bool ActiveEdges::Compute(const EdgeList& edges, const IndexedTriangle* faces, const PxVec3* verts, float epsilon) { // Checkings if(!faces || !verts) return SetIceError("ActiveEdges::ComputeConvexEdges: NULL parameter!"); PxU32 NbEdges = edges.GetNbEdges(); if(!NbEdges) return SetIceError("ActiveEdges::ComputeConvexEdges: no edges in edge list!"); const Edge* Edges = edges.GetEdges(); if(!Edges) return SetIceError("ActiveEdges::ComputeConvexEdges: no edge data in edge list!"); const EdgeDesc* ED = edges.GetEdgeToTriangles(); if(!ED) return SetIceError("ActiveEdges::ComputeConvexEdges: no edge-to-triangle in edge list!"); const PxU32* FBE = edges.GetFacesByEdges(); if(!FBE) return SetIceError("ActiveEdges::ComputeConvexEdges: no faces-by-edges in edge list!"); PX_FREE_AND_RESET(mActiveEdges); mActiveEdges = (bool*)ICE_ALLOC_MEM(sizeof(bool)*NbEdges,EdgeList_ActiveEdges); // Loop through edges and look for convex ones bool* CurrentMark = mActiveEdges; while(NbEdges--) { // Get number of triangles sharing current edge PxU32 Count = ED->Count; // Boundary edges are active => keep them (actually they're silhouette edges directly) // Internal edges can be active => test them // Singular edges ? => discard them bool Active = false; if(Count==1) { Active = true; } else if(Count==2) { PxU32 Op = faces[FBE[ED->Offset+0]].OppositeVertex(Edges->mRef0, Edges->mRef1); Plane PL1 = faces[FBE[ED->Offset+1]].PlaneEquation(verts); if(PL1.Distance(verts[Op])<-epsilon) Active = true; } *CurrentMark++ = Active; ED++; Edges++; } return true; }