mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-12-21 10:49:23 +00:00
Refactor so PWE compiles with the newly externalized LibCommon
This commit is contained in:
@@ -15,16 +15,16 @@ CBasicModel::CBasicModel(CResourceEntry *pEntry /*= 0*/)
|
||||
CBasicModel::~CBasicModel()
|
||||
{
|
||||
if (mHasOwnSurfaces)
|
||||
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
delete mSurfaces[iSurf];
|
||||
}
|
||||
|
||||
u32 CBasicModel::GetVertexCount()
|
||||
uint32 CBasicModel::GetVertexCount()
|
||||
{
|
||||
return mVertexCount;
|
||||
}
|
||||
|
||||
u32 CBasicModel::GetTriangleCount()
|
||||
uint32 CBasicModel::GetTriangleCount()
|
||||
{
|
||||
return mTriangleCount;
|
||||
}
|
||||
@@ -39,17 +39,17 @@ bool CBasicModel::IsBuffered()
|
||||
return mBuffered;
|
||||
}
|
||||
|
||||
u32 CBasicModel::GetSurfaceCount()
|
||||
uint32 CBasicModel::GetSurfaceCount()
|
||||
{
|
||||
return mSurfaces.size();
|
||||
}
|
||||
|
||||
CAABox CBasicModel::GetSurfaceAABox(u32 Surface)
|
||||
CAABox CBasicModel::GetSurfaceAABox(uint32 Surface)
|
||||
{
|
||||
return mSurfaces[Surface]->AABox;
|
||||
}
|
||||
|
||||
SSurface* CBasicModel::GetSurface(u32 Surface)
|
||||
SSurface* CBasicModel::GetSurface(uint32 Surface)
|
||||
{
|
||||
return mSurfaces[Surface];
|
||||
}
|
||||
|
||||
@@ -4,15 +4,15 @@
|
||||
#include "SSurface.h"
|
||||
#include "Core/Resource/CResource.h"
|
||||
#include "Core/OpenGL/CVertexBuffer.h"
|
||||
#include <Math/CAABox.h>
|
||||
#include <Common/Math/CAABox.h>
|
||||
|
||||
class CBasicModel : public CResource
|
||||
{
|
||||
DECLARE_RESOURCE_TYPE(eModel)
|
||||
protected:
|
||||
CAABox mAABox;
|
||||
u32 mVertexCount;
|
||||
u32 mTriangleCount;
|
||||
uint32 mVertexCount;
|
||||
uint32 mTriangleCount;
|
||||
bool mBuffered;
|
||||
bool mHasOwnMaterials;
|
||||
bool mHasOwnSurfaces;
|
||||
@@ -24,13 +24,13 @@ public:
|
||||
CBasicModel(CResourceEntry *pEntry = 0);
|
||||
~CBasicModel();
|
||||
|
||||
u32 GetVertexCount();
|
||||
u32 GetTriangleCount();
|
||||
uint32 GetVertexCount();
|
||||
uint32 GetTriangleCount();
|
||||
CAABox AABox();
|
||||
bool IsBuffered();
|
||||
u32 GetSurfaceCount();
|
||||
CAABox GetSurfaceAABox(u32 Surface);
|
||||
SSurface* GetSurface(u32 Surface);
|
||||
uint32 GetSurfaceCount();
|
||||
CAABox GetSurfaceAABox(uint32 Surface);
|
||||
SSurface* GetSurface(uint32 Surface);
|
||||
virtual void ClearGLBuffer() = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "Core/Render/CRenderer.h"
|
||||
#include "Core/Resource/Area/CGameArea.h"
|
||||
#include "Core/OpenGL/GLCommon.h"
|
||||
#include <Common/AssertMacro.h>
|
||||
#include <Common/Macros.h>
|
||||
|
||||
CModel::CModel(CResourceEntry *pEntry /*= 0*/)
|
||||
: CBasicModel(pEntry)
|
||||
@@ -25,7 +25,7 @@ CModel::CModel(CMaterialSet *pSet, bool OwnsMatSet)
|
||||
CModel::~CModel()
|
||||
{
|
||||
if (mHasOwnMaterials)
|
||||
for (u32 iMat = 0; iMat < mMaterialSets.size(); iMat++)
|
||||
for (uint32 iMat = 0; iMat < mMaterialSets.size(); iMat++)
|
||||
delete mMaterialSets[iMat];
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ CDependencyTree* CModel::BuildDependencyTree() const
|
||||
CDependencyTree *pTree = new CDependencyTree();
|
||||
std::set<CAssetID> TextureIDs;
|
||||
|
||||
for (u32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
|
||||
for (uint32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
|
||||
{
|
||||
CMaterialSet *pSet = mMaterialSets[iSet];
|
||||
pSet->GetUsedTextureIDs(TextureIDs);
|
||||
@@ -56,21 +56,21 @@ void CModel::BufferGL()
|
||||
|
||||
mSurfaceIndexBuffers.resize(mSurfaces.size());
|
||||
|
||||
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
{
|
||||
SSurface *pSurf = mSurfaces[iSurf];
|
||||
|
||||
u16 VBOStartOffset = (u16) mVBO.Size();
|
||||
mVBO.Reserve((u16) pSurf->VertexCount);
|
||||
uint16 VBOStartOffset = (uint16) mVBO.Size();
|
||||
mVBO.Reserve((uint16) pSurf->VertexCount);
|
||||
|
||||
for (u32 iPrim = 0; iPrim < pSurf->Primitives.size(); iPrim++)
|
||||
for (uint32 iPrim = 0; iPrim < pSurf->Primitives.size(); iPrim++)
|
||||
{
|
||||
SSurface::SPrimitive *pPrim = &pSurf->Primitives[iPrim];
|
||||
CIndexBuffer *pIBO = InternalGetIBO(iSurf, pPrim->Type);
|
||||
pIBO->Reserve(pPrim->Vertices.size() + 1); // Allocate enough space for this primitive, plus the restart index
|
||||
|
||||
std::vector<u16> Indices(pPrim->Vertices.size());
|
||||
for (u32 iVert = 0; iVert < pPrim->Vertices.size(); iVert++)
|
||||
std::vector<uint16> Indices(pPrim->Vertices.size());
|
||||
for (uint32 iVert = 0; iVert < pPrim->Vertices.size(); iVert++)
|
||||
Indices[iVert] = mVBO.AddIfUnique(pPrim->Vertices[iVert], VBOStartOffset);
|
||||
|
||||
// then add the indices to the IBO. We convert some primitives to strips to minimize draw calls.
|
||||
@@ -92,7 +92,7 @@ void CModel::BufferGL()
|
||||
}
|
||||
}
|
||||
|
||||
for (u32 iIBO = 0; iIBO < mSurfaceIndexBuffers[iSurf].size(); iIBO++)
|
||||
for (uint32 iIBO = 0; iIBO < mSurfaceIndexBuffers[iSurf].size(); iIBO++)
|
||||
mSurfaceIndexBuffers[iSurf][iIBO].Buffer();
|
||||
}
|
||||
|
||||
@@ -102,11 +102,11 @@ void CModel::BufferGL()
|
||||
|
||||
void CModel::GenerateMaterialShaders()
|
||||
{
|
||||
for (u32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
|
||||
for (uint32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
|
||||
{
|
||||
CMaterialSet *pSet = mMaterialSets[iSet];
|
||||
|
||||
for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
|
||||
for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
|
||||
{
|
||||
CMaterial *pMat = pSet->MaterialByIndex(iMat);
|
||||
pMat->GenerateShader(false);
|
||||
@@ -121,14 +121,14 @@ void CModel::ClearGLBuffer()
|
||||
mBuffered = false;
|
||||
}
|
||||
|
||||
void CModel::Draw(FRenderOptions Options, u32 MatSet)
|
||||
void CModel::Draw(FRenderOptions Options, uint32 MatSet)
|
||||
{
|
||||
if (!mBuffered) BufferGL();
|
||||
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
DrawSurface(Options, iSurf, MatSet);
|
||||
}
|
||||
|
||||
void CModel::DrawSurface(FRenderOptions Options, u32 Surface, u32 MatSet)
|
||||
void CModel::DrawSurface(FRenderOptions Options, uint32 Surface, uint32 MatSet)
|
||||
{
|
||||
if (!mBuffered) BufferGL();
|
||||
|
||||
@@ -152,7 +152,7 @@ void CModel::DrawSurface(FRenderOptions Options, u32 Surface, u32 MatSet)
|
||||
mVBO.Bind();
|
||||
glLineWidth(1.f);
|
||||
|
||||
for (u32 iIBO = 0; iIBO < mSurfaceIndexBuffers[Surface].size(); iIBO++)
|
||||
for (uint32 iIBO = 0; iIBO < mSurfaceIndexBuffers[Surface].size(); iIBO++)
|
||||
{
|
||||
CIndexBuffer *pIBO = &mSurfaceIndexBuffers[Surface][iIBO];
|
||||
pIBO->DrawElements();
|
||||
@@ -173,7 +173,7 @@ void CModel::DrawWireframe(FRenderOptions Options, CColor WireColor /*= CColor::
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
|
||||
// Draw surfaces
|
||||
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
DrawSurface(Options, iSurf, 0);
|
||||
|
||||
// Cleanup
|
||||
@@ -198,11 +198,11 @@ void CModel::SetSkin(CSkin *pSkin)
|
||||
else if (!pSkin && mVBO.VertexDesc().HasAnyFlags(kBoneFlags))
|
||||
mVBO.SetVertexDesc(mVBO.VertexDesc() & ~kBoneFlags);
|
||||
|
||||
for (u32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
|
||||
for (uint32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
|
||||
{
|
||||
CMaterialSet *pSet = mMaterialSets[iSet];
|
||||
|
||||
for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
|
||||
for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
|
||||
{
|
||||
CMaterial *pMat = pSet->MaterialByIndex(iMat);
|
||||
FVertexDescription VtxDesc = pMat->VtxDesc();
|
||||
@@ -223,23 +223,23 @@ void CModel::SetSkin(CSkin *pSkin)
|
||||
}
|
||||
}
|
||||
|
||||
u32 CModel::GetMatSetCount()
|
||||
uint32 CModel::GetMatSetCount()
|
||||
{
|
||||
return mMaterialSets.size();
|
||||
}
|
||||
|
||||
u32 CModel::GetMatCount()
|
||||
uint32 CModel::GetMatCount()
|
||||
{
|
||||
if (mMaterialSets.empty()) return 0;
|
||||
else return mMaterialSets[0]->NumMaterials();
|
||||
}
|
||||
|
||||
CMaterialSet* CModel::GetMatSet(u32 MatSet)
|
||||
CMaterialSet* CModel::GetMatSet(uint32 MatSet)
|
||||
{
|
||||
return mMaterialSets[MatSet];
|
||||
}
|
||||
|
||||
CMaterial* CModel::GetMaterialByIndex(u32 MatSet, u32 Index)
|
||||
CMaterial* CModel::GetMaterialByIndex(uint32 MatSet, uint32 Index)
|
||||
{
|
||||
if (MatSet >= mMaterialSets.size())
|
||||
MatSet = mMaterialSets.size() - 1;
|
||||
@@ -250,38 +250,38 @@ CMaterial* CModel::GetMaterialByIndex(u32 MatSet, u32 Index)
|
||||
return mMaterialSets[MatSet]->MaterialByIndex(Index);
|
||||
}
|
||||
|
||||
CMaterial* CModel::GetMaterialBySurface(u32 MatSet, u32 Surface)
|
||||
CMaterial* CModel::GetMaterialBySurface(uint32 MatSet, uint32 Surface)
|
||||
{
|
||||
return GetMaterialByIndex(MatSet, mSurfaces[Surface]->MaterialID);
|
||||
}
|
||||
|
||||
bool CModel::HasTransparency(u32 MatSet)
|
||||
bool CModel::HasTransparency(uint32 MatSet)
|
||||
{
|
||||
if (MatSet >= mMaterialSets.size())
|
||||
MatSet = mMaterialSets.size() - 1;
|
||||
|
||||
for (u32 iMat = 0; iMat < mMaterialSets[MatSet]->NumMaterials(); iMat++)
|
||||
for (uint32 iMat = 0; iMat < mMaterialSets[MatSet]->NumMaterials(); iMat++)
|
||||
if (mMaterialSets[MatSet]->MaterialByIndex(iMat)->Options() & CMaterial::eTransparent ) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CModel::IsSurfaceTransparent(u32 Surface, u32 MatSet)
|
||||
bool CModel::IsSurfaceTransparent(uint32 Surface, uint32 MatSet)
|
||||
{
|
||||
if (MatSet >= mMaterialSets.size())
|
||||
MatSet = mMaterialSets.size() - 1;
|
||||
|
||||
u32 matID = mSurfaces[Surface]->MaterialID;
|
||||
uint32 matID = mSurfaces[Surface]->MaterialID;
|
||||
return (mMaterialSets[MatSet]->MaterialByIndex(matID)->Options() & CMaterial::eTransparent) != 0;
|
||||
}
|
||||
|
||||
bool CModel::IsLightmapped() const
|
||||
{
|
||||
for (u32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
|
||||
for (uint32 iSet = 0; iSet < mMaterialSets.size(); iSet++)
|
||||
{
|
||||
CMaterialSet *pSet = mMaterialSets[iSet];
|
||||
|
||||
for (u32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
|
||||
for (uint32 iMat = 0; iMat < pSet->NumMaterials(); iMat++)
|
||||
{
|
||||
CMaterial *pMat = pSet->MaterialByIndex(iMat);
|
||||
if (pMat->Options().HasFlag(CMaterial::eLightmap))
|
||||
@@ -291,12 +291,12 @@ bool CModel::IsLightmapped() const
|
||||
return false;
|
||||
}
|
||||
|
||||
CIndexBuffer* CModel::InternalGetIBO(u32 Surface, EGXPrimitiveType Primitive)
|
||||
CIndexBuffer* CModel::InternalGetIBO(uint32 Surface, EGXPrimitiveType Primitive)
|
||||
{
|
||||
std::vector<CIndexBuffer> *pIBOs = &mSurfaceIndexBuffers[Surface];
|
||||
GLenum Type = GXPrimToGLPrim(Primitive);
|
||||
|
||||
for (u32 iIBO = 0; iIBO < pIBOs->size(); iIBO++)
|
||||
for (uint32 iIBO = 0; iIBO < pIBOs->size(); iIBO++)
|
||||
{
|
||||
if ((*pIBOs)[iIBO].GetPrimitiveType() == Type)
|
||||
return &(*pIBOs)[iIBO];
|
||||
|
||||
@@ -29,24 +29,24 @@ public:
|
||||
void BufferGL();
|
||||
void GenerateMaterialShaders();
|
||||
void ClearGLBuffer();
|
||||
void Draw(FRenderOptions Options, u32 MatSet);
|
||||
void DrawSurface(FRenderOptions Options, u32 Surface, u32 MatSet);
|
||||
void Draw(FRenderOptions Options, uint32 MatSet);
|
||||
void DrawSurface(FRenderOptions Options, uint32 Surface, uint32 MatSet);
|
||||
void DrawWireframe(FRenderOptions Options, CColor WireColor = CColor::skWhite);
|
||||
void SetSkin(CSkin *pSkin);
|
||||
|
||||
u32 GetMatSetCount();
|
||||
u32 GetMatCount();
|
||||
CMaterialSet* GetMatSet(u32 MatSet);
|
||||
CMaterial* GetMaterialByIndex(u32 MatSet, u32 Index);
|
||||
CMaterial* GetMaterialBySurface(u32 MatSet, u32 Surface);
|
||||
bool HasTransparency(u32 MatSet);
|
||||
bool IsSurfaceTransparent(u32 Surface, u32 MatSet);
|
||||
uint32 GetMatSetCount();
|
||||
uint32 GetMatCount();
|
||||
CMaterialSet* GetMatSet(uint32 MatSet);
|
||||
CMaterial* GetMaterialByIndex(uint32 MatSet, uint32 Index);
|
||||
CMaterial* GetMaterialBySurface(uint32 MatSet, uint32 Surface);
|
||||
bool HasTransparency(uint32 MatSet);
|
||||
bool IsSurfaceTransparent(uint32 Surface, uint32 MatSet);
|
||||
bool IsLightmapped() const;
|
||||
|
||||
inline bool IsSkinned() const { return (mpSkin != nullptr); }
|
||||
|
||||
private:
|
||||
CIndexBuffer* InternalGetIBO(u32 Surface, EGXPrimitiveType Primitive);
|
||||
CIndexBuffer* InternalGetIBO(uint32 Surface, EGXPrimitiveType Primitive);
|
||||
};
|
||||
|
||||
#endif // MODEL_H
|
||||
|
||||
@@ -37,22 +37,22 @@ void CStaticModel::BufferGL()
|
||||
mVBO.Clear();
|
||||
mIBOs.clear();
|
||||
|
||||
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
{
|
||||
SSurface *pSurf = mSurfaces[iSurf];
|
||||
|
||||
u16 VBOStartOffset = (u16) mVBO.Size();
|
||||
mVBO.Reserve((u16) pSurf->VertexCount);
|
||||
uint16 VBOStartOffset = (uint16) mVBO.Size();
|
||||
mVBO.Reserve((uint16) pSurf->VertexCount);
|
||||
|
||||
for (u32 iPrim = 0; iPrim < pSurf->Primitives.size(); iPrim++)
|
||||
for (uint32 iPrim = 0; iPrim < pSurf->Primitives.size(); iPrim++)
|
||||
{
|
||||
SSurface::SPrimitive *pPrim = &pSurf->Primitives[iPrim];
|
||||
CIndexBuffer *pIBO = InternalGetIBO(pPrim->Type);
|
||||
pIBO->Reserve(pPrim->Vertices.size() + 1); // Allocate enough space for this primitive, plus the restart index
|
||||
|
||||
// Next step: add new vertices to the VBO and create a small index buffer for the current primitive
|
||||
std::vector<u16> Indices(pPrim->Vertices.size());
|
||||
for (u32 iVert = 0; iVert < pPrim->Vertices.size(); iVert++)
|
||||
std::vector<uint16> Indices(pPrim->Vertices.size());
|
||||
for (uint32 iVert = 0; iVert < pPrim->Vertices.size(); iVert++)
|
||||
Indices[iVert] = mVBO.AddIfUnique(pPrim->Vertices[iVert], VBOStartOffset);
|
||||
|
||||
// then add the indices to the IBO. We convert some primitives to strips to minimize draw calls.
|
||||
@@ -76,15 +76,15 @@ void CStaticModel::BufferGL()
|
||||
|
||||
// Make sure the number of submesh offset vectors matches the number of IBOs, then add the offsets
|
||||
while (mIBOs.size() > mSurfaceEndOffsets.size())
|
||||
mSurfaceEndOffsets.emplace_back(std::vector<u32>(mSurfaces.size()));
|
||||
mSurfaceEndOffsets.emplace_back(std::vector<uint32>(mSurfaces.size()));
|
||||
|
||||
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||
for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||
mSurfaceEndOffsets[iIBO][iSurf] = mIBOs[iIBO].GetSize();
|
||||
}
|
||||
|
||||
mVBO.Buffer();
|
||||
|
||||
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||
for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||
mIBOs[iIBO].Buffer();
|
||||
|
||||
mBuffered = true;
|
||||
@@ -115,7 +115,7 @@ void CStaticModel::Draw(FRenderOptions Options)
|
||||
mVBO.Bind();
|
||||
glLineWidth(1.f);
|
||||
|
||||
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||
for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||
{
|
||||
CIndexBuffer *pIBO = &mIBOs[iIBO];
|
||||
pIBO->Bind();
|
||||
@@ -127,7 +127,7 @@ void CStaticModel::Draw(FRenderOptions Options)
|
||||
mVBO.Unbind();
|
||||
}
|
||||
|
||||
void CStaticModel::DrawSurface(FRenderOptions Options, u32 Surface)
|
||||
void CStaticModel::DrawSurface(FRenderOptions Options, uint32 Surface)
|
||||
{
|
||||
if (!mBuffered) BufferGL();
|
||||
|
||||
@@ -135,12 +135,12 @@ void CStaticModel::DrawSurface(FRenderOptions Options, u32 Surface)
|
||||
glLineWidth(1.f);
|
||||
if ((Options & eNoMaterialSetup) == 0) mpMaterial->SetCurrent(Options);
|
||||
|
||||
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||
for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||
{
|
||||
// Since there is a shared IBO for every mesh, we need two things to draw a single one: an offset and a size
|
||||
u32 Offset = 0;
|
||||
uint32 Offset = 0;
|
||||
if (Surface > 0) Offset = mSurfaceEndOffsets[iIBO][Surface - 1];
|
||||
u32 Size = mSurfaceEndOffsets[iIBO][Surface] - Offset;
|
||||
uint32 Size = mSurfaceEndOffsets[iIBO][Surface] - Offset;
|
||||
|
||||
if (!Size) continue; // The chosen submesh doesn't use this IBO
|
||||
|
||||
@@ -164,7 +164,7 @@ void CStaticModel::DrawWireframe(FRenderOptions Options, CColor WireColor /*= CC
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
|
||||
// Draw surfaces
|
||||
for (u32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
for (uint32 iSurf = 0; iSurf < mSurfaces.size(); iSurf++)
|
||||
DrawSurface(Options, iSurf);
|
||||
|
||||
// Cleanup
|
||||
@@ -196,7 +196,7 @@ CIndexBuffer* CStaticModel::InternalGetIBO(EGXPrimitiveType Primitive)
|
||||
{
|
||||
GLenum type = GXPrimToGLPrim(Primitive);
|
||||
|
||||
for (u32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||
for (uint32 iIBO = 0; iIBO < mIBOs.size(); iIBO++)
|
||||
{
|
||||
if (mIBOs[iIBO].GetPrimitiveType() == type)
|
||||
return &mIBOs[iIBO];
|
||||
|
||||
@@ -12,7 +12,7 @@ class CStaticModel : public CBasicModel
|
||||
{
|
||||
CMaterial *mpMaterial;
|
||||
std::vector<CIndexBuffer> mIBOs;
|
||||
std::vector<std::vector<u32>> mSurfaceEndOffsets;
|
||||
std::vector<std::vector<uint32>> mSurfaceEndOffsets;
|
||||
bool mTransparent;
|
||||
|
||||
public:
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
void GenerateMaterialShaders();
|
||||
void ClearGLBuffer();
|
||||
void Draw(FRenderOptions Options);
|
||||
void DrawSurface(FRenderOptions Options, u32 Surface);
|
||||
void DrawSurface(FRenderOptions Options, uint32 Surface);
|
||||
void DrawWireframe(FRenderOptions Options, CColor WireColor = CColor::skWhite);
|
||||
|
||||
CMaterial* GetMaterial();
|
||||
|
||||
@@ -2,25 +2,25 @@
|
||||
#define CVERTEX_H
|
||||
|
||||
#include <Common/CColor.h>
|
||||
#include <Math/CVector2f.h>
|
||||
#include <Math/CVector3f.h>
|
||||
#include <Common/Math/CVector2f.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <array>
|
||||
|
||||
typedef std::array<u8, 4> TBoneIndices;
|
||||
typedef std::array<uint8, 4> TBoneIndices;
|
||||
typedef std::array<float, 4> TBoneWeights;
|
||||
|
||||
class CVertex
|
||||
{
|
||||
public:
|
||||
u32 ArrayPosition; // Position of this vertex in the input model file.
|
||||
// This is needed to resave without breaking rigging.
|
||||
uint32 ArrayPosition; // Position of this vertex in the input model file.
|
||||
// This is needed to resave without breaking rigging.
|
||||
CVector3f Position;
|
||||
CVector3f Normal;
|
||||
CColor Color[2];
|
||||
CVector2f Tex[8];
|
||||
TBoneIndices BoneIndices;
|
||||
TBoneWeights BoneWeights;
|
||||
u8 MatrixIndices[8];
|
||||
uint8 MatrixIndices[8];
|
||||
|
||||
CVertex() {}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "EVertexAttribute.h"
|
||||
#include <Common/Log.h>
|
||||
|
||||
const u32 gkNumVertexAttribs = 22;
|
||||
const uint32 gkNumVertexAttribs = 22;
|
||||
|
||||
u32 VertexAttributeSize(EVertexAttribute Attrib)
|
||||
uint32 VertexAttributeSize(EVertexAttribute Attrib)
|
||||
{
|
||||
switch (Attrib)
|
||||
{
|
||||
@@ -26,7 +26,7 @@ u32 VertexAttributeSize(EVertexAttribute Attrib)
|
||||
case eBoneIndices:
|
||||
return 0x04;
|
||||
default:
|
||||
Log::Error("AttributeSize(): Unknown vertex attribute: " + TString::FromInt32(Attrib, 0, 10));
|
||||
errorf("AttributeSize(): Unknown vertex attribute: %d", Attrib);
|
||||
return 0x00;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ enum EVertexAttribute
|
||||
};
|
||||
DECLARE_FLAGS(EVertexAttribute, FVertexDescription)
|
||||
|
||||
extern const u32 gkNumVertexAttribs;
|
||||
u32 VertexAttributeSize(EVertexAttribute Attrib);
|
||||
extern const uint32 gkNumVertexAttribs;
|
||||
uint32 VertexAttributeSize(EVertexAttribute Attrib);
|
||||
|
||||
#endif // EVERTEXATTRIBUTE
|
||||
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
#include "SSurface.h"
|
||||
#include "Core/Render/CDrawUtil.h"
|
||||
#include "Core/CRayCollisionTester.h"
|
||||
#include <Math/MathUtil.h>
|
||||
#include <Common/Math/MathUtil.h>
|
||||
|
||||
std::pair<bool,float> SSurface::IntersectsRay(const CRay& rkRay, bool AllowBackfaces, float LineThreshold)
|
||||
{
|
||||
bool Hit = false;
|
||||
float HitDist;
|
||||
|
||||
for (u32 iPrim = 0; iPrim < Primitives.size(); iPrim++)
|
||||
for (uint32 iPrim = 0; iPrim < Primitives.size(); iPrim++)
|
||||
{
|
||||
SPrimitive *pPrim = &Primitives[iPrim];
|
||||
u32 NumVerts = pPrim->Vertices.size();
|
||||
uint32 NumVerts = pPrim->Vertices.size();
|
||||
|
||||
// Triangles
|
||||
if ((pPrim->Type == eGX_Triangles) || (pPrim->Type == eGX_TriangleFan) || (pPrim->Type == eGX_TriangleStrip))
|
||||
{
|
||||
u32 NumTris;
|
||||
uint32 NumTris;
|
||||
|
||||
if (pPrim->Type == eGX_Triangles)
|
||||
NumTris = NumVerts / 3;
|
||||
else
|
||||
NumTris = NumVerts - 2;
|
||||
|
||||
for (u32 iTri = 0; iTri < NumTris; iTri++)
|
||||
for (uint32 iTri = 0; iTri < NumTris; iTri++)
|
||||
{
|
||||
CVector3f VtxA, VtxB, VtxC;
|
||||
|
||||
// Get the three vertices that make up the current tri
|
||||
if (pPrim->Type == eGX_Triangles)
|
||||
{
|
||||
u32 VertIndex = iTri * 3;
|
||||
uint32 VertIndex = iTri * 3;
|
||||
VtxA = pPrim->Vertices[VertIndex].Position;
|
||||
VtxB = pPrim->Vertices[VertIndex+1].Position;
|
||||
VtxC = pPrim->Vertices[VertIndex+2].Position;
|
||||
@@ -77,19 +77,19 @@ std::pair<bool,float> SSurface::IntersectsRay(const CRay& rkRay, bool AllowBackf
|
||||
// Lines
|
||||
if ((pPrim->Type == eGX_Lines) || (pPrim->Type == eGX_LineStrip))
|
||||
{
|
||||
u32 NumLines;
|
||||
uint32 NumLines;
|
||||
|
||||
if (pPrim->Type == eGX_Lines)
|
||||
NumLines = NumVerts / 2;
|
||||
else
|
||||
NumLines = NumVerts - 1;
|
||||
|
||||
for (u32 iLine = 0; iLine < NumLines; iLine++)
|
||||
for (uint32 iLine = 0; iLine < NumLines; iLine++)
|
||||
{
|
||||
CVector3f VtxA, VtxB;
|
||||
|
||||
// Get the two vertices that make up the current line
|
||||
u32 Index = (pPrim->Type == eGX_Lines ? iLine * 2 : iLine);
|
||||
uint32 Index = (pPrim->Type == eGX_Lines ? iLine * 2 : iLine);
|
||||
VtxA = pPrim->Vertices[Index].Position;
|
||||
VtxB = pPrim->Vertices[Index+1].Position;
|
||||
|
||||
|
||||
@@ -5,23 +5,23 @@
|
||||
#include "Core/Resource/CMaterialSet.h"
|
||||
#include "Core/OpenGL/GLCommon.h"
|
||||
#include "Core/SRayIntersection.h"
|
||||
#include <Common/types.h>
|
||||
#include <Math/CAABox.h>
|
||||
#include <Math/CRay.h>
|
||||
#include <Math/CTransform4f.h>
|
||||
#include <Math/CVector3f.h>
|
||||
#include <Common/BasicTypes.h>
|
||||
#include <Common/Math/CAABox.h>
|
||||
#include <Common/Math/CRay.h>
|
||||
#include <Common/Math/CTransform4f.h>
|
||||
#include <Common/Math/CVector3f.h>
|
||||
#include <vector>
|
||||
|
||||
// Should prolly be a class
|
||||
struct SSurface
|
||||
{
|
||||
u32 VertexCount;
|
||||
u32 TriangleCount;
|
||||
uint32 VertexCount;
|
||||
uint32 TriangleCount;
|
||||
CAABox AABox;
|
||||
CVector3f CenterPoint;
|
||||
u32 MaterialID;
|
||||
uint32 MaterialID;
|
||||
CVector3f ReflectionDirection;
|
||||
u16 MeshID;
|
||||
uint16 MeshID;
|
||||
|
||||
struct SPrimitive
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user