Skip to content

Commit 4ea0c37

Browse files
committed
My implementation of Jerome's pull request POV-Ray#358.
Fix for issues POV-Ray#121, POV-Ray#125 and several related newsgroup reports as well. Mostly it restores 3.6 behavior with respect to intersection depths filtered. Note! Scenes using photons will often run slower and look somewhat different due additional photons being deposited. This includes our benchmark scene.
1 parent 75ddd88 commit 4ea0c37

File tree

3 files changed

+24
-32
lines changed

3 files changed

+24
-32
lines changed

source/core/configcore.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/// @parblock
1111
///
1212
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
13-
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
13+
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
1414
///
1515
/// POV-Ray is free software: you can redistribute it and/or modify
1616
/// it under the terms of the GNU Affero General Public License as
@@ -192,14 +192,6 @@
192192
///
193193
#define MAX_DISTANCE 1.0e7
194194

195-
/// @def MIN_ISECT_DEPTH
196-
/// Minimum distance that qualifies as ray-object intersection.
197-
///
198-
/// @note
199-
/// Some algorithms use @ref SMALL_TOLERANCE instead.
200-
///
201-
#define MIN_ISECT_DEPTH 1.0e-4
202-
203195
/// @}
204196
///
205197
//******************************************************************************

source/core/render/trace.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/// @parblock
99
///
1010
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
11-
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
11+
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
1212
///
1313
/// POV-Ray is free software: you can redistribute it and/or modify
1414
/// it under the terms of the GNU Affero General Public License as
@@ -365,8 +365,8 @@ bool Trace::FindIntersection(ObjectPtr object, Intersection& isect, const Ray& r
365365
while(depthstack->size() > 0)
366366
{
367367
tmpDepth = depthstack->top().Depth;
368-
// TODO FIXME - This was SMALL_TOLERANCE, but that's too rough for some scenes [cjc] need to check what it was in the old code [trf]
369-
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH))
368+
POV_ASSERT(tmpDepth > 0.0); // Shape code should never return intersections <= 0.0.
369+
if (tmpDepth < closest)
370370
{
371371
isect = depthstack->top();
372372
closest = tmpDepth;
@@ -418,8 +418,8 @@ bool Trace::FindIntersection(ObjectPtr object, Intersection& isect, const Ray& r
418418
while(depthstack->size() > 0)
419419
{
420420
tmpDepth = depthstack->top().Depth;
421-
// TODO FIXME - This was SMALL_TOLERANCE, but that's too rough for some scenes [cjc] need to check what it was in the old code [trf]
422-
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH) && postcondition(ray, object, tmpDepth))
421+
POV_ASSERT(tmpDepth > 0.0); // Shape code should never return intersections <= 0.0.
422+
if (tmpDepth < closest && postcondition(ray, object, tmpDepth))
423423
{
424424
isect = depthstack->top();
425425
closest = tmpDepth;

source/core/scene/object.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/// @parblock
99
///
1010
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
11-
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
11+
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
1212
///
1313
/// POV-Ray is free software: you can redistribute it and/or modify
1414
/// it under the terms of the GNU Affero General Public License as
@@ -136,8 +136,8 @@ bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, Tr
136136
while(depthstack->size() > 0)
137137
{
138138
tmpDepth = depthstack->top().Depth;
139-
// TODO FIXME - This was SMALL_TOLERANCE, but that's too rough for some scenes [cjc] need to check what it was in the old code [trf]
140-
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH))
139+
POV_ASSERT(tmpDepth < 0.0); // Shape code should never return intersections <= 0.0
140+
if (tmpDepth < closest)
141141
{
142142
*isect = depthstack->top();
143143
closest = tmpDepth;
@@ -190,8 +190,8 @@ bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, co
190190
while(depthstack->size() > 0)
191191
{
192192
tmpDepth = depthstack->top().Depth;
193-
// TODO FIXME - This was SMALL_TOLERANCE, but that's too rough for some scenes [cjc] need to check what it was in the old code [trf]
194-
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH) && postcondition(ray, object, tmpDepth))
193+
POV_ASSERT(tmpDepth < 0.0); // Shape code should never return intersections <= 0.0
194+
if (tmpDepth < closest && postcondition(ray, object, tmpDepth))
195195
{
196196
*isect = depthstack->top();
197197
closest = tmpDepth;
@@ -236,8 +236,8 @@ bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, BB
236236
while(depthstack->size() > 0)
237237
{
238238
tmpDepth = depthstack->top().Depth;
239-
// TODO FIXME - This was SMALL_TOLERANCE, but that's too rough for some scenes [cjc] need to check what it was in the old code [trf]
240-
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH))
239+
POV_ASSERT(tmpDepth < 0.0); // Shape code should never return intersections <= 0.0
240+
if (tmpDepth < closest)
241241
{
242242
*isect = depthstack->top();
243243
closest = tmpDepth;
@@ -282,8 +282,8 @@ bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, BB
282282
while(depthstack->size() > 0)
283283
{
284284
tmpDepth = depthstack->top().Depth;
285-
// TODO FIXME - This was SMALL_TOLERANCE, but that's too rough for some scenes [cjc] need to check what it was in the old code [trf]
286-
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH) && postcondition(ray, object, tmpDepth))
285+
POV_ASSERT(tmpDepth < 0.0); // Shape code should never return intersections <= 0.0
286+
if (tmpDepth < closest && postcondition(ray, object, tmpDepth))
287287
{
288288
*isect = depthstack->top();
289289
closest = tmpDepth;
@@ -903,25 +903,25 @@ ObjectPtr CompoundObject::Invert()
903903

904904
bool ObjectBase::Intersect_BBox(BBoxDirection variant, const BBoxVector3d& origin, const BBoxVector3d& invdir, BBoxScalar maxd) const
905905
{
906-
// TODO FIXME - This was SMALL_TOLERANCE, but that's too rough for some scenes [cjc] need to check what it was in the old code [trf]
906+
// reverted to SMALL_TOLERANCE over v3.7 MIN_ISECT_DEPTH, for FS324 [jg] old code [trf]
907907
switch(variant)
908908
{
909909
case BBOX_DIR_X0Y0Z0: // 000
910-
return Intersect_BBox_Dir<0, 0, 0>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
910+
return Intersect_BBox_Dir<0, 0, 0>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
911911
case BBOX_DIR_X0Y0Z1: // 001
912-
return Intersect_BBox_Dir<0, 0, 1>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
912+
return Intersect_BBox_Dir<0, 0, 1>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
913913
case BBOX_DIR_X0Y1Z0: // 010
914-
return Intersect_BBox_Dir<0, 1, 0>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
914+
return Intersect_BBox_Dir<0, 1, 0>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
915915
case BBOX_DIR_X0Y1Z1: // 011
916-
return Intersect_BBox_Dir<0, 1, 1>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
916+
return Intersect_BBox_Dir<0, 1, 1>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
917917
case BBOX_DIR_X1Y0Z0: // 100
918-
return Intersect_BBox_Dir<1, 0, 0>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
918+
return Intersect_BBox_Dir<1, 0, 0>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
919919
case BBOX_DIR_X1Y0Z1: // 101
920-
return Intersect_BBox_Dir<1, 0, 1>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
920+
return Intersect_BBox_Dir<1, 0, 1>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
921921
case BBOX_DIR_X1Y1Z0: // 110
922-
return Intersect_BBox_Dir<1, 1, 0>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
922+
return Intersect_BBox_Dir<1, 1, 0>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
923923
case BBOX_DIR_X1Y1Z1: // 111
924-
return Intersect_BBox_Dir<1, 1, 1>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
924+
return Intersect_BBox_Dir<1, 1, 1>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
925925
}
926926

927927
return false; // unreachable

0 commit comments

Comments
 (0)