From 51cd88b13c8f4d779a488881d5d8bd412eebf64d Mon Sep 17 00:00:00 2001 From: Matthew Mott Date: Mon, 29 Nov 2021 21:07:31 +0000 Subject: [PATCH] Add unit test for func_static translate after rotate This test is failing, consistent with the observed problems with models gaining additional rotations after each translation (introduced in a64abd187518645fa3). --- test/Entity.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/Entity.cpp b/test/Entity.cpp index 82ed21255a..670ca28701 100644 --- a/test/Entity.cpp +++ b/test/Entity.cpp @@ -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))); @@ -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