summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorPouleyKetchoupp <pouleyketchoup@gmail.com>2021-06-09 18:00:41 -0700
committerPouleyKetchoupp <pouleyketchoup@gmail.com>2021-06-09 18:26:00 -0700
commit0eb51b31d42ac9816b2db8a7505266455eff3fe9 (patch)
treec809119a5a770ff2385cf2c5e1b9e50bf1f303d1 /scene/2d
parent0818a466c0a81c7c9793fd8109d25a74f49c00ae (diff)
Expose collider RID in 2D/3D kinematic collision
Can be useful to access the colliding body information for bodies created with the physics server directly.
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/physics_body_2d.cpp6
-rw-r--r--scene/2d/physics_body_2d.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index 4b72043a46..b52c47c268 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -1352,6 +1352,10 @@ ObjectID KinematicCollision2D::get_collider_id() const {
return result.collider_id;
}
+RID KinematicCollision2D::get_collider_rid() const {
+ return result.collider;
+}
+
Object *KinematicCollision2D::get_collider_shape() const {
Object *collider = get_collider();
if (collider) {
@@ -1385,6 +1389,7 @@ void KinematicCollision2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision2D::get_local_shape);
ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision2D::get_collider);
ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision2D::get_collider_id);
+ ClassDB::bind_method(D_METHOD("get_collider_rid"), &KinematicCollision2D::get_collider_rid);
ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision2D::get_collider_shape);
ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision2D::get_collider_shape_index);
ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision2D::get_collider_velocity);
@@ -1397,6 +1402,7 @@ void KinematicCollision2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "local_shape"), "", "get_local_shape");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider"), "", "get_collider");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_id"), "", "get_collider_id");
+ ADD_PROPERTY(PropertyInfo(Variant::RID, "collider_rid"), "", "get_collider_rid");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "collider_shape"), "", "get_collider_shape");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collider_shape_index"), "", "get_collider_shape_index");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "collider_velocity"), "", "get_collider_velocity");
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index cd39a1996c..7fc1bfb446 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -357,6 +357,7 @@ public:
Object *get_local_shape() const;
Object *get_collider() const;
ObjectID get_collider_id() const;
+ RID get_collider_rid() const;
Object *get_collider_shape() const;
int get_collider_shape_index() const;
Vector2 get_collider_velocity() const;