I’ve a bit of an issue with getting Bullet to accommodate my scene graph and am currently seeking some kind of a solution for it. Basically, my game has a scene graph, where top-level structure is called “Region”. Regions have Neighbour nodes, which point to other Regions. Thus, the coordinates between Regions are relative and there can be multiple paths from an entity to root node such as Render.
The graph could look something like this:
| E |
| / |
‘A’ and ‘D’ are the top-level regions. ‘E’ is a neighbour node from ‘D’ that points to content of ‘A’ or ‘D’. Nodes ‘B’ and ‘F’ are merely to hold the direct contents of the region nodes. ‘E’ could point straight to ‘F’ and this is actually an intentional possibility in the game design and the source of some of these issues.
‘C’ and ‘H’ could be both renderable and collidable, with children nodes to handle both cases.
With Bullet, the effect I seem to get is somewhat similar to only one path to top-node being taken and sometimes it looks like nodes ended up duplicated somehow. The following code example showcases this: pastebin.com/rpFpQkcX There, change Line 35 from “node_B.reparentTo(render)” to “node_A.reparentTo(render)” to observe the difference between the two. To me, the natural cause seems that unlike what ends up to renderer (node_A vs. node_B), there’s no similarly changing intermediate root node with BulletWorld. Hence, BulletWorld has no frame of reference and no way to actually know which path to common top node it needed to use.
Far as I know about Bullet’s inner world – which is very little – these kind of multiple parent -things may not be very supportable by it. However, would they be, I’d be very excited to hear how!
But if it regardless turned out that Bullet can’t be made to bend well to my case, I see the following four options:
A) Create a BulletWorld per-region. - This is my least favorite choice, since it’d mean I have to manually select Regions that rays from camera can collide with, I’d have to manually handle moving objects between regions, the regions would also need to overlap so that they can affect each other, etc etc. Basically it’d mean I am doing things as if the P3D scene graph didn’t exist at all.
B) Manually transform RigidbodyNodes and do collisionPairTests. - Would be very performance-heavy and need some intermediate, manual optimizations.
C) Cook up custom collisions. - Yeah, right…
D) Switch to P3D’s own collisions. - Also problematic, since only Sphere is supported as the “From” shape and my objects don’t fit Spheres nicely. Building multiple spheres per-object would lead to either over-use of spheres or to uneven collision surfaces. One possible way would be implementing Box-to-Box and Polygon-to-Polygon collisions myself… But I don’t know the codebase very well.
None sounds very charming to me!
So… Any thoughts/ideas?