summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2024-02-22 01:16:29 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2024-02-22 01:16:29 +0000
commit3770b101cfc5ad37a069850b422f0098ade7fc08 (patch)
treedc4bdc403751062826d9c480779d1d8b3e7f7a31 /test
parentFix calculation of texture coords of terrain (diff)
downloadilt-3770b101cfc5ad37a069850b422f0098ade7fc08.tar.bz2
ilt-3770b101cfc5ad37a069850b422f0098ade7fc08.tar.xz
ilt-3770b101cfc5ad37a069850b422f0098ade7fc08.zip
First cut of terrain deformation
This "works" for some definition of works... But it's flawed in many ways, not least the following: * It's glitchy for no obvious reason * It's unreliable; fails if you tweak the parameters * The sides of the modified area are triangulated in the dumbest possible fashion, which results in ill-formed polygons * Probably other things, but... It works, remember...
Diffstat (limited to 'test')
-rw-r--r--test/test-geoData.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/test-geoData.cpp b/test/test-geoData.cpp
index f8437c3..6602b05 100644
--- a/test/test-geoData.cpp
+++ b/test/test-geoData.cpp
@@ -1,7 +1,12 @@
#define BOOST_TEST_MODULE terrain
+#include "game/terrain.h"
+#include "test/testMainWindow.h"
+#include "test/testRenderOutput.h"
#include "testHelpers.h"
+#include "ui/applicationBase.h"
#include <boost/test/data/test_case.hpp>
#include <boost/test/unit_test.hpp>
+#include <gfx/gl/sceneRenderer.h>
#include <stream_support.h>
#include <game/geoData.h>
@@ -199,3 +204,58 @@ BOOST_DATA_TEST_CASE(findEntries,
{
BOOST_CHECK_EQUAL(fixedTerrtain.findEntry(from, to).idx(), heh);
}
+
+BOOST_AUTO_TEST_CASE(setTriangle, *boost::unit_test::timeout(5))
+{
+ auto gd = std::make_shared<GeoData>(GeoData::createFlat({0, 0}, {1000000, 1000000}, 100));
+ std::array points {
+ GlobalPosition3D {70100, 123000, 6000},
+ GlobalPosition3D {50100, 52300, 6000},
+ GlobalPosition3D {191000, 283000, 8000},
+ GlobalPosition3D {241000, 123330, -2000},
+ };
+ BOOST_CHECK_NO_THROW(gd->setHeights(points));
+
+ ApplicationBase ab;
+ TestMainWindow tmw;
+ TestRenderOutput tro {{1792, 1024}};
+
+ SceneRenderer ss {tro.size, tro.output};
+ ss.camera.setView({-90000, -90000, 300000}, glm::normalize(glm::vec3 {1, 1, -1.5F}));
+
+ struct TestTerrain : public SceneProvider {
+ explicit TestTerrain(std::shared_ptr<GeoData> gd) : terrain(std::move(gd)) { }
+
+ const Terrain terrain;
+
+ void
+ content(const SceneShader & shader) const override
+ {
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ terrain.render(shader);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ }
+
+ void
+ environment(const SceneShader &, const SceneRenderer & sr) const override
+ {
+ sr.setAmbientLight({0.1, 0.1, 0.1});
+ sr.setDirectionalLight({1, 1, 1}, south + down, *this);
+ }
+
+ void
+ lights(const SceneShader &) const override
+ {
+ }
+
+ void
+ shadows(const ShadowMapper & shadowMapper) const override
+ {
+ terrain.shadows(shadowMapper);
+ }
+ };
+
+ TestTerrain t {gd};
+ BOOST_CHECK_NO_THROW(ss.render(t));
+ Texture::save(tro.outImage, "/tmp/geoData.tga");
+}