Skip to content

Commit

Permalink
#5565: Export qer_editorimage
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 26, 2021
1 parent 7d0aeaf commit 84986ba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
5 changes: 5 additions & 0 deletions radiantcore/shaders/MaterialSourceGenerator.cpp
Expand Up @@ -355,6 +355,11 @@ std::ostream& operator<<(std::ostream& stream, ShaderTemplate& shaderTemplate)
{
stream << "\n";

if (shaderTemplate.getEditorTexture())
{
stream << "\tqer_editorimage " << shaderTemplate.getEditorTexture()->getExpressionString() << "\n";
}

if (shaderTemplate.getSurfaceType() != Material::SURFTYPE_DEFAULT)
{
stream << "\t" << getStringForSurfaceType(shaderTemplate.getSurfaceType()) << "\n";
Expand Down
8 changes: 1 addition & 7 deletions radiantcore/shaders/ShaderTemplate.cpp
Expand Up @@ -79,13 +79,7 @@ void ShaderTemplate::setEditorImageExpressionFromString(const std::string& expre
{
if (!_parsed) parseDefinition();

if (expression.empty())
{
_editorTex.reset();
return;
}

_editorTex = MapExpression::createForString(expression);
_editorTex = !expression.empty() ? MapExpression::createForString(expression) : MapExpressionPtr();
onTemplateChanged();
}

Expand Down
13 changes: 13 additions & 0 deletions test/MaterialExport.cpp
Expand Up @@ -1008,4 +1008,17 @@ TEST_F(MaterialExportTest, FragmentPrograms)
expectDefinitionContains(material, "fragmentMap 2 temp/texture");
}

TEST_F(MaterialExportTest, EditorImage)
{
auto material = GlobalMaterialManager().getMaterial("textures/exporttest/empty");

EXPECT_EQ(string::trim_copy(material->getDefinition()), "");

material->setEditorImageExpressionFromString("textures/numbers/0.tga");
expectDefinitionContains(material, "qer_editorimage textures/numbers/0.tga");

material->setEditorImageExpressionFromString("");
expectDefinitionDoesNotContain(material, "qer_editorimage");
}

}

0 comments on commit 84986ba

Please sign in to comment.