Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaia Clary <gaia.clary@machinimatrix.org>2012-08-05 14:23:34 +0400
committerGaia Clary <gaia.clary@machinimatrix.org>2012-08-05 14:23:34 +0400
commitaff4c781eb27ea88a0bde0e8e0fef1691488841e (patch)
tree81ad510cbbf52914837cac036ce6dd9b44a502f6 /source/blender/collada
parentca382a8d2a5093d139859f39e26337f92b94d151 (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')
-rw-r--r--source/blender/collada/AnimationImporter.cpp16
-rw-r--r--source/blender/collada/DocumentImporter.cpp10
2 files changed, 22 insertions, 4 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;
diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp
index 6aa600cabe2..7cfce9d2526 100644
--- a/source/blender/collada/DocumentImporter.cpp
+++ b/source/blender/collada/DocumentImporter.cpp
@@ -308,7 +308,7 @@ Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera
{
const COLLADAFW::UniqueId& cam_uid = camera->getInstanciatedObjectId();
if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) {
- fprintf(stderr, "Couldn't find camera by UID.\n");
+ // fprintf(stderr, "Couldn't find camera by UID.\n");
return NULL;
}
@@ -443,7 +443,13 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent
}
while (camera_done < camera.getCount()) {
ob = create_camera_object(camera[camera_done], sce);
- objects_done->push_back(ob);
+ 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());
+ }
+ else
+ objects_done->push_back(ob);
++camera_done;
}
while (lamp_done < lamp.getCount()) {