Plane brushes with Bullet?

Post Reply
dv_
Posts: 6
Joined: Wed Jan 10, 2007 12:08 am

Plane brushes with Bullet?

Post by dv_ »

Hi,
Quake 3 BSP files store the collision detection in brushes, which are just a couple of planes forming a convex volume.

Is there a collision shape suitable for such a brush? I didnt find anything in the doxygen reference that fits.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Plane brushes with Bullet?

Post by Erwin Coumans »

Yes, you can represent each convex brush as a btConvexHullShape, by converting the plane equations into a convex point cloud.

Bullet provides a utility in LinearMath/btGeometryUtil to make this easy:

Code: Select all

class btGeometryUtil
{
	public:
		
		static void	getPlaneEquationsFromVertices(btAlignedObjectArray<btVector3>& vertices, btAlignedObjectArray<btVector3>& planeEquationsOut );

		static void	getVerticesFromPlaneEquations(const btAlignedObjectArray<btVector3>& planeEquations , btAlignedObjectArray<btVector3>& verticesOut );
	
		static bool	isInside(const btAlignedObjectArray<btVector3>& vertices, const btVector3& planeNormal, btScalar	margin);
		
		static bool	isPointInsidePlanes(const btAlignedObjectArray<btVector3>& planeEquations, const btVector3& point, btScalar	margin);

		static bool	areVerticesBehindPlane(const btVector3& planeNormal, const btAlignedObjectArray<btVector3>& vertices, btScalar	margin);

};
There is a demo in Bullet/Demos/BspDemo that loads a Quake 3 BSP, and lets you shoot boxes against those brushes.

Erwin

dv_ wrote:Hi,
Quake 3 BSP files store the collision detection in brushes, which are just a couple of planes forming a convex volume.

Is there a collision shape suitable for such a brush? I didnt find anything in the doxygen reference that fits.
dv_
Posts: 6
Joined: Wed Jan 10, 2007 12:08 am

Post by dv_ »

Ah, thanks, tried out the demo.

But I noticed that with complex maps the demo has serious performance issues. As an example, try this map out: http://lvlworld.com/readme.php?t=t8dm6 or this one: http://lvlworld.com/readme.php?t=pn03 . Especially in the latter case the demo slows down to a crawl. Any suggestions? I guess one is not supposed to send many small convex hulls to bullet, right? (t8dm6 has 1876 brushes, pn03 has even 2265!)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Post by Erwin Coumans »

A few thousand static convex objects should be no problem, so it's probably a graphics/rendering issue. I will check out your maps later.

Can you press 'p' and see where the performance it going?

Thanks,
Erwin


dv_ wrote:Ah, thanks, tried out the demo.

But I noticed that with complex maps the demo has serious performance issues. As an example, try this map out: http://lvlworld.com/readme.php?t=t8dm6 or this one: http://lvlworld.com/readme.php?t=pn03 . Especially in the latter case the demo slows down to a crawl. Any suggestions? I guess one is not supposed to send many small convex hulls to bullet, right? (t8dm6 has 1876 brushes, pn03 has even 2265!)
dv_
Posts: 6
Joined: Wed Jan 10, 2007 12:08 am

Post by dv_ »

I commented out the line drawing block (GL_ShapeDrawer.cpp:406) so that the hulls are not drawn - its still very slow.

Lookin at the profiling results there is a considerable increase. performDiscreteCollisionDetection and updateAabbs are at 0.04 - 0.05, whereas other maps with about ~200 brushes give me numbers at 0.003. Anyway, here are the csvs: http://dv.dword.org/stuff/results-csv.zip
(redm08 is a map with 208 brushes).
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Post by Erwin Coumans »

On my Macbook Pro the T8DM6 bsp level has a discrete collision detection time of 0.002607 with some boxes spawned.

What kind of machine are you running this under?
Which version of Bullet?
CPU type/clockspeed?
Operating system, compiler, build system?
Is the performance slow, even if you don't add any boxes?
Did you make any changes to the BspDemo ?

Did you make sure it is release mode, not debug?

Thanks for the feedback,
Erwin
dv_
Posts: 6
Joined: Wed Jan 10, 2007 12:08 am

