Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofpackage ZeroBlender.package·originates fromworld 240544fe-7…

meshMods

Blender's DECIMATE, TRIANGULATE and WEIGHTED_NORMAL modifiers over `meshBuf` meshes (Blender space). Each function takes an MB Mesh and returns a NEW one, leaving the input untouched, with material slots (`FM`), smooth flags (`SMF`) and UV layers carried over. All per-element dat…

by◐Deata·posted 1mo ago
What it does

meshMods

Blender's DECIMATE, TRIANGULATE and WEIGHTED_NORMAL modifiers over meshBuf meshes (Blender space). Each function takes an MB Mesh and returns a NEW one, leaving the input untouched, with material slots (FM), smooth flags (SMF) and UV layers carried over. All per-element data stays in substrate stores (MB.words / MB.vec3s / MB.hash), never in mesh-sized Luau tables, and every scratch store is freed when the call ends, including when it fails. The modifier stack (blenderSession) uses it to evaluate these modifiers.

local Mods = require("~ZeroBlender.modules.meshMods")
local low = Mods.decimate(m, {decimate_type="COLLAPSE", ratio=0.5})
local tri = Mods.triangulate(m, {quad_method="BEAUTY", ngon_method="BEAUTY", min_vertices=4})
local wn  = Mods.weightedNormal(m, {mode="FACE_AREA", weight=50, thresh=0.01})  -- wn.CNC: V3 per corner
local r   = Mods.apply(m, "DECIMATE", values)                                    -- dispatch by type

decimate(m, values)

  • COLLAPSE: triangulates, then does Garland-Heckbert quadric edge collapse until there are at most ratio * triangles faces. Boundary edges add perpendicular penalty planes (weight 100). A collapse is rejected when it would flip or degenerate a face normal, or when it would break the link condition (keeping the surface manifold). A binary heap in word stores with lazy invalidation orders the collapses. With use_collapse_triangulate=false, faces whose vertices never moved come back as the original quads and n-gons. use_symmetry keeps vertices on the mirror plane on it.
  • DISSOLVE (planar): adjacent faces join while their area-weighted normals stay within angle_limit. Each region bounded by one simple loop becomes an n-gon, found by walking its boundary. Vertices left between two nearly collinear edges are dropped. Supports delimit containing "MATERIAL" and use_dissolve_boundaries.
  • UNSUBDIV: reverses grid subdivision iterations times on all-quad meshes. Vertices are classified by 2-colouring the edge graph and then the quad diagonals. A mesh that is not a subdivided grid raises NotImplementedError: DECIMATE UNSUBDIV ....

triangulate(m, values)

Faces with min_vertices or more corners are split. quad_method is one of BEAUTY, FIXED (0-2), FIXED_ALTERNATE (1-3), SHORTEST_DIAGONAL or LONGEST_DIAGONAL. ngon_method CLIP ear-clips (MB.triangulateFace), and BEAUTY ear-clips and then flips edges. Every output corner copies the UVs of its source corner exactly. keep_custom_normals carries CNC/CNV.

weightedNormal(m, values)

Follows MOD_weighted_normal.cc. Values are corner angle, face area, or both multiplied, depending on mode. Items (fans) receive them in descending order: num_set grows when a value differs from the current one by more than thresh, and the face normal is added with weight val / weight^num_set. Here weight is the modifier weight divided by 50 (32767 at 100, 1/32767 at 1, and (w-1)*25 when that is greater than 1). With keep_sharp, fans split at m.SHARP edges (a W per MB.edges(m) edge), at flat faces (m.SMF) and at boundaries. Otherwise there is one fan per vertex. use_face_influence reads m.FSTR (a W per face: -1 weak, 0 medium, 1 strong). The result is a copy of m with CNC, a V3 with one normal per corner.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

Blender DECIMATE, TRIANGULATE and WEIGHTED_NORMAL modifiers over meshBuf meshes. Every function takes an MB Mesh in Blender space and returns a NEW mesh; the input is left untouched. Per-element data lives only in substrate stores (MB.words / MB.vec3s / MB.hash); every scratch store is registered with a small arena (one Luau entry per store, never per element) and freed when the operation ends, error or not.

acosc(x: ?) → void

argtypedescription
x?

arena( ) → void

w(n: ?, fill: ?) → void

argtypedescription
n?
fill?

v3(n: ?) → void

argtypedescription
n?

hash(ar: ?, exp: ?) → void

argtypedescription
ar?
exp?

add(s: ?) → void

argtypedescription
s?

mesh(m: ?) → void

