Skip to content

Commit

Permalink
#5571: Add two failing unit tests due to a problem with tables using …
Browse files Browse the repository at this point in the history
…negative lookup expressions
  • Loading branch information
codereader committed Mar 23, 2021
1 parent d068f28 commit 11d8e0c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
29 changes: 27 additions & 2 deletions test/Materials.cpp
Expand Up @@ -110,16 +110,41 @@ TEST_F(MaterialsTest, IdentifyAmbientLight)
EXPECT_FALSE(nonLight->isAmbientLight());
}

TEST_F(MaterialsTest, MaterialSinTableLookup)
TEST_F(MaterialsTest, MaterialTableLookup)
{
auto material = GlobalMaterialManager().getMaterial("textures/parsertest/expressions/sinTableLookup");

auto& stage = material->getAllLayers().front();
auto stage = material->getAllLayers().front();

// Set time to 5008 seconds, this is the value I happened to run into when debugging this in the engine
stage->evaluateExpressions(5008);

EXPECT_FLOAT_EQ(stage->getAlphaTest(), -0.00502608204f);

material = GlobalMaterialManager().getMaterial("textures/parsertest/expressions/cosTableLookup");

stage = material->getAllLayers().front();
stage->evaluateExpressions(1000);

EXPECT_FLOAT_EQ(stage->getAlphaTest(), 0.999998093f);
}

TEST_F(MaterialsTest, MaterialRotationEvaluation)
{
auto material = GlobalMaterialManager().getMaterial("textures/parsertest/expressions/rotationCalculation");

auto& stage = material->getAllLayers().front();

// Set time to 5008 seconds, this is the value I happened to run into when debugging this in the engine
stage->evaluateExpressions(5008);

auto expectedMatrix = Matrix4::byRows(
0.999998033, 0.000158024632, 0, 0,
-0.000158024632, 0.999998033, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
);
EXPECT_TRUE(stage->getTextureTransform().isEqual(expectedMatrix, TestEpsilon)) << "Expected:\n " << expectedMatrix << " but got:\n " << stage->getTextureTransform();
}

TEST_F(MaterialsTest, MaterialParserPolygonOffset)
Expand Down
20 changes: 19 additions & 1 deletion test/resources/tdm/materials/parsertest.mtr
Expand Up @@ -497,4 +497,22 @@ textures/parsertest/expressions/sinTableLookup
map _white
alphaTest sinTable[0.5008]
}
}
}

textures/parsertest/expressions/cosTableLookup
{
{
blend diffusemap
map _white
alphaTest cosTable[-0.000025]
}
}

textures/parsertest/expressions/rotationCalculation
{
{
blend diffusemap
map _white
rotate 0.005 * sintable [ time * 0.1]
}
}

0 comments on commit 11d8e0c

Please sign in to comment.