From 9b299014d130691b05c8d8028312e2f2e9004438 Mon Sep 17 00:00:00 2001 From: tcauchois Date: Wed, 20 Feb 2019 00:02:25 -0800 Subject: [PATCH] [usdImaging] Add support for animated cards textures. Follow-up to #735 (Internal change: 1940891) --- .../lib/usdImagingGL/drawModeAdapter.cpp | 47 ++++++++++--------- .../lib/usdImagingGL/drawModeAdapter.h | 7 ++- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.cpp b/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.cpp index 995576ed97..53c79efc46 100644 --- a/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.cpp +++ b/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.cpp @@ -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 textureAttrs = { UsdGeomTokens->modelCardTextureXPos, @@ -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. diff --git a/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.h b/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.h index d69048ae01..03710a3820 100644 --- a/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.h +++ b/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.h @@ -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.