Ball - trimesh collision problem

nomad
Posts: 32
Joined: Sun Jun 18, 2006 10:22 pm

Ball - trimesh collision problem

Post by nomad »

To see how stable the collision detection is in Bullet, I set up a app with a ball and a static trimesh, and dropped the ball onto the trimesh from various different heights. When it hits, I record the velocity (from GetLinearVelocity()).
I always get a collision (from PersistentManifold::GetNumContacts() ), but sometimes the ball just falls straight through the trimesh. When it does, the impact speed is less than the predicted speed, but still of a reasonable value. When the ball does not fall through, the velocity is very small.
These are the sort of figures I get (gravity = -40):

Code: Select all

Height    Impact speed    |GetLinearVeolcity()|  Falls through?
16             36                  36              YES
20             40                  7.28             NO
158            112                 93              YES
268            146                 6.26            NO 
368            172                 130             YES
618            222                 149             YES
(this is about the maximum speed I can get collisions at, which I guess works out at about 5m of travel per timestep)
I am using a timestep of 0.02, ball diameter=1, collision margin =0.01. I know I can increase the number of timesteps, and that seems to fix the problem. But I am still concerned that this is a bug, and Bullet may not be stable enough for my needs. Which would be a shame, Bullet is alot easier to use than ODE and in my opinion a better choice for game development. The CCD is more robust than ODE which really suffers from object-trimesh tunnelling when the object moves more than it's maximum bounding box size in a single timestep.

So I would really like to know if this is a known issue with Bullet, and if there is a way to stop this problem hapenning. Any help would be appreciated!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

The CCD/Swept Object against triangle mesh (hierarchy) is not enabled in Bullet. I will add an time-of-impact implementation very soon.

See http://www.continuousphysics.com/Bullet ... tml#l00197
(there is a 'todo' in that code)

See also this topic, I will consider adding support for hierarchy-versus-hierarchy too:
http://www.continuousphysics.com/Bullet ... .php?t=440

Thanks,
Erwin
nomad
Posts: 32
Joined: Sun Jun 18, 2006 10:22 pm

Post by nomad »

I'm staying with Bullet, and I look forward to your next release. Thanks.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

To organize issue a bit better, and to have fun with the new Google Code Project, I added the project there, and submitted your issue as first issue.

The sourceforge project will still be there too, but I experiment with Google Code Projects (and keep them in sync):

http://code.google.com/p/bullet/
nomad
Posts: 32
Joined: Sun Jun 18, 2006 10:22 pm

Post by nomad »

Thanks again, and I appreciate the 'Medium' priority!
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

Bullet 1.8e has support for Compound and non-convex Continuous Collision Detection. The dynamics part is still under development, but at least the time of impact can be detected for compounds/ and convex versus static triangle meshes. Please try the CcdPhysicsDemo, press '1' to enable CCD, and increate the shooting speed with '+'.

Download page

New is support for CMake cross platform build system. This allows autogeneration of MSVC projectfiles and Xcode projectfiles (for universal binaries under MacOS X). Just download cmake, and execute cmake . or
cmake -G Xcode .
(including the dot at the end) to autogenerate buildsystem files.

Erwin
nomad
Posts: 32
Joined: Sun Jun 18, 2006 10:22 pm

Post by nomad »

Tried the demo using CCD, very impressive!
In my test app, using CCD the ball part-penetrates the surface, just sticks there - I assume this is (just) a dynamics issue?
You mentioned integrating bullet collision detection with ODE in september - do you plan to drop Bullet dynamics and use ODE instead or keep a separate Bullet dynamics library?

Thanks.
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

nomad wrote:Tried the demo using CCD, very impressive!
In my test app, using CCD the ball part-penetrates the surface, just sticks there - I assume this is (just) a dynamics issue?
You mentioned integrating bullet collision detection with ODE in september - do you plan to drop Bullet dynamics and use ODE instead or keep a separate Bullet dynamics library?

Thanks.
Make sure to setup the ccdSweptShereRadius in CollisionObject/RigidBody. And set the value in between 0 and the actual size. Give it some margin, so the penetration depth can recover the blocking. So for a sphere of radius 0.5, set the ccdSweptShereRadius to 0.2 for example. Once this CCD feature is integrated inside Blender, there will be more testers and feedback, that allows to sort out most problems with respect to 'blocking' dynamics due to zero time of impact.

Code: Select all


		// Only do CCD if  motion in one timestep (1.f/60.f) exceeds CUBE_HALF_EXTENTS
		physObjects[i]->GetRigidBody()->m_ccdSquareMotionTreshold = CUBE_HALF_EXTENTS;
		
		//Experimental: better estimation of CCD Time of Impact:
		physObjects[i]->GetRigidBody()->m_ccdSweptShereRadius = 0.2*CUBE_HALF_EXTENTS;
I'm not planning to drop Bullet dynamics. Bullet has features that ODE doesn't have, and because I can control the source code it's easier to make improvements. Adding continuous dynamics, parallel multi-threading simulation, and some other improvements would involve too many discussion in the ODE project.

The plan is just to add Bullet's convex GJK collision detection, and perhaps the CCD queries to ODE.

Thanks,
Erwin
nomad
Posts: 32
Joined: Sun Jun 18, 2006 10:22 pm

Post by nomad »

Changing m_ccdSweptShereRadius certainly makes a difference, I'll experiment with various different values and let you know how I get on.
Many thanks.
R.