354 Commits

Author SHA1 Message Date
FatalErr42O
ae5c7046e8 fixed FFI library support, added success print 2023-09-08 20:13:07 -07:00
FatalErr42O
7ad207b4a9 added support for FFI library using trusted mods config 2023-09-08 19:11:08 -07:00
FatalErr42O
71e490eacb updated, not sure what changes were added 2023-09-01 18:20:43 -07:00
FatalErr42O
5afb9bc2d4 Merge branch 'master' of https://github.com/Minetest-Unification-Library/MTUL-CPML 2023-08-29 17:39:08 -07:00
FatalErr42O
eddd0bd720 verify integrity 2023-08-29 17:39:00 -07:00
FatalErr42O
0bae98220b
Update README.md 2023-08-29 16:58:05 -07:00
FatalErr42O
e9bf07339f
Update README.md 2023-08-29 16:56:49 -07:00
FatalErr42O
82f6a87587
Update README.md 2023-08-29 16:54:15 -07:00
FatalErr42O
24c636fa1a
Update README.md 2023-08-29 16:53:21 -07:00
FatalErr42O
4f3bb3ea5e now runs (with some require hax) 2023-08-29 16:01:42 -07:00
Colby Klein
eb209f6d91 fix typo in mat4.mul 2022-05-07 15:53:01 -07:00
Colby Klein
cf707cb6af bvh: add coarse aabb triangle query
doesn't bother checking individual tris, just the nodes
2022-05-06 23:54:34 -07:00
shakesoda
4234176b9b
Merge pull request #78 from rozenmad/master
fix BVH
2022-05-06 14:35:46 -07:00
mcclure
4dfe443585
Merge pull request #79 from vendethiel/patch-1
backtick * in readme so it isn't interpreted as md
2022-05-05 11:08:16 -04:00
ven
5277cd859f
backtick * in readme so it isn't interpreted as md
Without this, the two `*`s are considered matching italic delimiters.
2022-05-05 14:14:14 +02:00
rozenmad
c71d81f5aa fix BVH
Fixed:
1. splitNode - function didn't correctly split nodes.
2. Incorrect count of the number of elements in a node.
2022-05-05 04:13:06 +03:00
Colby Klein
8282157954 new tests for project/unproject 2022-04-30 15:38:13 -07:00
Colby Klein
7ab572f151 fix project/unproject 2022-04-30 14:48:40 -07:00
Colby Klein
7d22d13bca (breaking) simplify mat4.project and unproject
the separate view and projection just weren't really useful, might as
well pass in your own full transform instead.

this also fixes the z range, which should not have been manipulated.
this simplifies usage to check something as on screen to just 1 > z > 0

