diff --git a/NifMopp.def b/NifMopp.def index ca8e6bf..ee5ef5e 100644 --- a/NifMopp.def +++ b/NifMopp.def @@ -1,5 +1,6 @@ EXPORTS GenerateMoppCode + GenerateMoppCodeWithSubshapes RetrieveMoppCode RetrieveMoppOrigin RetrieveMoppScale diff --git a/NifMopp.dll b/NifMopp.dll index b0c4f3e..de65964 100644 Binary files a/NifMopp.dll and b/NifMopp.dll differ diff --git a/genmopp.cpp b/genmopp.cpp index b6f9c4e..edcb3ad 100644 --- a/genmopp.cpp +++ b/genmopp.cpp @@ -70,7 +70,7 @@ #pragma managed(push, off) #endif -static hkpSimpleMeshShape* ConstructHKMesh( int nVerts, Point3 const* verts, int nTris, Triangle const * tris) +static hkpSimpleMeshShape* ConstructHKMesh( int nVerts, Point3 const* verts, int nTris, Triangle const * tris, int vertOffset = 0) { hkpSimpleMeshShape * storageMeshShape = new hkpSimpleMeshShape( 0.01f ); hkArray &vertices = storageMeshShape->m_vertices; @@ -80,9 +80,9 @@ static hkpSimpleMeshShape* ConstructHKMesh( int nVerts, Point3 const* verts, int for (int i=0;im_data.getSize(); } +static int InternalGenerateCodeWithSubshapes(int nShapes, int *subShapes, int nVerts, Point3 const* verts, int nTris, Triangle const *tris) +{ + int retCode = 0; + InitializeHavok(); + + if (k_phkpMoppCode) + { + k_phkpMoppCode->removeReference(); + k_phkpMoppCode = NULL; + } + + //int voff = 0; + //int toff = 0; + + //hkpShape** shapes = new hkpShape*[nShapes]; + + //for (int i = 0; i= vend || t.b >= vend || t.c >= vend ) + // break; + // tend++; + // } + // hkpSimpleMeshShape* shape = ConstructHKMesh(vend-voff, &verts[voff], tend-toff, &tris[toff], voff); + // shapes[i] = shape; + // voff = vend; + // toff = tend; + //} + + //hkpListShape* list = new hkpListShape(&shapes[0], nShapes); + + hkpSimpleMeshShape* list = ConstructHKMesh(nVerts, verts, nTris, tris); + list->setRadius(0.1000f); + + hkArray &materialIndices = list->m_materialIndices; + + materialIndices.setSize(nShapes); + for (int i = 0; iremoveReference(); + //} + //delete [] shapes; + + list->removeReference(); + + return k_phkpMoppCode->m_data.getSize(); +} + +extern "C" +int __stdcall GenerateMoppCodeWithSubshapes(int nShapes, int *shapeVerts, int nVerts, Point3 const* verts, int nTris, Triangle const *tris) +{ + int retcode = 0; + __try + { + if (nShapes <= 1) + retcode = InternalGenerateCode(nVerts, verts, nTris, tris); + else + retcode = InternalGenerateCodeWithSubshapes(nShapes, shapeVerts, nVerts, verts, nTris, tris); + } + __except( EXCEPTION_EXECUTE_HANDLER ) + { + retcode = -1; + } + return retcode; +} extern "C" int __stdcall GenerateMoppCode(int nVerts, Point3 const* verts, int nTris, Triangle const *tris)