Originally Posted by
cronodragon
You are right! The author has a note about that division by zero problem. I just translated the content of the book, but haven't deeply tested it. There is a entire chapter at the end of the book dealing with those errors. It uses integer arithmetic, this is my new translation:
[pascal]function ch_IntersecaSegmentoPlano(
...
end;[/pascal]
Please let me know if it works for you, I don't want to have that bug in my code neither.
I have few questions to make it work. What does gr_rPlano3D type contain? How do i use its .PP variable? And why int64 instead of floating point single?
Edit: Oh, think it has 2 vectors in it, N for normal and PP for position
paul_nicholls, thanks, downloaded source from tutorial and found this:
Code:
int PlanePrim::Intersect( Ray& a_Ray, float& a_Dist )
{
float d = DOT( m_Plane.N, a_Ray.GetDirection() );
if (d != 0)
{
float dist = -(DOT( m_Plane.N, a_Ray.GetOrigin() ) + m_Plane.D) / d;
if (dist > 0)
{
if (dist < a_Dist)
{
a_Dist = dist;
return HIT;
}
}
}
return MISS;
}
Will let know how it works out.
And finally, of course the error can be in my test app, but i refuse to believe it
Bookmarks