[Bf-blender-cvs] [4b2198a96ac] master: Fix T59925: Crash when adding any generative modifier on a curve with more than one material.
Bastien Montagne
noreply at git.blender.org
Thu Jan 3 18:09:57 CET 2019
Commit: 4b2198a96ac368fa5f2a353c7c148e015246cccf
Author: Bastien Montagne
Date: Thu Jan 3 18:01:56 2019 +0100
Branches: master
https://developer.blender.org/rB4b2198a96ac368fa5f2a353c7c148e015246cccf
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.
===================================================================
M source/blender/blenkernel/intern/displist.c
===================================================================
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index c5dadb1b529..c5c503966c4 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -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;
}
-
}
}
More information about the Bf-blender-cvs
mailing list