Enhance animation and control tests; improve rendering and shape loading validation

- Added tests for player animations in animation_archive_tests to ensure all animations are loaded correctly.
- Updated entity_dispatch_entry_tests to validate animation direction updates and added tests for sixteen-direction animations.
- Expanded isometric_controls_tests with comprehensive key event handling and action requests for various controller states.
- Improved map_renderer_tests by adding viewport rendering tests to compare unbounded and bounded views.
- Enhanced shape_archive_tests to validate shape frame loading and decoding consistency.
This commit is contained in:
Maddo 2026-10-07 00:18:08 +02:00
commit a76b071049
28 changed files with 1608 additions and 154 deletions

View file

@ -4,6 +4,7 @@
#include "remorse/shape_archive.h"
#include <cassert>
#include <array>
#include <filesystem>
namespace {
@ -100,6 +101,14 @@ int main()
assert(stand.has_value() && stand->frameCount > 0);
assert(walk.has_value() && walk->frameCount == 17);
assert(run.has_value() && run->frameCount == 12);
std::array<std::optional<remorse::AnimationClip>, 0x40> playerAnimations;
for (const remorse::u8 index : remorse::controllerAnimationIndices) {
playerAnimations[index] = remorse::loadAnimationClip(
*animationArchive, 1, index);
}
for (const remorse::u8 animation : remorse::controllerAnimationIndices) {
assert(playerAnimations[animation] && playerAnimations[animation]->frameCount != 0);
}
for (const remorse::AnimationClip* clip : {&*walk, &*run}) {
assert(clip->header[1] == 5);
for (remorse::u8 direction = 0; direction < 16; ++direction) {
@ -148,7 +157,10 @@ int main()
const auto playerFrames = remorse::loadShapeFrames(*shapeArchive, 1);
assert(playerFrames.has_value() && playerFrames->size() >= walk->frameCount);
std::vector<bool> referencedFrames(playerFrames->size(), false);
for (const remorse::AnimationClip* clip : {&*stand, &*walk, &*run}) {
for (const auto& clip : playerAnimations) {
if (!clip) {
continue;
}
for (remorse::u8 direction = 0; direction < 16; ++direction) {
for (remorse::u8 frame = 0; frame < clip->frameCount; ++frame) {
const auto metadata = remorse::getAnimationFrame(*clip, direction, frame);
@ -159,14 +171,13 @@ int main()
}
}
}
bool decodedReferencedFrame = false;
for (std::size_t frame = 0; frame < referencedFrames.size(); ++frame) {
if (referencedFrames[frame]) {
assert(remorse::decodeShapeFrame(*shapeArchive, 1, static_cast<remorse::u32>(frame)).has_value());
decodedReferencedFrame = true;
break;
assert(remorse::decodeShapeFrame((*playerFrames)[frame]).has_value());
}
}
assert(decodedReferencedFrame);
assert(std::any_of(referencedFrames.begin(), referencedFrames.end(), [](bool referenced) {
return referenced;
}));
return 0;
}