change all frame properties adjustments

This commit is contained in:
2025-12-28 14:29:36 -05:00
parent 8096521f28
commit 233b2139fd
7 changed files with 27 additions and 10 deletions
+2
View File
@@ -71,6 +71,8 @@ namespace anm2ed::anm2
std::optional<float> tintG{};
std::optional<float> tintB{};
std::optional<float> tintA{};
std::optional<bool> isFlipX{};
std::optional<bool> isFlipY{};
};
}
+7 -6
View File
@@ -126,16 +126,14 @@ namespace anm2ed::anm2
return frame;
}
void Item::frames_change(FrameChange change, ChangeType type, int start, int numberFrames)
void Item::frames_change(FrameChange change, ChangeType type, std::set<int>& selection)
{
auto useStart = numberFrames > -1 ? start : 0;
auto end = numberFrames > -1 ? start + numberFrames : (int)frames.size();
end = glm::clamp(end, start, (int)frames.size());
const auto clamp_identity = [](auto value) { return value; };
const auto clamp01 = [](auto value) { return glm::clamp(value, 0.0f, 1.0f); };
const auto clamp_duration = [](int value) { return std::max(FRAME_DURATION_MIN, value); };
if (selection.empty()) return;
auto apply_scalar_with_clamp = [&](auto& target, const auto& optionalValue, auto clampFunc)
{
if (!optionalValue) return;
@@ -165,12 +163,15 @@ namespace anm2ed::anm2
auto apply_scalar = [&](auto& target, const auto& optionalValue)
{ apply_scalar_with_clamp(target, optionalValue, clamp_identity); };
for (int i = useStart; i < end; i++)
for (auto i : selection)
{
if (!vector::in_bounds(frames, i)) continue;
Frame& frame = frames[i];
if (change.isVisible) frame.isVisible = *change.isVisible;
if (change.isInterpolated) frame.isInterpolated = *change.isInterpolated;
if (change.isFlipX) frame.scale.x = -frame.scale.y;
if (change.isFlipY) frame.scale.y = -frame.scale.y;
apply_scalar(frame.rotation, change.rotation);
apply_scalar_with_clamp(frame.duration, change.duration, clamp_duration);
+1 -1
View File
@@ -20,7 +20,7 @@ namespace anm2ed::anm2
std::string to_string(Type, int = -1);
int length(Type);
Frame frame_generate(float, Type);
void frames_change(FrameChange, ChangeType, int, int = 0);
void frames_change(FrameChange, ChangeType, std::set<int>&);
bool frames_deserialize(const std::string&, Type, int, std::set<int>&, std::string*);
void frames_bake(int, int, bool, bool);
void frames_generate_from_grid(glm::ivec2, glm::ivec2, glm::ivec2, int, int, int);