Overview
Add non-allocating or caller-owned-buffer variants of 2D spatial queries so
hot gameplay paths can avoid per-query heap allocations.
Current State
query_point() and query_aabb() return Vec<RigidBody2D>, which is simple
and appropriate for most users, but not ideal for performance-sensitive loops.
Scope
Goals:
- Add query variants that write into caller-owned buffers or invoke callbacks
- Preserve the existing ergonomic
Vec-returning methods
- Keep the public API body-oriented and backend-agnostic
Non-Goals:
- Removing the current convenience APIs
- Query-side filtering if handled in a separate issue
- Unsafe APIs in the first iteration
Proposed API
impl PhysicsWorld2D {
pub fn query_point_into(
&self,
point: [f32; 2],
out: &mut Vec<RigidBody2D>,
);
pub fn query_aabb_into(
&self,
min: [f32; 2],
max: [f32; 2],
out: &mut Vec<RigidBody2D>,
);
pub fn query_point_each(
&self,
point: [f32; 2],
visit: impl FnMut(RigidBody2D),
);
}
Acceptance Criteria
Affected Crates
lambda-rs, lambda-rs-platform
Notes
- A callback-based API may avoid exposing buffer management concerns.
- This work should be driven by profiling.
Overview
Add non-allocating or caller-owned-buffer variants of 2D spatial queries so
hot gameplay paths can avoid per-query heap allocations.
Current State
query_point()andquery_aabb()returnVec<RigidBody2D>, which is simpleand appropriate for most users, but not ideal for performance-sensitive loops.
Scope
Goals:
Vec-returning methodsNon-Goals:
Proposed API
Acceptance Criteria
paths
Affected Crates
lambda-rs, lambda-rs-platform
Notes