Debian Codegraph @

scene/3d/physics/area_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* area_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 "core/templates/vset.h"
34 #include "scene/3d/physics/collision_object_3d.h"
35
36 class Area3D : public CollisionObject3D {
37 GDCLASS(Area3D, CollisionObject3D);
38
39 public:
40 enum SpaceOverride {
41 SPACE_OVERRIDE_DISABLED,
42 SPACE_OVERRIDE_COMBINE,
43 SPACE_OVERRIDE_COMBINE_REPLACE,
44 SPACE_OVERRIDE_REPLACE,
45 SPACE_OVERRIDE_REPLACE_COMBINE
46 };
47
48 private:
49 SpaceOverride gravity_space_override = SPACE_OVERRIDE_DISABLED;
50 Vector3 gravity_vec;
51 real_t gravity = 0.0;
52 bool gravity_is_point = false;
53 real_t gravity_point_unit_distance = 0.0;
54
55 SpaceOverride linear_damp_space_override = SPACE_OVERRIDE_DISABLED;
56 SpaceOverride angular_damp_space_override = SPACE_OVERRIDE_DISABLED;
57 real_t angular_damp = 0.1;
58 real_t linear_damp = 0.1;
59
60 int priority = 0;
61
62 real_t wind_force_magnitude = 0.0;
63 real_t wind_attenuation_factor = 0.0;
64 NodePath wind_source_path;
65
66 bool monitoring = false;
67 bool monitorable = false;
68 bool locked = false;
69
70 void _body_inout(int p_status, const RID &p_body, ObjectID p_instance, int p_body_shape, int p_area_shape);
71
72 void _body_enter_tree(ObjectID p_id);
73 void _body_exit_tree(ObjectID p_id);
74
75 struct ShapePair {
76 int body_shape = 0;
77 int area_shape = 0;
78 bool operator<(const ShapePair &p_sp) const {
79 if (body_shape == p_sp.body_shape) {
80 return area_shape < p_sp.area_shape;
81 } else {
82 return body_shape < p_sp.body_shape;
83 }
84 }
85
86 ShapePair() {}
87 ShapePair(int p_bs, int p_as) {
88 body_shape = p_bs;
89 area_shape = p_as;
90 }
91 };
92
93 struct BodyState {
94 RID rid;
95 int rc = 0;
96 bool in_tree = false;
97 VSet<ShapePair> shapes;
98 };
99
100 HashMap<ObjectID, BodyState> body_map;
101
102 void _area_inout(int p_status, const RID &p_area, ObjectID p_instance, int p_area_shape, int p_self_shape);
103
104 void _area_enter_tree(ObjectID p_id);
105 void _area_exit_tree(ObjectID p_id);
106
107 struct AreaShapePair {
108 int area_shape = 0;
109 int self_shape = 0;
110 bool operator<(const AreaShapePair &p_sp) const {
111 if (area_shape == p_sp.area_shape) {
112 return self_shape < p_sp.self_shape;
113 } else {
114 return area_shape < p_sp.area_shape;
115 }
116 }
117
118 AreaShapePair() {}
119 AreaShapePair(int p_bs, int p_as) {
120 area_shape = p_bs;
121 self_shape = p_as;
122 }
123 };
124
125 struct AreaState {
126 RID rid;
127 int rc = 0;
128 bool in_tree = false;
129 VSet<AreaShapePair> shapes;
130 };
131
132 HashMap<ObjectID, AreaState> area_map;
133 void _clear_monitoring();
134
135 bool audio_bus_override = false;
136 StringName audio_bus;
137
138 bool use_reverb_bus = false;
139 StringName reverb_bus;
140 float reverb_amount = 0.0;
141 float reverb_uniformity = 0.0;
142
143 void _initialize_wind();
144
145 protected:
146 void _notification(int p_what);
147 static void _bind_methods();
148 void _validate_property(PropertyInfo &p_property) const;
149
150 virtual void _space_changed(const RID &p_new_space) override;
151
152 public:
153 void set_gravity_space_override_mode(SpaceOverride p_mode);
154 SpaceOverride get_gravity_space_override_mode() const;
155
156 void set_gravity_is_point(bool p_enabled);
157 bool is_gravity_a_point() const;
158
159 void set_gravity_point_unit_distance(real_t p_scale);
160 real_t get_gravity_point_unit_distance() const;
161
162 void set_gravity_point_center(const Vector3 &p_center);
163 const Vector3 &get_gravity_point_center() const;
164
165 void set_gravity_direction(const Vector3 &p_direction);
166 const Vector3 &get_gravity_direction() const;
167
168 void set_gravity(real_t p_gravity);
169 real_t get_gravity() const;
170
171 void set_linear_damp_space_override_mode(SpaceOverride p_mode);
172 SpaceOverride get_linear_damp_space_override_mode() const;
173
174 void set_angular_damp_space_override_mode(SpaceOverride p_mode);
175 SpaceOverride get_angular_damp_space_override_mode() const;
176
177 void set_angular_damp(real_t p_angular_damp);
178 real_t get_angular_damp() const;
179
180 void set_linear_damp(real_t p_linear_damp);
181 real_t get_linear_damp() const;
182
183 void set_priority(int p_priority);
184 int get_priority() const;
185
186 void set_wind_force_magnitude(real_t p_wind_force_magnitude);
187 real_t get_wind_force_magnitude() const;
188
189 void set_wind_attenuation_factor(real_t p_wind_attenuation_factor);
190 real_t get_wind_attenuation_factor() const;
191
192 void set_wind_source_path(const NodePath &p_wind_source_path);
193 const NodePath &get_wind_source_path() const;
194
195 void set_monitoring(bool p_enable);
196 bool is_monitoring() const;
197
198 void set_monitorable(bool p_enable);
199 bool is_monitorable() const;
200
201 TypedArray<Node3D> get_overlapping_bodies() const;
202 TypedArray<Area3D> get_overlapping_areas() const; //function for script
203
204 bool has_overlapping_bodies() const;
205 bool has_overlapping_areas() const;
206
207 bool overlaps_area(RequiredParam<Node> rp_area) const;
208 bool overlaps_body(RequiredParam<Node> rp_body) const;
209
210 void set_audio_bus_override(bool p_override);
211 bool is_overriding_audio_bus() const;
212
213 void set_audio_bus_name(const StringName &p_audio_bus);
214 StringName get_audio_bus_name() const;
215
216 void set_use_reverb_bus(bool p_enable);
217 bool is_using_reverb_bus() const;
218
219 void set_reverb_bus_name(const StringName &p_audio_bus);
220 StringName get_reverb_bus_name() const;
221
222 void set_reverb_amount(float p_amount);
223 float get_reverb_amount() const;
224
225 void set_reverb_uniformity(float p_uniformity);
226 float get_reverb_uniformity() const;
227
228 Area3D();
229 ~Area3D();
230 };
231
232 VARIANT_ENUM_CAST(Area3D::SpaceOverride);