summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
authorkleonc <9283098+kleonc@users.noreply.github.com>2022-11-01 21:17:18 +0100
committerkleonc <9283098+kleonc@users.noreply.github.com>2022-11-01 21:17:18 +0100
commitbbd225a80483ec993e0633e3bcfea67853f21ded (patch)
tree484db66169bb7533b7b24e05780e286a47740bde /scene/3d
parent0a0e99cadc6e250ff2ee27ef31760eb9c2e21040 (diff)
Add `ShapeCast2D/3D::get_collider_rid` method
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/shape_cast_3d.cpp6
-rw-r--r--scene/3d/shape_cast_3d.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/scene/3d/shape_cast_3d.cpp b/scene/3d/shape_cast_3d.cpp
index 03cbd984cd..267139c7d0 100644
--- a/scene/3d/shape_cast_3d.cpp
+++ b/scene/3d/shape_cast_3d.cpp
@@ -115,6 +115,7 @@ void ShapeCast3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("force_shapecast_update"), &ShapeCast3D::force_shapecast_update);
ClassDB::bind_method(D_METHOD("get_collider", "index"), &ShapeCast3D::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_rid", "index"), &ShapeCast3D::get_collider_rid);
ClassDB::bind_method(D_METHOD("get_collider_shape", "index"), &ShapeCast3D::get_collider_shape);
ClassDB::bind_method(D_METHOD("get_collision_point", "index"), &ShapeCast3D::get_collision_point);
ClassDB::bind_method(D_METHOD("get_collision_normal", "index"), &ShapeCast3D::get_collision_normal);
@@ -282,6 +283,11 @@ Object *ShapeCast3D::get_collider(int p_idx) const {
return ObjectDB::get_instance(result[p_idx].collider_id);
}
+RID ShapeCast3D::get_collider_rid(int p_idx) const {
+ ERR_FAIL_INDEX_V_MSG(p_idx, result.size(), RID(), "No collider RID found.");
+ return result[p_idx].rid;
+}
+
int ShapeCast3D::get_collider_shape(int p_idx) const {
ERR_FAIL_INDEX_V_MSG(p_idx, result.size(), -1, "No collider shape found.");
return result[p_idx].shape;
diff --git a/scene/3d/shape_cast_3d.h b/scene/3d/shape_cast_3d.h
index 2526d8d32c..abe10c9b24 100644
--- a/scene/3d/shape_cast_3d.h
+++ b/scene/3d/shape_cast_3d.h
@@ -120,6 +120,7 @@ public:
int get_collision_count() const;
Object *get_collider(int p_idx) const;
+ RID get_collider_rid(int p_idx) const;
int get_collider_shape(int p_idx) const;
Vector3 get_collision_point(int p_idx) const;
Vector3 get_collision_normal(int p_idx) const;