/
Selection.cpp
80 lines (59 loc) · 2.69 KB
/
Selection.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "RadiantTest.h"
#include "ishaders.h"
#include "imap.h"
#include "ifilter.h"
#include "ilightnode.h"
#include "ibrush.h"
#include "ipatch.h"
#include "ientity.h"
#include "ieclass.h"
#include "algorithm/Scene.h"
#include "scenelib.h"
#include "selectionlib.h"
#include "string/convert.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"));
}
// #5443: Size display of lights doesn't change when modifying "light_radius"
TEST_F(SelectionTest, LightBoundsChangedAfterRadiusChange)
{
auto eclass = GlobalEntityClassManager().findOrInsert("light", false);
auto entityNode = GlobalEntityModule().createEntity(eclass);
EXPECT_TRUE(Node_getLightNode(entityNode));
auto* entity = Node_getEntity(entityNode);
entity->setKeyValue("light_radius", "300 200 100");
GlobalMapModule().getRoot()->addChildNode(entityNode);
Node_setSelected(entityNode, true);
auto defaultBounds = string::convert<Vector3>(entity->getKeyValue("light_radius"));
EXPECT_TRUE(GlobalSelectionSystem().getWorkZone().bounds.getExtents().isEqual(defaultBounds, 0.01));
// Modify just the light_radius spawnarg
entity->setKeyValue("light_radius", "30 20 10");
// The work zone should have adapted itself to the new bounds
// assuming that the LightNode recalculates its AABB
auto changedBounds = string::convert<Vector3>(entity->getKeyValue("light_radius"));
EXPECT_TRUE(GlobalSelectionSystem().getWorkZone().bounds.getExtents().isEqual(changedBounds, 0.01));
}
}