Repository navigation
perf(physics): batch native query and contact results - #24
Merged
Merged
Conversation
Own query filters and reusable result buffers per scene. Expose packed value views instead of per-hit Embind handles, and filter collision layers inside native queries. Copy contact values from callback-owned buffers and apply scene-query flags to controller shapes. Preserve all touch chunks and full 32-bit shape identifiers. Validation: standard and SIMD native builds; paired engine browser suites, 270 tests per runtime.
Store public query exclusion in per-shape filter data. Keep native scene-query flags enabled because controller movement uses native queries for collision detection. Expose the same query setting for ordinary and controller shapes without affecting simulation or movement collisions. Standard and SIMD builds and paired 272-test engine suites passed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Scene queries currently cross the WASM/JS boundary for every filter candidate and every hit property, exposing temporary Embind handles to the engine. Contact extraction has the same ownership problem.
This change gives each scene one native query owner with reusable touch and result buffers. Queries filter collision layers and public query participation natively and return packed borrowed value views; contact callbacks deliver shape IDs and packed contact values that the engine copies before the next callback. All touch chunks remain observable, including more than 256 results, and 32-bit shape identifiers retain full precision.
Public query participation lives in
PxShapequery filter data (word0 == 0means enabled, including default shapes). It must not cleareSCENE_QUERY_SHAPE: character-controller movement uses native scene queries for collision detection. The ordinary-shape and controller setters share one metadata helper; controller creation replays the setting from the source shape. Simulation and controller collision behavior remain independent of public query exclusion.The internal binding contract changes:
PxSceneQueriesreplaces the old query/filter/hit-wrapper APIs, and contact callbacks now receive(shape0ID, shape1ID, contacts). The paired consumer is galacean/engine#3102, engine commit35b799fc9298cb2cd23eb5a84c26d740c3f4096c. Existing published assets must remain immutable; publish a new standard/SIMD JS+WASM set and update engine defaults together before merging/releasing the consumer.Validation:
./build.sh: standard WASM and SIMD builds passed.The paired public
raycastAllAPI returns a boolean and optionally fills a caller-owned array. That array and its hit/vector objects are reused, including across scenes and caller edits; another query using the same output array overwrites those objects. Resource GC and scene destruction release hidden output caches without mutating caller-held results. Calls without output perform only a hit test. Native callback snapshots still allocate, so the complete path does not promise zero allocations.Local build runtime SHA-256 values: