From af94b54acfa9630f1767650a8ec988b2cd6d2540 Mon Sep 17 00:00:00 2001 From: parax0 Date: Sat, 16 Jan 2016 13:32:40 -0700 Subject: [PATCH] Fixed lighting mode in EGMC editor, disabled EGMC editor outside MP2/3, fixed a crash in the anim params editor --- src/Core/Resource/CAnimationParameters.cpp | 2 +- src/Core/Scene/CModelNode.cpp | 29 +++++++++++++++++----- src/Core/Scene/CModelNode.h | 6 ++--- src/Core/Scene/CScene.cpp | 2 +- src/Editor/Widgets/WAnimParamsEditor.cpp | 2 +- src/Editor/WorldEditor/CWorldEditor.cpp | 8 ++++-- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/Core/Resource/CAnimationParameters.cpp b/src/Core/Resource/CAnimationParameters.cpp index b60d1beb..d9dfd56a 100644 --- a/src/Core/Resource/CAnimationParameters.cpp +++ b/src/Core/Resource/CAnimationParameters.cpp @@ -112,7 +112,7 @@ u32 CAnimationParameters::Unknown(u32 index) // ************ SETTERS ************ void CAnimationParameters::SetResource(CResource *pRes) { - if ((pRes->Type() == eAnimSet) || (pRes->Type() == eCharacter)) + if (!pRes || (pRes->Type() == eAnimSet) || (pRes->Type() == eCharacter)) { mpCharSet = pRes; mNodeIndex = 0; diff --git a/src/Core/Scene/CModelNode.cpp b/src/Core/Scene/CModelNode.cpp index d7e6c579..6decb1b7 100644 --- a/src/Core/Scene/CModelNode.cpp +++ b/src/Core/Scene/CModelNode.cpp @@ -8,7 +8,7 @@ CModelNode::CModelNode(CScene *pScene, CSceneNode *pParent, CModel *pModel) : CS { SetModel(pModel); mScale = CVector3f(1.f); - mLightingEnabled = true; + mWorldModel = false; mForceAlphaOn = false; mEnableScanOverlay = false; mTintColor = CColor::skWhite; @@ -39,21 +39,38 @@ void CModelNode::Draw(FRenderOptions Options, int ComponentIndex, const SViewInf if (!mpModel) return; if (mForceAlphaOn) Options = (FRenderOptions) (Options & ~eNoAlpha); - if (mLightingEnabled) + if (!mWorldModel) { CGraphics::SetDefaultLighting(); CGraphics::UpdateLightBlock(); CGraphics::sVertexBlock.COLOR0_Amb = CGraphics::skDefaultAmbientColor; + CGraphics::sPixelBlock.LightmapMultiplier = 1.f; + CGraphics::sPixelBlock.TevColor = CColor::skWhite; } else { - CGraphics::sNumLights = 0; - CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack; + bool IsLightingEnabled = CGraphics::sLightMode == CGraphics::eWorldLighting || ViewInfo.GameMode; + + if (IsLightingEnabled) + { + CGraphics::sNumLights = 0; + CGraphics::sVertexBlock.COLOR0_Amb = CColor::skBlack; + CGraphics::sPixelBlock.LightmapMultiplier = 1.f; + CGraphics::UpdateLightBlock(); + } + + else + { + LoadLights(ViewInfo); + if (CGraphics::sLightMode == CGraphics::eNoLighting) + CGraphics::sVertexBlock.COLOR0_Amb = CColor::skWhite; + } + + float Mul = CGraphics::sWorldLightMultiplier; + CGraphics::sPixelBlock.TevColor = CColor(Mul,Mul,Mul); } - CGraphics::sPixelBlock.TevColor = CColor::skWhite; CGraphics::sPixelBlock.TintColor = TintColor(ViewInfo); - CGraphics::sPixelBlock.LightmapMultiplier = 1.f; LoadModelMatrix(); if (ComponentIndex < 0) diff --git a/src/Core/Scene/CModelNode.h b/src/Core/Scene/CModelNode.h index 152e753b..795994f4 100644 --- a/src/Core/Scene/CModelNode.h +++ b/src/Core/Scene/CModelNode.h @@ -8,7 +8,7 @@ class CModelNode : public CSceneNode { TResPtr mpModel; u32 mActiveMatSet; - bool mLightingEnabled; + bool mWorldModel; bool mForceAlphaOn; CColor mTintColor; bool mEnableScanOverlay; @@ -29,7 +29,7 @@ public: void SetModel(CModel *pModel); inline void SetMatSet(u32 MatSet) { mActiveMatSet = MatSet; } - inline void SetDynamicLighting(bool Enable) { mLightingEnabled = Enable; } + inline void SetWorldModel(bool World) { mWorldModel = World; } inline void ForceAlphaEnabled(bool Enable) { mForceAlphaOn = Enable; } inline void SetTintColor(const CColor& rkTintColor) { mTintColor = rkTintColor; } inline void ClearTintColor() { mTintColor = CColor::skWhite; } @@ -37,7 +37,7 @@ public: inline void SetScanOverlayColor(const CColor& rkColor) { mScanOverlayColor = rkColor; } inline CModel* Model() const { return mpModel; } inline u32 MatSet() const { return mActiveMatSet; } - inline bool IsDynamicLightingEnabled() const { return mLightingEnabled; } + inline bool IsWorldModel() const { return mWorldModel; } inline u32 FindMeshID() const { return mpModel->GetSurface(0)->MeshID; } }; diff --git a/src/Core/Scene/CScene.cpp b/src/Core/Scene/CScene.cpp index 6c0bd473..7a9141ff 100644 --- a/src/Core/Scene/CScene.cpp +++ b/src/Core/Scene/CScene.cpp @@ -106,7 +106,7 @@ void CScene::SetActiveArea(CGameArea *pArea) CModel *pModel = mpArea->GetTerrainModel(iMdl); CModelNode *pNode = CreateModelNode(pModel); pNode->SetName("World Model " + TString::FromInt32(iMdl, 0, 10)); - pNode->SetDynamicLighting(false); + pNode->SetWorldModel(true); } CreateCollisionNode(mpArea->GetCollision()); diff --git a/src/Editor/Widgets/WAnimParamsEditor.cpp b/src/Editor/Widgets/WAnimParamsEditor.cpp index ada08477..d56fb171 100644 --- a/src/Editor/Widgets/WAnimParamsEditor.cpp +++ b/src/Editor/Widgets/WAnimParamsEditor.cpp @@ -67,7 +67,7 @@ void WAnimParamsEditor::SetParameters(const CAnimationParameters& params) void WAnimParamsEditor::OnResourceChanged(QString path) { CResource *pRes = gResCache.GetResource(path.toStdString()); - if (pRes->Type() != eAnimSet) pRes = nullptr; + if (pRes && pRes->Type() != eAnimSet) pRes = nullptr; mParams.SetResource(pRes); emit ParametersChanged(mParams); diff --git a/src/Editor/WorldEditor/CWorldEditor.cpp b/src/Editor/WorldEditor/CWorldEditor.cpp index 471cd76e..a95ecc5d 100644 --- a/src/Editor/WorldEditor/CWorldEditor.cpp +++ b/src/Editor/WorldEditor/CWorldEditor.cpp @@ -150,16 +150,20 @@ void CWorldEditor::SetArea(CWorld *pWorld, CGameArea *pArea) // Default bloom to Fake Bloom for Metroid Prime 3; disable for other games if (mpWorld->Version() == eCorruption) { - ui->menuBloom->setEnabled(true); + ui->menuBloom->setVisible(true); on_ActionFakeBloom_triggered(); } else { - ui->menuBloom->setEnabled(false); + ui->menuBloom->setVisible(false); on_ActionNoBloom_triggered(); } + // Disable EGMC editing for Prime 1 and DKCR + bool AllowEGMC = ( (mpWorld->Version() >= eEchoesDemo) && (mpWorld->Version() <= eCorruption) ); + ui->ActionEditPoiToWorldMap->setVisible(AllowEGMC); + // Set up sidebar tabs CMasterTemplate *pMaster = CMasterTemplate::GetMasterForGame(mpArea->Version()); ui->InstancesTabContents->SetMaster(pMaster);