Debian Codegraph @

scene/3d/copy_transform_modifier_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* copy_transform_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/bone_constraint_3d.h"
34
35 class CopyTransformModifier3D : public BoneConstraint3D {
36 GDCLASS(CopyTransformModifier3D, BoneConstraint3D);
37
38 public:
39 enum TransformFlag {
40 TRANSFORM_FLAG_POSITION = 1,
41 TRANSFORM_FLAG_ROTATION = 2,
42 TRANSFORM_FLAG_SCALE = 4,
43 TRANSFORM_FLAG_ALL = TRANSFORM_FLAG_POSITION | TRANSFORM_FLAG_ROTATION | TRANSFORM_FLAG_SCALE,
44 };
45
46 enum AxisFlag {
47 AXIS_FLAG_X = 1,
48 AXIS_FLAG_Y = 2,
49 AXIS_FLAG_Z = 4,
50 AXIS_FLAG_ALL = AXIS_FLAG_X | AXIS_FLAG_Y | AXIS_FLAG_Z,
51 };
52
53 struct CopyTransform3DSetting : public BoneConstraint3DSetting {
54 BitField<TransformFlag> copy_flags = TRANSFORM_FLAG_ALL;
55 BitField<AxisFlag> axis_flags = AXIS_FLAG_ALL;
56 BitField<AxisFlag> invert_flags = 0;
57
58 bool relative = true;
59 bool additive = false;
60
61 bool is_relative() {
62 if (reference_type == REFERENCE_TYPE_NODE) {
63 return false;
64 }
65 return relative;
66 }
67 };
68
69 protected:
70 bool _get(const StringName &p_path, Variant &r_ret) const;
71 bool _set(const StringName &p_path, const Variant &p_value);
72 void _get_property_list(List<PropertyInfo> *p_list) const;
73 void _validate_dynamic_prop(PropertyInfo &p_property) const;
74
75 static void _bind_methods();
76
77 virtual void _process_constraint_by_bone(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, int p_reference_bone, float p_amount) override;
78 virtual void _process_constraint_by_node(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, const NodePath &p_reference_node, float p_amount) override;
79 virtual void _process_copy(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, const Transform3D &p_destination, float p_amount);
80 virtual void _validate_setting(int p_index) override;
81
82 public:
83 void set_copy_flags(int p_index, BitField<TransformFlag> p_copy_flags);
84 BitField<TransformFlag> get_copy_flags(int p_index) const;
85
86 void set_copy_position(int p_index, bool p_enabled);
87 bool is_position_copying(int p_index) const;
88 void set_copy_rotation(int p_index, bool p_enabled);
89 bool is_rotation_copying(int p_index) const;
90 void set_copy_scale(int p_index, bool p_enabled);
91 bool is_scale_copying(int p_index) const;
92
93 void set_axis_flags(int p_index, BitField<AxisFlag> p_axis_flags);
94 BitField<AxisFlag> get_axis_flags(int p_index) const;
95
96 void set_axis_x_enabled(int p_index, bool p_enabled);
97 bool is_axis_x_enabled(int p_index) const;
98 void set_axis_y_enabled(int p_index, bool p_enabled);
99 bool is_axis_y_enabled(int p_index) const;
100 void set_axis_z_enabled(int p_index, bool p_enabled);
101 bool is_axis_z_enabled(int p_index) const;
102
103 void set_invert_flags(int p_index, BitField<AxisFlag> p_axis_flags);
104 BitField<AxisFlag> get_invert_flags(int p_index) const;
105
106 void set_axis_x_inverted(int p_index, bool p_enabled);
107 bool is_axis_x_inverted(int p_index) const;
108 void set_axis_y_inverted(int p_index, bool p_enabled);
109 bool is_axis_y_inverted(int p_index) const;
110 void set_axis_z_inverted(int p_index, bool p_enabled);
111 bool is_axis_z_inverted(int p_index) const;
112
113 void set_relative(int p_index, bool p_enabled);
114 bool is_relative(int p_index) const;
115
116 void set_additive(int p_index, bool p_enabled);
117 bool is_additive(int p_index) const;
118
119 ~CopyTransformModifier3D();
120 };
121
122 VARIANT_BITFIELD_CAST(CopyTransformModifier3D::TransformFlag);
123 VARIANT_BITFIELD_CAST(CopyTransformModifier3D::AxisFlag);