Matrix lib clone fix.

This commit is contained in:
jussi
2024-05-09 22:05:24 +03:00
parent 02e1984781
commit 1980aebdc3
5 changed files with 19 additions and 22 deletions

2
API.md
View File

@@ -6739,7 +6739,7 @@ Load font from file into GPU memory (VRAM)
---
> font = RL.LoadFontEx( string fileName, int fontSize, int{} codepoints )
> font = RL.LoadFontEx( string fileName, int fontSize, int{}|nil codepoints )
Load font from file with extended parameters, use NULL for codepoints to load the default character set

View File

@@ -10,7 +10,7 @@ Reilua means fair in finnish.
## Status
ReiLua is WIP and some planned raylib functionality is still missing but it already has over 800 functions and should include all functions to make most 2D and 3D games. Current Raylib version 5.0.
ReiLua is WIP and some planned raylib functionality is still missing but it already has over 900. Current Raylib version 5.0.
Included submodules.

View File

@@ -3919,7 +3919,7 @@ function RL.LoadFont( fileName ) end
---- Success return Font
---@param fileName string
---@param fontSize integer
---@param codepoints table
---@param codepoints table|nil
---@return any font
function RL.LoadFontEx( fileName, fontSize, codepoints ) end

View File

@@ -3,20 +3,17 @@ if table.unpack == nil then
table.unpack = unpack
end
local function deepCopy( orig )
local copy
local function copyMatrix( orig )
local copy = RL.MatrixIdentity()
if type( orig ) == "table" then
copy = {}
for origKey, origValue in next, orig, nil do
-- If object has clone method, use that.
copy[ deepCopy( origKey ) ] = deepCopy( origValue )
if orig ~= nil then
for y = 1, 4 do
for x = 1, 4 do
if orig[x][y] ~= nil then
copy[x][y] = orig[x][y]
end
end
end
-- setmetatable( copy, utillib.deepCopy( getmetatable( orig ) ) )
else -- number, string, boolean, etc.
copy = orig
end
return copy
@@ -50,17 +47,17 @@ Matrix.meta = {
function Matrix:new( m )
local object = setmetatable( {}, Matrix.meta )
object.m = deepCopy( m )
object.m = copyMatrix( m )
return object
end
function Matrix:set( m )
self.m = deepCopy( m )
self.m = copyMatrix( m )
end
function Matrix:clone()
return Matrix:new( self )
return Matrix:new( self.m )
end
function Matrix:determinant()

View File

@@ -211,7 +211,7 @@ int ltextLoadFont( lua_State* L ) {
}
/*
> font = RL.LoadFontEx( string fileName, int fontSize, int{} codepoints )
> font = RL.LoadFontEx( string fileName, int fontSize, int{}|nil codepoints )
Load font from file with extended parameters, use NULL for codepoints to load the default character set