Terrain or static triangle

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Terrain or static triangle

Post by imtrobin »

Hi,

I like to ask if there is a performance difference for using Terrain or static triangle? Currently I'm using triangle mesh for terrain directly instead of heightmap, so I like to ask if there is a disadvantage of using static triangle. Terrain size is 10km, around 20K vertices, on a very low end specs.
Danthekilla
Posts: 136
Joined: Sun Jan 17, 2010 11:35 am

Re: Terrain or static triangle

Post by Danthekilla »

I have found that a height map is faster (but not by heaps) but also less accurate. Things are far more likly to fall though the world or intersect the world than with a static triangle mesh.

One thing you could do is split you static tri mesh up into 0.5km*0.5km chunks so on a 10km by 10km map you would have 400 chunks, and just insert them when needed. However the static tri mesh is a quadtree i believe so it may not help speed that much. But i'm sure norbo will know :)

I have also found that it will really slow down the simulator if you have more than 10-20 tris in very close proximity to each other in the tri mesh.
imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Re: Terrain or static triangle

Post by imtrobin »

Thanks for sharing.

Inserting dynamically is not an option for me because the whole map is actively using it.

10 - 20 triangles in cloes proximity means?
Danthekilla
Posts: 136
Joined: Sun Jan 17, 2010 11:35 am

Re: Terrain or static triangle

Post by Danthekilla »

more than 20 or so in a .5 by .5 by .5 space and it starts to slow down (expesially on 360) we had to just get very low poly physics versions of our models made up. Other than that it works fine.
Ahh the whole 10km is in use. hmm well a heightmap would probably be faster. what kind accuracy do you need? racing game, flight sim, shooter, rts etc..?

For most games you can get away with a low accuracy, also may i suggest tweaking the iteration count of the simulator. (the default is 10) if you arn't doing heaps of stacking 3-6 works quite well and gives you a mighty speedup.
imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Re: Terrain or static triangle

Post by imtrobin »

It's a rts sort of. I have used the heightmap fine on xbox360, there were some issues but were fixed in 0.10 (I think). Now porting to wp7 phone, which is much lower spec, so even more aggressive optimization needed.
Danthekilla
Posts: 136
Joined: Sun Jan 17, 2010 11:35 am

Re: Terrain or static triangle

Post by Danthekilla »

I would say go with a height map, and if that has problems then try something else.

A height map should use heaps less memory than a static tri mesh (i would think) which would be very important for the phone.
imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Re: Terrain or static triangle

Post by imtrobin »

Heightmap would be more work for me. Now currently using a triangle meshes for terrain because the phone has limitation on terrain vertices
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Terrain or static triangle

Post by Norbo »

The terrain uses a very direct grid approach based on the horizontal coordinates of entities, so it is fast and has no additional supporting data structures. The StaticTriangleGroup uses a bounding volume hierarchy which is also fast, but is made to support arbitrary geometry and cannot make as many assumptions about the data, making it slower (O(log N) as opposed to O(1)).

Additionally, a single large StaticTriangleGroup/Terrain is currently faster than multiple small StaticTriangleGroups/Terrains.

Provided that triangles are of fairly regular shapes and sizes, StaticTriangleGroups and Terrains should have equivalent collision detection robustness.

In the upcoming versions, as part of the significant collision detection system changes, both the StaticTriangleGroup and Terrain should get a nice bit faster and more robust.
Post Reply