Skip to main content
gamedev.net
🔒 Locked

Spatial structures

Started by schupf Sep 9, 2011 at 8:02 AM 0 replies 1k views
Original Post
schupf
schupf
Hello!

I have some simple questions about spatial structures:

1) Who should be responsible for creating the BVH? Take a look at this picture: http://www.cs.princeton.edu/courses/archive/fall00/cs426/lectures/raycast2/img007.gif
As you can see there are 3 clusters of object (Nodes 2,3 and C). Who should specify these nodes 2,3 and C? Should an artist/modeler (who places the objects) specify the nodes? Or should the engine automatically find the nodes?

2) Is a 3D Quadtree (a quadtree where each node is an AABB rather than a rectangle) a good structure for ray picking?

3) Obviously I have all static objects (trees etc) in my AABB Quadtree. Should I also add the dynamic/moving objects (i.e. the player) in the quadtree and update the position every frame? Or should I exclude moving objects from the AABB Quadtree?

Thanks:)
All8Up
All8Up

Hello!

I have some simple questions about spatial structures:

1) Who should be responsible for creating the BVH? Take a look at this picture: http://www.cs.prince...ast2/img007.gif
As you can see there are 3 clusters of object (Nodes 2,3 and C). Who should specify these nodes 2,3 and C? Should an artist/modeler (who places the objects) specify the nodes? Or should the engine automatically find the nodes?

The engine at work uses the manual artist controlled system and all I can say is that it is a major cause of problems without much benefit. As such, I highly suggest a simple realtime system and an octree (or variation) is your best bet.



2) Is a 3D Quadtree (a quadtree where each node is an AABB rather than a rectangle) a good structure for ray picking?

This is going to be related to your game requirements more than anything else. If you are doing a FPS type shooter it may be perfect and the simplicity will be a benefit. On the other hand, if the FPS includes buildings you want to be able to run around in and they contained lots of entities on different floors, everything would clump into one or two nodes and you would end up not getting much benefit from the structure in such a case. Honestly, I'd just start with a simple octree and not worry about it until it starts showing up in performance profiles. If/when it starts showing up, what I say below may be a decent rule of thumb sort of starting point at evaluating other options.


3) Obviously I have all static objects (trees etc) in my AABB Quadtree. Should I also add the dynamic/moving objects (i.e. the player) in the quadtree and update the position every frame? Or should I exclude moving objects from the AABB Quadtree?

This is another game specific item really. Assuming you have only a few dynamic objects you may not need anything more than a simple distance sorted list to handle the dynamic objects and you just go through both the static structure and the dynamic list looking for intersections. If on the other hand you have hundreds of objects, keeping them in the same structure with your static objects starts to make sense. Finally, for thousands of objects you may want to go to an even more dynamic system such as Ratcliff's sphere tree or my preferred system of using a sweep and prune system for it's stable performance under most conditions. Given that I like a lot of ambient AI objects running around to keep things busy (I.e. just for looks/fun) I almost always end up with the sweep and prune system, but I almost always start with the simple octree until I prove that it is becoming a performance problem. (Why not just start with sweep and prune? Because it is a more specialized structure which has certain limits you have to avoid, the octree is more generic and doesn't put any constraints on the system up front.)

Hope this gives you some ideas.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.