diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-11-26 13:51:33 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-11-26 14:14:13 +0000 |
commit | 7fba471728f2216d7e3b7900297fc3b3531e286c (patch) | |
tree | 5caef3b2efc23aefccb215ec9005cd8e7d2e91b8 /test | |
parent | Fix todo for handling a terrain walk from outside the mesh (diff) | |
parent | Model positions as integers (diff) | |
download | ilt-7fba471728f2216d7e3b7900297fc3b3531e286c.tar.bz2 ilt-7fba471728f2216d7e3b7900297fc3b3531e286c.tar.xz ilt-7fba471728f2216d7e3b7900297fc3b3531e286c.zip |
Merge branch 'ints' into terrain
Conflicts fix, compiles, some test failures remain.
Trees not added, possibility of OM invalid handle assertion failures,
normals broken due to integer overflow in Newell's method.
Diffstat (limited to 'test')
-rw-r--r-- | test/perf-geoData.cpp | 6 | ||||
-rw-r--r-- | test/test-assetFactory.cpp | 21 | ||||
-rw-r--r-- | test/test-geoData.cpp | 122 | ||||
-rw-r--r-- | test/test-glContextBhvr.cpp | 2 | ||||
-rw-r--r-- | test/test-maths.cpp | 12 | ||||
-rw-r--r-- | test/test-render.cpp | 26 | ||||
-rw-r--r-- | test/testRenderOutput.cpp | 2 | ||||
-rw-r--r-- | test/testRenderOutput.h | 7 | ||||
-rw-r--r-- | test/testStructures.h | 5 |
9 files changed, 105 insertions, 98 deletions
diff --git a/test/perf-geoData.cpp b/test/perf-geoData.cpp index 4fed632..4d4505e 100644 --- a/test/perf-geoData.cpp +++ b/test/perf-geoData.cpp @@ -8,17 +8,17 @@ namespace { terrain_findPoint(benchmark::State & state) { for (auto _ : state) { - benchmark::DoNotOptimize(tm.findPoint({315555, 495556})); + benchmark::DoNotOptimize(tm.findPoint({315555000, 495556000})); } } void terrain_walk(benchmark::State & state) { - const glm::vec2 point {310001, 490000}; + const glm::vec2 point {310001000, 490000000}; const GeoData::PointFace start {point, tm.findPoint(point)}; for (auto _ : state) { - tm.walk(start, {319999, 500000}, [](auto f) { + tm.walk(start, {319999000, 500000000}, [](auto f) { benchmark::DoNotOptimize(f); }); } diff --git a/test/test-assetFactory.cpp b/test/test-assetFactory.cpp index 145481e..c8183df 100644 --- a/test/test-assetFactory.cpp +++ b/test/test-assetFactory.cpp @@ -25,7 +25,7 @@ BOOST_GLOBAL_FIXTURE(TestMainWindow); const std::filesystem::path TMP {"/tmp"}; -class FactoryFixture : public TestRenderOutputSize<glm::ivec2 {2048, 1024}>, public SceneProvider { +class FactoryFixture : public TestRenderOutputSize<TextureAbsCoord {2048, 1024}>, public SceneProvider { public: FactoryFixture() : sceneRenderer {size, output} { } @@ -64,7 +64,7 @@ public: } void - render(float dist = 10.f) + render(float dist) { sceneRenderer.camera.setView({-dist, dist * 1.2f, dist * 1.2f}, south + east + down); sceneRenderer.render(*this); @@ -104,7 +104,7 @@ BOOST_AUTO_TEST_CASE(brush47xml, *boost::unit_test::timeout(5)) auto railVehicle = std::make_shared<RailVehicle>(brush47rvc); objects.objects.push_back(brush47rvc); - render(); + render(10000); } BOOST_AUTO_TEST_CASE(foliage, *boost::unit_test::timeout(5)) @@ -116,13 +116,13 @@ BOOST_AUTO_TEST_CASE(foliage, *boost::unit_test::timeout(5)) auto tree_01_1_f = std::dynamic_pointer_cast<Foliage>(tree_01_1); BOOST_REQUIRE(tree_01_1_f); - auto plant1 = std::make_shared<Plant>(tree_01_1_f, Location {{-2, 2, 0}, {0, 0, 0}}); - auto plant2 = std::make_shared<Plant>(tree_01_1_f, Location {{3, -4, 0}, {0, 1, 0}}); - auto plant3 = std::make_shared<Plant>(tree_01_1_f, Location {{-2, -4, 0}, {0, 2, 0}}); - auto plant4 = std::make_shared<Plant>(tree_01_1_f, Location {{3, 2, 0}, {0, 3, 0}}); + auto plant1 = std::make_shared<Plant>(tree_01_1_f, Location {{-2000, 2000, 0}, {0, 0, 0}}); + auto plant2 = std::make_shared<Plant>(tree_01_1_f, Location {{3000, -4000, 0}, {0, 1, 0}}); + auto plant3 = std::make_shared<Plant>(tree_01_1_f, Location {{-2000, -4000, 0}, {0, 2, 0}}); + auto plant4 = std::make_shared<Plant>(tree_01_1_f, Location {{3000, 2000, 0}, {0, 3, 0}}); objects.objects.push_back(tree_01_1_f); - render(5); + render(6000); } BOOST_AUTO_TEST_SUITE_END(); @@ -183,14 +183,15 @@ BOOST_AUTO_TEST_CASE(texturePacker_many, *boost::unit_test::timeout(5)) { std::vector<TexturePacker::Image> images(256); std::fill(images.begin(), images.end(), TexturePacker::Image {32, 32}); - const auto totalSize = std::accumulate(images.begin(), images.end(), 0U, [](auto t, const auto & i) { + const auto totalSize = std::accumulate(images.begin(), images.end(), 0, [](auto t, const auto & i) { return t + TexturePacker::area(i); }); TexturePacker tp {images}; BOOST_CHECK_EQUAL(TexturePacker::Size(32, 32), tp.minSize()); const auto result = tp.pack(); BOOST_CHECK_EQUAL(result.first.size(), images.size()); - BOOST_CHECK_GE(TexturePacker::area(result.second), TexturePacker::area(images.front()) * images.size()); + BOOST_CHECK_GE(TexturePacker::area(result.second), + TexturePacker::area(images.front()) * static_cast<GLsizei>(images.size())); BOOST_CHECK_EQUAL(totalSize, TexturePacker::area(result.second)); } diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp index 447ab37..4e85f73 100644 --- a/test/test-geoData.cpp +++ b/test/test-geoData.cpp @@ -11,7 +11,7 @@ public: TestTerrainMesh() : GeoData {GeoData::loadFromAsciiGrid(FIXTURESDIR "height/SD19.asc")} { } }; -constexpr size_t ncols = 200, nrows = 200, xllcorner = 310000, yllcorner = 490000, cellsize = 50; +constexpr size_t ncols = 200, nrows = 200, xllcorner = 310000000, yllcorner = 490000000, cellsize = 50000; BOOST_FIXTURE_TEST_SUITE(ttm, TestTerrainMesh); @@ -20,18 +20,22 @@ BOOST_AUTO_TEST_CASE(loadSuccess) BOOST_CHECK_EQUAL(ncols * nrows, n_vertices()); BOOST_CHECK_EQUAL(2 * (ncols - 1) * (nrows - 1), n_faces()); const auto [lower, upper] = getExtents(); - BOOST_CHECK_EQUAL(lower, glm::vec3(310000, 490000, -2.6)); - BOOST_CHECK_EQUAL(upper, glm::vec3(319950, 499950, 571.6)); + BOOST_CHECK_EQUAL(lower, GlobalPosition3D(310000000, 490000000, -2600)); + BOOST_CHECK_EQUAL(upper, GlobalPosition3D(319950000, 499950000, 571600)); } BOOST_AUTO_TEST_CASE(normalsAllPointUp) { - BOOST_CHECK(std::all_of(faces_begin(), faces_end(), [this](auto && vh) { - return normal(vh).z > 0; - })); - BOOST_CHECK(std::all_of(vertices_begin(), vertices_end(), [this](auto && vh) { - return normal(vh).z > 0; - })); + BOOST_CHECK_EQUAL(std::count_if(faces_begin(), faces_end(), + [this](auto && vh) { + return normal(vh).z > 0; + }), + n_faces()); + BOOST_CHECK_EQUAL(std::count_if(vertices_begin(), vertices_end(), + [this](auto && vh) { + return normal(vh).z > 0; + }), + n_vertices()); } BOOST_AUTO_TEST_CASE(trianglesContainsPoints) @@ -39,13 +43,13 @@ BOOST_AUTO_TEST_CASE(trianglesContainsPoints) const auto face = face_handle(0); BOOST_TEST_CONTEXT(GeoData::Triangle<2>(this, fv_range(face))) { - BOOST_CHECK(triangleContainsPoint(glm::vec2 {xllcorner, yllcorner}, face)); - BOOST_CHECK(triangleContainsPoint(glm::vec2 {xllcorner + cellsize, yllcorner + cellsize}, face)); - BOOST_CHECK(triangleContainsPoint(glm::vec2 {xllcorner, yllcorner + cellsize}, face)); - BOOST_CHECK(triangleContainsPoint(glm::vec2 {xllcorner + 1, yllcorner + 1}, face)); - BOOST_CHECK(triangleContainsPoint(glm::vec2 {xllcorner + 1, yllcorner + 2}, face)); - BOOST_CHECK(!triangleContainsPoint(glm::vec2 {xllcorner + 3, yllcorner + 2}, face)); - BOOST_CHECK(!triangleContainsPoint(glm::vec2 {xllcorner + cellsize, yllcorner}, face)); + BOOST_CHECK(triangleContainsPoint(GlobalPosition2D {xllcorner, yllcorner}, face)); + BOOST_CHECK(triangleContainsPoint(GlobalPosition2D {xllcorner + cellsize, yllcorner + cellsize}, face)); + BOOST_CHECK(triangleContainsPoint(GlobalPosition2D {xllcorner, yllcorner + cellsize}, face)); + BOOST_CHECK(triangleContainsPoint(GlobalPosition2D {xllcorner + 1, yllcorner + 1}, face)); + BOOST_CHECK(triangleContainsPoint(GlobalPosition2D {xllcorner + 1, yllcorner + 2}, face)); + BOOST_CHECK(!triangleContainsPoint(GlobalPosition2D {xllcorner + 3, yllcorner + 2}, face)); + BOOST_CHECK(!triangleContainsPoint(GlobalPosition2D {xllcorner + cellsize, yllcorner}, face)); } } @@ -55,7 +59,7 @@ static const TestTerrainMesh fixedTerrtain; BOOST_AUTO_TEST_CASE(locatePointFace) { - const GeoData::PointFace pf {{310002, 490003}}; + const GeoData::PointFace pf {{310002000, 490003000}}; BOOST_CHECK(!pf.isLocated()); BOOST_CHECK(pf.face(&fixedTerrtain).is_valid()); BOOST_CHECK_EQUAL(pf.face(&fixedTerrtain).idx(), 0); @@ -63,19 +67,19 @@ BOOST_AUTO_TEST_CASE(locatePointFace) BOOST_AUTO_TEST_CASE(preLocatePointFace) { - const GeoData::PointFace pf {{310002, 490003}, &fixedTerrtain}; + const GeoData::PointFace pf {{310002000, 490003000}, &fixedTerrtain}; BOOST_CHECK(pf.isLocated()); BOOST_CHECK_EQUAL(pf.face(&fixedTerrtain).idx(), 0); } -using FindPointData = std::tuple<glm::vec2, int>; +using FindPointData = std::tuple<GlobalPosition2D, int>; // No boundary cases as these can produce different valid results depending on starting point BOOST_DATA_TEST_CASE(findPointOnTerrain, boost::unit_test::data::make<FindPointData>({ {{0, 0}, -1}, {{xllcorner, 0}, -1}, {{0, yllcorner}, -1}, {{xllcorner + 1, yllcorner + 2}, 0}, {{xllcorner + (cellsize * (nrows - 1)) - 2, yllcorner + (cellsize * (ncols - 1)) - 1}, 79200}, - {{315555, 495556}, 44400}, // perf test target + {{315555000, 495556000}, 44400}, // perf test target }) * boost::unit_test::data::make<int>( {0, 1, 2, 3, 4, 5, 6, 10, 100, 150, 200, 1000, 1234, 17439, 79201, 79200, 79199}), @@ -84,38 +88,38 @@ BOOST_DATA_TEST_CASE(findPointOnTerrain, BOOST_CHECK_EQUAL(fh, fixedTerrtain.findPoint(p, GeoData::FaceHandle(start)).idx()); } -using FindPositionData = std::tuple<glm::vec2, float>; +using FindPositionData = std::tuple<GlobalPosition2D, GlobalDistance>; BOOST_DATA_TEST_CASE(findPositionAt, boost::unit_test::data::make<FindPositionData>({ // corners - {{310000, 490000}, 32.8F}, - {{310050, 490050}, 33.0F}, - {{310000, 490050}, 32.7F}, - {{310050, 490000}, 33.2F}, - {{310750, 490150}, 58.4F}, + {{310000000, 490000000}, 32800}, + {{310050000, 490050000}, 33000}, + {{310000000, 490050000}, 32700}, + {{310050000, 490000000}, 33200}, + {{310750000, 490150000}, 58399}, // midpoints - {{310025, 490025}, 32.9F}, - {{310025, 490050}, 32.85F}, - {{310000, 490025}, 32.75F}, + {{310025000, 490025000}, 32900}, + {{310025000, 490050000}, 32850}, + {{310000000, 490025000}, 32750}, // other - {{310751, 490152}, 58.326F}, + {{310751000, 490152000}, 58326}, }), p, h) { - BOOST_CHECK_CLOSE_VEC(fixedTerrtain.positionAt(p), p ^ h); + BOOST_CHECK_EQUAL(fixedTerrtain.positionAt(p), GlobalPosition3D(p, h)); } -using FindRayIntersectData = std::tuple<glm::vec3, glm::vec3, glm::vec3>; +using FindRayIntersectData = std::tuple<GlobalPosition3D, Direction3D, GlobalPosition3D>; BOOST_DATA_TEST_CASE(findRayIntersect, boost::unit_test::data::make<FindRayIntersectData>({ - {{310000, 490000, 50}, {1, 1, -2}, {310008.59, 490008.59, 32.834301}}, - {{310000, 490000, 50}, {1, 1, -1}, {310017.12, 490017.12, 32.868526}}, + {{310000000, 490000000, 50000}, {1, 1, -2}, {310008585, 490008585, 32834}}, + {{310000000, 490000000, 50000}, {1, 1, -1}, {310017136, 490017136, 32868}}, }), p, d, i) { - BOOST_CHECK_CLOSE_VEC(fixedTerrtain.intersectRay({p, d}).value(), i); + BOOST_CHECK_EQUAL(fixedTerrtain.intersectRay({p, d}).value(), i); } BOOST_AUTO_TEST_CASE(boundaryWalk) @@ -128,22 +132,22 @@ BOOST_AUTO_TEST_CASE(boundaryWalk) BOOST_CHECK_EQUAL(count, 2 * (ncols + nrows - 2)); } -using WalkTerrainData = std::tuple<glm::vec2, glm::vec2, std::vector<int>>; +using WalkTerrainData = std::tuple<GlobalPosition2D, GlobalPosition2D, std::vector<int>>; BOOST_DATA_TEST_CASE(walkTerrain, boost::unit_test::data::make<WalkTerrainData>({ - {{310002, 490003}, {310002, 490003}, {0}}, - {{310003, 490002}, {310003, 490002}, {1}}, - {{310002, 490003}, {310003, 490002}, {0, 1}}, - {{310003, 490002}, {310002, 490003}, {1, 0}}, - {{310002, 490003}, {310202, 490003}, {0, 1, 2, 3, 4, 5, 6, 7, 8}}, - {{310202, 490003}, {310002, 490003}, {8, 7, 6, 5, 4, 3, 2, 1, 0}}, - {{310002, 490003}, {310002, 490203}, {0, 399, 398, 797, 796, 1195, 1194, 1593, 1592}}, - {{310002, 490003}, {309999, 489999}, {0}}, - {{309999, 489999}, {310002, 490003}, {0}}, - {{320002, 500003}, {319949, 499948}, {79201}}, - {{309999, 490003}, {310004, 489997}, {0, 1}}, - {{310004, 489997}, {309999, 490003}, {1, 0}}, + {{310002000, 490003000}, {310002000, 490003000}, {0}}, + {{310003000, 490002000}, {310003000, 490002000}, {1}}, + {{310002000, 490003000}, {310003000, 490002000}, {0, 1}}, + {{310003000, 490002000}, {310002000, 490003000}, {1, 0}}, + {{310002000, 490003000}, {310202000, 490003000}, {0, 1, 2, 3, 4, 5, 6, 7, 8}}, + {{310202000, 490003000}, {310002000, 490003000}, {8, 7, 6, 5, 4, 3, 2, 1, 0}}, + {{310002000, 490003000}, {310002000, 490203000}, {0, 399, 398, 797, 796, 1195, 1194, 1593, 1592}}, + {{310002000, 490003000}, {309999000, 489999000}, {0}}, + {{309999000, 489999000}, {310002000, 490003000}, {0}}, + {{320002000, 500003000}, {319949000, 499948000}, {79201}}, + {{309999000, 490003000}, {310004000, 489997000}, {0, 1}}, + {{310004000, 489997000}, {309999000, 490003000}, {1, 0}}, }), from, to, visits) { @@ -156,10 +160,10 @@ BOOST_DATA_TEST_CASE(walkTerrain, BOOST_DATA_TEST_CASE(walkTerrainSetsFromFace, boost::unit_test::data::make<WalkTerrainData>({ - {{310002, 490003}, {310002, 490003}, {0}}, - {{310003, 490002}, {310003, 490002}, {1}}, - {{310002, 490003}, {310003, 490002}, {0, 1}}, - {{310003, 490002}, {310002, 490003}, {1, 0}}, + {{310002000, 490003000}, {310002000, 490003000}, {0}}, + {{310003000, 490002000}, {310003000, 490002000}, {1}}, + {{310002000, 490003000}, {310003000, 490002000}, {0, 1}}, + {{310003000, 490002000}, {310002000, 490003000}, {1, 0}}, }), from, to, visits) { @@ -170,13 +174,13 @@ BOOST_DATA_TEST_CASE(walkTerrainSetsFromFace, BOOST_DATA_TEST_CASE(walkTerrainUntil, boost::unit_test::data::make<WalkTerrainData>({ - {{310002, 490003}, {310002, 490003}, {0}}, - {{310003, 490002}, {310003, 490002}, {1}}, - {{310002, 490003}, {310003, 490002}, {0, 1}}, - {{310003, 490002}, {310002, 490003}, {1, 0}}, - {{310002, 490003}, {310202, 490003}, {0, 1, 2, 3, 4}}, - {{310202, 490003}, {310002, 490003}, {8, 7, 6, 5, 4}}, - {{310002, 490003}, {310002, 490203}, {0, 399, 398, 797, 796}}, + {{310002000, 490003000}, {310002000, 490003000}, {0}}, + {{310003000, 490002000}, {310003000, 490002000}, {1}}, + {{310002000, 490003000}, {310003000, 490002000}, {0, 1}}, + {{310003000, 490002000}, {310002000, 490003000}, {1, 0}}, + {{310002000, 490003000}, {310202000, 490003000}, {0, 1, 2, 3, 4}}, + {{310202000, 490003000}, {310002000, 490003000}, {8, 7, 6, 5, 4}}, + {{310002000, 490003000}, {310002000, 490203000}, {0, 399, 398, 797, 796}}, }), from, to, visits) { diff --git a/test/test-glContextBhvr.cpp b/test/test-glContextBhvr.cpp index 2f71aec..26b45d9 100644 --- a/test/test-glContextBhvr.cpp +++ b/test/test-glContextBhvr.cpp @@ -31,7 +31,7 @@ BOOST_AUTO_TEST_CASE(windowContextThingsBehaviour1) const SDL_GLContextPtr context {window}; BOOST_REQUIRE(context); BOOST_REQUIRE(!glCreateProgram); - BOOST_REQUIRE_EQUAL(gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress)), 40006); + BOOST_REQUIRE_GT(gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress)), 0); BOOST_REQUIRE(glCreateProgram); CreateProgramTest(); } // Context destroyed diff --git a/test/test-maths.cpp b/test/test-maths.cpp index 2560319..9eae918 100644 --- a/test/test-maths.cpp +++ b/test/test-maths.cpp @@ -196,12 +196,12 @@ BOOST_DATA_TEST_CASE(straight1, const TestLinkStraight l(v); { const auto p = l.positionAt(0, 0); - BOOST_CHECK_EQUAL(p.pos, origin); + BOOST_CHECK_EQUAL(p.pos, GlobalPosition3D {origin}); BOOST_CHECK_EQUAL(p.rot, glm::vec3(0, angFor, 0)); } { const auto p = l.positionAt(0, 1); - BOOST_CHECK_EQUAL(p.pos, v); + BOOST_CHECK_EQUAL(p.pos, GlobalPosition3D {v}); BOOST_CHECK_EQUAL(p.rot, glm::vec3(0, angBack, 0)); } } @@ -231,12 +231,12 @@ BOOST_DATA_TEST_CASE(curve1, BOOST_CHECK_EQUAL(l.radius, 1.F); { const auto p = l.positionAt(0, 0); - BOOST_CHECK_CLOSE_VEC(p.pos, origin); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, origin); BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angFor, 0)); } { const auto p = l.positionAt(0, 1); - BOOST_CHECK_CLOSE_VEC(p.pos, e1); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, e1); BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angBack, 0)); } } @@ -247,13 +247,13 @@ BOOST_DATA_TEST_CASE(curve1, { const auto p = l.positionAt(0, 0); const auto angForReversed = normalize(vector_yaw(origin - e1) * 2 - angFor); - BOOST_CHECK_CLOSE_VEC(p.pos, e1); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, e1); BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angForReversed, 0)); } { const auto p = l.positionAt(0, 1); const auto angBackReversed = normalize(vector_yaw(e1 - origin) * 2 - angBack); - BOOST_CHECK_CLOSE_VEC(p.pos, origin); + BOOST_CHECK_CLOSE_VEC(RelativePosition3D {p.pos}, origin); BOOST_CHECK_CLOSE_VEC(p.rot, glm::vec3(0, angBackReversed, 0)); } } diff --git a/test/test-render.cpp b/test/test-render.cpp index fb2a71b..f15e51e 100644 --- a/test/test-render.cpp +++ b/test/test-render.cpp @@ -26,7 +26,7 @@ class TestScene : public SceneProvider { std::shared_ptr<RailVehicle> train1, train2; Terrain terrain {[]() { - auto gd = std::make_shared<GeoData>(GeoData::createFlat({0, 0}, {1000, 1000}, 1)); + auto gd = std::make_shared<GeoData>(GeoData::createFlat({0, 0}, {1000000, 1000000}, 1)); return gd; }()}; @@ -34,11 +34,11 @@ public: TestScene() { train1 = std::make_shared<RailVehicle>(brush47rvc); - train1->location.setPosition({52, 50, 2}); + train1->location.setPosition({52000, 50000, 2000}); train1->bogies.front().setPosition(train1->bogies.front().position() + train1->location.position()); train1->bogies.back().setPosition(train1->bogies.back().position() + train1->location.position()); train2 = std::make_shared<RailVehicle>(brush47rvc); - train2->location.setPosition({52, 30, 2}); + train2->location.setPosition({52000, 30000, 2000}); train2->bogies.front().setPosition(train2->bogies.front().position() + train2->location.position()); train2->bogies.back().setPosition(train2->bogies.back().position() + train2->location.position()); } @@ -87,7 +87,7 @@ BOOST_FIXTURE_TEST_SUITE(w, TestRenderOutput); BOOST_AUTO_TEST_CASE(basic) { SceneRenderer ss {size, output}; - ss.camera.setView({-10, -10, 60}, glm::normalize(glm::vec3 {1, 1, -0.5F})); + ss.camera.setView({-10000, -10000, 60000}, glm::normalize(glm::vec3 {1, 1, -0.5F})); const TestScene scene; ss.render(scene); Texture::save(outImage, "/tmp/basic.tga"); @@ -96,7 +96,7 @@ BOOST_AUTO_TEST_CASE(basic) BOOST_AUTO_TEST_CASE(pointlight) { SceneRenderer ss {size, output}; - ss.camera.setView({-10, -10, 60}, glm::normalize(glm::vec3 {1, 1, -0.5F})); + ss.camera.setView({-10000, -10000, 60000}, glm::normalize(glm::vec3 {1, 1, -0.5F})); class PointLightScene : public TestScene { public: @@ -110,9 +110,9 @@ BOOST_AUTO_TEST_CASE(pointlight) void lights(const SceneShader & shader) const override { - for (int x = 50; x < 100; x += 20) { - for (int y = 50; y < 2000; y += 20) { - shader.pointLight.add({x, y, 4}, {1.0, 1.0, 1.0}, 0.1F); + for (int x = 50000; x < 100000; x += 20000) { + for (int y = 50000; y < 2000000; y += 20000) { + shader.pointLight.add({x, y, 4000}, {1.0, 1.0, 1.0}, 0.1F); } } } @@ -126,7 +126,7 @@ BOOST_AUTO_TEST_CASE(pointlight) BOOST_AUTO_TEST_CASE(spotlight) { SceneRenderer ss {size, output}; - ss.camera.setView({-10, -10, 60}, glm::normalize(glm::vec3 {1, 1, -0.5F})); + ss.camera.setView({-10000, -10000, 60000}, glm::normalize(glm::vec3 {1, 1, -0.5F})); class PointLightScene : public TestScene { public: @@ -140,10 +140,10 @@ BOOST_AUTO_TEST_CASE(spotlight) void lights(const SceneShader & shader) const override { - shader.spotLight.add({50, 50, 15}, down, {1.0, 1.0, 1.0}, 0.01F, 1); - shader.spotLight.add({51, 59.5, 1}, north, {1.0, 1.0, 1.0}, 0.001F, .5); - shader.spotLight.add({53, 59.5, 1}, north, {1.0, 1.0, 1.0}, 0.001F, .5); - shader.spotLight.add({60, 50, 3}, north + east, {1.0, 1.0, 1.0}, 0.0001F, .7F); + shader.spotLight.add({50000, 50000, 15000}, down, {1.0, 1.0, 1.0}, 0.01F, 1); + shader.spotLight.add({51000, 59500, 1000}, north, {1.0, 1.0, 1.0}, 0.001F, .5); + shader.spotLight.add({53000, 59500, 1000}, north, {1.0, 1.0, 1.0}, 0.001F, .5); + shader.spotLight.add({60000, 50000, 3000}, north + east, {1.0, 1.0, 1.0}, 0.0001F, .7F); } }; diff --git a/test/testRenderOutput.cpp b/test/testRenderOutput.cpp index 464b0b3..9af4451 100644 --- a/test/testRenderOutput.cpp +++ b/test/testRenderOutput.cpp @@ -1,7 +1,7 @@ #include "testRenderOutput.h" #include <stdexcept> -TestRenderOutput::TestRenderOutput(glm::ivec2 s) : size {s} +TestRenderOutput::TestRenderOutput(TextureAbsCoord s) : size {s} { glBindFramebuffer(GL_FRAMEBUFFER, output); const auto configuregdata diff --git a/test/testRenderOutput.h b/test/testRenderOutput.h index 13c380f..056d029 100644 --- a/test/testRenderOutput.h +++ b/test/testRenderOutput.h @@ -1,24 +1,25 @@ #pragma once +#include "config/types.h" #include "glArrays.h" #include <glm/vec2.hpp> #include <special_members.h> class TestRenderOutput { public: - TestRenderOutput(glm::ivec2 size = {640, 480}); + explicit TestRenderOutput(TextureAbsCoord size = {640, 480}); virtual ~TestRenderOutput() = default; NO_MOVE(TestRenderOutput); NO_COPY(TestRenderOutput); - const glm::ivec2 size; + const TextureAbsCoord size; glFrameBuffer output; glRenderBuffer depth; glTexture outImage; }; -template<glm::ivec2 Size> class TestRenderOutputSize : public TestRenderOutput { +template<TextureAbsCoord Size> class TestRenderOutputSize : public TestRenderOutput { public: TestRenderOutputSize() : TestRenderOutput {Size} { } }; diff --git a/test/testStructures.h b/test/testStructures.h index 6966052..aaaf940 100644 --- a/test/testStructures.h +++ b/test/testStructures.h @@ -1,5 +1,6 @@ #pragma once +#include "config/types.h" #include <persistence.h> struct AbsObject : public Persistence::Persistable { @@ -31,9 +32,9 @@ struct TestObject : public Persistence::Persistable { float flt {}; std::string str {}; bool bl {}; - glm::vec3 pos {}; + Position3D pos {}; std::vector<float> flts; - std::vector<glm::vec3> poss; + std::vector<Position3D> poss; std::vector<std::vector<std::vector<std::string>>> nest; std::unique_ptr<TestObject> ptr; std::unique_ptr<AbsObject> aptr; |