[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46205] trunk/blender/source/blender/ collada: Fix #31089: collada file crashing on importing file with unknown/ unsupported animation data.

Brecht Van Lommel brechtvanlommel at pandora.be
Wed May 2 20:11:10 CEST 2012


Revision: 46205
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46205
Author:   blendix
Date:     2012-05-02 18:11:09 +0000 (Wed, 02 May 2012)
Log Message:
-----------
Fix #31089: collada file crashing on importing file with unknown/unsupported animation data.

Modified Paths:
--------------
    trunk/blender/source/blender/collada/AnimationImporter.cpp
    trunk/blender/source/blender/collada/AnimationImporter.h

Modified: trunk/blender/source/blender/collada/AnimationImporter.cpp
===================================================================
--- trunk/blender/source/blender/collada/AnimationImporter.cpp	2012-05-02 18:08:55 UTC (rev 46204)
+++ trunk/blender/source/blender/collada/AnimationImporter.cpp	2012-05-02 18:11:09 UTC (rev 46205)
@@ -438,6 +438,16 @@
 	}
 }
 
+void AnimationImporter::unused_fcurve(std::vector<FCurve*>* curves)
+{
+	// when an error happens and we can't actually use curve remove it from unused_curves
+	std::vector<FCurve*>::iterator it;
+	for (it = curves->begin(); it != curves->end(); it++) {
+		FCurve *fcu = *it;
+		unused_curves.erase(std::remove(unused_curves.begin(), unused_curves.end(), fcu), unused_curves.end());
+	}
+}
+
 void AnimationImporter::find_frames( std::vector<float>* frames, std::vector<FCurve*>* curves)
 {
 	std::vector<FCurve*>::iterator iter;
@@ -499,6 +509,7 @@
 			modify_fcurve(curves, rna_path, -1 );
 			break;
 		default:
+			unused_fcurve(curves);
 			fprintf(stderr, "AnimationClass %d is not supported for %s.\n",
 				binding->animationClass, loc ? "TRANSLATE" : "SCALE");
 				}
@@ -534,10 +545,13 @@
 			else if (COLLADABU::Math::Vector3::UNIT_Z == axis) {
 				modify_fcurve(curves, rna_path, 2 );
 			}
+			else
+				unused_fcurve(curves);
 			break;
 		case COLLADAFW::AnimationList::AXISANGLE:
 			// TODO convert axis-angle to quat? or XYZ?
 		default:
+			unused_fcurve(curves);
 			fprintf(stderr, "AnimationClass %d is not supported for ROTATE transformation.\n",
 				binding->animationClass);
 				}
@@ -553,9 +567,11 @@
 
 			}
 			}*/
+			unused_fcurve(curves);
 			break;
 		case COLLADAFW::Transformation::SKEW:
 		case COLLADAFW::Transformation::LOOKAT:
+			unused_fcurve(curves);
 			fprintf(stderr, "Animation of SKEW and LOOKAT transformations is not supported yet.\n");
 			break;
 	}
@@ -591,6 +607,7 @@
 			break;
 
 		default:
+			unused_fcurve(&animcurves);
 			fprintf(stderr, "AnimationClass %d is not supported for %s.\n",
 				bindings[j].animationClass, "COLOR" );
 		}

Modified: trunk/blender/source/blender/collada/AnimationImporter.h
===================================================================
--- trunk/blender/source/blender/collada/AnimationImporter.h	2012-05-02 18:08:55 UTC (rev 46204)
+++ trunk/blender/source/blender/collada/AnimationImporter.h	2012-05-02 18:11:09 UTC (rev 46205)
@@ -165,6 +165,7 @@
 	int setAnimType ( const COLLADAFW::Animatable * prop, int type, int addition);
 	
 	void modify_fcurve(std::vector<FCurve*>* curves, const char* rna_path, int array_index );
+	void unused_fcurve(std::vector<FCurve*>* curves );
 	// prerequisites:
 	// animlist_map - map animlist id -> animlist
 	// curve_map - map anim id -> curve(s)




More information about the Bf-blender-cvs mailing list