Skip to content

Commit

Permalink
#6145: Fix entites not being drag-resizable in entity selection mode,…
Browse files Browse the repository at this point in the history
… add corresponding test
  • Loading branch information
codereader committed Nov 2, 2022
1 parent cb11774 commit 6b8cb62
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions radiantcore/selection/manipulators/DragManipulator.cpp
Expand Up @@ -125,6 +125,9 @@ void DragManipulator::testSelectEntityMode(const VolumeTest& view, SelectionTest
{
selector.addSelectable(SelectionIntersection(0, 0), &_dragSelectable);
}

// Check for selectable faces
_resizeModeActive = algorithm::testSelectPlanes(selector, test);
}

void DragManipulator::testSelectComponentMode(const VolumeTest& view, SelectionTest& test, SelectionPool& selector)
Expand Down
33 changes: 33 additions & 0 deletions test/Selection.cpp
Expand Up @@ -962,6 +962,39 @@ TEST_F(OrthoViewSelectionTest, DragManipulateEntityByDirectHitEntityMode)
EXPECT_TRUE(math::isNear(originalAABB.getExtents(), newAABB.getExtents(), 0.01)) << "Item should not have changed form";
}

// Ortho: Resize entities using the drag manipulator in entity mode
TEST_F(OrthoViewSelectionTest, DragManipulateEntityByPlaneEntityMode)
{
loadMap("selection_test2.map");

GlobalSelectionSystem().setSelectionMode(selection::SelectionMode::Entity);
GlobalSelectionSystem().setActiveManipulator(selection::IManipulator::Drag);

auto worldspawn = GlobalMapModule().findOrInsertWorldspawn();
auto light = algorithm::getEntityByName(GlobalMapModule().getRoot(), "light_1");

// Select the light and attempt to drag-resize
Node_setSelected(light, true);
auto oldRadius = Node_getEntity(light)->getKeyValue("light_radius");
auto oldOrigin = Node_getEntity(light)->getKeyValue("origin");

// Drag starting from the right side of the bounding box
auto originalAABB = light->worldAABB();
performDragOperation(originalAABB.getOrigin() + Vector3(originalAABB.getExtents().x(), 0, 0) + 20);

if (registry::getValue<bool>(RKEY_DRAG_RESIZE_SYMMETRICALLY))
{
EXPECT_EQ(Node_getEntity(light)->getKeyValue("origin"), oldOrigin) << "Entity origin shouldn't have changed";
}
else
{
EXPECT_NE(Node_getEntity(light)->getKeyValue("origin"), oldOrigin) << "Entity origin should have changed";
}

auto newRadius = Node_getEntity(light)->getKeyValue("light_radius");
EXPECT_NE(newRadius, oldRadius) << "Light radius should have changed";
}

// Ortho: Move items using the drag manipulator in group part mode
TEST_F(OrthoViewSelectionTest, DragManipulateChildBrushByDirectHitGroupPartMode)
{
Expand Down

0 comments on commit 6b8cb62

Please sign in to comment.