Commit Graph

42 Commits

Author SHA1 Message Date
bjorn 77abad4e21 Merge branch 'stable' into dev 2024-04-05 11:42:18 -07:00
bjorn 40879f383a Fix possible crash when using math module in multiple threads; 2024-04-05 11:41:51 -07:00
bjorn 2d7b636a90 Change more asserts to checks; 2024-03-11 00:58:21 -07:00
bjorn 08d6b2ad28 Refcounted modules;
This allows them to be initialized/destroyed from multiple threads in
any order.  Previously, the first thread to require a module had to be
the last thread to use the module, otherwise it would be destroyed too
early.

There are still a few issues.  If the main thread doesn't require a
module, it won't pick up the conf.lua settings.  Also graphics isn't
handling the shader cache writing properly.  And I think this breaks the
headset-graphics refcounting.  But these will be fixed in future
commits.
2023-11-23 17:07:44 -08:00
bjorn 9542d46f33 Buffer format cleanup; 2023-09-11 03:01:11 -07:00
bjorn be795c0ebd Change vec3 back to 3 floats; Clean up maf/vectors;
The "vec3 is 4 floats" thing was consistently confusing to people.  It's
reverted everywhere except for Curve.

maf now has full sets of methods for vec2/vec3/vec4, for consistency.

Vector bindings now use luax_readvec* helper functions for the
number/vector variants, and use maf for most functionality, which cleans
things up a lot.
2023-07-10 17:51:24 -07:00
bjorn fd0d3fc1ec Fix number + lightuserdata binary vector ops; 2023-07-03 19:17:09 -07:00
bjorn 41dd24edc4 Organize math module files; 2023-02-07 21:44:43 -08:00
bjorn bf98c066b4 t.math.globals also adds capitalized constructors; 2023-02-01 17:57:37 -08:00
bjorn d08cc539e8 Add vector constants;
They are implemented in the __index metamethod and return temporaries.
2023-01-24 18:37:04 -08:00
bjorn 4b0931a814 Change temp vector constructors to metatable __calls;
This enables a few things:

- Custom vector methods can be added/replaced.
- Vector methods can be called as non-methods e.g. vec3.normalize(v)
- Possibility for vector constants in an __index metamethod.

This was measured as increasing overhead by 3.5% when creating temporary
vectors (2ns), which is arbitrarily deemed acceptable.
2023-01-24 18:01:31 -08:00
bjorn e9776f98c6 Fix compatibility with Lua 5.2, 5.3, 5.4;
Part of this involved putting the Lua header back in api.h, since we
need to know the Lua version to define some macros properly.
2022-11-24 14:33:55 -08:00
bjorn 3c71828afa Revert "Change the way modules are destroyed;"
This reverts commit 019814e2c1.
2022-08-08 23:16:34 -07:00
bjorn 019814e2c1 Change the way modules are destroyed;
They are now destroyed explicitly after tearing down the Lua state
instead of relying on finalizers.  It's definitely annoying to make it
coordinated in a centralized way like this instead of being distributed,
but there's not really any reliabel way to ensure that graphics objects
are destroyed before the graphics module/device is destroyed, which is a
problem.
2022-08-04 21:44:34 -07:00
bjorn e47f3eb108 Use doubles for noise; 2022-03-27 14:51:06 -07:00
bjorn b7527c3584 More people use COUNTOF; 2022-03-22 17:56:26 -07:00
bjorn 2da18d419b mv util src; 2022-03-22 00:13:38 -07:00
bjorn fdfcb5539f Merge branch 'master' into dev 2022-03-14 13:19:59 -07: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 159243190b rm some unnecessary includes; 2021-04-20 20:08:30 -06:00
bjorn e63099ba6a Flatten api.h; 2021-03-15 18:54:27 -06:00
bjorn bc4cde1653 Adjust lovrRelease signature; 2021-02-08 17:52:26 -07:00
bjorn 3ded60948f rm core/ref; rm lovrAlloc; util does refcounting; 2021-02-08 17:26:44 -07:00
Josip Miskovic 1defba8f24 Create empty curve with specified number of points
This `lovr.math.newCurve(n)` variant is already described in API
documentation, now it is implemented.
2020-11-13 17:53:37 +01:00
bjorn 61eaf579cd Thread local vector metatable refs; 2020-11-06 13:12:57 -07:00
bjorn ec257b179f Support Lua 5.2, 5.3, 5.4; 2020-08-19 13:12:57 -06:00
bjorn f728496608 Make math module work better in threads;
conf doesn't work in threads.  While this seems problematic, it can
kinda be considered the right thing.  Right now the math module can't
be required at all in threads which seems bad, so we'll make it work
and just ignore the "globals" flag for now.
2020-01-14 00:39:38 -08:00
bjorn f3745a1edc Use uint64_t for seed in luax_checkrandomseed; 2019-12-05 13:46:12 -08:00
bjorn 305596adf8 Fix windows build;
LOVR_EXPORT needs to be on the declaration, unfortunately.
2019-08-26 15:53:10 -07:00
bjorn 8d4760167f luax is now api; 2019-08-21 15:27:26 -07:00
bjorn b51dece762 Fix bug with permanent vectors; 2019-08-20 00:54:42 -07:00
bjorn 584261e21f rm ffi vectors; 2019-08-19 14:13:36 -07:00
bjorn 122143b13a vec4; 2019-07-16 20:30:51 -07:00
bjorn 9156fa2cbf Vector rework; 2019-07-16 20:30:51 -07:00
bjorn 1f8a7e073f Curve: cleanup; 2019-07-11 11:22:03 -07:00
bjorn 4372eb293e rm comma operator;
everyone is making fun of me haha
2019-07-10 18:46:51 -07:00
bjorn eb1e257209 Add new array implementation; Upgrade filesystem;
Filesystem:

- Uses streaming file IO.
- Uses less memory when requiring files.
- Simplifies its require path implementation.
2019-06-16 13:30:30 -07:00
bjorn e9853ed3c7 t.math.ffi conf flag; 2019-06-10 00:11:20 -07:00
bjorn 06c6b172de vec3 has 4 elements; 2019-06-03 07:20:03 -07:00
bjorn 22fe333150 Update refcounting (again);
- Ref struct only stores refcount now and is more general.
- Proxy stores a hash of its type name instead of an enum.
- Variants store additional information instead of using a vtable.
- Remove the concept of superclasses from the API.
- Clean up some miscellaneous includes.
2019-06-02 01:02:26 -07:00
bjorn d11e9be175 Lua userdata store their destructor in their metatable; 2019-05-28 16:31:13 -07:00
bjorn 4a47afca38 Organize api folder; 2019-05-19 00:31:42 -07:00
Renamed from src/api/math.c (Browse further)