I think you're describing a kind of Octree or Quadtree approach to culling the tree objects. Split map into pieces and discard all tree where a frustum test against a large piece shows it to be outside the frustum.
Yes, that is exactly where I am going to with my code.
What I really meant was - how are you performing the actual collisions with the trees and such? Presumably you are not testing against all polygons in the model but load a 'collision map' for objects in the level?
Ah, actual collisions tests.
if two particles passes all other tests (they are near, they are collidable etc), then I make calculations of theit plane (xz) distance and their vertical (y) distance. Knowing how big they are in x,y,z (some king of ellipsoid tests), it is not hard to do:
1 2 3 4
| if ((getPlaneDistanceFrom(p) < ((this.size.x + p.size.x))) && (getYDistanceFrom(p) < (this.size.y / 2 + p.size.y / 2))) { p.doCollision(this); this.doCollision(p); } |
i sthat what you are interested in?
I am too planning to add buildings and walls and such in my games and still don't know the best approach to do collisions with all those walls. My current tests are great for ellipsoid shapes only, im affraid.