Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Maya: Optional viewport refresh on pointcache extraction #4144

Merged
merged 2 commits into from
Dec 2, 2022

Conversation

tokejepsen
Copy link
Member

Brief description

Optional viewport refresh on pointcache extraction.

Description

Sometimes you need the viewport to refresh for example when dealing with the bullet plugin.

Additional info

The rest will be ignored in changelog and should contain any additional
technical information.

Documentation (add "type: documentation" label)

feature_documentation

Testing notes:

  1. Create pointcache.
  2. Enabled refresh.
  3. See the viewport update as extraction is done.

@tokejepsen tokejepsen changed the title Optional viewport refresh on pointcache extraction Maya: Optional viewport refresh on pointcache extraction Nov 28, 2022
@mkolar mkolar added type: enhancement Enhancements to existing functionality host: Maya labels Dec 1, 2022
Copy link
Member

@LiborBatek LiborBatek left a comment

Choose a reason for hiding this comment

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

Everything seems ok. Pointcache being published and viewport updates as it goes when
Refresh option on pointcache family turned on
image

@BigRoy
Copy link
Collaborator

BigRoy commented Dec 1, 2022

What if we'd refactor suspended_refresh so that it takes an argument, and when False it also ensures/forces the viewport isn't suspended. That way it does still what you'd want even if the user had his viewport manually suspended - safer, and cleaner code?

@contextlib.contextmanager
def suspended_refresh(suspend=True):
    """Suspend viewport refreshes"""
    original_state= cmds.refresh(query=True, suspend=True)
    try:
        cmds.refresh(suspend=suspend)
        yield
    finally:
        cmds.refresh(suspend=original_state)

Otherwise a user that prior to publishing had his viewport disabled would've not gotten the same result.

@tokejepsen thoughts?

@tokejepsen
Copy link
Member Author

What if we'd refactor suspended_refresh so that it takes an argument, and when False it also ensures/forces the viewport isn't suspended. That way it does still what you'd want even if the user had his viewport manually suspended - safer, and cleaner code?

@contextlib.contextmanager
def suspended_refresh(suspend=True):
    """Suspend viewport refreshes"""
    original_state= cmds.refresh(query=True, suspend=True)
    try:
        cmds.refresh(suspend=suspend)
        yield
    finally:
        cmds.refresh(suspend=original_state)

Otherwise a user that prior to publishing had his viewport disabled would've not gotten the same result.

@tokejepsen thoughts?

Good point. Will have a look.

@tokejepsen tokejepsen marked this pull request as draft December 2, 2022 11:07
@tokejepsen tokejepsen marked this pull request as ready for review December 2, 2022 12:10
@antirotor antirotor merged commit c9e59c4 into ynput:develop Dec 2, 2022
@github-actions github-actions bot added this to the next-patch milestone Dec 2, 2022
@tokejepsen tokejepsen deleted the enhancement/maya_pointcache branch December 2, 2022 22:06
@tokejepsen
Copy link
Member Author

@BigRoy looks we merged too fast here, cause cmds.refresh is not queryable.

@BigRoy
Copy link
Collaborator

BigRoy commented Dec 8, 2022

cause cmds.refresh is not queryable.

Looks like you're correct.

Option 1

As such that'd make cmds.refresh(suspend=True) context manager only able to do this if we'd really need it that way:

@contextlib.contextmanager
def suspended_refresh(suspend=True):
    """Suspend viewport refreshes"""
    try:
        cmds.refresh(suspend=suspend)
        yield
    finally:
        cmds.refresh(suspend=False)

Option 2

Other option for disabling the viewport as an optimization could be cmds.ogs(pause=True)` which is queryable and essentially boils down to almost the same thing? (Just pauses viewports).

Option 3

There's also the very old school:

from maya import cmds
from maya import mel

main_pane = mel.eval("$gMainPaine=$gMainPane;")
cmds.paneLayout(main_pane, edit=True, manage=False)

To make Maya's main window unmanaged and disable and refreshes of it that way - however, torn off panels I believe would remain managed.

--

I'd recommend either Option 1 or 2.

@tokejepsen tokejepsen restored the enhancement/maya_pointcache branch December 9, 2022 10:05
@tokejepsen tokejepsen mentioned this pull request Dec 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
host: Maya type: enhancement Enhancements to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants