Jump to content
  • Advertisement
Sign in to follow this  
Rimio

BSP Leaf Finding (solved)

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

Hello ! I'm trying to find the leaf of a BSP the camera is in. Here's my code
  //  Find node
  i := 0;
  while (i >= 0) do
   begin
    Node := fNodes;
    Plane := fPlanes[Node.Plane];

    Distance := Plane.Normal[0] * pos[0] +
                Plane.Normal[1] * pos[1] +
                Plane.Normal[2] * pos[2] - Plane.Distance;

    if (Distance >= 0) then
      i := Node.Children[0]
     else
      i := Node.Children[1];
   end;

  //  Return
  Result := -(i+1);
It doesn't work since for most leafs the cluster is -1 which means the camera is outside of the map. I suspect this is the code that is failing. Any ideeas? PS: version 46 BSP (Quake 3) EDIT: I solved this a few days ago. It was actually an error when switching axes of the plane normals (I was doing something like "aux = n[1]; n[2][1] = n[2]; n[2] = -aux"; Note the 2 instead of an i :) ). That was it ... stupid error. Stupid stupid error. [Edited by - Rimio on May 28, 2007 12:54:13 AM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • 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!