[Bf-blender-cvs] [4400354] temp_hair_modifiers: Reset function for the final hair state before calculating hair dynamics and paths.

Lukas Tönne noreply at git.blender.org
Mon Feb 9 14:25:18 CET 2015


Commit: 4400354314e43841d68be2ec25b6566da9bc887a
Author: Lukas Tönne
Date:   Mon Feb 2 12:00:11 2015 +0100
Branches: temp_hair_modifiers
https://developer.blender.org/rB4400354314e43841d68be2ec25b6566da9bc887a

Reset function for the final hair state before calculating hair dynamics
and paths.

The integration with modifiers is still undefined: While it would be
nicer to have regular modifiers work on hair state as well, it is
probably not feasible with the current particle system, because all
these steps happen in a single update function. For integrating with
the modifier stack we would have to allow splitting this process into
individual parts, which is just not possible.

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

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

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

diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index acc32a7..0742fd8 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -2878,6 +2878,28 @@ static void collision_check(ParticleSimulationData *sim, int p, float dfra, floa
 /*			Hair								*/
 /************************************************/
 
+/* reset the hair_final keys to the initial state */
+static void psys_hair_final_reset(ParticleSimulationData *sim)
+{
+	ParticleSystem *psys = sim->psys;
+	ParticleData *pa;
+	int p;
+	
+	for (p = 0, pa = psys->particles; p < psys->totpart; ++p, ++pa) {
+		if (pa->totkey_final != pa->totkey) {
+			if (pa->hair_final)
+				MEM_freeN(pa->hair_final);
+			pa->hair_final = NULL;
+			pa->totkey_final = 0;
+		}
+		
+		if (pa->hair) {
+			pa->hair_final = MEM_dupallocN(pa->hair);
+			pa->totkey_final = pa->totkey;
+		}
+	}
+}
+
 static bool psys_needs_path_cache(ParticleSimulationData *sim)
 {
 	ParticleSystem *psys = sim->psys;
@@ -3509,6 +3531,8 @@ static void hair_step(ParticleSimulationData *sim, float cfra)
 			cloth_free_modifier(psys->clmd);
 	}
 
+	psys_hair_final_reset(sim);
+
 	/* dynamics with cloth simulation, psys->particles can be NULL with 0 particles [#25519] */
 	if (psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS && psys->particles)
 		do_hair_dynamics(sim);




More information about the Bf-blender-cvs mailing list