diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c9e35b6 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "Lua.workspace.checkThirdParty": false +} \ No newline at end of file diff --git a/README.md b/README.md index c9dccb2..2e8cd26 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,11 @@ Intended to be used with LuaJIT and LÖVE (this is the backbone of LÖVE3D). Online documentation can be found [here](http://excessive.github.io/cpml/) or you can generate them yourself using `ldoc -c doc/config.ld -o index .` +## Additionally adds to the API +`mat4:translate_local(out, a, t)` +does the same thing as `translate` only its far right column instead of bottom row (as that's what's needed for most local coordinate systems) +also: worth noting that "a" in both `translate` and `translate_local` can be an empty table, and it'll generate an identity matrix. Which is really +redundant code wise, not a fan of that. Probably will fix that at some point. + ### TODO: * Vec3s and Vec2s are not currently adapted for functionality with MT vectors (seperate classes) diff --git a/init.lua b/init.lua index 8063284..d8fc11f 100644 --- a/init.lua +++ b/init.lua @@ -64,19 +64,18 @@ local len = #modules local loaded_modules = {} function require(path) if loaded_modules[path] then return loaded_modules[path] end - print(" TEST \n\n\n") local ending = string.gsub(path:sub(len+1), "%.", "/")..".lua" --[[if ending[1] ~= "/" then ending = "/"..ending end]] path = modules..ending - print(path) loaded_modules[path] = dofile(path) return loaded_modules[path] end for _, file in ipairs(files) do mtul.math[file] = require(modules .. file) end +mtul.loaded_modules.cpml = true modules = nil require = old_require diff --git a/modules/mat4.lua b/modules/mat4.lua index 4018462..dd1b1c6 100644 --- a/modules/mat4.lua +++ b/modules/mat4.lua @@ -458,9 +458,9 @@ end -- @treturn mat4 out function mat4.scale(out, a, s) identity(tmp) - tmp[1] = s.x - tmp[6] = s.y - tmp[11] = s.z + tmp[1] = s.x or s[1] + tmp[6] = s.y or s[2] + tmp[11] = s.z or s[3] return out:mul(tmp, a) end @@ -507,9 +507,9 @@ end -- @treturn mat4 out function mat4.translate(out, a, t) identity(tmp) - tmp[13] = t.x - tmp[14] = t.y - tmp[15] = t.z + tmp[13] = t.x or t[1] + tmp[14] = t.y or t[2] + tmp[15] = t.z or t[3] return out:mul(tmp, a) end