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:
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_particle.h33
-rw-r--r--source/blender/blenkernel/BKE_pbvh.h1
-rw-r--r--source/blender/blenkernel/BKE_sound.h2
-rw-r--r--source/blender/blenkernel/intern/boids.c4
-rw-r--r--source/blender/blenkernel/intern/curve.c4
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c3
-rw-r--r--source/blender/blenkernel/intern/movieclip.c13
-rw-r--r--source/blender/blenkernel/intern/object.c6
-rw-r--r--source/blender/blenkernel/intern/paint.c2
-rw-r--r--source/blender/blenkernel/intern/particle.c75
-rw-r--r--source/blender/blenkernel/intern/particle_system.c52
-rw-r--r--source/blender/blenkernel/intern/pbvh.c7
-rw-r--r--source/blender/blenkernel/intern/scene.c9
-rw-r--r--source/blender/blenkernel/intern/sound.c12
14 files changed, 138 insertions, 85 deletions
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index b6be72fadd3..877aafe67a4 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -34,6 +34,8 @@
* \ingroup bke
*/
+#include "BLI_utildefines.h"
+
#include "DNA_particle_types.h"
#include "DNA_object_types.h"
@@ -70,9 +72,6 @@ struct EdgeHash;
/* OpenMP: Can only advance one variable within loop definition. */
#define LOOP_DYNAMIC_PARTICLES for (p = 0; p < psys->totpart; p++) if ((pa = psys->particles + p)->state.time > 0.0f)
-#define PSYS_FRAND_COUNT 1024
-#define PSYS_FRAND(seed) psys->frand[(seed) % PSYS_FRAND_COUNT]
-
/* fast but sure way to get the modifier*/
#define PARTICLE_PSMD ParticleSystemModifierData * psmd = sim->psmd ? sim->psmd : psys_get_modifier(sim->ob, sim->psys)
@@ -247,6 +246,34 @@ typedef struct ParticleDrawData {
#define PARTICLE_DRAW_DATA_UPDATED 1
+#define PSYS_FRAND_COUNT 1024
+extern unsigned int PSYS_FRAND_SEED_OFFSET[PSYS_FRAND_COUNT];
+extern unsigned int PSYS_FRAND_SEED_MULTIPLIER[PSYS_FRAND_COUNT];
+extern float PSYS_FRAND_BASE[PSYS_FRAND_COUNT];
+
+void psys_init_rng(void);
+
+BLI_INLINE float psys_frand(ParticleSystem *psys, unsigned int seed)
+{
+ /* XXX far from ideal, this simply scrambles particle random numbers a bit
+ * to avoid obvious correlations.
+ * Can't use previous psys->frand arrays because these require initialization
+ * inside psys_check_enabled, which wreaks havok in multithreaded depgraph updates.
+ */
+ unsigned int offset = PSYS_FRAND_SEED_OFFSET[psys->seed % PSYS_FRAND_COUNT];
+ unsigned int multiplier = PSYS_FRAND_SEED_MULTIPLIER[psys->seed % PSYS_FRAND_COUNT];
+ return PSYS_FRAND_BASE[(offset + seed * multiplier) % PSYS_FRAND_COUNT];
+}
+
+BLI_INLINE void psys_frand_vec(ParticleSystem *psys, unsigned int seed, float vec[3])
+{
+ unsigned int offset = PSYS_FRAND_SEED_OFFSET[psys->seed % PSYS_FRAND_COUNT];
+ unsigned int multiplier = PSYS_FRAND_SEED_MULTIPLIER[psys->seed % PSYS_FRAND_COUNT];
+ vec[0] = PSYS_FRAND_BASE[(offset + (seed + 0) * multiplier) % PSYS_FRAND_COUNT];
+ vec[1] = PSYS_FRAND_BASE[(offset + (seed + 1) * multiplier) % PSYS_FRAND_COUNT];
+ vec[2] = PSYS_FRAND_BASE[(offset + (seed + 2) * multiplier) % PSYS_FRAND_COUNT];
+}
+
/* ----------- functions needed outside particlesystem ---------------- */
/* particle.c */
int count_particles(struct ParticleSystem *psys);
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 34e96599b7e..7a0c8a1f187 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -71,6 +71,7 @@ void BKE_pbvh_build_bmesh(PBVH *bvh, struct BMesh *bm, int smooth_shading,
struct BMLog *log);
void BKE_pbvh_free(PBVH *bvh);
+void BKE_pbvh_free_layer_disp(PBVH *bvh);
/* Hierarchical Search in the BVH, two methods:
* - for each hit calling a callback
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index 64f0b97c3f0..eb0aec50300 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -134,7 +134,7 @@ void sound_free_waveform(struct bSound *sound);
void sound_read_waveform(struct bSound *sound);
-void sound_update_scene(struct Scene *scene);
+void sound_update_scene(struct Main *bmain, struct Scene *scene);
void *sound_get_factory(void *sound);
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index a8d64ea9fb6..157de3e2f1c 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -970,8 +970,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa)
bbd->wanted_speed = 0.0f;
/* create random seed for every particle & frame */
- rand = (int)(PSYS_FRAND(psys->seed + p) * 1000);
- rand = (int)(PSYS_FRAND((int)bbd->cfra + rand) * 1000);
+ rand = (int)(psys_frand(psys, psys->seed + p) * 1000);
+ rand = (int)(psys_frand(psys, (int)bbd->cfra + rand) * 1000);
set_boid_values(&val, bbd->part->boids, pa);
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 2a4882f7d4b..1fe01fa9637 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -3802,7 +3802,7 @@ bool BKE_nurb_order_clamp_u(struct Nurb *nu)
{
bool changed = false;
if (nu->pntsu < nu->orderu) {
- nu->orderu = nu->pntsu;
+ nu->orderu = max_ii(2, nu->pntsu);
changed = true;
}
if (((nu->flagu & CU_NURB_CYCLIC) == 0) && (nu->flagu & CU_NURB_BEZIER)) {
@@ -3816,7 +3816,7 @@ bool BKE_nurb_order_clamp_v(struct Nurb *nu)
{
bool changed = false;
if (nu->pntsv < nu->orderv) {
- nu->orderv = nu->pntsv;
+ nu->orderv = max_ii(2, nu->pntsv);
changed = true;
}
if (((nu->flagv & CU_NURB_CYCLIC) == 0) && (nu->flagv & CU_NURB_BEZIER)) {
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index bcbc5571077..56b087e7eb6 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -605,7 +605,8 @@ static float fcm_cycles_time(FModifierStackStorage *storage, FCurve *fcu, FModif
FMod_Cycles *data = (FMod_Cycles *)fcm->data;
float prevkey[2], lastkey[2], cycyofs = 0.0f;
short side = 0, mode = 0;
- int cycles = 0, ofs = 0;
+ int cycles = 0;
+ float ofs = 0;
/* check if modifier is first in stack, otherwise disable ourself... */
/* FIXME... */
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index 39c3b96f66e..a41b47809eb 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -214,8 +214,17 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user,
int undistort = user->render_flag & MCLIP_PROXY_RENDER_UNDISTORT;
get_proxy_fname(clip, user->render_size, undistort, framenr, name);
- /* proxies were built using default color space settings */
- colorspace = NULL;
+ /* Well, this is a bit weird, but proxies for movie sources
+ * are built in the same exact color space as the input,
+ *
+ * But image sequences are built in the display space.
+ */
+ if (clip->source == MCLIP_SRC_MOVIE) {
+ colorspace = clip->colorspace_settings.name;
+ }
+ else {
+ colorspace = NULL;
+ }
}
else {
get_sequence_fname(clip, framenr, name);
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index c0336bf9bc7..43dbc34f3d3 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -1279,7 +1279,6 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys)
psysn->pathcache = NULL;
psysn->childcache = NULL;
psysn->edit = NULL;
- psysn->frand = NULL;
psysn->pdd = NULL;
psysn->effectors = NULL;
psysn->tree = NULL;
@@ -1487,11 +1486,6 @@ Object *BKE_object_copy_ex(Main *bmain, Object *ob, int copy_caches)
obn->mode = 0;
obn->sculpt = NULL;
- /* Proxies are not to be copied. */
- obn->proxy_from = NULL;
- obn->proxy_group = NULL;
- obn->proxy = NULL;
-
/* increase user numbers */
id_us_plus((ID *)obn->data);
id_us_plus((ID *)obn->gpd);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 5a38445ee02..4d84dd5fbb1 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -308,8 +308,6 @@ void BKE_paint_init(Paint *p, const char col[3])
memcpy(p->paint_cursor_col, col, 3);
p->paint_cursor_col[3] = 128;
-
- p->flags |= PAINT_SHOW_BRUSH;
}
void BKE_paint_free(Paint *paint)
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index edf902e0eb5..3a6e710d68c 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -85,6 +85,21 @@
#include "RE_render_ext.h"
+unsigned int PSYS_FRAND_SEED_OFFSET[PSYS_FRAND_COUNT];
+unsigned int PSYS_FRAND_SEED_MULTIPLIER[PSYS_FRAND_COUNT];
+float PSYS_FRAND_BASE[PSYS_FRAND_COUNT];
+
+void psys_init_rng(void)
+{
+ int i;
+ BLI_srandom(5831); /* arbitrary */
+ for (i = 0; i < PSYS_FRAND_COUNT; ++i) {
+ PSYS_FRAND_BASE[i] = BLI_frand();
+ PSYS_FRAND_SEED_OFFSET[i] = (unsigned int)BLI_rand();
+ PSYS_FRAND_SEED_MULTIPLIER[i] = (unsigned int)BLI_rand();
+ }
+}
+
static void get_child_modifier_parameters(ParticleSettings *part, ParticleThreadContext *ctx,
ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex);
static void do_child_modifiers(ParticleSimulationData *sim,
@@ -260,16 +275,6 @@ int psys_in_edit_mode(Scene *scene, ParticleSystem *psys)
{
return (scene->basact && (scene->basact->object->mode & OB_MODE_PARTICLE_EDIT) && psys == psys_get_current((scene->basact)->object) && (psys->edit || psys->pointcache->edit) && !psys->renderdata);
}
-static void psys_create_frand(ParticleSystem *psys)
-{
- int i;
- float *rand = psys->frand = MEM_callocN(PSYS_FRAND_COUNT * sizeof(float), "particle randoms");
-
- BLI_srandom(psys->seed);
-
- for (i = 0; i < 1024; i++, rand++)
- *rand = BLI_frand();
-}
int psys_check_enabled(Object *ob, ParticleSystem *psys)
{
ParticleSystemModifierData *psmd;
@@ -285,14 +290,6 @@ int psys_check_enabled(Object *ob, ParticleSystem *psys)
else if (!(psmd->modifier.mode & eModifierMode_Realtime))
return 0;
- /* perhaps not the perfect place, but we have to be sure the rands are there before usage */
- if (!psys->frand)
- psys_create_frand(psys);
- else if (psys->recalc & PSYS_RECALC_RESET) {
- MEM_freeN(psys->frand);
- psys_create_frand(psys);
- }
-
return 1;
}
@@ -579,9 +576,6 @@ void psys_free(Object *ob, ParticleSystem *psys)
pdEndEffectors(&psys->effectors);
- if (psys->frand)
- MEM_freeN(psys->frand);
-
if (psys->pdd) {
psys_free_pdd(psys);
MEM_freeN(psys->pdd);
@@ -787,7 +781,7 @@ void psys_render_restore(Object *ob, ParticleSystem *psys)
PARTICLE_P;
LOOP_PARTICLES {
- if (PSYS_FRAND(p) > disp)
+ if (psys_frand(psys, p) > disp)
pa->flag |= PARS_NO_DISP;
else
pa->flag &= ~PARS_NO_DISP;
@@ -2403,6 +2397,11 @@ void psys_find_parents(ParticleSimulationData *sim)
if ((sim->psys->renderdata || G.is_rendering) && part->child_nbr && part->ren_child_nbr)
totparent *= (float)part->child_nbr / (float)part->ren_child_nbr;
+ /* hard limit, workaround for it being ignored above */
+ if (sim->psys->totpart < totparent) {
+ totparent = sim->psys->totpart;
+ }
+
tree = BLI_kdtree_new(totparent);
for (p = 0, cpa = sim->psys->child; p < totparent; p++, cpa++) {
@@ -2680,7 +2679,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle
/* get different child parameters from textures & vgroups */
get_child_modifier_parameters(part, ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex);
- if (ptex.exist < PSYS_FRAND(i + 24)) {
+ if (ptex.exist < psys_frand(psys, i + 24)) {
child_keys->steps = -1;
return;
}
@@ -2996,7 +2995,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
LOOP_SHOWN_PARTICLES {
if (!psys->totchild) {
psys_get_texture(sim, pa, &ptex, PAMAP_LENGTH, 0.f);
- pa_length = ptex.length * (1.0f - part->randlength * PSYS_FRAND(psys->seed + p));
+ pa_length = ptex.length * (1.0f - part->randlength * psys_frand(psys, psys->seed + p));
if (vg_length)
pa_length *= psys_particle_value_from_verts(psmd->dm, part->from, pa, vg_length);
}
@@ -3832,8 +3831,8 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti
ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink =
ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.0f;
- ptex->length = 1.0f - part->randlength * PSYS_FRAND(child_index + 26);
- ptex->length *= part->clength_thres < PSYS_FRAND(child_index + 27) ? part->clength : 1.0f;
+ ptex->length = 1.0f - part->randlength * psys_frand(psys, child_index + 26);
+ ptex->length *= part->clength_thres < psys_frand(psys, child_index + 27) ? part->clength : 1.0f;
for (m = 0; m < MAX_MTEX; m++, mtexp++) {
mtex = *mtexp;
@@ -3995,7 +3994,7 @@ float psys_get_child_time(ParticleSystem *psys, ChildParticle *cpa, float cfra,
w++;
}
- life = part->lifetime * (1.0f - part->randlife * PSYS_FRAND(cpa - psys->child + 25));
+ life = part->lifetime * (1.0f - part->randlife * psys_frand(psys, cpa - psys->child + 25));
}
else {
ParticleData *pa = psys->particles + cpa->parent;
@@ -4024,7 +4023,7 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float UNUSED
size *= part->childsize;
if (part->childrandsize != 0.0f)
- size *= 1.0f - part->childrandsize * PSYS_FRAND(cpa - psys->child + 26);
+ size *= 1.0f - part->childrandsize * psys_frand(psys, cpa - psys->child + 26);
return size;
}
@@ -4036,7 +4035,7 @@ static void get_child_modifier_parameters(ParticleSettings *part, ParticleThread
get_cpa_texture(ctx->dm, psys, part, psys->particles + cpa->pa[0], i, cpa_num, cpa_fuv, orco, ptex, PAMAP_DENS | PAMAP_CHILD, psys->cfra);
- if (ptex->exist < PSYS_FRAND(i + 24))
+ if (ptex->exist < psys_frand(psys, i + 24))
return;
if (ctx->vg_length)
@@ -4091,11 +4090,17 @@ static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *pte
if (rough1 > 0.f)
do_rough(orco, mat, t, rough1, part->rough1_size, 0.0, state);
- if (rough2 > 0.f)
- do_rough(sim->psys->frand + ((i + 27) % (PSYS_FRAND_COUNT - 3)), mat, t, rough2, part->rough2_size, part->rough2_thres, state);
+ if (rough2 > 0.f) {
+ float vec[3];
+ psys_frand_vec(sim->psys, i + 27, vec);
+ do_rough(vec, mat, t, rough2, part->rough2_size, part->rough2_thres, state);
+ }
- if (rough_end > 0.f)
- do_rough_end(sim->psys->frand + ((i + 27) % (PSYS_FRAND_COUNT - 3)), mat, t, rough_end, part->rough_end_shape, state);
+ if (rough_end > 0.f) {
+ float vec[3];
+ psys_frand_vec(sim->psys, i + 27, vec);
+ do_rough_end(vec, mat, t, rough_end, part->rough_end_shape, state);
+ }
}
/* get's hair (or keyed) particles state at the "path time" specified in state->time */
void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *state, int vel)
@@ -4358,7 +4363,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta
}
}
- state->time = (cfra - (part->sta + (part->end - part->sta) * PSYS_FRAND(p + 23))) / (part->lifetime * PSYS_FRAND(p + 24));
+ state->time = (cfra - (part->sta + (part->end - part->sta) * psys_frand(psys, p + 23))) / (part->lifetime * psys_frand(psys, p + 24));
psys_get_particle_on_path(sim, p, state, 1);
return 1;
@@ -4567,7 +4572,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa
float q_phase[4];
float phasefac = psys->part->phasefac;
if (psys->part->randphasefac != 0.0f)
- phasefac += psys->part->randphasefac * PSYS_FRAND((pa - psys->particles) + 20);
+ phasefac += psys->part->randphasefac * psys_frand(psys, (pa - psys->particles) + 20);
axis_angle_to_quat(q_phase, vec, phasefac * (float)M_PI);
mul_qt_v3(q_phase, side);
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 4eaa2618e26..3f4c53692e5 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -660,9 +660,9 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys)
if (pa->flag & PARS_UNEXIST)
continue;
- pa->fuv[0] += rfac * (PSYS_FRAND(p + 31) - 0.5f);
- pa->fuv[1] += rfac * (PSYS_FRAND(p + 32) - 0.5f);
- pa->fuv[2] += rfac * (PSYS_FRAND(p + 33) - 0.5f);
+ pa->fuv[0] += rfac * (psys_frand(psys, p + 31) - 0.5f);
+ pa->fuv[1] += rfac * (psys_frand(psys, p + 32) - 0.5f);
+ pa->fuv[2] += rfac * (psys_frand(psys, p + 33) - 0.5f);
}
}
}
@@ -1549,7 +1549,7 @@ static void initialize_particle_texture(ParticleSimulationData *sim, ParticleDat
if (part->type != PART_FLUID) {
psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f);
- if (ptex.exist < PSYS_FRAND(p+125))
+ if (ptex.exist < psys_frand(psys, p+125))
pa->flag |= PARS_UNEXIST;
pa->time = (part->type == PART_HAIR) ? 0.f : part->sta + (part->end - part->sta)*ptex.time;
@@ -1714,9 +1714,9 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
/* -velocity (boids need this even if there's no random velocity) */
if (part->randfac != 0.0f || (part->phystype==PART_PHYS_BOIDS && pa->boid)) {
- r_vel[0] = 2.0f * (PSYS_FRAND(p + 10) - 0.5f);
- r_vel[1] = 2.0f * (PSYS_FRAND(p + 11) - 0.5f);
- r_vel[2] = 2.0f * (PSYS_FRAND(p + 12) - 0.5f);
+ r_vel[0] = 2.0f * (psys_frand(psys, p + 10) - 0.5f);
+ r_vel[1] = 2.0f * (psys_frand(psys, p + 11) - 0.5f);
+ r_vel[2] = 2.0f * (psys_frand(psys, p + 12) - 0.5f);
mul_mat3_m4_v3(ob->obmat, r_vel);
normalize_v3(r_vel);
@@ -1724,9 +1724,9 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
/* -angular velocity */
if (part->avemode==PART_AVE_RAND) {
- r_ave[0] = 2.0f * (PSYS_FRAND(p + 13) - 0.5f);
- r_ave[1] = 2.0f * (PSYS_FRAND(p + 14) - 0.5f);
- r_ave[2] = 2.0f * (PSYS_FRAND(p + 15) - 0.5f);
+ r_ave[0] = 2.0f * (psys_frand(psys, p + 13) - 0.5f);
+ r_ave[1] = 2.0f * (psys_frand(psys, p + 14) - 0.5f);
+ r_ave[2] = 2.0f * (psys_frand(psys, p + 15) - 0.5f);
mul_mat3_m4_v3(ob->obmat,r_ave);
normalize_v3(r_ave);
@@ -1734,10 +1734,10 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
/* -rotation */
if (part->randrotfac != 0.0f) {
- r_rot[0] = 2.0f * (PSYS_FRAND(p + 16) - 0.5f);
- r_rot[1] = 2.0f * (PSYS_FRAND(p + 17) - 0.5f);
- r_rot[2] = 2.0f * (PSYS_FRAND(p + 18) - 0.5f);
- r_rot[3] = 2.0f * (PSYS_FRAND(p + 19) - 0.5f);
+ r_rot[0] = 2.0f * (psys_frand(psys, p + 16) - 0.5f);
+ r_rot[1] = 2.0f * (psys_frand(psys, p + 17) - 0.5f);
+ r_rot[2] = 2.0f * (psys_frand(psys, p + 18) - 0.5f);
+ r_rot[3] = 2.0f * (psys_frand(psys, p + 19) - 0.5f);
normalize_qt(r_rot);
mat4_to_quat(rot,ob->obmat);
@@ -1940,7 +1940,7 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P
/* rotation phase */
phasefac = part->phasefac;
if (part->randphasefac != 0.0f)
- phasefac += part->randphasefac * PSYS_FRAND(p + 20);
+ phasefac += part->randphasefac * psys_frand(psys, p + 20);
axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI);
/* combine base rotation & phase */
@@ -2019,7 +2019,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
/* initialize the lifetime, in case the texture coordinates
* are from Particles/Strands, which would cause undefined values
*/
- pa->lifetime = part->lifetime * (1.0f - part->randlife * PSYS_FRAND(p + 21));
+ pa->lifetime = part->lifetime * (1.0f - part->randlife * psys_frand(psys, p + 21));
pa->dietime = pa->time + pa->lifetime;
/* get possible textural influence */
@@ -2028,7 +2028,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
pa->lifetime = part->lifetime * ptex.life;
if (part->randlife != 0.0f)
- pa->lifetime *= 1.0f - part->randlife * PSYS_FRAND(p + 21);
+ pa->lifetime *= 1.0f - part->randlife * psys_frand(psys, p + 21);
}
pa->dietime = pa->time + pa->lifetime;
@@ -4093,9 +4093,9 @@ static void hair_step(ParticleSimulationData *sim, float cfra)
LOOP_PARTICLES {
pa->size = part->size;
if (part->randsize > 0.0f)
- pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
+ pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
- if (PSYS_FRAND(p) > disp)
+ if (psys_frand(psys, p) > disp)
pa->flag |= PARS_NO_DISP;
else
pa->flag &= ~PARS_NO_DISP;
@@ -4254,7 +4254,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
pa->size = part->size*ptex.size;
if (part->randsize > 0.0f)
- pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
+ pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
reset_particle(sim, pa, dtime, cfra);
}
@@ -4312,7 +4312,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
pa->size = part->size*ptex.size;
if (part->randsize > 0.0f)
- pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
+ pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
birthtime = pa->time;
dietime = pa->dietime;
@@ -4498,7 +4498,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra);
pa->size = part->size*ptex.size;
if (part->randsize > 0.0f)
- pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
+ pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
psys->lattice_deform_data = psys_create_lattice_deform_data(sim);
@@ -4520,7 +4520,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra)
psys->lattice_deform_data = NULL;
}
- if (PSYS_FRAND(p) > disp)
+ if (psys_frand(psys, p) > disp)
pa->flag |= PARS_NO_DISP;
else
pa->flag &= ~PARS_NO_DISP;
@@ -4744,7 +4744,7 @@ static void system_step(ParticleSimulationData *sim, float cfra)
disp= psys_get_current_display_percentage(psys);
LOOP_PARTICLES {
- if (PSYS_FRAND(p) > disp)
+ if (psys_frand(psys, p) > disp)
pa->flag |= PARS_NO_DISP;
else
pa->flag &= ~PARS_NO_DISP;
@@ -5055,11 +5055,11 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
LOOP_EXISTING_PARTICLES {
pa->size = part->size;
if (part->randsize > 0.0f)
- pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1);
+ pa->size *= 1.0f - part->randsize * psys_frand(psys, p + 1);
reset_particle(&sim, pa, 0.0, cfra);
- if (PSYS_FRAND(p) > disp)
+ if (psys_frand(psys, p) > disp)
pa->flag |= PARS_NO_DISP;
else
pa->flag &= ~PARS_NO_DISP;
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index cb7c7c636c8..426a1e1646c 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -626,6 +626,13 @@ void BKE_pbvh_free(PBVH *bvh)
MEM_freeN(bvh);
}
+void BKE_pbvh_free_layer_disp(PBVH *bvh)
+{
+ int i;
+ for (i = 0; i < bvh->totnode; ++i)
+ BKE_pbvh_node_layer_disp_free(&bvh->nodes[i]);
+}
+
static void pbvh_iter_begin(PBVHIter *iter, PBVH *bvh, BKE_pbvh_SearchCallback scb, void *search_data)
{
iter->bvh = bvh;
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index da2eda0fbee..110e91711f0 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -542,6 +542,8 @@ Scene *BKE_scene_add(Main *bmain, const char *name)
sce->toolsettings->proportional_size = 1.0f;
+ sce->toolsettings->imapaint.paint.flags |= PAINT_SHOW_BRUSH;
+
sce->physics_settings.gravity[0] = 0.0f;
sce->physics_settings.gravity[1] = 0.0f;
sce->physics_settings.gravity[2] = -9.81f;
@@ -1537,9 +1539,6 @@ static void scene_update_tagged_recursive(EvaluationContext *eval_ctx, Main *bma
/* scene drivers... */
scene_update_drivers(bmain, scene);
- /* update sound system animation */
- sound_update_scene(scene);
-
/* update masking curves */
BKE_mask_update_scene(bmain, scene);
@@ -1573,6 +1572,8 @@ void BKE_scene_update_tagged(EvaluationContext *eval_ctx, Main *bmain, Scene *sc
* in the future this should handle updates for all datablocks, not
* only objects and scenes. - brecht */
scene_update_tagged_recursive(eval_ctx, bmain, scene, scene);
+ /* update sound system animation (TODO, move to depsgraph) */
+ sound_update_scene(bmain, scene);
/* extra call here to recalc scene animation (for sequencer) */
{
@@ -1678,6 +1679,8 @@ void BKE_scene_update_for_newframe_ex(EvaluationContext *eval_ctx, Main *bmain,
/* BKE_object_handle_update() on all objects, groups and sets */
scene_update_tagged_recursive(eval_ctx, bmain, sce, sce);
+ /* update sound system animation (TODO, move to depsgraph) */
+ sound_update_scene(bmain, sce);
scene_depsgraph_hack(eval_ctx, sce, sce);
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index 3a8754e8dd2..1fe73a1f692 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -681,7 +681,7 @@ void sound_read_waveform(bSound *sound)
}
}
-void sound_update_scene(struct Scene *scene)
+void sound_update_scene(Main *bmain, struct Scene *scene)
{
Object *ob;
Base *base;
@@ -694,6 +694,11 @@ void sound_update_scene(struct Scene *scene)
void *handle;
float quat[4];
+ /* cheap test to skip looping over all objects (no speakers is a common case) */
+ if (BLI_listbase_is_empty(&bmain->speaker)) {
+ goto skip_speakers;
+ }
+
for (SETLOOPER(scene, sce_it, base)) {
ob = base->object;
if (ob->type == OB_SPEAKER) {
@@ -743,6 +748,9 @@ void sound_update_scene(struct Scene *scene)
}
}
+
+skip_speakers:
+
while ((handle = AUD_getSet(scene->speaker_handles))) {
AUD_removeSequence(scene->sound_scene, handle);
}
@@ -808,7 +816,7 @@ void sound_read_waveform(struct bSound *sound) { (void)sound; }
void sound_init_main(struct Main *bmain) { (void)bmain; }
void sound_set_cfra(int cfra) { (void)cfra; }
void sound_update_sequencer(struct Main *main, struct bSound *sound) { (void)main; (void)sound; }
-void sound_update_scene(struct Scene *scene) { (void)scene; }
+void sound_update_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) { }
void sound_update_scene_sound(void *handle, struct bSound *sound) { (void)handle; (void)sound; }
void sound_update_scene_listener(struct Scene *scene) { (void)scene; }
void sound_update_fps(struct Scene *scene) { (void)scene; }