Skip to content

Commit

Permalink
[usdImaging] Remove _GetDirtyBitsForPrimvarChange
Browse files Browse the repository at this point in the history
Addressing notes. Removes _GetDirtyBitsForPrimvarChange to simplify logic when checking dirty bits.

See #1807 for more details
  • Loading branch information
nvidia-jomiller committed May 16, 2022
1 parent 50aad30 commit 1a592fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 71 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
87 changes: 16 additions & 71 deletions pxr/usdImaging/usdImaging/primAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,53 +852,11 @@ UsdImagingPrimAdapter::_ComputeAndMergePrimvar(

namespace {

// The types of primvar changes expected
enum PrimvarChange {
PrimvarChangeValue,
PrimvarChangeAdd,
PrimvarChangeRemove,
PrimvarChangeDesc
};

// Maps the primvar changes (above) to the dirty bit that needs to be set.
// Figure out what changed about the primvar and update the primvar descriptors
// if necessary
/*static*/
HdDirtyBits
_GetDirtyBitsForPrimvarChange(
PrimvarChange changeType,
HdDirtyBits valueChangeDirtyBit)
{
HdDirtyBits dirty = HdChangeTracker::Clean;

switch (changeType) {
case PrimvarChangeRemove:
case PrimvarChangeDesc:
{
// XXX: Once we have a bit for descriptor changes, we should use
// that instead.
dirty = HdChangeTracker::DirtyPrimvar;
break;
}
case PrimvarChangeAdd:
case PrimvarChangeValue:
{
dirty = valueChangeDirtyBit;
break;
}
default:
{
TF_CODING_ERROR("Unsupported PrimvarChange %d\n", changeType);
}
}

return dirty;
}

// Figure out what changed about the primvar and returns the appropriate dirty
// bit.
/*static*/
PrimvarChange
void
_ProcessPrimvarChange(bool primvarOnPrim,
HdInterpolation primvarInterpOnPrim,
TfToken const& primvarName,
HdPrimvarDescriptorVector* primvarDescs,
SdfPath const& cachePath/*debug*/)
Expand All @@ -914,25 +872,14 @@ _ProcessPrimvarChange(bool primvarOnPrim,
}
bool primvarInValueCache = primvarIt != primvarDescs->end();

PrimvarChange changeType = PrimvarChangeValue;
if (primvarOnPrim && !primvarInValueCache) {
changeType = PrimvarChangeAdd;
} else if (!primvarOnPrim && primvarInValueCache) {
changeType = PrimvarChangeRemove;

if (!primvarOnPrim && primvarInValueCache) {
TF_DEBUG(USDIMAGING_CHANGES).Msg(
"Removing primvar descriptor %s for cachePath %s.\n",
primvarIt->name.GetText(), cachePath.GetText());

// Remove the value cache entry.
primvarDescs->erase(primvarIt);

} else if (primvarInValueCache && primvarOnPrim &&
(primvarIt->interpolation != primvarInterpOnPrim)) {
changeType = PrimvarChangeDesc;
}

return changeType;
}

} // anonymous namespace
Expand All @@ -944,7 +891,7 @@ UsdImagingPrimAdapter::_ProcessNonPrefixedPrimvarPropertyChange(
TfToken const& propertyName,
TfToken const& primvarName,
HdInterpolation const& primvarInterp,
HdDirtyBits valueChangeDirtyBit
HdDirtyBits primvarDirtyBit
/*= HdChangeTracker::DirtyPrimvar*/) const
{
// Determine if primvar exists on the prim.
Expand All @@ -965,21 +912,20 @@ UsdImagingPrimAdapter::_ProcessNonPrefixedPrimvarPropertyChange(
}

HdPrimvarDescriptorVector& primvarDescs =
_GetPrimvarDescCache()->GetPrimvars(cachePath);

PrimvarChange changeType =
_ProcessPrimvarChange(primvarOnPrim, primvarInterp,
primvarName, &primvarDescs, cachePath);
_GetPrimvarDescCache()->GetPrimvars(cachePath);

_ProcessPrimvarChange(primvarOnPrim, primvarName,&primvarDescs,
cachePath);

return _GetDirtyBitsForPrimvarChange(changeType, valueChangeDirtyBit);
return primvarDirtyBit;
}

HdDirtyBits
UsdImagingPrimAdapter::_ProcessPrefixedPrimvarPropertyChange(
UsdPrim const& prim,
SdfPath const& cachePath,
TfToken const& propertyName,
HdDirtyBits valueChangeDirtyBit/*= HdChangeTracker::DirtyPrimvar*/,
HdDirtyBits primvarDirtyBit/*= HdChangeTracker::DirtyPrimvar*/,
bool inherited/*=true*/) const
{
// Determine if primvar exists on the prim.
Expand Down Expand Up @@ -1007,13 +953,12 @@ UsdImagingPrimAdapter::_ProcessPrefixedPrimvarPropertyChange(
// Determine if primvar is in the value cache.
TfToken primvarName = UsdGeomPrimvar::StripPrimvarsName(propertyName);
HdPrimvarDescriptorVector& primvarDescs =
_GetPrimvarDescCache()->GetPrimvars(cachePath);

PrimvarChange changeType = _ProcessPrimvarChange(primvarOnPrim,
hdInterpOnPrim,
primvarName, &primvarDescs, cachePath);
_GetPrimvarDescCache()->GetPrimvars(cachePath);

_ProcessPrimvarChange(primvarOnPrim, primvarName, &primvarDescs,
cachePath);

return _GetDirtyBitsForPrimvarChange(changeType, valueChangeDirtyBit);
return primvarDirtyBit;
}

UsdImaging_CollectionCache&
Expand Down

0 comments on commit 1a592fb

Please sign in to comment.