Type class updates.
This commit is contained in:
76
API.md
76
API.md
@@ -11273,6 +11273,82 @@ Ease elastic in out
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Bitwise Operations - Arithmetic
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> result = RL.BitAnd( int a, int b )
|
||||||
|
|
||||||
|
Equivalent to a & b in C
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> result = RL.BitOr( int a, int b )
|
||||||
|
|
||||||
|
Equivalent to a | b in C
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> result = RL.BitXor( int a, int b )
|
||||||
|
|
||||||
|
Equivalent to a ^ b in C
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> result = RL.BitNot( int v )
|
||||||
|
|
||||||
|
Equivalent to ~v in C
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> result = RL.BitShiftLeft( int v, int n )
|
||||||
|
|
||||||
|
Equivalent to v << n in C
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> result = RL.BitShiftRight( int v, int n )
|
||||||
|
|
||||||
|
Equivalent to v >> n in C
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> result = RL.BitSet( int v, int i, bool b )
|
||||||
|
|
||||||
|
Set bit in index i to state b in value v
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> bit = RL.BitGet( int v, int i )
|
||||||
|
|
||||||
|
Get bit in index i from value v
|
||||||
|
|
||||||
|
- Success return bool
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
> result = RL.BitToggle( int v, int i )
|
||||||
|
|
||||||
|
Toggle bit in index i in value v
|
||||||
|
|
||||||
|
- Success return int
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## GLFW Core - Input-related functions: keyboard
|
## GLFW Core - Input-related functions: keyboard
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
@@ -8049,6 +8049,71 @@ function RL.EaseElasticOut( t, b, c, d ) end
|
|||||||
---@return any value
|
---@return any value
|
||||||
function RL.EaseElasticInOut( t, b, c, d ) end
|
function RL.EaseElasticInOut( t, b, c, d ) end
|
||||||
|
|
||||||
|
-- Bitwise Operations - Arithmetic
|
||||||
|
|
||||||
|
---Equivalent to a & b in C
|
||||||
|
---- Success return int
|
||||||
|
---@param a integer
|
||||||
|
---@param b integer
|
||||||
|
---@return any result
|
||||||
|
function RL.BitAnd( a, b ) end
|
||||||
|
|
||||||
|
---Equivalent to a | b in C
|
||||||
|
---- Success return int
|
||||||
|
---@param a integer
|
||||||
|
---@param b integer
|
||||||
|
---@return any result
|
||||||
|
function RL.BitOr( a, b ) end
|
||||||
|
|
||||||
|
---Equivalent to a ^ b in C
|
||||||
|
---- Success return int
|
||||||
|
---@param a integer
|
||||||
|
---@param b integer
|
||||||
|
---@return any result
|
||||||
|
function RL.BitXor( a, b ) end
|
||||||
|
|
||||||
|
---Equivalent to ~v in C
|
||||||
|
---- Success return int
|
||||||
|
---@param v integer
|
||||||
|
---@return any result
|
||||||
|
function RL.BitNot( v ) end
|
||||||
|
|
||||||
|
---Equivalent to v << n in C
|
||||||
|
---- Success return int
|
||||||
|
---@param v integer
|
||||||
|
---@param n integer
|
||||||
|
---@return any result
|
||||||
|
function RL.BitShiftLeft( v, n ) end
|
||||||
|
|
||||||
|
---Equivalent to v >> n in C
|
||||||
|
---- Success return int
|
||||||
|
---@param v integer
|
||||||
|
---@param n integer
|
||||||
|
---@return any result
|
||||||
|
function RL.BitShiftRight( v, n ) end
|
||||||
|
|
||||||
|
---Set bit in index i to state b in value v
|
||||||
|
---- Success return int
|
||||||
|
---@param v integer
|
||||||
|
---@param i integer
|
||||||
|
---@param b boolean
|
||||||
|
---@return any result
|
||||||
|
function RL.BitSet( v, i, b ) end
|
||||||
|
|
||||||
|
---Get bit in index i from value v
|
||||||
|
---- Success return bool
|
||||||
|
---@param v integer
|
||||||
|
---@param i integer
|
||||||
|
---@return any bit
|
||||||
|
function RL.BitGet( v, i ) end
|
||||||
|
|
||||||
|
---Toggle bit in index i in value v
|
||||||
|
---- Success return int
|
||||||
|
---@param v integer
|
||||||
|
---@param i integer
|
||||||
|
---@return any result
|
||||||
|
function RL.BitToggle( v, i ) end
|
||||||
|
|
||||||
-- GLFW Core - Input-related functions: keyboard
|
-- GLFW Core - Input-related functions: keyboard
|
||||||
|
|
||||||
---This function returns the name of the specified printable key, encoded as UTF-8.
|
---This function returns the name of the specified printable key, encoded as UTF-8.
|
||||||
|
|||||||
4
devnotes
4
devnotes
@@ -2,6 +2,8 @@ Current {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Backlog {
|
Backlog {
|
||||||
|
* Symbols
|
||||||
|
* Expose symbols on Windows.
|
||||||
* Raygui
|
* Raygui
|
||||||
* ICON_ defines.
|
* ICON_ defines.
|
||||||
* Raygui lib
|
* Raygui lib
|
||||||
@@ -15,7 +17,7 @@ Backlog {
|
|||||||
* Models
|
* Models
|
||||||
* Mesh bone weight management?
|
* Mesh bone weight management?
|
||||||
* CBuffer
|
* CBuffer
|
||||||
* Check endianess.
|
* Swap endianess.
|
||||||
|
|
||||||
* SDL2 platform specific functions.
|
* SDL2 platform specific functions.
|
||||||
* Textures
|
* Textures
|
||||||
|
|||||||
@@ -371,6 +371,7 @@ sourceFiles = {
|
|||||||
"rlgl",
|
"rlgl",
|
||||||
"gl",
|
"gl",
|
||||||
"easings",
|
"easings",
|
||||||
|
"bitwiseOp",
|
||||||
"platforms/core_desktop",
|
"platforms/core_desktop",
|
||||||
-- "platforms/core_desktop_sdl",
|
-- "platforms/core_desktop_sdl",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ if table.unpack == nil then
|
|||||||
table.unpack = unpack
|
table.unpack = unpack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local Vector3 = Vector3 or require( "vector3" )
|
||||||
|
|
||||||
local Color = {}
|
local Color = {}
|
||||||
local metatable = {
|
local metatable = {
|
||||||
__index = Color,
|
__index = Color,
|
||||||
@@ -45,8 +47,8 @@ function Color:new( r, g, b, a )
|
|||||||
local object = setmetatable( {}, metatable )
|
local object = setmetatable( {}, metatable )
|
||||||
|
|
||||||
object.r = r or 255
|
object.r = r or 255
|
||||||
object.g = g or 255
|
object.g = g or object.r
|
||||||
object.b = b or 255
|
object.b = b or object.g
|
||||||
object.a = a or 255
|
object.a = a or 255
|
||||||
|
|
||||||
return object
|
return object
|
||||||
@@ -73,8 +75,8 @@ end
|
|||||||
|
|
||||||
function Color:set( r, g, b, a )
|
function Color:set( r, g, b, a )
|
||||||
self.r = r or 255
|
self.r = r or 255
|
||||||
self.g = g or 255
|
self.g = g or self.r
|
||||||
self.b = b or 255
|
self.b = b or self.g
|
||||||
self.a = a or 255
|
self.a = a or 255
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -171,6 +173,15 @@ function Color:round()
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Color:mix( c )
|
||||||
|
return Color:temp(
|
||||||
|
( self.r + c.r ) / 2,
|
||||||
|
( self.g + c.g ) / 2,
|
||||||
|
( self.b + c.b ) / 2,
|
||||||
|
( self.a + c.a ) / 2
|
||||||
|
):round()
|
||||||
|
end
|
||||||
|
|
||||||
function Color:invert()
|
function Color:invert()
|
||||||
return Color:new( 255 - self.r, 255 - self.g, 255 - self.b, self.a )
|
return Color:new( 255 - self.r, 255 - self.g, 255 - self.b, self.a )
|
||||||
end
|
end
|
||||||
@@ -191,8 +202,8 @@ function Color:temp( r, g, b, a )
|
|||||||
curTemp = curTemp < TEMP_COUNT and curTemp + 1 or 1
|
curTemp = curTemp < TEMP_COUNT and curTemp + 1 or 1
|
||||||
|
|
||||||
object.r = r or 255
|
object.r = r or 255
|
||||||
object.g = g or 255
|
object.g = g or object.r
|
||||||
object.b = b or 255
|
object.b = b or object.g
|
||||||
object.a = a or 255
|
object.a = a or 255
|
||||||
|
|
||||||
return object
|
return object
|
||||||
|
|||||||
@@ -3,31 +3,15 @@ if table.unpack == nil then
|
|||||||
table.unpack = unpack
|
table.unpack = unpack
|
||||||
end
|
end
|
||||||
|
|
||||||
local function copyMatrix( orig )
|
|
||||||
local copy = RL.MatrixIdentity()
|
|
||||||
|
|
||||||
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
|
|
||||||
end
|
|
||||||
|
|
||||||
return copy
|
|
||||||
end
|
|
||||||
|
|
||||||
local Matrix = {}
|
local Matrix = {}
|
||||||
local metatable = {
|
local metatable = {
|
||||||
__index = Matrix,
|
__index = Matrix,
|
||||||
__tostring = function( m )
|
__tostring = function( m )
|
||||||
return "{\n"
|
return "{\n"
|
||||||
.." {"..m.m[1][1]..", "..m.m[1][2]..", "..m.m[1][3]..", "..m.m[1][4].."},\n"
|
.." {"..m[1][1]..", "..m[1][2]..", "..m[1][3]..", "..m[1][4].."},\n"
|
||||||
.." {"..m.m[2][1]..", "..m.m[2][2]..", "..m.m[2][3]..", "..m.m[2][4].."},\n"
|
.." {"..m[2][1]..", "..m[2][2]..", "..m[2][3]..", "..m[2][4].."},\n"
|
||||||
.." {"..m.m[3][1]..", "..m.m[3][2]..", "..m.m[3][3]..", "..m.m[3][4].."},\n"
|
.." {"..m[3][1]..", "..m[3][2]..", "..m[3][3]..", "..m[3][4].."},\n"
|
||||||
.." {"..m.m[3][1]..", "..m.m[3][2]..", "..m.m[3][3]..", "..m.m[3][4].."},\n"
|
.." {"..m[4][1]..", "..m[4][2]..", "..m[4][3]..", "..m[4][4].."},\n"
|
||||||
.."}"
|
.."}"
|
||||||
end,
|
end,
|
||||||
__add = function( m1, m2 )
|
__add = function( m1, m2 )
|
||||||
@@ -44,22 +28,40 @@ local metatable = {
|
|||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Matrix:copyMatrix( orig )
|
||||||
|
if orig ~= nil then
|
||||||
|
for y = 1, 4 do
|
||||||
|
for x = 1, 4 do
|
||||||
|
if orig[x][y] ~= nil then
|
||||||
|
self[x][y] = orig[x][y]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Matrix:new( m )
|
function Matrix:new( m )
|
||||||
local object = setmetatable( {}, metatable )
|
local object = setmetatable( {}, metatable )
|
||||||
|
|
||||||
object.m = copyMatrix( m )
|
-- Raylib style transposed matrix.
|
||||||
|
for x = 1, 4 do
|
||||||
|
object[x] = {}
|
||||||
|
for y = 1, 4 do
|
||||||
|
table.insert( object[x], m[x][y] )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
function Matrix:set( m )
|
function Matrix:set( m )
|
||||||
self.m = copyMatrix( m )
|
self:copyMatrix( m )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Matrix:serialize()
|
function Matrix:serialize()
|
||||||
local str = { "Matrix:new({" }
|
local str = { "Matrix:new({" }
|
||||||
|
|
||||||
for i, row in ipairs( self.m ) do
|
for i, row in ipairs( self ) do
|
||||||
table.insert( str, "{" )
|
table.insert( str, "{" )
|
||||||
|
|
||||||
for c, v in ipairs( row ) do
|
for c, v in ipairs( row ) do
|
||||||
@@ -79,7 +81,7 @@ function Matrix:serialize()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Matrix:clone()
|
function Matrix:clone()
|
||||||
return Matrix:new( self.m )
|
return Matrix:new( self )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Matrix:determinant()
|
function Matrix:determinant()
|
||||||
@@ -154,4 +156,28 @@ function Matrix:lookAt( eye, target, up )
|
|||||||
return Matrix:new( RL.MatrixLookAt( eye, target, up ) )
|
return Matrix:new( RL.MatrixLookAt( eye, target, up ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Temp pre generated objects to avoid "slow" table generation.
|
||||||
|
|
||||||
|
local TEMP_COUNT = 100
|
||||||
|
local tempPool = {}
|
||||||
|
local curTemp = 1
|
||||||
|
|
||||||
|
for _ = 1, TEMP_COUNT do
|
||||||
|
table.insert( tempPool, Matrix:new( RL.MatrixIdentity() ) )
|
||||||
|
end
|
||||||
|
|
||||||
|
function Matrix:temp( m )
|
||||||
|
local object = tempPool[ curTemp ]
|
||||||
|
|
||||||
|
curTemp = curTemp < TEMP_COUNT and curTemp + 1 or 1
|
||||||
|
|
||||||
|
object:copyMatrix( m )
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
function Matrix:getTempId()
|
||||||
|
return curTemp
|
||||||
|
end
|
||||||
|
|
||||||
return Matrix
|
return Matrix
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ function Quaternion:fromMatrix( mat )
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Quaternion:toMatrix()
|
function Quaternion:toMatrix()
|
||||||
return Matrix:newT( RL.QuaternionToMatrix( self ) )
|
return Matrix:new( RL.QuaternionToMatrix( self ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
function Quaternion:fromAxisAngle( axis, angle )
|
function Quaternion:fromAxisAngle( axis, angle )
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
if table.unpack == nil then
|
if table.unpack == nil then
|
||||||
table.unpack = unpack
|
table.unpack = unpack
|
||||||
end
|
end
|
||||||
|
|
||||||
local Vector2 = Vector2 or require( "vector2" )
|
local Vector2 = Vector2 or require( "vector2" )
|
||||||
|
|
||||||
local Rectangle = {}
|
local Rectangle = {}
|
||||||
@@ -73,6 +72,17 @@ function Rectangle:newR( r )
|
|||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Rectangle:newV( position, size )
|
||||||
|
local object = setmetatable( {}, metatable )
|
||||||
|
|
||||||
|
object.x = position.x
|
||||||
|
object.y = position.y
|
||||||
|
object.width = size.x
|
||||||
|
object.height = size.y
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
function Rectangle:set( x, y, width, height )
|
function Rectangle:set( x, y, width, height )
|
||||||
self.x = x or 0
|
self.x = x or 0
|
||||||
self.y = y or self.x
|
self.y = y or self.x
|
||||||
@@ -91,6 +101,13 @@ function Rectangle:setR( r )
|
|||||||
self.height = r.height
|
self.height = r.height
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Rectangle:setV( position, size )
|
||||||
|
self.x = position.x
|
||||||
|
self.y = position.y
|
||||||
|
self.width = size.x
|
||||||
|
self.height = size.y
|
||||||
|
end
|
||||||
|
|
||||||
function Rectangle:serialize()
|
function Rectangle:serialize()
|
||||||
return "Rectangle:new("..self.x..","..self.y..","..self.width..","..self.height..")"
|
return "Rectangle:new("..self.x..","..self.y..","..self.width..","..self.height..")"
|
||||||
end
|
end
|
||||||
@@ -221,6 +238,20 @@ function Rectangle:tempR( r )
|
|||||||
return object
|
return object
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Rectangle:tempV( position, size )
|
||||||
|
local object = tempPool[ curTemp ]
|
||||||
|
|
||||||
|
curTemp = curTemp < TEMP_COUNT and curTemp + 1 or 1
|
||||||
|
|
||||||
|
object.x = position.x
|
||||||
|
object.y = position.y
|
||||||
|
object.width = size.x
|
||||||
|
object.height = size.y
|
||||||
|
|
||||||
|
return object
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function Rectangle:getTempId()
|
function Rectangle:getTempId()
|
||||||
return curTemp
|
return curTemp
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user