Pointer != Pointer
Ok I''ve been working on some boundingbox code to make my 3d models follow the contours of the ground....At the start of the loop I test two variables to see if I need to recalculate anything.
BottomCenter, and TopCenter are pointers to a D3DVERTEX struct.
PHYSICSCLASS* Ground = cLand->ObjBase;
if (BottomCenter->y != Ground->TopCenter->y)
{
...
}
The first time that BottomCenter->y and TopCenter->y are equal the loop still executes anyways....but the next time that they''re the same it doesn''t. Does this have something to do with the fact that they''re pointers? I''ve tried dereferencing them but it doesn''t seem to make any difference, the loop still gets executed the first time the values are equal.
If you are comparing floating point values they may seem to be equal, but aren''t actually equal due to rounding error. Perhaps there is an error in the way that you are setting the two y values. The fact that you are using pointers doesn''t seem like it would make a difference in this case.
If you are having float rounding problems you can try to change the test to something like this:
if (abs(BottomCenter->y - Ground->TopCenter->y) > 0.001)
// or some other 'small' number
{
...
}
Hope that helps
Edited by - chippydip on May 26, 2000 11:49:25 AM
if (abs(BottomCenter->y - Ground->TopCenter->y) > 0.001)
// or some other 'small' number
{
...
}
Hope that helps
Edited by - chippydip on May 26, 2000 11:49:25 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement