Skip to content

Commit

Permalink
#5484: Projected lights don't rotate around their origin anymore: cha…
Browse files Browse the repository at this point in the history
…nge the getSelectAABB() implementation to always use the light origin as center point.
  • Loading branch information
codereader committed Jan 4, 2021
1 parent 1993988 commit bfe86f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
8 changes: 4 additions & 4 deletions radiantcore/entity/light/LightNode.cpp
Expand Up @@ -71,11 +71,11 @@ void LightNode::snapto(float snap) {

AABB LightNode::getSelectAABB() const
{
AABB returnValue = _light.lightAABB();
// Use the light origin as select AAB centerpoint
Vector3 extents;
default_extents(extents);

default_extents(returnValue.extents);

return returnValue;
return AABB(_light.getLightOrigin(), extents);
}

void LightNode::onLightRadiusChanged()
Expand Down
24 changes: 24 additions & 0 deletions test/Selection.cpp
Expand Up @@ -81,6 +81,30 @@ TEST_F(SelectionTest, LightBoundsChangedAfterRadiusChange)
EXPECT_TRUE(GlobalSelectionSystem().getWorkZone().bounds.getExtents().isEqual(changedBounds, 0.01));
}

// #5484: Projected lights don't rotate around their origin anymore
TEST_F(SelectionTest, SelectionBoundsOfProjectedLights)
{
auto eclass = GlobalEntityClassManager().findOrInsert("light", false);
auto entityNode = GlobalEntityModule().createEntity(eclass);

EXPECT_TRUE(Node_getLightNode(entityNode));
auto* entity = Node_getEntity(entityNode);

entity->setKeyValue("origin", "0 0 0");
entity->setKeyValue("light_target", "0 0 -256");
entity->setKeyValue("light_right", "128 0 0");
entity->setKeyValue("light_up", "0 128 0");
entity->setKeyValue("light_start", "");
entity->setKeyValue("light_end", "");

GlobalMapModule().getRoot()->addChildNode(entityNode);

Node_setSelected(entityNode, true);

// The center of the selection AABB needs to be at its origin
EXPECT_EQ(Node_getLightNode(entityNode)->getSelectAABB().getOrigin(), Vector3(0,0,0));
}

void constructCenteredXyView(render::View& view, const Vector3& origin)
{
double scale = 1.0;
Expand Down

0 comments on commit bfe86f7

Please sign in to comment.