[Bf-blender-cvs] [27b26f6b1c4] fluid-mantaflow: Merge branch 'bakeConfig' into particleSystem

Sebastián Barschkis noreply at git.blender.org
Sat Apr 6 22:13:37 CEST 2019


Commit: 27b26f6b1c4f14028eab59ae3396574ec3e1a477
Author: Sebastián Barschkis
Date:   Tue Mar 26 19:19:22 2019 +0100
Branches: fluid-mantaflow
https://developer.blender.org/rB27b26f6b1c4f14028eab59ae3396574ec3e1a477

Merge branch 'bakeConfig' into particleSystem

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



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

diff --cc source/blender/blenkernel/intern/particle_system.c
index d3c71f21477,7ec50ead0bb..de45e245104
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@@ -4471,111 -4255,123 +4467,122 @@@ void particle_system_update(struct Deps
  	/* setup necessary physics type dependent additional data if it doesn't yet exist */
  	psys_prepare_physics(&sim);
  
 -	switch (part->type) {
 -		case PART_HAIR:
 -		{
 -			/* nothing to do so bail out early */
 -			if (psys->totpart == 0 && part->totpart == 0) {
 -				psys_free_path_cache(psys, NULL);
 -				free_hair(ob, psys, 0);
 -				psys->flag |= PSYS_HAIR_DONE;
 -			}
 -			/* (re-)create hair */
 -			else if (hair_needs_recalc(psys)) {
 -				float hcfra=0.0f;
 -				int i, recalc = psys->recalc;
 -
 -				free_hair(ob, psys, 0);
 +	if (part->type & PART_HAIR)
 +	{
 +		/* nothing to do so bail out early */
 +		if (psys->totpart == 0 && part->totpart == 0) {
 +			psys_free_path_cache(psys, NULL);
 +			free_hair(ob, psys, 0);
 +			psys->flag |= PSYS_HAIR_DONE;
 +		}
 +		/* (re-)create hair */
 +		else if (hair_needs_recalc(psys)) {
 +			float hcfra=0.0f;
 +			int i, recalc = psys->recalc;
  
 -				if (psys_orig->edit && psys_orig->free_edit) {
 -					psys_orig->free_edit(psys_orig->edit);
 -					psys_orig->edit = NULL;
 -					psys_orig->free_edit = NULL;
 -				}
 +			free_hair(ob, psys, 0);
  
 -				/* first step is negative so particles get killed and reset */
 -				psys->cfra= 1.0f;
 +			if (psys_orig->edit && psys_orig->free_edit) {
 +				psys_orig->free_edit(psys_orig->edit);
 +				psys_orig->edit = NULL;
 +				psys_orig->free_edit = NULL;
 +			}
  
 -				ParticleSettings *part_local = part;
 -				if ((part->flag & PART_HAIR_REGROW) == 0) {
 -					part_local = particle_settings_localize(part);
 -					psys->part = part_local;
 -				}
 +			/* first step is negative so particles get killed and reset */
 +			psys->cfra= 1.0f;
  
 -				for (i=0; i<=part->hair_step; i++) {
 -					hcfra=100.0f*(float)i/(float)psys->part->hair_step;
 -					if ((part->flag & PART_HAIR_REGROW)==0)
 -						BKE_animsys_evaluate_animdata(depsgraph, scene, &part_local->id, part_local->adt, hcfra, ADT_RECALC_ANIM);
 -					system_step(&sim, hcfra, use_render_params);
 -					psys->cfra = hcfra;
 -					psys->recalc = 0;
 -					save_hair(&sim, hcfra);
 -				}
++			ParticleSettings *part_local = part;
++			if ((part->flag & PART_HAIR_REGROW) == 0) {
++				part_local = particle_settings_localize(part);
++				psys->part = part_local;
++			}
+ 
 -				if (part_local != part) {
 -					particle_settings_free_local(part_local);
 -					psys->part = part;
 -				}
 +			for (i=0; i<=part->hair_step; i++) {
 +				hcfra=100.0f*(float)i/(float)psys->part->hair_step;
 +				if ((part->flag & PART_HAIR_REGROW)==0)
- 					BKE_animsys_evaluate_animdata(depsgraph, scene, &part->id, part->adt, hcfra, ADT_RECALC_ANIM);
++					BKE_animsys_evaluate_animdata(depsgraph, scene, &part_local->id, part_local->adt, hcfra, ADT_RECALC_ANIM);
 +				system_step(&sim, hcfra, use_render_params);
 +				psys->cfra = hcfra;
 +				psys->recalc = 0;
 +				save_hair(&sim, hcfra);
 +			}
  
 -				psys->flag |= PSYS_HAIR_DONE;
 -				psys->recalc = recalc;
++			if (part_local != part) {
++				particle_settings_free_local(part_local);
++				psys->part = part;
+ 			}
 -			else if (psys->flag & PSYS_EDITED)
 -				psys->flag |= PSYS_HAIR_DONE;
+ 
 -			if (psys->flag & PSYS_HAIR_DONE)
 -				hair_step(&sim, cfra, use_render_params);
 -			break;
 +			psys->flag |= PSYS_HAIR_DONE;
 +			psys->recalc = recalc;
  		}
 -		case PART_FLUID:
 -		{
 -			particles_fluid_step(&sim, (int)cfra, use_render_params);
 -			break;
 -		}
 -		default:
 -		{
 -			switch (part->phystype) {
 -				case PART_PHYS_NO:
 -				case PART_PHYS_KEYED:
 -				{
 -					PARTICLE_P;
 -					float disp = psys_get_current_display_percentage(psys, use_render_params);
 -					bool free_unexisting = false;
 -
 -					/* Particles without dynamics haven't been reset yet because they don't use pointcache */
 -					if (psys->recalc & ID_RECALC_PSYS_RESET)
 -						psys_reset(psys, PSYS_RESET_ALL);
 -
 -					if (emit_particles(&sim, NULL, cfra) || (psys->recalc & ID_RECALC_PSYS_RESET)) {
 -						free_keyed_keys(psys);
 -						distribute_particles(&sim, part->from);
 -						initialize_all_particles(&sim);
 -						free_unexisting = true;
 -
 -						/* flag for possible explode modifiers after this system */
 -						sim.psmd->flag |= eParticleSystemFlag_Pars;
 -					}
 +		else if (psys->flag & PSYS_EDITED)
 +			psys->flag |= PSYS_HAIR_DONE;
  
 -					LOOP_EXISTING_PARTICLES {
 -						pa->size = part->size;
 -						if (part->randsize > 0.0f)
 -							pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
 -
 -						reset_particle(&sim, pa, 0.0, cfra);
 +		if (psys->flag & PSYS_HAIR_DONE)
 +			hair_step(&sim, cfra, use_render_params);
 +	}
 +	else if (part->type & PART_FLUID)
 +	{
 +		particles_fluid_step(&sim, (int)cfra, use_render_params);
 +	}
 +	else if (part->type & (PART_MANTA_FLIP | PART_MANTA_BUBBLE | PART_MANTA_BUBBLE | PART_MANTA_FOAM | PART_MANTA_TRACER))
 +	{
 +		particles_manta_step(&sim, (int)cfra, use_render_params);
 +	}
 +	else
 +	{
 +		switch (part->phystype) {
 +			case PART_PHYS_NO:
 +			case PART_PHYS_KEYED:
 +			{
 +				PARTICLE_P;
 +				float disp = psys_get_current_display_percentage(psys, use_render_params);
 +				bool free_unexisting = false;
 +
 +				/* Particles without dynamics haven't been reset yet because they don't use pointcache */
 +				if (psys->recalc & PSYS_RECALC_RESET)
 +					psys_reset(psys, PSYS_RESET_ALL);
 +
 +				if (emit_particles(&sim, NULL, cfra) || (psys->recalc & PSYS_RECALC_RESET)) {
 +					free_keyed_keys(psys);
 +					distribute_particles(&sim, part->from);
 +					initialize_all_particles(&sim);
 +					free_unexisting = true;
 +
 +					/* flag for possible explode modifiers after this system */
 +					sim.psmd->flag |= eParticleSystemFlag_Pars;
 +				}
  
 -						if (psys_frand(psys, p) > disp)
 -							pa->flag |= PARS_NO_DISP;
 -						else
 -							pa->flag &= ~PARS_NO_DISP;
 -					}
 +				LOOP_EXISTING_PARTICLES {
 +					pa->size = part->size;
 +					if (part->randsize > 0.0f)
 +						pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
  
 -					/* free unexisting after resetting particles */
 -					if (free_unexisting)
 -						free_unexisting_particles(&sim);
 +					reset_particle(&sim, pa, 0.0, cfra);
  
 -					if (part->phystype == PART_PHYS_KEYED) {
 -						psys_count_keyed_targets(&sim);
 -						set_keyed_keys(&sim);
 -						psys_update_path_cache(&sim, (int)cfra, use_render_params);
 -					}
 -					break;
 +					if (psys_frand(psys, p) > disp)
 +						pa->flag |= PARS_NO_DISP;
 +					else
 +						pa->flag &= ~PARS_NO_DISP;
  				}
 -				default:
 -				{
 -					/* the main dynamic particle system step */
 -					system_step(&sim, cfra, use_render_params);
 -					break;
 +
 +				/* free unexisting after resetting particles */
 +				if (free_unexisting)
 +					free_unexisting_particles(&sim);
 +
 +				if (part->phystype == PART_PHYS_KEYED) {
 +					psys_count_keyed_targets(&sim);
 +					set_keyed_keys(&sim);
 +					psys_update_path_cache(&sim, (int)cfra, use_render_params);
  				}
 +				break;
 +			}
 +			default:
 +			{
 +				/* the main dynamic particle system step */
 +				system_step(&sim, cfra, use_render_params);
 +				break;
  			}
 -			break;
  		}
  	}



More information about the Bf-blender-cvs mailing list