diff options
author | Janne Karhu <jhkarh@gmail.com> | 2010-04-12 21:34:06 +0400 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2010-04-12 21:34:06 +0400 |
commit | 919565f196b66026f0adf23ed1ee2214e5a517f7 (patch) | |
tree | 4018dfd0df1ce9a7c186e441203debff5aef082c /source/blender | |
parent | 99d755656d4090e922e944e65fe8746c2ccb9602 (diff) |
Subframe calculations for particles, original patch by Raul Fernandez Hernandez
* Increasing subframe count increases stability for SPH fluid and Newtonian particles
* Also small tweaks into physics ui panel to better fit new subframes value
* This commit also fixes the moving fluid emitter problem as described by Raul in the mailinglist
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 18 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_particle_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 5 |
3 files changed, 17 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 54abfd8fd40..389b31a20c7 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2308,8 +2308,7 @@ void particle_fluidsim(ParticleSystem *psys, ParticleData *pa, ParticleSettings VECCOPY(start, pa->prev_state.co); VECCOPY(end, pa->state.co); - sub_v3_v3v3(v, end, start); - mul_v3_fl(v, 1.f/dtime); + VECCOPY(v, pa->state.vel); neighbours = BLI_kdtree_range_search(tree, radius, start, NULL, &ptn); @@ -3790,18 +3789,23 @@ static void system_step(ParticleSimulationData *sim, float cfra) } if(psys->totpart) { - int dframe, totframesback = 0; - + int dframe, subframe = 0, totframesback = 0, totsubframe = part->subframes+1; + float fraction; + /* handle negative frame start at the first frame by doing * all the steps before the first frame */ if(framenr == startframe && part->sta < startframe) totframesback = (startframe - (int)part->sta); - + for(dframe=-totframesback; dframe<=0; dframe++) { /* ok now we're all set so let's go */ - dynamics_step(sim, cfra+dframe); - psys->cfra = cfra+dframe; + for (subframe = 1; subframe <= totsubframe; subframe++) { + fraction = (float)subframe/(float)totsubframe; + dynamics_step(sim, cfra+dframe+fraction - 1.f); + psys->cfra = cfra+dframe+fraction - 1.f; + } } + } /* 4. only write cache starting from second frame */ diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 8367875aa7a..105fa6d5289 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -136,7 +136,7 @@ typedef struct ParticleSettings { /* physics modes */ short phystype, rotmode, avemode, reactevent; short draw, draw_as, draw_size, childtype; - short ren_as, rt2; + short ren_as, subframes; /* number of path segments, power of 2 except */ short draw_step, ren_step; short hair_step, keys_step; diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 4e8776eff6a..4e728d57290 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -1476,6 +1476,11 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0, 10, 1, 3); RNA_def_property_ui_text(prop, "Tweak", "A multiplier for physics timestep (1.0 means one frame = 1/25 seconds)"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop= RNA_def_property(srna, "subframes", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0, 1000); + RNA_def_property_ui_text(prop, "Subframes", "Subframes to simulate for improved stability and finer granularity simulations"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); prop= RNA_def_property(srna, "jitter_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); |