Mesh topology and solid operations
Trace editable corners, render-mesh baking, BSP solid operations, bounds fitting, and independent collision geometry.
Asterune keeps editable mesh topology separately from the triangles submitted to the GPU. The editable form stores positions and polygon faces with per-corner attributes. Baking produces render vertices, triangle indices, material sections, and a mapping back to the editable source vertices.
Solid operations transform and split that topology before producing another bake. Collision can follow the resulting mesh or retain an earlier shape. Editing geometry therefore has consequences beyond changing a vertex buffer.
Positions, corners, and render vertices
An editable face contains corners that refer to position indices. Each corner also carries UV coordinates and an optional explicit normal. Adjacent faces can share one position while retaining different UVs or normals at that point. This represents a texture seam or a hard edge without requiring separate editable positions.
Baking first computes face normals, face areas, and the list of faces incident to each position. A finite nonzero explicit corner normal takes precedence. Otherwise, a flat face uses its own normal. A smooth face averages incident smooth-face normals within its smoothing-angle threshold, weighted by face area. The default angle is 30 degrees.
The bake sorts faces by material and records contiguous index sections. It triangulates each polygon, then deduplicates render vertices by quantized position, normal, and UV coordinates. The quantization uses a scale of 10,000 for those values. A UV seam can therefore create multiple render vertices from one editable position even when its geometry does not change.
Each resulting vertex retains its editable source index. Skin weights and morph targets can use that correspondence after triangulation and seam splitting. The number of GPU vertices is consequently not a direct measure of the number of editable positions or deformation controls.
Polygon triangulation
Triangular faces already supply their final corner order. Larger faces project into 2 dimensions by dropping the dominant normal axis while preserving winding. The triangulator then removes ears from that projected polygon.
An ear must be convex in the polygon's winding and contain no other remaining corner. Removing it emits one triangle and reduces the boundary until 3 corners remain. This handles ordinary concave polygons without filling their concavity with the triangles of an unconditional fan.
The search is bounded by a guard proportional to the square of the corner count. If it cannot complete the ear decomposition, it discards the partial triangulation and uses a fan from the first corner. That fallback terminates the bake; it does not establish that a self-intersecting or otherwise malformed polygon has become a valid solid.
Operand coordinate frames
A solid operation evaluates every operand in the subject part's local frame. It first scales the operand's authored mesh to its part size, then applies the operand's rotation and translation relative to the subject. This keeps plane tests in one coordinate system even when the parts have different world poses.
The operation applies operands sequentially. After each combination, the engine checks the resulting triangle count against its 250,000-triangle budget. A result above that bound returns a size error instead of publishing an oversized combined part. A result with no remaining mesh returns an empty-result error.
The final mesh is recentered on its bounds. Its midpoint becomes a local offset, and the containing part moves by the corresponding rotated world offset. Its size becomes the resulting extent. This preserves the surface's world position while aligning the part's bounds with the mesh used for culling and queries.
Direct edits through a bound live mesh follow a different coordinate rule: they retain the mesh coordinates written by the edit. Assigning a replacement mesh performs the fitting operation. Repeated live edits therefore do not implicitly recenter the coordinate system after each vertex change.
BSP classification and splitting
Constructive solid geometry (CSG) uses binary space partitioning (BSP) over triangulated polygons. A tree cell chooses a polygon plane and divides the remaining polygons into front, back, and coplanar groups. Children are stored by index in an array; construction and clipping use explicit work stacks.
A vertex's signed plane distance determines its classification, with a plane
tolerance of 1e-4. A polygon crossing a plane splits where each crossing edge
intersects it. The split linearly interpolates position and UV coordinates;
the resulting pieces retain the polygon's material and smoothing flag.
Coplanar polygons are classified further by the direction of their own normal.
Clipping keeps the exterior side of another tree and removes its interior polygons. Inverting a tree flips planes and triangle winding and exchanges its front and back children. Union, difference, and intersection combine those clipping and inversion operations in different orders. Difference can therefore retain an inverted operand boundary as the interior wall of a cut.
After combining the trees, the engine welds nearby positions, drops degenerate faces, merges compatible coplanar faces, and compacts unused topology. Coplanar merging requires matching material and smoothing state, an oppositely shared edge, and a convex merged boundary. The merge repeats until no more compatible pairs remain. It does not merge every visually adjacent triangle regardless of its surface attributes.
Baked identity and derived resources
A geometry component shares its editable mesh and baked representation through reference-counted storage. A topology edit clones the editable mesh and creates a replacement bake. Geometry fingerprints and bake keys let consumers identify that replacement instead of treating every frame as a fresh upload.
The bake retains bounds, material sections, source indices, and a convex hull.
Its volume calculation sums each triangle's signed tetrahedral contribution
using dot(a, cross(b, c)) / 6, then takes the absolute result. That calculation
uses the oriented surface; it is not the volume of the mesh's bounding box.
Changing the mesh rebuilds those derived resources. Deformation metadata and an explicitly frozen collision source survive the mesh replacement, while pose and binding caches are refreshed through their respective update paths. A mesh edit can therefore require a complete bake even when only one position changed. Instance snapshots share existing geometry; they do not make the subsequent baking work incremental at the vertex level.
Collision geometry and deformation
When collision follows the mesh, collision creation reads the current bake and scales it from authored extent to the part's size. Freezing collision retains the bake, extent, and collider cache from that moment. Later render edits then use the replacement geometry without silently replacing that retained physical shape. Refreshing frozen collision captures another explicit source.
The solver's chosen representation also depends on body type. A dynamic baked mesh ordinarily uses a convex hull, while an anchored mesh can retain a triangle surface or a recognized convex shape. Explicit collision geometry takes precedence. The exact synchronization and cache rules are described in Physics stepping and spatial queries.
Skinning and morph deformation operate on the render representation. Their source-index mapping connects the baked vertices to authored controls, but a posed vertex buffer does not automatically recook a collider for every pose. Geometry, depth, and transparency explains how the GPU path retains preceding posed positions for temporal motion.
For mesh-editing operations and their arguments, see GeometryPart and Mesh.