# BSP Leaf Finding (solved)

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

## 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]

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 13
• 19
• 14
• 9
• 9
• ### Forum Statistics

• Total Topics
632930
• Total Posts
3009290
• ### Who's Online (See full list)

There are no registered users currently online

×