mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-06-17 12:03:34 +00:00
commit
1fb554fa4c
@ -6,23 +6,7 @@
|
||||
|
||||
const bool gkForceDisableCompression = false;
|
||||
|
||||
CAreaCooker::CAreaCooker()
|
||||
: mGeometrySecNum(-1)
|
||||
, mSCLYSecNum(-1)
|
||||
, mSCGNSecNum(-1)
|
||||
, mCollisionSecNum(-1)
|
||||
, mUnknownSecNum(-1)
|
||||
, mLightsSecNum(-1)
|
||||
, mVISISecNum(-1)
|
||||
, mPATHSecNum(-1)
|
||||
, mAROTSecNum(-1)
|
||||
, mFFFFSecNum(-1)
|
||||
, mPTLASecNum(-1)
|
||||
, mEGMCSecNum(-1)
|
||||
, mDepsSecNum(-1)
|
||||
, mModulesSecNum(-1)
|
||||
{
|
||||
}
|
||||
CAreaCooker::CAreaCooker() = default;
|
||||
|
||||
void CAreaCooker::DetermineSectionNumbersPrime()
|
||||
{
|
||||
@ -49,8 +33,8 @@ void CAreaCooker::DetermineSectionNumbersPrime()
|
||||
break;
|
||||
}
|
||||
|
||||
for (uint32 iMesh = 0; iMesh < mpArea->mWorldModels.size(); iMesh++)
|
||||
GeometrySections += mpArea->mWorldModels[iMesh]->GetSurfaceCount();
|
||||
for (const auto& worldModel : mpArea->mWorldModels)
|
||||
GeometrySections += worldModel->GetSurfaceCount();
|
||||
|
||||
// Set section numbers
|
||||
uint32 SecNum = GeometrySections;
|
||||
@ -83,13 +67,16 @@ void CAreaCooker::DetermineSectionNumbersCorruption()
|
||||
{
|
||||
// Because we're copying these from the original file (because not all the numbers
|
||||
// are present in every file), we don't care about any of these except SCLY and SCGN.
|
||||
for (uint32 iNum = 0; iNum < mpArea->mSectionNumbers.size(); iNum++)
|
||||
for (const auto& num : mpArea->mSectionNumbers)
|
||||
{
|
||||
CGameArea::SSectionNumber& rNum = mpArea->mSectionNumbers[iNum];
|
||||
if (rNum.SectionID == "SOBJ") mSCLYSecNum = rNum.Index;
|
||||
else if (rNum.SectionID == "SGEN") mSCGNSecNum = rNum.Index;
|
||||
else if (rNum.SectionID == "DEPS") mDepsSecNum = rNum.Index;
|
||||
else if (rNum.SectionID == "RSOS") mModulesSecNum = rNum.Index;
|
||||
if (num.SectionID == "SOBJ")
|
||||
mSCLYSecNum = num.Index;
|
||||
else if (num.SectionID == "SGEN")
|
||||
mSCGNSecNum = num.Index;
|
||||
else if (num.SectionID == "DEPS")
|
||||
mDepsSecNum = num.Index;
|
||||
else if (num.SectionID == "RSOS")
|
||||
mModulesSecNum = num.Index;
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,8 +113,8 @@ void CAreaCooker::WritePrimeHeader(IOutputStream& rOut)
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
}
|
||||
|
||||
for (uint32 iSec = 0; iSec < mSectionSizes.size(); iSec++)
|
||||
rOut.WriteLong(mSectionSizes[iSec]);
|
||||
for (const uint32 size : mSectionSizes)
|
||||
rOut.WriteLong(size);
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
|
||||
if (mVersion >= EGame::Echoes)
|
||||
@ -146,33 +133,31 @@ void CAreaCooker::WriteCorruptionHeader(IOutputStream& rOut)
|
||||
rOut.WriteLong(mpArea->mSectionNumbers.size());
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
|
||||
for (uint32 iSec = 0; iSec < mSectionSizes.size(); iSec++)
|
||||
rOut.WriteLong(mSectionSizes[iSec]);
|
||||
for (const uint32 size : mSectionSizes)
|
||||
rOut.WriteLong(size);
|
||||
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
|
||||
WriteCompressionHeader(rOut);
|
||||
|
||||
for (uint32 iNum = 0; iNum < mpArea->mSectionNumbers.size(); iNum++)
|
||||
for (const auto& num : mpArea->mSectionNumbers)
|
||||
{
|
||||
CGameArea::SSectionNumber& rNum = mpArea->mSectionNumbers[iNum];
|
||||
rOut.WriteLong(rNum.SectionID.ToLong());
|
||||
rOut.WriteLong(rNum.Index);
|
||||
rOut.WriteLong(num.SectionID.ToLong());
|
||||
rOut.WriteLong(num.Index);
|
||||
}
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
}
|
||||
|
||||
void CAreaCooker::WriteCompressionHeader(IOutputStream& rOut)
|
||||
{
|
||||
for (uint32 iCmp = 0; iCmp < mCompressedBlocks.size(); iCmp++)
|
||||
for (const auto& block : mCompressedBlocks)
|
||||
{
|
||||
SCompressedBlock& rBlock = mCompressedBlocks[iCmp];
|
||||
bool IsCompressed = (rBlock.CompressedSize != 0);
|
||||
const bool IsCompressed = block.CompressedSize != 0;
|
||||
|
||||
rOut.WriteLong(IsCompressed ? rBlock.DecompressedSize + 0x120 : rBlock.DecompressedSize);
|
||||
rOut.WriteLong(rBlock.DecompressedSize);
|
||||
rOut.WriteLong(rBlock.CompressedSize);
|
||||
rOut.WriteLong(rBlock.NumSections);
|
||||
rOut.WriteLong(IsCompressed ? block.DecompressedSize + 0x120 : block.DecompressedSize);
|
||||
rOut.WriteLong(block.DecompressedSize);
|
||||
rOut.WriteLong(block.CompressedSize);
|
||||
rOut.WriteLong(block.NumSections);
|
||||
}
|
||||
|
||||
rOut.WriteToBoundary(32, 0);
|
||||
@ -271,18 +256,17 @@ void CAreaCooker::WriteDependencies(IOutputStream& rOut)
|
||||
// Write
|
||||
rOut.WriteLong(Dependencies.size());
|
||||
|
||||
for (auto Iter = Dependencies.begin(); Iter != Dependencies.end(); Iter++)
|
||||
for (const auto& dependency : Dependencies)
|
||||
{
|
||||
CAssetID ID = *Iter;
|
||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
||||
ID.Write(rOut);
|
||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(dependency);
|
||||
dependency.Write(rOut);
|
||||
pEntry->CookedExtension().Write(rOut);
|
||||
}
|
||||
|
||||
rOut.WriteLong(LayerOffsets.size());
|
||||
|
||||
for (auto Iter = LayerOffsets.begin(); Iter != LayerOffsets.end(); Iter++)
|
||||
rOut.WriteLong(*Iter);
|
||||
for (const uint32 offset : LayerOffsets)
|
||||
rOut.WriteLong(offset);
|
||||
|
||||
FinishSection(false);
|
||||
}
|
||||
@ -299,13 +283,13 @@ void CAreaCooker::WriteModules(IOutputStream& rOut)
|
||||
// Write
|
||||
rOut.WriteLong(ModuleNames.size());
|
||||
|
||||
for (uint32 ModuleIdx = 0; ModuleIdx < ModuleNames.size(); ModuleIdx++)
|
||||
rOut.WriteString( ModuleNames[ModuleIdx] );
|
||||
for (const auto& name : ModuleNames)
|
||||
rOut.WriteString(name);
|
||||
|
||||
rOut.WriteLong(LayerOffsets.size());
|
||||
|
||||
for (uint32 OffsetIdx = 0; OffsetIdx < LayerOffsets.size(); OffsetIdx++)
|
||||
rOut.WriteLong(LayerOffsets[OffsetIdx]);
|
||||
for (const uint32 offset : LayerOffsets)
|
||||
rOut.WriteLong(offset);
|
||||
|
||||
FinishSection(false);
|
||||
}
|
||||
|
@ -9,33 +9,30 @@
|
||||
class CAreaCooker
|
||||
{
|
||||
TResPtr<CGameArea> mpArea;
|
||||
EGame mVersion;
|
||||
EGame mVersion{};
|
||||
|
||||
std::vector<uint32> mSectionSizes;
|
||||
|
||||
uint32 mGeometrySecNum;
|
||||
uint32 mSCLYSecNum;
|
||||
uint32 mSCGNSecNum;
|
||||
uint32 mCollisionSecNum;
|
||||
uint32 mUnknownSecNum;
|
||||
uint32 mLightsSecNum;
|
||||
uint32 mVISISecNum;
|
||||
uint32 mPATHSecNum;
|
||||
uint32 mAROTSecNum;
|
||||
uint32 mFFFFSecNum;
|
||||
uint32 mPTLASecNum;
|
||||
uint32 mEGMCSecNum;
|
||||
uint32 mDepsSecNum;
|
||||
uint32 mModulesSecNum;
|
||||
uint32 mGeometrySecNum = UINT32_MAX;
|
||||
uint32 mSCLYSecNum = UINT32_MAX;
|
||||
uint32 mSCGNSecNum = UINT32_MAX;
|
||||
uint32 mCollisionSecNum = UINT32_MAX;
|
||||
uint32 mUnknownSecNum = UINT32_MAX;
|
||||
uint32 mLightsSecNum = UINT32_MAX;
|
||||
uint32 mVISISecNum = UINT32_MAX;
|
||||
uint32 mPATHSecNum = UINT32_MAX;
|
||||
uint32 mAROTSecNum = UINT32_MAX;
|
||||
uint32 mFFFFSecNum = UINT32_MAX;
|
||||
uint32 mPTLASecNum = UINT32_MAX;
|
||||
uint32 mEGMCSecNum = UINT32_MAX;
|
||||
uint32 mDepsSecNum = UINT32_MAX;
|
||||
uint32 mModulesSecNum = UINT32_MAX;
|
||||
|
||||
struct SCompressedBlock
|
||||
{
|
||||
uint32 CompressedSize;
|
||||
uint32 DecompressedSize;
|
||||
uint32 NumSections;
|
||||
|
||||
SCompressedBlock()
|
||||
: CompressedSize(0), DecompressedSize(0), NumSections(0) {}
|
||||
uint32 CompressedSize = 0;
|
||||
uint32 DecompressedSize = 0;
|
||||
uint32 NumSections = 0;
|
||||
};
|
||||
|
||||
SCompressedBlock mCurBlock;
|
||||
|
@ -2,13 +2,8 @@
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
CBasicModel::CBasicModel(CResourceEntry *pEntry /*= 0*/)
|
||||
CBasicModel::CBasicModel(CResourceEntry *pEntry)
|
||||
: CResource(pEntry)
|
||||
, mVertexCount(0)
|
||||
, mTriangleCount(0)
|
||||
, mBuffered(false)
|
||||
, mHasOwnMaterials(false)
|
||||
, mHasOwnSurfaces(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -19,32 +14,32 @@ CBasicModel::~CBasicModel()
|
||||
delete mSurfaces[iSurf];
|
||||
}
|
||||
|
||||
uint32 CBasicModel::GetVertexCount()
|
||||
uint32 CBasicModel::GetVertexCount() const
|
||||
{
|
||||
return mVertexCount;
|
||||
}
|
||||
|
||||
uint32 CBasicModel::GetTriangleCount()
|
||||
uint32 CBasicModel::GetTriangleCount() const
|
||||
{
|
||||
return mTriangleCount;
|
||||
}
|
||||
|
||||
CAABox CBasicModel::AABox()
|
||||
CAABox CBasicModel::AABox() const
|
||||
{
|
||||
return mAABox;
|
||||
}
|
||||
|
||||
bool CBasicModel::IsBuffered()
|
||||
bool CBasicModel::IsBuffered() const
|
||||
{
|
||||
return mBuffered;
|
||||
}
|
||||
|
||||
uint32 CBasicModel::GetSurfaceCount()
|
||||
uint32 CBasicModel::GetSurfaceCount() const
|
||||
{
|
||||
return mSurfaces.size();
|
||||
}
|
||||
|
||||
CAABox CBasicModel::GetSurfaceAABox(uint32 Surface)
|
||||
CAABox CBasicModel::GetSurfaceAABox(uint32 Surface) const
|
||||
{
|
||||
return mSurfaces[Surface]->AABox;
|
||||
}
|
||||
|
@ -11,25 +11,25 @@ class CBasicModel : public CResource
|
||||
DECLARE_RESOURCE_TYPE(Model)
|
||||
protected:
|
||||
CAABox mAABox;
|
||||
uint32 mVertexCount;
|
||||
uint32 mTriangleCount;
|
||||
bool mBuffered;
|
||||
bool mHasOwnMaterials;
|
||||
bool mHasOwnSurfaces;
|
||||
uint32 mVertexCount = 0;
|
||||
uint32 mTriangleCount = 0;
|
||||
bool mBuffered = false;
|
||||
bool mHasOwnMaterials = false;
|
||||
bool mHasOwnSurfaces = false;
|
||||
|
||||
CVertexBuffer mVBO;
|
||||
std::vector<SSurface*> mSurfaces;
|
||||
|
||||
public:
|
||||
CBasicModel(CResourceEntry *pEntry = 0);
|
||||
CBasicModel(CResourceEntry *pEntry = nullptr);
|
||||
~CBasicModel();
|
||||
|
||||
uint32 GetVertexCount();
|
||||
uint32 GetTriangleCount();
|
||||
CAABox AABox();
|
||||
bool IsBuffered();
|
||||
uint32 GetSurfaceCount();
|
||||
CAABox GetSurfaceAABox(uint32 Surface);
|
||||
uint32 GetVertexCount() const;
|
||||
uint32 GetTriangleCount() const;
|
||||
CAABox AABox() const;
|
||||
bool IsBuffered() const;
|
||||
uint32 GetSurfaceCount() const;
|
||||
CAABox GetSurfaceAABox(uint32 Surface) const;
|
||||
SSurface* GetSurface(uint32 Surface);
|
||||
virtual void ClearGLBuffer() = 0;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user