• Advertisement
Sign in to follow this  

BSP Leaf Finding (solved)

This topic is 3958 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
    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]
      i := Node.Children[1];

  //  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
Sign in to follow this  

  • Advertisement