free memory for btShapeHulls, keep track of it in GL_ShapeDrawer.
move btShapeHull and btConvexHull into its own library in Extras/ConvexHull (it allocates memory using mem/delete and refactoring into using btAlignedAlloc/Free takes too much time) fix heightfield / btOptimizedBvh for quantization, so that raycast can use quantized aabb (clamp up for maxima and down for minima) work-in-progress (update projectfiles etc)
This commit is contained in:
@@ -40,7 +40,8 @@ subject to the following restrictions:
|
||||
#include "BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btUniformScalingShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btStaticPlaneShape.h"
|
||||
#include "BulletCollision/CollisionShapes/btShapeHull.h"
|
||||
///
|
||||
#include "btShapeHull.h"
|
||||
|
||||
#include "LinearMath/btTransformUtil.h"
|
||||
|
||||
@@ -470,7 +471,12 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
||||
if (!shape->getUserPointer())
|
||||
{
|
||||
//create a hull approximation
|
||||
btShapeHull* hull = new btShapeHull(convexShape);
|
||||
void* mem = btAlignedAlloc(sizeof(btShapeHull),16);
|
||||
btShapeHull* hull = new(mem) btShapeHull(convexShape);
|
||||
|
||||
///cleanup memory
|
||||
m_shapeHulls.push_back(hull);
|
||||
|
||||
btScalar margin = shape->getMargin();
|
||||
hull->buildHull(margin);
|
||||
convexShape->setUserPointer(hull);
|
||||
@@ -655,3 +661,22 @@ void GL_ShapeDrawer::drawOpenGL(btScalar* m, const btCollisionShape* shape, cons
|
||||
glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
|
||||
GL_ShapeDrawer::GL_ShapeDrawer()
|
||||
{
|
||||
}
|
||||
|
||||
GL_ShapeDrawer::~GL_ShapeDrawer()
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<m_shapeHulls.size();i++)
|
||||
{
|
||||
btShapeHull* hull = m_shapeHulls[i];
|
||||
hull->~btShapeHull();
|
||||
btAlignedFree(hull);
|
||||
m_shapeHulls[i] = 0;
|
||||
}
|
||||
m_shapeHulls.clear();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user