Multiple spatial data structures

Started by
1 comment, last by Pilpel 8 years, 4 months ago
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
    Mesh *mesh = manager.meshCache()->loadObject("skeleton.mesh");


    SceneNode *skelNode = rootNode->addChildNode("skeleton node");


    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?
Advertisement
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.

Sean Middleditch – Game Systems Engineer – Join my team!

Should I hide the BVH implementation in the SceneManager class (meaning the user will only care about creating scene nodes) or should I let the user play a role in creating the BVH hierarchy?

I really have no clue about this, if there's no definite answer then your opinion will do as well.

This topic is closed to new replies.

Advertisement