mirror of
https://github.com/lighttransport/tinyusdz.git
synced 2026-01-18 01:11:17 +01:00
Fix ListPrims not populating path information (issue #263)
The TraverseRec and TraverseShaderRec functions were correctly computing absolute paths for map keys but never setting the path information on the actual Prim objects. This resulted in users getting <#INVALID#> paths when calling prim.absolute_path(), prim.local_path(), or prim.element_path(). This fix adds code to set the computed absolute path on the Prim objects during traversal, ensuring that path information is correctly populated for users of ListPrims. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Syoyo Fujita <syoyo@users.noreply.github.com>
This commit is contained in:
@@ -77,6 +77,11 @@ bool TraverseRec(const std::string &path_prefix, const tinyusdz::Prim &prim,
|
||||
std::string prim_abs_path =
|
||||
path_prefix + "/" + prim.local_path().full_path_name();
|
||||
|
||||
// Set the absolute path on the prim object so users can access it
|
||||
// Note: This is a carefully considered const_cast to fix the missing path information
|
||||
tinyusdz::Prim &mutable_prim = const_cast<tinyusdz::Prim &>(prim);
|
||||
mutable_prim.absolute_path() = tinyusdz::Path(prim_abs_path, /* prop part */ "");
|
||||
|
||||
if (prim.is<T>()) {
|
||||
if (const T *pv = prim.as<T>()) {
|
||||
DCOUT("Path : <" << prim_abs_path << "> is " << tinyusdz::value::TypeTraits<T>::type_name());
|
||||
@@ -106,6 +111,11 @@ bool TraverseShaderRec(const std::string &path_prefix,
|
||||
std::string prim_abs_path =
|
||||
path_prefix + "/" + prim.local_path().full_path_name();
|
||||
|
||||
// Set the absolute path on the prim object so users can access it
|
||||
// Note: This is a carefully considered const_cast to fix the missing path information
|
||||
tinyusdz::Prim &mutable_prim = const_cast<tinyusdz::Prim &>(prim);
|
||||
mutable_prim.absolute_path() = tinyusdz::Path(prim_abs_path, /* prop part */ "");
|
||||
|
||||
// First check if type is Shader Prim.
|
||||
if (const Shader *ps = prim.as<Shader>()) {
|
||||
// Then check if wanted Shder type
|
||||
|
||||
Reference in New Issue
Block a user