added VoronoiFractureDemo, thanks to RBD
fix in infinite recursion in quickSort, exclude the pivot in each sub partition disabled constraints don't merge simulation islands, and they don't disable collision between linked rigid bodies either.
This commit is contained in:
@@ -746,18 +746,20 @@ void btDiscreteDynamicsWorld::calculateSimulationIslands()
|
||||
for (i=0;i< numConstraints ; i++ )
|
||||
{
|
||||
btTypedConstraint* constraint = m_constraints[i];
|
||||
|
||||
const btRigidBody* colObj0 = &constraint->getRigidBodyA();
|
||||
const btRigidBody* colObj1 = &constraint->getRigidBodyB();
|
||||
|
||||
if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
|
||||
((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
|
||||
if (constraint->isEnabled())
|
||||
{
|
||||
if (colObj0->isActive() || colObj1->isActive())
|
||||
{
|
||||
const btRigidBody* colObj0 = &constraint->getRigidBodyA();
|
||||
const btRigidBody* colObj1 = &constraint->getRigidBodyB();
|
||||
|
||||
getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),
|
||||
(colObj1)->getIslandTag());
|
||||
if (((colObj0) && (!(colObj0)->isStaticOrKinematicObject())) &&
|
||||
((colObj1) && (!(colObj1)->isStaticOrKinematicObject())))
|
||||
{
|
||||
if (colObj0->isActive() || colObj1->isActive())
|
||||
{
|
||||
|
||||
getSimulationIslandManager()->getUnionFind().unite((colObj0)->getIslandTag(),
|
||||
(colObj1)->getIslandTag());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,8 +309,9 @@ bool btRigidBody::checkCollideWithOverride(btCollisionObject* co)
|
||||
for (int i = 0; i < m_constraintRefs.size(); ++i)
|
||||
{
|
||||
btTypedConstraint* c = m_constraintRefs[i];
|
||||
if (&c->getRigidBodyA() == otherRb || &c->getRigidBodyB() == otherRb)
|
||||
return false;
|
||||
if (c->isEnabled())
|
||||
if (&c->getRigidBodyA() == otherRb || &c->getRigidBodyB() == otherRb)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -313,33 +313,46 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
template <typename L>
|
||||
int partition (const L& CompareFunc, int lo, int hi, int pivotIndex)
|
||||
{
|
||||
if (pivotIndex != lo)
|
||||
swap (lo, pivotIndex);
|
||||
|
||||
pivotIndex = lo;
|
||||
lo++;
|
||||
while (lo <= hi)
|
||||
{
|
||||
//if (m_data[low] <= m_data[pivotIndex]) -> we don't have a <= so we use !(b<a) as a<=b
|
||||
if (!CompareFunc(m_data[pivotIndex],m_data[lo]))
|
||||
lo++;
|
||||
else if (CompareFunc(m_data[pivotIndex],m_data[hi]))
|
||||
hi--;
|
||||
else
|
||||
swap(lo,hi);
|
||||
}
|
||||
if (hi != pivotIndex)
|
||||
swap(pivotIndex, hi);
|
||||
return hi;
|
||||
}
|
||||
|
||||
template <typename L>
|
||||
void quickSortInternal(const L& CompareFunc,int lo, int hi)
|
||||
{
|
||||
// lo is the lower index, hi is the upper index
|
||||
// of the region of array a that is to be sorted
|
||||
int i=lo, j=hi;
|
||||
T x=m_data[(lo+hi)/2];
|
||||
|
||||
// partition
|
||||
do
|
||||
{
|
||||
while (CompareFunc(m_data[i],x))
|
||||
i++;
|
||||
while (CompareFunc(x,m_data[j]))
|
||||
j--;
|
||||
if (i<=j)
|
||||
{
|
||||
swap(i,j);
|
||||
i++; j--;
|
||||
}
|
||||
} while (i<=j);
|
||||
|
||||
// recursion
|
||||
if (lo<j)
|
||||
quickSortInternal( CompareFunc, lo, j);
|
||||
if (i<hi)
|
||||
quickSortInternal( CompareFunc, i, hi);
|
||||
if (lo>=hi)
|
||||
return;
|
||||
int pivotIndex = (lo+hi)/2;
|
||||
pivotIndex = partition(CompareFunc,lo,hi,pivotIndex);
|
||||
|
||||
// recursion, exclude the pivot
|
||||
if (lo<pivotIndex)
|
||||
{
|
||||
quickSortInternal( CompareFunc, lo, pivotIndex-1);
|
||||
}
|
||||
if (pivotIndex<hi)
|
||||
{
|
||||
quickSortInternal( CompareFunc, pivotIndex+1, hi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user