[Bf-blender-cvs] [75c9b6fe8ff] sybren-usd: USD: hair export is now optional

Sybren A. Stüvel noreply at git.blender.org
Fri Jul 5 18:11:17 CEST 2019


Commit: 75c9b6fe8ffa4d81029f5dd6dccd3032898e0e10
Author: Sybren A. Stüvel
Date:   Fri Jul 5 15:00:26 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB75c9b6fe8ffa4d81029f5dd6dccd3032898e0e10

USD: hair export is now optional

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

M	source/blender/editors/io/io_usd.c
M	source/blender/usd/intern/usd_capi.cc
M	source/blender/usd/intern/usd_hierarchy_iterator.cc
M	source/blender/usd/intern/usd_writer_abstract.cc
M	source/blender/usd/usd.h

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

diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c
index 97459b94c24..62e3bcd0955 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -84,10 +84,12 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
   const bool as_background_job = RNA_boolean_get(op->ptr, "as_background_job");
   const bool selected_objects_only = RNA_boolean_get(op->ptr, "selected_objects_only");
   const bool visible_objects_only = RNA_boolean_get(op->ptr, "visible_objects_only");
-  const bool animation = RNA_boolean_get(op->ptr, "animation");
+  const bool export_animation = RNA_boolean_get(op->ptr, "export_animation");
+  const bool export_hair = RNA_boolean_get(op->ptr, "export_hair");
 
   struct USDExportParams params = {
-      animation,
+      export_animation,
+      export_hair,
       selected_objects_only,
       visible_objects_only,
   };
@@ -115,21 +117,24 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
                   false,
                   "Only Export Selected Objects",
                   "Only selected objects are exported. Unselected parents of selected objects are "
-                  "exported as empty transform.");
+                  "exported as empty transform");
 
   RNA_def_boolean(ot->srna,
                   "visible_objects_only",
                   false,
                   "Only Export Visible Objects",
                   "Only visible objects are exported. Invisible parents of visible objects are "
-                  "exported as empty transform.");
+                  "exported as empty transform");
 
   RNA_def_boolean(ot->srna,
-                  "animation",
-                  false,
+                  "export_animation",
+                  true,
                   "Export Animation",
                   "When true, the render frame range is exported. When false, only the current "
-                  "frame is exported.");
+                  "frame is exported");
+
+  RNA_def_boolean(
+      ot->srna, "export_hair", false, "Export Hair", "When true, hair is exported as USD curves");
 
   RNA_def_boolean(
       ot->srna,
diff --git a/source/blender/usd/intern/usd_capi.cc b/source/blender/usd/intern/usd_capi.cc
index 398379820b4..7a84f854a91 100644
--- a/source/blender/usd/intern/usd_capi.cc
+++ b/source/blender/usd/intern/usd_capi.cc
@@ -103,7 +103,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
     usd_stage->SetMetadata(pxr::UsdGeomTokens->upAxis, pxr::VtValue(pxr::UsdGeomTokens->z));
 
     // Set up the stage for animated data.
-    if (data->params.do_animation) {
+    if (data->params.export_animation) {
       usd_stage->SetTimeCodesPerSecond(FPS);
       usd_stage->SetStartTimeCode(scene->r.sfra);
       usd_stage->SetEndTimeCode(scene->r.efra);
@@ -111,7 +111,7 @@ static void export_startjob(void *customdata, short *stop, short *do_update, flo
 
     USDHierarchyIterator iter(data->depsgraph, usd_stage, data->params);
 
-    if (data->params.do_animation) {
+    if (data->params.export_animation) {
       for (float frame = scene->r.sfra; frame < scene->r.efra; frame++) {
         *progress = 0.09 * frame;
 
diff --git a/source/blender/usd/intern/usd_hierarchy_iterator.cc b/source/blender/usd/intern/usd_hierarchy_iterator.cc
index 31beaeeb9e9..de10a8e7e44 100644
--- a/source/blender/usd/intern/usd_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/usd_hierarchy_iterator.cc
@@ -120,6 +120,9 @@ AbstractHierarchyWriter *USDHierarchyIterator::create_data_writer(const Hierarch
 
 AbstractHierarchyWriter *USDHierarchyIterator::create_hair_writer(const HierarchyContext &context)
 {
+  if (!params.export_hair) {
+    return nullptr;
+  }
   return new USDHairWriter(create_usd_export_context(context));
 }
 
diff --git a/source/blender/usd/intern/usd_writer_abstract.cc b/source/blender/usd/intern/usd_writer_abstract.cc
index 86143b1d035..793ff7c1ed7 100644
--- a/source/blender/usd/intern/usd_writer_abstract.cc
+++ b/source/blender/usd/intern/usd_writer_abstract.cc
@@ -49,7 +49,7 @@ void USDAbstractWriter::write(HierarchyContext &context)
     }
   }
   else {
-    is_animated_ = export_params.do_animation && check_is_animated(context);
+    is_animated_ = export_params.export_animation && check_is_animated(context);
     // printf("%sANIMATION\033[0m: %20s: %s\n",
     //        is_animated_ ? "\033[32;1m" : "\033[31;1m",
     //        context.export_path.c_str(),
diff --git a/source/blender/usd/usd.h b/source/blender/usd/usd.h
index ad2b087de3f..a9d5221d688 100644
--- a/source/blender/usd/usd.h
+++ b/source/blender/usd/usd.h
@@ -29,7 +29,8 @@ struct Scene;
 struct bContext;
 
 struct USDExportParams {
-  bool do_animation;
+  bool export_animation;
+  bool export_hair;
   bool selected_objects_only;
   bool visible_objects_only;
 };



More information about the Bf-blender-cvs mailing list