It seems that i can't delete collision shapes when exiting my app. It crashes with "Access violation reading location 0xcdcdcdc9" in btAlignedAllocator.cpp on line 198:
Code: Select all
...
if (ptr) {
real = *((void **)(ptr)-1);
sFreeFunc(real);
}
...Call stack:
Code: Select all
> ShipViewer.dll!btAlignedFreeInternal(void * ptr) Line 198 + 0x3 bytes C++
ShipViewer.dll!btAlignedAllocator<btVector3,16>::deallocate(btVector3 * ptr) Line 90 + 0x9 bytes C++
ShipViewer.dll!btAlignedObjectArray<btVector3>::deallocate() Line 104 C++
ShipViewer.dll!btAlignedObjectArray<btVector3>::clear() Line 169 C++
ShipViewer.dll!btAlignedObjectArray<btVector3>::~btAlignedObjectArray<btVector3>() Line 121 C++
ShipViewer.dll!btConvexHullShape::~btConvexHullShape() + 0x2e bytes C++
ShipViewer.dll!ColliderShape::~ColliderShape() Line 334 + 0x13 bytes C++
ShipViewer.dll!ColliderShape::`scalar deleting destructor'() + 0x2b bytes C++
ShipViewer.dll!BulletMgr::~BulletMgr() Line 49 + 0x3c bytes C++Code: Select all
for(natural i = dynamicsWorld->getNumCollisionObjects() - 1; i >= 0; i--)
dynamicsWorld->removeCollisionObject(dynamicsWorld->getCollisionObjectArray()[i]);
colliderList.RemoveAll(); //does not delete collider objects and just removes them from list. But tried with deletion - same results
delete shapeList.First(); //crash here when deleting at least even one (first) shapeCode: Select all
class ColliderShape:
public btConvexHullShape,
public MapElement<ColliderShape>
{
private:
unsigned long currentKey;
public:
typedef unsigned long KeyType;
ColliderShape(const char *ship, const char *collider, const float *vertices, const unsigned long count):
btConvexHullShape(vertices, count, 12),
currentKey(BuildColliderShapeKey(ship, collider))
{
};
~ColliderShape()
{
};
const KeyType GetKey() const
{
return(currentKey);
};
static unsigned long BuildColliderShapeKey(const char *ship, const char *collider)
{
String<255> text = ship;
text += collider;
return(Text::GetTextHash(text));
};
};For this scene i have only collision objects (not rigid bodies) in it and a map of collision shapes (for caching).
World and other stuff deletion happens after shapes deletion. So it didn't happen yet.