diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_global.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_multires.h | 6 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_utildefines.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/CMakeLists.txt | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/SConscript | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/Makefile | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim.c | 95 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 35 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/armature.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/image.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/packedFile.c | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 58 |
13 files changed, 176 insertions, 63 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_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 51d915cca18..0b3fce9408c 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -105,6 +105,7 @@ #define AVG2(x, y) ( 0.5 * ((x) + (y)) ) #define FTOCHAR(val) ((val)<=0.0f)? 0 : (((val)>(1.0f-0.5f/255.0f))? 255 : (char)((255.0f*(val))+0.5f)) +#define FTOUSHORT(val) ((val >= 1.0f-0.5f/65535)? 65535: (val <= 0.0f)? 0: (unsigned short)(val*65535.0f + 0.5f)) #define VECCOPY(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1); *(v1+2)= *(v2+2);} #define VECCOPY2D(v1,v2) {*(v1)= *(v2); *(v1+1)= *(v2+1);} diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 1ad0ddf0520..2086f4064d5 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 ac10889f36a..85d4934609d 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..313d79cf3b9 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -187,6 +187,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 +252,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 +390,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 +398,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 +413,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) { diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index a7a4d789610..10c2c1801cb 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -339,6 +339,19 @@ static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char *oldName, /* firstly, handle the F-Curve's own path */ if (fcu->rna_path) fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldName, newName, fcu->rna_path, verify_paths); + } +} + +/* Check RNA-Paths for a list of Drivers */ +static void drivers_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, char *oldKey, char *newKey, ListBase *curves, int verify_paths) +{ + FCurve *fcu; + + /* we need to check every curve - drivers are F-Curves too! */ + for (fcu= curves->first; fcu; fcu= fcu->next) { + /* firstly, handle the F-Curve's own path */ + if (fcu->rna_path) + fcu->rna_path= rna_path_rename_fix(owner_id, prefix, oldKey, newKey, fcu->rna_path, verify_paths); /* driver? */ if (fcu->driver) { @@ -352,15 +365,16 @@ static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char *oldName, { /* rename RNA path */ if (dtar->rna_path) - dtar->rna_path= rna_path_rename_fix(dtar->id, prefix, oldName, newName, dtar->rna_path, verify_paths); + dtar->rna_path= rna_path_rename_fix(dtar->id, prefix, oldKey, newKey, dtar->rna_path, verify_paths); /* also fix the bone-name (if applicable) */ - // XXX this has been disabled because the old/new names have padding which means this check will fail - //if ( ((dtar->id) && (GS(dtar->id->name) == ID_OB)) && - // (dtar->pchan_name[0]) && (strcmp(oldName, dtar->pchan_name)==0) ) - //{ - // BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name)); - //} + if (strstr(prefix, "bones")) { + if ( ((dtar->id) && (GS(dtar->id->name) == ID_OB)) && + (dtar->pchan_name[0]) && (strcmp(oldName, dtar->pchan_name)==0) ) + { + BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name)); + } + } } DRIVER_TARGETS_LOOPER_END } @@ -398,11 +412,12 @@ void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, c if (ELEM(NULL, owner_id, adt)) return; - if (oldName != NULL && newName != NULL) { + if ((oldName != NULL) && (newName != NULL)) { /* pad the names with [" "] so that only exact matches are made */ oldN= BLI_sprintfN("[\"%s\"]", oldName); newN= BLI_sprintfN("[\"%s\"]", newName); - } else { + } + else { oldN= BLI_sprintfN("[%d]", oldSubscript); newN= BLI_sprintfN("[%d]", newSubscript); } @@ -414,7 +429,7 @@ void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, c fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->tmpact->curves, verify_paths); /* Drivers - Drivers are really F-Curves */ - fcurves_path_rename_fix(owner_id, prefix, oldN, newN, &adt->drivers, verify_paths); + drivers_path_rename_fix(owner_id, prefix, oldName, newName, oldN, newN, &adt->drivers, verify_paths); /* NLA Data - Animation Data for Strips */ for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) 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/image.c b/source/blender/blenkernel/intern/image.c index eb478eaddf5..5588c8df161 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")) @@ -1187,12 +1189,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/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/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index fb973febf04..dc4a9ee3bdc 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -186,7 +186,7 @@ PackedFile *newPackedFile(ReportList *reports, char *filename) file= open(name, O_BINARY|O_RDONLY); if (file <= 0) { - BKE_reportf(reports, RPT_ERROR, "Can't open file: \"%s\"", name); + BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name); } else { filelen = BLI_filesize(file); @@ -216,15 +216,15 @@ void packAll(Main *bmain, ReportList *reports) bSound *sound; for(ima=bmain->image.first; ima; ima=ima->id.next) - if(ima->packedfile == NULL) + if(ima->packedfile == NULL && ima->id.lib==NULL && ELEM3(ima->type, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) ima->packedfile = newPackedFile(reports, ima->name); for(vf=bmain->vfont.first; vf; vf=vf->id.next) - if(vf->packedfile == NULL) + if(vf->packedfile == NULL && vf->id.lib==NULL) vf->packedfile = newPackedFile(reports, vf->name); for(sound=bmain->sound.first; sound; sound=sound->id.next) - if(sound->packedfile == NULL) + if(sound->packedfile == NULL && vf->id.lib==NULL) sound->packedfile = newPackedFile(reports, sound->name); } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 160f8a35520..cb596622431 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2366,8 +2366,12 @@ typedef struct { static void *ptcache_make_cache_thread(void *ptr) { ptcache_make_cache_data *data = (ptcache_make_cache_data*)ptr; - for(; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) + for(; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) { scene_update_for_newframe(data->scene, data->scene->lay); + if(G.background) { + printf("bake: frame %d :: %d\n", (int)*data->cfra_ptr, data->endframe); + } + } data->thread_ended = TRUE; return NULL; @@ -2489,36 +2493,40 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) thread_data.thread_ended = FALSE; old_progress = -1; - BLI_init_threads(&threads, ptcache_make_cache_thread, 1); - BLI_insert_thread(&threads, (void*)&thread_data); - - while (thread_data.thread_ended == FALSE) { + if(G.background) { + ptcache_make_cache_thread((void*)&thread_data); + } + else { + BLI_init_threads(&threads, ptcache_make_cache_thread, 1); + BLI_insert_thread(&threads, (void*)&thread_data); - if(bake) - progress = (int)(100.0f * (float)(CFRA - startframe)/(float)(thread_data.endframe-startframe)); - else - progress = CFRA; + while (thread_data.thread_ended == FALSE) { - /* NOTE: baking should not redraw whole ui as this slows things down */ - if ((baker->progressbar) && (progress != old_progress)) { - baker->progressbar(baker->progresscontext, progress); - old_progress = progress; - } - - /* Delay to lessen CPU load from UI thread */ - PIL_sleep_ms(200); + if(bake) + progress = (int)(100.0f * (float)(CFRA - startframe)/(float)(thread_data.endframe-startframe)); + else + progress = CFRA; + + /* NOTE: baking should not redraw whole ui as this slows things down */ + if ((baker->progressbar) && (progress != old_progress)) { + baker->progressbar(baker->progresscontext, progress); + old_progress = progress; + } + + /* Delay to lessen CPU load from UI thread */ + PIL_sleep_ms(200); - /* NOTE: breaking baking should leave calculated frames in cache, not clear it */ - if(blender_test_break() && !thread_data.break_operation) { - thread_data.break_operation = TRUE; - if (baker->progressend) - baker->progressend(baker->progresscontext); - WM_cursor_wait(1); + /* NOTE: breaking baking should leave calculated frames in cache, not clear it */ + if(blender_test_break() && !thread_data.break_operation) { + thread_data.break_operation = TRUE; + if (baker->progressend) + baker->progressend(baker->progresscontext); + WM_cursor_wait(1); + } } - } BLI_end_threads(&threads); - + } /* clear baking flag */ if(pid) { cache->flag &= ~(PTCACHE_BAKING|PTCACHE_REDO_NEEDED); |