Commit 319bdb49 authored by Frédéric Larue's avatar Frédéric Larue

Bug fixed in the ray/box intersection computation function.

parent 455e0ca9
...@@ -658,30 +658,32 @@ inline bool Box3f::Intersects( const QVector3D& rayOrigin, ...@@ -658,30 +658,32 @@ inline bool Box3f::Intersects( const QVector3D& rayOrigin,
intersectionDist = std::numeric_limits<float>::max(); intersectionDist = std::numeric_limits<float>::max();
for( int i=0; i<3; ++i ) for( int i=0; i<3; ++i )
{ if( rayDirection[i] != 0.0f )
float frontFacingPlane = (rayDirection[i] > 0.0f)? m_Max[i] : m_Min[i];
float t = (frontFacingPlane - rayOrigin[i]) / rayDirection[i];
if( t < intersectionDist )
{ {
intersectionDist = t; float frontFacingPlane = (rayDirection[i] > 0.0f)? m_Max[i] : m_Min[i];
intersectionPlaneId = i; float t = (frontFacingPlane - rayOrigin[i]) / rayDirection[i];
if( t < intersectionDist )
{
intersectionDist = t;
intersectionPlaneId = i;
}
} }
}
} }
else else
{ {
intersectionDist = 0.0f; intersectionDist = 0.0f;
for( int i=0; i<3; ++i ) for( int i=0; i<3; ++i )
{ if( rayDirection[i] != 0.0f )
float frontFacingPlane = (rayDirection[i] > 0.0f)? m_Min[i] : m_Max[i];
float t = (frontFacingPlane - rayOrigin[i]) / rayDirection[i];
if( t > intersectionDist )
{ {
intersectionDist = t; float frontFacingPlane = (rayDirection[i] > 0.0f)? m_Min[i] : m_Max[i];
intersectionPlaneId = i; float t = (frontFacingPlane - rayOrigin[i]) / rayDirection[i];
if( t > intersectionDist )
{
intersectionDist = t;
intersectionPlaneId = i;
}
} }
}
} }
if( intersectionPlaneId < 0 ) if( intersectionPlaneId < 0 )
......
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