2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
2021-10-18 19:24:30 +00:00
|
|
|
/* godot_cone_twist_joint_3d.cpp */
|
2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* This file is part of: */
|
|
|
|
/* GODOT ENGINE */
|
2017-08-27 12:16:55 +00:00
|
|
|
/* https://godotengine.org */
|
2016-06-18 12:46:12 +00:00
|
|
|
/*************************************************************************/
|
2022-01-03 20:27:34 +00:00
|
|
|
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
|
|
|
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
2016-06-18 12:46:12 +00: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.
|
2017-05-06 21:38:44 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Bullet Continuous Collision Detection and Physics Library
|
|
|
|
ConeTwistJointSW is Copyright (c) 2007 Starbreeze Studios
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
Written by: Marcus Hennix
|
2016-06-18 12:46:12 +00:00
|
|
|
*/
|
|
|
|
|
2021-10-18 19:24:30 +00:00
|
|
|
#include "godot_cone_twist_joint_3d.h"
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
static void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) {
|
2019-12-10 04:13:02 +00:00
|
|
|
if (Math::abs(n.z) > Math_SQRT12) {
|
2017-03-05 15:44:50 +00:00
|
|
|
// choose p in y-z plane
|
|
|
|
real_t a = n[1] * n[1] + n[2] * n[2];
|
|
|
|
real_t k = 1.0 / Math::sqrt(a);
|
|
|
|
p = Vector3(0, -n[2] * k, n[1] * k);
|
|
|
|
// set q = n x p
|
|
|
|
q = Vector3(a * k, -n[0] * p[2], n[0] * p[1]);
|
|
|
|
} else {
|
|
|
|
// choose p in x-y plane
|
|
|
|
real_t a = n.x * n.x + n.y * n.y;
|
|
|
|
real_t k = 1.0 / Math::sqrt(a);
|
|
|
|
p = Vector3(-n.y * k, n.x * k, 0);
|
|
|
|
// set q = n x p
|
|
|
|
q = Vector3(-n.z * p.y, n.z * p.x, a * k);
|
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) {
|
2014-09-15 14:33:30 +00:00
|
|
|
real_t coeff_1 = Math_PI / 4.0f;
|
|
|
|
real_t coeff_2 = 3.0f * coeff_1;
|
|
|
|
real_t abs_y = Math::abs(y);
|
|
|
|
real_t angle;
|
|
|
|
if (x >= 0.0f) {
|
|
|
|
real_t r = (x - abs_y) / (x + abs_y);
|
|
|
|
angle = coeff_1 - coeff_1 * r;
|
|
|
|
} else {
|
|
|
|
real_t r = (x + abs_y) / (abs_y - x);
|
|
|
|
angle = coeff_2 - coeff_1 * r;
|
|
|
|
}
|
|
|
|
return (y < 0.0f) ? -angle : angle;
|
|
|
|
}
|
|
|
|
|
2021-10-18 19:24:30 +00:00
|
|
|
GodotConeTwistJoint3D::GodotConeTwistJoint3D(GodotBody3D *rbA, GodotBody3D *rbB, const Transform3D &rbAFrame, const Transform3D &rbBFrame) :
|
|
|
|
GodotJoint3D(_arr, 2) {
|
2017-03-05 15:44:50 +00:00
|
|
|
A = rbA;
|
|
|
|
B = rbB;
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
m_rbAFrame = rbAFrame;
|
|
|
|
m_rbBFrame = rbBFrame;
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
A->add_constraint(this, 0);
|
|
|
|
B->add_constraint(this, 1);
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
2021-10-18 19:24:30 +00:00
|
|
|
bool GodotConeTwistJoint3D::setup(real_t p_timestep) {
|
2021-04-20 01:38:11 +00:00
|
|
|
dynamic_A = (A->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
|
|
|
|
dynamic_B = (B->get_mode() > PhysicsServer3D::BODY_MODE_KINEMATIC);
|
|
|
|
|
|
|
|
if (!dynamic_A && !dynamic_B) {
|
2021-04-16 00:37:45 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-15 14:33:30 +00:00
|
|
|
m_appliedImpulse = real_t(0.);
|
|
|
|
|
|
|
|
//set bias, sign, clear accumulator
|
|
|
|
m_swingCorrection = real_t(0.);
|
|
|
|
m_twistLimitSign = real_t(0.);
|
|
|
|
m_solveTwistLimit = false;
|
|
|
|
m_solveSwingLimit = false;
|
|
|
|
m_accTwistLimitImpulse = real_t(0.);
|
|
|
|
m_accSwingLimitImpulse = real_t(0.);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (!m_angularOnly) {
|
2014-09-15 14:33:30 +00:00
|
|
|
Vector3 pivotAInW = A->get_transform().xform(m_rbAFrame.origin);
|
|
|
|
Vector3 pivotBInW = B->get_transform().xform(m_rbBFrame.origin);
|
|
|
|
Vector3 relPos = pivotBInW - pivotAInW;
|
|
|
|
|
|
|
|
Vector3 normal[3];
|
2019-01-16 15:42:53 +00:00
|
|
|
if (Math::is_zero_approx(relPos.length_squared())) {
|
2017-03-05 15:44:50 +00:00
|
|
|
normal[0] = Vector3(real_t(1.0), 0, 0);
|
2019-01-16 15:42:53 +00:00
|
|
|
} else {
|
|
|
|
normal[0] = relPos.normalized();
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
plane_space(normal[0], normal[1], normal[2]);
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < 3; i++) {
|
2021-10-28 13:19:35 +00:00
|
|
|
memnew_placement(
|
|
|
|
&m_jac[i],
|
|
|
|
GodotJacobianEntry3D(
|
|
|
|
A->get_principal_inertia_axes().transposed(),
|
|
|
|
B->get_principal_inertia_axes().transposed(),
|
|
|
|
pivotAInW - A->get_transform().origin - A->get_center_of_mass(),
|
|
|
|
pivotBInW - B->get_transform().origin - B->get_center_of_mass(),
|
|
|
|
normal[i],
|
|
|
|
A->get_inv_inertia(),
|
|
|
|
A->get_inv_mass(),
|
|
|
|
B->get_inv_inertia(),
|
|
|
|
B->get_inv_mass()));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
Vector3 b1Axis1, b1Axis2, b1Axis3;
|
|
|
|
Vector3 b2Axis1, b2Axis2;
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2022-05-03 12:50:35 +00:00
|
|
|
b1Axis1 = A->get_transform().basis.xform(this->m_rbAFrame.basis.get_column(0));
|
|
|
|
b2Axis1 = B->get_transform().basis.xform(this->m_rbBFrame.basis.get_column(0));
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
real_t swing1 = real_t(0.), swing2 = real_t(0.);
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
real_t swx = real_t(0.), swy = real_t(0.);
|
2014-09-15 14:33:30 +00:00
|
|
|
real_t thresh = real_t(10.);
|
|
|
|
real_t fact;
|
|
|
|
|
|
|
|
// Get Frame into world space
|
2017-03-05 15:44:50 +00:00
|
|
|
if (m_swingSpan1 >= real_t(0.05f)) {
|
2022-05-03 12:50:35 +00:00
|
|
|
b1Axis2 = A->get_transform().basis.xform(this->m_rbAFrame.basis.get_column(1));
|
2017-01-14 11:26:56 +00:00
|
|
|
//swing1 = btAtan2Fast( b2Axis1.dot(b1Axis2),b2Axis1.dot(b1Axis1) );
|
2014-09-15 14:33:30 +00:00
|
|
|
swx = b2Axis1.dot(b1Axis1);
|
|
|
|
swy = b2Axis1.dot(b1Axis2);
|
2017-03-05 15:44:50 +00:00
|
|
|
swing1 = atan2fast(swy, swx);
|
|
|
|
fact = (swy * swy + swx * swx) * thresh * thresh;
|
2014-09-15 14:33:30 +00:00
|
|
|
fact = fact / (fact + real_t(1.0));
|
|
|
|
swing1 *= fact;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (m_swingSpan2 >= real_t(0.05f)) {
|
2022-05-03 12:50:35 +00:00
|
|
|
b1Axis3 = A->get_transform().basis.xform(this->m_rbAFrame.basis.get_column(2));
|
2017-01-14 11:26:56 +00:00
|
|
|
//swing2 = btAtan2Fast( b2Axis1.dot(b1Axis3),b2Axis1.dot(b1Axis1) );
|
2014-09-15 14:33:30 +00:00
|
|
|
swx = b2Axis1.dot(b1Axis1);
|
|
|
|
swy = b2Axis1.dot(b1Axis3);
|
2017-03-05 15:44:50 +00:00
|
|
|
swing2 = atan2fast(swy, swx);
|
|
|
|
fact = (swy * swy + swx * swx) * thresh * thresh;
|
2014-09-15 14:33:30 +00:00
|
|
|
fact = fact / (fact + real_t(1.0));
|
|
|
|
swing2 *= fact;
|
|
|
|
}
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
real_t RMaxAngle1Sq = 1.0f / (m_swingSpan1 * m_swingSpan1);
|
|
|
|
real_t RMaxAngle2Sq = 1.0f / (m_swingSpan2 * m_swingSpan2);
|
|
|
|
real_t EllipseAngle = Math::abs(swing1 * swing1) * RMaxAngle1Sq + Math::abs(swing2 * swing2) * RMaxAngle2Sq;
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
if (EllipseAngle > 1.0f) {
|
|
|
|
m_swingCorrection = EllipseAngle - 1.0f;
|
2014-09-15 14:33:30 +00:00
|
|
|
m_solveSwingLimit = true;
|
|
|
|
|
|
|
|
// Calculate necessary axis & factors
|
2017-03-05 15:44:50 +00:00
|
|
|
m_swingAxis = b2Axis1.cross(b1Axis2 * b2Axis1.dot(b1Axis2) + b1Axis3 * b2Axis1.dot(b1Axis3));
|
2014-09-15 14:33:30 +00:00
|
|
|
m_swingAxis.normalize();
|
|
|
|
|
|
|
|
real_t swingAxisSign = (b2Axis1.dot(b1Axis1) >= 0.0f) ? 1.0f : -1.0f;
|
|
|
|
m_swingAxis *= swingAxisSign;
|
|
|
|
|
2021-10-28 13:19:35 +00:00
|
|
|
m_kSwing = real_t(1.) / (A->compute_angular_impulse_denominator(m_swingAxis) + B->compute_angular_impulse_denominator(m_swingAxis));
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Twist limits
|
2017-03-05 15:44:50 +00:00
|
|
|
if (m_twistSpan >= real_t(0.)) {
|
2022-05-03 12:50:35 +00:00
|
|
|
Vector3 b2Axis22 = B->get_transform().basis.xform(this->m_rbBFrame.basis.get_column(1));
|
2021-01-20 07:02:02 +00:00
|
|
|
Quaternion rotationArc = Quaternion(b2Axis1, b1Axis1);
|
2019-02-12 20:10:08 +00:00
|
|
|
Vector3 TwistRef = rotationArc.xform(b2Axis22);
|
2017-03-05 15:44:50 +00:00
|
|
|
real_t twist = atan2fast(TwistRef.dot(b1Axis3), TwistRef.dot(b1Axis2));
|
2014-09-15 14:33:30 +00:00
|
|
|
|
|
|
|
real_t lockedFreeFactor = (m_twistSpan > real_t(0.05f)) ? m_limitSoftness : real_t(0.);
|
2017-03-05 15:44:50 +00:00
|
|
|
if (twist <= -m_twistSpan * lockedFreeFactor) {
|
2014-09-15 14:33:30 +00:00
|
|
|
m_twistCorrection = -(twist + m_twistSpan);
|
|
|
|
m_solveTwistLimit = true;
|
|
|
|
|
|
|
|
m_twistAxis = (b2Axis1 + b1Axis1) * 0.5f;
|
|
|
|
m_twistAxis.normalize();
|
|
|
|
m_twistAxis *= -1.0f;
|
|
|
|
|
2021-10-28 13:19:35 +00:00
|
|
|
m_kTwist = real_t(1.) / (A->compute_angular_impulse_denominator(m_twistAxis) + B->compute_angular_impulse_denominator(m_twistAxis));
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
} else if (twist > m_twistSpan * lockedFreeFactor) {
|
|
|
|
m_twistCorrection = (twist - m_twistSpan);
|
|
|
|
m_solveTwistLimit = true;
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
m_twistAxis = (b2Axis1 + b1Axis1) * 0.5f;
|
|
|
|
m_twistAxis.normalize();
|
2014-09-15 14:33:30 +00:00
|
|
|
|
2021-10-28 13:19:35 +00:00
|
|
|
m_kTwist = real_t(1.) / (A->compute_angular_impulse_denominator(m_twistAxis) + B->compute_angular_impulse_denominator(m_twistAxis));
|
2017-03-05 15:44:50 +00:00
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-10-18 19:24:30 +00:00
|
|
|
void GodotConeTwistJoint3D::solve(real_t p_timestep) {
|
2014-09-15 14:33:30 +00:00
|
|
|
Vector3 pivotAInW = A->get_transform().xform(m_rbAFrame.origin);
|
|
|
|
Vector3 pivotBInW = B->get_transform().xform(m_rbBFrame.origin);
|
|
|
|
|
|
|
|
real_t tau = real_t(0.3);
|
|
|
|
|
|
|
|
//linear part
|
2017-03-05 15:44:50 +00:00
|
|
|
if (!m_angularOnly) {
|
2014-09-15 14:33:30 +00:00
|
|
|
Vector3 rel_pos1 = pivotAInW - A->get_transform().origin;
|
|
|
|
Vector3 rel_pos2 = pivotBInW - B->get_transform().origin;
|
|
|
|
|
|
|
|
Vector3 vel1 = A->get_velocity_in_local_point(rel_pos1);
|
|
|
|
Vector3 vel2 = B->get_velocity_in_local_point(rel_pos2);
|
|
|
|
Vector3 vel = vel1 - vel2;
|
|
|
|
|
2017-03-05 15:44:50 +00:00
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
const Vector3 &normal = m_jac[i].m_linearJointAxis;
|
2014-09-15 14:33:30 +00:00
|
|
|
real_t jacDiagABInv = real_t(1.) / m_jac[i].getDiagonal();
|
|
|
|
|
|
|
|
real_t rel_vel;
|
|
|
|
rel_vel = normal.dot(vel);
|
|
|
|
//positional error (zeroth order error)
|
|
|
|
real_t depth = -(pivotAInW - pivotBInW).dot(normal); //this is the error projected on the normal
|
2017-08-11 19:10:05 +00:00
|
|
|
real_t impulse = depth * tau / p_timestep * jacDiagABInv - rel_vel * jacDiagABInv;
|
2014-09-15 14:33:30 +00:00
|
|
|
m_appliedImpulse += impulse;
|
|
|
|
Vector3 impulse_vector = normal * impulse;
|
2021-04-20 01:38:11 +00:00
|
|
|
if (dynamic_A) {
|
|
|
|
A->apply_impulse(impulse_vector, pivotAInW - A->get_transform().origin);
|
|
|
|
}
|
|
|
|
if (dynamic_B) {
|
|
|
|
B->apply_impulse(-impulse_vector, pivotBInW - B->get_transform().origin);
|
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
///solve angular part
|
2017-03-05 15:44:50 +00:00
|
|
|
const Vector3 &angVelA = A->get_angular_velocity();
|
|
|
|
const Vector3 &angVelB = B->get_angular_velocity();
|
2014-09-15 14:33:30 +00:00
|
|
|
|
|
|
|
// solve swing limit
|
2017-03-05 15:44:50 +00:00
|
|
|
if (m_solveSwingLimit) {
|
2017-08-11 19:10:05 +00:00
|
|
|
real_t amplitude = ((angVelB - angVelA).dot(m_swingAxis) * m_relaxationFactor * m_relaxationFactor + m_swingCorrection * (real_t(1.) / p_timestep) * m_biasFactor);
|
2014-09-15 14:33:30 +00:00
|
|
|
real_t impulseMag = amplitude * m_kSwing;
|
|
|
|
|
|
|
|
// Clamp the accumulated impulse
|
|
|
|
real_t temp = m_accSwingLimitImpulse;
|
2017-03-05 15:44:50 +00:00
|
|
|
m_accSwingLimitImpulse = MAX(m_accSwingLimitImpulse + impulseMag, real_t(0.0));
|
2014-09-15 14:33:30 +00:00
|
|
|
impulseMag = m_accSwingLimitImpulse - temp;
|
|
|
|
|
|
|
|
Vector3 impulse = m_swingAxis * impulseMag;
|
|
|
|
|
2021-04-20 01:38:11 +00:00
|
|
|
if (dynamic_A) {
|
|
|
|
A->apply_torque_impulse(impulse);
|
|
|
|
}
|
|
|
|
if (dynamic_B) {
|
|
|
|
B->apply_torque_impulse(-impulse);
|
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// solve twist limit
|
2017-03-05 15:44:50 +00:00
|
|
|
if (m_solveTwistLimit) {
|
2017-08-11 19:10:05 +00:00
|
|
|
real_t amplitude = ((angVelB - angVelA).dot(m_twistAxis) * m_relaxationFactor * m_relaxationFactor + m_twistCorrection * (real_t(1.) / p_timestep) * m_biasFactor);
|
2014-09-15 14:33:30 +00:00
|
|
|
real_t impulseMag = amplitude * m_kTwist;
|
|
|
|
|
|
|
|
// Clamp the accumulated impulse
|
|
|
|
real_t temp = m_accTwistLimitImpulse;
|
2017-03-05 15:44:50 +00:00
|
|
|
m_accTwistLimitImpulse = MAX(m_accTwistLimitImpulse + impulseMag, real_t(0.0));
|
2014-09-15 14:33:30 +00:00
|
|
|
impulseMag = m_accTwistLimitImpulse - temp;
|
|
|
|
|
|
|
|
Vector3 impulse = m_twistAxis * impulseMag;
|
|
|
|
|
2021-04-20 01:38:11 +00:00
|
|
|
if (dynamic_A) {
|
|
|
|
A->apply_torque_impulse(impulse);
|
|
|
|
}
|
|
|
|
if (dynamic_B) {
|
|
|
|
B->apply_torque_impulse(-impulse);
|
|
|
|
}
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 19:24:30 +00:00
|
|
|
void GodotConeTwistJoint3D::set_param(PhysicsServer3D::ConeTwistJointParam p_param, real_t p_value) {
|
2017-03-05 15:44:50 +00:00
|
|
|
switch (p_param) {
|
2020-03-27 18:21:27 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: {
|
2017-03-05 15:44:50 +00:00
|
|
|
m_swingSpan1 = p_value;
|
|
|
|
m_swingSpan2 = p_value;
|
2014-09-15 14:33:30 +00:00
|
|
|
} break;
|
2020-03-27 18:21:27 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: {
|
2017-03-05 15:44:50 +00:00
|
|
|
m_twistSpan = p_value;
|
2014-09-15 14:33:30 +00:00
|
|
|
} break;
|
2020-03-27 18:21:27 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: {
|
2017-03-05 15:44:50 +00:00
|
|
|
m_biasFactor = p_value;
|
2014-09-15 14:33:30 +00:00
|
|
|
} break;
|
2020-03-27 18:21:27 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: {
|
2017-03-05 15:44:50 +00:00
|
|
|
m_limitSoftness = p_value;
|
2014-09-15 14:33:30 +00:00
|
|
|
} break;
|
2020-03-27 18:21:27 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: {
|
2017-03-05 15:44:50 +00:00
|
|
|
m_relaxationFactor = p_value;
|
2014-09-15 14:33:30 +00:00
|
|
|
} break;
|
2020-05-10 11:00:47 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_MAX:
|
|
|
|
break; // Can't happen, but silences warning
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-18 19:24:30 +00:00
|
|
|
real_t GodotConeTwistJoint3D::get_param(PhysicsServer3D::ConeTwistJointParam p_param) const {
|
2017-03-05 15:44:50 +00:00
|
|
|
switch (p_param) {
|
2020-03-27 18:21:27 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_JOINT_SWING_SPAN: {
|
2014-09-15 14:33:30 +00:00
|
|
|
return m_swingSpan1;
|
|
|
|
} break;
|
2020-03-27 18:21:27 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_JOINT_TWIST_SPAN: {
|
2014-09-15 14:33:30 +00:00
|
|
|
return m_twistSpan;
|
|
|
|
} break;
|
2020-03-27 18:21:27 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_JOINT_BIAS: {
|
2014-09-15 14:33:30 +00:00
|
|
|
return m_biasFactor;
|
|
|
|
} break;
|
2020-03-27 18:21:27 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_JOINT_SOFTNESS: {
|
2014-09-15 14:33:30 +00:00
|
|
|
return m_limitSoftness;
|
|
|
|
} break;
|
2020-03-27 18:21:27 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_JOINT_RELAXATION: {
|
2014-09-15 14:33:30 +00:00
|
|
|
return m_relaxationFactor;
|
|
|
|
} break;
|
2020-05-10 11:00:47 +00:00
|
|
|
case PhysicsServer3D::CONE_TWIST_MAX:
|
|
|
|
break; // Can't happen, but silences warning
|
2014-09-15 14:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|