本文整理汇总了C++中PxShape::setSimulationFilterData方法的典型用法代码示例。如果您正苦于以下问题:C++ PxShape::setSimulationFilterData方法的具体用法?C++ PxShape::setSimulationFilterData怎么用?C++ PxShape::setSimulationFilterData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PxShape
的用法示例。
在下文中一共展示了PxShape::setSimulationFilterData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PxSetGroupsMask
void physx::PxSetGroupsMask(const PxRigidActor& actor, const PxGroupsMask& mask)
{
PxFilterData tmp;
PxFilterData fd = convert(mask);
if (actor.getNbShapes() == 1)
{
PxShape* shape = NULL;
actor.getShapes(&shape, 1);
// retrieve current group
tmp = shape->getSimulationFilterData();
fd.word0 = tmp.word0;
// set new filter data
shape->setSimulationFilterData(fd);
}
else
{
PxShape* shape;
PxU32 numShapes = actor.getNbShapes();
shdfnd::InlineArray<PxShape*, 64> shapes;
if(numShapes > 64)
{
shapes.resize(64);
}
else
{
shapes.resize(numShapes);
}
PxU32 iter = 1 + numShapes/64;
for(PxU32 i=0; i < iter; i++)
{
PxU32 offset = i * 64;
PxU32 size = numShapes - offset;
if(size > 64)
size = 64;
actor.getShapes(shapes.begin(), size, offset);
for(PxU32 j = size; j--;)
{
// retrieve current group mask
shape = shapes[j];
// retrieve current group
tmp = shape->getSimulationFilterData();
fd.word0 = tmp.word0;
// set new filter data
shape->setSimulationFilterData(fd);
}
}
}
}
示例2: PxSetGroup
void physx::PxSetGroup(const PxRigidActor& actor, const PxU16 collisionGroup)
{
PX_CHECK_AND_RETURN(collisionGroup < 32,"Collision group must be less than 32");
PxFilterData fd;
if (actor.getNbShapes() == 1)
{
PxShape* shape = NULL;
actor.getShapes(&shape, 1);
// retrieve current group mask
fd = shape->getSimulationFilterData();
fd.word0 = collisionGroup;
// set new filter data
shape->setSimulationFilterData(fd);
}
else
{
PxShape* shape;
PxU32 numShapes = actor.getNbShapes();
shdfnd::InlineArray<PxShape*, 64> shapes;
if(numShapes > 64)
{
shapes.resize(64);
}
else
{
shapes.resize(numShapes);
}
PxU32 iter = 1 + numShapes/64;
for(PxU32 i=0; i < iter; i++)
{
PxU32 offset = i * 64;
PxU32 size = numShapes - offset;
if(size > 64)
size = 64;
actor.getShapes(shapes.begin(), size, offset);
for(PxU32 j = size; j--;)
{
// retrieve current group mask
shape = shapes[j];
fd = shape->getSimulationFilterData();
fd.word0 = collisionGroup;
// set new filter data
shape->setSimulationFilterData(fd);
}
}
}
}
示例3: createVehicleActor
PxRigidDynamic* Vehicle::createVehicleActor(const PxVehicleChassisData& chassisData,
PxMaterial** wheelMaterials, PxConvexMesh** wheelConvexMeshes, const PxU32 numWheels,
PxMaterial** chassisMaterials, PxConvexMesh** chassisConvexMeshes, const PxU32 numChassisMeshes, PxPhysics& physics, PxVec3 initPos)
{
//We need a rigid body actor for the vehicle.
//Don't forget to add the actor to the scene after setting up the associated vehicle.
PxRigidDynamic* vehActor = physics.createRigidDynamic(PxTransform(initPos));
vehActor->setRigidBodyFlag(PxRigidBodyFlag::eENABLE_CCD, true);
//Wheel and chassis simulation filter data.
PxFilterData wheelSimFilterData;
wheelSimFilterData.word0 = COLLISION_FLAG_WHEEL;
wheelSimFilterData.word1 = COLLISION_FLAG_WHEEL_AGAINST;
PxFilterData chassisSimFilterData;
chassisSimFilterData.word0 = COLLISION_FLAG_CHASSIS;
chassisSimFilterData.word1 = COLLISION_FLAG_CHASSIS_AGAINST;
//Wheel and chassis query filter data.
//Optional: cars don't drive on other cars.
PxFilterData wheelQryFilterData;
wheelQryFilterData.word0 = FilterGroup::eWHEEL;
setupNonDrivableSurface(wheelQryFilterData);
PxFilterData chassisQryFilterData;
chassisQryFilterData.word0 = FilterGroup::eVEHICLE;
setupNonDrivableSurface(chassisQryFilterData);
//Add all the wheel shapes to the actor.
for (PxU32 i = 0; i < numWheels; i++)
{
PxConvexMeshGeometry geom(wheelConvexMeshes[i]);
PxShape* wheelShape = vehActor->createShape(geom, *wheelMaterials[i]);
wheelShape->setQueryFilterData(wheelQryFilterData);
wheelShape->setSimulationFilterData(wheelSimFilterData);
wheelShape->setLocalPose(PxTransform(PxIdentity));
}
//Add the chassis shapes to the actor.
for (PxU32 i = 0; i < numChassisMeshes; i++)
{
PxShape* chassisShape = vehActor->createShape
(PxConvexMeshGeometry(chassisConvexMeshes[i]), *chassisMaterials[i]);
chassisShape->setQueryFilterData(chassisQryFilterData);
chassisShape->setSimulationFilterData(chassisSimFilterData);
chassisShape->setLocalPose(PxTransform(PxIdentity));
}
vehActor->setMass(chassisData.mMass);
vehActor->setMassSpaceInertiaTensor(chassisData.mMOI);
vehActor->setCMassLocalPose(PxTransform(chassisData.mCMOffset, PxQuat(PxIdentity)));
return vehActor;
}
示例4: SetCollisionResponseForActor
void UDestructibleComponent::SetCollisionResponseForActor(const FCollisionResponse& ColResponse, PxRigidDynamic* Actor, int32 ChunkIdx)
{
// Get collision channel and response
PxFilterData PQueryFilterData, PSimFilterData;
uint8 MoveChannel = GetCollisionObjectType();
if(IsCollisionEnabled())
{
AActor* Owner = GetOwner();
CreateShapeFilterData(MoveChannel, (Owner ? Owner->GetUniqueID() : 0), ColResponse.GetResponseContainer(), 0, ChunkIdxToBoneIdx(ChunkIdx), PQueryFilterData, PSimFilterData, BodyInstance.bUseCCD, BodyInstance.bNotifyRigidBodyCollision, false);
PQueryFilterData.word3 |= EPDF_SimpleCollision | EPDF_ComplexCollision;
SCOPED_SCENE_WRITE_LOCK(Actor->getScene());
TArray<PxShape*> Shapes;
Shapes.AddUninitialized(Actor->getNbShapes());
int ShapeCount = Actor->getShapes(Shapes.GetTypedData(), Shapes.Num());
for (int32 i=0; i < ShapeCount; ++i)
{
PxShape* Shape = Shapes[i];
Shape->setQueryFilterData(PQueryFilterData);
Shape->setSimulationFilterData(PSimFilterData);
Shape->setFlag(PxShapeFlag::eSCENE_QUERY_SHAPE, true);
Shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true);
Shape->setFlag(PxShapeFlag::eVISUALIZATION, true);
}
}
}
示例5: createDrain
void SampleParticles::createDrain()
{
float lakeHeight = 5.5f;
//Creates a drain plane for the particles. This is good practice to avoid unnecessary
//spreading of particles, which is bad for performance. The drain represents a lake in this case.
{
PxRigidStatic* actor = getPhysics().createRigidStatic(PxTransform(PxVec3(0.0f, lakeHeight - 1.0f, 0.0f), PxQuat(PxHalfPi, PxVec3(0,0,1))));
runtimeAssert(actor, "PxPhysics::createRigidStatic returned NULL\n");
PxShape* shape = actor->createShape(PxPlaneGeometry(), getDefaultMaterial());
runtimeAssert(shape, "PxRigidStatic::createShape returned NULL\n");
shape->setSimulationFilterData(collisionGroupDrain);
shape->setFlags(PxShapeFlag::ePARTICLE_DRAIN | PxShapeFlag::eSIMULATION_SHAPE);
getActiveScene().addActor(*actor);
mPhysicsActors.push_back(actor);
}
//Creates the surface of the lake (the particles actually just collide with the underlaying drain).
{
PxBoxGeometry bg;
bg.halfExtents = PxVec3(130.0f, lakeHeight + 1.0f, 130.0f);
PxRigidStatic* actor = getPhysics().createRigidStatic(PxTransform(PxVec3(0.0f, 0.0f, 0.0f), PxQuat::createIdentity()));
runtimeAssert(actor, "PxPhysics::createRigidStatic returned NULL\n");
PxShape* shape = actor->createShape(bg, getDefaultMaterial());
runtimeAssert(shape, "PxRigidStatic::createShape returned NULL\n");
shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
shape->setFlag(PxShapeFlag::eSCENE_QUERY_SHAPE, false);
getActiveScene().addActor(*actor);
mPhysicsActors.push_back(actor);
createRenderObjectsFromActor(actor, getMaterial(MATERIAL_LAKE));
}
}
示例6: AttachShape_AssumesLocked
PxShape* AttachShape_AssumesLocked(const PxGeometry& PGeom, const PxTransform& PLocalPose, const float ContactOffset, PxShapeFlags PShapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE) const
{
const PxMaterial* PMaterial = GetDefaultPhysMaterial();
PxShape* PNewShape = bShapeSharing ? GPhysXSDK->createShape(PGeom, *PMaterial, /*isExclusive =*/ false, PShapeFlags) : PDestActor->createShape(PGeom, *PMaterial, PShapeFlags);
if (PNewShape)
{
PNewShape->setLocalPose(PLocalPose);
if (NewShapes)
{
NewShapes->Add(PNewShape);
}
PNewShape->setContactOffset(ContactOffset);
const bool bSyncFlags = bShapeSharing || SceneType == PST_Sync;
const FShapeFilterData& Filters = ShapeData.FilterData;
const bool bComplexShape = PNewShape->getGeometryType() == PxGeometryType::eTRIANGLEMESH;
PNewShape->setQueryFilterData(bComplexShape ? Filters.QueryComplexFilter : Filters.QuerySimpleFilter);
PNewShape->setFlags( (bSyncFlags ? ShapeData.SyncShapeFlags : ShapeData.AsyncShapeFlags) | (bComplexShape ? ShapeData.ComplexShapeFlags : ShapeData.SimpleShapeFlags));
PNewShape->setSimulationFilterData(Filters.SimFilter);
FBodyInstance::ApplyMaterialToShape_AssumesLocked(PNewShape, SimpleMaterial, ComplexMaterials, bShapeSharing);
if(bShapeSharing)
{
PDestActor->attachShape(*PNewShape);
PNewShape->release();
}
}
return PNewShape;
}
示例7: setCCDActive
void SampleNorthPole::setCCDActive(PxShape& shape)
{
shape.setFlag(PxShapeFlag::eUSE_SWEPT_BOUNDS,true);
PxFilterData fd = shape.getSimulationFilterData();
fd.word3 |= CCD_FLAG;
shape.setSimulationFilterData(fd);
}
示例8: setupFiltering
void setupFiltering(PxRigidActor* actor, PxU32 filterGroup, PxU32 filterMask)
{
PxFilterData filterData;
filterData.word0 = filterGroup; //word0 = own ID
filterData.word1 = filterMask; //word1 = ID mask to filter pairs that trigger a contact callback
const PxU32 numShapes = actor->getNbShapes();
PxShape** shapes = (PxShape**)_aligned_malloc(sizeof(PxShape*)*numShapes, 16);
actor->getShapes(shapes, numShapes);
for (PxU32 i = 0; i < numShapes; i++)
{
PxShape* shape = shapes[i];
shape->setSimulationFilterData(filterData);
}
_aligned_free(shapes);
}
示例9:
PxRigidDynamic* SampleParticles::Raygun::createRayCapsule(bool enableCollision, PxFilterData filterData)
{
PxRigidDynamic* actor = mSample->getPhysics().createRigidDynamic(PxTransform::createIdentity());
mSample->runtimeAssert(actor, "PxPhysics::createRigidDynamic returned NULL\n");
PxShape* shape = actor->createShape(PxCapsuleGeometry(0.1f, 150.0f), mSample->getDefaultMaterial());
mSample->runtimeAssert(shape, "PxRigidDynamic::createShape returned NULL\n");
shape->setFlag(PxShapeFlag::eSCENE_QUERY_SHAPE, false);
shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, enableCollision);
shape->setSimulationFilterData(filterData);
actor->setRigidDynamicFlag(PxRigidDynamicFlag::eKINEMATIC, true);
actor->setMass(1.0f);
actor->setMassSpaceInertiaTensor(PxVec3(1.0f));
mSample->getActiveScene().addActor(*actor);
return actor;
}
示例10: setupFiltering
/**
* Private method which is used to setup actor collision filtering. To use colision detection callback
* user must define collision pairs.
* @param actor is ponter to scene actor.
* @param filterGroup is actor own id.
* @param filterMask is mask to filter pairs that trigger a contact callback.
*/
void PhysicsManager::setupFiltering(PxRigidActor* actor, PxU32 filterGroup, PxU32 filterMask)
{
PxFilterData filterData;
filterData.word0 = filterGroup;
filterData.word1 = filterMask;
const PxU32 numShapes = actor->getNbShapes();
PxShape** shapes = new PxShape*[numShapes];
actor->getShapes(shapes, numShapes);
for(PxU32 i = 0; i < numShapes; i++)
{
PxShape* shape = shapes[i];
shape->setSimulationFilterData(filterData);
}
delete [] shapes;
}
示例11: PxCloneShape
PxShape* PxCloneShape(PxPhysics &physics, const PxShape& from, bool isExclusive)
{
Ps::InlineArray<PxMaterial*, 64> materials;
PxU16 materialCount = from.getNbMaterials();
materials.resize(materialCount);
from.getMaterials(materials.begin(), materialCount);
PxShape* to = physics.createShape(from.getGeometry().any(), materials.begin(), materialCount, isExclusive, from.getFlags());
to->setLocalPose(from.getLocalPose());
to->setContactOffset(from.getContactOffset());
to->setRestOffset(from.getRestOffset());
to->setSimulationFilterData(from.getSimulationFilterData());
to->setQueryFilterData(from.getQueryFilterData());
return to;
}
示例12: setupFiltering
void CPhysicManager::setupFiltering(physx::PxRigidActor* actor, unsigned int filterGroup, unsigned int filterMask)
{
using namespace physx;
PxFilterData filterData;
filterData.word0 = filterGroup;
filterData.word1 = filterMask;
const PxU32 numShapes = actor->getNbShapes();
PxShape** shapes = (PxShape**) malloc (sizeof(PxShape*)*numShapes);
actor->getShapes(shapes, numShapes);
for(PxU32 i = 0; i < numShapes; i++)
{
PxShape* shape = shapes[i];
shape->setSimulationFilterData(filterData);
}
free(shapes);
}
示例13: SetFilterData
void TCompCharacterController::SetFilterData(PxFilterData& filter)
{
PxRigidActor *ra = m_pActor->getActor()->isRigidActor();
m_filter = filter;
if (ra) {
const PxU32 numShapes = ra->getNbShapes();
PxShape **ptr;
ptr = new PxShape*[numShapes];
ra->getShapes(ptr, numShapes);
for (PxU32 i = 0; i < numShapes; i++)
{
PxShape* shape = ptr[i];
shape->setSimulationFilterData(m_filter);
shape->setQueryFilterData(m_filter);
}
}
}
示例14: SetCollisionResponseForActor
void UDestructibleComponent::SetCollisionResponseForActor(PxRigidDynamic* Actor, int32 ChunkIdx, const FCollisionResponseContainer* ResponseOverride /*= NULL*/)
{
#if WITH_APEX
if (ApexDestructibleActor == NULL)
{
return;
}
// Get collision channel and response
PxFilterData PQueryFilterData, PSimFilterData;
uint8 MoveChannel = GetCollisionObjectType();
if(IsCollisionEnabled())
{
UDestructibleMesh* TheDestructibleMesh = GetDestructibleMesh();
AActor* Owner = GetOwner();
bool bLargeChunk = IsChunkLarge(ChunkIdx);
const FCollisionResponseContainer& UseResponse = ResponseOverride == NULL ? (bLargeChunk ? LargeChunkCollisionResponse.GetResponseContainer() : SmallChunkCollisionResponse.GetResponseContainer()) : *ResponseOverride;
physx::PxU32 SupportDepth = TheDestructibleMesh->ApexDestructibleAsset->getChunkDepth(ChunkIdx);
const bool bEnableImpactDamage = IsImpactDamageEnabled(TheDestructibleMesh, SupportDepth);
CreateShapeFilterData(MoveChannel, GetUniqueID(), UseResponse, 0, ChunkIdxToBoneIdx(ChunkIdx), PQueryFilterData, PSimFilterData, BodyInstance.bUseCCD, bEnableImpactDamage, false);
PQueryFilterData.word3 |= EPDF_SimpleCollision | EPDF_ComplexCollision;
SCOPED_SCENE_WRITE_LOCK(Actor->getScene());
TArray<PxShape*> Shapes;
Shapes.AddUninitialized(Actor->getNbShapes());
int ShapeCount = Actor->getShapes(Shapes.GetData(), Shapes.Num());
for (int32 i=0; i < ShapeCount; ++i)
{
PxShape* Shape = Shapes[i];
Shape->setQueryFilterData(PQueryFilterData);
Shape->setSimulationFilterData(PSimFilterData);
Shape->setFlag(PxShapeFlag::eSCENE_QUERY_SHAPE, true);
Shape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true);
Shape->setFlag(PxShapeFlag::eVISUALIZATION, true);
}
}
#endif
}
示例15: CreateBall
Entity* CreateBall(float _fRadius, SimpleTree& _rParentNode)
{
Entity* pBall = new Entity(EntityCategories::BALL);
// The model
Sphere* pSphere = new Sphere(Vector2(), _fRadius);
pSphere->setColour(BALL_COLOUR);
pSphere->setLevelOfDetail(10);
pBall->addComponent(pSphere);
pSphere->setEntity(pBall);
// The physical body
Body::Material material;
material.density = 0.5f;
material.friction = 0.5f;
material.restitution = 0.5f;
PhysXBody* pBody = static_cast<PhysXBody*>(PhysicsFactory::getInstance()->createBody(material, pSphere,
BALL_POSITION, true));
pBall->addComponent(pBody);
pBody->setEntity(pBall);
// Collision detection
PxRigidDynamic* pRigidDynamic = pBody->getActor()->isRigidDynamic();
PxFilterData filterData;
filterData.word0 = EntityCategories::BALL;
filterData.word1 = EntityCategories::WALL_BLOCK;
PxShape* shapes;
pRigidDynamic->getShapes(&shapes, 1);
shapes->setSimulationFilterData(filterData);
pRigidDynamic->setContactReportThreshold(DESTRUCTION_FORCE_THRESHOLD);
// The scene
SimpleTree* pNode = new SimpleTree;
setTranslation(pNode->getTransformation(), BALL_POSITION);
pNode->setModel(pSphere);
pBody->setNode(pNode);
_rParentNode.addChild(pNode);
GazEngine::addEntity(pBall);
return pBall;
}