USD Export: Save Blender file path to metadata.
Write source Blender file path to stage customData.
This commit is contained in:
parent
19fa05d37c
commit
90e1c892b7
|
@ -303,6 +303,8 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
|
|||
|
||||
const bool export_blendshapes = RNA_boolean_get(op->ptr, "export_blendshapes");
|
||||
|
||||
const bool export_blender_metadata = RNA_boolean_get(op->ptr, "export_blender_metadata");
|
||||
|
||||
struct USDExportParams params = {RNA_int_get(op->ptr, "start"),
|
||||
RNA_int_get(op->ptr, "end"),
|
||||
export_animation,
|
||||
|
@ -359,7 +361,8 @@ static int wm_usd_export_exec(bContext *C, wmOperator *op)
|
|||
xform_op_mode,
|
||||
fix_skel_root,
|
||||
overwrite_textures,
|
||||
export_blendshapes};
|
||||
export_blendshapes,
|
||||
export_blender_metadata};
|
||||
|
||||
/* Take some defaults from the scene, if not specified explicitly. */
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
@ -424,6 +427,7 @@ static void wm_usd_export_draw(bContext *C, wmOperator *op)
|
|||
|
||||
box = uiLayoutBox(layout);
|
||||
uiItemL(box, IFACE_("Attributes:"), ICON_NONE);
|
||||
uiItemR(box, ptr, "export_blender_metadata", 0, NULL, ICON_NONE);
|
||||
uiItemR(box, ptr, "export_custom_properties", 0, NULL, ICON_NONE);
|
||||
if (RNA_boolean_get(ptr, "export_custom_properties")) {
|
||||
uiItemR(box, ptr, "add_properties_namespace", 0, NULL, ICON_NONE);
|
||||
|
@ -517,6 +521,7 @@ static void wm_usd_export_draw(bContext *C, wmOperator *op)
|
|||
uiItemL(box, IFACE_("Experimental:"), ICON_NONE);
|
||||
uiItemR(box, ptr, "use_instancing", 0, NULL, ICON_NONE);
|
||||
uiItemR(box, ptr, "fix_skel_root", 0, NULL, ICON_NONE);
|
||||
|
||||
}
|
||||
|
||||
static bool wm_usd_export_check(bContext *UNUSED(C), wmOperator *op)
|
||||
|
@ -915,6 +920,12 @@ void WM_OT_usd_export(struct wmOperatorType *ot)
|
|||
"Relative Paths",
|
||||
"Use relative paths to reference external files (i.e. textures, volumes) in "
|
||||
"USD, otherwise use absolute paths");
|
||||
|
||||
RNA_def_boolean(ot->srna,
|
||||
"export_blender_metadata",
|
||||
true,
|
||||
"Export Blender Metadata",
|
||||
"Write Blender-specific information to the Stage's customLayerData");
|
||||
}
|
||||
|
||||
/* ====== USD Import ====== */
|
||||
|
|
|
@ -288,6 +288,25 @@ static void export_startjob(void *customdata,
|
|||
usd_stage->GetRootLayer()->SetDocumentation(std::string("Blender v") +
|
||||
BKE_blender_version_string());
|
||||
|
||||
/* Add any Blender-specific custom export data */
|
||||
if (data->params.export_blender_metadata && strlen(data->bmain->filepath)) {
|
||||
auto root_layer = usd_stage->GetRootLayer();
|
||||
char full_path[1024];
|
||||
strcpy(full_path, data->bmain->filepath);
|
||||
|
||||
// make all paths uniformly unix-like
|
||||
BLI_str_replace_char(full_path + 2, SEP, ALTSEP);
|
||||
|
||||
char basename[128];
|
||||
strcpy(basename, BLI_path_basename(full_path));
|
||||
BLI_split_dir_part(full_path, full_path, 1024);
|
||||
|
||||
pxr::VtDictionary custom_data;
|
||||
custom_data.SetValueAtPath(std::string("sourceFilename"), pxr::VtValue(basename));
|
||||
custom_data.SetValueAtPath(std::string("sourceDirPath"), pxr::VtValue(full_path));
|
||||
root_layer->SetCustomLayerData(custom_data);
|
||||
}
|
||||
|
||||
/* Set up the stage for animated data. */
|
||||
if (data->params.export_animation) {
|
||||
usd_stage->SetTimeCodesPerSecond(FPS);
|
||||
|
|
|
@ -121,6 +121,7 @@ struct USDExportParams {
|
|||
bool fix_skel_root;
|
||||
bool overwrite_textures;
|
||||
bool export_blendshapes;
|
||||
bool export_blender_metadata;
|
||||
};
|
||||
|
||||
struct USDImportParams {
|
||||
|
|
Loading…
Reference in New Issue