mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-06-17 20:13:41 +00:00
CAreaCooker: Collapse for loops into ranged for where applicable
Same behavior, less code.
This commit is contained in:
parent
f727c07d13
commit
03f1aba7e8
@ -33,8 +33,8 @@ void CAreaCooker::DetermineSectionNumbersPrime()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32 iMesh = 0; iMesh < mpArea->mWorldModels.size(); iMesh++)
|
for (const auto& worldModel : mpArea->mWorldModels)
|
||||||
GeometrySections += mpArea->mWorldModels[iMesh]->GetSurfaceCount();
|
GeometrySections += worldModel->GetSurfaceCount();
|
||||||
|
|
||||||
// Set section numbers
|
// Set section numbers
|
||||||
uint32 SecNum = GeometrySections;
|
uint32 SecNum = GeometrySections;
|
||||||
@ -67,13 +67,16 @@ void CAreaCooker::DetermineSectionNumbersCorruption()
|
|||||||
{
|
{
|
||||||
// Because we're copying these from the original file (because not all the numbers
|
// 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.
|
// 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 (num.SectionID == "SOBJ")
|
||||||
if (rNum.SectionID == "SOBJ") mSCLYSecNum = rNum.Index;
|
mSCLYSecNum = num.Index;
|
||||||
else if (rNum.SectionID == "SGEN") mSCGNSecNum = rNum.Index;
|
else if (num.SectionID == "SGEN")
|
||||||
else if (rNum.SectionID == "DEPS") mDepsSecNum = rNum.Index;
|
mSCGNSecNum = num.Index;
|
||||||
else if (rNum.SectionID == "RSOS") mModulesSecNum = rNum.Index;
|
else if (num.SectionID == "DEPS")
|
||||||
|
mDepsSecNum = num.Index;
|
||||||
|
else if (num.SectionID == "RSOS")
|
||||||
|
mModulesSecNum = num.Index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,8 +113,8 @@ void CAreaCooker::WritePrimeHeader(IOutputStream& rOut)
|
|||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32 iSec = 0; iSec < mSectionSizes.size(); iSec++)
|
for (const uint32 size : mSectionSizes)
|
||||||
rOut.WriteLong(mSectionSizes[iSec]);
|
rOut.WriteLong(size);
|
||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
|
|
||||||
if (mVersion >= EGame::Echoes)
|
if (mVersion >= EGame::Echoes)
|
||||||
@ -130,33 +133,31 @@ void CAreaCooker::WriteCorruptionHeader(IOutputStream& rOut)
|
|||||||
rOut.WriteLong(mpArea->mSectionNumbers.size());
|
rOut.WriteLong(mpArea->mSectionNumbers.size());
|
||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
|
|
||||||
for (uint32 iSec = 0; iSec < mSectionSizes.size(); iSec++)
|
for (const uint32 size : mSectionSizes)
|
||||||
rOut.WriteLong(mSectionSizes[iSec]);
|
rOut.WriteLong(size);
|
||||||
|
|
||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
|
|
||||||
WriteCompressionHeader(rOut);
|
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(num.SectionID.ToLong());
|
||||||
rOut.WriteLong(rNum.SectionID.ToLong());
|
rOut.WriteLong(num.Index);
|
||||||
rOut.WriteLong(rNum.Index);
|
|
||||||
}
|
}
|
||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAreaCooker::WriteCompressionHeader(IOutputStream& rOut)
|
void CAreaCooker::WriteCompressionHeader(IOutputStream& rOut)
|
||||||
{
|
{
|
||||||
for (uint32 iCmp = 0; iCmp < mCompressedBlocks.size(); iCmp++)
|
for (const auto& block : mCompressedBlocks)
|
||||||
{
|
{
|
||||||
SCompressedBlock& rBlock = mCompressedBlocks[iCmp];
|
const bool IsCompressed = block.CompressedSize != 0;
|
||||||
bool IsCompressed = (rBlock.CompressedSize != 0);
|
|
||||||
|
|
||||||
rOut.WriteLong(IsCompressed ? rBlock.DecompressedSize + 0x120 : rBlock.DecompressedSize);
|
rOut.WriteLong(IsCompressed ? block.DecompressedSize + 0x120 : block.DecompressedSize);
|
||||||
rOut.WriteLong(rBlock.DecompressedSize);
|
rOut.WriteLong(block.DecompressedSize);
|
||||||
rOut.WriteLong(rBlock.CompressedSize);
|
rOut.WriteLong(block.CompressedSize);
|
||||||
rOut.WriteLong(rBlock.NumSections);
|
rOut.WriteLong(block.NumSections);
|
||||||
}
|
}
|
||||||
|
|
||||||
rOut.WriteToBoundary(32, 0);
|
rOut.WriteToBoundary(32, 0);
|
||||||
@ -255,18 +256,17 @@ void CAreaCooker::WriteDependencies(IOutputStream& rOut)
|
|||||||
// Write
|
// Write
|
||||||
rOut.WriteLong(Dependencies.size());
|
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(dependency);
|
||||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
dependency.Write(rOut);
|
||||||
ID.Write(rOut);
|
|
||||||
pEntry->CookedExtension().Write(rOut);
|
pEntry->CookedExtension().Write(rOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
rOut.WriteLong(LayerOffsets.size());
|
rOut.WriteLong(LayerOffsets.size());
|
||||||
|
|
||||||
for (auto Iter = LayerOffsets.begin(); Iter != LayerOffsets.end(); Iter++)
|
for (const uint32 offset : LayerOffsets)
|
||||||
rOut.WriteLong(*Iter);
|
rOut.WriteLong(offset);
|
||||||
|
|
||||||
FinishSection(false);
|
FinishSection(false);
|
||||||
}
|
}
|
||||||
@ -283,13 +283,13 @@ void CAreaCooker::WriteModules(IOutputStream& rOut)
|
|||||||
// Write
|
// Write
|
||||||
rOut.WriteLong(ModuleNames.size());
|
rOut.WriteLong(ModuleNames.size());
|
||||||
|
|
||||||
for (uint32 ModuleIdx = 0; ModuleIdx < ModuleNames.size(); ModuleIdx++)
|
for (const auto& name : ModuleNames)
|
||||||
rOut.WriteString( ModuleNames[ModuleIdx] );
|
rOut.WriteString(name);
|
||||||
|
|
||||||
rOut.WriteLong(LayerOffsets.size());
|
rOut.WriteLong(LayerOffsets.size());
|
||||||
|
|
||||||
for (uint32 OffsetIdx = 0; OffsetIdx < LayerOffsets.size(); OffsetIdx++)
|
for (const uint32 offset : LayerOffsets)
|
||||||
rOut.WriteLong(LayerOffsets[OffsetIdx]);
|
rOut.WriteLong(offset);
|
||||||
|
|
||||||
FinishSection(false);
|
FinishSection(false);
|
||||||
}
|
}
|
||||||
|
@ -2,13 +2,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
CBasicModel::CBasicModel(CResourceEntry *pEntry /*= 0*/)
|
CBasicModel::CBasicModel(CResourceEntry *pEntry)
|
||||||
: CResource(pEntry)
|
: CResource(pEntry)
|
||||||
, mVertexCount(0)
|
|
||||||
, mTriangleCount(0)
|
|
||||||
, mBuffered(false)
|
|
||||||
, mHasOwnMaterials(false)
|
|
||||||
, mHasOwnSurfaces(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,32 +14,32 @@ CBasicModel::~CBasicModel()
|
|||||||
delete mSurfaces[iSurf];
|
delete mSurfaces[iSurf];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 CBasicModel::GetVertexCount()
|
uint32 CBasicModel::GetVertexCount() const
|
||||||
{
|
{
|
||||||
return mVertexCount;
|
return mVertexCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 CBasicModel::GetTriangleCount()
|
uint32 CBasicModel::GetTriangleCount() const
|
||||||
{
|
{
|
||||||
return mTriangleCount;
|
return mTriangleCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAABox CBasicModel::AABox()
|
CAABox CBasicModel::AABox() const
|
||||||
{
|
{
|
||||||
return mAABox;
|
return mAABox;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBasicModel::IsBuffered()
|
bool CBasicModel::IsBuffered() const
|
||||||
{
|
{
|
||||||
return mBuffered;
|
return mBuffered;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 CBasicModel::GetSurfaceCount()
|
uint32 CBasicModel::GetSurfaceCount() const
|
||||||
{
|
{
|
||||||
return mSurfaces.size();
|
return mSurfaces.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
CAABox CBasicModel::GetSurfaceAABox(uint32 Surface)
|
CAABox CBasicModel::GetSurfaceAABox(uint32 Surface) const
|
||||||
{
|
{
|
||||||
return mSurfaces[Surface]->AABox;
|
return mSurfaces[Surface]->AABox;
|
||||||
}
|
}
|
||||||
|
@ -11,25 +11,25 @@ class CBasicModel : public CResource
|
|||||||
DECLARE_RESOURCE_TYPE(Model)
|
DECLARE_RESOURCE_TYPE(Model)
|
||||||
protected:
|
protected:
|
||||||
CAABox mAABox;
|
CAABox mAABox;
|
||||||
uint32 mVertexCount;
|
uint32 mVertexCount = 0;
|
||||||
uint32 mTriangleCount;
|
uint32 mTriangleCount = 0;
|
||||||
bool mBuffered;
|
bool mBuffered = false;
|
||||||
bool mHasOwnMaterials;
|
bool mHasOwnMaterials = false;
|
||||||
bool mHasOwnSurfaces;
|
bool mHasOwnSurfaces = false;
|
||||||
|
|
||||||
CVertexBuffer mVBO;
|
CVertexBuffer mVBO;
|
||||||
std::vector<SSurface*> mSurfaces;
|
std::vector<SSurface*> mSurfaces;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CBasicModel(CResourceEntry *pEntry = 0);
|
CBasicModel(CResourceEntry *pEntry = nullptr);
|
||||||
~CBasicModel();
|
~CBasicModel();
|
||||||
|
|
||||||
uint32 GetVertexCount();
|
uint32 GetVertexCount() const;
|
||||||
uint32 GetTriangleCount();
|
uint32 GetTriangleCount() const;
|
||||||
CAABox AABox();
|
CAABox AABox() const;
|
||||||
bool IsBuffered();
|
bool IsBuffered() const;
|
||||||
uint32 GetSurfaceCount();
|
uint32 GetSurfaceCount() const;
|
||||||
CAABox GetSurfaceAABox(uint32 Surface);
|
CAABox GetSurfaceAABox(uint32 Surface) const;
|
||||||
SSurface* GetSurface(uint32 Surface);
|
SSurface* GetSurface(uint32 Surface);
|
||||||
virtual void ClearGLBuffer() = 0;
|
virtual void ClearGLBuffer() = 0;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user