Skip to content

Commit

Permalink
#5410: Unit test asserting that it's possible to assign a texture to …
Browse files Browse the repository at this point in the history
…a forcedly visible brush
  • Loading branch information
codereader committed Nov 16, 2020
1 parent d7bb39e commit de3e2ae
Show file tree
Hide file tree
Showing 6 changed files with 685 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/Makefile.am
Expand Up @@ -37,5 +37,6 @@ drtest_SOURCES = math/Matrix4.cpp \
Models.cpp \
ModelExport.cpp \
ModelScale.cpp \
Selection.cpp \
SelectionAlgorithm.cpp \
VFS.cpp
50 changes: 50 additions & 0 deletions test/Selection.cpp
@@ -0,0 +1,50 @@
#include "RadiantTest.h"

#include "ishaders.h"
#include "imap.h"
#include "ifilter.h"
#include "ibrush.h"
#include "ipatch.h"
#include "algorithm/Scene.h"
#include "scenelib.h"
#include "selectionlib.h"

namespace test
{

using SelectionTest = RadiantTest;

TEST_F(SelectionTest, ApplyShadersToForcedVisibleObjects)
{
loadMap("primitives_with_clip_material.map");

auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
auto brush = algorithm::findFirstBrushWithMaterial(worldspawn, "textures/common/clip");
auto patch = algorithm::findFirstPatchWithMaterial(worldspawn, "textures/common/clip");

// Filter out the objects using the clip material
GlobalFilterSystem().setFilterState("Clip Textures", true);

// Glitch: Since this brush is completely filtered out, this won't be called by the filter system
Node_getIBrush(brush)->updateFaceVisibility();

EXPECT_FALSE(brush->visible());
EXPECT_FALSE(patch->visible());

Node_setSelected(brush, true);
Node_setSelected(patch, true);

EXPECT_TRUE(brush->visible());
EXPECT_TRUE(patch->visible());

// Apply the caulk material to the selection
selection::applyShaderToSelection("textures/common/caulk");

auto brushNode = std::dynamic_pointer_cast<IBrushNode>(brush);
auto patchNode = std::dynamic_pointer_cast<IPatchNode>(patch);

EXPECT_TRUE(brushNode->getIBrush().hasShader("textures/common/caulk"));
EXPECT_EQ(patchNode->getPatch().getShader(), ("textures/common/caulk"));
}

}
114 changes: 114 additions & 0 deletions test/resources/tdm/maps/primitives_with_clip_material.map
@@ -0,0 +1,114 @@
Version 2
// entity 0
{
"classname" "worldspawn"
// primitive 0
{
brushDef3
{
( 0 0 1 -136 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 1 0 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 1 0 0 -192 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 -1 0 -192 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( -1 0 0 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 0 -1 128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
}
}
// primitive 1
{
brushDef3
{
( 0 0 1 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 1 0 -136 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 1 0 0 -192 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 0 -1 -64 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( -1 0 0 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 -1 0 128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
}
}
// primitive 2
{
brushDef3
{
( 0 0 1 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 1 0 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 1 0 0 -200 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 0 -1 -64 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 -1 0 -192 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( -1 0 0 192 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
}
}
// primitive 3
{
brushDef3
{
( 0 1 0 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 1 0 0 -192 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 0 -1 -72 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 -1 0 -192 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( -1 0 0 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 0 1 64 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
}
}
// primitive 4
{
brushDef3
{
( 0 0 1 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 1 0 0 -192 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 0 -1 -64 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 -1 0 -200 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( -1 0 0 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 1 0 192 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
}
}
// primitive 5
{
brushDef3
{
( 0 0 1 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 1 0 -128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 0 -1 -64 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 0 -1 0 -192 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( -1 0 0 -136 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
( 1 0 0 128 ) ( ( 0.03125 0 0 ) ( 0 0.03125 0 ) ) "textures/common/caulk" 0 0 0
}
}
// primitive 6
{
brushDef3
{
( 0 0 1 -16 ) ( ( 0.015625 0 127 ) ( 0 0.015625 0 ) ) "textures/common/caulk" 0 0 0
( 0 1 0 -104 ) ( ( 0.015625 0 0 ) ( 0 0.015625 0 ) ) "textures/common/caulk" 0 0 0
( 1 0 0 -120 ) ( ( 0.015625 0 127 ) ( 0 0.015625 0 ) ) "textures/common/caulk" 0 0 0
( 0 0 -1 -40 ) ( ( 0.015625 0 127 ) ( 0 0.015625 0 ) ) "textures/common/caulk" 0 0 0
( 0 -1 0 56 ) ( ( 0.015625 0 0 ) ( 0 0.015625 127.875 ) ) "textures/common/caulk" 0 0 0
( -1 0 0 72 ) ( ( 0.015625 0 1 ) ( 0 0.015625 0 ) ) "textures/common/caulk" 0 0 0
}
}
// primitive 7
{
brushDef3
{
( 0 0 1 -16 ) ( ( 0.015625 0 127 ) ( 0 0.015625 1.625 ) ) "textures/common/clip" 0 0 0
( 0 1 0 -104 ) ( ( 0.015625 0 126.375 ) ( 0 0.015625 0 ) ) "textures/common/clip" 0 0 0
( 1 0 0 -16 ) ( ( 0.015625 0 127 ) ( 0 0.015625 0 ) ) "textures/common/clip" 0 0 0
( 0 0 -1 -40 ) ( ( 0.015625 0 127 ) ( 0 0.015625 126.375 ) ) "textures/common/clip" 0 0 0
( 0 -1 0 56 ) ( ( 0.015625 0 1.625 ) ( 0 0.015625 127.875 ) ) "textures/common/clip" 0 0 0
( -1 0 0 -32 ) ( ( 0.015625 0 1 ) ( 0 0.015625 0 ) ) "textures/common/clip" 0 0 0
}
}
// primitive 8
{
patchDef2
{
"textures/common/clip"
( 3 3 0 0 0 )
(
( ( -96 56 -12 0 0 ) ( -96 80 -12 0 -0.375 ) ( -96 104 -12 0 -0.75 ) )
( ( -72 56 -12 0.375 0 ) ( -72 80 -12 0.375 -0.375 ) ( -72 104 -12 0.375 -0.75 ) )
( ( -48 56 -12 0.75 0 ) ( -48 80 -12 0.75 -0.375 ) ( -48 104 -12 0.75 -0.75 ) )
)
}
}
}

0 comments on commit de3e2ae

Please sign in to comment.