Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Float hell

This topic is 5329 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys, I''m ~75% done with my first BSP tree! I currently only have one problem- For some reason when I use the D3DXPlaneDotCoord function and I pass it a vertex that *lies on the plane* it''ll return -0.00000f or 0.00000f, which when compared to 0.0f with the equality operator it will return false. I thought it might have been the function so I wrote my own which frustratingly enough returns the same result. I use this function to determine which side of the plane the vertices of a face are on so I can send it to the left or right as needed. Without being able to compare the dot product I can''t determine which side a face should goto. Does anyone know why this is occurring or how I can detect/fix it properly?

Share this post

Link to post
Share on other sites
It''s generally a bad idea to compare floating point numbers with the equality operator. Floating point numbers are not exact.

Instead, make sure the absolute value of their difference is below a certain threshhold, which is commonly referred to as "epsilon". 1e-5 is a pretty good epsilon value for many common uses, but you may want to change it if your numbers are very low or high.

"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!