Post by dv_ »

Erwin Coumans wrote:Did you make sure it is release mode, not debug?
Well I'm not sure, I use cmake by creating a dir "build", entering it, and typing "cmake ..". Can't find any references to a "release" or "debug" mode, and I cant get the build output to be verbose.
dv_
Posts: 6
Joined: Wed Jan 10, 2007 12:08 am

Post by dv_ »

Oh, never mind. I added these lines to CMakeLists.txt:

Code: Select all

IF (NOT CMAKE_BUILD_TYPE)
 SET(CMAKE_BUILD_TYPE "Release")
ENDIF (NOT CMAKE_BUILD_TYPE)
and now bullet is compiled with -O3 -DNDEBUG.

Now I get 0.0007 for both updateAabbs and the discrete collisions in redm08, and 0.008 - 0.01 for pn03, 0.004 for T8dm6. This stays quite constant, even after firing over 20 boxes.

I am using Ubuntu on a Pentium4 2.4GHz HT with 1 GB RAM, gcc 4.1.2, Bullet 2.42b. Other than commenting out the GL_LINES part out I didn't change anything.
dv_
Posts: 6
Joined: Wed Jan 10, 2007 12:08 am

Post by dv_ »

Erwin Coumans wrote:A few thousand static convex objects should be no problem, so it's probably a graphics/rendering issue.
How about 6000? With -O3 and -NDEBUG, I get bad results using http://lvlworld.com/readme.php?t=chartres . Again, updating the AABBs and performing the discrete collision detection are bottlenecks, both using 0.012 time. Overall I get stuttering movement, whereas motion is very smooth with simpler maps. Since the maps I'm using can be as complex as chartres (brush-wise, not graphics-wise) this is of interest to me.
goret
Posts: 4
Joined: Thu Feb 22, 2007 3:17 pm

Post by goret »

Hei,
I've got the same problem.
Performance decrease very quickly when i add some convex shape inside a bsp level. My software is running 60fps with no sphere, and falls to 15fps with only 10 spheres !
My level is about 3000 brushes.
The display doesn't affect these results.
Haven't searched yet where exactly is the problem (just know it's related to bullet), I will seek further in the next days, but if you've got an idea...
:)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Post by Erwin Coumans »

It seems there is indeed severe slowdown when many brushes are in a level, so I will investigate and fix it . One solution would be to create an AABB tree with brushes inside (instead of triangles).

goret, do you have a link to a .bsp file too?

Thanks everyone for the feedback!
Erwin
goret
Posts: 4
Joined: Thu Feb 22, 2007 3:17 pm

Post by goret »

Yes, an AABB tree will certainly help a lot !
Here you can find the 3000 brushes bsp map : http://zescript.free.fr/download/urban.zip
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Post by Erwin Coumans »

Thanks for the reports. There was some performance issue due to recomputation of the AABB every call. It has been fixed, by caching the local AABB for convex objects. This speeds up the large .bsp levels a lot.

Please check and download Bullet 2.43.
Thanks,
Erwin
goret
Posts: 4
Joined: Thu Feb 22, 2007 3:17 pm

Post by goret »

OK, thank you for the release !
I haven't tested yet into the same level, but it seems better.
Also, I mainly use shapes without contact response (to make some phantoms or triggers, and control myself the way they react).
In the bullet code, no island is computed for this kind of shapes, so I changed that, and it's really better.

thx,
greg
Peter Tchernev
Posts: 4
Joined: Thu Nov 15, 2007 8:25 pm

Re: Plane brushes with Bullet?

Post by Peter Tchernev »

I was investigating some unexpected performance issues in a level consisting of many static RBs and a single dynamic.
I am using btDiscreteDynamicsWorld.
As far as I can tell, the AABBs of all objects in the scene ( static and dynamic ) are queried, transformed and fed to the broadphase twice each substep.
Once in btDiscreteDynamicsWorld::updateAabbs() and another time in btCollisionWorld::performDiscreteCollisionDetection().
Is this intentional or have I set up my statics incorrectly somehow to trigger this updating?

Thanks
/Peter
Post Reply