shape scaling in transformation matrix => no collisions?

mp-nico
Posts: 5
Joined: Mon Feb 23, 2009 10:20 am

shape scaling in transformation matrix => no collisions?

Post by mp-nico »

Hi,

I recently began using bullet (2.73) in our project and discovered something odd.
For testing, I exported a simple scene from 3DS max. The scene contains 4 planes.
Screenshot:

Image

The planes are (left to right in the screenshot)
1. plane without rotation or scaling
Transformation matrix:

Code: Select all

[   1.0000,   0.0000,  -0.0000, -62.3693 ]
[   0.0000,   1.0000,  -0.0000,   9.0501 ]
[  -0.0000,  -0.0000,   1.0000, -18.1408 ]
[   0.0000,   0.0000,  -0.0000,   1.0000 ]
2. with rotation
Transformation matrix:

Code: Select all

[   0.9418,  -0.2212,   0.2532, -34.0320 ]
[   0.3093,   0.8652,  -0.3947,   8.9540 ]
[  -0.1318,   0.4501,   0.8832, -18.1408 ]
[   0.0000,   0.0000,  -0.0000,   1.0000 ]
3. with scaling
Transformation matrix:

Code: Select all

[   0.7260,   0.0000,  -0.0000,  -4.6945 ]
[   0.0000,   0.7260,  -0.0000,   8.3072 ]
[  -0.0000,  -0.0000,   0.7260, -18.1408 ]
[   0.0000,   0.0000,  -0.0000,   1.0000 ]
4. with both, rotation and scaling
Transformation matrix:

Code: Select all

[   0.6920,  -0.3558,   0.0661,  23.3640 ]
[   0.3468,   0.6111,  -0.3408,   7.9197 ]
[   0.1035,   0.3313,   0.6995, -18.1408 ]
[   0.0000,   0.0000,  -0.0000,   1.0000 ]
I create a static btBvhTriangleMeshShape + btRigidBody for each plane and a dynamic btCapsuleShape + btRigidBody for collision testing.
I'm also using btMotionstate for setting/getting the transformation.

Plane 1 and 2 collide correctly with the capsule. The capsule goes right through plane 3 and 4. There's no collision at all.
The results are the same if I use a btBoxShape instead of btBvhTriangleShape.

It's looks to me that whenever a transformation matrix has a scale, collisions don't work.
I'm aware that the shape provides a setLocalScaling that enables scaling of shapes and I'd be happy to use it if I could.
However, all I get from 3DS max is the transformation, and I don't know how to extract and deduct the scaling from the transformation (safely).

I guess, one option would be to transform all vertices before using them for a btBvhTriangleMeshShape.
Problem is, we have a lot of instances and this would increase the memory consumption drastically.

Any help / hint or even a explanation of the problem is appreciated .

Thanks!
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: shape scaling in transformation matrix => no collisions?

Post by pico »

Hi,

your assumption is true. The matrices you pass over to Bullet must not have any scaling. You can apply a local scaling to each body if needed.
mp-nico
Posts: 5
Joined: Mon Feb 23, 2009 10:20 am

Re: shape scaling in transformation matrix => no collisions?

Post by mp-nico »

Update:

I'm now decomposing the transformation using this code:

Code: Select all

template <typename T>
void decompose( Matrix44<T> const & _m, Vector3<T> & _outTranslation, Vector3<T> & _outScaling, Matrix33<T> & _outRotation )
{			
	_outTranslation = _m.getTranslation();
	_outScaling.x = _m.getColumn(0).length();
	_outScaling.y = _m.getColumn(1).length();
	_outScaling.z = _m.getColumn(2).length();
	_outRotation.setColumn( 0, _m.getColumn(0).normalize() );
	_outRotation.setColumn( 1, _m.getColumn(1).normalize() );
	_outRotation.setColumn( 2, _m.getColumn(2).normalize() );
}
It works just fine for my current test scenes but I'm worried that it will fail if 3DS max ever decides to provide me a non-affine/skewed matrix ...