summaryrefslogtreecommitdiff
path: root/modules/bullet
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2021-09-16 12:37:24 -0700
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2021-09-16 16:03:48 -0700
commited1ba5093f6a9d10adb5da74580bcb4469159214 (patch)
treec014e84d3930610b0c6ac658d86f41230fc05472 /modules/bullet
parent3581b893ed2dc1e444618ac40dc26dd58fe1219a (diff)
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.
Diffstat (limited to 'modules/bullet')
-rw-r--r--modules/bullet/rigid_body_bullet.cpp11
1 files changed, 4 insertions, 7 deletions
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;
}