Confirmation question about btBvhTriangleMeshShape slowdown

User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Confirmation question about btBvhTriangleMeshShape slowdown

Post by Dragonlord »

Tried working on a height based terrain for one world cell which is a 500x500 grid. I use btBvhTriangleMeshShape since I use this also for non-height map terrain geometry. Using this setup it takes roughly 15 seconds to build the btBvhTriangleMeshShape from this grid. A bit below a topic mentioned that the striding interface uses "signed short" which would limit the number of vertices and faces in a btBvhTriangleMeshShape to roughly ~32'000. This setup though produces 250'000 vertices and 498'002 faces.

Just want to see if my observation is correct and not some bug. Hence btBvhTriangleMeshShape is only efficient with up to 32.000 vertices and faces? If so I would split up the terrain per world cell into chunks of under 32'000 vertices and faces.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Confirmation question about btBvhTriangleMeshShape slowdown

Post by Erwin Coumans »

A few million triangles should be no problem for a btBvhTriangleMeshShape, you can use 32bit integers or 16 bit integers for indices, and 32bit is default. If you use btTriangleMesh, 32 bit indices is default too. Otherwise check out:

Code: Select all

void	btTriangleIndexVertexArray::addIndexedMesh(const btIndexedMesh& mesh, PHY_ScalarType indexType = PHY_INTEGER)
If the building of the btBvhTriangleMeshShape is too slow, you can serialize the acceleration structure (AABB tree) to disk, and load it back later (some call this process 'cooking').
See Demos\ConcaveDemo\ConcavePhysicsDemo.cpp for example how to serialize to/from disk (around #define SERIALIZE_TO_DISK).

Hope this helps,
Erwin
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Re: Confirmation question about btBvhTriangleMeshShape slowdown

Post by Dragonlord »

This is unfortunately not a possibility since the world editor is allowed to alter the height map terrain interactively and waiting 15 seconds between a paint stroke and an update to happen is unacceptable.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Confirmation question about btBvhTriangleMeshShape slowdown

Post by Erwin Coumans »

Dragonlord wrote:This is unfortunately not a possibility since the world editor is allowed to alter the height map terrain interactively and waiting 15 seconds between a paint stroke and an update to happen is unacceptable.
There are several options:
  • use the btHeightfieldTerrainShape instead, it has no slowdown
  • do a partialRefit, giving the min/max extents of the user deformation. See Demos/ConcaveDemo/ConcavePhysicsDemos.cpp how to use this
  • wait until we enable the use of the new btDbvt to accelerate triangle meshes, it has much faster creation
Hope this helps,
Erwin
User avatar
Dragonlord
Posts: 198
Joined: Mon Sep 04, 2006 5:31 pm
Location: Switzerland

Re: Confirmation question about btBvhTriangleMeshShape slowdown

Post by Dragonlord »

You forgot another option: write your own shape ( based on the height map ) :D . Maybe I'm going this way anyways. Another down-side of this class is that I have to duplicate mesh data 100%. After all in a height map the plane coordinates X and Z are easy to calculate given the height map coordinates. The same goes for the height. Thought about doing a class that simply streams the data to the rest of Bullet on a per-need basis. I have not looked closer into this one since I've got something else ( graphic rendering related ) to deal with right now but from my first glance on the height map terrain class already existing in Bullet it should be doable. Are there by the way any plans for a "true" streaming triangle mesh interface ( since there is only a striding one which can not be sub-classed to be streaming as the vital function is not virtual )?