Skip to content

Commit

Permalink
Merge pull request #720 from xiejiangzhi/auto_wakeup
Browse files Browse the repository at this point in the history
Auto wake up collider when calling API to apply force or change force.
  • Loading branch information
bjornbytes authored Nov 18, 2023
2 parents 164e05a + 1e120d3 commit 895c702
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 895c702

Please sign in to comment.