I'm trying to add a fixed object feature to the physics sandbox I'm making. It seems to work, but the collision shapes of the objects get messed up, so other objects will often fall straight through where the fixed object is supposed to be, and objects will hit an "invisible" fixed shape somewhere nearby on the screen. The selecting of objects (using testPoint) breaks as well, selecting the "ghost" shape rather than where the renderer is showing it if I click in the area where other objects are colliding with.
This is the code used to make an object fixed (this happens when a checkbox is clicked after an object is added to the world.
This is the code used to make an object fixed (this happens when a checkbox is clicked after an object is added to the world.
Code:
if((Boolean) value == true)
{
pMass = body.m_mass;
pInvMass = body.m_invMass;
body.m_invMass = 0;
body.m_mass = 0;
}
else
{
body.m_mass = pMass;
body.m_invMass = pInvMass;
}
{
pMass = body.m_mass;
pInvMass = body.m_invMass;
body.m_invMass = 0;
body.m_mass = 0;
}
else
{
body.m_mass = pMass;
body.m_invMass = pInvMass;
}