Commit Graph

1209 Commits

Author SHA1 Message Date
Samuel Gosselin 425a2ca343 Add support for setting the display refresh-rate.
OpenXR provides APIs to enumerate the supported refresh-rates, and
selecting a new refresh-rate. This patch adds two new APIs to the
lovr.headset module:

  - lovr.headset.getDisplayFrequencies():
	Returns a table containing the supported refresh-rates on
	success; nil otherwise.
  - lovr.headset.setDisplayFrequency(refreshRate:number):
	Returns true on success, false otherwise.

Only the OpenXR backend has support for this feature and it is
gated by the "refreshRate" feature flag, similarly to what the
"getDisplayFrequency()" API does.
2022-05-06 10:55:29 -07:00
Josip Miskovic 24a0751c16 Add `World:setStepIterations(num)` and its getter
Physics world's "quick step" is executed in multiple iteration steps.
The getter and setter for this value is now made available as two new
methods in the World object.

This is allows user to balance between the less accurate but quick
simulations, and more stable behavior of physics.

Something similar was already possible, by reducing the delta time and
running the sim multiple times per frame. However, any force user applies
to collider is zeroed after each step. User would thus have to keep track
of applied forces, and re-apply them inside the physics iteration loop.

By default ODE uses 20 iterations in quick step.
2022-04-27 11:39:08 -07:00
bjorn 85ee89d36f Fix weirdness with vec2 scale arguments; 2022-04-06 10:10:27 -07:00
bjorn cd0e458af9 lovr.filesystem.write/append returns success instead of size;
We don't have a good way of returning filesystem error messages yet,
but it's still useful to return a boolean instead of a number to
detect failure of zero byte writes.  Exposing the number of bytes
written is kind of weird since it's not very actionable.
2022-03-30 22:45:09 -07:00
bjorn 42e618fa00 World:getContacts; 2022-03-30 22:32:20 -07:00
bjorn 8fcdfd2bb4 Minor physics cleanup; 2022-03-30 22:05:10 -07:00
bjorn efbcb5e4c2 Merge branch 'master' into dev 2022-03-30 13:52:58 -07:00
bjorn 5d271de91a mv map util; 2022-03-30 12:34:38 -07:00
bjorn faa42ee38b mv resources etc; 2022-03-30 12:34:34 -07:00
bjorn d70619ec96 Source:isSpatial; Separate spatial from effects; 2022-03-27 19:09:25 -07:00
bjorn e47f3eb108 Use doubles for noise; 2022-03-27 14:51:06 -07:00
bjorn 342f92940e Add :equals method to vector objects; 2022-03-25 16:05:38 -07:00
bjorn 6c9531564e Make physics structs private; 2022-03-25 12:40:29 -07:00
bjorn 5e752f0b25 Fix error when passing objects as thread arguments; 2022-03-23 23:16:34 -07:00
bjorn dcd1e58d0d rm tracking drivers; 2022-03-23 13:11:16 -07:00
bjorn 243e686ea4 rm lovr.headset.getDisplayMask; 2022-03-22 19:45:44 -07:00
bjorn 1eed2bc83c lovr.headset.isFocused; 2022-03-22 19:43:00 -07:00
bjorn 3d542b4791 rm beacon devices;
They are no longer supported by any headset drivers.
2022-03-22 18:08:44 -07:00
bjorn b7527c3584 More people use COUNTOF; 2022-03-22 17:56:26 -07:00
bjorn 1f3c5dea79 dt uses headset time instead of system time; 2022-03-22 17:52:16 -07:00
bjorn d1dc2f3199 rm pico;
Notes:

- We can actually use a single Activity.java file for oculus/pico now
- We can unconditionally compile os_android.c on Android
- No need for including extra jars in build system
- Headset rendering is guaranteed synchronous now, no need to ref L
- Add an "android flavor" build setting to differentiate between oculus
  and pico devices, since they both use OpenXR.
