Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/scene/3d/copy_transform_modifier_3d.h
9902 views
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
bool relative = true;
58
bool additive = false;
59
};
60
61
protected:
62
bool _get(const StringName &p_path, Variant &r_ret) const;
63
bool _set(const StringName &p_path, const Variant &p_value);
64
void _get_property_list(List<PropertyInfo> *p_list) const;
65
66
static void _bind_methods();
67
68
virtual void _process_constraint(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, int p_reference_bone, float p_amount) override;
69
virtual void _validate_setting(int p_index) override;
70
71
public:
72
void set_copy_flags(int p_index, BitField<TransformFlag> p_copy_flags);
73
BitField<TransformFlag> get_copy_flags(int p_index) const;
74
75
void set_copy_position(int p_index, bool p_enabled);
76
bool is_position_copying(int p_index) const;
77
void set_copy_rotation(int p_index, bool p_enabled);
78
bool is_rotation_copying(int p_index) const;
79
void set_copy_scale(int p_index, bool p_enabled);
80
bool is_scale_copying(int p_index) const;
81
82
void set_axis_flags(int p_index, BitField<AxisFlag> p_axis_flags);
83
BitField<AxisFlag> get_axis_flags(int p_index) const;
84
85
void set_axis_x_enabled(int p_index, bool p_enabled);
86
bool is_axis_x_enabled(int p_index) const;
87
void set_axis_y_enabled(int p_index, bool p_enabled);
88
bool is_axis_y_enabled(int p_index) const;
89
void set_axis_z_enabled(int p_index, bool p_enabled);
90
bool is_axis_z_enabled(int p_index) const;
91
92
void set_invert_flags(int p_index, BitField<AxisFlag> p_axis_flags);
93
BitField<AxisFlag> get_invert_flags(int p_index) const;
94
95
void set_axis_x_inverted(int p_index, bool p_enabled);
96
bool is_axis_x_inverted(int p_index) const;
97
void set_axis_y_inverted(int p_index, bool p_enabled);
98
bool is_axis_y_inverted(int p_index) const;
99
void set_axis_z_inverted(int p_index, bool p_enabled);
100
bool is_axis_z_inverted(int p_index) const;
101
102
void set_relative(int p_index, bool p_enabled);
103
bool is_relative(int p_index) const;
104
105
void set_additive(int p_index, bool p_enabled);
106
bool is_additive(int p_index) const;
107
108
~CopyTransformModifier3D();
109
};
110
111
VARIANT_BITFIELD_CAST(CopyTransformModifier3D::TransformFlag);
112
VARIANT_BITFIELD_CAST(CopyTransformModifier3D::AxisFlag);
113
114