onionskin change

This commit is contained in:
2025-11-19 21:43:13 -05:00
parent 631c9c02fa
commit 6c6660d7c4
6 changed files with 93 additions and 29 deletions

View File

@@ -334,4 +334,19 @@ namespace anm2ed::anm2
return time;
}
int Item::frame_index_from_time_get(float time)
{
if (frames.empty()) return -1;
if (time <= 0.0f) return 0;
float duration{};
for (auto [i, frame] : std::views::enumerate(frames))
{
duration += frame.duration;
if (time < duration) return (int)i;
}
return (int)frames.size() - 1;
}
}

View File

@@ -26,6 +26,7 @@ namespace anm2ed::anm2
void frames_generate_from_grid(glm::ivec2, glm::ivec2, glm::ivec2, int, int, int);
void frames_sort_by_at_frame();
int frame_index_from_at_frame_get(int);
int frame_index_from_time_get(float);
float frame_time_from_index_get(int);
};
}
}