USD export: fix missing animation frames. #111248
|
@ -49,6 +49,7 @@ void MaterialData::init()
|
||||||
/* Create temporary in memory stage. */
|
/* Create temporary in memory stage. */
|
||||||
pxr::UsdStageRefPtr stage = pxr::UsdStage::CreateInMemory();
|
pxr::UsdStageRefPtr stage = pxr::UsdStage::CreateInMemory();
|
||||||
pxr::UsdTimeCode time = pxr::UsdTimeCode::Default();
|
pxr::UsdTimeCode time = pxr::UsdTimeCode::Default();
|
||||||
|
auto get_time_code = [time]() { return time; };
|
||||||
pxr::SdfPath material_library_path("/_materials");
|
pxr::SdfPath material_library_path("/_materials");
|
||||||
pxr::SdfPath material_path = material_library_path.AppendChild(
|
pxr::SdfPath material_path = material_library_path.AppendChild(
|
||||||
pxr::TfToken(prim_id.GetElementString()));
|
pxr::TfToken(prim_id.GetElementString()));
|
||||||
|
@ -63,7 +64,7 @@ void MaterialData::init()
|
||||||
scene_delegate_->depsgraph,
|
scene_delegate_->depsgraph,
|
||||||
stage,
|
stage,
|
||||||
material_library_path,
|
material_library_path,
|
||||||
time,
|
get_time_code,
|
||||||
export_params,
|
export_params,
|
||||||
image_cache_file_path()};
|
image_cache_file_path()};
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <pxr/usd/sdf/path.h>
|
#include <pxr/usd/sdf/path.h>
|
||||||
#include <pxr/usd/usd/common.h>
|
#include <pxr/usd/usd/common.h>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
struct Depsgraph;
|
struct Depsgraph;
|
||||||
struct Main;
|
struct Main;
|
||||||
|
|
||||||
|
@ -20,7 +22,13 @@ struct USDExporterContext {
|
||||||
Depsgraph *depsgraph;
|
Depsgraph *depsgraph;
|
||||||
const pxr::UsdStageRefPtr stage;
|
const pxr::UsdStageRefPtr stage;
|
||||||
const pxr::SdfPath usd_path;
|
const pxr::SdfPath usd_path;
|
||||||
pxr::UsdTimeCode time_code;
|
/**
|
||||||
|
* Wrap a function which returns the current time code
|
||||||
|
* for export. This is necessary since the context
|
||||||
|
* may be used for exporting an animation over a sequece
|
||||||
|
* of frames.
|
||||||
|
*/
|
||||||
|
std::function<pxr::UsdTimeCode()> get_time_code;
|
||||||
const USDExportParams &export_params;
|
const USDExportParams &export_params;
|
||||||
std::string export_file_path;
|
std::string export_file_path;
|
||||||
};
|
};
|
||||||
|
|
|
@ -78,9 +78,10 @@ USDExporterContext USDHierarchyIterator::create_usd_export_context(const Hierarc
|
||||||
* `pxr::UsdStage::CreateNew` function). */
|
* `pxr::UsdStage::CreateNew` function). */
|
||||||
const pxr::SdfLayerHandle root_layer = stage_->GetRootLayer();
|
const pxr::SdfLayerHandle root_layer = stage_->GetRootLayer();
|
||||||
const std::string export_file_path = root_layer->GetRealPath();
|
const std::string export_file_path = root_layer->GetRealPath();
|
||||||
|
auto get_time_code = [this]() { return this->export_time_; };
|
||||||
|
|
||||||
return USDExporterContext{
|
return USDExporterContext{
|
||||||
bmain_, depsgraph_, stage_, path, export_time_, params_, export_file_path};
|
bmain_, depsgraph_, stage_, path, get_time_code, params_, export_file_path};
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractHierarchyWriter *USDHierarchyIterator::create_transform_writer(
|
AbstractHierarchyWriter *USDHierarchyIterator::create_transform_writer(
|
||||||
|
|
|
@ -59,7 +59,8 @@ std::string USDAbstractWriter::get_export_file_path() const
|
||||||
pxr::UsdTimeCode USDAbstractWriter::get_export_time_code() const
|
pxr::UsdTimeCode USDAbstractWriter::get_export_time_code() const
|
||||||
{
|
{
|
||||||
if (is_animated_) {
|
if (is_animated_) {
|
||||||
return usd_export_context_.time_code;
|
BLI_assert(usd_export_context_.get_time_code);
|
||||||
|
return usd_export_context_.get_time_code();
|
||||||
}
|
}
|
||||||
/* By using the default timecode USD won't even write a single `timeSample` for non-animated
|
/* By using the default timecode USD won't even write a single `timeSample` for non-animated
|
||||||
* data. Instead, it writes it as non-timesampled. */
|
* data. Instead, it writes it as non-timesampled. */
|
||||||
|
|
Loading…
Reference in New Issue