partforge 0.145.2 → 0.146.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -26,17 +26,13 @@ const pt = (a, i) => (Number.isNaN(a[i]) ? null : [a[i], a[i + 1], a[i + 2]]);
|
|
|
26
26
|
|
|
27
27
|
// `verts`: bvh.js's triangleVertices(mesh) — 9 coords per triangle, mesh order.
|
|
28
28
|
// `makeJsIndex`: builds the JS BVH of the same mesh (the fallback), on demand.
|
|
29
|
-
//
|
|
30
|
-
// native/bvh.cpp); throws if the module faults while building. Either way the
|
|
31
|
-
// caller falls back to the JS index.
|
|
29
|
+
// Throws if the module faults while building; the caller falls back.
|
|
32
30
|
export function buildCoreBVH(c, verts, makeJsIndex) {
|
|
33
31
|
const { x } = c;
|
|
34
32
|
const ptr = c.alloc(verts.byteLength);
|
|
35
33
|
new Uint8Array(x.memory.buffer, ptr, verts.byteLength).set(new Uint8Array(verts.buffer, verts.byteOffset, verts.byteLength));
|
|
36
|
-
// adopt = 1: the C++ index owns the vertex buffer from here (no second copy)
|
|
37
|
-
// and frees it itself when it refuses the mesh
|
|
34
|
+
// adopt = 1: the C++ index owns the vertex buffer from here (no second copy)
|
|
38
35
|
const handle = x.bvh_build(ptr, verts.length / 9, verts instanceof Float64Array ? 1 : 0, 1);
|
|
39
|
-
if (!handle) return null;
|
|
40
36
|
x.bvh_root_bounds(handle, c.scratch + 64);
|
|
41
37
|
const rb = c.f64().slice(8, 14);
|
|
42
38
|
c.live++;
|