From c8738450c735f4ed42d0eb3459e856388f960bca Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Tue, 28 Feb 2023 00:22:45 +0100 Subject: [PATCH] b3d -> glTF: Fix buffer padding --- b3d.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/b3d.lua b/b3d.lua index 2d7a6ae..ced2a31 100644 --- a/b3d.lua +++ b/b3d.lua @@ -617,6 +617,10 @@ do func -- `function(write_byte) ... return count, min, max end` to be called to write to the buffer view; -- the count of elements written must be returned; min and max may be returned ) + -- Always add padding to obtain a multiple of 4 + -- TODO (?) don't add padding if it isn't required + table.insert(buffer_rope, ("\0"):rep(offset % 4)) + offset = math.ceil(offset / 4) * 4 local bytes_written = 0 local count, min, max = func(function(byte) table.insert(buffer_rope, string_char(byte))