本文整理汇总了C++中UsdRelationship::GetTargets方法的典型用法代码示例。如果您正苦于以下问题:C++ UsdRelationship::GetTargets方法的具体用法?C++ UsdRelationship::GetTargets怎么用?C++ UsdRelationship::GetTargets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UsdRelationship
的用法示例。
在下文中一共展示了UsdRelationship::GetTargets方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static SdfPathVector
_GetTargets(const UsdRelationship &self,
bool forwardToObjectsInMasters)
{
SdfPathVector result;
self.GetTargets(&result, forwardToObjectsInMasters);
return result;
}
示例2:
bool
UsdGeomCollectionAPI::IsEmpty() const
{
UsdRelationship targetsRel = _GetTargetsRel();
if (targetsRel) {
SdfPathVector targets;
targetsRel.GetTargets(&targets);
return targets.empty();
}
return true;
}
示例3: bboxCache
bool
UsdGeomPointInstancer::ComputeExtentAtTime(
VtVec3fArray* extent,
const UsdTimeCode time,
const UsdTimeCode baseTime) const
{
if (!extent) {
TF_WARN("%s -- null container passed to ComputeExtentAtTime()",
GetPrim().GetPath().GetText());
return false;
}
VtIntArray protoIndices;
if (!GetProtoIndicesAttr().Get(&protoIndices, time)) {
TF_WARN("%s -- no prototype indices",
GetPrim().GetPath().GetText());
return false;
}
const std::vector<bool> mask = ComputeMaskAtTime(time);
if (!mask.empty() && mask.size() != protoIndices.size()) {
TF_WARN("%s -- mask.size() [%zu] != protoIndices.size() [%zu]",
GetPrim().GetPath().GetText(),
mask.size(),
protoIndices.size());
return false;
}
const UsdRelationship prototypes = GetPrototypesRel();
SdfPathVector protoPaths;
if (!prototypes.GetTargets(&protoPaths) || protoPaths.empty()) {
TF_WARN("%s -- no prototypes",
GetPrim().GetPath().GetText());
return false;
}
// verify that all the protoIndices are in bounds.
TF_FOR_ALL(iter, protoIndices) {
const int protoIndex = *iter;
if (protoIndex < 0 ||
static_cast<size_t>(protoIndex) >= protoPaths.size()) {
TF_WARN("%s -- invalid prototype index: %d. Should be in [0, %zu)",
GetPrim().GetPath().GetText(),
protoIndex,
protoPaths.size());
return false;
}
}
// Note that we do NOT apply any masking when computing the instance
// transforms. This is so that for a particular instance we can determine
// both its transform and its prototype. Otherwise, the instanceTransforms
// array would have masked instances culled out and we would lose the
// mapping to the prototypes.
// Masked instances will be culled before being applied to the extent below.
VtMatrix4dArray instanceTransforms;
if (!ComputeInstanceTransformsAtTime(&instanceTransforms,
time,
baseTime,
IncludeProtoXform,
IgnoreMask)) {
TF_WARN("%s -- could not compute instance transforms",
GetPrim().GetPath().GetText());
return false;
}
UsdStageWeakPtr stage = GetPrim().GetStage();
const TfTokenVector purposes {
UsdGeomTokens->default_,
UsdGeomTokens->proxy,
UsdGeomTokens->render
};
UsdGeomBBoxCache bboxCache(time, purposes);
bboxCache.SetTime(time);
GfRange3d extentRange;
for (size_t instanceId = 0; instanceId < protoIndices.size(); ++instanceId) {
if (!mask.empty() && !mask[instanceId]) {
continue;
}
const int protoIndex = protoIndices[instanceId];
const SdfPath& protoPath = protoPaths[protoIndex];
const UsdPrim& protoPrim = stage->GetPrimAtPath(protoPath);
// Get the prototype bounding box.
GfBBox3d thisBounds = bboxCache.ComputeUntransformedBound(protoPrim);
// Apply the instance transform.
thisBounds.Transform(instanceTransforms[instanceId]);
extentRange.UnionWith(thisBounds.ComputeAlignedRange());
}
const GfVec3d extentMin = extentRange.GetMin();
const GfVec3d extentMax = extentRange.GetMax();
*extent = VtVec3fArray(2);
(*extent)[0] = GfVec3f(extentMin[0], extentMin[1], extentMin[2]);
(*extent)[1] = GfVec3f(extentMax[0], extentMax[1], extentMax[2]);
//.........这里部分代码省略.........
示例4: xformCache
bool
UsdGeomPointInstancer::ComputeInstanceTransformsAtTime(
VtArray<GfMatrix4d>* xforms,
const UsdTimeCode time,
const UsdTimeCode baseTime,
const ProtoXformInclusion doProtoXforms,
const MaskApplication applyMask) const
{
// XXX: Need to add handling of velocities/angularVelocities and baseTime.
(void)baseTime;
if (!xforms) {
TF_WARN("%s -- null container passed to ComputeInstanceTransformsAtTime()",
GetPrim().GetPath().GetText());
return false;
}
VtIntArray protoIndices;
if (!GetProtoIndicesAttr().Get(&protoIndices, time)) {
TF_WARN("%s -- no prototype indices",
GetPrim().GetPath().GetText());
return false;
}
if (protoIndices.empty()) {
xforms->clear();
return true;
}
VtVec3fArray positions;
if (!GetPositionsAttr().Get(&positions, time)) {
TF_WARN("%s -- no positions",
GetPrim().GetPath().GetText());
return false;
}
if (positions.size() != protoIndices.size()) {
TF_WARN("%s -- positions.size() [%zu] != protoIndices.size() [%zu]",
GetPrim().GetPath().GetText(),
positions.size(),
protoIndices.size());
return false;
}
VtVec3fArray scales;
GetScalesAttr().Get(&scales, time);
if (!scales.empty() && scales.size() != protoIndices.size()) {
TF_WARN("%s -- scales.size() [%zu] != protoIndices.size() [%zu]",
GetPrim().GetPath().GetText(),
scales.size(),
protoIndices.size());
return false;
}
VtQuathArray orientations;
GetOrientationsAttr().Get(&orientations, time);
if (!orientations.empty() && orientations.size() != protoIndices.size()) {
TF_WARN("%s -- orientations.size() [%zu] != protoIndices.size() [%zu]",
GetPrim().GetPath().GetText(),
orientations.size(),
protoIndices.size());
return false;
}
// If we're going to include the prototype transforms, verify that we have
// prototypes and that all of the protoIndices are in bounds.
SdfPathVector protoPaths;
if (doProtoXforms == IncludeProtoXform) {
const UsdRelationship prototypes = GetPrototypesRel();
if (!prototypes.GetTargets(&protoPaths) || protoPaths.empty()) {
TF_WARN("%s -- no prototypes",
GetPrim().GetPath().GetText());
return false;
}
TF_FOR_ALL(iter, protoIndices) {
const int protoIndex = *iter;
if (protoIndex < 0 || static_cast<size_t>(protoIndex) >= protoPaths.size()) {
TF_WARN("%s -- invalid prototype index: %d. Should be in [0, %zu)",
GetPrim().GetPath().GetText(),
protoIndex,
protoPaths.size());
return false;
}
}
}
// Compute the mask only if applyMask says we should, otherwise we leave
// mask empty so that its application below is a no-op.
std::vector<bool> mask;
if (applyMask == ApplyMask) {
mask = ComputeMaskAtTime(time);
if (!mask.empty() && mask.size() != protoIndices.size()) {
TF_WARN("%s -- mask.size() [%zu] != protoIndices.size() [%zu]",
GetPrim().GetPath().GetText(),
mask.size(),
protoIndices.size());
return false;
}
}
//.........这里部分代码省略.........