[Bf-blender-cvs] [7daeb1f9aee] collada: Merge 'master' into 'collada'

Brecht Van Lommel noreply at git.blender.org
Thu May 2 16:10:48 CEST 2019


Commit: 7daeb1f9aee284d958abe87622b43c70c21af967
Author: Brecht Van Lommel
Date:   Thu May 2 16:05:02 2019 +0200
Branches: collada
https://developer.blender.org/rB7daeb1f9aee284d958abe87622b43c70c21af967

Merge 'master' into 'collada'

===================================================================



===================================================================

diff --cc source/blender/collada/AnimationClipExporter.h
index 8c2825599eb,6d67ab7c406..ead894dc941
--- a/source/blender/collada/AnimationClipExporter.h
+++ b/source/blender/collada/AnimationClipExporter.h
@@@ -20,25 -20,27 +20,27 @@@
  
  #include "COLLADASWLibraryAnimationClips.h"
  
+ class AnimationClipExporter : COLLADASW::LibraryAnimationClips {
+  private:
+   Depsgraph *depsgraph;
+   Scene *scene;
+   COLLADASW::StreamWriter *sw;
 -  const ExportSettings *export_settings;
++  BCExportSettings &export_settings;
+   std::vector<std::vector<std::string>> anim_meta;
  
- class AnimationClipExporter:COLLADASW::LibraryAnimationClips {
- private:
- 	Depsgraph *depsgraph;
- 	Scene *scene;
- 	COLLADASW::StreamWriter *sw;
- 	BCExportSettings &export_settings;
- 	std::vector<std::vector<std::string>> anim_meta;
+  public:
+   AnimationClipExporter(Depsgraph *depsgraph,
+                         COLLADASW::StreamWriter *sw,
 -                        const ExportSettings *export_settings,
++                        BCExportSettings &export_settings,
+                         std::vector<std::vector<std::string>> anim_meta)
+       : COLLADASW::LibraryAnimationClips(sw),
+         depsgraph(depsgraph),
+         scene(nullptr),
+         sw(sw),
+         export_settings(export_settings),
+         anim_meta(anim_meta)
+   {
+   }
  
- public:
- 
- 	AnimationClipExporter(Depsgraph *depsgraph , COLLADASW::StreamWriter *sw, BCExportSettings &export_settings, std::vector<std::vector<std::string>> anim_meta) :
- 		COLLADASW::LibraryAnimationClips(sw),
- 		depsgraph(depsgraph),
- 		scene(nullptr),
- 		sw(sw),
- 		export_settings(export_settings),
- 		anim_meta(anim_meta)
- 	{}
- 
- 	void exportAnimationClips(Scene *sce);
+   void exportAnimationClips(Scene *sce);
  };
diff --cc source/blender/collada/AnimationExporter.cpp
index b2eb9c1fbdb,bfef2d76a3d..c9829b1f706
--- a/source/blender/collada/AnimationExporter.cpp
+++ b/source/blender/collada/AnimationExporter.cpp
@@@ -78,85 -77,90 +77,86 @@@ void AnimationExporter::close_animation
  
  bool AnimationExporter::exportAnimations()
  {
- 	Scene *sce = export_settings.get_scene();
 -  Scene *sce = blender_context.get_scene();
++  Scene *sce = export_settings.get_scene();
  
- 	LinkNode &export_set = *this->export_settings.get_export_set();
- 	bool has_anim_data = bc_has_animations(sce, export_set);
- 	int animation_count = 0;
- 	if (has_anim_data) {
 -  LinkNode &export_set = *this->export_settings->export_set;
++  LinkNode &export_set = *this->export_settings.get_export_set();
+   bool has_anim_data = bc_has_animations(sce, export_set);
+   int animation_count = 0;
+   if (has_anim_data) {
  
- 		BCObjectSet animated_subset;
- 		BCAnimationSampler::get_animated_from_export_set(animated_subset, export_set);
- 		animation_count = animated_subset.size();
- 		BCAnimationSampler animation_sampler(export_settings, animated_subset);
+     BCObjectSet animated_subset;
+     BCAnimationSampler::get_animated_from_export_set(animated_subset, export_set);
+     animation_count = animated_subset.size();
 -    BCAnimationSampler animation_sampler(blender_context, animated_subset);
++    BCAnimationSampler animation_sampler(export_settings, animated_subset);
  
- 		try {
- 			animation_sampler.sample_scene(export_settings, /*keyframe_at_end = */ true);
+     try {
 -      animation_sampler.sample_scene(export_settings->sampling_rate,
 -                                     /*keyframe_at_end = */ true,
 -                                     export_settings->open_sim,
 -                                     export_settings->keep_keyframes,
 -                                     export_settings->export_animation_type);
++      animation_sampler.sample_scene(export_settings, /*keyframe_at_end = */ true);
  
- 			openLibrary();
+       openLibrary();
  
- 			BCObjectSet::iterator it;
- 			for (it = animated_subset.begin(); it != animated_subset.end(); ++it) {
- 				Object *ob = *it;
- 				exportAnimation(ob, animation_sampler);
- 			}
- 		}
- 		catch (std::invalid_argument &iae)
- 		{
- 			fprintf(stderr, "Animation export interrupted");
- 			fprintf(stderr, "Exception was: %s", iae.what());
- 		}
+       BCObjectSet::iterator it;
+       for (it = animated_subset.begin(); it != animated_subset.end(); ++it) {
+         Object *ob = *it;
+         exportAnimation(ob, animation_sampler);
+       }
+     }
+     catch (std::invalid_argument &iae) {
+       fprintf(stderr, "Animation export interrupted");
+       fprintf(stderr, "Exception was: %s", iae.what());
+     }
  
- 		closeLibrary();
+     closeLibrary();
  
  #if 0
- 		/* TODO: If all actions shall be exported, we need to call the
- 		 * AnimationClipExporter which will figure out which actions
- 		 * need to be exported for which objects
- 		 */
- 		if (this->export_settings->include_all_actions) {
- 			AnimationClipExporter ace(eval_ctx, sw, export_settings, anim_meta);
- 			ace.exportAnimationClips(sce);
- 		}
+     /* TODO: If all actions shall be exported, we need to call the
+      * AnimationClipExporter which will figure out which actions
+      * need to be exported for which objects
+      */
+     if (this->export_settings->include_all_actions) {
+       AnimationClipExporter ace(eval_ctx, sw, export_settings, anim_meta);
+       ace.exportAnimationClips(sce);
+     }
  #endif
- 	}
- 	return animation_count;
+   }
+   return animation_count;
  }
  
  /* called for each exported object */
  void AnimationExporter::exportAnimation(Object *ob, BCAnimationSampler &sampler)
  {
- 	bool container_is_open = false;
+   bool container_is_open = false;
  
- 	//Transform animations (trans, rot, scale)
- 	container_is_open = open_animation_container(container_is_open, ob);
+   //Transform animations (trans, rot, scale)
+   container_is_open = open_animation_container(container_is_open, ob);
  
- 	/* Now take care of the Object Animations
- 	 * Note: For Armatures the skeletal animation has already been exported (see above)
- 	 * However Armatures also can have Object animation.
- 	 */
- 	bool export_as_matrix = this->export_settings.get_export_transformation_type() == BC_TRANSFORMATION_TYPE_MATRIX;
+   /* Now take care of the Object Animations
+    * Note: For Armatures the skeletal animation has already been exported (see above)
+    * However Armatures also can have Object animation.
+    */
 -  bool export_as_matrix = this->export_settings->export_transformation_type ==
++  bool export_as_matrix = this->export_settings.get_export_transformation_type() ==
+                           BC_TRANSFORMATION_TYPE_MATRIX;
  
- 	if (export_as_matrix) {
- 		export_matrix_animation(ob, sampler); // export all transform_curves as one single matrix animation
- 	}
+   if (export_as_matrix) {
+     export_matrix_animation(
+         ob, sampler);  // export all transform_curves as one single matrix animation
+   }
  
- 	export_curve_animation_set(ob, sampler, export_as_matrix);
+   export_curve_animation_set(ob, sampler, export_as_matrix);
  
- 	if (ob->type == OB_ARMATURE) {
+   if (ob->type == OB_ARMATURE) {
  
  #ifdef WITH_MORPH_ANIMATION
- 		/* TODO: This needs to be handled by extra profiles, postponed for now */
- 		export_morph_animation(ob);
+     /* TODO: This needs to be handled by extra profiles, postponed for now */
+     export_morph_animation(ob);
  #endif
  
- 		/* Export skeletal animation (if any) */
- 		bArmature *arm = (bArmature *)ob->data;
- 		for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next)
- 			export_bone_animations_recursive(ob, root_bone, sampler);
- 	}
+     /* Export skeletal animation (if any) */
+     bArmature *arm = (bArmature *)ob->data;
+     for (Bone *root_bone = (Bone *)arm->bonebase.first; root_bone; root_bone = root_bone->next)
+       export_bone_animations_recursive(ob, root_bone, sampler);
+   }
  
- 	close_animation_container(container_is_open);
+   close_animation_container(container_is_open);
  }
  
  /*
@@@ -169,101 -173,92 +169,106 @@@
   * And when parent inverse matrices are involved (when exporting
   * object hierarchies)
   */
