diff options
author | Peter Eastman <peastman@stanford.edu> | 2023-01-14 18:39:23 -0800 |
---|---|---|
committer | Peter Eastman <peastman@stanford.edu> | 2023-01-18 18:24:57 -0800 |
commit | 31c2a2489392991c9870f21092f86df6f8bd9c9c (patch) | |
tree | 8c2e9d19e14c15d92da827649a432ae43831fdc8 /servers/physics_3d/gjk_epa.cpp | |
parent | a51ca2beafc5d74d3e62cb56fbba76ceb39160a3 (diff) |
Analytic collision normals
Diffstat (limited to 'servers/physics_3d/gjk_epa.cpp')
-rw-r--r-- | servers/physics_3d/gjk_epa.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/servers/physics_3d/gjk_epa.cpp b/servers/physics_3d/gjk_epa.cpp index 88f2040d17..e5678914fe 100644 --- a/servers/physics_3d/gjk_epa.cpp +++ b/servers/physics_3d/gjk_epa.cpp @@ -1011,9 +1011,11 @@ bool gjk_epa_calculate_penetration(const GodotShape3D *p_shape_A, const Transfor if (GjkEpa2::Penetration(p_shape_A, p_transform_A, p_margin_A, p_shape_B, p_transform_B, p_margin_B, p_transform_B.origin - p_transform_A.origin, res)) { if (p_result_callback) { if (p_swap) { - p_result_callback(res.witnesses[1], 0, res.witnesses[0], 0, p_userdata); + Vector3 normal = (res.witnesses[1] - res.witnesses[0]).normalized(); + p_result_callback(res.witnesses[1], 0, res.witnesses[0], 0, normal, p_userdata); } else { - p_result_callback(res.witnesses[0], 0, res.witnesses[1], 0, p_userdata); + Vector3 normal = (res.witnesses[0] - res.witnesses[1]).normalized(); + p_result_callback(res.witnesses[0], 0, res.witnesses[1], 0, normal, p_userdata); } } return true; |