[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21552] branches/blender2.5/blender: Keyed physics refresh:

Janne Karhu jhkarh at utu.fi
Mon Jul 13 01:38:47 CEST 2009


Revision: 21552
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21552
Author:   jhk
Date:     2009-07-13 01:38:47 +0200 (Mon, 13 Jul 2009)

Log Message:
-----------
Keyed physics refresh:
- Keyed targets in one list instead of "chaining", this opens up many more possibilities than before and is much less obscure.
- Better keyed timing possibilities (time & duration in frames).
- Looping over keyed targets list.

Other changes:
- New child setting "length" with threshold (great for guard & underfur with a single particle system)
- Modularization of path interpolation code.
- Cleared "animateable" flags from many particle settings that shouldn't be animateable.

Fixes:
- Keyed particles weren't copied properly (ancient bug).
- Hair rotations depended on global z-axis for root rotation so downward facing strands could flip rotation randomly. Now initial hair rotation is derived from face dependent hair matrix. (This caused for example ugly flipping of child strands on some cases).
- Children from faces weren't calculated straight after activating them.
- Multiple disk cache fixes:
	* Disk cache didn't work correctly with frame steps.
	* Conversion from memory cache to disk cache didn't work with cloth.
	* Disk cache crashed on some frames trying to close an already closed cache file.
	* Trails didn't work with disk cached particles.
- Child rough effects were effected by emitter object loc/rot making them next to useless with animation, why didn't anybody tell me this!!
- Lots of random code cleanup.

Modified Paths:
--------------
    branches/blender2.5/blender/release/ui/buttons_particle.py
    branches/blender2.5/blender/source/blender/blenkernel/BKE_particle.h
    branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/object.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/particle.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/particle_system.c
    branches/blender2.5/blender/source/blender/blenkernel/intern/pointcache.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/blenloader/intern/writefile.c
    branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_intern.h
    branches/blender2.5/blender/source/blender/editors/space_buttons/buttons_ops.c
    branches/blender2.5/blender/source/blender/editors/space_buttons/space_buttons.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/drawobject.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_particle_types.h
    branches/blender2.5/blender/source/blender/makesrna/RNA_access.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_particle.c
    branches/blender2.5/blender/source/blender/render/intern/source/convertblender.c

Modified: branches/blender2.5/blender/release/ui/buttons_particle.py
===================================================================
--- branches/blender2.5/blender/release/ui/buttons_particle.py	2009-07-12 18:04:10 UTC (rev 21551)
+++ branches/blender2.5/blender/release/ui/buttons_particle.py	2009-07-12 23:38:47 UTC (rev 21552)
@@ -131,6 +131,9 @@
 		psys = context.particle_system
 		if psys==None:	return False
 		if psys.settings==None:  return False
+		phystype = psys.settings.physics_type
+		if phystype == 'NO' or phystype == 'KEYED':
+			return False
 		return psys.settings.type in ('EMITTER', 'REACTOR')
 
 	def draw(self, context):
@@ -277,16 +280,40 @@
 			sub.itemR(part, "acceleration")
 			
 		elif part.physics_type == 'KEYED':
-			sub.itemR(psys, "keyed_first")
-			if psys.keyed_first==True:
-				sub.itemR(psys, "timed_keys", text="Key timing")
-			else:
-				sub.itemR(part, "keyed_time")
-			sub = split.column()
-			sub.itemL(text="Next key from object:")
-			sub.itemR(psys, "keyed_object", text="")
-			sub.itemR(psys, "keyed_particle_system")
-		
+			row = layout.row()
+			col = row.column()
+			col.active = not psys.keyed_timing
+			col.itemR(part, "keyed_loops", text="Loops")
+			row.itemR(psys, "keyed_timing", text="Use Timing")
+			
+			layout.itemL(text="Keys:")
+			row = layout.row()
+			
+			row.template_list(psys, "keyed_targets", psys, "active_keyed_target_index")
+			
+			col = row.column()
+			subrow = col.row()
+			subcol = subrow.column(align=True)
+			subcol.itemO("PARTICLE_OT_new_keyed_target", icon="ICON_ZOOMIN", text="")
+			subcol.itemO("PARTICLE_OT_remove_keyed_target", icon="ICON_ZOOMOUT", text="")
+			subrow = col.row()
+			subcol = subrow.column(align=True)
+			subcol.itemO("PARTICLE_OT_keyed_target_move_up", icon="VICON_MOVE_UP", text="")
+			subcol.itemO("PARTICLE_OT_keyed_target_move_down", icon="VICON_MOVE_DOWN", text="")
+			
+			key = psys.active_keyed_target
+			if key:
+				row = layout.row()
+				col = row.column()
+				#doesn't work yet
+				#col.red_alert = key.valid
+				col.itemR(key, "object", text="")
+				col.itemR(key, "system", text="System")
+				col = row.column();
+				col.active = psys.keyed_timing
+				col.itemR(key, "time")
+				col.itemR(key, "duration")
+			
 		if part.physics_type=='NEWTON' or part.physics_type=='BOIDS':
 
 			sub.itemR(part, "size_deflect")
