Debian Codegraph @

editor/scene/3d/gizmos/physics/joint_3d_gizmo_plugin.h

raw symbols SCIP
1 /**************************************************************************/
2 /* joint_3d_gizmo_plugin.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 "editor/scene/3d/node_3d_editor_gizmos.h"
34
35 class Timer;
36
37 class Joint3DGizmoPlugin : public EditorNode3DGizmoPlugin {
38 GDCLASS(Joint3DGizmoPlugin, EditorNode3DGizmoPlugin);
39
40 Timer *update_timer = nullptr;
41 EditorNode3DGizmo *last_drawn = nullptr;
42
43 void incremental_update_gizmos();
44
45 public:
46 bool has_gizmo(Node3D *p_spatial) override;
47 String get_gizmo_name() const override;
48 int get_priority() const override;
49 void redraw(EditorNode3DGizmo *p_gizmo) override;
50
51 static void CreatePinJointGizmo(const Transform3D &p_offset, Vector<Vector3> &r_cursor_points);
52 static void CreateHingeJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_limit_lower, real_t p_limit_upper, bool p_use_limit, Vector<Vector3> &r_common_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
53 static void CreateSliderJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_angular_limit_lower, real_t p_angular_limit_upper, real_t p_linear_limit_lower, real_t p_linear_limit_upper, Vector<Vector3> &r_points, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
54 static void CreateConeTwistJointGizmo(const Transform3D &p_offset, const Transform3D &p_trs_joint, const Transform3D &p_trs_body_a, const Transform3D &p_trs_body_b, real_t p_swing, real_t p_twist, Vector<Vector3> *r_body_a_points, Vector<Vector3> *r_body_b_points);
55 static void CreateGeneric6DOFJointGizmo(
56 const Transform3D &p_offset,
57 const Transform3D &p_trs_joint,
58 const Transform3D &p_trs_body_a,
59 const Transform3D &p_trs_body_b,
60 real_t p_angular_limit_lower_x,
61 real_t p_angular_limit_upper_x,
62 real_t p_linear_limit_lower_x,
63 real_t p_linear_limit_upper_x,
64 bool p_enable_angular_limit_x,
65 bool p_enable_linear_limit_x,
66 real_t p_angular_limit_lower_y,
67 real_t p_angular_limit_upper_y,
68 real_t p_linear_limit_lower_y,
69 real_t p_linear_limit_upper_y,
70 bool p_enable_angular_limit_y,
71 bool p_enable_linear_limit_y,
72 real_t p_angular_limit_lower_z,
73 real_t p_angular_limit_upper_z,
74 real_t p_linear_limit_lower_z,
75 real_t p_linear_limit_upper_z,
76 bool p_enable_angular_limit_z,
77 bool p_enable_linear_limit_z,
78 Vector<Vector3> &r_points,
79 Vector<Vector3> *r_body_a_points,
80 Vector<Vector3> *r_body_b_points);
81
82 Joint3DGizmoPlugin();
83 };
84
85 class JointGizmosDrawer {
86 public:
87 static Basis look_body(const Transform3D &p_joint_transform, const Transform3D &p_body_transform);
88 static Basis look_body_toward(Vector3::Axis p_axis, const Transform3D &joint_transform, const Transform3D &body_transform);
89 static Basis look_body_toward_x(const Transform3D &p_joint_transform, const Transform3D &p_body_transform);
90 static Basis look_body_toward_y(const Transform3D &p_joint_transform, const Transform3D &p_body_transform);
91 /// Special function just used for physics joints, it returns a basis constrained toward Joint Z axis
92 /// with axis X and Y that are looking toward the body and oriented toward up
93 static Basis look_body_toward_z(const Transform3D &p_joint_transform, const Transform3D &p_body_transform);
94
95 // Draw circle around p_axis
96 static void draw_circle(Vector3::Axis p_axis, real_t p_radius, const Transform3D &p_offset, const Basis &p_base, real_t p_limit_lower, real_t p_limit_upper, Vector<Vector3> &r_points, bool p_inverse = false);
97 static void draw_cone(const Transform3D &p_offset, const Basis &p_base, real_t p_swing, real_t p_twist, Vector<Vector3> &r_points);
98 };