/
TextureManipulation.cpp
508 lines (384 loc) · 21.7 KB
/
TextureManipulation.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
#include "RadiantTest.h"
#include "ishaderclipboard.h"
#include "algorithm/Scene.h"
#include "algorithm/Primitives.h"
#include "scenelib.h"
#include "math/Matrix3.h"
#include "registry/registry.h"
#include "render/CameraView.h"
#include "algorithm/View.h"
namespace test
{
using TextureManipulationTest = RadiantTest;
TEST_F(TextureManipulationTest, RotateFace)
{
std::string mapPath = "maps/simple_brushes.map";
GlobalCommandSystem().executeCommand("OpenMap", mapPath);
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
// Find the brush that is centered at origin
auto brushNode = algorithm::findFirstBrushWithMaterial(worldspawn, "textures/numbers/2");
EXPECT_TRUE(brushNode && brushNode->getNodeType() == scene::INode::Type::Brush) << "Couldn't locate the test brush";
// Pick a few faces and run the algorithm against it, checking hardcoded results
// Facing 0,0,1
auto face = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(0, 0, 1));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -160), Vector2(0, 1)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, -64, -160), Vector2(0, 0)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, 64, -160), Vector2(1, 0)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, 64, -160), Vector2(1, 1)));
face->rotateTexdef(15); // degrees
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -160), Vector2(-0.112372, 0.853553)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, -64, -160), Vector2(0.146447, -0.112372)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, 64, -160), Vector2(1.11237, 0.146447)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, 64, -160), Vector2(0.853553, 1.11237)));
// Facing 1,0,0
face = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(1, 0, 0));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -288), Vector2(0, 65)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -160), Vector2(0, 64)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, 64, -160), Vector2(1, 64)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, 64, -288), Vector2(1, 65)));
face->rotateTexdef(15); // degrees
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -288), Vector2(-0.112372, 64.8536)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -160), Vector2(0.146447, 63.8876)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, 64, -160), Vector2(1.11237, 64.1464)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, 64, -288), Vector2(0.853553, 65.1124)));
// Facing 0,0,-1
face = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(0, 0, -1));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, -64, -288), Vector2(0, 1)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -288), Vector2(0, 0)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, 64, -288), Vector2(1, 0)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, 64, -288), Vector2(1, 1)));
face->rotateTexdef(15); // degrees
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, -64, -288), Vector2(-0.112372, 0.853553)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -288), Vector2(0.146447, -0.112372)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, 64, -288), Vector2(1.11237, 0.146447)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, 64, -288), Vector2(0.853553, 1.11237)));
// Facing 0,-1,0, this time rotate -15 degrees
face = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(0, -1, 0));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, -64, -160), Vector2(0, 64)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -160), Vector2(1, 64)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -288), Vector2(1, 65)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, -64, -288), Vector2(0, 65)));
face->rotateTexdef(-15); // degrees
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, -64, -160), Vector2(-0.112372, 64.1464)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -160), Vector2(0.853553, 63.8876)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(64, -64, -288), Vector2(1.11237, 64.8536)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-64, -64, -288), Vector2(0.146447, 65.1124)));
}
namespace
{
void performPatchRotateTest(bool clockwise)
{
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
auto patchNode = algorithm::createPatchFromBounds(worldspawn, AABB(Vector3(4, 50, 60), Vector3(64, 128, 256)), "textures/numbers/1");
auto patch = Node_getIPatch(patchNode);
patch->scaleTextureNaturally();
patch->controlPointsChanged();
Node_setSelected(patchNode, true);
auto bounds = algorithm::getTextureSpaceBounds(*patch);
std::vector<Vector2> oldTexCoords;
algorithm::foreachPatchVertex(*patch, [&](const PatchControl& ctrl) { oldTexCoords.push_back(ctrl.texcoord); });
// Set the rotation in the registry, TexRotate will pick it up
constexpr auto angle = 15.0f;
registry::setValue("user/ui/textures/surfaceInspector/rotStep", angle);
GlobalCommandSystem().executeCommand("TexRotate", { cmd::Argument(clockwise ? "1" : "-1") });
// Rotate each texture coordinate around the patch center with a manual transform
auto transform = Matrix3::getTranslation({ -bounds.origin.x(), -bounds.origin.y() });
transform.premultiplyBy(Matrix3::getRotation(degrees_to_radians(clockwise ? angle : -angle)));
transform.premultiplyBy(Matrix3::getTranslation({ bounds.origin.x(), bounds.origin.y() }));
auto old = oldTexCoords.begin();
algorithm::foreachPatchVertex(*patch, [&](const PatchControl& ctrl)
{
auto transformed = transform * (*old++);
EXPECT_TRUE(math::isNear(transformed, ctrl.texcoord, 0.02))
<< "Transformed UV coords should be " << transformed << " but was " << ctrl.texcoord;
});
}
}
TEST_F(TextureManipulationTest, RotatePatchClockwise)
{
performPatchRotateTest(true); // clockwise
}
TEST_F(TextureManipulationTest, RotatePatchCounterClockwise)
{
performPatchRotateTest(false); // clockwise
}
namespace
{
void performFaceFlipTest(int axis)
{
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
auto brush = algorithm::createCubicBrush(worldspawn, Vector3(0, 256, 256), "textures/numbers/1");
Node_setSelected(brush, true);
auto faceUp = algorithm::findBrushFaceWithNormal(Node_getIBrush(brush), Vector3(0, 0, 1));
std::vector<Vector2> oldTexCoords;
for (const auto& vertex : faceUp->getWinding())
{
oldTexCoords.push_back(vertex.texcoord);
}
auto cmd = axis == 0 ? "FlipTextureX" : "FlipTextureY";
GlobalCommandSystem().executeCommand(cmd);
auto faceUvBounds = algorithm::getTextureSpaceBounds(*faceUp);
// Every face vertex should have been flipped about the bounds origin
auto old = oldTexCoords.begin();
for (const auto& vertex : faceUp->getWinding())
{
// Calculate the mirrored coordinate
auto expectedTexcoord = *(old++);
expectedTexcoord[axis] = 2 * faceUvBounds.origin[axis] - expectedTexcoord[axis];
EXPECT_EQ(vertex.texcoord.x(), expectedTexcoord.x()) << "Mirrored vertex should be at " << expectedTexcoord;
EXPECT_EQ(vertex.texcoord.y(), expectedTexcoord.y()) << "Mirrored vertex should be at " << expectedTexcoord;
}
}
void performPatchFlipTest(int axis)
{
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
auto patchNode = algorithm::createPatchFromBounds(worldspawn, AABB(Vector3(4, 50, 60), Vector3(64, 128, 256)), "textures/numbers/1");
auto patch = Node_getIPatch(patchNode);
patch->scaleTextureNaturally();
patch->controlPointsChanged();
Node_setSelected(patchNode, true);
// Get the texture space bounds of this patch
auto patchBounds = algorithm::getTextureSpaceBounds(*patch);
auto bounds = patchBounds;
bounds.extents *= 1.2f;
std::vector<Vector2> oldTexCoords;
algorithm::foreachPatchVertex(*patch, [&](const PatchControl& ctrl) { oldTexCoords.push_back(ctrl.texcoord); });
auto cmd = axis == 0 ? "FlipTextureX" : "FlipTextureY";
GlobalCommandSystem().executeCommand(cmd);
// Every changed vertex should have been flipped about the bounds origin
algorithm::expectVerticesHaveBeenFlipped(axis, *patch, oldTexCoords, { patchBounds.origin.x(), patchBounds.origin.y() });
}
}
TEST_F(TextureManipulationTest, FlipFaceHorizontally)
{
performFaceFlipTest(0);
}
TEST_F(TextureManipulationTest, FlipFaceVertically)
{
performFaceFlipTest(1);
}
TEST_F(TextureManipulationTest, FlipPatchHorizontally)
{
performPatchFlipTest(0);
}
TEST_F(TextureManipulationTest, FlipPatchVertically)
{
performPatchFlipTest(1);
}
namespace
{
void assumeVerticesHaveBeenScaled(const std::vector<Vector2>& oldCoords, const std::vector<Vector2>& newCoords, const Vector2& scale, const Vector2& pivot)
{
auto oldCoord = oldCoords.begin();
auto newCoord = newCoords.begin();
auto transform = Matrix3::getTranslation(-pivot);
transform.premultiplyBy(Matrix3::getScale(scale));
transform.premultiplyBy(Matrix3::getTranslation(pivot));
while (newCoord != newCoords.end())
{
auto expected = transform * (*oldCoord++);
auto actual = *newCoord++;
EXPECT_TRUE(math::isNear(actual, expected, 0.01)) << "Vertex should be " << expected << ", but was " << actual;
}
}
void performFaceScaleTest(const Vector2& scale)
{
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
auto brush = algorithm::createCubicBrush(worldspawn, Vector3(0, 256, 256), "textures/numbers/1");
Node_setSelected(brush, true);
auto faceUp = algorithm::findBrushFaceWithNormal(Node_getIBrush(brush), Vector3(0, 0, 1));
std::vector<Vector2> oldTexCoords;
for (const auto& vertex : faceUp->getWinding())
{
oldTexCoords.push_back(vertex.texcoord);
}
// The incoming scale values are absolute 1.05 == 105%, the command accepts relative values, 0.05 == 105%
auto zeroBasedScale = scale - Vector2(1, 1);
GlobalCommandSystem().executeCommand("TexScale", { cmd::Argument(zeroBasedScale) });
auto faceUvBounds = algorithm::getTextureSpaceBounds(*faceUp);
std::vector<Vector2> newTexCoords;
for (const auto& vertex : faceUp->getWinding())
{
newTexCoords.push_back(vertex.texcoord);
}
Vector2 pivot(faceUvBounds.origin.x(), faceUvBounds.origin.y());
assumeVerticesHaveBeenScaled(oldTexCoords, newTexCoords, scale, pivot);
}
void performPatchScaleTest(const Vector2& scale)
{
// We create two patches, each of them should be scaled independently
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
auto patchNode1 = algorithm::createPatchFromBounds(worldspawn, AABB(Vector3(4, 50, 60), Vector3(64, 128, 256)), "textures/numbers/1");
auto patchNode2 = algorithm::createPatchFromBounds(worldspawn, AABB(Vector3(4, 50, -5), Vector3(64, 128, 64)), "textures/numbers/1");
auto patch1 = Node_getIPatch(patchNode1);
auto patch2 = Node_getIPatch(patchNode2);
patch1->scaleTextureNaturally();
patch1->controlPointsChanged();
patch2->scaleTextureNaturally();
patch2->controlPointsChanged();
Node_setSelected(patchNode1, true);
Node_setSelected(patchNode2, true);
std::vector<Vector2> oldTexCoords1;
std::vector<Vector2> oldTexCoords2;
algorithm::foreachPatchVertex(*patch1, [&](const PatchControl& ctrl) { oldTexCoords1.push_back(ctrl.texcoord); });
algorithm::foreachPatchVertex(*patch2, [&](const PatchControl& ctrl) { oldTexCoords2.push_back(ctrl.texcoord); });
// The incoming scale values are absolute 1.05 == 105%, the command accepts relative values, 0.05 == 105%
auto zeroBasedScale = scale - Vector2(1, 1);
GlobalCommandSystem().executeCommand("TexScale", { cmd::Argument(zeroBasedScale) });
auto uvBounds1 = algorithm::getTextureSpaceBounds(*patch1);
auto uvBounds2 = algorithm::getTextureSpaceBounds(*patch2);
std::vector<Vector2> newTexCoords1;
std::vector<Vector2> newTexCoords2;
algorithm::foreachPatchVertex(*patch1, [&](const PatchControl& ctrl) { newTexCoords1.push_back(ctrl.texcoord); });
algorithm::foreachPatchVertex(*patch2, [&](const PatchControl& ctrl) { newTexCoords2.push_back(ctrl.texcoord); });
Vector2 pivot(uvBounds1.origin.x(), uvBounds1.origin.y());
assumeVerticesHaveBeenScaled(oldTexCoords1, newTexCoords1, scale, pivot);
Vector2 pivot2(uvBounds2.origin.x(), uvBounds2.origin.y());
assumeVerticesHaveBeenScaled(oldTexCoords2, newTexCoords2, scale, pivot2);
}
}
TEST_F(TextureManipulationTest, ScaleFaceUniformly)
{
performFaceScaleTest({ 1.1, 1.1 });
}
TEST_F(TextureManipulationTest, ScaleFaceNonUniformly)
{
performFaceScaleTest({ 1.2, 0.9 });
}
TEST_F(TextureManipulationTest, ScalePatchUniformly)
{
performPatchScaleTest({ 1.1, 1.1 });
}
TEST_F(TextureManipulationTest, ScalePatchNonUniformly)
{
performPatchScaleTest({ 1.2, 0.9 });
}
std::vector<std::pair<const WindingVertex*, const WindingVertex*>> findSharedVertices(const IFace& face1, const IFace& face2)
{
std::vector<std::pair<const WindingVertex*, const WindingVertex*>> vertexPairs;
for (const auto& vertex1 : face1.getWinding())
{
for (const auto& vertex2 : face2.getWinding())
{
if (math::isNear(vertex1.vertex, vertex2.vertex, 0.01))
{
vertexPairs.emplace_back(std::make_pair(&vertex1, &vertex2));
}
}
}
return vertexPairs;
}
// Paste texture from the top face of a brush to the one one the front side (X)
TEST_F(TextureManipulationTest, PasteTextureToOrthogonalFace1)
{
std::string mapPath = "maps/simple_brushes.map";
GlobalCommandSystem().executeCommand("OpenMap", mapPath);
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
auto brushNode = algorithm::findFirstBrushWithMaterial(worldspawn, "textures/numbers/3");
auto faceUp = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(0, 0, 1));
auto faceRight = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(1, 0, 0));
// Find the shared vertices of the two faces
auto sharedVertices = findSharedVertices(*faceUp, *faceRight);
EXPECT_EQ(sharedVertices.size(), 2) << "There should be 2 shared 3D vertices between the two faces";
for (const auto& pair : sharedVertices)
{
EXPECT_FALSE(math::isNear(pair.first->texcoord, pair.second->texcoord, 0.01))
<< "Texture coordinates are the same before pasting the texture projection";
}
// Position the camera top-down, similar to what an XY view is seeing
render::View viewFaceUp(true);
algorithm::constructCameraView(viewFaceUp, brushNode->localAABB(), { 0, 0, -1 }, { -90, 0, 0 });
SelectionVolume testFaceUp(viewFaceUp);
GlobalShaderClipboard().pickFromSelectionTest(testFaceUp);
EXPECT_EQ(GlobalShaderClipboard().getSourceType(), selection::IShaderClipboard::SourceType::Face)
<< "Selection test failed to select the face";
render::View viewFaceRight(true);
algorithm::constructCameraView(viewFaceRight, brushNode->localAABB(), { -1, 0, 0 }, { 0, 180, 0 });
ConstructSelectionTest(viewFaceRight, selection::Rectangle::ConstructFromPoint({ 0, 0 }, { 0.1, 0.1 }));
SelectionVolume testFaceRight(viewFaceRight);
GlobalShaderClipboard().pasteShader(testFaceRight, selection::PasteMode::Natural, false);
for (const auto& pair : sharedVertices)
{
EXPECT_TRUE(math::isNear(pair.first->texcoord, pair.second->texcoord, 0.01))
<< "Texture coordinates should be the same after pasting the texture projection";
}
}
// Paste shader from top face of a brush to the one on the left (Y)
TEST_F(TextureManipulationTest, PasteTextureToOrthogonalFace2)
{
std::string mapPath = "maps/simple_brushes.map";
GlobalCommandSystem().executeCommand("OpenMap", mapPath);
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
auto brushNode = algorithm::findFirstBrushWithMaterial(worldspawn, "textures/numbers/4");
auto faceUp = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(0, 0, 1));
auto faceYDown = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(0, -1, 0));
// Find the shared vertices of the two faces
auto sharedVertices = findSharedVertices(*faceUp, *faceYDown);
EXPECT_EQ(sharedVertices.size(), 2) << "There should be 2 shared 3D vertices between the two faces";
for (const auto& pair : sharedVertices)
{
EXPECT_FALSE(math::isNear(pair.first->texcoord, pair.second->texcoord, 0.01))
<< "Texture coordinates are the same before pasting the texture projection";
}
// Position the camera top-down, similar to what an XY view is seeing
render::View viewFaceUp(true);
algorithm::constructCameraView(viewFaceUp, brushNode->localAABB(), { 0, 0, -1 }, { -90, 0, 0 });
SelectionVolume testFaceUp(viewFaceUp);
GlobalShaderClipboard().pickFromSelectionTest(testFaceUp);
EXPECT_EQ(GlobalShaderClipboard().getSourceType(), selection::IShaderClipboard::SourceType::Face)
<< "Selection test failed to select the face";
render::View viewFacingYUp(true);
algorithm::constructCameraView(viewFacingYUp, brushNode->localAABB(), { 0, 1, 0 }, { 0, 90, 0 });
ConstructSelectionTest(viewFacingYUp, selection::Rectangle::ConstructFromPoint({ 0, 0 }, { 0.1, 0.1 }));
SelectionVolume testFacingYUp(viewFacingYUp);
GlobalShaderClipboard().pasteShader(testFacingYUp, selection::PasteMode::Natural, false);
for (const auto& pair : sharedVertices)
{
EXPECT_TRUE(math::isNear(pair.first->texcoord, pair.second->texcoord, 0.01))
<< "Texture coordinates should be the same after pasting the texture projection";
}
}
TEST_F(TextureManipulationTest, NormaliseFace)
{
std::string mapPath = "maps/simple_brushes.map";
GlobalCommandSystem().executeCommand("OpenMap", mapPath);
auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
// Find the brush that is centered at origin
auto brushNode = algorithm::findFirstBrushWithMaterial(worldspawn, "textures/numbers/4");
EXPECT_TRUE(brushNode && brushNode->getNodeType() == scene::INode::Type::Brush) << "Couldn't locate the test brush";
// Pick a few faces and run the algorithm against it, checking hardcoded results
// Facing 0,1,0
auto face = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(0, 1, 0));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0,-24.0, 208.0), Vector2(61.13169449567795, -0.5979519486427307)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0,-24.0, 376.0), Vector2(61.13169449567795, -1.4489692151546478)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-992.0,-24.0, 376.0), Vector2(62.102946043014526, -1.4489692151546478)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-992.0,-24.0, 208.0), Vector2(62.102946043014526, -0.5979519486427307)));
face->normaliseTexture();
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -24.0, 208.0), Vector2(0.13169449567795, 0.40204805135726929)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -24.0, 376.0), Vector2(0.13169449567795, -0.4489692151546478)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-992.0, -24.0, 376.0), Vector2(1.102946043014526, -0.4489692151546478)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-992.0, -24.0, 208.0), Vector2(1.102946043014526, 0.40204805135726929)));
// Facing 1,0,0
face = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(1, 0, 0));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -280.0, 376.0), Vector2(-0.1557292342185974, 53.89497980847955)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -24.0, 376.0), Vector2(0.8797785639762878, 54.230962846428156)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -24.0, 208.0), Vector2(0.6975563578307629, 55.053220719099045)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -280.0, 208.0), Vector2(-0.3379514403641224, 54.717237681150436)));
face->normaliseTexture();
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -280.0, 376.0), Vector2(-0.1557292342185974, -0.10502019152045250)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -24.0, 376.0), Vector2(0.8797785639762878, 0.230962846428156)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -24.0, 208.0), Vector2(0.6975563578307629, 1.053220719099045)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -280.0, 208.0), Vector2(-0.3379514403641224, 0.717237681150436)));
// Facing 0,-1,0
face = algorithm::findBrushFaceWithNormal(Node_getIBrush(brushNode), Vector3(0, -1, 0));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-992.0, -280.0, 376.0), Vector2(-15.5, -5.875)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -280.0, 376.0), Vector2(-11.875, -5.875)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0, -280.0, 208.0), Vector2(-11.875, -3.25)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-992.0, -280.0, 208.0), Vector2(-15.5, -3.25)));
face->normaliseTexture();
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-992.0,-280.0,376.0), Vector2(-2.5, -1.875)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0,-280.0,376.0), Vector2(1.125, -1.875)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-760.0,-280.0,208.0), Vector2(1.125, 0.75)));
EXPECT_TRUE(algorithm::faceHasVertex(face, Vector3(-992.0,-280.0,208.0), Vector2(-2.5, 0.75)));
}
}