Skip to content

Commit

Permalink
Add support 32 bits mesh indices for AE
Browse files Browse the repository at this point in the history
  • Loading branch information
ForserX committed Sep 27, 2024
1 parent 010be95 commit fee32c2
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
7 changes: 4 additions & 3 deletions src/Editors/xrECore/Editor/ExportObjectOGF.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ struct SOGFVert{
}
};

struct SOGFFace{
WORD v[3];
struct SOGFFace
{
u32 v[3];
};

using OGFVertVec = xr_vector<SOGFVert>;
Expand Down Expand Up @@ -94,7 +95,7 @@ class CObjectOGFCollectorPacked
return true;
}
SOGFFace F;
u16 v;
u32 v;
v = VPack(v0); if (0xffff==v) return false; F.v[0] = v;
v = VPack(v1); if (0xffff==v) return false; F.v[1] = v;
v = VPack(v2); if (0xffff==v) return false; F.v[2] = v;
Expand Down
4 changes: 2 additions & 2 deletions src/Editors/xrECore/Editor/ExportObjectOGFCalculateTB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ IC void set_vertex(SOGFVert& out_vertex, const SOGFVert& in_old_vertex, const Me
out_vertex.B.set(cv_vector(binormal, in_vertex.binormal));
}

IC WORD& face_vertex(SOGFFace& F, u32 vertex_index)
IC u32& face_vertex(SOGFFace& F, u32 vertex_index)
{
VERIFY(vertex_index < 3);
return F.v[vertex_index];
}

IC const WORD& face_vertex(const SOGFFace& F, u32 vertex_index)
IC const u32& face_vertex(const SOGFFace& F, u32 vertex_index)
{
VERIFY(vertex_index < 3);
return F.v[vertex_index];
Expand Down
32 changes: 13 additions & 19 deletions src/Editors/xrECore/Editor/ExportSkeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ECORE_API BOOL g_force16BitTransformQuant = TRUE;
ECORE_API BOOL g_force32BitTransformQuant = FALSE;
ECORE_API float g_EpsSkelPositionDelta = EPS_L;

u16 CSkeletonCollectorPacked::VPack(SSkelVert& V)
u32 CSkeletonCollectorPacked::VPack(SSkelVert& V)
{
u32 P = 0xffffffff;

Expand Down Expand Up @@ -78,8 +78,9 @@ u16 CSkeletonCollectorPacked::VPack(SSkelVert& V)
if ((iyE != iy) && (izE != iz)) m_VM[ix][iyE][izE].push_back(P);
if ((ixE != ix) && (iyE != iy) && (izE != iz)) m_VM[ixE][iyE][izE].push_back(P);
}
VERIFY(P < u16(-1));
return (u16)P;

VERIFY(P < u32(-1));
return P;
}

CSkeletonCollectorPacked::CSkeletonCollectorPacked(const Fbox& _bb, int apx_vertices, int apx_faces)
Expand Down Expand Up @@ -439,14 +440,11 @@ void CExportSkeleton::SSplit::MakeProgressive()

void CExportSkeleton::SSplit::MakeStripify()
{
// int ccc = xrSimulate ((u16*)&m_Faces.front(),m_Faces.size()*3,24);
// Log("SRC:",ccc);
// alternative stripification - faces
bool NeedSkip = false;
{
DWORD* remap = xr_alloc<DWORD> (m_Faces.size());
HRESULT rhr = D3DXOptimizeFaces (&m_Faces.front(),m_Faces.size(),m_Verts.size(),FALSE,remap);
DWORD* remap = xr_alloc<DWORD>(m_Faces.size());
HRESULT rhr = D3DXOptimizeFaces(&m_Faces.front(), m_Faces.size(), m_Verts.size(), TRUE, remap);

if (rhr == S_OK)
{
SkelFaceVec _source = m_Faces;
Expand All @@ -458,17 +456,16 @@ void CExportSkeleton::SSplit::MakeStripify()
{
NeedSkip = true;
}
xr_free (remap);

// int ccc = xrSimulate ((u16*)&m_Faces.front(),m_Faces.size()*3,24);
// Log("X:",ccc);
xr_free(remap);
}

// alternative stripification - vertices
if (!NeedSkip)
{
DWORD* remap = xr_alloc<DWORD> (m_Verts.size());
HRESULT rhr = D3DXOptimizeVertices (&m_Faces.front(),m_Faces.size(),m_Verts.size(),FALSE,remap);
DWORD* remap = xr_alloc<DWORD>(m_Verts.size());
HRESULT rhr = D3DXOptimizeVertices(&m_Faces.front(), m_Faces.size(), m_Verts.size(), TRUE, remap);

if (rhr == S_OK)
{
SkelVertVec _source = m_Verts;
Expand All @@ -481,10 +478,7 @@ void CExportSkeleton::SSplit::MakeStripify()
m_Faces[fit].v[j] = remap[m_Faces[fit].v[j]];
}

xr_free (remap);

// int ccc = xrSimulate ((u16*)&m_Faces.front(),m_Faces.size()*3,24);
// Log("Y:",ccc);
xr_free(remap);
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/Editors/xrECore/Editor/ExportSkeleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ struct ECORE_API SSkelVert: public st_SVert{
}
};

struct ECORE_API SSkelFace{
WORD v[3];
struct ECORE_API SSkelFace
{
u32 v[3];
};

using SkelVertVec = xr_vector<SSkelVert>;
Expand All @@ -85,9 +86,11 @@ class ECORE_API CSkeletonCollectorPacked
U32Vec m_VM[clpSMX+1][clpSMY+1][clpSMZ+1];
Fvector m_VMeps;

u16 VPack(SSkelVert& V);
u32 VPack(SSkelVert& V);

public:
u32 invalid_faces;
u32 invalid_faces;

public:
CSkeletonCollectorPacked (const Fbox &bb, int apx_vertices=5000, int apx_faces=5000);
bool check (SSkelFace& F){
Expand Down
4 changes: 2 additions & 2 deletions src/Editors/xrECore/Editor/ExportSkeletonCalculateTB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ IC void set_vertex( SSkelVert& out_vertex, const SSkelVert& in_old_vertex, cons
}


IC u16 &face_vertex( SSkelFace &F, u32 vertex_index )
IC u32 &face_vertex( SSkelFace &F, u32 vertex_index )
{
VERIFY( vertex_index < 3 );
return F.v[vertex_index];
}

IC const u16 &face_vertex( const SSkelFace &F, u32 vertex_index )
IC const u32 &face_vertex( const SSkelFace &F, u32 vertex_index )
{
VERIFY( vertex_index < 3 );
return F.v[vertex_index];
Expand Down
4 changes: 2 additions & 2 deletions src/utils/xrLC/MeshMenderLayerOGF.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ IC void set_vertex( OGF_Vertex& out_vertex, const OGF_Vertex& in_old_vertex, co
}

/////////////////////////////////////////////////////////////////////////////////////
IC u16 &face_vertex( OGF_Face &F, u32 vertex_index )
IC u32 &face_vertex( OGF_Face &F, u32 vertex_index )
{
VERIFY( vertex_index < 3 );
return F.v[vertex_index];
}

IC const u16 &face_vertex( const OGF_Face &F, u32 vertex_index )
IC const u32& face_vertex( const OGF_Face &F, u32 vertex_index )
{
VERIFY( vertex_index < 3 );
return F.v[vertex_index];
Expand Down

0 comments on commit fee32c2

Please sign in to comment.