Loading...
Searching...
No Matches
stage.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_USD_USD_STAGE_H
8#define PXR_USD_USD_STAGE_H
9
11
12#include "pxr/pxr.h"
13#include "pxr/usd/usd/api.h"
14#include "pxr/usd/usd/common.h"
15#include "pxr/usd/usd/editTarget.h"
17#include "pxr/usd/usd/schemaRegistry.h"
19#include "pxr/usd/usd/stagePopulationMask.h"
20#include "pxr/usd/usd/primDefinition.h"
22
24#include "pxr/base/tf/hashmap.h"
25#include "pxr/base/tf/type.h"
27
28#include "pxr/usd/ar/ar.h"
29#include "pxr/usd/ar/notice.h"
31#include "pxr/usd/sdf/notice.h"
32#include "pxr/usd/sdf/path.h"
33#include "pxr/usd/sdf/types.h"
34#include "pxr/usd/pcp/cache.h"
35#include "pxr/base/vt/value.h"
37
38#include <tbb/concurrent_vector.h>
39#include <tbb/concurrent_unordered_set.h>
40#include <tbb/concurrent_hash_map.h>
41#include <tbb/spin_rw_mutex.h>
42
43#include <functional>
44#include <string>
45#include <memory>
46#include <optional>
47#include <unordered_map>
48#include <utility>
49
50PXR_NAMESPACE_OPEN_SCOPE
51
53class GfInterval;
55class TsSpline;
56class Usd_AssetPathContext;
57class Usd_ClipCache;
58class Usd_InstanceCache;
59class Usd_InstanceChanges;
60class Usd_InterpolatorBase;
61class Usd_Resolver;
62class UsdResolveInfo;
64class UsdPrim;
65class UsdPrimRange;
66
67SDF_DECLARE_HANDLES(SdfLayer);
68
136class UsdStage : public TfRefBase, public TfWeakBase {
137public:
138
139 // --------------------------------------------------------------------- //
143 // --------------------------------------------------------------------- //
144
150 {
152 LoadNone
153 };
154
165 //
177 USD_API
178 static UsdStageRefPtr
179 CreateNew(const std::string& identifier,
180 InitialLoadSet load = LoadAll);
182 USD_API
183 static UsdStageRefPtr
184 CreateNew(const std::string& identifier,
185 const SdfLayerHandle& sessionLayer,
186 InitialLoadSet load = LoadAll);
188 USD_API
189 static UsdStageRefPtr
190 CreateNew(const std::string& identifier,
191 const SdfLayerHandle& sessionLayer,
192 const ArResolverContext& pathResolverContext,
193 InitialLoadSet load = LoadAll);
195 USD_API
196 static UsdStageRefPtr
197 CreateNew(const std::string& identifier,
198 const ArResolverContext& pathResolverContext,
199 InitialLoadSet load = LoadAll);
200
218 USD_API
219 static UsdStageRefPtr
222 USD_API
223 static UsdStageRefPtr
224 CreateInMemory(const std::string& identifier,
225 InitialLoadSet load = LoadAll);
227 USD_API
228 static UsdStageRefPtr
229 CreateInMemory(const std::string& identifier,
230 const ArResolverContext& pathResolverContext,
231 InitialLoadSet load = LoadAll);
233 USD_API
234 static UsdStageRefPtr
235 CreateInMemory(const std::string& identifier,
236 const SdfLayerHandle &sessionLayer,
237 InitialLoadSet load = LoadAll);
239 USD_API
240 static UsdStageRefPtr
241 CreateInMemory(const std::string& identifier,
242 const SdfLayerHandle &sessionLayer,
243 const ArResolverContext& pathResolverContext,
244 InitialLoadSet load = LoadAll);
245
261 USD_API
262 static UsdStageRefPtr
263 Open(const std::string& filePath, InitialLoadSet load = LoadAll);
265 USD_API
266 static UsdStageRefPtr
267 Open(const std::string& filePath,
268 const ArResolverContext& pathResolverContext,
269 InitialLoadSet load = LoadAll);
270
288 USD_API
289 static UsdStageRefPtr
290 OpenMasked(const std::string &filePath,
291 UsdStagePopulationMask const &mask,
292 InitialLoadSet load = LoadAll);
294 USD_API
295 static UsdStageRefPtr
296 OpenMasked(const std::string &filePath,
297 const ArResolverContext &pathResolverContext,
298 UsdStagePopulationMask const &mask,
299 InitialLoadSet load = LoadAll);
300
329 USD_API
330 static UsdStageRefPtr
331 Open(const SdfLayerHandle& rootLayer,
334 USD_API
335 static UsdStageRefPtr
336 Open(const SdfLayerHandle& rootLayer,
337 const SdfLayerHandle& sessionLayer,
340 USD_API
341 static UsdStageRefPtr
342 Open(const SdfLayerHandle& rootLayer,
343 const ArResolverContext& pathResolverContext,
346 USD_API
347 static UsdStageRefPtr
348 Open(const SdfLayerHandle& rootLayer,
349 const SdfLayerHandle& sessionLayer,
350 const ArResolverContext& pathResolverContext,
352
373 USD_API
374 static UsdStageRefPtr
375 OpenMasked(const SdfLayerHandle& rootLayer,
376 const UsdStagePopulationMask &mask,
379 USD_API
380 static UsdStageRefPtr
381 OpenMasked(const SdfLayerHandle& rootLayer,
382 const SdfLayerHandle& sessionLayer,
383 const UsdStagePopulationMask &mask,
386 USD_API
387 static UsdStageRefPtr
388 OpenMasked(const SdfLayerHandle& rootLayer,
389 const ArResolverContext& pathResolverContext,
390 const UsdStagePopulationMask &mask,
393 USD_API
394 static UsdStageRefPtr
395 OpenMasked(const SdfLayerHandle& rootLayer,
396 const SdfLayerHandle& sessionLayer,
397 const ArResolverContext& pathResolverContext,
398 const UsdStagePopulationMask &mask,
400
401 USD_API
402 virtual ~UsdStage();
403
421 USD_API
422 void Reload();
423
432 USD_API
433 static bool
434 IsSupportedFile(const std::string& filePath);
435
437
438 // --------------------------------------------------------------------- //
447
455 USD_API
456 void Save();
457
465 USD_API
467
469
470 // --------------------------------------------------------------------- //
516
518 USD_API
520
526 USD_API
527 static void
529
531
532 // --------------------------------------------------------------------- //
561 // --------------------------------------------------------------------- //
562
570 USD_API
573
579 USD_API
581
593 USD_API
594 void LoadAndUnload(const SdfPathSet &loadSet, const SdfPathSet &unloadSet,
596
607 USD_API
608 SdfPathSet GetLoadSet();
609
629 USD_API
630 SdfPathSet FindLoadable(
631 const SdfPath& rootPath = SdfPath::AbsoluteRootPath());
632
639 return _loadRules;
640 }
641
651 USD_API
652 void SetLoadRules(UsdStageLoadRules const &rules);
653
656 return _populationMask;
657 }
658
660 USD_API
662
676 USD_API
678 Usd_PrimFlagsPredicate const &traversalPredicate,
679 std::function<bool (UsdRelationship const &)> const &relPred = nullptr,
680 std::function<bool (UsdAttribute const &)> const &attrPred = nullptr);
681
685 USD_API
687 std::function<bool (UsdRelationship const &)> const &relPred = nullptr,
688 std::function<bool (UsdAttribute const &)> const &attrPred = nullptr);
689
691
692 // --------------------------------------------------------------------- //
701 // --------------------------------------------------------------------- //
702
712 USD_API
714
722 USD_API
724
736 USD_API
737 void SetDefaultPrim(const UsdPrim &prim);
738
746 USD_API
748
756 USD_API
757 bool HasDefaultPrim() const;
758
768 USD_API
769 UsdPrim GetPrimAtPath(const SdfPath &path) const;
770
795 USD_API
797
806 USD_API
808
817 USD_API
819
828 USD_API
830private:
831 // Return the primData object at \p path.
832 Usd_PrimDataConstPtr _GetPrimDataAtPath(const SdfPath &path) const;
833 Usd_PrimDataPtr _GetPrimDataAtPath(const SdfPath &path);
834
835 // Return the primData object at \p path. If \p path indicates a prim
836 // beneath an instance, return the primData object for the corresponding
837 // prim in the instance's prototype.
838 Usd_PrimDataConstPtr
839 _GetPrimDataAtPathOrInPrototype(const SdfPath &path) const;
840
842 std::vector<UsdPrim>
843 _GetInstancesForPrototype(const UsdPrim& prototype) const;
844
845public:
846
867 USD_API
869
874 USD_API
875 UsdPrimRange Traverse(const Usd_PrimFlagsPredicate &predicate);
876
881 USD_API
883
902 USD_API
904
928 USD_API
930 const TfToken &typeName=TfToken());
931
944 USD_API
945 UsdPrim CreateClassPrim(const SdfPath &rootPrimPath);
946
968 USD_API
969 bool RemovePrim(const SdfPath& path);
970
972
973 // --------------------------------------------------------------------- //
977 // --------------------------------------------------------------------- //
978
980 USD_API
981 SdfLayerHandle GetSessionLayer() const;
982
984 USD_API
985 SdfLayerHandle GetRootLayer() const;
986
991 USD_API
993
1003 USD_API
1004 std::string
1005 ResolveIdentifierToEditTarget(std::string const &identifier) const;
1006
1009 USD_API
1010 PcpErrorVector GetCompositionErrors() const;
1011
1017 USD_API
1018 SdfLayerHandleVector GetLayerStack(bool includeSessionLayers=true) const;
1019
1031 USD_API
1032 SdfLayerHandleVector GetUsedLayers(bool includeClipLayers=true) const;
1033
1036 USD_API
1037 bool HasLocalLayer(const SdfLayerHandle &layer) const;
1038
1040 USD_API
1042
1046 USD_API
1048
1052 USD_API
1053 UsdEditTarget GetEditTargetForLocalLayer(const SdfLayerHandle &layer);
1054
1061 USD_API
1062 void SetEditTarget(const UsdEditTarget &editTarget);
1063
1090 USD_API
1091 void MuteLayer(const std::string &layerIdentifier);
1092
1095 USD_API
1096 void UnmuteLayer(const std::string &layerIdentifier);
1097
1105 USD_API
1106 void MuteAndUnmuteLayers(const std::vector<std::string> &muteLayers,
1107 const std::vector<std::string> &unmuteLayers);
1108
1110 USD_API
1111 const std::vector<std::string>& GetMutedLayers() const;
1112
1117 USD_API
1118 bool IsLayerMuted(const std::string& layerIdentifier) const;
1119
1121
1122 // --------------------------------------------------------------------- //
1126 // --------------------------------------------------------------------- //
1127 // Future Work:
1128 // * Flatten sub-trees or individual prims
1129 // * Allow flattening of local LayerStack
1130 // * Move Flatten into a free-function to ensure it doesn't rely on
1131 // Stage internals.
1132
1140 USD_API
1141 bool Export(const std::string &filename,
1142 bool addSourceFileComment=true,
1143 const SdfLayer::FileFormatArguments &args =
1145
1153 USD_API
1154 bool ExportToString(std::string *result,
1155 bool addSourceFileComment=true) const;
1156
1183 USD_API
1184 SdfLayerRefPtr Flatten(bool addSourceFileComment=true) const;
1186
1187public:
1188 // --------------------------------------------------------------------- //
1196 // --------------------------------------------------------------------- //
1197
1209 template <class T>
1210 bool GetMetadata(const TfToken &key, T *value) const;
1212 USD_API
1213 bool GetMetadata(const TfToken &key, VtValue *value) const;
1214
1221 USD_API
1222 bool HasMetadata(const TfToken &key) const;
1223
1232 USD_API
1233 bool HasAuthoredMetadata(const TfToken &key) const;
1234
1243 template<typename T>
1244 bool SetMetadata(const TfToken &key, const T &value) const;
1246 USD_API
1247 bool SetMetadata(const TfToken &key, const VtValue &value) const;
1248
1257 USD_API
1258 bool ClearMetadata(const TfToken &key) const;
1259
1275 template<typename T>
1276 bool GetMetadataByDictKey(const TfToken& key, const TfToken &keyPath,
1277 T* value) const;
1279 USD_API
1281 const TfToken& key, const TfToken &keyPath, VtValue *value) const;
1282
1293 USD_API
1295 const TfToken& key, const TfToken &keyPath) const;
1296
1305 USD_API
1307 const TfToken& key, const TfToken &keyPath) const;
1308
1320 template<typename T>
1321 bool SetMetadataByDictKey(const TfToken& key, const TfToken &keyPath,
1322 const T& value) const;
1324 USD_API
1326 const TfToken& key, const TfToken &keyPath, const VtValue& value) const;
1327
1339 USD_API
1341 const TfToken& key, const TfToken& keyPath) const;
1342
1361 USD_API
1363
1365
1366 // --------------------------------------------------------------------- //
1373 // --------------------------------------------------------------------- //
1377 USD_API
1378 double GetStartTimeCode() const;
1379
1386 USD_API
1387 void SetStartTimeCode(double);
1388
1392 USD_API
1393 double GetEndTimeCode() const;
1394
1401 USD_API
1402 void SetEndTimeCode(double);
1403
1406 USD_API
1408
1424 USD_API
1426
1435 USD_API
1436 void SetTimeCodesPerSecond(double timeCodesPerSecond) const;
1437
1447 USD_API
1448 double GetFramesPerSecond() const;
1449
1458 USD_API
1459 void SetFramesPerSecond(double framesPerSecond) const;
1460
1462
1463 // --------------------------------------------------------------------- //
1484 // --------------------------------------------------------------------- //
1485
1491 USD_API
1492 void SetColorConfiguration(const SdfAssetPath &colorConfig) const;
1493
1497 USD_API
1499
1504 USD_API
1505 void SetColorManagementSystem(const TfToken &cms) const;
1506
1511 USD_API
1513
1524 USD_API
1525 static void GetColorConfigFallbacks(SdfAssetPath *colorConfiguration,
1526 TfToken *colorManagementSystem);
1527
1541 USD_API
1542 static void
1543 SetColorConfigFallbacks(const SdfAssetPath &colorConfiguration,
1544 const TfToken &colorManagementSystem);
1545
1547
1548 // --------------------------------------------------------------------- //
1555 // --------------------------------------------------------------------- //
1556
1561 USD_API
1563
1566 USD_API
1568
1570
1571 // --------------------------------------------------------------------- //
1576 // --------------------------------------------------------------------- //
1577
1579 USD_API
1580 std::vector<UsdPrim> GetPrototypes() const;
1581
1583
1584private:
1585 struct _IncludePayloadsPredicate;
1586
1587 // --------------------------------------------------------------------- //
1588 // Stage Construction & Initialization
1589 // --------------------------------------------------------------------- //
1590
1591 UsdStage(const SdfLayerRefPtr& rootLayer,
1592 const SdfLayerRefPtr& sessionLayer,
1593 const ArResolverContext& pathResolverContext,
1594 const UsdStagePopulationMask& mask,
1595 InitialLoadSet load);
1596
1597 // Helper for Open() overloads -- searches and publishes to bound caches.
1598 template <class... Args>
1599 static UsdStageRefPtr _OpenImpl(InitialLoadSet load, Args const &... args);
1600
1601 // Releases resources used by this stage.
1602 void _Close();
1603
1604 // Common ref ptr initialization, called by public, static constructors.
1605 //
1606 // This method will either return a valid refptr (if the stage is correctly
1607 // initialized) or it will return a null ref pointer, deleting the
1608 // raw stage pointer in the process.
1609 static UsdStageRefPtr
1610 _InstantiateStage(const SdfLayerRefPtr &rootLayer,
1611 const SdfLayerRefPtr &sessionLayer,
1612 const ArResolverContext &pathResolverContext,
1613 const UsdStagePopulationMask &mask,
1614 InitialLoadSet load);
1615
1616 // --------------------------------------------------------------------- //
1617 // Spec Existence & Definition Helpers
1618 // --------------------------------------------------------------------- //
1619
1620 SdfPropertySpecHandleVector
1621 _GetPropertyStack(const UsdProperty &prop, UsdTimeCode time) const;
1622
1623 std::vector<std::pair<SdfPropertySpecHandle, SdfLayerOffset>>
1624 _GetPropertyStackWithLayerOffsets(
1625 const UsdProperty &prop, UsdTimeCode time) const;
1626
1627 static SdfPrimSpecHandleVector
1628 _GetPrimStack(const UsdPrim &prim);
1629
1630 static std::vector<std::pair<SdfPrimSpecHandle, SdfLayerOffset>>
1631 _GetPrimStackWithLayerOffsets(const UsdPrim &prim);
1632
1634 _GetSchemaProperty(const UsdProperty &prop) const;
1635
1637 _GetSchemaAttribute(const UsdAttribute &attr) const;
1638
1640 _GetSchemaRelationship(const UsdRelationship &rel) const;
1641
1642 SdfAttributeSpecHandle
1643 _CreateNewSpecFromSchemaAttribute(
1644 const UsdPrim &prim,
1645 const UsdPrimDefinition::Attribute &attrDef);
1646
1647 SdfRelationshipSpecHandle
1648 _CreateNewSpecFromSchemaRelationship(
1649 const UsdPrim &prim,
1650 const UsdPrimDefinition::Relationship &relDef);
1651
1652 template <class PropType>
1654 _CreateNewPropertySpecFromSchema(const UsdProperty &prop);
1655
1656 SdfPrimSpecHandle
1657 _CreatePrimSpecForEditing(const UsdPrim& prim);
1658
1659 template <class PropType>
1661 _CreatePropertySpecForEditing(const UsdProperty &prop);
1662
1663 SdfPropertySpecHandle
1664 _CreatePropertySpecForEditing(const UsdProperty &prop);
1665
1666 SdfAttributeSpecHandle
1667 _CreateAttributeSpecForEditing(const UsdAttribute &attr);
1668
1669 SdfRelationshipSpecHandle
1670 _CreateRelationshipSpecForEditing(const UsdRelationship &rel);
1671
1672 // Check if the given path is valid to use with the prim creation API,
1673 // like DefinePrim. If it is valid, returns (true, GetPrimAtPath(path)).
1674 // Otherwise, returns (false, UsdPrim()).
1675 std::pair<bool, UsdPrim>
1676 _IsValidPathForCreatingPrim(const SdfPath &path) const;
1677
1678 // Validates that editing a specified prim is allowed. If editing is not
1679 // allowed, issues a coding error like "Cannot <operation> ..." and
1680 // returns false. Otherwise, returns true.
1681 bool _ValidateEditPrim(const UsdPrim &prim, const char* operation) const;
1682 bool _ValidateEditPrimAtPath(const SdfPath &primPath,
1683 const char* operation) const;
1684
1685 UsdPrim _DefinePrim(const SdfPath &path, const TfToken &typeName);
1686
1687 bool _RemoveProperty(const SdfPath& path);
1688
1689 UsdProperty _FlattenProperty(const UsdProperty &srcProp,
1690 const UsdPrim &dstParent,
1691 const TfToken &dstName);
1692
1693 // --------------------------------------------------------------------- //
1694 // Value & Metadata Authoring
1695 // --------------------------------------------------------------------- //
1696
1697 // Trait that allows us to call the correct versions of _SetValue and
1698 // _SetMetadata for types whose values need to be mapped when written to
1699 // different edit targets.
1700 template <class T>
1701 struct _IsEditTargetMappable {
1702 static const bool value =
1703 std::is_same<T, SdfTimeCode>::value ||
1704 std::is_same<T, VtArray<SdfTimeCode>>::value ||
1705 std::is_same<T, SdfPathExpression>::value ||
1706 std::is_same<T, VtArray<SdfPathExpression>>::value ||
1707 std::is_same<T, SdfTimeSampleMap>::value ||
1708 std::is_same<T, TsSpline>::value ||
1709 std::is_same<T, VtDictionary>::value;
1710 };
1711
1712 // Set value for types that don't need to be mapped for edit targets.
1713 template <class T>
1714 typename std::enable_if<!_IsEditTargetMappable<T>::value, bool>::type
1715 _SetValue(
1716 UsdTimeCode time, const UsdAttribute &attr, const T &newValue);
1717
1718 // Set value for types that do need to be mapped for edit targets.
1719 template <class T>
1720 typename std::enable_if<_IsEditTargetMappable<T>::value, bool>::type
1721 _SetValue(
1722 UsdTimeCode time, const UsdAttribute &attr, const T &newValue);
1723
1724 // Set value for dynamically typed VtValue. Will map the value across edit
1725 // targets if the held value type supports it.
1726 bool _SetValue(
1727 UsdTimeCode time, const UsdAttribute &attr, const VtValue &newValue);
1728
1729 template <class T>
1730 bool _SetEditTargetMappedValue(
1731 UsdTimeCode time, const UsdAttribute &attr, const T &newValue);
1732
1733 TfType _GetAttributeValueType(
1734 const UsdAttribute &attr) const;
1735
1736 template <class T>
1737 bool _SetValueImpl(
1738 UsdTimeCode time, const UsdAttribute &attr, const T& value);
1739
1740 bool _ClearValue(UsdTimeCode time, const UsdAttribute &attr);
1741
1742 // Set metadata for types that don't need to be mapped across edit targets.
1743 template <class T>
1744 typename std::enable_if<!_IsEditTargetMappable<T>::value, bool>::type
1745 _SetMetadata(const UsdObject &object, const TfToken& key,
1746 const TfToken &keyPath, const T& value);
1747
1748 // Set metadata for types that do need to be mapped for edit targets.
1749 template <class T>
1750 typename std::enable_if<_IsEditTargetMappable<T>::value, bool>::type
1751 _SetMetadata(const UsdObject &object, const TfToken& key,
1752 const TfToken &keyPath, const T& value);
1753
1754 // Set metadata for dynamically typed VtValue. Will map the value across
1755 // edit targets if the held value type supports it.
1756 USD_API
1757 bool _SetMetadata(const UsdObject &object,
1758 const TfToken& key,
1759 const TfToken &keyPath,
1760 const VtValue& value);
1761
1762 template <class T>
1763 bool _SetEditTargetMappedMetadata(
1764 const UsdObject &obj, const TfToken& fieldName,
1765 const TfToken &keyPath, const T &newValue);
1766
1767 template <class T>
1768 bool _SetMetadataImpl(
1769 const UsdObject &obj, const TfToken& fieldName,
1770 const TfToken &keyPath, const T &value);
1771
1772 bool _ClearMetadata(const UsdObject &obj, const TfToken& fieldName,
1773 const TfToken &keyPath=TfToken());
1774
1775 // --------------------------------------------------------------------- //
1776 // Misc Internal Helpers
1777 // --------------------------------------------------------------------- //
1778
1779 // Pcp helpers.
1780 PcpCache const *_GetPcpCache() const { return _cache.get(); }
1781 PcpCache *_GetPcpCache() { return _cache.get(); }
1782
1783 // Returns the PrimIndex, using the read-only PcpCache API. We expect prims
1784 // to be composed during initial stage composition, so this method should
1785 // not be used in that context.
1786 const PcpPrimIndex* _GetPcpPrimIndex(const SdfPath& primPath) const;
1787
1788 // Helper to report pcp errors.
1789 void _ReportPcpErrors(const PcpErrorVector &errors,
1790 const std::string &context) const;
1791 void _ReportErrors(const PcpErrorVector &errors,
1792 const std::vector<std::string>& otherErrors,
1793 const std::string &context) const;
1794
1795 // --------------------------------------------------------------------- //
1796 // Scenegraph Composition & Change Processing
1797 // --------------------------------------------------------------------- //
1798
1799 // Compose the prim indexes in the subtrees rooted at the paths in
1800 // \p primIndexPaths. If \p instanceChanges is given, returns
1801 // changes to prototypes and instances due to the discovery of new instances
1802 // during composition.
1803 void _ComposePrimIndexesInParallel(
1804 const std::vector<SdfPath>& primIndexPaths,
1805 const std::string& context,
1806 Usd_InstanceChanges* instanceChanges = nullptr);
1807
1808 // Recompose the subtree rooted at \p prim: compose its type, flags, and
1809 // list of children, then invoke _ComposeSubtree on all its children.
1810 void _ComposeSubtree(
1811 Usd_PrimDataPtr prim, Usd_PrimDataConstPtr parent,
1812 UsdStagePopulationMask const *mask,
1813 const SdfPath &primIndexPath = SdfPath());
1814 void _ComposeSubtreeImpl(
1815 Usd_PrimDataPtr prim, Usd_PrimDataConstPtr parent,
1816 UsdStagePopulationMask const *mask,
1817 const SdfPath &primIndexPath = SdfPath());
1818 void _ComposeSubtreesInParallel(
1819 const std::vector<Usd_PrimDataPtr> &prims,
1820 const std::vector<SdfPath> *primIndexPaths = nullptr);
1821
1822 // Composes the full prim type info for the prim based on its type name
1823 // and applied API schemas.
1824 void _ComposePrimTypeInfoImpl(Usd_PrimDataPtr prim);
1825
1826 // Compose subtree rooted at \p prim under \p parent. This function
1827 // ensures that the appropriate prim index is specified for \p prim if
1828 // \p parent is in a prototype.
1829 void _ComposeChildSubtree(Usd_PrimDataPtr prim,
1830 Usd_PrimDataConstPtr parent,
1831 UsdStagePopulationMask const *mask);
1832
1833 // Compose \p prim's list of children and make any modifications necessary
1834 // to its _children member and the stage's _primMap, including possibly
1835 // instantiating new prims, or destroying existing subtrees of prims. The
1836 // any newly created prims *do not* have their prim index, type, flags, or
1837 // children composed.
1838 //
1839 // Compose only \p prim's direct children if recurse=false. Otherwise
1840 // recompose every descendent of \p prim. Callers that pass recurse=false
1841 // should invoke _ComposeSubtree on any newly created prims to ensure caches
1842 // are correctly populated.
1843 void _ComposeChildren(Usd_PrimDataPtr prim,
1844 UsdStagePopulationMask const *mask, bool recurse);
1845
1846 // Instantiate a prim instance. There must not already be an instance
1847 // at \p primPath.
1848 Usd_PrimDataPtr _InstantiatePrim(const SdfPath &primPath);
1849
1850 // Instantiate a prototype prim and sets its parent to pseudoroot.
1851 // There must not already be a prototype at \p primPath.
1852 Usd_PrimDataPtr _InstantiatePrototypePrim(const SdfPath &primPath);
1853
1854 // For \p prim and all of its descendants, remove from _primMap and empty
1855 // their _children vectors.
1856 void _DestroyPrim(Usd_PrimDataPtr prim);
1857
1858 // Destroy the prim subtrees rooted at each path in \p paths. \p paths may
1859 // not contain any path that is a descendent of another path in \p paths.
1860 void _DestroyPrimsInParallel(const std::vector<SdfPath>& paths);
1861
1862 // Invoke _DestroyPrim() on all of \p prim's direct children.
1863 void _DestroyDescendents(Usd_PrimDataPtr prim);
1864
1865 // Returns true if the object at the given path is a descendant of
1866 // an instance prim, i.e. a prim beneath an instance prim, or a property
1867 // of a prim beneath an instance prim.
1868 bool _IsObjectDescendantOfInstance(const SdfPath& path) const;
1869
1870 // If the given prim is an instance, returns the corresponding
1871 // prototype prim. Otherwise, returns an invalid prim.
1872 Usd_PrimDataConstPtr _GetPrototypeForInstance(Usd_PrimDataConstPtr p) const;
1873
1874 // Returns the path of the Usd prim using the prim index at the given path.
1875 SdfPath _GetPrimPathUsingPrimIndexAtPath(const SdfPath& primIndexPath) const;
1876
1877 // Responds to LayersDidChangeSentPerLayer event and update stage contents
1878 // in response to changes in scene description.
1879 void _HandleLayersDidChange(const SdfNotice::LayersDidChangeSentPerLayer &);
1880
1881 // Pushes changes through PCP to determine invalidation based on
1882 // composition metadata.
1883 // Note: This method will not perform any processing or notification
1884 // Refer to _ProcessPendingChanges()
1885 void _ComputePendingChanges(const SdfLayerChangeListVec &);
1886
1887 // Update stage contents in response to changes to the asset resolver.
1888 void _HandleResolverDidChange(const ArNotice::ResolverChanged &);
1889
1890 // Process stage change information stored in _pendingChanges.
1891 // _pendingChanges will be set to nullptr by the end of the function.
1892 // This function will return true if UsdNotice::ObjectsChanged and
1893 // UsdNotice::StageContentsChanged notices were sent during execution.
1894 bool _ProcessPendingChanges();
1895
1896 // Remove scene description for the prim at \p fullPath in the current edit
1897 // target.
1898 bool _RemovePrim(const SdfPath& fullPath);
1899
1900 SdfPrimSpecHandle _GetPrimSpec(const SdfPath& fullPath);
1901
1902 // Find and return the defining spec type for the property spec at the given
1903 // path, or SdfSpecTypeUnknown if none exists. The defining spec type is
1904 // either the builtin definition's spec type, if the indicated property is
1905 // builtin, otherwise it's the strongest authored spec's type if one exists,
1906 // otherwise it's SdfSpecTypeUnknown.
1907 SdfSpecType _GetDefiningSpecType(Usd_PrimDataConstPtr primData,
1908 const TfToken &propName) const;
1909
1910 // Helper to apply Pcp changes and recompose the scenegraph accordingly,
1911 // given an optional initial set of paths to recompose.
1912 void _Recompose(const PcpChanges &changes);
1913 template <class T>
1914 void _Recompose(const PcpChanges &changes, T *pathsToRecompose);
1915 template <class T>
1916 void _RecomposePrims(T *pathsToRecompose);
1917
1918 // Helper for _Recompose to find the subtrees that need to be
1919 // fully recomposed and to recompose the name children of the
1920 // parents of these subtrees. Note that [start, finish) must be a
1921 // sorted range of map iterators whose keys are paths with no descendent
1922 // paths. In C++20, consider using the ranges API to improve this.
1923 template <class Iter>
1924 void _ComputeSubtreesToRecompose(Iter start, Iter finish,
1925 std::vector<Usd_PrimDataPtr>* recompose);
1926
1927 // return true if the path is valid for load/unload operations.
1928 // This method will emit errors when invalid paths are encountered.
1929 bool _IsValidForLoad(const SdfPath& path) const;
1930 bool _IsValidForUnload(const SdfPath& path) const;
1931
1932 // Discover all payloads in a given subtree, adding the path of each
1933 // discovered prim index to the \p primIndexPaths set. If specified,
1934 // the corresponding UsdPrim path will be added to the \p usdPrimPaths
1935 // set. The root path will be considered for inclusion in the result set.
1936 //
1937 // Note that some payloads may not be discoverable in until an ancestral
1938 // payload has been included. UsdStage::LoadAndUnload takes this into
1939 // account.
1940 void _DiscoverPayloads(const SdfPath& rootPath,
1941 UsdLoadPolicy policy,
1942 SdfPathSet* primIndexPaths,
1943 bool unloadedOnly = false,
1944 SdfPathSet* usdPrimPaths = nullptr) const;
1945
1946 // ===================================================================== //
1947 // VALUE RESOLUTION //
1948 // ===================================================================== //
1949 // --------------------------------------------------------------------- //
1950 // Specialized Value Resolution
1951 // --------------------------------------------------------------------- //
1952
1953 // Helpers for resolving values for metadata fields requiring
1954 // special behaviors.
1955 static SdfSpecifier _GetSpecifier(Usd_PrimDataConstPtr primData);
1956 static TfToken _GetKind(Usd_PrimDataConstPtr primData);
1957 static bool _IsActive(Usd_PrimDataConstPtr primData);
1958
1959 // Custom is true if it is true anywhere in the stack.
1960 bool _IsCustom(const UsdProperty &prop) const;
1961
1962 // Variability is determined by the weakest opinion in the stack.
1963 SdfVariability _GetVariability(const UsdProperty &prop) const;
1964
1965 // Helper functions for resolving asset paths during value resolution.
1966 void _MakeResolvedAssetPaths(UsdTimeCode time, const UsdAttribute &attr,
1967 SdfAssetPath *assetPaths,
1968 size_t numAssetPaths,
1969 bool anchorAssetPathsOnly = false) const;
1970
1971 void _MakeResolvedAssetPathsValue(UsdTimeCode time, const UsdAttribute &attr,
1972 VtValue *value,
1973 bool anchorAssetPathsOnly = false) const;
1974
1975 void _MakeResolvedTimeCodes(UsdTimeCode time, const UsdAttribute &attr,
1976 SdfTimeCode *timeCodes,
1977 size_t numTimeCodes) const;
1978
1979 void _MakeResolvedPathExpressions(
1980 UsdTimeCode time, const UsdAttribute &attr,
1981 SdfPathExpression *pathExprs,
1982 size_t numPathExprs) const;
1983
1984 void _MakeResolvedAttributeValue(UsdTimeCode time, const UsdAttribute &attr,
1985 VtValue *value) const;
1986
1987 // --------------------------------------------------------------------- //
1988 // Metadata Resolution
1989 // --------------------------------------------------------------------- //
1990
1991public:
1992 // Trait that allows us to call the correct version of _GetMetadata for
1993 // types that require type specific value resolution as opposed to just
1994 // strongest opinion. These types also use type specific resolution
1995 // in _GetValue.
1996 template <class T>
1997 struct _HasTypeSpecificResolution {
1998 static const bool value =
1999 std::is_same<T, SdfAssetPath>::value ||
2000 std::is_same<T, VtArray<SdfAssetPath>>::value ||
2001 std::is_same<T, SdfTimeCode>::value ||
2002 std::is_same<T, VtArray<SdfTimeCode>>::value ||
2003 std::is_same<T, SdfPathExpression>::value ||
2004 std::is_same<T, VtArray<SdfPathExpression>>::value ||
2005 std::is_same<T, SdfTimeSampleMap>::value ||
2006 std::is_same<T, TsSpline>::value ||
2007 std::is_same<T, VtDictionary>::value;
2008 };
2009
2010private:
2011 // Get metadata for types that do not have type specific value resolution.
2012 template <class T>
2013 typename std::enable_if<!_HasTypeSpecificResolution<T>::value, bool>::type
2014 _GetMetadata(const UsdObject &obj,
2015 const TfToken& fieldName,
2016 const TfToken &keyPath,
2017 bool useFallbacks,
2018 T* result) const;
2019
2020 // Get metadata for types that do have type specific value resolution.
2021 template <class T>
2022 typename std::enable_if<_HasTypeSpecificResolution<T>::value, bool>::type
2023 _GetMetadata(const UsdObject &obj,
2024 const TfToken& fieldName,
2025 const TfToken &keyPath,
2026 bool useFallbacks,
2027 T* result) const;
2028
2029 // Get metadata as a dynamically typed VtValue. Will perform type specific
2030 // value resolution if the returned held type requires it.
2031 bool _GetMetadata(const UsdObject &obj,
2032 const TfToken& fieldName,
2033 const TfToken &keyPath,
2034 bool useFallbacks,
2035 VtValue* result) const;
2036
2037 // Gets a metadata value using only strongest value resolution. It is
2038 // assumed that result is holding a value that does not require type
2039 // specific value resolution.
2040 USD_API
2041 bool _GetStrongestResolvedMetadata(const UsdObject &obj,
2042 const TfToken& fieldName,
2043 const TfToken &keyPath,
2044 bool useFallbacks,
2045 SdfAbstractDataValue* result) const;
2046
2047 // Gets a metadata value with the type specific value resolution for the
2048 // type applied. This is only implemented for types that
2049 // _HasTypeSpecificResolution.
2050 template <class T>
2051 USD_API
2052 bool _GetTypeSpecificResolvedMetadata(const UsdObject &obj,
2053 const TfToken& fieldName,
2054 const TfToken &keyPath,
2055 bool useFallbacks,
2056 T* result) const;
2057
2058 template <class Composer>
2059 void _GetAttrTypeImpl(const UsdAttribute &attr,
2060 const TfToken &fieldName,
2061 bool useFallbacks,
2062 Composer *composer) const;
2063
2064 template <class Composer>
2065 void _GetAttrVariabilityImpl(const UsdAttribute &attr,
2066 bool useFallbacks,
2067 Composer *composer) const;
2068
2069 template <class Composer>
2070 void _GetPropCustomImpl(const UsdProperty &prop,
2071 bool useFallbacks,
2072 Composer *composer) const;
2073
2074 template <class Composer>
2075 bool _GetSpecialPropMetadataImpl(const UsdObject &obj,
2076 const TfToken &fieldName,
2077 const TfToken &keyPath,
2078 bool useFallbacks,
2079 Composer *composer) const;
2080 template <class Composer>
2081 bool _GetMetadataImpl(const UsdObject &obj,
2082 const TfToken& fieldName,
2083 const TfToken& keyPath,
2084 bool includeFallbacks,
2085 Composer *composer) const;
2086
2087 template <class Composer>
2088 bool _GetGeneralMetadataImpl(const UsdObject &obj,
2089 const TfToken& fieldName,
2090 const TfToken& keyPath,
2091 bool includeFallbacks,
2092 Composer *composer) const;
2093
2094 // NOTE: The "authoredOnly" flag is not yet in use, but when we have
2095 // support for prim-based metadata fallbacks, they should be ignored when
2096 // this flag is set to true.
2097 bool _HasMetadata(const UsdObject &obj, const TfToken& fieldName,
2098 const TfToken &keyPath, bool useFallbacks) const;
2099
2101 _ListMetadataFields(const UsdObject &obj, bool useFallbacks) const;
2102
2103 void _GetAllMetadata(const UsdObject &obj,
2104 bool useFallbacks,
2105 UsdMetadataValueMap* result,
2106 bool anchorAssetPathsOnly = false) const;
2107
2108 // --------------------------------------------------------------------- //
2109 // Default & TimeSample Resolution
2110 // --------------------------------------------------------------------- //
2111
2112 void _GetResolveInfo(const UsdAttribute &attr,
2113 UsdResolveInfo *resolveInfo,
2114 const UsdTimeCode *time = nullptr) const;
2115
2116 void _GetResolveInfoWithResolveTarget(
2117 const UsdAttribute &attr,
2118 const UsdResolveTarget &resolveTarget,
2119 UsdResolveInfo *resolveInfo,
2120 const UsdTimeCode *time = nullptr) const;
2121
2122 template <class T> struct _ExtraResolveInfo;
2123
2124 // Gets the value resolve info for the given attribute. If time is provided,
2125 // the resolve info is evaluated for that specific time (which may be
2126 // default). Otherwise, if time is null, the resolve info is evaluated for
2127 // "any numeric time" and will not populate values in extraInfo that
2128 // require a specific time to be evaluated.
2129 template <class T>
2130 void _GetResolveInfo(const UsdAttribute &attr,
2131 UsdResolveInfo *resolveInfo,
2132 const UsdTimeCode *time = nullptr,
2133 _ExtraResolveInfo<T> *extraInfo = nullptr) const;
2134
2135 // Gets the value resolve info for the given attribute using the given
2136 // resolve target. If time is provided, the resolve info is evaluated for
2137 // that specific time (which may be default). Otherwise, if time is null,
2138 // the resolve info is evaluated for "any numeric time" and will not
2139 // populate values in extraInfo that require a specific time to be
2140 // evaluated.
2141 template <class T>
2142 void _GetResolveInfoWithResolveTarget(
2143 const UsdAttribute &attr,
2144 const UsdResolveTarget &resolveTarget,
2145 UsdResolveInfo *resolveInfo,
2146 const UsdTimeCode *time = nullptr,
2147 _ExtraResolveInfo<T> *extraInfo = nullptr) const;
2148
2149 // Shared implementation function for _GetResolveInfo and
2150 // _GetResolveInfoWithResolveTarget. The only difference between how these
2151 // two functions behave is in how they create the Usd_Resolver used for
2152 // iterating over nodes and layers, thus they provide this implementation
2153 // with the needed MakeUsdResolverFn to create the Usd_Resolver.
2154 template <class T, class MakeUsdResolverFn>
2155 void _GetResolveInfoImpl(const UsdAttribute &attr,
2156 UsdResolveInfo *resolveInfo,
2157 const UsdTimeCode *time,
2158 _ExtraResolveInfo<T> *extraInfo,
2159 const MakeUsdResolverFn &makeUsdResolveFn) const;
2160
2161 template <class T> struct _ResolveInfoResolver;
2162 struct _PropertyStackResolver;
2163
2164 template <class Resolver, class MakeUsdResolverFn>
2165 void _GetResolvedValueAtDefaultImpl(
2166 const UsdProperty &prop,
2167 Resolver *resolver,
2168 const MakeUsdResolverFn &makeUsdResolverFn) const;
2169
2170 template <class Resolver, class MakeUsdResolverFn>
2171 void _GetResolvedValueAtTimeImpl(
2172 const UsdProperty &prop,
2173 Resolver *resolver,
2174 const UsdTimeCode *time,
2175 const MakeUsdResolverFn &makeUsdResolverFn) const;
2176
2177 bool _GetValue(UsdTimeCode time, const UsdAttribute &attr,
2178 VtValue* result) const;
2179
2180 template <class T>
2181 bool _GetValue(UsdTimeCode time, const UsdAttribute &attr,
2182 T* result) const;
2183
2184 template <class T>
2185 bool _GetValueImpl(UsdTimeCode time, const UsdAttribute &attr,
2186 Usd_InterpolatorBase* interpolator,
2187 T* value) const;
2188
2189 USD_API
2190 bool _GetValueFromResolveInfo(const UsdResolveInfo &info,
2191 UsdTimeCode time, const UsdAttribute &attr,
2192 VtValue* result) const;
2193
2194 template <class T>
2195 USD_API
2196 bool _GetValueFromResolveInfo(const UsdResolveInfo &info,
2197 UsdTimeCode time, const UsdAttribute &attr,
2198 T* result) const;
2199
2200 template <class T>
2201 bool _GetValueFromResolveInfoImpl(const UsdResolveInfo &info,
2202 UsdTimeCode time, const UsdAttribute &attr,
2203 Usd_InterpolatorBase* interpolator,
2204 T* value) const;
2205
2206 template <class T>
2207 bool _GetDefaultValueFromResolveInfoImpl(const UsdResolveInfo &info,
2208 const UsdAttribute &attr,
2209 T* value) const;
2210
2211 Usd_AssetPathContext
2212 _GetAssetPathContext(UsdTimeCode time, const UsdAttribute &attr) const;
2213
2214 // --------------------------------------------------------------------- //
2215 // Specialized Time Sample I/O
2216 // --------------------------------------------------------------------- //
2217
2224 bool _GetTimeSamplesInInterval(const UsdAttribute &attr,
2225 const GfInterval& interval,
2226 std::vector<double>* times) const;
2227
2228 bool _GetTimeSamplesInIntervalFromResolveInfo(
2229 const UsdResolveInfo &info,
2230 const UsdAttribute &attr,
2231 const GfInterval& interval,
2232 std::vector<double>* times) const;
2233
2234 size_t _GetNumTimeSamples(const UsdAttribute &attr) const;
2235
2236 size_t _GetNumTimeSamplesFromResolveInfo(const UsdResolveInfo &info,
2237 const UsdAttribute &attr) const;
2238
2242 bool _GetBracketingTimeSamples(const UsdAttribute &attr,
2243 double desiredTime,
2244 bool authoredOnly,
2245 double* lower,
2246 double* upper,
2247 bool* hasSamples) const;
2248
2249 bool _GetBracketingTimeSamplesFromResolveInfo(const UsdResolveInfo &info,
2250 const UsdAttribute &attr,
2251 double desiredTime,
2252 bool authoredOnly,
2253 double* lower,
2254 double* upper,
2255 bool* hasSamples) const;
2256
2257 bool _ValueMightBeTimeVarying(const UsdAttribute &attr) const;
2258
2259 bool _ValueMightBeTimeVaryingFromResolveInfo(const UsdResolveInfo &info,
2260 const UsdAttribute &attr) const;
2261
2262 void _RegisterPerLayerNotices();
2263 void _RegisterResolverChangeNotice();
2264
2265 // Helper to obtain a malloc tag string for this stage.
2266 inline char const *_GetMallocTagId() const;
2267
2268private:
2269 class _PendingChanges;
2270
2271 // Change block for use by the UsdNamespaceEditor to allow it to indicate
2272 // to its dependent stages what the expected namespace edits are when the
2273 // stages handles notices from the changes the namespace editor performs.
2274 // The stage uses this provide additional information about prim resyncs
2275 // related to namespace edits in the ObjectsChanged notice it sends.
2276 class _NamespaceEditsChangeBlock {
2277 public:
2278 // Info about an expected namespace edit change from UsdNamespaceEditor.
2279 // This includes the original pre-edit prim stack of the prim at the old
2280 // path which is used to determine if the prim at the new path has the
2281 // same composed contents after the edits as the prim had originally at
2282 // the old path before the edits.
2283 struct ExpectedNamespaceEditChange {
2284 SdfPath oldPath;
2285 SdfPath newPath;
2286 SdfPrimSpecHandleVector oldPrimStack;
2287 };
2288 using ExpectedNamespaceEditChangeVector =
2289 std::vector<ExpectedNamespaceEditChange>;
2290
2291 _NamespaceEditsChangeBlock(const UsdStagePtr &stage,
2292 ExpectedNamespaceEditChangeVector &&expectedChanges);
2293 _NamespaceEditsChangeBlock(_NamespaceEditsChangeBlock &&);
2294 ~_NamespaceEditsChangeBlock();
2295
2296 private:
2297 UsdStagePtr _stage;
2298 std::unique_ptr<_PendingChanges> _localPendingChanges;
2299 };
2300
2301 // The 'pseudo root' prim.
2302 Usd_PrimDataPtr _pseudoRoot;
2303
2304 // The stage's root layer.
2305 SdfLayerRefPtr _rootLayer;
2306
2307 // Every UsdStage has an implicit, in-memory session layer.
2308 // This is to allow for runtime overrides such as variant selections.
2309 SdfLayerRefPtr _sessionLayer;
2310
2311 // The stage's EditTarget.
2312 UsdEditTarget _editTarget;
2313 bool _editTargetIsLocalLayer;
2314
2315 std::unique_ptr<PcpCache> _cache;
2316 std::unique_ptr<Usd_ClipCache> _clipCache;
2317 std::unique_ptr<Usd_InstanceCache> _instanceCache;
2318
2319 TfHashMap<TfToken, TfToken, TfHash> _invalidPrimTypeToFallbackMap;
2320
2321 size_t _usedLayersRevision;
2322
2323 // A concurrent map from Path to Prim, for fast random access.
2324 struct _TbbHashEq {
2325 inline bool equal(SdfPath const &l, SdfPath const &r) const {
2326 return l == r;
2327 }
2328 inline size_t hash(SdfPath const &path) const {
2329 return path.GetHash();
2330 }
2331 };
2332 using PathToNodeMap = tbb::concurrent_hash_map<
2333 SdfPath, Usd_PrimDataIPtr, _TbbHashEq>;
2334 PathToNodeMap _primMap;
2335
2336 // The interpolation type used for all attributes on the stage.
2337 UsdInterpolationType _interpolationType;
2338
2339 typedef std::vector<
2340 std::pair<SdfLayerHandle, TfNotice::Key> > _LayerAndNoticeKeyVec;
2341 _LayerAndNoticeKeyVec _layersAndNoticeKeys;
2342 size_t _lastChangeSerialNumber;
2343
2344 TfNotice::Key _resolverChangeKey;
2345
2346 // Data for pending change processing.
2347 _PendingChanges* _pendingChanges;
2348
2349 std::optional<WorkDispatcher> _dispatcher;
2350
2351 // To provide useful aggregation of malloc stats, we bill everything
2352 // for this stage - from all access points - to this tag.
2353 std::unique_ptr<std::string> _mallocTagID;
2354
2355 // The state used when instantiating the stage.
2356 const InitialLoadSet _initialLoadSet;
2357
2358 // The population mask that applies to this stage.
2359 UsdStagePopulationMask _populationMask;
2360
2361 // The load rules that apply to this stage.
2362 UsdStageLoadRules _loadRules;
2363
2364 bool _isClosingStage;
2365 bool _isWritingFallbackPrimTypes;
2366
2367 friend class UsdAPISchemaBase;
2368 friend class UsdAttribute;
2369 friend class UsdAttributeQuery;
2370 friend class UsdEditTarget;
2371 friend class UsdInherits;
2372 friend class UsdNamespaceEditor;
2373 friend class UsdObject;
2374 friend class UsdPrim;
2375 friend class UsdProperty;
2376 friend class UsdRelationship;
2377 friend class UsdSpecializes;
2378 friend class UsdVariantSet;
2379 friend class UsdVariantSets;
2380 friend class Usd_AssetPathContext;
2381 friend class Usd_FlattenAccess;
2382 friend class Usd_PcpCacheAccess;
2383 friend class Usd_PrimData;
2384 friend class Usd_StageOpenRequest;
2385 friend class Usd_TypeQueryAccess;
2386 template <class T> friend struct Usd_AttrGetValueHelper;
2387 friend struct Usd_AttrGetUntypedValueHelper;
2388 template <class RefsOrPayloadsEditorType, class RefsOrPayloadsProxyType>
2389 friend struct Usd_ListEditImpl;
2390};
2391
2392// UsdObject's typed metadata query relies on this specialization being
2393// externally visible and exporting the primary template does not
2394// automatically export this specialization.
2395template <>
2396USD_API
2397bool
2398UsdStage::_GetTypeSpecificResolvedMetadata(const UsdObject &obj,
2399 const TfToken& fieldName,
2400 const TfToken &keyPath,
2401 bool useFallbacks,
2402 SdfTimeSampleMap* result) const;
2403
2404template<typename T>
2405bool
2406UsdStage::GetMetadata(const TfToken& key, T* value) const
2407{
2408 VtValue result;
2409 if (!GetMetadata(key, &result)){
2410 return false;
2411 }
2412
2413 if (result.IsHolding<T>()){
2414 *value = result.UncheckedGet<T>();
2415 return true;
2416 } else {
2417 TF_CODING_ERROR("Requested type %s for stage metadatum %s does not"
2418 " match retrieved type %s",
2419 ArchGetDemangled<T>().c_str(),
2420 key.GetText(),
2421 result.GetTypeName().c_str());
2422 return false;
2423 }
2424}
2425
2426template<typename T>
2427bool
2428UsdStage::SetMetadata(const TfToken& key, const T& value) const
2429{
2430 VtValue in(value);
2431 return SetMetadata(key, in);
2432}
2433
2434template<typename T>
2435bool
2437 T* value) const
2438{
2439 VtValue result;
2440 if (!GetMetadataByDictKey(key, keyPath, &result)){
2441 return false;
2442 }
2443
2444 if (result.IsHolding<T>()){
2445 *value = result.UncheckedGet<T>();
2446 return true;
2447 } else {
2448 TF_CODING_ERROR("Requested type %s for stage metadatum %s[%s] does not"
2449 " match retrieved type %s",
2450 ArchGetDemangled<T>().c_str(),
2451 key.GetText(),
2452 keyPath.GetText(),
2453 result.GetTypeName().c_str());
2454 return false;
2455 }
2456}
2457
2458template<typename T>
2459bool
2461 const T& value) const
2462{
2463 VtValue in(value);
2464 return SetMetadataByDictKey(key, keyPath, in);
2465}
2466
2467// Get metadata for types that do not have type specific value resolution.
2468template <class T>
2469typename std::enable_if<
2470 !UsdStage::_HasTypeSpecificResolution<T>::value, bool>::type
2471UsdStage::_GetMetadata(const UsdObject &obj,
2472 const TfToken& fieldName,
2473 const TfToken &keyPath,
2474 bool useFallbacks,
2475 T* result) const
2476{
2477 // Since these types don't have type specific value resolution, we can just
2478 // get the strongest metadata value and be done.
2479 SdfAbstractDataTypedValue<T> out(result);
2480 return _GetStrongestResolvedMetadata(
2481 obj, fieldName, keyPath, useFallbacks, &out);
2482}
2483
2484// Get metadata for types that do have type specific value resolution.
2485template <class T>
2486typename std::enable_if<
2487 UsdStage::_HasTypeSpecificResolution<T>::value, bool>::type
2488UsdStage::_GetMetadata(const UsdObject &obj,
2489 const TfToken& fieldName,
2490 const TfToken &keyPath,
2491 bool useFallbacks,
2492 T* result) const
2493{
2494 // Call the templated type specifice resolved metadata implementation that
2495 // will only be implemented for types that support it.
2496 return _GetTypeSpecificResolvedMetadata(
2497 obj, fieldName, keyPath, useFallbacks, result);
2498}
2499
2500
2501// Set metadata for types that don't need to be mapped across edit targets.
2502template <class T>
2503typename std::enable_if<!UsdStage::_IsEditTargetMappable<T>::value, bool>::type
2504UsdStage::_SetMetadata(const UsdObject &object, const TfToken& key,
2505 const TfToken &keyPath, const T& value)
2506{
2507 // Since we know that we don't need to map the value for edit targets,
2508 // we can just type erase the value and set the metadata as is.
2510 return _SetMetadataImpl<SdfAbstractDataConstValue>(
2511 object, key, keyPath, in);
2512}
2513
2514// Set metadata for types that do need to be mapped for edit targets.
2515template <class T>
2516typename std::enable_if<UsdStage::_IsEditTargetMappable<T>::value, bool>::type
2517UsdStage::_SetMetadata(const UsdObject &object, const TfToken& key,
2518 const TfToken &keyPath, const T& value)
2519{
2520 return _SetEditTargetMappedMetadata(object, key, keyPath, value);
2521}
2522
2523PXR_NAMESPACE_CLOSE_SCOPE
2524
2525#endif //PXR_USD_USD_STAGE_H
2526
Notice sent when asset paths may resolve to a different path than before due to a change in the resol...
Definition: notice.h:50
An asset resolver context allows clients to provide additional data to the resolver for use during re...
A basic mathematical interval class.
Definition: interval.h:33
PcpCache is the context required to make requests of the Pcp composition algorithm and cache the resu...
Definition: cache.h:77
Describes Pcp changes.
Definition: changes.h:219
PcpPrimIndex is an index of the all sites of scene description that contribute opinions to a specific...
Definition: primIndex.h:62
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:592
The fully-typed container for a field value in an SdfAbstractData.
Definition: abstractData.h:482
A type-erased container for a field value in an SdfAbstractData.
Definition: abstractData.h:417
Contains an asset path and optional evaluated and resolved paths.
Definition: assetPath.h:78
SdfHandle is a smart ptr that calls IsDormant() on the pointed-to object as an extra expiration check...
A scene description container that can combine with other such containers to form simple component as...
Definition: layer.h:84
std::map< std::string, std::string > FileFormatArguments
Type for specifying additional file format-specific arguments to layer API.
Definition: layer.h:107
Notice sent per-layer indicating all layers whose contents have changed within a single round of chan...
Definition: notice.h:94
Objects of this class represent a logical expression syntax tree consisting of SdfPathPattern s,...
A path value used to locate objects in layers or scenegraphs.
Definition: path.h:274
static SDF_API const SdfPath & AbsoluteRootPath()
The absolute path representing the top of the namespace hierarchy.
Value type that represents a time code.
Definition: timeCode.h:28
Stores a pointer to a ValueType which uses TfDelegatedCountIncrement and TfDelegatedCountDecrement to...
Handle-object returned by TfNotice::Register().
Definition: notice.h:241
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:56
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
char const * GetText() const
Return the text that this token represents.
Definition: token.h:179
TfType represents a dynamic runtime type.
Definition: type.h:48
Enable a concrete base class for use with TfWeakPtr.
Definition: weakBase.h:124
A mathematical description of a curved function from time to value.
Definition: spline.h:59
The base class for all API schemas.
Definition: apiSchemaBase.h:99
Scenegraph object for authoring and retrieving numeric, string, and array valued data,...
Definition: attribute.h:183
Object for efficiently making repeated queries for attribute values.
Defines a mapping from scene graph paths to Sdf spec paths in a SdfLayer where edits should be direct...
Definition: editTarget.h:64
A proxy class for applying listOp edits to the inherit paths list for a prim.
Definition: inherits.h:34
Base class for Usd scenegraph objects, providing common API.
Definition: object.h:115
Accessor to a attribute's definition in the prim definition.
Accessor to a property's definition in the prim definition.
Accessor to a relationship's definition in the prim definition.
UsdPrim is the sole persistent scenegraph object on a UsdStage, and is the embodiment of a "Prim" as ...
Definition: prim.h:117
An forward-iterable range that traverses a subtree of prims rooted at a given prim in depth-first ord...
Definition: primRange.h:102
Base class for UsdAttribute and UsdRelationship scenegraph objects.
Definition: property.h:38
A UsdRelationship creates dependencies between scenegraph objects by allowing a prim to target other ...
Definition: relationship.h:111
Container for information about the source of an attribute's value, i.e.
Definition: resolveInfo.h:55
Defines a subrange of nodes and layers within a prim's prim index to consider when performing value r...
Definition: resolveTarget.h:56
A proxy class for applying listOp edits to the specializes list for a prim.
Definition: specializes.h:34
The outermost container for scene description, which owns and presents composed prims as a scenegraph...
Definition: stage.h:136
USD_API void SetEndTimeCode(double)
Sets the stage's end timeCode.
USD_API bool SetMetadataByDictKey(const TfToken &key, const TfToken &keyPath, const VtValue &value) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API void LoadAndUnload(const SdfPathSet &loadSet, const SdfPathSet &unloadSet, UsdLoadPolicy policy=UsdLoadWithDescendants)
Unload and load the given path sets.
USD_API void WriteFallbackPrimTypes()
Writes the fallback prim types defined in the schema registry to the stage as dictionary valued fallb...
static USD_API void SetColorConfigFallbacks(const SdfAssetPath &colorConfiguration, const TfToken &colorManagementSystem)
Sets the global fallback values of color configuration metadata which includes the 'colorConfiguratio...
static USD_API UsdStageRefPtr Open(const SdfLayerHandle &rootLayer, const SdfLayerHandle &sessionLayer, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API bool ExportToString(std::string *result, bool addSourceFileComment=true) const
Writes the composite scene as a flattened Usd text representation into the given string.
bool SetMetadata(const TfToken &key, const T &value) const
Set the value of Stage metadatum key to value, if the stage's current UsdEditTarget is the root or se...
Definition: stage.h:2428
static USD_API UsdStageRefPtr OpenMasked(const SdfLayerHandle &rootLayer, const UsdStagePopulationMask &mask, InitialLoadSet load=LoadAll)
Open a stage rooted at rootLayer and with limited population subject to mask.
static USD_API UsdStageRefPtr CreateNew(const std::string &identifier, const SdfLayerHandle &sessionLayer, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API std::vector< UsdPrim > GetPrototypes() const
Returns all native instancing prototype prims.
USD_API bool HasAuthoredMetadataDictKey(const TfToken &key, const TfToken &keyPath) const
Return true if there exists any authored opinion (excluding fallbacks) for key and keyPath.
USD_API UsdPrim OverridePrim(const SdfPath &path)
Attempt to ensure a UsdPrim at path exists on this stage.
USD_API void SetPopulationMask(UsdStagePopulationMask const &mask)
Set this stage's population mask and recompose the stage.
USD_API void UnmuteLayer(const std::string &layerIdentifier)
Unmute the layer identified by layerIdentifier if it had previously been muted.
USD_API SdfPathSet GetLoadSet()
Returns a set of all loaded paths.
USD_API PcpErrorVector GetCompositionErrors() const
Return a PcpErrorVector containing all composition errors encountered when composing the prims and la...
static USD_API PcpVariantFallbackMap GetGlobalVariantFallbacks()
Get the global variant fallback preferences used in new UsdStages.
USD_API void ExpandPopulationMask(std::function< bool(UsdRelationship const &)> const &relPred=nullptr, std::function< bool(UsdAttribute const &)> const &attrPred=nullptr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API bool HasAuthoredMetadata(const TfToken &key) const
Returns true if the key has an authored value, false if no value was authored or the only value avail...
USD_API UsdEditTarget GetEditTargetForLocalLayer(size_t i)
Return a UsdEditTarget for editing the layer at index i in the layer stack.
USD_API SdfLayerHandleVector GetUsedLayers(bool includeClipLayers=true) const
Return a vector of all of the layers currently consumed by this stage, as determined by the compositi...
USD_API bool GetMetadataByDictKey(const TfToken &key, const TfToken &keyPath, VtValue *value) const
overload
USD_API double GetEndTimeCode() const
Returns the stage's end timeCode.
static USD_API UsdStageRefPtr CreateInMemory(const std::string &identifier, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
UsdStagePopulationMask GetPopulationMask() const
Return this stage's population mask.
Definition: stage.h:655
USD_API bool Export(const std::string &filename, bool addSourceFileComment=true, const SdfLayer::FileFormatArguments &args=SdfLayer::FileFormatArguments()) const
Writes out the composite scene as a single flattened layer into filename.
static USD_API UsdStageRefPtr CreateNew(const std::string &identifier, InitialLoadSet load=LoadAll)
Create a new stage with root layer identifier, destroying potentially existing files with that identi...
USD_API UsdPrim GetPseudoRoot() const
Return the stage's "pseudo-root" prim, whose name is defined by Usd.
USD_API double GetFramesPerSecond() const
Returns the stage's framesPerSecond value.
USD_API std::string ResolveIdentifierToEditTarget(std::string const &identifier) const
Resolve the given identifier using this stage's ArResolverContext and the layer of its GetEditTarget(...
USD_API void ExpandPopulationMask(Usd_PrimFlagsPredicate const &traversalPredicate, std::function< bool(UsdRelationship const &)> const &relPred=nullptr, std::function< bool(UsdAttribute const &)> const &attrPred=nullptr)
Expand this stage's population mask to include the targets of all relationships that pass relPred and...
USD_API UsdProperty GetPropertyAtPath(const SdfPath &path) const
Return the UsdProperty at path, or an invalid UsdProperty if none exists.
static USD_API UsdStageRefPtr CreateInMemory(const std::string &identifier, const SdfLayerHandle &sessionLayer, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API UsdPrim DefinePrim(const SdfPath &path, const TfToken &typeName=TfToken())
Attempt to ensure a UsdPrim at path is defined (according to UsdPrim::IsDefined()) on this stage.
USD_API void SetTimeCodesPerSecond(double timeCodesPerSecond) const
Sets the stage's timeCodesPerSecond value.
USD_API UsdAttribute GetAttributeAtPath(const SdfPath &path) const
Return the UsdAttribute at path, or an invalid UsdAttribute if none exists.
USD_API UsdPrim GetDefaultPrim() const
Return the UsdPrim on this stage whose path is the root layer's defaultPrim metadata's value.
USD_API bool HasDefaultPrim() const
Return true if this stage's root layer has an authored opinion for the default prim layer metadata.
USD_API UsdPrimRange Traverse(const Usd_PrimFlagsPredicate &predicate)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static USD_API void GetColorConfigFallbacks(SdfAssetPath *colorConfiguration, TfToken *colorManagementSystem)
Returns the global fallback values of 'colorConfiguration' and 'colorManagementSystem'.
USD_API UsdPrim GetPrimAtPath(const SdfPath &path) const
Return the UsdPrim at path, or an invalid UsdPrim if none exists.
USD_API UsdInterpolationType GetInterpolationType() const
Returns the interpolation type used during value resolution for all attributes on this stage.
USD_API UsdPrimRange TraverseAll()
Traverse all the prims on this stage depth-first.
USD_API bool IsLayerMuted(const std::string &layerIdentifier) const
Returns true if the layer specified by layerIdentifier is muted in this cache, false otherwise.
USD_API void SetColorManagementSystem(const TfToken &cms) const
Sets the name of the color management system used to interpret the color configuration file pointed a...
USD_API void ClearDefaultPrim()
Clear the default prim layer metadata in this stage's root layer.
InitialLoadSet
Specifies the initial set of prims to load when opening a UsdStage.
Definition: stage.h:150
@ LoadAll
Load all loadable prims.
Definition: stage.h:151
@ LoadNone
Load no loadable prims.
Definition: stage.h:152
bool SetMetadataByDictKey(const TfToken &key, const TfToken &keyPath, const T &value) const
Author value to the field identified by key and keyPath at the current EditTarget.
Definition: stage.h:2460
static USD_API UsdStageRefPtr CreateNew(const std::string &identifier, const SdfLayerHandle &sessionLayer, const ArResolverContext &pathResolverContext, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static USD_API UsdStageRefPtr CreateInMemory(InitialLoadSet load=LoadAll)
Creates a new stage only in memory, analogous to creating an anonymous SdfLayer.
USD_API void SetDefaultPrim(const UsdPrim &prim)
Set the default prim layer metadata in this stage's root layer.
USD_API double GetTimeCodesPerSecond() const
Returns the stage's timeCodesPerSecond value.
static USD_API UsdStageRefPtr OpenMasked(const SdfLayerHandle &rootLayer, const SdfLayerHandle &sessionLayer, const ArResolverContext &pathResolverContext, const UsdStagePopulationMask &mask, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API double GetStartTimeCode() const
Returns the stage's start timeCode.
USD_API void MuteLayer(const std::string &layerIdentifier)
Mute the layer identified by layerIdentifier.
USD_API const std::vector< std::string > & GetMutedLayers() const
Returns a vector of all layers that have been muted on this stage.
USD_API bool HasMetadataDictKey(const TfToken &key, const TfToken &keyPath) const
Return true if there exists any authored or fallback opinion for key and keyPath.
USD_API UsdPrim CreateClassPrim(const SdfPath &rootPrimPath)
Author an SdfPrimSpec with specifier == SdfSpecifierClass for the class at root prim path path at the...
USD_API void SaveSessionLayers()
Calls SdfLayer::Save on all dirty session layers and sublayers of session layers contributing to this...
static USD_API UsdStageRefPtr CreateInMemory(const std::string &identifier, const SdfLayerHandle &sessionLayer, const ArResolverContext &pathResolverContext, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static USD_API UsdStageRefPtr OpenMasked(const SdfLayerHandle &rootLayer, const ArResolverContext &pathResolverContext, const UsdStagePopulationMask &mask, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API UsdObject GetObjectAtPath(const SdfPath &path) const
Return the UsdObject at path, or an invalid UsdObject if none exists.
USD_API SdfLayerHandleVector GetLayerStack(bool includeSessionLayers=true) const
includeSessionLayers is true, return the linearized strong-to-weak sublayers rooted at the stage's se...
static USD_API UsdStageRefPtr CreateNew(const std::string &identifier, const ArResolverContext &pathResolverContext, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static USD_API bool IsSupportedFile(const std::string &filePath)
Indicates whether the specified file is supported by UsdStage.
static USD_API UsdStageRefPtr CreateInMemory(const std::string &identifier, const ArResolverContext &pathResolverContext, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API void MuteAndUnmuteLayers(const std::vector< std::string > &muteLayers, const std::vector< std::string > &unmuteLayers)
Mute and unmute the layers identified in muteLayers and unmuteLayers.
USD_API void SetColorConfiguration(const SdfAssetPath &colorConfig) const
Sets the default color configuration to be used for querying color configuration metadata stored in a...
USD_API bool HasLocalLayer(const SdfLayerHandle &layer) const
Return true if layer is one of the layers in this stage's local, root layerStack.
USD_API void SetFramesPerSecond(double framesPerSecond) const
Sets the stage's framesPerSecond value.
static USD_API UsdStageRefPtr Open(const SdfLayerHandle &rootLayer, const ArResolverContext &pathResolverContext, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool GetMetadataByDictKey(const TfToken &key, const TfToken &keyPath, T *value) const
Resolve the requested dictionary sub-element keyPath of dictionary-valued metadatum named key,...
Definition: stage.h:2436
USD_API SdfAssetPath GetColorConfiguration() const
Returns the default color configuration stored in layer metadata.
USD_API bool SetMetadata(const TfToken &key, const VtValue &value) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static USD_API UsdStageRefPtr Open(const std::string &filePath, InitialLoadSet load=LoadAll)
Attempt to find a matching existing stage in a cache if UsdStageCacheContext objects exist on the sta...
USD_API void Reload()
Calls SdfLayer::Reload on all layers contributing to this stage, except session layers and sublayers ...
USD_API bool RemovePrim(const SdfPath &path)
Remove all scene description for the given path and its subtree in the current UsdEditTarget.
USD_API bool HasAuthoredTimeCodeRange() const
Returns true if the stage has both start and end timeCodes authored in the session layer or the root ...
USD_API void SetEditTarget(const UsdEditTarget &editTarget)
Set the stage's EditTarget.
USD_API UsdEditTarget GetEditTargetForLocalLayer(const SdfLayerHandle &layer)
Return a UsdEditTarget for editing the given local layer.
USD_API void SetLoadRules(UsdStageLoadRules const &rules)
Set the UsdStageLoadRules to govern payload inclusion on this stage.
USD_API void SetInterpolationType(UsdInterpolationType interpolationType)
Sets the interpolation type used during value resolution for all attributes on this stage.
bool GetMetadata(const TfToken &key, T *value) const
Return in value an authored or fallback value (if one was defined for the given metadatum) for Stage ...
Definition: stage.h:2406
static USD_API UsdStageRefPtr Open(const SdfLayerHandle &rootLayer, InitialLoadSet load=LoadAll)
Open a stage rooted at rootLayer.
static USD_API UsdStageRefPtr OpenMasked(const std::string &filePath, const ArResolverContext &pathResolverContext, UsdStagePopulationMask const &mask, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static USD_API UsdStageRefPtr Open(const std::string &filePath, const ArResolverContext &pathResolverContext, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API ArResolverContext GetPathResolverContext() const
Return the path resolver context for all path resolution during composition of this stage.
USD_API TfToken GetColorManagementSystem() const
Sets the name of the color management system to be used for loading and interpreting the color config...
USD_API UsdPrimRange Traverse()
Traverse the active, loaded, defined, non-abstract prims on this stage depth-first.
UsdStageLoadRules const & GetLoadRules() const
Return the stage's current UsdStageLoadRules governing payload inclusion.
Definition: stage.h:638
static USD_API void SetGlobalVariantFallbacks(const PcpVariantFallbackMap &fallbacks)
Set the global variant fallback preferences used in new UsdStages.
static USD_API UsdStageRefPtr OpenMasked(const std::string &filePath, UsdStagePopulationMask const &mask, InitialLoadSet load=LoadAll)
Create a new stage and recursively compose prims defined within and referenced by the layer at filePa...
USD_API void Save()
Calls SdfLayer::Save on all dirty layers contributing to this stage except session layers and sublaye...
USD_API SdfPathSet FindLoadable(const SdfPath &rootPath=SdfPath::AbsoluteRootPath())
Returns an SdfPathSet of all paths that can be loaded.
USD_API bool HasMetadata(const TfToken &key) const
Returns true if the key has a meaningful value, that is, if GetMetadata() will provide a value,...
USD_API SdfLayerRefPtr Flatten(bool addSourceFileComment=true) const
Returns a single, anonymous, merged layer for this composite scene.
USD_API SdfLayerHandle GetRootLayer() const
Return this stage's root layer.
static USD_API UsdStageRefPtr OpenMasked(const SdfLayerHandle &rootLayer, const SdfLayerHandle &sessionLayer, const UsdStagePopulationMask &mask, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API UsdRelationship GetRelationshipAtPath(const SdfPath &path) const
Return the UsdAttribute at path, or an invalid UsdAttribute if none exists.
USD_API UsdPrim Load(const SdfPath &path=SdfPath::AbsoluteRootPath(), UsdLoadPolicy policy=UsdLoadWithDescendants)
Modify this stage's load rules to load the prim at path, its ancestors, and all of its descendants if...
USD_API void Unload(const SdfPath &path=SdfPath::AbsoluteRootPath())
Modify this stage's load rules to unload the prim and its descendants specified by path.
USD_API void SetStartTimeCode(double)
Sets the stage's start timeCode.
USD_API bool GetMetadata(const TfToken &key, VtValue *value) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static USD_API UsdStageRefPtr Open(const SdfLayerHandle &rootLayer, const SdfLayerHandle &sessionLayer, const ArResolverContext &pathResolverContext, InitialLoadSet load=LoadAll)
This is an overloaded member function, provided for convenience. It differs from the above function o...
USD_API bool ClearMetadata(const TfToken &key) const
Clear the value of stage metadatum key, if the stage's current UsdEditTarget is the root or session l...
USD_API SdfLayerHandle GetSessionLayer() const
Return this stage's root session layer.
USD_API const UsdEditTarget & GetEditTarget() const
Return the stage's EditTarget.
USD_API bool ClearMetadataByDictKey(const TfToken &key, const TfToken &keyPath) const
Clear any authored value identified by key and keyPath at the current EditTarget.
This class represents rules that govern payload inclusion on UsdStages.
This class represents a mask that may be applied to a UsdStage to limit the set of UsdPrim s it popul...
Represent a time value, which may be either numeric, holding a double value, or a sentinel value UsdT...
Definition: timeCode.h:72
A UsdVariantSet represents a single VariantSet in USD (e.g.
Definition: variantSets.h:39
UsdVariantSets represents the collection of VariantSets that are present on a UsdPrim.
Definition: variantSets.h:205
Provides a container which may hold any type, and provides introspection and iteration over array typ...
Definition: value.h:152
VT_API std::string GetTypeName() const
Return the type name of the held typeid.
bool IsHolding() const
Return true if this value is holding an object of type T, false otherwise.
Definition: value.h:1050
T const & UncheckedGet() const &
Returns a const reference to the held object if the held object is of type T.
Definition: value.h:1094
UsdLoadPolicy
Controls UsdStage::Load() and UsdPrim::Load() behavior regarding whether or not descendant prims are ...
Definition: common.h:99
@ UsdLoadWithDescendants
Load a prim plus all its descendants.
Definition: common.h:101
Standard pointer typedefs.
#define TF_CODING_ERROR(fmt, args)
Issue an internal programming error, but continue execution.
Definition: diagnostic.h:68
UsdInterpolationType
Attribute value interpolation options.
Definition: interpolation.h:28
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:440
std::map< std::string, std::vector< std::string > > PcpVariantFallbackMap
typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap
Definition: types.h:189
Basic Sdf data types.
SdfSpecType
An enum that specifies the type of an object.
Definition: types.h:68
SdfSpecifier
An enum that identifies the possible specifiers for an SdfPrimSpec.
Definition: types.h:100
SdfVariability
An enum that identifies variability types for attributes.
Definition: types.h:156
std::map< double, VtValue > SdfTimeSampleMap
A map from sample times to sample values.
Definition: types.h:277