Using TMap for a scene
BlitzMax Forums/BlitzMax Programming/Using TMap for a scene
| ||
I was thinking about using a TMap to store all objects in a scene. Every entity has a center position and a radius. I want a fast method of retrieving all entities within a bounding box. How would I use this with TMap? Obviously I could sort entities by position, and use 1 TMap for each axis. What about the radius? I would want to get all entities whose maximum extents lie within a bounding box, so then I would need 6 TMaps; one for the minimum extents on each axis, one for the max extents on each axis. Would this be slow? Is there a better way? Any comments on this? |
| ||
While your all thinking of how to answer Lead, could we also Explian in Noob terms what TMap is for at all. I understand the technical description, but cannot see a use for it over (say) TDoubleLinkedList. All the Pro programmers here seemed to think it important when Mark introduced it, yet I cannot see what use it is. |
| ||
Rather than a tmap can't you use something like this to check what's within range? Once you have a filtered list you could do a distance calculation on a small number of entities. <edit> Could each entity have a 'Entities_in_range' list checked when each entity moves? TBH, I'm guessing you're doing this in 3D-in-3D (rather than 2D-in-3D) and my mind still really only works with 2D grids. . H&K, you should really use your own topic but, in brief, read-up on Hash Tables for the gist as they're very similar. |
| ||
My terrain system got me thinking about using grids. I'm thinking about creating a big 3D texture of "blocks", and assigning an entity to one block. It's like an octree but simpler. Then you would just check the grid position directly, and return a list or something, like for all entities in point (x,y,z) do something. With an octree, you have a hierarchy you have to scan through to determine a point's cell. With this, you would just instantly retrieve that info, just like reading a pixmap. |