@@ -308,7 +335,7 @@
 
 		psys = context.particle_system
 		part = psys.settings
-		
+
 		row = layout.row()
 		row.itemR(part, "material")
 		row.itemR(psys, "parent");
@@ -336,7 +363,7 @@
 			sub.itemR(part, "velocity_length")
 		elif part.ren_as == 'PATH':
 		
-			if (part.type!='HAIR' and psys.point_cache.baked==False):
+			if (part.type!='HAIR' and part.physics_type!='KEYED' and psys.point_cache.baked==False):
 				box = layout.box()
 				box.itemL(text="Baked or keyed particles needed for correct rendering.")
 				return
@@ -460,7 +487,7 @@
 			
 		path = (part.ren_as=='PATH' and part.draw_as=='RENDER') or part.draw_as=='PATH'
 			
-		if path and part.type!='HAIR' and psys.point_cache.baked==False:
+		if path and part.type!='HAIR' and part.physics_type!='KEYED' and psys.point_cache.baked==False:
 			box = layout.box()
 			box.itemL(text="Baked or keyed particles needed for correct drawing.")
 			return
@@ -549,6 +576,15 @@
 		col.itemR(part, "rough2_size")
 		col.itemR(part, "rough2_thres", slider=True)
 		
+		row = layout.row()
+		col = row.column(align=True)
+		col.itemR(part, "child_length", slider=True)
+		col.itemR(part, "child_length_thres", slider=True)
+		
+		col = row.column(align=True)
+		col.itemL(text="Space reserved for")
+		col.itemL(text="hair parting controls")
+		
 		layout.row().itemL(text="Kink:")
 		layout.row().itemR(part, "kink", expand=True)
 		

Modified: branches/blender2.5/blender/source/blender/blenkernel/BKE_particle.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/BKE_particle.h	2009-07-12 18:04:10 UTC (rev 21551)
+++ branches/blender2.5/blender/source/blender/blenkernel/BKE_particle.h	2009-07-12 23:38:47 UTC (rev 21552)
@@ -260,7 +260,6 @@
 void make_local_particlesettings(struct ParticleSettings *part);
 
 struct LinkNode *psys_using_settings(struct Scene *scene, struct ParticleSettings *part, int flush_update);
-void psys_changed_type(struct ParticleSystem *psys);
 void psys_reset(struct ParticleSystem *psys, int mode);
 
 void psys_find_parents(struct Object *ob, struct ParticleSystemModifierData *psmd, struct ParticleSystem *psys);
@@ -289,12 +288,14 @@
 void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]);
 
 /* particle_system.c */
-int psys_count_keyed_targets(struct Object *ob, struct ParticleSystem *psys);
+void psys_count_keyed_targets(struct Object *ob, struct ParticleSystem *psys);
 void psys_get_reactor_target(struct Object *ob, struct ParticleSystem *psys, struct Object **target_ob, struct ParticleSystem **target_psys);
 
 void psys_init_effectors(struct Scene *scene, struct Object *obsrc, struct Group *group, struct ParticleSystem *psys);
 void psys_end_effectors(struct ParticleSystem *psys);
 
+void psys_make_temp_pointcache(struct Object *ob, struct ParticleSystem *psys);
+void psys_end_temp_pointcache(struct ParticleSystem *psys);
 void psys_get_pointcache_start_end(struct Scene *scene, struct ParticleSystem *psys, int *sfra, int *efra);
 
 void particle_system_update(struct Scene *scene, struct Object *ob, struct ParticleSystem *psys);

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c	2009-07-12 18:04:10 UTC (rev 21551)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/depsgraph.c	2009-07-12 23:38:47 UTC (rev 21552)
@@ -562,10 +562,17 @@
 			if(!psys_check_enabled(ob, psys))
 				continue;
 
