Purge Default Color Values (on by default)

Saves leave out tint channels of 255 and color offsets of 0, which Isaac and
the editor read as those defaults, in both the game's copy and the editor's.
The option sits beside Extended Format in Configure's Serialization row; the
manager takes it with the other settings (chords_set is now settings_apply).
Also drops layer_child_transform_get's unused model parameter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
shweetandClaude Opus 5.5 committed 2026-10-11 18:22:26 -04:00
1 parent 0857e62419
commit bec89bf48f
15 files changed
+65 -30

No files matched your search

+3 -1
View File
@@ -151,7 +151,8 @@ namespace anm2ed
SERIALIZE_NESTED_GROUPS = 1 << 6,
SERIALIZE_EXTENSIONS = 1 << 7,
SERIALIZE_FLATTEN_SPECIAL_INTERPOLATED_FRAMES = 1 << 8,
SERIALIZE_EXTENDED_DOCUMENT = 1 << 9
SERIALIZE_EXTENDED_DOCUMENT = 1 << 9,
SERIALIZE_PURGE_DEFAULT_COLORS = 1 << 10
};
using Flags = int;
@@ -175,6 +176,7 @@ namespace anm2ed
struct Options
{
bool isExtendedFormat{};
bool isPurgeDefaultColors{}; // leave out tints of 255 and color offsets of 0, which readers assume
const model::Model* gameModel{};
};
+2 -2
View File
@@ -148,8 +148,8 @@ namespace anm2ed::model
}
// Where an animation layer track (`layerId`) puts its child at a time, in the animation's space.
std::optional<glm::mat4> layer_child_transform_get(const Model& model, const Animation& animation, int layerId,
float time, bool isRootTransform)
std::optional<glm::mat4> layer_child_transform_get(const Animation& animation, int layerId, float time,
bool isRootTransform)
{
std::optional<glm::mat4> transform{};
tracks_each(animation.layers,
+1 -1
View File
@@ -65,7 +65,7 @@ namespace anm2ed::model
glm::mat4 frame_child_model_get(const Frame&);
std::pair<const Model*, const Animation*> child_get(const Model&, const Layer&, const Frame&, const LibraryGet&);
float child_time_get(const Track&, float, int, int);
std::optional<glm::mat4> layer_child_transform_get(const Model&, const Animation&, int, float, bool);
std::optional<glm::mat4> layer_child_transform_get(const Animation&, int, float, bool);
float draw_scale_get(const Draw&);
std::vector<Draw> animation_draws_get(const Model&, const Animation&, const DrawOptions&);
std::vector<TriggerFire> animation_triggers_get(const Model&, const Animation&, int, const LibraryGet& = {});
+9 -5
View File
@@ -1183,10 +1183,13 @@ namespace anm2ed::model
sink.attribute("SkewX", frame.skew.x);
sink.attribute("SkewY", frame.skew.y);
}
auto isPurged = writer.is(SERIALIZE_PURGE_DEFAULT_COLORS);
for (int i = 0; i < (int)std::size(TINT_ATTRIBUTES); ++i)
sink.attribute(TINT_ATTRIBUTES[i], math::float_to_uint8(frame.tint[i]));
if (auto tint = math::float_to_uint8(frame.tint[i]); !isPurged || tint != math::float_to_uint8(1.0f))
sink.attribute(TINT_ATTRIBUTES[i], tint);
for (int i = 0; i < (int)std::size(OFFSET_ATTRIBUTES); ++i)
sink.attribute(OFFSET_ATTRIBUTES[i], math::float_to_uint8(frame.colorOffset[i]));
if (auto offset = math::float_to_uint8(frame.colorOffset[i]); !isPurged || offset != 0)
sink.attribute(OFFSET_ATTRIBUTES[i], offset);
if (writer.is(SERIALIZE_EXTENSIONS) && math::float_to_uint8(frame.colorOffset.a) != 0)
sink.attribute("AlphaOffset", math::float_to_uint8(frame.colorOffset.a));
sink.attribute("Rotation", frame.rotation);
@@ -1764,10 +1767,11 @@ namespace anm2ed::model
// A save is the game's document with the editor's own copy embedded as SourceDocument (or just the editor's copy).
void document_write(Sink& sink, const Model& model, Options options)
{
Flags purge = options.isPurgeDefaultColors ? SERIALIZE_PURGE_DEFAULT_COLORS : 0;
if (options.isExtendedFormat)
return model_write(sink, model, SERIALIZE_ANM2ED_DEFAULT | SERIALIZE_EXTENDED_DOCUMENT);
model_write(sink, options.gameModel ? *options.gameModel : model, SERIALIZE_ISAAC_DEFAULT,
[&]() { model_write(sink, model, SERIALIZE_ANM2ED_DEFAULT, {}, SOURCE_DOCUMENT_TAG); });
return model_write(sink, model, SERIALIZE_ANM2ED_DEFAULT | SERIALIZE_EXTENDED_DOCUMENT | purge);
model_write(sink, options.gameModel ? *options.gameModel : model, SERIALIZE_ISAAC_DEFAULT | purge,
[&]() { model_write(sink, model, SERIALIZE_ANM2ED_DEFAULT | purge, {}, SOURCE_DOCUMENT_TAG); });
}
// The text of whatever `write` sends to a sink.