Skip to content

Commit

Permalink
[usdImaging] Add support for animated cards textures.
Browse files Browse the repository at this point in the history
Follow-up to #735

(Internal change: 1940891)
  • Loading branch information
tcauchois authored and pixar-oss committed Feb 20, 2019
1 parent d377b2b commit 9b29901
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
47 changes: 26 additions & 21 deletions pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,10 @@ UsdImagingGLDrawModeAdapter::MarkMaterialDirty(UsdPrim const& prim,
}
}


void
UsdImagingGLDrawModeAdapter::TrackVariability(UsdPrim const& prim,
SdfPath const& cachePath,
HdDirtyBits* timeVaryingBits,
UsdImagingInstancerContext const*
instancerContext) const
UsdImagingGLDrawModeAdapter::_CheckForTextureVariability(
UsdPrim const& prim, HdDirtyBits dirtyBits,
HdDirtyBits *timeVaryingBits) const
{
const std::array<TfToken, 6> textureAttrs = {
UsdGeomTokens->modelCardTextureXPos,
Expand All @@ -320,31 +317,39 @@ UsdImagingGLDrawModeAdapter::TrackVariability(UsdPrim const& prim,
UsdGeomTokens->modelCardTextureZNeg,
};

auto checkForTextureVariability =
[&textureAttrs, &prim, &timeVaryingBits, this]
(HdDirtyBits dirtyBits) {
for (const TfToken& attr: textureAttrs) {
if (_IsVarying(prim, attr, dirtyBits,
UsdImagingTokens->usdVaryingTexture,
timeVaryingBits, true)) {
break;
}
for (const TfToken& attr: textureAttrs) {
if (_IsVarying(prim, attr, dirtyBits,
UsdImagingTokens->usdVaryingTexture,
timeVaryingBits, false)) {
break;
}
};
}
}

void
UsdImagingGLDrawModeAdapter::TrackVariability(UsdPrim const& prim,
SdfPath const& cachePath,
HdDirtyBits* timeVaryingBits,
UsdImagingInstancerContext const*
instancerContext) const
{
// If the textures are time-varying, we need to mark DirtyTexture on the
// texture, and DirtyParams on the shader (so that the shader picks up
// the new texture handle).
// XXX: the DirtyParams part of this can go away when we do the dependency
// tracking in hydra.
if (_IsTexturePath(cachePath)) {
checkForTextureVariability(HdTexture::DirtyTexture);
_CheckForTextureVariability(prim, HdTexture::DirtyTexture,
timeVaryingBits);
return;
}

if (_IsMaterialPath(cachePath)) {
checkForTextureVariability(
HdMaterial::DirtySurfaceShader | HdMaterial::DirtyParams);
_CheckForTextureVariability(prim, HdMaterial::DirtyParams,
timeVaryingBits);
return;
}

checkForTextureVariability(HdChangeTracker::DirtyParams);

// WARNING: This method is executed from multiple threads, the value cache
// has been carefully pre-populated to avoid mutating the underlying
// container during update.
Expand Down
7 changes: 6 additions & 1 deletion pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,13 @@ class UsdImagingGLDrawModeAdapter : public UsdImagingPrimAdapter {
// Check whether the given cachePath is a path to the draw mode material.
bool _IsMaterialPath(SdfPath const& path) const;
// Check whether the given cachePath is a path to a draw mode texture.

bool _IsTexturePath(SdfPath const& path) const;

// Check if any of the cards texture attributes are marked as time-varying.
void _CheckForTextureVariability(UsdPrim const& prim,
HdDirtyBits dirtyBits,
HdDirtyBits *timeVaryingBits) const;

// Computes the extents of the given prim, using UsdGeomBBoxCache.
// The extents are computed at UsdTimeCode::EarliestTime() (and are not
// animated), and they are computed for purposes default/proxy/render.
Expand Down

0 comments on commit 9b29901

Please # to comment.