Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-06-25 02:41:40 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-06-25 02:41:40 +0400
commit454d6e020700195b191e6ff109d8ed0eccdf0254 (patch)
tree67e2eb3dce55b031ada08225b38f655a6a0db3f4 /source/blender/blenkernel
parent28dd9c6a40859bf8d707b072174557d37240f162 (diff)
Fix particle hair display percentage not properly getting restored after
rendering. This used to happen in an unneeded frame change update which was removed. For heavy particle systems this could have a bad impact on viewport performance after rendering.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_particle.h2
-rw-r--r--source/blender/blenkernel/intern/particle.c16
-rw-r--r--source/blender/blenkernel/intern/particle_system.c14
3 files changed, 25 insertions, 7 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index 2b753cba098..56b550a6f5d 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -380,6 +380,8 @@ int psys_particle_dm_face_lookup(struct Object *ob, struct DerivedMesh *dm, int
void reset_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, float dtime, float cfra);
+float psys_get_current_display_percentage(struct ParticleSystem *psys);
+
/* psys_reset */
#define PSYS_RESET_ALL 1
#define PSYS_RESET_DEPSGRAPH 2
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 3ab535febb1..f6901c7b81b 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -734,6 +734,8 @@ void psys_render_restore(Object *ob, ParticleSystem *psys)
{
ParticleRenderData *data;
ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys);
+ float render_disp = psys_get_current_display_percentage(psys);
+ float disp;
data = psys->renderdata;
if (!data)
@@ -777,6 +779,20 @@ void psys_render_restore(Object *ob, ParticleSystem *psys)
MEM_freeN(data);
psys->renderdata = NULL;
+
+ /* restore particle display percentage */
+ disp = psys_get_current_display_percentage(psys);
+
+ if (disp != render_disp) {
+ PARTICLE_P;
+
+ LOOP_PARTICLES {
+ if (PSYS_FRAND(p) > disp)
+ pa->flag |= PARS_NO_DISP;
+ else
+ pa->flag &= ~PARS_NO_DISP;
+ }
+ }
}
/* BMESH_TODO, for orig face data, we need to use MPoly */
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 50d2a47a97f..ec45c9eef40 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -123,7 +123,7 @@ static int particles_are_dynamic(ParticleSystem *psys)
return ELEM3(psys->part->phystype, PART_PHYS_NEWTON, PART_PHYS_BOIDS, PART_PHYS_FLUID);
}
-static int psys_get_current_display_percentage(ParticleSystem *psys)
+float psys_get_current_display_percentage(ParticleSystem *psys)
{
ParticleSettings *part=psys->part;
@@ -131,10 +131,10 @@ static int psys_get_current_display_percentage(ParticleSystem *psys)
(part->child_nbr && part->childtype) || /* display percentage applies to children */
(psys->pointcache->flag & PTCACHE_BAKING)) /* baking is always done with full amount */
{
- return 100;
+ return 1.0f;
}
- return psys->part->disp;
+ return psys->part->disp/100.0f;
}
static int tot_particles(ParticleSystem *psys, PTCacheID *pid)
@@ -3984,7 +3984,7 @@ static void hair_step(ParticleSimulationData *sim, float cfra)
ParticleSystem *psys = sim->psys;
ParticleSettings *part = psys->part;
PARTICLE_P;
- float disp = (float)psys_get_current_display_percentage(psys)/100.0f;
+ float disp = psys_get_current_display_percentage(psys);
LOOP_PARTICLES {
pa->size = part->size;
@@ -4388,7 +4388,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
psys_update_effectors(sim);
- disp= (float)psys_get_current_display_percentage(psys)/100.0f;
+ disp= psys_get_current_display_percentage(psys);
LOOP_PARTICLES {
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
@@ -4637,7 +4637,7 @@ static void system_step(ParticleSimulationData *sim, float cfra)
/* 3. do dynamics */
/* set particles to be not calculated TODO: can't work with pointcache */
- disp= (float)psys_get_current_display_percentage(psys)/100.0f;
+ disp= psys_get_current_display_percentage(psys);
LOOP_PARTICLES {
if (PSYS_FRAND(p) > disp)
@@ -4933,7 +4933,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
case PART_PHYS_KEYED:
{
PARTICLE_P;
- float disp = (float)psys_get_current_display_percentage(psys)/100.0f;
+ float disp = psys_get_current_display_percentage(psys);
/* Particles without dynamics haven't been reset yet because they don't use pointcache */
if (psys->recalc & PSYS_RECALC_RESET)