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
- Scene and items
- Meshes
- The Mesh Stack
- Channels and animation
- Materials
- Undo and history
- The .opscene file
The picture
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
}
- Points and polygons are positions in their lists (32-bit indices). A polygon is its list of point indices, any number of sides.
- Corners (one polygon's use of one point) have no list of their own. Per-corner data, such as UVs, is a list per polygon with one entry per corner.
- Edges are not stored. An edge is a pair of point indices, low one first, so both directions name the same edge. The edge list is worked out from the polygons when a tool needs it, and remembered between frames. Edge data (creases, edge selection sets) is keyed by that pair.
- Selection sets live inside the mesh, so they're saved with it and undo restores them like geometry.
- Limits: up to 100 million points and 100 million polygons per mesh.
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
- Tags. Each polygon names its material and part by tag, plain text on the polygon.
- 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.
- 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.
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": [ … ] }
}
- The Rust structs are the format.
sceneis the Scene written field for field. Fields at their default value are left out, so simple scenes stay small and readable. - Unknown fields are refused, so an older build won't open a newer file and silently drop data.
- Versions. Each new kind of saved data gets a version number (66 today). A save writes the lowest version that can hold what the scene actually uses, so a scene using nothing new still opens in older builds.
- Big arrays are packed. Points, polygons or a UV map with 1,024 or more entries are written as base64 blobs of little-endian numbers, so values come back bit for bit. Smaller ones stay plain JSON.
- Not in the file: painted pixels (saved as their own images), the undo history, session ids and anything computed.
- Safe saves and loads. A save writes beside the old file, flushes it to disk and swaps it in one step, so a failed save leaves the old file as it was. A load checks every array length and index, and a bad file is refused without touching the open scene.
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.