diff options
-rw-r--r-- | release/scripts/ui/properties_particle.py | 14 | ||||
-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 |
4 files changed, 27 insertions, 12 deletions
diff --git a/release/scripts/ui/properties_particle.py b/release/scripts/ui/properties_particle.py index 54ddb6da8a6..f3ab64258d9 100644 --- a/release/scripts/ui/properties_particle.py +++ b/release/scripts/ui/properties_particle.py @@ -390,10 +390,13 @@ class PARTICLE_PT_physics(ParticleButtonsPanel): sub.prop(part, "drag_factor", slider=True) sub.prop(part, "damp_factor", slider=True) sub = split.column() + sub.label(text="Integration:") + sub.prop(part, "integrator", text="") + sub.prop(part, "time_tweak") + sub.prop(part, "subframes") + sub = layout.row() sub.prop(part, "size_deflect") sub.prop(part, "die_on_collision") - sub.prop(part, "integrator") - sub.prop(part, "time_tweak") elif part.physics_type == 'FLUID': fluid = part.fluid @@ -405,10 +408,13 @@ class PARTICLE_PT_physics(ParticleButtonsPanel): sub.prop(part, "drag_factor", slider=True) sub.prop(part, "damp_factor", slider=True) sub = split.column() + sub.label(text="Integration:") + sub.prop(part, "integrator", text="") + sub.prop(part, "time_tweak") + sub.prop(part, "subframes") + sub = layout.row() sub.prop(part, "size_deflect") sub.prop(part, "die_on_collision") - sub.prop(part, "integrator") - sub.prop(part, "time_tweak") split = layout.split() sub = split.column() 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); |