|
@@ -508,19 +508,28 @@ int CreateAssetData()
|
|
|
unsigned int nidx;
|
|
|
switch (mesh->mPrimitiveTypes) {
|
|
|
case aiPrimitiveType_POINT:
|
|
|
- nidx = 1;break;
|
|
|
+ nidx = 1;
|
|
|
+ break;
|
|
|
case aiPrimitiveType_LINE:
|
|
|
- nidx = 2;break;
|
|
|
+ nidx = 2;
|
|
|
+ break;
|
|
|
case aiPrimitiveType_TRIANGLE:
|
|
|
- nidx = 3;break;
|
|
|
- default: ai_assert(false);
|
|
|
+ nidx = 3;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ ai_assert(false);
|
|
|
+ break;
|
|
|
};
|
|
|
|
|
|
+ unsigned int numIndices = mesh->mNumFaces * 3;
|
|
|
+ if (0 == numIndices && nidx == 1) {
|
|
|
+ numIndices = mesh->mNumVertices;
|
|
|
+ }
|
|
|
// check whether we can use 16 bit indices
|
|
|
- if (mesh->mNumFaces * 3 >= 65536) {
|
|
|
+ if (numIndices >= 65536) {
|
|
|
// create 32 bit index buffer
|
|
|
if(FAILED( g_piDevice->CreateIndexBuffer( 4 *
|
|
|
- mesh->mNumFaces * nidx,
|
|
|
+ numIndices,
|
|
|
D3DUSAGE_WRITEONLY | dwUsage,
|
|
|
D3DFMT_INDEX32,
|
|
|
D3DPOOL_DEFAULT,
|
|
@@ -546,7 +555,7 @@ int CreateAssetData()
|
|
|
else {
|
|
|
// create 16 bit index buffer
|
|
|
if(FAILED( g_piDevice->CreateIndexBuffer( 2 *
|
|
|
- mesh->mNumFaces * nidx,
|
|
|
+ numIndices,
|
|
|
D3DUSAGE_WRITEONLY | dwUsage,
|
|
|
D3DFMT_INDEX16,
|
|
|
D3DPOOL_DEFAULT,
|