aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-12-12 16:22:43 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-12-12 16:22:43 +0100
commitf1650941336db0b1b5152dc900022e99853770ed (patch)
tree0e3f75b21fe18e57c75b06995edd77e31dbf8214
parentb6ed980b0374868868ac274ed46a1a823c10db4f (diff)
updated constraints
-rw-r--r--src/crepe/system/PhysicsSystem.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/crepe/system/PhysicsSystem.cpp b/src/crepe/system/PhysicsSystem.cpp
index 5629809..38deb43 100644
--- a/src/crepe/system/PhysicsSystem.cpp
+++ b/src/crepe/system/PhysicsSystem.cpp
@@ -41,7 +41,7 @@ void PhysicsSystem::update() {
throw std::runtime_error("Config Gravity must be greater than 0");
}
- if (rigidbody.data.gravity_scale > 0) {
+ if (rigidbody.data.gravity_scale > 0 && !rigidbody.data.constraints.y) {
rigidbody.data.linear_velocity.y
+= (rigidbody.data.mass * rigidbody.data.gravity_scale * gravity
* dt);
@@ -53,13 +53,15 @@ void PhysicsSystem::update() {
}
// Add coefficient movement horizontal
- if (rigidbody.data.linear_velocity_coefficient.x > 0) {
+ if (rigidbody.data.linear_velocity_coefficient.x > 0
+ && !rigidbody.data.constraints.x) {
rigidbody.data.linear_velocity.x
*= std::pow(rigidbody.data.linear_velocity_coefficient.x, dt);
}
// Add coefficient movement horizontal
- if (rigidbody.data.linear_velocity_coefficient.y > 0) {
+ if (rigidbody.data.linear_velocity_coefficient.y > 0
+ && !rigidbody.data.constraints.y) {
rigidbody.data.linear_velocity.y
*= std::pow(rigidbody.data.linear_velocity_coefficient.y, dt);
}