[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14005] trunk/blender/source/blender/ blenkernel/intern: Fix for bug [#8402] Hair particles don' t react on changing of curve guides

Janne Karhu jhkarh at utu.fi
Fri Mar 7 23:39:54 CET 2008


Revision: 14005
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14005
Author:   jhk
Date:     2008-03-07 23:39:54 +0100 (Fri, 07 Mar 2008)

Log Message:
-----------
Fix for bug [#8402] Hair particles don't react on changing of curve guides
-guide calculation was accessing wrong pointers in hair calculation
-now guides also respect the "apply effectors to children" - button, but not the "stiff" value
-disabled guide calculation for initial hair calculation as it's all done dynamically later
-few useless commented lines cleaned out

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/particle.c
    trunk/blender/source/blender/blenkernel/intern/particle_system.c

Modified: trunk/blender/source/blender/blenkernel/intern/particle.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle.c	2008-03-07 22:39:45 UTC (rev 14004)
+++ trunk/blender/source/blender/blenkernel/intern/particle.c	2008-03-07 22:39:54 UTC (rev 14005)
@@ -2122,8 +2122,9 @@
 		}
 
 		/* apply different deformations to the child path */
-		if(part->flag & PART_CHILD_GUIDE)
-			guided = do_guide((ParticleKey*)state, i, t, &(psys->effectors)); //safe to cast, since only co and vel are used
+		if(part->flag & PART_CHILD_EFFECT)
+			/* state is safe to cast, since only co and vel are used */
+			guided = do_guide((ParticleKey*)state, cpa->parent, t, &(psys->effectors));
 
 		if(guided==0){
 			if(part->kink)
@@ -2557,8 +2558,9 @@
 				do_path_effectors(ob, psys, i, ca, k, steps, cache[i]->co, effector, dfra, cfra, &length, vec);
 
 			/* apply guide curves to path data */
-			if(edit==0 && psys->effectors.first && (psys->part->flag & PART_CHILD_GUIDE)==0)
-				do_guide(&result, i, time, &psys->effectors);
+			if(edit==0 && psys->effectors.first && (psys->part->flag & PART_CHILD_EFFECT)==0)
+				/* ca is safe to cast, since only co and vel are used */
+				do_guide((ParticleKey*)ca, i, (float)k/(float)steps, &psys->effectors);
 
 			/* apply lattice */
 			if(psys->lattice && edit==0)

Modified: trunk/blender/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle_system.c	2008-03-07 22:39:45 UTC (rev 14004)
+++ trunk/blender/source/blender/blenkernel/intern/particle_system.c	2008-03-07 22:39:54 UTC (rev 14005)
@@ -2825,13 +2825,10 @@
 
 		/* add global acceleration (gravitation) */
 		VECADD(force,force,part->acc);
-
-		//VecMulf(force,dtime);
 		
 		/* calculate next state */
 		VECADD(states[i].vel,states[i].vel,tvel);
 
-		//VecMulf(force,0.5f*dt);
 		switch(part->integrator){
 			case PART_INT_EULER:
 				VECADDFAC(state->co,states->co,states->vel,dtime);
@@ -2897,7 +2894,6 @@
 				}
 				break;
 		}
-		//VECADD(states[i+1].co,states[i+1].co,force);
 	}
 
 	/* damp affects final velocity */
@@ -2911,12 +2907,15 @@
 	VECCOPY(tkey.co,state->co);
 	VECCOPY(tkey.vel,state->vel);
 	tkey.time=state->time;
-	if(do_guide(&tkey,pa_no,time,&psys->effectors)){
-		VECCOPY(state->co,tkey.co);
-		/* guides don't produce valid velocity */
-		VECSUB(state->vel,tkey.co,pa->state.co);
-		VecMulf(state->vel,1.0f/dtime);
-		state->time=tkey.time;
+
+	if(part->type != PART_HAIR) {
+		if(do_guide(&tkey,pa_no,time,&psys->effectors)) {
+			VECCOPY(state->co,tkey.co);
+			/* guides don't produce valid velocity */
+			VECSUB(state->vel,tkey.co,pa->state.co);
+			VecMulf(state->vel,1.0f/dtime);
+			state->time=tkey.time;
+		}
 	}
 }
 static void rotate_particle(ParticleSettings *part, ParticleData *pa, float dfra, float timestep, ParticleKey *state)





More information about the Bf-blender-cvs mailing list