In my game, I have an object which spawns other entities. Those spawned entities are kinematic actors.
Because I don't want to decouple their graphics from their physics too much and I don't want them to just pop out. I've set up my "spawner" mesh to provide a "spawn point" which is inside the graphics mesh, as well as the physics hull.
The next step to make the spawned actor work is to allow it to be sweeped out of the spawner mesh.
To do so, I've provided a special functionality which selectively ignores certain rigid bodies when sweeping the kinematic actor. Problem is when populating this list, the results don't match what I expect. My current filter is
Code: Select all
struct ContactSet : btCollisionWorld::ContactResultCallback {
std::map<const btCollisionObject*, TouchInfo> touches;
btRigidBody *you;
btScalar addSingleResult(btManifoldPoint &cp, const btCollisionObject *colObj0, int partId0, int index0, const btCollisionObject *colObj1, int partId1, int index1) {
if(cp.getDistance() > .0f && you == colObj0) return 1.0f; // not touching
if(cp.getDistance() < .0f && you == colObj1) return 1.0f; // not touching
if(touches.find(colObj1) != touches.cend()) return 1.0f; // already stored one, not interesting.
TouchInfo add;
for(asizei loop = 0; loop < 3; loop++) add.encroaching[loop] = cp.m_normalWorldOnB[loop] * cp.getDistance();
for(asizei loop = 0; loop < 3; loop++) add.normal[loop] = cp.m_normalWorldOnB[loop];
add.otherHandle = colObj1; // id is not relevant here
for(asizei loop = 0; loop < 3; loop++) add.pointOther[loop] = cp.getPositionWorldOnB()[loop];
for(asizei loop = 0; loop < 3; loop++) add.pointYou[loop] = cp.getPositionWorldOnA()[loop];
add.world = false; // not relevant anyway!
touches.insert(std::make_pair(add.otherHandle, add));
return 1.0f;
}
};
By another point of view, the bounduary of the hull is considered "bidirectional" and does not influence the direction of the encroaching distance.
It should really be the other way around instead: either being inside shall negate encroach distance or ... better idea... the manifold should be owned by the hull... but I guess this wouldn't make much sense.
So, I need:
- A quick recap at my understanding of manifold points (because I'm no more sure I got them right)
- Do you think the above analysis is correct / makes sense?
- How would you fix/troubleshoot this problem?