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)
18 files changed:
1  2 
source/blender/blenkernel/intern/particle_distribute.c
source/blender/collada/AnimationExporter.cpp
source/blender/collada/AnimationExporter.h
source/blender/collada/ControllerExporter.cpp
source/blender/collada/DocumentExporter.cpp
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/uvedit/uvedit_ops.c
source/blender/makesrna/intern/rna_scene_api.c
source/blenderplayer/bad_level_call_stubs/stubs.c

index 24e5ecb8d1030a14cefb806586511ab1bf097072,8c0733374a189e5aff21a427d2510bd0af5b7a82..a1497a0ab44e8da0861883d0d56e44a69e3ceebc
@@@ -34,7 -34,7 +34,7 @@@ void forEachObjectInExportSet(Scene *sc
        }
  }
  
- bool AnimationExporter::exportAnimations(const struct EvaluationContext *eval_ctx, Scene *sce)
 -bool AnimationExporter::exportAnimations(Scene *sce)
++bool AnimationExporter::exportAnimations(EvaluationContext *eval_ctx, Scene *sce)
  {
        bool has_animations = hasAnimations(sce);
        if (has_animations) {
@@@ -171,6 -195,45 +196,45 @@@ void AnimationExporter::export_keyframe
   * Also keyframed animation exports tend to break when negative scales are involved.
   */
  void AnimationExporter::export_sampled_animation_set(Object *ob)
 -              bc_update_scene(scene, *ctime);
+ {
+       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;
                float fsize[3];
                float feul[3];
  
-               evaluate_anim_with_constraints(ob, *ctime); // set object transforms to the frame
 -              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);
@@@ -1224,12 -1323,9 +1324,10 @@@ std::string AnimationExporter::create_4
                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(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);
index 3bb510e51d699f8852e76f212a74705f62a4ab34,52b463535281cb8a5ebae5dadbac593b6f0a617b..1e0f434ca130e35f6edc1cf82d16401b50b0a1b8
@@@ -85,7 -85,6 +85,7 @@@ class AnimationExporter: COLLADASW::Lib
  {
  private:
        Scene *scene;
-       const struct EvaluationContext *eval_ctx;
++      EvaluationContext *eval_ctx;
        COLLADASW::StreamWriter *sw;
  
  public:
@@@ -97,7 -96,7 +97,7 @@@
                this->sw = sw;
        }
  
-       bool exportAnimations(const struct EvaluationContext *eval_ctx, Scene *sce);
 -      bool exportAnimations(Scene *sce);
++      bool exportAnimations(EvaluationContext *eval_ctx, Scene *sce);
  
        // called for each exported object
        void operator() (Object *ob); 
index 1741312af5fff29cfe1efdf32d2d6ba958b9b54f,2b5d56928718cbda5e18434ffb308611b7d63c7a..0e020c9011b964306d62a54ace789b6f73b42ea7
@@@ -300,30 -302,12 +300,12 @@@ int DocumentExporter::exportCurrentScen
  
        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(sce);
++              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(sce);
 +      se.exportScene(eval_ctx, sce);
        
        // <scene>
        std::string scene_name(translate_id(id_name(sce)));
index c375c09d869ecd62952a8f7e98033e78636bef31,5a0badf8d3a96aa35899ff3e3bb3d28ca4fb1dff..3a6386a87213f764262ca043a523ca758ec63a43
@@@ -39,12 -38,7 +39,7 @@@ SceneExporter::SceneExporter(COLLADASW:
  {
  }
  
- void SceneExporter::setExportTransformationType(BC_export_transformation_type transformation_type)
- {
-       this->transformation_type = transformation_type;
- }
 -void SceneExporter::exportScene(Scene *sce)
 +void SceneExporter::exportScene(const EvaluationContext *eval_ctx, Scene *sce)
  {
        // <library_visual_scenes> <visual_scene>
        std::string id_naming = id_name(sce);
index ded48983bd99b2e83b72ec07b18f8ddc87806d4e,b896b9abd8d28b83f2b08d9d6d7bd4fd892c57ec..3e3c15b836f958ffe7e8d7f8757b2dfd7df40e58
@@@ -96,15 -96,12 +96,12 @@@ class SceneExporter: COLLADASW::Library
  {
  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(Scene *sce);
++      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(Scene *sce);
 -      void writeNodes(Object *ob, Scene *sce);
 +      void exportHierarchy(const struct EvaluationContext *eval_ctx, Scene *sce);
 +      void writeNodes(const struct EvaluationContext *eval_ctx, Object *ob, Scene *sce);
        
        ArmatureExporter *arm_exporter;
        const ExportSettings *export_settings;
index 286444882e407685c935d6f53139fe2a8914e6ad,7f723aae71090dc5ee609cb15e43b283f3489596..04b828d35f92d8bf27bd2d564f630ab00816e74b
@@@ -32,6 -32,6 +32,7 @@@
  #include "DocumentImporter.h"
  #include "ExportSettings.h"
  #include "ImportSettings.h"
++#include "collada.h"
  
  extern "C"
  {
@@@ -68,39 -67,36 +69,39 @@@ int collada_import(bContext *C
        return 0;
  }
  
- int collada_export(bContext *C,
 -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,
 -                                 BC_export_texture_type export_texture_type,
--                                 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;
  
        export_settings.apply_modifiers          = apply_modifiers != 0;
        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.export_texture_type      = export_texture_type;
 +      export_settings.include_material_textures= include_material_textures != 0;
        export_settings.use_texture_copies       = use_texture_copies != 0;
  
        export_settings.triangulate                = triangulate != 0;
        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(sce, objectSet, (eObRelationTypes)includeFilter);
 +      export_settings.export_set = BKE_object_relational_superset(view_layer, objectSet, (eObRelationTypes)includeFilter);
 +
        int export_count = BLI_linklist_count(export_settings.export_set);
  
        if (export_count == 0) {
index 89853b8849f3db2c4d2581be1333d75de8d8a469,09b46c1de581ca16a647d0488b97f9798b991e98..47272255012a3565c8cae9b1f0987802f91d8039
@@@ -64,31 -69,33 +64,35 @@@ int collada_import(struct bContext *C
  
                                   int keep_bind_info);
  
- int collada_export(struct bContext *C,
 -int collada_export(struct EvaluationContext *eval_ctx,
 -                   struct 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,
 -                   BC_export_texture_type export_texture_type,
--                   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 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,fcd92e220c0ab3bcd80270c248b91251e483d2b1..d30f8e825908c3e7ee2610c97cea08c439307ddb
@@@ -152,7 -144,15 +154,16 @@@ EvaluationContext *bc_get_evaluation_co
        return bmain->eval_ctx;
  }
  
 -void bc_update_scene(Scene *scene, float ctime)
++
++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_update_for_newframe(ev_context, bmain, scene, scene->lay);
++      BKE_scene_graph_update_for_newframe(eval_ctx, eval_ctx->depsgraph, bmain, scene, eval_ctx->view_layer);
+ }
 -Object *bc_add_object(Scene *scene, int type, const char *name)
 +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 -891,179 +906,181 @@@ void bc_sanitize_mat(double mat[4][4], 
                        mat[i][j] = double_round(mat[i][j], precision);
  }
  
 -/*
 -* 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);
 -}
 -
+ 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,bbe36f2999c66f60b48f99aeaf8f6b44a3a1c993..cdc7b99722d2c358cca291d14df43fe3797c81ca
@@@ -60,13 -61,11 +60,14 @@@ extern "C" 
  #include "ExportSettings.h"
  #include "collada_internal.h"
  
 +struct EvaluationContext;
 +
  typedef std::map<COLLADAFW::TextureMapId, std::vector<MTex *> > TexIndexTextureArrayMap;
  
 +extern Scene *bc_get_scene(bContext *C);
  extern Main *bc_get_main();
  extern EvaluationContext *bc_get_evaluation_context();
 -extern void bc_update_scene(Scene *scene, float ctime);
++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);
index 98c88ba5fc9a522b7224603bd199a6f290246cd2,8826dc2971d4ee81a0e6a916db54e2f192e1b2a4..d89af5e85bdc2459373d7cd0d61f0d50987f34d1
@@@ -28,7 -28,7 +28,7 @@@
   *  \ingroup collada
   */
  #ifdef WITH_COLLADA
--#include "DNA_scene_types.h"
++#include "DNA_space_types.h"
  
  #include "BLT_translation.h"
  
@@@ -91,9 -87,12 +91,12 @@@ static int wm_collada_export_exec(bCont
        int include_armatures;
        int include_shapekeys;
        int deform_bones_only;
+       int include_animations;
+       int sample_animations;
        int sampling_rate;
  
 -      int export_texture_type;
 +      int include_material_textures;
        int use_texture_copies;
        int active_uv_only;
  
        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");
  
 -      export_texture_type      = RNA_enum_get(op->ptr, "export_texture_type_selection");
 +      include_material_textures = RNA_boolean_get(op->ptr, "include_material_textures");
        use_texture_copies       = RNA_boolean_get(op->ptr, "use_texture_copies");
        active_uv_only           = RNA_boolean_get(op->ptr, "active_uv_only");
  
        /* get editmode results */
        ED_object_editmode_load(CTX_data_edit_object(C));
  
-       export_count = collada_export(C,
 -      EvaluationContext *eval_ctx = G.main->eval_ctx;
+       Scene *scene = CTX_data_scene(C);
++      CTX_data_eval_ctx(C, &eval_ctx);
 -      export_count = collada_export(eval_ctx,
++      export_count = collada_export(&eval_ctx,
+               scene,
                filepath,
                apply_modifiers,
                export_mesh_type,
@@@ -376,10 -394,15 +394,16 @@@ void WM_OT_collada_export(wmOperatorTyp
        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",
                        "Export only the selected UV Map");
  
index f66c9ee99517d8740a370ac2093f719c05ffe649,bf5a06f0a1c9d78bc82d5271b46ec933a1d42903..61e0004915d2ea4c3db2377a793fcde06b30b7f8
@@@ -2802,9 -2914,11 +2805,10 @@@ static int uv_border_select_exec(bConte
        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) {
 -                      tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset);
 -                      if (!uvedit_face_visible_test(scene, ima, efa, tf))
 +                      if (!uvedit_face_visible_test(scene, obedit, ima, efa))
                                continue;
                        BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
                                luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
@@@ -3040,8 -3159,11 +3047,10 @@@ static bool do_lasso_select_mesh_uv(bCo
                }
        }
        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) {
 -                      tf = BM_ELEM_CD_GET_VOID_P(efa, cd_poly_tex_offset);
 -                      if (uvedit_face_visible_test(scene, ima, efa, tf)) {
 +                      if (uvedit_face_visible_test(scene, obedit, ima, efa)) {
                                BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
                                        if ((select) != (uvedit_uv_select_test(scene, l, cd_loop_uv_offset))) {
                                                MLoopUV *luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
index 580b4d3410674374fd3113a203ecccc6def17fdc,3043e636b318b72be47638dee2bc741f966758f7..212578cf3f03b6ce0396e52d02173daee6edf2c6
@@@ -407,72 -317,6 +348,7 @@@ 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. */
        func = RNA_def_function(srna, "alembic_export", "rna_Scene_alembic_export");