Add layer mask duplication operator#275
Conversation
0c860cf to
2b1c19e
Compare
This reverts commit 2b1c19e.
|
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 extra float/vector properties | ||
| new_mask.intensity_value = mask.intensity_value |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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[:] |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
This one also should use get_entity_prop_value and set_entity_prop_value
Initial version of the layer mask duplication operator. The feature is currently functional but incomplete.
Known issues:
CLOSES #153