Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/scene/3d/bone_constraint_3d.h
9896 views
1
/**************************************************************************/
2
/* bone_constraint_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 BoneConstraint3D : public SkeletonModifier3D {
36
GDCLASS(BoneConstraint3D, SkeletonModifier3D);
37
38
public:
39
struct BoneConstraint3DSetting {
40
float amount = 1.0;
41
42
String apply_bone_name;
43
int apply_bone = -1;
44
45
String reference_bone_name;
46
int reference_bone = -1;
47
};
48
49
protected:
50
Vector<BoneConstraint3DSetting *> settings;
51
52
bool _get(const StringName &p_path, Variant &r_ret) const;
53
bool _set(const StringName &p_path, const Variant &p_value);
54
55
// Define get_property_list() instead of _get_property_list()
56
// to merge child class properties into parent class array inspector.
57
void get_property_list(List<PropertyInfo> *p_list) const; // Will be called by child classes.
58
59
virtual void _validate_bone_names() override;
60
static void _bind_methods();
61
62
virtual void _process_modification(double p_delta) override;
63
64
virtual void _process_constraint(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, int p_reference_bone, float p_amount);
65
virtual void _validate_setting(int p_index);
66
67
public:
68
void set_amount(int p_index, float p_amount);
69
float get_amount(int p_index) const;
70
71
void set_apply_bone_name(int p_index, const String &p_bone_name);
72
String get_apply_bone_name(int p_index) const;
73
void set_apply_bone(int p_index, int p_bone);
74
int get_apply_bone(int p_index) const;
75
76
void set_reference_bone_name(int p_index, const String &p_bone_name);
77
String get_reference_bone_name(int p_index) const;
78
void set_reference_bone(int p_index, int p_bone);
79
int get_reference_bone(int p_index) const;
80
81
void set_setting_count(int p_count);
82
int get_setting_count() const;
83
84
void clear_settings();
85
86
static double symmetrize_angle(double p_angle); // Helper to make angle 0->TAU become -PI->PI.
87
static double get_roll_angle(const Quaternion &p_rotation, const Vector3 &p_roll_axis);
88
89
~BoneConstraint3D();
90
};
91
92