mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-21 02:39:17 +00:00
Linux build fixes
This commit is contained in:
@@ -10,7 +10,10 @@ find_package(logvisor CONFIG REQUIRED)
|
||||
find_package(lzokay CONFIG REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_package(assimp CONFIG REQUIRED)
|
||||
find_package(zlib REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
|
||||
# AssImp's cmake config is pretty awful. It doesn't include necesary libraries. Hopefully this can be fixed later.
|
||||
find_library(IIRXML_LIBRARY NAMES IrrXMLd IrrXML)
|
||||
|
||||
include(codegen)
|
||||
|
||||
@@ -41,6 +44,7 @@ target_link_libraries(
|
||||
OpenGL::GL
|
||||
codegen::codegen
|
||||
assimp::assimp
|
||||
${IIRXML_LIBRARY}
|
||||
${ZLIB_LIBRARY}
|
||||
)
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ void CAssetNameMap::PostLoadValidate()
|
||||
|
||||
for (auto Iter = Dupes.begin(); Iter != Dupes.end(); Iter++)
|
||||
{
|
||||
warnf("\t%s", Iter->FullPath());
|
||||
warnf("\t%s", *Iter->FullPath());
|
||||
}
|
||||
|
||||
mMap.clear();
|
||||
@@ -195,7 +195,7 @@ TString CAssetNameMap::DefaultNameMapPath(EIDLength IDLength)
|
||||
{
|
||||
ASSERT(IDLength != kInvalidIDLength);
|
||||
TString Suffix = (IDLength == k32Bit ? "32" : "64");
|
||||
return gkAssetMapPath + Suffix + "." + gkAssetMapExt;
|
||||
return gDataDir + gkAssetMapPath + Suffix + "." + gkAssetMapExt;
|
||||
}
|
||||
|
||||
TString CAssetNameMap::DefaultNameMapPath(EGame Game)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
const TString gkAssetMapPath = "../resources/gameinfo/AssetNameMap";
|
||||
const TString gkAssetMapPath = "resources/gameinfo/AssetNameMap";
|
||||
const TString gkAssetMapExt = "xml";
|
||||
|
||||
class CAssetNameMap
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
#define USE_ASSET_NAME_MAP 1
|
||||
#define EXPORT_COOKED 1
|
||||
|
||||
#if NOD_UCS2
|
||||
static nod::SystemStringView TStringToNodString(const TString& string) { return ToWChar(string); }
|
||||
#else
|
||||
static nod::SystemStringView TStringToNodString(const TString& string) { return *string; }
|
||||
#endif
|
||||
|
||||
CGameExporter::CGameExporter(EDiscType DiscType, EGame Game, bool FrontEnd, ERegion Region, const TString& rkGameName, const TString& rkGameID, float BuildVersion)
|
||||
: mGame(Game)
|
||||
, mRegion(Region)
|
||||
@@ -198,16 +204,16 @@ bool CGameExporter::ExtractDiscData()
|
||||
if (IsWii)
|
||||
{
|
||||
// Extract crypto files
|
||||
if (!pDataPartition->extractCryptoFiles(ToWChar(AbsDiscDir), Context))
|
||||
if (!pDataPartition->extractCryptoFiles(TStringToNodString(AbsDiscDir), Context))
|
||||
return false;
|
||||
|
||||
// Extract disc header files
|
||||
if (!mpDisc->extractDiscHeaderFiles(ToWChar(AbsDiscDir), Context))
|
||||
if (!mpDisc->extractDiscHeaderFiles(TStringToNodString(AbsDiscDir), Context))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extract system files
|
||||
if (!pDataPartition->extractSysFiles(ToWChar(AbsDiscDir), Context))
|
||||
if (!pDataPartition->extractSysFiles(TStringToNodString(AbsDiscDir), Context))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
@@ -226,7 +232,7 @@ bool CGameExporter::ExtractDiscNodeRecursive(const nod::Node *pkNode, const TStr
|
||||
if (Iter->getKind() == nod::Node::Kind::File)
|
||||
{
|
||||
TString FilePath = rkDir + Iter->getName().data();
|
||||
bool Success = Iter->extractToDirectory(ToWChar(rkDir), rkContext);
|
||||
bool Success = Iter->extractToDirectory(TStringToNodString(rkDir), rkContext);
|
||||
if (!Success) return false;
|
||||
|
||||
if (FilePath.GetFileExtension().CaseInsensitiveCompare("pak"))
|
||||
|
||||
@@ -63,6 +63,7 @@ class CGameExporter
|
||||
// Progress
|
||||
IProgressNotifier *mpProgress;
|
||||
|
||||
public:
|
||||
enum EExportStep
|
||||
{
|
||||
eES_ExtractDisc,
|
||||
@@ -72,7 +73,6 @@ class CGameExporter
|
||||
eES_NumSteps
|
||||
};
|
||||
|
||||
public:
|
||||
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);
|
||||
void LoadResource(const CAssetID& rkID, std::vector<uint8>& rBuffer);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "CGameInfo.h"
|
||||
#include "CResourceStore.h"
|
||||
#include <Common/FileUtil.h>
|
||||
|
||||
bool CGameInfo::LoadGameInfo(EGame Game)
|
||||
@@ -83,5 +84,5 @@ TString CGameInfo::GetDefaultGameInfoPath(EGame Game)
|
||||
return "";
|
||||
|
||||
TString GameName = GetGameShortName(Game);
|
||||
return TString::Format("%s/GameInfo%s.%s", *gkGameInfoDir, *GameName, *gkGameInfoExt);
|
||||
return TString::Format("%s/%s/GameInfo%s.%s", *gDataDir, *gkGameInfoDir, *GameName, *gkGameInfoExt);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <Common/Serialization/XML.h>
|
||||
#include <map>
|
||||
|
||||
const TString gkGameInfoDir = "../resources/gameinfo";
|
||||
const TString gkGameInfoDir = "resources/gameinfo";
|
||||
const TString gkGameInfoExt = "xml";
|
||||
|
||||
//@todo merge this class into CGameTemplate
|
||||
|
||||
@@ -5,6 +5,12 @@
|
||||
#include <Common/Serialization/XML.h>
|
||||
#include <nod/nod.hpp>
|
||||
|
||||
#if NOD_UCS2
|
||||
static nod::SystemStringView TStringToNodString(const TString& string) { return ToWChar(string); }
|
||||
#else
|
||||
static nod::SystemStringView TStringToNodString(const TString& string) { return *string; }
|
||||
#endif
|
||||
|
||||
CGameProject::~CGameProject()
|
||||
{
|
||||
if (mpResourceStore)
|
||||
@@ -88,13 +94,13 @@ bool CGameProject::BuildISO(const TString& rkIsoPath, IProgressNotifier *pProgre
|
||||
|
||||
if (!IsWiiBuild())
|
||||
{
|
||||
nod::DiscBuilderGCN Builder(ToWChar(rkIsoPath), ProgressCallback);
|
||||
return Builder.buildFromDirectory(ToWChar(DiscRoot)) == nod::EBuildResult::Success;
|
||||
nod::DiscBuilderGCN Builder(TStringToNodString(rkIsoPath), ProgressCallback);
|
||||
return Builder.buildFromDirectory(TStringToNodString(DiscRoot)) == nod::EBuildResult::Success;
|
||||
}
|
||||
else
|
||||
{
|
||||
nod::DiscBuilderWii Builder(ToWChar(rkIsoPath), IsTrilogy(), ProgressCallback);
|
||||
return Builder.buildFromDirectory(ToWChar(DiscRoot)) == nod::EBuildResult::Success;
|
||||
nod::DiscBuilderWii Builder(TStringToNodString(rkIsoPath), IsTrilogy(), ProgressCallback);
|
||||
return Builder.buildFromDirectory(TStringToNodString(DiscRoot)) == nod::EBuildResult::Success;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,8 +119,8 @@ bool CGameProject::MergeISO(const TString& rkIsoPath, nod::DiscWii *pOriginalIso
|
||||
|
||||
TString DiscRoot = DiscFilesystemRoot(false);
|
||||
|
||||
nod::DiscMergerWii Merger(ToWChar(rkIsoPath), *pOriginalIso, IsTrilogy(), ProgressCallback);
|
||||
return Merger.mergeFromDirectory(ToWChar(DiscRoot)) == nod::EBuildResult::Success;
|
||||
nod::DiscMergerWii Merger(TStringToNodString(rkIsoPath), *pOriginalIso, IsTrilogy(), ProgressCallback);
|
||||
return Merger.mergeFromDirectory(TStringToNodString(DiscRoot)) == nod::EBuildResult::Success;
|
||||
}
|
||||
|
||||
void CGameProject::GetWorldList(std::list<CAssetID>& rOut) const
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <tinyxml2.h>
|
||||
|
||||
using namespace tinyxml2;
|
||||
TString gDataDir;
|
||||
CResourceStore *gpResourceStore = nullptr;
|
||||
CResourceStore *gpEditorStore = nullptr;
|
||||
|
||||
@@ -607,6 +608,19 @@ bool CResourceStore::DeleteResourceEntry(CResourceEntry *pEntry)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
static int wrap_fopen(FILE** pFile, const char *filename, const char *mode)
|
||||
{
|
||||
return fopen_s(pFile, filename, mode);
|
||||
}
|
||||
#else
|
||||
static int wrap_fopen(FILE** pFile, const char *filename, const char *mode)
|
||||
{
|
||||
*pFile = fopen(filename, mode);
|
||||
return *pFile == nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, bool UnnamedOnly)
|
||||
{
|
||||
// Read file contents -first- then move assets -after-; this
|
||||
@@ -615,7 +629,7 @@ void CResourceStore::ImportNamesFromPakContentsTxt(const TString& rkTxtPath, boo
|
||||
// todo: move to CAssetNameMap?
|
||||
std::map<CResourceEntry*, TString> PathMap;
|
||||
FILE *pContentsFile;
|
||||
fopen_s(&pContentsFile, *rkTxtPath, "r");
|
||||
wrap_fopen(&pContentsFile, *rkTxtPath, "r");
|
||||
|
||||
if (!pContentsFile)
|
||||
{
|
||||
|
||||
@@ -93,6 +93,7 @@ public:
|
||||
inline bool IsEditorStore() const { return mpProj == nullptr; }
|
||||
};
|
||||
|
||||
extern TString gDataDir;
|
||||
extern CResourceStore *gpResourceStore;
|
||||
extern CResourceStore *gpEditorStore;
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ TString CVirtualDirectory::FullPath() const
|
||||
if (IsRoot())
|
||||
return "";
|
||||
else
|
||||
return (mpParent ? mpParent->FullPath() + mName : mName) + '/';
|
||||
return (mpParent ? mpParent->FullPath() + mName : static_cast<TString::BaseClass>(mName)) + '/';
|
||||
}
|
||||
|
||||
TString CVirtualDirectory::AbsolutePath() const
|
||||
@@ -89,7 +89,7 @@ CVirtualDirectory* CVirtualDirectory::GetRoot()
|
||||
CVirtualDirectory* CVirtualDirectory::FindChildDirectory(const TString& rkName, bool AllowCreate)
|
||||
{
|
||||
uint32 SlashIdx = rkName.IndexOf("\\/");
|
||||
TString DirName = (SlashIdx == -1 ? rkName : rkName.SubString(0, SlashIdx));
|
||||
TString DirName = (SlashIdx == -1 ? static_cast<TString::BaseClass>(rkName) : rkName.SubString(0, SlashIdx));
|
||||
|
||||
for (uint32 iSub = 0; iSub < mSubdirectories.size(); iSub++)
|
||||
{
|
||||
@@ -173,7 +173,7 @@ bool CVirtualDirectory::AddChild(const TString &rkPath, CResourceEntry *pEntry)
|
||||
else if (IsValidDirectoryPath(rkPath))
|
||||
{
|
||||
uint32 SlashIdx = rkPath.IndexOf("\\/");
|
||||
TString DirName = (SlashIdx == -1 ? rkPath : rkPath.SubString(0, SlashIdx));
|
||||
TString DirName = (SlashIdx == -1 ? static_cast<TString::BaseClass>(rkPath) : rkPath.SubString(0, SlashIdx));
|
||||
TString Remaining = (SlashIdx == -1 ? "" : rkPath.SubString(SlashIdx + 1, rkPath.Size() - SlashIdx));
|
||||
|
||||
// Check if this subdirectory already exists
|
||||
@@ -286,7 +286,7 @@ void CVirtualDirectory::SortSubdirectories()
|
||||
|
||||
bool CVirtualDirectory::Rename(const TString& rkNewName)
|
||||
{
|
||||
debugf("MOVING DIRECTORY: %s --> %s", *FullPath(), *mpParent->FullPath() + rkNewName + '/');
|
||||
debugf("MOVING DIRECTORY: %s --> %s", *FullPath(), *(mpParent->FullPath() + rkNewName + '/'));
|
||||
|
||||
if (!IsRoot())
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ class CRenderbuffer
|
||||
bool mInitialized;
|
||||
|
||||
public:
|
||||
CRenderbuffer::CRenderbuffer()
|
||||
CRenderbuffer()
|
||||
: mWidth(0)
|
||||
, mHeight(0)
|
||||
, mEnableMultisampling(false)
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
CRenderbuffer::CRenderbuffer(uint Width, uint Height)
|
||||
CRenderbuffer(uint Width, uint Height)
|
||||
: mWidth(Width)
|
||||
, mHeight(Height)
|
||||
, mEnableMultisampling(false)
|
||||
@@ -28,20 +28,20 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
CRenderbuffer::~CRenderbuffer()
|
||||
~CRenderbuffer()
|
||||
{
|
||||
if (mInitialized)
|
||||
glDeleteRenderbuffers(1, &mRenderbuffer);
|
||||
}
|
||||
|
||||
void CRenderbuffer::Init()
|
||||
void Init()
|
||||
{
|
||||
mInitialized = true;
|
||||
glGenRenderbuffers(1, &mRenderbuffer);
|
||||
InitStorage();
|
||||
}
|
||||
|
||||
inline void CRenderbuffer::Resize(uint Width, uint Height)
|
||||
inline void Resize(uint Width, uint Height)
|
||||
{
|
||||
mWidth = Width;
|
||||
mHeight = Height;
|
||||
@@ -50,13 +50,13 @@ public:
|
||||
InitStorage();
|
||||
}
|
||||
|
||||
inline void CRenderbuffer::Bind()
|
||||
inline void Bind()
|
||||
{
|
||||
if (!mInitialized) Init();
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, mRenderbuffer);
|
||||
}
|
||||
|
||||
inline void CRenderbuffer::Unbind()
|
||||
inline void Unbind()
|
||||
{
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
}
|
||||
|
||||
@@ -216,8 +216,8 @@ void CShader::SetCurrent()
|
||||
// ************ STATIC ************
|
||||
CShader* CShader::FromResourceFile(const TString& rkShaderName)
|
||||
{
|
||||
TString VertexShaderFilename = "../resources/shaders/" + rkShaderName + ".vs";
|
||||
TString PixelShaderFilename = "../resources/shaders/" + rkShaderName + ".ps";
|
||||
TString VertexShaderFilename = gDataDir + "resources/shaders/" + rkShaderName + ".vs";
|
||||
TString PixelShaderFilename = gDataDir + "resources/shaders/" + rkShaderName + ".ps";
|
||||
TString VertexShaderText, PixelShaderText;
|
||||
|
||||
if (!FileUtil::LoadFileToString(VertexShaderFilename, VertexShaderText))
|
||||
|
||||
@@ -6,18 +6,18 @@
|
||||
#include <iostream>
|
||||
|
||||
// ************ MEMBER INITIALIZATION ************
|
||||
CVertexBuffer CDrawUtil::mGridVertices;
|
||||
std::optional<CVertexBuffer> CDrawUtil::mGridVertices;
|
||||
CIndexBuffer CDrawUtil::mGridIndices;
|
||||
|
||||
CDynamicVertexBuffer CDrawUtil::mSquareVertices;
|
||||
std::optional<CDynamicVertexBuffer> CDrawUtil::mSquareVertices;
|
||||
CIndexBuffer CDrawUtil::mSquareIndices;
|
||||
|
||||
CDynamicVertexBuffer CDrawUtil::mLineVertices;
|
||||
std::optional<CDynamicVertexBuffer> CDrawUtil::mLineVertices;
|
||||
CIndexBuffer CDrawUtil::mLineIndices;
|
||||
|
||||
TResPtr<CModel> CDrawUtil::mpCubeModel;
|
||||
|
||||
CVertexBuffer CDrawUtil::mWireCubeVertices;
|
||||
std::optional<CVertexBuffer> CDrawUtil::mWireCubeVertices;
|
||||
CIndexBuffer CDrawUtil::mWireCubeIndices;
|
||||
|
||||
TResPtr<CModel> CDrawUtil::mpSphereModel;
|
||||
@@ -45,7 +45,7 @@ void CDrawUtil::DrawGrid(CColor LineColor, CColor BoldLineColor)
|
||||
{
|
||||
Init();
|
||||
|
||||
mGridVertices.Bind();
|
||||
mGridVertices->Bind();
|
||||
|
||||
CGraphics::sMVPBlock.ModelMatrix = CMatrix4f::skIdentity;
|
||||
CGraphics::UpdateMVPBlock();
|
||||
@@ -88,13 +88,13 @@ void CDrawUtil::DrawSquare(const float *pTexCoords)
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
{
|
||||
EVertexAttribute TexAttrib = (EVertexAttribute) ((uint) (EVertexAttribute::Tex0) << iTex);
|
||||
mSquareVertices.BufferAttrib(TexAttrib, pTexCoords);
|
||||
mSquareVertices->BufferAttrib(TexAttrib, pTexCoords);
|
||||
}
|
||||
|
||||
// Draw
|
||||
mSquareVertices.Bind();
|
||||
mSquareVertices->Bind();
|
||||
mSquareIndices.DrawElements();
|
||||
mSquareVertices.Unbind();
|
||||
mSquareVertices->Unbind();
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawLine(const CVector3f& PointA, const CVector3f& PointB)
|
||||
@@ -114,13 +114,13 @@ void CDrawUtil::DrawLine(const CVector3f& PointA, const CVector3f& PointB, const
|
||||
|
||||
// Copy vec3s into an array to ensure they are adjacent in memory
|
||||
CVector3f Points[2] = { PointA, PointB };
|
||||
mLineVertices.BufferAttrib(EVertexAttribute::Position, Points);
|
||||
mLineVertices->BufferAttrib(EVertexAttribute::Position, Points);
|
||||
|
||||
// Draw
|
||||
UseColorShader(LineColor);
|
||||
mLineVertices.Bind();
|
||||
mLineVertices->Bind();
|
||||
mLineIndices.DrawElements();
|
||||
mLineVertices.Unbind();
|
||||
mLineVertices->Unbind();
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawLine(const CVector2f& PointA, const CVector2f& PointB, const CColor& LineColor)
|
||||
@@ -161,9 +161,9 @@ void CDrawUtil::DrawWireCube()
|
||||
{
|
||||
Init();
|
||||
glLineWidth(1.f);
|
||||
mWireCubeVertices.Bind();
|
||||
mWireCubeVertices->Bind();
|
||||
mWireCubeIndices.DrawElements();
|
||||
mWireCubeVertices.Unbind();
|
||||
mWireCubeVertices->Unbind();
|
||||
}
|
||||
|
||||
void CDrawUtil::DrawWireCube(const CAABox& kAABox, const CColor& kColor)
|
||||
@@ -413,22 +413,23 @@ void CDrawUtil::InitGrid()
|
||||
int MinIdx = (kGridSize - 1) / -2;
|
||||
int MaxIdx = (kGridSize - 1) / 2;
|
||||
|
||||
mGridVertices.SetVertexDesc(EVertexAttribute::Position);
|
||||
mGridVertices.Reserve(kGridSize * 4);
|
||||
mGridVertices.emplace();
|
||||
mGridVertices->SetVertexDesc(EVertexAttribute::Position);
|
||||
mGridVertices->Reserve(kGridSize * 4);
|
||||
|
||||
for (int32 i = MinIdx; i <= MaxIdx; i++)
|
||||
{
|
||||
if (i == 0) continue;
|
||||
mGridVertices.AddVertex(CVector3f(MinIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(MaxIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(i * kGridSpacing, MinIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(i * kGridSpacing, MaxIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(MinIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(MaxIdx * kGridSpacing, i * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(i * kGridSpacing, MinIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(i * kGridSpacing, MaxIdx * kGridSpacing, 0.0f));
|
||||
}
|
||||
|
||||
mGridVertices.AddVertex(CVector3f(MinIdx * kGridSpacing, 0, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(MaxIdx * kGridSpacing, 0, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(0, MinIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices.AddVertex(CVector3f(0, MaxIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(MinIdx * kGridSpacing, 0, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(MaxIdx * kGridSpacing, 0, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(0, MinIdx * kGridSpacing, 0.0f));
|
||||
mGridVertices->AddVertex(CVector3f(0, MaxIdx * kGridSpacing, 0.0f));
|
||||
|
||||
int NumIndices = kGridSize * 4;
|
||||
mGridIndices.Reserve(NumIndices);
|
||||
@@ -439,17 +440,18 @@ void CDrawUtil::InitGrid()
|
||||
void CDrawUtil::InitSquare()
|
||||
{
|
||||
debugf("Creating square");
|
||||
mSquareVertices.SetActiveAttribs(EVertexAttribute::Position |
|
||||
EVertexAttribute::Normal |
|
||||
EVertexAttribute::Tex0 |
|
||||
EVertexAttribute::Tex1 |
|
||||
EVertexAttribute::Tex2 |
|
||||
EVertexAttribute::Tex3 |
|
||||
EVertexAttribute::Tex4 |
|
||||
EVertexAttribute::Tex5 |
|
||||
EVertexAttribute::Tex6 |
|
||||
EVertexAttribute::Tex7 );
|
||||
mSquareVertices.SetVertexCount(4);
|
||||
mSquareVertices.emplace();
|
||||
mSquareVertices->SetActiveAttribs(EVertexAttribute::Position |
|
||||
EVertexAttribute::Normal |
|
||||
EVertexAttribute::Tex0 |
|
||||
EVertexAttribute::Tex1 |
|
||||
EVertexAttribute::Tex2 |
|
||||
EVertexAttribute::Tex3 |
|
||||
EVertexAttribute::Tex4 |
|
||||
EVertexAttribute::Tex5 |
|
||||
EVertexAttribute::Tex6 |
|
||||
EVertexAttribute::Tex7 );
|
||||
mSquareVertices->SetVertexCount(4);
|
||||
|
||||
CVector3f SquareVertices[] = {
|
||||
CVector3f(-1.f, 1.f, 0.f),
|
||||
@@ -472,13 +474,13 @@ void CDrawUtil::InitSquare()
|
||||
CVector2f(0.f, 0.f)
|
||||
};
|
||||
|
||||
mSquareVertices.BufferAttrib(EVertexAttribute::Position, SquareVertices);
|
||||
mSquareVertices.BufferAttrib(EVertexAttribute::Normal, SquareNormals);
|
||||
mSquareVertices->BufferAttrib(EVertexAttribute::Position, SquareVertices);
|
||||
mSquareVertices->BufferAttrib(EVertexAttribute::Normal, SquareNormals);
|
||||
|
||||
for (uint32 iTex = 0; iTex < 8; iTex++)
|
||||
{
|
||||
EVertexAttribute Attrib = (EVertexAttribute) (EVertexAttribute::Tex0 << iTex);
|
||||
mSquareVertices.BufferAttrib(Attrib, SquareTexCoords);
|
||||
mSquareVertices->BufferAttrib(Attrib, SquareTexCoords);
|
||||
}
|
||||
|
||||
mSquareIndices.Reserve(4);
|
||||
@@ -492,8 +494,9 @@ void CDrawUtil::InitSquare()
|
||||
void CDrawUtil::InitLine()
|
||||
{
|
||||
debugf("Creating line");
|
||||
mLineVertices.SetActiveAttribs(EVertexAttribute::Position);
|
||||
mLineVertices.SetVertexCount(2);
|
||||
mLineVertices.emplace();
|
||||
mLineVertices->SetActiveAttribs(EVertexAttribute::Position);
|
||||
mLineVertices->SetVertexCount(2);
|
||||
|
||||
mLineIndices.Reserve(2);
|
||||
mLineIndices.SetPrimitiveType(GL_LINES);
|
||||
@@ -510,16 +513,17 @@ void CDrawUtil::InitCube()
|
||||
void CDrawUtil::InitWireCube()
|
||||
{
|
||||
debugf("Creating wire cube");
|
||||
mWireCubeVertices.SetVertexDesc(EVertexAttribute::Position);
|
||||
mWireCubeVertices.Reserve(8);
|
||||
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));
|
||||
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));
|
||||
mWireCubeVertices.emplace();
|
||||
mWireCubeVertices->SetVertexDesc(EVertexAttribute::Position);
|
||||
mWireCubeVertices->Reserve(8);
|
||||
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));
|
||||
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));
|
||||
|
||||
uint16 Indices[] = {
|
||||
0, 1,
|
||||
@@ -585,6 +589,10 @@ void CDrawUtil::Shutdown()
|
||||
if (mDrawUtilInitialized)
|
||||
{
|
||||
debugf("Shutting down");
|
||||
mGridVertices = std::nullopt;
|
||||
mSquareVertices = std::nullopt;
|
||||
mLineVertices = std::nullopt;
|
||||
mWireCubeVertices = std::nullopt;
|
||||
delete mpColorShader;
|
||||
delete mpColorShaderLighting;
|
||||
delete mpTextureShader;
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
#include "Core/OpenGL/CVertexBuffer.h"
|
||||
#include "Core/OpenGL/CDynamicVertexBuffer.h"
|
||||
#include "Core/OpenGL/CIndexBuffer.h"
|
||||
#include "Core/Resource/model/CModel.h"
|
||||
#include "Core/Resource/Model/CModel.h"
|
||||
#include "Core/Resource/CLight.h"
|
||||
|
||||
#include <optional>
|
||||
|
||||
/**
|
||||
* @todo there are a LOT of problems with how this is implemented; trying to
|
||||
* use CDrawUtil in a lot of places in the codebase just plain doesn't work
|
||||
@@ -17,22 +19,22 @@
|
||||
class CDrawUtil
|
||||
{
|
||||
// 7x7 Grid
|
||||
static CVertexBuffer mGridVertices;
|
||||
static std::optional<CVertexBuffer> mGridVertices;
|
||||
static CIndexBuffer mGridIndices;
|
||||
|
||||
// Square
|
||||
static CDynamicVertexBuffer mSquareVertices;
|
||||
static std::optional<CDynamicVertexBuffer> mSquareVertices;
|
||||
static CIndexBuffer mSquareIndices;
|
||||
|
||||
// Line
|
||||
static CDynamicVertexBuffer mLineVertices;
|
||||
static std::optional<CDynamicVertexBuffer> mLineVertices;
|
||||
static CIndexBuffer mLineIndices;
|
||||
|
||||
// Cube
|
||||
static TResPtr<CModel> mpCubeModel;
|
||||
|
||||
// Wire Cube
|
||||
static CVertexBuffer mWireCubeVertices;
|
||||
static std::optional<CVertexBuffer> mWireCubeVertices;
|
||||
static CIndexBuffer mWireCubeIndices;
|
||||
|
||||
// Sphere
|
||||
|
||||
@@ -26,9 +26,9 @@ const CColor CGraphics::skDefaultAmbientColor = CColor(0.5f, 0.5f, 0.5f, 1.f);
|
||||
CColor CGraphics::sAreaAmbientColor = CColor::skBlack;
|
||||
float CGraphics::sWorldLightMultiplier;
|
||||
CLight CGraphics::sDefaultDirectionalLights[3] = {
|
||||
*CLight::BuildDirectional(CVector3f(0), CVector3f (0.f, -0.866025f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f)),
|
||||
*CLight::BuildDirectional(CVector3f(0), CVector3f(-0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f)),
|
||||
*CLight::BuildDirectional(CVector3f(0), CVector3f( 0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f))
|
||||
CLight::BuildDirectional(CVector3f(0), CVector3f (0.f, -0.866025f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f)),
|
||||
CLight::BuildDirectional(CVector3f(0), CVector3f(-0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f)),
|
||||
CLight::BuildDirectional(CVector3f(0), CVector3f( 0.75f, 0.433013f, -0.5f), CColor(0.3f, 0.3f, 0.3f, 1.f))
|
||||
};
|
||||
|
||||
// ************ FUNCTIONS ************
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Common/Math/MathUtil.h>
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
CAnimation::CAnimation(CResourceEntry *pEntry /*= 0*/)
|
||||
: CResource(pEntry)
|
||||
, mDuration(0.f)
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <Common/Macros.h>
|
||||
#include <Common/Math/MathUtil.h>
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
// ************ CBone ************
|
||||
CBone::CBone(CSkeleton *pSkel)
|
||||
: mpSkeleton(pSkel)
|
||||
|
||||
@@ -21,10 +21,6 @@ CGameArea::~CGameArea()
|
||||
|
||||
for (uint32 iSCLY = 0; iSCLY < mScriptLayers.size(); iSCLY++)
|
||||
delete mScriptLayers[iSCLY];
|
||||
|
||||
for (uint32 iLyr = 0; iLyr < mLightLayers.size(); iLyr++)
|
||||
for (uint32 iLight = 0; iLight < mLightLayers[iLyr].size(); iLight++)
|
||||
delete mLightLayers[iLyr][iLight];
|
||||
}
|
||||
|
||||
CDependencyTree* CGameArea::BuildDependencyTree() const
|
||||
|
||||
@@ -53,7 +53,7 @@ class CGameArea : public CResource
|
||||
// Collision
|
||||
std::unique_ptr<CCollisionMeshGroup> mpCollision;
|
||||
// Lights
|
||||
std::vector<std::vector<CLight*>> mLightLayers;
|
||||
std::vector<std::vector<CLight>> mLightLayers;
|
||||
// Path Mesh
|
||||
CAssetID mPathID;
|
||||
// Portal Area
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
inline CScriptLayer* ScriptLayer(uint32 Index) const { return mScriptLayers[Index]; }
|
||||
inline uint32 NumLightLayers() const { return mLightLayers.size(); }
|
||||
inline uint32 NumLights(uint32 LayerIndex) const { return (LayerIndex < mLightLayers.size() ? mLightLayers[LayerIndex].size() : 0); }
|
||||
inline CLight* Light(uint32 LayerIndex, uint32 LightIndex) const { return mLightLayers[LayerIndex][LightIndex]; }
|
||||
inline CLight* Light(uint32 LayerIndex, uint32 LightIndex) { return &mLightLayers[LayerIndex][LightIndex]; }
|
||||
inline CAssetID PathID() const { return mPathID; }
|
||||
inline CPoiToWorld* PoiToWorldMap() const { return mpPoiToWorldMap; }
|
||||
inline CAssetID PortalAreaID() const { return mPortalAreaID; }
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "Core/Render/CDrawUtil.h"
|
||||
#include "Core/Render/CRenderer.h"
|
||||
|
||||
CDynamicVertexBuffer CFont::smGlyphVertices;
|
||||
std::optional<CDynamicVertexBuffer> CFont::smGlyphVertices;
|
||||
CIndexBuffer CFont::smGlyphIndices;
|
||||
bool CFont::smBuffersInitialized = false;
|
||||
|
||||
@@ -43,7 +43,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
||||
GLuint ColorLoc = pTextShader->GetUniformLocation("FontColor");
|
||||
GLuint LayerLoc = pTextShader->GetUniformLocation("RGBALayer");
|
||||
mpFontTexture->Bind(0);
|
||||
smGlyphVertices.Bind();
|
||||
smGlyphVertices->Bind();
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
// Initialize some more stuff before we start the character loop
|
||||
@@ -116,7 +116,7 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
||||
|
||||
// Load shader uniforms, buffer texture
|
||||
glUniformMatrix4fv(ModelMtxLoc, 1, GL_FALSE, (GLfloat*) &GlyphTransform);
|
||||
smGlyphVertices.BufferAttrib(EVertexAttribute::Tex0, &pGlyph->TexCoords);
|
||||
smGlyphVertices->BufferAttrib(EVertexAttribute::Tex0, &pGlyph->TexCoords);
|
||||
|
||||
// Draw fill
|
||||
glUniform1i(LayerLoc, GlyphLayer);
|
||||
@@ -148,8 +148,9 @@ CVector2f CFont::RenderString(const TString& rkString, CRenderer* /*pRenderer*/,
|
||||
|
||||
void CFont::InitBuffers()
|
||||
{
|
||||
smGlyphVertices.SetActiveAttribs(EVertexAttribute::Position | EVertexAttribute::Tex0);
|
||||
smGlyphVertices.SetVertexCount(4);
|
||||
smGlyphVertices.emplace();
|
||||
smGlyphVertices->SetActiveAttribs(EVertexAttribute::Position | EVertexAttribute::Tex0);
|
||||
smGlyphVertices->SetVertexCount(4);
|
||||
|
||||
CVector3f Vertices[4] = {
|
||||
CVector3f( 0.f, 0.f, 0.f),
|
||||
@@ -157,7 +158,7 @@ void CFont::InitBuffers()
|
||||
CVector3f( 0.f, -2.f, 0.f),
|
||||
CVector3f( 2.f, -2.f, 0.f)
|
||||
};
|
||||
smGlyphVertices.BufferAttrib(EVertexAttribute::Position, Vertices);
|
||||
smGlyphVertices->BufferAttrib(EVertexAttribute::Position, Vertices);
|
||||
|
||||
CVector2f TexCoords[4] = {
|
||||
CVector2f(0.f, 0.f),
|
||||
@@ -165,7 +166,7 @@ void CFont::InitBuffers()
|
||||
CVector2f(0.f, 1.f),
|
||||
CVector2f(1.f, 1.f)
|
||||
};
|
||||
smGlyphVertices.BufferAttrib(EVertexAttribute::Tex0, TexCoords);
|
||||
smGlyphVertices->BufferAttrib(EVertexAttribute::Tex0, TexCoords);
|
||||
|
||||
smGlyphIndices.Reserve(4);
|
||||
smGlyphIndices.AddIndex(0);
|
||||
@@ -176,3 +177,12 @@ void CFont::InitBuffers()
|
||||
|
||||
smBuffersInitialized = true;
|
||||
}
|
||||
|
||||
void CFont::ShutdownBuffers()
|
||||
{
|
||||
if (smBuffersInitialized)
|
||||
{
|
||||
smGlyphVertices = std::nullopt;
|
||||
smBuffersInitialized = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "Core/OpenGL/CIndexBuffer.h"
|
||||
#include <Common/BasicTypes.h>
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -20,9 +21,9 @@ class CFont : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(Font)
|
||||
friend class CFontLoader;
|
||||
static CDynamicVertexBuffer smGlyphVertices; // This is the vertex buffer used to draw glyphs. It has two attributes - Pos and Tex0. Tex0 should be updated for each glyph.
|
||||
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 std::optional<CDynamicVertexBuffer> smGlyphVertices; // This is the vertex buffer used to draw glyphs. It has two attributes - Pos and Tex0. Tex0 should be updated for each glyph.
|
||||
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().
|
||||
|
||||
uint32 mUnknown; // Value at offset 0x8. Not sure what this is. Including for experimentation purposes.
|
||||
uint32 mLineHeight; // Height of each line, in points
|
||||
@@ -70,7 +71,8 @@ public:
|
||||
inline TString FontName() const { return mFontName; }
|
||||
inline CTexture* Texture() const { return mpFontTexture; }
|
||||
private:
|
||||
void InitBuffers();
|
||||
static void InitBuffers();
|
||||
static void ShutdownBuffers();
|
||||
};
|
||||
|
||||
#endif // CFONT_H
|
||||
|
||||
@@ -216,56 +216,56 @@ void CLight::Load() const
|
||||
}
|
||||
|
||||
// ************ STATIC ************
|
||||
CLight* CLight::BuildLocalAmbient(const CVector3f& rkPosition, const CColor& rkColor)
|
||||
CLight CLight::BuildLocalAmbient(const CVector3f& rkPosition, const CColor& rkColor)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = ELightType::LocalAmbient;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = skDefaultLightDir;
|
||||
pLight->mColor = rkColor;
|
||||
pLight->mSpotCutoff = 0.f;
|
||||
CLight pLight;
|
||||
pLight.mType = ELightType::LocalAmbient;
|
||||
pLight.mPosition = rkPosition;
|
||||
pLight.mDirection = skDefaultLightDir;
|
||||
pLight.mColor = rkColor;
|
||||
pLight.mSpotCutoff = 0.f;
|
||||
return pLight;
|
||||
}
|
||||
|
||||
CLight* CLight::BuildDirectional(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor)
|
||||
CLight CLight::BuildDirectional(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = ELightType::Directional;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = rkDirection;
|
||||
pLight->mColor = rkColor;
|
||||
pLight->mSpotCutoff = 0.f;
|
||||
CLight pLight;
|
||||
pLight.mType = ELightType::Directional;
|
||||
pLight.mPosition = rkPosition;
|
||||
pLight.mDirection = rkDirection;
|
||||
pLight.mColor = rkColor;
|
||||
pLight.mSpotCutoff = 0.f;
|
||||
return pLight;
|
||||
}
|
||||
|
||||
CLight* CLight::BuildSpot(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor, float Cutoff)
|
||||
CLight CLight::BuildSpot(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor, float Cutoff)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = ELightType::Spot;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = -rkDirection.Normalized();
|
||||
pLight->mColor = rkColor;
|
||||
pLight->mSpotCutoff = Cutoff * 0.5f;
|
||||
pLight->mAngleAttenCoefficients = pLight->CalculateSpotAngleAtten();
|
||||
CLight pLight;
|
||||
pLight.mType = ELightType::Spot;
|
||||
pLight.mPosition = rkPosition;
|
||||
pLight.mDirection = -rkDirection.Normalized();
|
||||
pLight.mColor = rkColor;
|
||||
pLight.mSpotCutoff = Cutoff * 0.5f;
|
||||
pLight.mAngleAttenCoefficients = pLight.CalculateSpotAngleAtten();
|
||||
return pLight;
|
||||
}
|
||||
|
||||
CLight* CLight::BuildCustom(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor,
|
||||
float DistAttenA, float DistAttenB, float DistAttenC,
|
||||
float AngleAttenA, float AngleAttenB, float AngleAttenC)
|
||||
CLight CLight::BuildCustom(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor,
|
||||
float DistAttenA, float DistAttenB, float DistAttenC,
|
||||
float AngleAttenA, float AngleAttenB, float AngleAttenC)
|
||||
{
|
||||
CLight *pLight = new CLight;
|
||||
pLight->mType = ELightType::Custom;
|
||||
pLight->mPosition = rkPosition;
|
||||
pLight->mDirection = rkDirection;
|
||||
pLight->mColor = rkColor;
|
||||
pLight->mSpotCutoff = 0.f;
|
||||
pLight->mDistAttenCoefficients.X = DistAttenA;
|
||||
pLight->mDistAttenCoefficients.Y = DistAttenB;
|
||||
pLight->mDistAttenCoefficients.Z = DistAttenC;
|
||||
pLight->mAngleAttenCoefficients.X = AngleAttenA;
|
||||
pLight->mAngleAttenCoefficients.Y = AngleAttenB;
|
||||
pLight->mAngleAttenCoefficients.Z = AngleAttenC * AngleAttenC;
|
||||
CLight pLight;
|
||||
pLight.mType = ELightType::Custom;
|
||||
pLight.mPosition = rkPosition;
|
||||
pLight.mDirection = rkDirection;
|
||||
pLight.mColor = rkColor;
|
||||
pLight.mSpotCutoff = 0.f;
|
||||
pLight.mDistAttenCoefficients.X = DistAttenA;
|
||||
pLight.mDistAttenCoefficients.Y = DistAttenB;
|
||||
pLight.mDistAttenCoefficients.Z = DistAttenC;
|
||||
pLight.mAngleAttenCoefficients.X = AngleAttenA;
|
||||
pLight.mAngleAttenCoefficients.Y = AngleAttenB;
|
||||
pLight.mAngleAttenCoefficients.Z = AngleAttenC * AngleAttenC;
|
||||
return pLight;
|
||||
}
|
||||
|
||||
|
||||
@@ -69,10 +69,10 @@ public:
|
||||
void Load() const;
|
||||
|
||||
// Static
|
||||
static CLight* BuildLocalAmbient(const CVector3f& rkPosition, const CColor& rkColor);
|
||||
static CLight* BuildDirectional(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor);
|
||||
static CLight* BuildSpot(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor, float Cutoff);
|
||||
static CLight* BuildCustom(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor,
|
||||
static CLight BuildLocalAmbient(const CVector3f& rkPosition, const CColor& rkColor);
|
||||
static CLight BuildDirectional(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor);
|
||||
static CLight BuildSpot(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor, float Cutoff);
|
||||
static CLight BuildCustom(const CVector3f& rkPosition, const CVector3f& rkDirection, const CColor& rkColor,
|
||||
float DistAttenA, float DistAttenB, float DistAttenC,
|
||||
float AngleAttenA, float AngleAttenB, float AngleAttenC);
|
||||
|
||||
|
||||
@@ -40,11 +40,13 @@ class CMaterial
|
||||
friend class CMaterialLoader;
|
||||
friend class CMaterialCooker;
|
||||
|
||||
public:
|
||||
enum class EShaderStatus
|
||||
{
|
||||
NoShader, ShaderExists, ShaderFailed
|
||||
};
|
||||
|
||||
private:
|
||||
// Statics
|
||||
static uint64 sCurrentMaterial; // The hash for the currently bound material
|
||||
static CColor sCurrentTint; // The tint for the currently bound material
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <Common/Macros.h>
|
||||
#include <algorithm>
|
||||
|
||||
std::unordered_map<EResourceType, CResTypeInfo*> CResTypeInfo::smTypeMap;
|
||||
std::unordered_map<EResourceType, std::unique_ptr<CResTypeInfo>> CResTypeInfo::smTypeMap;
|
||||
|
||||
CResTypeInfo::CResTypeInfo(EResourceType Type, const TString& rkTypeName, const TString& rkRetroExtension)
|
||||
: mType(Type)
|
||||
@@ -15,7 +15,7 @@ CResTypeInfo::CResTypeInfo(EResourceType Type, const TString& rkTypeName, const
|
||||
#if !PUBLIC_RELEASE
|
||||
ASSERT(smTypeMap.find(Type) == smTypeMap.end());
|
||||
#endif
|
||||
smTypeMap[Type] = this;
|
||||
smTypeMap[Type] = std::unique_ptr<CResTypeInfo>(this);
|
||||
}
|
||||
|
||||
bool CResTypeInfo::IsInGame(EGame Game) const
|
||||
@@ -48,7 +48,7 @@ void CResTypeInfo::GetAllTypesInGame(EGame Game, std::list<CResTypeInfo*>& rOut)
|
||||
{
|
||||
for (auto Iter = smTypeMap.begin(); Iter != smTypeMap.end(); Iter++)
|
||||
{
|
||||
CResTypeInfo *pType = Iter->second;
|
||||
CResTypeInfo *pType = Iter->second.get();
|
||||
|
||||
if (pType->IsInGame(Game))
|
||||
rOut.push_back(pType);
|
||||
@@ -78,7 +78,7 @@ CResTypeInfo* CResTypeInfo::TypeForCookedExtension(EGame Game, CFourCC Ext)
|
||||
// Not cached - do a slow lookup
|
||||
for (auto Iter = smTypeMap.begin(); Iter != smTypeMap.end(); Iter++)
|
||||
{
|
||||
CResTypeInfo *pType = Iter->second;
|
||||
CResTypeInfo *pType = Iter->second.get();
|
||||
|
||||
if (pType->CookedExtension(Game) == Ext)
|
||||
{
|
||||
@@ -98,6 +98,12 @@ CResTypeInfo* CResTypeInfo::TypeForCookedExtension(EGame Game, CFourCC Ext)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
CResTypeInfo* CResTypeInfo::FindTypeInfo(EResourceType Type)
|
||||
{
|
||||
auto Iter = smTypeMap.find(Type);
|
||||
return (Iter == smTypeMap.end() ? nullptr : Iter->second.get());
|
||||
}
|
||||
|
||||
// ************ SERIALIZATION ************
|
||||
void Serialize(IArchive& rArc, CResTypeInfo*& rpType)
|
||||
{
|
||||
|
||||
@@ -25,11 +25,12 @@ class CResTypeInfo
|
||||
bool mCanHaveDependencies;
|
||||
bool mCanBeCreated;
|
||||
|
||||
static std::unordered_map<EResourceType, CResTypeInfo*> smTypeMap;
|
||||
static std::unordered_map<EResourceType, std::unique_ptr<CResTypeInfo>> smTypeMap;
|
||||
|
||||
// Private Methods
|
||||
CResTypeInfo(EResourceType Type, const TString& rkTypeName, const TString& rkRetroExtension);
|
||||
~CResTypeInfo() {}
|
||||
~CResTypeInfo() = default;
|
||||
friend class std::default_delete<CResTypeInfo>;
|
||||
|
||||
// Public Methods
|
||||
public:
|
||||
@@ -47,11 +48,7 @@ public:
|
||||
static void GetAllTypesInGame(EGame Game, std::list<CResTypeInfo*>& rOut);
|
||||
static CResTypeInfo* TypeForCookedExtension(EGame, CFourCC Ext);
|
||||
|
||||
inline static CResTypeInfo* FindTypeInfo(EResourceType Type)
|
||||
{
|
||||
auto Iter = smTypeMap.find(Type);
|
||||
return (Iter == smTypeMap.end() ? nullptr : Iter->second);
|
||||
}
|
||||
static CResTypeInfo* FindTypeInfo(EResourceType Type);
|
||||
|
||||
private:
|
||||
// Creation
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "CTexture.h"
|
||||
#include <cmath>
|
||||
|
||||
CTexture::CTexture(CResourceEntry *pEntry /*= 0*/)
|
||||
: CResource(pEntry)
|
||||
@@ -143,7 +144,7 @@ float CTexture::ReadTexelAlpha(const CVector2f& rkTexCoord)
|
||||
// todo: support texel formats other than DXT1
|
||||
// DXT1 is definitely the most complicated one anyway; try reusing CTextureDecoder functions for other formats
|
||||
uint32 TexelX = (uint32) ((mWidth - 1) * rkTexCoord.X);
|
||||
uint32 TexelY = (uint32) ((mHeight - 1) * (1.f - fmodf(rkTexCoord.Y, 1.f)));
|
||||
uint32 TexelY = (uint32) ((mHeight - 1) * (1.f - std::fmod(rkTexCoord.Y, 1.f)));
|
||||
|
||||
if (mTexelFormat == ETexelFormat::DXT1 && mBufferExists)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "CCollisionRenderData.h"
|
||||
#include <Core/Render/CDrawUtil.h>
|
||||
#include <algorithm>
|
||||
|
||||
/** Build from collision data */
|
||||
void CCollisionRenderData::BuildRenderData(const SCollisionIndexData& kIndexData)
|
||||
|
||||
@@ -99,6 +99,7 @@ enum class EUVAnimMode
|
||||
ConvolutedModeA = 0x7,
|
||||
ConvolutedModeB = 0x8,
|
||||
SimpleMode = 0xA,
|
||||
Eleven = 0xB,
|
||||
NoUVAnim = -1
|
||||
};
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include <Common/CFourCC.h>
|
||||
|
||||
#include <cfloat>
|
||||
#include <iostream>
|
||||
|
||||
CAreaLoader::CAreaLoader()
|
||||
@@ -151,7 +152,7 @@ void CAreaLoader::ReadSCLYPrime()
|
||||
CFourCC SCGN = mpMREA->ReadFourCC();
|
||||
|
||||
if (SCGN != FOURCC('SCGN'))
|
||||
errorf("%s [0x%X]: Invalid SCGN magic: %s", *mpMREA->GetSourceString(), mpMREA->Tell() - 4, SCGN.ToString());
|
||||
errorf("%s [0x%X]: Invalid SCGN magic: %s", *mpMREA->GetSourceString(), mpMREA->Tell() - 4, *SCGN.ToString());
|
||||
|
||||
else
|
||||
{
|
||||
@@ -191,7 +192,7 @@ void CAreaLoader::ReadLightsPrime()
|
||||
mpMREA->Seek(0x4, SEEK_CUR);
|
||||
|
||||
// Relevant data is read - now we process and form a CLight out of it
|
||||
CLight *pLight;
|
||||
CLight pLight;
|
||||
|
||||
CColor LightColor = CColor(Color.X, Color.Y, Color.Z, 0.f);
|
||||
if (Multiplier < FLT_EPSILON)
|
||||
@@ -225,7 +226,7 @@ void CAreaLoader::ReadLightsPrime()
|
||||
float DistAttenA = (FalloffType == 0) ? (2.f / Multiplier) : 0.f;
|
||||
float DistAttenB = (FalloffType == 1) ? (250.f / Multiplier) : 0.f;
|
||||
float DistAttenC = (FalloffType == 2) ? (25000.f / Multiplier) : 0.f;
|
||||
pLight->SetDistAtten(DistAttenA, DistAttenB, DistAttenC);
|
||||
pLight.SetDistAtten(DistAttenA, DistAttenB, DistAttenC);
|
||||
}
|
||||
|
||||
// Custom
|
||||
@@ -240,7 +241,7 @@ void CAreaLoader::ReadLightsPrime()
|
||||
1.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
pLight->SetLayer(iLyr);
|
||||
pLight.SetLayer(iLyr);
|
||||
mpArea->mLightLayers[iLyr][iLight] = pLight;
|
||||
}
|
||||
}
|
||||
@@ -493,7 +494,7 @@ void CAreaLoader::ReadLightsCorruption()
|
||||
mpMREA->Seek(0x18, SEEK_CUR);
|
||||
|
||||
// Relevant data is read - now we process and form a CLight out of it
|
||||
CLight *pLight;
|
||||
CLight pLight;
|
||||
|
||||
if (Multiplier < FLT_EPSILON)
|
||||
Multiplier = FLT_EPSILON;
|
||||
@@ -518,7 +519,7 @@ void CAreaLoader::ReadLightsCorruption()
|
||||
float DistAttenA = (FalloffType == 0) ? (2.f / Multiplier) : 0.f;
|
||||
float DistAttenB = (FalloffType == 1) ? (250.f / Multiplier) : 0.f;
|
||||
float DistAttenC = (FalloffType == 2) ? (25000.f / Multiplier) : 0.f;
|
||||
pLight->SetDistAtten(DistAttenA, DistAttenB, DistAttenC);
|
||||
pLight.SetDistAtten(DistAttenA, DistAttenB, DistAttenC);
|
||||
}
|
||||
|
||||
// Custom
|
||||
@@ -533,7 +534,7 @@ void CAreaLoader::ReadLightsCorruption()
|
||||
1.f, 0.f, 0.f);
|
||||
}
|
||||
|
||||
pLight->SetLayer(iLayer);
|
||||
pLight.SetLayer(iLayer);
|
||||
mpArea->mLightLayers[iLayer][iLight] = pLight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,28 +379,28 @@ CMaterial* CMaterialLoader::ReadCorruptionMaterial()
|
||||
|
||||
switch (pPass->mAnimMode)
|
||||
{
|
||||
case 3: // Rotation
|
||||
case 7: // ???
|
||||
case EUVAnimMode::UVRotation: // Rotation
|
||||
case EUVAnimMode::ConvolutedModeA: // ???
|
||||
pPass->mAnimParams[0] = mpFile->ReadFloat();
|
||||
pPass->mAnimParams[1] = mpFile->ReadFloat();
|
||||
break;
|
||||
case 2: // UV Scroll
|
||||
case 4: // U Scroll
|
||||
case 5: // V Scroll
|
||||
case EUVAnimMode::UVScroll: // UV Scroll
|
||||
case EUVAnimMode::HFilmstrip: // U Scroll
|
||||
case EUVAnimMode::VFilmstrip: // V Scroll
|
||||
pPass->mAnimParams[0] = mpFile->ReadFloat();
|
||||
pPass->mAnimParams[1] = mpFile->ReadFloat();
|
||||
pPass->mAnimParams[2] = mpFile->ReadFloat();
|
||||
pPass->mAnimParams[3] = mpFile->ReadFloat();
|
||||
break;
|
||||
case 0: // Inverse ModelView Matrix
|
||||
case 1: // Inverse ModelView Matrix Translated
|
||||
case 6: // Model Matrix
|
||||
case 10: // Yet-to-be-named
|
||||
case EUVAnimMode::InverseMV: // Inverse ModelView Matrix
|
||||
case EUVAnimMode::InverseMVTranslated: // Inverse ModelView Matrix Translated
|
||||
case EUVAnimMode::ModelMatrix: // Model Matrix
|
||||
case EUVAnimMode::SimpleMode: // Yet-to-be-named
|
||||
break;
|
||||
|
||||
// Unknown/unsupported animation type
|
||||
case 8:
|
||||
case 11:
|
||||
case EUVAnimMode::ConvolutedModeB:
|
||||
case EUVAnimMode::Eleven:
|
||||
break;
|
||||
default:
|
||||
errorf("%s [0x%X]: Unsupported animation mode encountered: %d", *mpFile->GetSourceString(), mpFile->Tell() - 8, pPass->mAnimMode);
|
||||
|
||||
@@ -111,19 +111,6 @@ EGame CScriptTemplate::Game() const
|
||||
return mpGame->Game();
|
||||
}
|
||||
|
||||
// ************ PROPERTY FETCHING ************
|
||||
template<class PropType>
|
||||
PropType* TFetchProperty(CStructProperty* pProperties, const TIDString& rkID)
|
||||
{
|
||||
if (rkID.IsEmpty()) return nullptr;
|
||||
IProperty *pProp = pProperties->ChildByIDString(rkID);
|
||||
|
||||
if (pProp && (pProp->Type() == PropEnum))
|
||||
return static_cast<PropType*>(pProp)->ValuePtr();
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EVolumeShape CScriptTemplate::VolumeShape(CScriptObject *pObj)
|
||||
{
|
||||
if (pObj->Template() != this)
|
||||
|
||||
@@ -52,7 +52,6 @@ public:
|
||||
ScaleEnabled, ScaleDisabled, ScaleVolume
|
||||
};
|
||||
|
||||
private:
|
||||
struct SEditorAsset
|
||||
{
|
||||
enum class EAssetType {
|
||||
@@ -75,6 +74,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
std::vector<TString> mModules;
|
||||
std::unique_ptr<CStructProperty> mpProperties;
|
||||
std::vector<SEditorAsset> mAssets;
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace NGameList
|
||||
{
|
||||
|
||||
/** Path for the templates directory */
|
||||
const TString gkTemplatesDir = "../templates/";
|
||||
const TString gkTemplatesDir = "templates/";
|
||||
|
||||
/** Path to the game list file */
|
||||
const TString gkGameListPath = gkTemplatesDir + "GameList.xml";
|
||||
@@ -33,7 +33,7 @@ struct SGameInfo
|
||||
}
|
||||
}
|
||||
};
|
||||
SGameInfo gGameList[EGame::Max];
|
||||
SGameInfo gGameList[int(EGame::Max)];
|
||||
|
||||
/** Whether the game list has been loaded */
|
||||
bool gLoadedGameList = false;
|
||||
@@ -88,7 +88,7 @@ void LoadGameList()
|
||||
ASSERT(!gLoadedGameList);
|
||||
debugf("Loading game list");
|
||||
|
||||
CXMLReader Reader(gkGameListPath);
|
||||
CXMLReader Reader(gDataDir + gkGameListPath);
|
||||
ASSERT(Reader.IsValid());
|
||||
|
||||
SerializeGameList(Reader);
|
||||
@@ -101,7 +101,7 @@ void SaveGameList()
|
||||
ASSERT(gLoadedGameList);
|
||||
debugf("Saving game list");
|
||||
|
||||
CXMLWriter Writer(gkGameListPath, "GameList");
|
||||
CXMLWriter Writer(gDataDir + gkGameListPath, "GameList");
|
||||
ASSERT(Writer.IsValid());
|
||||
|
||||
SerializeGameList(Writer);
|
||||
@@ -151,7 +151,7 @@ CGameTemplate* GetGameTemplate(EGame Game)
|
||||
// Load the game template, if it hasn't been loaded yet.
|
||||
if (!GameInfo.pTemplate && !GameInfo.Name.IsEmpty())
|
||||
{
|
||||
TString GamePath = gkTemplatesDir + GameInfo.TemplatePath;
|
||||
TString GamePath = gDataDir + gkTemplatesDir + GameInfo.TemplatePath;
|
||||
GameInfo.pTemplate = std::make_unique<CGameTemplate>();
|
||||
GameInfo.pTemplate->Load(GamePath);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace NPropertyMap
|
||||
{
|
||||
|
||||
/** Path to the property map file */
|
||||
const char* gpkLegacyMapPath = "../templates/PropertyMapLegacy.xml";
|
||||
const char* gpkMapPath = "../templates/PropertyMap.xml";
|
||||
const char* gpkLegacyMapPath = "templates/PropertyMapLegacy.xml";
|
||||
const char* gpkMapPath = "templates/PropertyMap.xml";
|
||||
|
||||
/** Whether to do name lookups from the legacy map */
|
||||
const bool gkUseLegacyMapForNameLookups = false;
|
||||
@@ -150,13 +150,13 @@ void LoadMap()
|
||||
|
||||
if ( gkUseLegacyMapForNameLookups )
|
||||
{
|
||||
CXMLReader Reader(gpkLegacyMapPath);
|
||||
CXMLReader Reader(gDataDir + gpkLegacyMapPath);
|
||||
ASSERT(Reader.IsValid());
|
||||
Reader << SerialParameter("PropertyMap", gLegacyNameMap, SH_HexDisplay);
|
||||
}
|
||||
else
|
||||
{
|
||||
CXMLReader Reader(gpkMapPath);
|
||||
CXMLReader Reader(gDataDir + gpkMapPath);
|
||||
ASSERT(Reader.IsValid());
|
||||
Reader << SerialParameter("PropertyMap", gNameMap, SH_HexDisplay);
|
||||
|
||||
@@ -198,7 +198,7 @@ void SaveMap(bool Force /*= false*/)
|
||||
{
|
||||
if( gkUseLegacyMapForUpdates )
|
||||
{
|
||||
CXMLWriter Writer(gpkLegacyMapPath, "PropertyMap");
|
||||
CXMLWriter Writer(gDataDir + gpkLegacyMapPath, "PropertyMap");
|
||||
ASSERT(Writer.IsValid());
|
||||
Writer << SerialParameter("PropertyMap", gLegacyNameMap, SH_HexDisplay);
|
||||
}
|
||||
@@ -219,7 +219,7 @@ void SaveMap(bool Force /*= false*/)
|
||||
}
|
||||
|
||||
// Perform the actual save
|
||||
CXMLWriter Writer(gpkMapPath, "PropertyMap");
|
||||
CXMLWriter Writer(gDataDir + gpkMapPath, "PropertyMap");
|
||||
ASSERT(Writer.IsValid());
|
||||
Writer << SerialParameter("PropertyMap", gNameMap, SH_HexDisplay);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ class CAssetProperty : public TSerializeableTypedProperty<CAssetID, EPropertyTyp
|
||||
CResTypeFilter mTypeFilter;
|
||||
|
||||
protected:
|
||||
CAssetProperty::CAssetProperty(EGame Game)
|
||||
CAssetProperty(EGame Game)
|
||||
: TSerializeableTypedProperty(Game)
|
||||
{
|
||||
mDefaultValue = CAssetID::InvalidID( mGame );
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
template<EPropertyType TypeEnum>
|
||||
class TEnumPropertyBase : public TSerializeableTypedProperty<int32, TypeEnum>
|
||||
{
|
||||
using base = TSerializeableTypedProperty<int32, TypeEnum>;
|
||||
friend class IProperty;
|
||||
|
||||
struct SEnumValue
|
||||
@@ -47,17 +48,17 @@ class TEnumPropertyBase : public TSerializeableTypedProperty<int32, TypeEnum>
|
||||
protected:
|
||||
/** Constructor */
|
||||
TEnumPropertyBase(EGame Game)
|
||||
: TSerializeableTypedProperty(Game)
|
||||
: base(Game)
|
||||
, mOverrideTypeName(false)
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual const char* HashableTypeName() const
|
||||
{
|
||||
if (mpArchetype)
|
||||
return mpArchetype->HashableTypeName();
|
||||
if (base::mpArchetype)
|
||||
return base::mpArchetype->HashableTypeName();
|
||||
else if (mOverrideTypeName)
|
||||
return *mName;
|
||||
return *base::mName;
|
||||
else if (TypeEnum == EPropertyType::Enum)
|
||||
return "enum";
|
||||
else
|
||||
@@ -67,15 +68,15 @@ public:
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
// Skip TSerializeableTypedProperty, serialize default value ourselves so we can set SH_HexDisplay
|
||||
TTypedProperty::Serialize(rArc);
|
||||
TTypedProperty<int32, TypeEnum>::Serialize(rArc);
|
||||
|
||||
// Serialize default value
|
||||
TEnumPropertyBase* pArchetype = static_cast<TEnumPropertyBase*>(mpArchetype);
|
||||
TEnumPropertyBase* pArchetype = static_cast<TEnumPropertyBase*>(base::mpArchetype);
|
||||
uint32 DefaultValueFlags = SH_Optional | (TypeEnum == EPropertyType::Enum ? SH_HexDisplay : 0);
|
||||
rArc << SerialParameter("DefaultValue", mDefaultValue, DefaultValueFlags, pArchetype ? pArchetype->mDefaultValue : 0);
|
||||
rArc << SerialParameter("DefaultValue", base::mDefaultValue, DefaultValueFlags, pArchetype ? pArchetype->mDefaultValue : 0);
|
||||
|
||||
// Only serialize type name override for root archetypes.
|
||||
if (!mpArchetype)
|
||||
if (!base::mpArchetype)
|
||||
{
|
||||
rArc << SerialParameter("OverrideTypeName", mOverrideTypeName, SH_Optional, false);
|
||||
}
|
||||
@@ -88,19 +89,19 @@ public:
|
||||
|
||||
virtual void SerializeValue(void* pData, IArchive& Arc) const
|
||||
{
|
||||
Arc.SerializePrimitive( (uint32&) ValueRef(pData), 0 );
|
||||
Arc.SerializePrimitive( (uint32&) base::ValueRef(pData), 0 );
|
||||
}
|
||||
|
||||
virtual void InitFromArchetype(IProperty* pOther)
|
||||
{
|
||||
TTypedProperty::InitFromArchetype(pOther);
|
||||
base::InitFromArchetype(pOther);
|
||||
TEnumPropertyBase* pOtherEnum = static_cast<TEnumPropertyBase*>(pOther);
|
||||
mValues = pOtherEnum->mValues;
|
||||
}
|
||||
|
||||
virtual TString ValueAsString(void* pData) const
|
||||
{
|
||||
return TString::FromInt32( Value(pData), 0, 10 );
|
||||
return TString::FromInt32( base::Value(pData), 0, 10 );
|
||||
}
|
||||
|
||||
void AddValue(TString ValueName, uint32 ValueID)
|
||||
@@ -137,21 +138,21 @@ public:
|
||||
bool HasValidValue(void* pPropertyData)
|
||||
{
|
||||
if (mValues.empty()) return true;
|
||||
int ID = ValueRef(pPropertyData);
|
||||
int ID = base::ValueRef(pPropertyData);
|
||||
uint32 Index = ValueIndex(ID);
|
||||
return Index >= 0 && Index < mValues.size();
|
||||
}
|
||||
|
||||
bool OverridesTypeName() const
|
||||
{
|
||||
return mpArchetype ? TPropCast<TEnumPropertyBase>(mpArchetype)->OverridesTypeName() : mOverrideTypeName;
|
||||
return base::mpArchetype ? TPropCast<TEnumPropertyBase>(base::mpArchetype)->OverridesTypeName() : mOverrideTypeName;
|
||||
}
|
||||
|
||||
void SetOverrideTypeName(bool Override)
|
||||
{
|
||||
if (mpArchetype)
|
||||
if (base::mpArchetype)
|
||||
{
|
||||
TEnumPropertyBase* pArchetype = TPropCast<TEnumPropertyBase>(RootArchetype());
|
||||
TEnumPropertyBase* pArchetype = TPropCast<TEnumPropertyBase>(base::RootArchetype());
|
||||
pArchetype->SetOverrideTypeName(Override);
|
||||
}
|
||||
else
|
||||
@@ -159,7 +160,7 @@ public:
|
||||
if (mOverrideTypeName != Override)
|
||||
{
|
||||
mOverrideTypeName = Override;
|
||||
MarkDirty();
|
||||
base::MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ void CPropertyNameGenerator::Warmup()
|
||||
mWords.clear();
|
||||
|
||||
// Load the word list from the file
|
||||
FILE* pListFile = fopen("../resources/WordList.txt", "r");
|
||||
FILE* pListFile = fopen(*(gDataDir + "resources/WordList.txt"), "r");
|
||||
ASSERT(pListFile);
|
||||
|
||||
while (!feof(pListFile))
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "Core/Resource/Script/NGameList.h"
|
||||
#include "Core/Resource/Script/NPropertyMap.h"
|
||||
|
||||
#include <cfloat>
|
||||
|
||||
/** IProperty */
|
||||
IProperty::IProperty(EGame Game)
|
||||
: mpParent( nullptr )
|
||||
@@ -311,7 +313,7 @@ TString IProperty::GetTemplateFileName()
|
||||
pTemplateRoot = pTemplateRoot->RootParent();
|
||||
|
||||
// Now that we have the base property of our template, we can return the file path.
|
||||
static const uint32 kChopAmount = strlen("../templates/");
|
||||
static const uint32 kChopAmount = strlen(*(gDataDir + "templates/"));
|
||||
|
||||
if (pTemplateRoot->ScriptTemplate())
|
||||
{
|
||||
|
||||
@@ -419,29 +419,30 @@ public:
|
||||
template<typename PropType, EPropertyType PropEnum>
|
||||
class TSerializeableTypedProperty : public TTypedProperty<PropType, PropEnum>
|
||||
{
|
||||
using base = TTypedProperty<PropType, PropEnum>;
|
||||
protected:
|
||||
TSerializeableTypedProperty(EGame Game)
|
||||
: TTypedProperty(Game)
|
||||
: base(Game)
|
||||
{}
|
||||
|
||||
public:
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
TTypedProperty::Serialize(rArc);
|
||||
TSerializeableTypedProperty* pArchetype = static_cast<TSerializeableTypedProperty*>(mpArchetype);
|
||||
base::Serialize(rArc);
|
||||
TSerializeableTypedProperty* pArchetype = static_cast<TSerializeableTypedProperty*>(base::mpArchetype);
|
||||
|
||||
// Determine if default value should be serialized as optional.
|
||||
// All MP1 properties should be optional. For MP2 and on, we set optional
|
||||
// on property types that don't have default values in the game executable.
|
||||
bool MakeOptional = false;
|
||||
|
||||
if (Game() <= EGame::Prime || pArchetype != nullptr)
|
||||
if (base::Game() <= EGame::Prime || pArchetype != nullptr)
|
||||
{
|
||||
MakeOptional = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (Type())
|
||||
switch (base::Type())
|
||||
{
|
||||
case EPropertyType::String:
|
||||
case EPropertyType::Asset:
|
||||
@@ -457,17 +458,18 @@ public:
|
||||
|
||||
// Branch here to avoid constructing a default value if we don't need to.
|
||||
if (MakeOptional)
|
||||
rArc << SerialParameter("DefaultValue", mDefaultValue, SH_Optional, pArchetype ? pArchetype->mDefaultValue : GetSerializationDefaultValue());
|
||||
rArc << SerialParameter("DefaultValue", base::mDefaultValue, SH_Optional,
|
||||
pArchetype ? pArchetype->mDefaultValue : GetSerializationDefaultValue());
|
||||
else
|
||||
rArc << SerialParameter("DefaultValue", mDefaultValue);
|
||||
rArc << SerialParameter("DefaultValue", base::mDefaultValue);
|
||||
}
|
||||
|
||||
virtual bool ShouldSerialize() const
|
||||
{
|
||||
TTypedProperty* pArchetype = static_cast<TTypedProperty*>(mpArchetype);
|
||||
base* pArchetype = static_cast<base*>(base::mpArchetype);
|
||||
|
||||
return TTypedProperty::ShouldSerialize() ||
|
||||
!(mDefaultValue == pArchetype->DefaultValue());
|
||||
return base::ShouldSerialize() ||
|
||||
!(base::mDefaultValue == pArchetype->DefaultValue());
|
||||
}
|
||||
|
||||
/** Return default value for serialization - can be customized per type */
|
||||
@@ -480,6 +482,7 @@ public:
|
||||
template<typename PropType, EPropertyType PropEnum>
|
||||
class TNumericalProperty : public TSerializeableTypedProperty<PropType, PropEnum>
|
||||
{
|
||||
using base = TSerializeableTypedProperty<PropType, PropEnum>;
|
||||
friend class IProperty;
|
||||
friend class CTemplateLoader;
|
||||
|
||||
@@ -488,7 +491,7 @@ protected:
|
||||
PropType mMaxValue;
|
||||
|
||||
TNumericalProperty(EGame Game)
|
||||
: TSerializeableTypedProperty(Game)
|
||||
: base(Game)
|
||||
, mMinValue( -1 )
|
||||
, mMaxValue( -1 )
|
||||
{}
|
||||
@@ -496,8 +499,8 @@ protected:
|
||||
public:
|
||||
virtual void Serialize(IArchive& rArc)
|
||||
{
|
||||
TSerializeableTypedProperty::Serialize(rArc);
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(mpArchetype);
|
||||
base::Serialize(rArc);
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(base::mpArchetype);
|
||||
|
||||
rArc << SerialParameter("Min", mMinValue, SH_Optional, pArchetype ? pArchetype->mMinValue : (PropType) -1)
|
||||
<< SerialParameter("Max", mMaxValue, SH_Optional, pArchetype ? pArchetype->mMaxValue : (PropType) -1);
|
||||
@@ -505,15 +508,15 @@ public:
|
||||
|
||||
virtual bool ShouldSerialize() const
|
||||
{
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(mpArchetype);
|
||||
return TSerializeableTypedProperty::ShouldSerialize() ||
|
||||
TNumericalProperty* pArchetype = static_cast<TNumericalProperty*>(base::mpArchetype);
|
||||
return base::ShouldSerialize() ||
|
||||
mMinValue != pArchetype->mMinValue ||
|
||||
mMaxValue != pArchetype->mMaxValue;
|
||||
}
|
||||
|
||||
virtual void InitFromArchetype(IProperty* pOther)
|
||||
{
|
||||
TSerializeableTypedProperty::InitFromArchetype(pOther);
|
||||
base::InitFromArchetype(pOther);
|
||||
TNumericalProperty* pCastOther = static_cast<TNumericalProperty*>(pOther);
|
||||
mMinValue = pCastOther->mMinValue;
|
||||
mMaxValue = pCastOther->mMaxValue;
|
||||
@@ -521,11 +524,11 @@ public:
|
||||
|
||||
virtual void PropertyValueChanged(void* pPropertyData)
|
||||
{
|
||||
TSerializeableTypedProperty::PropertyValueChanged(pPropertyData);
|
||||
base::PropertyValueChanged(pPropertyData);
|
||||
|
||||
if (mMinValue >= 0 && mMaxValue >= 0)
|
||||
{
|
||||
PropType& rValue = ValueRef(pPropertyData);
|
||||
PropType& rValue = base::ValueRef(pPropertyData);
|
||||
rValue = Math::Clamp(mMinValue, mMaxValue, rValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "CVectorProperty.h"
|
||||
|
||||
/** TPropertyRef: Embeds a reference to a property on a specific object */
|
||||
template<class PropertyClass, typename ValueType = PropertyClass::ValueType>
|
||||
template<class PropertyClass, typename ValueType = typename PropertyClass::ValueType>
|
||||
class TPropertyRef
|
||||
{
|
||||
/** Property data being referenced */
|
||||
@@ -96,17 +96,18 @@ typedef TPropertyRef<CArrayProperty> CArrayRef;
|
||||
template<typename ValueType>
|
||||
class TEnumRef : public TPropertyRef<CEnumProperty, ValueType>
|
||||
{
|
||||
using base = TPropertyRef<CEnumProperty, ValueType>;
|
||||
public:
|
||||
TEnumRef()
|
||||
: TPropertyRef()
|
||||
: base()
|
||||
{}
|
||||
|
||||
TEnumRef(void* pInData, IProperty* pInProperty)
|
||||
: TPropertyRef(pInData, pInProperty)
|
||||
: base(pInData, pInProperty)
|
||||
{}
|
||||
|
||||
TEnumRef(void* pInData, CEnumProperty* pInProperty)
|
||||
: TPropertyRef(pInData, pInProperty)
|
||||
: base(pInData, pInProperty)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@ class CScriptNode : public CSceneNode
|
||||
|
||||
CLightParameters *mpLightParameters;
|
||||
|
||||
public:
|
||||
enum class EGameModeVisibility
|
||||
{
|
||||
Visible, NotVisible, Untested
|
||||
} mGameModeVisibility;
|
||||
|
||||
public:
|
||||
CScriptNode(CScene *pScene, uint32 NodeID, CSceneNode *pParent = 0, CScriptObject *pObject = 0);
|
||||
ENodeType NodeType();
|
||||
void PostLoad();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
class CDamageableTriggerExtra : public CScriptExtra
|
||||
{
|
||||
public:
|
||||
// Render fluid planes for doors in MP1
|
||||
enum class ERenderSide
|
||||
{
|
||||
@@ -17,6 +18,7 @@ class CDamageableTriggerExtra : public CScriptExtra
|
||||
Down = 0x20
|
||||
};
|
||||
|
||||
private:
|
||||
CVectorRef mPlaneSize;
|
||||
TEnumRef<ERenderSide> mRenderSide;
|
||||
CAssetRef mTextureAssets[3];
|
||||
|
||||
Reference in New Issue
Block a user