Skip to content

Commit

Permalink
#5565: Changes to the global material properties are notifying observers
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Mar 25, 2021
1 parent a0db37e commit 11f7cb9
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions radiantcore/shaders/CShader.cpp
Expand Up @@ -51,12 +51,14 @@ void CShader::setSortRequest(float sortRequest)
{
ensureTemplateCopy();
_template->setSortRequest(sortRequest);
_sigMaterialModified.emit();
}

void CShader::resetSortReqest()
{
ensureTemplateCopy();
_template->resetSortReqest();
_sigMaterialModified.emit();
}

float CShader::getPolygonOffset() const
Expand All @@ -68,6 +70,7 @@ void CShader::setPolygonOffset(float offset)
{
ensureTemplateCopy();
_template->setPolygonOffset(offset);
_sigMaterialModified.emit();
}

TexturePtr CShader::getEditorImage()
Expand Down Expand Up @@ -97,6 +100,7 @@ void CShader::setLightFalloffExpressionFromString(const std::string& expressionS
{
ensureTemplateCopy();
_template->setLightFalloffExpressionFromString(expressionString);
_sigMaterialModified.emit();
}

IShaderLayer::MapType CShader::getLightFalloffCubeMapType()
Expand All @@ -108,6 +112,7 @@ void CShader::setLightFalloffCubeMapType(IShaderLayer::MapType type)
{
ensureTemplateCopy();
_template->setLightFalloffCubeMapType(type);
_sigMaterialModified.emit();
}

/*
Expand Down Expand Up @@ -142,11 +147,6 @@ TexturePtr CShader::lightFalloffImage() {
return _texLightFalloff;
}



/*
* Return name of shader.
*/
std::string CShader::getName() const
{
return _name;
Expand All @@ -161,6 +161,7 @@ void CShader::setDescription(const std::string& description)
{
ensureTemplateCopy();
_template->setDescription(description);
_sigMaterialModified.emit();
}

bool CShader::IsInUse() const {
Expand All @@ -181,12 +182,14 @@ void CShader::setMaterialFlag(Flags flag)
{
ensureTemplateCopy();
_template->setMaterialFlag(flag);
_sigMaterialModified.emit();
}

void CShader::clearMaterialFlag(Flags flag)
{
ensureTemplateCopy();
_template->clearMaterialFlag(flag);
_sigMaterialModified.emit();
}

bool CShader::IsDefault() const
Expand All @@ -204,6 +207,7 @@ void CShader::setCullType(CullType type)
{
ensureTemplateCopy();
_template->setCullType(type);
_sigMaterialModified.emit();
}

ClampType CShader::getClampType() const
Expand All @@ -215,6 +219,7 @@ void CShader::setClampType(ClampType type)
{
ensureTemplateCopy();
_template->setClampType(type);
_sigMaterialModified.emit();
}

int CShader::getSurfaceFlags() const
Expand All @@ -226,12 +231,14 @@ void CShader::setSurfaceFlag(Material::SurfaceFlags flag)
{
ensureTemplateCopy();
_template->setSurfaceFlag(flag);
_sigMaterialModified.emit();
}

void CShader::clearSurfaceFlag(Material::SurfaceFlags flag)
{
ensureTemplateCopy();
_template->clearSurfaceFlag(flag);
_sigMaterialModified.emit();
}

Material::SurfaceType CShader::getSurfaceType() const
Expand All @@ -243,6 +250,7 @@ void CShader::setSurfaceType(SurfaceType type)
{
ensureTemplateCopy();
_template->setSurfaceType(type);
_sigMaterialModified.emit();
}

Material::DeformType CShader::getDeformType() const
Expand All @@ -269,6 +277,7 @@ void CShader::setSpectrum(int spectrum)
{
ensureTemplateCopy();
_template->setSpectrum(spectrum);
_sigMaterialModified.emit();
}

Material::DecalInfo CShader::getDecalInfo() const
Expand Down Expand Up @@ -314,6 +323,8 @@ void CShader::revertModifications()
// We need to update that layer reference vector on change
unrealise();
realise();

_sigMaterialModified.emit();
}

sigc::signal<void>& CShader::sig_materialChanged()
Expand Down Expand Up @@ -360,11 +371,10 @@ void CShader::unrealiseLighting()
_layers.clear();
}

/*
* Set name of shader.
*/
void CShader::setName(const std::string& name) {
void CShader::setName(const std::string& name)
{
_name = name;
_sigMaterialModified.emit();
}

IShaderLayer* CShader::firstLayer() const
Expand All @@ -391,6 +401,8 @@ std::size_t CShader::addLayer(IShaderLayer::Type type)
unrealiseLighting();
realiseLighting();

_sigMaterialModified.emit();

return newIndex;
}

Expand All @@ -402,6 +414,8 @@ void CShader::removeLayer(std::size_t index)

unrealiseLighting();
realiseLighting();

_sigMaterialModified.emit();
}

void CShader::swapLayerPosition(std::size_t first, std::size_t second)
Expand All @@ -412,6 +426,8 @@ void CShader::swapLayerPosition(std::size_t first, std::size_t second)

unrealiseLighting();
realiseLighting();

_sigMaterialModified.emit();
}

std::size_t CShader::duplicateLayer(std::size_t index)
Expand All @@ -423,6 +439,8 @@ std::size_t CShader::duplicateLayer(std::size_t index)
unrealiseLighting();
realiseLighting();

_sigMaterialModified.emit();

return newIndex;
}

Expand Down Expand Up @@ -459,24 +477,28 @@ void CShader::setIsAmbientLight(bool newValue)
{
ensureTemplateCopy();
_template->setIsAmbientLight(newValue);
_sigMaterialModified.emit();
}

void CShader::setIsBlendLight(bool newValue)
{
ensureTemplateCopy();
_template->setIsBlendLight(newValue);
_sigMaterialModified.emit();
}

void CShader::setIsFogLight(bool newValue)
{
ensureTemplateCopy();
_template->setIsFogLight(newValue);
_sigMaterialModified.emit();
}

void CShader::setIsCubicLight(bool newValue)
{
ensureTemplateCopy();
_template->setIsCubicLight(newValue);
_sigMaterialModified.emit();
}


Expand Down Expand Up @@ -509,7 +531,8 @@ bool CShader::isVisible() const {
return _visible;
}

void CShader::setVisible(bool visible) {
void CShader::setVisible(bool visible)
{
_visible = visible;
}

Expand Down

0 comments on commit 11f7cb9

Please sign in to comment.