void CP_AssembledBody::RemoveBody(CP_Body *pBody) {
	for (int i = 0; i < GetBodyNumber(); ++i) {
		if (pBody == GetBody(i)) {
			RemoveBody(i);
			return;
		}
	}
}
Esempio n. 2
0
RigidBody::~RigidBody()
{
    // Explicitly reset here, RemoveCollisionShape() wont do it if shape type matches.
    impl->triangleMesh.reset();
    impl->convexHullSet.reset();

    RemoveBody();
    RemoveCollisionShape();
    if (impl->world)
        impl->world->debugRigidBodies_.Erase(this);
    delete impl;
}
Esempio n. 3
0
void CUniformGrid::AddBody(CGameNode * node)
{
	const int CurrentIndex = node->GetGridIndex();
	const int NewIndex = GetCellIndex(node->GetPosition());

	if (-1 != CurrentIndex)
	{
		if (NewIndex == CurrentIndex)
		{
			// Nothing to do, already in right place
			return;
		}
		else
		{
			// Got this unit but in wrong cell, so remove first
			RemoveBody(node);
		}
	}

	m_GridArray[NewIndex].push_back(node);
	node->SetGridIndex(NewIndex);
}
dgBroadPhaseAggregate::~dgBroadPhaseAggregate()
{
    if (m_root) {
        dgBody* buffer[2040];

        dgBroadPhaseNode* pool[DG_BROADPHASE_MAX_STACK_DEPTH];
        pool[0] = m_root;
        dgInt32 stack = 1;

        dgInt32 count = 0;
        while (stack) {
            stack--;
            dgBroadPhaseNode* const rootNode = pool[stack];
            if (rootNode->IsLeafNode()) {
                buffer[count] = rootNode->GetBody();;
                count ++;
            } else {
                dgBroadPhaseTreeNode* const tmpNode = (dgBroadPhaseTreeNode*)rootNode;
                dgAssert(tmpNode->m_left);
                dgAssert(tmpNode->m_right);

                pool[stack] = tmpNode->m_left;
                stack++;
                dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0])));
                pool[stack] = tmpNode->m_right;
                stack++;
                dgAssert(stack < dgInt32(sizeof (pool) / sizeof (pool[0])));
            }
        }

        for (dgInt32 i = 0; i < count; i ++) {
            RemoveBody(buffer[i]);
        }
        dgAssert (!m_root);
    }
}