add usd-21-05-win64_py37
This commit is contained in:
1 parent
41d23e71ba
commit
66bc054336
15675 files changed
+3061008
No files matched your search
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright 2017 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_API_H
|
||||
#define PXR_USD_PCP_API_H
|
||||
|
||||
#include "pxr/base/arch/export.h"
|
||||
|
||||
#if defined(PXR_STATIC)
|
||||
# define PCP_API
|
||||
# define PCP_API_TEMPLATE_CLASS(...)
|
||||
# define PCP_API_TEMPLATE_STRUCT(...)
|
||||
# define PCP_LOCAL
|
||||
#else
|
||||
# if defined(PCP_EXPORTS)
|
||||
# define PCP_API ARCH_EXPORT
|
||||
# define PCP_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
|
||||
# define PCP_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
|
||||
# else
|
||||
# define PCP_API ARCH_IMPORT
|
||||
# define PCP_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
|
||||
# define PCP_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
|
||||
# endif
|
||||
# define PCP_LOCAL ARCH_HIDDEN
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_ARC_H
|
||||
#define PXR_USD_PCP_ARC_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/mapExpression.h"
|
||||
#include "pxr/usd/pcp/node.h"
|
||||
#include "pxr/usd/pcp/types.h"
|
||||
#include "pxr/usd/sdf/path.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class PcpPrimIndex_Graph;
|
||||
|
||||
/// \class PcpArc
|
||||
///
|
||||
/// Represents an arc connecting two nodes in the prim index.
|
||||
/// The arc is owned by a node (source) and points to its parent node (target)
|
||||
/// in the index.
|
||||
///
|
||||
class PcpArc
|
||||
{
|
||||
public:
|
||||
PcpArc()
|
||||
: type(PcpArcTypeRoot)
|
||||
, siblingNumAtOrigin(0)
|
||||
, namespaceDepth(0)
|
||||
{ }
|
||||
|
||||
/// The type of this arc.
|
||||
PcpArcType type;
|
||||
|
||||
/// The parent (or target) node of this arc.
|
||||
/// If this arc's source node is a root node (i.e., type == PcpArcTypeRoot),
|
||||
/// this will be an invalid node.
|
||||
PcpNodeRef parent;
|
||||
|
||||
/// The origin node of this arc.
|
||||
/// This is the node that caused this arc's source node to be brought into
|
||||
/// the prim index. In most cases, this will be the same as the parent node.
|
||||
/// For implied inherits, this is the node from which this inherit arc was
|
||||
/// propagated. This affects strength ordering.
|
||||
PcpNodeRef origin;
|
||||
|
||||
/// The value-mapping function used to map values from this arc's source
|
||||
/// node to its parent node.
|
||||
PcpMapExpression mapToParent;
|
||||
|
||||
// index among sibling arcs at origin; lower is stronger
|
||||
int siblingNumAtOrigin;
|
||||
|
||||
// Absolute depth in namespace of node that introduced this node.
|
||||
// Note that this does *not* count any variant selections.
|
||||
int namespaceDepth;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_ARC_H
|
||||
@@ -0,0 +1,733 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_CACHE_H
|
||||
#define PXR_USD_PCP_CACHE_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/dependency.h"
|
||||
#include "pxr/usd/pcp/errors.h"
|
||||
#include "pxr/usd/pcp/mapFunction.h"
|
||||
#include "pxr/usd/pcp/primIndex.h"
|
||||
#include "pxr/usd/pcp/propertyIndex.h"
|
||||
#include "pxr/usd/sdf/declareHandles.h"
|
||||
#include "pxr/usd/sdf/path.h"
|
||||
#include "pxr/usd/sdf/pathTable.h"
|
||||
|
||||
#include "pxr/usd/ar/ar.h"
|
||||
#include "pxr/usd/ar/resolverContext.h"
|
||||
#include "pxr/base/tf/declarePtrs.h"
|
||||
#include "pxr/base/tf/hashset.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
// Forward declarations:
|
||||
class PcpChanges;
|
||||
class PcpCacheChanges;
|
||||
class Pcp_Dependencies;
|
||||
class PcpLayerStackIdentifier;
|
||||
class PcpLifeboat;
|
||||
class PcpNodeRef;
|
||||
class PcpMapFunction;
|
||||
|
||||
TF_DECLARE_WEAK_AND_REF_PTRS(PcpLayerStack);
|
||||
TF_DECLARE_WEAK_AND_REF_PTRS(Pcp_LayerStackRegistry);
|
||||
SDF_DECLARE_HANDLES(SdfSpec);
|
||||
|
||||
/// \class PcpCache
|
||||
///
|
||||
/// PcpCache is the context required to make requests of the Pcp
|
||||
/// composition algorithm and cache the results.
|
||||
///
|
||||
/// Because the algorithms are recursive -- making a request typically
|
||||
/// makes other internal requests to solve subproblems -- caching
|
||||
/// subproblem results is required for reasonable performance, and
|
||||
/// so this cache is the only entrypoint to the algorithms.
|
||||
///
|
||||
/// There is a set of parameters that affect the composition results:
|
||||
///
|
||||
/// \li variant fallbacks: per named variant set, an ordered list of
|
||||
/// fallback values to use when composing a prim that defines
|
||||
/// a variant set but does not specify a selection
|
||||
/// \li payload inclusion set: an SdfPath set used to identify which
|
||||
/// prims should have their payloads included during composition;
|
||||
/// this is the basis for explicit control over the "working set"
|
||||
/// of composition
|
||||
/// \li file format target: the file format target that Pcp will request
|
||||
/// when opening scene description layers
|
||||
/// \li "USD mode" configures the Pcp composition algorithm to provide
|
||||
/// only a custom, lighter subset of the full feature set, as needed
|
||||
/// by the Universal Scene Description system
|
||||
///
|
||||
/// There are a number of different computations that can be requested.
|
||||
/// These include computing a layer stack from a PcpLayerStackIdentifier,
|
||||
/// computing a prim index or prim stack, and computing a property index.
|
||||
///
|
||||
class PcpCache
|
||||
{
|
||||
PcpCache(PcpCache const &) = delete;
|
||||
PcpCache &operator=(PcpCache const &) = delete;
|
||||
public:
|
||||
/// Construct a PcpCache to compose results for the layer stack identified
|
||||
/// by \a layerStackIdentifier.
|
||||
///
|
||||
/// If \p fileFormatTarget is given, Pcp will specify \p fileFormatTarget
|
||||
/// as the file format target when searching for or opening a layer.
|
||||
///
|
||||
/// If \p usd is true, computation of prim indices and composition of prim
|
||||
/// child names are performed without relocates, inherits, permissions,
|
||||
/// symmetry, or payloads, and without populating the prim stack and
|
||||
/// gathering its dependencies.
|
||||
PCP_API
|
||||
PcpCache(const PcpLayerStackIdentifier & layerStackIdentifier,
|
||||
const std::string& fileFormatTarget = std::string(),
|
||||
bool usd = false);
|
||||
PCP_API ~PcpCache();
|
||||
|
||||
/// \name Parameters
|
||||
/// @{
|
||||
|
||||
/// Get the identifier of the layerStack used for composition.
|
||||
PCP_API
|
||||
const PcpLayerStackIdentifier& GetLayerStackIdentifier() const;
|
||||
|
||||
/// Get the layer stack for GetLayerStackIdentifier(). Note that
|
||||
/// this will neither compute the layer stack nor report errors.
|
||||
/// So if the layer stack has not been computed yet this will
|
||||
/// return \c NULL. Use ComputeLayerStack() if you need to
|
||||
/// compute the layer stack if it hasn't been computed already
|
||||
/// and/or get errors caused by computing the layer stack.
|
||||
PCP_API
|
||||
PcpLayerStackPtr GetLayerStack() const;
|
||||
|
||||
/// Return true if the cache is configured in Usd mode.
|
||||
PCP_API
|
||||
bool IsUsd() const;
|
||||
|
||||
/// Returns the file format target this cache is configured for.
|
||||
PCP_API
|
||||
const std::string& GetFileFormatTarget() const;
|
||||
|
||||
/// Get the list of fallbacks to attempt to use when evaluating
|
||||
/// variant sets that lack an authored selection.
|
||||
PCP_API
|
||||
PcpVariantFallbackMap GetVariantFallbacks() const;
|
||||
|
||||
/// Set the list of fallbacks to attempt to use when evaluating
|
||||
/// variant sets that lack an authored selection.
|
||||
///
|
||||
/// If \p changes is not \c NULL then it's adjusted to reflect the
|
||||
/// changes necessary to see the change in standin preferences,
|
||||
/// otherwise those changes are applied immediately.
|
||||
PCP_API
|
||||
void SetVariantFallbacks( const PcpVariantFallbackMap & map,
|
||||
PcpChanges* changes = NULL );
|
||||
|
||||
/// Return true if the payload is included for the given path.
|
||||
PCP_API
|
||||
bool IsPayloadIncluded(const SdfPath &path) const;
|
||||
|
||||
/// Returns the payloads requested for inclusion.
|
||||
using PayloadSet = std::unordered_set<SdfPath, SdfPath::Hash>;
|
||||
PCP_API
|
||||
PayloadSet const &GetIncludedPayloads() const;
|
||||
|
||||
/// Request payloads to be included or excluded from composition.
|
||||
/// \param pathsToInclude is a set of paths to add to the set for
|
||||
/// payload inclusion.
|
||||
/// \param pathsToExclude is a set of paths to remove from the set for
|
||||
/// payload inclusion.
|
||||
/// \param changes if not \c NULL, is adjusted to reflect the changes
|
||||
/// necessary to see the change in payloads; otherwise those
|
||||
/// changes are applied immediately.
|
||||
/// \note If a path is listed in both pathsToInclude and pathsToExclude,
|
||||
/// it will be treated as an inclusion only.
|
||||
///
|
||||
PCP_API
|
||||
void RequestPayloads( const SdfPathSet & pathsToInclude,
|
||||
const SdfPathSet & pathsToExclude,
|
||||
PcpChanges* changes = NULL );
|
||||
|
||||
/// Request layers to be muted or unmuted in this cache. Muted layers
|
||||
/// are ignored during composition and do not appear in any layer
|
||||
/// stacks. The root layer of this stage may not be muted; attempting
|
||||
/// to do so will generate a coding error. If the root layer of a
|
||||
/// reference or payload layer stack is muted, the behavior is as if
|
||||
/// the muted layer did not exist, which means a composition error will
|
||||
/// be generated.
|
||||
///
|
||||
#if AR_VERSION == 1
|
||||
/// A canonical identifier for each layer in \p layersToMute will be
|
||||
/// computed using ArResolver::ComputeRepositoryPath. Any layer
|
||||
/// encountered during composition with the same repository path will
|
||||
/// be considered muted and ignored. Relative paths will be assumed to
|
||||
/// be relative to the cache's root layer. Search paths are immediately
|
||||
/// resolved and the result is used for computing the canonical path.
|
||||
#else
|
||||
/// A canonical identifier for each layer in \p layersToMute will be
|
||||
/// computed using ArResolver::CreateIdentifier using the cache's root
|
||||
/// layer as the anchoring asset. Any layer encountered during composition
|
||||
/// with the same identifier will be considered muted and ignored.
|
||||
#endif
|
||||
///
|
||||
/// Note that muting a layer will cause this cache to release all
|
||||
/// references to that layer. If no other client is holding on to
|
||||
/// references to that layer, it will be unloaded. In this case, if
|
||||
/// there are unsaved edits to the muted layer, those edits are lost.
|
||||
/// Since anonymous layers are not serialized, muting an anonymous
|
||||
/// layer will cause that layer and its contents to be lost in this
|
||||
/// case.
|
||||
///
|
||||
/// If \p changes is not \c nullptr, it is adjusted to reflect the
|
||||
/// changes necessary to see the change in muted layers. Otherwise,
|
||||
/// those changes are applied immediately.
|
||||
///
|
||||
/// \p newLayersMuted and \p newLayersUnmuted contains the pruned vector
|
||||
/// of layers which are muted or unmuted by this call to RequestLayerMuting.
|
||||
///
|
||||
PCP_API
|
||||
void RequestLayerMuting(const std::vector<std::string>& layersToMute,
|
||||
const std::vector<std::string>& layersToUnmute,
|
||||
PcpChanges* changes = nullptr,
|
||||
std::vector<std::string>* newLayersMuted = nullptr,
|
||||
std::vector<std::string>* newLayersUnmuted =
|
||||
nullptr);
|
||||
|
||||
/// Returns the list of canonical identifiers for muted layers
|
||||
/// in this cache. See documentation on RequestLayerMuting for
|
||||
/// more details.
|
||||
PCP_API
|
||||
const std::vector<std::string>& GetMutedLayers() const;
|
||||
|
||||
/// Returns true if the layer specified by \p layerIdentifier is
|
||||
/// muted in this cache, false otherwise. If \p layerIdentifier
|
||||
/// is relative, it is assumed to be relative to this cache's
|
||||
/// root layer. See documentation on RequestLayerMuting for
|
||||
/// more details.
|
||||
PCP_API
|
||||
bool IsLayerMuted(const std::string& layerIdentifier) const;
|
||||
|
||||
/// Returns true if the layer specified by \p layerIdentifier is
|
||||
/// muted in this cache, false otherwise. If \p layerIdentifier
|
||||
/// is relative, it is assumed to be relative to \p anchorLayer.
|
||||
/// If \p canonicalMutedLayerIdentifier is supplied, it will be
|
||||
/// populated with the canonical identifier of the muted layer if this
|
||||
/// function returns true. See documentation on RequestLayerMuting
|
||||
/// for more details.
|
||||
PCP_API
|
||||
bool IsLayerMuted(const SdfLayerHandle& anchorLayer,
|
||||
const std::string& layerIdentifier,
|
||||
std::string* canonicalMutedLayerIdentifier
|
||||
= nullptr) const;
|
||||
|
||||
/// Returns parameter object containing all inputs for the prim index
|
||||
/// computation used by this cache.
|
||||
PCP_API
|
||||
PcpPrimIndexInputs GetPrimIndexInputs();
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Computations
|
||||
/// @{
|
||||
|
||||
/// Returns the layer stack for \p identifier if it exists, otherwise
|
||||
/// creates a new layer stack for \p identifier. This returns \c NULL
|
||||
/// if \p identifier is invalid (i.e. its root layer is \c NULL).
|
||||
/// \p allErrors will contain any errors encountered while creating a
|
||||
/// new layer stack. It'll be unchanged if the layer stack already existed.
|
||||
PCP_API
|
||||
PcpLayerStackRefPtr
|
||||
ComputeLayerStack(const PcpLayerStackIdentifier &identifier,
|
||||
PcpErrorVector *allErrors);
|
||||
|
||||
/// Returns the layer stack for \p identifier if it has been computed
|
||||
/// and cached, otherwise returns \c NULL.
|
||||
PCP_API
|
||||
PcpLayerStackPtr
|
||||
FindLayerStack(const PcpLayerStackIdentifier &identifier) const;
|
||||
|
||||
/// Compute and return a reference to the cached result for the
|
||||
/// prim index for the given path. \p allErrors will contain any errors
|
||||
/// encountered while performing this operation.
|
||||
PCP_API
|
||||
const PcpPrimIndex &
|
||||
ComputePrimIndex(const SdfPath &primPath, PcpErrorVector *allErrors);
|
||||
|
||||
/// Compute PcpPrimIndexes in the subtree rooted at path in parallel,
|
||||
/// recursing to children based on the supplied \p childrenPred. Also
|
||||
/// include payloads not already in this cache's included payloads (see
|
||||
/// GetIncludedPayloads()) according to \p payloadPred.
|
||||
///
|
||||
/// This is similar to ComputePrimIndex(), except it computes an entire
|
||||
/// subtree of indexes in parallel so it can be much more efficient. This
|
||||
/// function invokes both \p childrenPred and \p payloadPred concurrently,
|
||||
/// so it must be safe to do so.
|
||||
///
|
||||
/// When a PcpPrimIndex computation completes invoke \p childrenPred,
|
||||
/// passing it the PcpPrimIndex. If \p childrenPred returns true, continue
|
||||
/// indexing children prim indexes. In this case, \p childrenPred may
|
||||
/// provide a list of names of the children prim indexes to compute.
|
||||
/// If it does not, all children prim indexes will be computed.
|
||||
/// If \p childrenPred returns false, stop indexing in that subtree.
|
||||
///
|
||||
/// If payloads discovered during indexing do not already appear in this
|
||||
/// cache's set of included payloads, invoke \p payloadPred, passing it the
|
||||
/// path for the prim with the payload. If \p payloadPred returns true,
|
||||
/// include its payload and add it to the cache's set of included payloads
|
||||
/// upon completion.
|
||||
template <class ChildrenPredicate, class PayloadPredicate>
|
||||
void ComputePrimIndexesInParallel(const SdfPath &path,
|
||||
PcpErrorVector *allErrors,
|
||||
const ChildrenPredicate &childrenPred,
|
||||
const PayloadPredicate &payloadPred) {
|
||||
ComputePrimIndexesInParallel(SdfPathVector(1, path), allErrors,
|
||||
childrenPred, payloadPred,
|
||||
"Pcp", "ComputePrimIndexesInParallel");
|
||||
}
|
||||
|
||||
/// \overload
|
||||
/// XXX Do not add new callers of this method. It is needed as a workaround
|
||||
/// for bug #132031, which we hope to tackle soon (as of 6/2016)
|
||||
template <class ChildrenPredicate, class PayloadPredicate>
|
||||
void ComputePrimIndexesInParallel(const SdfPath &path,
|
||||
PcpErrorVector *allErrors,
|
||||
const ChildrenPredicate &childrenPred,
|
||||
const PayloadPredicate &payloadPred,
|
||||
const char *mallocTag1,
|
||||
const char *mallocTag2) {
|
||||
ComputePrimIndexesInParallel(SdfPathVector(1, path), allErrors,
|
||||
childrenPred, payloadPred,
|
||||
mallocTag1, mallocTag2);
|
||||
}
|
||||
|
||||
/// Vectorized form of ComputePrimIndexesInParallel(). Equivalent to
|
||||
/// invoking that method for each path in \p paths, but more efficient.
|
||||
template <class ChildrenPredicate, class PayloadPredicate>
|
||||
void ComputePrimIndexesInParallel(const SdfPathVector &paths,
|
||||
PcpErrorVector *allErrors,
|
||||
const ChildrenPredicate &childrenPred,
|
||||
const PayloadPredicate &payloadPred) {
|
||||
_UntypedIndexingChildrenPredicate cp(&childrenPred);
|
||||
_UntypedIndexingPayloadPredicate pp(&payloadPred);
|
||||
_ComputePrimIndexesInParallel(paths, allErrors, cp, pp,
|
||||
"Pcp", "ComputePrimIndexesInParallel");
|
||||
}
|
||||
|
||||
/// \overload
|
||||
/// XXX Do not add new callers of this method. It is needed as a workaround
|
||||
/// for bug #132031, which we hope to tackle soon (as of 6/2016)
|
||||
template <class ChildrenPredicate, class PayloadPredicate>
|
||||
void ComputePrimIndexesInParallel(const SdfPathVector &paths,
|
||||
PcpErrorVector *allErrors,
|
||||
const ChildrenPredicate &childrenPred,
|
||||
const PayloadPredicate &payloadPred,
|
||||
const char *mallocTag1,
|
||||
const char *mallocTag2) {
|
||||
_UntypedIndexingChildrenPredicate cp(&childrenPred);
|
||||
_UntypedIndexingPayloadPredicate pp(&payloadPred);
|
||||
_ComputePrimIndexesInParallel(paths, allErrors, cp, pp,
|
||||
mallocTag1, mallocTag2);
|
||||
}
|
||||
|
||||
/// Returns a pointer to the cached computed prim index for the given
|
||||
/// path, or NULL if it has not been computed.
|
||||
PCP_API
|
||||
const PcpPrimIndex *
|
||||
FindPrimIndex(const SdfPath &primPath) const;
|
||||
|
||||
/// Compute and return a reference to the cached result for the
|
||||
/// property index for the given path. \p allErrors will contain any
|
||||
/// errors encountered while performing this operation.
|
||||
PCP_API
|
||||
const PcpPropertyIndex &
|
||||
ComputePropertyIndex(const SdfPath &propPath, PcpErrorVector *allErrors);
|
||||
|
||||
/// Returns a pointer to the cached computed property index for the given
|
||||
/// path, or NULL if it has not been computed.
|
||||
PCP_API
|
||||
const PcpPropertyIndex *
|
||||
FindPropertyIndex(const SdfPath &propPath) const;
|
||||
|
||||
/// Compute the relationship target paths for the relationship at
|
||||
/// \p relationshipPath into \p paths. If \p localOnly is \c true then
|
||||
/// this will compose relationship targets from local nodes only. If
|
||||
/// \p stopProperty is not \c NULL then this will stop composing
|
||||
/// relationship targets at \p stopProperty, including \p stopProperty
|
||||
/// iff \p includeStopProperty is \c true. If not \c NULL, \p deletedPaths
|
||||
/// will be populated with target paths whose deletion contributed to
|
||||
/// the computed result. \p allErrors will contain any errors encountered
|
||||
/// while performing this operation.
|
||||
PCP_API
|
||||
void
|
||||
ComputeRelationshipTargetPaths(const SdfPath &relationshipPath,
|
||||
SdfPathVector *paths,
|
||||
bool localOnly,
|
||||
const SdfSpecHandle &stopProperty,
|
||||
bool includeStopProperty,
|
||||
SdfPathVector *deletedPaths,
|
||||
PcpErrorVector *allErrors);
|
||||
|
||||
/// Compute the attribute connection paths for the attribute at
|
||||
/// \p attributePath into \p paths. If \p localOnly is \c true then
|
||||
/// this will compose attribute connections from local nodes only. If
|
||||
/// \p stopProperty is not \c NULL then this will stop composing
|
||||
/// attribute connections at \p stopProperty, including \p stopProperty
|
||||
/// iff \p includeStopProperty is \c true. If not \c NULL, \p deletedPaths
|
||||
/// will be populated with connection paths whose deletion contributed to
|
||||
/// the computed result. \p allErrors will contain any errors encountered
|
||||
/// while performing this operation.
|
||||
PCP_API
|
||||
void
|
||||
ComputeAttributeConnectionPaths(const SdfPath &attributePath,
|
||||
SdfPathVector *paths,
|
||||
bool localOnly,
|
||||
const SdfSpecHandle &stopProperty,
|
||||
bool includeStopProperty,
|
||||
SdfPathVector *deletedPaths,
|
||||
PcpErrorVector *allErrors);
|
||||
|
||||
/// @}
|
||||
/// \name Dependencies
|
||||
/// @{
|
||||
|
||||
/// Returns set of all layers used by this cache.
|
||||
PCP_API
|
||||
SdfLayerHandleSet GetUsedLayers() const;
|
||||
|
||||
/// Returns set of all root layers used by this cache.
|
||||
PCP_API
|
||||
SdfLayerHandleSet GetUsedRootLayers() const;
|
||||
|
||||
/// Returns every computed & cached layer stack that includes \p layer.
|
||||
PCP_API
|
||||
const PcpLayerStackPtrVector&
|
||||
FindAllLayerStacksUsingLayer(const SdfLayerHandle& layer) const;
|
||||
|
||||
/// Returns dependencies on the given site of scene description,
|
||||
/// as discovered by the cached index computations.
|
||||
///
|
||||
/// \param depMask specifies what classes of dependency to include;
|
||||
/// see PcpDependencyFlags for details
|
||||
/// \param recurseOnSite includes incoming dependencies on
|
||||
/// children of sitePath
|
||||
/// \param recurseOnIndex extends the result to include all PcpCache
|
||||
/// child indexes below discovered results
|
||||
/// \param filterForExistingCachesOnly filters the results to only
|
||||
/// paths representing computed prim and property index caches;
|
||||
/// otherwise a recursively-expanded result can include
|
||||
/// un-computed paths that are expected to depend on the site
|
||||
PCP_API
|
||||
PcpDependencyVector
|
||||
FindSiteDependencies(const PcpLayerStackPtr& siteLayerStack,
|
||||
const SdfPath& sitePath,
|
||||
PcpDependencyFlags depMask,
|
||||
bool recurseOnSite,
|
||||
bool recurseOnIndex,
|
||||
bool filterForExistingCachesOnly) const;
|
||||
|
||||
/// Returns dependencies on the given site of scene description,
|
||||
/// as discovered by the cached index computations.
|
||||
///
|
||||
/// This method overload takes a site layer rather than a layer
|
||||
/// stack. It will check every layer stack using that layer, and
|
||||
/// apply any relevant sublayer offsets to the map functions in the
|
||||
/// returned PcpDependencyVector.
|
||||
///
|
||||
/// See the other method for parameter details.
|
||||
PCP_API
|
||||
PcpDependencyVector
|
||||
FindSiteDependencies(const SdfLayerHandle& siteLayer,
|
||||
const SdfPath& sitePath,
|
||||
PcpDependencyFlags depMask,
|
||||
bool recurseOnSite,
|
||||
bool recurseOnIndex,
|
||||
bool filterForExistingCachesOnly) const;
|
||||
|
||||
/// Returns \c true if an opinion for the site at \p localPcpSitePath
|
||||
/// in the cache's layer stack can be provided by an opinion in \p layer,
|
||||
/// \c false otherwise. If \c true and \p allowedPathInLayer is not
|
||||
/// \c NULL then it's set to a path in \p layer that would provide an
|
||||
/// opinion.
|
||||
///
|
||||
/// This returns \c false if no prim index has yet been computed for
|
||||
/// \p localPcpSitePath.
|
||||
PCP_API
|
||||
bool CanHaveOpinionForSite(const SdfPath& localPcpSitePath,
|
||||
const SdfLayerHandle& layer,
|
||||
SdfPath* allowedPathInLayer) const;
|
||||
|
||||
/// Returns a vector of sublayer asset paths used in the layer stack
|
||||
/// that didn't resolve to valid assets.
|
||||
PCP_API
|
||||
std::vector<std::string> GetInvalidSublayerIdentifiers() const;
|
||||
|
||||
/// Returns true if \p identifier was used as a sublayer path in a
|
||||
/// layer stack but did not identify a valid layer. This is functionally
|
||||
/// equivalent to examining the values in the vector returned by
|
||||
/// GetInvalidSublayerIdentifiers, but more efficient.
|
||||
PCP_API
|
||||
bool IsInvalidSublayerIdentifier(const std::string& identifier) const;
|
||||
|
||||
/// Returns a map of prim paths to asset paths used by that prim
|
||||
/// (e.g. in a reference) that didn't resolve to valid assets.
|
||||
PCP_API
|
||||
std::map<SdfPath, std::vector<std::string>, SdfPath::FastLessThan>
|
||||
GetInvalidAssetPaths() const;
|
||||
|
||||
/// Returns true if \p resolvedAssetPath was used by a prim (e.g. in
|
||||
/// a reference) but did not resolve to a valid asset. This is
|
||||
/// functionally equivalent to examining the values in the map returned
|
||||
/// by GetInvalidAssetPaths, but more efficient.
|
||||
PCP_API
|
||||
bool IsInvalidAssetPath(const std::string& resolvedAssetPath) const;
|
||||
|
||||
/// Returns true if any prim index in this cache has a dependency on a
|
||||
/// dynamic file format argument field.
|
||||
PCP_API
|
||||
bool HasAnyDynamicFileFormatArgumentDependencies() const;
|
||||
|
||||
/// Returns true if the given \p field is the name of a field that
|
||||
/// was composed while generating dynamic file format arguments for any prim
|
||||
/// index in this cache.
|
||||
PCP_API
|
||||
bool IsPossibleDynamicFileFormatArgumentField(const TfToken &field) const;
|
||||
|
||||
/// Returns the dynamic file format dependency data object for the prim
|
||||
/// index with the given \p primIndexPath. This will return an empty
|
||||
/// dependency data if either there is no cache prim index for the path or
|
||||
/// if the prim index has no dynamic file formats that it depends on.
|
||||
PCP_API
|
||||
const PcpDynamicFileFormatDependencyData &
|
||||
GetDynamicFileFormatArgumentDependencyData(
|
||||
const SdfPath &primIndexPath) const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Change handling
|
||||
/// @{
|
||||
|
||||
/// Apply the changes in \p changes. This blows caches. It's up to
|
||||
/// the client to pull on those caches again as needed.
|
||||
///
|
||||
/// Objects that are no longer needed and would be destroyed are
|
||||
/// retained in \p lifeboat and won't be destroyed until \p lifeboat is
|
||||
/// itself destroyed. This gives the client control over the timing
|
||||
/// of the destruction of those objects. Clients may choose to pull
|
||||
/// on the caches before destroying \p lifeboat. That may cause the
|
||||
/// caches to again retain the objects, meaning they won't be destroyed
|
||||
/// when \p lifeboat is destroyed.
|
||||
///
|
||||
/// For example, if blowing a cache means an SdfLayer is no longer
|
||||
/// needed then \p lifeboat will hold an SdfLayerRefPtr to that layer.
|
||||
/// The client can then pull on that cache, which could cause the
|
||||
/// cache to hold an SdfLayerRefPtr to the layer again. If so then
|
||||
/// destroying \p changes will not destroy the layer. In any case,
|
||||
/// we don't destroy the layer and then read it again. However, if
|
||||
/// the client destroys \p lifeboat before pulling on the cache then
|
||||
/// we would destroy the layer then read it again.
|
||||
PCP_API
|
||||
void Apply(const PcpCacheChanges& changes, PcpLifeboat* lifeboat);
|
||||
|
||||
/// Reload the layers of the layer stack, except session layers
|
||||
/// and sublayers of session layers. This will also try to load
|
||||
/// sublayers in this cache's layer stack that could not be loaded
|
||||
/// previously. It will also try to load any referenced or payloaded
|
||||
/// layer that could not be loaded previously. Clients should
|
||||
/// subsequently \c Apply() \p changes to use any now-valid layers.
|
||||
PCP_API
|
||||
void Reload(PcpChanges* changes);
|
||||
|
||||
/// Reload every layer used by the prim at \p primPath that's across
|
||||
/// a reference or payload. Clients should subsequently apply the
|
||||
/// changes to use any now valid layers.
|
||||
///
|
||||
/// Note: If a reference or payload was to an invalid asset and this
|
||||
/// asset is valid upon reloading then this call will not necessarily
|
||||
/// reload every layer accessible across the reference or payload.
|
||||
/// For example, say prim R has an invalid reference and prim Q has a
|
||||
/// valid reference to layer X with sublayer Y. If on reload R now
|
||||
/// has a valid reference to layer Z with sublayer Y, we will load Z
|
||||
/// but we will not reload Y.
|
||||
PCP_API
|
||||
void ReloadReferences(PcpChanges* changes, const SdfPath& primPath);
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Diagnostics
|
||||
/// @{
|
||||
|
||||
/// Prints various statistics about the data stored in this cache.
|
||||
PCP_API
|
||||
void PrintStatistics() const;
|
||||
|
||||
/// @}
|
||||
|
||||
private:
|
||||
friend class PcpChanges;
|
||||
friend class Pcp_Statistics;
|
||||
|
||||
struct _ParallelIndexer;
|
||||
|
||||
// Helper struct to type-erase a children predicate for the duration of
|
||||
// ComputePrimIndexesInParallel.
|
||||
//
|
||||
// This lets us achieve two goals. First, clients may pass any arbitrary
|
||||
// type as a predicate (e.g. they do not have to derive some base class).
|
||||
// Second, it lets us keep the parallel indexing implementation in the .cpp
|
||||
// file, avoiding any large template code instantiation.
|
||||
//
|
||||
// The cost we pay is this very thin indirect call. We instantiate a
|
||||
// function template with the client's predicate type that simply does a
|
||||
// typecast and predicate invocation, and pass that function pointer into
|
||||
// the implementation. There is no heap allocation, no predicate copy, no
|
||||
// argument marshalling, etc.
|
||||
struct _UntypedIndexingChildrenPredicate {
|
||||
_UntypedIndexingChildrenPredicate() : pred(nullptr), invoke(nullptr) {}
|
||||
template <class Pred>
|
||||
explicit _UntypedIndexingChildrenPredicate(const Pred *pred)
|
||||
: pred(pred), invoke(_Invoke<Pred>) {}
|
||||
|
||||
inline bool operator()(const PcpPrimIndex &index,
|
||||
TfTokenVector *childNamesToCompose) const {
|
||||
return invoke(pred, index, childNamesToCompose);
|
||||
}
|
||||
private:
|
||||
template <class Pred>
|
||||
static bool _Invoke(const void *pred, const PcpPrimIndex &index,
|
||||
TfTokenVector *namesToCompose) {
|
||||
return (*static_cast<const Pred *>(pred))(index, namesToCompose);
|
||||
}
|
||||
const void *pred;
|
||||
bool (*invoke)(const void *, const PcpPrimIndex &, TfTokenVector *);
|
||||
};
|
||||
|
||||
// See doc for _UntypedIndexingChildrenPredicate above. This does the same
|
||||
// for the payload inclusion predicate.
|
||||
struct _UntypedIndexingPayloadPredicate {
|
||||
template <class Pred>
|
||||
explicit _UntypedIndexingPayloadPredicate(const Pred *pred)
|
||||
: pred(pred), invoke(_Invoke<Pred>) {}
|
||||
|
||||
inline bool operator()(const SdfPath &path) const {
|
||||
return invoke(pred, path);
|
||||
}
|
||||
private:
|
||||
template <class Pred>
|
||||
static bool _Invoke(const void *pred, const SdfPath &path) {
|
||||
return (*static_cast<const Pred *>(pred))(path);
|
||||
}
|
||||
const void *pred;
|
||||
bool (*invoke)(const void *, const SdfPath &);
|
||||
};
|
||||
|
||||
// Internal helper for recursive indexing.
|
||||
const PcpPrimIndex &
|
||||
_ComputePrimIndexWithCompatibleInputs(
|
||||
const SdfPath & path, const PcpPrimIndexInputs &inputs,
|
||||
PcpErrorVector *allErrors);
|
||||
|
||||
// Friend to allow low-level indexing code access to the above.
|
||||
friend const PcpPrimIndex &
|
||||
Pcp_ComputePrimIndexWithCompatibleInputs(
|
||||
PcpCache &cache,
|
||||
const SdfPath & path, const PcpPrimIndexInputs &inputs,
|
||||
PcpErrorVector *allErrors);
|
||||
|
||||
// Parallel indexing implementation.
|
||||
PCP_API
|
||||
void _ComputePrimIndexesInParallel(
|
||||
const SdfPathVector &paths,
|
||||
PcpErrorVector *allErrors,
|
||||
_UntypedIndexingChildrenPredicate childrenPred,
|
||||
_UntypedIndexingPayloadPredicate payloadPred,
|
||||
const char *mallocTag1,
|
||||
const char *mallocTag2);
|
||||
|
||||
void _RemovePrimCache(const SdfPath& primPath, PcpLifeboat* lifeboat);
|
||||
void _RemovePrimAndPropertyCaches(const SdfPath& root,
|
||||
PcpLifeboat* lifeboat);
|
||||
void _RemovePropertyCache(const SdfPath& root, PcpLifeboat* lifeboat);
|
||||
void _RemovePropertyCaches(const SdfPath& root, PcpLifeboat* lifeboat);
|
||||
|
||||
// Returns the prim index for \p path if it exists, NULL otherwise.
|
||||
PcpPrimIndex* _GetPrimIndex(const SdfPath& path);
|
||||
const PcpPrimIndex* _GetPrimIndex(const SdfPath& path) const;
|
||||
|
||||
// Returns the property index for \p path if it exists, NULL otherwise.
|
||||
PcpPropertyIndex* _GetPropertyIndex(const SdfPath& path);
|
||||
const PcpPropertyIndex* _GetPropertyIndex(const SdfPath& path) const;
|
||||
|
||||
private:
|
||||
// Fixed evaluation parameters, set when the cache is created. Note that
|
||||
// _rootLayer and _sessionLayer are not const because we want to mutate them
|
||||
// to enable parallel teardown in the destructor.
|
||||
SdfLayerRefPtr _rootLayer;
|
||||
SdfLayerRefPtr _sessionLayer;
|
||||
const PcpLayerStackIdentifier _layerStackIdentifier;
|
||||
|
||||
// Flag that configures PcpCache to use the restricted set of USD features.
|
||||
// Currently it governs whether relocates, inherits, permissions,
|
||||
// symmetry, or payloads are considered, and whether the prim stack
|
||||
// is populated and its depdencies gathered during computation of
|
||||
// prim indices and composition of prim child names.
|
||||
const bool _usd;
|
||||
|
||||
// File format target for all scene description layers this cache will
|
||||
// find or open during prim index computation.
|
||||
const std::string _fileFormatTarget;
|
||||
|
||||
// The layer stack for this cache. Holding this by ref ptr means we
|
||||
// hold all of our local layers by ref ptr (including the root and
|
||||
// session layers, again).
|
||||
PcpLayerStackRefPtr _layerStack;
|
||||
|
||||
// Modifiable evaluation parameters.
|
||||
// Anything that changes these should also yield a PcpChanges
|
||||
// value describing the necessary cache invalidation.
|
||||
PayloadSet _includedPayloads;
|
||||
PcpVariantFallbackMap _variantFallbackMap;
|
||||
|
||||
// Cached computation types.
|
||||
typedef Pcp_LayerStackRegistryRefPtr _LayerStackCache;
|
||||
typedef SdfPathTable<PcpPrimIndex> _PrimIndexCache;
|
||||
typedef SdfPathTable<PcpPropertyIndex> _PropertyIndexCache;
|
||||
|
||||
// Cached computations.
|
||||
_LayerStackCache _layerStackCache;
|
||||
_PrimIndexCache _primIndexCache;
|
||||
_PropertyIndexCache _propertyIndexCache;
|
||||
std::unique_ptr<Pcp_Dependencies> _primDependencies;
|
||||
|
||||
// Parallel indexer state.
|
||||
std::unique_ptr<_ParallelIndexer> _parallelIndexer;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_CACHE_H
|
||||
@@ -0,0 +1,406 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_CHANGES_H
|
||||
#define PXR_USD_PCP_CHANGES_H
|
||||
|
||||
/// \file pcp/changes.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/sdf/changeList.h"
|
||||
#include "pxr/usd/sdf/declareHandles.h"
|
||||
#include "pxr/usd/sdf/path.h"
|
||||
#include "pxr/usd/sdf/types.h"
|
||||
#include "pxr/base/tf/declarePtrs.h"
|
||||
#include "pxr/base/tf/span.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
SDF_DECLARE_HANDLES(SdfLayer);
|
||||
TF_DECLARE_WEAK_AND_REF_PTRS(PcpLayerStack);
|
||||
|
||||
class PcpCache;
|
||||
class PcpSite;
|
||||
|
||||
/// \class PcpLayerStackChanges
|
||||
///
|
||||
/// Types of changes per layer stack.
|
||||
///
|
||||
class PcpLayerStackChanges {
|
||||
public:
|
||||
/// Must rebuild the layer tree. Implies didChangeLayerOffsets.
|
||||
bool didChangeLayers;
|
||||
|
||||
/// Must rebuild the layer offsets.
|
||||
bool didChangeLayerOffsets;
|
||||
|
||||
/// Must rebuild the relocation tables.
|
||||
bool didChangeRelocates;
|
||||
|
||||
/// A significant layer stack change means the composed opinions of
|
||||
/// the layer stack may have changed in arbitrary ways. This
|
||||
/// represents a coarse invalidation. By way of contrast, an example
|
||||
/// of an insignificant change is adding or removing a layer empty
|
||||
/// of opinions.
|
||||
bool didChangeSignificantly;
|
||||
|
||||
/// New relocation maps for this layer stack.
|
||||
/// If didChangeRelocates is true, these fields will be populated
|
||||
/// as part of determining the changes to this layer stack.
|
||||
/// However, we do not immediately apply those changes to the
|
||||
/// layer stack; we store them here and commit them in Apply().
|
||||
SdfRelocatesMap newRelocatesTargetToSource;
|
||||
SdfRelocatesMap newRelocatesSourceToTarget;
|
||||
SdfRelocatesMap newIncrementalRelocatesSourceToTarget;
|
||||
SdfRelocatesMap newIncrementalRelocatesTargetToSource;
|
||||
SdfPathVector newRelocatesPrimPaths;
|
||||
|
||||
/// Paths that are affected by the above relocation changes.
|
||||
SdfPathSet pathsAffectedByRelocationChanges;
|
||||
|
||||
PcpLayerStackChanges() :
|
||||
didChangeLayers(false),
|
||||
didChangeLayerOffsets(false),
|
||||
didChangeRelocates(false),
|
||||
didChangeSignificantly(false)
|
||||
{}
|
||||
};
|
||||
|
||||
/// \class PcpCacheChanges
|
||||
///
|
||||
/// Types of changes per cache.
|
||||
///
|
||||
class PcpCacheChanges {
|
||||
public:
|
||||
enum TargetType {
|
||||
TargetTypeConnection = 1 << 0,
|
||||
TargetTypeRelationshipTarget = 1 << 1
|
||||
};
|
||||
|
||||
/// Must rebuild the indexes at and below each path. This
|
||||
/// implies rebuilding the prim/property stacks at
|
||||
/// and below each path.
|
||||
SdfPathSet didChangeSignificantly;
|
||||
|
||||
/// Must rebuild the prim/property stacks at each path.
|
||||
SdfPathSet didChangeSpecs;
|
||||
|
||||
/// Must rebuild the prim indexes at each path. This implies rebuilding
|
||||
/// the prim stack at each path.
|
||||
SdfPathSet didChangePrims;
|
||||
|
||||
/// Must rebuild the connections/targets at each path.
|
||||
std::map<SdfPath, int, SdfPath::FastLessThan> didChangeTargets;
|
||||
|
||||
/// Must update the path on every namespace object at and below each
|
||||
/// given path. The first path is the old path to the object and the
|
||||
/// second path is the new path. The order of the vector matters and
|
||||
/// indicates the order in which the namespace edits occur.
|
||||
std::vector<std::pair<SdfPath, SdfPath>> didChangePath;
|
||||
|
||||
private:
|
||||
friend class PcpCache;
|
||||
friend class PcpChanges;
|
||||
|
||||
// Must rebuild the prim/property stacks at each path due to a change
|
||||
// that only affects the internal representation of the stack and
|
||||
// not its contents. Because this causes no externally-observable
|
||||
// changes in state, clients do not need to be aware of these changes.
|
||||
SdfPathSet _didChangeSpecsInternal;
|
||||
};
|
||||
|
||||
/// Structure used to temporarily retain layers and layerStacks within
|
||||
/// a code block. Analogous to the autorelease pool in obj-c.
|
||||
class PcpLifeboat {
|
||||
public:
|
||||
PcpLifeboat();
|
||||
~PcpLifeboat();
|
||||
|
||||
/// Ensure that \p layer exists until this object is destroyed.
|
||||
void Retain(const SdfLayerRefPtr& layer);
|
||||
|
||||
/// Ensure that \p layerStack exists until this object is destroyed.
|
||||
void Retain(const PcpLayerStackRefPtr& layerStack);
|
||||
|
||||
/// Returns reference to the set of layer stacks currently being held
|
||||
/// in the lifeboat.
|
||||
const std::set<PcpLayerStackRefPtr>& GetLayerStacks() const;
|
||||
|
||||
/// Swap the contents of this and \p other.
|
||||
void Swap(PcpLifeboat& other);
|
||||
|
||||
private:
|
||||
std::set<SdfLayerRefPtr> _layers;
|
||||
std::set<PcpLayerStackRefPtr> _layerStacks;
|
||||
};
|
||||
|
||||
/// \class PcpChanges
|
||||
///
|
||||
/// Describes Pcp changes.
|
||||
///
|
||||
/// Collects changes to Pcp necessary to reflect changes in Sd. It does
|
||||
/// not cause any changes to any Pcp caches, layer stacks, etc; it only
|
||||
/// computes what changes would be necessary to Pcp to reflect the Sd
|
||||
/// changes.
|
||||
///
|
||||
class PcpChanges {
|
||||
public:
|
||||
PCP_API PcpChanges();
|
||||
PCP_API ~PcpChanges();
|
||||
|
||||
/// Breaks down \p changes into individual changes on the caches in
|
||||
/// \p caches. This simply translates data in \p changes into other
|
||||
/// Did...() calls on this object.
|
||||
///
|
||||
/// Clients will typically call this method once then call \c Apply() or
|
||||
/// get the changes using \c GetLayerStackChanges() and
|
||||
/// \c GetCacheChanges().
|
||||
PCP_API
|
||||
void DidChange(const TfSpan<const PcpCache*> &caches,
|
||||
const SdfLayerChangeListVec& changes);
|
||||
|
||||
/// Tries to load the sublayer of \p layer at \p sublayerPath. If
|
||||
/// successful, any layer stack using \p layer is marked as having changed
|
||||
/// and all prims in \p cache using any prim in any of those layer stacks
|
||||
/// are marked as changed.
|
||||
PCP_API
|
||||
void DidMaybeFixSublayer(const PcpCache* cache,
|
||||
const SdfLayerHandle& layer,
|
||||
const std::string& assetPath);
|
||||
|
||||
/// Tries to load the asset at \p assetPath. If successful, any prim
|
||||
/// in \p cache using the site \p site is marked as changed.
|
||||
PCP_API
|
||||
void DidMaybeFixAsset(const PcpCache* cache,
|
||||
const PcpSite& site,
|
||||
const SdfLayerHandle& srcLayer,
|
||||
const std::string& assetPath);
|
||||
|
||||
/// The layer identified by \p layerId was muted in \p cache.
|
||||
PCP_API
|
||||
void DidMuteLayer(const PcpCache* cache, const std::string& layerId);
|
||||
|
||||
/// The layer identified by \p layerId was unmuted in \p cache.
|
||||
PCP_API
|
||||
void DidUnmuteLayer(const PcpCache* cache, const std::string& layerId);
|
||||
|
||||
/// The sublayer tree changed. This often, but doesn't always, imply that
|
||||
/// anything and everything may have changed. If clients want to indicate
|
||||
/// that anything and everything may have changed they should call this
|
||||
/// method and \c DidChangePrimGraph() with the absolute root path.
|
||||
PCP_API
|
||||
void DidChangeLayers(const PcpCache* cache);
|
||||
|
||||
/// The sublayer offsets changed.
|
||||
PCP_API
|
||||
void DidChangeLayerOffsets(const PcpCache* cache);
|
||||
|
||||
/// The object at \p path changed significantly enough to require
|
||||
/// recomputing the entire prim or property index. A significant change
|
||||
/// implies changes to every namespace descendant's index, specs, and
|
||||
/// dependencies.
|
||||
PCP_API
|
||||
void DidChangeSignificantly(const PcpCache* cache, const SdfPath& path);
|
||||
|
||||
/// The spec stack for the prim or property has changed, due to the
|
||||
/// addition or removal of the spec in \p changedLayer at \p changedPath.
|
||||
/// This is used when inert prims/properties are added or removed or when
|
||||
/// any change requires rebuilding the property stack. It implies that
|
||||
/// dependencies on those specs has changed.
|
||||
PCP_API
|
||||
void DidChangeSpecs(const PcpCache* cache, const SdfPath& path,
|
||||
const SdfLayerHandle& changedLayer,
|
||||
const SdfPath& changedPath);
|
||||
|
||||
/// The spec stack for the prim or property at \p path in \p cache has
|
||||
/// changed.
|
||||
PCP_API
|
||||
void DidChangeSpecStack(const PcpCache* cache, const SdfPath& path);
|
||||
|
||||
/// The connections on the attribute or targets on the relationship have
|
||||
/// changed.
|
||||
PCP_API
|
||||
void DidChangeTargets(const PcpCache* cache, const SdfPath& path,
|
||||
PcpCacheChanges::TargetType targetType);
|
||||
|
||||
/// The relocates that affect prims and properties at and below
|
||||
/// the given cache path have changed.
|
||||
PCP_API
|
||||
void DidChangeRelocates(const PcpCache* cache, const SdfPath& path);
|
||||
|
||||
/// The composed object at \p oldPath was moved to \p newPath. This
|
||||
/// implies every corresponding Sd change. This object will subsume
|
||||
/// those Sd changes under this higher-level move. Sd path changes
|
||||
/// that are not so subsumed will be converted to DidChangePrimGraph()
|
||||
/// and/or DidChangeSpecs() changes.
|
||||
PCP_API
|
||||
void DidChangePaths(const PcpCache* cache,
|
||||
const SdfPath& oldPath, const SdfPath& newPath);
|
||||
|
||||
/// Remove any changes for \p cache.
|
||||
PCP_API
|
||||
void DidDestroyCache(const PcpCache* cache);
|
||||
|
||||
/// Swap the contents of this and \p other.
|
||||
PCP_API
|
||||
void Swap(PcpChanges& other);
|
||||
|
||||
/// Returns \c true iff there are no changes.
|
||||
PCP_API
|
||||
bool IsEmpty() const;
|
||||
|
||||
typedef std::map<PcpLayerStackPtr, PcpLayerStackChanges> LayerStackChanges;
|
||||
typedef std::map<PcpCache*, PcpCacheChanges> CacheChanges;
|
||||
|
||||
/// Returns a map of all of the layer stack changes. Note that some
|
||||
/// keys may be to expired layer stacks.
|
||||
PCP_API
|
||||
const LayerStackChanges& GetLayerStackChanges() const;
|
||||
|
||||
/// Returns a map of all of the cache changes.
|
||||
PCP_API
|
||||
const CacheChanges& GetCacheChanges() const;
|
||||
|
||||
/// Returns the lifeboat responsible for maintaining the lifetime of
|
||||
/// layers and layer stacks during change processing. Consumers may
|
||||
/// inspect this object to determine which of these objects, if any,
|
||||
/// had their lifetimes affected during change processing.
|
||||
PCP_API
|
||||
const PcpLifeboat& GetLifeboat() const;
|
||||
|
||||
/// Applies the changes to the layer stacks and caches.
|
||||
PCP_API
|
||||
void Apply() const;
|
||||
|
||||
private:
|
||||
// Internal data types for namespace edits from Sd.
|
||||
typedef std::map<SdfPath, SdfPath> _PathEditMap;
|
||||
typedef std::map<PcpCache*, _PathEditMap> _RenameChanges;
|
||||
|
||||
// Returns the PcpLayerStackChanges for the given cache's layer stack.
|
||||
PcpLayerStackChanges& _GetLayerStackChanges(const PcpCache* cache);
|
||||
|
||||
// Returns the PcpLayerStackChanges for the given layer stack.
|
||||
PcpLayerStackChanges& _GetLayerStackChanges(const PcpLayerStackPtr&);
|
||||
|
||||
// Returns the PcpCacheChanges for the given cache.
|
||||
PcpCacheChanges& _GetCacheChanges(const PcpCache* cache);
|
||||
|
||||
// Returns the _PathEditMap for the given cache.
|
||||
_PathEditMap& _GetRenameChanges(const PcpCache* cache);
|
||||
|
||||
|
||||
// Optimize the changes.
|
||||
void _Optimize() const;
|
||||
|
||||
// Optimize the changes.
|
||||
void _Optimize();
|
||||
|
||||
// Optimize the changes for a given cache.
|
||||
void _Optimize(PcpCacheChanges*);
|
||||
|
||||
// Optimize path changes.
|
||||
void _OptimizePathChanges(const PcpCache* cache, PcpCacheChanges* changes,
|
||||
const _PathEditMap* pathChanges);
|
||||
|
||||
// Sublayer change type for _DidChangeSublayer.
|
||||
enum _SublayerChangeType {
|
||||
_SublayerAdded,
|
||||
_SublayerRemoved
|
||||
};
|
||||
|
||||
// Helper function for loading a sublayer of \p layer at \p sublayerPath
|
||||
// for processing changes described by \p sublayerChange.
|
||||
SdfLayerRefPtr _LoadSublayerForChange(const PcpCache* cache,
|
||||
const SdfLayerHandle& layer,
|
||||
const std::string& sublayerPath,
|
||||
_SublayerChangeType changeType) const;
|
||||
|
||||
// Helper function for loading a sublayer at \p sublayerPath
|
||||
// for processing changes described by \p sublayerChange.
|
||||
SdfLayerRefPtr _LoadSublayerForChange(const PcpCache* cache,
|
||||
const std::string& sublayerPath,
|
||||
_SublayerChangeType changeType) const;
|
||||
|
||||
// Propagates changes to \p sublayer specified by \p sublayerChange to
|
||||
// the dependents of that sublayer. This includes all layer stacks
|
||||
// that include the sublayer.
|
||||
void _DidChangeSublayerAndLayerStacks(const PcpCache* cache,
|
||||
const PcpLayerStackPtrVector& stacks,
|
||||
const std::string& sublayerPath,
|
||||
const SdfLayerHandle& sublayer,
|
||||
_SublayerChangeType sublayerChange,
|
||||
std::string* debugSummary);
|
||||
|
||||
// Propagates changes to \p sublayer specified by \p sublayerChange to
|
||||
// the dependents of that sublayer.
|
||||
void _DidChangeSublayer(const PcpCache* cache,
|
||||
const PcpLayerStackPtrVector& layerStacks,
|
||||
const std::string& sublayerPath,
|
||||
const SdfLayerHandle& sublayer,
|
||||
_SublayerChangeType sublayerChange,
|
||||
std::string* debugSummary,
|
||||
bool *significant);
|
||||
|
||||
// Mark the layer stack as having changed.
|
||||
void _DidChangeLayerStack(const PcpLayerStackPtr& layerStack,
|
||||
bool requiresLayerStackChange,
|
||||
bool requiresLayerStackOffsetsChange,
|
||||
bool requiresSignificantChange);
|
||||
|
||||
// Mark the layer stack's relocations as having changed.
|
||||
// Recompute the new relocations, storing the result in the Changes,
|
||||
// so that change-processing can determine which other caches it
|
||||
// needs to invalidate.
|
||||
void _DidChangeLayerStackRelocations(
|
||||
const TfSpan<const PcpCache*>& caches,
|
||||
const PcpLayerStackPtr & layerStack,
|
||||
std::string* debugSummary);
|
||||
|
||||
// Register changes to any prim indexes in \p caches that are affected
|
||||
// by a change to a layer's resolved path used by \p layerStack.
|
||||
void _DidChangeLayerStackResolvedPath(
|
||||
const TfSpan<const PcpCache*>& caches,
|
||||
const PcpLayerStackPtr& layerStack,
|
||||
std::string* debugSummary);
|
||||
|
||||
// The spec stack for the prim or property index at \p path must be
|
||||
// recomputed due to a change that affects only the internal representation
|
||||
// of the stack and not its contents.
|
||||
void _DidChangeSpecStackInternal(
|
||||
const PcpCache* cache, const SdfPath& path);
|
||||
|
||||
private:
|
||||
LayerStackChanges _layerStackChanges;
|
||||
CacheChanges _cacheChanges;
|
||||
_RenameChanges _renameChanges;
|
||||
mutable PcpLifeboat _lifeboat;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_CHANGES_H
|
||||
@@ -0,0 +1,297 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_COMPOSE_SITE_H
|
||||
#define PXR_USD_PCP_COMPOSE_SITE_H
|
||||
|
||||
/// \file pcp/composeSite.h
|
||||
///
|
||||
/// Single-site composition.
|
||||
///
|
||||
/// These are helpers that compose specific fields at single sites.
|
||||
/// They compose the field for a given path across a layer stack,
|
||||
/// using field-specific rules to combine the values.
|
||||
///
|
||||
/// These helpers are low-level utilities used by the rest of the
|
||||
/// Pcp algorithms, to discover composition arcs in scene description.
|
||||
/// These arcs are what guide the algorithm to pull additional
|
||||
/// sites of scene description into the PcpPrimIndex.
|
||||
///
|
||||
/// Some of these field types support list-editing. (See SdListOp.)
|
||||
/// List-editing for these fields is applied across the fixed domain
|
||||
/// of a single site; you cannot apply list-ops across sites.
|
||||
/// The intention is to avoid subtle ordering issues in composition
|
||||
/// semantics.
|
||||
///
|
||||
/// Note that these helpers do not take PcpSite as a literal parameter;
|
||||
/// instead, they require the actual computed layer stack that a site
|
||||
/// identified. Rather than tying these helpers to PcpCache and its
|
||||
/// process of computing layer stacks, they just employ the result.
|
||||
/// Conceptually, though, they are operating on the scene description
|
||||
/// identified by a PcpSite.
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/node.h"
|
||||
#include "pxr/usd/sdf/layerOffset.h"
|
||||
#include "pxr/usd/sdf/path.h"
|
||||
#include "pxr/usd/sdf/payload.h"
|
||||
#include "pxr/usd/sdf/reference.h"
|
||||
#include "pxr/usd/sdf/types.h"
|
||||
#include "pxr/usd/sdf/site.h"
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
TF_DECLARE_WEAK_AND_REF_PTRS(PcpLayerStack);
|
||||
|
||||
class PcpLayerStackSite;
|
||||
|
||||
/// \struct PcpSourceArcInfo
|
||||
///
|
||||
/// Information about the source of the target of an arc.
|
||||
/// All arcs have a layer that the arc comes from. References and payloads
|
||||
/// have a resolved layer offset and authored asset path as well.
|
||||
///
|
||||
struct PcpSourceArcInfo {
|
||||
SdfLayerHandle layer;
|
||||
SdfLayerOffset layerOffset;
|
||||
std::string authoredAssetPath;
|
||||
};
|
||||
|
||||
/// A vector of reference or payload arc information.
|
||||
typedef std::vector<PcpSourceArcInfo> PcpSourceArcInfoVector;
|
||||
|
||||
/// References
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSiteReferences(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path,
|
||||
SdfReferenceVector *result,
|
||||
PcpSourceArcInfoVector *info);
|
||||
inline void
|
||||
PcpComposeSiteReferences(PcpNodeRef const &node,
|
||||
SdfReferenceVector *result,
|
||||
PcpSourceArcInfoVector *info)
|
||||
{
|
||||
return PcpComposeSiteReferences(node.GetLayerStack(), node.GetPath(),
|
||||
result, info);
|
||||
}
|
||||
|
||||
/// Payloads
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSitePayloads(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path,
|
||||
SdfPayloadVector *result,
|
||||
PcpSourceArcInfoVector *info);
|
||||
inline void
|
||||
PcpComposeSitePayloads(PcpNodeRef const &node,
|
||||
SdfPayloadVector *result,
|
||||
PcpSourceArcInfoVector *info)
|
||||
{
|
||||
return PcpComposeSitePayloads(node.GetLayerStack(), node.GetPath(),
|
||||
result, info);
|
||||
}
|
||||
|
||||
/// Permission
|
||||
PCP_API
|
||||
SdfPermission
|
||||
PcpComposeSitePermission(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path);
|
||||
|
||||
inline SdfPermission
|
||||
PcpComposeSitePermission(PcpNodeRef const &node)
|
||||
{
|
||||
return PcpComposeSitePermission(node.GetLayerStack(), node.GetPath());
|
||||
}
|
||||
|
||||
/// Prim sites
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSitePrimSites(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path,
|
||||
SdfSiteVector *result);
|
||||
|
||||
inline void
|
||||
PcpComposeSitePrimSites(PcpNodeRef const &node, SdfSiteVector *result)
|
||||
{
|
||||
return PcpComposeSitePrimSites(
|
||||
node.GetLayerStack(), node.GetPath(), result);
|
||||
}
|
||||
|
||||
/// Relocates
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSiteRelocates(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path,
|
||||
SdfRelocatesMap *result);
|
||||
|
||||
inline void
|
||||
PcpComposeSiteRelocates(PcpNodeRef const &node, SdfRelocatesMap *result)
|
||||
{
|
||||
return PcpComposeSiteRelocates(
|
||||
node.GetLayerStack(), node.GetPath(), result);
|
||||
}
|
||||
|
||||
/// Has prim specs.
|
||||
PCP_API
|
||||
bool
|
||||
PcpComposeSiteHasPrimSpecs(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path);
|
||||
inline bool
|
||||
PcpComposeSiteHasPrimSpecs(PcpNodeRef const &node)
|
||||
{
|
||||
return PcpComposeSiteHasPrimSpecs(node.GetLayerStack(), node.GetPath());
|
||||
}
|
||||
|
||||
/// Symmetry
|
||||
PCP_API
|
||||
bool
|
||||
PcpComposeSiteHasSymmetry(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path);
|
||||
inline bool
|
||||
PcpComposeSiteHasSymmetry(PcpNodeRef const &node)
|
||||
{
|
||||
return PcpComposeSiteHasSymmetry(node.GetLayerStack(), node.GetPath());
|
||||
}
|
||||
|
||||
/// Inherits
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSiteInherits(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path, SdfPathVector *result,
|
||||
PcpSourceArcInfoVector *info);
|
||||
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSiteInherits(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path, SdfPathVector *result);
|
||||
|
||||
inline void
|
||||
PcpComposeSiteInherits(PcpNodeRef const &node, SdfPathVector *result)
|
||||
{
|
||||
return PcpComposeSiteInherits(node.GetLayerStack(), node.GetPath(), result);
|
||||
}
|
||||
|
||||
/// Specializes
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSiteSpecializes(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path, SdfPathVector *result,
|
||||
PcpSourceArcInfoVector *info);
|
||||
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSiteSpecializes(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path, SdfPathVector *result);
|
||||
|
||||
inline void
|
||||
PcpComposeSiteSpecializes(PcpNodeRef const &node, SdfPathVector *result)
|
||||
{
|
||||
return PcpComposeSiteSpecializes(
|
||||
node.GetLayerStack(), node.GetPath(), result);
|
||||
}
|
||||
|
||||
/// VariantSets
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSiteVariantSets(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path,
|
||||
std::vector<std::string> *result,
|
||||
PcpSourceArcInfoVector *info);
|
||||
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSiteVariantSets(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path,
|
||||
std::vector<std::string> *result);
|
||||
inline void
|
||||
PcpComposeSiteVariantSets(PcpNodeRef const &node,
|
||||
std::vector<std::string> *result) {
|
||||
return PcpComposeSiteVariantSets(
|
||||
node.GetLayerStack(), node.GetPath(), result);
|
||||
}
|
||||
|
||||
/// VariantSetOptions
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSiteVariantSetOptions(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path,
|
||||
std::string const &vsetName,
|
||||
std::set<std::string> *result);
|
||||
inline void
|
||||
PcpComposeSiteVariantSetOptions(PcpNodeRef const &node,
|
||||
std::string const &vsetName,
|
||||
std::set<std::string> *result)
|
||||
{
|
||||
return PcpComposeSiteVariantSetOptions(
|
||||
node.GetLayerStack(), node.GetPath(), vsetName, result);
|
||||
}
|
||||
|
||||
/// VariantSelection
|
||||
PCP_API
|
||||
bool
|
||||
PcpComposeSiteVariantSelection(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path,
|
||||
std::string const &vsetName,
|
||||
std::string *result);
|
||||
inline bool
|
||||
PcpComposeSiteVariantSelection(PcpNodeRef const &node,
|
||||
std::string const &vsetName,
|
||||
std::string *result)
|
||||
{
|
||||
return PcpComposeSiteVariantSelection(node.GetLayerStack(), node.GetPath(),
|
||||
vsetName, result);
|
||||
}
|
||||
|
||||
/// VariantSelections
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSiteVariantSelections(PcpLayerStackRefPtr const &layerStack,
|
||||
SdfPath const &path,
|
||||
SdfVariantSelectionMap *result);
|
||||
inline void
|
||||
PcpComposeSiteVariantSelections(PcpNodeRef const &node,
|
||||
SdfVariantSelectionMap *result)
|
||||
{
|
||||
return PcpComposeSiteVariantSelections(node.GetLayerStack(), node.GetPath(),
|
||||
result);
|
||||
}
|
||||
|
||||
/// Compose child names.
|
||||
/// If the optional \p orderField is provided, its order will be applied.
|
||||
PCP_API
|
||||
void
|
||||
PcpComposeSiteChildNames(SdfLayerRefPtrVector const &layers,
|
||||
SdfPath const &path,
|
||||
const TfToken & namesField,
|
||||
TfTokenVector *nameOrder,
|
||||
PcpTokenSet *nameSet,
|
||||
const TfToken *orderField = nullptr);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_COMPOSE_SITE_H
|
||||
@@ -0,0 +1,147 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_DEPENDENCY_H
|
||||
#define PXR_USD_PCP_DEPENDENCY_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/mapFunction.h"
|
||||
#include "pxr/usd/sdf/path.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class PcpNodeRef;
|
||||
|
||||
/// \enum PcpDependencyType
|
||||
///
|
||||
/// A classification of PcpPrimIndex->PcpSite dependencies
|
||||
/// by composition structure.
|
||||
///
|
||||
enum PcpDependencyType {
|
||||
/// No type of dependency.
|
||||
PcpDependencyTypeNone = 0,
|
||||
|
||||
/// The root dependency of a cache on its root site.
|
||||
/// This may be useful to either include, as when invalidating
|
||||
/// caches in response to scene edits, or to exclude, as when
|
||||
/// scanning dependency arcs to compensate for a namespace edit.
|
||||
PcpDependencyTypeRoot = (1 << 0),
|
||||
|
||||
/// Purely direct dependencies involve only arcs introduced
|
||||
/// directly at this level of namespace.
|
||||
PcpDependencyTypePurelyDirect = (1 << 1),
|
||||
|
||||
/// Partly direct dependencies involve at least one arc introduced
|
||||
/// directly at this level of namespace; they may also involve
|
||||
/// ancestral arcs along the chain as well.
|
||||
PcpDependencyTypePartlyDirect = (1 << 2),
|
||||
|
||||
/// Ancestral dependencies involve only arcs from ancestral
|
||||
/// levels of namespace, and no direct arcs.
|
||||
PcpDependencyTypeAncestral = (1 << 3),
|
||||
|
||||
/// Virtual dependencies do not contribute scene description,
|
||||
/// yet represent sites whose scene description (or ancestral
|
||||
/// scene description) informed the structure of the cache.
|
||||
///
|
||||
/// One case of this is when a reference or payload arc
|
||||
/// does not specify a prim, and the target layerStack does
|
||||
/// not provide defaultPrim metadata either. In that case
|
||||
/// a virtual dependency to the root of that layer stack will
|
||||
/// represent the latent dependency on that site's metadata.
|
||||
///
|
||||
/// Another case of this is "spooky ancestral" dependencies from
|
||||
/// relocates. These are referred to as "spooky" dependencies
|
||||
/// because they can be seen as a form of action-at-a-distance. They
|
||||
/// only occur as a result of relocation arcs.
|
||||
PcpDependencyTypeVirtual = (1 << 4),
|
||||
PcpDependencyTypeNonVirtual = (1 << 5),
|
||||
|
||||
/// Combined mask value representing both pure and partly direct
|
||||
/// deps.
|
||||
PcpDependencyTypeDirect =
|
||||
PcpDependencyTypePartlyDirect
|
||||
| PcpDependencyTypePurelyDirect,
|
||||
|
||||
/// Combined mask value representing any kind of dependency,
|
||||
/// except virtual ones.
|
||||
PcpDependencyTypeAnyNonVirtual =
|
||||
PcpDependencyTypeRoot
|
||||
| PcpDependencyTypeDirect
|
||||
| PcpDependencyTypeAncestral
|
||||
| PcpDependencyTypeNonVirtual,
|
||||
|
||||
/// Combined mask value representing any kind of dependency.
|
||||
PcpDependencyTypeAnyIncludingVirtual =
|
||||
PcpDependencyTypeAnyNonVirtual
|
||||
| PcpDependencyTypeVirtual,
|
||||
};
|
||||
|
||||
/// A typedef for a bitmask of flags from PcpDependencyType.
|
||||
typedef unsigned int PcpDependencyFlags;
|
||||
|
||||
/// Description of a dependency.
|
||||
struct PcpDependency {
|
||||
/// The path in this PcpCache's root layer stack that depends
|
||||
/// on the site.
|
||||
SdfPath indexPath;
|
||||
/// The site path. When using recurseDownNamespace, this may
|
||||
/// be a path beneath the initial sitePath.
|
||||
SdfPath sitePath;
|
||||
/// The map function that applies to values from the site.
|
||||
PcpMapFunction mapFunc;
|
||||
|
||||
bool operator==(const PcpDependency &rhs) const {
|
||||
return indexPath == rhs.indexPath &&
|
||||
sitePath == rhs.sitePath &&
|
||||
mapFunc == rhs.mapFunc;
|
||||
}
|
||||
bool operator!=(const PcpDependency &rhs) const {
|
||||
return !(*this == rhs);
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::vector<PcpDependency> PcpDependencyVector;
|
||||
|
||||
/// Returns true if this node introduces a dependency in its
|
||||
/// PcpPrimIndex, false otherwise. This is equivalent to
|
||||
/// PcpClassifyNodeDependency(n) != PcpDependencyTypeNone, but
|
||||
/// is faster.
|
||||
PCP_API
|
||||
bool PcpNodeIntroducesDependency(const PcpNodeRef &n);
|
||||
|
||||
/// Classify the dependency represented by a node, by analyzing
|
||||
/// its structural role in its PcpPrimIndex. Returns a
|
||||
/// bitmask of flags from PcpDependencyType.
|
||||
PCP_API
|
||||
PcpDependencyFlags PcpClassifyNodeDependency(const PcpNodeRef &n);
|
||||
|
||||
PCP_API
|
||||
std::string PcpDependencyFlagsToString(const PcpDependencyFlags flags);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_DEPENDENCY_H
|
||||
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_DYNAMIC_FILE_FORMAT_CONTEXT_H
|
||||
#define PXR_USD_PCP_DYNAMIC_FILE_FORMAT_CONTEXT_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/node.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class PcpPrimIndex_StackFrame;
|
||||
class PcpCache;
|
||||
|
||||
/// \class PcpDynamicFileFormatContext
|
||||
///
|
||||
/// Context object for the current state of a prim index that is being built
|
||||
/// that allows implementations of PcpDynamicFileFormatInterface to compose
|
||||
/// field values when generating dynamic file format arguments. The context
|
||||
/// allows us to iterate over all nodes that have already been composed looking
|
||||
/// for the strongest opinion for a relevant field.
|
||||
class PcpDynamicFileFormatContext
|
||||
{
|
||||
public:
|
||||
using VtValueVector = std::vector<VtValue>;
|
||||
|
||||
PCP_API
|
||||
~PcpDynamicFileFormatContext() = default;
|
||||
|
||||
/// Compose the \p value of the given \p field and return its current
|
||||
/// strongest opinion. For dictionary valued fields this will be a
|
||||
/// dictionary containing the strongest value for each individual key.
|
||||
/// Returns true if a value for the field was found.
|
||||
PCP_API
|
||||
bool ComposeValue(const TfToken &field, VtValue *value) const;
|
||||
|
||||
/// Compose the \p values of the given \p field returning all available
|
||||
/// opinions ordered from strongest to weakest. For dictionary valued
|
||||
/// fields, the dictionaries from each opinion are not composed together
|
||||
/// at each step and are instead returned in the list as is.
|
||||
/// Returns true if a value for the field was found.
|
||||
///
|
||||
/// Note that this is slower than ComposeValue, especially for
|
||||
/// non-dictionary valued fields, and should only be used if knowing more
|
||||
/// than just the strongest value is necessary.
|
||||
PCP_API
|
||||
bool ComposeValueStack(const TfToken &field,
|
||||
VtValueVector *values) const;
|
||||
|
||||
private:
|
||||
// Callback function for ComposeValue. This callback function will
|
||||
// be passed values for the field given to ComposeValue from
|
||||
// strongest to weakest available opinion and is free to copy or
|
||||
// swap out the value as desired.
|
||||
using _ComposeFunction = std::function<void(VtValue &&)>;
|
||||
|
||||
/// Constructs a context.
|
||||
/// \p parentNode and \p previousFrame are used to traverse the
|
||||
/// current state of the prim index graph when composing the opinions on
|
||||
/// fields. \p composedFieldNames is the set of field names that is
|
||||
/// to be updated with the names of fields that ComposeValue and
|
||||
/// ComposeValueStack are called on for dependency tracking.
|
||||
PcpDynamicFileFormatContext(
|
||||
const PcpNodeRef &parentNode,
|
||||
PcpPrimIndex_StackFrame *previousFrame,
|
||||
TfToken::Set *composedFieldNames);
|
||||
/// Access to private constructor. Should only be called by prim indexing.
|
||||
friend PcpDynamicFileFormatContext Pcp_CreateDynamicFileFormatContext(
|
||||
const PcpNodeRef &, PcpPrimIndex_StackFrame *, TfToken::Set *);
|
||||
|
||||
/// Returns whether the given \p field is allowed to be used to generate
|
||||
/// file format arguments. It can also return whether the value type of
|
||||
/// the field is a dictionary if needed.
|
||||
bool _IsAllowedFieldForArguments(
|
||||
const TfToken &field, bool *fieldValueIsDictionary = nullptr) const;
|
||||
|
||||
private:
|
||||
PcpNodeRef _parentNode;
|
||||
PcpPrimIndex_StackFrame *_previousStackFrame;
|
||||
|
||||
// Cached names of fields that had values composed by this context.
|
||||
TfToken::Set *_composedFieldNames;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_DYNAMIC_FILE_FORMAT_CONTEXT_H
|
||||
@@ -0,0 +1,147 @@
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_DYNAMIC_FILE_FORMAT_DEPENDENCY_DATA_H
|
||||
#define PXR_USD_PCP_DYNAMIC_FILE_FORMAT_DEPENDENCY_DATA_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/base/tf/declarePtrs.h"
|
||||
#include "pxr/base/tf/token.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class PcpDynamicFileFormatInterface;
|
||||
class VtValue;
|
||||
|
||||
TF_DECLARE_WEAK_PTRS(SdfFileFormat);
|
||||
|
||||
/// \class PcpDynamicFileFormatDependencyData
|
||||
///
|
||||
/// Contains the necessary information for storing a prim index's dependency
|
||||
/// on dynamic file format arguments and determining if a field change affects
|
||||
/// the prim index. This data structure does not store the prim index or its
|
||||
/// path itself and is expected to be the data in some other data structure
|
||||
/// that maps prim indexes to its dependencies.
|
||||
///
|
||||
class PcpDynamicFileFormatDependencyData
|
||||
{
|
||||
public:
|
||||
/// Default constructor. This data will be empty.
|
||||
PCP_API
|
||||
PcpDynamicFileFormatDependencyData() = default;
|
||||
|
||||
/// Move constructor.
|
||||
PCP_API
|
||||
PcpDynamicFileFormatDependencyData(
|
||||
PcpDynamicFileFormatDependencyData &&) = default;
|
||||
|
||||
/// Copy constructor.
|
||||
PCP_API
|
||||
PcpDynamicFileFormatDependencyData(
|
||||
const PcpDynamicFileFormatDependencyData &rhs);
|
||||
|
||||
/// Move assignment operator
|
||||
PcpDynamicFileFormatDependencyData &operator=(
|
||||
PcpDynamicFileFormatDependencyData &&rhs) {
|
||||
Swap(rhs);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Copy assignment operator
|
||||
PcpDynamicFileFormatDependencyData &operator=(
|
||||
const PcpDynamicFileFormatDependencyData &rhs) {
|
||||
PcpDynamicFileFormatDependencyData(rhs).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Swap the contents of this dependency data with \p rhs.
|
||||
inline void Swap(PcpDynamicFileFormatDependencyData& rhs) {
|
||||
_data.swap(rhs._data);
|
||||
}
|
||||
|
||||
/// Same as Swap(), but standard name.
|
||||
inline void swap(PcpDynamicFileFormatDependencyData &rhs) { Swap(rhs); }
|
||||
|
||||
/// Returns whether this dependency data is empty.
|
||||
inline bool IsEmpty() const {
|
||||
return !_data;
|
||||
}
|
||||
|
||||
/// Adds dependency info from a single context that generated dynamic file
|
||||
/// format arguments (usually a payload arc in the graph).
|
||||
/// \p dynamicFileFormat is the file format that generated the arguments.
|
||||
/// \p dependencyContextData is custom dependency information generated when
|
||||
/// the file format generated its arguments. \p composedFieldNames is a
|
||||
/// list of the fields that were composed on the prim to generate arguments.
|
||||
PCP_API
|
||||
void AddDependencyContext(
|
||||
const PcpDynamicFileFormatInterface *dynamicFileFormat,
|
||||
VtValue &&dependencyContextData,
|
||||
TfToken::Set &&composedFieldNames);
|
||||
|
||||
/// Takes all the dependency data from \p dependencyData and adds it to this
|
||||
/// dependency.
|
||||
PCP_API
|
||||
void AppendDependencyData(
|
||||
PcpDynamicFileFormatDependencyData &&dependencyData);
|
||||
|
||||
/// Returns a list of field names that were composed for any of the
|
||||
/// dependency contexts that were added to this dependency.
|
||||
PCP_API
|
||||
const TfToken::Set &GetRelevantFieldNames() const;
|
||||
|
||||
/// Given a \p field name and the changed field values in \p oldAndNewValues
|
||||
/// this return whether this change can affect any of the file format
|
||||
/// arguments generated by any of the contexts stored in this dependency.
|
||||
PCP_API
|
||||
bool CanFieldChangeAffectFileFormatArguments(const TfToken &fieldName,
|
||||
const VtValue& oldValue,
|
||||
const VtValue& newValue) const;
|
||||
|
||||
private:
|
||||
// Struct containing the entire contents of the dependency.
|
||||
struct _Data
|
||||
{
|
||||
using _ContextData =
|
||||
std::pair<const PcpDynamicFileFormatInterface *, VtValue>;
|
||||
using _ContextDataVector = std::vector<_ContextData>;
|
||||
|
||||
_ContextDataVector dependencyContexts;
|
||||
TfToken::Set relevantFieldNames;
|
||||
|
||||
// Helper for adding relevant fields. We avoid copying by taking the
|
||||
// input set if our set is empty.
|
||||
void _AddRelevantFieldNames(TfToken::Set &&fieldNames);
|
||||
};
|
||||
|
||||
// Pointer to data. Will be null if this an empty data object.
|
||||
std::unique_ptr<_Data> _data;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_DYNAMIC_FILE_FORMAT_DEPENDENCY_DATA_H
|
||||
@@ -0,0 +1,97 @@
|
||||
//
|
||||
// Copyright 2019 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_DYNAMIC_FILE_FORMAT_INTERFACE_H
|
||||
#define PXR_USD_PCP_DYNAMIC_FILE_FORMAT_INTERFACE_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/sdf/fileFormat.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class PcpDynamicFileFormatContext;
|
||||
class VtValue;
|
||||
|
||||
/// \class PcpDynamicFileFormatInterface
|
||||
///
|
||||
/// Interface mixin that can be included by SdfFileFormat subclasses to enable
|
||||
/// dynamic file format argument generation for a file format plugin.
|
||||
/// When prim index composition encounters a payload to an asset of a file
|
||||
/// format that implements this interface, it will call
|
||||
/// ComposeFieldsForFileFormatArguments to generate arguments from the current
|
||||
/// composition context at which the payload is being added. The derived file
|
||||
/// format is on the hook for using the provided context to compute any prim
|
||||
/// field values it needs and generate the relevant file format arguments for
|
||||
/// its content.
|
||||
class PcpDynamicFileFormatInterface
|
||||
{
|
||||
public:
|
||||
/// Empty virtual destructor to prevent build errors with some compilers.
|
||||
PCP_API
|
||||
virtual ~PcpDynamicFileFormatInterface();
|
||||
|
||||
/// Derived classes must implement this function to compose prim fields
|
||||
/// using the given \p context and use them to generate file format
|
||||
/// arguments for the layer at \p assetPath. The context provides methods
|
||||
/// to compose field values at the current point in prim index composition
|
||||
/// which can be used to generate the relevant file format arguments. These
|
||||
/// arguments need to be added to the set of file format arguments provided
|
||||
/// by \p args.
|
||||
///
|
||||
/// Additionally, implementations can output \p dependencyContextData of
|
||||
/// any value type that will then be passed back in to calls to
|
||||
/// CanFieldChangeAffectFileFormatArguments during change processing.
|
||||
/// This can be used to provide more that context that is specific to the
|
||||
/// file format when determining whether a field change really does affect
|
||||
/// the arguments generated by a particular call to this function.
|
||||
PCP_API
|
||||
virtual void ComposeFieldsForFileFormatArguments(
|
||||
const std::string& assetPath,
|
||||
const PcpDynamicFileFormatContext &context,
|
||||
SdfFileFormat::FileFormatArguments* args,
|
||||
VtValue *dependencyContextData) const = 0;
|
||||
|
||||
/// Derived classes must implement this function to return true if the
|
||||
/// change to scene description of the field named \p field can affect the
|
||||
/// dynamic file format arguments generated by
|
||||
/// ComposeFieldsForFileFormatArguments. This function will be called during
|
||||
/// change processing to determine whether a change to a field affects
|
||||
/// the dynamic file format arguments of a payload that a prim index depends
|
||||
/// on.
|
||||
///
|
||||
/// \p oldValue and \p newValue contain the old and new values of the field.
|
||||
/// \p dependencyContextData is the arbitrary typed data that was generated
|
||||
/// by the call to ComposeFieldsForFileFormatArguments when the payload arc
|
||||
/// was computed.
|
||||
PCP_API
|
||||
virtual bool CanFieldChangeAffectFileFormatArguments(
|
||||
const TfToken& field,
|
||||
const VtValue& oldValue,
|
||||
const VtValue& newValue,
|
||||
const VtValue &dependencyContextData) const = 0;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_DYNAMIC_FILE_FORMAT_INTERFACE_H
|
||||
@@ -0,0 +1,893 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_ERRORS_H
|
||||
#define PXR_USD_PCP_ERRORS_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/site.h"
|
||||
#include "pxr/usd/pcp/types.h"
|
||||
#include "pxr/usd/sdf/layer.h"
|
||||
#include "pxr/usd/sdf/layerOffset.h"
|
||||
#include "pxr/usd/sdf/path.h"
|
||||
|
||||
#include "pxr/base/tf/enum.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
// Forward declaration:
|
||||
class PcpCache;
|
||||
|
||||
/// \enum PcpErrorType
|
||||
///
|
||||
/// Enum to indicate the type represented by a Pcp error.
|
||||
///
|
||||
enum PcpErrorType {
|
||||
PcpErrorType_ArcCycle,
|
||||
PcpErrorType_ArcPermissionDenied,
|
||||
PcpErrorType_IndexCapacityExceeded,
|
||||
PcpErrorType_ArcCapacityExceeded,
|
||||
PcpErrorType_ArcNamespaceDepthCapacityExceeded,
|
||||
PcpErrorType_InconsistentPropertyType,
|
||||
PcpErrorType_InconsistentAttributeType,
|
||||
PcpErrorType_InconsistentAttributeVariability,
|
||||
PcpErrorType_InternalAssetPath,
|
||||
PcpErrorType_InvalidPrimPath,
|
||||
PcpErrorType_InvalidAssetPath,
|
||||
PcpErrorType_InvalidInstanceTargetPath,
|
||||
PcpErrorType_InvalidExternalTargetPath,
|
||||
PcpErrorType_InvalidTargetPath,
|
||||
PcpErrorType_InvalidReferenceOffset,
|
||||
PcpErrorType_InvalidSublayerOffset,
|
||||
PcpErrorType_InvalidSublayerOwnership,
|
||||
PcpErrorType_InvalidSublayerPath,
|
||||
PcpErrorType_InvalidVariantSelection,
|
||||
PcpErrorType_MutedAssetPath,
|
||||
PcpErrorType_OpinionAtRelocationSource,
|
||||
PcpErrorType_PrimPermissionDenied,
|
||||
PcpErrorType_PropertyPermissionDenied,
|
||||
PcpErrorType_SublayerCycle,
|
||||
PcpErrorType_TargetPermissionDenied,
|
||||
PcpErrorType_UnresolvedPrimPath
|
||||
};
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorBase;
|
||||
typedef std::shared_ptr<PcpErrorBase> PcpErrorBasePtr;
|
||||
typedef std::vector<PcpErrorBasePtr> PcpErrorVector;
|
||||
|
||||
/// \class PcpErrorBase
|
||||
///
|
||||
/// Base class for all error types.
|
||||
///
|
||||
class PcpErrorBase {
|
||||
public:
|
||||
/// Destructor.
|
||||
PCP_API virtual ~PcpErrorBase();
|
||||
/// Converts error to string message.
|
||||
virtual std::string ToString() const = 0;
|
||||
|
||||
/// The error code.
|
||||
const TfEnum errorType;
|
||||
|
||||
/// The site of the composed prim or property being computed when
|
||||
/// the error was encountered. (Note that some error types
|
||||
/// contain an additional site to capture more specific information
|
||||
/// about the site of the error.)
|
||||
PcpSiteStr rootSite;
|
||||
|
||||
/// Return true if this type of error should be reported at most
|
||||
/// once for a given prim.
|
||||
bool ShouldReportAtMostOnce() const {
|
||||
// Capacity errors are reported at most once. (If these limits are
|
||||
// reached, there is likely to be a very large number of whatever
|
||||
// caused it.)
|
||||
return errorType == PcpErrorType_IndexCapacityExceeded ||
|
||||
errorType == PcpErrorType_ArcCapacityExceeded ||
|
||||
errorType == PcpErrorType_ArcNamespaceDepthCapacityExceeded;
|
||||
}
|
||||
|
||||
protected:
|
||||
/// Constructor.
|
||||
PcpErrorBase(TfEnum errorType);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorArcCycle;
|
||||
typedef std::shared_ptr<PcpErrorArcCycle> PcpErrorArcCyclePtr;
|
||||
|
||||
/// \class PcpErrorArcCycle
|
||||
///
|
||||
/// Arcs between PcpNodes that form a cycle.
|
||||
///
|
||||
class PcpErrorArcCycle : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorArcCyclePtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorArcCycle();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
PcpSiteTracker cycle;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorArcCycle();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorArcPermissionDenied;
|
||||
typedef std::shared_ptr<PcpErrorArcPermissionDenied>
|
||||
PcpErrorArcPermissionDeniedPtr;
|
||||
|
||||
/// \class PcpErrorArcPermissionDenied
|
||||
///
|
||||
/// Arcs that were not made between PcpNodes because of permission
|
||||
/// restrictions.
|
||||
///
|
||||
class PcpErrorArcPermissionDenied : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorArcPermissionDeniedPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorArcPermissionDenied();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
/// The site where the invalid arc was expressed.
|
||||
PcpSite site;
|
||||
/// The private, invalid target of the arc.
|
||||
PcpSite privateSite;
|
||||
/// The type of arc.
|
||||
PcpArcType arcType;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorArcPermissionDenied();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorCapacityExceeded;
|
||||
typedef std::shared_ptr<PcpErrorCapacityExceeded> PcpErrorCapacityExceededPtr;
|
||||
|
||||
/// \class PcpErrorCapacityExceeded
|
||||
///
|
||||
/// Exceeded the capacity for composition arcs at a single site.
|
||||
///
|
||||
class PcpErrorCapacityExceeded : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorCapacityExceededPtr New(PcpErrorType errorType);
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorCapacityExceeded();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorCapacityExceeded(PcpErrorType errorType);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class PcpErrorInconsistentPropertyBase : public PcpErrorBase {
|
||||
public:
|
||||
/// Destructor.
|
||||
PCP_API virtual ~PcpErrorInconsistentPropertyBase();
|
||||
|
||||
/// The identifier of the layer with the defining property spec.
|
||||
std::string definingLayerIdentifier;
|
||||
/// The path of the defining property spec.
|
||||
SdfPath definingSpecPath;
|
||||
|
||||
/// The identifier of the layer with the conflicting property spec.
|
||||
std::string conflictingLayerIdentifier;
|
||||
/// The path of the conflicting property spec.
|
||||
SdfPath conflictingSpecPath;
|
||||
|
||||
protected:
|
||||
/// Constructor.
|
||||
PcpErrorInconsistentPropertyBase(TfEnum errorType);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInconsistentPropertyType;
|
||||
typedef std::shared_ptr<PcpErrorInconsistentPropertyType>
|
||||
PcpErrorInconsistentPropertyTypePtr;
|
||||
|
||||
/// \class PcpErrorInconsistentPropertyType
|
||||
///
|
||||
/// Properties that have specs with conflicting definitions.
|
||||
///
|
||||
class PcpErrorInconsistentPropertyType :
|
||||
public PcpErrorInconsistentPropertyBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInconsistentPropertyTypePtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInconsistentPropertyType();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
/// The type of the defining spec.
|
||||
SdfSpecType definingSpecType;
|
||||
/// The type of the conflicting spec.
|
||||
SdfSpecType conflictingSpecType;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInconsistentPropertyType();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInconsistentAttributeType;
|
||||
typedef std::shared_ptr<PcpErrorInconsistentAttributeType>
|
||||
PcpErrorInconsistentAttributeTypePtr;
|
||||
|
||||
/// \class PcpErrorInconsistentAttributeType
|
||||
///
|
||||
/// Attributes that have specs with conflicting definitions.
|
||||
///
|
||||
class PcpErrorInconsistentAttributeType :
|
||||
public PcpErrorInconsistentPropertyBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInconsistentAttributeTypePtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInconsistentAttributeType();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
/// The value type from the defining spec.
|
||||
TfToken definingValueType;
|
||||
/// The value type from the conflicting spec.
|
||||
TfToken conflictingValueType;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInconsistentAttributeType();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInconsistentAttributeVariability;
|
||||
typedef std::shared_ptr<PcpErrorInconsistentAttributeVariability>
|
||||
PcpErrorInconsistentAttributeVariabilityPtr;
|
||||
|
||||
/// \class PcpErrorInconsistentAttributeVariability
|
||||
///
|
||||
/// Attributes that have specs with conflicting variability.
|
||||
///
|
||||
class PcpErrorInconsistentAttributeVariability :
|
||||
public PcpErrorInconsistentPropertyBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInconsistentAttributeVariabilityPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInconsistentAttributeVariability();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
/// The variability of the defining spec.
|
||||
SdfVariability definingVariability;
|
||||
/// The variability of the conflicting spec.
|
||||
SdfVariability conflictingVariability;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInconsistentAttributeVariability();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInternalAssetPath;
|
||||
typedef std::shared_ptr<PcpErrorInternalAssetPath>
|
||||
PcpErrorInternalAssetPathPtr;
|
||||
|
||||
/// \class PcpErrorInternalAssetPath
|
||||
///
|
||||
/// Error about an arc that is prohibited due to being internal to an asset.
|
||||
///
|
||||
class PcpErrorInternalAssetPath : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInternalAssetPathPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInternalAssetPath();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
/// The site where the invalid arc was expressed.
|
||||
PcpSite site;
|
||||
SdfPath targetPath;
|
||||
std::string assetPath;
|
||||
std::string resolvedAssetPath;
|
||||
PcpArcType arcType;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInternalAssetPath();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInvalidPrimPath;
|
||||
typedef std::shared_ptr<PcpErrorInvalidPrimPath>
|
||||
PcpErrorInvalidPrimPathPtr;
|
||||
|
||||
/// \class PcpErrorInvalidPrimPath
|
||||
///
|
||||
/// Invalid prim paths used by references or payloads.
|
||||
///
|
||||
class PcpErrorInvalidPrimPath : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInvalidPrimPathPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInvalidPrimPath();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
/// The site where the invalid arc was expressed.
|
||||
PcpSite site;
|
||||
SdfPath primPath;
|
||||
PcpArcType arcType;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInvalidPrimPath();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInvalidAssetPathBase;
|
||||
typedef std::shared_ptr<PcpErrorInvalidAssetPathBase>
|
||||
PcpErrorInvalidAssetPathBasePtr;
|
||||
|
||||
class PcpErrorInvalidAssetPathBase : public PcpErrorBase {
|
||||
public:
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInvalidAssetPathBase();
|
||||
|
||||
/// The site where the invalid arc was expressed.
|
||||
PcpSite site;
|
||||
SdfPath targetPath;
|
||||
std::string assetPath;
|
||||
std::string resolvedAssetPath;
|
||||
PcpArcType arcType;
|
||||
SdfLayerHandle layer;
|
||||
std::string messages;
|
||||
|
||||
protected:
|
||||
/// Constructor.
|
||||
PcpErrorInvalidAssetPathBase(TfEnum errorType);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInvalidAssetPath;
|
||||
typedef std::shared_ptr<PcpErrorInvalidAssetPath>
|
||||
PcpErrorInvalidAssetPathPtr;
|
||||
|
||||
/// \class PcpErrorInvalidAssetPath
|
||||
///
|
||||
/// Invalid asset paths used by references or payloads.
|
||||
///
|
||||
class PcpErrorInvalidAssetPath : public PcpErrorInvalidAssetPathBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInvalidAssetPathPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInvalidAssetPath();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInvalidAssetPath();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorMutedAssetPath;
|
||||
typedef std::shared_ptr<PcpErrorMutedAssetPath>
|
||||
PcpErrorMutedAssetPathPtr;
|
||||
|
||||
/// \class PcpErrorMutedAssetPath
|
||||
///
|
||||
/// Muted asset paths used by references or payloads.
|
||||
///
|
||||
class PcpErrorMutedAssetPath : public PcpErrorInvalidAssetPathBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorMutedAssetPathPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorMutedAssetPath();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorMutedAssetPath();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorTargetPathBase;
|
||||
typedef std::shared_ptr<PcpErrorTargetPathBase>
|
||||
PcpErrorTargetPathBasePtr;
|
||||
|
||||
/// \class PcpErrorTargetPathBase
|
||||
///
|
||||
/// Base class for composition errors related to target or connection paths.
|
||||
///
|
||||
class PcpErrorTargetPathBase : public PcpErrorBase {
|
||||
public:
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorTargetPathBase();
|
||||
|
||||
/// The invalid target or connection path that was authored.
|
||||
SdfPath targetPath;
|
||||
/// The path to the property where the target was authored.
|
||||
SdfPath owningPath;
|
||||
/// The spec type of the property where the target was authored.
|
||||
SdfSpecType ownerSpecType;
|
||||
/// The layer containing the property where the target was authored.
|
||||
SdfLayerHandle layer;
|
||||
|
||||
/// The target or connection path in the composed scene.
|
||||
/// If this path could not be translated to the composed scene
|
||||
/// (e.g., in the case of an invalid external target path),
|
||||
/// this path will be empty.
|
||||
SdfPath composedTargetPath;
|
||||
|
||||
protected:
|
||||
PcpErrorTargetPathBase(TfEnum errorType);
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInvalidInstanceTargetPath;
|
||||
typedef std::shared_ptr<PcpErrorInvalidInstanceTargetPath>
|
||||
PcpErrorInvalidInstanceTargetPathPtr;
|
||||
|
||||
/// \class PcpErrorInvalidInstanceTargetPath
|
||||
///
|
||||
/// Invalid target or connection path authored in an inherited
|
||||
/// class that points to an instance of that class.
|
||||
///
|
||||
class PcpErrorInvalidInstanceTargetPath : public PcpErrorTargetPathBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInvalidInstanceTargetPathPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInvalidInstanceTargetPath();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInvalidInstanceTargetPath();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInvalidExternalTargetPath;
|
||||
typedef std::shared_ptr<PcpErrorInvalidExternalTargetPath>
|
||||
PcpErrorInvalidExternalTargetPathPtr;
|
||||
|
||||
/// \class PcpErrorInvalidExternalTargetPath
|
||||
///
|
||||
/// Invalid target or connection path in some scope that points to
|
||||
/// an object outside of that scope.
|
||||
///
|
||||
class PcpErrorInvalidExternalTargetPath : public PcpErrorTargetPathBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInvalidExternalTargetPathPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInvalidExternalTargetPath();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
PcpArcType ownerArcType;
|
||||
SdfPath ownerIntroPath;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInvalidExternalTargetPath();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInvalidTargetPath;
|
||||
typedef std::shared_ptr<PcpErrorInvalidTargetPath>
|
||||
PcpErrorInvalidTargetPathPtr;
|
||||
|
||||
/// \class PcpErrorInvalidTargetPath
|
||||
///
|
||||
/// Invalid target or connection path.
|
||||
///
|
||||
class PcpErrorInvalidTargetPath : public PcpErrorTargetPathBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInvalidTargetPathPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInvalidTargetPath();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInvalidTargetPath();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInvalidSublayerOffset;
|
||||
typedef std::shared_ptr<PcpErrorInvalidSublayerOffset>
|
||||
PcpErrorInvalidSublayerOffsetPtr;
|
||||
|
||||
/// \class PcpErrorInvalidSublayerOffset
|
||||
///
|
||||
/// Sublayers that use invalid layer offsets.
|
||||
///
|
||||
class PcpErrorInvalidSublayerOffset : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInvalidSublayerOffsetPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInvalidSublayerOffset();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
SdfLayerHandle layer;
|
||||
SdfLayerHandle sublayer;
|
||||
SdfLayerOffset offset;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInvalidSublayerOffset();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInvalidReferenceOffset;
|
||||
typedef std::shared_ptr<PcpErrorInvalidReferenceOffset>
|
||||
PcpErrorInvalidReferenceOffsetPtr;
|
||||
|
||||
/// \class PcpErrorInvalidReferenceOffset
|
||||
///
|
||||
/// Sublayers that use invalid layer offsets.
|
||||
///
|
||||
class PcpErrorInvalidReferenceOffset : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInvalidReferenceOffsetPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInvalidReferenceOffset();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
SdfLayerHandle layer;
|
||||
SdfPath sourcePath;
|
||||
std::string assetPath;
|
||||
SdfPath targetPath;
|
||||
SdfLayerOffset offset;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInvalidReferenceOffset();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInvalidSublayerOwnership;
|
||||
typedef std::shared_ptr<PcpErrorInvalidSublayerOwnership>
|
||||
PcpErrorInvalidSublayerOwnershipPtr;
|
||||
|
||||
/// \class PcpErrorInvalidSublayerOwnership
|
||||
///
|
||||
/// Sibling layers that have the same owner.
|
||||
///
|
||||
class PcpErrorInvalidSublayerOwnership : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInvalidSublayerOwnershipPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInvalidSublayerOwnership();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
std::string owner;
|
||||
SdfLayerHandle layer;
|
||||
SdfLayerHandleVector sublayers;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInvalidSublayerOwnership();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInvalidSublayerPath;
|
||||
typedef std::shared_ptr<PcpErrorInvalidSublayerPath>
|
||||
PcpErrorInvalidSublayerPathPtr;
|
||||
|
||||
/// \class PcpErrorInvalidSublayerPath
|
||||
///
|
||||
/// Asset paths that could not be both resolved and loaded.
|
||||
///
|
||||
class PcpErrorInvalidSublayerPath : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInvalidSublayerPathPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInvalidSublayerPath();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
SdfLayerHandle layer;
|
||||
std::string sublayerPath;
|
||||
std::string messages;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInvalidSublayerPath();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorInvalidVariantSelection;
|
||||
typedef std::shared_ptr<PcpErrorInvalidVariantSelection>
|
||||
PcpErrorInvalidVariantSelectionPtr;
|
||||
|
||||
/// \class PcpErrorInvalidVariantSelection
|
||||
///
|
||||
/// Invalid variant selections.
|
||||
///
|
||||
class PcpErrorInvalidVariantSelection : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorInvalidVariantSelectionPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorInvalidVariantSelection();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
std::string siteAssetPath;
|
||||
SdfPath sitePath;
|
||||
std::string vset, vsel;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorInvalidVariantSelection();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorOpinionAtRelocationSource;
|
||||
typedef std::shared_ptr<PcpErrorOpinionAtRelocationSource>
|
||||
PcpErrorOpinionAtRelocationSourcePtr;
|
||||
|
||||
/// \class PcpErrorOpinionAtRelocationSource
|
||||
///
|
||||
/// Opinions were found at a relocation source path.
|
||||
///
|
||||
class PcpErrorOpinionAtRelocationSource : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorOpinionAtRelocationSourcePtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorOpinionAtRelocationSource();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
SdfLayerHandle layer;
|
||||
SdfPath path;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorOpinionAtRelocationSource();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorPrimPermissionDenied;
|
||||
typedef std::shared_ptr<PcpErrorPrimPermissionDenied>
|
||||
PcpErrorPrimPermissionDeniedPtr;
|
||||
|
||||
/// \class PcpErrorPrimPermissionDenied
|
||||
///
|
||||
/// Layers with illegal opinions about private prims.
|
||||
///
|
||||
class PcpErrorPrimPermissionDenied : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorPrimPermissionDeniedPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorPrimPermissionDenied();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
/// The site where the invalid arc was expressed.
|
||||
PcpSiteStr site;
|
||||
/// The private, invalid target of the arc.
|
||||
PcpSiteStr privateSite;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorPrimPermissionDenied();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorPropertyPermissionDenied;
|
||||
typedef std::shared_ptr<PcpErrorPropertyPermissionDenied>
|
||||
PcpErrorPropertyPermissionDeniedPtr;
|
||||
|
||||
/// \class PcpErrorPropertyPermissionDenied
|
||||
///
|
||||
/// Layers with illegal opinions about private properties.
|
||||
///
|
||||
class PcpErrorPropertyPermissionDenied : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorPropertyPermissionDeniedPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorPropertyPermissionDenied();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
SdfPath propPath;
|
||||
SdfSpecType propType;
|
||||
std::string layerPath;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorPropertyPermissionDenied();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorSublayerCycle;
|
||||
typedef std::shared_ptr<PcpErrorSublayerCycle> PcpErrorSublayerCyclePtr;
|
||||
|
||||
/// \class PcpErrorSublayerCycle
|
||||
///
|
||||
/// Layers that recursively sublayer themselves.
|
||||
///
|
||||
class PcpErrorSublayerCycle : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorSublayerCyclePtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorSublayerCycle();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
SdfLayerHandle layer;
|
||||
SdfLayerHandle sublayer;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorSublayerCycle();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorTargetPermissionDenied;
|
||||
typedef std::shared_ptr<PcpErrorTargetPermissionDenied>
|
||||
PcpErrorTargetPermissionDeniedPtr;
|
||||
|
||||
/// \class PcpErrorTargetPermissionDenied
|
||||
///
|
||||
/// Paths with illegal opinions about private targets.
|
||||
///
|
||||
class PcpErrorTargetPermissionDenied : public PcpErrorTargetPathBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorTargetPermissionDeniedPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorTargetPermissionDenied();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorTargetPermissionDenied();
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Forward declarations:
|
||||
class PcpErrorUnresolvedPrimPath;
|
||||
typedef std::shared_ptr<PcpErrorUnresolvedPrimPath>
|
||||
PcpErrorUnresolvedPrimPathPtr;
|
||||
|
||||
/// \class PcpErrorUnresolvedPrimPath
|
||||
///
|
||||
/// Asset paths that could not be both resolved and loaded.
|
||||
///
|
||||
class PcpErrorUnresolvedPrimPath : public PcpErrorBase {
|
||||
public:
|
||||
/// Returns a new error object.
|
||||
static PcpErrorUnresolvedPrimPathPtr New();
|
||||
/// Destructor.
|
||||
PCP_API ~PcpErrorUnresolvedPrimPath();
|
||||
/// Converts error to string message.
|
||||
PCP_API virtual std::string ToString() const;
|
||||
|
||||
/// The site where the invalid arc was expressed.
|
||||
PcpSiteStr site;
|
||||
SdfPath unresolvedPath;
|
||||
PcpArcType arcType;
|
||||
|
||||
private:
|
||||
/// Constructor is private. Use New() instead.
|
||||
PcpErrorUnresolvedPrimPath();
|
||||
};
|
||||
|
||||
/// Raise the given errors as runtime errors.
|
||||
PCP_API
|
||||
void PcpRaiseErrors(const PcpErrorVector &errors);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_ERRORS_H
|
||||
@@ -0,0 +1,133 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_INSTANCE_KEY_H
|
||||
#define PXR_USD_PCP_INSTANCE_KEY_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/mapExpression.h"
|
||||
#include "pxr/usd/pcp/node.h"
|
||||
#include "pxr/usd/pcp/site.h"
|
||||
#include "pxr/usd/pcp/types.h"
|
||||
|
||||
#include "pxr/usd/sdf/layerOffset.h"
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class PcpPrimIndex;
|
||||
|
||||
/// \class PcpInstanceKey
|
||||
///
|
||||
/// A PcpInstanceKey identifies instanceable prim indexes that share the
|
||||
/// same set of opinions. Instanceable prim indexes with equal instance
|
||||
/// keys are guaranteed to have the same opinions for name children and
|
||||
/// properties beneath those name children. They are NOT guaranteed to have
|
||||
/// the same opinions for direct properties of the prim indexes themselves.
|
||||
///
|
||||
class PcpInstanceKey
|
||||
{
|
||||
public:
|
||||
PCP_API
|
||||
PcpInstanceKey();
|
||||
|
||||
/// Create an instance key for the given prim index.
|
||||
PCP_API
|
||||
explicit PcpInstanceKey(const PcpPrimIndex& primIndex);
|
||||
|
||||
/// Comparison operators
|
||||
PCP_API
|
||||
bool operator==(const PcpInstanceKey& rhs) const;
|
||||
PCP_API
|
||||
bool operator!=(const PcpInstanceKey& rhs) const;
|
||||
|
||||
/// Returns hash value for this instance key.
|
||||
friend size_t hash_value(const PcpInstanceKey& key)
|
||||
{
|
||||
return key._hash;
|
||||
}
|
||||
|
||||
/// \struct Hash
|
||||
///
|
||||
/// Hash functor.
|
||||
///
|
||||
struct Hash {
|
||||
inline size_t operator()(const PcpInstanceKey& key) const
|
||||
{
|
||||
return key._hash;
|
||||
}
|
||||
};
|
||||
|
||||
/// Returns string representation of this instance key
|
||||
/// for debugging purposes.
|
||||
PCP_API
|
||||
std::string GetString() const;
|
||||
|
||||
private:
|
||||
struct _Collector;
|
||||
|
||||
struct _Arc
|
||||
{
|
||||
explicit _Arc(const PcpNodeRef& node)
|
||||
: _arcType(node.GetArcType())
|
||||
, _sourceSite(node.GetSite())
|
||||
, _timeOffset(node.GetMapToRoot().GetTimeOffset())
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const _Arc& rhs) const
|
||||
{
|
||||
return _arcType == rhs._arcType &&
|
||||
_sourceSite == rhs._sourceSite &&
|
||||
_timeOffset == rhs._timeOffset;
|
||||
}
|
||||
|
||||
size_t GetHash() const
|
||||
{
|
||||
size_t hash = _arcType;
|
||||
boost::hash_combine(hash, _sourceSite);
|
||||
boost::hash_combine(hash, _timeOffset.GetHash());
|
||||
return hash;
|
||||
}
|
||||
|
||||
PcpArcType _arcType;
|
||||
PcpSite _sourceSite;
|
||||
SdfLayerOffset _timeOffset;
|
||||
};
|
||||
std::vector<_Arc> _arcs;
|
||||
|
||||
typedef std::pair<std::string, std::string> _VariantSelection;
|
||||
std::vector<_VariantSelection> _variantSelection;
|
||||
|
||||
size_t _hash;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_INSTANCE_KEY_H
|
||||
@@ -0,0 +1,347 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_ITERATOR_H
|
||||
#define PXR_USD_PCP_ITERATOR_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/node.h"
|
||||
|
||||
#include "pxr/usd/sdf/primSpec.h"
|
||||
#include "pxr/usd/sdf/propertySpec.h"
|
||||
#include "pxr/usd/sdf/site.h"
|
||||
|
||||
#include "pxr/base/tf/iterator.h"
|
||||
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/iterator/reverse_iterator.hpp>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class PcpPrimIndex;
|
||||
class PcpPrimIndex_Graph;
|
||||
class PcpPropertyIndex;
|
||||
|
||||
/// \class PcpNodeIterator
|
||||
///
|
||||
/// Object used to iterate over nodes in the prim index graph in strong-to-weak
|
||||
/// order.
|
||||
///
|
||||
class PcpNodeIterator
|
||||
: public boost::iterator_facade<
|
||||
/* Derived = */ PcpNodeIterator,
|
||||
/* ValueType = */ PcpNodeRef,
|
||||
/* Category = */ boost::random_access_traversal_tag,
|
||||
/* RefType = */ PcpNodeRef
|
||||
>
|
||||
{
|
||||
public:
|
||||
/// Constructs an invalid iterator.
|
||||
PcpNodeIterator() : _graph(0), _nodeIdx(PCP_INVALID_INDEX) {}
|
||||
|
||||
// Returns a compressed Sd site. For internal use only.
|
||||
Pcp_CompressedSdSite GetCompressedSdSite(size_t layerIndex) const
|
||||
{
|
||||
return Pcp_CompressedSdSite(_nodeIdx, layerIndex);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class PcpPrimIndex;
|
||||
PcpNodeIterator(PcpPrimIndex_Graph* graph, size_t nodeIdx) :
|
||||
_graph(graph), _nodeIdx(nodeIdx) {}
|
||||
|
||||
friend class boost::iterator_core_access;
|
||||
|
||||
void increment() { ++_nodeIdx; }
|
||||
void decrement() { --_nodeIdx; }
|
||||
void advance(difference_type n) { _nodeIdx += n; }
|
||||
difference_type distance_to(const PcpNodeIterator& other) const {
|
||||
return (difference_type)(other._nodeIdx) - _nodeIdx;
|
||||
}
|
||||
bool equal(const PcpNodeIterator& other) const {
|
||||
return (_graph == other._graph) & (_nodeIdx == other._nodeIdx);
|
||||
}
|
||||
reference dereference() const {
|
||||
return PcpNodeRef(_graph, _nodeIdx);
|
||||
}
|
||||
|
||||
private:
|
||||
PcpPrimIndex_Graph* _graph;
|
||||
size_t _nodeIdx;
|
||||
};
|
||||
|
||||
/// \class PcpNodeReverseIterator
|
||||
///
|
||||
/// Object used to iterate over nodes in the prim index graph in weak-to-strong
|
||||
/// order.
|
||||
///
|
||||
class PcpNodeReverseIterator
|
||||
: public boost::reverse_iterator<PcpNodeIterator>
|
||||
{
|
||||
public:
|
||||
PcpNodeReverseIterator() { }
|
||||
explicit PcpNodeReverseIterator(const PcpNodeIterator& iter)
|
||||
: boost::reverse_iterator<PcpNodeIterator>(iter) { }
|
||||
};
|
||||
|
||||
/// \class PcpPrimIterator
|
||||
///
|
||||
/// Object used to iterate over prim specs in the prim index graph in
|
||||
/// strong-to-weak order.
|
||||
///
|
||||
class PcpPrimIterator
|
||||
: public boost::iterator_facade<
|
||||
/* Derived = */ PcpPrimIterator,
|
||||
/* Value = */ SdfSite,
|
||||
/* Category = */ boost::random_access_traversal_tag,
|
||||
/* Ref = */ SdfSite
|
||||
>
|
||||
{
|
||||
public:
|
||||
/// Constructs an invalid iterator.
|
||||
PCP_API
|
||||
PcpPrimIterator();
|
||||
|
||||
/// Constructs a prim iterator beginning at position \p pos in the
|
||||
/// prim stack of prim index \p primIndex.
|
||||
PCP_API
|
||||
PcpPrimIterator(const PcpPrimIndex* primIndex, size_t pos);
|
||||
|
||||
/// Returns the PcpNode from which the current prim originated.
|
||||
PCP_API
|
||||
PcpNodeRef GetNode() const;
|
||||
|
||||
// Returns the \c Pcp_SdSiteRef from which the current prim originated.
|
||||
// For internal use only.
|
||||
PCP_API
|
||||
Pcp_SdSiteRef _GetSiteRef() const;
|
||||
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
PCP_API
|
||||
void increment();
|
||||
PCP_API
|
||||
void decrement();
|
||||
PCP_API
|
||||
void advance(difference_type n);
|
||||
PCP_API
|
||||
difference_type distance_to(const PcpPrimIterator& other) const;
|
||||
PCP_API
|
||||
bool equal(const PcpPrimIterator& other) const;
|
||||
PCP_API
|
||||
reference dereference() const;
|
||||
|
||||
private:
|
||||
const PcpPrimIndex* _primIndex;
|
||||
size_t _pos;
|
||||
};
|
||||
|
||||
/// \class PcpPrimReverseIterator
|
||||
///
|
||||
/// Object used to iterate over prim specs in the prim index graph in
|
||||
/// weak-to-strong order.
|
||||
///
|
||||
class PcpPrimReverseIterator
|
||||
: public boost::reverse_iterator<PcpPrimIterator>
|
||||
{
|
||||
public:
|
||||
PcpPrimReverseIterator() { }
|
||||
explicit PcpPrimReverseIterator(const PcpPrimIterator& iter)
|
||||
: boost::reverse_iterator<PcpPrimIterator>(iter) { }
|
||||
|
||||
PcpNodeRef GetNode() const
|
||||
{
|
||||
PcpPrimIterator tmp = base();
|
||||
return (--tmp).GetNode();
|
||||
}
|
||||
|
||||
Pcp_SdSiteRef _GetSiteRef() const
|
||||
{
|
||||
PcpPrimIterator tmp = base();
|
||||
return (--tmp)._GetSiteRef();
|
||||
}
|
||||
};
|
||||
|
||||
/// \class PcpPropertyIterator
|
||||
///
|
||||
/// Object used to iterate over property specs in a property index in
|
||||
/// strong-to-weak order.
|
||||
///
|
||||
class PcpPropertyIterator
|
||||
: public boost::iterator_facade<
|
||||
/* Derived = */ PcpPropertyIterator,
|
||||
/* Value = */ const SdfPropertySpecHandle,
|
||||
/* Category = */ boost::random_access_traversal_tag
|
||||
>
|
||||
{
|
||||
public:
|
||||
/// Constructs an invalid iterator.
|
||||
PCP_API
|
||||
PcpPropertyIterator();
|
||||
|
||||
/// Constructs a property iterator for \p index beginning at position
|
||||
/// \p pos in the property stack.
|
||||
PCP_API
|
||||
PcpPropertyIterator(const PcpPropertyIndex& index, size_t pos = 0);
|
||||
|
||||
/// Returns the PcpNode from which the current property originated.
|
||||
PCP_API
|
||||
PcpNodeRef GetNode() const;
|
||||
|
||||
/// Returns true if the current property is local to the owning
|
||||
/// property index's layer stack, false otherwise.
|
||||
PCP_API
|
||||
bool IsLocal() const;
|
||||
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
PCP_API
|
||||
void increment();
|
||||
PCP_API
|
||||
void decrement();
|
||||
PCP_API
|
||||
void advance(difference_type n);
|
||||
PCP_API
|
||||
difference_type distance_to(const PcpPropertyIterator& other) const;
|
||||
PCP_API
|
||||
bool equal(const PcpPropertyIterator& other) const;
|
||||
PCP_API
|
||||
reference dereference() const;
|
||||
|
||||
private:
|
||||
const PcpPropertyIndex* _propertyIndex;
|
||||
size_t _pos;
|
||||
};
|
||||
|
||||
/// \class PcpPropertyReverseIterator
|
||||
///
|
||||
/// Object used to iterate over property specs in a property index in
|
||||
/// weak-to-strong order.
|
||||
///
|
||||
class PcpPropertyReverseIterator
|
||||
: public boost::reverse_iterator<PcpPropertyIterator>
|
||||
{
|
||||
public:
|
||||
PcpPropertyReverseIterator() { }
|
||||
explicit PcpPropertyReverseIterator(const PcpPropertyIterator& iter)
|
||||
: boost::reverse_iterator<PcpPropertyIterator>(iter) { }
|
||||
|
||||
PcpNodeRef GetNode() const
|
||||
{
|
||||
PcpPropertyIterator tmp = base();
|
||||
return (--tmp).GetNode();
|
||||
}
|
||||
|
||||
bool IsLocal() const
|
||||
{
|
||||
PcpPropertyIterator tmp = base();
|
||||
return (--tmp).IsLocal();
|
||||
}
|
||||
};
|
||||
|
||||
// Helper macro for defining iterator ranges, which are simply pairs of
|
||||
// iterators denoting the [start, end) of a series of values. These ranges
|
||||
// may be used with TF_FOR_ALL and TF_REVERSE_FOR_ALL.
|
||||
#define PCP_DEFINE_RANGE(Range, Iterator, ReverseIterator) \
|
||||
typedef std::pair<Iterator, Iterator> Range; \
|
||||
\
|
||||
inline Iterator begin(Range &range) { return range.first; } \
|
||||
inline Iterator begin(const Range &range) { return range.first; } \
|
||||
inline Iterator end(Range &range) { return range.second; } \
|
||||
inline Iterator end(const Range &range) { return range.second; } \
|
||||
\
|
||||
template <> \
|
||||
struct Tf_IteratorInterface<Range, false> { \
|
||||
typedef Iterator IteratorType; \
|
||||
static IteratorType Begin(Range &c) { return c.first; } \
|
||||
static IteratorType End(Range &c) { return c.second; } \
|
||||
}; \
|
||||
\
|
||||
template <> \
|
||||
struct Tf_IteratorInterface<const Range, false> { \
|
||||
typedef Iterator IteratorType; \
|
||||
static IteratorType Begin(Range const &c) { return c.first; } \
|
||||
static IteratorType End(Range const &c) { return c.second; } \
|
||||
}; \
|
||||
\
|
||||
template <> \
|
||||
struct Tf_IteratorInterface<Range, true> { \
|
||||
typedef ReverseIterator IteratorType; \
|
||||
static IteratorType Begin(Range &c) \
|
||||
{ return IteratorType(c.second); } \
|
||||
static IteratorType End(Range &c) \
|
||||
{ return IteratorType(c.first); } \
|
||||
}; \
|
||||
\
|
||||
template <> \
|
||||
struct Tf_IteratorInterface<const Range, true> { \
|
||||
typedef ReverseIterator IteratorType; \
|
||||
static IteratorType Begin(Range const &c) \
|
||||
{ return IteratorType(c.second); } \
|
||||
static IteratorType End(Range const &c) \
|
||||
{ return IteratorType(c.first); } \
|
||||
}; \
|
||||
\
|
||||
template <> \
|
||||
struct Tf_ShouldIterateOverCopy<Range> : boost::true_type {}; \
|
||||
\
|
||||
template <> \
|
||||
struct Tf_ShouldIterateOverCopy<const Range> : boost::true_type {}
|
||||
|
||||
PCP_DEFINE_RANGE(PcpNodeRange, PcpNodeIterator, PcpNodeReverseIterator);
|
||||
PCP_DEFINE_RANGE(PcpPrimRange, PcpPrimIterator, PcpPrimReverseIterator);
|
||||
PCP_DEFINE_RANGE(PcpPropertyRange, PcpPropertyIterator,
|
||||
PcpPropertyReverseIterator);
|
||||
|
||||
/// \class PcpIteratorTraits
|
||||
///
|
||||
/// Traits class for retrieving useful characteristics about one of the
|
||||
/// Pcp iterator types above.
|
||||
///
|
||||
template <class Iterator> struct PcpIteratorTraits;
|
||||
|
||||
template <>
|
||||
struct PcpIteratorTraits<PcpNodeIterator>
|
||||
{
|
||||
typedef PcpNodeRange RangeType;
|
||||
typedef PcpNodeReverseIterator ReverseIteratorType;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PcpIteratorTraits<PcpPrimIterator>
|
||||
{
|
||||
typedef PcpPrimRange RangeType;
|
||||
typedef PcpPrimReverseIterator ReverseIteratorType;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct PcpIteratorTraits<PcpPropertyIterator>
|
||||
{
|
||||
typedef PcpPropertyRange RangeType;
|
||||
typedef PcpPropertyReverseIterator ReverseIteratorType;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_ITERATOR_H
|
||||
@@ -0,0 +1,72 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_LAYER_PREFETCH_REQUEST_H
|
||||
#define PXR_USD_PCP_LAYER_PREFETCH_REQUEST_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/sdf/layer.h"
|
||||
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class Pcp_MutedLayers;
|
||||
|
||||
/// \class PcpLayerPrefetchRequest
|
||||
///
|
||||
/// PcpLayerPrefetchRequest represents a request to pre-fetch and retain
|
||||
/// a set of layers in memory. It performs the fetch as a parallel
|
||||
/// operation using a thread pool. Fetched layers are retained by the
|
||||
/// request to keep them alive until the client can decide what to do
|
||||
/// with them.
|
||||
///
|
||||
class PcpLayerPrefetchRequest
|
||||
{
|
||||
public:
|
||||
/// Enqueue a request to pre-fetch of the sublayers of \a layer.
|
||||
/// This recursively includes any nested sublayers. Arguments in \a args
|
||||
/// will be passed to Sdf when finding or opening sublayers.
|
||||
PCP_API
|
||||
void RequestSublayerStack(
|
||||
const SdfLayerRefPtr &layer,
|
||||
const SdfLayer::FileFormatArguments &args);
|
||||
|
||||
/// Run the queued requests, returning when complete.
|
||||
PCP_API
|
||||
void Run(const Pcp_MutedLayers& mutedLayers);
|
||||
|
||||
private:
|
||||
// The request object retains both the layer requests and
|
||||
// the pre-fetched sublayers.
|
||||
typedef std::pair<SdfLayerRefPtr, SdfLayer::FileFormatArguments> _Request;
|
||||
std::set<_Request> _sublayerRequests;
|
||||
|
||||
std::set<SdfLayerRefPtr> _retainedLayers;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_LAYER_PREFETCH_REQUEST_H
|
||||
@@ -0,0 +1,353 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_LAYER_STACK_H
|
||||
#define PXR_USD_PCP_LAYER_STACK_H
|
||||
|
||||
/// \file pcp/layerStack.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/errors.h"
|
||||
#include "pxr/usd/pcp/layerStackIdentifier.h"
|
||||
#include "pxr/usd/pcp/mapExpression.h"
|
||||
#include "pxr/usd/sdf/layerTree.h"
|
||||
#include "pxr/base/tf/declarePtrs.h"
|
||||
|
||||
#include <tbb/spin_mutex.h>
|
||||
#include <iosfwd>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
TF_DECLARE_REF_PTRS(SdfLayer);
|
||||
TF_DECLARE_WEAK_AND_REF_PTRS(PcpLayerStack);
|
||||
TF_DECLARE_WEAK_AND_REF_PTRS(Pcp_LayerStackRegistry);
|
||||
|
||||
class ArResolverContext;
|
||||
class Pcp_LayerStackRegistry;
|
||||
class Pcp_MutedLayers;
|
||||
class PcpLayerStackChanges;
|
||||
class PcpLifeboat;
|
||||
|
||||
/// \class PcpLayerStack
|
||||
///
|
||||
/// Represents a stack of layers that contribute opinions to composition.
|
||||
///
|
||||
/// Each PcpLayerStack is identified by a PcpLayerStackIdentifier. This
|
||||
/// identifier contains all of the parameters needed to construct a layer stack,
|
||||
/// such as the root layer, session layer, and path resolver context.
|
||||
///
|
||||
/// PcpLayerStacks are constructed and managed by a Pcp_LayerStackRegistry.
|
||||
///
|
||||
class PcpLayerStack : public TfRefBase, public TfWeakBase {
|
||||
PcpLayerStack(const PcpLayerStack&) = delete;
|
||||
PcpLayerStack& operator=(const PcpLayerStack&) = delete;
|
||||
|
||||
public:
|
||||
// See Pcp_LayerStackRegistry for creating layer stacks.
|
||||
PCP_API
|
||||
virtual ~PcpLayerStack();
|
||||
|
||||
/// Returns the identifier for this layer stack.
|
||||
PCP_API
|
||||
const PcpLayerStackIdentifier& GetIdentifier() const;
|
||||
|
||||
/// Returns the layers in this layer stack in strong-to-weak order.
|
||||
/// Note that this is only the *local* layer stack -- it does not
|
||||
/// include any layers brought in by references inside prims.
|
||||
PCP_API
|
||||
const SdfLayerRefPtrVector& GetLayers() const;
|
||||
|
||||
/// Returns only the session layers in the layer stack in strong-to-weak
|
||||
/// order.
|
||||
PCP_API
|
||||
SdfLayerHandleVector GetSessionLayers() const;
|
||||
|
||||
/// Returns the layer tree representing the structure of this layer
|
||||
/// stack.
|
||||
PCP_API
|
||||
const SdfLayerTreeHandle& GetLayerTree() const;
|
||||
|
||||
/// Returns the layer offset for the given layer, or NULL if the layer
|
||||
/// can't be found or is the identity.
|
||||
PCP_API
|
||||
const SdfLayerOffset* GetLayerOffsetForLayer(const SdfLayerHandle&) const;
|
||||
|
||||
/// Return the layer offset for the given layer, or NULL if the layer
|
||||
/// can't be found or is the identity.
|
||||
PCP_API
|
||||
const SdfLayerOffset* GetLayerOffsetForLayer(const SdfLayerRefPtr&) const;
|
||||
|
||||
/// Returns the layer offset for the layer at the given index in this
|
||||
/// layer stack. Returns NULL if the offset is the identity.
|
||||
PCP_API
|
||||
const SdfLayerOffset* GetLayerOffsetForLayer(size_t layerIdx) const;
|
||||
|
||||
/// Returns the set of layers that were muted in this layer
|
||||
/// stack.
|
||||
PCP_API
|
||||
const std::set<std::string>& GetMutedLayers() const;
|
||||
|
||||
/// Return the list of errors local to this layer stack.
|
||||
PcpErrorVector GetLocalErrors() const {
|
||||
return _localErrors ? *_localErrors.get() : PcpErrorVector();
|
||||
}
|
||||
|
||||
/// Returns true if this layer stack contains the given layer, false
|
||||
/// otherwise.
|
||||
PCP_API
|
||||
bool HasLayer(const SdfLayerHandle& layer) const;
|
||||
PCP_API
|
||||
bool HasLayer(const SdfLayerRefPtr& layer) const;
|
||||
|
||||
/// Return the time codes per second value of the layer stack. This is
|
||||
/// usually the same as the computed time codes per second of the root layer
|
||||
/// but may be computed from the session layer when its present.
|
||||
double GetTimeCodesPerSecond() const { return _timeCodesPerSecond; }
|
||||
|
||||
/// Returns relocation source-to-target mapping for this layer stack.
|
||||
///
|
||||
/// This map combines the individual relocation entries found across
|
||||
/// all layers in this layer stack; multiple entries that affect a single
|
||||
/// prim will be combined into a single entry. For instance, if this
|
||||
/// layer stack contains relocations { /A: /B } and { /A/C: /A/D }, this
|
||||
/// map will contain { /A: /B } and { /B/C: /B/D }. This allows consumers
|
||||
/// to go from unrelocated namespace to relocated namespace in a single
|
||||
/// step.
|
||||
PCP_API
|
||||
const SdfRelocatesMap& GetRelocatesSourceToTarget() const;
|
||||
|
||||
/// Returns relocation target-to-source mapping for this layer stack.
|
||||
///
|
||||
/// See GetRelocatesSourceToTarget for more details.
|
||||
PCP_API
|
||||
const SdfRelocatesMap& GetRelocatesTargetToSource() const;
|
||||
|
||||
/// Returns incremental relocation source-to-target mapping for this layer
|
||||
/// stack.
|
||||
///
|
||||
/// This map contains the individual relocation entries found across
|
||||
/// all layers in this layer stack; it does not combine ancestral
|
||||
/// entries with descendant entries. For instance, if this
|
||||
/// layer stack contains relocations { /A: /B } and { /A/C: /A/D }, this
|
||||
/// map will contain { /A: /B } and { /A/C: /A/D }.
|
||||
PCP_API
|
||||
const SdfRelocatesMap& GetIncrementalRelocatesSourceToTarget() const;
|
||||
|
||||
/// Returns incremental relocation target-to-source mapping for this layer
|
||||
/// stack.
|
||||
///
|
||||
/// See GetIncrementalRelocatesTargetToSource for more details.
|
||||
PCP_API
|
||||
const SdfRelocatesMap& GetIncrementalRelocatesTargetToSource() const;
|
||||
|
||||
/// Returns a list of paths to all prims across all layers in this
|
||||
/// layer stack that contained relocates.
|
||||
PCP_API
|
||||
const SdfPathVector& GetPathsToPrimsWithRelocates() const;
|
||||
|
||||
/// Apply the changes in \p changes. This blows caches. It's up to
|
||||
/// the client to pull on those caches again as needed.
|
||||
///
|
||||
/// Objects that are no longer needed and would be destroyed are
|
||||
/// retained in \p lifeboat and won't be destroyed until \p lifeboat is
|
||||
/// itself destroyed. This gives the client control over the timing
|
||||
/// of the destruction of those objects. Clients may choose to pull
|
||||
/// on the caches before destroying \p lifeboat. That may cause the
|
||||
/// caches to again retain the objects, meaning they won't be destroyed
|
||||
/// when \p lifeboat is destroyed.
|
||||
///
|
||||
/// For example, if blowing a cache means an SdfLayer is no longer
|
||||
/// needed then \p lifeboat will hold an SdfLayerRefPtr to that layer.
|
||||
/// The client can then pull on that cache, which could cause the
|
||||
/// cache to hold an SdfLayerRefPtr to the layer again. If so then
|
||||
/// destroying \p changes will not destroy the layer. In any case,
|
||||
/// we don't destroy the layer and then read it again. However, if
|
||||
/// the client destroys \p lifeboat before pulling on the cache then
|
||||
/// we would destroy the layer then read it again.
|
||||
PCP_API
|
||||
void Apply(const PcpLayerStackChanges& changes, PcpLifeboat* lifeboat);
|
||||
|
||||
/// Return a PcpMapExpression representing the relocations that affect
|
||||
/// namespace at and below the given path. The value of this
|
||||
/// expression will continue to track the effective relocations if
|
||||
/// they are changed later.
|
||||
PCP_API
|
||||
PcpMapExpression GetExpressionForRelocatesAtPath(const SdfPath &path);
|
||||
|
||||
private:
|
||||
// Only a registry can create a layer stack.
|
||||
friend class Pcp_LayerStackRegistry;
|
||||
// PcpCache needs access to check the _registry.
|
||||
friend class PcpCache;
|
||||
// Needs access to _sublayerSourceInfo
|
||||
friend bool Pcp_NeedToRecomputeDueToAssetPathChange(const PcpLayerStackPtr&);
|
||||
|
||||
// It's a coding error to construct a layer stack with a NULL root layer.
|
||||
PcpLayerStack(const PcpLayerStackIdentifier &identifier,
|
||||
const std::string &fileFormatTarget,
|
||||
const Pcp_MutedLayers &mutedLayers,
|
||||
bool isUsd);
|
||||
|
||||
void _BlowLayers();
|
||||
void _BlowRelocations();
|
||||
void _Compute(const std::string &fileFormatTarget,
|
||||
const Pcp_MutedLayers &mutedLayers);
|
||||
|
||||
SdfLayerTreeHandle _BuildLayerStack(
|
||||
const SdfLayerHandle & layer,
|
||||
const SdfLayerOffset & offset,
|
||||
double layerTcps,
|
||||
const ArResolverContext & pathResolverContext,
|
||||
const SdfLayer::FileFormatArguments & layerArgs,
|
||||
const std::string & sessionOwner,
|
||||
const Pcp_MutedLayers & mutedLayers,
|
||||
SdfLayerHandleSet *seenLayers,
|
||||
PcpErrorVector *errors);
|
||||
|
||||
private:
|
||||
/// The identifier that uniquely identifies this layer stack.
|
||||
const PcpLayerStackIdentifier _identifier;
|
||||
/// The registry (1:1 with a PcpCache) this layer stack belongs to. This
|
||||
/// may not be set, particularly when a registry is creating a layer stack
|
||||
/// but before it's been installed in the registry.
|
||||
Pcp_LayerStackRegistryPtr _registry;
|
||||
|
||||
/// Data representing the computed layer stack contents.
|
||||
///
|
||||
/// This is built by examining the session and root layers for
|
||||
/// sublayers, resolving their asset paths with the path resolver context,
|
||||
/// and recursively building up the layer stack.
|
||||
///
|
||||
/// Note that this is only the *local* layer stack -- it does not
|
||||
/// include any layers brought in by references inside prims.
|
||||
|
||||
/// Retained references to the layers in the stack,
|
||||
/// in strong-to-weak order.
|
||||
SdfLayerRefPtrVector _layers;
|
||||
|
||||
/// The corresponding map functions for each entry in 'layers'.
|
||||
/// Each map function contains a time offset that should be applied
|
||||
/// to its corresponding layer.
|
||||
std::vector<PcpMapFunction> _mapFunctions;
|
||||
|
||||
/// Stores the computed time codes per second value of the layer stack which
|
||||
/// has some special logic when a session layer is present.
|
||||
double _timeCodesPerSecond;
|
||||
|
||||
/// The tree structure of the layer stack.
|
||||
/// Stored separately because this is needed only occasionally.
|
||||
SdfLayerTreeHandle _layerTree;
|
||||
|
||||
/// Tracks information used to compute sublayer asset paths.
|
||||
struct _SublayerSourceInfo {
|
||||
_SublayerSourceInfo(
|
||||
const SdfLayerHandle& layer_,
|
||||
const std::string& authoredSublayerPath_,
|
||||
const std::string& computedSublayerPath_)
|
||||
: layer(layer_)
|
||||
, authoredSublayerPath(authoredSublayerPath_)
|
||||
, computedSublayerPath(computedSublayerPath_) { }
|
||||
|
||||
SdfLayerHandle layer;
|
||||
std::string authoredSublayerPath;
|
||||
std::string computedSublayerPath;
|
||||
};
|
||||
|
||||
/// List of source info for sublayer asset path computations.
|
||||
std::vector<_SublayerSourceInfo> _sublayerSourceInfo;
|
||||
|
||||
/// Set of asset paths that were muted in this layer stack.
|
||||
std::set<std::string> _mutedAssetPaths;
|
||||
|
||||
/// The errors, if any, discovered while computing this layer stack.
|
||||
/// NULL if no errors were found (the expected common case).
|
||||
std::unique_ptr<PcpErrorVector> _localErrors;
|
||||
|
||||
/// Pre-computed table of local relocates.
|
||||
SdfRelocatesMap _relocatesSourceToTarget;
|
||||
SdfRelocatesMap _relocatesTargetToSource;
|
||||
SdfRelocatesMap _incrementalRelocatesSourceToTarget;
|
||||
SdfRelocatesMap _incrementalRelocatesTargetToSource;
|
||||
|
||||
/// A map of PcpMapExpressions::Variable instances used to represent
|
||||
/// the current value of relocations given out by
|
||||
/// GetExpressionForRelocatesAtPath(). This map is used to update
|
||||
/// those values when relocations change.
|
||||
typedef std::map<SdfPath, PcpMapExpression::VariableUniquePtr,
|
||||
SdfPath::FastLessThan> _RelocatesVarMap;
|
||||
_RelocatesVarMap _relocatesVariables;
|
||||
tbb::spin_mutex _relocatesVariablesMutex;
|
||||
|
||||
/// List of all prim spec paths where relocations were found.
|
||||
SdfPathVector _relocatesPrimPaths;
|
||||
|
||||
bool _isUsd;
|
||||
};
|
||||
|
||||
PCP_API
|
||||
std::ostream& operator<<(std::ostream&, const PcpLayerStackPtr&);
|
||||
PCP_API
|
||||
std::ostream& operator<<(std::ostream&, const PcpLayerStackRefPtr&);
|
||||
|
||||
/// Compose the relocation arcs in the given stack of layers,
|
||||
/// putting the results into the given sourceToTarget and targetToSource
|
||||
/// maps.
|
||||
void
|
||||
Pcp_ComputeRelocationsForLayerStack(
|
||||
const SdfLayerRefPtrVector & layers,
|
||||
SdfRelocatesMap *relocatesSourceToTarget,
|
||||
SdfRelocatesMap *relocatesTargetToSource,
|
||||
SdfRelocatesMap *incrementalRelocatesSourceToTarget,
|
||||
SdfRelocatesMap *incrementalRelocatesTargetToSource,
|
||||
SdfPathVector *relocatesPrimPaths);
|
||||
|
||||
// Returns true if \p layerStack should be recomputed due to changes to
|
||||
// any computed asset paths that were used to find or open layers
|
||||
// when originally composing \p layerStack. This may be due to scene
|
||||
// description changes or external changes to asset resolution that
|
||||
// may affect the computation of those asset paths.
|
||||
bool
|
||||
Pcp_NeedToRecomputeDueToAssetPathChange(const PcpLayerStackPtr& layerStack);
|
||||
|
||||
// Returns true if the \p layerStack should be recomputed because
|
||||
// \p changedLayer has had changes that would cause the layer stack to have
|
||||
// a different computed overall time codes per second value.
|
||||
bool
|
||||
Pcp_NeedToRecomputeLayerStackTimeCodesPerSecond(
|
||||
const PcpLayerStackPtr& layerStack, const SdfLayerHandle &changedLayer);
|
||||
|
||||
/// Returns true when the environment variable has been set to disable the
|
||||
/// behavior where differing time codes per second metadata in layers sublayered
|
||||
/// or referenced by another layer are used to apply a layer offset scale to the
|
||||
/// map function.
|
||||
PCP_API
|
||||
bool
|
||||
PcpIsTimeScalingForLayerTimeCodesPerSecondDisabled();
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_LAYER_STACK_H
|
||||
@@ -0,0 +1,220 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_LAYER_STACK_IDENTIFIER_H
|
||||
#define PXR_USD_PCP_LAYER_STACK_IDENTIFIER_H
|
||||
|
||||
/// \file pcp/layerStackIdentifier.h
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/sdf/declareHandles.h"
|
||||
#include "pxr/usd/ar/resolverContext.h"
|
||||
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
#include <iosfwd>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
SDF_DECLARE_HANDLES(SdfLayer);
|
||||
|
||||
/// \class PcpLayerStackIdentifier
|
||||
///
|
||||
/// Arguments used to identify a layer stack.
|
||||
///
|
||||
/// Objects of this type are immutable.
|
||||
///
|
||||
class PcpLayerStackIdentifier :
|
||||
boost::totally_ordered<PcpLayerStackIdentifier> {
|
||||
public:
|
||||
typedef PcpLayerStackIdentifier This;
|
||||
|
||||
/// Construct with all empty pointers.
|
||||
PCP_API
|
||||
PcpLayerStackIdentifier();
|
||||
|
||||
/// Construct with given pointers. If all arguments are \c TfNullPtr
|
||||
/// then the result is identical to the default constructed object.
|
||||
PCP_API
|
||||
PcpLayerStackIdentifier(const SdfLayerHandle& rootLayer_,
|
||||
const SdfLayerHandle& sessionLayer_ = TfNullPtr,
|
||||
const ArResolverContext& pathResolverContext_ =
|
||||
ArResolverContext());
|
||||
|
||||
// XXX: Allow assignment because there are clients using this
|
||||
// as a member that themselves want to be assignable.
|
||||
PCP_API
|
||||
PcpLayerStackIdentifier& operator=(const PcpLayerStackIdentifier&);
|
||||
|
||||
// Validity.
|
||||
#if !defined(doxygen)
|
||||
typedef const size_t This::*UnspecifiedBoolType;
|
||||
#endif
|
||||
PCP_API
|
||||
operator UnspecifiedBoolType() const;
|
||||
|
||||
// Comparison.
|
||||
PCP_API
|
||||
bool operator==(const This &rhs) const;
|
||||
PCP_API
|
||||
bool operator<(const This &rhs) const;
|
||||
|
||||
// Hashing.
|
||||
struct Hash {
|
||||
size_t operator()(const This & x) const
|
||||
{
|
||||
return x.GetHash();
|
||||
}
|
||||
};
|
||||
size_t GetHash() const
|
||||
{
|
||||
return _hash;
|
||||
}
|
||||
|
||||
public:
|
||||
/// The root layer.
|
||||
const SdfLayerHandle rootLayer;
|
||||
|
||||
/// The session layer (optional).
|
||||
const SdfLayerHandle sessionLayer;
|
||||
|
||||
/// The path resolver context used for resolving asset paths. (optional)
|
||||
const ArResolverContext pathResolverContext;
|
||||
|
||||
private:
|
||||
size_t _ComputeHash() const;
|
||||
|
||||
private:
|
||||
const size_t _hash;
|
||||
};
|
||||
|
||||
|
||||
/// \class PcpLayerStackIdentifierStr
|
||||
///
|
||||
/// A "string"-based version of PcpLayerStackIdentifier. These are used in
|
||||
/// places where they should be stable wrt layer lifetimes. This is done by
|
||||
/// storing layer identifiers as strings rather than SdfLayerHandles.
|
||||
///
|
||||
class PcpLayerStackIdentifierStr :
|
||||
boost::totally_ordered<PcpLayerStackIdentifierStr> {
|
||||
public:
|
||||
typedef PcpLayerStackIdentifierStr This;
|
||||
|
||||
/// Construct with given identifier strings and context. If all arguments
|
||||
/// are empty strings and default-constructed ArResolverContext, then the
|
||||
/// result is identical to the default constructed object.
|
||||
PCP_API
|
||||
explicit PcpLayerStackIdentifierStr(
|
||||
std::string const &rootLayerId = std::string(),
|
||||
std::string const &sessionLayerId = std::string(),
|
||||
ArResolverContext const &resolverContext = ArResolverContext());
|
||||
|
||||
/// Allow implicit conversion from PcpLayerStackIdentifier
|
||||
PCP_API
|
||||
PcpLayerStackIdentifierStr(PcpLayerStackIdentifier const &lsid);
|
||||
|
||||
// Validity.
|
||||
#if !defined(doxygen)
|
||||
typedef const size_t This::*UnspecifiedBoolType;
|
||||
#endif
|
||||
PCP_API
|
||||
operator UnspecifiedBoolType() const;
|
||||
|
||||
// Comparison.
|
||||
PCP_API
|
||||
bool operator==(const This &rhs) const;
|
||||
PCP_API
|
||||
bool operator<(const This &rhs) const;
|
||||
|
||||
// Hashing.
|
||||
struct Hash {
|
||||
size_t operator()(const This & x) const
|
||||
{
|
||||
return x.GetHash();
|
||||
}
|
||||
};
|
||||
size_t GetHash() const
|
||||
{
|
||||
return _hash;
|
||||
}
|
||||
|
||||
public:
|
||||
/// The root layer.
|
||||
std::string rootLayerId;
|
||||
|
||||
/// The session layer (optional).
|
||||
std::string sessionLayerId;
|
||||
|
||||
/// The path resolver context used for resolving asset paths. (optional)
|
||||
ArResolverContext pathResolverContext;
|
||||
|
||||
private:
|
||||
size_t _ComputeHash() const;
|
||||
|
||||
private:
|
||||
size_t _hash;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
size_t
|
||||
hash_value(const PcpLayerStackIdentifier& x)
|
||||
{
|
||||
return x.GetHash();
|
||||
}
|
||||
|
||||
inline
|
||||
size_t
|
||||
hash_value(const PcpLayerStackIdentifierStr& x)
|
||||
{
|
||||
return x.GetHash();
|
||||
}
|
||||
|
||||
PCP_API
|
||||
std::ostream& operator<<(std::ostream&, const PcpLayerStackIdentifier&);
|
||||
PCP_API
|
||||
std::ostream& operator<<(std::ostream&, const PcpLayerStackIdentifierStr&);
|
||||
|
||||
/// Manipulator to cause the next PcpLayerStackIdentifier or
|
||||
/// PcpLayerStackIdentifierStr written to the ostream to write the base name of
|
||||
/// its layers, rather than the full identifier.
|
||||
PCP_API
|
||||
std::ostream& PcpIdentifierFormatBaseName(std::ostream&);
|
||||
|
||||
/// Manipulator to cause the next PcpLayerStackIdentifier or
|
||||
/// PcpLayerStackIdentifierStr written to the ostream to write the real path of
|
||||
/// its layers, rather than the identifier.
|
||||
PCP_API
|
||||
std::ostream& PcpIdentifierFormatRealPath(std::ostream&);
|
||||
|
||||
/// Manipulator to cause the next PcpLayerStackIdentifier or
|
||||
/// PcpLayerStackIdentifierStr written to the ostream to write the identifier of
|
||||
/// its layers. This is the default state; this manipulator is only to nullify
|
||||
/// one of the above manipulators.
|
||||
PCP_API
|
||||
std::ostream& PcpIdentifierFormatIdentifier(std::ostream&);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_LAYER_STACK_IDENTIFIER_H
|
||||
@@ -0,0 +1,284 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_MAP_EXPRESSION_H
|
||||
#define PXR_USD_PCP_MAP_EXPRESSION_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/mapFunction.h"
|
||||
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
|
||||
#include <tbb/atomic.h>
|
||||
#include <tbb/spin_mutex.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
/// \class PcpMapExpression
|
||||
///
|
||||
/// An expression that yields a PcpMapFunction value.
|
||||
///
|
||||
/// Expressions comprise constant values, variables, and operators
|
||||
/// applied to sub-expressions. Expressions cache their computed values
|
||||
/// internally. Assigning a new value to a variable automatically
|
||||
/// invalidates the cached values of dependent expressions. Common
|
||||
/// (sub-)expressions are automatically detected and shared.
|
||||
///
|
||||
/// PcpMapExpression exists solely to support efficient incremental
|
||||
/// handling of relocates edits. It represents a tree of the namespace
|
||||
/// mapping operations and their inputs, so we can narrowly redo the
|
||||
/// computation when one of the inputs changes.
|
||||
///
|
||||
class PcpMapExpression
|
||||
{
|
||||
public:
|
||||
/// The value type of PcpMapExpression is a PcpMapFunction.
|
||||
typedef PcpMapFunction Value;
|
||||
|
||||
/// Evaluate this expression, yielding a PcpMapFunction value.
|
||||
/// The computed result is cached.
|
||||
/// The return value is a reference to the internal cached value.
|
||||
/// The cache is automatically invalidated as needed.
|
||||
PCP_API
|
||||
const Value & Evaluate() const;
|
||||
|
||||
/// Default-construct a NULL expression.
|
||||
PCP_API
|
||||
PcpMapExpression();
|
||||
|
||||
/// Swap this expression with the other.
|
||||
PCP_API
|
||||
void Swap(PcpMapExpression &other);
|
||||
|
||||
/// Return true if this is a null expression.
|
||||
PCP_API
|
||||
bool IsNull() const;
|
||||
|
||||
/// \name Creating expressions
|
||||
/// @{
|
||||
|
||||
/// Return an expression representing PcpMapFunction::Identity().
|
||||
PCP_API
|
||||
static PcpMapExpression Identity();
|
||||
|
||||
/// Create a new constant.
|
||||
PCP_API
|
||||
static PcpMapExpression Constant( const Value & constValue );
|
||||
|
||||
/// A Variable is a mutable memory cell that holds a value.
|
||||
/// Changing a variable's value invalidates any expressions using
|
||||
/// that variable.
|
||||
class Variable {
|
||||
Variable(Variable const &) = delete;
|
||||
Variable &operator=(Variable const &) = delete;
|
||||
public:
|
||||
Variable() = default;
|
||||
virtual ~Variable();
|
||||
/// Return the current value.
|
||||
virtual const Value & GetValue() const = 0;
|
||||
/// Mutate the variable to have the new value.
|
||||
/// This will also invalidate dependant expressions.
|
||||
virtual void SetValue(Value && value) = 0;
|
||||
/// Return an expression representing the value of this variable.
|
||||
/// This lets you use the variable as a sub-term in other expressions.
|
||||
virtual PcpMapExpression GetExpression() const = 0;
|
||||
};
|
||||
|
||||
/// Variables are held by reference.
|
||||
typedef std::unique_ptr<Variable> VariableUniquePtr;
|
||||
|
||||
/// Create a new variable.
|
||||
/// The client is expected to retain the reference for as long as
|
||||
/// it wishes to continue being able to set the value of the variable.
|
||||
/// After the reference is dropped, expressions using the variable
|
||||
/// will continue to be valid, but there will be no way to further
|
||||
/// change the value of the variable.
|
||||
PCP_API
|
||||
static VariableUniquePtr NewVariable(Value && initialValue);
|
||||
|
||||
/// Create a new PcpMapExpression representing the application of
|
||||
/// f's value, followed by the application of this expression's value.
|
||||
PCP_API
|
||||
PcpMapExpression Compose(const PcpMapExpression &f) const;
|
||||
|
||||
/// Create a new PcpMapExpression representing the inverse of f.
|
||||
PCP_API
|
||||
PcpMapExpression Inverse() const;
|
||||
|
||||
/// Return a new expression representing this expression with an added
|
||||
/// (if necessary) mapping from </> to </>.
|
||||
PCP_API
|
||||
PcpMapExpression AddRootIdentity() const;
|
||||
|
||||
/// Return true if the map function is the constant identity function.
|
||||
bool IsConstantIdentity() const {
|
||||
return _node && _node->key.op == _OpConstant &&
|
||||
_node->key.valueForConstant.IsIdentity();
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Convenience API
|
||||
/// The following API just forwards through to the underlying evaluated
|
||||
/// mapfunction value.
|
||||
/// @{
|
||||
|
||||
/// Return true if the evaluated map function is the identity function.
|
||||
/// For identity, MapSourceToTarget() always returns the path unchanged.
|
||||
bool IsIdentity() const {
|
||||
return Evaluate().IsIdentity();
|
||||
}
|
||||
|
||||
/// Map a path in the source namespace to the target.
|
||||
/// If the path is not in the domain, returns an empty path.
|
||||
SdfPath MapSourceToTarget(const SdfPath &path) const {
|
||||
return Evaluate().MapSourceToTarget(path);
|
||||
}
|
||||
|
||||
/// Map a path in the target namespace to the source.
|
||||
/// If the path is not in the co-domain, returns an empty path.
|
||||
SdfPath MapTargetToSource(const SdfPath &path) const {
|
||||
return Evaluate().MapTargetToSource(path);
|
||||
}
|
||||
|
||||
/// The time offset of the mapping.
|
||||
const SdfLayerOffset &GetTimeOffset() const {
|
||||
return Evaluate().GetTimeOffset();
|
||||
}
|
||||
|
||||
/// Returns a string representation of this mapping for debugging
|
||||
/// purposes.
|
||||
std::string GetString() const {
|
||||
return Evaluate().GetString();
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
||||
private:
|
||||
// Allow Pcp_Statistics access to internal data for diagnostics.
|
||||
friend class Pcp_Statistics;
|
||||
friend struct Pcp_VariableImpl;
|
||||
|
||||
class _Node;
|
||||
typedef boost::intrusive_ptr<_Node> _NodeRefPtr;
|
||||
|
||||
explicit PcpMapExpression(const _NodeRefPtr & node) : _node(node) {}
|
||||
|
||||
private: // data
|
||||
enum _Op {
|
||||
_OpConstant,
|
||||
_OpVariable,
|
||||
_OpInverse,
|
||||
_OpCompose,
|
||||
_OpAddRootIdentity
|
||||
};
|
||||
|
||||
class _Node : public boost::noncopyable {
|
||||
public:
|
||||
// The Key holds all the state needed to uniquely identify
|
||||
// this (sub-)expression.
|
||||
struct Key {
|
||||
const _Op op;
|
||||
const _NodeRefPtr arg1, arg2;
|
||||
const Value valueForConstant;
|
||||
|
||||
Key( _Op op_,
|
||||
const _NodeRefPtr & arg1_,
|
||||
const _NodeRefPtr & arg2_,
|
||||
const Value & valueForConstant_ )
|
||||
: op(op_)
|
||||
, arg1(arg1_)
|
||||
, arg2(arg2_)
|
||||
, valueForConstant(valueForConstant_)
|
||||
{}
|
||||
inline size_t GetHash() const;
|
||||
bool operator==(const Key &key) const;
|
||||
};
|
||||
|
||||
// The Key of a node is const, and established when it is created.
|
||||
const Key key;
|
||||
|
||||
// Whether or not the expression tree up to and including this node
|
||||
// will always include an identity mapping.
|
||||
const bool expressionTreeAlwaysHasIdentity;
|
||||
|
||||
// Factory method to create new nodes.
|
||||
static _NodeRefPtr
|
||||
New( _Op op,
|
||||
const _NodeRefPtr & arg1 = _NodeRefPtr(),
|
||||
const _NodeRefPtr & arg2 = _NodeRefPtr(),
|
||||
const Value & valueForConstant = Value() );
|
||||
~_Node();
|
||||
|
||||
// Evaluate (and internally cache) the value of this node.
|
||||
const Value & EvaluateAndCache() const;
|
||||
|
||||
// For _OpVariable nodes, sets the variable's value.
|
||||
void SetValueForVariable(Value &&newValue);
|
||||
|
||||
// For _OpVariable nodes, returns the variable's value.
|
||||
const Value & GetValueForVariable() const {
|
||||
return _valueForVariable;
|
||||
}
|
||||
|
||||
private:
|
||||
explicit _Node( const Key &key_ );
|
||||
void _Invalidate();
|
||||
Value _EvaluateUncached() const;
|
||||
|
||||
// Helper to determine if the expression tree indicated by key
|
||||
// will always contains the root identity.
|
||||
static bool _ExpressionTreeAlwaysHasIdentity(const Key& key);
|
||||
|
||||
// Ref-counting ops manage _refCount.
|
||||
// Need to friend them here to have access to _refCount.
|
||||
friend PCP_API void intrusive_ptr_add_ref(_Node*);
|
||||
friend PCP_API void intrusive_ptr_release(_Node*);
|
||||
|
||||
// Registry of node instances, identified by Key.
|
||||
// Note: variable nodes are not tracked by the registry.
|
||||
struct _NodeMap;
|
||||
static TfStaticData<_NodeMap> _nodeRegistry;
|
||||
|
||||
mutable tbb::atomic<int> _refCount;
|
||||
mutable Value _cachedValue;
|
||||
mutable std::set<_Node*> _dependentExpressions;
|
||||
Value _valueForVariable;
|
||||
mutable tbb::spin_mutex _mutex;
|
||||
mutable std::atomic<bool> _hasCachedValue;
|
||||
};
|
||||
|
||||
// Need to friend them here to have visibility to private class _Node.
|
||||
friend PCP_API void intrusive_ptr_add_ref(_Node*);
|
||||
friend PCP_API void intrusive_ptr_release(_Node*);
|
||||
|
||||
_NodeRefPtr _node;
|
||||
};
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_MAP_EXPRESSION_H
|
||||
@@ -0,0 +1,309 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_MAP_FUNCTION_H
|
||||
#define PXR_USD_PCP_MAP_FUNCTION_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/sdf/path.h"
|
||||
#include "pxr/usd/sdf/layerOffset.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
/// \class PcpMapFunction
|
||||
///
|
||||
/// A function that maps values from one namespace (and time domain) to
|
||||
/// another. It represents the transformation that an arc such as a reference
|
||||
/// arc applies as it incorporates values across the arc.
|
||||
///
|
||||
/// Take the example of a reference arc, where a source path
|
||||
/// \</Model\> is referenced as a target path, \</Model_1\>.
|
||||
/// The source path \</Model\> is the source of the opinions;
|
||||
/// the target path \</Model_1\> is where they are incorporated in the scene.
|
||||
/// Values in the model that refer to paths relative to \</Model\> must be
|
||||
/// transformed to be relative to \</Model_1\> instead.
|
||||
/// The PcpMapFunction for the arc provides this service.
|
||||
///
|
||||
/// Map functions have a specific \em domain, or set of values they can
|
||||
/// operate on. Any values outside the domain cannot be mapped.
|
||||
/// The domain precisely tracks what areas of namespace can be
|
||||
/// referred to across various forms of arcs.
|
||||
///
|
||||
/// Map functions can be chained to represent a series of map
|
||||
/// operations applied in sequence. The map function represent the
|
||||
/// cumulative effect as efficiently as possible. For example, in
|
||||
/// the case of a chained reference from \</Model\> to \</Model\>
|
||||
/// to \</Model\> to \</Model_1\>, this is effectively the same as
|
||||
/// a mapping directly from \</Model\> to \</Model_1\>. Representing
|
||||
/// the cumulative effect of arcs in this way is important for
|
||||
/// handling larger scenes efficiently.
|
||||
///
|
||||
/// Map functions can be \em inverted. Formally, map functions are
|
||||
/// bijections (one-to-one and onto), which ensures that they can
|
||||
/// be inverted. Put differently, no information is lost by applying
|
||||
/// a map function to set of values within its domain; they retain
|
||||
/// their distinct identities and can always be mapped back.
|
||||
///
|
||||
/// One analogy that may or may not be helpful:
|
||||
/// In the same way a geometric transform maps a model's points in its
|
||||
/// rest space into the world coordinates for a particular instance,
|
||||
/// a PcpMapFunction maps values about a referenced model into the
|
||||
/// composed scene for a particular instance of that model. But rather
|
||||
/// than translating and rotating points, the map function shifts the
|
||||
/// values in namespace (and time).
|
||||
///
|
||||
///
|
||||
class PcpMapFunction
|
||||
{
|
||||
public:
|
||||
/// A mapping from path to path.
|
||||
typedef std::map<SdfPath, SdfPath, SdfPath::FastLessThan> PathMap;
|
||||
typedef std::pair<SdfPath, SdfPath> PathPair;
|
||||
typedef std::vector<PathPair> PathPairVector;
|
||||
|
||||
/// Construct a null function.
|
||||
PcpMapFunction() = default;
|
||||
|
||||
/// Constructs a map function with the given arguments.
|
||||
/// Returns a null map function on error (see IsNull()).
|
||||
///
|
||||
/// \param sourceToTargetMap The map from source paths to target paths.
|
||||
/// \param offset The time offset to apply from source to target.
|
||||
///
|
||||
PCP_API
|
||||
static PcpMapFunction
|
||||
Create(const PathMap &sourceToTargetMap,
|
||||
const SdfLayerOffset &offset);
|
||||
|
||||
/// Construct an identity map function.
|
||||
PCP_API
|
||||
static const PcpMapFunction &Identity();
|
||||
|
||||
/// Returns an identity path mapping.
|
||||
PCP_API
|
||||
static const PathMap &IdentityPathMap();
|
||||
|
||||
/// Swap the contents of this map function with \p map.
|
||||
PCP_API
|
||||
void Swap(PcpMapFunction &map);
|
||||
void swap(PcpMapFunction &map) { Swap(map); }
|
||||
|
||||
/// Equality.
|
||||
PCP_API
|
||||
bool operator==(const PcpMapFunction &map) const;
|
||||
|
||||
/// Inequality.
|
||||
PCP_API
|
||||
bool operator!=(const PcpMapFunction &map) const;
|
||||
|
||||
/// Return true if this map function is the null function.
|
||||
/// For a null function, MapSourceToTarget() always returns an empty path.
|
||||
PCP_API
|
||||
bool IsNull() const;
|
||||
|
||||
/// Return true if the map function is the identity function.
|
||||
/// For identity, MapSourceToTarget() always returns the path unchanged.
|
||||
PCP_API
|
||||
bool IsIdentity() const;
|
||||
|
||||
/// Return true if the map function maps the absolute root path to the
|
||||
/// absolute root path, false otherwise.
|
||||
bool HasRootIdentity() const { return _data.hasRootIdentity; }
|
||||
|
||||
/// Map a path in the source namespace to the target.
|
||||
/// If the path is not in the domain, returns an empty path.
|
||||
PCP_API
|
||||
SdfPath MapSourceToTarget(const SdfPath &path) const;
|
||||
|
||||
/// Map a path in the target namespace to the source.
|
||||
/// If the path is not in the co-domain, returns an empty path.
|
||||
PCP_API
|
||||
SdfPath MapTargetToSource(const SdfPath &path) const;
|
||||
|
||||
/// Compose this map over the given map function.
|
||||
/// The result will represent the application of f followed by
|
||||
/// the application of this function.
|
||||
PCP_API
|
||||
PcpMapFunction Compose(const PcpMapFunction &f) const;
|
||||
|
||||
/// Compose this map function over a hypothetical map function that has an
|
||||
/// identity path mapping and \p offset. This is equivalent to building
|
||||
/// such a map function and invoking Compose(), but is faster.
|
||||
PCP_API
|
||||
PcpMapFunction ComposeOffset(const SdfLayerOffset &newOffset) const;
|
||||
|
||||
/// Return the inverse of this map function.
|
||||
/// This returns a true inverse \p inv: for any path p in this function's
|
||||
/// domain that it maps to p', inv(p') -> p.
|
||||
PCP_API
|
||||
PcpMapFunction GetInverse() const;
|
||||
|
||||
/// The set of path mappings, from source to target.
|
||||
PCP_API
|
||||
PathMap GetSourceToTargetMap() const;
|
||||
|
||||
/// The time offset of the mapping.
|
||||
const SdfLayerOffset &GetTimeOffset() const { return _offset; }
|
||||
|
||||
/// Returns a string representation of this mapping for debugging
|
||||
/// purposes.
|
||||
PCP_API
|
||||
std::string GetString() const;
|
||||
|
||||
/// Return a size_t hash for this map function.
|
||||
PCP_API
|
||||
size_t Hash() const;
|
||||
|
||||
private:
|
||||
|
||||
PCP_API
|
||||
PcpMapFunction(PathPair const *sourceToTargetBegin,
|
||||
PathPair const *sourceToTargetEnd,
|
||||
SdfLayerOffset offset,
|
||||
bool hasRootIdentity);
|
||||
|
||||
private:
|
||||
friend PcpMapFunction *Pcp_MakeIdentity();
|
||||
|
||||
static const int _MaxLocalPairs = 2;
|
||||
struct _Data final {
|
||||
_Data() {};
|
||||
|
||||
_Data(PathPair const *begin, PathPair const *end, bool hasRootIdentity)
|
||||
: numPairs(end-begin)
|
||||
, hasRootIdentity(hasRootIdentity) {
|
||||
if (numPairs == 0)
|
||||
return;
|
||||
if (numPairs <= _MaxLocalPairs) {
|
||||
std::uninitialized_copy(begin, end, localPairs);
|
||||
}
|
||||
else {
|
||||
new (&remotePairs) std::shared_ptr<PathPair>(
|
||||
new PathPair[numPairs], std::default_delete<PathPair[]>());
|
||||
std::copy(begin, end, remotePairs.get());
|
||||
}
|
||||
}
|
||||
|
||||
_Data(_Data const &other)
|
||||
: numPairs(other.numPairs)
|
||||
, hasRootIdentity(other.hasRootIdentity) {
|
||||
if (numPairs <= _MaxLocalPairs) {
|
||||
std::uninitialized_copy(
|
||||
other.localPairs,
|
||||
other.localPairs + other.numPairs, localPairs);
|
||||
}
|
||||
else {
|
||||
new (&remotePairs) std::shared_ptr<PathPair>(other.remotePairs);
|
||||
}
|
||||
}
|
||||
_Data(_Data &&other)
|
||||
: numPairs(other.numPairs)
|
||||
, hasRootIdentity(other.hasRootIdentity) {
|
||||
if (numPairs <= _MaxLocalPairs) {
|
||||
PathPair *dst = localPairs;
|
||||
PathPair *src = other.localPairs;
|
||||
PathPair *srcEnd = other.localPairs + other.numPairs;
|
||||
for (; src != srcEnd; ++src, ++dst) {
|
||||
::new (static_cast<void*>(std::addressof(*dst)))
|
||||
PathPair(std::move(*src));
|
||||
}
|
||||
}
|
||||
else {
|
||||
new (&remotePairs)
|
||||
std::shared_ptr<PathPair>(std::move(other.remotePairs));
|
||||
}
|
||||
}
|
||||
_Data &operator=(_Data const &other) {
|
||||
if (this != &other) {
|
||||
this->~_Data();
|
||||
new (this) _Data(other);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
_Data &operator=(_Data &&other) {
|
||||
if (this != &other) {
|
||||
this->~_Data();
|
||||
new (this) _Data(std::move(other));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
~_Data() {
|
||||
if (numPairs <= _MaxLocalPairs) {
|
||||
for (PathPair *p = localPairs; numPairs--; ++p) {
|
||||
p->~PathPair();
|
||||
}
|
||||
}
|
||||
else {
|
||||
remotePairs.~shared_ptr<PathPair>();
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNull() const {
|
||||
return numPairs == 0 && !hasRootIdentity;
|
||||
}
|
||||
|
||||
PathPair const *begin() const {
|
||||
return numPairs <= _MaxLocalPairs ? localPairs : remotePairs.get();
|
||||
}
|
||||
|
||||
PathPair const *end() const {
|
||||
return begin() + numPairs;
|
||||
}
|
||||
|
||||
bool operator==(_Data const &other) const {
|
||||
return numPairs == other.numPairs &&
|
||||
hasRootIdentity == other.hasRootIdentity &&
|
||||
std::equal(begin(), end(), other.begin());
|
||||
}
|
||||
|
||||
bool operator!=(_Data const &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
union {
|
||||
PathPair localPairs[_MaxLocalPairs > 0 ? _MaxLocalPairs : 1];
|
||||
std::shared_ptr<PathPair> remotePairs;
|
||||
};
|
||||
typedef int PairCount;
|
||||
PairCount numPairs = 0;
|
||||
bool hasRootIdentity = false;
|
||||
};
|
||||
|
||||
_Data _data;
|
||||
SdfLayerOffset _offset;
|
||||
};
|
||||
|
||||
// Specialize hash_value for PcpMapFunction.
|
||||
inline
|
||||
size_t hash_value(const PcpMapFunction& x)
|
||||
{
|
||||
return x.Hash();
|
||||
}
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_MAP_FUNCTION_H
|
||||
@@ -0,0 +1,146 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_NAMESPACE_EDITS_H
|
||||
#define PXR_USD_PCP_NAMESPACE_EDITS_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/cache.h"
|
||||
#include "pxr/base/tf/hashset.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
// Forward declarations:
|
||||
class PcpChanges;
|
||||
class PcpCacheChanges;
|
||||
class Pcp_Dependencies;
|
||||
class PcpLayerStackIdentifier;
|
||||
class PcpLifeboat;
|
||||
class PcpNodeRef;
|
||||
class PcpMapFunction;
|
||||
|
||||
TF_DECLARE_WEAK_AND_REF_PTRS(PcpLayerStack);
|
||||
TF_DECLARE_WEAK_AND_REF_PTRS(Pcp_LayerStackRegistry);
|
||||
SDF_DECLARE_HANDLES(SdfSpec);
|
||||
|
||||
/// Sites that must respond to a namespace edit.
|
||||
struct PcpNamespaceEdits {
|
||||
|
||||
/// Types of namespace edits that a given layer stack site could need
|
||||
/// to perform to respond to a namespace edit.
|
||||
enum EditType {
|
||||
EditPath, ///< Must namespace edit spec
|
||||
EditInherit, ///< Must fixup inherits
|
||||
EditSpecializes, ///< Must fixup specializes
|
||||
EditReference, ///< Must fixup references
|
||||
EditPayload, ///< Must fixup payload
|
||||
EditRelocate, ///< Must fixup relocates
|
||||
};
|
||||
|
||||
void Swap(PcpNamespaceEdits& rhs)
|
||||
{
|
||||
cacheSites.swap(rhs.cacheSites);
|
||||
layerStackSites.swap(rhs.layerStackSites);
|
||||
invalidLayerStackSites.swap(rhs.invalidLayerStackSites);
|
||||
}
|
||||
|
||||
/// Cache site that must respond to a namespace edit.
|
||||
struct CacheSite {
|
||||
size_t cacheIndex; ///< Index of cache of site.
|
||||
SdfPath oldPath; ///< Old path of site.
|
||||
SdfPath newPath; ///< New path of site.
|
||||
};
|
||||
typedef std::vector<CacheSite> CacheSites;
|
||||
|
||||
/// Layer stack site that must respond to a namespace edit. All
|
||||
/// of the specs at the site will respond the same way.
|
||||
struct LayerStackSite {
|
||||
size_t cacheIndex; ///< Index of cache of site.
|
||||
EditType type; ///< Type of edit.
|
||||
PcpLayerStackPtr layerStack; ///< Layer stack needing fix.
|
||||
SdfPath sitePath; ///< Path of site needing fix.
|
||||
SdfPath oldPath; ///< Old path.
|
||||
SdfPath newPath; ///< New path.
|
||||
};
|
||||
typedef std::vector<LayerStackSite> LayerStackSites;
|
||||
|
||||
/// Cache sites that must respond to a namespace edit.
|
||||
CacheSites cacheSites;
|
||||
|
||||
/// Layer stack sites that must respond to a namespace edit.
|
||||
LayerStackSites layerStackSites;
|
||||
|
||||
/// Layer stack sites that are affected by a namespace edit but
|
||||
/// cannot respond properly. For example, in situations involving
|
||||
/// relocates, a valid namespace edit in one cache may result in
|
||||
/// an invalid edit in another cache in response.
|
||||
LayerStackSites invalidLayerStackSites;
|
||||
};
|
||||
|
||||
/// Returns the changes caused in any cache in \p caches due to
|
||||
/// namespace editing the object at \p curPath in this cache to
|
||||
/// have the path \p newPath. \p caches should have all caches,
|
||||
/// including this cache. If \p caches includes this cache then
|
||||
/// the result includes the changes caused at \p curPath in this
|
||||
/// cache itself.
|
||||
///
|
||||
/// To keep everything consistent, a namespace edit requires that
|
||||
/// everything using the namespace edited site to be changed in an
|
||||
/// appropriate way. For example, if a referenced prim /A is renamed
|
||||
/// to /B then everything referencing /A must be changed to reference
|
||||
/// /B instead. There are many other possibilities.
|
||||
///
|
||||
/// One possibility is that there are no opinions at \p curPath in
|
||||
/// this cache's layer stack and the site exists due to some ancestor
|
||||
/// arc. This requires a relocation and only sites using \p curPath
|
||||
/// that include the layer with the relocation must be changed in
|
||||
/// response. To find those sites, \p relocatesLayer indicates which
|
||||
/// layer the client will write the relocation to.
|
||||
///
|
||||
/// Clients must perform the changes to correctly perform a namespace
|
||||
/// edit. All changes must be performed in a change block, otherwise
|
||||
/// notices could be sent prematurely.
|
||||
///
|
||||
/// This method only works when the affected prim indexes have been
|
||||
/// computed. In general, this means you must have computed the prim
|
||||
/// index of everything in any existing cache, otherwise you might miss
|
||||
/// changes to objects in those caches that use the namespace edited
|
||||
/// object. Using the above example, if a prim with an uncomputed prim
|
||||
/// index referenced /A then this method would not report that prim.
|
||||
/// As a result that prim would continue to reference /A, which no
|
||||
/// longer exists.
|
||||
PCP_API
|
||||
PcpNamespaceEdits
|
||||
PcpComputeNamespaceEdits(const PcpCache *primaryCache,
|
||||
const std::vector<PcpCache*>& caches,
|
||||
const SdfPath& curPath,
|
||||
const SdfPath& newPath,
|
||||
const SdfLayerHandle& relocatesLayer);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_NAMESPACE_EDITS_H
|
||||
@@ -0,0 +1,454 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_NODE_H
|
||||
#define PXR_USD_PCP_NODE_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/types.h"
|
||||
#include "pxr/usd/sdf/types.h"
|
||||
#include "pxr/base/tf/iterator.h"
|
||||
#include "pxr/base/tf/hashset.h"
|
||||
|
||||
#include <boost/operators.hpp>
|
||||
#include <boost/iterator/iterator_facade.hpp>
|
||||
#include <boost/iterator/reverse_iterator.hpp>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class PcpArc;
|
||||
class PcpLayerStackSite;
|
||||
class PcpMapExpression;
|
||||
class PcpNodeRef;
|
||||
class PcpNodeRef_ChildrenIterator;
|
||||
class PcpNodeRef_ChildrenReverseIterator;
|
||||
class PcpErrorBase;
|
||||
typedef std::shared_ptr<PcpErrorBase> PcpErrorBasePtr;
|
||||
|
||||
TF_DECLARE_WEAK_PTRS(PcpPrimIndex_Graph);
|
||||
|
||||
/// \class PcpNodeRef
|
||||
///
|
||||
/// PcpNode represents a node in an expression tree for compositing
|
||||
/// scene description.
|
||||
///
|
||||
/// A node represents the opinions from a particular site. In addition,
|
||||
/// it may have child nodes, representing nested expressions that are
|
||||
/// composited over/under this node.
|
||||
///
|
||||
/// Child nodes are stored and composited in strength order.
|
||||
///
|
||||
/// Each node holds information about the arc to its parent.
|
||||
/// This captures both the relative strength of the sub-expression
|
||||
/// as well as any value-mapping needed, such as to rename opinions
|
||||
/// from a model to use in a particular instance.
|
||||
///
|
||||
class PcpNodeRef :
|
||||
public boost::totally_ordered<PcpNodeRef>
|
||||
{
|
||||
public:
|
||||
typedef PcpNodeRef_ChildrenIterator child_const_iterator;
|
||||
typedef PcpNodeRef_ChildrenReverseIterator child_const_reverse_iterator;
|
||||
typedef std::pair<child_const_iterator,
|
||||
child_const_iterator> child_const_range;
|
||||
|
||||
PcpNodeRef() : _graph(0), _nodeIdx(PCP_INVALID_INDEX) {}
|
||||
|
||||
/// \name Operators / Miscellaneous
|
||||
/// @{
|
||||
|
||||
/// Returns true if this is a valid node reference, false otherwise.
|
||||
typedef size_t PcpNodeRef::*UnspecifiedBoolType;
|
||||
inline operator UnspecifiedBoolType() const {
|
||||
return (_graph && _nodeIdx != PCP_INVALID_INDEX) ? &PcpNodeRef::_nodeIdx : 0;
|
||||
}
|
||||
|
||||
/// Returns true if this references the same node as \p rhs.
|
||||
inline bool operator==(const PcpNodeRef& rhs) const {
|
||||
return _nodeIdx == rhs._nodeIdx && _graph == rhs._graph;
|
||||
}
|
||||
|
||||
/// Returns true if this node is 'less' than \p rhs.
|
||||
/// The ordering of nodes is arbitrary and does not indicate the relative
|
||||
/// strength of the nodes.
|
||||
PCP_API
|
||||
bool operator<(const PcpNodeRef& rhs) const;
|
||||
|
||||
/// Hash functor.
|
||||
struct Hash {
|
||||
size_t operator()(const PcpNodeRef& rhs) const
|
||||
{ return (size_t)rhs.GetUniqueIdentifier(); }
|
||||
};
|
||||
|
||||
/// Returns the graph that this node belongs to.
|
||||
PcpPrimIndex_GraphPtr GetOwningGraph() const;
|
||||
|
||||
/// Returns a value that uniquely identifies this node.
|
||||
PCP_API
|
||||
void* GetUniqueIdentifier() const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Arc information
|
||||
/// Information pertaining to the arcs connecting this node to its
|
||||
/// parent and child nodes.
|
||||
/// @{
|
||||
|
||||
/// Returns the type of arc connecting this node to its parent node.
|
||||
PCP_API
|
||||
PcpArcType GetArcType() const;
|
||||
|
||||
/// Returns this node's immediate parent node. Will return NULL if this
|
||||
/// node is a root node.
|
||||
PCP_API
|
||||
PcpNodeRef GetParentNode() const;
|
||||
|
||||
/// Returns an iterator range over the children nodes in strongest to
|
||||
/// weakest order.
|
||||
PCP_API
|
||||
child_const_range GetChildrenRange() const;
|
||||
|
||||
/// Inserts a new child node for \p site, connected to this node via
|
||||
/// \p arc.
|
||||
PCP_API
|
||||
PcpNodeRef InsertChild(const PcpLayerStackSite& site, const PcpArc& arc,
|
||||
PcpErrorBasePtr *error);
|
||||
|
||||
/// Inserts \p subgraph as a child of this node, with the root node of
|
||||
/// \p subtree connected to this node via \p arc.
|
||||
PCP_API
|
||||
PcpNodeRef InsertChildSubgraph(
|
||||
const PcpPrimIndex_GraphPtr& subgraph, const PcpArc& arc,
|
||||
PcpErrorBasePtr *error);
|
||||
|
||||
/// Returns the immediate origin node for this node. The origin node
|
||||
/// is the node that caused this node to be brought into the prim index.
|
||||
/// In most cases, this is the same as the parent node. For implied
|
||||
/// inherits, the origin is the node from which this node was propagated.
|
||||
PCP_API
|
||||
PcpNodeRef GetOriginNode() const;
|
||||
|
||||
/// Walk up to the root origin node for this node. This is the very
|
||||
/// first node that caused this node to be added to the graph. For
|
||||
/// instance, the root origin node of an implied inherit is the
|
||||
/// original inherit node.
|
||||
PCP_API
|
||||
PcpNodeRef GetOriginRootNode() const;
|
||||
|
||||
/// Walk up to the root node of this expression.
|
||||
PCP_API
|
||||
PcpNodeRef GetRootNode() const;
|
||||
|
||||
/// Returns mapping function used to translate paths and values from
|
||||
/// this node to its parent node.
|
||||
PCP_API
|
||||
const PcpMapExpression& GetMapToParent() const;
|
||||
|
||||
/// Returns mapping function used to translate paths and values from
|
||||
/// this node directly to the root node.
|
||||
PCP_API
|
||||
const PcpMapExpression& GetMapToRoot() const;
|
||||
|
||||
/// Returns this node's index among siblings with the same arc type
|
||||
/// at this node's origin.
|
||||
PCP_API
|
||||
int GetSiblingNumAtOrigin() const;
|
||||
|
||||
/// Returns the absolute namespace depth of the node that introduced
|
||||
/// this node. Note that this does *not* count any variant selections.
|
||||
PCP_API
|
||||
int GetNamespaceDepth() const;
|
||||
|
||||
/// Return the number of levels of namespace this node's site is
|
||||
/// below the level at which it was introduced by an arc.
|
||||
PCP_API
|
||||
int GetDepthBelowIntroduction() const;
|
||||
|
||||
/// Returns the path for this node's site when it was introduced.
|
||||
PCP_API
|
||||
SdfPath GetPathAtIntroduction() const;
|
||||
|
||||
/// Get the path that introduced this node.
|
||||
/// Specifically, this is the path the parent node had at the level
|
||||
/// of namespace where this node was added as a child.
|
||||
/// For a root node, this returns the absolute root path.
|
||||
/// See also GetDepthBelowIntroduction().
|
||||
PCP_API
|
||||
SdfPath GetIntroPath() const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Node information
|
||||
/// Information pertaining specifically to this node and the opinions
|
||||
/// that it may or may not provide.
|
||||
/// @{
|
||||
|
||||
/// Get the site this node represents.
|
||||
PCP_API
|
||||
PcpLayerStackSite GetSite() const;
|
||||
|
||||
/// Returns the path for the site this node represents.
|
||||
PCP_API
|
||||
const SdfPath& GetPath() const;
|
||||
|
||||
/// Returns the layer stack for the site this node represents.
|
||||
PCP_API
|
||||
const PcpLayerStackRefPtr& GetLayerStack() const;
|
||||
|
||||
/// Returns true if this node is the root node of the prim index graph.
|
||||
PCP_API
|
||||
bool IsRootNode() const;
|
||||
|
||||
/// Returns true if this node is due to an ancestral opinion.
|
||||
PCP_API
|
||||
bool IsDueToAncestor() const;
|
||||
|
||||
/// Get/set whether this node provides any symmetry opinions, either
|
||||
/// directly or from a namespace ancestor.
|
||||
PCP_API
|
||||
void SetHasSymmetry(bool hasSymmetry);
|
||||
PCP_API
|
||||
bool HasSymmetry() const;
|
||||
|
||||
/// Get/set the permission for this node. This indicates whether specs
|
||||
/// on this node can be accessed from other nodes.
|
||||
PCP_API
|
||||
void SetPermission(SdfPermission perm);
|
||||
PCP_API
|
||||
SdfPermission GetPermission() const;
|
||||
|
||||
/// Get/set whether this node is inert. An inert node never provides
|
||||
/// any opinions to a prim index. Such a node may exist purely as a
|
||||
/// marker to represent certain composition structure, but should never
|
||||
/// contribute opinions.
|
||||
PCP_API
|
||||
void SetInert(bool inert);
|
||||
PCP_API
|
||||
bool IsInert() const;
|
||||
|
||||
/// Get/set whether this node is culled. If a node is culled, it and
|
||||
/// all descendant nodes provide no opinions to the index. A culled
|
||||
/// node is also considered inert.
|
||||
PCP_API
|
||||
void SetCulled(bool culled);
|
||||
PCP_API
|
||||
bool IsCulled() const;
|
||||
|
||||
/// Get/set whether this node is restricted. A restricted node is a
|
||||
/// node that cannot contribute opinions to the index due to permissions.
|
||||
PCP_API
|
||||
void SetRestricted(bool restricted);
|
||||
PCP_API
|
||||
bool IsRestricted() const;
|
||||
|
||||
/// Returns true if this node is allowed to contribute opinions
|
||||
/// for composition, false otherwise.
|
||||
PCP_API
|
||||
bool CanContributeSpecs() const;
|
||||
|
||||
/// Returns true if this node has opinions authored
|
||||
/// for composition, false otherwise.
|
||||
PCP_API
|
||||
void SetHasSpecs(bool hasSpecs);
|
||||
PCP_API
|
||||
bool HasSpecs() const;
|
||||
|
||||
/// @}
|
||||
|
||||
// Returns a compressed Sd site. For internal use only.
|
||||
Pcp_CompressedSdSite GetCompressedSdSite(size_t layerIndex) const
|
||||
{
|
||||
return Pcp_CompressedSdSite(_nodeIdx, layerIndex);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class PcpPrimIndex_Graph;
|
||||
friend class PcpNodeIterator;
|
||||
friend class PcpNodeRef_ChildrenIterator;
|
||||
friend class PcpNodeRef_ChildrenReverseIterator;
|
||||
friend class PcpNodeRef_PrivateChildrenConstIterator;
|
||||
friend class PcpNodeRef_PrivateChildrenConstReverseIterator;
|
||||
|
||||
// Private constructor for internal use.
|
||||
PcpNodeRef(PcpPrimIndex_Graph* graph, size_t idx)
|
||||
: _graph(graph), _nodeIdx(idx)
|
||||
{}
|
||||
|
||||
size_t _GetNodeIndex() const { return _nodeIdx; }
|
||||
|
||||
size_t _GetParentIndex() const;
|
||||
size_t _GetOriginIndex() const;
|
||||
|
||||
private: // Data
|
||||
PcpPrimIndex_Graph* _graph;
|
||||
size_t _nodeIdx;
|
||||
};
|
||||
|
||||
/// Typedefs and support functions
|
||||
inline
|
||||
size_t
|
||||
hash_value(const PcpNodeRef& x)
|
||||
{
|
||||
return (size_t)x.GetUniqueIdentifier();
|
||||
}
|
||||
|
||||
typedef TfHashSet<PcpNodeRef, PcpNodeRef::Hash> PcpNodeRefHashSet;
|
||||
typedef std::vector<PcpNodeRef> PcpNodeRefVector;
|
||||
|
||||
/// \class PcpNodeRef_ChildrenIterator
|
||||
///
|
||||
/// Object used to iterate over child nodes (not all descendant nodes) of a
|
||||
/// node in the prim index graph in strong-to-weak order.
|
||||
///
|
||||
class PcpNodeRef_ChildrenIterator
|
||||
: public boost::iterator_facade<
|
||||
/* Derived = */ PcpNodeRef_ChildrenIterator,
|
||||
/* ValueType = */ PcpNodeRef,
|
||||
/* Category = */ boost::forward_traversal_tag,
|
||||
/* RefType = */ PcpNodeRef
|
||||
>
|
||||
{
|
||||
public:
|
||||
/// Constructs an invalid iterator.
|
||||
PCP_API
|
||||
PcpNodeRef_ChildrenIterator();
|
||||
|
||||
/// Constructs an iterator pointing to \p node. Passing a NULL value
|
||||
/// for \p node constructs an end iterator.
|
||||
PCP_API
|
||||
PcpNodeRef_ChildrenIterator(const PcpNodeRef& node, bool end = false);
|
||||
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
PCP_API
|
||||
void increment();
|
||||
bool equal(const PcpNodeRef_ChildrenIterator& other) const
|
||||
{
|
||||
// Note: The default constructed iterator is *not* equal to any
|
||||
// other iterator.
|
||||
return (_node == other._node && _index == other._index);
|
||||
}
|
||||
reference dereference() const
|
||||
{
|
||||
return reference(_node._graph, _index);
|
||||
}
|
||||
|
||||
private:
|
||||
// Current graph node this iterator is pointing at.
|
||||
PcpNodeRef _node;
|
||||
|
||||
// Index of current child.
|
||||
size_t _index;
|
||||
|
||||
friend class PcpNodeRef_ChildrenReverseIterator;
|
||||
};
|
||||
|
||||
/// \class PcpNodeRef_ChildrenReverseIterator
|
||||
///
|
||||
/// Object used to iterate over nodes in the prim index graph in weak-to-strong
|
||||
/// order.
|
||||
///
|
||||
class PcpNodeRef_ChildrenReverseIterator
|
||||
: public boost::iterator_facade<
|
||||
/* Derived = */ PcpNodeRef_ChildrenReverseIterator,
|
||||
/* ValueType = */ PcpNodeRef,
|
||||
/* Category = */ boost::forward_traversal_tag,
|
||||
/* RefType = */ PcpNodeRef
|
||||
>
|
||||
{
|
||||
public:
|
||||
/// Constructs an invalid iterator.
|
||||
PCP_API
|
||||
PcpNodeRef_ChildrenReverseIterator();
|
||||
|
||||
/// Constructs a reverse iterator from a forward iterator.
|
||||
PCP_API
|
||||
PcpNodeRef_ChildrenReverseIterator(const PcpNodeRef_ChildrenIterator&);
|
||||
|
||||
/// Constructs an iterator pointing to \p node. Passing a NULL value
|
||||
/// for \p node constructs an end iterator.
|
||||
PCP_API
|
||||
PcpNodeRef_ChildrenReverseIterator(const PcpNodeRef& node,bool end = false);
|
||||
|
||||
private:
|
||||
friend class boost::iterator_core_access;
|
||||
PCP_API
|
||||
void increment();
|
||||
bool equal(const PcpNodeRef_ChildrenReverseIterator& other) const
|
||||
{
|
||||
// Note: The default constructed iterator is *not* equal to any
|
||||
// other iterator.
|
||||
return (_node == other._node && _index == other._index);
|
||||
}
|
||||
reference dereference() const
|
||||
{
|
||||
return reference(_node._graph, _index);
|
||||
}
|
||||
|
||||
private:
|
||||
// Current graph node this iterator is pointing at.
|
||||
PcpNodeRef _node;
|
||||
|
||||
// Index of current child.
|
||||
size_t _index;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Tf_IteratorInterface<PcpNodeRef::child_const_range, false> {
|
||||
typedef PcpNodeRef::child_const_iterator IteratorType;
|
||||
static IteratorType Begin(PcpNodeRef::child_const_range const &c)
|
||||
{
|
||||
return c.first;
|
||||
}
|
||||
static IteratorType End(PcpNodeRef::child_const_range const &c)
|
||||
{
|
||||
return c.second;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Tf_IteratorInterface<PcpNodeRef::child_const_range, true> {
|
||||
typedef PcpNodeRef::child_const_reverse_iterator IteratorType;
|
||||
static IteratorType Begin(PcpNodeRef::child_const_range const &c)
|
||||
{
|
||||
return c.second;
|
||||
}
|
||||
static IteratorType End(PcpNodeRef::child_const_range const &c)
|
||||
{
|
||||
return c.first;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Tf_ShouldIterateOverCopy<PcpNodeRef::child_const_range> :
|
||||
boost::true_type {};
|
||||
|
||||
// Helper to count the non-variant path components of a path; equivalent
|
||||
// to path.StripAllVariantSelections().GetPathElementCount() except
|
||||
// this method avoids constructing a new SdfPath value.
|
||||
int PcpNode_GetNonVariantPathElementCount(const SdfPath &path);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_NODE_H
|
||||
@@ -0,0 +1,116 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_PATH_TRANSLATION_H
|
||||
#define PXR_USD_PCP_PATH_TRANSLATION_H
|
||||
|
||||
/// \file pcp/pathTranslation.h
|
||||
/// Path translation.
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class PcpMapFunction;
|
||||
class PcpNodeRef;
|
||||
class SdfPath;
|
||||
|
||||
/// Translates \p pathInNodeNamespace from the namespace of the prim index node
|
||||
/// \p sourceNode to the namespace of the prim index's root node. This applies
|
||||
/// all necessary namespace translations.
|
||||
///
|
||||
/// If the path is successfully translated and \p pathWasTranslated is supplied,
|
||||
/// it will be set to \c true. In some cases, paths may fail to translate
|
||||
/// because they fall outside the set of paths that are allowed by nodes in the
|
||||
/// prim index. For instance, for a referenced model, paths referring to
|
||||
/// locations outside that model will not be translated. In these cases, this
|
||||
/// function will return an empty SdfPath and \p pathWasTranslated will be set
|
||||
/// to \c false.
|
||||
///
|
||||
/// In Sd/Csd terminology, this is forward path translation from the
|
||||
/// namespace of the prim spec represented by \p sourceNode to the composed
|
||||
/// scene namespace.
|
||||
PCP_API
|
||||
SdfPath
|
||||
PcpTranslatePathFromNodeToRoot(
|
||||
const PcpNodeRef& sourceNode,
|
||||
const SdfPath& pathInNodeNamespace,
|
||||
bool* pathWasTranslated = 0);
|
||||
|
||||
/// Translates \p pathInRootNamespace from the namespace of the root of the
|
||||
/// prim index that \p destNode belongs to to the namespace of \p destNode
|
||||
/// itself. This applies all necessary namespace translations.
|
||||
///
|
||||
/// If the path is successfully translated and \p pathWasTranslated is supplied,
|
||||
/// it will be set to \c true. In some cases, paths may fail to translate
|
||||
/// because they fall outside the set of paths that are allowed by nodes in the
|
||||
/// prim index. For instance, for a referenced model, paths referring to
|
||||
/// locations outside that model will not be translated. In these cases, this
|
||||
/// function will return an empty SdfPath and \p pathWasTranslated will be set
|
||||
/// to \c false.
|
||||
///
|
||||
/// In Sd/Csd terminology, this is reverse path translation from the
|
||||
/// namespace of the composed scene to the namespace of the prim spec
|
||||
/// represented by \p destNode.
|
||||
PCP_API
|
||||
SdfPath
|
||||
PcpTranslatePathFromRootToNode(
|
||||
const PcpNodeRef& destNode,
|
||||
const SdfPath& pathInRootNamespace,
|
||||
bool* pathWasTranslated = 0);
|
||||
|
||||
/// Same as \a PcpTranslatePathFromRootToNode, but explicitly for use when
|
||||
/// translating paths intended for use as attribute connections or relationship
|
||||
/// targets. The primary difference is that variant selections will never
|
||||
/// be included in the translated path. This is functionally equivalent to
|
||||
/// calling StripAllVariantSelections() on the result of the referenced
|
||||
/// function, but is more efficient.
|
||||
PCP_API
|
||||
SdfPath
|
||||
PcpTranslateTargetPathFromRootToNode(
|
||||
const PcpNodeRef& destNode,
|
||||
const SdfPath& pathInRootNamespace,
|
||||
bool* pathWasTranslated = 0);
|
||||
|
||||
/// Convenience function like \a PcpTranslatePathFromRootToNode, but
|
||||
/// takes a function rather than a node.
|
||||
PCP_API
|
||||
SdfPath
|
||||
PcpTranslatePathFromRootToNodeUsingFunction(
|
||||
const PcpMapFunction &mapToRoot,
|
||||
const SdfPath &pathInRootNamespace,
|
||||
bool *pathWasTranslated = 0);
|
||||
|
||||
/// Convenience function like \a PcpTranslatePathFromNodeToRoot, but
|
||||
/// takes a function rather than a node.
|
||||
PCP_API
|
||||
SdfPath
|
||||
PcpTranslatePathFromNodeToRootUsingFunction(
|
||||
const PcpMapFunction &mapToRoot,
|
||||
const SdfPath &pathInNodeNamespace,
|
||||
bool *pathWasTranslated = 0);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_PATH_TRANSLATION_H
|
||||
@@ -0,0 +1,432 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_PRIM_INDEX_H
|
||||
#define PXR_USD_PCP_PRIM_INDEX_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/composeSite.h"
|
||||
#include "pxr/usd/pcp/dynamicFileFormatDependencyData.h"
|
||||
#include "pxr/usd/pcp/errors.h"
|
||||
#include "pxr/usd/pcp/iterator.h"
|
||||
#include "pxr/usd/pcp/node.h"
|
||||
#include "pxr/usd/pcp/types.h"
|
||||
#include "pxr/usd/sdf/declareHandles.h"
|
||||
#include "pxr/usd/sdf/site.h"
|
||||
#include "pxr/base/tf/declarePtrs.h"
|
||||
#include "pxr/base/tf/hashmap.h"
|
||||
#include "pxr/base/tf/hashset.h"
|
||||
|
||||
#include <tbb/spin_rw_mutex.h>
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_set>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
SDF_DECLARE_HANDLES(SdfLayer);
|
||||
SDF_DECLARE_HANDLES(SdfPrimSpec);
|
||||
|
||||
TF_DECLARE_REF_PTRS(PcpLayerStack);
|
||||
TF_DECLARE_WEAK_AND_REF_PTRS(PcpPrimIndex_Graph);
|
||||
|
||||
class ArResolver;
|
||||
class PcpCache;
|
||||
class PcpPrimIndex;
|
||||
class PcpPrimIndexInputs;
|
||||
class PcpPrimIndexOutputs;
|
||||
class SdfPath;
|
||||
|
||||
/// \class PcpPrimIndex
|
||||
///
|
||||
/// PcpPrimIndex is an index of the all sites of scene description that
|
||||
/// contribute opinions to a specific prim, under composition
|
||||
/// semantics.
|
||||
///
|
||||
/// PcpComputePrimIndex() builds an index ("indexes") the given prim site.
|
||||
/// At any site there may be scene description values expressing arcs
|
||||
/// that represent instructions to pull in further scene description.
|
||||
/// PcpComputePrimIndex() recursively follows these arcs, building and
|
||||
/// ordering the results.
|
||||
///
|
||||
class PcpPrimIndex
|
||||
{
|
||||
public:
|
||||
/// Default construct an empty, invalid prim index.
|
||||
PCP_API
|
||||
PcpPrimIndex();
|
||||
|
||||
/// Copy-construct a prim index.
|
||||
PCP_API
|
||||
PcpPrimIndex(const PcpPrimIndex& rhs);
|
||||
|
||||
/// Assignment.
|
||||
PcpPrimIndex &operator=(const PcpPrimIndex &rhs) {
|
||||
PcpPrimIndex(rhs).Swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// Swap the contents of this prim index with \p index.
|
||||
PCP_API
|
||||
void Swap(PcpPrimIndex& rhs);
|
||||
|
||||
/// Same as Swap(), but standard name.
|
||||
inline void swap(PcpPrimIndex &rhs) { Swap(rhs); }
|
||||
|
||||
/// Return true if this index is valid.
|
||||
/// A default-constructed index is invalid.
|
||||
bool IsValid() const { return bool(_graph); }
|
||||
|
||||
PCP_API
|
||||
void SetGraph(const PcpPrimIndex_GraphRefPtr& graph);
|
||||
PCP_API
|
||||
PcpPrimIndex_GraphPtr GetGraph() const;
|
||||
|
||||
/// Returns the root node of the prim index graph.
|
||||
PCP_API
|
||||
PcpNodeRef GetRootNode() const;
|
||||
|
||||
/// Returns the path of the prim whose opinions are represented by this
|
||||
/// prim index.
|
||||
PCP_API
|
||||
const SdfPath& GetPath() const;
|
||||
|
||||
/// Returns true if this prim index contains any scene description
|
||||
/// opinions.
|
||||
PCP_API
|
||||
bool HasSpecs() const;
|
||||
|
||||
/// Returns true if the prim has any authored payload arcs.
|
||||
/// The payload contents are only resolved and included
|
||||
/// if this prim's path is in the payload inclusion set
|
||||
/// provided in PcpPrimIndexInputs.
|
||||
PCP_API
|
||||
bool HasAnyPayloads() const;
|
||||
|
||||
/// Returns true if this prim index was composed in USD mode.
|
||||
/// \see PcpCache::IsUsd().
|
||||
PCP_API
|
||||
bool IsUsd() const;
|
||||
|
||||
/// Returns true if this prim index is instanceable.
|
||||
/// Instanceable prim indexes with the same instance key are
|
||||
/// guaranteed to have the same set of opinions, but may not have
|
||||
/// local opinions about name children.
|
||||
/// \see PcpInstanceKey
|
||||
PCP_API
|
||||
bool IsInstanceable() const;
|
||||
|
||||
/// \name Iteration
|
||||
/// @{
|
||||
|
||||
/// Returns range of iterators that encompass all children of the root node
|
||||
/// with the given arc type as well as their descendants, in
|
||||
/// strong-to-weak order.
|
||||
///
|
||||
/// By default, this returns a range encompassing the entire index.
|
||||
PCP_API
|
||||
PcpNodeRange GetNodeRange(PcpRangeType rangeType = PcpRangeTypeAll) const;
|
||||
|
||||
/// Returns range of iterators that encompasses all prims, in
|
||||
/// strong-to-weak order.
|
||||
PCP_API
|
||||
PcpPrimRange GetPrimRange(PcpRangeType rangeType = PcpRangeTypeAll) const;
|
||||
|
||||
/// Returns range of iterators that encompasses all prims from the
|
||||
/// site of \p node. \p node must belong to this prim index.
|
||||
PCP_API
|
||||
PcpPrimRange GetPrimRangeForNode(const PcpNodeRef& node) const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Lookup
|
||||
/// @{
|
||||
|
||||
/// Returns the node that brings opinions from \p primSpec into
|
||||
/// this prim index. If no such node exists, returns an invalid PcpNodeRef.
|
||||
PCP_API
|
||||
PcpNodeRef GetNodeProvidingSpec(const SdfPrimSpecHandle& primSpec) const;
|
||||
|
||||
/// Returns the node that brings opinions from the Sd prim spec at \p layer
|
||||
/// and \p path into this prim index. If no such node exists, returns an
|
||||
/// invalid PcpNodeRef.
|
||||
PCP_API
|
||||
PcpNodeRef GetNodeProvidingSpec(
|
||||
const SdfLayerHandle& layer, const SdfPath& path) const;
|
||||
|
||||
/// @}
|
||||
|
||||
/// \name Diagnostics
|
||||
/// @{
|
||||
|
||||
/// Return the list of errors local to this prim.
|
||||
PcpErrorVector GetLocalErrors() const {
|
||||
return _localErrors ? *_localErrors.get() : PcpErrorVector();
|
||||
}
|
||||
|
||||
/// Prints various statistics about this prim index.
|
||||
PCP_API
|
||||
void PrintStatistics() const;
|
||||
|
||||
/// Dump the prim index contents to a string.
|
||||
///
|
||||
/// If \p includeInheritOriginInfo is \c true, output for implied inherit
|
||||
/// nodes will include information about the originating inherit node.
|
||||
/// If \p includeMaps is \c true, output for each node will include the
|
||||
/// mappings to the parent and root node.
|
||||
PCP_API
|
||||
std::string DumpToString(
|
||||
bool includeInheritOriginInfo = true,
|
||||
bool includeMaps = true) const;
|
||||
|
||||
/// Dump the prim index in dot format to the file named \p filename.
|
||||
/// See Dump(...) for information regarding arguments.
|
||||
PCP_API
|
||||
void DumpToDotGraph(
|
||||
const std::string& filename,
|
||||
bool includeInheritOriginInfo = true,
|
||||
bool includeMaps = false) const;
|
||||
|
||||
/// @}
|
||||
|
||||
|
||||
/// \name Derived computations
|
||||
/// @{
|
||||
|
||||
/// Compute the prim child names for the given path. \p errors will
|
||||
/// contain any errors encountered while performing this operation.
|
||||
PCP_API
|
||||
void ComputePrimChildNames(TfTokenVector *nameOrder,
|
||||
PcpTokenSet *prohibitedNameSet) const;
|
||||
|
||||
/// Compute the prim property names for the given path. \p errors will
|
||||
/// contain any errors encountered while performing this operation. The
|
||||
/// \p nameOrder vector must not contain any duplicate entries.
|
||||
PCP_API
|
||||
void ComputePrimPropertyNames(TfTokenVector *nameOrder) const;
|
||||
|
||||
/// Compose the authored prim variant selections.
|
||||
///
|
||||
/// These are the variant selections expressed in scene description.
|
||||
/// Note that these selections may not have actually been applied,
|
||||
/// if they are invalid.
|
||||
///
|
||||
/// \note This result is not cached, but computed each time.
|
||||
PCP_API
|
||||
SdfVariantSelectionMap ComposeAuthoredVariantSelections() const;
|
||||
|
||||
/// Return the variant selection applied for the named variant set.
|
||||
/// If none was applied, this returns an empty string.
|
||||
/// This can be different from the authored variant selection;
|
||||
/// for example, if the authored selection is invalid.
|
||||
PCP_API
|
||||
std::string GetSelectionAppliedForVariantSet(
|
||||
const std::string &variantSet) const;
|
||||
|
||||
/// @}
|
||||
|
||||
private:
|
||||
friend class PcpPrimIterator;
|
||||
friend struct Pcp_PrimIndexer;
|
||||
friend void Pcp_RescanForSpecs(PcpPrimIndex*, bool usd,
|
||||
bool updateHasSpecs);
|
||||
|
||||
// The node graph representing the compositional structure of this prim.
|
||||
PcpPrimIndex_GraphRefPtr _graph;
|
||||
|
||||
// The prim stack. This is just a derived structure representing
|
||||
// a cached strong-to-weak traversal of the graph collecting specs.
|
||||
Pcp_CompressedSdSiteVector _primStack;
|
||||
|
||||
// List of errors local to this prim, encountered during computation.
|
||||
// NULL if no errors were found (the expected common case).
|
||||
std::unique_ptr<PcpErrorVector> _localErrors;
|
||||
};
|
||||
|
||||
/// Free function version for generic code and ADL.
|
||||
inline void swap(PcpPrimIndex &l, PcpPrimIndex &r) { l.swap(r); }
|
||||
|
||||
/// \class PcpPrimIndexOutputs
|
||||
///
|
||||
/// Outputs of the prim indexing procedure.
|
||||
///
|
||||
class PcpPrimIndexOutputs
|
||||
{
|
||||
public:
|
||||
/// Enumerator whose enumerants describe the payload state of this prim
|
||||
/// index. NoPayload if the index has no payload arcs, otherwise whether
|
||||
/// payloads were included or excluded, and if done so by consulting either
|
||||
/// the cache's payload include set, or determined by a payload predicate.
|
||||
enum PayloadState { NoPayload,
|
||||
IncludedByIncludeSet, ExcludedByIncludeSet,
|
||||
IncludedByPredicate, ExcludedByPredicate };
|
||||
|
||||
/// Prim index describing the composition structure for the associated
|
||||
/// prim.
|
||||
PcpPrimIndex primIndex;
|
||||
|
||||
/// List of all errors encountered during indexing.
|
||||
PcpErrorVector allErrors;
|
||||
|
||||
/// Indicates the payload state of this index. See documentation for
|
||||
/// PayloadState enum for more information.
|
||||
PayloadState payloadState = NoPayload;
|
||||
|
||||
/// A list of names of fields that were composed to generate dynamic file
|
||||
/// format arguments for a node in primIndex. These are not necessarily
|
||||
/// fields that had values, but is the list of all fields that a composed
|
||||
/// value was requested for.
|
||||
PcpDynamicFileFormatDependencyData dynamicFileFormatDependency;
|
||||
|
||||
/// Swap content with \p r.
|
||||
inline void swap(PcpPrimIndexOutputs &r) {
|
||||
primIndex.swap(r.primIndex);
|
||||
allErrors.swap(r.allErrors);
|
||||
std::swap(payloadState, r.payloadState);
|
||||
dynamicFileFormatDependency.swap(r.dynamicFileFormatDependency);
|
||||
}
|
||||
|
||||
/// Appends the outputs from \p childOutputs to this object, using
|
||||
/// \p arcToParent to connect \p childOutputs' prim index to this object's
|
||||
/// prim index.
|
||||
///
|
||||
/// Returns the node in this object's prim index corresponding to the root
|
||||
/// node of \p childOutputs' prim index.
|
||||
PcpNodeRef Append(PcpPrimIndexOutputs&& childOutputs,
|
||||
const PcpArc& arcToParent,
|
||||
PcpErrorBasePtr *error);
|
||||
};
|
||||
|
||||
/// Free function version for generic code and ADL.
|
||||
inline void swap(PcpPrimIndexOutputs &l, PcpPrimIndexOutputs &r) { l.swap(r); }
|
||||
|
||||
/// \class PcpPrimIndexInputs
|
||||
///
|
||||
/// Inputs for the prim indexing procedure.
|
||||
///
|
||||
class PcpPrimIndexInputs {
|
||||
public:
|
||||
PcpPrimIndexInputs()
|
||||
: cache(nullptr)
|
||||
, variantFallbacks(nullptr)
|
||||
, includedPayloads(nullptr)
|
||||
, includedPayloadsMutex(nullptr)
|
||||
, parentIndex(nullptr)
|
||||
, cull(true)
|
||||
, usd(false)
|
||||
{ }
|
||||
|
||||
/// Returns true if prim index computations using this parameters object
|
||||
/// would be equivalent to computations using \p params.
|
||||
bool IsEquivalentTo(const PcpPrimIndexInputs& params) const;
|
||||
|
||||
/// If supplied, the given PcpCache will be used where possible to compute
|
||||
/// needed intermediate results.
|
||||
PcpPrimIndexInputs& Cache(PcpCache* cache_)
|
||||
{ cache = cache_; return *this; }
|
||||
|
||||
/// Ordered list of variant names to use for the "standin" variant set
|
||||
/// if there is no authored opinion in scene description.
|
||||
PcpPrimIndexInputs& VariantFallbacks(const PcpVariantFallbackMap* map)
|
||||
{ variantFallbacks = map; return *this; }
|
||||
|
||||
/// Set of paths to prims that should have their payloads included
|
||||
/// during composition.
|
||||
using PayloadSet = std::unordered_set<SdfPath, SdfPath::Hash>;
|
||||
PcpPrimIndexInputs& IncludedPayloads(const PayloadSet* payloadSet)
|
||||
{ includedPayloads = payloadSet; return *this; }
|
||||
|
||||
/// Optional mutex for accessing includedPayloads.
|
||||
PcpPrimIndexInputs &IncludedPayloadsMutex(tbb::spin_rw_mutex *mutex)
|
||||
{ includedPayloadsMutex = mutex; return *this; }
|
||||
|
||||
/// Optional predicate evaluated when a not-yet-included payload is
|
||||
/// discovered while indexing. If the predicate returns true, indexing
|
||||
/// includes the payload and sets the includedDiscoveredPayload bit in the
|
||||
/// outputs.
|
||||
PcpPrimIndexInputs &IncludePayloadPredicate(
|
||||
std::function<bool (const SdfPath &)> predicate)
|
||||
{ includePayloadPredicate = predicate; return *this; }
|
||||
|
||||
/// Whether subtrees that contribute no opinions should be culled
|
||||
/// from the index.
|
||||
PcpPrimIndexInputs& Cull(bool doCulling = true)
|
||||
{ cull = doCulling; return *this; }
|
||||
|
||||
/// Whether the prim stack should be computed, and
|
||||
/// whether relocates, inherits, permissions, symmetry, or payloads should
|
||||
/// be considered during prim index computation,
|
||||
PcpPrimIndexInputs& USD(bool doUSD = true)
|
||||
{ usd = doUSD; return *this; }
|
||||
|
||||
/// The file format target for scene description layers encountered during
|
||||
/// prim index computation.
|
||||
PcpPrimIndexInputs& FileFormatTarget(const std::string& target)
|
||||
{ fileFormatTarget = target; return *this; }
|
||||
|
||||
// private:
|
||||
PcpCache* cache;
|
||||
const PcpVariantFallbackMap* variantFallbacks;
|
||||
const PayloadSet* includedPayloads;
|
||||
tbb::spin_rw_mutex *includedPayloadsMutex;
|
||||
std::function<bool (const SdfPath &)> includePayloadPredicate;
|
||||
const PcpPrimIndex *parentIndex;
|
||||
std::string fileFormatTarget;
|
||||
bool cull;
|
||||
bool usd;
|
||||
};
|
||||
|
||||
/// Compute an index for the given path. \p errors will contain any errors
|
||||
/// encountered while performing this operation.
|
||||
PCP_API
|
||||
void
|
||||
PcpComputePrimIndex(
|
||||
const SdfPath& primPath,
|
||||
const PcpLayerStackPtr& layerStack,
|
||||
const PcpPrimIndexInputs& inputs,
|
||||
PcpPrimIndexOutputs* outputs,
|
||||
ArResolver* pathResolver = NULL);
|
||||
|
||||
/// Returns true if the 'new' default standin behavior is enabled.
|
||||
PCP_API
|
||||
bool
|
||||
PcpIsNewDefaultStandinBehaviorEnabled();
|
||||
|
||||
// Sets the prim stack in \p index.
|
||||
void
|
||||
Pcp_RescanForSpecs(PcpPrimIndex* index, bool usd);
|
||||
|
||||
// Returns true if \p index should be recomputed due to changes to
|
||||
// any computed asset paths that were used to find or open layers
|
||||
// when originally composing \p index. This may be due to scene
|
||||
// description changes or external changes to asset resolution that
|
||||
// may affect the computation of those asset paths.
|
||||
bool
|
||||
Pcp_NeedToRecomputeDueToAssetPathChange(const PcpPrimIndex& index);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_PRIM_INDEX_H
|
||||
@@ -0,0 +1,138 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_PROPERTY_INDEX_H
|
||||
#define PXR_USD_PCP_PROPERTY_INDEX_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/errors.h"
|
||||
#include "pxr/usd/pcp/iterator.h"
|
||||
#include "pxr/usd/pcp/node.h"
|
||||
|
||||
#include "pxr/usd/sdf/path.h"
|
||||
#include "pxr/usd/sdf/propertySpec.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
// Forward declarations:
|
||||
class PcpCache;
|
||||
|
||||
/// \class Pcp_PropertyInfo
|
||||
///
|
||||
/// Private helper structure containing information about a property in the
|
||||
/// property stack.
|
||||
///
|
||||
struct Pcp_PropertyInfo
|
||||
{
|
||||
Pcp_PropertyInfo() { }
|
||||
Pcp_PropertyInfo(const SdfPropertySpecHandle& prop, const PcpNodeRef& node)
|
||||
: propertySpec(prop), originatingNode(node) { }
|
||||
|
||||
SdfPropertySpecHandle propertySpec;
|
||||
PcpNodeRef originatingNode;
|
||||
};
|
||||
|
||||
/// \class PcpPropertyIndex
|
||||
///
|
||||
/// PcpPropertyIndex is an index of all sites in scene description that
|
||||
/// contribute opinions to a specific property, under composition
|
||||
/// semantics.
|
||||
///
|
||||
class PcpPropertyIndex
|
||||
{
|
||||
public:
|
||||
/// Construct an empty property index.
|
||||
PCP_API
|
||||
PcpPropertyIndex();
|
||||
|
||||
/// Copy-construct a property index.
|
||||
PCP_API
|
||||
PcpPropertyIndex(const PcpPropertyIndex &rhs);
|
||||
|
||||
/// Swap the contents of this property index with \p index.
|
||||
PCP_API
|
||||
void Swap(PcpPropertyIndex& index);
|
||||
|
||||
/// Returns true if this property index contains no opinions, false
|
||||
/// otherwise.
|
||||
PCP_API
|
||||
bool IsEmpty() const;
|
||||
|
||||
/// Returns range of iterators that encompasses properties in this
|
||||
/// index's property stack.
|
||||
///
|
||||
/// By default, this returns a range encompassing all properties in the
|
||||
/// index. If \p localOnly is specified, the range will only include
|
||||
/// properties from local nodes in its owning prim's graph.
|
||||
PCP_API
|
||||
PcpPropertyRange GetPropertyRange(bool localOnly = false) const;
|
||||
|
||||
/// Return the list of errors local to this property.
|
||||
PcpErrorVector GetLocalErrors() const {
|
||||
return _localErrors ? *_localErrors.get() : PcpErrorVector();
|
||||
}
|
||||
|
||||
/// Returns the number of local properties in this prim index.
|
||||
PCP_API
|
||||
size_t GetNumLocalSpecs() const;
|
||||
|
||||
private:
|
||||
friend class PcpPropertyIterator;
|
||||
friend class Pcp_PropertyIndexer;
|
||||
|
||||
// The property stack is a list of Pcp_PropertyInfo objects in
|
||||
// strong-to-weak order.
|
||||
std::vector<Pcp_PropertyInfo> _propertyStack;
|
||||
|
||||
/// List of errors local to this property, encountered during computation.
|
||||
/// NULL if no errors were found (the expected common case).
|
||||
std::unique_ptr<PcpErrorVector> _localErrors;
|
||||
};
|
||||
|
||||
/// Builds a property index for the property at \p path,
|
||||
/// internally computing and caching an owning prim index as necessary.
|
||||
/// \p allErrors will contain any errors encountered.
|
||||
PCP_API
|
||||
void
|
||||
PcpBuildPropertyIndex( const SdfPath& propertyPath,
|
||||
PcpCache *cache,
|
||||
PcpPropertyIndex *propertyIndex,
|
||||
PcpErrorVector *allErrors );
|
||||
|
||||
/// Builds a prim property index for the property at \p propertyPath.
|
||||
/// \p allErrors will contain any errors encountered.
|
||||
PCP_API
|
||||
void
|
||||
PcpBuildPrimPropertyIndex( const SdfPath& propertyPath,
|
||||
const PcpCache& cache,
|
||||
const PcpPrimIndex& owningPrimIndex,
|
||||
PcpPropertyIndex *propertyIndex,
|
||||
PcpErrorVector *allErrors );
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_PROPERTY_INDEX_H
|
||||
@@ -0,0 +1,47 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_PY_UTILS_H
|
||||
#define PXR_USD_PCP_PY_UTILS_H
|
||||
|
||||
#include <boost/python/dict.hpp>
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/types.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
/// Convert the Python dictionary \p dict to a PcpVariantFallbackMap
|
||||
/// object and return it via \p result, returning true if successful.
|
||||
PCP_API
|
||||
bool
|
||||
PcpVariantFallbackMapFromPython(
|
||||
const boost::python::dict& dict,
|
||||
PcpVariantFallbackMap *result);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_PY_UTILS_H
|
||||
@@ -0,0 +1,171 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_SITE_H
|
||||
#define PXR_USD_PCP_SITE_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/layerStackIdentifier.h"
|
||||
#include "pxr/usd/sdf/path.h"
|
||||
#include "pxr/usd/sdf/types.h"
|
||||
#include "pxr/base/tf/declarePtrs.h"
|
||||
|
||||
#include <boost/operators.hpp>
|
||||
#include <iosfwd>
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
TF_DECLARE_WEAK_AND_REF_PTRS(PcpLayerStack);
|
||||
class PcpLayerStackSite;
|
||||
|
||||
/// \class PcpSite
|
||||
///
|
||||
/// A site specifies a path in a layer stack of scene description.
|
||||
///
|
||||
class PcpSite : boost::totally_ordered<PcpSite>
|
||||
{
|
||||
public:
|
||||
PcpLayerStackIdentifier layerStackIdentifier;
|
||||
SdfPath path;
|
||||
|
||||
PCP_API
|
||||
PcpSite();
|
||||
|
||||
PCP_API
|
||||
PcpSite( const PcpLayerStackIdentifier &, const SdfPath & path );
|
||||
PCP_API
|
||||
PcpSite( const PcpLayerStackPtr &, const SdfPath & path );
|
||||
PCP_API
|
||||
PcpSite( const SdfLayerHandle &, const SdfPath & path );
|
||||
PCP_API
|
||||
explicit PcpSite( const PcpLayerStackSite & );
|
||||
|
||||
PCP_API
|
||||
bool operator==(const PcpSite &rhs) const;
|
||||
|
||||
PCP_API
|
||||
bool operator<(const PcpSite &rhs) const;
|
||||
|
||||
struct Hash {
|
||||
PCP_API
|
||||
size_t operator()(const PcpSite &) const;
|
||||
};
|
||||
};
|
||||
|
||||
/// \class PcpSiteStr
|
||||
///
|
||||
/// A "string-based" version of PcpSite. This stores layer identifiers as
|
||||
/// strings rather than SdfLayerHandles, making it stable wrt layer lifetimes.
|
||||
///
|
||||
class PcpSiteStr : boost::totally_ordered<PcpSiteStr>
|
||||
{
|
||||
public:
|
||||
PcpLayerStackIdentifierStr layerStackIdentifierStr;
|
||||
SdfPath path;
|
||||
|
||||
PCP_API
|
||||
PcpSiteStr();
|
||||
|
||||
PCP_API
|
||||
PcpSiteStr( const PcpLayerStackIdentifierStr &, const SdfPath & path );
|
||||
PCP_API
|
||||
PcpSiteStr( const PcpLayerStackIdentifier &, const SdfPath & path );
|
||||
PCP_API
|
||||
PcpSiteStr( const SdfLayerHandle &, const SdfPath & path );
|
||||
PCP_API
|
||||
PcpSiteStr(PcpLayerStackSite const &);
|
||||
PCP_API
|
||||
PcpSiteStr(PcpSite const &);
|
||||
|
||||
PCP_API
|
||||
bool operator==(const PcpSiteStr &rhs) const;
|
||||
|
||||
PCP_API
|
||||
bool operator<(const PcpSiteStr &rhs) const;
|
||||
|
||||
struct Hash {
|
||||
PCP_API
|
||||
size_t operator()(const PcpSiteStr &) const;
|
||||
};
|
||||
};
|
||||
|
||||
/// \class PcpLayerStackSite
|
||||
///
|
||||
/// A site specifies a path in a layer stack of scene description.
|
||||
///
|
||||
class PcpLayerStackSite : boost::totally_ordered<PcpLayerStackSite>
|
||||
{
|
||||
public:
|
||||
PcpLayerStackRefPtr layerStack;
|
||||
SdfPath path;
|
||||
|
||||
PCP_API
|
||||
PcpLayerStackSite();
|
||||
|
||||
PCP_API
|
||||
PcpLayerStackSite( const PcpLayerStackRefPtr &, const SdfPath & path );
|
||||
|
||||
PCP_API
|
||||
bool operator==(const PcpLayerStackSite &rhs) const;
|
||||
|
||||
PCP_API
|
||||
bool operator<(const PcpLayerStackSite &rhs) const;
|
||||
|
||||
struct Hash {
|
||||
PCP_API
|
||||
size_t operator()(const PcpLayerStackSite &) const;
|
||||
};
|
||||
};
|
||||
|
||||
PCP_API
|
||||
std::ostream& operator<<(std::ostream&, const PcpSite&);
|
||||
PCP_API
|
||||
std::ostream& operator<<(std::ostream&, const PcpSiteStr&);
|
||||
PCP_API
|
||||
std::ostream& operator<<(std::ostream&, const PcpLayerStackSite&);
|
||||
|
||||
static inline
|
||||
size_t
|
||||
hash_value(const PcpSite& site)
|
||||
{
|
||||
return PcpSite::Hash()(site);
|
||||
}
|
||||
|
||||
static inline
|
||||
size_t
|
||||
hash_value(const PcpSiteStr& site)
|
||||
{
|
||||
return PcpSiteStr::Hash()(site);
|
||||
}
|
||||
|
||||
static inline
|
||||
size_t
|
||||
hash_value(const PcpLayerStackSite& site)
|
||||
{
|
||||
return PcpLayerStackSite::Hash()(site);
|
||||
}
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_SITE_H
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_STRENGTH_ORDERING_H
|
||||
#define PXR_USD_PCP_STRENGTH_ORDERING_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
class PcpNodeRef;
|
||||
|
||||
/// Compares the strength of nodes \p a and \p b. These nodes must be siblings;
|
||||
/// it is a coding error if \p a and \p b do not have the same parent node.
|
||||
///
|
||||
/// Returns -1 if a is stronger than b,
|
||||
/// 0 if a is equivalent to b,
|
||||
/// 1 if a is weaker than b
|
||||
PCP_API
|
||||
int
|
||||
PcpCompareSiblingNodeStrength(const PcpNodeRef& a, const PcpNodeRef& b);
|
||||
|
||||
/// Compares the strength of nodes \p a and \p b. These nodes must be part
|
||||
/// of the same graph; it is a coding error if \p a and \p b do not have the
|
||||
/// same root node.
|
||||
///
|
||||
/// Returns -1 if a is stronger than b,
|
||||
/// 0 if a is equivalent to b,
|
||||
/// 1 if a is weaker than b
|
||||
PCP_API
|
||||
int
|
||||
PcpCompareNodeStrength(const PcpNodeRef& a, const PcpNodeRef& b);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_STRENGTH_ORDERING_H
|
||||
@@ -0,0 +1,108 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_TARGET_INDEX_H
|
||||
#define PXR_USD_PCP_TARGET_INDEX_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/errors.h"
|
||||
#include "pxr/usd/sdf/declareHandles.h"
|
||||
#include "pxr/usd/sdf/path.h"
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
SDF_DECLARE_HANDLES(SdfSpec);
|
||||
class PcpCache;
|
||||
class PcpPropertyIndex;
|
||||
|
||||
/// \class PcpTargetIndex
|
||||
///
|
||||
/// A PcpTargetIndex represents the results of indexing the target
|
||||
/// paths of a relationship or attribute. Note that this is just
|
||||
/// the result; it does not retain all of the input arguments used
|
||||
/// in computing the index, such as the owning property.
|
||||
///
|
||||
struct PcpTargetIndex {
|
||||
SdfPathVector paths;
|
||||
PcpErrorVector localErrors;
|
||||
bool hasTargetOpinions = false;
|
||||
};
|
||||
|
||||
/// Build a PcpTargetIndex representing the target paths of the given
|
||||
/// property.
|
||||
///
|
||||
/// \p propIndex is a PcpPropertyIndex of the relationship or attribute.
|
||||
/// \p relOrAttrType indicates if the property is a relationship
|
||||
/// or attribute.
|
||||
/// \p allErrors will contain any errors encountered while
|
||||
/// performing this operation.
|
||||
///
|
||||
/// Note that this function will skip the validation checks performed
|
||||
/// by PcpBuildFilteredTargetIndex. See documentation below for details.
|
||||
PCP_API
|
||||
void
|
||||
PcpBuildTargetIndex(
|
||||
const PcpSite& propSite,
|
||||
const PcpPropertyIndex& propIndex,
|
||||
const SdfSpecType relOrAttrType,
|
||||
PcpTargetIndex *targetIndex,
|
||||
PcpErrorVector *allErrors);
|
||||
|
||||
/// Like PcpBuildTargetIndex, but optionally filters the result by
|
||||
/// enforcing permissions restrictions and a stopProperty.
|
||||
///
|
||||
/// If \p localOnly is \c true then this will compose relationship
|
||||
/// targets from local nodes only. If \p stopProperty is not \c
|
||||
/// NULL then this will stop composing relationship targets at \p
|
||||
/// stopProperty, including \p stopProperty iff \p includeStopProperty
|
||||
/// is \c true.
|
||||
///
|
||||
/// \p cacheForValidation is a PcpCache that will be used to compute
|
||||
/// additional prim indexes as needed for validation. NULL may be
|
||||
/// passed in, but doing so will disable validation that relies on
|
||||
/// this cache, which includes permissions checks.
|
||||
///
|
||||
/// \p deletedPaths, if not \c NULL, will be populated with target
|
||||
/// paths whose deletion contributed to the computed value of
|
||||
/// \c targetIndex->paths.
|
||||
///
|
||||
/// \p allErrors will contain any errors encountered while
|
||||
/// performing this operation.
|
||||
PCP_API
|
||||
void
|
||||
PcpBuildFilteredTargetIndex(
|
||||
const PcpSite& propSite,
|
||||
const PcpPropertyIndex& propIndex,
|
||||
const SdfSpecType relOrAttrType,
|
||||
const bool localOnly,
|
||||
const SdfSpecHandle &stopProperty,
|
||||
const bool includeStopProperty,
|
||||
PcpCache *cacheForValidation,
|
||||
PcpTargetIndex *targetIndex,
|
||||
SdfPathVector *deletedPaths,
|
||||
PcpErrorVector *allErrors);
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_TARGET_INDEX_H
|
||||
@@ -0,0 +1,204 @@
|
||||
//
|
||||
// Copyright 2016 Pixar
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
||||
// with the following modification; you may not use this file except in
|
||||
// compliance with the Apache License and the following modification to it:
|
||||
// Section 6. Trademarks. is deleted and replaced with:
|
||||
//
|
||||
// 6. Trademarks. This License does not grant permission to use the trade
|
||||
// names, trademarks, service marks, or product names of the Licensor
|
||||
// and its affiliates, except as required to comply with Section 4(c) of
|
||||
// the License and to reproduce the content of the NOTICE file.
|
||||
//
|
||||
// You may obtain a copy of the Apache License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the Apache License with the above modification is
|
||||
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#ifndef PXR_USD_PCP_TYPES_H
|
||||
#define PXR_USD_PCP_TYPES_H
|
||||
|
||||
#include "pxr/pxr.h"
|
||||
#include "pxr/usd/pcp/api.h"
|
||||
#include "pxr/usd/pcp/site.h"
|
||||
#include "pxr/usd/sdf/layer.h"
|
||||
#include "pxr/base/tf/denseHashSet.h"
|
||||
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/operators.hpp>
|
||||
|
||||
/// \file pcp/types.h
|
||||
|
||||
PXR_NAMESPACE_OPEN_SCOPE
|
||||
|
||||
/// \enum PcpArcType
|
||||
///
|
||||
/// Describes the type of arc connecting two nodes in the prim index.
|
||||
///
|
||||
enum PcpArcType {
|
||||
// The root arc is a special value used for the root node of
|
||||
// the prim index. Unlike the following arcs, it has no parent node.
|
||||
PcpArcTypeRoot,
|
||||
|
||||
// The following arcs are listed in strength order.
|
||||
PcpArcTypeInherit,
|
||||
PcpArcTypeVariant,
|
||||
PcpArcTypeRelocate,
|
||||
PcpArcTypeReference,
|
||||
PcpArcTypePayload,
|
||||
PcpArcTypeSpecialize,
|
||||
|
||||
PcpNumArcTypes
|
||||
};
|
||||
|
||||
/// \enum PcpRangeType
|
||||
enum PcpRangeType {
|
||||
// Range including just the root node.
|
||||
PcpRangeTypeRoot,
|
||||
|
||||
// Ranges including child arcs, from the root node, of the specified type
|
||||
// as well as all descendants of those arcs.
|
||||
PcpRangeTypeInherit,
|
||||
PcpRangeTypeVariant,
|
||||
PcpRangeTypeReference,
|
||||
PcpRangeTypePayload,
|
||||
PcpRangeTypeSpecialize,
|
||||
|
||||
// Range including all nodes.
|
||||
PcpRangeTypeAll,
|
||||
|
||||
// Range including all nodes weaker than the root node.
|
||||
PcpRangeTypeWeakerThanRoot,
|
||||
|
||||
// Range including all nodes stronger than the payload
|
||||
// node.
|
||||
PcpRangeTypeStrongerThanPayload,
|
||||
|
||||
PcpRangeTypeInvalid
|
||||
};
|
||||
|
||||
/// Returns true if \p arcType represents an inherit arc, false
|
||||
/// otherwise.
|
||||
inline bool
|
||||
PcpIsInheritArc(PcpArcType arcType)
|
||||
{
|
||||
return (arcType == PcpArcTypeInherit);
|
||||
}
|
||||
|
||||
/// Returns true if \p arcType represents a specialize arc, false
|
||||
/// otherwise.
|
||||
inline bool
|
||||
PcpIsSpecializeArc(PcpArcType arcType)
|
||||
{
|
||||
return (arcType == PcpArcTypeSpecialize);
|
||||
}
|
||||
|
||||
/// Returns true if \p arcType represents a class-based
|
||||
/// composition arc, false otherwise.
|
||||
///
|
||||
/// The key characteristic of these arcs is that they imply
|
||||
/// additional sources of opinions outside of the site where
|
||||
/// the arc is introduced.
|
||||
inline bool
|
||||
PcpIsClassBasedArc(PcpArcType arcType)
|
||||
{
|
||||
return PcpIsInheritArc(arcType) || PcpIsSpecializeArc(arcType);
|
||||
}
|
||||
|
||||
/// \struct PcpSiteTrackerSegment
|
||||
///
|
||||
/// Used to keep track of which sites have been visited and through
|
||||
/// what type of arcs.
|
||||
///
|
||||
struct PcpSiteTrackerSegment {
|
||||
PcpSiteStr site;
|
||||
PcpArcType arcType;
|
||||
};
|
||||
|
||||
/// \typedef std::vector<PcpSiteTrackerSegment> PcpSiteTracker
|
||||
/// Represents a single path through the composition tree. As the tree
|
||||
/// is being built, we add segments to the tracker. If we encounter a
|
||||
/// site that we've already visited, we've found a cycle.
|
||||
typedef std::vector<PcpSiteTrackerSegment> PcpSiteTracker;
|
||||
|
||||
// Internal type for Sd sites.
|
||||
struct Pcp_SdSiteRef : boost::totally_ordered<Pcp_SdSiteRef> {
|
||||
Pcp_SdSiteRef(const SdfLayerRefPtr& layer_, const SdfPath& path_) :
|
||||
layer(layer_), path(path_)
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
bool operator==(const Pcp_SdSiteRef& other) const
|
||||
{
|
||||
return layer == other.layer && path == other.path;
|
||||
}
|
||||
|
||||
bool operator<(const Pcp_SdSiteRef& other) const
|
||||
{
|
||||
return layer < other.layer ||
|
||||
(!(other.layer < layer) && path < other.path);
|
||||
}
|
||||
|
||||
// These are held by reference for performance,
|
||||
// to avoid extra ref-counting operations.
|
||||
const SdfLayerRefPtr & layer;
|
||||
const SdfPath & path;
|
||||
};
|
||||
|
||||
// Internal type for Sd sites.
|
||||
struct Pcp_CompressedSdSite {
|
||||
Pcp_CompressedSdSite(size_t nodeIndex_, size_t layerIndex_) :
|
||||
nodeIndex(static_cast<uint16_t>(nodeIndex_)),
|
||||
layerIndex(static_cast<uint16_t>(layerIndex_))
|
||||
{
|
||||
TF_VERIFY(nodeIndex_ < (size_t(1) << 16));
|
||||
TF_VERIFY(layerIndex_ < (size_t(1) << 16));
|
||||
}
|
||||
|
||||
// These are small to minimize the size of vectors of these.
|
||||
uint16_t nodeIndex; // The index of the node in its graph.
|
||||
uint16_t layerIndex; // The index of the layer in the node's layer stack.
|
||||
};
|
||||
typedef std::vector<Pcp_CompressedSdSite> Pcp_CompressedSdSiteVector;
|
||||
|
||||
// XXX Even with <map> included properly, doxygen refuses to acknowledge
|
||||
// the existence of std::map, so if we include the full typedef in the
|
||||
// \typedef directive, it will warn and fail to produce an entry for
|
||||
// PcpVariantFallbackMap. So we instead put the decl inline.
|
||||
/// \typedef PcpVariantFallbackMap
|
||||
/// typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap
|
||||
///
|
||||
/// A "map of lists" of fallbacks to attempt to use when evaluating
|
||||
/// variant sets that lack an authored selection.
|
||||
///
|
||||
/// This maps a name of a variant set (ex: "shadingComplexity") to a
|
||||
/// ordered list of variant selection names. If there is no variant
|
||||
/// selection in scene description, Pcp will check for each listed
|
||||
/// fallback in sequence, using the first one that exists.
|
||||
///
|
||||
typedef std::map<std::string, std::vector<std::string>> PcpVariantFallbackMap;
|
||||
|
||||
typedef TfDenseHashSet<TfToken, TfToken::HashFunctor> PcpTokenSet;
|
||||
|
||||
/// \var size_t PCP_INVALID_INDEX
|
||||
/// A value which indicates an invalid index. This is simply used inplace of
|
||||
/// either -1 or numeric_limits::max() (which are equivalent for size_t).
|
||||
/// for better clarity.
|
||||
#if defined(doxygen)
|
||||
constexpr size_t PCP_INVALID_INDEX = unspecified;
|
||||
#else
|
||||
constexpr size_t PCP_INVALID_INDEX = std::numeric_limits<size_t>::max();
|
||||
#endif
|
||||
|
||||
PXR_NAMESPACE_CLOSE_SCOPE
|
||||
|
||||
#endif // PXR_USD_PCP_TYPES_H
|
||||
Reference in new issue
Block a user