From deeeaed3d858cf8be7d9fba294e96db3778aa587 Mon Sep 17 00:00:00 2001 From: Gaia Clary Date: Fri, 8 Feb 2013 19:52:02 +0000 Subject: [#33955] Collada Model Import Hangs Blender. Optimized Object import for better performance. Added logging messages --- source/blender/collada/DocumentImporter.cpp | 18 ++++++++++++++++-- source/blender/collada/collada_utils.cpp | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index da19fe11783..835812fddbb 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -76,6 +76,9 @@ extern "C" { #include "MEM_guardedalloc.h" +#include "WM_api.h" +#include "WM_types.h" + } #include "ExtraHandler.h" @@ -207,6 +210,12 @@ void DocumentImporter::finish() for (unsigned int i = 0; i < roots.getCount(); i++) { write_node(roots[i], NULL, sce, NULL, false); } + + Main *bmain = CTX_data_main(mContext); + DAG_scene_sort(bmain, sce); + DAG_ids_flush_update(bmain, 0); + WM_event_add_notifier(mContext, NC_OBJECT | ND_TRANSFORM, NULL); + } @@ -424,9 +433,16 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent Object *ob = NULL; bool is_joint = node->getType() == COLLADAFW::Node::JOINT; bool read_transform = true; + std::string id = node->getOriginalId(); + std::string name = node->getName(); std::vector *objects_done = new std::vector(); + fprintf(stderr, + "Writing node id='%s', name='%s'\n", + id.c_str(), + name.c_str()); + if (is_joint) { armature_importer.add_joint(node, parent_node == NULL || parent_node->getType() != COLLADAFW::Node::JOINT, par, sce); } @@ -449,8 +465,6 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map, material_texture_mapping_map); if (ob == NULL) { - std::string id = node->getOriginalId(); - std::string name = node->getName(); fprintf(stderr, "...contains a reference to an unknown instance_mesh.\n", id.c_str(), diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index 58e6301a084..9fdca048177 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -116,9 +116,12 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA; par->recalc |= OB_RECALC_OB; + /** done once after import DAG_scene_sort(bmain, sce); DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + */ + return true; } -- cgit v1.2.3