@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
|
@@ -23,9 +23,11 @@ module.exports = __toCommonJS(gpu_rigid_body_world_exports);
|
|
|
23
23
|
var import_bound_kernel = require("../gpu-core/utils/bound-kernel.cjs");
|
|
24
24
|
var import_core = require("@luma.gl/core");
|
|
25
25
|
var import_rigid_body_origin = require("./rigid-body-origin.cjs");
|
|
26
|
+
var import_rigid_body_height_field = require("./rigid-body-height-field.cjs");
|
|
26
27
|
var import_rigid_body_shape_properties = require("./rigid-body-shape-properties.cjs");
|
|
27
28
|
var import_rigid_body_ensemble_shaders = require("./rigid-body-ensemble-shaders.cjs");
|
|
28
29
|
var import_rigid_body_ensemble_reset = require("./rigid-body-ensemble-reset.cjs");
|
|
30
|
+
var import_rigid_body_terrain_atlas = require("./rigid-body-terrain-atlas.cjs");
|
|
29
31
|
var import_rigid_body_geometry = require("./rigid-body-geometry.cjs");
|
|
30
32
|
var import_rigid_body_properties = require("./rigid-body-properties.cjs");
|
|
31
33
|
var import_gpu_command_node = require("../gpu-core/gpu-command-node.cjs");
|
|
@@ -43,7 +45,10 @@ var import_rigid_body_publication = require("./rigid-body-publication.cjs");
|
|
|
43
45
|
var import_rigid_body_shaders = require("./rigid-body-shaders.cjs");
|
|
44
46
|
var import_rigid_body_vehicle = require("./rigid-body-vehicle.cjs");
|
|
45
47
|
var import_rigid_body_events = require("./rigid-body-events.cjs");
|
|
48
|
+
var import_rigid_body_event_compaction = require("./rigid-body-event-compaction.cjs");
|
|
49
|
+
var import_rigid_body_event_snapshot = require("./rigid-body-event-snapshot.cjs");
|
|
46
50
|
var import_rigid_body_queries = require("./rigid-body-queries.cjs");
|
|
51
|
+
var import_rigid_body_cast_index = require("./rigid-body-cast-index.cjs");
|
|
47
52
|
class GPURigidBodyWorld {
|
|
48
53
|
worldOrigin = [0, 0, 0];
|
|
49
54
|
id;
|
|
@@ -65,6 +70,14 @@ class GPURigidBodyWorld {
|
|
|
65
70
|
sleepStates = null;
|
|
66
71
|
/** World-owned GPU event ring; present only when eventCapacity is positive. */
|
|
67
72
|
contactEvents = null;
|
|
73
|
+
/** Trigger history and authored group IDs remain stable until world destruction. */
|
|
74
|
+
triggerHistory = null;
|
|
75
|
+
/** Contact activity is recorded in pair-slot order after accepted steps. */
|
|
76
|
+
contactHistory = null;
|
|
77
|
+
/** A recovery read shares the incremental trigger cursor. */
|
|
78
|
+
triggerSnapshotRead = null;
|
|
79
|
+
/** A recovery read shares the incremental contact cursor. */
|
|
80
|
+
contactSnapshotRead = null;
|
|
68
81
|
triggerEvents = null;
|
|
69
82
|
triggerCursor = 0;
|
|
70
83
|
triggerRead = null;
|
|
@@ -72,6 +85,24 @@ class GPURigidBodyWorld {
|
|
|
72
85
|
eventRead = null;
|
|
73
86
|
queryComputation = null;
|
|
74
87
|
queryReduction = null;
|
|
88
|
+
/** Batched nearest-hit computation using the current world pose buffers. */
|
|
89
|
+
batchCast = null;
|
|
90
|
+
/** Compiled query graph that refits the world BVH and then casts. */
|
|
91
|
+
batchCastIndex = null;
|
|
92
|
+
/** Initial spatial order and stable collider ID mapping for indexed batches. */
|
|
93
|
+
batchCastOrder = null;
|
|
94
|
+
/** Query graph reservation before attachment, when the physical plan is unavailable. */
|
|
95
|
+
batchCastIndexEstimate;
|
|
96
|
+
/** Reusable storage for a bounded list of ray and sweep commands. */
|
|
97
|
+
batchCastCommands = null;
|
|
98
|
+
/** Reusable GPU output with one compact result per batch command. */
|
|
99
|
+
batchCastResults = null;
|
|
100
|
+
/** Chassis definitions in GPU storage order. */
|
|
101
|
+
vehicles;
|
|
102
|
+
/** Whether any chassis has more than one terrain candidate. */
|
|
103
|
+
multiSurfaceVehicles;
|
|
104
|
+
/** Number of vehicles in each equal-sized ensemble partition, or zero for a standalone world. */
|
|
105
|
+
vehiclesPerInstance;
|
|
75
106
|
vehicleBuffer = null;
|
|
76
107
|
querySettings = null;
|
|
77
108
|
querySelection = null;
|
|
@@ -80,9 +111,23 @@ class GPURigidBodyWorld {
|
|
|
80
111
|
targets = null;
|
|
81
112
|
simulationStatistics = null;
|
|
82
113
|
colliders;
|
|
114
|
+
bodyColliderStarts;
|
|
115
|
+
ensembleTerrainSlots;
|
|
83
116
|
props;
|
|
84
117
|
ownedBuffers = [];
|
|
118
|
+
allocationPlan;
|
|
85
119
|
ensembleBuffer = null;
|
|
120
|
+
/** Byte offsets of writable fixed-dimension height fields in the world metadata buffer. */
|
|
121
|
+
heightFieldSlots = /* @__PURE__ */ new Map();
|
|
122
|
+
/** Float32-exact edit stamp, restored together with the contact cache. */
|
|
123
|
+
terrainRevision = 1;
|
|
124
|
+
terrainWake = null;
|
|
125
|
+
/** Page ownership and live lease counts for an opt-in fused atlas. */
|
|
126
|
+
terrainAtlas;
|
|
127
|
+
/** Start of the shared atlas in the GPU metadata buffer, measured in 32-bit words. */
|
|
128
|
+
terrainAtlasWord = 0;
|
|
129
|
+
/** Start of the shader geometry region in the GPU metadata buffer, measured in 32-bit words. */
|
|
130
|
+
terrainGeometryWord = 0;
|
|
86
131
|
ensembleResetOrigin;
|
|
87
132
|
ensembleReset;
|
|
88
133
|
initialEnsembleBodies;
|
|
@@ -99,7 +144,10 @@ class GPURigidBodyWorld {
|
|
|
99
144
|
gpuCheckpoints = /* @__PURE__ */ new Set();
|
|
100
145
|
broadPhaseCounters = null;
|
|
101
146
|
constructor(props) {
|
|
102
|
-
var _a, _b, _c, _d, _e;
|
|
147
|
+
var _a, _b, _c, _d, _e, _f;
|
|
148
|
+
const queryBatchCapacity = props.queryBatchCapacity ?? 0;
|
|
149
|
+
if (!Number.isSafeInteger(queryBatchCapacity) || queryBatchCapacity < 0 || queryBatchCapacity > 65535 || queryBatchCapacity > 0 && !props.enableQueries || props.queryBatchIndex && queryBatchCapacity === 0)
|
|
150
|
+
throw new Error("Invalid collision cast batch capacity");
|
|
103
151
|
for (const damping of [props.linearDamping ?? 0, props.angularDamping ?? 0]) {
|
|
104
152
|
if (!Number.isFinite(damping) || damping < 0)
|
|
105
153
|
throw new Error("Invalid damping");
|
|
@@ -148,6 +196,8 @@ class GPURigidBodyWorld {
|
|
|
148
196
|
throw new Error("Supply shape or colliders");
|
|
149
197
|
const shapes = body.colliders ?? (body.shape ? [{ shape: body.shape }] : []);
|
|
150
198
|
for (const collider of shapes) {
|
|
199
|
+
if (collider.shape.type === "height-field" && (body.mode ?? (body.mass === 0 ? "static" : "dynamic")) !== "static")
|
|
200
|
+
throw new Error("Height fields require static bodies");
|
|
151
201
|
const properties = (0, import_rigid_body_shape_properties.getRigidBodyShapeProperties)(collider.shape);
|
|
152
202
|
if (!Number.isFinite(properties.volume) || !properties.center.every(Number.isFinite) || !properties.tensor.every(Number.isFinite))
|
|
153
203
|
throw new Error("Invalid shape properties");
|
|
@@ -204,8 +254,11 @@ class GPURigidBodyWorld {
|
|
|
204
254
|
this.maximumPairs = this.broadPhase === "all-pairs" ? this.colliderStorageCount * this.colliderStorageCount : props.maximumPairs ?? 2 ** Math.ceil(Math.log2(Math.max(64, this.colliderStorageCount * 16)));
|
|
205
255
|
if (!["all-pairs", "hierarchical-grid"].includes(this.broadPhase) || !Number.isSafeInteger(this.maximumPairs) || this.maximumPairs < 1 || this.maximumPairs > 1073741824 || this.broadPhase === "hierarchical-grid" && (this.maximumPairs & this.maximumPairs - 1) !== 0)
|
|
206
256
|
throw new Error("Invalid rigid-body pair capacity");
|
|
257
|
+
const instancePairCapacity = props.ensemblePairsPerInstance;
|
|
258
|
+
if (instancePairCapacity !== void 0 && (!props.ensembleBodiesPerInstance || props.failurePolicy !== "rollback" || !Number.isSafeInteger(instancePairCapacity) || instancePairCapacity < 1 || instancePairCapacity * (this.count / props.ensembleBodiesPerInstance) > this.maximumPairs || (instancePairCapacity & instancePairCapacity - 1) !== 0))
|
|
259
|
+
throw new Error("Invalid ensemble instance contact capacity");
|
|
207
260
|
if (props.continuous) {
|
|
208
|
-
if (props.failurePolicy !== "rollback" || !Number.isInteger(props.continuous.maximumImpacts ?? 4) || (props.continuous.maximumImpacts ?? 4) < 1 || (props.continuous.maximumImpacts ?? 4) > 16 || !["sphere-static", "convex"].includes(props.continuous.mode ?? "sphere-static") || !Number.isSafeInteger(props.continuous.maximumCandidates ?? this.maximumPairs) || (props.continuous.maximumCandidates ?? this.maximumPairs) < 1 || (props.continuous.maximumCandidates ?? this.maximumPairs) > 1073741824 || props.continuous.mode === "convex" && (Boolean((_d = props.joints) == null ? void 0 : _d.length) || colliders.some((collider) => ["plane", "triangle-mesh"].includes(collider.shape.type))))
|
|
261
|
+
if (props.failurePolicy !== "rollback" || !Number.isInteger(props.continuous.maximumImpacts ?? 4) || (props.continuous.maximumImpacts ?? 4) < 1 || (props.continuous.maximumImpacts ?? 4) > 16 || !["sphere-static", "convex"].includes(props.continuous.mode ?? "sphere-static") || !Number.isSafeInteger(props.continuous.maximumCandidates ?? this.maximumPairs) || (props.continuous.maximumCandidates ?? this.maximumPairs) < 1 || (props.continuous.maximumCandidates ?? this.maximumPairs) > 1073741824 || props.continuous.mode === "convex" && (Boolean((_d = props.joints) == null ? void 0 : _d.length) || colliders.some((collider) => ["plane", "triangle-mesh", "height-field"].includes(collider.shape.type))))
|
|
209
262
|
throw new Error("Invalid continuous settings");
|
|
210
263
|
for (const index of props.continuous.bodies) {
|
|
211
264
|
const body = props.bodies[index];
|
|
@@ -222,20 +275,70 @@ class GPURigidBodyWorld {
|
|
|
222
275
|
const definitions = structuredClone({ colliders, props });
|
|
223
276
|
this.props = definitions.props;
|
|
224
277
|
this.colliders = definitions.colliders;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
278
|
+
this.batchCastIndexEstimate = this.props.queryBatchIndex && this.colliderCount ? (0, import_rigid_body_cast_index.estimateRigidBodyCastIndexBytes)(this.colliders.filter(import_rigid_body_cast_index.canIndexRigidBodyCastCollider).length) : 0;
|
|
279
|
+
this.ensembleTerrainSlots = new Set(this.props.ensembleTerrainSlots);
|
|
280
|
+
if (this.ensembleTerrainSlots.size && (!this.props.ensembleBodiesPerInstance || [...this.ensembleTerrainSlots].some((index) => {
|
|
281
|
+
var _a2;
|
|
282
|
+
return ((_a2 = this.colliders[index]) == null ? void 0 : _a2.shape.type) !== "height-field";
|
|
283
|
+
})))
|
|
284
|
+
throw new Error("Invalid ensemble terrain slots");
|
|
285
|
+
if (this.props.ensembleTerrainAtlas) {
|
|
286
|
+
this.terrainAtlas = new import_rigid_body_terrain_atlas.RigidBodyTerrainAtlas(this.props.ensembleTerrainAtlas, Array.from(this.ensembleTerrainSlots, (collider) => {
|
|
287
|
+
const shape = this.colliders[collider].shape;
|
|
288
|
+
if (shape.type !== "height-field")
|
|
289
|
+
throw new Error("Invalid ensemble terrain slot");
|
|
290
|
+
return { collider, width: shape.field.width, height: shape.field.height };
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
293
|
+
this.bodyColliderStarts = new Uint32Array(this.count + 1);
|
|
294
|
+
let colliderIndex = 0;
|
|
295
|
+
for (let body = 0; body < this.count; body++) {
|
|
296
|
+
this.bodyColliderStarts[body] = colliderIndex;
|
|
297
|
+
while (((_f = this.colliders[colliderIndex]) == null ? void 0 : _f.body) === body)
|
|
298
|
+
colliderIndex++;
|
|
299
|
+
}
|
|
300
|
+
this.bodyColliderStarts[this.count] = colliderIndex;
|
|
301
|
+
if (this.props.vehicle && this.props.vehicles)
|
|
302
|
+
throw new Error("Choose vehicle or vehicles");
|
|
303
|
+
this.vehicles = this.props.vehicles ?? (this.props.vehicle ? [this.props.vehicle] : []);
|
|
304
|
+
this.multiSurfaceVehicles = this.vehicles.some((vehicle) => {
|
|
305
|
+
var _a2;
|
|
306
|
+
return (_a2 = vehicle.additionalTerrainColliders) == null ? void 0 : _a2.length;
|
|
307
|
+
});
|
|
308
|
+
const bodiesPerInstance = props.ensembleBodiesPerInstance;
|
|
309
|
+
const collidersPerInstance = props.collisionPartitionSize;
|
|
310
|
+
this.vehiclesPerInstance = bodiesPerInstance ? this.vehicles.length / (this.count / bodiesPerInstance) : 0;
|
|
311
|
+
if (!Number.isInteger(this.vehiclesPerInstance))
|
|
312
|
+
throw new Error("Invalid ensemble vehicle layout");
|
|
313
|
+
const vehicleChassis = /* @__PURE__ */ new Set();
|
|
314
|
+
for (const [vehicleIndex, vehicle] of this.vehicles.entries()) {
|
|
315
|
+
const instance = bodiesPerInstance ? Math.floor(vehicleIndex / this.vehiclesPerInstance) : 0;
|
|
316
|
+
const terrainIndices = [
|
|
317
|
+
vehicle.terrainCollider,
|
|
318
|
+
...vehicle.additionalTerrainColliders ?? []
|
|
319
|
+
];
|
|
228
320
|
const chassis = this.props.bodies[vehicle.chassis];
|
|
229
|
-
|
|
230
|
-
|
|
321
|
+
if (!chassis || vehicleChassis.has(vehicle.chassis) || terrainIndices.length > 4 || new Set(terrainIndices).size !== terrainIndices.length || terrainIndices.some((colliderIndex2) => {
|
|
322
|
+
const collider = this.colliders[colliderIndex2];
|
|
323
|
+
const ground = collider && this.props.bodies[collider.body];
|
|
324
|
+
return !ground || collider.isTrigger || this.getBodyMode(collider.body) !== "static" || bodiesPerInstance && Math.floor(colliderIndex2 / collidersPerInstance) !== instance;
|
|
325
|
+
}) || (chassis.mode ?? (chassis.mass === 0 ? "static" : "dynamic")) !== "dynamic" || vehicle.wheels.length !== 4 || bodiesPerInstance && Math.floor(vehicle.chassis / bodiesPerInstance) !== instance || ![vehicle.radius, vehicle.travel, vehicle.springRate, vehicle.wheelInertia].every((value) => Number.isFinite(value) && value > 0) || ![vehicle.damping, vehicle.grip, vehicle.motorTorque, vehicle.brakeTorque].every((value) => Number.isFinite(value) && value >= 0) || vehicle.steeringWheelbase !== void 0 && (!Number.isFinite(Math.fround(vehicle.steeringWheelbase)) || vehicle.steeringWheelbase <= 0) || !Number.isFinite(Math.fround(vehicle.antiRollRate ?? 0)) || (vehicle.antiRollRate ?? 0) < 0 || vehicle.slipGain !== void 0 && (vehicle.slipGain.length !== 2 || !vehicle.slipGain.every((gain) => Number.isFinite(Math.fround(gain)) && gain >= 0)) || vehicle.wheels.some((wheel) => wheel.mount.length !== 3 || !wheel.mount.every(Number.isFinite)))
|
|
231
326
|
throw new Error("Invalid vehicle configuration");
|
|
327
|
+
vehicleChassis.add(vehicle.chassis);
|
|
232
328
|
}
|
|
233
329
|
if (props.ensembleBodiesPerInstance)
|
|
234
330
|
this.initialEnsembleBodies = this.props.bodies.slice(0, props.ensembleBodiesPerInstance);
|
|
235
331
|
}
|
|
332
|
+
/** Allocation size including optional immutable terrain rows after the wheel state. */
|
|
333
|
+
getVehicleByteLength() {
|
|
334
|
+
return this.vehicles.length * (import_rigid_body_vehicle.VEHICLE_STRIDE + (this.multiSurfaceVehicles ? import_rigid_body_vehicle.VEHICLE_TERRAIN_ROW_SIZE : 0));
|
|
335
|
+
}
|
|
236
336
|
getStorageLayout() {
|
|
237
|
-
var _a, _b, _c;
|
|
238
|
-
const packed = (0, import_rigid_body_geometry.packRigidBodyShapes)(this.colliders);
|
|
337
|
+
var _a, _b, _c, _d;
|
|
338
|
+
const packed = (0, import_rigid_body_geometry.packRigidBodyShapes)(this.colliders, Boolean(this.props.ensembleBodiesPerInstance), this.ensembleTerrainSlots, Boolean(this.terrainAtlas));
|
|
339
|
+
const geometryWords = packed.geometry.length + (((_a = this.terrainAtlas) == null ? void 0 : _a.wordLength) ?? 0);
|
|
340
|
+
if (this.terrainAtlas && geometryWords >= 2 ** 26)
|
|
341
|
+
throw new Error("Terrain atlas exceeds address capacity");
|
|
239
342
|
const sparse = this.broadPhase === "hierarchical-grid";
|
|
240
343
|
const extended = this.colliders.some((collider) => collider.shape.type !== "sphere" && collider.shape.type !== "box" || collider.isTrigger && collider.shape.type !== "sphere");
|
|
241
344
|
const parallel = this.solver === "parallel";
|
|
@@ -244,11 +347,20 @@ class GPURigidBodyWorld {
|
|
|
244
347
|
sparse,
|
|
245
348
|
extended,
|
|
246
349
|
parallel,
|
|
247
|
-
...(0, import_rigid_body_capacity.getRigidBodyStorageLayout)(this.count, this.colliderStorageCount, this.maximumPairs,
|
|
350
|
+
...(0, import_rigid_body_capacity.getRigidBodyStorageLayout)(this.count, this.colliderStorageCount, this.maximumPairs, geometryWords, sparse, extended, parallel, this.props.eventCapacity ?? 0, this.props.enableQueries ?? false, this.props.failurePolicy === "rollback", Boolean(this.props.continuous), ((_b = this.props.joints) == null ? void 0 : _b.length) ?? 0, this.props.ensembleBodiesPerInstance ? this.count / this.props.ensembleBodiesPerInstance : 0, Boolean(this.props.ensemblePairsPerInstance), this.props.queryBatchCapacity)
|
|
248
351
|
};
|
|
249
|
-
if (this.
|
|
250
|
-
|
|
251
|
-
|
|
352
|
+
if (this.vehicles.length) {
|
|
353
|
+
const byteLength = this.getVehicleByteLength();
|
|
354
|
+
storage.buffers.push({ name: "vehicle", byteLength, uniform: false });
|
|
355
|
+
if (this.props.failurePolicy === "rollback") {
|
|
356
|
+
storage.buffers.push({
|
|
357
|
+
name: this.vehiclesPerInstance ? "checkpoint-vehicles" : "checkpoint-7",
|
|
358
|
+
byteLength: this.vehiclesPerInstance ? this.vehicles.length * import_rigid_body_vehicle.VEHICLE_STRIDE : byteLength,
|
|
359
|
+
uniform: false
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if (((_c = this.props.continuous) == null ? void 0 : _c.mode) === "convex") {
|
|
252
364
|
storage.buffers = storage.buffers.filter((buffer) => buffer.name !== "continuous-previous");
|
|
253
365
|
storage.buffers.push({ name: "continuous-dispatch", byteLength: 16, uniform: false });
|
|
254
366
|
storage.buffers.push({
|
|
@@ -259,7 +371,7 @@ class GPURigidBodyWorld {
|
|
|
259
371
|
}
|
|
260
372
|
if (this.props.publicationBounds || this.props.publishPoses)
|
|
261
373
|
storage.buffers.push({ name: "pose-metadata", byteLength: this.count * 48, uniform: false }, { name: "pose-matrices", byteLength: this.count * 64, uniform: false }, { name: "pose-bounds", byteLength: this.count * 32, uniform: false });
|
|
262
|
-
const triggerLayout = ((
|
|
374
|
+
const triggerLayout = ((_d = this.props.triggers) == null ? void 0 : _d.length) ? (0, import_rigid_body_triggers.makeRigidBodyTriggerLayout)(this.props.triggers, this.colliders) : void 0;
|
|
263
375
|
if (triggerLayout)
|
|
264
376
|
storage.buffers.push({ name: "trigger-previous", byteLength: this.colliderStorageCount * 16, uniform: false }, { name: "trigger-groups", byteLength: triggerLayout.groups.byteLength, uniform: false }, { name: "trigger-pairs", byteLength: triggerLayout.pairs.byteLength, uniform: false }, {
|
|
265
377
|
name: "trigger-samples",
|
|
@@ -292,7 +404,7 @@ class GPURigidBodyWorld {
|
|
|
292
404
|
if (!this.device || !this.ensembleBuffer || this.destroyed)
|
|
293
405
|
throw new Error("World has no ensemble scheduler");
|
|
294
406
|
this.ensembleResetOrigin ??= this.origin;
|
|
295
|
-
this.ensembleReset ??= (0, import_rigid_body_ensemble_reset.makeEnsembleReset)(this.device, this.id, this.ownedBuffers, this.count, this.props.ensembleBodiesPerInstance, this.props.collisionPartitionSize, this.maximumPairs);
|
|
407
|
+
this.ensembleReset ??= (0, import_rigid_body_ensemble_reset.makeEnsembleReset)(this.device, this.id, this.ownedBuffers, this.count, this.props.ensembleBodiesPerInstance, this.props.collisionPartitionSize, this.maximumPairs, this.vehiclesPerInstance, this.ensembleTerrainSlots, this.props.ensemblePairsPerInstance);
|
|
296
408
|
return this.ensembleReset.byteLength;
|
|
297
409
|
}
|
|
298
410
|
resetEnsembleInstance(instance) {
|
|
@@ -303,34 +415,37 @@ class GPURigidBodyWorld {
|
|
|
303
415
|
const colliderStart = instance * this.props.collisionPartitionSize;
|
|
304
416
|
let colliderIndex = colliderStart;
|
|
305
417
|
const restored = this.initialEnsembleBodies.map((body) => {
|
|
306
|
-
|
|
307
|
-
|
|
418
|
+
const { shape, colliders, ...properties } = body;
|
|
419
|
+
const resetCollider = (definition) => {
|
|
420
|
+
var _a;
|
|
421
|
+
const index = colliderIndex++;
|
|
422
|
+
const { body: _, ...current } = this.colliders[index];
|
|
423
|
+
if (this.ensembleTerrainSlots.has(index))
|
|
424
|
+
return current;
|
|
308
425
|
return {
|
|
309
|
-
...
|
|
310
|
-
shape:
|
|
426
|
+
...definition,
|
|
427
|
+
shape: definition.shape.type === "convex-hull" || definition.shape.type === "triangle-mesh" ? current.shape : definition.shape,
|
|
428
|
+
excludedColliders: (_a = definition.excludedColliders) == null ? void 0 : _a.map((index2) => index2 + colliderStart)
|
|
311
429
|
};
|
|
312
|
-
}
|
|
313
|
-
return {
|
|
314
|
-
...body,
|
|
315
|
-
colliders: body.colliders.map((collider) => {
|
|
316
|
-
var _a;
|
|
317
|
-
const current = this.colliders[colliderIndex++].shape;
|
|
318
|
-
return {
|
|
319
|
-
...collider,
|
|
320
|
-
shape: collider.shape.type === "convex-hull" || collider.shape.type === "triangle-mesh" ? current : collider.shape,
|
|
321
|
-
excludedColliders: (_a = collider.excludedColliders) == null ? void 0 : _a.map((index) => index + colliderStart)
|
|
322
|
-
};
|
|
323
|
-
})
|
|
324
430
|
};
|
|
431
|
+
if (shape && !this.ensembleTerrainSlots.has(colliderIndex))
|
|
432
|
+
return { ...body, shape: resetCollider({ shape }).shape };
|
|
433
|
+
return { ...properties, colliders: (colliders ?? [{ shape }]).map(resetCollider) };
|
|
325
434
|
});
|
|
326
|
-
const definitions =
|
|
435
|
+
const definitions = this.props.bodies;
|
|
327
436
|
definitions.splice(bodyStart, restored.length, ...restored);
|
|
328
|
-
this.
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
437
|
+
this.restoreColliderDefinitions(bodyStart, bodyStart + restored.length);
|
|
438
|
+
const metadata = this.ownedBuffers.find((buffer) => buffer.id === `${this.id}-bodies`);
|
|
439
|
+
for (let index = colliderStart; index < colliderIndex; index++) {
|
|
440
|
+
this.colliderShapeScales.delete(index);
|
|
441
|
+
if (!this.ensembleTerrainSlots.has(index))
|
|
442
|
+
continue;
|
|
443
|
+
const collider = this.colliders[index];
|
|
444
|
+
const center = definitions[collider.body].centerOfMass ?? [0, 0, 0];
|
|
445
|
+
metadata.write(new Float32Array((collider.position ?? [0, 0, 0]).map((value, axis) => value - center[axis])), this.count * 48 + index * 96 + 16);
|
|
446
|
+
}
|
|
332
447
|
this.ensembleReset.reset(instance, this.origin.map((value, axis) => value - this.ensembleResetOrigin[axis]));
|
|
333
|
-
this.ensembleBuffer.write(new Uint32Array([0, 0, 0, 0, 1, 1]), (16 + instance * 8 + 1) * 4);
|
|
448
|
+
this.ensembleBuffer.write(new Uint32Array([0, 0, 0, 0, 1, 1, 0]), (16 + instance * 8 + 1) * 4);
|
|
334
449
|
if (this.encodePosePublication) {
|
|
335
450
|
const encoder = this.device.createCommandEncoder();
|
|
336
451
|
this.encodePosePublication(encoder);
|
|
@@ -373,6 +488,7 @@ class GPURigidBodyWorld {
|
|
|
373
488
|
claimedContacts,
|
|
374
489
|
journaledContacts,
|
|
375
490
|
bodySnapshotBytes: activeBodies * 80,
|
|
491
|
+
vehicleSnapshotBytes: activeInstances * this.vehiclesPerInstance * import_rigid_body_vehicle.VEHICLE_STRIDE,
|
|
376
492
|
contactSnapshotBytes: journaledContacts * 416,
|
|
377
493
|
allocatorSnapshotBytes: (8 + activeInstances * 2 + journaledContacts * 3) * 4,
|
|
378
494
|
residentInstances: this.count / this.props.ensembleBodiesPerInstance,
|
|
@@ -384,15 +500,17 @@ class GPURigidBodyWorld {
|
|
|
384
500
|
if (!this.ensembleBuffer || this.destroyed || !Number.isSafeInteger(instance) || instance < 0 || instance >= this.count / this.props.ensembleBodiesPerInstance)
|
|
385
501
|
throw new Error("Invalid ensemble instance");
|
|
386
502
|
}
|
|
387
|
-
/**
|
|
503
|
+
/** World buffer sizes and private query scratch. Simulation graph scratch and driver overhead are separate. */
|
|
388
504
|
getCapacityInfo() {
|
|
389
|
-
|
|
505
|
+
var _a;
|
|
506
|
+
const buffers = this.allocationPlan ? this.allocationPlan.map((buffer) => ({ ...buffer })) : this.getStorageLayout().buffers;
|
|
390
507
|
return {
|
|
391
508
|
bodyCount: this.count,
|
|
392
509
|
colliderCount: this.colliderCount,
|
|
393
510
|
maximumPairs: this.maximumPairs,
|
|
394
511
|
pairWorkgroups: Math.ceil(this.maximumPairs / 64),
|
|
395
512
|
buffers,
|
|
513
|
+
queryIndexScratchBytes: ((_a = this.batchCastIndex) == null ? void 0 : _a.stats.physicalTransientResourceBytes) ?? this.batchCastIndexEstimate,
|
|
396
514
|
ownedBufferBytes: buffers.reduce((total, buffer) => total + buffer.byteLength, 0)
|
|
397
515
|
};
|
|
398
516
|
}
|
|
@@ -405,11 +523,16 @@ class GPURigidBodyWorld {
|
|
|
405
523
|
throw new Error("Rigid-body pair dispatch exceeds device limits");
|
|
406
524
|
if (((_a = this.props.continuous) == null ? void 0 : _a.mode) === "convex" && 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)
|
|
407
525
|
throw new Error("Continuous candidate dispatch exceeds device limits");
|
|
526
|
+
if (!this.vehiclesPerInstance && this.vehicles.length > graph.device.limits.maxComputeWorkgroupsPerDimension)
|
|
527
|
+
throw new Error("Vehicle dispatch exceeds device limits");
|
|
408
528
|
for (const buffer of allocationPlan) {
|
|
409
529
|
const bindingLimit = buffer.uniform ? graph.device.limits.maxUniformBufferBindingSize : graph.device.limits.maxStorageBufferBindingSize;
|
|
410
530
|
if (buffer.byteLength > Math.min(graph.device.limits.maxBufferSize, bindingLimit))
|
|
411
531
|
throw new Error(`Rigid-body ${buffer.name} storage exceeds device limits`);
|
|
412
532
|
}
|
|
533
|
+
if ((this.props.queryBatchCapacity ?? 0) > graph.device.limits.maxComputeWorkgroupsPerDimension)
|
|
534
|
+
throw new Error("Collision cast batch exceeds device dispatch limits");
|
|
535
|
+
this.allocationPlan = allocationPlan;
|
|
413
536
|
this.device = graph.device;
|
|
414
537
|
const allocate = (name, data, uniform = false) => {
|
|
415
538
|
const buffer = graph.device.createBuffer({
|
|
@@ -431,6 +554,29 @@ class GPURigidBodyWorld {
|
|
|
431
554
|
} : void 0;
|
|
432
555
|
const metadata = new Float32Array(metadataLength);
|
|
433
556
|
metadata.set(packed.geometry, geometryOffset);
|
|
557
|
+
if (this.terrainAtlas) {
|
|
558
|
+
this.terrainGeometryWord = geometryOffset;
|
|
559
|
+
this.terrainAtlasWord = geometryOffset + packed.geometry.length;
|
|
560
|
+
const { wordsByCollider, uploads } = this.terrainAtlas.bind(Array.from(packed.atlasFields, ([collider, field]) => ({
|
|
561
|
+
collider,
|
|
562
|
+
data: new Float32Array(field.data)
|
|
563
|
+
})));
|
|
564
|
+
for (const { word, data } of uploads)
|
|
565
|
+
metadata.set(data, this.terrainAtlasWord + word);
|
|
566
|
+
for (const [collider, word] of wordsByCollider) {
|
|
567
|
+
const field = packed.atlasFields.get(collider);
|
|
568
|
+
const address = (packed.geometry.length + word) / 4;
|
|
569
|
+
const shape = packed.shapes[collider];
|
|
570
|
+
shape.padding[0] = address;
|
|
571
|
+
shape.padding[3] = field.triangleCount;
|
|
572
|
+
shape.policies[0] = address + field.nodeOffset;
|
|
573
|
+
shape.policies[1] = field.nodeCount;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
this.heightFieldSlots = new Map(Array.from(packed.heightFields, ([collider, offset]) => [
|
|
577
|
+
collider,
|
|
578
|
+
(geometryOffset + offset * 4) * 4
|
|
579
|
+
]));
|
|
434
580
|
const bodyColliders = Array.from({ length: this.count }, () => []);
|
|
435
581
|
if (this.colliderCount)
|
|
436
582
|
for (const collider of this.colliders)
|
|
@@ -488,7 +634,10 @@ class GPURigidBodyWorld {
|
|
|
488
634
|
(material == null ? void 0 : material.restitutionCombine) ? policies.indexOf(material.restitutionCombine) : 4,
|
|
489
635
|
(material == null ? void 0 : material.frictionCombine) ? policies.indexOf(material.frictionCombine) : 4,
|
|
490
636
|
...shape.policies,
|
|
491
|
-
|
|
637
|
+
shape.padding[0],
|
|
638
|
+
shape.padding[1],
|
|
639
|
+
this.ensembleTerrainSlots.has(index) ? 1 : shape.padding[2],
|
|
640
|
+
shape.padding[3]
|
|
492
641
|
], this.count * 12 + index * 24);
|
|
493
642
|
}
|
|
494
643
|
const exclusionOffset = this.count * 12 + this.colliderStorageCount * 24;
|
|
@@ -499,7 +648,7 @@ class GPURigidBodyWorld {
|
|
|
499
648
|
this.velocities = allocate("velocities", velocities);
|
|
500
649
|
this.angularVelocities = allocate("angular-velocities", angular);
|
|
501
650
|
this.sleepStates = allocate("sleep", this.count * 16);
|
|
502
|
-
this.targets = allocate("targets", this.props.ensembleBodiesPerInstance ? (0, import_rigid_body_ensemble_layout.getEnsembleContactLayout)(this.count, this.count / this.props.ensembleBodiesPerInstance, this.maximumPairs).byteLength : Math.ceil((this.count * 32 + (sparse ? 32 + this.maximumPairs * 8 : 16)) / 16) * 16 + (((_c = this.props.joints) == null ? void 0 : _c.length) ?? 0) * import_rigid_body_joints.RIGID_BODY_JOINT_STATE_BYTES);
|
|
651
|
+
this.targets = allocate("targets", this.props.ensembleBodiesPerInstance ? (0, import_rigid_body_ensemble_layout.getEnsembleContactLayout)(this.count, this.count / this.props.ensembleBodiesPerInstance, this.maximumPairs, Boolean(this.props.ensemblePairsPerInstance)).byteLength : Math.ceil((this.count * 32 + (sparse ? 32 + this.maximumPairs * 8 : 16)) / 16) * 16 + (((_c = this.props.joints) == null ? void 0 : _c.length) ?? 0) * import_rigid_body_joints.RIGID_BODY_JOINT_STATE_BYTES);
|
|
503
652
|
for (const [index, joint] of (this.props.joints ?? []).entries()) {
|
|
504
653
|
this.targets.write((0, import_rigid_body_joints.packRigidBodyJointState)(joint), this.getJointStateOffset() + index * import_rigid_body_joints.RIGID_BODY_JOINT_STATE_BYTES);
|
|
505
654
|
}
|
|
@@ -586,7 +735,7 @@ class GPURigidBodyWorld {
|
|
|
586
735
|
byteLength: objectAttributes.byteLength,
|
|
587
736
|
usage: import_core.Buffer.STORAGE
|
|
588
737
|
}, objectAttributes), { format: "uint32", length: this.colliderStorageCount }) : void 0;
|
|
589
|
-
const source = (0, import_rigid_body_shaders.getRigidBodyShader)(this.count, this.props.iterations ?? 16, this.colliderStorageCount, extended, sparseLayout, parallel, this.props.maximumMeshTraversalTestsPerPair ?? 65536, (0, import_rigid_body_joints.getRigidBodyJointShader)(this.props.joints ?? [], this.props.bodies), Boolean((_d = this.props.joints) == null ? void 0 : _d.length), this.props.linearDamping ?? 0, this.props.angularDamping ?? 0, ((_e = this.props.joints) == null ? void 0 : _e.length) ?? 0, this.props.compactContacts ?? true, this.props.collisionPartitionSize, this.props.ensembleBodiesPerInstance, this.props.parallelContactSolver === "block");
|
|
738
|
+
const source = (0, import_rigid_body_shaders.getRigidBodyShader)(this.count, this.props.iterations ?? 16, this.colliderStorageCount, extended, sparseLayout, parallel, this.props.maximumMeshTraversalTestsPerPair ?? 65536, (0, import_rigid_body_joints.getRigidBodyJointShader)(this.props.joints ?? [], this.props.bodies), Boolean((_d = this.props.joints) == null ? void 0 : _d.length), this.props.linearDamping ?? 0, this.props.angularDamping ?? 0, ((_e = this.props.joints) == null ? void 0 : _e.length) ?? 0, this.props.compactContacts ?? true, this.props.collisionPartitionSize, this.props.ensembleBodiesPerInstance, this.props.parallelContactSolver === "block", this.colliders.some((collider) => collider.shape.type === "height-field"), this.props.ensemblePairsPerInstance);
|
|
590
739
|
const parallelBindings = {
|
|
591
740
|
parallelReset: ["parallelState"],
|
|
592
741
|
parallelResetCounters: ["parallelState"],
|
|
@@ -656,29 +805,6 @@ class GPURigidBodyWorld {
|
|
|
656
805
|
}
|
|
657
806
|
this.simulationStatistics = allocate("simulation-statistics", 64);
|
|
658
807
|
const statisticsResource = graph.importBuffer({ id: `${this.id}-statistics`, byteLength: 64, usage: import_core.Buffer.STORAGE }, this.simulationStatistics);
|
|
659
|
-
const checkpointStates = [
|
|
660
|
-
"positions",
|
|
661
|
-
"orientations",
|
|
662
|
-
"velocities",
|
|
663
|
-
"angularVelocities",
|
|
664
|
-
"sleepStates",
|
|
665
|
-
"targets"
|
|
666
|
-
].map((name) => {
|
|
667
|
-
const binding = bindings.find((binding2) => binding2.name === name);
|
|
668
|
-
return { buffer: binding.buffer, resource: binding.resource };
|
|
669
|
-
});
|
|
670
|
-
const restoreCheckpoint = this.props.failurePolicy === "rollback" ? this.ensembleBuffer ? (0, import_rigid_body_ensemble_transaction.addEnsembleCheckpoint)(graph, this.id, checkpointStates, { buffer: this.simulationStatistics, resource: statisticsResource }, bindings.find((binding) => binding.name === "ensemble"), bindings.find((binding) => binding.name === "manifolds"), this.props.ensembleBodiesPerInstance, this.maximumPairs, allocate) : (0, import_rigid_body_transaction.addRigidBodyCheckpoint)(graph, this.id, [
|
|
671
|
-
"positions",
|
|
672
|
-
"orientations",
|
|
673
|
-
"velocities",
|
|
674
|
-
"angularVelocities",
|
|
675
|
-
"sleepStates",
|
|
676
|
-
"targets",
|
|
677
|
-
...this.ensembleBuffer ? [] : ["manifolds"]
|
|
678
|
-
].map((name) => {
|
|
679
|
-
const binding = bindings.find((binding2) => binding2.name === name);
|
|
680
|
-
return { buffer: binding.buffer, resource: binding.resource };
|
|
681
|
-
}), { buffer: this.simulationStatistics, resource: statisticsResource }, allocate) : void 0;
|
|
682
808
|
const continuousSelection = new Uint32Array(this.count);
|
|
683
809
|
for (const body of ((_g = this.props.continuous) == null ? void 0 : _g.bodies) ?? [])
|
|
684
810
|
continuousSelection[body] = this.colliders.findIndex((collider) => collider.body === body) + 1;
|
|
@@ -690,6 +816,8 @@ class GPURigidBodyWorld {
|
|
|
690
816
|
location: 18
|
|
691
817
|
}, allocate, Boolean((_i = this.props.joints) == null ? void 0 : _i.length), extended) : void 0;
|
|
692
818
|
this.triggerEvents = (triggers == null ? void 0 : triggers.events) ?? null;
|
|
819
|
+
if (triggers && triggerLayout)
|
|
820
|
+
this.triggerHistory = { buffer: triggers.history, groups: triggerLayout.groups };
|
|
693
821
|
const passDescriptions = {
|
|
694
822
|
integrate: "Apply gravity and advance body velocities and predicted poses for this timestep.",
|
|
695
823
|
prepare: "Reset broad-phase counters before generating potential collider pairs.",
|
|
@@ -713,45 +841,66 @@ class GPURigidBodyWorld {
|
|
|
713
841
|
parallelMarkSleep: "Identify islands whose bodies are quiet enough to sleep.",
|
|
714
842
|
parallelSleep: "Put quiet constraint islands to sleep."
|
|
715
843
|
};
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
vehicle.springRate,
|
|
723
|
-
vehicle.damping,
|
|
724
|
-
vehicle.grip,
|
|
725
|
-
vehicle.motorTorque,
|
|
726
|
-
vehicle.brakeTorque,
|
|
727
|
-
vehicle.wheelInertia
|
|
728
|
-
], 4);
|
|
729
|
-
new Uint32Array(data.buffer).set([vehicle.chassis, vehicle.terrainCollider], 12);
|
|
730
|
-
vehicle.wheels.forEach((wheel, index) => {
|
|
731
|
-
const offset = 16 + index * 12;
|
|
732
|
-
data.set(wheel.mount, offset);
|
|
733
|
-
data.set([Number(Boolean(wheel.steer)), Number(Boolean(wheel.drive))], offset + 4);
|
|
734
|
-
data[offset + 10] = vehicle.travel;
|
|
844
|
+
let vehicleResource;
|
|
845
|
+
let addVehiclePass;
|
|
846
|
+
if (this.vehicles.length) {
|
|
847
|
+
const packed2 = new Float32Array(this.getVehicleByteLength() / 4);
|
|
848
|
+
for (const [vehicleIndex, vehicle] of this.vehicles.entries()) {
|
|
849
|
+
const data = packed2.subarray(vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE / 4, (vehicleIndex + 1) * import_rigid_body_vehicle.VEHICLE_STRIDE / 4);
|
|
735
850
|
data.set([
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
wheel.mount
|
|
751
|
-
1
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
851
|
+
vehicle.radius,
|
|
852
|
+
vehicle.travel,
|
|
853
|
+
vehicle.springRate,
|
|
854
|
+
vehicle.damping,
|
|
855
|
+
vehicle.grip,
|
|
856
|
+
vehicle.motorTorque,
|
|
857
|
+
vehicle.brakeTorque,
|
|
858
|
+
vehicle.wheelInertia
|
|
859
|
+
], 4);
|
|
860
|
+
new Uint32Array(data.buffer, data.byteOffset, data.length).set([vehicle.chassis, vehicle.terrainCollider], 12);
|
|
861
|
+
data.set([vehicle.steeringWheelbase ?? 0, vehicle.antiRollRate ?? 0], 14);
|
|
862
|
+
const [longitudinalGain, lateralGain] = vehicle.slipGain ?? [1.1, 1.5];
|
|
863
|
+
vehicle.wheels.forEach((wheel, index) => {
|
|
864
|
+
const offset = 16 + index * 12;
|
|
865
|
+
data.set([...wheel.mount, longitudinalGain + 1], offset);
|
|
866
|
+
data.set([Number(Boolean(wheel.steer)), Number(Boolean(wheel.drive)), lateralGain + 1], offset + 4);
|
|
867
|
+
data[offset + 10] = vehicle.travel;
|
|
868
|
+
data.set([
|
|
869
|
+
1,
|
|
870
|
+
0,
|
|
871
|
+
0,
|
|
872
|
+
0,
|
|
873
|
+
0,
|
|
874
|
+
1,
|
|
875
|
+
0,
|
|
876
|
+
0,
|
|
877
|
+
0,
|
|
878
|
+
0,
|
|
879
|
+
1,
|
|
880
|
+
0,
|
|
881
|
+
wheel.mount[0],
|
|
882
|
+
wheel.mount[1],
|
|
883
|
+
wheel.mount[2] - vehicle.travel,
|
|
884
|
+
1
|
|
885
|
+
], 64 + 16 * index);
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
if (this.multiSurfaceVehicles) {
|
|
889
|
+
const terrainRows = new Uint32Array(packed2.buffer, this.vehicles.length * import_rigid_body_vehicle.VEHICLE_STRIDE);
|
|
890
|
+
terrainRows.fill(4294967295);
|
|
891
|
+
for (const [vehicleIndex, vehicle] of this.vehicles.entries())
|
|
892
|
+
terrainRows.set(vehicle.additionalTerrainColliders ?? [], vehicleIndex * (import_rigid_body_vehicle.VEHICLE_TERRAIN_ROW_SIZE / 4));
|
|
893
|
+
}
|
|
894
|
+
this.vehicleBuffer = allocate("vehicle", packed2);
|
|
895
|
+
vehicleResource = {
|
|
896
|
+
buffer: this.vehicleBuffer,
|
|
897
|
+
resource: graph.importBuffer({
|
|
898
|
+
id: this.id + "-vehicle",
|
|
899
|
+
byteLength: packed2.byteLength,
|
|
900
|
+
usage: import_core.Buffer.STORAGE | import_core.Buffer.COPY_SRC
|
|
901
|
+
}, this.vehicleBuffer)
|
|
902
|
+
};
|
|
903
|
+
const ensembleBinding = bindings.find((binding) => binding.name === "ensemble");
|
|
755
904
|
const vehicleBindings = [
|
|
756
905
|
...bindings.filter((binding) => [
|
|
757
906
|
"settings",
|
|
@@ -760,45 +909,74 @@ class GPURigidBodyWorld {
|
|
|
760
909
|
"velocities",
|
|
761
910
|
"angularVelocities",
|
|
762
911
|
"bodies",
|
|
763
|
-
"sleepStates"
|
|
912
|
+
"sleepStates",
|
|
913
|
+
"ensemble"
|
|
764
914
|
].includes(binding.name)),
|
|
765
|
-
{
|
|
766
|
-
name: "vehicle",
|
|
767
|
-
location: 12,
|
|
768
|
-
buffer: this.vehicleBuffer,
|
|
769
|
-
resource: graph.importBuffer({ id: this.id + "-vehicle", byteLength: data.byteLength, usage: import_core.Buffer.STORAGE }, this.vehicleBuffer)
|
|
770
|
-
}
|
|
915
|
+
{ name: "vehicle", location: 12, ...vehicleResource }
|
|
771
916
|
];
|
|
772
917
|
const properties = {
|
|
773
918
|
id: this.id + "-suspension",
|
|
774
|
-
source: source + import_rigid_body_query_geometry.RIGID_BODY_QUERY_GEOMETRY_SHADER + import_rigid_body_vehicle.
|
|
919
|
+
source: (0, import_rigid_body_ensemble_shaders.readOnlyEnsembleShader)(source) + import_rigid_body_query_geometry.RIGID_BODY_QUERY_GEOMETRY_SHADER + (0, import_rigid_body_vehicle.getVehicleShader)(this.vehicles.length, this.multiSurfaceVehicles, this.vehiclesPerInstance),
|
|
775
920
|
entryPoint: "advanceVehicle",
|
|
776
921
|
shaderLayout: {
|
|
777
922
|
bindings: vehicleBindings.map(({ name, location }) => name === "settings" ? { name, location, group: 0, type: "uniform" } : {
|
|
778
923
|
name,
|
|
779
924
|
location,
|
|
780
925
|
group: 0,
|
|
781
|
-
type: name === "bodies" ? "read-only-storage" : "storage"
|
|
926
|
+
type: name === "bodies" || name === "ensemble" ? "read-only-storage" : "storage"
|
|
782
927
|
})
|
|
783
928
|
}
|
|
784
929
|
};
|
|
785
930
|
const executable = (computation) => ({
|
|
786
931
|
encode: ({ computePass, getBuffer }) => {
|
|
787
932
|
Object.assign(computation.bindings, Object.fromEntries(vehicleBindings.map((binding) => [binding.name, getBuffer(binding.resource)])));
|
|
788
|
-
|
|
933
|
+
if (ensembleBinding)
|
|
934
|
+
computation.kernel.dispatchIndirect(computePass, {
|
|
935
|
+
bindings: computation.bindings,
|
|
936
|
+
indirectBuffer: getBuffer(ensembleBinding.resource),
|
|
937
|
+
indirectOffset: 16
|
|
938
|
+
});
|
|
939
|
+
else
|
|
940
|
+
computation.kernel.dispatch(computePass, {
|
|
941
|
+
bindings: computation.bindings,
|
|
942
|
+
x: this.vehicles.length
|
|
943
|
+
});
|
|
789
944
|
},
|
|
790
945
|
destroy: () => computation.kernel.destroy()
|
|
791
946
|
});
|
|
792
|
-
graph.addComputePass({
|
|
947
|
+
addVehiclePass = () => graph.addComputePass({
|
|
793
948
|
id: properties.id,
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
949
|
+
description: "Sweep four wheels and apply suspension and tire forces per chassis.",
|
|
950
|
+
resources: [
|
|
951
|
+
...vehicleBindings.map((binding) => ({
|
|
952
|
+
buffer: binding.resource,
|
|
953
|
+
usage: binding.name === "settings" ? "uniform" : binding.name === "bodies" || binding.name === "ensemble" ? "storage-read" : "storage-read-write"
|
|
954
|
+
})),
|
|
955
|
+
...ensembleBinding ? [{ buffer: ensembleBinding.resource, usage: "indirect" }] : []
|
|
956
|
+
],
|
|
798
957
|
compile: () => executable((0, import_bound_kernel.createBoundKernel)(graph.device, properties)),
|
|
799
958
|
compileAsync: async () => executable(await (0, import_bound_kernel.createBoundKernelAsync)(graph.device, properties))
|
|
800
959
|
});
|
|
801
960
|
}
|
|
961
|
+
const checkpointStates = [
|
|
962
|
+
"positions",
|
|
963
|
+
"orientations",
|
|
964
|
+
"velocities",
|
|
965
|
+
"angularVelocities",
|
|
966
|
+
"sleepStates",
|
|
967
|
+
"targets"
|
|
968
|
+
].map((name) => {
|
|
969
|
+
const binding = bindings.find((binding2) => binding2.name === name);
|
|
970
|
+
return { buffer: binding.buffer, resource: binding.resource };
|
|
971
|
+
});
|
|
972
|
+
const restoreCheckpoint = this.props.failurePolicy === "rollback" ? this.ensembleBuffer ? (0, import_rigid_body_ensemble_transaction.addEnsembleCheckpoint)(graph, this.id, checkpointStates, { buffer: this.simulationStatistics, resource: statisticsResource }, bindings.find((binding) => binding.name === "ensemble"), bindings.find((binding) => binding.name === "manifolds"), this.props.ensembleBodiesPerInstance, this.maximumPairs, allocate, vehicleResource && {
|
|
973
|
+
state: vehicleResource,
|
|
974
|
+
vehiclesPerInstance: this.vehiclesPerInstance
|
|
975
|
+
}, this.props.ensemblePairsPerInstance) : (0, import_rigid_body_transaction.addRigidBodyCheckpoint)(graph, this.id, [
|
|
976
|
+
...checkpointStates,
|
|
977
|
+
bindings.find((binding) => binding.name === "manifolds"),
|
|
978
|
+
...vehicleResource ? [vehicleResource] : []
|
|
979
|
+
], { buffer: this.simulationStatistics, resource: statisticsResource }, allocate) : void 0;
|
|
802
980
|
for (const entryPoint of [
|
|
803
981
|
...this.ensembleBuffer ? ["ensembleClear", "ensembleMark", "ensembleCompact", "ensembleDispatch"] : [],
|
|
804
982
|
"integrate",
|
|
@@ -827,8 +1005,10 @@ class GPURigidBodyWorld {
|
|
|
827
1005
|
"parallelSleep"
|
|
828
1006
|
] : [...extended && ((_j = this.props.joints) == null ? void 0 : _j.length) ? ["meshCollect"] : [], "solve", "finish"]
|
|
829
1007
|
]) {
|
|
830
|
-
if (entryPoint === "integrate")
|
|
1008
|
+
if (entryPoint === "integrate") {
|
|
831
1009
|
(_k = restoreCheckpoint == null ? void 0 : restoreCheckpoint.save) == null ? void 0 : _k.call(restoreCheckpoint);
|
|
1010
|
+
addVehiclePass == null ? void 0 : addVehiclePass();
|
|
1011
|
+
}
|
|
832
1012
|
if (sparse && entryPoint === "collide") {
|
|
833
1013
|
const bodyBinding = bindings.find((binding) => binding.name === "bodies");
|
|
834
1014
|
const minimumBinding = bindings.find((binding) => binding.name === "minima");
|
|
@@ -1104,7 +1284,10 @@ class GPURigidBodyWorld {
|
|
|
1104
1284
|
});
|
|
1105
1285
|
restoreCheckpoint == null ? void 0 : restoreCheckpoint.restore();
|
|
1106
1286
|
if (this.ensembleBuffer)
|
|
1107
|
-
(0, import_rigid_body_ensemble_shaders.addEnsembleStatus)(graph, this.id, this.count / this.props.ensembleBodiesPerInstance, this.props.ensembleBodiesPerInstance, diagnosticBinding("bodies"), diagnosticBinding("sleepStates"), diagnosticBinding("ensemble"), { buffer: this.simulationStatistics, resource: statisticsResource }
|
|
1287
|
+
(0, import_rigid_body_ensemble_shaders.addEnsembleStatus)(graph, this.id, this.count / this.props.ensembleBodiesPerInstance, this.props.ensembleBodiesPerInstance, diagnosticBinding("bodies"), diagnosticBinding("sleepStates"), diagnosticBinding("ensemble"), { buffer: this.simulationStatistics, resource: statisticsResource }, this.props.ensemblePairsPerInstance ? {
|
|
1288
|
+
...diagnosticBinding("targets"),
|
|
1289
|
+
wordOffset: (0, import_rigid_body_ensemble_layout.getEnsembleContactLayout)(this.count, this.count / this.props.ensembleBodiesPerInstance, this.maximumPairs, true).failureOffset
|
|
1290
|
+
} : void 0);
|
|
1108
1291
|
triggers == null ? void 0 : triggers.publish();
|
|
1109
1292
|
if (this.props.publicationBounds || this.props.publishPoses) {
|
|
1110
1293
|
const publication = (0, import_rigid_body_publication.addRigidBodyPosePublication)(graph, this.id, this.props.bodies, this.props.publicationBounds ?? this.props.bodies.map(() => [
|
|
@@ -1117,6 +1300,7 @@ class GPURigidBodyWorld {
|
|
|
1117
1300
|
}
|
|
1118
1301
|
if (this.props.eventCapacity) {
|
|
1119
1302
|
const contactHistory = allocate("contact-history", this.maximumPairs * 16);
|
|
1303
|
+
this.contactHistory = contactHistory;
|
|
1120
1304
|
this.contactEvents = allocate("contact-events", 16 + this.props.eventCapacity * 64);
|
|
1121
1305
|
const eventBindings = [
|
|
1122
1306
|
...bindings.filter((binding) => ["bodies", "manifolds", "ensemble"].includes(binding.name)),
|
|
@@ -1140,35 +1324,21 @@ class GPURigidBodyWorld {
|
|
|
1140
1324
|
}, binding.buffer)
|
|
1141
1325
|
}))
|
|
1142
1326
|
];
|
|
1143
|
-
const
|
|
1327
|
+
const contactResources = eventBindings.map(({ name, resource, location }) => ({
|
|
1328
|
+
name,
|
|
1329
|
+
resource,
|
|
1330
|
+
location,
|
|
1331
|
+
readOnly: name === "bodies" || name === "eventStatistics"
|
|
1332
|
+
}));
|
|
1333
|
+
(0, import_rigid_body_event_compaction.addRigidBodyEventCompaction)(graph, {
|
|
1144
1334
|
id: `${this.id}-contact-events`,
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
type: ["bodies", "eventStatistics"].includes(name) ? "read-only-storage" : "storage"
|
|
1153
|
-
}))
|
|
1154
|
-
}
|
|
1155
|
-
};
|
|
1156
|
-
const executable = (computation) => ({
|
|
1157
|
-
encode: ({ computePass, getBuffer }) => {
|
|
1158
|
-
Object.assign(computation.bindings, Object.fromEntries(eventBindings.map((binding) => [binding.name, getBuffer(binding.resource)])));
|
|
1159
|
-
computation.kernel.dispatch(computePass, { bindings: computation.bindings, x: 1 });
|
|
1160
|
-
},
|
|
1161
|
-
destroy: () => computation.kernel.destroy()
|
|
1162
|
-
});
|
|
1163
|
-
graph.addComputePass({
|
|
1164
|
-
id: properties.id,
|
|
1165
|
-
description: "Compare contact history and publish contact begin, persist, and end events.",
|
|
1166
|
-
resources: eventBindings.map((binding) => ({
|
|
1167
|
-
buffer: binding.resource,
|
|
1168
|
-
usage: ["bodies", "eventStatistics"].includes(binding.name) ? "storage-read" : "storage-read-write"
|
|
1169
|
-
})),
|
|
1170
|
-
compile: () => executable((0, import_bound_kernel.createBoundKernel)(graph.device, properties)),
|
|
1171
|
-
compileAsync: async () => executable(await (0, import_bound_kernel.createBoundKernelAsync)(graph.device, properties))
|
|
1335
|
+
rowCount: this.maximumPairs,
|
|
1336
|
+
capacity: this.props.eventCapacity,
|
|
1337
|
+
ring: "contactEvents",
|
|
1338
|
+
source: source + (0, import_rigid_body_events.getRigidBodyEventShader)(this.props.eventCapacity, this.props.impactImpulseThreshold ?? 1, this.props.failurePolicy === "rollback", this.props.ensemblePairsPerInstance),
|
|
1339
|
+
classify: contactResources.filter((binding) => !["bodies", "contactEvents"].includes(binding.name)),
|
|
1340
|
+
commit: contactResources.filter((binding) => ["eventStatistics", "contactEvents"].includes(binding.name)),
|
|
1341
|
+
publish: contactResources.filter((binding) => !["eventStatistics", "ensemble"].includes(binding.name))
|
|
1172
1342
|
});
|
|
1173
1343
|
}
|
|
1174
1344
|
if (this.props.enableQueries) {
|
|
@@ -1209,6 +1379,43 @@ class GPURigidBodyWorld {
|
|
|
1209
1379
|
queryOutput: this.queryOutput
|
|
1210
1380
|
}
|
|
1211
1381
|
});
|
|
1382
|
+
if (this.props.queryBatchCapacity) {
|
|
1383
|
+
const capacity = this.props.queryBatchCapacity;
|
|
1384
|
+
this.batchCastCommands = allocate("query-batch-commands", capacity * import_rigid_body_queries.RIGID_BODY_CAST_COMMAND_BYTES);
|
|
1385
|
+
this.batchCastResults = allocate("query-batch-results", capacity * import_rigid_body_queries.RIGID_BODY_BATCH_RESULT_BYTES);
|
|
1386
|
+
const batchBindings = {
|
|
1387
|
+
positions: this.positions,
|
|
1388
|
+
orientations: this.orientations,
|
|
1389
|
+
bodies,
|
|
1390
|
+
querySelection: this.querySelection,
|
|
1391
|
+
batchCommands: this.batchCastCommands,
|
|
1392
|
+
batchResults: this.batchCastResults
|
|
1393
|
+
};
|
|
1394
|
+
const batchLayout = [
|
|
1395
|
+
...queryProperties.shaderLayout.bindings.filter((binding) => ["positions", "orientations", "bodies", "querySelection"].includes(binding.name)),
|
|
1396
|
+
{ name: "batchCommands", group: 0, location: 30, type: "read-only-storage" },
|
|
1397
|
+
{ name: "batchResults", group: 0, location: 31, type: "storage" }
|
|
1398
|
+
];
|
|
1399
|
+
this.batchCast = (0, import_bound_kernel.createBoundKernel)(graph.device, {
|
|
1400
|
+
id: `${this.id}-batched-casts`,
|
|
1401
|
+
entryPoint: "castBatch",
|
|
1402
|
+
source: queryProperties.source + (0, import_rigid_body_queries.getRigidBodyBatchCastShader)(),
|
|
1403
|
+
shaderLayout: { bindings: batchLayout },
|
|
1404
|
+
bindings: batchBindings
|
|
1405
|
+
});
|
|
1406
|
+
if (this.props.queryBatchIndex && this.colliderCount) {
|
|
1407
|
+
this.batchCastOrder = (0, import_rigid_body_cast_index.getRigidBodyCastOrder)(this.colliders, this.props.bodies);
|
|
1408
|
+
if (this.batchCastOrder.indexedCount) {
|
|
1409
|
+
this.batchCastIndex = (0, import_rigid_body_cast_index.createRigidBodyCastIndex)(graph.device, {
|
|
1410
|
+
id: `${this.id}-cast-index`,
|
|
1411
|
+
source: queryProperties.source,
|
|
1412
|
+
layout: batchLayout,
|
|
1413
|
+
buffers: batchBindings,
|
|
1414
|
+
indexedCount: this.batchCastOrder.indexedCount
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1212
1419
|
}
|
|
1213
1420
|
this.controlSettings = allocate("control-settings", 64, true);
|
|
1214
1421
|
const controlProperties = {
|
|
@@ -1288,6 +1495,48 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1288
1495
|
},
|
|
1289
1496
|
bindings: Object.fromEntries(Object.entries(controlProperties.bindings).filter(([name]) => invalidationBindings.includes(name)))
|
|
1290
1497
|
});
|
|
1498
|
+
if (this.heightFieldSlots.size && !this.ensembleBuffer) {
|
|
1499
|
+
this.terrainWake = (0, import_bound_kernel.createBoundKernel)(graph.device, {
|
|
1500
|
+
id: `${this.id}-terrain-wake`,
|
|
1501
|
+
entryPoint: "wakeTerrain",
|
|
1502
|
+
source: controlProperties.source + /* wgsl */
|
|
1503
|
+
`
|
|
1504
|
+
@group(0) @binding(26) var<storage,read_write> terrainSleep:array<atomic<u32>>;
|
|
1505
|
+
@compute @workgroup_size(64) fn wakeTerrain(@builtin(global_invocation_id) invocation:vec3u) {
|
|
1506
|
+
let collider=invocation.x;if(collider>=COLLIDER_COUNT){return;}
|
|
1507
|
+
let body=colliderBody(collider);if(!dynamic(body)){return;}
|
|
1508
|
+
let tile=command.bodyIndex.x;if(bodies.colliders[tile].padding.w==0.0){return;}
|
|
1509
|
+
if(any(abs(colliderPosition(collider)-colliderPosition(tile))>shapeWorldExtent(collider)+shapeWorldExtent(tile)+vec3f(settings.solver.x))){return;}
|
|
1510
|
+
// Several colliders on one sleeping body may all overlap the tile.
|
|
1511
|
+
for(var axis=0u;axis<4u;axis++){atomicStore(&terrainSleep[body*4u+axis],0u);}
|
|
1512
|
+
}`,
|
|
1513
|
+
shaderLayout: {
|
|
1514
|
+
bindings: [
|
|
1515
|
+
...shaderLayout.bindings.filter((binding) => ["settings", "positions", "orientations", "bodies"].includes(binding.name)),
|
|
1516
|
+
{ name: "command", group: 0, location: 8, type: "uniform" },
|
|
1517
|
+
{ name: "terrainSleep", group: 0, location: 26, type: "storage" }
|
|
1518
|
+
]
|
|
1519
|
+
},
|
|
1520
|
+
bindings: {
|
|
1521
|
+
settings: buffers.settings,
|
|
1522
|
+
positions: buffers.positions,
|
|
1523
|
+
orientations: buffers.orientations,
|
|
1524
|
+
bodies: buffers.bodies,
|
|
1525
|
+
command: this.controlSettings,
|
|
1526
|
+
terrainSleep: this.sleepStates
|
|
1527
|
+
}
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
/** Wake sleeping bodies overlapping one published terrain footprint. */
|
|
1532
|
+
wakeTerrainFootprint(collider) {
|
|
1533
|
+
const { kernel, bindings } = this.terrainWake;
|
|
1534
|
+
this.controlSettings.write(new Uint32Array([collider]), 48);
|
|
1535
|
+
const encoder = this.device.createCommandEncoder();
|
|
1536
|
+
const pass = encoder.beginComputePass();
|
|
1537
|
+
kernel.dispatch(pass, { bindings, x: Math.ceil(this.colliderStorageCount / 64) });
|
|
1538
|
+
pass.end();
|
|
1539
|
+
this.device.submit(encoder.finish());
|
|
1291
1540
|
}
|
|
1292
1541
|
invalidateState(pass) {
|
|
1293
1542
|
var _a, _b;
|
|
@@ -1305,7 +1554,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1305
1554
|
}
|
|
1306
1555
|
/** Rebase between submissions, preserving velocities, contact impulses and sleeping state. */
|
|
1307
1556
|
shiftOrigin(shift) {
|
|
1308
|
-
if (!this.device || this.destroyed || this.queryPending || this.
|
|
1557
|
+
if (!this.device || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
1309
1558
|
throw new Error("Origin shifting requires an idle attached world");
|
|
1310
1559
|
if (shift.length !== 3 || shift.some((value) => !Number.isFinite(value) || Math.fround(value) !== value))
|
|
1311
1560
|
throw new Error("Origin shift must be an exactly representable float32 vector");
|
|
@@ -1321,62 +1570,76 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1321
1570
|
return definition ? definition.mode ?? ((definition.mass ?? 1) === 0 ? "static" : "dynamic") : void 0;
|
|
1322
1571
|
}
|
|
1323
1572
|
/** Set signed throttle, steering angle in radians and brake fraction for upcoming substeps. */
|
|
1324
|
-
setVehicleControls(throttle, steering, brake) {
|
|
1325
|
-
if (!this.vehicleBuffer || this.destroyed || ![throttle, steering, brake].every(Number.isFinite))
|
|
1573
|
+
setVehicleControls(throttle, steering, brake, vehicleIndex = 0) {
|
|
1574
|
+
if (!this.vehicleBuffer || this.destroyed || !this.vehicles[vehicleIndex] || ![throttle, steering, brake].every((value) => Number.isFinite(Math.fround(value))))
|
|
1326
1575
|
throw new Error("Invalid vehicle controls");
|
|
1327
1576
|
this.vehicleBuffer.write(new Float32Array([
|
|
1328
1577
|
Math.max(-1, Math.min(1, throttle)),
|
|
1329
1578
|
steering,
|
|
1330
1579
|
Math.max(0, Math.min(1, brake)),
|
|
1331
1580
|
0
|
|
1332
|
-
]));
|
|
1581
|
+
]), vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE);
|
|
1582
|
+
if (this.vehiclesPerInstance) {
|
|
1583
|
+
const instance = Math.floor(vehicleIndex / this.vehiclesPerInstance);
|
|
1584
|
+
this.ensembleBuffer.write(new Uint32Array([1]), (16 + instance * 8 + 6) * 4);
|
|
1585
|
+
}
|
|
1333
1586
|
}
|
|
1334
1587
|
/** Borrow four column-major wheel transforms relative to the chassis node, ordered by mount. */
|
|
1335
1588
|
get vehicleWheelPoses() {
|
|
1336
|
-
return this.
|
|
1589
|
+
return this.getVehicleWheelPoses();
|
|
1590
|
+
}
|
|
1591
|
+
/** Borrow the indexed vehicle’s four chassis-local wheel poses, in mount order. */
|
|
1592
|
+
getVehicleWheelPoses(vehicleIndex = 0) {
|
|
1593
|
+
return this.vehicleBuffer && !this.destroyed && this.vehicles[vehicleIndex] ? {
|
|
1594
|
+
buffer: this.vehicleBuffer,
|
|
1595
|
+
byteOffset: vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE + 256,
|
|
1596
|
+
byteLength: 256
|
|
1597
|
+
} : null;
|
|
1337
1598
|
}
|
|
1338
1599
|
/** Transfer wheel motion between rebuilt worlds for wheels with matching chassis-local mounts. */
|
|
1339
|
-
copyVehicleMotionFrom(previous) {
|
|
1600
|
+
copyVehicleMotionFrom(previous, vehicleIndex = 0, previousVehicleIndex = 0) {
|
|
1340
1601
|
var _a;
|
|
1341
1602
|
const sourceBuffer = previous.vehicleBuffer;
|
|
1342
1603
|
const destinationBuffer = this.vehicleBuffer;
|
|
1343
|
-
const previousVehicle = previous.
|
|
1604
|
+
const previousVehicle = previous.vehicles[previousVehicleIndex];
|
|
1344
1605
|
if (!this.device || !sourceBuffer || !destinationBuffer || !previousVehicle)
|
|
1345
1606
|
return;
|
|
1346
1607
|
const encoder = this.device.createCommandEncoder();
|
|
1347
|
-
(_a = this.
|
|
1608
|
+
(_a = this.vehicles[vehicleIndex]) == null ? void 0 : _a.wheels.forEach((wheel, index) => {
|
|
1348
1609
|
const sourceIndex = previousVehicle.wheels.findIndex((source) => source.mount.every((coordinate, axis) => coordinate === wheel.mount[axis]));
|
|
1349
1610
|
if (sourceIndex < 0)
|
|
1350
1611
|
return;
|
|
1351
1612
|
encoder.copyBufferToBuffer({
|
|
1352
1613
|
sourceBuffer,
|
|
1353
1614
|
destinationBuffer,
|
|
1354
|
-
sourceOffset:
|
|
1355
|
-
destinationOffset:
|
|
1356
|
-
size:
|
|
1615
|
+
sourceOffset: previousVehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE + 92 + sourceIndex * 48,
|
|
1616
|
+
destinationOffset: vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE + 92 + index * 48,
|
|
1617
|
+
size: 20
|
|
1357
1618
|
});
|
|
1358
1619
|
encoder.copyBufferToBuffer({
|
|
1359
1620
|
sourceBuffer,
|
|
1360
1621
|
destinationBuffer,
|
|
1361
|
-
sourceOffset: 256 + sourceIndex * 64,
|
|
1362
|
-
destinationOffset: 256 + index * 64,
|
|
1622
|
+
sourceOffset: previousVehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE + 256 + sourceIndex * 64,
|
|
1623
|
+
destinationOffset: vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE + 256 + index * 64,
|
|
1363
1624
|
size: 64
|
|
1364
1625
|
});
|
|
1365
1626
|
});
|
|
1366
1627
|
this.device.submit(encoder.finish());
|
|
1367
1628
|
}
|
|
1368
1629
|
/** Read wheel spin, angle, suspension length and normal load after submitted steps. */
|
|
1369
|
-
async readVehicleWheels() {
|
|
1370
|
-
if (!this.vehicleBuffer || this.destroyed)
|
|
1630
|
+
async readVehicleWheels(vehicleIndex = 0) {
|
|
1631
|
+
if (!this.vehicleBuffer || this.destroyed || !this.vehicles[vehicleIndex])
|
|
1371
1632
|
throw new Error("Vehicle unavailable");
|
|
1372
|
-
const
|
|
1633
|
+
const bytes = await this.vehicleBuffer.readAsync(vehicleIndex * import_rigid_body_vehicle.VEHICLE_STRIDE, 256);
|
|
1634
|
+
const values = new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
1373
1635
|
return Array.from({ length: 4 }, (_, index) => {
|
|
1374
1636
|
const offset = 24 + index * 12;
|
|
1375
1637
|
return {
|
|
1376
1638
|
speed: values[offset],
|
|
1377
1639
|
angle: values[offset + 1],
|
|
1378
1640
|
length: values[offset + 2],
|
|
1379
|
-
load: values[offset + 3]
|
|
1641
|
+
load: values[offset + 3],
|
|
1642
|
+
steering: values[offset - 1]
|
|
1380
1643
|
};
|
|
1381
1644
|
});
|
|
1382
1645
|
}
|
|
@@ -1435,6 +1698,16 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1435
1698
|
metadata.write(data);
|
|
1436
1699
|
this.props.publicationBounds = structuredClone(bounds);
|
|
1437
1700
|
}
|
|
1701
|
+
/** Read the authored collider frame relative to its body's node origin, excluding COM offset. */
|
|
1702
|
+
getColliderTransform(colliderIndex) {
|
|
1703
|
+
const collider = this.colliders[colliderIndex];
|
|
1704
|
+
if (!Number.isInteger(colliderIndex) || !collider || this.destroyed)
|
|
1705
|
+
throw new Error("Invalid collider");
|
|
1706
|
+
return {
|
|
1707
|
+
position: [...collider.position ?? [0, 0, 0]],
|
|
1708
|
+
orientation: (0, import_rigid_body_properties.normalizeRigidBodyRotation)(collider.orientation)
|
|
1709
|
+
};
|
|
1710
|
+
}
|
|
1438
1711
|
/** Applied scale relative to the initially cooked analytic shape. */
|
|
1439
1712
|
getColliderShapeScale(colliderIndex) {
|
|
1440
1713
|
this.getColliderShape(colliderIndex);
|
|
@@ -1460,7 +1733,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1460
1733
|
const shape = structuredClone(edit.shape);
|
|
1461
1734
|
if (edit.shapeScale && (edit.shapeScale.length !== 3 || edit.shapeScale.some((value) => !Number.isFinite(value) || value <= 0)))
|
|
1462
1735
|
throw new Error("Invalid collider shape scale");
|
|
1463
|
-
if (indices.has(edit.collider) || previous.type !== shape.type || shape.type === "convex-hull" || shape.type === "triangle-mesh")
|
|
1736
|
+
if (indices.has(edit.collider) || previous.type !== shape.type || shape.type === "convex-hull" || shape.type === "triangle-mesh" || shape.type === "height-field")
|
|
1464
1737
|
throw new Error("Shape edit requires a topology rebuild");
|
|
1465
1738
|
indices.add(edit.collider);
|
|
1466
1739
|
const properties = (0, import_rigid_body_shape_properties.getRigidBodyShapeProperties)(shape);
|
|
@@ -1493,6 +1766,94 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1493
1766
|
this.setBodyParameters(body, {});
|
|
1494
1767
|
}
|
|
1495
1768
|
}
|
|
1769
|
+
/**
|
|
1770
|
+
* Replace or evict fixed-dimension height-field tiles between submissions.
|
|
1771
|
+
* Optional positions are in each collider's body-local frame. The caller owns
|
|
1772
|
+
* tile selection and must submit already encoded steps before editing residency.
|
|
1773
|
+
*/
|
|
1774
|
+
setHeightFieldTiles(edits) {
|
|
1775
|
+
var _a;
|
|
1776
|
+
if (!edits.length)
|
|
1777
|
+
return;
|
|
1778
|
+
const metadata = this.ownedBuffers.find((buffer) => buffer.id === `${this.id}-bodies`);
|
|
1779
|
+
if (!metadata || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
1780
|
+
throw new Error("Terrain streaming requires an idle attached world");
|
|
1781
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1782
|
+
const packedFields = this.terrainAtlas ? /* @__PURE__ */ new Map() : void 0;
|
|
1783
|
+
const replacements = edits.map(({ collider: colliderIndex, field, position }) => {
|
|
1784
|
+
const collider = this.colliders[colliderIndex];
|
|
1785
|
+
const offset = this.heightFieldSlots.get(colliderIndex);
|
|
1786
|
+
if (offset === void 0 && !(this.terrainAtlas && this.ensembleTerrainSlots.has(colliderIndex)) || (collider == null ? void 0 : collider.shape.type) !== "height-field" || seen.has(colliderIndex))
|
|
1787
|
+
throw new Error("Invalid writable height-field slot");
|
|
1788
|
+
seen.add(colliderIndex);
|
|
1789
|
+
const previous = collider.shape.field;
|
|
1790
|
+
if (field && (field.width !== previous.width || field.height !== previous.height))
|
|
1791
|
+
throw new Error("Height-field slot dimensions are fixed");
|
|
1792
|
+
const center = this.props.bodies[collider.body].centerOfMass ?? [0, 0, 0];
|
|
1793
|
+
const localOffset = position == null ? void 0 : position.map((value, axis) => value - center[axis]);
|
|
1794
|
+
if (position && (position.length !== 3 || !(localOffset == null ? void 0 : localOffset.every((value) => Number.isFinite(Math.fround(value))))))
|
|
1795
|
+
throw new Error("Invalid height-field tile position");
|
|
1796
|
+
let payload = field ? packedFields == null ? void 0 : packedFields.get(field) : void 0;
|
|
1797
|
+
if (!payload) {
|
|
1798
|
+
const next = field ? structuredClone(field) : { ...previous, heights: void 0, validity: void 0 };
|
|
1799
|
+
const packed = (0, import_rigid_body_height_field.packRigidBodyHeightField)(next);
|
|
1800
|
+
const data = packedFields && packed.nodeCount ? new Float32Array(packed.data) : null;
|
|
1801
|
+
payload = { field: next, packed, data };
|
|
1802
|
+
if (field)
|
|
1803
|
+
packedFields == null ? void 0 : packedFields.set(field, payload);
|
|
1804
|
+
}
|
|
1805
|
+
return { collider, colliderIndex, offset, position, localOffset, ...payload };
|
|
1806
|
+
});
|
|
1807
|
+
const atlas = (_a = this.terrainAtlas) == null ? void 0 : _a.bind(replacements.map(({ colliderIndex, data }) => ({ collider: colliderIndex, data })));
|
|
1808
|
+
if (this.terrainRevision === 16777215) {
|
|
1809
|
+
this.wake();
|
|
1810
|
+
this.terrainRevision = 1;
|
|
1811
|
+
}
|
|
1812
|
+
const revision = ++this.terrainRevision;
|
|
1813
|
+
for (const { word, data } of (atlas == null ? void 0 : atlas.uploads) ?? [])
|
|
1814
|
+
metadata.write(data, (this.terrainAtlasWord + word) * 4);
|
|
1815
|
+
const changedBodies = /* @__PURE__ */ new Set();
|
|
1816
|
+
const affectedInstances = /* @__PURE__ */ new Set();
|
|
1817
|
+
for (const replacement of replacements) {
|
|
1818
|
+
const { collider, colliderIndex, offset, field, position, localOffset, packed } = replacement;
|
|
1819
|
+
const base = this.count * 48 + colliderIndex * 96;
|
|
1820
|
+
if (this.terrainWake)
|
|
1821
|
+
this.wakeTerrainFootprint(colliderIndex);
|
|
1822
|
+
if (atlas) {
|
|
1823
|
+
const word = atlas.wordsByCollider.get(colliderIndex);
|
|
1824
|
+
const address = word === void 0 ? 0 : (this.terrainAtlasWord - this.terrainGeometryWord + word) / 4;
|
|
1825
|
+
metadata.write(new Float32Array([
|
|
1826
|
+
word === void 0 ? 0 : address + packed.nodeOffset,
|
|
1827
|
+
packed.nodeCount,
|
|
1828
|
+
address
|
|
1829
|
+
]), base + 72);
|
|
1830
|
+
} else {
|
|
1831
|
+
metadata.write(new Float32Array(packed.data), offset);
|
|
1832
|
+
metadata.write(new Float32Array([packed.nodeCount]), base + 76);
|
|
1833
|
+
}
|
|
1834
|
+
metadata.write(new Float32Array(packed.extent), base);
|
|
1835
|
+
metadata.write(new Float32Array([revision, packed.triangleCount]), base + 88);
|
|
1836
|
+
if (position && localOffset) {
|
|
1837
|
+
metadata.write(new Float32Array(localOffset), base + 16);
|
|
1838
|
+
collider.position = [...position];
|
|
1839
|
+
}
|
|
1840
|
+
collider.shape = { type: "height-field", field };
|
|
1841
|
+
changedBodies.add(collider.body);
|
|
1842
|
+
if (this.terrainWake)
|
|
1843
|
+
this.wakeTerrainFootprint(colliderIndex);
|
|
1844
|
+
if (this.props.ensembleBodiesPerInstance)
|
|
1845
|
+
affectedInstances.add(Math.floor(collider.body / this.props.ensembleBodiesPerInstance));
|
|
1846
|
+
}
|
|
1847
|
+
for (const body of changedBodies)
|
|
1848
|
+
this.updateColliderDefinitions(body);
|
|
1849
|
+
for (const instance of affectedInstances)
|
|
1850
|
+
this.wakeEnsembleInstance(instance);
|
|
1851
|
+
}
|
|
1852
|
+
/** Shared atlas utilization, when the fused layout enabled page sharing. */
|
|
1853
|
+
getTerrainAtlasStats() {
|
|
1854
|
+
var _a;
|
|
1855
|
+
return (_a = this.terrainAtlas) == null ? void 0 : _a.getStats();
|
|
1856
|
+
}
|
|
1496
1857
|
/** Change an existing collider material between submissions, invalidating cached friction. */
|
|
1497
1858
|
setColliderMaterial(colliderIndex, material) {
|
|
1498
1859
|
const collider = this.colliders[colliderIndex];
|
|
@@ -1552,10 +1913,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1552
1913
|
}
|
|
1553
1914
|
updateColliderDefinitions(bodyIndex) {
|
|
1554
1915
|
const { shape, colliders, ...properties } = this.props.bodies[bodyIndex];
|
|
1555
|
-
const updated = this.colliders.
|
|
1556
|
-
|
|
1557
|
-
bodies[bodyIndex] = { ...properties, colliders: updated };
|
|
1558
|
-
this.props.bodies = bodies;
|
|
1916
|
+
const updated = this.colliders.slice(this.bodyColliderStarts[bodyIndex], this.bodyColliderStarts[bodyIndex + 1]).map(({ body, ...candidate }) => candidate);
|
|
1917
|
+
this.props.bodies[bodyIndex] = { ...properties, colliders: updated };
|
|
1559
1918
|
}
|
|
1560
1919
|
getColliderMaterial(collider) {
|
|
1561
1920
|
const definition = this.colliders[collider];
|
|
@@ -1563,14 +1922,17 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1563
1922
|
throw new Error("Invalid collider");
|
|
1564
1923
|
return structuredClone(definition.material ?? {});
|
|
1565
1924
|
}
|
|
1566
|
-
restoreColliderDefinitions() {
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
const
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1925
|
+
restoreColliderDefinitions(first = 0, end = this.count) {
|
|
1926
|
+
for (let body = first; body < end; body++) {
|
|
1927
|
+
const definition = this.props.bodies[body];
|
|
1928
|
+
const colliders = definition.colliders ?? (definition.shape ? [{ shape: definition.shape }] : []);
|
|
1929
|
+
for (const [index, source] of colliders.entries()) {
|
|
1930
|
+
const collider = this.colliders[this.bodyColliderStarts[body] + index];
|
|
1931
|
+
collider.shape = source.shape;
|
|
1932
|
+
collider.material = source.material;
|
|
1933
|
+
collider.position = source.position;
|
|
1934
|
+
collider.orientation = source.orientation;
|
|
1935
|
+
}
|
|
1574
1936
|
}
|
|
1575
1937
|
}
|
|
1576
1938
|
/** Update motion properties between submissions; preserve the node pose when its COM changes. */
|
|
@@ -1597,9 +1959,12 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1597
1959
|
(0, import_rigid_body_joints.validateRigidBodyJoints)(this.props.joints, proposedBodies, this.solver);
|
|
1598
1960
|
}
|
|
1599
1961
|
const colliders = this.colliders.filter((collider) => collider.body === bodyIndex);
|
|
1600
|
-
for (const collider of colliders)
|
|
1962
|
+
for (const collider of colliders) {
|
|
1963
|
+
if (collider.shape.type === "height-field" && mode !== "static")
|
|
1964
|
+
throw new Error("Height fields require static bodies");
|
|
1601
1965
|
if ((collider.shape.type === "convex-hull" || collider.shape.type === "triangle-mesh") && mode !== "static" && mass > 0 && (!collider.shape.geometry.closed || !((0, import_rigid_body_shape_properties.getRigidBodyShapeProperties)(collider.shape).volume > 0)))
|
|
1602
1966
|
throw new Error("Dynamic meshes require closed positive-volume geometry");
|
|
1967
|
+
}
|
|
1603
1968
|
if (((_b = this.props.continuous) == null ? void 0 : _b.bodies.includes(bodyIndex)) && (mode !== "dynamic" || mass === 0 || this.props.continuous.mode !== "convex" && (colliders[0].position ?? [0, 0, 0]).some((value, axis) => value !== center[axis])))
|
|
1604
1969
|
throw new Error("Mutation exceeds the continuous body envelope");
|
|
1605
1970
|
const compound = (0, import_rigid_body_properties.getCompoundBodyInertia)(mass, colliders, center);
|
|
@@ -1746,15 +2111,22 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1746
2111
|
readContactEvents() {
|
|
1747
2112
|
if (!this.contactEvents || this.destroyed)
|
|
1748
2113
|
return Promise.reject(new Error("Contact events are not enabled"));
|
|
1749
|
-
|
|
1750
|
-
|
|
2114
|
+
const afterSnapshot = this.contactSnapshotRead;
|
|
2115
|
+
if (this.eventRead && (!afterSnapshot || this.eventRead.afterSnapshot === afterSnapshot))
|
|
2116
|
+
return this.eventRead.result;
|
|
2117
|
+
const pending = {
|
|
2118
|
+
afterSnapshot,
|
|
2119
|
+
result: this.contactEvents.readAsync().finally(() => afterSnapshot).then((bytes) => {
|
|
1751
2120
|
const batch = (0, import_rigid_body_events.decodeRigidBodyContactEvents)(new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4), this.eventCursor);
|
|
1752
2121
|
this.eventCursor = batch.sequence;
|
|
1753
2122
|
return batch;
|
|
1754
2123
|
}).finally(() => {
|
|
1755
|
-
this.eventRead
|
|
1756
|
-
|
|
1757
|
-
|
|
2124
|
+
if (this.eventRead === pending)
|
|
2125
|
+
this.eventRead = null;
|
|
2126
|
+
})
|
|
2127
|
+
};
|
|
2128
|
+
this.eventRead = pending;
|
|
2129
|
+
return pending.result;
|
|
1758
2130
|
}
|
|
1759
2131
|
/** Nearest exact sphere/OBB hit. Origins inside a shape return distance zero and a zero normal. */
|
|
1760
2132
|
raycast(query) {
|
|
@@ -1764,6 +2136,57 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1764
2136
|
overlapSphere(query) {
|
|
1765
2137
|
return this.runQuery(query);
|
|
1766
2138
|
}
|
|
2139
|
+
/**
|
|
2140
|
+
* Query the closest hit for each ray or sphere cast with one submission and readback.
|
|
2141
|
+
* Results follow input order. This snapshots already submitted poses, using one shared collider selection.
|
|
2142
|
+
*/
|
|
2143
|
+
async castBatch(commands, options = {}) {
|
|
2144
|
+
if (!this.device || !this.batchCast || !this.querySelection || !this.batchCastCommands || !this.batchCastResults || this.destroyed || this.queryPending)
|
|
2145
|
+
throw new Error("Batched collision casts are disabled or busy");
|
|
2146
|
+
if (commands.length > this.props.queryBatchCapacity)
|
|
2147
|
+
throw new Error("Collision cast batch exceeds capacity");
|
|
2148
|
+
if (!commands.length)
|
|
2149
|
+
return [];
|
|
2150
|
+
if (options.strategy === "indexed" && !this.props.queryBatchIndex)
|
|
2151
|
+
throw new Error("Batched collision cast index is disabled");
|
|
2152
|
+
const order = options.strategy === "scan" ? null : this.batchCastOrder;
|
|
2153
|
+
const selection = options.colliderIndices ? Uint32Array.from(new Set(this.validateQueryColliders(options.colliderIndices))) : (order == null ? void 0 : order.indices) ?? Uint32Array.from({ length: this.colliderCount }, (_, index) => index);
|
|
2154
|
+
let indexedCount = (order == null ? void 0 : order.indexedCount) ?? 0;
|
|
2155
|
+
if (order && options.colliderIndices) {
|
|
2156
|
+
selection.sort((first, second) => order.ranks[first] - order.ranks[second]);
|
|
2157
|
+
const firstExtended = selection.findIndex((index) => order.ranks[index] >= order.indexedCount);
|
|
2158
|
+
indexedCount = firstExtended < 0 ? selection.length : firstExtended;
|
|
2159
|
+
}
|
|
2160
|
+
const data = (0, import_rigid_body_queries.packRigidBodyBatchCasts)(commands, this.count, selection.length, indexedCount);
|
|
2161
|
+
this.queryPending = true;
|
|
2162
|
+
try {
|
|
2163
|
+
this.batchCastCommands.write(data);
|
|
2164
|
+
if (selection.length)
|
|
2165
|
+
this.querySelection.write(selection);
|
|
2166
|
+
const encoder = this.device.createCommandEncoder();
|
|
2167
|
+
if (this.batchCastIndex && indexedCount) {
|
|
2168
|
+
this.batchCastIndex.encode(encoder, { parameters: commands.length });
|
|
2169
|
+
} else {
|
|
2170
|
+
const pass = encoder.beginComputePass();
|
|
2171
|
+
this.batchCast.kernel.dispatch(pass, {
|
|
2172
|
+
bindings: this.batchCast.bindings,
|
|
2173
|
+
x: commands.length
|
|
2174
|
+
});
|
|
2175
|
+
pass.end();
|
|
2176
|
+
}
|
|
2177
|
+
this.device.submit(encoder.finish());
|
|
2178
|
+
return (0, import_rigid_body_queries.decodeRigidBodyBatchCasts)(await this.batchCastResults.readAsync(0, commands.length * import_rigid_body_queries.RIGID_BODY_BATCH_RESULT_BYTES));
|
|
2179
|
+
} finally {
|
|
2180
|
+
this.queryPending = false;
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
/** Reject invalid indices before scalar or batch query buffers are written. */
|
|
2184
|
+
validateQueryColliders(indices) {
|
|
2185
|
+
for (const index of indices)
|
|
2186
|
+
if (!Number.isInteger(index) || index < 0 || index >= this.colliderCount)
|
|
2187
|
+
throw new Error("Invalid query collider");
|
|
2188
|
+
return indices;
|
|
2189
|
+
}
|
|
1767
2190
|
async runQuery(query) {
|
|
1768
2191
|
if (!this.device || !this.queryComputation || !this.querySettings || !this.querySelection || !this.queryOutput || this.destroyed || this.queryPending)
|
|
1769
2192
|
throw new Error("Queries are disabled or busy");
|
|
@@ -1777,9 +2200,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1777
2200
|
throw new Error("Invalid collision query");
|
|
1778
2201
|
const selected = query.colliderIndices ?? Array.from({ length: this.colliderCount }, (_, index) => index);
|
|
1779
2202
|
const selection = new Uint32Array(this.colliderStorageCount);
|
|
1780
|
-
for (const index of selected) {
|
|
1781
|
-
if (!Number.isInteger(index) || index < 0 || index >= this.colliderCount)
|
|
1782
|
-
throw new Error("Invalid query collider");
|
|
2203
|
+
for (const index of this.validateQueryColliders(selected)) {
|
|
1783
2204
|
const collider = this.colliders[index];
|
|
1784
2205
|
if (collider.body === query.excludeBody)
|
|
1785
2206
|
continue;
|
|
@@ -1809,16 +2230,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1809
2230
|
const bytes = await this.queryOutput.readAsync(0, 16 + maximumHits * 48);
|
|
1810
2231
|
const words = new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
1811
2232
|
const floats = new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
1812
|
-
const hits = Array.from({ length: words[0] }, (_, index) =>
|
|
1813
|
-
const offset = 4 + index * 12;
|
|
1814
|
-
return {
|
|
1815
|
-
body: words[offset],
|
|
1816
|
-
collider: words[offset + 1],
|
|
1817
|
-
point: [floats[offset + 4], floats[offset + 5], floats[offset + 6]],
|
|
1818
|
-
distance: floats[offset + 7],
|
|
1819
|
-
normal: [floats[offset + 8], floats[offset + 9], floats[offset + 10]]
|
|
1820
|
-
};
|
|
1821
|
-
});
|
|
2233
|
+
const hits = Array.from({ length: words[0] }, (_, index) => (0, import_rigid_body_queries.decodeRigidBodyQueryHit)(words, floats, 4 + index * 12));
|
|
1822
2234
|
return {
|
|
1823
2235
|
hits,
|
|
1824
2236
|
totalHits: words[1],
|
|
@@ -1863,22 +2275,94 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1863
2275
|
readTriggerEvents() {
|
|
1864
2276
|
if (!this.triggerEvents || this.destroyed)
|
|
1865
2277
|
throw new Error("Triggers are disabled");
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
2278
|
+
const afterSnapshot = this.triggerSnapshotRead;
|
|
2279
|
+
if (this.triggerRead && (!afterSnapshot || this.triggerRead.afterSnapshot === afterSnapshot))
|
|
2280
|
+
return this.triggerRead.result;
|
|
2281
|
+
const pending = {
|
|
2282
|
+
afterSnapshot,
|
|
2283
|
+
result: this.triggerEvents.readAsync().finally(() => afterSnapshot).then((bytes) => {
|
|
2284
|
+
const batch = (0, import_rigid_body_triggers.decodeRigidBodyTriggerEvents)(new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4), this.triggerCursor);
|
|
2285
|
+
this.triggerCursor = batch.sequence;
|
|
2286
|
+
return batch;
|
|
2287
|
+
}).finally(() => {
|
|
2288
|
+
if (this.triggerRead === pending)
|
|
2289
|
+
this.triggerRead = null;
|
|
2290
|
+
})
|
|
2291
|
+
};
|
|
2292
|
+
this.triggerRead = pending;
|
|
2293
|
+
return pending.result;
|
|
2294
|
+
}
|
|
2295
|
+
/** Recover the active contact set and advance the incremental cursor to the snapshot. */
|
|
2296
|
+
resyncContactEvents() {
|
|
2297
|
+
var _a;
|
|
2298
|
+
if (!this.device || !this.contactEvents || !this.contactHistory || this.destroyed)
|
|
2299
|
+
return Promise.reject(new Error("Contact events are not enabled"));
|
|
2300
|
+
if (this.contactSnapshotRead)
|
|
2301
|
+
return this.contactSnapshotRead;
|
|
2302
|
+
const priorRead = (_a = this.eventRead) == null ? void 0 : _a.result.catch(() => void 0);
|
|
2303
|
+
const snapshot = (0, import_rigid_body_event_snapshot.readRigidBodyEventSnapshot)(this.device, this.contactEvents, this.contactHistory, (header, rows) => {
|
|
2304
|
+
const contacts = [];
|
|
2305
|
+
for (let offset = 0; offset < rows.length; offset += 4) {
|
|
2306
|
+
if (rows[offset + 2] === 0)
|
|
2307
|
+
continue;
|
|
2308
|
+
const first = rows[offset];
|
|
2309
|
+
const second = rows[offset + 1];
|
|
2310
|
+
contacts.push({
|
|
2311
|
+
colliders: [first, second],
|
|
2312
|
+
bodies: [this.colliders[first].body, this.colliders[second].body]
|
|
2313
|
+
});
|
|
2314
|
+
}
|
|
2315
|
+
return { ...header, contacts };
|
|
2316
|
+
});
|
|
2317
|
+
this.contactSnapshotRead = snapshot.finally(() => priorRead).then((result) => {
|
|
2318
|
+
this.eventCursor = result.sequence;
|
|
2319
|
+
return result;
|
|
1872
2320
|
}).finally(() => {
|
|
1873
|
-
this.
|
|
2321
|
+
this.contactSnapshotRead = null;
|
|
1874
2322
|
});
|
|
1875
|
-
return this.
|
|
2323
|
+
return this.contactSnapshotRead;
|
|
2324
|
+
}
|
|
2325
|
+
/** Recover the active trigger overlap set and advance the incremental trigger cursor. */
|
|
2326
|
+
resyncTriggerEvents() {
|
|
2327
|
+
var _a;
|
|
2328
|
+
if (!this.device || !this.triggerEvents || !this.triggerHistory || this.destroyed)
|
|
2329
|
+
return Promise.reject(new Error("Triggers are disabled"));
|
|
2330
|
+
if (this.triggerSnapshotRead)
|
|
2331
|
+
return this.triggerSnapshotRead;
|
|
2332
|
+
const { buffer, groups } = this.triggerHistory;
|
|
2333
|
+
const priorRead = (_a = this.triggerRead) == null ? void 0 : _a.result.catch(() => void 0);
|
|
2334
|
+
const snapshot = (0, import_rigid_body_event_snapshot.readRigidBodyEventSnapshot)(this.device, this.triggerEvents, buffer, (header, rows) => {
|
|
2335
|
+
const overlaps = [];
|
|
2336
|
+
for (let offset = 0; offset < rows.length; offset += 4) {
|
|
2337
|
+
if ((rows[offset] & 1) === 0)
|
|
2338
|
+
continue;
|
|
2339
|
+
overlaps.push({
|
|
2340
|
+
trigger: groups[offset],
|
|
2341
|
+
body: groups[offset + 1],
|
|
2342
|
+
triggerCollider: rows[offset + 1],
|
|
2343
|
+
collider: rows[offset + 2]
|
|
2344
|
+
});
|
|
2345
|
+
}
|
|
2346
|
+
return { ...header, overlaps };
|
|
2347
|
+
});
|
|
2348
|
+
this.triggerSnapshotRead = snapshot.finally(() => priorRead).then((result) => {
|
|
2349
|
+
this.triggerCursor = result.sequence;
|
|
2350
|
+
return result;
|
|
2351
|
+
}).finally(() => {
|
|
2352
|
+
this.triggerSnapshotRead = null;
|
|
2353
|
+
});
|
|
2354
|
+
return this.triggerSnapshotRead;
|
|
2355
|
+
}
|
|
2356
|
+
/** Reset, capture and origin operations require stable event cursors. */
|
|
2357
|
+
get eventReadsPending() {
|
|
2358
|
+
return Boolean(this.eventRead || this.triggerRead || this.contactSnapshotRead || this.triggerSnapshotRead);
|
|
1876
2359
|
}
|
|
1877
2360
|
getSnapshotBuffers(includeRollbackScratch = true) {
|
|
1878
2361
|
return this.ownedBuffers.filter((buffer) => includeRollbackScratch || !buffer.id.startsWith(`${this.id}-checkpoint-`));
|
|
1879
2362
|
}
|
|
1880
2363
|
/** Reusable same-world GPU checkpoint; copies state without CPU pose or buffer readback. */
|
|
1881
2364
|
createGPUCheckpoint(options = {}) {
|
|
2365
|
+
var _a;
|
|
1882
2366
|
if (!this.device || this.destroyed)
|
|
1883
2367
|
throw new Error("Checkpoint requires an attached world");
|
|
1884
2368
|
const device = this.device;
|
|
@@ -1891,6 +2375,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1891
2375
|
let bodyDefinitions = structuredClone(this.props.bodies);
|
|
1892
2376
|
let contactCursor = 0;
|
|
1893
2377
|
let triggerCursor = 0;
|
|
2378
|
+
let terrainRevision = this.terrainRevision;
|
|
2379
|
+
let terrainAtlas = (_a = this.terrainAtlas) == null ? void 0 : _a.snapshot();
|
|
1894
2380
|
try {
|
|
1895
2381
|
for (const buffer of checkpointBuffers)
|
|
1896
2382
|
snapshots.push(device.createBuffer({
|
|
@@ -1904,7 +2390,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1904
2390
|
throw error;
|
|
1905
2391
|
}
|
|
1906
2392
|
const copy = (restore) => {
|
|
1907
|
-
if (released || this.destroyed || this.queryPending || this.
|
|
2393
|
+
if (released || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
1908
2394
|
throw new Error("Checkpoint requires an idle live world");
|
|
1909
2395
|
const encoder = device.createCommandEncoder();
|
|
1910
2396
|
for (const [index, buffer] of checkpointBuffers.entries())
|
|
@@ -1920,6 +2406,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1920
2406
|
const checkpoint = {
|
|
1921
2407
|
byteLength: snapshots.reduce((sum, buffer) => sum + buffer.byteLength, 0),
|
|
1922
2408
|
save: () => {
|
|
2409
|
+
var _a2;
|
|
1923
2410
|
copy(false);
|
|
1924
2411
|
origin = [...this.worldOrigin];
|
|
1925
2412
|
joints = structuredClone(this.props.joints);
|
|
@@ -1928,6 +2415,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1928
2415
|
publicationBounds = structuredClone(this.props.publicationBounds);
|
|
1929
2416
|
contactCursor = this.eventCursor;
|
|
1930
2417
|
triggerCursor = this.triggerCursor;
|
|
2418
|
+
terrainRevision = this.terrainRevision;
|
|
2419
|
+
terrainAtlas = (_a2 = this.terrainAtlas) == null ? void 0 : _a2.snapshot();
|
|
1931
2420
|
saved = true;
|
|
1932
2421
|
},
|
|
1933
2422
|
restore: () => {
|
|
@@ -1942,6 +2431,9 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1942
2431
|
this.props.publicationBounds = structuredClone(publicationBounds);
|
|
1943
2432
|
this.eventCursor = contactCursor;
|
|
1944
2433
|
this.triggerCursor = triggerCursor;
|
|
2434
|
+
this.terrainRevision = terrainRevision;
|
|
2435
|
+
if (terrainAtlas)
|
|
2436
|
+
this.terrainAtlas.restore(terrainAtlas.leases, (_word, _words, page) => terrainAtlas.payloads.get(page));
|
|
1945
2437
|
},
|
|
1946
2438
|
destroy: () => {
|
|
1947
2439
|
if (released)
|
|
@@ -1957,7 +2449,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1957
2449
|
}
|
|
1958
2450
|
/** Stop graph submissions and controls first; includes diagnostics, caches and event history. */
|
|
1959
2451
|
async captureState(options = {}) {
|
|
1960
|
-
|
|
2452
|
+
var _a;
|
|
2453
|
+
if (!this.device || this.destroyed || this.queryPending || this.eventReadsPending)
|
|
1961
2454
|
throw new Error("Capture requires an idle attached world");
|
|
1962
2455
|
return {
|
|
1963
2456
|
version: 1,
|
|
@@ -1967,6 +2460,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1967
2460
|
colliderShapeScales: structuredClone([...this.colliderShapeScales]),
|
|
1968
2461
|
contactCursor: this.eventCursor,
|
|
1969
2462
|
triggerCursor: this.triggerCursor,
|
|
2463
|
+
terrainRevision: this.terrainRevision,
|
|
2464
|
+
terrainAtlasLeases: (_a = this.terrainAtlas) == null ? void 0 : _a.getLeases(),
|
|
1970
2465
|
buffers: await Promise.all(this.getSnapshotBuffers(options.includeRollbackScratch).map(async (buffer) => ({
|
|
1971
2466
|
name: buffer.id.slice(this.id.length + 1),
|
|
1972
2467
|
data: new Uint8Array(await buffer.readAsync())
|
|
@@ -1976,7 +2471,8 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1976
2471
|
/** Restore between submissions on the same configuration and implementation; no implicit wake. */
|
|
1977
2472
|
restoreState(capture) {
|
|
1978
2473
|
const checkpointBuffers = this.getSnapshotBuffers(capture.includeRollbackScratch);
|
|
1979
|
-
|
|
2474
|
+
const terrainRevision = capture.terrainRevision ?? 1;
|
|
2475
|
+
if (!this.device || this.destroyed || this.queryPending || this.eventReadsPending || capture.version !== 1 || Boolean(capture.terrainAtlasLeases) !== Boolean(this.terrainAtlas) || !Number.isInteger(terrainRevision) || terrainRevision < 1 || terrainRevision > 16777215 || capture.origin !== void 0 && (capture.origin.length !== 3 || !capture.origin.every(Number.isFinite)) || capture.buffers.length !== checkpointBuffers.length || serializeCaptureProps(capture.props) !== serializeCaptureProps(this.props) || ![capture.contactCursor, capture.triggerCursor].every((value) => Number.isInteger(value) && value >= 0 && value <= 4294967295))
|
|
1980
2476
|
throw new Error("Incompatible rigid-body capture");
|
|
1981
2477
|
const shapeScales = new Map(capture.colliderShapeScales ?? []);
|
|
1982
2478
|
for (const [index, scale] of shapeScales) {
|
|
@@ -1989,6 +2485,26 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1989
2485
|
if (saved.name !== buffer.id.slice(this.id.length + 1) || !(saved.data instanceof Uint8Array) || saved.data.byteLength !== buffer.byteLength)
|
|
1990
2486
|
throw new Error("Incompatible rigid-body capture storage");
|
|
1991
2487
|
}
|
|
2488
|
+
if (this.terrainAtlas && capture.terrainAtlasLeases) {
|
|
2489
|
+
const metadata = capture.buffers.find((buffer) => buffer.name === "bodies").data;
|
|
2490
|
+
const view = new DataView(metadata.buffer, metadata.byteOffset, metadata.byteLength);
|
|
2491
|
+
const colliderBase = this.count * 48;
|
|
2492
|
+
let active = 0;
|
|
2493
|
+
for (const collider of this.ensembleTerrainSlots)
|
|
2494
|
+
if (view.getFloat32(colliderBase + collider * 96 + 76, true) > 0)
|
|
2495
|
+
active++;
|
|
2496
|
+
if (active !== capture.terrainAtlasLeases.length)
|
|
2497
|
+
throw new Error("Incomplete captured terrain atlas leases");
|
|
2498
|
+
this.terrainAtlas.restore(capture.terrainAtlasLeases, (word, words) => {
|
|
2499
|
+
const first = (this.terrainAtlasWord + word) * 4;
|
|
2500
|
+
return new Float32Array(metadata.slice(first, first + words * 4).buffer);
|
|
2501
|
+
}, (collider, word) => {
|
|
2502
|
+
const base = colliderBase + collider * 96;
|
|
2503
|
+
const address = (this.terrainAtlasWord - this.terrainGeometryWord + word) / 4;
|
|
2504
|
+
if (view.getFloat32(base + 76, true) <= 0 || view.getFloat32(base + 80, true) !== address)
|
|
2505
|
+
throw new Error("Captured terrain collider has an invalid page address");
|
|
2506
|
+
});
|
|
2507
|
+
}
|
|
1992
2508
|
for (const [index, buffer] of checkpointBuffers.entries())
|
|
1993
2509
|
buffer.write(capture.buffers[index].data);
|
|
1994
2510
|
this.props.joints = structuredClone(capture.props.joints);
|
|
@@ -1999,6 +2515,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
1999
2515
|
this.worldOrigin = [...capture.origin ?? [0, 0, 0]];
|
|
2000
2516
|
this.eventCursor = capture.contactCursor;
|
|
2001
2517
|
this.triggerCursor = capture.triggerCursor;
|
|
2518
|
+
this.terrainRevision = terrainRevision;
|
|
2002
2519
|
}
|
|
2003
2520
|
/** Stop submissions first. Reconstruct with these accepted poses and larger budgets after rollback. */
|
|
2004
2521
|
async getRecoveryProps(overrides = {}) {
|
|
@@ -2088,7 +2605,7 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2088
2605
|
}
|
|
2089
2606
|
/** Destroy the compiled graph and finish readbacks before destroying its world. */
|
|
2090
2607
|
destroy() {
|
|
2091
|
-
var _a, _b, _c, _d, _e;
|
|
2608
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2092
2609
|
if (this.destroyed)
|
|
2093
2610
|
return;
|
|
2094
2611
|
(_a = this.ensembleReset) == null ? void 0 : _a.destroy();
|
|
@@ -2097,8 +2614,11 @@ struct Command { impulse: vec4f, point: vec4f, orientation: vec4f, bodyIndex: ve
|
|
|
2097
2614
|
this.destroyed = true;
|
|
2098
2615
|
(_b = this.control) == null ? void 0 : _b.kernel.destroy();
|
|
2099
2616
|
(_c = this.invalidation) == null ? void 0 : _c.kernel.destroy();
|
|
2100
|
-
(_d = this.
|
|
2101
|
-
(_e = this.
|
|
2617
|
+
(_d = this.terrainWake) == null ? void 0 : _d.kernel.destroy();
|
|
2618
|
+
(_e = this.queryComputation) == null ? void 0 : _e.kernel.destroy();
|
|
2619
|
+
(_f = this.queryReduction) == null ? void 0 : _f.kernel.destroy();
|
|
2620
|
+
(_g = this.batchCastIndex) == null ? void 0 : _g.destroy();
|
|
2621
|
+
(_h = this.batchCast) == null ? void 0 : _h.kernel.destroy();
|
|
2102
2622
|
for (const buffer of this.ownedBuffers)
|
|
2103
2623
|
buffer.destroy();
|
|
2104
2624
|
this.ownedBuffers.length = 0;
|
|
@@ -2114,10 +2634,14 @@ function serializeCaptureProps(props) {
|
|
|
2114
2634
|
...body,
|
|
2115
2635
|
shape: void 0,
|
|
2116
2636
|
colliders: (body.colliders ?? [{ shape: body.shape }]).map((collider) => {
|
|
2117
|
-
var _a2, _b, _c;
|
|
2637
|
+
var _a2, _b, _c, _d;
|
|
2118
2638
|
return {
|
|
2119
2639
|
...collider,
|
|
2120
|
-
shape: ((_a2 = collider.shape) == null ? void 0 : _a2.type) === "convex-hull" || ((_b = collider.shape) == null ? void 0 : _b.type) === "triangle-mesh" ? collider.shape :
|
|
2640
|
+
shape: ((_a2 = collider.shape) == null ? void 0 : _a2.type) === "convex-hull" || ((_b = collider.shape) == null ? void 0 : _b.type) === "triangle-mesh" ? collider.shape : ((_c = collider.shape) == null ? void 0 : _c.type) === "height-field" ? {
|
|
2641
|
+
type: collider.shape.type,
|
|
2642
|
+
width: collider.shape.field.width,
|
|
2643
|
+
height: collider.shape.field.height
|
|
2644
|
+
} : { type: (_d = collider.shape) == null ? void 0 : _d.type },
|
|
2121
2645
|
material: void 0,
|
|
2122
2646
|
position: void 0,
|
|
2123
2647
|
orientation: void 0
|