@woosh/meep-engine 2.117.32 → 2.117.34
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 +4 -3
- 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 +13 -4
- 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":"AAWA
|
|
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"}
|
|
@@ -17,13 +17,15 @@ import { ebvh_build_hierarchy } from "./ebvh_build_hierarchy.js";
|
|
|
17
17
|
* @param {number[]|Float32Array|Float64Array} position_array
|
|
18
18
|
* @param {Uint32Array} [morton_codes]
|
|
19
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
|
|
20
21
|
*/
|
|
21
22
|
export function ebvh_build_for_geometry_morton(
|
|
22
23
|
bvh,
|
|
23
24
|
index_array,
|
|
24
25
|
position_array,
|
|
25
26
|
morton_codes = new Uint32Array(index_array.length / 3),
|
|
26
|
-
bounds
|
|
27
|
+
bounds,
|
|
28
|
+
quality = 0
|
|
27
29
|
) {
|
|
28
30
|
assert.defined(bvh, 'bvh');
|
|
29
31
|
|
|
@@ -38,7 +40,6 @@ export function ebvh_build_for_geometry_morton(
|
|
|
38
40
|
// clear out existing BVH
|
|
39
41
|
bvh.release_all();
|
|
40
42
|
|
|
41
|
-
|
|
42
43
|
// allocate nodes
|
|
43
44
|
const tri_count = index_array.length / 3;
|
|
44
45
|
|
|
@@ -128,5 +129,5 @@ export function ebvh_build_for_geometry_morton(
|
|
|
128
129
|
array_copy(nodes, 0, unprocessed_nodes, 0, tri_count);
|
|
129
130
|
|
|
130
131
|
// assign root
|
|
131
|
-
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 );
|
|
132
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":"AAKA
|
|
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"}
|
|
@@ -12,6 +12,7 @@ import { ebvh_nodes_sort_sah_local4 } from "./ebvh_nodes_sort_sah_local4.js";
|
|
|
12
12
|
* @param {number} input_node_count
|
|
13
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
|
|
14
14
|
* @param {number} node_pool_offset
|
|
15
|
+
* @param {number} [sah_optimization_level]
|
|
15
16
|
* @returns {number} new root
|
|
16
17
|
*/
|
|
17
18
|
export function ebvh_build_hierarchy(
|
|
@@ -19,7 +20,8 @@ export function ebvh_build_hierarchy(
|
|
|
19
20
|
unprocessed_nodes,
|
|
20
21
|
input_node_count,
|
|
21
22
|
node_pool,
|
|
22
|
-
node_pool_offset
|
|
23
|
+
node_pool_offset,
|
|
24
|
+
sah_optimization_level = 1
|
|
23
25
|
) {
|
|
24
26
|
|
|
25
27
|
assert.isNonNegativeInteger(input_node_count, 'input_node_count');
|
|
@@ -30,12 +32,19 @@ export function ebvh_build_hierarchy(
|
|
|
30
32
|
// Assemble hierarchy
|
|
31
33
|
let unprocessed_node_count = input_node_count;
|
|
32
34
|
|
|
35
|
+
let optimization_cycle_limit = sah_optimization_level;
|
|
33
36
|
|
|
34
37
|
while (unprocessed_node_count > 1) {
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
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, 0, unprocessed_node_count);
|
|
42
|
+
swap_count += ebvh_nodes_sort_sah_local4(bvh, unprocessed_nodes, 2, unprocessed_node_count - 2);
|
|
43
|
+
|
|
44
|
+
if(swap_count === 0){
|
|
45
|
+
optimization_cycle_limit = 0;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
39
48
|
|
|
40
49
|
let added_nodes = 0;
|
|
41
50
|
let cursor = 0;
|
|
@@ -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"}
|