@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
|
@@ -45,7 +45,10 @@ var import_rigid_body_publication = require("./rigid-body-publication.cjs");
|
|
|
45
45
|
var import_rigid_body_shaders = require("./rigid-body-shaders.cjs");
|
|
46
46
|
var import_rigid_body_vehicle = require("./rigid-body-vehicle.cjs");
|
|
47
47
|
var import_rigid_body_events = require("./rigid-body-events.cjs");
|
|
48
|
+
var import_rigid_body_event_compaction = require("./rigid-body-event-compaction.cjs");
|
|
49
|
+
var import_rigid_body_event_snapshot = require("./rigid-body-event-snapshot.cjs");
|
|
48
50
|
var import_rigid_body_queries = require("./rigid-body-queries.cjs");
|
|
51
|
+
var import_rigid_body_cast_index = require("./rigid-body-cast-index.cjs");
|
|
49
52
|
class GPURigidBodyWorld {
|
|
50
53
|
worldOrigin = [0, 0, 0];
|
|
51
54
|
id;
|
|
@@ -67,6 +70,14 @@ class GPURigidBodyWorld {
|
|
|
67
70
|
sleepStates = null;
|
|
68
71
|
/** World-owned GPU event ring; present only when eventCapacity is positive. */
|
|
69
72
|
contactEvents = null;
|
|
73
|
+
/** Trigger history and authored group IDs remain stable until world destruction. */
|
|
74
|
+
triggerHistory = null;
|
|
75
|
+
/** Contact activity is recorded in pair-slot order after accepted steps. */
|
|
76
|
+
contactHistory = null;
|
|
77
|
+
/** A recovery read shares the incremental trigger cursor. */
|
|
78
|
+
triggerSnapshotRead = null;
|
|
79
|
+
/** A recovery read shares the incremental contact cursor. */
|
|
80
|
+
contactSnapshotRead = null;
|
|
70
81
|
triggerEvents = null;
|
|
71
82
|
triggerCursor = 0;
|
|
72
83
|
triggerRead = null;
|
|
@@ -74,6 +85,18 @@ class GPURigidBodyWorld {
|
|
|
74
85
|
eventRead = null;
|
|
75
86
|
queryComputation = null;
|
|
76
87
|
queryReduction = null;
|
|
88
|
+
/** Batched nearest-hit computation using the current world pose buffers. */
|
|
89
|
+
batchCast = null;
|
|
90
|
+
/** Compiled query graph that refits the world BVH and then casts. */
|
|
91
|
+
batchCastIndex = null;
|
|
92
|
+
/** Initial spatial order and stable collider ID mapping for indexed batches. */
|
|
93
|
+
batchCastOrder = null;
|
|
94
|
+
/** Query graph reservation before attachment, when the physical plan is unavailable. */
|
|
95
|
+
batchCastIndexEstimate;
|
|
96
|
+
/** Reusable storage for a bounded list of ray and sweep commands. */
|
|
97
|
+
batchCastCommands = null;
|
|
98
|
+
/** Reusable GPU output with one compact result per batch command. */
|
|
99
|
+
batchCastResults = null;
|
|
77
100
|
/** Chassis definitions in GPU storage order. */
|
|
78
101
|
vehicles;
|
|
79
102
|
/** Whether any chassis has more than one terrain candidate. */
|
|
@@ -122,6 +145,9 @@ class GPURigidBodyWorld {
|
|
|
122
145
|
broadPhaseCounters = null;
|
|
123
146
|
constructor(props) {
|
|
124
147
|
var _a, _b, _c, _d, _e, _f;
|
|
148
|
+
const queryBatchCapacity = props.queryBatchCapacity ?? 0;
|
|
149
|
+
if (!Number.isSafeInteger(queryBatchCapacity) || queryBatchCapacity < 0 || queryBatchCapacity > 65535 || queryBatchCapacity > 0 && !props.enableQueries || props.queryBatchIndex && queryBatchCapacity === 0)
|
|
150
|
+
throw new Error("Invalid collision cast batch capacity");
|
|
125
151
|
for (const damping of [props.linearDamping ?? 0, props.angularDamping ?? 0]) {
|
|
126
152
|
if (!Number.isFinite(damping) || damping < 0)
|
|
127
153
|
throw new Error("Invalid damping");
|
|
@@ -228,6 +254,9 @@ class GPURigidBodyWorld {
|
|
|
228
254
|
this.maximumPairs = this.broadPhase === "all-pairs" ? this.colliderStorageCount * this.colliderStorageCount : props.maximumPairs ?? 2 ** Math.ceil(Math.log2(Math.max(64, this.colliderStorageCount * 16)));
|
|
229
255
|
if (!["all-pairs", "hierarchical-grid"].includes(this.broadPhase) || !Number.isSafeInteger(this.maximumPairs) || this.maximumPairs < 1 || this.maximumPairs > 1073741824 || this.broadPhase === "hierarchical-grid" && (this.maximumPairs & this.maximumPairs - 1) !== 0)
|
|
230
256
|
throw new Error("Invalid rigid-body pair capacity");
|
|
257
|
+
const instancePairCapacity = props.ensemblePairsPerInstance;
|
|
258
|
+
if (instancePairCapacity !== void 0 && (!props.ensembleBodiesPerInstance || props.failurePolicy !== "rollback" || !Number.isSafeInteger(instancePairCapacity) || instancePairCapacity < 1 || instancePairCapacity * (this.count / props.ensembleBodiesPerInstance) > this.maximumPairs || (instancePairCapacity & instancePairCapacity - 1) !== 0))
|
|
259
|
+
throw new Error("Invalid ensemble instance contact capacity");
|
|
231
260
|
if (props.continuous) {
|
|
232
261
|
if (props.failurePolicy !== "rollback" || !Number.isInteger(props.continuous.maximumImpacts ?? 4) || (props.continuous.maximumImpacts ?? 4) < 1 || (props.continuous.maximumImpacts ?? 4) > 16 || !["sphere-static", "convex"].includes(props.continuous.mode ?? "sphere-static") || !Number.isSafeInteger(props.continuous.maximumCandidates ?? this.maximumPairs) || (props.continuous.maximumCandidates ?? this.maximumPairs) < 1 || (props.continuous.maximumCandidates ?? this.maximumPairs) > 1073741824 || props.continuous.mode === "convex" && (Boolean((_d = props.joints) == null ? void 0 : _d.length) || colliders.some((collider) => ["plane", "triangle-mesh", "height-field"].includes(collider.shape.type))))
|
|
233
262
|
throw new Error("Invalid continuous settings");
|
|
@@ -246,6 +275,7 @@ class GPURigidBodyWorld {
|
|
|
246
275
|
const definitions = structuredClone({ colliders, props });
|
|
247
276
|
this.props = definitions.props;
|
|
248
277
|
this.colliders = definitions.colliders;
|
|
278
|
+
this.batchCastIndexEstimate = this.props.queryBatchIndex && this.colliderCount ? (0, import_rigid_body_cast_index.estimateRigidBodyCastIndexBytes)(this.colliders.filter(import_rigid_body_cast_index.canIndexRigidBodyCastCollider).length) : 0;
|
|
249
279
|
this.ensembleTerrainSlots = new Set(this.props.ensembleTerrainSlots);
|
|
250
280
|
if (this.ensembleTerrainSlots.size && (!this.props.ensembleBodiesPerInstance || [...this.ensembleTerrainSlots].some((index) => {
|
|
251
281
|
var _a2;
|
|
@@ -317,7 +347,7 @@ class GPURigidBodyWorld {
|
|
|
317
347
|
sparse,
|
|
318
348
|
extended,
|
|
319
349
|
parallel,
|
|
320
|
-
...(0, import_rigid_body_capacity.getRigidBodyStorageLayout)(this.count, this.colliderStorageCount, this.maximumPairs, geometryWords, sparse, extended, parallel, this.props.eventCapacity ?? 0, this.props.enableQueries ?? false, this.props.failurePolicy === "rollback", Boolean(this.props.continuous), ((_b = this.props.joints) == null ? void 0 : _b.length) ?? 0, this.props.ensembleBodiesPerInstance ? this.count / this.props.ensembleBodiesPerInstance : 0)
|
|
350
|
+
...(0, import_rigid_body_capacity.getRigidBodyStorageLayout)(this.count, this.colliderStorageCount, this.maximumPairs, geometryWords, sparse, extended, parallel, this.props.eventCapacity ?? 0, this.props.enableQueries ?? false, this.props.failurePolicy === "rollback", Boolean(this.props.continuous), ((_b = this.props.joints) == null ? void 0 : _b.length) ?? 0, this.props.ensembleBodiesPerInstance ? this.count / this.props.ensembleBodiesPerInstance : 0, Boolean(this.props.ensemblePairsPerInstance), this.props.queryBatchCapacity)
|
|
321
351
|
};
|
|
322
352
|
if (this.vehicles.length) {
|
|
323
353
|
const byteLength = this.getVehicleByteLength();
|
|
@@ -374,7 +404,7 @@ class GPURigidBodyWorld {
|
|
|
374
404
|
if (!this.device || !this.ensembleBuffer || this.destroyed)
|
|
375
405
|
throw new Error("World has no ensemble scheduler");
|
|
376
406
|
this.ensembleResetOrigin ??= this.origin;
|
|
377
|
-
this.ensembleReset ??= (0, import_rigid_body_ensemble_reset.makeEnsembleReset)(this.device, this.id, this.ownedBuffers, this.count, this.props.ensembleBodiesPerInstance, this.props.collisionPartitionSize, this.maximumPairs, this.vehiclesPerInstance, this.ensembleTerrainSlots);
|
|
407
|
+
this.ensembleReset ??= (0, import_rigid_body_ensemble_reset.makeEnsembleReset)(this.device, this.id, this.ownedBuffers, this.count, this.props.ensembleBodiesPerInstance, this.props.collisionPartitionSize, this.maximumPairs, this.vehiclesPerInstance, this.ensembleTerrainSlots, this.props.ensemblePairsPerInstance);
|
|
378
408
|
return this.ensembleReset.byteLength;
|
|
379
409
|
}
|
|
380
410
|
resetEnsembleInstance(instance) {
|
|
@@ -415,7 +445,7 @@ class GPURigidBodyWorld {
|
|
|
415
445
|
metadata.write(new Float32Array((collider.position ?? [0, 0, 0]).map((value, axis) => value - center[axis])), this.count * 48 + index * 96 + 16);
|
|
416
446
|
}
|
|
417
447
|
this.ensembleReset.reset(instance, this.origin.map((value, axis) => value - this.ensembleResetOrigin[axis]));
|
|
418
|
-
this.ensembleBuffer.write(new Uint32Array([0, 0, 0, 0, 1, 1]), (16 + instance * 8 + 1) * 4);
|
|
448
|
+
this.ensembleBuffer.write(new Uint32Array([0, 0, 0, 0, 1, 1, 0]), (16 + instance * 8 + 1) * 4);
|
|
419
449
|
if (this.encodePosePublication) {
|
|
420
450
|
const encoder = this.device.createCommandEncoder();
|
|
421
451
|
this.encodePosePublication(encoder);
|
|
@@ -470,8 +500,9 @@ class GPURigidBodyWorld {
|
|
|
470
500
|
if (!this.ensembleBuffer || this.destroyed || !Number.isSafeInteger(instance) || instance < 0 || instance >= this.count / this.props.ensembleBodiesPerInstance)
|
|
471
501
|
throw new Error("Invalid ensemble instance");
|
|
472
502
|
}
|
|
473
|
-
/**
|
|
503
|
+
/** World buffer sizes and private query scratch. Simulation graph scratch and driver overhead are separate. */
|
|
474
504
|
getCapacityInfo() {
|
|
505
|
+
var _a;
|
|
475
506
|
const buffers = this.allocationPlan ? this.allocationPlan.map((buffer) => ({ ...buffer })) : this.getStorageLayout().buffers;
|
|
476
507
|
return {
|
|
477
508
|
bodyCount: this.count,
|
|
@@ -479,6 +510,7 @@ class GPURigidBodyWorld {
|
|
|
479
510
|
maximumPairs: this.maximumPairs,
|
|
480
511
|
pairWorkgroups: Math.ceil(this.maximumPairs / 64),
|
|
481
512
|
buffers,
|
|
513
|
+
queryIndexScratchBytes: ((_a = this.batchCastIndex) == null ? void 0 : _a.stats.physicalTransientResourceBytes) ?? this.batchCastIndexEstimate,
|
|
482
514
|
ownedBufferBytes: buffers.reduce((total, buffer) => total + buffer.byteLength, 0)
|
|
483
515
|
};
|
|
484
516
|
}
|
|
@@ -498,6 +530,8 @@ class GPURigidBodyWorld {
|
|
|
498
530
|
if (buffer.byteLength > Math.min(graph.device.limits.maxBufferSize, bindingLimit))
|
|
499
531
|
throw new Error(`Rigid-body ${buffer.name} storage exceeds device limits`);
|
|
500
532
|
}
|
|
533
|
+
if ((this.props.queryBatchCapacity ?? 0) > graph.device.limits.maxComputeWorkgroupsPerDimension)
|
|
534
|
+
throw new Error("Collision cast batch exceeds device dispatch limits");
|
|
501
535
|
this.allocationPlan = allocationPlan;
|
|
502
536
|
this.device = graph.device;
|
|
503
537
|
const allocate = (name, data, uniform = false) => {
|
|
@@ -614,7 +648,7 @@ class GPURigidBodyWorld {
|
|
|
614
648
|
this.velocities = allocate("velocities", velocities);
|
|
615
649
|
this.angularVelocities = allocate("angular-velocities", angular);
|
|
616
650
|
this.sleepStates = allocate("sleep", this.count * 16);
|
|
617
|
-
this.targets = allocate("targets", this.props.ensembleBodiesPerInstance ? (0, import_rigid_body_ensemble_layout.getEnsembleContactLayout)(this.count, this.count / this.props.ensembleBodiesPerInstance, this.maximumPairs).byteLength : Math.ceil((this.count * 32 + (sparse ? 32 + this.maximumPairs * 8 : 16)) / 16) * 16 + (((_c = this.props.joints) == null ? void 0 : _c.length) ?? 0) * import_rigid_body_joints.RIGID_BODY_JOINT_STATE_BYTES);
|
|
651
|
+
this.targets = allocate("targets", this.props.ensembleBodiesPerInstance ? (0, import_rigid_body_ensemble_layout.getEnsembleContactLayout)(this.count, this.count / this.props.ensembleBodiesPerInstance, this.maximumPairs, Boolean(this.props.ensemblePairsPerInstance)).byteLength : Math.ceil((this.count * 32 + (sparse ? 32 + this.maximumPairs * 8 : 16)) / 16) * 16 + (((_c = this.props.joints) == null ? void 0 : _c.length) ?? 0) * import_rigid_body_joints.RIGID_BODY_JOINT_STATE_BYTES);
|
|
618
652
|
for (const [index, joint] of (this.props.joints ?? []).entries()) {
|
|
619
653
|
this.targets.write((0, import_rigid_body_joints.packRigidBodyJointState)(joint), this.getJointStateOffset() + index * import_rigid_body_joints.RIGID_BODY_JOINT_STATE_BYTES);
|
|
620
654
|
}
|
|
@@ -701,7 +735,7 @@ class GPURigidBodyWorld {
|
|
|
701
735
|
byteLength: objectAttributes.byteLength,
|
|
702
736
|
usage: import_core.Buffer.STORAGE
|
|
703
737
|
}, objectAttributes), { format: "uint32", length: this.colliderStorageCount }) : void 0;
|
|
704
|
-
const source = (0, import_rigid_body_shaders.getRigidBodyShader)(this.count, this.props.iterations ?? 16, this.colliderStorageCount, extended, sparseLayout, parallel, this.props.maximumMeshTraversalTestsPerPair ?? 65536, (0, import_rigid_body_joints.getRigidBodyJointShader)(this.props.joints ?? [], this.props.bodies), Boolean((_d = this.props.joints) == null ? void 0 : _d.length), this.props.linearDamping ?? 0, this.props.angularDamping ?? 0, ((_e = this.props.joints) == null ? void 0 : _e.length) ?? 0, this.props.compactContacts ?? true, this.props.collisionPartitionSize, this.props.ensembleBodiesPerInstance, this.props.parallelContactSolver === "block", this.colliders.some((collider) => collider.shape.type === "height-field"));
|
|
738
|
+
const source = (0, import_rigid_body_shaders.getRigidBodyShader)(this.count, this.props.iterations ?? 16, this.colliderStorageCount, extended, sparseLayout, parallel, this.props.maximumMeshTraversalTestsPerPair ?? 65536, (0, import_rigid_body_joints.getRigidBodyJointShader)(this.props.joints ?? [], this.props.bodies), Boolean((_d = this.props.joints) == null ? void 0 : _d.length), this.props.linearDamping ?? 0, this.props.angularDamping ?? 0, ((_e = this.props.joints) == null ? void 0 : _e.length) ?? 0, this.props.compactContacts ?? true, this.props.collisionPartitionSize, this.props.ensembleBodiesPerInstance, this.props.parallelContactSolver === "block", this.colliders.some((collider) => collider.shape.type === "height-field"), this.props.ensemblePairsPerInstance);
|
|
705
739
|
const parallelBindings = {
|
|
706
740
|
parallelReset: ["parallelState"],
|
|
707
741
|
parallelResetCounters: ["parallelState"],
|
|
@@ -782,6 +816,8 @@ class GPURigidBodyWorld {
|
|
|
782
816
|
location: 18
|
|
783
817
|
}, allocate, Boolean((_i = this.props.joints) == null ? void 0 : _i.length), extended) : void 0;
|
|
784
818
|
this.triggerEvents = (triggers == null ? void 0 : triggers.events) ?? null;
|
|
819
|
+
if (triggers && triggerLayout)
|
|
820
|
+
this.triggerHistory = { buffer: triggers.history, groups: triggerLayout.groups };
|
|
785
821
|
const passDescriptions = {
|
|
786
822
|
integrate: "Apply gravity and advance body velocities and predicted poses for this timestep.",
|
|
787
823
|
prepare: "Reset broad-phase counters before generating potential collider pairs.",
|
|
@@ -936,7 +972,7 @@ class GPURigidBodyWorld {
|
|
|
936
972
|
const restoreCheckpoint = this.props.failurePolicy === "rollback" ? this.ensembleBuffer ? (0, import_rigid_body_ensemble_transaction.addEnsembleCheckpoint)(graph, this.id, checkpointStates, { buffer: this.simulationStatistics, resource: statisticsResource }, bindings.find((binding) => binding.name === "ensemble"), bindings.find((binding) => binding.name === "manifolds"), this.props.ensembleBodiesPerInstance, this.maximumPairs, allocate, vehicleResource && {
|
|
937
973
|
state: vehicleResource,
|
|
938
974
|
vehiclesPerInstance: this.vehiclesPerInstance
|
|
939
|
-
}) : (0, import_rigid_body_transaction.addRigidBodyCheckpoint)(graph, this.id, [
|
|
975
|
+
}, this.props.ensemblePairsPerInstance) : (0, import_rigid_body_transaction.addRigidBodyCheckpoint)(graph, this.id, [
|
|
940
976
|
...checkpointStates,
|
|
941
977
|
bindings.find((binding) => binding.name === "manifolds"),
|
|
942
978
|
...vehicleResource ? [vehicleResource] : []
|
|
@@ -1248,7 +1284,10 @@ class GPURigidBodyWorld {
|
|
|
1248
1284
|
});
|
|
1249
1285
|
restoreCheckpoint == null ? void 0 : restoreCheckpoint.restore();
|
|
1250
1286
|
if (this.ensembleBuffer)
|
|
1251
|
-
(0, import_rigid_body_ensemble_shaders.addEnsembleStatus)(graph, this.id, this.count / this.props.ensembleBodiesPerInstance, this.props.ensembleBodiesPerInstance, diagnosticBinding("bodies"), diagnosticBinding("sleepStates"), diagnosticBinding("ensemble"), { buffer: this.simulationStatistics, resource: statisticsResource }
|
|
1287
|
+
(0, import_rigid_body_ensemble_shaders.addEnsembleStatus)(graph, this.id, this.count / this.props.ensembleBodiesPerInstance, this.props.ensembleBodiesPerInstance, diagnosticBinding("bodies"), diagnosticBinding("sleepStates"), diagnosticBinding("ensemble"), { buffer: this.simulationStatistics, resource: statisticsResource }, this.props.ensemblePairsPerInstance ? {
|
|
1288
|
+
...diagnosticBinding("targets"),
|
|
1289
|
+
wordOffset: (0, import_rigid_body_ensemble_layout.getEnsembleContactLayout)(this.count, this.count / this.props.ensembleBodiesPerInstance, this.maximumPairs, true).failureOffset
|
|
1290
|
+
} : void 0);
|
|
1252
1291
|
triggers == null ? void 0 : triggers.publish();
|
|
1253
1292
|
if (this.props.publicationBounds || this.props.publishPoses) {
|
|
1254
1293
|
const publication = (0, import_rigid_body_publication.addRigidBodyPosePublication)(graph, this.id, this.props.bodies, this.props.publicationBounds ?? this.props.bodies.map(() => [
|
|
@@ -1261,6 +1300,7 @@ class GPURigidBodyWorld {
|
|
|
1261
1300
|
}
|
|
1262
1301
|
if (this.props.eventCapacity) {
|
|
1263
1302
|
const contactHistory = allocate("contact-history", this.maximumPairs * 16);
|
|
1303
|
+
this.contactHistory = contactHistory;
|
|
1264
1304
|
this.contactEvents = allocate("contact-events", 16 + this.props.eventCapacity * 64);
|
|
1265
1305
|
const eventBindings = [
|
|
1266
1306
|
...bindings.filter((binding) => ["bodies", "manifolds", "ensemble"].includes(binding.name)),
|
|
@@ -1284,35 +1324,21 @@ class GPURigidBodyWorld {
|
|
|
1284
1324
|
}, binding.buffer)
|
|
1285
1325
|
}))
|
|
1286
1326
|
];
|
|
1287
|
-
const
|
|
1327
|
+
const contactResources = eventBindings.map(({ name, resource, location }) => ({
|
|
1328
|
+
name,
|
|
1329
|
+
resource,
|
|
1330
|
+
location,
|
|
1331
|
+
readOnly: name === "bodies" || name === "eventStatistics"
|
|
1332
|
+
}));
|
|
1333
|
+
(0, import_rigid_body_event_compaction.addRigidBodyEventCompaction)(graph, {
|
|
1288
1334
|
id: `${this.id}-contact-events`,
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
type: ["bodies", "eventStatistics"].includes(name) ? "read-only-storage" : "storage"
|
|
1297
|
-
}))
|
|
1298
|
-
}
|
|
1299
|
-
};
|
|
1300
|
-
const executable = (computation) => ({
|
|
1301
|
-
encode: ({ computePass, getBuffer }) => {
|
|
1302
|
-
Object.assign(computation.bindings, Object.fromEntries(eventBindings.map((binding) => [binding.name, getBuffer(binding.resource)])));
|
|
1303
|
-
computation.kernel.dispatch(computePass, { bindings: computation.bindings, x: 1 });
|
|
1304
|
-
},
|
|
1305
|
-
destroy: () => computation.kernel.destroy()
|
|
1306
|
-
});
|
|
1307
|
-
graph.addComputePass({
|
|
1308
|
-
id: properties.id,
|
|
1309
|
-
description: "Compare contact history and publish contact begin, persist, and end events.",
|
|
1310
|
-
resources: eventBindings.map((binding) => ({
|
|
1311
|
-
buffer: binding.resource,
|
|
1312
|
-
usage: ["bodies", "eventStatistics"].includes(binding.name) ? "storage-read" : "storage-read-write"
|
|
1313
|
-
})),
|
|
1314
|
-
compile: () => executable((0, import_bound_kernel.createBoundKernel)(graph.device, properties)),
|
|
1315
|
-
compileAsync: async () => executable(await (0, import_bound_kernel.createBoundKernelAsync)(graph.device, properties))
|
|
1335
|
+
rowCount: this.maximumPairs,
|
|
1336
|
+
capacity: this.props.eventCapacity,
|
|
1337
|
+
ring: "contactEvents",
|
|
1338
|
+
source: source + (0, import_rigid_body_events.getRigidBodyEventShader)(this.props.eventCapacity, this.props.impactImpulseThreshold ?? 1, this.props.failurePolicy === "rollback", this.props.ensemblePairsPerInstance),
|
|
1339
|
+
classify: contactResources.filter((binding) => !["bodies", "contactEvents"].includes(binding.name)),
|
|
1340
|
+
commit: contactResources.filter((binding) => ["eventStatistics", "contactEvents"].includes(binding.name)),
|
|
1341
|
+
publish: contactResources.filter((binding) => !["eventStatistics", "ensemble"].includes(binding.name))
|
|
1316
1342
|
});
|
|
1317
1343
|
}
|
|
1318
1344
|
if (this.props.enableQueries) {
|
|
@@ -1353,6 +1379,43 @@ class GPURigidBodyWorld {
|
|
|
1353
1379
|
queryOutput: this.queryOutput
|
|
1354
1380
|
}
|
|
1355
1381
|
});
|
|
1382
|
+
if (this.props.queryBatchCapacity) {
|
|
1383
|
+
const capacity = this.props.queryBatchCapacity;
|
|
1384
|
+
this.batchCastCommands = allocate("query-batch-commands", capacity * import_rigid_body_queries.RIGID_BODY_CAST_COMMAND_BYTES);
|
|
1385
|
+
this.batchCastResults = allocate("query-batch-results", capacity * import_rigid_body_queries.RIGID_BODY_BATCH_RESULT_BYTES);
|
|
1386
|
+
const batchBindings = {
|
|
1387
|
+
positions: this.positions,
|
|
1388
|
+
orientations: this.orientations,
|
|
1389
|
+
bodies,
|
|
1390
|
+
querySelection: this.querySelection,
|
|
1391
|
+
batchCommands: this.batchCastCommands,
|
|
1392
|
+
batchResults: this.batchCastResults
|
|
1393
|
+
};
|
|
1394
|
+
const batchLayout = [
|
|
1395
|
+
...queryProperties.shaderLayout.bindings.filter((binding) => ["positions", "orientations", "bodies", "querySelection"].includes(binding.name)),
|
|
1396
|
+
{ name: "batchCommands", group: 0, location: 30, type: "read-only-storage" },
|
|
1397
|
+
{ name: "batchResults", group: 0, location: 31, type: "storage" }
|
|
1398
|
+
];
|
|
1399
|
+
this.batchCast = (0, import_bound_kernel.createBoundKernel)(graph.device, {
|
|
1400
|
+
id: `${this.id}-batched-casts`,
|
|
1401
|
+
entryPoint: "castBatch",
|
|
1402
|
+
source: queryProperties.source + (0, import_rigid_body_queries.getRigidBodyBatchCastShader)(),
|
|
1403
|
+
shaderLayout: { bindings: batchLayout },
|
|
1404
|
+
bindings: batchBindings
|
|
1405
|
+
});
|
|
1406
|
+
if (this.props.queryBatchIndex && this.colliderCount) {
|
|
1407
|
+
this.batchCastOrder = (0, import_rigid_body_cast_index.getRigidBodyCastOrder)(this.colliders, this.props.bodies);
|
|
1408
|
+
if (this.batchCastOrder.indexedCount) {
|
|
1409
|
+
this.batchCastIndex = (0, import_rigid_body_cast_index.createRigidBodyCastIndex)(graph.device, {
|
|
1410
|
+
id: `${this.id}-cast-index`,
|
|
1411
|
+
source: queryProperties.source,
|
|
1412
|
+
layout: batchLayout,
|
|
1413
|
+
buffers: batchBindings,
|
|
1414
|
+
indexedCount: this.batchCastOrder.indexedCount
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1356
1419
|
}
|
|
1357
1420
|
this.controlSettings = allocate("control-settings", 64, true);
|
|
1358
1421
|
const controlProperties = {
|
|
@@ -1491,7 +1554,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1491
1554
|
}
|
|
1492
1555
|
/** Rebase between submissions, preserving velocities, contact impulses and sleeping state. */
|
|
1493
1556
|
shiftOrigin(shift) {
|
|
1494
|
-
if (!this.device || this.destroyed || this.queryPending || this.
|
|
1557
|
+
if (!this.device || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
1495
1558
|
throw new Error("Origin shifting requires an idle attached world");
|
|
1496
1559
|
if (shift.length !== 3 || shift.some((value) => !Number.isFinite(value) || Math.fround(value) !== value))
|
|
1497
1560
|
throw new Error("Origin shift must be an exactly representable float32 vector");
|
|
@@ -1635,6 +1698,16 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1635
1698
|
metadata.write(data);
|
|
1636
1699
|
this.props.publicationBounds = structuredClone(bounds);
|
|
1637
1700
|
}
|
|
1701
|
+
/** Read the authored collider frame relative to its body's node origin, excluding COM offset. */
|
|
1702
|
+
getColliderTransform(colliderIndex) {
|
|
1703
|
+
const collider = this.colliders[colliderIndex];
|
|
1704
|
+
if (!Number.isInteger(colliderIndex) || !collider || this.destroyed)
|
|
1705
|
+
throw new Error("Invalid collider");
|
|
1706
|
+
return {
|
|
1707
|
+
position: [...collider.position ?? [0, 0, 0]],
|
|
1708
|
+
orientation: (0, import_rigid_body_properties.normalizeRigidBodyRotation)(collider.orientation)
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1638
1711
|
/** Applied scale relative to the initially cooked analytic shape. */
|
|
1639
1712
|
getColliderShapeScale(colliderIndex) {
|
|
1640
1713
|
this.getColliderShape(colliderIndex);
|
|
@@ -1703,7 +1776,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1703
1776
|
if (!edits.length)
|
|
1704
1777
|
return;
|
|
1705
1778
|
const metadata = this.ownedBuffers.find((buffer) => buffer.id === `${this.id}-bodies`);
|
|
1706
|
-
if (!metadata || this.destroyed || this.queryPending || this.
|
|
1779
|
+
if (!metadata || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
1707
1780
|
throw new Error("Terrain streaming requires an idle attached world");
|
|
1708
1781
|
const seen = /* @__PURE__ */ new Set();
|
|
1709
1782
|
const packedFields = this.terrainAtlas ? /* @__PURE__ */ new Map() : void 0;
|
|
@@ -1980,6 +2053,68 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1980
2053
|
throw new Error("Invalid joint");
|
|
1981
2054
|
return structuredClone(joint);
|
|
1982
2055
|
}
|
|
2056
|
+
/** Command a named angular force drive. Angles are radians and maximum torque is N·m. */
|
|
2057
|
+
setAngularActuator(id, axis, command) {
|
|
2058
|
+
const index = this.findAngularActuator(id, axis);
|
|
2059
|
+
const joint = this.props.joints[index];
|
|
2060
|
+
if (joint.type !== "general" || !joint.drive)
|
|
2061
|
+
throw new Error("Expected angular drive");
|
|
2062
|
+
if (command.stiffness === void 0 && command.damping === void 0 && command.maximumTorque === void 0) {
|
|
2063
|
+
this.setAngularDriveTargets(/* @__PURE__ */ new Map([[index, command.angle]]));
|
|
2064
|
+
return;
|
|
2065
|
+
}
|
|
2066
|
+
this.setJointParameters(index, {
|
|
2067
|
+
...joint,
|
|
2068
|
+
drive: {
|
|
2069
|
+
...joint.drive,
|
|
2070
|
+
positionTarget: command.angle,
|
|
2071
|
+
stiffness: command.stiffness ?? joint.drive.stiffness,
|
|
2072
|
+
damping: command.damping ?? joint.drive.damping,
|
|
2073
|
+
maximumForce: command.maximumTorque ?? joint.drive.maximumForce
|
|
2074
|
+
}
|
|
2075
|
+
});
|
|
2076
|
+
}
|
|
2077
|
+
/** Read the signed mean motor torque from the most recently submitted step. */
|
|
2078
|
+
async readAngularActuatorTorque(id, axis) {
|
|
2079
|
+
const index = this.findAngularActuator(id, axis);
|
|
2080
|
+
if (!this.targets || this.destroyed)
|
|
2081
|
+
throw new Error("Inactive world");
|
|
2082
|
+
const bytes = await this.targets.readAsync(this.getJointStateOffset() + index * import_rigid_body_joints.RIGID_BODY_JOINT_STATE_BYTES, 4);
|
|
2083
|
+
return new DataView(bytes.buffer, bytes.byteOffset, 4).getFloat32(0, true) / this.timeStep;
|
|
2084
|
+
}
|
|
2085
|
+
findAngularActuator(id, axis) {
|
|
2086
|
+
const indices = (this.props.joints ?? []).flatMap((joint, index) => joint.id === id && joint.type === "general" && joint.angular && joint.drive && joint.drive.mode !== "acceleration" && joint.axes[0] === axis ? [index] : []);
|
|
2087
|
+
if (indices.length !== 1)
|
|
2088
|
+
throw new Error("Missing or ambiguous angular force drive");
|
|
2089
|
+
return indices[0];
|
|
2090
|
+
}
|
|
2091
|
+
/** Retarget authored angular drive rows between steps while preserving the other joints' settings. */
|
|
2092
|
+
setAngularDriveTargets(targets) {
|
|
2093
|
+
var _a;
|
|
2094
|
+
const joints = [...this.props.joints ?? []];
|
|
2095
|
+
if (!this.targets || !this.sleepStates || this.destroyed)
|
|
2096
|
+
throw new Error("Inactive world");
|
|
2097
|
+
for (const [index, angle] of targets) {
|
|
2098
|
+
const joint = joints[index];
|
|
2099
|
+
if ((joint == null ? void 0 : joint.type) !== "general" || !joint.angular || !joint.drive || !Number.isFinite(Math.fround(angle))) {
|
|
2100
|
+
throw new Error("Invalid angular drive target");
|
|
2101
|
+
}
|
|
2102
|
+
if (Math.fround(joint.drive.positionTarget ?? 0) === Math.fround(angle))
|
|
2103
|
+
continue;
|
|
2104
|
+
joints[index] = { ...joint, drive: { ...joint.drive, positionTarget: angle } };
|
|
2105
|
+
}
|
|
2106
|
+
const drivenBodies = /* @__PURE__ */ new Set();
|
|
2107
|
+
for (const [index, angle] of targets) {
|
|
2108
|
+
if (joints[index] === ((_a = this.props.joints) == null ? void 0 : _a[index]))
|
|
2109
|
+
continue;
|
|
2110
|
+
drivenBodies.add(joints[index].first);
|
|
2111
|
+
drivenBodies.add(joints[index].second);
|
|
2112
|
+
this.targets.write(new Float32Array([angle]), this.getJointStateOffset() + index * import_rigid_body_joints.RIGID_BODY_JOINT_STATE_BYTES + 40 * 4);
|
|
2113
|
+
}
|
|
2114
|
+
this.props.joints = joints;
|
|
2115
|
+
for (const body of drivenBodies)
|
|
2116
|
+
this.sleepStates.write(new Float32Array(2), body * 16);
|
|
2117
|
+
}
|
|
1983
2118
|
/** Update an existing constraint's response without recompiling or changing attachment topology. */
|
|
1984
2119
|
setJointParameters(index, parameters) {
|
|
1985
2120
|
this.setJointParameterEdits([{ index, parameters }]);
|
|
@@ -2038,15 +2173,22 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2038
2173
|
readContactEvents() {
|
|
2039
2174
|
if (!this.contactEvents || this.destroyed)
|
|
2040
2175
|
return Promise.reject(new Error("Contact events are not enabled"));
|
|
2041
|
-
|
|
2042
|
-
|
|
2176
|
+
const afterSnapshot = this.contactSnapshotRead;
|
|
2177
|
+
if (this.eventRead && (!afterSnapshot || this.eventRead.afterSnapshot === afterSnapshot))
|
|
2178
|
+
return this.eventRead.result;
|
|
2179
|
+
const pending = {
|
|
2180
|
+
afterSnapshot,
|
|
2181
|
+
result: this.contactEvents.readAsync().finally(() => afterSnapshot).then((bytes) => {
|
|
2043
2182
|
const batch = (0, import_rigid_body_events.decodeRigidBodyContactEvents)(new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4), this.eventCursor);
|
|
2044
2183
|
this.eventCursor = batch.sequence;
|
|
2045
2184
|
return batch;
|
|
2046
2185
|
}).finally(() => {
|
|
2047
|
-
this.eventRead
|
|
2048
|
-
|
|
2049
|
-
|
|
2186
|
+
if (this.eventRead === pending)
|
|
2187
|
+
this.eventRead = null;
|
|
2188
|
+
})
|
|
2189
|
+
};
|
|
2190
|
+
this.eventRead = pending;
|
|
2191
|
+
return pending.result;
|
|
2050
2192
|
}
|
|
2051
2193
|
/** Nearest exact sphere/OBB hit. Origins inside a shape return distance zero and a zero normal. */
|
|
2052
2194
|
raycast(query) {
|
|
@@ -2056,6 +2198,57 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2056
2198
|
overlapSphere(query) {
|
|
2057
2199
|
return this.runQuery(query);
|
|
2058
2200
|
}
|
|
2201
|
+
/**
|
|
2202
|
+
* Query the closest hit for each ray or sphere cast with one submission and readback.
|
|
2203
|
+
* Results follow input order. This snapshots already submitted poses, using one shared collider selection.
|
|
2204
|
+
*/
|
|
2205
|
+
async castBatch(commands, options = {}) {
|
|
2206
|
+
if (!this.device || !this.batchCast || !this.querySelection || !this.batchCastCommands || !this.batchCastResults || this.destroyed || this.queryPending)
|
|
2207
|
+
throw new Error("Batched collision casts are disabled or busy");
|
|
2208
|
+
if (commands.length > this.props.queryBatchCapacity)
|
|
2209
|
+
throw new Error("Collision cast batch exceeds capacity");
|
|
2210
|
+
if (!commands.length)
|
|
2211
|
+
return [];
|
|
2212
|
+
if (options.strategy === "indexed" && !this.props.queryBatchIndex)
|
|
2213
|
+
throw new Error("Batched collision cast index is disabled");
|
|
2214
|
+
const order = options.strategy === "scan" ? null : this.batchCastOrder;
|
|
2215
|
+
const selection = options.colliderIndices ? Uint32Array.from(new Set(this.validateQueryColliders(options.colliderIndices))) : (order == null ? void 0 : order.indices) ?? Uint32Array.from({ length: this.colliderCount }, (_, index) => index);
|
|
2216
|
+
let indexedCount = (order == null ? void 0 : order.indexedCount) ?? 0;
|
|
2217
|
+
if (order && options.colliderIndices) {
|
|
2218
|
+
selection.sort((first, second) => order.ranks[first] - order.ranks[second]);
|
|
2219
|
+
const firstExtended = selection.findIndex((index) => order.ranks[index] >= order.indexedCount);
|
|
2220
|
+
indexedCount = firstExtended < 0 ? selection.length : firstExtended;
|
|
2221
|
+
}
|
|
2222
|
+
const data = (0, import_rigid_body_queries.packRigidBodyBatchCasts)(commands, this.count, selection.length, indexedCount);
|
|
2223
|
+
this.queryPending = true;
|
|
2224
|
+
try {
|
|
2225
|
+
this.batchCastCommands.write(data);
|
|
2226
|
+
if (selection.length)
|
|
2227
|
+
this.querySelection.write(selection);
|
|
2228
|
+
const encoder = this.device.createCommandEncoder();
|
|
2229
|
+
if (this.batchCastIndex && indexedCount) {
|
|
2230
|
+
this.batchCastIndex.encode(encoder, { parameters: commands.length });
|
|
2231
|
+
} else {
|
|
2232
|
+
const pass = encoder.beginComputePass();
|
|
2233
|
+
this.batchCast.kernel.dispatch(pass, {
|
|
2234
|
+
bindings: this.batchCast.bindings,
|
|
2235
|
+
x: commands.length
|
|
2236
|
+
});
|
|
2237
|
+
pass.end();
|
|
2238
|
+
}
|
|
2239
|
+
this.device.submit(encoder.finish());
|
|
2240
|
+
return (0, import_rigid_body_queries.decodeRigidBodyBatchCasts)(await this.batchCastResults.readAsync(0, commands.length * import_rigid_body_queries.RIGID_BODY_BATCH_RESULT_BYTES));
|
|
2241
|
+
} finally {
|
|
2242
|
+
this.queryPending = false;
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
/** Reject invalid indices before scalar or batch query buffers are written. */
|
|
2246
|
+
validateQueryColliders(indices) {
|
|
2247
|
+
for (const index of indices)
|
|
2248
|
+
if (!Number.isInteger(index) || index < 0 || index >= this.colliderCount)
|
|
2249
|
+
throw new Error("Invalid query collider");
|
|
2250
|
+
return indices;
|
|
2251
|
+
}
|
|
2059
2252
|
async runQuery(query) {
|
|
2060
2253
|
if (!this.device || !this.queryComputation || !this.querySettings || !this.querySelection || !this.queryOutput || this.destroyed || this.queryPending)
|
|
2061
2254
|
throw new Error("Queries are disabled or busy");
|
|
@@ -2069,9 +2262,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2069
2262
|
throw new Error("Invalid collision query");
|
|
2070
2263
|
const selected = query.colliderIndices ?? Array.from({ length: this.colliderCount }, (_, index) => index);
|
|
2071
2264
|
const selection = new Uint32Array(this.colliderStorageCount);
|
|
2072
|
-
for (const index of selected) {
|
|
2073
|
-
if (!Number.isInteger(index) || index < 0 || index >= this.colliderCount)
|
|
2074
|
-
throw new Error("Invalid query collider");
|
|
2265
|
+
for (const index of this.validateQueryColliders(selected)) {
|
|
2075
2266
|
const collider = this.colliders[index];
|
|
2076
2267
|
if (collider.body === query.excludeBody)
|
|
2077
2268
|
continue;
|
|
@@ -2101,16 +2292,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2101
2292
|
const bytes = await this.queryOutput.readAsync(0, 16 + maximumHits * 48);
|
|
2102
2293
|
const words = new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
2103
2294
|
const floats = new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
2104
|
-
const hits = Array.from({ length: words[0] }, (_, index) =>
|
|
2105
|
-
const offset = 4 + index * 12;
|
|
2106
|
-
return {
|
|
2107
|
-
body: words[offset],
|
|
2108
|
-
collider: words[offset + 1],
|
|
2109
|
-
point: [floats[offset + 4], floats[offset + 5], floats[offset + 6]],
|
|
2110
|
-
distance: floats[offset + 7],
|
|
2111
|
-
normal: [floats[offset + 8], floats[offset + 9], floats[offset + 10]]
|
|
2112
|
-
};
|
|
2113
|
-
});
|
|
2295
|
+
const hits = Array.from({ length: words[0] }, (_, index) => (0, import_rigid_body_queries.decodeRigidBodyQueryHit)(words, floats, 4 + index * 12));
|
|
2114
2296
|
return {
|
|
2115
2297
|
hits,
|
|
2116
2298
|
totalHits: words[1],
|
|
@@ -2155,16 +2337,87 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2155
2337
|
readTriggerEvents() {
|
|
2156
2338
|
if (!this.triggerEvents || this.destroyed)
|
|
2157
2339
|
throw new Error("Triggers are disabled");
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2340
|
+
const afterSnapshot = this.triggerSnapshotRead;
|
|
2341
|
+
if (this.triggerRead && (!afterSnapshot || this.triggerRead.afterSnapshot === afterSnapshot))
|
|
2342
|
+
return this.triggerRead.result;
|
|
2343
|
+
const pending = {
|
|
2344
|
+
afterSnapshot,
|
|
2345
|
+
result: this.triggerEvents.readAsync().finally(() => afterSnapshot).then((bytes) => {
|
|
2346
|
+
const batch = (0, import_rigid_body_triggers.decodeRigidBodyTriggerEvents)(new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4), this.triggerCursor);
|
|
2347
|
+
this.triggerCursor = batch.sequence;
|
|
2348
|
+
return batch;
|
|
2349
|
+
}).finally(() => {
|
|
2350
|
+
if (this.triggerRead === pending)
|
|
2351
|
+
this.triggerRead = null;
|
|
2352
|
+
})
|
|
2353
|
+
};
|
|
2354
|
+
this.triggerRead = pending;
|
|
2355
|
+
return pending.result;
|
|
2356
|
+
}
|
|
2357
|
+
/** Recover the active contact set and advance the incremental cursor to the snapshot. */
|
|
2358
|
+
resyncContactEvents() {
|
|
2359
|
+
var _a;
|
|
2360
|
+
if (!this.device || !this.contactEvents || !this.contactHistory || this.destroyed)
|
|
2361
|
+
return Promise.reject(new Error("Contact events are not enabled"));
|
|
2362
|
+
if (this.contactSnapshotRead)
|
|
2363
|
+
return this.contactSnapshotRead;
|
|
2364
|
+
const priorRead = (_a = this.eventRead) == null ? void 0 : _a.result.catch(() => void 0);
|
|
2365
|
+
const snapshot = (0, import_rigid_body_event_snapshot.readRigidBodyEventSnapshot)(this.device, this.contactEvents, this.contactHistory, (header, rows) => {
|
|
2366
|
+
const contacts = [];
|
|
2367
|
+
for (let offset = 0; offset < rows.length; offset += 4) {
|
|
2368
|
+
if (rows[offset + 2] === 0)
|
|
2369
|
+
continue;
|
|
2370
|
+
const first = rows[offset];
|
|
2371
|
+
const second = rows[offset + 1];
|
|
2372
|
+
contacts.push({
|
|
2373
|
+
colliders: [first, second],
|
|
2374
|
+
bodies: [this.colliders[first].body, this.colliders[second].body]
|
|
2375
|
+
});
|
|
2376
|
+
}
|
|
2377
|
+
return { ...header, contacts };
|
|
2378
|
+
});
|
|
2379
|
+
this.contactSnapshotRead = snapshot.finally(() => priorRead).then((result) => {
|
|
2380
|
+
this.eventCursor = result.sequence;
|
|
2381
|
+
return result;
|
|
2164
2382
|
}).finally(() => {
|
|
2165
|
-
this.
|
|
2383
|
+
this.contactSnapshotRead = null;
|
|
2166
2384
|
});
|
|
2167
|
-
return this.
|
|
2385
|
+
return this.contactSnapshotRead;
|
|
2386
|
+
}
|
|
2387
|
+
/** Recover the active trigger overlap set and advance the incremental trigger cursor. */
|
|
2388
|
+
resyncTriggerEvents() {
|
|
2389
|
+
var _a;
|
|
2390
|
+
if (!this.device || !this.triggerEvents || !this.triggerHistory || this.destroyed)
|
|
2391
|
+
return Promise.reject(new Error("Triggers are disabled"));
|
|
2392
|
+
if (this.triggerSnapshotRead)
|
|
2393
|
+
return this.triggerSnapshotRead;
|
|
2394
|
+
const { buffer, groups } = this.triggerHistory;
|
|
2395
|
+
const priorRead = (_a = this.triggerRead) == null ? void 0 : _a.result.catch(() => void 0);
|
|
2396
|
+
const snapshot = (0, import_rigid_body_event_snapshot.readRigidBodyEventSnapshot)(this.device, this.triggerEvents, buffer, (header, rows) => {
|
|
2397
|
+
const overlaps = [];
|
|
2398
|
+
for (let offset = 0; offset < rows.length; offset += 4) {
|
|
2399
|
+
if ((rows[offset] & 1) === 0)
|
|
2400
|
+
continue;
|
|
2401
|
+
overlaps.push({
|
|
2402
|
+
trigger: groups[offset],
|
|
2403
|
+
body: groups[offset + 1],
|
|
2404
|
+
triggerCollider: rows[offset + 1],
|
|
2405
|
+
collider: rows[offset + 2]
|
|
2406
|
+
});
|
|
2407
|
+
}
|
|
2408
|
+
return { ...header, overlaps };
|
|
2409
|
+
});
|
|
2410
|
+
this.triggerSnapshotRead = snapshot.finally(() => priorRead).then((result) => {
|
|
2411
|
+
this.triggerCursor = result.sequence;
|
|
2412
|
+
return result;
|
|
2413
|
+
}).finally(() => {
|
|
2414
|
+
this.triggerSnapshotRead = null;
|
|
2415
|
+
});
|
|
2416
|
+
return this.triggerSnapshotRead;
|
|
2417
|
+
}
|
|
2418
|
+
/** Reset, capture and origin operations require stable event cursors. */
|
|
2419
|
+
get eventReadsPending() {
|
|
2420
|
+
return Boolean(this.eventRead || this.triggerRead || this.contactSnapshotRead || this.triggerSnapshotRead);
|
|
2168
2421
|
}
|
|
2169
2422
|
getSnapshotBuffers(includeRollbackScratch = true) {
|
|
2170
2423
|
return this.ownedBuffers.filter((buffer) => includeRollbackScratch || !buffer.id.startsWith(`${this.id}-checkpoint-`));
|
|
@@ -2199,7 +2452,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2199
2452
|
throw error;
|
|
2200
2453
|
}
|
|
2201
2454
|
const copy = (restore) => {
|
|
2202
|
-
if (released || this.destroyed || this.queryPending || this.
|
|
2455
|
+
if (released || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
2203
2456
|
throw new Error("Checkpoint requires an idle live world");
|
|
2204
2457
|
const encoder = device.createCommandEncoder();
|
|
2205
2458
|
for (const [index, buffer] of checkpointBuffers.entries())
|
|
@@ -2259,7 +2512,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2259
2512
|
/** Stop graph submissions and controls first; includes diagnostics, caches and event history. */
|
|
2260
2513
|
async captureState(options = {}) {
|
|
2261
2514
|
var _a;
|
|
2262
|
-
if (!this.device || this.destroyed || this.queryPending || this.
|
|
2515
|
+
if (!this.device || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
2263
2516
|
throw new Error("Capture requires an idle attached world");
|
|
2264
2517
|
return {
|
|
2265
2518
|
version: 1,
|
|
@@ -2281,7 +2534,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2281
2534
|
restoreState(capture) {
|
|
2282
2535
|
const checkpointBuffers = this.getSnapshotBuffers(capture.includeRollbackScratch);
|
|
2283
2536
|
const terrainRevision = capture.terrainRevision ?? 1;
|
|
2284
|
-
if (!this.device || this.destroyed || this.queryPending || this.
|
|
2537
|
+
if (!this.device || this.destroyed || this.queryPending || this.eventReadsPending || capture.version !== 1 || Boolean(capture.terrainAtlasLeases) !== Boolean(this.terrainAtlas) || !Number.isInteger(terrainRevision) || terrainRevision < 1 || terrainRevision > 16777215 || capture.origin !== void 0 && (capture.origin.length !== 3 || !capture.origin.every(Number.isFinite)) || capture.buffers.length !== checkpointBuffers.length || serializeCaptureProps(capture.props) !== serializeCaptureProps(this.props) || ![capture.contactCursor, capture.triggerCursor].every((value) => Number.isInteger(value) && value >= 0 && value <= 4294967295))
|
|
2285
2538
|
throw new Error("Incompatible rigid-body capture");
|
|
2286
2539
|
const shapeScales = new Map(capture.colliderShapeScales ?? []);
|
|
2287
2540
|
for (const [index, scale] of shapeScales) {
|
|
@@ -2414,7 +2667,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2414
2667
|
}
|
|
2415
2668
|
/** Destroy the compiled graph and finish readbacks before destroying its world. */
|
|
2416
2669
|
destroy() {
|
|
2417
|
-
var _a, _b, _c, _d, _e, _f;
|
|
2670
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2418
2671
|
if (this.destroyed)
|
|
2419
2672
|
return;
|
|
2420
2673
|
(_a = this.ensembleReset) == null ? void 0 : _a.destroy();
|
|
@@ -2426,6 +2679,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2426
2679
|
(_d = this.terrainWake) == null ? void 0 : _d.kernel.destroy();
|
|
2427
2680
|
(_e = this.queryComputation) == null ? void 0 : _e.kernel.destroy();
|
|
2428
2681
|
(_f = this.queryReduction) == null ? void 0 : _f.kernel.destroy();
|
|
2682
|
+
(_g = this.batchCastIndex) == null ? void 0 : _g.destroy();
|
|
2683
|
+
(_h = this.batchCast) == null ? void 0 : _h.kernel.destroy();
|
|
2429
2684
|
for (const buffer of this.ownedBuffers)
|
|
2430
2685
|
buffer.destroy();
|
|
2431
2686
|
this.ownedBuffers.length = 0;
|