forked from blender/blender
USD: Fix Export progress report. #2
@ -215,6 +215,15 @@ static pxr::UsdStageRefPtr export_to_stage(const USDExportParams ¶ms,
|
||||
Scene *scene = DEG_get_input_scene(depsgraph);
|
||||
Main *bmain = DEG_get_bmain(depsgraph);
|
||||
|
||||
/* This whole `export_to_stage` function is assumed to cover about 80% of the whole export
|
||||
* process, from 0.1f to 0.9f. */
|
||||
if (progress) {
|
||||
*progress = 0.10f;
|
||||
}
|
||||
if (do_update) {
|
||||
*do_update = true;
|
||||
}
|
||||
|
||||
usd_stage->SetMetadata(pxr::UsdGeomTokens->metersPerUnit, double(scene->unit.scale_length));
|
||||
usd_stage->GetRootLayer()->SetDocumentation(std::string("Blender v") +
|
||||
BKE_blender_version_string());
|
||||
@ -237,9 +246,16 @@ static pxr::UsdStageRefPtr export_to_stage(const USDExportParams ¶ms,
|
||||
|
||||
USDHierarchyIterator iter(bmain, depsgraph, usd_stage, params);
|
||||
|
||||
if (progress) {
|
||||
*progress = 0.11f;
|
||||
}
|
||||
if (do_update) {
|
||||
*do_update = true;
|
||||
}
|
||||
|
||||
if (params.export_animation) {
|
||||
/* Writing the animated frames is not 100% of the work, but it's our best guess. */
|
||||
float progress_per_frame = 1.0f / std::max(1, (scene->r.efra - scene->r.sfra + 1));
|
||||
/* Writing the animated frames is not 100% of the work, here it's assumed to be 75% of it. */
|
||||
float progress_per_frame = 0.75f / std::max(1, (scene->r.efra - scene->r.sfra + 1));
|
||||
|
||||
for (float frame = scene->r.sfra; frame <= scene->r.efra; frame++) {
|
||||
if (G.is_break || (stop != nullptr && *stop)) {
|
||||
@ -267,6 +283,13 @@ static pxr::UsdStageRefPtr export_to_stage(const USDExportParams ¶ms,
|
||||
iter.iterate_and_write();
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
*progress = 0.86f;
|
||||
}
|
||||
if (do_update) {
|
||||
*do_update = true;
|
||||
}
|
||||
|
||||
iter.release_writers();
|
||||
|
||||
/* Set the default prim if it doesn't exist */
|
||||
@ -281,12 +304,26 @@ static pxr::UsdStageRefPtr export_to_stage(const USDExportParams ¶ms,
|
||||
|
||||
call_export_hooks(usd_stage, depsgraph);
|
||||
|
||||
if (progress) {
|
||||
*progress = 0.88f;
|
||||
}
|
||||
if (do_update) {
|
||||
*do_update = true;
|
||||
}
|
||||
|
||||
/* Finish up by going back to the keyframe that was current before we started. */
|
||||
if (scene->r.cfra != orig_frame) {
|
||||
scene->r.cfra = orig_frame;
|
||||
BKE_scene_graph_update_for_newframe(depsgraph);
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
*progress = 0.9f;
|
||||
}
|
||||
if (do_update) {
|
||||
*do_update = true;
|
||||
}
|
||||
|
||||
return usd_stage;
|
||||
}
|
||||
|
||||
@ -314,6 +351,9 @@ static void export_startjob(void *customdata,
|
||||
}
|
||||
G.is_break = false;
|
||||
|
||||
*progress = 0.01f;
|
||||
*do_update = true;
|
||||
|
||||
/* Evaluate the despgraph for exporting.
|
||||
*
|
||||
* Note that, unlike with its building, this is expected to be safe to perform from worker
|
||||
@ -323,7 +363,7 @@ static void export_startjob(void *customdata,
|
||||
* #USD_export. */
|
||||
BKE_scene_graph_update_tagged(data->depsgraph, data->bmain);
|
||||
|
||||
*progress = 0.0f;
|
||||
*progress = 0.1f;
|
||||
*do_update = true;
|
||||
|
||||
pxr::UsdStageRefPtr usd_stage = export_to_stage(
|
||||
@ -340,6 +380,9 @@ static void export_startjob(void *customdata,
|
||||
|
||||
usd_stage->GetRootLayer()->Save();
|
||||
|
||||
*progress = 0.98f;
|
||||
*do_update = true;
|
||||
|
||||
if (data->targets_usdz()) {
|
||||
bool usd_conversion_success = perform_usdz_conversion(data);
|
||||
if (!usd_conversion_success) {
|
||||
|
Loading…
Reference in New Issue
Block a user