Skip to content

Conversation

@BittieByte
Copy link
Contributor

@BittieByte BittieByte commented May 16, 2025

Initial version of the layer mask duplication operator. The feature is currently functional but incomplete.

Known issues:

  • Duplicate creates a new decal object instead of reusing the original source.
  • Duplicated mask is not inserted directly below the original.
  • Some properties such as transform values, intensity, and modifiers are not yet copied.

CLOSES #153

@BittieByte BittieByte force-pushed the feature/mask-duplication branch from 0c860cf to 2b1c19e Compare May 16, 2025 14:11
@ucupumar
Copy link
Owner

ucupumar commented May 16, 2025

Oh yeah, I don't realize that you can just create a new mask with all properties copied from the original mask. I thought duplicating a mask is similar to duplicating a layer, which actually copies the node manually. Okay, I'll test this later. Thanks for the PR! 👍

Copy link
Owner

@ucupumar ucupumar left a comment

Choose a reason for hiding this comment

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

I made some comments on the implementation, maybe you can address those. Nice work otherwise! 👍

)

# Copy extra float/vector properties
new_mask.intensity_value = mask.intensity_value
Copy link
Owner

Choose a reason for hiding this comment

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

Copying the intensity_value property directly won't use the updated value that the original mask actually uses. The property only stores the value only when the mask is disabled. This is because ucupaint prioritizes the value that actually exists as node input in the material rather than the one on the python property. Ucupaint always deletes unnecessary nodes and inputs when no entity is using them, so it's for optimization purposes.

You can use get_entity_prop_value and set_entity_prop_value functions to get and set the entity property. Those will guarantee use the correct value. You learn what those functions do in common.py

I hope that's not too confusing, please ask me if you have any questions.

mask_type=mask.type,
texcoord_type=mask.texcoord_type,
uv_name=mask.uv_name,
image=image,
Copy link
Owner

Choose a reason for hiding this comment

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

I think there's should be an option to duplicate packed images, like on Duplicate Layer operator

new_mask.intensity_value = mask.intensity_value

# Transform
new_mask.translation = mask.translation[:]
Copy link
Owner

Choose a reason for hiding this comment

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

For transformation, it's a bit different to copy the values, you need to get the mapping node from the original mask and copy the values to the new mapping node

new_mask.blur_vector_factor = mask.blur_vector_factor

# Decal projection distance
new_mask.decal_distance_value = mask.decal_distance_value
Copy link
Owner

Choose a reason for hiding this comment

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

This one also should use get_entity_prop_value and set_entity_prop_value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add duplicate mask operator

2 participants