Skip to content

Commit

Permalink
#5942: Add unit test checking Brush::buildBREP behaviour when encount…
Browse files Browse the repository at this point in the history
…ering duplicated face planes.

The Doom3 game code will remove the second plane during dmap.
  • Loading branch information
codereader committed Apr 18, 2022
1 parent 0728b7d commit 611a68d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/version.h
Expand Up @@ -4,7 +4,7 @@
#include <config.h>
#define RADIANT_VERSION PACKAGE_VERSION
#else
#define RADIANT_VERSION "3.0.0pre3"
#define RADIANT_VERSION "3.0.0pre4"
#endif

#define RADIANT_APPNAME "DarkRadiant"
Expand Down
27 changes: 27 additions & 0 deletions test/Brush.cpp
Expand Up @@ -419,4 +419,31 @@ TEST_F(BrushTest, RotateBrushY90Degrees)
checkFaceNormalAndShader(brush, 5, {-1, 0, 0 }, "textures/numbers/1");
}

// #5942: Missing brushes when opening alphalabs1 from vanilla Doom 3
TEST_F(BrushTest, LoadBrushWithDuplicatePlanes)
{
std::string mapPath = "maps/brush_with_duplicate_planes.map";
GlobalCommandSystem().executeCommand("OpenMap", mapPath);

// Check that we have exactly one brush loaded
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
auto brushNode = algorithm::findFirstBrushWithMaterial(worldspawn, "textures/common/caulk");
EXPECT_TRUE(brushNode && brushNode->getNodeType() == scene::INode::Type::Brush) << "Couldn't locate the test brush";

auto brush = Node_getIBrush(brushNode);
brush->evaluateBRep();

EXPECT_TRUE(brush->hasContributingFaces()) << "Brush should not be degenerate";
EXPECT_EQ(brush->getNumFaces(), 6) << "Brush should have 6 faces after map loading, even though it has been declared with 9";

// The second duplicates should have been removed, they were textured with caulk2
// Therefore all 6 faces should have the caulk texture exclusively
for (auto i = 0; i < brush->getNumFaces(); ++i)
{
auto& face = brush->getFace(i);

EXPECT_EQ(face.getShader(), "textures/common/caulk") << "Face " << i << " should be textured with caulk";
}
}

}
21 changes: 21 additions & 0 deletions test/resources/tdm/maps/brush_with_duplicate_planes.map
@@ -0,0 +1,21 @@
Version 2
// entity 0
{
"classname" "worldspawn"
"description" "The brush below has 3 redundant planes but different materials than the previously declared planes"
// primitive 0
{
brushDef3
{
( 0 0 1 -128 ) ( ( 0.015625 0 -14 ) ( 0 0.0078130001 0.7460148931 ) ) "textures/common/caulk" 0 0 0
( 0 1 0 -4144 ) ( ( 0.015625 0 -1.5000076294 ) ( 0 0.0078119999 -0.9999359846 ) ) "textures/common/caulk" 0 0 0
( -1 0 0 -136 ) ( ( 0.015625 0 14 ) ( 0 0.0078130001 -1.0000640154 ) ) "textures/common/caulk" 0 0 0
( 0 -1 0 4104 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 1 0 0 128 ) ( ( 0.015625 0 0 ) ( 0 0.0078125 0 ) ) "textures/common/caulk" 0 0 0
( 0 0 -1 -128 ) ( ( 0.015625 0 -14 ) ( 0 0.0078130001 -0.7460148931 ) ) "textures/common/caulk" 0 0 0
( -1 0 0 -136 ) ( ( 0.0104219997 0 43.905040741 ) ( 0 0.0078130001 0.9999360442 ) ) "textures/common/caulk2" 0 0 0
( 1 0 0 128 ) ( ( 0.015625 0 -14 ) ( 0 0.0078130001 -1.0000640154 ) ) "textures/common/caulk2" 0 0 0
( 0 1 0 -4144 ) ( ( 0.015625 0 -1.5000076294 ) ( 0 0.0078119999 -0.9999359846 ) ) "textures/common/caulk2" 0 0 0
}
}
}

0 comments on commit 611a68d

Please sign in to comment.