mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-26 02:20:54 +00:00
Fix the bug that caused the shape exporter to crash
This commit is contained in:
parent
aaad67a5e5
commit
ad40eb6450
2 changed files with 6 additions and 2 deletions
|
@ -791,17 +791,20 @@ void CMeshMultiLod::compileCoarseMeshes()
|
||||||
{
|
{
|
||||||
slotRef.CoarseTriangles.resize(slotRef.CoarseNumTris * 3);
|
slotRef.CoarseTriangles.resize(slotRef.CoarseNumTris * 3);
|
||||||
TCoarseMeshIndexType *dstPtr= &slotRef.CoarseTriangles[0];
|
TCoarseMeshIndexType *dstPtr= &slotRef.CoarseTriangles[0];
|
||||||
|
uint totalTris = 0;
|
||||||
for(uint i=0;i<meshGeom->getNbRdrPass(0);i++)
|
for(uint i=0;i<meshGeom->getNbRdrPass(0);i++)
|
||||||
{
|
{
|
||||||
const CIndexBuffer &pb= meshGeom->getRdrPassPrimitiveBlock(0, i);
|
const CIndexBuffer &pb= meshGeom->getRdrPassPrimitiveBlock(0, i);
|
||||||
CIndexBufferRead ibaRead;
|
CIndexBufferRead ibaRead;
|
||||||
pb.lock (ibaRead);
|
pb.lock (ibaRead);
|
||||||
uint numTris= pb.getNumIndexes()/3;
|
uint numTris= pb.getNumIndexes()/3;
|
||||||
|
totalTris += numTris;
|
||||||
if (pb.getFormat() == CIndexBuffer::Indices16)
|
if (pb.getFormat() == CIndexBuffer::Indices16)
|
||||||
{
|
{
|
||||||
if (sizeof(TCoarseMeshIndexType) == sizeof(uint16))
|
if (sizeof(TCoarseMeshIndexType) == sizeof(uint16))
|
||||||
{
|
{
|
||||||
memcpy(dstPtr, (uint16 *) ibaRead.getPtr(), numTris*3*sizeof(uint16));
|
memcpy(dstPtr, (uint16 *) ibaRead.getPtr(), numTris*3*sizeof(uint16));
|
||||||
|
dstPtr+= numTris*3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -820,6 +823,7 @@ void CMeshMultiLod::compileCoarseMeshes()
|
||||||
if (sizeof(TCoarseMeshIndexType) == sizeof(uint32))
|
if (sizeof(TCoarseMeshIndexType) == sizeof(uint32))
|
||||||
{
|
{
|
||||||
memcpy(dstPtr, (uint32 *) ibaRead.getPtr(), numTris*3*sizeof(uint32));
|
memcpy(dstPtr, (uint32 *) ibaRead.getPtr(), numTris*3*sizeof(uint32));
|
||||||
|
dstPtr+= numTris*3;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -836,8 +840,8 @@ void CMeshMultiLod::compileCoarseMeshes()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dstPtr+= numTris*3;
|
|
||||||
}
|
}
|
||||||
|
nlassert(totalTris == slotRef.CoarseNumTris);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,7 +142,7 @@ bool CNelExport::exportMesh (const char *sPath, INode& node, TimeValue time)
|
||||||
{
|
{
|
||||||
bool tempBRet = bRet;
|
bool tempBRet = bRet;
|
||||||
bRet = false;
|
bRet = false;
|
||||||
// delete pShape; // FIXME: there is a delete bug with CMeshMultiLod exported from max!!!
|
delete pShape;
|
||||||
bRet = tempBRet;
|
bRet = tempBRet;
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
|
|
Loading…
Reference in a new issue