Debian Codegraph @

scene/3d/retarget_modifier_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* retarget_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 #include "scene/resources/skeleton_profile.h"
35
36 class RetargetModifier3D : public SkeletonModifier3D {
37 GDCLASS(RetargetModifier3D, SkeletonModifier3D);
38
39 public:
40 enum TransformFlag {
41 TRANSFORM_FLAG_POSITION = 1,
42 TRANSFORM_FLAG_ROTATION = 2,
43 TRANSFORM_FLAG_SCALE = 4,
44 TRANSFORM_FLAG_ALL = TRANSFORM_FLAG_POSITION | TRANSFORM_FLAG_ROTATION | TRANSFORM_FLAG_SCALE,
45 };
46
47 private:
48 Ref<SkeletonProfile> profile;
49
50 bool use_global_pose = false;
51 BitField<TransformFlag> enable_flags = TRANSFORM_FLAG_ALL;
52
53 struct RetargetBoneInfo {
54 int bone_id = -1;
55 Basis pre_basis;
56 Basis post_basis;
57 };
58
59 struct RetargetInfo {
60 ObjectID skeleton_id;
61 Vector<RetargetBoneInfo> humanoid_bone_rests;
62 };
63
64 Vector<RetargetInfo> child_skeletons;
65 Vector<int> source_bone_ids;
66
67 void _update_child_skeleton_rests(int p_child_skeleton_idx);
68 void _update_child_skeletons();
69 void _reset_child_skeleton_poses();
70 void _reset_child_skeletons();
71
72 #ifdef TOOLS_ENABLED
73 void _force_update_child_skeletons();
74 #endif // TOOLS_ENABLED
75
76 void cache_rests_with_reset();
77 void cache_rests();
78 Vector<RetargetBoneInfo> cache_bone_global_rests(Skeleton3D *p_skeleton);
79 Vector<RetargetBoneInfo> cache_bone_rests(Skeleton3D *p_skeleton);
80 Vector<RetargetBoneInfo> get_humanoid_bone_rests(Skeleton3D *p_skeleton);
81
82 void _retarget_global_pose();
83 void _retarget_pose();
84
85 protected:
86 virtual void _skeleton_changed(Skeleton3D *p_old, Skeleton3D *p_new) override;
87 void _profile_changed(Ref<SkeletonProfile> p_old, Ref<SkeletonProfile> p_new);
88
89 void _validate_property(PropertyInfo &p_property) const;
90
91 static void _bind_methods();
92 virtual void _notification(int p_what);
93
94 virtual void add_child_notify(Node *p_child) override;
95 virtual void move_child_notify(Node *p_child) override;
96 virtual void remove_child_notify(Node *p_child) override;
97
98 virtual void _set_active(bool p_active) override;
99 virtual void _process_modification(double p_delta) override;
100
101 public:
102 virtual PackedStringArray get_configuration_warnings() const override;
103
104 void set_use_global_pose(bool p_use_global_pose);
105 bool is_using_global_pose() const;
106 void set_enable_flags(BitField<TransformFlag> p_enable_flags);
107 BitField<TransformFlag> get_enable_flags() const;
108
109 void set_position_enabled(bool p_enabled);
110 bool is_position_enabled() const;
111 void set_rotation_enabled(bool p_enabled);
112 bool is_rotation_enabled() const;
113 void set_scale_enabled(bool p_enabled);
114 bool is_scale_enabled() const;
115
116 void set_profile(Ref<SkeletonProfile> p_profile);
117 Ref<SkeletonProfile> get_profile() const;
118
119 #ifdef TOOLS_ENABLED
120 virtual bool is_processed_on_saving() const override { return true; }
121 #endif
122
123 RetargetModifier3D();
124 virtual ~RetargetModifier3D();
125 };
126
127 VARIANT_BITFIELD_CAST(RetargetModifier3D::TransformFlag);