#include "../Tests.hpp" #include "core/math/Box.hpp" static void testInit() { Core::Box box(Core::Vector3(1.0f, 2.0f, 3.0f)); CORE_TEST_STRING("Box([0.00, 0.00, 0.00], [1.00, 2.00, 3.00])", box); CORE_TEST_STRING("[0.00, 0.00, 0.00]", box.getMin()); CORE_TEST_STRING("[1.00, 2.00, 3.00]", box.getMax()); box = Core::Box(Core::Vector3(-1.0f, -2.0f, -3.0f)); CORE_TEST_STRING("Box([-1.00, -2.00, -3.00], [0.00, 0.00, 0.00])", box); CORE_TEST_STRING("[-1.00, -2.00, -3.00]", box.getMin()); CORE_TEST_STRING("[0.00, 0.00, 0.00]", box.getMax()); } static void testOffset() { Core::Box box(Core::Vector3(1.0f, 2.0f, 3.0f)); CORE_TEST_STRING("Box([7.00, -4.00, 6.00], [8.00, -2.00, 9.00])", box.offset(Core::Vector3(7.0f, -4.0f, 6.0f))); } static void testCollidesWith() { Core::Box boxA(Core::Vector3(1.0f, 2.0f, 3.0f)); Core::Box boxB(Core::Vector3(-1.0f, -2.0f, -3.0f)); Core::Box boxC(Core::Vector3(2.0f, 2.0f, 2.0f)); boxC = boxC.offset(Core::Vector3(-1.0f, -1.0f, -1.0f)); CORE_TEST_TRUE(boxC.collidesWith(boxA)); CORE_TEST_TRUE(boxC.collidesWith(boxB)); CORE_TEST_TRUE(boxA.collidesWith(boxC)); CORE_TEST_TRUE(boxB.collidesWith(boxC)); CORE_TEST_FALSE(boxA.collidesWith(boxB)); CORE_TEST_FALSE(boxB.collidesWith(boxA)); } static void testExpand() { Core::Box box(Core::Vector3(1.0f, 2.0f, 3.0f)); CORE_TEST_STRING("Box([0.00, -4.00, 0.00], [8.00, 2.00, 9.00])", box.expand(Core::Vector3(7.0f, -4.0f, 6.0f))); CORE_TEST_STRING("Box([-7.00, 0.00, -6.00], [1.00, 6.00, 3.00])", box.expand(Core::Vector3(-7.0f, 4.0f, -6.0f))); } static void testGrow() { Core::Box box(Core::Vector3(1.0f, 2.0f, 3.0f)); CORE_TEST_STRING("Box([-2.00, -1.00, -3.00], [3.00, 3.00, 6.00])", box.grow(Core::Vector3(4.0f, 2.0f, 6.0f))); CORE_TEST_STRING("Box([0.50, 1.00, 1.50], [0.50, 1.00, 1.50])", box.grow(Core::Vector3(-4.0f, -2.0f, -6.0f))); CORE_TEST_STRING("Box([0.05, 1.00, 0.50], [0.95, 1.00, 2.50])", box.grow(Core::Vector3(-0.1f, -4.0f, -1.0f))); } void Core::testBox() { testInit(); testOffset(); testCollidesWith(); testExpand(); testGrow(); }