Can collision occur before bodies don't reach each other??

manuyavuz
Posts: 6
Joined: Tue Feb 22, 2011 1:47 pm

Can collision occur before bodies don't reach each other??

Post by manuyavuz »

Hi,

I'm facing with a weird thing about getManifolds functionality.

I wanted to print position and radius info of my colliding cylinder shaped rigidbodies.

This is the code where obA and obB are the bodies of the contact point.

Code: Select all

btTransform transA = obA->getWorldTransform();
btTransform transB = obB->getWorldTransform();
btCylinderShapeZ* cylShape = (btCylinderShapeZ*) obA->getCollisionShape();
float radiusA = cylShape->getRadius();
cylShape = (btCylinderShapeZ*) obB->getCollisionShape();
float radiusB = cylShape->getRadius();
NSLog(@"ob0 x: %.3f \ty: %.3f \t radius: %.3f\n",transA.getOrigin().getX(),transA.getOrigin().getY(),radiusA);
NSLog(@"ob1 x: %.3f \ty: %.3f radius: %.3f",transB.getOrigin().getX(),transB.getOrigin().getY(),radiusB);
Result is the following:

ob0 x: 218.746 y: 234.662 radius: 16.000
ob1 x: 259.522 y: 234.645 radius: 16.000

Strange thing here is that, bodies have a radius of 16 unit, so they have to be at least 32 unit close to each other. But as can be seen, their distance on x axis is nearly 41 units.

How it could be, what's the situation that i couldn't figured out?
Ripiz
Posts: 47
Joined: Mon Aug 16, 2010 10:43 am

Re: Can collision occur before bodies don't reach each other

Post by Ripiz »

Cylinder is NOT a sphere.

This is cylinder and sphere, if you look hard enough you'll find your answer (ignore the text in image):
Image
manuyavuz
Posts: 6
Joined: Tue Feb 22, 2011 1:47 pm

Re: Can collision occur before bodies don't reach each other

Post by manuyavuz »

I know that cylinder is not a sphere.

getRadius() value should represent the radius of the circular face for the cylinder in normal case.

Bodies are moving on X-Y axis and they have a 2d motion, so they shouldn't be colliding when their x poses are 41 units far from each other.

Sorry but I still can't figured out the trick here. I need an explanation.

Thanks