15 #include <pxr/usd/usdGeom/camera.h>
16 #include <pxr/usd/usdGeom/curves.h>
17 #include <pxr/usd/usdGeom/mesh.h>
18 #include <pxr/usd/usdGeom/nurbsCurves.h>
19 #include <pxr/usd/usdGeom/scope.h>
20 #include <pxr/usd/usdGeom/xform.h>
22 #if PXR_VERSION >= 2111
23 # include <pxr/usd/usdLux/boundableLightBase.h>
24 # include <pxr/usd/usdLux/nonboundableLightBase.h>
26 # include <pxr/usd/usdLux/light.h>
39 : stage_(
stage), params_(
params), settings_(settings)
67 #if PXR_VERSION >= 2111
69 prim.IsA<pxr::UsdLuxNonboundableLightBase>())) {
78 if (prim.IsA<pxr::UsdGeomImageable>()) {
87 if (prim.IsA<pxr::UsdGeomCamera>()) {
90 if (prim.IsA<pxr::UsdGeomBasisCurves>()) {
93 if (prim.IsA<pxr::UsdGeomNurbsCurves>()) {
96 if (prim.IsA<pxr::UsdGeomMesh>()) {
99 #if PXR_VERSION >= 2111
100 if (prim.IsA<pxr::UsdLuxBoundableLightBase>() || prim.IsA<pxr::UsdLuxNonboundableLightBase>()) {
102 if (prim.IsA<pxr::UsdLuxLight>()) {
106 if (prim.IsA<pxr::UsdVolVolume>()) {
109 if (prim.IsA<pxr::UsdGeomImageable>()) {
115 bool USDStageReader::include_by_visibility(
const pxr::UsdGeomImageable &imageable)
const
122 pxr::UsdAttribute visibility_attr = imageable.GetVisibilityAttr();
124 if (!visibility_attr) {
131 if (visibility_attr.ValueMightBeTimeVarying()) {
135 pxr::TfToken visibility;
136 visibility_attr.Get(&visibility);
137 return visibility != pxr::UsdGeomTokens->invisible;
140 bool USDStageReader::include_by_purpose(
const pxr::UsdGeomImageable &imageable)
const
147 pxr::UsdAttribute purpose_attr = imageable.GetPurposeAttr();
154 pxr::TfToken purpose;
155 purpose_attr.Get(&purpose);
157 if (purpose == pxr::UsdGeomTokens->guide) {
160 if (purpose == pxr::UsdGeomTokens->proxy) {
163 if (purpose == pxr::UsdGeomTokens->render) {
187 if (!xform_reader->
prim().GetParent().IsA<pxr::UsdGeomXform>()) {
192 if (xform_reader->
prim().IsA<pxr::UsdGeomXform>() ||
193 xform_reader->
prim().IsA<pxr::UsdGeomScope>()) {
210 if (prim.IsA<pxr::UsdGeomImageable>()) {
211 pxr::UsdGeomImageable imageable(prim);
213 if (!include_by_purpose(imageable)) {
217 if (!include_by_visibility(imageable)) {
222 pxr::Usd_PrimFlagsPredicate filter_predicate = pxr::UsdPrimDefaultPredicate;
225 filter_predicate = pxr::UsdTraverseInstanceProxies(filter_predicate);
228 pxr::UsdPrimSiblingRange children = prim.GetFilteredChildren(filter_predicate);
230 std::vector<USDPrimReader *> child_readers;
232 for (
const auto &childPrim : children) {
234 child_readers.push_back(child_reader);
238 if (prim.IsPseudoRoot()) {
243 if (child_readers.size() == 1) {
245 USDPrimReader *child_reader = child_readers.front();
262 for (USDPrimReader *child_reader : child_readers) {
263 child_reader->parent(reader);
278 pxr::UsdPrim root =
stage_->GetPseudoRoot();
282 if (!prim_path_mask.empty()) {
283 pxr::UsdPrim prim =
stage_->GetPrimAtPath(pxr::SdfPath(prim_path_mask));
284 if (prim.IsValid()) {
288 std::cerr <<
"WARNING: Prim Path Mask " << prim_path_mask
289 <<
" does not specify a valid prim.\n";
293 stage_->SetInterpolationType(pxr::UsdInterpolationType::UsdInterpolationTypeHeld);
306 if (reader->refcount() == 0) {
318 const char *na = a ? a->name().c_str() :
"";
319 const char *nb = b ? b->name().c_str() :
"";
320 return BLI_strcasecmp(na, nb) < 0;
const pxr::UsdPrim & prim() const
std::vector< USDPrimReader * > readers_
USDPrimReader * create_reader(const pxr::UsdPrim &prim)
USDPrimReader * create_reader_if_allowed(const pxr::UsdPrim &prim)
pxr::UsdStageRefPtr stage_
void collect_readers(struct Main *bmain)
USDStageReader(pxr::UsdStageRefPtr stage, const USDImportParams ¶ms, const ImportSettings &settings)
static bool merge_with_parent(USDPrimReader *reader)
void parallel_sort(RandomAccessIterator begin, RandomAccessIterator end)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
bool import_instance_proxies