Merge branch 'master' into blender2.8
[blender.git] / source / blender / collada / AnimationExporter.cpp
index 54da8b981389374fdfe736ddab20df74895ce547..3e57dafed19a31a5b7c24381d0677fa2dfc8a314 100644 (file)
@@ -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();
@@ -216,7 +217,7 @@ void AnimationExporter::export_sampled_matrix_animation(Object *ob, std::vector<
                float fmat[4][4];
                float outmat[4][4];
 
-               bc_update_scene(scene, *ctime);
+               bc_update_scene(eval_ctx, scene, *ctime);
                BKE_object_matrix_local_get(ob, fmat);
 
                converter.mat4_to_dae(outmat, fmat);
@@ -251,7 +252,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);
@@ -408,7 +409,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) {
@@ -727,7 +728,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()) {
@@ -736,7 +737,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)
@@ -1011,7 +1012,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 };
@@ -1027,7 +1028,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);
                                }
                        }
 
@@ -1035,7 +1036,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);
 }
 
 /*
@@ -1321,15 +1322,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
@@ -1847,7 +1849,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()) {
@@ -1877,7 +1879,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)
@@ -1902,7 +1904,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) {
@@ -1956,6 +1958,9 @@ bool AnimationExporter::validateConstraints(bConstraint *con)
  */
 void AnimationExporter::calc_obmat_at_time(Object *ob, float ctime )
 {
+<<<<<<< HEAD
+       ListBase *conlist = get_active_constraints(this->eval_ctx, ob);
+=======
        BKE_scene_frame_set(scene, ctime);
 
        Main *bmain = bc_get_main();
@@ -1963,6 +1968,7 @@ void AnimationExporter::calc_obmat_at_time(Object *ob, float ctime )
        BKE_scene_update_for_newframe(ev_context, bmain, scene, scene->lay);
 
        ListBase *conlist = get_active_constraints(ob);
+>>>>>>> master
        bConstraint *con;
        for (con = (bConstraint *)conlist->first; con; con = con->next) {
                ListBase targets = {NULL, NULL};
@@ -1978,7 +1984,7 @@ void AnimationExporter::calc_obmat_at_time(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(eval_ctx, scene, obtar, ctime);
                                }
                        }
 
@@ -1986,7 +1992,12 @@ void AnimationExporter::calc_obmat_at_time(Object *ob, float ctime )
                                cti->flush_constraint_targets(con, &targets, 1);
                }
        }
+<<<<<<< HEAD
+       BKE_object_where_is_calc_time(eval_ctx, scene, ob, ctime);
+       copy_m4_m4(mat, ob->obmat);
+=======
        BKE_object_where_is_calc_time(scene, ob, ctime);
+>>>>>>> master
 }
 #endif