Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key frame tile linking is broken in some cases #60

Open
grunt-lucas opened this issue Sep 21, 2024 · 0 comments
Open

Key frame tile linking is broken in some cases #60

grunt-lucas opened this issue Sep 21, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@grunt-lucas
Copy link
Owner

grunt-lucas commented Sep 21, 2024

The key frame tile linking is bugged. See branch bug/anim-tiles for details. Specifically, the problem is in the logic of compiler.cpp assignTilesPrimary (and secondary) function.

The function first runs through all the animated NormalizedTiles. These tiles are tagged with ColorSets that include all the colors across all the animation frames, not just the key frame. Based on those ColorSets, it chooses the first matching palette for the tile, computes the GBATile, and stores that in the usedKeyFrameTiles map.

Later on, when processing the regular NormalizedTiles, it is possible in some cases that a regular tile that visually matches a key frame tile won't link up. Why? Because if the key frame tile does not contain all the colors used across all frames, then the regular-tile version of the key frame tile will have a different ColorSet. (An aside: this is quite a common case. Consider a flower animation where one of the key frame tiles is just a leaf, but in the last frame some of the red flower dips into the tile. The full AnimTile version will contain the red, while the regular-tile version present on the layer sheet will not.) This means that it is possible Porytiles will choose a different palette for the regular-tile version, since there is often more than one palette that can match a tile (color duplication across palettes). It will then compute the GBATile using a different palette. Since that palette will almost certainly have the colors in different positions, the regular-tile version's GBATile won't match the AnimTile GBATile in the usedKeyFrameTiles map. Thus the animation won't be correctly linked.

I will have to think about how to fix this. One idea: change the usedKeyFrameTiles map to store more information so that later on when assigning the non-anim tiles, we can try to detect if a regular-tile version of a key frame is present but with a slightly different ColorSet.

Another solution possibility: let's try to fix this issue and #49 in one fell swoop. The idea: decouple the key frame entirely from the compilation system. Change NormalizedTile to have a special field called keyFrame that is only set for animated tiles. keyFrame could have a new type, i.e. be a regular RGB image. The colors in keyFrame will not be used at all for palette allocation (we could also modify the importer so that we can remove the 16 color limit. That is, when the importer sees a tile that violates the 16 color limit, first check if its a key frame, since we imported those first). When we do the final linking up in assignTiles{Primary,Secondary}, for each tile we first check if it exactly matches one of our key frames. If so, we link up that anim. Otherwise, process as normal.

@grunt-lucas grunt-lucas added the bug Something isn't working label Sep 21, 2024
@grunt-lucas grunt-lucas added this to the 1.0.0 Release milestone Sep 21, 2024
@grunt-lucas grunt-lucas self-assigned this Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant