| 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 "servers/physics_3d/physics_server_3d.h" |
| 34 |
|
| 35 |
#include "Jolt/Jolt.h" |
| 36 |
|
| 37 |
#include "Jolt/Physics/Constraints/Constraint.h" |
| 38 |
|
| 39 |
class JoltBody3D; |
| 40 |
class JoltSpace3D; |
| 41 |
|
| 42 |
class JoltJoint3D { |
| 43 |
protected: |
| 44 |
bool enabled = true; |
| 45 |
bool collision_disabled = false; |
| 46 |
|
| 47 |
int velocity_iterations = 0; |
| 48 |
int position_iterations = 0; |
| 49 |
|
| 50 |
JPH::Ref<JPH::Constraint> jolt_ref; |
| 51 |
|
| 52 |
JoltBody3D *body_a = nullptr; |
| 53 |
JoltBody3D *body_b = nullptr; |
| 54 |
|
| 55 |
RID rid; |
| 56 |
|
| 57 |
Transform3D local_ref_a; |
| 58 |
Transform3D local_ref_b; |
| 59 |
|
| 60 |
void _shift_reference_frames(const Vector3 &p_linear_shift, const Vector3 &p_angular_shift, Transform3D &r_shifted_ref_a, Transform3D &r_shifted_ref_b); |
| 61 |
|
| 62 |
void _wake_up_bodies(); |
| 63 |
|
| 64 |
void _update_enabled(); |
| 65 |
void _update_iterations(); |
| 66 |
|
| 67 |
void _enabled_changed(); |
| 68 |
void _iterations_changed(); |
| 69 |
|
| 70 |
String _bodies_to_string() const; |
| 71 |
|
| 72 |
public: |
| 73 |
JoltJoint3D() = default; |
| 74 |
JoltJoint3D(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); |
| 75 |
virtual ~JoltJoint3D(); |
| 76 |
|
| 77 |
virtual PhysicsServer3D::JointType get_type() const { return PhysicsServer3D::JOINT_TYPE_MAX; } |
| 78 |
|
| 79 |
RID get_rid() const { return rid; } |
| 80 |
void set_rid(const RID &p_rid) { rid = p_rid; } |
| 81 |
|
| 82 |
JoltSpace3D *get_space() const; |
| 83 |
|
| 84 |
JPH::Constraint *get_jolt_ref() const { return jolt_ref; } |
| 85 |
|
| 86 |
bool is_enabled() const { return enabled; } |
| 87 |
void set_enabled(bool p_enabled); |
| 88 |
|
| 89 |
int get_solver_priority() const; |
| 90 |
void set_solver_priority(int p_priority); |
| 91 |
|
| 92 |
int get_solver_velocity_iterations() const { return velocity_iterations; } |
| 93 |
void set_solver_velocity_iterations(int p_iterations); |
| 94 |
|
| 95 |
int get_solver_position_iterations() const { return position_iterations; } |
| 96 |
void set_solver_position_iterations(int p_iterations); |
| 97 |
|
| 98 |
bool is_collision_disabled() const { return collision_disabled; } |
| 99 |
void set_collision_disabled(bool p_disabled); |
| 100 |
|
| 101 |
void destroy(); |
| 102 |
|
| 103 |
virtual void rebuild() {} |
| 104 |
}; |