Fix T84416: Vertex color baking checks for UVMap

Since the introduction in rB2221389d6e8e, baking to vertex colors would
still check for the existence of a valid UVMap (as if baking to image
textures).

Now check for vertex colors instead if target is
R_BAKE_TARGET_VERTEX_COLORS.

Maniphest Tasks: T84416

Differential Revision: https://developer.blender.org/D10006
This commit is contained in:
Philipp Oeser 2021-01-05 17:56:41 +01:00
parent 6ea01dc509
commit 211e161d76
Notes: blender-bot 2023-02-14 06:17:14 +01:00
Referenced by issue #84416, Cycles: can't bake to vertex colors unless there is 1 Uv Map ("No active Uv Layer found")
1 changed files with 16 additions and 5 deletions

View File

@ -441,13 +441,24 @@ static bool bake_object_check(ViewLayer *view_layer,
}
Mesh *me = (Mesh *)ob->data;
if (CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV) == -1) {
BKE_reportf(
reports, RPT_ERROR, "No active UV layer found in the object \"%s\"", ob->id.name + 2);
return false;
if (target == R_BAKE_TARGET_VERTEX_COLORS) {
MPropCol *mcol = CustomData_get_layer(&me->vdata, CD_PROP_COLOR);
MLoopCol *mloopcol = CustomData_get_layer(&me->ldata, CD_MLOOPCOL);
if (mcol == NULL && mloopcol == NULL) {
BKE_reportf(reports,
RPT_ERROR,
"No vertex colors layer found in the object \"%s\"",
ob->id.name + 2);
return false;
}
}
else if (target == R_BAKE_TARGET_IMAGE_TEXTURES) {
if (CustomData_get_active_layer_index(&me->ldata, CD_MLOOPUV) == -1) {
BKE_reportf(
reports, RPT_ERROR, "No active UV layer found in the object \"%s\"", ob->id.name + 2);
return false;
}
if (target == R_BAKE_TARGET_IMAGE_TEXTURES) {
for (int i = 0; i < ob->totcol; i++) {
bNodeTree *ntree = NULL;
bNode *node = NULL;