From f425325f250a8b008d4c40cc37bed221d0171c07 Mon Sep 17 00:00:00 2001 From: codereader Date: Fri, 12 Nov 2021 10:03:43 +0100 Subject: [PATCH] #5807: Add test checking the behaviour of a mixed brush & single face selection. The Texture Tool Scene Graph recognises more nodes than necessary. --- test/TextureTool.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/TextureTool.cpp b/test/TextureTool.cpp index c74dd98a7e..111c877d7f 100644 --- a/test/TextureTool.cpp +++ b/test/TextureTool.cpp @@ -12,6 +12,7 @@ #include "scenelib.h" #include "algorithm/Primitives.h" #include "render/TextureToolView.h" +#include "algorithm/View.h" #include "selection/SelectionVolume.h" #include "Rectangle.h" @@ -192,6 +193,32 @@ TEST_F(TextureToolTest, SceneGraphRecognisesBrushes) EXPECT_GT(getTextureToolNodeCount(), 0) << "There should be some tex tool nodes now"; } +TEST_F(TextureToolTest, SceneGraphRecognisesSingleFaces) +{ + auto worldspawn = GlobalMapModule().findOrInsertWorldspawn(); + auto brush1 = algorithm::createCubicBrush(worldspawn, Vector3(0, 0, 0), "textures/numbers/1"); + auto brush2 = algorithm::createCubicBrush(worldspawn, Vector3(100, 100, 0), "textures/numbers/1"); + + auto faceUp = algorithm::findBrushFaceWithNormal(Node_getIBrush(brush1), Vector3(0, 0, 1)); + + // Position the camera top-down, similar to what an XY view is seeing + render::View viewFaceUp(true); + algorithm::constructCameraView(viewFaceUp, brush1->localAABB(), { 0, 0, -1 }, { -90, 0, 0 }); + + SelectionVolume testFaceUp(viewFaceUp); + GlobalSelectionSystem().selectPoint(testFaceUp, selection::SelectionSystem::eToggle, true); + + EXPECT_EQ(GlobalSelectionSystem().countSelectedComponents(), 1) << "1 Face component should be selected"; + EXPECT_EQ(getTextureToolNodeCount(), 1) << "There should be some exactly 1 tex tool node now"; + + Node_setSelected(brush2, true); + + EXPECT_EQ(GlobalSelectionSystem().countSelectedComponents(), 1) << "1 Face component should be selected"; + EXPECT_EQ(GlobalSelectionSystem().countSelected(), 1) << "1 Brush should be selected"; + + EXPECT_EQ(getTextureToolNodeCount(), 7) << "There should be 7 tex tool nodes now, 1 single face + 6 brush faces"; +} + TEST_F(TextureToolTest, SceneGraphRecognisesPatches) { auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();