[Bf-blender-cvs] [ed1dc43] strand_editmode: Fix for strands undo creating an invalid BMesh.

Lukas Tönne noreply at git.blender.org
Mon Apr 20 14:24:31 CEST 2015


Commit: ed1dc43657c6362ec91a4cc4a1e80021279a9415
Author: Lukas Tönne
Date:   Sun Feb 1 14:20:45 2015 +0100
Branches: strand_editmode
https://developer.blender.org/rBed1dc43657c6362ec91a4cc4a1e80021279a9415

Fix for strands undo creating an invalid BMesh.

When copying mesh data to bmesh the MVERT and similar customdata types
have to be omitted. Otherwise the bmesh instance ends up with NULL
pointers in customdata layers, but entries in the typemap != -1. The
effect was that when storing new steps after one or more undo, the
resulting original data would be copied, and subsequent undo steps
are ignored.

===================================================================

M	source/blender/blenkernel/BKE_customdata.h
M	source/blender/blenkernel/intern/customdata.c
M	source/blender/editors/hair/hair_undo.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 85d1a25..8cd6311 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -58,6 +58,7 @@ extern const CustomDataMask CD_MASK_DERIVEDMESH;
 extern const CustomDataMask CD_MASK_BMESH;
 extern const CustomDataMask CD_MASK_FACECORNERS;
 extern const CustomDataMask CD_MASK_STRANDS;
+extern const CustomDataMask CD_MASK_STRANDS_BMESH;
 extern const CustomDataMask CD_MASK_EVERYTHING;
 
 /* for ORIGINDEX layer type, indicates no original index for this element */
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 444163e..dd86d79 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1373,7 +1373,12 @@ const CustomDataMask CD_MASK_STRANDS =
     CD_MASK_MVERT | CD_MASK_MEDGE |
     CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MCOL |
     CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS |
-    CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE | CD_MASK_FREESTYLE_FACE |
+    CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE |
+    CD_MASK_MSURFACE_SAMPLE;
+const CustomDataMask CD_MASK_STRANDS_BMESH =
+    CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT |
+    CD_MASK_PROP_STR | CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MDISPS |
+    CD_MASK_MVERT_SKIN | CD_MASK_FREESTYLE_EDGE |
     CD_MASK_MSURFACE_SAMPLE;
 const CustomDataMask CD_MASK_EVERYTHING =
     CD_MASK_MVERT | CD_MASK_MSTICKY /* DEPRECATED */ | CD_MASK_MDEFORMVERT | CD_MASK_MEDGE | CD_MASK_MFACE |
diff --git a/source/blender/editors/hair/hair_undo.c b/source/blender/editors/hair/hair_undo.c
index 0b169a8..7e1c3cf 100644
--- a/source/blender/editors/hair/hair_undo.c
+++ b/source/blender/editors/hair/hair_undo.c
@@ -118,7 +118,7 @@ static void strands_undo_to_edit(void *undov, void *editv, void *UNUSED(obdata))
 	edit->bm->shapenr = undo->shapenr;
 	
 	bm = BM_mesh_create(&allocsize);
-	BM_mesh_bm_from_me_ex(bm, &undo->me, CD_MASK_STRANDS, false, false, undo->shapenr);
+	BM_mesh_bm_from_me_ex(bm, &undo->me, CD_MASK_STRANDS_BMESH, false, false, undo->shapenr);
 	
 	/* note: have to create the new edit before freeing the old one,
 	 * because it owns the root_dm and we have to copy it before
@@ -184,6 +184,5 @@ void undo_push_strands(bContext *C, const char *name)
 	BMEditStrands *edit = BKE_editstrands_from_object(obact);
 	edit->ob = obact;
 	
-
 	undo_editmode_push(C, name, CTX_data_active_object, strands_get_edit, strands_free_undo, strands_undo_to_edit, strands_edit_to_undo, NULL);
 }




More information about the Bf-blender-cvs mailing list