Path: blob/master/modules/godot_physics_3d/joints/godot_pin_joint_3d.h
10278 views
/**************************************************************************/1/* godot_pin_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 GodotPinJoint3D : public GodotJoint3D {55union {56struct {57GodotBody3D *A;58GodotBody3D *B;59};6061GodotBody3D *_arr[2] = {};62};6364real_t m_tau = 0.3; //bias65real_t m_damping = 1.0;66real_t m_impulseClamp = 0.0;67real_t m_appliedImpulse = 0.0;6869GodotJacobianEntry3D m_jac[3] = {}; //3 orthogonal linear constraints7071Vector3 m_pivotInA;72Vector3 m_pivotInB;7374public:75virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_PIN; }7677virtual bool setup(real_t p_step) override;78virtual void solve(real_t p_step) override;7980void set_param(PhysicsServer3D::PinJointParam p_param, real_t p_value);81real_t get_param(PhysicsServer3D::PinJointParam p_param) const;8283void set_pos_a(const Vector3 &p_pos) { m_pivotInA = p_pos; }84void set_pos_b(const Vector3 &p_pos) { m_pivotInB = p_pos; }8586Vector3 get_position_a() { return m_pivotInA; }87Vector3 get_position_b() { return m_pivotInB; }8889GodotPinJoint3D(GodotBody3D *p_body_a, const Vector3 &p_pos_a, GodotBody3D *p_body_b, const Vector3 &p_pos_b);90~GodotPinJoint3D();91};929394