Getting the amount of repulsion during collision detected

Post Reply
lucky7456969
Posts: 26
Joined: Thu Sep 11, 2014 5:40 am

Getting the amount of repulsion during collision detected

Post by lucky7456969 »

The physics component is one of the many components in my simulation.
But at least for this moment, the order of execution is not explicitly defined.
So the setWorldTransform called during each frame can be overridden by
the other components.

My thought was to just get the amount of distance the physics has repelled
for the objects it is working on.

Say object A and B collided, the amount of force makes the A to move
2 cm/s/s away from B....

But you can see in the code snippet below, I am setting the absolute position
during each frame call.

From the worldTrans, how can I tell (the difference) how much the physics has repelled (how
much they bounced off each other) the two objects
I'm after?

so that I can do
l_transform->addPosition(...)
l_transform->addRotation(...)

Code: Select all

void AgentMotionState::setWorldTransform(const btTransform& worldTrans) 
{
	 
	D3DXMATRIX d3dMatrix = BT2DX_MATRIX(worldTrans);
	D3DXVECTOR3 pos, scale;
	D3DXQUATERNION quat;
	D3DXMatrixDecompose(&scale, &quat, &pos, &d3dMatrix);	 
	Transform* l_transform = m_object->FindComponentByType<Transform>();

	l_transform->setPosition(D3DXVECTOR3(pos.x, pos.y, pos.z));	
	l_transform->setRotation(quat);
	l_transform->setScale(scale);


}
Post Reply