Debian Codegraph @

modules/jolt_physics/joints/jolt_joint_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* jolt_joint_3d.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
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 };