Open 3D Engine WhiteBox Gem API Reference 26.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
WhiteBox::Api::Detail Namespace Reference

Classes

struct  V2
 A 2D point on a region's plane (double precision for robust geometry). More...
 

Functions

Csg::TriangleMesh ToTriangleMesh (const WhiteBoxMesh &whiteBox, const AZ::Transform &transform)
 
AZ::Vector3 TriangleMeshPosition (const Csg::TriangleMesh &triangleMesh, uint32_t vertexIndex)
 Reconstruct the world-space position of a triangle-mesh vertex.
 
AZ::Vector3 TriangleNormal (const Csg::TriangleMesh &triangleMesh, size_t triangleIndex)
 Compute the (safe-normalized) normal of the given triangle.
 
AZStd::vector< AZStd::vector< size_t > > GroupCoplanarTriangles (const Csg::TriangleMesh &triangleMesh)
 
double Cross2 (const V2 &a, const V2 &b, const V2 &c)
 Twice the signed area of triangle (a, b, c); > 0 when CCW.
 
bool PointInTri (const V2 &p, const V2 &a, const V2 &b, const V2 &c)
 Is point p inside (or on) triangle (a, b, c)?
 
bool EarClip (const AZStd::vector< V2 > &pts, AZStd::vector< AZStd::array< uint32_t, 3 > > &outTris)
 Ear-clip a simple CCW polygon (2D), emitting triangle index-triples into outTris.
 
bool BridgeHoles (const AZStd::vector< V2 > &outerPts, const AZStd::vector< uint32_t > &outerGid, AZStd::vector< AZStd::vector< V2 > > &holePts, AZStd::vector< AZStd::vector< uint32_t > > &holeGid, AZStd::vector< V2 > &mergedPts, AZStd::vector< uint32_t > &mergedGid)
 
AZStd::unordered_set< uint32_t > ComputeRemovableVertices (const Csg::TriangleMesh &mesh, const AZStd::vector< AZStd::vector< size_t > > &groups)
 
bool CleanCoplanarGroup (const Csg::TriangleMesh &mesh, const AZStd::vector< size_t > &group, const AZ::Vector3 &groupNormal, const AZStd::unordered_set< uint32_t > &removable, AZStd::vector< AZStd::array< uint32_t, 3 > > &outTris)
 
AZ::Vector3 GroupNormal (const Csg::TriangleMesh &mesh, const AZStd::vector< size_t > &group)
 Average (area-weighted) normal of a coplanar triangle group.
 
void RebuildFromTriangleMesh (WhiteBoxMesh &whiteBox, const Csg::TriangleMesh &triangleMesh)
 Replace the contents of the white box mesh with the given triangle mesh.
 

Detailed Description

Internal helpers backing the CSG integration layer (see WhiteBoxCsg.cpp). These convert between white box meshes and the engine-agnostic Csg::TriangleMesh, group/clean the coplanar regions a boolean leaves behind, and rebuild a white box mesh from a triangulated result. Declared here so they can be unit tested and so the implementation file stays focused on definitions.

Function Documentation

◆ BridgeHoles()

bool WhiteBox::Api::Detail::BridgeHoles ( const AZStd::vector< V2 > &  outerPts,
const AZStd::vector< uint32_t > &  outerGid,
AZStd::vector< AZStd::vector< V2 > > &  holePts,
AZStd::vector< AZStd::vector< uint32_t > > &  holeGid,
AZStd::vector< V2 > &  mergedPts,
AZStd::vector< uint32_t > &  mergedGid 
)

Merge holes (CW) into the outer loop (CCW), producing one simple CCW polygon by inserting a 'bridge' edge per hole (classic ear-clipping hole handling).

◆ CleanCoplanarGroup()

bool WhiteBox::Api::Detail::CleanCoplanarGroup ( const Csg::TriangleMesh &  mesh,
const AZStd::vector< size_t > &  group,
const AZ::Vector3 &  groupNormal,
const AZStd::unordered_set< uint32_t > &  removable,
AZStd::vector< AZStd::array< uint32_t, 3 > > &  outTris 
)

Rebuild one coplanar group as clean triangles (global vertex indices) with redundant collinear vertices removed. Returns false for anything it can't safely simplify (the caller then keeps the original triangles).

◆ ComputeRemovableVertices()

AZStd::unordered_set< uint32_t > WhiteBox::Api::Detail::ComputeRemovableVertices ( const Csg::TriangleMesh &  mesh,
const AZStd::vector< AZStd::vector< size_t > > &  groups 
)

Find vertices that sit mid-way along a straight visible edge and are therefore redundant; removing them never opens a crack.

◆ GroupCoplanarTriangles()

AZStd::vector< AZStd::vector< size_t > > WhiteBox::Api::Detail::GroupCoplanarTriangles ( const Csg::TriangleMesh &  triangleMesh)

Group triangles into connected coplanar regions; each region becomes one white box polygon (interior edges hidden).

◆ ToTriangleMesh()

Csg::TriangleMesh WhiteBox::Api::Detail::ToTriangleMesh ( const WhiteBoxMesh &  whiteBox,
const AZ::Transform &  transform 
)

Convert a white box mesh to an indexed triangle mesh, transforming all positions by the given transform. Shared vertices are welded.