[Bf-blender-cvs] [bb83bdf] master: Fix T38366: export collada crash - if you set a keyframe
Bastien Montagne
noreply at git.blender.org
Sun Jan 26 16:08:02 CET 2014
Commit: bb83bdf89123690e99ef36afd24a93246685dc68
Author: Bastien Montagne
Date: Sun Jan 26 16:06:47 2014 +0100
https://developer.blender.org/rBbb83bdf89123690e99ef36afd24a93246685dc68
Fix T38366: export collada crash - if you set a keyframe
Don't assume all objects have a valid animdata...
===================================================================
M source/blender/collada/AnimationExporter.cpp
===================================================================
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp
index 559b180..7e90f05 100644
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@ -1279,19 +1279,20 @@ char *AnimationExporter::extract_transform_name(char *rna_path)
//find keyframes of all the objects animations
void AnimationExporter::find_frames(Object *ob, std::vector<float> &fra)
{
- FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
-
- for (; fcu; fcu = fcu->next) {
+ if (ob->adt && ob->adt->action) {
+ FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
- for (unsigned int i = 0; i < fcu->totvert; i++) {
- float f = fcu->bezt[i].vec[1][0];
- if (std::find(fra.begin(), fra.end(), f) == fra.end())
- fra.push_back(f);
+ for (; fcu; fcu = fcu->next) {
+ for (unsigned int i = 0; i < fcu->totvert; i++) {
+ float f = fcu->bezt[i].vec[1][0];
+ if (std::find(fra.begin(), fra.end(), f) == fra.end())
+ fra.push_back(f);
+ }
}
- }
- // keep the keys in ascending order
- std::sort(fra.begin(), fra.end());
+ // keep the keys in ascending order
+ std::sort(fra.begin(), fra.end());
+ }
}
@@ -1371,24 +1372,26 @@ void AnimationExporter::find_rotation_frames(Object *ob, std::vector<float> &fra
void AnimationExporter::find_frames(Object *ob, std::vector<float> &fra, const char *prefix, const char *tm_name)
{
- FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
-
- for (; fcu; fcu = fcu->next) {
- if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix)))
- continue;
-
- char *name = extract_transform_name(fcu->rna_path);
- if (!strcmp(name, tm_name)) {
- for (unsigned int i = 0; i < fcu->totvert; i++) {
- float f = fcu->bezt[i].vec[1][0];
- if (std::find(fra.begin(), fra.end(), f) == fra.end())
- fra.push_back(f);
+ if (ob->adt && ob->adt->action) {
+ FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
+
+ for (; fcu; fcu = fcu->next) {
+ if (prefix && strncmp(prefix, fcu->rna_path, strlen(prefix)))
+ continue;
+
+ char *name = extract_transform_name(fcu->rna_path);
+ if (!strcmp(name, tm_name)) {
+ for (unsigned int i = 0; i < fcu->totvert; i++) {
+ float f = fcu->bezt[i].vec[1][0];
+ if (std::find(fra.begin(), fra.end(), f) == fra.end())
+ fra.push_back(f);
+ }
}
}
- }
- // keep the keys in ascending order
- std::sort(fra.begin(), fra.end());
+ // keep the keys in ascending order
+ std::sort(fra.begin(), fra.end());
+ }
}
void AnimationExporter::write_bone_animation(Object *ob_arm, Bone *bone)
More information about the Bf-blender-cvs
mailing list