Does scaling work OK?

Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Does scaling work OK?

Post by Jack »

Situation:

1) Static Box vs Dynamic Sphere -> Collision OK
2) Scaled Static Box vs Dynamic Sphere -> No collision at all. They do not sense each other.

Code: Select all

void					SetScale(D3DXVECTOR3 &v)
{
	_pPhyObj->m_worldTransform.scale(*(btVector3*)&v);
}
What can be wrong?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Does scaling work OK?

Post by Erwin Coumans »

Jack wrote:Situation:

1) Static Box vs Dynamic Sphere -> Collision OK
2) Scaled Static Box vs Dynamic Sphere -> No collision at all. They do not sense each other.

Code: Select all

void					SetScale(D3DXVECTOR3 &v)
{
	_pPhyObj->m_worldTransform.scale(*(btVector3*)&v);
}
What can be wrong?
You should set the scaling on the btCollisionShape. Please do so before you calculate the inertia tensor, and preferably before you add it to the world.

I will remove the scaling on the worldtransform, we are only dealing with rigid transforms in Bullet (the scaling method on btTransform it is an obsolete remainder).

Thanks for pointing this out,
Erwin
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Re: Does scaling work OK?

Post by Jack »

Erwin Coumans wrote:
Jack wrote:Situation:

1) Static Box vs Dynamic Sphere -> Collision OK
2) Scaled Static Box vs Dynamic Sphere -> No collision at all. They do not sense each other.

Code: Select all

void					SetScale(D3DXVECTOR3 &v)
{
	_pPhyObj->m_worldTransform.scale(*(btVector3*)&v);
}
What can be wrong?
You should set the scaling on the btCollisionShape. Please do so before you calculate the inertia tensor, and preferably before you add it to the world.

I will remove the scaling on the worldtransform, we are only dealing with rigid transforms in Bullet (the scaling method on btTransform it is an obsolete remainder).

Thanks for pointing this out,
Erwin
That worked. But:
1) getOpenGLMatrix does not include scaling in the returned matrix. Do you think it is right?
2) As I understood I can not change scale dynamicaly. Right? Then it is going to be useless feature, I think...
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Does scaling work OK?

Post by Erwin Coumans »

Jack wrote: That worked. But:
1) getOpenGLMatrix does not include scaling in the returned matrix. Do you think it is right?
2) As I understood I can not change scale dynamicaly. Right? Then it is going to be useless feature, I think...
You have to apply the scaling yourself on the graphics object, the world transform doesn't contain the scaling.

You can dynamically scale rigid bodies, as long as you make sure to call a method to update the inertial tensor. WARNING: not all shapes might support the re-scaling yet, especially static triangle meshes that use a bounding volume hierarchy need to rebuild this hierarchy probably.

1) update the scaling on the btCollisionShape derived class
2) calculate new localinertia on that collision shape
3) call the setMassProps(mass,updatedLocalInertia) on btRigidBody
4) call the updateInertiaTensor on the btRigidBody

If you are rescaling a dynamic rigidbody make also sure to activate it, and don't cause too deep penetration in one timestep.

Hope this helps,
Erwin
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Re: Does scaling work OK?

Post by Jack »

Erwin Coumans wrote:
Jack wrote: That worked. But:
1) getOpenGLMatrix does not include scaling in the returned matrix. Do you think it is right?
2) As I understood I can not change scale dynamicaly. Right? Then it is going to be useless feature, I think...
You have to apply the scaling yourself on the graphics object, the world transform doesn't contain the scaling.

You can dynamically scale rigid bodies, as long as you make sure to call a method to update the inertial tensor. WARNING: not all shapes might support the re-scaling yet, especially static triangle meshes that use a bounding volume hierarchy need to rebuild this hierarchy probably.

1) update the scaling on the btCollisionShape derived class
2) calculate new localinertia on that collision shape
3) call the setMassProps(mass,updatedLocalInertia) on btRigidBody
4) call the updateInertiaTensor on the btRigidBody

If you are rescaling a dynamic rigidbody make also sure to activate it, and don't cause too deep penetration in one timestep.

Hope this helps,
Erwin
Do not you think these steps should be done automaticaly by Bullet? Do not you think that Inertia Tensor to be managed entirely By Bullet? Probably there could be method GetInertiaTensor (if user wants to know it), but such methods as calculateLocalInertia, updateInertiaTensor, setMassProps look redundant.
When you create the shape you pass body density. Then Volume, Mass, Inertia are managed automaticaly. User can get these values, but not set...
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Does scaling work OK?

Post by Erwin Coumans »

Jack wrote: Do not you think these steps should be done automaticaly by Bullet? Do not you think that Inertia Tensor to be managed entirely By Bullet? Probably there could be method GetInertiaTensor (if user wants to know it), but such methods as calculateLocalInertia, updateInertiaTensor, setMassProps look redundant.
When you create the shape you pass body density. Then Volume, Mass, Inertia are managed automaticaly. User can get these values, but not set...
No, I don't want to force users to use Bullet's inertial tensor calculation. You can optionally use it, but also load it from file (COLLADA physics provides the inertia tensor that it gets from the tool (Maya, Max, XSI, Blender etc)) or calculate it yourself.
I haven't checked it out yet, but perhaps setMassProps already updates the cached inverse of the inertia tensor. Otherwise I will add that, to reduce the work.
Note however that scaling/rescaling is not a common use case in rigid body dynamics.

Thanks for the feedback,
Erwin
daBrado
Posts: 11
Joined: Thu Oct 05, 2006 10:41 am

Re: Does scaling work OK?

Post by daBrado »

Erwin Coumans wrote:I will remove the scaling on the worldtransform, we are only dealing with rigid transforms in Bullet (the scaling method on btTransform it is an obsolete remainder).
So, is a btTransform only for rotations and translations?

If so, would it be bad form to do something like:

Code: Select all

myBtTransform . getBasis ( ) . scaled ( myBtVector ) ;
Thanks,
Braden