Skip to content

Commit

Permalink
Use JPH_Shape_MustBeStatic to detect if Collider should be static;
Browse files Browse the repository at this point in the history
This is better because it will also make the collider static if it has a
compound shape with a mesh collider in it.
  • Loading branch information
bjornbytes committed May 10, 2024
1 parent 722a947 commit c657441
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/modules/physics/physics_jolt.c
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,11 @@ void lovrColliderSetShape(Collider* collider, Shape* shape) {
collider->shape = shape;
lovrRetain(shape);

bool updateMass = true;
if (shape->type == SHAPE_MESH || shape->type == SHAPE_TERRAIN) {
bool isStatic = JPH_Shape_MustBeStatic(shape->handle);
bool updateMass = !isStatic;

if (isStatic) {
JPH_BodyInterface_SetMotionType(collider->world->bodies, collider->id, JPH_MotionType_Static, JPH_Activation_DontActivate);
updateMass = false;
}

JPH_BodyInterface_SetShape(collider->world->bodies, collider->id, shape->handle, updateMass, JPH_Activation_Activate);
Expand Down

0 comments on commit c657441

Please sign in to comment.