Allocate large arrays of btVector3s on the heap instead of the stack. Fixes Issue #193

This commit is contained in:
john.mccutchan
2009-02-10 16:24:12 +00:00
parent 2a10a61f50
commit 225772b12a
4 changed files with 31 additions and 5 deletions

View File

@@ -913,6 +913,8 @@ btHfFluidColumnRigidBodyCallback::btHfFluidColumnRigidBodyCallback (btRigidBody*
m_density = density;
m_floatyness = floatyness;
m_numVoxels = m_buoyantShape->getNumVoxels ();
m_voxelPositionsXformed = (btVector3*)btAlignedAlloc(sizeof(btVector3)*m_numVoxels, 16);
m_voxelSubmerged = (bool*)btAlignedAlloc(sizeof(bool)*m_numVoxels, 16);
for (int i = 0; i < m_numVoxels; i++)
{
btVector3 p = m_buoyantShape->getVoxelPositionsArray()[i];
@@ -923,6 +925,14 @@ btHfFluidColumnRigidBodyCallback::btHfFluidColumnRigidBodyCallback (btRigidBody*
}
}
btHfFluidColumnRigidBodyCallback::~btHfFluidColumnRigidBodyCallback ()
{
if (m_voxelPositionsXformed)
btAlignedFree (m_voxelPositionsXformed);
if (m_voxelSubmerged)
btAlignedFree (m_voxelSubmerged);
}
static bool sphereVsAABB (const btVector3& aabbMin, const btVector3& aabbMax, const btVector3& sphereCenter, const btScalar sphereRadius)
{
btScalar totalDistance = 0;