Skip to content

Commit

Permalink
#5532: Add some parser unit tests for deform variants
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Feb 21, 2021
1 parent 08aeb12 commit 66db22e
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
45 changes: 45 additions & 0 deletions test/Materials.cpp
Expand Up @@ -199,4 +199,49 @@ TEST_F(MaterialsTest, MaterialParserRenderbumpFlat)
checkRenderBumpArguments("textures/parsertest/renderBumpFlat2", "renderbumpflat");
}

TEST_F(MaterialsTest, MaterialParserDeform)
{
auto material = GlobalMaterialManager().getMaterialForName("textures/parsertest/deform1");
EXPECT_EQ(material->getDeformType(), Material::DEFORM_FLARE);
EXPECT_EQ(material->getDeformDeclName(), "");
EXPECT_EQ(material->getDeformExpression(0)->getExpressionString(), "1.5");
EXPECT_FALSE(material->getDeformExpression(1));
EXPECT_FALSE(material->getDeformExpression(2));

material = GlobalMaterialManager().getMaterialForName("textures/parsertest/deform2");
EXPECT_EQ(material->getDeformType(), Material::DEFORM_EXPAND);
EXPECT_EQ(material->getDeformDeclName(), "");
EXPECT_EQ(material->getDeformExpression(0)->getExpressionString(), "(0.1 * deformtesttable[time * (0.3 + time)] - global3)");
EXPECT_FALSE(material->getDeformExpression(1));
EXPECT_FALSE(material->getDeformExpression(2));

material = GlobalMaterialManager().getMaterialForName("textures/parsertest/deform3");
EXPECT_EQ(material->getDeformType(), Material::DEFORM_MOVE);
EXPECT_EQ(material->getDeformDeclName(), "");
EXPECT_EQ(material->getDeformExpression(0)->getExpressionString(), "(1.7 + time + 4.0 - global3)");
EXPECT_FALSE(material->getDeformExpression(1));
EXPECT_FALSE(material->getDeformExpression(2));

material = GlobalMaterialManager().getMaterialForName("textures/parsertest/deform4");
EXPECT_EQ(material->getDeformType(), Material::DEFORM_TURBULENT);
EXPECT_EQ(material->getDeformDeclName(), "deformtesttable");
EXPECT_EQ(material->getDeformExpression(0)->getExpressionString(), "time * 2.0");
EXPECT_EQ(material->getDeformExpression(1)->getExpressionString(), "(parm11 - 4.0)");
EXPECT_EQ(material->getDeformExpression(2)->getExpressionString(), "-1.0 * global5");

material = GlobalMaterialManager().getMaterialForName("textures/parsertest/deform5");
EXPECT_EQ(material->getDeformType(), Material::DEFORM_PARTICLE);
EXPECT_EQ(material->getDeformDeclName(), "testparticle");
EXPECT_FALSE(material->getDeformExpression(0));
EXPECT_FALSE(material->getDeformExpression(1));
EXPECT_FALSE(material->getDeformExpression(2));

material = GlobalMaterialManager().getMaterialForName("textures/parsertest/deform6");
EXPECT_EQ(material->getDeformType(), Material::DEFORM_PARTICLE2);
EXPECT_EQ(material->getDeformDeclName(), "testparticle");
EXPECT_FALSE(material->getDeformExpression(0));
EXPECT_FALSE(material->getDeformExpression(1));
EXPECT_FALSE(material->getDeformExpression(2));
}

}
31 changes: 31 additions & 0 deletions test/resources/tdm/materials/parsertest.mtr
Expand Up @@ -94,3 +94,34 @@ textures/parsertest/renderBumpFlat2
renderBumpflat models/hipoly
}

table deformtesttable { { 0, 0, 0, 0, 1, 1 } }

textures/parsertest/deform1
{
deform flare 1.5
}

textures/parsertest/deform2
{
deform expand (0.1 * deformtesttable[time * (0.3+time)] - global3)
}

textures/parsertest/deform3
{
deform move (1.7 + time + 4 - global3)
}

textures/parsertest/deform4
{
deform turbulent deformtesttable time*2 (parm11-4) -global5
}

textures/parsertest/deform5
{
deform particle testparticle
}

textures/parsertest/deform6
{
deform particle2 testparticle
}

0 comments on commit 66db22e

Please sign in to comment.