Exemplo n.º 1
0
void WorldItemImpl::extractCollisions(const CollisionPair& collisionPair)
{
    CollisionLinkPairPtr collisionLinkPair = std::make_shared<CollisionLinkPair>();
    collisionLinkPair->collisions = collisionPair.collisions();
    BodyItem* bodyItem = 0;
    for(int i=0; i < 2; ++i){
        ColdetLinkInfo* linkInfo = static_cast<ColdetLinkInfo*>(collisionPair.object(i));
        if(linkInfo->bodyItem != bodyItem){
            bodyItem = linkInfo->bodyItem;
            bodyItem->collisions().push_back(collisionLinkPair);
        }
        collisionLinkPair->body[i] = bodyItem->body();
        Link* link = linkInfo->link;
        collisionLinkPair->link[i] = link;
        bodyItem->collisionsOfLink(link->index()).push_back(collisionLinkPair);
        bodyItem->collisionLinkBitSet().set(link->index());
    }
    collisions->push_back(collisionLinkPair);
}
Exemplo n.º 2
0
void WorldItemImpl::extractCollisions(const CollisionPair& collisionPair)
{
    CollisionLinkPairPtr collisionLinkPair = std::make_shared<CollisionLinkPair>();
    collisionLinkPair->collisions = collisionPair.collisions;
    BodyItem* bodyItem = 0;
    for(int i=0; i < 2; ++i){
        const int geometryId = collisionPair.geometryId[i];
        BodyItemInfoMap::const_iterator p = geometryIdToBodyInfoMap[geometryId];
        const BodyItemInfo& info = p->second;
        const int linkIndex = geometryId - info.geometryId;
        if(p->first != bodyItem){
            bodyItem = p->first;
            bodyItem->collisions().push_back(collisionLinkPair);
        }
        const BodyPtr& body = bodyItem->body();
        collisionLinkPair->body[i] = body;
        collisionLinkPair->link[i] = body->link(linkIndex);
        bodyItem->collisionsOfLink(linkIndex).push_back(collisionLinkPair);
        bodyItem->collisionLinkBitSet().set(linkIndex);
    }
    collisions->push_back(collisionLinkPair);
}