Skip to content
0.2.0-dev Download ZIP
97 lines ·3.8 KB Raw
1/**************************************************************************/
2/* bone_attachment_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_3d.h"
34
35class BoneAttachment3D : public Node3D {
36 GDCLASS(BoneAttachment3D, Node3D);
37
38 bool bound = false;
39 String bone_name;
40 int bone_idx = -1;
41
42 bool override_pose = false;
43 bool _override_dirty = false;
44 bool overriding = false;
45
46 bool use_external_skeleton = false;
47 NodePath external_skeleton_node;
48 ObjectID external_skeleton_node_cache;
49
50 void _check_bind();
51 void _check_unbind();
52
53 bool updating = false;
54 void _transform_changed();
55 void _update_external_skeleton_cache();
56
57protected:
58 void _validate_property(PropertyInfo &p_property) const;
59 void _notification(int p_what);
60
61 static void _bind_methods();
62#ifndef DISABLE_DEPRECATED
63 virtual void _on_bone_pose_update_bind_compat_90575(int p_bone_index);
64 static void _bind_compatibility_methods();
65#endif
66
67public:
68#ifdef TOOLS_ENABLED
69 virtual void notify_skeleton_bones_renamed(Node *p_base_scene, Skeleton3D *p_skeleton, Dictionary p_rename_map);
70#endif // TOOLS_ENABLED
71
72 virtual PackedStringArray get_configuration_warnings() const override;
73
74 Skeleton3D *get_skeleton();
75
76 void set_bone_name(const String &p_name);
77 String get_bone_name() const;
78
79 void set_bone_idx(const int &p_idx);
80 int get_bone_idx() const;
81
82 void set_override_pose(bool p_override_pose);
83 bool get_override_pose() const;
84
85 void set_use_external_skeleton(bool p_use_external_skeleton);
86 bool get_use_external_skeleton() const;
87 void set_external_skeleton(NodePath p_external_skeleton);
88 NodePath get_external_skeleton() const;
89
90 virtual void on_skeleton_update();
91
92#ifdef TOOLS_ENABLED
93 virtual void notify_rebind_required();
94#endif
95
96 BoneAttachment3D();
97};