[Bf-blender-cvs] [90f1d1f4b66] universal-scene-description: USD Import: Support multiple prim path masks.

Michael Kowalski noreply at git.blender.org
Wed Nov 23 20:20:19 CET 2022


Commit: 90f1d1f4b665fff57da774ced961fadd5424e0db
Author: Michael Kowalski
Date:   Wed Nov 23 14:13:17 2022 -0500
Branches: universal-scene-description
https://developer.blender.org/rB90f1d1f4b665fff57da774ced961fadd5424e0db

USD Import: Support multiple prim path masks.

Extended the Prim Path option to support multiple path
entries, delimited by commas, spaces or semicolons.

===================================================================

M	source/blender/io/usd/intern/usd_capi_import.cc
M	source/blender/io/usd/intern/usd_reader_stage.cc

===================================================================

diff --git a/source/blender/io/usd/intern/usd_capi_import.cc b/source/blender/io/usd/intern/usd_capi_import.cc
index 9ed0e4cb69f..22b9eb2186d 100644
--- a/source/blender/io/usd/intern/usd_capi_import.cc
+++ b/source/blender/io/usd/intern/usd_capi_import.cc
@@ -383,8 +383,21 @@ static void import_startjob(void *customdata, short *stop, short *do_update, flo
   *data->do_update = true;
   *data->progress = 0.1f;
 
-  pxr::UsdStageRefPtr stage = pxr::UsdStage::Open(data->filepath);
+  std::string prim_path_mask(data->params.prim_path_mask);
+  pxr::UsdStagePopulationMask pop_mask;
+  if (!prim_path_mask.empty()) {
+    const std::vector<std::string> mask_tokens = pxr::TfStringTokenize(prim_path_mask, " ,;");
+    for (const std::string &tok : mask_tokens) {
+      pxr::SdfPath prim_path(tok);
+      if (!prim_path.IsEmpty()) {
+        pop_mask.Add(prim_path);
+      }
+    }
+  }
 
+  pxr::UsdStageRefPtr stage = pop_mask.IsEmpty() ?
+                                  pxr::UsdStage::Open(data->filepath) :
+                                  pxr::UsdStage::OpenMasked(data->filepath, pop_mask);
   if (!stage) {
     WM_reportf(RPT_ERROR, "USD Import: unable to open stage to read %s", data->filepath);
     data->import_ok = false;
diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc b/source/blender/io/usd/intern/usd_reader_stage.cc
index 6c29a5e01b0..052b71bfcc5 100644
--- a/source/blender/io/usd/intern/usd_reader_stage.cc
+++ b/source/blender/io/usd/intern/usd_reader_stage.cc
@@ -353,19 +353,6 @@ void USDStageReader::collect_readers(Main *bmain)
   /* Iterate through the stage. */
   pxr::UsdPrim root = stage_->GetPseudoRoot();
 
-  std::string prim_path_mask(params_.prim_path_mask);
-
-  if (!prim_path_mask.empty()) {
-    pxr::UsdPrim prim = stage_->GetPrimAtPath(pxr::SdfPath(prim_path_mask));
-    if (prim.IsValid()) {
-      root = prim;
-    }
-    else {
-      std::cerr << "WARNING: Prim Path Mask " << prim_path_mask
-                << " does not specify a valid prim.\n";
-    }
-  }
-
   stage_->SetInterpolationType(pxr::UsdInterpolationType::UsdInterpolationTypeHeld);
 
   pxr::UsdGeomXformCache xf_cache;



More information about the Bf-blender-cvs mailing list