Make first non-anonymous CustomData layer active #106972

Closed
Martijn Versteegh wants to merge 1 commits from Baardaap/blender:setfirstnonhiddenlayeractive into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 18 additions and 0 deletions

View File

@ -2851,6 +2851,24 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
new_layer.active_rnd = data->layers[index - 1].active_rnd;
new_layer.active_clone = data->layers[index - 1].active_clone;
new_layer.active_mask = data->layers[index - 1].active_mask;
/* Even though the typemap is invalidated for all types larger than the current type
* it's still valid for the current, because the layers are sorted by type. */
int first_layer_of_type = data->typemap[type];
/* If the previous active layer is an anonymous layer make the new one the active one.
* and analogous for the render,clone and mask layers */
if (data->layers[first_layer_of_type + new_layer.active].anonymous_id) {
new_layer.active = index - first_layer_of_type;
}
if (data->layers[first_layer_of_type + new_layer.active_rnd].anonymous_id) {
new_layer.active_rnd = index - first_layer_of_type;
}
if (data->layers[first_layer_of_type + new_layer.active_clone].anonymous_id) {
new_layer.active_clone = index - first_layer_of_type;
}
if (data->layers[first_layer_of_type + new_layer.active_mask].anonymous_id) {
new_layer.active_mask = index - first_layer_of_type;
}
}
else {
new_layer.active = 0;