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

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.

by◐Deata·posted 1mo ago
What it does

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.
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")

Interface

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

conforms to

zero/source-extract/v2

Polygon meshes held entirely in substrate (engine) memory. Every array is a "word store" (W): a CPU substrate buffer of vec3 records read and written in place with getVec3/setVec3, so a read or a write makes no Luau value. Word w is record w//3, lane w%3. Integers (vertex ids, offsets, material indices) are stored as f32 and are exact below 2^24. A Mesh: P positions, one vec3 record per vertex (nv of them) C corners: the vertex id of each face corner, faces in order O face offsets: O[f] is face f's first corner, O[nf] the corner count FM material slot per face (nil while every face is slot 0) UV UV layers { name, W } with (u,v) per corner; uvActive/uvRender 1-based LE loose edges, two vertex ids per edge SEL selection words for selMode's domain (VERT/EDGE/FACE), 1 = selected Algorithms keep their scratch in word stores too (M.words, M.Hash), never in per-element Luau tables. Free a store with :free() when done.

tick( ) → void

resetSlice( ) → void

cpu(records: ?) → void

argtypedescription
records?

wbuf(s: ?, cap: ?) → void

argtypedescription
s?
cap?

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

argtypedescription
n?
fill?

get(w: ?) → void

argtypedescription
w?

set(w: ?, v: ?) → void

argtypedescription
w?
v?

add(w: ?, v: ?) → void

argtypedescription
w?
v?

reserve(n: ?) → void

argtypedescription
n?

push(v: ?) → void

argtypedescription
v?

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

argtypedescription
n?
fill?

fill(v: ?) → void

argtypedescription
v?

copy( ) → void

free( ) → void

toBytes(n: ?) → void

The first n words as packed f32 bytes (4 per word), and back.

argtypedescription
n?

wordsFromBytes(str: ?) → void

argtypedescription
str?

vec3s(n: ?) → void

argtypedescription
n?

get(i: ?) → void

argtypedescription
i?

set(i: ?, x: ?, y: ?, z: ?) → void

argtypedescription
i?
x?
y?
z?

add(i: ?, x: ?, y: ?, z: ?) → void

argtypedescription
i?
x?
y?
z?

reserve(n: ?) → void

argtypedescription
n?

push(x: ?, y: ?, z: ?) → void

argtypedescription
x?
y?
z?

zero( ) → void

copy( ) → void

free( ) → void

hash(arity: ?, expected: ?) → void

argtypedescription
arity?
expected?

slot(a: ?, b: ?, c: ?) → void

argtypedescription
a?
b?
c?

get(a: ?, b: ?, c: ?) → void

argtypedescription
a?
b?
c?

put(v: ?, a: ?, b: ?, c: ?) → void

argtypedescription
v?
a?
b?
c?

each(fn: ?) → void

Visit every entry: fn(value, a, b, c).

argtypedescription
fn?

free( ) → void

new( ) → void

isMesh(x: ?) → void

argtypedescription
x?

co(i: ?) → void

argtypedescription
i?

setCo(i: ?, x: ?, y: ?, z: ?) → void

argtypedescription
i?
x?
y?
z?

addVert(x: ?, y: ?, z: ?) → void

argtypedescription
x?
y?
z?

faceStart(f: ?) → void

argtypedescription
f?

faceEnd(f: ?) → void

argtypedescription
f?

faceLen(f: ?) → void

argtypedescription
f?

corner(c: ?) → void

argtypedescription
c?

setCorner(c: ?, v: ?) → void

argtypedescription
c?
v?

ncorners( ) → void

pushCorner(v: ?) → void

Build a face: pushCorner for each corner, then closeFace(materialSlot?).

argtypedescription
v?

closeFace(mat: ?) → void

argtypedescription
mat?

faceMat(f: ?) → void

argtypedescription
f?

enableFaceMat( ) → void

setFaceMat(f: ?, v: ?) → void

argtypedescription
f?
v?

addUVLayer(name: ?, init: ?) → void

argtypedescription
name?
init?

uv(layer: ?, c: ?) → void

argtypedescription
layer?
c?

setUV(layer: ?, c: ?, u: ?, v: ?) → void

argtypedescription
layer?
c?
u?
v?

removeUVLayer(i: ?) → void

argtypedescription
i?

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

argtypedescription
a?
b?

looseCount( ) → void

selCount( ) → void

Selection: one word per element of selMode's domain (sized lazily).

isSel(i: ?) → void

argtypedescription
i?

setSel(i: ?, v: ?) → void

argtypedescription
i?
v?

clearSel( ) → void

clearFaces( ) → void

clear( ) → void

copy( ) → void

assign(src: ?) → void

Take every store of `src` (which is left empty).

argtypedescription
src?

freeStores( ) → void

free( ) → void

append(src: ?, T: ?, remap: ?, flip: ?) → void

Append `src` transformed by a 4x4 row-major matrix T (Lua array of 16, 1-based) with slot remap function (oldSlot -> newSlot). Flips winding when det<0.

argtypedescription
src?
T?
remap?
flip?

filterFaces(keep: ?) → void

Keep the faces for which keep(f) is true (faces renumbered in order).

argtypedescription
keep?

compactVerts( ) → void

Drop vertices no face or loose edge uses; returns the old->new map (W, -1 = dropped).

