Commit: 0fc240dadb21652b4fed6d21dd4044ee71daede2 Author: gaiaclary Date: Mon Aug 25 19:03:02 2014 +0200 Branches: master https://developer.blender.org/rB0fc240dadb21652b4fed6d21dd4044ee71daede2
Fix T41513 Avoid adding NULL values into object lists when lamp- and controller-instances could not be created. =================================================================== M source/blender/collada/DocumentImporter.cpp M source/blender/collada/DocumentImporter.h =================================================================== diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 97d300e..cd006a4 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -483,6 +483,17 @@ void DocumentImporter::create_constraints(ExtraTags *et, Object *ob) } } +void DocumentImporter::report_unknown_reference(const COLLADAFW::Node &node, const std::string object_type) +{ + std::string id = node.getOriginalId(); + std::string name = node.getName(); + fprintf(stderr, + "<node id=\"%s\", name=\"%s\" >...contains a reference to an unknown %s.\n", + id.c_str(), + name.c_str(), + object_type.c_str()); +} + std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent_node, Scene *sce, Object *par, bool is_library_node) { Object *ob = NULL; @@ -538,10 +549,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA ob = mesh_importer.create_mesh_object(node, geom[geom_done], false, uid_material_map, material_texture_mapping_map); if (ob == NULL) { - fprintf(stderr, - "<node id=\"%s\", name=\"%s\" >...contains a reference to an unknown instance_mesh.\n", - id.c_str(), - name.c_str()); + report_unknown_reference(*node, "instance_mesh"); } else { objects_done->push_back(ob); @@ -554,9 +562,7 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA while (camera_done < camera.getCount()) { ob = create_camera_object(camera[camera_done], sce); if (ob == NULL) { - std::string id = node->getOriginalId(); - std::string name = node->getName(); - fprintf(stderr, "<node id=\"%s\", name=\"%s\" >...contains a reference to an unknown instance_camera.\n", id.c_str(), name.c_str()); + report_unknown_reference(*node, "instance_camera"); } else { objects_done->push_back(ob); @@ -568,18 +574,28 @@ std::vector<Object *> *DocumentImporter::write_node(COLLADAFW::Node *node, COLLA } while (lamp_done < lamp.getCount()) { ob = create_lamp_object(lamp[lamp_done], sce); - objects_done->push_back(ob); - if (parent_node == NULL) { - root_objects->push_back(ob); + if (ob == NULL) { + report_unknown_reference(*node, "instance_lamp"); + } + else { + objects_done->push_back(ob); + if (parent_node == NULL) { + root_objects->push_back(ob); + } } ++lamp_done; } while (controller_done < controller.getCount()) { COLLADAFW::InstanceGeometry *geom = (COLLADAFW::InstanceGeometry *)controller[controller_done]; ob = mesh_importer.create_mesh_object(node, geom, true, uid_material_map, material_texture_mapping_map); - objects_done->push_back(ob); - if (parent_node == NULL) { - root_objects->push_back(ob); + if (ob == NULL) { + report_unknown_reference(*node, "instance_controller"); + } + else { + objects_done->push_back(ob); + if (parent_node == NULL) { + root_objects->push_back(ob); + } } ++controller_done; } diff --git a/source/blender/collada/DocumentImporter.h b/source/blender/collada/DocumentImporter.h index 96aa7eb..5a7df9a 100644 --- a/source/blender/collada/DocumentImporter.h +++ b/source/blender/collada/DocumentImporter.h @@ -171,6 +171,8 @@ private: std::map<COLLADAFW::UniqueId, const COLLADAFW::Object*> FW_object_map; std::string import_from_version; + + void report_unknown_reference(const COLLADAFW::Node &node, const std::string object_type); }; #endif _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs