This adds the ability to load and animate a mesh for hand tracking on
the Oculus Quest. It is more or less identical to the current
functionality on the vrapi driver.
One key part of this change is that getPose in OpenXR will see if action
spaces are active before locating their spaces. This is due to some
behavior observed on the Oculus Quest with hand tracking where pose
actions for controllers would return invalid data with all of the
location flags erroneously set. The only way to detect and work around
this is to check the pose action state. When this happens, we fall back
to returning the pose of the wrist joint, which is where the Oculus hand
mesh wants to be drawn. In the event that both controllers and hand
tracking are active, the controller pose will be returned by getPose but
the wrist joint can still be accessed using getSkeleton.
Note that this does not yet include support for properly scaling the
hand mesh.
There are numerous opportunities for optimization here that may be
investigated in the future, though performance is well within an
acceptable range right now.
The notdef glyph will get rendered instead, which is slightly better.
Note that the default font does not have a notdef glyph (bug).
Note that notdef will be rasterized multiple times right now.
Currently there is a single allocator function used in arr_t. Its
behavior depends on the values for the pointer and size arguments:
- If pointer is NULL, it should allocate new memory.
- If pointer is non-NULL and size is positive, it should resize memory.
- If size is zero, it should free memory.
All instances of arr_t use realloc for this right now. The problem
is that realloc's behavior is undefined when the size argument is zero.
On Windows and Linux, realloc will free the pointer, but on macOS this
isn't the case. This means that arr_t leaks memory on macOS.
It's best to not rely on undefined behavior like this, so let's instead
use a helper function that behaves the way we want.
The VrApi implementation now checks that X, Y, A, B buttons exist on that
specific controller. X,Y are on left; A,B on the right controller. That
mapping covers Quest Touch and Quest 2 controllers.
Functions to calculate the angle between two vectors. Angle is always
positive. Implementations give the same result as this Lua code:
```lua
local function lua_angle(v1, v2)
return math.acos(v1:dot(v2) / (v1:length() * v2:length()))
end
```
If either vector is zero-length, the pi/2 value is returned.
These functions read an unsigned 32 bit integer from the Lua stack
and error if the value is negative or too big. Currently converting
Lua numbers to integers will silently wrap or invoke undefined behavior
when they are outside of the acceptable range.
For projects that don't want the overhead of type/bounds checks, the
supercharge build option (LOVR_UNCHECKED) can now be used to skip all
type/bounds checks.
Correcting the order of stack operations to fetch RGB components from
the table and to put in conversion the results.
Before the fix these two calls produced different results:
`lovr.math.gammaToLinear( 0.1, 0.2, 0.3 )`
`lovr.math.gammaToLinear( {0.1, 0.2, 0.3} )`