Initialize with = instead of braces, and drop const from local autos
Scalars get = 0, = false or = nullptr. Standard containers and strings rely on their constructors.
Other types get = {} or = value, and lists keep = {...}.
glm types are left alone until they're replaced.
This commit is contained in:
1 parent
666f65bf3a
commit
40f6b554b5
138 files changed
+1500
-1500
No files matched your search
+29
-29
@@ -8,15 +8,15 @@
|
||||
|
||||
std::set<int> animation_group_ids_get(const Model& model)
|
||||
{
|
||||
std::set<int> ids{};
|
||||
for (const auto& entry : model.animations.entries)
|
||||
std::set<int> ids;
|
||||
for (auto& entry : model.animations.entries)
|
||||
if (auto group = std::get_if<AnimationGroup>(&entry)) ids.insert(group->id);
|
||||
return ids;
|
||||
}
|
||||
|
||||
std::set<int> animation_group_indices_get(const Model& model, int groupId)
|
||||
{
|
||||
std::set<int> indices{};
|
||||
std::set<int> indices;
|
||||
for (int i = 0; i < model.animations_count_get(); ++i)
|
||||
if (model.animation_group_id_get(i) == groupId) indices.insert(i);
|
||||
return indices;
|
||||
@@ -25,14 +25,14 @@
|
||||
// Animations and whole groups taken out of the list, remembering the order they had.
|
||||
struct AnimationsTaken
|
||||
{
|
||||
std::vector<AnimationPointer> animations{};
|
||||
std::vector<AnimationGroup> groups{};
|
||||
std::vector<AnimationPointer> animations;
|
||||
std::vector<AnimationGroup> groups;
|
||||
};
|
||||
|
||||
static AnimationsTaken animations_take(Model& model, const std::set<int>& indices, const std::set<int>& groupIds)
|
||||
{
|
||||
AnimationsTaken taken{};
|
||||
int index{};
|
||||
AnimationsTaken taken = {};
|
||||
int index = 0;
|
||||
std::erase_if(model.animations.entries,
|
||||
[&](AnimationEntry& entry)
|
||||
{
|
||||
@@ -64,9 +64,9 @@
|
||||
// Where an animation with this uid sits: its top-level entry, and its group (or nullptr) and position there.
|
||||
struct AnimationPlace
|
||||
{
|
||||
int entry{-1};
|
||||
AnimationGroup* group{};
|
||||
int position{-1};
|
||||
int entry = -1;
|
||||
AnimationGroup* group = nullptr;
|
||||
int position = -1;
|
||||
};
|
||||
|
||||
static AnimationPlace animation_place_get(Model& model, std::uint64_t uid)
|
||||
@@ -133,18 +133,18 @@
|
||||
// An empty copy of a track list: same tracks and groups, no frames.
|
||||
static std::vector<TrackEntry> track_entries_shell_get(const std::vector<TrackEntry>& entries)
|
||||
{
|
||||
std::vector<TrackEntry> shell{};
|
||||
std::vector<TrackEntry> shell;
|
||||
auto track_shell_get = [](const Track& track)
|
||||
{ return Track{.type = track.type, .id = track.id, .isVisible = track.isVisible}; };
|
||||
for (const auto& entry : entries)
|
||||
for (auto& entry : entries)
|
||||
if (auto track = std::get_if<Track>(&entry))
|
||||
shell.emplace_back(track_shell_get(*track));
|
||||
else
|
||||
{
|
||||
const auto& group = std::get<TrackGroup>(entry);
|
||||
auto& group = std::get<TrackGroup>(entry);
|
||||
TrackGroup copy{
|
||||
.id = group.id, .name = group.name, .isExpanded = group.isExpanded, .isVisible = group.isVisible};
|
||||
for (const auto& groupTrack : group.tracks)
|
||||
for (auto& groupTrack : group.tracks)
|
||||
copy.tracks.push_back(track_shell_get(groupTrack));
|
||||
shell.emplace_back(std::move(copy));
|
||||
}
|
||||
@@ -154,7 +154,7 @@
|
||||
// Adds an animation with the same (empty) tracks as the template animation.
|
||||
Uids animation_add(Model& model, int index, int groupId, int templateIndex, const std::string& name)
|
||||
{
|
||||
Animation animation{.name = name};
|
||||
Animation animation = {.name = name};
|
||||
if (auto source = model.animation_get(templateIndex))
|
||||
{
|
||||
animation.layers = track_entries_shell_get(source->layers);
|
||||
@@ -187,8 +187,8 @@
|
||||
auto taken = animations_take(model, indices, groupIds);
|
||||
if (taken.animations.empty() && taken.groups.empty()) return {};
|
||||
|
||||
Uids uids{};
|
||||
for (const auto& animation : taken.animations)
|
||||
Uids uids = {};
|
||||
for (auto& animation : taken.animations)
|
||||
uids.push_back(animation->uid);
|
||||
|
||||
auto& entries = model.animations.entries;
|
||||
@@ -250,9 +250,9 @@
|
||||
|
||||
auto existingGroupIds = animation_group_ids_get(model);
|
||||
auto nextGroupId = existingGroupIds.empty() ? 0 : *existingGroupIds.rbegin() + 1;
|
||||
Uids uids{};
|
||||
std::vector<AnimationPointer> loose{};
|
||||
std::vector<AnimationEntry> placed{};
|
||||
Uids uids = {};
|
||||
std::vector<AnimationPointer> loose;
|
||||
std::vector<AnimationEntry> placed;
|
||||
for (auto& entry : entries)
|
||||
if (auto animation = std::get_if<AnimationPointer>(&entry))
|
||||
{
|
||||
@@ -265,7 +265,7 @@
|
||||
auto& group = std::get<AnimationGroup>(entry);
|
||||
group.id = nextGroupId++;
|
||||
groupIds.insert(group.id);
|
||||
for (const auto& animation : group.animations)
|
||||
for (auto& animation : group.animations)
|
||||
uids.push_back(animation->uid);
|
||||
placed.push_back(std::move(entry));
|
||||
}
|
||||
@@ -285,8 +285,8 @@
|
||||
|
||||
static void track_merge(Track& destination, const Track& source, Merge type)
|
||||
{
|
||||
std::vector<Frame> frames{};
|
||||
for (const auto& frame : source.frames)
|
||||
std::vector<Frame> frames;
|
||||
for (auto& frame : source.frames)
|
||||
frames.push_back(frame_clone(frame));
|
||||
switch (type)
|
||||
{
|
||||
@@ -310,15 +310,15 @@
|
||||
static void track_entries_merge(std::vector<TrackEntry>& destination, const std::vector<TrackEntry>& source,
|
||||
Merge type)
|
||||
{
|
||||
std::map<int, int> groupRemap{};
|
||||
std::set<int> matchedGroupIds{};
|
||||
int nextGroupId{};
|
||||
std::map<int, int> groupRemap;
|
||||
std::set<int> matchedGroupIds;
|
||||
int nextGroupId = 0;
|
||||
groups_each(destination, [&](const TrackGroup& group) { nextGroupId = std::max(nextGroupId, group.id + 1); });
|
||||
|
||||
groups_each(source,
|
||||
[&](const TrackGroup& sourceGroup)
|
||||
{
|
||||
TrackGroup* matched{};
|
||||
TrackGroup* matched = nullptr;
|
||||
groups_each(destination,
|
||||
[&](TrackGroup& group)
|
||||
{
|
||||
@@ -345,14 +345,14 @@
|
||||
tracks_each(source,
|
||||
[&](const Track& sourceTrack, const TrackGroup* sourceGroup)
|
||||
{
|
||||
TrackGroup* group{};
|
||||
TrackGroup* group = nullptr;
|
||||
if (sourceGroup)
|
||||
groups_each(destination,
|
||||
[&](TrackGroup& candidate)
|
||||
{
|
||||
if (candidate.id == groupRemap[sourceGroup->id]) group = &candidate;
|
||||
});
|
||||
Track* existing{};
|
||||
Track* existing = nullptr;
|
||||
if (group)
|
||||
{
|
||||
for (auto& track : group->tracks)
|
||||
|
||||
+14
-14
@@ -29,7 +29,7 @@
|
||||
{
|
||||
auto animation = model.animation_get(animationIndex);
|
||||
if (!animation) return;
|
||||
std::vector<std::pair<int, int>> tracks{};
|
||||
std::vector<std::pair<int, int>> tracks;
|
||||
tracks_each(animation->layers,
|
||||
[&](const Track& track, const TrackGroup* group)
|
||||
{
|
||||
@@ -48,7 +48,7 @@
|
||||
Uids regions_generate(Model& model, const std::set<int>& animationIndices, const std::set<Reference>& frames,
|
||||
const std::string& format, RegionFrameMapping mapping)
|
||||
{
|
||||
std::unordered_map<int, int> regionNumbers{};
|
||||
std::unordered_map<int, int> regionNumbers;
|
||||
auto frame_apply = [&](Frame& frame, int spritesheetId)
|
||||
{
|
||||
auto& regions = item_get(model.content.spritesheets, spritesheetId)->regions;
|
||||
@@ -86,7 +86,7 @@
|
||||
[&](Frame& frame, int spritesheetId)
|
||||
{
|
||||
if (frame.regionId != -1) return;
|
||||
for (const auto& region : item_get(model.content.spritesheets, spritesheetId)->regions)
|
||||
for (auto& region : item_get(model.content.spritesheets, spritesheetId)->regions)
|
||||
if (is_region_matched(region, frame))
|
||||
{
|
||||
frame.regionId = region.id;
|
||||
@@ -131,8 +131,8 @@
|
||||
{ std::erase_if(items, [&](const auto& item) { return ids.contains(item.id); }); };
|
||||
auto layer_ids_get = [&](auto&& is_removed)
|
||||
{
|
||||
std::set<int> layerIds{};
|
||||
for (const auto& layer : content.layers)
|
||||
std::set<int> layerIds;
|
||||
for (auto& layer : content.layers)
|
||||
if (is_removed(layer)) layerIds.insert(layer.id);
|
||||
return layerIds;
|
||||
};
|
||||
@@ -239,7 +239,7 @@
|
||||
// Appends grid frames to each layer track (optionally making a region per frame) and fits the animation length.
|
||||
Uids animation_grid_generate(Model& model, const std::vector<Reference>& tracks, const GridOptions& options)
|
||||
{
|
||||
Uids uids{};
|
||||
Uids uids = {};
|
||||
for (auto reference : tracks)
|
||||
{
|
||||
if (!model.track_get(reference)) continue;
|
||||
@@ -273,8 +273,8 @@
|
||||
// given animations.
|
||||
Uids frames_change_apply(Model& model, const ChangeTargets& targets, FrameChange change, ChangeType type)
|
||||
{
|
||||
std::map<Reference, std::set<int>> frames{};
|
||||
std::set<Reference> wholeTracks{};
|
||||
std::map<Reference, std::set<int>> frames;
|
||||
std::set<Reference> wholeTracks;
|
||||
for (auto reference : targets.references)
|
||||
{
|
||||
auto index = std::exchange(reference.frameIndex, -1);
|
||||
@@ -288,7 +288,7 @@
|
||||
};
|
||||
auto whole_apply = [&](Track& track)
|
||||
{
|
||||
std::set<int> indices{};
|
||||
std::set<int> indices;
|
||||
for (int i = 0; i < (int)track.frames.size(); ++i)
|
||||
indices.insert(i);
|
||||
frames_change(track, change, track.type, type, indices, is_animation_layer(track));
|
||||
@@ -315,17 +315,17 @@
|
||||
bool file_merge(Model& model, const std::filesystem::path& path, const std::filesystem::path& directory,
|
||||
FileMergePreset preset)
|
||||
{
|
||||
Model source{};
|
||||
Model source = {};
|
||||
if (!model_load(source, path) || !source.isValid) return false;
|
||||
|
||||
auto isAppendAsNew = preset == FILE_MERGE_PRESET_APPEND_AS_NEW;
|
||||
std::map<ElementType, std::unordered_map<int, int>> remaps{};
|
||||
std::map<ElementType, std::unordered_map<int, int>> remaps;
|
||||
auto& content = model.content;
|
||||
|
||||
auto path_remap = [&](const std::filesystem::path& original)
|
||||
{
|
||||
if (directory.empty() || original.empty()) return original;
|
||||
std::error_code ec{};
|
||||
std::error_code ec;
|
||||
auto absolute =
|
||||
original.is_absolute() ? original : std::filesystem::weakly_canonical(path.parent_path() / original, ec);
|
||||
if (ec) absolute = path.parent_path() / original;
|
||||
@@ -429,7 +429,7 @@
|
||||
|
||||
auto entries_remap = [&](std::vector<TrackEntry>& entries, ElementType type)
|
||||
{
|
||||
std::vector<TrackEntry> result{};
|
||||
std::vector<TrackEntry> result;
|
||||
auto track_keep = [&](Track& track)
|
||||
{
|
||||
track.id = id_remap(type, track.id);
|
||||
@@ -469,7 +469,7 @@
|
||||
return -1;
|
||||
};
|
||||
|
||||
std::string defaultAnimationName{};
|
||||
std::string defaultAnimationName;
|
||||
for (auto [index, incoming] : source.animations_get())
|
||||
{
|
||||
auto processed = animation_build(*incoming);
|
||||
|
||||
+22
-22
@@ -19,18 +19,18 @@
|
||||
|
||||
struct RowTarget
|
||||
{
|
||||
bool isGroup{};
|
||||
int type{NONE};
|
||||
int id{-1};
|
||||
int groupId{-1};
|
||||
bool isGroup = false;
|
||||
int type = NONE;
|
||||
int id = -1;
|
||||
int groupId = -1;
|
||||
};
|
||||
|
||||
struct RootBakeOptions
|
||||
{
|
||||
bool isRoundScale{};
|
||||
bool isRoundRotation{};
|
||||
bool isMatchRootInterpolation{};
|
||||
bool isUseRootPivot{};
|
||||
bool isRoundScale = false;
|
||||
bool isRoundRotation = false;
|
||||
bool isMatchRootInterpolation = false;
|
||||
bool isUseRootPivot = false;
|
||||
};
|
||||
|
||||
struct GridOptions
|
||||
@@ -38,28 +38,28 @@
|
||||
glm::ivec2 start{};
|
||||
glm::ivec2 size{};
|
||||
glm::vec2 pivot{};
|
||||
int columns{};
|
||||
int count{};
|
||||
int delay{};
|
||||
bool isMakeRegions{};
|
||||
std::string regionNameFormat{};
|
||||
int columns = 0;
|
||||
int count = 0;
|
||||
int delay = 0;
|
||||
bool isMakeRegions = false;
|
||||
std::string regionNameFormat;
|
||||
};
|
||||
|
||||
struct ChangeTargets
|
||||
{
|
||||
std::set<Reference> references{};
|
||||
std::set<int> animations{};
|
||||
bool isRoot{};
|
||||
bool isLayers{};
|
||||
bool isNulls{};
|
||||
std::set<Reference> references;
|
||||
std::set<int> animations;
|
||||
bool isRoot = false;
|
||||
bool isLayers = false;
|
||||
bool isNulls = false;
|
||||
};
|
||||
|
||||
struct AnimationTarget
|
||||
{
|
||||
int animationIndex{-1};
|
||||
int groupId{-1};
|
||||
bool isAfter{};
|
||||
bool isInto{};
|
||||
int animationIndex = -1;
|
||||
int groupId = -1;
|
||||
bool isAfter = false;
|
||||
bool isInto = false;
|
||||
};
|
||||
|
||||
// Frame properties that can be copied on their own.
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
{ return layer.is_animation() && (layerIds.empty() || layerIds.contains(layer.id)); };
|
||||
if (std::ranges::none_of(content.layers, is_flattened)) return model;
|
||||
|
||||
std::map<std::pair<const Model*, int>, int> spritesheetIds{};
|
||||
std::map<std::pair<const Model*, int>, int> spritesheetIds;
|
||||
auto spritesheet_id_get = [&](const Model* source, int id)
|
||||
{
|
||||
if (source == &model) return id;
|
||||
@@ -62,7 +62,7 @@
|
||||
};
|
||||
|
||||
// (animation layer, source, source layer) -> the plain layer standing in for it.
|
||||
std::map<std::tuple<int, const Model*, int>, int> plainIds{};
|
||||
std::map<std::tuple<int, const Model*, int>, int> plainIds;
|
||||
auto layer_id_get = [&](const Draw& draw)
|
||||
{
|
||||
auto [it, isNew] = plainIds.try_emplace({draw.id, draw.source, draw.sourceId});
|
||||
@@ -84,10 +84,10 @@
|
||||
{
|
||||
auto layer = item_get(content.layers, track.id);
|
||||
if (!layer || !is_flattened(*layer)) return std::vector{track};
|
||||
std::map<int, std::vector<Frame>> frames{};
|
||||
std::vector<int> order{};
|
||||
std::map<int, std::vector<Frame>> frames;
|
||||
std::vector<int> order;
|
||||
for (int time = 0; time < source.frameNum; ++time)
|
||||
for (const auto& draw : animation_draws_get(model, source, {.time = (float)time, .library_get = library_get}))
|
||||
for (auto& draw : animation_draws_get(model, source, {.time = (float)time, .library_get = library_get}))
|
||||
{
|
||||
if (draw.type != DrawType::LAYER || draw.id != track.id || draw.frame.size == glm::vec2()) continue;
|
||||
auto id = layer_id_get(draw);
|
||||
@@ -95,7 +95,7 @@
|
||||
if (isNew) order.push_back(id);
|
||||
it->second[time] = draw_frame_bake(draw);
|
||||
}
|
||||
std::vector<Track> tracks{};
|
||||
std::vector<Track> tracks;
|
||||
for (auto id : order)
|
||||
{
|
||||
auto& baked = tracks.emplace_back(Track{.type = ItemType::LAYER, .id = id, .isVisible = track.isVisible});
|
||||
@@ -108,7 +108,7 @@
|
||||
return tracks;
|
||||
};
|
||||
|
||||
std::vector<TrackEntry> entries{};
|
||||
std::vector<TrackEntry> entries;
|
||||
for (auto& entry : source.layers)
|
||||
if (auto track = std::get_if<Track>(&entry))
|
||||
for (auto& flat : tracks_flatten(*track))
|
||||
@@ -127,8 +127,8 @@
|
||||
auto triggers = source.triggers;
|
||||
for (int time = 0; time < source.frameNum; ++time)
|
||||
{
|
||||
std::vector<int> eventIds{};
|
||||
for (const auto& fire : animation_triggers_get(model, source, time, library_get))
|
||||
std::vector<int> eventIds;
|
||||
for (auto& fire : animation_triggers_get(model, source, time, library_get))
|
||||
{
|
||||
auto layer = item_get(content.layers, fire.layerId);
|
||||
if (!layer || !is_flattened(*layer)) continue;
|
||||
|
||||
+22
-22
@@ -9,7 +9,7 @@
|
||||
|
||||
std::map<Reference, std::set<int>> frames_by_track_get(const std::set<Reference>& frames)
|
||||
{
|
||||
std::map<Reference, std::set<int>> result{};
|
||||
std::map<Reference, std::set<int>> result;
|
||||
for (auto frame : frames)
|
||||
{
|
||||
auto index = std::exchange(frame.frameIndex, -1);
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
static Uids frames_uids_get(const Track& track, int start, int count)
|
||||
{
|
||||
Uids uids{};
|
||||
Uids uids = {};
|
||||
for (int i = std::max(start, 0); i < std::min(start + count, (int)track.frames.size()); ++i)
|
||||
uids.push_back(track.frames[i].uid);
|
||||
return uids;
|
||||
@@ -34,7 +34,7 @@
|
||||
if (track->type == ItemType::TRIGGER)
|
||||
{
|
||||
if (std::ranges::any_of(track->frames, [&](const Frame& trigger) { return trigger.atFrame == time; })) return {};
|
||||
Frame trigger{};
|
||||
Frame trigger = {};
|
||||
trigger.atFrame = time;
|
||||
track->frames.push_back(trigger);
|
||||
frames_sort_by_at_frame(*track);
|
||||
@@ -62,15 +62,15 @@
|
||||
|
||||
Uids frames_duplicate(Model& model, const std::set<Reference>& frames, Reference focus)
|
||||
{
|
||||
Uids uids{};
|
||||
std::uint64_t focusUid{};
|
||||
Uids uids = {};
|
||||
std::uint64_t focusUid = 0;
|
||||
for (auto& [trackReference, indices] : frames_by_track_get(frames))
|
||||
{
|
||||
auto track = model.track_edit(trackReference);
|
||||
if (!track) continue;
|
||||
|
||||
std::vector<Frame> copies{};
|
||||
int lastIndex{-1};
|
||||
std::vector<Frame> copies;
|
||||
int lastIndex = -1;
|
||||
for (auto index : indices)
|
||||
{
|
||||
if (index < 0 || index >= (int)track->frames.size()) continue;
|
||||
@@ -82,7 +82,7 @@
|
||||
}
|
||||
if (copies.empty()) continue;
|
||||
|
||||
for (const auto& copy : copies)
|
||||
for (auto& copy : copies)
|
||||
uids.push_back(copy.uid);
|
||||
track->frames.insert(track->frames.begin() + lastIndex + 1, copies.begin(), copies.end());
|
||||
}
|
||||
@@ -100,7 +100,7 @@
|
||||
auto track = model.track_edit(trackReference);
|
||||
if (!track || indices.size() < 2) continue;
|
||||
|
||||
std::vector<Frame> reversed{};
|
||||
std::vector<Frame> reversed;
|
||||
for (auto it = indices.rbegin(); it != indices.rend(); ++it)
|
||||
if (*it >= 0 && *it < (int)track->frames.size())
|
||||
{
|
||||
@@ -116,13 +116,13 @@
|
||||
Uids frames_bake(Model& model, const std::set<Reference>& frames, int interval, bool isRoundScale,
|
||||
bool isRoundRotation)
|
||||
{
|
||||
Uids uids{};
|
||||
Uids uids = {};
|
||||
for (auto& [trackReference, indices] : frames_by_track_get(frames))
|
||||
{
|
||||
auto track = model.track_edit(trackReference);
|
||||
if (!track) continue;
|
||||
|
||||
int inserted{};
|
||||
int inserted = 0;
|
||||
for (auto originalIndex : indices)
|
||||
{
|
||||
auto index = originalIndex + inserted;
|
||||
@@ -163,7 +163,7 @@
|
||||
// Splits each of the frames that spans the time (last first, so earlier references stay valid).
|
||||
Uids frames_split(Model& model, const std::set<Reference>& references, int time)
|
||||
{
|
||||
Uids uids{};
|
||||
Uids uids = {};
|
||||
for (auto it = references.rbegin(); it != references.rend(); ++it)
|
||||
std::ranges::copy(frame_split(model, *it, time), std::back_inserter(uids));
|
||||
return uids;
|
||||
@@ -178,12 +178,12 @@
|
||||
auto targetUid = targetTrack->uid;
|
||||
insertIndex = std::clamp(insertIndex, 0, (int)targetTrack->frames.size());
|
||||
|
||||
std::vector<Frame> moved{};
|
||||
std::vector<Frame> moved;
|
||||
for (auto& [trackReference, indices] : frames_by_track_get(frames))
|
||||
{
|
||||
auto track = model.track_edit(trackReference);
|
||||
if (!track) continue;
|
||||
std::vector<Frame> trackMoved{};
|
||||
std::vector<Frame> trackMoved;
|
||||
for (auto it = indices.rbegin(); it != indices.rend(); ++it)
|
||||
{
|
||||
if (*it < 0 || *it >= (int)track->frames.size()) continue;
|
||||
@@ -290,7 +290,7 @@
|
||||
Uids frames_property_set(Model& model, const std::set<Reference>& references, FrameProperty property,
|
||||
const Frame& source)
|
||||
{
|
||||
Uids uids{};
|
||||
Uids uids = {};
|
||||
for (auto reference : references)
|
||||
if (is_frame_property_valid(property, (ItemType)reference.itemType))
|
||||
if (auto frame = model.frame_edit(reference))
|
||||
@@ -315,7 +315,7 @@
|
||||
auto trigger = model.frame_edit(reference);
|
||||
if (!trigger) return {};
|
||||
trigger->atFrame = atFrame;
|
||||
for (const auto& other : model.track_get(reference)->frames)
|
||||
for (auto& other : model.track_get(reference)->frames)
|
||||
if (&other != trigger && other.atFrame == trigger->atFrame) trigger->atFrame--;
|
||||
return {};
|
||||
}
|
||||
@@ -351,7 +351,7 @@
|
||||
frame.regionId = -1;
|
||||
|
||||
auto& track = *model.track_edit(reference);
|
||||
Uids uids{};
|
||||
Uids uids = {};
|
||||
if (track.type != ItemType::TRIGGER)
|
||||
{
|
||||
track.frames.insert(track.frames.begin() + insertIndex, frames.begin(), frames.end());
|
||||
@@ -383,7 +383,7 @@
|
||||
if (!rootTrack) return {};
|
||||
auto root = *rootTrack;
|
||||
|
||||
std::vector<std::pair<int, int>> spans{};
|
||||
std::vector<std::pair<int, int>> spans;
|
||||
for (auto index : rootIndices)
|
||||
if (index >= 0 && index < (int)root.frames.size())
|
||||
{
|
||||
@@ -413,13 +413,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
Uids uids{};
|
||||
std::vector<Frame> rewritten{};
|
||||
int defaultDuration{};
|
||||
Uids uids = {};
|
||||
std::vector<Frame> rewritten;
|
||||
int defaultDuration = 0;
|
||||
auto default_push = [&]()
|
||||
{
|
||||
if (defaultDuration <= 0) return;
|
||||
Frame frame{};
|
||||
Frame frame = {};
|
||||
frame.duration = std::max(defaultDuration, FRAME_DURATION_MIN);
|
||||
uids.push_back(frame.uid);
|
||||
rewritten.push_back(frame);
|
||||
|
||||
+5
-5
@@ -36,7 +36,7 @@
|
||||
static void depths_bridge(Model& model)
|
||||
{
|
||||
auto& content = model.content;
|
||||
std::map<std::pair<int, int>, int> copyIds{};
|
||||
std::map<std::pair<int, int>, int> copyIds;
|
||||
auto copy_id_get = [&](int layerId, int depth)
|
||||
{
|
||||
auto [it, isNew] = copyIds.try_emplace({layerId, depth});
|
||||
@@ -57,7 +57,7 @@
|
||||
if (!isUsed) continue;
|
||||
auto& animation = *model.animation_edit(i);
|
||||
|
||||
std::vector<Track> tracks{};
|
||||
std::vector<Track> tracks;
|
||||
for (auto& entry : animation.layers)
|
||||
if (auto track = std::get_if<Track>(&entry))
|
||||
tracks.push_back(std::move(*track));
|
||||
@@ -73,7 +73,7 @@
|
||||
}
|
||||
|
||||
// Each track's place in drawing order: (its position + depth, depth), kept in position order when equal.
|
||||
std::vector<std::pair<std::pair<int, int>, Track>> placed{};
|
||||
std::vector<std::pair<std::pair<int, int>, Track>> placed;
|
||||
auto shown_set = [](Track& track, int depth)
|
||||
{
|
||||
for (auto& frame : track.frames)
|
||||
@@ -85,8 +85,8 @@
|
||||
for (int position = 0; position < (int)tracks.size(); ++position)
|
||||
{
|
||||
auto& track = tracks[position];
|
||||
std::set<int> depths{};
|
||||
for (const auto& frame : track.frames)
|
||||
std::set<int> depths;
|
||||
for (auto& frame : track.frames)
|
||||
if (frame.depth != 0) depths.insert(frame.depth);
|
||||
for (auto depth : depths)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
auto spritesheet = item_get(model.content.spritesheets, spritesheetId);
|
||||
if (!spritesheet || !source.is_valid() || source.pixels.empty()) return false;
|
||||
|
||||
bool isChanged{};
|
||||
bool isChanged = false;
|
||||
for (auto id : ids)
|
||||
{
|
||||
auto region = item_get(spritesheet->regions, id);
|
||||
@@ -63,7 +63,7 @@
|
||||
{
|
||||
struct PackItem
|
||||
{
|
||||
int regionId{-1};
|
||||
int regionId = -1;
|
||||
glm::ivec2 source{};
|
||||
glm::ivec2 size{};
|
||||
};
|
||||
@@ -72,7 +72,7 @@
|
||||
if (!spritesheet || !sheet.is_valid() || sheet.pixels.empty()) return {};
|
||||
|
||||
padding = std::max(0, padding);
|
||||
std::vector<PackItem> items{};
|
||||
std::vector<PackItem> items;
|
||||
for (auto& region : spritesheet->regions)
|
||||
{
|
||||
auto minPoint = glm::ivec2(glm::min(region.crop, region.crop + region.size));
|
||||
@@ -96,7 +96,7 @@
|
||||
std::vector<glm::ivec2> positions{};
|
||||
if (!rects_pack(sizes, packedSize, positions) || packedSize.x <= 0 || packedSize.y <= 0) return {};
|
||||
|
||||
std::vector<ImagePart> parts{};
|
||||
std::vector<ImagePart> parts;
|
||||
for (int i = 0; i < (int)items.size(); ++i)
|
||||
parts.push_back({&sheet, items[i].source, items[i].size, positions[i] + padding});
|
||||
for (auto& region : spritesheet->regions)
|
||||
@@ -119,12 +119,12 @@
|
||||
auto base = item_get(model.content.spritesheets, baseId);
|
||||
auto mergedSize = image_get(baseId)->size;
|
||||
std::vector<ImagePart> parts{{image_get(baseId), {}, mergedSize, {}}};
|
||||
std::unordered_map<int, std::unordered_map<int, int>> regionIdMap{};
|
||||
std::unordered_map<int, std::unordered_map<int, int>> regionIdMap;
|
||||
|
||||
auto location_region_add = [&](int sourceId, glm::ivec2 crop, glm::ivec2 size)
|
||||
{
|
||||
auto source = item_get(model.content.spritesheets, sourceId);
|
||||
Region region{};
|
||||
Region region = {};
|
||||
region.id = item_next_id_get(base->regions);
|
||||
auto stem = path_to_utf8(source->path.stem());
|
||||
region.name = stem.empty() ? std::format("#{}", sourceId) : stem;
|
||||
@@ -158,7 +158,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
std::unordered_map<int, int> layerSpritesheetBefore{};
|
||||
std::unordered_map<int, int> layerSpritesheetBefore;
|
||||
for (auto& layer : model.content.layers)
|
||||
if (ids.contains(layer.spritesheetId))
|
||||
{
|
||||
|
||||
+5
-5
@@ -38,9 +38,9 @@
|
||||
auto entries = track_entries_edit(model, animationIndex, type);
|
||||
if (!entries) return {};
|
||||
|
||||
int nextId{};
|
||||
int nextId = 0;
|
||||
groups_each(*entries, [&](const TrackGroup& group) { nextId = std::max(nextId, group.id + 1); });
|
||||
TrackGroup group{.id = nextId, .name = name};
|
||||
TrackGroup group = {.id = nextId, .name = name};
|
||||
|
||||
auto insertIndex = -1;
|
||||
for (int i = 0; i < (int)entries->size(); ++i)
|
||||
@@ -68,8 +68,8 @@
|
||||
auto entries = track_entries_edit(model, animationIndex, type);
|
||||
if (!entries) return {};
|
||||
|
||||
std::vector<Track> movedTracks{};
|
||||
std::vector<TrackEntry> movedGroups{};
|
||||
std::vector<Track> movedTracks;
|
||||
std::vector<TrackEntry> movedGroups;
|
||||
std::erase_if(*entries,
|
||||
[&](TrackEntry& entry)
|
||||
{
|
||||
@@ -138,7 +138,7 @@
|
||||
movedTracks.clear();
|
||||
}
|
||||
|
||||
std::vector<TrackEntry> topMoved{};
|
||||
std::vector<TrackEntry> topMoved;
|
||||
for (auto& track : movedTracks)
|
||||
topMoved.emplace_back(std::move(track));
|
||||
topMoved.insert(topMoved.end(), std::make_move_iterator(movedGroups.begin()),
|
||||
|
||||
Reference in new issue
Block a user