[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30659] trunk/blender/source/blender/ editors/physics/particle_edit.c: Fix for [#22644] hair particles bug 2, patch by Lukas Toenne

Janne Karhu jhkarh at gmail.com
Fri Jul 23 18:48:45 CEST 2010


Revision: 30659
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30659
Author:   jhk
Date:     2010-07-23 18:48:45 +0200 (Fri, 23 Jul 2010)

Log Message:
-----------
Fix for [#22644] hair particles bug 2, patch by Lukas Toenne

Modified Paths:
--------------
    trunk/blender/source/blender/editors/physics/particle_edit.c

Modified: trunk/blender/source/blender/editors/physics/particle_edit.c
===================================================================
--- trunk/blender/source/blender/editors/physics/particle_edit.c	2010-07-23 15:36:27 UTC (rev 30658)
+++ trunk/blender/source/blender/editors/physics/particle_edit.c	2010-07-23 16:48:45 UTC (rev 30659)
@@ -2098,6 +2098,7 @@
 	ParticleData *pa;
 	HairKey *hkey, *nhkey, *new_hkeys=0;
 	POINT_P; KEY_K;
+	PTCacheEditKey *nkey, *new_keys;
 	ParticleSystemModifierData *psmd;
 	short new_totkey;
 
@@ -2133,9 +2134,10 @@
 		}
 
 		if(new_totkey != pa->totkey) {
-			hkey= pa->hair;
 			nhkey= new_hkeys= MEM_callocN(new_totkey*sizeof(HairKey), "HairKeys");
+			nkey= new_keys= MEM_callocN(new_totkey*sizeof(PTCacheEditKey), "particle edit keys");
 
+			hkey= pa->hair;
 			LOOP_KEYS {
 				while(key->flag & PEK_TAG && hkey < pa->hair + pa->totkey) {
 					key++;
@@ -2144,29 +2146,36 @@
 
 				if(hkey < pa->hair + pa->totkey) {
 					VECCOPY(nhkey->co, hkey->co);
+					nhkey->editflag = hkey->editflag;
 					nhkey->time= hkey->time;
 					nhkey->weight= hkey->weight;
+					
+					nkey->co= nhkey->co;
+					nkey->time= &nhkey->time;
+					/* these can be copied from old edit keys */
+					nkey->flag = key->flag;
+					nkey->ftime = key->ftime;
+					nkey->length = key->length;
+					VECCOPY(nkey->world_co, key->world_co);
 				}
+				nkey++;
+				nhkey++;
 				hkey++;
-				nhkey++;
 			}
+
 			if(pa->hair)
 				MEM_freeN(pa->hair);
+
+			if(point->keys)
+				MEM_freeN(point->keys);
 			
 			pa->hair= new_hkeys;
+			point->keys= new_keys;
 
 			point->totkey= pa->totkey= new_totkey;
 
-			if(point->keys)
-				MEM_freeN(point->keys);
-			key= point->keys= MEM_callocN(new_totkey*sizeof(PTCacheEditKey), "particle edit keys");
-
-			hkey = pa->hair;
-			LOOP_KEYS {
-				key->co= hkey->co;
-				key->time= &hkey->time;
-				hkey++;
-			}
+			/* flag for recalculating length */
+			point->flag |= PEP_EDIT_RECALC;
 		}
 	}
 }





More information about the Bf-blender-cvs mailing list