Article Directory
Problem Description
The normal of the slope of a staircase is reversed. As a result, the model will be stuck on this staircase and cannot come out, similar to a closed box. Because the model can't be changed now, we are ready to solve it technically: enable the double-sided function.
- PVD front sees the stairs, can't see the slope
- Bevel seen on the reverse side of PVD
- Combined to see a closed space inside, the capsule body fell into the card and stuck
Create double-sided mesh
By default, PhysX only creates one triangle. In PVD, you can also see that it is not drawn from the back. Set the Flag when creating the triangle geometry: PxMeshGeometryFlag :: eDOUBLE_SIDED
PxTriangleMeshGeometry(pTriangleMesh, PxMeshScale(PxVec3(gScale.x, gScale.y, gScale.z),
PxQuat(gScaleRotaion.x, gScaleRotaion.y, gScaleRotaion.z, gScaleRotaion.w)), PxMeshGeometryFlag::eDOUBLE_SIDED);
The double-sided effect of
PVD, the oblique surface can be seen on the front so that it can be seen in the PVD, and the obverse surface can be seen on both the front and the back. However, the capsule is still stuck inside ~
problem solved
- The move function used for our mobile, found that the move function does not support double-sided by default
if(PxMeshQuery::sweep(unitDir, impact.mDistance, geom, pose, nbTris, triangles, sweepHit, getSweepHintFlags(sweepTest->mUserParams), &cachedIndex))
The sweep function finally used by the eMESH_BOTH_SIDES move function, the last parameter is whether to support both sides, but the default is false
bool physx::PxMeshQuery::sweep( const PxVec3& unitDir, const PxReal maxDistance,
const PxGeometry& geom, const PxTransform& pose,
PxU32 triangleCount, const PxTriangle* triangles,
PxSweepHit& sweepHit, PxHitFlags hintFlags_,
const PxU32* cachedIndex, const PxReal inflation, bool doubleSided)
{
- Modify the SDK code directly. The
last parameter is set to true
if(PxMeshQuery::sweep(unitDir, impact.mDistance, geom, pose, nbTris, triangles, sweepHit, getSweepHintFlags(sweepTest->mUserParams), &cachedIndex, 0, true))
The problem is solved
to sum up
- If you open a double-sided, the efficiency will definitely decline, the correct way to solve this problem is to modify the model