Skip to content

Commit

Permalink
Add a test for a func_static's localToWorld()
Browse files Browse the repository at this point in the history
Confirm that the localToWorld matrix reflects changes in the "origin" key.
  • Loading branch information
Matthew Mott committed Feb 9, 2021
1 parent fc6119c commit 070757c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/Entity.cpp
Expand Up @@ -402,6 +402,27 @@ TEST_F(EntityTest, LightLocalToWorldFromOrigin)
EXPECT_EQ(light->localToWorld(), Matrix4::getTranslation(ORIGIN));
}

TEST_F(EntityTest, FuncStaticLocalToWorld)
{
auto funcStatic = createByClassName("func_static");
auto& spawnArgs = funcStatic->getEntity();
spawnArgs.setKeyValue("origin", "0 0 0");

// Initial localToWorld should be an identity matrix
EXPECT_EQ(funcStatic->localToWorld(), Matrix4::getIdentity());

// Set a new origin and make sure the localToWorld reflects the
// corresponding translation
const Vector3 MOVED(46, -128, 4096);
spawnArgs.setKeyValue("origin", string::to_string(MOVED));
EXPECT_EQ(funcStatic->localToWorld(),
Matrix4::getTranslation(MOVED));

// Clear transformation and get back to identity
spawnArgs.setKeyValue("origin", "0 0 0");
EXPECT_EQ(funcStatic->localToWorld(), Matrix4::getIdentity());
}

TEST_F(EntityTest, LightTransformedByParent)
{
// Parent a light to another entity (this isn't currently how the attachment
Expand Down

0 comments on commit 070757c

Please sign in to comment.