Fix #135370: Crash when baking textures with a modified UV map
The report was storing a non-2D-Vector attribute with geometry nodes over a valid UVMap, resulting in the evaluated mesh not having a valid `CD_PROP_FLOAT2` layer anymore. There is already a check to early out for the original mesh in case it has no UVs, but as mentioned, not for the **evaluated** (cage/multi-no-res) mesh which is actually/rightfully used to get the UVs. To resolve, check again if we have UVs right after getting he mesh that is actually used. (we might even want to remove the first check, seems redundant now - even though it would early out a bit sooner...) Pull Request: https://projects.blender.org/blender/blender/pulls/135388
This commit is contained in:
committed by
Philipp Oeser
parent
84123446e3
commit
f3161149db
@@ -1518,6 +1518,13 @@ static int bake(const BakeAPIRender *bkr,
|
||||
pixel_array_low = static_cast<BakePixel *>(
|
||||
MEM_mallocN(sizeof(BakePixel) * targets.pixels_num, "bake pixels low poly"));
|
||||
if ((bkr->is_selected_to_active && (ob_cage == nullptr) && bkr->is_cage) == false) {
|
||||
if (!CustomData_has_layer(&me_low_eval->corner_data, CD_PROP_FLOAT2)) {
|
||||
BKE_reportf(reports,
|
||||
RPT_ERROR,
|
||||
"No UV map found in the evaluated object \"%s\"",
|
||||
ob_low->id.name + 2);
|
||||
goto cleanup;
|
||||
}
|
||||
bake_targets_populate_pixels(bkr, &targets, ob_low, me_low_eval, pixel_array_low);
|
||||
}
|
||||
|
||||
@@ -1570,6 +1577,13 @@ static int bake(const BakeAPIRender *bkr,
|
||||
}
|
||||
|
||||
me_cage_eval = BKE_mesh_new_from_object(nullptr, ob_low_eval, false, preserve_origindex);
|
||||
if (!CustomData_has_layer(&me_cage_eval->corner_data, CD_PROP_FLOAT2)) {
|
||||
BKE_reportf(reports,
|
||||
RPT_ERROR,
|
||||
"No UV map found in the evaluated object \"%s\"",
|
||||
ob_low->id.name + 2);
|
||||
goto cleanup;
|
||||
}
|
||||
bake_targets_populate_pixels(bkr, &targets, ob_low, me_cage_eval, pixel_array_low);
|
||||
}
|
||||
|
||||
@@ -1752,6 +1766,14 @@ static int bake(const BakeAPIRender *bkr,
|
||||
|
||||
/* Evaluate modifiers again. */
|
||||
me_nores = BKE_mesh_new_from_object(nullptr, ob_low_eval, false, false);
|
||||
if (!CustomData_has_layer(&me_nores->corner_data, CD_PROP_FLOAT2)) {
|
||||
BKE_reportf(reports,
|
||||
RPT_ERROR,
|
||||
"No UV map found in the evaluated object \"%s\"",
|
||||
ob_low->id.name + 2);
|
||||
BKE_id_free(nullptr, &me_nores->id);
|
||||
goto cleanup;
|
||||
}
|
||||
bake_targets_populate_pixels(bkr, &targets, ob_low, me_nores, pixel_array_low);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user