[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25174] trunk/blender: Particles: child editing bugfixes

Brecht Van Lommel brecht at blender.org
Mon Dec 7 18:55:58 CET 2009


Revision: 25174
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25174
Author:   blendix
Date:     2009-12-07 18:55:58 +0100 (Mon, 07 Dec 2009)

Log Message:
-----------
Particles: child editing bugfixes

* Make partial update work again for faster editing.
* Draw parents over children again, nicer for editing.
* Fix crash with remove tools & showing child particles.
* Fix children not disappearing always when setting to None.
* Fix wrong normal for last point in child path.
* Fix a python error in the hair dynamics panel.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/properties_particle.py
    trunk/blender/source/blender/blenkernel/intern/particle.c
    trunk/blender/source/blender/blenkernel/intern/particle_system.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/editors/physics/particle_edit.c
    trunk/blender/source/blender/editors/space_view3d/drawobject.c

Modified: trunk/blender/release/scripts/ui/properties_particle.py
===================================================================
--- trunk/blender/release/scripts/ui/properties_particle.py	2009-12-07 17:21:30 UTC (rev 25173)
+++ trunk/blender/release/scripts/ui/properties_particle.py	2009-12-07 17:55:58 UTC (rev 25174)
@@ -208,6 +208,10 @@
         layout = self.layout
 
         psys = context.particle_system
+
+        if not psys.cloth:
+            return
+
         #part = psys.settings
         cloth = psys.cloth.settings
 
@@ -298,8 +302,8 @@
         sub.prop(part, "random_factor")
 
         #if part.type=='REACTOR':
-        #	sub.prop(part, "reactor_factor")
-        #	sub.prop(part, "reaction_shape", slider=True)
+        #    sub.prop(part, "reactor_factor")
+        #    sub.prop(part, "reaction_shape", slider=True)
 
 
 class PARTICLE_PT_rotation(ParticleButtonsPanel):

Modified: trunk/blender/source/blender/blenkernel/intern/particle.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle.c	2009-12-07 17:21:30 UTC (rev 25173)
+++ trunk/blender/source/blender/blenkernel/intern/particle.c	2009-12-07 17:55:58 UTC (rev 25174)
@@ -2332,6 +2332,7 @@
 	ctx->totparent= totparent;
 	ctx->parent_pass= 0;
 	ctx->cfra= cfra;
+	ctx->editupdate= editupdate;
 
 	psys->lattice = psys_get_lattice(&ctx->sim);
 
@@ -2615,6 +2616,9 @@
 				get_strand_normal(ctx->ma, ornor, cur_length, (state-1)->vel);
 		}
 
+		if(k == ctx->steps)
+			VECSUB(state->vel,state->co,(state-1)->co);
+
 		/* check if path needs to be cut before actual end of data points */
 		if(k){
 			VECSUB(dvec,state->co,(state-1)->co);

Modified: trunk/blender/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle_system.c	2009-12-07 17:21:30 UTC (rev 25173)
+++ trunk/blender/source/blender/blenkernel/intern/particle_system.c	2009-12-07 17:55:58 UTC (rev 25174)
@@ -2925,6 +2925,8 @@
 					psys_find_parents(sim);
 			}
 		}
+		else
+			psys_free_children(psys);
 	}
 
 	if((part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED)==0)

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2009-12-07 17:21:30 UTC (rev 25173)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2009-12-07 17:55:58 UTC (rev 25174)
@@ -10165,8 +10165,14 @@
 	}
 	
 	/* put 2.50 compatibility code here until next subversion bump */
-	
+	{
+		Scene *sce= main->scene.first;
 
+		for(sce=main->scene.first; sce; sce=sce->id.next)
+			if(!sce->toolsettings->particle.selectmode)
+				sce->toolsettings->particle.selectmode= SCE_SELECT_PATH;
+	}
+
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
 	/* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
 

Modified: trunk/blender/source/blender/editors/physics/particle_edit.c
===================================================================
--- trunk/blender/source/blender/editors/physics/particle_edit.c	2009-12-07 17:21:30 UTC (rev 25173)
+++ trunk/blender/source/blender/editors/physics/particle_edit.c	2009-12-07 17:55:58 UTC (rev 25174)
@@ -1174,8 +1174,11 @@
 		}
 	}
 }
+
 void PE_update_object(Scene *scene, Object *ob, int useflag)
 {
+	/* use this to do partial particle updates, not usable when adding or
+	   removing, then a full redo is necessary and calling this may crash */
 	ParticleEditSettings *pset= PE_settings(scene);
 	PTCacheEdit *edit = PE_get_current(scene, ob);
 	POINT_P;
@@ -2064,6 +2067,12 @@
 			edit->mirror_cache= NULL;
 		}
 
+		if(psys->child) {
+			MEM_freeN(psys->child);
+			psys->child= NULL;
+			psys->totchild=0;
+		}
+
 		edit->totpoint= psys->totpart= new_totpart;
 	}
 
