Skip to content

Commit

Permalink
Auto wake up collider when calling API to apply force or change force.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiejiangzhi committed Nov 18, 2023
1 parent eefc899 commit 1e120d3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/modules/physics/physics.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ void lovrColliderGetLinearVelocity(Collider* collider, float* x, float* y, float
}

void lovrColliderSetLinearVelocity(Collider* collider, float x, float y, float z) {
dBodyEnable(collider->body);
dBodySetLinearVel(collider->body, x, y, z);
}

Expand All @@ -731,6 +732,7 @@ void lovrColliderGetAngularVelocity(Collider* collider, float* x, float* y, floa
}

void lovrColliderSetAngularVelocity(Collider* collider, float x, float y, float z) {
dBodyEnable(collider->body);
dBodySetAngularVel(collider->body, x, y, z);
}

Expand All @@ -755,14 +757,17 @@ void lovrColliderSetAngularDamping(Collider* collider, float damping, float thre
}

void lovrColliderApplyForce(Collider* collider, float x, float y, float z) {
dBodyEnable(collider->body);
dBodyAddForce(collider->body, x, y, z);
}

void lovrColliderApplyForceAtPosition(Collider* collider, float x, float y, float z, float cx, float cy, float cz) {
dBodyEnable(collider->body);
dBodyAddForceAtPos(collider->body, x, y, z, cx, cy, cz);
}

void lovrColliderApplyTorque(Collider* collider, float x, float y, float z) {
dBodyEnable(collider->body);
dBodyAddTorque(collider->body, x, y, z);
}

Expand Down

0 comments on commit 1e120d3

Please sign in to comment.