diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2013-11-12 00:37:19 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2013-11-12 00:37:19 +0400 |
commit | 59e46005261ea2739fe3d3009ac7cc43fdfa6833 (patch) | |
tree | e13beb4e65c72c04cd2089f4ea11d46103da80e1 /source/blender | |
parent | 7fc1088164303df0807fd78ccffbd0ec8a12a09e (diff) |
Fix [#37380] vertex paint colors don't render.
Another Evil Typo (r) one, you could add much more than the 8 allowed VCol layers!
Note: added some (warning-only) checks in mesh validate functions, but we still have a big issue with new cdlayer merge function, which could generate more than 8 layers of UVs or VCol... Don't know yet how to handle this situation. :(
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_validate.c | 30 | ||||
-rw-r--r-- | source/blender/editors/mesh/mesh_data.c | 2 |
2 files changed, 30 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 1c9576d74d0..a4f5529ee43 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -922,7 +922,7 @@ bool BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata, { bool is_valid = true; bool is_change_v, is_change_e, is_change_l, is_change_p; - int tot_texpoly, tot_uvloop; + int tot_texpoly, tot_uvloop, tot_vcolloop; CustomDataMask mask = check_meshmask ? CD_MASK_MESH : 0; is_valid &= mesh_validate_customdata(vdata, mask, do_verbose, do_fixes, &is_change_v); @@ -932,10 +932,23 @@ bool BKE_mesh_validate_all_customdata(CustomData *vdata, CustomData *edata, tot_texpoly = CustomData_number_of_layers(pdata, CD_MTEXPOLY); tot_uvloop = CustomData_number_of_layers(ldata, CD_MLOOPUV); + tot_vcolloop = CustomData_number_of_layers(ldata, CD_MLOOPCOL); if (tot_texpoly != tot_uvloop) { PRINT_ERR("\tCustomDataLayer mismatch, tot_texpoly(%d), tot_uvloop(%d)\n", tot_texpoly, tot_uvloop); } + if (tot_texpoly > MAX_MTFACE) { + PRINT_ERR("\tMore UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MTFACE, tot_texpoly - MAX_MTFACE); + } + if (tot_uvloop > MAX_MTFACE) { + PRINT_ERR("\tMore UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MTFACE, tot_uvloop - MAX_MTFACE); + } + if (tot_vcolloop > MAX_MCOL) { + PRINT_ERR("\tMore VCol layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MCOL, tot_vcolloop - MAX_MCOL); + } *r_change = (is_change_v || is_change_e || is_change_l || is_change_p); @@ -989,10 +1002,25 @@ void BKE_mesh_cd_validate(Mesh *me) { int totlayer_mtex = CustomData_number_of_layers(&me->pdata, CD_MTEXPOLY); int totlayer_uv = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV); + int totlayer_mcol = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL); int mtex_index = CustomData_get_layer_index(&me->pdata, CD_MTEXPOLY); int uv_index = CustomData_get_layer_index(&me->ldata, CD_MLOOPUV); int i; + /* XXX For now, do not delete those, just warn they are not really usable. */ + if (UNLIKELY(totlayer_mtex > MAX_MTFACE)) { + printf("WARNING! More UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MTFACE, totlayer_mtex - MAX_MTFACE); + } + if (UNLIKELY(totlayer_uv > MAX_MTFACE)) { + printf("WARNING! More UV layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MTFACE, totlayer_uv - MAX_MTFACE); + } + if (UNLIKELY(totlayer_mcol > MAX_MCOL)) { + printf("WARNING! More VCol layers than %d allowed, %d last ones won't be available for render, shaders, etc.\n", + MAX_MCOL, totlayer_mcol - MAX_MCOL); + } + if (LIKELY(totlayer_mtex == totlayer_uv)) { /* pass */ } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index e8cbf0926d4..f35a46b50d3 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -417,7 +417,7 @@ int ED_mesh_color_add(Mesh *me, const char *name, const bool active_set) } else { layernum = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL); - if (layernum >= CD_MLOOPCOL) { + if (layernum >= MAX_MCOL) { return -1; } |