Commit 4d3d14d0 authored by Johannes Braun's avatar Johannes Braun
Browse files

There is an error. I just don't know what's wrong.

parent 173ae34d
[Debug]
Pos=-1,0
Pos=-1,3
Size=353,64
Collapsed=0
[Scene]
Pos=-5,65
Pos=4,66
Size=352,837
Collapsed=0
[Settings]
Pos=1132,-3
Pos=1128,0
Size=311,899
Collapsed=0
<linespace version="1.0">
<item name="subdivisions" value="10"/>
<item name="subdivisions" value="6"/>
<item name="radial-subdivision" value="50"/>
<item name="generator" value="gpu"/>
</linespace>
......@@ -49,7 +49,11 @@ bool traverseObjects(const in Ray ray, const in bool use_first, const in float m
{
for(int ls = 0; ls < mesh.num_linespaces; ++ls)
{
if(mesh.traverseLineSpace(ls, ray.makeRelative(mesh), use_first, current_t, hit, t_min)){
Hit bla;
float mint = t_min;
if(mesh.traverseLineSpace(ls, ray.makeRelative(mesh), use_first, current_t, bla, mint) && mint < t_min){
hit = bla;
t_min = mint;
hit_triangle = true;
if (use_first)
{
......
......@@ -124,6 +124,11 @@ uint lineIndex(const in Ray ray, const in Mesh mesh, int ls_index, float tmin, f
uint start = (entry_info.patch_index.y + entry_info.patch_index.x * start_height) * end_width * end_height;
uint end = (exit_info.patch_index.y + exit_info.patch_index.x * end_height);
uint cunt = linespace.line_count;
if((offset + start+end) * 2 + 1 > cunt)
return 0;
return offset + start + end;
}
......@@ -140,20 +145,13 @@ bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, co
Ray loc = local_ray;
loc.origin += 0.05f * loc.direction;
float offset = -100.f;//-1.f;//compMin(mesh.linespace.patch_size);
Ray offset_ray = local_ray;
offset_ray.origin += local_ray.direction * offset;
if(!offset_ray.intersectsBounds(mesh.linespaces[index].bounds, tmin, tmax, face_tmin, face_tmax) || t_min <= tmin-offset || tmin-offset > max_distance)
if(!loc.intersectsBounds(mesh.linespaces[index].bounds, tmin, tmax, face_tmin, face_tmax) || t_min <= tmin || tmin > max_distance)
{
return false;
}
bool swapped = false;
uint line_id = lineIndex(offset_ray, mesh, index, tmin, tmax, face_tmin, face_tmax, swapped);
// if(line_id * 2 + 1 > mesh.linespaces[index].line_count)
// return false;
uint line_id = lineIndex(loc, mesh, index, tmin, tmax, face_tmin, face_tmax, swapped);
Line line_near = mesh.linespaces[index].lines[line_id * 2];
Line line_far = mesh.linespaces[index].lines[line_id * 2 + 1];
......@@ -168,7 +166,7 @@ bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, co
nearer.mesh = mesh.id;
if(loc.intersectsTrianglePlane(near_data, mesh, t, nearer.barycentric.x, nearer.barycentric.y))
{
float nearest_distance = t-offset;
float nearest_distance = t;
if(nearest_distance > 0 && max_distance > nearest_distance && t < t_min){
hit = nearer;
t_min = t;
......@@ -185,7 +183,7 @@ bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, co
nearer.mesh = mesh.id;
if(loc.intersectsTrianglePlane(near_data, mesh, t, nearer.barycentric.x, nearer.barycentric.y))
{
float farthest_distance = t-offset;
float farthest_distance = t;
if(farthest_distance > 0 && max_distance > farthest_distance && t < t_min){
hit = nearer;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment