Fix broken negative scaling when using Jolt Physics

This commit is contained in:
Mikael Hermansson
2025-03-01 18:47:49 +01:00
parent 15ff450680
commit 62e8b1e5fd
6 changed files with 155 additions and 26 deletions

View File

@@ -31,6 +31,7 @@
#include "jolt_area_3d.h"
#include "../jolt_project_settings.h"
#include "../misc/jolt_math_funcs.h"
#include "../misc/jolt_type_conversions.h"
#include "../shapes/jolt_shape_3d.h"
#include "../spaces/jolt_broad_phase_layer.h"
@@ -370,7 +371,8 @@ void JoltArea3D::set_default_area(bool p_value) {
void JoltArea3D::set_transform(Transform3D p_transform) {
JOLT_ENSURE_SCALE_NOT_ZERO(p_transform, vformat("An invalid transform was passed to area '%s'.", to_string()));
const Vector3 new_scale = p_transform.basis.get_scale();
Vector3 new_scale;
JoltMath::decompose(p_transform, new_scale);
// Ideally we would do an exact comparison here, but due to floating-point precision this would be invalidated very often.
if (!scale.is_equal_approx(new_scale)) {
@@ -378,8 +380,6 @@ void JoltArea3D::set_transform(Transform3D p_transform) {
_shapes_changed();
}
p_transform.basis.orthonormalize();
if (!in_space()) {
jolt_settings->mPosition = to_jolt_r(p_transform.origin);
jolt_settings->mRotation = to_jolt(p_transform.basis);