Skip to content

Commit

Permalink
#5547: Add test rotating a brush with texture lock enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Oct 7, 2021
1 parent 9e6bed8 commit e6db9d5
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions test/TextureManipulation.cpp
Expand Up @@ -6,6 +6,7 @@
#include "algorithm/Primitives.h"
#include "scenelib.h"
#include "math/Matrix3.h"
#include "math/Quaternion.h"
#include "registry/registry.h"
#include "render/CameraView.h"
#include "algorithm/View.h"
Expand Down Expand Up @@ -538,8 +539,10 @@ TEST_F(TextureManipulationTest, NormalisePatch)
EXPECT_TRUE(math::isNear(patch->ctrlAt(2, 2).texcoord, { 0.648697, -3.27677 }, 0.01));
}

// Move a brush with texture lock enabled
TEST_F(TextureManipulationTest, MoveTextureLocked)
namespace
{

void performTextureLockBrushTransformationTest(const std::function<void(ITransformablePtr)>& doTransform)
{
registry::setValue(RKEY_ENABLE_TEXTURE_LOCK, true);

Expand All @@ -557,13 +560,12 @@ TEST_F(TextureManipulationTest, MoveTextureLocked)
oldTexCoords.push_back(vertex.texcoord);
}

auto transform = Node_getTransformable(brushNode);
auto transformable = Node_getTransformable(brushNode);

if (transform)
if (transformable)
{
transform->setType(TRANSFORM_PRIMITIVE);
transform->setTranslation(Vector3(45, 66, 100));
transform->freezeTransform();
doTransform(transformable);
transformable->freezeTransform();
}

// We need the texture coords to be up to date
Expand All @@ -577,3 +579,24 @@ TEST_F(TextureManipulationTest, MoveTextureLocked)
}

}

// Move a brush with texture lock enabled
TEST_F(TextureManipulationTest, MoveTextureLocked)
{
performTextureLockBrushTransformationTest([&](const ITransformablePtr& transformable)
{
transformable->setType(TRANSFORM_PRIMITIVE);
transformable->setTranslation(Vector3(45, 66, 100));
});
}

TEST_F(TextureManipulationTest, RotateTextureLocked)
{
performTextureLockBrushTransformationTest([&](const ITransformablePtr& transformable)
{
transformable->setType(TRANSFORM_PRIMITIVE);
transformable->setRotation(Quaternion::createForEulerXYZDegrees({ 5, 35, 75 }));
});
}

}

0 comments on commit e6db9d5

Please sign in to comment.