|
@@ -47,6 +47,8 @@ void PhysicsBody2D::_bind_methods() {
|
|
|
|
|
|
ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody2D::set_layer_mask);
|
|
ObjectTypeDB::bind_method(_MD("set_layer_mask","mask"),&PhysicsBody2D::set_layer_mask);
|
|
ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask);
|
|
ObjectTypeDB::bind_method(_MD("get_layer_mask"),&PhysicsBody2D::get_layer_mask);
|
|
|
|
+ ObjectTypeDB::bind_method(_MD("add_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::add_collision_exception_with);
|
|
|
|
+ ObjectTypeDB::bind_method(_MD("remove_collision_exception_with","body:PhysicsBody2D"),&PhysicsBody2D::remove_collision_exception_with);
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
|
|
ADD_PROPERTY(PropertyInfo(Variant::INT,"layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -67,6 +69,29 @@ PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : CollisionObject
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void PhysicsBody2D::add_collision_exception_with(Node* p_node) {
|
|
|
|
+
|
|
|
|
+ ERR_FAIL_NULL(p_node);
|
|
|
|
+ PhysicsBody2D *physics_body = p_node->cast_to<PhysicsBody2D>();
|
|
|
|
+ if (!physics_body) {
|
|
|
|
+ ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
|
|
|
|
+ }
|
|
|
|
+ ERR_FAIL_COND(!physics_body);
|
|
|
|
+ Physics2DServer::get_singleton()->body_add_collision_exception(get_rid(),physics_body->get_rid());
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void PhysicsBody2D::remove_collision_exception_with(Node* p_node) {
|
|
|
|
+
|
|
|
|
+ ERR_FAIL_NULL(p_node);
|
|
|
|
+ PhysicsBody2D *physics_body = p_node->cast_to<PhysicsBody2D>();
|
|
|
|
+ if (!physics_body) {
|
|
|
|
+ ERR_EXPLAIN("Collision exception only works between two objects of PhysicsBody type");
|
|
|
|
+ }
|
|
|
|
+ ERR_FAIL_COND(!physics_body);
|
|
|
|
+ Physics2DServer::get_singleton()->body_remove_collision_exception(get_rid(),physics_body->get_rid());
|
|
|
|
+}
|
|
|
|
+
|
|
void StaticBody2D::set_constant_linear_velocity(const Vector2& p_vel) {
|
|
void StaticBody2D::set_constant_linear_velocity(const Vector2& p_vel) {
|
|
|
|
|
|
constant_linear_velocity=p_vel;
|
|
constant_linear_velocity=p_vel;
|
|
@@ -375,7 +400,7 @@ void RigidBody2D::_direct_state_changed(Object *p_state) {
|
|
set_global_transform(state->get_transform());
|
|
set_global_transform(state->get_transform());
|
|
linear_velocity=state->get_linear_velocity();
|
|
linear_velocity=state->get_linear_velocity();
|
|
angular_velocity=state->get_angular_velocity();
|
|
angular_velocity=state->get_angular_velocity();
|
|
- active=!state->is_sleeping();
|
|
|
|
|
|
+ sleeping=state->is_sleeping();
|
|
if (get_script_instance())
|
|
if (get_script_instance())
|
|
get_script_instance()->call("_integrate_forces",state);
|
|
get_script_instance()->call("_integrate_forces",state);
|
|
set_block_transform_notify(false); // want it back
|
|
set_block_transform_notify(false); // want it back
|
|
@@ -525,10 +550,10 @@ bool RigidBody2D::is_using_custom_integrator(){
|
|
return custom_integrator;
|
|
return custom_integrator;
|
|
}
|
|
}
|
|
|
|
|
|
-void RigidBody2D::set_active(bool p_active) {
|
|
|
|
|
|
+void RigidBody2D::set_sleeping(bool p_sleeping) {
|
|
|
|
|
|
- active=p_active;
|
|
|
|
- Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_SLEEPING,!active);
|
|
|
|
|
|
+ sleeping=p_sleeping;
|
|
|
|
+ Physics2DServer::get_singleton()->body_set_state(get_rid(),Physics2DServer::BODY_STATE_SLEEPING,sleeping);
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -543,9 +568,9 @@ bool RigidBody2D::is_able_to_sleep() const {
|
|
return can_sleep;
|
|
return can_sleep;
|
|
}
|
|
}
|
|
|
|
|
|
-bool RigidBody2D::is_active() const {
|
|
|
|
|
|
+bool RigidBody2D::is_sleeping() const {
|
|
|
|
|
|
- return active;
|
|
|
|
|
|
+ return sleeping;
|
|
}
|
|
}
|
|
|
|
|
|
void RigidBody2D::set_max_contacts_reported(int p_amount) {
|
|
void RigidBody2D::set_max_contacts_reported(int p_amount) {
|
|
@@ -657,8 +682,8 @@ void RigidBody2D::_bind_methods() {
|
|
ObjectTypeDB::bind_method(_MD("set_applied_force","force"),&RigidBody2D::set_applied_force);
|
|
ObjectTypeDB::bind_method(_MD("set_applied_force","force"),&RigidBody2D::set_applied_force);
|
|
ObjectTypeDB::bind_method(_MD("get_applied_force"),&RigidBody2D::get_applied_force);
|
|
ObjectTypeDB::bind_method(_MD("get_applied_force"),&RigidBody2D::get_applied_force);
|
|
|
|
|
|
- ObjectTypeDB::bind_method(_MD("set_active","active"),&RigidBody2D::set_active);
|
|
|
|
- ObjectTypeDB::bind_method(_MD("is_active"),&RigidBody2D::is_active);
|
|
|
|
|
|
+ ObjectTypeDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody2D::set_sleeping);
|
|
|
|
+ ObjectTypeDB::bind_method(_MD("is_sleeping"),&RigidBody2D::is_sleeping);
|
|
|
|
|
|
ObjectTypeDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody2D::set_can_sleep);
|
|
ObjectTypeDB::bind_method(_MD("set_can_sleep","able_to_sleep"),&RigidBody2D::set_can_sleep);
|
|
ObjectTypeDB::bind_method(_MD("is_able_to_sleep"),&RigidBody2D::is_able_to_sleep);
|
|
ObjectTypeDB::bind_method(_MD("is_able_to_sleep"),&RigidBody2D::is_able_to_sleep);
|
|
@@ -678,7 +703,7 @@ void RigidBody2D::_bind_methods() {
|
|
ADD_PROPERTY( PropertyInfo(Variant::INT,"continuous_cd",PROPERTY_HINT_ENUM,"Disabled,Cast Ray,Cast Shape"),_SCS("set_continuous_collision_detection_mode"),_SCS("get_continuous_collision_detection_mode"));
|
|
ADD_PROPERTY( PropertyInfo(Variant::INT,"continuous_cd",PROPERTY_HINT_ENUM,"Disabled,Cast Ray,Cast Shape"),_SCS("set_continuous_collision_detection_mode"),_SCS("get_continuous_collision_detection_mode"));
|
|
ADD_PROPERTY( PropertyInfo(Variant::INT,"contacts_reported"),_SCS("set_max_contacts_reported"),_SCS("get_max_contacts_reported"));
|
|
ADD_PROPERTY( PropertyInfo(Variant::INT,"contacts_reported"),_SCS("set_max_contacts_reported"),_SCS("get_max_contacts_reported"));
|
|
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"contact_monitor"),_SCS("set_contact_monitor"),_SCS("is_contact_monitor_enabled"));
|
|
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"contact_monitor"),_SCS("set_contact_monitor"),_SCS("is_contact_monitor_enabled"));
|
|
- ADD_PROPERTY( PropertyInfo(Variant::BOOL,"active"),_SCS("set_active"),_SCS("is_active"));
|
|
|
|
|
|
+ ADD_PROPERTY( PropertyInfo(Variant::BOOL,"sleeping"),_SCS("set_sleeping"),_SCS("is_sleeping"));
|
|
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"can_sleep"),_SCS("set_can_sleep"),_SCS("is_able_to_sleep"));
|
|
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"can_sleep"),_SCS("set_can_sleep"),_SCS("is_able_to_sleep"));
|
|
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"velocity/linear"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity"));
|
|
ADD_PROPERTY( PropertyInfo(Variant::VECTOR2,"velocity/linear"),_SCS("set_linear_velocity"),_SCS("get_linear_velocity"));
|
|
ADD_PROPERTY( PropertyInfo(Variant::REAL,"velocity/angular"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity"));
|
|
ADD_PROPERTY( PropertyInfo(Variant::REAL,"velocity/angular"),_SCS("set_angular_velocity"),_SCS("get_angular_velocity"));
|
|
@@ -710,7 +735,7 @@ RigidBody2D::RigidBody2D() : PhysicsBody2D(Physics2DServer::BODY_MODE_RIGID) {
|
|
state=NULL;
|
|
state=NULL;
|
|
|
|
|
|
angular_velocity=0;
|
|
angular_velocity=0;
|
|
- active=true;
|
|
|
|
|
|
+ sleeping=false;
|
|
ccd_mode=CCD_MODE_DISABLED;
|
|
ccd_mode=CCD_MODE_DISABLED;
|
|
|
|
|
|
custom_integrator=false;
|
|
custom_integrator=false;
|