made read frames offset by -1 to match irrlicht behavior

This commit is contained in:
FatalErr42O 2023-12-21 13:41:33 -08:00
parent 30035ad476
commit ddf16392da
3 changed files with 5 additions and 3 deletions

View File

@ -17,5 +17,6 @@ features:
todo:
* allow use of `get_node_by_name()` without CPML. (move to b3d_reader or set alias?)
* document b3d table contents (I already wrote most of the documentation in modlib's wiki...)
* finish b3d writer (NOTE: must offset "frame" by +1 as the reader is modified to match irrlicht)
Without Appgurue's Modlib this would not be possible, and while I personally have my issues with it, it still provides useful tools, and it's worth looking into for libraries.

View File

@ -275,7 +275,8 @@ function mtul.b3d_reader.read_from_stream(stream, ignore_chunks)
}
while content() do
local frame = {}
frame.frame = int()
--minetest uses a zero indexed frame system, so for consistency, we offset it by 1
frame.frame = int()-1
if position then
frame.position = vector3()
end

View File

@ -56,8 +56,8 @@ function b3d_nodes.get_animated_local_trs(node, target_frame)
local frames = node.keys
local key_index_before = 0 --index of the key before the target_frame.
for i, key in ipairs(frames) do
--pick the closest frame we find that's less then the target
if key.frame < target_frame then
--pick the closest frame we find that's less then the target. Also allow it to pick itself if this is an option.
if (key.frame <= target_frame) then
key_index_before = i
else
break --we've reached the end of our possible frames to use.