This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Maya: Implement iter_visible_nodes_in_range
for extracting Alembics
#3100
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b74774d
Implement `get_visible_in_frame_range` for extracting Alembics
BigRoy 66f8ebb
Use MDGContext as context manager
BigRoy 338bb15
Fix bug in `iter_parents`
BigRoy b7d5221
Remove redundant workaround
BigRoy 4c259c4
Improve comments
BigRoy a521c87
Merge remote-tracking branch 'upstream/develop' into fix3085
BigRoy 3b8b479
Skip extraction when no visible nodes found in frame range
BigRoy ee27389
Add alembic visible only validator
BigRoy 96150eb
Remove no visible nodes warning in extractors since validator catches…
BigRoy a29d1d4
Use iterator to speed up visible only validation for most cases
BigRoy a99cc8f
Fix iterator
BigRoy 19a5ed7
Refactor `iter_visible_in_frame_range` -> `iter_visible_nodes_in_range`
BigRoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
openpype/hosts/maya/plugins/publish/validate_visible_only.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import pyblish.api | ||
|
||
import openpype.api | ||
from openpype.hosts.maya.api.lib import iter_visible_nodes_in_range | ||
import openpype.hosts.maya.api.action | ||
|
||
|
||
class ValidateAlembicVisibleOnly(pyblish.api.InstancePlugin): | ||
"""Validates at least a single node is visible in frame range. | ||
|
||
This validation only validates if the `visibleOnly` flag is enabled | ||
on the instance - otherwise the validation is skipped. | ||
|
||
""" | ||
order = openpype.api.ValidateContentsOrder + 0.05 | ||
label = "Alembic Visible Only" | ||
hosts = ["maya"] | ||
families = ["pointcache", "animation"] | ||
actions = [openpype.hosts.maya.api.action.SelectInvalidAction] | ||
|
||
def process(self, instance): | ||
|
||
if not instance.data.get("visibleOnly", False): | ||
self.log.debug("Visible only is disabled. Validation skipped..") | ||
return | ||
|
||
invalid = self.get_invalid(instance) | ||
if invalid: | ||
start, end = self.get_frame_range(instance) | ||
raise RuntimeError("No visible nodes found in " | ||
"frame range {}-{}.".format(start, end)) | ||
|
||
@classmethod | ||
def get_invalid(cls, instance): | ||
|
||
if instance.data["family"] == "animation": | ||
# Special behavior to use the nodes in out_SET | ||
nodes = instance.data["out_hierarchy"] | ||
else: | ||
nodes = instance[:] | ||
|
||
start, end = cls.get_frame_range(instance) | ||
if not any(iter_visible_nodes_in_range(nodes, start, end)): | ||
# Return the nodes we have considered so the user can identify | ||
# them with the select invalid action | ||
return nodes | ||
|
||
@staticmethod | ||
def get_frame_range(instance): | ||
data = instance.data | ||
return data["frameStartHandle"], data["frameEndHandle"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning
It's good to be aware that this logic depends on THIS Collector plug-in.
The bug/issue is that if the instance in Maya is set to
active=False
on the objectSet/instance directly that that Collector does not run. This bug is present in many more areas actually so be aware.There are two solutions to that:
__active
. Then have a very later Collector (CollectorOrder + 0.499
) which setsinstance.data["active"] = instance.data,pop("__active", True)
- so that up to that point all collectors do run as expected.PYBLISH_QML_POST_COLLECT
see: Implementing "Post Collect" pyblish/pyblish-qml#356 - that way we can have these collectors that should always run for an active instance in the post collection step after the user toggled states. Upside to this is that collecting will be MUCH faster since many collectors could move to the post collector order.@mkolar Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that during local publishing (artist publishing where he can toggle instance activity) we process during collection all instances no matter if they are active or not (until collector check that on it's own?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's any collector that appends data into an instance that would fail to do so for inactive instances. So I suspect the issue will also exist for these:
Basically anything running over the instance would not actually run because Collect Instances already collects directly whether the instance should be considered "active" to run over the instance for. So the issue is much more widespread than just this particular one.