• 9
• 10
• 11
• 14
• 9

# Multiple spatial data structures

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

## Recommended Posts

I'm in a bit frustrating dead end as I try to implement a BVH in my framework mainly for ray tracing and secondary for occlusion culling.

I already have a Scene Node system (a Scene Graph) and it works quite well with animations too. Every SceneNode has local and global transformations, children, and may also have: - A Mesh object that can be rendered. - A surrounding bounding volume (AABB, sphere).

The way I render stuff is as follows:

//global scope
SceneManager manager;
Camera *myCamera;

void init()
{
myCamera = manager.cameraCache()->loadObject("player camera"); //create a camera object and name it "player camera"

SceneNode *rootNode = manager.sceneGraph()->rootSceneNode(); //for fast access

manager.attachMeshToSceneNode(skelNode, mesh);

if(iWantToPlayAnAnimation)
manager.animationController()->playAnimation(skelNode, "attack");
}

void render() //this is set as the render method in glut
{
manager.drawFrame(myCamera);
}
As you can see I use scene nodes as "keys" as well for my animationController class. (the key above is skelNode)

Now my problem is that I'm not sure how to mix my scene graph and the new BVH. Can you suggest a good approach on this? Anything else you see wrong in my system?

As a side question:
I'm not even sure BVH is the hierarchy I want. I'm not after any fancy collision detection algorithms for many objects. (just my character).
Is BVH the favorite for this situation?
Edited by Pilpel

##### Share on other sites
It's quite common to have multiple structures.

"Scene Graph" in a traditional sense isn't used a whole a lot anymore and the modern ones are basically just transform hierarchies. They literally zero useful purpose besides making it fast to update hierarchies of connected objects and animations, and the latter is often special-cased for speed.

A typical approach then is to have your transform hierarchy in one structure and the BVH in another. The BVH just references the scene nodes/transforms stored in the hierarchy (e.g. using pointers or indices).

You may even have multiple forms of BVH or other structure, as some are best for doing broad-phase culling, others are good for ray casts, and yet others are good for "find nearby objects" queries for AI and the like. Some games do all of those with one structure, some break them up into separate ones.