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

Loading mayaHydra should not set scene as modified. #216

Merged
merged 3 commits into from
Jan 20, 2025

Conversation

ppt-adsk
Copy link
Collaborator

@ppt-adsk ppt-adsk commented Dec 2, 2024

No description provided.

@ppt-adsk ppt-adsk requested a review from debloip-adsk December 2, 2024 18:04
@ppt-adsk ppt-adsk self-assigned this Dec 2, 2024
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Trivial test for modified scene.

@@ -26,6 +26,8 @@ class TestPolygonPrimitives(mtohUtils.MayaHydraBaseTestCase):
IMAGE_DIFF_FAIL_THRESHOLD = 0.05
IMAGE_DIFF_FAIL_PERCENT = 1.5

_requiredPlugins = ['modelingToolkit']
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 plugin was being loaded for all tests, in fixturesUtils.py, but only this test was using it.

@@ -19,9 +19,6 @@
import sys
import unittest

# Plugins that are bundled and loaded by default in a Maya installation
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ArubaTesselator plugin is unused by our tests, and modelingToolkit was only used by a single test.

for defaultPlugin in DEFAULT_PLUGINS:
cmds.loadPlugin(defaultPlugin, quiet=True)
isModified = cmds.file(query=True, modified=True)
assert isModified == wasModified, ('Loading plugin %s modified the scene' % pluginName)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Assert that loading the test fixture plugin does not mark the scene as modified.

@@ -43,61 +43,6 @@
HD_STORM = "HdStormRendererPlugin"
HD_STORM_OVERRIDE = "mayaHydraRenderOverride_" + HD_STORM

def loadPlugin(pluginName):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed dead code.

@@ -35,13 +35,6 @@
HD_STORM_OVERRIDE = "mayaHydraRenderOverride_" + HD_STORM
MAYAUSD_PLUGIN_NAME = 'mayaUsdPlugin'

def checkForPlugin(pluginName: str):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed dead code.

@@ -78,6 +79,44 @@ namespace {
setenv(name.c_str(), value.c_str(), 1);
#endif
}

class SceneModifiedGuard
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Core change in the pull request. Create an RAII guard class to set the scene as unmodified after loading the mayaHydra plugin. Plugins often add default nodes on being loaded. This conceptually does not change the modified state of the scene.

Comment on lines 109 to 111
# We've just opened a new scene, so we should not be modified. Setting
# Storm should conceptually not change that status.
cmds.file(modified=False)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be an assert? The comment makes it sound like this is checking that setting Storm does not change the modified state, but this just forces it to false

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is setting it to unmodified, because the line above (setHdStormRenderer()) modifies the file. I can update the comment if you want.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What confuses me is the contradiction between :

[...] we should not be modified. Setting Storm should conceptually not change that status

and

(setHdStormRenderer()) modifies the file

It's unclear to me whether Storm should mark the file as modified. If it should, then why do force the flag to false, and if it shouldn't, then should this not be an assert, or otherwise point to a problem where setting Storm does change the modified flag without us wanting it to do so?

@ppt-adsk ppt-adsk assigned ppt-adsk and unassigned ppt-adsk Dec 3, 2024
@ppt-adsk ppt-adsk requested a review from debloip-adsk December 3, 2024 20:03
debloip-adsk
debloip-adsk previously approved these changes Dec 3, 2024
@ppt-adsk ppt-adsk added the ready-for-merge Development process is finished, PR is ready for merge label Jan 17, 2025
@lilike-adsk lilike-adsk merged commit c6e6317 into dev Jan 20, 2025
10 checks passed
@lilike-adsk lilike-adsk deleted the tremblp/HYDRA-1266/dont_modify_scene_on_plugin_load branch January 20, 2025 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge Development process is finished, PR is ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants