Struct MeshSplitter

Struct Documentation

struct legion::physics::MeshSplitter

Public Functions

void InitializePolygons(ecs::entity_handle entity)

Creates a Half-Edge Data structure around the mesh and.

Parameters

inline void BFSPolygonize(std::queue<meshHalfEdgePtr> &halfEdgeQueue, const math::mat4 &transform)

Given a queue of edges and a transform, populates the std::vector ‘meshPolygons’ using BFS.

Note

halfEdgeQueue will be empty after this function

inline bool BFSIdentifyPolygon(meshHalfEdgePtr startEdge, std::shared_ptr<SplittablePolygon> &polygon, std::queue<meshHalfEdgePtr> &halfEdgeQueue, const math::mat4 &transform)

Given an intial startEdge, do a BFS to identify the polygon that the edge is in. Also populates the halfEdgeQueue with the neigbors of the boundary of the polygon.

void MultipleSplitMesh(const std::vector<MeshSplitParams> &splittingPlanes, std::vector<ecs::entity_handle> &entitiesGenerated, bool keepBelow = true, int debugAt = -1)

Given a list of splitting planes, splits the mesh based on the list of splitting planes.

void SplitPolygons(std::vector<SplittablePolygonPtr> &polygonsToSplit, const math::vec3 &planeNormal, const math::vec3 &planePosition, const math::mat4 &transform, std::vector<std::vector<SplittablePolygonPtr>> &resultingIslands, bool keepBelow = true, bool shouldDebug = false)

Given a list of polygons to split in ‘polygonsToSplit’, splits them based on a splitting plane defined by ‘planePosition’ and ‘planeNormal’. The result is then placed in ‘resultingIslands.

void CopyPolygons(std::vector<SplittablePolygonPtr> &originalSplitMesh, std::vector<SplittablePolygonPtr> &copySplitMesh)

Copies the polygons of ‘originalSplitMesh’ and places them in ‘copySplitMesh’.

void CopyEdgeVector(std::vector<meshHalfEdgePtr> &originalHalfEdgeList, std::vector<meshHalfEdgePtr> &resultCopyList)
void BFSFindRequestedAndIntersecting(SplittablePolygonPtr &intialPolygon, std::vector<SplittablePolygonPtr> &originalSplitMesh, std::vector<SplittablePolygonPtr> &originalNonSplitMesh, SplitState requestedState)

Does a floodfill to find polygons that are either intersecting the splitting plane or at the requested state.

void DetectIntersectionIsland(std::vector<SplittablePolygonPtr> &splitPolygons, std::vector<std::vector<SplittablePolygonPtr>> &intersectionIslands)

Given a list of polygons that are intersecting the splitting plane, detects if there are sets of polygons that are disconected from each other.

void SplitPolygon(SplittablePolygonPtr splitPolygon, const math::mat4 &transform, const math::vec3 cutPosition, const math::vec3 cutNormal, SplitState requestedState, std::vector<IntersectionEdgeInfo> &generatedIntersectionEdges, bool shouldDebug = false)

Creates an IntersectingPolygonOrganizer thats splits a given a SplittablePolygon along a plane located at ‘planePosition’ with a normal equal to ‘planeNormal’.

inline bool FindFirstIntersectingOrRequestedState(SplittablePolygonPtr &outfirstFound, SplitState requestedState, std::vector<SplittablePolygonPtr> &polygonList)

Given a list of SplittablePolygons finds the first unvisited SplittablePolygon that has a split state of ‘intersecting’ or a split state of ‘requestedState’.

inline bool FindFirstUnivistedIntersectionPolygon(std::vector<SplittablePolygonPtr> &splitPolygon, SplittablePolygonPtr &foundPolygon)
inline SplittablePolygonPtr CreateIntersectionPolygon(std::vector<IntersectionEdgeInfo> &generatedIntersectionEdges, const math::vec3 &localSplitNormal)
inline void DestroyTestSplitter(ecs::EcsRegistry *m_ecs)
inline void TestSplit()
void DEBUG_DrawPolygonData(const math::mat4 &transform)

Public Members

ecs::entity_handle owner
std::vector<ecs::entity_handle> splitTester
rendering::material_handle ownerMaterialH
std::vector<SplittablePolygonPtr> meshPolygons