Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Invert part matrices with invertAffine and record the measured size and cost

Nguyen Xuan And9b4f78f400b
diff --git a/changes/751-flush-clip.size.md b/changes/751-flush-clip.size.md
index a381f0ee..8ad8c9a5 100644
--- a/changes/751-flush-clip.size.md
+++ b/changes/751-flush-clip.size.md
@@ -1,10 +1,17 @@
-- entry:coplanar-overlap: cutting hidden flush faces (flush-clip.js: subtract the covering triangle, interpolate the vertex arrays, give every seam vertex to both sides of its edge); an addon chunk, loaded by agent scenes and by renderers that pass resolveCoplanar; it is what settles stacks deeper than the 16 ranks and gives the path tracer one face per plane
-- entry:core: the renderer draws a cut geometry beside the part and the path tracer reads it (a few lines in renderer.js and path-tracer-scene.js)
-- scene:lit-box: same core growth; accepted for flicker-free rendering
-- scene:gltf-box: same core growth; accepted for flicker-free rendering
+- entry:coplanar-overlap: cutting hidden flush faces (flush-clip.js: subtract the covering triangle, interpolate the vertex arrays, give every seam vertex to both sides of its edge), +3584 bytes gzip on top of step 1 (7880 to 11464); an addon chunk, loaded by agent scenes and by renderers that pass resolveCoplanar; it is what settles stacks deeper than the 16 ranks and gives the path tracer one face per plane
+- entry:core: the renderer draws a cut geometry beside the part and the path tracer reads it, +45 bytes gzip on top of step 1 (85679 to 85724)
+- scene:lit-box: same core growth (+52 bytes gzip); accepted for flicker-free rendering
+- scene:gltf-box: same core growth (+51 bytes gzip); accepted for flicker-free rendering
- scene:gltf-box+lazy: same core growth; accepted for flicker-free rendering
-- scene:agent-scene: same core growth; accepted for flicker-free rendering
+- scene:agent-scene: same core growth (+71 bytes gzip); accepted for flicker-free rendering
- scene:agent-scene+lazy: the core growth plus the larger flush chunk; it is the fix, so it has to load
- goal:lit-box: the growth is the cut-geometry lookup in the core; accepted for flicker-free rendering
- goal:gltf-box: the growth is the cut-geometry lookup in the core; accepted for flicker-free rendering
- goal:agent-scene: the growth is the cut-geometry lookup in the core; accepted for flicker-free rendering
+
+Measured in Node on the Melbourne drape map (9,718 pairs, 6,543 of them on one plane), one run on a loaded machine:
+the flush pass takes 1.4 s where the search alone takes 0.9 s, and 0.7 s on a second run of the unchanged scene (cuts and orders are kept);
+cut parts draw from their own copy of the vertex arrays: walls 110,368 to 119,988 vertices, glass 20,360 to 23,970, roofs 48,901 to 49,693, canopy 82,848 to 82,886, about 9 MB at 32 bytes a vertex (inferred from the counts, not read from the renderer);
+triangles drawn: walls 55,184 to 62,547, glass 10,180 to 13,154, roofs 38,116 to 38,927, canopy 138,080 to 138,128.
+Frame time and draw calls were not measured for this step.
+Tool cost: no schema or result grew.
diff --git a/src/flush-resolve.js b/src/flush-resolve.js
index d69f00a2..10422d71 100644
--- a/src/flush-resolve.js
+++ b/src/flush-resolve.js
@@ -3,10 +3,10 @@
// normal gets the higher draw rank, and the renderer pulls each rank a little closer in depth only, so the same triangle
// wins every frame and at every distance. Ranks are per triangle, not per part: a whole-part offset moved faces that had
// no conflict and made things worse (issue #593).
-import { mat4 } from 'gl-matrix';
import { depthLayerOf, MAXIMUM_FLUSH_RANK, setFlushOrder } from './depth-layer.js';
import { clipFlushOverlaps, FLUSH_CUT_MINIMUM_AREA, FLUSH_CUT_STRIDE, sameNumbers } from './flush-clip.js';
import { findFlushPairs, float32Step, worldBounds } from './flush-search.js';
+import { invertAffine } from './path-tracer-reprojection.js';
const COLLAPSED_AXIS_SHARE = 1e-3;
const CACHED_ORDERS_PER_GEOMETRY = 8;
@@ -77,7 +77,7 @@ function coordinateStep(part) {
function cutRecords(found, partIndex, cutPairs) {
const part = found.parts[partIndex];
const { positions, indices } = part.geometry;
- const inverse = mat4.invert(new Float64Array(16), part.matrix);
+ const inverse = invertAffine(part.matrix);
if (!inverse) return null;
cutPairs.sort((one, other) => found.local[one.back] - found.local[other.back] || one.front - other.front);
const cuts = new Float64Array(cutPairs.length * FLUSH_CUT_STRIDE);