diff options
Diffstat (limited to 'editor')
| -rw-r--r-- | editor/doc/doc_data.cpp | 6 | ||||
| -rw-r--r-- | editor/editor_asset_installer.cpp | 2 | ||||
| -rw-r--r-- | editor/editor_profiler.cpp | 2 | ||||
| -rw-r--r-- | editor/editor_settings.cpp | 6 | ||||
| -rw-r--r-- | editor/export_template_manager.cpp | 4 | ||||
| -rw-r--r-- | editor/fileserver/editor_file_server.cpp | 3 | ||||
| -rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 18 | ||||
| -rw-r--r-- | editor/import/resource_importer_obj.cpp | 1 | ||||
| -rw-r--r-- | editor/import/resource_importer_scene.cpp | 18 | ||||
| -rw-r--r-- | editor/import/resource_importer_scene.h | 8 | ||||
| -rw-r--r-- | editor/plugins/navigation_mesh_generator.cpp | 4 | ||||
| -rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 8 | ||||
| -rw-r--r-- | editor/project_manager.cpp | 2 | ||||
| -rw-r--r-- | editor/scene_tree_dock.cpp | 1 |
14 files changed, 51 insertions, 32 deletions
diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index bfee66569a..3a72f8e569 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -1081,9 +1081,9 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri ConstantDoc &k = c.constants[i]; if (k.enumeration != String()) { - _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\">"); - } else { _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\">"); + } else { + _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\">"); } _write_string(f, 3, k.description.strip_edges().xml_escape()); _write_string(f, 2, "</constant>"); @@ -1115,7 +1115,7 @@ Error DocData::load_compressed(const uint8_t *p_data, int p_compressed_size, int Vector<uint8_t> data; data.resize(p_uncompressed_size); - Compression::decompress(data.ptr(), p_uncompressed_size, p_data, p_compressed_size, Compression::MODE_DEFLATE); + Compression::decompress(data.ptrw(), p_uncompressed_size, p_data, p_compressed_size, Compression::MODE_DEFLATE); class_list.clear(); Ref<XMLParser> parser = memnew(XMLParser); diff --git a/editor/editor_asset_installer.cpp b/editor/editor_asset_installer.cpp index 1aac697ffd..94108a52fc 100644 --- a/editor/editor_asset_installer.cpp +++ b/editor/editor_asset_installer.cpp @@ -268,7 +268,7 @@ void EditorAssetInstaller::ok_pressed() { //read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptr(), data.size()); + unzReadCurrentFile(pkg, data.ptrw(), data.size()); unzCloseCurrentFile(pkg); FileAccess *f = FileAccess::open(path, FileAccess::WRITE); diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index faf49ffd41..5d81fc6ea4 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -221,7 +221,7 @@ void EditorProfiler::_update_plot() { Vector<int> columnv; columnv.resize(h * 4); - int *column = columnv.ptr(); + int *column = columnv.ptrw(); Map<StringName, int> plot_prev; //Map<StringName,int> plot_max; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 910c06053e..52672fff72 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -370,8 +370,8 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("editors/3d/grid_color", Color::html("808080")); hints["editors/3d/grid_color"] = PropertyInfo(Variant::COLOR, "editors/3d/grid_color", PROPERTY_HINT_COLOR_NO_ALPHA, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); - _initial_set("editors/3d/default_fov", 55.0); - _initial_set("editors/3d/default_z_near", 0.1); + _initial_set("editors/3d/default_fov", 70.0); + _initial_set("editors/3d/default_z_near", 0.05); _initial_set("editors/3d/default_z_far", 500.0); // navigation @@ -1390,7 +1390,7 @@ EditorSettings::EditorSettings() { Vector<uint8_t> data; data.resize(etl->uncomp_size); - Compression::decompress(data.ptr(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE); + Compression::decompress(data.ptrw(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE); FileAccessMemory *fa = memnew(FileAccessMemory); fa->open_custom(data.ptr(), data.size()); diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index d208bbe662..2aad4774b0 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -207,7 +207,7 @@ void ExportTemplateManager::_install_from_file(const String &p_file) { //read unzOpenCurrentFile(pkg); - ret = unzReadCurrentFile(pkg, data.ptr(), data.size()); + ret = unzReadCurrentFile(pkg, data.ptrw(), data.size()); unzCloseCurrentFile(pkg); String data_str; @@ -277,7 +277,7 @@ void ExportTemplateManager::_install_from_file(const String &p_file) { //read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptr(), data.size()); + unzReadCurrentFile(pkg, data.ptrw(), data.size()); unzCloseCurrentFile(pkg); print_line(fname); diff --git a/editor/fileserver/editor_file_server.cpp b/editor/fileserver/editor_file_server.cpp index fccf7c323c..ad035b48f3 100644 --- a/editor/fileserver/editor_file_server.cpp +++ b/editor/fileserver/editor_file_server.cpp @@ -31,7 +31,6 @@ #include "../editor_settings.h" #include "io/marshalls.h" -#include "io/marshalls.h" //#define DEBUG_PRINT(m_p) print_line(m_p) #define DEBUG_TIME(m_what) printf("MS: %s - %lu\n", m_what, OS::get_singleton()->get_ticks_usec()); @@ -240,7 +239,7 @@ void EditorFileServer::_subthread_start(void *s) { cd->files[id]->seek(offset); Vector<uint8_t> buf; buf.resize(blocklen); - int read = cd->files[id]->get_buffer(buf.ptr(), blocklen); + int read = cd->files[id]->get_buffer(buf.ptrw(), blocklen); ERR_CONTINUE(read < 0); print_line("GET BLOCK - offset: " + itos(offset) + ", blocklen: " + itos(blocklen)); diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 397bb6ad68..f704d97373 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -29,7 +29,7 @@ Error EditorSceneImporterGLTF::_parse_json(const String &p_path, GLTFState &stat Vector<uint8_t> array; array.resize(f->get_len()); - f->get_buffer(array.ptr(), array.size()); + f->get_buffer(array.ptrw(), array.size()); String text; text.parse_utf8((const char *)array.ptr(), array.size()); @@ -65,7 +65,7 @@ Error EditorSceneImporterGLTF::_parse_glb(const String &p_path, GLTFState &state ERR_FAIL_COND_V(chunk_type != 0x4E4F534A, ERR_PARSE_ERROR); //JSON Vector<uint8_t> json_data; json_data.resize(chunk_length); - uint32_t len = f->get_buffer(json_data.ptr(), chunk_length); + uint32_t len = f->get_buffer(json_data.ptrw(), chunk_length); ERR_FAIL_COND_V(len != chunk_length, ERR_FILE_CORRUPT); String text; @@ -94,7 +94,7 @@ Error EditorSceneImporterGLTF::_parse_glb(const String &p_path, GLTFState &state ERR_FAIL_COND_V(chunk_type != 0x004E4942, ERR_PARSE_ERROR); //BIN state.glb_data.resize(chunk_length); - len = f->get_buffer(state.glb_data.ptr(), chunk_length); + len = f->get_buffer(state.glb_data.ptrw(), chunk_length); ERR_FAIL_COND_V(len != chunk_length, ERR_FILE_CORRUPT); return OK; @@ -467,9 +467,10 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffe uint32_t offset = bv.byte_offset + byte_offset; Vector<uint8_t> buffer = state.buffers[bv.buffer]; //copy on write, so no performance hit + const uint8_t *bufptr = buffer.ptr(); //use to debug - print_line("type " + _get_type_name(type) + " component type: " + _get_component_type_name(component_type) + " stride: " + itos(stride) + " amount " + itos(count)); + //print_line("type " + _get_type_name(type) + " component type: " + _get_component_type_name(component_type) + " stride: " + itos(stride) + " amount " + itos(count)); print_line("accessor offset" + itos(byte_offset) + " view offset: " + itos(bv.byte_offset) + " total buffer len: " + itos(buffer.size()) + " view len " + itos(bv.byte_length)); int buffer_end = (stride * (count - 1)) + element_size; @@ -481,7 +482,7 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffe for (int i = 0; i < count; i++) { - const uint8_t *src = &buffer[offset + i * stride]; + const uint8_t *src = &bufptr[offset + i * stride]; for (int j = 0; j < component_count; j++) { @@ -605,7 +606,7 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, int p Vector<double> dst_buffer; dst_buffer.resize(component_count * a.count); - double *dst = dst_buffer.ptr(); + double *dst = dst_buffer.ptrw(); if (a.buffer_view >= 0) { @@ -628,13 +629,13 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, int p indices.resize(a.sparse_count); int indices_component_size = _get_component_type_size(a.sparse_indices_component_type); - Error err = _decode_buffer_view(state, a.sparse_indices_buffer_view, indices.ptr(), 0, 0, indices_component_size, a.sparse_count, TYPE_SCALAR, 1, a.sparse_indices_component_type, indices_component_size, false, a.sparse_indices_byte_offset, false); + Error err = _decode_buffer_view(state, a.sparse_indices_buffer_view, indices.ptrw(), 0, 0, indices_component_size, a.sparse_count, TYPE_SCALAR, 1, a.sparse_indices_component_type, indices_component_size, false, a.sparse_indices_byte_offset, false); if (err != OK) return Vector<double>(); Vector<double> data; data.resize(component_count * a.sparse_count); - err = _decode_buffer_view(state, a.sparse_values_buffer_view, data.ptr(), skip_every, skip_bytes, element_size, a.sparse_count, a.type, component_count, a.component_type, component_size, a.normalized, a.sparse_values_byte_offset, p_for_vertex); + err = _decode_buffer_view(state, a.sparse_values_buffer_view, data.ptrw(), skip_every, skip_bytes, element_size, a.sparse_count, a.type, component_count, a.component_type, component_size, a.normalized, a.sparse_values_byte_offset, p_for_vertex); if (err != OK) return Vector<double>(); @@ -813,6 +814,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { Array meshes = state.json["meshes"]; for (int i = 0; i < meshes.size(); i++) { + print_line("on mesh: " + itos(i)); Dictionary d = meshes[i]; GLTFMesh mesh; diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index bd24aac99b..14bda9bb4e 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -58,6 +58,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati current_name = l.replace("newmtl", "").strip_edges(); current.instance(); + current->set_name(current_name); material_map[current_name] = current; } else if (l.begins_with("Ka ")) { //uv diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 63d4039295..95445693b4 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -156,12 +156,12 @@ static String _fixstr(const String &p_what, const String &p_str) { return p_what; } -Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map) { +Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map, LightBakeMode p_light_bake_mode) { // children first.. for (int i = 0; i < p_node->get_child_count(); i++) { - Node *r = _fix_node(p_node->get_child(i), p_root, collision_map); + Node *r = _fix_node(p_node->get_child(i), p_root, collision_map, p_light_bake_mode); if (!r) { print_line("was erased.."); i--; //was erased @@ -205,6 +205,11 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array } } } + + if (p_light_bake_mode != LIGHT_BAKE_DISABLED) { + + mi->set_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT, true); + } } if (Object::cast_to<AnimationPlayer>(p_node)) { @@ -947,7 +952,10 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String for (int i = 0; i < mesh->get_surface_count(); i++) { mat = mesh->surface_get_material(i); - if (!mat.is_valid() || mat->get_name() == "") + + if (!mat.is_valid()) + continue; + if (mat->get_name() == "") continue; if (!p_materials.has(mat)) { @@ -1022,6 +1030,7 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/compress"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/ensure_tangents"), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/storage", PROPERTY_HINT_ENUM, "Built-In,Files"), meshes_out ? 1 : 0)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/light_baking", PROPERTY_HINT_ENUM, "Disabled,Enable"), 0)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "external_files/store_in_subdir"), false)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15)); @@ -1131,10 +1140,11 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p float anim_optimizer_linerr = p_options["animation/optimizer/max_linear_error"]; float anim_optimizer_angerr = p_options["animation/optimizer/max_angular_error"]; float anim_optimizer_maxang = p_options["animation/optimizer/max_angle"]; + int light_bake_mode = p_options["meshes/light_baking"]; Map<Ref<ArrayMesh>, Ref<Shape> > collision_map; - scene = _fix_node(scene, scene, collision_map); + scene = _fix_node(scene, scene, collision_map, LightBakeMode(light_bake_mode)); if (use_optimizer) { _optimize_animations(scene, anim_optimizer_linerr, anim_optimizer_angerr, anim_optimizer_maxang); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 5bf3145148..92777fafb6 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -100,6 +100,12 @@ class ResourceImporterScene : public ResourceImporter { PRESET_MAX }; + enum LightBakeMode { + LIGHT_BAKE_DISABLED, + LIGHT_BAKE_ENABLE, + //LIGHT_BAKE_LIGHTMAPS + }; + void _replace_owner(Node *p_node, Node *p_scene, Node *p_new_owner); public: @@ -124,7 +130,7 @@ public: void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes); - Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map); + Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map, LightBakeMode p_light_bake_mode); void _create_clips(Node *scene, const Array &p_clips, bool p_bake_all); void _filter_anim_tracks(Ref<Animation> anim, Set<String> &keep); diff --git a/editor/plugins/navigation_mesh_generator.cpp b/editor/plugins/navigation_mesh_generator.cpp index 5d50e9c855..005a132e22 100644 --- a/editor/plugins/navigation_mesh_generator.cpp +++ b/editor/plugins/navigation_mesh_generator.cpp @@ -189,8 +189,8 @@ void NavigationMeshGenerator::_build_recast_navigation_mesh(Ref<NavigationMesh> ERR_FAIL_COND(tri_areas.size() == 0); - memset(tri_areas.ptr(), 0, ntris * sizeof(unsigned char)); - rcMarkWalkableTriangles(&ctx, cfg.walkableSlopeAngle, verts, nverts, tris, ntris, tri_areas.ptr()); + memset(tri_areas.ptrw(), 0, ntris * sizeof(unsigned char)); + rcMarkWalkableTriangles(&ctx, cfg.walkableSlopeAngle, verts, nverts, tris, ntris, tri_areas.ptrw()); ERR_FAIL_COND(!rcRasterizeTriangles(&ctx, verts, nverts, tris, tri_areas.ptr(), ntris, *hf, cfg.walkableClimb)); } diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 384c20d79f..9fd41c1064 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -4855,8 +4855,8 @@ void SpatialEditor::_bind_methods() { void SpatialEditor::clear() { - settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 55.0)); - settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.1)); + settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 70.0)); + settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.05)); settings_zfar->set_value(EDITOR_DEF("editors/3d/default_z_far", 1500.0)); for (uint32_t i = 0; i < VIEWPORTS_COUNT; i++) { @@ -5099,14 +5099,14 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { settings_fov->set_max(MAX_FOV); settings_fov->set_min(MIN_FOV); settings_fov->set_step(0.01); - settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 55.0)); + settings_fov->set_value(EDITOR_DEF("editors/3d/default_fov", 70.0)); settings_vbc->add_margin_child(TTR("Perspective FOV (deg.):"), settings_fov); settings_znear = memnew(SpinBox); settings_znear->set_max(MAX_Z); settings_znear->set_min(MIN_Z); settings_znear->set_step(0.01); - settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.1)); + settings_znear->set_value(EDITOR_DEF("editors/3d/default_z_near", 0.05)); settings_vbc->add_margin_child(TTR("View Z-Near:"), settings_znear); settings_zfar = memnew(SpinBox); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 16b85121ef..46c47d8656 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -383,7 +383,7 @@ private: //read unzOpenCurrentFile(pkg); - unzReadCurrentFile(pkg, data.ptr(), data.size()); + unzReadCurrentFile(pkg, data.ptrw(), data.size()); unzCloseCurrentFile(pkg); FileAccess *f = FileAccess::open(dir.plus_file(path), FileAccess::WRITE); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 2ca621e24d..b23d914b88 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -290,6 +290,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (!scene) { EditorNode::get_singleton()->new_inherited_scene(); + break; } file->set_mode(EditorFileDialog::MODE_OPEN_FILE); |