diff options
Diffstat (limited to 'source/blender/collada/AnimationExporter.cpp')
-rw-r--r-- | source/blender/collada/AnimationExporter.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 97d3b6b29b8..1196b3dfbe8 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -34,10 +34,11 @@ void forEachObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set) } } -bool AnimationExporter::exportAnimations(Scene *sce) +bool AnimationExporter::exportAnimations(EvaluationContext *eval_ctx, Scene *sce) { bool has_animations = hasAnimations(sce); if (has_animations) { + this->eval_ctx = eval_ctx; this->scene = sce; openLibrary(); @@ -214,7 +215,7 @@ void AnimationExporter::export_sampled_matrix_animation(Object *ob, std::vector< for (std::vector<float>::iterator ctime = ctimes.begin(); ctime != ctimes.end(); ++ctime) { float fmat[4][4]; - bc_update_scene(scene, *ctime); + bc_update_scene(eval_ctx, scene, *ctime); BKE_object_matrix_local_get(ob, fmat); if (this->export_settings->limit_precision) bc_sanitize_mat(fmat, 6); @@ -246,7 +247,7 @@ void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::ve float fsize[3]; float feul[3]; - bc_update_scene(scene, *ctime); + bc_update_scene(eval_ctx, scene, *ctime); BKE_object_matrix_local_get(ob, fmat); mat4_decompose(floc, fquat, fsize, fmat); quat_to_eul(feul, fquat); @@ -402,7 +403,7 @@ void AnimationExporter::export_morph_animation(Object *ob) void AnimationExporter::make_anim_frames_from_targets(Object *ob, std::vector<float> &frames ) { - ListBase *conlist = get_active_constraints(ob); + ListBase *conlist = get_active_constraints(this->eval_ctx, ob); if (conlist == NULL) return; bConstraint *con; for (con = (bConstraint *)conlist->first; con; con = con->next) { @@ -721,7 +722,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B if (flag & ARM_RESTPOS) { arm->flag &= ~ARM_RESTPOS; - BKE_pose_where_is(scene, ob_arm); + BKE_pose_where_is(eval_ctx, scene, ob_arm); } if (fra.size()) { @@ -730,7 +731,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B if (flag & ARM_RESTPOS) arm->flag = flag; - BKE_pose_where_is(scene, ob_arm); + BKE_pose_where_is(eval_ctx, scene, ob_arm); } void AnimationExporter::dae_baked_animation(std::vector<float> &fra, Object *ob_arm, Bone *bone) @@ -1005,7 +1006,7 @@ std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemanti void AnimationExporter::evaluate_anim_with_constraints(Object *ob, float ctime) { BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL); - ListBase *conlist = get_active_constraints(ob); + ListBase *conlist = get_active_constraints(this->eval_ctx, ob); bConstraint *con; for (con = (bConstraint *)conlist->first; con; con = con->next) { ListBase targets = { NULL, NULL }; @@ -1021,7 +1022,7 @@ void AnimationExporter::evaluate_anim_with_constraints(Object *ob, float ctime) if (obtar) { BKE_animsys_evaluate_animdata(scene, &obtar->id, obtar->adt, ctime, ADT_RECALC_ANIM); - BKE_object_where_is_calc_time(scene, obtar, ctime); + BKE_object_where_is_calc_time(this->eval_ctx, scene, obtar, ctime); } } @@ -1029,7 +1030,7 @@ void AnimationExporter::evaluate_anim_with_constraints(Object *ob, float ctime) cti->flush_constraint_targets(con, &targets, 1); } } - BKE_object_where_is_calc_time(scene, ob, ctime); + BKE_object_where_is_calc_time(this->eval_ctx, scene, ob, ctime); } /* @@ -1315,15 +1316,16 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj float frame = *it; float ctime = BKE_scene_frame_get_from_ctime(scene, frame); - bc_update_scene(scene, ctime); + bc_update_scene(eval_ctx, scene, ctime); if (is_bone_animation) { + if (pchan->flag & POSE_CHAIN) { enable_fcurves(ob->adt->action, NULL); BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL); - BKE_pose_where_is(scene, ob); + BKE_pose_where_is(eval_ctx, scene, ob); } else { - BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); + BKE_pose_where_is_bone(eval_ctx, scene, ob, pchan, ctime, 1); } // compute bone local mat @@ -1841,7 +1843,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo // exit rest position if (flag & ARM_RESTPOS) { arm->flag &= ~ARM_RESTPOS; - BKE_pose_where_is(scene, ob_arm); + BKE_pose_where_is(eval_ctx, scene, ob_arm); } //v array will hold all values which will be exported. if (fra.size()) { @@ -1871,7 +1873,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo // restore restpos if (flag & ARM_RESTPOS) arm->flag = flag; - BKE_pose_where_is(scene, ob_arm); + BKE_pose_where_is(eval_ctx, scene, ob_arm); } void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan) @@ -1896,7 +1898,7 @@ void AnimationExporter::sample_animation(float *v, std::vector<float> &frames, i BKE_animsys_evaluate_animdata(scene, &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); - BKE_pose_where_is_bone(scene, ob_arm, pchan, ctime, 1); + BKE_pose_where_is_bone(eval_ctx, scene, ob_arm, pchan, ctime, 1); // compute bone local mat if (bone->parent) { |