diff options
-rw-r--r-- | doc/classes/RayCast.xml | 14 | ||||
-rw-r--r-- | doc/classes/RayCast2D.xml | 12 | ||||
-rw-r--r-- | scene/2d/ray_cast_2d.cpp | 18 | ||||
-rw-r--r-- | scene/2d/ray_cast_2d.h | 6 | ||||
-rw-r--r-- | scene/3d/ray_cast.cpp | 18 | ||||
-rw-r--r-- | scene/3d/ray_cast.h | 6 | ||||
-rw-r--r-- | servers/physics/space_sw.cpp | 28 | ||||
-rw-r--r-- | servers/physics/space_sw.h | 12 | ||||
-rw-r--r-- | servers/physics_2d/space_2d_sw.cpp | 28 | ||||
-rw-r--r-- | servers/physics_2d/space_2d_sw.h | 12 |
10 files changed, 77 insertions, 77 deletions
diff --git a/doc/classes/RayCast.xml b/doc/classes/RayCast.xml index 3782a98e3e..fc96a183eb 100644 --- a/doc/classes/RayCast.xml +++ b/doc/classes/RayCast.xml @@ -78,11 +78,11 @@ [/codeblock] </description> </method> - <method name="get_collision_layer" qualifiers="const"> + <method name="get_collision_mask" qualifiers="const"> <return type="int"> </return> <description> - Returns the collision layer for this ray. + Returns the collision mask for this ray. </description> </method> <method name="get_collision_normal" qualifiers="const"> @@ -147,13 +147,13 @@ Sets the ray destination point, so that the ray will test from the ray's origin to [code]local_point[/code]. </description> </method> - <method name="set_collision_layer"> + <method name="set_collision_mask"> <return type="void"> </return> - <argument index="0" name="layer" type="int"> + <argument index="0" name="mask" type="int"> </argument> <description> - Set the mask to filter objects. Only objects with at least the same mask element set will be detected. + Set the mask to filter objects. Only objects in at least one collision layer enabled in the mask will be detected. </description> </method> <method name="set_enabled"> @@ -179,8 +179,8 @@ <member name="cast_to" type="Vector3" setter="set_cast_to" getter="get_cast_to"> The ray's destination point, relative to the RayCast's [code]position[/code]. </member> - <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer"> - The RayCast's collision layer(s). Only bodies in the same collision layer(s) will be detected. + <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask"> + The ray's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. </member> <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled"> If [code]true[/code], collisions will be reported. Default value: [code]false[/code]. diff --git a/doc/classes/RayCast2D.xml b/doc/classes/RayCast2D.xml index 74ee0a8911..b6c657783d 100644 --- a/doc/classes/RayCast2D.xml +++ b/doc/classes/RayCast2D.xml @@ -77,11 +77,11 @@ [/codeblock] </description> </method> - <method name="get_collision_layer" qualifiers="const"> + <method name="get_collision_mask" qualifiers="const"> <return type="int"> </return> <description> - Returns the collision layer for this ray. + Returns the collision mask for this ray. </description> </method> <method name="get_collision_normal" qualifiers="const"> @@ -153,13 +153,13 @@ Sets the ray destination point, so that the ray will test from the ray's origin to [code]local_point[/code] </description> </method> - <method name="set_collision_layer"> + <method name="set_collision_mask"> <return type="void"> </return> <argument index="0" name="layer" type="int"> </argument> <description> - Set the mask to filter objects. Only objects with at least the same mask element set will be detected. + Set the mask to filter objects. Only objects in at least one collision layer enabled in the mask will be detected. </description> </method> <method name="set_enabled"> @@ -194,8 +194,8 @@ <member name="cast_to" type="Vector2" setter="set_cast_to" getter="get_cast_to"> The ray's destination point, relative to the RayCast's [code]position[/code]. </member> - <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer"> - The RayCast2D's collision layer(s). Only bodies in the same collision layer(s) will be detected. + <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask"> + The ray's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. </member> <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled"> If [code]true[/code], collisions will be reported. Default value: [code]false[/code]. diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index b272da46f8..fa656bdcd3 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -46,14 +46,14 @@ Vector2 RayCast2D::get_cast_to() const { return cast_to; } -void RayCast2D::set_collision_layer(uint32_t p_layer) { +void RayCast2D::set_collision_mask(uint32_t p_mask) { - collision_layer = p_layer; + collision_mask = p_mask; } -uint32_t RayCast2D::get_collision_layer() const { +uint32_t RayCast2D::get_collision_mask() const { - return collision_layer; + return collision_mask; } void RayCast2D::set_type_mask(uint32_t p_mask) { @@ -203,7 +203,7 @@ void RayCast2D::_update_raycast_state() { Physics2DDirectSpaceState::RayResult rr; - if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_layer, type_mask)) { + if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, type_mask)) { collided = true; against = rr.collider_id; @@ -276,8 +276,8 @@ void RayCast2D::_bind_methods() { ClassDB::bind_method(D_METHOD("clear_exceptions"), &RayCast2D::clear_exceptions); - ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &RayCast2D::set_collision_layer); - ClassDB::bind_method(D_METHOD("get_collision_layer"), &RayCast2D::get_collision_layer); + ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &RayCast2D::set_collision_mask); + ClassDB::bind_method(D_METHOD("get_collision_mask"), &RayCast2D::get_collision_mask); ClassDB::bind_method(D_METHOD("set_type_mask", "mask"), &RayCast2D::set_type_mask); ClassDB::bind_method(D_METHOD("get_type_mask"), &RayCast2D::get_type_mask); @@ -288,7 +288,7 @@ void RayCast2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "exclude_parent"), "set_exclude_parent_body", "get_exclude_parent_body"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "cast_to"), "set_cast_to", "get_cast_to"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_layer", "get_collision_layer"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_mask", "get_collision_mask"); ADD_PROPERTY(PropertyInfo(Variant::INT, "type_mask", PROPERTY_HINT_FLAGS, "Static,Kinematic,Rigid,Character,Area"), "set_type_mask", "get_type_mask"); } @@ -298,7 +298,7 @@ RayCast2D::RayCast2D() { against = 0; collided = false; against_shape = 0; - collision_layer = 1; + collision_mask = 1; type_mask = Physics2DDirectSpaceState::TYPE_MASK_COLLISION; cast_to = Vector2(0, 50); exclude_parent_body = true; diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h index 338de814d2..da1be84307 100644 --- a/scene/2d/ray_cast_2d.h +++ b/scene/2d/ray_cast_2d.h @@ -43,7 +43,7 @@ class RayCast2D : public Node2D { Vector2 collision_point; Vector2 collision_normal; Set<RID> exclude; - uint32_t collision_layer; + uint32_t collision_mask; uint32_t type_mask; bool exclude_parent_body; @@ -61,8 +61,8 @@ public: void set_cast_to(const Vector2 &p_point); Vector2 get_cast_to() 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_type_mask(uint32_t p_mask); uint32_t get_type_mask() const; diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index df6764ee1a..296bddf0a3 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -48,14 +48,14 @@ Vector3 RayCast::get_cast_to() const { return cast_to; } -void RayCast::set_collision_layer(uint32_t p_layer) { +void RayCast::set_collision_mask(uint32_t p_mask) { - collision_layer = p_layer; + collision_mask = p_mask; } -uint32_t RayCast::get_collision_layer() const { +uint32_t RayCast::get_collision_mask() const { - return collision_layer; + return collision_mask; } void RayCast::set_type_mask(uint32_t p_mask) { @@ -172,7 +172,7 @@ void RayCast::_update_raycast_state() { PhysicsDirectSpaceState::RayResult rr; - if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_layer, type_mask)) { + if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, type_mask)) { collided = true; against = rr.collider_id; @@ -245,15 +245,15 @@ void RayCast::_bind_methods() { ClassDB::bind_method(D_METHOD("clear_exceptions"), &RayCast::clear_exceptions); - ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &RayCast::set_collision_layer); - ClassDB::bind_method(D_METHOD("get_collision_layer"), &RayCast::get_collision_layer); + ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &RayCast::set_collision_mask); + ClassDB::bind_method(D_METHOD("get_collision_mask"), &RayCast::get_collision_mask); ClassDB::bind_method(D_METHOD("set_type_mask", "mask"), &RayCast::set_type_mask); ClassDB::bind_method(D_METHOD("get_type_mask"), &RayCast::get_type_mask); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enabled"), "set_enabled", "is_enabled"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "cast_to"), "set_cast_to", "get_cast_to"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_layer", "get_collision_layer"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask"); ADD_PROPERTY(PropertyInfo(Variant::INT, "type_mask", PROPERTY_HINT_FLAGS, "Static,Kinematic,Rigid,Character,Area"), "set_type_mask", "get_type_mask"); } @@ -325,7 +325,7 @@ RayCast::RayCast() { against = 0; collided = false; against_shape = 0; - collision_layer = 1; + collision_mask = 1; type_mask = PhysicsDirectSpaceState::TYPE_MASK_COLLISION; cast_to = Vector3(0, -1, 0); debug_shape = NULL; diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h index fd566cd343..cd3cf3c913 100644 --- a/scene/3d/ray_cast.h +++ b/scene/3d/ray_cast.h @@ -47,7 +47,7 @@ class RayCast : public Spatial { Set<RID> exclude; - uint32_t collision_layer; + uint32_t collision_mask; uint32_t type_mask; Node *debug_shape; @@ -69,8 +69,8 @@ public: void set_cast_to(const Vector3 &p_point); Vector3 get_cast_to() 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_type_mask(uint32_t p_mask); uint32_t get_type_mask() const; diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index 17e2df6c9e..7e68d54bfa 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -33,9 +33,9 @@ #include "physics_server_sw.h" #include "project_settings.h" -_FORCE_INLINE_ static bool _match_object_type_query(CollisionObjectSW *p_object, uint32_t p_collision_layer, uint32_t p_type_mask) { +_FORCE_INLINE_ static bool _match_object_type_query(CollisionObjectSW *p_object, uint32_t p_collision_mask, uint32_t p_type_mask) { - if ((p_object->get_collision_layer() & p_collision_layer) == 0) + if ((p_object->get_collision_layer() & p_collision_mask) == 0) return false; if (p_object->get_type() == CollisionObjectSW::TYPE_AREA) @@ -46,7 +46,7 @@ _FORCE_INLINE_ static bool _match_object_type_query(CollisionObjectSW *p_object, return (1 << body->get_mode()) & p_type_mask; } -int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask) { +int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask) { ERR_FAIL_COND_V(space->locked, false); int amount = space->broadphase->cull_point(p_point, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); @@ -59,7 +59,7 @@ int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResu if (cc >= p_result_max) break; - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; //area can't be picked by ray (default) @@ -90,7 +90,7 @@ int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResu return cc; } -bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask, bool p_pick_ray) { +bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask, bool p_pick_ray) { ERR_FAIL_COND_V(space->locked, false); @@ -112,7 +112,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto for (int i = 0; i < amount; i++) { - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; if (p_pick_ray && !(static_cast<CollisionObjectSW *>(space->intersection_query_results[i])->is_ray_pickable())) @@ -168,7 +168,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto return true; } -int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask) { +int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask) { if (p_result_max <= 0) return 0; @@ -189,7 +189,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo if (cc >= p_result_max) break; - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; //area can't be picked by ray (default) @@ -219,7 +219,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo return cc; } -bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask, ShapeRestInfo *r_info) { +bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask, ShapeRestInfo *r_info) { ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, false); @@ -249,7 +249,7 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform for (int i = 0; i < amount; i++) { - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; if (p_exclude.has(space->intersection_query_results[i]->get_self())) @@ -333,7 +333,7 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform return true; } -bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask) { +bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask) { if (p_result_max <= 0) return 0; @@ -363,7 +363,7 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh for (int i = 0; i < amount; i++) { - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; const CollisionObjectSW *col_obj = space->intersection_query_results[i]; @@ -412,7 +412,7 @@ static void _rest_cbk_result(const Vector3 &p_point_A, const Vector3 &p_point_B, rd->best_object = rd->object; rd->best_shape = rd->shape; } -bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask) { +bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask) { ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, 0); @@ -429,7 +429,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_ for (int i = 0; i < amount; i++) { - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; const CollisionObjectSW *col_obj = space->intersection_query_results[i]; diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h index 56f4d2f10d..270e4ef1bd 100644 --- a/servers/physics/space_sw.h +++ b/servers/physics/space_sw.h @@ -47,12 +47,12 @@ class PhysicsDirectSpaceStateSW : public PhysicsDirectSpaceState { public: SpaceSW *space; - virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); - virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, bool p_pick_ray = false); - virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); - virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, ShapeRestInfo *r_info = NULL); - virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); - virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); + virtual int intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); + virtual bool intersect_ray(const Vector3 &p_from, const Vector3 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, bool p_pick_ray = false); + virtual int intersect_shape(const RID &p_shape, const Transform &p_xform, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); + virtual bool cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, ShapeRestInfo *r_info = NULL); + virtual bool collide_shape(RID p_shape, const Transform &p_shape_xform, real_t p_margin, Vector3 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); + virtual bool rest_info(RID p_shape, const Transform &p_shape_xform, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const; PhysicsDirectSpaceStateSW(); diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 8f22d1cd44..6eaaaa777b 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -32,9 +32,9 @@ #include "collision_solver_2d_sw.h" #include "pair.h" #include "physics_2d_server_sw.h" -_FORCE_INLINE_ static bool _match_object_type_query(CollisionObject2DSW *p_object, uint32_t p_collision_layer, uint32_t p_type_mask) { +_FORCE_INLINE_ static bool _match_object_type_query(CollisionObject2DSW *p_object, uint32_t p_collision_mask, uint32_t p_type_mask) { - if ((p_object->get_collision_layer() & p_collision_layer) == 0) + if ((p_object->get_collision_layer() & p_collision_mask) == 0) return false; if (p_object->get_type() == CollisionObject2DSW::TYPE_AREA) @@ -45,7 +45,7 @@ _FORCE_INLINE_ static bool _match_object_type_query(CollisionObject2DSW *p_objec return (1 << body->get_mode()) & p_type_mask; } -int Physics2DDirectSpaceStateSW::intersect_point(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask, bool p_pick_point) { +int Physics2DDirectSpaceStateSW::intersect_point(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask, bool p_pick_point) { if (p_result_max <= 0) return 0; @@ -60,7 +60,7 @@ int Physics2DDirectSpaceStateSW::intersect_point(const Vector2 &p_point, ShapeRe for (int i = 0; i < amount; i++) { - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; if (p_exclude.has(space->intersection_query_results[i]->get_self())) @@ -96,7 +96,7 @@ int Physics2DDirectSpaceStateSW::intersect_point(const Vector2 &p_point, ShapeRe return cc; } -bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2 &p_from, const Vector2 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask) { +bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2 &p_from, const Vector2 &p_to, RayResult &r_result, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask) { ERR_FAIL_COND_V(space->locked, false); @@ -118,7 +118,7 @@ bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2 &p_from, const Vec for (int i = 0; i < amount; i++) { - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; if (p_exclude.has(space->intersection_query_results[i]->get_self())) @@ -176,7 +176,7 @@ bool Physics2DDirectSpaceStateSW::intersect_ray(const Vector2 &p_from, const Vec return true; } -int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask) { +int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask) { if (p_result_max <= 0) return 0; @@ -193,7 +193,7 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans for (int i = 0; i < amount; i++) { - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; if (p_exclude.has(space->intersection_query_results[i]->get_self())) @@ -218,7 +218,7 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans return cc; } -bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask) { +bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask) { Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, false); @@ -239,7 +239,7 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transfor for (int i = 0; i < amount; i++) { - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; if (p_exclude.has(space->intersection_query_results[i]->get_self())) @@ -302,7 +302,7 @@ bool Physics2DDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transfor return true; } -bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask) { +bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask) { if (p_result_max <= 0) return 0; @@ -333,7 +333,7 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D & for (int i = 0; i < amount; i++) { - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; const CollisionObject2DSW *col_obj = space->intersection_query_results[i]; @@ -391,7 +391,7 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B, rd->best_shape = rd->shape; } -bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask) { +bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude, uint32_t p_collision_mask, uint32_t p_object_type_mask) { Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, 0); @@ -409,7 +409,7 @@ bool Physics2DDirectSpaceStateSW::rest_info(RID p_shape, const Transform2D &p_sh for (int i = 0; i < amount; i++) { - if (!_match_object_type_query(space->intersection_query_results[i], p_collision_layer, p_object_type_mask)) + if (!_match_object_type_query(space->intersection_query_results[i], p_collision_mask, p_object_type_mask)) continue; const CollisionObject2DSW *col_obj = space->intersection_query_results[i]; diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h index c7e7497397..bf0796fb22 100644 --- a/servers/physics_2d/space_2d_sw.h +++ b/servers/physics_2d/space_2d_sw.h @@ -47,12 +47,12 @@ class Physics2DDirectSpaceStateSW : public Physics2DDirectSpaceState { public: Space2DSW *space; - virtual int intersect_point(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, bool p_pick_point = false); - virtual bool intersect_ray(const Vector2 &p_from, const Vector2 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); - virtual int intersect_shape(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); - virtual bool cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); - virtual bool collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); - virtual bool rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); + virtual int intersect_point(const Vector2 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, bool p_pick_point = false); + virtual bool intersect_ray(const Vector2 &p_from, const Vector2 &p_to, RayResult &r_result, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); + virtual int intersect_shape(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); + virtual bool cast_motion(const RID &p_shape, const Transform2D &p_xform, const Vector2 &p_motion, real_t p_margin, real_t &p_closest_safe, real_t &p_closest_unsafe, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); + virtual bool collide_shape(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, Vector2 *r_results, int p_result_max, int &r_result_count, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); + virtual bool rest_info(RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, real_t p_margin, ShapeRestInfo *r_info, const Set<RID> &p_exclude = Set<RID>(), uint32_t p_collision_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); Physics2DDirectSpaceStateSW(); }; |