@@ -755,8 +755,7 @@ TEST_F(LinkIntegrationTest, AxisAlignedBoxInLink)
755
755
756
756
// LinkA - bounding box from collisions
757
757
gz::sim::Link linkA (eLinkA);
758
- linkA.EnableBoundingBoxChecks (ecm);
759
- auto aabb = linkA.AxisAlignedBox (ecm);
758
+ auto aabb = linkA.ComputeAxisAlignedBox (ecm);
760
759
761
760
EXPECT_TRUE (aabb.has_value ());
762
761
EXPECT_EQ (-5.0 , aabb->Min ().X ());
@@ -766,12 +765,20 @@ TEST_F(LinkIntegrationTest, AxisAlignedBoxInLink)
766
765
EXPECT_EQ (4.0 , aabb->Max ().Y ());
767
766
EXPECT_EQ (2.0 , aabb->Max ().Z ());
768
767
768
+ // By default, the bounding box checks are disabled.
769
+ // Once enabled, the result must match the computed AABB.
770
+ EXPECT_EQ (std::nullopt, linkA.AxisAlignedBox (ecm));
771
+ linkA.EnableBoundingBoxChecks (ecm);
772
+ EXPECT_EQ (aabb, linkA.AxisAlignedBox (ecm));
773
+
769
774
// If ECM is updated with new link AABB, the ECM value is returned
775
+ // instead of recomputing the AABB from the collisions
770
776
math::AxisAlignedBox newAabb (-math::Vector3d::One, math::Vector3d::One);
771
777
ecm.SetComponentData <components::AxisAlignedBox>(eLinkA, newAabb);
778
+ EXPECT_NE (newAabb, aabb.value ());
772
779
EXPECT_EQ (newAabb, linkA.AxisAlignedBox (ecm));
773
780
774
- // If the bounding box checks are disabled and then enabled again , the
781
+ // If the bounding box checks are disabled and then re- enabled, the
775
782
// bounding box should be recalculated from the collisions
776
783
linkA.EnableBoundingBoxChecks (ecm, false );
777
784
EXPECT_EQ (std::nullopt, linkA.AxisAlignedBox (ecm));
@@ -805,8 +812,7 @@ TEST_F(LinkIntegrationTest, AxisAlignedBoxInLink)
805
812
806
813
// LinkB - bounding box from collisions
807
814
gz::sim::Link linkB (eLinkB);
808
- linkB.EnableBoundingBoxChecks (ecm);
809
- aabb = linkB.AxisAlignedBox (ecm);
815
+ aabb = linkB.ComputeAxisAlignedBox (ecm);
810
816
811
817
EXPECT_TRUE (aabb.has_value ());
812
818
EXPECT_EQ (-1.5 , aabb->Min ().X ());
@@ -824,6 +830,7 @@ TEST_F(LinkIntegrationTest, AxisAlignedBoxInLink)
824
830
// LinkC - No collisions (AABB should be invalid if checks are enabled)
825
831
gz::sim::Link linkC (eLinkC);
826
832
EXPECT_EQ (std::nullopt, linkC.AxisAlignedBox (ecm));
833
+ EXPECT_EQ (std::nullopt, linkC.ComputeAxisAlignedBox (ecm));
827
834
linkC.EnableBoundingBoxChecks (ecm);
828
835
EXPECT_EQ (math::AxisAlignedBox (), linkC.AxisAlignedBox (ecm));
829
836
@@ -844,6 +851,7 @@ TEST_F(LinkIntegrationTest, AxisAlignedBoxInLink)
844
851
linkC = gz::sim::Link (eLinkC);
845
852
linkC.EnableBoundingBoxChecks (ecm, false );
846
853
EXPECT_EQ (std::nullopt, linkC.AxisAlignedBox (ecm));
854
+ EXPECT_EQ (math::AxisAlignedBox (), linkC.ComputeAxisAlignedBox (ecm));
847
855
linkC.EnableBoundingBoxChecks (ecm);
848
856
EXPECT_EQ (math::AxisAlignedBox (), linkC.AxisAlignedBox (ecm));
849
857
@@ -858,10 +866,7 @@ TEST_F(LinkIntegrationTest, AxisAlignedBoxInLink)
858
866
// LinkC - Invalid mesh will be skiped with warning, bounding
859
867
// box will be defined for the valid mesh only
860
868
linkC = gz::sim::Link (eLinkC);
861
- linkC.EnableBoundingBoxChecks (ecm, false );
862
- EXPECT_EQ (std::nullopt, linkC.AxisAlignedBox (ecm));
863
- linkC.EnableBoundingBoxChecks (ecm);
864
- aabb = linkC.AxisAlignedBox (ecm);
869
+ aabb = linkC.ComputeAxisAlignedBox (ecm);
865
870
866
871
EXPECT_TRUE (aabb.has_value ());
867
872
EXPECT_EQ (-0.5 , aabb->Min ().X ());
@@ -878,10 +883,7 @@ TEST_F(LinkIntegrationTest, AxisAlignedBoxInLink)
878
883
creator.SetParent (eCollisions[0 ], eLinkB);
879
884
880
885
linkC = gz::sim::Link (eLinkC);
881
- linkC.EnableBoundingBoxChecks (ecm, false );
882
- EXPECT_EQ (std::nullopt, linkC.AxisAlignedBox (ecm));
883
- linkC.EnableBoundingBoxChecks (ecm);
884
- aabb = linkC.AxisAlignedBox (ecm);
886
+ aabb = linkC.ComputeAxisAlignedBox (ecm);
885
887
886
888
EXPECT_TRUE (aabb.has_value ());
887
889
EXPECT_EQ (-0.5 , aabb->Min ().X ());
0 commit comments