29 #ifndef PHYSICS_BODY_2D_H 30 #define PHYSICS_BODY_2D_H 32 #include "scene/2d/collision_object_2d.h" 33 #include "servers/physics_2d_server.h" 42 uint32_t collision_mask;
43 Vector2 one_way_collision_direction;
44 float one_way_collision_max_depth;
47 void _set_layers(uint32_t p_mask);
48 uint32_t _get_layers()
const;
52 void _notification(
int p_what);
55 static void _bind_methods();
58 void set_layer_mask(uint32_t p_mask);
59 uint32_t get_layer_mask()
const;
61 void set_collision_mask(uint32_t p_mask);
62 uint32_t get_collision_mask()
const;
65 void set_collision_mask_bit(
int p_bit,
bool p_value);
66 bool get_collision_mask_bit(
int p_bit)
const;
68 void set_layer_mask_bit(
int p_bit,
bool p_value);
69 bool get_layer_mask_bit(
int p_bit)
const;
71 void add_collision_exception_with(
Node* p_node);
72 void remove_collision_exception_with(
Node* p_node);
74 void set_one_way_collision_direction(
const Vector2& p_dir);
75 Vector2 get_one_way_collision_direction()
const;
77 void set_one_way_collision_max_depth(
float p_dir);
78 float get_one_way_collision_max_depth()
const;
88 Vector2 constant_linear_velocity;
89 real_t constant_angular_velocity;
97 static void _bind_methods();
101 void set_friction(real_t p_friction);
102 real_t get_friction()
const;
104 void set_bounce(real_t p_bounce);
105 real_t get_bounce()
const;
108 void set_constant_linear_velocity(
const Vector2& p_vel);
109 void set_constant_angular_velocity(real_t p_vel);
111 Vector2 get_constant_linear_velocity()
const;
112 real_t get_constant_angular_velocity()
const;
140 Physics2DDirectBodyState *state;
146 real_t gravity_scale;
151 real_t angular_velocity;
155 int max_contacts_reported;
157 bool custom_integrator;
167 bool operator<(
const ShapePair& p_sp)
const {
168 if (body_shape==p_sp.body_shape)
169 return local_shape < p_sp.local_shape;
171 return body_shape < p_sp.body_shape;
175 ShapePair(
int p_bs,
int p_ls) { body_shape=p_bs; local_shape=p_ls; }
177 struct RigidBody2D_RemoveAction {
191 struct ContactMonitor {
199 ContactMonitor *contact_monitor;
200 void _body_enter_tree(ObjectID p_id);
201 void _body_exit_tree(ObjectID p_id);
204 void _body_inout(
int p_status, ObjectID p_instance,
int p_body_shape,
int p_local_shape);
205 void _direct_state_changed(
Object *p_state);
211 static void _bind_methods();
214 void set_mode(Mode p_mode);
215 Mode get_mode()
const;
217 void set_mass(real_t p_mass);
218 real_t get_mass()
const;
220 void set_weight(real_t p_weight);
221 real_t get_weight()
const;
223 void set_friction(real_t p_friction);
224 real_t get_friction()
const;
226 void set_bounce(real_t p_bounce);
227 real_t get_bounce()
const;
229 void set_gravity_scale(real_t p_gravity_scale);
230 real_t get_gravity_scale()
const;
232 void set_linear_damp(real_t p_linear_damp);
233 real_t get_linear_damp()
const;
235 void set_angular_damp(real_t p_angular_damp);
236 real_t get_angular_damp()
const;
238 void set_linear_velocity(
const Vector2& p_velocity);
239 Vector2 get_linear_velocity()
const;
241 void set_axis_velocity(
const Vector2& p_axis);
243 void set_angular_velocity(real_t p_velocity);
244 real_t get_angular_velocity()
const;
246 void set_use_custom_integrator(
bool p_enable);
247 bool is_using_custom_integrator();
249 void set_sleeping(
bool p_sleeping);
250 bool is_sleeping()
const;
252 void set_can_sleep(
bool p_active);
253 bool is_able_to_sleep()
const;
255 void set_contact_monitor(
bool p_enabled);
256 bool is_contact_monitor_enabled()
const;
258 void set_max_contacts_reported(
int p_amount);
259 int get_max_contacts_reported()
const;
261 void set_continuous_collision_detection_mode(CCDMode p_mode);
262 CCDMode get_continuous_collision_detection_mode()
const;
264 void apply_impulse(
const Vector2& p_pos,
const Vector2& p_impulse);
266 void set_applied_force(
const Vector2& p_force);
267 Vector2 get_applied_force()
const;
271 Array get_colliding_bodies()
const;
278 VARIANT_ENUM_CAST(RigidBody2D::Mode);
279 VARIANT_ENUM_CAST(RigidBody2D::CCDMode);
299 _FORCE_INLINE_
bool _ignores_mode(Physics2DServer::BodyMode)
const;
302 static void _bind_methods();
308 bool test_move(
const Vector2& p_motion);
309 bool is_colliding()
const;
312 void revert_motion();
314 Vector2 get_collision_pos()
const;
315 Vector2 get_collision_normal()
const;
316 Vector2 get_collider_velocity()
const;
317 ObjectID get_collider()
const;
318 int get_collider_shape()
const;
319 Variant get_collider_metadata()
const;
321 void set_collision_margin(
float p_margin);
322 float get_collision_margin()
const;
330 #endif // PHYSICS_BODY_2D_H Definition: physics_body_2d.h:119
Definition: tween_interpolaters.cpp:313
Definition: reference.h:78
Definition: physics_body_2d.h:37
Definition: physics_body_2d.h:283
Definition: physics_body_2d.h:84
Definition: collision_object_2d.h:35