A result mesh: freed only when the operation fails.

argtypedescription
m?

free(failed: ?) → void

argtypedescription
failed?

run(body: ?, ...: ?) → void

argtypedescription
body?
...?

hpush(H: ?, K: ?, id: ?, key: ?) → void

argtypedescription
H?
K?
id?
key?

hpop(H: ?, K: ?) → void

argtypedescription
H?
K?

newOut(src: ?) → void

A new mesh sharing src's vertex positions (copied); faces are pushed with r.C:push(v) + SC:push(sourceCorner) and closed with closeOut(r,SF,sourceFace).

argtypedescription
src?

closeOut(r: ?, SF: ?, f: ?) → void

argtypedescription
r?
SF?
f?

finish(r: ?, src: ?, SF: ?, SC: ?, normals: ?) → void

Material slots, smooth flags and UV layers (exact copies from source corners; a corner with SC = -1 keeps whatever its layer already holds).

argtypedescription
r?
src?
SF?
SC?
normals?

clone(m: ?, normals: ?) → void

argtypedescription
m?
normals?

area2(ax: ?, ay: ?, az: ?, bx: ?, by: ?, bz: ?, cx: ?, cy: ?, cz: ?, nx: ?, ny: ?, nz: ?) → void

Signed doubled area of (a,b,c) projected on n.

argtypedescription
ax?
ay?
az?
bx?
by?
bz?
cx?
cy?
cz?
nx?
ny?
nz?

dist(ax: ?, ay: ?, az: ?, bx: ?, by: ?, bz: ?) → void

argtypedescription
ax?
ay?
az?
bx?
by?
bz?

quadFacs(m: ?, c0: ?, c1: ?, c2: ?, c3: ?, nx: ?, ny: ?, nz: ?) → void

Blender's quad "beauty" (BLI_polyfill_beautify_quad_rotate_calc): for the quad c0..c3 (corner ids), the area/perimeter quality of splitting along 0-2 and along 1-3, whether each split gives two positive triangles, and both diagonals.

argtypedescription
m?
c0?
c1?
c2?
c3?
nx?
ny?
nz?

quadSplit13(m: ?, f: ?, s: ?, method: ?) → void

true = split quad (s..s+3) along corners 1-3.

argtypedescription
m?
f?
s?
method?

beautify(m: ?, f: ?, Tl: ?) → void

Edge flips over an ear-clipped n-gon (corner triples in Tl) until no flip raises the beauty measure (BLI_polyfill_beautify).

argtypedescription
m?
f?
Tl?

triangulate(m: ?, values: ?) → void

values: {min_vertices=4, quad_method="BEAUTY", ngon_method="BEAUTY", keep_custom_normals=false}

argtypedescription
m?
values?

tri(a: ?, b: ?, c: ?, f: ?) → void

argtypedescription
a?
b?
c?
f?

f32(x: ?) → void

argtypedescription
x?

qget(Q: any, v: number) → void

argtypedescription
Qany
vnumber

qset(Q: ?, v: ?, q0: ?, q1: ?, q2: ?, q3: ?, q4: ?, q5: ?, q6: ?, q7: ?, q8: ?, q9: ?) → void

argtypedescription
Q?
v?
q0?
q1?
q2?
q3?
q4?
q5?
q6?
q7?
q8?
q9?

qeval(q0: ?, q1: ?, q2: ?, q3: ?, q4: ?, q5: ?, q6: ?, q7: ?, q8: ?, q9: ?, x: ?, y: ?, z: ?) → void

argtypedescription
q0?
q1?
q2?
q3?
q4?
q5?
q6?
q7?
q8?
q9?
x?
y?
z?

collapse(A: ?, m: ?, v: ?) → void

argtypedescription
A?
m?
v?

triPlane(t: ?) → void

argtypedescription
t?

qaddPlane(i: ?, a: ?, b: ?, c: ?, d: ?, w: ?) → void

argtypedescription
i?
a?
b?
c?
d?
w?

edgeCost(a: ?, b: ?) → void

Edge cost: optimal point of the summed quadric, else the best of ends/middle.

argtypedescription
a?
b?

newTok( ) → void

pushEdge(a: ?, b: ?) → void

argtypedescription
a?
b?

triHas(t: ?, x: ?) → void

argtypedescription
t?
x?

prune(i: ?) → void

argtypedescription
i?

flips(t: ?, u: ?, px: ?, py: ?, pz: ?) → void

Moving u (a corner of t) to p flips or collapses t?

argtypedescription
t?
u?
px?
py?
pz?

