Cleanup: make functions for setting active/render layer more consistent
The active/render layer is indexed from the first layer of that type. These functions incorrectly subtracted the layer index of *each* layer, instead of the first one. If there's only a single layer this doesn't matter, but when there are multiple layers it will set the wrong active layer for consecutive layers. I'm not aware of any actual errors caused by this, because the active and render layers are only ever queried from the first layer of that type, but it was confusing during debugging a related issue. This patch makes the behavior of CustomData_set_layer_active_index() consistent with CustomData_set_layer_active() and the same for render. Differential Revision: https://developer.blender.org/D14955
This commit is contained in:
committed by
Jacques Lucke
parent
b98175008f
commit
f1beb3b3f6
@@ -2575,18 +2575,24 @@ void CustomData_set_layer_stencil(CustomData *data, int type, int n)
|
||||
|
||||
void CustomData_set_layer_active_index(CustomData *data, int type, int n)
|
||||
{
|
||||
const int layer_index = data->typemap[type];
|
||||
BLI_assert(customdata_typemap_is_valid(data));
|
||||
|
||||
for (int i = 0; i < data->totlayer; i++) {
|
||||
if (data->layers[i].type == type) {
|
||||
data->layers[i].active = n - i;
|
||||
data->layers[i].active = n - layer_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CustomData_set_layer_render_index(CustomData *data, int type, int n)
|
||||
{
|
||||
const int layer_index = data->typemap[type];
|
||||
BLI_assert(customdata_typemap_is_valid(data));
|
||||
|
||||
for (int i = 0; i < data->totlayer; i++) {
|
||||
if (data->layers[i].type == type) {
|
||||
data->layers[i].active_rnd = n - i;
|
||||
data->layers[i].active_rnd = n - layer_index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user