From e8c5b41dd8d9825d0ae2f053f2f219289aed91a8 Mon Sep 17 00:00:00 2001 From: Biliogadafr Date: Mon, 1 Feb 2016 04:30:16 +0300 Subject: [PATCH] Physics2D: Allow to use 'intersect_point' with objects which is not 'pickable' --- scene/main/viewport.cpp | 2 +- servers/physics_2d/space_2d_sw.cpp | 4 ++-- servers/physics_2d/space_2d_sw.h | 2 +- servers/physics_2d_server.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 7ed1882d778..d9903636df1 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -533,7 +533,7 @@ void Viewport::_notification(int p_what) { Vector2 point = get_canvas_transform().affine_inverse().xform(pos); Physics2DDirectSpaceState::ShapeResult res[64]; - int rc = ss2d->intersect_point(point,res,64,Set(),0xFFFFFFFF,0xFFFFFFFF); + int rc = ss2d->intersect_point(point,res,64,Set(),0xFFFFFFFF,0xFFFFFFFF,true); for(int i=0;i& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) { +int Physics2DDirectSpaceStateSW::intersect_point(const Vector2& p_point,ShapeResult *r_results,int p_result_max,const Set& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask,bool p_pick_point) { if (p_result_max<=0) return 0; @@ -69,7 +69,7 @@ int Physics2DDirectSpaceStateSW::intersect_point(const Vector2& p_point,ShapeRes const CollisionObject2DSW *col_obj=space->intersection_query_results[i]; - if (!col_obj->is_pickable()) + if (p_pick_point && !col_obj->is_pickable()) continue; int shape_idx=space->intersection_query_subindex_results[i]; diff --git a/servers/physics_2d/space_2d_sw.h b/servers/physics_2d/space_2d_sw.h index 2bdbb8a8815..5f35f224b2e 100644 --- a/servers/physics_2d/space_2d_sw.h +++ b/servers/physics_2d/space_2d_sw.h @@ -46,7 +46,7 @@ public: Space2DSW *space; - virtual int intersect_point(const Vector2& p_point,ShapeResult *r_results,int p_result_max,const Set& p_exclude=Set(),uint32_t p_layer_mask=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& p_exclude=Set(),uint32_t p_layer_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& p_exclude=Set(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); virtual int intersect_shape(const RID& p_shape, const Matrix32& p_xform,const Vector2& p_motion,float p_margin,ShapeResult *r_results,int p_result_max,const Set& p_exclude=Set(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); virtual bool cast_motion(const RID& p_shape, const Matrix32& p_xform,const Vector2& p_motion,float p_margin,float &p_closest_safe,float &p_closest_unsafe, const Set& p_exclude=Set(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION); diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h index 08f69f98b13..7a4365bea3b 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_2d_server.h @@ -182,7 +182,7 @@ public: }; - virtual int intersect_point(const Vector2& p_point,ShapeResult *r_results,int p_result_max,const Set& p_exclude=Set(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION)=0; + virtual int intersect_point(const Vector2& p_point,ShapeResult *r_results,int p_result_max,const Set& p_exclude=Set(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION,bool p_pick_point=false)=0; virtual int intersect_shape(const RID& p_shape, const Matrix32& p_xform,const Vector2& p_motion,float p_margin,ShapeResult *r_results,int p_result_max,const Set& p_exclude=Set(),uint32_t p_layer_mask=0xFFFFFFFF,uint32_t p_object_type_mask=TYPE_MASK_COLLISION)=0;