From 46e5056ba7c0c97e7edbfed6f35a5bd6d23f7418 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 18 Jun 2020 13:28:23 -0400 Subject: [PATCH] CMaterial: Make use of in-class initializers Same behavior, less code. --- src/Core/Resource/CMaterial.cpp | 30 ++---------------------------- src/Core/Resource/CMaterial.h | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 44 deletions(-) diff --git a/src/Core/Resource/CMaterial.cpp b/src/Core/Resource/CMaterial.cpp index 888c4785..407c93c8 100644 --- a/src/Core/Resource/CMaterial.cpp +++ b/src/Core/Resource/CMaterial.cpp @@ -12,38 +12,12 @@ uint64 CMaterial::sCurrentMaterial = 0; CColor CMaterial::sCurrentTint = CColor::White(); std::map CMaterial::smShaderMap; -CMaterial::CMaterial() - : mpShader(nullptr) - , mShaderStatus(EShaderStatus::NoShader) - , mRecalcHash(true) - , mVersion(EGame::Invalid) - , mOptions(EMaterialOption::None) - , mVtxDesc(EVertexAttribute::None) - , mBlendSrcFac(GL_ONE) - , mBlendDstFac(GL_ZERO) - , mLightingEnabled(true) - , mEchoesUnknownA(0) - , mEchoesUnknownB(0) - , mpIndirectTexture(nullptr) - , mpNextDrawPassMaterial(nullptr) - , mpBloomMaterial(nullptr) -{} +CMaterial::CMaterial() = default; CMaterial::CMaterial(EGame Version, FVertexDescription VtxDesc) - : mpShader(nullptr) - , mShaderStatus(EShaderStatus::NoShader) - , mRecalcHash(true) - , mVersion(Version) + : mVersion(Version) , mOptions(EMaterialOption::DepthWrite | EMaterialOption::ColorWrite) , mVtxDesc(VtxDesc) - , mBlendSrcFac(GL_ONE) - , mBlendDstFac(GL_ZERO) - , mLightingEnabled(true) - , mEchoesUnknownA(0) - , mEchoesUnknownB(0) - , mpIndirectTexture(nullptr) - , mpNextDrawPassMaterial(nullptr) - , mpBloomMaterial(nullptr) {} CMaterial::~CMaterial() diff --git a/src/Core/Resource/CMaterial.h b/src/Core/Resource/CMaterial.h index c15ae749..c7b20a29 100644 --- a/src/Core/Resource/CMaterial.h +++ b/src/Core/Resource/CMaterial.h @@ -74,23 +74,23 @@ private: static CColor sCurrentTint; // The tint for the currently bound material // Members - TString mName; // Name of the material - CShader *mpShader; // This material's generated shader. Created with GenerateShader(). - EShaderStatus mShaderStatus; // A status variable so that PWE won't crash if a shader fails to compile. - uint64 mParametersHash; // A hash of all the parameters that can identify this TEV setup. - bool mRecalcHash; // Indicates the hash needs to be recalculated. Set true when parameters are changed. + TString mName; // Name of the material + CShader *mpShader = nullptr; // This material's generated shader. Created with GenerateShader(). + EShaderStatus mShaderStatus{EShaderStatus::NoShader}; // A status variable so that PWE won't crash if a shader fails to compile. + uint64 mParametersHash = 0; // A hash of all the parameters that can identify this TEV setup. + bool mRecalcHash = true; // Indicates the hash needs to be recalculated. Set true when parameters are changed. - EGame mVersion; - FMaterialOptions mOptions; // See the EMaterialOption enum above - FVertexDescription mVtxDesc; // Descriptor of vertex attributes used by this material - std::array mKonstColors; // Konst color values for TEV - std::array mTevColors; // Initial TEV color register values (for MP3 materials only) - GLenum mBlendSrcFac; // Source blend factor - GLenum mBlendDstFac; // Dest blend factor - bool mLightingEnabled; // Color channel control flags; indicate whether lighting is enabled - uint32 mEchoesUnknownA; // First unknown value introduced in Echoes. Included for cooking. - uint32 mEchoesUnknownB; // Second unknown value introduced in Echoes. Included for cooking. - TResPtr mpIndirectTexture; // Optional texture used for the indirect stage for reflections + EGame mVersion{EGame::Invalid}; + FMaterialOptions mOptions{EMaterialOption::None}; // See the EMaterialOption enum above + FVertexDescription mVtxDesc{EVertexAttribute::None}; // Descriptor of vertex attributes used by this material + std::array mKonstColors; // Konst color values for TEV + std::array mTevColors; // Initial TEV color register values (for MP3 materials only) + GLenum mBlendSrcFac{GL_ONE}; // Source blend factor + GLenum mBlendDstFac{GL_ZERO}; // Dest blend factor + bool mLightingEnabled = true; // Color channel control flags; indicate whether lighting is enabled + uint32 mEchoesUnknownA = 0; // First unknown value introduced in Echoes. Included for cooking. + uint32 mEchoesUnknownB = 0; // Second unknown value introduced in Echoes. Included for cooking. + TResPtr mpIndirectTexture; // Optional texture used for the indirect stage for reflections std::vector> mPasses;