static FVector FindHeightFieldOpposingNormal(const PxLocationHit& PHit, const FVector& TraceDirectionDenorm, const FVector InNormal) { if (IsInvalidFaceIndex(PHit.faceIndex)) { return InNormal; } PxHeightFieldGeometry PHeightFieldGeom; const bool bReadGeomSuccess = PHit.shape->getHeightFieldGeometry(PHeightFieldGeom); check(bReadGeomSuccess); //we should only call this function when we have a heightfield if (PHeightFieldGeom.heightField) { const PxU32 TriIndex = PHit.faceIndex; const PxTransform PShapeWorldPose = PxShapeExt::getGlobalPose(*PHit.shape, *PHit.actor); PxTriangle Tri; PxMeshQuery::getTriangle(PHeightFieldGeom, PShapeWorldPose, TriIndex, Tri); PxVec3 TriNormal; Tri.normal(TriNormal); return P2UVector(TriNormal); } return InNormal; }
static bool FindHeightFieldOpposingNormal(const PxLocationHit& PHit, const FVector& TraceDirectionDenorm, FVector& OutNormal) { PxHeightFieldGeometry PHeightFieldGeom; bool bSuccess = PHit.shape->getHeightFieldGeometry(PHeightFieldGeom); check(bSuccess); //we should only call this function when we have a heightfield if (PHeightFieldGeom.heightField) { const PxU32 TriIndex = PHit.faceIndex; const PxTransform PShapeWorldPose = PxShapeExt::getGlobalPose(*PHit.shape, *PHit.actor); PxTriangle Tri; PxMeshQuery::getTriangle(PHeightFieldGeom, PShapeWorldPose, TriIndex, Tri); PxVec3 TriNormal; Tri.normal(TriNormal); OutNormal = P2UVector(TriNormal); return true; } return false; }
static PxU32 createInvisibleWalls(const CCTParams& params, const PxTriangle& currentTriangle, TriArray& worldTriangles, IntArray& triIndicesArray) { const PxF32 wallHeight = params.mInvisibleWallHeight; if(wallHeight==0.0f) return 0; PxU32 nbNewTris = 0; // Number of newly created tris const PxVec3& upDirection = params.mUpDirection; PxVec3 normal; currentTriangle.normal(normal); if(testSlope(normal, upDirection, params.mSlopeLimit)) { const PxVec3 upWall = upDirection*wallHeight; PxVec3 v0p = currentTriangle.verts[0] + upWall; PxVec3 v1p = currentTriangle.verts[1] + upWall; PxVec3 v2p = currentTriangle.verts[2] + upWall; // Extrude edge 0-1 PxVec3 faceNormal01; { // 0-1-0p const PxTriangle tri0_1_0p(currentTriangle.verts[0], currentTriangle.verts[1], v0p); worldTriangles.pushBack(tri0_1_0p); // 0p-1-1p const PxTriangle tri0p_1_1p(v0p, currentTriangle.verts[1], v1p); worldTriangles.pushBack(tri0p_1_1p); tri0p_1_1p.normal(faceNormal01); } // Extrude edge 1-2 PxVec3 faceNormal12; { // 1p-1-2p const PxTriangle tri1p_1_2p(v1p, currentTriangle.verts[1], v2p); worldTriangles.pushBack(tri1p_1_2p); // 2p-1-2 const PxTriangle tri2p_1_2(v2p, currentTriangle.verts[1], currentTriangle.verts[2]); worldTriangles.pushBack(tri2p_1_2); tri2p_1_2.normal(faceNormal12); } // Extrude edge 2-0 PxVec3 faceNormal20; { // 0p-2-0 const PxTriangle tri0p_2_0(v0p, currentTriangle.verts[2], currentTriangle.verts[0]); worldTriangles.pushBack(tri0p_2_0); // 0p-2p-2 const PxTriangle tri0p_2p_2(v0p, v2p, currentTriangle.verts[2]); worldTriangles.pushBack(tri0p_2p_2); tri0p_2p_2.normal(faceNormal20); } const PxU32 triIndex = PX_INVALID_U32; for(PxU32 i=0;i<6;i++) triIndicesArray.pushBack(triIndex); nbNewTris += 6; } return nbNewTris; }