From 577b6d11965df8d5cc79ff76095eca1b1c3c6a93 Mon Sep 17 00:00:00 2001 From: stoofin <44447892+stoofin@users.noreply.github.com> Date: Tue, 19 Nov 2019 22:30:28 -0800 Subject: [PATCH] Fixed bug caused by a copy/paste error in Face3::get_closest_point_to MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit s * edge0 = -d / a * edge0 = -edge0⋅v0 / (edge0⋅edge0) * edge0 = vector projection of -v0 onto edge0 By incorrectly using -e/c instead of -d/a, Face3::get_closest_point_to was returning the wrong point in certain cases. Specifically, I noticed it returning vertex[0] when it should have been returning vertex[1]. (cherry picked from commit 8abd64dcbbe80e20b23fd526437bd068289f365c) --- core/math/face3.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/math/face3.cpp b/core/math/face3.cpp index ab09142b2d3..666d214f98f 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -393,7 +393,7 @@ Vector3 Face3::get_closest_point_to(const Vector3 &p_point) const { s = CLAMP(numer / denom, 0.f, 1.f); t = 1 - s; } else { - s = CLAMP(-e / c, 0.f, 1.f); + s = CLAMP(-d / a, 0.f, 1.f); t = 0.f; } } else {