Stage 7b: model/xml.cpp reads and writes tinyxml2 directly; Element tree removed
- Reading goes from tinyxml2 straight into the typed model, including legacy layouts (flat GroupId groups, *AnimationGroups with Index, FrameRestore backups, baked frames, SoundId, Overlay) and load-time id/region repair. - Writing builds an XmlNode tree from the typed model for a set of flags: id renumbering, region sync, group-root and interpolation baking happen on typed data; groups are nested or extracted the way the old pipeline did. - Unknown XML is kept verbatim (XmlNode) instead of being re-emitted through the Element writer. - model_hash is an FNV hash of the editor-format node tree (what a save would write); the per-fixture hash goldens are gone. - Deletes src/anm2 (Element, normalize, groups, hash, xml) and the unused util/xml attribute helpers and ElementType/ItemType table columns. - All goldens, invariants and the local corpus are byte-identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0b6f67d9bd
commit
e50d76c784
33 files changed
+1386
-2935
No files matched your search
+43
-72
@@ -12,55 +12,49 @@
|
||||
#include "types.hpp"
|
||||
|
||||
#define ANM2_ELEMENT_TYPES \
|
||||
X(UNKNOWN, "", UNKNOWN) \
|
||||
X(ANIMATED_ACTOR, "AnimatedActor", UNKNOWN) \
|
||||
X(INFO, "Info", UNKNOWN) \
|
||||
X(CONTENT, "Content", UNKNOWN) \
|
||||
X(SPRITESHEETS, "Spritesheets", UNKNOWN) \
|
||||
X(SPRITESHEET, "Spritesheet", SPRITESHEETS) \
|
||||
X(SHADERS, "Shaders", UNKNOWN) \
|
||||
X(SHADER, "Shader", SHADERS) \
|
||||
X(UNIFORM, "Uniform", UNKNOWN) \
|
||||
X(COMPONENT, "Component", UNKNOWN) \
|
||||
X(REGION, "Region", UNKNOWN) \
|
||||
X(LAYERS, "Layers", UNKNOWN) \
|
||||
X(LAYER_ELEMENT, "Layer", LAYERS) \
|
||||
X(NULLS, "Nulls", UNKNOWN) \
|
||||
X(NULL_ELEMENT, "Null", NULLS) \
|
||||
X(EVENTS, "Events", UNKNOWN) \
|
||||
X(EVENT_ELEMENT, "Event", EVENTS) \
|
||||
X(SOUNDS, "Sounds", UNKNOWN) \
|
||||
X(SOUND_ELEMENT, "Sound", SOUNDS) \
|
||||
X(ANIMATIONS, "Animations", UNKNOWN) \
|
||||
X(ANIMATION, "Animation", ANIMATIONS) \
|
||||
X(ROOT_ANIMATION, "RootAnimation", UNKNOWN) \
|
||||
X(LAYER_ANIMATIONS, "LayerAnimations", UNKNOWN) \
|
||||
X(LAYER_ANIMATION_GROUPS, "LayerAnimationGroups", UNKNOWN) \
|
||||
X(LAYER_ANIMATION, "LayerAnimation", UNKNOWN) \
|
||||
X(NULL_ANIMATIONS, "NullAnimations", UNKNOWN) \
|
||||
X(NULL_ANIMATION_GROUPS, "NullAnimationGroups", UNKNOWN) \
|
||||
X(NULL_ANIMATION, "NullAnimation", UNKNOWN) \
|
||||
X(GROUP, "Group", UNKNOWN) \
|
||||
X(TRIGGERS, "Triggers", UNKNOWN) \
|
||||
X(FRAME, "Frame", UNKNOWN) \
|
||||
X(TRIGGER, "Trigger", UNKNOWN)
|
||||
X(UNKNOWN, "") \
|
||||
X(ANIMATED_ACTOR, "AnimatedActor") \
|
||||
X(INFO, "Info") \
|
||||
X(CONTENT, "Content") \
|
||||
X(SPRITESHEETS, "Spritesheets") \
|
||||
X(SPRITESHEET, "Spritesheet") \
|
||||
X(SHADERS, "Shaders") \
|
||||
X(SHADER, "Shader") \
|
||||
X(UNIFORM, "Uniform") \
|
||||
X(COMPONENT, "Component") \
|
||||
X(REGION, "Region") \
|
||||
X(LAYERS, "Layers") \
|
||||
X(LAYER_ELEMENT, "Layer") \
|
||||
X(NULLS, "Nulls") \
|
||||
X(NULL_ELEMENT, "Null") \
|
||||
X(EVENTS, "Events") \
|
||||
X(EVENT_ELEMENT, "Event") \
|
||||
X(SOUNDS, "Sounds") \
|
||||
X(SOUND_ELEMENT, "Sound") \
|
||||
X(ANIMATIONS, "Animations") \
|
||||
X(ANIMATION, "Animation") \
|
||||
X(ROOT_ANIMATION, "RootAnimation") \
|
||||
X(LAYER_ANIMATIONS, "LayerAnimations") \
|
||||
X(LAYER_ANIMATION_GROUPS, "LayerAnimationGroups") \
|
||||
X(LAYER_ANIMATION, "LayerAnimation") \
|
||||
X(NULL_ANIMATIONS, "NullAnimations") \
|
||||
X(NULL_ANIMATION_GROUPS, "NullAnimationGroups") \
|
||||
X(NULL_ANIMATION, "NullAnimation") \
|
||||
X(GROUP, "Group") \
|
||||
X(TRIGGERS, "Triggers") \
|
||||
X(FRAME, "Frame") \
|
||||
X(TRIGGER, "Trigger")
|
||||
|
||||
namespace anm2ed
|
||||
{
|
||||
enum class ElementType
|
||||
{
|
||||
#define X(symbol, tag, container) symbol,
|
||||
#define X(symbol, tag) symbol,
|
||||
ANM2_ELEMENT_TYPES
|
||||
#undef X
|
||||
COUNT
|
||||
};
|
||||
|
||||
inline constexpr ElementType ELEMENT_CONTAINERS[] = {
|
||||
#define X(symbol, tag, container) ElementType::container,
|
||||
ANM2_ELEMENT_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
enum class Interpolation
|
||||
{
|
||||
NONE,
|
||||
@@ -129,60 +123,38 @@ namespace anm2ed
|
||||
inline const glm::vec4 TRIGGER_COLOR_HOVERED = glm::vec4(0.950f, 0.330f, 0.490f, 1.000f);
|
||||
|
||||
#define ANM2_ITEM_TYPES \
|
||||
X(NONE, STRING_UNDEFINED, "", resource::icon::NONE, glm::vec4(), glm::vec4(), glm::vec4(), UNKNOWN, UNKNOWN) \
|
||||
X(ROOT, BASIC_ROOT, "RootAnimation", resource::icon::ROOT, ROOT_COLOR, ROOT_COLOR_ACTIVE, ROOT_COLOR_HOVERED, \
|
||||
ROOT_ANIMATION, UNKNOWN) \
|
||||
X(LAYER, BASIC_LAYER_ANIMATION, "LayerAnimation", resource::icon::LAYER, LAYER_COLOR, LAYER_COLOR_ACTIVE, \
|
||||
LAYER_COLOR_HOVERED, LAYER_ANIMATION, LAYER_ANIMATIONS) \
|
||||
X(NULL_, BASIC_NULL_ANIMATION, "NullAnimation", resource::icon::NULL_, NULL_COLOR, NULL_COLOR_ACTIVE, \
|
||||
NULL_COLOR_HOVERED, NULL_ANIMATION, NULL_ANIMATIONS) \
|
||||
X(TRIGGER, BASIC_TRIGGERS, "Triggers", resource::icon::TRIGGERS, TRIGGER_COLOR, TRIGGER_COLOR_ACTIVE, \
|
||||
TRIGGER_COLOR_HOVERED, TRIGGERS, UNKNOWN)
|
||||
X(NONE, STRING_UNDEFINED, resource::icon::NONE, glm::vec4(), glm::vec4(), glm::vec4()) \
|
||||
X(ROOT, BASIC_ROOT, resource::icon::ROOT, ROOT_COLOR, ROOT_COLOR_ACTIVE, ROOT_COLOR_HOVERED) \
|
||||
X(LAYER, BASIC_LAYER_ANIMATION, resource::icon::LAYER, LAYER_COLOR, LAYER_COLOR_ACTIVE, LAYER_COLOR_HOVERED) \
|
||||
X(NULL_, BASIC_NULL_ANIMATION, resource::icon::NULL_, NULL_COLOR, NULL_COLOR_ACTIVE, NULL_COLOR_HOVERED) \
|
||||
X(TRIGGER, BASIC_TRIGGERS, resource::icon::TRIGGERS, TRIGGER_COLOR, TRIGGER_COLOR_ACTIVE, TRIGGER_COLOR_HOVERED)
|
||||
|
||||
constexpr StringType TYPE_STRINGS[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered, track, container) string,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr const char* TYPE_ITEM_STRINGS[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered, track, container) itemString,
|
||||
#define X(symbol, string, icon, color, colorActive, colorHovered) string,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
constexpr resource::icon::Type TYPE_ICONS[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered, track, container) icon,
|
||||
#define X(symbol, string, icon, color, colorActive, colorHovered) icon,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
inline const glm::vec4 TYPE_COLOR[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered, track, container) color,
|
||||
#define X(symbol, string, icon, color, colorActive, colorHovered) color,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
inline const glm::vec4 TYPE_COLOR_ACTIVE[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered, track, container) colorActive,
|
||||
#define X(symbol, string, icon, color, colorActive, colorHovered) colorActive,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
inline const glm::vec4 TYPE_COLOR_HOVERED[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered, track, container) colorHovered,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
inline constexpr ElementType TYPE_TRACKS[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered, track, container) ElementType::track,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
|
||||
inline constexpr ElementType TYPE_CONTAINERS[] = {
|
||||
#define X(symbol, string, itemString, icon, color, colorActive, colorHovered, track, container) ElementType::container,
|
||||
#define X(symbol, string, icon, color, colorActive, colorHovered) colorHovered,
|
||||
ANM2_ITEM_TYPES
|
||||
#undef X
|
||||
};
|
||||
@@ -236,7 +208,6 @@ namespace anm2ed
|
||||
|
||||
struct Options
|
||||
{
|
||||
Flags flags{SERIALIZE_DEFAULT};
|
||||
bool isExtendedFormat{};
|
||||
};
|
||||
|
||||
|
||||
@@ -44,6 +44,26 @@ namespace anm2ed::model
|
||||
math::percent_to_unit(frame.shear));
|
||||
}
|
||||
|
||||
void frame_root_transform_apply(Frame& frame, const Frame& rootFrame, bool isRoundScale, bool isRoundRotation,
|
||||
bool isUseRootPivot)
|
||||
{
|
||||
auto rootScale = math::percent_to_unit(rootFrame.scale);
|
||||
auto pivot = isUseRootPivot ? rootFrame.position : glm::vec2();
|
||||
auto offset = (frame.position - pivot) * rootScale;
|
||||
auto radians = glm::radians(rootFrame.rotation);
|
||||
auto cos = std::cos(radians);
|
||||
auto sin = std::sin(radians);
|
||||
|
||||
frame.position = rootFrame.position + glm::vec2(offset.x * cos - offset.y * sin, offset.x * sin + offset.y * cos);
|
||||
frame.scale *= rootScale;
|
||||
frame.rotation += rootFrame.rotation;
|
||||
frame.tint *= rootFrame.tint;
|
||||
frame.colorOffset += rootFrame.colorOffset;
|
||||
|
||||
if (isRoundScale) frame.scale = glm::round(frame.scale);
|
||||
if (isRoundRotation) frame.rotation = std::round(frame.rotation);
|
||||
}
|
||||
|
||||
// The track's state at a time: the frame playing then, mixed toward the next one when interpolated. A trigger is
|
||||
// returned only on its exact frame; otherwise the result is invisible.
|
||||
Frame frame_generate(const Track& track, float time)
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace anm2ed::model
|
||||
void frame_mix(Frame&, const Frame&, float);
|
||||
std::vector<Frame> frame_bake_split(const Frame&, const Frame&, int, bool, bool);
|
||||
glm::mat4 frame_parent_model_get(const Frame&);
|
||||
void frame_root_transform_apply(Frame&, const Frame&, bool, bool, bool);
|
||||
Frame frame_generate(const Track&, float);
|
||||
int frame_index_from_at_frame_get(const Track&, int);
|
||||
int frame_index_from_time_get(const Track&, float);
|
||||
|
||||
+1319
-659
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -15,7 +15,7 @@ namespace anm2ed::model
|
||||
bool model_save(const Model&, const std::filesystem::path&, std::string* = nullptr, Options = {});
|
||||
std::string model_to_string(const Model&, Options = {});
|
||||
std::string model_serialize(const Model&, Flags);
|
||||
std::uint64_t model_hash(const Model&, Options = {});
|
||||
std::uint64_t model_hash(const Model&);
|
||||
bool is_special_interpolated_frames(const Model&);
|
||||
|
||||
std::string frame_to_string(const Frame&, ItemType);
|
||||
|
||||
Reference in new issue
Block a user