diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-04-08 01:46:55 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-04-08 01:46:55 -0300 |
commit | e18c6ef63bb57290b023fde01391f8bdcdfe5aed (patch) | |
tree | 66ce5152cc84c6b503c86cea2ddc7b4323bc8021 /tools/editor/io_plugins | |
parent | b016f3898b9b54a744b022c12d80ba9905477e86 (diff) |
-Better Collada now keeps mesh names properly from blender, makes the "overwrite existing, keep materials" import mode work properly.
Diffstat (limited to 'tools/editor/io_plugins')
-rw-r--r-- | tools/editor/io_plugins/editor_scene_import_plugin.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/tools/editor/io_plugins/editor_scene_import_plugin.cpp b/tools/editor/io_plugins/editor_scene_import_plugin.cpp index 06c9a12eb3..d01c2af907 100644 --- a/tools/editor/io_plugins/editor_scene_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_scene_import_plugin.cpp @@ -2130,14 +2130,14 @@ void EditorSceneImportPlugin::_add_new_nodes(Node *p_node,Node *p_imported,Node Node *imported_node = p_imported->get_child(i); if (imported_node->get_owner()!=p_imported_scene) { - print_line("skipping because not imported at "+String(imported_node->get_name())); + // print_line("skipping because not imported at "+String(imported_node->get_name())); continue; //end of the road } Vector<StringName> nn; nn.push_back(imported_node->get_name()); NodePath imported_path(nn,false); - print_line("check for: "+String(imported_path)); + //print_line("check for: "+String(imported_path)); if (!p_node->has_node(imported_path) && !checked_nodes.has(imported_node)) { //not there, re-add it @@ -2147,11 +2147,11 @@ void EditorSceneImportPlugin::_add_new_nodes(Node *p_node,Node *p_imported,Node if (o) n=o->cast_to<Node>(); - print_line("creating node of same type.."); + //print_line("creating node of same type.."); if (n) { - print_line("copy props and add"); + //print_line("copy props and add"); List<PropertyInfo> pl; imported_node->get_property_list(&pl); for(List<PropertyInfo>::Element *E=pl.front();E;E=E->next()) { @@ -2165,7 +2165,7 @@ void EditorSceneImportPlugin::_add_new_nodes(Node *p_node,Node *p_imported,Node } } else { - print_line("already exists"); + //print_line("already exists"); } @@ -2223,27 +2223,33 @@ void EditorSceneImportPlugin::_scan_materials(Node*p_base,Node *p_node,Map<Strin void EditorSceneImportPlugin::_apply_materials(Node*p_base,Node *p_node,Map<String,Ref<Material> > &mesh_materials,Map<String,Ref<Material> >& override_materials,Set<Ref<Mesh> >& meshes_processed) { - if (!p_base && p_node->get_owner()!=p_base) + if (p_node!=p_base && p_node->get_owner()!=p_base) return; MeshInstance *mi=p_node->cast_to<MeshInstance>(); if (mi) { + print_line("is mesh "+String(p_node->get_name())); String path = p_base->get_path_to(p_node); - if (override_materials.has(path)) + if (override_materials.has(path)) { + print_line("is in material overrides"); mi->set_material_override(override_materials[path]); + } Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_valid() && !meshes_processed.has(mesh)) { + print_line("mesh was not processed"); meshes_processed.insert(mesh); for(int i=0;i<mesh->get_surface_count();i++) { String name = mesh->get_name()+":"+mesh->surface_get_name(i); + print_line("name for surface "+itos(i)+": "+name); if (mesh_materials.has(name)) { Ref<Material> mat = mesh_materials[name]; mesh->surface_set_material(i,mat); + print_line("overriding!"); } } } @@ -2260,9 +2266,19 @@ void EditorSceneImportPlugin::_merge_materials(Node *p_node,Node *p_imported) { Map<String,Ref<Material> > override_materials; _scan_materials(p_node,p_node,mesh_materials,override_materials); + + for (Map<String,Ref<Material> >::Element *E=mesh_materials.front();E;E=E->next()) { + print_line("Mats: "+String(E->key())); + } + + for (Map<String,Ref<Material> >::Element *E=override_materials.front();E;E=E->next()) { + print_line("Overrides: "+String(E->key())); + } + Set<Ref<Mesh> > mp; _apply_materials(p_imported,p_imported,mesh_materials,override_materials,mp); + } #if 0 |