Skip to content

Commit

Permalink
[usdImaging] fix _GetDirtyBitsForPrimvarChange for PrimvarChangeAdd
Browse files Browse the repository at this point in the history
It was observed that primvars such as widths for UsdGeomPoints would not
update in hdSt from the usdImagingDelegate. If the widths primvar was
not read from disk it would always display with it's default value. The
change here is that with a PrimvarChangeAdd it will set the incoming
dirty bit instead of just DirtyPrimvar
  • Loading branch information
nvidia-jomiller committed May 16, 2022
1 parent 080df97 commit 50aad30
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 1 deletion.
20 changes: 20 additions & 0 deletions pxr/usdImaging/bin/testusdview/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ pxr_install_test_dir(
DEST testUsdviewVariantSelection
)

pxr_install_test_dir(
SRC testenv/testUsdviewPointWidths
DEST testUsdviewPointWidths
)


pxr_register_test(testUsdviewAlive
PRE_COMMAND "${PYTHON_EXECUTABLE} testUsdviewAliveSetup.py"
Expand Down Expand Up @@ -961,6 +966,21 @@ pxr_register_test(testUsdviewVariantSelection
EXPECTED_RETURN_CODE 0
)

pxr_register_test(testUsdviewPointWidths
PYTHON
COMMAND "${CMAKE_INSTALL_PREFIX}/bin/testusdview --testScript testUsdviewPointWidths.py points.usda"
IMAGE_DIFF_COMPARE
start.png
set_point_widths_025.png
set_point_widths_050.png
set_point_widths_primvar_075.png
end.png
FAIL 1
FAIL_PERCENT 0.002
PERCEPTUAL
EXPECTED_RETURN_CODE 0
)

if(OPENCOLORIO_FOUND AND ${PXR_BUILD_OPENCOLORIO_PLUGIN})
pxr_register_test(testUsdviewColorManagement
PYTHON
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#usda 1.0
(
defaultPrim = "World"
upAxis = "Y"
)

def Xform "Scene" {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/pxrpythonsubst
#
# Copyright 2020 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
from __future__ import print_function

from pxr.Usdviewq.common import Usd, UsdGeom
from pxr import Vt, Gf, Sdf

# Remove any unwanted visuals from the view, and enable autoClip
def _modifySettings(appController):
appController._dataModel.viewSettings.showBBoxes = False
appController._dataModel.viewSettings.showHUD = False
appController._dataModel.viewSettings.autoComputeClippingPlanes = True

def _createPoints(stage):
# define the points Prim on the stage
points = UsdGeom.Points.Define(stage, Sdf.Path("/Scene/points"))

positions = []
for x in range(-5, 5):
positions.append(Gf.Vec3f(x, 0, 10))

points.CreatePointsAttr().Set(Vt.Vec3fArray(positions))
return points

def _createWidths(points, widthSize):
# initialize the widths attribute to a specific value
widths = []
for _ in range(0, len(points.GetPointsAttr().Get())):
widths.append(widthSize)

points.CreateWidthsAttr().Set(widths)

def _createWidthsPrimvar(points, widthSize):
widths = []
for _ in range(0, len(points.GetPointsAttr().Get())):
widths.append(widthSize)

api = UsdGeom.PrimvarsAPI(points)
api.CreatePrimvar(UsdGeom.Tokens.widths, Sdf.ValueTypeNames.FloatArray).Set(widths)

def _removeWidthsPrimvar(points):
api = UsdGeom.PrimvarsAPI(points)
api.RemovePrimvar(UsdGeom.Tokens.widths)

def _testPointsWidthsAttr(appController):
# create the initial set of points that we will be changing the widths on
points = _createPoints(appController._dataModel.stage)

# take a screen shot of the points with their default widths
appController._takeShot("start.png")

# now author the widths attribute to a non-default width size
_createWidths(points, 0.25)
appController._takeShot("set_point_widths_025.png")

# change widths to a different value
_createWidths(points, 0.5)
appController._takeShot("set_point_widths_050.png")

# now author the widths primvar to override the widths attr
_createWidthsPrimvar(points, 0.75)
appController._takeShot("set_point_widths_primvar_075.png")

# remove the widths primvar to revert back to the widths attr
_removeWidthsPrimvar(points)
appController._takeShot("end.png")

# This test adds and removes primvars that are used/unused by the material.
def testUsdviewInputFunction(appController):
_modifySettings(appController)
_testPointsWidthsAttr(appController)
2 changes: 1 addition & 1 deletion pxr/usdImaging/usdImaging/primAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,6 @@ _GetDirtyBitsForPrimvarChange(
HdDirtyBits dirty = HdChangeTracker::Clean;

switch (changeType) {
case PrimvarChangeAdd:
case PrimvarChangeRemove:
case PrimvarChangeDesc:
{
Expand All @@ -879,6 +878,7 @@ _GetDirtyBitsForPrimvarChange(
dirty = HdChangeTracker::DirtyPrimvar;
break;
}
case PrimvarChangeAdd:
case PrimvarChangeValue:
{
dirty = valueChangeDirtyBit;
Expand Down

0 comments on commit 50aad30

Please sign in to comment.