Skip to content

Code Design

Iris edited this page Mar 15, 2025 · 1 revision

In this section I discuss the structure and design of Voxircle's code, mostly for myself.

List of objects (traits, structs, and enums)

  • Shape<Alg, Params>: trait abstracting a class of shapes that can be configured by a set of parameters. Objects implementing this trait may carry some parameters that (globally) configure how the slider/code set the parameters
    • Squircle: object implementing Shape<SquircleAlgorithm, SquircleParams>. Carries single_radius: bool that says whether or not both the major and minor radii of the squircle should be the same (this is reflected in how the slider/code look and work)
      • SquircleParams: struct carrying all the parameters that define a squircle
      • SquircleAlgorithm: enum of all the algorithms that voxilize the squircle (possibly carrying additional configuration options, such as for Percentage)
    • Line (not implemented)
  • LayerParameters: all data required for generating a single layer. Contains:
    • One SquircleAlgorithm which is run on all of
    • Vec<SquircleParams>, which come from sliders (in no-code case) or sampling the rhai code fields
  • Blocks: struct encoding a voxelization, is the output of a generation algorithm
  • ParamField: A parameter field, which is a slider with a code field. Also does its own (more or less modular) UI and sampling
    • FieldState
  • math: objects with algorithms especially for the generation of Blocks
    • Vec2
    • Mat2
    • Orientation
    • Square
  • Metrics: struct containing all metrics (such as nr_blocks, etc.)
    • SparseBlocks: struct encoding a voxelization, is used in metrics (esp. the boundary)
    • SymmetryType: enum of the symmetry type
  • App
    • Control
    • SampleCombineMethod
    • SampleDistributeMethod
    • ZVec
    • View

Clone this wiki locally