From fbc3d116c30d7441cbe9ba3e9708d3055b3fb106 Mon Sep 17 00:00:00 2001 From: codereader Date: Sun, 5 Sep 2021 13:58:15 +0200 Subject: [PATCH] #5710: Add another unit test with an axis-aligned brush including a non-identity texdef --- test/Brush.cpp | 22 +++++++++++++++++++ .../tdm/maps/quake3maps/angled_brush.map | 13 +++++++++++ .../maps/quake3maps/brush_with_transform.map | 13 +++++++++++ 3 files changed, 48 insertions(+) create mode 100644 test/resources/tdm/maps/quake3maps/angled_brush.map create mode 100644 test/resources/tdm/maps/quake3maps/brush_with_transform.map diff --git a/test/Brush.cpp b/test/Brush.cpp index 3ec120d366..97f9ed594c 100644 --- a/test/Brush.cpp +++ b/test/Brush.cpp @@ -252,6 +252,28 @@ TEST_F(Quake3BrushTest, LoadBrushWithIdentityTexDef) EXPECT_TRUE(faceHasVertex(face, Vector3(0, 0, 64), Vector2(0, -0.125))); } +// Load an axis-aligned brush somewhere at (-600 1000 56) and some shift/scale/rotation values +TEST_F(Quake3BrushTest, LoadAxisAlignedBrushWithTransform) +{ + std::string mapPath = "maps/quake3maps/brush_with_transform.map"; + GlobalCommandSystem().executeCommand("OpenMap", mapPath); + + auto worldspawn = GlobalMapModule().findOrInsertWorldspawn(); + EXPECT_EQ(algorithm::getChildCount(worldspawn), 1) << "Scene has not exactly 1 brush"; + + // Check that we have exactly one brush loaded + auto brushNode = algorithm::findFirstBrushWithMaterial(worldspawn, "textures/a_1024x512"); + EXPECT_TRUE(brushNode && brushNode->getNodeType() == scene::INode::Type::Brush) << "Couldn't locate the test brush"; + + auto face = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(0, 0, 1)); + EXPECT_TRUE(face != nullptr) << "No brush plane is facing upwards?"; + + EXPECT_TRUE(faceHasVertex(face, Vector3(-624, 800, 64), Vector2(5, 13))); + EXPECT_TRUE(faceHasVertex(face, Vector3(-688, 800, 64), Vector2(5.5, 13))); + EXPECT_TRUE(faceHasVertex(face, Vector3(-688, 1024, 64), Vector2(5.5, 16.5))); + EXPECT_TRUE(faceHasVertex(face, Vector3(-624, 1024, 64), Vector2(5, 16.5))); +} + #if 0 // This test case is not working since the Q3 texture projection mechanics // are different from idTech4, so DR cannot render angled faces as they would diff --git a/test/resources/tdm/maps/quake3maps/angled_brush.map b/test/resources/tdm/maps/quake3maps/angled_brush.map new file mode 100644 index 0000000000..1f67f766a1 --- /dev/null +++ b/test/resources/tdm/maps/quake3maps/angled_brush.map @@ -0,0 +1,13 @@ +// entity 0 +{ +"classname" "worldspawn" +// brush 0 +{ +( -592 1168 112 ) ( -720 1040 64 ) ( -720 1168 112 ) a_1024x512 128 128 180 0.125000 0.125000 134217728 0 0 +( -592 1040 48 ) ( -720 1168 96 ) ( -720 1040 48 ) a_1024x512 64 48 -90 0.500000 0.500000 134217728 0 0 +( -592 1168 112 ) ( -720 1168 112 ) ( -720 1168 96 ) a_1024x512 0 0 0 0.250000 0.250000 134217728 0 0 +( -592 1040 64 ) ( -720 1040 48 ) ( -720 1040 64 ) a_1024x512 0 0 0 0.250000 0.250000 134217728 0 0 +( -688 1104 64 ) ( -688 1072 -64 ) ( -688 1104 -64 ) a_1024x512 0 0 0 0.250000 0.250000 134217728 0 0 +( -624 1056 64 ) ( -624 1088 -64 ) ( -624 1056 -64 ) a_1024x512 0 0 0 0.250000 0.250000 134217728 0 0 +} +} diff --git a/test/resources/tdm/maps/quake3maps/brush_with_transform.map b/test/resources/tdm/maps/quake3maps/brush_with_transform.map new file mode 100644 index 0000000000..a0547e0c7f --- /dev/null +++ b/test/resources/tdm/maps/quake3maps/brush_with_transform.map @@ -0,0 +1,13 @@ +// entity 0 +{ +"classname" "worldspawn" +// brush 0 +{ +( -624 1024 64 ) ( -688 1024 56 ) ( -624 1024 56 ) a_1024x512 0 0 0 0.250000 0.250000 134217728 0 0 +( -624 928 64 ) ( -624 832 56 ) ( -624 832 64 ) a_1024x512 0 0 0 0.125000 0.125000 134217728 0 0 +( -688 928 56 ) ( -688 832 64 ) ( -688 832 56 ) a_1024x512 0 0 0 0.125000 0.125000 134217728 0 0 +( -688 800 64 ) ( -624 800 64 ) ( -624 800 56 ) a_1024x512 0 0 0 0.125000 0.125000 134217728 0 0 +( -624 928 56 ) ( -688 832 56 ) ( -624 832 56 ) a_1024x512 0 16 0 0.500000 0.500000 134217728 0 0 +( -688 928 64 ) ( -624 832 64 ) ( -688 832 64 ) a_1024x512 128 256 180 0.125000 0.125000 134217728 0 0 +} +}