I have been working some while on this:
Basic setup: Irrlicht engine for the looks, bullet physics for the feel.
I try to create a terrain collision shape by iterating over its graphical counterpart and collecting height vals.
This is the function in question:
Code: Select all
btHeightfieldTerrainShape* ITerrainShape::createShape(irr::scene::ITerrainSceneNode* const terrain, u32 gridSize /*which is 512 normally*/)
{
terrain->updateAbsolutePosition();
const core::aabbox3df bb = terrain->getBoundingBox();
s32 sizeX = bb.MaxEdge.X - bb.MinEdge.X;
s32 sizeY = bb.MaxEdge.Y - bb.MinEdge.Y;
s32 sizeZ = bb.MaxEdge.Z - bb.MinEdge.Z;
f32 minHeight = 10000000.f, maxHeight = -1000000.f;
heightVal = new f32[gridSize*gridSize];
const f32 stepWidthX = (f32)sizeX / (f32)gridSize;
const f32 stepWidthZ = (f32)sizeZ / (f32)gridSize;
u32 runVal = 0;
for (f32 z = bb.MinEdge.Z; z < bb.MaxEdge.Z; z+=stepWidthZ)
{
for (f32 x = bb.MinEdge.X; x < bb.MaxEdge.X; x+=stepWidthX)
{
const f32 curVal = terrain->getHeight(x, z);
heightVal[runVal++] = curVal;
if (curVal > maxHeight)
maxHeight = curVal;
if (curVal < minHeight)
minHeight = curVal;
}
}
btHeightfieldTerrainShape* s = new btHeightfieldTerrainShape(gridSize, gridSize, heightVal, 1.f, minHeight, maxHeight, 1, PHY_FLOAT, false);
delete[] heightVal;
return s;
}
I can confirm that this error is always reproducible. I think that I might miss smth here that causes the error. Help is greatly appreciated.Overflow in AABB, object removed from simulation
If you can reproduce this, please email bugs@continuousphysics.com
Please include above information, your Platform, version of OS.
Thanks.
Stats:
Bullet Physics: 2.79
System: Arch Linux
Thank you,
p.