forked from bartvdbraak/blender
Patch/Bugfix so wind noise got controlable seed and therefore redoable cloth sims - bug reported by istvan
This commit is contained in:
parent
8ed66c5691
commit
580e69b365
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -162,6 +162,8 @@
|
||||
#include "mydevice.h"
|
||||
#include "blendef.h"
|
||||
|
||||
#include "PIL_time.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
/*
|
||||
@ -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! */
|
||||
|
@ -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 {
|
||||
|
@ -3758,6 +3758,7 @@ static int setupPI( Object* ob )
|
||||
ob->pd->f_strength =0;
|
||||
ob->pd->f_power =0;
|
||||
ob->pd->maxdist =0;
|
||||
ob->pd->seed =0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -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");
|
||||
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");
|
||||
|
Loading…
Reference in New Issue
Block a user