What problem does it solve?
In Lua-based Defold projects, hot-path math frequently allocates objects, triggering GC pauses. xmath enables in-place mutation and reuses pre-allocated scratch variables, eliminating per-frame allocations and reducing GC pressure.
Core Features & Use Cases
- In-place mutation: all xmath operations write results into the first argument, enabling scratch buffers to be reused across frames.
- Pre-allocated scratch variables: store transient vectors/quaternions at module scope or init to avoid per-frame allocations.
- Type support: xmath handles vector3, vector4, and quaternion operations with a consistent first-argument output convention.
- Integration pattern: pair xmath with vmath to initialize scratch objects, then apply a sequence of operations to compute final results.
- Use cases: physics nudges, animation tweaks, and other hot-path math in gameplay loops.
Quick Start
Pre-allocate scratch buffers and rewrite hot math paths to mutate outputs in place using xmath.