Skip to content

Commit

Permalink
My implementation of Jerome's pull request POV-Ray#358.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wfpokorny committed Feb 17, 2019
1 parent 75ddd88 commit 4ea0c37
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 32 deletions.
10 changes: 1 addition & 9 deletions source/core/configcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
///
/// POV-Ray is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -192,14 +192,6 @@
///
#define MAX_DISTANCE 1.0e7

/// @def MIN_ISECT_DEPTH
/// Minimum distance that qualifies as ray-object intersection.
///
/// @note
/// Some algorithms use @ref SMALL_TOLERANCE instead.
///
#define MIN_ISECT_DEPTH 1.0e-4

/// @}
///
//******************************************************************************
Expand Down
10 changes: 5 additions & 5 deletions source/core/render/trace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
///
/// POV-Ray is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -365,8 +365,8 @@ bool Trace::FindIntersection(ObjectPtr object, Intersection& isect, const Ray& r
while(depthstack->size() > 0)
{
tmpDepth = depthstack->top().Depth;
// 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]
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH))
POV_ASSERT(tmpDepth > 0.0); // Shape code should never return intersections <= 0.0.
if (tmpDepth < closest)
{
isect = depthstack->top();
closest = tmpDepth;
Expand Down Expand Up @@ -418,8 +418,8 @@ bool Trace::FindIntersection(ObjectPtr object, Intersection& isect, const Ray& r
while(depthstack->size() > 0)
{
tmpDepth = depthstack->top().Depth;
// 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]
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH) && postcondition(ray, object, tmpDepth))
POV_ASSERT(tmpDepth > 0.0); // Shape code should never return intersections <= 0.0.
if (tmpDepth < closest && postcondition(ray, object, tmpDepth))
{
isect = depthstack->top();
closest = tmpDepth;
Expand Down
36 changes: 18 additions & 18 deletions source/core/scene/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// @parblock
///
/// Persistence of Vision Ray Tracer ('POV-Ray') version 3.8.
/// Copyright 1991-2018 Persistence of Vision Raytracer Pty. Ltd.
/// Copyright 1991-2019 Persistence of Vision Raytracer Pty. Ltd.
///
/// POV-Ray is free software: you can redistribute it and/or modify
/// it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -136,8 +136,8 @@ bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, Tr
while(depthstack->size() > 0)
{
tmpDepth = depthstack->top().Depth;
// 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]
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH))
POV_ASSERT(tmpDepth < 0.0); // Shape code should never return intersections <= 0.0
if (tmpDepth < closest)
{
*isect = depthstack->top();
closest = tmpDepth;
Expand Down Expand Up @@ -190,8 +190,8 @@ bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, co
while(depthstack->size() > 0)
{
tmpDepth = depthstack->top().Depth;
// 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]
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH) && postcondition(ray, object, tmpDepth))
POV_ASSERT(tmpDepth < 0.0); // Shape code should never return intersections <= 0.0
if (tmpDepth < closest && postcondition(ray, object, tmpDepth))
{
*isect = depthstack->top();
closest = tmpDepth;
Expand Down Expand Up @@ -236,8 +236,8 @@ bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, BB
while(depthstack->size() > 0)
{
tmpDepth = depthstack->top().Depth;
// 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]
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH))
POV_ASSERT(tmpDepth < 0.0); // Shape code should never return intersections <= 0.0
if (tmpDepth < closest)
{
*isect = depthstack->top();
closest = tmpDepth;
Expand Down Expand Up @@ -282,8 +282,8 @@ bool Find_Intersection(Intersection *isect, ObjectPtr object, const Ray& ray, BB
while(depthstack->size() > 0)
{
tmpDepth = depthstack->top().Depth;
// 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]
if(tmpDepth < closest && (ray.IsSubsurfaceRay() || tmpDepth >= MIN_ISECT_DEPTH) && postcondition(ray, object, tmpDepth))
POV_ASSERT(tmpDepth < 0.0); // Shape code should never return intersections <= 0.0
if (tmpDepth < closest && postcondition(ray, object, tmpDepth))
{
*isect = depthstack->top();
closest = tmpDepth;
Expand Down Expand Up @@ -903,25 +903,25 @@ ObjectPtr CompoundObject::Invert()

bool ObjectBase::Intersect_BBox(BBoxDirection variant, const BBoxVector3d& origin, const BBoxVector3d& invdir, BBoxScalar maxd) const
{
// 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]
// reverted to SMALL_TOLERANCE over v3.7 MIN_ISECT_DEPTH, for FS324 [jg] old code [trf]
switch(variant)
{
case BBOX_DIR_X0Y0Z0: // 000
return Intersect_BBox_Dir<0, 0, 0>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
return Intersect_BBox_Dir<0, 0, 0>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
case BBOX_DIR_X0Y0Z1: // 001
return Intersect_BBox_Dir<0, 0, 1>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
return Intersect_BBox_Dir<0, 0, 1>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
case BBOX_DIR_X0Y1Z0: // 010
return Intersect_BBox_Dir<0, 1, 0>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
return Intersect_BBox_Dir<0, 1, 0>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
case BBOX_DIR_X0Y1Z1: // 011
return Intersect_BBox_Dir<0, 1, 1>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
return Intersect_BBox_Dir<0, 1, 1>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
case BBOX_DIR_X1Y0Z0: // 100
return Intersect_BBox_Dir<1, 0, 0>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
return Intersect_BBox_Dir<1, 0, 0>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
case BBOX_DIR_X1Y0Z1: // 101
return Intersect_BBox_Dir<1, 0, 1>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
return Intersect_BBox_Dir<1, 0, 1>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
case BBOX_DIR_X1Y1Z0: // 110
return Intersect_BBox_Dir<1, 1, 0>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
return Intersect_BBox_Dir<1, 1, 0>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
case BBOX_DIR_X1Y1Z1: // 111
return Intersect_BBox_Dir<1, 1, 1>(BBox, origin, invdir, MIN_ISECT_DEPTH, maxd);
return Intersect_BBox_Dir<1, 1, 1>(BBox, origin, invdir, SMALL_TOLERANCE, maxd);
}

return false; // unreachable
Expand Down

0 comments on commit 4ea0c37

Please sign in to comment.