@luma.gl/graph 10.0.0-beta.2 → 10.0.0-beta.4
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/dist/arrow/gpu/arrow-gpu-analytics-adapters.cjs +22 -9
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts +11 -2
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js +27 -10
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.cjs +24 -13
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts +9 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js +41 -14
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.cjs +82 -23
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts +16 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js +98 -24
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.cjs +7 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts +2 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.js +14 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.js.map +1 -1
- package/dist/arrow/index.cjs +2 -0
- package/dist/arrow/index.cjs.map +3 -3
- package/dist/arrow/index.d.ts +1 -1
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js +1 -1
- package/dist/arrow/index.js.map +1 -1
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.cjs +1 -2
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.js +2 -2
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.js.map +1 -1
- package/dist/dist.dev.js +62 -27
- package/dist/dist.min.js +48 -47
- package/dist/gpu-core/gpu-bvh-bounds.cjs +63 -0
- package/dist/gpu-core/gpu-bvh-bounds.d.ts +32 -0
- package/dist/gpu-core/gpu-bvh-bounds.d.ts.map +1 -0
- package/dist/gpu-core/gpu-bvh-bounds.js +56 -0
- package/dist/gpu-core/gpu-bvh-bounds.js.map +1 -0
- package/dist/gpu-core/gpu-command-graph-budget-controller.cjs +10 -2
- package/dist/gpu-core/gpu-command-graph-budget-controller.d.ts +4 -0
- package/dist/gpu-core/gpu-command-graph-budget-controller.d.ts.map +1 -1
- package/dist/gpu-core/gpu-command-graph-budget-controller.js +10 -2
- package/dist/gpu-core/gpu-command-graph-budget-controller.js.map +1 -1
- package/dist/gpu-core/gpu-command-graph-submission-pacer.cjs +92 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.d.ts +41 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.d.ts.map +1 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.js +85 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.js.map +1 -0
- package/dist/gpu-core/gpu-group-aggregation.cjs +45 -21
- package/dist/gpu-core/gpu-group-aggregation.d.ts +4 -0
- package/dist/gpu-core/gpu-group-aggregation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-group-aggregation.js +58 -24
- package/dist/gpu-core/gpu-group-aggregation.js.map +1 -1
- package/dist/gpu-core/index.cjs +6 -0
- package/dist/gpu-core/index.cjs.map +3 -3
- package/dist/gpu-core/index.d.ts +4 -0
- package/dist/gpu-core/index.d.ts.map +1 -1
- package/dist/gpu-core/index.js +2 -0
- package/dist/gpu-core/index.js.map +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.cjs +6 -6
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js +6 -6
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.cjs +55 -14
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts +13 -2
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.js +58 -17
- package/dist/gpu-dataframe/gpu-data-frame-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.cjs +1 -3
- package/dist/gpu-dataframe/gpu-data-frame.d.ts +10 -0
- package/dist/gpu-dataframe/gpu-data-frame.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.js +1 -3
- package/dist/gpu-dataframe/gpu-data-frame.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.cjs +94 -44
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts +8 -5
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.js +110 -47
- package/dist/gpu-dataframe/gpu-expression-shader.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.cjs +14 -8
- package/dist/gpu-dataframe/gpu-expression.d.ts +12 -1
- package/dist/gpu-dataframe/gpu-expression.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.js +11 -6
- package/dist/gpu-dataframe/gpu-expression.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.cjs +8 -4
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts +2 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js +10 -4
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.cjs +2 -2
- package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts +5 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js +6 -2
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.cjs +156 -124
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts +12 -2
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js +160 -128
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.cjs +366 -53
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts +26 -4
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js +378 -47
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.cjs +20 -9
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts +15 -2
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.js +22 -8
- package/dist/gpu-dataframe/gpu-group-by-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.cjs +61 -8
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts +10 -2
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.js +60 -7
- package/dist/gpu-dataframe/gpu-join-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.cjs +61 -11
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts +5 -1
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.js +61 -10
- package/dist/gpu-dataframe/gpu-query-compiler.js.map +1 -1
- package/dist/gpu-dataframe/index.cjs +4 -2
- package/dist/gpu-dataframe/index.cjs.map +3 -3
- package/dist/gpu-dataframe/index.d.ts +1 -1
- package/dist/gpu-dataframe/index.d.ts.map +1 -1
- package/dist/gpu-dataframe/index.js +1 -1
- package/dist/gpu-dataframe/index.js.map +1 -1
- package/dist/gpu-graph/index.cjs.map +1 -1
- package/dist/gpu-graph-algorithms/benchmarks.cjs.map +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.cjs +182 -62
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.d.ts +29 -2
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.d.ts.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.js +200 -64
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.cjs +135 -9
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.d.ts +55 -8
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.d.ts.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.js +145 -14
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.js.map +1 -1
- package/dist/gpu-graph-algorithms/index.cjs.map +3 -3
- package/dist/gpu-physics/articulation-tree-shader.cjs +177 -0
- package/dist/gpu-physics/articulation-tree-shader.d.ts +3 -0
- package/dist/gpu-physics/articulation-tree-shader.d.ts.map +1 -0
- package/dist/gpu-physics/articulation-tree-shader.js +159 -0
- package/dist/gpu-physics/articulation-tree-shader.js.map +1 -0
- package/dist/gpu-physics/gpu-articulation-tree.cjs +203 -0
- package/dist/gpu-physics/gpu-articulation-tree.d.ts +81 -0
- package/dist/gpu-physics/gpu-articulation-tree.d.ts.map +1 -0
- package/dist/gpu-physics/gpu-articulation-tree.js +205 -0
- package/dist/gpu-physics/gpu-articulation-tree.js.map +1 -0
- package/dist/gpu-physics/gpu-physics-batch.cjs +11 -10
- package/dist/gpu-physics/gpu-physics-batch.d.ts +1 -0
- package/dist/gpu-physics/gpu-physics-batch.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-batch.js +14 -10
- package/dist/gpu-physics/gpu-physics-batch.js.map +1 -1
- package/dist/gpu-physics/gpu-physics-ensemble.cjs +9 -4
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts +10 -1
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-ensemble.js +11 -4
- package/dist/gpu-physics/gpu-physics-ensemble.js.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.cjs +323 -68
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts +59 -2
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js +400 -75
- package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
- package/dist/gpu-physics/index.cjs +3 -0
- package/dist/gpu-physics/index.cjs.map +3 -3
- package/dist/gpu-physics/index.d.ts +3 -1
- package/dist/gpu-physics/index.d.ts.map +1 -1
- package/dist/gpu-physics/index.js +1 -0
- package/dist/gpu-physics/index.js.map +1 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.cjs +10 -6
- package/dist/gpu-physics/rigid-body-cache-shaders.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.js +15 -6
- package/dist/gpu-physics/rigid-body-cache-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-capacity.cjs +15 -2
- package/dist/gpu-physics/rigid-body-capacity.d.ts +3 -1
- package/dist/gpu-physics/rigid-body-capacity.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-capacity.js +21 -2
- package/dist/gpu-physics/rigid-body-capacity.js.map +1 -1
- package/dist/gpu-physics/rigid-body-cast-index.cjs +192 -0
- package/dist/gpu-physics/rigid-body-cast-index.d.ts +44 -0
- package/dist/gpu-physics/rigid-body-cast-index.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-cast-index.js +194 -0
- package/dist/gpu-physics/rigid-body-cast-index.js.map +1 -0
- package/dist/gpu-physics/rigid-body-ensemble-layout.cjs +4 -2
- package/dist/gpu-physics/rigid-body-ensemble-layout.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-ensemble-layout.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-layout.js +5 -2
- package/dist/gpu-physics/rigid-body-ensemble-layout.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.cjs +11 -9
- package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.js +13 -9
- package/dist/gpu-physics/rigid-body-ensemble-reset.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-shaders.cjs +14 -7
- package/dist/gpu-physics/rigid-body-ensemble-shaders.d.ts +5 -0
- package/dist/gpu-physics/rigid-body-ensemble-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-shaders.js +17 -7
- package/dist/gpu-physics/rigid-body-ensemble-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.cjs +21 -11
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts +2 -2
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js +28 -12
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js.map +1 -1
- package/dist/gpu-physics/rigid-body-event-compaction.cjs +184 -0
- package/dist/gpu-physics/rigid-body-event-compaction.d.ts +35 -0
- package/dist/gpu-physics/rigid-body-event-compaction.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-event-compaction.js +168 -0
- package/dist/gpu-physics/rigid-body-event-compaction.js.map +1 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.cjs +51 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.d.ts +33 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.js +34 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.js.map +1 -0
- package/dist/gpu-physics/rigid-body-events.cjs +57 -25
- package/dist/gpu-physics/rigid-body-events.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-events.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-events.js +60 -25
- package/dist/gpu-physics/rigid-body-events.js.map +1 -1
- package/dist/gpu-physics/rigid-body-joints.cjs +8 -3
- package/dist/gpu-physics/rigid-body-joints.d.ts +2 -0
- package/dist/gpu-physics/rigid-body-joints.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-joints.js +10 -6
- package/dist/gpu-physics/rigid-body-joints.js.map +1 -1
- package/dist/gpu-physics/rigid-body-queries.cjs +159 -16
- package/dist/gpu-physics/rigid-body-queries.d.ts +24 -1
- package/dist/gpu-physics/rigid-body-queries.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-queries.js +166 -14
- package/dist/gpu-physics/rigid-body-queries.js.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.cjs +3 -3
- package/dist/gpu-physics/rigid-body-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.js +3 -3
- package/dist/gpu-physics/rigid-body-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-triggers.cjs +53 -15
- package/dist/gpu-physics/rigid-body-triggers.d.ts +1 -0
- package/dist/gpu-physics/rigid-body-triggers.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-triggers.js +55 -15
- package/dist/gpu-physics/rigid-body-triggers.js.map +1 -1
- package/dist/gpu-physics/sphere-world-shaders.cjs +48 -20
- package/dist/gpu-physics/sphere-world-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/sphere-world-shaders.js +51 -21
- package/dist/gpu-physics/sphere-world-shaders.js.map +1 -1
- package/dist/gpu-project/benchmarks.cjs.map +2 -2
- package/dist/gpu-project/crs.cjs.map +2 -2
- package/dist/gpu-project/graph.cjs.map +2 -2
- package/dist/gpu-project/index.cjs.map +2 -2
- package/dist/gpu-project/projection-program.cjs +2 -9
- package/dist/gpu-project/projection-program.d.ts.map +1 -1
- package/dist/gpu-project/projection-program.js +1 -8
- package/dist/gpu-project/projection-program.js.map +1 -1
- package/dist/gpu-simple-graph/index.cjs.map +2 -2
- package/dist/gpu-sql/gpu-sql.cjs +345 -81
- package/dist/gpu-sql/gpu-sql.d.ts +42 -2
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
- package/dist/gpu-sql/gpu-sql.js +393 -90
- package/dist/gpu-sql/gpu-sql.js.map +1 -1
- package/dist/gpu-sql/index.cjs.map +3 -3
- package/dist/gpu-sql/index.d.ts +1 -1
- package/dist/gpu-sql/index.d.ts.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/utils/float32.cjs +35 -0
- package/dist/utils/float32.d.ts +3 -0
- package/dist/utils/float32.d.ts.map +1 -0
- package/dist/utils/float32.js +16 -0
- package/dist/utils/float32.js.map +1 -0
- package/package.json +8 -8
- package/src/arrow/gpu/arrow-gpu-analytics-adapters.ts +77 -25
- package/src/arrow/gpu/arrow-gpu-analytics-readback.ts +52 -16
- package/src/arrow/gpu/arrow-gpu-table-conversion.ts +130 -31
- package/src/arrow/gpu/arrow-gpu-vector-conversion.ts +19 -0
- package/src/arrow/index.ts +1 -0
- package/src/arrow/vectors/arrow-temporal-gpu-vector.ts +2 -2
- package/src/gpu-core/gpu-bvh-bounds.ts +84 -0
- package/src/gpu-core/gpu-command-graph-budget-controller.ts +22 -2
- package/src/gpu-core/gpu-command-graph-submission-pacer.ts +102 -0
- package/src/gpu-core/gpu-group-aggregation.ts +68 -30
- package/src/gpu-core/index.ts +5 -0
- package/src/gpu-dataframe/gpu-analytics-compiler-utils.ts +7 -10
- package/src/gpu-dataframe/gpu-data-frame-query.ts +106 -25
- package/src/gpu-dataframe/gpu-data-frame.ts +35 -2
- package/src/gpu-dataframe/gpu-expression-shader.ts +172 -58
- package/src/gpu-dataframe/gpu-expression.ts +62 -9
- package/src/gpu-dataframe/gpu-global-aggregation-compiler.ts +15 -4
- package/src/gpu-dataframe/gpu-global-aggregation-query.ts +12 -3
- package/src/gpu-dataframe/gpu-global-sort-compiler.ts +231 -156
- package/src/gpu-dataframe/gpu-group-aggregation-compiler.ts +645 -61
- package/src/gpu-dataframe/gpu-group-by-query.ts +51 -14
- package/src/gpu-dataframe/gpu-join-compiler.ts +87 -6
- package/src/gpu-dataframe/gpu-query-compiler.ts +100 -18
- package/src/gpu-dataframe/index.ts +1 -1
- package/src/gpu-graph-algorithms/README.md +4 -2
- package/src/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.ts +248 -66
- package/src/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.ts +218 -20
- package/src/gpu-physics/articulation-tree-shader.ts +169 -0
- package/src/gpu-physics/gpu-articulation-tree.ts +279 -0
- package/src/gpu-physics/gpu-physics-batch.ts +19 -13
- package/src/gpu-physics/gpu-physics-ensemble.ts +20 -4
- package/src/gpu-physics/gpu-rigid-body-world.ts +510 -93
- package/src/gpu-physics/index.ts +16 -0
- package/src/gpu-physics/rigid-body-cache-shaders.ts +18 -6
- package/src/gpu-physics/rigid-body-capacity.ts +25 -4
- package/src/gpu-physics/rigid-body-cast-index.ts +277 -0
- package/src/gpu-physics/rigid-body-ensemble-layout.ts +6 -2
- package/src/gpu-physics/rigid-body-ensemble-reset.ts +21 -9
- package/src/gpu-physics/rigid-body-ensemble-shaders.ts +18 -7
- package/src/gpu-physics/rigid-body-ensemble-transaction.ts +31 -13
- package/src/gpu-physics/rigid-body-event-compaction.ts +252 -0
- package/src/gpu-physics/rigid-body-event-snapshot.ts +76 -0
- package/src/gpu-physics/rigid-body-events.ts +63 -25
- package/src/gpu-physics/rigid-body-joints.ts +11 -11
- package/src/gpu-physics/rigid-body-queries.ts +202 -14
- package/src/gpu-physics/rigid-body-shaders.ts +4 -3
- package/src/gpu-physics/rigid-body-triggers.ts +64 -20
- package/src/gpu-physics/sphere-world-shaders.ts +53 -21
- package/src/gpu-project/projection-program.ts +1 -9
- package/src/gpu-sql/gpu-sql.ts +629 -124
- package/src/gpu-sql/index.ts +1 -1
- package/src/utils/float32.ts +16 -0
|
@@ -3,14 +3,26 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuGraph.
|
|
5
5
|
|
|
6
|
-
import type
|
|
6
|
+
import {Buffer, type Device} from '@luma.gl/core';
|
|
7
7
|
import {DynamicBuffer} from '@luma.gl/core/dynamic';
|
|
8
8
|
import type {GPUData, GPUVector} from '@luma.gl/graph/gpu-data';
|
|
9
|
-
import type
|
|
10
|
-
import {
|
|
9
|
+
import {GPUCommandGraph, type CompiledGPUCommandGraph} from '../gpu-core/gpu-command-graph';
|
|
10
|
+
import {
|
|
11
|
+
type GPUGraphAlgorithmsShortestPathPersistentState,
|
|
12
|
+
SHORTEST_PATH_CONTROL_BYTE_LENGTH,
|
|
13
|
+
SHORTEST_PATH_CONTROL_CONVERGED,
|
|
14
|
+
SHORTEST_PATH_CONTROL_DISPATCH_X,
|
|
15
|
+
SHORTEST_PATH_CONTROL_ITERATIONS,
|
|
16
|
+
addGPUGraphAlgorithmsShortestPathInitializationToGraph,
|
|
17
|
+
addGPUGraphAlgorithmsShortestPathRoundsToGraph,
|
|
18
|
+
addGPUGraphAlgorithmsSingleSourceShortestPathToGraphWithDispatchLimit
|
|
19
|
+
} from './gpu-graph-single-source-shortest-path-internals';
|
|
11
20
|
import type {GPUGraphAlgorithmsAdjacency, GPUGraphAlgorithmsTopology} from './gpu-graph-topology';
|
|
12
21
|
|
|
13
|
-
|
|
22
|
+
/** Most relaxation rounds that one command graph encodes. */
|
|
23
|
+
const MAXIMUM_ENCODED_ITERATIONS = 1024;
|
|
24
|
+
const MAXIMUM_UINT32 = 0xffffffff;
|
|
25
|
+
const DEFAULT_ITERATIONS_PER_SUBMIT = 128;
|
|
14
26
|
const SCALAR_BYTE_LENGTH = 4;
|
|
15
27
|
|
|
16
28
|
/** Forward, reverse, or combined orientation for weighted shortest-path exploration. */
|
|
@@ -22,13 +34,14 @@ export type GPUGraphAlgorithmsSingleSourceShortestPathProps = {
|
|
|
22
34
|
id?: string;
|
|
23
35
|
/** Existing GPU-resident compressed adjacency and its explicit overflow status. */
|
|
24
36
|
topology: GPUGraphAlgorithmsTopology;
|
|
25
|
-
/** Stable source vertex identifier; zero is also accepted for an empty graph. */
|
|
26
|
-
sourceVertex: number;
|
|
27
37
|
/** One caller-owned floating-point distance for every graph vertex. */
|
|
28
38
|
distances: GPUVector<'float32'>;
|
|
29
39
|
/** One caller-owned unsigned predecessor identifier for every graph vertex. */
|
|
30
40
|
predecessors: GPUVector<'uint32'>;
|
|
31
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Maximum relaxation rounds, a uint32. Defaults to `vertexCount - 1`, which is enough for every
|
|
43
|
+
* simple path. `addToGraph()` encodes at most 1,024 of them; `run()` continues to this budget.
|
|
44
|
+
*/
|
|
32
45
|
maxIterations?: number;
|
|
33
46
|
/** Forward, reverse, or combined edge orientation. Defaults to outgoing. */
|
|
34
47
|
direction?: GPUGraphAlgorithmsSingleSourceShortestPathDirection;
|
|
@@ -36,6 +49,33 @@ export type GPUGraphAlgorithmsSingleSourceShortestPathProps = {
|
|
|
36
49
|
converged?: GPUVector<'uint32'>;
|
|
37
50
|
/** Optional caller-owned scalar receiving invalid, valid-endpoint source-edge weights. */
|
|
38
51
|
invalidWeightCount?: GPUVector<'uint32'>;
|
|
52
|
+
/**
|
|
53
|
+
* Stable source vertex identifier; zero is also accepted for an empty graph. Give exactly one
|
|
54
|
+
* of `sourceVertex` and `seeds`.
|
|
55
|
+
*/
|
|
56
|
+
sourceVertex?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Caller-owned source vertex identifiers in one packed chunk, read when the GPU work runs.
|
|
59
|
+
* Await {@link GPUGraphAlgorithmsSingleSourceShortestPath.run} before writing new identifiers.
|
|
60
|
+
* Every seed starts at distance zero. Identifiers outside the graph are ignored.
|
|
61
|
+
*/
|
|
62
|
+
seeds?: GPUVector<'uint32'>;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** Options for {@link GPUGraphAlgorithmsSingleSourceShortestPath.run}. */
|
|
66
|
+
export type GPUGraphAlgorithmsSingleSourceShortestPathRunOptions = {
|
|
67
|
+
/** Relaxation rounds encoded per submission, between 1 and 1,024. Default 128. */
|
|
68
|
+
iterationsPerSubmit?: number;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/** Status of one {@link GPUGraphAlgorithmsSingleSourceShortestPath.run}. */
|
|
72
|
+
export type GPUGraphAlgorithmsSingleSourceShortestPathRunResult = {
|
|
73
|
+
/** Whether every distance is final. */
|
|
74
|
+
converged: boolean;
|
|
75
|
+
/** Relaxation rounds that ran, including the last round, which found no shorter distance. */
|
|
76
|
+
iterations: number;
|
|
77
|
+
/** Command buffers submitted, each followed by one status readback. */
|
|
78
|
+
submissions: number;
|
|
39
79
|
};
|
|
40
80
|
|
|
41
81
|
/**
|
|
@@ -51,13 +91,15 @@ export class GPUGraphAlgorithmsSingleSourceShortestPath {
|
|
|
51
91
|
readonly id: string;
|
|
52
92
|
/** Existing caller-owned graph topology. */
|
|
53
93
|
readonly topology: GPUGraphAlgorithmsTopology;
|
|
54
|
-
/** Stable source vertex identifier
|
|
55
|
-
readonly sourceVertex
|
|
94
|
+
/** Stable source vertex identifier, when the source is not read from `seeds`. */
|
|
95
|
+
readonly sourceVertex?: number;
|
|
96
|
+
/** Caller-owned source vertex identifiers. Await {@link run} before writing to the buffer. */
|
|
97
|
+
readonly seeds?: GPUVector<'uint32'>;
|
|
56
98
|
/** Caller-owned, vertex-aligned weighted distance column. */
|
|
57
99
|
readonly distances: GPUVector<'float32'>;
|
|
58
100
|
/** Caller-owned, vertex-aligned deterministic predecessor column. */
|
|
59
101
|
readonly predecessors: GPUVector<'uint32'>;
|
|
60
|
-
/** Maximum
|
|
102
|
+
/** Maximum Bellman-Ford relaxation rounds. */
|
|
61
103
|
readonly maxIterations: number;
|
|
62
104
|
/** Selected graph edge orientation. */
|
|
63
105
|
readonly direction: GPUGraphAlgorithmsSingleSourceShortestPathDirection;
|
|
@@ -66,28 +108,38 @@ export class GPUGraphAlgorithmsSingleSourceShortestPath {
|
|
|
66
108
|
/** Optional caller-owned invalid-source-edge-weight count scalar. */
|
|
67
109
|
readonly invalidWeightCount?: GPUVector<'uint32'>;
|
|
68
110
|
|
|
111
|
+
private _runner?: ShortestPathRunner;
|
|
112
|
+
/** Whether a run owns the runner and its outputs. */
|
|
113
|
+
private _running = false;
|
|
114
|
+
|
|
69
115
|
/** Validates caller-owned metadata without allocating, submitting, or reading GPU work. */
|
|
70
116
|
constructor(props: GPUGraphAlgorithmsSingleSourceShortestPathProps) {
|
|
71
117
|
this.id = props.id ?? 'gpu-graph-single-source-shortest-path';
|
|
72
118
|
this.topology = props.topology;
|
|
73
119
|
this.sourceVertex = props.sourceVertex;
|
|
120
|
+
this.seeds = props.seeds;
|
|
74
121
|
this.distances = props.distances;
|
|
75
122
|
this.predecessors = props.predecessors;
|
|
76
|
-
this.maxIterations =
|
|
77
|
-
props.maxIterations ??
|
|
78
|
-
Math.min(Math.max(this.topology.graph.vertexCount - 1, 0), MAXIMUM_SHORTEST_PATH_ITERATIONS);
|
|
123
|
+
this.maxIterations = props.maxIterations ?? Math.max(this.topology.graph.vertexCount - 1, 0);
|
|
79
124
|
this.direction = props.direction ?? 'outgoing';
|
|
80
125
|
this.converged = props.converged;
|
|
81
126
|
this.invalidWeightCount = props.invalidWeightCount;
|
|
82
127
|
|
|
128
|
+
if ((this.sourceVertex === undefined) === (this.seeds === undefined)) {
|
|
129
|
+
throw new Error(`${this.id} requires exactly one of sourceVertex and seeds`);
|
|
130
|
+
}
|
|
83
131
|
const maximumSourceVertex = Math.max(this.topology.graph.vertexCount - 1, 0);
|
|
84
132
|
if (
|
|
85
|
-
|
|
86
|
-
this.sourceVertex
|
|
87
|
-
|
|
133
|
+
this.sourceVertex !== undefined &&
|
|
134
|
+
(!Number.isSafeInteger(this.sourceVertex) ||
|
|
135
|
+
this.sourceVertex < 0 ||
|
|
136
|
+
this.sourceVertex > maximumSourceVertex)
|
|
88
137
|
) {
|
|
89
138
|
throw new Error(`${this.id} sourceVertex must identify an existing graph vertex`);
|
|
90
139
|
}
|
|
140
|
+
if (this.seeds) {
|
|
141
|
+
validateSeedVector(this.seeds, `${this.id} seeds`);
|
|
142
|
+
}
|
|
91
143
|
if (!['outgoing', 'incoming', 'both'].includes(this.direction)) {
|
|
92
144
|
throw new Error(`${this.id} direction must be outgoing, incoming, or both`);
|
|
93
145
|
}
|
|
@@ -99,9 +151,9 @@ export class GPUGraphAlgorithmsSingleSourceShortestPath {
|
|
|
99
151
|
if (
|
|
100
152
|
!Number.isSafeInteger(this.maxIterations) ||
|
|
101
153
|
this.maxIterations < 0 ||
|
|
102
|
-
this.maxIterations >
|
|
154
|
+
this.maxIterations > MAXIMUM_UINT32
|
|
103
155
|
) {
|
|
104
|
-
throw new Error(`${this.id} maxIterations must be
|
|
156
|
+
throw new Error(`${this.id} maxIterations must be an integer between zero and 2^32 - 1`);
|
|
105
157
|
}
|
|
106
158
|
|
|
107
159
|
validateShortestPathVector(
|
|
@@ -130,16 +182,159 @@ export class GPUGraphAlgorithmsSingleSourceShortestPath {
|
|
|
130
182
|
validateDistinctShortestPathOutputs(this);
|
|
131
183
|
}
|
|
132
184
|
|
|
133
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* Adds initialization and up to 1,024 relaxation rounds without submitting or reading back.
|
|
187
|
+
*
|
|
188
|
+
* Every round is GPU-gated: once the search converges or exhausts `maxIterations`, later rounds
|
|
189
|
+
* dispatch zero workgroups. Use {@link run} when the search can need more than 1,024 rounds.
|
|
190
|
+
*/
|
|
134
191
|
addToGraph<Parameters>(commandGraph: GPUCommandGraph<Parameters>): void {
|
|
135
192
|
addGPUGraphAlgorithmsSingleSourceShortestPathToGraphWithDispatchLimit(
|
|
136
193
|
this,
|
|
137
194
|
commandGraph,
|
|
138
|
-
commandGraph.device.limits.maxComputeWorkgroupsPerDimension
|
|
195
|
+
commandGraph.device.limits.maxComputeWorkgroupsPerDimension,
|
|
196
|
+
Math.min(this.maxIterations, MAXIMUM_ENCODED_ITERATIONS)
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Runs the search to convergence or to `maxIterations`, in batches of GPU-gated rounds.
|
|
202
|
+
*
|
|
203
|
+
* Each submission encodes `iterationsPerSubmit` rounds and reads back one 32-byte status.
|
|
204
|
+
* Runs with the same batch size reuse the compiled command graphs. Build the topology first.
|
|
205
|
+
* An overlapping call rejects. Await the current run before writing to {@link seeds} or calling
|
|
206
|
+
* {@link destroy}.
|
|
207
|
+
*/
|
|
208
|
+
async run(
|
|
209
|
+
options: GPUGraphAlgorithmsSingleSourceShortestPathRunOptions = {}
|
|
210
|
+
): Promise<GPUGraphAlgorithmsSingleSourceShortestPathRunResult> {
|
|
211
|
+
if (this._running) {
|
|
212
|
+
throw new Error(`${this.id} is already running. Await run() before starting another run.`);
|
|
213
|
+
}
|
|
214
|
+
const iterationsPerSubmit = options.iterationsPerSubmit ?? DEFAULT_ITERATIONS_PER_SUBMIT;
|
|
215
|
+
if (
|
|
216
|
+
!Number.isSafeInteger(iterationsPerSubmit) ||
|
|
217
|
+
iterationsPerSubmit < 1 ||
|
|
218
|
+
iterationsPerSubmit > MAXIMUM_ENCODED_ITERATIONS
|
|
219
|
+
) {
|
|
220
|
+
throw new Error(`${this.id} iterationsPerSubmit must be an integer between 1 and 1024`);
|
|
221
|
+
}
|
|
222
|
+
this._running = true;
|
|
223
|
+
try {
|
|
224
|
+
if (this._runner?.iterationsPerSubmit !== iterationsPerSubmit) {
|
|
225
|
+
this._runner?.destroy();
|
|
226
|
+
this._runner = undefined;
|
|
227
|
+
this._runner = createShortestPathRunner(this, iterationsPerSubmit);
|
|
228
|
+
}
|
|
229
|
+
const runner = this._runner;
|
|
230
|
+
const {device} = runner;
|
|
231
|
+
|
|
232
|
+
let submissions = 0;
|
|
233
|
+
let status: Uint32Array;
|
|
234
|
+
let encoder = device.createCommandEncoder({id: `${this.id}-run`});
|
|
235
|
+
runner.initialization.encode(encoder, {parameters: undefined});
|
|
236
|
+
for (;;) {
|
|
237
|
+
runner.rounds.encode(encoder, {parameters: undefined});
|
|
238
|
+
device.submit(encoder.finish());
|
|
239
|
+
submissions++;
|
|
240
|
+
status = await readControl(runner.control);
|
|
241
|
+
if (status[SHORTEST_PATH_CONTROL_DISPATCH_X] === 0) {
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
encoder = device.createCommandEncoder({id: `${this.id}-run`});
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
converged: status[SHORTEST_PATH_CONTROL_CONVERGED] === 1,
|
|
248
|
+
iterations: status[SHORTEST_PATH_CONTROL_ITERATIONS],
|
|
249
|
+
submissions
|
|
250
|
+
};
|
|
251
|
+
} finally {
|
|
252
|
+
this._running = false;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/** Releases the command graphs and status buffers. Await {@link run} before calling this method. */
|
|
257
|
+
destroy(): void {
|
|
258
|
+
this._runner?.destroy();
|
|
259
|
+
this._runner = undefined;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
type ShortestPathRunner = {
|
|
264
|
+
device: Device;
|
|
265
|
+
iterationsPerSubmit: number;
|
|
266
|
+
control: Buffer;
|
|
267
|
+
initialization: CompiledGPUCommandGraph;
|
|
268
|
+
rounds: CompiledGPUCommandGraph;
|
|
269
|
+
destroy: () => void;
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
/** Compiles the reusable initialization and round-batch command graphs for {@link run}. */
|
|
273
|
+
function createShortestPathRunner(
|
|
274
|
+
search: GPUGraphAlgorithmsSingleSourceShortestPath,
|
|
275
|
+
iterationsPerSubmit: number
|
|
276
|
+
): ShortestPathRunner {
|
|
277
|
+
const device = getPhysicalBuffer(search.distances.data[0]).device;
|
|
278
|
+
const maxComputeWorkgroupsPerDimension = device.limits.maxComputeWorkgroupsPerDimension;
|
|
279
|
+
const control = device.createBuffer({
|
|
280
|
+
id: `${search.id}-control`,
|
|
281
|
+
byteLength: SHORTEST_PATH_CONTROL_BYTE_LENGTH,
|
|
282
|
+
usage: Buffer.STORAGE | Buffer.INDIRECT | Buffer.COPY_SRC
|
|
283
|
+
});
|
|
284
|
+
const persistent: GPUGraphAlgorithmsShortestPathPersistentState = {control};
|
|
285
|
+
const compiled: CompiledGPUCommandGraph[] = [];
|
|
286
|
+
const destroy = () => {
|
|
287
|
+
for (const graph of compiled) graph.destroy();
|
|
288
|
+
control.destroy();
|
|
289
|
+
};
|
|
290
|
+
try {
|
|
291
|
+
const initializationGraph = new GPUCommandGraph(device, {id: `${search.id}-initialization`});
|
|
292
|
+
addGPUGraphAlgorithmsShortestPathInitializationToGraph(
|
|
293
|
+
search,
|
|
294
|
+
initializationGraph,
|
|
295
|
+
maxComputeWorkgroupsPerDimension,
|
|
296
|
+
persistent
|
|
139
297
|
);
|
|
298
|
+
const initialization = initializationGraph.compile();
|
|
299
|
+
compiled.push(initialization);
|
|
300
|
+
const roundsGraph = new GPUCommandGraph(device, {id: `${search.id}-rounds`});
|
|
301
|
+
addGPUGraphAlgorithmsShortestPathRoundsToGraph(
|
|
302
|
+
search,
|
|
303
|
+
roundsGraph,
|
|
304
|
+
maxComputeWorkgroupsPerDimension,
|
|
305
|
+
iterationsPerSubmit,
|
|
306
|
+
persistent
|
|
307
|
+
);
|
|
308
|
+
const rounds = roundsGraph.compile();
|
|
309
|
+
compiled.push(rounds);
|
|
310
|
+
return {
|
|
311
|
+
device,
|
|
312
|
+
iterationsPerSubmit,
|
|
313
|
+
control,
|
|
314
|
+
initialization,
|
|
315
|
+
rounds,
|
|
316
|
+
destroy
|
|
317
|
+
};
|
|
318
|
+
} catch (error) {
|
|
319
|
+
destroy();
|
|
320
|
+
throw error;
|
|
140
321
|
}
|
|
141
322
|
}
|
|
142
323
|
|
|
324
|
+
/** Reads the dispatch command, round count, and convergence status in one transfer. */
|
|
325
|
+
async function readControl(control: Buffer): Promise<Uint32Array> {
|
|
326
|
+
const bytes = await control.readAsync(0, SHORTEST_PATH_CONTROL_BYTE_LENGTH);
|
|
327
|
+
return new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** Requires one packed uint32 chunk with at least one seed. */
|
|
331
|
+
function validateSeedVector(seeds: GPUVector<'uint32'>, name: string): void {
|
|
332
|
+
if (seeds.length < 1 || seeds.length > MAXIMUM_UINT32) {
|
|
333
|
+
throw new Error(`${name} must contain at least one uint32 vertex identifier`);
|
|
334
|
+
}
|
|
335
|
+
validateShortestPathVector(seeds, 'uint32', seeds.length, name);
|
|
336
|
+
}
|
|
337
|
+
|
|
143
338
|
/** Requires exactly one packed, properly aligned caller-owned scalar output chunk. */
|
|
144
339
|
function validateShortestPathVector<Format extends 'uint32' | 'float32'>(
|
|
145
340
|
vector: GPUVector<Format>,
|
|
@@ -197,6 +392,9 @@ function validateDistinctShortestPathOutputs(
|
|
|
197
392
|
}
|
|
198
393
|
}
|
|
199
394
|
|
|
395
|
+
if (search.seeds) {
|
|
396
|
+
physicalAllocations.add(getPhysicalBuffer(search.seeds.data[0]));
|
|
397
|
+
}
|
|
200
398
|
const outputs = [
|
|
201
399
|
{name: 'distances', vector: search.distances},
|
|
202
400
|
{name: 'predecessors', vector: search.predecessors},
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/** Fixed-base joint-space forward dynamics. One invocation owns a whole small tree. */
|
|
6
|
+
export function getArticulationTreeShader(
|
|
7
|
+
count: number,
|
|
8
|
+
contact = false,
|
|
9
|
+
publishMatrices = false
|
|
10
|
+
): string {
|
|
11
|
+
return /* wgsl */ `
|
|
12
|
+
const N = ${count}u;
|
|
13
|
+
struct Link {
|
|
14
|
+
parentAnchor:vec4f, childAnchor:vec4f, axisMass:vec4f, inertia:vec4f, rest:vec4f
|
|
15
|
+
}
|
|
16
|
+
struct Pose { position:vec4f, rotation:vec4f, velocity:vec4f, spin:vec4f }
|
|
17
|
+
struct Settings { base:vec4f, gravityStep:vec4f, boxCenterRadius:vec4f, boxExtentsLink:vec4f }
|
|
18
|
+
@group(0) @binding(0) var<storage,read> links:array<Link>;
|
|
19
|
+
@group(0) @binding(1) var<storage,read> drives:array<vec4f>;
|
|
20
|
+
@group(0) @binding(2) var<storage,read_write> coordinates:array<vec4f>;
|
|
21
|
+
@group(0) @binding(3) var<storage,read_write> poses:array<Pose>;
|
|
22
|
+
@group(0) @binding(4) var<storage,read_write> counters:array<u32>;
|
|
23
|
+
@group(0) @binding(5) var<uniform> settings:Settings;
|
|
24
|
+
|
|
25
|
+
${publishMatrices ? '@group(0) @binding(6) var<storage,read_write> matrices:array<mat4x4f>;' : ''}
|
|
26
|
+
var<private> angle:array<f32,N>;
|
|
27
|
+
var<private> speed:array<f32,N>;
|
|
28
|
+
var<private> solved:array<Pose,N>;
|
|
29
|
+
var<private> axis:array<vec3f,N>;
|
|
30
|
+
var<private> pivot:array<vec3f,N>;
|
|
31
|
+
var<private> acceleration:array<vec3f,N>;
|
|
32
|
+
var<private> angularAcceleration:array<vec3f,N>;
|
|
33
|
+
fn rotate(q:vec4f,v:vec3f)->vec3f{return v+2.0*cross(q.xyz,cross(q.xyz,v)+q.w*v);}
|
|
34
|
+
fn product(a:vec4f,b:vec4f)->vec4f{return vec4f(a.w*b.xyz+b.w*a.xyz+cross(a.xyz,b.xyz),a.w*b.w-dot(a.xyz,b.xyz));}
|
|
35
|
+
fn inertia(i:u32,v:vec3f)->vec3f{
|
|
36
|
+
let q=solved[i].rotation;
|
|
37
|
+
return rotate(q,links[i].inertia.xyz*rotate(vec4f(-q.xyz,q.w),v));
|
|
38
|
+
}
|
|
39
|
+
// Propagate pose, twist and bias acceleration (joint accelerations held at zero).
|
|
40
|
+
fn kinematics(){
|
|
41
|
+
for(var i=0u;i<N;i++){
|
|
42
|
+
let link=links[i];let parent=i32(link.parentAnchor.w);
|
|
43
|
+
var previous=Pose(vec4f(settings.base.xyz,0),vec4f(0,0,0,1),vec4f(0),vec4f(0));
|
|
44
|
+
var linearBias=vec3f(0);var angularBias=vec3f(0);
|
|
45
|
+
if(parent>=0){previous=solved[parent];linearBias=acceleration[parent];angularBias=angularAcceleration[parent];}
|
|
46
|
+
let offset=rotate(previous.rotation,link.parentAnchor.xyz);
|
|
47
|
+
pivot[i]=previous.position.xyz+offset;
|
|
48
|
+
axis[i]=rotate(previous.rotation,link.axisMass.xyz);
|
|
49
|
+
let halfAngle=0.5*angle[i];
|
|
50
|
+
let rotation=normalize(product(product(previous.rotation,vec4f(link.axisMass.xyz*sin(halfAngle),cos(halfAngle))),link.rest));
|
|
51
|
+
let radius=rotate(rotation,-link.childAnchor.xyz);
|
|
52
|
+
let parentSpin=previous.spin.xyz;
|
|
53
|
+
let spin=parentSpin+axis[i]*speed[i];
|
|
54
|
+
let velocity=previous.velocity.xyz+cross(parentSpin,offset)+cross(spin,radius);
|
|
55
|
+
let pivotBias=linearBias+cross(angularBias,offset)+cross(parentSpin,cross(parentSpin,offset));
|
|
56
|
+
angularAcceleration[i]=angularBias+cross(parentSpin,axis[i]*speed[i]);
|
|
57
|
+
acceleration[i]=pivotBias+cross(angularAcceleration[i],radius)+cross(spin,cross(spin,radius));
|
|
58
|
+
solved[i]=Pose(vec4f(pivot[i]+radius,1),rotation,vec4f(velocity,0),vec4f(spin,0));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
fn finite(v:vec4f)->bool{return all(abs(v)<=vec4f(3.4028234e38));}
|
|
62
|
+
@compute @workgroup_size(1) fn main(){
|
|
63
|
+
if(counters[1]!=0u){return;}
|
|
64
|
+
let dt=settings.gravityStep.w;
|
|
65
|
+
var mass:array<array<f32,N>,N>;var inverse:array<array<f32,N>,N>;
|
|
66
|
+
var force:array<f32,N>;var impulse:array<f32,N>;
|
|
67
|
+
for(var i=0u;i<N;i++){
|
|
68
|
+
angle[i]=coordinates[i].x;speed[i]=coordinates[i].y;inverse[i][i]=1;
|
|
69
|
+
// A fixed link contributes its mass to ancestors and has no generalized motion.
|
|
70
|
+
if(dot(links[i].axisMass.xyz,links[i].axisMass.xyz)==0){mass[i][i]=1;}
|
|
71
|
+
}
|
|
72
|
+
kinematics();
|
|
73
|
+
for(var body=0u;body<N;body++){
|
|
74
|
+
let center=solved[body].position.xyz;let spin=solved[body].spin.xyz;
|
|
75
|
+
let load=links[body].axisMass.w*(settings.gravityStep.xyz-acceleration[body]);
|
|
76
|
+
let moment= -inertia(body,angularAcceleration[body])-cross(spin,inertia(body,spin));
|
|
77
|
+
for(var row=i32(body);row>=0;row=i32(links[row].parentAnchor.w)){
|
|
78
|
+
let linear=cross(axis[row],center-pivot[row]);
|
|
79
|
+
force[row]+=dot(linear,load)+dot(axis[row],moment);
|
|
80
|
+
let angularMass=inertia(body,axis[row]);
|
|
81
|
+
for(var column=i32(body);column>=0;column=i32(links[column].parentAnchor.w)){
|
|
82
|
+
mass[row][column]+=links[body].axisMass.w*dot(linear,cross(axis[column],center-pivot[column]))+dot(angularMass,axis[column]);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Positive definite joint inertia admits elimination without pivoting.
|
|
87
|
+
for(var k=0u;k<N;k++){
|
|
88
|
+
let diagonal=mass[k][k];if(!(diagonal>0)){counters[1]=1u;return;}
|
|
89
|
+
for(var j=0u;j<N;j++){mass[k][j]/=diagonal;inverse[k][j]/=diagonal;}
|
|
90
|
+
for(var i=0u;i<N;i++){if(i!=k){
|
|
91
|
+
let factor=mass[i][k];
|
|
92
|
+
for(var j=0u;j<N;j++){mass[i][j]-=factor*mass[k][j];inverse[i][j]-=factor*inverse[k][j];}
|
|
93
|
+
}}
|
|
94
|
+
}
|
|
95
|
+
for(var i=0u;i<N;i++){for(var j=0u;j<N;j++){speed[i]+=dt*inverse[i][j]*force[j];}}
|
|
96
|
+
${
|
|
97
|
+
contact
|
|
98
|
+
? `// Closest point on a finite AABB. Inside, use the nearest exit face.
|
|
99
|
+
let body=u32(settings.boxExtentsLink.w);
|
|
100
|
+
let center=solved[body].position.xyz;
|
|
101
|
+
let local=center-settings.boxCenterRadius.xyz;
|
|
102
|
+
let extent=settings.boxExtentsLink.xyz;
|
|
103
|
+
let outside=local-clamp(local,-extent,extent);
|
|
104
|
+
let distance=length(outside);
|
|
105
|
+
var normal=vec3f(0);
|
|
106
|
+
var gap=distance-settings.boxCenterRadius.w;
|
|
107
|
+
if(distance>0.0){normal=outside/distance;}else{
|
|
108
|
+
let depth=extent-abs(local);var face=0u;
|
|
109
|
+
if(depth.y<depth.x){face=1u;}if(depth.z<depth[face]){face=2u;}
|
|
110
|
+
normal[face]=select(-1.0,1.0,local[face]>=0.0);
|
|
111
|
+
gap= -depth[face]-settings.boxCenterRadius.w;
|
|
112
|
+
}
|
|
113
|
+
var jacobian:array<f32,N>;var response:array<f32,N>;
|
|
114
|
+
for(var joint=i32(body);joint>=0;joint=i32(links[joint].parentAnchor.w)){
|
|
115
|
+
jacobian[joint]=dot(normal,cross(axis[joint],center-pivot[joint]));
|
|
116
|
+
}
|
|
117
|
+
var inverseContactMass=0.0;
|
|
118
|
+
for(var row=0u;row<N;row++){
|
|
119
|
+
for(var column=0u;column<N;column++){response[row]+=inverse[row][column]*jacobian[column];}
|
|
120
|
+
inverseContactMass+=jacobian[row]*response[row];
|
|
121
|
+
}
|
|
122
|
+
// Speculate across the remaining gap; correct existing overlap gradually.
|
|
123
|
+
let separationSpeed=select(-gap/dt,min(2.0,0.2*max(0.0,-gap-0.0001)/dt),gap<0.0);
|
|
124
|
+
var normalImpulse=0.0;`
|
|
125
|
+
: ''
|
|
126
|
+
}
|
|
127
|
+
// Implicit spring/damper impulses in coupled joint space. Project each update
|
|
128
|
+
// onto its torque budget and propagate the resulting velocity change to all axes.
|
|
129
|
+
for(var sweep=0u;sweep<64u;sweep++){
|
|
130
|
+
var change=0.0;
|
|
131
|
+
for(var i=0u;i<N;i++){
|
|
132
|
+
let drive=drives[i];let resistance=dt*(drive.z+dt*drive.y);
|
|
133
|
+
let residual=dt*drive.y*(drive.x-angle[i])-resistance*speed[i]-impulse[i];
|
|
134
|
+
let next=clamp(impulse[i]+residual/(1.0+resistance*inverse[i][i]),-dt*drive.w,dt*drive.w);
|
|
135
|
+
let delta=next-impulse[i];impulse[i]=next;change=max(change,abs(delta));
|
|
136
|
+
for(var j=0u;j<N;j++){speed[j]+=inverse[j][i]*delta;}
|
|
137
|
+
}
|
|
138
|
+
${
|
|
139
|
+
contact
|
|
140
|
+
? `if(inverseContactMass>1e-9){
|
|
141
|
+
var normalSpeed=0.0;
|
|
142
|
+
for(var j=0u;j<N;j++){normalSpeed+=jacobian[j]*speed[j];}
|
|
143
|
+
let next=max(0.0,normalImpulse+(separationSpeed-normalSpeed)/inverseContactMass);
|
|
144
|
+
let delta=next-normalImpulse;normalImpulse=next;change=max(change,abs(delta));
|
|
145
|
+
for(var j=0u;j<N;j++){speed[j]+=response[j]*delta;}
|
|
146
|
+
}`
|
|
147
|
+
: ''
|
|
148
|
+
}
|
|
149
|
+
if(change<1e-7){break;}
|
|
150
|
+
}
|
|
151
|
+
for(var i=0u;i<N;i++){angle[i]+=dt*speed[i];}
|
|
152
|
+
kinematics();
|
|
153
|
+
for(var i=0u;i<N;i++){let pose=solved[i];
|
|
154
|
+
if(!finite(vec4f(angle[i],speed[i],impulse[i]/dt,0))||!finite(pose.position)||!finite(pose.rotation)||!finite(pose.velocity)||!finite(pose.spin)){counters[1]=1u;return;}
|
|
155
|
+
}
|
|
156
|
+
for(var i=0u;i<N;i++){coordinates[i]=vec4f(angle[i],speed[i],impulse[i]/dt,0);poses[i]=solved[i];}
|
|
157
|
+
${contact ? 'counters[2]=bitcast<u32>(normalImpulse/dt);' : ''}
|
|
158
|
+
${
|
|
159
|
+
publishMatrices
|
|
160
|
+
? `for(var i=0u;i<N;i++){
|
|
161
|
+
let pose=solved[i];let q=pose.rotation;
|
|
162
|
+
matrices[i]=mat4x4f(vec4f(rotate(q,vec3f(1,0,0)),0),vec4f(rotate(q,vec3f(0,1,0)),0),vec4f(rotate(q,vec3f(0,0,1)),0),pose.position);
|
|
163
|
+
}`
|
|
164
|
+
: ''
|
|
165
|
+
}
|
|
166
|
+
counters[0]++;
|
|
167
|
+
}
|
|
168
|
+
`;
|
|
169
|
+
}
|