Page 1 of 1

btSphereSphereCollisionAlgorithm division by 0

Posted: Tue Nov 13, 2007 1:33 am
by SeanTasker
Hi Erwin,
While working on a project we have found that the btSphereSphereCollisionAlgorithm causes a crash when two spheres are in the same position.

I've patched the following code to include a check

Code: Select all

	btVector3 diff = col0->getWorldTransform().getOrigin()-  col1->getWorldTransform().getOrigin();
	btScalar len = diff.length();
	btScalar radius0 = sphere0->getRadius();
	btScalar radius1 = sphere1->getRadius();
to

Code: Select all

	btVector3 diff = col0->getWorldTransform().getOrigin()-  col1->getWorldTransform().getOrigin();
	btScalar len = diff.length();
	if(len==0.0f)
		return;
	btScalar radius0 = sphere0->getRadius();
	btScalar radius1 = sphere1->getRadius();
I realise that this is something that doesn't tend to happen much and that we should be spawning our objects in different places. In the rare even that this happens the above patch fixes it :)

Thank you a million for bullet it is absolutely awesome! :)
-Sean Tasker

Re: btSphereSphereCollisionAlgorithm division by 0

Posted: Fri Nov 16, 2007 2:21 am
by Erwin Coumans
Thanks for the report, this will be fixed!

Erwin

Re: btSphereSphereCollisionAlgorithm division by 0

Posted: Wed Nov 21, 2007 4:18 am
by Erwin Coumans
It has been fixed, slightly different: it will report a penetration, with an arbitrary separating normal (1,0,0).

Thanks a lot for the feedback,
Erwin