Skip to main content

MarchingCubesPlugin

A class in Root.Township, Alta.Caves.

Cave generator plugin that turns a density layer into a mesh with marching cubes, one mesh per map chunk. Uses a pregenerated mesh instead when one exists for the same seed.

Constructors​

MemberWhat it is
MarchingCubesPlugin()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

4 private and internal fields
MemberWhat it is
private Plugin generatorLayerThe plugin layer whose values are meshed.
private static Logger loggerNLog logger for this class.
private Dictionary<MapChunk, MarchingCubesPlugin.GeneratedMesh> meshesMeshes built for each chunk, waiting to be collected with GetMesh.
private float thresholdDensity value where the surface is placed (default 0.5).

Methods​

MemberWhat it is
MarchingCubesPlugin.GeneratedMesh GetMesh(MapChunk chunk)Returns and removes the mesh built for the chunk. Throws if none was built.
override void Modify(MapChunk chunk, IPartInstance[] parts)Builds the chunk's mesh from generatorLayer at threshold (or takes the pregenerated one) and stores it for GetMesh.
1 private and internal method
MemberWhat it is
private void EnsureCleanMeshMap()Removes entries for chunks that have been destroyed from meshes.

Used in​

Members of other types that take, return or hold a MarchingCubesPlugin: