@luma.gl/graph 10.0.0-beta.1 → 10.0.0-beta.3
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 +24 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts +10 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js +29 -1
- package/dist/arrow/gpu/arrow-gpu-table-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/experimental-models.cjs +21 -0
- package/dist/experimental-models.d.ts +2 -0
- package/dist/experimental-models.d.ts.map +1 -0
- package/dist/experimental-models.js +5 -0
- package/dist/experimental-models.js.map +1 -0
- package/dist/experimental-simulation.cjs +21 -0
- package/dist/experimental-simulation.d.ts +2 -0
- package/dist/experimental-simulation.d.ts.map +1 -0
- package/dist/experimental-simulation.js +5 -0
- package/dist/experimental-simulation.js.map +1 -0
- 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-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/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 +60 -15
- 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 +69 -18
- 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 +157 -25
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts +9 -5
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.js +184 -25
- package/dist/gpu-dataframe/gpu-expression-shader.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.cjs +100 -8
- package/dist/gpu-dataframe/gpu-expression.d.ts +35 -3
- package/dist/gpu-dataframe/gpu-expression.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.js +92 -6
- package/dist/gpu-dataframe/gpu-expression.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.cjs +2 -3
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js +4 -3
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.cjs +4 -4
- 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 +11 -5
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.cjs +136 -99
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts +7 -2
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js +135 -97
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.cjs +286 -49
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts +17 -2
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js +290 -40
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.cjs +10 -8
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts +7 -1
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.js +14 -8
- package/dist/gpu-dataframe/gpu-group-by-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.cjs +0 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.js +0 -1
- package/dist/gpu-dataframe/gpu-histogram-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.cjs +8 -8
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.js +9 -9
- package/dist/gpu-dataframe/gpu-join-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.cjs +38 -10
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts +3 -2
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.js +37 -9
- package/dist/gpu-dataframe/gpu-query-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.cjs +0 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.js +0 -1
- package/dist/gpu-dataframe/gpu-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-query.cjs +13 -5
- package/dist/gpu-dataframe/gpu-sort-query.d.ts +4 -1
- package/dist/gpu-dataframe/gpu-sort-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-sort-query.js +14 -5
- package/dist/gpu-dataframe/gpu-sort-query.js.map +1 -1
- package/dist/gpu-dataframe/index.cjs +12 -2
- package/dist/gpu-dataframe/index.cjs.map +3 -3
- package/dist/gpu-dataframe/index.d.ts +3 -3
- package/dist/gpu-dataframe/index.d.ts.map +1 -1
- package/dist/gpu-dataframe/index.js +2 -2
- package/dist/gpu-dataframe/index.js.map +1 -1
- package/dist/gpu-dataframe/portable-expression.cjs +68 -4
- package/dist/gpu-dataframe/portable-expression.d.ts +3 -1
- package/dist/gpu-dataframe/portable-expression.d.ts.map +1 -1
- package/dist/gpu-dataframe/portable-expression.js +69 -5
- package/dist/gpu-dataframe/portable-expression.js.map +1 -1
- package/dist/gpu-dggs-benchmarks.cjs +21 -0
- package/dist/gpu-dggs-benchmarks.d.ts +2 -0
- package/dist/gpu-dggs-benchmarks.d.ts.map +1 -0
- package/dist/gpu-dggs-benchmarks.js +5 -0
- package/dist/gpu-dggs-benchmarks.js.map +1 -0
- package/dist/gpu-graph-algorithms-benchmarks.cjs +21 -0
- package/dist/gpu-graph-algorithms-benchmarks.d.ts +2 -0
- package/dist/gpu-graph-algorithms-benchmarks.d.ts.map +1 -0
- package/dist/gpu-graph-algorithms-benchmarks.js +5 -0
- package/dist/gpu-graph-algorithms-benchmarks.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-terrain.cjs +116 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.d.ts +42 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.d.ts.map +1 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.js +90 -0
- package/dist/gpu-physics/gpu-physics-ensemble-terrain.js.map +1 -0
- package/dist/gpu-physics/gpu-physics-ensemble.cjs +105 -8
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts +40 -2
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-ensemble.js +109 -6
- package/dist/gpu-physics/gpu-physics-ensemble.js.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.cjs +737 -213
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts +111 -5
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js +842 -231
- package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
- package/dist/gpu-physics/index.cjs +23 -2
- package/dist/gpu-physics/index.cjs.map +3 -3
- package/dist/gpu-physics/index.d.ts +10 -3
- package/dist/gpu-physics/index.d.ts.map +1 -1
- package/dist/gpu-physics/index.js +6 -1
- package/dist/gpu-physics/index.js.map +1 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.cjs +21 -8
- package/dist/gpu-physics/rigid-body-bounds-shaders.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.js +15 -1
- package/dist/gpu-physics/rigid-body-bounds-shaders.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-convex-shaders.cjs +3 -2
- package/dist/gpu-physics/rigid-body-convex-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-convex-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-convex-shaders.js +3 -2
- package/dist/gpu-physics/rigid-body-convex-shaders.js.map +1 -1
- 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 +45 -14
- 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 +53 -14
- 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 +40 -8
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts +5 -2
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js +49 -9
- 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-geometry.cjs +41 -4
- package/dist/gpu-physics/rigid-body-geometry.d.ts +10 -1
- package/dist/gpu-physics/rigid-body-geometry.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-geometry.js +44 -3
- package/dist/gpu-physics/rigid-body-geometry.js.map +1 -1
- package/dist/gpu-physics/rigid-body-height-field-shader.cjs +80 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.d.ts +3 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.js +56 -0
- package/dist/gpu-physics/rigid-body-height-field-shader.js.map +1 -0
- package/dist/gpu-physics/rigid-body-height-field.cjs +166 -0
- package/dist/gpu-physics/rigid-body-height-field.d.ts +55 -0
- package/dist/gpu-physics/rigid-body-height-field.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-height-field.js +184 -0
- package/dist/gpu-physics/rigid-body-height-field.js.map +1 -0
- package/dist/gpu-physics/rigid-body-joints.cjs +8 -3
- 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-mesh-query-shaders.cjs +4 -2
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.js +4 -2
- package/dist/gpu-physics/rigid-body-mesh-query-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-mesh.cjs +72 -17
- package/dist/gpu-physics/rigid-body-mesh.d.ts +3 -0
- package/dist/gpu-physics/rigid-body-mesh.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-mesh.js +76 -20
- package/dist/gpu-physics/rigid-body-mesh.js.map +1 -1
- package/dist/gpu-physics/rigid-body-properties.cjs +4 -4
- package/dist/gpu-physics/rigid-body-properties.d.ts +6 -0
- package/dist/gpu-physics/rigid-body-properties.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-properties.js +1 -1
- package/dist/gpu-physics/rigid-body-properties.js.map +1 -1
- package/dist/gpu-physics/rigid-body-publication.cjs +2 -2
- package/dist/gpu-physics/rigid-body-publication.js +1 -1
- package/dist/gpu-physics/rigid-body-publication.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-query-geometry.cjs +22 -4
- package/dist/gpu-physics/rigid-body-query-geometry.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-query-geometry.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-query-geometry.js +22 -4
- package/dist/gpu-physics/rigid-body-query-geometry.js.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.cjs +13 -7
- 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 +16 -8
- package/dist/gpu-physics/rigid-body-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-shape-properties.cjs +2 -0
- package/dist/gpu-physics/rigid-body-shape-properties.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-shape-properties.js +2 -0
- package/dist/gpu-physics/rigid-body-shape-properties.js.map +1 -1
- package/dist/gpu-physics/rigid-body-terrain-atlas.cjs +287 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.d.ts +87 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.js +275 -0
- package/dist/gpu-physics/rigid-body-terrain-atlas.js.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.cjs +240 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.d.ts +76 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.js +247 -0
- package/dist/gpu-physics/rigid-body-terrain-lod.js.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.cjs +215 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.d.ts +25 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.js +218 -0
- package/dist/gpu-physics/rigid-body-terrain-stitch.js.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.cjs +263 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.d.ts +97 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.js +250 -0
- package/dist/gpu-physics/rigid-body-terrain-stream.js.map +1 -0
- package/dist/gpu-physics/rigid-body-triggers.cjs +54 -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 +56 -15
- package/dist/gpu-physics/rigid-body-triggers.js.map +1 -1
- package/dist/gpu-physics/rigid-body-vehicle.cjs +99 -44
- package/dist/gpu-physics/rigid-body-vehicle.d.ts +15 -3
- package/dist/gpu-physics/rigid-body-vehicle.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-vehicle.js +93 -40
- package/dist/gpu-physics/rigid-body-vehicle.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/cpu-geometry-pipelines.d.ts +1 -1
- package/dist/gpu-project/cpu-projection-operation.d.ts +1 -1
- package/dist/gpu-project/crs.cjs.map +3 -3
- package/dist/gpu-project/crs.d.ts +1 -1
- package/dist/gpu-project/index.cjs.map +2 -2
- package/dist/gpu-project/projection-crs-benchmark.cjs +2 -2
- package/dist/gpu-project/projection-crs-benchmark.d.ts +1 -1
- package/dist/gpu-project/projection-crs-benchmark.js +1 -1
- package/dist/gpu-project/projection-crs-input.cjs +7 -7
- package/dist/gpu-project/projection-crs-input.d.ts +1 -1
- package/dist/gpu-project/projection-crs-input.js +4 -4
- package/dist/gpu-project/projection-engine.d.ts +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-project-benchmarks.cjs +21 -0
- package/dist/gpu-project-benchmarks.d.ts +2 -0
- package/dist/gpu-project-benchmarks.d.ts.map +1 -0
- package/dist/gpu-project-benchmarks.js +5 -0
- package/dist/gpu-project-benchmarks.js.map +1 -0
- package/dist/gpu-project-crs.cjs +21 -0
- package/dist/gpu-project-crs.d.ts +2 -0
- package/dist/gpu-project-crs.d.ts.map +1 -0
- package/dist/gpu-project-crs.js +5 -0
- package/dist/gpu-project-crs.js.map +1 -0
- package/dist/gpu-project-geoarrow.cjs +21 -0
- package/dist/gpu-project-geoarrow.d.ts +2 -0
- package/dist/gpu-project-geoarrow.d.ts.map +1 -0
- package/dist/gpu-project-geoarrow.js +5 -0
- package/dist/gpu-project-geoarrow.js.map +1 -0
- package/dist/gpu-project-graph.cjs +21 -0
- package/dist/gpu-project-graph.d.ts +2 -0
- package/dist/gpu-project-graph.d.ts.map +1 -0
- package/dist/gpu-project-graph.js +5 -0
- package/dist/gpu-project-graph.js.map +1 -0
- package/dist/gpu-simple-graph/gpu-simple-graph-transfer.d.ts +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-transfer.d.ts.map +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-value.d.ts +1 -1
- package/dist/gpu-simple-graph/gpu-simple-graph-value.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts +1 -1
- package/dist/gpu-simple-graph/operation/gpu-data-evaluator.d.ts.map +1 -1
- package/dist/gpu-simple-graph/operation/operation.d.ts +1 -1
- package/dist/gpu-simple-graph/operation/operation.d.ts.map +1 -1
- package/dist/gpu-simple-graph-cpu.cjs +21 -0
- package/dist/gpu-simple-graph-cpu.d.ts +2 -0
- package/dist/gpu-simple-graph-cpu.d.ts.map +1 -0
- package/dist/gpu-simple-graph-cpu.js +5 -0
- package/dist/gpu-simple-graph-cpu.js.map +1 -0
- package/dist/gpu-simple-graph-webgl.cjs +21 -0
- package/dist/gpu-simple-graph-webgl.d.ts +2 -0
- package/dist/gpu-simple-graph-webgl.d.ts.map +1 -0
- package/dist/gpu-simple-graph-webgl.js +5 -0
- package/dist/gpu-simple-graph-webgl.js.map +1 -0
- package/dist/gpu-simple-graph-webgpu.cjs +21 -0
- package/dist/gpu-simple-graph-webgpu.d.ts +2 -0
- package/dist/gpu-simple-graph-webgpu.d.ts.map +1 -0
- package/dist/gpu-simple-graph-webgpu.js +5 -0
- package/dist/gpu-simple-graph-webgpu.js.map +1 -0
- package/dist/gpu-sql/gpu-sql.cjs +269 -171
- package/dist/gpu-sql/gpu-sql.d.ts +36 -1
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
- package/dist/gpu-sql/gpu-sql.js +313 -181
- 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/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 +19 -19
- 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 +46 -1
- package/src/arrow/index.ts +1 -0
- package/src/experimental-models.ts +5 -0
- package/src/experimental-simulation.ts +5 -0
- package/src/gpu-core/gpu-bvh-bounds.ts +84 -0
- package/src/gpu-core/gpu-command-graph-submission-pacer.ts +102 -0
- 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 +119 -25
- package/src/gpu-dataframe/gpu-data-frame.ts +35 -2
- package/src/gpu-dataframe/gpu-expression-shader.ts +267 -32
- package/src/gpu-dataframe/gpu-expression.ts +186 -10
- package/src/gpu-dataframe/gpu-global-aggregation-compiler.ts +6 -3
- package/src/gpu-dataframe/gpu-global-aggregation-query.ts +17 -6
- package/src/gpu-dataframe/gpu-global-sort-compiler.ts +177 -105
- package/src/gpu-dataframe/gpu-group-aggregation-compiler.ts +469 -53
- package/src/gpu-dataframe/gpu-group-by-query.ts +29 -13
- package/src/gpu-dataframe/gpu-histogram-compiler.ts +0 -1
- package/src/gpu-dataframe/gpu-join-compiler.ts +12 -8
- package/src/gpu-dataframe/gpu-query-compiler.ts +61 -19
- package/src/gpu-dataframe/gpu-sort-compiler.ts +0 -1
- package/src/gpu-dataframe/gpu-sort-query.ts +31 -5
- package/src/gpu-dataframe/index.ts +16 -3
- package/src/gpu-dataframe/portable-expression.ts +81 -4
- package/src/gpu-dggs-benchmarks.ts +5 -0
- package/src/gpu-graph-algorithms-benchmarks.ts +5 -0
- package/src/gpu-physics/gpu-physics-batch.ts +19 -13
- package/src/gpu-physics/gpu-physics-ensemble-terrain.ts +114 -0
- package/src/gpu-physics/gpu-physics-ensemble.ts +166 -7
- package/src/gpu-physics/gpu-rigid-body-world.ts +1085 -287
- package/src/gpu-physics/index.ts +46 -0
- package/src/gpu-physics/rigid-body-bounds-shaders.ts +16 -1
- 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-convex-shaders.ts +3 -2
- package/src/gpu-physics/rigid-body-ensemble-layout.ts +6 -2
- package/src/gpu-physics/rigid-body-ensemble-reset.ts +67 -15
- package/src/gpu-physics/rigid-body-ensemble-shaders.ts +18 -7
- package/src/gpu-physics/rigid-body-ensemble-transaction.ts +61 -10
- 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-geometry.ts +49 -4
- package/src/gpu-physics/rigid-body-height-field-shader.ts +56 -0
- package/src/gpu-physics/rigid-body-height-field.ts +257 -0
- package/src/gpu-physics/rigid-body-joints.ts +9 -11
- package/src/gpu-physics/rigid-body-mesh-query-shaders.ts +4 -2
- package/src/gpu-physics/rigid-body-mesh.ts +97 -26
- package/src/gpu-physics/rigid-body-properties.ts +5 -2
- package/src/gpu-physics/rigid-body-publication.ts +1 -1
- package/src/gpu-physics/rigid-body-queries.ts +202 -14
- package/src/gpu-physics/rigid-body-query-geometry.ts +22 -4
- package/src/gpu-physics/rigid-body-shaders.ts +20 -8
- package/src/gpu-physics/rigid-body-shape-properties.ts +2 -0
- package/src/gpu-physics/rigid-body-terrain-atlas.ts +378 -0
- package/src/gpu-physics/rigid-body-terrain-lod.ts +332 -0
- package/src/gpu-physics/rigid-body-terrain-stitch.ts +286 -0
- package/src/gpu-physics/rigid-body-terrain-stream.ts +323 -0
- package/src/gpu-physics/rigid-body-triggers.ts +65 -20
- package/src/gpu-physics/rigid-body-vehicle.ts +108 -41
- package/src/gpu-physics/sphere-world-shaders.ts +53 -21
- package/src/gpu-project/README.md +2 -2
- package/src/gpu-project/cpu-geometry-pipelines.ts +1 -1
- package/src/gpu-project/cpu-projection-operation.ts +1 -1
- package/src/gpu-project/crs.ts +2 -2
- package/src/gpu-project/projection-crs-benchmark.ts +2 -2
- package/src/gpu-project/projection-crs-input.ts +4 -4
- package/src/gpu-project/projection-engine.ts +2 -2
- package/src/gpu-project/projection-program.ts +1 -9
- package/src/gpu-project-benchmarks.ts +5 -0
- package/src/gpu-project-crs.ts +5 -0
- package/src/gpu-project-geoarrow.ts +5 -0
- package/src/gpu-project-graph.ts +5 -0
- package/src/gpu-simple-graph/gpu-simple-graph-transfer.ts +1 -1
- package/src/gpu-simple-graph/gpu-simple-graph-value.ts +1 -1
- package/src/gpu-simple-graph/operation/gpu-data-evaluator.ts +1 -1
- package/src/gpu-simple-graph/operation/operation.ts +1 -1
- package/src/gpu-simple-graph/operations/swizzle.ts +1 -1
- package/src/gpu-simple-graph-cpu.ts +5 -0
- package/src/gpu-simple-graph-webgl.ts +5 -0
- package/src/gpu-simple-graph-webgpu.ts +5 -0
- package/src/gpu-sql/gpu-sql.ts +535 -223
- package/src/gpu-sql/index.ts +1 -1
- package/src/utils/float32.ts +16 -0
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
import { createBoundKernel, createBoundKernelAsync } from "../gpu-core/utils/bound-kernel.js";
|
|
5
5
|
import { Buffer } from '@luma.gl/core';
|
|
6
6
|
import { shiftRigidBodyBuffers } from "./rigid-body-origin.js";
|
|
7
|
+
import { packRigidBodyHeightField } from "./rigid-body-height-field.js";
|
|
7
8
|
import { getRigidBodyShapeProperties } from "./rigid-body-shape-properties.js";
|
|
8
9
|
import { addEnsembleStatus, readOnlyEnsembleShader } from "./rigid-body-ensemble-shaders.js";
|
|
9
10
|
import { makeEnsembleReset } from "./rigid-body-ensemble-reset.js";
|
|
11
|
+
import { RigidBodyTerrainAtlas } from "./rigid-body-terrain-atlas.js";
|
|
10
12
|
import { packRigidBodyShapes } from "./rigid-body-geometry.js";
|
|
11
13
|
import { getCompoundBodyInertia, normalizeRigidBodyRotation, rotateRigidBodyVector } from "./rigid-body-properties.js";
|
|
12
14
|
import { addGPUCommandNodes } from "../gpu-core/gpu-command-node.js";
|
|
@@ -22,9 +24,12 @@ import { addRigidBodyCheckpoint } from "./rigid-body-transaction.js";
|
|
|
22
24
|
import { getRigidBodyJointShader, packRigidBodyJointState, RIGID_BODY_JOINT_STATE_BYTES, validateRigidBodyJoints } from "./rigid-body-joints.js";
|
|
23
25
|
import { addRigidBodyPosePublication } from "./rigid-body-publication.js";
|
|
24
26
|
import { getRigidBodyShader } from "./rigid-body-shaders.js";
|
|
25
|
-
import {
|
|
27
|
+
import { getVehicleShader, VEHICLE_STRIDE, VEHICLE_TERRAIN_ROW_SIZE } from "./rigid-body-vehicle.js";
|
|
26
28
|
import { decodeRigidBodyContactEvents, getRigidBodyEventShader } from "./rigid-body-events.js";
|
|
27
|
-
import {
|
|
29
|
+
import { addRigidBodyEventCompaction } from "./rigid-body-event-compaction.js";
|
|
30
|
+
import { readRigidBodyEventSnapshot } from "./rigid-body-event-snapshot.js";
|
|
31
|
+
import { RIGID_BODY_QUERY_SHADER, getRigidBodyBatchCastShader, RIGID_BODY_CAST_COMMAND_BYTES, RIGID_BODY_BATCH_RESULT_BYTES, packRigidBodyBatchCasts, decodeRigidBodyBatchCasts, decodeRigidBodyQueryHit } from "./rigid-body-queries.js";
|
|
32
|
+
import { canIndexRigidBodyCastCollider, createRigidBodyCastIndex, estimateRigidBodyCastIndexBytes, getRigidBodyCastOrder } from "./rigid-body-cast-index.js";
|
|
28
33
|
export class GPURigidBodyWorld {
|
|
29
34
|
worldOrigin = [0, 0, 0];
|
|
30
35
|
id;
|
|
@@ -46,6 +51,14 @@ export class GPURigidBodyWorld {
|
|
|
46
51
|
sleepStates = null;
|
|
47
52
|
/** World-owned GPU event ring; present only when eventCapacity is positive. */
|
|
48
53
|
contactEvents = null;
|
|
54
|
+
/** Trigger history and authored group IDs remain stable until world destruction. */
|
|
55
|
+
triggerHistory = null;
|
|
56
|
+
/** Contact activity is recorded in pair-slot order after accepted steps. */
|
|
57
|
+
contactHistory = null;
|
|
58
|
+
/** A recovery read shares the incremental trigger cursor. */
|
|
59
|
+
triggerSnapshotRead = null;
|
|
60
|
+
/** A recovery read shares the incremental contact cursor. */
|
|
61
|
+
contactSnapshotRead = null;
|
|
49
62
|
triggerEvents = null;
|
|
50
63
|
triggerCursor = 0;
|
|
51
64
|
triggerRead = null;
|
|
@@ -53,6 +66,24 @@ export class GPURigidBodyWorld {
|
|
|
53
66
|
eventRead = null;
|
|
54
67
|
queryComputation = null;
|
|
55
68
|
queryReduction = null;
|
|
69
|
+
/** Batched nearest-hit computation using the current world pose buffers. */
|
|
70
|
+
batchCast = null;
|
|
71
|
+
/** Compiled query graph that refits the world BVH and then casts. */
|
|
72
|
+
batchCastIndex = null;
|
|
73
|
+
/** Initial spatial order and stable collider ID mapping for indexed batches. */
|
|
74
|
+
batchCastOrder = null;
|
|
75
|
+
/** Query graph reservation before attachment, when the physical plan is unavailable. */
|
|
76
|
+
batchCastIndexEstimate;
|
|
77
|
+
/** Reusable storage for a bounded list of ray and sweep commands. */
|
|
78
|
+
batchCastCommands = null;
|
|
79
|
+
/** Reusable GPU output with one compact result per batch command. */
|
|
80
|
+
batchCastResults = null;
|
|
81
|
+
/** Chassis definitions in GPU storage order. */
|
|
82
|
+
vehicles;
|
|
83
|
+
/** Whether any chassis has more than one terrain candidate. */
|
|
84
|
+
multiSurfaceVehicles;
|
|
85
|
+
/** Number of vehicles in each equal-sized ensemble partition, or zero for a standalone world. */
|
|
86
|
+
vehiclesPerInstance;
|
|
56
87
|
vehicleBuffer = null;
|
|
57
88
|
querySettings = null;
|
|
58
89
|
querySelection = null;
|
|
@@ -61,9 +92,23 @@ export class GPURigidBodyWorld {
|
|
|
61
92
|
targets = null;
|
|
62
93
|
simulationStatistics = null;
|
|
63
94
|
colliders;
|
|
95
|
+
bodyColliderStarts;
|
|
96
|
+
ensembleTerrainSlots;
|
|
64
97
|
props;
|
|
65
98
|
ownedBuffers = [];
|
|
99
|
+
allocationPlan;
|
|
66
100
|
ensembleBuffer = null;
|
|
101
|
+
/** Byte offsets of writable fixed-dimension height fields in the world metadata buffer. */
|
|
102
|
+
heightFieldSlots = new Map();
|
|
103
|
+
/** Float32-exact edit stamp, restored together with the contact cache. */
|
|
104
|
+
terrainRevision = 1;
|
|
105
|
+
terrainWake = null;
|
|
106
|
+
/** Page ownership and live lease counts for an opt-in fused atlas. */
|
|
107
|
+
terrainAtlas;
|
|
108
|
+
/** Start of the shared atlas in the GPU metadata buffer, measured in 32-bit words. */
|
|
109
|
+
terrainAtlasWord = 0;
|
|
110
|
+
/** Start of the shader geometry region in the GPU metadata buffer, measured in 32-bit words. */
|
|
111
|
+
terrainGeometryWord = 0;
|
|
67
112
|
ensembleResetOrigin;
|
|
68
113
|
ensembleReset;
|
|
69
114
|
initialEnsembleBodies;
|
|
@@ -80,6 +125,14 @@ export class GPURigidBodyWorld {
|
|
|
80
125
|
gpuCheckpoints = new Set();
|
|
81
126
|
broadPhaseCounters = null;
|
|
82
127
|
constructor(props) {
|
|
128
|
+
/** Zero leaves the optional command and result buffers unallocated. */
|
|
129
|
+
const queryBatchCapacity = props.queryBatchCapacity ?? 0;
|
|
130
|
+
if (!Number.isSafeInteger(queryBatchCapacity) ||
|
|
131
|
+
queryBatchCapacity < 0 ||
|
|
132
|
+
queryBatchCapacity > 65535 ||
|
|
133
|
+
(queryBatchCapacity > 0 && !props.enableQueries) ||
|
|
134
|
+
(props.queryBatchIndex && queryBatchCapacity === 0))
|
|
135
|
+
throw new Error('Invalid collision cast batch capacity');
|
|
83
136
|
for (const damping of [props.linearDamping ?? 0, props.angularDamping ?? 0]) {
|
|
84
137
|
if (!Number.isFinite(damping) || damping < 0)
|
|
85
138
|
throw new Error('Invalid damping');
|
|
@@ -146,6 +199,9 @@ export class GPURigidBodyWorld {
|
|
|
146
199
|
throw new Error('Supply shape or colliders');
|
|
147
200
|
const shapes = body.colliders ?? (body.shape ? [{ shape: body.shape }] : []);
|
|
148
201
|
for (const collider of shapes) {
|
|
202
|
+
if (collider.shape.type === 'height-field' &&
|
|
203
|
+
(body.mode ?? (body.mass === 0 ? 'static' : 'dynamic')) !== 'static')
|
|
204
|
+
throw new Error('Height fields require static bodies');
|
|
149
205
|
const properties = getRigidBodyShapeProperties(collider.shape);
|
|
150
206
|
if (!Number.isFinite(properties.volume) ||
|
|
151
207
|
!properties.center.every(Number.isFinite) ||
|
|
@@ -242,6 +298,16 @@ export class GPURigidBodyWorld {
|
|
|
242
298
|
(this.broadPhase === 'hierarchical-grid' &&
|
|
243
299
|
(this.maximumPairs & (this.maximumPairs - 1)) !== 0))
|
|
244
300
|
throw new Error('Invalid rigid-body pair capacity');
|
|
301
|
+
/** Size each recoverable cache range independently of the shared candidate budget. */
|
|
302
|
+
const instancePairCapacity = props.ensemblePairsPerInstance;
|
|
303
|
+
if (instancePairCapacity !== undefined &&
|
|
304
|
+
(!props.ensembleBodiesPerInstance ||
|
|
305
|
+
props.failurePolicy !== 'rollback' ||
|
|
306
|
+
!Number.isSafeInteger(instancePairCapacity) ||
|
|
307
|
+
instancePairCapacity < 1 ||
|
|
308
|
+
instancePairCapacity * (this.count / props.ensembleBodiesPerInstance) > this.maximumPairs ||
|
|
309
|
+
(instancePairCapacity & (instancePairCapacity - 1)) !== 0))
|
|
310
|
+
throw new Error('Invalid ensemble instance contact capacity');
|
|
245
311
|
if (props.continuous) {
|
|
246
312
|
if (props.failurePolicy !== 'rollback' ||
|
|
247
313
|
!Number.isInteger(props.continuous.maximumImpacts ?? 4) ||
|
|
@@ -253,7 +319,7 @@ export class GPURigidBodyWorld {
|
|
|
253
319
|
(props.continuous.maximumCandidates ?? this.maximumPairs) > 0x40000000 ||
|
|
254
320
|
(props.continuous.mode === 'convex' &&
|
|
255
321
|
(Boolean(props.joints?.length) ||
|
|
256
|
-
colliders.some(collider => ['plane', 'triangle-mesh'].includes(collider.shape.type)))))
|
|
322
|
+
colliders.some(collider => ['plane', 'triangle-mesh', 'height-field'].includes(collider.shape.type)))))
|
|
257
323
|
throw new Error('Invalid continuous settings');
|
|
258
324
|
for (const index of props.continuous.bodies) {
|
|
259
325
|
const body = props.bodies[index];
|
|
@@ -282,29 +348,92 @@ export class GPURigidBodyWorld {
|
|
|
282
348
|
const definitions = structuredClone({ colliders, props });
|
|
283
349
|
this.props = definitions.props;
|
|
284
350
|
this.colliders = definitions.colliders;
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
351
|
+
this.batchCastIndexEstimate =
|
|
352
|
+
this.props.queryBatchIndex && this.colliderCount
|
|
353
|
+
? estimateRigidBodyCastIndexBytes(this.colliders.filter(canIndexRigidBodyCastCollider).length)
|
|
354
|
+
: 0;
|
|
355
|
+
this.ensembleTerrainSlots = new Set(this.props.ensembleTerrainSlots);
|
|
356
|
+
if (this.ensembleTerrainSlots.size &&
|
|
357
|
+
(!this.props.ensembleBodiesPerInstance ||
|
|
358
|
+
[...this.ensembleTerrainSlots].some(index => this.colliders[index]?.shape.type !== 'height-field')))
|
|
359
|
+
throw new Error('Invalid ensemble terrain slots');
|
|
360
|
+
if (this.props.ensembleTerrainAtlas) {
|
|
361
|
+
this.terrainAtlas = new RigidBodyTerrainAtlas(this.props.ensembleTerrainAtlas, Array.from(this.ensembleTerrainSlots, collider => {
|
|
362
|
+
const shape = this.colliders[collider].shape;
|
|
363
|
+
if (shape.type !== 'height-field')
|
|
364
|
+
throw new Error('Invalid ensemble terrain slot');
|
|
365
|
+
return { collider, width: shape.field.width, height: shape.field.height };
|
|
366
|
+
}));
|
|
367
|
+
}
|
|
368
|
+
this.bodyColliderStarts = new Uint32Array(this.count + 1);
|
|
369
|
+
let colliderIndex = 0;
|
|
370
|
+
for (let body = 0; body < this.count; body++) {
|
|
371
|
+
this.bodyColliderStarts[body] = colliderIndex;
|
|
372
|
+
while (this.colliders[colliderIndex]?.body === body)
|
|
373
|
+
colliderIndex++;
|
|
374
|
+
}
|
|
375
|
+
this.bodyColliderStarts[this.count] = colliderIndex;
|
|
376
|
+
if (this.props.vehicle && this.props.vehicles)
|
|
377
|
+
throw new Error('Choose vehicle or vehicles');
|
|
378
|
+
this.vehicles = this.props.vehicles ?? (this.props.vehicle ? [this.props.vehicle] : []);
|
|
379
|
+
this.multiSurfaceVehicles = this.vehicles.some(vehicle => vehicle.additionalTerrainColliders?.length);
|
|
380
|
+
const bodiesPerInstance = props.ensembleBodiesPerInstance;
|
|
381
|
+
const collidersPerInstance = props.collisionPartitionSize;
|
|
382
|
+
this.vehiclesPerInstance = bodiesPerInstance
|
|
383
|
+
? this.vehicles.length / (this.count / bodiesPerInstance)
|
|
384
|
+
: 0;
|
|
385
|
+
if (!Number.isInteger(this.vehiclesPerInstance))
|
|
386
|
+
throw new Error('Invalid ensemble vehicle layout');
|
|
387
|
+
const vehicleChassis = new Set();
|
|
388
|
+
for (const [vehicleIndex, vehicle] of this.vehicles.entries()) {
|
|
389
|
+
const instance = bodiesPerInstance ? Math.floor(vehicleIndex / this.vehiclesPerInstance) : 0;
|
|
390
|
+
const terrainIndices = [
|
|
391
|
+
vehicle.terrainCollider,
|
|
392
|
+
...(vehicle.additionalTerrainColliders ?? [])
|
|
393
|
+
];
|
|
288
394
|
const chassis = this.props.bodies[vehicle.chassis];
|
|
289
|
-
const ground = terrain && this.props.bodies[terrain.body];
|
|
290
395
|
if (!chassis ||
|
|
291
|
-
|
|
292
|
-
|
|
396
|
+
vehicleChassis.has(vehicle.chassis) ||
|
|
397
|
+
terrainIndices.length > 4 ||
|
|
398
|
+
new Set(terrainIndices).size !== terrainIndices.length ||
|
|
399
|
+
terrainIndices.some(colliderIndex => {
|
|
400
|
+
const collider = this.colliders[colliderIndex];
|
|
401
|
+
const ground = collider && this.props.bodies[collider.body];
|
|
402
|
+
return (!ground ||
|
|
403
|
+
collider.isTrigger ||
|
|
404
|
+
this.getBodyMode(collider.body) !== 'static' ||
|
|
405
|
+
(bodiesPerInstance && Math.floor(colliderIndex / collidersPerInstance) !== instance));
|
|
406
|
+
}) ||
|
|
293
407
|
(chassis.mode ?? (chassis.mass === 0 ? 'static' : 'dynamic')) !== 'dynamic' ||
|
|
294
|
-
(ground.mode ?? (ground.mass === 0 ? 'static' : 'dynamic')) !== 'static' ||
|
|
295
408
|
vehicle.wheels.length !== 4 ||
|
|
296
|
-
|
|
297
|
-
this.props.ensembleBodiesPerInstance ||
|
|
409
|
+
(bodiesPerInstance && Math.floor(vehicle.chassis / bodiesPerInstance) !== instance) ||
|
|
298
410
|
![vehicle.radius, vehicle.travel, vehicle.springRate, vehicle.wheelInertia].every(value => Number.isFinite(value) && value > 0) ||
|
|
299
411
|
![vehicle.damping, vehicle.grip, vehicle.motorTorque, vehicle.brakeTorque].every(value => Number.isFinite(value) && value >= 0) ||
|
|
412
|
+
(vehicle.steeringWheelbase !== undefined &&
|
|
413
|
+
(!Number.isFinite(Math.fround(vehicle.steeringWheelbase)) ||
|
|
414
|
+
vehicle.steeringWheelbase <= 0)) ||
|
|
415
|
+
!Number.isFinite(Math.fround(vehicle.antiRollRate ?? 0)) ||
|
|
416
|
+
(vehicle.antiRollRate ?? 0) < 0 ||
|
|
417
|
+
(vehicle.slipGain !== undefined &&
|
|
418
|
+
(vehicle.slipGain.length !== 2 ||
|
|
419
|
+
!vehicle.slipGain.every(gain => Number.isFinite(Math.fround(gain)) && gain >= 0))) ||
|
|
300
420
|
vehicle.wheels.some(wheel => wheel.mount.length !== 3 || !wheel.mount.every(Number.isFinite)))
|
|
301
421
|
throw new Error('Invalid vehicle configuration');
|
|
422
|
+
vehicleChassis.add(vehicle.chassis);
|
|
302
423
|
}
|
|
303
424
|
if (props.ensembleBodiesPerInstance)
|
|
304
425
|
this.initialEnsembleBodies = this.props.bodies.slice(0, props.ensembleBodiesPerInstance);
|
|
305
426
|
}
|
|
427
|
+
/** Allocation size including optional immutable terrain rows after the wheel state. */
|
|
428
|
+
getVehicleByteLength() {
|
|
429
|
+
return (this.vehicles.length *
|
|
430
|
+
(VEHICLE_STRIDE + (this.multiSurfaceVehicles ? VEHICLE_TERRAIN_ROW_SIZE : 0)));
|
|
431
|
+
}
|
|
306
432
|
getStorageLayout() {
|
|
307
|
-
const packed = packRigidBodyShapes(this.colliders);
|
|
433
|
+
const packed = packRigidBodyShapes(this.colliders, Boolean(this.props.ensembleBodiesPerInstance), this.ensembleTerrainSlots, Boolean(this.terrainAtlas));
|
|
434
|
+
const geometryWords = packed.geometry.length + (this.terrainAtlas?.wordLength ?? 0);
|
|
435
|
+
if (this.terrainAtlas && geometryWords >= 2 ** 26)
|
|
436
|
+
throw new Error('Terrain atlas exceeds address capacity');
|
|
308
437
|
const sparse = this.broadPhase === 'hierarchical-grid';
|
|
309
438
|
const extended = this.colliders.some(collider => (collider.shape.type !== 'sphere' && collider.shape.type !== 'box') ||
|
|
310
439
|
(collider.isTrigger && collider.shape.type !== 'sphere'));
|
|
@@ -314,10 +443,21 @@ export class GPURigidBodyWorld {
|
|
|
314
443
|
sparse,
|
|
315
444
|
extended,
|
|
316
445
|
parallel,
|
|
317
|
-
...getRigidBodyStorageLayout(this.count, this.colliderStorageCount, this.maximumPairs,
|
|
446
|
+
...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), this.props.joints?.length ?? 0, this.props.ensembleBodiesPerInstance
|
|
447
|
+
? this.count / this.props.ensembleBodiesPerInstance
|
|
448
|
+
: 0, Boolean(this.props.ensemblePairsPerInstance), this.props.queryBatchCapacity)
|
|
318
449
|
};
|
|
319
|
-
if (this.
|
|
320
|
-
|
|
450
|
+
if (this.vehicles.length) {
|
|
451
|
+
const byteLength = this.getVehicleByteLength();
|
|
452
|
+
storage.buffers.push({ name: 'vehicle', byteLength, uniform: false });
|
|
453
|
+
if (this.props.failurePolicy === 'rollback') {
|
|
454
|
+
storage.buffers.push({
|
|
455
|
+
name: this.vehiclesPerInstance ? 'checkpoint-vehicles' : 'checkpoint-7',
|
|
456
|
+
byteLength: this.vehiclesPerInstance ? this.vehicles.length * VEHICLE_STRIDE : byteLength,
|
|
457
|
+
uniform: false
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
}
|
|
321
461
|
if (this.props.continuous?.mode === 'convex') {
|
|
322
462
|
storage.buffers = storage.buffers.filter(buffer => buffer.name !== 'continuous-previous');
|
|
323
463
|
storage.buffers.push({ name: 'continuous-dispatch', byteLength: 16, uniform: false });
|
|
@@ -370,7 +510,7 @@ export class GPURigidBodyWorld {
|
|
|
370
510
|
if (!this.device || !this.ensembleBuffer || this.destroyed)
|
|
371
511
|
throw new Error('World has no ensemble scheduler');
|
|
372
512
|
this.ensembleResetOrigin ??= this.origin;
|
|
373
|
-
this.ensembleReset ??= makeEnsembleReset(this.device, this.id, this.ownedBuffers, this.count, this.props.ensembleBodiesPerInstance, this.props.collisionPartitionSize, this.maximumPairs);
|
|
513
|
+
this.ensembleReset ??= makeEnsembleReset(this.device, this.id, this.ownedBuffers, this.count, this.props.ensembleBodiesPerInstance, this.props.collisionPartitionSize, this.maximumPairs, this.vehiclesPerInstance, this.ensembleTerrainSlots, this.props.ensemblePairsPerInstance);
|
|
374
514
|
return this.ensembleReset.byteLength;
|
|
375
515
|
}
|
|
376
516
|
resetEnsembleInstance(instance) {
|
|
@@ -381,37 +521,38 @@ export class GPURigidBodyWorld {
|
|
|
381
521
|
const colliderStart = instance * this.props.collisionPartitionSize;
|
|
382
522
|
let colliderIndex = colliderStart;
|
|
383
523
|
const restored = this.initialEnsembleBodies.map(body => {
|
|
384
|
-
|
|
385
|
-
|
|
524
|
+
const { shape, colliders, ...properties } = body;
|
|
525
|
+
const resetCollider = (definition) => {
|
|
526
|
+
const index = colliderIndex++;
|
|
527
|
+
const { body: _, ...current } = this.colliders[index];
|
|
528
|
+
if (this.ensembleTerrainSlots.has(index))
|
|
529
|
+
return current;
|
|
386
530
|
return {
|
|
387
|
-
...
|
|
388
|
-
shape:
|
|
389
|
-
? current
|
|
390
|
-
:
|
|
531
|
+
...definition,
|
|
532
|
+
shape: definition.shape.type === 'convex-hull' || definition.shape.type === 'triangle-mesh'
|
|
533
|
+
? current.shape
|
|
534
|
+
: definition.shape,
|
|
535
|
+
excludedColliders: definition.excludedColliders?.map(index => index + colliderStart)
|
|
391
536
|
};
|
|
392
|
-
}
|
|
393
|
-
return {
|
|
394
|
-
...body,
|
|
395
|
-
colliders: body.colliders.map(collider => {
|
|
396
|
-
const current = this.colliders[colliderIndex++].shape;
|
|
397
|
-
return {
|
|
398
|
-
...collider,
|
|
399
|
-
shape: collider.shape.type === 'convex-hull' || collider.shape.type === 'triangle-mesh'
|
|
400
|
-
? current
|
|
401
|
-
: collider.shape,
|
|
402
|
-
excludedColliders: collider.excludedColliders?.map(index => index + colliderStart)
|
|
403
|
-
};
|
|
404
|
-
})
|
|
405
537
|
};
|
|
538
|
+
if (shape && !this.ensembleTerrainSlots.has(colliderIndex))
|
|
539
|
+
return { ...body, shape: resetCollider({ shape }).shape };
|
|
540
|
+
return { ...properties, colliders: (colliders ?? [{ shape: shape }]).map(resetCollider) };
|
|
406
541
|
});
|
|
407
|
-
const definitions =
|
|
542
|
+
const definitions = this.props.bodies;
|
|
408
543
|
definitions.splice(bodyStart, restored.length, ...restored);
|
|
409
|
-
this.
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
544
|
+
this.restoreColliderDefinitions(bodyStart, bodyStart + restored.length);
|
|
545
|
+
const metadata = this.ownedBuffers.find(buffer => buffer.id === `${this.id}-bodies`);
|
|
546
|
+
for (let index = colliderStart; index < colliderIndex; index++) {
|
|
547
|
+
this.colliderShapeScales.delete(index);
|
|
548
|
+
if (!this.ensembleTerrainSlots.has(index))
|
|
549
|
+
continue;
|
|
550
|
+
const collider = this.colliders[index];
|
|
551
|
+
const center = definitions[collider.body].centerOfMass ?? [0, 0, 0];
|
|
552
|
+
metadata.write(new Float32Array((collider.position ?? [0, 0, 0]).map((value, axis) => value - center[axis])), this.count * 48 + index * 96 + 16);
|
|
553
|
+
}
|
|
413
554
|
this.ensembleReset.reset(instance, this.origin.map((value, axis) => value - this.ensembleResetOrigin[axis]));
|
|
414
|
-
this.ensembleBuffer.write(new Uint32Array([0, 0, 0, 0, 1, 1]), (16 + instance * 8 + 1) * 4);
|
|
555
|
+
this.ensembleBuffer.write(new Uint32Array([0, 0, 0, 0, 1, 1, 0]), (16 + instance * 8 + 1) * 4);
|
|
415
556
|
if (this.encodePosePublication) {
|
|
416
557
|
const encoder = this.device.createCommandEncoder();
|
|
417
558
|
this.encodePosePublication(encoder);
|
|
@@ -454,6 +595,7 @@ export class GPURigidBodyWorld {
|
|
|
454
595
|
claimedContacts,
|
|
455
596
|
journaledContacts,
|
|
456
597
|
bodySnapshotBytes: activeBodies * 80,
|
|
598
|
+
vehicleSnapshotBytes: activeInstances * this.vehiclesPerInstance * VEHICLE_STRIDE,
|
|
457
599
|
contactSnapshotBytes: journaledContacts * 416,
|
|
458
600
|
allocatorSnapshotBytes: (8 + activeInstances * 2 + journaledContacts * 3) * 4,
|
|
459
601
|
residentInstances: this.count / this.props.ensembleBodiesPerInstance,
|
|
@@ -469,15 +611,18 @@ export class GPURigidBodyWorld {
|
|
|
469
611
|
instance >= this.count / this.props.ensembleBodiesPerInstance)
|
|
470
612
|
throw new Error('Invalid ensemble instance');
|
|
471
613
|
}
|
|
472
|
-
/**
|
|
614
|
+
/** World buffer sizes and private query scratch. Simulation graph scratch and driver overhead are separate. */
|
|
473
615
|
getCapacityInfo() {
|
|
474
|
-
const
|
|
616
|
+
const buffers = this.allocationPlan
|
|
617
|
+
? this.allocationPlan.map(buffer => ({ ...buffer }))
|
|
618
|
+
: this.getStorageLayout().buffers;
|
|
475
619
|
return {
|
|
476
620
|
bodyCount: this.count,
|
|
477
621
|
colliderCount: this.colliderCount,
|
|
478
622
|
maximumPairs: this.maximumPairs,
|
|
479
623
|
pairWorkgroups: Math.ceil(this.maximumPairs / 64),
|
|
480
624
|
buffers,
|
|
625
|
+
queryIndexScratchBytes: this.batchCastIndex?.stats.physicalTransientResourceBytes ?? this.batchCastIndexEstimate,
|
|
481
626
|
ownedBufferBytes: buffers.reduce((total, buffer) => total + buffer.byteLength, 0)
|
|
482
627
|
};
|
|
483
628
|
}
|
|
@@ -490,6 +635,9 @@ export class GPURigidBodyWorld {
|
|
|
490
635
|
if (this.props.continuous?.mode === 'convex' &&
|
|
491
636
|
Math.max(Math.ceil((this.props.continuous.maximumCandidates ?? this.maximumPairs) / 64), Math.ceil(2 ** Math.ceil(Math.log2(Math.max(1, this.colliders.length))) / 64)) > graph.device.limits.maxComputeWorkgroupsPerDimension)
|
|
492
637
|
throw new Error('Continuous candidate dispatch exceeds device limits');
|
|
638
|
+
if (!this.vehiclesPerInstance &&
|
|
639
|
+
this.vehicles.length > graph.device.limits.maxComputeWorkgroupsPerDimension)
|
|
640
|
+
throw new Error('Vehicle dispatch exceeds device limits');
|
|
493
641
|
for (const buffer of allocationPlan) {
|
|
494
642
|
const bindingLimit = buffer.uniform
|
|
495
643
|
? graph.device.limits.maxUniformBufferBindingSize
|
|
@@ -497,6 +645,9 @@ export class GPURigidBodyWorld {
|
|
|
497
645
|
if (buffer.byteLength > Math.min(graph.device.limits.maxBufferSize, bindingLimit))
|
|
498
646
|
throw new Error(`Rigid-body ${buffer.name} storage exceeds device limits`);
|
|
499
647
|
}
|
|
648
|
+
if ((this.props.queryBatchCapacity ?? 0) > graph.device.limits.maxComputeWorkgroupsPerDimension)
|
|
649
|
+
throw new Error('Collision cast batch exceeds device dispatch limits');
|
|
650
|
+
this.allocationPlan = allocationPlan;
|
|
500
651
|
this.device = graph.device;
|
|
501
652
|
const allocate = (name, data, uniform = false) => {
|
|
502
653
|
const buffer = graph.device.createBuffer({
|
|
@@ -525,6 +676,29 @@ export class GPURigidBodyWorld {
|
|
|
525
676
|
: undefined;
|
|
526
677
|
const metadata = new Float32Array(metadataLength);
|
|
527
678
|
metadata.set(packed.geometry, geometryOffset);
|
|
679
|
+
if (this.terrainAtlas) {
|
|
680
|
+
this.terrainGeometryWord = geometryOffset;
|
|
681
|
+
this.terrainAtlasWord = geometryOffset + packed.geometry.length;
|
|
682
|
+
const { wordsByCollider, uploads } = this.terrainAtlas.bind(Array.from(packed.atlasFields, ([collider, field]) => ({
|
|
683
|
+
collider,
|
|
684
|
+
data: new Float32Array(field.data)
|
|
685
|
+
})));
|
|
686
|
+
for (const { word, data } of uploads)
|
|
687
|
+
metadata.set(data, this.terrainAtlasWord + word);
|
|
688
|
+
for (const [collider, word] of wordsByCollider) {
|
|
689
|
+
const field = packed.atlasFields.get(collider);
|
|
690
|
+
const address = (packed.geometry.length + word) / 4;
|
|
691
|
+
const shape = packed.shapes[collider];
|
|
692
|
+
shape.padding[0] = address;
|
|
693
|
+
shape.padding[3] = field.triangleCount;
|
|
694
|
+
shape.policies[0] = address + field.nodeOffset;
|
|
695
|
+
shape.policies[1] = field.nodeCount;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
this.heightFieldSlots = new Map(Array.from(packed.heightFields, ([collider, offset]) => [
|
|
699
|
+
collider,
|
|
700
|
+
(geometryOffset + offset * 4) * 4
|
|
701
|
+
]));
|
|
528
702
|
const bodyColliders = Array.from({ length: this.count }, () => []);
|
|
529
703
|
if (this.colliderCount)
|
|
530
704
|
for (const collider of this.colliders)
|
|
@@ -582,7 +756,10 @@ export class GPURigidBodyWorld {
|
|
|
582
756
|
material?.restitutionCombine ? policies.indexOf(material.restitutionCombine) : 4,
|
|
583
757
|
material?.frictionCombine ? policies.indexOf(material.frictionCombine) : 4,
|
|
584
758
|
...shape.policies,
|
|
585
|
-
|
|
759
|
+
shape.padding[0],
|
|
760
|
+
shape.padding[1],
|
|
761
|
+
this.ensembleTerrainSlots.has(index) ? 1 : shape.padding[2],
|
|
762
|
+
shape.padding[3]
|
|
586
763
|
], this.count * 12 + index * 24);
|
|
587
764
|
}
|
|
588
765
|
const exclusionOffset = this.count * 12 + this.colliderStorageCount * 24;
|
|
@@ -594,7 +771,7 @@ export class GPURigidBodyWorld {
|
|
|
594
771
|
this.angularVelocities = allocate('angular-velocities', angular);
|
|
595
772
|
this.sleepStates = allocate('sleep', this.count * 16);
|
|
596
773
|
this.targets = allocate('targets', this.props.ensembleBodiesPerInstance
|
|
597
|
-
? getEnsembleContactLayout(this.count, this.count / this.props.ensembleBodiesPerInstance, this.maximumPairs).byteLength
|
|
774
|
+
? getEnsembleContactLayout(this.count, this.count / this.props.ensembleBodiesPerInstance, this.maximumPairs, Boolean(this.props.ensemblePairsPerInstance)).byteLength
|
|
598
775
|
: Math.ceil((this.count * 32 + (sparse ? 32 + this.maximumPairs * 8 : 16)) / 16) * 16 +
|
|
599
776
|
(this.props.joints?.length ?? 0) * RIGID_BODY_JOINT_STATE_BYTES);
|
|
600
777
|
for (const [index, joint] of (this.props.joints ?? []).entries()) {
|
|
@@ -710,7 +887,7 @@ export class GPURigidBodyWorld {
|
|
|
710
887
|
usage: Buffer.STORAGE
|
|
711
888
|
}, objectAttributes), { format: 'uint32', length: this.colliderStorageCount })
|
|
712
889
|
: undefined;
|
|
713
|
-
const source = getRigidBodyShader(this.count, this.props.iterations ?? 16, this.colliderStorageCount, extended, sparseLayout, parallel, this.props.maximumMeshTraversalTestsPerPair ?? 65536, getRigidBodyJointShader(this.props.joints ?? [], this.props.bodies), Boolean(this.props.joints?.length), this.props.linearDamping ?? 0, this.props.angularDamping ?? 0, this.props.joints?.length ?? 0, this.props.compactContacts ?? true, this.props.collisionPartitionSize, this.props.ensembleBodiesPerInstance, this.props.parallelContactSolver === 'block');
|
|
890
|
+
const source = getRigidBodyShader(this.count, this.props.iterations ?? 16, this.colliderStorageCount, extended, sparseLayout, parallel, this.props.maximumMeshTraversalTestsPerPair ?? 65536, getRigidBodyJointShader(this.props.joints ?? [], this.props.bodies), Boolean(this.props.joints?.length), this.props.linearDamping ?? 0, this.props.angularDamping ?? 0, this.props.joints?.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);
|
|
714
891
|
const parallelBindings = {
|
|
715
892
|
parallelReset: ['parallelState'],
|
|
716
893
|
parallelResetCounters: ['parallelState'],
|
|
@@ -780,33 +957,6 @@ export class GPURigidBodyWorld {
|
|
|
780
957
|
}
|
|
781
958
|
this.simulationStatistics = allocate('simulation-statistics', 64);
|
|
782
959
|
const statisticsResource = graph.importBuffer({ id: `${this.id}-statistics`, byteLength: 64, usage: Buffer.STORAGE }, this.simulationStatistics);
|
|
783
|
-
const checkpointStates = [
|
|
784
|
-
'positions',
|
|
785
|
-
'orientations',
|
|
786
|
-
'velocities',
|
|
787
|
-
'angularVelocities',
|
|
788
|
-
'sleepStates',
|
|
789
|
-
'targets'
|
|
790
|
-
].map(name => {
|
|
791
|
-
const binding = bindings.find(binding => binding.name === name);
|
|
792
|
-
return { buffer: binding.buffer, resource: binding.resource };
|
|
793
|
-
});
|
|
794
|
-
const restoreCheckpoint = this.props.failurePolicy === 'rollback'
|
|
795
|
-
? this.ensembleBuffer
|
|
796
|
-
? 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)
|
|
797
|
-
: addRigidBodyCheckpoint(graph, this.id, [
|
|
798
|
-
'positions',
|
|
799
|
-
'orientations',
|
|
800
|
-
'velocities',
|
|
801
|
-
'angularVelocities',
|
|
802
|
-
'sleepStates',
|
|
803
|
-
'targets',
|
|
804
|
-
...(this.ensembleBuffer ? [] : ['manifolds'])
|
|
805
|
-
].map(name => {
|
|
806
|
-
const binding = bindings.find(binding => binding.name === name);
|
|
807
|
-
return { buffer: binding.buffer, resource: binding.resource };
|
|
808
|
-
}), { buffer: this.simulationStatistics, resource: statisticsResource }, allocate)
|
|
809
|
-
: undefined;
|
|
810
960
|
const continuousSelection = new Uint32Array(this.count);
|
|
811
961
|
for (const body of this.props.continuous?.bodies ?? [])
|
|
812
962
|
continuousSelection[body] = this.colliders.findIndex(collider => collider.body === body) + 1;
|
|
@@ -824,6 +974,8 @@ export class GPURigidBodyWorld {
|
|
|
824
974
|
}, allocate, Boolean(this.props.joints?.length), extended)
|
|
825
975
|
: undefined;
|
|
826
976
|
this.triggerEvents = triggers?.events ?? null;
|
|
977
|
+
if (triggers && triggerLayout)
|
|
978
|
+
this.triggerHistory = { buffer: triggers.history, groups: triggerLayout.groups };
|
|
827
979
|
const passDescriptions = {
|
|
828
980
|
integrate: 'Apply gravity and advance body velocities and predicted poses for this timestep.',
|
|
829
981
|
prepare: 'Reset broad-phase counters before generating potential collider pairs.',
|
|
@@ -847,45 +999,67 @@ export class GPURigidBodyWorld {
|
|
|
847
999
|
parallelMarkSleep: 'Identify islands whose bodies are quiet enough to sleep.',
|
|
848
1000
|
parallelSleep: 'Put quiet constraint islands to sleep.'
|
|
849
1001
|
};
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
vehicle.springRate,
|
|
857
|
-
vehicle.damping,
|
|
858
|
-
vehicle.grip,
|
|
859
|
-
vehicle.motorTorque,
|
|
860
|
-
vehicle.brakeTorque,
|
|
861
|
-
vehicle.wheelInertia
|
|
862
|
-
], 4);
|
|
863
|
-
new Uint32Array(data.buffer).set([vehicle.chassis, vehicle.terrainCollider], 12);
|
|
864
|
-
vehicle.wheels.forEach((wheel, index) => {
|
|
865
|
-
const offset = 16 + index * 12;
|
|
866
|
-
data.set(wheel.mount, offset);
|
|
867
|
-
data.set([Number(Boolean(wheel.steer)), Number(Boolean(wheel.drive))], offset + 4);
|
|
868
|
-
data[offset + 10] = vehicle.travel;
|
|
1002
|
+
let vehicleResource;
|
|
1003
|
+
let addVehiclePass;
|
|
1004
|
+
if (this.vehicles.length) {
|
|
1005
|
+
const packed = new Float32Array(this.getVehicleByteLength() / 4);
|
|
1006
|
+
for (const [vehicleIndex, vehicle] of this.vehicles.entries()) {
|
|
1007
|
+
const data = packed.subarray((vehicleIndex * VEHICLE_STRIDE) / 4, ((vehicleIndex + 1) * VEHICLE_STRIDE) / 4);
|
|
869
1008
|
data.set([
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
wheel.mount
|
|
885
|
-
1
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
1009
|
+
vehicle.radius,
|
|
1010
|
+
vehicle.travel,
|
|
1011
|
+
vehicle.springRate,
|
|
1012
|
+
vehicle.damping,
|
|
1013
|
+
vehicle.grip,
|
|
1014
|
+
vehicle.motorTorque,
|
|
1015
|
+
vehicle.brakeTorque,
|
|
1016
|
+
vehicle.wheelInertia
|
|
1017
|
+
], 4);
|
|
1018
|
+
new Uint32Array(data.buffer, data.byteOffset, data.length).set([vehicle.chassis, vehicle.terrainCollider], 12);
|
|
1019
|
+
data.set([vehicle.steeringWheelbase ?? 0, vehicle.antiRollRate ?? 0], 14);
|
|
1020
|
+
const [longitudinalGain, lateralGain] = vehicle.slipGain ?? [1.1, 1.5];
|
|
1021
|
+
vehicle.wheels.forEach((wheel, index) => {
|
|
1022
|
+
const offset = 16 + index * 12;
|
|
1023
|
+
data.set([...wheel.mount, longitudinalGain + 1], offset);
|
|
1024
|
+
data.set([Number(Boolean(wheel.steer)), Number(Boolean(wheel.drive)), lateralGain + 1], offset + 4);
|
|
1025
|
+
data[offset + 10] = vehicle.travel;
|
|
1026
|
+
data.set([
|
|
1027
|
+
1,
|
|
1028
|
+
0,
|
|
1029
|
+
0,
|
|
1030
|
+
0,
|
|
1031
|
+
0,
|
|
1032
|
+
1,
|
|
1033
|
+
0,
|
|
1034
|
+
0,
|
|
1035
|
+
0,
|
|
1036
|
+
0,
|
|
1037
|
+
1,
|
|
1038
|
+
0,
|
|
1039
|
+
wheel.mount[0],
|
|
1040
|
+
wheel.mount[1],
|
|
1041
|
+
wheel.mount[2] - vehicle.travel,
|
|
1042
|
+
1
|
|
1043
|
+
], 64 + 16 * index);
|
|
1044
|
+
});
|
|
1045
|
+
}
|
|
1046
|
+
if (this.multiSurfaceVehicles) {
|
|
1047
|
+
// Place the immutable terrain rows after the unchanged vehicle pose/telemetry ranges.
|
|
1048
|
+
const terrainRows = new Uint32Array(packed.buffer, this.vehicles.length * VEHICLE_STRIDE);
|
|
1049
|
+
terrainRows.fill(0xffffffff);
|
|
1050
|
+
for (const [vehicleIndex, vehicle] of this.vehicles.entries())
|
|
1051
|
+
terrainRows.set(vehicle.additionalTerrainColliders ?? [], vehicleIndex * (VEHICLE_TERRAIN_ROW_SIZE / 4));
|
|
1052
|
+
}
|
|
1053
|
+
this.vehicleBuffer = allocate('vehicle', packed);
|
|
1054
|
+
vehicleResource = {
|
|
1055
|
+
buffer: this.vehicleBuffer,
|
|
1056
|
+
resource: graph.importBuffer({
|
|
1057
|
+
id: this.id + '-vehicle',
|
|
1058
|
+
byteLength: packed.byteLength,
|
|
1059
|
+
usage: Buffer.STORAGE | Buffer.COPY_SRC
|
|
1060
|
+
}, this.vehicleBuffer)
|
|
1061
|
+
};
|
|
1062
|
+
const ensembleBinding = bindings.find(binding => binding.name === 'ensemble');
|
|
889
1063
|
const vehicleBindings = [
|
|
890
1064
|
...bindings.filter(binding => [
|
|
891
1065
|
'settings',
|
|
@@ -894,18 +1068,16 @@ export class GPURigidBodyWorld {
|
|
|
894
1068
|
'velocities',
|
|
895
1069
|
'angularVelocities',
|
|
896
1070
|
'bodies',
|
|
897
|
-
'sleepStates'
|
|
1071
|
+
'sleepStates',
|
|
1072
|
+
'ensemble'
|
|
898
1073
|
].includes(binding.name)),
|
|
899
|
-
{
|
|
900
|
-
name: 'vehicle',
|
|
901
|
-
location: 12,
|
|
902
|
-
buffer: this.vehicleBuffer,
|
|
903
|
-
resource: graph.importBuffer({ id: this.id + '-vehicle', byteLength: data.byteLength, usage: Buffer.STORAGE }, this.vehicleBuffer)
|
|
904
|
-
}
|
|
1074
|
+
{ name: 'vehicle', location: 12, ...vehicleResource }
|
|
905
1075
|
];
|
|
906
1076
|
const properties = {
|
|
907
1077
|
id: this.id + '-suspension',
|
|
908
|
-
source: source +
|
|
1078
|
+
source: readOnlyEnsembleShader(source) +
|
|
1079
|
+
RIGID_BODY_QUERY_GEOMETRY_SHADER +
|
|
1080
|
+
getVehicleShader(this.vehicles.length, this.multiSurfaceVehicles, this.vehiclesPerInstance),
|
|
909
1081
|
entryPoint: 'advanceVehicle',
|
|
910
1082
|
shaderLayout: {
|
|
911
1083
|
bindings: vehicleBindings.map(({ name, location }) => name === 'settings'
|
|
@@ -914,31 +1086,70 @@ export class GPURigidBodyWorld {
|
|
|
914
1086
|
name,
|
|
915
1087
|
location,
|
|
916
1088
|
group: 0,
|
|
917
|
-
type: name === 'bodies' ? 'read-only-storage' : 'storage'
|
|
1089
|
+
type: name === 'bodies' || name === 'ensemble' ? 'read-only-storage' : 'storage'
|
|
918
1090
|
})
|
|
919
1091
|
}
|
|
920
1092
|
};
|
|
921
1093
|
const executable = (computation) => ({
|
|
922
1094
|
encode: ({ computePass, getBuffer }) => {
|
|
923
1095
|
Object.assign(computation.bindings, Object.fromEntries(vehicleBindings.map(binding => [binding.name, getBuffer(binding.resource)])));
|
|
924
|
-
|
|
1096
|
+
if (ensembleBinding)
|
|
1097
|
+
computation.kernel.dispatchIndirect(computePass, {
|
|
1098
|
+
bindings: computation.bindings,
|
|
1099
|
+
indirectBuffer: getBuffer(ensembleBinding.resource),
|
|
1100
|
+
indirectOffset: 16
|
|
1101
|
+
});
|
|
1102
|
+
else
|
|
1103
|
+
computation.kernel.dispatch(computePass, {
|
|
1104
|
+
bindings: computation.bindings,
|
|
1105
|
+
x: this.vehicles.length
|
|
1106
|
+
});
|
|
925
1107
|
},
|
|
926
1108
|
destroy: () => computation.kernel.destroy()
|
|
927
1109
|
});
|
|
928
|
-
graph.addComputePass({
|
|
1110
|
+
addVehiclePass = () => graph.addComputePass({
|
|
929
1111
|
id: properties.id,
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
: binding.name === '
|
|
935
|
-
? '
|
|
936
|
-
: '
|
|
937
|
-
|
|
1112
|
+
description: 'Sweep four wheels and apply suspension and tire forces per chassis.',
|
|
1113
|
+
resources: [
|
|
1114
|
+
...vehicleBindings.map(binding => ({
|
|
1115
|
+
buffer: binding.resource,
|
|
1116
|
+
usage: binding.name === 'settings'
|
|
1117
|
+
? 'uniform'
|
|
1118
|
+
: binding.name === 'bodies' || binding.name === 'ensemble'
|
|
1119
|
+
? 'storage-read'
|
|
1120
|
+
: 'storage-read-write'
|
|
1121
|
+
})),
|
|
1122
|
+
...(ensembleBinding
|
|
1123
|
+
? [{ buffer: ensembleBinding.resource, usage: 'indirect' }]
|
|
1124
|
+
: [])
|
|
1125
|
+
],
|
|
938
1126
|
compile: () => executable(createBoundKernel(graph.device, properties)),
|
|
939
1127
|
compileAsync: async () => executable(await createBoundKernelAsync(graph.device, properties))
|
|
940
1128
|
});
|
|
941
1129
|
}
|
|
1130
|
+
const checkpointStates = [
|
|
1131
|
+
'positions',
|
|
1132
|
+
'orientations',
|
|
1133
|
+
'velocities',
|
|
1134
|
+
'angularVelocities',
|
|
1135
|
+
'sleepStates',
|
|
1136
|
+
'targets'
|
|
1137
|
+
].map(name => {
|
|
1138
|
+
const binding = bindings.find(binding => binding.name === name);
|
|
1139
|
+
return { buffer: binding.buffer, resource: binding.resource };
|
|
1140
|
+
});
|
|
1141
|
+
const restoreCheckpoint = this.props.failurePolicy === 'rollback'
|
|
1142
|
+
? this.ensembleBuffer
|
|
1143
|
+
? 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 && {
|
|
1144
|
+
state: vehicleResource,
|
|
1145
|
+
vehiclesPerInstance: this.vehiclesPerInstance
|
|
1146
|
+
}, this.props.ensemblePairsPerInstance)
|
|
1147
|
+
: addRigidBodyCheckpoint(graph, this.id, [
|
|
1148
|
+
...checkpointStates,
|
|
1149
|
+
bindings.find(binding => binding.name === 'manifolds'),
|
|
1150
|
+
...(vehicleResource ? [vehicleResource] : [])
|
|
1151
|
+
], { buffer: this.simulationStatistics, resource: statisticsResource }, allocate)
|
|
1152
|
+
: undefined;
|
|
942
1153
|
for (const entryPoint of [
|
|
943
1154
|
...(this.ensembleBuffer
|
|
944
1155
|
? ['ensembleClear', 'ensembleMark', 'ensembleCompact', 'ensembleDispatch']
|
|
@@ -977,8 +1188,10 @@ export class GPURigidBodyWorld {
|
|
|
977
1188
|
]
|
|
978
1189
|
: [...(extended && this.props.joints?.length ? ['meshCollect'] : []), 'solve', 'finish'])
|
|
979
1190
|
]) {
|
|
980
|
-
if (entryPoint === 'integrate')
|
|
1191
|
+
if (entryPoint === 'integrate') {
|
|
981
1192
|
restoreCheckpoint?.save?.();
|
|
1193
|
+
addVehiclePass?.();
|
|
1194
|
+
}
|
|
982
1195
|
if (sparse && entryPoint === 'collide') {
|
|
983
1196
|
const bodyBinding = bindings.find(binding => binding.name === 'bodies');
|
|
984
1197
|
const minimumBinding = bindings.find(binding => binding.name === 'minima');
|
|
@@ -1341,7 +1554,12 @@ export class GPURigidBodyWorld {
|
|
|
1341
1554
|
});
|
|
1342
1555
|
restoreCheckpoint?.restore();
|
|
1343
1556
|
if (this.ensembleBuffer)
|
|
1344
|
-
addEnsembleStatus(graph, this.id, this.count / this.props.ensembleBodiesPerInstance, this.props.ensembleBodiesPerInstance, diagnosticBinding('bodies'), diagnosticBinding('sleepStates'), diagnosticBinding('ensemble'), { buffer: this.simulationStatistics, resource: statisticsResource }
|
|
1557
|
+
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
|
|
1558
|
+
? {
|
|
1559
|
+
...diagnosticBinding('targets'),
|
|
1560
|
+
wordOffset: getEnsembleContactLayout(this.count, this.count / this.props.ensembleBodiesPerInstance, this.maximumPairs, true).failureOffset
|
|
1561
|
+
}
|
|
1562
|
+
: undefined);
|
|
1345
1563
|
triggers?.publish();
|
|
1346
1564
|
if (this.props.publicationBounds || this.props.publishPoses) {
|
|
1347
1565
|
const publication = addRigidBodyPosePublication(graph, this.id, this.props.bodies, this.props.publicationBounds ??
|
|
@@ -1355,6 +1573,7 @@ export class GPURigidBodyWorld {
|
|
|
1355
1573
|
}
|
|
1356
1574
|
if (this.props.eventCapacity) {
|
|
1357
1575
|
const contactHistory = allocate('contact-history', this.maximumPairs * 16);
|
|
1576
|
+
this.contactHistory = contactHistory;
|
|
1358
1577
|
this.contactEvents = allocate('contact-events', 16 + this.props.eventCapacity * 64);
|
|
1359
1578
|
const eventBindings = [
|
|
1360
1579
|
...bindings.filter(binding => ['bodies', 'manifolds', 'ensemble'].includes(binding.name)),
|
|
@@ -1380,40 +1599,23 @@ export class GPURigidBodyWorld {
|
|
|
1380
1599
|
}, binding.buffer)
|
|
1381
1600
|
}))
|
|
1382
1601
|
];
|
|
1383
|
-
|
|
1602
|
+
/** The classify and scatter passes use the same committed manifold and history buffers. */
|
|
1603
|
+
const contactResources = eventBindings.map(({ name, resource, location }) => ({
|
|
1604
|
+
name,
|
|
1605
|
+
resource,
|
|
1606
|
+
location,
|
|
1607
|
+
readOnly: name === 'bodies' || name === 'eventStatistics'
|
|
1608
|
+
}));
|
|
1609
|
+
addRigidBodyEventCompaction(graph, {
|
|
1384
1610
|
id: `${this.id}-contact-events`,
|
|
1611
|
+
rowCount: this.maximumPairs,
|
|
1612
|
+
capacity: this.props.eventCapacity,
|
|
1613
|
+
ring: 'contactEvents',
|
|
1385
1614
|
source: source +
|
|
1386
|
-
getRigidBodyEventShader(this.props.eventCapacity, this.props.impactImpulseThreshold ?? 1, this.props.failurePolicy === 'rollback'),
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
name,
|
|
1391
|
-
location,
|
|
1392
|
-
group: 0,
|
|
1393
|
-
type: ['bodies', 'eventStatistics'].includes(name)
|
|
1394
|
-
? 'read-only-storage'
|
|
1395
|
-
: 'storage'
|
|
1396
|
-
}))
|
|
1397
|
-
}
|
|
1398
|
-
};
|
|
1399
|
-
const executable = (computation) => ({
|
|
1400
|
-
encode: ({ computePass, getBuffer }) => {
|
|
1401
|
-
Object.assign(computation.bindings, Object.fromEntries(eventBindings.map(binding => [binding.name, getBuffer(binding.resource)])));
|
|
1402
|
-
computation.kernel.dispatch(computePass, { bindings: computation.bindings, x: 1 });
|
|
1403
|
-
},
|
|
1404
|
-
destroy: () => computation.kernel.destroy()
|
|
1405
|
-
});
|
|
1406
|
-
graph.addComputePass({
|
|
1407
|
-
id: properties.id,
|
|
1408
|
-
description: 'Compare contact history and publish contact begin, persist, and end events.',
|
|
1409
|
-
resources: eventBindings.map(binding => ({
|
|
1410
|
-
buffer: binding.resource,
|
|
1411
|
-
usage: ['bodies', 'eventStatistics'].includes(binding.name)
|
|
1412
|
-
? 'storage-read'
|
|
1413
|
-
: 'storage-read-write'
|
|
1414
|
-
})),
|
|
1415
|
-
compile: () => executable(createBoundKernel(graph.device, properties)),
|
|
1416
|
-
compileAsync: async () => executable(await createBoundKernelAsync(graph.device, properties))
|
|
1615
|
+
getRigidBodyEventShader(this.props.eventCapacity, this.props.impactImpulseThreshold ?? 1, this.props.failurePolicy === 'rollback', this.props.ensemblePairsPerInstance),
|
|
1616
|
+
classify: contactResources.filter(binding => !['bodies', 'contactEvents'].includes(binding.name)),
|
|
1617
|
+
commit: contactResources.filter(binding => ['eventStatistics', 'contactEvents'].includes(binding.name)),
|
|
1618
|
+
publish: contactResources.filter(binding => !['eventStatistics', 'ensemble'].includes(binding.name))
|
|
1417
1619
|
});
|
|
1418
1620
|
}
|
|
1419
1621
|
if (this.props.enableQueries) {
|
|
@@ -1454,6 +1656,46 @@ export class GPURigidBodyWorld {
|
|
|
1454
1656
|
queryOutput: this.queryOutput
|
|
1455
1657
|
}
|
|
1456
1658
|
});
|
|
1659
|
+
if (this.props.queryBatchCapacity) {
|
|
1660
|
+
/** Fixed staging capacity keeps query dispatch independent of simulation allocations. */
|
|
1661
|
+
const capacity = this.props.queryBatchCapacity;
|
|
1662
|
+
this.batchCastCommands = allocate('query-batch-commands', capacity * RIGID_BODY_CAST_COMMAND_BYTES);
|
|
1663
|
+
this.batchCastResults = allocate('query-batch-results', capacity * RIGID_BODY_BATCH_RESULT_BYTES);
|
|
1664
|
+
/** Share external bindings between the scan and the indexed query graph. */
|
|
1665
|
+
const batchBindings = {
|
|
1666
|
+
positions: this.positions,
|
|
1667
|
+
orientations: this.orientations,
|
|
1668
|
+
bodies,
|
|
1669
|
+
querySelection: this.querySelection,
|
|
1670
|
+
batchCommands: this.batchCastCommands,
|
|
1671
|
+
batchResults: this.batchCastResults
|
|
1672
|
+
};
|
|
1673
|
+
/** Batch commands and results use storage bindings, shared by both strategies. */
|
|
1674
|
+
const batchLayout = [
|
|
1675
|
+
...queryProperties.shaderLayout.bindings.filter(binding => ['positions', 'orientations', 'bodies', 'querySelection'].includes(binding.name)),
|
|
1676
|
+
{ name: 'batchCommands', group: 0, location: 30, type: 'read-only-storage' },
|
|
1677
|
+
{ name: 'batchResults', group: 0, location: 31, type: 'storage' }
|
|
1678
|
+
];
|
|
1679
|
+
this.batchCast = createBoundKernel(graph.device, {
|
|
1680
|
+
id: `${this.id}-batched-casts`,
|
|
1681
|
+
entryPoint: 'castBatch',
|
|
1682
|
+
source: queryProperties.source + getRigidBodyBatchCastShader(),
|
|
1683
|
+
shaderLayout: { bindings: batchLayout },
|
|
1684
|
+
bindings: batchBindings
|
|
1685
|
+
});
|
|
1686
|
+
if (this.props.queryBatchIndex && this.colliderCount) {
|
|
1687
|
+
this.batchCastOrder = getRigidBodyCastOrder(this.colliders, this.props.bodies);
|
|
1688
|
+
if (this.batchCastOrder.indexedCount) {
|
|
1689
|
+
this.batchCastIndex = createRigidBodyCastIndex(graph.device, {
|
|
1690
|
+
id: `${this.id}-cast-index`,
|
|
1691
|
+
source: queryProperties.source,
|
|
1692
|
+
layout: batchLayout,
|
|
1693
|
+
buffers: batchBindings,
|
|
1694
|
+
indexedCount: this.batchCastOrder.indexedCount
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1457
1699
|
}
|
|
1458
1700
|
this.controlSettings = allocate('control-settings', 64, true);
|
|
1459
1701
|
const controlProperties = {
|
|
@@ -1533,6 +1775,48 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1533
1775
|
},
|
|
1534
1776
|
bindings: Object.fromEntries(Object.entries(controlProperties.bindings).filter(([name]) => invalidationBindings.includes(name)))
|
|
1535
1777
|
});
|
|
1778
|
+
if (this.heightFieldSlots.size && !this.ensembleBuffer) {
|
|
1779
|
+
this.terrainWake = createBoundKernel(graph.device, {
|
|
1780
|
+
id: `${this.id}-terrain-wake`,
|
|
1781
|
+
entryPoint: 'wakeTerrain',
|
|
1782
|
+
source: controlProperties.source +
|
|
1783
|
+
/* wgsl */ `
|
|
1784
|
+
@group(0) @binding(26) var<storage,read_write> terrainSleep:array<atomic<u32>>;
|
|
1785
|
+
@compute @workgroup_size(64) fn wakeTerrain(@builtin(global_invocation_id) invocation:vec3u) {
|
|
1786
|
+
let collider=invocation.x;if(collider>=COLLIDER_COUNT){return;}
|
|
1787
|
+
let body=colliderBody(collider);if(!dynamic(body)){return;}
|
|
1788
|
+
let tile=command.bodyIndex.x;if(bodies.colliders[tile].padding.w==0.0){return;}
|
|
1789
|
+
if(any(abs(colliderPosition(collider)-colliderPosition(tile))>shapeWorldExtent(collider)+shapeWorldExtent(tile)+vec3f(settings.solver.x))){return;}
|
|
1790
|
+
// Several colliders on one sleeping body may all overlap the tile.
|
|
1791
|
+
for(var axis=0u;axis<4u;axis++){atomicStore(&terrainSleep[body*4u+axis],0u);}
|
|
1792
|
+
}`,
|
|
1793
|
+
shaderLayout: {
|
|
1794
|
+
bindings: [
|
|
1795
|
+
...shaderLayout.bindings.filter(binding => ['settings', 'positions', 'orientations', 'bodies'].includes(binding.name)),
|
|
1796
|
+
{ name: 'command', group: 0, location: 8, type: 'uniform' },
|
|
1797
|
+
{ name: 'terrainSleep', group: 0, location: 26, type: 'storage' }
|
|
1798
|
+
]
|
|
1799
|
+
},
|
|
1800
|
+
bindings: {
|
|
1801
|
+
settings: buffers.settings,
|
|
1802
|
+
positions: buffers.positions,
|
|
1803
|
+
orientations: buffers.orientations,
|
|
1804
|
+
bodies: buffers.bodies,
|
|
1805
|
+
command: this.controlSettings,
|
|
1806
|
+
terrainSleep: this.sleepStates
|
|
1807
|
+
}
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
/** Wake sleeping bodies overlapping one published terrain footprint. */
|
|
1812
|
+
wakeTerrainFootprint(collider) {
|
|
1813
|
+
const { kernel, bindings } = this.terrainWake;
|
|
1814
|
+
this.controlSettings.write(new Uint32Array([collider]), 48);
|
|
1815
|
+
const encoder = this.device.createCommandEncoder();
|
|
1816
|
+
const pass = encoder.beginComputePass();
|
|
1817
|
+
kernel.dispatch(pass, { bindings, x: Math.ceil(this.colliderStorageCount / 64) });
|
|
1818
|
+
pass.end();
|
|
1819
|
+
this.device.submit(encoder.finish());
|
|
1536
1820
|
}
|
|
1537
1821
|
invalidateState(pass) {
|
|
1538
1822
|
// Controls may wake any island; reclassify enabled instances on the next GPU step.
|
|
@@ -1550,7 +1834,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1550
1834
|
}
|
|
1551
1835
|
/** Rebase between submissions, preserving velocities, contact impulses and sleeping state. */
|
|
1552
1836
|
shiftOrigin(shift) {
|
|
1553
|
-
if (!this.device || this.destroyed || this.queryPending || this.
|
|
1837
|
+
if (!this.device || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
1554
1838
|
throw new Error('Origin shifting requires an idle attached world');
|
|
1555
1839
|
// Exact float32 shifts keep the CPU origin and GPU subtraction consistent.
|
|
1556
1840
|
if (shift.length !== 3 ||
|
|
@@ -1570,65 +1854,80 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1570
1854
|
: undefined;
|
|
1571
1855
|
}
|
|
1572
1856
|
/** Set signed throttle, steering angle in radians and brake fraction for upcoming substeps. */
|
|
1573
|
-
setVehicleControls(throttle, steering, brake) {
|
|
1857
|
+
setVehicleControls(throttle, steering, brake, vehicleIndex = 0) {
|
|
1574
1858
|
if (!this.vehicleBuffer ||
|
|
1575
1859
|
this.destroyed ||
|
|
1576
|
-
![
|
|
1860
|
+
!this.vehicles[vehicleIndex] ||
|
|
1861
|
+
![throttle, steering, brake].every(value => Number.isFinite(Math.fround(value))))
|
|
1577
1862
|
throw new Error('Invalid vehicle controls');
|
|
1578
1863
|
this.vehicleBuffer.write(new Float32Array([
|
|
1579
1864
|
Math.max(-1, Math.min(1, throttle)),
|
|
1580
1865
|
steering,
|
|
1581
1866
|
Math.max(0, Math.min(1, brake)),
|
|
1582
1867
|
0
|
|
1583
|
-
]));
|
|
1868
|
+
]), vehicleIndex * VEHICLE_STRIDE);
|
|
1869
|
+
if (this.vehiclesPerInstance) {
|
|
1870
|
+
const instance = Math.floor(vehicleIndex / this.vehiclesPerInstance);
|
|
1871
|
+
this.ensembleBuffer.write(new Uint32Array([1]), (16 + instance * 8 + 6) * 4);
|
|
1872
|
+
}
|
|
1584
1873
|
}
|
|
1585
1874
|
/** Borrow four column-major wheel transforms relative to the chassis node, ordered by mount. */
|
|
1586
1875
|
get vehicleWheelPoses() {
|
|
1587
|
-
return this.
|
|
1588
|
-
|
|
1876
|
+
return this.getVehicleWheelPoses();
|
|
1877
|
+
}
|
|
1878
|
+
/** Borrow the indexed vehicle’s four chassis-local wheel poses, in mount order. */
|
|
1879
|
+
getVehicleWheelPoses(vehicleIndex = 0) {
|
|
1880
|
+
return this.vehicleBuffer && !this.destroyed && this.vehicles[vehicleIndex]
|
|
1881
|
+
? {
|
|
1882
|
+
buffer: this.vehicleBuffer,
|
|
1883
|
+
byteOffset: vehicleIndex * VEHICLE_STRIDE + 256,
|
|
1884
|
+
byteLength: 256
|
|
1885
|
+
}
|
|
1589
1886
|
: null;
|
|
1590
1887
|
}
|
|
1591
1888
|
/** Transfer wheel motion between rebuilt worlds for wheels with matching chassis-local mounts. */
|
|
1592
|
-
copyVehicleMotionFrom(previous) {
|
|
1889
|
+
copyVehicleMotionFrom(previous, vehicleIndex = 0, previousVehicleIndex = 0) {
|
|
1593
1890
|
const sourceBuffer = previous.vehicleBuffer;
|
|
1594
1891
|
const destinationBuffer = this.vehicleBuffer;
|
|
1595
|
-
const previousVehicle = previous.
|
|
1892
|
+
const previousVehicle = previous.vehicles[previousVehicleIndex];
|
|
1596
1893
|
if (!this.device || !sourceBuffer || !destinationBuffer || !previousVehicle)
|
|
1597
1894
|
return;
|
|
1598
1895
|
const encoder = this.device.createCommandEncoder();
|
|
1599
|
-
this.
|
|
1896
|
+
this.vehicles[vehicleIndex]?.wheels.forEach((wheel, index) => {
|
|
1600
1897
|
const sourceIndex = previousVehicle.wheels.findIndex(source => source.mount.every((coordinate, axis) => coordinate === wheel.mount[axis]));
|
|
1601
1898
|
if (sourceIndex < 0)
|
|
1602
1899
|
return;
|
|
1603
1900
|
encoder.copyBufferToBuffer({
|
|
1604
1901
|
sourceBuffer,
|
|
1605
1902
|
destinationBuffer,
|
|
1606
|
-
sourceOffset:
|
|
1607
|
-
destinationOffset:
|
|
1608
|
-
size:
|
|
1903
|
+
sourceOffset: previousVehicleIndex * VEHICLE_STRIDE + 92 + sourceIndex * 48,
|
|
1904
|
+
destinationOffset: vehicleIndex * VEHICLE_STRIDE + 92 + index * 48,
|
|
1905
|
+
size: 20
|
|
1609
1906
|
});
|
|
1610
1907
|
encoder.copyBufferToBuffer({
|
|
1611
1908
|
sourceBuffer,
|
|
1612
1909
|
destinationBuffer,
|
|
1613
|
-
sourceOffset: 256 + sourceIndex * 64,
|
|
1614
|
-
destinationOffset: 256 + index * 64,
|
|
1910
|
+
sourceOffset: previousVehicleIndex * VEHICLE_STRIDE + 256 + sourceIndex * 64,
|
|
1911
|
+
destinationOffset: vehicleIndex * VEHICLE_STRIDE + 256 + index * 64,
|
|
1615
1912
|
size: 64
|
|
1616
1913
|
});
|
|
1617
1914
|
});
|
|
1618
1915
|
this.device.submit(encoder.finish());
|
|
1619
1916
|
}
|
|
1620
1917
|
/** Read wheel spin, angle, suspension length and normal load after submitted steps. */
|
|
1621
|
-
async readVehicleWheels() {
|
|
1622
|
-
if (!this.vehicleBuffer || this.destroyed)
|
|
1918
|
+
async readVehicleWheels(vehicleIndex = 0) {
|
|
1919
|
+
if (!this.vehicleBuffer || this.destroyed || !this.vehicles[vehicleIndex])
|
|
1623
1920
|
throw new Error('Vehicle unavailable');
|
|
1624
|
-
const
|
|
1921
|
+
const bytes = await this.vehicleBuffer.readAsync(vehicleIndex * VEHICLE_STRIDE, 256);
|
|
1922
|
+
const values = new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
1625
1923
|
return Array.from({ length: 4 }, (_, index) => {
|
|
1626
1924
|
const offset = 24 + index * 12;
|
|
1627
1925
|
return {
|
|
1628
1926
|
speed: values[offset],
|
|
1629
1927
|
angle: values[offset + 1],
|
|
1630
1928
|
length: values[offset + 2],
|
|
1631
|
-
load: values[offset + 3]
|
|
1929
|
+
load: values[offset + 3],
|
|
1930
|
+
steering: values[offset - 1]
|
|
1632
1931
|
};
|
|
1633
1932
|
});
|
|
1634
1933
|
}
|
|
@@ -1699,6 +1998,17 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1699
1998
|
metadata.write(data);
|
|
1700
1999
|
this.props.publicationBounds = structuredClone(bounds);
|
|
1701
2000
|
}
|
|
2001
|
+
/** Read the authored collider frame relative to its body's node origin, excluding COM offset. */
|
|
2002
|
+
getColliderTransform(colliderIndex) {
|
|
2003
|
+
/** This frame is metadata, so reading it does not synchronize the device. */
|
|
2004
|
+
const collider = this.colliders[colliderIndex];
|
|
2005
|
+
if (!Number.isInteger(colliderIndex) || !collider || this.destroyed)
|
|
2006
|
+
throw new Error('Invalid collider');
|
|
2007
|
+
return {
|
|
2008
|
+
position: [...(collider.position ?? [0, 0, 0])],
|
|
2009
|
+
orientation: normalizeRigidBodyRotation(collider.orientation)
|
|
2010
|
+
};
|
|
2011
|
+
}
|
|
1702
2012
|
/** Applied scale relative to the initially cooked analytic shape. */
|
|
1703
2013
|
getColliderShapeScale(colliderIndex) {
|
|
1704
2014
|
this.getColliderShape(colliderIndex);
|
|
@@ -1729,7 +2039,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1729
2039
|
if (indices.has(edit.collider) ||
|
|
1730
2040
|
previous.type !== shape.type ||
|
|
1731
2041
|
shape.type === 'convex-hull' ||
|
|
1732
|
-
shape.type === 'triangle-mesh'
|
|
2042
|
+
shape.type === 'triangle-mesh' ||
|
|
2043
|
+
shape.type === 'height-field')
|
|
1733
2044
|
throw new Error('Shape edit requires a topology rebuild');
|
|
1734
2045
|
indices.add(edit.collider);
|
|
1735
2046
|
const properties = getRigidBodyShapeProperties(shape);
|
|
@@ -1763,6 +2074,103 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1763
2074
|
this.setBodyParameters(body, {});
|
|
1764
2075
|
}
|
|
1765
2076
|
}
|
|
2077
|
+
/**
|
|
2078
|
+
* Replace or evict fixed-dimension height-field tiles between submissions.
|
|
2079
|
+
* Optional positions are in each collider's body-local frame. The caller owns
|
|
2080
|
+
* tile selection and must submit already encoded steps before editing residency.
|
|
2081
|
+
*/
|
|
2082
|
+
setHeightFieldTiles(edits) {
|
|
2083
|
+
if (!edits.length)
|
|
2084
|
+
return;
|
|
2085
|
+
const metadata = this.ownedBuffers.find(buffer => buffer.id === `${this.id}-bodies`);
|
|
2086
|
+
if (!metadata || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
2087
|
+
throw new Error('Terrain streaming requires an idle attached world');
|
|
2088
|
+
const seen = new Set();
|
|
2089
|
+
const packedFields = this.terrainAtlas
|
|
2090
|
+
? new Map()
|
|
2091
|
+
: undefined;
|
|
2092
|
+
const replacements = edits.map(({ collider: colliderIndex, field, position }) => {
|
|
2093
|
+
const collider = this.colliders[colliderIndex];
|
|
2094
|
+
const offset = this.heightFieldSlots.get(colliderIndex);
|
|
2095
|
+
if ((offset === undefined &&
|
|
2096
|
+
!(this.terrainAtlas && this.ensembleTerrainSlots.has(colliderIndex))) ||
|
|
2097
|
+
collider?.shape.type !== 'height-field' ||
|
|
2098
|
+
seen.has(colliderIndex))
|
|
2099
|
+
throw new Error('Invalid writable height-field slot');
|
|
2100
|
+
seen.add(colliderIndex);
|
|
2101
|
+
const previous = collider.shape.field;
|
|
2102
|
+
if (field && (field.width !== previous.width || field.height !== previous.height))
|
|
2103
|
+
throw new Error('Height-field slot dimensions are fixed');
|
|
2104
|
+
const center = this.props.bodies[collider.body].centerOfMass ?? [0, 0, 0];
|
|
2105
|
+
const localOffset = position?.map((value, axis) => value - center[axis]);
|
|
2106
|
+
if (position &&
|
|
2107
|
+
(position.length !== 3 || !localOffset?.every(value => Number.isFinite(Math.fround(value)))))
|
|
2108
|
+
throw new Error('Invalid height-field tile position');
|
|
2109
|
+
let payload = field ? packedFields?.get(field) : undefined;
|
|
2110
|
+
if (!payload) {
|
|
2111
|
+
const next = field
|
|
2112
|
+
? structuredClone(field)
|
|
2113
|
+
: { ...previous, heights: undefined, validity: undefined };
|
|
2114
|
+
const packed = packRigidBodyHeightField(next);
|
|
2115
|
+
const data = packedFields && packed.nodeCount ? new Float32Array(packed.data) : null;
|
|
2116
|
+
payload = { field: next, packed, data };
|
|
2117
|
+
if (field)
|
|
2118
|
+
packedFields?.set(field, payload);
|
|
2119
|
+
}
|
|
2120
|
+
return { collider, colliderIndex, offset, position, localOffset, ...payload };
|
|
2121
|
+
});
|
|
2122
|
+
const atlas = this.terrainAtlas?.bind(replacements.map(({ colliderIndex, data }) => ({ collider: colliderIndex, data })));
|
|
2123
|
+
// Stamp once per validated edit batch. On float32 counter wrap, clear old impulses
|
|
2124
|
+
// so a retained contact cannot confuse a new stamp with a very old revision.
|
|
2125
|
+
if (this.terrainRevision === 0xffffff) {
|
|
2126
|
+
this.wake();
|
|
2127
|
+
this.terrainRevision = 1;
|
|
2128
|
+
}
|
|
2129
|
+
const revision = ++this.terrainRevision;
|
|
2130
|
+
for (const { word, data } of atlas?.uploads ?? [])
|
|
2131
|
+
metadata.write(data, (this.terrainAtlasWord + word) * 4);
|
|
2132
|
+
const changedBodies = new Set();
|
|
2133
|
+
const affectedInstances = new Set();
|
|
2134
|
+
for (const replacement of replacements) {
|
|
2135
|
+
const { collider, colliderIndex, offset, field, position, localOffset, packed } = replacement;
|
|
2136
|
+
const base = this.count * 48 + colliderIndex * 96;
|
|
2137
|
+
if (this.terrainWake)
|
|
2138
|
+
this.wakeTerrainFootprint(colliderIndex);
|
|
2139
|
+
if (atlas) {
|
|
2140
|
+
const word = atlas.wordsByCollider.get(colliderIndex);
|
|
2141
|
+
const address = word === undefined ? 0 : (this.terrainAtlasWord - this.terrainGeometryWord + word) / 4;
|
|
2142
|
+
metadata.write(new Float32Array([
|
|
2143
|
+
word === undefined ? 0 : address + packed.nodeOffset,
|
|
2144
|
+
packed.nodeCount,
|
|
2145
|
+
address
|
|
2146
|
+
]), base + 72);
|
|
2147
|
+
}
|
|
2148
|
+
else {
|
|
2149
|
+
metadata.write(new Float32Array(packed.data), offset);
|
|
2150
|
+
metadata.write(new Float32Array([packed.nodeCount]), base + 76);
|
|
2151
|
+
}
|
|
2152
|
+
metadata.write(new Float32Array(packed.extent), base);
|
|
2153
|
+
metadata.write(new Float32Array([revision, packed.triangleCount]), base + 88);
|
|
2154
|
+
if (position && localOffset) {
|
|
2155
|
+
metadata.write(new Float32Array(localOffset), base + 16);
|
|
2156
|
+
collider.position = [...position];
|
|
2157
|
+
}
|
|
2158
|
+
collider.shape = { type: 'height-field', field };
|
|
2159
|
+
changedBodies.add(collider.body);
|
|
2160
|
+
if (this.terrainWake)
|
|
2161
|
+
this.wakeTerrainFootprint(colliderIndex);
|
|
2162
|
+
if (this.props.ensembleBodiesPerInstance)
|
|
2163
|
+
affectedInstances.add(Math.floor(collider.body / this.props.ensembleBodiesPerInstance));
|
|
2164
|
+
}
|
|
2165
|
+
for (const body of changedBodies)
|
|
2166
|
+
this.updateColliderDefinitions(body);
|
|
2167
|
+
for (const instance of affectedInstances)
|
|
2168
|
+
this.wakeEnsembleInstance(instance);
|
|
2169
|
+
}
|
|
2170
|
+
/** Shared atlas utilization, when the fused layout enabled page sharing. */
|
|
2171
|
+
getTerrainAtlasStats() {
|
|
2172
|
+
return this.terrainAtlas?.getStats();
|
|
2173
|
+
}
|
|
1766
2174
|
/** Change an existing collider material between submissions, invalidating cached friction. */
|
|
1767
2175
|
setColliderMaterial(colliderIndex, material) {
|
|
1768
2176
|
const collider = this.colliders[colliderIndex];
|
|
@@ -1829,11 +2237,9 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1829
2237
|
updateColliderDefinitions(bodyIndex) {
|
|
1830
2238
|
const { shape, colliders, ...properties } = this.props.bodies[bodyIndex];
|
|
1831
2239
|
const updated = this.colliders
|
|
1832
|
-
.
|
|
2240
|
+
.slice(this.bodyColliderStarts[bodyIndex], this.bodyColliderStarts[bodyIndex + 1])
|
|
1833
2241
|
.map(({ body, ...candidate }) => candidate);
|
|
1834
|
-
|
|
1835
|
-
bodies[bodyIndex] = { ...properties, colliders: updated };
|
|
1836
|
-
this.props.bodies = bodies;
|
|
2242
|
+
this.props.bodies[bodyIndex] = { ...properties, colliders: updated };
|
|
1837
2243
|
}
|
|
1838
2244
|
getColliderMaterial(collider) {
|
|
1839
2245
|
const definition = this.colliders[collider];
|
|
@@ -1841,15 +2247,18 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1841
2247
|
throw new Error('Invalid collider');
|
|
1842
2248
|
return structuredClone(definition.material ?? {});
|
|
1843
2249
|
}
|
|
1844
|
-
restoreColliderDefinitions() {
|
|
1845
|
-
// Body definitions are
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
const
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
2250
|
+
restoreColliderDefinitions(first = 0, end = this.count) {
|
|
2251
|
+
// Body definitions are world-owned. Keep shared geometry identities.
|
|
2252
|
+
for (let body = first; body < end; body++) {
|
|
2253
|
+
const definition = this.props.bodies[body];
|
|
2254
|
+
const colliders = definition.colliders ?? (definition.shape ? [{ shape: definition.shape }] : []);
|
|
2255
|
+
for (const [index, source] of colliders.entries()) {
|
|
2256
|
+
const collider = this.colliders[this.bodyColliderStarts[body] + index];
|
|
2257
|
+
collider.shape = source.shape;
|
|
2258
|
+
collider.material = source.material;
|
|
2259
|
+
collider.position = source.position;
|
|
2260
|
+
collider.orientation = source.orientation;
|
|
2261
|
+
}
|
|
1853
2262
|
}
|
|
1854
2263
|
}
|
|
1855
2264
|
/** Update motion properties between submissions; preserve the node pose when its COM changes. */
|
|
@@ -1885,13 +2294,16 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1885
2294
|
validateRigidBodyJoints(this.props.joints, proposedBodies, this.solver);
|
|
1886
2295
|
}
|
|
1887
2296
|
const colliders = this.colliders.filter(collider => collider.body === bodyIndex);
|
|
1888
|
-
for (const collider of colliders)
|
|
2297
|
+
for (const collider of colliders) {
|
|
2298
|
+
if (collider.shape.type === 'height-field' && mode !== 'static')
|
|
2299
|
+
throw new Error('Height fields require static bodies');
|
|
1889
2300
|
if ((collider.shape.type === 'convex-hull' || collider.shape.type === 'triangle-mesh') &&
|
|
1890
2301
|
mode !== 'static' &&
|
|
1891
2302
|
mass > 0 &&
|
|
1892
2303
|
(!collider.shape.geometry.closed ||
|
|
1893
2304
|
!(getRigidBodyShapeProperties(collider.shape).volume > 0)))
|
|
1894
2305
|
throw new Error('Dynamic meshes require closed positive-volume geometry');
|
|
2306
|
+
}
|
|
1895
2307
|
if (this.props.continuous?.bodies.includes(bodyIndex) &&
|
|
1896
2308
|
(mode !== 'dynamic' ||
|
|
1897
2309
|
mass === 0 ||
|
|
@@ -2067,18 +2479,29 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2067
2479
|
readContactEvents() {
|
|
2068
2480
|
if (!this.contactEvents || this.destroyed)
|
|
2069
2481
|
return Promise.reject(new Error('Contact events are not enabled'));
|
|
2070
|
-
|
|
2071
|
-
|
|
2482
|
+
/** Queue the copy now, then decode only after any preceding recovery sets the cursor. */
|
|
2483
|
+
const afterSnapshot = this.contactSnapshotRead;
|
|
2484
|
+
if (this.eventRead && (!afterSnapshot || this.eventRead.afterSnapshot === afterSnapshot))
|
|
2485
|
+
return this.eventRead.result;
|
|
2486
|
+
/** Register the read before recovery can clear its own busy flag. */
|
|
2487
|
+
const pending = {
|
|
2488
|
+
afterSnapshot,
|
|
2489
|
+
result: this.contactEvents
|
|
2072
2490
|
.readAsync()
|
|
2491
|
+
.finally(() => afterSnapshot)
|
|
2073
2492
|
.then(bytes => {
|
|
2493
|
+
/** The newest stream cursor is available once the preceding snapshot resolves. */
|
|
2074
2494
|
const batch = decodeRigidBodyContactEvents(new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4), this.eventCursor);
|
|
2075
2495
|
this.eventCursor = batch.sequence;
|
|
2076
2496
|
return batch;
|
|
2077
2497
|
})
|
|
2078
2498
|
.finally(() => {
|
|
2079
|
-
this.eventRead
|
|
2080
|
-
|
|
2081
|
-
|
|
2499
|
+
if (this.eventRead === pending)
|
|
2500
|
+
this.eventRead = null;
|
|
2501
|
+
})
|
|
2502
|
+
};
|
|
2503
|
+
this.eventRead = pending;
|
|
2504
|
+
return pending.result;
|
|
2082
2505
|
}
|
|
2083
2506
|
/** Nearest exact sphere/OBB hit. Origins inside a shape return distance zero and a zero normal. */
|
|
2084
2507
|
raycast(query) {
|
|
@@ -2088,6 +2511,74 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2088
2511
|
overlapSphere(query) {
|
|
2089
2512
|
return this.runQuery(query);
|
|
2090
2513
|
}
|
|
2514
|
+
/**
|
|
2515
|
+
* Query the closest hit for each ray or sphere cast with one submission and readback.
|
|
2516
|
+
* Results follow input order. This snapshots already submitted poses, using one shared collider selection.
|
|
2517
|
+
*/
|
|
2518
|
+
async castBatch(commands, options = {}) {
|
|
2519
|
+
if (!this.device ||
|
|
2520
|
+
!this.batchCast ||
|
|
2521
|
+
!this.querySelection ||
|
|
2522
|
+
!this.batchCastCommands ||
|
|
2523
|
+
!this.batchCastResults ||
|
|
2524
|
+
this.destroyed ||
|
|
2525
|
+
this.queryPending)
|
|
2526
|
+
throw new Error('Batched collision casts are disabled or busy');
|
|
2527
|
+
if (commands.length > this.props.queryBatchCapacity)
|
|
2528
|
+
throw new Error('Collision cast batch exceeds capacity');
|
|
2529
|
+
if (!commands.length)
|
|
2530
|
+
return [];
|
|
2531
|
+
if (options.strategy === 'indexed' && !this.props.queryBatchIndex)
|
|
2532
|
+
throw new Error('Batched collision cast index is disabled');
|
|
2533
|
+
/** The scan remains available for short or dense workloads and reference comparisons. */
|
|
2534
|
+
const order = options.strategy === 'scan' ? null : this.batchCastOrder;
|
|
2535
|
+
/** Deduplicate the shared selection before publishing any GPU input. */
|
|
2536
|
+
const selection = options.colliderIndices
|
|
2537
|
+
? Uint32Array.from(new Set(this.validateQueryColliders(options.colliderIndices)))
|
|
2538
|
+
: (order?.indices ?? Uint32Array.from({ length: this.colliderCount }, (_, index) => index));
|
|
2539
|
+
/** The indexed prefix can be empty when a filter selects only extended geometry. */
|
|
2540
|
+
let indexedCount = order?.indexedCount ?? 0;
|
|
2541
|
+
if (order && options.colliderIndices) {
|
|
2542
|
+
selection.sort((first, second) => order.ranks[first] - order.ranks[second]);
|
|
2543
|
+
/** All selected primitives precede the extended collider fallback. */
|
|
2544
|
+
const firstExtended = selection.findIndex(index => order.ranks[index] >= order.indexedCount);
|
|
2545
|
+
indexedCount = firstExtended < 0 ? selection.length : firstExtended;
|
|
2546
|
+
}
|
|
2547
|
+
/** Validate and encode all commands before changing staging data. */
|
|
2548
|
+
const data = packRigidBodyBatchCasts(commands, this.count, selection.length, indexedCount);
|
|
2549
|
+
this.queryPending = true;
|
|
2550
|
+
try {
|
|
2551
|
+
this.batchCastCommands.write(data);
|
|
2552
|
+
if (selection.length)
|
|
2553
|
+
this.querySelection.write(selection);
|
|
2554
|
+
/** Submit after any preceding pose changes in device queue order. */
|
|
2555
|
+
const encoder = this.device.createCommandEncoder();
|
|
2556
|
+
if (this.batchCastIndex && indexedCount) {
|
|
2557
|
+
this.batchCastIndex.encode(encoder, { parameters: commands.length });
|
|
2558
|
+
}
|
|
2559
|
+
else {
|
|
2560
|
+
/** One workgroup handles one command and reduces its collider results locally. */
|
|
2561
|
+
const pass = encoder.beginComputePass();
|
|
2562
|
+
this.batchCast.kernel.dispatch(pass, {
|
|
2563
|
+
bindings: this.batchCast.bindings,
|
|
2564
|
+
x: commands.length
|
|
2565
|
+
});
|
|
2566
|
+
pass.end();
|
|
2567
|
+
}
|
|
2568
|
+
this.device.submit(encoder.finish());
|
|
2569
|
+
return decodeRigidBodyBatchCasts(await this.batchCastResults.readAsync(0, commands.length * RIGID_BODY_BATCH_RESULT_BYTES));
|
|
2570
|
+
}
|
|
2571
|
+
finally {
|
|
2572
|
+
this.queryPending = false;
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
/** Reject invalid indices before scalar or batch query buffers are written. */
|
|
2576
|
+
validateQueryColliders(indices) {
|
|
2577
|
+
for (const index of indices)
|
|
2578
|
+
if (!Number.isInteger(index) || index < 0 || index >= this.colliderCount)
|
|
2579
|
+
throw new Error('Invalid query collider');
|
|
2580
|
+
return indices;
|
|
2581
|
+
}
|
|
2091
2582
|
async runQuery(query) {
|
|
2092
2583
|
if (!this.device ||
|
|
2093
2584
|
!this.queryComputation ||
|
|
@@ -2124,9 +2615,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2124
2615
|
throw new Error('Invalid collision query');
|
|
2125
2616
|
const selected = query.colliderIndices ?? Array.from({ length: this.colliderCount }, (_, index) => index);
|
|
2126
2617
|
const selection = new Uint32Array(this.colliderStorageCount);
|
|
2127
|
-
for (const index of selected) {
|
|
2128
|
-
if (!Number.isInteger(index) || index < 0 || index >= this.colliderCount)
|
|
2129
|
-
throw new Error('Invalid query collider');
|
|
2618
|
+
for (const index of this.validateQueryColliders(selected)) {
|
|
2130
2619
|
const collider = this.colliders[index];
|
|
2131
2620
|
if (collider.body === query.excludeBody)
|
|
2132
2621
|
continue;
|
|
@@ -2156,16 +2645,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2156
2645
|
const bytes = await this.queryOutput.readAsync(0, 16 + maximumHits * 48);
|
|
2157
2646
|
const words = new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
2158
2647
|
const floats = new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
2159
|
-
const hits = Array.from({ length: words[0] }, (_, index) =>
|
|
2160
|
-
const offset = 4 + index * 12;
|
|
2161
|
-
return {
|
|
2162
|
-
body: words[offset],
|
|
2163
|
-
collider: words[offset + 1],
|
|
2164
|
-
point: [floats[offset + 4], floats[offset + 5], floats[offset + 6]],
|
|
2165
|
-
distance: floats[offset + 7],
|
|
2166
|
-
normal: [floats[offset + 8], floats[offset + 9], floats[offset + 10]]
|
|
2167
|
-
};
|
|
2168
|
-
});
|
|
2648
|
+
const hits = Array.from({ length: words[0] }, (_, index) => decodeRigidBodyQueryHit(words, floats, 4 + index * 12));
|
|
2169
2649
|
return {
|
|
2170
2650
|
hits,
|
|
2171
2651
|
totalHits: words[1],
|
|
@@ -2216,19 +2696,107 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2216
2696
|
readTriggerEvents() {
|
|
2217
2697
|
if (!this.triggerEvents || this.destroyed)
|
|
2218
2698
|
throw new Error('Triggers are disabled');
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
this.triggerRead
|
|
2222
|
-
.
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2699
|
+
/** Queue the copy in caller order, including when recovery is still mapping. */
|
|
2700
|
+
const afterSnapshot = this.triggerSnapshotRead;
|
|
2701
|
+
if (this.triggerRead && (!afterSnapshot || this.triggerRead.afterSnapshot === afterSnapshot))
|
|
2702
|
+
return this.triggerRead.result;
|
|
2703
|
+
/** Track the read immediately so checkpoint operations see a busy world. */
|
|
2704
|
+
const pending = {
|
|
2705
|
+
afterSnapshot,
|
|
2706
|
+
result: this.triggerEvents
|
|
2707
|
+
.readAsync()
|
|
2708
|
+
.finally(() => afterSnapshot)
|
|
2709
|
+
.then(bytes => {
|
|
2710
|
+
/** The snapshot has established the sequence used to decode this delta. */
|
|
2711
|
+
const batch = decodeRigidBodyTriggerEvents(new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4), this.triggerCursor);
|
|
2712
|
+
this.triggerCursor = batch.sequence;
|
|
2713
|
+
return batch;
|
|
2714
|
+
})
|
|
2715
|
+
.finally(() => {
|
|
2716
|
+
if (this.triggerRead === pending)
|
|
2717
|
+
this.triggerRead = null;
|
|
2718
|
+
})
|
|
2719
|
+
};
|
|
2720
|
+
this.triggerRead = pending;
|
|
2721
|
+
return pending.result;
|
|
2722
|
+
}
|
|
2723
|
+
/** Recover the active contact set and advance the incremental cursor to the snapshot. */
|
|
2724
|
+
resyncContactEvents() {
|
|
2725
|
+
if (!this.device || !this.contactEvents || !this.contactHistory || this.destroyed)
|
|
2726
|
+
return Promise.reject(new Error('Contact events are not enabled'));
|
|
2727
|
+
if (this.contactSnapshotRead)
|
|
2728
|
+
return this.contactSnapshotRead;
|
|
2729
|
+
/** An earlier incremental read may still be advancing its cursor. */
|
|
2730
|
+
const priorRead = this.eventRead?.result.catch(() => undefined);
|
|
2731
|
+
/** Capture immediately, even when a previous delta read is still mapping. */
|
|
2732
|
+
const snapshot = readRigidBodyEventSnapshot(this.device, this.contactEvents, this.contactHistory, (header, rows) => {
|
|
2733
|
+
/** The retained history contains active pairs, independent of event retention. */
|
|
2734
|
+
const contacts = [];
|
|
2735
|
+
for (let offset = 0; offset < rows.length; offset += 4) {
|
|
2736
|
+
if (rows[offset + 2] === 0)
|
|
2737
|
+
continue;
|
|
2738
|
+
/** A contact history row stores the two original collider IDs. */
|
|
2739
|
+
const first = rows[offset];
|
|
2740
|
+
/** Compound collider IDs map back to their owning bodies. */
|
|
2741
|
+
const second = rows[offset + 1];
|
|
2742
|
+
contacts.push({
|
|
2743
|
+
colliders: [first, second],
|
|
2744
|
+
bodies: [this.colliders[first].body, this.colliders[second].body]
|
|
2745
|
+
});
|
|
2746
|
+
}
|
|
2747
|
+
return { ...header, contacts };
|
|
2748
|
+
});
|
|
2749
|
+
this.contactSnapshotRead = snapshot
|
|
2750
|
+
.finally(() => priorRead)
|
|
2751
|
+
.then(result => {
|
|
2752
|
+
this.eventCursor = result.sequence;
|
|
2753
|
+
return result;
|
|
2227
2754
|
})
|
|
2228
2755
|
.finally(() => {
|
|
2229
|
-
this.
|
|
2756
|
+
this.contactSnapshotRead = null;
|
|
2230
2757
|
});
|
|
2231
|
-
return this.
|
|
2758
|
+
return this.contactSnapshotRead;
|
|
2759
|
+
}
|
|
2760
|
+
/** Recover the active trigger overlap set and advance the incremental trigger cursor. */
|
|
2761
|
+
resyncTriggerEvents() {
|
|
2762
|
+
if (!this.device || !this.triggerEvents || !this.triggerHistory || this.destroyed)
|
|
2763
|
+
return Promise.reject(new Error('Triggers are disabled'));
|
|
2764
|
+
if (this.triggerSnapshotRead)
|
|
2765
|
+
return this.triggerSnapshotRead;
|
|
2766
|
+
/** Preserve authored trigger and target-body identities alongside the sampled pairs. */
|
|
2767
|
+
const { buffer, groups } = this.triggerHistory;
|
|
2768
|
+
/** Wait for prior cursor updates before replacing them with the new recovery point. */
|
|
2769
|
+
const priorRead = this.triggerRead?.result.catch(() => undefined);
|
|
2770
|
+
/** Read only the history bit and representative collider pair for each group. */
|
|
2771
|
+
const snapshot = readRigidBodyEventSnapshot(this.device, this.triggerEvents, buffer, (header, rows) => {
|
|
2772
|
+
/** Swept crossings with no final overlap are absent from this state. */
|
|
2773
|
+
const overlaps = [];
|
|
2774
|
+
for (let offset = 0; offset < rows.length; offset += 4) {
|
|
2775
|
+
if ((rows[offset] & 1) === 0)
|
|
2776
|
+
continue;
|
|
2777
|
+
overlaps.push({
|
|
2778
|
+
trigger: groups[offset],
|
|
2779
|
+
body: groups[offset + 1],
|
|
2780
|
+
triggerCollider: rows[offset + 1],
|
|
2781
|
+
collider: rows[offset + 2]
|
|
2782
|
+
});
|
|
2783
|
+
}
|
|
2784
|
+
return { ...header, overlaps };
|
|
2785
|
+
});
|
|
2786
|
+
this.triggerSnapshotRead = snapshot
|
|
2787
|
+
.finally(() => priorRead)
|
|
2788
|
+
.then(result => {
|
|
2789
|
+
this.triggerCursor = result.sequence;
|
|
2790
|
+
return result;
|
|
2791
|
+
})
|
|
2792
|
+
.finally(() => {
|
|
2793
|
+
this.triggerSnapshotRead = null;
|
|
2794
|
+
});
|
|
2795
|
+
return this.triggerSnapshotRead;
|
|
2796
|
+
}
|
|
2797
|
+
/** Reset, capture and origin operations require stable event cursors. */
|
|
2798
|
+
get eventReadsPending() {
|
|
2799
|
+
return Boolean(this.eventRead || this.triggerRead || this.contactSnapshotRead || this.triggerSnapshotRead);
|
|
2232
2800
|
}
|
|
2233
2801
|
getSnapshotBuffers(includeRollbackScratch = true) {
|
|
2234
2802
|
return this.ownedBuffers.filter(buffer => includeRollbackScratch || !buffer.id.startsWith(`${this.id}-checkpoint-`));
|
|
@@ -2248,6 +2816,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2248
2816
|
let bodyDefinitions = structuredClone(this.props.bodies);
|
|
2249
2817
|
let contactCursor = 0;
|
|
2250
2818
|
let triggerCursor = 0;
|
|
2819
|
+
let terrainRevision = this.terrainRevision;
|
|
2820
|
+
let terrainAtlas = this.terrainAtlas?.snapshot();
|
|
2251
2821
|
try {
|
|
2252
2822
|
for (const buffer of checkpointBuffers)
|
|
2253
2823
|
snapshots.push(device.createBuffer({
|
|
@@ -2262,7 +2832,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2262
2832
|
throw error;
|
|
2263
2833
|
}
|
|
2264
2834
|
const copy = (restore) => {
|
|
2265
|
-
if (released || this.destroyed || this.queryPending || this.
|
|
2835
|
+
if (released || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
2266
2836
|
throw new Error('Checkpoint requires an idle live world');
|
|
2267
2837
|
const encoder = device.createCommandEncoder();
|
|
2268
2838
|
for (const [index, buffer] of checkpointBuffers.entries())
|
|
@@ -2286,6 +2856,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2286
2856
|
publicationBounds = structuredClone(this.props.publicationBounds);
|
|
2287
2857
|
contactCursor = this.eventCursor;
|
|
2288
2858
|
triggerCursor = this.triggerCursor;
|
|
2859
|
+
terrainRevision = this.terrainRevision;
|
|
2860
|
+
terrainAtlas = this.terrainAtlas?.snapshot();
|
|
2289
2861
|
saved = true;
|
|
2290
2862
|
},
|
|
2291
2863
|
restore: () => {
|
|
@@ -2300,6 +2872,9 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2300
2872
|
this.props.publicationBounds = structuredClone(publicationBounds);
|
|
2301
2873
|
this.eventCursor = contactCursor;
|
|
2302
2874
|
this.triggerCursor = triggerCursor;
|
|
2875
|
+
this.terrainRevision = terrainRevision;
|
|
2876
|
+
if (terrainAtlas)
|
|
2877
|
+
this.terrainAtlas.restore(terrainAtlas.leases, (_word, _words, page) => terrainAtlas.payloads.get(page));
|
|
2303
2878
|
},
|
|
2304
2879
|
destroy: () => {
|
|
2305
2880
|
if (released)
|
|
@@ -2315,7 +2890,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2315
2890
|
}
|
|
2316
2891
|
/** Stop graph submissions and controls first; includes diagnostics, caches and event history. */
|
|
2317
2892
|
async captureState(options = {}) {
|
|
2318
|
-
if (!this.device || this.destroyed || this.queryPending || this.
|
|
2893
|
+
if (!this.device || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
2319
2894
|
throw new Error('Capture requires an idle attached world');
|
|
2320
2895
|
return {
|
|
2321
2896
|
version: 1,
|
|
@@ -2325,6 +2900,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2325
2900
|
colliderShapeScales: structuredClone([...this.colliderShapeScales]),
|
|
2326
2901
|
contactCursor: this.eventCursor,
|
|
2327
2902
|
triggerCursor: this.triggerCursor,
|
|
2903
|
+
terrainRevision: this.terrainRevision,
|
|
2904
|
+
terrainAtlasLeases: this.terrainAtlas?.getLeases(),
|
|
2328
2905
|
buffers: await Promise.all(this.getSnapshotBuffers(options.includeRollbackScratch).map(async (buffer) => ({
|
|
2329
2906
|
name: buffer.id.slice(this.id.length + 1),
|
|
2330
2907
|
data: new Uint8Array(await buffer.readAsync())
|
|
@@ -2334,12 +2911,16 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2334
2911
|
/** Restore between submissions on the same configuration and implementation; no implicit wake. */
|
|
2335
2912
|
restoreState(capture) {
|
|
2336
2913
|
const checkpointBuffers = this.getSnapshotBuffers(capture.includeRollbackScratch);
|
|
2914
|
+
const terrainRevision = capture.terrainRevision ?? 1;
|
|
2337
2915
|
if (!this.device ||
|
|
2338
2916
|
this.destroyed ||
|
|
2339
2917
|
this.queryPending ||
|
|
2340
|
-
this.
|
|
2341
|
-
this.triggerRead ||
|
|
2918
|
+
this.eventReadsPending ||
|
|
2342
2919
|
capture.version !== 1 ||
|
|
2920
|
+
Boolean(capture.terrainAtlasLeases) !== Boolean(this.terrainAtlas) ||
|
|
2921
|
+
!Number.isInteger(terrainRevision) ||
|
|
2922
|
+
terrainRevision < 1 ||
|
|
2923
|
+
terrainRevision > 0xffffff ||
|
|
2343
2924
|
(capture.origin !== undefined &&
|
|
2344
2925
|
(capture.origin.length !== 3 || !capture.origin.every(Number.isFinite))) ||
|
|
2345
2926
|
capture.buffers.length !== checkpointBuffers.length ||
|
|
@@ -2360,6 +2941,26 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2360
2941
|
saved.data.byteLength !== buffer.byteLength)
|
|
2361
2942
|
throw new Error('Incompatible rigid-body capture storage');
|
|
2362
2943
|
}
|
|
2944
|
+
if (this.terrainAtlas && capture.terrainAtlasLeases) {
|
|
2945
|
+
const metadata = capture.buffers.find(buffer => buffer.name === 'bodies').data;
|
|
2946
|
+
const view = new DataView(metadata.buffer, metadata.byteOffset, metadata.byteLength);
|
|
2947
|
+
const colliderBase = this.count * 48;
|
|
2948
|
+
let active = 0;
|
|
2949
|
+
for (const collider of this.ensembleTerrainSlots)
|
|
2950
|
+
if (view.getFloat32(colliderBase + collider * 96 + 76, true) > 0)
|
|
2951
|
+
active++;
|
|
2952
|
+
if (active !== capture.terrainAtlasLeases.length)
|
|
2953
|
+
throw new Error('Incomplete captured terrain atlas leases');
|
|
2954
|
+
this.terrainAtlas.restore(capture.terrainAtlasLeases, (word, words) => {
|
|
2955
|
+
const first = (this.terrainAtlasWord + word) * 4;
|
|
2956
|
+
return new Float32Array(metadata.slice(first, first + words * 4).buffer);
|
|
2957
|
+
}, (collider, word) => {
|
|
2958
|
+
const base = colliderBase + collider * 96;
|
|
2959
|
+
const address = (this.terrainAtlasWord - this.terrainGeometryWord + word) / 4;
|
|
2960
|
+
if (view.getFloat32(base + 76, true) <= 0 || view.getFloat32(base + 80, true) !== address)
|
|
2961
|
+
throw new Error('Captured terrain collider has an invalid page address');
|
|
2962
|
+
});
|
|
2963
|
+
}
|
|
2363
2964
|
for (const [index, buffer] of checkpointBuffers.entries())
|
|
2364
2965
|
buffer.write(capture.buffers[index].data);
|
|
2365
2966
|
this.props.joints = structuredClone(capture.props.joints);
|
|
@@ -2370,6 +2971,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2370
2971
|
this.worldOrigin = [...(capture.origin ?? [0, 0, 0])];
|
|
2371
2972
|
this.eventCursor = capture.contactCursor;
|
|
2372
2973
|
this.triggerCursor = capture.triggerCursor;
|
|
2974
|
+
this.terrainRevision = terrainRevision;
|
|
2373
2975
|
}
|
|
2374
2976
|
/** Stop submissions first. Reconstruct with these accepted poses and larger budgets after rollback. */
|
|
2375
2977
|
async getRecoveryProps(overrides = {}) {
|
|
@@ -2475,8 +3077,11 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2475
3077
|
this.destroyed = true;
|
|
2476
3078
|
this.control?.kernel.destroy();
|
|
2477
3079
|
this.invalidation?.kernel.destroy();
|
|
3080
|
+
this.terrainWake?.kernel.destroy();
|
|
2478
3081
|
this.queryComputation?.kernel.destroy();
|
|
2479
3082
|
this.queryReduction?.kernel.destroy();
|
|
3083
|
+
this.batchCastIndex?.destroy();
|
|
3084
|
+
this.batchCast?.kernel.destroy();
|
|
2480
3085
|
for (const buffer of this.ownedBuffers)
|
|
2481
3086
|
buffer.destroy();
|
|
2482
3087
|
this.ownedBuffers.length = 0;
|
|
@@ -2497,7 +3102,13 @@ function serializeCaptureProps(props) {
|
|
|
2497
3102
|
...collider,
|
|
2498
3103
|
shape: collider.shape?.type === 'convex-hull' || collider.shape?.type === 'triangle-mesh'
|
|
2499
3104
|
? collider.shape
|
|
2500
|
-
:
|
|
3105
|
+
: collider.shape?.type === 'height-field'
|
|
3106
|
+
? {
|
|
3107
|
+
type: collider.shape.type,
|
|
3108
|
+
width: collider.shape.field.width,
|
|
3109
|
+
height: collider.shape.field.height
|
|
3110
|
+
}
|
|
3111
|
+
: { type: collider.shape?.type },
|
|
2501
3112
|
material: undefined,
|
|
2502
3113
|
position: undefined,
|
|
2503
3114
|
orientation: undefined
|