@woosh/meep-engine 2.119.108 → 2.119.110

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
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.119.108",
8
+ "version": "2.119.110",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -0,0 +1,7 @@
1
+ /**
2
+ *
3
+ * @param {number} i32
4
+ * @returns {number} number of set bits
5
+ */
6
+ export function bitcount(i32: number): number;
7
+ //# sourceMappingURL=bitcount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitcount.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/bitcount.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,8BAHW,MAAM,GACJ,MAAM,CAWlB"}
@@ -0,0 +1,15 @@
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
+ }
@@ -43,7 +43,7 @@ export function int32_to_binary_string(input_value, byte_separator = " ", bit_co
43
43
  result += byte_separator;
44
44
  }
45
45
 
46
- const bit_value = (input_value << bit_index) >>> 31;
46
+ const bit_value = (input_value << (bit_index + 32 - bit_count)) >>> 31;
47
47
 
48
48
  result += String(bit_value);
49
49