might break the test, but tested working locally
2022-04-30 14:10:51 -07:00
Colby Klein
e34ab20d82 spacing 2022-04-30 12:09:29 -07:00
Colby Klein
62e5e16b46 mat4.mul can now concatenate a table of inputs 2022-04-30 12:07:54 -07:00
Colby Klein
6c7c929c38 fix doc typo 2022-04-30 11:31:54 -07:00
Colby Klein
3a9951d4b1 add mat4.target 2022-04-30 11:29:45 -07:00
Colby Klein
53a3d0c7de fix doc typo 2022-04-30 11:27:50 -07:00
Colby Klein
6babc92c2b use mul_vec3_perspective on mat4.__mul
if you are using the `mat4 * vec3` overload, this is probably what you
would expect to be happening. this should be the same for any case which
worked previously, but will return a correct result with perspective.
2022-04-21 13:02:58 -07:00
Colby Klein
c84a8e07c0 add mat4.mul_vec3_perspective, fix doc typo 2022-04-21 12:12:02 -07:00
Colby Klein
d83b4c71ce fix doc typo 2022-04-21 12:10:28 -07:00
Colby Klein
0bff69f3ba add vec3.normalize_len, fix some doc typos 2022-04-21 12:10:04 -07:00
Colby Klein
919900fea2 add utils.sign 2022-04-21 11:53:00 -07:00
Colby Klein
f11cea9588 fix whitespace 2022-04-21 11:25:58 -07:00
Colby Klein
9f57a1a939 remove unused a parameter from mat4.look_at 2022-04-21 11:22:55 -07:00
Colby Klein
13cd41770f fix formatting 2022-04-21 11:22:18 -07:00
shakesoda
3b90354910
Merge pull request #63 from semyon422/master
Minor fixes
2022-04-21 11:08:52 -07:00
shakesoda
4350c25d0c
Merge pull request #72 from idbrii/color
Overhaul color: fix bugs, change to 0-1
2022-04-21 10:47:54 -07:00
shakesoda
9b4b6e7fa7
Merge pull request #76 from xiejiangzhi/xjz
Add Vec3.angle_to
2022-04-21 10:46:01 -07:00
shakesoda
ab0132a6ac
Merge pull request #66 from aki-cat/master
Implement scale to mat4.from_transform method
2022-04-20 15:56:31 -07:00
jiangzhi.xie
6bc7ec7718 Add testing code for vec3.angle_to 2022-04-20 20:05:52 +08:00
xiejiangzhi
02d7604b17 Add vec3.angle_to 2022-04-20 19:13:08 +08:00
David Briscoe
7d99a08134 [Breaking] color: Convert hue [0,359] -> [0,1]
imgui [uses 0-1 for everything internally](
https://github.com/ocornut/imgui/blob/master/imgui.cpp#L2045).

[Both Unity](https://docs.unity3d.com/ScriptReference/Color.RGBToHSV.html)
[and Godot](https://docs.godotengine.org/en/stable/classes/class_color.html#class-color-property-h)
use H, S, and V in the range 0.0 to 1.0

Since we're switching colours out of 0,255 we should also switch hue out
of 0,359. Now all of our r,g,b,a,h,s,v values are all in 0,1.
2022-04-01 21:55:40 -07:00
David Briscoe
0c12f17805 color: Linear alpha in linear<->gamma conversions
Maintain linear alpha when converting to gamma.

Update to latest wikipedia links.

Add simple test that does the round trip conversion.
2022-04-01 21:55:40 -07:00
David Briscoe
aec3b9fd7f Prevent nan when using color_to_hsv(white)
When r,g,b are equal, delta will be zero and hue will be nan due to
divide by zero.

This is also an issue with the reference C++ code:
https://tio.run/##Sy4o0E3OScxL//9fOTMvOac0JVXBJjO/uKQoNTHXjiszr0QhNzEzT0NToZqLs7gkxcoqOb@0RMHGRkHJIzUnJ19HITy/KCdFUQkkBJZPzUvJseaq/f8fAA

An alternative approach is to always add epsilon or use a different hue
calculation:
    http://web.archive.org/web/20210515082154/http://lolengine.net/blog/2013/01/13/fast-rgb-to-hsv
2022-04-01 21:55:32 -07:00
David Briscoe
41b1f0b5b9 color: Add more tests 2022-04-01 21:47:56 -07:00
David Briscoe
343f320e2f [Breaking] color: Convert 0-255 -> 0-1 range
Our hsv logic assumes 0-1 (cs.rit.edu says "r,g,b values are from 0 to
1") and it makes more sense to provide __mul for multiplying in 0-1
since the result will stay in that range. Additionally, love switched to
0-1 color since 11.0.

Included an as_255() function to unpack the color in 0-255 for some
amount of backwards compatibility. Doesn't make sense to provide any
kind of color object for it since most of our functions won't work
correctly.

Add tests for hue(), saturation(), value() that fail (even with /255
removed) for the old code, but pass on the new 0-1 range because the hsv
logic outputs colors in 0-1. Test comparisons use reduced precision
because my input data has limited precision.
2022-04-01 21:47:56 -07:00
David Briscoe
df92f0c5cd [Breaking] color: Make expected range match docs
lighten/darken: documented range is 0-255, so we don't need to multiply.
Makes more sense to work with colors in the same range that we're
incrementing by, but this changes behaviour.

saturation/value: we use a percent, so it's 0-1. It's clamped so that's
obviously expected.

Add tests to validate this new behaviour.
2022-04-01 21:47:09 -07:00
David Briscoe
509594aec2 color: Use color_mt and normal indexing
Fix #34.

Set color_mt on new colors so add, subtract, multiply, is_color work.

We don't use ffi for color (32cf0e8), so remove cdata check for 0-based
offset indexing.

Add tests for creating colours and using operators.
2022-04-01 19:55:55 -07:00
shakesoda
ea79f346f6
Merge pull request #75 from idbrii/precond
Include offending type in precondition failure msg
2022-03-31 06:05:54 -07:00
shakesoda
36dfd97429
Merge pull request #74 from idbrii/atan
vec2: Fallback to math.atan
2022-03-27 14:37:52 -07:00
David Briscoe
be10073156 vec2: Fallback to math.atan
Lua 5.3+ use a two-argument version of math.atan instead of math.atan2.
atan2 exists but is deprecated, so if you use cpml in a lua build that
strips deprecated functions vec2.angle_to will fail.
2022-03-27 09:56:44 -07:00
David Briscoe
c26cc1a508 Include offending type in precondition failure msg
Output the type that was incorrect to make it more obvious what the user
is doing wrong without them adding logging.

To avoid string building during lots of vector math, introduced a
private precond module that only builds the strings when an error
occurs. It uses error() to put the resulting error message at the caller
to cpml.

Before:

  lua: ~/cpml/modules/vec2.lua:52: new: Wrong argument type for x (<number> expected)
  lua: ~/cpml/modules/vec2.lua:424: __add: Wrong argument type for right hand operand. (<cpml.vec2> expected)

  example stack traceback:
  	[C]: in function 'assert'
  	~/cpml/modules/vec2.lua:424: in metamethod '__add'
  	test_cpml.lua:32: in main chunk
  	[C]: in ?

After:

  lua: test_cpml.lua:31: new: Wrong argument type for x: string (<number> expected)
  lua: test_cpml.lua:32: __add: Wrong argument type 'string' for right hand operand. (<cpml.vec2> expected)

  example stack traceback:
  	[C]: in function 'error'
  	~/cpml/modules/_private_precond.lua:13: in function 'modules._private_precond.assert'
  	~/cpml/modules/vec2.lua:425: in metamethod '__add'
  	test_cpml.lua:32: in main chunk
  	[C]: in ?

The tracebacks are longer, but the initial error is at the location of
the mistake and the output includes the input type.
2022-03-27 09:56:15 -07:00
shakesoda
c50d292cb6
Merge pull request #69 from idbrii/mat-cleanup
mat4: minor cleanup of globals and unused variables
2022-03-27 03:48:54 -07:00