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. :(
This commit is contained in:
2013-11-11 20:37:19 +00:00
parent 7fc1088164
commit 59e4600526
2 changed files with 30 additions and 2 deletions

View File

@@ -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 */
}

View File

@@ -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;
}