2016-06-18 14:46:12 +02:00
|
|
|
/*************************************************************************/
|
2020-03-28 13:19:05 +01:00
|
|
|
/* generic_6dof_joint_3d_sw.h */
|
2016-06-18 14:46:12 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 14:16:55 +02:00
|
|
|
/* https://godotengine.org */
|
2016-06-18 14:46:12 +02:00
|
|
|
/*************************************************************************/
|
2020-01-01 11:16:22 +01:00
|
|
|
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
|
2016-06-18 14:46:12 +02: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. */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Adapted to Godot from the Bullet library.
|
|
|
|
*/
|
|
|
|
|
2014-09-15 16:33:30 +02:00
|
|
|
#ifndef GENERIC_6DOF_JOINT_SW_H
|
|
|
|
#define GENERIC_6DOF_JOINT_SW_H
|
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
#include "servers/physics_3d/joints/jacobian_entry_3d_sw.h"
|
|
|
|
#include "servers/physics_3d/joints_3d_sw.h"
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
Bullet Continuous Collision Detection and Physics Library
|
|
|
|
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied warranty.
|
|
|
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it freely,
|
|
|
|
subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
2007-09-09
|
|
|
|
Generic6DOFJointSW Refactored by Francisco Le?n
|
|
|
|
email: projectileman@yahoo.com
|
|
|
|
http://gimpact.sf.net
|
|
|
|
*/
|
|
|
|
|
|
|
|
//! Rotation Limit structure for generic joints
|
2020-03-27 19:21:27 +01:00
|
|
|
class G6DOFRotationalLimitMotor3DSW {
|
2014-09-15 16:33:30 +02:00
|
|
|
public:
|
2017-03-05 16:44:50 +01:00
|
|
|
//! limit_parameters
|
|
|
|
//!@{
|
|
|
|
real_t m_loLimit; //!< joint limit
|
|
|
|
real_t m_hiLimit; //!< joint limit
|
|
|
|
real_t m_targetVelocity; //!< target motor velocity
|
|
|
|
real_t m_maxMotorForce; //!< max force on motor
|
|
|
|
real_t m_maxLimitForce; //!< max force on limit
|
|
|
|
real_t m_damping; //!< Damping.
|
|
|
|
real_t m_limitSoftness; //! Relaxation factor
|
|
|
|
real_t m_ERP; //!< Error tolerance factor when joint is at limit
|
|
|
|
real_t m_bounce; //!< restitution factor
|
|
|
|
bool m_enableMotor;
|
|
|
|
bool m_enableLimit;
|
|
|
|
|
|
|
|
//!@}
|
|
|
|
|
|
|
|
//! temp_variables
|
|
|
|
//!@{
|
|
|
|
real_t m_currentLimitError; //! How much is violated this limit
|
|
|
|
int m_currentLimit; //!< 0=free, 1=at lo limit, 2=at hi limit
|
|
|
|
real_t m_accumulatedImpulse;
|
|
|
|
//!@}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
G6DOFRotationalLimitMotor3DSW() {
|
2017-03-05 16:44:50 +01:00
|
|
|
m_accumulatedImpulse = 0.f;
|
|
|
|
m_targetVelocity = 0;
|
|
|
|
m_maxMotorForce = 0.1f;
|
|
|
|
m_maxLimitForce = 300.0f;
|
|
|
|
m_loLimit = -1e30;
|
|
|
|
m_hiLimit = 1e30;
|
|
|
|
m_ERP = 0.5f;
|
|
|
|
m_bounce = 0.0f;
|
|
|
|
m_damping = 1.0f;
|
|
|
|
m_limitSoftness = 0.5f;
|
|
|
|
m_currentLimit = 0;
|
|
|
|
m_currentLimitError = 0;
|
|
|
|
m_enableMotor = false;
|
|
|
|
m_enableLimit = false;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
G6DOFRotationalLimitMotor3DSW(const G6DOFRotationalLimitMotor3DSW &limot) {
|
2017-03-05 16:44:50 +01:00
|
|
|
m_targetVelocity = limot.m_targetVelocity;
|
|
|
|
m_maxMotorForce = limot.m_maxMotorForce;
|
|
|
|
m_limitSoftness = limot.m_limitSoftness;
|
|
|
|
m_loLimit = limot.m_loLimit;
|
|
|
|
m_hiLimit = limot.m_hiLimit;
|
|
|
|
m_ERP = limot.m_ERP;
|
|
|
|
m_bounce = limot.m_bounce;
|
|
|
|
m_currentLimit = limot.m_currentLimit;
|
|
|
|
m_currentLimitError = limot.m_currentLimitError;
|
|
|
|
m_enableMotor = limot.m_enableMotor;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
//! Is limited
|
2017-03-05 16:44:50 +01:00
|
|
|
bool isLimited() {
|
2018-10-06 22:20:41 +02:00
|
|
|
return (m_loLimit < m_hiLimit);
|
2017-03-05 16:44:50 +01:00
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
//! Need apply correction
|
2017-03-05 16:44:50 +01:00
|
|
|
bool needApplyTorques() {
|
2018-10-06 22:20:41 +02:00
|
|
|
return (m_enableMotor || m_currentLimit != 0);
|
2017-03-05 16:44:50 +01:00
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
//! calculates error
|
|
|
|
/*!
|
|
|
|
calculates m_currentLimit and m_currentLimitError.
|
|
|
|
*/
|
|
|
|
int testLimitValue(real_t test_value);
|
|
|
|
|
|
|
|
//! apply the correction impulses for two bodies
|
2020-03-27 19:21:27 +01:00
|
|
|
real_t solveAngularLimits(real_t timeStep, Vector3 &axis, real_t jacDiagABInv, Body3DSW *body0, Body3DSW *body1);
|
2017-03-05 16:44:50 +01:00
|
|
|
};
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
class G6DOFTranslationalLimitMotor3DSW {
|
2017-03-05 16:44:50 +01:00
|
|
|
public:
|
|
|
|
Vector3 m_lowerLimit; //!< the constraint lower limits
|
|
|
|
Vector3 m_upperLimit; //!< the constraint upper limits
|
|
|
|
Vector3 m_accumulatedImpulse;
|
|
|
|
//! Linear_Limit_parameters
|
|
|
|
//!@{
|
|
|
|
Vector3 m_limitSoftness; //!< Softness for linear limit
|
|
|
|
Vector3 m_damping; //!< Damping for linear limit
|
|
|
|
Vector3 m_restitution; //! Bounce parameter for linear limit
|
|
|
|
//!@}
|
|
|
|
bool enable_limit[3];
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
G6DOFTranslationalLimitMotor3DSW() {
|
2017-03-05 16:44:50 +01:00
|
|
|
m_lowerLimit = Vector3(0.f, 0.f, 0.f);
|
|
|
|
m_upperLimit = Vector3(0.f, 0.f, 0.f);
|
|
|
|
m_accumulatedImpulse = Vector3(0.f, 0.f, 0.f);
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
m_limitSoftness = Vector3(1, 1, 1) * 0.7f;
|
|
|
|
m_damping = Vector3(1, 1, 1) * real_t(1.0f);
|
|
|
|
m_restitution = Vector3(1, 1, 1) * real_t(0.5f);
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
enable_limit[0] = true;
|
|
|
|
enable_limit[1] = true;
|
|
|
|
enable_limit[2] = true;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
G6DOFTranslationalLimitMotor3DSW(const G6DOFTranslationalLimitMotor3DSW &other) {
|
2017-03-05 16:44:50 +01:00
|
|
|
m_lowerLimit = other.m_lowerLimit;
|
|
|
|
m_upperLimit = other.m_upperLimit;
|
|
|
|
m_accumulatedImpulse = other.m_accumulatedImpulse;
|
|
|
|
|
|
|
|
m_limitSoftness = other.m_limitSoftness;
|
|
|
|
m_damping = other.m_damping;
|
|
|
|
m_restitution = other.m_restitution;
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Test limit
|
2014-09-15 16:33:30 +02:00
|
|
|
/*!
|
|
|
|
- free means upper < lower,
|
|
|
|
- locked means upper == lower
|
|
|
|
- limited means upper > lower
|
|
|
|
- limitIndex: first 3 are linear, next 3 are angular
|
|
|
|
*/
|
2017-03-05 16:44:50 +01:00
|
|
|
inline bool isLimited(int limitIndex) {
|
|
|
|
return (m_upperLimit[limitIndex] >= m_lowerLimit[limitIndex]);
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
real_t solveLinearAxis(
|
|
|
|
real_t timeStep,
|
|
|
|
real_t jacDiagABInv,
|
2020-03-27 19:21:27 +01:00
|
|
|
Body3DSW *body1, const Vector3 &pointInA,
|
|
|
|
Body3DSW *body2, const Vector3 &pointInB,
|
2017-03-05 16:44:50 +01:00
|
|
|
int limit_index,
|
|
|
|
const Vector3 &axis_normal_on_a,
|
|
|
|
const Vector3 &anchorPos);
|
2014-09-15 16:33:30 +02:00
|
|
|
};
|
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
class Generic6DOFJoint3DSW : public Joint3DSW {
|
2014-09-15 16:33:30 +02:00
|
|
|
protected:
|
|
|
|
union {
|
|
|
|
struct {
|
2020-03-27 19:21:27 +01:00
|
|
|
Body3DSW *A;
|
|
|
|
Body3DSW *B;
|
2014-09-15 16:33:30 +02:00
|
|
|
};
|
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
Body3DSW *_arr[2];
|
2014-09-15 16:33:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//! relative_frames
|
2017-03-05 16:44:50 +01:00
|
|
|
//!@{
|
|
|
|
Transform m_frameInA; //!< the constraint space w.r.t body A
|
|
|
|
Transform m_frameInB; //!< the constraint space w.r.t body B
|
|
|
|
//!@}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
//! Jacobians
|
|
|
|
//!@{
|
2020-03-27 19:21:27 +01:00
|
|
|
JacobianEntry3DSW m_jacLinear[3]; //!< 3 orthogonal linear constraints
|
|
|
|
JacobianEntry3DSW m_jacAng[3]; //!< 3 orthogonal angular constraints
|
2017-03-05 16:44:50 +01:00
|
|
|
//!@}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
//! Linear_Limit_parameters
|
2017-03-05 16:44:50 +01:00
|
|
|
//!@{
|
2020-03-27 19:21:27 +01:00
|
|
|
G6DOFTranslationalLimitMotor3DSW m_linearLimits;
|
2014-09-15 16:33:30 +02:00
|
|
|
//!@}
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
//! hinge_parameters
|
|
|
|
//!@{
|
2020-03-27 19:21:27 +01:00
|
|
|
G6DOFRotationalLimitMotor3DSW m_angularLimits[3];
|
2017-03-05 16:44:50 +01:00
|
|
|
//!@}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
protected:
|
2017-03-05 16:44:50 +01:00
|
|
|
//! temporal variables
|
|
|
|
//!@{
|
|
|
|
real_t m_timeStep;
|
|
|
|
Transform m_calculatedTransformA;
|
|
|
|
Transform m_calculatedTransformB;
|
|
|
|
Vector3 m_calculatedAxisAngleDiff;
|
|
|
|
Vector3 m_calculatedAxis[3];
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-24 21:45:31 +01:00
|
|
|
Vector3 m_AnchorPos; // point between pivots of bodies A and B to solve linear axes
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
bool m_useLinearReferenceFrameA;
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
//!@}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
Generic6DOFJoint3DSW &operator=(Generic6DOFJoint3DSW &other) {
|
2017-03-05 16:44:50 +01:00
|
|
|
ERR_PRINT("pito");
|
|
|
|
(void)other;
|
|
|
|
return *this;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void buildLinearJacobian(
|
2020-03-27 19:21:27 +01:00
|
|
|
JacobianEntry3DSW &jacLinear, const Vector3 &normalWorld,
|
2017-03-05 16:44:50 +01:00
|
|
|
const Vector3 &pivotAInW, const Vector3 &pivotBInW);
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
void buildAngularJacobian(JacobianEntry3DSW &jacAngular, const Vector3 &jointAxisW);
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
//! calcs the euler angles between the two bodies.
|
2017-03-05 16:44:50 +01:00
|
|
|
void calculateAngleInfo();
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
public:
|
2020-03-27 19:21:27 +01:00
|
|
|
Generic6DOFJoint3DSW(Body3DSW *rbA, Body3DSW *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA);
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_6DOF; }
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-08-11 21:10:05 +02:00
|
|
|
virtual bool setup(real_t p_timestep);
|
|
|
|
virtual void solve(real_t p_timestep);
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
//! Calcs global transform of the offsets
|
|
|
|
/*!
|
|
|
|
Calcs the global transform for the joint offset for body A an B, and also calcs the agle differences between the bodies.
|
|
|
|
\sa Generic6DOFJointSW.getCalculatedTransformA , Generic6DOFJointSW.getCalculatedTransformB, Generic6DOFJointSW.calculateAngleInfo
|
|
|
|
*/
|
2017-03-05 16:44:50 +01:00
|
|
|
void calculateTransforms();
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
//! Gets the global transform of the offset for body A
|
2017-03-05 16:44:50 +01:00
|
|
|
/*!
|
2014-09-15 16:33:30 +02:00
|
|
|
\sa Generic6DOFJointSW.getFrameOffsetA, Generic6DOFJointSW.getFrameOffsetB, Generic6DOFJointSW.calculateAngleInfo.
|
|
|
|
*/
|
2017-03-05 16:44:50 +01:00
|
|
|
const Transform &getCalculatedTransformA() const {
|
|
|
|
return m_calculatedTransformA;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
//! Gets the global transform of the offset for body B
|
|
|
|
/*!
|
2014-09-15 16:33:30 +02:00
|
|
|
\sa Generic6DOFJointSW.getFrameOffsetA, Generic6DOFJointSW.getFrameOffsetB, Generic6DOFJointSW.calculateAngleInfo.
|
|
|
|
*/
|
2017-03-05 16:44:50 +01:00
|
|
|
const Transform &getCalculatedTransformB() const {
|
|
|
|
return m_calculatedTransformB;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
const Transform &getFrameOffsetA() const {
|
|
|
|
return m_frameInA;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
const Transform &getFrameOffsetB() const {
|
|
|
|
return m_frameInB;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Transform &getFrameOffsetA() {
|
|
|
|
return m_frameInA;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
Transform &getFrameOffsetB() {
|
|
|
|
return m_frameInB;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
//! performs Jacobian calculation, and also calculates angle differences and axis
|
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
void updateRHS(real_t timeStep);
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
//! Get the rotation axis in global coordinates
|
|
|
|
/*!
|
|
|
|
\pre Generic6DOFJointSW.buildJacobian must be called previously.
|
|
|
|
*/
|
2017-03-05 16:44:50 +01:00
|
|
|
Vector3 getAxis(int axis_index) const;
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2017-03-05 16:44:50 +01:00
|
|
|
//! Get the relative Euler angle
|
|
|
|
/*!
|
2014-09-15 16:33:30 +02:00
|
|
|
\pre Generic6DOFJointSW.buildJacobian must be called previously.
|
|
|
|
*/
|
2017-03-05 16:44:50 +01:00
|
|
|
real_t getAngle(int axis_index) const;
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
//! Test angular limit.
|
|
|
|
/*!
|
|
|
|
Calculates angular correction and returns true if limit needs to be corrected.
|
|
|
|
\pre Generic6DOFJointSW.buildJacobian must be called previously.
|
|
|
|
*/
|
2017-03-05 16:44:50 +01:00
|
|
|
bool testAngularLimitMotor(int axis_index);
|
|
|
|
|
|
|
|
void setLinearLowerLimit(const Vector3 &linearLower) {
|
|
|
|
m_linearLimits.m_lowerLimit = linearLower;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setLinearUpperLimit(const Vector3 &linearUpper) {
|
|
|
|
m_linearLimits.m_upperLimit = linearUpper;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAngularLowerLimit(const Vector3 &angularLower) {
|
|
|
|
m_angularLimits[0].m_loLimit = angularLower.x;
|
|
|
|
m_angularLimits[1].m_loLimit = angularLower.y;
|
|
|
|
m_angularLimits[2].m_loLimit = angularLower.z;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setAngularUpperLimit(const Vector3 &angularUpper) {
|
|
|
|
m_angularLimits[0].m_hiLimit = angularUpper.x;
|
|
|
|
m_angularLimits[1].m_hiLimit = angularUpper.y;
|
|
|
|
m_angularLimits[2].m_hiLimit = angularUpper.z;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
|
|
|
//! Retrieves the angular limit informacion
|
2020-03-27 19:21:27 +01:00
|
|
|
G6DOFRotationalLimitMotor3DSW *getRotationalLimitMotor(int index) {
|
2017-03-05 16:44:50 +01:00
|
|
|
return &m_angularLimits[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
//! Retrieves the limit informacion
|
2020-03-27 19:21:27 +01:00
|
|
|
G6DOFTranslationalLimitMotor3DSW *getTranslationalLimitMotor() {
|
2017-03-05 16:44:50 +01:00
|
|
|
return &m_linearLimits;
|
2014-09-15 16:33:30 +02:00
|
|
|
}
|
2017-03-05 16:44:50 +01:00
|
|
|
|
|
|
|
//first 3 are linear, next 3 are angular
|
|
|
|
void setLimit(int axis, real_t lo, real_t hi) {
|
|
|
|
if (axis < 3) {
|
|
|
|
m_linearLimits.m_lowerLimit[axis] = lo;
|
|
|
|
m_linearLimits.m_upperLimit[axis] = hi;
|
|
|
|
} else {
|
|
|
|
m_angularLimits[axis - 3].m_loLimit = lo;
|
|
|
|
m_angularLimits[axis - 3].m_hiLimit = hi;
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Test limit
|
|
|
|
/*!
|
|
|
|
- free means upper < lower,
|
|
|
|
- locked means upper == lower
|
|
|
|
- limited means upper > lower
|
|
|
|
- limitIndex: first 3 are linear, next 3 are angular
|
|
|
|
*/
|
2017-03-05 16:44:50 +01:00
|
|
|
bool isLimited(int limitIndex) {
|
|
|
|
if (limitIndex < 3) {
|
2014-09-15 16:33:30 +02:00
|
|
|
return m_linearLimits.isLimited(limitIndex);
|
2017-03-05 16:44:50 +01:00
|
|
|
}
|
|
|
|
return m_angularLimits[limitIndex - 3].isLimited();
|
|
|
|
}
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
const Body3DSW *getRigidBodyA() const {
|
2017-03-05 16:44:50 +01:00
|
|
|
return A;
|
|
|
|
}
|
2020-03-27 19:21:27 +01:00
|
|
|
const Body3DSW *getRigidBodyB() const {
|
2017-03-05 16:44:50 +01:00
|
|
|
return B;
|
2014-09-15 16:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void calcAnchorPos(void); // overridable
|
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
void set_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param, real_t p_value);
|
|
|
|
real_t get_param(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisParam p_param) const;
|
2014-09-15 16:33:30 +02:00
|
|
|
|
2020-03-27 19:21:27 +01:00
|
|
|
void set_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag, bool p_value);
|
|
|
|
bool get_flag(Vector3::Axis p_axis, PhysicsServer3D::G6DOFJointAxisFlag p_flag) const;
|
2014-09-15 16:33:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GENERIC_6DOF_JOINT_SW_H
|