Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhysicsShapeQueryParameters2D collision_layer property is actually collision_mask #44622

Closed
Tracked by #45334
briansemrau opened this issue Dec 23, 2020 · 1 comment
Closed
Tracked by #45334

Comments

@briansemrau
Copy link
Contributor

Godot version:

3.2, 4.0.dev

Issue description:

While looking at the code for PhysicsShapeQueryParameters2D, I noticed the property name collision_layer was different than the name in the implementation (collision_mask). This also occurs in the parameter names for various intersect_... functions in PhysicsDirectSpaceState2D. The implementation behaves as collision_mask, as it should.

This mismatch is also apparent in the documentation, for example here. The parameter name is listed as "collision_layer", but the description only talks about a collision_mask. This can only serve to confuse users even more, given the already confusing nature of the two properties.

PhysicsShapeQueryParameters2D:

// physics_server_2d.cpp
ClassDB::bind_method(D_METHOD("set_collision_layer", "collision_layer"), &PhysicsShapeQueryParameters2D::set_collision_mask);
ClassDB::bind_method(D_METHOD("get_collision_layer"), &PhysicsShapeQueryParameters2D::get_collision_mask);
...
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_layer", PROPERTY_HINT_LAYERS_2D_PHYSICS), "set_collision_layer", "get_collision_layer");

PhysicsDirectSpaceState2D:

// physics_server_2d.cpp
ClassDB::bind_method(D_METHOD("intersect_point", "point", "max_results", "exclude", "collision_layer", "collide_with_bodies", "collide_with_areas"), &PhysicsDirectSpaceState2D::_intersect_point, DEFVAL(32), DEFVAL(Array()), DEFVAL(0x7FFFFFFF), DEFVAL(true), DEFVAL(false));

Note the parameter name "collision_layer". This bound function passes through to eventually arrive at this, with parameter "p_collision_mask":

// space_2d_sw.h
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, bool p_collide_with_bodies = true, bool p_collide_with_areas = false, bool p_pick_point = false) override;
@rburing
Copy link
Member

rburing commented Apr 20, 2024

Fixed a few years ago by #51532.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants