1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add VoxelArea::intersect()

This commit is contained in:
sfan5 2023-06-17 18:05:54 +02:00
parent 659828b142
commit 84fb663d6c
2 changed files with 41 additions and 0 deletions

View file

@ -38,6 +38,7 @@ public:
void test_equal();
void test_plus();
void test_minor();
void test_intersect();
void test_index_xyz_all_pos();
void test_index_xyz_x_neg();
void test_index_xyz_y_neg();
@ -74,6 +75,7 @@ void TestVoxelArea::runTests(IGameDef *gamedef)
TEST(test_equal);
TEST(test_plus);
TEST(test_minor);
TEST(test_intersect);
TEST(test_index_xyz_all_pos);
TEST(test_index_xyz_x_neg);
TEST(test_index_xyz_y_neg);
@ -210,6 +212,20 @@ void TestVoxelArea::test_minor()
VoxelArea(v3s16(-10, -10, -45), v3s16(100, 100, 65)));
}
void TestVoxelArea::test_intersect()
{
VoxelArea v1({-10, -10, -10}, {10, 10, 10});
VoxelArea v2({1, 2, 3}, {4, 5, 6});
VoxelArea v3({11, 11, 11}, {11, 11, 11});
VoxelArea v4({-11, -2, -10}, {10, 2, 11});
UASSERT(v2.intersect(v1) == v2);
UASSERT(v1.intersect(v2) == v2.intersect(v1));
UASSERT(v1.intersect(v3).hasEmptyExtent());
UASSERT(v3.intersect(v1) == v1.intersect(v3));
UASSERT(v1.intersect(v4) ==
VoxelArea({-10, -2, -10}, {10, 2, 10}));
}
void TestVoxelArea::test_index_xyz_all_pos()
{
VoxelArea v1;