[Bf-blender-cvs] [3e305dc] gooseberry: Fix for particle shape key editing to prevent losing shape data when switching the active key.

Lukas Tönne noreply at git.blender.org
Mon Apr 20 18:59:03 CEST 2015


Commit: 3e305dcaee0939fd7dd0f1285fc1d08b5826b35a
Author: Lukas Tönne
Date:   Mon Apr 20 18:54:56 2015 +0200
Branches: gooseberry
https://developer.blender.org/rB3e305dcaee0939fd7dd0f1285fc1d08b5826b35a

Fix for particle shape key editing to prevent losing shape data
when switching the active key.

Particle shapes were always using the relative blending of keys when
evaluating hair data. This works ok for meshes, because their edit data
is entirely separate from the mesh data (using bmesh). For particles,
however, the edit mode is hardwired to the hair data, so when switching
keys in edit mode we must take care to replace everything with the
shape. Otherwise the hair data will be using blender shapes and the edit
data will overwrite any shape keys with that.

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

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

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

diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 862c47b..a1d0680 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -58,6 +58,7 @@
 #include "BKE_curve.h"
 #include "BKE_customdata.h"
 #include "BKE_deform.h"
+#include "BKE_pointcache.h"
 #include "BKE_global.h"
 #include "BKE_key.h"
 #include "BKE_lattice.h"
@@ -1558,6 +1559,7 @@ float *BKE_key_evaluate_object(Object *ob, int *r_totelem)
 float *BKE_key_evaluate_particles_ex(Object *ob, ParticleSystem *psys, float cfra, int *r_totelem,
                                      float *arr, size_t arr_size)
 {
+	const bool use_editmode = (ob->mode & OB_MODE_PARTICLE_EDIT) && psys == psys_get_current(ob) && (psys->edit || psys->pointcache->edit) && !psys->renderdata;
 	Key *key = psys->key;
 	KeyBlock *actkb = BKE_keyblock_from_particles(psys);
 	char *out;
@@ -1592,7 +1594,21 @@ float *BKE_key_evaluate_particles_ex(Object *ob, ParticleSystem *psys, float cfr
 	/* prevent python from screwing this up? anyhoo, the from pointer could be dropped */
 	BKE_key_set_from_particles(key, ob, psys);
 	
-	if (ob->shapeflag & OB_SHAPE_LOCK) {
+	if (use_editmode) {
+		/* in edit mode, only evaluate the active shape */
+		KeyBlock *kb = BLI_findlink(&key->block, psys->shapenr - 1);
+		
+		if (kb && (kb->flag & KEYBLOCK_MUTE))
+			kb = key->refkey;
+		
+		if (kb == NULL) {
+			kb = key->block.first;
+			psys->shapenr = 1;
+		}
+		
+		cp_key(0, tot, tot, out, key, actkb, kb, NULL, 0);
+	}
+	else if (ob->shapeflag & OB_SHAPE_LOCK) {
 		/* shape locked, copy the locked shape instead of blending */
 		KeyBlock *kb = BLI_findlink(&key->block, psys->shapenr - 1);
 		float *weights;




More information about the Bf-blender-cvs mailing list