I have an issue that I've worked around but I don't feel good about my solution.
I noticed that in our scenes we have a lot of Ghosts and spend up to 3ms updating them.
The Ghosts have setCollisionFlags set to btCollisionObject::CF_NO_CONTACT_RESPONSE.
The DyanmicsWorld has mDynamicsWorld->setForceUpdateAllAabbs(false) so that aabbs of CollisionObjects should not be calculated if the CollisionObjects are not active.
Looking at the Bullet profiler, almost all the time is spend in updating the Ghost AABBs in btCollisionWorld::updateAabbs().
After some investigation I noticed that, even though the Ghosts never move, they are always active and that means that their aabbs get recalculated every frame.
To get around this, I changed the code in btCollisionWorld::updateAabbs() from
Code: Select all
//only update aabb of active objects
if (m_forceUpdateAllAabbs || colObj->isActive()))
{
updateSingleAabb(colObj);
}
Code: Select all
//only update aabb of active objects
if (m_forceUpdateAllAabbs || (colObj->isActive() && (colObj->getInternalType() != btCollisionObject::CO_GHOST_OBJECT)))
{
updateSingleAabb(colObj);
}
This was all so that the aabb of a Ghost is not recalculated unless its transform changes.
Is this the right way to solve this problem?
Are there better, less hacky solutions that I am not thinking of?
Thanks in advance for any help,
cg