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] [Debug]
Pos=-1,0 Pos=-1,3
Size=353,64 Size=353,64
Collapsed=0 Collapsed=0
[Scene] [Scene]
Pos=-5,65 Pos=4,66
Size=352,837 Size=352,837
Collapsed=0 Collapsed=0
[Settings] [Settings]
Pos=1132,-3 Pos=1128,0
Size=311,899 Size=311,899
Collapsed=0 Collapsed=0
<linespace version="1.0"> <linespace version="1.0">
<item name="subdivisions" value="10"/> <item name="subdivisions" value="6"/>
<item name="radial-subdivision" value="50"/> <item name="radial-subdivision" value="50"/>
<item name="generator" value="gpu"/> <item name="generator" value="gpu"/>
</linespace> </linespace>
...@@ -49,7 +49,11 @@ bool traverseObjects(const in Ray ray, const in bool use_first, const in float m ...@@ -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) 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; hit_triangle = true;
if (use_first) if (use_first)
{ {
......
...@@ -124,6 +124,11 @@ uint lineIndex(const in Ray ray, const in Mesh mesh, int ls_index, float tmin, f ...@@ -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 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 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; return offset + start + end;
} }
...@@ -140,20 +145,13 @@ bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, co ...@@ -140,20 +145,13 @@ bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, co
Ray loc = local_ray; Ray loc = local_ray;
loc.origin += 0.05f * loc.direction; loc.origin += 0.05f * loc.direction;
float offset = -100.f;//-1.f;//compMin(mesh.linespace.patch_size); if(!loc.intersectsBounds(mesh.linespaces[index].bounds, tmin, tmax, face_tmin, face_tmax) || t_min <= tmin || tmin > max_distance)
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)
{ {
return false; return false;
} }
bool swapped = false; bool swapped = false;
uint line_id = lineIndex(offset_ray, mesh, index, tmin, tmax, face_tmin, face_tmax, swapped); uint line_id = lineIndex(loc, mesh, index, tmin, tmax, face_tmin, face_tmax, swapped);
// if(line_id * 2 + 1 > mesh.linespaces[index].line_count)
// return false;
Line line_near = mesh.linespaces[index].lines[line_id * 2]; Line line_near = mesh.linespaces[index].lines[line_id * 2];
Line line_far = mesh.linespaces[index].lines[line_id * 2 + 1]; 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 ...@@ -168,7 +166,7 @@ bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, co
nearer.mesh = mesh.id; nearer.mesh = mesh.id;
if(loc.intersectsTrianglePlane(near_data, mesh, t, nearer.barycentric.x, nearer.barycentric.y)) 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){ if(nearest_distance > 0 && max_distance > nearest_distance && t < t_min){
hit = nearer; hit = nearer;
t_min = t; t_min = t;
...@@ -185,7 +183,7 @@ bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, co ...@@ -185,7 +183,7 @@ bool traverseLineSpace(const in Mesh mesh, int index, const in Ray local_ray, co
nearer.mesh = mesh.id; nearer.mesh = mesh.id;
if(loc.intersectsTrianglePlane(near_data, mesh, t, nearer.barycentric.x, nearer.barycentric.y)) 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){ if(farthest_distance > 0 && max_distance > farthest_distance && t < t_min){
hit = nearer; 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