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:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-02-05 21:37:19 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2014-02-05 21:46:01 +0400
commit78c491e62a573eac647085a0520cb35526d6fcc3 (patch)
treea1addde2d05532f58ea590dfcaf69b1e9a96569f /source/blender/blenkernel/intern/particle_system.c
parent9800ed5f6d0a31dd075363ac2e0ba80842e20443 (diff)
Fix T35247: Particle texture behaves incorrectly after changing the number of particles
Root of the issue goes to the order of particle initialization which does texture evaluation (which does depend on particle coordinate) and particle birth coordinate calculation. So basically what happened is: * Changing number of particles re-allocated all the particles, which sets their coordinate to (0,0,0) * Texture evaluation used this non-initialized coordinate * Coordinates were calculated for particles Reshuffled code a bit so now texture evaluation happens after particles. coordinate calculation. Basically moved texture evaluation to particle reset function. Reset happens after initialization anyway and it does know particle coordinates. Also, if reset is being called without init then it's also kind of logical to re-evaluate texture because particle coordinates might change.
Diffstat (limited to 'source/blender/blenkernel/intern/particle_system.c')
-rw-r--r--source/blender/blenkernel/intern/particle_system.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 78db7e67b23..6ae3e2e9d5e 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -1540,23 +1540,26 @@ void psys_threads_free(ParticleThread *threads)
MEM_freeN(threads);
}
-/* set particle parameters that don't change during particle's life */
-void initialize_particle(ParticleSimulationData *sim, ParticleData *pa, int p)
+static void initialize_particle_texture(ParticleSimulationData *sim, ParticleData *pa, int p)
{
ParticleSystem *psys = sim->psys;
ParticleSettings *part = psys->part;
ParticleTexture ptex;
- pa->flag &= ~PARS_UNEXIST;
-
if (part->type != PART_FLUID) {
psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f);
-
+
if (ptex.exist < PSYS_FRAND(p+125))
pa->flag |= PARS_UNEXIST;
pa->time = (part->type == PART_HAIR) ? 0.f : part->sta + (part->end - part->sta)*ptex.time;
}
+}
+
+/* set particle parameters that don't change during particle's life */
+void initialize_particle(ParticleData *pa)
+{
+ pa->flag &= ~PARS_UNEXIST;
pa->hair_index = 0;
/* we can't reset to -1 anymore since we've figured out correct index in distribute_particles */
@@ -1572,7 +1575,7 @@ static void initialize_all_particles(ParticleSimulationData *sim)
LOOP_PARTICLES {
if ((pa->flag & PARS_UNEXIST)==0)
- initialize_particle(sim, pa, p);
+ initialize_particle(pa);
if (pa->flag & PARS_UNEXIST)
psys->totunexist++;
@@ -1984,6 +1987,13 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
psys_get_birth_coordinates(sim, pa, &pa->state, dtime, cfra);
+ /* Initialize particle settings which depends on texture.
+ *
+ * We could only do it now because we'll need to know coordinate
+ * before sampling the texture.
+ */
+ initialize_particle_texture(sim, pa, p);
+
if (part->phystype==PART_PHYS_BOIDS && pa->boid) {
BoidParticle *bpa = pa->boid;