From 6e42f1af3cc59579713feddd8749152a297f8dd8 Mon Sep 17 00:00:00 2001 From: d1str4ught <> Date: Fri, 22 Aug 2025 20:39:23 +0200 Subject: [PATCH] small fixes --- src/EterGrnLib/Mesh.cpp | 2 +- src/EterGrnLib/Model.cpp | 10 +--------- src/EterLib/GrpIndexBuffer.cpp | 3 ++- src/EterLib/GrpVertexBuffer.cpp | 5 +---- src/EterLib/GrpVertexBufferDynamic.cpp | 2 +- 5 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/EterGrnLib/Mesh.cpp b/src/EterGrnLib/Mesh.cpp index c0b2736..54b4228 100644 --- a/src/EterGrnLib/Mesh.cpp +++ b/src/EterGrnLib/Mesh.cpp @@ -56,7 +56,7 @@ void CGrannyMesh::DeformPNTVertices(void * dstBaseVertices, D3DXMATRIX * boneMat int vtxCount = GrannyGetMeshVertexCount(pgrnMesh); // WORK - int * boneIndices = (int*)GrannyGetMeshBindingToBoneIndices(pgrnMeshBinding); + granny_int32x * boneIndices = (granny_int32x*)GrannyGetMeshBindingToBoneIndices(pgrnMeshBinding); // END_OF_WORK GrannyDeformVertices( diff --git a/src/EterGrnLib/Model.cpp b/src/EterGrnLib/Model.cpp index a43f584..6261be5 100644 --- a/src/EterGrnLib/Model.cpp +++ b/src/EterGrnLib/Model.cpp @@ -196,15 +196,8 @@ bool CGrannyModel::LoadMeshs() } m_bHaveBlendThing |= rMesh.HaveBlendThing(); - granny_int32x grni32xTypeCount = GrannyGetTotalTypeSize(pgrnMesh->PrimaryVertexData->VertexType) / sizeof(granny_vertex_data); - int i = 0; - while (i < grni32xTypeCount) + for (int i = 0; pgrnMesh->PrimaryVertexData->VertexType[i].Name != nullptr; ++i) { - if (NULL == pgrnMesh->PrimaryVertexData->VertexType[i].Name || 0 == strlen(pgrnMesh->PrimaryVertexData->VertexType[i].Name)) - { - ++i; - continue; - } if ( 0 == strcmp(pgrnMesh->PrimaryVertexData->VertexType[i].Name, GrannyVertexPositionName) ) m_dwFvF |= D3DFVF_XYZ; else if ( 0 == strcmp(pgrnMesh->PrimaryVertexData->VertexType[i].Name, GrannyVertexNormalName) ) @@ -213,7 +206,6 @@ bool CGrannyModel::LoadMeshs() m_dwFvF |= D3DFVF_TEX1; else if ( 0 == strcmp(pgrnMesh->PrimaryVertexData->VertexType[i].Name, GrannyVertexTextureCoordinatesName"1") ) m_dwFvF |= D3DFVF_TEX2; - ++i; } vtxPos += GrannyGetMeshVertexCount(pgrnMesh); diff --git a/src/EterLib/GrpIndexBuffer.cpp b/src/EterLib/GrpIndexBuffer.cpp index f993994..66996f4 100644 --- a/src/EterLib/GrpIndexBuffer.cpp +++ b/src/EterLib/GrpIndexBuffer.cpp @@ -125,7 +125,8 @@ bool CGraphicIndexBuffer::Create(int idxCount, D3DFORMAT d3dFmt) Destroy(); m_iidxCount = idxCount; - m_dwBufferSize = sizeof(WORD) * idxCount; + UINT bytesPerIndex = (d3dFmt == D3DFMT_INDEX32) ? 4u : 2u; + m_dwBufferSize = bytesPerIndex * idxCount; m_d3dFmt = d3dFmt; return CreateDeviceObjects(); diff --git a/src/EterLib/GrpVertexBuffer.cpp b/src/EterLib/GrpVertexBuffer.cpp index 6ddf5cf..f3d9fe2 100644 --- a/src/EterLib/GrpVertexBuffer.cpp +++ b/src/EterLib/GrpVertexBuffer.cpp @@ -61,10 +61,7 @@ bool CGraphicVertexBuffer::Unlock() const bool CGraphicVertexBuffer::IsEmpty() const { - if (m_lpd3dVB) - return true; - else - return false; + return m_lpd3dVB == nullptr; } bool CGraphicVertexBuffer::LockDynamic(void** pretVertices) diff --git a/src/EterLib/GrpVertexBufferDynamic.cpp b/src/EterLib/GrpVertexBufferDynamic.cpp index 1b2a28d..bbe79e3 100644 --- a/src/EterLib/GrpVertexBufferDynamic.cpp +++ b/src/EterLib/GrpVertexBufferDynamic.cpp @@ -15,7 +15,7 @@ bool CDynamicVertexBuffer::Create(int vtxCount, int fvf) m_vtxCount = vtxCount; m_fvf = fvf; - return CGraphicVertexBuffer::Create(m_vtxCount, m_fvf, D3DUSAGE_DYNAMIC, D3DPOOL_SYSTEMMEM); + return CGraphicVertexBuffer::Create(m_vtxCount, m_fvf, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DPOOL_DEFAULT); } CDynamicVertexBuffer::CDynamicVertexBuffer()