- Update the pico manifest to reflect their OpenXR sample
- Remove some OpenGL hacks that aren't necessary anymore
2022-03-22 16:03:21 -07:00
bjorn f1cc668298 rm vrapi; 2022-03-22 16:02:45 -07:00
bjorn 4f39f4f68f rm oculus; 2022-03-22 16:02:45 -07:00
bjorn b9889ca97a rm openvr; 2022-03-22 16:02:45 -07:00
bjorn 2da18d419b mv util src; 2022-03-22 00:13:38 -07:00
bjorn 0c17046847 Add eye/gaze device;
This provides an accurate pose for what the user is looking at, instead
of the poses of the individual eyes.  Supported on some OpenXR
implementations.
2022-03-21 15:05:23 -07:00
bjorn 1ca3d1c8e1 Fix unintended int truncation in Font:getLineHeight; 2022-03-16 12:23:59 -07:00
bjorn bbd502153a Formatting; 2022-03-15 16:33:53 -07:00
bjorn a4faad39f8 Font:getFilter; Font:setFilter; 2022-03-15 16:02:35 -07:00
bjorn 17c05b1760 Merge branch 'master' into dev 2022-03-14 14:10:25 -07:00
bjorn fdfcb5539f Merge branch 'master' into dev 2022-03-14 13:19:59 -07:00
bjorn c9fe026a66 Fix undefined behavior in arr_free;
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.
2022-03-14 12:27:58 -07:00
bjorn 1e91eea9b0 Fix Mat4:__mul(Vec3);
The matrix was transforming the input vector, not the new vector.
2022-03-10 07:41:44 -08:00
bjorn 54154a643a Thumbrest support; 2022-03-06 17:43:04 -08:00
Josip Miskovic 2e5c529faf Return nil if device doesn't have that button
Functions `lh.isDown()` and `isTouched()` should return nil if device
doesn't have the queried button.
2022-03-06 17:41:33 -08:00
murat g ee3ba6ef3e Font filtering now respects the default setting. 2022-03-03 22:41:47 -08:00
Josip Miskovic ef41e06fc9 Add Vec2/3/4:angle(other)
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.
2022-03-03 14:12:56 -08:00
bjorn b22dbd8f0c Add luax_checku32 and luax_optu32;
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.
2022-02-21 14:19:24 -08:00
bjorn a6a86fd908 lovr.filesystem.getDirectoryItems works if table.sort is unavailable;
It just doesn't sort the output.
2022-02-21 14:04:58 -08:00
bjorn 88f367c0e5 Declare data module constructors consistently; 2022-02-21 14:01:47 -08:00
bjorn a6747f97ea Sound:getByteStride; 2022-02-21 14:00:36 -08:00
bjorn bfb73f0c19 Improve Sound:getFrames Blob error message;
Probably need a generic "out of range" template, but this makes things
better for now.
2022-02-21 13:58:46 -08:00
Josip Miskovic 110333fce7 Fix gamma/linear conversion of a RGB table
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} )`
2022-02-19 22:21:35 -08:00
bjorn 6f3e46d8cf Fix some pointer formatting; 2022-02-02 12:01:38 -08:00
bjorn 7ed47e946b Fix problem when requiring audio/graphics/headset in threads;
These modules access the conf table, which isn't available on threads.
2022-01-16 12:13:46 -08:00
bjorn 8462beef00 Fix/improve alpha cutoff;
The current flag did not work because float shader flags are not
supported.  It was also not very useful because it was per-shader
and did not use the alpha cutoff property of glTF materials.

Instead, let's turn the shader flag into an enable/disable boolean,
and add a scalar material property named "alphacutoff" that gets
read by the glTF importer.

When the alphaCutoff flag is enabled, the material property will be
compared against the pixel's alpha value to decide whether it should
get discarded.
2021-12-28 21:10:52 +02:00
bjorn 20e4567bd6 Merge branch 'master' into dev 2021-12-20 17:12:39 +02:00
Josip Miskovic 09cc73a988 Move text measuring to Rasterizer 2021-10-21 10:42:11 -07:00
bjorn fe08dc3769 Fix Mesh:setVertices starting index wraparound crash; 2021-10-09 03:01:40 -07:00
bjorn 61730dd89b ModelData exposes its animations; 2021-10-08 14:25:03 -07:00