Skip to content

Commit

Permalink
Allow colormap and control map to be upgraded independently
Browse files Browse the repository at this point in the history
  • Loading branch information
TokisanGames committed Oct 28, 2023
1 parent 2bae7dd commit ecfde12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/terrain_3d_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ void Terrain3DStorage::set_control_maps(const TypedArray<Image> &p_maps) {
Ref<Image> new_img = Image::create_from_data(_region_size, _region_size, false, Image::FORMAT_RF, pba);
maps[i] = new_img;
}
_version = CURRENT_VERSION; // Prevent running again on focus
}
_control_maps = sanitize_maps(TYPE_CONTROL, maps);
force_update_maps(TYPE_CONTROL);
Expand All @@ -406,7 +405,7 @@ void Terrain3DStorage::set_color_maps(const TypedArray<Image> &p_maps) {
TypedArray<Image> maps = p_maps;
// DEPRECATED 0.8.4 Remove 0.9
// Convert colormap from linear <0.84 to srgb 0.841
if (_version < CURRENT_VERSION && maps.size() > 0) {
if (_version < CURRENT_VERSION && maps.size() > 0 && !_colormap_upgraded) {
LOG(WARN, "Color maps are being converted from linear to srgb. Upgrading: ", vformat("%.2f", _version), "->", vformat("%.2f", CURRENT_VERSION));
for (int i = 0; i < maps.size(); i++) {
Ref<Image> img = maps[i];
Expand All @@ -418,7 +417,7 @@ void Terrain3DStorage::set_color_maps(const TypedArray<Image> &p_maps) {
}
maps[i] = img;
}
_version = CURRENT_VERSION; // Prevent running again on focus
_colormap_upgraded = true;
}
_color_maps = sanitize_maps(TYPE_COLOR, maps);
force_update_maps(TYPE_COLOR);
Expand Down
2 changes: 2 additions & 0 deletions src/terrain_3d_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class Terrain3DStorage : public Resource {

// DEPRECATED 0.8.3, remove 0.9
Ref<Terrain3DTextureList> _texture_list;
// DEPRECATED 0.8.4, remove 0.9
bool _colormap_upgraded = false;

public:
Terrain3DStorage();
Expand Down

0 comments on commit ecfde12

Please sign in to comment.