Page 1 of 1
Does scaling work OK?
Posted: Mon Oct 09, 2006 9:38 am
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?
Re: Does scaling work OK?
Posted: Mon Oct 09, 2006 1:46 pm
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
Re: Does scaling work OK?
Posted: Mon Oct 09, 2006 2:44 pm
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...
Re: Does scaling work OK?
Posted: Mon Oct 09, 2006 2:56 pm
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
Re: Does scaling work OK?
Posted: Mon Oct 09, 2006 3:34 pm
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...
Re: Does scaling work OK?
Posted: Mon Oct 09, 2006 3:43 pm
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
Re: Does scaling work OK?
Posted: Wed Oct 11, 2006 7:10 am
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