我需要在PhysX 3.2中制作一个像刚体一样的NULL。非冲突的-仅作为锚点。反正有做吗?我只需要它来解决一些关节组合。
提前致谢
最佳答案
首先为配对创建一个过滤器:
PxFilterFlags Simplefilter( PxFilterObjectAttributes attributes0,
PxFilterData filterData0,
PxFilterObjectAttributes attributes1,
PxFilterData filterData1,
PxPairFlags& pairFlags,
const void* constantBlock,
PxU32 constantBlockSize )
{
if(filterData0.word0 = -99) //-99 is random
{
return PxFilterFlag::eKILL;
}
pairFlags = PxPairFlag::eRESOLVE_CONTACTS;
pairFlags |= PxPairFlag::eCONTACT_DEFAULT;
pairFlags |= PxPairFlag::eNOTIFY_TOUCH_FOUND;
pairFlags |= PxPairFlag::eNOTIFY_CONTACT_POINTS;
return PxFilterFlag::eDEFAULT;
}
然后,在创建PxScene时添加以下行:
PxSceneDesc sceneDesc(gPhysicsSDK->getTolerancesScale());
...
sceneDesc.filterShader = Simplefilter;
gScene = gPhysicsSDK->createScene(sceneDesc);
最后,通过以下方法使actor的形状(在我的示例中为gSphere)不易碰撞:
unsigned int nbShapes = gSphere->getNbShapes();
PxShape** shapes = new PxShape*[nbShapes];
if(nbShapes > 0)
{
gSphere->getShapes(shapes,nbShapes,0);
for(unsigned int j = 0; j< nbShapes; j++)
{
PxFilterData data;
data.word0 = -99; // the same number above
shapes[j]->setSimulationFilterData(data);
}
}