@@ -2330,7 +2339,6 @@
 
 	BKE_reportf(op->reports, RPT_INFO, "Remove %d double particles.", totremoved);
 
-	PE_update_object(scene, ob, 0);
 	DAG_id_flush_update(&ob->id, OB_RECALC_DATA);
 	WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, ob);
 
@@ -2507,7 +2515,6 @@
 		recalc_lengths(data.edit);
 	}
 
-	PE_update_object(data.scene, data.ob, 0);
 	DAG_id_flush_update(&data.ob->id, OB_RECALC_DATA);
 	WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE_DATA, data.ob);
 
@@ -3733,7 +3740,6 @@
 		}
 	}
 
-	PE_update_object(scene, OBACT, 0);
 	DAG_id_flush_update(&OBACT->id, OB_RECALC_DATA);
 }
 

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c	2009-12-07 17:21:30 UTC (rev 25173)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c	2009-12-07 17:55:58 UTC (rev 25174)
@@ -4166,6 +4166,16 @@
 		wmLoadMatrix(rv3d->viewmat);
 }
 
+static void draw_update_ptcache_edit(Scene *scene, Object *ob, PTCacheEdit *edit)
+{
+	if(edit->psys && edit->psys->flag & PSYS_HAIR_UPDATED)
+		PE_update_object(scene, ob, 0);
+
+	/* create path and child path cache if it doesn't exist already */
+	if(edit->pathcache==0)
+		psys_cache_edit_paths(scene, ob, edit, CFRA);
+}
+
 static void draw_ptcache_edit(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, PTCacheEdit *edit, int dt)
 {
 	ParticleCacheKey **cache, *path, *pkey;
@@ -4178,15 +4188,7 @@
 	float nosel_col[3];
 	float *pathcol = NULL, *pcol;
 
-
-	if(edit->psys && edit->psys->flag & PSYS_HAIR_UPDATED)
-		PE_update_object(scene, ob, 0);
-
-	/* create path and child path cache if it doesn't exist already */
 	if(edit->pathcache==0)
-		psys_cache_edit_paths(scene, ob, edit, CFRA);
-
-	if(edit->pathcache==0)
 		return;
 
 	PE_hide_keys_time(scene, edit, CFRA);
@@ -5900,22 +5902,6 @@
 
 	if(ob->pd && ob->pd->forcefield) draw_forcefield(scene, ob);
 
-	/* particle mode has to be drawn first so that possible child particles get cached in edit mode */
-	if(		(warning_recursive==0) &&
-			(flag & DRAW_PICKING)==0 &&
-			(!scene->obedit)	
-	  ) {
-
-		if(ob->mode & OB_MODE_PARTICLE_EDIT && ob==OBACT) {
-			PTCacheEdit *edit = PE_get_current(scene, ob);
-			if(edit) {
-				wmLoadMatrix(rv3d->viewmat);
-				draw_ptcache_edit(scene, v3d, rv3d, ob, edit, dt);
-				wmMultMatrix(ob->obmat);
-			}
-		}
-	}
-
 	/* code for new particle system */
 	if(		(warning_recursive==0) &&
 			(ob->particlesystem.first) &&
@@ -5923,6 +5909,8 @@
 			(ob!=scene->obedit)	
 	  ) {
 		ParticleSystem *psys;
+		PTCacheEdit *edit = PE_get_current(scene, ob);
+
 		if(col || (ob->flag & SELECT)) cpack(0xFFFFFF);	/* for visibility, also while wpaint */
 		//glDepthMask(GL_FALSE);
 
@@ -5930,8 +5918,13 @@
 		
 		view3d_cached_text_draw_begin();
 
-		for(psys=ob->particlesystem.first; psys; psys=psys->next)
+		for(psys=ob->particlesystem.first; psys; psys=psys->next) {
+			/* run this so that possible child particles get cached */
+			if(edit && edit->psys == psys)
+				draw_update_ptcache_edit(scene, ob, edit);
+
 			draw_new_particle_system(scene, v3d, rv3d, base, psys, dt);
+		}
 		
 		view3d_cached_text_draw_end(v3d, ar, 0, NULL);
 
@@ -5941,6 +5934,22 @@
 		if(col) cpack(col);
 	}
 
+	/* draw edit particles last so that they can draw over child particles */
+	if(		(warning_recursive==0) &&
+			(flag & DRAW_PICKING)==0 &&
+			(!scene->obedit)	
+	  ) {
+
+		if(ob->mode & OB_MODE_PARTICLE_EDIT && ob==OBACT) {
+			PTCacheEdit *edit = PE_get_current(scene, ob);
+			if(edit) {
+				wmLoadMatrix(rv3d->viewmat);
+				draw_ptcache_edit(scene, v3d, rv3d, ob, edit, dt);
+				wmMultMatrix(ob->obmat);
+			}
+		}
+	}
+
 	/* draw code for smoke */
 	if((md = modifiers_findByType(ob, eModifierType_Smoke)))
 	{





More information about the Bf-blender-cvs mailing list