USD export: option to add a root prim. #107855
|
@ -137,7 +137,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
|
||||||
const bool export_textures = RNA_boolean_get(op->ptr, "export_textures");
|
const bool export_textures = RNA_boolean_get(op->ptr, "export_textures");
|
||||||
const bool overwrite_textures = RNA_boolean_get(op->ptr, "overwrite_textures");
|
const bool overwrite_textures = RNA_boolean_get(op->ptr, "overwrite_textures");
|
||||||
const bool relative_paths = RNA_boolean_get(op->ptr, "relative_paths");
|
const bool relative_paths = RNA_boolean_get(op->ptr, "relative_paths");
|
||||||
const bool add_root = RNA_boolean_get(op->ptr, "add_root");
|
const bool add_root_node = RNA_boolean_get(op->ptr, "add_root_node");
|
||||||
|
|
||||||
struct USDExportParams params = {
|
struct USDExportParams params = {
|
||||||
export_animation,
|
export_animation,
|
||||||
|
@ -153,7 +153,7 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
|
||||||
export_textures,
|
export_textures,
|
||||||
overwrite_textures,
|
overwrite_textures,
|
||||||
relative_paths,
|
relative_paths,
|
||||||
add_root,
|
add_root_node,
|
||||||
};
|
};
|
||||||
|
|
||||||
brecht marked this conversation as resolved
|
|||||||
bool ok = USD_export(C, filename, ¶ms, as_background_job);
|
bool ok = USD_export(C, filename, ¶ms, as_background_job);
|
||||||
|
@ -181,7 +181,7 @@ static void wm_usd_export_draw(bContext *UNUSED(C), wmOperator *op)
|
||||||
uiItemR(col, ptr, "export_uvmaps", 0, NULL, ICON_NONE);
|
uiItemR(col, ptr, "export_uvmaps", 0, NULL, ICON_NONE);
|
||||||
uiItemR(col, ptr, "export_normals", 0, NULL, ICON_NONE);
|
uiItemR(col, ptr, "export_normals", 0, NULL, ICON_NONE);
|
||||||
uiItemR(col, ptr, "export_materials", 0, NULL, ICON_NONE);
|
uiItemR(col, ptr, "export_materials", 0, NULL, ICON_NONE);
|
||||||
uiItemR(col, ptr, "add_root", 0, NULL, ICON_NONE);
|
uiItemR(col, ptr, "add_root_node", 0, NULL, ICON_NONE);
|
||||||
|
|
||||||
col = uiLayoutColumn(box, true);
|
col = uiLayoutColumn(box, true);
|
||||||
uiItemR(col, ptr, "evaluation_mode", 0, NULL, ICON_NONE);
|
uiItemR(col, ptr, "evaluation_mode", 0, NULL, ICON_NONE);
|
||||||
|
@ -339,10 +339,11 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
|
||||||
"USD, otherwise use absolute paths");
|
"USD, otherwise use absolute paths");
|
||||||
|
|
||||||
RNA_def_boolean(ot->srna,
|
RNA_def_boolean(ot->srna,
|
||||||
"add_root",
|
"add_root_node",
|
||||||
false,
|
false,
|
||||||
"Add Root",
|
"Add Root Node",
|
||||||
"Add a Root 'Scope' node to the stage.");
|
"Add a Root 'Xform' node to the stage that can be used in other applications"
|
||||||
|
"to transform all the primitives in the stage");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ====== USD Import ====== */
|
/* ====== USD Import ====== */
|
||||||
|
|
|
@ -112,7 +112,7 @@ static void export_startjob(void *customdata,
|
||||||
usd_stage->SetEndTimeCode(scene->r.efra);
|
usd_stage->SetEndTimeCode(scene->r.efra);
|
||||||
}
|
}
|
||||||
|
|
||||||
brecht marked this conversation as resolved
Matt McLin
commented
I wonder if it might be better to remove this I wonder if it might be better to remove this `WM_reportf`? If every failure path in `prim_path_valid` already reports an error, then this seems superfluous, and also the error reported from `prim_path_valid` provides more explicit guidance to the user about the problem.
Michael Kowalski
commented
I agree and will remove the report statement. Thanks very much for the review! I agree and will remove the report statement. Thanks very much for the review!
|
|||||||
if (data->params.add_root) {
|
if (data->params.add_root_node) {
|
||||||
pxr::UsdGeomXform::Define(usd_stage, pxr::SdfPath("/Root"));
|
pxr::UsdGeomXform::Define(usd_stage, pxr::SdfPath("/Root"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ const pxr::UsdTimeCode &USDHierarchyIterator::get_export_time_code() const
|
||||||
USDExporterContext USDHierarchyIterator::create_usd_export_context(const HierarchyContext *context)
|
USDExporterContext USDHierarchyIterator::create_usd_export_context(const HierarchyContext *context)
|
||||||
{
|
{
|
||||||
pxr::SdfPath path;
|
pxr::SdfPath path;
|
||||||
if (params_.add_root) {
|
if (params_.add_root_node) {
|
||||||
path = pxr::SdfPath("/Root" + context->export_path);
|
path = pxr::SdfPath("/Root" + context->export_path);
|
||||||
} else {
|
} else {
|
||||||
path = pxr::SdfPath(context->export_path);
|
path = pxr::SdfPath(context->export_path);
|
||||||
|
|
|
@ -50,7 +50,7 @@ struct USDExportParams {
|
||||||
bool export_textures;
|
bool export_textures;
|
||||||
bool overwrite_textures;
|
bool overwrite_textures;
|
||||||
bool relative_paths;
|
bool relative_paths;
|
||||||
bool add_root;
|
bool add_root_node;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct USDImportParams {
|
struct USDImportParams {
|
||||||
|
|
Loading…
Reference in New Issue
I see this is same convention used everywhere else, so not a problem for this PR, but just a question: it seems
RNA_string_get
doesn't concern itself with potential buffer overflow or null termination (which could impact thestrlen
operation inprocess_prim_path
, among other things). Is this somehow handled in a clever way that I'm missing?The
RNA_def_string
for this property sets the maximum length toFILE_MAX
, so this is ok.