- void AnimationExporter::export_curve_animation_set(Object *ob, BCAnimationSampler &sampler, bool export_as_matrix)
+ void AnimationExporter::export_curve_animation_set(Object *ob,
+                                                    BCAnimationSampler &sampler,
+                                                    bool export_as_matrix)
  {
- 	BCAnimationCurveMap *curves = sampler.get_curves(ob);
- 	bool keep_flat_curves = this->export_settings.get_keep_flat_curves();
- 
- 	BCAnimationCurveMap::iterator it;
- 	for (it = curves->begin(); it != curves->end(); ++it) {
- 		BCAnimationCurve &curve = *it->second;
- 		if (curve.get_channel_target() == "rotation_quaternion") {
- 			/*
- 			   Can not export Quaternion animation in Collada as far as i know)
- 			   Maybe automatically convert to euler rotation?
- 			   Discard for now.
- 			*/
- 			continue;
- 		}
- 
- 		if (export_as_matrix && curve.is_transform_curve()) {
- 			/* All Transform curves will be exported within a single matrix animation,
- 			 * see export_matrix_animation()
- 			 * No need to export the curves here again.
- 			 */
- 			continue;
- 		}
- 
- 		if (!keep_flat_curves && !curve.is_animated()) {
- 			continue;
- 		}
- 
- 		BCAnimationCurve *mcurve = get_modified_export_curve(ob, curve, *curves);
- 		if (mcurve) {
- 			export_curve_animation(ob, *mcurve);
- 			delete mcurve;
- 		}
- 		else {
- 			export_curve_animation(ob, curve);
- 		}
- 	}
+   BCAnimationCurveMap *curves = sampler.get_curves(ob);
 -  bool keep_flat_curves = this->export_settings->keep_flat_curves;
++  bool keep_flat_curves = this->export_settings.get_keep_flat_curves();
+ 
+   BCAnimationCurveMap::iterator it;
+   for (it = curves->begin(); it != curves->end(); ++it) {
+     BCAnimationCurve &curve = *it->second;
+     if (curve.get_channel_target() == "rotation_quaternion") {
+       /*
+          Can not export Quaternion animation in Collada as far as i know)
+          Maybe automatically convert to euler rotation?
+          Discard for now.
+       */
+       continue;
+     }
+ 
+     if (export_as_matrix && curve.is_transform_c

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list