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 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 ## 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. Included submodules.

View File

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

View File

@@ -3,23 +3,20 @@ if table.unpack == nil then
table.unpack = unpack table.unpack = unpack
end end
local function deepCopy( orig ) local function copyMatrix( orig )
local copy local copy = RL.MatrixIdentity()
if type( orig ) == "table" then if orig ~= nil then
copy = {} 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
end
for origKey, origValue in next, orig, nil do return copy
-- If object has clone method, use that.
copy[ deepCopy( origKey ) ] = deepCopy( origValue )
end
-- setmetatable( copy, utillib.deepCopy( getmetatable( orig ) ) )
else -- number, string, boolean, etc.
copy = orig
end
return copy
end end
local Matrix = {} local Matrix = {}
@@ -50,17 +47,17 @@ Matrix.meta = {
function Matrix:new( m ) function Matrix:new( m )
local object = setmetatable( {}, Matrix.meta ) local object = setmetatable( {}, Matrix.meta )
object.m = deepCopy( m ) object.m = copyMatrix( m )
return object return object
end end
function Matrix:set( m ) function Matrix:set( m )
self.m = deepCopy( m ) self.m = copyMatrix( m )
end end
function Matrix:clone() function Matrix:clone()
return Matrix:new( self ) return Matrix:new( self.m )
end end
function Matrix:determinant() 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 Load font from file with extended parameters, use NULL for codepoints to load the default character set