Trouv / bevy_ecs_ldtk

ECS-friendly ldtk plugin for bevy, leveraging bevy_ecs_tilemap
Other
630 stars 74 forks source link

fix: recalculate layer offset to adjust for tileset sizes #254

Closed Trouv closed 8 months ago

Trouv commented 8 months ago

Closes #248

Currently, we adjust the adjust the transform of layer entities to account for the following:

However, for more niche cases of using a layer grid size that differs from the tileset tile size, this isn't sufficient. We also need to adjust the layer's transform to account for the following:

This PR makes these additional adjustments. It also makes some stylistic changes that I hope will make some of the mathematical logic more clear.

The plugin still doesn't handle cases where tile size is not divisible by grid size. LDtk does spit out a warning in these scenarios though, so I think it is more reasonable to leave this unsupported for the time being.