Skip to content

Commit

Permalink
Revert "Allow Area2D and 3D mouse events without a collision layer"
Browse files Browse the repository at this point in the history
This reverts commit 1585068.
  • Loading branch information
akien-mga committed Jul 27, 2020
1 parent 37bac7d commit 400a780
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions doc/classes/CollisionObject2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
</methods>
<members>
<member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" default="true">
If [code]true[/code], this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events.
If [code]true[/code], this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one [code]collision_layer[/code] bit to be set.
</member>
</members>
<signals>
Expand All @@ -229,17 +229,17 @@
<argument index="2" name="shape_idx" type="int">
</argument>
<description>
Emitted when an input event occurs and [code]input_pickable[/code] is [code]true[/code]. See [method _input_event] for details.
Emitted when an input event occurs. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set. See [method _input_event] for details.
</description>
</signal>
<signal name="mouse_entered">
<description>
Emitted when the mouse pointer enters any of this object's shapes.
Emitted when the mouse pointer enters any of this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.
</description>
</signal>
<signal name="mouse_exited">
<description>
Emitted when the mouse pointer exits all this object's shapes.
Emitted when the mouse pointer exits all this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.
</description>
</signal>
</signals>
Expand Down
2 changes: 1 addition & 1 deletion modules/bullet/godot_result_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool GodotFilterCallback::needBroadphaseCollision(btBroadphaseProxy *proxy0, btB

bool GodotClosestRayResultCallback::needsCollision(btBroadphaseProxy *proxy0) const {
const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask);
if (m_pickRay || needs) {
if (needs) {
btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject);
CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer());

Expand Down
6 changes: 3 additions & 3 deletions servers/physics/space_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
#include "core/project_settings.h"
#include "physics_server_sw.h"

_FORCE_INLINE_ static bool _can_collide_with(CollisionObjectSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_ignore_layers = false) {
_FORCE_INLINE_ static bool _can_collide_with(CollisionObjectSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {

if (!p_ignore_layers && !(p_object->get_collision_layer() & p_collision_mask)) {
if (!(p_object->get_collision_layer() & p_collision_mask)) {
return false;
}

Expand Down Expand Up @@ -115,7 +115,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3 &p_from, const Vecto

for (int i = 0; i < amount; i++) {

if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas, p_pick_ray))
if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
continue;

if (p_pick_ray && !(space->intersection_query_results[i]->is_ray_pickable()))
Expand Down
7 changes: 4 additions & 3 deletions servers/physics_2d/space_2d_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
#include "core/os/os.h"
#include "core/pair.h"
#include "physics_2d_server_sw.h"
_FORCE_INLINE_ static bool _can_collide_with(CollisionObject2DSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas) {

_FORCE_INLINE_ static bool _can_collide_with(CollisionObject2DSW *p_object, uint32_t p_collision_mask, bool p_collide_with_bodies, bool p_collide_with_areas, bool p_ignore_layers = false) {
if (!p_ignore_layers && !(p_object->get_collision_layer() & p_collision_mask)) {
if (!(p_object->get_collision_layer() & p_collision_mask)) {
return false;
}

Expand All @@ -63,7 +63,8 @@ int Physics2DDirectSpaceStateSW::_intersect_point_impl(const Vector2 &p_point, S
int cc = 0;

for (int i = 0; i < amount; i++) {
if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas, p_filter_by_canvas))

if (!_can_collide_with(space->intersection_query_results[i], p_collision_mask, p_collide_with_bodies, p_collide_with_areas))
continue;

if (p_exclude.has(space->intersection_query_results[i]->get_self()))
Expand Down

0 comments on commit 400a780

Please sign in to comment.