-			if(part->phystype==PART_PHYS_KEYED && psys->keyed_ob &&
-			   BLI_findlink(&psys->keyed_ob->particlesystem,psys->keyed_psys-1)) {
-				node2 = dag_get_node(dag, psys->keyed_ob);
-				dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA, "Particle Keyed Physics");
+			if(part->phystype==PART_PHYS_KEYED) {
+				KeyedParticleTarget *kpt = psys->keyed_targets.first;
+
+				for(; kpt; kpt=kpt->next) {
+					if(kpt->ob && BLI_findlink(&kpt->ob->particlesystem, kpt->psys-1)) {
+						node2 = dag_get_node(dag, kpt->ob);
+						dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Particle Keyed Physics");
+					}
+					else
+						break;
+			   }
 			}
 
 			if(part->ren_as == PART_DRAW_OB && part->dup_ob) {

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/object.c	2009-07-12 18:04:10 UTC (rev 21551)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/object.c	2009-07-12 23:38:47 UTC (rev 21552)
@@ -427,17 +427,14 @@
 		if(obt->particlesystem.first) {
 			ParticleSystem *tpsys= obt->particlesystem.first;
 			for(; tpsys; tpsys=tpsys->next) {
-				if(tpsys->keyed_ob==ob) {
-					ParticleSystem *psys= BLI_findlink(&ob->particlesystem,tpsys->keyed_psys-1);
-
-					if(psys && psys->keyed_ob) {
-						tpsys->keyed_ob= psys->keyed_ob;
-						tpsys->keyed_psys= psys->keyed_psys;
+				KeyedParticleTarget *kpt = tpsys->keyed_targets.first;
+				for(; kpt; kpt=kpt->next) {
+					if(kpt->ob==ob) {
+						BLI_remlink(&tpsys->keyed_targets, kpt);
+						MEM_freeN(kpt);
+						obt->recalc |= OB_RECALC_DATA;
+						break;
 					}
-					else
-						tpsys->keyed_ob= NULL;
-
-					obt->recalc |= OB_RECALC_DATA;
 				}
 
 				if(tpsys->target_ob==ob) {
@@ -1050,18 +1047,23 @@
 	psysn= MEM_dupallocN(psys);
 	psysn->particles= MEM_dupallocN(psys->particles);
 	psysn->child= MEM_dupallocN(psys->child);
+	if(psysn->particles->keys)
+		psysn->particles->keys = MEM_dupallocN(psys->particles->keys);
 
 	for(a=0, pa=psysn->particles; a<psysn->totpart; a++, pa++) {
 		if(pa->hair)
 			pa->hair= MEM_dupallocN(pa->hair);
-		if(pa->keys)
-			pa->keys= MEM_dupallocN(pa->keys);
+		if(a)
+			pa->keys= (pa-1)->keys + (pa-1)->totkey;
 	}
 
 	if(psys->soft) {
 		psysn->soft= copy_softbody(psys->soft);
 		psysn->soft->particles = psysn;
 	}
+
+	if(psys->keyed_targets.first)
+		BLI_duplicatelist(&psysn->keyed_targets, &psys->keyed_targets);
 	
 	psysn->pathcache= NULL;
 	psysn->childcache= NULL;

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/particle.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/particle.c	2009-07-12 18:04:10 UTC (rev 21551)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/particle.c	2009-07-12 23:38:47 UTC (rev 21552)
@@ -84,7 +84,8 @@
 static void get_child_modifier_parameters(ParticleSettings *part, ParticleThreadContext *ctx,
 				ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex);
 static void do_child_modifiers(Scene *scene, Object *ob, ParticleSystem *psys, ParticleSettings *part,
-				ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, float *orco, ParticleKey *state, float t);
+				ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa,
+				float *orco, float mat[4][4], ParticleKey *state, float t);
 
 /* few helpers for countall etc. */
 int count_particles(ParticleSystem *psys){
@@ -478,10 +479,16 @@
 		if(psys->pointcache)
 			BKE_ptcache_free(psys->pointcache);
 		
+		if(psys->keyed_targets.first)
+			BLI_freelistN(&psys->keyed_targets);
+
 		MEM_freeN(psys);
 	}
 }
 
+/************************************************/
+/*			Rendering							*/
+/************************************************/
 /* these functions move away particle data and bring it back after
  * rendering, to make different render settings possible without
  * removing the previous data. this should be solved properly once */
@@ -889,7 +896,7 @@
 }
 
 /************************************************/
-/*			Interpolated Particles				*/
+/*			Interpolation						*/
 /************************************************/
 static float interpolate_particle_value(float v1, float v2, float v3, float v4, float *w, int four)
 {
@@ -938,6 +945,214 @@
 
 
 

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list