From a6917af7c47cf386c09bec67983bc327bc5df65a Mon Sep 17 00:00:00 2001 From: Pal Mezei Date: Tue, 8 Jan 2019 10:03:53 +1100 Subject: [PATCH] [USD] Allowing animated textures in drawModeAdapter. --- pxr/usdImaging/lib/usdImaging/tokens.h | 1 + .../lib/usdImagingGL/drawModeAdapter.cpp | 33 +++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/pxr/usdImaging/lib/usdImaging/tokens.h b/pxr/usdImaging/lib/usdImaging/tokens.h index e9b10d8e61..7f822cbe64 100644 --- a/pxr/usdImaging/lib/usdImaging/tokens.h +++ b/pxr/usdImaging/lib/usdImaging/tokens.h @@ -47,6 +47,7 @@ PXR_NAMESPACE_OPEN_SCOPE (usdVaryingWidths) \ (usdVaryingNormals) \ (usdVaryingXform) \ + (usdVaryingTexture) \ (bxdf) \ (displacement) \ (uvPrimvar) \ diff --git a/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.cpp b/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.cpp index 9af7b01214..107244fbf9 100644 --- a/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.cpp +++ b/pxr/usdImaging/lib/usdImagingGL/drawModeAdapter.cpp @@ -311,11 +311,40 @@ UsdImagingGLDrawModeAdapter::TrackVariability(UsdPrim const& prim, UsdImagingInstancerContext const* instancerContext) const { - if (_IsMaterialPath(cachePath) || _IsTexturePath(cachePath)) { - // Shader/texture aspects aren't time-varying. + const std::array textureAttrs = { + UsdGeomTokens->modelCardTextureXPos, + UsdGeomTokens->modelCardTextureYPos, + UsdGeomTokens->modelCardTextureZPos, + UsdGeomTokens->modelCardTextureXNeg, + UsdGeomTokens->modelCardTextureYNeg, + 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; + } + } + }; + + if (_IsTexturePath(cachePath)) { + checkForTextureVariability(HdTexture::DirtyTexture); return; } + if (_IsMaterialPath(cachePath)) { + checkForTextureVariability( + HdMaterial::DirtySurfaceShader | HdMaterial::DirtyParams); + 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.