fix overflow visual shape in COLLADA .dae file importer.
This commit is contained in:
@@ -28,6 +28,7 @@ subject to the following restrictions:
|
|||||||
#include "btMatrix4x4.h"
|
#include "btMatrix4x4.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_VISUAL_SHAPES 512
|
||||||
|
|
||||||
|
|
||||||
struct VertexSource
|
struct VertexSource
|
||||||
@@ -288,6 +289,8 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray<GLInstanceGr
|
|||||||
}//for each mesh
|
}//for each mesh
|
||||||
|
|
||||||
int shapeIndex = visualShapes.size();
|
int shapeIndex = visualShapes.size();
|
||||||
|
if (shapeIndex<MAX_VISUAL_SHAPES)
|
||||||
|
{
|
||||||
GLInstanceGraphicsShape& visualShape = visualShapes.expand();
|
GLInstanceGraphicsShape& visualShape = visualShapes.expand();
|
||||||
{
|
{
|
||||||
visualShape.m_vertices = new b3AlignedObjectArray<GLInstanceVertex>;
|
visualShape.m_vertices = new b3AlignedObjectArray<GLInstanceVertex>;
|
||||||
@@ -323,7 +326,10 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray<GLInstanceGr
|
|||||||
}
|
}
|
||||||
//b3Printf("geometry name=%s\n",geometryName);
|
//b3Printf("geometry name=%s\n",geometryName);
|
||||||
name2Shape.insert(geometryName,shapeIndex);
|
name2Shape.insert(geometryName,shapeIndex);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
b3Warning("DAE exceeds number of visual shapes (%d/%d)",shapeIndex, MAX_VISUAL_SHAPES);
|
||||||
|
}
|
||||||
|
|
||||||
}//for each geometry
|
}//for each geometry
|
||||||
}
|
}
|
||||||
@@ -557,7 +563,7 @@ void LoadMeshFromCollada(const char* relativeFileName, btAlignedObjectArray<GLIn
|
|||||||
// GLInstanceGraphicsShape* instance = 0;
|
// GLInstanceGraphicsShape* instance = 0;
|
||||||
|
|
||||||
//usually COLLADA files don't have that many visual geometries/shapes
|
//usually COLLADA files don't have that many visual geometries/shapes
|
||||||
visualShapes.reserve(32);
|
visualShapes.reserve(MAX_VISUAL_SHAPES);
|
||||||
|
|
||||||
float extraScaling = 1;//0.01;
|
float extraScaling = 1;//0.01;
|
||||||
btHashMap<btHashString, int> name2ShapeIndex;
|
btHashMap<btHashString, int> name2ShapeIndex;
|
||||||
|
|||||||
Reference in New Issue
Block a user