merge from master
authorGaia Clary <gaia.clary@machinimatrix.org>
Mon, 26 Feb 2018 21:49:30 +0000 (22:49 +0100)
committerGaia Clary <gaia.clary@machinimatrix.org>
Mon, 26 Feb 2018 21:49:30 +0000 (22:49 +0100)
29 files changed:
doc/guides/blender-guardedalloc.txt
release/scripts/modules/bpy/path.py
release/scripts/presets/camera/1_colon_2.3_inch.py [moved from release/scripts/presets/camera/1__colon__2.3_inch.py with 100% similarity]
release/scripts/presets/camera/1_colon_2.5_inch.py [moved from release/scripts/presets/camera/1__colon__2.5_inch.py with 100% similarity]
release/scripts/presets/camera/2_colon_3_inch.py [moved from release/scripts/presets/camera/2__colon__3_inch.py with 100% similarity]
release/scripts/presets/camera/4_colon_3_inch.py [moved from release/scripts/presets/camera/4__colon__3_inch.py with 100% similarity]
source/blender/blenkernel/intern/particle_distribute.c
source/blender/blenkernel/intern/tracking_region_tracker.c
source/blender/blenlib/intern/storage.c
source/blender/collada/AnimationExporter.cpp
source/blender/collada/AnimationExporter.h
source/blender/collada/ControllerExporter.cpp
source/blender/collada/DocumentExporter.cpp
source/blender/collada/DocumentExporter.h
source/blender/collada/ExportSettings.h
source/blender/collada/SceneExporter.cpp
source/blender/collada/SceneExporter.h
source/blender/collada/collada.cpp
source/blender/collada/collada.h
source/blender/collada/collada_utils.cpp
source/blender/collada/collada_utils.h
source/blender/editors/animation/anim_filter.c
source/blender/editors/interface/interface_widgets.c
source/blender/editors/io/io_collada.c
source/blender/editors/space_graph/graph_utils.c
source/blender/editors/uvedit/uvedit_ops.c
source/blender/makesrna/intern/rna_scene_api.c
source/blenderplayer/bad_level_call_stubs/stubs.c
tests/python/collada/mesh/test_mesh_simple.py

index 44a9722a4e424e2313d513fe0f7e7502577d2ff7..3db647a4e7775291d53335e635e03cb3429c17c4 100644 (file)
@@ -1,7 +1,7 @@
 MEMORY MANAGEMENT IN BLENDER (guardedalloc)
 -------------------------------------------
 
-NOTE: This file does not cover memutil and smart pointers and rerefence counted
+NOTE: This file does not cover memutil and smart pointers and reference counted
       garbage collection, which are contained in the memutil module.
 
 Blender takes care of dynamic memory allocation using a set of own functions
index 0bfb14e4e0dd535fb717c803332238b5965acbea..a88e60d002203a218130f9f687df6e483f7d1d86 100644 (file)
@@ -187,7 +187,6 @@ clean_name._trans_cache = {}
 
 
 def _clean_utf8(name):
-    name = _os.path.splitext(basename(name))[0]
     if type(name) == bytes:
         return name.decode("utf8", "replace")
     else:
@@ -207,6 +206,9 @@ def display_name(name):
     mixed case names are kept as is. Intended for use with
     filenames and module names.
     """
+
+    name = _os.path.splitext(basename(name))[0]
+
     # string replacements
     for disp_value, file_value in _display_name_literals.items():
         name = name.replace(file_value, disp_value)
@@ -237,6 +239,7 @@ def display_name_from_filepath(name):
     ensured to be utf8 compatible.
     """
 
+    name = _os.path.splitext(basename(name))[0]
     name = _clean_utf8(name)
     return name
 
index 767a17a34e724a5621ce4f091dae9fa9494c3b3a..f411a605c7f648ce4e380a8947732fa564ff9122 100644 (file)
@@ -1101,7 +1101,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, Parti
                /* This is to address tricky issues with vertex-emitting when user tries (and expects) exact 1-1 vert/part
                 * distribution (see T47983 and its two example files). It allows us to consider pos as
                 * 'midpoint between v and v+1' (or 'p and p+1', depending whether we have more vertices than particles or not),
-                * and avoid stumbling over float imprecisions in element_sum.
+                * and avoid stumbling over float impression in element_sum.
                 * Note: moved face and volume distribution to this as well (instead of starting at zero),
                 * for the same reasons, see T52682. */
                pos = (totpart < totmapped) ? 0.5 / (double)totmapped : step * 0.5;  /* We choose the smaller step. */
index dd7def16ca8eb478ac6447e6cd278d1e5800eb1b..106dd125575ca4a0c5032be1c616fc485a6b1dab 100644 (file)
@@ -189,7 +189,7 @@ void tracking_configure_tracker(const MovieTrackingTrack *track, float *mask,
                options->image1_mask = NULL;
 }
 
-/* Peform tracking from a reference_marker to destination_ibuf.
+/* Perform tracking from a reference_marker to destination_ibuf.
  * Uses marker as an initial position guess.
  *
  * Returns truth if tracker returned success, puts result
index c08329ef34ff0ba442617dd69a7f8b2de0ad6460..f69b35ce5a935de574f9e10181f8f84118f53b58 100644 (file)
@@ -185,7 +185,7 @@ size_t BLI_file_size(const char *path)
 }
 
 /**
- * Returns the st_mode from statting the specified path name, or 0 if it couldn't be statted
+ * Returns the st_mode from stat-ing the specified path name, or 0 if stat fails
  * (most likely doesn't exist or no access).
  */
 int BLI_exists(const char *name)
index 24e5ecb8d1030a14cefb806586511ab1bf097072..a1497a0ab44e8da0861883d0d56e44a69e3ceebc 100644 (file)
@@ -34,7 +34,7 @@ void forEachObjectInExportSet(Scene *sce, Functor &f, LinkNode *export_set)
        }
 }
 
