Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HYDRA-1275 Prepare code and unit test for usd 24.11 #206

Merged
merged 2 commits into from
Nov 22, 2024

Conversation

lanierd-adsk
Copy link
Collaborator

No description provided.

@lanierd-adsk lanierd-adsk self-assigned this Nov 21, 2024
@@ -107,23 +107,6 @@ find_library(USD_LIBRARY

get_filename_component(USD_LIBRARY_DIR ${USD_LIBRARY} DIRECTORY)

# Get the boost version from the one built with USD
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not used at all, we don't use Boost and it was removed in usd 24.11+

@@ -53,6 +54,14 @@ class TestIsolateSelect(mtohUtils.MayaHydraBaseTestCase):

_requiredPlugins = ['mayaHydraCppTests', 'mayaHydraFlowViewportAPILocator']

imageVersion = None

@classmethod
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the unit tests, there are basically 2 possible workarounds to keep the same images as much as possible.

  1. modifyDefaultLightIntensityIfUsdGreaterOrEqualTo_24_11() / resetDefaultLightIntensityIfUsdGreaterOrEqualTo_24_11() to modify/reset the default light intensity which fixes most of the problematic tests.
  2. When 1. doesn't work I need to do another baseline image and I am using the imageVersion from assertsnapshot where the new version of the image is in a given folder whose name is imageVersion (when it's not None).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For 1. : Could we change the modify/reset methods to be more generic/modifiable over time than them being fixed to a single version, since I presume these things could change again? i.e. have something like setDefaultLightIntensityByUsdVersion and resetDefaultLightIntensity, in which we could handle all the different USD versions

For 2. : Could we move the imageVersion class attribute and setup to the MayaHydraBaseTestCase in mtohUtils.py? That way the usd version would always be set automatically, can be used as needed and the code will not have to be copy-pasted in each test

@@ -232,7 +237,13 @@ VtValue MayaHydraLightAdapter::GetLightParamValue(const TfToken& paramName)
const auto color = light.color();
return VtValue(GfVec3f(color.r, color.g, color.b));
} else if (paramName == HdLightTokens->intensity) {
return VtValue(light.intensity());
float intensity = light.intensity();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor : auto is used in the surrounding code, could use it here as well for consistency

Comment on lines 142 to 158
def modifyDefaultLightIntensityIfUsdGreaterOrEqualTo_24_11(self):
#For Usd 24.11+ set the default light intensity to PI instead of 1.0 to counter balance the changes in usd 24.11
#This can be called after the original setUp function which sets the default light to 1
if Usd.GetVersion() >= (0, 24, 11):
if maya.mel.eval("optionVar -exists defaultLightIntensity"):
maya.mel.eval("optionVar -fv defaultLightIntensity 3.1415")
if cmds.attributeQuery('defaultLightIntensity', node='hardwareRenderingGlobals', exists=True):
cmds.setAttr('hardwareRenderingGlobals.defaultLightIntensity', 3.1415)

def resetDefaultLightIntensityIfUsdGreaterOrEqualTo_24_11(self):
#For Usd 24.11+ reset the default light intensity to 1 instead of PI to counter balance the changes in usd 24.11
if Usd.GetVersion() >= (0, 24, 11):
if maya.mel.eval("optionVar -exists defaultLightIntensity"):
maya.mel.eval("optionVar -fv defaultLightIntensity 1.0")
if cmds.attributeQuery('defaultLightIntensity', node='hardwareRenderingGlobals', exists=True):
cmds.setAttr('hardwareRenderingGlobals.defaultLightIntensity', 1.0)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are pretty much copy-paste, so I'd suggest extracting out a common method to set the default light intensity

@@ -53,6 +54,14 @@ class TestIsolateSelect(mtohUtils.MayaHydraBaseTestCase):

_requiredPlugins = ['mayaHydraCppTests', 'mayaHydraFlowViewportAPILocator']

imageVersion = None

@classmethod
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For 1. : Could we change the modify/reset methods to be more generic/modifiable over time than them being fixed to a single version, since I presume these things could change again? i.e. have something like setDefaultLightIntensityByUsdVersion and resetDefaultLightIntensity, in which we could handle all the different USD versions

For 2. : Could we move the imageVersion class attribute and setup to the MayaHydraBaseTestCase in mtohUtils.py? That way the usd version would always be set automatically, can be used as needed and the code will not have to be copy-pasted in each test

Comment on lines +61 to +62
if cls._usdVersion >= (0, 24, 11):
cls.imageVersion = 'usd_2411+'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I had in mind was actually to move the imageVersion attribute itself to MayaHydraBaseTestCase, but I can see how not all tests might want to use that as their image version(s)

@debloip-adsk debloip-adsk merged commit 64314ba into dev Nov 22, 2024
11 checks passed
@debloip-adsk debloip-adsk deleted the lanierd/HYDRA-1275 branch November 22, 2024 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants