Debian Codegraph @

scene/3d/limit_angular_velocity_modifier_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* limit_angular_velocity_modifier_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 "scene/3d/skeleton_modifier_3d.h"
34
35 class LimitAngularVelocityModifier3D : public SkeletonModifier3D {
36 GDCLASS(LimitAngularVelocityModifier3D, SkeletonModifier3D);
37
38 public:
39 struct BoneJoint {
40 StringName name;
41 int bone = -1;
42 };
43
44 struct Chain {
45 BoneJoint root_bone;
46 BoneJoint end_bone;
47 };
48
49 typedef Pair<int, Quaternion> BoneRot;
50
51 private:
52 bool exclude = false;
53 double max_angular_velocity = Math::TAU;
54
55 LocalVector<Chain> chains;
56 LocalVector<BoneJoint> joints;
57 LocalVector<BoneRot> bones;
58
59 bool joints_dirty = false;
60 bool init_needed = true;
61
62 protected:
63 bool _get(const StringName &p_path, Variant &r_ret) const;
64 bool _set(const StringName &p_path, const Variant &p_value);
65 void _get_property_list(List<PropertyInfo> *p_list) const;
66 void _validate_property(PropertyInfo &p_property) const;
67
68 static void _bind_methods();
69
70 void _notification(int p_what);
71
72 virtual void _set_active(bool p_active) override;
73 virtual void _skeleton_changed(Skeleton3D *p_old, Skeleton3D *p_new) override;
74
75 virtual void _validate_bone_names() override;
76
77 void _make_joints_dirty();
78 void _update_joints();
79 bool _is_joint_contained(int p_bone);
80
81 // For editor.
82 int _get_joint_count() const;
83
84 virtual void _process_modification(double p_delta) override;
85
86 public:
87 void set_root_bone_name(int p_index, const String &p_bone_name);
88 String get_root_bone_name(int p_index) const;
89 void set_root_bone(int p_index, int p_bone);
90 int get_root_bone(int p_index) const;
91
92 void set_end_bone_name(int p_index, const String &p_bone_name);
93 String get_end_bone_name(int p_index) const;
94 void set_end_bone(int p_index, int p_bone);
95 int get_end_bone(int p_index) const;
96
97 String get_joint_bone_name(int p_index) const;
98 int get_joint_bone(int p_index) const;
99
100 void set_chain_count(int p_count);
101 int get_chain_count() const;
102 void clear_chains();
103
104 void set_max_angular_velocity(double p_angular_velocity);
105 double get_max_angular_velocity() const;
106
107 void set_exclude(bool p_exclude);
108 bool is_exclude() const;
109
110 void reset();
111
112 ~LimitAngularVelocityModifier3D();
113 };