Jump to content
  • Advertisement


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



This topic is 6250 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

This procedure is giving me an headache. Could somebody tell me what is wrong with it?
TXPPlane = record
  m_normal: TD3DXVector3;
  m_distance: Single;

procedure PlaneNormalize(P: TXPPlane);
  denom: Single;
  sq: Single;
  with P do
    sq := sqrt(sqr(m_normal.x) + sqr(m_normal.y) + sqr(m_normal.z));
    denom := 1 / sq; // This is where the error happens.
    m_normal.x := m_normal.x * denom;
    m_normal.y := m_normal.y * denom;
    m_normal.z := m_normal.z * denom;
    m_distance := m_distance * denom;
Is there any other way?

Share this post

Link to post
Share on other sites
That seems like a very unusual error to call there...

Have you tried:
denom := 1 / sqrt(sqr(m_normal.x) + sqr(m_normal.y) + sqr(m_normal.z));

(just in case)

alternatively... - if you ensure that the plane normals are normalized on creation (are unitvectors) - then you can save yourself the trouble of normalizing the plane at later times. Oh wait... I think thatZ what ur trying to do...

But if you ensure that the vectors that you use to get plane normals are already unitvectors (normalized) then the resultant plane normals are already normalized after you use the crossproduct to compute them. That might be worthwhile lookin into.

Check if there is an "invert" function; and replace 1/sq with inv(sq) [might be possible] - or try writing an explicit invert function if that fails.


Share this post

Link to post
Share on other sites
What is the value of sq at crash?
(if unavailable, check the values of m_normal)

A "NAN" could perhaps trigger and EInvalidOp. You can get a NAN after a divison by zero with FPU exceptions masked, if you have a wild pointer, memory overwrites, etc. Which means that the issue is not here, it just pops up here, but damage is done elsewhere...

Eric Grange

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!