diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index cc2f9bd8334..5513f98b299 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -41,7 +41,7 @@ struct ListBase; struct MemFile; #define BLENDER_VERSION 249 -#define BLENDER_SUBVERSION 0 +#define BLENDER_SUBVERSION 1 #define BLENDER_MINVERSION 245 #define BLENDER_MINSUBVERSION 15 diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index cca5d68167e..5bc3e295272 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -80,7 +80,6 @@ #include "BKE_screen.h" #include "BKE_utildefines.h" -#include "PIL_time.h" #include "RE_render_ext.h" /* fluid sim particle import */ @@ -161,8 +160,7 @@ static void add_to_effectorcache(ListBase *lb, Object *ob, Object *obsrc) if(pd->forcefield == PFIELD_WIND) { - pd->rng = rng_new(1); - rng_srandom(pd->rng, (unsigned int)(ceil(PIL_check_seconds_timer()))); // use better seed + pd->rng = rng_new(pd->seed); } ec= MEM_callocN(sizeof(pEffectorCache), "effector cache"); @@ -286,14 +284,14 @@ static float eff_calc_visibility(Object *ob, float *co, float *dir) // noise function for wind e.g. static float wind_func(struct RNG *rng, float strength) { - int random = (rng_getInt(rng)+1) % 65535; // max 2357 + int random = (rng_getInt(rng)+1) % 128; // max 2357 float force = rng_getFloat(rng) + 1.0f; float ret; float sign = 0; - sign = (random > 32000.0) ? 1.0: -1.0; // dividing by 2 is not giving equal sign distribution + sign = ((float)random > 64.0) ? 1.0: -1.0; // dividing by 2 is not giving equal sign distribution - ret = sign*((float)random / force)*strength/65535.0f; + ret = sign*((float)random / force)*strength/128.0f; return ret; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f0ec75dedd9..38b8bfaaa88 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -162,6 +162,8 @@ #include "mydevice.h" #include "blendef.h" +#include "PIL_time.h" + #include /* @@ -8144,6 +8146,16 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } + // correct introduce of seed for wind force + if (main->versionfile < 249 && main->subversionfile < 1) { + Object *ob; + for(ob = main->object.first; ob; ob= ob->id.next) { + if(ob->pd) + ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128; + } + + } + /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */ diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index dc449a64c6d..718d1a17834 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -69,7 +69,7 @@ typedef struct PartDeflect { struct Tex *tex; /* Texture of the texture effector */ struct RNG *rng; /* random noise generator for e.g. wind */ float f_noise; /* noise of force (currently used for wind) */ - int pad; + int seed; /* wind noise random seed */ } PartDeflect; typedef struct PointCache { diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index c3f7a21a7bf..b50b0082bf4 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -3757,7 +3757,8 @@ static int setupPI( Object* ob ) ob->pd->pdef_perm =0; ob->pd->f_strength =0; ob->pd->f_power =0; - ob->pd->maxdist =0; + ob->pd->maxdist =0; + ob->pd->seed =0; return 1; } diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index a90dd0447e9..8bf62836888 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -159,6 +159,8 @@ #include "butspace.h" // own module +#include "PIL_time.h" + static float prspeed=0.0; float prlen=0.0; @@ -3337,6 +3339,7 @@ static void object_panel_collision(Object *ob) ob->pd->pdef_sbdamp = 0.1f; ob->pd->pdef_sbift = 0.2f; ob->pd->pdef_sboft = 0.02f; + ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128; } /* only meshes collide now */ @@ -3431,6 +3434,7 @@ static void object_panel_fields(Object *ob) ob->pd->pdef_sbift = 0.2f; ob->pd->pdef_sboft = 0.02f; ob->pd->tex_nabla = 0.025f; + ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128; } if(ob->pd) { @@ -3530,7 +3534,10 @@ static void object_panel_fields(Object *ob) else if(pd->forcefield == PFIELD_HARMONIC) uiDefButF(block, NUM, B_FIELD_CHANGE, "Damp: ", 10,120,140,20, &pd->f_damp, 0, 10, 10, 0, "Damping of the harmonic force"); else if(pd->forcefield == PFIELD_WIND) - uiDefButF(block, NUM, B_FIELD_CHANGE, "Noise: ",10,120,140,20, &pd->f_noise, 0, 10, 100, 0, "Noise of the wind force"); + { + uiDefButF(block, NUM, B_FIELD_CHANGE, "Noise: ",10,120,140,20, &pd->f_noise, 0, 10, 100, 0, "Noise of the wind force"); + uiDefButI(block, NUM, B_FIELD_CHANGE, "Seed: ",10,100,140,20, &pd->seed, 1, 128, 1, 0, "Seed of the wind noise"); + } } uiBlockEndAlign(block); @@ -3839,6 +3846,7 @@ static void object_softbodies_collision(Object *ob) ob->pd->pdef_sbdamp = 0.1f; ob->pd->pdef_sbift = 0.2f; ob->pd->pdef_sboft = 0.02f; + ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128; } block= uiNewBlock(&curarea->uiblocks, "object_softbodies_collision", UI_EMBOSS, UI_HELV, curarea->win); uiNewPanelTabbed("Soft Body", "Physics");