I have a level set up where I have a box on the ground and I have a smaller box bouncing on it
This is the code I use to set that up.
hkVector4 halfExtents(0.5f, 0.5f, 0.5f);
hkpBoxShape* boxShape = new hkpBoxShape(halfExtents);hkpRigidBodyCinfo ci;
ci.m_shape = boxShape;
ci.m_position = hkVector4(0, 30, 0);
ci.m_motionType = hkpMotion::MOTION_DYNAMIC;
boxShape->setRadius(0.00001f);const hkReal boxMass(10.0f);
hkMassProperties massProps;
hkpInertiaTensorComputer::computeShapeVolumeMassProperties(boxShape, boxMass, massProps);
ci.setMassProperties(massProps);
ci.m_restitution = 1.0f;hkpRigidBody* rigidBody = new hkpRigidBody(ci);
boxShape->removeReference();
box = static_cast<hkpRigidBody*>(g_pWorld->addEntity(rigidBody));rigidBody->removeReference();
hkVector4 he(20.0f, 2.0f, 20.f);
hkpBoxShape* bs = new hkpBoxShape(he);
hkpRigidBodyCinfo cis;
cis.m_shape = bs;
cis.m_position = hkVector4(0, -2, 0);
cis.m_motionType = hkpMotion::MOTION_FIXED;
cis.m_restitution = 1.0f;
bs->setRadius(0.00001f);
hkpRigidBody* rigidBodyz = new hkpRigidBody(cis);
bs->removeReference();
g_pWorld->addEntity(rigidBodyz)->removeReference();
I have 2 boxes drawn on the screen and I update the transform for the dynamic on by geting the position from it like this.
hkVector4 pos = hkbox->getPosition();
UpdateBoxTransform(pos(0), pos(1), pos(2))
And when I do that the dynamic box bounces off the static box and as soon as its about to loose its upper velocity after bouncing and about to go for another bounce it freezes and stops in mid air.
Does anyone know how to solve the issue and is there anything I'm doing wrong? Thank you!