Add Vector3
support for Luau i64
This commit is contained in:
parent
04d1840d2d
commit
5c2209fcf0
@ -28,7 +28,30 @@ local from_u32, into_u32, from_u64, into_u64
|
|||||||
local num_add, num_subtract, num_multiply, num_divide_unsigned, num_negate, num_not
|
local num_add, num_subtract, num_multiply, num_divide_unsigned, num_negate, num_not
|
||||||
local num_is_negative, num_is_zero, num_is_equal, num_is_less_unsigned, num_is_greater_unsigned
|
local num_is_negative, num_is_zero, num_is_equal, num_is_less_unsigned, num_is_greater_unsigned
|
||||||
|
|
||||||
-- TODO: Eventually support Vector3
|
if Vector3 then
|
||||||
|
local bit_extract = bit32.extract
|
||||||
|
local constructor = Vector3.new
|
||||||
|
|
||||||
|
-- X: a[0 ..21]
|
||||||
|
-- Y: a[22..31]
|
||||||
|
-- | b[0 ..11]
|
||||||
|
-- Z: b[12..31]
|
||||||
|
|
||||||
|
function Numeric.from_u32(data_1, data_2)
|
||||||
|
local x = bit_and(data_1, 0x3FFFFF)
|
||||||
|
local y = bit_or(bit_and(data_1, 0xFFC00000), bit_and(data_2, 0xFFF))
|
||||||
|
local z = bit_extract(data_2, 12, 20)
|
||||||
|
|
||||||
|
return constructor(x, y, z)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Numeric.into_u32(data)
|
||||||
|
local data_1 = bit_or(bit_and(data.X, 0x3FFFFF), bit_and(data.Y, 0xFFC00000))
|
||||||
|
local data_2 = bit_replace(bit_and(data.Y, 0xFFF), bit_and(data.Z, 0xFFFFF), 12, 20)
|
||||||
|
|
||||||
|
return data_1, data_2
|
||||||
|
end
|
||||||
|
else
|
||||||
function Numeric.from_u32(data_1, data_2)
|
function Numeric.from_u32(data_1, data_2)
|
||||||
return table_freeze({ data_1, data_2 })
|
return table_freeze({ data_1, data_2 })
|
||||||
end
|
end
|
||||||
@ -36,6 +59,7 @@ end
|
|||||||
function Numeric.into_u32(data)
|
function Numeric.into_u32(data)
|
||||||
return data[1], data[2]
|
return data[1], data[2]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Numeric.from_u64(value)
|
function Numeric.from_u64(value)
|
||||||
return from_u32(bit_and(value), math_floor(value / BIT_SET_32))
|
return from_u32(bit_and(value), math_floor(value / BIT_SET_32))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user