[Bf-blender-cvs] [53e20493642] sybren-usd: USD: Offer choice for viewport or render settings
Sybren A. Stüvel
noreply at git.blender.org
Fri Jul 12 15:21:12 CEST 2019
Commit: 53e2049364229c00eb926e5c65e35b86acb04a26
Author: Sybren A. Stüvel
Date: Fri Jul 12 15:19:44 2019 +0200
Branches: sybren-usd
https://developer.blender.org/rB53e2049364229c00eb926e5c65e35b86acb04a26
USD: Offer choice for viewport or render settings
The exporter operator now takes a parameter to choose the depsgraph
evaluation mode (Viewport/Render). This makes it easier to switch between
exporting particle hair (Render) or mesh hair (Viewport).
===================================================================
M source/blender/editors/io/io_usd.c
M source/blender/usd/intern/abstract_hierarchy_iterator.cc
M source/blender/usd/intern/usd_capi.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 62e3bcd0955..6041ffcbf21 100644
--- a/source/blender/editors/io/io_usd.c
+++ b/source/blender/editors/io/io_usd.c
@@ -37,9 +37,25 @@
# include "WM_api.h"
# include "WM_types.h"
+# include "DEG_depsgraph.h"
+
# include "io_usd.h"
# include "usd.h"
+const EnumPropertyItem rna_enum_usd_export_evaluation_mode_items[] = {
+ {DAG_EVAL_RENDER,
+ "RENDER",
+ 0,
+ "Render",
+ "Use Render settings for object visibility, modifier settings, etc"},
+ {DAG_EVAL_VIEWPORT,
+ "VIEWPORT",
+ 0,
+ "Viewport",
+ "Use Viewport settings for object visibility, modifier settings, etc"},
+ {0, NULL, 0, NULL, NULL},
+};
+
static int wm_usd_export_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
if (!RNA_struct_property_is_set(op->ptr, "as_background_job")) {
@@ -86,12 +102,14 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
const bool visible_objects_only = RNA_boolean_get(op->ptr, "visible_objects_only");
const bool export_animation = RNA_boolean_get(op->ptr, "export_animation");
const bool export_hair = RNA_boolean_get(op->ptr, "export_hair");
+ const bool evaluation_mode = RNA_boolean_get(op->ptr, "evaluation_mode");
struct USDExportParams params = {
export_animation,
export_hair,
selected_objects_only,
visible_objects_only,
+ evaluation_mode,
};
bool ok = USD_export(scene, C, filename, ¶ms, as_background_job);
@@ -121,14 +139,14 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
RNA_def_boolean(ot->srna,
"visible_objects_only",
- false,
+ true,
"Only Export Visible Objects",
"Only visible objects are exported. Invisible parents of visible objects are "
"exported as empty transform");
RNA_def_boolean(ot->srna,
"export_animation",
- true,
+ false,
"Export Animation",
"When true, the render frame range is exported. When false, only the current "
"frame is exported");
@@ -136,6 +154,13 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
RNA_def_boolean(
ot->srna, "export_hair", false, "Export Hair", "When true, hair is exported as USD curves");
+ RNA_def_enum(ot->srna,
+ "evaluation_mode",
+ rna_enum_usd_export_evaluation_mode_items,
+ DAG_EVAL_RENDER,
+ "Evaluation Mode",
+ "Determines visibility of objects and modifier settings");
+
RNA_def_boolean(
ot->srna,
"as_background_job",
diff --git a/source/blender/usd/intern/abstract_hierarchy_iterator.cc b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
index fc40178365f..b8cbe8b64f7 100644
--- a/source/blender/usd/intern/abstract_hierarchy_iterator.cc
+++ b/source/blender/usd/intern/abstract_hierarchy_iterator.cc
@@ -314,6 +314,9 @@ void AbstractHierarchyIterator::make_writers(const HierarchyContext &parent_cont
}
BLI_assert(DEG_is_evaluated_object(context.object));
+ /* XXX This can lead to too many XForms being written. For example, a camera writer can refuse
+ * to write an orthographic camera. By the time that this is known, the XForm has already been
+ * written. */
xform_writer->write(context);
if (!context.weak_export) {
diff --git a/source/blender/usd/intern/usd_capi.cc b/source/blender/usd/intern/usd_capi.cc
index cedc539acbd..d1b84c453bc 100644
--- a/source/blender/usd/intern/usd_capi.cc
+++ b/source/blender/usd/intern/usd_capi.cc
@@ -196,7 +196,7 @@ bool USD_export(Scene *scene,
BLI_strncpy(job->filename, filepath, 1024);
ViewLayer *view_layer = CTX_data_view_layer(C);
- job->depsgraph = DEG_graph_new(scene, view_layer, DAG_EVAL_RENDER);
+ job->depsgraph = DEG_graph_new(scene, view_layer, params->evaluation_mode);
job->params = *params;
bool export_ok = false;
diff --git a/source/blender/usd/usd.h b/source/blender/usd/usd.h
index a9d5221d688..1f958048bf5 100644
--- a/source/blender/usd/usd.h
+++ b/source/blender/usd/usd.h
@@ -25,6 +25,8 @@
extern "C" {
#endif
+#include "DEG_depsgraph.h"
+
struct Scene;
struct bContext;
@@ -33,6 +35,7 @@ struct USDExportParams {
bool export_hair;
bool selected_objects_only;
bool visible_objects_only;
+ enum eEvaluationMode evaluation_mode;
};
/* The USD_export takes a as_background_job parameter, and returns a boolean.
More information about the Bf-blender-cvs
mailing list