Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartijn Versteegh <Baardaap>2022-05-16 17:32:41 +0300
committerJacques Lucke <jacques@blender.org>2022-05-16 17:34:25 +0300
commitf1beb3b3f60be45854285935d6bfcedf839b317c (patch)
tree480385ee07be3e8891a3b32d5e9ff3d958d587de
parentb98175008f16fba9365e1c07dd50fd0a2a390dbc (diff)
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
-rw-r--r--source/blender/blenkernel/intern/customdata.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 62351a31042..52d2060a1fc 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -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;
}
}
}