[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [56907] trunk/blender/source/blender/ blenkernel: Fix #35407: different particle behavior compared to 2.66, reverted part of 56073.
Brecht Van Lommel
brechtvanlommel at pandora.be
Sun May 19 06:07:02 CEST 2013
Revision: 56907
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=56907
Author: blendix
Date: 2013-05-19 04:07:01 +0000 (Sun, 19 May 2013)
Log Message:
-----------
Fix #35407: different particle behavior compared to 2.66, reverted part of 56073.
Modified Paths:
--------------
trunk/blender/source/blender/blenkernel/BKE_particle.h
trunk/blender/source/blender/blenkernel/intern/anim.c
trunk/blender/source/blender/blenkernel/intern/effect.c
trunk/blender/source/blender/blenkernel/intern/particle.c
trunk/blender/source/blender/blenkernel/intern/particle_system.c
Modified: trunk/blender/source/blender/blenkernel/BKE_particle.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_particle.h 2013-05-19 03:15:50 UTC (rev 56906)
+++ trunk/blender/source/blender/blenkernel/BKE_particle.h 2013-05-19 04:07:01 UTC (rev 56907)
@@ -61,7 +61,6 @@
struct BVHTreeRay;
struct BVHTreeRayHit;
struct EdgeHash;
-struct RNG;
#define PARTICLE_P ParticleData * pa; int p
#define LOOP_PARTICLES for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++)
@@ -83,7 +82,6 @@
struct ParticleSystem *psys;
struct ParticleSystemModifierData *psmd;
struct ListBase *colliders;
- struct RNG *rng;
/* Courant number. This is used to implement an adaptive time step. Only the
* maximum value per time step is important. Only sph_integrate makes use of
* this at the moment. Other solvers could, too. */
Modified: trunk/blender/source/blender/blenkernel/intern/anim.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/anim.c 2013-05-19 03:15:50 UTC (rev 56906)
+++ trunk/blender/source/blender/blenkernel/intern/anim.c 2013-05-19 04:07:01 UTC (rev 56907)
@@ -1263,7 +1263,6 @@
ChildParticle *cpa = NULL;
ParticleKey state;
ParticleCacheKey *cache;
- RNG *rng = NULL;
float ctime, pa_time, scale = 1.0f;
float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size = 0.0;
float (*obmat)[4], (*oldobmat)[4];
@@ -1294,9 +1293,14 @@
totpart = psys->totpart;
totchild = psys->totchild;
+ BLI_srandom(31415926 + psys->seed);
+
if ((psys->renderdata || part->draw_as == PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
ParticleSimulationData sim = {NULL};
-
+ sim.scene = scene;
+ sim.ob = par;
+ sim.psys = psys;
+ sim.psmd = psys_get_modifier(par, psys);
/* make sure emitter imat is in global coordinates instead of render view coordinates */
invert_m4_m4(par->imat, par->obmat);
@@ -1328,12 +1332,6 @@
psys_check_group_weights(part);
- sim.scene = scene;
- sim.ob = par;
- sim.psys = psys;
- sim.psmd = psys_get_modifier(par, psys);
- sim.rng = BLI_rng_new(0);
-
psys->lattice = psys_get_lattice(&sim);
/* gather list of objects or single object */
@@ -1380,8 +1378,6 @@
obcopy = *ob;
}
- rng = BLI_rng_new_srandom(31415926 + psys->seed);
-
if (totchild == 0 || part->draw & PART_DRAW_PARENT)
a = 0;
else
@@ -1421,7 +1417,7 @@
/* for groups, pick the object based on settings */
if (part->draw & PART_DRAW_RAND_GR)
- b = BLI_rng_get_int(rng) % totgroup;
+ b = BLI_rand() % totgroup;
else
b = a % totgroup;
@@ -1565,8 +1561,6 @@
}
else
*ob = obcopy;
-
- BLI_rng_free(sim.rng);
}
/* clean up */
@@ -1579,9 +1573,6 @@
end_latt_deform(psys->lattice);
psys->lattice = NULL;
}
-
- if (rng)
- BLI_rng_free(rng);
}
static Object *find_family_object(Object **obar, char *family, char ch)
Modified: trunk/blender/source/blender/blenkernel/intern/effect.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/effect.c 2013-05-19 03:15:50 UTC (rev 56906)
+++ trunk/blender/source/blender/blenkernel/intern/effect.c 2013-05-19 04:07:01 UTC (rev 56907)
@@ -619,7 +619,6 @@
sim.scene= eff->scene;
sim.ob= eff->ob;
sim.psys= eff->psys;
- sim.rng= NULL;
/* TODO: time from actual previous calculated frame (step might not be 1) */
state.time = cfra - 1.0f;
Modified: trunk/blender/source/blender/blenkernel/intern/particle.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle.c 2013-05-19 03:15:50 UTC (rev 56906)
+++ trunk/blender/source/blender/blenkernel/intern/particle.c 2013-05-19 04:07:01 UTC (rev 56907)
@@ -264,12 +264,11 @@
{
int i;
float *rand = psys->frand = MEM_callocN(PSYS_FRAND_COUNT * sizeof(float), "particle randoms");
- RNG *rng = BLI_rng_new_srandom(psys->seed);
- for (i = 0; i < 1024; i++, rand++)
- *rand = BLI_rng_get_float(rng);
+ BLI_srandom(psys->seed);
- BLI_rng_free(rng);
+ for (i = 0; i < 1024; i++, rand++)
+ *rand = BLI_frand();
}
int psys_check_enabled(Object *ob, ParticleSystem *psys)
{
@@ -3303,11 +3302,8 @@
sim.ob = ob;
sim.psys = psys;
sim.psmd = psys_get_modifier(ob, psys);
- sim.rng = BLI_rng_new(0);
psys_cache_child_paths(&sim, cfra, 1);
-
- BLI_rng_free(sim.rng);
}
/* clear recalc flag if set here */
@@ -4664,7 +4660,6 @@
sim.ob = ob;
sim.psys = psys;
sim.psmd = psys_get_modifier(ob, psys);
- sim.rng = BLI_rng_new(0);
psys->lattice = psys_get_lattice(&sim);
@@ -4692,6 +4687,4 @@
/* protect the applied shape */
psys->flag |= PSYS_EDITED;
}
-
- BLI_rng_free(sim.rng);
}
Modified: trunk/blender/source/blender/blenkernel/intern/particle_system.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/particle_system.c 2013-05-19 03:15:50 UTC (rev 56906)
+++ trunk/blender/source/blender/blenkernel/intern/particle_system.c 2013-05-19 04:07:01 UTC (rev 56907)
@@ -423,7 +423,7 @@
}
}
-static void distribute_simple_children(Scene *scene, Object *ob, DerivedMesh *finaldm, ParticleSystem *psys, RNG *rng)
+static void distribute_simple_children(Scene *scene, Object *ob, DerivedMesh *finaldm, ParticleSystem *psys)
{
ChildParticle *cpa = NULL;
int i, p;
@@ -440,9 +440,9 @@
/* create even spherical distribution inside unit sphere */
while (length>=1.0f) {
- cpa->fuv[0]=2.0f*BLI_rng_get_float(rng)-1.0f;
- cpa->fuv[1]=2.0f*BLI_rng_get_float(rng)-1.0f;
- cpa->fuv[2]=2.0f*BLI_rng_get_float(rng)-1.0f;
+ cpa->fuv[0]=2.0f*BLI_frand()-1.0f;
+ cpa->fuv[1]=2.0f*BLI_frand()-1.0f;
+ cpa->fuv[2]=2.0f*BLI_frand()-1.0f;
length=len_v3(cpa->fuv);
}
@@ -872,7 +872,7 @@
pa->foffset *= ctx->jit[p % (2 * ctx->jitlevel)];
break;
case PART_DISTR_RAND:
- pa->foffset *= BLI_rng_get_float(ctx->sim.rng);
+ pa->foffset *= BLI_frand();
break;
}
}
@@ -1065,15 +1065,15 @@
if (from == PART_FROM_CHILD) {
/* Simple children */
if (part->childtype != PART_CHILD_FACES) {
- BLI_rng_srandom(ctx->sim.rng, 31415926 + psys->seed + psys->child_seed);
- distribute_simple_children(scene, ob, finaldm, psys, ctx->sim.rng);
+ BLI_srandom(31415926 + psys->seed + psys->child_seed);
+ distribute_simple_children(scene, ob, finaldm, psys);
return 0;
}
}
else {
/* Grid distribution */
if (part->distr==PART_DISTR_GRID && from != PART_FROM_VERT) {
- BLI_rng_srandom(ctx->sim.rng, 31415926 + psys->seed);
+ BLI_srandom(31415926 + psys->seed);
dm= CDDM_from_mesh((Mesh*)ob->data, ob);
DM_ensure_tessface(dm);
distribute_grid(dm,psys);
@@ -1085,7 +1085,7 @@
/* Create trees and original coordinates if needed */
if (from == PART_FROM_CHILD) {
distr=PART_DISTR_RAND;
- BLI_rng_srandom(ctx->sim.rng, 31415926 + psys->seed + psys->child_seed);
+ BLI_srandom(31415926 + psys->seed + psys->child_seed);
dm= finaldm;
/* BMESH ONLY */
@@ -1108,7 +1108,7 @@
}
else {
distr = part->distr;
- BLI_rng_srandom(ctx->sim.rng, 31415926 + psys->seed);
+ BLI_srandom(31415926 + psys->seed);
dm= CDDM_from_mesh((Mesh*)ob->data, ob);
@@ -1264,7 +1264,7 @@
for (p=0; p<totpart; p++) {
/* In theory element_sum[totelem] should be 1.0, but due to float errors this is not necessarily always true, so scale pos accordingly. */
- pos= BLI_rng_get_float(ctx->sim.rng) * element_sum[totelem];
+ pos= BLI_frand() * element_sum[totelem];
particle_element[p] = distribute_binary_search(element_sum, totelem, pos);
particle_element[p] = MIN2(totelem-1, particle_element[p]);
jitter_offset[particle_element[p]] = pos;
@@ -2911,9 +2911,9 @@
/* brownian force */
if (part->brownfac != 0.0f) {
- force[0] += (BLI_rng_get_float(sim->rng)-0.5f) * part->brownfac;
- force[1] += (BLI_rng_get_float(sim->rng)-0.5f) * part->brownfac;
- force[2] += (BLI_rng_get_float(sim->rng)-0.5f) * part->brownfac;
+ force[0] += (BLI_frand()-0.5f) * part->brownfac;
+ force[1] += (BLI_frand()-0.5f) * part->brownfac;
+ force[2] += (BLI_frand()-0.5f) * part->brownfac;
}
if (part->flag & PART_ROT_DYN && epoint.ave)
@@ -3492,7 +3492,7 @@
return hit->index >= 0;
}
-static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeRayHit *hit, int kill, int dynamic_rotation, RNG *rng)
+static int collision_response(ParticleData *pa, ParticleCollision *col, BVHTreeRayHit *hit, int kill, int dynamic_rotation)
{
ParticleCollisionElement *pce = &col->pce;
PartDeflect *pd = col->hit->pd;
@@ -3501,7 +3501,7 @@
float f = col->f + x * (1.0f - col->f); /* time factor of collision between timestep */
float dt1 = (f - col->f) * col->total_time; /* time since previous collision (in seconds) */
float dt2 = (1.0f - f) * col->total_time; /* time left after collision (in seconds) */
- int through = (BLI_rng_get_float(rng) < pd->pdef_perm) ? 1 : 0; /* did particle pass through the collision surface? */
+ int through = (BLI_frand() < pd->pdef_perm) ? 1 : 0; /* did particle pass through the collision surface? */
/* calculate exact collision location */
interp_v3_v3v3(co, col->co1, col->co2, x);
@@ -3526,8 +3526,8 @@
float v0_tan[3];/* tangential component of v0 */
float vc_tan[3];/* tangential component of collision surface velocity */
float v0_dot, vc_dot;
- float damp = pd->pdef_damp + pd->pdef_rdamp * 2 * (BLI_rng_get_float(rng) - 0.5f);
- float frict = pd->pdef_frict + pd->pdef_rfrict * 2 * (BLI_rng_get_float(rng) - 0.5f);
+ float damp = pd->pdef_damp + pd->pdef_rdamp * 2 * (BLI_frand() - 0.5f);
+ float frict = pd->pdef_frict + pd->pdef_rfrict * 2 * (BLI_frand() - 0.5f);
float distance, nor[3], dot;
CLAMP(damp,0.0f, 1.0f);
@@ -3735,7 +3735,7 @@
if (collision_count == COLLISION_MAX_COLLISIONS)
collision_fail(pa, &col);
- else if (collision_response(pa, &col, &hit, part->flag & PART_DIE_ON_COL, part->flag & PART_ROT_DYN, sim->rng)==0)
+ else if (collision_response(pa, &col, &hit, part->flag & PART_DIE_ON_COL, part->flag & PART_ROT_DYN)==0)
return;
}
else
@@ -4095,7 +4095,6 @@
{
ParticleSystem *psys = sim->psys;
ParticleSettings *part=psys->part;
- RNG *rng;
BoidBrainData bbd;
ParticleTexture ptex;
PARTICLE_P;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list