https://github.com/thejustinwalsh/defold-xmath
Defold Math eXtension Library that avoids allocations
https://github.com/thejustinwalsh/defold-xmath
defold defold-native-extension game lua
Last synced: about 1 month ago
JSON representation
Defold Math eXtension Library that avoids allocations
- Host: GitHub
- URL: https://github.com/thejustinwalsh/defold-xmath
- Owner: thejustinwalsh
- License: mit
- Created: 2021-10-17T17:23:33.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-03T02:08:59.000Z (5 months ago)
- Last Synced: 2025-03-31T14:58:23.301Z (3 months ago)
- Topics: defold, defold-native-extension, game, lua
- Language: C++
- Homepage: https://thejustinwalsh.com/defold-xmath/
- Size: 2.48 MB
- Stars: 28
- Watchers: 4
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-defold - xMath - imagining of vmath functions that avoid allocations. (Libraries / Programming Language)
README
# xMath Extension
> Defold Math Library ❌ ~~allocations~~A re-imagining of vmath functions that avoid allocations by taking the output as the first argument instead of returning a new Vector3, Vector4, or Quat requiring an allocation.
```lua
go.property("dir", vmath.vector3(0, 1, 0))-- allocate v once and reuse each update
local v = vmath.vector3();function update(self, dt)
local pos = go.get_position();xmath.mul(v, self.dir, 5 * dt); -- save 1 allocation
xmath.add(v, pos, v); -- save 2 allocationsgo.set_position(v);
end
```## Demo
https://thejustinwalsh.com/defold-xmath/