Renamed to LEEF-Math
This commit is contained in:
parent
7a55cf9303
commit
190eee0d9c
@ -1,7 +1,7 @@
|
|||||||
Cirno's Perfect Math Library
|
Cirno's Perfect Math Library
|
||||||
====
|
====
|
||||||
|
|
||||||
This is a Love (the game framework) library which has been ported and modified to work in the context of Luanti.
|
This is a Love (the game framework) library CPML which has been ported and modified to work in the context of Luanti.
|
||||||
|
|
||||||
### Main features
|
### Main features
|
||||||
* only Luanti Library which implements the ability to manipulate matrices and quaternions and convert them reliably to irrlicht bone rotations.
|
* only Luanti Library which implements the ability to manipulate matrices and quaternions and convert them reliably to irrlicht bone rotations.
|
||||||
@ -14,12 +14,12 @@ This is a Love (the game framework) library which has been ported and modified t
|
|||||||
* more
|
* more
|
||||||
|
|
||||||
### Adapted for Luanti
|
### Adapted for Luanti
|
||||||
For best memory performance: have luaJIT & it's FFI library (this should be built into luaJIT), and add MTUL-CPML to your trusted list (so it can `require()` call the FFI library).
|
For best memory performance: have luaJIT & it's FFI library (this should be built into luaJIT), and add LEEF-Math to your trusted list (so it can `require()` call the FFI library).
|
||||||
|
|
||||||
Various useful bits of game math. 3D line intersections, ray casting, 2d/3d vectors, 4x4 matrices, quaternions, etc.
|
Various useful bits of game math. 3D line intersections, ray casting, 2d/3d vectors, 4x4 matrices, quaternions, etc.
|
||||||
|
|
||||||
This is a fork of CPML (for LÖVE/love3d), it's been ported over the minetest so it can be used in whatever you need it for.
|
This is a fork of CPML (for LÖVE/love3d), it's been ported over the minetest so it can be used in whatever you need it for.
|
||||||
Documentation can be found here: <https://minetest-unified-library.github.io/MTUL-CPML/>.
|
Documentation can be found here: <https://minetest-unified-library.github.io/LEEF-Math/>.
|
||||||
|
|
||||||
For possible future contributors: documentation must be generated manually when a commit is made, because I haven't set up workflows (and have no idea how to).
|
For possible future contributors: documentation must be generated manually when a commit is made, because I haven't set up workflows (and have no idea how to).
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<div id="content">
|
<div id="content">
|
||||||
|
|
||||||
|
|
||||||
<h2>A math library with (hopefully) everything you need for 2D/3D games</h2>
|
<h2>The CPML library ported to Luanti and extended.</h2>
|
||||||
|
|
||||||
<h2>Modules</h2>
|
<h2>Modules</h2>
|
||||||
<table class="module_list">
|
<table class="module_list">
|
||||||
@ -130,7 +130,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -662,7 +662,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -662,7 +662,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -77,7 +77,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -730,7 +730,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -118,7 +118,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -77,7 +77,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -1505,7 +1505,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -77,7 +77,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -703,7 +703,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -1403,7 +1403,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -77,7 +77,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -550,7 +550,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -1117,7 +1117,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -1025,7 +1025,7 @@
|
|||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<div id="navigation">
|
<div id="navigation">
|
||||||
<br/>
|
<br/>
|
||||||
<h1>CPML</h1>
|
<h1>LEEF Math</h1>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
@ -61,26 +61,38 @@
|
|||||||
|
|
||||||
|
|
||||||
<h1>Cirno's Perfect Math Library</h1>
|
<h1>Cirno's Perfect Math Library</h1>
|
||||||
<h3>Adapted for Minetest</h3>
|
|
||||||
<p>For best memory performance: have luaJIT & it's FFI library (this should be built into luaJIT), and add MTUL-CPML to your trusted list (so it can <code>require()</code> call the FFI library).</p>
|
<p>This is a Love (the game framework) library CPML which has been ported and modified to work in the context of Luanti.</p>
|
||||||
|
|
||||||
|
<h3>Main features</h3>
|
||||||
|
<p>* only Luanti Library which implements the ability to manipulate matrices and quaternions and convert them reliably to irrlicht bone rotations.
|
||||||
|
* bounding box modules
|
||||||
|
* mat4
|
||||||
|
* vec3
|
||||||
|
* quaternions
|
||||||
|
* octrees
|
||||||
|
* bvh lib
|
||||||
|
* more</p>
|
||||||
|
|
||||||
|
<h3>Adapted for Luanti</h3>
|
||||||
|
<p>For best memory performance: have luaJIT & it's FFI library (this should be built into luaJIT), and add LEEF-Math to your trusted list (so it can <code>require()</code> call the FFI library).</p>
|
||||||
|
|
||||||
<p>Various useful bits of game math. 3D line intersections, ray casting, 2d/3d vectors, 4x4 matrices, quaternions, etc.</p>
|
<p>Various useful bits of game math. 3D line intersections, ray casting, 2d/3d vectors, 4x4 matrices, quaternions, etc.</p>
|
||||||
|
|
||||||
<p>This is a fork of CPML (for LÖVE/love3d), it's been ported over the minetest so it can be used in whatever you need it for.
|
<p>This is a fork of CPML (for LÖVE/love3d), it's been ported over the minetest so it can be used in whatever you need it for.
|
||||||
Documentation can be found here: <a href="https://minetest-unification-library.github.io/MTUL-CPML/">https://minetest-unification-library.github.io/MTUL-CPML/</a>.</p>
|
Documentation can be found here: <a href="https://minetest-unified-library.github.io/LEEF-Math/">https://minetest-unified-library.github.io/LEEF-Math/</a>.</p>
|
||||||
|
|
||||||
<p>Documentation must be generated manually when a commit is made, because I haven't set up workflows (and have no idea how to).</p>
|
<p>For possible future contributors: documentation must be generated manually when a commit is made, because I haven't set up workflows (and have no idea how to).</p>
|
||||||
|
|
||||||
<h3>TODO:</h3>
|
<h3>TODO:</h3>
|
||||||
<p>* Vec3s and Vec2s are not currently adapted for functionality with MT vectors (seperate classes)
|
<p>* Vec3s and Vec2s are not currently adapted for functionality with MT vectors, fix.</p>
|
||||||
* Figure out how CPML (originally) automatically updated docs, and do it here.</p>
|
|
||||||
|
|
||||||
|
|
||||||
</div> <!-- id="content" -->
|
</div> <!-- id="content" -->
|
||||||
</div> <!-- id="main" -->
|
</div> <!-- id="main" -->
|
||||||
<div id="about">
|
<div id="about">
|
||||||
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
<i>generated by <a href="http://github.com/lunarmodules/ldoc">LDoc 1.5.0</a></i>
|
||||||
<i style="float:right;">Last updated 2024-11-30 20:09:10 </i>
|
<i style="float:right;">Last updated 2024-12-01 12:04:18 </i>
|
||||||
</div> <!-- id="about" -->
|
</div> <!-- id="about" -->
|
||||||
</div> <!-- id="container" -->
|
</div> <!-- id="container" -->
|
||||||
</body>
|
</body>
|
||||||
|
25
init.lua
25
init.lua
@ -35,7 +35,6 @@
|
|||||||
local cpml = {
|
local cpml = {
|
||||||
_LICENSE = "CPML is distributed under the terms of the MIT license. See LICENSE.md.",
|
_LICENSE = "CPML is distributed under the terms of the MIT license. See LICENSE.md.",
|
||||||
_URL = "https://github.com/excessive/cpml",
|
_URL = "https://github.com/excessive/cpml",
|
||||||
_VERSION = "1.2.9",
|
|
||||||
_DESCRIPTION = "Cirno's Perfect Math Library: Just about everything you need for 3D games. Hopefully."
|
_DESCRIPTION = "Cirno's Perfect Math Library: Just about everything you need for 3D games. Hopefully."
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,18 +58,18 @@ local files = {
|
|||||||
--you will now witness the lua equivelant of a schizo rant. Have fun with this bullshit.
|
--you will now witness the lua equivelant of a schizo rant. Have fun with this bullshit.
|
||||||
|
|
||||||
--initialize some variables
|
--initialize some variables
|
||||||
mtul = mtul or {
|
leef = leef or {
|
||||||
loaded_modules = {}
|
loaded_modules = {}
|
||||||
}
|
}
|
||||||
mtul.math = mtul.math or {}
|
leef.math = leef.math or {}
|
||||||
mtul.loaded_modules.cpml = true
|
leef.loaded_modules.math = true
|
||||||
|
|
||||||
local old_require = require --just in case require is present (aka it's an insecure environment)
|
local old_require = require --just in case require is present (aka it's an insecure environment)
|
||||||
local old_package_path
|
local old_package_path
|
||||||
local modpath
|
local modpath
|
||||||
--check that it's minetest and not a lua script running it. If it's not minetest we dont have to do all of this, but otherwise we dont know if
|
--check that it's minetest and not a lua script running it. If it's not minetest we dont have to do all of this, but otherwise we dont know if
|
||||||
if minetest or (core and core.register_globalstep) then
|
if minetest or (core and core.register_globalstep) then
|
||||||
modpath = minetest.get_modpath("mtul_cpml")
|
modpath = minetest.get_modpath("leef_math")
|
||||||
local ie = minetest.request_insecure_environment()
|
local ie = minetest.request_insecure_environment()
|
||||||
|
|
||||||
--since we can't use require, what we do instead is override require by some utterly offensive means.
|
--since we can't use require, what we do instead is override require by some utterly offensive means.
|
||||||
@ -94,22 +93,22 @@ if minetest or (core and core.register_globalstep) then
|
|||||||
if type(jit) == "table" and jit.status() then
|
if type(jit) == "table" and jit.status() then
|
||||||
if ie then
|
if ie then
|
||||||
if pcall(require, "ffi") then
|
if pcall(require, "ffi") then
|
||||||
minetest.log("verbose", "MTUL-CPML: loaded JIT FFI library. Memory efficiency with FFI enabled.")
|
minetest.log("verbose", "LEEF-Math: loaded JIT FFI library. Memory efficiency with FFI enabled.")
|
||||||
print("mtul-cpml: JIT FFI loaded successfully.")
|
print("LEEF-Math: JIT FFI loaded successfully.")
|
||||||
else
|
else
|
||||||
minetest.log("error", "MTUL-CPML: Failure to load JIT FFI library.")
|
minetest.log("error", "LEEF-Math: Failure to load JIT FFI library.")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
minetest.log("error", "MTUL-CPML: insecure environment denied for MTUL-CPML. Add mtul-cpml to your trusted mods for better performance")
|
minetest.log("error", "LEEF-Math: insecure environment denied for LEEF-Math. Add leef_math to your trusted mods for better performance")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
minetest.log("verbose", "MTUL-CPML: JIT not present, skipped attempt to load JIT FFI library for acceleration and memory efficiency")
|
minetest.log("verbose", "LEEF-Math: JIT not present, skipped attempt to load JIT FFI library for acceleration and memory efficiency")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
--load the files
|
--load the files
|
||||||
|
|
||||||
for _, file in ipairs(files) do
|
for _, file in ipairs(files) do
|
||||||
mtul.math[file] = require(modules .. file)
|
leef.math[file] = require(modules .. file)
|
||||||
end
|
end
|
||||||
|
|
||||||
--unset all the global shit we had to change for CPML to work properly.
|
--unset all the global shit we had to change for CPML to work properly.
|
||||||
@ -123,12 +122,12 @@ end
|
|||||||
|
|
||||||
--dofile(modpath.."/unit_tests/quat_unit_test.lua")
|
--dofile(modpath.."/unit_tests/quat_unit_test.lua")
|
||||||
if modpath then
|
if modpath then
|
||||||
print("MTUL CPML: BEGINNING UNIT TESTING FOR COMPLEX TYPES")
|
print("LEEF Math: BEGINNING UNIT TESTING FOR COMPLEX TYPES")
|
||||||
dofile(modpath.."/unit_tests/irrlicht_luanti_tests.lua")
|
dofile(modpath.."/unit_tests/irrlicht_luanti_tests.lua")
|
||||||
dofile(modpath.."/unit_tests/matrix_unit_test.lua")
|
dofile(modpath.."/unit_tests/matrix_unit_test.lua")
|
||||||
dofile(modpath.."/unit_tests/quat_unit_test.lua")
|
dofile(modpath.."/unit_tests/quat_unit_test.lua")
|
||||||
else
|
else
|
||||||
print("MTUL CPML: BEGINNING UNIT TESTING FOR COMPLEX TYPES")
|
print("LEEF Math: BEGINNING UNIT TESTING FOR COMPLEX TYPES")
|
||||||
require("/unit_tests/irrlicht_luanti_tests.lua")
|
require("/unit_tests/irrlicht_luanti_tests.lua")
|
||||||
require("/unit_tests/matrix_unit_test.lua")
|
require("/unit_tests/matrix_unit_test.lua")
|
||||||
require("/unit_tests/quat_unit_test.lua")
|
require("/unit_tests/quat_unit_test.lua")
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
project="CPML"
|
project="LEEF Math"
|
||||||
title="CPML documentation"
|
title="CPML documentation"
|
||||||
description="A math library with (hopefully) everything you need for 2D/3D games"
|
description="The CPML library ported to Luanti and extended."
|
||||||
format="markdown"
|
format="markdown"
|
||||||
backtick_references=false
|
backtick_references=false
|
||||||
file = {
|
file = {
|
||||||
|
7
mod.conf
7
mod.conf
@ -1,5 +1,4 @@
|
|||||||
name = mtul_cpml
|
name = leef_math
|
||||||
title = MTUL Cirnos Perfect Math Library
|
title = LEEF - Cirnos Perfect Math Library
|
||||||
description = integrates CPML library from the Love framework community into Minetest
|
description = integrates CPML library from the Love framework community into Minetest
|
||||||
author = CPML creators, FatalError42O
|
author = CPML creators, FatalError42O
|
||||||
optional_depends = mtul_core
|
|
@ -949,7 +949,7 @@ end
|
|||||||
local quat_new
|
local quat_new
|
||||||
function mat4.to_quaternion(m)
|
function mat4.to_quaternion(m)
|
||||||
--I want to note that for no apparent reason at all the original matrix was transposed here
|
--I want to note that for no apparent reason at all the original matrix was transposed here
|
||||||
if not quat_new then quat_new = mtul.math.quat.new end
|
if not quat_new then quat_new = leef.math.quat.new end
|
||||||
local w = math.sqrt(1 + m[1] + m[6] + m[11]) / 2
|
local w = math.sqrt(1 + m[1] + m[6] + m[11]) / 2
|
||||||
local q=quat_new(
|
local q=quat_new(
|
||||||
(m[7] - m[10]) /(4 * w),
|
(m[7] - m[10]) /(4 * w),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
local cos = math.cos
|
local cos = math.cos
|
||||||
local sin = math.sin
|
local sin = math.sin
|
||||||
local m = mtul.math
|
local m = leef.math
|
||||||
local mat4 = mtul.math.mat4
|
local mat4 = leef.math.mat4
|
||||||
|
|
||||||
local pitch_ZY = function(a)
|
local pitch_ZY = function(a)
|
||||||
local temp = mat4.new()
|
local temp = mat4.new()
|
||||||
@ -97,7 +97,7 @@ local function make_funcs_human_readable(str)
|
|||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
function mtul.math.find_matrix_rotation_order(check_func)
|
function leef.math.find_matrix_rotation_order(check_func)
|
||||||
--x,y,z
|
--x,y,z
|
||||||
local euler = {(math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4}
|
local euler = {(math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4}
|
||||||
local output = check_func(mat4.new(), euler[1],euler[2],euler[3])
|
local output = check_func(mat4.new(), euler[1],euler[2],euler[3])
|
||||||
@ -131,17 +131,17 @@ function mtul.math.find_matrix_rotation_order(check_func)
|
|||||||
end
|
end
|
||||||
print("================== BEGINNING LUANTI AND IRRLICHT UNIT TESTs =======================")
|
print("================== BEGINNING LUANTI AND IRRLICHT UNIT TESTs =======================")
|
||||||
|
|
||||||
local find_rot_order = mtul.math.find_matrix_rotation_order
|
local find_rot_order = leef.math.find_matrix_rotation_order
|
||||||
print("\n checking sanity of tests:")
|
print("\n checking sanity of tests:")
|
||||||
local _tempeuler = {(math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4}
|
local _tempeuler = {(math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4}
|
||||||
local _testmatrix = mtul.math.mat4.set_rot_zxy(mat4.new(), _tempeuler[1],_tempeuler[2],_tempeuler[3])
|
local _testmatrix = leef.math.mat4.set_rot_zxy(mat4.new(), _tempeuler[1],_tempeuler[2],_tempeuler[3])
|
||||||
print("matrix equality check func is sane:", check_matrix_equality(_testmatrix,_testmatrix))
|
print("matrix equality check func is sane:", check_matrix_equality(_testmatrix,_testmatrix))
|
||||||
print("matrix equality check func tolerance:", matrix_tolerance)
|
print("matrix equality check func tolerance:", matrix_tolerance)
|
||||||
|
|
||||||
print("\n Checking rotation orders. Rotation application order is in reverse, these are the literal matrix multiplication order. ")
|
print("\n Checking rotation orders. Rotation application order is in reverse, these are the literal matrix multiplication order. ")
|
||||||
print("checking rotation matrix `set_rot_luanti_entity`")
|
print("checking rotation matrix `set_rot_luanti_entity`")
|
||||||
find_rot_order(mtul.math.mat4.set_rot_luanti_entity)
|
find_rot_order(leef.math.mat4.set_rot_luanti_entity)
|
||||||
print("checking `set_rot_irrlicht_bone`")
|
print("checking `set_rot_irrlicht_bone`")
|
||||||
find_rot_order(mtul.math.mat4.set_rot_irrlicht_bone)
|
find_rot_order(leef.math.mat4.set_rot_irrlicht_bone)
|
||||||
|
|
||||||
print("================== ENDING LUANTI AND IRRLICHT UNIT TESTs =======================")
|
print("================== ENDING LUANTI AND IRRLICHT UNIT TESTs =======================")
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
local mat4 = mtul.math.mat4
|
local mat4 = leef.math.mat4
|
||||||
local matrix_tolerance = .00001
|
local matrix_tolerance = .00001
|
||||||
local function check_matrix_equality(m1,m2)
|
local function check_matrix_equality(m1,m2)
|
||||||
for i = 1,16 do
|
for i = 1,16 do
|
||||||
@ -35,10 +35,10 @@ end
|
|||||||
find_irr_order()
|
find_irr_order()
|
||||||
end]]
|
end]]
|
||||||
print("================== BEGINNING MATRIX UNIT TESTs =======================")
|
print("================== BEGINNING MATRIX UNIT TESTs =======================")
|
||||||
local find_rot_order = mtul.math.find_matrix_rotation_order
|
local find_rot_order = leef.math.find_matrix_rotation_order
|
||||||
print("\n checking sanity of tests:")
|
print("\n checking sanity of tests:")
|
||||||
local _tempeuler = {(math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4}
|
local _tempeuler = {(math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4, (math.random()-.5)*math.pi*4}
|
||||||
local _testmatrix = mtul.math.mat4.set_rot_zxy(mat4.new(), _tempeuler[1],_tempeuler[2],_tempeuler[3])
|
local _testmatrix = leef.math.mat4.set_rot_zxy(mat4.new(), _tempeuler[1],_tempeuler[2],_tempeuler[3])
|
||||||
print("matrix equality check func is sane:", check_matrix_equality(_testmatrix,_testmatrix))
|
print("matrix equality check func is sane:", check_matrix_equality(_testmatrix,_testmatrix))
|
||||||
print("matrix equality check func tolerance:", matrix_tolerance)
|
print("matrix equality check func tolerance:", matrix_tolerance)
|
||||||
local ran_ang = math.random()*math.pi*2
|
local ran_ang = math.random()*math.pi*2
|
||||||
@ -46,11 +46,11 @@ print("santitize_angle is sane:", equals(1.60947655802, santitize_angle(7.892661
|
|||||||
--print("checking irrlicht setRotationRadians")
|
--print("checking irrlicht setRotationRadians")
|
||||||
--print(find_rot_order(irrlicht_matrix_setRotationRadians).." iterations")
|
--print(find_rot_order(irrlicht_matrix_setRotationRadians).." iterations")
|
||||||
|
|
||||||
print("\n checking MTUL's luanti and irrlicht matrix rotation orders. Rotation application order is in reverse, these are the literal matrix multiplication order. ")
|
print("\n checking LEEF's luanti and irrlicht matrix rotation orders. Rotation application order is in reverse, these are the literal matrix multiplication order. ")
|
||||||
print("checking rotation matrix `set_rot_luanti_entity`")
|
print("checking rotation matrix `set_rot_luanti_entity`")
|
||||||
find_rot_order(mtul.math.mat4.set_rot_luanti_entity)
|
find_rot_order(leef.math.mat4.set_rot_luanti_entity)
|
||||||
print("checking `set_rot_irrlicht_bone`")
|
print("checking `set_rot_irrlicht_bone`")
|
||||||
find_rot_order(mtul.math.mat4.set_rot_irrlicht_bone)
|
find_rot_order(leef.math.mat4.set_rot_irrlicht_bone)
|
||||||
|
|
||||||
--[[print("check in euler out euler for minetest entitiy matrix rotations")
|
--[[print("check in euler out euler for minetest entitiy matrix rotations")
|
||||||
local x,y,z =(math.random()-.5)*math.pi*4,(math.random()-.5)*math.pi*4,(math.random()-.5)*math.pi*4
|
local x,y,z =(math.random()-.5)*math.pi*4,(math.random()-.5)*math.pi*4,(math.random()-.5)*math.pi*4
|
||||||
@ -103,13 +103,13 @@ print()]]
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
--[[local quat = mtul.math.quat
|
--[[local quat = leef.math.quat
|
||||||
print("\n comparing `euler to matrix` & `euler to quaternion` matrix outputs")
|
print("\n comparing `euler to matrix` & `euler to quaternion` matrix outputs")
|
||||||
x,y,z = math.random()*math.pi*2, math.random()*math.pi*2, math.random()*math.pi*2
|
x,y,z = math.random()*math.pi*2, math.random()*math.pi*2, math.random()*math.pi*2
|
||||||
local mat1 = mat4.set_rot_zxy(mat4.new(), x,y,z)
|
local mat1 = mat4.set_rot_zxy(mat4.new(), x,y,z)
|
||||||
local new_quat = quat.new():from_euler_zxy(x,y,z)
|
local new_quat = quat.new():from_euler_zxy(x,y,z)
|
||||||
local mat2 = mat4.set_rot_from_quaternion(mat4.new(), new_quat)
|
local mat2 = mat4.set_rot_from_quaternion(mat4.new(), new_quat)
|
||||||
--local new_quat = mtul.quat.from_euler_
|
--local new_quat = leef.quat.from_euler_
|
||||||
print(mat1)
|
print(mat1)
|
||||||
print(mat2)
|
print(mat2)
|
||||||
print(check_matrix_equality(mat1,mat2))]]
|
print(check_matrix_equality(mat1,mat2))]]
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
local mat4 = mtul.math.mat4
|
local mat4 = leef.math.mat4
|
||||||
local quat = mtul.math.quat
|
local quat = leef.math.quat
|
||||||
local vec3 = mtul.math.vec3
|
local vec3 = leef.math.vec3
|
||||||
local function check_matrix_equality(m1,m2)
|
local function check_matrix_equality(m1,m2)
|
||||||
for i = 1,16 do
|
for i = 1,16 do
|
||||||
if math.abs(m1[i]-m2[i]) > 0.001 then
|
if math.abs(m1[i]-m2[i]) > 0.001 then
|
||||||
@ -15,7 +15,7 @@ end
|
|||||||
print("================== BEGINNING QUATERNION UNIT TESTs =======================")
|
print("================== BEGINNING QUATERNION UNIT TESTs =======================")
|
||||||
|
|
||||||
--print("\n comparing mul_vec3 and rotate_vec3 with random quat on forward facing unit dir")
|
--print("\n comparing mul_vec3 and rotate_vec3 with random quat on forward facing unit dir")
|
||||||
--[[local new_quat = mtul.math.quat.from_angle_axis((math.random()-.5)*math.pi*4, mtul.math.vec3.new(math.random(), math.random(), math.random())):normalize()
|
--[[local new_quat = leef.math.quat.from_angle_axis((math.random()-.5)*math.pi*4, leef.math.vec3.new(math.random(), math.random(), math.random())):normalize()
|
||||||
local forward = vec3.new(0,0,1)
|
local forward = vec3.new(0,0,1)
|
||||||
print(new_quat:mul_vec3(forward))
|
print(new_quat:mul_vec3(forward))
|
||||||
print(new_quat:rotate_vec3(forward))
|
print(new_quat:rotate_vec3(forward))
|
||||||
@ -26,8 +26,8 @@ print(new_quat:rotate_vec3(forward))]]
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
local new_quat = mtul.math.quat.from_angle_axis((math.random()-.5)*math.pi*4, mtul.math.vec3.new(math.random(), math.random(), math.random())):normalize()
|
local new_quat = leef.math.quat.from_angle_axis((math.random()-.5)*math.pi*4, leef.math.vec3.new(math.random(), math.random(), math.random())):normalize()
|
||||||
local to_mat_from_quat = mtul.math.mat4.from_quaternion(new_quat)
|
local to_mat_from_quat = leef.math.mat4.from_quaternion(new_quat)
|
||||||
local to_mat_from_axis_from_quat = mat4.from_angle_axis(new_quat:to_angle_axis())
|
local to_mat_from_axis_from_quat = mat4.from_angle_axis(new_quat:to_angle_axis())
|
||||||
--should tell us that quat to matrix is working fine... trusting the original creators anyway...
|
--should tell us that quat to matrix is working fine... trusting the original creators anyway...
|
||||||
print("\n comparing `quat->matrix` to old `quat->angle_axis->matrix`. Matches:",
|
print("\n comparing `quat->matrix` to old `quat->angle_axis->matrix`. Matches:",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user