@@ -479,11 +479,15 @@ static void _collision_segment_rectangle(const GodotShape2D *p_a, const Transfor
479
479
return ;
480
480
}
481
481
482
- if (!separator.test_axis (p_transform_b.columns [0 ].normalized ())) {
482
+ const Vector2 rect_fn = p_transform_b.columns [0 ].normalized ();
483
+
484
+ if (!separator.test_axis (rect_fn)) {
483
485
return ;
484
486
}
485
487
486
- if (!separator.test_axis (p_transform_b.columns [1 ].normalized ())) {
488
+ const Vector2 nd_rect_fn = Vector2 (-rect_fn[1 ], rect_fn[0 ]);
489
+
490
+ if (!separator.test_axis (nd_rect_fn)) {
487
491
return ;
488
492
}
489
493
@@ -652,11 +656,14 @@ static void _collision_circle_rectangle(const GodotShape2D *p_a, const Transform
652
656
const Vector2 *axis = &p_transform_b.columns [0 ];
653
657
// const Vector2& half_extents = rectangle_B->get_half_extents();
654
658
655
- if (!separator.test_axis (axis[0 ].normalized ())) {
659
+ const Vector2 rect_fn = axis[0 ].normalized ();
660
+ if (!separator.test_axis (rect_fn)) {
656
661
return ;
657
662
}
658
663
659
- if (!separator.test_axis (axis[1 ].normalized ())) {
664
+ const Vector2 nd_rect_fn = Vector2 (-rect_fn[1 ], rect_fn[0 ]);
665
+
666
+ if (!separator.test_axis (nd_rect_fn)) {
660
667
return ;
661
668
}
662
669
@@ -770,21 +777,31 @@ static void _collision_rectangle_rectangle(const GodotShape2D *p_a, const Transf
770
777
return ;
771
778
}
772
779
780
+ // It's the same normal for both axis tests,
781
+ // but the second one is just inverted and has the x as inverse.
782
+ const Vector2 rect_fn = p_transform_a.columns [0 ].normalized ();
783
+
773
784
// box faces A
774
- if (!separator.test_axis (p_transform_a. columns [ 0 ]. normalized () )) {
785
+ if (!separator.test_axis (rect_fn )) {
775
786
return ;
776
787
}
777
788
778
- if (!separator.test_axis (p_transform_a.columns [1 ].normalized ())) {
789
+ const Vector2 nd_rect_fn = Vector2 (-rect_fn[1 ], rect_fn[0 ]);
790
+
791
+ if (!separator.test_axis (nd_rect_fn)) {
779
792
return ;
780
793
}
781
794
795
+ const Vector2 rect_fn2 = p_transform_b.columns [0 ].normalized ();
796
+
782
797
// box faces B
783
- if (!separator.test_axis (p_transform_b. columns [ 0 ]. normalized () )) {
798
+ if (!separator.test_axis (rect_fn2 )) {
784
799
return ;
785
800
}
786
801
787
- if (!separator.test_axis (p_transform_b.columns [1 ].normalized ())) {
802
+ const Vector2 nd_rect_fn2 = Vector2 (-rect_fn2[1 ], rect_fn2[0 ]);
803
+
804
+ if (!separator.test_axis (nd_rect_fn2)) {
788
805
return ;
789
806
}
790
807
@@ -844,12 +861,18 @@ static void _collision_rectangle_capsule(const GodotShape2D *p_a, const Transfor
844
861
return ;
845
862
}
846
863
864
+ // It's the same normal for both axis tests,
865
+ // but the second one is just inverted and has the x as inverse.
866
+ const Vector2 rect_fn = p_transform_a.columns [0 ].normalized ();
867
+
847
868
// box faces
848
- if (!separator.test_axis (p_transform_a. columns [ 0 ]. normalized () )) {
869
+ if (!separator.test_axis (rect_fn )) {
849
870
return ;
850
871
}
851
872
852
- if (!separator.test_axis (p_transform_a.columns [1 ].normalized ())) {
873
+ const Vector2 nd_rect_fn = Vector2 (-rect_fn[1 ], rect_fn[0 ]);
874
+
875
+ if (!separator.test_axis (nd_rect_fn)) {
853
876
return ;
854
877
}
855
878
@@ -922,12 +945,18 @@ static void _collision_rectangle_convex_polygon(const GodotShape2D *p_a, const T
922
945
return ;
923
946
}
924
947
948
+ // It's the same normal for both axis tests,
949
+ // but the second one is just inverted and has the x as inverse.
950
+ const Vector2 rect_fn = p_transform_a.columns [0 ].normalized ();
951
+
925
952
// box faces
926
- if (!separator.test_axis (p_transform_a. columns [ 0 ]. normalized () )) {
953
+ if (!separator.test_axis (rect_fn )) {
927
954
return ;
928
955
}
929
956
930
- if (!separator.test_axis (p_transform_a.columns [1 ].normalized ())) {
957
+ const Vector2 nd_rect_fn = Vector2 (-rect_fn[1 ], rect_fn[0 ]);
958
+
959
+ if (!separator.test_axis (nd_rect_fn)) {
931
960
return ;
932
961
}
933
962
0 commit comments