Skip to content

Commit

Permalink
Broadcast transformChanged() to attached entities
Browse files Browse the repository at this point in the history
Attached light now moves with the parent entity, which did not happen before
because the attached entity's transformChanged() method was never called to
invalidate its localToWorld when the parent entity moved.
  • Loading branch information
Matthew Mott committed Feb 9, 2021
1 parent 070757c commit 42b1d0b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
10 changes: 10 additions & 0 deletions radiantcore/entity/EntityNode.cpp
Expand Up @@ -148,6 +148,16 @@ void EntityNode::createAttachedEntities()
);
}

void EntityNode::transformChanged()
{
Node::transformChanged();

// Broadcast transformChanged to all attached entities so they can update
// their position
for (auto attached: _attachedEnts)
attached->transformChanged();
}

void EntityNode::onEntityClassChanged()
{
// By default, we notify the KeyObservers attached to this entity
Expand Down
1 change: 1 addition & 0 deletions radiantcore/entity/EntityNode.h
Expand Up @@ -103,6 +103,7 @@ class EntityNode :
// IEntityNode implementation
Entity& getEntity() override;
virtual void refreshModel() override;
void transformChanged() override;

// RenderEntity implementation
virtual float getShaderParm(int parmNum) const override;
Expand Down
4 changes: 0 additions & 4 deletions test/Entity.cpp
Expand Up @@ -602,10 +602,6 @@ TEST_F(EntityTest, RenderAttachedLightEntity)
RenderFixture rf(true /* solid mode */);
rf.renderSubGraph(torch);

// The node visitor should have visited the entity itself and one child node (a
// static model)
EXPECT_EQ(rf.nodesVisited, 2);

// There should be 3 renderables from the torch (because the entity has a
// shadowmesh and a collision mesh as well as the main model) and one from
// the light (the origin diamond).
Expand Down

0 comments on commit 42b1d0b

Please sign in to comment.