summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-11-02 18:53:23 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-11-02 18:53:23 +0100
commit23e793fd189cbba0d16b7145847bcd5586c5a926 (patch)
treebe1a83801bf9ed13c2d98b4c380aa1d23b7a2fe1 /scene/2d
parent1bff95ad497ab78e9fb7ef4033d34ef5af9a212a (diff)
parentbbd225a80483ec993e0633e3bcfea67853f21ded (diff)
Merge pull request #68137 from kleonc/shape-cast-get-collider-rid
Add `ShapeCast2D/3D::get_collider_rid` method
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/shape_cast_2d.cpp6
-rw-r--r--scene/2d/shape_cast_2d.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/scene/2d/shape_cast_2d.cpp b/scene/2d/shape_cast_2d.cpp
index 6222b0db14..4c2e9e4c19 100644
--- a/scene/2d/shape_cast_2d.cpp
+++ b/scene/2d/shape_cast_2d.cpp
@@ -107,6 +107,11 @@ Object *ShapeCast2D::get_collider(int p_idx) const {
return ObjectDB::get_instance(result[p_idx].collider_id);
}
+RID ShapeCast2D::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 ShapeCast2D::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;
@@ -422,6 +427,7 @@ void ShapeCast2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("force_shapecast_update"), &ShapeCast2D::force_shapecast_update);
ClassDB::bind_method(D_METHOD("get_collider", "index"), &ShapeCast2D::get_collider);
+ ClassDB::bind_method(D_METHOD("get_collider_rid", "index"), &ShapeCast2D::get_collider_rid);
ClassDB::bind_method(D_METHOD("get_collider_shape", "index"), &ShapeCast2D::get_collider_shape);
ClassDB::bind_method(D_METHOD("get_collision_point", "index"), &ShapeCast2D::get_collision_point);
ClassDB::bind_method(D_METHOD("get_collision_normal", "index"), &ShapeCast2D::get_collision_normal);
diff --git a/scene/2d/shape_cast_2d.h b/scene/2d/shape_cast_2d.h
index 7b55566b01..134f236d3b 100644
--- a/scene/2d/shape_cast_2d.h
+++ b/scene/2d/shape_cast_2d.h
@@ -104,6 +104,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;
Vector2 get_collision_point(int p_idx) const;
Vector2 get_collision_normal(int p_idx) const;