-bool AnimationExporter::exportAnimations(const struct EvaluationContext *eval_ctx, Scene *sce)
+bool AnimationExporter::exportAnimations(EvaluationContext *eval_ctx, Scene *sce)
 {
        bool has_animations = hasAnimations(sce);
        if (has_animations) {
@@ -50,7 +50,16 @@ bool AnimationExporter::exportAnimations(const struct EvaluationContext *eval_ct
        return has_animations;
 }
 
-
+bool AnimationExporter::is_flat_line(std::vector<float> &values, int channel_count)
+{
+       for (int i = 0; i < values.size(); i += channel_count) {
+               for (int j = 0; j < channel_count; j++) {
+                       if (!bc_in_range(values[j], values[i+j], 0.000001))
+                               return false;
+               }
+       }
+       return true;
+}
 /*
  *  This function creates a complete LINEAR Collada <Animation> Entry with all needed 
  *  <source>, <sampler>, and <channel> entries.
@@ -84,9 +93,11 @@ void AnimationExporter::create_sampled_animation(int channel_count,
        std::string axis_name,
        bool is_rot)
 {
-
        char anim_id[200];
 
+       if (is_flat_line(values, channel_count))
+               return;
+
        BLI_snprintf(anim_id, sizeof(anim_id), "%s_%s_%s", (char *)translate_id(ob_name).c_str(), label.c_str(), axis_name.c_str());
 
        openAnimation(anim_id, COLLADABU::Utils::EMPTY_STRING);
@@ -98,8 +109,10 @@ void AnimationExporter::create_sampled_animation(int channel_count,
        std::string output_id;
        if (channel_count == 1)
                output_id = create_source_from_array(COLLADASW::InputSemantic::OUTPUT, &values[0], values.size(), is_rot, anim_id, axis_name.c_str());
-       else if(channel_count = 3)
+       else if (channel_count == 3)
                output_id = create_xyz_source(&values[0], times.size(), anim_id);
+       else if (channel_count == 16)
+               output_id = create_4x4_source(times, values, anim_id);
 
        std::string sampler_id = std::string(anim_id) + SAMPLER_ID_SUFFIX;
        COLLADASW::LibraryAnimations::Sampler sampler(sw, sampler_id);
@@ -136,26 +149,38 @@ void AnimationExporter::create_sampled_animation(int channel_count,
 void AnimationExporter::export_keyframed_animation_set(Object *ob)
 {
        FCurve *fcu = (FCurve *)ob->adt->action->curves.first;
+       if (!fcu) {
+               return; /* object has no animation */
+       }
 
-       char *transformName;
-       while (fcu) {
-               //for armature animations as objects
-               if (ob->type == OB_ARMATURE)
-                       transformName = fcu->rna_path;
-               else
-                       transformName = extract_transform_name(fcu->rna_path);
+       if (this->export_settings->export_transformation_type == BC_TRANSFORMATION_TYPE_MATRIX) {
 
-               if (
-                       STREQ(transformName, "location") ||
-                       STREQ(transformName, "scale") ||
-                       (STREQ(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL) ||
-                       STREQ(transformName, "rotation_quaternion"))
-               {
-                       create_keyframed_animation(ob, fcu, transformName, false);
-               }
-               fcu = fcu->next;
+               std::vector<float> ctimes;
+               std::vector<float[4][4]> values;
+               find_keyframes(ob, ctimes);
+               if (ctimes.size() > 0)
+                       export_sampled_matrix_animation(ob, ctimes);
        }
+       else {
+               char *transformName;
+               while (fcu) {
+                       //for armature animations as objects
+                       if (ob->type == OB_ARMATURE)
+                               transformName = fcu->rna_path;
+                       else
+                               transformName = extract_transform_name(fcu->rna_path);
 
+                       if (
+                               STREQ(transformName, "location") ||
+                               STREQ(transformName, "scale") ||
+                               (STREQ(transformName, "rotation_euler") && ob->rotmode == ROT_MODE_EUL) ||
+                               STREQ(transformName, "rotation_quaternion"))
+                       {
+                               create_keyframed_animation(ob, fcu, transformName, false);
+                       }
+                       fcu = fcu->next;
+               }
+       }
 }
 
 /*
@@ -171,20 +196,53 @@ void AnimationExporter::export_keyframed_animation_set(Object *ob)
  * Also keyframed animation exports tend to break when negative scales are involved.
  */
 void AnimationExporter::export_sampled_animation_set(Object *ob)
+{
+       std::vector<float>ctimes;
+       find_sampleframes(ob, ctimes);
+       if (ctimes.size() > 0) {
+               if (this->export_settings->export_transformation_type == BC_TRANSFORMATION_TYPE_MATRIX)
+                       export_sampled_matrix_animation(ob, ctimes);
+               else
+                       export_sampled_transrotloc_animation(ob, ctimes);
+       }
+}
+
+void AnimationExporter::export_sampled_matrix_animation(Object *ob, std::vector<float> &ctimes)
+{
+       UnitConverter converter;
+
+       std::vector<float> values;
+
+       for (std::vector<float>::iterator ctime = ctimes.begin(); ctime != ctimes.end(); ++ctime) {
+               float fmat[4][4];
+               float outmat[4][4];
+
+               bc_update_scene(eval_ctx, scene, *ctime);
+               BKE_object_matrix_local_get(ob, fmat);
+               converter.mat4_to_dae(outmat, fmat);
+
+               if (this->export_settings->limit_precision)
+                       bc_sanitize_mat(outmat, 6);
+
+               for (int i = 0; i < 4; i++)
+                       for (int j = 0; j < 4; j++)
+                               values.push_back(outmat[j][i]);
+       }
+
+       std::string ob_name = id_name(ob);
+
+       create_sampled_animation(16, ctimes, values, ob_name, "transform", "", false);
+}
+
+void AnimationExporter::export_sampled_transrotloc_animation(Object *ob, std::vector<float> &ctimes)
 {
        static int LOC   = 0;
        static int EULX  = 1;
        static int EULY  = 2;
        static int EULZ  = 3;
        static int SCALE = 4;
-       static int TIME  = 5;
 
-       if (this->export_settings->sampling_rate < 1)
-               return; // to avoid infinite loop
-
-       std::vector<float> baked_curves[6];
-       std::vector<float> &ctimes = baked_curves[TIME];
-       find_sampleframes(ob, ctimes);
+       std::vector<float> baked_curves[5];
 
        for (std::vector<float>::iterator ctime = ctimes.begin(); ctime != ctimes.end(); ++ctime ) {
                float fmat[4][4];
@@ -193,7 +251,7 @@ void AnimationExporter::export_sampled_animation_set(Object *ob)
                float fsize[3];
                float feul[3];
 
-               evaluate_anim_with_constraints(ob, *ctime); // set object transforms to the frame
+               bc_update_scene(eval_ctx, scene, *ctime);
 
                BKE_object_matrix_local_get(ob, fmat);
                mat4_decompose(floc, fquat, fsize, fmat);
@@ -215,16 +273,16 @@ void AnimationExporter::export_sampled_animation_set(Object *ob)
 
        std::string ob_name = id_name(ob);
 
-       create_sampled_animation(3, baked_curves[TIME], baked_curves[SCALE], ob_name, "scale",   "", false);
-       create_sampled_animation(3, baked_curves[TIME], baked_curves[LOC],  ob_name, "location", "", false);
+       create_sampled_animation(3, ctimes, baked_curves[SCALE], ob_name, "scale",   "", false);
+       create_sampled_animation(3, ctimes, baked_curves[LOC],  ob_name, "location", "", false);
 
        /* Not sure how to export rotation as a 3channel animation, 
         * so separate into 3 single animations for now:
         */
 
-       create_sampled_animation(1, baked_curves[TIME], baked_curves[EULX], ob_name, "rotation", "X", true);
-       create_sampled_animation(1, baked_curves[TIME], baked_curves[EULY], ob_name, "rotation", "Y", true);
-       create_sampled_animation(1, baked_curves[TIME], baked_curves[EULZ], ob_name, "rotation", "Z", true);
+       create_sampled_animation(1, ctimes, baked_curves[EULX], ob_name, "rotation", "X", true);
+       create_sampled_animation(1, ctimes, baked_curves[EULY], ob_name, "rotation", "Y", true);
+       create_sampled_animation(1, ctimes, baked_curves[EULZ], ob_name, "rotation", "Z", true);
 
        fprintf(stdout, "Animation Export: Baked %zd frames for %s (sampling rate: %d)\n",
                baked_curves[0].size(),
@@ -243,19 +301,19 @@ void AnimationExporter::operator()(Object *ob)
        if (ob->adt && ob->adt->action) {
 
                if (ob->type == OB_ARMATURE) {
+                       /* Export skeletal animation (if any)*/
                        bArmature *arm = (bArmature *)ob->data;
                        for (Bone *bone = (Bone *)arm->bonebase.first; bone; bone = bone->next)
                                write_bone_animation_matrix(ob, bone);
                }
+
+               /* Armatures can have object animation and skeletal animation*/
+               if (this->export_settings->sampling_rate < 1) {
+                       export_keyframed_animation_set(ob);
+               }
                else {
-                       if (this->export_settings->sampling_rate == -1) {
-                               export_keyframed_animation_set(ob);
-                       }
-                       else {
-                               export_sampled_animation_set(ob);
-                       }
+                       export_sampled_animation_set(ob);
                }
-
        }
 
        export_object_constraint_animation(ob);
@@ -1187,9 +1245,51 @@ std::string AnimationExporter::create_source_from_vector(COLLADASW::InputSemanti
        return source_id;
 }
 
+std::string AnimationExporter::create_4x4_source(std::vector<float> &ctimes, std::vector<float> &values , const std::string &anim_id)
+{
+       COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT;
+       std::string source_id = anim_id + get_semantic_suffix(semantic);
+
+       COLLADASW::Float4x4Source source(mSW);
+       source.setId(source_id);
+       source.setArrayId(source_id + ARRAY_ID_SUFFIX);
+       source.setAccessorCount(ctimes.size());
+       source.setAccessorStride(16);
+
+       COLLADASW::SourceBase::ParameterNameList &param = source.getParameterNameList();
+       add_source_parameters(param, semantic, false, NULL, true);
+
+       source.prepareToAppendValues();
+
+       bPoseChannel *parchan = NULL;
+       bPoseChannel *pchan = NULL;
+
+
+       std::vector<float>::iterator it;
+
+       for (it = values.begin(); it != values.end(); it+=16) {
+               float mat[4][4];
+
+               bc_copy_m4_farray(mat, &*it);
+
+               UnitConverter converter;
+               double outmat[4][4];
+               converter.mat4_to_dae_double(outmat, mat);
+
+               if (this->export_settings->limit_precision)
+                       bc_sanitize_mat(outmat, 6);
+
+               source.appendValues(outmat);
+       }
+
+       source.finish();
+       return source_id;
+}
 
 std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Object *ob, Bone *bone, const std::string &anim_id)
 {
+       bool is_bone_animation = ob->type == OB_ARMATURE && bone;
+
        COLLADASW::InputSemantic::Semantics semantic = COLLADASW::InputSemantic::OUTPUT;
        std::string source_id = anim_id + get_semantic_suffix(semantic);
 
@@ -1207,7 +1307,7 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
        bPoseChannel *parchan = NULL;
        bPoseChannel *pchan = NULL;
 
-       if (ob->type == OB_ARMATURE && bone) {
+       if (is_bone_animation) {
                bPose *pose = ob->pose;
                pchan = BKE_pose_channel_find_name(pose, bone->name);
                if (!pchan)
@@ -1224,12 +1324,10 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
                float mat[4][4], ipar[4][4];
                float frame = *it;
 
-               float ctime = BKE_scene_frame_get_from_ctime(scene, *it);
-               CFRA = BKE_scene_frame_get_from_ctime(scene, *it);
-               //BKE_scene_graph_update_for_newframe(G.main->eval_ctx, depsgraph, G.main,scene);
-               BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_ALL);
-                               
-               if (bone) {
+               float ctime = BKE_scene_frame_get_from_ctime(scene, frame);
+               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);
@@ -1269,9 +1367,6 @@ std::string AnimationExporter::create_4x4_source(std::vector<float> &frames, Obj
 
                }
                else {
-                       BKE_scene_frame_set(scene, ctime);
-                       Main *bmain = bc_get_main();
-                       BKE_animsys_evaluate_all_animation(bmain, scene, ctime);
                        copy_m4_m4(mat, ob->obmat);
                }
                
index 3bb510e51d699f8852e76f212a74705f62a4ab34..1e0f434ca130e35f6edc1cf82d16401b50b0a1b8 100644 (file)
@@ -85,7 +85,7 @@ class AnimationExporter: COLLADASW::LibraryAnimations
 {
 private:
        Scene *scene;
-       const struct EvaluationContext *eval_ctx;
+       EvaluationContext *eval_ctx;
        COLLADASW::StreamWriter *sw;
 
 public:
@@ -97,7 +97,7 @@ public:
                this->sw = sw;
        }
 
-       bool exportAnimations(const struct EvaluationContext *eval_ctx, Scene *sce);
+       bool exportAnimations(EvaluationContext *eval_ctx, Scene *sce);
 
        // called for each exported object
        void operator() (Object *ob); 
@@ -145,9 +145,12 @@ protected:
        
        float* get_eul_source_for_quat(Object *ob );
 
+       bool is_flat_line(std::vector<float> &values, int channel_count);
        void export_keyframed_animation_set(Object *ob);
        void create_keyframed_animation(Object *ob, FCurve *fcu, char *transformName, bool is_param, Material *ma = NULL);
        void export_sampled_animation_set(Object *ob);
+       void export_sampled_transrotloc_animation(Object *ob, std::vector<float> &ctimes);
+       void export_sampled_matrix_animation(Object *ob, std::vector<float> &ctimes);
        void create_sampled_animation(int channel_count, std::vector<float> &times, std::vector<float> &values, std::string, std::string label, std::string axis_name, bool is_rot);
 
        void evaluate_anim_with_constraints(Object *ob, float ctime);
@@ -162,7 +165,7 @@ protected:
        std::string create_source_from_vector(COLLADASW::InputSemantic::Semantics semantic, std::vector<float> &fra, bool is_rot, const std::string& anim_id, const char *axis_name);
 
        std::string create_xyz_source(float *v, int tot, const std::string& anim_id);
-
+       std::string create_4x4_source(std::vector<float> &times, std::vector<float> &values, const std::string& anim_id);
        std::string create_4x4_source(std::vector<float> &frames, Object * ob_arm, Bone *bone, const std::string& anim_id);
 
        std::string create_interpolation_source(FCurve *fcu, const std::string& anim_id, const char *axis_name, bool *has_tangents);
index f413651167c7de942f376cac25ef74b8af6fad62..ae99e6bafdece1e9d4bdb09827bdff3cbe2a26a2 100644 (file)
@@ -280,7 +280,7 @@ void ControllerExporter::export_skin_controller(Object *ob, Object *ob_arm)
                }
 
                if (oob_counter > 0) {
-                       fprintf(stderr, "Ignored %d Vertex weights which use index to non existing VGroup %lu.\n",
+                       fprintf(stderr, "Ignored %d Vertex weights which use index to non existing VGroup %zu.\n",
                                oob_counter, joint_index_by_def_index.size());
                }
        }
index 1741312af5fff29cfe1efdf32d2d6ba958b9b54f..0e020c9011b964306d62a54ace789b6f73b42ea7 100644 (file)
@@ -179,7 +179,7 @@ static COLLADABU::NativeString make_temp_filepath(const char *name, const char *
 // COLLADA allows this through multiple <channel>s in <animation>.
 // For this to work, we need to know objects that use a certain action.
 
-int DocumentExporter::exportCurrentScene(const EvaluationContext *eval_ctx, Scene *sce)
+int DocumentExporter::exportCurrentScene(EvaluationContext *eval_ctx, Scene *sce)
 {
        PointerRNA sceneptr, unit_settings;
        PropertyRNA *system; /* unused , *scale; */
@@ -300,29 +300,11 @@ int DocumentExporter::exportCurrentScene(const EvaluationContext *eval_ctx, Scen
 
        SceneExporter se(writer, &arm_exporter, this->export_settings);
 
-       // <library_animations>
-       AnimationExporter ae(writer, this->export_settings);
-
-#if 0
-       bool has_animations = ae.exportAnimations(eval_ctx, sce);
-       /* The following code seems to be an obsolete workaround
-       Comment out until it proofs correct that we no longer need it.
-       */
-       if (has_animations && this->export_settings->export_transformation_type == BC_TRANSFORMATION_TYPE_MATRIX) {
-               // channels adressing <matrix> objects is not (yet) supported
-               // So we force usage of <location>, <translation> and <scale>
-               fprintf(stdout, 
-                       "For animated Ojects we must use decomposed <matrix> elements,\n" \
-                       "Forcing usage of TransLocRot transformation type.");
-               se.setExportTransformationType(BC_TRANSFORMATION_TYPE_TRANSROTLOC);
+       if (this->export_settings->include_animations) {
+               // <library_animations>
+               AnimationExporter ae(writer, this->export_settings);
+               ae.exportAnimations(eval_ctx, sce);
        }
-       else {
-               se.setExportTransformationType(this->export_settings->export_transformation_type);
-       }
-#else
-       ae.exportAnimations(eval_ctx, sce);
-       se.setExportTransformationType(this->export_settings->export_transformation_type);
-#endif
        se.exportScene(eval_ctx, sce);
        
        // <scene>
index 895787c7bbc475c632c34340aa7225498fc79dbf..b2d8214212cc905ed7bd595370898f7fa22462e4 100644 (file)
@@ -39,7 +39,7 @@ class DocumentExporter
 {
  public:
        DocumentExporter(const ExportSettings *export_settings);
-       int  exportCurrentScene(const struct EvaluationContext *eval_ctx, Scene *sce);
+       int  exportCurrentScene(EvaluationContext *eval_ctx, Scene *sce);
        void exportScenes(const char *filename);
 private:
        const ExportSettings *export_settings;
index 0483449e5130c9c6ff7b19f32eb8d9d2d39eda55..620ccedd54423585e171d8b9d7c2f65dd2069c38 100644 (file)
@@ -40,6 +40,7 @@ public:
        bool include_armatures;
        bool include_shapekeys;
        bool deform_bones_only;
+       bool include_animations;
        int sampling_rate;
 
        bool active_uv_only;
index c375c09d869ecd62952a8f7e98033e78636bef31..3a6386a87213f764262ca043a523ca758ec63a43 100644 (file)
@@ -39,11 +39,6 @@ SceneExporter::SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm,
 {
 }
 
-void SceneExporter::setExportTransformationType(BC_export_transformation_type transformation_type)
-{
-       this->transformation_type = transformation_type;
-}
-
 void SceneExporter::exportScene(const EvaluationContext *eval_ctx, Scene *sce)
 {
        // <library_visual_scenes> <visual_scene>
@@ -139,7 +134,7 @@ void SceneExporter::writeNodes(const EvaluationContext *eval_ctx, Object *ob, Sc
                // for skinned mesh we write obmat in <bind_shape_matrix>
                TransformWriter::add_node_transform_identity(colladaNode);
        else {
-               TransformWriter::add_node_transform_ob(colladaNode, ob, this->transformation_type);
+               TransformWriter::add_node_transform_ob(colladaNode, ob, this->export_settings->export_transformation_type);
        }
 
        // <instance_geometry>
index ded48983bd99b2e83b72ec07b18f8ddc87806d4e..3e3c15b836f958ffe7e8d7f8757b2dfd7df40e58 100644 (file)
@@ -96,12 +96,9 @@ class SceneExporter: COLLADASW::LibraryVisualScenes, protected TransformWriter,
 {
 public:
        SceneExporter(COLLADASW::StreamWriter *sw, ArmatureExporter *arm, const ExportSettings *export_settings);
-       void exportScene(const struct EvaluationContext *eval_ctx, Scene *sce);
-       void setExportTransformationType(BC_export_transformation_type transformation_type);
+       void exportScene(const EvaluationContext *eval_ctx, Scene *sce);
 
 private:
-       BC_export_transformation_type transformation_type;
-       // required for writeNodes() for bone-parented objects
        friend class ArmatureExporter;
        void exportHierarchy(const struct EvaluationContext *eval_ctx, Scene *sce);
        void writeNodes(const struct EvaluationContext *eval_ctx, Object *ob, Scene *sce);
index 286444882e407685c935d6f53139fe2a8914e6ad..04b828d35f92d8bf27bd2d564f630ab00816e74b 100644 (file)
@@ -32,6 +32,7 @@
 #include "DocumentImporter.h"
 #include "ExportSettings.h"
 #include "ImportSettings.h"
+#include "collada.h"
 
 extern "C"
 {
@@ -68,38 +69,38 @@ int collada_import(bContext *C,
        return 0;
 }
 
-int collada_export(bContext *C,
-                   const char *filepath,
-
-                   int apply_modifiers,
-                                  BC_export_mesh_type export_mesh_type,
-
-                   int selected,
-                   int include_children,
-                   int include_armatures,
-                                  int include_shapekeys,
-                   int deform_bones_only,
-                   int sampling_rate,
-
-                                  int active_uv_only,
-                                  int include_material_textures,
-                                  int use_texture_copies,
-
-                   int triangulate,
-                                  int use_object_instantiation,
-                                  int use_blender_profile,
-                                  int sort_by_name,
-                                  BC_export_transformation_type export_transformation_type,
-                                  int open_sim,
-                                  int limit_precision,
-                                  int keep_bind_info)
+int collada_export(
+       EvaluationContext *eval_ctx,
+       Scene *sce,
+       const char *filepath,
+
+       int apply_modifiers,
+       BC_export_mesh_type export_mesh_type,
+
+       int selected,
+       int include_children,
+       int include_armatures,
+       int include_shapekeys,
+       int deform_bones_only,
+       int include_animations,
+       int sampling_rate,
+
+       int active_uv_only,
+       int include_material_textures,
+       int use_texture_copies,
+
+       int triangulate,
+       int use_object_instantiation,
+       int use_blender_profile,
+       int sort_by_name,
+       BC_export_transformation_type export_transformation_type,
+       int open_sim,
+       int limit_precision,
+       int keep_bind_info)
 {
        ExportSettings export_settings;
 
-       EvaluationContext eval_ctx;
-       CTX_data_eval_ctx(C, &eval_ctx);
-       Scene *sce = CTX_data_scene(C);
-       ViewLayer *view_layer = CTX_data_view_layer(C);
+       ViewLayer *view_layer = eval_ctx->view_layer;
 
        export_settings.filepath                 = (char *)filepath;
 
@@ -110,7 +111,8 @@ int collada_export(bContext *C,
        export_settings.include_armatures        = include_armatures != 0;
        export_settings.include_shapekeys        = include_shapekeys != 0;
        export_settings.deform_bones_only        = deform_bones_only != 0;
-       export_settings.sampling_rate            = sampling_rate;
+       export_settings.include_animations       = include_animations;
+       export_settings.sampling_rate = sampling_rate;
 
        export_settings.active_uv_only           = active_uv_only != 0;
        export_settings.include_material_textures= include_material_textures != 0;
@@ -130,7 +132,6 @@ int collada_export(bContext *C,
        if (export_settings.include_children) includeFilter |= OB_REL_CHILDREN_RECURSIVE;
 
        eObjectSet objectSet = (export_settings.selected) ? OB_SET_SELECTED : OB_SET_ALL;
-
        export_settings.export_set = BKE_object_relational_superset(view_layer, objectSet, (eObRelationTypes)includeFilter);
 
        int export_count = BLI_linklist_count(export_settings.export_set);
@@ -149,7 +150,7 @@ int collada_export(bContext *C,
        }
 
        DocumentExporter exporter(&export_settings);
-       int status = exporter.exportCurrentScene(&eval_ctx, sce);
+       int status = exporter.exportCurrentScene(eval_ctx, sce);
 
        BLI_linklist_free(export_settings.export_set, NULL);
 
index 89853b8849f3db2c4d2581be1333d75de8d8a469..47272255012a3565c8cae9b1f0987802f91d8039 100644 (file)
@@ -64,31 +64,35 @@ int collada_import(struct bContext *C,
 
                                   int keep_bind_info);
 
-int collada_export(struct bContext *C,
-                   const char *filepath,
-                   int apply_modifiers,
-                   BC_export_mesh_type export_mesh_type,
-
-                   int selected,
-                   int include_children,
-                   int include_armatures,
-                   int include_shapekeys,
-                   int deform_bones_only,
-                   int sampling_rate,
-
-                   int active_uv_only,
-                   int include_material_textures,
-                   int use_texture_copies,
-
-                   int triangulate,
-                   int use_object_instantiation,
-                   int use_blender_profile,
-                   int sort_by_name,
-                   BC_export_transformation_type export_transformation_type,
-
-                                  int open_sim,
-                                  int limit_precision,
-                                  int keep_bind_info);
+int collada_export(
+       EvaluationContext *eval_ctx,
+       Scene *sce,
+       const char *filepath,
+
+       int apply_modifiers,
+       BC_export_mesh_type export_mesh_type,
+
+       int selected,
+       int include_children,
+       int include_armatures,
+       int include_shapekeys,
+       int deform_bones_only,
+       int include_animations,
+       int sampling_rate,
+
+       int active_uv_only,
+       int include_material_textures,
+       int use_texture_copies,
+
+       int triangulate,
+       int use_object_instantiation,
+       int use_blender_profile,
+       int sort_by_name,
+       BC_export_transformation_type export_transformation_type,
+
+       int open_sim,
+       int limit_precision,
+       int keep_bind_info);
 
 #ifdef __cplusplus
 }
index 99eca373e4e4ed99e7935368d7cc23cbc53c9c84..d30f8e825908c3e7ee2610c97cea08c439307ddb 100644 (file)
@@ -32,6 +32,8 @@
 #include "COLLADAFWMeshPrimitive.h"
 #include "COLLADAFWMeshVertexData.h"
 
+#include <set>
+
 extern "C" {
 #include "DNA_modifier_types.h"
 #include "DNA_customdata_types.h"
@@ -152,6 +154,15 @@ EvaluationContext *bc_get_evaluation_context()
        return bmain->eval_ctx;
 }
 
+
+void bc_update_scene(EvaluationContext *eval_ctx, Scene *scene, float ctime)
+{
+       BKE_scene_frame_set(scene, ctime);
+       Main *bmain = bc_get_main();
+       EvaluationContext *ev_context = bc_get_evaluation_context();
+       BKE_scene_graph_update_for_newframe(eval_ctx, eval_ctx->depsgraph, bmain, scene, eval_ctx->view_layer);
+}
+
 Object *bc_add_object(Scene *scene, ViewLayer *view_layer, int type, const char *name)
 {
        Object *ob = BKE_object_add_only_object(G.main, type, name);
@@ -895,3 +906,181 @@ void bc_sanitize_mat(double mat[4][4], int precision)
                        mat[i][j] = double_round(mat[i][j], precision);
 }
 
+void bc_copy_m4_farray(float r[4][4], float *a)
+{
+       for (int i = 0; i < 4; i++)
+               for (int j = 0; j < 4; j++)
+                       r[i][j] = *a++;
+}
+
+void bc_copy_farray_m4(float *r, float a[4][4])
+{
+       for (int i = 0; i < 4; i++)
+               for (int j = 0; j < 4; j++)
+                       *r++ = a[i][j];
+
+}
+
+/*
+ * Returns name of Active UV Layer or empty String if no active UV Layer defined
+ */
+std::string bc_get_active_uvlayer_name(Mesh *me)
+{
+       int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
+       if (num_layers) {
+               char *layer_name = bc_CustomData_get_active_layer_name(&me->fdata, CD_MTFACE);
+               if (layer_name) {
+                       return std::string(layer_name);
+               }
+       }
+       return "";
+}
+
+/*
+* Returns name of Active UV Layer or empty String if no active UV Layer defined.
+* Assuming the Object is of type MESH
+*/
+std::string bc_get_active_uvlayer_name(Object *ob)
+{
+       Mesh *me = (Mesh *)ob->data;
+       return bc_get_active_uvlayer_name(me);
+}
+
+/*
+ * Returns UV Layer name or empty string if layer index is out of range
+ */
+std::string bc_get_uvlayer_name(Mesh *me, int layer)
+{
+       int num_layers = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
+       if (num_layers && layer < num_layers) {
+               char *layer_name = bc_CustomData_get_layer_name(&me->fdata, CD_MTFACE, layer);
+               if (layer_name) {
+                       return std::string(layer_name);
+               }
+       }
+       return "";
+}
+
+#if 0
+/**********************************************************************
+*
+* Return the list of Mesh objects with assigned UVtextures and Images
+* Note: We need to create artificaial materials for each of them
+*
+***********************************************************************/
+std::set<Object *> bc_getUVTexturedObjects(Scene *sce, bool all_uv_layers)
+{
+       std::set <Object *> UVObjects;
+       Base *base = (Base *)sce->base.first;
+
+       while (base) {
+               Object *ob = base->object;
+               bool has_uvimage = false;
+               if (ob->type == OB_MESH) {
+                       Mesh *me = (Mesh *)ob->data;
+                       int active_uv_layer = CustomData_get_active_layer_index(&me->pdata, CD_MTEXPOLY);
+
+                       for (int i = 0; i < me->pdata.totlayer && !has_uvimage; i++) {
+                               if (all_uv_layers || active_uv_layer == i)
+                               {
+                                       if (me->pdata.layers[i].type == CD_MTEXPOLY) {
+                                               MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data;
+                                               MPoly *mpoly = me->mpoly;
+                                               for (int j = 0; j < me->totpoly; j++, mpoly++, txface++) {
+
+                                                       Image *ima = txface->tpage;
+                                                       if (ima != NULL) {
+                                                               has_uvimage = true;
+                                                               break;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+
+                       if (has_uvimage) {
+                               UVObjects.insert(ob);
+                       }
+               }
+               base = base->next;
+       }
+       return UVObjects;
+}
+
+/**********************************************************************
+*
+* Return the list of UV Texture images from all exported Mesh Items
+* Note: We need to create one artificial material for each Image.
+*
+***********************************************************************/
+std::set<Image *> bc_getUVImages(Scene *sce, bool all_uv_layers)
+{
+       std::set <Image *> UVImages;
+       Base *base = (Base *)sce->base.first;
+
+       while (base) {
+               Object *ob = base->object;
+               bool has_uvimage = false;
+               if (ob->type == OB_MESH) {
+                       Mesh *me = (Mesh *)ob->data;
+                       int active_uv_layer = CustomData_get_active_layer_index(&me->pdata, CD_MTEXPOLY);
+
+                       for (int i = 0; i < me->pdata.totlayer && !has_uvimage; i++) {
+                               if (all_uv_layers || active_uv_layer == i)
+                               {
+                                       if (me->pdata.layers[i].type == CD_MTEXPOLY) {
+                                               MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data;
+                                               MPoly *mpoly = me->mpoly;
+                                               for (int j = 0; j < me->totpoly; j++, mpoly++, txface++) {
+
+                                                       Image *ima = txface->tpage;
+                                                       if (ima != NULL) {
+                                                               if (UVImages.find(ima) == UVImages.end())
+                                                                       UVImages.insert(ima);
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               base = base->next;
+       }
+       return UVImages;
+}
+
+/**********************************************************************
+*
+* Return the list of UV Texture images for the given Object
+* Note: We need to create one artificial material for each Image.
+*
+***********************************************************************/
+std::set<Image *> bc_getUVImages(Object *ob, bool all_uv_layers)
+{
+       std::set <Image *> UVImages;
+
+       bool has_uvimage = false;
+       if (ob->type == OB_MESH) {
+               Mesh *me = (Mesh *)ob->data;
+               int active_uv_layer = CustomData_get_active_layer_index(&me->pdata, CD_MTEXPOLY);
+
+               for (int i = 0; i < me->pdata.totlayer && !has_uvimage; i++) {
+                       if (all_uv_layers || active_uv_layer == i)
+                       {
+                               if (me->pdata.layers[i].type == CD_MTEXPOLY) {
+                                       MTexPoly *txface = (MTexPoly *)me->pdata.layers[i].data;
+                                       MPoly *mpoly = me->mpoly;
+                                       for (int j = 0; j < me->totpoly; j++, mpoly++, txface++) {
+
+                                               Image *ima = txface->tpage;
+                                               if (ima != NULL) {
+                                                       if (UVImages.find(ima) == UVImages.end())
+                                                               UVImages.insert(ima);
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       return UVImages;
+}
+#endif 
index 43fcdf66dce4a13885c89cb5b67acc6dcd74f967..cdc7b99722d2c358cca291d14df43fe3797c81ca 100644 (file)
@@ -67,6 +67,7 @@ typedef std::map<COLLADAFW::TextureMapId, std::vector<MTex *> > TexIndexTextureA
 extern Scene *bc_get_scene(bContext *C);
 extern Main *bc_get_main();
 extern EvaluationContext *bc_get_evaluation_context();
+extern void bc_update_scene(EvaluationContext *eval_ctx, Scene *scene, float ctime);
 
 extern float bc_get_float_value(const COLLADAFW::FloatOrDoubleArray& array, unsigned int index);
 extern int bc_test_parent_loop(Object *par, Object *ob);
@@ -104,6 +105,13 @@ extern bool bc_is_leaf_bone(Bone *bone);
 extern EditBone *bc_get_edit_bone(bArmature * armature, char *name);
 extern int bc_set_layer(int bitfield, int layer, bool enable);
 extern int bc_set_layer(int bitfield, int layer);
+
+inline bool bc_in_range(float a, float b, float range) {
+       return abs(a - b) < range;
+}
+void bc_copy_m4_farray(float r[4][4], float *a);
+void bc_copy_farray_m4(float *r, float a[4][4]);
+
 extern void bc_sanitize_mat(float mat[4][4], int precision);
 extern void bc_sanitize_mat(double mat[4][4], int precision);
 
index eb101fd89a7149e803109f5073733e1ddbbf3655..85bcfb603cdb23272d687883a0ca89553023b571 100644 (file)
@@ -116,7 +116,7 @@ static void animedit_get_yscale_factor(bAnimContext *ac)
        
        /* grab scale factor directly from action editor setting
         * NOTE: This theme setting doesn't have an ID, as it cannot be accessed normally
-        *       since it is a float, and the theem settings methods can only handle chars.
+        *       since it is a float, and the theme settings methods can only handle chars.
         */
        ac->yscale_fac = btheme->tact.keyframe_scale_fac;
        
index 3a77a103aeb07d780eb11569bbe85f82cd698dee..246f7d7bd61d9049f6389f801bbc1a537bd2a152 100644 (file)
@@ -1591,6 +1591,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
                rcti temp = *rect;
                temp.xmin = rect->xmax - BLI_rcti_size_y(rect) - 1;
                widget_draw_icon(but, ICON_LAYER_USED, alpha, &temp, false);
+               rect->xmax = temp.xmin;
        }
 
        /* If there's an icon too (made with uiDefIconTextBut) then draw the icon
index 98c88ba5fc9a522b7224603bd199a6f290246cd2..d89af5e85bdc2459373d7cd0d61f0d50987f34d1 100644 (file)
@@ -28,7 +28,7 @@
  *  \ingroup collada
  */
 #ifdef WITH_COLLADA
-#include "DNA_scene_types.h"
+#include "DNA_space_types.h"
 
 #include "BLT_translation.h"
 
@@ -91,6 +91,9 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
        int include_armatures;
        int include_shapekeys;
        int deform_bones_only;
+
+       int include_animations;
+       int sample_animations;
        int sampling_rate;
 
        int include_material_textures;
@@ -144,7 +147,11 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
        include_children         = RNA_boolean_get(op->ptr, "include_children");
        include_armatures        = RNA_boolean_get(op->ptr, "include_armatures");
        include_shapekeys        = RNA_boolean_get(op->ptr, "include_shapekeys");
-       sampling_rate             = RNA_int_get(op->ptr,     "sampling_rate");
+
+       include_animations       = RNA_boolean_get(op->ptr, "include_animations");
+       sample_animations        = RNA_boolean_get(op->ptr, "sample_animations");
+       sampling_rate            = (sample_animations)? RNA_int_get(op->ptr, "sampling_rate") : 0;
+
        deform_bones_only        = RNA_boolean_get(op->ptr, "deform_bones_only");
 
        include_material_textures = RNA_boolean_get(op->ptr, "include_material_textures");
@@ -164,7 +171,11 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
        /* get editmode results */
        ED_object_editmode_load(CTX_data_edit_object(C));
 
-       export_count = collada_export(C,
+       Scene *scene = CTX_data_scene(C);
+       CTX_data_eval_ctx(C, &eval_ctx);
+
+       export_count = collada_export(&eval_ctx,
+               scene,
                filepath,
                apply_modifiers,
                export_mesh_type,
@@ -173,6 +184,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
                include_armatures,
                include_shapekeys,
                deform_bones_only,
+               include_animations,
                sampling_rate,
 
                active_uv_only,
@@ -209,6 +221,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op)
 static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
 {
        uiLayout *box, *row, *col, *split;
+       bool include_animations = RNA_boolean_get(imfptr, "include_animations");
 
        /* Export Options: */
        box = uiLayoutBox(layout);
@@ -239,9 +252,15 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
        uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "selected"));
 
        row = uiLayoutRow(box, false);
-       uiItemR(row, imfptr, "sampling_rate", 0, NULL, ICON_NONE);
+       uiItemR(row, imfptr, "include_animations", 0, NULL, ICON_NONE);
+       row = uiLayoutRow(box, false);
+       if (include_animations) {
+               uiItemR(row, imfptr, "sample_animations", 0, NULL, ICON_NONE);
+               row = uiLayoutColumn(box, false);
+               uiItemR(row, imfptr, "sampling_rate", 0, NULL, ICON_NONE);
+               uiLayoutSetEnabled(row, RNA_boolean_get(imfptr, "sample_animations"));
+       }
 
-       
        /* Texture options */
        box = uiLayoutBox(layout);
        row = uiLayoutRow(box, false);
@@ -284,7 +303,6 @@ static void uiCollada_exportSettings(uiLayout *layout, PointerRNA *imfptr)
        split = uiLayoutSplit(row, 0.6f, UI_LAYOUT_ALIGN_RIGHT);
        uiItemL(split, IFACE_("Transformation Type"), ICON_NONE);
        uiItemR(split, imfptr, "export_transformation_type_selection", 0, "", ICON_NONE);
-
        row = uiLayoutRow(box, false);
        uiItemR(row, imfptr, "sort_by_name", 0, NULL, ICON_NONE);
 
@@ -376,8 +394,14 @@ void WM_OT_collada_export(wmOperatorType *ot)
        RNA_def_boolean(func, "deform_bones_only", 0, "Deform Bones only",
                        "Only export deforming bones with armatures");
 
-       RNA_def_int(func, "sampling_rate", 0, -1, INT_MAX,
-               "Samplintg Rate", "The maximum distance of frames between 2 keyframes. Disabled when value is -1", -1, INT_MAX);
+       RNA_def_boolean(func, "include_animations", false,
+               "Include Animations", "Export Animations if available.\nExporting Animations will enforce the decomposition of node transforms\ninto  <translation> <rotation> and <scale> components");
+
+       RNA_def_boolean(func, "sample_animations", 0,
+               "Sample Animations", "Auto-generate keyframes with a frame distance set by 'Sampling Rate'.\nWhen disabled, export only the keyframes defined in the animation f-curves (may be less accurate)");
+
+       RNA_def_int(func, "sampling_rate", 1, 1, INT_MAX,
+               "Sampling Rate", "The distance between 2 keyframes. 1 means: Every frame is keyed", 1, INT_MAX);
 
 
        RNA_def_boolean(func, "active_uv_only", 0, "Only Selected UV Map",
index 0e56dc817e4b5e8885ccefdd3f3716a92d6f6df6..907f346c93162358db395293fcd0305265cd04d1 100644 (file)
@@ -171,8 +171,8 @@ int graphop_editable_keyframes_poll(bContext *C)
                
                /* editable curves must fulfill the following criteria:
                 *      - it has bezier keyframes
-                *      - it must not be protected from editing (this is already checked for with the foredit flag
-                *      - F-Curve modifiers do not interfere with the result too much 
+                *      - it must not be protected from editing (this is already checked for with the edit flag
+                *      - F-Curve modifiers do not interfere with the result too much
                 *        (i.e. the modifier-control drawing check returns false)
                 */
                if (fcu->bezt == NULL)
index f66c9ee99517d8740a370ac2093f719c05ffe649..61e0004915d2ea4c3db2377a793fcde06b30b7f8 100644 (file)
@@ -286,6 +286,21 @@ static void uvedit_pixel_to_float(SpaceImage *sima, float *dist, float pixeldist
 
 /*************** visibility and selection utilities **************/
 
+static void uvedit_vertex_select_tagged(BMEditMesh *em, Scene *scene, bool select, int cd_loop_uv_offset)
+{
+       BMFace *efa;
+       BMLoop *l;
+       BMIter iter, liter;
+
+       BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
+               BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
+                       if (BM_elem_flag_test(l->v, BM_ELEM_TAG)) {
+                               uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+                       }
+               }
+       }
+}
+
 bool uvedit_face_visible_nolocal(Scene *scene, BMFace *efa)
 {
        ToolSettings *ts = scene->toolsettings;
@@ -1291,9 +1306,7 @@ static int uv_select_more_less(bContext *C, const bool select)
        if (ts->uv_selectmode == UV_SELECT_FACE) {
 
                /* clear tags */
-               BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
-                       BM_elem_flag_disable(efa, BM_ELEM_TAG);
-               }
+               BM_mesh_elem_hflag_disable_all(em->bm, BM_FACE, BM_ELEM_TAG, false);
 
                /* mark loops to be selected */
                BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
@@ -1485,9 +1498,7 @@ static void uv_weld_align(bContext *C, int tool)
                BMIter iter, liter, eiter;
 
                /* clear tag */
-               BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
-                       BM_elem_flag_disable(eve, BM_ELEM_TAG);
-               }
+               BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
 
                /* tag verts with a selected UV */
                BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
@@ -2587,12 +2598,8 @@ static void uv_select_flush_from_tag_face(SpaceImage *sima, Scene *scene, Object
        if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_VERTEX) {
                /* Tag all verts as untouched, then touch the ones that have a face center
                 * in the loop and select all MLoopUV's that use a touched vert. */
-               BMVert *eve;
-               
-               BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
-                       BM_elem_flag_disable(eve, BM_ELEM_TAG);
-               }
-               
+               BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
+
                BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                        if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
                                BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
@@ -2677,11 +2684,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, Scene *scene, Object
        if ((ts->uv_flag & UV_SYNC_SELECTION) == 0 && sima->sticky == SI_STICKY_VERTEX) {
                /* Tag all verts as untouched, then touch the ones that have a face center
                 * in the loop and select all MLoopUV's that use a touched vert. */
-               BMVert *eve;
-
-               BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) {
-                       BM_elem_flag_disable(eve, BM_ELEM_TAG);
-               }
+               BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
 
                BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                        BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
@@ -2802,7 +2805,8 @@ static int uv_border_select_exec(bContext *C, wmOperator *op)
        else {
                /* other selection modes */
                changed = true;
-               
+               BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
+
                BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                        if (!uvedit_face_visible_test(scene, obedit, ima, efa))
                                continue;
@@ -2814,15 +2818,21 @@ static int uv_border_select_exec(bContext *C, wmOperator *op)
                                        /* UV_SYNC_SELECTION - can't do pinned selection */
                                        if (BLI_rctf_isect_pt_v(&rectf, luv->uv)) {
                                                uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+                                               BM_elem_flag_enable(l->v, BM_ELEM_TAG);
                                        }
                                }
                                else if (pinned) {
                                        if ((luv->flag & MLOOPUV_PINNED) && BLI_rctf_isect_pt_v(&rectf, luv->uv)) {
                                                uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+                                               BM_elem_flag_enable(l->v, BM_ELEM_TAG);
                                        }
                                }
                        }
                }
+
+               if (sima->sticky == SI_STICKY_VERTEX) {
+                       uvedit_vertex_select_tagged(em, scene, select, cd_loop_uv_offset);
+               }
        }
 
        if (changed) {
@@ -2872,19 +2882,6 @@ static int uv_inside_circle(const float uv[2], const float offset[2], const floa
        return ((x * x + y * y) < 1.0f);
 }
 
-static bool uv_select_inside_ellipse(BMEditMesh *em, Scene *scene, const bool select,
-                                     const float offset[2], const float ellipse[2], BMLoop *l, MLoopUV *luv,
-                                     const int cd_loop_uv_offset)
-{
-       if (uv_inside_circle(luv->uv, offset, ellipse)) {
-               uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
-               return true;
-       }
-       else {
-               return false;
-       }
-}
-
 static int uv_circle_select_exec(bContext *C, wmOperator *op)
 {
        SpaceImage *sima = CTX_wm_space_image(C);
@@ -2944,12 +2941,22 @@ static int uv_circle_select_exec(bContext *C, wmOperator *op)
                }
        }
        else {
+               BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
+
                BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                        BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
                                luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
-                               changed |= uv_select_inside_ellipse(em, scene, select, offset, ellipse, l, luv, cd_loop_uv_offset);
+                               if (uv_inside_circle(luv->uv, offset, ellipse)) {
+                                       changed = true;
+                                       uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
+                                       BM_elem_flag_enable(l->v, BM_ELEM_TAG);
+                               }
                        }
                }
+
+               if (sima->sticky == SI_STICKY_VERTEX) {
+                       uvedit_vertex_select_tagged(em, scene, select, cd_loop_uv_offset);
+               }
        }
 
        if (changed) {
@@ -3040,6 +3047,8 @@ static bool do_lasso_select_mesh_uv(bContext *C, const int mcords[][2], short mo
                }
        }
        else { /* Vert Sel */
+               BM_mesh_elem_hflag_disable_all(em->bm, BM_VERT, BM_ELEM_TAG, false);
+
                BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                        if (uvedit_face_visible_test(scene, obedit, ima, efa)) {
                                BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
@@ -3053,11 +3062,16 @@ static bool do_lasso_select_mesh_uv(bContext *C, const int mcords[][2], short mo
                                                {
                                                        uvedit_uv_select_set(em, scene, l, select, false, cd_loop_uv_offset);
                                                        changed = true;
+                                                       BM_elem_flag_enable(l->v, BM_ELEM_TAG);
                                                }
                                        }
                                }
                        }
                }
+
+               if (sima->sticky == SI_STICKY_VERTEX) {
+                       uvedit_vertex_select_tagged(em, scene, select, cd_loop_uv_offset);
+               }
        }
 
        if (changed) {
@@ -3966,17 +3980,14 @@ static int uv_mark_seam_exec(bContext *C, wmOperator *op)
        BMFace *efa;
        BMLoop *loop;
        BMIter iter, liter;
-       bool clear = RNA_boolean_get(op->ptr, "clear");
+       bool flag_set = !RNA_boolean_get(op->ptr, "clear");
 
        const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
 
        BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
                BM_ITER_ELEM (loop, &liter, efa, BM_LOOPS_OF_FACE) {
                        if (uvedit_edge_select_test(scene, loop, cd_loop_uv_offset)) {
-                               if (clear)
-                                       BM_elem_flag_disable(loop->e, BM_ELEM_SEAM);
-                               else
-                                       BM_elem_flag_enable(loop->e, BM_ELEM_SEAM);
+                               BM_elem_flag_set(loop->e, BM_ELEM_SEAM, flag_set);
                        }
                }
        }
index 580b4d3410674374fd3113a203ecccc6def17fdc..212578cf3f03b6ce0396e52d02173daee6edf2c6 100644 (file)
@@ -290,65 +290,6 @@ static void rna_Scene_alembic_export(
 
 #endif
 
-#ifdef WITH_COLLADA
-/* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */
-#include "../../collada/collada.h"
-
-/* Note: This definition must match to the generated function call */
-static void rna_Scene_collada_export(
-        bContext *C,
-        const char *filepath, 
-        int apply_modifiers,
-
-        int export_mesh_type,
-        int selected,
-        int include_children,
-        int include_armatures,
-        int include_shapekeys,
-        int deform_bones_only,
-        int sampling_rate,
-        int active_uv_only,
-        int include_material_textures,
-        int use_texture_copies,
-        int triangulate,
-        int use_object_instantiation,
-        int use_blender_profile,
-        int sort_by_name,
-        int export_transformation_type,
-        int open_sim,
-        int limit_precision,
-        int keep_bind_info)
-{
-       collada_export(C,
-               filepath,
-
-               apply_modifiers,
-               export_mesh_type,
-
-               selected,
-               include_children,
-               include_armatures,
-               include_shapekeys,
-               deform_bones_only,
-               sampling_rate,
-
-               active_uv_only,
-               include_material_textures,
-               use_texture_copies,
-
-               triangulate,
-               use_object_instantiation,
-               use_blender_profile,
-               sort_by_name,
-
-               export_transformation_type,
-               open_sim,
-               limit_precision,
-               keep_bind_info);
-}
-
-#endif
-
 #else
 
 void RNA_api_scene(StructRNA *srna)
@@ -407,71 +348,6 @@ void RNA_api_scene(StructRNA *srna)
        parm = RNA_def_float_matrix(func, "matrix", 4, 4, NULL, 0.0f, 0.0f, "", "Matrix", 0.0f, 0.0f);
        RNA_def_function_output(func, parm);
 
-#ifdef WITH_COLLADA
-       /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */
-       func = RNA_def_function(srna, "collada_export", "rna_Scene_collada_export");
-       RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
-       parm = RNA_def_string(func, "filepath", NULL, FILE_MAX, "File Path", "File path to write Collada file");
-       RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
-       RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */
-
-       RNA_def_boolean(func, "apply_modifiers", false,
-                       "Apply Modifiers", "Apply modifiers to exported mesh (non destructive))");
-
-       RNA_def_int(func, "export_mesh_type", 0, INT_MIN, INT_MAX,
-                   "Resolution", "Modifier resolution for export", INT_MIN, INT_MAX);
-
-       RNA_def_boolean(func, "selected", false, "Selection Only", "Export only selected elements");
-
-       RNA_def_boolean(func, "include_children", false,
-                       "Include Children", "Export all children of selected objects (even if not selected)");
-
-       RNA_def_boolean(func, "include_armatures", false,
-                       "Include Armatures", "Export related armatures (even if not selected)");
-
-       RNA_def_boolean(func, "include_shapekeys", true, "Include Shape Keys", "Export all Shape Keys from Mesh Objects");
-
-       RNA_def_boolean(func, "deform_bones_only", false,
-                       "Deform Bones only", "Only export deforming bones with armatures");
-
-       RNA_def_int(func, "sampling_rate", 0, -1, INT_MAX,
-               "Samplintg Rate", "The maximum distance of frames between 2 keyframes. Disabled when value is -1", -1, INT_MAX);
-
-       RNA_def_boolean(func, "active_uv_only", false, "Only Selected UV Map", "Export only the selected UV Map");
-
-       RNA_def_boolean(func, "include_material_textures", false,
-                       "Include Material Textures", "Export textures assigned to the object Materials");
-
-       RNA_def_boolean(func, "use_texture_copies", true,
-                       "Copy", "Copy textures to same folder where the .dae file is exported");
-
-       RNA_def_boolean(func, "triangulate", true, "Triangulate", "Export Polygons (Quads & NGons) as Triangles");
-
-       RNA_def_boolean(func, "use_object_instantiation", true,
-                       "Use Object Instances", "Instantiate multiple Objects from same Data");
-
-       RNA_def_boolean(func, "use_blender_profile", true, "Use Blender Profile",
-                       "Export additional Blender specific information (for material, shaders, bones, etc.)");
-
-       RNA_def_boolean(func, "sort_by_name", false, "Sort by Object name", "Sort exported data by Object name");
-
-       RNA_def_int(func, "export_transformation_type", 0, INT_MIN, INT_MAX,
-                   "Transform", "Transformation type for translation, scale and rotation", INT_MIN, INT_MAX);
-
-       RNA_def_boolean(func, "open_sim", false,
-                       "Export to SL/OpenSim", "Compatibility mode for SL, OpenSim and other compatible online worlds");
-
-       RNA_def_boolean(func, "limit_precision", false,
-                       "Limit Precision",
-                       "Reduce the precision of the exported data to 6 digits");
-
-       RNA_def_boolean(func, "keep_bind_info", false,
-                       "Keep Bind Info",
-                       "Store bind pose information in custom bone properties for later use during Collada export");
-
-       RNA_def_function_flag(func, FUNC_USE_CONTEXT);
-
-#endif
 
 #ifdef WITH_ALEMBIC
        /* XXX Deprecated, will be removed in 2.8 in favour of calling the export operator. */
index 28f413299a53d9730c59d28faf8be279a3cc58e2..3098bb88cf8bbd1154db97ba9179c040197102fa 100644 (file)
@@ -152,7 +152,6 @@ struct wmManipulatorMap;
 #include "../../intern/elbeem/extern/elbeem.h"
 #include "../blender/blenkernel/BKE_modifier.h"
 #include "../blender/blenkernel/BKE_paint.h"
-#include "../blender/collada/collada.h"
 #include "../blender/compositor/COM_compositor.h"
 #include "../blender/editors/include/ED_armature.h"
 #include "../blender/editors/include/ED_anim_api.h"
@@ -825,34 +824,6 @@ struct uiLayout *uiLayoutRadial(struct uiLayout *layout) RET_NULL
 int UI_pie_menu_invoke_from_operator_enum(struct bContext *C, const char *title, const char *opname,
                              const char *propname, const struct wmEvent *event) RET_ZERO
 
-/* RNA COLLADA dependency */
-int collada_export(const struct EvaluationContext *eval_ctx,
-                   struct Scene *sce,
-                   struct ViewLayer *view_layer,
-                   const char *filepath,
-                   int apply_modifiers,
-                   BC_export_mesh_type export_mesh_type,
-
-                   int selected,
-                   int include_children,
-                   int include_armatures,
-                   int include_shapekeys,
-                   int deform_bones_only,
-                   int sampling_rate,
-
-                   int active_uv_only,
-                   int include_material_textures,
-                   int use_texture_copies,
-
-                   int triangulate,
-                   int use_object_instantiation,
-                   int use_blender_profile,
-                   int sort_by_name,
-                   BC_export_transformation_type export_transformation_type,
-                   int open_sim,
-                   int limit_precision,
-                   int keep_bind_info) RET_ZERO
-
 void ED_mesh_calc_tessface(struct Mesh *mesh, bool free_mpoly) RET_NONE
 
 /* bpy/python internal api */
index 4ef98fdc6b4e6469c3df982dbe109e61677117b1..f592160f6aadd6bcb9aba6617e2d5c856380adb2 100644 (file)
@@ -56,6 +56,8 @@ def with_tempdir(wrapped):
 
     return decorator
 
+LINE = "+----------------------------------------------------------------"
+
 class AbstractColladaTest(unittest.TestCase):
 
     @classmethod
@@ -89,12 +91,19 @@ class AbstractColladaTest(unittest.TestCase):
                         break
             if error:
                 diff_count +=1
-                print ("%s"%line.strip())
+                pline = line.strip()
+                if diff_count == 1:
+                    print("\n%s" % LINE)
+                    print("|Test has errors:")
+                    print(LINE)
+                pre = "reference" if pline[0] == "-" else "generated"
+                print ("| %s:%s"% (pre, pline[1:]))
 
         if diff_count > 0:
-            print("Generated file differs from reference")
-            print("reference: %s" % reference)
-            print("result   : %s" % export)
+            print(LINE)
+            print("ref :%s" % reference)
+            print("test:%s" % export)
+            print("%s\n" % LINE)
 
         return diff_count == 0
 
@@ -134,7 +143,8 @@ class MeshExportTest(AbstractColladaTest):
             keep_bind_info=False)
         
         # Now check the resulting Collada file.
-        self.assertTrue(self.checkdae(reference_dae, outfile))
+        if not self.checkdae(reference_dae, outfile):
+            self.fail()
 
 if __name__ == '__main__':
     sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else [])