@woosh/meep-engine 2.119.121 → 2.119.122
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_hierarchy.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy.js +1 -16
- package/src/core/bvh2/bvh3/ebvh_nodes_sort_sah_local4.d.ts +1 -2
- 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 +6 -30
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedScene.js +1 -3
package/package.json
CHANGED
|
@@ -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":"AAMA;;;;;;;;;;;;GAYG;AACH,0CATW,GAAG,qBACH,MAAM,EAAE,GAAC,WAAW,oBACpB,MAAM,aACN,MAAM,EAAE,GAAC,WAAW,oBACpB,MAAM,2BACN,MAAM,0BACN,MAAM,GACJ,MAAM,CAsFlB"}
|
|
@@ -3,11 +3,6 @@ import { max2 } from "../../math/max2.js";
|
|
|
3
3
|
import { NULL_NODE } from "./BVH.js";
|
|
4
4
|
import { ebvh_nodes_sort_sah_local4 } from "./ebvh_nodes_sort_sah_local4.js";
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Somewhat arbitrary, pulled from various papers
|
|
8
|
-
* @type {number}
|
|
9
|
-
*/
|
|
10
|
-
const SAH_MERGE_FRACTION = 0.93;
|
|
11
6
|
|
|
12
7
|
/**
|
|
13
8
|
* Given a set of leaves, build intermediate node hierarchy on top, all the way up to the root
|
|
@@ -42,9 +37,6 @@ export function ebvh_build_hierarchy(
|
|
|
42
37
|
|
|
43
38
|
let current_construction_depth = 0;
|
|
44
39
|
|
|
45
|
-
const primitive_counts = new Uint32Array(input_node_count);
|
|
46
|
-
primitive_counts.fill(1);
|
|
47
|
-
|
|
48
40
|
while (unprocessed_node_count > 1) {
|
|
49
41
|
|
|
50
42
|
const sah_optimization_cycle_count = Math.floor(sah_optimization_level + sah_optimization_bias * current_construction_depth);
|
|
@@ -57,7 +49,6 @@ export function ebvh_build_hierarchy(
|
|
|
57
49
|
ebvh_nodes_sort_sah_local4(
|
|
58
50
|
bvh,
|
|
59
51
|
unprocessed_nodes,
|
|
60
|
-
primitive_counts,
|
|
61
52
|
0,
|
|
62
53
|
swap_distance,
|
|
63
54
|
unprocessed_node_count
|
|
@@ -68,12 +59,7 @@ export function ebvh_build_hierarchy(
|
|
|
68
59
|
let added_nodes = 0;
|
|
69
60
|
let cursor = 0;
|
|
70
61
|
|
|
71
|
-
|
|
72
|
-
if (sah_optimization_cycle_count > 0) {
|
|
73
|
-
merge_limit = Math.ceil(unprocessed_node_count * SAH_MERGE_FRACTION);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
while (cursor + 1 < merge_limit) {
|
|
62
|
+
while (cursor + 1 < sah_optimization_cycle_count) {
|
|
77
63
|
const child_2_index = cursor++;
|
|
78
64
|
const child_1_index = cursor++;
|
|
79
65
|
|
|
@@ -99,7 +85,6 @@ export function ebvh_build_hierarchy(
|
|
|
99
85
|
|
|
100
86
|
const parent_index = added_nodes++;
|
|
101
87
|
unprocessed_nodes[parent_index] = parent;
|
|
102
|
-
primitive_counts[parent_index] = primitive_counts[child_1_index] + primitive_counts[child_2_index];
|
|
103
88
|
}
|
|
104
89
|
|
|
105
90
|
while (cursor < unprocessed_node_count) {
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
* Useful for optimizing topology for traversal.
|
|
4
4
|
* @param {BVH} bvh
|
|
5
5
|
* @param {number[]|Uint32Array} nodes
|
|
6
|
-
* @param {number[]|Uint32Array} primitive_counts
|
|
7
6
|
* @param {number} offset
|
|
8
7
|
* @param {number} distance
|
|
9
8
|
* @param {number} count
|
|
10
9
|
*/
|
|
11
|
-
export function ebvh_nodes_sort_sah_local4(bvh: BVH, nodes: number[] | Uint32Array,
|
|
10
|
+
export function ebvh_nodes_sort_sah_local4(bvh: BVH, nodes: number[] | Uint32Array, offset: number, distance: number, count: number): number;
|
|
12
11
|
//# 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":"
|
|
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;;;;;;;;GAQG;AACH,gDANW,GAAG,SACH,MAAM,EAAE,GAAC,WAAW,UACpB,MAAM,YACN,MAAM,SACN,MAAM,UAoFhB"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { array_swap } from "../../collection/array/array_swap.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
1
|
/**
|
|
5
2
|
* Sort consequent 4 nodes to reduce SAH among each consequent pair.
|
|
6
3
|
* Useful for optimizing topology for traversal.
|
|
7
4
|
* @param {BVH} bvh
|
|
8
5
|
* @param {number[]|Uint32Array} nodes
|
|
9
|
-
* @param {number[]|Uint32Array} primitive_counts
|
|
10
6
|
* @param {number} offset
|
|
11
7
|
* @param {number} distance
|
|
12
8
|
* @param {number} count
|
|
@@ -14,7 +10,6 @@ import { array_swap } from "../../collection/array/array_swap.js";
|
|
|
14
10
|
export function ebvh_nodes_sort_sah_local4(
|
|
15
11
|
bvh,
|
|
16
12
|
nodes,
|
|
17
|
-
primitive_counts,
|
|
18
13
|
offset,
|
|
19
14
|
distance,
|
|
20
15
|
count
|
|
@@ -37,12 +32,6 @@ export function ebvh_nodes_sort_sah_local4(
|
|
|
37
32
|
const node_c = nodes[index_c];
|
|
38
33
|
const node_d = nodes[index_d];
|
|
39
34
|
|
|
40
|
-
const count_a = primitive_counts[index_a];
|
|
41
|
-
const count_b = primitive_counts[index_b];
|
|
42
|
-
|
|
43
|
-
const count_c = primitive_counts[index_c];
|
|
44
|
-
const count_d = primitive_counts[index_d];
|
|
45
|
-
|
|
46
35
|
/*
|
|
47
36
|
possible combinations:
|
|
48
37
|
AB CD
|
|
@@ -61,14 +50,14 @@ export function ebvh_nodes_sort_sah_local4(
|
|
|
61
50
|
const area_ad = bvh.node_get_combined_surface_area(node_a, node_d);
|
|
62
51
|
const area_cb = bvh.node_get_combined_surface_area(node_c, node_b);
|
|
63
52
|
|
|
64
|
-
const cost_ab = area_ab
|
|
65
|
-
const cost_cd = area_cd
|
|
53
|
+
const cost_ab = area_ab;
|
|
54
|
+
const cost_cd = area_cd;
|
|
66
55
|
|
|
67
|
-
const cost_ac = area_ac
|
|
68
|
-
const cost_bd = area_bd
|
|
56
|
+
const cost_ac = area_ac;
|
|
57
|
+
const cost_bd = area_bd;
|
|
69
58
|
|
|
70
|
-
const cost_ad = area_ad
|
|
71
|
-
const cost_cb = area_cb
|
|
59
|
+
const cost_ad = area_ad;
|
|
60
|
+
const cost_cb = area_cb;
|
|
72
61
|
|
|
73
62
|
const cost0 = cost_ab + cost_cd;
|
|
74
63
|
const cost1 = cost_ac + cost_bd;
|
|
@@ -78,37 +67,24 @@ export function ebvh_nodes_sort_sah_local4(
|
|
|
78
67
|
|
|
79
68
|
if (cost0 <= cost1 && cost0 <= cost2) {
|
|
80
69
|
// no change
|
|
81
|
-
post_swap = cost_cd > cost_ab;
|
|
82
70
|
|
|
83
71
|
} else if (cost1 <= cost2) {
|
|
84
72
|
// swap C and B
|
|
85
73
|
nodes[index_b] = node_c;
|
|
86
74
|
nodes[index_c] = node_b;
|
|
87
75
|
|
|
88
|
-
primitive_counts[index_b] = count_c;
|
|
89
|
-
primitive_counts[index_c] = count_b;
|
|
90
|
-
|
|
91
76
|
swap_count++;
|
|
92
77
|
|
|
93
|
-
post_swap = cost_bd > cost_ac;
|
|
94
78
|
} else {
|
|
95
79
|
// swap B and D
|
|
96
80
|
nodes[index_b] = node_d;
|
|
97
81
|
nodes[index_d] = node_b;
|
|
98
82
|
|
|
99
|
-
primitive_counts[index_b] = count_d;
|
|
100
|
-
primitive_counts[index_d] = count_b;
|
|
101
83
|
|
|
102
84
|
swap_count++;
|
|
103
85
|
|
|
104
|
-
post_swap = cost_cb > cost_ad;
|
|
105
86
|
}
|
|
106
87
|
|
|
107
|
-
if (post_swap) {
|
|
108
|
-
// put node pairs in their cost order
|
|
109
|
-
array_swap(nodes, index_a, nodes, index_c, 2);
|
|
110
|
-
array_swap(primitive_counts, index_a, primitive_counts, index_c, 2);
|
|
111
|
-
}
|
|
112
88
|
|
|
113
89
|
}
|
|
114
90
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathTracedScene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracedScene.js"],"names":[],"mappings":"AAoDA;IAGI;;;OAGG;IACH,eAFU,GAAG,CAEa;IAG1B;;;OAGG;IACH,QAFU,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAElB;IAEnB;;;OAGG;IACH,UAFU,aAAa,EAAE,CAEX;IAEd;;;OAGG;IACH,WAFU,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAElC;IAmBtB;;;;OAIG;IACH,6BAA6C;
|
|
1
|
+
{"version":3,"file":"PathTracedScene.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/path_tracer/PathTracedScene.js"],"names":[],"mappings":"AAoDA;IAGI;;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bvh.node_set_height(node, 0);
|
|
172
172
|
|
|
173
173
|
}
|
|
174
|
-
const primitive_counts = new Uint32Array(node_leaf_count);
|
|
175
|
-
primitive_counts.fill(1);
|
|
176
174
|
|
|
177
|
-
ebvh_nodes_sort_sah_local4(bvh, nodes,
|
|
175
|
+
ebvh_nodes_sort_sah_local4(bvh, nodes, 0, 2, node_leaf_count);
|
|
178
176
|
|
|
179
177
|
// record newly generated nodes as "unprocessed"
|
|
180
178
|
const unprocessed_nodes = new Uint32Array(node_leaf_count);
|