@@ -1571,6 +1571,7 @@ void TileMapLayer::_scenes_update_cell(CellData &r_cell_data) {
15711571 Transform2D xform;
15721572 xform.set_origin (tile_set->map_to_local (r_cell_data.coords ));
15731573 scene_as_node2d->set_transform (xform * scene_as_node2d->get_transform ());
1574+ _set_scene_transformed_alternative (c.alternative_tile , scene_as_node2d);
15741575 }
15751576 if (tile_map_node) {
15761577 // Compatibility with TileMap.
@@ -1631,6 +1632,49 @@ void TileMapLayer::_scenes_draw_cell_debug(const RID &p_canvas_item, const Vecto
16311632}
16321633#endif // DEBUG_ENABLED
16331634
1635+ void TileMapLayer::_set_scene_transformed_alternative (const int p_alternative_id, Node2D *p_scene) {
1636+ // Determine the transformations based on the alternative ID.
1637+ bool transform_flip_h = p_alternative_id & TileSetAtlasSource::TRANSFORM_FLIP_H;
1638+ bool transform_flip_v = p_alternative_id & TileSetAtlasSource::TRANSFORM_FLIP_V;
1639+ bool transform_transpose = p_alternative_id & TileSetAtlasSource::TRANSFORM_TRANSPOSE;
1640+
1641+ double scene_rotation = 0.0 ;
1642+ Vector2 scene_scale = p_scene->get_scale ();
1643+
1644+ // Determine the scene rotation and scale based on the transformation flags.
1645+ if (!transform_flip_h && !transform_flip_v && !transform_transpose) {
1646+ scene_rotation = 0.0 ;
1647+ scene_scale.x = 1 ;
1648+ } else if (transform_flip_h && !transform_flip_v && transform_transpose) {
1649+ scene_rotation = 90.0 ;
1650+ scene_scale.x = 1 ;
1651+ } else if (transform_flip_h && transform_flip_v && !transform_transpose) {
1652+ scene_rotation = 180.0 ;
1653+ scene_scale.x = 1 ;
1654+ } else if (!transform_flip_h && transform_flip_v && transform_transpose) {
1655+ scene_rotation = 270.0 ;
1656+ scene_scale.x = 1 ;
1657+ } else if (transform_flip_h && !transform_flip_v && !transform_transpose) {
1658+ scene_rotation = 0.0 ;
1659+ scene_scale.x = -1 ;
1660+ } else if (transform_flip_h && transform_flip_v && transform_transpose) {
1661+ scene_rotation = 90.0 ;
1662+ scene_scale.x = -1 ;
1663+ } else if (!transform_flip_h && transform_flip_v && !transform_transpose) {
1664+ scene_rotation = 180.0 ;
1665+ scene_scale.x = -1 ;
1666+ } else if (!transform_flip_h && !transform_flip_v && transform_transpose) {
1667+ scene_rotation = 270.0 ;
1668+ scene_scale.x = -1 ;
1669+ }
1670+
1671+ // Apply the transformations to the scene.
1672+ double current_rotation = p_scene->get_rotation_degrees () + scene_rotation;
1673+ Vector2 current_scale = p_scene->get_scale () + scene_scale;
1674+ p_scene->set_rotation_degrees (current_rotation);
1675+ p_scene->set_scale (current_scale);
1676+ }
1677+
16341678// ///////////////////////////////////////////////////////////////////
16351679
16361680void TileMapLayer::_build_runtime_update_tile_data (bool p_force_cleanup) {
0 commit comments