mirror of https://github.com/bjornbytes/lovr.git
Call NotifyShapeChanged when collider shape changes;
Jolt says we have to do this if the collider has joints. um...ok...
This commit is contained in:
parent
ee76f3418a
commit
b6b13deea6
|
@ -496,6 +496,20 @@ void lovrColliderSetShape(Collider* collider, Shape* shape) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (collider->joints) {
|
||||
JPH_Vec3 oldCenterOfMass;
|
||||
JPH_Vec3 newCenterOfMass;
|
||||
JPH_Vec3 deltaCenterOfMass;
|
||||
JPH_Shape_GetCenterOfMass(collider->shape->shape, &oldCenterOfMass);
|
||||
JPH_Shape_GetCenterOfMass(collider->shape->shape, &newCenterOfMass);
|
||||
deltaCenterOfMass.x = newCenterOfMass.x - oldCenterOfMass.x;
|
||||
deltaCenterOfMass.y = newCenterOfMass.y - oldCenterOfMass.y;
|
||||
deltaCenterOfMass.z = newCenterOfMass.z - oldCenterOfMass.z;
|
||||
for (Joint* joint = collider->joints; joint; joint = lovrJointGetNext(joint, collider)) {
|
||||
JPH_Constraint_NotifyShapeChanged(joint->constraint, collider->id, &deltaCenterOfMass);
|
||||
}
|
||||
}
|
||||
|
||||
lovrRelease(collider->shape, lovrShapeDestroy);
|
||||
collider->shape = shape;
|
||||
lovrRetain(shape);
|
||||
|
|
Loading…
Reference in New Issue