|
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"
|
@@ -286,17 +287,17 @@ bool JoltPhysicsDirectSpaceState3D::_body_motion_cast(const JoltBody3D &p_body,
|
286 | 287 | const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass());
|
287 | 288 | const Transform3D transform_local = p_body.get_shape_transform_scaled(i);
|
288 | 289 | const Transform3D transform_com_local = transform_local.translated_local(com_scaled);
|
289 |
| - Transform3D transform_com = body_transform * transform_com_local; |
| 290 | + const Transform3D transform_com = body_transform * transform_com_local; |
290 | 291 |
|
291 |
| - Vector3 scale = transform_com.basis.get_scale(); |
| 292 | + Transform3D transform_com_unscaled; |
| 293 | + Vector3 scale; |
| 294 | + JoltMath::decomposed(transform_com, transform_com_unscaled, scale); |
292 | 295 | 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 | 296 |
|
294 |
| - transform_com.basis.orthonormalize(); |
295 |
| - |
296 | 297 | real_t shape_safe_fraction = 1.0;
|
297 | 298 | real_t shape_unsafe_fraction = 1.0;
|
298 | 299 |
|
299 |
| - collided |= _cast_motion_impl(*jolt_shape, transform_com, scale, p_motion, JoltProjectSettings::use_enhanced_internal_edge_removal_for_motion_queries(), false, settings, motion_filter, motion_filter, motion_filter, motion_filter, shape_safe_fraction, shape_unsafe_fraction); |
| 300 | + collided |= _cast_motion_impl(*jolt_shape, transform_com_unscaled, scale, p_motion, JoltProjectSettings::use_enhanced_internal_edge_removal_for_motion_queries(), false, settings, motion_filter, motion_filter, motion_filter, motion_filter, shape_safe_fraction, shape_unsafe_fraction); |
300 | 301 |
|
301 | 302 | r_safe_fraction = MIN(r_safe_fraction, shape_safe_fraction);
|
302 | 303 | r_unsafe_fraction = MIN(r_unsafe_fraction, shape_unsafe_fraction);
|
@@ -590,11 +591,10 @@ int JoltPhysicsDirectSpaceState3D::intersect_shape(const ShapeParameters &p_para
|
590 | 591 | Transform3D transform = p_parameters.transform;
|
591 | 592 | JOLT_ENSURE_SCALE_NOT_ZERO(transform, "intersect_shape was passed an invalid transform.");
|
592 | 593 |
|
593 |
| - Vector3 scale = transform.basis.get_scale(); |
| 594 | + Vector3 scale; |
| 595 | + JoltMath::decompose(transform, scale); |
594 | 596 | JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "intersect_shape was passed an invalid transform.");
|
595 | 597 |
|
596 |
| - transform.basis.orthonormalize(); |
597 |
| - |
598 | 598 | const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass());
|
599 | 599 | const Transform3D transform_com = transform.translated_local(com_scaled);
|
600 | 600 |
|
@@ -647,11 +647,10 @@ bool JoltPhysicsDirectSpaceState3D::cast_motion(const ShapeParameters &p_paramet
|
647 | 647 | Transform3D transform = p_parameters.transform;
|
648 | 648 | JOLT_ENSURE_SCALE_NOT_ZERO(transform, "cast_motion (maybe from ShapeCast3D?) was passed an invalid transform.");
|
649 | 649 |
|
650 |
| - Vector3 scale = transform.basis.get_scale(); |
| 650 | + Vector3 scale; |
| 651 | + JoltMath::decompose(transform, scale); |
651 | 652 | JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "cast_motion (maybe from ShapeCast3D?) was passed an invalid transform.");
|
652 | 653 |
|
653 |
| - transform.basis.orthonormalize(); |
654 |
| - |
655 | 654 | const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass());
|
656 | 655 | Transform3D transform_com = transform.translated_local(com_scaled);
|
657 | 656 |
|
@@ -684,11 +683,10 @@ bool JoltPhysicsDirectSpaceState3D::collide_shape(const ShapeParameters &p_param
|
684 | 683 | Transform3D transform = p_parameters.transform;
|
685 | 684 | JOLT_ENSURE_SCALE_NOT_ZERO(transform, "collide_shape was passed an invalid transform.");
|
686 | 685 |
|
687 |
| - Vector3 scale = transform.basis.get_scale(); |
| 686 | + Vector3 scale; |
| 687 | + JoltMath::decompose(transform, scale); |
688 | 688 | JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "collide_shape was passed an invalid transform.");
|
689 | 689 |
|
690 |
| - transform.basis.orthonormalize(); |
691 |
| - |
692 | 690 | const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass());
|
693 | 691 | const Transform3D transform_com = transform.translated_local(com_scaled);
|
694 | 692 |
|
@@ -754,11 +752,10 @@ bool JoltPhysicsDirectSpaceState3D::rest_info(const ShapeParameters &p_parameter
|
754 | 752 | Transform3D transform = p_parameters.transform;
|
755 | 753 | JOLT_ENSURE_SCALE_NOT_ZERO(transform, "get_rest_info (maybe from ShapeCast3D?) was passed an invalid transform.");
|
756 | 754 |
|
757 |
| - Vector3 scale = transform.basis.get_scale(); |
| 755 | + Vector3 scale; |
| 756 | + JoltMath::decompose(transform, scale); |
758 | 757 | JOLT_ENSURE_SCALE_VALID(jolt_shape, scale, "get_rest_info (maybe from ShapeCast3D?) was passed an invalid transform.");
|
759 | 758 |
|
760 |
| - transform.basis.orthonormalize(); |
761 |
| - |
762 | 759 | const Vector3 com_scaled = to_godot(jolt_shape->GetCenterOfMass());
|
763 | 760 | const Transform3D transform_com = transform.translated_local(com_scaled);
|
764 | 761 |
|
@@ -890,8 +887,8 @@ bool JoltPhysicsDirectSpaceState3D::body_test_motion(const JoltBody3D &p_body, c
|
890 | 887 | Transform3D transform = p_parameters.from;
|
891 | 888 | 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 | 889 |
|
893 |
| - Vector3 scale = transform.basis.get_scale(); |
894 |
| - transform.basis.orthonormalize(); |
| 890 | + Vector3 scale; |
| 891 | + JoltMath::decompose(transform, scale); |
895 | 892 |
|
896 | 893 | space->try_optimize();
|
897 | 894 |
|
|
0 commit comments