Path: blob/master/modules/godot_physics_3d/joints/godot_hinge_joint_3d.h
10278 views
/**************************************************************************/1/* godot_hinge_joint_3d.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132/*33Adapted to Godot from the Bullet library.34*/3536#include "../godot_joint_3d.h"37#include "godot_jacobian_entry_3d.h"3839/*40Bullet Continuous Collision Detection and Physics Library41Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/4243This software is provided 'as-is', without any express or implied warranty.44In no event will the authors be held liable for any damages arising from the use of this software.45Permission is granted to anyone to use this software for any purpose,46including commercial applications, and to alter it and redistribute it freely,47subject to the following restrictions:48491. 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.502. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.513. This notice may not be removed or altered from any source distribution.52*/5354class GodotHingeJoint3D : public GodotJoint3D {55union {56struct {57GodotBody3D *A;58GodotBody3D *B;59};6061GodotBody3D *_arr[2] = {};62};6364GodotJacobianEntry3D m_jac[3]; //3 orthogonal linear constraints65GodotJacobianEntry3D m_jacAng[3]; //2 orthogonal angular constraints+ 1 for limit/motor6667Transform3D m_rbAFrame; // constraint axii. Assumes z is hinge axis.68Transform3D m_rbBFrame;6970real_t m_motorTargetVelocity = 0.0;71real_t m_maxMotorImpulse = 0.0;7273real_t m_limitSoftness = 0.9;74real_t m_biasFactor = 0.3;75real_t m_relaxationFactor = 1.0;7677real_t m_lowerLimit = Math::PI;78real_t m_upperLimit = -Math::PI;7980real_t m_kHinge = 0.0;8182real_t m_limitSign = 0.0;83real_t m_correction = 0.0;8485real_t m_accLimitImpulse = 0.0;8687real_t tau = 0.3;8889bool m_useLimit = false;90bool m_angularOnly = false;91bool m_enableAngularMotor = false;92bool m_solveLimit = false;9394real_t m_appliedImpulse = 0.0;9596public:97virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_HINGE; }9899virtual bool setup(real_t p_step) override;100virtual void solve(real_t p_step) override;101102real_t get_hinge_angle();103104void set_param(PhysicsServer3D::HingeJointParam p_param, real_t p_value);105real_t get_param(PhysicsServer3D::HingeJointParam p_param) const;106107void set_flag(PhysicsServer3D::HingeJointFlag p_flag, bool p_value);108bool get_flag(PhysicsServer3D::HingeJointFlag p_flag) const;109110GodotHingeJoint3D(GodotBody3D *rbA, GodotBody3D *rbB, const Transform3D &frameA, const Transform3D &frameB);111GodotHingeJoint3D(GodotBody3D *rbA, GodotBody3D *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB);112};113114115