[Bf-blender-cvs] [7a76223f1f1] blender2.8: Ensure BKE_mesh_new_nomain_from_template() always has valid mxxx pointers

Sybren A. Stüvel noreply at git.blender.org
Wed Jun 6 12:28:00 CEST 2018

Commit: 7a76223f1f12b6bb049df1864e5d0cda70060a8f
Author: Sybren A. Stüvel
Date:   Wed Jun 6 12:21:36 2018 +0200
Branches: blender2.8

Ensure BKE_mesh_new_nomain_from_template() always has valid mxxx pointers

When the source mesh doesn't have the primary layers (CD_VERT for vdata,
etc.) the returned mesh also didn't have those layers, even when non-zero
elements were requested (for example requesting 4 vertices would still
result in mvert = NULL).


M	source/blender/blenkernel/intern/mesh.c


diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index f2a5f3b5d5f..b325d8d02d9 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -670,6 +670,9 @@ static Mesh *mesh_new_nomain_from_template_ex(
 		mesh_tessface_clear_intern(me_dst, false);
+	/* The destination mesh should at least have valid primary CD layers,
+	 * even in cases where the source mesh does not. */
+	mesh_ensure_cdlayers_primary(me_dst, do_tessface);
 	mesh_ensure_cdlayers_origindex(me_dst, false);
 	BKE_mesh_update_customdata_pointers(me_dst, false);

More information about the Bf-blender-cvs mailing list