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.
This commit is contained in:
parent
0818a466c0
commit
0eb51b31d4
|
@ -21,6 +21,9 @@
|
|||
<member name="collider_metadata" type="Variant" setter="" getter="get_collider_metadata">
|
||||
The colliding body's metadata. See [Object].
|
||||
</member>
|
||||
<member name="collider_rid" type="RID" setter="" getter="get_collider_rid">
|
||||
The colliding body's [RID] used by the [PhysicsServer2D].
|
||||
</member>
|
||||
<member name="collider_shape" type="Object" setter="" getter="get_collider_shape">
|
||||
The colliding body's shape.
|
||||
</member>
|
||||
|
|
|
@ -21,6 +21,9 @@
|
|||
<member name="collider_metadata" type="Variant" setter="" getter="get_collider_metadata">
|
||||
The colliding body's metadata. See [Object].
|
||||
</member>
|
||||
<member name="collider_rid" type="RID" setter="" getter="get_collider_rid">
|
||||
The colliding body's [RID] used by the [PhysicsServer3D].
|
||||
</member>
|
||||
<member name="collider_shape" type="Object" setter="" getter="get_collider_shape">
|
||||
The colliding body's shape.
|
||||
</member>
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1337,6 +1337,10 @@ ObjectID KinematicCollision3D::get_collider_id() const {
|
|||
return result.collider_id;
|
||||
}
|
||||
|
||||
RID KinematicCollision3D::get_collider_rid() const {
|
||||
return result.collider;
|
||||
}
|
||||
|
||||
Object *KinematicCollision3D::get_collider_shape() const {
|
||||
Object *collider = get_collider();
|
||||
if (collider) {
|
||||
|
@ -1370,6 +1374,7 @@ void KinematicCollision3D::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("get_local_shape"), &KinematicCollision3D::get_local_shape);
|
||||
ClassDB::bind_method(D_METHOD("get_collider"), &KinematicCollision3D::get_collider);
|
||||
ClassDB::bind_method(D_METHOD("get_collider_id"), &KinematicCollision3D::get_collider_id);
|
||||
ClassDB::bind_method(D_METHOD("get_collider_rid"), &KinematicCollision3D::get_collider_rid);
|
||||
ClassDB::bind_method(D_METHOD("get_collider_shape"), &KinematicCollision3D::get_collider_shape);
|
||||
ClassDB::bind_method(D_METHOD("get_collider_shape_index"), &KinematicCollision3D::get_collider_shape_index);
|
||||
ClassDB::bind_method(D_METHOD("get_collider_velocity"), &KinematicCollision3D::get_collider_velocity);
|
||||
|
@ -1382,6 +1387,7 @@ void KinematicCollision3D::_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");
|
||||
|
|
|
@ -358,6 +358,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;
|
||||
|
|
Loading…
Reference in New Issue