Skip to content

Commit

Permalink
Print invalid(empty) Payload as None to align with pxrUSD.
Browse files Browse the repository at this point in the history
  • Loading branch information
syoyo committed Nov 24, 2023
1 parent c405a7a commit 7f11b84
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/pprinter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,15 @@ std::ostream &operator<<(std::ostream &ofs, const tinyusdz::Reference &v) {
}

std::ostream &operator<<(std::ostream &ofs, const tinyusdz::Payload &v) {
ofs << v.asset_path;
if (v.prim_path.is_valid()) {
ofs << v.prim_path;
if (v.is_none()) {
ofs << "None";
} else {
ofs << v.asset_path;
if (v.prim_path.is_valid()) {
ofs << v.prim_path;
}
ofs << v.layerOffset;
}
ofs << v.layerOffset;

return ofs;
}
Expand Down Expand Up @@ -1764,12 +1768,18 @@ std::string to_string(const Reference &v) {
std::string to_string(const Payload &v) {
std::stringstream ss;

ss << v.asset_path;
if (v.prim_path.is_valid()) {
ss << v.prim_path;
}
if (v.is_none()) {
// pxrUSD serialize and prints 'None' for payload by filling all members in Payload empty.
ss << "None";

ss << v.layerOffset;
} else {
ss << v.asset_path;
if (v.prim_path.is_valid()) {
ss << v.prim_path;
}

ss << v.layerOffset;
}

return ss.str();
}
Expand Down
6 changes: 6 additions & 0 deletions src/prim-types.hh
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,12 @@ struct Payload {
Path prim_path;
LayerOffset layerOffset; // from 0.8.0
// No customData for Payload

// NOTE: pxrUSD encodes `payload = None` as Payload with empty paths in USDC(Crate).
// (Not ValueBlock)
bool is_none() const {
return asset_path.GetAssetPath().empty() && !prim_path.is_valid();
}
};

// Metadata for Prim
Expand Down

0 comments on commit 7f11b84

Please sign in to comment.