fixing some issues: force needs to wake up objects, property sensor issue, island activation issue

This commit is contained in:
2006-12-25 02:02:13 +00:00
parent 0e094ffcab
commit e820cdf6a0
6 changed files with 50 additions and 25 deletions

View File

@@ -271,41 +271,50 @@ void btSimulationIslandManager::buildAndProcessIslands(btDispatcher* dispatcher,
int islandId;
//update the sleeping state for bodies, if all are sleeping
//solve the constraint for each islands, if there are contacts/constraints
for (int startIslandIndex=0;startIslandIndex<numElem;startIslandIndex = endIslandIndex)
{
int islandId = getUnionFind().getElement(startIslandIndex).m_id;
for (endIslandIndex = startIslandIndex+1;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
bool islandSleeping = false;
for (endIslandIndex = startIslandIndex;(endIslandIndex<numElem) && (getUnionFind().getElement(endIslandIndex).m_id == islandId);endIslandIndex++)
{
int i = getUnionFind().getElement(endIslandIndex).m_sz;
btCollisionObject* colObj0 = collisionObjects[i];
if (!colObj0->isActive())
islandSleeping = true;
}
//find the accompanying contact manifold for this islandId
int numIslandManifolds = 0;
btPersistentManifold** startManifold = 0;
if (startManifoldIndex<numManifolds)
if (!islandSleeping)
{
int curIslandId = getIslandId(islandmanifold[startManifoldIndex]);
if (curIslandId == islandId)
{
startManifold = &islandmanifold[startManifoldIndex];
for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(islandmanifold[endManifoldIndex]));endManifoldIndex++)
{
//find the accompanying contact manifold for this islandId
int numIslandManifolds = 0;
btPersistentManifold** startManifold = 0;
if (startManifoldIndex<numManifolds)
{
int curIslandId = getIslandId(islandmanifold[startManifoldIndex]);
if (curIslandId == islandId)
{
startManifold = &islandmanifold[startManifoldIndex];
for (endManifoldIndex = startManifoldIndex+1;(endManifoldIndex<numManifolds) && (islandId == getIslandId(islandmanifold[endManifoldIndex]));endManifoldIndex++)
{
}
/// Process the actual simulation, only if not sleeping/deactivated
numIslandManifolds = endManifoldIndex-startManifoldIndex;
}
/// Process the actual simulation, only if not sleeping/deactivated
numIslandManifolds = endManifoldIndex-startManifoldIndex;
}
}
callback->ProcessIsland(startManifold,numIslandManifolds, islandId);
callback->ProcessIsland(startManifold,numIslandManifolds, islandId);
if (numIslandManifolds)
{
startManifoldIndex = endManifoldIndex;
if (numIslandManifolds)
{
startManifoldIndex = endManifoldIndex;
}
}
}
}

View File

@@ -68,8 +68,10 @@ class btAlignedObjectArray
SIMD_FORCE_INLINE void deallocate()
{
if(m_data)
if(m_data) {
m_allocator.deallocate(m_data);
m_data = 0;
}
}

View File

@@ -268,7 +268,7 @@ bool SCA_PropertySensor::CheckPropertyCondition()
m_recentresult=result;
} else
{
m_recentresult=true;
m_recentresult=result;//true;
}
return result;
}

View File

@@ -90,7 +90,8 @@ bool KX_NetworkMessageSensor::Evaluate(CValue* event)
bool result = false;
bool WasUp = m_IsUp;
m_IsUp = false;
// m_IsUp = false;
if (m_BodyList) {
m_BodyList->Release();
m_BodyList = NULL;

View File

@@ -379,6 +379,10 @@ void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque
{
btVector3 torque(torqueX,torqueY,torqueZ);
btTransform xform = m_body->getCenterOfMassTransform();
if (torque.length2() > (SIMD_EPSILON*SIMD_EPSILON))
{
m_body->activate();
}
if (local)
{
torque = xform.getBasis()*torque;
@@ -389,6 +393,13 @@ void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torque
void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local)
{
btVector3 force(forceX,forceY,forceZ);
if (force.length2() > (SIMD_EPSILON*SIMD_EPSILON))
{
m_body->activate();
}
btTransform xform = m_body->getCenterOfMassTransform();
if (local)
{

View File

@@ -653,6 +653,8 @@ void CcdPhysicsEnvironment::removeConstraint(int constraintId)
btTypedConstraint* constraint = m_dynamicsWorld->getConstraint(i);
if (constraint->getUserConstraintId() == constraintId)
{
constraint->getRigidBodyA().activate();
constraint->getRigidBodyB().activate();
m_dynamicsWorld->removeConstraint(constraint);
break;
}