From ed1ba5093f6a9d10adb5da74580bcb4469159214 Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Thu, 16 Sep 2021 12:37:24 -0700 Subject: Clarify RigidDynamicBody modes RigidDynamicBody modes are replaced with several properties to make their usage clearer: -lock_rotation: disable body's rotation (instead of MODE_LOCKED) -freeze: no gravity or forces (instead of MODE_STATIC and MODE_KINEMATIC) -freeze_mode: Static (can be only teleported) or Kinematic (can be animated) Also renamed MODE_DYNAMIC_LOCKED to MODE_DYNAMIC_LINEAR in the physics servers. --- modules/bullet/rigid_body_bullet.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'modules') diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 0d2cd1f5a0..a45333e5bc 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -529,26 +529,23 @@ void RigidBodyBullet::set_mode(PhysicsServer3D::BodyMode p_mode) { can_integrate_forces = false; destroy_kinematic_utilities(); // The mode change is relevant to its mass + mode = p_mode; switch (p_mode) { case PhysicsServer3D::BODY_MODE_KINEMATIC: - mode = PhysicsServer3D::BODY_MODE_KINEMATIC; reload_axis_lock(); _internal_set_mass(0); init_kinematic_utilities(); break; case PhysicsServer3D::BODY_MODE_STATIC: - mode = PhysicsServer3D::BODY_MODE_STATIC; reload_axis_lock(); _internal_set_mass(0); break; case PhysicsServer3D::BODY_MODE_DYNAMIC: - mode = PhysicsServer3D::BODY_MODE_DYNAMIC; reload_axis_lock(); _internal_set_mass(0 == mass ? 1 : mass); scratch_space_override_modificator(); break; - case PhysicsServer3D::MODE_DYNAMIC_LOCKED: - mode = PhysicsServer3D::MODE_DYNAMIC_LOCKED; + case PhysicsServer3D::MODE_DYNAMIC_LINEAR: reload_axis_lock(); _internal_set_mass(0 == mass ? 1 : mass); scratch_space_override_modificator(); @@ -721,7 +718,7 @@ bool RigidBodyBullet::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const { void RigidBodyBullet::reload_axis_lock() { btBody->setLinearFactor(btVector3(btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), btScalar(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z)))); - if (PhysicsServer3D::MODE_DYNAMIC_LOCKED == mode) { + if (PhysicsServer3D::MODE_DYNAMIC_LINEAR == mode) { /// When character angular is always locked btBody->setAngularFactor(btVector3(0., 0., 0.)); } else { @@ -1016,7 +1013,7 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) { // Rigidbody is dynamic if and only if mass is non Zero, otherwise static const bool isDynamic = p_mass != 0.f; if (isDynamic) { - if (PhysicsServer3D::BODY_MODE_DYNAMIC != mode && PhysicsServer3D::MODE_DYNAMIC_LOCKED != mode) { + if (PhysicsServer3D::BODY_MODE_DYNAMIC != mode && PhysicsServer3D::MODE_DYNAMIC_LINEAR != mode) { return; } -- cgit v1.2.3