Hello all,
I just tried an upgrade from 2.71 to 2.72, and then to the newest SVN 1388 version. Something has changed since 2.72 that breaks my terrain collision system, which has been working nicely for the last year and a half.
Our game engine has a huge global dataset for the terrain (similar to Google Earth, maybe), which is pretty optimized. So to get bullet collision into this, I wrote a terrain collision shape:
Code: Select all
class WbBulletTerrain : public btConcaveShape
{
public:
WbBulletTerrain(GgGlobe* terrain);
~WbBulletTerrain();
virtual void processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
virtual void processAllTrianglesBruteForce(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
virtual void setLocalScaling(const btVector3& scaling) { scaling_ = scaling; }
virtual const btVector3& getLocalScaling() const { return scaling_; }
virtual const char* getName() const { return "TERRAIN"; }
virtual int getShapeType() const { return TERRAIN_SHAPE_PROXYTYPE; }
};
On the implementation side, here's the constructor and getAabb functions:
Code: Select all
WbBulletTerrain::WbBulletTerrain(GgGlobe* terrain)
{
terrain_ = terrain;
scaling_.setValue(btScalar(1.0),btScalar(1.0),btScalar(1.0));
double box = Gg::earth_radius + 10000.0;
local_aabb_min_.setValue(btScalar(-box), btScalar(-box), btScalar(-box));
local_aabb_max_.setValue(btScalar( box), btScalar( box), btScalar( box));
}
void WbBulletTerrain::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
{
btVector3 localHalfExtents = btScalar(0.5)*(local_aabb_max_ - local_aabb_min_);
btVector3 localCenter = btScalar(0.5)*(local_aabb_max_ + local_aabb_min_);
btMatrix3x3 abs_b = trans.getBasis().absolute();
btPoint3 center = trans(localCenter);
btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
abs_b[1].dot(localHalfExtents),
abs_b[2].dot(localHalfExtents));
extent += btVector3(getMargin(),getMargin(),getMargin());
aabbMin = center - extent;
aabbMax = center + extent;
}
When I add this shape to the bullet dynamics world, I create a static rigid body placed at the earth's core, and that's it. It's all been working so far, but not any more. processAllTriangles is not called at all, so my other rigid bodies fall through the ground.
So I'd really appreciate any hints on what did change from bullet 2.71 to 2.72 that might have caused this to stop working. I do use double precision for this (obviously ), I cannot test in single precision. I use the btDbvtBroadphase, but have tested with the bt32BitAxisSweep3 broadphase too, no difference.
Maybe it's got something to do with the added ccd functionality?
Best regards,
Ola
EDIT: Never mind the brute force function, I found it's been removed from the btConcaveShape.h file anyway.