From f1650941336db0b1b5152dc900022e99853770ed Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Thu, 12 Dec 2024 16:22:43 +0100 Subject: updated constraints --- src/crepe/system/PhysicsSystem.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') 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); } -- cgit v1.2.3