BSPNodes and efficiency

I would like BSP nodes to extend nodes (or at least spatials). The problem is that Spatials have both worldtransform and localtransform. These two are unneeded and basicly a waste. BSP nodes aren’t transformed mid tree. Maybe the root of the BSP tree takes some transformation but the nodes themselves don’t. Not all spatials need the bloat of localXXX. For a bsp tree, that’s a lot of computation/memory that’s not needed.



And actually, not all BSP nodes need a bounding volume. I’ve talked to a few graphics programmers about writting BSP tree code and they said Bounding Volumes weren’t introduced at each level of the BSP tree because it would be too inefficient, and I kind of agree. Bounding Volumes were only used at specific levels.



And if I make BSP nodes extend Node, all the regular “node” accessing functions mess up the order BSP nodes need their children to be in. So to make it complete I’ld be overwriting all of Node’s children access functions to make sure they don’t mess up the BSP. That doesn’t seem very OOP like, to have a parent class that is a parent only in name.



Ugh the ligistics are killing me. I’ve got it coded up and it seems to work, but I’m just not sure how this should “best” fit.



Any ideas?

Renanse and I have been discussing the memory usage of Spatials et al, and have basically come with a plan for the next couple releases. I’m going to write something up soon, but your concerns will be addressed with our ideas. Until then, do your best to work with what’s there and just try to swallow the memory usage, we are going to take care of it. :slight_smile:

And if I make BSP nodes extend Node, all the regular "node" accessing functions mess up the order BSP nodes need their children to be in. So to make it complete I'ld be overwriting all of Node's children access functions to make sure they don't mess up the BSP. That doesn't seem very OOP like, to have a parent class that is a parent only in name.


Should BSPNode extend Spatial then? Or did you have something else in mind?

BSPTree extends Spatial and BSPNode is it’s own little class?

How would you put items in the level if each node was a seperate class? This is truely me just asking, as I know very little about BSPs.



If you had a BSPTree with BSPNodes (extending spatials), then I could add a monster to a node that contains a room (attachChild). How would I do it if the entire tree is a single spatial? Again, BSPs might not even be set up to give you access to "rooms" or whatever, so that may be irrelevant.

@cep: BSPTree is a class to do the partitioning, whereas BSPNode holds the two (three) children plus the splitting plane, as in the wild magic examples?



@mojo: you don’t place moving objects into the bsp tree, afaik. You would always have to redistribute and recalculate the tree as it may change - this would kill the frame rate. It is an np complete problem, which means the time it takes can not be described by a polynomial function of the number of meshes it has to separate, it rather will be an exponential function.



Generally: As I understood this, you build the bsp tree for the static objects, but merely to optimize the partitioning of your world for finding out, which region you are in - from where you then can find out, which other regions are visible. Additionally you can use this to optimise collision detections. Therefore normally the bsp tree is not a fully developed tree (ending in single triangles) but one whose leafs are convex regions. At least thats what every map compiler I have looked at delivers to you.



That is why I thought that you’d have your static map reside in a single node (a map node, bsp root node, whatever) and the bsp tree is an internal mechanism of this, which helps find the cam position in the map etc.