Skip to content

Commit

Permalink
fixed dependency miss-match
Browse files Browse the repository at this point in the history
  • Loading branch information
FatalistError committed Jan 6, 2024
1 parent ddf1639 commit 5ef536a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
4 changes: 2 additions & 2 deletions mod.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = mtul_b3d
title = MTUL b3d standalone
description = a b3d reader for minetest, cloned from modlib. Requires MTUL-core, also requires MTUL-math for bone reading implementations.
depends = mtul_core
description = a b3d reader for minetest, cloned from modlib. Requires MTUL-core, also requires MTUL-CPML for nodes module.
depends = mtul_filesystem
optional_depends = mtul_cpml
author = FatalError42O, Appgurue
23 changes: 18 additions & 5 deletions modlib/read_b3d.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,20 @@
--@module b3d_reader

local read_int, read_single = mtul.binary.read_int, mtul.binary.read_single

local function tbl_append(table, other_table)
local length = #table
for index, value in ipairs(other_table) do
table[length + index] = value
end
return table
end
local function tbl_keys(table)
local keys = {}
for key, _ in pairs(table) do
keys[#keys + 1] = key
end
return keys
end
--reads a model directly (based on name). Note that "node_only" abstracts chunks not necessary to finding the position/transform of a bone/node.

--- read b3d models by their name. This simplifies read_from_stream.
Expand Down Expand Up @@ -326,7 +339,7 @@ function mtul.b3d_reader.read_from_stream(stream, ignore_chunks)
end
elseif type == "KEYS" then
if not ignored[type] then
mtul.tbl.append(node.keys, elem)
tbl_append(node.keys, elem)
end
elseif type == "NODE" then
elem.parent = node
Expand Down Expand Up @@ -364,9 +377,9 @@ function mtul.b3d_reader.read_from_stream(stream, ignore_chunks)
local field, type = chunk{TEXS = true, BRUS = true, NODE = true}
if not ignored[type] then
if type == "TEXS" then
mtul.tbl.append(self.textures, field)
tbl_append(self.textures, field)
elseif type == "BRUS" then
mtul.tbl.append(self.brushes, field)
tbl_append(self.brushes, field)
else
self.node = field
end
Expand All @@ -386,7 +399,7 @@ function mtul.b3d_reader.read_from_stream(stream, ignore_chunks)
local parent_left
left, parent_left = new_left, left
if possible_chunks and not possible_chunks[type] then
error("expected one of " .. table.concat(mtul.tbl.keys(possible_chunks), ", ") .. ", found " .. type .. ". This is likely exporter error.")
error("expected one of " .. table.concat(tbl_keys(possible_chunks), ", ") .. ", found " .. type .. ". This is likely exporter error.")
end
local res = assert(chunks[type])()
assert(left == 0)
Expand Down

0 comments on commit 5ef536a

Please sign in to comment.