[Bf-blender-cvs] [7d247a658be] cycles_procedural_api: Alembic import: add an option to force the addition of a modifier on every object

Kévin Dietrich noreply at git.blender.org
Tue Oct 6 07:18:59 CEST 2020


Commit: 7d247a658bef51fa21a0172e53e134ee4a62ffe6
Author: Kévin Dietrich
Date:   Sun Oct 4 05:24:27 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rB7d247a658bef51fa21a0172e53e134ee4a62ffe6

Alembic import: add an option to force the addition of a modifier on
every object

This way we can read the full file from Cycles.

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

M	source/blender/editors/io/io_alembic.c
M	source/blender/io/alembic/ABC_alembic.h
M	source/blender/io/alembic/intern/abc_reader_curves.cc
M	source/blender/io/alembic/intern/abc_reader_mesh.cc
M	source/blender/io/alembic/intern/abc_reader_object.h
M	source/blender/io/alembic/intern/abc_reader_points.cc
M	source/blender/io/alembic/intern/alembic_capi.cc

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

diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c
index 292d8e6066c..cf694256573 100644
--- a/source/blender/editors/io/io_alembic.c
+++ b/source/blender/editors/io/io_alembic.c
@@ -594,6 +594,7 @@ static void ui_alembic_import_settings(uiLayout *layout, PointerRNA *imfptr)
   uiItemR(col, imfptr, "set_frame_range", 0, NULL, ICON_NONE);
   uiItemR(col, imfptr, "is_sequence", 0, NULL, ICON_NONE);
   uiItemR(col, imfptr, "validate_meshes", 0, NULL, ICON_NONE);
+  uiItemR(col, imfptr, "force_modifier", 0, NULL, ICON_NONE);
 }
 
 static void wm_alembic_import_draw(bContext *UNUSED(C), wmOperator *op)
@@ -627,6 +628,7 @@ static int wm_alembic_import_exec(bContext *C, wmOperator *op)
   const bool is_sequence = RNA_boolean_get(op->ptr, "is_sequence");
   const bool set_frame_range = RNA_boolean_get(op->ptr, "set_frame_range");
   const bool validate_meshes = RNA_boolean_get(op->ptr, "validate_meshes");
+  const bool force_modifier = RNA_boolean_get(op->ptr, "force_modifier");
   const bool as_background_job = RNA_boolean_get(op->ptr, "as_background_job");
 
   int offset = 0;
@@ -654,6 +656,7 @@ static int wm_alembic_import_exec(bContext *C, wmOperator *op)
                        sequence_len,
                        offset,
                        validate_meshes,
+                       force_modifier,
                        as_background_job);
 
   return as_background_job || ok ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
@@ -703,6 +706,12 @@ void WM_OT_alembic_import(wmOperatorType *ot)
                   "Validate Meshes",
                   "Check imported mesh objects for invalid data (slow)");
 
