From 1aaf507ffb9b96627219d1e6f4ca1f22565e06b8 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Sun, 10 Jan 2016 15:54:57 -0300 Subject: [PATCH] change intersect_ray function to discriminate pickable objects, fixes #3203 --- scene/main/viewport.cpp | 4 ++-- servers/physics/space_sw.cpp | 4 ++-- servers/physics/space_sw.h | 2 +- servers/physics_server.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 6d18a53c9f4..330f855006e 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -577,7 +577,7 @@ void Viewport::_notification(int p_what) { PhysicsDirectSpaceState *space = PhysicsServer::get_singleton()->space_get_direct_state(find_world()->get_space()); if (space) { - bool col = space->intersect_ray(from,from+dir*10000,result,Set(),0xFFFFFFFF,0xFFFFFFFF); + bool col = space->intersect_ray(from,from+dir*10000,result,Set(),0xFFFFFFFF,0xFFFFFFFF,true); ObjectID new_collider=0; if (col) { @@ -617,7 +617,7 @@ void Viewport::_notification(int p_what) { PhysicsDirectSpaceState *space = PhysicsServer::get_singleton()->space_get_direct_state(find_world()->get_space()); if (space) { - bool col = space->intersect_ray(from,from+dir*10000,result,Set(),0xFFFFFFFF,0xFFFFFFFF); + bool col = space->intersect_ray(from,from+dir*10000,result,Set(),0xFFFFFFFF,0xFFFFFFFF,true); ObjectID new_collider=0; if (col) { if (result.collider) { diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index c85e5a85e9b..08f280a9767 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -47,7 +47,7 @@ _FORCE_INLINE_ static bool _match_object_type_query(CollisionObjectSW *p_object, } -bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3& p_from, const Vector3& p_to,RayResult &r_result,const Set& p_exclude,uint32_t p_layer_mask,uint32_t p_object_type_mask) { +bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3& p_from, const Vector3& p_to, RayResult &r_result, const Set& p_exclude, uint32_t p_layer_mask, uint32_t p_object_type_mask, bool p_pick_ray) { ERR_FAIL_COND_V(space->locked,false); @@ -77,7 +77,7 @@ bool PhysicsDirectSpaceStateSW::intersect_ray(const Vector3& p_from, const Vecto if (!_match_object_type_query(space->intersection_query_results[i],p_layer_mask,p_object_type_mask)) continue; - if (!(static_cast(space->intersection_query_results[i])->is_ray_pickable())) + if (p_pick_ray && !(static_cast(space->intersection_query_results[i])->is_ray_pickable())) continue; if (p_exclude.has( space->intersection_query_results[i]->get_self())) diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h index 9c735653819..6300c206d8e 100644 --- a/servers/physics/space_sw.h +++ b/servers/physics/space_sw.h @@ -46,7 +46,7 @@ public: SpaceSW *space; - virtual bool intersect_ray(const Vector3& p_from, const Vector3& 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 bool intersect_ray(const Vector3& p_from, const Vector3& 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,bool p_pick_ray=false); virtual int intersect_shape(const RID& p_shape, const Transform& p_xform,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 Transform& p_xform,const Vector3& 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,ShapeRestInfo *r_info=NULL); virtual bool collide_shape(RID p_shape, const Transform& p_shape_xform,float p_margin,Vector3 *r_results,int p_result_max,int &r_result_count, 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_server.h b/servers/physics_server.h index e04765633dc..8e302bf3636 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -170,7 +170,7 @@ public: int shape; }; - virtual bool intersect_ray(const Vector3& p_from, const Vector3& 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)=0; + virtual bool intersect_ray(const Vector3& p_from, const Vector3& 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,bool p_pick_ray=false)=0; struct ShapeResult {