hasDelimit(d: ?, name: ?) → void

argtypedescription
d?
name?

dissolve(A: ?, m: ?, v: ?) → void

argtypedescription
A?
m?
v?

find(x: ?) → void

argtypedescription
x?

nextC(c: ?) → void

argtypedescription
c?

unsubdivOnce(A: ?, m: ?) → void

Reverses one level of grid subdivision on an all-quad mesh: vertices split into original (O), edge (E) and face (F) points by 2-colouring the edge graph (O/F vs E) and then the quad diagonals (O vs F); each F point's fan of quads becomes one face through its O corners. Extraordinary vertices seed O.

argtypedescription
A?
m?

extraordinary(i: ?) → void

argtypedescription
i?

nb(c: ?, d: ?) → void

argtypedescription
c?
d?

fail( ) → void

bfsCol(seed: ?) → void

argtypedescription
seed?

bfsKind(seed: ?) → void

argtypedescription
seed?

decimate(m: ?, values: ?) → void

values: {decimate_type="COLLAPSE"|"UNSUBDIV"|"DISSOLVE", ratio, iterations, angle_limit, use_collapse_triangulate, use_symmetry, symmetry_axis, delimit, use_dissolve_boundaries}

argtypedescription
m?
values?

weightedNormal(m: ?, values: ?) → void

argtypedescription
m?
values?

nextC(c: ?) → void

argtypedescription
c?

find(x: ?) → void

argtypedescription
x?

union(a: ?, b: ?) → void

argtypedescription
a?
b?

item(c: ?) → void

argtypedescription
c?

aggregate(it: ?, f: ?, val: ?) → void

argtypedescription
it?
f?
val?

cornerAngle(c: ?) → void

argtypedescription
c?

cval(c: ?) → void

argtypedescription
c?

apply(m: ?, typ: ?, values: ?) → void

Dispatch by Blender modifier type.

argtypedescription
m?
typ?
values?

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

Showing up to 3 levels deep. Open a part to see what it holds further down.

8+items
▣
module · born here
❒asset
# meshBuf Polygon meshes kept entirely in substrate (engine) memory, for ZeroBlender documents and every algorithm that edits them. No mesh-sized Luau table is ever built: every array is a CPU substrate buffer read and written in place. ## Stores - `M.words(n, fill?)` -> `W`: n numbers. `:get(i)`, `:set(i,v)`, `:add(i,v)`, `:push(v)`, `:resize(n,fill?)`, `:reserve(n)`, `:fill(v)`, `:copy()`, `:free()`; field `.n`. Indices are 0-based. Integers are exact below 2^24. - `M.vec3s(n)` -> `V3`: n xyz records. `:get(i)->x,y,z`, `:set(i,x,y,z)`, `:add(i,x,y,z)`, `:push(x,y,z)`, `:zero()`, `:copy()`, `:free()`. - `M.hash(arity, expected?)` -> `Hash`: integer keys (1-3, each in [0,2^24)) mapping to a number. `:get(a,b?,c?)`, `:put(v,a,b?,c?)`, `:each(fn(v,a,b,c))`, `:free()`; field `.n`. ## Mesh (`M.new()`) Fields: `P` (V3 positions, `nv`), `C` (W corner vertex ids), `O` (W face offsets, `nf+1` words), `FM` (W material slot per face, or nil), `UV` (list of `{name, W}`, two words per corner; `uvActive`/`uvRender` 1-based), `LE` (W loose edges, 2 words each), `SEL` + `selMode`, `ver` (bumped by every edit). Reading: `co(i)`, `faceStart(f)`, `faceEnd(f)`, `faceLen(f)`, `corner(c)`, `faceMat(f)`, `uv(layer,c)`, `faceNormal(f)`, `faceNormalRaw(f)`, `faceCenter(f)`, `faceArea(f)`, `bounds()`, `triangleCount()`, `signedVolume()`, `looseCount()`, `isSel(i)`. Writing: `addVert(x,y,z)`, `setCo`, `pushCorner(v)` then `closeFace(slot?)`, `setCorner`, `setFaceMat`, `addUVLayer(name,init?)`, `setUV`, `removeUVLayer`, `addLooseEdge(a,b)`, `setSel`, `clearSel`, `reverseFace(f)`, `filterFaces(keep)`, `compactVerts()`, `append(src,T,remap,flip)`, `clearFaces()`, `clear()`, `copy()`, `assign(src)` (takes src's stores), `free()`. ## Derived data - `M.edges(m)` -> unique undirected edges, numbered in (low, high) vertex order: `.n`, `:verts(e)`, `:find(a,b)`, `:faceCount(e)`, `.CE` (edge of corner c -> c+1). Cached until `m.ver` changes. - `M.vertexCorners(m)` -> `{off, vc, cf}` CSR: the corners of vertex v are `vc[off[v] .. off[v+1])`, `cf[c]` is the face of corner c. Call `:free()`. - `M.triangulate(m)` -> `T` (3 corner ids per triangle), `TF` (face per triangle). Quads and n-gons ear-clipped against the face normal. - `M.vertexNormals(m)`, `M.cornerNormalsByAngle(m, angle)` -> V3. - `M.weldIds(m, tol)`, `M.audit(m)`. ## Drawing and saving - `M.upload(m, slot|nil, "flat"|"smooth"|"angle", normals?, name)` builds GPU vertex and index buffers and a renderer mesh from them (Zero basis x, z, -y). `M.release(up)` frees them. - `M.save(m)` -> blob string, `M.load(blob, uvNames)` -> Mesh. ```luau local MB = require("~ZeroBlender.modules.meshBuf") local m = MB.new() for _, p in { {0,0,0}, {1,0,0}, {0,1,0} } do m:addVert(p[1], p[2], p[3]) end m:pushCorner(0); m:pushCorner(1); m:pushCorner(2); m:closeFace() local up = MB.upload(m, nil, "flat", nil, "tri") ```
▲ 0↑ born
❒
package · born here
❒asset
# ZeroBlender Blender-style modeling inside Zero. Install this package and you get the whole surface: the `.zblend` document type, the tools that edit it, the Python/bpy runtime behind them, the layer previews live in, and the workflow that drives a modeling job to the end. ## Contents | Path | What it is | |---|---| | `zblend.assetType/` | The `.zblend` document (Zero's `.blend`): editable `scene.json`, history, images, and a live `output.bundle`. Scene-instantiable, previewed, searchable. Its ref methods open and edit documents (below); `M.modules` exposes every module here to instances. | | `blender.toolbox/` | Blender MCP-compatible tools: `execute_blender_code`, `get_scene_info`, `get_object_info`, `get_viewport_screenshot`, `bpy_api_lookup`, `get_addon_status`, `compare_to_reference`. `api.json` is the implemented bpy surface. | | `modules/blenderSession` | The bpy/bmesh/mathutils session: objects, meshes, modifiers, materials, viewport, flush to the document and bundle. | | `modules/pythonParser`, `pythonRuntime` | The Python subset the scripts run in (Luau-hosted, not CPython). | | `modules/animation`, `rigging` | Armatures, pose, vertex groups, ARMATURE deform, auto weights, keyframes/actions/F-Curves, constraints, IK, drivers, NLA; clip baking. | | `modules/sceneOps` | Empties, duplicates, collections, collection instances, `zero_instance`, `origin_set`, cursor, snapping. | | `modules/curves`, `meshOps`, `polygonTopology`, `xform` | Curve/text meshing, edit-mode operators, topology and evaluation, matrix math. | | `modules/referenceCompare` | Silhouette scoring against a reference image. | | `modules/bpy`, `hardSurface`, `kestrel` | Older core geometry layer and hard-surface helpers used by the session. | | `workspace/ModelingWorkspace.scene` | Additive layer holding document previews, on render layer `modelingWorkspace` (hidden from the editor camera, drawn by screenshots). | | `model.workflow/` | Multi-pass modeling job: reference → model → critic/builder rounds → finish. | | `modeling.agentSkill/` | The `modeling` skill that starts the workflow. | ## Usage ```luau -- Make or open a document and edit it local doc = asset.create("zblend", "Lantern", { folder = "models" }) doc:run([[import bpy bpy.ops.mesh.primitive_cylinder_add(radius=0.1, depth=0.3)]]) doc:screenshot("ISO") doc:sceneInfo() doc:open() -- load as a live session, returns its name -- Place it (live: placed copies follow edits and play its clips) doc:instantiate(entity.find("Shelf")) -- Frozen copy doc:exportBundle("/zero/source/models/Lantern_v1.bundle") ``` Agents use the `blender` toolbox directly with `session="<folder>/<Name>"`, or start the `model` workflow for a full modeling job (`zero workflow start --name model --args '{"subject":"..."}'`). Documents default to `modeling/models/<name>.zblend`; user data (models, references, reports) is not part of the package.
▲ 0↑ born
backing path · ZeroBlender.package/modules/meshMods.module

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.