From 7b81aa52684b3cfc881dc15adc2f10f66907d2d7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 11 Jun 2020 17:41:28 -0400 Subject: [PATCH] CMaterialPass: Simplify initialization code --- src/Core/Resource/CMaterialPass.cpp | 26 ++----------------- src/Core/Resource/CMaterialPass.h | 40 ++++++++++++++--------------- 2 files changed, 22 insertions(+), 44 deletions(-) diff --git a/src/Core/Resource/CMaterialPass.cpp b/src/Core/Resource/CMaterialPass.cpp index 23fc14ab..4527d501 100644 --- a/src/Core/Resource/CMaterialPass.cpp +++ b/src/Core/Resource/CMaterialPass.cpp @@ -4,33 +4,11 @@ #include CMaterialPass::CMaterialPass(CMaterial *pParent) - : mPassType("CUST") - , mSettings(EPassSettings::None) - , mpTexture(nullptr) - , mEnabled(true) - , mpParentMat(pParent) - , mColorOutput(kPrevReg) - , mAlphaOutput(kPrevReg) - , mKColorSel(kKonstOne) - , mKAlphaSel(kKonstOne) - , mRasSel(kRasColorNull) - , mTevColorScale(1.f) - , mTevAlphaScale(1.f) - , mTexCoordSource(0xFF) - , mAnimMode(EUVAnimMode::NoUVAnim) - , mTexSwapComps{'r', 'g', 'b', 'a'} + : mpParentMat(pParent) { - for (uint32 iParam = 0; iParam < 4; iParam++) - { - mColorInputs[iParam] = kZeroRGB; - mAlphaInputs[iParam] = kZeroAlpha; - mAnimParams[iParam] = 0.f; - } } -CMaterialPass::~CMaterialPass() -{ -} +CMaterialPass::~CMaterialPass() = default; std::unique_ptr CMaterialPass::Clone(CMaterial* pParent) { diff --git a/src/Core/Resource/CMaterialPass.h b/src/Core/Resource/CMaterialPass.h index 4bc6b247..0698c0ce 100644 --- a/src/Core/Resource/CMaterialPass.h +++ b/src/Core/Resource/CMaterialPass.h @@ -24,29 +24,29 @@ class CMaterialPass friend class CMaterialLoader; friend class CMaterialCooker; - CMaterial *mpParentMat; - CFourCC mPassType; - FPassSettings mSettings; + CMaterial *mpParentMat = nullptr; + CFourCC mPassType{"CUST"}; + FPassSettings mSettings{EPassSettings::None}; - ETevColorInput mColorInputs[4]; - ETevAlphaInput mAlphaInputs[4]; - ETevOutput mColorOutput; - ETevOutput mAlphaOutput; - ETevKSel mKColorSel; - ETevKSel mKAlphaSel; - ETevRasSel mRasSel; - float mTevColorScale; - float mTevAlphaScale; - uint32 mTexCoordSource; // Should maybe be an enum but worried about conflicts with EVertexDescriptionn - TResPtr mpTexture; - EUVAnimMode mAnimMode; - EUVConvolutedModeBType mAnimConvolutedModeBType; - float mAnimParams[8]; - char mTexSwapComps[4]; - bool mEnabled; + ETevColorInput mColorInputs[4] = {kZeroRGB, kZeroRGB, kZeroRGB, kZeroRGB}; + ETevAlphaInput mAlphaInputs[4] = {kZeroAlpha, kZeroAlpha, kZeroAlpha, kZeroAlpha}; + ETevOutput mColorOutput{kPrevReg}; + ETevOutput mAlphaOutput{kPrevReg}; + ETevKSel mKColorSel{kKonstOne}; + ETevKSel mKAlphaSel{kKonstOne}; + ETevRasSel mRasSel{kRasColorNull}; + float mTevColorScale = 1.0f; + float mTevAlphaScale = 1.0f; + uint32 mTexCoordSource = 0xFF; // Should maybe be an enum but worried about conflicts with EVertexDescriptionn + TResPtr mpTexture{nullptr}; + EUVAnimMode mAnimMode{EUVAnimMode::NoUVAnim}; + EUVConvolutedModeBType mAnimConvolutedModeBType{}; + float mAnimParams[8] = {}; + char mTexSwapComps[4] = {'r', 'g', 'b', 'a'}; + bool mEnabled = true; public: - CMaterialPass(CMaterial *pParent); + explicit CMaterialPass(CMaterial *pParent); ~CMaterialPass(); std::unique_ptr Clone(CMaterial *pParent); void HashParameters(CFNV1A& rHash);