+  RNA_def_boolean(ot->srna,
+                  "force_modifier",
+                  false,
+                  "Force Modifier",
+                  "Add a cache modifier for every object in the Alembic archive, even if they are not animated");
+
   RNA_def_boolean(ot->srna,
                   "is_sequence",
                   false,
diff --git a/source/blender/io/alembic/ABC_alembic.h b/source/blender/io/alembic/ABC_alembic.h
index 9785f6d68ab..9504d2b99a6 100644
--- a/source/blender/io/alembic/ABC_alembic.h
+++ b/source/blender/io/alembic/ABC_alembic.h
@@ -95,6 +95,7 @@ bool ABC_import(struct bContext *C,
                 int sequence_len,
                 int offset,
                 bool validate_meshes,
+                bool force_modifier,
                 bool as_background_job);
 
 AbcArchiveHandle *ABC_create_handle(struct Main *bmain,
diff --git a/source/blender/io/alembic/intern/abc_reader_curves.cc b/source/blender/io/alembic/intern/abc_reader_curves.cc
index e29b6eda6fc..f199bf4b25b 100644
--- a/source/blender/io/alembic/intern/abc_reader_curves.cc
+++ b/source/blender/io/alembic/intern/abc_reader_curves.cc
@@ -112,7 +112,7 @@ void AbcCurveReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele
 
   read_curve_sample(cu, m_curves_schema, sample_sel);
 
-  if (has_animations(m_curves_schema, m_settings)) {
+  if (m_settings->force_modifier || has_animations(m_curves_schema, m_settings)) {
     addCacheModifier();
   }
 }
diff --git a/source/blender/io/alembic/intern/abc_reader_mesh.cc b/source/blender/io/alembic/intern/abc_reader_mesh.cc
index e69c0edfec8..853335905e8 100644
--- a/source/blender/io/alembic/intern/abc_reader_mesh.cc
+++ b/source/blender/io/alembic/intern/abc_reader_mesh.cc
@@ -529,7 +529,7 @@ void AbcMeshReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
 
   readFaceSetsSample(bmain, mesh, sample_sel);
 
-  if (has_animations(m_schema, m_settings)) {
+  if (m_settings->force_modifier || has_animations(m_schema, m_settings)) {
     addCacheModifier();
   }
 }
@@ -881,7 +881,7 @@ void AbcSubDReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelec
     BKE_mesh_validate(mesh, false, false);
   }
 
-  if (has_animations(m_schema, m_settings)) {
+  if (m_settings->force_modifier || has_animations(m_schema, m_settings)) {
     addCacheModifier();
   }
 }
diff --git a/source/blender/io/alembic/intern/abc_reader_object.h b/source/blender/io/alembic/intern/abc_reader_object.h
index 8e00ed42777..ff11f75348b 100644
--- a/source/blender/io/alembic/intern/abc_reader_object.h
+++ b/source/blender/io/alembic/intern/abc_reader_object.h
@@ -51,6 +51,7 @@ struct ImportSettings {
   int read_flag;
 
   bool validate_meshes;
+  bool force_modifier;
 
   CacheFile *cache_file;
 
@@ -65,6 +66,7 @@ struct ImportSettings {
         sequence_offset(0),
         read_flag(0),
         validate_meshes(false),
+        force_modifier(false),
         cache_file(NULL)
   {
   }
diff --git a/source/blender/io/alembic/intern/abc_reader_points.cc b/source/blender/io/alembic/intern/abc_reader_points.cc
index 88b5088805f..93dfc7ace0d 100644
--- a/source/blender/io/alembic/intern/abc_reader_points.cc
+++ b/source/blender/io/alembic/intern/abc_reader_points.cc
@@ -95,7 +95,7 @@ void AbcPointsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSel
   m_object = BKE_object_add_only_object(bmain, OB_MESH, m_object_name.c_str());
   m_object->data = mesh;
 
-  if (has_animations(m_schema, m_settings)) {
+  if (m_settings->force_modifier || has_animations(m_schema, m_settings)) {
     addCacheModifier();
   }
 }
diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc
index eba7f64db02..60d0d0af8e4 100644
--- a/source/blender/io/alembic/intern/alembic_capi.cc
+++ b/source/blender/io/alembic/intern/alembic_capi.cc
@@ -665,6 +665,7 @@ bool ABC_import(bContext *C,
                 int sequence_len,
                 int offset,
                 bool validate_meshes,
+                bool force_modifier,
                 bool as_background_job)
 {
   /* Using new here since MEM_* functions do not call constructor to properly initialize data. */
@@ -683,6 +684,7 @@ bool ABC_import(bContext *C,
   job->settings.sequence_len = sequence_len;
   job->settings.sequence_offset = offset;
   job->settings.validate_meshes = validate_meshes;
+  job->settings.force_modifier = force_modifier;
   job->error_code = ABC_NO_ERROR;
   job->was_cancelled = false;
   job->archive = NULL;



More information about the Bf-blender-cvs mailing list