Rename RayCasts collision_layer to collision_mask

The point is that `RayCast`s are checked against objects' `collision_layer`(s), but they themselves are considered no to _belong_ to any layer. Therefore, the correct name for their property is `collision_mask`, rather than `collision_layer`.

Only renaming is needed since the behavior was already the right one, only that it wasn't matching what users would expect from the name and description of the property.

Fixes #7589, where it's also discussed.
This commit is contained in:
Pedro J. Estébanez 2017-10-21 22:17:26 +02:00
parent 6361e24f29
commit 7b12ae39f2
10 changed files with 77 additions and 77 deletions

View file

@ -78,11 +78,11 @@
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
<method name="get_collision_layer" qualifiers="const"> <method name="get_collision_mask" qualifiers="const">
<return type="int"> <return type="int">
</return> </return>
<description> <description>
Returns the collision layer for this ray. Returns the collision mask for this ray.
</description> </description>
</method> </method>
<method name="get_collision_normal" qualifiers="const"> <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]. Sets the ray destination point, so that the ray will test from the ray's origin to [code]local_point[/code].
</description> </description>
</method> </method>
<method name="set_collision_layer"> <method name="set_collision_mask">
<return type="void"> <return type="void">
</return> </return>
<argument index="0" name="layer" type="int"> <argument index="0" name="mask" type="int">
</argument> </argument>
<description> <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> </description>
</method> </method>
<method name="set_enabled"> <method name="set_enabled">
@ -179,8 +179,8 @@
<member name="cast_to" type="Vector3" setter="set_cast_to" getter="get_cast_to"> <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]. The ray's destination point, relative to the RayCast's [code]position[/code].
</member> </member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer"> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask">
The RayCast's collision layer(s). Only bodies in the same collision layer(s) will be detected. The ray's collision mask. Only objects in at least one collision layer enabled in the mask will be detected.
</member> </member>
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled"> <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled">
If [code]true[/code], collisions will be reported. Default value: [code]false[/code]. If [code]true[/code], collisions will be reported. Default value: [code]false[/code].

View file

@ -77,11 +77,11 @@
[/codeblock] [/codeblock]
</description> </description>
</method> </method>
<method name="get_collision_layer" qualifiers="const"> <method name="get_collision_mask" qualifiers="const">
<return type="int"> <return type="int">
</return> </return>
<description> <description>
Returns the collision layer for this ray. Returns the collision mask for this ray.
</description> </description>
</method> </method>
<method name="get_collision_normal" qualifiers="const"> <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] Sets the ray destination point, so that the ray will test from the ray's origin to [code]local_point[/code]
</description> </description>
</method> </method>
<method name="set_collision_layer"> <method name="set_collision_mask">
<return type="void"> <return type="void">
</return> </return>
<argument index="0" name="layer" type="int"> <argument index="0" name="layer" type="int">
</argument> </argument>
<description> <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> </description>
</method> </method>
<method name="set_enabled"> <method name="set_enabled">
@ -194,8 +194,8 @@
<member name="cast_to" type="Vector2" setter="set_cast_to" getter="get_cast_to"> <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]. The ray's destination point, relative to the RayCast's [code]position[/code].
</member> </member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer"> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask">
The RayCast2D's collision layer(s). Only bodies in the same collision layer(s) will be detected. The ray's collision mask. Only objects in at least one collision layer enabled in the mask will be detected.
</member> </member>
<member name="enabled" type="bool" setter="set_enabled" getter="is_enabled"> <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled">
If [code]true[/code], collisions will be reported. Default value: [code]false[/code]. If [code]true[/code], collisions will be reported. Default value: [code]false[/code].

View file

