Giant static forest

CookieMonster
Posts: 49
Joined: Sun Jan 29, 2012 10:01 pm

Giant static forest

Post by CookieMonster »

I have a giant forest with trees to collide with but just adding them as static rigid bodies gives poor performance because they are in the same broad phase as dynamic bodies.
Can I modify the height field class to return cones and other shapes from each tile in a low resolution grid?
If not, I could let the modified height field point to triangle shapes to transform per vertex but taking any shape would be more reusable.
DestroyerOfCities
Posts: 20
Joined: Fri Dec 10, 2010 3:39 am

Re: Giant static forest

Post by DestroyerOfCities »

wait, so are they all trimeshes right now?
CookieMonster
Posts: 49
Joined: Sun Jan 29, 2012 10:01 pm

Re: Giant static forest

Post by CookieMonster »

They are cone shapes with hand written dimensions right now. I have a list of triangles in the graphical model that I can read directly inside a collision shape but a cone shape would avoid multiplying each vertex with a transformation matrix each time they are used for collision.

My idea is to look up all shapes in the cells that overlap the query AABB and return all shapes who's AABB intersect with the dynamic body's AABB. The Query AABB is the dynamic body's world space AABB + tolerance for how much the static bodies are outside of their cells in the grid.
CookieMonster
Posts: 49
Joined: Sun Jan 29, 2012 10:01 pm

Re: Giant static forest

Post by CookieMonster »

Now when I have my debug drawing working, I see that the reason for the bad performance is invalid calculation of world space bounding boxes. Every tree's bounding box is stretched to the center of the world so that the tree for static bodies do nothing for the speed. I don't use compound shapes for the cones and I place them at their initial locations before adding them to the world.

Edit:
Calling setInterpolationWorldTransform after calling setWorldTransform with the same transformation when placing static bodies solved the bug. :)