mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Support clips Prim metadatum.
This commit is contained in:
@@ -284,6 +284,9 @@ static void RegisterPrimMetas(
|
||||
// NOTE: items are expected to be all string type.
|
||||
metas["sdrMetadata"] = AsciiParser::VariableDef(value::kDictionary, "sdrMetadata");
|
||||
|
||||
metas["clips"] =
|
||||
AsciiParser::VariableDef(value::kDictionary, "clips");
|
||||
|
||||
|
||||
// USDZ extension
|
||||
metas["sceneName"] = AsciiParser::VariableDef(value::kString, "sceneName");
|
||||
@@ -2489,6 +2492,8 @@ bool AsciiParser::ParseMetaValue(const VariableDef &def, MetaVariable *outvar) {
|
||||
|
||||
bool array_qual{false};
|
||||
|
||||
DCOUT("parseMeta: vartype " << vartype);
|
||||
|
||||
if (endsWith(vartype, "[]")) {
|
||||
vartype = removeSuffix(vartype, "[]");
|
||||
array_qual = true;
|
||||
|
||||
@@ -466,6 +466,10 @@ std::string print_prim_metas(const PrimMeta &meta, const uint32_t indent) {
|
||||
ss << pprint::Indent(indent) << "active = " << to_string(meta.active.value()) << "\n";
|
||||
}
|
||||
|
||||
if (meta.clips) {
|
||||
ss << print_customData(meta.clips.value(), "clips", indent);
|
||||
}
|
||||
|
||||
if (meta.instanceable) {
|
||||
ss << pprint::Indent(indent) << "instanceable = " << to_string(meta.instanceable.value()) << "\n";
|
||||
}
|
||||
|
||||
@@ -1791,6 +1791,14 @@ void PrimMetas::update_from(const PrimMetas &rhs, const bool override_authored)
|
||||
}
|
||||
}
|
||||
|
||||
if (rhs.clips) {
|
||||
if (clips) {
|
||||
OverrideDictionary(clips.value(), rhs.clips.value(), override_authored);
|
||||
} else if (override_authored) {
|
||||
clips = rhs.clips;
|
||||
}
|
||||
}
|
||||
|
||||
if (rhs.customData) {
|
||||
if (customData) {
|
||||
OverrideDictionary(customData.value(), rhs.customData.value(), override_authored);
|
||||
|
||||
@@ -807,6 +807,7 @@ struct PrimMetas {
|
||||
sdrMetadata; // 'sdrMetadata' (usdShade Prim only?)
|
||||
|
||||
nonstd::optional<bool> instanceable; // 'instanceable'
|
||||
nonstd::optional<Dictionary> clips; // 'clips'
|
||||
|
||||
// String representation of Kind.
|
||||
// For user-defined Kind, it returns `_kind_str`
|
||||
@@ -868,7 +869,7 @@ struct PrimMetas {
|
||||
return (active || hidden || kind || customData || references || payload ||
|
||||
inherits || variants || variantSets || specializes || displayName ||
|
||||
sceneName || doc || comment || unregisteredMetas.size() || meta.size() || apiSchemas ||
|
||||
sdrMetadata || assetInfo || instanceable);
|
||||
sdrMetadata || assetInfo || instanceable || clips);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -897,6 +897,24 @@ class USDAReader::Impl {
|
||||
"`dictionary`. got type `"
|
||||
<< var.type_name() << "`");
|
||||
}
|
||||
} else if (meta.first == "clips") {
|
||||
DCOUT("clips. type = " << var.type_name());
|
||||
if (var.type_id() == value::TypeTraits<Dictionary>::type_id()) {
|
||||
if (auto pv = var.get_value<Dictionary>()) {
|
||||
out->clips = pv.value();
|
||||
} else {
|
||||
PUSH_ERROR_AND_RETURN_TAG(kTag,
|
||||
"(Internal error?) `clips` metadataum is not type "
|
||||
"`dictionary`. got type `"
|
||||
<< var.type_name() << "`");
|
||||
}
|
||||
|
||||
} else {
|
||||
PUSH_ERROR_AND_RETURN(
|
||||
"(Internal error?) `clips` metadataum is not type "
|
||||
"`dictionary`. got type `"
|
||||
<< var.type_name() << "`");
|
||||
}
|
||||
} else if (meta.first == "assetInfo") {
|
||||
DCOUT("assetInfo. type = " << var.type_name());
|
||||
if (auto pv = var.get_value<Dictionary>()) {
|
||||
|
||||
@@ -1829,6 +1829,15 @@ bool USDCReader::Impl::ParsePrimSpec(const crate::FieldValuePairVector &fvs,
|
||||
kTag, "`assetInfo` must be type `dictionary`, but got type `"
|
||||
<< fv.second.type_name() << "`");
|
||||
}
|
||||
} else if (fv.first == "clips") {
|
||||
// CustomData(dict)
|
||||
if (auto pv = fv.second.as<CustomDataType>()) {
|
||||
primMeta.clips = (*pv);
|
||||
} else {
|
||||
PUSH_ERROR_AND_RETURN_TAG(
|
||||
kTag, "`clips` must be type `dictionary`, but got type `"
|
||||
<< fv.second.type_name() << "`");
|
||||
}
|
||||
} else if (fv.first == "kind") {
|
||||
if (auto pv = fv.second.as<value::token>()) {
|
||||
|
||||
|
||||
14
tests/usda/clips-primmeta-001.usda
Normal file
14
tests/usda/clips-primmeta-001.usda
Normal file
@@ -0,0 +1,14 @@
|
||||
#usda 1.0
|
||||
over "GEO" (
|
||||
clips = {
|
||||
dictionary geo = {
|
||||
double2[] active = [(1004, 0)]
|
||||
asset[] assetPaths = [@payload/animated_data.1004.usdc@]
|
||||
asset manifestAssetPath = @./clip.manifest.usda@
|
||||
string primPath = "/root/remi/body_M_hrc/GEO"
|
||||
double2[] times = []
|
||||
}
|
||||
}
|
||||
)
|
||||
{ }
|
||||
|
||||
BIN
tests/usdc/clips-primmeta-001.usdc
Normal file
BIN
tests/usdc/clips-primmeta-001.usdc
Normal file
Binary file not shown.
Reference in New Issue
Block a user