Refactor so PWE compiles with the newly externalized LibCommon
This commit is contained in:
parent
dacd21d7fc
commit
2287b05bc3
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 42038000181a5fa5b92f2abfb74d91b7bec25040
|
|
@ -1 +1 @@
|
||||||
Subproject commit 252e4c7e96099c0f684b96d57eb9d947278d565b
|
Subproject commit 4917932573b3e6539113886c537a473550d3bbff
|
|
@ -28,13 +28,13 @@ void CAudioManager::LoadAssets()
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create SFX Define ID -> AGSC map
|
// Create SFX Define ID -> AGSC map
|
||||||
for (u32 iGrp = 0; iGrp < mAudioGroups.size(); iGrp++)
|
for (uint iGrp = 0; iGrp < mAudioGroups.size(); iGrp++)
|
||||||
{
|
{
|
||||||
CAudioGroup *pGroup = mAudioGroups[iGrp];
|
CAudioGroup *pGroup = mAudioGroups[iGrp];
|
||||||
|
|
||||||
for (u32 iSnd = 0; iSnd < pGroup->NumSoundDefineIDs(); iSnd++)
|
for (uint iSnd = 0; iSnd < pGroup->NumSoundDefineIDs(); iSnd++)
|
||||||
{
|
{
|
||||||
u16 DefineID = pGroup->SoundDefineIDByIndex(iSnd);
|
uint16 DefineID = pGroup->SoundDefineIDByIndex(iSnd);
|
||||||
ASSERT(mSfxIdMap.find(DefineID) == mSfxIdMap.end());
|
ASSERT(mSfxIdMap.find(DefineID) == mSfxIdMap.end());
|
||||||
mSfxIdMap[DefineID] = pGroup;
|
mSfxIdMap[DefineID] = pGroup;
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ void CAudioManager::ClearAssets()
|
||||||
mSfxIdMap.clear();
|
mSfxIdMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
SSoundInfo CAudioManager::GetSoundInfo(u32 SoundID)
|
SSoundInfo CAudioManager::GetSoundInfo(uint32 SoundID)
|
||||||
{
|
{
|
||||||
SSoundInfo Out;
|
SSoundInfo Out;
|
||||||
Out.SoundID = SoundID;
|
Out.SoundID = SoundID;
|
||||||
|
@ -84,18 +84,18 @@ SSoundInfo CAudioManager::GetSoundInfo(u32 SoundID)
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAudioManager::LogSoundInfo(u32 SoundID)
|
void CAudioManager::LogSoundInfo(uint32 SoundID)
|
||||||
{
|
{
|
||||||
SSoundInfo SoundInfo = GetSoundInfo(SoundID);
|
SSoundInfo SoundInfo = GetSoundInfo(SoundID);
|
||||||
|
|
||||||
if (SoundInfo.DefineID != 0xFFFF)
|
if (SoundInfo.DefineID != 0xFFFF)
|
||||||
{
|
{
|
||||||
if (mpProject->Game() >= EGame::EchoesDemo)
|
if (mpProject->Game() >= EGame::EchoesDemo)
|
||||||
Log::Write("Sound Name: " + SoundInfo.Name);
|
debugf("Sound Name: %s", *SoundInfo.Name);
|
||||||
|
|
||||||
Log::Write("Sound ID: " + TString::HexString(SoundInfo.SoundID, 4));
|
debugf("Sound ID: 0x%04x", SoundInfo.SoundID);
|
||||||
Log::Write("Define ID: " + TString::HexString(SoundInfo.DefineID, 4));
|
debugf("Define ID: 0x%04x", SoundInfo.DefineID);
|
||||||
Log::Write("Audio Group: " + SoundInfo.pAudioGroup->Entry()->Name());
|
debugf("Audio Group: %s", *SoundInfo.pAudioGroup->Entry()->Name());
|
||||||
Log::Write("");
|
debugf("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@ struct SSoundInfo
|
||||||
{
|
{
|
||||||
CAudioGroup *pAudioGroup;
|
CAudioGroup *pAudioGroup;
|
||||||
TString Name;
|
TString Name;
|
||||||
u32 SoundID;
|
uint32 SoundID;
|
||||||
u16 DefineID;
|
uint16 DefineID;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CAudioManager
|
class CAudioManager
|
||||||
|
@ -23,14 +23,14 @@ class CAudioManager
|
||||||
std::vector<TResPtr<CAudioGroup>> mAudioGroups;
|
std::vector<TResPtr<CAudioGroup>> mAudioGroups;
|
||||||
TResPtr<CAudioLookupTable> mpAudioLookupTable;
|
TResPtr<CAudioLookupTable> mpAudioLookupTable;
|
||||||
TResPtr<CStringList> mpSfxNameList;
|
TResPtr<CStringList> mpSfxNameList;
|
||||||
std::unordered_map<u16, CAudioGroup*> mSfxIdMap;
|
std::unordered_map<uint16, CAudioGroup*> mSfxIdMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAudioManager(CGameProject *pProj);
|
CAudioManager(CGameProject *pProj);
|
||||||
void LoadAssets();
|
void LoadAssets();
|
||||||
void ClearAssets();
|
void ClearAssets();
|
||||||
SSoundInfo GetSoundInfo(u32 SoundID);
|
SSoundInfo GetSoundInfo(uint32 SoundID);
|
||||||
void LogSoundInfo(u32 SoundID);
|
void LogSoundInfo(uint32 SoundID);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CAUDIOMANAGER
|
#endif // CAUDIOMANAGER
|
||||||
|
|
|
@ -10,7 +10,7 @@ CRayCollisionTester::~CRayCollisionTester()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRayCollisionTester::AddNode(CSceneNode *pNode, u32 ComponentIndex, float Distance)
|
void CRayCollisionTester::AddNode(CSceneNode *pNode, uint32 ComponentIndex, float Distance)
|
||||||
{
|
{
|
||||||
mBoxIntersectList.emplace_back(SRayIntersection());
|
mBoxIntersectList.emplace_back(SRayIntersection());
|
||||||
SRayIntersection& rIntersection = mBoxIntersectList.back();
|
SRayIntersection& rIntersection = mBoxIntersectList.back();
|
||||||
|
@ -22,7 +22,7 @@ void CRayCollisionTester::AddNode(CSceneNode *pNode, u32 ComponentIndex, float D
|
||||||
void CRayCollisionTester::AddNodeModel(CSceneNode *pNode, CBasicModel *pModel)
|
void CRayCollisionTester::AddNodeModel(CSceneNode *pNode, CBasicModel *pModel)
|
||||||
{
|
{
|
||||||
// Check each of the model's surfaces and queue them for further testing if they hit
|
// Check each of the model's surfaces and queue them for further testing if they hit
|
||||||
for (u32 iSurf = 0; iSurf < pModel->GetSurfaceCount(); iSurf++)
|
for (uint32 iSurf = 0; iSurf < pModel->GetSurfaceCount(); iSurf++)
|
||||||
{
|
{
|
||||||
std::pair<bool,float> SurfResult = pModel->GetSurfaceAABox(iSurf).Transformed(pNode->Transform()).IntersectsRay(mRay);
|
std::pair<bool,float> SurfResult = pModel->GetSurfaceAABox(iSurf).Transformed(pNode->Transform()).IntersectsRay(mRay);
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
#include "SRayIntersection.h"
|
#include "SRayIntersection.h"
|
||||||
#include "Core/Render/SViewInfo.h"
|
#include "Core/Render/SViewInfo.h"
|
||||||
#include "Core/Resource/Model/CBasicModel.h"
|
#include "Core/Resource/Model/CBasicModel.h"
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
#include <Math/CAABox.h>
|
#include <Common/Math/CAABox.h>
|
||||||
#include <Math/CRay.h>
|
#include <Common/Math/CRay.h>
|
||||||
#include <Math/CVector3f.h>
|
#include <Common/Math/CVector3f.h>
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ public:
|
||||||
~CRayCollisionTester();
|
~CRayCollisionTester();
|
||||||
const CRay& Ray() const { return mRay; }
|
const CRay& Ray() const { return mRay; }
|
||||||
|
|
||||||
void AddNode(CSceneNode *pNode, u32 AssetIndex, float Distance);
|
void AddNode(CSceneNode *pNode, uint32 AssetIndex, float Distance);
|
||||||
void AddNodeModel(CSceneNode *pNode, CBasicModel *pModel);
|
void AddNodeModel(CSceneNode *pNode, CBasicModel *pModel);
|
||||||
SRayIntersection TestNodes(const SViewInfo& rkViewInfo);
|
SRayIntersection TestNodes(const SViewInfo& rkViewInfo);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
#include "CompressionUtil.h"
|
#include "CompressionUtil.h"
|
||||||
#include <Common/Log.h>
|
#include <Common/Common.h>
|
||||||
#include <Common/TString.h>
|
|
||||||
#include <Common/types.h>
|
|
||||||
|
|
||||||
#include <lzo/lzo1x.h>
|
#include <lzo/lzo1x.h>
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
namespace CompressionUtil
|
namespace CompressionUtil
|
||||||
{
|
{
|
||||||
TString ErrorText_zlib(s32 Error)
|
const char* ErrorText_zlib(int32 Error)
|
||||||
{
|
{
|
||||||
switch (Error)
|
switch (Error)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +23,7 @@ namespace CompressionUtil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TString ErrorText_LZO(s32 Error)
|
const char* ErrorText_LZO(int32 Error)
|
||||||
{
|
{
|
||||||
switch (Error)
|
switch (Error)
|
||||||
{
|
{
|
||||||
|
@ -48,7 +46,7 @@ namespace CompressionUtil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ DECOMPRESS ************
|
// ************ DECOMPRESS ************
|
||||||
bool DecompressZlib(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen, u32& rTotalOut)
|
bool DecompressZlib(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut)
|
||||||
{
|
{
|
||||||
// Initialize z_stream
|
// Initialize z_stream
|
||||||
z_stream z;
|
z_stream z;
|
||||||
|
@ -61,7 +59,7 @@ namespace CompressionUtil
|
||||||
z.next_out = pDst;
|
z.next_out = pDst;
|
||||||
|
|
||||||
// Attempt decompress
|
// Attempt decompress
|
||||||
s32 Error = inflateInit(&z);
|
int32 Error = inflateInit(&z);
|
||||||
|
|
||||||
if (!Error)
|
if (!Error)
|
||||||
{
|
{
|
||||||
|
@ -76,42 +74,42 @@ namespace CompressionUtil
|
||||||
// Check for errors
|
// Check for errors
|
||||||
if (Error && Error != Z_STREAM_END)
|
if (Error && Error != Z_STREAM_END)
|
||||||
{
|
{
|
||||||
Log::Error("zlib error: " + ErrorText_zlib(Error));
|
errorf("zlib error: %s", ErrorText_zlib(Error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DecompressLZO(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut)
|
bool DecompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut)
|
||||||
{
|
{
|
||||||
lzo_init();
|
lzo_init();
|
||||||
lzo_uint TotalOut;
|
lzo_uint TotalOut;
|
||||||
s32 Error = lzo1x_decompress(pSrc, SrcLen, pDst, &TotalOut, LZO1X_MEM_DECOMPRESS);
|
int32 Error = lzo1x_decompress(pSrc, SrcLen, pDst, &TotalOut, LZO1X_MEM_DECOMPRESS);
|
||||||
rTotalOut = (u32) TotalOut;
|
rTotalOut = (uint32) TotalOut;
|
||||||
|
|
||||||
if (Error)
|
if (Error)
|
||||||
{
|
{
|
||||||
Log::Error("LZO error: " + ErrorText_LZO(Error));
|
errorf("LZO error: %s", ErrorText_LZO(Error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DecompressSegmentedData(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen)
|
bool DecompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen)
|
||||||
{
|
{
|
||||||
u8 *pSrcEnd = pSrc + SrcLen;
|
uint8 *pSrcEnd = pSrc + SrcLen;
|
||||||
u8 *pDstEnd = pDst + DstLen;
|
uint8 *pDstEnd = pDst + DstLen;
|
||||||
|
|
||||||
while ((pSrc < pSrcEnd) && (pDst < pDstEnd))
|
while ((pSrc < pSrcEnd) && (pDst < pDstEnd))
|
||||||
{
|
{
|
||||||
// Read size value (this method is Endian-independent)
|
// Read size value (this method is Endian-independent)
|
||||||
u8 ByteA = *pSrc++;
|
uint8 ByteA = *pSrc++;
|
||||||
u8 ByteB = *pSrc++;
|
uint8 ByteB = *pSrc++;
|
||||||
s16 Size = (ByteA << 8) | ByteB;
|
int16 Size = (ByteA << 8) | ByteB;
|
||||||
|
|
||||||
u32 TotalOut;
|
uint32 TotalOut;
|
||||||
|
|
||||||
// Negative size denotes uncompressed data.
|
// Negative size denotes uncompressed data.
|
||||||
if (Size < 0)
|
if (Size < 0)
|
||||||
|
@ -126,13 +124,13 @@ namespace CompressionUtil
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Check for zlib magic
|
// Check for zlib magic
|
||||||
u8 ByteC = pSrc[0];
|
uint8 ByteC = pSrc[0];
|
||||||
u8 ByteD = pSrc[1];
|
uint8 ByteD = pSrc[1];
|
||||||
u16 PeekMagic = (ByteC << 8) | ByteD;
|
uint16 PeekMagic = (ByteC << 8) | ByteD;
|
||||||
|
|
||||||
if (PeekMagic == 0x78DA || PeekMagic == 0x789C || PeekMagic == 0x7801)
|
if (PeekMagic == 0x78DA || PeekMagic == 0x789C || PeekMagic == 0x7801)
|
||||||
{
|
{
|
||||||
bool Success = DecompressZlib(pSrc, Size, pDst, (u32) (pDstEnd - pDst), TotalOut);
|
bool Success = DecompressZlib(pSrc, Size, pDst, (uint32) (pDstEnd - pDst), TotalOut);
|
||||||
if (!Success) return false;
|
if (!Success) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +150,7 @@ namespace CompressionUtil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ COMPRESS ************
|
// ************ COMPRESS ************
|
||||||
bool CompressZlib(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen, u32& rTotalOut)
|
bool CompressZlib(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut)
|
||||||
{
|
{
|
||||||
z_stream z;
|
z_stream z;
|
||||||
z.zalloc = Z_NULL;
|
z.zalloc = Z_NULL;
|
||||||
|
@ -163,7 +161,7 @@ namespace CompressionUtil
|
||||||
z.avail_out = DstLen;
|
z.avail_out = DstLen;
|
||||||
z.next_out = pDst;
|
z.next_out = pDst;
|
||||||
|
|
||||||
s32 Error = deflateInit(&z, 9);
|
int32 Error = deflateInit(&z, 9);
|
||||||
|
|
||||||
if (!Error)
|
if (!Error)
|
||||||
{
|
{
|
||||||
|
@ -177,46 +175,46 @@ namespace CompressionUtil
|
||||||
|
|
||||||
if (Error && Error != Z_STREAM_END)
|
if (Error && Error != Z_STREAM_END)
|
||||||
{
|
{
|
||||||
Log::Error("zlib error: " + ErrorText_zlib(Error));
|
errorf("zlib error: %s", ErrorText_zlib(Error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompressLZO(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut)
|
bool CompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut)
|
||||||
{
|
{
|
||||||
lzo_init();
|
lzo_init();
|
||||||
|
|
||||||
u8 *pWorkMem = new u8[LZO1X_999_MEM_COMPRESS];
|
uint8 *pWorkMem = new uint8[LZO1X_999_MEM_COMPRESS];
|
||||||
s32 Error = lzo1x_999_compress(pSrc, SrcLen, pDst, (lzo_uint*) &rTotalOut, pWorkMem);
|
int32 Error = lzo1x_999_compress(pSrc, SrcLen, pDst, (lzo_uint*) &rTotalOut, pWorkMem);
|
||||||
delete[] pWorkMem;
|
delete[] pWorkMem;
|
||||||
|
|
||||||
if (Error)
|
if (Error)
|
||||||
{
|
{
|
||||||
Log::Error("LZO error: " + ErrorText_LZO(Error));
|
errorf("LZO error: %s", ErrorText_LZO(Error));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompressSegmentedData(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool IsZlib, bool AllowUncompressedSegments)
|
bool CompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool IsZlib, bool AllowUncompressedSegments)
|
||||||
{
|
{
|
||||||
u8 *pSrcEnd = pSrc + SrcLen;
|
uint8 *pSrcEnd = pSrc + SrcLen;
|
||||||
u8 *pDstStart = pDst;
|
uint8 *pDstStart = pDst;
|
||||||
|
|
||||||
while (pSrc < pSrcEnd)
|
while (pSrc < pSrcEnd)
|
||||||
{
|
{
|
||||||
// Each segment is compressed separately. Segment size should always be 0x4000 unless there's less than 0x4000 bytes left.
|
// Each segment is compressed separately. Segment size should always be 0x4000 unless there's less than 0x4000 bytes left.
|
||||||
u16 Size;
|
uint16 Size;
|
||||||
u32 Remaining = (u32) (pSrcEnd - pSrc);
|
uint32 Remaining = (uint32) (pSrcEnd - pSrc);
|
||||||
|
|
||||||
if (Remaining < 0x4000) Size = (u16) Remaining;
|
if (Remaining < 0x4000) Size = (uint16) Remaining;
|
||||||
else Size = 0x4000;
|
else Size = 0x4000;
|
||||||
|
|
||||||
std::vector<u8> Compressed(Size * 2);
|
std::vector<uint8> Compressed(Size * 2);
|
||||||
u32 TotalOut;
|
uint32 TotalOut;
|
||||||
|
|
||||||
if (IsZlib)
|
if (IsZlib)
|
||||||
CompressZlib(pSrc, Size, Compressed.data(), Compressed.size(), TotalOut);
|
CompressZlib(pSrc, Size, Compressed.data(), Compressed.size(), TotalOut);
|
||||||
|
@ -248,16 +246,16 @@ namespace CompressionUtil
|
||||||
pDst += TotalOut;
|
pDst += TotalOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
rTotalOut = (u32) (pDst - pDstStart);
|
rTotalOut = (uint32) (pDst - pDstStart);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompressZlibSegmented(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool AllowUncompressedSegments)
|
bool CompressZlibSegmented(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool AllowUncompressedSegments)
|
||||||
{
|
{
|
||||||
return CompressSegmentedData(pSrc, SrcLen, pDst, rTotalOut, true, AllowUncompressedSegments);
|
return CompressSegmentedData(pSrc, SrcLen, pDst, rTotalOut, true, AllowUncompressedSegments);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CompressLZOSegmented(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool AllowUncompressedSegments)
|
bool CompressLZOSegmented(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool AllowUncompressedSegments)
|
||||||
{
|
{
|
||||||
return CompressSegmentedData(pSrc, SrcLen, pDst, rTotalOut, false, AllowUncompressedSegments);
|
return CompressSegmentedData(pSrc, SrcLen, pDst, rTotalOut, false, AllowUncompressedSegments);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,23 @@
|
||||||
#ifndef COMPRESSIONUTIL_H
|
#ifndef COMPRESSIONUTIL_H
|
||||||
#define COMPRESSIONUTIL_H
|
#define COMPRESSIONUTIL_H
|
||||||
|
|
||||||
|
#include <Common/BasicTypes.h>
|
||||||
#include <Common/FileIO.h>
|
#include <Common/FileIO.h>
|
||||||
#include <Common/TString.h>
|
#include <Common/TString.h>
|
||||||
#include <Common/types.h>
|
|
||||||
|
|
||||||
namespace CompressionUtil
|
namespace CompressionUtil
|
||||||
{
|
{
|
||||||
TString ErrorText_zlib(s32 Error);
|
|
||||||
TString ErrorText_LZO(s32 Error);
|
|
||||||
|
|
||||||
// Decompression
|
// Decompression
|
||||||
bool DecompressZlib(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen, u32& rTotalOut);
|
bool DecompressZlib(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut);
|
||||||
bool DecompressLZO(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut);
|
bool DecompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut);
|
||||||
bool DecompressSegmentedData(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen);
|
bool DecompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen);
|
||||||
|
|
||||||
// Compression
|
// Compression
|
||||||
bool CompressZlib(u8 *pSrc, u32 SrcLen, u8 *pDst, u32 DstLen, u32& rTotalOut);
|
bool CompressZlib(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32 DstLen, uint32& rTotalOut);
|
||||||
bool CompressLZO(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut);
|
bool CompressLZO(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut);
|
||||||
bool CompressSegmentedData(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool IsZlib, bool AllowUncompressedSegments);
|
bool CompressSegmentedData(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool IsZlib, bool AllowUncompressedSegments);
|
||||||
bool CompressZlibSegmented(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool AllowUncompressedSegments);
|
bool CompressZlibSegmented(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool AllowUncompressedSegments);
|
||||||
bool CompressLZOSegmented(u8 *pSrc, u32 SrcLen, u8 *pDst, u32& rTotalOut, bool AllowUncompressedSegments);
|
bool CompressLZOSegmented(uint8 *pSrc, uint32 SrcLen, uint8 *pDst, uint32& rTotalOut, bool AllowUncompressedSegments);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // COMPRESSIONUTIL_H
|
#endif // COMPRESSIONUTIL_H
|
||||||
|
|
|
@ -27,17 +27,15 @@ CONFIG (debug, debug|release) {
|
||||||
TARGET = Cored
|
TARGET = Cored
|
||||||
|
|
||||||
# Debug Libs
|
# Debug Libs
|
||||||
LIBS += -L$$BUILD_DIR/Common/ -lCommond \
|
LIBS += -L$$EXTERNALS_DIR/assimp/lib/Debug -lassimp-vc140-mt \
|
||||||
-L$$BUILD_DIR/Math/ -lMathd \
|
-L$$EXTERNALS_DIR/LibCommon/Build -lLibCommond \
|
||||||
-L$$EXTERNALS_DIR/assimp/lib/Debug -lassimp-vc140-mt \
|
|
||||||
-L$$EXTERNALS_DIR/nod/lib/Debug -lnod \
|
-L$$EXTERNALS_DIR/nod/lib/Debug -lnod \
|
||||||
-L$$EXTERNALS_DIR/nod/logvisor/Debug -llogvisor \
|
-L$$EXTERNALS_DIR/nod/logvisor/Debug -llogvisor \
|
||||||
-L$$EXTERNALS_DIR/zlib/lib/ -lzlibd
|
-L$$EXTERNALS_DIR/zlib/lib/ -lzlibd
|
||||||
|
|
||||||
# Debug Target Dependencies
|
# Debug Target Dependencies
|
||||||
win32 {
|
win32 {
|
||||||
PRE_TARGETDEPS += $$BUILD_DIR/Common/Commond.lib \
|
PRE_TARGETDEPS += $$EXTERNALS_DIR/LibCommon/Build/LibCommond.lib
|
||||||
$$BUILD_DIR/Math/Mathd.lib
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,17 +45,15 @@ CONFIG (release, debug|release) {
|
||||||
TARGET = Core
|
TARGET = Core
|
||||||
|
|
||||||
# Release Libs
|
# Release Libs
|
||||||
LIBS += -L$$BUILD_DIR/Common/ -lCommon \
|
LIBS += -L$$EXTERNALS_DIR/assimp/lib/Release -lassimp-vc140-mt \
|
||||||
-L$$BUILD_DIR/Math/ -lMath \
|
-L$$EXTERNALS_DIR/LibCommon/Build -lLibCommon \
|
||||||
-L$$EXTERNALS_DIR/assimp/lib/Release -lassimp-vc140-mt \
|
|
||||||
-L$$EXTERNALS_DIR/nod/lib/Release -lnod \
|
-L$$EXTERNALS_DIR/nod/lib/Release -lnod \
|
||||||
-L$$EXTERNALS_DIR/nod/logvisor/Release -llogvisor \
|
-L$$EXTERNALS_DIR/nod/logvisor/Release -llogvisor \
|
||||||
-L$$EXTERNALS_DIR/zlib/lib/ -lzlib
|
-L$$EXTERNALS_DIR/zlib/lib/ -lzlib
|
||||||
|
|
||||||
# Release Target Dependencies
|
# Release Target Dependencies
|
||||||
win32 {
|
win32 {
|
||||||
PRE_TARGETDEPS += $$BUILD_DIR/Common/Common.lib \
|
PRE_TARGETDEPS += $$EXTERNALS_DIR/LibCommon/Build/LibCommon.lib
|
||||||
$$BUILD_DIR/Math/Math.lib
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,6 +66,7 @@ INCLUDEPATH += $$PWE_MAIN_INCLUDE \
|
||||||
$$EXTERNALS_DIR/assimp/include \
|
$$EXTERNALS_DIR/assimp/include \
|
||||||
$$EXTERNALS_DIR/CodeGen/include \
|
$$EXTERNALS_DIR/CodeGen/include \
|
||||||
$$EXTERNALS_DIR/glew-2.1.0/include \
|
$$EXTERNALS_DIR/glew-2.1.0/include \
|
||||||
|
$$EXTERNALS_DIR/LibCommon/Source \
|
||||||
$$EXTERNALS_DIR/lzo-2.10/include \
|
$$EXTERNALS_DIR/lzo-2.10/include \
|
||||||
$$EXTERNALS_DIR/nod/include \
|
$$EXTERNALS_DIR/nod/include \
|
||||||
$$EXTERNALS_DIR/nod/logvisor/include \
|
$$EXTERNALS_DIR/nod/logvisor/include \
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "Core/Resource/CWorld.h"
|
#include "Core/Resource/CWorld.h"
|
||||||
#include "Core/Resource/Animation/CAnimSet.h"
|
#include "Core/Resource/Animation/CAnimSet.h"
|
||||||
#include "Core/Resource/Script/CScriptLayer.h"
|
#include "Core/Resource/Script/CScriptLayer.h"
|
||||||
#include <Math/MathUtil.h>
|
#include <Common/Math/MathUtil.h>
|
||||||
|
|
||||||
#define REVERT_AUTO_NAMES 1
|
#define REVERT_AUTO_NAMES 1
|
||||||
#define PROCESS_PACKAGES 1
|
#define PROCESS_PACKAGES 1
|
||||||
|
@ -85,12 +85,12 @@ void ApplyGeneratedName(CResourceEntry *pEntry, const TString& rkDir, const TStr
|
||||||
|
|
||||||
void GenerateAssetNames(CGameProject *pProj)
|
void GenerateAssetNames(CGameProject *pProj)
|
||||||
{
|
{
|
||||||
Log::Write("*** Generating Asset Names ***");
|
debugf("*** Generating Asset Names ***");
|
||||||
CResourceStore *pStore = pProj->ResourceStore();
|
CResourceStore *pStore = pProj->ResourceStore();
|
||||||
|
|
||||||
#if REVERT_AUTO_NAMES
|
#if REVERT_AUTO_NAMES
|
||||||
// Revert all auto-generated asset names back to default to prevent name conflicts resulting in inconsistent results.
|
// Revert all auto-generated asset names back to default to prevent name conflicts resulting in inconsistent results.
|
||||||
Log::Write("Reverting auto-generated names");
|
debugf("Reverting auto-generated names");
|
||||||
|
|
||||||
for (CResourceIterator It(pStore); It; ++It)
|
for (CResourceIterator It(pStore); It; ++It)
|
||||||
{
|
{
|
||||||
|
@ -106,13 +106,13 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
|
|
||||||
#if PROCESS_PACKAGES
|
#if PROCESS_PACKAGES
|
||||||
// Generate names for package named resources
|
// Generate names for package named resources
|
||||||
Log::Write("Processing packages");
|
debugf("Processing packages");
|
||||||
|
|
||||||
for (u32 iPkg = 0; iPkg < pProj->NumPackages(); iPkg++)
|
for (uint32 iPkg = 0; iPkg < pProj->NumPackages(); iPkg++)
|
||||||
{
|
{
|
||||||
CPackage *pPkg = pProj->PackageByIndex(iPkg);
|
CPackage *pPkg = pProj->PackageByIndex(iPkg);
|
||||||
|
|
||||||
for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
|
for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
|
||||||
{
|
{
|
||||||
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
|
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
|
||||||
if (rkRes.Name.EndsWith("NODEPEND")) continue;
|
if (rkRes.Name.EndsWith("NODEPEND")) continue;
|
||||||
|
@ -128,7 +128,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
|
|
||||||
#if PROCESS_WORLDS
|
#if PROCESS_WORLDS
|
||||||
// Generate world/area names
|
// Generate world/area names
|
||||||
Log::Write("Processing worlds");
|
debugf("Processing worlds");
|
||||||
const TString kWorldsRoot = "Worlds/";
|
const TString kWorldsRoot = "Worlds/";
|
||||||
|
|
||||||
for (TResourceIterator<eWorld> It(pStore); It; ++It)
|
for (TResourceIterator<eWorld> It(pStore); It; ++It)
|
||||||
|
@ -165,15 +165,15 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
ApplyGeneratedName(pSkyEntry, WorldDir + "sky/cooked/", WorldName + "_sky");
|
ApplyGeneratedName(pSkyEntry, WorldDir + "sky/cooked/", WorldName + "_sky");
|
||||||
|
|
||||||
// Move sky textures
|
// Move sky textures
|
||||||
for (u32 iSet = 0; iSet < pSkyModel->GetMatSetCount(); iSet++)
|
for (uint32 iSet = 0; iSet < pSkyModel->GetMatSetCount(); iSet++)
|
||||||
{
|
{
|
||||||
CMaterialSet *pSet = pSkyModel->GetMatSet(iSet);
|
CMaterialSet *pSet = pSkyModel->GetMatSet(iSet);
|
||||||
|
|
||||||
for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
|
for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
|
||||||
{
|
{
|
||||||
CMaterial *pMat = pSet->MaterialByIndex(iMat);
|
CMaterial *pMat = pSet->MaterialByIndex(iMat);
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < pMat->PassCount(); iPass++)
|
for (uint32 iPass = 0; iPass < pMat->PassCount(); iPass++)
|
||||||
{
|
{
|
||||||
CMaterialPass *pPass = pMat->Pass(iPass);
|
CMaterialPass *pPass = pMat->Pass(iPass);
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Areas
|
// Areas
|
||||||
for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
|
for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
|
||||||
{
|
{
|
||||||
// Determine area name
|
// Determine area name
|
||||||
TString AreaName = pWorld->AreaInternalName(iArea);
|
TString AreaName = pWorld->AreaInternalName(iArea);
|
||||||
|
@ -233,15 +233,15 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
CGameArea *pArea = (CGameArea*) pAreaEntry->Load();
|
CGameArea *pArea = (CGameArea*) pAreaEntry->Load();
|
||||||
|
|
||||||
// Area lightmaps
|
// Area lightmaps
|
||||||
u32 LightmapNum = 0;
|
uint32 LightmapNum = 0;
|
||||||
CMaterialSet *pMaterials = pArea->Materials();
|
CMaterialSet *pMaterials = pArea->Materials();
|
||||||
|
|
||||||
for (u32 iMat = 0; iMat < pMaterials->NumMaterials(); iMat++)
|
for (uint32 iMat = 0; iMat < pMaterials->NumMaterials(); iMat++)
|
||||||
{
|
{
|
||||||
CMaterial *pMat = pMaterials->MaterialByIndex(iMat);
|
CMaterial *pMat = pMaterials->MaterialByIndex(iMat);
|
||||||
bool FoundLightmap = false;
|
bool FoundLightmap = false;
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < pMat->PassCount(); iPass++)
|
for (uint32 iPass = 0; iPass < pMat->PassCount(); iPass++)
|
||||||
{
|
{
|
||||||
CMaterialPass *pPass = pMat->Pass(iPass);
|
CMaterialPass *pPass = pMat->Pass(iPass);
|
||||||
|
|
||||||
|
@ -277,11 +277,11 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generate names from script instance names
|
// Generate names from script instance names
|
||||||
for (u32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++)
|
for (uint32 iLyr = 0; iLyr < pArea->NumScriptLayers(); iLyr++)
|
||||||
{
|
{
|
||||||
CScriptLayer *pLayer = pArea->ScriptLayer(iLyr);
|
CScriptLayer *pLayer = pArea->ScriptLayer(iLyr);
|
||||||
|
|
||||||
for (u32 iInst = 0; iInst < pLayer->NumInstances(); iInst++)
|
for (uint32 iInst = 0; iInst < pLayer->NumInstances(); iInst++)
|
||||||
{
|
{
|
||||||
CScriptObject* pInst = pLayer->InstanceByIndex(iInst);
|
CScriptObject* pInst = pLayer->InstanceByIndex(iInst);
|
||||||
CStructProperty* pProperties = pInst->Template()->Properties();
|
CStructProperty* pProperties = pInst->Template()->Properties();
|
||||||
|
@ -327,7 +327,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
|
|
||||||
if (Name.EndsWith(".STRG", false))
|
if (Name.EndsWith(".STRG", false))
|
||||||
{
|
{
|
||||||
u32 StringPropID = (pProj->Game() <= EGame::Prime ? 0x4 : 0x9182250C);
|
uint32 StringPropID = (pProj->Game() <= EGame::Prime ? 0x4 : 0x9182250C);
|
||||||
CAssetProperty *pStringProperty = TPropCast<CAssetProperty>(pProperties->ChildByID(StringPropID));
|
CAssetProperty *pStringProperty = TPropCast<CAssetProperty>(pProperties->ChildByID(StringPropID));
|
||||||
ASSERT(pStringProperty); // Temporary assert to remind myself later to update this code when uncooked properties are added to the template
|
ASSERT(pStringProperty); // Temporary assert to remind myself later to update this code when uncooked properties are added to the template
|
||||||
|
|
||||||
|
@ -353,7 +353,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
else if (pInst->ObjectTypeID() == 0x0 || pInst->ObjectTypeID() == FOURCC('ACTR') ||
|
else if (pInst->ObjectTypeID() == 0x0 || pInst->ObjectTypeID() == FOURCC('ACTR') ||
|
||||||
pInst->ObjectTypeID() == 0x8 || pInst->ObjectTypeID() == FOURCC('PLAT'))
|
pInst->ObjectTypeID() == 0x8 || pInst->ObjectTypeID() == FOURCC('PLAT'))
|
||||||
{
|
{
|
||||||
u32 ModelPropID = (pProj->Game() <= EGame::Prime ? (pInst->ObjectTypeID() == 0x0 ? 0xA : 0x6) : 0xC27FFA8F);
|
uint32 ModelPropID = (pProj->Game() <= EGame::Prime ? (pInst->ObjectTypeID() == 0x0 ? 0xA : 0x6) : 0xC27FFA8F);
|
||||||
CAssetProperty *pModelProperty = TPropCast<CAssetProperty>(pProperties->ChildByID(ModelPropID));
|
CAssetProperty *pModelProperty = TPropCast<CAssetProperty>(pProperties->ChildByID(ModelPropID));
|
||||||
ASSERT(pModelProperty); // Temporary assert to remind myself later to update this code when uncooked properties are added to the template
|
ASSERT(pModelProperty); // Temporary assert to remind myself later to update this code when uncooked properties are added to the template
|
||||||
|
|
||||||
|
@ -396,22 +396,22 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
|
|
||||||
#if PROCESS_MODELS
|
#if PROCESS_MODELS
|
||||||
// Generate Model Lightmap names
|
// Generate Model Lightmap names
|
||||||
Log::Write("Processing model lightmaps");
|
debugf("Processing model lightmaps");
|
||||||
|
|
||||||
for (TResourceIterator<eModel> It(pStore); It; ++It)
|
for (TResourceIterator<eModel> It(pStore); It; ++It)
|
||||||
{
|
{
|
||||||
CModel *pModel = (CModel*) It->Load();
|
CModel *pModel = (CModel*) It->Load();
|
||||||
u32 LightmapNum = 0;
|
uint32 LightmapNum = 0;
|
||||||
|
|
||||||
for (u32 iSet = 0; iSet < pModel->GetMatSetCount(); iSet++)
|
for (uint32 iSet = 0; iSet < pModel->GetMatSetCount(); iSet++)
|
||||||
{
|
{
|
||||||
CMaterialSet *pSet = pModel->GetMatSet(iSet);
|
CMaterialSet *pSet = pModel->GetMatSet(iSet);
|
||||||
|
|
||||||
for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
|
for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
|
||||||
{
|
{
|
||||||
CMaterial *pMat = pSet->MaterialByIndex(iMat);
|
CMaterial *pMat = pSet->MaterialByIndex(iMat);
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < pMat->PassCount(); iPass++)
|
for (uint32 iPass = 0; iPass < pMat->PassCount(); iPass++)
|
||||||
{
|
{
|
||||||
CMaterialPass *pPass = pMat->Pass(iPass);
|
CMaterialPass *pPass = pMat->Pass(iPass);
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
|
|
||||||
#if PROCESS_AUDIO_GROUPS
|
#if PROCESS_AUDIO_GROUPS
|
||||||
// Generate Audio Group names
|
// Generate Audio Group names
|
||||||
Log::Write("Processing audio groups");
|
debugf("Processing audio groups");
|
||||||
const TString kAudioGrpDir = "Audio/";
|
const TString kAudioGrpDir = "Audio/";
|
||||||
|
|
||||||
for (TResourceIterator<eAudioGroup> It(pStore); It; ++It)
|
for (TResourceIterator<eAudioGroup> It(pStore); It; ++It)
|
||||||
|
@ -452,7 +452,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
|
|
||||||
#if PROCESS_AUDIO_MACROS
|
#if PROCESS_AUDIO_MACROS
|
||||||
// Process audio macro/sample names
|
// Process audio macro/sample names
|
||||||
Log::Write("Processing audio macros");
|
debugf("Processing audio macros");
|
||||||
const TString kSfxDir = "Audio/Uncategorized/";
|
const TString kSfxDir = "Audio/Uncategorized/";
|
||||||
|
|
||||||
for (TResourceIterator<eAudioMacro> It(pStore); It; ++It)
|
for (TResourceIterator<eAudioMacro> It(pStore); It; ++It)
|
||||||
|
@ -461,7 +461,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
TString MacroName = pMacro->MacroName();
|
TString MacroName = pMacro->MacroName();
|
||||||
ApplyGeneratedName(*It, kSfxDir, MacroName);
|
ApplyGeneratedName(*It, kSfxDir, MacroName);
|
||||||
|
|
||||||
for (u32 iSamp = 0; iSamp < pMacro->NumSamples(); iSamp++)
|
for (uint32 iSamp = 0; iSamp < pMacro->NumSamples(); iSamp++)
|
||||||
{
|
{
|
||||||
CAssetID SampleID = pMacro->SampleByIndex(iSamp);
|
CAssetID SampleID = pMacro->SampleByIndex(iSamp);
|
||||||
CResourceEntry *pSample = pStore->FindEntry(SampleID);
|
CResourceEntry *pSample = pStore->FindEntry(SampleID);
|
||||||
|
@ -484,7 +484,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
#if PROCESS_ANIM_CHAR_SETS
|
#if PROCESS_ANIM_CHAR_SETS
|
||||||
// Generate animation format names
|
// Generate animation format names
|
||||||
// Hacky syntax because animsets are under eAnimSet in MP1/2 and eCharacter in MP3/DKCR
|
// Hacky syntax because animsets are under eAnimSet in MP1/2 and eCharacter in MP3/DKCR
|
||||||
Log::Write("Processing animation data");
|
debugf("Processing animation data");
|
||||||
CResourceIterator *pIter = (pProj->Game() <= EGame::Echoes ? (CResourceIterator*) new TResourceIterator<eAnimSet> : (CResourceIterator*) new TResourceIterator<eCharacter>);
|
CResourceIterator *pIter = (pProj->Game() <= EGame::Echoes ? (CResourceIterator*) new TResourceIterator<eAnimSet> : (CResourceIterator*) new TResourceIterator<eCharacter>);
|
||||||
CResourceIterator& It = *pIter;
|
CResourceIterator& It = *pIter;
|
||||||
|
|
||||||
|
@ -494,7 +494,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
TString NewSetName;
|
TString NewSetName;
|
||||||
CAnimSet *pSet = (CAnimSet*) It->Load();
|
CAnimSet *pSet = (CAnimSet*) It->Load();
|
||||||
|
|
||||||
for (u32 iChar = 0; iChar < pSet->NumCharacters(); iChar++)
|
for (uint32 iChar = 0; iChar < pSet->NumCharacters(); iChar++)
|
||||||
{
|
{
|
||||||
const SSetCharacter *pkChar = pSet->Character(iChar);
|
const SSetCharacter *pkChar = pSet->Character(iChar);
|
||||||
|
|
||||||
|
@ -516,7 +516,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 iOverlay = 0; iOverlay < pkChar->OverlayModels.size(); iOverlay++)
|
for (uint32 iOverlay = 0; iOverlay < pkChar->OverlayModels.size(); iOverlay++)
|
||||||
{
|
{
|
||||||
const SOverlayModel& rkOverlay = pkChar->OverlayModels[iOverlay];
|
const SOverlayModel& rkOverlay = pkChar->OverlayModels[iOverlay];
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
|
|
||||||
#if PROCESS_STRINGS
|
#if PROCESS_STRINGS
|
||||||
// Generate string names
|
// Generate string names
|
||||||
Log::Write("Processing strings");
|
debugf("Processing strings");
|
||||||
const TString kStringsDir = "Strings/Uncategorized/";
|
const TString kStringsDir = "Strings/Uncategorized/";
|
||||||
|
|
||||||
for (TResourceIterator<eStringTable> It(pStore); It; ++It)
|
for (TResourceIterator<eStringTable> It(pStore); It; ++It)
|
||||||
|
@ -582,12 +582,12 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
CStringTable *pString = (CStringTable*) It->Load();
|
CStringTable *pString = (CStringTable*) It->Load();
|
||||||
TString String;
|
TString String;
|
||||||
|
|
||||||
for (u32 iStr = 0; iStr < pString->NumStrings() && String.IsEmpty(); iStr++)
|
for (uint32 iStr = 0; iStr < pString->NumStrings() && String.IsEmpty(); iStr++)
|
||||||
String = CStringTable::StripFormatting( pString->String("ENGL", iStr) ).Trimmed();
|
String = CStringTable::StripFormatting( pString->String("ENGL", iStr) ).Trimmed();
|
||||||
|
|
||||||
if (!String.IsEmpty())
|
if (!String.IsEmpty())
|
||||||
{
|
{
|
||||||
TString Name = String.SubString(0, Math::Min<u32>(String.Size(), 50)).Trimmed();
|
TString Name = String.SubString(0, Math::Min<uint32>(String.Size(), 50)).Trimmed();
|
||||||
Name.Replace("\n", " ");
|
Name.Replace("\n", " ");
|
||||||
|
|
||||||
while (Name.EndsWith(".") || TString::IsWhitespace(Name.Back()))
|
while (Name.EndsWith(".") || TString::IsWhitespace(Name.Back()))
|
||||||
|
@ -600,7 +600,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
|
|
||||||
#if PROCESS_SCANS
|
#if PROCESS_SCANS
|
||||||
// Generate scan names
|
// Generate scan names
|
||||||
Log::Write("Processing scans");
|
debugf("Processing scans");
|
||||||
for (TResourceIterator<eScan> It(pStore); It; ++It)
|
for (TResourceIterator<eScan> It(pStore); It; ++It)
|
||||||
{
|
{
|
||||||
if (It->IsNamed()) continue;
|
if (It->IsNamed()) continue;
|
||||||
|
@ -628,7 +628,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
CResourceEntry *pEntry = pStore->FindEntry(FrameID);
|
CResourceEntry *pEntry = pStore->FindEntry(FrameID);
|
||||||
if (pEntry) ApplyGeneratedName(pEntry, pEntry->DirectoryPath(), "ScanFrame");
|
if (pEntry) ApplyGeneratedName(pEntry, pEntry->DirectoryPath(), "ScanFrame");
|
||||||
|
|
||||||
for (u32 iImg = 0; iImg < 4; iImg++)
|
for (uint32 iImg = 0; iImg < 4; iImg++)
|
||||||
{
|
{
|
||||||
CAssetID ImageID = pScan->ScanImage(iImg);
|
CAssetID ImageID = pScan->ScanImage(iImg);
|
||||||
CResourceEntry *pImgEntry = pStore->FindEntry(ImageID);
|
CResourceEntry *pImgEntry = pStore->FindEntry(ImageID);
|
||||||
|
@ -640,7 +640,7 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
|
|
||||||
#if PROCESS_FONTS
|
#if PROCESS_FONTS
|
||||||
// Generate font names
|
// Generate font names
|
||||||
Log::Write("Processing fonts");
|
debugf("Processing fonts");
|
||||||
for (TResourceIterator<eFont> It(pStore); It; ++It)
|
for (TResourceIterator<eFont> It(pStore); It; ++It)
|
||||||
{
|
{
|
||||||
CFont *pFont = (CFont*) It->Load();
|
CFont *pFont = (CFont*) It->Load();
|
||||||
|
@ -659,5 +659,5 @@ void GenerateAssetNames(CGameProject *pProj)
|
||||||
|
|
||||||
pStore->RootDirectory()->DeleteEmptySubdirectories();
|
pStore->RootDirectory()->DeleteEmptySubdirectories();
|
||||||
pStore->ConditionalSaveStore();
|
pStore->ConditionalSaveStore();
|
||||||
Log::Write("*** Asset Name Generation FINISHED ***");
|
debugf("*** Asset Name Generation FINISHED ***");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,15 +18,15 @@ bool CAssetNameMap::LoadAssetNames(TString Path /*= ""*/)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TString ExpectedIDLength = (mIDLength == e32Bit ? "32-bit" : "64-bit");
|
debugf("Failed to load asset names; expected %s IDs, got %s",
|
||||||
TString GotIDLength = (FileIDLength == e32Bit ? "32-bit" : "64-bit");
|
mIDLength == e32Bit ? "32-bit" : "64-bit",
|
||||||
Log::Error("Failed to load asset names; expected " + ExpectedIDLength + " IDs, got " + GotIDLength);
|
FileIDLength == e32Bit ? "32-bit" : "64-bit" );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::Error("Failed to load asset names; couldn't open XML.");
|
errorf("Failed to load asset names; couldn't open XML.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,9 +117,9 @@ void CAssetNameMap::CopyFromStore(CResourceStore *pStore /*= gpResourceStore*/)
|
||||||
|
|
||||||
TString OldPath = NameInfo.FullPath();
|
TString OldPath = NameInfo.FullPath();
|
||||||
TString NewPath = NewNameInfo.FullPath();
|
TString NewPath = NewNameInfo.FullPath();
|
||||||
Log::Warning("Detected name conflict when copying asset name from the resource store; renaming.");
|
warnf("Detected name conflict when copying asset name from the resource store; renaming.");
|
||||||
Log::Warning("\tOld Path: " + OldPath);
|
warnf("\tOld Path: %s", *OldPath);
|
||||||
Log::Warning("\tNew Path: " + NewPath);
|
warnf("\tNew Path: %s", *NewPath);
|
||||||
NameInfo.Name = NewNameInfo.Name;
|
NameInfo.Name = NewNameInfo.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ void CAssetNameMap::PostLoadValidate()
|
||||||
// Verify the name/path is valid
|
// Verify the name/path is valid
|
||||||
if (!CResourceStore::IsValidResourcePath(rkInfo.Directory, rkInfo.Name))
|
if (!CResourceStore::IsValidResourcePath(rkInfo.Directory, rkInfo.Name))
|
||||||
{
|
{
|
||||||
Log::Error("Invalid resource path in asset name map: " + rkInfo.Directory + rkInfo.Name + "." + rkInfo.Type.ToString());
|
errorf("Invalid resource path in asset name map: %s%s.%s", *rkInfo.Directory, *rkInfo.Name, *rkInfo.Type.ToString());
|
||||||
Iter = mMap.erase(Iter);
|
Iter = mMap.erase(Iter);
|
||||||
FoundErrors = true;
|
FoundErrors = true;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ void CAssetNameMap::PostLoadValidate()
|
||||||
// Verify correct ID length
|
// Verify correct ID length
|
||||||
if (Iter->first.Length() != mIDLength)
|
if (Iter->first.Length() != mIDLength)
|
||||||
{
|
{
|
||||||
Log::Error("Incorrect asset ID length in asset name map: " + Iter->first.ToString());
|
errorf("Incorrect asset ID length in asset name map: %s", *Iter->first.ToString());
|
||||||
Iter = mMap.erase(Iter);
|
Iter = mMap.erase(Iter);
|
||||||
FoundErrors = true;
|
FoundErrors = true;
|
||||||
}
|
}
|
||||||
|
@ -178,13 +178,11 @@ void CAssetNameMap::PostLoadValidate()
|
||||||
// If we detected any dupes, then this map can't be used
|
// If we detected any dupes, then this map can't be used
|
||||||
if (!Dupes.empty())
|
if (!Dupes.empty())
|
||||||
{
|
{
|
||||||
Log::Error("Asset name map is invalid and cannot be used! Duplicate asset entries detected:");
|
errorf("Asset name map is invalid and cannot be used! Duplicate asset entries detected:");
|
||||||
|
|
||||||
for (auto Iter = Dupes.begin(); Iter != Dupes.end(); Iter++)
|
for (auto Iter = Dupes.begin(); Iter != Dupes.end(); Iter++)
|
||||||
{
|
{
|
||||||
const SAssetNameInfo& rkInfo = *Iter;
|
warnf("\t%s", Iter->FullPath());
|
||||||
TString FullPath = rkInfo.FullPath();
|
|
||||||
Log::Error("\t" + FullPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mMap.clear();
|
mMap.clear();
|
||||||
|
|
|
@ -9,13 +9,13 @@
|
||||||
// ************ IDependencyNode ************
|
// ************ IDependencyNode ************
|
||||||
IDependencyNode::~IDependencyNode()
|
IDependencyNode::~IDependencyNode()
|
||||||
{
|
{
|
||||||
for (u32 iChild = 0; iChild < mChildren.size(); iChild++)
|
for (uint32 iChild = 0; iChild < mChildren.size(); iChild++)
|
||||||
delete mChildren[iChild];
|
delete mChildren[iChild];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IDependencyNode::HasDependency(const CAssetID& rkID) const
|
bool IDependencyNode::HasDependency(const CAssetID& rkID) const
|
||||||
{
|
{
|
||||||
for (u32 iChild = 0; iChild < mChildren.size(); iChild++)
|
for (uint32 iChild = 0; iChild < mChildren.size(); iChild++)
|
||||||
{
|
{
|
||||||
if (mChildren[iChild]->HasDependency(rkID))
|
if (mChildren[iChild]->HasDependency(rkID))
|
||||||
return true;
|
return true;
|
||||||
|
@ -26,7 +26,7 @@ bool IDependencyNode::HasDependency(const CAssetID& rkID) const
|
||||||
|
|
||||||
void IDependencyNode::GetAllResourceReferences(std::set<CAssetID>& rOutSet) const
|
void IDependencyNode::GetAllResourceReferences(std::set<CAssetID>& rOutSet) const
|
||||||
{
|
{
|
||||||
for (u32 iChild = 0; iChild < mChildren.size(); iChild++)
|
for (uint32 iChild = 0; iChild < mChildren.size(); iChild++)
|
||||||
mChildren[iChild]->GetAllResourceReferences(rOutSet);
|
mChildren[iChild]->GetAllResourceReferences(rOutSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc
|
||||||
// Recursive function for parsing script dependencies and loading them into the script instance dependency
|
// Recursive function for parsing script dependencies and loading them into the script instance dependency
|
||||||
void* pPropertyData = pInstance->PropertyData();
|
void* pPropertyData = pInstance->PropertyData();
|
||||||
|
|
||||||
for (u32 PropertyIdx = 0; PropertyIdx < pStruct->NumChildren(); PropertyIdx++)
|
for (uint32 PropertyIdx = 0; PropertyIdx < pStruct->NumChildren(); PropertyIdx++)
|
||||||
{
|
{
|
||||||
IProperty *pProp = pStruct->ChildByIndex(PropertyIdx);
|
IProperty *pProp = pStruct->ChildByIndex(PropertyIdx);
|
||||||
EPropertyType Type = pProp->Type();
|
EPropertyType Type = pProp->Type();
|
||||||
|
@ -170,7 +170,7 @@ void CScriptInstanceDependency::ParseStructDependencies(CScriptInstanceDependenc
|
||||||
|
|
||||||
else if (Type == EPropertyType::Sound)
|
else if (Type == EPropertyType::Sound)
|
||||||
{
|
{
|
||||||
u32 SoundID = TPropCast<CSoundProperty>(pProp)->Value(pPropertyData);
|
uint32 SoundID = TPropCast<CSoundProperty>(pProp)->Value(pPropertyData);
|
||||||
|
|
||||||
if (SoundID != -1)
|
if (SoundID != -1)
|
||||||
{
|
{
|
||||||
|
@ -246,13 +246,13 @@ CSetCharacterDependency* CSetCharacterDependency::BuildTree(const SSetCharacter&
|
||||||
&rkChar.EffectParticles
|
&rkChar.EffectParticles
|
||||||
};
|
};
|
||||||
|
|
||||||
for (u32 iVec = 0; iVec < 5; iVec++)
|
for (uint32 iVec = 0; iVec < 5; iVec++)
|
||||||
{
|
{
|
||||||
for (u32 iPart = 0; iPart < pkParticleVectors[iVec]->size(); iPart++)
|
for (uint32 iPart = 0; iPart < pkParticleVectors[iVec]->size(); iPart++)
|
||||||
pTree->AddDependency(pkParticleVectors[iVec]->at(iPart));
|
pTree->AddDependency(pkParticleVectors[iVec]->at(iPart));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 iOverlay = 0; iOverlay < rkChar.OverlayModels.size(); iOverlay++)
|
for (uint32 iOverlay = 0; iOverlay < rkChar.OverlayModels.size(); iOverlay++)
|
||||||
{
|
{
|
||||||
const SOverlayModel& rkOverlay = rkChar.OverlayModels[iOverlay];
|
const SOverlayModel& rkOverlay = rkChar.OverlayModels[iOverlay];
|
||||||
pTree->AddDependency(rkOverlay.ModelID);
|
pTree->AddDependency(rkOverlay.ModelID);
|
||||||
|
@ -276,13 +276,13 @@ void CSetAnimationDependency::Serialize(IArchive& rArc)
|
||||||
<< SerialParameter("Children", mChildren);
|
<< SerialParameter("Children", mChildren);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSetAnimationDependency* CSetAnimationDependency::BuildTree(const CAnimSet *pkOwnerSet, u32 AnimIndex)
|
CSetAnimationDependency* CSetAnimationDependency::BuildTree(const CAnimSet *pkOwnerSet, uint32 AnimIndex)
|
||||||
{
|
{
|
||||||
CSetAnimationDependency *pTree = new CSetAnimationDependency;
|
CSetAnimationDependency *pTree = new CSetAnimationDependency;
|
||||||
const SAnimation *pkAnim = pkOwnerSet->Animation(AnimIndex);
|
const SAnimation *pkAnim = pkOwnerSet->Animation(AnimIndex);
|
||||||
|
|
||||||
// Find relevant character indices
|
// Find relevant character indices
|
||||||
for (u32 iChar = 0; iChar < pkOwnerSet->NumCharacters(); iChar++)
|
for (uint32 iChar = 0; iChar < pkOwnerSet->NumCharacters(); iChar++)
|
||||||
{
|
{
|
||||||
const SSetCharacter *pkChar = pkOwnerSet->Character(iChar);
|
const SSetCharacter *pkChar = pkOwnerSet->Character(iChar);
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ void CAreaDependencyTree::AddScriptLayer(CScriptLayer *pLayer, const std::vector
|
||||||
mLayerOffsets.push_back(mChildren.size());
|
mLayerOffsets.push_back(mChildren.size());
|
||||||
std::set<CAssetID> UsedIDs;
|
std::set<CAssetID> UsedIDs;
|
||||||
|
|
||||||
for (u32 iInst = 0; iInst < pLayer->NumInstances(); iInst++)
|
for (uint32 iInst = 0; iInst < pLayer->NumInstances(); iInst++)
|
||||||
{
|
{
|
||||||
CScriptInstanceDependency *pTree = CScriptInstanceDependency::BuildTree( pLayer->InstanceByIndex(iInst) );
|
CScriptInstanceDependency *pTree = CScriptInstanceDependency::BuildTree( pLayer->InstanceByIndex(iInst) );
|
||||||
ASSERT(pTree != nullptr);
|
ASSERT(pTree != nullptr);
|
||||||
|
@ -355,34 +355,34 @@ void CAreaDependencyTree::AddScriptLayer(CScriptLayer *pLayer, const std::vector
|
||||||
delete pTree;
|
delete pTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 iDep = 0; iDep < rkExtraDeps.size(); iDep++)
|
for (uint32 iDep = 0; iDep < rkExtraDeps.size(); iDep++)
|
||||||
AddDependency(rkExtraDeps[iDep]);
|
AddDependency(rkExtraDeps[iDep]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<u32>& rModuleLayerOffsetsOut) const
|
void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<uint32>& rModuleLayerOffsetsOut) const
|
||||||
{
|
{
|
||||||
CGameTemplate *pGame = NGameList::GetGameTemplate(Game);
|
CGameTemplate *pGame = NGameList::GetGameTemplate(Game);
|
||||||
|
|
||||||
// Output module list will be split per-script layer
|
// Output module list will be split per-script layer
|
||||||
// The output offset list contains two offsets per layer - start index and end index
|
// The output offset list contains two offsets per layer - start index and end index
|
||||||
for (u32 iLayer = 0; iLayer < mLayerOffsets.size(); iLayer++)
|
for (uint32 iLayer = 0; iLayer < mLayerOffsets.size(); iLayer++)
|
||||||
{
|
{
|
||||||
u32 StartIdx = mLayerOffsets[iLayer];
|
uint32 StartIdx = mLayerOffsets[iLayer];
|
||||||
u32 EndIdx = (iLayer == mLayerOffsets.size() - 1 ? mChildren.size() : mLayerOffsets[iLayer + 1]);
|
uint32 EndIdx = (iLayer == mLayerOffsets.size() - 1 ? mChildren.size() : mLayerOffsets[iLayer + 1]);
|
||||||
|
|
||||||
u32 ModuleStartIdx = rModuleDepsOut.size();
|
uint32 ModuleStartIdx = rModuleDepsOut.size();
|
||||||
rModuleLayerOffsetsOut.push_back(ModuleStartIdx);
|
rModuleLayerOffsetsOut.push_back(ModuleStartIdx);
|
||||||
|
|
||||||
// Keep track of which types we've already checked on this layer to speed things up a little...
|
// Keep track of which types we've already checked on this layer to speed things up a little...
|
||||||
std::set<u32> UsedObjectTypes;
|
std::set<uint32> UsedObjectTypes;
|
||||||
|
|
||||||
for (u32 iInst = StartIdx; iInst < EndIdx; iInst++)
|
for (uint32 iInst = StartIdx; iInst < EndIdx; iInst++)
|
||||||
{
|
{
|
||||||
IDependencyNode *pNode = mChildren[iInst];
|
IDependencyNode *pNode = mChildren[iInst];
|
||||||
if (pNode->Type() != eDNT_ScriptInstance) continue;
|
if (pNode->Type() != eDNT_ScriptInstance) continue;
|
||||||
|
|
||||||
CScriptInstanceDependency *pInst = static_cast<CScriptInstanceDependency*>(pNode);
|
CScriptInstanceDependency *pInst = static_cast<CScriptInstanceDependency*>(pNode);
|
||||||
u32 ObjType = pInst->ObjectType();
|
uint32 ObjType = pInst->ObjectType();
|
||||||
|
|
||||||
if (UsedObjectTypes.find(ObjType) == UsedObjectTypes.end())
|
if (UsedObjectTypes.find(ObjType) == UsedObjectTypes.end())
|
||||||
{
|
{
|
||||||
|
@ -390,12 +390,12 @@ void CAreaDependencyTree::GetModuleDependencies(EGame Game, std::vector<TString>
|
||||||
CScriptTemplate *pTemplate = pGame->TemplateByID(ObjType);
|
CScriptTemplate *pTemplate = pGame->TemplateByID(ObjType);
|
||||||
const std::vector<TString>& rkModules = pTemplate->RequiredModules();
|
const std::vector<TString>& rkModules = pTemplate->RequiredModules();
|
||||||
|
|
||||||
for (u32 iMod = 0; iMod < rkModules.size(); iMod++)
|
for (uint32 iMod = 0; iMod < rkModules.size(); iMod++)
|
||||||
{
|
{
|
||||||
TString ModuleName = rkModules[iMod];
|
TString ModuleName = rkModules[iMod];
|
||||||
bool NewModule = true;
|
bool NewModule = true;
|
||||||
|
|
||||||
for (u32 iUsed = ModuleStartIdx; iUsed < rModuleDepsOut.size(); iUsed++)
|
for (uint32 iUsed = ModuleStartIdx; iUsed < rModuleDepsOut.size(); iUsed++)
|
||||||
{
|
{
|
||||||
if (rModuleDepsOut[iUsed] == ModuleName)
|
if (rModuleDepsOut[iUsed] == ModuleName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
#define CDEPENDENCYTREE
|
#define CDEPENDENCYTREE
|
||||||
|
|
||||||
#include "CResourceEntry.h"
|
#include "CResourceEntry.h"
|
||||||
#include <Common/AssertMacro.h>
|
|
||||||
#include <Common/CAssetID.h>
|
#include <Common/CAssetID.h>
|
||||||
#include <Common/FileIO.h>
|
#include <Common/FileIO.h>
|
||||||
|
#include <Common/Macros.h>
|
||||||
|
|
||||||
class CScriptLayer;
|
class CScriptLayer;
|
||||||
class CScriptObject;
|
class CScriptObject;
|
||||||
|
@ -44,8 +44,8 @@ public:
|
||||||
static IDependencyNode* ArchiveConstructor(EDependencyNodeType Type);
|
static IDependencyNode* ArchiveConstructor(EDependencyNodeType Type);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline u32 NumChildren() const { return mChildren.size(); }
|
inline uint NumChildren() const { return mChildren.size(); }
|
||||||
inline IDependencyNode* ChildByIndex(u32 Index) const { return mChildren[Index]; }
|
inline IDependencyNode* ChildByIndex(uint Index) const { return mChildren[Index]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Basic dependency tree; this class is sufficient for most resource types.
|
// Basic dependency tree; this class is sufficient for most resource types.
|
||||||
|
@ -109,7 +109,7 @@ public:
|
||||||
class CCharPropertyDependency : public CPropertyDependency
|
class CCharPropertyDependency : public CPropertyDependency
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
u32 mUsedChar;
|
int mUsedChar;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCharPropertyDependency()
|
CCharPropertyDependency()
|
||||||
|
@ -117,7 +117,7 @@ public:
|
||||||
, mUsedChar(-1)
|
, mUsedChar(-1)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CCharPropertyDependency(const TString& rkPropID, const CAssetID& rkAssetID, u32 UsedChar)
|
CCharPropertyDependency(const TString& rkPropID, const CAssetID& rkAssetID, int UsedChar)
|
||||||
: CPropertyDependency(rkPropID, rkAssetID)
|
: CPropertyDependency(rkPropID, rkAssetID)
|
||||||
, mUsedChar(UsedChar)
|
, mUsedChar(UsedChar)
|
||||||
{}
|
{}
|
||||||
|
@ -126,21 +126,21 @@ public:
|
||||||
virtual void Serialize(IArchive& rArc);
|
virtual void Serialize(IArchive& rArc);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline u32 UsedChar() const { return mUsedChar; }
|
inline int UsedChar() const { return mUsedChar; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Node representing a script object. Indicates the type of object.
|
// Node representing a script object. Indicates the type of object.
|
||||||
class CScriptInstanceDependency : public IDependencyNode
|
class CScriptInstanceDependency : public IDependencyNode
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
u32 mObjectType;
|
uint mObjectType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual EDependencyNodeType Type() const;
|
virtual EDependencyNodeType Type() const;
|
||||||
virtual void Serialize(IArchive& rArc);
|
virtual void Serialize(IArchive& rArc);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline u32 ObjectType() const { return mObjectType; }
|
inline uint ObjectType() const { return mObjectType; }
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
static CScriptInstanceDependency* BuildTree(CScriptObject *pInstance);
|
static CScriptInstanceDependency* BuildTree(CScriptObject *pInstance);
|
||||||
|
@ -152,17 +152,17 @@ protected:
|
||||||
class CSetCharacterDependency : public CDependencyTree
|
class CSetCharacterDependency : public CDependencyTree
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
u32 mCharSetIndex;
|
uint32 mCharSetIndex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSetCharacterDependency() : CDependencyTree() {}
|
CSetCharacterDependency() : CDependencyTree() {}
|
||||||
CSetCharacterDependency(u32 SetIndex) : CDependencyTree(), mCharSetIndex(SetIndex) {}
|
CSetCharacterDependency(uint32 SetIndex) : CDependencyTree(), mCharSetIndex(SetIndex) {}
|
||||||
|
|
||||||
virtual EDependencyNodeType Type() const;
|
virtual EDependencyNodeType Type() const;
|
||||||
virtual void Serialize(IArchive& rArc);
|
virtual void Serialize(IArchive& rArc);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline u32 CharSetIndex() const { return mCharSetIndex; }
|
inline uint32 CharSetIndex() const { return mCharSetIndex; }
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
static CSetCharacterDependency* BuildTree(const SSetCharacter& rkChar);
|
static CSetCharacterDependency* BuildTree(const SSetCharacter& rkChar);
|
||||||
|
@ -172,7 +172,7 @@ public:
|
||||||
class CSetAnimationDependency : public CDependencyTree
|
class CSetAnimationDependency : public CDependencyTree
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
std::set<u32> mCharacterIndices;
|
std::set<uint32> mCharacterIndices;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSetAnimationDependency() : CDependencyTree() {}
|
CSetAnimationDependency() : CDependencyTree() {}
|
||||||
|
@ -181,36 +181,36 @@ public:
|
||||||
virtual void Serialize(IArchive& rArc);
|
virtual void Serialize(IArchive& rArc);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline bool IsUsedByCharacter(u32 CharIdx) const { return mCharacterIndices.find(CharIdx) != mCharacterIndices.end(); }
|
inline bool IsUsedByCharacter(uint32 CharIdx) const { return mCharacterIndices.find(CharIdx) != mCharacterIndices.end(); }
|
||||||
inline bool IsUsedByAnyCharacter() const { return !mCharacterIndices.empty(); }
|
inline bool IsUsedByAnyCharacter() const { return !mCharacterIndices.empty(); }
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
static CSetAnimationDependency* BuildTree(const CAnimSet *pkOwnerSet, u32 AnimIndex);
|
static CSetAnimationDependency* BuildTree(const CAnimSet *pkOwnerSet, uint32 AnimIndex);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Node representing an animation event. Indicates which character index uses this event.
|
// Node representing an animation event. Indicates which character index uses this event.
|
||||||
class CAnimEventDependency : public CResourceDependency
|
class CAnimEventDependency : public CResourceDependency
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
u32 mCharIndex;
|
uint32 mCharIndex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAnimEventDependency() : CResourceDependency() {}
|
CAnimEventDependency() : CResourceDependency() {}
|
||||||
CAnimEventDependency(const CAssetID& rkID, u32 CharIndex)
|
CAnimEventDependency(const CAssetID& rkID, uint32 CharIndex)
|
||||||
: CResourceDependency(rkID), mCharIndex(CharIndex) {}
|
: CResourceDependency(rkID), mCharIndex(CharIndex) {}
|
||||||
|
|
||||||
virtual EDependencyNodeType Type() const;
|
virtual EDependencyNodeType Type() const;
|
||||||
virtual void Serialize(IArchive& rArc);
|
virtual void Serialize(IArchive& rArc);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline u32 CharIndex() const { return mCharIndex; }
|
inline uint32 CharIndex() const { return mCharIndex; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Node representing an area. Tracks dependencies on a per-instance basis and can separate dependencies of different script layers.
|
// Node representing an area. Tracks dependencies on a per-instance basis and can separate dependencies of different script layers.
|
||||||
class CAreaDependencyTree : public CDependencyTree
|
class CAreaDependencyTree : public CDependencyTree
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
std::vector<u32> mLayerOffsets;
|
std::vector<uint32> mLayerOffsets;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAreaDependencyTree() : CDependencyTree() {}
|
CAreaDependencyTree() : CDependencyTree() {}
|
||||||
|
@ -219,11 +219,11 @@ public:
|
||||||
virtual void Serialize(IArchive& rArc);
|
virtual void Serialize(IArchive& rArc);
|
||||||
|
|
||||||
void AddScriptLayer(CScriptLayer *pLayer, const std::vector<CAssetID>& rkExtraDeps);
|
void AddScriptLayer(CScriptLayer *pLayer, const std::vector<CAssetID>& rkExtraDeps);
|
||||||
void GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<u32>& rModuleLayerOffsetsOut) const;
|
void GetModuleDependencies(EGame Game, std::vector<TString>& rModuleDepsOut, std::vector<uint32>& rModuleLayerOffsetsOut) const;
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline u32 NumScriptLayers() const { return mLayerOffsets.size(); }
|
inline uint32 NumScriptLayers() const { return mLayerOffsets.size(); }
|
||||||
inline u32 ScriptLayerOffset(u32 LayerIdx) const { return mLayerOffsets[LayerIdx]; }
|
inline uint32 ScriptLayerOffset(uint32 LayerIdx) const { return mLayerOffsets[LayerIdx]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CDEPENDENCYTREE
|
#endif // CDEPENDENCYTREE
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "Core/CompressionUtil.h"
|
#include "Core/CompressionUtil.h"
|
||||||
#include "Core/Resource/CWorld.h"
|
#include "Core/Resource/CWorld.h"
|
||||||
#include "Core/Resource/Script/CGameTemplate.h"
|
#include "Core/Resource/Script/CGameTemplate.h"
|
||||||
#include <Common/AssertMacro.h>
|
#include <Common/Macros.h>
|
||||||
#include <Common/CScopedTimer.h>
|
#include <Common/CScopedTimer.h>
|
||||||
#include <Common/FileIO.h>
|
#include <Common/FileIO.h>
|
||||||
#include <Common/FileUtil.h>
|
#include <Common/FileUtil.h>
|
||||||
|
@ -92,7 +92,7 @@ bool CGameExporter::Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAs
|
||||||
return !mpProgress->ShouldCancel();
|
return !mpProgress->ShouldCancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameExporter::LoadResource(const CAssetID& rkID, std::vector<u8>& rBuffer)
|
void CGameExporter::LoadResource(const CAssetID& rkID, std::vector<uint8>& rBuffer)
|
||||||
{
|
{
|
||||||
SResourceInstance *pInst = FindResourceInstance(rkID);
|
SResourceInstance *pInst = FindResourceInstance(rkID);
|
||||||
if (pInst) LoadResource(*pInst, rBuffer);
|
if (pInst) LoadResource(*pInst, rBuffer);
|
||||||
|
@ -268,7 +268,7 @@ void CGameExporter::LoadPaks()
|
||||||
|
|
||||||
if (!Pak.IsValid())
|
if (!Pak.IsValid())
|
||||||
{
|
{
|
||||||
Log::Error("Couldn't open pak: " + PakPath);
|
errorf("Couldn't open pak: %s", *PakPath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,38 +278,38 @@ void CGameExporter::LoadPaks()
|
||||||
// MP1-MP3Proto
|
// MP1-MP3Proto
|
||||||
if (mGame < EGame::Corruption)
|
if (mGame < EGame::Corruption)
|
||||||
{
|
{
|
||||||
u32 PakVersion = Pak.ReadLong();
|
uint32 PakVersion = Pak.ReadLong();
|
||||||
Pak.Seek(0x4, SEEK_CUR);
|
Pak.Seek(0x4, SEEK_CUR);
|
||||||
ASSERT(PakVersion == 0x00030005);
|
ASSERT(PakVersion == 0x00030005);
|
||||||
|
|
||||||
// Echoes demo disc has a pak that ends right here.
|
// Echoes demo disc has a pak that ends right here.
|
||||||
if (!Pak.EoF())
|
if (!Pak.EoF())
|
||||||
{
|
{
|
||||||
u32 NumNamedResources = Pak.ReadLong();
|
uint32 NumNamedResources = Pak.ReadLong();
|
||||||
ASSERT(NumNamedResources > 0);
|
ASSERT(NumNamedResources > 0);
|
||||||
|
|
||||||
for (u32 iName = 0; iName < NumNamedResources; iName++)
|
for (uint32 iName = 0; iName < NumNamedResources; iName++)
|
||||||
{
|
{
|
||||||
CFourCC ResType = Pak.ReadLong();
|
CFourCC ResType = Pak.ReadLong();
|
||||||
CAssetID ResID(Pak, mGame);
|
CAssetID ResID(Pak, mGame);
|
||||||
u32 NameLen = Pak.ReadLong();
|
uint32 NameLen = Pak.ReadLong();
|
||||||
TString Name = Pak.ReadString(NameLen);
|
TString Name = Pak.ReadString(NameLen);
|
||||||
pPackage->AddResource(Name, ResID, ResType);
|
pPackage->AddResource(Name, ResID, ResType);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 NumResources = Pak.ReadLong();
|
uint32 NumResources = Pak.ReadLong();
|
||||||
|
|
||||||
// Keep track of which areas have duplicate resources
|
// Keep track of which areas have duplicate resources
|
||||||
std::set<CAssetID> PakResourceSet;
|
std::set<CAssetID> PakResourceSet;
|
||||||
bool AreaHasDuplicates = true; // Default to true so that first area is always considered as having duplicates
|
bool AreaHasDuplicates = true; // Default to true so that first area is always considered as having duplicates
|
||||||
|
|
||||||
for (u32 iRes = 0; iRes < NumResources; iRes++)
|
for (uint32 iRes = 0; iRes < NumResources; iRes++)
|
||||||
{
|
{
|
||||||
bool Compressed = (Pak.ReadLong() == 1);
|
bool Compressed = (Pak.ReadLong() == 1);
|
||||||
CFourCC ResType = Pak.ReadLong();
|
CFourCC ResType = Pak.ReadLong();
|
||||||
CAssetID ResID(Pak, mGame);
|
CAssetID ResID(Pak, mGame);
|
||||||
u32 ResSize = Pak.ReadLong();
|
uint32 ResSize = Pak.ReadLong();
|
||||||
u32 ResOffset = Pak.ReadLong();
|
uint32 ResOffset = Pak.ReadLong();
|
||||||
|
|
||||||
if (mResourceMap.find(ResID) == mResourceMap.end())
|
if (mResourceMap.find(ResID) == mResourceMap.end())
|
||||||
mResourceMap[ResID] = SResourceInstance { PakPath, ResID, ResType, ResOffset, ResSize, Compressed, false };
|
mResourceMap[ResID] = SResourceInstance { PakPath, ResID, ResType, ResOffset, ResSize, Compressed, false };
|
||||||
|
@ -333,37 +333,37 @@ void CGameExporter::LoadPaks()
|
||||||
// MP3 + DKCR
|
// MP3 + DKCR
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u32 PakVersion = Pak.ReadLong();
|
uint32 PakVersion = Pak.ReadLong();
|
||||||
u32 PakHeaderLen = Pak.ReadLong();
|
uint32 PakHeaderLen = Pak.ReadLong();
|
||||||
Pak.Seek(PakHeaderLen - 0x8, SEEK_CUR);
|
Pak.Seek(PakHeaderLen - 0x8, SEEK_CUR);
|
||||||
ASSERT(PakVersion == 2);
|
ASSERT(PakVersion == 2);
|
||||||
|
|
||||||
struct SPakSection {
|
struct SPakSection {
|
||||||
CFourCC Type; u32 Size;
|
CFourCC Type; uint32 Size;
|
||||||
};
|
};
|
||||||
std::vector<SPakSection> PakSections;
|
std::vector<SPakSection> PakSections;
|
||||||
|
|
||||||
u32 NumPakSections = Pak.ReadLong();
|
uint32 NumPakSections = Pak.ReadLong();
|
||||||
ASSERT(NumPakSections == 3);
|
ASSERT(NumPakSections == 3);
|
||||||
|
|
||||||
for (u32 iSec = 0; iSec < NumPakSections; iSec++)
|
for (uint32 iSec = 0; iSec < NumPakSections; iSec++)
|
||||||
{
|
{
|
||||||
CFourCC Type = Pak.ReadLong();
|
CFourCC Type = Pak.ReadLong();
|
||||||
u32 Size = Pak.ReadLong();
|
uint32 Size = Pak.ReadLong();
|
||||||
PakSections.push_back(SPakSection { Type, Size });
|
PakSections.push_back(SPakSection { Type, Size });
|
||||||
}
|
}
|
||||||
Pak.SeekToBoundary(64);
|
Pak.SeekToBoundary(64);
|
||||||
|
|
||||||
for (u32 iSec = 0; iSec < NumPakSections; iSec++)
|
for (uint32 iSec = 0; iSec < NumPakSections; iSec++)
|
||||||
{
|
{
|
||||||
u32 Next = Pak.Tell() + PakSections[iSec].Size;
|
uint32 Next = Pak.Tell() + PakSections[iSec].Size;
|
||||||
|
|
||||||
// Named Resources
|
// Named Resources
|
||||||
if (PakSections[iSec].Type == "STRG")
|
if (PakSections[iSec].Type == "STRG")
|
||||||
{
|
{
|
||||||
u32 NumNamedResources = Pak.ReadLong();
|
uint32 NumNamedResources = Pak.ReadLong();
|
||||||
|
|
||||||
for (u32 iName = 0; iName < NumNamedResources; iName++)
|
for (uint32 iName = 0; iName < NumNamedResources; iName++)
|
||||||
{
|
{
|
||||||
TString Name = Pak.ReadString();
|
TString Name = Pak.ReadString();
|
||||||
CFourCC ResType = Pak.ReadLong();
|
CFourCC ResType = Pak.ReadLong();
|
||||||
|
@ -375,20 +375,20 @@ void CGameExporter::LoadPaks()
|
||||||
else if (PakSections[iSec].Type == "RSHD")
|
else if (PakSections[iSec].Type == "RSHD")
|
||||||
{
|
{
|
||||||
ASSERT(PakSections[iSec + 1].Type == "DATA");
|
ASSERT(PakSections[iSec + 1].Type == "DATA");
|
||||||
u32 DataStart = Next;
|
uint32 DataStart = Next;
|
||||||
u32 NumResources = Pak.ReadLong();
|
uint32 NumResources = Pak.ReadLong();
|
||||||
|
|
||||||
// Keep track of which areas have duplicate resources
|
// Keep track of which areas have duplicate resources
|
||||||
std::set<CAssetID> PakResourceSet;
|
std::set<CAssetID> PakResourceSet;
|
||||||
bool AreaHasDuplicates = true; // Default to true so that first area is always considered as having duplicates
|
bool AreaHasDuplicates = true; // Default to true so that first area is always considered as having duplicates
|
||||||
|
|
||||||
for (u32 iRes = 0; iRes < NumResources; iRes++)
|
for (uint32 iRes = 0; iRes < NumResources; iRes++)
|
||||||
{
|
{
|
||||||
bool Compressed = (Pak.ReadLong() == 1);
|
bool Compressed = (Pak.ReadLong() == 1);
|
||||||
CFourCC Type = Pak.ReadLong();
|
CFourCC Type = Pak.ReadLong();
|
||||||
CAssetID ResID(Pak, mGame);
|
CAssetID ResID(Pak, mGame);
|
||||||
u32 Size = Pak.ReadLong();
|
uint32 Size = Pak.ReadLong();
|
||||||
u32 Offset = DataStart + Pak.ReadLong();
|
uint32 Offset = DataStart + Pak.ReadLong();
|
||||||
|
|
||||||
if (mResourceMap.find(ResID) == mResourceMap.end())
|
if (mResourceMap.find(ResID) == mResourceMap.end())
|
||||||
mResourceMap[ResID] = SResourceInstance { PakPath, ResID, Type, Offset, Size, Compressed, false };
|
mResourceMap[ResID] = SResourceInstance { PakPath, ResID, Type, Offset, Size, Compressed, false };
|
||||||
|
@ -425,7 +425,7 @@ void CGameExporter::LoadPaks()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vector<u8>& rBuffer)
|
void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vector<uint8>& rBuffer)
|
||||||
{
|
{
|
||||||
CFileInStream Pak(rkResource.PakFile, IOUtil::eBigEndian);
|
CFileInStream Pak(rkResource.PakFile, IOUtil::eBigEndian);
|
||||||
|
|
||||||
|
@ -440,15 +440,15 @@ void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vecto
|
||||||
|
|
||||||
if (mGame <= EGame::CorruptionProto)
|
if (mGame <= EGame::CorruptionProto)
|
||||||
{
|
{
|
||||||
std::vector<u8> CompressedData(rkResource.PakSize);
|
std::vector<uint8> CompressedData(rkResource.PakSize);
|
||||||
|
|
||||||
u32 UncompressedSize = Pak.ReadLong();
|
uint32 UncompressedSize = Pak.ReadLong();
|
||||||
rBuffer.resize(UncompressedSize);
|
rBuffer.resize(UncompressedSize);
|
||||||
Pak.ReadBytes(CompressedData.data(), CompressedData.size());
|
Pak.ReadBytes(CompressedData.data(), CompressedData.size());
|
||||||
|
|
||||||
if (ZlibCompressed)
|
if (ZlibCompressed)
|
||||||
{
|
{
|
||||||
u32 TotalOut;
|
uint32 TotalOut;
|
||||||
CompressionUtil::DecompressZlib(CompressedData.data(), CompressedData.size(), rBuffer.data(), rBuffer.size(), TotalOut);
|
CompressionUtil::DecompressZlib(CompressedData.data(), CompressedData.size(), rBuffer.data(), rBuffer.size(), TotalOut);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -462,40 +462,40 @@ void CGameExporter::LoadResource(const SResourceInstance& rkResource, std::vecto
|
||||||
CFourCC Magic = Pak.ReadLong();
|
CFourCC Magic = Pak.ReadLong();
|
||||||
ASSERT(Magic == "CMPD");
|
ASSERT(Magic == "CMPD");
|
||||||
|
|
||||||
u32 NumBlocks = Pak.ReadLong();
|
uint32 NumBlocks = Pak.ReadLong();
|
||||||
|
|
||||||
struct SCompressedBlock {
|
struct SCompressedBlock {
|
||||||
u32 CompressedSize; u32 UncompressedSize;
|
uint32 CompressedSize; uint32 UncompressedSize;
|
||||||
};
|
};
|
||||||
std::vector<SCompressedBlock> CompressedBlocks;
|
std::vector<SCompressedBlock> CompressedBlocks;
|
||||||
|
|
||||||
u32 TotalUncompressedSize = 0;
|
uint32 TotalUncompressedSize = 0;
|
||||||
for (u32 iBlock = 0; iBlock < NumBlocks; iBlock++)
|
for (uint32 iBlock = 0; iBlock < NumBlocks; iBlock++)
|
||||||
{
|
{
|
||||||
u32 CompressedSize = (Pak.ReadLong() & 0x00FFFFFF);
|
uint32 CompressedSize = (Pak.ReadLong() & 0x00FFFFFF);
|
||||||
u32 UncompressedSize = Pak.ReadLong();
|
uint32 UncompressedSize = Pak.ReadLong();
|
||||||
|
|
||||||
TotalUncompressedSize += UncompressedSize;
|
TotalUncompressedSize += UncompressedSize;
|
||||||
CompressedBlocks.push_back( SCompressedBlock { CompressedSize, UncompressedSize } );
|
CompressedBlocks.push_back( SCompressedBlock { CompressedSize, UncompressedSize } );
|
||||||
}
|
}
|
||||||
|
|
||||||
rBuffer.resize(TotalUncompressedSize);
|
rBuffer.resize(TotalUncompressedSize);
|
||||||
u32 Offset = 0;
|
uint32 Offset = 0;
|
||||||
|
|
||||||
for (u32 iBlock = 0; iBlock < NumBlocks; iBlock++)
|
for (uint32 iBlock = 0; iBlock < NumBlocks; iBlock++)
|
||||||
{
|
{
|
||||||
u32 CompressedSize = CompressedBlocks[iBlock].CompressedSize;
|
uint32 CompressedSize = CompressedBlocks[iBlock].CompressedSize;
|
||||||
u32 UncompressedSize = CompressedBlocks[iBlock].UncompressedSize;
|
uint32 UncompressedSize = CompressedBlocks[iBlock].UncompressedSize;
|
||||||
|
|
||||||
// Block is compressed
|
// Block is compressed
|
||||||
if (CompressedSize != UncompressedSize)
|
if (CompressedSize != UncompressedSize)
|
||||||
{
|
{
|
||||||
std::vector<u8> CompressedData(CompressedBlocks[iBlock].CompressedSize);
|
std::vector<uint8> CompressedData(CompressedBlocks[iBlock].CompressedSize);
|
||||||
Pak.ReadBytes(CompressedData.data(), CompressedData.size());
|
Pak.ReadBytes(CompressedData.data(), CompressedData.size());
|
||||||
|
|
||||||
if (ZlibCompressed)
|
if (ZlibCompressed)
|
||||||
{
|
{
|
||||||
u32 TotalOut;
|
uint32 TotalOut;
|
||||||
CompressionUtil::DecompressZlib(CompressedData.data(), CompressedData.size(), rBuffer.data() + Offset, UncompressedSize, TotalOut);
|
CompressionUtil::DecompressZlib(CompressedData.data(), CompressedData.size(), rBuffer.data() + Offset, UncompressedSize, TotalOut);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -570,7 +570,7 @@ void CGameExporter::ExportResourceEditorData()
|
||||||
CWorld *pWorld = (CWorld*) It->Load();
|
CWorld *pWorld = (CWorld*) It->Load();
|
||||||
|
|
||||||
// Set area duplicate flags
|
// Set area duplicate flags
|
||||||
for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
|
for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
|
||||||
{
|
{
|
||||||
CAssetID AreaID = pWorld->AreaResourceID(iArea);
|
CAssetID AreaID = pWorld->AreaResourceID(iArea);
|
||||||
auto Find = mAreaDuplicateMap.find(AreaID);
|
auto Find = mAreaDuplicateMap.find(AreaID);
|
||||||
|
@ -612,7 +612,7 @@ void CGameExporter::ExportResource(SResourceInstance& rRes)
|
||||||
{
|
{
|
||||||
if (!rRes.Exported)
|
if (!rRes.Exported)
|
||||||
{
|
{
|
||||||
std::vector<u8> ResourceData;
|
std::vector<uint8> ResourceData;
|
||||||
LoadResource(rRes, ResourceData);
|
LoadResource(rRes, ResourceData);
|
||||||
|
|
||||||
// Register resource and write to file
|
// Register resource and write to file
|
||||||
|
@ -657,11 +657,11 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
|
||||||
// Find the original world name in the package resource names
|
// Find the original world name in the package resource names
|
||||||
TString WorldName;
|
TString WorldName;
|
||||||
|
|
||||||
for (u32 iPkg = 0; iPkg < mpProject->NumPackages(); iPkg++)
|
for (uint32 iPkg = 0; iPkg < mpProject->NumPackages(); iPkg++)
|
||||||
{
|
{
|
||||||
CPackage *pPkg = mpProject->PackageByIndex(iPkg);
|
CPackage *pPkg = mpProject->PackageByIndex(iPkg);
|
||||||
|
|
||||||
for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
|
for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
|
||||||
{
|
{
|
||||||
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
|
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
|
||||||
|
|
||||||
|
@ -712,8 +712,8 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
|
||||||
// MP2 demo - Use text between the first and second underscores
|
// MP2 demo - Use text between the first and second underscores
|
||||||
else if (mGame == EGame::EchoesDemo)
|
else if (mGame == EGame::EchoesDemo)
|
||||||
{
|
{
|
||||||
u32 UnderscoreA = WorldName.IndexOf('_');
|
uint32 UnderscoreA = WorldName.IndexOf('_');
|
||||||
u32 UnderscoreB = WorldName.IndexOf('_', UnderscoreA + 1);
|
uint32 UnderscoreB = WorldName.IndexOf('_', UnderscoreA + 1);
|
||||||
|
|
||||||
if (UnderscoreA != UnderscoreB && UnderscoreA != -1 && UnderscoreB != -1)
|
if (UnderscoreA != UnderscoreB && UnderscoreA != -1 && UnderscoreB != -1)
|
||||||
WorldName = WorldName.SubString(UnderscoreA + 1, UnderscoreB - UnderscoreA - 1);
|
WorldName = WorldName.SubString(UnderscoreA + 1, UnderscoreB - UnderscoreA - 1);
|
||||||
|
@ -722,8 +722,8 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
|
||||||
// MP2 - Remove text before first underscore and after last underscore, strip remaining underscores (except multiplayer maps, which have one underscore)
|
// MP2 - Remove text before first underscore and after last underscore, strip remaining underscores (except multiplayer maps, which have one underscore)
|
||||||
else if (mGame == EGame::Echoes)
|
else if (mGame == EGame::Echoes)
|
||||||
{
|
{
|
||||||
u32 FirstUnderscore = WorldName.IndexOf('_');
|
uint32 FirstUnderscore = WorldName.IndexOf('_');
|
||||||
u32 LastUnderscore = WorldName.LastIndexOf('_');
|
uint32 LastUnderscore = WorldName.LastIndexOf('_');
|
||||||
|
|
||||||
if (FirstUnderscore != LastUnderscore && FirstUnderscore != -1 && LastUnderscore != -1)
|
if (FirstUnderscore != LastUnderscore && FirstUnderscore != -1 && LastUnderscore != -1)
|
||||||
{
|
{
|
||||||
|
@ -739,14 +739,14 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
|
||||||
if (WorldName.StartsWith('!'))
|
if (WorldName.StartsWith('!'))
|
||||||
WorldName = WorldName.ChopFront(1);
|
WorldName = WorldName.ChopFront(1);
|
||||||
|
|
||||||
u32 LastUnderscore = WorldName.LastIndexOf('_');
|
uint32 LastUnderscore = WorldName.LastIndexOf('_');
|
||||||
WorldName = WorldName.ChopBack(WorldName.Size() - LastUnderscore);
|
WorldName = WorldName.ChopBack(WorldName.Size() - LastUnderscore);
|
||||||
}
|
}
|
||||||
|
|
||||||
// MP3 - Remove text after last underscore
|
// MP3 - Remove text after last underscore
|
||||||
else if (mGame == EGame::Corruption)
|
else if (mGame == EGame::Corruption)
|
||||||
{
|
{
|
||||||
u32 LastUnderscore = WorldName.LastIndexOf('_');
|
uint32 LastUnderscore = WorldName.LastIndexOf('_');
|
||||||
|
|
||||||
if (LastUnderscore != -1 && !WorldName.StartsWith("front_end_"))
|
if (LastUnderscore != -1 && !WorldName.StartsWith("front_end_"))
|
||||||
WorldName = WorldName.ChopBack(WorldName.Size() - LastUnderscore);
|
WorldName = WorldName.ChopBack(WorldName.Size() - LastUnderscore);
|
||||||
|
@ -755,7 +755,7 @@ TString CGameExporter::MakeWorldName(CAssetID WorldID)
|
||||||
// DKCR - Remove text prior to first underscore
|
// DKCR - Remove text prior to first underscore
|
||||||
else if (mGame == EGame::DKCReturns)
|
else if (mGame == EGame::DKCReturns)
|
||||||
{
|
{
|
||||||
u32 Underscore = WorldName.IndexOf('_');
|
uint32 Underscore = WorldName.IndexOf('_');
|
||||||
WorldName = WorldName.ChopFront(Underscore + 1);
|
WorldName = WorldName.ChopFront(Underscore + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <Common/CAssetID.h>
|
#include <Common/CAssetID.h>
|
||||||
#include <Common/Flags.h>
|
#include <Common/Flags.h>
|
||||||
#include <Common/TString.h>
|
#include <Common/TString.h>
|
||||||
#include <Common/types.h>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <nod/nod.hpp>
|
#include <nod/nod.hpp>
|
||||||
|
|
||||||
|
@ -54,8 +53,8 @@ class CGameExporter
|
||||||
TString PakFile;
|
TString PakFile;
|
||||||
CAssetID ResourceID;
|
CAssetID ResourceID;
|
||||||
CFourCC ResourceType;
|
CFourCC ResourceType;
|
||||||
u32 PakOffset;
|
uint32 PakOffset;
|
||||||
u32 PakSize;
|
uint32 PakSize;
|
||||||
bool Compressed;
|
bool Compressed;
|
||||||
bool Exported;
|
bool Exported;
|
||||||
};
|
};
|
||||||
|
@ -76,7 +75,7 @@ class CGameExporter
|
||||||
public:
|
public:
|
||||||
CGameExporter(EDiscType DiscType, EGame Game, bool FrontEnd, ERegion Region, const TString& rkGameName, const TString& rkGameID, float BuildVersion);
|
CGameExporter(EDiscType DiscType, EGame Game, bool FrontEnd, ERegion Region, const TString& rkGameName, const TString& rkGameID, float BuildVersion);
|
||||||
bool Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAssetNameMap *pNameMap, CGameInfo *pGameInfo, IProgressNotifier *pProgress);
|
bool Export(nod::DiscBase *pDisc, const TString& rkOutputDir, CAssetNameMap *pNameMap, CGameInfo *pGameInfo, IProgressNotifier *pProgress);
|
||||||
void LoadResource(const CAssetID& rkID, std::vector<u8>& rBuffer);
|
void LoadResource(const CAssetID& rkID, std::vector<uint8>& rBuffer);
|
||||||
bool ShouldExportDiscNode(const nod::Node *pkNode, bool IsInRoot);
|
bool ShouldExportDiscNode(const nod::Node *pkNode, bool IsInRoot);
|
||||||
|
|
||||||
inline TString ProjectPath() const { return mProjectPath; }
|
inline TString ProjectPath() const { return mProjectPath; }
|
||||||
|
@ -85,7 +84,7 @@ protected:
|
||||||
bool ExtractDiscData();
|
bool ExtractDiscData();
|
||||||
bool ExtractDiscNodeRecursive(const nod::Node *pkNode, const TString& rkDir, bool RootNode, const nod::ExtractionContext& rkContext);
|
bool ExtractDiscNodeRecursive(const nod::Node *pkNode, const TString& rkDir, bool RootNode, const nod::ExtractionContext& rkContext);
|
||||||
void LoadPaks();
|
void LoadPaks();
|
||||||
void LoadResource(const SResourceInstance& rkResource, std::vector<u8>& rBuffer);
|
void LoadResource(const SResourceInstance& rkResource, std::vector<uint8>& rBuffer);
|
||||||
void ExportCookedResources();
|
void ExportCookedResources();
|
||||||
void ExportResourceEditorData();
|
void ExportResourceEditorData();
|
||||||
void ExportResource(SResourceInstance& rRes);
|
void ExportResource(SResourceInstance& rRes);
|
||||||
|
@ -94,7 +93,7 @@ protected:
|
||||||
// Convenience Functions
|
// Convenience Functions
|
||||||
inline SResourceInstance* FindResourceInstance(const CAssetID& rkID)
|
inline SResourceInstance* FindResourceInstance(const CAssetID& rkID)
|
||||||
{
|
{
|
||||||
u64 IntegralID = rkID.ToLongLong();
|
uint64 IntegralID = rkID.ToLongLong();
|
||||||
auto Found = mResourceMap.find(IntegralID);
|
auto Found = mResourceMap.find(IntegralID);
|
||||||
return (Found == mResourceMap.end() ? nullptr : &Found->second);
|
return (Found == mResourceMap.end() ? nullptr : &Found->second);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ void CGameInfo::Serialize(IArchive& rArc)
|
||||||
|
|
||||||
TString CGameInfo::GetBuildName(float BuildVer, ERegion Region) const
|
TString CGameInfo::GetBuildName(float BuildVer, ERegion Region) const
|
||||||
{
|
{
|
||||||
for (u32 iBuild = 0; iBuild < mBuilds.size(); iBuild++)
|
for (uint32 iBuild = 0; iBuild < mBuilds.size(); iBuild++)
|
||||||
{
|
{
|
||||||
const SBuildInfo& rkBuildInfo = mBuilds[iBuild];
|
const SBuildInfo& rkBuildInfo = mBuilds[iBuild];
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef CGAMEINFO
|
#ifndef CGAMEINFO
|
||||||
#define CGAMEINFO
|
#define CGAMEINFO
|
||||||
|
|
||||||
#include <Common/AssertMacro.h>
|
#include <Common/Macros.h>
|
||||||
#include <Common/CAssetID.h>
|
#include <Common/CAssetID.h>
|
||||||
#include <Common/TString.h>
|
#include <Common/TString.h>
|
||||||
#include <Common/Serialization/IArchive.h>
|
#include <Common/Serialization/IArchive.h>
|
||||||
|
|
|
@ -14,7 +14,7 @@ CGameProject::~CGameProject()
|
||||||
gpResourceStore = nullptr;
|
gpResourceStore = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
|
for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
|
||||||
delete mPackages[iPkg];
|
delete mPackages[iPkg];
|
||||||
|
|
||||||
delete mpAudioManager;
|
delete mpAudioManager;
|
||||||
|
@ -45,7 +45,7 @@ bool CGameProject::Serialize(IArchive& rArc)
|
||||||
|
|
||||||
if (!rArc.IsReader())
|
if (!rArc.IsReader())
|
||||||
{
|
{
|
||||||
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
|
for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
|
||||||
PackageList.push_back( mPackages[iPkg]->DefinitionPath(true) );
|
PackageList.push_back( mPackages[iPkg]->DefinitionPath(true) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ bool CGameProject::Serialize(IArchive& rArc)
|
||||||
{
|
{
|
||||||
ASSERT(mPackages.empty());
|
ASSERT(mPackages.empty());
|
||||||
|
|
||||||
for (u32 iPkg = 0; iPkg < PackageList.size(); iPkg++)
|
for (uint32 iPkg = 0; iPkg < PackageList.size(); iPkg++)
|
||||||
{
|
{
|
||||||
const TString& rkPackagePath = PackageList[iPkg];
|
const TString& rkPackagePath = PackageList[iPkg];
|
||||||
TString PackageName = rkPackagePath.GetFileName(false);
|
TString PackageName = rkPackagePath.GetFileName(false);
|
||||||
|
@ -122,7 +122,7 @@ bool CGameProject::MergeISO(const TString& rkIsoPath, nod::DiscWii *pOriginalIso
|
||||||
|
|
||||||
void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
|
void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
|
||||||
{
|
{
|
||||||
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
|
for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
|
||||||
{
|
{
|
||||||
CPackage *pPkg = mPackages[iPkg];
|
CPackage *pPkg = mPackages[iPkg];
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@ void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
|
||||||
// Construct a sorted list of worlds in this package
|
// Construct a sorted list of worlds in this package
|
||||||
std::list<const SNamedResource*> PackageWorlds;
|
std::list<const SNamedResource*> PackageWorlds;
|
||||||
|
|
||||||
for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
|
for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
|
||||||
{
|
{
|
||||||
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
|
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
|
||||||
|
|
||||||
|
@ -153,11 +153,11 @@ void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
|
||||||
|
|
||||||
CAssetID CGameProject::FindNamedResource(const TString& rkName) const
|
CAssetID CGameProject::FindNamedResource(const TString& rkName) const
|
||||||
{
|
{
|
||||||
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
|
for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
|
||||||
{
|
{
|
||||||
CPackage *pPkg = mPackages[iPkg];
|
CPackage *pPkg = mPackages[iPkg];
|
||||||
|
|
||||||
for (u32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
|
for (uint32 iRes = 0; iRes < pPkg->NumNamedResources(); iRes++)
|
||||||
{
|
{
|
||||||
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
|
const SNamedResource& rkRes = pPkg->NamedResourceByIndex(iRes);
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ CAssetID CGameProject::FindNamedResource(const TString& rkName) const
|
||||||
|
|
||||||
CPackage* CGameProject::FindPackage(const TString& rkName) const
|
CPackage* CGameProject::FindPackage(const TString& rkName) const
|
||||||
{
|
{
|
||||||
for (u32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
|
for (uint32 iPkg = 0; iPkg < mPackages.size(); iPkg++)
|
||||||
{
|
{
|
||||||
CPackage *pPackage = mPackages[iPkg];
|
CPackage *pPackage = mPackages[iPkg];
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include <Common/EGame.h>
|
#include <Common/EGame.h>
|
||||||
#include <Common/FileUtil.h>
|
#include <Common/FileUtil.h>
|
||||||
#include <Common/TString.h>
|
#include <Common/TString.h>
|
||||||
#include <Common/types.h>
|
|
||||||
#include <Common/FileIO/CFileLock.h>
|
#include <Common/FileIO/CFileLock.h>
|
||||||
|
|
||||||
namespace nod { class DiscWii; }
|
namespace nod { class DiscWii; }
|
||||||
|
@ -92,8 +91,8 @@ public:
|
||||||
inline void SetProjectName(const TString& rkName) { mProjectName = rkName; }
|
inline void SetProjectName(const TString& rkName) { mProjectName = rkName; }
|
||||||
|
|
||||||
inline TString Name() const { return mProjectName; }
|
inline TString Name() const { return mProjectName; }
|
||||||
inline u32 NumPackages() const { return mPackages.size(); }
|
inline uint32 NumPackages() const { return mPackages.size(); }
|
||||||
inline CPackage* PackageByIndex(u32 Index) const { return mPackages[Index]; }
|
inline CPackage* PackageByIndex(uint32 Index) const { return mPackages[Index]; }
|
||||||
inline void AddPackage(CPackage *pPackage) { mPackages.push_back(pPackage); }
|
inline void AddPackage(CPackage *pPackage) { mPackages.push_back(pPackage); }
|
||||||
inline CResourceStore* ResourceStore() const { return mpResourceStore; }
|
inline CResourceStore* ResourceStore() const { return mpResourceStore; }
|
||||||
inline CGameInfo* GameInfo() const { return mpGameInfo; }
|
inline CGameInfo* GameInfo() const { return mpGameInfo; }
|
||||||
|
|
|
@ -22,10 +22,10 @@ TString COpeningBanner::EnglishGameName() const
|
||||||
// this and prevent the string-reading function from overrunning the buffer
|
// this and prevent the string-reading function from overrunning the buffer
|
||||||
CMemoryInStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian);
|
CMemoryInStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian);
|
||||||
|
|
||||||
u32 CharSize = mWii ? 2 : 1;
|
uint32 CharSize = mWii ? 2 : 1;
|
||||||
u32 MaxLen = MaxGameNameLength();
|
uint32 MaxLen = MaxGameNameLength();
|
||||||
|
|
||||||
std::vector<u8> NameBuffer((MaxLen + 1) * CharSize, 0);
|
std::vector<uint8> NameBuffer((MaxLen + 1) * CharSize, 0);
|
||||||
Banner.GoTo( mWii ? 0xB0 : 0x1860 );
|
Banner.GoTo( mWii ? 0xB0 : 0x1860 );
|
||||||
Banner.ReadBytes(NameBuffer.data(), MaxLen * CharSize);
|
Banner.ReadBytes(NameBuffer.data(), MaxLen * CharSize);
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ TString COpeningBanner::EnglishGameName() const
|
||||||
void COpeningBanner::SetEnglishGameName(const TString& rkName)
|
void COpeningBanner::SetEnglishGameName(const TString& rkName)
|
||||||
{
|
{
|
||||||
CMemoryOutStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian);
|
CMemoryOutStream Banner(mBannerData.data(), mBannerData.size(), IOUtil::eBigEndian);
|
||||||
u32 PadCount = 0;
|
uint32 PadCount = 0;
|
||||||
|
|
||||||
u32 MaxLen = MaxGameNameLength();
|
uint32 MaxLen = MaxGameNameLength();
|
||||||
ASSERT(rkName.Size() <= MaxLen);
|
ASSERT(rkName.Size() <= MaxLen);
|
||||||
|
|
||||||
if (mWii)
|
if (mWii)
|
||||||
|
@ -54,7 +54,7 @@ void COpeningBanner::SetEnglishGameName(const TString& rkName)
|
||||||
PadCount = MaxLen - rkName.Size();
|
PadCount = MaxLen - rkName.Size();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 Pad = 0; Pad < PadCount; Pad++)
|
for (uint32 Pad = 0; Pad < PadCount; Pad++)
|
||||||
Banner.WriteByte(0);
|
Banner.WriteByte(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void COpeningBanner::Save()
|
||||||
Banner.WriteBytes(mBannerData.data(), mBannerData.size());
|
Banner.WriteBytes(mBannerData.data(), mBannerData.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 COpeningBanner::MaxGameNameLength() const
|
uint32 COpeningBanner::MaxGameNameLength() const
|
||||||
{
|
{
|
||||||
return (mWii ? 21 : 64);
|
return (mWii ? 21 : 64);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ class CGameProject;
|
||||||
class COpeningBanner
|
class COpeningBanner
|
||||||
{
|
{
|
||||||
CGameProject *mpProj;
|
CGameProject *mpProj;
|
||||||
std::vector<u8> mBannerData;
|
std::vector<uint8> mBannerData;
|
||||||
bool mWii;
|
bool mWii;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -18,7 +18,7 @@ public:
|
||||||
void SetEnglishGameName(const TString& rkName);
|
void SetEnglishGameName(const TString& rkName);
|
||||||
void Save();
|
void Save();
|
||||||
|
|
||||||
u32 MaxGameNameLength() const;
|
uint32 MaxGameNameLength() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // COPENINGBANNER_H
|
#endif // COPENINGBANNER_H
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "CGameProject.h"
|
#include "CGameProject.h"
|
||||||
#include "Core/CompressionUtil.h"
|
#include "Core/CompressionUtil.h"
|
||||||
#include "Core/Resource/Cooker/CWorldCooker.h"
|
#include "Core/Resource/Cooker/CWorldCooker.h"
|
||||||
#include <Common/AssertMacro.h>
|
#include <Common/Macros.h>
|
||||||
#include <Common/FileIO.h>
|
#include <Common/FileIO.h>
|
||||||
#include <Common/FileUtil.h>
|
#include <Common/FileUtil.h>
|
||||||
#include <Common/Serialization/XML.h>
|
#include <Common/Serialization/XML.h>
|
||||||
|
@ -69,7 +69,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||||
CPackageDependencyListBuilder Builder(this);
|
CPackageDependencyListBuilder Builder(this);
|
||||||
std::list<CAssetID> AssetList;
|
std::list<CAssetID> AssetList;
|
||||||
Builder.BuildDependencyList(true, AssetList);
|
Builder.BuildDependencyList(true, AssetList);
|
||||||
Log::Write(TString::FromInt32(AssetList.size(), 0, 10) + " assets in " + Name() + ".pak");
|
debugf("%d assets in %s.pak", AssetList.size(), *Name());
|
||||||
|
|
||||||
// Write new pak
|
// Write new pak
|
||||||
TString PakPath = CookedPackagePath(false);
|
TString PakPath = CookedPackagePath(false);
|
||||||
|
@ -77,19 +77,19 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||||
|
|
||||||
if (!Pak.IsValid())
|
if (!Pak.IsValid())
|
||||||
{
|
{
|
||||||
Log::Error("Couldn't cook package " + CookedPackagePath(true) + "; unable to open package for writing");
|
errorf("Couldn't cook package %s; unable to open package for writing", *CookedPackagePath(true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
EGame Game = mpProject->Game();
|
EGame Game = mpProject->Game();
|
||||||
u32 Alignment = (Game <= EGame::CorruptionProto ? 0x20 : 0x40);
|
uint32 Alignment = (Game <= EGame::CorruptionProto ? 0x20 : 0x40);
|
||||||
u32 AlignmentMinusOne = Alignment - 1;
|
uint32 AlignmentMinusOne = Alignment - 1;
|
||||||
|
|
||||||
u32 TocOffset = 0;
|
uint32 TocOffset = 0;
|
||||||
u32 NamesSize = 0;
|
uint32 NamesSize = 0;
|
||||||
u32 ResTableOffset = 0;
|
uint32 ResTableOffset = 0;
|
||||||
u32 ResTableSize = 0;
|
uint32 ResTableSize = 0;
|
||||||
u32 ResDataSize = 0;
|
uint32 ResDataSize = 0;
|
||||||
|
|
||||||
// Write MP1 pak header
|
// Write MP1 pak header
|
||||||
if (Game <= EGame::CorruptionProto)
|
if (Game <= EGame::CorruptionProto)
|
||||||
|
@ -123,7 +123,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||||
Pak.WriteToBoundary(0x40, 0);
|
Pak.WriteToBoundary(0x40, 0);
|
||||||
|
|
||||||
// Named Resources
|
// Named Resources
|
||||||
u32 NamesStart = Pak.Tell();
|
uint32 NamesStart = Pak.Tell();
|
||||||
Pak.WriteLong(mResources.size());
|
Pak.WriteLong(mResources.size());
|
||||||
|
|
||||||
for (auto Iter = mResources.begin(); Iter != mResources.end(); Iter++)
|
for (auto Iter = mResources.begin(); Iter != mResources.end(); Iter++)
|
||||||
|
@ -143,7 +143,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||||
Pak.WriteLong(AssetList.size());
|
Pak.WriteLong(AssetList.size());
|
||||||
CAssetID Dummy = CAssetID::InvalidID(Game);
|
CAssetID Dummy = CAssetID::InvalidID(Game);
|
||||||
|
|
||||||
for (u32 iRes = 0; iRes < AssetList.size(); iRes++)
|
for (uint32 iRes = 0; iRes < AssetList.size(); iRes++)
|
||||||
{
|
{
|
||||||
Pak.WriteLongLong(0);
|
Pak.WriteLongLong(0);
|
||||||
Dummy.Write(Pak);
|
Dummy.Write(Pak);
|
||||||
|
@ -157,18 +157,18 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||||
struct SResourceTableInfo
|
struct SResourceTableInfo
|
||||||
{
|
{
|
||||||
CResourceEntry *pEntry;
|
CResourceEntry *pEntry;
|
||||||
u32 Offset;
|
uint32 Offset;
|
||||||
u32 Size;
|
uint32 Size;
|
||||||
bool Compressed;
|
bool Compressed;
|
||||||
};
|
};
|
||||||
std::vector<SResourceTableInfo> ResourceTableData(AssetList.size());
|
std::vector<SResourceTableInfo> ResourceTableData(AssetList.size());
|
||||||
u32 ResIdx = 0;
|
uint32 ResIdx = 0;
|
||||||
u32 ResDataOffset = Pak.Tell();
|
uint32 ResDataOffset = Pak.Tell();
|
||||||
|
|
||||||
for (auto Iter = AssetList.begin(); Iter != AssetList.end() && !pProgress->ShouldCancel(); Iter++, ResIdx++)
|
for (auto Iter = AssetList.begin(); Iter != AssetList.end() && !pProgress->ShouldCancel(); Iter++, ResIdx++)
|
||||||
{
|
{
|
||||||
// Initialize entry, recook assets if needed
|
// Initialize entry, recook assets if needed
|
||||||
u32 AssetOffset = Pak.Tell();
|
uint32 AssetOffset = Pak.Tell();
|
||||||
CAssetID ID = *Iter;
|
CAssetID ID = *Iter;
|
||||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
||||||
ASSERT(pEntry != nullptr);
|
ASSERT(pEntry != nullptr);
|
||||||
|
@ -193,15 +193,15 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||||
// Load resource data
|
// Load resource data
|
||||||
CFileInStream CookedAsset(pEntry->CookedAssetPath(), IOUtil::eBigEndian);
|
CFileInStream CookedAsset(pEntry->CookedAssetPath(), IOUtil::eBigEndian);
|
||||||
ASSERT(CookedAsset.IsValid());
|
ASSERT(CookedAsset.IsValid());
|
||||||
u32 ResourceSize = CookedAsset.Size();
|
uint32 ResourceSize = CookedAsset.Size();
|
||||||
|
|
||||||
std::vector<u8> ResourceData(ResourceSize);
|
std::vector<uint8> ResourceData(ResourceSize);
|
||||||
CookedAsset.ReadBytes(ResourceData.data(), ResourceData.size());
|
CookedAsset.ReadBytes(ResourceData.data(), ResourceData.size());
|
||||||
|
|
||||||
// Check if this asset should be compressed; there are a few resource types that are
|
// Check if this asset should be compressed; there are a few resource types that are
|
||||||
// always compressed, and some types that are compressed if they're over a certain size
|
// always compressed, and some types that are compressed if they're over a certain size
|
||||||
EResType Type = pEntry->ResourceType();
|
EResType Type = pEntry->ResourceType();
|
||||||
u32 CompressThreshold = (Game <= EGame::CorruptionProto ? 0x400 : 0x80);
|
uint32 CompressThreshold = (Game <= EGame::CorruptionProto ? 0x400 : 0x80);
|
||||||
|
|
||||||
bool ShouldAlwaysCompress = (Type == eTexture || Type == eModel || Type == eSkin ||
|
bool ShouldAlwaysCompress = (Type == eTexture || Type == eModel || Type == eSkin ||
|
||||||
Type == eAnimSet || Type == eAnimation || Type == eFont);
|
Type == eAnimSet || Type == eAnimation || Type == eFont);
|
||||||
|
@ -230,8 +230,8 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u32 CompressedSize;
|
uint32 CompressedSize;
|
||||||
std::vector<u8> CompressedData(ResourceData.size() * 2);
|
std::vector<uint8> CompressedData(ResourceData.size() * 2);
|
||||||
bool Success = false;
|
bool Success = false;
|
||||||
|
|
||||||
if (Game <= EGame::EchoesDemo || Game == EGame::DKCReturns)
|
if (Game <= EGame::EchoesDemo || Game == EGame::DKCReturns)
|
||||||
|
@ -242,9 +242,9 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||||
// Make sure that the compressed data is actually smaller, accounting for padding + uncompressed size value
|
// Make sure that the compressed data is actually smaller, accounting for padding + uncompressed size value
|
||||||
if (Success)
|
if (Success)
|
||||||
{
|
{
|
||||||
u32 CompressionHeaderSize = (Game <= EGame::CorruptionProto ? 4 : 0x10);
|
uint32 CompressionHeaderSize = (Game <= EGame::CorruptionProto ? 4 : 0x10);
|
||||||
u32 PaddedUncompressedSize = (ResourceSize + AlignmentMinusOne) & ~AlignmentMinusOne;
|
uint32 PaddedUncompressedSize = (ResourceSize + AlignmentMinusOne) & ~AlignmentMinusOne;
|
||||||
u32 PaddedCompressedSize = (CompressedSize + CompressionHeaderSize + AlignmentMinusOne) & ~AlignmentMinusOne;
|
uint32 PaddedCompressedSize = (CompressedSize + CompressionHeaderSize + AlignmentMinusOne) & ~AlignmentMinusOne;
|
||||||
Success = (PaddedCompressedSize < PaddedUncompressedSize);
|
Success = (PaddedCompressedSize < PaddedUncompressedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||||
// Write resource table for real
|
// Write resource table for real
|
||||||
Pak.Seek(ResTableOffset+4, SEEK_SET);
|
Pak.Seek(ResTableOffset+4, SEEK_SET);
|
||||||
|
|
||||||
for (u32 iRes = 0; iRes < AssetList.size(); iRes++)
|
for (uint32 iRes = 0; iRes < AssetList.size(); iRes++)
|
||||||
{
|
{
|
||||||
const SResourceTableInfo& rkInfo = ResourceTableData[iRes];
|
const SResourceTableInfo& rkInfo = ResourceTableData[iRes];
|
||||||
CResourceEntry *pEntry = rkInfo.pEntry;
|
CResourceEntry *pEntry = rkInfo.pEntry;
|
||||||
|
@ -321,7 +321,7 @@ void CPackage::Cook(IProgressNotifier *pProgress)
|
||||||
|
|
||||||
// Clear recook flag
|
// Clear recook flag
|
||||||
mNeedsRecook = false;
|
mNeedsRecook = false;
|
||||||
Log::Write("Finished writing " + PakPath);
|
debugf("Finished writing %s", *PakPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
Save();
|
Save();
|
||||||
|
@ -346,31 +346,31 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
||||||
|
|
||||||
if (!Pak.IsValid() || Pak.Size() == 0)
|
if (!Pak.IsValid() || Pak.Size() == 0)
|
||||||
{
|
{
|
||||||
Log::Error("Failed to compare to original asset list; couldn't open the original pak");
|
errorf("Failed to compare to original asset list; couldn't open the original pak");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine pak version
|
// Determine pak version
|
||||||
u32 PakVersion = Pak.ReadLong();
|
uint32 PakVersion = Pak.ReadLong();
|
||||||
std::set<CAssetID> OldListSet;
|
std::set<CAssetID> OldListSet;
|
||||||
|
|
||||||
// Read MP1/2 pak
|
// Read MP1/2 pak
|
||||||
if (PakVersion == 0x00030005)
|
if (PakVersion == 0x00030005)
|
||||||
{
|
{
|
||||||
Pak.Seek(0x4, SEEK_CUR);
|
Pak.Seek(0x4, SEEK_CUR);
|
||||||
u32 NumNamedResources = Pak.ReadLong();
|
uint32 NumNamedResources = Pak.ReadLong();
|
||||||
|
|
||||||
for (u32 iName = 0; iName < NumNamedResources; iName++)
|
for (uint32 iName = 0; iName < NumNamedResources; iName++)
|
||||||
{
|
{
|
||||||
Pak.Seek(0x8, SEEK_CUR);
|
Pak.Seek(0x8, SEEK_CUR);
|
||||||
u32 NameLen = Pak.ReadLong();
|
uint32 NameLen = Pak.ReadLong();
|
||||||
Pak.Seek(NameLen, SEEK_CUR);
|
Pak.Seek(NameLen, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a set out of the original pak resource list
|
// Build a set out of the original pak resource list
|
||||||
u32 NumResources = Pak.ReadLong();
|
uint32 NumResources = Pak.ReadLong();
|
||||||
|
|
||||||
for (u32 iRes = 0; iRes < NumResources; iRes++)
|
for (uint32 iRes = 0; iRes < NumResources; iRes++)
|
||||||
{
|
{
|
||||||
Pak.Seek(0x8, SEEK_CUR);
|
Pak.Seek(0x8, SEEK_CUR);
|
||||||
OldListSet.insert( CAssetID(Pak, e32Bit) );
|
OldListSet.insert( CAssetID(Pak, e32Bit) );
|
||||||
|
@ -386,15 +386,15 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
||||||
// Skip named resources
|
// Skip named resources
|
||||||
Pak.Seek(0x44, SEEK_SET);
|
Pak.Seek(0x44, SEEK_SET);
|
||||||
CFourCC StringSecType = Pak.ReadLong();
|
CFourCC StringSecType = Pak.ReadLong();
|
||||||
u32 StringSecSize = Pak.ReadLong();
|
uint32 StringSecSize = Pak.ReadLong();
|
||||||
ASSERT(StringSecType == "STRG");
|
ASSERT(StringSecType == "STRG");
|
||||||
|
|
||||||
Pak.Seek(0x80 + StringSecSize, SEEK_SET);
|
Pak.Seek(0x80 + StringSecSize, SEEK_SET);
|
||||||
|
|
||||||
// Read resource table
|
// Read resource table
|
||||||
u32 NumResources = Pak.ReadLong();
|
uint32 NumResources = Pak.ReadLong();
|
||||||
|
|
||||||
for (u32 iRes = 0; iRes < NumResources; iRes++)
|
for (uint32 iRes = 0; iRes < NumResources; iRes++)
|
||||||
{
|
{
|
||||||
Pak.Seek(0x8, SEEK_CUR);
|
Pak.Seek(0x8, SEEK_CUR);
|
||||||
OldListSet.insert( CAssetID(Pak, e64Bit) );
|
OldListSet.insert( CAssetID(Pak, e64Bit) );
|
||||||
|
@ -411,7 +411,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
||||||
{
|
{
|
||||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
||||||
TString Extension = (pEntry ? "." + pEntry->CookedExtension() : "");
|
TString Extension = (pEntry ? "." + pEntry->CookedExtension() : "");
|
||||||
Log::Error("Missing resource: " + ID.ToString() + Extension);
|
warnf("Missing resource: %s%s", *ID.ToString(), *Extension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ void CPackage::CompareOriginalAssetList(const std::list<CAssetID>& rkNewList)
|
||||||
{
|
{
|
||||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
CResourceEntry *pEntry = gpResourceStore->FindEntry(ID);
|
||||||
TString Extension = (pEntry ? "." + pEntry->CookedExtension() : "");
|
TString Extension = (pEntry ? "." + pEntry->CookedExtension() : "");
|
||||||
Log::Error("Extra resource: " + ID.ToString() + Extension);
|
warnf("Extra resource: %s%s", *ID.ToString(), *Extension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,8 @@ public:
|
||||||
inline TString Name() const { return mPakName; }
|
inline TString Name() const { return mPakName; }
|
||||||
inline TString Path() const { return mPakPath; }
|
inline TString Path() const { return mPakPath; }
|
||||||
inline CGameProject* Project() const { return mpProject; }
|
inline CGameProject* Project() const { return mpProject; }
|
||||||
inline u32 NumNamedResources() const { return mResources.size(); }
|
inline uint32 NumNamedResources() const { return mResources.size(); }
|
||||||
inline const SNamedResource& NamedResourceByIndex(u32 Idx) const { return mResources[Idx]; }
|
inline const SNamedResource& NamedResourceByIndex(uint32 Idx) const { return mResources[Idx]; }
|
||||||
inline bool NeedsRecook() const { return mNeedsRecook; }
|
inline bool NeedsRecook() const { return mNeedsRecook; }
|
||||||
|
|
||||||
inline void SetPakName(TString NewName) { mPakName = NewName; }
|
inline void SetPakName(TString NewName) { mPakName = NewName; }
|
||||||
|
|
|
@ -96,7 +96,7 @@ bool CResourceEntry::LoadMetadata()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::Error(Path + ": Failed to load metadata file!");
|
errorf("%s: Failed to load metadata file!", *Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -174,7 +174,7 @@ void CResourceEntry::UpdateDependencies()
|
||||||
|
|
||||||
if (!mpResource)
|
if (!mpResource)
|
||||||
{
|
{
|
||||||
Log::Error("Unable to update cached dependencies; failed to load resource");
|
errorf("Unable to update cached dependencies; failed to load resource");
|
||||||
mpDependencies = new CDependencyTree();
|
mpDependencies = new CDependencyTree();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ bool CResourceEntry::IsInDirectory(CVirtualDirectory *pDir) const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 CResourceEntry::Size() const
|
uint64 CResourceEntry::Size() const
|
||||||
{
|
{
|
||||||
if (mCachedSize == -1)
|
if (mCachedSize == -1)
|
||||||
{
|
{
|
||||||
|
@ -294,8 +294,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/)
|
||||||
|
|
||||||
if (!Writer.Save())
|
if (!Writer.Save())
|
||||||
{
|
{
|
||||||
Log::Error("Failed to save raw resource: " + Path);
|
errorf("Failed to save raw resource: %s", *Path);
|
||||||
DEBUG_BREAK;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +308,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/)
|
||||||
|
|
||||||
if (!CookSuccess)
|
if (!CookSuccess)
|
||||||
{
|
{
|
||||||
Log::Error("Failed to save resource: " + Name() + "." + CookedExtension().ToString());
|
errorf("Failed to save resource: %s.%s", *Name(), *CookedExtension().ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -324,7 +323,7 @@ bool CResourceEntry::Save(bool SkipCacheSave /*= false*/)
|
||||||
mpStore->ConditionalSaveStore();
|
mpStore->ConditionalSaveStore();
|
||||||
|
|
||||||
// Flag dirty any packages that contain this resource.
|
// Flag dirty any packages that contain this resource.
|
||||||
for (u32 iPkg = 0; iPkg < mpStore->Project()->NumPackages(); iPkg++)
|
for (uint32 iPkg = 0; iPkg < mpStore->Project()->NumPackages(); iPkg++)
|
||||||
{
|
{
|
||||||
CPackage *pPkg = mpStore->Project()->PackageByIndex(iPkg);
|
CPackage *pPkg = mpStore->Project()->PackageByIndex(iPkg);
|
||||||
|
|
||||||
|
@ -352,7 +351,7 @@ bool CResourceEntry::Cook()
|
||||||
CFileOutStream File(Path, IOUtil::eBigEndian);
|
CFileOutStream File(Path, IOUtil::eBigEndian);
|
||||||
if (!File.IsValid())
|
if (!File.IsValid())
|
||||||
{
|
{
|
||||||
Log::Error("Failed to open cooked file for writing: " + Path);
|
errorf("Failed to open cooked file for writing: %s", *Path);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,7 +389,7 @@ CResource* CResourceEntry::Load()
|
||||||
|
|
||||||
if (!Reader.IsValid())
|
if (!Reader.IsValid())
|
||||||
{
|
{
|
||||||
Log::Error("Failed to load raw resource; falling back on cooked. Raw path: " + RawAssetPath());
|
errorf("Failed to load raw resource; falling back on cooked. Raw path: %s", *RawAssetPath());
|
||||||
delete mpResource;
|
delete mpResource;
|
||||||
mpResource = nullptr;
|
mpResource = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -414,7 +413,7 @@ CResource* CResourceEntry::Load()
|
||||||
|
|
||||||
if (!File.IsValid())
|
if (!File.IsValid())
|
||||||
{
|
{
|
||||||
Log::Error("Failed to open cooked resource: " + CookedAssetPath(true));
|
errorf("Failed to open cooked resource: %s", *CookedAssetPath(true));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -423,7 +422,7 @@ CResource* CResourceEntry::Load()
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::Error("Couldn't locate resource: " + CookedAssetPath(true));
|
errorf("Couldn't locate resource: %s", *CookedAssetPath(true));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,7 +499,10 @@ bool CResourceEntry::MoveAndRename(const TString& rkDir, const TString& rkName,
|
||||||
TString NewRawPath = RawAssetPath();
|
TString NewRawPath = RawAssetPath();
|
||||||
TString NewMetaPath = MetadataFilePath();
|
TString NewMetaPath = MetadataFilePath();
|
||||||
|
|
||||||
Log::Write("MOVING RESOURCE: " + FileUtil::MakeRelative(OldCookedPath, mpStore->ResourcesDir()) + " --> " + FileUtil::MakeRelative(NewCookedPath, mpStore->ResourcesDir()));
|
debugf("MOVING RESOURCE: %s --> %s",
|
||||||
|
*FileUtil::MakeRelative(OldCookedPath, mpStore->ResourcesDir()),
|
||||||
|
*FileUtil::MakeRelative(NewCookedPath, mpStore->ResourcesDir())
|
||||||
|
);
|
||||||
|
|
||||||
// If the old/new paths are the same then we should have already exited as CanMoveTo() should have returned false
|
// If the old/new paths are the same then we should have already exited as CanMoveTo() should have returned false
|
||||||
ASSERT(OldCookedPath != NewCookedPath && OldRawPath != NewRawPath && OldMetaPath != NewMetaPath);
|
ASSERT(OldCookedPath != NewCookedPath && OldRawPath != NewRawPath && OldMetaPath != NewMetaPath);
|
||||||
|
@ -586,7 +588,7 @@ bool CResourceEntry::MoveAndRename(const TString& rkDir, const TString& rkName,
|
||||||
// Otherwise, revert changes and let the caller know the move failed
|
// Otherwise, revert changes and let the caller know the move failed
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::Error("MOVE FAILED: " + MoveFailReason);
|
errorf("MOVE FAILED: %s", *MoveFailReason);
|
||||||
mpDirectory = pOldDir;
|
mpDirectory = pOldDir;
|
||||||
mName = OldName;
|
mName = OldName;
|
||||||
mpStore->ConditionalDeleteDirectory(pNewDir, false);
|
mpStore->ConditionalDeleteDirectory(pNewDir, false);
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include <Common/CAssetID.h>
|
#include <Common/CAssetID.h>
|
||||||
#include <Common/CFourCC.h>
|
#include <Common/CFourCC.h>
|
||||||
#include <Common/Flags.h>
|
#include <Common/Flags.h>
|
||||||
#include <Common/types.h>
|
|
||||||
|
|
||||||
class CResource;
|
class CResource;
|
||||||
class CGameProject;
|
class CGameProject;
|
||||||
|
@ -37,7 +36,7 @@ class CResourceEntry
|
||||||
FResEntryFlags mFlags;
|
FResEntryFlags mFlags;
|
||||||
|
|
||||||
mutable bool mMetadataDirty;
|
mutable bool mMetadataDirty;
|
||||||
mutable u64 mCachedSize;
|
mutable uint64 mCachedSize;
|
||||||
mutable TString mCachedUppercaseName; // This is used to speed up case-insensitive sorting and filtering.
|
mutable TString mCachedUppercaseName; // This is used to speed up case-insensitive sorting and filtering.
|
||||||
|
|
||||||
// Private constructor
|
// Private constructor
|
||||||
|
@ -66,7 +65,7 @@ public:
|
||||||
CFourCC CookedExtension() const;
|
CFourCC CookedExtension() const;
|
||||||
TString MetadataFilePath(bool Relative = false) const;
|
TString MetadataFilePath(bool Relative = false) const;
|
||||||
bool IsInDirectory(CVirtualDirectory *pDir) const;
|
bool IsInDirectory(CVirtualDirectory *pDir) const;
|
||||||
u64 Size() const;
|
uint64 Size() const;
|
||||||
bool NeedsRecook() const;
|
bool NeedsRecook() const;
|
||||||
bool Save(bool SkipCacheSave = false);
|
bool Save(bool SkipCacheSave = false);
|
||||||
bool Cook();
|
bool Cook();
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "CResourceIterator.h"
|
#include "CResourceIterator.h"
|
||||||
#include "Core/IUIRelay.h"
|
#include "Core/IUIRelay.h"
|
||||||
#include "Core/Resource/CResource.h"
|
#include "Core/Resource/CResource.h"
|
||||||
#include <Common/AssertMacro.h>
|
#include <Common/Macros.h>
|
||||||
#include <Common/FileUtil.h>
|
#include <Common/FileUtil.h>
|
||||||
#include <Common/Log.h>
|
#include <Common/Log.h>
|
||||||
#include <Common/Serialization/Binary.h>
|
#include <Common/Serialization/Binary.h>
|
||||||
|
@ -54,7 +54,7 @@ void RecursiveGetListOfEmptyDirectories(CVirtualDirectory *pDir, TStringList& rO
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (u32 SubIdx = 0; SubIdx < pDir->NumSubdirectories(); SubIdx++)
|
for (uint32 SubIdx = 0; SubIdx < pDir->NumSubdirectories(); SubIdx++)
|
||||||
RecursiveGetListOfEmptyDirectories(pDir->SubdirectoryByIndex(SubIdx), rOutList);
|
RecursiveGetListOfEmptyDirectories(pDir->SubdirectoryByIndex(SubIdx), rOutList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,12 +65,12 @@ bool CResourceStore::SerializeDatabaseCache(IArchive& rArc)
|
||||||
if (rArc.ParamBegin("Resources", 0))
|
if (rArc.ParamBegin("Resources", 0))
|
||||||
{
|
{
|
||||||
// Serialize resources
|
// Serialize resources
|
||||||
u32 ResourceCount = mResourceEntries.size();
|
uint32 ResourceCount = mResourceEntries.size();
|
||||||
rArc << SerialParameter("ResourceCount", ResourceCount);
|
rArc << SerialParameter("ResourceCount", ResourceCount);
|
||||||
|
|
||||||
if (rArc.IsReader())
|
if (rArc.IsReader())
|
||||||
{
|
{
|
||||||
for (u32 ResIdx = 0; ResIdx < ResourceCount; ResIdx++)
|
for (uint32 ResIdx = 0; ResIdx < ResourceCount; ResIdx++)
|
||||||
{
|
{
|
||||||
if (rArc.ParamBegin("Resource", 0))
|
if (rArc.ParamBegin("Resource", 0))
|
||||||
{
|
{
|
||||||
|
@ -195,12 +195,12 @@ void CResourceStore::CloseProject()
|
||||||
// If there are, that means something didn't clean up resource references properly on project close!!!
|
// If there are, that means something didn't clean up resource references properly on project close!!!
|
||||||
if (!mLoadedResources.empty())
|
if (!mLoadedResources.empty())
|
||||||
{
|
{
|
||||||
Log::Error(TString::FromInt32(mLoadedResources.size(), 0, 10) + " resources still loaded on project close:");
|
warnf("%d resources still loaded on project close:", mLoadedResources.size());
|
||||||
|
|
||||||
for (auto Iter = mLoadedResources.begin(); Iter != mLoadedResources.end(); Iter++)
|
for (auto Iter = mLoadedResources.begin(); Iter != mLoadedResources.end(); Iter++)
|
||||||
{
|
{
|
||||||
CResourceEntry *pEntry = Iter->second;
|
CResourceEntry *pEntry = Iter->second;
|
||||||
Log::Write("\t" + pEntry->Name() + "." + pEntry->CookedExtension().ToString());
|
warnf("\t%s.%s", *pEntry->Name(), *pEntry->CookedExtension().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
|
@ -325,7 +325,7 @@ bool CResourceStore::BuildFromDirectory(bool ShouldGenerateCacheFile)
|
||||||
|
|
||||||
if (!pTypeInfo)
|
if (!pTypeInfo)
|
||||||
{
|
{
|
||||||
Log::Error("Found resource but couldn't register because failed to identify resource type: " + RelPath);
|
errorf("Found resource but couldn't register because failed to identify resource type: %s", *RelPath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType
|
||||||
CResourceEntry *pEntry = FindEntry(rkID);
|
CResourceEntry *pEntry = FindEntry(rkID);
|
||||||
|
|
||||||
if (pEntry)
|
if (pEntry)
|
||||||
Log::Error("Attempted to register resource that's already tracked in the database: " + rkID.ToString() + " / " + rkDir + " / " + rkName);
|
errorf("Attempted to register resource that's already tracked in the database: %s / %s / %s", *rkID.ToString(), *rkDir, *rkName);
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -401,7 +401,7 @@ CResourceEntry* CResourceStore::RegisterResource(const CAssetID& rkID, EResType
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
Log::Error("Invalid resource path, failed to register: " + rkDir + rkName);
|
errorf("Invalid resource path, failed to register: %s%s", *rkDir, *rkName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pEntry;
|
return pEntry;
|
||||||
|
@ -419,7 +419,7 @@ CResource* CResourceStore::LoadResource(const CAssetID& rkID)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Resource doesn't seem to exist
|
// Resource doesn't seem to exist
|
||||||
Log::Error("Can't find requested resource with ID \"" + rkID.ToString() + "\".");;
|
warnf("Can't find requested resource with ID \"%s\"", *rkID.ToString());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -440,7 +440,7 @@ CResource* CResourceStore::LoadResource(const CAssetID& rkID, EResType Type)
|
||||||
CResTypeInfo *pGotType = pRes->TypeInfo();
|
CResTypeInfo *pGotType = pRes->TypeInfo();
|
||||||
ASSERT(pExpectedType && pGotType);
|
ASSERT(pExpectedType && pGotType);
|
||||||
|
|
||||||
Log::Error("Resource with ID \"" + rkID.ToString() + "\" requested with the wrong type; expected " + pExpectedType->TypeName() + " asset, got " + pGotType->TypeName() + " asset");
|
errorf("Resource with ID \"%s\" requested with the wrong type; expected %s asset, get %s asset", *rkID.ToString(), *pExpectedType->TypeName(), *pGotType->TypeName());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -487,7 +487,7 @@ void CResourceStore::TrackLoadedResource(CResourceEntry *pEntry)
|
||||||
void CResourceStore::DestroyUnreferencedResources()
|
void CResourceStore::DestroyUnreferencedResources()
|
||||||
{
|
{
|
||||||
// This can be updated to avoid the do-while loop when reference lookup is implemented.
|
// This can be updated to avoid the do-while loop when reference lookup is implemented.
|
||||||
u32 NumDeleted;
|
uint32 NumDeleted;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
@ -546,7 +546,7 @@ void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, boo
|
||||||
|
|
||||||
if (!pContentsFile)
|
if (!pContentsFile)
|
||||||
{
|
{
|
||||||
Log::Error("Failed to open .contents.txt file: " + rkTxtPath);
|
errorf("Failed to open .contents.txt file: %s", *rkTxtPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,12 +559,12 @@ void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, boo
|
||||||
TString Line(LineBuffer);
|
TString Line(LineBuffer);
|
||||||
if (Line.IsEmpty()) break;
|
if (Line.IsEmpty()) break;
|
||||||
|
|
||||||
u32 IDStart = Line.IndexOfPhrase("0x") + 2;
|
uint32 IDStart = Line.IndexOfPhrase("0x") + 2;
|
||||||
if (IDStart == 1) continue;
|
if (IDStart == 1) continue;
|
||||||
|
|
||||||
u32 IDEnd = Line.IndexOf(" \t", IDStart);
|
uint32 IDEnd = Line.IndexOf(" \t", IDStart);
|
||||||
u32 PathStart = IDEnd + 1;
|
uint32 PathStart = IDEnd + 1;
|
||||||
u32 PathEnd = Line.Size() - 5;
|
uint32 PathEnd = Line.Size() - 5;
|
||||||
|
|
||||||
TString IDStr = Line.SubString(IDStart, IDEnd - IDStart);
|
TString IDStr = Line.SubString(IDStart, IDEnd - IDStart);
|
||||||
TString Path = Line.SubString(PathStart, PathEnd - PathStart);
|
TString Path = Line.SubString(PathStart, PathEnd - PathStart);
|
||||||
|
@ -576,7 +576,7 @@ void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, boo
|
||||||
if (pEntry)
|
if (pEntry)
|
||||||
{
|
{
|
||||||
// Chop name to just after "x_rep"
|
// Chop name to just after "x_rep"
|
||||||
u32 RepStart = Path.IndexOfPhrase("_rep");
|
uint32 RepStart = Path.IndexOfPhrase("_rep");
|
||||||
|
|
||||||
if (RepStart != -1)
|
if (RepStart != -1)
|
||||||
Path = Path.ChopFront(RepStart + 5);
|
Path = Path.ChopFront(RepStart + 5);
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <Common/CFourCC.h>
|
#include <Common/CFourCC.h>
|
||||||
#include <Common/FileUtil.h>
|
#include <Common/FileUtil.h>
|
||||||
#include <Common/TString.h>
|
#include <Common/TString.h>
|
||||||
#include <Common/types.h>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
@ -82,8 +81,8 @@ public:
|
||||||
inline TString ResourcesDir() const { return IsEditorStore() ? DatabaseRootPath() : DatabaseRootPath() + "Resources/"; }
|
inline TString ResourcesDir() const { return IsEditorStore() ? DatabaseRootPath() : DatabaseRootPath() + "Resources/"; }
|
||||||
inline TString DatabasePath() const { return DatabaseRootPath() + "ResourceDatabaseCache.bin"; }
|
inline TString DatabasePath() const { return DatabaseRootPath() + "ResourceDatabaseCache.bin"; }
|
||||||
inline CVirtualDirectory* RootDirectory() const { return mpDatabaseRoot; }
|
inline CVirtualDirectory* RootDirectory() const { return mpDatabaseRoot; }
|
||||||
inline u32 NumTotalResources() const { return mResourceEntries.size(); }
|
inline uint32 NumTotalResources() const { return mResourceEntries.size(); }
|
||||||
inline u32 NumLoadedResources() const { return mLoadedResources.size(); }
|
inline uint32 NumLoadedResources() const { return mLoadedResources.size(); }
|
||||||
inline bool IsCacheDirty() const { return mDatabaseCacheDirty; }
|
inline bool IsCacheDirty() const { return mDatabaseCacheDirty; }
|
||||||
|
|
||||||
inline void SetCacheDirty() { mDatabaseCacheDirty = true; }
|
inline void SetCacheDirty() { mDatabaseCacheDirty = true; }
|
||||||
|
|
|
@ -22,7 +22,7 @@ CVirtualDirectory::CVirtualDirectory(CVirtualDirectory *pParent, const TString&
|
||||||
|
|
||||||
CVirtualDirectory::~CVirtualDirectory()
|
CVirtualDirectory::~CVirtualDirectory()
|
||||||
{
|
{
|
||||||
for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
|
for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
|
||||||
delete mSubdirectories[iSub];
|
delete mSubdirectories[iSub];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ bool CVirtualDirectory::IsEmpty(bool CheckFilesystem) const
|
||||||
if (!mResources.empty())
|
if (!mResources.empty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
|
for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
|
||||||
if (!mSubdirectories[iSub]->IsEmpty(CheckFilesystem))
|
if (!mSubdirectories[iSub]->IsEmpty(CheckFilesystem))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -66,10 +66,10 @@ CVirtualDirectory* CVirtualDirectory::GetRoot()
|
||||||
|
|
||||||
CVirtualDirectory* CVirtualDirectory::FindChildDirectory(const TString& rkName, bool AllowCreate)
|
CVirtualDirectory* CVirtualDirectory::FindChildDirectory(const TString& rkName, bool AllowCreate)
|
||||||
{
|
{
|
||||||
u32 SlashIdx = rkName.IndexOf("\\/");
|
uint32 SlashIdx = rkName.IndexOf("\\/");
|
||||||
TString DirName = (SlashIdx == -1 ? rkName : rkName.SubString(0, SlashIdx));
|
TString DirName = (SlashIdx == -1 ? rkName : rkName.SubString(0, SlashIdx));
|
||||||
|
|
||||||
for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
|
for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
|
||||||
{
|
{
|
||||||
CVirtualDirectory *pChild = mSubdirectories[iSub];
|
CVirtualDirectory *pChild = mSubdirectories[iSub];
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkPath)
|
||||||
|
|
||||||
CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkName, EResType Type)
|
CResourceEntry* CVirtualDirectory::FindChildResource(const TString& rkName, EResType Type)
|
||||||
{
|
{
|
||||||
for (u32 iRes = 0; iRes < mResources.size(); iRes++)
|
for (uint32 iRes = 0; iRes < mResources.size(); iRes++)
|
||||||
{
|
{
|
||||||
if (rkName.CaseInsensitiveCompare(mResources[iRes]->Name()) && mResources[iRes]->ResourceType() == Type)
|
if (rkName.CaseInsensitiveCompare(mResources[iRes]->Name()) && mResources[iRes]->ResourceType() == Type)
|
||||||
return mResources[iRes];
|
return mResources[iRes];
|
||||||
|
@ -150,14 +150,14 @@ bool CVirtualDirectory::AddChild(const TString &rkPath, CResourceEntry *pEntry)
|
||||||
|
|
||||||
else if (IsValidDirectoryPath(rkPath))
|
else if (IsValidDirectoryPath(rkPath))
|
||||||
{
|
{
|
||||||
u32 SlashIdx = rkPath.IndexOf("\\/");
|
uint32 SlashIdx = rkPath.IndexOf("\\/");
|
||||||
TString DirName = (SlashIdx == -1 ? rkPath : rkPath.SubString(0, SlashIdx));
|
TString DirName = (SlashIdx == -1 ? rkPath : rkPath.SubString(0, SlashIdx));
|
||||||
TString Remaining = (SlashIdx == -1 ? "" : rkPath.SubString(SlashIdx + 1, rkPath.Size() - SlashIdx));
|
TString Remaining = (SlashIdx == -1 ? "" : rkPath.SubString(SlashIdx + 1, rkPath.Size() - SlashIdx));
|
||||||
|
|
||||||
// Check if this subdirectory already exists
|
// Check if this subdirectory already exists
|
||||||
CVirtualDirectory *pSubdir = nullptr;
|
CVirtualDirectory *pSubdir = nullptr;
|
||||||
|
|
||||||
for (u32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
|
for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
|
||||||
{
|
{
|
||||||
if (mSubdirectories[iSub]->Name() == DirName)
|
if (mSubdirectories[iSub]->Name() == DirName)
|
||||||
{
|
{
|
||||||
|
@ -264,7 +264,7 @@ void CVirtualDirectory::SortSubdirectories()
|
||||||
|
|
||||||
bool CVirtualDirectory::Rename(const TString& rkNewName)
|
bool CVirtualDirectory::Rename(const TString& rkNewName)
|
||||||
{
|
{
|
||||||
Log::Write("MOVING DIRECTORY: " + FullPath() + " -> " + mpParent->FullPath() + rkNewName + '/');
|
debugf("MOVING DIRECTORY: %s --> %s", *FullPath(), *mpParent->FullPath() + rkNewName + '/');
|
||||||
|
|
||||||
if (!IsRoot())
|
if (!IsRoot())
|
||||||
{
|
{
|
||||||
|
@ -283,7 +283,7 @@ bool CVirtualDirectory::Rename(const TString& rkNewName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::Error("DIRECTORY MOVE FAILED");
|
errorf("DIRECTORY MOVE FAILED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ bool CVirtualDirectory::Delete()
|
||||||
|
|
||||||
void CVirtualDirectory::DeleteEmptySubdirectories()
|
void CVirtualDirectory::DeleteEmptySubdirectories()
|
||||||
{
|
{
|
||||||
for (u32 SubdirIdx = 0; SubdirIdx < mSubdirectories.size(); SubdirIdx++)
|
for (uint32 SubdirIdx = 0; SubdirIdx < mSubdirectories.size(); SubdirIdx++)
|
||||||
{
|
{
|
||||||
CVirtualDirectory *pDir = mSubdirectories[SubdirIdx];
|
CVirtualDirectory *pDir = mSubdirectories[SubdirIdx];
|
||||||
|
|
||||||
|
@ -332,7 +332,7 @@ bool CVirtualDirectory::CreateFilesystemDirectory()
|
||||||
bool CreateSuccess = FileUtil::MakeDirectory(AbsPath);
|
bool CreateSuccess = FileUtil::MakeDirectory(AbsPath);
|
||||||
|
|
||||||
if (!CreateSuccess)
|
if (!CreateSuccess)
|
||||||
Log::Error("FAILED to create filesystem directory: " + AbsPath);
|
errorf("FAILED to create filesystem directory: %s", *AbsPath);
|
||||||
|
|
||||||
return CreateSuccess;
|
return CreateSuccess;
|
||||||
}
|
}
|
||||||
|
@ -345,14 +345,14 @@ bool CVirtualDirectory::SetParent(CVirtualDirectory *pParent)
|
||||||
ASSERT(!pParent->IsDescendantOf(this));
|
ASSERT(!pParent->IsDescendantOf(this));
|
||||||
if (mpParent == pParent) return true;
|
if (mpParent == pParent) return true;
|
||||||
|
|
||||||
Log::Write("MOVING DIRECTORY: " + FullPath() + " -> " + pParent->FullPath() + mName + '/');
|
debugf("MOVING DIRECTORY: %s -> %s", *FullPath(), *(pParent->FullPath() + mName + '/'));
|
||||||
|
|
||||||
// Check for a conflict
|
// Check for a conflict
|
||||||
CVirtualDirectory *pConflictDir = pParent->FindChildDirectory(mName, false);
|
CVirtualDirectory *pConflictDir = pParent->FindChildDirectory(mName, false);
|
||||||
|
|
||||||
if (pConflictDir)
|
if (pConflictDir)
|
||||||
{
|
{
|
||||||
Log::Error("DIRECTORY MOVE FAILED: Conflicting directory exists at the destination path!");
|
errorf("DIRECTORY MOVE FAILED: Conflicting directory exists at the destination path!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +369,7 @@ bool CVirtualDirectory::SetParent(CVirtualDirectory *pParent)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Log::Error("DIRECTORY MOVE FAILED: Filesystem move operation failed!");
|
errorf("DIRECTORY MOVE FAILED: Filesystem move operation failed!");
|
||||||
mpParent->AddChild(this);
|
mpParent->AddChild(this);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
/* Virtual directory system used to look up resources by their location in the filesystem. */
|
/* Virtual directory system used to look up resources by their location in the filesystem. */
|
||||||
#include "Core/Resource/EResType.h"
|
#include "Core/Resource/EResType.h"
|
||||||
#include <Common/AssertMacro.h>
|
#include <Common/Macros.h>
|
||||||
#include <Common/TString.h>
|
#include <Common/TString.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -51,10 +51,10 @@ public:
|
||||||
inline bool IsRoot() const { return !mpParent; }
|
inline bool IsRoot() const { return !mpParent; }
|
||||||
inline TString Name() const { return mName; }
|
inline TString Name() const { return mName; }
|
||||||
|
|
||||||
inline u32 NumSubdirectories() const { return mSubdirectories.size(); }
|
inline uint32 NumSubdirectories() const { return mSubdirectories.size(); }
|
||||||
inline CVirtualDirectory* SubdirectoryByIndex(u32 Index) { return mSubdirectories[Index]; }
|
inline CVirtualDirectory* SubdirectoryByIndex(uint32 Index) { return mSubdirectories[Index]; }
|
||||||
inline u32 NumResources() const { return mResources.size(); }
|
inline uint32 NumResources() const { return mResources.size(); }
|
||||||
inline CResourceEntry* ResourceByIndex(u32 Index) { return mResources[Index]; }
|
inline CResourceEntry* ResourceByIndex(uint32 Index) { return mResources[Index]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CVIRTUALDIRECTORY
|
#endif // CVIRTUALDIRECTORY
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "DependencyListBuilders.h"
|
#include "DependencyListBuilders.h"
|
||||||
|
|
||||||
// ************ CCharacterUsageMap ************
|
// ************ CCharacterUsageMap ************
|
||||||
bool CCharacterUsageMap::IsCharacterUsed(const CAssetID& rkID, u32 CharacterIndex) const
|
bool CCharacterUsageMap::IsCharacterUsed(const CAssetID& rkID, uint32 CharacterIndex) const
|
||||||
{
|
{
|
||||||
if (mpStore->Game() >= EGame::CorruptionProto) return true;
|
if (mpStore->Game() >= EGame::CorruptionProto) return true;
|
||||||
auto Find = mUsageMap.find(rkID);
|
auto Find = mUsageMap.find(rkID);
|
||||||
|
@ -18,7 +18,7 @@ bool CCharacterUsageMap::IsAnimationUsed(const CAssetID& rkID, CSetAnimationDepe
|
||||||
if (Find == mUsageMap.end()) return false;
|
if (Find == mUsageMap.end()) return false;
|
||||||
const std::vector<bool>& rkUsageList = Find->second;
|
const std::vector<bool>& rkUsageList = Find->second;
|
||||||
|
|
||||||
for (u32 iChar = 0; iChar < rkUsageList.size(); iChar++)
|
for (uint32 iChar = 0; iChar < rkUsageList.size(); iChar++)
|
||||||
{
|
{
|
||||||
if (rkUsageList[iChar] && pAnim->IsUsedByCharacter(iChar))
|
if (rkUsageList[iChar] && pAnim->IsUsedByCharacter(iChar))
|
||||||
return true;
|
return true;
|
||||||
|
@ -37,7 +37,7 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntr
|
||||||
{
|
{
|
||||||
ASSERT(pEntry->ResourceType() == eArea);
|
ASSERT(pEntry->ResourceType() == eArea);
|
||||||
|
|
||||||
for (u32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
|
for (uint32 iArea = 0; iArea < pWorld->NumAreas(); iArea++)
|
||||||
{
|
{
|
||||||
if (pWorld->AreaResourceID(iArea) == pEntry->ID())
|
if (pWorld->AreaResourceID(iArea) == pEntry->ID())
|
||||||
{
|
{
|
||||||
|
@ -47,12 +47,12 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, u32 AreaIndex)
|
void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, uint32 AreaIndex)
|
||||||
{
|
{
|
||||||
// We only need to search forward from this area to other areas that both use the same character(s) + have duplicates enabled
|
// We only need to search forward from this area to other areas that both use the same character(s) + have duplicates enabled
|
||||||
Clear();
|
Clear();
|
||||||
|
|
||||||
for (u32 iArea = AreaIndex; iArea < pWorld->NumAreas(); iArea++)
|
for (uint32 iArea = AreaIndex; iArea < pWorld->NumAreas(); iArea++)
|
||||||
{
|
{
|
||||||
if (!mIsInitialArea && mStillLookingIDs.empty()) break;
|
if (!mIsInitialArea && mStillLookingIDs.empty()) break;
|
||||||
mCurrentAreaAllowsDupes = pWorld->DoesAreaAllowPakDuplicates(iArea);
|
mCurrentAreaAllowsDupes = pWorld->DoesAreaAllowPakDuplicates(iArea);
|
||||||
|
@ -66,7 +66,7 @@ void CCharacterUsageMap::FindUsagesForArea(CWorld *pWorld, u32 AreaIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 LayerIndex)
|
void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, uint32 LayerIndex)
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
mLayerIndex = LayerIndex;
|
mLayerIndex = LayerIndex;
|
||||||
|
@ -76,10 +76,10 @@ void CCharacterUsageMap::FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 Laye
|
||||||
|
|
||||||
// Only examine dependencies of the particular layer specified by the caller
|
// Only examine dependencies of the particular layer specified by the caller
|
||||||
bool IsLastLayer = (mLayerIndex == pTree->NumScriptLayers() - 1);
|
bool IsLastLayer = (mLayerIndex == pTree->NumScriptLayers() - 1);
|
||||||
u32 StartIdx = pTree->ScriptLayerOffset(mLayerIndex);
|
uint32 StartIdx = pTree->ScriptLayerOffset(mLayerIndex);
|
||||||
u32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(mLayerIndex + 1));
|
uint32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(mLayerIndex + 1));
|
||||||
|
|
||||||
for (u32 iInst = StartIdx; iInst < EndIdx; iInst++)
|
for (uint32 iInst = StartIdx; iInst < EndIdx; iInst++)
|
||||||
ParseDependencyNode(pTree->ChildByIndex(iInst));
|
ParseDependencyNode(pTree->ChildByIndex(iInst));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,11 +101,11 @@ void CCharacterUsageMap::DebugPrintContents()
|
||||||
std::vector<bool>& rUsedList = Iter->second;
|
std::vector<bool>& rUsedList = Iter->second;
|
||||||
CAnimSet *pSet = mpStore->LoadResource<CAnimSet>(ID);
|
CAnimSet *pSet = mpStore->LoadResource<CAnimSet>(ID);
|
||||||
|
|
||||||
for (u32 iChar = 0; iChar < pSet->NumCharacters(); iChar++)
|
for (uint32 iChar = 0; iChar < pSet->NumCharacters(); iChar++)
|
||||||
{
|
{
|
||||||
bool Used = (rUsedList.size() > iChar && rUsedList[iChar]);
|
bool Used = (rUsedList.size() > iChar && rUsedList[iChar]);
|
||||||
TString CharName = pSet->Character(iChar)->Name;
|
TString CharName = pSet->Character(iChar)->Name;
|
||||||
Log::Write(ID.ToString() + " : Char " + TString::FromInt32(iChar, 0, 10) + " : " + CharName + " : " + (Used ? "USED" : "UNUSED"));
|
debugf("%s : Char %d : %s : %s", *ID.ToString(), iChar, *CharName, (Used ? "USED" : "UNUSED"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<bool>& rUsageList = mUsageMap[ResID];
|
std::vector<bool>& rUsageList = mUsageMap[ResID];
|
||||||
u32 UsedChar = pDep->UsedChar();
|
uint32 UsedChar = pDep->UsedChar();
|
||||||
|
|
||||||
if (rUsageList.size() <= UsedChar)
|
if (rUsageList.size() <= UsedChar)
|
||||||
rUsageList.resize(UsedChar + 1, false);
|
rUsageList.resize(UsedChar + 1, false);
|
||||||
|
@ -164,7 +164,7 @@ void CCharacterUsageMap::ParseDependencyNode(IDependencyNode *pNode)
|
||||||
// Look for sub-dependencies of the current node
|
// Look for sub-dependencies of the current node
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (u32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
||||||
ParseDependencyNode(pNode->ChildByIndex(iChild));
|
ParseDependencyNode(pNode->ChildByIndex(iChild));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ void CPackageDependencyListBuilder::BuildDependencyList(bool AllowDuplicates, st
|
||||||
FindUniversalAreaAssets();
|
FindUniversalAreaAssets();
|
||||||
|
|
||||||
// Iterate over all resources and parse their dependencies
|
// Iterate over all resources and parse their dependencies
|
||||||
for (u32 iRes = 0; iRes < mpkPackage->NumNamedResources(); iRes++)
|
for (uint32 iRes = 0; iRes < mpkPackage->NumNamedResources(); iRes++)
|
||||||
{
|
{
|
||||||
const SNamedResource& rkRes = mpkPackage->NamedResourceByIndex(iRes);
|
const SNamedResource& rkRes = mpkPackage->NamedResourceByIndex(iRes);
|
||||||
CResourceEntry *pEntry = mpStore->FindEntry(rkRes.ID);
|
CResourceEntry *pEntry = mpStore->FindEntry(rkRes.ID);
|
||||||
|
@ -240,7 +240,7 @@ void CPackageDependencyListBuilder::AddDependency(CResourceEntry *pCurEntry, con
|
||||||
|
|
||||||
if (mEnableDuplicates)
|
if (mEnableDuplicates)
|
||||||
{
|
{
|
||||||
for (u32 iArea = 0; iArea < mpWorld->NumAreas(); iArea++)
|
for (uint32 iArea = 0; iArea < mpWorld->NumAreas(); iArea++)
|
||||||
{
|
{
|
||||||
if (mpWorld->AreaResourceID(iArea) == rkID)
|
if (mpWorld->AreaResourceID(iArea) == rkID)
|
||||||
{
|
{
|
||||||
|
@ -285,7 +285,7 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
||||||
else if (Type == eDNT_AnimEvent)
|
else if (Type == eDNT_AnimEvent)
|
||||||
{
|
{
|
||||||
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pNode);
|
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pNode);
|
||||||
u32 CharIndex = pDep->CharIndex();
|
uint32 CharIndex = pDep->CharIndex();
|
||||||
|
|
||||||
if (CharIndex == -1 || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIndex))
|
if (CharIndex == -1 || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIndex))
|
||||||
AddDependency(pCurEntry, pDep->ID(), rOut);
|
AddDependency(pCurEntry, pDep->ID(), rOut);
|
||||||
|
@ -313,11 +313,11 @@ void CPackageDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurE
|
||||||
{
|
{
|
||||||
if (Type == eDNT_ScriptInstance)
|
if (Type == eDNT_ScriptInstance)
|
||||||
{
|
{
|
||||||
u32 ObjType = static_cast<CScriptInstanceDependency*>(pNode)->ObjectType();
|
uint32 ObjType = static_cast<CScriptInstanceDependency*>(pNode)->ObjectType();
|
||||||
mIsPlayerActor = (ObjType == 0x4C || ObjType == FOURCC('PLAC'));
|
mIsPlayerActor = (ObjType == 0x4C || ObjType == FOURCC('PLAC'));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
||||||
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut);
|
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut);
|
||||||
|
|
||||||
if (Type == eDNT_ScriptInstance)
|
if (Type == eDNT_ScriptInstance)
|
||||||
|
@ -333,7 +333,7 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets()
|
||||||
if (pPackage)
|
if (pPackage)
|
||||||
{
|
{
|
||||||
// Iterate over all the package contents, keep track of all universal area assets
|
// Iterate over all the package contents, keep track of all universal area assets
|
||||||
for (u32 ResIdx = 0; ResIdx < pPackage->NumNamedResources(); ResIdx++)
|
for (uint32 ResIdx = 0; ResIdx < pPackage->NumNamedResources(); ResIdx++)
|
||||||
{
|
{
|
||||||
const SNamedResource& rkRes = pPackage->NamedResourceByIndex(ResIdx);
|
const SNamedResource& rkRes = pPackage->NamedResourceByIndex(ResIdx);
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets()
|
||||||
if (pUniverseWorld)
|
if (pUniverseWorld)
|
||||||
{
|
{
|
||||||
// Area IDs
|
// Area IDs
|
||||||
for (u32 AreaIdx = 0; AreaIdx < pUniverseWorld->NumAreas(); AreaIdx++)
|
for (uint32 AreaIdx = 0; AreaIdx < pUniverseWorld->NumAreas(); AreaIdx++)
|
||||||
{
|
{
|
||||||
CAssetID AreaID = pUniverseWorld->AreaResourceID(AreaIdx);
|
CAssetID AreaID = pUniverseWorld->AreaResourceID(AreaIdx);
|
||||||
|
|
||||||
|
@ -362,7 +362,7 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets()
|
||||||
|
|
||||||
if (pMapWorld)
|
if (pMapWorld)
|
||||||
{
|
{
|
||||||
for (u32 DepIdx = 0; DepIdx < pMapWorld->NumDependencies(); DepIdx++)
|
for (uint32 DepIdx = 0; DepIdx < pMapWorld->NumDependencies(); DepIdx++)
|
||||||
{
|
{
|
||||||
CAssetID DepID = pMapWorld->DependencyByIndex(DepIdx);
|
CAssetID DepID = pMapWorld->DependencyByIndex(DepIdx);
|
||||||
|
|
||||||
|
@ -378,14 +378,14 @@ void CPackageDependencyListBuilder::FindUniversalAreaAssets()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ CAreaDependencyListBuilder ************
|
// ************ CAreaDependencyListBuilder ************
|
||||||
void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAssetsOut, std::list<u32>& rLayerOffsetsOut, std::set<CAssetID> *pAudioGroupsOut)
|
void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAssetsOut, std::list<uint32>& rLayerOffsetsOut, std::set<CAssetID> *pAudioGroupsOut)
|
||||||
{
|
{
|
||||||
CAreaDependencyTree *pTree = static_cast<CAreaDependencyTree*>(mpAreaEntry->Dependencies());
|
CAreaDependencyTree *pTree = static_cast<CAreaDependencyTree*>(mpAreaEntry->Dependencies());
|
||||||
|
|
||||||
// Fill area base used assets set (don't actually add to list yet)
|
// Fill area base used assets set (don't actually add to list yet)
|
||||||
u32 BaseEndIndex = (pTree->NumScriptLayers() > 0 ? pTree->ScriptLayerOffset(0) : pTree->NumChildren());
|
uint32 BaseEndIndex = (pTree->NumScriptLayers() > 0 ? pTree->ScriptLayerOffset(0) : pTree->NumChildren());
|
||||||
|
|
||||||
for (u32 iDep = 0; iDep < BaseEndIndex; iDep++)
|
for (uint32 iDep = 0; iDep < BaseEndIndex; iDep++)
|
||||||
{
|
{
|
||||||
CResourceDependency *pRes = static_cast<CResourceDependency*>(pTree->ChildByIndex(iDep));
|
CResourceDependency *pRes = static_cast<CResourceDependency*>(pTree->ChildByIndex(iDep));
|
||||||
ASSERT(pRes->Type() == eDNT_ResourceDependency);
|
ASSERT(pRes->Type() == eDNT_ResourceDependency);
|
||||||
|
@ -393,17 +393,17 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get dependencies of each layer
|
// Get dependencies of each layer
|
||||||
for (u32 iLyr = 0; iLyr < pTree->NumScriptLayers(); iLyr++)
|
for (uint32 iLyr = 0; iLyr < pTree->NumScriptLayers(); iLyr++)
|
||||||
{
|
{
|
||||||
mLayerUsedAssets.clear();
|
mLayerUsedAssets.clear();
|
||||||
mCharacterUsageMap.FindUsagesForLayer(mpAreaEntry, iLyr);
|
mCharacterUsageMap.FindUsagesForLayer(mpAreaEntry, iLyr);
|
||||||
rLayerOffsetsOut.push_back(rAssetsOut.size());
|
rLayerOffsetsOut.push_back(rAssetsOut.size());
|
||||||
|
|
||||||
bool IsLastLayer = (iLyr == pTree->NumScriptLayers() - 1);
|
bool IsLastLayer = (iLyr == pTree->NumScriptLayers() - 1);
|
||||||
u32 StartIdx = pTree->ScriptLayerOffset(iLyr);
|
uint32 StartIdx = pTree->ScriptLayerOffset(iLyr);
|
||||||
u32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(iLyr + 1));
|
uint32 EndIdx = (IsLastLayer ? pTree->NumChildren() : pTree->ScriptLayerOffset(iLyr + 1));
|
||||||
|
|
||||||
for (u32 iChild = StartIdx; iChild < EndIdx; iChild++)
|
for (uint32 iChild = StartIdx; iChild < EndIdx; iChild++)
|
||||||
{
|
{
|
||||||
IDependencyNode *pNode = pTree->ChildByIndex(iChild);
|
IDependencyNode *pNode = pTree->ChildByIndex(iChild);
|
||||||
|
|
||||||
|
@ -412,7 +412,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
||||||
CScriptInstanceDependency *pInst = static_cast<CScriptInstanceDependency*>(pNode);
|
CScriptInstanceDependency *pInst = static_cast<CScriptInstanceDependency*>(pNode);
|
||||||
mIsPlayerActor = (pInst->ObjectType() == 0x4C || pInst->ObjectType() == FOURCC('PLAC'));
|
mIsPlayerActor = (pInst->ObjectType() == 0x4C || pInst->ObjectType() == FOURCC('PLAC'));
|
||||||
|
|
||||||
for (u32 iDep = 0; iDep < pInst->NumChildren(); iDep++)
|
for (uint32 iDep = 0; iDep < pInst->NumChildren(); iDep++)
|
||||||
{
|
{
|
||||||
CPropertyDependency *pDep = static_cast<CPropertyDependency*>(pInst->ChildByIndex(iDep));
|
CPropertyDependency *pDep = static_cast<CPropertyDependency*>(pInst->ChildByIndex(iDep));
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ void CAreaDependencyListBuilder::BuildDependencyList(std::list<CAssetID>& rAsset
|
||||||
mLayerUsedAssets.clear();
|
mLayerUsedAssets.clear();
|
||||||
rLayerOffsetsOut.push_back(rAssetsOut.size());
|
rLayerOffsetsOut.push_back(rAssetsOut.size());
|
||||||
|
|
||||||
for (u32 iDep = 0; iDep < BaseEndIndex; iDep++)
|
for (uint32 iDep = 0; iDep < BaseEndIndex; iDep++)
|
||||||
{
|
{
|
||||||
CResourceDependency *pDep = static_cast<CResourceDependency*>(pTree->ChildByIndex(iDep));
|
CResourceDependency *pDep = static_cast<CResourceDependency*>(pTree->ChildByIndex(iDep));
|
||||||
AddDependency(pDep->ID(), rAssetsOut, pAudioGroupsOut);
|
AddDependency(pDep->ID(), rAssetsOut, pAudioGroupsOut);
|
||||||
|
@ -525,7 +525,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
||||||
else if (Type == eDNT_AnimEvent)
|
else if (Type == eDNT_AnimEvent)
|
||||||
{
|
{
|
||||||
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pNode);
|
CAnimEventDependency *pDep = static_cast<CAnimEventDependency*>(pNode);
|
||||||
u32 CharIndex = pDep->CharIndex();
|
uint32 CharIndex = pDep->CharIndex();
|
||||||
|
|
||||||
if (CharIndex == -1 || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIndex))
|
if (CharIndex == -1 || mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, CharIndex))
|
||||||
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
AddDependency(pDep->ID(), rOut, pAudioGroupsOut);
|
||||||
|
@ -534,10 +534,10 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
||||||
else if (Type == eDNT_SetCharacter)
|
else if (Type == eDNT_SetCharacter)
|
||||||
{
|
{
|
||||||
// Note: For MP1/2 PlayerActor, always treat as if Empty Suit is the only used one
|
// Note: For MP1/2 PlayerActor, always treat as if Empty Suit is the only used one
|
||||||
const u32 kEmptySuitIndex = (mGame >= EGame::EchoesDemo ? 3 : 5);
|
const uint32 kEmptySuitIndex = (mGame >= EGame::EchoesDemo ? 3 : 5);
|
||||||
|
|
||||||
CSetCharacterDependency *pChar = static_cast<CSetCharacterDependency*>(pNode);
|
CSetCharacterDependency *pChar = static_cast<CSetCharacterDependency*>(pNode);
|
||||||
u32 SetIndex = pChar->CharSetIndex();
|
uint32 SetIndex = pChar->CharSetIndex();
|
||||||
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || (mIsPlayerActor && SetIndex == kEmptySuitIndex);
|
ParseChildren = mCharacterUsageMap.IsCharacterUsed(mCurrentAnimSetID, pChar->CharSetIndex()) || (mIsPlayerActor && SetIndex == kEmptySuitIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,7 +552,7 @@ void CAreaDependencyListBuilder::EvaluateDependencyNode(CResourceEntry *pCurEntr
|
||||||
|
|
||||||
if (ParseChildren)
|
if (ParseChildren)
|
||||||
{
|
{
|
||||||
for (u32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
for (uint32 iChild = 0; iChild < pNode->NumChildren(); iChild++)
|
||||||
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut, pAudioGroupsOut);
|
EvaluateDependencyNode(pCurEntry, pNode->ChildByIndex(iChild), rOut, pAudioGroupsOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ class CCharacterUsageMap
|
||||||
std::map<CAssetID, std::vector<bool>> mUsageMap;
|
std::map<CAssetID, std::vector<bool>> mUsageMap;
|
||||||
std::set<CAssetID> mStillLookingIDs;
|
std::set<CAssetID> mStillLookingIDs;
|
||||||
CResourceStore *mpStore;
|
CResourceStore *mpStore;
|
||||||
u32 mLayerIndex;
|
uint32 mLayerIndex;
|
||||||
bool mIsInitialArea;
|
bool mIsInitialArea;
|
||||||
bool mCurrentAreaAllowsDupes;
|
bool mCurrentAreaAllowsDupes;
|
||||||
|
|
||||||
|
@ -22,12 +22,12 @@ public:
|
||||||
: mpStore(pStore), mLayerIndex(-1), mIsInitialArea(true), mCurrentAreaAllowsDupes(false)
|
: mpStore(pStore), mLayerIndex(-1), mIsInitialArea(true), mCurrentAreaAllowsDupes(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool IsCharacterUsed(const CAssetID& rkID, u32 CharacterIndex) const;
|
bool IsCharacterUsed(const CAssetID& rkID, uint32 CharacterIndex) const;
|
||||||
bool IsAnimationUsed(const CAssetID& rkID, CSetAnimationDependency *pAnim) const;
|
bool IsAnimationUsed(const CAssetID& rkID, CSetAnimationDependency *pAnim) const;
|
||||||
void FindUsagesForAsset(CResourceEntry *pEntry);
|
void FindUsagesForAsset(CResourceEntry *pEntry);
|
||||||
void FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntry);
|
void FindUsagesForArea(CWorld *pWorld, CResourceEntry *pEntry);
|
||||||
void FindUsagesForArea(CWorld *pWorld, u32 AreaIndex);
|
void FindUsagesForArea(CWorld *pWorld, uint32 AreaIndex);
|
||||||
void FindUsagesForLayer(CResourceEntry *pAreaEntry, u32 LayerIndex);
|
void FindUsagesForLayer(CResourceEntry *pAreaEntry, uint32 LayerIndex);
|
||||||
void Clear();
|
void Clear();
|
||||||
void DebugPrintContents();
|
void DebugPrintContents();
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public:
|
||||||
ASSERT(mpAreaEntry->ResourceType() == eArea);
|
ASSERT(mpAreaEntry->ResourceType() == eArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildDependencyList(std::list<CAssetID>& rAssetsOut, std::list<u32>& rLayerOffsetsOut, std::set<CAssetID> *pAudioGroupsOut = nullptr);
|
void BuildDependencyList(std::list<CAssetID>& rAssetsOut, std::list<uint32>& rLayerOffsetsOut, std::set<CAssetID> *pAudioGroupsOut = nullptr);
|
||||||
void AddDependency(const CAssetID& rkID, std::list<CAssetID>& rOut, std::set<CAssetID> *pAudioGroupsOut);
|
void AddDependency(const CAssetID& rkID, std::list<CAssetID>& rOut, std::set<CAssetID> *pAudioGroupsOut);
|
||||||
void EvaluateDependencyNode(CResourceEntry *pCurEntry, IDependencyNode *pNode, std::list<CAssetID>& rOut, std::set<CAssetID> *pAudioGroupsOut);
|
void EvaluateDependencyNode(CResourceEntry *pCurEntry, IDependencyNode *pNode, std::list<CAssetID>& rOut, std::set<CAssetID> *pAudioGroupsOut);
|
||||||
};
|
};
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define IPROGRESSNOTIFIER_H
|
#define IPROGRESSNOTIFIER_H
|
||||||
|
|
||||||
#include <Common/Common.h>
|
#include <Common/Common.h>
|
||||||
#include <Math/MathUtil.h>
|
#include <Common/Math/MathUtil.h>
|
||||||
|
|
||||||
class IProgressNotifier
|
class IProgressNotifier
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "CDynamicVertexBuffer.h"
|
#include "CDynamicVertexBuffer.h"
|
||||||
#include "CVertexArrayManager.h"
|
#include "CVertexArrayManager.h"
|
||||||
|
|
||||||
static const u32 gskAttribSize[] = {
|
static const uint32 gskAttribSize[] = {
|
||||||
0xC, 0xC, 0x4, 0x4, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8
|
0xC, 0xC, 0x4, 0x4, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ CDynamicVertexBuffer::~CDynamicVertexBuffer()
|
||||||
ClearBuffers();
|
ClearBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDynamicVertexBuffer::SetVertexCount(u32 NumVerts)
|
void CDynamicVertexBuffer::SetVertexCount(uint32 NumVerts)
|
||||||
{
|
{
|
||||||
ClearBuffers();
|
ClearBuffers();
|
||||||
mNumVertices = NumVerts;
|
mNumVertices = NumVerts;
|
||||||
|
@ -44,7 +44,7 @@ void CDynamicVertexBuffer::SetActiveAttribs(FVertexDescription AttribFlags)
|
||||||
|
|
||||||
void CDynamicVertexBuffer::BufferAttrib(EVertexAttribute Attrib, const void *pkData)
|
void CDynamicVertexBuffer::BufferAttrib(EVertexAttribute Attrib, const void *pkData)
|
||||||
{
|
{
|
||||||
u32 Index;
|
uint32 Index;
|
||||||
|
|
||||||
switch (Attrib)
|
switch (Attrib)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ void CDynamicVertexBuffer::BufferAttrib(EVertexAttribute Attrib, const void *pkD
|
||||||
|
|
||||||
void CDynamicVertexBuffer::ClearBuffers()
|
void CDynamicVertexBuffer::ClearBuffers()
|
||||||
{
|
{
|
||||||
for (u32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
for (uint32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
||||||
{
|
{
|
||||||
int Bit = 1 << iAttrib;
|
int Bit = 1 << iAttrib;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ GLuint CDynamicVertexBuffer::CreateVAO()
|
||||||
glGenVertexArrays(1, &VertexArray);
|
glGenVertexArrays(1, &VertexArray);
|
||||||
glBindVertexArray(VertexArray);
|
glBindVertexArray(VertexArray);
|
||||||
|
|
||||||
for (u32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
for (uint32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
||||||
{
|
{
|
||||||
bool HasAttrib = ((3 << (iAttrib * 2)) != 0);
|
bool HasAttrib = ((3 << (iAttrib * 2)) != 0);
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ void CDynamicVertexBuffer::InitBuffers()
|
||||||
{
|
{
|
||||||
if (mBufferedFlags) ClearBuffers();
|
if (mBufferedFlags) ClearBuffers();
|
||||||
|
|
||||||
for (u32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
for (uint32 iAttrib = 0; iAttrib < 12; iAttrib++)
|
||||||
{
|
{
|
||||||
bool HasAttrib = ((3 << (iAttrib * 2)) != 0);
|
bool HasAttrib = ((3 << (iAttrib * 2)) != 0);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define CDYNAMICVERTEXBUFFER_H
|
#define CDYNAMICVERTEXBUFFER_H
|
||||||
|
|
||||||
#include "Core/Resource/Model/EVertexAttribute.h"
|
#include "Core/Resource/Model/EVertexAttribute.h"
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
@ -11,13 +11,13 @@ class CDynamicVertexBuffer
|
||||||
{
|
{
|
||||||
FVertexDescription mAttribFlags;
|
FVertexDescription mAttribFlags;
|
||||||
FVertexDescription mBufferedFlags;
|
FVertexDescription mBufferedFlags;
|
||||||
u32 mNumVertices;
|
uint32 mNumVertices;
|
||||||
GLuint mAttribBuffers[12];
|
GLuint mAttribBuffers[12];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CDynamicVertexBuffer();
|
CDynamicVertexBuffer();
|
||||||
~CDynamicVertexBuffer();
|
~CDynamicVertexBuffer();
|
||||||
void SetVertexCount(u32 NumVerts);
|
void SetVertexCount(uint32 NumVerts);
|
||||||
void Bind();
|
void Bind();
|
||||||
void Unbind();
|
void Unbind();
|
||||||
void SetActiveAttribs(FVertexDescription AttribFlags);
|
void SetActiveAttribs(FVertexDescription AttribFlags);
|
||||||
|
|
|
@ -11,7 +11,7 @@ CFramebuffer::CFramebuffer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CFramebuffer::CFramebuffer(u32 Width, u32 Height)
|
CFramebuffer::CFramebuffer(uint32 Width, uint32 Height)
|
||||||
: mpRenderbuffer(nullptr)
|
: mpRenderbuffer(nullptr)
|
||||||
, mpTexture(nullptr)
|
, mpTexture(nullptr)
|
||||||
, mWidth(0)
|
, mWidth(0)
|
||||||
|
@ -60,7 +60,7 @@ void CFramebuffer::Bind(GLenum Target /*= GL_FRAMEBUFFER*/)
|
||||||
glBindFramebuffer(Target, mFramebuffer);
|
glBindFramebuffer(Target, mFramebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFramebuffer::Resize(u32 Width, u32 Height)
|
void CFramebuffer::Resize(uint32 Width, uint32 Height)
|
||||||
{
|
{
|
||||||
if ((mWidth != Width) || (mHeight != Height))
|
if ((mWidth != Width) || (mHeight != Height))
|
||||||
{
|
{
|
||||||
|
@ -109,7 +109,7 @@ void CFramebuffer::InitBuffers()
|
||||||
mStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
mStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
|
|
||||||
if (mStatus != GL_FRAMEBUFFER_COMPLETE)
|
if (mStatus != GL_FRAMEBUFFER_COMPLETE)
|
||||||
Log::Error("Framebuffer not complete; error " + TString::HexString((u32) mStatus, 0));
|
errorf("Framebuffer not complete; error 0x%X", mStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ STATIC ************
|
// ************ STATIC ************
|
||||||
|
|
|
@ -10,7 +10,7 @@ class CFramebuffer
|
||||||
GLuint mFramebuffer;
|
GLuint mFramebuffer;
|
||||||
CRenderbuffer *mpRenderbuffer;
|
CRenderbuffer *mpRenderbuffer;
|
||||||
CTexture *mpTexture;
|
CTexture *mpTexture;
|
||||||
u32 mWidth, mHeight;
|
uint32 mWidth, mHeight;
|
||||||
bool mEnableMultisampling;
|
bool mEnableMultisampling;
|
||||||
bool mInitialized;
|
bool mInitialized;
|
||||||
GLenum mStatus;
|
GLenum mStatus;
|
||||||
|
@ -20,11 +20,11 @@ class CFramebuffer
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CFramebuffer();
|
CFramebuffer();
|
||||||
CFramebuffer(u32 Width, u32 Height);
|
CFramebuffer(uint32 Width, uint32 Height);
|
||||||
~CFramebuffer();
|
~CFramebuffer();
|
||||||
void Init();
|
void Init();
|
||||||
void Bind(GLenum Target = GL_FRAMEBUFFER);
|
void Bind(GLenum Target = GL_FRAMEBUFFER);
|
||||||
void Resize(u32 Width, u32 Height);
|
void Resize(uint32 Width, uint32 Height);
|
||||||
void SetMultisamplingEnabled(bool Enable);
|
void SetMultisamplingEnabled(bool Enable);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
|
|
|
@ -17,19 +17,19 @@ CIndexBuffer::~CIndexBuffer()
|
||||||
glDeleteBuffers(1, &mIndexBuffer);
|
glDeleteBuffers(1, &mIndexBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIndexBuffer::AddIndex(u16 Index)
|
void CIndexBuffer::AddIndex(uint16 Index)
|
||||||
{
|
{
|
||||||
mIndices.push_back(Index);
|
mIndices.push_back(Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIndexBuffer::AddIndices(u16 *pIndices, u32 Count)
|
void CIndexBuffer::AddIndices(uint16 *pIndices, uint Count)
|
||||||
{
|
{
|
||||||
Reserve(Count);
|
Reserve(Count);
|
||||||
for (u32 iIdx = 0; iIdx < Count; iIdx++)
|
for (uint iIdx = 0; iIdx < Count; iIdx++)
|
||||||
mIndices.push_back(*pIndices++);
|
mIndices.push_back(*pIndices++);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIndexBuffer::Reserve(u32 Size)
|
void CIndexBuffer::Reserve(uint Size)
|
||||||
{
|
{
|
||||||
mIndices.reserve(mIndices.size() + Size);
|
mIndices.reserve(mIndices.size() + Size);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ void CIndexBuffer::Buffer()
|
||||||
|
|
||||||
glGenBuffers(1, &mIndexBuffer);
|
glGenBuffers(1, &mIndexBuffer);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer);
|
||||||
glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndices.size() * sizeof(u16), mIndices.data(), GL_STATIC_DRAW);
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, mIndices.size() * sizeof(uint16), mIndices.data(), GL_STATIC_DRAW);
|
||||||
|
|
||||||
mBuffered = true;
|
mBuffered = true;
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ void CIndexBuffer::DrawElements()
|
||||||
Unbind();
|
Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIndexBuffer::DrawElements(u32 Offset, u32 Size)
|
void CIndexBuffer::DrawElements(uint Offset, uint Size)
|
||||||
{
|
{
|
||||||
Bind();
|
Bind();
|
||||||
glDrawElements(mPrimitiveType, Size, GL_UNSIGNED_SHORT, (char*)0 + (Offset * 2));
|
glDrawElements(mPrimitiveType, Size, GL_UNSIGNED_SHORT, (char*)0 + (Offset * 2));
|
||||||
|
@ -84,7 +84,7 @@ bool CIndexBuffer::IsBuffered()
|
||||||
return mBuffered;
|
return mBuffered;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CIndexBuffer::GetSize()
|
uint CIndexBuffer::GetSize()
|
||||||
{
|
{
|
||||||
return mIndices.size();
|
return mIndices.size();
|
||||||
}
|
}
|
||||||
|
@ -99,11 +99,11 @@ void CIndexBuffer::SetPrimitiveType(GLenum Type)
|
||||||
mPrimitiveType = Type;
|
mPrimitiveType = Type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIndexBuffer::TrianglesToStrips(u16 *pIndices, u32 Count)
|
void CIndexBuffer::TrianglesToStrips(uint16 *pIndices, uint Count)
|
||||||
{
|
{
|
||||||
Reserve(Count + (Count / 3));
|
Reserve(Count + (Count / 3));
|
||||||
|
|
||||||
for (u32 iIdx = 0; iIdx < Count; iIdx += 3)
|
for (uint iIdx = 0; iIdx < Count; iIdx += 3)
|
||||||
{
|
{
|
||||||
mIndices.push_back(*pIndices++);
|
mIndices.push_back(*pIndices++);
|
||||||
mIndices.push_back(*pIndices++);
|
mIndices.push_back(*pIndices++);
|
||||||
|
@ -112,12 +112,12 @@ void CIndexBuffer::TrianglesToStrips(u16 *pIndices, u32 Count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIndexBuffer::FansToStrips(u16 *pIndices, u32 Count)
|
void CIndexBuffer::FansToStrips(uint16 *pIndices, uint Count)
|
||||||
{
|
{
|
||||||
Reserve(Count);
|
Reserve(Count);
|
||||||
u16 FirstIndex = *pIndices;
|
uint16 FirstIndex = *pIndices;
|
||||||
|
|
||||||
for (u32 iIdx = 2; iIdx < Count; iIdx += 3)
|
for (uint iIdx = 2; iIdx < Count; iIdx += 3)
|
||||||
{
|
{
|
||||||
mIndices.push_back(pIndices[iIdx - 1]);
|
mIndices.push_back(pIndices[iIdx - 1]);
|
||||||
mIndices.push_back(pIndices[iIdx]);
|
mIndices.push_back(pIndices[iIdx]);
|
||||||
|
@ -130,11 +130,11 @@ void CIndexBuffer::FansToStrips(u16 *pIndices, u32 Count)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CIndexBuffer::QuadsToStrips(u16 *pIndices, u32 Count)
|
void CIndexBuffer::QuadsToStrips(uint16 *pIndices, uint Count)
|
||||||
{
|
{
|
||||||
Reserve((u32) (Count * 1.25));
|
Reserve((uint) (Count * 1.25));
|
||||||
|
|
||||||
u32 iIdx = 3;
|
uint iIdx = 3;
|
||||||
for (; iIdx < Count; iIdx += 4)
|
for (; iIdx < Count; iIdx += 4)
|
||||||
{
|
{
|
||||||
mIndices.push_back(pIndices[iIdx - 2]);
|
mIndices.push_back(pIndices[iIdx - 2]);
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#ifndef CINDEXBUFFER_H
|
#ifndef CINDEXBUFFER_H
|
||||||
#define CINDEXBUFFER_H
|
#define CINDEXBUFFER_H
|
||||||
|
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
#include <Math/CVector3f.h>
|
#include <Common/Math/CVector3f.h>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
class CIndexBuffer
|
class CIndexBuffer
|
||||||
{
|
{
|
||||||
GLuint mIndexBuffer;
|
GLuint mIndexBuffer;
|
||||||
std::vector<u16> mIndices;
|
std::vector<uint16> mIndices;
|
||||||
GLenum mPrimitiveType;
|
GLenum mPrimitiveType;
|
||||||
bool mBuffered;
|
bool mBuffered;
|
||||||
|
|
||||||
|
@ -16,24 +16,24 @@ public:
|
||||||
CIndexBuffer();
|
CIndexBuffer();
|
||||||
CIndexBuffer(GLenum Type);
|
CIndexBuffer(GLenum Type);
|
||||||
~CIndexBuffer();
|
~CIndexBuffer();
|
||||||
void AddIndex(u16 Index);
|
void AddIndex(uint16 Index);
|
||||||
void AddIndices(u16 *pIndices, u32 Count);
|
void AddIndices(uint16 *pIndices, uint Count);
|
||||||
void Reserve(u32 Size);
|
void Reserve(uint Size);
|
||||||
void Clear();
|
void Clear();
|
||||||
void Buffer();
|
void Buffer();
|
||||||
void Bind();
|
void Bind();
|
||||||
void Unbind();
|
void Unbind();
|
||||||
void DrawElements();
|
void DrawElements();
|
||||||
void DrawElements(u32 Offset, u32 Size);
|
void DrawElements(uint Offset, uint Size);
|
||||||
bool IsBuffered();
|
bool IsBuffered();
|
||||||
|
|
||||||
u32 GetSize();
|
uint GetSize();
|
||||||
GLenum GetPrimitiveType();
|
GLenum GetPrimitiveType();
|
||||||
void SetPrimitiveType(GLenum Type);
|
void SetPrimitiveType(GLenum Type);
|
||||||
|
|
||||||
void TrianglesToStrips(u16 *pIndices, u32 Count);
|
void TrianglesToStrips(uint16 *pIndices, uint Count);
|
||||||
void FansToStrips(u16 *pIndices, u32 Count);
|
void FansToStrips(uint16 *pIndices, uint Count);
|
||||||
void QuadsToStrips(u16 *pIndices, u32 Count);
|
void QuadsToStrips(uint16 *pIndices, uint Count);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CINDEXBUFFER_H
|
#endif // CINDEXBUFFER_H
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#ifndef CRENDERBUFFER_H
|
#ifndef CRENDERBUFFER_H
|
||||||
#define CRENDERBUFFER_H
|
#define CRENDERBUFFER_H
|
||||||
|
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
class CRenderbuffer
|
class CRenderbuffer
|
||||||
{
|
{
|
||||||
GLuint mRenderbuffer;
|
GLuint mRenderbuffer;
|
||||||
u32 mWidth, mHeight;
|
uint mWidth, mHeight;
|
||||||
bool mEnableMultisampling;
|
bool mEnableMultisampling;
|
||||||
bool mInitialized;
|
bool mInitialized;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CRenderbuffer::CRenderbuffer(u32 Width, u32 Height)
|
CRenderbuffer::CRenderbuffer(uint Width, uint Height)
|
||||||
: mWidth(Width)
|
: mWidth(Width)
|
||||||
, mHeight(Height)
|
, mHeight(Height)
|
||||||
, mEnableMultisampling(false)
|
, mEnableMultisampling(false)
|
||||||
|
@ -41,7 +41,7 @@ public:
|
||||||
InitStorage();
|
InitStorage();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CRenderbuffer::Resize(u32 Width, u32 Height)
|
inline void CRenderbuffer::Resize(uint Width, uint Height)
|
||||||
{
|
{
|
||||||
mWidth = Width;
|
mWidth = Width;
|
||||||
mHeight = Height;
|
mHeight = Height;
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
#include "CShader.h"
|
#include "CShader.h"
|
||||||
#include "Core/Render/CGraphics.h"
|
#include "Core/Render/CGraphics.h"
|
||||||
|
#include <Common/BasicTypes.h>
|
||||||
#include <Common/Log.h>
|
#include <Common/Log.h>
|
||||||
#include <Common/TString.h>
|
#include <Common/TString.h>
|
||||||
#include <Common/types.h>
|
|
||||||
#include <Common/FileIO/CTextInStream.h>
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
bool gDebugDumpShaders = false;
|
bool gDebugDumpShaders = false;
|
||||||
u64 gFailedCompileCount = 0;
|
uint64 gFailedCompileCount = 0;
|
||||||
u64 gSuccessfulCompileCount = 0;
|
uint64 gSuccessfulCompileCount = 0;
|
||||||
|
|
||||||
CShader* CShader::spCurrentShader = nullptr;
|
CShader* CShader::spCurrentShader = nullptr;
|
||||||
int CShader::smNumShaders = 0;
|
int CShader::smNumShaders = 0;
|
||||||
|
@ -58,8 +57,8 @@ bool CShader::CompileVertexSource(const char* pkSource)
|
||||||
if (CompileStatus == GL_FALSE)
|
if (CompileStatus == GL_FALSE)
|
||||||
{
|
{
|
||||||
TString Out = "dump/BadVS_" + std::to_string(gFailedCompileCount) + ".txt";
|
TString Out = "dump/BadVS_" + std::to_string(gFailedCompileCount) + ".txt";
|
||||||
Log::Error("Unable to compile vertex shader; dumped to " + Out);
|
|
||||||
DumpShaderSource(mVertexShader, Out);
|
DumpShaderSource(mVertexShader, Out);
|
||||||
|
errorf("Unable to compile vertex shader; dumped to %s", *Out);
|
||||||
|
|
||||||
gFailedCompileCount++;
|
gFailedCompileCount++;
|
||||||
glDeleteShader(mVertexShader);
|
glDeleteShader(mVertexShader);
|
||||||
|
@ -70,8 +69,8 @@ bool CShader::CompileVertexSource(const char* pkSource)
|
||||||
else if (gDebugDumpShaders == true)
|
else if (gDebugDumpShaders == true)
|
||||||
{
|
{
|
||||||
TString Out = "dump/VS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt";
|
TString Out = "dump/VS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt";
|
||||||
Log::Write("Debug shader dumping enabled; dumped to " + Out);
|
|
||||||
DumpShaderSource(mVertexShader, Out);
|
DumpShaderSource(mVertexShader, Out);
|
||||||
|
debugf("Debug shader dumping enabled; dumped to %s", *Out);
|
||||||
|
|
||||||
gSuccessfulCompileCount++;
|
gSuccessfulCompileCount++;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +92,7 @@ bool CShader::CompilePixelSource(const char* pkSource)
|
||||||
if (CompileStatus == GL_FALSE)
|
if (CompileStatus == GL_FALSE)
|
||||||
{
|
{
|
||||||
TString Out = "dump/BadPS_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt";
|
TString Out = "dump/BadPS_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt";
|
||||||
Log::Error("Unable to compile pixel shader; dumped to " + Out);
|
errorf("Unable to compile pixel shader; dumped to %s", *Out);
|
||||||
DumpShaderSource(mPixelShader, Out);
|
DumpShaderSource(mPixelShader, Out);
|
||||||
|
|
||||||
gFailedCompileCount++;
|
gFailedCompileCount++;
|
||||||
|
@ -105,7 +104,7 @@ bool CShader::CompilePixelSource(const char* pkSource)
|
||||||
else if (gDebugDumpShaders == true)
|
else if (gDebugDumpShaders == true)
|
||||||
{
|
{
|
||||||
TString Out = "dump/PS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt";
|
TString Out = "dump/PS_" + TString::FromInt64(gSuccessfulCompileCount, 8, 10) + ".txt";
|
||||||
Log::Write("Debug shader dumping enabled; dumped to " + Out);
|
debugf("Debug shader dumping enabled; dumped to %s", *Out);
|
||||||
DumpShaderSource(mPixelShader, Out);
|
DumpShaderSource(mPixelShader, Out);
|
||||||
|
|
||||||
gSuccessfulCompileCount++;
|
gSuccessfulCompileCount++;
|
||||||
|
@ -136,7 +135,7 @@ bool CShader::LinkShaders()
|
||||||
if (LinkStatus == GL_FALSE)
|
if (LinkStatus == GL_FALSE)
|
||||||
{
|
{
|
||||||
TString Out = "dump/BadLink_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt";
|
TString Out = "dump/BadLink_" + TString::FromInt64(gFailedCompileCount, 8, 10) + ".txt";
|
||||||
Log::Error("Unable to link shaders. Dumped error log to " + Out);
|
errorf("Unable to link shaders. Dumped error log to %s", *Out);
|
||||||
|
|
||||||
GLint LogLen;
|
GLint LogLen;
|
||||||
glGetProgramiv(mProgram, GL_INFO_LOG_LENGTH, &LogLen);
|
glGetProgramiv(mProgram, GL_INFO_LOG_LENGTH, &LogLen);
|
||||||
|
@ -188,13 +187,13 @@ GLuint CShader::GetUniformBlockIndex(const char* pkUniformBlock)
|
||||||
return glGetUniformBlockIndex(mProgram, pkUniformBlock);
|
return glGetUniformBlockIndex(mProgram, pkUniformBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CShader::SetTextureUniforms(u32 NumTextures)
|
void CShader::SetTextureUniforms(uint32 NumTextures)
|
||||||
{
|
{
|
||||||
for (u32 iTex = 0; iTex < NumTextures; iTex++)
|
for (uint32 iTex = 0; iTex < NumTextures; iTex++)
|
||||||
glUniform1i(mTextureUniforms[iTex], iTex);
|
glUniform1i(mTextureUniforms[iTex], iTex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CShader::SetNumLights(u32 NumLights)
|
void CShader::SetNumLights(uint32 NumLights)
|
||||||
{
|
{
|
||||||
glUniform1i(mNumLightsUniform, NumLights);
|
glUniform1i(mNumLightsUniform, NumLights);
|
||||||
}
|
}
|
||||||
|
@ -219,26 +218,18 @@ CShader* CShader::FromResourceFile(const TString& rkShaderName)
|
||||||
{
|
{
|
||||||
TString VertexShaderFilename = "../resources/shaders/" + rkShaderName + ".vs";
|
TString VertexShaderFilename = "../resources/shaders/" + rkShaderName + ".vs";
|
||||||
TString PixelShaderFilename = "../resources/shaders/" + rkShaderName + ".ps";
|
TString PixelShaderFilename = "../resources/shaders/" + rkShaderName + ".ps";
|
||||||
CTextInStream VertexShaderFile(VertexShaderFilename);
|
TString VertexShaderText, PixelShaderText;
|
||||||
CTextInStream PixelShaderFile(PixelShaderFilename);
|
|
||||||
|
|
||||||
if (!VertexShaderFile.IsValid())
|
if (!FileUtil::LoadFileToString(VertexShaderFilename, VertexShaderText))
|
||||||
Log::Error("Couldn't load vertex shader file for " + rkShaderName);
|
errorf("Couldn't load vertex shader file for %s", *rkShaderName);
|
||||||
if (!PixelShaderFile.IsValid())
|
if (!FileUtil::LoadFileToString(PixelShaderFilename, PixelShaderText))
|
||||||
Log::Error("Error: Couldn't load pixel shader file for " + rkShaderName);
|
errorf("Couldn't load pixel shader file for %s", *rkShaderName);
|
||||||
if ((!VertexShaderFile.IsValid()) || (!PixelShaderFile.IsValid())) return nullptr;
|
if (VertexShaderText.IsEmpty() || PixelShaderText.IsEmpty())
|
||||||
|
return nullptr;
|
||||||
std::stringstream VertexShader;
|
|
||||||
while (!VertexShaderFile.EoF())
|
|
||||||
VertexShader << VertexShaderFile.GetString();
|
|
||||||
|
|
||||||
std::stringstream PixelShader;
|
|
||||||
while (!PixelShaderFile.EoF())
|
|
||||||
PixelShader << PixelShaderFile.GetString();
|
|
||||||
|
|
||||||
CShader *pShader = new CShader();
|
CShader *pShader = new CShader();
|
||||||
pShader->CompileVertexSource(VertexShader.str().c_str());
|
pShader->CompileVertexSource(*VertexShaderText);
|
||||||
pShader->CompilePixelSource(PixelShader.str().c_str());
|
pShader->CompilePixelSource(*PixelShaderText);
|
||||||
pShader->LinkShaders();
|
pShader->LinkShaders();
|
||||||
return pShader;
|
return pShader;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +247,7 @@ void CShader::KillCachedShader()
|
||||||
// ************ PRIVATE ************
|
// ************ PRIVATE ************
|
||||||
void CShader::CacheCommonUniforms()
|
void CShader::CacheCommonUniforms()
|
||||||
{
|
{
|
||||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||||
{
|
{
|
||||||
TString TexUniform = "Texture" + TString::FromInt32(iTex);
|
TString TexUniform = "Texture" + TString::FromInt32(iTex);
|
||||||
mTextureUniforms[iTex] = glGetUniformLocation(mProgram, *TexUniform);
|
mTextureUniforms[iTex] = glGetUniformLocation(mProgram, *TexUniform);
|
||||||
|
|
|
@ -37,8 +37,8 @@ public:
|
||||||
GLuint GetProgramID();
|
GLuint GetProgramID();
|
||||||
GLuint GetUniformLocation(const char* pkUniform);
|
GLuint GetUniformLocation(const char* pkUniform);
|
||||||
GLuint GetUniformBlockIndex(const char* pkUniformBlock);
|
GLuint GetUniformBlockIndex(const char* pkUniformBlock);
|
||||||
void SetTextureUniforms(u32 NumTextures);
|
void SetTextureUniforms(uint32 NumTextures);
|
||||||
void SetNumLights(u32 NumLights);
|
void SetNumLights(uint32 NumLights);
|
||||||
void SetCurrent();
|
void SetCurrent();
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "CShaderGenerator.h"
|
#include "CShaderGenerator.h"
|
||||||
#include <Common/AssertMacro.h>
|
#include <Common/Macros.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -179,7 +179,7 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
||||||
if (VtxDesc & eColor0) ShaderCode << "out vec4 Color0;\n";
|
if (VtxDesc & eColor0) ShaderCode << "out vec4 Color0;\n";
|
||||||
if (VtxDesc & eColor1) ShaderCode << "out vec4 Color1;\n";
|
if (VtxDesc & eColor1) ShaderCode << "out vec4 Color1;\n";
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < rkMat.PassCount(); iPass++)
|
for (uint32 iPass = 0; iPass < rkMat.PassCount(); iPass++)
|
||||||
if (rkMat.Pass(iPass)->TexCoordSource() != 0xFF)
|
if (rkMat.Pass(iPass)->TexCoordSource() != 0xFF)
|
||||||
ShaderCode << "out vec3 Tex" << iPass << ";\n";
|
ShaderCode << "out vec3 Tex" << iPass << ";\n";
|
||||||
|
|
||||||
|
@ -332,9 +332,9 @@ bool CShaderGenerator::CreateVertexShader(const CMaterial& rkMat)
|
||||||
ShaderCode << " \n"
|
ShaderCode << " \n"
|
||||||
<< " // TexGen\n";
|
<< " // TexGen\n";
|
||||||
|
|
||||||
u32 PassCount = rkMat.PassCount();
|
uint32 PassCount = rkMat.PassCount();
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
for (uint32 iPass = 0; iPass < PassCount; iPass++)
|
||||||
{
|
{
|
||||||
CMaterialPass *pPass = rkMat.Pass(iPass);
|
CMaterialPass *pPass = rkMat.Pass(iPass);
|
||||||
if (pPass->TexCoordSource() == 0xFF) continue;
|
if (pPass->TexCoordSource() == 0xFF) continue;
|
||||||
|
@ -378,9 +378,9 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
|
||||||
if (VtxDesc & eColor0) ShaderCode << "in vec4 Color0;\n";
|
if (VtxDesc & eColor0) ShaderCode << "in vec4 Color0;\n";
|
||||||
if (VtxDesc & eColor1) ShaderCode << "in vec4 Color1;\n";
|
if (VtxDesc & eColor1) ShaderCode << "in vec4 Color1;\n";
|
||||||
|
|
||||||
u32 PassCount = rkMat.PassCount();
|
uint32 PassCount = rkMat.PassCount();
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
for (uint32 iPass = 0; iPass < PassCount; iPass++)
|
||||||
if (rkMat.Pass(iPass)->TexCoordSource() != 0xFF)
|
if (rkMat.Pass(iPass)->TexCoordSource() != 0xFF)
|
||||||
ShaderCode << "in vec3 Tex" << iPass << ";\n";
|
ShaderCode << "in vec3 Tex" << iPass << ";\n";
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
|
||||||
<< " float LightmapMultiplier;\n"
|
<< " float LightmapMultiplier;\n"
|
||||||
<< "};\n\n";
|
<< "};\n\n";
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
for (uint32 iPass = 0; iPass < PassCount; iPass++)
|
||||||
if (rkMat.Pass(iPass)->Texture() != nullptr)
|
if (rkMat.Pass(iPass)->Texture() != nullptr)
|
||||||
ShaderCode << "uniform sampler2D Texture" << iPass << ";\n";
|
ShaderCode << "uniform sampler2D Texture" << iPass << ";\n";
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
|
||||||
<< " \n";
|
<< " \n";
|
||||||
|
|
||||||
bool Lightmap = false;
|
bool Lightmap = false;
|
||||||
for (u32 iPass = 0; iPass < PassCount; iPass++)
|
for (uint32 iPass = 0; iPass < PassCount; iPass++)
|
||||||
{
|
{
|
||||||
const CMaterialPass *pPass = rkMat.Pass(iPass);
|
const CMaterialPass *pPass = rkMat.Pass(iPass);
|
||||||
CFourCC PassType = pPass->Type();
|
CFourCC PassType = pPass->Type();
|
||||||
|
@ -451,7 +451,7 @@ bool CShaderGenerator::CreatePixelShader(const CMaterial& rkMat)
|
||||||
if (pPass->RasSel() != eRasColorNull)
|
if (pPass->RasSel() != eRasColorNull)
|
||||||
ShaderCode << " Ras = " << gkRasSel[pPass->RasSel()] << ";\n";
|
ShaderCode << " Ras = " << gkRasSel[pPass->RasSel()] << ";\n";
|
||||||
|
|
||||||
for (u8 iInput = 0; iInput < 4; iInput++)
|
for (uint8 iInput = 0; iInput < 4; iInput++)
|
||||||
{
|
{
|
||||||
char TevChar = iInput + 0x41; // the current stage number represented as an ASCII letter; eg 0 is 'A'
|
char TevChar = iInput + 0x41; // the current stage number represented as an ASCII letter; eg 0 is 'A'
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#ifndef CUNIFORMBUFFER_H
|
#ifndef CUNIFORMBUFFER_H
|
||||||
#define CUNIFORMBUFFER_H
|
#define CUNIFORMBUFFER_H
|
||||||
|
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
class CUniformBuffer
|
class CUniformBuffer
|
||||||
{
|
{
|
||||||
GLuint mUniformBuffer;
|
GLuint mUniformBuffer;
|
||||||
u32 mBufferSize;
|
uint mBufferSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public:
|
||||||
SetBufferSize(0);
|
SetBufferSize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CUniformBuffer(u32 Size)
|
CUniformBuffer(uint Size)
|
||||||
{
|
{
|
||||||
glGenBuffers(1, &mUniformBuffer);
|
glGenBuffers(1, &mUniformBuffer);
|
||||||
SetBufferSize(Size);
|
SetBufferSize(Size);
|
||||||
|
@ -52,20 +52,20 @@ public:
|
||||||
Unbind();
|
Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BufferRange(const void *pkData, u32 Offset, u32 Size)
|
void BufferRange(const void *pkData, uint Offset, uint Size)
|
||||||
{
|
{
|
||||||
Bind();
|
Bind();
|
||||||
glBufferSubData(GL_UNIFORM_BUFFER, Offset, Size, pkData);
|
glBufferSubData(GL_UNIFORM_BUFFER, Offset, Size, pkData);
|
||||||
Unbind();
|
Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetBufferSize(u32 Size)
|
void SetBufferSize(uint Size)
|
||||||
{
|
{
|
||||||
mBufferSize = Size;
|
mBufferSize = Size;
|
||||||
InitializeBuffer();
|
InitializeBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 GetBufferSize()
|
uint GetBufferSize()
|
||||||
{
|
{
|
||||||
return mBufferSize;
|
return mBufferSize;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,12 +94,12 @@ CVertexArrayManager* CVertexArrayManager::Current()
|
||||||
|
|
||||||
void CVertexArrayManager::DeleteAllArraysForVBO(CVertexBuffer *pVBO)
|
void CVertexArrayManager::DeleteAllArraysForVBO(CVertexBuffer *pVBO)
|
||||||
{
|
{
|
||||||
for (u32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++)
|
for (uint32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++)
|
||||||
sVAManagers[iVAM]->DeleteVAO(pVBO);
|
sVAManagers[iVAM]->DeleteVAO(pVBO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVertexArrayManager::DeleteAllArraysForVBO(CDynamicVertexBuffer *pVBO)
|
void CVertexArrayManager::DeleteAllArraysForVBO(CDynamicVertexBuffer *pVBO)
|
||||||
{
|
{
|
||||||
for (u32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++)
|
for (uint32 iVAM = 0; iVAM < sVAManagers.size(); iVAM++)
|
||||||
sVAManagers[iVAM]->DeleteVAO(pVBO);
|
sVAManagers[iVAM]->DeleteVAO(pVBO);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class CVertexArrayManager
|
||||||
{
|
{
|
||||||
std::unordered_map<CVertexBuffer*, GLuint> mVBOMap;
|
std::unordered_map<CVertexBuffer*, GLuint> mVBOMap;
|
||||||
std::unordered_map<CDynamicVertexBuffer*, GLuint> mDynamicVBOMap;
|
std::unordered_map<CDynamicVertexBuffer*, GLuint> mDynamicVBOMap;
|
||||||
u32 mVectorIndex;
|
uint32 mVectorIndex;
|
||||||
|
|
||||||
static std::vector<CVertexArrayManager*> sVAManagers;
|
static std::vector<CVertexArrayManager*> sVAManagers;
|
||||||
static CVertexArrayManager *spCurrentManager;
|
static CVertexArrayManager *spCurrentManager;
|
||||||
|
|
|
@ -21,7 +21,7 @@ CVertexBuffer::~CVertexBuffer()
|
||||||
glDeleteBuffers(14, mAttribBuffers);
|
glDeleteBuffers(14, mAttribBuffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 CVertexBuffer::AddVertex(const CVertex& rkVtx)
|
uint16 CVertexBuffer::AddVertex(const CVertex& rkVtx)
|
||||||
{
|
{
|
||||||
if (mPositions.size() == 0xFFFF) throw std::overflow_error("VBO contains too many vertices");
|
if (mPositions.size() == 0xFFFF) throw std::overflow_error("VBO contains too many vertices");
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ u16 CVertexBuffer::AddVertex(const CVertex& rkVtx)
|
||||||
if (mVtxDesc & eColor0) mColors[0].push_back(rkVtx.Color[0]);
|
if (mVtxDesc & eColor0) mColors[0].push_back(rkVtx.Color[0]);
|
||||||
if (mVtxDesc & eColor1) mColors[1].push_back(rkVtx.Color[1]);
|
if (mVtxDesc & eColor1) mColors[1].push_back(rkVtx.Color[1]);
|
||||||
|
|
||||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||||
if (mVtxDesc & (eTex0 << iTex)) mTexCoords[iTex].push_back(rkVtx.Tex[iTex]);
|
if (mVtxDesc & (eTex0 << iTex)) mTexCoords[iTex].push_back(rkVtx.Tex[iTex]);
|
||||||
|
|
||||||
for (u32 iMtx = 0; iMtx < 8; iMtx++)
|
for (uint32 iMtx = 0; iMtx < 8; iMtx++)
|
||||||
if (mVtxDesc & (ePosMtx << iMtx)) mTexCoords[iMtx].push_back(rkVtx.MatrixIndices[iMtx]);
|
if (mVtxDesc & (ePosMtx << iMtx)) mTexCoords[iMtx].push_back(rkVtx.MatrixIndices[iMtx]);
|
||||||
|
|
||||||
if (mVtxDesc.HasAnyFlags(eBoneIndices | eBoneWeights) && mpSkin)
|
if (mVtxDesc.HasAnyFlags(eBoneIndices | eBoneWeights) && mpSkin)
|
||||||
|
@ -46,11 +46,11 @@ u16 CVertexBuffer::AddVertex(const CVertex& rkVtx)
|
||||||
return (mPositions.size() - 1);
|
return (mPositions.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start)
|
uint16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, uint16 Start)
|
||||||
{
|
{
|
||||||
if (Start < mPositions.size())
|
if (Start < mPositions.size())
|
||||||
{
|
{
|
||||||
for (u16 iVert = Start; iVert < mPositions.size(); iVert++)
|
for (uint16 iVert = Start; iVert < mPositions.size(); iVert++)
|
||||||
{
|
{
|
||||||
// I use a bool because "continue" doesn't work properly within the iTex loop
|
// I use a bool because "continue" doesn't work properly within the iTex loop
|
||||||
bool Unique = false;
|
bool Unique = false;
|
||||||
|
@ -68,7 +68,7 @@ u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start)
|
||||||
if (rkVtx.Color[1] != mColors[1][iVert]) Unique = true;
|
if (rkVtx.Color[1] != mColors[1][iVert]) Unique = true;
|
||||||
|
|
||||||
if (!Unique)
|
if (!Unique)
|
||||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||||
if ((mVtxDesc & (eTex0 << iTex)))
|
if ((mVtxDesc & (eTex0 << iTex)))
|
||||||
if (rkVtx.Tex[iTex] != mTexCoords[iTex][iVert])
|
if (rkVtx.Tex[iTex] != mTexCoords[iTex][iVert])
|
||||||
{
|
{
|
||||||
|
@ -80,7 +80,7 @@ u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start)
|
||||||
{
|
{
|
||||||
const SVertexWeights& rkWeights = mpSkin->WeightsForVertex(rkVtx.ArrayPosition);
|
const SVertexWeights& rkWeights = mpSkin->WeightsForVertex(rkVtx.ArrayPosition);
|
||||||
|
|
||||||
for (u32 iWgt = 0; iWgt < 4; iWgt++)
|
for (uint32 iWgt = 0; iWgt < 4; iWgt++)
|
||||||
{
|
{
|
||||||
if ( ((mVtxDesc & eBoneIndices) && (rkWeights.Indices[iWgt] != mBoneIndices[iVert][iWgt])) ||
|
if ( ((mVtxDesc & eBoneIndices) && (rkWeights.Indices[iWgt] != mBoneIndices[iVert][iWgt])) ||
|
||||||
((mVtxDesc & eBoneWeights) && (rkWeights.Weights[iWgt] != mBoneWeights[iVert][iWgt])) )
|
((mVtxDesc & eBoneWeights) && (rkWeights.Weights[iWgt] != mBoneWeights[iVert][iWgt])) )
|
||||||
|
@ -98,9 +98,9 @@ u16 CVertexBuffer::AddIfUnique(const CVertex& rkVtx, u16 Start)
|
||||||
return AddVertex(rkVtx);
|
return AddVertex(rkVtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CVertexBuffer::Reserve(u16 Size)
|
void CVertexBuffer::Reserve(uint16 Size)
|
||||||
{
|
{
|
||||||
u32 ReserveSize = mPositions.size() + Size;
|
uint32 ReserveSize = mPositions.size() + Size;
|
||||||
|
|
||||||
if (mVtxDesc & ePosition)
|
if (mVtxDesc & ePosition)
|
||||||
mPositions.reserve(ReserveSize);
|
mPositions.reserve(ReserveSize);
|
||||||
|
@ -114,7 +114,7 @@ void CVertexBuffer::Reserve(u16 Size)
|
||||||
if (mVtxDesc & eColor1)
|
if (mVtxDesc & eColor1)
|
||||||
mColors[1].reserve(ReserveSize);
|
mColors[1].reserve(ReserveSize);
|
||||||
|
|
||||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||||
if (mVtxDesc & (eTex0 << iTex))
|
if (mVtxDesc & (eTex0 << iTex))
|
||||||
mTexCoords[iTex].reserve(ReserveSize);
|
mTexCoords[iTex].reserve(ReserveSize);
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ void CVertexBuffer::Clear()
|
||||||
mColors[0].clear();
|
mColors[0].clear();
|
||||||
mColors[1].clear();
|
mColors[1].clear();
|
||||||
|
|
||||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||||
mTexCoords[iTex].clear();
|
mTexCoords[iTex].clear();
|
||||||
|
|
||||||
mBoneIndices.clear();
|
mBoneIndices.clear();
|
||||||
|
@ -155,7 +155,7 @@ void CVertexBuffer::Buffer()
|
||||||
// Generate buffers
|
// Generate buffers
|
||||||
glGenBuffers(14, mAttribBuffers);
|
glGenBuffers(14, mAttribBuffers);
|
||||||
|
|
||||||
for (u32 iAttrib = 0; iAttrib < 14; iAttrib++)
|
for (uint32 iAttrib = 0; iAttrib < 14; iAttrib++)
|
||||||
{
|
{
|
||||||
int Attrib = (ePosition << iAttrib);
|
int Attrib = (ePosition << iAttrib);
|
||||||
bool HasAttrib = ((mVtxDesc & Attrib) != 0);
|
bool HasAttrib = ((mVtxDesc & Attrib) != 0);
|
||||||
|
@ -171,7 +171,7 @@ void CVertexBuffer::Buffer()
|
||||||
|
|
||||||
else if (iAttrib < 4)
|
else if (iAttrib < 4)
|
||||||
{
|
{
|
||||||
u8 Index = (u8) (iAttrib - 2);
|
uint8 Index = (uint8) (iAttrib - 2);
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, mAttribBuffers[iAttrib]);
|
glBindBuffer(GL_ARRAY_BUFFER, mAttribBuffers[iAttrib]);
|
||||||
glBufferData(GL_ARRAY_BUFFER, mColors[Index].size() * sizeof(CColor), mColors[Index].data(), GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, mColors[Index].size() * sizeof(CColor), mColors[Index].data(), GL_STATIC_DRAW);
|
||||||
|
@ -179,7 +179,7 @@ void CVertexBuffer::Buffer()
|
||||||
|
|
||||||
else if (iAttrib < 12)
|
else if (iAttrib < 12)
|
||||||
{
|
{
|
||||||
u8 Index = (u8) (iAttrib - 4);
|
uint8 Index = (uint8) (iAttrib - 4);
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, mAttribBuffers[iAttrib]);
|
glBindBuffer(GL_ARRAY_BUFFER, mAttribBuffers[iAttrib]);
|
||||||
glBufferData(GL_ARRAY_BUFFER, mTexCoords[Index].size() * sizeof(CVector2f), mTexCoords[Index].data(), GL_STATIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, mTexCoords[Index].size() * sizeof(CVector2f), mTexCoords[Index].data(), GL_STATIC_DRAW);
|
||||||
|
@ -234,7 +234,7 @@ void CVertexBuffer::SetSkin(CSkin *pSkin)
|
||||||
mpSkin = pSkin;
|
mpSkin = pSkin;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CVertexBuffer::Size()
|
uint32 CVertexBuffer::Size()
|
||||||
{
|
{
|
||||||
return mPositions.size();
|
return mPositions.size();
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ GLuint CVertexBuffer::CreateVAO()
|
||||||
glGenVertexArrays(1, &VertexArray);
|
glGenVertexArrays(1, &VertexArray);
|
||||||
glBindVertexArray(VertexArray);
|
glBindVertexArray(VertexArray);
|
||||||
|
|
||||||
for (u32 iAttrib = 0; iAttrib < 14; iAttrib++)
|
for (uint32 iAttrib = 0; iAttrib < 14; iAttrib++)
|
||||||
{
|
{
|
||||||
int Attrib = (ePosition << iAttrib);
|
int Attrib = (ePosition << iAttrib);
|
||||||
bool HasAttrib = ((mVtxDesc & Attrib) != 0);
|
bool HasAttrib = ((mVtxDesc & Attrib) != 0);
|
||||||
|
|
|
@ -25,9 +25,9 @@ public:
|
||||||
CVertexBuffer();
|
CVertexBuffer();
|
||||||
CVertexBuffer(FVertexDescription Desc);
|
CVertexBuffer(FVertexDescription Desc);
|
||||||
~CVertexBuffer();
|
~CVertexBuffer();
|
||||||
u16 AddVertex(const CVertex& rkVtx);
|
uint16 AddVertex(const CVertex& rkVtx);
|
||||||
u16 AddIfUnique(const CVertex& rkVtx, u16 Start);
|
uint16 AddIfUnique(const CVertex& rkVtx, uint16 Start);
|
||||||
void Reserve(u16 Size);
|
void Reserve(uint16 Size);
|
||||||
void Clear();
|
void Clear();
|
||||||
void Buffer();
|
void Buffer();
|
||||||
void Bind();
|
void Bind();
|
||||||
|
@ -36,7 +36,7 @@ public:
|
||||||
FVertexDescription VertexDesc();
|
FVertexDescription VertexDesc();
|
||||||
void SetVertexDesc(FVertexDescription Desc);
|
void SetVertexDesc(FVertexDescription Desc);
|
||||||
void SetSkin(CSkin *pSkin);
|
void SetSkin(CSkin *pSkin);
|
||||||
u32 Size();
|
uint32 Size();
|
||||||
GLuint CreateVAO();
|
GLuint CreateVAO();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef GLCOMMON_H
|
#ifndef GLCOMMON_H
|
||||||
#define GLCOMMON_H
|
#define GLCOMMON_H
|
||||||
|
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
enum EBlendFactor
|
enum EBlendFactor
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#define CBONETRANSFORMDATA
|
#define CBONETRANSFORMDATA
|
||||||
|
|
||||||
#include "Core/Resource/Animation/CSkeleton.h"
|
#include "Core/Resource/Animation/CSkeleton.h"
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
#include <Math/CTransform4f.h>
|
#include <Common/Math/CTransform4f.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class CBoneTransformData
|
class CBoneTransformData
|
||||||
|
@ -11,16 +11,16 @@ class CBoneTransformData
|
||||||
std::vector<CTransform4f> mBoneMatrices;
|
std::vector<CTransform4f> mBoneMatrices;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CBoneTransformData() { }
|
CBoneTransformData() { }
|
||||||
CBoneTransformData(CSkeleton *pSkel) { ResizeToSkeleton(pSkel); }
|
CBoneTransformData(CSkeleton *pSkel) { ResizeToSkeleton(pSkel); }
|
||||||
inline void ResizeToSkeleton(CSkeleton *pSkel) { mBoneMatrices.resize(pSkel ? pSkel->MaxBoneID() + 1 : 0); }
|
inline void ResizeToSkeleton(CSkeleton *pSkel) { mBoneMatrices.resize(pSkel ? pSkel->MaxBoneID() + 1 : 0); }
|
||||||
inline CTransform4f& BoneMatrix(u32 BoneID) { return mBoneMatrices[BoneID]; }
|
inline CTransform4f& BoneMatrix(uint32 BoneID) { return mBoneMatrices[BoneID]; }
|
||||||
inline const CTransform4f& BoneMatrix(u32 BoneID) const { return mBoneMatrices[BoneID]; }
|
inline const CTransform4f& BoneMatrix(uint32 BoneID) const { return mBoneMatrices[BoneID]; }
|
||||||
inline const void* Data() const { return mBoneMatrices.data(); }
|
inline const void* Data() const { return mBoneMatrices.data(); }
|
||||||
inline u32 DataSize() const { return mBoneMatrices.size() * sizeof(CTransform4f); }
|
inline uint32 DataSize() const { return mBoneMatrices.size() * sizeof(CTransform4f); }
|
||||||
inline u32 NumTrackedBones() const { return mBoneMatrices.size(); }
|
inline uint32 NumTrackedBones() const { return mBoneMatrices.size(); }
|
||||||
inline CTransform4f& operator[](u32 BoneIndex) { return BoneMatrix(BoneIndex); }
|
inline CTransform4f& operator[](uint32 BoneIndex) { return BoneMatrix(BoneIndex); }
|
||||||
inline const CTransform4f& operator[](u32 BoneIndex) const { return BoneMatrix(BoneIndex); }
|
inline const CTransform4f& operator[](uint32 BoneIndex) const { return BoneMatrix(BoneIndex); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CBONETRANSFORMDATA
|
#endif // CBONETRANSFORMDATA
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "CCamera.h"
|
#include "CCamera.h"
|
||||||
#include "CGraphics.h"
|
#include "CGraphics.h"
|
||||||
#include <Math/CQuaternion.h>
|
#include <Common/Math/CQuaternion.h>
|
||||||
#include <Math/MathUtil.h>
|
#include <Common/Math/MathUtil.h>
|
||||||
|
|
||||||
CCamera::CCamera()
|
CCamera::CCamera()
|
||||||
: mMode(eFreeCamera)
|
: mMode(eFreeCamera)
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#ifndef CCAMERA_H
|
#ifndef CCAMERA_H
|
||||||
#define CCAMERA_H
|
#define CCAMERA_H
|
||||||
|
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
#include <Common/EKeyInputs.h>
|
#include <Common/EKeyInputs.h>
|
||||||
#include <Common/EMouseInputs.h>
|
#include <Common/EMouseInputs.h>
|
||||||
#include <Math/CAABox.h>
|
#include <Common/Math/CAABox.h>
|
||||||
#include <Math/CFrustumPlanes.h>
|
#include <Common/Math/CFrustumPlanes.h>
|
||||||
#include <Math/CMatrix4f.h>
|
#include <Common/Math/CMatrix4f.h>
|
||||||
#include <Math/CRay.h>
|
#include <Common/Math/CRay.h>
|
||||||
#include <Math/CVector2i.h>
|
#include <Common/Math/CVector2i.h>
|
||||||
#include <Math/CVector3f.h>
|
#include <Common/Math/CVector3f.h>
|
||||||
|
|
||||||
enum ECameraMoveMode
|
enum ECameraMoveMode
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "CGraphics.h"
|
#include "CGraphics.h"
|
||||||
#include "Core/GameProject/CResourceStore.h"
|
#include "Core/GameProject/CResourceStore.h"
|
||||||
#include <Common/Log.h>
|
#include <Common/Log.h>
|
||||||
#include <Math/CTransform4f.h>
|
#include <Common/Math/CTransform4f.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
// ************ MEMBER INITIALIZATION ************
|
// ************ MEMBER INITIALIZATION ************
|
||||||
|
@ -85,7 +85,7 @@ void CDrawUtil::DrawSquare(const float *pTexCoords)
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
// Set tex coords
|
// Set tex coords
|
||||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||||
{
|
{
|
||||||
EVertexAttribute TexAttrib = (EVertexAttribute) (eTex0 << (iTex *2));
|
EVertexAttribute TexAttrib = (EVertexAttribute) (eTex0 << (iTex *2));
|
||||||
mSquareVertices.BufferAttrib(TexAttrib, pTexCoords);
|
mSquareVertices.BufferAttrib(TexAttrib, pTexCoords);
|
||||||
|
@ -357,7 +357,7 @@ CShader* CDrawUtil::GetTextShader()
|
||||||
return mpTextShader;
|
return mpTextShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDrawUtil::LoadCheckerboardTexture(u32 GLTextureUnit)
|
void CDrawUtil::LoadCheckerboardTexture(uint32 GLTextureUnit)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
mpCheckerTexture->Bind(GLTextureUnit);
|
mpCheckerTexture->Bind(GLTextureUnit);
|
||||||
|
@ -390,7 +390,7 @@ void CDrawUtil::Init()
|
||||||
{
|
{
|
||||||
if (!mDrawUtilInitialized)
|
if (!mDrawUtilInitialized)
|
||||||
{
|
{
|
||||||
Log::Write("Initializing CDrawUtil");
|
debugf("Initializing CDrawUtil");
|
||||||
InitGrid();
|
InitGrid();
|
||||||
InitSquare();
|
InitSquare();
|
||||||
InitLine();
|
InitLine();
|
||||||
|
@ -406,7 +406,7 @@ void CDrawUtil::Init()
|
||||||
|
|
||||||
void CDrawUtil::InitGrid()
|
void CDrawUtil::InitGrid()
|
||||||
{
|
{
|
||||||
Log::Write("Creating grid");
|
debugf("Creating grid");
|
||||||
|
|
||||||
const int kGridSize = 501; // must be odd
|
const int kGridSize = 501; // must be odd
|
||||||
const float kGridSpacing = 1.f;
|
const float kGridSpacing = 1.f;
|
||||||
|
@ -416,7 +416,7 @@ void CDrawUtil::InitGrid()
|
||||||
mGridVertices.SetVertexDesc(ePosition);
|
mGridVertices.SetVertexDesc(ePosition);
|
||||||
mGridVertices.Reserve(kGridSize * 4);
|
mGridVertices.Reserve(kGridSize * 4);
|
||||||
|
|
||||||
for (s32 i = MinIdx; i <= MaxIdx; i++)
|
for (int32 i = MinIdx; i <= MaxIdx; i++)
|
||||||
{
|
{
|
||||||
if (i == 0) continue;
|
if (i == 0) continue;
|
||||||
mGridVertices.AddVertex(CVector3f(MinIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
mGridVertices.AddVertex(CVector3f(MinIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
||||||
|
@ -432,13 +432,13 @@ void CDrawUtil::InitGrid()
|
||||||
|
|
||||||
int NumIndices = kGridSize * 4;
|
int NumIndices = kGridSize * 4;
|
||||||
mGridIndices.Reserve(NumIndices);
|
mGridIndices.Reserve(NumIndices);
|
||||||
for (u16 i = 0; i < NumIndices; i++) mGridIndices.AddIndex(i);
|
for (uint16 i = 0; i < NumIndices; i++) mGridIndices.AddIndex(i);
|
||||||
mGridIndices.SetPrimitiveType(GL_LINES);
|
mGridIndices.SetPrimitiveType(GL_LINES);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDrawUtil::InitSquare()
|
void CDrawUtil::InitSquare()
|
||||||
{
|
{
|
||||||
Log::Write("Creating square");
|
debugf("Creating square");
|
||||||
mSquareVertices.SetActiveAttribs(ePosition | eNormal |
|
mSquareVertices.SetActiveAttribs(ePosition | eNormal |
|
||||||
eTex0 | eTex1 | eTex2 | eTex3 |
|
eTex0 | eTex1 | eTex2 | eTex3 |
|
||||||
eTex4 | eTex5 | eTex6 | eTex7);
|
eTex4 | eTex5 | eTex6 | eTex7);
|
||||||
|
@ -468,7 +468,7 @@ void CDrawUtil::InitSquare()
|
||||||
mSquareVertices.BufferAttrib(ePosition, SquareVertices);
|
mSquareVertices.BufferAttrib(ePosition, SquareVertices);
|
||||||
mSquareVertices.BufferAttrib(eNormal, SquareNormals);
|
mSquareVertices.BufferAttrib(eNormal, SquareNormals);
|
||||||
|
|
||||||
for (u32 iTex = 0; iTex < 8; iTex++)
|
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||||
{
|
{
|
||||||
EVertexAttribute Attrib = (EVertexAttribute) (eTex0 << (iTex *2));
|
EVertexAttribute Attrib = (EVertexAttribute) (eTex0 << (iTex *2));
|
||||||
mSquareVertices.BufferAttrib(Attrib, SquareTexCoords);
|
mSquareVertices.BufferAttrib(Attrib, SquareTexCoords);
|
||||||
|
@ -484,7 +484,7 @@ void CDrawUtil::InitSquare()
|
||||||
|
|
||||||
void CDrawUtil::InitLine()
|
void CDrawUtil::InitLine()
|
||||||
{
|
{
|
||||||
Log::Write("Creating line");
|
debugf("Creating line");
|
||||||
mLineVertices.SetActiveAttribs(ePosition);
|
mLineVertices.SetActiveAttribs(ePosition);
|
||||||
mLineVertices.SetVertexCount(2);
|
mLineVertices.SetVertexCount(2);
|
||||||
|
|
||||||
|
@ -496,13 +496,13 @@ void CDrawUtil::InitLine()
|
||||||
|
|
||||||
void CDrawUtil::InitCube()
|
void CDrawUtil::InitCube()
|
||||||
{
|
{
|
||||||
Log::Write("Creating cube");
|
debugf("Creating cube");
|
||||||
mpCubeModel = gpEditorStore->LoadResource("Cube.CMDL");
|
mpCubeModel = gpEditorStore->LoadResource("Cube.CMDL");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDrawUtil::InitWireCube()
|
void CDrawUtil::InitWireCube()
|
||||||
{
|
{
|
||||||
Log::Write("Creating wire cube");
|
debugf("Creating wire cube");
|
||||||
mWireCubeVertices.SetVertexDesc(ePosition);
|
mWireCubeVertices.SetVertexDesc(ePosition);
|
||||||
mWireCubeVertices.Reserve(8);
|
mWireCubeVertices.Reserve(8);
|
||||||
mWireCubeVertices.AddVertex(CVector3f(-0.5f, -0.5f, -0.5f));
|
mWireCubeVertices.AddVertex(CVector3f(-0.5f, -0.5f, -0.5f));
|
||||||
|
@ -514,7 +514,7 @@ void CDrawUtil::InitWireCube()
|
||||||
mWireCubeVertices.AddVertex(CVector3f( 0.5f, 0.5f, 0.5f));
|
mWireCubeVertices.AddVertex(CVector3f( 0.5f, 0.5f, 0.5f));
|
||||||
mWireCubeVertices.AddVertex(CVector3f(-0.5f, 0.5f, 0.5f));
|
mWireCubeVertices.AddVertex(CVector3f(-0.5f, 0.5f, 0.5f));
|
||||||
|
|
||||||
u16 Indices[] = {
|
uint16 Indices[] = {
|
||||||
0, 1,
|
0, 1,
|
||||||
1, 2,
|
1, 2,
|
||||||
2, 3,
|
2, 3,
|
||||||
|
@ -528,26 +528,26 @@ void CDrawUtil::InitWireCube()
|
||||||
2, 6,
|
2, 6,
|
||||||
3, 5
|
3, 5
|
||||||
};
|
};
|
||||||
mWireCubeIndices.AddIndices(Indices, sizeof(Indices) / sizeof(u16));
|
mWireCubeIndices.AddIndices(Indices, sizeof(Indices) / sizeof(uint16));
|
||||||
mWireCubeIndices.SetPrimitiveType(GL_LINES);
|
mWireCubeIndices.SetPrimitiveType(GL_LINES);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDrawUtil::InitSphere()
|
void CDrawUtil::InitSphere()
|
||||||
{
|
{
|
||||||
Log::Write("Creating sphere");
|
debugf("Creating sphere");
|
||||||
mpSphereModel = gpEditorStore->LoadResource("Sphere.CMDL");
|
mpSphereModel = gpEditorStore->LoadResource("Sphere.CMDL");
|
||||||
mpDoubleSidedSphereModel = gpEditorStore->LoadResource("SphereDoubleSided.CMDL");
|
mpDoubleSidedSphereModel = gpEditorStore->LoadResource("SphereDoubleSided.CMDL");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDrawUtil::InitWireSphere()
|
void CDrawUtil::InitWireSphere()
|
||||||
{
|
{
|
||||||
Log::Write("Creating wire sphere");
|
debugf("Creating wire sphere");
|
||||||
mpWireSphereModel = gpEditorStore->LoadResource("WireSphere.CMDL");
|
mpWireSphereModel = gpEditorStore->LoadResource("WireSphere.CMDL");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDrawUtil::InitShaders()
|
void CDrawUtil::InitShaders()
|
||||||
{
|
{
|
||||||
Log::Write("Creating shaders");
|
debugf("Creating shaders");
|
||||||
mpColorShader = CShader::FromResourceFile("ColorShader");
|
mpColorShader = CShader::FromResourceFile("ColorShader");
|
||||||
mpColorShaderLighting = CShader::FromResourceFile("ColorShaderLighting");
|
mpColorShaderLighting = CShader::FromResourceFile("ColorShaderLighting");
|
||||||
mpBillboardShader = CShader::FromResourceFile("BillboardShader");
|
mpBillboardShader = CShader::FromResourceFile("BillboardShader");
|
||||||
|
@ -559,7 +559,7 @@ void CDrawUtil::InitShaders()
|
||||||
|
|
||||||
void CDrawUtil::InitTextures()
|
void CDrawUtil::InitTextures()
|
||||||
{
|
{
|
||||||
Log::Write("Loading textures");
|
debugf("Loading textures");
|
||||||
mpCheckerTexture = gpEditorStore->LoadResource("Checkerboard.TXTR");
|
mpCheckerTexture = gpEditorStore->LoadResource("Checkerboard.TXTR");
|
||||||
|
|
||||||
mpLightTextures[0] = gpEditorStore->LoadResource("LightAmbient.TXTR");
|
mpLightTextures[0] = gpEditorStore->LoadResource("LightAmbient.TXTR");
|
||||||
|
@ -577,7 +577,7 @@ void CDrawUtil::Shutdown()
|
||||||
{
|
{
|
||||||
if (mDrawUtilInitialized)
|
if (mDrawUtilInitialized)
|
||||||
{
|
{
|
||||||
Log::Write("Shutting down");
|
debugf("Shutting down");
|
||||||
delete mpColorShader;
|
delete mpColorShader;
|
||||||
delete mpColorShaderLighting;
|
delete mpColorShaderLighting;
|
||||||
delete mpTextureShader;
|
delete mpTextureShader;
|
||||||
|
|
|
@ -92,7 +92,7 @@ public:
|
||||||
static void UseCollisionShader(bool IsFloor, bool IsUnstandable, const CColor& TintColor = CColor::skWhite);
|
static void UseCollisionShader(bool IsFloor, bool IsUnstandable, const CColor& TintColor = CColor::skWhite);
|
||||||
|
|
||||||
static CShader* GetTextShader();
|
static CShader* GetTextShader();
|
||||||
static void LoadCheckerboardTexture(u32 GLTextureUnit);
|
static void LoadCheckerboardTexture(uint32 GLTextureUnit);
|
||||||
static CTexture* GetLightTexture(ELightType Type);
|
static CTexture* GetLightTexture(ELightType Type);
|
||||||
static CTexture* GetLightMask(ELightType Type);
|
static CTexture* GetLightMask(ELightType Type);
|
||||||
static CModel* GetCubeModel();
|
static CModel* GetCubeModel();
|
||||||
|
|
|
@ -9,8 +9,8 @@ CUniformBuffer* CGraphics::mpVertexBlockBuffer;
|
||||||
CUniformBuffer* CGraphics::mpPixelBlockBuffer;
|
CUniformBuffer* CGraphics::mpPixelBlockBuffer;
|
||||||
CUniformBuffer* CGraphics::mpLightBlockBuffer;
|
CUniformBuffer* CGraphics::mpLightBlockBuffer;
|
||||||
CUniformBuffer* CGraphics::mpBoneTransformBuffer;
|
CUniformBuffer* CGraphics::mpBoneTransformBuffer;
|
||||||
u32 CGraphics::mContextIndices = 0;
|
uint32 CGraphics::mContextIndices = 0;
|
||||||
u32 CGraphics::mActiveContext = -1;
|
uint32 CGraphics::mActiveContext = -1;
|
||||||
bool CGraphics::mInitialized = false;
|
bool CGraphics::mInitialized = false;
|
||||||
std::vector<CVertexArrayManager*> CGraphics::mVAMs;
|
std::vector<CVertexArrayManager*> CGraphics::mVAMs;
|
||||||
bool CGraphics::mIdentityBoneTransforms = false;
|
bool CGraphics::mIdentityBoneTransforms = false;
|
||||||
|
@ -21,7 +21,7 @@ CGraphics::SPixelBlock CGraphics::sPixelBlock;
|
||||||
CGraphics::SLightBlock CGraphics::sLightBlock;
|
CGraphics::SLightBlock CGraphics::sLightBlock;
|
||||||
|
|
||||||
CGraphics::ELightingMode CGraphics::sLightMode;
|
CGraphics::ELightingMode CGraphics::sLightMode;
|
||||||
u32 CGraphics::sNumLights;
|
uint32 CGraphics::sNumLights;
|
||||||
const CColor CGraphics::skDefaultAmbientColor = CColor(0.5f, 0.5f, 0.5f, 1.f);
|
const CColor CGraphics::skDefaultAmbientColor = CColor(0.5f, 0.5f, 0.5f, 1.f);
|
||||||
CColor CGraphics::sAreaAmbientColor = CColor::skBlack;
|
CColor CGraphics::sAreaAmbientColor = CColor::skBlack;
|
||||||
float CGraphics::sWorldLightMultiplier;
|
float CGraphics::sWorldLightMultiplier;
|
||||||
|
@ -36,12 +36,12 @@ void CGraphics::Initialize()
|
||||||
{
|
{
|
||||||
if (!mInitialized)
|
if (!mInitialized)
|
||||||
{
|
{
|
||||||
Log::Write("Initializing GLEW");
|
debugf("Initializing GLEW");
|
||||||
glewExperimental = true;
|
glewExperimental = true;
|
||||||
glewInit();
|
glewInit();
|
||||||
glGetError(); // This is to work around a glew bug - error is always set after initializing
|
glGetError(); // This is to work around a glew bug - error is always set after initializing
|
||||||
|
|
||||||
Log::Write("Creating uniform buffers");
|
debugf("Creating uniform buffers");
|
||||||
mpMVPBlockBuffer = new CUniformBuffer(sizeof(sMVPBlock));
|
mpMVPBlockBuffer = new CUniformBuffer(sizeof(sMVPBlock));
|
||||||
mpVertexBlockBuffer = new CUniformBuffer(sizeof(sVertexBlock));
|
mpVertexBlockBuffer = new CUniformBuffer(sizeof(sVertexBlock));
|
||||||
mpPixelBlockBuffer = new CUniformBuffer(sizeof(sPixelBlock));
|
mpPixelBlockBuffer = new CUniformBuffer(sizeof(sPixelBlock));
|
||||||
|
@ -66,7 +66,7 @@ void CGraphics::Shutdown()
|
||||||
{
|
{
|
||||||
if (mInitialized)
|
if (mInitialized)
|
||||||
{
|
{
|
||||||
Log::Write("Shutting down CGraphics");
|
debugf("Shutting down CGraphics");
|
||||||
delete mpMVPBlockBuffer;
|
delete mpMVPBlockBuffer;
|
||||||
delete mpVertexBlockBuffer;
|
delete mpVertexBlockBuffer;
|
||||||
delete mpPixelBlockBuffer;
|
delete mpPixelBlockBuffer;
|
||||||
|
@ -121,11 +121,11 @@ GLuint CGraphics::BoneTransformBlockBindingPoint()
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CGraphics::GetContextIndex()
|
uint32 CGraphics::GetContextIndex()
|
||||||
{
|
{
|
||||||
for (u32 iCon = 0; iCon < 32; iCon++)
|
for (uint32 iCon = 0; iCon < 32; iCon++)
|
||||||
{
|
{
|
||||||
u32 Mask = (1 << iCon);
|
uint32 Mask = (1 << iCon);
|
||||||
if ((mContextIndices & Mask) == 0)
|
if ((mContextIndices & Mask) == 0)
|
||||||
{
|
{
|
||||||
mContextIndices |= Mask;
|
mContextIndices |= Mask;
|
||||||
|
@ -141,19 +141,19 @@ u32 CGraphics::GetContextIndex()
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CGraphics::GetActiveContext()
|
uint32 CGraphics::GetActiveContext()
|
||||||
{
|
{
|
||||||
return mActiveContext;
|
return mActiveContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphics::ReleaseContext(u32 Index)
|
void CGraphics::ReleaseContext(uint32 Index)
|
||||||
{
|
{
|
||||||
if (Index < 32) mContextIndices &= ~(1 << Index);
|
if (Index < 32) mContextIndices &= ~(1 << Index);
|
||||||
if (mActiveContext == Index) mActiveContext = -1;
|
if (mActiveContext == Index) mActiveContext = -1;
|
||||||
delete mVAMs[Index];
|
delete mVAMs[Index];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGraphics::SetActiveContext(u32 Index)
|
void CGraphics::SetActiveContext(uint32 Index)
|
||||||
{
|
{
|
||||||
mActiveContext = Index;
|
mActiveContext = Index;
|
||||||
mVAMs[Index]->SetCurrent();
|
mVAMs[Index]->SetCurrent();
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
#include "Core/OpenGL/CVertexArrayManager.h"
|
#include "Core/OpenGL/CVertexArrayManager.h"
|
||||||
#include "Core/Resource/CLight.h"
|
#include "Core/Resource/CLight.h"
|
||||||
#include <Common/CColor.h>
|
#include <Common/CColor.h>
|
||||||
#include <Math/CMatrix4f.h>
|
#include <Common/Math/CMatrix4f.h>
|
||||||
#include <Math/CVector3f.h>
|
#include <Common/Math/CVector3f.h>
|
||||||
#include <Math/CVector4f.h>
|
#include <Common/Math/CVector4f.h>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,8 +25,8 @@ class CGraphics
|
||||||
static CUniformBuffer *mpPixelBlockBuffer;
|
static CUniformBuffer *mpPixelBlockBuffer;
|
||||||
static CUniformBuffer *mpLightBlockBuffer;
|
static CUniformBuffer *mpLightBlockBuffer;
|
||||||
static CUniformBuffer *mpBoneTransformBuffer;
|
static CUniformBuffer *mpBoneTransformBuffer;
|
||||||
static u32 mContextIndices;
|
static uint32 mContextIndices;
|
||||||
static u32 mActiveContext;
|
static uint32 mActiveContext;
|
||||||
static bool mInitialized;
|
static bool mInitialized;
|
||||||
static std::vector<CVertexArrayManager*> mVAMs;
|
static std::vector<CVertexArrayManager*> mVAMs;
|
||||||
static bool mIdentityBoneTransforms;
|
static bool mIdentityBoneTransforms;
|
||||||
|
@ -81,7 +81,7 @@ public:
|
||||||
// Lighting-related
|
// Lighting-related
|
||||||
enum ELightingMode { eNoLighting, eBasicLighting, eWorldLighting };
|
enum ELightingMode { eNoLighting, eBasicLighting, eWorldLighting };
|
||||||
static ELightingMode sLightMode;
|
static ELightingMode sLightMode;
|
||||||
static u32 sNumLights;
|
static uint32 sNumLights;
|
||||||
static const CColor skDefaultAmbientColor;
|
static const CColor skDefaultAmbientColor;
|
||||||
static CColor sAreaAmbientColor;
|
static CColor sAreaAmbientColor;
|
||||||
static float sWorldLightMultiplier;
|
static float sWorldLightMultiplier;
|
||||||
|
@ -99,10 +99,10 @@ public:
|
||||||
static GLuint PixelBlockBindingPoint();
|
static GLuint PixelBlockBindingPoint();
|
||||||
static GLuint LightBlockBindingPoint();
|
static GLuint LightBlockBindingPoint();
|
||||||
static GLuint BoneTransformBlockBindingPoint();
|
static GLuint BoneTransformBlockBindingPoint();
|
||||||
static u32 GetContextIndex();
|
static uint32 GetContextIndex();
|
||||||
static u32 GetActiveContext();
|
static uint32 GetActiveContext();
|
||||||
static void ReleaseContext(u32 Index);
|
static void ReleaseContext(uint32 Index);
|
||||||
static void SetActiveContext(u32 Index);
|
static void SetActiveContext(uint32 Index);
|
||||||
static void SetDefaultLighting();
|
static void SetDefaultLighting();
|
||||||
static void SetupAmbientColor();
|
static void SetupAmbientColor();
|
||||||
static void SetIdentityMVP();
|
static void SetIdentityMVP();
|
||||||
|
|
|
@ -32,7 +32,7 @@ void CRenderBucket::CSubBucket::Sort(const CCamera* pkCamera, bool DebugVisualiz
|
||||||
|
|
||||||
if (DebugVisualization)
|
if (DebugVisualization)
|
||||||
{
|
{
|
||||||
for (u32 iPtr = 0; iPtr < mSize; iPtr++)
|
for (uint32 iPtr = 0; iPtr < mSize; iPtr++)
|
||||||
{
|
{
|
||||||
SRenderablePtr *pPtr = &mRenderables[iPtr];
|
SRenderablePtr *pPtr = &mRenderables[iPtr];
|
||||||
CVector3f Point = pPtr->AABox.ClosestPointAlongVector(pkCamera->Direction());
|
CVector3f Point = pPtr->AABox.ClosestPointAlongVector(pkCamera->Direction());
|
||||||
|
@ -63,7 +63,7 @@ void CRenderBucket::CSubBucket::Draw(const SViewInfo& rkViewInfo)
|
||||||
{
|
{
|
||||||
FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions();
|
FRenderOptions Options = rkViewInfo.pRenderer->RenderOptions();
|
||||||
|
|
||||||
for (u32 iPtr = 0; iPtr < mSize; iPtr++)
|
for (uint32 iPtr = 0; iPtr < mSize; iPtr++)
|
||||||
{
|
{
|
||||||
const SRenderablePtr& rkPtr = mRenderables[iPtr];
|
const SRenderablePtr& rkPtr = mRenderables[iPtr];
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "CGraphics.h"
|
#include "CGraphics.h"
|
||||||
#include "FRenderOptions.h"
|
#include "FRenderOptions.h"
|
||||||
#include "SRenderablePtr.h"
|
#include "SRenderablePtr.h"
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ class CRenderBucket
|
||||||
class CSubBucket
|
class CSubBucket
|
||||||
{
|
{
|
||||||
std::vector<SRenderablePtr> mRenderables;
|
std::vector<SRenderablePtr> mRenderables;
|
||||||
u32 mEstSize;
|
uint32 mEstSize;
|
||||||
u32 mSize;
|
uint32 mSize;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSubBucket()
|
CSubBucket()
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "CGraphics.h"
|
#include "CGraphics.h"
|
||||||
#include "Core/GameProject/CResourceStore.h"
|
#include "Core/GameProject/CResourceStore.h"
|
||||||
#include "Core/Resource/Factory/CTextureDecoder.h"
|
#include "Core/Resource/Factory/CTextureDecoder.h"
|
||||||
#include <Math/CTransform4f.h>
|
#include <Common/Math/CTransform4f.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
// ************ STATIC MEMBER INITIALIZATION ************
|
// ************ STATIC MEMBER INITIALIZATION ************
|
||||||
u32 CRenderer::sNumRenderers = 0;
|
uint32 CRenderer::sNumRenderers = 0;
|
||||||
|
|
||||||
// ************ INITIALIZATION ************
|
// ************ INITIALIZATION ************
|
||||||
CRenderer::CRenderer()
|
CRenderer::CRenderer()
|
||||||
|
@ -99,14 +99,14 @@ void CRenderer::SetClearColor(const CColor& rkClear)
|
||||||
glClearColor(mClearColor.R, mClearColor.G, mClearColor.B, mClearColor.A);
|
glClearColor(mClearColor.R, mClearColor.G, mClearColor.B, mClearColor.A);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRenderer::SetViewportSize(u32 Width, u32 Height)
|
void CRenderer::SetViewportSize(uint32 Width, uint32 Height)
|
||||||
{
|
{
|
||||||
mViewportWidth = Width;
|
mViewportWidth = Width;
|
||||||
mViewportHeight = Height;
|
mViewportHeight = Height;
|
||||||
mBloomHScale = ((float) Width / 640);
|
mBloomHScale = ((float) Width / 640);
|
||||||
mBloomVScale = ((float) Height / 528);
|
mBloomVScale = ((float) Height / 528);
|
||||||
mBloomWidth = (u32) (320 * mBloomHScale);
|
mBloomWidth = (uint32) (320 * mBloomHScale);
|
||||||
mBloomHeight = (u32) (224 * mBloomVScale);
|
mBloomHeight = (uint32) (224 * mBloomVScale);
|
||||||
mBloomHScale = 1.f / mBloomHScale;
|
mBloomHScale = 1.f / mBloomHScale;
|
||||||
mBloomVScale = 1.f / mBloomVScale;
|
mBloomVScale = 1.f / mBloomVScale;
|
||||||
}
|
}
|
||||||
|
@ -161,8 +161,8 @@ void CRenderer::RenderBloom()
|
||||||
CColor::Integral(53, 53, 53),
|
CColor::Integral(53, 53, 53),
|
||||||
CColor::Integral(17, 17, 17) };
|
CColor::Integral(17, 17, 17) };
|
||||||
|
|
||||||
u32 BloomWidth = (mBloomMode == eBloom ? mBloomWidth : mViewportWidth);
|
uint32 BloomWidth = (mBloomMode == eBloom ? mBloomWidth : mViewportWidth);
|
||||||
u32 BloomHeight = (mBloomMode == eBloom ? mBloomHeight : mViewportHeight);
|
uint32 BloomHeight = (mBloomMode == eBloom ? mBloomHeight : mViewportHeight);
|
||||||
float BloomHScale = (mBloomMode == eBloom ? mBloomHScale : 0);
|
float BloomHScale = (mBloomMode == eBloom ? mBloomHScale : 0);
|
||||||
float BloomVScale = (mBloomMode == eBloom ? mBloomVScale : 0);
|
float BloomVScale = (mBloomMode == eBloom ? mBloomVScale : 0);
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ void CRenderer::RenderBloom()
|
||||||
mBloomFramebuffers[0].Texture()->Bind(0);
|
mBloomFramebuffers[0].Texture()->Bind(0);
|
||||||
CDrawUtil::DrawSquare();
|
CDrawUtil::DrawSquare();
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < 6; iPass++)
|
for (uint32 iPass = 0; iPass < 6; iPass++)
|
||||||
{
|
{
|
||||||
CDrawUtil::UseTextureShader(skTintColors[iPass]);
|
CDrawUtil::UseTextureShader(skTintColors[iPass]);
|
||||||
CVector3f Translate(skHOffset[iPass] * BloomHScale, 0.f, 0.f);
|
CVector3f Translate(skHOffset[iPass] * BloomHScale, 0.f, 0.f);
|
||||||
|
@ -219,7 +219,7 @@ void CRenderer::RenderBloom()
|
||||||
mBloomFramebuffers[1].Texture()->Bind(0);
|
mBloomFramebuffers[1].Texture()->Bind(0);
|
||||||
CDrawUtil::DrawSquare();
|
CDrawUtil::DrawSquare();
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < 6; iPass++)
|
for (uint32 iPass = 0; iPass < 6; iPass++)
|
||||||
{
|
{
|
||||||
CDrawUtil::UseTextureShader(skTintColors[iPass]);
|
CDrawUtil::UseTextureShader(skTintColors[iPass]);
|
||||||
CVector3f Translate(0.f, skVOffset[iPass] * BloomVScale, 0.f);
|
CVector3f Translate(0.f, skVOffset[iPass] * BloomVScale, 0.f);
|
||||||
|
@ -353,4 +353,4 @@ void CRenderer::InitFramebuffer()
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 gDrawCount;
|
uint32 gDrawCount;
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
#include "Core/Scene/CSceneNode.h"
|
#include "Core/Scene/CSceneNode.h"
|
||||||
|
|
||||||
#include <Common/CColor.h>
|
#include <Common/CColor.h>
|
||||||
#include <Math/CAABox.h>
|
#include <Common/Math/CAABox.h>
|
||||||
#include <Math/CMatrix4f.h>
|
#include <Common/Math/CMatrix4f.h>
|
||||||
|
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
|
@ -33,10 +33,10 @@ private:
|
||||||
EBloomMode mBloomMode;
|
EBloomMode mBloomMode;
|
||||||
bool mDrawGrid;
|
bool mDrawGrid;
|
||||||
CColor mClearColor;
|
CColor mClearColor;
|
||||||
u32 mContextIndex;
|
uint32 mContextIndex;
|
||||||
bool mInitialized;
|
bool mInitialized;
|
||||||
u32 mViewportWidth, mViewportHeight;
|
uint32 mViewportWidth, mViewportHeight;
|
||||||
u32 mBloomWidth, mBloomHeight;
|
uint32 mBloomWidth, mBloomHeight;
|
||||||
float mBloomHScale, mBloomVScale;
|
float mBloomHScale, mBloomVScale;
|
||||||
|
|
||||||
CFramebuffer mSceneFramebuffer;
|
CFramebuffer mSceneFramebuffer;
|
||||||
|
@ -50,7 +50,7 @@ private:
|
||||||
CRenderBucket mUIBucket;
|
CRenderBucket mUIBucket;
|
||||||
|
|
||||||
// Static Members
|
// Static Members
|
||||||
static u32 sNumRenderers;
|
static uint32 sNumRenderers;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Initialization
|
// Initialization
|
||||||
|
@ -67,7 +67,7 @@ public:
|
||||||
void ToggleAlphaDisabled(bool Enable);
|
void ToggleAlphaDisabled(bool Enable);
|
||||||
void SetBloom(EBloomMode BloomMode);
|
void SetBloom(EBloomMode BloomMode);
|
||||||
void SetClearColor(const CColor& rkClear);
|
void SetClearColor(const CColor& rkClear);
|
||||||
void SetViewportSize(u32 Width, u32 Height);
|
void SetViewportSize(uint32 Width, uint32 Height);
|
||||||
|
|
||||||
// Render
|
// Render
|
||||||
void RenderBuckets(const SViewInfo& rkViewInfo);
|
void RenderBuckets(const SViewInfo& rkViewInfo);
|
||||||
|
@ -83,6 +83,6 @@ private:
|
||||||
void InitFramebuffer();
|
void InitFramebuffer();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern u32 gDrawCount;
|
extern uint32 gDrawCount;
|
||||||
|
|
||||||
#endif // RENDERMANAGER_H
|
#endif // RENDERMANAGER_H
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "ERenderCommand.h"
|
#include "ERenderCommand.h"
|
||||||
#include "FRenderOptions.h"
|
#include "FRenderOptions.h"
|
||||||
#include "SViewInfo.h"
|
#include "SViewInfo.h"
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
|
|
||||||
class CRenderer;
|
class CRenderer;
|
||||||
|
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
#include "ERenderCommand.h"
|
#include "ERenderCommand.h"
|
||||||
#include "IRenderable.h"
|
#include "IRenderable.h"
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
#include <Math/CAABox.h>
|
#include <Common/Math/CAABox.h>
|
||||||
|
|
||||||
struct SRenderablePtr
|
struct SRenderablePtr
|
||||||
{
|
{
|
||||||
IRenderable *pRenderable;
|
IRenderable *pRenderable;
|
||||||
u32 ComponentIndex;
|
uint32 ComponentIndex;
|
||||||
CAABox AABox;
|
CAABox AABox;
|
||||||
ERenderCommand Command;
|
ERenderCommand Command;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,14 +3,14 @@
|
||||||
|
|
||||||
#include "Core/Resource/CCollisionMaterial.h"
|
#include "Core/Resource/CCollisionMaterial.h"
|
||||||
#include "Core/Scene/FShowFlags.h"
|
#include "Core/Scene/FShowFlags.h"
|
||||||
#include <Math/CFrustumPlanes.h>
|
#include <Common/Math/CFrustumPlanes.h>
|
||||||
#include <Math/CMatrix4f.h>
|
#include <Common/Math/CMatrix4f.h>
|
||||||
#include <Math/CRay.h>
|
#include <Common/Math/CRay.h>
|
||||||
|
|
||||||
struct SCollisionRenderSettings
|
struct SCollisionRenderSettings
|
||||||
{
|
{
|
||||||
u64 HighlightMask;
|
uint64 HighlightMask;
|
||||||
u64 HideMask;
|
uint64 HideMask;
|
||||||
|
|
||||||
CCollisionMaterial HideMaterial;
|
CCollisionMaterial HideMaterial;
|
||||||
bool DrawWireframe;
|
bool DrawWireframe;
|
||||||
|
|
|
@ -9,7 +9,7 @@ class CAnimEventData : public CResource
|
||||||
|
|
||||||
struct SEvent
|
struct SEvent
|
||||||
{
|
{
|
||||||
u32 mCharacterIndex;
|
uint32 mCharacterIndex;
|
||||||
CAssetID mAssetRef;
|
CAssetID mAssetRef;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ public:
|
||||||
|
|
||||||
void AddDependenciesToTree(CDependencyTree *pTree) const
|
void AddDependenciesToTree(CDependencyTree *pTree) const
|
||||||
{
|
{
|
||||||
for (u32 iEvt = 0; iEvt < mEvents.size(); iEvt++)
|
for (uint32 iEvt = 0; iEvt < mEvents.size(); iEvt++)
|
||||||
{
|
{
|
||||||
const SEvent& rkEvent = mEvents[iEvt];
|
const SEvent& rkEvent = mEvents[iEvt];
|
||||||
CAssetID ID = rkEvent.mAssetRef;
|
CAssetID ID = rkEvent.mAssetRef;
|
||||||
|
@ -43,11 +43,11 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u32 NumEvents() const { return mEvents.size(); }
|
inline uint32 NumEvents() const { return mEvents.size(); }
|
||||||
inline u32 EventCharacterIndex(u32 EventIdx) const { return mEvents[EventIdx].mCharacterIndex; }
|
inline uint32 EventCharacterIndex(uint32 EventIdx) const { return mEvents[EventIdx].mCharacterIndex; }
|
||||||
inline CAssetID EventAssetRef(u32 EventIdx) const { return mEvents[EventIdx].mAssetRef; }
|
inline CAssetID EventAssetRef(uint32 EventIdx) const { return mEvents[EventIdx].mAssetRef; }
|
||||||
|
|
||||||
inline void AddEvent(u32 CharIdx, CAssetID AssetID) { mEvents.push_back( SEvent { CharIdx, AssetID } ); }
|
inline void AddEvent(uint32 CharIdx, CAssetID AssetID) { mEvents.push_back( SEvent { CharIdx, AssetID } ); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CANIMEVENTDATA
|
#endif // CANIMEVENTDATA
|
||||||
|
|
|
@ -12,14 +12,14 @@
|
||||||
#include "Core/Resource/CResource.h"
|
#include "Core/Resource/CResource.h"
|
||||||
#include "Core/Resource/TResPtr.h"
|
#include "Core/Resource/TResPtr.h"
|
||||||
#include "Core/Resource/Model/CModel.h"
|
#include "Core/Resource/Model/CModel.h"
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// Animation structures
|
// Animation structures
|
||||||
struct SAdditiveAnim
|
struct SAdditiveAnim
|
||||||
{
|
{
|
||||||
u32 AnimID;
|
uint32 AnimID;
|
||||||
float FadeInTime;
|
float FadeInTime;
|
||||||
float FadeOutTime;
|
float FadeOutTime;
|
||||||
};
|
};
|
||||||
|
@ -32,15 +32,15 @@ struct SAnimation
|
||||||
|
|
||||||
struct STransition
|
struct STransition
|
||||||
{
|
{
|
||||||
u32 Unknown;
|
uint32 Unknown;
|
||||||
u32 AnimIdA;
|
uint32 AnimIdA;
|
||||||
u32 AnimIdB;
|
uint32 AnimIdB;
|
||||||
IMetaTransition *pMetaTrans;
|
IMetaTransition *pMetaTrans;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SHalfTransition
|
struct SHalfTransition
|
||||||
{
|
{
|
||||||
u32 AnimID;
|
uint32 AnimID;
|
||||||
IMetaTransition *pMetaTrans;
|
IMetaTransition *pMetaTrans;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ struct SOverlayModel
|
||||||
|
|
||||||
struct SSetCharacter
|
struct SSetCharacter
|
||||||
{
|
{
|
||||||
u32 ID;
|
uint32 ID;
|
||||||
TString Name;
|
TString Name;
|
||||||
TResPtr<CModel> pModel;
|
TResPtr<CModel> pModel;
|
||||||
TResPtr<CSkin> pSkin;
|
TResPtr<CSkin> pSkin;
|
||||||
|
@ -79,7 +79,7 @@ struct SSetCharacter
|
||||||
std::vector<CAssetID> SoundEffects;
|
std::vector<CAssetID> SoundEffects;
|
||||||
std::vector<CAssetID> DKDependencies;
|
std::vector<CAssetID> DKDependencies;
|
||||||
CAssetID SpatialPrimitives;
|
CAssetID SpatialPrimitives;
|
||||||
std::set<u32> UsedAnimationIndices;
|
std::set<uint32> UsedAnimationIndices;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CAnimSet : public CResource
|
class CAnimSet : public CResource
|
||||||
|
@ -109,19 +109,19 @@ public:
|
||||||
|
|
||||||
~CAnimSet()
|
~CAnimSet()
|
||||||
{
|
{
|
||||||
for (u32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
|
for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
|
||||||
delete mAnimations[iAnim].pMetaAnim;
|
delete mAnimations[iAnim].pMetaAnim;
|
||||||
|
|
||||||
for (u32 iTrans = 0; iTrans < mTransitions.size(); iTrans++)
|
for (uint32 iTrans = 0; iTrans < mTransitions.size(); iTrans++)
|
||||||
delete mTransitions[iTrans].pMetaTrans;
|
delete mTransitions[iTrans].pMetaTrans;
|
||||||
|
|
||||||
for (u32 iHalf = 0; iHalf < mHalfTransitions.size(); iHalf++)
|
for (uint32 iHalf = 0; iHalf < mHalfTransitions.size(); iHalf++)
|
||||||
delete mHalfTransitions[iHalf].pMetaTrans;
|
delete mHalfTransitions[iHalf].pMetaTrans;
|
||||||
|
|
||||||
delete mpDefaultTransition;
|
delete mpDefaultTransition;
|
||||||
|
|
||||||
// For MP2, anim events need to be cleaned up manually
|
// For MP2, anim events need to be cleaned up manually
|
||||||
for (u32 iEvent = 0; iEvent < mAnimEvents.size(); iEvent++)
|
for (uint32 iEvent = 0; iEvent < mAnimEvents.size(); iEvent++)
|
||||||
{
|
{
|
||||||
ASSERT(mAnimEvents[iEvent] && !mAnimEvents[iEvent]->Entry());
|
ASSERT(mAnimEvents[iEvent] && !mAnimEvents[iEvent]->Entry());
|
||||||
delete mAnimEvents[iEvent];
|
delete mAnimEvents[iEvent];
|
||||||
|
@ -133,7 +133,7 @@ public:
|
||||||
CDependencyTree *pTree = new CDependencyTree();
|
CDependencyTree *pTree = new CDependencyTree();
|
||||||
|
|
||||||
// Character dependencies
|
// Character dependencies
|
||||||
for (u32 iChar = 0; iChar < mCharacters.size(); iChar++)
|
for (uint32 iChar = 0; iChar < mCharacters.size(); iChar++)
|
||||||
{
|
{
|
||||||
CSetCharacterDependency *pCharTree = CSetCharacterDependency::BuildTree( mCharacters[iChar] );
|
CSetCharacterDependency *pCharTree = CSetCharacterDependency::BuildTree( mCharacters[iChar] );
|
||||||
ASSERT(pCharTree);
|
ASSERT(pCharTree);
|
||||||
|
@ -143,7 +143,7 @@ public:
|
||||||
// Animation dependencies
|
// Animation dependencies
|
||||||
if (Game() <= EGame::Echoes)
|
if (Game() <= EGame::Echoes)
|
||||||
{
|
{
|
||||||
for (u32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
|
for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
|
||||||
{
|
{
|
||||||
CSetAnimationDependency *pAnimTree = CSetAnimationDependency::BuildTree(this, iAnim);
|
CSetAnimationDependency *pAnimTree = CSetAnimationDependency::BuildTree(this, iAnim);
|
||||||
ASSERT(pAnimTree);
|
ASSERT(pAnimTree);
|
||||||
|
@ -157,7 +157,7 @@ public:
|
||||||
std::set<CAnimPrimitive> PrimitiveSet;
|
std::set<CAnimPrimitive> PrimitiveSet;
|
||||||
|
|
||||||
// Animations
|
// Animations
|
||||||
for (u32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
|
for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
|
||||||
{
|
{
|
||||||
const SAnimation& rkAnim = mAnimations[iAnim];
|
const SAnimation& rkAnim = mAnimations[iAnim];
|
||||||
rkAnim.pMetaAnim->GetUniquePrimitives(PrimitiveSet);
|
rkAnim.pMetaAnim->GetUniquePrimitives(PrimitiveSet);
|
||||||
|
@ -174,7 +174,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event sounds
|
// Event sounds
|
||||||
for (u32 iSound = 0; iSound < rkChar.SoundEffects.size(); iSound++)
|
for (uint32 iSound = 0; iSound < rkChar.SoundEffects.size(); iSound++)
|
||||||
{
|
{
|
||||||
pTree->AddDependency(rkChar.SoundEffects[iSound]);
|
pTree->AddDependency(rkChar.SoundEffects[iSound]);
|
||||||
}
|
}
|
||||||
|
@ -184,14 +184,14 @@ public:
|
||||||
{
|
{
|
||||||
const SSetCharacter& rkChar = mCharacters[0];
|
const SSetCharacter& rkChar = mCharacters[0];
|
||||||
|
|
||||||
for (u32 iDep = 0; iDep < rkChar.DKDependencies.size(); iDep++)
|
for (uint32 iDep = 0; iDep < rkChar.DKDependencies.size(); iDep++)
|
||||||
pTree->AddDependency(rkChar.DKDependencies[iDep]);
|
pTree->AddDependency(rkChar.DKDependencies[iDep]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pTree;
|
return pTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimation* FindAnimationAsset(u32 AnimID) const
|
CAnimation* FindAnimationAsset(uint32 AnimID) const
|
||||||
{
|
{
|
||||||
if (AnimID >= 0 && AnimID < mAnimPrimitives.size())
|
if (AnimID >= 0 && AnimID < mAnimPrimitives.size())
|
||||||
{
|
{
|
||||||
|
@ -204,27 +204,27 @@ public:
|
||||||
|
|
||||||
void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
||||||
{
|
{
|
||||||
for (u32 iAnim = 0; iAnim < mAnimPrimitives.size(); iAnim++)
|
for (uint32 iAnim = 0; iAnim < mAnimPrimitives.size(); iAnim++)
|
||||||
rPrimSet.insert(mAnimPrimitives[iAnim]);
|
rPrimSet.insert(mAnimPrimitives[iAnim]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline u32 NumCharacters() const { return mCharacters.size(); }
|
inline uint32 NumCharacters() const { return mCharacters.size(); }
|
||||||
inline u32 NumAnimations() const { return mAnimations.size(); }
|
inline uint32 NumAnimations() const { return mAnimations.size(); }
|
||||||
|
|
||||||
inline const SSetCharacter* Character(u32 Index) const
|
inline const SSetCharacter* Character(uint32 Index) const
|
||||||
{
|
{
|
||||||
ASSERT(Index >= 0 && Index < NumCharacters());
|
ASSERT(Index >= 0 && Index < NumCharacters());
|
||||||
return &mCharacters[Index];
|
return &mCharacters[Index];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const SAnimation* Animation(u32 Index) const
|
inline const SAnimation* Animation(uint32 Index) const
|
||||||
{
|
{
|
||||||
ASSERT(Index >= 0 && Index < NumAnimations());
|
ASSERT(Index >= 0 && Index < NumAnimations());
|
||||||
return &mAnimations[Index];
|
return &mAnimations[Index];
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimEventData* AnimationEventData(u32 Index) const
|
CAnimEventData* AnimationEventData(uint32 Index) const
|
||||||
{
|
{
|
||||||
ASSERT(Index >= 0 && Index < NumAnimations());
|
ASSERT(Index >= 0 && Index < NumAnimations());
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "CAnimation.h"
|
#include "CAnimation.h"
|
||||||
#include <Math/CTransform4f.h>
|
#include <Common/Math/CTransform4f.h>
|
||||||
#include <Math/MathUtil.h>
|
#include <Common/Math/MathUtil.h>
|
||||||
|
|
||||||
CAnimation::CAnimation(CResourceEntry *pEntry /*= 0*/)
|
CAnimation::CAnimation(CResourceEntry *pEntry /*= 0*/)
|
||||||
: CResource(pEntry)
|
: CResource(pEntry)
|
||||||
|
@ -8,7 +8,7 @@ CAnimation::CAnimation(CResourceEntry *pEntry /*= 0*/)
|
||||||
, mTickInterval(0.0333333f)
|
, mTickInterval(0.0333333f)
|
||||||
, mNumKeys(0)
|
, mNumKeys(0)
|
||||||
{
|
{
|
||||||
for (u32 iBone = 0; iBone < 100; iBone++)
|
for (uint32 iBone = 0; iBone < 100; iBone++)
|
||||||
{
|
{
|
||||||
mBoneInfo[iBone].TranslationChannelIdx = 0xFF;
|
mBoneInfo[iBone].TranslationChannelIdx = 0xFF;
|
||||||
mBoneInfo[iBone].RotationChannelIdx = 0xFF;
|
mBoneInfo[iBone].RotationChannelIdx = 0xFF;
|
||||||
|
@ -23,7 +23,7 @@ CDependencyTree* CAnimation::BuildDependencyTree() const
|
||||||
return pTree;
|
return pTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimation::EvaluateTransform(float Time, u32 BoneID, CVector3f *pOutTranslation, CQuaternion *pOutRotation, CVector3f *pOutScale) const
|
void CAnimation::EvaluateTransform(float Time, uint32 BoneID, CVector3f *pOutTranslation, CQuaternion *pOutRotation, CVector3f *pOutScale) const
|
||||||
{
|
{
|
||||||
const bool kInterpolate = true;
|
const bool kInterpolate = true;
|
||||||
if (!pOutTranslation && !pOutRotation && !pOutScale) return;
|
if (!pOutTranslation && !pOutRotation && !pOutScale) return;
|
||||||
|
@ -32,12 +32,12 @@ void CAnimation::EvaluateTransform(float Time, u32 BoneID, CVector3f *pOutTransl
|
||||||
if (Time >= mDuration) Time = mDuration;
|
if (Time >= mDuration) Time = mDuration;
|
||||||
if (Time >= FLT_EPSILON) Time -= FLT_EPSILON;
|
if (Time >= FLT_EPSILON) Time -= FLT_EPSILON;
|
||||||
float t = fmodf(Time, mTickInterval) / mTickInterval;
|
float t = fmodf(Time, mTickInterval) / mTickInterval;
|
||||||
u32 LowKey = (u32) (Time / mTickInterval);
|
uint32 LowKey = (uint32) (Time / mTickInterval);
|
||||||
if (LowKey == (mNumKeys - 1)) LowKey = mNumKeys - 2;
|
if (LowKey == (mNumKeys - 1)) LowKey = mNumKeys - 2;
|
||||||
|
|
||||||
u8 ScaleChannel = mBoneInfo[BoneID].ScaleChannelIdx;
|
uint8 ScaleChannel = mBoneInfo[BoneID].ScaleChannelIdx;
|
||||||
u8 RotChannel = mBoneInfo[BoneID].RotationChannelIdx;
|
uint8 RotChannel = mBoneInfo[BoneID].RotationChannelIdx;
|
||||||
u8 TransChannel = mBoneInfo[BoneID].TranslationChannelIdx;
|
uint8 TransChannel = mBoneInfo[BoneID].TranslationChannelIdx;
|
||||||
|
|
||||||
if (ScaleChannel != 0xFF && pOutScale)
|
if (ScaleChannel != 0xFF && pOutScale)
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ void CAnimation::EvaluateTransform(float Time, u32 BoneID, CVector3f *pOutTransl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAnimation::HasTranslation(u32 BoneID) const
|
bool CAnimation::HasTranslation(uint32 BoneID) const
|
||||||
{
|
{
|
||||||
return (mBoneInfo[BoneID].TranslationChannelIdx != 0xFF);
|
return (mBoneInfo[BoneID].TranslationChannelIdx != 0xFF);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
#include "Core/Resource/CResource.h"
|
#include "Core/Resource/CResource.h"
|
||||||
#include "Core/Resource/TResPtr.h"
|
#include "Core/Resource/TResPtr.h"
|
||||||
#include "Core/Resource/Animation/CAnimEventData.h"
|
#include "Core/Resource/Animation/CAnimEventData.h"
|
||||||
#include <Math/CQuaternion.h>
|
#include <Common/Math/CQuaternion.h>
|
||||||
#include <Math/CVector3f.h>
|
#include <Common/Math/CVector3f.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class CAnimation : public CResource
|
class CAnimation : public CResource
|
||||||
|
@ -19,7 +19,7 @@ class CAnimation : public CResource
|
||||||
|
|
||||||
float mDuration;
|
float mDuration;
|
||||||
float mTickInterval;
|
float mTickInterval;
|
||||||
u32 mNumKeys;
|
uint32 mNumKeys;
|
||||||
|
|
||||||
std::vector<TScaleChannel> mScaleChannels;
|
std::vector<TScaleChannel> mScaleChannels;
|
||||||
std::vector<TRotationChannel> mRotationChannels;
|
std::vector<TRotationChannel> mRotationChannels;
|
||||||
|
@ -27,9 +27,9 @@ class CAnimation : public CResource
|
||||||
|
|
||||||
struct SBoneChannelInfo
|
struct SBoneChannelInfo
|
||||||
{
|
{
|
||||||
u8 ScaleChannelIdx;
|
uint8 ScaleChannelIdx;
|
||||||
u8 RotationChannelIdx;
|
uint8 RotationChannelIdx;
|
||||||
u8 TranslationChannelIdx;
|
uint8 TranslationChannelIdx;
|
||||||
};
|
};
|
||||||
SBoneChannelInfo mBoneInfo[100];
|
SBoneChannelInfo mBoneInfo[100];
|
||||||
|
|
||||||
|
@ -38,11 +38,11 @@ class CAnimation : public CResource
|
||||||
public:
|
public:
|
||||||
CAnimation(CResourceEntry *pEntry = 0);
|
CAnimation(CResourceEntry *pEntry = 0);
|
||||||
CDependencyTree* BuildDependencyTree() const;
|
CDependencyTree* BuildDependencyTree() const;
|
||||||
void EvaluateTransform(float Time, u32 BoneID, CVector3f *pOutTranslation, CQuaternion *pOutRotation, CVector3f *pOutScale) const;
|
void EvaluateTransform(float Time, uint32 BoneID, CVector3f *pOutTranslation, CQuaternion *pOutRotation, CVector3f *pOutScale) const;
|
||||||
bool HasTranslation(u32 BoneID) const;
|
bool HasTranslation(uint32 BoneID) const;
|
||||||
|
|
||||||
inline float Duration() const { return mDuration; }
|
inline float Duration() const { return mDuration; }
|
||||||
inline u32 NumKeys() const { return mNumKeys; }
|
inline uint32 NumKeys() const { return mNumKeys; }
|
||||||
inline float TickInterval() const { return mTickInterval; }
|
inline float TickInterval() const { return mTickInterval; }
|
||||||
inline CAnimEventData* EventData() const { return mpEventData; }
|
inline CAnimEventData* EventData() const { return mpEventData; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -45,7 +45,7 @@ CAnimationParameters::CAnimationParameters(IInputStream& rSCLY, EGame Game)
|
||||||
|
|
||||||
else if (Game == EGame::DKCReturns)
|
else if (Game == EGame::DKCReturns)
|
||||||
{
|
{
|
||||||
u8 Flags = rSCLY.ReadByte();
|
uint8 Flags = rSCLY.ReadByte();
|
||||||
|
|
||||||
// 0x80 - CharacterAnimationSet is empty.
|
// 0x80 - CharacterAnimationSet is empty.
|
||||||
if (Flags & 0x80)
|
if (Flags & 0x80)
|
||||||
|
@ -114,11 +114,11 @@ void CAnimationParameters::Write(IOutputStream& rSCLY)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!mCharacterID.IsValid())
|
if (!mCharacterID.IsValid())
|
||||||
rSCLY.WriteByte((u8) 0x80);
|
rSCLY.WriteByte((uint8) 0x80);
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8 Flag = 0;
|
uint8 Flag = 0;
|
||||||
if (mAnimIndex != -1) Flag |= 0x20;
|
if (mAnimIndex != -1) Flag |= 0x20;
|
||||||
if (mUnknown2 != 0 || mUnknown3 != 0) Flag |= 0x40;
|
if (mUnknown2 != 0 || mUnknown3 != 0) Flag |= 0x40;
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ void CAnimationParameters::Serialize(IArchive& rArc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SSetCharacter* CAnimationParameters::GetCurrentSetCharacter(s32 NodeIndex /*= -1*/)
|
const SSetCharacter* CAnimationParameters::GetCurrentSetCharacter(int32 NodeIndex /*= -1*/)
|
||||||
{
|
{
|
||||||
CAnimSet *pSet = AnimSet();
|
CAnimSet *pSet = AnimSet();
|
||||||
|
|
||||||
|
@ -165,27 +165,27 @@ const SSetCharacter* CAnimationParameters::GetCurrentSetCharacter(s32 NodeIndex
|
||||||
if (NodeIndex == -1)
|
if (NodeIndex == -1)
|
||||||
NodeIndex = mCharIndex;
|
NodeIndex = mCharIndex;
|
||||||
|
|
||||||
if (mCharIndex != -1 && pSet->NumCharacters() > (u32) NodeIndex)
|
if (mCharIndex != -1 && pSet->NumCharacters() > (uint32) NodeIndex)
|
||||||
return pSet->Character(NodeIndex);
|
return pSet->Character(NodeIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CModel* CAnimationParameters::GetCurrentModel(s32 NodeIndex /*= -1*/)
|
CModel* CAnimationParameters::GetCurrentModel(int32 NodeIndex /*= -1*/)
|
||||||
{
|
{
|
||||||
const SSetCharacter *pkChar = GetCurrentSetCharacter(NodeIndex);
|
const SSetCharacter *pkChar = GetCurrentSetCharacter(NodeIndex);
|
||||||
return pkChar ? pkChar->pModel : nullptr;
|
return pkChar ? pkChar->pModel : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TString CAnimationParameters::GetCurrentCharacterName(s32 NodeIndex /*= -1*/)
|
TString CAnimationParameters::GetCurrentCharacterName(int32 NodeIndex /*= -1*/)
|
||||||
{
|
{
|
||||||
const SSetCharacter *pkChar = GetCurrentSetCharacter(NodeIndex);
|
const SSetCharacter *pkChar = GetCurrentSetCharacter(NodeIndex);
|
||||||
return pkChar ? pkChar->Name : "";
|
return pkChar ? pkChar->Name : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ ACCESSORS ************
|
// ************ ACCESSORS ************
|
||||||
u32 CAnimationParameters::Unknown(u32 Index)
|
uint32 CAnimationParameters::Unknown(uint32 Index)
|
||||||
{
|
{
|
||||||
// mAnimIndex isn't unknown, but I'm too lazy to move it because there's a lot
|
// mAnimIndex isn't unknown, but I'm too lazy to move it because there's a lot
|
||||||
// of UI stuff that depends on these functions atm for accessing and editing parameters.
|
// of UI stuff that depends on these functions atm for accessing and editing parameters.
|
||||||
|
@ -214,14 +214,14 @@ void CAnimationParameters::SetResource(const CAssetID& rkID)
|
||||||
CResourceEntry *pEntry = gpResourceStore->FindEntry(rkID);
|
CResourceEntry *pEntry = gpResourceStore->FindEntry(rkID);
|
||||||
|
|
||||||
if (!pEntry)
|
if (!pEntry)
|
||||||
Log::Error("Invalid resource ID passed to CAnimationParameters: " + rkID.ToString());
|
errorf("Invalid resource ID passed to CAnimationParameters: %s", *rkID.ToString());
|
||||||
else if (pEntry->ResourceType() != eAnimSet && pEntry->ResourceType() != eCharacter)
|
else if (pEntry->ResourceType() != eAnimSet && pEntry->ResourceType() != eCharacter)
|
||||||
Log::Error("Resource with invalid type passed to CAnimationParameters: " + pEntry->CookedAssetPath().GetFileName());
|
errorf("Resource with invalid type passed to CAnimationParameters: %s", *pEntry->CookedAssetPath().GetFileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CAnimationParameters::SetUnknown(u32 Index, u32 Value)
|
void CAnimationParameters::SetUnknown(uint32 Index, uint32 Value)
|
||||||
{
|
{
|
||||||
switch (Index)
|
switch (Index)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,10 +10,10 @@ class CAnimationParameters
|
||||||
EGame mGame;
|
EGame mGame;
|
||||||
CAssetID mCharacterID;
|
CAssetID mCharacterID;
|
||||||
|
|
||||||
u32 mCharIndex;
|
uint32 mCharIndex;
|
||||||
u32 mAnimIndex;
|
uint32 mAnimIndex;
|
||||||
u32 mUnknown2;
|
uint32 mUnknown2;
|
||||||
u32 mUnknown3;
|
uint32 mUnknown3;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAnimationParameters();
|
CAnimationParameters();
|
||||||
|
@ -22,18 +22,18 @@ public:
|
||||||
void Write(IOutputStream& rSCLY);
|
void Write(IOutputStream& rSCLY);
|
||||||
void Serialize(IArchive& rArc);
|
void Serialize(IArchive& rArc);
|
||||||
|
|
||||||
const SSetCharacter* GetCurrentSetCharacter(s32 NodeIndex = -1);
|
const SSetCharacter* GetCurrentSetCharacter(int32 NodeIndex = -1);
|
||||||
CModel* GetCurrentModel(s32 NodeIndex = -1);
|
CModel* GetCurrentModel(int32 NodeIndex = -1);
|
||||||
TString GetCurrentCharacterName(s32 NodeIndex = -1);
|
TString GetCurrentCharacterName(int32 NodeIndex = -1);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline EGame Version() const { return mGame; }
|
inline EGame Version() const { return mGame; }
|
||||||
inline CAssetID ID() const { return mCharacterID; }
|
inline CAssetID ID() const { return mCharacterID; }
|
||||||
inline CAnimSet* AnimSet() const { return (CAnimSet*) gpResourceStore->LoadResource(mCharacterID); }
|
inline CAnimSet* AnimSet() const { return (CAnimSet*) gpResourceStore->LoadResource(mCharacterID); }
|
||||||
inline u32 CharacterIndex() const { return mCharIndex; }
|
inline uint32 CharacterIndex() const { return mCharIndex; }
|
||||||
inline u32 AnimIndex() const { return mAnimIndex; }
|
inline uint32 AnimIndex() const { return mAnimIndex; }
|
||||||
inline void SetCharIndex(u32 Index) { mCharIndex = Index; }
|
inline void SetCharIndex(uint32 Index) { mCharIndex = Index; }
|
||||||
inline void SetAnimIndex(u32 Index) { mAnimIndex = Index; }
|
inline void SetAnimIndex(uint32 Index) { mAnimIndex = Index; }
|
||||||
|
|
||||||
inline void SetGame(EGame Game)
|
inline void SetGame(EGame Game)
|
||||||
{
|
{
|
||||||
|
@ -49,9 +49,9 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Unknown(u32 Index);
|
uint32 Unknown(uint32 Index);
|
||||||
void SetResource(const CAssetID& rkID);
|
void SetResource(const CAssetID& rkID);
|
||||||
void SetUnknown(u32 Index, u32 Value);
|
void SetUnknown(uint32 Index, uint32 Value);
|
||||||
|
|
||||||
// Operators
|
// Operators
|
||||||
inline CAnimationParameters& operator=(const CAnimationParameters& rkOther)
|
inline CAnimationParameters& operator=(const CAnimationParameters& rkOther)
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
#include "Core/Render/CBoneTransformData.h"
|
#include "Core/Render/CBoneTransformData.h"
|
||||||
#include "Core/Render/CDrawUtil.h"
|
#include "Core/Render/CDrawUtil.h"
|
||||||
#include "Core/Render/CGraphics.h"
|
#include "Core/Render/CGraphics.h"
|
||||||
#include <Common/AssertMacro.h>
|
#include <Common/Macros.h>
|
||||||
#include <Math/MathUtil.h>
|
#include <Common/Math/MathUtil.h>
|
||||||
|
|
||||||
// ************ CBone ************
|
// ************ CBone ************
|
||||||
CBone::CBone(CSkeleton *pSkel)
|
CBone::CBone(CSkeleton *pSkel)
|
||||||
|
@ -37,7 +37,7 @@ void CBone::UpdateTransform(CBoneTransformData& rData, const SBoneTransformInfo&
|
||||||
rTransform *= mInvBind;
|
rTransform *= mInvBind;
|
||||||
|
|
||||||
// Calculate children
|
// Calculate children
|
||||||
for (u32 iChild = 0; iChild < mChildren.size(); iChild++)
|
for (uint32 iChild = 0; iChild < mChildren.size(); iChild++)
|
||||||
mChildren[iChild]->UpdateTransform(rData, TransformInfo, pAnim, Time, AnchorRoot);
|
mChildren[iChild]->UpdateTransform(rData, TransformInfo, pAnim, Time, AnchorRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,13 +70,13 @@ CSkeleton::CSkeleton(CResourceEntry *pEntry /*= 0*/)
|
||||||
|
|
||||||
CSkeleton::~CSkeleton()
|
CSkeleton::~CSkeleton()
|
||||||
{
|
{
|
||||||
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
|
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
|
||||||
delete mBones[iBone];
|
delete mBones[iBone];
|
||||||
}
|
}
|
||||||
|
|
||||||
CBone* CSkeleton::BoneByID(u32 BoneID) const
|
CBone* CSkeleton::BoneByID(uint32 BoneID) const
|
||||||
{
|
{
|
||||||
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
|
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
|
||||||
{
|
{
|
||||||
if (mBones[iBone]->ID() == BoneID)
|
if (mBones[iBone]->ID() == BoneID)
|
||||||
return mBones[iBone];
|
return mBones[iBone];
|
||||||
|
@ -87,7 +87,7 @@ CBone* CSkeleton::BoneByID(u32 BoneID) const
|
||||||
|
|
||||||
CBone* CSkeleton::BoneByName(const TString& rkBoneName) const
|
CBone* CSkeleton::BoneByName(const TString& rkBoneName) const
|
||||||
{
|
{
|
||||||
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
|
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
|
||||||
{
|
{
|
||||||
if (mBones[iBone]->Name() == rkBoneName)
|
if (mBones[iBone]->Name() == rkBoneName)
|
||||||
return mBones[iBone];
|
return mBones[iBone];
|
||||||
|
@ -96,11 +96,11 @@ CBone* CSkeleton::BoneByName(const TString& rkBoneName) const
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CSkeleton::MaxBoneID() const
|
uint32 CSkeleton::MaxBoneID() const
|
||||||
{
|
{
|
||||||
u32 ID = 0;
|
uint32 ID = 0;
|
||||||
|
|
||||||
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
|
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
|
||||||
{
|
{
|
||||||
if (mBones[iBone]->ID() > ID)
|
if (mBones[iBone]->ID() > ID)
|
||||||
ID = mBones[iBone]->ID();
|
ID = mBones[iBone]->ID();
|
||||||
|
@ -121,7 +121,7 @@ void CSkeleton::Draw(FRenderOptions /*Options*/, const CBoneTransformData *pkDat
|
||||||
glLineWidth(1.f);
|
glLineWidth(1.f);
|
||||||
|
|
||||||
// Draw all child links first to minimize model matrix swaps.
|
// Draw all child links first to minimize model matrix swaps.
|
||||||
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
|
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
|
||||||
{
|
{
|
||||||
CBone *pBone = mBones[iBone];
|
CBone *pBone = mBones[iBone];
|
||||||
CVector3f BonePos = pkData ? pBone->TransformedPosition(*pkData) : pBone->Position();
|
CVector3f BonePos = pkData ? pBone->TransformedPosition(*pkData) : pBone->Position();
|
||||||
|
@ -136,7 +136,7 @@ void CSkeleton::Draw(FRenderOptions /*Options*/, const CBoneTransformData *pkDat
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw child links
|
// Draw child links
|
||||||
for (u32 iChild = 0; iChild < pBone->NumChildren(); iChild++)
|
for (uint32 iChild = 0; iChild < pBone->NumChildren(); iChild++)
|
||||||
{
|
{
|
||||||
CBone *pChild = pBone->ChildByIndex(iChild);
|
CBone *pChild = pBone->ChildByIndex(iChild);
|
||||||
CVector3f ChildPos = pkData ? pChild->TransformedPosition(*pkData) : pChild->Position();
|
CVector3f ChildPos = pkData ? pChild->TransformedPosition(*pkData) : pChild->Position();
|
||||||
|
@ -147,7 +147,7 @@ void CSkeleton::Draw(FRenderOptions /*Options*/, const CBoneTransformData *pkDat
|
||||||
// Draw bone spheres
|
// Draw bone spheres
|
||||||
CTransform4f BaseTransform = CGraphics::sMVPBlock.ModelMatrix;
|
CTransform4f BaseTransform = CGraphics::sMVPBlock.ModelMatrix;
|
||||||
|
|
||||||
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
|
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
|
||||||
{
|
{
|
||||||
CBone *pBone = mBones[iBone];
|
CBone *pBone = mBones[iBone];
|
||||||
CVector3f BonePos = pkData ? pBone->TransformedPosition(*pkData) : pBone->Position();
|
CVector3f BonePos = pkData ? pBone->TransformedPosition(*pkData) : pBone->Position();
|
||||||
|
@ -161,11 +161,11 @@ void CSkeleton::Draw(FRenderOptions /*Options*/, const CBoneTransformData *pkDat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<s32,float> CSkeleton::RayIntersect(const CRay& rkRay, const CBoneTransformData& rkData)
|
std::pair<int32,float> CSkeleton::RayIntersect(const CRay& rkRay, const CBoneTransformData& rkData)
|
||||||
{
|
{
|
||||||
std::pair<s32,float> Out(-1, FLT_MAX);
|
std::pair<int32,float> Out(-1, FLT_MAX);
|
||||||
|
|
||||||
for (u32 iBone = 0; iBone < mBones.size(); iBone++)
|
for (uint32 iBone = 0; iBone < mBones.size(); iBone++)
|
||||||
{
|
{
|
||||||
CBone *pBone = mBones[iBone];
|
CBone *pBone = mBones[iBone];
|
||||||
CVector3f BonePos = pBone->TransformedPosition(rkData);
|
CVector3f BonePos = pBone->TransformedPosition(rkData);
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
#include "CAnimation.h"
|
#include "CAnimation.h"
|
||||||
#include "Core/Render/FRenderOptions.h"
|
#include "Core/Render/FRenderOptions.h"
|
||||||
#include "Core/Resource/CResource.h"
|
#include "Core/Resource/CResource.h"
|
||||||
|
#include <Common/BasicTypes.h>
|
||||||
#include <Common/TString.h>
|
#include <Common/TString.h>
|
||||||
#include <Common/types.h>
|
#include <Common/Math/CRay.h>
|
||||||
#include <Math/CRay.h>
|
#include <Common/Math/CVector3f.h>
|
||||||
#include <Math/CVector3f.h>
|
|
||||||
|
|
||||||
class CBoneTransformData;
|
class CBoneTransformData;
|
||||||
class CBone;
|
class CBone;
|
||||||
|
@ -36,14 +36,14 @@ public:
|
||||||
CSkeleton(CResourceEntry *pEntry = 0);
|
CSkeleton(CResourceEntry *pEntry = 0);
|
||||||
~CSkeleton();
|
~CSkeleton();
|
||||||
void UpdateTransform(CBoneTransformData& rData, CAnimation *pAnim, float Time, bool AnchorRoot);
|
void UpdateTransform(CBoneTransformData& rData, CAnimation *pAnim, float Time, bool AnchorRoot);
|
||||||
CBone* BoneByID(u32 BoneID) const;
|
CBone* BoneByID(uint32 BoneID) const;
|
||||||
CBone* BoneByName(const TString& rkBoneName) const;
|
CBone* BoneByName(const TString& rkBoneName) const;
|
||||||
u32 MaxBoneID() const;
|
uint32 MaxBoneID() const;
|
||||||
|
|
||||||
void Draw(FRenderOptions Options, const CBoneTransformData *pkData);
|
void Draw(FRenderOptions Options, const CBoneTransformData *pkData);
|
||||||
std::pair<s32,float> RayIntersect(const CRay& rkRay, const CBoneTransformData& rkData);
|
std::pair<int32,float> RayIntersect(const CRay& rkRay, const CBoneTransformData& rkData);
|
||||||
|
|
||||||
inline u32 NumBones() const { return mBones.size(); }
|
inline uint32 NumBones() const { return mBones.size(); }
|
||||||
inline CBone* RootBone() const { return mpRootBone; }
|
inline CBone* RootBone() const { return mpRootBone; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class CBone
|
||||||
CSkeleton *mpSkeleton;
|
CSkeleton *mpSkeleton;
|
||||||
CBone *mpParent;
|
CBone *mpParent;
|
||||||
std::vector<CBone*> mChildren;
|
std::vector<CBone*> mChildren;
|
||||||
u32 mID;
|
uint32 mID;
|
||||||
CVector3f mPosition;
|
CVector3f mPosition;
|
||||||
CVector3f mLocalPosition;
|
CVector3f mLocalPosition;
|
||||||
CQuaternion mRotation;
|
CQuaternion mRotation;
|
||||||
|
@ -73,9 +73,9 @@ public:
|
||||||
// Accessors
|
// Accessors
|
||||||
inline CSkeleton* Skeleton() const { return mpSkeleton; }
|
inline CSkeleton* Skeleton() const { return mpSkeleton; }
|
||||||
inline CBone* Parent() const { return mpParent; }
|
inline CBone* Parent() const { return mpParent; }
|
||||||
inline u32 NumChildren() const { return mChildren.size(); }
|
inline uint32 NumChildren() const { return mChildren.size(); }
|
||||||
inline CBone* ChildByIndex(u32 Index) const { return mChildren[Index]; }
|
inline CBone* ChildByIndex(uint32 Index) const { return mChildren[Index]; }
|
||||||
inline u32 ID() const { return mID; }
|
inline uint32 ID() const { return mID; }
|
||||||
inline CVector3f Position() const { return mPosition; }
|
inline CVector3f Position() const { return mPosition; }
|
||||||
inline CVector3f LocalPosition() const { return mLocalPosition; }
|
inline CVector3f LocalPosition() const { return mLocalPosition; }
|
||||||
inline CQuaternion Rotation() const { return mRotation; }
|
inline CQuaternion Rotation() const { return mRotation; }
|
||||||
|
|
|
@ -18,14 +18,14 @@ class CSkin : public CResource
|
||||||
struct SVertGroup
|
struct SVertGroup
|
||||||
{
|
{
|
||||||
SVertexWeights Weights;
|
SVertexWeights Weights;
|
||||||
u32 NumVertices;
|
uint32 NumVertices;
|
||||||
};
|
};
|
||||||
std::vector<SVertGroup> mVertGroups;
|
std::vector<SVertGroup> mVertGroups;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CSkin(CResourceEntry *pEntry = 0) : CResource(pEntry) {}
|
CSkin(CResourceEntry *pEntry = 0) : CResource(pEntry) {}
|
||||||
|
|
||||||
const SVertexWeights& WeightsForVertex(u32 VertIdx)
|
const SVertexWeights& WeightsForVertex(uint32 VertIdx)
|
||||||
{
|
{
|
||||||
// Null weights bind everything to the root bone in case there is no matching vertex group
|
// Null weights bind everything to the root bone in case there is no matching vertex group
|
||||||
static const SVertexWeights skNullWeights = {
|
static const SVertexWeights skNullWeights = {
|
||||||
|
@ -33,9 +33,9 @@ public:
|
||||||
{ 1.f, 0.f, 0.f, 0.f }
|
{ 1.f, 0.f, 0.f, 0.f }
|
||||||
};
|
};
|
||||||
|
|
||||||
u32 Index = 0;
|
uint32 Index = 0;
|
||||||
|
|
||||||
for (u32 iGrp = 0; iGrp < mVertGroups.size(); iGrp++)
|
for (uint32 iGrp = 0; iGrp < mVertGroups.size(); iGrp++)
|
||||||
{
|
{
|
||||||
if (VertIdx < Index + mVertGroups[iGrp].NumVertices)
|
if (VertIdx < Index + mVertGroups[iGrp].NumVertices)
|
||||||
return mVertGroups[iGrp].Weights;
|
return mVertGroups[iGrp].Weights;
|
||||||
|
|
|
@ -34,10 +34,10 @@ public:
|
||||||
|
|
||||||
~CSourceAnimData()
|
~CSourceAnimData()
|
||||||
{
|
{
|
||||||
for (u32 TransIdx = 0; TransIdx < mTransitions.size(); TransIdx++)
|
for (uint32 TransIdx = 0; TransIdx < mTransitions.size(); TransIdx++)
|
||||||
delete mTransitions[TransIdx].pTransition;
|
delete mTransitions[TransIdx].pTransition;
|
||||||
|
|
||||||
for (u32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
|
for (uint32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
|
||||||
delete mHalfTransitions[HalfIdx].pTransition;
|
delete mHalfTransitions[HalfIdx].pTransition;
|
||||||
|
|
||||||
delete mpDefaultTransition;
|
delete mpDefaultTransition;
|
||||||
|
@ -54,10 +54,10 @@ public:
|
||||||
|
|
||||||
void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
||||||
{
|
{
|
||||||
for (u32 TransIdx = 0; TransIdx < mTransitions.size(); TransIdx++)
|
for (uint32 TransIdx = 0; TransIdx < mTransitions.size(); TransIdx++)
|
||||||
mTransitions[TransIdx].pTransition->GetUniquePrimitives(rPrimSet);
|
mTransitions[TransIdx].pTransition->GetUniquePrimitives(rPrimSet);
|
||||||
|
|
||||||
for (u32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
|
for (uint32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
|
||||||
mHalfTransitions[HalfIdx].pTransition->GetUniquePrimitives(rPrimSet);
|
mHalfTransitions[HalfIdx].pTransition->GetUniquePrimitives(rPrimSet);
|
||||||
|
|
||||||
if (mpDefaultTransition)
|
if (mpDefaultTransition)
|
||||||
|
@ -80,7 +80,7 @@ public:
|
||||||
UsedTransitions.insert(mpDefaultTransition);
|
UsedTransitions.insert(mpDefaultTransition);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 TransitionIdx = 0; TransitionIdx < mTransitions.size(); TransitionIdx++)
|
for (uint32 TransitionIdx = 0; TransitionIdx < mTransitions.size(); TransitionIdx++)
|
||||||
{
|
{
|
||||||
const STransition& rkTransition = mTransitions[TransitionIdx];
|
const STransition& rkTransition = mTransitions[TransitionIdx];
|
||||||
IMetaTransition *pTransition = rkTransition.pTransition;
|
IMetaTransition *pTransition = rkTransition.pTransition;
|
||||||
|
@ -94,7 +94,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (u32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
|
for (uint32 HalfIdx = 0; HalfIdx < mHalfTransitions.size(); HalfIdx++)
|
||||||
{
|
{
|
||||||
const SHalfTransition& rkHalfTrans = mHalfTransitions[HalfIdx];
|
const SHalfTransition& rkHalfTrans = mHalfTransitions[HalfIdx];
|
||||||
IMetaTransition *pTransition = rkHalfTrans.pTransition;
|
IMetaTransition *pTransition = rkHalfTrans.pTransition;
|
||||||
|
|
|
@ -23,13 +23,13 @@ IMetaAnimation* CMetaAnimFactory::LoadFromStream(IInputStream& rInput, EGame Gam
|
||||||
return new CMetaAnimSequence(rInput, Game);
|
return new CMetaAnimSequence(rInput, Game);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log::Error("Unrecognized meta-animation type: " + TString::FromInt32(Type, 0, 10));
|
errorf("Unrecognized meta-animation type: %d", Type);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ CMetaAnimationPlay ************
|
// ************ CMetaAnimationPlay ************
|
||||||
CMetaAnimPlay::CMetaAnimPlay(const CAnimPrimitive& rkPrimitive, float UnkA, u32 UnkB)
|
CMetaAnimPlay::CMetaAnimPlay(const CAnimPrimitive& rkPrimitive, float UnkA, uint32 UnkB)
|
||||||
: mPrimitive(rkPrimitive)
|
: mPrimitive(rkPrimitive)
|
||||||
, mUnknownA(UnkA)
|
, mUnknownA(UnkA)
|
||||||
, mUnknownB(UnkB)
|
, mUnknownB(UnkB)
|
||||||
|
@ -84,10 +84,10 @@ void CMetaAnimBlend::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) con
|
||||||
// ************ CMetaAnimRandom ************
|
// ************ CMetaAnimRandom ************
|
||||||
CMetaAnimRandom::CMetaAnimRandom(IInputStream& rInput, EGame Game)
|
CMetaAnimRandom::CMetaAnimRandom(IInputStream& rInput, EGame Game)
|
||||||
{
|
{
|
||||||
u32 NumPairs = rInput.ReadLong();
|
uint32 NumPairs = rInput.ReadLong();
|
||||||
mProbabilityPairs.reserve(NumPairs);
|
mProbabilityPairs.reserve(NumPairs);
|
||||||
|
|
||||||
for (u32 iAnim = 0; iAnim < NumPairs; iAnim++)
|
for (uint32 iAnim = 0; iAnim < NumPairs; iAnim++)
|
||||||
{
|
{
|
||||||
SAnimProbabilityPair Pair;
|
SAnimProbabilityPair Pair;
|
||||||
Pair.pAnim = gMetaAnimFactory.LoadFromStream(rInput, Game);
|
Pair.pAnim = gMetaAnimFactory.LoadFromStream(rInput, Game);
|
||||||
|
@ -98,7 +98,7 @@ CMetaAnimRandom::CMetaAnimRandom(IInputStream& rInput, EGame Game)
|
||||||
|
|
||||||
CMetaAnimRandom::~CMetaAnimRandom()
|
CMetaAnimRandom::~CMetaAnimRandom()
|
||||||
{
|
{
|
||||||
for (u32 iPair = 0; iPair < mProbabilityPairs.size(); iPair++)
|
for (uint32 iPair = 0; iPair < mProbabilityPairs.size(); iPair++)
|
||||||
delete mProbabilityPairs[iPair].pAnim;
|
delete mProbabilityPairs[iPair].pAnim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,17 +109,17 @@ EMetaAnimationType CMetaAnimRandom::Type() const
|
||||||
|
|
||||||
void CMetaAnimRandom::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
void CMetaAnimRandom::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
||||||
{
|
{
|
||||||
for (u32 iPair = 0; iPair < mProbabilityPairs.size(); iPair++)
|
for (uint32 iPair = 0; iPair < mProbabilityPairs.size(); iPair++)
|
||||||
mProbabilityPairs[iPair].pAnim->GetUniquePrimitives(rPrimSet);
|
mProbabilityPairs[iPair].pAnim->GetUniquePrimitives(rPrimSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************ CMetaAnimSequence ************
|
// ************ CMetaAnimSequence ************
|
||||||
CMetaAnimSequence::CMetaAnimSequence(IInputStream& rInput, EGame Game)
|
CMetaAnimSequence::CMetaAnimSequence(IInputStream& rInput, EGame Game)
|
||||||
{
|
{
|
||||||
u32 NumAnims = rInput.ReadLong();
|
uint32 NumAnims = rInput.ReadLong();
|
||||||
mAnimations.reserve(NumAnims);
|
mAnimations.reserve(NumAnims);
|
||||||
|
|
||||||
for (u32 iAnim = 0; iAnim < NumAnims; iAnim++)
|
for (uint32 iAnim = 0; iAnim < NumAnims; iAnim++)
|
||||||
{
|
{
|
||||||
IMetaAnimation *pAnim = gMetaAnimFactory.LoadFromStream(rInput, Game);
|
IMetaAnimation *pAnim = gMetaAnimFactory.LoadFromStream(rInput, Game);
|
||||||
mAnimations.push_back(pAnim);
|
mAnimations.push_back(pAnim);
|
||||||
|
@ -128,7 +128,7 @@ CMetaAnimSequence::CMetaAnimSequence(IInputStream& rInput, EGame Game)
|
||||||
|
|
||||||
CMetaAnimSequence::~CMetaAnimSequence()
|
CMetaAnimSequence::~CMetaAnimSequence()
|
||||||
{
|
{
|
||||||
for (u32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
|
for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
|
||||||
delete mAnimations[iAnim];
|
delete mAnimations[iAnim];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +139,6 @@ EMetaAnimationType CMetaAnimSequence::Type() const
|
||||||
|
|
||||||
void CMetaAnimSequence::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
void CMetaAnimSequence::GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const
|
||||||
{
|
{
|
||||||
for (u32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
|
for (uint32 iAnim = 0; iAnim < mAnimations.size(); iAnim++)
|
||||||
mAnimations[iAnim]->GetUniquePrimitives(rPrimSet);
|
mAnimations[iAnim]->GetUniquePrimitives(rPrimSet);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,13 +26,13 @@ extern CMetaAnimFactory gMetaAnimFactory;
|
||||||
class CAnimPrimitive
|
class CAnimPrimitive
|
||||||
{
|
{
|
||||||
TResPtr<CAnimation> mpAnim;
|
TResPtr<CAnimation> mpAnim;
|
||||||
u32 mID;
|
uint32 mID;
|
||||||
TString mName;
|
TString mName;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAnimPrimitive() : mID(0) {}
|
CAnimPrimitive() : mID(0) {}
|
||||||
|
|
||||||
CAnimPrimitive(const CAssetID& rkAnimAssetID, u32 CharAnimID, const TString& rkAnimName)
|
CAnimPrimitive(const CAssetID& rkAnimAssetID, uint32 CharAnimID, const TString& rkAnimName)
|
||||||
: mID(CharAnimID), mName(rkAnimName)
|
: mID(CharAnimID), mName(rkAnimName)
|
||||||
{
|
{
|
||||||
mpAnim = gpResourceStore->LoadResource(rkAnimAssetID);
|
mpAnim = gpResourceStore->LoadResource(rkAnimAssetID);
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
CAnimation* Animation() const { return mpAnim; }
|
CAnimation* Animation() const { return mpAnim; }
|
||||||
u32 ID() const { return mID; }
|
uint32 ID() const { return mID; }
|
||||||
TString Name() const { return mName; }
|
TString Name() const { return mName; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,10 +73,10 @@ class CMetaAnimPlay : public IMetaAnimation
|
||||||
protected:
|
protected:
|
||||||
CAnimPrimitive mPrimitive;
|
CAnimPrimitive mPrimitive;
|
||||||
float mUnknownA;
|
float mUnknownA;
|
||||||
u32 mUnknownB;
|
uint32 mUnknownB;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMetaAnimPlay(const CAnimPrimitive& rkPrimitive, float UnkA, u32 UnkB);
|
CMetaAnimPlay(const CAnimPrimitive& rkPrimitive, float UnkA, uint32 UnkB);
|
||||||
CMetaAnimPlay(IInputStream& rInput, EGame Game);
|
CMetaAnimPlay(IInputStream& rInput, EGame Game);
|
||||||
virtual EMetaAnimationType Type() const;
|
virtual EMetaAnimationType Type() const;
|
||||||
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
|
virtual void GetUniquePrimitives(std::set<CAnimPrimitive>& rPrimSet) const;
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
// Accessors
|
// Accessors
|
||||||
inline CAnimPrimitive Primitive() const { return mPrimitive; }
|
inline CAnimPrimitive Primitive() const { return mPrimitive; }
|
||||||
inline float UnknownA() const { return mUnknownA; }
|
inline float UnknownA() const { return mUnknownA; }
|
||||||
inline u32 UnknownB() const { return mUnknownB; }
|
inline uint32 UnknownB() const { return mUnknownB; }
|
||||||
};
|
};
|
||||||
|
|
||||||
// CMetaAnimBlend - blend between two animations
|
// CMetaAnimBlend - blend between two animations
|
||||||
|
@ -114,7 +114,7 @@ public:
|
||||||
struct SAnimProbabilityPair
|
struct SAnimProbabilityPair
|
||||||
{
|
{
|
||||||
IMetaAnimation *pAnim;
|
IMetaAnimation *pAnim;
|
||||||
u32 Probability;
|
uint32 Probability;
|
||||||
};
|
};
|
||||||
|
|
||||||
// CMetaAnimRandom - play random animation
|
// CMetaAnimRandom - play random animation
|
||||||
|
|
|
@ -24,7 +24,7 @@ IMetaTransition* CMetaTransFactory::LoadFromStream(IInputStream& rInput, EGame G
|
||||||
return new CMetaTransType4(rInput, Game);
|
return new CMetaTransType4(rInput, Game);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Log::Error("Unrecognized meta-transition type: " + TString::FromInt32(Type, 0, 10));
|
errorf("Unrecognized meta-transition type: %d", Type);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,10 @@ class CMetaTransTrans : public IMetaTransition
|
||||||
{
|
{
|
||||||
EMetaTransitionType mType;
|
EMetaTransitionType mType;
|
||||||
float mUnknownA;
|
float mUnknownA;
|
||||||
u32 mUnknownB;
|
uint32 mUnknownB;
|
||||||
bool mUnknownC;
|
bool mUnknownC;
|
||||||
bool mUnknownD;
|
bool mUnknownD;
|
||||||
u32 mUnknownE;
|
uint32 mUnknownE;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMetaTransTrans(EMetaTransitionType Type, IInputStream& rInput, EGame Game);
|
CMetaTransTrans(EMetaTransitionType Type, IInputStream& rInput, EGame Game);
|
||||||
|
|
|
@ -21,11 +21,11 @@ CGameArea::~CGameArea()
|
||||||
|
|
||||||
delete mpCollision;
|
delete mpCollision;
|
||||||
|
|
||||||
for (u32 iSCLY = 0; iSCLY < mScriptLayers.size(); iSCLY++)
|
for (uint32 iSCLY = 0; iSCLY < mScriptLayers.size(); iSCLY++)
|
||||||
delete mScriptLayers[iSCLY];
|
delete mScriptLayers[iSCLY];
|
||||||
|
|
||||||
for (u32 iLyr = 0; iLyr < mLightLayers.size(); iLyr++)
|
for (uint32 iLyr = 0; iLyr < mLightLayers.size(); iLyr++)
|
||||||
for (u32 iLight = 0; iLight < mLightLayers[iLyr].size(); iLight++)
|
for (uint32 iLight = 0; iLight < mLightLayers[iLyr].size(); iLight++)
|
||||||
delete mLightLayers[iLyr][iLight];
|
delete mLightLayers[iLyr][iLight];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,13 +49,13 @@ CDependencyTree* CGameArea::BuildDependencyTree() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra deps
|
// Extra deps
|
||||||
for (u32 iDep = 0; iDep < mExtraAreaDeps.size(); iDep++)
|
for (uint32 iDep = 0; iDep < mExtraAreaDeps.size(); iDep++)
|
||||||
pTree->AddDependency(mExtraAreaDeps[iDep]);
|
pTree->AddDependency(mExtraAreaDeps[iDep]);
|
||||||
|
|
||||||
// Layer dependencies
|
// Layer dependencies
|
||||||
std::vector<CAssetID> DummyDeps;
|
std::vector<CAssetID> DummyDeps;
|
||||||
|
|
||||||
for (u32 iLayer = 0; iLayer < mScriptLayers.size(); iLayer++)
|
for (uint32 iLayer = 0; iLayer < mScriptLayers.size(); iLayer++)
|
||||||
{
|
{
|
||||||
const std::vector<CAssetID>& rkExtras = (mExtraLayerDeps.size() > iLayer ? mExtraLayerDeps[iLayer] : DummyDeps);
|
const std::vector<CAssetID>& rkExtras = (mExtraLayerDeps.size() > iLayer ? mExtraLayerDeps[iLayer] : DummyDeps);
|
||||||
pTree->AddScriptLayer(mScriptLayers[iLayer], rkExtras);
|
pTree->AddScriptLayer(mScriptLayers[iLayer], rkExtras);
|
||||||
|
@ -77,12 +77,12 @@ void CGameArea::MergeTerrain()
|
||||||
if (mTerrainMerged) return;
|
if (mTerrainMerged) return;
|
||||||
|
|
||||||
// Nothing really complicated here - iterate through every terrain submesh, add each to a static model
|
// Nothing really complicated here - iterate through every terrain submesh, add each to a static model
|
||||||
for (u32 iMdl = 0; iMdl < mWorldModels.size(); iMdl++)
|
for (uint32 iMdl = 0; iMdl < mWorldModels.size(); iMdl++)
|
||||||
{
|
{
|
||||||
CModel *pMdl = mWorldModels[iMdl];
|
CModel *pMdl = mWorldModels[iMdl];
|
||||||
u32 SubmeshCount = pMdl->GetSurfaceCount();
|
uint32 SubmeshCount = pMdl->GetSurfaceCount();
|
||||||
|
|
||||||
for (u32 iSurf = 0; iSurf < SubmeshCount; iSurf++)
|
for (uint32 iSurf = 0; iSurf < SubmeshCount; iSurf++)
|
||||||
{
|
{
|
||||||
SSurface *pSurf = pMdl->GetSurface(iSurf);
|
SSurface *pSurf = pMdl->GetSurface(iSurf);
|
||||||
CMaterial *pMat = mpMaterialSet->MaterialByIndex(pSurf->MaterialID);
|
CMaterial *pMat = mpMaterialSet->MaterialByIndex(pSurf->MaterialID);
|
||||||
|
@ -118,11 +118,11 @@ void CGameArea::MergeTerrain()
|
||||||
|
|
||||||
void CGameArea::ClearTerrain()
|
void CGameArea::ClearTerrain()
|
||||||
{
|
{
|
||||||
for (u32 iModel = 0; iModel < mWorldModels.size(); iModel++)
|
for (uint32 iModel = 0; iModel < mWorldModels.size(); iModel++)
|
||||||
delete mWorldModels[iModel];
|
delete mWorldModels[iModel];
|
||||||
mWorldModels.clear();
|
mWorldModels.clear();
|
||||||
|
|
||||||
for (u32 iStatic = 0; iStatic < mStaticWorldModels.size(); iStatic++)
|
for (uint32 iStatic = 0; iStatic < mStaticWorldModels.size(); iStatic++)
|
||||||
delete mStaticWorldModels[iStatic];
|
delete mStaticWorldModels[iStatic];
|
||||||
mStaticWorldModels.clear();
|
mStaticWorldModels.clear();
|
||||||
|
|
||||||
|
@ -141,26 +141,26 @@ void CGameArea::ClearScriptLayers()
|
||||||
mScriptLayers.clear();
|
mScriptLayers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CGameArea::TotalInstanceCount() const
|
uint32 CGameArea::TotalInstanceCount() const
|
||||||
{
|
{
|
||||||
u32 Num = 0;
|
uint32 Num = 0;
|
||||||
|
|
||||||
for (u32 iLyr = 0; iLyr < mScriptLayers.size(); iLyr++)
|
for (uint32 iLyr = 0; iLyr < mScriptLayers.size(); iLyr++)
|
||||||
Num += mScriptLayers[iLyr]->NumInstances();
|
Num += mScriptLayers[iLyr]->NumInstances();
|
||||||
|
|
||||||
return Num;
|
return Num;
|
||||||
}
|
}
|
||||||
|
|
||||||
CScriptObject* CGameArea::InstanceByID(u32 InstanceID)
|
CScriptObject* CGameArea::InstanceByID(uint32 InstanceID)
|
||||||
{
|
{
|
||||||
auto it = mObjectMap.find(InstanceID);
|
auto it = mObjectMap.find(InstanceID);
|
||||||
if (it != mObjectMap.end()) return it->second;
|
if (it != mObjectMap.end()) return it->second;
|
||||||
else return nullptr;
|
else return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 CGameArea::FindUnusedInstanceID() const
|
uint32 CGameArea::FindUnusedInstanceID() const
|
||||||
{
|
{
|
||||||
u32 InstanceID = (mWorldIndex << 16) | 1;
|
uint32 InstanceID = (mWorldIndex << 16) | 1;
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -180,20 +180,20 @@ CScriptObject* CGameArea::SpawnInstance(CScriptTemplate *pTemplate,
|
||||||
const CVector3f& rkPosition /*= CVector3f::skZero*/,
|
const CVector3f& rkPosition /*= CVector3f::skZero*/,
|
||||||
const CQuaternion& rkRotation /*= CQuaternion::skIdentity*/,
|
const CQuaternion& rkRotation /*= CQuaternion::skIdentity*/,
|
||||||
const CVector3f& rkScale /*= CVector3f::skOne*/,
|
const CVector3f& rkScale /*= CVector3f::skOne*/,
|
||||||
u32 SuggestedID /*= -1*/,
|
uint32 SuggestedID /*= -1*/,
|
||||||
u32 SuggestedLayerIndex /*= -1*/ )
|
uint32 SuggestedLayerIndex /*= -1*/ )
|
||||||
{
|
{
|
||||||
// Verify we can fit another instance in this area.
|
// Verify we can fit another instance in this area.
|
||||||
u32 NumInstances = TotalInstanceCount();
|
uint32 NumInstances = TotalInstanceCount();
|
||||||
|
|
||||||
if (NumInstances >= 0xFFFF)
|
if (NumInstances >= 0xFFFF)
|
||||||
{
|
{
|
||||||
Log::Error("Unable to spawn a new script instance; too many instances in area (" + TString::FromInt32(NumInstances, 0, 10) + ")");
|
errorf("Unable to spawn a new script instance; too many instances in area (%d)", NumInstances);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether the suggested instance ID is valid
|
// Check whether the suggested instance ID is valid
|
||||||
u32 InstanceID = SuggestedID;
|
uint32 InstanceID = SuggestedID;
|
||||||
|
|
||||||
if (InstanceID != -1)
|
if (InstanceID != -1)
|
||||||
{
|
{
|
||||||
|
@ -205,11 +205,11 @@ CScriptObject* CGameArea::SpawnInstance(CScriptTemplate *pTemplate,
|
||||||
if (InstanceID == -1)
|
if (InstanceID == -1)
|
||||||
{
|
{
|
||||||
// Determine layer index
|
// Determine layer index
|
||||||
u32 LayerIndex = pLayer->AreaIndex();
|
uint32 LayerIndex = pLayer->AreaIndex();
|
||||||
|
|
||||||
if (LayerIndex == -1)
|
if (LayerIndex == -1)
|
||||||
{
|
{
|
||||||
Log::Error("Unable to spawn a new script instance; invalid script layer passed in");
|
errorf("Unable to spawn a new script instance; invalid script layer passed in");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,9 @@
|
||||||
#include "Core/Resource/CPoiToWorld.h"
|
#include "Core/Resource/CPoiToWorld.h"
|
||||||
#include "Core/Resource/Model/CModel.h"
|
#include "Core/Resource/Model/CModel.h"
|
||||||
#include "Core/Resource/Model/CStaticModel.h"
|
#include "Core/Resource/Model/CStaticModel.h"
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
#include <Math/CQuaternion.h>
|
#include <Common/Math/CQuaternion.h>
|
||||||
#include <Math/CTransform4f.h>
|
#include <Common/Math/CTransform4f.h>
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
@ -24,22 +24,22 @@ class CGameArea : public CResource
|
||||||
friend class CAreaLoader;
|
friend class CAreaLoader;
|
||||||
friend class CAreaCooker;
|
friend class CAreaCooker;
|
||||||
|
|
||||||
u32 mWorldIndex;
|
uint32 mWorldIndex;
|
||||||
u32 mVertexCount;
|
uint32 mVertexCount;
|
||||||
u32 mTriangleCount;
|
uint32 mTriangleCount;
|
||||||
bool mTerrainMerged;
|
bool mTerrainMerged;
|
||||||
CTransform4f mTransform;
|
CTransform4f mTransform;
|
||||||
CAABox mAABox;
|
CAABox mAABox;
|
||||||
|
|
||||||
// Data saved from the original file to help on recook
|
// Data saved from the original file to help on recook
|
||||||
std::vector<std::vector<u8>> mSectionDataBuffers;
|
std::vector<std::vector<uint8>> mSectionDataBuffers;
|
||||||
u32 mOriginalWorldMeshCount;
|
uint32 mOriginalWorldMeshCount;
|
||||||
bool mUsesCompression;
|
bool mUsesCompression;
|
||||||
|
|
||||||
struct SSectionNumber
|
struct SSectionNumber
|
||||||
{
|
{
|
||||||
CFourCC SectionID;
|
CFourCC SectionID;
|
||||||
u32 Index;
|
uint32 Index;
|
||||||
};
|
};
|
||||||
std::vector<SSectionNumber> mSectionNumbers;
|
std::vector<SSectionNumber> mSectionNumbers;
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ class CGameArea : public CResource
|
||||||
std::vector<CStaticModel*> mStaticWorldModels; // StaticTerrainModels is the merged terrain for faster rendering in the world editor
|
std::vector<CStaticModel*> mStaticWorldModels; // StaticTerrainModels is the merged terrain for faster rendering in the world editor
|
||||||
// Script
|
// Script
|
||||||
std::vector<CScriptLayer*> mScriptLayers;
|
std::vector<CScriptLayer*> mScriptLayers;
|
||||||
std::unordered_map<u32, CScriptObject*> mObjectMap;
|
std::unordered_map<uint32, CScriptObject*> mObjectMap;
|
||||||
// Collision
|
// Collision
|
||||||
CCollisionMeshGroup *mpCollision;
|
CCollisionMeshGroup *mpCollision;
|
||||||
// Lights
|
// Lights
|
||||||
|
@ -73,38 +73,38 @@ public:
|
||||||
void MergeTerrain();
|
void MergeTerrain();
|
||||||
void ClearTerrain();
|
void ClearTerrain();
|
||||||
void ClearScriptLayers();
|
void ClearScriptLayers();
|
||||||
u32 TotalInstanceCount() const;
|
uint32 TotalInstanceCount() const;
|
||||||
CScriptObject* InstanceByID(u32 InstanceID);
|
CScriptObject* InstanceByID(uint32 InstanceID);
|
||||||
u32 FindUnusedInstanceID() const;
|
uint32 FindUnusedInstanceID() const;
|
||||||
CScriptObject* SpawnInstance(CScriptTemplate *pTemplate, CScriptLayer *pLayer,
|
CScriptObject* SpawnInstance(CScriptTemplate *pTemplate, CScriptLayer *pLayer,
|
||||||
const CVector3f& rkPosition = CVector3f::skZero,
|
const CVector3f& rkPosition = CVector3f::skZero,
|
||||||
const CQuaternion& rkRotation = CQuaternion::skIdentity,
|
const CQuaternion& rkRotation = CQuaternion::skIdentity,
|
||||||
const CVector3f& rkScale = CVector3f::skOne,
|
const CVector3f& rkScale = CVector3f::skOne,
|
||||||
u32 SuggestedID = -1, u32 SuggestedLayerIndex = -1);
|
uint32 SuggestedID = -1, uint32 SuggestedLayerIndex = -1);
|
||||||
void AddInstanceToArea(CScriptObject *pInstance);
|
void AddInstanceToArea(CScriptObject *pInstance);
|
||||||
void DeleteInstance(CScriptObject *pInstance);
|
void DeleteInstance(CScriptObject *pInstance);
|
||||||
void ClearExtraDependencies();
|
void ClearExtraDependencies();
|
||||||
|
|
||||||
// Inline Accessors
|
// Inline Accessors
|
||||||
inline u32 WorldIndex() const { return mWorldIndex; }
|
inline uint32 WorldIndex() const { return mWorldIndex; }
|
||||||
inline CTransform4f Transform() const { return mTransform; }
|
inline CTransform4f Transform() const { return mTransform; }
|
||||||
inline CMaterialSet* Materials() const { return mpMaterialSet; }
|
inline CMaterialSet* Materials() const { return mpMaterialSet; }
|
||||||
inline u32 NumWorldModels() const { return mWorldModels.size(); }
|
inline uint32 NumWorldModels() const { return mWorldModels.size(); }
|
||||||
inline u32 NumStaticModels() const { return mStaticWorldModels.size(); }
|
inline uint32 NumStaticModels() const { return mStaticWorldModels.size(); }
|
||||||
inline CModel* TerrainModel(u32 iMdl) const { return mWorldModels[iMdl]; }
|
inline CModel* TerrainModel(uint32 iMdl) const { return mWorldModels[iMdl]; }
|
||||||
inline CStaticModel* StaticModel(u32 iMdl) const { return mStaticWorldModels[iMdl]; }
|
inline CStaticModel* StaticModel(uint32 iMdl) const { return mStaticWorldModels[iMdl]; }
|
||||||
inline CCollisionMeshGroup* Collision() const { return mpCollision; }
|
inline CCollisionMeshGroup* Collision() const { return mpCollision; }
|
||||||
inline u32 NumScriptLayers() const { return mScriptLayers.size(); }
|
inline uint32 NumScriptLayers() const { return mScriptLayers.size(); }
|
||||||
inline CScriptLayer* ScriptLayer(u32 Index) const { return mScriptLayers[Index]; }
|
inline CScriptLayer* ScriptLayer(uint32 Index) const { return mScriptLayers[Index]; }
|
||||||
inline u32 NumLightLayers() const { return mLightLayers.size(); }
|
inline uint32 NumLightLayers() const { return mLightLayers.size(); }
|
||||||
inline u32 NumLights(u32 LayerIndex) const { return (LayerIndex < mLightLayers.size() ? mLightLayers[LayerIndex].size() : 0); }
|
inline uint32 NumLights(uint32 LayerIndex) const { return (LayerIndex < mLightLayers.size() ? mLightLayers[LayerIndex].size() : 0); }
|
||||||
inline CLight* Light(u32 LayerIndex, u32 LightIndex) const { return mLightLayers[LayerIndex][LightIndex]; }
|
inline CLight* Light(uint32 LayerIndex, uint32 LightIndex) const { return mLightLayers[LayerIndex][LightIndex]; }
|
||||||
inline CAssetID PathID() const { return mPathID; }
|
inline CAssetID PathID() const { return mPathID; }
|
||||||
inline CPoiToWorld* PoiToWorldMap() const { return mpPoiToWorldMap; }
|
inline CPoiToWorld* PoiToWorldMap() const { return mpPoiToWorldMap; }
|
||||||
inline CAssetID PortalAreaID() const { return mPortalAreaID; }
|
inline CAssetID PortalAreaID() const { return mPortalAreaID; }
|
||||||
inline CAABox AABox() const { return mAABox; }
|
inline CAABox AABox() const { return mAABox; }
|
||||||
|
|
||||||
inline void SetWorldIndex(u32 NewWorldIndex) { mWorldIndex = NewWorldIndex; }
|
inline void SetWorldIndex(uint32 NewWorldIndex) { mWorldIndex = NewWorldIndex; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CGAMEAREA_H
|
#endif // CGAMEAREA_H
|
||||||
|
|
|
@ -10,8 +10,8 @@ class CAudioGroup : public CResource
|
||||||
friend class CAudioGroupLoader;
|
friend class CAudioGroupLoader;
|
||||||
|
|
||||||
TString mGroupName;
|
TString mGroupName;
|
||||||
u32 mGroupID;
|
uint32 mGroupID;
|
||||||
std::vector<u16> mDefineIDs;
|
std::vector<uint16> mDefineIDs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAudioGroup(CResourceEntry *pEntry = 0)
|
CAudioGroup(CResourceEntry *pEntry = 0)
|
||||||
|
@ -20,10 +20,10 @@ public:
|
||||||
{}
|
{}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline TString GroupName() const { return mGroupName; }
|
inline TString GroupName() const { return mGroupName; }
|
||||||
inline u32 GroupID() const { return mGroupID; }
|
inline uint32 GroupID() const { return mGroupID; }
|
||||||
inline u32 NumSoundDefineIDs() const { return mDefineIDs.size(); }
|
inline uint32 NumSoundDefineIDs() const { return mDefineIDs.size(); }
|
||||||
inline u16 SoundDefineIDByIndex(u32 Index) const { return mDefineIDs[Index]; }
|
inline uint16 SoundDefineIDByIndex(uint32 Index) const { return mDefineIDs[Index]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CAUDIOGROUP
|
#endif // CAUDIOGROUP
|
||||||
|
|
|
@ -7,14 +7,14 @@ class CAudioLookupTable : public CResource
|
||||||
{
|
{
|
||||||
DECLARE_RESOURCE_TYPE(eAudioLookupTable)
|
DECLARE_RESOURCE_TYPE(eAudioLookupTable)
|
||||||
friend class CAudioGroupLoader;
|
friend class CAudioGroupLoader;
|
||||||
std::vector<u16> mDefineIDs;
|
std::vector<uint16> mDefineIDs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAudioLookupTable(CResourceEntry *pEntry = 0)
|
CAudioLookupTable(CResourceEntry *pEntry = 0)
|
||||||
: CResource(pEntry)
|
: CResource(pEntry)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
inline u16 FindSoundDefineID(u32 SoundID)
|
inline uint16 FindSoundDefineID(uint32 SoundID)
|
||||||
{
|
{
|
||||||
if (SoundID >= mDefineIDs.size()) return -1;
|
if (SoundID >= mDefineIDs.size()) return -1;
|
||||||
return mDefineIDs[SoundID];
|
return mDefineIDs[SoundID];
|
||||||
|
|
|
@ -20,16 +20,16 @@ public:
|
||||||
{
|
{
|
||||||
CDependencyTree *pTree = new CDependencyTree();
|
CDependencyTree *pTree = new CDependencyTree();
|
||||||
|
|
||||||
for (u32 iSamp = 0; iSamp < mSamples.size(); iSamp++)
|
for (uint32 iSamp = 0; iSamp < mSamples.size(); iSamp++)
|
||||||
pTree->AddDependency(mSamples[iSamp]);
|
pTree->AddDependency(mSamples[iSamp]);
|
||||||
|
|
||||||
return pTree;
|
return pTree;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline TString MacroName() const { return mMacroName; }
|
inline TString MacroName() const { return mMacroName; }
|
||||||
inline u32 NumSamples() const { return mSamples.size(); }
|
inline uint32 NumSamples() const { return mSamples.size(); }
|
||||||
inline CAssetID SampleByIndex(u32 Index) const { return mSamples[Index]; }
|
inline CAssetID SampleByIndex(uint32 Index) const { return mSamples[Index]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CAUDIOMACRO_H
|
#endif // CAUDIOMACRO_H
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "CCollisionMaterial.h"
|
#include "CCollisionMaterial.h"
|
||||||
#include <Common/AssertMacro.h>
|
#include <Common/Macros.h>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
ECollisionFlag CCollisionMaterial::SurfaceType(EGame Game) const
|
ECollisionFlag CCollisionMaterial::SurfaceType(EGame Game) const
|
||||||
|
@ -19,7 +19,7 @@ ECollisionFlag CCollisionMaterial::SurfaceType(EGame Game) const
|
||||||
|
|
||||||
// Determine which list we should use.
|
// Determine which list we should use.
|
||||||
const ECollisionFlag* pkFlagArray;
|
const ECollisionFlag* pkFlagArray;
|
||||||
u32 Num;
|
uint32 Num;
|
||||||
|
|
||||||
if (Game <= EGame::Prime)
|
if (Game <= EGame::Prime)
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ ECollisionFlag CCollisionMaterial::SurfaceType(EGame Game) const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Locate type.
|
// Locate type.
|
||||||
for (u32 iType = 0; iType < Num; iType++)
|
for (uint32 iType = 0; iType < Num; iType++)
|
||||||
{
|
{
|
||||||
if (*this & pkFlagArray[iType])
|
if (*this & pkFlagArray[iType])
|
||||||
return pkFlagArray[iType];
|
return pkFlagArray[iType];
|
||||||
|
|
|
@ -51,7 +51,7 @@ enum ECollisionFlag
|
||||||
class CCollisionMaterial : public TFlags<ECollisionFlag>
|
class CCollisionMaterial : public TFlags<ECollisionFlag>
|
||||||
{
|
{
|
||||||
friend class CCollisionLoader;
|
friend class CCollisionLoader;
|
||||||
u64 mRawFlags;
|
uint64 mRawFlags;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ECollisionFlag SurfaceType(EGame Game) const;
|
ECollisionFlag SurfaceType(EGame Game) const;
|
||||||
|
@ -59,7 +59,7 @@ public:
|
||||||
bool IsFloor() const;
|
bool IsFloor() const;
|
||||||
bool IsUnstandable(EGame Game) const;
|
bool IsUnstandable(EGame Game) const;
|
||||||
|
|
||||||
inline u64 RawFlags() const { return mRawFlags; }
|
inline uint64 RawFlags() const { return mRawFlags; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CCOLLISIONMATERIAL
|
#endif // CCOLLISIONMATERIAL
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "CCollisionMesh.h"
|
#include "CCollisionMesh.h"
|
||||||
#include "Core/Render/CRenderer.h"
|
#include "Core/Render/CRenderer.h"
|
||||||
#include "Core/Render/CDrawUtil.h"
|
#include "Core/Render/CDrawUtil.h"
|
||||||
#include <Common/AssertMacro.h>
|
#include <Common/Macros.h>
|
||||||
|
|
||||||
CCollisionMesh::CCollisionMesh()
|
CCollisionMesh::CCollisionMesh()
|
||||||
{
|
{
|
||||||
|
@ -43,11 +43,11 @@ void CCollisionMesh::BufferGL()
|
||||||
mIBO.Reserve(SortedTris.size() * 3);
|
mIBO.Reserve(SortedTris.size() * 3);
|
||||||
|
|
||||||
mMaterialOffsets.reserve(mMaterials.size());
|
mMaterialOffsets.reserve(mMaterials.size());
|
||||||
u32 CurMat = 0;
|
uint32 CurMat = 0;
|
||||||
|
|
||||||
for (u32 iTri = 0; iTri < SortedTris.size(); iTri++)
|
for (uint32 iTri = 0; iTri < SortedTris.size(); iTri++)
|
||||||
{
|
{
|
||||||
u16 Verts[3];
|
uint16 Verts[3];
|
||||||
|
|
||||||
CCollisionFace *pFace = &SortedTris[iTri];
|
CCollisionFace *pFace = &SortedTris[iTri];
|
||||||
CCollisionLine *pLineA = GetLine(pFace->Lines[0]);
|
CCollisionLine *pLineA = GetLine(pFace->Lines[0]);
|
||||||
|
@ -75,7 +75,7 @@ void CCollisionMesh::BufferGL()
|
||||||
// Some faces have a property that indicates they need to be inverted
|
// Some faces have a property that indicates they need to be inverted
|
||||||
if (GetMaterial(pFace->MaterialIdx) & eCF_FlippedTri)
|
if (GetMaterial(pFace->MaterialIdx) & eCF_FlippedTri)
|
||||||
{
|
{
|
||||||
u16 V0 = Verts[0];
|
uint16 V0 = Verts[0];
|
||||||
Verts[0] = Verts[2];
|
Verts[0] = Verts[2];
|
||||||
Verts[2] = V0;
|
Verts[2] = V0;
|
||||||
}
|
}
|
||||||
|
@ -89,12 +89,12 @@ void CCollisionMesh::BufferGL()
|
||||||
CVector3f V0toV2 = (rVert2.Pos - rVert0.Pos).Normalized();
|
CVector3f V0toV2 = (rVert2.Pos - rVert0.Pos).Normalized();
|
||||||
CVector3f FaceNormal = V0toV1.Cross(V0toV2).Normalized();
|
CVector3f FaceNormal = V0toV1.Cross(V0toV2).Normalized();
|
||||||
|
|
||||||
for (u32 iVtx = 0; iVtx < 3; iVtx++)
|
for (uint32 iVtx = 0; iVtx < 3; iVtx++)
|
||||||
{
|
{
|
||||||
CVertex Vtx;
|
CVertex Vtx;
|
||||||
Vtx.Position = mCollisionVertices[ Verts[iVtx] ].Pos;
|
Vtx.Position = mCollisionVertices[ Verts[iVtx] ].Pos;
|
||||||
Vtx.Normal = FaceNormal;
|
Vtx.Normal = FaceNormal;
|
||||||
u16 Index = mVBO.AddVertex(Vtx);
|
uint16 Index = mVBO.AddVertex(Vtx);
|
||||||
mIBO.AddIndex(Index);
|
mIBO.AddIndex(Index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,14 +122,14 @@ void CCollisionMesh::Draw()
|
||||||
mVBO.Unbind();
|
mVBO.Unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCollisionMesh::DrawMaterial(u32 MatIdx, bool Wireframe)
|
void CCollisionMesh::DrawMaterial(uint32 MatIdx, bool Wireframe)
|
||||||
{
|
{
|
||||||
if (!mBuffered) BufferGL();
|
if (!mBuffered) BufferGL();
|
||||||
ASSERT(MatIdx < mMaterials.size());
|
ASSERT(MatIdx < mMaterials.size());
|
||||||
|
|
||||||
mVBO.Bind();
|
mVBO.Bind();
|
||||||
u32 StartIdx = (MatIdx == 0 ? 0 : mMaterialOffsets[MatIdx - 1]);
|
uint32 StartIdx = (MatIdx == 0 ? 0 : mMaterialOffsets[MatIdx - 1]);
|
||||||
u32 NumElements = mMaterialOffsets[MatIdx] - StartIdx;
|
uint32 NumElements = mMaterialOffsets[MatIdx] - StartIdx;
|
||||||
|
|
||||||
if (Wireframe)
|
if (Wireframe)
|
||||||
{
|
{
|
||||||
|
@ -153,17 +153,17 @@ void CCollisionMesh::DrawWireframe()
|
||||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||||
}
|
}
|
||||||
|
|
||||||
CCollisionMesh::CCollisionVertex* CCollisionMesh::GetVertex(u16 Index)
|
CCollisionMesh::CCollisionVertex* CCollisionMesh::GetVertex(uint16 Index)
|
||||||
{
|
{
|
||||||
return &mCollisionVertices[Index];
|
return &mCollisionVertices[Index];
|
||||||
}
|
}
|
||||||
|
|
||||||
CCollisionMesh::CCollisionLine* CCollisionMesh::GetLine(u16 Index)
|
CCollisionMesh::CCollisionLine* CCollisionMesh::GetLine(uint16 Index)
|
||||||
{
|
{
|
||||||
return &mCollisionLines[Index];
|
return &mCollisionLines[Index];
|
||||||
}
|
}
|
||||||
|
|
||||||
CCollisionMesh::CCollisionFace* CCollisionMesh::GetFace(u16 Index)
|
CCollisionMesh::CCollisionFace* CCollisionMesh::GetFace(uint16 Index)
|
||||||
{
|
{
|
||||||
return &mCollisionFaces[Index];
|
return &mCollisionFaces[Index];
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "CResource.h"
|
#include "CResource.h"
|
||||||
#include "Core/OpenGL/CVertexBuffer.h"
|
#include "Core/OpenGL/CVertexBuffer.h"
|
||||||
#include "Core/OpenGL/CIndexBuffer.h"
|
#include "Core/OpenGL/CIndexBuffer.h"
|
||||||
#include <Math/CAABox.h>
|
#include <Common/Math/CAABox.h>
|
||||||
|
|
||||||
class CCollisionMesh
|
class CCollisionMesh
|
||||||
{
|
{
|
||||||
|
@ -19,12 +19,12 @@ class CCollisionMesh
|
||||||
struct SLeaf : public SOctreeNode
|
struct SLeaf : public SOctreeNode
|
||||||
{
|
{
|
||||||
CAABox AABox;
|
CAABox AABox;
|
||||||
std::vector<u16> FaceIndices;
|
std::vector<uint16> FaceIndices;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SBranch : public SOctreeNode
|
struct SBranch : public SOctreeNode
|
||||||
{
|
{
|
||||||
u16 Flags;
|
uint16 Flags;
|
||||||
SOctreeNode *pChildren[8];
|
SOctreeNode *pChildren[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,29 +34,29 @@ class CCollisionMesh
|
||||||
class CCollisionVertex
|
class CCollisionVertex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
u32 MaterialIdx;
|
uint32 MaterialIdx;
|
||||||
CVector3f Pos;
|
CVector3f Pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCollisionLine
|
class CCollisionLine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
u32 MaterialIdx;
|
uint32 MaterialIdx;
|
||||||
u16 Vertices[2];
|
uint16 Vertices[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
class CCollisionFace
|
class CCollisionFace
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
u32 MaterialIdx;
|
uint32 MaterialIdx;
|
||||||
u16 Lines[3];
|
uint16 Lines[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
CVertexBuffer mVBO;
|
CVertexBuffer mVBO;
|
||||||
CIndexBuffer mIBO;
|
CIndexBuffer mIBO;
|
||||||
u32 mVertexCount;
|
uint32 mVertexCount;
|
||||||
u32 mLineCount;
|
uint32 mLineCount;
|
||||||
u32 mFaceCount;
|
uint32 mFaceCount;
|
||||||
bool mBuffered;
|
bool mBuffered;
|
||||||
|
|
||||||
CAABox mAABox;
|
CAABox mAABox;
|
||||||
|
@ -65,12 +65,12 @@ class CCollisionMesh
|
||||||
std::vector<CCollisionVertex> mCollisionVertices;
|
std::vector<CCollisionVertex> mCollisionVertices;
|
||||||
std::vector<CCollisionLine> mCollisionLines;
|
std::vector<CCollisionLine> mCollisionLines;
|
||||||
std::vector<CCollisionFace> mCollisionFaces;
|
std::vector<CCollisionFace> mCollisionFaces;
|
||||||
std::vector<u32> mMaterialOffsets;
|
std::vector<uint32> mMaterialOffsets;
|
||||||
bool mOctreeLoaded;
|
bool mOctreeLoaded;
|
||||||
|
|
||||||
CCollisionVertex *GetVertex(u16 Index);
|
CCollisionVertex *GetVertex(uint16 Index);
|
||||||
CCollisionLine *GetLine(u16 Index);
|
CCollisionLine *GetLine(uint16 Index);
|
||||||
CCollisionFace *GetFace(u16 Index);
|
CCollisionFace *GetFace(uint16 Index);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CCollisionMesh();
|
CCollisionMesh();
|
||||||
|
@ -78,12 +78,12 @@ public:
|
||||||
|
|
||||||
void BufferGL();
|
void BufferGL();
|
||||||
void Draw();
|
void Draw();
|
||||||
void DrawMaterial(u32 MatIdx, bool Wireframe);
|
void DrawMaterial(uint32 MatIdx, bool Wireframe);
|
||||||
void DrawWireframe();
|
void DrawWireframe();
|
||||||
|
|
||||||
inline u32 NumMaterials() const { return mMaterials.size(); }
|
inline uint32 NumMaterials() const { return mMaterials.size(); }
|
||||||
inline CCollisionMaterial& GetMaterial(u32 Index) { return mMaterials[Index]; }
|
inline CCollisionMaterial& GetMaterial(uint32 Index) { return mMaterials[Index]; }
|
||||||
inline const CAABox& BoundingBox() const { return mAABox; }
|
inline const CAABox& BoundingBox() const { return mAABox; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CCOLLISIONMESH_H
|
#endif // CCOLLISIONMESH_H
|
||||||
|
|
|
@ -20,9 +20,9 @@ public:
|
||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u32 NumMeshes() const { return mMeshes.size(); }
|
inline uint32 NumMeshes() const { return mMeshes.size(); }
|
||||||
inline CCollisionMesh* MeshByIndex(u32 Index) const { return mMeshes[Index]; }
|
inline CCollisionMesh* MeshByIndex(uint32 Index) const { return mMeshes[Index]; }
|
||||||
inline void AddMesh(CCollisionMesh *pMesh) { mMeshes.push_back(pMesh); }
|
inline void AddMesh(CCollisionMesh *pMesh) { mMeshes.push_back(pMesh); }
|
||||||
|
|
||||||
inline void Draw()
|
inline void Draw()
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,8 +12,8 @@ public:
|
||||||
CDependencyGroup(CResourceEntry *pEntry = 0) : CResource(pEntry) {}
|
CDependencyGroup(CResourceEntry *pEntry = 0) : CResource(pEntry) {}
|
||||||
|
|
||||||
inline void Clear() { mDependencies.clear(); }
|
inline void Clear() { mDependencies.clear(); }
|
||||||
inline u32 NumDependencies() const { return mDependencies.size(); }
|
inline uint32 NumDependencies() const { return mDependencies.size(); }
|
||||||
inline CAssetID DependencyByIndex(u32 Index) const { return mDependencies[Index]; }
|
inline CAssetID DependencyByIndex(uint32 Index) const { return mDependencies[Index]; }
|
||||||
|
|
||||||
inline void AddDependency(const CAssetID& rkID)
|
inline void AddDependency(const CAssetID& rkID)
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@ public:
|
||||||
|
|
||||||
bool HasDependency(const CAssetID &rkID) const
|
bool HasDependency(const CAssetID &rkID) const
|
||||||
{
|
{
|
||||||
for (u32 iDep = 0; iDep < mDependencies.size(); iDep++)
|
for (uint32 iDep = 0; iDep < mDependencies.size(); iDep++)
|
||||||
{
|
{
|
||||||
if (mDependencies[iDep] == rkID)
|
if (mDependencies[iDep] == rkID)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -15,7 +15,7 @@ CFont::~CFont()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float PtsToFloat(s32 Pt)
|
inline float PtsToFloat(int32 Pt)
|
||||||
{
|
{
|
||||||
// This is a bit of an arbitrary number but it works
|
// This is a bit of an arbitrary number but it works
|
||||||
// 1 / (1280 / 1.333333f / 2)
|
// 1 / (1280 / 1.333333f / 2)
|
||||||
|
@ -30,7 +30,7 @@ CDependencyTree* CFont::BuildDependencyTree() const
|
||||||
}
|
}
|
||||||
|
|
||||||
CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/, float /*AspectRatio*/,
|
CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/, float /*AspectRatio*/,
|
||||||
CVector2f /*Position*/, CColor FillColor, CColor StrokeColor, u32 FontSize)
|
CVector2f /*Position*/, CColor FillColor, CColor StrokeColor, uint32 FontSize)
|
||||||
{
|
{
|
||||||
// WIP
|
// WIP
|
||||||
if (!smBuffersInitialized) InitBuffers();
|
if (!smBuffersInitialized) InitBuffers();
|
||||||
|
@ -55,7 +55,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
||||||
if (FontSize == CFONT_DEFAULT_SIZE) Scale = 1.f;
|
if (FontSize == CFONT_DEFAULT_SIZE) Scale = 1.f;
|
||||||
else Scale = (float) FontSize / (mDefaultSize != 0 ? mDefaultSize : 18);
|
else Scale = (float) FontSize / (mDefaultSize != 0 ? mDefaultSize : 18);
|
||||||
|
|
||||||
for (u32 iChar = 0; iChar < rkString.Length(); iChar++)
|
for (uint32 iChar = 0; iChar < rkString.Length(); iChar++)
|
||||||
{
|
{
|
||||||
// Get character, check for newline
|
// Get character, check for newline
|
||||||
char Char = rkString[iChar];
|
char Char = rkString[iChar];
|
||||||
|
@ -80,7 +80,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
||||||
{
|
{
|
||||||
if (pPrevGlyph->KerningIndex != -1)
|
if (pPrevGlyph->KerningIndex != -1)
|
||||||
{
|
{
|
||||||
for (u32 iKern = pPrevGlyph->KerningIndex; iKern < mKerningTable.size(); iKern++)
|
for (uint32 iKern = pPrevGlyph->KerningIndex; iKern < mKerningTable.size(); iKern++)
|
||||||
{
|
{
|
||||||
if (mKerningTable[iKern].CharacterA != pPrevGlyph->Character) break;
|
if (mKerningTable[iKern].CharacterA != pPrevGlyph->Character) break;
|
||||||
if (mKerningTable[iKern].CharacterB == rkString[iChar])
|
if (mKerningTable[iKern].CharacterB == rkString[iChar])
|
||||||
|
@ -110,7 +110,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
||||||
GlyphTransform.Translate(CVector3f(XTrans, YTrans, 0.f));
|
GlyphTransform.Translate(CVector3f(XTrans, YTrans, 0.f));
|
||||||
|
|
||||||
// Get glyph layer
|
// Get glyph layer
|
||||||
u8 GlyphLayer = pGlyph->RGBAChannel;
|
uint8 GlyphLayer = pGlyph->RGBAChannel;
|
||||||
if (mTextureFormat == 3) GlyphLayer *= 2;
|
if (mTextureFormat == 3) GlyphLayer *= 2;
|
||||||
else if (mTextureFormat == 8) GlyphLayer = 3;
|
else if (mTextureFormat == 8) GlyphLayer = 3;
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
||||||
// Draw stroke
|
// Draw stroke
|
||||||
if ((mTextureFormat == 1) || (mTextureFormat == 3) || (mTextureFormat == 8))
|
if ((mTextureFormat == 1) || (mTextureFormat == 3) || (mTextureFormat == 8))
|
||||||
{
|
{
|
||||||
u8 StrokeLayer;
|
uint8 StrokeLayer;
|
||||||
if (mTextureFormat == 1) StrokeLayer = 1;
|
if (mTextureFormat == 1) StrokeLayer = 1;
|
||||||
else if (mTextureFormat == 3) StrokeLayer = GlyphLayer + 1;
|
else if (mTextureFormat == 3) StrokeLayer = GlyphLayer + 1;
|
||||||
else if (mTextureFormat == 8) StrokeLayer = GlyphLayer - 2;
|
else if (mTextureFormat == 8) StrokeLayer = GlyphLayer - 2;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "Core/Resource/Model/CVertex.h"
|
#include "Core/Resource/Model/CVertex.h"
|
||||||
#include "Core/OpenGL/CDynamicVertexBuffer.h"
|
#include "Core/OpenGL/CDynamicVertexBuffer.h"
|
||||||
#include "Core/OpenGL/CIndexBuffer.h"
|
#include "Core/OpenGL/CIndexBuffer.h"
|
||||||
#include <Common/types.h>
|
#include <Common/BasicTypes.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
@ -24,35 +24,35 @@ class CFont : public CResource
|
||||||
static CIndexBuffer smGlyphIndices; // This is the index buffer used to draw glyphs. It uses a triangle strip.
|
static CIndexBuffer smGlyphIndices; // This is the index buffer used to draw glyphs. It uses a triangle strip.
|
||||||
static bool smBuffersInitialized; // This bool indicates whether the vertex/index buffer have been initialized. Checked at the start of RenderString().
|
static bool smBuffersInitialized; // This bool indicates whether the vertex/index buffer have been initialized. Checked at the start of RenderString().
|
||||||
|
|
||||||
u32 mUnknown; // Value at offset 0x8. Not sure what this is. Including for experimentation purposes.
|
uint32 mUnknown; // Value at offset 0x8. Not sure what this is. Including for experimentation purposes.
|
||||||
u32 mLineHeight; // Height of each line, in points
|
uint32 mLineHeight; // Height of each line, in points
|
||||||
u32 mLineMargin; // Gap between lines, in points - this is added to the line height
|
uint32 mLineMargin; // Gap between lines, in points - this is added to the line height
|
||||||
u32 mVerticalOffset; // In points. This is used to reposition glyphs after the per-glyph vertical offset is applied
|
uint32 mVerticalOffset; // In points. This is used to reposition glyphs after the per-glyph vertical offset is applied
|
||||||
u32 mDefaultSize; // In points.
|
uint32 mDefaultSize; // In points.
|
||||||
TString mFontName; // Self-explanatory
|
TString mFontName; // Self-explanatory
|
||||||
TResPtr<CTexture> mpFontTexture; // The texture used by this font
|
TResPtr<CTexture> mpFontTexture; // The texture used by this font
|
||||||
u32 mTextureFormat; // Indicates which layers on the texture are for what - multiple glyph layers or fill/stroke
|
uint32 mTextureFormat; // Indicates which layers on the texture are for what - multiple glyph layers or fill/stroke
|
||||||
|
|
||||||
struct SGlyph
|
struct SGlyph
|
||||||
{
|
{
|
||||||
u16 Character; // The UTF-16 character that this glyph corresponds to
|
uint16 Character; // The UTF-16 character that this glyph corresponds to
|
||||||
CVector2f TexCoords[4]; // The format only lists the min/max X/Y values; tracking absolute coordinates in memory is faster
|
CVector2f TexCoords[4]; // The format only lists the min/max X/Y values; tracking absolute coordinates in memory is faster
|
||||||
s32 LeftPadding; // The amount of padding applied left of this glyph, in points
|
int32 LeftPadding; // The amount of padding applied left of this glyph, in points
|
||||||
s32 RightPadding; // The amount of padding applied right of this glyph, in points
|
int32 RightPadding; // The amount of padding applied right of this glyph, in points
|
||||||
u32 Width; // The width of the glyph, in points
|
uint32 Width; // The width of the glyph, in points
|
||||||
u32 Height; // The height of the glyph, in points
|
uint32 Height; // The height of the glyph, in points
|
||||||
u32 PrintAdvance; // How far the print head advances horizontally after printing this glyph, in points
|
uint32 PrintAdvance; // How far the print head advances horizontally after printing this glyph, in points
|
||||||
u32 BaseOffset; // Vertical offset for this glyph, in points; the font-wide offset is added to this
|
uint32 BaseOffset; // Vertical offset for this glyph, in points; the font-wide offset is added to this
|
||||||
u32 KerningIndex; // Index into the kerning table of the first kerning pair for this glyph. -1 if no pairs.
|
uint32 KerningIndex; // Index into the kerning table of the first kerning pair for this glyph. -1 if no pairs.
|
||||||
u8 RGBAChannel; // Fonts can store multiple glyphs in the same space on different RGBA channels. This value corresponds to R, G, B, or A.
|
uint8 RGBAChannel; // Fonts can store multiple glyphs in the same space on different RGBA channels. This value corresponds to R, G, B, or A.
|
||||||
};
|
};
|
||||||
std::unordered_map<u16, SGlyph> mGlyphs;
|
std::unordered_map<uint16, SGlyph> mGlyphs;
|
||||||
|
|
||||||
struct SKerningPair
|
struct SKerningPair
|
||||||
{
|
{
|
||||||
u16 CharacterA; // Left character
|
uint16 CharacterA; // Left character
|
||||||
u16 CharacterB; // Right character
|
uint16 CharacterB; // Right character
|
||||||
s32 Adjust; // The horizontal offset to apply to CharacterB if this pair is encountered, in points
|
int32 Adjust; // The horizontal offset to apply to CharacterB if this pair is encountered, in points
|
||||||
};
|
};
|
||||||
std::vector<SKerningPair> mKerningTable; // The kerning table should be laid out in alphabetical order for the indices to work properly
|
std::vector<SKerningPair> mKerningTable; // The kerning table should be laid out in alphabetical order for the indices to work properly
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public:
|
||||||
CVector2f RenderString(const TString& rkString, CRenderer *pRenderer, float AspectRatio,
|
CVector2f RenderString(const TString& rkString, CRenderer *pRenderer, float AspectRatio,
|
||||||
CVector2f Position = CVector2f(0,0),
|
CVector2f Position = CVector2f(0,0),
|
||||||
CColor FillColor = CColor::skWhite, CColor StrokeColor = CColor::skBlack,
|
CColor FillColor = CColor::skWhite, CColor StrokeColor = CColor::skBlack,
|
||||||
u32 FontSize = CFONT_DEFAULT_SIZE);
|
uint32 FontSize = CFONT_DEFAULT_SIZE);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline TString FontName() const { return mFontName; }
|
inline TString FontName() const { return mFontName; }
|
||||||
|
|
|
@ -177,7 +177,7 @@ CStructProperty* CLight::GetProperties() const
|
||||||
// ************ OTHER ************
|
// ************ OTHER ************
|
||||||
void CLight::Load() const
|
void CLight::Load() const
|
||||||
{
|
{
|
||||||
u8 Index = (u8) CGraphics::sNumLights;
|
uint8 Index = (uint8) CGraphics::sNumLights;
|
||||||
if (Index >= 8) return;
|
if (Index >= 8) return;
|
||||||
|
|
||||||
CGraphics::SLightBlock::SGXLight *pLight = &CGraphics::sLightBlock.Lights[Index];
|
CGraphics::SLightBlock::SGXLight *pLight = &CGraphics::sLightBlock.Lights[Index];
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "Core/Resource/Script/Property/Properties.h"
|
#include "Core/Resource/Script/Property/Properties.h"
|
||||||
#include <Common/CColor.h>
|
#include <Common/CColor.h>
|
||||||
#include <Common/FileIO/IInputStream.h>
|
#include <Common/FileIO/IInputStream.h>
|
||||||
#include <Math/CVector3f.h>
|
#include <Common/Math/CVector3f.h>
|
||||||
|
|
||||||
/* CLight is currently heavily based on the lights system from Metroid Prime,
|
/* CLight is currently heavily based on the lights system from Metroid Prime,
|
||||||
* including code reverse engineered from the game's executable. Not yet sure
|
* including code reverse engineered from the game's executable. Not yet sure
|
||||||
|
@ -20,7 +20,7 @@ enum ELightType
|
||||||
class CLight
|
class CLight
|
||||||
{
|
{
|
||||||
ELightType mType;
|
ELightType mType;
|
||||||
u32 mLayerIndex;
|
uint32 mLayerIndex;
|
||||||
CVector3f mPosition;
|
CVector3f mPosition;
|
||||||
CVector3f mDirection;
|
CVector3f mDirection;
|
||||||
CColor mColor;
|
CColor mColor;
|
||||||
|
@ -30,7 +30,7 @@ class CLight
|
||||||
|
|
||||||
mutable float mCachedRadius;
|
mutable float mCachedRadius;
|
||||||
mutable float mCachedIntensity;
|
mutable float mCachedIntensity;
|
||||||
mutable u8 mDirtyFlags;
|
mutable uint8 mDirtyFlags;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CLight();
|
CLight();
|
||||||
|
@ -44,14 +44,14 @@ private:
|
||||||
public:
|
public:
|
||||||
// Accessors
|
// Accessors
|
||||||
inline ELightType Type() const { return mType; }
|
inline ELightType Type() const { return mType; }
|
||||||
inline u32 LayerIndex() const { return mLayerIndex; }
|
inline uint32 LayerIndex() const { return mLayerIndex; }
|
||||||
inline CVector3f Position() const { return mPosition; }
|
inline CVector3f Position() const { return mPosition; }
|
||||||
inline CVector3f Direction() const { return mDirection; }
|
inline CVector3f Direction() const { return mDirection; }
|
||||||
inline CColor Color() const { return mColor; }
|
inline CColor Color() const { return mColor; }
|
||||||
inline CVector3f DistAttenuation() const { return mDistAttenCoefficients; }
|
inline CVector3f DistAttenuation() const { return mDistAttenCoefficients; }
|
||||||
inline CVector3f AngleAttenuation() const { return mAngleAttenCoefficients; }
|
inline CVector3f AngleAttenuation() const { return mAngleAttenCoefficients; }
|
||||||
|
|
||||||
inline void SetLayer(u32 Index) { mLayerIndex = Index; }
|
inline void SetLayer(uint32 Index) { mLayerIndex = Index; }
|
||||||
inline void SetPosition(const CVector3f& rkPosition) { mPosition = rkPosition; }
|
inline void SetPosition(const CVector3f& rkPosition) { mPosition = rkPosition; }
|
||||||
inline void SetDirection(const CVector3f& rkDirection) { mDirection = rkDirection; }
|
inline void SetDirection(const CVector3f& rkDirection) { mDirection = rkDirection; }
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <GL/glew.h>
|
#include <GL/glew.h>
|
||||||
|
|
||||||
u64 CMaterial::sCurrentMaterial = 0;
|
uint64 CMaterial::sCurrentMaterial = 0;
|
||||||
CColor CMaterial::sCurrentTint = CColor::skWhite;
|
CColor CMaterial::sCurrentTint = CColor::skWhite;
|
||||||
std::map<u64, CMaterial::SMaterialShader> CMaterial::smShaderMap;
|
std::map<uint64, CMaterial::SMaterialShader> CMaterial::smShaderMap;
|
||||||
|
|
||||||
CMaterial::CMaterial()
|
CMaterial::CMaterial()
|
||||||
: mpShader(nullptr)
|
: mpShader(nullptr)
|
||||||
|
@ -62,7 +62,7 @@ CMaterial::CMaterial(EGame Version, FVertexDescription VtxDesc)
|
||||||
|
|
||||||
CMaterial::~CMaterial()
|
CMaterial::~CMaterial()
|
||||||
{
|
{
|
||||||
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
|
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
|
||||||
delete mPasses[iPass];
|
delete mPasses[iPass];
|
||||||
|
|
||||||
ClearShader();
|
ClearShader();
|
||||||
|
@ -76,7 +76,7 @@ CMaterial* CMaterial::Clone()
|
||||||
pOut->mVersion = mVersion;
|
pOut->mVersion = mVersion;
|
||||||
pOut->mOptions = mOptions;
|
pOut->mOptions = mOptions;
|
||||||
pOut->mVtxDesc = mVtxDesc;
|
pOut->mVtxDesc = mVtxDesc;
|
||||||
for (u32 iKonst = 0; iKonst < 4; iKonst++)
|
for (uint32 iKonst = 0; iKonst < 4; iKonst++)
|
||||||
pOut->mKonstColors[iKonst] = mKonstColors[iKonst];
|
pOut->mKonstColors[iKonst] = mKonstColors[iKonst];
|
||||||
pOut->mBlendSrcFac = mBlendSrcFac;
|
pOut->mBlendSrcFac = mBlendSrcFac;
|
||||||
pOut->mBlendDstFac = mBlendDstFac;
|
pOut->mBlendDstFac = mBlendDstFac;
|
||||||
|
@ -86,7 +86,7 @@ CMaterial* CMaterial::Clone()
|
||||||
pOut->mpIndirectTexture = mpIndirectTexture;
|
pOut->mpIndirectTexture = mpIndirectTexture;
|
||||||
|
|
||||||
pOut->mPasses.resize(mPasses.size());
|
pOut->mPasses.resize(mPasses.size());
|
||||||
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
|
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
|
||||||
pOut->mPasses[iPass] = mPasses[iPass]->Clone(pOut);
|
pOut->mPasses[iPass] = mPasses[iPass]->Clone(pOut);
|
||||||
|
|
||||||
return pOut;
|
return pOut;
|
||||||
|
@ -193,7 +193,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
|
||||||
glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||||
|
|
||||||
// Set konst inputs
|
// Set konst inputs
|
||||||
for (u32 iKonst = 0; iKonst < 4; iKonst++)
|
for (uint32 iKonst = 0; iKonst < 4; iKonst++)
|
||||||
CGraphics::sPixelBlock.Konst[iKonst] = mKonstColors[iKonst];
|
CGraphics::sPixelBlock.Konst[iKonst] = mKonstColors[iKonst];
|
||||||
|
|
||||||
// Set color channels
|
// Set color channels
|
||||||
|
@ -205,7 +205,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
|
||||||
else glDepthMask(GL_FALSE);
|
else glDepthMask(GL_FALSE);
|
||||||
|
|
||||||
// Load uniforms
|
// Load uniforms
|
||||||
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
|
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
|
||||||
mPasses[iPass]->SetAnimCurrent(Options, iPass);
|
mPasses[iPass]->SetAnimCurrent(Options, iPass);
|
||||||
|
|
||||||
sCurrentMaterial = HashParameters();
|
sCurrentMaterial = HashParameters();
|
||||||
|
@ -214,7 +214,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
|
||||||
// If the passes are otherwise the same, update UV anims that use the model matrix
|
// If the passes are otherwise the same, update UV anims that use the model matrix
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
|
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
|
||||||
{
|
{
|
||||||
EUVAnimMode mode = mPasses[iPass]->AnimMode();
|
EUVAnimMode mode = mPasses[iPass]->AnimMode();
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up shader uniforms
|
// Set up shader uniforms
|
||||||
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
|
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
|
||||||
mPasses[iPass]->LoadTexture(iPass);
|
mPasses[iPass]->LoadTexture(iPass);
|
||||||
|
|
||||||
CShader *pShader = CShader::CurrentShader();
|
CShader *pShader = CShader::CurrentShader();
|
||||||
|
@ -239,7 +239,7 @@ bool CMaterial::SetCurrent(FRenderOptions Options)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 CMaterial::HashParameters()
|
uint64 CMaterial::HashParameters()
|
||||||
{
|
{
|
||||||
if (mRecalcHash)
|
if (mRecalcHash)
|
||||||
{
|
{
|
||||||
|
@ -255,10 +255,10 @@ u64 CMaterial::HashParameters()
|
||||||
Hash.HashLong(mEchoesUnknownA);
|
Hash.HashLong(mEchoesUnknownA);
|
||||||
Hash.HashLong(mEchoesUnknownB);
|
Hash.HashLong(mEchoesUnknownB);
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < mPasses.size(); iPass++)
|
for (uint32 iPass = 0; iPass < mPasses.size(); iPass++)
|
||||||
mPasses[iPass]->HashParameters(Hash);
|
mPasses[iPass]->HashParameters(Hash);
|
||||||
|
|
||||||
u64 NewHash = Hash.GetHash64();
|
uint64 NewHash = Hash.GetHash64();
|
||||||
|
|
||||||
if (mParametersHash != NewHash)
|
if (mParametersHash != NewHash)
|
||||||
ClearShader();
|
ClearShader();
|
||||||
|
@ -276,20 +276,20 @@ void CMaterial::Update()
|
||||||
mShaderStatus = eNoShader;
|
mShaderStatus = eNoShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMaterial::SetNumPasses(u32 NumPasses)
|
void CMaterial::SetNumPasses(uint32 NumPasses)
|
||||||
{
|
{
|
||||||
if (NumPasses < mPasses.size())
|
if (NumPasses < mPasses.size())
|
||||||
{
|
{
|
||||||
for (u32 iPass = NumPasses; iPass < mPasses.size(); iPass++)
|
for (uint32 iPass = NumPasses; iPass < mPasses.size(); iPass++)
|
||||||
delete mPasses[iPass];
|
delete mPasses[iPass];
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 OldCount = mPasses.size();
|
uint32 OldCount = mPasses.size();
|
||||||
mPasses.resize(NumPasses);
|
mPasses.resize(NumPasses);
|
||||||
|
|
||||||
if (NumPasses > OldCount)
|
if (NumPasses > OldCount)
|
||||||
{
|
{
|
||||||
for (u32 iPass = OldCount; iPass < NumPasses; iPass++)
|
for (uint32 iPass = OldCount; iPass < NumPasses; iPass++)
|
||||||
mPasses[iPass] = new CMaterialPass(this);
|
mPasses[iPass] = new CMaterialPass(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
#include "Core/Render/FRenderOptions.h"
|
#include "Core/Render/FRenderOptions.h"
|
||||||
#include "Core/OpenGL/CShader.h"
|
#include "Core/OpenGL/CShader.h"
|
||||||
|
|
||||||
|
#include <Common/BasicTypes.h>
|
||||||
#include <Common/CColor.h>
|
#include <Common/CColor.h>
|
||||||
#include <Common/EGame.h>
|
#include <Common/EGame.h>
|
||||||
#include <Common/Flags.h>
|
#include <Common/Flags.h>
|
||||||
#include <Common/types.h>
|
|
||||||
#include <Common/FileIO/IInputStream.h>
|
#include <Common/FileIO/IInputStream.h>
|
||||||
|
|
||||||
class CMaterialSet;
|
class CMaterialSet;
|
||||||
|
@ -48,14 +48,14 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
// Statics
|
// Statics
|
||||||
static u64 sCurrentMaterial; // The hash for the currently bound material
|
static uint64 sCurrentMaterial; // The hash for the currently bound material
|
||||||
static CColor sCurrentTint; // The tint for the currently bound material
|
static CColor sCurrentTint; // The tint for the currently bound material
|
||||||
|
|
||||||
// Members
|
// Members
|
||||||
TString mName; // Name of the material
|
TString mName; // Name of the material
|
||||||
CShader *mpShader; // This material's generated shader. Created with GenerateShader().
|
CShader *mpShader; // This material's generated shader. Created with GenerateShader().
|
||||||
EShaderStatus mShaderStatus; // A status variable so that PWE won't crash if a shader fails to compile.
|
EShaderStatus mShaderStatus; // A status variable so that PWE won't crash if a shader fails to compile.
|
||||||
u64 mParametersHash; // A hash of all the parameters that can identify this TEV setup.
|
uint64 mParametersHash; // A hash of all the parameters that can identify this TEV setup.
|
||||||
bool mRecalcHash; // Indicates the hash needs to be recalculated. Set true when parameters are changed.
|
bool mRecalcHash; // Indicates the hash needs to be recalculated. Set true when parameters are changed.
|
||||||
bool mEnableBloom; // Bool that toggles bloom on or off. On by default on MP3 materials, off by default on MP1 materials.
|
bool mEnableBloom; // Bool that toggles bloom on or off. On by default on MP3 materials, off by default on MP1 materials.
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@ private:
|
||||||
GLenum mBlendSrcFac; // Source blend factor
|
GLenum mBlendSrcFac; // Source blend factor
|
||||||
GLenum mBlendDstFac; // Dest blend factor
|
GLenum mBlendDstFac; // Dest blend factor
|
||||||
bool mLightingEnabled; // Color channel control flags; indicate whether lighting is enabled
|
bool mLightingEnabled; // Color channel control flags; indicate whether lighting is enabled
|
||||||
u32 mEchoesUnknownA; // First unknown value introduced in Echoes. Included for cooking.
|
uint32 mEchoesUnknownA; // First unknown value introduced in Echoes. Included for cooking.
|
||||||
u32 mEchoesUnknownB; // Second unknown value introduced in Echoes. Included for cooking.
|
uint32 mEchoesUnknownB; // Second unknown value introduced in Echoes. Included for cooking.
|
||||||
TResPtr<CTexture> mpIndirectTexture; // Optional texture used for the indirect stage for reflections
|
TResPtr<CTexture> mpIndirectTexture; // Optional texture used for the indirect stage for reflections
|
||||||
|
|
||||||
std::vector<CMaterialPass*> mPasses;
|
std::vector<CMaterialPass*> mPasses;
|
||||||
|
@ -78,7 +78,7 @@ private:
|
||||||
int NumReferences;
|
int NumReferences;
|
||||||
CShader *pShader;
|
CShader *pShader;
|
||||||
};
|
};
|
||||||
static std::map<u64, SMaterialShader> smShaderMap;
|
static std::map<uint64, SMaterialShader> smShaderMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CMaterial();
|
CMaterial();
|
||||||
|
@ -89,30 +89,30 @@ public:
|
||||||
void GenerateShader(bool AllowRegen = true);
|
void GenerateShader(bool AllowRegen = true);
|
||||||
void ClearShader();
|
void ClearShader();
|
||||||
bool SetCurrent(FRenderOptions Options);
|
bool SetCurrent(FRenderOptions Options);
|
||||||
u64 HashParameters();
|
uint64 HashParameters();
|
||||||
void Update();
|
void Update();
|
||||||
void SetNumPasses(u32 NumPasses);
|
void SetNumPasses(uint32 NumPasses);
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
inline TString Name() const { return mName; }
|
inline TString Name() const { return mName; }
|
||||||
inline EGame Version() const { return mVersion; }
|
inline EGame Version() const { return mVersion; }
|
||||||
inline FMaterialOptions Options() const { return mOptions; }
|
inline FMaterialOptions Options() const { return mOptions; }
|
||||||
inline FVertexDescription VtxDesc() const { return mVtxDesc; }
|
inline FVertexDescription VtxDesc() const { return mVtxDesc; }
|
||||||
inline GLenum BlendSrcFac() const { return mBlendSrcFac; }
|
inline GLenum BlendSrcFac() const { return mBlendSrcFac; }
|
||||||
inline GLenum BlendDstFac() const { return mBlendDstFac; }
|
inline GLenum BlendDstFac() const { return mBlendDstFac; }
|
||||||
inline CColor Konst(u32 KIndex) const { return mKonstColors[KIndex]; }
|
inline CColor Konst(uint32 KIndex) const { return mKonstColors[KIndex]; }
|
||||||
inline CTexture* IndTexture() const { return mpIndirectTexture; }
|
inline CTexture* IndTexture() const { return mpIndirectTexture; }
|
||||||
inline bool IsLightingEnabled() const { return mLightingEnabled; }
|
inline bool IsLightingEnabled() const { return mLightingEnabled; }
|
||||||
inline u32 EchoesUnknownA() const { return mEchoesUnknownA; }
|
inline uint32 EchoesUnknownA() const { return mEchoesUnknownA; }
|
||||||
inline u32 EchoesUnknownB() const { return mEchoesUnknownB; }
|
inline uint32 EchoesUnknownB() const { return mEchoesUnknownB; }
|
||||||
inline u32 PassCount() const { return mPasses.size(); }
|
inline uint32 PassCount() const { return mPasses.size(); }
|
||||||
inline CMaterialPass* Pass(u32 PassIndex) const { return mPasses[PassIndex]; }
|
inline CMaterialPass* Pass(uint32 PassIndex) const { return mPasses[PassIndex]; }
|
||||||
|
|
||||||
inline void SetName(const TString& rkName) { mName = rkName; }
|
inline void SetName(const TString& rkName) { mName = rkName; }
|
||||||
inline void SetOptions(FMaterialOptions Options) { mOptions = Options; Update(); }
|
inline void SetOptions(FMaterialOptions Options) { mOptions = Options; Update(); }
|
||||||
inline void SetVertexDescription(FVertexDescription Desc) { mVtxDesc = Desc; Update(); }
|
inline void SetVertexDescription(FVertexDescription Desc) { mVtxDesc = Desc; Update(); }
|
||||||
inline void SetBlendMode(GLenum SrcFac, GLenum DstFac) { mBlendSrcFac = SrcFac; mBlendDstFac = DstFac; mRecalcHash = true; }
|
inline void SetBlendMode(GLenum SrcFac, GLenum DstFac) { mBlendSrcFac = SrcFac; mBlendDstFac = DstFac; mRecalcHash = true; }
|
||||||
inline void SetKonst(const CColor& Konst, u32 KIndex) { mKonstColors[KIndex] = Konst; Update(); }
|
inline void SetKonst(const CColor& Konst, uint32 KIndex) { mKonstColors[KIndex] = Konst; Update(); }
|
||||||
inline void SetIndTexture(CTexture *pTex) { mpIndirectTexture = pTex; }
|
inline void SetIndTexture(CTexture *pTex) { mpIndirectTexture = pTex; }
|
||||||
inline void SetLightingEnabled(bool Enabled) { mLightingEnabled = Enabled; Update(); }
|
inline void SetLightingEnabled(bool Enabled) { mLightingEnabled = Enabled; Update(); }
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ CMaterialPass::CMaterialPass(CMaterial *pParent)
|
||||||
, mTexCoordSource(0xFF)
|
, mTexCoordSource(0xFF)
|
||||||
, mAnimMode(eNoUVAnim)
|
, mAnimMode(eNoUVAnim)
|
||||||
{
|
{
|
||||||
for (u32 iParam = 0; iParam < 4; iParam++)
|
for (uint32 iParam = 0; iParam < 4; iParam++)
|
||||||
{
|
{
|
||||||
mColorInputs[iParam] = eZeroRGB;
|
mColorInputs[iParam] = eZeroRGB;
|
||||||
mAlphaInputs[iParam] = eZeroAlpha;
|
mAlphaInputs[iParam] = eZeroAlpha;
|
||||||
|
@ -35,7 +35,7 @@ CMaterialPass* CMaterialPass::Clone(CMaterial *pParent)
|
||||||
pOut->mPassType = mPassType;
|
pOut->mPassType = mPassType;
|
||||||
pOut->mSettings = mSettings;
|
pOut->mSettings = mSettings;
|
||||||
|
|
||||||
for (u32 iIn = 0; iIn < 4; iIn++)
|
for (uint32 iIn = 0; iIn < 4; iIn++)
|
||||||
{
|
{
|
||||||
pOut->mColorInputs[iIn] = mColorInputs[iIn];
|
pOut->mColorInputs[iIn] = mColorInputs[iIn];
|
||||||
pOut->mAlphaInputs[iIn] = mAlphaInputs[iIn];
|
pOut->mAlphaInputs[iIn] = mAlphaInputs[iIn];
|
||||||
|
@ -50,7 +50,7 @@ CMaterialPass* CMaterialPass::Clone(CMaterial *pParent)
|
||||||
pOut->mpTexture = mpTexture;
|
pOut->mpTexture = mpTexture;
|
||||||
pOut->mAnimMode = mAnimMode;
|
pOut->mAnimMode = mAnimMode;
|
||||||
|
|
||||||
for (u32 iParam = 0; iParam < 4; iParam++)
|
for (uint32 iParam = 0; iParam < 4; iParam++)
|
||||||
pOut->mAnimParams[iParam] = mAnimParams[iParam];
|
pOut->mAnimParams[iParam] = mAnimParams[iParam];
|
||||||
|
|
||||||
pOut->mEnabled = mEnabled;
|
pOut->mEnabled = mEnabled;
|
||||||
|
@ -78,13 +78,13 @@ void CMaterialPass::HashParameters(CFNV1A& rHash)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMaterialPass::LoadTexture(u32 PassIndex)
|
void CMaterialPass::LoadTexture(uint32 PassIndex)
|
||||||
{
|
{
|
||||||
if (mpTexture)
|
if (mpTexture)
|
||||||
mpTexture->Bind(PassIndex);
|
mpTexture->Bind(PassIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMaterialPass::SetAnimCurrent(FRenderOptions Options, u32 PassIndex)
|
void CMaterialPass::SetAnimCurrent(FRenderOptions Options, uint32 PassIndex)
|
||||||
{
|
{
|
||||||
if (mAnimMode == eNoUVAnim) return;
|
if (mAnimMode == eNoUVAnim) return;
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ void CMaterialPass::SetRasSel(ETevRasSel Sel)
|
||||||
mpParentMat->Update();
|
mpParentMat->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMaterialPass::SetTexCoordSource(u32 Source)
|
void CMaterialPass::SetTexCoordSource(uint32 Source)
|
||||||
{
|
{
|
||||||
mTexCoordSource = Source;
|
mTexCoordSource = Source;
|
||||||
mpParentMat->Update();
|
mpParentMat->Update();
|
||||||
|
@ -286,7 +286,7 @@ void CMaterialPass::SetAnimMode(EUVAnimMode Mode)
|
||||||
mpParentMat->Update();
|
mpParentMat->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMaterialPass::SetAnimParam(u32 ParamIndex, float Value)
|
void CMaterialPass::SetAnimParam(uint32 ParamIndex, float Value)
|
||||||
{
|
{
|
||||||
mAnimParams[ParamIndex] = Value;
|
mAnimParams[ParamIndex] = Value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ private:
|
||||||
ETevKSel mKColorSel;
|
ETevKSel mKColorSel;
|
||||||
ETevKSel mKAlphaSel;
|
ETevKSel mKAlphaSel;
|
||||||
ETevRasSel mRasSel;
|
ETevRasSel mRasSel;
|
||||||
u32 mTexCoordSource; // Should maybe be an enum but worried about conflicts with EVertexDescriptionn
|
uint32 mTexCoordSource; // Should maybe be an enum but worried about conflicts with EVertexDescriptionn
|
||||||
TResPtr<CTexture> mpTexture;
|
TResPtr<CTexture> mpTexture;
|
||||||
EUVAnimMode mAnimMode;
|
EUVAnimMode mAnimMode;
|
||||||
float mAnimParams[4];
|
float mAnimParams[4];
|
||||||
|
@ -46,8 +46,8 @@ public:
|
||||||
~CMaterialPass();
|
~CMaterialPass();
|
||||||
CMaterialPass* Clone(CMaterial *pParent);
|
CMaterialPass* Clone(CMaterial *pParent);
|
||||||
void HashParameters(CFNV1A& rHash);
|
void HashParameters(CFNV1A& rHash);
|
||||||
void LoadTexture(u32 PassIndex);
|
void LoadTexture(uint32 PassIndex);
|
||||||
void SetAnimCurrent(FRenderOptions Options, u32 PassIndex);
|
void SetAnimCurrent(FRenderOptions Options, uint32 PassIndex);
|
||||||
|
|
||||||
// Setters
|
// Setters
|
||||||
void SetType(CFourCC Type);
|
void SetType(CFourCC Type);
|
||||||
|
@ -58,27 +58,27 @@ public:
|
||||||
void SetKColorSel(ETevKSel Sel);
|
void SetKColorSel(ETevKSel Sel);
|
||||||
void SetKAlphaSel(ETevKSel Sel);
|
void SetKAlphaSel(ETevKSel Sel);
|
||||||
void SetRasSel(ETevRasSel Sel);
|
void SetRasSel(ETevRasSel Sel);
|
||||||
void SetTexCoordSource(u32 Source);
|
void SetTexCoordSource(uint32 Source);
|
||||||
void SetTexture(CTexture *pTex);
|
void SetTexture(CTexture *pTex);
|
||||||
void SetAnimMode(EUVAnimMode Mode);
|
void SetAnimMode(EUVAnimMode Mode);
|
||||||
void SetAnimParam(u32 ParamIndex, float Value);
|
void SetAnimParam(uint32 ParamIndex, float Value);
|
||||||
void SetEnabled(bool Enabled);
|
void SetEnabled(bool Enabled);
|
||||||
|
|
||||||
// Getters
|
// Getters
|
||||||
inline CFourCC Type() const { return mPassType; }
|
inline CFourCC Type() const { return mPassType; }
|
||||||
inline TString NamedType() const { return PassTypeName(mPassType); }
|
inline TString NamedType() const { return PassTypeName(mPassType); }
|
||||||
inline ETevColorInput ColorInput(u32 Input) const { return mColorInputs[Input]; }
|
inline ETevColorInput ColorInput(uint32 Input) const { return mColorInputs[Input]; }
|
||||||
inline ETevAlphaInput AlphaInput(u32 Input) const { return mAlphaInputs[Input]; }
|
inline ETevAlphaInput AlphaInput(uint32 Input) const { return mAlphaInputs[Input]; }
|
||||||
inline ETevOutput ColorOutput() const { return mColorOutput; }
|
inline ETevOutput ColorOutput() const { return mColorOutput; }
|
||||||
inline ETevOutput AlphaOutput() const { return mAlphaOutput; }
|
inline ETevOutput AlphaOutput() const { return mAlphaOutput; }
|
||||||
inline ETevKSel KColorSel() const { return mKColorSel; }
|
inline ETevKSel KColorSel() const { return mKColorSel; }
|
||||||
inline ETevKSel KAlphaSel() const { return mKAlphaSel; }
|
inline ETevKSel KAlphaSel() const { return mKAlphaSel; }
|
||||||
inline ETevRasSel RasSel() const { return mRasSel; }
|
inline ETevRasSel RasSel() const { return mRasSel; }
|
||||||
inline u32 TexCoordSource() const { return mTexCoordSource; }
|
inline uint32 TexCoordSource() const { return mTexCoordSource; }
|
||||||
inline CTexture* Texture() const { return mpTexture; }
|
inline CTexture* Texture() const { return mpTexture; }
|
||||||
inline EUVAnimMode AnimMode() const { return mAnimMode; }
|
inline EUVAnimMode AnimMode() const { return mAnimMode; }
|
||||||
inline float AnimParam(u32 ParamIndex) const { return mAnimParams[ParamIndex]; }
|
inline float AnimParam(uint32 ParamIndex) const { return mAnimParams[ParamIndex]; }
|
||||||
inline bool IsEnabled() const { return mEnabled; }
|
inline bool IsEnabled() const { return mEnabled; }
|
||||||
|
|
||||||
// Static
|
// Static
|
||||||
static TString PassTypeName(CFourCC Type);
|
static TString PassTypeName(CFourCC Type);
|
||||||
|
|
|
@ -18,7 +18,7 @@ public:
|
||||||
|
|
||||||
~CMaterialSet()
|
~CMaterialSet()
|
||||||
{
|
{
|
||||||
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
for (uint32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
||||||
delete mMaterials[iMat];
|
delete mMaterials[iMat];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,18 +27,18 @@ public:
|
||||||
CMaterialSet *pOut = new CMaterialSet();
|
CMaterialSet *pOut = new CMaterialSet();
|
||||||
|
|
||||||
pOut->mMaterials.resize(mMaterials.size());
|
pOut->mMaterials.resize(mMaterials.size());
|
||||||
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
for (uint32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
||||||
pOut->mMaterials[iMat] = mMaterials[iMat]->Clone();
|
pOut->mMaterials[iMat] = mMaterials[iMat]->Clone();
|
||||||
|
|
||||||
return pOut;
|
return pOut;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 NumMaterials()
|
uint32 NumMaterials()
|
||||||
{
|
{
|
||||||
return mMaterials.size();
|
return mMaterials.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
CMaterial* MaterialByIndex(u32 Index)
|
CMaterial* MaterialByIndex(uint32 Index)
|
||||||
{
|
{
|
||||||
if (Index >= NumMaterials()) return nullptr;
|
if (Index >= NumMaterials()) return nullptr;
|
||||||
return mMaterials[Index];
|
return mMaterials[Index];
|
||||||
|
@ -52,9 +52,9 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 MaterialIndexByName(const TString& rkName)
|
uint32 MaterialIndexByName(const TString& rkName)
|
||||||
{
|
{
|
||||||
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
for (uint32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
||||||
if (mMaterials[iMat]->Name() == rkName) return iMat;
|
if (mMaterials[iMat]->Name() == rkName) return iMat;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -62,12 +62,12 @@ public:
|
||||||
|
|
||||||
void GetUsedTextureIDs(std::set<CAssetID>& rOut)
|
void GetUsedTextureIDs(std::set<CAssetID>& rOut)
|
||||||
{
|
{
|
||||||
for (u32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
for (uint32 iMat = 0; iMat < mMaterials.size(); iMat++)
|
||||||
{
|
{
|
||||||
CMaterial *pMat = mMaterials[iMat];
|
CMaterial *pMat = mMaterials[iMat];
|
||||||
if (pMat->IndTexture()) rOut.insert(pMat->IndTexture()->ID());
|
if (pMat->IndTexture()) rOut.insert(pMat->IndTexture()->ID());
|
||||||
|
|
||||||
for (u32 iPass = 0; iPass < pMat->PassCount(); iPass++)
|
for (uint32 iPass = 0; iPass < pMat->PassCount(); iPass++)
|
||||||
{
|
{
|
||||||
CTexture *pTex = pMat->Pass(iPass)->Texture();
|
CTexture *pTex = pMat->Pass(iPass)->Texture();
|
||||||
if (pTex) rOut.insert(pTex->ID());
|
if (pTex) rOut.insert(pTex->ID());
|
||||||
|
|
|
@ -11,7 +11,7 @@ CPoiToWorld::~CPoiToWorld()
|
||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiToWorld::AddPoi(u32 PoiID)
|
void CPoiToWorld::AddPoi(uint32 PoiID)
|
||||||
{
|
{
|
||||||
// Check if this POI already exists
|
// Check if this POI already exists
|
||||||
auto it = mPoiLookupMap.find(PoiID);
|
auto it = mPoiLookupMap.find(PoiID);
|
||||||
|
@ -26,7 +26,7 @@ void CPoiToWorld::AddPoi(u32 PoiID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiToWorld::AddPoiMeshMap(u32 PoiID, u32 ModelID)
|
void CPoiToWorld::AddPoiMeshMap(uint32 PoiID, uint32 ModelID)
|
||||||
{
|
{
|
||||||
// Make sure the POI exists; the add function won't do anything if it does
|
// Make sure the POI exists; the add function won't do anything if it does
|
||||||
AddPoi(PoiID);
|
AddPoi(PoiID);
|
||||||
|
@ -43,7 +43,7 @@ void CPoiToWorld::AddPoiMeshMap(u32 PoiID, u32 ModelID)
|
||||||
pMap->ModelIDs.push_back(ModelID);
|
pMap->ModelIDs.push_back(ModelID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiToWorld::RemovePoi(u32 PoiID)
|
void CPoiToWorld::RemovePoi(uint32 PoiID)
|
||||||
{
|
{
|
||||||
for (auto it = mMaps.begin(); it != mMaps.end(); it++)
|
for (auto it = mMaps.begin(); it != mMaps.end(); it++)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ void CPoiToWorld::RemovePoi(u32 PoiID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPoiToWorld::RemovePoiMeshMap(u32 PoiID, u32 ModelID)
|
void CPoiToWorld::RemovePoiMeshMap(uint32 PoiID, uint32 ModelID)
|
||||||
{
|
{
|
||||||
auto MapIt = mPoiLookupMap.find(PoiID);
|
auto MapIt = mPoiLookupMap.find(PoiID);
|
||||||
|
|
||||||
|
|
|
@ -13,34 +13,34 @@ class CPoiToWorld : public CResource
|
||||||
public:
|
public:
|
||||||
struct SPoiMap
|
struct SPoiMap
|
||||||
{
|
{
|
||||||
u32 PoiID;
|
uint32 PoiID;
|
||||||
std::list<u32> ModelIDs;
|
std::list<uint32> ModelIDs;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<SPoiMap*> mMaps;
|
std::vector<SPoiMap*> mMaps;
|
||||||
std::map<u32,SPoiMap*> mPoiLookupMap;
|
std::map<uint32,SPoiMap*> mPoiLookupMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CPoiToWorld(CResourceEntry *pEntry = 0);
|
CPoiToWorld(CResourceEntry *pEntry = 0);
|
||||||
~CPoiToWorld();
|
~CPoiToWorld();
|
||||||
|
|
||||||
void AddPoi(u32 PoiID);
|
void AddPoi(uint32 PoiID);
|
||||||
void AddPoiMeshMap(u32 PoiID, u32 ModelID);
|
void AddPoiMeshMap(uint32 PoiID, uint32 ModelID);
|
||||||
void RemovePoi(u32 PoiID);
|
void RemovePoi(uint32 PoiID);
|
||||||
void RemovePoiMeshMap(u32 PoiID, u32 ModelID);
|
void RemovePoiMeshMap(uint32 PoiID, uint32 ModelID);
|
||||||
|
|
||||||
inline u32 NumMappedPOIs() const
|
inline uint32 NumMappedPOIs() const
|
||||||
{
|
{
|
||||||
return mMaps.size();
|
return mMaps.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const SPoiMap* MapByIndex(u32 Index) const
|
inline const SPoiMap* MapByIndex(uint32 Index) const
|
||||||
{
|
{
|
||||||
return mMaps[Index];
|
return mMaps[Index];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const SPoiMap* MapByID(u32 InstanceID) const
|
inline const SPoiMap* MapByID(uint32 InstanceID) const
|
||||||
{
|
{
|
||||||
auto it = mPoiLookupMap.find(InstanceID);
|
auto it = mPoiLookupMap.find(InstanceID);
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasPoiMappings(u32 InstanceID) const
|
bool HasPoiMappings(uint32 InstanceID) const
|
||||||
{
|
{
|
||||||
auto it = mPoiLookupMap.find(InstanceID);
|
auto it = mPoiLookupMap.find(InstanceID);
|
||||||
return (it != mPoiLookupMap.end());
|
return (it != mPoiLookupMap.end());
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "CResTypeInfo.h"
|
#include "CResTypeInfo.h"
|
||||||
#include <Common/AssertMacro.h>
|
#include <Common/Macros.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
std::unordered_map<EResType, CResTypeInfo*> CResTypeInfo::smTypeMap;
|
std::unordered_map<EResType, CResTypeInfo*> CResTypeInfo::smTypeMap;
|
||||||
|
@ -19,7 +19,7 @@ CResTypeInfo::CResTypeInfo(EResType Type, const TString& rkTypeName, const TStri
|
||||||
|
|
||||||
bool CResTypeInfo::IsInGame(EGame Game) const
|
bool CResTypeInfo::IsInGame(EGame Game) const
|
||||||
{
|
{
|
||||||
for (u32 iGame = 0; iGame < mCookedExtensions.size(); iGame++)
|
for (uint32 iGame = 0; iGame < mCookedExtensions.size(); iGame++)
|
||||||
{
|
{
|
||||||
if (mCookedExtensions[iGame].Game == Game)
|
if (mCookedExtensions[iGame].Game == Game)
|
||||||
return true;
|
return true;
|
||||||
|
@ -33,7 +33,7 @@ CFourCC CResTypeInfo::CookedExtension(EGame Game) const
|
||||||
if (Game == EGame::Invalid)
|
if (Game == EGame::Invalid)
|
||||||
Game = EGame::Prime;
|
Game = EGame::Prime;
|
||||||
|
|
||||||
for (u32 iGame = 0; iGame < mCookedExtensions.size(); iGame++)
|
for (uint32 iGame = 0; iGame < mCookedExtensions.size(); iGame++)
|
||||||
{
|
{
|
||||||
if (mCookedExtensions[iGame].Game == Game)
|
if (mCookedExtensions[iGame].Game == Game)
|
||||||
return mCookedExtensions[iGame].CookedExt;
|
return mCookedExtensions[iGame].CookedExt;
|
||||||
|
@ -90,7 +90,7 @@ CResTypeInfo* CResTypeInfo::TypeForCookedExtension(EGame Game, CFourCC Ext)
|
||||||
// Note UNKN is used to indicate unknown asset type
|
// Note UNKN is used to indicate unknown asset type
|
||||||
if (Ext != FOURCC('UNKN'))
|
if (Ext != FOURCC('UNKN'))
|
||||||
{
|
{
|
||||||
Log::Error("Failed to find resource type for cooked extension: " + Ext.ToString());
|
errorf("Failed to find resource type for cooked extension: %s", *Ext.ToString());
|
||||||
DEBUG_BREAK;
|
DEBUG_BREAK;
|
||||||
}
|
}
|
||||||
sCachedTypeMap[Ext] = nullptr;
|
sCachedTypeMap[Ext] = nullptr;
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "Core/GameProject/CResourceStore.h"
|
#include "Core/GameProject/CResourceStore.h"
|
||||||
#include <Common/CAssetID.h>
|
#include <Common/CAssetID.h>
|
||||||
#include <Common/CFourCC.h>
|
#include <Common/CFourCC.h>
|
||||||
#include <Common/types.h>
|
|
||||||
#include <Common/TString.h>
|
#include <Common/TString.h>
|
||||||
#include <Common/Serialization/IArchive.h>
|
#include <Common/Serialization/IArchive.h>
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue