Skip to content

Commit

Permalink
Add unit test for func_static translate after rotate
Browse files Browse the repository at this point in the history
This test is failing, consistent with the observed problems with models gaining
additional rotations after each translation (introduced in a64abd1).
  • Loading branch information
Matthew Mott committed Nov 29, 2021
1 parent 7029c29 commit 51cd88b
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test/Entity.cpp
Expand Up @@ -739,7 +739,7 @@ TEST_F(EntityTest, RotateFuncStatic)
torch.args().setKeyValue("origin", "0 0 0");
torch.args().setKeyValue("model", "models/torch.lwo");

// Set translation via the ITransformable interface
// Set rotation via the ITransformable interface
auto transformable = Node_getTransformable(torch.node);
ASSERT_TRUE(transformable);
transformable->setRotation(Quaternion::createForEulerXYZDegrees(Vector3(0, 0, 45)));
Expand All @@ -754,6 +754,27 @@ TEST_F(EntityTest, RotateFuncStatic)
EXPECT_EQ(torch.args().getKeyValue("origin"), "0 0 0");
}

TEST_F(EntityTest, TranslateFuncStaticAfterRotation)
{
auto torch = TestEntity::create("func_static");
torch.args().setKeyValue("origin", "0 0 0");
torch.args().setKeyValue("model", "models/torch.lwo");

// Set rotation via the ITransformable interface and freeze the transform
auto transformable = Node_getTransformable(torch.node);
ASSERT_TRUE(transformable);
transformable->setRotation(Quaternion::createForEulerXYZDegrees(Vector3(0, 0, 90)));
transformable->freezeTransform();
EXPECT_EQ(torch.args().getKeyValue("rotation"), "0 1 0 -1 0 0 0 0 1");

// Now add a translation
transformable->setTranslation(Vector3(-1200, 45, 962));
transformable->freezeTransform();

// Rotation must not have changed
EXPECT_EQ(torch.args().getKeyValue("rotation"), "0 1 0 -1 0 0 0 0 1");
}

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

0 comments on commit 51cd88b

Please sign in to comment.