I'm encountering an issue with Bullet internals, and I'm not sure what the best way to resolve it.
Basically, the issue is related to the collision between a rope (softbody) and a terrain, for which I've derived a class from btConcaveShape, overriding processAllTriangles() etc.
This derived class works well for rigid bodies, however, with soft bodies, I came across an issue.
Initially, I figured out each triangle of that custom concave shape gets turned into a convex hull made of the extruded triangle. This convex hull shape is then cached in btSoftBodyTriangleCallback::m_shapeCache.
However, my issue is that my terrain is huge (the Earth). The key used to index each triangle derived convex hull shape is made out of a single 32-bits integer, with 10 bits for the part ID, and the remaining 22 bits for the vertex ID.
This is clearly not sufficient for my purpose (we would need at least 64-bits if not more).
So, my initial (easy) solution was to call btSoftBodyTriangleCallback::clearCache() after each call to my custom class processAllTriangles(). This works, however, the performance penalty involved by the following line is huge (linear search):
Code: Select all
m_softBody->getWorldInfo()->m_sparsesdf.RemoveReferences(tmp->m_childShape); //necessary?
However, this doesn't really work, as in the case a new temporary triangle convex hull is being allocated at the same memory location as a previous destroyed shape, we might end up with a false positive test result in btSparseSdf::Evaluate() (since
Code: Select all
(c->pclient == shape)
So, right now I don't know how the solve that problem. I understand it's not straightforward.
The options I can see:
- increase the number of bits used to index into btSoftBodyTriangleCallback::m_shapeCache, although the ever growing scheme of that cache worries me a bit
- find a solution to make RemoveReferences() more efficient
- ?
Does anyone see any better way of tackling that problem ? Thanks a lot !