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:
authorNick Samarin <nicks1987@bigmir.net>2010-06-01 03:44:43 +0400
committerNick Samarin <nicks1987@bigmir.net>2010-06-01 03:44:43 +0400
commitd3d2e92fccc7ed65d753dbf8872b720ffe0fd6ad (patch)
tree47e96828bf662ecf9dc1800cce7361ce5fa0dbb6 /source/blender/blenkernel
parent05b92f0fc90b5f2cd5d933f97df20c774b42479f (diff)
synched branch with trunk at revision 29109
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_global.h3
-rw-r--r--source/blender/blenkernel/BKE_multires.h6
-rw-r--r--source/blender/blenkernel/BKE_particle.h2
-rw-r--r--source/blender/blenkernel/BKE_utildefines.h5
-rw-r--r--source/blender/blenkernel/CMakeLists.txt4
-rw-r--r--source/blender/blenkernel/SConscript3
-rw-r--r--source/blender/blenkernel/intern/Makefile4
-rw-r--r--source/blender/blenkernel/intern/anim.c117
-rw-r--r--source/blender/blenkernel/intern/armature.c4
-rw-r--r--source/blender/blenkernel/intern/blender.c2
-rw-r--r--source/blender/blenkernel/intern/cloth.c7
-rw-r--r--source/blender/blenkernel/intern/collision.c32
-rw-r--r--source/blender/blenkernel/intern/constraint.c219
-rw-r--r--source/blender/blenkernel/intern/customdata.c10
-rw-r--r--source/blender/blenkernel/intern/depsgraph.c43
-rw-r--r--source/blender/blenkernel/intern/fcurve.c2
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c2
-rw-r--r--source/blender/blenkernel/intern/image.c57
-rw-r--r--source/blender/blenkernel/intern/implicit.c65
-rw-r--r--source/blender/blenkernel/intern/multires.c10
-rw-r--r--source/blender/blenkernel/intern/node.c12
-rw-r--r--source/blender/blenkernel/intern/object.c28
-rw-r--r--source/blender/blenkernel/intern/particle.c91
-rw-r--r--source/blender/blenkernel/intern/particle_system.c90
-rw-r--r--source/blender/blenkernel/intern/sca.c23
25 files changed, 566 insertions, 275 deletions
diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h
index 291deb5ea70..6a602339e11 100644
--- a/source/blender/blenkernel/BKE_global.h
+++ b/source/blender/blenkernel/BKE_global.h
@@ -83,9 +83,6 @@ typedef struct Global {
struct VFont *selfont;
struct ListBase ttfdata;
- /* libtiff flag used to determine if shared library loaded for libtiff*/
- int have_libtiff;
-
/* this variable is written to / read from FileGlobal->fileflags */
int fileflags;
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h
index e5c7745f637..258fb6f1b3f 100644
--- a/source/blender/blenkernel/BKE_multires.h
+++ b/source/blender/blenkernel/BKE_multires.h
@@ -52,9 +52,9 @@ void multiresModifier_join(struct Object *);
void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction);
void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob,
int updateblock, int simple);
-int multiresModifier_reshape(struct MultiresModifierData *mmd, struct Object *dst, struct Object *src);
-int multiresModifier_reshapeFromDM(struct MultiresModifierData *mmd, struct Object *ob, struct DerivedMesh *srcdm);
-int multiresModifier_reshapeFromDeformMod(struct MultiresModifierData *mmd, struct Object *ob, struct ModifierData *md);
+int multiresModifier_reshape(struct Object *dst, struct Object *src);
+int multiresModifier_reshapeFromDM(struct Object *ob, struct DerivedMesh *srcdm);
+int multiresModifier_reshapeFromDeformMod(struct Object *ob, struct ModifierData *md);
void multires_stitch_grids(struct Object *);
diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h
index fcef00ae9b3..33a41821fe2 100644
--- a/source/blender/blenkernel/BKE_particle.h
+++ b/source/blender/blenkernel/BKE_particle.h
@@ -255,9 +255,11 @@ void psys_threads_free(ParticleThread *threads);
void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]);
/* particle_system.c */
+void psys_update_path_cache(struct ParticleSimulationData *sim, float cfra);
struct ParticleSystem *psys_get_target_system(struct Object *ob, struct ParticleTarget *pt);
void psys_count_keyed_targets(struct ParticleSimulationData *sim);
void psys_update_particle_tree(struct ParticleSystem *psys, float cfra);
+void psys_update_children(struct ParticleSimulationData *sim);
void psys_make_temp_pointcache(struct Object *ob, struct ParticleSystem *psys);
void psys_get_pointcache_start_end(struct Scene *scene, ParticleSystem *psys, int *sfra, int *efra);
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h
index 0b3fce9408c..925b1d7171a 100644
--- a/source/blender/blenkernel/BKE_utildefines.h
+++ b/source/blender/blenkernel/BKE_utildefines.h
@@ -38,6 +38,9 @@
#define TRUE 1
#endif
+/* Macro to convert a value to string in the preprocessor */
+#define QUOTE(x) #x
+
/* these values need to be hardcoded in structs, dna does not recognize defines */
/* also defined in DNA_space_types.h */
#ifndef FILE_MAXDIR
@@ -163,7 +166,7 @@
#define IMAG MAKE_ID('I','M','A','G')
#define DNA1 MAKE_ID('D','N','A','1')
-#define TEST MAKE_ID('T','E','S','T')
+#define TEST MAKE_ID('T','E','S','T') /* used as preview between 'REND' and 'GLOB' */
#define REND MAKE_ID('R','E','N','D')
#define USER MAKE_ID('U','S','E','R')
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index afb29fbcd62..68684bcc0a1 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -50,6 +50,10 @@ IF(WITH_OPENEXR)
ADD_DEFINITIONS(-DWITH_OPENEXR)
ENDIF(WITH_OPENEXR)
+IF(WITH_TIFF)
+ ADD_DEFINITIONS(-DWITH_TIFF)
+ENDIF(WITH_TIFF)
+
IF(WITH_OPENJPEG)
ADD_DEFINITIONS(-DWITH_OPENJPEG)
ENDIF(WITH_OPENJPEG)
diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript
index 57d7e45d986..6198520c853 100644
--- a/source/blender/blenkernel/SConscript
+++ b/source/blender/blenkernel/SConscript
@@ -38,6 +38,9 @@ else:
if env['WITH_BF_OPENEXR']:
defs.append('WITH_OPENEXR')
+if env['WITH_BF_TIFF']:
+ defs.append('WITH_TIFF')
+
if env['WITH_BF_OPENJPEG']:
defs.append('WITH_OPENJPEG')
diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile
index 4e365f363c3..15c022592f9 100644
--- a/source/blender/blenkernel/intern/Makefile
+++ b/source/blender/blenkernel/intern/Makefile
@@ -132,6 +132,10 @@ ifeq ($(WITH_QUICKTIME), true)
CPPFLAGS += -DWITH_QUICKTIME
endif
+ifeq ($(WITH_TIFF), true)
+ CPPFLAGS += -DWITH_TIFF
+endif
+
ifeq ($(OS), darwin)
ifeq ($(WITH_BF_OPENMP), true)
CPPFLAGS += -DPARALLEL=1
diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c
index 8619ab1eb1c..20afc715c77 100644
--- a/source/blender/blenkernel/intern/anim.c
+++ b/source/blender/blenkernel/intern/anim.c
@@ -52,6 +52,7 @@
#include "BKE_anim.h"
#include "BKE_curve.h"
#include "BKE_DerivedMesh.h"
+#include "BKE_depsgraph.h"
#include "BKE_font.h"
#include "BKE_group.h"
#include "BKE_global.h"
@@ -63,6 +64,7 @@
#include "BKE_particle.h"
#include "BKE_scene.h"
#include "BKE_utildefines.h"
+#include "BKE_depsgraph.h"
// XXX bad level call...
@@ -187,6 +189,8 @@ bMotionPath *animviz_verify_motionpaths(Scene *scene, Object *ob, bPoseChannel *
if (avs->path_bakeflag & MOTIONPATH_BAKE_HEADS)
mpath->flag |= MOTIONPATH_FLAG_BHEAD;
+ else
+ mpath->flag &= ~MOTIONPATH_FLAG_BHEAD;
/* allocate a cache */
mpath->points= MEM_callocN(sizeof(bMotionPathVert)*mpath->length, "bMotionPathVerts");
@@ -250,6 +254,83 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
/* ........ */
+/* Note on evaluation optimisations:
+ * Optimisations currently used here play tricks with the depsgraph in order to try and
+ * evaluate as few objects as strictly necessary to get nicer performance under standard
+ * production conditions. For those people who really need the accurate version,
+ * disable the ifdef (i.e. 1 -> 0) and comment out the call to motionpaths_calc_optimise_depsgraph()
+ */
+
+/* tweak the object ordering to trick depsgraph into making MotionPath calculations run faster */
+static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets)
+{
+ Base *base, *baseNext;
+ MPathTarget *mpt;
+
+ /* make sure our temp-tag isn't already in use */
+ for (base= scene->base.first; base; base= base->next)
+ base->object->flag &= ~BA_TEMP_TAG;
+
+ /* for each target, dump its object to the start of the list if it wasn't moved already */
+ for (mpt= targets->first; mpt; mpt= mpt->next) {
+ for (base=scene->base.first; base; base=baseNext) {
+ baseNext = base->next;
+
+ if ((base->object == mpt->ob) && !(mpt->ob->flag & BA_TEMP_TAG)) {
+ BLI_remlink(&scene->base, base);
+ BLI_addhead(&scene->base, base);
+
+ mpt->ob->flag |= BA_TEMP_TAG;
+ break; // we really don't need to continue anymore once this happens, but this line might really 'break'
+ }
+ }
+ }
+
+ /* "brew me a list that's sorted a bit faster now depsy" */
+ DAG_scene_sort(scene);
+}
+
+/* update scene for current frame */
+static void motionpaths_calc_update_scene(Scene *scene)
+{
+#if 1 // 'production' optimisations always on
+ Base *base, *last=NULL;
+
+ /* only stuff that moves or needs display still */
+ DAG_scene_update_flags(scene, scene->lay);
+
+ /* find the last object with the tag
+ * - all those afterwards are assumed to not be relevant for our calculations
+ */
+ // optimise further by moving out...
+ for (base=scene->base.first; base; base=base->next) {
+ if (base->object->flag & BA_TEMP_TAG)
+ last = base;
+ }
+
+ /* perform updates for tagged objects */
+ // XXX: this will break if rigs depend on scene or other data that
+ // is animated but not attached to/updatable from objects
+ for (base=scene->base.first; base; base=base->next) {
+ /* update this object */
+ object_handle_update(scene, base->object);
+
+ /* if this is the last one we need to update, let's stop to save some time */
+ if (base == last)
+ break;
+ }
+#else // original, 'always correct' version
+ /* do all updates
+ * - if this is too slow, resort to using a more efficient way
+ * that doesn't force complete update, but for now, this is the
+ * most accurate way!
+ */
+ scene_update_for_newframe(scene, scene->lay); // XXX this is the best way we can get anything moving
+#endif
+}
+
+/* ........ */
+
/* perform baking for the targets on the current frame */
static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets)
{
@@ -311,7 +392,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
// TODO: this method could be improved...
// 1) max range for standard baking
- // 2) minimum range for recalc baking (i.e. between keyfames, but how?)
+ // 2) minimum range for recalc baking (i.e. between keyframes, but how?)
for (mpt= targets->first; mpt; mpt= mpt->next) {
/* try to increase area to do (only as much as needed) */
sfra= MIN2(sfra, mpt->mpath->start_frame);
@@ -319,14 +400,14 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
}
if (efra <= sfra) return;
+ /* optimise the depsgraph for faster updates */
+ // TODO: whether this is used should depend on some setting for the level of optimisations used
+ motionpaths_calc_optimise_depsgraph(scene, targets);
+
/* calculate path over requested range */
for (CFRA=sfra; CFRA<=efra; CFRA++) {
- /* do all updates
- * - if this is too slow, resort to using a more efficient way
- * that doesn't force complete update, but for now, this is the
- * most accurate way!
- */
- scene_update_for_newframe(scene, scene->lay); // XXX this is the best way we can get anything moving
+ /* update relevant data for new frame */
+ motionpaths_calc_update_scene(scene);
/* perform baking for targets */
motionpaths_calc_bake_targets(scene, targets);
@@ -334,7 +415,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets)
/* reset original environment */
CFRA= cfra;
- scene_update_for_newframe(scene, scene->lay); // XXX this is the best way we can get anything moving
+ motionpaths_calc_update_scene(scene);
/* clear recalc flags from targets */
for (mpt= targets->first; mpt; mpt= mpt->next) {
@@ -1107,11 +1188,21 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
BLI_srandom(31415926 + psys->seed);
lay= scene->lay;
- if((psys->renderdata || part->draw_as==PART_DRAW_REND) &&
- ((part->ren_as == PART_DRAW_OB && part->dup_ob) ||
- (part->ren_as == PART_DRAW_GR && part->dup_group && part->dup_group->gobject.first))) {
+ if((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) {
- psys_check_group_weights(part);
+ /* first check for loops (particle system object used as dupli object) */
+ if(part->ren_as == PART_DRAW_OB) {
+ if(ELEM(part->dup_ob, NULL, par))
+ return;
+ }
+ else { /*PART_DRAW_GR */
+ if(part->dup_group == NULL || part->dup_group->gobject.first == NULL)
+ return;
+
+ for(go=part->dup_group->gobject.first; go; go=go->next)
+ if(go->ob == par)
+ return;
+ }
/* if we have a hair particle system, use the path cache */
if(part->type == PART_HAIR) {
@@ -1125,6 +1216,8 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p
totpart = psys->totcached;
}
+ psys_check_group_weights(part);
+
psys->lattice = psys_get_lattice(&sim);
/* gather list of objects or single object */
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 4f9b9435a80..557f3900d7b 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -2055,7 +2055,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o
/* we need to clamp this within sensible values */
// NOTE: these should be fine for now, but should get sanitised in future
- scale= MIN2( MAX2(scale, 0.0001) , 100000);
+ scale= MIN2(MAX2(scale, 0.0001) , 100000);
}
else
scale= 1.0f;
@@ -2127,8 +2127,6 @@ static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_
splineik_evaluate_bone(tree, scene, ob, pchan, i, ctime);
}
- // TODO: if another pass is needed to ensure the validity of the chain after blending, it should go here
-
/* free the tree info specific to SplineIK trees now */
if (tree->chain) MEM_freeN(tree->chain);
if (tree->free_points) MEM_freeN(tree->points);
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 5d12675952c..046b8de2431 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -534,7 +534,7 @@ void BKE_write_undo(bContext *C, char *name)
sprintf(numstr, "%d.blend", counter);
BLI_make_file_string("/", tstr, btempdir, numstr);
- success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL);
+ success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL, NULL);
strcpy(curundo->str, tstr);
}
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 2b11c4bdfa0..ce5bca1da56 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -27,16 +27,13 @@
#include "MEM_guardedalloc.h"
-#include "BKE_cloth.h"
-
#include "BKE_cdderivedmesh.h"
+#include "BKE_cloth.h"
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_modifier.h"
-#include "BKE_utildefines.h"
-
#include "BKE_pointcache.h"
-
+#include "BKE_utildefines.h"
#ifdef _WIN32
void tstart ( void )
diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c
index ffd504f5945..a77ac9b8e24 100644
--- a/source/blender/blenkernel/intern/collision.c
+++ b/source/blender/blenkernel/intern/collision.c
@@ -59,7 +59,7 @@ Collision modifier code start
/* step is limited from 0 (frame start position) to 1 (frame end position) */
void collision_move_object ( CollisionModifierData *collmd, float step, float prevstep )
{
- float tv[3] = {0,0,0};
+ float tv[3] = {0, 0, 0};
unsigned int i = 0;
for ( i = 0; i < collmd->numverts; i++ )
@@ -69,6 +69,7 @@ void collision_move_object ( CollisionModifierData *collmd, float step, float pr
VECADDS ( collmd->current_xnew[i].co, collmd->x[i].co, tv, step );
VECSUB ( collmd->current_v[i].co, collmd->current_xnew[i].co, collmd->current_x[i].co );
}
+
bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 );
}
@@ -527,7 +528,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier
float magtangent = 0, repulse = 0, d = 0;
double impulse = 0.0;
float vrel_t_pre[3];
- float temp[3];
+ float temp[3], spf;
// calculate tangential velocity
VECCOPY ( temp, collpair->normal );
@@ -565,10 +566,12 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier
// Apply repulse impulse if distance too short
// I_r = -min(dt*kd, m(0,1d/dt - v_n))
+ spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
+
d = clmd->coll_parms->epsilon*8.0/9.0 + epsilon2*8.0/9.0 - collpair->distance;
- if ( ( magrelVel < 0.1*d*clmd->sim_parms->stepsPerFrame ) && ( d > ALMOST_ZERO ) )
+ if ( ( magrelVel < 0.1*d*spf ) && ( d > ALMOST_ZERO ) )
{
- repulse = MIN2 ( d*1.0/clmd->sim_parms->stepsPerFrame, 0.1*d*clmd->sim_parms->stepsPerFrame - magrelVel );
+ repulse = MIN2 ( d*1.0/spf, 0.1*d*spf - magrelVel );
// stay on the safe side and clamp repulse
if ( impulse > ALMOST_ZERO )
@@ -1541,20 +1544,15 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl
overlap = BLI_bvhtree_overlap ( cloth_bvh, collmd->bvhtree, &result );
// go to next object if no overlap is there
- if(!result || !overlap)
- {
- if ( overlap )
- MEM_freeN ( overlap );
- continue;
- }
-
- /* check if collisions really happen (costly near check) */
- cloth_bvh_objcollisions_nearcheck ( clmd, collmd, &collisions[i], &collisions_index[i], result, overlap);
-
- // resolve nearby collisions
- ret += cloth_bvh_objcollisions_resolve ( clmd, collmd, collisions[i], collisions_index[i]);
- ret2 += ret;
+ if( result && overlap ) {
+ /* check if collisions really happen (costly near check) */
+ cloth_bvh_objcollisions_nearcheck ( clmd, collmd, &collisions[i], &collisions_index[i], result, overlap);
+ // resolve nearby collisions
+ ret += cloth_bvh_objcollisions_resolve ( clmd, collmd, collisions[i], collisions_index[i]);
+ ret2 += ret;
+ }
+
if ( overlap )
MEM_freeN ( overlap );
}
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index a3f1cb0cb0c..171276d118e 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -820,12 +820,12 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
/* extract components of both matrices */
VECCOPY(loc, ct->matrix[3]);
- mat4_to_eulO( eul, ct->rotOrder,ct->matrix);
- mat4_to_size( size,ct->matrix);
+ mat4_to_eulO(eul, ct->rotOrder, ct->matrix);
+ mat4_to_size(size, ct->matrix);
VECCOPY(loco, invmat[3]);
- mat4_to_eulO( eulo, cob->rotOrder,invmat);
- mat4_to_size( sizo,invmat);
+ mat4_to_eulO(eulo, cob->rotOrder, invmat);
+ mat4_to_size(sizo, invmat);
/* disable channels not enabled */
if (!(data->flag & CHILDOF_LOCX)) loc[0]= loco[0]= 0.0f;
@@ -1017,7 +1017,7 @@ static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
float tmat[4][4];
/* Get size property, since ob->size is only the object's own relative size, not its global one */
- mat4_to_size( size,cob->matrix);
+ mat4_to_size(size, cob->matrix);
/* Clear the object's rotation */
cob->matrix[0][0]=size[0];
@@ -1385,9 +1385,9 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t
float size[3];
VECCOPY(loc, cob->matrix[3]);
- mat4_to_size( size,cob->matrix);
+ mat4_to_size(size, cob->matrix);
- mat4_to_eulO( eul, cob->rotOrder,cob->matrix);
+ mat4_to_eulO(eul, cob->rotOrder, cob->matrix);
/* constraint data uses radians internally */
@@ -1638,11 +1638,11 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta
float size[3];
VECCOPY(loc, cob->matrix[3]);
- mat4_to_size( size,cob->matrix);
+ mat4_to_size(size, cob->matrix);
/* to allow compatible rotations, must get both rotations in the order of the owner... */
- mat4_to_eulO( eul, cob->rotOrder,ct->matrix);
- mat4_to_eulO( obeul, cob->rotOrder,cob->matrix);
+ mat4_to_eulO(eul, cob->rotOrder, ct->matrix);
+ mat4_to_eulO(obeul, cob->rotOrder, cob->matrix);
if ((data->flag & ROTLIKE_X)==0)
eul[0] = obeul[0];
@@ -1868,29 +1868,29 @@ static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob, ListBase
{
bSameVolumeConstraint *data= con->data;
+ float volume = data->volume;
+ float fac = 1.0f;
float obsize[3];
- float volume=data->volume;
mat4_to_size(obsize, cob->matrix);
-
+
+ /* calculate normalising scale factor for non-essential values */
+ if (obsize[data->flag] != 0)
+ fac = sqrt(volume / obsize[data->flag]) / obsize[data->flag];
+
+ /* apply scaling factor to the channels not being kept */
switch (data->flag) {
case SAMEVOL_X:
- if (obsize[0]!=0) {
- mul_v3_fl(cob->matrix[1], sqrt(volume/obsize[0])/obsize[0]);
- mul_v3_fl(cob->matrix[2], sqrt(volume/obsize[0])/obsize[0]);
- }
+ mul_v3_fl(cob->matrix[1], fac);
+ mul_v3_fl(cob->matrix[2], fac);
break;
case SAMEVOL_Y:
- if (obsize[1]!=0) {
- mul_v3_fl(cob->matrix[0], sqrt(volume/obsize[1])/obsize[1]);
- mul_v3_fl(cob->matrix[2], sqrt(volume/obsize[1])/obsize[1]);
- }
+ mul_v3_fl(cob->matrix[0], fac);
+ mul_v3_fl(cob->matrix[2], fac);
break;
case SAMEVOL_Z:
- if (obsize[2]!=0) {
- mul_v3_fl(cob->matrix[0], sqrt(volume/obsize[2])/obsize[2]);
- mul_v3_fl(cob->matrix[1], sqrt(volume/obsize[2])/obsize[2]);
- }
+ mul_v3_fl(cob->matrix[0], fac);
+ mul_v3_fl(cob->matrix[1], fac);
break;
}
}
@@ -2770,7 +2770,7 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
float dist;
/* store scaling before destroying obmat */
- mat4_to_size( size,cob->matrix);
+ mat4_to_size(size, cob->matrix);
/* store X orientation before destroying obmat */
xx[0] = cob->matrix[0][0];
@@ -3353,7 +3353,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
mat4_to_size( dvec,ct->matrix);
break;
case 1: /* rotation (convert to degrees first) */
- mat4_to_eulO( dvec, cob->rotOrder,ct->matrix);
+ mat4_to_eulO(dvec, cob->rotOrder, ct->matrix);
for (i=0; i<3; i++)
dvec[i] = (float)(dvec[i] / M_PI * 180);
break;
@@ -3364,8 +3364,8 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
/* extract components of owner's matrix */
VECCOPY(loc, cob->matrix[3]);
- mat4_to_eulO( eul, cob->rotOrder,cob->matrix);
- mat4_to_size( size,cob->matrix);
+ mat4_to_eulO(eul, cob->rotOrder, cob->matrix);
+ mat4_to_size(size, cob->matrix);
/* determine where in range current transforms lie */
if (data->expo) {
@@ -3485,73 +3485,73 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
float co[3] = {0.0f, 0.0f, 0.0f};
float no[3] = {0.0f, 0.0f, 0.0f};
float dist;
-
+
SpaceTransform transform;
DerivedMesh *target = object_get_derived_final(cob->scene, ct->tar, CD_MASK_BAREMESH);
BVHTreeRayHit hit;
BVHTreeNearest nearest;
-
+
BVHTreeFromMesh treeData;
- memset( &treeData, 0, sizeof(treeData) );
-
+ memset(&treeData, 0, sizeof(treeData));
+
nearest.index = -1;
nearest.dist = FLT_MAX;
-
+
hit.index = -1;
hit.dist = 100000.0f; //TODO should use FLT_MAX.. but normal projection doenst yet supports it
-
+
unit_m4(ct->matrix);
-
+
if(target != NULL)
{
space_transform_from_matrixs(&transform, cob->matrix, ct->tar->obmat);
-
+
switch(scon->shrinkType)
{
case MOD_SHRINKWRAP_NEAREST_SURFACE:
case MOD_SHRINKWRAP_NEAREST_VERTEX:
-
+
if(scon->shrinkType == MOD_SHRINKWRAP_NEAREST_VERTEX)
bvhtree_from_mesh_verts(&treeData, target, 0.0, 2, 6);
else
bvhtree_from_mesh_faces(&treeData, target, 0.0, 2, 6);
-
+
if(treeData.tree == NULL)
{
fail = TRUE;
break;
}
-
+
space_transform_apply(&transform, co);
-
+
BLI_bvhtree_find_nearest(treeData.tree, co, &nearest, treeData.nearest_callback, &treeData);
dist = len_v3v3(co, nearest.co);
interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */
space_transform_invert(&transform, co);
break;
-
+
case MOD_SHRINKWRAP_PROJECT:
if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) no[0] = 1.0f;
if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) no[1] = 1.0f;
if(scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) no[2] = 1.0f;
-
+
if(INPR(no,no) < FLT_EPSILON)
{
fail = TRUE;
break;
}
-
+
normalize_v3(no);
-
-
+
+
bvhtree_from_mesh_faces(&treeData, target, scon->dist, 4, 6);
if(treeData.tree == NULL)
{
fail = TRUE;
break;
}
-
+
if(normal_projection_project_vertex(0, co, no, &transform, treeData.tree, &hit, treeData.raycast_callback, &treeData) == FALSE)
{
fail = TRUE;
@@ -3560,17 +3560,17 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr
VECCOPY(co, hit.co);
break;
}
-
+
free_bvhtree_from_mesh(&treeData);
-
+
target->release(target);
-
+
if(fail == TRUE)
{
/* Don't move the point */
co[0] = co[1] = co[2] = 0.0f;
}
-
+
/* co is in local object coordinates, change it to global and update target position */
mul_m4_v3(cob->matrix, co);
VECCOPY(ct->matrix[3], co);
@@ -3704,7 +3704,7 @@ static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *
/* construct rotation matrix from the axis-angle rotation found above
* - this call takes care to make sure that the axis provided is a unit vector first
*/
- axis_angle_to_mat3( rmat,raxis, rangle);
+ axis_angle_to_mat3(rmat, raxis, rangle);
/* rotate the owner in the way defined by this rotation matrix, then reapply the location since
* we may have destroyed that in the process of multiplying the matrix
@@ -3831,6 +3831,118 @@ static bConstraintTypeInfo CTI_SPLINEIK = {
NULL /* evaluate - solved as separate loop */
};
+/* ----------- Pivot ------------- */
+
+static void pivotcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata)
+{
+ bPivotConstraint *data= con->data;
+
+ /* target only */
+ func(con, (ID**)&data->tar, userdata);
+}
+
+static int pivotcon_get_tars (bConstraint *con, ListBase *list)
+{
+ if (con && list) {
+ bPivotConstraint *data= con->data;
+ bConstraintTarget *ct;
+
+ /* standard target-getting macro for single-target constraints */
+ SINGLETARGET_GET_TARS(con, data->tar, data->subtarget, ct, list)
+
+ return 1;
+ }
+
+ return 0;
+}
+
+static void pivotcon_flush_tars (bConstraint *con, ListBase *list, short nocopy)
+{
+ if (con && list) {
+ bPivotConstraint *data= con->data;
+ bConstraintTarget *ct= list->first;
+
+ /* the following macro is used for all standard single-target constraints */
+ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy)
+ }
+}
+
+static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets)
+{
+ bPivotConstraint *data= con->data;
+ bConstraintTarget *ct= targets->first;
+
+ float pivot[3], vec[3];
+ float rotMat[3][3];
+
+ /* firstly, check if pivoting should take place based on the current rotation */
+ if (data->rotAxis != PIVOTCON_AXIS_NONE) {
+ float rot[3];
+
+ /* extract euler-rotation of target */
+ mat4_to_eulO(rot, cob->rotOrder, cob->matrix);
+
+ /* check which range might be violated */
+ if (data->rotAxis < PIVOTCON_AXIS_X) {
+ /* negative rotations (data->rotAxis = 0 -> 2) */
+ if (rot[data->rotAxis] > 0.0f)
+ return;
+ }
+ else {
+ /* positive rotations (data->rotAxis = 3 -> 5 */
+ if (rot[data->rotAxis - PIVOTCON_AXIS_X] < 0.0f)
+ return;
+ }
+ }
+
+ /* find the pivot-point to use */
+ if (VALID_CONS_TARGET(ct)) {
+ /* apply offset to target location */
+ add_v3_v3v3(pivot, ct->matrix[3], data->offset);
+ }
+ else {
+ /* no targets to worry about... */
+ if ((data->flag & PIVOTCON_FLAG_OFFSET_ABS) == 0) {
+ /* offset is relative to owner */
+ add_v3_v3v3(pivot, cob->matrix[3], data->offset);
+ }
+ else {
+ /* directly use the 'offset' specified as an absolute position instead */
+ VECCOPY(pivot, data->offset);
+ }
+ }
+
+ /* get rotation matrix representing the rotation of the owner */
+ // TODO: perhaps we might want to include scaling based on the pivot too?
+ copy_m3_m4(rotMat, cob->matrix);
+ normalize_m3(rotMat);
+
+ /* perform the pivoting... */
+ /* 1. take the vector from owner to the pivot */
+ sub_v3_v3v3(vec, pivot, cob->matrix[3]);
+ /* 2. rotate this vector by the rotation of the object... */
+ mul_m3_v3(rotMat, vec);
+ /* 3. make the rotation in terms of the pivot now */
+ add_v3_v3v3(cob->matrix[3], pivot, vec);
+}
+
+
+static bConstraintTypeInfo CTI_PIVOT = {
+ CONSTRAINT_TYPE_PIVOT, /* type */
+ sizeof(bPivotConstraint), /* size */
+ "Pivot", /* name */
+ "bPivotConstraint", /* struct name */
+ NULL, /* free data */
+ NULL, /* relink data */
+ pivotcon_id_looper, /* id looper */
+ NULL, /* copy data */
+ NULL, /* new data */ // XXX: might be needed to get 'normal' pivot behaviour...
+ pivotcon_get_tars, /* get constraint targets */
+ pivotcon_flush_tars, /* flush constraint targets */
+ default_get_tarmat, /* get target matrix */
+ pivotcon_evaluate /* evaluate */
+};
+
/* ************************* Constraints Type-Info *************************** */
/* All of the constraints api functions use bConstraintTypeInfo structs to carry out
* and operations that involve constraint specific code.
@@ -3867,6 +3979,7 @@ static void constraints_init_typeinfo () {
constraintsTypeInfo[22]= &CTI_SPLINEIK; /* Spline IK Constraint */
constraintsTypeInfo[23]= &CTI_TRANSLIKE; /* Copy Transforms Constraint */
constraintsTypeInfo[24]= &CTI_SAMEVOL; /* Maintain Volume Constraint */
+ constraintsTypeInfo[25]= &CTI_PIVOT; /* Pivot Constraint */
}
/* This function should be used for getting the appropriate type-info when only
@@ -4149,9 +4262,9 @@ void copy_constraints (ListBase *dst, const ListBase *src, int do_extern)
/* perform custom copying operations if needed */
if (cti->copy_data)
cti->copy_data(con, srccon);
-
+
/* for proxies we dont want to make extern */
- if(do_extern) {
+ if (do_extern) {
/* go over used ID-links for this constraint to ensure that they are valid for proxies */
if (cti->id_looper)
cti->id_looper(con, con_extern_cb, NULL);
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 69327eccfaf..361e6f3fd22 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -798,10 +798,12 @@ const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
};
const char *LAYERTYPENAMES[CD_NUMTYPES] = {
- "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace", "CDMTFace",
- "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags","CDMFloatProperty",
- "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco", "CDMTexPoly", "CDMLoopUV",
- "CDMloopCol", "CDTangent", "CDMDisps", "CDWeightMCol", "CDClothOrco"};
+ /* 0-4 */ "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace",
+ /* 5-9 */ "CDMTFace", "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags",
+ /* 10-14 */ "CDMFloatProperty", "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco",
+ /* 15-19 */ "CDMTexPoly", "CDMLoopUV", "CDMloopCol", "CDTangent", "CDMDisps",
+ /* 20-23 */"CDWeightMCol", "CDIDMCol", "CDTextureMCol", "CDClothOrco"
+};
const CustomDataMask CD_MASK_BAREMESH =
CD_MASK_MVERT | CD_MASK_MEDGE | CD_MASK_MFACE;
diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 1e5f276ba95..bdeacdf6946 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -2250,6 +2250,16 @@ void DAG_on_load_update(void)
}
}
+static void dag_id_flush_update__isDependentTexture(void *userData, Object *ob, ID **idpoin)
+{
+ struct { ID *id; int is_dependent; } *data = userData;
+
+ if(*idpoin && GS((*idpoin)->name)==ID_TE) {
+ if (data->id == (*idpoin))
+ data->is_dependent = 1;
+ }
+}
+
void DAG_id_flush_update(ID *id, short flag)
{
Main *bmain= G.main;
@@ -2276,11 +2286,7 @@ void DAG_id_flush_update(ID *id, short flag)
/* no point in trying in this cases */
if(!id || id->us <= 1)
id= NULL;
- /* curves and surfaces only need to mark one object, since
- otherwise cu->displist would be computed multiple times */
- else if(ob->type==OB_CURVE || ob->type==OB_SURF)
- id= NULL;
- /* also for locked shape keys we make an exception */
+ /* for locked shape keys we make an exception */
else if(ob_get_key(ob) && (ob->shapeflag & OB_SHAPE_LOCK))
id= NULL;
}
@@ -2291,19 +2297,38 @@ void DAG_id_flush_update(ID *id, short flag)
idtype= GS(id->name);
if(ELEM7(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR)) {
+ int first_ob= 1;
for(obt=bmain->object.first; obt; obt= obt->id.next) {
if(!(ob && obt == ob) && obt->data == id) {
+
+ /* try to avoid displist recalculation for linked curves */
+ if (!first_ob && ELEM(obt->type, OB_CURVE, OB_SURF)) {
+ /* if curve object has got derivedFinal it means this
+ object has got constructive modifiers and object
+ should be recalculated anyhow */
+ if (!obt->derivedFinal)
+ continue;
+ }
+
obt->recalc |= OB_RECALC_DATA;
BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH);
- /* for these we only flag one object, otherwise cu->displist
- would be computed multiple times */
- if(obt->type==OB_CURVE || obt->type==OB_SURF)
- break;
+ first_ob= 0;
}
}
}
+ /* set flags based on textures - can influence depgraph via modifiers */
+ if(idtype == ID_TE) {
+ for(obt=bmain->object.first; obt; obt= obt->id.next) {
+ struct { ID *id; int is_dependent; } data = {id, 0};
+
+ modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data);
+ if (data.is_dependent)
+ obt->recalc |= OB_RECALC_DATA;
+ }
+ }
+
/* set flags based on ShapeKey */
if(idtype == ID_KE) {
for(obt=bmain->object.first; obt; obt= obt->id.next) {
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c
index 619bb1a58f9..43f01199b69 100644
--- a/source/blender/blenkernel/intern/fcurve.c
+++ b/source/blender/blenkernel/intern/fcurve.c
@@ -1418,7 +1418,7 @@ static float evaluate_driver (ChannelDriver *driver, float evaltime)
/* this evaluates the expression using Python,and returns its result:
* - on errors it reports, then returns 0.0f
*/
- driver->curval= BPY_pydriver_eval(driver);
+ driver->curval= BPY_eval_driver(driver);
}
#endif /* DISABLE_PYTHON*/
}
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 868b06f2348..6fcc49f9ec1 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -44,7 +44,7 @@
#include "BKE_utildefines.h"
#ifndef DISABLE_PYTHON
-#include "BPY_extern.h" /* for BPY_pydriver_eval() */
+#include "BPY_extern.h" /* for BPY_eval_driver() */
#endif
#define SMALL -1.0e-10
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index eb478eaddf5..39efd9fe72e 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -779,10 +779,12 @@ void BKE_add_image_extension(char *string, int imtype)
if(!BLI_testextensie(string, ".bmp"))
extension= ".bmp";
}
- else if(G.have_libtiff && (imtype==R_TIFF)) {
+#ifdef WITH_TIFF
+ else if(imtype==R_TIFF) {
if(!BLI_testextensie(string, ".tif") &&
!BLI_testextensie(string, ".tiff")) extension= ".tif";
}
+#endif
#ifdef WITH_OPENEXR
else if( ELEM(imtype, R_OPENEXR, R_MULTILAYER)) {
if(!BLI_testextensie(string, ".exr"))
@@ -980,6 +982,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
struct StampData stamp_data;
float w, h, pad;
int x, y;
+ float h_fixed;
if (!rect && !rectf)
return;
@@ -996,16 +999,24 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0);
pad= BLF_width(mono, "--");
+ /* use 'h_fixed' rather then 'h', aligns better */
+ // BLF_width_and_height(mono, "^|/_AgPpJjlYy", &w, &h_fixed);
+ {
+ rctf box;
+ BLF_boundbox(mono, "^|/_AgPpJjlYy", &box);
+ h_fixed= box.ymax - box.ymin;
+ }
+
x= 0;
y= height;
if (stamp_data.file[0]) {
/* Top left corner */
- BLF_width_and_height(mono, stamp_data.file, &w, &h);
+ BLF_width_and_height(mono, stamp_data.file, &w, &h); h= h_fixed;
y -= h;
/* also a little of space to the background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, w+3, y+h+3);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, w+3, y+h+2);
/* and draw the text. */
BLF_position(mono, x, y, 0.0);
@@ -1017,11 +1028,11 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
/* Top left corner, below File */
if (stamp_data.note[0]) {
- BLF_width_and_height(mono, stamp_data.note, &w, &h);
+ BLF_width_and_height(mono, stamp_data.note, &w, &h); h= h_fixed;
y -= h;
/* and space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-2, w+3, y+h+2);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+2);
BLF_position(mono, x, y+1, 0.0);
BLF_draw_buffer(mono, stamp_data.note);
@@ -1032,11 +1043,11 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
/* Top left corner, below File (or Note) */
if (stamp_data.date[0]) {
- BLF_width_and_height(mono, stamp_data.date, &w, &h);
+ BLF_width_and_height(mono, stamp_data.date, &w, &h); h= h_fixed;
y -= h;
/* and space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+2);
BLF_position(mono, x, y, 0.0);
BLF_draw_buffer(mono, stamp_data.date);
@@ -1047,11 +1058,11 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
/* Top left corner, below File, Date or Note */
if (stamp_data.rendertime[0]) {
- BLF_width_and_height(mono, stamp_data.rendertime, &w, &h);
+ BLF_width_and_height(mono, stamp_data.rendertime, &w, &h); h= h_fixed;
y -= h;
/* and space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+3);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+2);
BLF_position(mono, x, y, 0.0);
BLF_draw_buffer(mono, stamp_data.rendertime);
@@ -1062,10 +1073,10 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
/* Bottom left corner, leaving space for timing */
if (stamp_data.marker[0]) {
- BLF_width_and_height(mono, stamp_data.marker, &w, &h);
+ BLF_width_and_height(mono, stamp_data.marker, &w, &h); h= h_fixed;
/* extra space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, w+2, y+h+3);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, w+2, y+h+2);
/* and pad the text. */
BLF_position(mono, x, y+3, 0.0);
@@ -1077,10 +1088,10 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
/* Left bottom corner */
if (stamp_data.time[0]) {
- BLF_width_and_height(mono, stamp_data.time, &w, &h);
+ BLF_width_and_height(mono, stamp_data.time, &w, &h); h= h_fixed;
/* extra space for background */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2);
/* and pad the text. */
BLF_position(mono, x, y+3, 0.0);
@@ -1091,10 +1102,10 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
}
if (stamp_data.frame[0]) {
- BLF_width_and_height(mono, stamp_data.frame, &w, &h);
+ BLF_width_and_height(mono, stamp_data.frame, &w, &h); h= h_fixed;
/* extra space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2);
/* and pad the text. */
BLF_position(mono, x, y+3, 0.0);
@@ -1105,22 +1116,22 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
}
if (stamp_data.camera[0]) {
- BLF_width_and_height(mono, stamp_data.camera, &w, &h);
+ BLF_width_and_height(mono, stamp_data.camera, &w, &h); h= h_fixed;
/* extra space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+3);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2);
BLF_position(mono, x, y+3, 0.0);
BLF_draw_buffer(mono, stamp_data.camera);
}
if (stamp_data.scene[0]) {
- BLF_width_and_height(mono, stamp_data.scene, &w, &h);
+ BLF_width_and_height(mono, stamp_data.scene, &w, &h); h= h_fixed;
/* Bottom right corner, with an extra space because blenfont is too strict! */
x= width - w - 2;
/* extra space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+3, y+h+3);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+3, y+h+2);
/* and pad the text. */
BLF_position(mono, x, y+3, 0.0);
@@ -1128,14 +1139,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i
}
if (stamp_data.strip[0]) {
- BLF_width_and_height(mono, stamp_data.scene, &w, &h);
+ BLF_width_and_height(mono, stamp_data.scene, &w, &h); h= h_fixed;
/* Top right corner, with an extra space because blenfont is too strict! */
x= width - w - pad;
y= height - h;
/* extra space for background. */
- buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, x+w+pad, y+h+3);
+ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, x+w+pad, y+h+2);
BLF_position(mono, x, y, 0.0);
BLF_draw_buffer(mono, stamp_data.strip);
@@ -1187,12 +1198,14 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt
else if ((imtype==R_BMP)) {
ibuf->ftype= BMP;
}
- else if ((G.have_libtiff) && (imtype==R_TIFF)) {
+#ifdef WITH_TIFF
+ else if (imtype==R_TIFF) {
ibuf->ftype= TIF;
if(subimtype & R_TIFF_16BIT)
ibuf->ftype |= TIF_16BIT;
}
+#endif
#ifdef WITH_OPENEXR
else if (imtype==R_OPENEXR || imtype==R_MULTILAYER) {
ibuf->ftype= OPENEXR;
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c
index c625fb28840..902965bd2f6 100644
--- a/source/blender/blenkernel/intern/implicit.c
+++ b/source/blender/blenkernel/intern/implicit.c
@@ -37,6 +37,10 @@
#include "BKE_global.h"
#include "BKE_utildefines.h"
+#include "BLI_threads.h"
+
+#define CLOTH_OPENMP_LIMIT 25
+
#ifdef _WIN32
#include <windows.h>
static LARGE_INTEGER _itstart, _itend;
@@ -230,8 +234,11 @@ DO_INLINE float dot_lfvector(float (*fLongVectorA)[3], float (*fLongVectorB)[3],
{
long i = 0;
float temp = 0.0;
+// XXX brecht, disabled this for now (first schedule line was already disabled),
+// due to non-commutative nature of floating point ops this makes the sim give
+// different results each time you run it!
// schedule(guided, 2)
-#pragma omp parallel for reduction(+: temp)
+//#pragma omp parallel for reduction(+: temp) if(verts > CLOTH_OPENMP_LIMIT)
for(i = 0; i < (long)verts; i++)
{
temp += INPR(fLongVectorA[i], fLongVectorB[i]);
@@ -577,11 +584,12 @@ DO_INLINE void mul_bfmatrix_S(fmatrix3x3 *matrix, float scalar)
DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector *fLongVector)
{
unsigned int i = 0;
- lfVector *temp = create_lfvector(from[0].vcount);
+ unsigned int vcount = from[0].vcount;
+ lfVector *temp = create_lfvector(vcount);
- zero_lfvector(to, from[0].vcount);
+ zero_lfvector(to, vcount);
-#pragma omp parallel sections private(i)
+#pragma omp parallel sections private(i) if(vcount > CLOTH_OPENMP_LIMIT)
{
#pragma omp section
{
@@ -962,7 +970,7 @@ DO_INLINE void BuildPPinv(fmatrix3x3 *lA, fmatrix3x3 *P, fmatrix3x3 *Pinv)
unsigned int i = 0;
// Take only the diagonal blocks of A
-// #pragma omp parallel for private(i)
+// #pragma omp parallel for private(i) if(lA[0].vcount > CLOTH_OPENMP_LIMIT)
for(i = 0; i<lA[0].vcount; i++)
{
// block diagonalizer
@@ -1460,6 +1468,8 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
i = HAIR_GRID_INDEX(lX[v], gmin, gmax, 0);
j = HAIR_GRID_INDEX(lX[v], gmin, gmax, 1);
k = HAIR_GRID_INDEX(lX[v], gmin, gmax, 2);
+ if (i < 0 || j < 0 || k < 0 || i > 10 || j >= 10 || k >= 10)
+ continue;
grid[i][j][k].velocity[0] += lV[v][0];
grid[i][j][k].velocity[1] += lV[v][1];
@@ -1523,6 +1533,8 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
i = HAIR_GRID_INDEX(lX[v], gmin, gmax, 0);
j = HAIR_GRID_INDEX(lX[v], gmin, gmax, 1);
k = HAIR_GRID_INDEX(lX[v], gmin, gmax, 2);
+ if (i < 0 || j < 0 || k < 0 || i > 10 || j >= 10 || k >= 10)
+ continue;
lF[v][0] += smoothfac * (grid[i][j][k].velocity[0] - lV[v][0]);
lF[v][1] += smoothfac * (grid[i][j][k].velocity[1] - lV[v][1]);
@@ -1537,6 +1549,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec
free_collider_cache(&colliders);
}
+
static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF, lfVector *lX, lfVector *lV, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, ListBase *effectors, float time, fmatrix3x3 *M)
{
/* Collect forces and derivatives: F,dFdX,dFdV */
@@ -1731,9 +1744,10 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
ClothVertex *verts = cloth->verts;
unsigned int numverts = cloth->numverts;
float dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame;
+ float spf = (float)clmd->sim_parms->stepsPerFrame / clmd->sim_parms->timescale;
Implicit_Data *id = cloth->implicit;
- int result = 0;
-
+ int do_extra_solve;
+
if(clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) /* do goal stuff */
{
for(i = 0; i < numverts; i++)
@@ -1778,60 +1792,50 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
if(clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED && clmd->clothObject->bvhtree)
{
- float temp = clmd->sim_parms->stepsPerFrame;
- /* not too nice hack, but collisions need this correction -jahka */
- clmd->sim_parms->stepsPerFrame /= clmd->sim_parms->timescale;
-
// collisions
// itstart();
// update verts to current positions
for(i = 0; i < numverts; i++)
- {
+ {
VECCOPY(verts[i].tx, id->Xnew[i]);
-
+
VECSUB(verts[i].tv, verts[i].tx, verts[i].txold);
VECCOPY(verts[i].v, verts[i].tv);
}
-
+
// call collision function
// TODO: check if "step" or "step+dt" is correct - dg
- result = cloth_bvh_objcollision(ob, clmd, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale);
-
- // correct velocity again, just to be sure we had to change it due to adaptive collisions
- for(i = 0; i < numverts; i++)
- {
- VECSUB(verts[i].tv, verts[i].tx, id->X[i]);
- }
+ do_extra_solve = cloth_bvh_objcollision(ob, clmd, step/clmd->sim_parms->timescale, dt/clmd->sim_parms->timescale);
// copy corrected positions back to simulation
for(i = 0; i < numverts; i++)
{
- if(result)
+ // correct velocity again, just to be sure we had to change it due to adaptive collisions
+ VECSUB(verts[i].tv, verts[i].tx, id->X[i]);
+
+ if(do_extra_solve)
{
if((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_GOAL) && (verts [i].flags & CLOTH_VERT_FLAG_PINNED))
continue;
-
+
VECCOPY(id->Xnew[i], verts[i].tx);
VECCOPY(id->Vnew[i], verts[i].tv);
- mul_v3_fl(id->Vnew[i], clmd->sim_parms->stepsPerFrame);
+ mul_v3_fl(id->Vnew[i], spf);
}
}
- /* restore original stepsPerFrame */
- clmd->sim_parms->stepsPerFrame = temp;
-
// X = Xnew;
cp_lfvector(id->X, id->Xnew, numverts);
-
+
// if there were collisions, advance the velocity from v_n+1/2 to v_n+1
- if(result)
+ if(do_extra_solve)
{
// V = Vnew;
cp_lfvector(id->V, id->Vnew, numverts);
-
+
// calculate
cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step+dt, id->M);
@@ -1851,7 +1855,6 @@ int implicit_solver (Object *ob, float frame, ClothModifierData *clmd, ListBase
cp_lfvector(id->V, id->Vnew, numverts);
step += dt;
-
}
for(i = 0; i < numverts; i++)
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c
index 52c6f9355a3..d8c39abc44a 100644
--- a/source/blender/blenkernel/intern/multires.c
+++ b/source/blender/blenkernel/intern/multires.c
@@ -207,7 +207,7 @@ void multiresModifier_join(Object *ob)
}
#endif
-int multiresModifier_reshapeFromDM(MultiresModifierData *mmd, Object *ob, DerivedMesh *srcdm)
+int multiresModifier_reshapeFromDM(Object *ob, DerivedMesh *srcdm)
{
DerivedMesh *mrdm = get_multires_dm (ob);
@@ -228,13 +228,13 @@ int multiresModifier_reshapeFromDM(MultiresModifierData *mmd, Object *ob, Derive
}
/* Returns 1 on success, 0 if the src's totvert doesn't match */
-int multiresModifier_reshape(MultiresModifierData *mmd, Object *dst, Object *src)
+int multiresModifier_reshape(Object *dst, Object *src)
{
DerivedMesh *srcdm = src->derivedFinal;
- return multiresModifier_reshapeFromDM(mmd, dst, srcdm);
+ return multiresModifier_reshapeFromDM(dst, srcdm);
}
-int multiresModifier_reshapeFromDeformMod(MultiresModifierData *mmd, Object *ob, ModifierData *md)
+int multiresModifier_reshapeFromDeformMod(Object *ob, ModifierData *md)
{
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
DerivedMesh *dm, *ndm;
@@ -256,7 +256,7 @@ int multiresModifier_reshapeFromDeformMod(MultiresModifierData *mmd, Object *ob,
dm->release(dm);
/* Reshaping */
- result= multiresModifier_reshapeFromDM(mmd, ob, ndm);
+ result= multiresModifier_reshapeFromDM(ob, ndm);
/* Cleanup */
ndm->release(ndm);
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 3d49548cba7..13ea55ebf0f 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -2434,7 +2434,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
bNode *node;
ListBase threads;
ThreadData thdata;
- int totnode, rendering= 1;
+ int totnode, curnode, rendering= 1;
if(ntree==NULL) return;
@@ -2455,7 +2455,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
BLI_srandom(rd->cfra);
/* sets need_exec tags in nodes */
- totnode= setExecutableNodes(ntree, &thdata);
+ curnode = totnode= setExecutableNodes(ntree, &thdata);
BLI_init_threads(&threads, exec_composite_node, rd->threads);
@@ -2465,14 +2465,14 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
node= getExecutableNode(ntree);
if(node) {
- if(ntree->timecursor)
- ntree->timecursor(ntree->tch, totnode);
+ if(ntree->progress)
+ ntree->progress(ntree->prh, (1.0 - curnode/(float)totnode));
if(ntree->stats_draw) {
char str[64];
- sprintf(str, "Compositing %d %s", totnode, node->name);
+ sprintf(str, "Compositing %d %s", curnode, node->name);
ntree->stats_draw(ntree->sdh, str);
}
- totnode--;
+ curnode--;
node->threaddata = &thdata;
node->exec= NODE_PROCESSING;
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 24c23e5ea41..576b3481d07 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -2879,15 +2879,18 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, char *name, int from_m
newkey= 1;
}
- kb= add_keyblock(key, name);
-
if(newkey || from_mix==FALSE) {
/* create from mesh */
+ kb= add_keyblock(key, name);
mesh_to_key(me, kb);
}
else {
/* copy from current values */
- kb->data= do_ob_key(scene, ob);
+ float *data= do_ob_key(scene, ob);
+
+ /* create new block with prepared data */
+ kb= add_keyblock(key, name);
+ kb->data= data;
kb->totelem= me->totvert;
}
@@ -2907,16 +2910,20 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, char *name, int from_m
newkey= 1;
}
- kb= add_keyblock(key, name);
-
if(newkey || from_mix==FALSE) {
+ kb= add_keyblock(key, name);
+
/* create from lattice */
latt_to_key(lt, kb);
}
else {
/* copy from current values */
+ float *data= do_ob_key(scene, ob);
+
+ /* create new block with prepared data */
+ kb= add_keyblock(key, name);
kb->totelem= lt->pntsu*lt->pntsv*lt->pntsw;
- kb->data= do_ob_key(scene, ob);
+ kb->data= data;
}
return kb;
@@ -2936,16 +2943,19 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, char *name, int from_
newkey= 1;
}
- kb= add_keyblock(key, name);
-
if(newkey || from_mix==FALSE) {
/* create from curve */
+ kb= add_keyblock(key, name);
curve_to_key(cu, kb, lb);
}
else {
/* copy from current values */
+ float *data= do_ob_key(scene, ob);
+
+ /* create new block with prepared data */
+ kb= add_keyblock(key, name);
kb->totelem= count_curveverts(lb);
- kb->data= do_ob_key(scene, ob);
+ kb->data= data;
}
return kb;
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index fffbd31aa02..0c55cc2aaac 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -433,7 +433,7 @@ void free_keyed_keys(ParticleSystem *psys)
}
}
}
-static void free_child_path_cache(ParticleSystem *psys)
+void psys_free_child_path_cache(ParticleSystem *psys)
{
psys_free_path_cache_buffers(psys->childcache, &psys->childcachebufs);
psys->childcache = NULL;
@@ -451,7 +451,7 @@ void psys_free_path_cache(ParticleSystem *psys, PTCacheEdit *edit)
psys->pathcache= NULL;
psys->totcached= 0;
- free_child_path_cache(psys);
+ psys_free_child_path_cache(psys);
}
}
void psys_free_children(ParticleSystem *psys)
@@ -462,7 +462,7 @@ void psys_free_children(ParticleSystem *psys)
psys->totchild=0;
}
- free_child_path_cache(psys);
+ psys_free_child_path_cache(psys);
}
void psys_free_particles(ParticleSystem *psys)
{
@@ -1037,6 +1037,7 @@ typedef struct ParticleInterpolationData {
ParticleKey *kkey[2];
PointCache *cache;
+ PTCacheMem *pm;
PTCacheEditPoint *epoint;
PTCacheEditKey *ekey[2];
@@ -1045,31 +1046,74 @@ typedef struct ParticleInterpolationData {
int bspline;
} ParticleInterpolationData;
/* Assumes pointcache->mem_cache exists, so for disk cached particles call psys_make_temp_pointcache() before use */
-static void get_pointcache_keys_for_time(Object *ob, PointCache *cache, int index, float t, ParticleKey *key1, ParticleKey *key2)
+/* It uses ParticleInterpolationData->pm to store the current memory cache frame so it's thread safe. */
+static void get_pointcache_keys_for_time(Object *ob, PointCache *cache, PTCacheMem **cur, int index, float t, ParticleKey *key1, ParticleKey *key2)
{
- static PTCacheMem *pm = NULL; /* not thread safe */
+ static PTCacheMem *pm = NULL;
if(index < 0) { /* initialize */
- pm = cache->mem_cache.first;
+ *cur = cache->mem_cache.first;
- if(pm)
- pm = pm->next;
+ if(*cur)
+ *cur = (*cur)->next;
}
else {
- if(pm) {
- while(pm && pm->next && (float)pm->frame < t)
- pm = pm->next;
+ if(*cur) {
+ while(*cur && (*cur)->next && (float)(*cur)->frame < t)
+ *cur = (*cur)->next;
+
+ pm = *cur;
BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame);
- BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] - 1 : index, pm->prev->data, (float)pm->prev->frame);
+ if(pm->prev->index_array && pm->prev->index_array[index] == 0)
+ copy_particle_key(key1, key2, 1);
+ else
+ BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] - 1 : index, pm->prev->data, (float)pm->prev->frame);
}
else if(cache->mem_cache.first) {
- PTCacheMem *pm2 = cache->mem_cache.first;
- BKE_ptcache_make_particle_key(key2, pm2->index_array ? pm2->index_array[index] - 1 : index, pm2->data, (float)pm2->frame);
+ pm = cache->mem_cache.first;
+ BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame);
copy_particle_key(key1, key2, 1);
}
}
}
+static int get_pointcache_times_for_particle(PointCache *cache, int index, float *start, float *end)
+{
+ PTCacheMem *pm;
+ int ret = 0;
+
+ for(pm=cache->mem_cache.first; pm; pm=pm->next) {
+ if(pm->index_array) {
+ if(pm->index_array[index]) {
+ *start = pm->frame;
+ ret++;
+ break;
+ }
+ }
+ else {
+ *start = pm->frame;
+ ret++;
+ break;
+ }
+ }
+
+ for(pm=cache->mem_cache.last; pm; pm=pm->prev) {
+ if(pm->index_array) {
+ if(pm->index_array[index]) {
+ *end = pm->frame;
+ ret++;
+ break;
+ }
+ }
+ else {
+ *end = pm->frame;
+ ret++;
+ break;
+ }
+ }
+
+ return ret == 2;
+}
static void init_particle_interpolation(Object *ob, ParticleSystem *psys, ParticleData *pa, ParticleInterpolationData *pind)
{
@@ -1091,10 +1135,15 @@ static void init_particle_interpolation(Object *ob, ParticleSystem *psys, Partic
pind->dietime = (key + pa->totkey - 1)->time;
}
else if(pind->cache) {
- get_pointcache_keys_for_time(ob, pind->cache, -1, 0.0f, NULL, NULL);
-
+ float start, end;
+ get_pointcache_keys_for_time(ob, pind->cache, &pind->pm, -1, 0.0f, NULL, NULL);
pind->birthtime = pa ? pa->time : pind->cache->startframe;
pind->dietime = pa ? pa->dietime : pind->cache->endframe;
+
+ if(get_pointcache_times_for_particle(pind->cache, pa - psys->particles, &start, &end)) {
+ pind->birthtime = MAX2(pind->birthtime, start);
+ pind->dietime = MIN2(pind->dietime, end);
+ }
}
else {
HairKey *key = pa->hair;
@@ -1224,7 +1273,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData
memcpy(keys + 2, pind->kkey[1], sizeof(ParticleKey));
}
else if(pind->cache) {
- get_pointcache_keys_for_time(NULL, pind->cache, p, real_t, keys+1, keys+2);
+ get_pointcache_keys_for_time(NULL, pind->cache, &pind->pm, p, real_t, keys+1, keys+2);
}
else {
hair_to_particle(keys + 1, pind->hkey[0]);
@@ -2672,7 +2721,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd
}
else {
/* clear out old and create new empty path cache */
- free_child_path_cache(sim->psys);
+ psys_free_child_path_cache(sim->psys);
sim->psys->childcache= psys_alloc_path_cache_buffers(&sim->psys->childcachebufs, totchild, ctx->steps+1);
sim->psys->totchildcache = totchild;
}
@@ -2743,7 +2792,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
int keyed, baked;
/* we don't have anything valid to create paths from so let's quit here */
- if((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED)==0)
+ if((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache)==0)
return;
if(psys_in_edit_mode(sim->scene, psys))
@@ -2753,7 +2802,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra)
BLI_srandom(psys->seed);
keyed = psys->flag & PSYS_KEYED;
- baked = !hair_dm && psys->pointcache->flag & PTCACHE_BAKED;
+ baked = !hair_dm && psys->pointcache->mem_cache.first;
/* clear out old and create new empty path cache */
psys_free_path_cache(psys, psys->edit);
@@ -3148,7 +3197,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf
edit->totcached = totpart;
- if(psys && psys->part->type == PART_HAIR) {
+ if(psys) {
ParticleSimulationData sim = {scene, ob, psys, psys_get_modifier(ob, psys), NULL};
psys_cache_child_paths(&sim, cfra, 1);
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 25328a06328..ce84ee96d01 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -3075,66 +3075,18 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo
/* Hair */
/************************************************/
/* check if path cache or children need updating and do it if needed */
-static void psys_update_path_cache(ParticleSimulationData *sim, float cfra)
+void psys_update_path_cache(ParticleSimulationData *sim, float cfra)
{
ParticleSystem *psys = sim->psys;
ParticleSettings *part = psys->part;
- ParticleEditSettings *pset = &sim->scene->toolsettings->particle;
- int distr=0, alloc=0, skip=0;
-
- if((psys->part->childtype && psys->totchild != get_psys_tot_child(sim->scene, psys)) || psys->recalc&PSYS_RECALC_RESET)
- alloc=1;
-
- if(alloc || psys->recalc&PSYS_RECALC_CHILD || (psys->vgroup[PSYS_VG_DENSITY] && (sim->ob && sim->ob->mode & OB_MODE_WEIGHT_PAINT)))
- distr=1;
-
- if(distr){
- if(alloc)
- realloc_particles(sim, sim->psys->totpart);
-
- if(get_psys_tot_child(sim->scene, psys)) {
- /* don't generate children while computing the hair keys */
- if(!(psys->part->type == PART_HAIR) || (psys->flag & PSYS_HAIR_DONE)) {
- distribute_particles(sim, PART_FROM_CHILD);
-
- if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES && part->parents!=0.0)
- psys_find_parents(sim);
- }
- }
- else
- psys_free_children(psys);
- }
-
- if((part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->flag & PTCACHE_BAKED)==0)
- skip = 1; /* only hair, keyed and baked stuff can have paths */
- else if(part->ren_as != PART_DRAW_PATH && !(part->type==PART_HAIR && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)))
- skip = 1; /* particle visualization must be set as path */
- else if(!psys->renderdata) {
- if(part->draw_as != PART_DRAW_REND)
- skip = 1; /* draw visualization */
- else if(psys->pointcache->flag & PTCACHE_BAKING)
- skip = 1; /* no need to cache paths while baking dynamics */
- else if(psys_in_edit_mode(sim->scene, psys)) {
- if((pset->flag & PE_DRAW_PART)==0)
- skip = 1;
- else if(part->childtype==0 && (psys->flag & PSYS_HAIR_DYNAMICS && psys->pointcache->flag & PTCACHE_BAKED)==0)
- skip = 1; /* in edit mode paths are needed for child particles and dynamic hair */
- }
- }
-
- if(!skip) {
+
+ /* only hair, keyed and baked stuff can have paths */
+ if(part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->mem_cache.first) {
psys_cache_paths(sim, cfra);
/* for render, child particle paths are computed on the fly */
- if(part->childtype) {
- if(!psys->totchild)
- skip = 1;
- else if((psys->part->type == PART_HAIR && psys->flag & PSYS_HAIR_DONE)==0)
- skip = 1;
-
- if(!skip)
- psys_cache_child_paths(sim, cfra, 0);
- }
+ if(part->childtype && psys->totchild)
+ psys_cache_child_paths(sim, cfra, 0);
}
else if(psys->pathcache)
psys_free_path_cache(psys, NULL);
@@ -3249,6 +3201,8 @@ static void do_hair_dynamics(ParticleSimulationData *sim)
psys->hair_out_dm = clothModifier_do(psys->clmd, sim->scene, sim->ob, dm, 0, 0);
psys->clmd->sim_parms->effector_weights = NULL;
+
+ psys_free_path_cache(psys, NULL);
}
static void hair_step(ParticleSimulationData *sim, float cfra)
{
@@ -3278,10 +3232,6 @@ static void hair_step(ParticleSimulationData *sim, float cfra)
if(psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS)
do_hair_dynamics(sim);
- psys_update_effectors(sim);
-
- psys_update_path_cache(sim, cfra);
-
psys->flag |= PSYS_HAIR_UPDATED;
}
@@ -3500,14 +3450,19 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra)
}
free_collider_cache(&sim->colliders);
+
+ if(psys->pathcache)
+ psys_free_path_cache(psys, NULL);
}
-static void update_children(ParticleSimulationData *sim)
+void psys_update_children(ParticleSimulationData *sim)
{
if((sim->psys->part->type == PART_HAIR) && (sim->psys->flag & PSYS_HAIR_DONE)==0)
/* don't generate children while growing hair - waste of time */
psys_free_children(sim->psys);
- else if(sim->psys->part->childtype && sim->psys->totchild != get_psys_tot_child(sim->scene, sim->psys))
- distribute_particles(sim, PART_FROM_CHILD);
+ else if(sim->psys->part->childtype) {
+ if(sim->psys->totchild != get_psys_tot_child(sim->scene, sim->psys))
+ distribute_particles(sim, PART_FROM_CHILD);
+ }
else
psys_free_children(sim->psys);
}
@@ -3762,8 +3717,6 @@ static void system_step(ParticleSimulationData *sim, float cfra)
if(ELEM(cache_result, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED)) {
cached_step(sim, cfra);
- update_children(sim);
- psys_update_path_cache(sim, cfra);
BKE_ptcache_validate(cache, framenr);
@@ -3827,9 +3780,6 @@ static void system_step(ParticleSimulationData *sim, float cfra)
BKE_ptcache_write_cache(use_cache, framenr);
}
- if(init)
- update_children(sim);
-
/* cleanup */
if(psys->lattice){
end_latt_deform(psys->lattice);
@@ -3992,6 +3942,13 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
/* execute drivers only, as animation has already been done */
BKE_animsys_evaluate_animdata(&part->id, part->adt, cfra, ADT_RECALC_DRIVERS);
+ /* TODO: only free child paths in case of PSYS_RECALC_CHILD */
+ if(psys->recalc & PSYS_RECALC)
+ psys_free_path_cache(psys, NULL);
+
+ if(psys->recalc & PSYS_RECALC_CHILD)
+ psys_free_children(psys);
+
if(psys->recalc & PSYS_RECALC_TYPE)
psys_changed_type(&sim);
else if(psys->recalc & PSYS_RECALC_PHYS)
@@ -4048,7 +4005,6 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
if(part->phystype == PART_PHYS_KEYED) {
psys_count_keyed_targets(&sim);
set_keyed_keys(&sim);
- psys_update_path_cache(&sim,(int)cfra);
}
break;
}
diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c
index 6a43251efdd..80904c1b1e7 100644
--- a/source/blender/blenkernel/intern/sca.c
+++ b/source/blender/blenkernel/intern/sca.c
@@ -44,6 +44,7 @@
#include "BKE_utildefines.h"
#include "BKE_global.h"
#include "BKE_main.h"
+#include "BKE_library.h"
/* ******************* SENSORS ************************ */
@@ -348,7 +349,19 @@ void unlink_actuators(ListBase *lb)
void free_actuator(bActuator *act)
{
- if(act->data) MEM_freeN(act->data);
+ bSoundActuator *sa;
+
+ if(act->data) {
+ switch (act->type) {
+ case ACT_SOUND:
+ sa = (bSoundActuator *) act->data;
+ if(sa->sound)
+ id_us_min((ID *) sa->sound);
+ break;
+ }
+
+ MEM_freeN(act->data);
+ }
MEM_freeN(act);
}
@@ -365,6 +378,7 @@ void free_actuators(ListBase *lb)
bActuator *copy_actuator(bActuator *act)
{
bActuator *actn;
+ bSoundActuator *sa;
act->mynew=actn= MEM_dupallocN(act);
actn->flag |= ACT_NEW;
@@ -372,6 +386,13 @@ bActuator *copy_actuator(bActuator *act)
actn->data= MEM_dupallocN(act->data);
}
+ switch (act->type) {
+ case ACT_SOUND:
+ sa= (bSoundActuator *)act->data;
+ if(sa->sound)
+ id_us_plus((ID *) sa->sound);
+ break;
+ }
return actn;
}