From f8c4ffcdde4ac140cd4e26b9a1142b0473fb094c Mon Sep 17 00:00:00 2001 From: Pasi Nuutinmaki Date: Sun, 15 Mar 2020 10:01:28 +0200 Subject: [PATCH] Fix area calculation of Face3 There seemed to be a bug in area calculation in Face3::get_area()-function. It returned the area of "imaginary" parallelogram instead of the triangle. Therefore the area returned was twice the real area. This manifested itself when using a hydro module for godot ( https://gitlab.com/ringtechsolutions/godot-tools/hydro/hydro ) causing the buoyancy to be two times the expected value. "Reference": http://www.maths.usyd.edu.au/u/MOW/vectors/vectors-11/v-11-7.html (cherry picked from commit a165eed73bd9783a07cdec4571a4912df71464ce) --- core/math/face3.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/math/face3.cpp b/core/math/face3.cpp index a7a5e91d51a..674c5068a8c 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -180,8 +180,7 @@ Vector3 Face3::get_median_point() const { } real_t Face3::get_area() const { - - return vec3_cross(vertex[0] - vertex[1], vertex[0] - vertex[2]).length(); + return vec3_cross(vertex[0] - vertex[1], vertex[0] - vertex[2]).length() * 0.5; } ClockDirection Face3::get_clock_dir() const {