@ -46,14 +46,14 @@ Vector2 RayCast2D::get_cast_to() const {
return cast_to; 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) { void RayCast2D::set_type_mask(uint32_t p_mask) {
@ -203,7 +203,7 @@ void RayCast2D::_update_raycast_state() {
Physics2DDirectSpaceState::RayResult rr; 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; collided = true;
against = rr.collider_id; 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("clear_exceptions"), &RayCast2D::clear_exceptions);
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &RayCast2D::set_collision_layer); ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &RayCast2D::set_collision_mask);
ClassDB::bind_method(D_METHOD("get_collision_layer"), &RayCast2D::get_collision_layer); 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("set_type_mask", "mask"), &RayCast2D::set_type_mask);
ClassDB::bind_method(D_METHOD("get_type_mask"), &RayCast2D::get_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, "enabled"), "set_enabled", "is_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "exclude_parent"), "set_exclude_parent_body", "get_exclude_parent_body"); 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::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"); 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; against = 0;
collided = false; collided = false;
against_shape = 0; against_shape = 0;
collision_layer = 1; collision_mask = 1;
type_mask = Physics2DDirectSpaceState::TYPE_MASK_COLLISION; type_mask = Physics2DDirectSpaceState::TYPE_MASK_COLLISION;
cast_to = Vector2(0, 50); cast_to = Vector2(0, 50);
exclude_parent_body = true; exclude_parent_body = true;

View file

@ -43,7 +43,7 @@ class RayCast2D : public Node2D {
Vector2 collision_point; Vector2 collision_point;
Vector2 collision_normal; Vector2 collision_normal;
Set<RID> exclude; Set<RID> exclude;
uint32_t collision_layer; uint32_t collision_mask;
uint32_t type_mask; uint32_t type_mask;
bool exclude_parent_body; bool exclude_parent_body;
@ -61,8 +61,8 @@ public:
void set_cast_to(const Vector2 &p_point); void set_cast_to(const Vector2 &p_point);
Vector2 get_cast_to() const; Vector2 get_cast_to() const;
void set_collision_layer(uint32_t p_layer); void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_layer() const; uint32_t get_collision_mask() const;
void set_type_mask(uint32_t p_mask); void set_type_mask(uint32_t p_mask);
uint32_t get_type_mask() const; uint32_t get_type_mask() const;

View file

@ -48,14 +48,14 @@ Vector3 RayCast::get_cast_to() const {
return cast_to; 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) { void RayCast::set_type_mask(uint32_t p_mask) {
@ -172,7 +172,7 @@ void RayCast::_update_raycast_state() {
PhysicsDirectSpaceState::RayResult rr; 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; collided = true;
against = rr.collider_id; 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("clear_exceptions"), &RayCast::clear_exceptions);
ClassDB::bind_method(D_METHOD("set_collision_layer", "layer"), &RayCast::set_collision_layer); ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &RayCast::set_collision_mask);
ClassDB::bind_method(D_METHOD("get_collision_layer"), &RayCast::get_collision_layer); 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("set_type_mask", "mask"), &RayCast::set_type_mask);
ClassDB::bind_method(D_METHOD("get_type_mask"), &RayCast::get_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::BOOL, "enabled"), "set_enabled", "is_enabled");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "cast_to"), "set_cast_to", "get_cast_to"); 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"); 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; against = 0;
collided = false; collided = false;
against_shape = 0; against_shape = 0;
collision_layer = 1; collision_mask = 1;
type_mask = PhysicsDirectSpaceState::TYPE_MASK_COLLISION; type_mask = PhysicsDirectSpaceState::TYPE_MASK_COLLISION;
cast_to = Vector3(0, -1, 0); cast_to = Vector3(0, -1, 0);
debug_shape = NULL; debug_shape = NULL;

View file

