本文整理汇总了C++中TfTokenVector::size方法的典型用法代码示例。如果您正苦于以下问题:C++ TfTokenVector::size方法的具体用法?C++ TfTokenVector::size怎么用?C++ TfTokenVector::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TfTokenVector
的用法示例。
在下文中一共展示了TfTokenVector::size方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TfStringJoin
std::string
SdfPath::JoinIdentifier(const TfTokenVector& names)
{
std::vector<std::string> tmp;
tmp.reserve(names.size());
for (size_t i = 0, n = names.size(); i != n; ++i) {
if (!names[i].IsEmpty()) {
tmp.push_back(names[i].GetString());
}
}
return TfStringJoin(tmp, SdfPathTokens->namespaceDelimiter.GetText());
}
示例2: GlfTextureHandlePtr
GlfTextureHandleRefPtr
GlfTextureRegistry::GetTextureHandle(const TfTokenVector &textures)
{
if (textures.empty()) {
TF_WARN("Attempting to register arrayTexture with empty token vector.");
return GlfTextureHandlePtr();
}
const size_t numTextures = textures.size();
// We register an array texture with the
// path of the first texture in the array
TfToken texture = textures[0];
GlfTextureHandleRefPtr textureHandle;
_TextureMetadata md(textures);
// look into exisiting textures
std::map<TfToken, _TextureMetadata>::iterator it =
_textureRegistry.find(texture);
if (it != _textureRegistry.end() && it->second.IsMetadataEqual(md)) {
textureHandle = it->second.GetHandle();
} else {
// if not exists, create it
textureHandle = _CreateTexture(textures, numTextures);
md.SetHandle(textureHandle);
_textureRegistry[texture] = md;
}
return textureHandle;
}
示例3: source
void
HdPoints::_PopulateVertexPrimVars(HdDrawItem *drawItem,
HdChangeTracker::DirtyBits *dirtyBits)
{
HD_TRACE_FUNCTION();
HD_MALLOC_TAG_FUNCTION();
SdfPath const& id = GetId();
HdSceneDelegate* delegate = GetDelegate();
HdResourceRegistry *resourceRegistry = &HdResourceRegistry::GetInstance();
// The "points" attribute is expected to be in this list.
TfTokenVector primVarNames = delegate->GetPrimVarVertexNames(id);
TfTokenVector const& vars = delegate->GetPrimVarVaryingNames(id);
primVarNames.insert(primVarNames.end(), vars.begin(), vars.end());
HdBufferSourceVector sources;
sources.reserve(primVarNames.size());
int pointsIndexInSourceArray = -1;
TF_FOR_ALL(nameIt, primVarNames) {
if (not HdChangeTracker::IsPrimVarDirty(*dirtyBits, id, *nameIt))
continue;
// TODO: We don't need to pull primvar metadata every time a value
// changes, but we need support from the delegate.
//assert name not in range.bufferArray.GetResources()
VtValue value = delegate->Get(id, *nameIt);
if (!value.IsEmpty()) {
// Store where the points will be stored in the source array
// we need this later to figure out if the number of points is changing
// and we need to force a garbage collection to resize the buffer
if (*nameIt == HdTokens->points) {
pointsIndexInSourceArray = sources.size();
}
// XXX: do we need special treatment for width as basicCurves?
HdBufferSourceSharedPtr source(new HdVtBufferSource(*nameIt, value));
sources.push_back(source);
}
}
// return before allocation if it's empty.
if (sources.empty())
return;
if (not drawItem->GetVertexPrimVarRange() or
not drawItem->GetVertexPrimVarRange()->IsValid()) {
// initialize buffer array
HdBufferSpecVector bufferSpecs;
TF_FOR_ALL(it, sources) {
(*it)->AddBufferSpecs(&bufferSpecs);
}
示例4:
void
Hd_PrimTypeIndex<PrimType>::InitPrimTypes(const TfTokenVector &primTypes)
{
size_t primTypeCount = primTypes.size();
_entries.resize(primTypeCount);
for (size_t typeIdx = 0; typeIdx < primTypeCount; ++typeIdx) {
_index.emplace(primTypes[typeIdx], typeIdx);
}
}
示例5: New
virtual GlfTextureRefPtr New(const TfTokenVector& texturePaths,
GlfImage::ImageOriginLocation originLocation =
GlfImage::OriginUpperLeft) const
{
return GlfArrayTexture::New(texturePaths,
texturePaths.size(),
/*cropTop*/ 0,
/*cropBottom*/ 0,
/*cropLeft*/ 0,
/*cropRight*/ 0,
originLocation);
}
示例6: if
std::vector<UsdProperty>
UsdPrim::_MakeProperties(const TfTokenVector &names) const
{
std::vector<UsdProperty> props;
UsdStage *stage = _GetStage();
props.reserve(names.size());
for (auto const &propName : names) {
SdfSpecType specType = stage->_GetDefiningSpecType(*this, propName);
if (specType == SdfSpecTypeAttribute) {
props.push_back(GetAttribute(propName));
} else if (TF_VERIFY(specType == SdfSpecTypeRelationship)) {
props.push_back(GetRelationship(propName));
}
}
return props;
}
示例7:
UsdRelationshipVector
UsdPrim::_GetRelationships(bool onlyAuthored, bool applyOrder) const
{
const TfTokenVector names = _GetPropertyNames(onlyAuthored, applyOrder);
UsdRelationshipVector rels;
// PERFORMANCE: This is sloppy, since property names are a superset of
// relationship names, however this vector is likely short lived and worth
// the trade off of repeated reallocation.
rels.reserve(names.size());
for (const auto& propName : names) {
if (UsdRelationship rel = GetRelationship(propName)) {
rels.push_back(rel);
}
}
return rels;
}
示例8: source
void
HdRprim::_PopulateConstantPrimVars(HdSceneDelegate* delegate,
HdDrawItem *drawItem,
HdDirtyBits *dirtyBits)
{
HD_TRACE_FUNCTION();
HF_MALLOC_TAG_FUNCTION();
SdfPath const& id = GetId();
HdRenderIndex &renderIndex = delegate->GetRenderIndex();
HdResourceRegistry *resourceRegistry = &HdResourceRegistry::GetInstance();
// XXX: this should be in a different method
// XXX: This should be in HdSt getting the HdSt Shader
const HdShader *shader = static_cast<const HdShader *>(
renderIndex.GetSprim(HdPrimTypeTokens->shader,
_surfaceShaderID));
if (shader == nullptr) {
shader = static_cast<const HdShader *>(
renderIndex.GetFallbackSprim(HdPrimTypeTokens->shader));
}
_sharedData.surfaceShader = shader->GetShaderCode();
// update uniforms
HdBufferSourceVector sources;
if (HdChangeTracker::IsTransformDirty(*dirtyBits, id)) {
GfMatrix4d transform = delegate->GetTransform(id);
_sharedData.bounds.SetMatrix(transform); // for CPU frustum culling
HdBufferSourceSharedPtr source(new HdVtBufferSource(
HdTokens->transform,
transform));
sources.push_back(source);
source.reset(new HdVtBufferSource(HdTokens->transformInverse,
transform.GetInverse()));
sources.push_back(source);
// if this is a prototype (has instancer),
// also push the instancer transform separately.
if (!_instancerID.IsEmpty()) {
// gather all instancer transforms in the instancing hierarchy
VtMatrix4dArray rootTransforms = _GetInstancerTransforms(delegate);
VtMatrix4dArray rootInverseTransforms(rootTransforms.size());
bool leftHanded = transform.IsLeftHanded();
for (size_t i = 0; i < rootTransforms.size(); ++i) {
rootInverseTransforms[i] = rootTransforms[i].GetInverse();
// flip the handedness if necessary
leftHanded ^= rootTransforms[i].IsLeftHanded();
}
source.reset(new HdVtBufferSource(
HdTokens->instancerTransform,
rootTransforms, /*staticArray=*/true));
sources.push_back(source);
source.reset(new HdVtBufferSource(
HdTokens->instancerTransformInverse,
rootInverseTransforms, /*staticArray=*/true));
sources.push_back(source);
// XXX: It might be worth to consider to have isFlipped
// for non-instanced prims as well. It can improve
// the drawing performance on older-GPUs by reducing
// fragment shader cost, although it needs more GPU memory.
// set as int (GLSL needs 32-bit align for bool)
source.reset(new HdVtBufferSource(
HdTokens->isFlipped, VtValue(int(leftHanded))));
sources.push_back(source);
}
}
if (HdChangeTracker::IsExtentDirty(*dirtyBits, id)) {
_sharedData.bounds.SetRange(GetExtent(delegate));
GfVec3d const & localMin = drawItem->GetBounds().GetBox().GetMin();
HdBufferSourceSharedPtr sourceMin(new HdVtBufferSource(
HdTokens->bboxLocalMin,
VtValue(GfVec4f(
localMin[0],
localMin[1],
localMin[2], 0))));
sources.push_back(sourceMin);
GfVec3d const & localMax = drawItem->GetBounds().GetBox().GetMax();
HdBufferSourceSharedPtr sourceMax(new HdVtBufferSource(
HdTokens->bboxLocalMax,
VtValue(GfVec4f(
localMax[0],
localMax[1],
localMax[2], 0))));
sources.push_back(sourceMax);
}
if (HdChangeTracker::IsPrimIdDirty(*dirtyBits, id)) {
GfVec4f primIdColor;
int32_t primId = GetPrimId();
HdBufferSourceSharedPtr source(new HdVtBufferSource(
//.........这里部分代码省略.........
示例9:
GlfTextureRegistry::_TextureMetadata::_TextureMetadata(
const TfTokenVector &textures)
: _TextureMetadata(textures.data(), textures.size())
{}