Skip to content

Commit

Permalink
Entity::Attachment now provides joint information
Browse files Browse the repository at this point in the history
Pass the already-parsed joint value from AttachmentData to the
Entity::Attachment functor parameter, and confirm this in the unit test of the
builder_guard AI.
  • Loading branch information
Matthew Mott committed Feb 10, 2021
1 parent aaf5134 commit df126d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/ientity.h
Expand Up @@ -245,6 +245,9 @@ class Entity

/// Vector offset where the attached entity should appear
Vector3 offset;

/// Optional model joint to use as origin
std::string joint;
};

/// A functor which can receive Attachment objects
Expand Down
9 changes: 8 additions & 1 deletion radiantcore/entity/AttachmentData.h
Expand Up @@ -107,9 +107,16 @@ class AttachmentData
{
for (auto i = _objects.begin(); i != _objects.end(); ++i)
{
// Locate attachment position
const AttachPos& pos = _positions.at(i->second.posName);

// Construct the functor argument
Entity::Attachment a;
a.eclass = i->second.className;
a.offset = _positions.at(i->second.posName).origin;
a.offset = pos.origin;
a.joint = pos.joint;

// Invoke the functor
func(a);
}
}
Expand Down
3 changes: 3 additions & 0 deletions test/Entity.cpp
Expand Up @@ -680,6 +680,9 @@ TEST_F(EntityTest, CreateAIEntity)
// Guard should have a hammer attachment
auto attachments = getAttachments(guard);
EXPECT_EQ(attachments.size(), 1);
EXPECT_EQ(attachments.front().eclass, "atdm:moveable_warhammer");
EXPECT_EQ(attachments.front().offset, Vector3(14, -6, -6));
EXPECT_EQ(attachments.front().joint, "Spine2");
}

}

0 comments on commit df126d9

Please sign in to comment.