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_blender.h2
-rw-r--r--source/blender/blenkernel/BKE_node.h2
-rw-r--r--source/blender/blenkernel/BKE_particle.h3
-rw-r--r--source/blender/blenkernel/BKE_sound.h3
-rw-r--r--source/blender/blenkernel/intern/bvhutils.c2
-rw-r--r--source/blender/blenkernel/intern/constraint.c38
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c5
-rw-r--r--source/blender/blenkernel/intern/mesh.c2
-rw-r--r--source/blender/blenkernel/intern/movieclip.c4
-rw-r--r--source/blender/blenkernel/intern/node.c5
-rw-r--r--source/blender/blenkernel/intern/object.c49
-rw-r--r--source/blender/blenkernel/intern/particle_system.c157
-rw-r--r--source/blender/blenkernel/intern/scene.c2
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c60
-rw-r--r--source/blender/blenkernel/intern/sequencer.c14
-rw-r--r--source/blender/blenkernel/intern/sound.c27
-rw-r--r--source/blender/blenkernel/intern/tracking.c33
17 files changed, 235 insertions, 173 deletions
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index cb4fba43f8d..49cde9d6517 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 261
-#define BLENDER_SUBVERSION 0
+#define BLENDER_SUBVERSION 1
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index 6234308048b..9fdae5b190e 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -374,6 +374,8 @@ int nodeUpdateID(struct bNodeTree *ntree, struct ID *id);
void nodeFreePreview(struct bNode *node);
+int nodeSocketIsHidden(struct bNodeSocket *sock);
+
/* ************** NODE TYPE ACCESS *************** */
struct bNodeTemplate nodeMakeTemplate(struct bNode *node);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index f491761f3f2..dbefbd95a15 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -63,7 +63,8 @@ struct BVHTreeRayHit;
#define LOOP_PARTICLES for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++)
#define LOOP_EXISTING_PARTICLES for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) if(!(pa->flag & PARS_UNEXIST))
#define LOOP_SHOWN_PARTICLES for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) if(!(pa->flag & (PARS_UNEXIST|PARS_NO_DISP)))
-#define LOOP_DYNAMIC_PARTICLES for(p=0, pa=psys->particles; p<psys->totpart; p++, pa++) if(pa->state.time > 0.f)
+/* 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.f)
#define PSYS_FRAND_COUNT 1024
#define PSYS_FRAND(seed) psys->frand[(seed) % PSYS_FRAND_COUNT]
diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h
index 57746f3a68f..fdf1d09559d 100644
--- a/source/blender/blenkernel/BKE_sound.h
+++ b/source/blender/blenkernel/BKE_sound.h
@@ -94,14 +94,17 @@ void sound_update_fps(struct Scene *scene);
void sound_update_scene_listener(struct Scene *scene);
void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip);
+void* sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence);
void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip);
+void* sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence);
void sound_remove_scene_sound(struct Scene *scene, void* handle);
void sound_mute_scene_sound(void* handle, char mute);
void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip);
+void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence);
void sound_update_scene_sound(void* handle, struct bSound* sound);
diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c
index 1100c1c0ef5..1aad0a242f9 100644
--- a/source/blender/blenkernel/intern/bvhutils.c
+++ b/source/blender/blenkernel/intern/bvhutils.c
@@ -52,7 +52,7 @@ float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_d
{
float dist;
- if(isect_ray_tri_v3(ray->origin, ray->direction, v0, v1, v2, &dist, NULL))
+ if(isect_ray_tri_epsilon_v3(ray->origin, ray->direction, v0, v1, v2, &dist, NULL, FLT_EPSILON))
return dist;
return FLT_MAX;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index 878db6b3ed1..77a4a6a429c 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -41,6 +41,7 @@
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_editVert.h"
+#include "BLI_kdopbvh.h"
#include "BLI_utildefines.h"
#include "DNA_armature_types.h"
@@ -64,6 +65,7 @@
#include "BKE_anim.h" /* for the curve calculation part */
#include "BKE_armature.h"
#include "BKE_blender.h"
+#include "BKE_bvhutils.h"
#include "BKE_camera.h"
#include "BKE_constraint.h"
#include "BKE_displist.h"
@@ -3950,6 +3952,7 @@ static void followtrack_id_looper (bConstraint *con, ConstraintIDFunc func, void
func(con, (ID**)&data->clip, userdata);
func(con, (ID**)&data->camera, userdata);
+ func(con, (ID**)&data->depth_ob, userdata);
}
static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets))
@@ -3985,7 +3988,6 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
if (data->flag & FOLLOWTRACK_USE_3D_POSITION) {
if (track->flag & TRACK_HAS_BUNDLE) {
- MovieTracking *tracking= &clip->tracking;
float obmat[4][4], mat[4][4];
copy_m4_m4(obmat, cob->matrix);
@@ -4008,9 +4010,8 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
translate_m4(cob->matrix, track->bundle_pos[0], track->bundle_pos[1], track->bundle_pos[2]);
}
}
- }
+ }
else {
- MovieClipUser user;
MovieTrackingMarker *marker;
float vec[3], disp[3], axis[3], mat[4][4];
float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp);
@@ -4035,8 +4036,7 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
CameraParams params;
float pos[2], rmat[4][4];
- user.framenr= scene->r.cfra;
- marker= BKE_tracking_get_marker(track, user.framenr);
+ marker= BKE_tracking_get_marker(track, scene->r.cfra);
add_v2_v2v2(pos, marker->pos, track->offset);
@@ -4078,6 +4078,34 @@ static void followtrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
copy_v3_v3(cob->matrix[3], disp);
}
+
+ if(data->depth_ob && data->depth_ob->derivedFinal) {
+ Object *depth_ob= data->depth_ob;
+ BVHTreeFromMesh treeData= NULL_BVHTreeFromMesh;
+ BVHTreeRayHit hit;
+ float ray_start[3], ray_end[3], ray_nor[3], imat[4][4];
+ int result;
+
+ invert_m4_m4(imat, depth_ob->obmat);
+
+ mul_v3_m4v3(ray_start, imat, camob->obmat[3]);
+ mul_v3_m4v3(ray_end, imat, cob->matrix[3]);
+
+ sub_v3_v3v3(ray_nor, ray_end, ray_start);
+
+ bvhtree_from_mesh_faces(&treeData, depth_ob->derivedFinal, 0.0f, 4, 6);
+
+ hit.dist= FLT_MAX;
+ hit.index= -1;
+
+ result= BLI_bvhtree_ray_cast(treeData.tree, ray_start, ray_nor, 0.0f, &hit, treeData.raycast_callback, &treeData);
+
+ if(result != -1) {
+ mul_v3_m4v3(cob->matrix[3], depth_ob->obmat, hit.co);
+ }
+
+ free_bvhtree_from_mesh(&treeData);
+ }
}
}
}
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 3cb2f8ce738..762aaf3efc1 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -657,6 +657,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O
if((data->clip || data->flag&FOLLOWTRACK_ACTIVECLIP) && data->track[0])
depends_on_camera= 1;
+
+ if(data->depth_ob) {
+ node2 = dag_get_node(dag, data->depth_ob);
+ dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name);
+ }
}
else if(cti->type==CONSTRAINT_TYPE_OBJECTSOLVER)
depends_on_camera= 1;
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c
index 408a141608d..ef2249409f0 100644
--- a/source/blender/blenkernel/intern/mesh.c
+++ b/source/blender/blenkernel/intern/mesh.c
@@ -1248,8 +1248,6 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth)
mf->flag &= ~ME_SMOOTH;
}
}
-
- mesh_calc_normals(me->mvert, me->totvert, me->mface, me->totface, NULL);
}
void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float (*faceNors_r)[3])
diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c
index ab963f1e78c..4c78ab13874 100644
--- a/source/blender/blenkernel/intern/movieclip.c
+++ b/source/blender/blenkernel/intern/movieclip.c
@@ -860,7 +860,9 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip
undist_marker.pos[1]/= height*aspy;
}
- tmpibuf= BKE_tracking_get_pattern_imbuf(ibuf, track, &undist_marker, 1, 1, scopes->track_pos, NULL);
+ /* NOTE: margin should be kept in sync with value from ui_draw_but_TRACKPREVIEW */
+ tmpibuf= BKE_tracking_get_pattern_imbuf(ibuf, track, &undist_marker, 2 /* margin */,
+ 1 /* anchor */, scopes->track_pos, NULL);
if(tmpibuf->rect_float)
IMB_rect_from_float(tmpibuf);
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index ce1dd429794..5253d7a9961 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1325,6 +1325,11 @@ void nodeSetActive(bNodeTree *ntree, bNode *node)
node->flag |= NODE_ACTIVE_TEXTURE;
}
+int nodeSocketIsHidden(bNodeSocket *sock)
+{
+ return ((sock->flag & (SOCK_HIDDEN | SOCK_AUTO_HIDDEN | SOCK_UNAVAIL)) != 0);
+}
+
/* ************** dependency stuff *********** */
/* node is guaranteed to be not checked before */
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index ac612e3e996..fab59a7b88a 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -432,7 +432,8 @@ void unlink_object(Object *ob)
if(pchan->custom==ob)
pchan->custom= NULL;
}
- } else if(ELEM(OB_MBALL, ob->type, obt->type)) {
+ }
+ else if(ELEM(OB_MBALL, ob->type, obt->type)) {
if(is_mball_basis_for(obt, ob))
obt->recalc|= OB_RECALC_DATA;
}
@@ -618,21 +619,6 @@ void unlink_object(Object *ob)
sce= sce->id.next;
}
-#if 0 // XXX old animation system
- /* ipos */
- ipo= bmain->ipo.first;
- while(ipo) {
- if(ipo->id.lib==NULL) {
- IpoCurve *icu;
- for(icu= ipo->curve.first; icu; icu= icu->next) {
- if(icu->driver && icu->driver->ob==ob)
- icu->driver->ob= NULL;
- }
- }
- ipo= ipo->id.next;
- }
-#endif // XXX old animation system
-
/* screens */
sc= bmain->screen.first;
while(sc) {
@@ -1000,7 +986,7 @@ void copy_object_particlesystems(Object *obn, Object *ob)
}
else if (md->type==eModifierType_Smoke) {
SmokeModifierData *smd = (SmokeModifierData*) md;
-
+
if(smd->type==MOD_SMOKE_TYPE_FLOW) {
if (smd->flow) {
if (smd->flow->psys == psys)
@@ -1036,22 +1022,6 @@ static void copy_object_pose(Object *obn, Object *ob)
ListBase targets = {NULL, NULL};
bConstraintTarget *ct;
-#if 0 // XXX old animation system
- /* note that we can't change lib linked ipo blocks. for making
- * proxies this still works correct however because the object
- * is changed to object->proxy_from when evaluating the driver. */
- if(con->ipo && !con->ipo->id.lib) {
- IpoCurve *icu;
-
- con->ipo= copy_ipo(con->ipo);
-
- for(icu= con->ipo->curve.first; icu; icu= icu->next) {
- if(icu->driver && icu->driver->ob==ob)
- icu->driver->ob= obn;
- }
- }
-#endif // XXX old animation system
-
if (cti && cti->get_constraint_targets) {
cti->get_constraint_targets(con, &targets);
@@ -1081,8 +1051,7 @@ static int object_pose_context(Object *ob)
}
}
-//Object *object_pose_armature_get(Object *ob)
-Object *object_pose_armature_get(struct Object *ob)
+Object *object_pose_armature_get(Object *ob)
{
if(ob==NULL)
return NULL;
@@ -1188,13 +1157,8 @@ Object *copy_object(Object *ob)
static void extern_local_object(Object *ob)
{
- //bActionStrip *strip;
ParticleSystem *psys;
-#if 0 // XXX old animation system
- id_lib_extern((ID *)ob->action);
- id_lib_extern((ID *)ob->ipo);
-#endif // XXX old animation system
id_lib_extern((ID *)ob->data);
id_lib_extern((ID *)ob->dup_group);
id_lib_extern((ID *)ob->poselib);
@@ -1202,11 +1166,6 @@ static void extern_local_object(Object *ob)
extern_local_matarar(ob->mat, ob->totcol);
-#if 0 // XXX old animation system
- for (strip=ob->nlastrips.first; strip; strip=strip->next) {
- id_lib_extern((ID *)strip->act);
- }
-#endif // XXX old animation system
for(psys=ob->particlesystem.first; psys; psys=psys->next)
id_lib_extern((ID *)psys->part);
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index e4dcfcf1354..4afe9412786 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -39,6 +39,10 @@
#include <math.h>
#include <string.h>
+#ifdef _OPENMP
+#include <omp.h>
+#endif
+
#include "MEM_guardedalloc.h"
#include "DNA_anim_types.h"
@@ -2301,6 +2305,7 @@ static EdgeHash *sph_springhash_build(ParticleSystem *psys)
return springhash;
}
+#define SPH_NEIGHBORS 512
typedef struct SPHNeighbor
{
ParticleSystem *psys;
@@ -2308,7 +2313,7 @@ typedef struct SPHNeighbor
} SPHNeighbor;
typedef struct SPHRangeData
{
- SPHNeighbor neighbors[128];
+ SPHNeighbor neighbors[SPH_NEIGHBORS];
int tot_neighbors;
float density, near_density;
@@ -2319,10 +2324,6 @@ typedef struct SPHRangeData
float massfac;
int use_size;
-
- /* Same as SPHData::element_size */
- float element_size;
- float flow[3];
} SPHRangeData;
typedef struct SPHData {
ParticleSystem *psys[10];
@@ -2332,9 +2333,15 @@ typedef struct SPHData {
float *gravity;
/* Average distance to neighbours (other particles in the support domain),
for calculating the Courant number (adaptive time step). */
+ int pass;
float element_size;
float flow[3];
+
+ /* Integrator callbacks. This allows different SPH implementations. */
+ void (*force_cb) (void *sphdata_v, ParticleKey *state, float *force, float *impulse);
+ void (*density_cb) (void *rangedata_v, int index, float squared_dist);
}SPHData;
+
static void sph_density_accum_cb(void *userdata, int index, float squared_dist)
{
SPHRangeData *pfr = (SPHRangeData *)userdata;
@@ -2345,11 +2352,13 @@ static void sph_density_accum_cb(void *userdata, int index, float squared_dist)
if(npa == pfr->pa || squared_dist < FLT_EPSILON)
return;
- /* Ugh! One particle has over 128 neighbors! Really shouldn't happen,
- * but even if it does it shouldn't do any terrible harm if all are
- * not taken into account - jahka
+ /* Ugh! One particle has too many neighbors! If some aren't taken into
+ * account, the forces will be biased by the tree search order. This
+ * effectively adds enery to the system, and results in a churning motion.
+ * But, we have to stop somewhere, and it's not the end of the world.
+ * - jahka and z0r
*/
- if(pfr->tot_neighbors >= 128)
+ if(pfr->tot_neighbors >= SPH_NEIGHBORS)
return;
pfr->neighbors[pfr->tot_neighbors].index = index;
@@ -2359,15 +2368,38 @@ static void sph_density_accum_cb(void *userdata, int index, float squared_dist)
dist = sqrtf(squared_dist);
q = (1.f - dist/pfr->h) * pfr->massfac;
- add_v3_v3(pfr->flow, npa->state.vel);
- pfr->element_size += dist;
-
if(pfr->use_size)
q *= npa->size;
pfr->density += q*q;
pfr->near_density += q*q*q;
}
+/*
+ * Find the Courant number for an SPH particle (used for adaptive time step).
+ */
+static void sph_particle_courant(SPHData *sphdata, SPHRangeData *pfr) {
+ ParticleData *pa, *npa;
+ int i;
+ float flow[3], offset[3], dist;
+
+ flow[0] = flow[1] = flow[2] = 0.0f;
+ dist = 0.0f;
+ if (pfr->tot_neighbors > 0) {
+ pa = pfr->pa;
+ for (i=0; i < pfr->tot_neighbors; i++) {
+ npa = pfr->neighbors[i].psys->particles + pfr->neighbors[i].index;
+ sub_v3_v3v3(offset, pa->prev_state.co, npa->prev_state.co);
+ dist += len_v3(offset);
+ add_v3_v3(flow, npa->prev_state.vel);
+ }
+ dist += sphdata->psys[0]->part->fluid->radius; // TODO: remove this? - z0r
+ sphdata->element_size = dist / pfr->tot_neighbors;
+ mul_v3_v3fl(sphdata->flow, flow, 1.0f / pfr->tot_neighbors);
+ } else {
+ sphdata->element_size = MAXFLOAT;
+ VECCOPY(sphdata->flow, flow);
+ }
+}
static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, float *UNUSED(impulse))
{
SPHData *sphdata = (SPHData *)sphdata_v;
@@ -2408,24 +2440,14 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
pfr.density = pfr.near_density = 0.f;
pfr.h = h;
pfr.pa = pa;
- pfr.element_size = fluid->radius;
- pfr.flow[0] = pfr.flow[1] = pfr.flow[2] = 0.0f;
for(i=0; i<10 && psys[i]; i++) {
pfr.npsys = psys[i];
pfr.massfac = psys[i]->part->mass*inv_mass;
pfr.use_size = psys[i]->part->flag & PART_SIZEMASS;
- BLI_bvhtree_range_query(psys[i]->bvhtree, state->co, h, sph_density_accum_cb, &pfr);
- }
- if (pfr.tot_neighbors > 0) {
- pfr.element_size /= pfr.tot_neighbors;
- mul_v3_fl(pfr.flow, 1.0f / pfr.tot_neighbors);
- } else {
- pfr.element_size = MAXFLOAT;
+ BLI_bvhtree_range_query(psys[i]->bvhtree, state->co, h, sphdata->density_cb, &pfr);
}
- sphdata->element_size = pfr.element_size;
- copy_v3_v3(sphdata->flow, pfr.flow);
pressure = stiffness * (pfr.density - rest_density);
near_pressure = stiffness_near_fac * pfr.near_density;
@@ -2464,6 +2486,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
if(spring_constant > 0.f) {
/* Viscoelastic spring force */
if (pfn->psys == psys[0] && fluid->flag & SPH_VISCOELASTIC_SPRINGS && springhash) {
+ /* BLI_edgehash_lookup appears to be thread-safe. - z0r */
spring_index = GET_INT_FROM_POINTER(BLI_edgehash_lookup(springhash, index, pfn->index));
if(spring_index) {
@@ -2477,7 +2500,9 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
temp_spring.particle_index[1] = pfn->index;
temp_spring.rest_length = (fluid->flag & SPH_CURRENT_REST_LENGTH) ? rij : rest_length;
temp_spring.delete_flag = 0;
-
+
+ /* sph_spring_add is not thread-safe. - z0r */
+ #pragma omp critical
sph_spring_add(psys[0], &temp_spring);
}
}
@@ -2490,29 +2515,52 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa
/* Artificial buoyancy force in negative gravity direction */
if (fluid->buoyancy > 0.f && gravity)
madd_v3_v3fl(force, gravity, fluid->buoyancy * (pfr.density-rest_density));
+
+ if (sphdata->pass == 0 && psys[0]->part->time_flag & PART_TIME_AUTOSF)
+ sph_particle_courant(sphdata, &pfr);
+ sphdata->pass++;
}
-static void sph_integrate(ParticleSimulationData *sim, ParticleData *pa, float dfra, float *gravity, EdgeHash *springhash, float *element_size, float flow[3])
-{
+static void sph_solver_init(ParticleSimulationData *sim, SPHData *sphdata) {
ParticleTarget *pt;
int i;
+ // Add other coupled particle systems.
+ sphdata->psys[0] = sim->psys;
+ for(i=1, pt=sim->psys->targets.first; i<10; i++, pt=(pt?pt->next:NULL))
+ sphdata->psys[i] = pt ? psys_get_target_system(sim->ob, pt) : NULL;
+
+ if (psys_uses_gravity(sim))
+ sphdata->gravity = sim->scene->physics_settings.gravity;
+ else
+ sphdata->gravity = NULL;
+ sphdata->eh = sph_springhash_build(sim->psys);
+
+ // These per-particle values should be overridden later, but just for
+ // completeness we give them default values now.
+ sphdata->pa = NULL;
+ sphdata->mass = 1.0f;
+
+ sphdata->force_cb = sph_force_cb;
+ sphdata->density_cb = sph_density_accum_cb;
+}
+static void sph_solver_finalise(SPHData *sphdata) {
+ if (sphdata->eh) {
+ BLI_edgehash_free(sphdata->eh, NULL);
+ sphdata->eh = NULL;
+ }
+}
+static void sph_integrate(ParticleSimulationData *sim, ParticleData *pa, float dfra, SPHData *sphdata){
ParticleSettings *part = sim->psys->part;
// float timestep = psys_get_timestep(sim); // UNUSED
float pa_mass = part->mass * (part->flag & PART_SIZEMASS ? pa->size : 1.f);
float dtime = dfra*psys_get_timestep(sim);
// int steps = 1; // UNUSED
float effector_acceleration[3];
- SPHData sphdata;
- sphdata.psys[0] = sim->psys;
- for(i=1, pt=sim->psys->targets.first; i<10; i++, pt=(pt?pt->next:NULL))
- sphdata.psys[i] = pt ? psys_get_target_system(sim->ob, pt) : NULL;
-
- sphdata.pa = pa;
- sphdata.gravity = gravity;
- sphdata.mass = pa_mass;
- sphdata.eh = springhash;
+ sphdata->pa = pa;
+ sphdata->mass = pa_mass;
+ sphdata->pass = 0;
//sphdata.element_size and sphdata.flow are set in the callback.
/* restore previous state and treat gravity & effectors as external acceleration*/
@@ -2521,9 +2569,7 @@ static void sph_integrate(ParticleSimulationData *sim, ParticleData *pa, float d
copy_particle_key(&pa->state, &pa->prev_state, 0);
- integrate_particle(part, pa, dtime, effector_acceleration, sph_force_cb, &sphdata);
- *element_size = sphdata.element_size;
- copy_v3_v3(flow, sphdata.flow);
+ integrate_particle(part, pa, dtime, effector_acceleration, sphdata->force_cb, sphdata);
}
/************************************************/
@@ -3623,15 +3669,15 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra))
step, after the velocity has been updated. element_size defines the scale of
the simulation, and is typically the distance to neighbourning particles. */
void update_courant_num(ParticleSimulationData *sim, ParticleData *pa,
- float dtime, float element_size, float flow[3])
+ float dtime, SPHData *sphdata)
{
float relative_vel[3];
float speed;
- sub_v3_v3v3(relative_vel, pa->state.vel, flow);
+ sub_v3_v3v3(relative_vel, pa->prev_state.vel, sphdata->flow);
speed = len_v3(relative_vel);
- if (sim->courant_num < speed * dtime / element_size)
- sim->courant_num = speed * dtime / element_size;
+ if (sim->courant_num < speed * dtime / sphdata->element_size)
+ sim->courant_num = speed * dtime / sphdata->element_size;
}
/* Update time step size to suit current conditions. */
float update_timestep(ParticleSystem *psys, ParticleSimulationData *sim,
@@ -3717,11 +3763,11 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
case PART_PHYS_FLUID:
{
ParticleTarget *pt = psys->targets.first;
- psys_update_particle_bvhtree(psys, psys->cfra);
+ psys_update_particle_bvhtree(psys, cfra);
for(; pt; pt=pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */
if(pt->ob)
- psys_update_particle_bvhtree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), psys->cfra);
+ psys_update_particle_bvhtree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra);
}
break;
}
@@ -3803,37 +3849,32 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
}
case PART_PHYS_FLUID:
{
- EdgeHash *springhash = sph_springhash_build(psys);
- float *gravity = NULL;
- float element_size, flow[3];
-
- if(psys_uses_gravity(sim))
- gravity = sim->scene->physics_settings.gravity;
+ SPHData sphdata;
+ sph_solver_init(sim, &sphdata);
+ #pragma omp parallel for firstprivate (sphdata) private (pa) schedule(dynamic,5)
LOOP_DYNAMIC_PARTICLES {
/* do global forces & effectors */
basic_integrate(sim, p, pa->state.time, cfra);
/* actual fluids calculations */
- sph_integrate(sim, pa, pa->state.time, gravity, springhash,
- &element_size, flow);
+ sph_integrate(sim, pa, pa->state.time, &sphdata);
if(sim->colliders)
collision_check(sim, p, pa->state.time, cfra);
- /* SPH particles are not physical particles, just interpolation particles, thus rotation has not a direct sense for them */
+ /* SPH particles are not physical particles, just interpolation
+ * particles, thus rotation has not a direct sense for them */
basic_rotate(part, pa, pa->state.time, timestep);
+ #pragma omp critical
if (part->time_flag & PART_TIME_AUTOSF)
- update_courant_num(sim, pa, dtime, element_size, flow);
+ update_courant_num(sim, pa, dtime, &sphdata);
}
sph_springs_modify(psys, timestep);
- if(springhash) {
- BLI_edgehash_free(springhash, NULL);
- springhash = NULL;
- }
+ sph_solver_finalise(&sphdata);
break;
}
}
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c
index 5a57299cf25..7ea4fd751c4 100644
--- a/source/blender/blenkernel/intern/scene.c
+++ b/source/blender/blenkernel/intern/scene.c
@@ -80,8 +80,6 @@
#include "FRS_freestyle_config.h"
-//XXX #include "nla.h"
-
#ifdef WIN32
#else
#include <sys/time.h>
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index 718b3144677..731f82e1b80 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -1574,7 +1574,6 @@ typedef struct WipeZone {
int flip;
int xo, yo;
int width;
- float invwidth;
float pythangle;
} WipeZone;
@@ -1585,33 +1584,25 @@ static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo
wipezone->xo = xo;
wipezone->yo = yo;
wipezone->width = (int)(wipe->edgeWidth*((xo+yo)/2.0f));
- wipezone->pythangle = 1.0f/sqrtf(wipe->angle*wipe->angle + 1.0f);
-
- if(wipe->wipetype == DO_SINGLE_WIPE)
- wipezone->invwidth = 1.0f/wipezone->width;
- else
- wipezone->invwidth = 1.0f/(0.5f*wipezone->width);
+ wipezone->pythangle = 1.0f/sqrtf(wipezone->angle*wipezone->angle + 1.0f);
}
// This function calculates the blur band for the wipe effects
-static float in_band(WipeZone *wipezone,float width,float dist,float perc,int side,int dir)
+static float in_band(float width,float dist,int side,int dir)
{
- float t1,t2,alpha;
+ float alpha;
if(width == 0)
return (float)side;
-
+
if(width < dist)
- return side;
-
- t1 = dist * wipezone->invwidth; //percentange of width that is
- t2 = wipezone->invwidth; //amount of alpha per % point
-
+ return (float)side;
+
if(side == 1)
- alpha = (t1*t2*100) + (1-perc); // add point's alpha contrib to current position in wipe
+ alpha = (dist+0.5*width) / (width);
else
- alpha = (1-perc) - (t1*t2*100);
-
+ alpha = (0.5*width-dist) / (width);
+
if(dir == 0)
alpha = 1-alpha;
@@ -1648,7 +1639,6 @@ float hyp3,hyp4,b4,b5
switch (wipe->wipetype) {
case DO_SINGLE_WIPE:
width = wipezone->width;
- hwidth = width*0.5f;
if(angle == 0.0f) {
b1 = posy;
@@ -1669,15 +1659,15 @@ float hyp3,hyp4,b4,b5
if(wipe->forward) {
if(b1 < b2)
- output = in_band(wipezone,width,hyp,facf0,1,1);
+ output = in_band(width,hyp,1,1);
else
- output = in_band(wipezone,width,hyp,facf0,0,1);
+ output = in_band(width,hyp,0,1);
}
else {
if(b1 < b2)
- output = in_band(wipezone,width,hyp,facf0,0,1);
+ output = in_band(width,hyp,0,1);
else
- output = in_band(wipezone,width,hyp,facf0,1,1);
+ output = in_band(width,hyp,1,1);
}
break;
@@ -1700,27 +1690,23 @@ float hyp3,hyp4,b4,b5
b3 = (yo-posy*0.5f) - (-angle)*(xo-posx*0.5f);
b2 = y - (-angle)*x;
- hyp = abs(angle*x+y+(-posy*0.5f-angle*posx*0.5f))*wipezone->pythangle;
- hyp2 = abs(angle*x+y+(-(yo-posy*0.5f)-angle*(xo-posx*0.5f)))*wipezone->pythangle;
+ hyp = fabsf(angle*x+y+(-posy*0.5f-angle*posx*0.5f))*wipezone->pythangle;
+ hyp2 = fabsf(angle*x+y+(-(yo-posy*0.5f)-angle*(xo-posx*0.5f)))*wipezone->pythangle;
}
- temp1 = xo*(1-facf0*0.5f)-xo*facf0*0.5f;
- temp2 = yo*(1-facf0*0.5f)-yo*facf0*0.5f;
- pointdist = sqrt(temp1*temp1 + temp2*temp2);
+ hwidth= MIN2(hwidth, fabsf(b3-b1)/2.0f);
if(b2 < b1 && b2 < b3 ){
- if(hwidth < pointdist)
- output = in_band(wipezone,hwidth,hyp,facf0,0,1);
+ output = in_band(hwidth,hyp,0,1);
} else if(b2 > b1 && b2 > b3 ){
- if(hwidth < pointdist)
- output = in_band(wipezone,hwidth,hyp2,facf0,0,1);
+ output = in_band(hwidth,hyp2,0,1);
} else {
if( hyp < hwidth && hyp2 > hwidth )
- output = in_band(wipezone,hwidth,hyp,facf0,1,1);
+ output = in_band(hwidth,hyp,1,1);
else if( hyp > hwidth && hyp2 < hwidth )
- output = in_band(wipezone,hwidth,hyp2,facf0,1,1);
+ output = in_band(hwidth,hyp2,1,1);
else
- output = in_band(wipezone,hwidth,hyp2,facf0,1,1) * in_band(wipezone,hwidth,hyp,facf0,1,1);
+ output = in_band(hwidth,hyp2,1,1) * in_band(hwidth,hyp,1,1);
}
if(!wipe->forward)output = 1-output;
break;
@@ -1840,8 +1826,8 @@ float hyp3,hyp4,b4,b5
pointdist = sqrt(temp1*temp1 + temp1*temp1);
temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y));
- if(temp2 > pointdist) output = in_band(wipezone,hwidth,fabs(temp2-pointdist),facf0,0,1);
- else output = in_band(wipezone,hwidth,fabs(temp2-pointdist),facf0,1,1);
+ if(temp2 > pointdist) output = in_band(hwidth,fabs(temp2-pointdist),0,1);
+ else output = in_band(hwidth,fabs(temp2-pointdist),1,1);
if(!wipe->forward) output = 1-output;
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index cc4b8917a32..6da9199ddc4 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -3070,10 +3070,10 @@ void seq_sound_init(Scene *scene, Sequence *seq)
}
else {
if(seq->sound) {
- seq->scene_sound = sound_add_scene_sound(scene, seq, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
+ seq->scene_sound = sound_add_scene_sound_defaults(scene, seq);
}
if(seq->scene) {
- sound_scene_add_scene_sound(scene, seq, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
+ sound_scene_add_scene_sound_defaults(scene, seq);
}
}
}
@@ -3227,10 +3227,8 @@ void seq_update_sound_bounds_all(Scene *scene)
void seq_update_sound_bounds(Scene* scene, Sequence *seq)
{
- if(seq->scene_sound) {
- sound_move_scene_sound(scene, seq->scene_sound, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
- /* mute is set in seq_update_muting_recursive */
- }
+ sound_move_scene_sound_defaults(scene, seq);
+ /* mute is set in seq_update_muting_recursive */
}
static void seq_update_muting_recursive(ListBase *seqbasep, Sequence *metaseq, int mute)
@@ -3772,7 +3770,7 @@ static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence
} else if(seq->type == SEQ_SCENE) {
seqn->strip->stripdata = NULL;
if(seq->scene_sound)
- seqn->scene_sound = sound_scene_add_scene_sound(sce_audio, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
+ seqn->scene_sound = sound_scene_add_scene_sound_defaults(sce_audio, seqn);
} else if(seq->type == SEQ_MOVIE) {
seqn->strip->stripdata =
MEM_dupallocN(seq->strip->stripdata);
@@ -3781,7 +3779,7 @@ static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence
seqn->strip->stripdata =
MEM_dupallocN(seq->strip->stripdata);
if(seq->scene_sound)
- seqn->scene_sound = sound_add_scene_sound(sce_audio, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs);
+ seqn->scene_sound = sound_add_scene_sound_defaults(sce_audio, seqn);
seqn->sound->id.us++;
} else if(seq->type == SEQ_IMAGE) {
diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c
index ceaba2502d9..649984a7934 100644
--- a/source/blender/blenkernel/intern/sound.c
+++ b/source/blender/blenkernel/intern/sound.c
@@ -449,6 +449,13 @@ void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence
return NULL;
}
+void* sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence)
+{
+ return sound_scene_add_scene_sound(scene, sequence,
+ sequence->startdisp, sequence->enddisp,
+ sequence->startofs + sequence->anim_startofs);
+}
+
void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip)
{
void* handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS);
@@ -459,6 +466,13 @@ void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int
return handle;
}
+void* sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence)
+{
+ return sound_add_scene_sound(scene, sequence,
+ sequence->startdisp, sequence->enddisp,
+ sequence->startofs + sequence->anim_startofs);
+}
+
void sound_remove_scene_sound(struct Scene *scene, void* handle)
{
AUD_removeSequence(scene->sound_scene, handle);
@@ -474,6 +488,15 @@ void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, i
AUD_moveSequence(handle, startframe / FPS, endframe / FPS, frameskip / FPS);
}
+void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence)
+{
+ if (sequence->scene_sound) {
+ sound_move_scene_sound(scene, sequence->scene_sound,
+ sequence->startdisp, sequence->enddisp,
+ sequence->startofs + sequence->anim_startofs);
+ }
+}
+
void sound_update_scene_sound(void* handle, struct bSound* sound)
{
AUD_updateSequenceSound(handle, sound->playback_handle);
@@ -781,11 +804,13 @@ void sound_create_scene(struct Scene *UNUSED(scene)) {}
void sound_destroy_scene(struct Scene *UNUSED(scene)) {}
void sound_mute_scene(struct Scene *UNUSED(scene), int UNUSED(muted)) {}
void* sound_scene_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
+void* sound_scene_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence)) { return NULL; }
void* sound_add_scene_sound(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) { return NULL; }
+void* sound_add_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence* UNUSED(sequence)) { return NULL; }
void sound_remove_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle)) {}
void sound_mute_scene_sound(void* UNUSED(handle), char UNUSED(mute)) {}
void sound_move_scene_sound(struct Scene *UNUSED(scene), void* UNUSED(handle), int UNUSED(startframe), int UNUSED(endframe), int UNUSED(frameskip)) {}
-static void sound_start_play_scene(struct Scene *UNUSED(scene)) {}
+void sound_move_scene_sound_defaults(struct Scene *UNUSED(scene), struct Sequence *UNUSED(sequence)) {}
void sound_play_scene(struct Scene *UNUSED(scene)) {}
void sound_stop_scene(struct Scene *UNUSED(scene)) {}
void sound_seek_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) {}
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 7bfc7a8ef87..ff76fc14755 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -999,17 +999,24 @@ static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTracki
if(anchored)
add_v2_v2(mpos, track->offset);
+ if(pos)
+ zero_v2(pos);
+
x= mpos[0]*ibuf->x;
y= mpos[1]*ibuf->y;
- x1= x-(int)(-min[0]*ibuf->x);
- y1= y-(int)(-min[1]*ibuf->y);
- x2= x+(int)(max[0]*ibuf->x);
- y2= y+(int)(max[1]*ibuf->y);
- /* dimensions should be odd */
- w= (x2-x1)|1;
- h= (y2-y1)|1;
+ w= (max[0]-min[0])*ibuf->x;
+ h= (max[1]-min[1])*ibuf->y;
+
+ w= w|1;
+ h= h|1;
+ x1= x-(int)(w/2.0f);
+ y1= y-(int)(h/2.0f);
+ x2= x+(int)(w/2.0f);
+ y2= y+(int)(h/2.0f);
+
+ /* dimensions should be odd */
tmpibuf= IMB_allocImBuf(w+margin*2, h+margin*2, 32, IB_rect);
IMB_rectcpy(tmpibuf, ibuf, 0, 0, x1-margin, y1-margin, w+margin*2, h+margin*2);
@@ -1023,13 +1030,17 @@ static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTracki
origin[1]= y1-margin;
}
- if ((track->flag & TRACK_PREVIEW_GRAYSCALE) ||
- (track->flag & TRACK_DISABLE_RED) ||
- (track->flag & TRACK_DISABLE_GREEN) ||
- (track->flag & TRACK_DISABLE_BLUE) ) {
+ if((track->flag & TRACK_PREVIEW_GRAYSCALE) ||
+ (track->flag & TRACK_DISABLE_RED) ||
+ (track->flag & TRACK_DISABLE_GREEN) ||
+ (track->flag & TRACK_DISABLE_BLUE))
+ {
disable_imbuf_channels(tmpibuf, track, 1 /* grayscale */);
}
+ tmpibuf->ftype= PNG;
+ IMB_saveiff(tmpibuf, "/tmp/1.png", IB_rect);
+
return tmpibuf;
}