Remove namespaces, and make file-local helpers static
Names that only a namespace told apart get prefixes: TOOL_PAN, FONT_BOLD, ICON_FOLDER, COLOR_WHITE, path_to_utf8 and so on. The OpenGL shader class is ShaderProgram, and its uniform ShaderUniform, beside the document's Shader and Uniform. Free functions a member of the same name would hide are called through :: for now. Two unused shader window helpers are gone.
This commit is contained in:
1 parent
7fb2c607c2
commit
666f65bf3a
174 files changed
+2396
-3154
No files matched your search
+21
-24
@@ -5,16 +5,13 @@
|
||||
#include "edit/edit.h"
|
||||
#include "snapshots.h"
|
||||
|
||||
using namespace anm2ed;
|
||||
using namespace anm2ed::test;
|
||||
|
||||
constexpr int WALK_STEPS = 150;
|
||||
constexpr int WALK_SEED = 1234;
|
||||
constexpr int UNDO_LIMIT = 1000;
|
||||
|
||||
std::vector<Reference> references_all_get(const model::Model& anm2, bool isFrames)
|
||||
static std::vector<Reference> references_all_get(const Model& anm2, bool isFrames)
|
||||
{
|
||||
model::UidIndex index(anm2);
|
||||
UidIndex index(anm2);
|
||||
std::vector<Reference> result{};
|
||||
auto add = [&](std::uint64_t uid)
|
||||
{
|
||||
@@ -23,8 +20,8 @@ std::vector<Reference> references_all_get(const model::Model& anm2, bool isFrame
|
||||
if (isFrames == (reference->frameIndex >= 0)) result.push_back(*reference);
|
||||
};
|
||||
for (auto [i, animation] : anm2.animations_get())
|
||||
model::animation_tracks_each(*animation,
|
||||
[&](const model::Track& track)
|
||||
animation_tracks_each(*animation,
|
||||
[&](const Track& track)
|
||||
{
|
||||
add(track.uid);
|
||||
for (const auto& frame : track.frames)
|
||||
@@ -34,7 +31,7 @@ std::vector<Reference> references_all_get(const model::Model& anm2, bool isFrame
|
||||
}
|
||||
|
||||
// One random edit on randomly chosen live elements; returns false when nothing applicable exists.
|
||||
bool edit_random_apply(model::Model& anm2, std::mt19937& random)
|
||||
static bool edit_random_apply(Model& anm2, std::mt19937& random)
|
||||
{
|
||||
auto frames = references_all_get(anm2, true);
|
||||
auto tracks = references_all_get(anm2, false);
|
||||
@@ -47,31 +44,31 @@ bool edit_random_apply(model::Model& anm2, std::mt19937& random)
|
||||
switch (std::uniform_int_distribution<int>(0, 8)(random))
|
||||
{
|
||||
case 0:
|
||||
edit::frame_insert(anm2, frame, 0);
|
||||
frame_insert(anm2, frame, 0);
|
||||
break;
|
||||
case 1:
|
||||
if (frames.size() > 4) edit::frames_delete(anm2, {frame, other});
|
||||
if (frames.size() > 4) frames_delete(anm2, {frame, other});
|
||||
break;
|
||||
case 2:
|
||||
edit::frames_duplicate(anm2, {frame, other}, frame);
|
||||
frames_duplicate(anm2, {frame, other}, frame);
|
||||
break;
|
||||
case 3:
|
||||
edit::frames_reverse(anm2, {frame, other});
|
||||
frames_reverse(anm2, {frame, other});
|
||||
break;
|
||||
case 4:
|
||||
edit::frames_bake(anm2, {frame}, 1, false, false);
|
||||
frames_bake(anm2, {frame}, 1, false, false);
|
||||
break;
|
||||
case 5:
|
||||
edit::frame_split(anm2, frame, 1);
|
||||
frame_split(anm2, frame, 1);
|
||||
break;
|
||||
case 6:
|
||||
if (frame.itemType != ROOT) edit::frames_move(anm2, {frame}, pick(tracks), 0);
|
||||
if (frame.itemType != ROOT) frames_move(anm2, {frame}, pick(tracks), 0);
|
||||
break;
|
||||
case 7:
|
||||
edit::animation_add(anm2, 0, -1, frame.animationIndex, "Walk");
|
||||
animation_add(anm2, 0, -1, frame.animationIndex, "Walk");
|
||||
break;
|
||||
default:
|
||||
edit::animations_move(anm2, {frame.animationIndex}, {}, {.animationIndex = 0});
|
||||
animations_move(anm2, {frame.animationIndex}, {}, {.animationIndex = 0});
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@@ -88,28 +85,28 @@ TEST_CASE("undo and redo restore every state of a random edit walk")
|
||||
snapshots.current.model = model_load(file_load(CORPUS_DIR / name));
|
||||
std::mt19937 random(WALK_SEED);
|
||||
|
||||
std::vector<std::uint64_t> hashes{model::model_hash(snapshots.current.model)};
|
||||
std::vector<std::uint64_t> hashes{model_hash(snapshots.current.model)};
|
||||
for (int step = 0; step < WALK_STEPS; ++step)
|
||||
{
|
||||
snapshots.push("Edit");
|
||||
if (!edit_random_apply(snapshots.current.model, random)) break;
|
||||
auto count = snapshots.undoStack.size();
|
||||
snapshots.commit();
|
||||
if (snapshots.undoStack.size() != count) hashes.push_back(model::model_hash(snapshots.current.model));
|
||||
if (snapshots.undoStack.size() != count) hashes.push_back(model_hash(snapshots.current.model));
|
||||
}
|
||||
REQUIRE(hashes.size() > 1);
|
||||
|
||||
for (auto it = hashes.rbegin() + 1; it != hashes.rend(); ++it)
|
||||
{
|
||||
REQUIRE(snapshots.undo());
|
||||
CHECK(model::model_hash(snapshots.current.model) == *it);
|
||||
CHECK(model_hash(snapshots.current.model) == *it);
|
||||
}
|
||||
CHECK_FALSE(snapshots.undo());
|
||||
|
||||
for (auto it = hashes.begin() + 1; it != hashes.end(); ++it)
|
||||
{
|
||||
REQUIRE(snapshots.redo());
|
||||
CHECK(model::model_hash(snapshots.current.model) == *it);
|
||||
CHECK(model_hash(snapshots.current.model) == *it);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,15 +120,15 @@ TEST_CASE("selection follows its frame through an edit and its undo")
|
||||
selection_references_set(current.selection, current.model, SelectionKind::FRAMES, {{0, LAYER, 0, 1}});
|
||||
|
||||
snapshots.push("Insert");
|
||||
edit::frame_insert(current.model, {0, LAYER, 0, -1}, 0);
|
||||
frame_insert(current.model, {0, LAYER, 0, -1}, 0);
|
||||
auto& track = *current.model.track_edit(Reference{0, LAYER, 0});
|
||||
std::rotate(track.frames.begin(), track.frames.end() - 1, track.frames.end());
|
||||
snapshots.commit();
|
||||
model::UidIndex index(current.model);
|
||||
UidIndex index(current.model);
|
||||
CHECK(selection_focus_get(current.selection, index) == Reference{0, LAYER, 0, 2});
|
||||
CHECK(selection_references_get(current.selection, index, SelectionKind::FRAMES) ==
|
||||
std::set<Reference>{{0, LAYER, 0, 2}});
|
||||
|
||||
REQUIRE(snapshots.undo());
|
||||
CHECK(selection_focus_get(current.selection, model::UidIndex(current.model)) == Reference{0, LAYER, 0, 1});
|
||||
CHECK(selection_focus_get(current.selection, UidIndex(current.model)) == Reference{0, LAYER, 0, 1});
|
||||
}
|
||||
Reference in new issue
Block a user