Merge pull request #1116 from olegklimov/master
Rewrite collision filtering code for C API
This commit is contained in:
@@ -4536,7 +4536,6 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
|||||||
int linkIndexB = -1;
|
int linkIndexB = -1;
|
||||||
|
|
||||||
int objectIndexB = -1;
|
int objectIndexB = -1;
|
||||||
|
|
||||||
const btRigidBody* bodyB = btRigidBody::upcast(manifold->getBody1());
|
const btRigidBody* bodyB = btRigidBody::upcast(manifold->getBody1());
|
||||||
if (bodyB)
|
if (bodyB)
|
||||||
{
|
{
|
||||||
@@ -4547,12 +4546,6 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
|||||||
{
|
{
|
||||||
linkIndexB = mblB->m_link;
|
linkIndexB = mblB->m_link;
|
||||||
objectIndexB = mblB->m_multiBody->getUserIndex2();
|
objectIndexB = mblB->m_multiBody->getUserIndex2();
|
||||||
if (
|
|
||||||
(clientCmd.m_updateFlags & CMD_REQUEST_CONTACT_POINT_HAS_LINK_INDEX_B_FILTER) &&
|
|
||||||
clientCmd.m_requestContactPointArguments.m_linkIndexBIndexFilter != linkIndexB)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int objectIndexA = -1;
|
int objectIndexA = -1;
|
||||||
@@ -4566,30 +4559,55 @@ bool PhysicsServerCommandProcessor::processCommand(const struct SharedMemoryComm
|
|||||||
{
|
{
|
||||||
linkIndexA = mblA->m_link;
|
linkIndexA = mblA->m_link;
|
||||||
objectIndexA = mblA->m_multiBody->getUserIndex2();
|
objectIndexA = mblA->m_multiBody->getUserIndex2();
|
||||||
if (
|
}
|
||||||
(clientCmd.m_updateFlags & CMD_REQUEST_CONTACT_POINT_HAS_LINK_INDEX_A_FILTER) &&
|
btAssert(bodyA || mblA);
|
||||||
clientCmd.m_requestContactPointArguments.m_linkIndexAIndexFilter != linkIndexA)
|
|
||||||
|
//apply the filter, if the user provides it
|
||||||
|
bool swap = false;
|
||||||
|
if (clientCmd.m_requestContactPointArguments.m_objectAIndexFilter >= 0)
|
||||||
|
{
|
||||||
|
if (clientCmd.m_requestContactPointArguments.m_objectAIndexFilter == objectIndexA)
|
||||||
|
{
|
||||||
|
swap = false;
|
||||||
|
}
|
||||||
|
else if (clientCmd.m_requestContactPointArguments.m_objectAIndexFilter == objectIndexB)
|
||||||
|
{
|
||||||
|
swap = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
btAssert(bodyA || mblA);
|
if (swap)
|
||||||
|
|
||||||
//apply the filter, if the user provides it
|
|
||||||
if (clientCmd.m_requestContactPointArguments.m_objectAIndexFilter >= 0)
|
|
||||||
{
|
{
|
||||||
if ((clientCmd.m_requestContactPointArguments.m_objectAIndexFilter != objectIndexA) &&
|
std::swap(objectIndexA, objectIndexB);
|
||||||
(clientCmd.m_requestContactPointArguments.m_objectAIndexFilter != objectIndexB))
|
std::swap(linkIndexA, linkIndexB);
|
||||||
continue;
|
std::swap(bodyA, bodyB);
|
||||||
}
|
}
|
||||||
|
|
||||||
//apply the second object filter, if the user provides it
|
//apply the second object filter, if the user provides it
|
||||||
if (clientCmd.m_requestContactPointArguments.m_objectBIndexFilter >= 0)
|
if (clientCmd.m_requestContactPointArguments.m_objectBIndexFilter >= 0)
|
||||||
{
|
{
|
||||||
if ((clientCmd.m_requestContactPointArguments.m_objectBIndexFilter != objectIndexA) &&
|
if (clientCmd.m_requestContactPointArguments.m_objectBIndexFilter != objectIndexB)
|
||||||
(clientCmd.m_requestContactPointArguments.m_objectBIndexFilter != objectIndexB))
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
(clientCmd.m_updateFlags & CMD_REQUEST_CONTACT_POINT_HAS_LINK_INDEX_A_FILTER) &&
|
||||||
|
clientCmd.m_requestContactPointArguments.m_linkIndexAIndexFilter != linkIndexA)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
(clientCmd.m_updateFlags & CMD_REQUEST_CONTACT_POINT_HAS_LINK_INDEX_B_FILTER) &&
|
||||||
|
clientCmd.m_requestContactPointArguments.m_linkIndexBIndexFilter != linkIndexB)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int p = 0; p < manifold->getNumContacts(); p++)
|
for (int p = 0; p < manifold->getNumContacts(); p++)
|
||||||
|
|||||||
@@ -74,11 +74,6 @@ public:
|
|||||||
if (m_link>=0)
|
if (m_link>=0)
|
||||||
{
|
{
|
||||||
const btMultibodyLink& link = m_multiBody->getLink(this->m_link);
|
const btMultibodyLink& link = m_multiBody->getLink(this->m_link);
|
||||||
if (link.m_flags&BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION)
|
|
||||||
{
|
|
||||||
if ( link.m_parent == other->m_link)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (link.m_flags&BT_MULTIBODYLINKFLAGS_DISABLE_ALL_PARENT_COLLISION)
|
if (link.m_flags&BT_MULTIBODYLINKFLAGS_DISABLE_ALL_PARENT_COLLISION)
|
||||||
{
|
{
|
||||||
int parent_of_this = m_link;
|
int parent_of_this = m_link;
|
||||||
@@ -93,16 +88,17 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (link.m_flags&BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION)
|
||||||
|
{
|
||||||
|
if ( link.m_parent == other->m_link)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (other->m_link>=0)
|
if (other->m_link>=0)
|
||||||
{
|
{
|
||||||
const btMultibodyLink& otherLink = other->m_multiBody->getLink(other->m_link);
|
const btMultibodyLink& otherLink = other->m_multiBody->getLink(other->m_link);
|
||||||
if (otherLink.m_flags& BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION)
|
|
||||||
{
|
|
||||||
if (otherLink.m_parent == this->m_link)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (otherLink.m_flags& BT_MULTIBODYLINKFLAGS_DISABLE_ALL_PARENT_COLLISION)
|
if (otherLink.m_flags& BT_MULTIBODYLINKFLAGS_DISABLE_ALL_PARENT_COLLISION)
|
||||||
{
|
{
|
||||||
int parent_of_other = other->m_link;
|
int parent_of_other = other->m_link;
|
||||||
@@ -115,6 +111,11 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (otherLink.m_flags& BT_MULTIBODYLINKFLAGS_DISABLE_PARENT_COLLISION)
|
||||||
|
{
|
||||||
|
if (otherLink.m_parent == this->m_link)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user