Navigation Menu

Skip to content

Commit

Permalink
#5710: Add another unit test with an axis-aligned brush including a n…
Browse files Browse the repository at this point in the history
…on-identity texdef
  • Loading branch information
codereader committed Sep 5, 2021
1 parent 5ef45c6 commit fbc3d11
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/Brush.cpp
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions 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
}
}
13 changes: 13 additions & 0 deletions 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
}
}

0 comments on commit fbc3d11

Please sign in to comment.