|
32 | 32 |
|
33 | 33 | #include "../jolt_physics_server_3d.h" |
34 | 34 | #include "../jolt_project_settings.h" |
| 35 | +#include "../misc/jolt_math_funcs.h" |
35 | 36 | #include "../misc/jolt_type_conversions.h" |
36 | 37 | #include "../objects/jolt_area_3d.h" |
37 | 38 | #include "../objects/jolt_body_3d.h" |
@@ -288,11 +289,10 @@ bool JoltPhysicsDirectSpaceState3D::_body_motion_cast(const JoltBody3D &p_body, |
288 | 289 | const Transform3D transform_com_local = transform_local.translated_local(com_scaled); |
289 | 290 | Transform3D transform_com = body_transform * transform_com_local; |
290 | 291 |
|
291 | | - Vector3 scale = transform_com.basis.get_scale(); |
| 292 | + Vector3 scale; |
| 293 | + JoltMath::decompose(transform_com, scale); |
292 | 294 | JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "body_test_motion was passed an invalid transform along with body '%s'. This results in invalid scaling for shape at index %d."); |
293 | 295 |
|
294 | | - transform_com.basis.orthonormalize(); |
295 | | - |
296 | 296 | real_t shape_safe_fraction = 1.0; |
297 | 297 | real_t shape_unsafe_fraction = 1.0; |
298 | 298 |
|
@@ -590,11 +590,10 @@ int JoltPhysicsDirectSpaceState3D::intersect_shape(const ShapeParameters &p_para |
590 | 590 | Transform3D transform = p_parameters.transform; |
591 | 591 | JOLT_ENSURE_SCALE_NOT_ZERO(transform, "intersect_shape was passed an invalid transform."); |
592 | 592 |
|
593 | | - Vector3 scale = transform.basis.get_scale(); |
| 593 | + Vector3 scale; |
| 594 | + JoltMath::decompose(transform, scale); |
594 | 595 | JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "intersect_shape was passed an invalid transform."); |
595 | 596 |
|
596 | | - transform.basis.orthonormalize(); |
597 | | - |
598 | 597 | const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass()); |
599 | 598 | const Transform3D transform_com = transform.translated_local(com_scaled); |
600 | 599 |
|
@@ -647,11 +646,10 @@ bool JoltPhysicsDirectSpaceState3D::cast_motion(const ShapeParameters &p_paramet |
647 | 646 | Transform3D transform = p_parameters.transform; |
648 | 647 | JOLT_ENSURE_SCALE_NOT_ZERO(transform, "cast_motion (maybe from ShapeCast3D?) was passed an invalid transform."); |
649 | 648 |
|
650 | | - Vector3 scale = transform.basis.get_scale(); |
| 649 | + Vector3 scale; |
| 650 | + JoltMath::decompose(transform, scale); |
651 | 651 | JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "cast_motion (maybe from ShapeCast3D?) was passed an invalid transform."); |
652 | 652 |
|
653 | | - transform.basis.orthonormalize(); |
654 | | - |
655 | 653 | const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass()); |
656 | 654 | Transform3D transform_com = transform.translated_local(com_scaled); |
657 | 655 |
|
@@ -684,11 +682,10 @@ bool JoltPhysicsDirectSpaceState3D::collide_shape(const ShapeParameters &p_param |
684 | 682 | Transform3D transform = p_parameters.transform; |
685 | 683 | JOLT_ENSURE_SCALE_NOT_ZERO(transform, "collide_shape was passed an invalid transform."); |
686 | 684 |
|
687 | | - Vector3 scale = transform.basis.get_scale(); |
| 685 | + Vector3 scale; |
| 686 | + JoltMath::decompose(transform, scale); |
688 | 687 | JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "collide_shape was passed an invalid transform."); |
689 | 688 |
|
690 | | - transform.basis.orthonormalize(); |
691 | | - |
692 | 689 | const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass()); |
693 | 690 | const Transform3D transform_com = transform.translated_local(com_scaled); |
694 | 691 |
|
@@ -754,11 +751,10 @@ bool JoltPhysicsDirectSpaceState3D::rest_info(const ShapeParameters &p_parameter |
754 | 751 | Transform3D transform = p_parameters.transform; |
755 | 752 | JOLT_ENSURE_SCALE_NOT_ZERO(transform, "get_rest_info (maybe from ShapeCast3D?) was passed an invalid transform."); |
756 | 753 |
|
757 | | - Vector3 scale = transform.basis.get_scale(); |
| 754 | + Vector3 scale; |
| 755 | + JoltMath::decompose(transform, scale); |
758 | 756 | JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "get_rest_info (maybe from ShapeCast3D?) was passed an invalid transform."); |
759 | 757 |
|
760 | | - transform.basis.orthonormalize(); |
761 | | - |
762 | 758 | const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass()); |
763 | 759 | const Transform3D transform_com = transform.translated_local(com_scaled); |
764 | 760 |
|
@@ -890,8 +886,8 @@ bool JoltPhysicsDirectSpaceState3D::body_test_motion(const JoltBody3D &p_body, c |
890 | 886 | Transform3D transform = p_parameters.from; |
891 | 887 | JOLT_ENSURE_SCALE_NOT_ZERO(transform, vformat("body_test_motion (maybe from move_and_slide?) was passed an invalid transform along with body '%s'.", p_body.to_string())); |
892 | 888 |
|
893 | | - Vector3 scale = transform.basis.get_scale(); |
894 | | - transform.basis.orthonormalize(); |
| 889 | + Vector3 scale; |
| 890 | + JoltMath::decompose(transform, scale); |
895 | 891 |
|
896 | 892 | space->try_optimize(); |
897 | 893 |
|
|
0 commit comments