@ -47,7 +47,7 @@ class RayCast : public Spatial {
Set<RID> exclude; Set<RID> exclude;
uint32_t collision_layer; uint32_t collision_mask;
uint32_t type_mask; uint32_t type_mask;
Node *debug_shape; Node *debug_shape;
@ -69,8 +69,8 @@ public:
void set_cast_to(const Vector3 &p_point); void set_cast_to(const Vector3 &p_point);
Vector3 get_cast_to() const; Vector3 get_cast_to() const;
void set_collision_layer(uint32_t p_layer); void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_layer() const; uint32_t get_collision_mask() const;
void set_type_mask(uint32_t p_mask); void set_type_mask(uint32_t p_mask);
uint32_t get_type_mask() const; uint32_t get_type_mask() const;

View file

@ -33,9 +33,9 @@
#include "physics_server_sw.h" #include "physics_server_sw.h"
#include "project_settings.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; return false;
if (p_object->get_type() == CollisionObjectSW::TYPE_AREA) 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; 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); 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); 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) if (cc >= p_result_max)
break; 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; continue;
//area can't be picked by ray (default) //area can't be picked by ray (default)
@ -90,7 +90,7 @@ int PhysicsDirectSpaceStateSW::intersect_point(const Vector3 &p_point, ShapeResu
return cc; 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); 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++) { 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; continue;
if (p_pick_ray && !(static_cast<CollisionObjectSW *>(space->intersection_query_results[i])->is_ray_pickable())) 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; 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) if (p_result_max <= 0)
return 0; return 0;
@ -189,7 +189,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo
if (cc >= p_result_max) if (cc >= p_result_max)
break; 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; continue;
//area can't be picked by ray (default) //area can't be picked by ray (default)
@ -219,7 +219,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo
return cc; 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); ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
ERR_FAIL_COND_V(!shape, false); 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++) { 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; continue;
if (p_exclude.has(space->intersection_query_results[i]->get_self())) 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; 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) if (p_result_max <= 0)
return 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++) { 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; continue;
const CollisionObjectSW *col_obj = space->intersection_query_results[i]; 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_object = rd->object;
rd->best_shape = rd->shape; 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); ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
ERR_FAIL_COND_V(!shape, 0); 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++) { 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; continue;
const CollisionObjectSW *col_obj = space->intersection_query_results[i]; const CollisionObjectSW *col_obj = space->intersection_query_results[i];

View file

@ -47,12 +47,12 @@ class PhysicsDirectSpaceStateSW : public PhysicsDirectSpaceState {
public: public:
SpaceSW *space; 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 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_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, bool p_pick_ray = false); 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_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); 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_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION, ShapeRestInfo *r_info = NULL); 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_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); 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_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_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; virtual Vector3 get_closest_point_to_object_volume(RID p_object, const Vector3 p_point) const;
PhysicsDirectSpaceStateSW(); PhysicsDirectSpaceStateSW();

View file

@ -32,9 +32,9 @@
#include "collision_solver_2d_sw.h" #include "collision_solver_2d_sw.h"
#include "pair.h" #include "pair.h"
#include "physics_2d_server_sw.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; return false;
if (p_object->get_type() == CollisionObject2DSW::TYPE_AREA) 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; 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) if (p_result_max <= 0)
return 0; return 0;
@ -60,7 +60,7 @@ int Physics2DDirectSpaceStateSW::intersect_point(const Vector2 &p_point, ShapeRe
for (int i = 0; i < amount; i++) { 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; continue;
if (p_exclude.has(space->intersection_query_results[i]->get_self())) 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; 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); 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++) { 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; continue;
if (p_exclude.has(space->intersection_query_results[i]->get_self())) 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; 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) if (p_result_max <= 0)
return 0; return 0;
@ -193,7 +193,7 @@ int Physics2DDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Trans
for (int i = 0; i < amount; i++) { 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; continue;
if (p_exclude.has(space->intersection_query_results[i]->get_self())) 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; 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); Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
ERR_FAIL_COND_V(!shape, false); 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++) { 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; continue;
if (p_exclude.has(space->intersection_query_results[i]->get_self())) 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; 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) if (p_result_max <= 0)
return 0; return 0;
@ -333,7 +333,7 @@ bool Physics2DDirectSpaceStateSW::collide_shape(RID p_shape, const Transform2D &
for (int i = 0; i < amount; i++) { 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; continue;
const CollisionObject2DSW *col_obj = space->intersection_query_results[i]; 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; 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); Shape2DSW *shape = Physics2DServerSW::singletonsw->shape_owner.get(p_shape);
ERR_FAIL_COND_V(!shape, 0); 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++) { 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; continue;
const CollisionObject2DSW *col_obj = space->intersection_query_results[i]; const CollisionObject2DSW *col_obj = space->intersection_query_results[i];

View file

@ -47,12 +47,12 @@ class Physics2DDirectSpaceStateSW : public Physics2DDirectSpaceState {
public: public:
Space2DSW *space; 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 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_layer = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION); 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_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_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_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_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_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_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_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_mask = 0xFFFFFFFF, uint32_t p_object_type_mask = TYPE_MASK_COLLISION);
Physics2DDirectSpaceStateSW(); Physics2DDirectSpaceStateSW();
}; };