Debian Codegraph @

scene/3d/physics/physical_bone_simulator_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* physical_bone_simulator_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 PhysicalBone3D;
36
37 class PhysicalBoneSimulator3D : public SkeletonModifier3D {
38 GDCLASS(PhysicalBoneSimulator3D, SkeletonModifier3D);
39
40 bool simulating = false;
41
42 struct SimulatedBone {
43 int parent;
44 Vector<int> child_bones;
45
46 Transform3D global_pose;
47
48 PhysicalBone3D *physical_bone = nullptr;
49 PhysicalBone3D *cache_parent_physical_bone = nullptr;
50
51 SimulatedBone() {
52 parent = -1;
53 global_pose = Transform3D();
54 physical_bone = nullptr;
55 cache_parent_physical_bone = nullptr;
56 }
57 };
58
59 LocalVector<SimulatedBone> bones;
60
61 /// This is a slow API, so it's cached
62 PhysicalBone3D *_get_physical_bone_parent(int p_bone);
63 void _rebuild_physical_bones_cache();
64 void _reset_physical_bones_state();
65
66 protected:
67 static void _bind_methods();
68
69 virtual void _set_active(bool p_active) override;
70
71 void _bone_list_changed();
72 void _pose_updated();
73 void _bone_pose_updated(Skeleton3D *skeleton, int p_bone_id);
74
75 virtual void _process_modification(double p_delta) override;
76
77 virtual void _skeleton_changed(Skeleton3D *p_old, Skeleton3D *p_new) override;
78
79 public:
80 #ifndef DISABLE_DEPRECATED
81 bool is_compat = false;
82 #endif // _DISABLE_DEPRECATED
83 bool is_simulating_physics() const;
84
85 int find_bone(const String &p_name) const;
86 String get_bone_name(int p_bone) const;
87 int get_bone_count() const;
88 bool is_bone_parent_of(int p_bone_id, int p_parent_bone_id) const;
89
90 Transform3D get_bone_global_pose(int p_bone) const;
91 void set_bone_global_pose(int p_bone, const Transform3D &p_pose);
92
93 void bind_physical_bone_to_bone(int p_bone, PhysicalBone3D *p_physical_bone);
94 void unbind_physical_bone_from_bone(int p_bone);
95
96 PhysicalBone3D *get_physical_bone(int p_bone);
97 PhysicalBone3D *get_physical_bone_parent(int p_bone);
98
99 void physical_bones_stop_simulation();
100 void physical_bones_start_simulation_on(const TypedArray<StringName> &p_bones);
101 void physical_bones_add_collision_exception(RID p_exception);
102 void physical_bones_remove_collision_exception(RID p_exception);
103
104 PhysicalBoneSimulator3D();
105 };