Operandi

Data model

What an Operandi scene is made of, in memory and on disk. The code map shows the folders and files; this page shows the data they work on.

The short version: one Scene value holds the whole document. It is plain Rust data, the editor changes it only by running a command, undo keeps earlier copies of it, and a save writes it out as JSON. Big arrays inside it are shared copy-on-write, so those copies are cheap. Everything here lives in the operandi-core crate; the full developer version, with file paths, is docs/DATA_MODEL.md.

The picture

.opscene file (JSON) format: "Operandi" version: 66 scene material_graphs the saved document Saved MaterialX graphs graphs: one per surface bindings: item + tags the materials' master copy Scene items: flat list of Item selection · workplane materials (by tag) shader_tree (the view) animation time · render · groups guides · images contains Animation channels: key → curve + rest markers · channel sets rig: pieces, pivots, IK key = item id + channel name Item id · name · parent id transform mesh (mesh slot) kind: camera, light … mesh_stack common: user channels locked / hidden elements each Mesh vertices: positions faces: point indices, material + part tags uv_maps: per corner attributes: weight, colour, morph maps, selection sets, creases edges are not stored points at binds to Computed, never saved or undone Mesh Stack results · evaluation graph edge lists and topology caches session ids of points, edges, polygons GPU buffers rebuilt from
Solid arrows: "contains". Dashed arrows: "refers to by id" or "is computed from". Everything inside the solid boxes is saved and undone; the dashed box is rebuilt whenever it's needed.

Scene and items

The Scene is the document. It holds every item, the selection, the work plane, materials and the Shader Tree, animation, time, render settings, item groups, guides and Backdrop images. A few conveniences (an index of where each item sits, paint pixels) ride along on the scene but are never saved; opening a file rebuilds them.

The hierarchy is a flat list. items is one list, and each item names its parent by id (or none, for a root). Sibling order is list order. There is no tree object in memory; helpers walk the list as a tree when needed.

Every item has the same shape: an id that never changes or gets reused, a name, a visibility eye, a transform (position, rotation in radians, scale, rotation order), a parent id and a mesh slot. What kind of item it is comes from one optional field per kind: camera, light, locator, environment, backdrop, texture, replicator, or an item a kit adds. An item with none of those set is a mesh item. Shared tab settings and the item's user channels live in common. Item groups are separate from the hierarchy: a group is a name and a list of item ids.

Meshes

Mesh {
  vertices:   list of 3D points (f64)
  faces:      list of Face { point indices, material tag, part tag, smooth }
  uv_maps:    name → per polygon → per corner → UV or empty
  attributes: weight / colour / normal / morph maps, selection sets,
              edge creases, which polygons are lines
}

Because indices are positions in a list, deleting geometry renumbers them. For "the same point" across an edit, the editor keeps session-only ids that edits like merge, split and collapse carry over. They're never saved.

Why big meshes stay cheap

The polygon list, UV maps and attributes are each shared copy-on-write: copying a mesh costs a reference count, and the first change copies only the part that changed. On top of that, an item's mesh slot can hold the mesh packed into a few flat arrays instead of one object per polygon, exactly and bit for bit, and code that only reads works on either form. Each slot carries a stamp that changes only when its contents might have, so caches key on that.

The Mesh Stack

When an item has a Mesh Stack, its mesh is the Base Mesh and the stack is a list of operations run on top of it, bottom first. Each op has an id, an on/off switch, a type name, its values (as JSON, checked by the op type) and what it acts on. An op type this build doesn't know is kept as a placeholder: it passes its input through and saves back unchanged, so a file using a missing kit doesn't lose anything.

The stack is the recipe, and the recipe is what gets saved and undone. The result, the mesh you see, render and export, is computed and cached per op, and is never stored in the scene, the undo history or the file. Ops that read other items (Merge Meshes, Boolean) name them by id, and loops are refused.

Channels and animation

A channel is one named value: pos.X, rot.Y, scl.Z for transforms, and names like visible or color.r for everything else. Channels aren't a second copy of the data. They're a named view onto fields the item already has, set through one command each, so every channel change is one undo step. User channels are the exception: values you add to an item yourself, stored on the item.

Time is exact. Times are whole ticks (254,016,000,000 per second), which divides evenly into every common frame rate, so keys never drift by rounding.

The scene's animation holds a map from (item id, channel name) to an animated channel: a key curve plus the channel's rest value from before it was first keyed. A curve is a list of keys sorted by time, each with a value and its in and out slopes. Animation also holds markers, channel sets (the channel panel's lists), shadow curves and the rig.

The one rule to remember: the item's own field always holds the value at the current time. Every tool, panel, render and export reads that field. Changing the time writes each curve's value into its field. If you edit a field without keying it, the edit sits there until the next time change replaces it.

Materials

  1. Tags. Each polygon names its material and part by tag, plain text on the polygon.
  2. The Shader Tree. One per scene: a flat list of layers (materials, textures, groups, outputs), each with a parent and an order among its siblings. Material Groups are masked to an item and a tag.
  3. MaterialX graphs, the saved master copy. A save writes every distinct surface as a MaterialX graph, plus bindings saying which item, tags and selection sets use which graph. The tree's layers are saved too, as the layout of the view.

On open, the graphs are the truth. If the layers would now produce a different surface (an older build, or a graph edited in another program), the saved graph is pinned to those polygons and used for rendering and export until you edit the layers that shade them. Old files without graphs open from their layers and gain graphs on their next save.

Undo and history

Every change is a command, and one finished command (or one drag) is one undo step. A step is a checkpoint: the whole scene as it was before and after, the step's name, and the command lines that made it. Undo puts the "before" scene back. There are no per-tool undo routines and no diffs to replay, which is why every command gets undo for free.

One undo step: "Move" scene before scene after old point positions polygons, UV maps, attributes: one copy new point positions both share
Whole-scene snapshots are cheap because unchanged data is shared. A step that only moved points pays for one extra point list, not a second copy of the mesh.

The history keeps up to the Max Undo Level (100 by default) and trims the oldest steps when the data that only they hold passes a memory budget. Undo deliberately leaves alone the current time, painted pixels, view state such as which channel set is showing, and anything computed. Inside an open tool, Undo first takes back the tool's own last tweak and keeps the tool open. The history belongs to the open scene (one per tab) and is never saved in the file.

The .opscene file

{
  "format": "Operandi",
  "version": 66,
  "scene": { "items": [ … ], "next_id": 12, "selection": { … }, … },
  "material_graphs": { "graphs": [ … ], "bindings": [ … ] }
}

Presets use the same format with an extra header. Other formats (OBJ, glTF, FBX, USD and the rest) are importers and exporters that convert to and from the same Scene.

Built from the code on main, November 2026. If something here disagrees with the code, the code wins; please open an issue.