2017-11-04 20:52:59 +01:00
|
|
|
/*************************************************************************/
|
|
|
|
/* generic_6dof_joint_bullet.cpp */
|
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2018-01-05 00:50:27 +01:00
|
|
|
/* https://godotengine.org */
|
2017-11-04 20:52:59 +01:00
|
|
|
/*************************************************************************/
|
2021-01-01 20:13:46 +01:00
|
|
|
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
2017-11-04 20:52:59 +01:00
|
|
|
/* */
|
|
|
|
/* Permission is hereby granted, free of charge, to any person obtaining */
|
|
|
|
/* a copy of this software and associated documentation files (the */
|
|
|
|
/* "Software"), to deal in the Software without restriction, including */
|
|
|
|
/* without limitation the rights to use, copy, modify, merge, publish, */
|
|
|
|
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
|
|
|
/* permit persons to whom the Software is furnished to do so, subject to */
|
|
|
|
/* the following conditions: */
|
|
|
|
/* */
|
|
|
|
/* The above copyright notice and this permission notice shall be */
|
|
|
|
/* included in all copies or substantial portions of the Software. */
|
|
|
|
/* */
|
|
|
|
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
|
|
|
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
|
|
|
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
|
|
|
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
|
|
|
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
|
|
|
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
|
|
|
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
#include "generic_6dof_joint_bullet.h"
|
2018-01-05 00:50:27 +01:00
|
|
|
|
2017-11-04 20:52:59 +01:00
|
|
|
#include "bullet_types_converter.h"
|
|
|
|
#include "bullet_utilities.h"
|
|
|
|
#include "rigid_body_bullet.h"
|
|
|
|
|
2018-08-15 18:14:32 +02:00
|
|
|
#include <BulletDynamics/ConstraintSolver/btGeneric6DofSpring2Constraint.h>
|
2018-01-05 00:50:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
@author AndreaCatania
|
|
|
|
*/
|
|
|
|
|
2020-10-17 07:08:21 +02:00
|
|
|
Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform3D &frameInA, const Transform3D &frameInB) :
|
2017-12-06 21:36:34 +01:00
|
|
|
JointBullet() {
|
2020-04-01 19:29:35 +02:00
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
for (int j = 0; j < PhysicsServer3D::G6DOF_JOINT_FLAG_MAX; j++) {
|
|
|
|
flags[i][j] = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 07:08:21 +02:00
|
|
|
Transform3D scaled_AFrame(frameInA.scaled(rbA->get_body_scale()));
|
2017-12-09 01:22:36 +01:00
|
|
|
|
|
|
|
scaled_AFrame.basis.rotref_posscale_decomposition(scaled_AFrame.basis);
|
|
|
|
|
2017-11-04 20:52:59 +01:00
|
|
|
btTransform btFrameA;
|
2017-12-09 01:22:36 +01:00
|
|
|
G_TO_B(scaled_AFrame, btFrameA);
|
2017-11-04 20:52:59 +01:00
|
|
|
|
|
|
|
if (rbB) {
|
2020-10-17 07:08:21 +02:00
|
|
|
Transform3D scaled_BFrame(frameInB.scaled(rbB->get_body_scale()));
|
2017-12-09 01:22:36 +01:00
|
|
|
|
|
|
|
scaled_BFrame.basis.rotref_posscale_decomposition(scaled_BFrame.basis);
|
|
|
|
|
2017-11-04 20:52:59 +01:00
|
|
|
btTransform btFrameB;
|
2017-12-09 01:22:36 +01:00
|
|
|
G_TO_B(scaled_BFrame, btFrameB);
|
2017-11-04 20:52:59 +01:00
|
|
|
|
2018-08-15 18:14:32 +02:00
|
|
|
sixDOFConstraint = bulletnew(btGeneric6DofSpring2Constraint(*rbA->get_bt_rigid_body(), *rbB->get_bt_rigid_body(), btFrameA, btFrameB));
|
2017-11-04 20:52:59 +01:00
|
|
|
} else {
|
2018-08-15 18:14:32 +02:00
|
|
|
sixDOFConstraint = bulletnew(btGeneric6DofSpring2Constraint(*rbA->get_bt_rigid_body(), btFrameA));
|
2017-11-04 20:52:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
setup(sixDOFConstraint);
|
|
|
|
}
|
|
|
|
|
2020-10-17 07:08:21 +02:00
|
|
|
Transform3D Generic6DOFJointBullet::getFrameOffsetA() const {
|
2017-11-04 20:52:59 +01:00
|
|
|
btTransform btTrs = sixDOFConstraint->getFrameOffsetA();
|
2020-10-17 07:08:21 +02:00
|
|
|
Transform3D gTrs;
|
2017-11-04 20:52:59 +01:00
|
|
|
B_TO_G(btTrs, gTrs);
|
|
|
|
return gTrs;
|
|
|
|
}
|
|
|
|
|
2020-10-17 07:08:21 +02:00
|
|
|
Transform3D Generic6DOFJointBullet::getFrameOffsetB() const {
|
2017-11-04 20:52:59 +01:00
|
|
|
btTransform btTrs = sixDOFConstraint->getFrameOffsetB();
|
2020-10-17 07:08:21 +02:00
|
|
|
Transform3D gTrs;
|
2017-11-04 20:52:59 +01:00
|
|
|
B_TO_G(btTrs, gTrs);
|
|
|
|
return gTrs;
|
|
|
|
}
|
|
|
|
|
2020-10-17 07:08:21 +02:00
|
|
|
Transform3D Generic6DOFJointBullet::getFrameOffsetA() {
|
2017-11-04 20:52:59 +01:00
|
|
|
btTransform btTrs = sixDOFConstraint->getFrameOffsetA();
|
2020-10-17 07:08:21 +02:00
|
|
|
Transform3D gTrs;
|
2017-11-04 20:52:59 +01:00
|
|
|
B_TO_G(btTrs, gTrs);
|
|
|
|
return gTrs;
|
|
|
|
}
|
|
|
|
|
2020-10-17 07:08:21 +02:00
|
|
|
Transform3D Generic6DOFJointBullet::getFrameOffsetB() {
|
2017-11-04 20:52:59 +01:00
|
|
|
btTransform btTrs = sixDOFConstraint->getFrameOffsetB();
|
2020-10-17 07:08:21 +02:00
|
|
|
Transform3D gTrs;
|
2017-11-04 20:52:59 +01:00
|
|
|
B_TO_G(btTrs, gTrs);
|
|
|
|
return gTrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Generic6DOFJointBullet::set_linear_lower_limit(const Vector3 &linearLower) {
|
|
|
|
btVector3 btVec;
|
|
|
|
G_TO_B(linearLower, btVec);
|
|
|
|
sixDOFConstraint->setLinearLowerLimit(btVec);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Generic6DOFJointBullet::set_linear_upper_limit(const Vector3 &linearUpper) {
|
|
|
|
btVector3 btVec;
|
|
|
|
G_TO_B(linearUpper, btVec);
|
|
|
|
sixDOFConstraint->setLinearUpperLimit(btVec);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Generic6DOFJointBullet::set_angular_lower_limit(const Vector3 &angularLower) {
|
|
|
|
btVector3 btVec;
|
|
|
|
G_TO_B(angularLower, btVec);
|
|
|
|
sixDOFConstraint->setAngularLowerLimit(btVec);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Generic6DOFJointBullet::set_angular_upper_limit(const Vector3 &angularUpper) {
|
|
|
|
btVector3 btVec;
|
|
|
|
G_TO_B(angularUpper, btVec);
|
|
|
|
sixDOFConstraint->setAngularUpperLimit(btVec);
|
|
|
|
}
|
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
void Generic6DOFJointBullet::set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value) {
|
2017-11-04 20:52:59 +01:00
|
|
|
ERR_FAIL_INDEX(p_axis, 3);
|
|
|
|
switch (p_param) {
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT:
|
2017-12-09 19:53:08 +01:00
|
|
|
limits_lower[0][p_axis] = p_value;
|
2020-03-27 19:21:27 +01:00
|
|
|
set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter
|
2017-11-04 20:52:59 +01:00
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT:
|
2017-12-09 19:53:08 +01:00
|
|
|
limits_upper[0][p_axis] = p_value;
|
2020-03-27 19:21:27 +01:00
|
|
|
set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT]); // Reload bullet parameter
|
2017-11-04 20:52:59 +01:00
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY:
|
2018-03-16 13:07:52 +01:00
|
|
|
sixDOFConstraint->getTranslationalLimitMotor()->m_targetVelocity.m_floats[p_axis] = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT:
|
2018-03-16 13:07:52 +01:00
|
|
|
sixDOFConstraint->getTranslationalLimitMotor()->m_maxMotorForce.m_floats[p_axis] = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING:
|
2018-11-09 12:58:57 +01:00
|
|
|
sixDOFConstraint->getTranslationalLimitMotor()->m_springDamping.m_floats[p_axis] = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS:
|
2018-11-09 12:58:57 +01:00
|
|
|
sixDOFConstraint->getTranslationalLimitMotor()->m_springStiffness.m_floats[p_axis] = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT:
|
2018-11-09 12:58:57 +01:00
|
|
|
sixDOFConstraint->getTranslationalLimitMotor()->m_equilibriumPoint.m_floats[p_axis] = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT:
|
2017-12-09 19:53:08 +01:00
|
|
|
limits_lower[1][p_axis] = p_value;
|
2020-03-27 19:21:27 +01:00
|
|
|
set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter
|
2017-11-04 20:52:59 +01:00
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT:
|
2017-12-09 19:53:08 +01:00
|
|
|
limits_upper[1][p_axis] = p_value;
|
2020-03-27 19:21:27 +01:00
|
|
|
set_flag(p_axis, PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT, flags[p_axis][PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT]); // Reload bullet parameter
|
2017-11-04 20:52:59 +01:00
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION:
|
2018-11-09 12:58:57 +01:00
|
|
|
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_bounce = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP:
|
2017-11-04 20:52:59 +01:00
|
|
|
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_stopERP = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY:
|
2017-11-04 20:52:59 +01:00
|
|
|
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_targetVelocity = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT:
|
2018-08-15 18:14:32 +02:00
|
|
|
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_maxMotorForce = p_value;
|
2017-11-04 20:52:59 +01:00
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS:
|
2018-11-09 12:58:57 +01:00
|
|
|
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springStiffness = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING:
|
2018-11-09 12:58:57 +01:00
|
|
|
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springDamping = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
|
2018-11-09 12:58:57 +01:00
|
|
|
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_MAX:
|
2020-02-13 11:37:37 +01:00
|
|
|
// Internal size value, nothing to do.
|
|
|
|
break;
|
2017-11-04 20:52:59 +01:00
|
|
|
default:
|
2019-08-11 10:49:53 +02:00
|
|
|
WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
|
2018-08-27 10:10:40 +02:00
|
|
|
break;
|
2017-11-04 20:52:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
real_t Generic6DOFJointBullet::get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const {
|
2017-11-04 20:52:59 +01:00
|
|
|
ERR_FAIL_INDEX_V(p_axis, 3, 0.);
|
|
|
|
switch (p_param) {
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_LOWER_LIMIT:
|
2017-12-09 19:53:08 +01:00
|
|
|
return limits_lower[0][p_axis];
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_UPPER_LIMIT:
|
2017-12-09 19:53:08 +01:00
|
|
|
return limits_upper[0][p_axis];
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_TARGET_VELOCITY:
|
2018-03-16 13:07:52 +01:00
|
|
|
return sixDOFConstraint->getTranslationalLimitMotor()->m_targetVelocity.m_floats[p_axis];
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_MOTOR_FORCE_LIMIT:
|
2018-03-16 13:07:52 +01:00
|
|
|
return sixDOFConstraint->getTranslationalLimitMotor()->m_maxMotorForce.m_floats[p_axis];
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_DAMPING:
|
2018-11-09 12:58:57 +01:00
|
|
|
return sixDOFConstraint->getTranslationalLimitMotor()->m_springDamping.m_floats[p_axis];
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_STIFFNESS:
|
2018-11-09 12:58:57 +01:00
|
|
|
return sixDOFConstraint->getTranslationalLimitMotor()->m_springStiffness.m_floats[p_axis];
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_LINEAR_SPRING_EQUILIBRIUM_POINT:
|
2018-11-09 12:58:57 +01:00
|
|
|
return sixDOFConstraint->getTranslationalLimitMotor()->m_equilibriumPoint.m_floats[p_axis];
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_LOWER_LIMIT:
|
2017-12-09 19:53:08 +01:00
|
|
|
return limits_lower[1][p_axis];
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_UPPER_LIMIT:
|
2017-12-09 19:53:08 +01:00
|
|
|
return limits_upper[1][p_axis];
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_RESTITUTION:
|
2017-11-04 20:52:59 +01:00
|
|
|
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_bounce;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_ERP:
|
2017-11-04 20:52:59 +01:00
|
|
|
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_stopERP;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_TARGET_VELOCITY:
|
2017-11-04 20:52:59 +01:00
|
|
|
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_targetVelocity;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_MOTOR_FORCE_LIMIT:
|
2018-08-15 18:14:32 +02:00
|
|
|
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_maxMotorForce;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_STIFFNESS:
|
2018-11-09 12:58:57 +01:00
|
|
|
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springStiffness;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_DAMPING:
|
2018-11-09 12:58:57 +01:00
|
|
|
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_springDamping;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_ANGULAR_SPRING_EQUILIBRIUM_POINT:
|
2018-11-09 12:58:57 +01:00
|
|
|
return sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_equilibriumPoint;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_MAX:
|
2020-02-13 11:37:37 +01:00
|
|
|
// Internal size value, nothing to do.
|
|
|
|
return 0;
|
2017-11-04 20:52:59 +01:00
|
|
|
default:
|
2019-08-11 10:49:53 +02:00
|
|
|
WARN_DEPRECATED_MSG("The parameter " + itos(p_param) + " is deprecated.");
|
2018-08-26 09:10:30 +02:00
|
|
|
return 0;
|
2017-11-04 20:52:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
void Generic6DOFJointBullet::set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value) {
|
2017-11-04 20:52:59 +01:00
|
|
|
ERR_FAIL_INDEX(p_axis, 3);
|
2017-12-09 19:53:08 +01:00
|
|
|
|
|
|
|
flags[p_axis][p_flag] = p_value;
|
|
|
|
|
2017-11-04 20:52:59 +01:00
|
|
|
switch (p_flag) {
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_LIMIT:
|
2017-12-09 19:53:08 +01:00
|
|
|
if (flags[p_axis][p_flag]) {
|
|
|
|
sixDOFConstraint->setLimit(p_axis, limits_lower[0][p_axis], limits_upper[0][p_axis]);
|
2017-11-04 20:52:59 +01:00
|
|
|
} else {
|
2017-12-09 19:53:08 +01:00
|
|
|
sixDOFConstraint->setLimit(p_axis, 0, -1); // Free
|
2017-11-04 20:52:59 +01:00
|
|
|
}
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_LIMIT:
|
2017-12-09 19:53:08 +01:00
|
|
|
if (flags[p_axis][p_flag]) {
|
|
|
|
sixDOFConstraint->setLimit(p_axis + 3, limits_lower[1][p_axis], limits_upper[1][p_axis]);
|
2017-11-04 20:52:59 +01:00
|
|
|
} else {
|
2017-12-09 19:53:08 +01:00
|
|
|
sixDOFConstraint->setLimit(p_axis + 3, 0, -1); // Free
|
2017-11-04 20:52:59 +01:00
|
|
|
}
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_ANGULAR_SPRING:
|
2020-02-13 11:37:37 +01:00
|
|
|
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableSpring = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_SPRING:
|
2020-02-13 11:37:37 +01:00
|
|
|
sixDOFConstraint->getTranslationalLimitMotor()->m_enableSpring[p_axis] = p_value;
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_MOTOR:
|
2017-12-09 19:53:08 +01:00
|
|
|
sixDOFConstraint->getRotationalLimitMotor(p_axis)->m_enableMotor = flags[p_axis][p_flag];
|
2017-11-04 20:52:59 +01:00
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_FLAG_ENABLE_LINEAR_MOTOR:
|
2018-03-16 13:07:52 +01:00
|
|
|
sixDOFConstraint->getTranslationalLimitMotor()->m_enableMotor[p_axis] = flags[p_axis][p_flag];
|
|
|
|
break;
|
2020-03-27 19:21:27 +01:00
|
|
|
case PhysicsServer3D::G6DOF_JOINT_FLAG_MAX:
|
2020-02-13 11:37:37 +01:00
|
|
|
// Internal size value, nothing to do.
|
2018-08-27 10:10:40 +02:00
|
|
|
break;
|
2017-11-04 20:52:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
bool Generic6DOFJointBullet::get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const {
|
2017-11-04 20:52:59 +01:00
|
|
|
ERR_FAIL_INDEX_V(p_axis, 3, false);
|
2017-12-09 19:53:08 +01:00
|
|
|
return flags[p_axis][p_flag];
|
2017-11-04 20:52:59 +01:00
|
|
|
}
|