diff --git a/doc/classes/KinematicCollision.xml b/doc/classes/KinematicCollision.xml index e0ec788fd9c..17be68c071d 100644 --- a/doc/classes/KinematicCollision.xml +++ b/doc/classes/KinematicCollision.xml @@ -21,6 +21,9 @@ The colliding body's metadata. See [Object]. + + The colliding body's [RID] used by the [PhysicsServer]. + The colliding body's shape. diff --git a/doc/classes/KinematicCollision2D.xml b/doc/classes/KinematicCollision2D.xml index 80304e705f6..d70d53e6c00 100644 --- a/doc/classes/KinematicCollision2D.xml +++ b/doc/classes/KinematicCollision2D.xml @@ -21,6 +21,9 @@ The colliding body's metadata. See [Object]. + + The colliding body's [RID] used by the [Physics2DServer]. + The colliding body's shape. diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index e9e194dae15..5092492f532 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -1392,6 +1392,9 @@ Object *KinematicCollision2D::get_collider() const { ObjectID KinematicCollision2D::get_collider_id() const { return collision.collider; } +RID KinematicCollision2D::get_collider_rid() const { + return collision.collider_rid; +} Object *KinematicCollision2D::get_collider_shape() const { Object *collider = get_collider(); if (collider) { @@ -1422,6 +1425,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); @@ -1434,6 +1438,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 6a81654ed89..b14dd57e43e 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -355,6 +355,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; diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index e724ba8c87d..70ebbe2c953 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -1335,6 +1335,9 @@ Object *KinematicCollision::get_collider() const { ObjectID KinematicCollision::get_collider_id() const { return collision.collider; } +RID KinematicCollision::get_collider_rid() const { + return collision.collider_rid; +} Object *KinematicCollision::get_collider_shape() const { Object *collider = get_collider(); if (collider) { @@ -1365,6 +1368,7 @@ void KinematicCollision::_bind_methods() { ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision::get_local_shape); ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision::get_collider); ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision::get_collider_id); + ClassDB::bind_method(D_METHOD("get_collider_rid"), &KinematicCollision::get_collider_rid); ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision::get_collider_shape); ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision::get_collider_shape_index); ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision::get_collider_velocity); @@ -1377,6 +1381,7 @@ void KinematicCollision::_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::VECTOR3, "collider_velocity"), "", "get_collider_velocity"); diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index 673c05390cf..01e6cb6370a 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -346,6 +346,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; Vector3 get_collider_velocity() const;