gpt4 book ai didi

c++ - 如何在 PhysX 中创建非碰撞刚体

转载 作者:行者123 更新时间:2023-11-28 06:50:29 28 4
gpt4 key购买 nike

我需要在 PhysX 3.2 中制作一个类似 NULL 的刚体。一个非碰撞的 - 仅作为 anchor 。有什么办法吗?我只需要它来解决一些关节组合。提前致谢

最佳答案

首先为对创建一个过滤器:

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);
}
}

关于c++ - 如何在 PhysX 中创建非碰撞刚体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24050296/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com