Fix T59925: Crash when adding any generative modifier on a curve with more than one material.
Am not totally convinced that generating meshes without fully valid material info is a good thing, but this seems to be rather common in our code base (in both mesh editing and convert-to-mesh cases). So for now, duplicated code in mesh eval finalization to main displist creation/eval function, synchronizing mat data at the end of modifiers stack eval, if needed.
This commit is contained in:
parent
255ab75eb3
commit
4b2198a96a
Notes:
blender-bot
2023-02-14 09:03:55 +01:00
Referenced by issue #59925, Crash when adding any generative modifier on a curve with more than one material.
|
@ -1089,12 +1089,22 @@ static void curve_calc_modifiers_post(
|
|||
/* XXX2.8(Sybren): make sure the face normals are recalculated as well */
|
||||
BKE_mesh_ensure_normals(modified);
|
||||
|
||||
/* Special tweaks, needed since neither BKE_mesh_new_nomain_from_template() nor
|
||||
* BKE_mesh_new_nomain_from_curve_displist() properly duplicate mat info...
|
||||
*/
|
||||
BLI_strncpy(modified->id.name, cu->id.name, sizeof(modified->id.name));
|
||||
*((short *)modified->id.name) = ID_ME;
|
||||
MEM_SAFE_FREE(modified->mat);
|
||||
/* Set flag which makes it easier to see what's going on in a debugger. */
|
||||
modified->id.tag |= LIB_TAG_COPIED_ON_WRITE_EVAL_RESULT;
|
||||
modified->mat = MEM_dupallocN(cu->mat);
|
||||
modified->totcol = cu->totcol;
|
||||
|
||||
(*r_final) = modified;
|
||||
}
|
||||
else {
|
||||
(*r_final) = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue