Hair drawing: respect the amount of layers.

Current implementation works with at most of 3 layers, but was not
checked during hair drawing leading to reading from uninitialized
memory.

This commit limits it to the number of layers that is used during
compilation of blender.
This commit is contained in:
Jeroen Bakker 2018-06-28 10:35:48 +02:00
parent 3f2bde5a39
commit f09480b212
1 changed files with 2 additions and 2 deletions

View File

@ -115,12 +115,12 @@ static DRWShadingGroup *drw_shgroup_create_hair_procedural_ex(
/* TODO optimize this. Only bind the ones GPUMaterial needs. */
for (int i = 0; i < hair_cache->num_uv_layers; ++i) {
for (int n = 0; hair_cache->uv_layer_names[i][n][0] != '\0'; ++n) {
for (int n = 0; n < MAX_LAYER_NAME_CT && hair_cache->uv_layer_names[i][n][0] != '\0'; ++n) {
DRW_shgroup_uniform_texture(shgrp, hair_cache->uv_layer_names[i][n], hair_cache->uv_tex[i]);
}
}
for (int i = 0; i < hair_cache->num_col_layers; ++i) {
for (int n = 0; hair_cache->col_layer_names[i][n][0] != '\0'; ++n) {
for (int n = 0; n < MAX_LAYER_NAME_CT && hair_cache->col_layer_names[i][n][0] != '\0'; ++n) {
DRW_shgroup_uniform_texture(shgrp, hair_cache->col_layer_names[i][n], hair_cache->col_tex[i]);
}
}