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;
|
||||
}
|
||||
|
||||
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;
|
||||
@ -67,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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -110,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)
|
||||
@ -130,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);
|
||||
@ -255,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);
|
||||
}
|
||||
@ -283,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);
|
||||
}
|
||||
|
@ -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