CMaterial: Implicit conversion to bool cleanup

This commit is contained in:
Lioncash 2020-06-22 03:26:45 -04:00
parent 9c8b65c629
commit d52b05d71c
1 changed files with 20 additions and 20 deletions

View File

@ -97,25 +97,25 @@ void CMaterial::GenerateShader(bool AllowRegen /*= true*/)
void CMaterial::ClearShader() void CMaterial::ClearShader()
{ {
if (mpShader) if (mpShader == nullptr)
return;
const auto Find = smShaderMap.find(mParametersHash);
ASSERT(Find != smShaderMap.cend());
SMaterialShader& rShader = Find->second;
ASSERT(rShader.pShader == mpShader);
rShader.NumReferences--;
if (rShader.NumReferences == 0)
{ {
auto Find = smShaderMap.find(mParametersHash); delete mpShader;
ASSERT(Find != smShaderMap.end()); smShaderMap.erase(Find);
SMaterialShader& rShader = Find->second;
ASSERT(rShader.pShader == mpShader);
rShader.NumReferences--;
if (rShader.NumReferences == 0)
{
delete mpShader;
smShaderMap.erase(Find);
}
mpShader = nullptr;
mShaderStatus = EShaderStatus::NoShader;
} }
mpShader = nullptr;
mShaderStatus = EShaderStatus::NoShader;
} }
bool CMaterial::SetCurrent(FRenderOptions Options) bool CMaterial::SetCurrent(FRenderOptions Options)
@ -133,7 +133,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
// Set RGB blend equation - force to ZERO/ONE if alpha is disabled // Set RGB blend equation - force to ZERO/ONE if alpha is disabled
GLenum srcRGB, dstRGB, srcAlpha, dstAlpha; GLenum srcRGB, dstRGB, srcAlpha, dstAlpha;
if (Options & ERenderOption::NoAlpha) { if ((Options & ERenderOption::NoAlpha) != 0) {
srcRGB = GL_ONE; srcRGB = GL_ONE;
dstRGB = GL_ZERO; dstRGB = GL_ZERO;
} else { } else {
@ -141,7 +141,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
dstRGB = mBlendDstFac; dstRGB = mBlendDstFac;
} }
if (mOptions & EMaterialOption::ZeroDestAlpha) { if ((mOptions & EMaterialOption::ZeroDestAlpha) != 0) {
srcAlpha = GL_ZERO; srcAlpha = GL_ZERO;
dstAlpha = GL_ZERO; dstAlpha = GL_ZERO;
} else { } else {
@ -164,7 +164,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
// COLOR0_Amb,Mat is initialized by the node instead of by the material // COLOR0_Amb,Mat is initialized by the node instead of by the material
// Set depth write - force on if alpha is disabled (lots of weird depth issues otherwise) // Set depth write - force on if alpha is disabled (lots of weird depth issues otherwise)
if ((mOptions & EMaterialOption::DepthWrite) || (Options & ERenderOption::NoAlpha)) if ((mOptions & EMaterialOption::DepthWrite) != 0 || (Options & ERenderOption::NoAlpha) != 0)
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
else else
glDepthMask(GL_FALSE); glDepthMask(GL_FALSE);