@woosh/meep-engine 2.117.31 → 2.117.33
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 +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts +2 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +5 -6
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts +2 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +15 -1
- package/src/core/bvh2/bvh3/ebvh_nodes_sort_sah_local4.d.ts +1 -1
- package/src/core/bvh2/bvh3/ebvh_nodes_sort_sah_local4.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_nodes_sort_sah_local4.js +7 -0
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js +2 -1
package/package.json
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
* @param {number[]|Float32Array|Float64Array} position_array
|
|
7
7
|
* @param {Uint32Array} [morton_codes]
|
|
8
8
|
* @param {AABB3} [bounds] Bounding box of the entire geometry, if not supplied will be computed internally
|
|
9
|
+
* @param {number} [quality] va value from 0 to infinity, controls how many optimization passes are to be done beyond morton sort
|
|
9
10
|
*/
|
|
10
|
-
export function ebvh_build_for_geometry_morton(bvh: BVH, index_array: number[] | Uint32Array | Uint16Array, position_array: number[] | Float32Array | Float64Array, morton_codes?: Uint32Array, bounds?: AABB3): void;
|
|
11
|
+
export function ebvh_build_for_geometry_morton(bvh: BVH, index_array: number[] | Uint32Array | Uint16Array, position_array: number[] | Float32Array | Float64Array, morton_codes?: Uint32Array, bounds?: AABB3, quality?: number): void;
|
|
11
12
|
import { AABB3 } from "../../geom/3d/aabb/AABB3.js";
|
|
12
13
|
//# sourceMappingURL=ebvh_build_for_geometry_morton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ebvh_build_for_geometry_morton.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ebvh_build_for_geometry_morton.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js"],"names":[],"mappings":"AAWA;;;;;;;;;GASG;AACH,sEANW,MAAM,EAAE,GAAC,WAAW,GAAC,WAAW,kBAChC,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,iBAClC,WAAW,WACX,KAAK,YACL,MAAM,QAiHhB;sBAjIqB,6BAA6B"}
|
|
@@ -8,7 +8,6 @@ import { max2 } from "../../math/max2.js";
|
|
|
8
8
|
import { build_triangle_morton_codes } from "./build_triangle_morton_codes.js";
|
|
9
9
|
import { COLUMN_CHILD_1, COLUMN_HEIGHT, COLUMN_USER_DATA, ELEMENT_WORD_COUNT, NULL_NODE } from "./BVH.js";
|
|
10
10
|
import { ebvh_build_hierarchy } from "./ebvh_build_hierarchy.js";
|
|
11
|
-
import { ebvh_nodes_sort_sah_local4 } from "./ebvh_nodes_sort_sah_local4.js";
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Build the BVH bottom-up using spatial hash sorting
|
|
@@ -18,13 +17,15 @@ import { ebvh_nodes_sort_sah_local4 } from "./ebvh_nodes_sort_sah_local4.js";
|
|
|
18
17
|
* @param {number[]|Float32Array|Float64Array} position_array
|
|
19
18
|
* @param {Uint32Array} [morton_codes]
|
|
20
19
|
* @param {AABB3} [bounds] Bounding box of the entire geometry, if not supplied will be computed internally
|
|
20
|
+
* @param {number} [quality] va value from 0 to infinity, controls how many optimization passes are to be done beyond morton sort
|
|
21
21
|
*/
|
|
22
22
|
export function ebvh_build_for_geometry_morton(
|
|
23
23
|
bvh,
|
|
24
24
|
index_array,
|
|
25
25
|
position_array,
|
|
26
26
|
morton_codes = new Uint32Array(index_array.length / 3),
|
|
27
|
-
bounds
|
|
27
|
+
bounds,
|
|
28
|
+
quality = 0
|
|
28
29
|
) {
|
|
29
30
|
assert.defined(bvh, 'bvh');
|
|
30
31
|
|
|
@@ -39,7 +40,6 @@ export function ebvh_build_for_geometry_morton(
|
|
|
39
40
|
// clear out existing BVH
|
|
40
41
|
bvh.release_all();
|
|
41
42
|
|
|
42
|
-
|
|
43
43
|
// allocate nodes
|
|
44
44
|
const tri_count = index_array.length / 3;
|
|
45
45
|
|
|
@@ -113,6 +113,7 @@ export function ebvh_build_for_geometry_morton(
|
|
|
113
113
|
const c_index = index_array[triangle_index3 + 2];
|
|
114
114
|
|
|
115
115
|
const node_address = ELEMENT_WORD_COUNT * node;
|
|
116
|
+
|
|
116
117
|
aabb3_compute_from_triangle(
|
|
117
118
|
bvh_float32, node_address,
|
|
118
119
|
position_array, a_index, b_index, c_index
|
|
@@ -123,12 +124,10 @@ export function ebvh_build_for_geometry_morton(
|
|
|
123
124
|
bvh_uint32[node_address + COLUMN_HEIGHT] = 0;
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
ebvh_nodes_sort_sah_local4(bvh, nodes, 0, tri_count );
|
|
127
|
-
|
|
128
127
|
// record newly generated nodes as "unprocessed"
|
|
129
128
|
const unprocessed_nodes = new Uint32Array(tri_count);
|
|
130
129
|
array_copy(nodes, 0, unprocessed_nodes, 0, tri_count);
|
|
131
130
|
|
|
132
131
|
// assign root
|
|
133
|
-
bvh.root = ebvh_build_hierarchy(bvh, unprocessed_nodes, tri_count, nodes, tri_count);
|
|
132
|
+
bvh.root = ebvh_build_hierarchy(bvh, unprocessed_nodes, tri_count, nodes, tri_count, quality );
|
|
134
133
|
}
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* @param {number} input_node_count
|
|
8
8
|
* @param {number[]|Uint32Array} node_pool Contains node indices that can be used to build ancestry hierarchy, need to be pre-allocated before calling this method
|
|
9
9
|
* @param {number} node_pool_offset
|
|
10
|
+
* @param {number} [sah_optimization_level]
|
|
10
11
|
* @returns {number} new root
|
|
11
12
|
*/
|
|
12
|
-
export function ebvh_build_hierarchy(bvh: BVH, unprocessed_nodes: number[] | Uint32Array, input_node_count: number, node_pool: number[] | Uint32Array, node_pool_offset: number): number;
|
|
13
|
+
export function ebvh_build_hierarchy(bvh: BVH, unprocessed_nodes: number[] | Uint32Array, input_node_count: number, node_pool: number[] | Uint32Array, node_pool_offset: number, sah_optimization_level?: number): number;
|
|
13
14
|
//# sourceMappingURL=ebvh_build_hierarchy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ebvh_build_hierarchy.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_hierarchy.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ebvh_build_hierarchy.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_build_hierarchy.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;GAWG;AACH,kEAPW,MAAM,EAAE,GAAC,WAAW,oBACpB,MAAM,aACN,MAAM,EAAE,GAAC,WAAW,oBACpB,MAAM,2BACN,MAAM,GACJ,MAAM,CAwElB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assert } from "../../assert.js";
|
|
2
2
|
import { max2 } from "../../math/max2.js";
|
|
3
3
|
import { NULL_NODE } from "./BVH.js";
|
|
4
|
+
import { ebvh_nodes_sort_sah_local4 } from "./ebvh_nodes_sort_sah_local4.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Given a set of leaves, build intermediate node hierarchy on top, all the way up to the root
|
|
@@ -11,6 +12,7 @@ import { NULL_NODE } from "./BVH.js";
|
|
|
11
12
|
* @param {number} input_node_count
|
|
12
13
|
* @param {number[]|Uint32Array} node_pool Contains node indices that can be used to build ancestry hierarchy, need to be pre-allocated before calling this method
|
|
13
14
|
* @param {number} node_pool_offset
|
|
15
|
+
* @param {number} [sah_optimization_level]
|
|
14
16
|
* @returns {number} new root
|
|
15
17
|
*/
|
|
16
18
|
export function ebvh_build_hierarchy(
|
|
@@ -18,7 +20,8 @@ export function ebvh_build_hierarchy(
|
|
|
18
20
|
unprocessed_nodes,
|
|
19
21
|
input_node_count,
|
|
20
22
|
node_pool,
|
|
21
|
-
node_pool_offset
|
|
23
|
+
node_pool_offset,
|
|
24
|
+
sah_optimization_level = 1
|
|
22
25
|
) {
|
|
23
26
|
|
|
24
27
|
assert.isNonNegativeInteger(input_node_count, 'input_node_count');
|
|
@@ -29,9 +32,20 @@ export function ebvh_build_hierarchy(
|
|
|
29
32
|
// Assemble hierarchy
|
|
30
33
|
let unprocessed_node_count = input_node_count;
|
|
31
34
|
|
|
35
|
+
let optimization_cycle_limit = sah_optimization_level;
|
|
32
36
|
|
|
33
37
|
while (unprocessed_node_count > 1) {
|
|
34
38
|
|
|
39
|
+
for (let i = 0; i < optimization_cycle_limit; i++) {
|
|
40
|
+
// sort intermediate nodes using small locality and SAH metric
|
|
41
|
+
let swap_count = ebvh_nodes_sort_sah_local4(bvh, unprocessed_nodes, 2, unprocessed_node_count - 2);
|
|
42
|
+
swap_count += ebvh_nodes_sort_sah_local4(bvh, unprocessed_nodes, 0, unprocessed_node_count);
|
|
43
|
+
|
|
44
|
+
if(swap_count === 0){
|
|
45
|
+
optimization_cycle_limit = 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
35
49
|
let added_nodes = 0;
|
|
36
50
|
let cursor = 0;
|
|
37
51
|
|
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* @param {number} offset
|
|
7
7
|
* @param {number} count
|
|
8
8
|
*/
|
|
9
|
-
export function ebvh_nodes_sort_sah_local4(bvh: BVH, nodes: number[] | Uint32Array, offset: number, count: number):
|
|
9
|
+
export function ebvh_nodes_sort_sah_local4(bvh: BVH, nodes: number[] | Uint32Array, offset: number, count: number): number;
|
|
10
10
|
//# sourceMappingURL=ebvh_nodes_sort_sah_local4.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ebvh_nodes_sort_sah_local4.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_nodes_sort_sah_local4.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,4DAJW,MAAM,EAAE,GAAC,WAAW,UACpB,MAAM,SACN,MAAM,
|
|
1
|
+
{"version":3,"file":"ebvh_nodes_sort_sah_local4.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/ebvh_nodes_sort_sah_local4.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,4DAJW,MAAM,EAAE,GAAC,WAAW,UACpB,MAAM,SACN,MAAM,UA6ChB"}
|
|
@@ -11,6 +11,8 @@ export function ebvh_nodes_sort_sah_local4(bvh, nodes, offset, count) {
|
|
|
11
11
|
// the bit manipulation rounds count down to nearest value divisible by 4
|
|
12
12
|
const end = offset + ((count >>> 2) << 2);
|
|
13
13
|
|
|
14
|
+
let swap_count = 0;
|
|
15
|
+
|
|
14
16
|
for (let i = offset; i < end; i += 4) {
|
|
15
17
|
const a = nodes[i];
|
|
16
18
|
const b = nodes[i + 1];
|
|
@@ -31,15 +33,20 @@ export function ebvh_nodes_sort_sah_local4(bvh, nodes, offset, count) {
|
|
|
31
33
|
|
|
32
34
|
if (cost0 <= cost1 && cost0 <= cost2) {
|
|
33
35
|
// no change
|
|
36
|
+
continue;
|
|
34
37
|
} else if (cost1 <= cost2) {
|
|
35
38
|
// swap C and B
|
|
36
39
|
nodes[i + 1] = c;
|
|
37
40
|
nodes[i + 2] = b;
|
|
41
|
+
|
|
38
42
|
} else {
|
|
39
43
|
// swap B and D
|
|
40
44
|
nodes[i + 1] = d;
|
|
41
45
|
nodes[i + 3] = b;
|
|
42
46
|
}
|
|
47
|
+
|
|
48
|
+
swap_count++;
|
|
43
49
|
}
|
|
44
50
|
|
|
51
|
+
return swap_count;
|
|
45
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BufferedGeometryBVH.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js"],"names":[],"mappings":"AA8CA;IAkBI;;;OAGG;IACH,eAFW,KAAK,GAAC,MAAM,EAAE,QAIxB;IAIG;;;;OAIG;IACH,mBAAsB;IAEtB;;;;OAIG;IACH,yBAA4B;IAE5B;;;;OAIG;IACH,6BAAgC;IAGhC;;;;OAIG;IACH,yBAAyB;IAG7B;;;OAGG;IACH,WAFW,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"BufferedGeometryBVH.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/BufferedGeometryBVH.js"],"names":[],"mappings":"AA8CA;IAkBI;;;OAGG;IACH,eAFW,KAAK,GAAC,MAAM,EAAE,QAIxB;IAIG;;;;OAIG;IACH,mBAAsB;IAEtB;;;;OAIG;IACH,yBAA4B;IAE5B;;;;OAIG;IACH,6BAAgC;IAGhC;;;;OAIG;IACH,yBAAyB;IAG7B;;;OAGG;IACH,WAFW,MAAM,cAAc,QA2C9B;IAED;;;;;OAKG;IACH,qBAFa,OAAO,CAmHnB;IAED;;;;;;;OAOG;IACH,4BANW,aAAa,KACb,MAAM,KACN,MAAM,KACN,MAAM,GACJ,OAAO,CAqKnB;IAGD;;;;;;OAMG;IACH,iBAJW,MAAM,EAAE,OACR,MAAM,EAAE,OAAK,GACX,MAAM,CAoIlB;IAED;;;;;OAKG;IACH,gBAJW,MAAM,EAAE,OACR,MAAM,EAAE,OAAK,GACX,MAAM,CA2ElB;;CACJ;sBA7oBqB,wCAAwC;8BAMhC,2CAA2C"}
|