arkavo-org / arkavo-org/VRMMetalKit
SpringBone physics does CPU-side interpolation and array rebuilds every frame
- Dominant language
- Swift
- Stars
- 6
- Forks
- 2
- Avg merge
- 18h 51m
- Merged PRs (30d)
- 26
Description
## Summary
SpringBone physics runs fixed-timestep substeps (default 120 Hz, 2–4 substeps per 60 Hz frame). Each substep interpolates root positions, world bind directions, and all collider transforms on the CPU before dispatching GPU compute kernels. Additionally, collider arrays and dictionaries are rebuilt from scratch every frame even when colliders are static.
## Impact
- CPU-bound interpolation for high substep counts.
- Per-frame allocation of `colliderToGroupIndex`, `sphereColliders`, `capsuleColliders`, `planeColliders`.
- `applyCenterFrameDeltas()` computes 4×4 matrix inverse + multiply per center node using unaccelerated Swift SIMD.
## Location
- Main update: `Sources/VRMMetalKit/SpringBoneComputeSystem.swift:298–378`
- CPU interpolation: `:1519–1608`
- Collider rebuilds: `:938–950`
- Center frame deltas: `:1627–1653`
## Suggested Fixes
1. **Move interpolation to GPU:** Store previous/current bind poses and collider transforms in buffers; let the compute shader interpolate.
2. **Cache static colliders:** Only rebuild collider arrays when the VRM animation changes collider positions.
3. **Reduce default substep count** or make it adaptive based on bone velocity.
Contributor guide
Research direction
Start with the main update in Sources/VRMMetalKit/SpringBoneComputeSystem.swift:298–378, then read the CPU interpolation section at :1519–1608 and collider rebuilds at :938–950. Review center-frame handling at :1627–1653 and determine which proposed optimization can be isolated first. Done means reducing repeated CPU interpolation or collider allocation work while preserving SpringBone physics behavior; the issue does not define tests or exact acceptance criteria.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- computer-graphics, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100