reverseFace(f: ?) → void

argtypedescription
f?

faceNormalRaw(f: ?) → void

Newell normal of face f (unnormalized, then unit).

argtypedescription
f?

faceNormal(f: ?) → void

argtypedescription
f?

faceCenter(f: ?) → void

argtypedescription
f?

faceArea(f: ?) → void

argtypedescription
f?

bounds( ) → void

triangleCount( ) → void

signedVolume( ) → void

edges(m: ?) → void

argtypedescription
m?

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

argtypedescription
a?
b?

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

argtypedescription
a?
b?

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

argtypedescription
a?
b?

verts(e: ?) → void

argtypedescription
e?

faceCount(e: ?) → void

argtypedescription
e?

free( ) → void

vertexCorners(m: ?) → void

Vertex -> faces (CSR over corners): for vertex v, corners vc[voff[v]..voff[v+1]).

argtypedescription
m?

vcCached(m: ?) → void

Cached per mesh version: corners of each vertex, triangles, vertex normals.

argtypedescription
m?

triCached(m: ?) → void

argtypedescription
m?

vnCached(m: ?) → void

argtypedescription
m?

cornerFace(c: ?) → void

Face containing corner c (binary search over O).

argtypedescription
c?

inTri(m: ?, px: ?, py: ?, pz: ?, a: ?, b: ?, c: ?, nx: ?, ny: ?, nz: ?) → void

argtypedescription
m?
px?
py?
pz?
a?
b?
c?
nx?
ny?
nz?

side(ux: ?, uy: ?, uz: ?, vx: ?, vy: ?, vz: ?, wx: ?, wy: ?, wz: ?) → void

argtypedescription
ux?
uy?
uz?
vx?
vy?
vz?
wx?
wy?
wz?

convex(m: ?, a: ?, b: ?, c: ?, nx: ?, ny: ?, nz: ?) → void

argtypedescription
m?
a?
b?
c?
nx?
ny?
nz?

triangulateFace(m: ?, f: ?, T: ?, TF: ?) → void

Append the triangles of face f to T/TF.

argtypedescription
m?
f?
T?
TF?

tn(a: ?, b: ?, c: ?) → void

argtypedescription
a?
b?
c?

triangulate(m: ?) → void

argtypedescription
m?

vertexNormals(m: ?) → void

Area-weighted vertex normals (smooth shading), as a V3 of nv records.

argtypedescription
m?

cornerNormalsByAngle(m: ?, angle: ?) → void

Corner normals smoothed across faces whose normals are within `angle` (Blender's smooth-by-angle). One record per corner.

argtypedescription
m?
angle?

weldIds(m: ?, tol: ?) → void

Position welding: canonical id per vertex for vertices within `tol`.

argtypedescription
m?
tol?

audit(m: ?, tolerance: ?) → void

Topology audit (as the old render-geometry audit: welded by position).

argtypedescription
m?
tolerance?

upload(m: ?, slot: ?, shade: ?, N: ?, name: ?, faceSmooth: ?) → void

shade: "flat" | "smooth" | "angle"; N: V3 per vertex (smooth) or per corner (angle). faceSmooth (W per face, optional): with "smooth"/"angle", faces holding 0 draw flat.

argtypedescription
m?
slot?
shade?
N?
name?
faceSmooth?

release(up: ?) → void

argtypedescription
up?

save(m: ?) → void

One binary blob per mesh (f32 words): magic, nv, nc, nf, hasFM, nuv, nle, then P, C, O, FM, each UV layer, LE. UV layer names travel in scene.json.

argtypedescription
m?

put(v: ?) → void

argtypedescription
v?

load(str: ?, uvNames: ?) → void

argtypedescription
str?
uvNames?

orient(m: ?) → void

Consistent winding: faces sharing an edge are made to traverse it in opposite directions (flood fill per connected component), then each component with negative signed volume is flipped as a whole.

argtypedescription
m?

locateFaces(src: ?, dst: ?) → void

For each face of `dst` (built from `src` by an operation that moved or split faces), the source face it lies on: matching normal, nearest plane, inside the source face's bounds. Found through a uniform grid (CSR over cells). Returns W of nf(dst) source-face ids (-1 when src has no faces).

argtypedescription
src?
dst?

ci(v: ?, lo: ?) → void

argtypedescription
v?
lo?

cellsOf(f: ?, pass: ?) → void

argtypedescription
f?
pass?

carryFaceData(src: ?, dst: ?, map: ?) → void

Material slots and UV layers of `dst` from `src` through a face map (from locateFaces, or one the operation knows exactly). UVs are each source face's planar affine UV map applied to the new corner positions.

argtypedescription
src?
dst?
map?

fromTables(vs: ?, fs: ?, fm: ?, uvLayers: ?) → void

Test bridges: convert ONE mesh to/from the old polygon tables, only to compare a ported algorithm with the table implementation it replaces.

argtypedescription
vs?
fs?
fm?
uvLayers?

toTables(m: ?) → void

argtypedescription
m?

hash( ) → void

Content hash (change detection).

fold(v: ?) → void

argtypedescription
v?

Sub-parts

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

3items
This part has no composite children. See the Files segment for its leaf payloads.
backing path · ZeroBlender.package/modules/meshBuf.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. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬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.