mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-25 08:43:44 +01:00
b3d writing: Round Lua doubles to floats
rather than erroring if float (precision) bounds are exceeded
This commit is contained in:
parent
898db2c278
commit
aa327126bf
4
b3d.lua
4
b3d.lua
@ -6,6 +6,8 @@ local read_int, read_single = modlib.binary.read_int, modlib.binary.read_single
|
|||||||
|
|
||||||
local write_int, write_single = modlib.binary.write_int, modlib.binary.write_single
|
local write_int, write_single = modlib.binary.write_int, modlib.binary.write_single
|
||||||
|
|
||||||
|
local fround = modlib.math.fround
|
||||||
|
|
||||||
-- Set environment
|
-- Set environment
|
||||||
local _ENV = {}
|
local _ENV = {}
|
||||||
setfenv(1, _ENV)
|
setfenv(1, _ENV)
|
||||||
@ -346,7 +348,7 @@ local function write_rope(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function float(val)
|
local function float(val)
|
||||||
write_single(byte, val)
|
write_single(byte, fround(val))
|
||||||
end
|
end
|
||||||
|
|
||||||
local function float_array(arr, len)
|
local function float_array(arr, len)
|
||||||
|
Loading…
Reference in New Issue
Block a user