Skip to content

Commit

Permalink
SCENEGRAPH: extended test cases for issue #420
Browse files Browse the repository at this point in the history
  • Loading branch information
mgerhardy committed Mar 19, 2024
1 parent fd64a74 commit 4b0e010
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/modules/scenegraph/tests/SceneGraphTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,74 @@ TEST_F(SceneGraphTest, testKeyFrameTransformLerp) {
}
}

TEST_F(SceneGraphTest, testKeyFrameTransformParentRotation) {
SceneGraph sceneGraph;
voxel::RawVolume v(voxel::Region(0, 0));
int firstNodeId;
int secondNodeId;
{
SceneGraphNode node(SceneGraphNodeType::Model);
node.setVolume(&v, false);
node.setName("Parent");
SceneGraphTransform transform;
transform.setWorldOrientation(glm::quat(glm::vec3(glm::radians(180.0f), 0.0f, 0.0f)));
node.setTransform(0, transform);
firstNodeId = sceneGraph.emplace(core::move(node));
}
{
SceneGraphNode node(SceneGraphNodeType::Model);
node.setVolume(&v, false);
node.setName("Child");
secondNodeId = sceneGraph.emplace(core::move(node), firstNodeId);
}
sceneGraph.updateTransforms();
{
const SceneGraphNode &childNode2 = sceneGraph.node(secondNodeId);
const FrameTransform &transform = sceneGraph.transformForFrame(childNode2, 0);
EXPECT_FLOAT_EQ(glm::abs(glm::eulerAngles(transform.orientation).x), glm::radians(180.0f));
}
{
const SceneGraphNode &childNode2 = sceneGraph.node(secondNodeId);
const FrameTransform &transform = sceneGraph.transformForFrame(childNode2, 1);
EXPECT_FLOAT_EQ(glm::abs(glm::eulerAngles(transform.orientation).x), glm::radians(180.0f));
}
}

TEST_F(SceneGraphTest, testKeyFrameTransformParentRotation2) {
SceneGraph sceneGraph;
voxel::RawVolume v(voxel::Region(0, 0));
int firstNodeId;
int secondNodeId;
{
SceneGraphNode node(SceneGraphNodeType::Model);
node.setVolume(&v, false);
node.setName("Parent");
SceneGraphTransform transform0;
transform0.setWorldOrientation(glm::quat(glm::vec3(glm::radians(-180.0f), 0.0f, 0.0f)));
node.setTransform(0, transform0);
node.keyFrame(1).frameIdx = 40;
node.keyFrame(1).transform().setWorldOrientation(glm::quat(glm::vec3(0.0f, 0.0f, 0.0f)));
firstNodeId = sceneGraph.emplace(core::move(node));
}
{
SceneGraphNode node(SceneGraphNodeType::Model);
node.setVolume(&v, false);
node.setName("Child");
secondNodeId = sceneGraph.emplace(core::move(node), firstNodeId);
}
sceneGraph.updateTransforms();
{
const SceneGraphNode &childNode2 = sceneGraph.node(secondNodeId);
const FrameTransform &transform = sceneGraph.transformForFrame(childNode2, 0);
EXPECT_FLOAT_EQ(glm::abs(glm::eulerAngles(transform.orientation).x), glm::radians(180.0f));
}
{
const SceneGraphNode &childNode2 = sceneGraph.node(secondNodeId);
const FrameTransform &transform = sceneGraph.transformForFrame(childNode2, 20);
EXPECT_FLOAT_EQ(glm::abs(glm::eulerAngles(transform.orientation).x), glm::radians(90.0f));
}
}

TEST_F(SceneGraphTest, testSceneRegion) {
SceneGraph sceneGraph;
voxel::RawVolume v(voxel::Region(-3, 3));
Expand Down

0 comments on commit 4b0e010

Please sign in to comment.