Skip to content

Commit d840b26

Browse files
committed
Fixing photon ray first intersection filters for lemon/ovus.
Details in the github pull POV-Ray#358 request discussion thread. See especially comments made in April of 2019. Note, this fixes only one of a layered set of reasons photon rays can bleed through all or part of ovus and lemon shapes.
1 parent af9f282 commit d840b26

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

source/core/shape/lemon.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ namespace pov
6767
// as it is used only with low power, precision can be high
6868
const DBL Lemon_Tolerance = 1.0e-10;
6969

70-
// Tolerance used while selecting from solver returned roots.
71-
// TODO FIXME - can we use EPSILON or a similar more generic constant instead?
72-
const DBL ROOT_TOLERANCE = 1.0e-4;
73-
7470

7571
/*****************************************************************************
7672
*
@@ -221,9 +217,9 @@ int Lemon::Intersect(const Vector3d& P, const Vector3d& D, LEMON_INT *Intersecti
221217
vertical = Ipoint[Z];
222218
if ((vertical >= 0.0) && (vertical <= 1.0))
223219
{
220+
DBL effectiveIRadius = sqrt(Sqr(Ipoint[X]) + Sqr(Ipoint[Y]) + Sqr(Ipoint[Z]-VerticalPosition));
224221
horizontal = sqrt(Sqr(Ipoint[X]) + Sqr(Ipoint[Y]));
225-
OCSquared = Sqr((horizontal - HorizontalPosition)) + Sqr((vertical - VerticalPosition));
226-
if (fabs(OCSquared - r2 ) < ROOT_TOLERANCE)
222+
if (effectiveIRadius < inner_radius)
227223
{
228224
Intersection[i].d = r[n];
229225
INormal = Ipoint;

source/core/shape/ovus.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ void Ovus::Intersect_Ovus_Spheres(const Vector3d& P, const Vector3d& D,
226226
vertical = IPoint[Y];
227227
if ((vertical > BottomVertical) && (vertical < TopVertical))
228228
{
229+
DBL effectiveIRadius = sqrt(Sqr(IPoint[X]) + Sqr(IPoint[Y]-VerticalPosition) + Sqr(IPoint[Z]));
229230
horizontal = sqrt(Sqr(IPoint[X]) + Sqr(IPoint[Z]));
230-
OCSquared = Sqr((horizontal + HorizontalPosition)) + Sqr((vertical - VerticalPosition));
231-
if (fabs(OCSquared - Sqr(ConnectingRadius)) < RootTolerance)
231+
if (effectiveIRadius < ConnectingRadius)
232232
{
233233
if (*Depth5 < 0)
234234
{

0 commit comments

Comments
 (0)