@woosh/meep-engine 2.114.0 → 2.116.0
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/build/meep.cjs +236 -197
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +236 -197
- package/editor/ecs/component/editors/Sampler2DEditor.js +3 -3
- package/editor/view/ecs/HierarchicalEntityListView.js +2 -2
- package/package.json +1 -1
- package/src/core/binary/clz32.d.ts +7 -0
- package/src/core/binary/clz32.d.ts.map +1 -0
- package/src/core/binary/clz32.js +37 -0
- package/src/core/binary/is_data_url.d.ts.map +1 -1
- package/src/core/binary/is_data_url.js +1 -0
- package/src/core/binary/makeArrayBuffer.d.ts.map +1 -1
- package/src/core/binary/makeArrayBuffer.js +1 -0
- package/src/core/binary/msb_32.d.ts +7 -1
- package/src/core/binary/msb_32.d.ts.map +1 -1
- package/src/core/binary/msb_32.js +3 -12
- package/src/core/collection/RingBuffer.d.ts +1 -1
- package/src/core/collection/RingBuffer.js +1 -1
- package/src/core/{primitives/array/compareArrays.d.ts → collection/array/array_compare.d.ts} +2 -2
- package/src/core/collection/array/array_compare.d.ts.map +1 -0
- package/src/core/{primitives/array/compareArrays.js → collection/array/array_compare.js} +5 -1
- package/src/core/collection/array/{arrayIndexByEquality.d.ts → array_index_by_equality.d.ts} +2 -2
- package/src/core/collection/array/array_index_by_equality.d.ts.map +1 -0
- package/src/core/collection/array/{arrayIndexByEquality.js → array_index_by_equality.js} +1 -1
- package/src/core/collection/array/array_pick_best_element.d.ts.map +1 -0
- package/src/core/collection/array/{arrayPickBestElement.js → array_pick_best_element.js} +2 -2
- package/src/core/collection/array/array_pick_best_elements.d.ts +8 -0
- package/src/core/collection/array/array_pick_best_elements.d.ts.map +1 -0
- package/src/core/collection/array/{arrayPickBestElements.js → array_pick_best_elements.js} +1 -1
- package/src/core/collection/array/{arraySetDiff.d.ts → array_set_diff.d.ts} +3 -3
- package/src/core/collection/array/array_set_diff.d.ts.map +1 -0
- package/src/core/collection/array/{arraySetDiff.js → array_set_diff.js} +4 -4
- package/src/core/collection/array/{arraySetSortingDiff.d.ts → array_set_diff_sorting.d.ts} +2 -2
- package/src/core/collection/array/array_set_diff_sorting.d.ts.map +1 -0
- package/src/core/collection/array/{arraySetSortingDiff.js → array_set_diff_sorting.js} +1 -1
- package/src/core/collection/array/combine_hash.js +1 -1
- package/src/core/{primitives → collection}/array/computeIntegerArrayHash.d.ts.map +1 -1
- package/src/core/{primitives → collection}/array/computeStridedArrayHash.d.ts.map +1 -1
- package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.d.ts.map +1 -1
- package/src/core/collection/array/randomMultipleFromArray.d.ts +6 -6
- package/src/core/collection/array/randomMultipleFromArray.d.ts.map +1 -1
- package/src/core/collection/array/randomMultipleFromArray.js +5 -5
- package/src/core/collection/array/typed/sparse_typed_array_hash.js +1 -1
- package/src/core/collection/array/typed/typedArrayConstructorByInstance.d.ts.map +1 -0
- package/src/core/collection/list/FilteredListProjection.d.ts.map +1 -1
- package/src/core/collection/list/FilteredListProjection.js +2 -2
- package/src/core/collection/list/List.js +4 -4
- package/src/core/geom/2d/Rectangle.d.ts.map +1 -1
- package/src/core/geom/2d/Rectangle.js +18 -5
- package/src/core/geom/2d/aabb/aabb2_overlap_exists.d.ts.map +1 -1
- package/src/core/geom/2d/aabb/aabb2_overlap_exists.js +4 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.d.ts +3 -3
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.d.ts.map +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js +11 -4
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +2 -2
- package/src/core/geom/2d/convex-hull/orientation3_array.js +2 -2
- package/src/core/geom/2d/intersect_ray_2d.d.ts.map +1 -1
- package/src/core/geom/2d/intersect_ray_2d.js +5 -5
- package/src/core/geom/2d/{compute_triangle_area_2d.d.ts → triangle2d_compute_area.d.ts} +2 -2
- package/src/core/geom/2d/triangle2d_compute_area.d.ts.map +1 -0
- package/src/core/geom/2d/{compute_triangle_area_2d.js → triangle2d_compute_area.js} +1 -1
- package/src/core/geom/2d/triangle2d_contains_point.d.ts +14 -0
- package/src/core/geom/2d/triangle2d_contains_point.d.ts.map +1 -0
- package/src/core/geom/2d/triangle2d_contains_point.js +39 -0
- package/src/core/geom/2d/triangle2d_get_barycentric.d.ts +2 -2
- package/src/core/geom/2d/triangle2d_get_barycentric.d.ts.map +1 -1
- package/src/core/geom/2d/triangle2d_get_barycentric.js +1 -1
- package/src/core/geom/3d/topology/expandConnectivityByLocality.js +2 -2
- package/src/core/geom/Vector2.d.ts.map +1 -1
- package/src/core/geom/Vector2.js +2 -2
- package/src/core/math/bessel_3.d.ts +1 -1
- package/src/core/math/bessel_3.js +1 -1
- package/src/core/math/computeWholeDivisorLow.d.ts +1 -1
- package/src/core/math/computeWholeDivisorLow.d.ts.map +1 -1
- package/src/core/math/computeWholeDivisorLow.js +8 -5
- package/src/core/math/interval/separation1D.d.ts.map +1 -0
- package/src/core/math/{separation1D.js → interval/separation1D.js} +3 -3
- package/src/core/math/solveQuadratic.d.ts.map +1 -1
- package/src/core/math/solveQuadratic.js +10 -0
- package/src/core/model/object/compareValues.js +5 -5
- package/src/engine/EntityCreator.d.ts +11 -11
- package/src/engine/EntityCreator.d.ts.map +1 -1
- package/src/engine/EntityCreator.js +2 -4
- package/src/engine/ecs/EntityComponentDataset.js +3 -3
- package/src/engine/ecs/grid/HeightMap2NormalMap.js +2 -2
- package/src/engine/ecs/grid/NormalMap2AOMap.js +3 -3
- package/src/engine/graphics/ecs/mesh/SkeletonUtils.js +2 -2
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts +2 -2
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/util/build_cutout_from_atlas_by_alpha.js +5 -55
- package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.d.ts +9 -0
- package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.d.ts.map +1 -0
- package/src/engine/graphics/impostors/octahedral/util/sampler2d_build_cutout.js +64 -0
- package/src/engine/graphics/sh3/path_tracer/material/MaterialConverter.js +2 -2
- package/src/engine/graphics/texture/sampler/Sampler2D.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/Sampler2D.js +4 -2
- package/src/engine/graphics/texture/sampler/filter/kaiser_bessel_window.js +1 -1
- package/src/engine/graphics/texture/sampler/filter/sampler2d_scale_down_generic.js +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_multiply_vector.d.ts +8 -0
- package/src/engine/graphics/texture/sampler/sampler2d_multiply_vector.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/{sampler_multiply_vector.js → sampler2d_multiply_vector.js} +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_to_float32_texture.d.ts +8 -0
- package/src/engine/graphics/texture/sampler/sampler2d_to_float32_texture.d.ts.map +1 -0
- package/src/engine/graphics/texture/sampler/{sampler2DToFloat32Texture.js → sampler2d_to_float32_texture.js} +2 -2
- package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/util/drawSamplerHTML.js +3 -1
- package/src/engine/grid/obstacle/GridObstacle.d.ts.map +1 -1
- package/src/engine/grid/obstacle/GridObstacle.js +1 -1
- package/src/engine/physics/computeInterceptPoint.js +20 -6
- package/src/engine/physics/mls-mpm/MLS_MPM.d.ts.map +1 -1
- package/src/engine/physics/mls-mpm/MLS_MPM.js +14 -17
- package/src/engine/platform/WebEnginePlatform.d.ts.map +1 -1
- package/src/engine/platform/WebEnginePlatform.js +4 -4
- package/src/engine/save/GameStateLoader.js +2 -2
- package/src/engine/ui/cursor/CursorCoalescence.d.ts.map +1 -1
- package/src/engine/ui/cursor/CursorCoalescence.js +2 -2
- package/src/view/elements/radial/RadialMenu.js +2 -2
- package/src/core/UUID.d.ts +0 -6
- package/src/core/UUID.d.ts.map +0 -1
- package/src/core/UUID.js +0 -21
- package/src/core/collection/array/arrayIndexByEquality.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickBestElement.d.ts.map +0 -1
- package/src/core/collection/array/arrayPickBestElements.d.ts +0 -8
- package/src/core/collection/array/arrayPickBestElements.d.ts.map +0 -1
- package/src/core/collection/array/arraySetDiff.d.ts.map +0 -1
- package/src/core/collection/array/arraySetSortingDiff.d.ts.map +0 -1
- package/src/core/geom/2d/compute_triangle_area_2d.d.ts.map +0 -1
- package/src/core/geom/2d/convex-hull/orientation3.d.ts +0 -12
- package/src/core/geom/2d/convex-hull/orientation3.d.ts.map +0 -1
- package/src/core/geom/2d/convex-hull/orientation3.js +0 -489
- package/src/core/geom/2d/convex-hull/orientation3_v2.d.ts +0 -9
- package/src/core/geom/2d/convex-hull/orientation3_v2.d.ts.map +0 -1
- package/src/core/geom/2d/convex-hull/orientation3_v2.js +0 -12
- package/src/core/math/separation1D.d.ts.map +0 -1
- package/src/core/primitives/array/compareArrays.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.d.ts +0 -8
- package/src/engine/graphics/texture/sampler/sampler2DToFloat32Texture.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/sampler_multiply_vector.d.ts +0 -8
- package/src/engine/graphics/texture/sampler/sampler_multiply_vector.d.ts.map +0 -1
- package/src/engine/graphics/texture/sampler/typedArrayConstructorByInstance.d.ts.map +0 -1
- package/src/engine/save/storage/InMemoryLocalStorage.d.ts +0 -6
- package/src/engine/save/storage/InMemoryLocalStorage.d.ts.map +0 -1
- package/src/engine/save/storage/InMemoryLocalStorage.js +0 -13
- /package/src/core/collection/array/{arrayPickBestElement.d.ts → array_pick_best_element.d.ts} +0 -0
- /package/src/core/{primitives → collection}/array/computeIntegerArrayHash.d.ts +0 -0
- /package/src/core/{primitives → collection}/array/computeIntegerArrayHash.js +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedArrayHash.d.ts +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedArrayHash.js +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.d.ts +0 -0
- /package/src/core/{primitives → collection}/array/computeStridedIntegerArrayHash.js +0 -0
- /package/src/{engine/graphics/texture/sampler → core/collection/array/typed}/typedArrayConstructorByInstance.d.ts +0 -0
- /package/src/{engine/graphics/texture/sampler → core/collection/array/typed}/typedArrayConstructorByInstance.js +0 -0
- /package/src/core/math/{separation1D.d.ts → interval/separation1D.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clz32.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/clz32.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,yBAHW,MAAM,GACJ,MAAM,CAiClB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Count leading zeroes in a 32bit integer
|
|
3
|
+
* @param {number} x
|
|
4
|
+
* @returns {number}
|
|
5
|
+
*/
|
|
6
|
+
export function clz32(x) {
|
|
7
|
+
if (x === 0) {
|
|
8
|
+
return 32;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let v = x >>> 0;
|
|
12
|
+
let result = 0;
|
|
13
|
+
|
|
14
|
+
// Binary search.
|
|
15
|
+
if ((v & 0xFFFF0000) === 0) {
|
|
16
|
+
v <<= 16;
|
|
17
|
+
result += 16;
|
|
18
|
+
}
|
|
19
|
+
if ((v & 0xFF000000) === 0) {
|
|
20
|
+
v <<= 8;
|
|
21
|
+
result += 8;
|
|
22
|
+
}
|
|
23
|
+
if ((v & 0xF0000000) === 0) {
|
|
24
|
+
v <<= 4;
|
|
25
|
+
result += 4;
|
|
26
|
+
}
|
|
27
|
+
if ((v & 0xC0000000) === 0) {
|
|
28
|
+
v <<= 2;
|
|
29
|
+
result += 2;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if ((v & 0x80000000) === 0) {
|
|
33
|
+
result += 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is_data_url.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/is_data_url.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"is_data_url.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/is_data_url.js"],"names":[],"mappings":"AACA;;;;GAIG;AACH,iCAHW,MAAM,GACL,OAAO,CAQlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"makeArrayBuffer.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/makeArrayBuffer.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,2CAJW,MAAM,WACN,OAAO,GACN,WAAW,GAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"makeArrayBuffer.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/makeArrayBuffer.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,2CAJW,MAAM,WACN,OAAO,GACN,WAAW,GAAC,iBAAiB,CAexC"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* get most significant set bit
|
|
3
|
+
* @see https://graphics.stanford.edu/~seander/bithacks.html
|
|
4
|
+
* @param {number} x 32 bit integer
|
|
5
|
+
* @returns {number} integer position of most significant bit
|
|
6
|
+
*/
|
|
7
|
+
export function msb_32(x: number): number;
|
|
2
8
|
//# sourceMappingURL=msb_32.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"msb_32.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/msb_32.js"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"msb_32.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/msb_32.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,0BAHW,MAAM,GACJ,MAAM,CAIlB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { clz32 } from "./clz32.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* get most significant set bit
|
|
@@ -6,15 +6,6 @@ import { msb_lut_de_bruijn } from "./msb_lut_de_bruijn.js";
|
|
|
6
6
|
* @param {number} x 32 bit integer
|
|
7
7
|
* @returns {number} integer position of most significant bit
|
|
8
8
|
*/
|
|
9
|
-
function msb_32(x) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
v |= v >>> 1;
|
|
13
|
-
v |= v >>> 2;
|
|
14
|
-
v |= v >>> 4;
|
|
15
|
-
v |= v >>> 8;
|
|
16
|
-
v |= v >>> 16;
|
|
17
|
-
v = (v >>> 1) + 1;
|
|
18
|
-
|
|
19
|
-
return msb_lut_de_bruijn[(v * 0x077CB531) >>> 27];
|
|
9
|
+
export function msb_32(x) {
|
|
10
|
+
return 31 - clz32(x);
|
|
20
11
|
}
|
package/src/core/{primitives/array/compareArrays.d.ts → collection/array/array_compare.d.ts}
RENAMED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @param {function(T,T):number} comparator
|
|
6
6
|
* @return {number}
|
|
7
7
|
*/
|
|
8
|
-
export function
|
|
9
|
-
//# sourceMappingURL=
|
|
8
|
+
export function array_compare<T>(as: T[], bs: T[], comparator: (arg0: T, arg1: T) => number): number;
|
|
9
|
+
//# sourceMappingURL=array_compare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_compare.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_compare.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,qFAHyB,MAAM,GACnB,MAAM,CA0BjB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* @template T
|
|
3
5
|
* @param {T[]} as
|
|
@@ -5,7 +7,9 @@
|
|
|
5
7
|
* @param {function(T,T):number} comparator
|
|
6
8
|
* @return {number}
|
|
7
9
|
*/
|
|
8
|
-
export function
|
|
10
|
+
export function array_compare(as, bs, comparator) {
|
|
11
|
+
assert.isFunction(comparator,'comparator');
|
|
12
|
+
|
|
9
13
|
const n = as.length;
|
|
10
14
|
const m = bs.length;
|
|
11
15
|
|
package/src/core/collection/array/{arrayIndexByEquality.d.ts → array_index_by_equality.d.ts}
RENAMED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
* @param {function(a:T,b:T):boolean} equals
|
|
7
7
|
* @returns {number} index of first match or -1 if no matches found
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
10
|
-
//# sourceMappingURL=
|
|
9
|
+
export function array_index_by_equality<T>(array: T[], element: T, equals: any): number;
|
|
10
|
+
//# sourceMappingURL=array_index_by_equality.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_index_by_equality.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_index_by_equality.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,iFAFa,MAAM,CAclB"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {function(a:T,b:T):boolean} equals
|
|
7
7
|
* @returns {number} index of first match or -1 if no matches found
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
9
|
+
export function array_index_by_equality(array, element, equals) {
|
|
10
10
|
const n = array.length;
|
|
11
11
|
|
|
12
12
|
for (let i = 0; i < n; i++) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_pick_best_element.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_pick_best_element.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,8EAkCC"}
|
|
@@ -8,9 +8,9 @@ import { assert } from "../../assert.js";
|
|
|
8
8
|
* @param {function(el:T, index:number):number} scoreFunction
|
|
9
9
|
* @returns {T|undefined}
|
|
10
10
|
*/
|
|
11
|
-
export function
|
|
11
|
+
export function array_pick_best_element(array, scoreFunction) {
|
|
12
12
|
assert.notEqual(array, undefined, 'array is undefined');
|
|
13
|
-
assert.
|
|
13
|
+
assert.isFunction(scoreFunction, 'scoreFunction');
|
|
14
14
|
|
|
15
15
|
let bestElement;
|
|
16
16
|
let bestScore;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @param {T[]} array
|
|
4
|
+
* @param {function(el:T, index:number):number} scoreFunction
|
|
5
|
+
* @returns {T[]}
|
|
6
|
+
*/
|
|
7
|
+
export function array_pick_best_elements<T>(array: T[], scoreFunction: any): T[];
|
|
8
|
+
//# sourceMappingURL=array_pick_best_elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_pick_best_elements.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_pick_best_elements.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,iFA0CC"}
|
|
@@ -6,7 +6,7 @@ import { assert } from "../../assert.js";
|
|
|
6
6
|
* @param {function(el:T, index:number):number} scoreFunction
|
|
7
7
|
* @returns {T[]}
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
9
|
+
export function array_pick_best_elements(array, scoreFunction) {
|
|
10
10
|
assert.notEqual(array, undefined, 'array is undefined');
|
|
11
11
|
assert.isArray(array, 'array');
|
|
12
12
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compute a diff between two arrays, result is a 3 way split between common items, unique items in `a` array and unique items in `b` array
|
|
3
|
-
* @see prefer to use {@link
|
|
3
|
+
* @see prefer to use {@link array_set_diff_sorting}, as it's much faster, especially for large sets
|
|
4
4
|
* @template T
|
|
5
5
|
* @param {T[]} a
|
|
6
6
|
* @param {T[]} b
|
|
7
7
|
* @param {function(a:T,b:T):boolean} [equals] method to determine equality between two elements
|
|
8
8
|
* @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
|
|
9
9
|
*/
|
|
10
|
-
export function
|
|
10
|
+
export function array_set_diff<T>(a: T[], b: T[], equals?: typeof strictEquals): {
|
|
11
11
|
uniqueA: T[];
|
|
12
12
|
uniqueB: T[];
|
|
13
13
|
common: T[];
|
|
14
14
|
};
|
|
15
15
|
import { strictEquals } from "../../function/strictEquals.js";
|
|
16
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=array_set_diff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_set_diff.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_set_diff.js"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH;;;;EAoCC;6BAhD4B,gCAAgC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { assert } from "../../assert.js";
|
|
2
2
|
|
|
3
3
|
import { strictEquals } from "../../function/strictEquals.js";
|
|
4
|
-
import {
|
|
4
|
+
import { array_index_by_equality } from "./array_index_by_equality.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Compute a diff between two arrays, result is a 3 way split between common items, unique items in `a` array and unique items in `b` array
|
|
8
|
-
* @see prefer to use {@link
|
|
8
|
+
* @see prefer to use {@link array_set_diff_sorting}, as it's much faster, especially for large sets
|
|
9
9
|
* @template T
|
|
10
10
|
* @param {T[]} a
|
|
11
11
|
* @param {T[]} b
|
|
12
12
|
* @param {function(a:T,b:T):boolean} [equals] method to determine equality between two elements
|
|
13
13
|
* @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
|
|
14
14
|
*/
|
|
15
|
-
export function
|
|
15
|
+
export function array_set_diff(a, b, equals = strictEquals) {
|
|
16
16
|
assert.isArray(a, 'a');
|
|
17
17
|
assert.isArray(b, 'b');
|
|
18
18
|
assert.isFunction(equals, 'equals');
|
|
@@ -27,7 +27,7 @@ export function arraySetDiff(a, b, equals = strictEquals) {
|
|
|
27
27
|
for (let i = 0; i < a_length; i++) {
|
|
28
28
|
const elA = uniqueA[i];
|
|
29
29
|
|
|
30
|
-
const j =
|
|
30
|
+
const j = array_index_by_equality(uniqueB, elA, equals);
|
|
31
31
|
|
|
32
32
|
if (j !== -1) {
|
|
33
33
|
// common element found
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
* @param {function(a:T,b:T):number} [compare]
|
|
7
7
|
* @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
|
|
8
8
|
*/
|
|
9
|
-
export function
|
|
9
|
+
export function array_set_diff_sorting<T>(a: T[], b: T[], compare: any): {
|
|
10
10
|
uniqueA: T[];
|
|
11
11
|
uniqueB: T[];
|
|
12
12
|
common: T[];
|
|
13
13
|
};
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=array_set_diff_sorting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_set_diff_sorting.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/array_set_diff_sorting.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH;;;;EAsDC"}
|
|
@@ -10,7 +10,7 @@ import { assert } from "../../assert.js";
|
|
|
10
10
|
* @param {function(a:T,b:T):number} [compare]
|
|
11
11
|
* @returns {{uniqueA:T[], uniqueB:T[], common:T[]}}
|
|
12
12
|
*/
|
|
13
|
-
export function
|
|
13
|
+
export function array_set_diff_sorting(a, b, compare) {
|
|
14
14
|
assert.isFunction(compare, 'compare');
|
|
15
15
|
|
|
16
16
|
const uniqueA = a.slice();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert } from "../../assert.js";
|
|
2
|
-
import { computeIntegerArrayHash } from "
|
|
2
|
+
import { computeIntegerArrayHash } from "./computeIntegerArrayHash.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Computes hash on integer values, useful for building composite hashes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeIntegerArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/
|
|
1
|
+
{"version":3,"file":"computeIntegerArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/computeIntegerArrayHash.js"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,8CAJW,UAAU,GAAC,MAAM,EAAE,GAAC,UAAU,MAAM,CAAC,GAAC,UAAU,UAChD,MAAM,UACN,MAAM,UAIhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeStridedArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/
|
|
1
|
+
{"version":3,"file":"computeStridedArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/computeStridedArrayHash.js"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AACH,wGAPW,MAAM,UACN,MAAM,UACN,MAAM,4BACM,MAAM,6BAEjB,MAAM,CAwBjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeStridedIntegerArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/
|
|
1
|
+
{"version":3,"file":"computeStridedIntegerArrayHash.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/computeStridedIntegerArrayHash.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,sDANW,MAAM,EAAE,GAAC,WAAW,GAAC,WAAW,GAAC,UAAU,UAC3C,MAAM,UACN,MAAM,UACN,MAAM,GACL,MAAM,CAoBjB"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
* Pick multiple random items from an array
|
|
3
3
|
*
|
|
4
4
|
* @template T
|
|
5
|
-
* @param {function} random
|
|
6
|
-
* @param {T[]} source
|
|
7
|
-
* @param {T[]} target
|
|
8
|
-
* @param {number} count how many items to pick
|
|
9
|
-
* @returns {
|
|
5
|
+
* @param {function} random random function, must return a value between 0 and 1
|
|
6
|
+
* @param {T[]} source Where to pick elements from
|
|
7
|
+
* @param {T[]} target Where to place picked elements
|
|
8
|
+
* @param {number} count how many items to pick, if this number is greater than the length of {@link source}, it will be limited to length of {@link source} instead
|
|
9
|
+
* @returns {number} number of picked elements
|
|
10
10
|
*/
|
|
11
|
-
export function randomMultipleFromArray<T>(random: Function, source: T[], target: T[], count: number):
|
|
11
|
+
export function randomMultipleFromArray<T>(random: Function, source: T[], target: T[], count: number): number;
|
|
12
12
|
//# sourceMappingURL=randomMultipleFromArray.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"randomMultipleFromArray.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/randomMultipleFromArray.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,8FAHW,MAAM,
|
|
1
|
+
{"version":3,"file":"randomMultipleFromArray.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/array/randomMultipleFromArray.js"],"names":[],"mappings":"AAGA;;;;;;;;;GASG;AACH,8FAHW,MAAM,GACJ,MAAM,CAsBlB"}
|
|
@@ -5,11 +5,11 @@ import { array_shuffle } from "./array_shuffle.js";
|
|
|
5
5
|
* Pick multiple random items from an array
|
|
6
6
|
*
|
|
7
7
|
* @template T
|
|
8
|
-
* @param {function} random
|
|
9
|
-
* @param {T[]} source
|
|
10
|
-
* @param {T[]} target
|
|
11
|
-
* @param {number} count how many items to pick
|
|
12
|
-
* @returns {
|
|
8
|
+
* @param {function} random random function, must return a value between 0 and 1
|
|
9
|
+
* @param {T[]} source Where to pick elements from
|
|
10
|
+
* @param {T[]} target Where to place picked elements
|
|
11
|
+
* @param {number} count how many items to pick, if this number is greater than the length of {@link source}, it will be limited to length of {@link source} instead
|
|
12
|
+
* @returns {number} number of picked elements
|
|
13
13
|
*/
|
|
14
14
|
export function randomMultipleFromArray(random, source, target, count) {
|
|
15
15
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { min2 } from "../../../math/min2.js";
|
|
2
|
-
import { computeStridedArrayHash } from "../../../primitives/array/computeStridedArrayHash.js";
|
|
3
2
|
import { computeHashFloat } from "../../../primitives/numbers/computeHashFloat.js";
|
|
3
|
+
import { computeStridedArrayHash } from "../computeStridedArrayHash.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedArrayConstructorByInstance.d.ts","sourceRoot":"","sources":["../../../../../../src/core/collection/array/typed/typedArrayConstructorByInstance.js"],"names":[],"mappings":"AAAA,8SAwBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilteredListProjection.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/list/FilteredListProjection.js"],"names":[],"mappings":"AAKA;IACI;;;;;OAKG;IACH,qCAHW,sBAAsB,EA6BhC;IAzBG;;;OAGG;IACH,eAAkB;IAElB;;;OAGG;IACH,gBAAwB;IAExB;;;OAGG;IACH,SAFU,sBAAsB,CAEV;IAEtB;;;OAGG;IACH,UAFU,OAAO,CAEG;IAEpB,wBAAoD;IAGxD,eAMC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,sBAEC;IAED;;;OAGG;IACH,0BAGC;IAED;;;OAGG;IACH,4BAGC;IAED,aAUC;IAED,eAQC;IAED,cAiFC;CACJ;
|
|
1
|
+
{"version":3,"file":"FilteredListProjection.d.ts","sourceRoot":"","sources":["../../../../../src/core/collection/list/FilteredListProjection.js"],"names":[],"mappings":"AAKA;IACI;;;;;OAKG;IACH,qCAHW,sBAAsB,EA6BhC;IAzBG;;;OAGG;IACH,eAAkB;IAElB;;;OAGG;IACH,gBAAwB;IAExB;;;OAGG;IACH,SAFU,sBAAsB,CAEV;IAEtB;;;OAGG;IACH,UAFU,OAAO,CAEG;IAEpB,wBAAoD;IAGxD,eAMC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,sBAEC;IAED;;;OAGG;IACH,0BAGC;IAED;;;OAGG;IACH,4BAGC;IAED,aAUC;IAED,eAQC;IAED,cAiFC;CACJ;iBAvLgB,WAAW"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { frameThrottle } from "../../../engine/graphics/FrameThrottle.js";
|
|
2
2
|
import { invokeObjectEquals } from "../../model/object/invokeObjectEquals.js";
|
|
3
|
+
import { array_set_diff } from "../array/array_set_diff.js";
|
|
3
4
|
import List from "./List.js";
|
|
4
|
-
import { arraySetDiff } from "../array/arraySetDiff.js";
|
|
5
5
|
|
|
6
6
|
export class FilteredListProjection {
|
|
7
7
|
/**
|
|
@@ -136,7 +136,7 @@ export class FilteredListProjection {
|
|
|
136
136
|
newOutput.push(v);
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
const diff =
|
|
139
|
+
const diff = array_set_diff(oldOutput, newOutput, invokeObjectEquals);
|
|
140
140
|
|
|
141
141
|
//resolve diff
|
|
142
142
|
const removals = diff.uniqueA;
|
|
@@ -7,8 +7,8 @@ import { assert } from "../../assert.js";
|
|
|
7
7
|
import Signal from "../../events/signal/Signal.js";
|
|
8
8
|
import { objectsEqual } from "../../function/objectsEqual.js";
|
|
9
9
|
import { invokeObjectEquals } from "../../model/object/invokeObjectEquals.js";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { array_index_by_equality } from "../array/array_index_by_equality.js";
|
|
11
|
+
import { array_set_diff } from "../array/array_set_diff.js";
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -214,7 +214,7 @@ class List {
|
|
|
214
214
|
|
|
215
215
|
const data = this.data;
|
|
216
216
|
|
|
217
|
-
const diff =
|
|
217
|
+
const diff = array_set_diff(data, new_data, objectsEqual);
|
|
218
218
|
|
|
219
219
|
//resolve diff
|
|
220
220
|
const removals = diff.uniqueA;
|
|
@@ -744,7 +744,7 @@ class List {
|
|
|
744
744
|
for (let i = 0; i < nThisItems; i++) {
|
|
745
745
|
const a = thisItems[i];
|
|
746
746
|
|
|
747
|
-
const index =
|
|
747
|
+
const index = array_index_by_equality(otherItems, a, invokeObjectEquals);
|
|
748
748
|
|
|
749
749
|
if (index !== -1) {
|
|
750
750
|
newData[index] = a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rectangle.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/Rectangle.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Rectangle.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/2d/Rectangle.js"],"names":[],"mappings":";AAOA;IACI;;;;;;;OAOG;IACH,gBANW,MAAM,MACN,MAAM,UACN,MAAM,WACN,MAAM,EAgBhB;IAXG;;;OAGG;IACH,mBAFU,OAAO,CAEgB;IAEjC;;;OAGG;IACH,eAFU,OAAO,CAEqB;IAG1C;;;OAGG;IACH,iBAEC;IAED;;;OAGG;IACH,iBAEC;IAED;;;OAGG;IACH,iBAEC;IAED;;;OAGG;IACH,iBAEC;IAED;;;;;;OAMG;IACH,OALW,MAAM,KACN,MAAM,SACN,MAAM,UACN,MAAM,QAKhB;IAED;;;OAGG;IACH,SAFa,SAAS,CAUrB;IAED;;;OAGG;IACH,YAFW,SAAS,QAKnB;IAED;;;;;;;OAOG;IACH,gBANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAUnB;IAED;;;;OAIG;IACH,kBAHW,SAAS,GACP,OAAO,CAQnB;IAED;;;;;;;OAOG;IACH,cANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAenB;IAED;;;;OAIG;IACH,gBAHW,SAAS,GACP,OAAO,CASnB;IAED;;;;;;OAMG;IACH,iBALW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,QAyBhB;IAED;;;OAGG;IACH,mBAFW,SAAS,QASnB;IAED;;;;;;;OAOG;IACH,cANW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,GACJ,OAAO,CAiBnB;IAED;;;;OAIG;IACH,gBAHW,SAAS,GACP,OAAO,CAUnB;IAED;;;OAGG;IACH,sBAFW,OAAO,QAUjB;IAED;;;OAGG;IACH,eAFY,MAAM,CAIjB;IAED;;;;OAIG;IACH,gBAHW,MAAO,MAAM,CAAC,GAAC,YAAY,GAAC,YAAY,GAAC,UAAU,iBACnD,MAAM,QAOhB;IAED;;;MAKC;IAED,0BAGC;IAGL;;;OAGG;IACH,sBAFU,OAAO,CAEc;CAN9B;oBArSmB,eAAe"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { intersects1D } from "../../math/interval/intersects1D.js";
|
|
2
|
-
import { overlap1D } from "../../math/interval/overlap1D.js";
|
|
3
2
|
import { max2 } from "../../math/max2.js";
|
|
4
3
|
import { min2 } from "../../math/min2.js";
|
|
5
4
|
import Vector2 from "../Vector2.js";
|
|
5
|
+
import { aabb2_contains } from "./aabb/aabb2_contains.js";
|
|
6
|
+
import { aabb2_overlap_exists } from "./aabb/aabb2_overlap_exists.js";
|
|
6
7
|
|
|
7
8
|
class Rectangle {
|
|
8
9
|
/**
|
|
@@ -140,8 +141,13 @@ class Rectangle {
|
|
|
140
141
|
|
|
141
142
|
const _x0 = p.x;
|
|
142
143
|
const _y0 = p.y;
|
|
144
|
+
const _x1 = s.x + _x0;
|
|
145
|
+
const _y1 = _y0 + s.y;
|
|
143
146
|
|
|
144
|
-
return
|
|
147
|
+
return aabb2_overlap_exists(
|
|
148
|
+
_x0, _y0, _x1, _y1,
|
|
149
|
+
x0, y0, x1, y1
|
|
150
|
+
);
|
|
145
151
|
}
|
|
146
152
|
|
|
147
153
|
/**
|
|
@@ -154,6 +160,7 @@ class Rectangle {
|
|
|
154
160
|
const y0 = other.position.y;
|
|
155
161
|
const y1 = other.size.y + y0;
|
|
156
162
|
const x1 = other.size.x + x0;
|
|
163
|
+
|
|
157
164
|
return this._overlaps(x0, y0, x1, y1);
|
|
158
165
|
}
|
|
159
166
|
|
|
@@ -213,13 +220,18 @@ class Rectangle {
|
|
|
213
220
|
_contains(x0, y0, x1, y1) {
|
|
214
221
|
const size = this.size;
|
|
215
222
|
|
|
216
|
-
const
|
|
217
|
-
|
|
223
|
+
const position = this.position;
|
|
224
|
+
|
|
225
|
+
const _x0 = position.x;
|
|
226
|
+
const _y0 = position.y;
|
|
218
227
|
|
|
219
228
|
const _y1 = size.y + _y0;
|
|
220
229
|
const _x1 = size.x + _x0;
|
|
221
230
|
|
|
222
|
-
return
|
|
231
|
+
return aabb2_contains(
|
|
232
|
+
_x0, _y0, _x1, _y1,
|
|
233
|
+
x0, y0, x1, y1
|
|
234
|
+
);
|
|
223
235
|
}
|
|
224
236
|
|
|
225
237
|
/**
|
|
@@ -230,6 +242,7 @@ class Rectangle {
|
|
|
230
242
|
contains(other) {
|
|
231
243
|
const x0 = other.position.x;
|
|
232
244
|
const y0 = other.position.y;
|
|
245
|
+
|
|
233
246
|
const y1 = other.size.y + y0;
|
|
234
247
|
const x1 = other.size.x + x0;
|
|
235
248
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aabb2_overlap_exists.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/aabb2_overlap_exists.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,0CAVW,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,GACJ,OAAO,
|
|
1
|
+
{"version":3,"file":"aabb2_overlap_exists.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/aabb2_overlap_exists.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,0CAVW,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,OACN,MAAM,GACJ,OAAO,CAQnB"}
|
|
@@ -12,7 +12,10 @@ import { overlap1D } from "../../../math/interval/overlap1D.js";
|
|
|
12
12
|
* @param {number} by1
|
|
13
13
|
* @returns {boolean} true if overlap exists, false if no overlap
|
|
14
14
|
*/
|
|
15
|
-
export function aabb2_overlap_exists(
|
|
15
|
+
export function aabb2_overlap_exists(
|
|
16
|
+
ax0, ay0, ax1, ay1,
|
|
17
|
+
bx0, by0, bx1, by1
|
|
18
|
+
) {
|
|
16
19
|
return overlap1D(ax0, ax1, bx0, bx1)
|
|
17
20
|
&& overlap1D(ay0, ay1, by0, by1);
|
|
18
21
|
}
|
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* @param {number[]|Float32Array} output result will be written here
|
|
7
7
|
* @param {number} output_offset offset into output array where to write the result
|
|
8
8
|
* @param {number} output_point_count number of points to comprise bounding polygon
|
|
9
|
-
* @param {number[]} input_points Points to be bounded, must be an ordered loop
|
|
9
|
+
* @param {number[]} input_points Points to be bounded, must be an ordered loop. Must form a convex hull
|
|
10
10
|
* @param {number} input_point_count number of points in the input to consider
|
|
11
|
-
* @returns {
|
|
11
|
+
* @returns {number} number of points added to the output
|
|
12
12
|
*
|
|
13
13
|
* @see 2014 "Implementation of linear minimum area enclosing triangle algorithm" Ovidiu Pârvu & David Gilbert
|
|
14
14
|
* @see https://github.com/MagnusTiberius/humus3/blob/9d43412d6e6be869e224817f0a966fe48a1af40f/Util/ConvexHull.cpp#L281
|
|
15
15
|
*/
|
|
16
|
-
export function fixed_convex_hull_humus(output: number[] | Float32Array, output_offset: number, output_point_count: number, input_points: number[], input_point_count: number):
|
|
16
|
+
export function fixed_convex_hull_humus(output: number[] | Float32Array, output_offset: number, output_point_count: number, input_points: number[], input_point_count: number): number;
|
|
17
17
|
//# sourceMappingURL=fixed_convex_hull_humus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixed_convex_hull_humus.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,gDAVW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,sBACN,MAAM,gBACN,MAAM,EAAE,qBACR,MAAM,GACJ,
|
|
1
|
+
{"version":3,"file":"fixed_convex_hull_humus.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/convex-hull/fixed_convex_hull_humus.js"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,gDAVW,MAAM,EAAE,GAAC,YAAY,iBACrB,MAAM,sBACN,MAAM,gBACN,MAAM,EAAE,qBACR,MAAM,GACJ,MAAM,CA0IlB"}
|
|
@@ -13,9 +13,9 @@ import { intersect_ray_2d } from "../intersect_ray_2d.js";
|
|
|
13
13
|
* @param {number[]|Float32Array} output result will be written here
|
|
14
14
|
* @param {number} output_offset offset into output array where to write the result
|
|
15
15
|
* @param {number} output_point_count number of points to comprise bounding polygon
|
|
16
|
-
* @param {number[]} input_points Points to be bounded, must be an ordered loop
|
|
16
|
+
* @param {number[]} input_points Points to be bounded, must be an ordered loop. Must form a convex hull
|
|
17
17
|
* @param {number} input_point_count number of points in the input to consider
|
|
18
|
-
* @returns {
|
|
18
|
+
* @returns {number} number of points added to the output
|
|
19
19
|
*
|
|
20
20
|
* @see 2014 "Implementation of linear minimum area enclosing triangle algorithm" Ovidiu Pârvu & David Gilbert
|
|
21
21
|
* @see https://github.com/MagnusTiberius/humus3/blob/9d43412d6e6be869e224817f0a966fe48a1af40f/Util/ConvexHull.cpp#L281
|
|
@@ -24,9 +24,11 @@ export function fixed_convex_hull_humus(
|
|
|
24
24
|
output, output_offset, output_point_count,
|
|
25
25
|
input_points, input_point_count
|
|
26
26
|
) {
|
|
27
|
+
|
|
27
28
|
if (output_point_count >= input_point_count) {
|
|
28
29
|
// special case, input polygon is smaller or equal to in cardinality to what's desired
|
|
29
30
|
array_copy(input_points, 0, output, output_offset, input_point_count * 2);
|
|
31
|
+
|
|
30
32
|
return input_point_count;
|
|
31
33
|
}
|
|
32
34
|
|
|
@@ -61,6 +63,7 @@ export function fixed_convex_hull_humus(
|
|
|
61
63
|
combos++;
|
|
62
64
|
|
|
63
65
|
for (let i = 0; i < k; i++) {
|
|
66
|
+
// pick point indices to represent a line
|
|
64
67
|
const i0 = subset[i];
|
|
65
68
|
const i1 = subset[(i + 1) % k];
|
|
66
69
|
|
|
@@ -143,7 +146,11 @@ export function fixed_convex_hull_humus(
|
|
|
143
146
|
process_combination(s);
|
|
144
147
|
}
|
|
145
148
|
|
|
146
|
-
console.log(`combinations: ${combos}, valid: ${combos_valid} (${(combos_valid * 100 / combos).toFixed(2)}%)`);
|
|
149
|
+
// console.log(`combinations: ${combos}, valid: ${combos_valid} (${(combos_valid * 100 / combos).toFixed(2)}%)`);
|
|
150
|
+
if(combos_valid === 0){
|
|
151
|
+
// no valid combinations
|
|
152
|
+
return 0;
|
|
153
|
+
}
|
|
147
154
|
|
|
148
|
-
return
|
|
155
|
+
return output_point_count;
|
|
149
156
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { array_copy } from "../../../collection/array/array_copy.js";
|
|
2
2
|
import { Uint32Heap } from "../../../collection/heap/Uint32Heap.js";
|
|
3
3
|
import { intersect_ray_2d } from "../intersect_ray_2d.js";
|
|
4
|
-
import {
|
|
4
|
+
import { triangle2d_compute_area } from "../triangle2d_compute_area.js";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
const v2_temp = new Float32Array(2);
|
|
@@ -158,7 +158,7 @@ function compute_collapse_cost(edge, vertex_buffer) {
|
|
|
158
158
|
const v1x = vertex_buffer[edge.v1 * 2];
|
|
159
159
|
const v1y = vertex_buffer[edge.v1 * 2 + 1];
|
|
160
160
|
|
|
161
|
-
const area =
|
|
161
|
+
const area = triangle2d_compute_area(
|
|
162
162
|
v0x, v0y, v2_temp[0], v2_temp[1], v1x, v1y
|
|
163
163
|
);
|
|
164
164
|
|