Skip to content

Commit

Permalink
Print min/max height on export. Dereference gentex parameter. Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
TokisanGames committed Oct 25, 2024
1 parent 4088dbc commit b0fc103
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions project/addons/terrain_3d/editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ func _edit(p_object: Object) -> void:
ui.set_visible(true)
terrain.set_meta("_edit_lock_", true)

# Deprecated 0.9.3 - Remove 1.0
if terrain.storage:
ui.terrain_menu.directory_setup.directory_setup_popup()

Expand Down
2 changes: 1 addition & 1 deletion project/addons/terrain_3d/extras/import_sgt.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# 1. Click import. The output window and console will report when finished.
# 1. Clear the script from your Terrain3D node, and save your scene.
#
# The instance transforms are now stored in your Storage resource.
# The instance transforms are now stored in your region files.
#
# Use clear_instances to erase all instances that match the assign_mesh_id.
#
Expand Down
2 changes: 1 addition & 1 deletion project/addons/terrain_3d/extras/project_on_terrain3d.gd
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#return
#
#if not _terrain.data:
#warning += """Terrain3D storage is not initialized"""
#warning += """Terrain3DData is not initialized"""
#return
#
## Get global transform
Expand Down
1 change: 0 additions & 1 deletion project/addons/terrain_3d/tools/importer.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ mesh_list = Array[Terrain3DMeshAsset]([SubResource("Terrain3DMeshAsset_7je72")])
material = SubResource("Terrain3DMaterial_p55u0")
assets = SubResource("Terrain3DAssets_op32e")
mesh_lods = 8
debug_show_region_labels = true
top_level = true
script = ExtResource("1_60b8f")
metadata/_edit_lock_ = true
2 changes: 1 addition & 1 deletion src/generated_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RID GeneratedTexture::create(const TypedArray<Image> &p_layers) {
return _rid;
}

void GeneratedTexture::update(const Ref<Image> &p_image, const int &p_layer) {
void GeneratedTexture::update(const Ref<Image> &p_image, const int p_layer) {
LOG(EXTREME, "RenderingServer updating Texture2DArray at index: ", p_layer);
RS->texture_2d_update(_rid, p_image, p_layer);
}
Expand Down
2 changes: 1 addition & 1 deletion src/generated_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GeneratedTexture {
void clear();
bool is_dirty() const { return _dirty; }
RID create(const TypedArray<Image> &p_layers);
void update(const Ref<Image> &p_image, const int &p_layer);
void update(const Ref<Image> &p_image, const int p_layer);
RID create(const Ref<Image> &p_image);
Ref<Image> get_image() const { return _image; }
RID get_rid() const { return _rid; }
Expand Down
11 changes: 6 additions & 5 deletions src/terrain_3d_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
///////////////////////////

void Terrain3DData::_clear() {
LOG(INFO, "Clearing storage");
LOG(INFO, "Clearing data");
_region_map_dirty = true;
_region_map.clear();
_region_map.resize(REGION_MAP_SIZE * REGION_MAP_SIZE);
Expand Down Expand Up @@ -50,7 +50,7 @@ void Terrain3DData::initialize(Terrain3D *p_terrain) {
LOG(ERROR, "Initialization failed, p_terrain is null");
return;
}
LOG(INFO, "Initializing storage");
LOG(INFO, "Initializing data");
bool prev_initialized = _terrain != nullptr;
_terrain = p_terrain;
_region_map.resize(REGION_MAP_SIZE * REGION_MAP_SIZE);
Expand Down Expand Up @@ -950,7 +950,7 @@ void Terrain3DData::import_images(const TypedArray<Image> &p_images, const Vecto
/** Exports a specified map as one of r16/raw, exr, jpg, png, webp, res, tres
* r16 or exr are recommended for roundtrip external editing
* r16 can be edited by Krita, however you must know the dimensions and min/max before reimporting
* res/tres allow storage in any of Godot's native Image formats.
* res/tres stores in Godot's native format.
*/
Error Terrain3DData::export_image(const String &p_file_name, const MapType p_map_type) const {
if (p_map_type < 0 || p_map_type >= TYPE_MAX) {
Expand Down Expand Up @@ -1013,8 +1013,9 @@ Error Terrain3DData::export_image(const String &p_file_name, const MapType p_map
String ext = file_name.get_extension().to_lower();
LOG(MESG, "Saving ", img->get_size(), " sized ", TYPESTR[p_map_type],
" map in format ", img->get_format(), " as ", ext, " to: ", file_name);
Vector2i minmax = Util::get_min_max(img);
LOG(MESG, "Minimum height: ", minmax.x, ", Maximum height: ", minmax.y);
if (ext == "r16" || ext == "raw") {
Vector2i minmax = Util::get_min_max(img);
Ref<FileAccess> file = FileAccess::open(file_name, FileAccess::WRITE);
real_t height_min = minmax.x;
real_t height_max = minmax.y;
Expand Down Expand Up @@ -1082,7 +1083,7 @@ Ref<Image> Terrain3DData::layered_to_image(const MapType p_map_type) const {
}

void Terrain3DData::print_audit_data() const {
LOG(INFO, "Dumping storage data");
LOG(INFO, "Dumping data");
LOG(INFO, "Region_locations size: ", _region_locations.size(), " ", _region_locations);
LOG(INFO, "Region map");
for (int i = 0; i < _region_map.size(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/terrain_3d_instancer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void Terrain3DInstancer::initialize(Terrain3D *p_terrain) {
if (p_terrain) {
_terrain = p_terrain;
}
IS_DATA_INIT_MESG("Terrain or storage not ready yet", VOID);
IS_DATA_INIT_MESG("Terrain3D not initialized yet", VOID);
LOG(INFO, "Initializing Instancer");

{ // DEPRECATED 0.9.3 - Remove 1.0
Expand Down

0 comments on commit b0fc103

Please sign in to comment.