Skip to content

Commit

Permalink
#5565: Export DecalInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 25, 2021
1 parent 29a9de2 commit d80bbcf
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
12 changes: 12 additions & 0 deletions radiantcore/shaders/MaterialSourceGenerator.cpp
Expand Up @@ -134,6 +134,18 @@ std::ostream& operator<<(std::ostream& stream, ShaderTemplate& shaderTemplate)
}
}

// DecalInfo
if (shaderTemplate.getParseFlags() & Material::PF_HasDecalInfo)
{
const auto& decalInfo = shaderTemplate.getDecalInfo();
stream << "\tdecalinfo " << (decalInfo.stayMilliSeconds / 1000.0f) << " "
<< (decalInfo.fadeMilliSeconds / 1000.0f) << " "
<< "( " << decalInfo.startColour.x() << " " << decalInfo.startColour.y() << " "
<< decalInfo.startColour.z() << " " << decalInfo.startColour.w() << " ) "
<< "( " << decalInfo.endColour.x() << " " << decalInfo.endColour.y() << " "
<< decalInfo.endColour.z() << " " << decalInfo.endColour.w() << " )\n";
}

for (const auto& layer : shaderTemplate.getLayers())
{
stream << "\t{\n";
Expand Down
11 changes: 11 additions & 0 deletions test/MaterialExport.cpp
Expand Up @@ -266,4 +266,15 @@ TEST_F(MaterialExportTest, Deform)
expectDefinitionContains(material, "deform particle2 testparticle");
}

TEST_F(MaterialExportTest, DecalInfo)
{
auto material = GlobalMaterialManager().getMaterial("textures/exporttest/decalinfo");
expectDefinitionContains(material, "decalinfo");

// Mark the definition as modified by setting the description
material->setDescription("-");

expectDefinitionContains(material, "decalinfo 14.3 1.5 ( 0.9 0.8 0.7 0.6 ) ( 0.5 0.5 0.4 0.3 )");
}

}
17 changes: 17 additions & 0 deletions test/Materials.cpp
Expand Up @@ -936,4 +936,21 @@ TEST_F(MaterialsTest, MaterialParserLightfallOff)
EXPECT_EQ(material->getLightFalloffExpression()->getExpressionString(), "lights/squarelight1a");
}

TEST_F(MaterialsTest, MaterialParserDecalInfo)
{
auto material = GlobalMaterialManager().getMaterial("textures/parsertest/decalinfo");

EXPECT_EQ(material->getDecalInfo().stayMilliSeconds, 14300);
EXPECT_EQ(material->getDecalInfo().fadeMilliSeconds, 1500);

EXPECT_NEAR(material->getDecalInfo().startColour.x(), 0.9, TestEpsilon);
EXPECT_NEAR(material->getDecalInfo().startColour.y(), 0.8, TestEpsilon);
EXPECT_NEAR(material->getDecalInfo().startColour.z(), 0.7, TestEpsilon);
EXPECT_NEAR(material->getDecalInfo().startColour.w(), 0.6, TestEpsilon);

EXPECT_NEAR(material->getDecalInfo().endColour.x(), 0.5, TestEpsilon);
EXPECT_NEAR(material->getDecalInfo().endColour.y(), 0.5, TestEpsilon);
EXPECT_NEAR(material->getDecalInfo().endColour.z(), 0.4, TestEpsilon);
EXPECT_NEAR(material->getDecalInfo().endColour.w(), 0.3, TestEpsilon);
}
}
7 changes: 6 additions & 1 deletion test/resources/tdm/materials/exporttest.mtr
Expand Up @@ -52,4 +52,9 @@ textures/exporttest/deform5
textures/exporttest/deform6
{
deform particle2 testparticle
}
}

textures/exporttest/decalinfo
{
decalinfo 14.3 1.5 ( 0.9 0.8 0.7 0.6 ) (0.5 0.5 0.4 0.3)
}
6 changes: 6 additions & 0 deletions test/resources/tdm/materials/parsertest.mtr
Expand Up @@ -516,3 +516,9 @@ textures/parsertest/expressions/rotationCalculation
rotate 0.005 * sintable [ time * 0.1]
}
}

textures/parsertest/decalinfo
{
decalinfo 14.3 1.5 ( 0.9 0.8 0.7 0.6 ) (0.5 0.5 0.4 0.3)
}

0 comments on commit d80bbcf

Please sign in to comment.