@@ -1638,6 +1638,7 @@ void TileMapLayer::_scenes_update_cell(CellData &r_cell_data) {
16381638 Transform2D xform;
16391639 xform.set_origin (tile_set->map_to_local (r_cell_data.coords ));
16401640 scene_as_node2d->set_transform (xform * scene_as_node2d->get_transform ());
1641+ _set_scene_transformed_alternative (c.alternative_tile , scene_as_node2d);
16411642 }
16421643#ifdef TOOLS_ENABLED
16431644 RenderingServer *rs = RenderingServer::get_singleton ();
@@ -1705,6 +1706,49 @@ void TileMapLayer::_scenes_draw_cell_debug(const RID &p_canvas_item, const Vecto
17051706}
17061707#endif // DEBUG_ENABLED
17071708
1709+ void TileMapLayer::_set_scene_transformed_alternative (const int p_alternative_id, Node2D *p_scene) {
1710+ // Determine the transformations based on the alternative ID.
1711+ bool transform_flip_h = p_alternative_id & TileSetAtlasSource::TRANSFORM_FLIP_H;
1712+ bool transform_flip_v = p_alternative_id & TileSetAtlasSource::TRANSFORM_FLIP_V;
1713+ bool transform_transpose = p_alternative_id & TileSetAtlasSource::TRANSFORM_TRANSPOSE;
1714+
1715+ double scene_rotation = 0.0 ;
1716+ Vector2 scene_scale = p_scene->get_scale ();
1717+
1718+ // Determine the scene rotation and scale based on the transformation flags.
1719+ if (!transform_flip_h && !transform_flip_v && !transform_transpose) {
1720+ scene_rotation = 0.0 ;
1721+ scene_scale.x = 1 ;
1722+ } else if (transform_flip_h && !transform_flip_v && transform_transpose) {
1723+ scene_rotation = 90.0 ;
1724+ scene_scale.x = 1 ;
1725+ } else if (transform_flip_h && transform_flip_v && !transform_transpose) {
1726+ scene_rotation = 180.0 ;
1727+ scene_scale.x = 1 ;
1728+ } else if (!transform_flip_h && transform_flip_v && transform_transpose) {
1729+ scene_rotation = 270.0 ;
1730+ scene_scale.x = 1 ;
1731+ } else if (transform_flip_h && !transform_flip_v && !transform_transpose) {
1732+ scene_rotation = 0.0 ;
1733+ scene_scale.x = -1 ;
1734+ } else if (transform_flip_h && transform_flip_v && transform_transpose) {
1735+ scene_rotation = 90.0 ;
1736+ scene_scale.x = -1 ;
1737+ } else if (!transform_flip_h && transform_flip_v && !transform_transpose) {
1738+ scene_rotation = 180.0 ;
1739+ scene_scale.x = -1 ;
1740+ } else if (!transform_flip_h && !transform_flip_v && transform_transpose) {
1741+ scene_rotation = 270.0 ;
1742+ scene_scale.x = -1 ;
1743+ }
1744+
1745+ // Apply the transformations to the scene.
1746+ double current_rotation = p_scene->get_rotation_degrees () + scene_rotation;
1747+ Vector2 current_scale = p_scene->get_scale () + scene_scale;
1748+ p_scene->set_rotation_degrees (current_rotation);
1749+ p_scene->set_scale (current_scale);
1750+ }
1751+
17081752// ///////////////////////////////////////////////////////////////////
17091753
17101754void TileMapLayer::_build_runtime_update_tile_data (bool p_force_cleanup) {
0 commit comments