Repository: godotengine/godot
File: scene/2d/tile_map_layer.cpp (C++)

Code before:
		scene_scale.x = 1;
	} else if (transform_flip_h && !transform_flip_v && transform_transpose) {
		scene_rotation = 90.0;
		scene_scale.x = 1;
	} else if (transform_flip_h && transform_flip_v && !transform_transpose) {
		scene_rotation = 180.0;
		scene_scale.x = 1;
	} else if (!transform_flip_h && transform_flip_v && transform_transpose) {
		scene_rotation = 270.0;
		scene_scale.x = 1;
	} else if (transform_flip_h && !transform_flip_v && !transform_transpose) {
		scene_rotation = 0.0;
		scene_scale.x = -1;
	} else if (transform_flip_h && transform_flip_v && transform_transpose) {
		scene_rotation = 90.0;
		scene_scale.x = -1;
	} else if (!transform_flip_h && transform_flip_v && !transform_transpose) {
		scene_rotation = 180.0;
		scene_scale.x = -1;
	} else if (!transform_flip_h && !transform_flip_v && transform_transpose) {
		scene_rotation = 270.0;
		scene_scale.x = -1;
	}

	p_scene->set_rotation_degrees(scene_rotation);
	p_scene->set_scale(scene_scale);
}

/////////////////////////////////////////////////////////////////////

void TileMapLayer::_build_runtime_update_tile_data(bool p_force_cleanup) {
	// Check if we should cleanup everything.
	bool forced_cleanup = p_force_cleanup || !enabled || tile_set.is_null() || !is_visible_in_tree();
	if (!forced_cleanup) {
		bool valid_runtime_update = GDVIRTUAL_IS_OVERRIDDEN(_use_tile_data_runtime_update) && GDVIRTUAL_IS_OVERRIDDEN(_tile_data_runtime_update);
		bool valid_runtime_update_for_tilemap = tile_map_node && tile_map_node->GDVIRTUAL_IS_OVERRIDDEN(_use_tile_data_runtime_update) && tile_map_node->GDVIRTUAL_IS_OVERRIDDEN(_tile_data_runtime_update); // For keeping compatibility.
		if (valid_runtime_update || valid_runtime_update_for_tilemap) {
			bool use_tilemap_for_runtime = valid_runtime_update_for_tilemap && !valid_runtime_update;
			if (_runtime_update_tile_data_was_cleaned_up || dirty.flags[DIRTY_FLAGS_TILE_SET]) {
				_runtime_update_needs_all_cells_cleaned_up = true;
				for (KeyValue<Vector2i, CellData> &E : tile_map_layer_data) {
					_build_runtime_update_tile_data_for_cell(E.value, use_tilemap_for_runtime);
				}
			} else if (dirty.flags[DIRTY_FLAGS_LAYER_RUNTIME_UPDATE]) {
				for (KeyValue<Vector2i, CellData> &E : tile_map_layer_data) {
					_build_runtime_update_tile_data_for_cell(E.value, use_tilemap_for_runtime, true);
				}
			} else {
				for (SelfList<CellData> *cell_data_list_element = dirty.cell_list.first(); cell_data_list_element; cell_data_list_element = cell_data_list_element->next()) {
					CellData &cell_data = *cell_data_list_element->self();
					_build_runtime_update_tile_data_for_cell(cell_data, use_tilemap_for_runtime);

Review comment (suggestion):
You should add the rotation to the current one, and multiply the scale by the current one, instead of erasing it. Otherwise this means the original scale/rotation will not be applied even if there are no transform (which is compat-breaking).

Code after:
	if (!transform_flip_h && !transform_flip_v && !transform_transpose) {
		scene_rotation = 0.0;
		scene_scale.x = 1;
	} else if (transform_flip_h && !transform_flip_v && transform_transpose) {
		scene_rotation = 90.0;
		scene_scale.x = 1;
	} else if (transform_flip_h && transform_flip_v && !transform_transpose) {
		scene_rotation = 180.0;
		scene_scale.x = 1;
	} else if (!transform_flip_h && transform_flip_v && transform_transpose) {
		scene_rotation = 270.0;
		scene_scale.x = 1;
	} else if (transform_flip_h && !transform_flip_v && !transform_transpose) {
		scene_rotation = 0.0;
		scene_scale.x = -1;
	} else if (transform_flip_h && transform_flip_v && transform_transpose) {
		scene_rotation = 90.0;
		scene_scale.x = -1;
	} else if (!transform_flip_h && transform_flip_v && !transform_transpose) {
		scene_rotation = 180.0;
		scene_scale.x = -1;
	} else if (!transform_flip_h && !transform_flip_v && transform_transpose) {
		scene_rotation = 270.0;
		scene_scale.x = -1;
	}

	// Apply the transformations to the scene.
	double current_rotation = p_scene->get_rotation_degrees() + scene_rotation;
	Vector2 current_scale = p_scene->get_scale() + scene_scale;
	p_scene->set_rotation_degrees(current_rotation);
	p_scene->set_scale(current_scale);
}

/////////////////////////////////////////////////////////////////////

void TileMapLayer::_build_runtime_update_tile_data(bool p_force_cleanup) {
	// Check if we should cleanup everything.
	bool forced_cleanup = p_force_cleanup || !enabled || tile_set.is_null() || !is_visible_in_tree();
	if (!forced_cleanup) {
		bool valid_runtime_update = GDVIRTUAL_IS_OVERRIDDEN(_use_tile_data_runtime_update) && GDVIRTUAL_IS_OVERRIDDEN(_tile_data_runtime_update);
		bool valid_runtime_update_for_tilemap = tile_map_node && tile_map_node->GDVIRTUAL_IS_OVERRIDDEN(_use_tile_data_runtime_update) && tile_map_node->GDVIRTUAL_IS_OVERRIDDEN(_tile_data_runtime_update); // For keeping compatibility.
		if (valid_runtime_update || valid_runtime_update_for_tilemap) {
			bool use_tilemap_for_runtime = valid_runtime_update_for_tilemap && !valid_runtime_update;
			if (_runtime_update_tile_data_was_cleaned_up || dirty.flags[DIRTY_FLAGS_TILE_SET]) {
				_runtime_update_needs_all_cells_cleaned_up = true;
				for (KeyValue<Vector2i, CellData> &E : tile_map_layer_data) {
					_build_runtime_update_tile_data_for_cell(E.value, use_tilemap_for_runtime);
				}
			} else if (dirty.flags[DIRTY_FLAGS_LAYER_RUNTIME_UPDATE]) {
				for (KeyValue<Vector2i, CellData> &E : tile_map_layer_data) {
					_build_runtime_update_tile_data_for_cell(E.value, use_tilemap_for_runtime, true);