merge from master (needed to fix collada headerfiles which have been modified in...
authorGaia Clary <gaia.clary@machinimatrix.org>
Wed, 28 Feb 2018 16:29:56 +0000 (17:29 +0100)
committerGaia Clary <gaia.clary@machinimatrix.org>
Wed, 28 Feb 2018 16:29:56 +0000 (17:29 +0100)
1  2 
source/blender/collada/DocumentExporter.cpp
source/blender/collada/DocumentExporter.h
source/blender/collada/ExportSettings.h
source/blender/collada/collada.cpp
source/blender/collada/collada.h
source/blender/editors/io/io_collada.c

index 437cdac974b483f01d11f0d563b1690b7d3eb143,d4eb6b477db83cad9461fb67f5b7dfd5392a340b..04af73f24066f3974a1fba9fbfaf2a36fe8bfcf1
@@@ -181,7 -181,7 +181,8 @@@ static COLLADABU::NativeString make_tem
  // 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(Scene *sce)
  {
        PointerRNA sceneptr, unit_settings;
        PropertyRNA *system; /* unused , *scale; */
index badf4f5a6532df2d20caf4a17ec1f0b70ea02197,60e5deb0e31c553c08248a717d9c4d0c8d4df8d5..68e1523fbeef0924c6a6c9c83d1596d2246327ee
@@@ -31,6 -31,7 +31,7 @@@
  
  extern "C" {
  #include "DNA_customdata_types.h"
 -#include "BKE_depsgraph.h"
++
  }
  
  struct Scene;
@@@ -38,8 -39,8 +39,9 @@@
  class DocumentExporter
  {
   public:
 -      DocumentExporter(const ExportSettings *export_settings);
 -      int  exportCurrentScene(const EvaluationContext *eval_ctx, Scene *sce);
 +      DocumentExporter(EvaluationContext *eval_ctx, const ExportSettings *export_settings);
 +      int  exportCurrentScene(Scene *sce);
++
        void exportScenes(const char *filename);
  private:
        const ExportSettings *export_settings;
index 620ccedd54423585e171d8b9d7c2f65dd2069c38,fa6751bef6093a84f27ca603525ea3b565d304e7..b6a7c1f1b4e829e925cae95a420fca25f0f3c667
  #ifndef __EXPORTSETTINGS_H__
  #define __EXPORTSETTINGS_H__
  
- #include "collada.h"
- #include "collada.h"
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ #include "BLI_linklist.h"
+ typedef enum BC_export_mesh_type {
+       BC_MESH_TYPE_VIEW,
+       BC_MESH_TYPE_RENDER
+ } BC_export_mesh_type;
+ typedef enum BC_export_transformation_type {
+       BC_TRANSFORMATION_TYPE_MATRIX,
+       BC_TRANSFORMATION_TYPE_TRANSROTLOC
+ } BC_export_transformation_type;
  
- struct ExportSettings {
- public:
 -typedef enum BC_export_texture_type {
 -      BC_TEXTURE_TYPE_MAT,
 -      BC_TEXTURE_TYPE_UV
 -} BC_export_texture_type;
+ typedef struct ExportSettings {
        bool apply_modifiers;
        BC_export_mesh_type export_mesh_type;
  
index b86246c13991486170c6c25277fb70aac69231f0,3794b6aefacd563c121d80ad5344cd610924e76a..64e3a4c36ce82c4d768dda6342dc14177030c6c7
@@@ -44,100 -42,27 +44,29 @@@ extern "C
  #include "BLI_fileops.h"
  #include "BLI_linklist.h"
  
- int collada_import(bContext *C,
-                                  const char *filepath,
-                                  int import_units,
-                                  int find_chains,
-                                  int auto_connect,
-                                  int fix_orientation,
-                                  int min_chain_length,
-                                  int keep_bind_info)
+ int collada_import(bContext *C, ImportSettings *import_settings)
  {
-       ImportSettings import_settings;
-       import_settings.filepath         = (char *)filepath;
-       import_settings.import_units     = import_units != 0;
-       import_settings.auto_connect     = auto_connect != 0;
-       import_settings.find_chains      = find_chains != 0;
-       import_settings.fix_orientation  = fix_orientation != 0;
-       import_settings.min_chain_length = min_chain_length;
-       import_settings.keep_bind_info = keep_bind_info !=0;
-       DocumentImporter imp(C, &import_settings);
-       if (imp.import()) return 1;
-       return 0;
+       DocumentImporter imp(C, import_settings);
+       return (imp.import())? 1:0;
  }
  
- 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)
+ int collada_export(EvaluationContext *eval_ctx,
+                    Scene *sce,
+                    ExportSettings *export_settings)
  {
-       ExportSettings export_settings;
 +      ViewLayer *view_layer = eval_ctx->view_layer;
  
-       export_settings.filepath                 = (char *)filepath;
-       export_settings.apply_modifiers          = apply_modifiers != 0;
-       export_settings.export_mesh_type         = export_mesh_type;
-       export_settings.selected                 = selected          != 0;
-       export_settings.include_children         = include_children  != 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.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;
-       export_settings.use_texture_copies       = use_texture_copies != 0;
-       export_settings.triangulate                = triangulate != 0;
-       export_settings.use_object_instantiation   = use_object_instantiation != 0;
-       export_settings.use_blender_profile        = use_blender_profile != 0;
-       export_settings.sort_by_name               = sort_by_name != 0;
-       export_settings.export_transformation_type = export_transformation_type;
-       export_settings.open_sim                   = open_sim != 0;
-       export_settings.limit_precision = limit_precision != 0;
-       export_settings.keep_bind_info = keep_bind_info !=0;
        int includeFilter = OB_REL_NONE;
-       if (export_settings.include_armatures) includeFilter |= OB_REL_MOD_ARMATURE;
-       if (export_settings.include_children) includeFilter |= OB_REL_CHILDREN_RECURSIVE;
+       if (export_settings->include_armatures) includeFilter |= OB_REL_MOD_ARMATURE;
+       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);
+       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);
+       int export_count = BLI_linklist_count(export_settings->export_set);
  
        if (export_count == 0) {
-               if (export_settings.selected) {
+               if (export_settings->selected) {
                        fprintf(stderr, "Collada: Found no objects to export.\nPlease ensure that all objects which shall be exported are also visible in the 3D Viewport.\n");
                }
                else {
                }
        }
        else {
-               if (export_settings.sort_by_name)
-                       bc_bubble_sort_by_Object_name(export_settings.export_set);
+               if (export_settings->sort_by_name)
+                       bc_bubble_sort_by_Object_name(export_settings->export_set);
        }
  
-       DocumentExporter exporter(eval_ctx, &export_settings);
 -      DocumentExporter exporter(export_settings);
 -      int status = exporter.exportCurrentScene(eval_ctx, sce);
++      DocumentExporter exporter(eval_ctx, export_settings);
 +      int status = exporter.exportCurrentScene(sce);
  
-       BLI_linklist_free(export_settings.export_set, NULL);
+       BLI_linklist_free(export_settings->export_set, NULL);
  
        return (status) ? -1:export_count;
  }
index 47272255012a3565c8cae9b1f0987802f91d8039,312f11d4ba9af43ec0e1c7288510d0e61d56ed27..f95fca03b654214ab285f179e4df9aff597c1d51
@@@ -36,63 -41,20 +40,21 @@@ extern "C" 
  #include "BLI_path_util.h"
  #include "RNA_types.h"
  
- typedef enum BC_export_mesh_type {
-       BC_MESH_TYPE_VIEW,
-       BC_MESH_TYPE_RENDER
- } BC_export_mesh_type;
- typedef enum BC_export_transformation_type {
-       BC_TRANSFORMATION_TYPE_MATRIX,
-       BC_TRANSFORMATION_TYPE_TRANSROTLOC
- } BC_export_transformation_type;
--
 -struct EvaluationContext;
  struct bContext;
  struct Scene;
 +struct ViewLayer;
 +struct EvaluationContext;
  
  /*
   * both return 1 on success, 0 on error
   */
  int collada_import(struct bContext *C,
-                    const char *filepath,
-                                  int import_units,
-                                  int find_chains,
-                                  int auto_connect,
-                                  int fix_orientation,
-                                  int min_chain_length,
-                                  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,
+                                  ImportSettings *import_settings);
  
-       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(struct EvaluationContext *eval_ctx,
+                    struct Scene *sce,
+                    ExportSettings *export_settings);
  
  #ifdef __cplusplus
  }
index 443b8afd6ff26899a653886b612f681d0ea4377c,e6c9b924c7fb21c01b24eded6cd57ba2fa7e901c..a42aeee912ba1b40f6a97c4f422f9ce06b00d7ba
  #include "BKE_global.h"
  #include "BKE_main.h"
  #include "BKE_report.h"
+ #include "BKE_object.h"
  
 +#include "DEG_depsgraph.h"
 +
  #include "ED_screen.h"
  #include "ED_object.h"
  
@@@ -171,35 -166,43 +172,42 @@@ static int wm_collada_export_exec(bCont
        /* get editmode results */
        ED_object_editmode_load(CTX_data_edit_object(C));
  
 -      EvaluationContext *eval_ctx = G.main->eval_ctx;
        Scene *scene = CTX_data_scene(C);
 -      export_settings.export_texture_type = export_texture_type;
 +      CTX_data_eval_ctx(C, &eval_ctx);
 +
+       ExportSettings export_settings;
+       export_settings.filepath = filepath;
+       export_settings.apply_modifiers = apply_modifiers != 0;
+       export_settings.export_mesh_type = export_mesh_type;
+       export_settings.selected = selected != 0;
+       export_settings.include_children = include_children != 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.include_animations = include_animations;
+       export_settings.sampling_rate = sampling_rate;
+       export_settings.active_uv_only = active_uv_only != 0;
 -
 -      export_count = collada_export(eval_ctx,
+       export_settings.use_texture_copies = use_texture_copies != 0;
+       export_settings.triangulate = triangulate != 0;
+       export_settings.use_object_instantiation = use_object_instantiation != 0;
+       export_settings.use_blender_profile = use_blender_profile != 0;
+       export_settings.sort_by_name = sort_by_name != 0;
+       export_settings.export_transformation_type = export_transformation_type;
+       export_settings.open_sim = open_sim != 0;
+       export_settings.limit_precision = limit_precision != 0;
+       export_settings.keep_bind_info = keep_bind_info != 0;
+       int includeFilter = OB_REL_NONE;
+       if (export_settings.include_armatures) includeFilter |= OB_REL_MOD_ARMATURE;
+       if (export_settings.include_children) includeFilter |= OB_REL_CHILDREN_RECURSIVE;
 +      export_count = collada_export(&eval_ctx,
                scene,
-               filepath,
-               apply_modifiers,
-               export_mesh_type,
-               selected,
-               include_children,
-               include_armatures,
-               include_shapekeys,
-               deform_bones_only,
-               include_animations,
-               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
+               &export_settings
        );
  
        if (export_count == 0) {
@@@ -472,16 -487,17 +481,18 @@@ static int wm_collada_import_exec(bCont
        min_chain_length = RNA_int_get(op->ptr, "min_chain_length");
  
        RNA_string_get(op->ptr, "filepath", filename);
-       if (collada_import(
-               C, filename,
-               import_units,
-               find_chains,
-               auto_connect,
-               fix_orientation,
-               min_chain_length,
-               keep_bind_info) )
+       import_settings.filepath = filename;
+       import_settings.import_units = import_units != 0;
+       import_settings.auto_connect = auto_connect != 0;
+       import_settings.find_chains = find_chains != 0;
+       import_settings.fix_orientation = fix_orientation != 0;
+       import_settings.min_chain_length = min_chain_length;
+       import_settings.keep_bind_info = keep_bind_info != 0;
+       if (collada_import(C, &import_settings) )
        {
 +              DEG_id_tag_update(&CTX_data_scene(C)->id, DEG_TAG_BASE_FLAGS_UPDATE);
                return OPERATOR_FINISHED;
        }
        else {