aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/PhysicsSystem.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-06 20:03:12 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-12-06 20:03:12 +0100
commit5eedba3a070c3a7a4f27ae3ec7dd41812695f7e9 (patch)
tree666955b4308e2d59f6958119f3efbcbf179c493d /src/crepe/system/PhysicsSystem.cpp
parent75ca0750dcc07b6ca043320397917e33638e97b4 (diff)
parentcfd578dd0b7d5894ff0b0a0796d85cd5e9ae6e56 (diff)
Merge branch 'master' into niels/decoupling_pixel_and_pos
Diffstat (limited to 'src/crepe/system/PhysicsSystem.cpp')
-rw-r--r--src/crepe/system/PhysicsSystem.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/crepe/system/PhysicsSystem.cpp b/src/crepe/system/PhysicsSystem.cpp
index bebcf3d..ebf4439 100644
--- a/src/crepe/system/PhysicsSystem.cpp
+++ b/src/crepe/system/PhysicsSystem.cpp
@@ -25,17 +25,20 @@ void PhysicsSystem::update() {
if (transform.game_object_id == rigidbody.game_object_id) {
// Add gravity
- if (rigidbody.data.use_gravity) {
+ if (rigidbody.data.gravity_scale > 0) {
rigidbody.data.linear_velocity.y
+= (rigidbody.data.mass * rigidbody.data.gravity_scale
* gravity);
}
// Add damping
- if (rigidbody.data.angular_damping != 0) {
- rigidbody.data.angular_velocity *= rigidbody.data.angular_damping;
+ if (rigidbody.data.angular_velocity_coefficient > 0) {
+ rigidbody.data.angular_velocity
+ *= rigidbody.data.angular_velocity_coefficient;
}
- if (rigidbody.data.linear_damping != vec2{0, 0}) {
- rigidbody.data.linear_velocity *= rigidbody.data.linear_damping;
+ if (rigidbody.data.linear_velocity_coefficient.x > 0
+ && rigidbody.data.linear_velocity_coefficient.y > 0) {
+ rigidbody.data.linear_velocity
+ *= rigidbody.data.linear_velocity_coefficient;
}
// Max velocity check