diff options
author | Gaia Clary <gaia.clary@machinimatrix.org> | 2012-08-05 14:23:34 +0400 |
---|---|---|
committer | Gaia Clary <gaia.clary@machinimatrix.org> | 2012-08-05 14:23:34 +0400 |
commit | aff4c781eb27ea88a0bde0e8e0fef1691488841e (patch) | |
tree | 81ad510cbbf52914837cac036ce6dd9b44a502f6 /source/blender/collada/AnimationImporter.cpp | |
parent | ca382a8d2a5093d139859f39e26337f92b94d151 (diff) |
COLLADA: #29058 Fixed crash when illegal reference to non existing camera object is found. And report a warning to the console)
Diffstat (limited to 'source/blender/collada/AnimationImporter.cpp')
-rw-r--r-- | source/blender/collada/AnimationImporter.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 3b5b96bc544..af6d70ecca0 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -804,8 +804,15 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node, AnimationImporter::AnimMix *animType = get_animation_type(node, FW_object_map); bool is_joint = node->getType() == COLLADAFW::Node::JOINT; - COLLADAFW::Node *root = root_map.find(node->getUniqueId()) == root_map.end() ? node : root_map[node->getUniqueId()]; - Object *ob = is_joint ? armature_importer->get_armature_for_joint(root) : object_map.find(node->getUniqueId())->second; + COLLADAFW::UniqueId uid = node->getUniqueId(); + COLLADAFW::Node *root = root_map.find(uid) == root_map.end() ? node : root_map[uid]; + + Object *ob; + if(is_joint) + ob = armature_importer->get_armature_for_joint(root); + else + ob = object_map.find(uid) == object_map.end() ? NULL : object_map.find(uid)->second; + if (!ob) { fprintf(stderr, "cannot find Object for Node with id=\"%s\"\n", node->getOriginalId().c_str()); return; @@ -1179,6 +1186,11 @@ AnimationImporter::AnimMix *AnimationImporter::get_animation_type(const COLLADAF const COLLADAFW::InstanceCameraPointerArray& nodeCameras = node->getInstanceCameras(); for (unsigned int i = 0; i < nodeCameras.getCount(); i++) { const COLLADAFW::Camera *camera = (COLLADAFW::Camera *) FW_object_map[nodeCameras[i]->getInstanciatedObjectId()]; + if ( camera == NULL ) { + // Can happen if the node refers to an unknown camera. + continue; + } + const bool is_perspective_type = camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE; int addition; |