summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-08-10 11:47:23 +0200
committerGitHub <noreply@github.com>2022-08-10 11:47:23 +0200
commit0e60a4ab0211617dc43c7b5369be5604a409620e (patch)
treeb5f0fad8998faf88d531b03da595a2a24d274778 /scene
parent7a5c50540ea05ba40b96b9712b8e24a40d57764f (diff)
parent733129552384e3047e4e7703974ececa4cd57742 (diff)
Merge pull request #64195 from TokageItLab/add-get-depth-3d
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/physics_body_2d.cpp5
-rw-r--r--scene/2d/physics_body_2d.h1
-rw-r--r--scene/3d/physics_body_3d.cpp5
-rw-r--r--scene/3d/physics_body_3d.h1
4 files changed, 12 insertions, 0 deletions
diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp
index ce22f32b01..2ead48c889 100644
--- a/scene/2d/physics_body_2d.cpp
+++ b/scene/2d/physics_body_2d.cpp
@@ -1823,6 +1823,10 @@ real_t KinematicCollision2D::get_angle(const Vector2 &p_up_direction) const {
return result.get_angle(p_up_direction);
}
+real_t KinematicCollision2D::get_depth() const {
+ return result.collision_depth;
+}
+
Object *KinematicCollision2D::get_local_shape() const {
if (!owner) {
return nullptr;
@@ -1874,6 +1878,7 @@ void KinematicCollision2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision2D::get_travel);
ClassDB::bind_method(D_METHOD("get_remainder"), &KinematicCollision2D::get_remainder);
ClassDB::bind_method(D_METHOD("get_angle", "up_direction"), &KinematicCollision2D::get_angle, DEFVAL(Vector2(0.0, -1.0)));
+ ClassDB::bind_method(D_METHOD("get_depth"), &KinematicCollision2D::get_depth);
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);
diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h
index 7401fc7578..c762a832c4 100644
--- a/scene/2d/physics_body_2d.h
+++ b/scene/2d/physics_body_2d.h
@@ -473,6 +473,7 @@ public:
Vector2 get_travel() const;
Vector2 get_remainder() const;
real_t get_angle(const Vector2 &p_up_direction = Vector2(0.0, -1.0)) const;
+ real_t get_depth() const;
Object *get_local_shape() const;
Object *get_collider() const;
ObjectID get_collider_id() const;
diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp
index 993608c306..cbdef02826 100644
--- a/scene/3d/physics_body_3d.cpp
+++ b/scene/3d/physics_body_3d.cpp
@@ -2057,6 +2057,10 @@ int KinematicCollision3D::get_collision_count() const {
return result.collision_count;
}
+real_t KinematicCollision3D::get_depth() const {
+ return result.collision_depth;
+}
+
Vector3 KinematicCollision3D::get_position(int p_collision_index) const {
ERR_FAIL_INDEX_V(p_collision_index, result.collision_count, Vector3());
return result.collisions[p_collision_index].position;
@@ -2127,6 +2131,7 @@ Vector3 KinematicCollision3D::get_collider_velocity(int p_collision_index) const
void KinematicCollision3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_travel"), &KinematicCollision3D::get_travel);
ClassDB::bind_method(D_METHOD("get_remainder"), &KinematicCollision3D::get_remainder);
+ ClassDB::bind_method(D_METHOD("get_depth"), &KinematicCollision3D::get_depth);
ClassDB::bind_method(D_METHOD("get_collision_count"), &KinematicCollision3D::get_collision_count);
ClassDB::bind_method(D_METHOD("get_position", "collision_index"), &KinematicCollision3D::get_position, DEFVAL(0));
ClassDB::bind_method(D_METHOD("get_normal", "collision_index"), &KinematicCollision3D::get_normal, DEFVAL(0));
diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h
index e4a41be6c0..b9baba4d96 100644
--- a/scene/3d/physics_body_3d.h
+++ b/scene/3d/physics_body_3d.h
@@ -504,6 +504,7 @@ public:
Vector3 get_travel() const;
Vector3 get_remainder() const;
int get_collision_count() const;
+ real_t get_depth() const;
Vector3 get_position(int p_collision_index = 0) const;
Vector3 get_normal(int p_collision_index = 0) const;
real_t get_angle(int p_collision_index = 0, const Vector3 &p_up_direction = Vector3(0.0, 1.0, 0.0)) const;