Fixed lighting mode in EGMC editor, disabled EGMC editor outside MP2/3, fixed a crash in the anim params editor

This commit is contained in:
parax0 2016-01-16 13:32:40 -07:00
parent 440c3ad484
commit af94b54acf
6 changed files with 35 additions and 14 deletions

View File

@ -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;

View File

@ -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
{
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)

View File

@ -8,7 +8,7 @@ class CModelNode : public CSceneNode
{
TResPtr<CModel> 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; }
};

View File

@ -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());

View File

@ -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);

View File

@ -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);