@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
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
+
import type {Geometry} from '@math.gl/geometry/primitives';
|
|
5
6
|
import {makeExactOrientation} from './rigid-body-orientation';
|
|
6
7
|
|
|
7
8
|
export type RigidBodyMeshGeometry = {
|
|
@@ -151,6 +152,31 @@ export function makeConvexHullGeometry(positions: ArrayLike<number>): RigidBodyM
|
|
|
151
152
|
export function makeTriangleMeshGeometry(
|
|
152
153
|
positions: ArrayLike<number>,
|
|
153
154
|
indices: ArrayLike<number>
|
|
155
|
+
): RigidBodyMeshGeometry {
|
|
156
|
+
return cookTriangleMeshGeometry(positions, indices, false);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Cook a CPU triangle surface, including a math.gl HeightFieldGeometry, for a static collider. */
|
|
160
|
+
export function makeStaticTriangleMeshGeometry(geometry: Geometry): RigidBodyMeshGeometry {
|
|
161
|
+
const position = geometry.attributes['POSITION'];
|
|
162
|
+
if (geometry.topology !== 'triangle-list' || position?.size !== 3)
|
|
163
|
+
throw new Error('Static surfaces require triangle-list POSITION geometry');
|
|
164
|
+
const sourceIndices = geometry.indices?.value;
|
|
165
|
+
if (
|
|
166
|
+
geometry.vertexCount > Math.min(sourceIndices?.length ?? position.value.length / 3, 3_000_000)
|
|
167
|
+
)
|
|
168
|
+
throw new Error('Invalid mesh vertex count');
|
|
169
|
+
const indices =
|
|
170
|
+
sourceIndices?.subarray(0, geometry.vertexCount) ??
|
|
171
|
+
Array.from({length: geometry.vertexCount}, (_, index) => index);
|
|
172
|
+
return cookTriangleMeshGeometry(position.value, indices, true);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Build collision data from authored triangles, with optional mass properties for dynamic meshes. */
|
|
176
|
+
function cookTriangleMeshGeometry(
|
|
177
|
+
positions: ArrayLike<number>,
|
|
178
|
+
indices: ArrayLike<number>,
|
|
179
|
+
staticSurface: boolean
|
|
154
180
|
): RigidBodyMeshGeometry {
|
|
155
181
|
if (
|
|
156
182
|
!Number.isSafeInteger(positions.length) ||
|
|
@@ -163,25 +189,34 @@ export function makeTriangleMeshGeometry(
|
|
|
163
189
|
throw new Error('Incomplete mesh geometry');
|
|
164
190
|
if (positions.length > 3_000_000 || indices.length > 3_000_000)
|
|
165
191
|
throw new Error('Mesh geometry capacity exceeded');
|
|
166
|
-
const vertices = Array.from(positions, Math.fround);
|
|
167
192
|
const triangles = Array.from(indices);
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
triangles.some(index => !Number.isInteger(index) || index < 0 || index >= vertices.length / 3)
|
|
171
|
-
)
|
|
193
|
+
const vertexCount = positions.length / 3;
|
|
194
|
+
if (triangles.some(index => !Number.isInteger(index) || index < 0 || index >= vertexCount))
|
|
172
195
|
throw new Error('Invalid mesh geometry');
|
|
196
|
+
const vertices = staticSurface
|
|
197
|
+
? compactSurfaceVertices(positions, triangles)
|
|
198
|
+
: Array.from(positions, Math.fround);
|
|
199
|
+
if (!vertices.every(Number.isFinite)) throw new Error('Invalid mesh geometry');
|
|
173
200
|
const point = (index: number): Point => [
|
|
174
201
|
vertices[index * 3],
|
|
175
202
|
vertices[index * 3 + 1],
|
|
176
203
|
vertices[index * 3 + 2]
|
|
177
204
|
];
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
);
|
|
205
|
+
// Cache each face's bounds and centroid key once. BVH sorting must not allocate per comparison.
|
|
206
|
+
const triangleCount = triangles.length / 3;
|
|
207
|
+
const triangleBounds = new Float32Array(triangleCount * 6);
|
|
208
|
+
const triangleCentroids = new Float64Array(triangleCount * 3);
|
|
209
|
+
for (let triangle = 0; triangle < triangleCount; triangle++) {
|
|
210
|
+
const first = point(triangles[triangle * 3]);
|
|
211
|
+
const second = point(triangles[triangle * 3 + 1]);
|
|
212
|
+
const third = point(triangles[triangle * 3 + 2]);
|
|
213
|
+
const normal = cross(subtract(second, first), subtract(third, first));
|
|
184
214
|
if (normal.every(value => value === 0)) throw new Error('Degenerate mesh triangle');
|
|
215
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
216
|
+
triangleBounds[triangle * 6 + axis] = Math.min(first[axis], second[axis], third[axis]);
|
|
217
|
+
triangleBounds[triangle * 6 + axis + 3] = Math.max(first[axis], second[axis], third[axis]);
|
|
218
|
+
triangleCentroids[triangle * 3 + axis] = first[axis] + second[axis] + third[axis];
|
|
219
|
+
}
|
|
185
220
|
}
|
|
186
221
|
const minimum: Point = [Infinity, Infinity, Infinity],
|
|
187
222
|
maximum: Point = [-Infinity, -Infinity, -Infinity];
|
|
@@ -198,36 +233,51 @@ export function makeTriangleMeshGeometry(
|
|
|
198
233
|
const lower: Point = [Infinity, Infinity, Infinity],
|
|
199
234
|
upper: Point = [-Infinity, -Infinity, -Infinity];
|
|
200
235
|
for (const triangle of faces)
|
|
201
|
-
for (let
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
lower[axis] = Math.min(lower[axis], vertex[axis]);
|
|
205
|
-
upper[axis] = Math.max(upper[axis], vertex[axis]);
|
|
206
|
-
}
|
|
236
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
237
|
+
lower[axis] = Math.min(lower[axis], triangleBounds[triangle * 6 + axis]);
|
|
238
|
+
upper[axis] = Math.max(upper[axis], triangleBounds[triangle * 6 + axis + 3]);
|
|
207
239
|
}
|
|
208
240
|
if (faces.length <= 4) {
|
|
209
241
|
nodes[offset + 7] = faces.length;
|
|
210
242
|
nodes[offset + 8] = ordered.length / 3;
|
|
211
243
|
for (const triangle of faces)
|
|
212
|
-
ordered.push(
|
|
244
|
+
ordered.push(
|
|
245
|
+
triangles[triangle * 3],
|
|
246
|
+
triangles[triangle * 3 + 1],
|
|
247
|
+
triangles[triangle * 3 + 2]
|
|
248
|
+
);
|
|
213
249
|
} else {
|
|
214
250
|
let axis = 0;
|
|
215
251
|
for (let candidate = 1; candidate < 3; candidate++)
|
|
216
252
|
if (upper[candidate] - lower[candidate] > upper[axis] - lower[axis]) axis = candidate;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
faces.sort((first, second) => centroid(first) - centroid(second));
|
|
253
|
+
faces.sort(
|
|
254
|
+
(first, second) =>
|
|
255
|
+
triangleCentroids[first * 3 + axis] - triangleCentroids[second * 3 + axis]
|
|
256
|
+
);
|
|
222
257
|
const middle = faces.length >> 1;
|
|
223
258
|
build(faces.slice(0, middle));
|
|
224
259
|
build(faces.slice(middle));
|
|
225
260
|
}
|
|
226
|
-
|
|
227
|
-
|
|
261
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
262
|
+
nodes[offset + axis] = lower[axis];
|
|
263
|
+
nodes[offset + 4 + axis] = upper[axis];
|
|
264
|
+
}
|
|
228
265
|
nodes[offset + 3] = nodes.length / 12;
|
|
229
266
|
};
|
|
230
|
-
build(Array.from({length:
|
|
267
|
+
build(Array.from({length: triangleCount}, (_, index) => index));
|
|
268
|
+
if (staticSurface) {
|
|
269
|
+
return {
|
|
270
|
+
positions: vertices,
|
|
271
|
+
indices: ordered,
|
|
272
|
+
minimum,
|
|
273
|
+
maximum,
|
|
274
|
+
nodes,
|
|
275
|
+
closed: false,
|
|
276
|
+
volume: 0,
|
|
277
|
+
center: [0, 0, 0],
|
|
278
|
+
tensor: Array<number>(9).fill(0)
|
|
279
|
+
};
|
|
280
|
+
}
|
|
231
281
|
// Weld by coordinates for topology checks: glTF often splits vertices at UV seams.
|
|
232
282
|
const vertexKeys = Array.from({length: vertices.length / 3}, (_, index) =>
|
|
233
283
|
point(index).join(',')
|
|
@@ -294,3 +344,24 @@ export function makeTriangleMeshGeometry(
|
|
|
294
344
|
tensor
|
|
295
345
|
};
|
|
296
346
|
}
|
|
347
|
+
|
|
348
|
+
/** Remap a detached index list and retain only vertices referenced by the surface. */
|
|
349
|
+
function compactSurfaceVertices(positions: ArrayLike<number>, triangles: number[]): number[] {
|
|
350
|
+
const remapped = new Int32Array(positions.length / 3);
|
|
351
|
+
remapped.fill(-1);
|
|
352
|
+
const vertices: number[] = [];
|
|
353
|
+
for (let index = 0; index < triangles.length; index++) {
|
|
354
|
+
const sourceVertex = triangles[index];
|
|
355
|
+
if (remapped[sourceVertex] < 0) {
|
|
356
|
+
remapped[sourceVertex] = vertices.length / 3;
|
|
357
|
+
const offset = sourceVertex * 3;
|
|
358
|
+
vertices.push(
|
|
359
|
+
Math.fround(positions[offset]),
|
|
360
|
+
Math.fround(positions[offset + 1]),
|
|
361
|
+
Math.fround(positions[offset + 2])
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
triangles[index] = remapped[sourceVertex];
|
|
365
|
+
}
|
|
366
|
+
return vertices;
|
|
367
|
+
}
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {Matrix4, Quaternion} from '@math.gl/core';
|
|
5
|
+
import {Matrix4, Quaternion} from '@math.gl/core/matrix';
|
|
6
|
+
import type {GPURigidBodyHeightField} from './rigid-body-height-field';
|
|
6
7
|
import type {RigidBodyMeshGeometry} from './rigid-body-mesh';
|
|
7
8
|
import {getRigidBodyShapeProperties} from './rigid-body-shape-properties';
|
|
8
9
|
|
|
@@ -16,7 +17,9 @@ export type GPURigidBodyShape =
|
|
|
16
17
|
| {type: 'capsule'; height: number; radiusBottom: number; radiusTop: number}
|
|
17
18
|
| {type: 'cylinder'; height: number; radiusBottom: number; radiusTop: number}
|
|
18
19
|
| {type: 'convex-hull'; geometry: RigidBodyMeshGeometry}
|
|
19
|
-
| {type: 'triangle-mesh'; geometry: RigidBodyMeshGeometry}
|
|
20
|
+
| {type: 'triangle-mesh'; geometry: RigidBodyMeshGeometry}
|
|
21
|
+
/** Static Z-up terrain with on-GPU triangle reconstruction. */
|
|
22
|
+
| {type: 'height-field'; field: GPURigidBodyHeightField};
|
|
20
23
|
export type GPURigidBodyMaterial = {
|
|
21
24
|
restitution?: number;
|
|
22
25
|
staticFriction?: number;
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
createBoundKernelAsync
|
|
9
9
|
} from '../gpu-core/utils/bound-kernel';
|
|
10
10
|
import {Buffer, type CommandEncoder} from '@luma.gl/core';
|
|
11
|
-
import {Matrix4} from '@math.gl/core';
|
|
11
|
+
import {Matrix4} from '@math.gl/core/matrix';
|
|
12
12
|
import {normalizeRigidBodyRotation} from './rigid-body-properties';
|
|
13
13
|
|
|
14
14
|
import type {
|
|
@@ -33,6 +33,104 @@ export type GPURigidBodyQueryResult = {
|
|
|
33
33
|
complete: boolean;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
|
+
/** One batched ray, or a sphere sweep when radius is supplied. Filters share the batch selection. */
|
|
37
|
+
export type GPURigidBodyBatchCast = Omit<GPURigidBodyRayQuery, 'colliderIndices'> & {
|
|
38
|
+
/** Nonnegative sweep radius. Omit for a ray. */
|
|
39
|
+
radius?: number;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** Optional collider selection shared by every command in a cast batch. */
|
|
43
|
+
export type GPURigidBodyBatchCastOptions = Pick<GPURigidBodyQueryFilter, 'colliderIndices'> & {
|
|
44
|
+
/** Override the world's default. Indexed casts require queryBatchIndex. */
|
|
45
|
+
strategy?: 'scan' | 'indexed';
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Input command stride in bytes, matching the WGSL Query structure. */
|
|
49
|
+
export const RIGID_BODY_CAST_COMMAND_BYTES = 48;
|
|
50
|
+
|
|
51
|
+
/** One result header and one nearest-hit record per command, measured in bytes. */
|
|
52
|
+
export const RIGID_BODY_BATCH_RESULT_BYTES = 64;
|
|
53
|
+
|
|
54
|
+
/** Encode a batch without duplicating the collider selection per command. */
|
|
55
|
+
export function packRigidBodyBatchCasts(
|
|
56
|
+
commands: readonly GPURigidBodyBatchCast[],
|
|
57
|
+
bodyCount: number,
|
|
58
|
+
selectedCount: number,
|
|
59
|
+
indexedCount = 0
|
|
60
|
+
): Uint8Array {
|
|
61
|
+
/** Shared typed views for the command floats and integer flags. */
|
|
62
|
+
const data = new ArrayBuffer(commands.length * RIGID_BODY_CAST_COMMAND_BYTES);
|
|
63
|
+
/** Position, direction, segment length and sweep radius. */
|
|
64
|
+
const floats = new Float32Array(data);
|
|
65
|
+
/** Query kind and optional excluded body. */
|
|
66
|
+
const words = new Uint32Array(data);
|
|
67
|
+
for (const [index, command] of commands.entries()) {
|
|
68
|
+
/** Resolve the per-command segment and optional exclusion before packing. */
|
|
69
|
+
const {origin, direction, maximumDistance, radius, excludeBody} = command;
|
|
70
|
+
/** Normalize directions once on the CPU, retaining distance in world units. */
|
|
71
|
+
const length = Math.hypot(...direction);
|
|
72
|
+
if (
|
|
73
|
+
'colliderIndices' in command ||
|
|
74
|
+
origin.length !== 3 ||
|
|
75
|
+
!origin.every(value => Number.isFinite(Math.fround(value))) ||
|
|
76
|
+
direction.length !== 3 ||
|
|
77
|
+
!Number.isFinite(length) ||
|
|
78
|
+
length === 0 ||
|
|
79
|
+
!Number.isFinite(Math.fround(maximumDistance)) ||
|
|
80
|
+
maximumDistance < 0 ||
|
|
81
|
+
(radius !== undefined && (!Number.isFinite(Math.fround(radius)) || radius < 0)) ||
|
|
82
|
+
(excludeBody !== undefined &&
|
|
83
|
+
(!Number.isInteger(excludeBody) || excludeBody < 0 || excludeBody >= bodyCount))
|
|
84
|
+
)
|
|
85
|
+
throw new Error('Invalid batched collision cast');
|
|
86
|
+
/** Each row is independently aligned to one Query. */
|
|
87
|
+
const offset = (index * RIGID_BODY_CAST_COMMAND_BYTES) / 4;
|
|
88
|
+
floats.set(
|
|
89
|
+
[...origin, radius ?? 0, ...direction.map(value => value / length), maximumDistance],
|
|
90
|
+
offset
|
|
91
|
+
);
|
|
92
|
+
words.set(
|
|
93
|
+
[radius === undefined ? 0 : 2, indexedCount, excludeBody ?? 0xffffffff, selectedCount],
|
|
94
|
+
offset + 8
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
return new Uint8Array(data);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Read one nearest hit, using the same layout for scalar and batched query results. */
|
|
101
|
+
export function decodeRigidBodyQueryHit(
|
|
102
|
+
words: Uint32Array,
|
|
103
|
+
floats: Float32Array,
|
|
104
|
+
offset: number
|
|
105
|
+
): GPURigidBodyQueryHit {
|
|
106
|
+
return {
|
|
107
|
+
body: words[offset],
|
|
108
|
+
collider: words[offset + 1],
|
|
109
|
+
point: [floats[offset + 4], floats[offset + 5], floats[offset + 6]],
|
|
110
|
+
distance: floats[offset + 7],
|
|
111
|
+
normal: [floats[offset + 8], floats[offset + 9], floats[offset + 10]]
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Decode ordered results from one compact GPU readback. */
|
|
116
|
+
export function decodeRigidBodyBatchCasts(bytes: Uint8Array): GPURigidBodyQueryResult[] {
|
|
117
|
+
/** Header and identifier words for every command. */
|
|
118
|
+
const words = new Uint32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
119
|
+
/** Nearest hit geometry for each result row. */
|
|
120
|
+
const floats = new Float32Array(bytes.buffer, bytes.byteOffset, bytes.byteLength / 4);
|
|
121
|
+
return Array.from({length: bytes.byteLength / RIGID_BODY_BATCH_RESULT_BYTES}, (_, index) => {
|
|
122
|
+
/** A four-word header precedes the nearest-hit record. */
|
|
123
|
+
const offset = (index * RIGID_BODY_BATCH_RESULT_BYTES) / 4;
|
|
124
|
+
return {
|
|
125
|
+
hits: words[offset] ? [decodeRigidBodyQueryHit(words, floats, offset + 4)] : [],
|
|
126
|
+
totalHits: words[offset + 1],
|
|
127
|
+
truncated: false,
|
|
128
|
+
complete: words[offset + 2] === 0
|
|
129
|
+
};
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Shared collider intersection code for scalar queries and batched casts. */
|
|
36
134
|
export const RIGID_BODY_QUERY_SHADER = /* wgsl */ `
|
|
37
135
|
struct Query { origin:vec4f, direction:vec4f, settings:vec4u }
|
|
38
136
|
struct QueryHit { identifiers:vec4u, point:vec4f, normal:vec4f }
|
|
@@ -40,21 +138,18 @@ struct QueryOutput { count:u32, total:u32, reserved:vec2u, hits:array<QueryHit>
|
|
|
40
138
|
@group(0) @binding(12) var<uniform> query:Query;
|
|
41
139
|
@group(0) @binding(13) var<storage,read> querySelection:array<u32>;
|
|
42
140
|
@group(0) @binding(14) var<storage,read_write> queryOutput:QueryOutput;
|
|
43
|
-
|
|
44
|
-
let collider=invocation.x;if(collider>=COLLIDER_COUNT){return;}
|
|
45
|
-
queryOutput.hits[collider]=QueryHit();
|
|
46
|
-
if(querySelection[collider]==0u){return;}
|
|
141
|
+
fn queryCollider(collider:u32,request:Query)->QueryHit {
|
|
47
142
|
let shape=bodies.colliders[collider].shape;
|
|
48
|
-
let origin=colliderLocal(collider,
|
|
49
|
-
let direction=colliderLocal(collider,
|
|
143
|
+
let origin=colliderLocal(collider,request.origin.xyz-colliderPosition(collider));
|
|
144
|
+
let direction=colliderLocal(collider,request.direction.xyz);
|
|
50
145
|
var point=origin;var normal=vec3f(0);var distance=0.0;var hit=false;
|
|
51
146
|
var complete=1u;
|
|
52
|
-
if(
|
|
53
|
-
if(
|
|
54
|
-
else{let sweep=sweepSphere(collider,origin,direction,
|
|
55
|
-
}else if(
|
|
56
|
-
if(shape.w==0.0){let lengthFromCenter=length(origin);hit=lengthFromCenter<=shape.x+
|
|
57
|
-
else {point=clamp(origin,-shape.xyz,shape.xyz);let separation=origin-point;let lengthFromSurface=length(separation);hit=lengthFromSurface<=
|
|
147
|
+
if(request.settings.x==2u||shape.w>1.0){
|
|
148
|
+
if(request.settings.x==1u){let surface=closestSurface(collider,origin);hit=surface.distance<=request.origin.w;point=surface.point;normal=select(vec3f(0),(origin-point)/max(length(origin-point),1e-20),surface.distance>0.0);complete=surface.complete;if(shape.w==6.0&&shape.z==0.0&&origin.y<0.0){hit=false;}}
|
|
149
|
+
else{let sweep=sweepSphere(collider,origin,direction,request.direction.w,request.origin.w,false);hit=sweep.hit!=0u;point=sweep.point;normal=sweep.normal;distance=sweep.distance;complete=sweep.complete;}
|
|
150
|
+
}else if(request.settings.x==1u){
|
|
151
|
+
if(shape.w==0.0){let lengthFromCenter=length(origin);hit=lengthFromCenter<=shape.x+request.origin.w;normal=select(vec3f(1,0,0),origin/max(lengthFromCenter,1e-20),lengthFromCenter>1e-20);point=normal*shape.x;}
|
|
152
|
+
else {point=clamp(origin,-shape.xyz,shape.xyz);let separation=origin-point;let lengthFromSurface=length(separation);hit=lengthFromSurface<=request.origin.w;normal=separation/max(lengthFromSurface,1e-20);}
|
|
58
153
|
}else if(shape.w==0.0){
|
|
59
154
|
let projection=dot(origin,direction);
|
|
60
155
|
// Avoid cancellation between large squared distances for distant rays.
|
|
@@ -62,7 +157,7 @@ struct QueryOutput { count:u32, total:u32, reserved:vec2u, hits:array<QueryHit>
|
|
|
62
157
|
if(dot(origin,origin)<=shape.x*shape.x){hit=true;}
|
|
63
158
|
else if(discriminant>=0.0){distance=-projection-sqrt(discriminant);hit=distance>=0.0;point=origin+direction*distance;normal=normalize(point);}
|
|
64
159
|
}else{
|
|
65
|
-
var enter=0.0;var leave=
|
|
160
|
+
var enter=0.0;var leave=request.direction.w;hit=true;
|
|
66
161
|
for(var coordinate=0u;coordinate<3u;coordinate++){
|
|
67
162
|
if(direction[coordinate]==0.0){if(abs(origin[coordinate])>shape[coordinate]){hit=false;}}
|
|
68
163
|
else{
|
|
@@ -74,7 +169,12 @@ struct QueryOutput { count:u32, total:u32, reserved:vec2u, hits:array<QueryHit>
|
|
|
74
169
|
}
|
|
75
170
|
distance=enter;point=origin+direction*distance;hit=hit&&enter<=leave&&leave>=0.0;
|
|
76
171
|
}
|
|
77
|
-
|
|
172
|
+
return QueryHit(vec4u(colliderBody(collider),collider,select(0u,1u,hit&&distance<=request.direction.w),complete),vec4f(colliderPosition(collider)+rotate(colliderRotation(collider),point),distance),vec4f(rotate(colliderRotation(collider),normal),0));
|
|
173
|
+
}
|
|
174
|
+
@compute @workgroup_size(64) fn queryColliders(@builtin(global_invocation_id) invocation:vec3u){
|
|
175
|
+
let collider=invocation.x;if(collider>=COLLIDER_COUNT){return;}
|
|
176
|
+
queryOutput.hits[collider]=QueryHit();
|
|
177
|
+
if(querySelection[collider]!=0u){queryOutput.hits[collider]=queryCollider(collider,query);}
|
|
78
178
|
}
|
|
79
179
|
@compute @workgroup_size(1) fn reduceQueries(){
|
|
80
180
|
queryOutput.count=0u;queryOutput.total=0u;queryOutput.reserved=vec2u(0);var nearest=query.direction.w;
|
|
@@ -88,3 +188,91 @@ struct QueryOutput { count:u32, total:u32, reserved:vec2u, hits:array<QueryHit>
|
|
|
88
188
|
}
|
|
89
189
|
}
|
|
90
190
|
`;
|
|
191
|
+
|
|
192
|
+
/** One workgroup per cast. Scratch is local to the group and scales with lane count. */
|
|
193
|
+
export function getRigidBodyBatchCastShader(leafCapacity = 0): string {
|
|
194
|
+
return /* wgsl */ `
|
|
195
|
+
struct BatchResult {header:vec4u,hit:QueryHit}
|
|
196
|
+
@group(0) @binding(30) var<storage,read> batchCommands:array<Query>;
|
|
197
|
+
@group(0) @binding(31) var<storage,read_write> batchResults:array<BatchResult>;
|
|
198
|
+
var<workgroup> reducedHits:array<QueryHit,64>;
|
|
199
|
+
var<workgroup> reducedCounts:array<vec2u,64>;
|
|
200
|
+
|
|
201
|
+
// Match the scalar reducer: prefer the smaller collider index at equal distance.
|
|
202
|
+
fn closer(first:QueryHit,second:QueryHit)->bool{
|
|
203
|
+
return first.identifiers.z!=0u&&(second.identifiers.z==0u||
|
|
204
|
+
first.point.w<second.point.w||
|
|
205
|
+
(first.point.w==second.point.w&&first.identifiers.y<second.identifiers.y));
|
|
206
|
+
}
|
|
207
|
+
${leafCapacity ? getCastTraversalShader(leafCapacity) : ''}
|
|
208
|
+
fn accumulateCast(
|
|
209
|
+
collider:u32,command:Query,best:ptr<function,QueryHit>,counts:ptr<function,vec2u>
|
|
210
|
+
){
|
|
211
|
+
if(colliderBody(collider)==command.settings.z){return;}
|
|
212
|
+
let candidate=queryCollider(collider,command);
|
|
213
|
+
(*counts)+=vec2u(candidate.identifiers.z,select(0u,1u,candidate.identifiers.w==0u));
|
|
214
|
+
if(closer(candidate,*best)){*best=candidate;}
|
|
215
|
+
}
|
|
216
|
+
@compute @workgroup_size(64) fn castBatch(
|
|
217
|
+
@builtin(workgroup_id) groupIndex:vec3u,
|
|
218
|
+
@builtin(local_invocation_index) lane:u32
|
|
219
|
+
){
|
|
220
|
+
let command=batchCommands[groupIndex.x];
|
|
221
|
+
var best=QueryHit();var counts=vec2u(0);
|
|
222
|
+
${leafCapacity ? 'traverseCastBounds(lane,command,&best,&counts);' : ''}
|
|
223
|
+
for(var work=lane+command.settings.y;work<command.settings.w;work+=64u){
|
|
224
|
+
accumulateCast(querySelection[work],command,&best,&counts);
|
|
225
|
+
}
|
|
226
|
+
reducedHits[lane]=best;reducedCounts[lane]=counts;workgroupBarrier();
|
|
227
|
+
for(var stride=32u;stride>0u;stride/=2u){
|
|
228
|
+
if(lane<stride){
|
|
229
|
+
let neighbor=lane+stride;
|
|
230
|
+
if(closer(reducedHits[neighbor],reducedHits[lane])){reducedHits[lane]=reducedHits[neighbor];}
|
|
231
|
+
reducedCounts[lane]+=reducedCounts[neighbor];
|
|
232
|
+
}
|
|
233
|
+
workgroupBarrier();
|
|
234
|
+
}
|
|
235
|
+
if(lane==0u){
|
|
236
|
+
let hit=reducedHits[0];let counts=reducedCounts[0];
|
|
237
|
+
batchResults[groupIndex.x]=BatchResult(vec4u(hit.identifiers.z,counts.x,counts.y,0u),hit);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
`;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Traverse disjoint implicit subtrees without a private stack or a candidate buffer. */
|
|
244
|
+
function getCastTraversalShader(leafCapacity: number): string {
|
|
245
|
+
return /* wgsl */ `
|
|
246
|
+
@group(0) @binding(26) var<storage,read> nodeMinima:array<f32>;
|
|
247
|
+
@group(0) @binding(27) var<storage,read> nodeMaxima:array<f32>;
|
|
248
|
+
const CAST_LEAVES:u32=${leafCapacity}u;
|
|
249
|
+
const CAST_SUBTREES:u32=min(CAST_LEAVES,8u);
|
|
250
|
+
|
|
251
|
+
fn traverseCastBounds(
|
|
252
|
+
lane:u32,command:Query,best:ptr<function,QueryHit>,counts:ptr<function,vec2u>
|
|
253
|
+
){
|
|
254
|
+
if(lane>=CAST_SUBTREES){return;}
|
|
255
|
+
// One-based heap addresses make sibling and parent navigation arithmetic.
|
|
256
|
+
let root=CAST_SUBTREES+lane;
|
|
257
|
+
var node=root;
|
|
258
|
+
// The world slab and local intersection use different arithmetic orders.
|
|
259
|
+
let directionRoundoff=command.direction.w*vec3f(2e-6);
|
|
260
|
+
let padding=command.origin.w*1.000002+abs(command.origin.xyz)*2e-6+directionRoundoff;
|
|
261
|
+
loop{
|
|
262
|
+
let offset=(node-1u)*3u;
|
|
263
|
+
let lower=vec3f(nodeMinima[offset],nodeMinima[offset+1u],nodeMinima[offset+2u]);
|
|
264
|
+
let upper=vec3f(nodeMaxima[offset],nodeMaxima[offset+1u],nodeMaxima[offset+2u]);
|
|
265
|
+
if(all(lower<=upper)&&intersectsSweepBounds(
|
|
266
|
+
command.origin.xyz,command.direction.xyz,command.direction.w,lower-padding,upper+padding
|
|
267
|
+
)){
|
|
268
|
+
if(node<CAST_LEAVES){node*=2u;continue;}
|
|
269
|
+
let row=node-CAST_LEAVES;
|
|
270
|
+
if(row<command.settings.y){accumulateCast(querySelection[row],command,best,counts);}
|
|
271
|
+
}
|
|
272
|
+
while(node>root&&(node&1u)!=0u){node/=2u;}
|
|
273
|
+
if(node==root){break;}
|
|
274
|
+
node+=1u;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
`;
|
|
278
|
+
}
|
|
@@ -63,15 +63,17 @@ fn closestSurface(collider:u32,point:vec3f)->SurfacePoint{
|
|
|
63
63
|
loop{
|
|
64
64
|
if(node>=nodeCount){break;}if(work>=MESH_TRAVERSAL_BUDGET){complete=0u;break;}work++;
|
|
65
65
|
let lower=readGeometry(nodeOffset+node*3u);let upper=readGeometry(nodeOffset+node*3u+1u);
|
|
66
|
-
if(distance(point,clamp(point,lower.xyz,upper.xyz))>best){node=u32(lower.w);continue;}
|
|
66
|
+
if(any(lower.xyz>upper.xyz)||distance(point,clamp(point,lower.xyz,upper.xyz))>best){node=u32(lower.w);continue;}
|
|
67
67
|
if(upper.w>0.0){let start=u32(readGeometry(nodeOffset+node*3u+2u).x);
|
|
68
68
|
for(var offset=0u;offset<u32(upper.w);offset++){
|
|
69
69
|
if(work>=MESH_TRAVERSAL_BUDGET){complete=0u;break;}work++;
|
|
70
|
+
if(!meshTriangleActive(collider,start+offset)){continue;}
|
|
70
71
|
let candidate=closestTriangle(point,triangleVertex(collider,start+offset,0u),triangleVertex(collider,start+offset,1u),triangleVertex(collider,start+offset,2u));
|
|
71
72
|
let separation=distance(point,candidate);if(separation<best){best=separation;nearest=candidate;}
|
|
72
73
|
}
|
|
73
74
|
}if(complete==0u){break;}node++;
|
|
74
75
|
}
|
|
76
|
+
if(best==3.402823e38){return SurfacePoint(point,best,complete);}
|
|
75
77
|
}
|
|
76
78
|
return SurfacePoint(nearest,select(distance(point,nearest),0.0,inside),complete);
|
|
77
79
|
}
|
|
@@ -125,6 +127,12 @@ fn sweepBox(origin:vec3f,direction:vec3f,maximumDistance:f32,radius:f32,extent:v
|
|
|
125
127
|
if(result.hit!=0u){result.distance=nearest;result.point=origin+direction*nearest-result.normal*radius;}
|
|
126
128
|
return result;
|
|
127
129
|
}
|
|
130
|
+
// Drop the dominant normal component for ray edge tests. An on-edge ray can
|
|
131
|
+
// otherwise look outside when the computed plane intersection rounds off-plane.
|
|
132
|
+
fn rayTriangleEdge(edge:vec3f,offset:vec3f,normal:vec3f,axis:u32)->bool{
|
|
133
|
+
let horizontal=(axis+1u)%3u;let vertical=(axis+2u)%3u;
|
|
134
|
+
return (edge[horizontal]*offset[vertical]-edge[vertical]*offset[horizontal])*normal[axis]>=0.0;
|
|
135
|
+
}
|
|
128
136
|
// A triangle's sphere expansion is convex. Ignore only a departing initial touch
|
|
129
137
|
// on that triangle; other triangles in the same nonconvex mesh remain candidates.
|
|
130
138
|
fn sweepTriangle(origin:vec3f,direction:vec3f,maximumDistance:f32,radius:f32,first:vec3f,second:vec3f,third:vec3f,skipSeparating:bool)->SphereSweep{
|
|
@@ -161,9 +169,18 @@ fn sweepTriangle(origin:vec3f,direction:vec3f,maximumDistance:f32,radius:f32,fir
|
|
|
161
169
|
let travelled=(sign*radius-dot(origin-first,normal))/denominator;
|
|
162
170
|
let point=origin+direction*travelled-normal*(sign*radius);
|
|
163
171
|
if(travelled<0.0||travelled>nearest){continue;}
|
|
164
|
-
|
|
165
|
-
|
|
172
|
+
let firstSide=(second-first)/edgeScale;let secondSide=(third-second)/edgeScale;let thirdSide=(first-third)/edgeScale;
|
|
173
|
+
let firstOffset=(point-first)/edgeScale;let secondOffset=(point-second)/edgeScale;let thirdOffset=(point-third)/edgeScale;
|
|
174
|
+
var inside=false;
|
|
175
|
+
if(radius==0.0){
|
|
176
|
+
let magnitude=abs(normal);
|
|
177
|
+
var axis=select(0u,1u,magnitude.y>magnitude.x);
|
|
178
|
+
if(magnitude.z>magnitude[axis]){axis=2u;}
|
|
179
|
+
inside=rayTriangleEdge(firstSide,firstOffset,normal,axis)&&rayTriangleEdge(secondSide,secondOffset,normal,axis)&&rayTriangleEdge(thirdSide,thirdOffset,normal,axis);
|
|
180
|
+
}else{
|
|
181
|
+
inside=dot(cross(firstSide,firstOffset),normal)>=0.0&&dot(cross(secondSide,secondOffset),normal)>=0.0&&dot(cross(thirdSide,thirdOffset),normal)>=0.0;
|
|
166
182
|
}
|
|
183
|
+
if(inside){nearest=travelled;result.hit=1u;result.normal=normal*sign;}
|
|
167
184
|
}}
|
|
168
185
|
if(radius>0.0){
|
|
169
186
|
var vertices=array<vec3f,3>(first,second,third);
|
|
@@ -205,10 +222,11 @@ fn sweepMesh(collider:u32,origin:vec3f,direction:vec3f,maximumDistance:f32,radiu
|
|
|
205
222
|
loop{
|
|
206
223
|
if(node>=nodeCount){break;}if(work>=MESH_TRAVERSAL_BUDGET){result.complete=0u;return result;}work++;
|
|
207
224
|
let lower=readGeometry(nodeOffset+node*3u);let upper=readGeometry(nodeOffset+node*3u+1u);
|
|
208
|
-
if(
|
|
225
|
+
if(any(lower.xyz>upper.xyz)||!intersectsSweepBounds(origin,direction,nearest,lower.xyz-vec3f(radius),upper.xyz+vec3f(radius))){node=u32(lower.w);continue;}
|
|
209
226
|
if(upper.w>0.0){let start=u32(readGeometry(nodeOffset+node*3u+2u).x);
|
|
210
227
|
for(var offset=0u;offset<u32(upper.w);offset++){
|
|
211
228
|
if(work>=MESH_TRAVERSAL_BUDGET){result.complete=0u;return result;}work++;
|
|
229
|
+
if(!meshTriangleActive(collider,start+offset)){continue;}
|
|
212
230
|
let candidate=sweepTriangle(origin,direction,nearest,radius,triangleVertex(collider,start+offset,0u),triangleVertex(collider,start+offset,1u),triangleVertex(collider,start+offset,2u),skipSeparating);
|
|
213
231
|
if(candidate.hit!=0u){nearest=candidate.distance;result=candidate;}
|
|
214
232
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/** Bounded rigid-body reference path. Pair discovery is parallel; impulses are ordered on GPU. */
|
|
6
6
|
import {getEnsembleShader} from './rigid-body-ensemble-shaders';
|
|
7
7
|
import {
|
|
8
|
-
|
|
8
|
+
getRigidBodyBoundsShader,
|
|
9
9
|
RIGID_BODY_BOUND_PUBLICATION_SHADER
|
|
10
10
|
} from './rigid-body-bounds-shaders';
|
|
11
11
|
import {getRigidBodyParallelShader} from './rigid-body-parallel-shaders';
|
|
@@ -30,7 +30,9 @@ export function getRigidBodyShader(
|
|
|
30
30
|
compactContacts = true,
|
|
31
31
|
collisionPartitionSize?: number,
|
|
32
32
|
ensembleBodiesPerInstance?: number,
|
|
33
|
-
blockContacts = false
|
|
33
|
+
blockContacts = false,
|
|
34
|
+
heightFields = false,
|
|
35
|
+
ensemblePairsPerInstance?: number
|
|
34
36
|
): string {
|
|
35
37
|
return /* wgsl */ `
|
|
36
38
|
const COMPACT_CONTACTS:bool=${compactContacts};
|
|
@@ -46,9 +48,9 @@ struct Target { position: vec4f, orientation: vec4f }
|
|
|
46
48
|
struct CacheKey { key:atomic<u32>, epoch:u32 }
|
|
47
49
|
struct GeneralConstraint {axes:vec4f,limits:vec4f,control:vec4f,drive:vec4f}
|
|
48
50
|
struct JointState {impulses:array<f32,8>, control:vec4f, limits:vec4f, motor:vec4f, drive:vec4f, spring:vec4f, general:GeneralConstraint}
|
|
49
|
-
struct Targets { entries:array<Target,BODY_COUNT>, dispatch:atomic<u32>, vertical:u32, depth:u32 ${sparse ? `, frame:u32, cacheDropped:atomic<u32>, reserved0:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, reserved1:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, reserved2:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, keys:array<CacheKey,PAIR_CAPACITY>` : ''}${ensembleBodiesPerInstance ? `, instanceHeads:array<atomic<u32>,${count / ensembleBodiesPerInstance}>, instanceFrames:array<u32,${count / ensembleBodiesPerInstance}>, links:array<u32,PAIR_CAPACITY>, journalMarks:array<u32,PAIR_CAPACITY>, journalSlots:array<u32,PAIR_CAPACITY>, journalKeys:array<vec2u,PAIR_CAPACITY>, journalLinks:array<u32,PAIR_CAPACITY>, savedHeads:array<u32,${count / ensembleBodiesPerInstance}>, savedFrames:array<u32,${count / ensembleBodiesPerInstance}>, savedHeader:array<u32,8>, journalManifolds:array<Manifold,PAIR_CAPACITY>` : ''}${jointCount ? `, joints:array<JointState,${jointCount}>` : ''} }
|
|
51
|
+
struct Targets { entries:array<Target,BODY_COUNT>, dispatch:atomic<u32>, vertical:u32, depth:u32 ${sparse ? `, frame:u32, cacheDropped:atomic<u32>, reserved0:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, reserved1:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, reserved2:${ensembleBodiesPerInstance ? 'atomic<u32>' : 'u32'}, keys:array<CacheKey,PAIR_CAPACITY>` : ''}${ensembleBodiesPerInstance ? `, instanceHeads:array<atomic<u32>,${count / ensembleBodiesPerInstance}>, instanceFrames:array<u32,${count / ensembleBodiesPerInstance}>, links:array<u32,PAIR_CAPACITY>, journalMarks:array<u32,PAIR_CAPACITY>, journalSlots:array<u32,PAIR_CAPACITY>, journalKeys:array<vec2u,PAIR_CAPACITY>, journalLinks:array<u32,PAIR_CAPACITY>, savedHeads:array<u32,${count / ensembleBodiesPerInstance}>, savedFrames:array<u32,${count / ensembleBodiesPerInstance}>, savedHeader:array<u32,8>, journalManifolds:array<Manifold,PAIR_CAPACITY>${ensemblePairsPerInstance ? `, instanceFailures:array<atomic<u32>,${count / ensembleBodiesPerInstance + 1}>` : ''}` : ''}${jointCount ? `, joints:array<JointState,${jointCount}>` : ''} }
|
|
50
52
|
struct Contact { point: vec4f, normal: vec4f, impulse: vec4f, tangent: vec4f, firstAnchor:vec4f, secondAnchor:vec4f }
|
|
51
|
-
struct Manifold { contacts: array<Contact, 4>, count: u32, first:u32, second:u32, previousCount:u32, padding: vec3u }
|
|
53
|
+
struct Manifold { contacts: array<Contact, 4>, count: u32, first:u32, second:u32, previousCount:u32, padding: vec3u, terrainRevision:u32 }
|
|
52
54
|
struct Settings { gravity: vec4f, solver: vec4f, sleep: vec4f, stability: vec4f }
|
|
53
55
|
@group(0) @binding(0) var<uniform> settings: Settings;
|
|
54
56
|
@group(0) @binding(1) var<storage, read_write> positions: array<vec4f>;
|
|
@@ -62,7 +64,7 @@ struct Settings { gravity: vec4f, solver: vec4f, sleep: vec4f, stability: vec4f
|
|
|
62
64
|
${getEnsembleShader(count, ensembleBodiesPerInstance, collisionPartitionSize, extended)}
|
|
63
65
|
${
|
|
64
66
|
sparse
|
|
65
|
-
? getRigidBodyCacheShader(sparse, Boolean(ensembleBodiesPerInstance))
|
|
67
|
+
? getRigidBodyCacheShader(sparse, Boolean(ensembleBodiesPerInstance), ensemblePairsPerInstance)
|
|
66
68
|
: `
|
|
67
69
|
fn getFirstCollider(pair:u32)->u32{return pair/COLLIDER_COUNT;}
|
|
68
70
|
fn getSecondCollider(pair:u32)->u32{return pair%COLLIDER_COUNT;}
|
|
@@ -210,11 +212,11 @@ fn contactFeature(collider:u32,point:vec3f,normal:vec3f)->u32 {
|
|
|
210
212
|
let score=separation+(1.0-alignment)*settings.solver.w;
|
|
211
213
|
if(score<nearest){nearest=score;feature=triangle;}
|
|
212
214
|
}
|
|
213
|
-
return
|
|
215
|
+
return meshTriangleData(collider,feature)/8u;
|
|
214
216
|
}
|
|
215
217
|
fn cookedContactFeature(collider:u32,triangle:i32,fallback:u32)->u32 {
|
|
216
218
|
if(triangle<0){return fallback;}
|
|
217
|
-
return
|
|
219
|
+
return meshTriangleData(collider,u32(triangle))/8u;
|
|
218
220
|
}
|
|
219
221
|
fn storeFeatureContact(pair: u32, slot: u32, point: vec3f, normal: vec3f, depth: f32, previous: Manifold, firstCollider: u32, secondCollider: u32, firstTriangle:i32, secondTriangle:i32) {
|
|
220
222
|
let first=colliderBody(firstCollider);let second=colliderBody(secondCollider);
|
|
@@ -285,7 +287,7 @@ fn clipBoxContact(reference:u32,incident:u32,faceAxis:u32,referenceNormal:vec3f,
|
|
|
285
287
|
fn storeContact(pair:u32,slot:u32,point:vec3f,normal:vec3f,depth:f32,previous:Manifold,first:u32,second:u32){
|
|
286
288
|
storeFeatureContact(pair,slot,point,normal,depth,previous,first,second,-1,-1);
|
|
287
289
|
}
|
|
288
|
-
${
|
|
290
|
+
${getRigidBodyBoundsShader(heightFields)}
|
|
289
291
|
${sparse ? RIGID_BODY_BOUND_PUBLICATION_SHADER : ''}
|
|
290
292
|
${
|
|
291
293
|
extended
|
|
@@ -315,6 +317,16 @@ ${
|
|
|
315
317
|
}
|
|
316
318
|
var previous=manifolds[pair]; ${sparse ? 'previous.count=previous.previousCount;' : ''} manifolds[pair].count=0u;
|
|
317
319
|
${extended ? 'manifolds[pair].padding=vec3u(0);' : ''}
|
|
320
|
+
${
|
|
321
|
+
heightFields
|
|
322
|
+
? `
|
|
323
|
+
// Only one side can be a static height field. Ignore ordinary mesh triangle offsets.
|
|
324
|
+
let firstTerrain=bodies.colliders[first].padding;let secondTerrain=bodies.colliders[second].padding;
|
|
325
|
+
let revision=max(select(0u,u32(firstTerrain.z),firstTerrain.y<0.0),select(0u,u32(secondTerrain.z),secondTerrain.y<0.0));
|
|
326
|
+
if(previous.terrainRevision!=revision){previous.count=0u;}
|
|
327
|
+
manifolds[pair].terrainRevision=revision;`
|
|
328
|
+
: ''
|
|
329
|
+
}
|
|
318
330
|
let firstBody=colliderBody(first);let secondBody=colliderBody(second);
|
|
319
331
|
if(bodies.colliders[first].material.w!=0.0 || bodies.colliders[second].material.w!=0.0 || first>=second || firstBody==secondBody || (excludes(first,second)||excludes(second,first)) || (!dynamic(firstBody) && !dynamic(secondBody))) {return;}
|
|
320
332
|
${extended ? 'manifolds[pair].padding=vec3u(0); if(bodies.colliders[first].shape.w>=2.0 || bodies.colliders[second].shape.w>=2.0){collideExtended(pair,first,second,previous);return;}' : ''}
|
|
@@ -14,6 +14,8 @@ export type RigidBodyShapeProperties = {
|
|
|
14
14
|
/** Geometric properties at unit density, with the tensor measured about its own COM. */
|
|
15
15
|
export function getRigidBodyShapeProperties(shape: GPURigidBodyShape): RigidBodyShapeProperties {
|
|
16
16
|
if (shape.type === 'convex-hull' || shape.type === 'triangle-mesh') return shape.geometry;
|
|
17
|
+
if (shape.type === 'height-field')
|
|
18
|
+
return {volume: 0, center: [0, 0, 0], tensor: Array<number>(9).fill(0)};
|
|
17
19
|
if (shape.type === 'plane') {
|
|
18
20
|
if (
|
|
19
21
|
[shape.sizeX, shape.sizeZ].some(
|