Skip to content

Commit

Permalink
Ensure light collections are dirtied on creation
Browse files Browse the repository at this point in the history
  • Loading branch information
aloysbaillet committed Apr 27, 2022
1 parent db8e326 commit 73d78c8
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion pxr/usdImaging/usdImaging/delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1348,10 +1348,35 @@ UsdImagingDelegate::_ResyncUsdPrim(SdfPath const& usdPath,
// Otherwise, this is a totally new branch of the scene, so populate
// from the resync target path. Note: we need to verify that usdPath exists,
// since we can get resync notices for prims that were deleted.
if (_stage->GetPrimAtPath(usdPath)) {
UsdPrim usdPrim = _stage->GetPrimAtPath(usdPath);
if (usdPrim) {
TF_DEBUG(USDIMAGING_CHANGES).Msg(" - affected new prim: <%s>\n",
usdPath.GetText());
proxy->Repopulate(usdPath);

if (usdPrim.HasAPI<UsdLuxLightAPI>()) {
// If a new light was added, ensure collections are dirtied
TRACE_SCOPE("Resync light/shadow link targets");
auto _MarkLinkPathsDirty = [&](const SdfPathSet& linkedPaths) {
for (SdfPath affectedCachePath : linkedPaths) {
TF_DEBUG(USDIMAGING_CHANGES).Msg("[Refresh Object]: "
"Light <%s> modified; invalidate linked prim %s\n",
usdPath.GetText(), affectedCachePath.GetText());
_HdPrimInfo* primInfo = _GetHdPrimInfo(affectedCachePath);
if (primInfo && primInfo->usdPrim.IsValid() &&
TF_VERIFY(primInfo->adapter, "%s", affectedCachePath.GetText())) {
UsdImagingPrimAdapterSharedPtr& adapter = primInfo->adapter;
adapter->MarkDirty(primInfo->usdPrim, affectedCachePath,
HdChangeTracker::DirtyCategories, proxy);
}
}
};
UsdLuxLightAPI light(usdPrim);
UsdCollectionAPI lightLink{ light.GetLightLinkCollectionAPI() };
_MarkLinkPathsDirty(lightLink.ComputeIncludedPaths(lightLink.ComputeMembershipQuery(), _stage));
UsdCollectionAPI shadowLink{ light.GetShadowLinkCollectionAPI() };
_MarkLinkPathsDirty(shadowLink.ComputeIncludedPaths(shadowLink.ComputeMembershipQuery(), _stage));
}
} else {
TF_DEBUG(USDIMAGING_CHANGES).Msg(" - affected deleted prim: <%s>\n",
usdPath.GetText());
Expand Down

0 comments on commit 73d78c8

Please sign in to comment.