Merge branch 'develop' into enhancement/console-allow-name-change

This commit is contained in:
Jakub Trllo 2025-12-16 10:29:43 +01:00 committed by GitHub
commit 1614737053
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 37 additions and 20 deletions

View file

@ -299,7 +299,6 @@ def add_ordered_sublayer(layer, contribution_path, layer_id, order=None,
sdf format args metadata if enabled) sdf format args metadata if enabled)
""" """
# Add the order with the contribution path so that for future # Add the order with the contribution path so that for future
# contributions we can again use it to magically fit into the # contributions we can again use it to magically fit into the
# ordering. We put this in the path because sublayer paths do # ordering. We put this in the path because sublayer paths do
@ -317,20 +316,25 @@ def add_ordered_sublayer(layer, contribution_path, layer_id, order=None,
# If the layer was already in the layers, then replace it # If the layer was already in the layers, then replace it
for index, existing_path in enumerate(layer.subLayerPaths): for index, existing_path in enumerate(layer.subLayerPaths):
args = get_sdf_format_args(existing_path) args = get_sdf_format_args(existing_path)
existing_layer = args.get("layer_id") existing_layer_id = args.get("layer_id")
if existing_layer == layer_id: if existing_layer_id == layer_id:
existing_layer = layer.subLayerPaths[index]
existing_order = args.get("order")
existing_order = int(existing_order) if existing_order else None
if order is not None and order != existing_order:
# We need to move the layer, so we will remove this index
# and then re-insert it below at the right order
log.debug(f"Removing existing layer: {existing_layer}")
del layer.subLayerPaths[index]
break
# Put it in the same position where it was before when swapping # Put it in the same position where it was before when swapping
# it with the original, also take over its order metadata # it with the original, also take over its order metadata
order = args.get("order")
if order is not None:
order = int(order)
else:
order = None
contribution_path = _format_path(contribution_path, contribution_path = _format_path(contribution_path,
order=order, order=existing_order,
layer_id=layer_id) layer_id=layer_id)
log.debug( log.debug(
f"Replacing existing layer: {layer.subLayerPaths[index]} " f"Replacing existing layer: {existing_layer} "
f"-> {contribution_path}" f"-> {contribution_path}"
) )
layer.subLayerPaths[index] = contribution_path layer.subLayerPaths[index] = contribution_path

View file

@ -16,7 +16,7 @@ from ayon_core.lib import (
UISeparatorDef, UISeparatorDef,
UILabelDef, UILabelDef,
EnumDef, EnumDef,
filter_profiles filter_profiles, NumberDef
) )
try: try:
from ayon_core.pipeline.usdlib import ( from ayon_core.pipeline.usdlib import (
@ -275,7 +275,7 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin,
# the contributions so that we can design a system where custom # the contributions so that we can design a system where custom
# contributions outside the predefined orders are possible to be # contributions outside the predefined orders are possible to be
# managed. So that if a particular asset requires an extra contribution # managed. So that if a particular asset requires an extra contribution
# level, you can add itdirectly from the publisher at that particular # level, you can add it directly from the publisher at that particular
# order. Future publishes will then see the existing contribution and will # order. Future publishes will then see the existing contribution and will
# persist adding it to future bootstraps at that order # persist adding it to future bootstraps at that order
contribution_layers: Dict[str, int] = { contribution_layers: Dict[str, int] = {
@ -334,10 +334,7 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin,
attr_values[key] = attr_values[key].format(**data) attr_values[key] = attr_values[key].format(**data)
# Define contribution # Define contribution
order = self.contribution_layers.get( in_layer_order: int = attr_values.get("contribution_in_layer_order", 0)
attr_values["contribution_layer"], 0
)
if attr_values["contribution_apply_as_variant"]: if attr_values["contribution_apply_as_variant"]:
contribution = VariantContribution( contribution = VariantContribution(
instance=instance, instance=instance,
@ -346,18 +343,21 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin,
variant_set_name=attr_values["contribution_variant_set_name"], variant_set_name=attr_values["contribution_variant_set_name"],
variant_name=attr_values["contribution_variant"], variant_name=attr_values["contribution_variant"],
variant_is_default=attr_values["contribution_variant_is_default"], # noqa: E501 variant_is_default=attr_values["contribution_variant_is_default"], # noqa: E501
order=order order=in_layer_order
) )
else: else:
contribution = SublayerContribution( contribution = SublayerContribution(
instance=instance, instance=instance,
layer_id=attr_values["contribution_layer"], layer_id=attr_values["contribution_layer"],
target_product=attr_values["contribution_target_product"], target_product=attr_values["contribution_target_product"],
order=order order=in_layer_order
) )
asset_product = contribution.target_product asset_product = contribution.target_product
layer_product = "{}_{}".format(asset_product, contribution.layer_id) layer_product = "{}_{}".format(asset_product, contribution.layer_id)
layer_order: int = self.contribution_layers.get(
attr_values["contribution_layer"], 0
)
# Layer contribution instance # Layer contribution instance
layer_instance = self.get_or_create_instance( layer_instance = self.get_or_create_instance(
@ -370,7 +370,7 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin,
contribution contribution
) )
layer_instance.data["usd_layer_id"] = contribution.layer_id layer_instance.data["usd_layer_id"] = contribution.layer_id
layer_instance.data["usd_layer_order"] = contribution.order layer_instance.data["usd_layer_order"] = layer_order
layer_instance.data["productGroup"] = ( layer_instance.data["productGroup"] = (
instance.data.get("productGroup") or "USD Layer" instance.data.get("productGroup") or "USD Layer"
@ -561,6 +561,19 @@ class CollectUSDLayerContributions(pyblish.api.InstancePlugin,
items=list(cls.contribution_layers.keys()), items=list(cls.contribution_layers.keys()),
default=default_contribution_layer, default=default_contribution_layer,
visible=visible), visible=visible),
# TODO: We may want to make the visibility of this optional
# based on studio preference, to avoid complexity when not needed
NumberDef("contribution_in_layer_order",
label="Strength order",
tooltip=(
"The contribution inside the department layer will be "
"made with this offset applied. A higher number means "
"a stronger opinion."
),
default=0,
minimum=-99999,
maximum=99999,
visible=visible),
BoolDef("contribution_apply_as_variant", BoolDef("contribution_apply_as_variant",
label="Add as variant", label="Add as variant",
tooltip=( tooltip=(
@ -729,7 +742,7 @@ class ExtractUSDLayerContribution(publish.Extractor):
layer=sdf_layer, layer=sdf_layer,
contribution_path=path, contribution_path=path,
layer_id=product_name, layer_id=product_name,
order=None, # unordered order=contribution.order,
add_sdf_arguments_metadata=True add_sdf_arguments_metadata=True
) )
else: else: