Pass BakeOptions to every bake instead of rounding bools
RootBakeOptions moves into the model as BakeOptions, used by frame and track bakes and root transforms.
This commit is contained in:
1 parent
f9dcfb8d79
commit
1fc6b064ae
9 files changed
+44
-43
No files matched your search
+4
-12
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "image.h"
|
||||
#include "model/draw.h"
|
||||
#include "model/frames.h"
|
||||
#include "model/model.h"
|
||||
|
||||
// Document edits as plain functions of the model. Each returns the uids of the elements it created or changed that
|
||||
@@ -25,14 +26,6 @@ struct RowTarget
|
||||
int groupId = -1;
|
||||
};
|
||||
|
||||
struct RootBakeOptions
|
||||
{
|
||||
bool isRoundScale = false;
|
||||
bool isRoundRotation = false;
|
||||
bool isMatchRootInterpolation = false;
|
||||
bool isUseRootPivot = false;
|
||||
};
|
||||
|
||||
struct GridOptions
|
||||
{
|
||||
IVec2 start{};
|
||||
@@ -94,10 +87,9 @@ enum class FrameProperty
|
||||
#define X(property, tracks, ...) property,
|
||||
FRAME_PROPERTIES(X)
|
||||
#undef X
|
||||
COUNT
|
||||
COUNT
|
||||
};
|
||||
|
||||
|
||||
bool is_frame_property_valid(FrameProperty, ItemType);
|
||||
void frame_property_copy(Frame&, const Frame&, FrameProperty);
|
||||
Uids frames_property_set(Model&, const std::set<Reference>&, FrameProperty, const Frame&);
|
||||
@@ -108,14 +100,14 @@ Uids frame_insert(Model&, Reference, int);
|
||||
void frames_delete(Model&, const std::set<Reference>&);
|
||||
Uids frames_duplicate(Model&, const std::set<Reference>&, Reference);
|
||||
void frames_reverse(Model&, const std::set<Reference>&);
|
||||
Uids frames_bake(Model&, const std::set<Reference>&, int, bool, bool);
|
||||
Uids frames_bake(Model&, const std::set<Reference>&, int, BakeOptions);
|
||||
Uids frame_split(Model&, Reference, int);
|
||||
Uids frames_split(Model&, const std::set<Reference>&, int);
|
||||
Uids frames_move(Model&, const std::set<Reference>&, Reference, int);
|
||||
void frame_durations_set(Model&, const std::map<Reference, int>&);
|
||||
void trigger_at_frame_set(Model&, Reference, int);
|
||||
Uids frames_paste(Model&, Reference, const std::set<Reference>&, const std::string&, int, std::string*);
|
||||
Uids root_bake_into(Model&, const std::set<Reference>&, const std::set<Reference>&, RootBakeOptions);
|
||||
Uids root_bake_into(Model&, const std::set<Reference>&, const std::set<Reference>&, BakeOptions);
|
||||
|
||||
void items_remove(Model&, int, const std::map<int, std::set<int>>&, const std::map<int, std::set<int>>&);
|
||||
Uids items_group(Model&, int, int, const std::set<int>&, const std::string&);
|
||||
|
||||
+5
-6
@@ -119,7 +119,7 @@ void frames_reverse(Model& model, const std::set<Reference>& frames)
|
||||
}
|
||||
}
|
||||
|
||||
Uids frames_bake(Model& model, const std::set<Reference>& frames, int interval, bool isRoundScale, bool isRoundRotation)
|
||||
Uids frames_bake(Model& model, const std::set<Reference>& frames, int interval, BakeOptions options)
|
||||
{
|
||||
Uids uids = {};
|
||||
for (auto& [trackReference, indices] : frames_by_track_get(frames))
|
||||
@@ -136,7 +136,7 @@ Uids frames_bake(Model& model, const std::set<Reference>& frames, int interval,
|
||||
continue;
|
||||
auto duration = track->frames[index].duration;
|
||||
auto count = duration <= FRAME_DURATION_MIN ? 1 : (int)std::ceil((float)duration / interval);
|
||||
frame_bake(*track, index, interval, isRoundScale, isRoundRotation);
|
||||
frame_bake(*track, index, interval, options);
|
||||
uids.append_range(frames_uids_get(*track, index, count));
|
||||
inserted += count - 1;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ Uids frames_paste(Model& model, Reference reference, const std::set<Reference>&
|
||||
// Applies the selected root frames' transforms to the target tracks' frames under them, then resets those root
|
||||
// frames to a default frame spanning the same time.
|
||||
Uids root_bake_into(Model& model, const std::set<Reference>& rootFrames, const std::set<Reference>& targets,
|
||||
RootBakeOptions options)
|
||||
BakeOptions options)
|
||||
{
|
||||
auto byTrack = frames_by_track_get(rootFrames);
|
||||
if (byTrack.size() != 1 || targets.empty())
|
||||
@@ -373,14 +373,13 @@ Uids root_bake_into(Model& model, const std::set<Reference>& rootFrames, const s
|
||||
if (options.isMatchRootInterpolation)
|
||||
for (int index = (int)track->frames.size() - 1; index >= 0; --index)
|
||||
if (is_spanned((int)frame_time_from_index_get(*track, index)))
|
||||
frame_bake(*track, index, FRAME_DURATION_MIN, options.isRoundScale, options.isRoundRotation);
|
||||
frame_bake(*track, index, FRAME_DURATION_MIN, options);
|
||||
|
||||
for (int index = 0; index < (int)track->frames.size(); ++index)
|
||||
{
|
||||
auto start = (int)frame_time_from_index_get(*track, index);
|
||||
if (is_spanned(start))
|
||||
frame_root_transform_apply(track->frames[index], frame_generate(root, (float)start),
|
||||
options.isRoundScale, options.isRoundRotation, options.isUseRootPivot);
|
||||
frame_root_transform_apply(track->frames[index], frame_generate(root, (float)start), options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user