mirror of
https://github.com/godotengine/godot.git
synced 2024-11-27 09:16:35 +08:00
-new collision layer & mask system for 2D, for more flexible collision masking
This commit is contained in:
parent
5f2aac4bbe
commit
af06843982
@ -19442,7 +19442,7 @@
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="body_set_user_mask" >
|
||||
<method name="body_set_collision_mask" >
|
||||
<argument index="0" name="body" type="RID">
|
||||
</argument>
|
||||
<argument index="1" name="mask" type="int">
|
||||
@ -19450,7 +19450,7 @@
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="body_get_user_mask" qualifiers="const" >
|
||||
<method name="body_get_collision_mask" qualifiers="const" >
|
||||
<return type="int">
|
||||
</return>
|
||||
<argument index="0" name="body" type="RID">
|
||||
|
@ -512,6 +512,29 @@ bool Area2D::overlaps_body(Node* p_body) const{
|
||||
|
||||
}
|
||||
|
||||
void Area2D::set_collision_mask(uint32_t p_mask) {
|
||||
|
||||
collision_mask=p_mask;
|
||||
Physics2DServer::get_singleton()->area_set_collision_mask(get_rid(),p_mask);
|
||||
}
|
||||
|
||||
uint32_t Area2D::get_collision_mask() const {
|
||||
|
||||
return collision_mask;
|
||||
}
|
||||
|
||||
|
||||
void Area2D::set_layer_mask(uint32_t p_mask) {
|
||||
|
||||
layer_mask=p_mask;
|
||||
Physics2DServer::get_singleton()->area_set_layer_mask(get_rid(),p_mask);
|
||||
}
|
||||
|
||||
uint32_t Area2D::get_layer_mask() const {
|
||||
|
||||
return layer_mask;
|
||||
}
|
||||
|
||||
|
||||
void Area2D::_bind_methods() {
|
||||
|
||||
@ -542,6 +565,12 @@ void Area2D::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("set_priority","priority"),&Area2D::set_priority);
|
||||
ObjectTypeDB::bind_method(_MD("get_priority"),&Area2D::get_priority);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_collision_mask","collision_mask"),&Area2D::set_collision_mask);
|
||||
ObjectTypeDB::bind_method(_MD("get_collision_mask"),&Area2D::get_collision_mask);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_layer_mask","layer_mask"),&Area2D::set_layer_mask);
|
||||
ObjectTypeDB::bind_method(_MD("get_layer_mask"),&Area2D::get_layer_mask);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_enable_monitoring","enable"),&Area2D::set_enable_monitoring);
|
||||
ObjectTypeDB::bind_method(_MD("is_monitoring_enabled"),&Area2D::is_monitoring_enabled);
|
||||
|
||||
@ -578,6 +607,8 @@ void Area2D::_bind_methods() {
|
||||
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"priority",PROPERTY_HINT_RANGE,"0,128,1"),_SCS("set_priority"),_SCS("get_priority"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitoring"),_SCS("set_enable_monitoring"),_SCS("is_monitoring_enabled"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"monitorable"),_SCS("set_monitorable"),_SCS("is_monitorable"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
|
||||
|
||||
}
|
||||
|
||||
@ -593,9 +624,10 @@ Area2D::Area2D() : CollisionObject2D(Physics2DServer::get_singleton()->area_crea
|
||||
priority=0;
|
||||
monitoring=false;
|
||||
monitorable=false;
|
||||
collision_mask=1;
|
||||
layer_mask=1;
|
||||
set_enable_monitoring(true);
|
||||
set_monitorable(true);
|
||||
|
||||
}
|
||||
|
||||
Area2D::~Area2D() {
|
||||
|
@ -51,6 +51,8 @@ private:
|
||||
bool gravity_is_point;
|
||||
real_t linear_damp;
|
||||
real_t angular_damp;
|
||||
uint32_t collision_mask;
|
||||
uint32_t layer_mask;
|
||||
int priority;
|
||||
bool monitoring;
|
||||
bool monitorable;
|
||||
@ -151,6 +153,12 @@ public:
|
||||
void set_monitorable(bool p_enable);
|
||||
bool is_monitorable() const;
|
||||
|
||||
void set_collision_mask(uint32_t p_mask);
|
||||
uint32_t get_collision_mask() const;
|
||||
|
||||
void set_layer_mask(uint32_t p_mask);
|
||||
uint32_t get_layer_mask() const;
|
||||
|
||||
Array get_overlapping_bodies() const; //function for script
|
||||
Array get_overlapping_areas() const; //function for script
|
||||
|
||||
|
@ -72,13 +72,16 @@ void PhysicsBody2D::_bind_methods() {
|
||||
|
||||
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("set_collision_mask","mask"),&PhysicsBody2D::set_collision_mask);
|
||||
ObjectTypeDB::bind_method(_MD("get_collision_mask"),&PhysicsBody2D::get_collision_mask);
|
||||
ObjectTypeDB::bind_method(_MD("set_one_way_collision_direction","dir"),&PhysicsBody2D::set_one_way_collision_direction);
|
||||
ObjectTypeDB::bind_method(_MD("get_one_way_collision_direction"),&PhysicsBody2D::get_one_way_collision_direction);
|
||||
ObjectTypeDB::bind_method(_MD("set_one_way_collision_max_depth","depth"),&PhysicsBody2D::set_one_way_collision_max_depth);
|
||||
ObjectTypeDB::bind_method(_MD("get_one_way_collision_max_depth"),&PhysicsBody2D::get_one_way_collision_max_depth);
|
||||
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,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_layer_mask"),_SCS("get_layer_mask"));
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
|
||||
ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2,"one_way_collision/direction"),_SCS("set_one_way_collision_direction"),_SCS("get_one_way_collision_direction"));
|
||||
ADD_PROPERTYNZ(PropertyInfo(Variant::REAL,"one_way_collision/max_depth"),_SCS("set_one_way_collision_max_depth"),_SCS("get_one_way_collision_max_depth"));
|
||||
}
|
||||
@ -94,9 +97,22 @@ uint32_t PhysicsBody2D::get_layer_mask() const {
|
||||
return mask;
|
||||
}
|
||||
|
||||
void PhysicsBody2D::set_collision_mask(uint32_t p_mask) {
|
||||
|
||||
collision_mask=p_mask;
|
||||
Physics2DServer::get_singleton()->body_set_collision_mask(get_rid(),p_mask);
|
||||
}
|
||||
|
||||
uint32_t PhysicsBody2D::get_collision_mask() const {
|
||||
|
||||
return collision_mask;
|
||||
}
|
||||
|
||||
|
||||
PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : CollisionObject2D( Physics2DServer::get_singleton()->body_create(p_mode), false) {
|
||||
|
||||
mask=1;
|
||||
collision_mask=1;
|
||||
set_one_way_collision_max_depth(0);
|
||||
set_pickable(false);
|
||||
|
||||
|
@ -39,6 +39,7 @@ class PhysicsBody2D : public CollisionObject2D {
|
||||
OBJ_TYPE(PhysicsBody2D,CollisionObject2D);
|
||||
|
||||
uint32_t mask;
|
||||
uint32_t collision_mask;
|
||||
Vector2 one_way_collision_direction;
|
||||
float one_way_collision_max_depth;
|
||||
protected:
|
||||
@ -52,6 +53,9 @@ public:
|
||||
void set_layer_mask(uint32_t p_mask);
|
||||
uint32_t get_layer_mask() const;
|
||||
|
||||
void set_collision_mask(uint32_t p_mask);
|
||||
uint32_t get_collision_mask() const;
|
||||
|
||||
void add_collision_exception_with(Node* p_node); //must be physicsbody
|
||||
void remove_collision_exception_with(Node* p_node);
|
||||
|
||||
|
@ -519,6 +519,7 @@ Map<TileMap::PosKey,TileMap::Quadrant>::Element *TileMap::_create_quadrant(const
|
||||
q.body=Physics2DServer::get_singleton()->body_create(use_kinematic?Physics2DServer::BODY_MODE_KINEMATIC:Physics2DServer::BODY_MODE_STATIC);
|
||||
Physics2DServer::get_singleton()->body_attach_object_instance_ID(q.body,get_instance_ID());
|
||||
Physics2DServer::get_singleton()->body_set_layer_mask(q.body,collision_layer);
|
||||
Physics2DServer::get_singleton()->body_set_collision_mask(q.body,collision_mask);
|
||||
Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_FRICTION,friction);
|
||||
Physics2DServer::get_singleton()->body_set_param(q.body,Physics2DServer::BODY_PARAM_BOUNCE,bounce);
|
||||
|
||||
@ -790,7 +791,7 @@ Rect2 TileMap::get_item_rect() const {
|
||||
return rect_cache;
|
||||
}
|
||||
|
||||
void TileMap::set_collision_layer_mask(uint32_t p_layer) {
|
||||
void TileMap::set_collision_layer(uint32_t p_layer) {
|
||||
|
||||
collision_layer=p_layer;
|
||||
for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
|
||||
@ -800,6 +801,16 @@ void TileMap::set_collision_layer_mask(uint32_t p_layer) {
|
||||
}
|
||||
}
|
||||
|
||||
void TileMap::set_collision_mask(uint32_t p_mask) {
|
||||
|
||||
collision_mask=p_mask;
|
||||
for (Map<PosKey,Quadrant>::Element *E=quadrant_map.front();E;E=E->next()) {
|
||||
|
||||
Quadrant &q=E->get();
|
||||
Physics2DServer::get_singleton()->body_set_collision_mask(q.body,collision_mask);
|
||||
}
|
||||
}
|
||||
|
||||
bool TileMap::get_collision_use_kinematic() const{
|
||||
|
||||
return use_kinematic;
|
||||
@ -844,11 +855,16 @@ float TileMap::get_collision_bounce() const{
|
||||
}
|
||||
|
||||
|
||||
uint32_t TileMap::get_collision_layer_mask() const {
|
||||
uint32_t TileMap::get_collision_layer() const {
|
||||
|
||||
return collision_layer;
|
||||
}
|
||||
|
||||
uint32_t TileMap::get_collision_mask() const {
|
||||
|
||||
return collision_mask;
|
||||
}
|
||||
|
||||
void TileMap::set_mode(Mode p_mode) {
|
||||
|
||||
_clear_quadrants();
|
||||
@ -1077,8 +1093,11 @@ void TileMap::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("set_collision_use_kinematic","use_kinematic"),&TileMap::set_collision_use_kinematic);
|
||||
ObjectTypeDB::bind_method(_MD("get_collision_use_kinematic"),&TileMap::get_collision_use_kinematic);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_collision_layer_mask","mask"),&TileMap::set_collision_layer_mask);
|
||||
ObjectTypeDB::bind_method(_MD("get_collision_layer_mask"),&TileMap::get_collision_layer_mask);
|
||||
ObjectTypeDB::bind_method(_MD("set_collision_layer","mask"),&TileMap::set_collision_layer);
|
||||
ObjectTypeDB::bind_method(_MD("get_collision_layer"),&TileMap::get_collision_layer);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_collision_mask","mask"),&TileMap::set_collision_mask);
|
||||
ObjectTypeDB::bind_method(_MD("get_collision_mask"),&TileMap::get_collision_mask);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_collision_friction","value"),&TileMap::set_collision_friction);
|
||||
ObjectTypeDB::bind_method(_MD("get_collision_friction"),&TileMap::get_collision_friction);
|
||||
@ -1117,7 +1136,9 @@ void TileMap::_bind_methods() {
|
||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"collision/use_kinematic",PROPERTY_HINT_NONE,""),_SCS("set_collision_use_kinematic"),_SCS("get_collision_use_kinematic"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/friction",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_friction"),_SCS("get_collision_friction"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::REAL,"collision/bounce",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("set_collision_bounce"),_SCS("get_collision_bounce"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer_mask"),_SCS("get_collision_layer_mask"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/layers",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_layer"),_SCS("get_collision_layer"));
|
||||
ADD_PROPERTY( PropertyInfo(Variant::INT,"collision/mask",PROPERTY_HINT_ALL_FLAGS),_SCS("set_collision_mask"),_SCS("get_collision_mask"));
|
||||
|
||||
ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"tile_data",PROPERTY_HINT_NONE,"",PROPERTY_USAGE_NOEDITOR),_SCS("_set_tile_data"),_SCS("_get_tile_data"));
|
||||
|
||||
ADD_SIGNAL(MethodInfo("settings_changed"));
|
||||
@ -1146,6 +1167,7 @@ TileMap::TileMap() {
|
||||
center_x=false;
|
||||
center_y=false;
|
||||
collision_layer=1;
|
||||
collision_mask=1;
|
||||
friction=1;
|
||||
bounce=0;
|
||||
mode=MODE_SQUARE;
|
||||
|
@ -146,6 +146,8 @@ private:
|
||||
float friction;
|
||||
float bounce;
|
||||
uint32_t collision_layer;
|
||||
uint32_t collision_mask;
|
||||
|
||||
TileOrigin tile_origin;
|
||||
|
||||
void _fix_cell_transform(Matrix32& xform, const Cell& p_cell, const Vector2 &p_offset, const Size2 &p_sc);
|
||||
@ -207,8 +209,11 @@ public:
|
||||
|
||||
Rect2 get_item_rect() const;
|
||||
|
||||
void set_collision_layer_mask(uint32_t p_layer);
|
||||
uint32_t get_collision_layer_mask() const;
|
||||
void set_collision_layer(uint32_t p_layer);
|
||||
uint32_t get_collision_layer() const;
|
||||
|
||||
void set_collision_mask(uint32_t p_mask);
|
||||
uint32_t get_collision_mask() const;
|
||||
|
||||
void set_collision_use_kinematic(bool p_use_kinematic);
|
||||
bool get_collision_use_kinematic() const;
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
bool AreaPair2DSW::setup(float p_step) {
|
||||
|
||||
bool result = CollisionSolver2DSW::solve(body->get_shape(body_shape),body->get_transform() * body->get_shape_transform(body_shape),Vector2(),area->get_shape(area_shape),area->get_transform() * area->get_shape_transform(area_shape),Vector2(),NULL,this);
|
||||
bool result = area->test_collision_mask(body) && CollisionSolver2DSW::solve(body->get_shape(body_shape),body->get_transform() * body->get_shape_transform(body_shape),Vector2(),area->get_shape(area_shape),area->get_transform() * area->get_shape_transform(area_shape),Vector2(),NULL,this);
|
||||
|
||||
if (result!=colliding) {
|
||||
|
||||
@ -102,7 +102,7 @@ AreaPair2DSW::~AreaPair2DSW() {
|
||||
|
||||
bool Area2Pair2DSW::setup(float p_step) {
|
||||
|
||||
bool result = CollisionSolver2DSW::solve(area_a->get_shape(shape_a),area_a->get_transform() * area_a->get_shape_transform(shape_a),Vector2(),area_b->get_shape(shape_b),area_b->get_transform() * area_b->get_shape_transform(shape_b),Vector2(),NULL,this);
|
||||
bool result = area_a->test_collision_mask(area_b) && CollisionSolver2DSW::solve(area_a->get_shape(shape_a),area_a->get_transform() * area_a->get_shape_transform(shape_a),Vector2(),area_b->get_shape(shape_b),area_b->get_transform() * area_b->get_shape_transform(shape_b),Vector2(),NULL,this);
|
||||
|
||||
if (result!=colliding) {
|
||||
|
||||
|
@ -234,7 +234,7 @@ bool BodyPair2DSW::setup(float p_step) {
|
||||
|
||||
|
||||
//cannot collide
|
||||
if ((A->get_layer_mask()&B->get_layer_mask())==0 || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && B->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported()==0 && B->get_max_contacts_reported()==0)) {
|
||||
if (!A->test_collision_mask(B) || A->has_exception(B->get_self()) || B->has_exception(A->get_self()) || (A->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && B->get_mode()<=Physics2DServer::BODY_MODE_KINEMATIC && A->get_max_contacts_reported()==0 && B->get_max_contacts_reported()==0)) {
|
||||
collided=false;
|
||||
return false;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ CollisionObject2DSW::CollisionObject2DSW(Type p_type) {
|
||||
type=p_type;
|
||||
space=NULL;
|
||||
instance_id=0;
|
||||
user_mask=0;
|
||||
collision_mask=1;
|
||||
layer_mask=1;
|
||||
pickable=true;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ private:
|
||||
Space2DSW *space;
|
||||
Matrix32 transform;
|
||||
Matrix32 inv_transform;
|
||||
uint32_t user_mask;
|
||||
uint32_t collision_mask;
|
||||
uint32_t layer_mask;
|
||||
bool _static;
|
||||
|
||||
@ -117,8 +117,8 @@ public:
|
||||
_FORCE_INLINE_ bool is_shape_set_as_trigger(int p_idx) const { return shapes[p_idx].trigger; }
|
||||
|
||||
|
||||
void set_user_mask(uint32_t p_mask) {user_mask=p_mask;}
|
||||
_FORCE_INLINE_ uint32_t get_user_mask() const { return user_mask; }
|
||||
void set_collision_mask(uint32_t p_mask) {collision_mask=p_mask;}
|
||||
_FORCE_INLINE_ uint32_t get_collision_mask() const { return collision_mask; }
|
||||
|
||||
void set_layer_mask(uint32_t p_mask) {layer_mask=p_mask;}
|
||||
_FORCE_INLINE_ uint32_t get_layer_mask() const { return layer_mask; }
|
||||
@ -133,6 +133,11 @@ public:
|
||||
void set_pickable(bool p_pickable) { pickable=p_pickable; }
|
||||
_FORCE_INLINE_ bool is_pickable() const { return pickable; }
|
||||
|
||||
_FORCE_INLINE_ bool test_collision_mask(CollisionObject2DSW* p_other) const {
|
||||
|
||||
return layer_mask&p_other->collision_mask || p_other->layer_mask&collision_mask;
|
||||
}
|
||||
|
||||
virtual ~CollisionObject2DSW() {}
|
||||
|
||||
};
|
||||
|
@ -480,6 +480,22 @@ void Physics2DServerSW::area_set_monitorable(RID p_area,bool p_monitorable) {
|
||||
|
||||
}
|
||||
|
||||
void Physics2DServerSW::area_set_collision_mask(RID p_area,uint32_t p_mask) {
|
||||
|
||||
Area2DSW *area = area_owner.get(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
|
||||
area->set_collision_mask(p_mask);
|
||||
}
|
||||
|
||||
void Physics2DServerSW::area_set_layer_mask(RID p_area,uint32_t p_mask) {
|
||||
|
||||
Area2DSW *area = area_owner.get(p_area);
|
||||
ERR_FAIL_COND(!area);
|
||||
|
||||
area->set_layer_mask(p_mask);
|
||||
}
|
||||
|
||||
|
||||
void Physics2DServerSW::area_set_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method) {
|
||||
|
||||
@ -726,20 +742,20 @@ uint32_t Physics2DServerSW::body_get_layer_mask(RID p_body, uint32_t p_flags) co
|
||||
};
|
||||
|
||||
|
||||
void Physics2DServerSW::body_set_user_mask(RID p_body, uint32_t p_flags) {
|
||||
void Physics2DServerSW::body_set_collision_mask(RID p_body, uint32_t p_flags) {
|
||||
|
||||
Body2DSW *body = body_owner.get(p_body);
|
||||
ERR_FAIL_COND(!body);
|
||||
body->set_user_mask(p_flags);
|
||||
body->set_collision_mask(p_flags);
|
||||
|
||||
};
|
||||
|
||||
uint32_t Physics2DServerSW::body_get_user_mask(RID p_body, uint32_t p_flags) const {
|
||||
uint32_t Physics2DServerSW::body_get_collision_mask(RID p_body, uint32_t p_flags) const {
|
||||
|
||||
Body2DSW *body = body_owner.get(p_body);
|
||||
ERR_FAIL_COND_V(!body,0);
|
||||
|
||||
return body->get_user_mask();
|
||||
return body->get_collision_mask();
|
||||
};
|
||||
|
||||
void Physics2DServerSW::body_set_param(RID p_body, BodyParameter p_param, float p_value) {
|
||||
|
@ -134,6 +134,8 @@ public:
|
||||
virtual Variant area_get_param(RID p_parea,AreaParameter p_param) const;
|
||||
virtual Matrix32 area_get_transform(RID p_area) const;
|
||||
virtual void area_set_monitorable(RID p_area,bool p_monitorable);
|
||||
virtual void area_set_collision_mask(RID p_area,uint32_t p_mask);
|
||||
virtual void area_set_layer_mask(RID p_area,uint32_t p_mask);
|
||||
|
||||
virtual void area_set_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method);
|
||||
virtual void area_set_area_monitor_callback(RID p_area,Object *p_receiver,const StringName& p_method);
|
||||
@ -179,8 +181,8 @@ public:
|
||||
virtual void body_set_layer_mask(RID p_body, uint32_t p_mask);
|
||||
virtual uint32_t body_get_layer_mask(RID p_body, uint32_t p_mask) const;
|
||||
|
||||
virtual void body_set_user_mask(RID p_body, uint32_t p_mask);
|
||||
virtual uint32_t body_get_user_mask(RID p_body, uint32_t p_mask) const;
|
||||
virtual void body_set_collision_mask(RID p_body, uint32_t p_mask);
|
||||
virtual uint32_t body_get_collision_mask(RID p_body, uint32_t p_mask) const;
|
||||
|
||||
virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value);
|
||||
virtual float body_get_param(RID p_body, BodyParameter p_param) const;
|
||||
|
@ -596,7 +596,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body,const Vector2&p_motion,float p
|
||||
keep=false;
|
||||
else if (intersection_query_results[i]->get_type()==CollisionObject2DSW::TYPE_AREA)
|
||||
keep=false;
|
||||
else if ((static_cast<Body2DSW*>(intersection_query_results[i])->get_layer_mask()&p_body->get_layer_mask())==0)
|
||||
else if ((static_cast<Body2DSW*>(intersection_query_results[i])->test_collision_mask(p_body))==0)
|
||||
keep=false;
|
||||
else if (static_cast<Body2DSW*>(intersection_query_results[i])->has_exception(p_body->get_self()) || p_body->has_exception(intersection_query_results[i]->get_self()))
|
||||
keep=false;
|
||||
|
@ -536,6 +536,8 @@ void Physics2DServer::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("area_remove_shape","area","shape_idx"),&Physics2DServer::area_remove_shape);
|
||||
ObjectTypeDB::bind_method(_MD("area_clear_shapes","area"),&Physics2DServer::area_clear_shapes);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("area_set_layer_mask","area","mask"),&Physics2DServer::area_set_layer_mask);
|
||||
ObjectTypeDB::bind_method(_MD("area_set_collision_mask","area","mask"),&Physics2DServer::area_set_collision_mask);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("area_set_param","area","param","value"),&Physics2DServer::area_set_param);
|
||||
ObjectTypeDB::bind_method(_MD("area_set_transform","area","transform"),&Physics2DServer::area_set_transform);
|
||||
@ -584,8 +586,8 @@ void Physics2DServer::_bind_methods() {
|
||||
ObjectTypeDB::bind_method(_MD("body_set_layer_mask","body","mask"),&Physics2DServer::body_set_layer_mask);
|
||||
ObjectTypeDB::bind_method(_MD("body_get_layer_mask","body"),&Physics2DServer::body_get_layer_mask);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("body_set_user_mask","body","mask"),&Physics2DServer::body_set_user_mask);
|
||||
ObjectTypeDB::bind_method(_MD("body_get_user_mask","body"),&Physics2DServer::body_get_user_mask);
|
||||
ObjectTypeDB::bind_method(_MD("body_set_collision_mask","body","mask"),&Physics2DServer::body_set_collision_mask);
|
||||
ObjectTypeDB::bind_method(_MD("body_get_collision_mask","body"),&Physics2DServer::body_get_collision_mask);
|
||||
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("body_set_param","body","param","value"),&Physics2DServer::body_set_param);
|
||||
|
@ -347,6 +347,9 @@ public:
|
||||
virtual Variant area_get_param(RID p_parea,AreaParameter p_param) const=0;
|
||||
virtual Matrix32 area_get_transform(RID p_area) const=0;
|
||||
|
||||
virtual void area_set_collision_mask(RID p_area,uint32_t p_mask)=0;
|
||||
virtual void area_set_layer_mask(RID p_area,uint32_t p_mask)=0;
|
||||
|
||||
virtual void area_set_monitorable(RID p_area,bool p_monitorable)=0;
|
||||
virtual void area_set_pickable(RID p_area,bool p_pickable)=0;
|
||||
|
||||
@ -404,8 +407,8 @@ public:
|
||||
virtual void body_set_layer_mask(RID p_body, uint32_t p_mask)=0;
|
||||
virtual uint32_t body_get_layer_mask(RID p_body, uint32_t p_mask) const=0;
|
||||
|
||||
virtual void body_set_user_mask(RID p_body, uint32_t p_mask)=0;
|
||||
virtual uint32_t body_get_user_mask(RID p_body, uint32_t p_mask) const=0;
|
||||
virtual void body_set_collision_mask(RID p_body, uint32_t p_mask)=0;
|
||||
virtual uint32_t body_get_collision_mask(RID p_body, uint32_t p_mask) const=0;
|
||||
|
||||
// common body variables
|
||||
enum BodyParameter {
|
||||
|
@ -221,7 +221,7 @@ PhysicsShapeQueryParameters::PhysicsShapeQueryParameters() {
|
||||
/////////////////////////////////////
|
||||
|
||||
/*
|
||||
Variant PhysicsDirectSpaceState::_intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max,const Vector<RID>& p_exclude,uint32_t p_user_mask) {
|
||||
Variant PhysicsDirectSpaceState::_intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max,const Vector<RID>& p_exclude,uint32_t p_collision_mask) {
|
||||
|
||||
|
||||
|
||||
|
@ -131,8 +131,8 @@ class PhysicsDirectSpaceState : public Object {
|
||||
|
||||
OBJ_TYPE( PhysicsDirectSpaceState, Object );
|
||||
|
||||
// Variant _intersect_ray(const Vector3& p_from, const Vector3& p_to,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_user_mask=0);
|
||||
// Variant _intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max=64,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_user_mask=0);
|
||||
// Variant _intersect_ray(const Vector3& p_from, const Vector3& p_to,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_collision_mask=0);
|
||||
// Variant _intersect_shape(const RID& p_shape, const Transform& p_xform,int p_result_max=64,const Vector<RID>& p_exclude=Vector<RID>(),uint32_t p_collision_mask=0);
|
||||
public:
|
||||
|
||||
enum ObjectTypeMask {
|
||||
|
Loading…
Reference in New Issue
Block a user