diff options
Diffstat (limited to 'modules/bullet/rigid_body_bullet.cpp')
-rw-r--r-- | modules/bullet/rigid_body_bullet.cpp | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 80f42c8441..b92166e653 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -194,7 +194,7 @@ Vector3 BulletPhysicsDirectBodyState::get_contact_collider_velocity_at_position( return velocityAtPoint; } -PhysicsDirectSpaceState *BulletPhysicsDirectBodyState::get_space_state() { +PhysicsDirectSpaceState3D *BulletPhysicsDirectBodyState::get_space_state() { return body->get_space()->get_direct_state(); } @@ -231,12 +231,12 @@ void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() { shapes.write[i].transform = shape_wrapper->transform; shapes.write[i].transform.getOrigin() *= owner_scale; switch (shape_wrapper->shape->get_type()) { - case PhysicsServer::SHAPE_SPHERE: - case PhysicsServer::SHAPE_BOX: - case PhysicsServer::SHAPE_CAPSULE: - case PhysicsServer::SHAPE_CYLINDER: - case PhysicsServer::SHAPE_CONVEX_POLYGON: - case PhysicsServer::SHAPE_RAY: { + case PhysicsServer3D::SHAPE_SPHERE: + case PhysicsServer3D::SHAPE_BOX: + case PhysicsServer3D::SHAPE_CAPSULE: + case PhysicsServer3D::SHAPE_CYLINDER: + case PhysicsServer3D::SHAPE_CONVEX_POLYGON: + case PhysicsServer3D::SHAPE_RAY: { shapes.write[i].shape = static_cast<btConvexShape *>(shape_wrapper->shape->create_bt_shape(owner_scale * shape_wrapper->scale, safe_margin)); } break; default: @@ -286,7 +286,7 @@ RigidBodyBullet::RigidBodyBullet() : reload_shapes(); setupBulletCollisionObject(btBody); - set_mode(PhysicsServer::BODY_MODE_RIGID); + set_mode(PhysicsServer3D::BODY_MODE_RIGID); reload_axis_lock(); areasWhereIam.resize(maxAreasWhereIam); @@ -487,29 +487,29 @@ void RigidBodyBullet::set_omit_forces_integration(bool p_omit) { omit_forces_integration = p_omit; } -void RigidBodyBullet::set_param(PhysicsServer::BodyParameter p_param, real_t p_value) { +void RigidBodyBullet::set_param(PhysicsServer3D::BodyParameter p_param, real_t p_value) { switch (p_param) { - case PhysicsServer::BODY_PARAM_BOUNCE: + case PhysicsServer3D::BODY_PARAM_BOUNCE: btBody->setRestitution(p_value); break; - case PhysicsServer::BODY_PARAM_FRICTION: + case PhysicsServer3D::BODY_PARAM_FRICTION: btBody->setFriction(p_value); break; - case PhysicsServer::BODY_PARAM_MASS: { + case PhysicsServer3D::BODY_PARAM_MASS: { ERR_FAIL_COND(p_value < 0); mass = p_value; _internal_set_mass(p_value); break; } - case PhysicsServer::BODY_PARAM_LINEAR_DAMP: + case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: linearDamp = p_value; btBody->setDamping(linearDamp, angularDamp); break; - case PhysicsServer::BODY_PARAM_ANGULAR_DAMP: + case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: angularDamp = p_value; btBody->setDamping(linearDamp, angularDamp); break; - case PhysicsServer::BODY_PARAM_GRAVITY_SCALE: + case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: gravity_scale = p_value; /// The Bullet gravity will be is set by reload_space_override_modificator scratch_space_override_modificator(); @@ -519,21 +519,21 @@ void RigidBodyBullet::set_param(PhysicsServer::BodyParameter p_param, real_t p_v } } -real_t RigidBodyBullet::get_param(PhysicsServer::BodyParameter p_param) const { +real_t RigidBodyBullet::get_param(PhysicsServer3D::BodyParameter p_param) const { switch (p_param) { - case PhysicsServer::BODY_PARAM_BOUNCE: + case PhysicsServer3D::BODY_PARAM_BOUNCE: return btBody->getRestitution(); - case PhysicsServer::BODY_PARAM_FRICTION: + case PhysicsServer3D::BODY_PARAM_FRICTION: return btBody->getFriction(); - case PhysicsServer::BODY_PARAM_MASS: { + case PhysicsServer3D::BODY_PARAM_MASS: { const btScalar invMass = btBody->getInvMass(); return 0 == invMass ? 0 : 1 / invMass; } - case PhysicsServer::BODY_PARAM_LINEAR_DAMP: + case PhysicsServer3D::BODY_PARAM_LINEAR_DAMP: return linearDamp; - case PhysicsServer::BODY_PARAM_ANGULAR_DAMP: + case PhysicsServer3D::BODY_PARAM_ANGULAR_DAMP: return angularDamp; - case PhysicsServer::BODY_PARAM_GRAVITY_SCALE: + case PhysicsServer3D::BODY_PARAM_GRAVITY_SCALE: return gravity_scale; default: WARN_PRINT("Parameter " + itos(p_param) + " not supported by bullet"); @@ -541,31 +541,31 @@ real_t RigidBodyBullet::get_param(PhysicsServer::BodyParameter p_param) const { } } -void RigidBodyBullet::set_mode(PhysicsServer::BodyMode p_mode) { +void RigidBodyBullet::set_mode(PhysicsServer3D::BodyMode p_mode) { // This is necessary to block force_integration untile next move can_integrate_forces = false; destroy_kinematic_utilities(); // The mode change is relevant to its mass switch (p_mode) { - case PhysicsServer::BODY_MODE_KINEMATIC: - mode = PhysicsServer::BODY_MODE_KINEMATIC; + case PhysicsServer3D::BODY_MODE_KINEMATIC: + mode = PhysicsServer3D::BODY_MODE_KINEMATIC; reload_axis_lock(); _internal_set_mass(0); init_kinematic_utilities(); break; - case PhysicsServer::BODY_MODE_STATIC: - mode = PhysicsServer::BODY_MODE_STATIC; + case PhysicsServer3D::BODY_MODE_STATIC: + mode = PhysicsServer3D::BODY_MODE_STATIC; reload_axis_lock(); _internal_set_mass(0); break; - case PhysicsServer::BODY_MODE_RIGID: - mode = PhysicsServer::BODY_MODE_RIGID; + case PhysicsServer3D::BODY_MODE_RIGID: + mode = PhysicsServer3D::BODY_MODE_RIGID; reload_axis_lock(); _internal_set_mass(0 == mass ? 1 : mass); scratch_space_override_modificator(); break; - case PhysicsServer::BODY_MODE_CHARACTER: - mode = PhysicsServer::BODY_MODE_CHARACTER; + case PhysicsServer3D::BODY_MODE_CHARACTER: + mode = PhysicsServer3D::BODY_MODE_CHARACTER; reload_axis_lock(); _internal_set_mass(0 == mass ? 1 : mass); scratch_space_override_modificator(); @@ -575,26 +575,26 @@ void RigidBodyBullet::set_mode(PhysicsServer::BodyMode p_mode) { btBody->setAngularVelocity(btVector3(0, 0, 0)); btBody->setLinearVelocity(btVector3(0, 0, 0)); } -PhysicsServer::BodyMode RigidBodyBullet::get_mode() const { +PhysicsServer3D::BodyMode RigidBodyBullet::get_mode() const { return mode; } -void RigidBodyBullet::set_state(PhysicsServer::BodyState p_state, const Variant &p_variant) { +void RigidBodyBullet::set_state(PhysicsServer3D::BodyState p_state, const Variant &p_variant) { switch (p_state) { - case PhysicsServer::BODY_STATE_TRANSFORM: + case PhysicsServer3D::BODY_STATE_TRANSFORM: set_transform(p_variant); break; - case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: + case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: set_linear_velocity(p_variant); break; - case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: + case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: set_angular_velocity(p_variant); break; - case PhysicsServer::BODY_STATE_SLEEPING: + case PhysicsServer3D::BODY_STATE_SLEEPING: set_activation_state(!bool(p_variant)); break; - case PhysicsServer::BODY_STATE_CAN_SLEEP: + case PhysicsServer3D::BODY_STATE_CAN_SLEEP: can_sleep = bool(p_variant); if (!can_sleep) { // Can't sleep @@ -606,17 +606,17 @@ void RigidBodyBullet::set_state(PhysicsServer::BodyState p_state, const Variant } } -Variant RigidBodyBullet::get_state(PhysicsServer::BodyState p_state) const { +Variant RigidBodyBullet::get_state(PhysicsServer3D::BodyState p_state) const { switch (p_state) { - case PhysicsServer::BODY_STATE_TRANSFORM: + case PhysicsServer3D::BODY_STATE_TRANSFORM: return get_transform(); - case PhysicsServer::BODY_STATE_LINEAR_VELOCITY: + case PhysicsServer3D::BODY_STATE_LINEAR_VELOCITY: return get_linear_velocity(); - case PhysicsServer::BODY_STATE_ANGULAR_VELOCITY: + case PhysicsServer3D::BODY_STATE_ANGULAR_VELOCITY: return get_angular_velocity(); - case PhysicsServer::BODY_STATE_SLEEPING: + case PhysicsServer3D::BODY_STATE_SLEEPING: return !is_active(); - case PhysicsServer::BODY_STATE_CAN_SLEEP: + case PhysicsServer3D::BODY_STATE_CAN_SLEEP: return can_sleep; default: WARN_PRINT("This state " + itos(p_state) + " is not supported by Bullet"); @@ -714,7 +714,7 @@ Vector3 RigidBodyBullet::get_applied_torque() const { return gTotTorq; } -void RigidBodyBullet::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) { +void RigidBodyBullet::set_axis_lock(PhysicsServer3D::BodyAxis p_axis, bool lock) { if (lock) { locked_axis |= p_axis; } else { @@ -724,18 +724,18 @@ void RigidBodyBullet::set_axis_lock(PhysicsServer::BodyAxis p_axis, bool lock) { reload_axis_lock(); } -bool RigidBodyBullet::is_axis_locked(PhysicsServer::BodyAxis p_axis) const { +bool RigidBodyBullet::is_axis_locked(PhysicsServer3D::BodyAxis p_axis) const { return locked_axis & p_axis; } void RigidBodyBullet::reload_axis_lock() { - btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_LINEAR_Z)))); - if (PhysicsServer::BODY_MODE_CHARACTER == mode) { + btBody->setLinearFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_LINEAR_Z)))); + if (PhysicsServer3D::BODY_MODE_CHARACTER == mode) { /// When character angular is always locked btBody->setAngularFactor(btVector3(0., 0., 0.)); } else { - btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer::BODY_AXIS_ANGULAR_Z)))); + btBody->setAngularFactor(btVector3(float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_X)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Y)), float(!is_axis_locked(PhysicsServer3D::BODY_AXIS_ANGULAR_Z)))); } } @@ -794,7 +794,7 @@ Vector3 RigidBodyBullet::get_angular_velocity() const { } void RigidBodyBullet::set_transform__bullet(const btTransform &p_global_transform) { - if (mode == PhysicsServer::BODY_MODE_KINEMATIC) { + if (mode == PhysicsServer3D::BODY_MODE_KINEMATIC) { if (space && space->get_delta_time() != 0) btBody->setLinearVelocity((p_global_transform.getOrigin() - btBody->getWorldTransform().getOrigin()) / space->get_delta_time()); // The kinematic use MotionState class @@ -862,7 +862,7 @@ void RigidBodyBullet::on_enter_area(AreaBullet *p_area) { } } } - if (PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) { + if (PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) { scratch_space_override_modificator(); } @@ -895,7 +895,7 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) { --areaWhereIamCount; areasWhereIam.write[areaWhereIamCount] = NULL; // Even if this is not required, I clear the last element to be safe - if (PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) { + if (PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED != p_area->get_spOv_mode()) { scratch_space_override_modificator(); } } @@ -904,7 +904,7 @@ void RigidBodyBullet::on_exit_area(AreaBullet *p_area) { void RigidBodyBullet::reload_space_override_modificator() { // Make sure that kinematic bodies have their total gravity calculated - if (!is_active() && PhysicsServer::BODY_MODE_KINEMATIC != mode) + if (!is_active() && PhysicsServer3D::BODY_MODE_KINEMATIC != mode) return; Vector3 newGravity(space->get_gravity_direction() * space->get_gravity_magnitude()); @@ -920,7 +920,7 @@ void RigidBodyBullet::reload_space_override_modificator() { currentArea = areasWhereIam[i]; - if (!currentArea || PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED == currentArea->get_spOv_mode()) { + if (!currentArea || PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED == currentArea->get_spOv_mode()) { continue; } @@ -954,11 +954,11 @@ void RigidBodyBullet::reload_space_override_modificator() { } switch (currentArea->get_spOv_mode()) { - case PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_DISABLED: /// This area does not affect gravity/damp. These are generally areas /// that exist only to detect collisions, and objects entering or exiting them. break; - case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE: /// This area adds its gravity/damp values to whatever has been /// calculated so far. This way, many overlapping areas can combine /// their physics to make interesting @@ -967,7 +967,7 @@ void RigidBodyBullet::reload_space_override_modificator() { newAngularDamp += currentArea->get_spOv_angularDamp(); ++countCombined; break; - case PhysicsServer::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_COMBINE_REPLACE: /// This area adds its gravity/damp values to whatever has been calculated /// so far. Then stops taking into account the rest of the areas, even the /// default one. @@ -976,7 +976,7 @@ void RigidBodyBullet::reload_space_override_modificator() { newAngularDamp += currentArea->get_spOv_angularDamp(); ++countCombined; goto endAreasCycle; - case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE: /// This area replaces any gravity/damp, even the default one, and /// stops taking into account the rest of the areas. newGravity = support_gravity; @@ -984,7 +984,7 @@ void RigidBodyBullet::reload_space_override_modificator() { newAngularDamp = currentArea->get_spOv_angularDamp(); countCombined = 1; goto endAreasCycle; - case PhysicsServer::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: + case PhysicsServer3D::AREA_SPACE_OVERRIDE_REPLACE_COMBINE: /// This area replaces any gravity/damp calculated so far, but keeps /// calculating the rest of the areas, down to the default one. newGravity = support_gravity; @@ -1032,14 +1032,14 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) { const bool isDynamic = p_mass != 0.f; if (isDynamic) { - if (PhysicsServer::BODY_MODE_RIGID != mode && PhysicsServer::BODY_MODE_CHARACTER != mode) + if (PhysicsServer3D::BODY_MODE_RIGID != mode && PhysicsServer3D::BODY_MODE_CHARACTER != mode) return; m_isStatic = false; if (mainShape) mainShape->calculateLocalInertia(p_mass, localInertia); - if (PhysicsServer::BODY_MODE_RIGID == mode) { + if (PhysicsServer3D::BODY_MODE_RIGID == mode) { btBody->setCollisionFlags(clearedCurrentFlags); // Just set the flags without Kin and Static } else { @@ -1054,11 +1054,11 @@ void RigidBodyBullet::_internal_set_mass(real_t p_mass) { } } else { - if (PhysicsServer::BODY_MODE_STATIC != mode && PhysicsServer::BODY_MODE_KINEMATIC != mode) + if (PhysicsServer3D::BODY_MODE_STATIC != mode && PhysicsServer3D::BODY_MODE_KINEMATIC != mode) return; m_isStatic = true; - if (PhysicsServer::BODY_MODE_STATIC == mode) { + if (PhysicsServer3D::BODY_MODE_STATIC == mode) { btBody->setCollisionFlags(clearedCurrentFlags | btCollisionObject::CF_STATIC_OBJECT); } else { |