@woosh/meep-engine 2.119.110 → 2.119.111
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/binary/operations/bitCount.d.ts.map +1 -1
- package/src/core/binary/operations/bitCount.js +8 -7
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/build_triangle_morton_codes.js +7 -4
- package/src/core/binary/bitcount.d.ts +0 -7
- package/src/core/binary/bitcount.d.ts.map +0 -1
- package/src/core/binary/bitcount.js +0 -15
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bitCount.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/operations/bitCount.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,4BAHW,MAAM,GACJ,MAAM,
|
|
1
|
+
{"version":3,"file":"bitCount.d.ts","sourceRoot":"","sources":["../../../../../src/core/binary/operations/bitCount.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,4BAHW,MAAM,GACJ,MAAM,CAalB"}
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* @returns {number}
|
|
5
5
|
*/
|
|
6
6
|
export function bitCount(v) {
|
|
7
|
-
|
|
7
|
+
// see https://stackoverflow.com/a/109025/3973586
|
|
8
|
+
// see https://graphics.stanford.edu/%7Eseander/bithacks.html#CountBitsSetParallel
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
x = ((x >> 1) & 0x55555555) + (x & 0x55555555);
|
|
11
|
-
x = ((x >> 2) & 0x33333333) + (x & 0x33333333);
|
|
12
|
-
x = ((x >> 4) & 0x0f0f0f0f) + (x & 0x0f0f0f0f);
|
|
13
|
-
x = ((x >> 8) & 0x00ff00ff) + (x & 0x00ff00ff);
|
|
10
|
+
let i = v|0;
|
|
14
11
|
|
|
15
|
-
|
|
12
|
+
i = i - ((i >> 1) & 0x55555555); // add pairs of bits
|
|
13
|
+
i = (i & 0x33333333) + ((i >> 2) & 0x33333333); // quads
|
|
14
|
+
i = (i + (i >> 4)) & 0x0F0F0F0F; // groups of 8
|
|
15
|
+
i *= 0x01010101; // horizontal sum of bytes
|
|
16
|
+
return i >> 24; // return just that top byte (after truncating to 32-bit even when int is wider than uint32_t)
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build_triangle_morton_codes.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/build_triangle_morton_codes.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,0DAXW,MAAM,EAAE,GAAC,WAAW,aACpB,MAAM,eACN,MAAM,EAAE,GAAC,UAAU,GAAC,WAAW,GAAC,WAAW,kBAC3C,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,
|
|
1
|
+
{"version":3,"file":"build_triangle_morton_codes.d.ts","sourceRoot":"","sources":["../../../../../src/core/bvh2/bvh3/build_triangle_morton_codes.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,0DAXW,MAAM,EAAE,GAAC,WAAW,aACpB,MAAM,eACN,MAAM,EAAE,GAAC,UAAU,GAAC,WAAW,GAAC,WAAW,kBAC3C,MAAM,EAAE,GAAC,YAAY,WACrB,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,WACN,MAAM,QAyEhB"}
|
|
@@ -21,6 +21,7 @@ export function build_triangle_morton_codes(
|
|
|
21
21
|
aabb_x0, aabb_y0, aabb_z0,
|
|
22
22
|
aabb_x1, aabb_y1, aabb_z1
|
|
23
23
|
) {
|
|
24
|
+
// TODO use adaptive number of bits per axis (see "Extended Morton Codes for High Performance Bounding Volume Hierarchy Construction" by Marek Vinkler et al, 2017, Proceedings of HPG
|
|
24
25
|
|
|
25
26
|
const aabb_size_x = aabb_x1 - aabb_x0;
|
|
26
27
|
const aabb_size_y = aabb_y1 - aabb_y0;
|
|
@@ -35,9 +36,10 @@ export function build_triangle_morton_codes(
|
|
|
35
36
|
const aabb_3_z0 = aabb_z0 * 3;
|
|
36
37
|
|
|
37
38
|
// compute multipliers to bring normalized values in range of 10bit unsigned integer each
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
const
|
|
39
|
+
// NOTE we give extra 11 bits to X and Z as most models tend to sprawl horizontally
|
|
40
|
+
const morton_scale_x = aabb_size_x === 0 ? 0 : 2047 / (aabb_size_x * 3);
|
|
41
|
+
const morton_scale_y = aabb_size_y === 0 ? 0 : 1023 / (aabb_size_y * 3);
|
|
42
|
+
const morton_scale_z = aabb_size_z === 0 ? 0 : 2047 / (aabb_size_z * 3);
|
|
41
43
|
|
|
42
44
|
// compute morton codes
|
|
43
45
|
for (let i = 0; i < tri_count; i++) {
|
|
@@ -66,6 +68,7 @@ export function build_triangle_morton_codes(
|
|
|
66
68
|
const cy = position_array[c_address + 1];
|
|
67
69
|
const cz = position_array[c_address + 2];
|
|
68
70
|
|
|
71
|
+
// compute centroid coordinate
|
|
69
72
|
const center_x = (ax + bx + cx);
|
|
70
73
|
const center_y = (ay + by + cy);
|
|
71
74
|
const center_z = (az + bz + cz);
|
|
@@ -77,8 +80,8 @@ export function build_triangle_morton_codes(
|
|
|
77
80
|
|
|
78
81
|
morton_codes[i] = morton(
|
|
79
82
|
Math.round(ncx),
|
|
83
|
+
Math.round(ncz),
|
|
80
84
|
Math.round(ncy),
|
|
81
|
-
Math.round(ncz)
|
|
82
85
|
);
|
|
83
86
|
}
|
|
84
87
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bitcount.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/bitcount.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,8BAHW,MAAM,GACJ,MAAM,CAWlB"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {number} i32
|
|
4
|
-
* @returns {number} number of set bits
|
|
5
|
-
*/
|
|
6
|
-
export function bitcount(i32){
|
|
7
|
-
// see https://stackoverflow.com/a/109025/3973586
|
|
8
|
-
// see https://graphics.stanford.edu/%7Eseander/bithacks.html#CountBitsSetParallel
|
|
9
|
-
|
|
10
|
-
let i = (i32|0) - ((i32 >> 1) & 0x55555555); // add pairs of bits
|
|
11
|
-
i = (i & 0x33333333) + ((i >> 2) & 0x33333333); // quads
|
|
12
|
-
i = (i + (i >> 4)) & 0x0F0F0F0F; // groups of 8
|
|
13
|
-
i *= 0x01010101; // horizontal sum of bytes
|
|
14
|
-
return i >> 24; // return just that top byte (after truncating to 32-bit even when int is wider than uint32_t)
|
|
15
|
-
}
|