Fixed grid drawing at incorrect depth, fixed MP2 areas not loading correctly with the AnimSet loader changes

This commit is contained in:
parax0 2016-04-28 00:44:50 -06:00
parent c4268746f2
commit 7f3929d4ca
9 changed files with 75 additions and 52 deletions

View File

@ -298,6 +298,8 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS)
}
}
if (Loader.mVersion <= ePrime)
{
// Load Animation Set
u32 SetStart = rANCS.Tell();
SetStart = SetStart;
@ -341,6 +343,7 @@ CAnimSet* CAnimSetLoader::LoadANCS(IInputStream& rANCS)
Loader.pSet->mAnims.push_back(Anim);
}
}
}
return Loader.pSet;
}

View File

@ -464,16 +464,6 @@ CModel* CModelLoader::LoadCMDL(IInputStream& rCMDL)
{
Loader.mMaterials[iSet] = CMaterialLoader::LoadMaterialSet(rCMDL, Loader.mVersion);
// Toggle skinning on materials
if (Loader.mFlags.HasAnyFlags(eSkinnedModel))
{
for (u32 iMat = 0; iMat < Loader.mMaterials[iSet]->NumMaterials(); iMat++)
{
CMaterial *pMat = Loader.mMaterials[iSet]->MaterialByIndex(iMat);
pMat->SetVertexDescription(pMat->VtxDesc() | FVertexDescription(eBoneIndices | eBoneWeights));
}
}
if (Loader.mVersion < eCorruptionProto)
Loader.mpSectionMgr->ToNextSection();
}

View File

@ -122,7 +122,7 @@ void CModel::DrawSurface(FRenderOptions Options, u32 Surface, u32 MatSet)
SSurface *pSurf = mSurfaces[Surface];
CMaterial *pMat = mMaterialSets[MatSet]->MaterialByIndex(pSurf->MaterialID);
if ((!(Options & eEnableOccluders)) && (pMat->Options() & CMaterial::eOccluder))
if (!Options.HasFlag(eEnableOccluders) && pMat->Options().HasFlag(CMaterial::eOccluder))
return;
pMat->SetCurrent(Options);

View File

@ -0,0 +1,23 @@
#ifndef CGRIDRENDERABLE
#define CGRIDRENDERABLE
#include <Core/Render/CRenderer.h>
#include <Core/Render/IRenderable.h>
// Tiny helper to make sure the grid draws at the correct depth.
class CGridRenderable : public IRenderable
{
public:
void AddToRenderer(CRenderer *pRenderer, const SViewInfo&)
{
pRenderer->AddMesh(this, 0, CAABox::skOne, false, eDrawMesh);
}
void Draw(FRenderOptions, int, const SViewInfo&)
{
CDrawUtil::DrawGrid();
}
};
#endif // CGRIDRENDERABLE

View File

@ -49,14 +49,14 @@ void CCharacterEditorViewport::Paint()
{
mpRenderer->BeginFrame();
mCamera.LoadMatrices();
CDrawUtil::DrawGrid();
mGrid.AddToRenderer(mpRenderer, mViewInfo);
if (mpCharNode)
{
mpCharNode->AddToRenderer(mpRenderer, mViewInfo);
mpRenderer->RenderBuckets(mViewInfo);
}
mpRenderer->RenderBuckets(mViewInfo);
mpRenderer->EndFrame();
}

View File

@ -2,6 +2,7 @@
#define CCHARACTEREDITORVIEWPORT_H
#include "Editor/CBasicViewport.h"
#include "Editor/CGridRenderable.h"
#include <Core/Scene/CCharacterNode.h>
class CCharacterEditorViewport : public CBasicViewport
@ -9,6 +10,7 @@ class CCharacterEditorViewport : public CBasicViewport
Q_OBJECT
CCharacterNode *mpCharNode;
CGridRenderable mGrid;
CRenderer *mpRenderer;
u32 mHoverBone;

View File

@ -158,7 +158,8 @@ HEADERS += \
WorldEditor/CRepackInfoDialog.h \
CAboutDialog.h \
CharacterEditor/CCharacterEditor.h \
CharacterEditor/CCharacterEditorViewport.h
CharacterEditor/CCharacterEditorViewport.h \
CGridRenderable.h
# Source Files
SOURCES += \

View File

@ -56,13 +56,15 @@ void CModelEditorViewport::Paint()
if (!mpModelNode->Model())
{
if (mGridEnabled)
CDrawUtil::DrawGrid();
mGrid.AddToRenderer(mpRenderer, mViewInfo);
mpRenderer->RenderBuckets(mViewInfo);
}
else if (mMode == eDrawMesh)
{
if (mGridEnabled)
CDrawUtil::DrawGrid();
mGrid.AddToRenderer(mpRenderer, mViewInfo);
mpModelNode->AddToRenderer(mpRenderer, mViewInfo);
mpRenderer->RenderBuckets(mViewInfo);

View File

@ -2,6 +2,7 @@
#define CMODELEDITORVIEWPORT_H
#include "Editor/CBasicViewport.h"
#include "Editor/CGridRenderable.h"
#include <Core/Scene/CModelNode.h>
class CModelEditorViewport : public CBasicViewport
@ -13,6 +14,7 @@ public:
private:
EDrawMode mMode;
CGridRenderable mGrid;
CModelNode *mpModelNode;
CMaterial *mpActiveMaterial;
CRenderer *mpRenderer;