本文整理汇总了C++中UsdStagePtr::GetRootLayer方法的典型用法代码示例。如果您正苦于以下问题:C++ UsdStagePtr::GetRootLayer方法的具体用法?C++ UsdStagePtr::GetRootLayer怎么用?C++ UsdStagePtr::GetRootLayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UsdStagePtr
的用法示例。
在下文中一共展示了UsdStagePtr::GetRootLayer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prim
void
GusdPrimWrapper::updateTransformFromGTPrim( const GfMatrix4d &xform,
UsdTimeCode time, bool force )
{
UsdGeomImageable usdGeom = getUsdPrimForWrite();
UsdGeomXformable prim( usdGeom );
// Determine if we need to clear previous transformations from a stronger
// opinion on the stage before authoring ours.
UsdStagePtr stage = usdGeom.GetPrim().GetStage();
UsdEditTarget currEditTarget = stage->GetEditTarget();
// If the edit target does no mapping, it is most likely the session
// layer which means it is in the local layer stack and can overlay
// any xformOps.
if ( !currEditTarget.GetMapFunction().IsNull() &&
!currEditTarget.GetMapFunction().IsIdentity() ) {
bool reset;
std::vector<UsdGeomXformOp> xformVec = prim.GetOrderedXformOps(&reset);
// The xformOps attribute is static so we only check if we haven't
// changed anything yet. In addition nothing needs to be cleared if it
// was previously empty.
if (m_lastXformSet.IsDefault() && (int)xformVec.size() > 0) {
// Load the root layer for temp, stronger opinion changes.
stage->GetRootLayer()->SetPermissionToSave(false);
stage->SetEditTarget(stage->GetRootLayer());
UsdGeomXformable stagePrim( getUsdPrimForWrite() );
// Clear the xformOps on the stronger layer, so our weaker edit
// target (with mapping across a reference) can write out clean,
// new transforms.
stagePrim.ClearXformOpOrder();
stage->SetEditTarget(currEditTarget);
}
}
if( !prim )
return;
// Try to avoid setting the transform when we can.
// If force it true, always write the transform (used when writting per frame)
bool setKnot = true;
if( !force ) {
// Has the transform has been set at least once
if( !m_lastXformSet.IsDefault() ) {
// Is the transform at this frame the same as the last frame
if( isClose(xform,m_xformCache) ) {
setKnot = false;
m_lastXformCompared = time;
}
else {
// If the transform has been held for more than one frame,
// set a knot on the last frame
if( m_lastXformCompared != m_lastXformSet ) {
prim.MakeMatrixXform().Set( m_xformCache, m_lastXformCompared );
}
}
}
else {
// If the transform is an identity, don't set it
if( isClose(xform,GfMatrix4d( 1.0 ))) {
setKnot = false;
m_lastXformCompared = time;
}
else {
// If the transform was identity and now isn't, set a knot on the last frame
if( !m_lastXformCompared.IsDefault() ) {
prim.MakeMatrixXform().Set( GfMatrix4d(1.0), m_lastXformCompared );
}
}
}
}
if( setKnot ) {
prim.MakeMatrixXform().Set( xform, time );
m_xformCache = xform;
m_lastXformSet = time;
m_lastXformCompared = time;
}
}