diff --git a/src/geoclipmap.cpp b/src/geoclipmap.cpp index 54e30943..33175aab 100644 --- a/src/geoclipmap.cpp +++ b/src/geoclipmap.cpp @@ -77,7 +77,7 @@ Vector GeoClipMap::generate(int p_size, int p_levels) { for (int y = 0; y < PATCH_VERT_RESOLUTION; y++) { for (int x = 0; x < PATCH_VERT_RESOLUTION; x++) { - vertices[n++] = Vector3(x, 0, y); + vertices[n++] = Vector3(x, 0.f, y); } } @@ -95,7 +95,7 @@ Vector GeoClipMap::generate(int p_size, int p_levels) { } } - aabb = AABB(Vector3(0, 0, 0), Vector3(PATCH_VERT_RESOLUTION, 0.1, PATCH_VERT_RESOLUTION)); + aabb = AABB(Vector3(0.f, 0.f, 0.f), Vector3(PATCH_VERT_RESOLUTION, 0.1f, PATCH_VERT_RESOLUTION)); tile_mesh = _create_mesh(vertices, indices, aabb); } @@ -112,41 +112,41 @@ Vector GeoClipMap::generate(int p_size, int p_levels) { int offset = TILE_RESOLUTION; for (int i = 0; i < PATCH_VERT_RESOLUTION; i++) { - vertices[n] = Vector3(offset + i + 1, 0, 0); + vertices[n] = Vector3(offset + i + 1.f, 0.f, 0.f); aabb.expand_to(vertices[n]); n++; - vertices[n] = Vector3(offset + i + 1, 0, 1); + vertices[n] = Vector3(offset + i + 1.f, 0.f, 1.f); aabb.expand_to(vertices[n]); n++; } for (int i = 0; i < PATCH_VERT_RESOLUTION; i++) { - vertices[n] = Vector3(1, 0, offset + i + 1); + vertices[n] = Vector3(1.f, 0.f, offset + i + 1.f); aabb.expand_to(vertices[n]); n++; - vertices[n] = Vector3(0, 0, offset + i + 1); + vertices[n] = Vector3(0.f, 0.f, offset + i + 1.f); aabb.expand_to(vertices[n]); n++; } for (int i = 0; i < PATCH_VERT_RESOLUTION; i++) { - vertices[n] = Vector3(-real_t(offset + i), 0, 1); + vertices[n] = Vector3(-real_t(offset + i), 0.f, 1.f); aabb.expand_to(vertices[n]); n++; - vertices[n] = Vector3(-real_t(offset + i), 0, 0); + vertices[n] = Vector3(-real_t(offset + i), 0.f, 0.f); aabb.expand_to(vertices[n]); n++; } for (int i = 0; i < PATCH_VERT_RESOLUTION; i++) { - vertices[n] = Vector3(0, 0, -real_t(offset + i)); + vertices[n] = Vector3(0.f, 0.f, -real_t(offset + i)); aabb.expand_to(vertices[n]); n++; - vertices[n] = Vector3(1, 0, -real_t(offset + i)); + vertices[n] = Vector3(1.f, 0.f, -real_t(offset + i)); aabb.expand_to(vertices[n]); n++; } @@ -190,14 +190,14 @@ Vector GeoClipMap::generate(int p_size, int p_levels) { indices.resize((CLIPMAP_VERT_RESOLUTION * 2 - 1) * 6); n = 0; - Vector3 offset = Vector3(0.5f * real_t(CLIPMAP_VERT_RESOLUTION + 1), 0, 0.5f * real_t(CLIPMAP_VERT_RESOLUTION + 1)); + Vector3 offset = Vector3(0.5f * real_t(CLIPMAP_VERT_RESOLUTION + 1), 0.f, 0.5f * real_t(CLIPMAP_VERT_RESOLUTION + 1)); for (int i = 0; i < CLIPMAP_VERT_RESOLUTION + 1; i++) { - vertices[n] = Vector3(0, 0, CLIPMAP_VERT_RESOLUTION - i) - offset; + vertices[n] = Vector3(0.f, 0.f, CLIPMAP_VERT_RESOLUTION - i) - offset; aabb.expand_to(vertices[n]); n++; - vertices[n] = Vector3(1, 0, CLIPMAP_VERT_RESOLUTION - i) - offset; + vertices[n] = Vector3(1.f, 0.f, CLIPMAP_VERT_RESOLUTION - i) - offset; aabb.expand_to(vertices[n]); n++; } @@ -205,11 +205,11 @@ Vector GeoClipMap::generate(int p_size, int p_levels) { int start_of_horizontal = n; for (int i = 0; i < CLIPMAP_VERT_RESOLUTION; i++) { - vertices[n] = Vector3(i + 1, 0, 0) - offset; + vertices[n] = Vector3(i + 1.f, 0.f, 0.f) - offset; aabb.expand_to(vertices[n]); n++; - vertices[n] = Vector3(i + 1, 0, 1) - offset; + vertices[n] = Vector3(i + 1.f, 0.f, 1.f) - offset; aabb.expand_to(vertices[n]); n++; } @@ -251,11 +251,11 @@ Vector GeoClipMap::generate(int p_size, int p_levels) { n = 0; for (int i = 0; i < PATCH_VERT_RESOLUTION * 2; i++) { - vertices[n] = Vector3(i - real_t(TILE_RESOLUTION), 0, 0); + vertices[n] = Vector3(real_t(i - TILE_RESOLUTION), 0.f, 0.f); aabb.expand_to(vertices[n]); n++; - vertices[n] = Vector3(i - real_t(TILE_RESOLUTION), 0, 1); + vertices[n] = Vector3(real_t(i - TILE_RESOLUTION), 0.f, 1.f); aabb.expand_to(vertices[n]); n++; } @@ -263,11 +263,11 @@ Vector GeoClipMap::generate(int p_size, int p_levels) { int start_of_vertical = n; for (int i = 0; i < PATCH_VERT_RESOLUTION * 2; i++) { - vertices[n] = Vector3(0, 0, i - real_t(TILE_RESOLUTION)); + vertices[n] = Vector3(0.f, 0.f, real_t(i - TILE_RESOLUTION)); aabb.expand_to(vertices[n]); n++; - vertices[n] = Vector3(1, 0, i - real_t(TILE_RESOLUTION)); + vertices[n] = Vector3(1.f, 0.f, real_t(i - TILE_RESOLUTION)); aabb.expand_to(vertices[n]); n++; } @@ -322,19 +322,19 @@ Vector GeoClipMap::generate(int p_size, int p_levels) { for (int i = 0; i < CLIPMAP_VERT_RESOLUTION; i++) { n = CLIPMAP_VERT_RESOLUTION * 0 + i; - vertices[n] = Vector3(i, 0, 0); + vertices[n] = Vector3(i, 0.f, 0.f); aabb.expand_to(vertices[n]); n = CLIPMAP_VERT_RESOLUTION * 1 + i; - vertices[n] = Vector3(CLIPMAP_VERT_RESOLUTION, 0, i); + vertices[n] = Vector3(CLIPMAP_VERT_RESOLUTION, 0.f, i); aabb.expand_to(vertices[n]); n = CLIPMAP_VERT_RESOLUTION * 2 + i; - vertices[n] = Vector3(CLIPMAP_VERT_RESOLUTION - i, 0, CLIPMAP_VERT_RESOLUTION); + vertices[n] = Vector3(CLIPMAP_VERT_RESOLUTION - i, 0.f, CLIPMAP_VERT_RESOLUTION); aabb.expand_to(vertices[n]); n = CLIPMAP_VERT_RESOLUTION * 3 + i; - vertices[n] = Vector3(0, 0, CLIPMAP_VERT_RESOLUTION - i); + vertices[n] = Vector3(0.f, 0.f, CLIPMAP_VERT_RESOLUTION - i); aabb.expand_to(vertices[n]); } diff --git a/src/terrain_3d.cpp b/src/terrain_3d.cpp index c33f90b1..25a5181e 100644 --- a/src/terrain_3d.cpp +++ b/src/terrain_3d.cpp @@ -370,23 +370,23 @@ void Terrain3D::_update_collision() { map_data.resize(shape_size * shape_size); Vector2i global_offset = Vector2i(_storage->get_region_offsets()[i]) * region_size; - Vector3 global_pos = Vector3(global_offset.x, 0, global_offset.y); + Vector3 global_pos = Vector3(global_offset.x, 0.f, global_offset.y); Ref map, map_x, map_z, map_xz; Ref cmap, cmap_x, cmap_z, cmap_xz; map = _storage->get_map_region(Terrain3DStorage::TYPE_HEIGHT, i); cmap = _storage->get_map_region(Terrain3DStorage::TYPE_CONTROL, i); - int region = _storage->get_region_index(Vector3(global_pos.x + region_size, 0, global_pos.z)); + int region = _storage->get_region_index(Vector3(global_pos.x + region_size, 0.f, global_pos.z)); if (region >= 0) { map_x = _storage->get_map_region(Terrain3DStorage::TYPE_HEIGHT, region); cmap_x = _storage->get_map_region(Terrain3DStorage::TYPE_CONTROL, region); } - region = _storage->get_region_index(Vector3(global_pos.x, 0, global_pos.z + region_size)); + region = _storage->get_region_index(Vector3(global_pos.x, 0.f, global_pos.z + region_size)); if (region >= 0) { map_z = _storage->get_map_region(Terrain3DStorage::TYPE_HEIGHT, region); cmap_z = _storage->get_map_region(Terrain3DStorage::TYPE_CONTROL, region); } - region = _storage->get_region_index(Vector3(global_pos.x + region_size, 0, global_pos.z + region_size)); + region = _storage->get_region_index(Vector3(global_pos.x + region_size, 0.f, global_pos.z + region_size)); if (region >= 0) { map_xz = _storage->get_map_region(Terrain3DStorage::TYPE_HEIGHT, region); cmap_xz = _storage->get_map_region(Terrain3DStorage::TYPE_CONTROL, region); @@ -429,9 +429,9 @@ void Terrain3D::_update_collision() { // Non rotated shape for normal array index above //Transform3D xform = Transform3D(Basis(), global_pos); // Rotated shape Y=90 for -90 rotated array index - Transform3D xform = Transform3D(Basis(Vector3(0, 1.0, 0), Math_PI * .5), - global_pos + Vector3(region_size, 0, region_size) * .5); - xform.scale(Vector3(_mesh_vertex_spacing, 1, _mesh_vertex_spacing)); + Transform3D xform = Transform3D(Basis(Vector3(0.f, 1.f, 0.f), Math_PI * .5f), + global_pos + Vector3(region_size, 0.f, region_size) * .5f); + xform.scale(Vector3(_mesh_vertex_spacing, 1.f, _mesh_vertex_spacing)); if (!_show_debug_collision) { RID shape = PhysicsServer3D::get_singleton()->heightmap_shape_create(); @@ -570,7 +570,7 @@ void Terrain3D::_generate_triangles(PackedVector3Array &p_vertices, PackedVector for (int32_t z = z_start; z < z_end; ++z) { for (int32_t x = x_start; x < x_end; ++x) { - real_t height = _storage->get_height(Vector3(x, 0.0, z)); + real_t height = _storage->get_height(Vector3(x, 0.f, z)); if (height >= p_global_aabb.position.y && height <= p_global_aabb.get_end().y) { _generate_triangle_pair(p_vertices, p_uvs, p_lod, p_filter, p_require_nav, x, z); } @@ -816,7 +816,7 @@ void Terrain3D::snap(Vector3 p_cam_pos) { real_t scale = real_t(1 << l) * _mesh_vertex_spacing; Vector3 snapped_pos = (p_cam_pos / scale).floor() * scale; Vector3 tile_size = Vector3(real_t(_mesh_size << l), 0, real_t(_mesh_size << l)) * _mesh_vertex_spacing; - Vector3 base = snapped_pos - Vector3(real_t(_mesh_size << (l + 1)), 0, real_t(_mesh_size << (l + 1))) * _mesh_vertex_spacing; + Vector3 base = snapped_pos - Vector3(real_t(_mesh_size << (l + 1)), 0.f, real_t(_mesh_size << (l + 1))) * _mesh_vertex_spacing; // Position tiles for (int x = 0; x < 4; x++) { @@ -825,11 +825,11 @@ void Terrain3D::snap(Vector3 p_cam_pos) { continue; } - Vector3 fill = Vector3(x >= 2 ? 1 : 0, 0, y >= 2 ? 1 : 0) * scale; - Vector3 tile_tl = base + Vector3(x, 0, y) * tile_size + fill; + Vector3 fill = Vector3(x >= 2 ? 1.f : 0.f, 0.f, y >= 2 ? 1.f : 0.f) * scale; + Vector3 tile_tl = base + Vector3(x, 0.f, y) * tile_size + fill; //Vector3 tile_br = tile_tl + tile_size; - Transform3D t = Transform3D().scaled(Vector3(scale, 1, scale)); + Transform3D t = Transform3D().scaled(Vector3(scale, 1.f, scale)); t.origin = tile_tl; RS->instance_set_transform(_data.tiles[tile], t); @@ -838,7 +838,7 @@ void Terrain3D::snap(Vector3 p_cam_pos) { } } { - Transform3D t = Transform3D().scaled(Vector3(scale, 1, scale)); + Transform3D t = Transform3D().scaled(Vector3(scale, 1.f, scale)); t.origin = snapped_pos; RS->instance_set_transform(_data.fillers[l], t); } @@ -849,26 +849,26 @@ void Terrain3D::snap(Vector3 p_cam_pos) { // Position trims { - Vector3 tile_center = snapped_pos + (Vector3(scale, 0, scale) * 0.5f); + Vector3 tile_center = snapped_pos + (Vector3(scale, 0.f, scale) * 0.5f); Vector3 d = p_cam_pos - next_snapped_pos; int r = 0; r |= d.x >= scale ? 0 : 2; r |= d.z >= scale ? 0 : 1; - real_t rotations[4] = { 0.0, 270.0, 90, 180.0 }; + real_t rotations[4] = { 0.f, 270.f, 90.f, 180.f }; real_t angle = UtilityFunctions::deg_to_rad(rotations[r]); - Transform3D t = Transform3D().rotated(Vector3(0, 1, 0), -angle); - t = t.scaled(Vector3(scale, 1, scale)); + Transform3D t = Transform3D().rotated(Vector3(0.f, 1.f, 0.f), -angle); + t = t.scaled(Vector3(scale, 1.f, scale)); t.origin = tile_center; RS->instance_set_transform(_data.trims[edge], t); } // Position seams { - Vector3 next_base = next_snapped_pos - Vector3(real_t(_mesh_size << (l + 1)), 0, real_t(_mesh_size << (l + 1))) * _mesh_vertex_spacing; - Transform3D t = Transform3D().scaled(Vector3(scale, 1, scale)); + Vector3 next_base = next_snapped_pos - Vector3(real_t(_mesh_size << (l + 1)), 0.f, real_t(_mesh_size << (l + 1))) * _mesh_vertex_spacing; + Transform3D t = Transform3D().scaled(Vector3(scale, 1.f, scale)); t.origin = next_base; RS->instance_set_transform(_data.seams[edge], t); } diff --git a/src/terrain_3d.h b/src/terrain_3d.h index 2b2488f3..2d4cb644 100644 --- a/src/terrain_3d.h +++ b/src/terrain_3d.h @@ -63,7 +63,7 @@ class Terrain3D : public Node3D { // Renderer settings uint32_t _render_layers = 1 | (1 << 31); // Bit 1 and 32 for the cursor GeometryInstance3D::ShadowCastingSetting _shadow_casting = GeometryInstance3D::SHADOW_CASTING_SETTING_ON; - real_t _cull_margin = 0.0; + real_t _cull_margin = 0.0f; // Mouse cursor SubViewport *_mouse_vp = nullptr; @@ -78,7 +78,7 @@ class Terrain3D : public Node3D { bool _show_debug_collision = false; uint32_t _collision_layer = 1; uint32_t _collision_mask = 1; - real_t _collision_priority = 1.0; + real_t _collision_priority = 1.0f; void _initialize(); void __ready(); diff --git a/src/terrain_3d_editor.cpp b/src/terrain_3d_editor.cpp index c3b5d00a..56a03450 100644 --- a/src/terrain_3d_editor.cpp +++ b/src/terrain_3d_editor.cpp @@ -148,8 +148,8 @@ void Terrain3DEditor::_operate_map(Vector3 p_global_position, real_t p_camera_di Object::cast_to(_terrain->get_plugin()->get("ui"))->call("set_decal_rotation", rot); AABB edited_area; - edited_area.position = p_global_position - Vector3(brush_size, 0.0f, brush_size) / 2.0f; - edited_area.size = Vector3(brush_size, 0.0f, brush_size); + edited_area.position = p_global_position - Vector3(brush_size, 0.f, brush_size) / 2.f; + edited_area.size = Vector3(brush_size, 0.f, brush_size); for (int x = 0; x < brush_size; x++) { for (int y = 0; y < brush_size; y++) { @@ -231,7 +231,7 @@ void Terrain3DEditor::_operate_map(Vector3 p_global_position, real_t p_camera_di up = storage->get_pixel(map_type, up_position).r; down = storage->get_pixel(map_type, down_position).r; - real_t avg = (srcf + left + right + up + down) * 0.2; + real_t avg = (srcf + left + right + up + down) * 0.2f; destf = Math::lerp(srcf, avg, brush_alpha * opacity); break; } @@ -244,7 +244,7 @@ void Terrain3DEditor::_operate_map(Vector3 p_global_position, real_t p_camera_di Vector2 point_2_xz = Vector2(point_2.x, point_2.z); Vector2 brush_xz = Vector2(brush_global_position.x, brush_global_position.z); - if (_operation_movement.length_squared() > 0.0) { + if (_operation_movement.length_squared() > 0.f) { // Ramp up/down only in the direction of movement, to avoid giving winding // paths one edge higher than the other. Vector2 movement_xz = Vector2(_operation_movement.x, _operation_movement.z).normalized(); @@ -254,7 +254,7 @@ void Terrain3DEditor::_operate_map(Vector3 p_global_position, real_t p_camera_di Vector2 dir = point_2_xz - point_1_xz; real_t weight = dir.normalized().dot(brush_xz - point_1_xz) / dir.length(); - weight = Math::clamp(weight, (real_t)0.0, (real_t)1.0); + weight = Math::clamp(weight, (real_t)0.0f, (real_t)1.0f); real_t height = Math::lerp(point_1.y, point_2.y, weight); destf = Math::lerp(srcf, height, brush_alpha * opacity); @@ -264,7 +264,7 @@ void Terrain3DEditor::_operate_map(Vector3 p_global_position, real_t p_camera_di default: break; } - dest = Color(destf, 0.0f, 0.0f, 1.0f); + dest = Color(destf, 0.f, 0.f, 1.f); storage->update_heights(destf); edited_position.y = destf; @@ -274,12 +274,12 @@ void Terrain3DEditor::_operate_map(Vector3 p_global_position, real_t p_camera_di // Get bit field from pixel uint32_t base_id = Util::get_base(src.r); uint32_t overlay_id = Util::get_overlay(src.r); - real_t blend = real_t(Util::get_blend(src.r)) / 255.0f; + real_t blend = real_t(Util::get_blend(src.r)) / 255.f; bool hole = Util::is_hole(src.r); bool navigation = Util::is_nav(src.r); bool autoshader = Util::is_auto(src.r); - real_t alpha_clip = (brush_alpha > 0.1f) ? 1.0f : 0.0f; + real_t alpha_clip = (brush_alpha > 0.1f) ? 1.f : 0.f; uint32_t dest_id = uint32_t(Math::lerp(base_id, texture_id, alpha_clip)); switch (_tool) { @@ -290,7 +290,7 @@ void Terrain3DEditor::_operate_map(Vector3 p_global_position, real_t p_camera_di // Set base texture base_id = dest_id; // Erase blend value - blend = Math::lerp(blend, real_t(0.0f), alpha_clip); + blend = Math::lerp(blend, real_t(0.f), alpha_clip); if (brush_alpha > 0.1f) { autoshader = false; } @@ -299,14 +299,14 @@ void Terrain3DEditor::_operate_map(Vector3 p_global_position, real_t p_camera_di // Overlay Spray case ADD: { real_t spray_opacity = CLAMP(opacity * 0.025f, 0.003f, 0.025f); - real_t brush_value = CLAMP(brush_alpha * spray_opacity, 0.0f, 1.0f); + real_t brush_value = CLAMP(brush_alpha * spray_opacity, 0.f, 1.f); // If overlay and base texture are the same, reduce blend value if (dest_id == base_id) { - blend = CLAMP(blend - brush_value, 0.0f, 1.0f); + blend = CLAMP(blend - brush_value, 0.f, 1.f); } else { // Else overlay and base are separate, set overlay texture and increase blend value overlay_id = dest_id; - blend = CLAMP(blend + brush_value, 0.0f, 1.0f); + blend = CLAMP(blend + brush_value, 0.f, 1.f); } if (brush_alpha * opacity * 11.f > 0.1f) { autoshader = false; @@ -337,13 +337,13 @@ void Terrain3DEditor::_operate_map(Vector3 p_global_position, real_t p_camera_di } // Convert back to bitfield - uint32_t blend_int = uint32_t(CLAMP(Math::round(blend * 255.0f), 0.0f, 255.0f)); + uint32_t blend_int = uint32_t(CLAMP(Math::round(blend * 255.f), 0.f, 255.f)); uint32_t bits = Util::enc_base(base_id) | Util::enc_overlay(overlay_id) | Util::enc_blend(blend_int) | Util::enc_hole(hole) | Util::enc_nav(navigation) | Util::enc_auto(autoshader); // Write back to pixel in FORMAT_RF. Must be a 32-bit float - dest = Color(*(float *)&bits, 0.f, 0.f, 1.0f); + dest = Color(*(float *)&bits, 0.f, 0.f, 1.f); } else if (map_type == Terrain3DStorage::TYPE_COLOR) { switch (_tool) { @@ -390,9 +390,9 @@ Vector2 Terrain3DEditor::_get_uv_position(Vector3 p_global_position, int p_regio } Vector2 Terrain3DEditor::_rotate_uv(Vector2 p_uv, real_t p_angle) { - Vector2 rotation_offset = Vector2(0.5, 0.5); + Vector2 rotation_offset = Vector2(0.5f, 0.5f); p_uv = (p_uv - rotation_offset).rotated(p_angle) + rotation_offset; - return p_uv.clamp(Vector2(0, 0), Vector2(1, 1)); + return p_uv.clamp(Vector2(0.f, 0.f), Vector2(1.f, 1.f)); } /* Stored in the _undo_set is: diff --git a/src/terrain_3d_editor.h b/src/terrain_3d_editor.h index 083a7d07..a0a08a32 100644 --- a/src/terrain_3d_editor.h +++ b/src/terrain_3d_editor.h @@ -70,18 +70,18 @@ class Terrain3DEditor : public Object { Ref _texture; int _size = 0; - real_t _opacity = 0.0; - real_t _height = 0.0; + real_t _opacity = 0.0f; + real_t _height = 0.0f; int _texture_index = 0; Color _color = COLOR_ROUGHNESS; - real_t _roughness = 0.5; + real_t _roughness = 0.5f; PackedVector3Array _gradient_points; bool _enable = false; bool _auto_regions = false; bool _align_to_view = false; - real_t _gamma = 1.0; - real_t _jitter = 0.0; + real_t _gamma = 1.0f; + real_t _jitter = 0.0f; public: void set_data(Dictionary p_data); diff --git a/src/terrain_3d_material.cpp b/src/terrain_3d_material.cpp index c0aafab0..8d7f29d1 100644 --- a/src/terrain_3d_material.cpp +++ b/src/terrain_3d_material.cpp @@ -279,8 +279,8 @@ void Terrain3DMaterial::_update_shader() { pfa.push_back(1.0f); curve->set_offsets(pfa); PackedColorArray pca; - pca.push_back(Color(1., 1., 1., 1.)); - pca.push_back(Color(0., 0., 0., 1.)); + pca.push_back(Color(1.f, 1.f, 1.f, 1.f)); + pca.push_back(Color(0.f, 0.f, 0.f, 1.f)); curve->set_colors(pca); Ref noise_tex; diff --git a/src/terrain_3d_storage.cpp b/src/terrain_3d_storage.cpp index edafefca..2479f398 100644 --- a/src/terrain_3d_storage.cpp +++ b/src/terrain_3d_storage.cpp @@ -75,7 +75,7 @@ void Terrain3DStorage::update_heights(Vector2 p_heights) { } void Terrain3DStorage::update_height_range() { - _height_range = Vector2(0, 0); + _height_range = Vector2(0.f, 0.f); for (int i = 0; i < _height_maps.size(); i++) { update_heights(Util::get_min_max(_height_maps[i])); } @@ -164,7 +164,7 @@ Error Terrain3DStorage::add_region(Vector3 p_global_position, const TypedArray TYPE_HEIGHT) { min_max = Util::get_min_max(images[TYPE_HEIGHT]); LOG(DEBUG, "Checking imported height range: ", min_max); @@ -210,7 +210,7 @@ void Terrain3DStorage::remove_region(Vector3 p_global_position, bool p_update) { LOG(DEBUG, "Removed colormaps, new size: ", _color_maps.size()); if (_height_maps.size() == 0) { - _height_range = Vector2(0, 0); + _height_range = Vector2(0.f, 0.f); } // Region_map is used by get_region_index so must be updated @@ -632,7 +632,7 @@ Ref Terrain3DStorage::load_image(String p_file_name, int p_cache_mode, Ve for (int x = 0; x < p_r16_size.x; x++) { real_t h = real_t(file->get_16()) / 65535.0f; h = h * (p_r16_height_range.y - p_r16_height_range.x) + p_r16_height_range.x; - img->set_pixel(x, y, Color(h, 0, 0)); + img->set_pixel(x, y, Color(h, 0.f, 0.f)); } } @@ -718,7 +718,7 @@ void Terrain3DStorage::import_images(const TypedArray &p_images, Vector3 } // Apply scale and offsets to a new heightmap if applicable - if (i == TYPE_HEIGHT && (p_offset != 0 || p_scale != 1.0)) { + if (i == TYPE_HEIGHT && (p_offset != 0.f || p_scale != 1.f)) { LOG(DEBUG, "Creating new temp image to adjust scale: ", p_scale, " offset: ", p_offset); Ref newimg = Image::create(img->get_size().x, img->get_size().y, false, FORMAT[TYPE_HEIGHT]); for (int y = 0; y < img->get_height(); y++) { @@ -769,7 +769,7 @@ void Terrain3DStorage::import_images(const TypedArray &p_images, Vector3 images[i] = img_slice; } // Add the heightmap slice and only regenerate on the last one - Vector3 position = Vector3(p_global_position.x + start_coords.x, 0, p_global_position.z + start_coords.y); + Vector3 position = Vector3(p_global_position.x + start_coords.x, 0.f, p_global_position.z + start_coords.y); add_region(position, images, (x == slices_width - 1 && y == slices_height - 1)); } } // for y < slices_height, x < slices_width @@ -920,7 +920,7 @@ Ref Terrain3DStorage::layered_to_image(MapType p_map_type) { Vector3 Terrain3DStorage::get_mesh_vertex(int32_t p_lod, HeightFilter p_filter, Vector3 p_global_position) { LOG(INFO, "Calculating vertex location"); int32_t step = 1 << CLAMP(p_lod, 0, 8); - real_t height = 0.0; + real_t height = 0.0f; switch (p_filter) { case HEIGHT_FILTER_NEAREST: { @@ -934,7 +934,7 @@ Vector3 Terrain3DStorage::get_mesh_vertex(int32_t p_lod, HeightFilter p_filter, height = get_height(p_global_position); for (int32_t dx = -step / 2; dx < step / 2; dx += 1) { for (int32_t dz = -step / 2; dz < step / 2; dz += 1) { - Vector3 position = p_global_position + Vector3(dx, 0.0, dz); + Vector3 position = p_global_position + Vector3(dx, 0.f, dz); if (Util::is_hole(get_control(position))) { height = NAN; break; diff --git a/src/terrain_3d_storage.h b/src/terrain_3d_storage.h index 52b1d6e5..5500b3a4 100644 --- a/src/terrain_3d_storage.h +++ b/src/terrain_3d_storage.h @@ -20,7 +20,7 @@ class Terrain3DStorage : public Resource { // Constants static inline const char *__class__ = "Terrain3DStorage"; - static inline const real_t CURRENT_VERSION = 0.842; + static inline const real_t CURRENT_VERSION = 0.842f; static inline const int REGION_MAP_SIZE = 16; static inline const Vector2i REGION_MAP_VSIZE = Vector2i(REGION_MAP_SIZE, REGION_MAP_SIZE); @@ -68,14 +68,14 @@ class Terrain3DStorage : public Resource { private: // Storage Settings & flags - real_t _version = 0.8; // Set to ensure Godot always saves this + real_t _version = 0.8f; // Set to ensure Godot always saves this bool _modified = false; bool _save_16_bit = false; RegionSize _region_size = SIZE_1024; Vector2i _region_sizev = Vector2i(_region_size, _region_size); // Stored Data - Vector2 _height_range = Vector2(0, 0); + Vector2 _height_range = Vector2(0.f, 0.f); AABB _edited_area; /** @@ -163,9 +163,9 @@ class Terrain3DStorage : public Resource { void clear_modified() { _modified = false; } void set_modified() { _modified = true; } static Ref load_image(String p_file_name, int p_cache_mode = ResourceLoader::CACHE_MODE_IGNORE, - Vector2 p_r16_height_range = Vector2(0, 255), Vector2i p_r16_size = Vector2i(0, 0)); - void import_images(const TypedArray &p_images, Vector3 p_global_position = Vector3(0, 0, 0), - real_t p_offset = 0.0, real_t p_scale = 1.0); + Vector2 p_r16_height_range = Vector2(0.f, 255.f), Vector2i p_r16_size = Vector2i(0, 0)); + void import_images(const TypedArray &p_images, Vector3 p_global_position = Vector3(0.f, 0.f, 0.f), + real_t p_offset = 0.f, real_t p_scale = 1.f); Error export_image(String p_file_name, MapType p_map_type = TYPE_HEIGHT); Ref layered_to_image(MapType p_map_type); @@ -185,7 +185,7 @@ VARIANT_ENUM_CAST(Terrain3DStorage::HeightFilter); // Inline Functions inline void Terrain3DStorage::set_height(Vector3 p_global_position, real_t p_height) { - set_pixel(TYPE_HEIGHT, p_global_position, Color(p_height, 0., 0., 1.)); + set_pixel(TYPE_HEIGHT, p_global_position, Color(p_height, 0.f, 0.f, 1.f)); } inline real_t Terrain3DStorage::get_height(Vector3 p_global_position) { diff --git a/src/terrain_3d_texture.cpp b/src/terrain_3d_texture.cpp index 1b1c99ad..ef0359bf 100644 --- a/src/terrain_3d_texture.cpp +++ b/src/terrain_3d_texture.cpp @@ -41,7 +41,7 @@ Terrain3DTexture::~Terrain3DTexture() { void Terrain3DTexture::clear() { _data._name = "New Texture"; _data._texture_id = 0; - _data._albedo_color = Color(1.0, 1.0, 1.0, 1.0); + _data._albedo_color = Color(1.0f, 1.0f, 1.0f, 1.0f); _data._albedo_texture.unref(); _data._normal_texture.unref(); _data._uv_scale = 0.1f; diff --git a/src/terrain_3d_texture.h b/src/terrain_3d_texture.h index 60b47f1d..6e5014ff 100644 --- a/src/terrain_3d_texture.h +++ b/src/terrain_3d_texture.h @@ -17,7 +17,7 @@ class Terrain3DTexture : public Resource { struct Settings { String _name = "New Texture"; int _texture_id = 0; - Color _albedo_color = Color(1.0, 1.0, 1.0, 1.0); + Color _albedo_color = Color(1.f, 1.f, 1.f, 1.f); Ref _albedo_texture; Ref _normal_texture; real_t _uv_scale = 0.1f; diff --git a/src/util.cpp b/src/util.cpp index d8beaef3..61282e24 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -41,7 +41,7 @@ Vector2 Util::get_min_max(const Ref p_image) { return Vector2(INFINITY, INFINITY); } - Vector2 min_max = Vector2(0, 0); + Vector2 min_max = Vector2(0.f, 0.f); for (int y = 0; y < p_image->get_height(); y++) { for (int x = 0; x < p_image->get_width(); x++) { @@ -89,7 +89,7 @@ Ref Util::get_thumbnail(const Ref p_image, Vector2i p_size) { hmin = abs(hmin); hmax = abs(hmax) + hmin; // Avoid divide by zero - hmax = (hmax == 0) ? 0.001 : hmax; + hmax = (hmax == 0) ? 0.001f : hmax; // Create a new image w / normalized values Ref thumb = Image::create(p_size.x, p_size.y, false, Image::FORMAT_RGB8);