summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/ray_cast.cpp32
-rw-r--r--scene/3d/ray_cast.h8
2 files changed, 39 insertions, 1 deletions
diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp
index 7f83e2c3ea..e1897c0187 100644
--- a/scene/3d/ray_cast.cpp
+++ b/scene/3d/ray_cast.cpp
@@ -49,6 +49,26 @@ Vector3 RayCast::get_cast_to() const {
return cast_to;
}
+void RayCast::set_collide_with_bodies(bool p_enable) {
+
+ collide_with_bodies = p_enable;
+}
+
+bool RayCast::get_collide_with_bodies() const {
+
+ return collide_with_bodies;
+}
+
+void RayCast::set_collide_with_areas(bool p_enable) {
+
+ collide_with_areas = p_enable;
+}
+
+bool RayCast::get_collide_with_areas() const {
+
+ return collide_with_areas;
+}
+
void RayCast::set_collision_mask(uint32_t p_mask) {
collision_mask = p_mask;
@@ -208,7 +228,7 @@ void RayCast::_update_raycast_state() {
PhysicsDirectSpaceState::RayResult rr;
- if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask)) {
+ if (dss->intersect_ray(gt.get_origin(), gt.xform(to), rr, exclude, collision_mask, collide_with_bodies, collide_with_areas)) {
collided = true;
against = rr.collider_id;
@@ -267,6 +287,12 @@ void RayCast::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_cast_to", "local_point"), &RayCast::set_cast_to);
ClassDB::bind_method(D_METHOD("get_cast_to"), &RayCast::get_cast_to);
+ ClassDB::bind_method(D_METHOD("set_collide_with_bodies", "enable"), &RayCast::set_collide_with_bodies);
+ ClassDB::bind_method(D_METHOD("get_collide_with_bodies"), &RayCast::get_collide_with_bodies);
+
+ ClassDB::bind_method(D_METHOD("set_collide_with_areas", "enable"), &RayCast::set_collide_with_areas);
+ ClassDB::bind_method(D_METHOD("get_collide_with_areas"), &RayCast::get_collide_with_areas);
+
ClassDB::bind_method(D_METHOD("is_colliding"), &RayCast::is_colliding);
ClassDB::bind_method(D_METHOD("force_raycast_update"), &RayCast::force_raycast_update);
@@ -295,6 +321,8 @@ void RayCast::_bind_methods() {
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::VECTOR3, "cast_to"), "set_cast_to", "get_cast_to");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_bodies"), "set_collide_with_bodies", "get_collide_with_bodies");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collide_with_areas"), "set_collide_with_areas", "get_collide_with_areas");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask");
}
@@ -368,6 +396,8 @@ RayCast::RayCast() {
against_shape = 0;
collision_mask = 1;
cast_to = Vector3(0, -1, 0);
+ collide_with_bodies = true;
+ collide_with_areas = false;
debug_shape = NULL;
exclude_parent_body = true;
}
diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h
index 20cea80700..417cb884cc 100644
--- a/scene/3d/ray_cast.h
+++ b/scene/3d/ray_cast.h
@@ -45,6 +45,8 @@ class RayCast : public Spatial {
Vector3 collision_normal;
Vector3 cast_to;
+ bool collide_with_bodies;
+ bool collide_with_areas;
Set<RID> exclude;
@@ -70,6 +72,12 @@ public:
void set_cast_to(const Vector3 &p_point);
Vector3 get_cast_to() const;
+ void set_collide_with_bodies(bool p_enable);
+ bool get_collide_with_bodies() const;
+
+ void set_collide_with_areas(bool p_enable);
+ bool get_collide_with_areas() const;
+
void set_collision_mask(uint32_t p_mask);
uint32_t get_collision_mask() const;