| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "../jolt_physics_server_3d.h" |
| 34 |
#include "jolt_joint_3d.h" |
| 35 |
|
| 36 |
#include "Jolt/Jolt.h" |
| 37 |
|
| 38 |
#include "Jolt/Physics/Body/Body.h" |
| 39 |
|
| 40 |
class JoltConeTwistJoint3D final : public JoltJoint3D { |
| 41 |
typedef PhysicsServer3D::ConeTwistJointParam Parameter; |
| 42 |
typedef JoltPhysicsServer3D::ConeTwistJointParamJolt JoltParameter; |
| 43 |
typedef JoltPhysicsServer3D::ConeTwistJointFlagJolt JoltFlag; |
| 44 |
|
| 45 |
double swing_limit_span = 0.0; |
| 46 |
double twist_limit_span = 0.0; |
| 47 |
|
| 48 |
double swing_motor_target_speed_y = 0.0; |
| 49 |
double swing_motor_target_speed_z = 0.0; |
| 50 |
double twist_motor_target_speed = 0.0; |
| 51 |
|
| 52 |
double swing_motor_max_torque = FLT_MAX; |
| 53 |
double twist_motor_max_torque = FLT_MAX; |
| 54 |
|
| 55 |
bool swing_limit_enabled = true; |
| 56 |
bool twist_limit_enabled = true; |
| 57 |
|
| 58 |
bool swing_motor_enabled = false; |
| 59 |
bool twist_motor_enabled = false; |
| 60 |
|
| 61 |
JPH::Constraint *_build_swing_twist(JPH::Body *p_jolt_body_a, JPH::Body *p_jolt_body_b, const Transform3D &p_shifted_ref_a, const Transform3D &p_shifted_ref_b, float p_swing_limit_span, float p_twist_limit_span) const; |
| 62 |
|
| 63 |
void _update_swing_motor_state(); |
| 64 |
void _update_twist_motor_state(); |
| 65 |
void _update_motor_velocity(); |
| 66 |
void _update_swing_motor_limit(); |
| 67 |
void _update_twist_motor_limit(); |
| 68 |
|
| 69 |
void _limits_changed(); |
| 70 |
void _swing_motor_state_changed(); |
| 71 |
void _twist_motor_state_changed(); |
| 72 |
void _motor_velocity_changed(); |
| 73 |
void _swing_motor_limit_changed(); |
| 74 |
void _twist_motor_limit_changed(); |
| 75 |
|
| 76 |
public: |
| 77 |
JoltConeTwistJoint3D(const JoltJoint3D &p_old_joint, JoltBody3D *p_body_a, JoltBody3D *p_body_b, const Transform3D &p_local_ref_a, const Transform3D &p_local_ref_b); |
| 78 |
|
| 79 |
virtual PhysicsServer3D::JointType get_type() const override { return PhysicsServer3D::JOINT_TYPE_CONE_TWIST; } |
| 80 |
|
| 81 |
double get_param(PhysicsServer3D::ConeTwistJointParam p_param) const; |
| 82 |
void set_param(PhysicsServer3D::ConeTwistJointParam p_param, double p_value); |
| 83 |
|
| 84 |
double get_jolt_param(JoltParameter p_param) const; |
| 85 |
void set_jolt_param(JoltParameter p_param, double p_value); |
| 86 |
|
| 87 |
bool get_jolt_flag(JoltFlag p_flag) const; |
| 88 |
void set_jolt_flag(JoltFlag p_flag, bool p_enabled); |
| 89 |
|
| 90 |
float get_applied_force() const; |
| 91 |
float get_applied_torque() const; |
| 92 |
|
| 93 |
virtual void rebuild() override; |
| 94 |
}; |