Assembly Spline – Distribution
Generates mesh distribution patterns (random or round-robin) for assembly spline component placement, with probability weighting and variation support.
Generates mesh distribution patterns (random or round-robin) for assembly spline component placement, with probability weighting and variation support.
Module Info
| Key | Value |
|---|---|
| File | lua/ge/extensions/editor/assemblySpline/distribution.lua |
| Type | Required module (not an extension) |
| Dependencies | editor/assemblySpline/molecule |
Public Functions
| Function | Returns | Description |
|---|---|---|
M.computeMeshMap(molecule, numPlacements, spline) | rigidMaps, bridgeMaps | Computes component distribution maps for all rigid and bridge components using random or round-robin patterns |
Component Group Structure
componentGroup = {
mesh = {
id = "fence_post",
meshPath = "/props/fence/post.dae",
randomWeight = 1.0
},
randomWeight = 1.0, -- base component weight
variations = {
{ id = "fence_post_alt", meshPath = "/props/fence/post_alt.dae", randomWeight = 0.5 },
}
}Algorithm Details
Random Distribution
- Collects all enabled components (base + variations) using
mol.getRigidEnabled/mol.getBridgeEnabled - Normalises
randomWeightvalues to sum to 1.0 - For each placement, samples a component using cumulative probability
- Returns array of mesh paths
Round-Robin Distribution
- Collects all enabled components
- Cycles through them sequentially for each placement
- Returns array of mesh paths
Internal State
Pre-allocated arrays are reused across calls for performance:
| Variable | Purpose |
|---|---|
componentMeshData | Parallel array of mesh data objects |
componentProbabilities | Parallel array of normalised weights |
resultArrays | Cached result arrays keyed by component ID |
Usage Example
local dist = require('editor/assemblySpline/distribution')
-- Compute distribution maps for all rigid and bridge components
local rigidMaps, bridgeMaps = dist.computeMeshMap(molecule, numPlacements, mySpline)Functions
computeMeshMap(molecule, numPlacements, spline)
Computes component distribution maps for all rigid and bridge components in the molecule. Uses random or round-robin distribution based on each component group's isRandom flag. Bridge maps have numPlacements - 1 entries (one per adjacent molecule pair).
molecule(table) - Molecule structure withrigidsandbridgesarraysnumPlacements(number) - Number of molecule placement positions along the splinespline(table) - The assembly spline (used to check enabled states)
Returns: rigidMaps (table), bridgeMaps (table) - Indexed arrays of mesh path arrays per component group
See Also
- Assembly Spline - Main tool
- Assembly Spline Import - Scene import
Editor API – Dynamic Decals Textures
Manages the texture file library for the dynamic decals system, including sidecar metadata files, tag indexing, and file-change monitoring.
Assembly Spline – Import
Imports existing scene objects (TSStatic groups) into assembly splines by analyzing positions, fitting curves, and reconstructing spline data with undo support.