From d94868f82138baedbd227c708878577061191bbe Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 16 Jul 2010 09:45:09 +0000 Subject: Incorrect flags were checing for cyclic in order clamping functions --- source/blender/blenkernel/intern/curve.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index aa7b44aecda..5015e0cef6c 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -3078,7 +3078,7 @@ int clamp_nurb_order_u( struct Nurb *nu ) nu->orderu= nu->pntsu; change= 1; } - if(((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { + if(((nu->flagu & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { CLAMP(nu->orderu, 3,4); change= 1; } @@ -3092,7 +3092,7 @@ int clamp_nurb_order_v( struct Nurb *nu) nu->orderv= nu->pntsv; change= 1; } - if(((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { + if(((nu->flagv & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { CLAMP(nu->orderv, 3,4); change= 1; } -- cgit v1.2.3 From 3ef41270f96b4ee3592ec5302a5383399c38ff5d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 16 Jul 2010 15:45:35 +0000 Subject: [#22880] SEQUENCER: Flip Y broken in recent builds (Windows & Linux) own fault when adding saturation. --- source/blender/blenkernel/intern/sequencer.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d97e6151a13..de4e7a5ccbe 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1800,6 +1800,10 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf if(seq->flag & SEQ_FLIPX) { IMB_flipx(se->ibuf); } + + if(seq->flag & SEQ_FLIPY) { + IMB_flipy(se->ibuf); + } if(seq->sat != 1.0f) { /* inline for now, could become an imbuf function */ @@ -2279,6 +2283,13 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int addzbuffloatImBuf(se->ibuf); memcpy(se->ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty); } + + /* { + ImBuf *imb= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); + IMB_saveiff(imb, "/tmp/foo.image", IB_rect | IB_metadata); + IMB_freeImBuf(imb); + } */ + } else if (rres.rect32) { se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0); memcpy(se->ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty); -- cgit v1.2.3 From 22c6b7d174ec7158acc526821b002d9703cf4f56 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Jul 2010 13:29:55 +0000 Subject: PNG Compression can now be set, writing uncompressed PNG's is significantly faster for high resolution images - 2k. --- source/blender/blenkernel/intern/image.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index b66b5c60916..ffd0b378f07 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1180,6 +1180,10 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt } else if (ELEM5(imtype, R_PNG, R_FFMPEG, R_H264, R_THEORA, R_XVID)) { ibuf->ftype= PNG; + + if(imtype==R_PNG) + ibuf->ftype |= quality; /* quality is actually compression 0-100 --> 0-9 */ + } #ifdef WITH_DDS else if ((imtype==R_DDS)) { -- cgit v1.2.3 From fd982af4471d55e756629c0aeffe60fe8f5b4687 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 17 Jul 2010 13:41:22 +0000 Subject: Merging revision 30434 from my GSoC branch, log: Fixed sound wave display bug for sounds that are not full length. --- source/blender/blenkernel/intern/sound.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 6402f908422..f780e71d5cd 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -468,7 +468,9 @@ int sound_scene_playing(struct Scene *scene) return -1; } -int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length) +int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length, float start, float end) { - return AUD_readSound(sound->cache, buffer, length); + AUD_Sound* limiter = AUD_limitSound(sound->cache, start, end); + return AUD_readSound(limiter, buffer, length); + AUD_unload(limiter); } -- cgit v1.2.3 From 02ef91a6195db38388b12ec9c643858ba1b5be7e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Jul 2010 16:17:30 +0000 Subject: [#22876] Add new scene, stacker ".00" bug finding duplicates is a bit faster now too since it doesnt split the name and number before comparing ID's prefix. --- source/blender/blenkernel/intern/library.c | 40 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 8d859a2f712..0cc31cc1cfa 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -995,7 +995,7 @@ void IMAnames_to_pupstring(char **str, char *title, char *extraops, ListBase *lb /* used by buttons.c library.c mball.c */ -void splitIDname(char *name, char *left, int *nr) +int splitIDname(char *name, char *left, int *nr) { int a; @@ -1003,19 +1003,21 @@ void splitIDname(char *name, char *left, int *nr) strncpy(left, name, 21); a= strlen(name); - if(a>1 && name[a-1]=='.') return; + if(a>1 && name[a-1]=='.') return a; while(a--) { if( name[a]=='.' ) { left[a]= 0; *nr= atol(name+a+1); - return; + return a; } if( isdigit(name[a])==0 ) break; left[a]= 0; } strcpy(left, name); + + return a; } static void sort_alpha_id(ListBase *lb, ID *id) @@ -1077,8 +1079,7 @@ static ID *is_dupid(ListBase *lb, ID *id, char *name) static int check_for_dupid(ListBase *lb, ID *id, char *name) { ID *idtest; - int nr= 0, nrtest, a; - const int maxtest=32; + int nr= 0, nrtest, a, left_len; char left[32], leftest[32], in_use[32]; /* make sure input name is terminated properly */ @@ -1095,22 +1096,25 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* we have a dup; need to make a new name */ /* quick check so we can reuse one of first 32 ids if vacant */ - memset(in_use, 0, maxtest); + memset(in_use, 0, sizeof(in_use)); /* get name portion, number portion ("name.number") */ - splitIDname( name, left, &nr); + left_len= splitIDname(name, left, &nr); /* if new name will be too long, truncate it */ if(nr>999 && strlen(left)>16) left[16]= 0; else if(strlen(left)>17) left[17]= 0; - for( idtest = lb->first; idtest; idtest = idtest->next ) { - if( id != idtest && idtest->lib == NULL ) { - splitIDname(idtest->name+2, leftest, &nrtest); - /* if base names match... */ - /* optimized */ - if( *left == *leftest && strcmp(left, leftest)==0 ) { - if(nrtest < maxtest) + if(left_len) { + for(idtest= lb->first; idtest; idtest= idtest->next) { + if( (id != idtest) && + (idtest->lib == NULL) && + (*name == *(idtest->name+2)) && + (strncmp(name, idtest->name+2, left_len)==0) && + (splitIDname(idtest->name+2, leftest, &nrtest) == left_len) + + ) { + if(nrtest < sizeof(in_use)) in_use[nrtest]= 1; /* mark as used */ if(nr <= nrtest) nr= nrtest+1; /* track largest unused */ @@ -1119,7 +1123,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) } /* decide which value of nr to use */ - for(a=0; a=nr) break; /* stop when we've check up to biggest */ if( in_use[a]==0 ) { /* found an unused value */ nr = a; @@ -1129,8 +1133,9 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* If the original name has no numeric suffix, * rather than just chopping and adding numbers, - * shave off the end chars until we have a unique name */ - if (nr==0) { + * shave off the end chars until we have a unique name. + * Check the null terminators match as well so we dont get Cube.000 -> Cube.00 */ + if (nr==0 && name[left_len] == left[left_len]) { int len = strlen(name)-1; idtest= is_dupid(lb, id, name); @@ -1389,4 +1394,3 @@ void rename_id(ID *id, char *name) new_id(lb, id, name); } - -- cgit v1.2.3 From 21cb1f82db01f9e0a69c955569cd6af4356b63e5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 17 Jul 2010 17:07:50 +0000 Subject: Revert part of commit 29079, cleanup of particle path drawing logic This commit and other commits attempting to fix it broke various things. The main thing that changed was that instead of computing children/paths in advance as part of particle_system_update, this was moved to do it just before drawing or rendering. I've changed back that behavior and tried to keep the other fixes in the commit. When the new particle system was just committed, it also worked this way but gave various problems, and I had to remove that behavior to get things working stable. Basically it meant that you could get have a path cache that was outdated in various situations, and it doesn't fit well with dependency graph evaluation order. This fixes: #22823: Children Particle Rendering is broken #22733: Particle objects not displayed #22888: SigSegV when rending hair particles #22820: Another SigSegV when undo adding hairs in particel edit mode Some particle setups in dupligroups. The three bugs that the original commit fixed are now also still working in my tests: #21316: Hair weight drawing is wrong #21923: Consistent Crash When Rendering Particle Scene. #21950: Path rendering option for particles causes crash --- source/blender/blenkernel/intern/particle.c | 8 +- source/blender/blenkernel/intern/particle_system.c | 86 ++++++++++++++++------ 2 files changed, 67 insertions(+), 27 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 96c0afedfb0..3791d808d01 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) } } } -void psys_free_child_path_cache(ParticleSystem *psys) +static void 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; - psys_free_child_path_cache(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; } - psys_free_child_path_cache(psys); + free_child_path_cache(psys); } void psys_free_particles(ParticleSystem *psys) { @@ -2721,7 +2721,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd } else { /* clear out old and create new empty path cache */ - psys_free_child_path_cache(sim->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; } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 33ea9f5ba6e..181d8fee4ba 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3075,18 +3075,66 @@ 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 */ -void psys_update_path_cache(ParticleSimulationData *sim, float cfra) +static void psys_update_path_cache(ParticleSimulationData *sim, float cfra) { ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; - - /* only hair, keyed and baked stuff can have paths */ - if(part->type==PART_HAIR || psys->flag&PSYS_KEYED || psys->pointcache->mem_cache.first) { + 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) { psys_cache_paths(sim, cfra); /* for render, child particle paths are computed on the fly */ - if(part->childtype && psys->totchild) - psys_cache_child_paths(sim, cfra, 0); + 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); + } } else if(psys->pathcache) psys_free_path_cache(psys, NULL); @@ -3201,8 +3249,6 @@ 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) { @@ -3454,19 +3500,14 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) } free_collider_cache(&sim->colliders); - - if(psys->pathcache) - psys_free_path_cache(psys, NULL); } -void psys_update_children(ParticleSimulationData *sim) +static void 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) { - if(sim->psys->totchild != get_psys_tot_child(sim->scene, sim->psys)) - distribute_particles(sim, PART_FROM_CHILD); - } + else if(sim->psys->part->childtype && sim->psys->totchild != get_psys_tot_child(sim->scene, sim->psys)) + distribute_particles(sim, PART_FROM_CHILD); else psys_free_children(sim->psys); } @@ -3721,6 +3762,8 @@ 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); @@ -3784,6 +3827,9 @@ 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); @@ -3946,13 +3992,6 @@ 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 || ob->recalc & OB_RECALC_ALL) - 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) @@ -4009,6 +4048,7 @@ 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; } -- cgit v1.2.3 From 1bb0c84236ec98647dabdd944d8575f32db33650 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Jul 2010 17:50:20 +0000 Subject: - added text3d.body_format to be able to set bold/italic/smallcaps etc on text. - the length of a new text object wasnt set on creation. - tex3d and controllers rna name was being set to its body (rather then ID name) - remove reference to wave objects which are very old and not used anymore. --- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/object.c | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 5015e0cef6c..d355a520a8c 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -148,7 +148,7 @@ Curve *add_curve(char *name, int type) cu->vfont->id.us+=4; cu->str= MEM_mallocN(12, "str"); strcpy(cu->str, "Text"); - cu->pos= 4; + cu->len= cu->pos= 4; cu->strinfo= MEM_callocN(12*sizeof(CharInfo), "strinfo new"); cu->totbox= cu->actbox= 1; cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "textbox"); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 012b38570da..75b5e6d9331 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -948,12 +948,6 @@ void free_lamp(Lamp *la) la->id.icon_id = 0; } -void *add_wave() -{ - return 0; -} - - /* *************************************************** */ static void *add_obdata_from_type(int type) @@ -967,7 +961,6 @@ static void *add_obdata_from_type(int type) case OB_CAMERA: return add_camera("Camera"); case OB_LAMP: return add_lamp("Lamp"); case OB_LATTICE: return add_lattice("Lattice"); - case OB_WAVE: return add_wave(); case OB_ARMATURE: return add_armature("Armature"); case OB_EMPTY: return NULL; default: @@ -987,7 +980,6 @@ static char *get_obdata_defname(int type) case OB_CAMERA: return "Camera"; case OB_LAMP: return "Lamp"; case OB_LATTICE: return "Lattice"; - case OB_WAVE: return "Wave"; case OB_ARMATURE: return "Armature"; case OB_EMPTY: return "Empty"; default: -- cgit v1.2.3 From fd31436897f49ddf6e51a059add2e74361fbfdd8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 17 Jul 2010 18:08:14 +0000 Subject: spelling correction: alredy --> already --- source/blender/blenkernel/intern/library.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 0cc31cc1cfa..8b035ff1bba 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1308,7 +1308,7 @@ void all_local(Library *lib, int untagged_only) /* The check on the second line (LIB_PRE_EXISTING) is done so its * possible to tag data you dont want to be made local, used for - * appending data, so any libdata alredy linked wont become local + * appending data, so any libdata already linked wont become local * (very nasty to discover all your links are lost after appending) * */ if(id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW) && -- cgit v1.2.3 From 7aebd561539140e2ae53b464536ba9aa43177795 Mon Sep 17 00:00:00 2001 From: Dalai Felinto Date: Sun, 18 Jul 2010 01:51:14 +0000 Subject: fixing small ambiguity in the logic brick link code (not sure it booms in any compiler, but it doesn't hurt to make it right) --- source/blender/blenkernel/intern/sca.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 61e98ce9d45..f5ca7ee3cef 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -800,7 +800,7 @@ void link_logicbricks(void **poin, void ***ppoin, short *tot, short size) (*tot) ++; *ppoin = MEM_callocN((*tot)*size, "new link"); - for (ibrick=0; ibrick < *tot - 1; ibrick++) { + for (ibrick=0; ibrick < *(tot) - 1; ibrick++) { (*ppoin)[ibrick] = old_links[ibrick]; } (*ppoin)[ibrick] = *poin; -- cgit v1.2.3 From acf3c4bb02c329f628f1314b0515db39cfdeebbf Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Mon, 19 Jul 2010 07:29:52 +0000 Subject: * decrementing image_icon ref count from wrong place --- source/blender/blenkernel/intern/brush.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index c423d426e32..c47f5a3ddba 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -131,7 +131,9 @@ Brush *copy_brush(Brush *brush) brushn= copy_libblock(brush); if(brush->mtex.tex) id_us_plus((ID*)brush->mtex.tex); - + + if(brush->image_icon) id_us_plus((ID*)brush->image_icon); + brushn->curve= curvemapping_copy(brush->curve); /* enable fake user by default */ -- cgit v1.2.3 From c7ce37471d8f7858735695ad92db1731fa2c1ae3 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Mon, 19 Jul 2010 20:01:18 +0000 Subject: == Sequencer == Bugfix: free_imbuf_seq() was closing IMB anim handles on nearly every change of RNA variables. This can be *very* slow, if you twiddle with parameters during playback. Especially multicam editing... Now: we close IMB anim handles only on refresh_all() and filepath changes. --- source/blender/blenkernel/intern/sequencer.c | 60 +++------------------------- 1 file changed, 5 insertions(+), 55 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index de4e7a5ccbe..f631e42e05a 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3267,59 +3267,8 @@ static void free_anim_seq(Sequence *seq) } } -#if 0 -static void free_imbuf_seq_except(Scene *scene, int cfra) -{ - Editing *ed= seq_give_editing(scene, FALSE); - Sequence *seq; - TStripElem *se; - int a; - - if(ed==NULL) return; - - SEQ_BEGIN(ed, seq) { - if(seq->strip) { - TStripElem * curelem = give_tstripelem(seq, cfra); - - for(a = 0, se = seq->strip->tstripdata; - a < seq->strip->len && se; a++, se++) { - if(se != curelem) { - free_imbuf_strip_elem(se); - } - } - for(a = 0, se = seq->strip->tstripdata_startstill; - a < seq->strip->startstill && se; a++, se++) { - if(se != curelem) { - free_imbuf_strip_elem(se); - } - } - for(a = 0, se = seq->strip->tstripdata_endstill; - a < seq->strip->endstill && se; a++, se++) { - if(se != curelem) { - free_imbuf_strip_elem(se); - } - } - if(seq->strip->ibuf_startstill) { - IMB_freeImBuf(seq->strip->ibuf_startstill); - seq->strip->ibuf_startstill = 0; - } - - if(seq->strip->ibuf_endstill) { - IMB_freeImBuf(seq->strip->ibuf_endstill); - seq->strip->ibuf_endstill = 0; - } - - if(seq->type==SEQ_MOVIE) - if(seq->startdisp > cfra || seq->enddisp < cfra) - free_anim_seq(seq); - free_proxy_seq(seq); - } - } - SEQ_END -} -#endif - -void free_imbuf_seq(Scene *scene, ListBase * seqbase, int check_mem_usage) +void free_imbuf_seq(Scene *scene, ListBase * seqbase, int check_mem_usage, + int keep_file_handles) { Sequence *seq; TStripElem *se; @@ -3374,14 +3323,15 @@ void free_imbuf_seq(Scene *scene, ListBase * seqbase, int check_mem_usage) seq->strip->ibuf_endstill = 0; } - if(seq->type==SEQ_MOVIE) + if(seq->type==SEQ_MOVIE && !keep_file_handles) free_anim_seq(seq); if(seq->type==SEQ_SPEED) { sequence_effect_speed_rebuild_map(scene, seq, 1); } } if(seq->type==SEQ_META) { - free_imbuf_seq(scene, &seq->seqbase, FALSE); + free_imbuf_seq(scene, &seq->seqbase, FALSE, + keep_file_handles); } if(seq->type==SEQ_SCENE) { /* FIXME: recurs downwards, -- cgit v1.2.3 From 80e63236464a7e864c45e163dd059ffe61735926 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Tue, 20 Jul 2010 02:18:10 +0000 Subject: * Images for brush icons are now reloaded when they are needed from an external file * First, try to load the file from the given filename. This is either absolute or relative to the current .blend * If file is found using the given filename directly then look for the file in the datafiles/brushicons directory (local, user, or system). * Note: This commit does not update the .blend to reference the default icons * Note: This commit does not make sure that the build system copies the default icons to the 2.52/datafiles/brushicons directory --- source/blender/blenkernel/intern/brush.c | 33 ++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index c47f5a3ddba..cea9ba32160 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -132,8 +132,6 @@ Brush *copy_brush(Brush *brush) if(brush->mtex.tex) id_us_plus((ID*)brush->mtex.tex); - if(brush->image_icon) id_us_plus((ID*)brush->image_icon); - brushn->curve= curvemapping_copy(brush->curve); /* enable fake user by default */ @@ -205,6 +203,37 @@ void make_local_brush(Brush *brush) } } +/* image icon function */ +Image* get_brush_icon(Brush *brush) +{ + + if (!(brush->image_icon) && brush->image_icon_path[0]) { + // first use the path directly to try and load the file + brush->image_icon= BKE_add_image_file(brush->image_icon_path, 1); + + // otherwise lets try to find it in other directories + if (!(brush->image_icon)) { + char path[240]; + char *folder; + + folder= BLI_get_folder(BLENDER_DATAFILES, "brushicons"); + + path[0] = 0; + + BLI_make_file_string(G.sce, path, folder, brush->image_icon_path); + + if (path[0]) + brush->image_icon= BKE_add_image_file(path, 1); + } + + // remove user count so image isn't saved on exit + if (brush->image_icon) + id_us_min((ID*)(brush->image_icon)); + } + + return brush->image_icon; +} + /* Library Operations */ int brush_set_nr(Brush **current_brush, int nr, const char *name) -- cgit v1.2.3 From 75410037fd0d5ec81ef24c70789b9a684ca86f3f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 20 Jul 2010 10:41:08 +0000 Subject: - correct some spelling errors. - remove FreeCamera struct (wasnt used) - remove world color alpha values (not used anywhre). --- source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/collision.c | 2 +- source/blender/blenkernel/intern/fmodifier.c | 2 +- source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/softbody.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 6c8e5c48745..228860c9287 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -301,7 +301,7 @@ void action_groups_add_channel (bAction *act, bActionGroup *agrp, FCurve *fcurve /* firstly, link this F-Curve to the group */ agrp->channels.first = agrp->channels.last = fcurve; - /* step through the groups preceeding this one, finding the F-Curve there to attach this one after */ + /* step through the groups preceding this one, finding the F-Curve there to attach this one after */ for (grp= agrp->prev; grp; grp= grp->prev) { /* if this group has F-Curves, we want weave the given one in right after the last channel there, * but via the Action's list not this group's list diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 9b49ac9c6ff..54adc648539 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -591,7 +591,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier return result; } -//Determines collisions on overlap, collisions are writen to collpair[i] and collision+number_collision_found is returned +//Determines collisions on overlap, collisions are written to collpair[i] and collision+number_collision_found is returned CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap *overlap, CollPair *collpair ) { ClothModifierData *clmd = ( ClothModifierData * ) md1; diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 6fcc49f9ec1..3271749643a 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -1193,7 +1193,7 @@ short list_has_suitable_fmodifier (ListBase *modifiers, int mtype, short acttype * - this step acts as an optimisation to prevent the F-Curve stack being evaluated * several times by modifiers requesting the time be modified, as the final result * would have required using the modified time - * - modifiers only ever recieve the unmodified time, as subsequent modifiers should be + * - modifiers only ever receive the unmodified time, as subsequent modifiers should be * working on the 'global' result of the modified curve, not some localised segment, * so nevaltime gets set to whatever the last time-modifying modifier likes... * - we start from the end of the stack, as only the last one matters for now diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index cd8ab8290e5..64c9bf4bd07 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -906,7 +906,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co *array_index= dummy_index; } - /* append preceeding bits to path */ + /* append preceding bits to path */ if ((actname && actname[0]) && (constname && constname[0])) { /* Constraint in Pose-Channel */ sprintf(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname); diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index b44fe1ad1d0..c82595ee2b2 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -251,7 +251,7 @@ static float _final_mass(Object *ob,BodyPoint *bp) /******************** for each target object/face the axis aligned bounding box (AABB) is stored -faces paralell to global axes +faces parallel to global axes so only simple "value" in [min,max] ckecks are used float operations still */ -- cgit v1.2.3 From b618a335f5e7b5b3d291aa0cba8be232b79e9a4e Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Tue, 20 Jul 2010 11:32:30 +0000 Subject: * Made the default sculpt icons an internal part of the executable * Default icons can be selected from a menu * Option to make a custom icon from a file is present but the UI is disabled because of a mysterious crash * New startup.blend that has the appropriate icons selected --- source/blender/blenkernel/intern/brush.c | 157 ++++++++++++++++++++++++++----- source/blender/blenkernel/intern/icons.c | 7 ++ 2 files changed, 141 insertions(+), 23 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index cea9ba32160..dcc96e65988 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -104,7 +104,7 @@ Brush *add_brush(const char *name) /* brush appearance */ - brush->image_icon= NULL; + brush->icon_imbuf= get_brush_icon(brush); brush->add_col[0]= 1.00; /* add mode color is light red */ brush->add_col[1]= 0.39; @@ -132,6 +132,8 @@ Brush *copy_brush(Brush *brush) if(brush->mtex.tex) id_us_plus((ID*)brush->mtex.tex); + IMB_refImBuf(brushn->icon_imbuf); + brushn->curve= curvemapping_copy(brush->curve); /* enable fake user by default */ @@ -146,7 +148,13 @@ Brush *copy_brush(Brush *brush) /* not brush itself */ void free_brush(Brush *brush) { - if(brush->mtex.tex) brush->mtex.tex->id.us--; + if (brush->mtex.tex) + brush->mtex.tex->id.us--; + + if (brush->icon==BRUSH_ICON_FILE && brush->icon_imbuf) + IMB_freeImBuf(brush->icon_imbuf); + + BKE_previewimg_free(&(brush->preview)); curvemapping_free(brush->curve); } @@ -176,7 +184,7 @@ void make_local_brush(Brush *brush) if(scene->id.lib) lib= 1; else local= 1; } - + if(local && lib==0) { brush->id.lib= 0; brush->id.flag= LIB_LOCAL; @@ -204,34 +212,137 @@ void make_local_brush(Brush *brush) } /* image icon function */ -Image* get_brush_icon(Brush *brush) +ImBuf* get_brush_icon(Brush *brush) { + extern char datatoc_blob_png; + extern char datatoc_clay_png; + extern char datatoc_crease_png; + extern char datatoc_draw_png; + extern char datatoc_fill_png; + extern char datatoc_flatten_png; + extern char datatoc_grab_png; + extern char datatoc_inflate_png; + extern char datatoc_layer_png; + extern char datatoc_nudge_png; + extern char datatoc_pinch_png; + extern char datatoc_scrape_png; + extern char datatoc_smooth_png; + extern char datatoc_snake_hook_png; + extern char datatoc_thumb_png; + extern char datatoc_twist_png; + + extern int datatoc_blob_png_size; + extern int datatoc_clay_png_size; + extern int datatoc_crease_png_size; + extern int datatoc_draw_png_size; + extern int datatoc_fill_png_size; + extern int datatoc_flatten_png_size; + extern int datatoc_grab_png_size; + extern int datatoc_inflate_png_size; + extern int datatoc_layer_png_size; + extern int datatoc_nudge_png_size; + extern int datatoc_pinch_png_size; + extern int datatoc_scrape_png_size; + extern int datatoc_smooth_png_size; + extern int datatoc_snake_hook_png_size; + extern int datatoc_thumb_png_size; + extern int datatoc_twist_png_size; + + void *icon_data[]= { + 0, + &datatoc_blob_png, + &datatoc_clay_png, + &datatoc_crease_png, + &datatoc_draw_png, + &datatoc_fill_png, + &datatoc_flatten_png, + &datatoc_grab_png, + &datatoc_inflate_png, + &datatoc_layer_png, + &datatoc_nudge_png, + &datatoc_pinch_png, + &datatoc_scrape_png, + &datatoc_smooth_png, + &datatoc_snake_hook_png, + &datatoc_thumb_png, + &datatoc_twist_png, + }; + + size_t icon_size[]= { + 0, + datatoc_blob_png_size, + datatoc_clay_png_size, + datatoc_crease_png_size, + datatoc_draw_png_size, + datatoc_fill_png_size, + datatoc_flatten_png_size, + datatoc_grab_png_size, + datatoc_inflate_png_size, + datatoc_layer_png_size, + datatoc_nudge_png_size, + datatoc_pinch_png_size, + datatoc_scrape_png_size, + datatoc_smooth_png_size, + datatoc_snake_hook_png_size, + datatoc_thumb_png_size, + datatoc_twist_png_size, + }; + + static ImBuf *icon_imbuf[BRUSH_ICON_COUNT]= { 0 }; + + static const int flags = IB_rect|IB_multilayer|IB_metadata; + + static const int default_icon = BRUSH_ICON_DRAW; + + char path[240]; + char *folder; + + if (!(brush->icon_imbuf)) { + if (brush->icon==BRUSH_ICON_FILE) { + + if (brush->icon_filepath[0]) { + // first use the path directly to try and load the file + + BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath)); + BLI_path_abs(path, G.sce); + + brush->icon_imbuf= IMB_loadiffname(path, flags); + + // otherwise lets try to find it in other directories + if (!(brush->icon_imbuf)) { + folder= BLI_get_folder(BLENDER_DATAFILES, "brushicons"); + + path[0]= 0; + + BLI_make_file_string(G.sce, path, folder, brush->icon_filepath); + + if (path[0]) + brush->icon_imbuf= IMB_loadiffname(path, flags); + } + } - if (!(brush->image_icon) && brush->image_icon_path[0]) { - // first use the path directly to try and load the file - brush->image_icon= BKE_add_image_file(brush->image_icon_path, 1); - - // otherwise lets try to find it in other directories - if (!(brush->image_icon)) { - char path[240]; - char *folder; - - folder= BLI_get_folder(BLENDER_DATAFILES, "brushicons"); - - path[0] = 0; + // if all else fails use a default image + if (!(brush->icon_imbuf)) { + if (!icon_imbuf[default_icon]) + icon_imbuf[default_icon]= IMB_ibImageFromMemory(icon_data[default_icon], icon_size[default_icon], flags); - BLI_make_file_string(G.sce, path, folder, brush->image_icon_path); + brush->icon_imbuf= icon_imbuf[default_icon]; + } + } + else { + if (!icon_imbuf[brush->icon]) + icon_imbuf[brush->icon]= IMB_ibImageFromMemory(icon_data[brush->icon], icon_size[brush->icon], flags); - if (path[0]) - brush->image_icon= BKE_add_image_file(path, 1); + brush->icon_imbuf= icon_imbuf[brush->icon]; } - // remove user count so image isn't saved on exit - if (brush->image_icon) - id_us_min((ID*)(brush->image_icon)); + BKE_icon_changed(BKE_icon_getid(&(brush->id))); } - return brush->image_icon; + if (!(brush->icon_imbuf)) + printf("get_brush_icon: unable to resolve brush icon imbuf\n"); + + return brush->icon_imbuf; } /* Library Operations */ diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index ad2c857be75..c1e00e091e8 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -177,6 +177,9 @@ void BKE_previewimg_free_id(ID *id) } else if (GS(id->name) == ID_IM) { Image *img = (Image*)id; BKE_previewimg_free(&img->preview); + } else if (GS(id->name) == ID_BR) { + Brush *br = (Brush*)br; + BKE_previewimg_free(&br->preview); } } @@ -204,6 +207,10 @@ PreviewImage* BKE_previewimg_get(ID *id) Image *img = (Image*)id; if (!img->preview) img->preview = BKE_previewimg_create(); prv_img = img->preview; + } else if (GS(id->name) == ID_BR) { + Brush *br = (Brush*)id; + if (!br->preview) br->preview = BKE_previewimg_create(); + prv_img = br->preview; } return prv_img; -- cgit v1.2.3 From f9e9e90a0293e4251528ceaaf7e7b000d7c05874 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Tue, 20 Jul 2010 12:22:45 +0000 Subject: == Sequencer == Cutting effect strips (esp multicam) didn't free endstill tstripdata. Doesn't sound like much of a problem, but those can get big on large timelines. So every cut eating 3 MB of memory doesn't leave much room for editing decisions :) --- source/blender/blenkernel/intern/sequencer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index f631e42e05a..94aa2c62f1a 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1142,7 +1142,7 @@ static TStripElem *give_tstripelem(Sequence *seq, int cfra) Strip * s = seq->strip; if (cfra < seq->start) { se = s->tstripdata_startstill; - if (seq->startstill > s->startstill) { + if (seq->startstill != s->startstill) { free_tstripdata(s->startstill, s->tstripdata_startstill); se = 0; @@ -1159,7 +1159,7 @@ static TStripElem *give_tstripelem(Sequence *seq, int cfra) } else if (cfra > seq->start + seq->len-1) { se = s->tstripdata_endstill; - if (seq->endstill > s->endstill) { + if (seq->endstill != s->endstill) { free_tstripdata(s->endstill, s->tstripdata_endstill); se = 0; -- cgit v1.2.3 From 886ce5a35101ea8bfef9c02745a94b1ab017f12f Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Tue, 20 Jul 2010 13:42:27 +0000 Subject: * can use file for brush icon * fixed memory leaks * moved some of the brush icon code around * the update of the icon after a change is more responsive --- source/blender/blenkernel/intern/brush.c | 144 ++----------------------------- 1 file changed, 5 insertions(+), 139 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index dcc96e65988..8e3cc0751b5 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -104,8 +104,6 @@ Brush *add_brush(const char *name) /* brush appearance */ - brush->icon_imbuf= get_brush_icon(brush); - brush->add_col[0]= 1.00; /* add mode color is light red */ brush->add_col[1]= 0.39; brush->add_col[2]= 0.39; @@ -130,9 +128,11 @@ Brush *copy_brush(Brush *brush) brushn= copy_libblock(brush); - if(brush->mtex.tex) id_us_plus((ID*)brush->mtex.tex); + if (brush->mtex.tex) + id_us_plus((ID*)brush->mtex.tex); - IMB_refImBuf(brushn->icon_imbuf); + if (brush->icon_imbuf) + brushn->icon_imbuf= IMB_dupImBuf(brush->icon_imbuf); brushn->curve= curvemapping_copy(brush->curve); @@ -151,7 +151,7 @@ void free_brush(Brush *brush) if (brush->mtex.tex) brush->mtex.tex->id.us--; - if (brush->icon==BRUSH_ICON_FILE && brush->icon_imbuf) + if (brush->icon_imbuf) IMB_freeImBuf(brush->icon_imbuf); BKE_previewimg_free(&(brush->preview)); @@ -211,140 +211,6 @@ void make_local_brush(Brush *brush) } } -/* image icon function */ -ImBuf* get_brush_icon(Brush *brush) -{ - extern char datatoc_blob_png; - extern char datatoc_clay_png; - extern char datatoc_crease_png; - extern char datatoc_draw_png; - extern char datatoc_fill_png; - extern char datatoc_flatten_png; - extern char datatoc_grab_png; - extern char datatoc_inflate_png; - extern char datatoc_layer_png; - extern char datatoc_nudge_png; - extern char datatoc_pinch_png; - extern char datatoc_scrape_png; - extern char datatoc_smooth_png; - extern char datatoc_snake_hook_png; - extern char datatoc_thumb_png; - extern char datatoc_twist_png; - - extern int datatoc_blob_png_size; - extern int datatoc_clay_png_size; - extern int datatoc_crease_png_size; - extern int datatoc_draw_png_size; - extern int datatoc_fill_png_size; - extern int datatoc_flatten_png_size; - extern int datatoc_grab_png_size; - extern int datatoc_inflate_png_size; - extern int datatoc_layer_png_size; - extern int datatoc_nudge_png_size; - extern int datatoc_pinch_png_size; - extern int datatoc_scrape_png_size; - extern int datatoc_smooth_png_size; - extern int datatoc_snake_hook_png_size; - extern int datatoc_thumb_png_size; - extern int datatoc_twist_png_size; - - void *icon_data[]= { - 0, - &datatoc_blob_png, - &datatoc_clay_png, - &datatoc_crease_png, - &datatoc_draw_png, - &datatoc_fill_png, - &datatoc_flatten_png, - &datatoc_grab_png, - &datatoc_inflate_png, - &datatoc_layer_png, - &datatoc_nudge_png, - &datatoc_pinch_png, - &datatoc_scrape_png, - &datatoc_smooth_png, - &datatoc_snake_hook_png, - &datatoc_thumb_png, - &datatoc_twist_png, - }; - - size_t icon_size[]= { - 0, - datatoc_blob_png_size, - datatoc_clay_png_size, - datatoc_crease_png_size, - datatoc_draw_png_size, - datatoc_fill_png_size, - datatoc_flatten_png_size, - datatoc_grab_png_size, - datatoc_inflate_png_size, - datatoc_layer_png_size, - datatoc_nudge_png_size, - datatoc_pinch_png_size, - datatoc_scrape_png_size, - datatoc_smooth_png_size, - datatoc_snake_hook_png_size, - datatoc_thumb_png_size, - datatoc_twist_png_size, - }; - - static ImBuf *icon_imbuf[BRUSH_ICON_COUNT]= { 0 }; - - static const int flags = IB_rect|IB_multilayer|IB_metadata; - - static const int default_icon = BRUSH_ICON_DRAW; - - char path[240]; - char *folder; - - if (!(brush->icon_imbuf)) { - if (brush->icon==BRUSH_ICON_FILE) { - - if (brush->icon_filepath[0]) { - // first use the path directly to try and load the file - - BLI_strncpy(path, brush->icon_filepath, sizeof(brush->icon_filepath)); - BLI_path_abs(path, G.sce); - - brush->icon_imbuf= IMB_loadiffname(path, flags); - - // otherwise lets try to find it in other directories - if (!(brush->icon_imbuf)) { - folder= BLI_get_folder(BLENDER_DATAFILES, "brushicons"); - - path[0]= 0; - - BLI_make_file_string(G.sce, path, folder, brush->icon_filepath); - - if (path[0]) - brush->icon_imbuf= IMB_loadiffname(path, flags); - } - } - - // if all else fails use a default image - if (!(brush->icon_imbuf)) { - if (!icon_imbuf[default_icon]) - icon_imbuf[default_icon]= IMB_ibImageFromMemory(icon_data[default_icon], icon_size[default_icon], flags); - - brush->icon_imbuf= icon_imbuf[default_icon]; - } - } - else { - if (!icon_imbuf[brush->icon]) - icon_imbuf[brush->icon]= IMB_ibImageFromMemory(icon_data[brush->icon], icon_size[brush->icon], flags); - - brush->icon_imbuf= icon_imbuf[brush->icon]; - } - - BKE_icon_changed(BKE_icon_getid(&(brush->id))); - } - - if (!(brush->icon_imbuf)) - printf("get_brush_icon: unable to resolve brush icon imbuf\n"); - - return brush->icon_imbuf; -} - /* Library Operations */ int brush_set_nr(Brush **current_brush, int nr, const char *name) -- cgit v1.2.3 From d17ce0f148d5cb5d11cc3b1591b397865f3fb641 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Wed, 21 Jul 2010 07:55:53 +0000 Subject: Merging revision 30567 from my GSoC branch, log: Fix for sound not possible to load when file unsaved. --- source/blender/blenkernel/intern/sound.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index f780e71d5cd..ca39355976b 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -122,10 +122,15 @@ struct bSound* sound_new_file(struct Main *bmain, char* filename) bSound* sound = NULL; char str[FILE_MAX]; + char *path; + int len; strcpy(str, filename); - BLI_path_abs(str, bmain->name); + + path = /*bmain ? bmain->name :*/ G.sce; + + BLI_path_abs(str, path); len = strlen(filename); while(len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') @@ -258,7 +263,7 @@ void sound_load(struct Main *bmain, struct bSound* sound) if(sound->id.lib) path = sound->id.lib->filepath; else - path = bmain ? bmain->name : G.sce; + path = /*bmain ? bmain->name :*/ G.sce; BLI_path_abs(fullpath, path); -- cgit v1.2.3 From edeef8bcd7af488bb11f03464d0bce7757eefcf8 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Jul 2010 10:39:51 +0000 Subject: Revert revision 30441: [#22876] Add new scene, stacker ".00" bug This commit broke unique datablock naming, tried to fix it properly but the code here is too tricky to change now, will just reopen the bug report. --- source/blender/blenkernel/intern/library.c | 40 ++++++++++++++---------------- 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 8b035ff1bba..fdc98d9ed29 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -995,7 +995,7 @@ void IMAnames_to_pupstring(char **str, char *title, char *extraops, ListBase *lb /* used by buttons.c library.c mball.c */ -int splitIDname(char *name, char *left, int *nr) +void splitIDname(char *name, char *left, int *nr) { int a; @@ -1003,21 +1003,19 @@ int splitIDname(char *name, char *left, int *nr) strncpy(left, name, 21); a= strlen(name); - if(a>1 && name[a-1]=='.') return a; + if(a>1 && name[a-1]=='.') return; while(a--) { if( name[a]=='.' ) { left[a]= 0; *nr= atol(name+a+1); - return a; + return; } if( isdigit(name[a])==0 ) break; left[a]= 0; } strcpy(left, name); - - return a; } static void sort_alpha_id(ListBase *lb, ID *id) @@ -1079,7 +1077,8 @@ static ID *is_dupid(ListBase *lb, ID *id, char *name) static int check_for_dupid(ListBase *lb, ID *id, char *name) { ID *idtest; - int nr= 0, nrtest, a, left_len; + int nr= 0, nrtest, a; + const int maxtest=32; char left[32], leftest[32], in_use[32]; /* make sure input name is terminated properly */ @@ -1096,25 +1095,22 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* we have a dup; need to make a new name */ /* quick check so we can reuse one of first 32 ids if vacant */ - memset(in_use, 0, sizeof(in_use)); + memset(in_use, 0, maxtest); /* get name portion, number portion ("name.number") */ - left_len= splitIDname(name, left, &nr); + splitIDname( name, left, &nr); /* if new name will be too long, truncate it */ if(nr>999 && strlen(left)>16) left[16]= 0; else if(strlen(left)>17) left[17]= 0; - if(left_len) { - for(idtest= lb->first; idtest; idtest= idtest->next) { - if( (id != idtest) && - (idtest->lib == NULL) && - (*name == *(idtest->name+2)) && - (strncmp(name, idtest->name+2, left_len)==0) && - (splitIDname(idtest->name+2, leftest, &nrtest) == left_len) - - ) { - if(nrtest < sizeof(in_use)) + for( idtest = lb->first; idtest; idtest = idtest->next ) { + if( id != idtest && idtest->lib == NULL ) { + splitIDname(idtest->name+2, leftest, &nrtest); + /* if base names match... */ + /* optimized */ + if( *left == *leftest && strcmp(left, leftest)==0 ) { + if(nrtest < maxtest) in_use[nrtest]= 1; /* mark as used */ if(nr <= nrtest) nr= nrtest+1; /* track largest unused */ @@ -1123,7 +1119,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) } /* decide which value of nr to use */ - for(a=0; a < sizeof(in_use); a++) { + for(a=0; a=nr) break; /* stop when we've check up to biggest */ if( in_use[a]==0 ) { /* found an unused value */ nr = a; @@ -1133,9 +1129,8 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* If the original name has no numeric suffix, * rather than just chopping and adding numbers, - * shave off the end chars until we have a unique name. - * Check the null terminators match as well so we dont get Cube.000 -> Cube.00 */ - if (nr==0 && name[left_len] == left[left_len]) { + * shave off the end chars until we have a unique name */ + if (nr==0) { int len = strlen(name)-1; idtest= is_dupid(lb, id, name); @@ -1394,3 +1389,4 @@ void rename_id(ID *id, char *name) new_id(lb, id, name); } + -- cgit v1.2.3 From b72af8c09a37854fa71f26b3d929cda41e003e44 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Jul 2010 15:58:15 +0000 Subject: Fix #20983: cloth and smoke point cache step was not enforced to 1. --- source/blender/blenkernel/intern/cloth.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index ce5bca1da56..b9b1c16c0c4 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -144,6 +144,9 @@ void cloth_init ( ClothModifierData *clmd ) if(!clmd->sim_parms->effector_weights) clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL); + + if(clmd->point_cache) + clmd->point_cache->step = 1; } static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float epsilon) -- cgit v1.2.3 From 4536a4c6104085f39fe8fcd1c27f37caa3cd8950 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 21 Jul 2010 16:20:54 +0000 Subject: Fix #22841: crash rendering scene with opengl in sequencer as part of animation. Only allow this from main thread, opengl can't be called from render threads. It was already disabled in background mode. For now I'm going to consider this a limitation. --- source/blender/blenkernel/intern/sequencer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 94aa2c62f1a..61415eb4a52 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -55,6 +55,7 @@ #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_string.h" +#include "BLI_threads.h" #include #include "IMB_imbuf.h" @@ -2258,7 +2259,7 @@ static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int seq->scene->markers.first= seq->scene->markers.last= NULL; #endif - if(sequencer_view3d_cb && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) { + if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) { /* opengl offscreen render */ scene_update_for_newframe(seq->scene, seq->scene->lay); se->ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, scene->r.seq_prev_type); -- cgit v1.2.3 From 3b5b761a56424987790bd1aad6fcb9ac1f0a281b Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Thu, 22 Jul 2010 18:56:46 +0000 Subject: == Sculpt/Paint Fixes == * Fix: unify strength and size did work consistently with other paint modes * Fix: If [ and ] keys were used to resize a brush it was not possible to increase the size of the brush if it went under 10 pixels * Fix: Made interpretation of brush size consistent across all modes, Texture/Image paint interpreted brush size as the diameter while all the other modes interpret it as radius * Fix: The default spacing for vertex paint brushes was 3%, should be 10% * Fix: due to fixes to unified strength, re-enabled 'Unify Size' by default * Fix: Unified size and strength were stored in UserPrefs, moved this to ToolSettings * Fix: The setting of pressure sensitivity was not unified when strength or size were unified. Now the appropriate pressure sensitivity setting is also unified across all brushes when corresponding unification option is selected * Fix: When using [ and ] to resize the brush it didn't immediately redraw * Fix: fkey resizing/"re-strength-ing" was not working consistently accross all paint modes due to only sculpt mode having full support for unified size and strength, now it works properly. * Fix: other paint modes did expose the ability to have a custom brush colors, so I added the small bit of code to allow it. Note: I made all of the other paint mode brushes white. Note2: Actually, probably want to make the paint modes use the selected color for painting instead of a constant brush color. * I had removed OPTYPE_REGISTER from some Sculpt/Paint operators but in this commit I add them back. I'm not completely sure what this option does so I don't want to disturb it for now. --- source/blender/blenkernel/intern/brush.c | 348 +++++++++++++++++++++++++++---- 1 file changed, 302 insertions(+), 46 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 8e3cc0751b5..ac600f7ef4e 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -38,6 +38,7 @@ #include "DNA_windowmanager_types.h" #include "WM_types.h" +#include "WM_api.h" #include "RNA_access.h" @@ -357,9 +358,10 @@ void brush_sample_tex(Brush *brush, float *xy, float *rgba) if (mtex && mtex->tex) { float co[3], tin, tr, tg, tb, ta; int hasrgb; - - co[0]= xy[0]/(brush->size >> 1); - co[1]= xy[1]/(brush->size >> 1); + const int radius= brush_size(brush); + + co[0]= xy[0]/radius; + co[1]= xy[1]/radius; co[2]= 0.0f; hasrgb= externtex(mtex, co, &tin, &tr, &tg, &tb, &ta); @@ -382,23 +384,24 @@ void brush_sample_tex(Brush *brush, float *xy, float *rgba) } -void brush_imbuf_new(Brush *brush, short flt, short texfall, int size, ImBuf **outbuf) +void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf **outbuf) { ImBuf *ibuf; float xy[2], dist, rgba[4], *dstf; int x, y, rowbytes, xoff, yoff, imbflag; - int maxsize = brush->size >> 1; + const int radius= brush_size(brush); char *dst, crgb[3]; + const float alpha= brush_alpha(brush); imbflag= (flt)? IB_rectfloat: IB_rect; - xoff = -size/2.0f + 0.5f; - yoff = -size/2.0f + 0.5f; - rowbytes= size*4; + xoff = -bufsize/2.0f + 0.5f; + yoff = -bufsize/2.0f + 0.5f; + rowbytes= bufsize*4; if (*outbuf) ibuf= *outbuf; else - ibuf= IMB_allocImBuf(size, size, 32, imbflag, 0); + ibuf= IMB_allocImBuf(bufsize, bufsize, 32, imbflag, 0); if (flt) { for (y=0; y < ibuf->y; y++) { @@ -412,7 +415,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int size, ImBuf **o dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]); VECCOPY(dstf, brush->rgb); - dstf[3]= brush->alpha*brush_curve_strength_clamp(brush, dist, maxsize); + dstf[3]= alpha*brush_curve_strength_clamp(brush, dist, radius); } else if (texfall == 1) { brush_sample_tex(brush, xy, dstf); @@ -425,7 +428,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int size, ImBuf **o dstf[0] = rgba[0]*brush->rgb[0]; dstf[1] = rgba[1]*brush->rgb[1]; dstf[2] = rgba[2]*brush->rgb[2]; - dstf[3] = rgba[3]*brush->alpha*brush_curve_strength_clamp(brush, dist, maxsize); + dstf[3] = rgba[3]*alpha*brush_curve_strength_clamp(brush, dist, radius); } } } @@ -448,7 +451,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int size, ImBuf **o dst[0]= crgb[0]; dst[1]= crgb[1]; dst[2]= crgb[2]; - dst[3]= FTOCHAR(brush->alpha*brush_curve_strength(brush, dist, maxsize)); + dst[3]= FTOCHAR(alpha*brush_curve_strength(brush, dist, radius)); } else if (texfall == 1) { brush_sample_tex(brush, xy, rgba); @@ -464,7 +467,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int size, ImBuf **o dst[0] = FTOCHAR(rgba[0]*brush->rgb[0]); dst[1] = FTOCHAR(rgba[1]*brush->rgb[1]); dst[2] = FTOCHAR(rgba[2]*brush->rgb[2]); - dst[3] = FTOCHAR(rgba[3]*brush->alpha*brush_curve_strength_clamp(brush, dist, maxsize)); + dst[3] = FTOCHAR(rgba[3]*alpha*brush_curve_strength_clamp(brush, dist, radius)); } } } @@ -478,7 +481,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int size, ImBuf **o typedef struct BrushPainterCache { short enabled; - int size; /* size override, if 0 uses brush->size */ + int size; /* size override, if 0 uses brush_size(brush) */ short flt; /* need float imbuf? */ short texonly; /* no alpha, color or fallof, only texture in imbuf */ @@ -523,8 +526,8 @@ BrushPainter *brush_painter_new(Brush *brush) painter->firsttouch= 1; painter->cache.lastsize= -1; /* force ibuf create in refresh */ - painter->startsize = brush->size; - painter->startalpha = brush->alpha; + painter->startsize = brush_size(brush); + painter->startalpha = brush_alpha(brush); painter->startjitter = brush->jitter; painter->startspacing = brush->spacing; @@ -557,8 +560,8 @@ void brush_painter_free(BrushPainter *painter) { Brush *brush = painter->brush; - brush->size = painter->startsize; - brush->alpha = painter->startalpha; + brush_set_size(brush, painter->startsize); + brush_set_alpha(brush, painter->startalpha); brush->jitter = painter->startjitter; brush->spacing = painter->startspacing; @@ -575,9 +578,10 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i float *bf, *mf, *tf, *otf=NULL, xoff, yoff, xy[2], rgba[4]; char *b, *m, *t, *ot= NULL; int dotexold, origx= x, origy= y; + const int radius= brush_size(brush); - xoff = -brush->size/2.0f + 0.5f; - yoff = -brush->size/2.0f + 0.5f; + xoff = -radius + 0.5f; + yoff = -radius + 0.5f; xoff += (int)pos[0] - (int)painter->startpaintpos[0]; yoff += (int)pos[1] - (int)painter->startpaintpos[1]; @@ -659,14 +663,15 @@ static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, float BrushPainterCache *cache= &painter->cache; ImBuf *oldtexibuf, *ibuf; int imbflag, destx, desty, srcx, srcy, w, h, x1, y1, x2, y2; + const int diameter= 2*brush_size(brush); imbflag= (cache->flt)? IB_rectfloat: IB_rect; if (!cache->ibuf) - cache->ibuf= IMB_allocImBuf(brush->size, brush->size, 32, imbflag, 0); + cache->ibuf= IMB_allocImBuf(diameter, diameter, 32, imbflag, 0); ibuf= cache->ibuf; oldtexibuf= cache->texibuf; - cache->texibuf= IMB_allocImBuf(brush->size, brush->size, 32, imbflag, 0); + cache->texibuf= IMB_allocImBuf(diameter, diameter, 32, imbflag, 0); if (oldtexibuf) { srcx= srcy= 0; @@ -713,9 +718,13 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos) MTex *mtex= &brush->mtex; int size; short flt; + const int radius= brush_size(brush); + const float alpha= brush_alpha(brush); - if ((brush->size != cache->lastsize) || (brush->alpha != cache->lastalpha) - || (brush->jitter != cache->lastjitter)) { + if (radius != cache->lastsize || + alpha != cache->lastalpha || + brush->jitter != cache->lastjitter) + { if (cache->ibuf) { IMB_freeImBuf(cache->ibuf); cache->ibuf= NULL; @@ -726,7 +735,7 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos) } flt= cache->flt; - size= (cache->size)? cache->size: brush->size; + size= (cache->size)? cache->size: radius; if (!(mtex && mtex->tex) || (mtex->tex->type==0)) { brush_imbuf_new(brush, flt, 0, size, &cache->ibuf); @@ -738,8 +747,8 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos) else brush_imbuf_new(brush, flt, 2, size, &cache->ibuf); - cache->lastsize= brush->size; - cache->lastalpha= brush->alpha; + cache->lastsize= radius; + cache->lastalpha= alpha; cache->lastjitter= brush->jitter; } else if ((brush->flag & BRUSH_FIXED_TEX) && mtex && mtex->tex) { @@ -758,10 +767,10 @@ void brush_painter_break_stroke(BrushPainter *painter) static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pressure) { - if (brush->flag & BRUSH_ALPHA_PRESSURE) - brush->alpha = MAX2(0.0, painter->startalpha*pressure); - if (brush->flag & BRUSH_SIZE_PRESSURE) - brush->size = MAX2(1.0, painter->startsize*pressure); + if (brush_use_alpha_pressure(brush)) + brush_set_alpha(brush, MAX2(0.0, painter->startalpha*pressure)); + if (brush_use_size_pressure(brush)) + brush_set_size(brush, MAX2(1.0, painter->startsize*pressure)); if (brush->flag & BRUSH_JITTER_PRESSURE) brush->jitter = MAX2(0.0, painter->startjitter*pressure); if (brush->flag & BRUSH_SPACING_PRESSURE) @@ -772,6 +781,7 @@ void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos) { if(brush->jitter){ float rand_pos[2]; + const int radius= brush_size(brush); // find random position within a circle of diameter 1 do { @@ -779,8 +789,8 @@ void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos) rand_pos[1] = BLI_frand()-0.5f; } while (len_v2(rand_pos) > 0.5f); - jitterpos[0] = pos[0] + 2*rand_pos[0]*brush->size*brush->jitter; - jitterpos[1] = pos[1] + 2*rand_pos[1]*brush->size*brush->jitter; + jitterpos[0] = pos[0] + 2*rand_pos[0]*radius*brush->jitter; + jitterpos[1] = pos[1] + 2*rand_pos[1]*radius*brush->jitter; } else { VECCOPY2D(jitterpos, pos); @@ -819,7 +829,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl double starttime, curtime= time; /* compute brush spacing adapted to brush size */ - spacing= brush->rate; //brush->size*brush->spacing*0.01f; + spacing= brush->rate; //brush_size(brush)*brush->spacing*0.01f; /* setup starting time, direction vector and accumulated time */ starttime= painter->accumtime; @@ -850,11 +860,12 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl else { float startdistance, spacing, step, paintpos[2], dmousepos[2], finalpos[2]; float t, len, press; + const int radius= brush_size(brush); - /* compute brush spacing adapted to brush size, spacing may depend + /* compute brush spacing adapted to brush radius, spacing may depend on pressure, so update it */ brush_apply_pressure(painter, brush, painter->lastpressure); - spacing= MAX2(1.0f, brush->size)*brush->spacing*0.01f; + spacing= MAX2(1.0f, radius)*brush->spacing*0.01f; /* setup starting distance, direction vector and accumulated distance */ startdistance= painter->accumdistance; @@ -871,7 +882,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl t = step/len; press= (1.0f-t)*painter->lastpressure + t*pressure; brush_apply_pressure(painter, brush, press); - spacing= MAX2(1.0f, brush->size)*brush->spacing*0.01f; + spacing= MAX2(1.0f, radius)*brush->spacing*0.01f; brush_jitter_pos(brush, paintpos, finalpos); @@ -921,8 +932,8 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl painter->lastmousepos[1]= pos[1]; painter->lastpressure= pressure; - brush->alpha = painter->startalpha; - brush->size = painter->startsize; + brush_set_alpha(brush, painter->startalpha); + brush_set_size(brush, painter->startsize); brush->jitter = painter->startjitter; brush->spacing = painter->startspacing; @@ -1041,9 +1052,9 @@ void brush_radial_control_invoke(wmOperator *op, Brush *br, float size_weight) float original_value= 0; if(mode == WM_RADIALCONTROL_SIZE) - original_value = sculpt_get_brush_size(br) * size_weight; + original_value = brush_size(br) * size_weight; else if(mode == WM_RADIALCONTROL_STRENGTH) - original_value = sculpt_get_brush_alpha(br); + original_value = brush_alpha(br); else if(mode == WM_RADIALCONTROL_ANGLE) { MTex *mtex = brush_active_texture(br); if(mtex) @@ -1061,15 +1072,15 @@ int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight) const float conv = 0.017453293; if(mode == WM_RADIALCONTROL_SIZE) - if (sculpt_get_lock_brush_size(br)) { + if (brush_use_locked_size(br)) { float initial_value = RNA_float_get(op->ptr, "initial_value"); - const float unprojected_radius = sculpt_get_brush_unprojected_radius(br); - sculpt_set_brush_unprojected_radius(br, unprojected_radius * new_value/initial_value * size_weight); + const float unprojected_radius = brush_unprojected_radius(br); + brush_set_unprojected_radius(br, unprojected_radius * new_value/initial_value * size_weight); } else - sculpt_set_brush_size(br, new_value * size_weight); + brush_set_size(br, new_value * size_weight); else if(mode == WM_RADIALCONTROL_STRENGTH) - sculpt_set_brush_alpha(br, new_value); + brush_set_alpha(br, new_value); else if(mode == WM_RADIALCONTROL_ANGLE) { MTex *mtex = brush_active_texture(br); if(mtex) @@ -1078,3 +1089,248 @@ int brush_radial_control_exec(wmOperator *op, Brush *br, float size_weight) return OPERATOR_FINISHED; } + +/* Unified Size and Strength */ + +static void set_unified_settings(Brush *brush, short flag, int value) +{ + Scene *sce; + for (sce= G.main->scene.first; sce; sce= sce->id.next) { + if (sce->toolsettings && + ELEM4(brush, + paint_brush(&(sce->toolsettings->imapaint.paint)), + paint_brush(&(sce->toolsettings->vpaint->paint)), + paint_brush(&(sce->toolsettings->wpaint->paint)), + paint_brush(&(sce->toolsettings->sculpt->paint)))) + { + if (value) + sce->toolsettings->sculpt_paint_settings |= flag; + else + sce->toolsettings->sculpt_paint_settings &= ~flag; + } + } +} + +static short unified_settings(Brush *brush) +{ + Scene *sce; + for (sce= G.main->scene.first; sce; sce= sce->id.next) { + if (sce->toolsettings && + ELEM4(brush, + paint_brush(&(sce->toolsettings->imapaint.paint)), + paint_brush(&(sce->toolsettings->vpaint->paint)), + paint_brush(&(sce->toolsettings->wpaint->paint)), + paint_brush(&(sce->toolsettings->sculpt->paint)))) + { + return sce->toolsettings->sculpt_paint_settings; + } + } + + return 0; +} + +static void set_unified_size(Brush *brush, int value) +{ + Scene *sce; + for (sce= G.main->scene.first; sce; sce= sce->id.next) { + if (sce->toolsettings && + ELEM4(brush, + paint_brush(&(sce->toolsettings->imapaint.paint)), + paint_brush(&(sce->toolsettings->vpaint->paint)), + paint_brush(&(sce->toolsettings->wpaint->paint)), + paint_brush(&(sce->toolsettings->sculpt->paint)))) + { + sce->toolsettings->sculpt_paint_unified_size= value; + } + } +} + +static int unified_size(Brush *brush) +{ + Scene *sce; + for (sce= G.main->scene.first; sce; sce= sce->id.next) { + if (sce->toolsettings && + ELEM4(brush, + paint_brush(&(sce->toolsettings->imapaint.paint)), + paint_brush(&(sce->toolsettings->vpaint->paint)), + paint_brush(&(sce->toolsettings->wpaint->paint)), + paint_brush(&(sce->toolsettings->sculpt->paint)))) + { + return sce->toolsettings->sculpt_paint_unified_size; + } + } + + return 35; // XXX magic number +} + +static void set_unified_alpha(Brush *brush, float value) +{ + Scene *sce; + for (sce= G.main->scene.first; sce; sce= sce->id.next) { + if (sce->toolsettings && + ELEM4(brush, + paint_brush(&(sce->toolsettings->imapaint.paint)), + paint_brush(&(sce->toolsettings->vpaint->paint)), + paint_brush(&(sce->toolsettings->wpaint->paint)), + paint_brush(&(sce->toolsettings->sculpt->paint)))) + { + sce->toolsettings->sculpt_paint_unified_alpha= value; + } + } +} + +static float unified_alpha(Brush *brush) +{ + Scene *sce; + for (sce= G.main->scene.first; sce; sce= sce->id.next) { + if (sce->toolsettings && + ELEM4(brush, + paint_brush(&(sce->toolsettings->imapaint.paint)), + paint_brush(&(sce->toolsettings->vpaint->paint)), + paint_brush(&(sce->toolsettings->wpaint->paint)), + paint_brush(&(sce->toolsettings->sculpt->paint)))) + { + return sce->toolsettings->sculpt_paint_unified_alpha; + } + } + + return 0.5f; // XXX magic number +} + +static void set_unified_unprojected_radius(Brush *brush, float value) +{ + Scene *sce; + for (sce= G.main->scene.first; sce; sce= sce->id.next) { + if (sce->toolsettings && + ELEM4(brush, + paint_brush(&(sce->toolsettings->imapaint.paint)), + paint_brush(&(sce->toolsettings->vpaint->paint)), + paint_brush(&(sce->toolsettings->wpaint->paint)), + paint_brush(&(sce->toolsettings->sculpt->paint)))) + { + sce->toolsettings->sculpt_paint_unified_unprojected_radius= value; + } + } +} + +static float unified_unprojected_radius(Brush *brush) +{ + Scene *sce; + for (sce= G.main->scene.first; sce; sce= sce->id.next) { + if (sce->toolsettings && + ELEM4(brush, + paint_brush(&(sce->toolsettings->imapaint.paint)), + paint_brush(&(sce->toolsettings->vpaint->paint)), + paint_brush(&(sce->toolsettings->wpaint->paint)), + paint_brush(&(sce->toolsettings->sculpt->paint)))) + { + return sce->toolsettings->sculpt_paint_unified_unprojected_radius; + } + } + + return 0.125f; // XXX magic number +} +void brush_set_size(Brush *brush, int size) +{ + if (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_SIZE) + set_unified_size(brush, size); + else + brush->size= size; + + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); +} + +int brush_size(Brush *brush) +{ + return (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_SIZE) ? unified_size(brush) : brush->size; +} + +void brush_set_use_locked_size(Brush *brush, int value) +{ + if (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_SIZE) { + set_unified_settings(brush, SCULPT_PAINT_UNIFIED_LOCK_BRUSH_SIZE, value); + } + else { + if (value) + brush->flag |= BRUSH_LOCK_SIZE; + else + brush->flag &= ~BRUSH_LOCK_SIZE; + } + + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); +} + +int brush_use_locked_size(Brush *brush) +{ + return (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_SIZE) ? (unified_settings(brush) & SCULPT_PAINT_UNIFIED_LOCK_BRUSH_SIZE) : (brush->flag & BRUSH_LOCK_SIZE); +} + +void brush_set_use_size_pressure(Brush *brush, int value) +{ + if (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_SIZE) { + set_unified_settings(brush, SCULPT_PAINT_UNIFIED_SIZE_PRESSURE, value); + } + else { + if (value) + brush->flag |= BRUSH_SIZE_PRESSURE; + else + brush->flag &= ~BRUSH_SIZE_PRESSURE; + } + + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); +} + +int brush_use_size_pressure(Brush *brush) +{ + return (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_SIZE) ? (unified_settings(brush) & SCULPT_PAINT_UNIFIED_SIZE_PRESSURE) : (brush->flag & BRUSH_SIZE_PRESSURE); +} + +void brush_set_use_alpha_pressure(Brush *brush, int value) +{ + if (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_ALPHA) { + set_unified_settings(brush, SCULPT_PAINT_UNIFIED_ALPHA_PRESSURE, value); + } + else { + if (value) + brush->flag |= BRUSH_ALPHA_PRESSURE; + else + brush->flag &= ~BRUSH_ALPHA_PRESSURE; + } + + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); +} + +int brush_use_alpha_pressure(Brush *brush) +{ + return (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_ALPHA) ? (unified_settings(brush) & SCULPT_PAINT_UNIFIED_ALPHA_PRESSURE) : (brush->flag & BRUSH_ALPHA_PRESSURE); +} + +void brush_set_unprojected_radius(Brush *brush, float unprojected_radius) +{ + if (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_SIZE) + set_unified_unprojected_radius(brush, unprojected_radius); + else + brush->unprojected_radius= unprojected_radius; + + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); +} + +float brush_unprojected_radius(Brush *brush) +{ + return (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_SIZE) ? unified_unprojected_radius(brush) : brush->unprojected_radius; +} + +void brush_set_alpha(Brush *brush, float alpha) +{ + if (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_ALPHA) + set_unified_alpha(brush, alpha); + else + brush->alpha= alpha; + + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); +} + +float brush_alpha(Brush *brush) +{ + return (unified_settings(brush) & SCULPT_PAINT_USE_UNIFIED_ALPHA) ? unified_alpha(brush) : brush->alpha; +} -- cgit v1.2.3 From 2a02632882a4b538fcde785668ef993d26fae84b Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Thu, 22 Jul 2010 20:18:42 +0000 Subject: * removing the notifiers I added until I can discover the most lightweight way to achieve the same thing --- source/blender/blenkernel/intern/brush.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index ac600f7ef4e..a668249b0d5 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1237,7 +1237,7 @@ void brush_set_size(Brush *brush, int size) else brush->size= size; - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_size(Brush *brush) @@ -1257,7 +1257,7 @@ void brush_set_use_locked_size(Brush *brush, int value) brush->flag &= ~BRUSH_LOCK_SIZE; } - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_use_locked_size(Brush *brush) @@ -1277,7 +1277,7 @@ void brush_set_use_size_pressure(Brush *brush, int value) brush->flag &= ~BRUSH_SIZE_PRESSURE; } - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_use_size_pressure(Brush *brush) @@ -1297,7 +1297,7 @@ void brush_set_use_alpha_pressure(Brush *brush, int value) brush->flag &= ~BRUSH_ALPHA_PRESSURE; } - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_use_alpha_pressure(Brush *brush) @@ -1312,7 +1312,7 @@ void brush_set_unprojected_radius(Brush *brush, float unprojected_radius) else brush->unprojected_radius= unprojected_radius; - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } float brush_unprojected_radius(Brush *brush) @@ -1327,7 +1327,7 @@ void brush_set_alpha(Brush *brush, float alpha) else brush->alpha= alpha; - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } float brush_alpha(Brush *brush) -- cgit v1.2.3 From 3a042d205321574838b08fcfe99aa2d97fc4bc97 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Thu, 22 Jul 2010 21:10:29 +0000 Subject: Fix [#22965] Icons for new brushes won't get sticky --- source/blender/blenkernel/intern/brush.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index a668249b0d5..8670665a1ac 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -132,6 +132,8 @@ Brush *copy_brush(Brush *brush) if (brush->mtex.tex) id_us_plus((ID*)brush->mtex.tex); + //brushn->preview= NULL; + if (brush->icon_imbuf) brushn->icon_imbuf= IMB_dupImBuf(brush->icon_imbuf); -- cgit v1.2.3 From bd30c4da8aeb164d9276beffe09a2a18a5c90523 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Jul 2010 04:41:27 +0000 Subject: [#22876] Add new scene, stacker ".00" bug fix for r30441, (reverted for the beta), splitIDname wasnt returning the correct string length. --- source/blender/blenkernel/intern/library.c | 49 ++++++++++++++++-------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index fdc98d9ed29..acfaef9eb88 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -995,7 +995,7 @@ void IMAnames_to_pupstring(char **str, char *title, char *extraops, ListBase *lb /* used by buttons.c library.c mball.c */ -void splitIDname(char *name, char *left, int *nr) +int splitIDname(char *name, char *left, int *nr) { int a; @@ -1003,19 +1003,23 @@ void splitIDname(char *name, char *left, int *nr) strncpy(left, name, 21); a= strlen(name); - if(a>1 && name[a-1]=='.') return; + if(a>1 && name[a-1]=='.') return a; while(a--) { if( name[a]=='.' ) { left[a]= 0; *nr= atol(name+a+1); - return; + return a; } if( isdigit(name[a])==0 ) break; left[a]= 0; } - strcpy(left, name); + + for(a= 0; name[a]; a++) + left[a]= name[a]; + + return a; } static void sort_alpha_id(ListBase *lb, ID *id) @@ -1077,8 +1081,7 @@ static ID *is_dupid(ListBase *lb, ID *id, char *name) static int check_for_dupid(ListBase *lb, ID *id, char *name) { ID *idtest; - int nr= 0, nrtest, a; - const int maxtest=32; + int nr= 0, nrtest, a, left_len; char left[32], leftest[32], in_use[32]; /* make sure input name is terminated properly */ @@ -1095,31 +1098,31 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* we have a dup; need to make a new name */ /* quick check so we can reuse one of first 32 ids if vacant */ - memset(in_use, 0, maxtest); + memset(in_use, 0, sizeof(in_use)); /* get name portion, number portion ("name.number") */ - splitIDname( name, left, &nr); + left_len= splitIDname(name, left, &nr); /* if new name will be too long, truncate it */ if(nr>999 && strlen(left)>16) left[16]= 0; else if(strlen(left)>17) left[17]= 0; - for( idtest = lb->first; idtest; idtest = idtest->next ) { - if( id != idtest && idtest->lib == NULL ) { - splitIDname(idtest->name+2, leftest, &nrtest); - /* if base names match... */ - /* optimized */ - if( *left == *leftest && strcmp(left, leftest)==0 ) { - if(nrtest < maxtest) - in_use[nrtest]= 1; /* mark as used */ - if(nr <= nrtest) - nr= nrtest+1; /* track largest unused */ - } + for(idtest= lb->first; idtest; idtest= idtest->next) { + if( (id != idtest) && + (idtest->lib == NULL) && + (*name == *(idtest->name+2)) && + (strncmp(name, idtest->name+2, left_len)==0) && + (splitIDname(idtest->name+2, leftest, &nrtest) == left_len) + ) { + if(nrtest < sizeof(in_use)) + in_use[nrtest]= 1; /* mark as used */ + if(nr <= nrtest) + nr= nrtest+1; /* track largest unused */ } } /* decide which value of nr to use */ - for(a=0; a=nr) break; /* stop when we've check up to biggest */ if( in_use[a]==0 ) { /* found an unused value */ nr = a; @@ -1129,8 +1132,9 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* If the original name has no numeric suffix, * rather than just chopping and adding numbers, - * shave off the end chars until we have a unique name */ - if (nr==0) { + * shave off the end chars until we have a unique name. + * Check the null terminators match as well so we dont get Cube.000 -> Cube.00 */ + if (nr==0 && name[left_len]== left[left_len]) { int len = strlen(name)-1; idtest= is_dupid(lb, id, name); @@ -1389,4 +1393,3 @@ void rename_id(ID *id, char *name) new_id(lb, id, name); } - -- cgit v1.2.3 From 65fcb0edcf64b70ff79e298ffebcbbf8812e2774 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Fri, 23 Jul 2010 16:57:11 +0000 Subject: == Sequencer == This patch cleans up the sequencer core by replacing the caching system (TStripElems) with a hash based system, which is: a) a lot faster b) a lot more readable c) a lot more memory conserving The new caching system is also a good building ground for a) sub frame precision rendering (even on scene strips) b) multi core rendering (threaded rendering is still disabled, but can be extended now to arbitrary core numbers) I tested the code on an extensive editing session today and had no crashes during 4 hours of editing. So I consider it very stable. --- source/blender/blenkernel/intern/blender.c | 1 + source/blender/blenkernel/intern/seqcache.c | 267 ++++ source/blender/blenkernel/intern/seqeffects.c | 1 + source/blender/blenkernel/intern/sequencer.c | 1739 ++++++++----------------- 4 files changed, 826 insertions(+), 1182 deletions(-) create mode 100644 source/blender/blenkernel/intern/seqcache.c (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 101c7a3bbbd..9a624017a16 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -102,6 +102,7 @@ void free_blender(void) BKE_spacetypes_free(); /* after free main, it uses space callbacks */ IMB_exit(); + seq_stripelem_cache_destruct(); free_nodesystem(); } diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c new file mode 100644 index 00000000000..c2b689195f6 --- /dev/null +++ b/source/blender/blenkernel/intern/seqcache.c @@ -0,0 +1,267 @@ +/** +* $Id: seqcache.c 29923 2010-07-04 10:51:10Z schlaile $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Peter Schlaile 2010 + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include +#include +#include + +#include "MEM_guardedalloc.h" +#include "MEM_CacheLimiterC-Api.h" + +#include "DNA_sequence_types.h" +#include "BKE_sequencer.h" +#include "BLI_ghash.h" +#include "BLI_mempool.h" +#include + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + +typedef struct seqCacheKey +{ + struct Sequence * seq; + int rectx; + int recty; + float cfra; + seq_stripelem_ibuf_t type; +} seqCacheKey; + +typedef struct seqCacheEntry +{ + ImBuf * ibuf; + MEM_CacheLimiterHandleC * c_handle; +} seqCacheEntry; + +static GHash * hash = 0; +static MEM_CacheLimiterC * limitor = 0; +static struct BLI_mempool * entrypool = 0; +static struct BLI_mempool * keypool = 0; +static int ibufs_in = 0; +static int ibufs_rem = 0; + +static unsigned int HashHash(void *key_) +{ + seqCacheKey * key = (seqCacheKey*) key_; + unsigned int rval = key->rectx + key->recty; + + rval ^= *(unsigned int*) &key->cfra; + rval += key->type; + rval ^= (unsigned int) key->seq; + + return rval; +} + +static int HashCmp(void *a_, void *b_) +{ + seqCacheKey * a = (seqCacheKey*) a_; + seqCacheKey * b = (seqCacheKey*) b_; + + if (a->seq < b->seq) { + return -1; + } + if (a->seq > b->seq) { + return 1; + } + + if (a->cfra < b->cfra) { + return -1; + } + if (a->cfra > b->cfra) { + return 1; + } + + if (a->type < b->type) { + return -1; + } + if (a->type > b->type) { + return 1; + } + + if (a->rectx < b->rectx) { + return -1; + } + if (a->rectx > b->rectx) { + return 1; + } + + if (a->recty < b->recty) { + return -1; + } + if (a->recty > b->recty) { + return 1; + } + + return 0; +} + +static void HashKeyFree(void *key) +{ + BLI_mempool_free(keypool, key); +} + +static void HashValFree(void *val) +{ + seqCacheEntry* e = (seqCacheEntry*) val; + + if (e->ibuf) { + /* fprintf(stderr, "Removing: %p, cnt: %d\n", e->ibuf, + e->ibuf->refcounter); */ + IMB_freeImBuf(e->ibuf); + MEM_CacheLimiter_unmanage(e->c_handle); + ibufs_rem++; + } + + e->ibuf = 0; + e->c_handle = 0; + + BLI_mempool_free(entrypool, e); +} + +static void IMB_seq_cache_destructor(void * p) +{ + seqCacheEntry* e = (seqCacheEntry*) p; + + if (e && e->ibuf) { + /* fprintf(stderr, "Removing: %p, cnt: %d\n", e->ibuf, + e->ibuf->refcounter); */ + IMB_freeImBuf(e->ibuf); + ibufs_rem++; + + e->ibuf = 0; + e->c_handle = 0; + } +} + +void seq_stripelem_cache_init() +{ + hash = BLI_ghash_new(HashHash, HashCmp, "seq stripelem cache hash"); + limitor = new_MEM_CacheLimiter( IMB_seq_cache_destructor ); + + entrypool = BLI_mempool_create(sizeof(seqCacheEntry), 64, 64, 0); + keypool = BLI_mempool_create(sizeof(seqCacheKey), 64, 64, 0); +} + +void seq_stripelem_cache_destruct() +{ + if (!entrypool) { + return; + } + BLI_ghash_free(hash, HashKeyFree, HashValFree); + delete_MEM_CacheLimiter(limitor); + BLI_mempool_destroy(entrypool); + BLI_mempool_destroy(keypool); +} + +void seq_stripelem_cache_cleanup() +{ + if (!entrypool) { + seq_stripelem_cache_init(); + } + + /* fprintf(stderr, "Stats before cleanup: in: %d rem: %d\n", + ibufs_in, ibufs_rem); */ + + BLI_ghash_free(hash, HashKeyFree, HashValFree); + hash = BLI_ghash_new(HashHash, HashCmp, "seq stripelem cache hash"); + + /* fprintf(stderr, "Stats after cleanup: in: %d rem: %d\n", + ibufs_in, ibufs_rem); */ + +} + +struct ImBuf * seq_stripelem_cache_get( + struct Sequence * seq, int rectx, int recty, + float cfra, seq_stripelem_ibuf_t type) +{ + seqCacheKey key; + seqCacheEntry * e; + + if (!seq) { + return 0; + } + + if (!entrypool) { + seq_stripelem_cache_init(); + } + + key.seq = seq; + key.rectx = rectx; + key.recty = recty; + key.cfra = cfra - seq->start; + key.type = type; + + e = (seqCacheEntry*) BLI_ghash_lookup(hash, &key); + + if (e && e->ibuf) { + IMB_refImBuf(e->ibuf); + + MEM_CacheLimiter_touch(e->c_handle); + return e->ibuf; + } + return 0; +} + +void seq_stripelem_cache_put( + struct Sequence * seq, int rectx, int recty, + float cfra, seq_stripelem_ibuf_t type, struct ImBuf * i) +{ + seqCacheKey * key; + seqCacheEntry * e; + + if (!i) { + return; + } + + ibufs_in++; + + if (!entrypool) { + seq_stripelem_cache_init(); + } + + key = (seqCacheKey*) BLI_mempool_alloc(keypool); + + key->seq = seq; + key->rectx = rectx; + key->recty = recty; + key->cfra = cfra - seq->start; + key->type = type; + + /* we want our own version */ + IMB_refImBuf(i); + + e = (seqCacheEntry*) BLI_mempool_alloc(entrypool); + + e->ibuf = i; + e->c_handle = 0; + + BLI_ghash_remove(hash, key, HashKeyFree, HashValFree); + BLI_ghash_insert(hash, key, e); + + e->c_handle = MEM_CacheLimiter_insert(limitor, e); + + MEM_CacheLimiter_ref(e->c_handle); + MEM_CacheLimiter_enforce_limits(limitor); + MEM_CacheLimiter_unref(e->c_handle); +} diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 73c19772c69..efebca0f780 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2786,6 +2786,7 @@ static void do_multicam(Scene *scene, Sequence *seq, int cfra, IMB_float_from_rect_simple(i); memcpy(out->rect_float, i->rect_float, out->x * out->y *4*sizeof(float)); } + IMB_freeImBuf(i); } /* ********************************************************************** diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 61415eb4a52..5f41debbbe9 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -116,53 +116,11 @@ int seq_recursive_apply(Sequence *seq, int (*apply_func)(Sequence *, void *), vo alloc / free functions ********************************************************************** */ -static void free_tstripdata(int len, TStripElem *se) -{ - TStripElem *seo; - int a; - - seo= se; - if (!se) - return; - - for(a=0; aibuf) { - IMB_freeImBuf(se->ibuf); - se->ibuf = 0; - } - if(se->ibuf_comp) { - IMB_freeImBuf(se->ibuf_comp); - se->ibuf_comp = 0; - } - } - - MEM_freeN(seo); -} void new_tstripdata(Sequence *seq) { if(seq->strip) { - free_tstripdata(seq->strip->len, seq->strip->tstripdata); - free_tstripdata(seq->strip->endstill, - seq->strip->tstripdata_endstill); - free_tstripdata(seq->strip->startstill, - seq->strip->tstripdata_startstill); - - seq->strip->tstripdata= 0; - seq->strip->tstripdata_endstill= 0; - seq->strip->tstripdata_startstill= 0; - - if(seq->strip->ibuf_startstill) { - IMB_freeImBuf(seq->strip->ibuf_startstill); - seq->strip->ibuf_startstill = 0; - } - - if(seq->strip->ibuf_endstill) { - IMB_freeImBuf(seq->strip->ibuf_endstill); - seq->strip->ibuf_endstill = 0; - } - seq->strip->len= seq->len; } } @@ -208,20 +166,6 @@ void seq_free_strip(Strip *strip) MEM_freeN(strip->color_balance); } - free_tstripdata(strip->len, strip->tstripdata); - free_tstripdata(strip->endstill, strip->tstripdata_endstill); - free_tstripdata(strip->startstill, strip->tstripdata_startstill); - - if(strip->ibuf_startstill) { - IMB_freeImBuf(strip->ibuf_startstill); - strip->ibuf_startstill = 0; - } - - if(strip->ibuf_endstill) { - IMB_freeImBuf(strip->ibuf_endstill); - strip->ibuf_endstill = 0; - } - MEM_freeN(strip); } @@ -950,137 +894,9 @@ static void multibuf(ImBuf *ibuf, float fmul) } } -static void do_effect(Scene *scene, int cfra, Sequence *seq, TStripElem * se, - int render_size) -{ - TStripElem *se1, *se2, *se3; - float fac, facf; - int x, y; - int early_out; - struct SeqEffectHandle sh = get_sequence_effect(seq); - FCurve *fcu= NULL; - - if (!sh.execute) { /* effect not supported in this version... */ - make_black_ibuf(se->ibuf); - return; - } - - if ((seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) != 0) { - sh.get_default_fac(seq, cfra, &fac, &facf); - if( scene->r.mode & R_FIELDS ); else facf= fac; - } else { - fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, - "effect_fader", 0); - if (fcu) { - fac = facf = evaluate_fcurve(fcu, cfra); - if( scene->r.mode & R_FIELDS ) { - facf = evaluate_fcurve(fcu, cfra + 0.5); - } - } else { - fac = facf = seq->effect_fader; - } - } - - early_out = sh.early_out(seq, fac, facf); - - if (early_out == -1) { /* no input needed */ - sh.execute(scene, seq, cfra, fac, facf, - se->ibuf->x, se->ibuf->y, render_size, - 0, 0, 0, se->ibuf); - return; - } - - switch (early_out) { - case 0: - if (se->se1==0 || se->se2==0 || se->se3==0) { - make_black_ibuf(se->ibuf); - return; - } - - se1= se->se1; - se2= se->se2; - se3= se->se3; - - if ( (se1==0 || se2==0 || se3==0) - || (se1->ibuf==0 || se2->ibuf==0 || se3->ibuf==0)) { - make_black_ibuf(se->ibuf); - return; - } - - break; - case 1: - if (se->se1 == 0) { - make_black_ibuf(se->ibuf); - return; - } - - se1= se->se1; - - if (se1 == 0 || se1->ibuf == 0) { - make_black_ibuf(se->ibuf); - return; - } - - if (se->ibuf != se1->ibuf) { - IMB_freeImBuf(se->ibuf); - se->ibuf = se1->ibuf; - IMB_refImBuf(se->ibuf); - } - return; - case 2: - if (se->se2 == 0) { - make_black_ibuf(se->ibuf); - return; - } - - se2= se->se2; - - if (se2 == 0 || se2->ibuf == 0) { - make_black_ibuf(se->ibuf); - return; - } - if (se->ibuf != se2->ibuf) { - IMB_freeImBuf(se->ibuf); - se->ibuf = se2->ibuf; - IMB_refImBuf(se->ibuf); - } - return; - default: - make_black_ibuf(se->ibuf); - return; - } - - x= se2->ibuf->x; - y= se2->ibuf->y; - - if (!se1->ibuf->rect_float && se->ibuf->rect_float) { - IMB_float_from_rect_simple(se1->ibuf); - } - if (!se2->ibuf->rect_float && se->ibuf->rect_float) { - IMB_float_from_rect_simple(se2->ibuf); - } - if (!se3->ibuf->rect_float && se->ibuf->rect_float) { - IMB_float_from_rect_simple(se3->ibuf); - } - - if (!se1->ibuf->rect && !se->ibuf->rect_float) { - IMB_rect_from_float(se1->ibuf); - } - if (!se2->ibuf->rect && !se->ibuf->rect_float) { - IMB_rect_from_float(se2->ibuf); - } - if (!se3->ibuf->rect && !se->ibuf->rect_float) { - IMB_rect_from_float(se3->ibuf); - } - - sh.execute(scene, seq, cfra, fac, facf, x, y, render_size, - se1->ibuf, se2->ibuf, se3->ibuf, - se->ibuf); -} - -static int give_stripelem_index(Sequence *seq, int cfra) +static float give_stripelem_index(Sequence *seq, float cfra) { - int nr; + float nr; if(seq->startdisp >cfra || seq->enddisp <= cfra) return -1; if(seq->len == 0) return -1; @@ -1096,93 +912,12 @@ static int give_stripelem_index(Sequence *seq, int cfra) } if (seq->strobe < 1.0) seq->strobe = 1.0; if (seq->strobe > 1.0) { - nr -= (int)fmod((double)nr, (double)seq->strobe); + nr -= fmod((double)nr, (double)seq->strobe); } return nr; } -static TStripElem* alloc_tstripdata(int len, const char * name) -{ - int i; - TStripElem *se = MEM_callocN(len * sizeof(TStripElem), name); - for (i = 0; i < len; i++) { - se[i].ok = STRIPELEM_OK; - } - return se; -} - -static TStripElem *give_tstripelem(Sequence *seq, int cfra) -{ - TStripElem *se; - int nr; - - se = seq->strip->tstripdata; - if (se == 0 && seq->len > 0) { - se = seq->strip->tstripdata = alloc_tstripdata(seq->len, - "tstripelems"); - } - nr = give_stripelem_index(seq, cfra); - - if (nr == -1) return 0; - if (se == 0) return 0; - - se += nr; - - /* if there are IPOs with blend modes active, one has to watch out - for startstill + endstill area: we can't use the same tstripelem - here for all ibufs, since then, blending with IPOs won't work! - - Rather common case, if you use a single image and try to fade - it in and out... or want to use your strip as a watermark in - alpha over mode... - */ - if (seq->blend_mode != SEQ_BLEND_REPLACE || - (/*seq->ipo && seq->ipo->curve.first &&*/ - (!(seq->type & SEQ_EFFECT) || !seq->seq1))) { - Strip * s = seq->strip; - if (cfra < seq->start) { - se = s->tstripdata_startstill; - if (seq->startstill != s->startstill) { - free_tstripdata(s->startstill, - s->tstripdata_startstill); - se = 0; - } - - if (se == 0) { - s->startstill = seq->startstill; - se = seq->strip->tstripdata_startstill - = alloc_tstripdata( - s->startstill, - "tstripelems_startstill"); - } - se += seq->start - cfra - 1; - - } else if (cfra > seq->start + seq->len-1) { - se = s->tstripdata_endstill; - if (seq->endstill != s->endstill) { - free_tstripdata(s->endstill, - s->tstripdata_endstill); - se = 0; - } - - if (se == 0) { - s->endstill = seq->endstill; - se = seq->strip->tstripdata_endstill - = alloc_tstripdata( - s->endstill, - "tstripelems_endstill"); - } - se += cfra - (seq->start + seq->len-1) - 1; - } - } - - - se->nr= nr; - - return se; -} - StripElem *give_stripelem(Sequence *seq, int cfra) { StripElem *se= seq->strip->stripdata; @@ -1191,7 +926,7 @@ StripElem *give_stripelem(Sequence *seq, int cfra) /* use the first */ } else { - int nr = give_stripelem_index(seq, cfra); + int nr = (int) give_stripelem_index(seq, cfra); if (nr == -1) return 0; if (se == 0) return 0; @@ -1322,17 +1057,15 @@ static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * na dir, render_size, se->name); frameno = 1; } else if (seq->type == SEQ_MOVIE) { - TStripElem * tse = give_tstripelem(seq, cfra); - - frameno = tse->nr + seq->anim_startofs; + frameno = (int) give_stripelem_index(seq, cfra) + + seq->anim_startofs; snprintf(name, PROXY_MAXFILE, "%s/%s/%d/####", dir, seq->strip->stripdata->name, render_size); } else { - TStripElem * tse = give_tstripelem(seq, cfra); - - frameno = tse->nr + seq->anim_startofs; + frameno = (int) give_stripelem_index(seq, cfra) + + seq->anim_startofs; snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, render_size); @@ -1361,10 +1094,11 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in } if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { - TStripElem * tse = give_tstripelem(seq, cfra); - int frameno = tse->nr + seq->anim_startofs; + int frameno = (int) give_stripelem_index(seq, cfra) + + seq->anim_startofs; if (!seq->strip->proxy->anim) { - if (!seq_proxy_get_fname(scene, seq, cfra, name, render_size)) { + if (!seq_proxy_get_fname( + scene, seq, cfra, name, render_size)) { return 0; } @@ -1607,12 +1341,12 @@ static void make_cb_table_float(float lift, float gain, float gamma, } } -static void color_balance_byte_byte(Sequence * seq, TStripElem* se, float mul) +static void color_balance_byte_byte(Sequence * seq, ImBuf* ibuf, float mul) { unsigned char cb_tab[3][256]; int c; - unsigned char * p = (unsigned char*) se->ibuf->rect; - unsigned char * e = p + se->ibuf->x * 4 * se->ibuf->y; + unsigned char * p = (unsigned char*) ibuf->rect; + unsigned char * e = p + ibuf->x * 4 * ibuf->y; StripColorBalance cb = calc_cb(seq->strip->color_balance); @@ -1630,24 +1364,24 @@ static void color_balance_byte_byte(Sequence * seq, TStripElem* se, float mul) } } -static void color_balance_byte_float(Sequence * seq, TStripElem* se, float mul) +static void color_balance_byte_float(Sequence * seq, ImBuf* ibuf, float mul) { float cb_tab[4][256]; int c,i; - unsigned char * p = (unsigned char*) se->ibuf->rect; - unsigned char * e = p + se->ibuf->x * 4 * se->ibuf->y; + unsigned char * p = (unsigned char*) ibuf->rect; + unsigned char * e = p + ibuf->x * 4 * ibuf->y; float * o; StripColorBalance cb; - imb_addrectfloatImBuf(se->ibuf); + imb_addrectfloatImBuf(ibuf); - o = se->ibuf->rect_float; + o = ibuf->rect_float; cb = calc_cb(seq->strip->color_balance); for (c = 0; c < 3; c++) { make_cb_table_float(cb.lift[c], cb.gain[c], cb.gamma[c], - cb_tab[c], mul); + cb_tab[c], mul); } for (i = 0; i < 256; i++) { @@ -1664,10 +1398,10 @@ static void color_balance_byte_float(Sequence * seq, TStripElem* se, float mul) } } -static void color_balance_float_float(Sequence * seq, TStripElem* se, float mul) +static void color_balance_float_float(Sequence * seq, ImBuf* ibuf, float mul) { - float * p = se->ibuf->rect_float; - float * e = se->ibuf->rect_float + se->ibuf->x * 4* se->ibuf->y; + float * p = ibuf->rect_float; + float * e = ibuf->rect_float + ibuf->x * 4* ibuf->y; StripColorBalance cb = calc_cb(seq->strip->color_balance); while (p < e) { @@ -1679,14 +1413,14 @@ static void color_balance_float_float(Sequence * seq, TStripElem* se, float mul) } } -static void color_balance(Sequence * seq, TStripElem* se, float mul) +static void color_balance(Sequence * seq, ImBuf* ibuf, float mul) { - if (se->ibuf->rect_float) { - color_balance_float_float(seq, se, mul); + if (ibuf->rect_float) { + color_balance_float_float(seq, ibuf, mul); } else if(seq->flag & SEQ_MAKE_FLOAT) { - color_balance_byte_float(seq, se, mul); + color_balance_byte_float(seq, ibuf, mul); } else { - color_balance_byte_byte(seq, se, mul); + color_balance_byte_byte(seq, ibuf, mul); } } @@ -1709,18 +1443,18 @@ static void color_balance(Sequence * seq, TStripElem* se, float mul) */ -static int input_have_to_preprocess(Scene *scene, Sequence * seq, TStripElem* se, int cfra, int seqrectx, int seqrecty) +static int input_have_to_preprocess( + Scene *scene, Sequence * seq, float cfra, int seqrectx, int seqrecty) { float mul; if ((seq->flag & SEQ_FILTERY) || - (seq->flag & SEQ_USE_CROP) || - (seq->flag & SEQ_USE_TRANSFORM) || - (seq->flag & SEQ_FLIPX) || - (seq->flag & SEQ_FLIPY) || - (seq->flag & SEQ_USE_COLOR_BALANCE) || - (seq->flag & SEQ_MAKE_PREMUL) || - (se->ibuf->x != seqrectx || se->ibuf->y != seqrecty)) { + (seq->flag & SEQ_USE_CROP) || + (seq->flag & SEQ_USE_TRANSFORM) || + (seq->flag & SEQ_FLIPX) || + (seq->flag & SEQ_FLIPY) || + (seq->flag & SEQ_USE_COLOR_BALANCE) || + (seq->flag & SEQ_MAKE_PREMUL)) { return TRUE; } @@ -1734,19 +1468,25 @@ static int input_have_to_preprocess(Scene *scene, Sequence * seq, TStripElem* se if (mul != 1.0) { return TRUE; } + + if (seq->sat != 1.0) { + return TRUE; + } return FALSE; } -static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cfra, int seqrectx, int seqrecty) +static ImBuf * input_preprocess( + Scene *scene, Sequence *seq, float cfra, int seqrectx, int seqrecty, + ImBuf * ibuf) { float mul; - seq->strip->orx= se->ibuf->x; - seq->strip->ory= se->ibuf->y; + seq->strip->orx= ibuf->x; + seq->strip->ory= ibuf->y; if((seq->flag & SEQ_FILTERY) && seq->type != SEQ_MOVIE) { - IMB_filtery(se->ibuf); + IMB_filtery(ibuf); } if(seq->flag & SEQ_USE_CROP || seq->flag & SEQ_USE_TRANSFORM) { @@ -1764,8 +1504,8 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf t = *seq->strip->transform; } - sx = se->ibuf->x - c.left - c.right; - sy = se->ibuf->y - c.top - c.bottom; + sx = ibuf->x - c.left - c.right; + sy = ibuf->y - c.top - c.bottom; dx = sx; dy = sy; @@ -1774,49 +1514,49 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf dy = scene->r.ysch; } - if (c.top + c.bottom >= se->ibuf->y || - c.left + c.right >= se->ibuf->x || + if (c.top + c.bottom >= ibuf->y || + c.left + c.right >= ibuf->x || t.xofs >= dx || t.yofs >= dy) { - make_black_ibuf(se->ibuf); + make_black_ibuf(ibuf); } else { ImBuf * i; - if (se->ibuf->rect_float) { + if (ibuf->rect_float) { i = IMB_allocImBuf(dx, dy,32, IB_rectfloat, 0); } else { i = IMB_allocImBuf(dx, dy,32, IB_rect, 0); } - IMB_rectcpy(i, se->ibuf, - t.xofs, t.yofs, - c.left, c.bottom, - sx, sy); - - IMB_freeImBuf(se->ibuf); + IMB_rectcpy(i, ibuf, + t.xofs, t.yofs, + c.left, c.bottom, + sx, sy); + + IMB_freeImBuf(ibuf); - se->ibuf = i; + ibuf = i; } } if(seq->flag & SEQ_FLIPX) { - IMB_flipx(se->ibuf); + IMB_flipx(ibuf); } if(seq->flag & SEQ_FLIPY) { - IMB_flipy(se->ibuf); + IMB_flipy(ibuf); } if(seq->sat != 1.0f) { /* inline for now, could become an imbuf function */ int i; - char *rct= (char *)se->ibuf->rect; - float *rctf= se->ibuf->rect_float; + char *rct= (char *)ibuf->rect; + float *rctf= ibuf->rect_float; const float sat= seq->sat; float hsv[3]; if(rct) { float rgb[3]; - for (i = se->ibuf->x * se->ibuf->y; i > 0; i--, rct+=4) { + for (i = ibuf->x * ibuf->y; i > 0; i--, rct+=4) { rgb_byte_to_float(rct, rgb); rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv+1, hsv+2); hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rgb, rgb+1, rgb+2); @@ -1825,7 +1565,7 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf } if(rctf) { - for (i = se->ibuf->x * se->ibuf->y; i > 0; i--, rctf+=4) { + for (i = ibuf->x * ibuf->y; i > 0; i--, rctf+=4) { rgb_to_hsv(rctf[0], rctf[1], rctf[2], hsv, hsv+1, hsv+2); hsv_to_rgb(hsv[0], hsv[1] * sat, hsv[2], rctf, rctf+1, rctf+2); } @@ -1839,725 +1579,544 @@ static void input_preprocess(Scene *scene, Sequence *seq, TStripElem *se, int cf } if(seq->flag & SEQ_USE_COLOR_BALANCE && seq->strip->color_balance) { - color_balance(seq, se, mul); + color_balance(seq, ibuf, mul); mul = 1.0; } if(seq->flag & SEQ_MAKE_FLOAT) { - if (!se->ibuf->rect_float) - IMB_float_from_rect_simple(se->ibuf); + if (!ibuf->rect_float) + IMB_float_from_rect_simple(ibuf); - if (se->ibuf->rect) { - imb_freerectImBuf(se->ibuf); + if (ibuf->rect) { + imb_freerectImBuf(ibuf); } } if(mul != 1.0) { - multibuf(se->ibuf, mul); + multibuf(ibuf, mul); } if(seq->flag & SEQ_MAKE_PREMUL) { - if(se->ibuf->depth == 32 && se->ibuf->zbuf == 0) { - IMB_premultiply_alpha(se->ibuf); + if(ibuf->depth == 32 && ibuf->zbuf == 0) { + IMB_premultiply_alpha(ibuf); } } - if(se->ibuf->x != seqrectx || se->ibuf->y != seqrecty ) { + if(ibuf->x != seqrectx || ibuf->y != seqrecty ) { if(scene->r.mode & R_OSA) { - IMB_scaleImBuf(se->ibuf, - (short)seqrectx, (short)seqrecty); + IMB_scaleImBuf(ibuf, + (short)seqrectx, (short)seqrecty); } else { - IMB_scalefastImBuf(se->ibuf, + IMB_scalefastImBuf(ibuf, (short)seqrectx, (short)seqrecty); } } + return ibuf; } -/* test if image too small or discarded from cache: reload */ - -static void test_and_auto_discard_ibuf(TStripElem * se, - int seqrectx, int seqrecty) +static ImBuf * copy_from_ibuf_still(Sequence * seq, float nr, + int seqrectx, int seqrecty) { - if (se->ibuf) { - if(se->ibuf->x != seqrectx || se->ibuf->y != seqrecty - || !(se->ibuf->rect || se->ibuf->rect_float)) { - IMB_freeImBuf(se->ibuf); + ImBuf * rval = 0; + ImBuf * ibuf = 0; - se->ibuf= 0; - se->ok= STRIPELEM_OK; - } + if (nr == 0) { + ibuf = seq_stripelem_cache_get( + seq, seqrectx, seqrecty, seq->start, + SEQ_STRIPELEM_IBUF_STARTSTILL); + } + if (nr == seq->len - 1) { + ibuf = seq_stripelem_cache_get( + seq, seqrectx, seqrecty, seq->start, + SEQ_STRIPELEM_IBUF_ENDSTILL); } - if (se->ibuf_comp) { - if(se->ibuf_comp->x != seqrectx || se->ibuf_comp->y != seqrecty - || !(se->ibuf_comp->rect || se->ibuf_comp->rect_float)) { - IMB_freeImBuf(se->ibuf_comp); - se->ibuf_comp = 0; - } + if (ibuf) { + rval = IMB_dupImBuf(ibuf); + IMB_freeImBuf(ibuf); } + + return rval; } -static void test_and_auto_discard_ibuf_stills(Strip * strip) +static void copy_to_ibuf_still(Sequence * seq, float nr, + ImBuf * ibuf) { - if (strip->ibuf_startstill) { - if (!strip->ibuf_startstill->rect && - !strip->ibuf_startstill->rect_float) { - IMB_freeImBuf(strip->ibuf_startstill); - strip->ibuf_startstill = 0; - } + if (nr == 0) { + seq_stripelem_cache_put( + seq, 0, 0, seq->start, + SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf); } - if (strip->ibuf_endstill) { - if (!strip->ibuf_endstill->rect && - !strip->ibuf_endstill->rect_float) { - IMB_freeImBuf(strip->ibuf_endstill); - strip->ibuf_endstill = 0; - } + if (nr == seq->len - 1) { + seq_stripelem_cache_put( + seq, 0, 0, seq->start, + SEQ_STRIPELEM_IBUF_ENDSTILL, ibuf); } } -static void copy_from_ibuf_still(Sequence * seq, TStripElem * se) -{ - if (!se->ibuf) { - if (se->nr == 0 && seq->strip->ibuf_startstill) { - IMB_cache_limiter_touch(seq->strip->ibuf_startstill); +/* ********************************************************************** + strip rendering functions + ********************************************************************** */ - se->ibuf = IMB_dupImBuf(seq->strip->ibuf_startstill); - } - if (se->nr == seq->len - 1 - && (seq->len != 1) - && seq->strip->ibuf_endstill) { - IMB_cache_limiter_touch(seq->strip->ibuf_endstill); +static ImBuf* seq_render_strip_stack( + Scene *scene, + ListBase *seqbasep, float cfra, int chanshown, int render_size, + int seqrectx, int seqrecty); + +static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra, + int render_size, + int seqrectx, int seqrecty); - se->ibuf = IMB_dupImBuf(seq->strip->ibuf_endstill); - } - } -} -static void copy_to_ibuf_still(Sequence * seq, TStripElem * se) +static ImBuf* seq_render_effect_strip_impl( + Scene *scene, float cfra, Sequence *seq, int render_size, + int seqrectx, int seqrecty) { - if (se->ibuf) { - if (se->nr == 0) { - seq->strip->ibuf_startstill = IMB_dupImBuf(se->ibuf); + float fac, facf; + int early_out; + int i; + int must_preprocess = FALSE; - IMB_cache_limiter_insert(seq->strip->ibuf_startstill); - IMB_cache_limiter_touch(seq->strip->ibuf_startstill); - } - if (se->nr == seq->len - 1 && seq->len != 1) { - seq->strip->ibuf_endstill = IMB_dupImBuf(se->ibuf); + struct SeqEffectHandle sh = get_sequence_effect(seq); + FCurve *fcu= NULL; + ImBuf * ibuf[3]; + ImBuf * out = 0; + + ibuf[0] = ibuf[1] = ibuf[2] = 0; + + if (!sh.execute) { /* effect not supported in this version... */ + goto finish; + } - IMB_cache_limiter_insert(seq->strip->ibuf_endstill); - IMB_cache_limiter_touch(seq->strip->ibuf_endstill); + if ((seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) != 0) { + sh.get_default_fac(seq, cfra, &fac, &facf); + if( scene->r.mode & R_FIELDS ); else facf= fac; + } else { + fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, + "effect_fader", 0); + if (fcu) { + fac = facf = evaluate_fcurve(fcu, cfra); + if( scene->r.mode & R_FIELDS ) { + facf = evaluate_fcurve(fcu, cfra + 0.5); + } + } else { + fac = facf = seq->effect_fader; } } -} -static void free_metastrip_imbufs(ListBase *seqbasep, int cfra, int chanshown) -{ - Sequence* seq_arr[MAXSEQ+1]; - int i; - TStripElem* se = 0; + early_out = sh.early_out(seq, fac, facf); - evaluate_seq_frame_gen(seq_arr, seqbasep, cfra); + if (early_out == -1) { /* no input needed */ + /* hmmm, global float option ? */ + out = IMB_allocImBuf( + (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); - for (i = 0; i < MAXSEQ; i++) { - if (!video_seq_is_rendered(seq_arr[i])) { - continue; - } - se = give_tstripelem(seq_arr[i], cfra); - if (se) { - if (se->ibuf) { - IMB_freeImBuf(se->ibuf); + sh.execute(scene, seq, cfra, fac, facf, + out->x, out->y, render_size, + 0, 0, 0, out); + goto finish; + } - se->ibuf= 0; - se->ok= STRIPELEM_OK; - } - if (se->ibuf_comp) { - IMB_freeImBuf(se->ibuf_comp); + must_preprocess = input_have_to_preprocess( + scene, seq, cfra, seqrectx, seqrecty); - se->ibuf_comp = 0; - } + switch (early_out) { + case 0: + break; + case 1: + if (seq->seq1) { + ibuf[0] = seq_render_strip(scene, seq->seq1, cfra, + render_size, + seqrectx, seqrecty); } - } - -} - -static void check_limiter_refcount(const char * func, TStripElem *se) -{ - if (se && se->ibuf) { - int refcount = IMB_cache_limiter_get_refcount(se->ibuf); - if (refcount != 1) { - /* can happen on complex pipelines */ - if (refcount > 1 && (G.f & G_DEBUG) == 0) { - return; + if (ibuf[0]) { + if (must_preprocess) { + out = IMB_dupImBuf(ibuf[0]); + } else { + out = ibuf[0]; + IMB_refImBuf(out); } - - fprintf(stderr, - "sequencer: (ibuf) %s: " - "suspicious memcache " - "limiter refcount: %d\n", func, refcount); } - } -} - -static void check_limiter_refcount_comp(const char * func, TStripElem *se) -{ - if (se && se->ibuf_comp) { - int refcount = IMB_cache_limiter_get_refcount(se->ibuf_comp); - if (refcount != 1) { - /* can happen on complex pipelines */ - if (refcount > 1 && (G.f & G_DEBUG) == 0) { - return; + goto finish; + case 2: + if (seq->seq2) { + ibuf[1] = seq_render_strip(scene, seq->seq2, cfra, + render_size, + seqrectx, seqrecty); + } + if (ibuf[1]) { + if (must_preprocess) { + out = IMB_dupImBuf(ibuf[1]); + } else { + out = ibuf[1]; + IMB_refImBuf(out); } - fprintf(stderr, - "sequencer: (ibuf comp) %s: " - "suspicious memcache " - "limiter refcount: %d\n", func, refcount); } + goto finish; + default: + goto finish; } -} -static TStripElem* do_build_seq_array_recursively( - Scene *scene, - ListBase *seqbasep, int cfra, int chanshown, int render_size, - int seqrectx, int seqrecty); + if (seq->seq1) { + ibuf[0] = seq_render_strip(scene, seq->seq1, cfra, + render_size, + seqrectx, seqrecty); + } -static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, - int build_proxy_run, int render_size, int seqrectx, int seqrecty) -{ - char name[FILE_MAXDIR+FILE_MAXFILE]; - int use_limiter = TRUE; + if (seq->seq2) { + ibuf[1] = seq_render_strip(scene, seq->seq2, cfra, + render_size, + seqrectx, seqrecty); + } - test_and_auto_discard_ibuf(se, seqrectx, seqrecty); - test_and_auto_discard_ibuf_stills(seq->strip); + if (seq->seq3) { + ibuf[2] = seq_render_strip(scene, seq->seq3, cfra, + render_size, + seqrectx, seqrecty); + } - if(seq->type == SEQ_META) { - TStripElem * meta_se = 0; - int use_preprocess = FALSE; - use_limiter = FALSE; - - if (!build_proxy_run && se->ibuf == 0) { - se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); - if (se->ibuf) { - use_limiter = TRUE; - use_preprocess = TRUE; + if (!ibuf[0] || !ibuf[1]) { + goto finish; + } + + /* if any inputs are rectfloat, output is float too */ + if((ibuf[0] && ibuf[0]->rect_float) || + (ibuf[1] && ibuf[1]->rect_float) || + (ibuf[2] && ibuf[2]->rect_float)) { + out = IMB_allocImBuf( + (short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); + } else { + out = IMB_allocImBuf( + (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); + } + + for (i = 0; i < 3; i++) { + ImBuf * b = ibuf[i]; + if (b) { + if (!b->rect_float && out->rect_float) { + IMB_float_from_rect_simple(b); + } + if (!b->rect && !out->rect_float) { + IMB_rect_from_float(b); } } + } - if(!se->ibuf && seq->seqbase.first) { - meta_se = do_build_seq_array_recursively(scene, - &seq->seqbase, seq->start + se->nr, 0, - render_size, seqrectx, seqrecty); + sh.execute(scene, seq, cfra, fac, facf, out->x, out->y, render_size, + ibuf[0], ibuf[1], ibuf[2], out); - check_limiter_refcount("do_build_seq_ibuf: for META", meta_se); - } +finish: + for (i = 0; i < 3; i++) { + IMB_freeImBuf(ibuf[i]); + } - se->ok = STRIPELEM_OK; - - if(!se->ibuf && meta_se) { - se->ibuf = meta_se->ibuf_comp; - if(se->ibuf && - (!input_have_to_preprocess(scene, seq, se, cfra, - seqrectx, seqrecty) || - build_proxy_run)) { - IMB_refImBuf(se->ibuf); - if (build_proxy_run) { - IMB_cache_limiter_unref(se->ibuf); - } - } else if (se->ibuf) { - struct ImBuf * i = IMB_dupImBuf(se->ibuf); + if (!out) { + out = IMB_allocImBuf( + (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); + } - IMB_cache_limiter_unref(se->ibuf); + return out; +} - se->ibuf = i; - use_limiter = TRUE; - use_preprocess = TRUE; - } - } else if (se->ibuf) { - use_limiter = TRUE; - } - if (meta_se) { - free_metastrip_imbufs( - &seq->seqbase, seq->start + se->nr, 0); - } +static ImBuf * seq_render_scene_strip_impl( + Scene * scene, Sequence * seq, float nr, int seqrectx, int seqrecty) +{ + ImBuf * ibuf = 0; + float frame= seq->sfra + nr + seq->anim_startofs; + float oldcfra = seq->scene->r.cfra; + Object *oldcamera= seq->scene->camera; + ListBase oldmarkers; + + /* Hack! This function can be called from do_render_seq(), in that case + the seq->scene can already have a Render initialized with same name, + so we have to use a default name. (compositor uses scene name to + find render). + However, when called from within the UI (image preview in sequencer) + we do want to use scene Render, that way the render result is defined + for display in render/imagewindow + + Hmm, don't see, why we can't do that all the time, + and since G.rendering is uhm, gone... (Peter) + */ - if (use_preprocess) { - input_preprocess(scene, seq, se, cfra, seqrectx, - seqrecty); - } - } else if(seq->type & SEQ_EFFECT) { - int use_preprocess = FALSE; - /* should the effect be recalculated? */ - - if (!build_proxy_run && se->ibuf == 0) { - se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); - if (se->ibuf) { - use_preprocess = TRUE; - } - } + int rendering = G.rendering; + int doseq; + int doseq_gl= G.rendering ? /*(scene->r.seq_flag & R_SEQ_GL_REND)*/ 0 : (scene->r.seq_flag & R_SEQ_GL_PREV); + int have_seq= FALSE; + Scene *sce= seq->scene;// *oldsce= scene; + int sce_valid= FALSE; - if(se->ibuf == 0) { - /* if any inputs are rectfloat, output is float too */ - if((se->se1 && se->se1->ibuf && se->se1->ibuf->rect_float) || - (se->se2 && se->se2->ibuf && se->se2->ibuf->rect_float) || - (se->se3 && se->se3->ibuf && se->se3->ibuf->rect_float)) - se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); - else - se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect, 0); - - do_effect(scene, cfra, seq, se, render_size); - if (input_have_to_preprocess(scene, seq, se, cfra, - seqrectx, seqrecty) && - !build_proxy_run) { - if ((se->se1 && (se->ibuf == se->se1->ibuf)) || - (se->se2 && (se->ibuf == se->se2->ibuf))) { - struct ImBuf * i - = IMB_dupImBuf(se->ibuf); - - IMB_freeImBuf(se->ibuf); - - se->ibuf = i; - } - use_preprocess = TRUE; - } - } - if (use_preprocess) { - input_preprocess(scene, seq, se, cfra, seqrectx, - seqrecty); - } - } else if(seq->type == SEQ_IMAGE) { - if(se->ok == STRIPELEM_OK && se->ibuf == 0) { - StripElem * s_elem = give_stripelem(seq, cfra); - BLI_join_dirfile(name, seq->strip->dir, s_elem->name); - BLI_path_abs(name, G.sce); - if (!build_proxy_run) { - se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); - } - copy_from_ibuf_still(seq, se); + have_seq= (sce->r.scemode & R_DOSEQ) + && sce->ed && sce->ed->seqbase.first; - if (se->ibuf==NULL && (se->ibuf= IMB_loadiffname(name, IB_rect))) { - /* we don't need both (speed reasons)! */ - if (se->ibuf->rect_float && se->ibuf->rect) - imb_freerectImBuf(se->ibuf); + if(sce) { + sce_valid= (sce->camera || have_seq); + } - /* all sequencer color is done in SRGB space, linear gives odd crossfades */ - if(se->ibuf->profile == IB_PROFILE_LINEAR_RGB) - IMB_convert_profile(se->ibuf, IB_PROFILE_NONE); + if (!sce_valid) { + return 0; + } - copy_to_ibuf_still(seq, se); - } - - if(se->ibuf == 0) { - se->ok = STRIPELEM_FAILED; - } else if (!build_proxy_run) { - input_preprocess(scene, seq, se, cfra, - seqrectx, seqrecty); - } - } - } else if(seq->type == SEQ_MOVIE) { - if(se->ok == STRIPELEM_OK && se->ibuf==0) { - if(!build_proxy_run) { - se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); - } - copy_from_ibuf_still(seq, se); - - if (se->ibuf == 0) { - if(seq->anim==0) { - BLI_join_dirfile(name, seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(name, G.sce); - - seq->anim = openanim( - name, IB_rect | - ((seq->flag & SEQ_FILTERY) - ? IB_animdeinterlace : 0)); - } - if(seq->anim) { - IMB_anim_set_preseek(seq->anim, seq->anim_preseek); - se->ibuf = IMB_anim_absolute(seq->anim, se->nr + seq->anim_startofs); - /* we don't need both (speed reasons)! */ - if (se->ibuf - && se->ibuf->rect_float - && se->ibuf->rect) { - imb_freerectImBuf(se->ibuf); - } - - } - copy_to_ibuf_still(seq, se); + + /* prevent eternal loop */ + doseq= scene->r.scemode & R_DOSEQ; + scene->r.scemode &= ~R_DOSEQ; + + seq->scene->r.cfra= frame; + if(seq->scene_camera) + seq->scene->camera= seq->scene_camera; + else + scene_camera_switch_update(seq->scene); + +#ifdef DURIAN_CAMERA_SWITCH + /* stooping to new low's in hackyness :( */ + oldmarkers= seq->scene->markers; + seq->scene->markers.first= seq->scene->markers.last= NULL; +#endif + + if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) { + /* opengl offscreen render */ + scene_update_for_newframe(seq->scene, seq->scene->lay); + ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, + scene->r.seq_prev_type); + } + else { + Render *re; + RenderResult rres; + + if(rendering) + re= RE_NewRender(" do_build_seq_ibuf"); + else + re= RE_NewRender(sce->id.name); + + RE_BlenderFrame(re, sce, NULL, sce->lay, frame); + + RE_AcquireResultImage(re, &rres); + + if(rres.rectf) { + ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); + memcpy(ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty); + if(rres.rectz) { + addzbuffloatImBuf(ibuf); + memcpy(ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty); } - if(se->ibuf == 0) { - se->ok = STRIPELEM_FAILED; - } else if (!build_proxy_run) { - input_preprocess(scene, seq, se, cfra, - seqrectx, seqrecty); - } - } - } else if(seq->type == SEQ_SCENE) { // scene can be NULL after deletions - Scene *sce= seq->scene;// *oldsce= scene; - int have_seq= FALSE; - int sce_valid= FALSE; - - if(sce) { - have_seq= (sce->r.scemode & R_DOSEQ) && sce->ed && sce->ed->seqbase.first; - sce_valid= (sce->camera || have_seq); - } - - if (se->ibuf == NULL && sce_valid && !build_proxy_run) { - se->ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); - if (se->ibuf) { - input_preprocess(scene, seq, se, cfra, - seqrectx, seqrecty); - } - } - - if (se->ibuf == NULL && sce_valid) { - copy_from_ibuf_still(seq, se); - if (se->ibuf) { - input_preprocess(scene, seq, se, cfra, - seqrectx, seqrecty); - } + /* { + ImBuf *imb= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); + IMB_saveiff(imb, "/tmp/foo.image", IB_rect | IB_metadata); + IMB_freeImBuf(imb); + } */ + + } else if (rres.rect32) { + ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0); + memcpy(ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty); } - if (!sce_valid) { - se->ok = STRIPELEM_FAILED; - } - else if (se->ibuf==NULL && sce_valid) { - int frame= seq->sfra + se->nr + seq->anim_startofs; - int oldcfra = seq->scene->r.cfra; - Object *oldcamera= seq->scene->camera; - ListBase oldmarkers; - - /* Hack! This function can be called from do_render_seq(), in that case - the seq->scene can already have a Render initialized with same name, - so we have to use a default name. (compositor uses scene name to - find render). - However, when called from within the UI (image preview in sequencer) - we do want to use scene Render, that way the render result is defined - for display in render/imagewindow - - Hmm, don't see, why we can't do that all the time, - and since G.rendering is uhm, gone... (Peter) - */ - - int rendering = G.rendering; - int doseq; - int doseq_gl= G.rendering ? /*(scene->r.seq_flag & R_SEQ_GL_REND)*/ 0 : (scene->r.seq_flag & R_SEQ_GL_PREV); - - /* prevent eternal loop */ - doseq= scene->r.scemode & R_DOSEQ; - scene->r.scemode &= ~R_DOSEQ; - - seq->scene->r.cfra= frame; - if(seq->scene_camera) seq->scene->camera= seq->scene_camera; - else scene_camera_switch_update(seq->scene); - + RE_ReleaseResultImage(re); + + // BIF_end_render_callbacks(); + } + + /* restore */ + scene->r.scemode |= doseq; + + seq->scene->r.cfra = oldcfra; + seq->scene->camera= oldcamera; + #ifdef DURIAN_CAMERA_SWITCH - /* stooping to new low's in hackyness :( */ - oldmarkers= seq->scene->markers; - seq->scene->markers.first= seq->scene->markers.last= NULL; + /* stooping to new low's in hackyness :( */ + seq->scene->markers= oldmarkers; #endif - if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) { - /* opengl offscreen render */ - scene_update_for_newframe(seq->scene, seq->scene->lay); - se->ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, scene->r.seq_prev_type); - } - else { - Render *re; - RenderResult rres; + return ibuf; +} - if(rendering) - re= RE_NewRender(" do_build_seq_ibuf"); - else - re= RE_NewRender(sce->id.name); +static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra, + int render_size, + int seqrectx, int seqrecty) +{ + char name[FILE_MAXDIR+FILE_MAXFILE]; + int use_preprocess = input_have_to_preprocess( + scene, seq, cfra, seqrectx, seqrecty); + ImBuf * ibuf = seq_stripelem_cache_get( + seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF); + float nr = give_stripelem_index(seq, cfra); - RE_BlenderFrame(re, sce, NULL, sce->lay, frame); + /* currently, we cache preprocessed images */ + if (ibuf) { + use_preprocess = FALSE; + } - RE_AcquireResultImage(re, &rres); + if(seq->type == SEQ_META) { + ImBuf * meta_ibuf = 0; - if(rres.rectf) { - se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); - memcpy(se->ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty); - if(rres.rectz) { - addzbuffloatImBuf(se->ibuf); - memcpy(se->ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty); - } + if (ibuf == 0) { + ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); + } - /* { - ImBuf *imb= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); - IMB_saveiff(imb, "/tmp/foo.image", IB_rect | IB_metadata); - IMB_freeImBuf(imb); - } */ + if(!ibuf && seq->seqbase.first) { + meta_ibuf = seq_render_strip_stack( + scene, + &seq->seqbase, seq->start + nr, 0, + render_size, seqrectx, seqrecty); + } - } else if (rres.rect32) { - se->ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0); - memcpy(se->ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty); - } + if(!ibuf && meta_ibuf) { + ibuf = meta_ibuf; + if(ibuf && use_preprocess) { + struct ImBuf * i = IMB_dupImBuf(ibuf); - RE_ReleaseResultImage(re); + IMB_freeImBuf(ibuf); - // BIF_end_render_callbacks(); + ibuf = i; } - - /* restore */ - scene->r.scemode |= doseq; + } + } else if(seq->type == SEQ_SPEED) { + ImBuf * child_ibuf = 0; - seq->scene->r.cfra = oldcfra; - seq->scene->camera= oldcamera; + if (ibuf == 0) { + ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); + } -#ifdef DURIAN_CAMERA_SWITCH - /* stooping to new low's in hackyness :( */ - seq->scene->markers= oldmarkers; -#endif + if (ibuf == 0) { + float f_cfra; + SpeedControlVars * s + = (SpeedControlVars *)seq->effectdata; - copy_to_ibuf_still(seq, se); + sequence_effect_speed_rebuild_map(scene, seq, 0); - if (!build_proxy_run) { - if(se->ibuf == NULL) { - se->ok = STRIPELEM_FAILED; - } else { - input_preprocess(scene, seq, se, cfra, - seqrectx, seqrecty); - } - } + /* weeek! */ + f_cfra = seq->start + s->frameMap[(int) nr]; + child_ibuf = seq_render_strip(scene, seq->seq1, f_cfra, + render_size, + seqrectx, seqrecty); } - } - if (!build_proxy_run) { - if (se->ibuf && use_limiter) { - IMB_cache_limiter_insert(se->ibuf); - IMB_cache_limiter_ref(se->ibuf); - IMB_cache_limiter_touch(se->ibuf); - } - } -} -static TStripElem* do_build_seq_recursively(Scene *scene, Sequence *seq, int cfra, int render_size, int seqrectx, int seqrecty); + if (!ibuf && child_ibuf) { + ibuf = child_ibuf; + if(ibuf && use_preprocess) { + struct ImBuf * i = IMB_dupImBuf(ibuf); -static void do_effect_seq_recursively(Scene *scene, Sequence *seq, TStripElem *se, int cfra, int render_size, int seqrectx, int seqrecty) -{ - float fac, facf; - struct SeqEffectHandle sh = get_sequence_effect(seq); - int early_out; - FCurve *fcu= NULL; - - se->se1 = 0; - se->se2 = 0; - se->se3 = 0; + IMB_freeImBuf(ibuf); - if ((seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) != 0) { - sh.get_default_fac(seq, cfra, &fac, &facf); - if( scene->r.mode & R_FIELDS ); else facf= fac; - } else { - fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, - "effect_fader", 0); - if (fcu) { - fac = facf = evaluate_fcurve(fcu, cfra); - if( scene->r.mode & R_FIELDS ) { - facf = evaluate_fcurve(fcu, cfra + 0.5); + ibuf = i; } - } else { - fac = facf = seq->effect_fader; } - } - - early_out = sh.early_out(seq, fac, facf); - switch (early_out) { - case -1: - /* no input needed */ - break; - case 0: - se->se1 = do_build_seq_recursively(scene, seq->seq1, cfra, render_size, seqrectx, seqrecty); - se->se2 = do_build_seq_recursively(scene, seq->seq2, cfra, render_size, seqrectx, seqrecty); - if (seq->seq3) { - se->se3 = do_build_seq_recursively(scene, seq->seq3, cfra, render_size, seqrectx, seqrecty); + } else if(seq->type & SEQ_EFFECT) { + /* should the effect be recalculated? */ + + if (ibuf == 0) { + ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); } - break; - case 1: - se->se1 = do_build_seq_recursively(scene, seq->seq1, cfra, render_size, seqrectx, seqrecty); - break; - case 2: - se->se2 = do_build_seq_recursively(scene, seq->seq2, cfra, render_size, seqrectx, seqrecty); - break; - } - - - do_build_seq_ibuf(scene, seq, se, cfra, FALSE, render_size, seqrectx, seqrecty); - /* children are not needed anymore ... */ - - if (se->se1 && se->se1->ibuf) { - IMB_cache_limiter_unref(se->se1->ibuf); - } - if (se->se2 && se->se2->ibuf) { - IMB_cache_limiter_unref(se->se2->ibuf); - } - if (se->se3 && se->se3->ibuf) { - IMB_cache_limiter_unref(se->se3->ibuf); - } - check_limiter_refcount("do_effect_seq_recursively", se); -} - -static TStripElem* do_build_seq_recursively_impl(Scene *scene, Sequence * seq, int cfra, int render_size, int seqrectx, int seqrecty) -{ - TStripElem *se; - - se = give_tstripelem(seq, cfra); - - if(se) { - if (seq->type & SEQ_EFFECT) { - do_effect_seq_recursively(scene, seq, se, cfra, render_size, seqrectx, seqrecty); - } else { - do_build_seq_ibuf(scene, seq, se, cfra, FALSE, render_size, seqrectx, seqrecty); + if(ibuf == 0) { + ibuf = seq_render_effect_strip_impl( + scene, cfra, seq, render_size, + seqrectx, seqrecty); } - } - return se; -} - -/* FIXME: - -If cfra was float throughout blender (especially in the render -pipeline) one could even _render_ with subframe precision -instead of faking using the blend code below... - -*/ - -static TStripElem* do_handle_speed_effect(Scene *scene, Sequence * seq, int cfra, int render_size, int seqrectx, int seqrecty) -{ - SpeedControlVars * s = (SpeedControlVars *)seq->effectdata; - int nr = cfra - seq->start; - float f_cfra; - int cfra_left; - int cfra_right; - TStripElem * se = 0; - TStripElem * se1 = 0; - TStripElem * se2 = 0; - - sequence_effect_speed_rebuild_map(scene, seq, 0); - - f_cfra = seq->start + s->frameMap[nr]; - - cfra_left = (int) floor(f_cfra); - cfra_right = (int) ceil(f_cfra); + } else if(seq->type == SEQ_IMAGE) { + StripElem * s_elem = give_stripelem(seq, cfra); - se = give_tstripelem(seq, cfra); + if(ibuf == 0) { + BLI_join_dirfile(name, seq->strip->dir, s_elem->name); + BLI_path_abs(name, G.sce); - if (!se) { - return se; - } + ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); + } - if (cfra_left == cfra_right || - (s->flags & SEQ_SPEED_BLEND) == 0) { - test_and_auto_discard_ibuf(se, seqrectx, seqrecty); + if (ibuf == 0) { + ibuf = copy_from_ibuf_still(seq,nr,seqrectx,seqrecty); + } - if (se->ibuf == NULL) { - se1 = do_build_seq_recursively(scene, seq->seq1, cfra_left, render_size, seqrectx, seqrecty); + if (ibuf == 0 && (ibuf=IMB_loadiffname(name, IB_rect))) { + /* we don't need both (speed reasons)! */ + if (ibuf->rect_float && ibuf->rect) + imb_freerectImBuf(ibuf); - if((se1 && se1->ibuf && se1->ibuf->rect_float)) - se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); - else - se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect, 0); + /* all sequencer color is done in SRGB space, linear gives odd crossfades */ + if(ibuf->profile == IB_PROFILE_LINEAR_RGB) + IMB_convert_profile(ibuf, IB_PROFILE_NONE); - if (se1 == 0 || se1->ibuf == 0) { - make_black_ibuf(se->ibuf); - } else { - if (se->ibuf != se1->ibuf) { - if (se->ibuf) { - IMB_freeImBuf(se->ibuf); - } + copy_to_ibuf_still(seq, nr, ibuf); + } + } else if(seq->type == SEQ_MOVIE) { + if(ibuf == 0) { + ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); + + } + + if (ibuf == 0) { + ibuf = copy_from_ibuf_still(seq, nr,seqrectx,seqrecty); + } - se->ibuf = se1->ibuf; - IMB_refImBuf(se->ibuf); + if (ibuf == 0) { + if(seq->anim==0) { + BLI_join_dirfile(name, + seq->strip->dir, + seq->strip->stripdata->name); + BLI_path_abs(name, G.sce); + + seq->anim = openanim( + name, IB_rect | + ((seq->flag & SEQ_FILTERY) + ? IB_animdeinterlace : 0)); + } + if(seq->anim) { + IMB_anim_set_preseek(seq->anim, + seq->anim_preseek); + ibuf = IMB_anim_absolute(seq->anim, + nr + + seq->anim_startofs); + /* we don't need both (speed reasons)! */ + if (ibuf && ibuf->rect_float + && ibuf->rect) { + imb_freerectImBuf(ibuf); } - } - } - } else { - struct SeqEffectHandle sh; - if(se->ibuf) { - if(se->ibuf->x < seqrectx || se->ibuf->y < seqrecty - || !(se->ibuf->rect || se->ibuf->rect_float)) { - IMB_freeImBuf(se->ibuf); - se->ibuf= 0; } + copy_to_ibuf_still(seq, nr, ibuf); } - - if (se->ibuf == NULL) { - se1 = do_build_seq_recursively(scene, seq->seq1, cfra_left, render_size, seqrectx, seqrecty); - se2 = do_build_seq_recursively(scene, seq->seq1, cfra_right, render_size, seqrectx, seqrecty); - - if((se1 && se1->ibuf && se1->ibuf->rect_float)) - se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); - else - se->ibuf= IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect, 0); - if (!se1 || !se2) { - make_black_ibuf(se->ibuf); - } else { - sh = get_sequence_effect(seq); - - sh.execute(scene, seq, cfra, - f_cfra - (float) cfra_left, - f_cfra - (float) cfra_left, - se->ibuf->x, se->ibuf->y, - render_size, - se1->ibuf, se2->ibuf, 0, se->ibuf); - } + } else if(seq->type == SEQ_SCENE) { // scene can be NULL after deletions + if (ibuf == 0) { + ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); } + if (ibuf == 0) { + ibuf = copy_from_ibuf_still(seq, nr,seqrectx,seqrecty); + } + + if (ibuf == 0) { + ibuf = seq_render_scene_strip_impl(scene, seq, nr, + seqrectx, seqrecty); + copy_to_ibuf_still(seq, nr, ibuf); + } } - /* caller expects this to be referenced, so do it! */ - if (se->ibuf) { - IMB_cache_limiter_insert(se->ibuf); - IMB_cache_limiter_ref(se->ibuf); - IMB_cache_limiter_touch(se->ibuf); + if (!ibuf) { + ibuf = IMB_allocImBuf( + (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); } - /* children are no longer needed */ - if (se1 && se1->ibuf) - IMB_cache_limiter_unref(se1->ibuf); - if (se2 && se2->ibuf) - IMB_cache_limiter_unref(se2->ibuf); - - check_limiter_refcount("do_handle_speed_effect", se); - - return se; -} - -/* - * build all ibufs recursively - * - * if successfull, the returned TStripElem contains the (referenced!) imbuf - * that means: you _must_ call - * - * IMB_cache_limiter_unref(rval); - * - * if rval != 0 - * - */ - -static TStripElem* do_build_seq_recursively(Scene *scene, Sequence * seq, int cfra, int render_size, int seqrectx, int seqrecty) -{ - TStripElem *se; - - /* BAD HACK! Seperate handling for speed effects needed, since - a) you can't just fetch a different cfra within an effect strip - b) we have to blend two frames, and CFRA is not float... - */ - if (seq->type == SEQ_SPEED) { - se = do_handle_speed_effect(scene, seq, cfra, render_size, seqrectx, seqrecty); - } else { - se = do_build_seq_recursively_impl(scene, seq, cfra, render_size, seqrectx, seqrecty); + if (use_preprocess) { + ibuf = input_preprocess(scene, seq, cfra, seqrectx, + seqrecty, ibuf); } - check_limiter_refcount("do_build_seq_recursively", se); + seq_stripelem_cache_put( + seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF, ibuf); - return se; + return ibuf; } +/* ********************************************************************** + strip stack rendering functions + ********************************************************************** */ + static int seq_must_swap_input_in_blend_mode(Sequence * seq) { int swap_input = FALSE; @@ -2594,28 +2153,22 @@ static int seq_get_early_out_for_blend_mode(Sequence * seq) return early_out; } -static TStripElem* do_build_seq_array_recursively( - Scene *scene, ListBase *seqbasep, int cfra, int chanshown, +static ImBuf* seq_render_strip_stack( + Scene *scene, ListBase *seqbasep, float cfra, int chanshown, int render_size, int seqrectx, int seqrecty) { Sequence* seq_arr[MAXSEQ+1]; int count; int i; - TStripElem* se = 0; + ImBuf* out = 0; count = get_shown_sequences(seqbasep, cfra, chanshown, - (Sequence **)&seq_arr); + (Sequence **)&seq_arr); if (!count) { return 0; } - se = give_tstripelem(seq_arr[count - 1], cfra); - - if (!se) { - return 0; - } - #if 0 /* commentind since this breaks keyframing, since it resets the value on draw */ if(scene->r.cfra != cfra) { // XXX for prefetch and overlay offset!..., very bad!!! @@ -2624,25 +2177,24 @@ static TStripElem* do_build_seq_array_recursively( } #endif - test_and_auto_discard_ibuf(se, seqrectx, seqrecty); + out = seq_stripelem_cache_get( + seq_arr[count - 1], + seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP); - if (se->ibuf_comp != 0) { - IMB_cache_limiter_insert(se->ibuf_comp); - IMB_cache_limiter_ref(se->ibuf_comp); - IMB_cache_limiter_touch(se->ibuf_comp); - return se; + if (out) { + return out; } - if(count == 1) { - se = do_build_seq_recursively(scene, seq_arr[0], - cfra, render_size, - seqrectx, seqrecty); - if (se->ibuf) { - se->ibuf_comp = se->ibuf; - IMB_refImBuf(se->ibuf_comp); - } - return se; + out = seq_render_strip(scene, seq_arr[0], + cfra, render_size, + seqrectx, seqrecty); + seq_stripelem_cache_put( + seq_arr[0], + seqrectx, seqrecty, cfra, + SEQ_STRIPELEM_IBUF_COMP, out); + + return out; } @@ -2650,29 +2202,17 @@ static TStripElem* do_build_seq_array_recursively( int early_out; Sequence * seq = seq_arr[i]; - se = give_tstripelem(seq, cfra); - - test_and_auto_discard_ibuf(se, seqrectx, seqrecty); + out = seq_stripelem_cache_get( + seq, + seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP); - if (se->ibuf_comp != 0) { + if (out) { break; } if (seq->blend_mode == SEQ_BLEND_REPLACE) { - do_build_seq_recursively( - scene, seq, cfra, render_size, - seqrectx, seqrecty); - - if (se->ibuf) { - se->ibuf_comp = se->ibuf; - IMB_refImBuf(se->ibuf); - } else { - se->ibuf_comp = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, - 32, IB_rect, 0); - IMB_cache_limiter_insert(se->ibuf_comp); - IMB_cache_limiter_ref(se->ibuf_comp); - IMB_cache_limiter_touch(se->ibuf_comp); - } + out = seq_render_strip(scene, seq, cfra, + render_size, + seqrectx, seqrecty); break; } @@ -2681,154 +2221,111 @@ static TStripElem* do_build_seq_array_recursively( switch (early_out) { case -1: case 2: - do_build_seq_recursively( - scene, seq, cfra, render_size, - seqrectx, seqrecty); - - if (se->ibuf) { - se->ibuf_comp = se->ibuf; - IMB_refImBuf(se->ibuf_comp); - } else { - se->ibuf_comp = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, - 32, IB_rect, 0); - IMB_cache_limiter_insert(se->ibuf_comp); - IMB_cache_limiter_ref(se->ibuf_comp); - IMB_cache_limiter_touch(se->ibuf_comp); - } + out = seq_render_strip(scene, seq, cfra, + render_size, + seqrectx, seqrecty); break; case 1: if (i == 0) { - se->ibuf_comp = IMB_allocImBuf( + out = IMB_allocImBuf( (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); - IMB_cache_limiter_insert(se->ibuf_comp); - IMB_cache_limiter_ref(se->ibuf_comp); - IMB_cache_limiter_touch(se->ibuf_comp); } break; case 0: - do_build_seq_recursively( - scene, seq, cfra, render_size, - seqrectx, seqrecty); - - if (!se->ibuf) { - se->ibuf = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, - 32, IB_rect, 0); - IMB_cache_limiter_insert(se->ibuf); - IMB_cache_limiter_ref(se->ibuf); - IMB_cache_limiter_touch(se->ibuf); - } if (i == 0) { - se->ibuf_comp = se->ibuf; - IMB_refImBuf(se->ibuf_comp); + out = seq_render_strip(scene, seq, cfra, + render_size, + seqrectx, seqrecty); } + break; } - - if (se->ibuf_comp) { + if (out) { break; } } + seq_stripelem_cache_put( + seq_arr[i], seqrectx, seqrecty, cfra, + SEQ_STRIPELEM_IBUF_COMP, out); + + i++; for (; i < count; i++) { Sequence * seq = seq_arr[i]; - struct SeqEffectHandle sh = get_sequence_blend(seq); - TStripElem* se1 = give_tstripelem(seq_arr[i-1], cfra); - TStripElem* se2 = give_tstripelem(seq_arr[i], cfra); - float facf = seq->blend_opacity / 100.0; - int swap_input = seq_must_swap_input_in_blend_mode(seq); - int early_out = seq_get_early_out_for_blend_mode(seq); + if (seq_get_early_out_for_blend_mode(seq) == 0) { + struct SeqEffectHandle sh = get_sequence_blend(seq); + ImBuf * ibuf1 = out; + ImBuf * ibuf2 = seq_render_strip(scene, seq, cfra, + render_size, + seqrectx, seqrecty); - switch (early_out) { - case 0: { - int x= se2->ibuf->x; - int y= se2->ibuf->y; + float facf = seq->blend_opacity / 100.0; + int swap_input + = seq_must_swap_input_in_blend_mode(seq); - if(se1->ibuf_comp == NULL) - continue; + int x= out->x; + int y= out->y; - if (se1->ibuf_comp->rect_float || - se2->ibuf->rect_float) { - se2->ibuf_comp = IMB_allocImBuf( + if (ibuf1->rect_float || ibuf2->rect_float) { + out = IMB_allocImBuf( (short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); } else { - se2->ibuf_comp = IMB_allocImBuf( + out = IMB_allocImBuf( (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); } - - if (!se1->ibuf_comp->rect_float && - se2->ibuf_comp->rect_float) { - IMB_float_from_rect_simple(se1->ibuf_comp); + if (!ibuf1->rect_float && out->rect_float) { + IMB_float_from_rect_simple(ibuf1); } - if (!se2->ibuf->rect_float && - se2->ibuf_comp->rect_float) { - IMB_float_from_rect_simple(se2->ibuf); + if (!ibuf2->rect_float && out->rect_float) { + IMB_float_from_rect_simple(ibuf2); } - if (!se1->ibuf_comp->rect && - !se2->ibuf_comp->rect_float) { - IMB_rect_from_float(se1->ibuf_comp); + if (!ibuf1->rect && !out->rect_float) { + IMB_rect_from_float(ibuf1); } - if (!se2->ibuf->rect && - !se2->ibuf_comp->rect_float) { - IMB_rect_from_float(se2->ibuf); + if (!ibuf2->rect && !out->rect_float) { + IMB_rect_from_float(ibuf2); } if (swap_input) { sh.execute(scene, seq, cfra, facf, facf, x, y, render_size, - se2->ibuf, se1->ibuf_comp, 0, - se2->ibuf_comp); + ibuf2, ibuf1, 0, out); } else { sh.execute(scene, seq, cfra, facf, facf, x, y, render_size, - se1->ibuf_comp, se2->ibuf, 0, - se2->ibuf_comp); + ibuf1, ibuf2, 0, out); } - - IMB_cache_limiter_insert(se2->ibuf_comp); - IMB_cache_limiter_ref(se2->ibuf_comp); - IMB_cache_limiter_touch(se2->ibuf_comp); - - IMB_cache_limiter_unref(se1->ibuf_comp); - IMB_cache_limiter_unref(se2->ibuf); - - break; + + IMB_freeImBuf(ibuf1); + IMB_freeImBuf(ibuf2); } - case 1: { - se2->ibuf_comp = se1->ibuf_comp; - if(se2->ibuf_comp) - IMB_refImBuf(se2->ibuf_comp); - break; - } - } - se = se2; + seq_stripelem_cache_put( + seq_arr[i], seqrectx, seqrecty, cfra, + SEQ_STRIPELEM_IBUF_COMP, out); } - return se; + return out; } /* * returned ImBuf is refed! - * you have to unref after usage! + * you have to free after usage! */ -static ImBuf *give_ibuf_seq_impl(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size) +ImBuf *give_ibuf_seq(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size) { Editing *ed= seq_give_editing(scene, FALSE); int count; ListBase *seqbasep; - TStripElem *se; - if(ed==NULL) return NULL; @@ -2840,64 +2337,19 @@ static ImBuf *give_ibuf_seq_impl(Scene *scene, int rectx, int recty, int cfra, i seqbasep= ed->seqbasep; } - se = do_build_seq_array_recursively(scene, seqbasep, cfra, chanshown, render_size, rectx, recty); - - if(!se) { - return 0; - } - - check_limiter_refcount_comp("give_ibuf_seq_impl", se); - - return se->ibuf_comp; + return seq_render_strip_stack( + scene, seqbasep, cfra, chanshown, render_size, rectx, recty); } ImBuf *give_ibuf_seqbase(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size, ListBase *seqbasep) { - TStripElem *se; - - se = do_build_seq_array_recursively(scene, seqbasep, cfra, chanshown, render_size, rectx, recty); - - if(!se) { - return 0; - } - - check_limiter_refcount_comp("give_ibuf_seqbase", se); - - if (se->ibuf_comp) { - IMB_cache_limiter_unref(se->ibuf_comp); - } - - return se->ibuf_comp; + return seq_render_strip_stack(scene, seqbasep, cfra, chanshown, render_size, rectx, recty); } ImBuf *give_ibuf_seq_direct(Scene *scene, int rectx, int recty, int cfra, int render_size, Sequence *seq) { - TStripElem* se; - - se = do_build_seq_recursively(scene, seq, cfra, render_size, rectx, recty); - - if(!se) { - return 0; - } - - check_limiter_refcount("give_ibuf_seq_direct", se); - - if (se->ibuf) { - IMB_cache_limiter_unref(se->ibuf); - } - - return se->ibuf; -} - -ImBuf *give_ibuf_seq(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size) -{ - ImBuf* i = give_ibuf_seq_impl(scene, rectx, recty, cfra, chanshown, render_size); - - if (i) { - IMB_cache_limiter_unref(i); - } - return i; + return seq_render_strip(scene, seq, cfra, render_size, rectx, recty); } #if 0 @@ -3246,20 +2698,6 @@ ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int /* Functions to free imbuf and anim data on changes */ -static void free_imbuf_strip_elem(TStripElem *se) -{ - if(se->ibuf) { - IMB_freeImBuf(se->ibuf); - } - if(se->ibuf_comp) { - IMB_freeImBuf(se->ibuf_comp); - } - se->ibuf_comp = 0; - se->ibuf= 0; - se->ok= STRIPELEM_OK; - se->se1= se->se2= se->se3= 0; -} - static void free_anim_seq(Sequence *seq) { if(seq->anim) { @@ -3272,8 +2710,6 @@ void free_imbuf_seq(Scene *scene, ListBase * seqbase, int check_mem_usage, int keep_file_handles) { Sequence *seq; - TStripElem *se; - int a; if (check_mem_usage) { /* Let the cache limitor take care of this (schlaile) */ @@ -3299,31 +2735,10 @@ void free_imbuf_seq(Scene *scene, ListBase * seqbase, int check_mem_usage, } } + seq_stripelem_cache_cleanup(); for(seq= seqbase->first; seq; seq= seq->next) { if(seq->strip) { - for(a = 0, se = seq->strip->tstripdata; - a < seq->strip->len && se; a++, se++) { - free_imbuf_strip_elem(se); - } - for(a = 0, se = seq->strip->tstripdata_startstill; - a < seq->strip->startstill && se; a++, se++) { - free_imbuf_strip_elem(se); - } - for(a = 0, se = seq->strip->tstripdata_endstill; - a < seq->strip->endstill && se; a++, se++) { - free_imbuf_strip_elem(se); - } - if(seq->strip->ibuf_startstill) { - IMB_freeImBuf(seq->strip->ibuf_startstill); - seq->strip->ibuf_startstill = 0; - } - - if(seq->strip->ibuf_endstill) { - IMB_freeImBuf(seq->strip->ibuf_endstill); - seq->strip->ibuf_endstill = 0; - } - if(seq->type==SEQ_MOVIE && !keep_file_handles) free_anim_seq(seq); if(seq->type==SEQ_SPEED) { @@ -3345,8 +2760,7 @@ void free_imbuf_seq(Scene *scene, ListBase * seqbase, int check_mem_usage, static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *changed_seq, int len_change, int ibuf_change) { Sequence *subseq; - int a, free_imbuf = 0; - TStripElem *se; + int free_imbuf = 0; /* recurs downwards to see if this seq depends on the changed seq */ @@ -3372,12 +2786,6 @@ static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *chan if(free_imbuf) { if(ibuf_change) { - se= seq->strip->tstripdata; - if (se) { - for(a=0; alen; a++, se++) - free_imbuf_strip_elem(se); - } - if(seq->type == SEQ_MOVIE) free_anim_seq(seq); if(seq->type == SEQ_SPEED) { @@ -3403,39 +2811,6 @@ void update_changed_seq_and_deps(Scene *scene, Sequence *changed_seq, int len_ch update_changed_seq_recurs(scene, seq, changed_seq, len_change, ibuf_change); } -#if 0 // XXX from 2.4x, needs updating -void free_imbuf_seq() -{ - Scene * sce = G.main->scene.first; - while(sce) { - free_imbuf_seq_editing(sce->ed); - sce= sce->id.next; - } -} -#endif - -#if 0 // XXX old animation system -static void free_imbuf_seq_with_ipo(Scene *scene, struct Ipo *ipo) -{ - /* force update of all sequences with this ipo, on ipo changes */ - Editing *ed= seq_give_editing(scene, FALSE); - Sequence *seq; - - if(ed==NULL) return; - - SEQ_BEGIN(ed, seq) { - if(seq->ipo == ipo) { - update_changed_seq_and_deps(scene, seq, 0, 1); - if(seq->type == SEQ_SPEED) { - sequence_effect_speed_rebuild_map(seq, 1); - } - free_proxy_seq(seq); - } - } - SEQ_END -} -#endif - /* seq funcs's for transforming internally notice the difference between start/end and left/right. -- cgit v1.2.3 From 7275ba728df01a965706d1119b6bed7210820fa3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 23 Jul 2010 18:42:15 +0000 Subject: fix for another case where object editmode data could be lost when switching scenes. --- source/blender/blenkernel/intern/scene.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index fe52375617b..9d736bd92eb 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -512,6 +512,10 @@ void set_scene_bg(Scene *scene) /* check for cyclic sets, for reading old files but also for definite security (py?) */ scene_check_setscene(scene); + /* can happen when switching modes in other scenes */ + if(scene->obedit && !(scene->obedit->mode & OB_MODE_EDIT)) + scene->obedit= NULL; + /* deselect objects (for dataselect) */ for(ob= G.main->object.first; ob; ob= ob->id.next) ob->flag &= ~(SELECT|OB_FROMGROUP); -- cgit v1.2.3 From c36fcf51167a881bc4aaa21c82d77e1965fc884a Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Fri, 23 Jul 2010 19:43:13 +0000 Subject: SVN maintenance. --- source/blender/blenkernel/intern/seqcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index c2b689195f6..9c72b7af0be 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -1,5 +1,5 @@ /** -* $Id: seqcache.c 29923 2010-07-04 10:51:10Z schlaile $ +* $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * -- cgit v1.2.3 From f24bcc689cb1d97b3ddbce00f99231e9779f2b98 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 24 Jul 2010 02:51:51 +0000 Subject: bugfix [#22988] Duplicating Lights by Frame Causes Hangup --- source/blender/blenkernel/intern/pointcache.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 5295a496d2b..ced5d116ad0 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1041,11 +1041,13 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup if((lb_dupli_ob=object_duplilist(scene, ob))) { DupliObject *dob; for(dob= lb_dupli_ob->first; dob; dob= dob->next) { - ListBase lb_dupli_pid; - BKE_ptcache_ids_from_object(&lb_dupli_pid, dob->ob, scene, duplis); - addlisttolist(lb, &lb_dupli_pid); - if(lb_dupli_pid.first) - printf("Adding Dupli\n"); + if(dob->ob != ob) { /* avoids recursive loops with dupliframes: bug 22988 */ + ListBase lb_dupli_pid; + BKE_ptcache_ids_from_object(&lb_dupli_pid, dob->ob, scene, duplis); + addlisttolist(lb, &lb_dupli_pid); + if(lb_dupli_pid.first) + printf("Adding Dupli\n"); + } } free_object_duplilist(lb_dupli_ob); /* does restore */ -- cgit v1.2.3 From 068b0c3f6f99f2717122e1e9e776330459cfc303 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Sat, 24 Jul 2010 05:53:30 +0000 Subject: Fix [#22965] Icons for new brushes won't get sticky Somehow the code I submitted to fix this problem was commented out. I think I just submitted the wrong code. --- source/blender/blenkernel/intern/brush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 8670665a1ac..1536c394726 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -132,7 +132,7 @@ Brush *copy_brush(Brush *brush) if (brush->mtex.tex) id_us_plus((ID*)brush->mtex.tex); - //brushn->preview= NULL; + brushn->preview= NULL; if (brush->icon_imbuf) brushn->icon_imbuf= IMB_dupImBuf(brush->icon_imbuf); -- cgit v1.2.3 From 0246caf51337ad65b27d0211de036b0bda153397 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Sat, 24 Jul 2010 07:18:31 +0000 Subject: * Fix: the radius of the brush is bigger than the texture square in the UV image editor so it is always drawing a square at stronger intensity. --- source/blender/blenkernel/intern/brush.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 1536c394726..23a221cadf4 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -132,8 +132,6 @@ Brush *copy_brush(Brush *brush) if (brush->mtex.tex) id_us_plus((ID*)brush->mtex.tex); - brushn->preview= NULL; - if (brush->icon_imbuf) brushn->icon_imbuf= IMB_dupImBuf(brush->icon_imbuf); @@ -483,7 +481,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf typedef struct BrushPainterCache { short enabled; - int size; /* size override, if 0 uses brush_size(brush) */ + int size; /* size override, if 0 uses 2*brush_size(brush) */ short flt; /* need float imbuf? */ short texonly; /* no alpha, color or fallof, only texture in imbuf */ @@ -720,10 +718,10 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos) MTex *mtex= &brush->mtex; int size; short flt; - const int radius= brush_size(brush); + const int diameter= 2*brush_size(brush); const float alpha= brush_alpha(brush); - if (radius != cache->lastsize || + if (diameter != cache->lastsize || alpha != cache->lastalpha || brush->jitter != cache->lastjitter) { @@ -737,7 +735,7 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos) } flt= cache->flt; - size= (cache->size)? cache->size: radius; + size= (cache->size)? cache->size: diameter; if (!(mtex && mtex->tex) || (mtex->tex->type==0)) { brush_imbuf_new(brush, flt, 0, size, &cache->ibuf); @@ -749,7 +747,7 @@ static void brush_painter_refresh_cache(BrushPainter *painter, float *pos) else brush_imbuf_new(brush, flt, 2, size, &cache->ibuf); - cache->lastsize= radius; + cache->lastsize= diameter; cache->lastalpha= alpha; cache->lastjitter= brush->jitter; } @@ -784,6 +782,7 @@ void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos) if(brush->jitter){ float rand_pos[2]; const int radius= brush_size(brush); + const int diameter= 2*radius; // find random position within a circle of diameter 1 do { @@ -791,8 +790,8 @@ void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos) rand_pos[1] = BLI_frand()-0.5f; } while (len_v2(rand_pos) > 0.5f); - jitterpos[0] = pos[0] + 2*rand_pos[0]*radius*brush->jitter; - jitterpos[1] = pos[1] + 2*rand_pos[1]*radius*brush->jitter; + jitterpos[0] = pos[0] + 2*rand_pos[0]*diameter*brush->jitter; + jitterpos[1] = pos[1] + 2*rand_pos[1]*diameter*brush->jitter; } else { VECCOPY2D(jitterpos, pos); @@ -831,7 +830,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl double starttime, curtime= time; /* compute brush spacing adapted to brush size */ - spacing= brush->rate; //brush_size(brush)*brush->spacing*0.01f; + spacing= brush->rate; //radius*brush->spacing*0.01f; /* setup starting time, direction vector and accumulated time */ starttime= painter->accumtime; @@ -863,6 +862,7 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl float startdistance, spacing, step, paintpos[2], dmousepos[2], finalpos[2]; float t, len, press; const int radius= brush_size(brush); + const int diameter= 2*radius; /* compute brush spacing adapted to brush radius, spacing may depend on pressure, so update it */ @@ -1239,7 +1239,7 @@ void brush_set_size(Brush *brush, int size) else brush->size= size; - //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_size(Brush *brush) @@ -1259,7 +1259,7 @@ void brush_set_use_locked_size(Brush *brush, int value) brush->flag &= ~BRUSH_LOCK_SIZE; } - //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_use_locked_size(Brush *brush) @@ -1279,7 +1279,7 @@ void brush_set_use_size_pressure(Brush *brush, int value) brush->flag &= ~BRUSH_SIZE_PRESSURE; } - //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_use_size_pressure(Brush *brush) @@ -1299,7 +1299,7 @@ void brush_set_use_alpha_pressure(Brush *brush, int value) brush->flag &= ~BRUSH_ALPHA_PRESSURE; } - //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_use_alpha_pressure(Brush *brush) @@ -1314,7 +1314,7 @@ void brush_set_unprojected_radius(Brush *brush, float unprojected_radius) else brush->unprojected_radius= unprojected_radius; - //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } float brush_unprojected_radius(Brush *brush) @@ -1329,7 +1329,7 @@ void brush_set_alpha(Brush *brush, float alpha) else brush->alpha= alpha; - //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } float brush_alpha(Brush *brush) -- cgit v1.2.3 From 1e816635b0c42ed0912807c77eb8e5685e5c7995 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sat, 24 Jul 2010 08:47:14 +0000 Subject: Bugfix: Small change to hash algorithm hinted by James Ruan on mailing list to make hash distribution a little bit better. --- source/blender/blenkernel/intern/seqcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 9c72b7af0be..4d58ec8212a 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -68,7 +68,7 @@ static unsigned int HashHash(void *key_) rval ^= *(unsigned int*) &key->cfra; rval += key->type; - rval ^= (unsigned int) key->seq; + rval ^= ((unsigned int) key->seq) << 6; return rval; } -- cgit v1.2.3 From 6a4d370a16193b5590ff39f05e0823d0744a4c80 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sat, 24 Jul 2010 19:42:29 +0000 Subject: Bugfix: the sequencer core rewrite missed preprocessing of images with wrong resolution on input, which can create image distortion and crashes on render. Thanks to Juan Pablo Bouza for spotting this one! --- source/blender/blenkernel/intern/sequencer.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 5f41debbbe9..bbc50490ab7 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2102,6 +2102,10 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra, (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); } + if (ibuf->x != seqrectx || ibuf->y != seqrecty) { + use_preprocess = TRUE; + } + if (use_preprocess) { ibuf = input_preprocess(scene, seq, cfra, seqrectx, seqrecty, ibuf); -- cgit v1.2.3 From 885bbe699976318a6d90441d46dc0cd43e16d4a2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 25 Jul 2010 01:45:53 +0000 Subject: from Luca's recent commit noticed there are more typo's: lenght -> length --- source/blender/blenkernel/intern/seqeffects.c | 2 +- source/blender/blenkernel/intern/softbody.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index efebca0f780..151fc1c407c 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -827,7 +827,7 @@ static void makeGammaTables(float gamma) /* The end of the table should match 1.0 carefully. In order to avoid */ /* rounding errors, we just set this explicitly. The last segment may */ - /* have a different lenght than the other segments, but our */ + /* have a different length than the other segments, but our */ /* interpolation is insensitive to that. */ color_domain_table[RE_GAMMA_TABLE_SIZE] = 1.0; gamma_range_table[RE_GAMMA_TABLE_SIZE] = 1.0; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index c82595ee2b2..4d1994e760b 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3226,7 +3226,7 @@ static void get_scalar_from_vertexgroup(Object *ob, int vertID, short groupindex } /* Resetting a Mesh SB object's springs */ -/* Spring lenght are caculted from'raw' mesh vertices that are NOT altered by modifier stack. */ +/* Spring length are caculted from'raw' mesh vertices that are NOT altered by modifier stack. */ static void springs_from_mesh(Object *ob) { SoftBody *sb; @@ -3362,7 +3362,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) add_2nd_order_springs(ob,sb->secondspring); /* exploits the the first run of build_bps_springlist(ob);*/ build_bps_springlist(ob); /* yes we need to do it again*/ } - springs_from_mesh(ob); /* write the 'rest'-lenght of the springs */ + springs_from_mesh(ob); /* write the 'rest'-length of the springs */ if (ob->softflag & OB_SB_SELF) {calculate_collision_balls(ob);} } -- cgit v1.2.3 From cc0f3146e798479be0758b5c152ef67ef42ea8dc Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 25 Jul 2010 11:57:36 +0000 Subject: Shapekeys for curves/surfeces Fix #21498: Edit curve Shape key /252_r 27318 Added full support of shape keys for curves and nurbs surfaces including topology changing in edit mode, undo stuff, updating relative keys when working under basis and so on. --- source/blender/blenkernel/intern/anim.c | 12 ++- source/blender/blenkernel/intern/curve.c | 26 +++-- source/blender/blenkernel/intern/displist.c | 17 ++-- source/blender/blenkernel/intern/key.c | 151 +++++++++++++++++----------- source/blender/blenkernel/intern/object.c | 13 ++- 5 files changed, 129 insertions(+), 90 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 157c0743c50..412084f7cd1 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -66,6 +66,8 @@ #include "BKE_utildefines.h" #include "BKE_depsgraph.h" +#include "ED_curve.h" /* for ED_curve_nurbs */ + // XXX bad level call... /* --------------------- */ @@ -458,17 +460,17 @@ void calc_curvepath(Object *ob) float *fp, *dist, *maxdist, xyz[3]; float fac, d=0, fac1, fac2; int a, tot, cycl=0; + ListBase *nurbs; /* in a path vertices are with equal differences: path->len = number of verts */ /* NOW WITH BEVELCURVE!!! */ if(ob==NULL || ob->type != OB_CURVE) return; cu= ob->data; - if(cu->editnurb) - nu= cu->editnurb->first; - else - nu= cu->nurb.first; - + + nurbs= BKE_curve_nurbs(cu); + nu= nurbs->first; + if(cu->path) free_path(cu->path); cu->path= NULL; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index d355a520a8c..4142ad7128f 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -58,6 +58,8 @@ #include "BKE_object.h" #include "BKE_utildefines.h" // VECCOPY +#include "ED_curve.h" + /* globals */ /* local */ @@ -104,13 +106,8 @@ void free_curve(Curve *cu) BLI_freelistN(&cu->bev); freedisplist(&cu->disp); BKE_free_editfont(cu); - - if(cu->editnurb) { - freeNurblist(cu->editnurb); - MEM_freeN(cu->editnurb); - cu->editnurb= NULL; - } + free_curve_editNurb(cu); unlink_curve(cu); BKE_free_animdata((ID *)cu); @@ -2008,8 +2005,10 @@ void makeBevelList(Object *ob) /* STEP 1: MAKE POLYS */ BLI_freelistN(&(cu->bev)); - if(cu->editnurb && ob->type!=OB_FONT) nu= cu->editnurb->first; - else nu= cu->nurb.first; + if(cu->editnurb && ob->type!=OB_FONT) { + ListBase *nurbs= ED_curve_editnurbs(cu); + nu= nurbs->first; + } else nu= cu->nurb.first; while(nu) { @@ -2999,7 +2998,7 @@ float (*curve_getKeyVertexCos(Curve *cu, ListBase *lb, float *key))[3] VECCOPY(co, key); co+=3; key+=3; VECCOPY(co, key); co+=3; key+=3; VECCOPY(co, key); co+=3; key+=3; - key++; /* skip tilt */ + key+=3; /* skip tilt */ } } else { @@ -3099,5 +3098,12 @@ int clamp_nurb_order_v( struct Nurb *nu) return change; } +/* Get edit nurbs or normal nurbs list */ +ListBase *BKE_curve_nurbs(Curve *cu) +{ + if (cu->editnurb) { + return ED_curve_editnurbs(cu); + } - + return &cu->nurb; +} diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index bb020c936a6..ca659faa972 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -63,6 +63,7 @@ #include "BLO_sys_types.h" // for intptr_t support +#include "ED_curve.h" /* for BKE_curve_nurbs */ static void boundbox_displist(Object *ob); @@ -1221,7 +1222,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *preTesselatePoint; Curve *cu= ob->data; - ListBase *nurb= cu->editnurb?cu->editnurb:&cu->nurb; + ListBase *nurb= BKE_curve_nurbs(cu); int numVerts = 0; int editmode = (!forRender && cu->editnurb); float (*originalVerts)[3] = NULL; @@ -1324,8 +1325,9 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *preTesselatePoint; Curve *cu= ob->data; - ListBase *nurb= cu->editnurb?cu->editnurb:&cu->nurb; - int required_mode, totvert = 0; + ListBase *nurb= BKE_curve_nurbs(cu); + DispList *dl; + int required_mode = 0, totvert = 0; int editmode = (!forRender && cu->editnurb); DerivedMesh *dm= NULL, *ndm; float (*vertCos)[3] = NULL; @@ -1590,9 +1592,9 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, int numVerts; float (*originalVerts)[3]; float (*deformedVerts)[3]; - + if(!forRender && cu->editnurb) - nubase= cu->editnurb; + nubase= ED_curve_editnurbs(cu); else nubase= &cu->nurb; @@ -1689,10 +1691,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba cu->taperobj = NULL; } - if(cu->editnurb) - nubase= cu->editnurb; - else - nubase= &cu->nurb; + nubase= BKE_curve_nurbs(cu); BLI_freelistN(&(cu->bev)); diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index b8219c4aa35..354b3b0e7d8 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -542,11 +542,15 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * poinsize= ofs[0]; } else if( GS(key->from->name)==ID_CU ) { - if(mode==KEY_BPOINT) ofs[0]= sizeof(float)*4; - else ofs[0]= sizeof(float)*10; - + if(mode==KEY_BPOINT) { + ofs[0]= sizeof(float)*4; + poinsize= ofs[0]; + }else { + ofs[0]= sizeof(float)*12; + poinsize= ofs[0]/3; + } + ofs[1]= 0; - poinsize= ofs[0]; } if(end>tot) end= tot; @@ -612,7 +616,7 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * memcpy(poin, k1, sizeof(float)*4); break; case IPO_BEZTRIPLE: - memcpy(poin, k1, sizeof(float)*10); + memcpy(poin, k1, sizeof(float)*12); break; } @@ -644,28 +648,25 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, int start, int end, char *out, int tot) { Nurb *nu; - char *poin; int a, step, a1, a2; for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) { if(nu->bp) { step= nu->pntsu*nu->pntsv; - - /* exception because keys prefer to work with complete blocks */ - poin= out - a*sizeof(float)*4; + a1= MAX2(a, start); a2= MIN2(a+step, end); - - if(a1bezt) { step= 3*nu->pntsu; - - poin= out - a*sizeof(float)*10; + + /* exception because keys prefer to work with complete blocks */ a1= MAX2(a, start); a2= MIN2(a+step, end); - if(a1from==NULL) return; - + if( GS(key->from->name)==ID_ME ) { ofs[0]= sizeof(float)*3; ofs[1]= 0; + poinsize= ofs[0]; } else if( GS(key->from->name)==ID_LT ) { ofs[0]= sizeof(float)*3; ofs[1]= 0; + poinsize= ofs[0]; } else if( GS(key->from->name)==ID_CU ) { - if(mode==KEY_BPOINT) ofs[0]= sizeof(float)*4; - else ofs[0]= sizeof(float)*10; - + if(mode==KEY_BPOINT) { + ofs[0]= sizeof(float)*4; + poinsize= ofs[0]; + } else { + ofs[0]= sizeof(float)*12; + poinsize= ofs[0] / 3; + } + ofs[1]= 0; } - + if(end>tot) end= tot; - + /* in case of beztriple */ elemstr[0]= 1; /* nr of ipofloats */ elemstr[1]= IPO_BEZTRIPLE; @@ -730,7 +739,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock from= key_block_get_data(key, actkb, kb, &freefrom); reffrom= key_block_get_data(key, actkb, refb, &freereffrom); - poin+= start*ofs[0]; + poin+= start*poinsize; reffrom+= key->elemsize*start; // key elemsize yes! from+= key->elemsize*start; @@ -756,7 +765,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock rel_flerp(4, (float *)poin, (float *)reffrom, (float *)from, weight); break; case IPO_BEZTRIPLE: - rel_flerp(10, (float *)poin, (float *)reffrom, (float *)from, weight); + rel_flerp(12, (float *)poin, (float *)reffrom, (float *)from, weight); break; } @@ -803,11 +812,15 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * poinsize= ofs[0]; } else if( GS(key->from->name)==ID_CU ) { - if(mode==KEY_BPOINT) ofs[0]= sizeof(float)*4; - else ofs[0]= sizeof(float)*10; - + if(mode==KEY_BPOINT) { + ofs[0]= sizeof(float)*4; + poinsize= ofs[0]; + } else { + ofs[0]= sizeof(float)*12; + poinsize= ofs[0] / 3; + } + ofs[1]= 0; - poinsize= ofs[0]; } if(end>tot) end= tot; @@ -929,7 +942,7 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * flerp(4, (float *)poin, (float *)k1, (float *)k2, (float *)k3, (float *)k4, t); break; case IPO_BEZTRIPLE: - flerp(10, (void *)poin, (void *)k1, (void *)k2, (void *)k3, (void *)k4, t); + flerp(12, (void *)poin, (void *)k1, (void *)k2, (void *)k3, (void *)k4, t); break; } @@ -1137,19 +1150,16 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, int tot) static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float *t, char *out, int tot) { Nurb *nu; - char *poin; int a, step; for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) { if(nu->bp) { step= nu->pntsu*nu->pntsv; - poin= out - a*sizeof(float)*4; - do_key(a, a+step, tot, poin, key, actkb, k, t, KEY_BPOINT); + do_key(a, a+step, tot, out, key, actkb, k, t, KEY_BPOINT); } else if(nu->bezt) { step= 3*nu->pntsu; - poin= out - a*sizeof(float)*10; - do_key(a, a+step, tot, poin, key, actkb, k, t, KEY_BEZTRIPLE); + do_key(a, a+step, tot, out, key, actkb, k, t, KEY_BEZTRIPLE); } else step= 0; @@ -1159,19 +1169,16 @@ static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, float ctime, char *out, int tot) { Nurb *nu; - char *poin; int a, step; for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) { if(nu->bp) { step= nu->pntsu*nu->pntsv; - poin= out - a*sizeof(float)*3; do_rel_key(a, a+step, tot, out, key, actkb, KEY_BPOINT); } else if(nu->bezt) { step= 3*nu->pntsu; - poin= out - a*sizeof(float)*10; - do_rel_key(a, a+step, tot, poin, key, actkb, KEY_BEZTRIPLE); + do_rel_key(a, a+step, tot, out, key, actkb, KEY_BEZTRIPLE); } else step= 0; @@ -1184,35 +1191,61 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot) KeyBlock *k[4], *actkb= ob_get_keyblock(ob); float cfra, ctime, t[4], delta; int a, flag = 0, step = 0; - - if(key->slurph) { - delta= key->slurph; - delta/= tot; - + + if(key->slurph && key->type!=KEY_RELATIVE) { + Nurb *nu; + int mode, i= 0, remain= 0, estep, count; + + delta= (float)key->slurph / tot; + step= 1; if(tot>100 && slurph_opt) { step= tot/50; delta*= step; /* in do_key and cp_key the case a>tot has been handled */ } - + cfra= (float)scene->r.cfra; - - for(a=0; aipo, KEY_SPEED, &ctime)==0) { - ctime /= 100.0; - CLAMP(ctime, 0.0, 1.0); + + for(nu=cu->nurb.first; nu; nu=nu->next) { + if(nu->bp) { + mode= KEY_BPOINT; + estep= nu->pntsu*nu->pntsv; + } + else if(nu->bezt) { + mode= KEY_BEZTRIPLE; + estep= 3*nu->pntsu; } -#endif // XXX old animation system - - flag= setkeys(ctime, &key->block, k, t, 0); - - if(flag==0) - do_key(a, a+step, tot, (char *)out, key, actkb, k, t, 0); else - cp_key(a, a+step, tot, (char *)out, key, actkb, k[2], NULL, 0); + step= 0; + + a= 0; + while (a < estep) { + if (remain <= 0) { + cfra+= delta; + ctime= bsystem_time(scene, 0, cfra, 0.0f); // XXX old cruft + + ctime /= 100.0f; + CLAMP(ctime, 0.0f, 1.0f); // XXX for compat, we use this, but this clamping was confusing + flag= setkeys(ctime, &key->block, k, t, 0); + + remain= step; + } + + count= MIN2(remain, estep); + if (mode == KEY_BEZTRIPLE) { + count += 3 - count % 3; + } + + if(flag==0) + do_key(i, i+count, tot, (char *)out, key, actkb, k, t, mode); + else + cp_key(i, i+count, tot, (char *)out, key, actkb, k[2], NULL, mode); + + a += count; + i += count; + remain -= count; + } } } else { @@ -1336,11 +1369,11 @@ float *do_ob_key(Scene *scene, Object *ob) for(nu=cu->nurb.first; nu; nu=nu->next) { if(nu->bezt) { tot += 3*nu->pntsu; - size += nu->pntsu*10*sizeof(float); + size += nu->pntsu*12*sizeof(float); } else if(nu->bp) { tot += nu->pntsu*nu->pntsv; - size += nu->pntsu*nu->pntsv*10*sizeof(float); + size += nu->pntsu*nu->pntsv*12*sizeof(float); } } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 75b5e6d9331..efff3d138e6 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1885,13 +1885,12 @@ static void give_parvert(Object *par, int nr, float *vec) BPoint *bp; BezTriple *bezt; int found= 0; - + ListBase *nurbs; + cu= par->data; - if(cu->editnurb) - nu= cu->editnurb->first; - else - nu= cu->nurb.first; - + nurbs= BKE_curve_nurbs(cu); + nu= nurbs->first; + count= 0; while(nu && !found) { if(nu->type == CU_BEZIER) { @@ -2946,7 +2945,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, char *name, int from_ Curve *cu= ob->data; Key *key= cu->key; KeyBlock *kb; - ListBase *lb= (cu->editnurb)? cu->editnurb: &cu->nurb; + ListBase *lb= BKE_curve_nurbs(cu); int newkey= 0; if(key==NULL) { -- cgit v1.2.3 From 1e7f96343efd1472b9f827e5f5d3fd7f984b8612 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 25 Jul 2010 13:18:15 +0000 Subject: Fix for [#22167] Hair lattice only works with dynamic hair * Doing hair effectors, guides & lattices all in one loop didn't work properly --- source/blender/blenkernel/intern/particle.c | 125 ++++++++++++++-------------- 1 file changed, 62 insertions(+), 63 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 3791d808d01..ed63f011342 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2787,7 +2787,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) int steps = (int)pow(2.0, (double)(psys->renderdata ? part->ren_step : part->draw_step)); int totpart = psys->totpart; float length, vec[3]; - float *vg_effector= NULL, effector=0.0f; + float *vg_effector= NULL; float *vg_length= NULL, pa_length=1.0f; int keyed, baked; @@ -2889,85 +2889,84 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /*--modify paths and calculate rotation & velocity--*/ - sub_v3_v3v3(vec,(cache[p]+1)->co,cache[p]->co); - length = len_v3(vec); + if(!(psys->flag & PSYS_GLOBAL_HAIR)) { + /* apply effectors */ + if((psys->part->flag & PART_CHILD_EFFECT) == 0) { + float effector= 1.0f; + if(vg_effector) + effector*= psys_particle_value_from_verts(psmd->dm,psys->part->from,pa,vg_effector); - effector= 1.0f; - if(vg_effector) - effector*= psys_particle_value_from_verts(psmd->dm,psys->part->from,pa,vg_effector); + sub_v3_v3v3(vec,(cache[p]+1)->co,cache[p]->co); + length = len_v3(vec); - for(k=0, ca=cache[p]; k<=steps; k++, ca++) { - if(!(psys->flag & PSYS_GLOBAL_HAIR)) { - /* apply effectors */ - if(!(psys->part->flag & PART_CHILD_EFFECT) && k) + for(k=1, ca=cache[p]+1; k<=steps; k++, ca++) do_path_effectors(sim, p, ca, k, steps, cache[p]->co, effector, dfra, cfra, &length, vec); + } - /* apply guide curves to path data */ - if(sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT)==0) + /* apply guide curves to path data */ + if(sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT)==0) { + for(k=0, ca=cache[p]; k<=steps; k++, ca++) /* ca is safe to cast, since only co and vel are used */ do_guides(sim->psys->effectors, (ParticleKey*)ca, p, (float)k/(float)steps); + } - /* apply lattice */ - if(psys->lattice) + /* lattices have to be calculated separately to avoid mixups between effector calculations */ + if(psys->lattice) { + for(k=0, ca=cache[p]; k<=steps; k++, ca++) calc_latt_deform(psys->lattice, ca->co, 1.0f); + } + } - /* figure out rotation */ - - if(k) { - float cosangle, angle, tangent[3], normal[3], q[4]; - - if(k == 1) { - /* calculate initial tangent for incremental rotations */ - VECSUB(tangent, ca->co, (ca - 1)->co); - VECCOPY(prev_tangent, tangent); - normalize_v3(prev_tangent); - - /* First rotation is based on emitting face orientation. */ - /* This is way better than having flipping rotations resulting */ - /* from using a global axis as a rotation pole (vec_to_quat()). */ - /* It's not an ideal solution though since it disregards the */ - /* initial tangent, but taking that in to account will allow */ - /* the possibility of flipping again. -jahka */ - mat3_to_quat_is_ok( (ca-1)->rot,rotmat); - } - else { - VECSUB(tangent, ca->co, (ca - 1)->co); - normalize_v3(tangent); - - cosangle= dot_v3v3(tangent, prev_tangent); - - /* note we do the comparison on cosangle instead of - * angle, since floating point accuracy makes it give - * different results across platforms */ - if(cosangle > 0.999999f) { - QUATCOPY((ca - 1)->rot, (ca - 2)->rot); - } - else { - angle= saacos(cosangle); - cross_v3_v3v3(normal, prev_tangent, tangent); - axis_angle_to_quat( q,normal, angle); - mul_qt_qtqt((ca - 1)->rot, q, (ca - 2)->rot); - } + /* finally do rotation & velocity */ + for(k=1, ca=cache[p]+1; k<=steps; k++, ca++) { + /* figure out rotation */ + float cosangle, angle, tangent[3], normal[3], q[4]; + + if(k == 1) { + /* calculate initial tangent for incremental rotations */ + VECSUB(tangent, ca->co, (ca - 1)->co); + VECCOPY(prev_tangent, tangent); + normalize_v3(prev_tangent); + + /* First rotation is based on emitting face orientation. */ + /* This is way better than having flipping rotations resulting */ + /* from using a global axis as a rotation pole (vec_to_quat()). */ + /* It's not an ideal solution though since it disregards the */ + /* initial tangent, but taking that in to account will allow */ + /* the possibility of flipping again. -jahka */ + mat3_to_quat_is_ok( (ca-1)->rot,rotmat); + } + else { + VECSUB(tangent, ca->co, (ca - 1)->co); + normalize_v3(tangent); - VECCOPY(prev_tangent, tangent); - } + cosangle= dot_v3v3(tangent, prev_tangent); - if(k == steps) - QUATCOPY(ca->rot, (ca - 1)->rot); + /* note we do the comparison on cosangle instead of + * angle, since floating point accuracy makes it give + * different results across platforms */ + if(cosangle > 0.999999f) { + QUATCOPY((ca - 1)->rot, (ca - 2)->rot); + } + else { + angle= saacos(cosangle); + cross_v3_v3v3(normal, prev_tangent, tangent); + axis_angle_to_quat( q,normal, angle); + mul_qt_qtqt((ca - 1)->rot, q, (ca - 2)->rot); } + VECCOPY(prev_tangent, tangent); } - - /* set velocity */ - if(k){ - VECSUB(ca->vel, ca->co, (ca-1)->co); + if(k == steps) + QUATCOPY(ca->rot, (ca - 1)->rot); + - if(k==1) { - VECCOPY((ca-1)->vel, ca->vel); - } + /* set velocity */ + VECSUB(ca->vel, ca->co, (ca-1)->co); - } + if(k==1) + VECCOPY((ca-1)->vel, ca->vel); } } -- cgit v1.2.3 From 6ec87e60955cfa2e2737cdf9c1cc902c73f37d08 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 25 Jul 2010 14:40:18 +0000 Subject: Fix for [#22128] particle sizes and physics * size wasn't updated at all for particles with keyed or no physics --- source/blender/blenkernel/intern/particle_system.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 181d8fee4ba..a38fc921bea 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4038,12 +4038,21 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) case PART_PHYS_NO: case PART_PHYS_KEYED: { + PARTICLE_P; + if(emit_particles(&sim, NULL, cfra)) { free_keyed_keys(psys); distribute_particles(&sim, part->from); initialize_all_particles(&sim); } - reset_all_particles(&sim, 0.0, cfra, 0); + + LOOP_EXISTING_PARTICLES { + pa->size = part->size; + if(part->randsize > 0.0) + pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); + + reset_particle(&sim, pa, 0.0, cfra); + } if(part->phystype == PART_PHYS_KEYED) { psys_count_keyed_targets(&sim); -- cgit v1.2.3 From 98e26b1b081205730c4392fa884810bb65bd0c21 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 25 Jul 2010 17:19:55 +0000 Subject: == Sequencer == Some cleanup on effects: - converted interface to float cfra - made effects return their own ImBufs, which has the following advantages: * code in sequencer.c is a lot more readable. * multicam saves one memcpy of an image * prepares things for GPU-rendering --- source/blender/blenkernel/intern/seqeffects.c | 330 ++++++++++++++++---------- source/blender/blenkernel/intern/sequencer.c | 80 ++----- 2 files changed, 223 insertions(+), 187 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 151fc1c407c..c117f51c072 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -67,6 +67,48 @@ enum { GlowA=3 }; +static struct ImBuf * prepare_effect_imbufs( + int x, int y, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) +{ + struct ImBuf * out; + + if (!ibuf1 && !ibuf2 && !ibuf3) { + /* hmmm, global float option ? */ + out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect, 0); + } else if ((ibuf1 && ibuf1->rect_float) || + (ibuf2 && ibuf2->rect_float) || + (ibuf3 && ibuf3->rect_float)) { + /* if any inputs are rectfloat, output is float too */ + + out = IMB_allocImBuf((short)x, (short)y, 32, IB_rectfloat, 0); + } else { + out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect, 0); + } + + if (ibuf1 && !ibuf1->rect_float && out->rect_float) { + IMB_float_from_rect_simple(ibuf1); + } + if (ibuf2 && !ibuf2->rect_float && out->rect_float) { + IMB_float_from_rect_simple(ibuf2); + } + if (ibuf3 && !ibuf3->rect_float && out->rect_float) { + IMB_float_from_rect_simple(ibuf3); + } + + if (ibuf1 && !ibuf1->rect && !out->rect_float) { + IMB_rect_from_float(ibuf1); + } + if (ibuf2 && !ibuf2->rect && !out->rect_float) { + IMB_rect_from_float(ibuf2); + } + if (ibuf3 && !ibuf3->rect && !out->rect_float) { + IMB_rect_from_float(ibuf3); + } + + return out; +} /* ********************************************************************** PLUGINS @@ -229,11 +271,12 @@ static ImBuf * IMB_cast_away_list(ImBuf * i) return (ImBuf*) (((void**) i) + 2); } -static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_plugin_effect( + Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { char *cp; int float_rendering; @@ -241,6 +284,8 @@ static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra, old plugins) do very bad stuff with imbuf-internals */ + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if(seq->plugin && seq->plugin->doit) { if(seq->plugin->cfra) @@ -321,6 +366,7 @@ static void do_plugin_effect(Scene *scene, Sequence *seq, int cfra, if (ibuf3) IMB_freeImBuf(ibuf3); } } + return out; } static int do_plugin_early_out(struct Sequence *seq, @@ -476,12 +522,15 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, } } -static void do_alphaover_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_alphaover_effect( + Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_alphaover_effect_float( facf0, facf1, x, y, @@ -493,6 +542,7 @@ static void do_alphaover_effect(Scene *scene, Sequence *seq, int cfra, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } + return out; } @@ -644,12 +694,15 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, } } -static void do_alphaunder_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf* do_alphaunder_effect( + Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_alphaunder_effect_float( facf0, facf1, x, y, @@ -661,6 +714,7 @@ static void do_alphaunder_effect(Scene *scene, Sequence *seq, int cfra, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } + return out; } @@ -765,12 +819,15 @@ void do_cross_effect_float(float facf0, float facf1, int x, int y, /* carefull: also used by speed effect! */ -static void do_cross_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf* do_cross_effect( + Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_cross_effect_float( facf0, facf1, x, y, @@ -782,6 +839,7 @@ static void do_cross_effect(Scene *scene, Sequence *seq, int cfra, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } + return out; } @@ -1028,12 +1086,15 @@ static void do_gammacross_effect_float(float facf0, float facf1, } } -static void do_gammacross_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_gammacross_effect( + Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + build_gammatabs(); if (out->rect_float) { @@ -1047,6 +1108,7 @@ static void do_gammacross_effect(Scene *scene, Sequence *seq, int cfra, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } + return out; } @@ -1143,12 +1205,14 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y, } } -static void do_add_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_add_effect(Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_add_effect_float( facf0, facf1, x, y, @@ -1160,6 +1224,7 @@ static void do_add_effect(Scene *scene, Sequence *seq, int cfra, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } + return out; } @@ -1256,12 +1321,15 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y, } } -static void do_sub_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_sub_effect( + Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_sub_effect_float( facf0, facf1, x, y, @@ -1273,6 +1341,7 @@ static void do_sub_effect(Scene *scene, Sequence *seq, int cfra, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } + return out; } /* ********************************************************************** @@ -1284,8 +1353,8 @@ static void do_sub_effect(Scene *scene, Sequence *seq, int cfra, #define YOFF 8 static void do_drop_effect_byte(float facf0, float facf1, int x, int y, - unsigned char *rect2i, unsigned char *rect1i, - unsigned char *outi) + char *rect2i, char *rect1i, + char *outi) { int height, width, temp, fac, fac1, fac2; char *rt1, *rt2, *out; @@ -1364,27 +1433,6 @@ static void do_drop_effect_float(float facf0, float facf1, int x, int y, memcpy(out, rt1, 4 * sizeof(float)*YOFF*width); } - -static void do_drop_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf * ibuf3, - struct ImBuf *out) -{ - if (out->rect_float) { - do_drop_effect_float( - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); - } else { - do_drop_effect_byte( - facf0, facf1, x, y, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); - } -} - /* ********************************************************************** MUL ********************************************************************** */ @@ -1487,12 +1535,15 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, } } -static void do_mul_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_mul_effect( + Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_mul_effect_float( facf0, facf1, x, y, @@ -1504,6 +1555,8 @@ static void do_mul_effect(Scene *scene, Sequence *seq, int cfra, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } + + return out; } /* ********************************************************************** @@ -1938,12 +1991,15 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float facf1, } } -static void do_wipe_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_wipe_effect( + Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_wipe_effect_float(seq, facf0, facf1, x, y, @@ -1955,6 +2011,8 @@ static void do_wipe_effect(Scene *scene, Sequence *seq, int cfra, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } + + return out; } /* ********************************************************************** TRANSFORM @@ -2084,13 +2142,18 @@ static void do_transform(Scene *scene, Sequence *seq, float facf0, int x, int y, } -static void do_transform_effect(Scene *scene, Sequence *seq,int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_transform_effect( + Scene *scene, Sequence *seq,float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + do_transform(scene, seq, facf0, x, y, ibuf1, out); + + return out; } @@ -2597,12 +2660,15 @@ static void do_glow_effect_float(Sequence *seq, float facf0, float facf1, RVAddBitmaps_float (inbuf , outbuf, outbuf, x, y); } -static void do_glow_effect(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_glow_effect( + Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + if (out->rect_float) { do_glow_effect_float(seq, facf0, facf1, x, y, @@ -2614,6 +2680,8 @@ static void do_glow_effect(Scene *scene, Sequence *seq, int cfra, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } + + return out; } /* ********************************************************************** @@ -2653,12 +2721,15 @@ static int early_out_color(struct Sequence *seq, return -1; } -static void do_solid_color(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_solid_color( + Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + SolidColorVars *cv = (SolidColorVars *)seq->effectdata; unsigned char *rect; @@ -2728,6 +2799,7 @@ static void do_solid_color(Scene *scene, Sequence *seq, int cfra, } } } + return out; } /* ********************************************************************** @@ -2745,48 +2817,45 @@ static int early_out_multicam(struct Sequence *seq, float facf0, float facf1) return -1; } -static void do_multicam(Scene *scene, Sequence *seq, int cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) +static struct ImBuf * do_multicam( + Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, int x, int y, + int preview_render_size, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { struct ImBuf * i; + struct ImBuf * out; Editing * ed; ListBase * seqbasep; if (seq->multicam_source == 0 || seq->multicam_source >= seq->machine) { - return; + return 0; } ed = scene->ed; if (!ed) { - return; + return 0; } seqbasep = seq_seqbase(&ed->seqbase, seq); if (!seqbasep) { - return; + return 0; } - i = give_ibuf_seqbase(scene, - out->x, out->y, cfra, seq->multicam_source, + i = give_ibuf_seqbase(scene, x, y, cfra, seq->multicam_source, preview_render_size, seqbasep); if (!i) { - return; + return 0; } - if (out->rect && i->rect) { - memcpy(out->rect, i->rect, out->x * out->y * 4); - } else if (out->rect_float && i->rect_float) { - memcpy(out->rect_float, i->rect_float, out->x * out->y *4*sizeof(float)); - } else if (out->rect && i->rect_float) { - IMB_rect_from_float(i); - memcpy(out->rect, i->rect, out->x * out->y * 4); - } else if (out->rect_float && i->rect) { - IMB_float_from_rect_simple(i); - memcpy(out->rect_float, i->rect_float, out->x * out->y *4*sizeof(float)); + if (input_have_to_preprocess(scene, seq, cfra, x, y)) { + out = IMB_dupImBuf(i); + IMB_freeImBuf(i); + } else { + out = i; } - IMB_freeImBuf(i); + + return out; } /* ********************************************************************** @@ -3049,13 +3118,13 @@ static void store_icu_yrange_noop(struct Sequence * seq, /* defaults are fine */ } -static void get_default_fac_noop(struct Sequence *seq, int cfra, +static void get_default_fac_noop(struct Sequence *seq, float cfra, float * facf0, float * facf1) { *facf0 = *facf1 = 1.0; } -static void get_default_fac_fade(struct Sequence *seq, int cfra, +static void get_default_fac_fade(struct Sequence *seq, float cfra, float * facf0, float * facf1) { *facf0 = (float)(cfra - seq->startdisp); @@ -3064,21 +3133,38 @@ static void get_default_fac_fade(struct Sequence *seq, int cfra, *facf1 /= seq->len; } -static void do_overdrop_effect(Scene *scene, Sequence *seq, int cfra, - float fac, float facf, - int x, int y, - int preview_render_size, - struct ImBuf * ibuf1, - struct ImBuf * ibuf2, - struct ImBuf * ibuf3, - struct ImBuf * out) -{ - do_drop_effect(scene, seq, cfra, fac, facf, x, y, - preview_render_size, - ibuf1, ibuf2, ibuf3, out); - do_alphaover_effect(scene, seq, cfra, fac, facf, x, y, - preview_render_size, - ibuf1, ibuf2, ibuf3, out); +static struct ImBuf * do_overdrop_effect(Scene *scene, Sequence *seq, float cfra, + float facf0, float facf1, + int x, int y, + int preview_render_size, + struct ImBuf * ibuf1, + struct ImBuf * ibuf2, + struct ImBuf * ibuf3) +{ + struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + + if (out->rect_float) { + do_drop_effect_float( + facf0, facf1, x, y, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); + do_alphaover_effect_float( + facf0, facf1, x, y, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); + } else { + do_drop_effect_byte( + facf0, facf1, x, y, + (char*) ibuf1->rect, + (char*) ibuf2->rect, + (char*) out->rect); + do_alphaover_effect_byte( + facf0, facf1, x, y, + (char*) ibuf1->rect, (char*) ibuf2->rect, + (char*) out->rect); + } + + return out; } static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index bbc50490ab7..0651f1a6261 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1443,7 +1443,7 @@ static void color_balance(Sequence * seq, ImBuf* ibuf, float mul) */ -static int input_have_to_preprocess( +int input_have_to_preprocess( Scene *scene, Sequence * seq, float cfra, int seqrectx, int seqrecty) { float mul; @@ -1708,13 +1708,9 @@ static ImBuf* seq_render_effect_strip_impl( early_out = sh.early_out(seq, fac, facf); if (early_out == -1) { /* no input needed */ - /* hmmm, global float option ? */ - out = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); - - sh.execute(scene, seq, cfra, fac, facf, - out->x, out->y, render_size, - 0, 0, 0, out); + out = sh.execute(scene, seq, cfra, fac, facf, + seqrectx, seqrecty, render_size, + 0, 0, 0); goto finish; } @@ -1781,31 +1777,9 @@ static ImBuf* seq_render_effect_strip_impl( goto finish; } - /* if any inputs are rectfloat, output is float too */ - if((ibuf[0] && ibuf[0]->rect_float) || - (ibuf[1] && ibuf[1]->rect_float) || - (ibuf[2] && ibuf[2]->rect_float)) { - out = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, 32, IB_rectfloat, 0); - } else { - out = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); - } - - for (i = 0; i < 3; i++) { - ImBuf * b = ibuf[i]; - if (b) { - if (!b->rect_float && out->rect_float) { - IMB_float_from_rect_simple(b); - } - if (!b->rect && !out->rect_float) { - IMB_rect_from_float(b); - } - } - } - - sh.execute(scene, seq, cfra, fac, facf, out->x, out->y, render_size, - ibuf[0], ibuf[1], ibuf[2], out); + out = sh.execute(scene, seq, cfra, fac, facf, seqrectx, seqrecty, + render_size, + ibuf[0], ibuf[1], ibuf[2]); finish: for (i = 0; i < 3; i++) { @@ -2271,41 +2245,17 @@ static ImBuf* seq_render_strip_stack( int swap_input = seq_must_swap_input_in_blend_mode(seq); - int x= out->x; - int y= out->y; + int x= seqrectx; + int y= seqrecty; - if (ibuf1->rect_float || ibuf2->rect_float) { - out = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, - 32, IB_rectfloat, 0); - } else { - out = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, - 32, IB_rect, 0); - } - - if (!ibuf1->rect_float && out->rect_float) { - IMB_float_from_rect_simple(ibuf1); - } - if (!ibuf2->rect_float && out->rect_float) { - IMB_float_from_rect_simple(ibuf2); - } - - if (!ibuf1->rect && !out->rect_float) { - IMB_rect_from_float(ibuf1); - } - if (!ibuf2->rect && !out->rect_float) { - IMB_rect_from_float(ibuf2); - } - if (swap_input) { - sh.execute(scene, seq, cfra, - facf, facf, x, y, render_size, - ibuf2, ibuf1, 0, out); + out = sh.execute(scene, seq, cfra, + facf, facf, x, y, render_size, + ibuf2, ibuf1, 0); } else { - sh.execute(scene, seq, cfra, - facf, facf, x, y, render_size, - ibuf1, ibuf2, 0, out); + out = sh.execute(scene, seq, cfra, + facf, facf, x, y, render_size, + ibuf1, ibuf2, 0); } IMB_freeImBuf(ibuf1); -- cgit v1.2.3 From cc061d075f4368f7a8d380becb0688bbea14832a Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 25 Jul 2010 22:23:40 +0000 Subject: == Sculpt == More icon work * Added icon defines for all the brushes * Load all the brush icons after loading regular Blender icons * Added the brush icons to their respective tool enums in RNA * Fixed a couple unused-variable warnings --- source/blender/blenkernel/intern/brush.c | 1 - source/blender/blenkernel/intern/displist.c | 1 - 2 files changed, 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 23a221cadf4..a032f7ecca6 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -862,7 +862,6 @@ int brush_painter_paint(BrushPainter *painter, BrushFunc func, float *pos, doubl float startdistance, spacing, step, paintpos[2], dmousepos[2], finalpos[2]; float t, len, press; const int radius= brush_size(brush); - const int diameter= 2*radius; /* compute brush spacing adapted to brush radius, spacing may depend on pressure, so update it */ diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index ca659faa972..1cb28fe56d8 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1326,7 +1326,6 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba ModifierData *preTesselatePoint; Curve *cu= ob->data; ListBase *nurb= BKE_curve_nurbs(cu); - DispList *dl; int required_mode = 0, totvert = 0; int editmode = (!forRender && cu->editnurb); DerivedMesh *dm= NULL, *ndm; -- cgit v1.2.3 From 5b1231849cd2f87af24d13b6631199ba28e100e6 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Mon, 26 Jul 2010 02:35:43 +0000 Subject: * Factored out some duplicated code from rna_brush into paint.c, added a new function that checks whether a brush is used by that paint struct * Fixed an improperly initialized variable in BKE_previewing_free_id * Added an RNA access function to get the icon associated with a value --- source/blender/blenkernel/intern/icons.c | 2 +- source/blender/blenkernel/intern/paint.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index c1e00e091e8..78306705d6b 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -178,7 +178,7 @@ void BKE_previewimg_free_id(ID *id) Image *img = (Image*)id; BKE_previewimg_free(&img->preview); } else if (GS(id->name) == ID_BR) { - Brush *br = (Brush*)br; + Brush *br = (Brush*)id; BKE_previewimg_free(&br->preview); } } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index cf5deb95258..fcbe8d65d64 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -192,3 +192,15 @@ void copy_paint(Paint *orig, Paint *new) id_us_plus((ID *)new->brushes[i]); } } + +int paint_has_brush(Paint *p, Brush *brush) +{ + int i; + + for (i= 0; i < p->brush_count; i++) { + if (strcmp(brush->id.name+2, p->brushes[i]->id.name+2) == 0) + return 1; + } + + return 0; +} -- cgit v1.2.3 From e62c0ea835534acf2500ab0b4efcbb7b1eaa3cdd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 26 Jul 2010 06:34:56 +0000 Subject: replace macros VECCOPY and QUATCOPY with inline math functions no functional changes also replace mul_m4_v3() with mul_v3_m4v3() in a few places. --- source/blender/blenkernel/intern/constraint.c | 5 ++--- source/blender/blenkernel/intern/effect.c | 5 ++--- source/blender/blenkernel/intern/font.c | 8 ++------ source/blender/blenkernel/intern/object.c | 6 ++---- 4 files changed, 8 insertions(+), 16 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 171276d118e..aae70c055d0 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1127,10 +1127,9 @@ static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstra else { float vec[3]; /* move grabtarget into world space */ - VECCOPY(vec, data->grabtarget); - mul_m4_v3(ob->obmat, vec); + mul_v3_m4v3(vec, ob->obmat, data->grabtarget); copy_m4_m4(ct->matrix, ob->obmat); - VECCOPY(ct->matrix[3], vec); + copy_v3_v3(ct->matrix[3], vec); } } else diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index e9283ea867e..5f55814341b 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -433,9 +433,8 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect if(!colls) return visibility; - - VECCOPY(norm, efd->vec_to_point); - negate_v3(norm); + + negate_v3_v3(norm, efd->vec_to_point); len = normalize_v3(norm); // check all collision objects diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index a99f2599f66..7ebd0c3f457 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -1194,18 +1194,14 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) ascii = mem[i]; info = &(custrinfo[i]); if (cu->sepchar == (i+1)) { - float vecyo[3]; + float vecyo[3]= {ct->xof, ct->yof, 0.0f}; mem[0] = ascii; mem[1] = 0; custrinfo[0]= *info; cu->pos = 1; cu->len = 1; - vecyo[0] = ct->xof; - vecyo[1] = ct->yof; - vecyo[2] = 0; - mul_m4_v3(ob->obmat, vecyo); - VECCOPY(ob->loc, vecyo); + mul_v3_m4v3(ob->loc, ob->obmat, vecyo); outta = 1; cu->sepchar = 0; } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index efff3d138e6..01724b7e9fd 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2324,11 +2324,9 @@ void minmax_object(Object *ob, float *min, float *max) if(ob->pose) { bPoseChannel *pchan; for(pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - VECCOPY(vec, pchan->pose_head); - mul_m4_v3(ob->obmat, vec); + mul_v3_m4v3(vec, ob->obmat, pchan->pose_head); DO_MINMAX(vec, min, max); - VECCOPY(vec, pchan->pose_tail); - mul_m4_v3(ob->obmat, vec); + mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); DO_MINMAX(vec, min, max); } break; -- cgit v1.2.3 From 8eb31b6bcb21bde6892da83f7e50e0d4430837d1 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 26 Jul 2010 10:31:51 +0000 Subject: Fix for [#22073] Particle Emit From Volume Button No Different Than Emit From Faces Button --- source/blender/blenkernel/intern/particle_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index a38fc921bea..366d2e37d78 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -727,7 +727,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData pa->foffset=0.0; else switch(distr){ case PART_DISTR_JIT: - pa->foffset*= ctx->jit[2*(int)ctx->jitoff[i]]; + pa->foffset*= ctx->jit[p%(2*ctx->jitlevel)]; break; case PART_DISTR_RAND: pa->foffset*=BLI_frand(); -- cgit v1.2.3 From 230d66796b36917992348939b3dad85ee32afdec Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 26 Jul 2010 18:50:38 +0000 Subject: [#23033] Unindent after continue statement in Text Space [Patch to fix attached] from Justin Dailey (dail) from the tracker --- snip --- In the text space after the python commands return, break, pass or yeild and hitting "Enter" for a new line, it unindents 1 tab. However it does not do this for the continue statement. --- source/blender/blenkernel/intern/text.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index e8328d0e622..71c5963c52b 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2689,7 +2689,7 @@ int setcurr_tab (Text *text) int test = 0; char *word = ":"; char *comm = "#"; - char back_words[4][7] = {"return", "break", "pass", "yield"}; + static char *back_words[]= {"return", "break", "continue", "pass", "yield", NULL}; if (!text) return 0; if (!text->curl) return 0; @@ -2722,9 +2722,9 @@ int setcurr_tab (Text *text) } } - for(test=0; test < 4; test++) + for(test=0; back_words[test]; test++) { - //if there are these 4 key words then remove a tab because we are done with the block + /* if there are these key words then remove a tab because we are done with the block */ if(strstr(text->curl->line, back_words[test]) && i > 0) { if(strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm)) -- cgit v1.2.3 From cc9dbc7ac259e6f8547a58904bf5f834e14d58bc Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 26 Jul 2010 19:07:33 +0000 Subject: Curve shape keys: - Fixed incorrect working of "from mix" insert keyblock operator property shapekey coordinated are applying on curve's data when creating displist, so curve's nurbs can't be used as unchanged data -- use basis keyblock data instead - Fixed tilt damaging when loading editcurve -- made a typo in array indexes --- source/blender/blenkernel/intern/object.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 01724b7e9fd..81799a5409d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2955,7 +2955,11 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, char *name, int from_ if(newkey || from_mix==FALSE) { /* create from curve */ kb= add_keyblock(key, name); - curve_to_key(cu, kb, lb); + if (!newkey) { + KeyBlock *basekb= (KeyBlock *)key->block.first; + kb->data= MEM_dupallocN(basekb->data); + kb->totelem= basekb->totelem; + } else curve_to_key(cu, kb, lb); } else { /* copy from current values */ -- cgit v1.2.3 From 2ab8a2a516109c9c892f2343dfebadb3a7995c69 Mon Sep 17 00:00:00 2001 From: Jason Wilkins Date: Mon, 26 Jul 2010 20:42:50 +0000 Subject: * Fix: CPU usage was going way up because some WM_main_add_notifier functions that I thought were commented out somehow became active again. --- source/blender/blenkernel/intern/brush.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index a032f7ecca6..a8a53e3fbe6 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1238,7 +1238,7 @@ void brush_set_size(Brush *brush, int size) else brush->size= size; - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_size(Brush *brush) @@ -1258,7 +1258,7 @@ void brush_set_use_locked_size(Brush *brush, int value) brush->flag &= ~BRUSH_LOCK_SIZE; } - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_use_locked_size(Brush *brush) @@ -1278,7 +1278,7 @@ void brush_set_use_size_pressure(Brush *brush, int value) brush->flag &= ~BRUSH_SIZE_PRESSURE; } - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_use_size_pressure(Brush *brush) @@ -1298,7 +1298,7 @@ void brush_set_use_alpha_pressure(Brush *brush, int value) brush->flag &= ~BRUSH_ALPHA_PRESSURE; } - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } int brush_use_alpha_pressure(Brush *brush) @@ -1313,7 +1313,7 @@ void brush_set_unprojected_radius(Brush *brush, float unprojected_radius) else brush->unprojected_radius= unprojected_radius; - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } float brush_unprojected_radius(Brush *brush) @@ -1328,7 +1328,7 @@ void brush_set_alpha(Brush *brush, float alpha) else brush->alpha= alpha; - WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); + //WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); } float brush_alpha(Brush *brush) -- cgit v1.2.3 From 31362c865f6e392c5948ecdb63b984cf28979044 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 27 Jul 2010 12:01:40 +0000 Subject: Fix #22673: crash with solidify + subsurf + array modifier in edit mode. --- source/blender/blenkernel/intern/cdderivedmesh.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 41e33002999..a931a87e8c3 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1673,6 +1673,11 @@ DerivedMesh *CDDM_from_template(DerivedMesh *source, CDDerivedMesh *cddm = cdDM_create("CDDM_from_template dest"); DerivedMesh *dm = &cddm->dm; + /* ensure these are created if they are made on demand */ + source->getVertDataArray(source, CD_ORIGINDEX); + source->getEdgeDataArray(source, CD_ORIGINDEX); + source->getFaceDataArray(source, CD_ORIGINDEX); + /* this does a copy of all non mvert/medge/mface layers */ DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numFaces); -- cgit v1.2.3 From 967d25ac1c269f28ab793f7c63edb9fd540dd5cf Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Tue, 27 Jul 2010 14:53:20 +0000 Subject: =?UTF-8?q?Smoke=20Patch=20+=20additions:=20a)=20Applying=20patch?= =?UTF-8?q?=20#22765=20by=20Miika=20H=C3=A4m=C3=A4l=C3=A4inen=20(domain=20?= =?UTF-8?q?border=20collision=20settings,=20vorticity=20settings,=20time?= =?UTF-8?q?=20scale,=20non=20absolute=20density,=20smooth=20high=20res=20e?= =?UTF-8?q?mitter,=20initial=20velocity=20multiplier,=20high=20res=20stren?= =?UTF-8?q?gth=20available=20to=20be=20set=20to=200),=20b)=20Additions=20b?= =?UTF-8?q?y=20me:=20--Initial=20velocity=20is=20now=20per=20flow=20object?= =?UTF-8?q?,=20not=20per=20domain;=20--Using=20boundingbox=20as=20standard?= =?UTF-8?q?=20display=20mode=20for=20domains=20(was=20wire=20before);=20--?= =?UTF-8?q?When=20adding=20a=20flow=20object,=20an=20initial=20nice=20Smok?= =?UTF-8?q?eParticle=20system=20is=20added=20too=20with=20nice=20initial?= =?UTF-8?q?=20settings=20(life=3D1,=20no=5Frender,=20unborn,=20etc)=20fitt?= =?UTF-8?q?ing=20smoke=20simulation;=20--Adaptive=20timesteps=20introduced?= =?UTF-8?q?=20to=20the=20smoke=20sim=20(depending=20on=20the=20magnitude?= =?UTF-8?q?=20of=20the=20velocity)=20because=20it=20was=20quite=20unstable?= =?UTF-8?q?=20when=20used=20for=20fire=20simulations,=20still=20needs=20to?= =?UTF-8?q?=20be=20tested=20and=20will=20also=20slow=20down=20some=20simul?= =?UTF-8?q?ations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/blender/blenkernel/intern/smoke.c | 207 ++++++++++++++++++++++++++----- 1 file changed, 174 insertions(+), 33 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 7424026354a..193512b11dc 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -220,7 +220,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive // printf("res[0]: %d, res[1]: %d, res[2]: %d\n", smd->domain->res[0], smd->domain->res[1], smd->domain->res[2]); // dt max is 0.1 - smd->domain->fluid = smoke_init(smd->domain->res, smd->domain->p0, 0.1); + smd->domain->fluid = smoke_init(smd->domain->res, smd->domain->p0); smd->time = scene->r.cfra; if(smd->domain->flags & MOD_SMOKE_HIGHRES) @@ -237,7 +237,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive if(!smd->domain->shadow) smd->domain->shadow = MEM_callocN(sizeof(float) * smd->domain->res[0] * smd->domain->res[1] * smd->domain->res[2], "SmokeDomainShadow"); - smoke_initBlenderRNA(smd->domain->fluid, &(smd->domain->alpha), &(smd->domain->beta)); + smoke_initBlenderRNA(smd->domain->fluid, &(smd->domain->alpha), &(smd->domain->beta), &(smd->domain->time_scale), &(smd->domain->vorticity), &(smd->domain->border_collisions)); if(smd->domain->wt) { @@ -713,12 +713,16 @@ void smokeModifier_createType(struct SmokeModifierData *smd) smd->domain->omega = 1.0; smd->domain->alpha = -0.001; smd->domain->beta = 0.1; - smd->domain->flags = MOD_SMOKE_DISSOLVE_LOG; + smd->domain->time_scale = 1.0; + smd->domain->vorticity = 2.0; + smd->domain->border_collisions = 1; // vertically non-colliding + smd->domain->flags = MOD_SMOKE_DISSOLVE_LOG | MOD_SMOKE_HIGH_SMOOTH; smd->domain->strength = 2.0; smd->domain->noise = MOD_SMOKE_NOISEWAVE; smd->domain->diss_speed = 5; - // init view3d buffer - smd->domain->viewsettings = 0; + // init 3dview buffer + + smd->domain->viewsettings = MOD_SMOKE_VIEW_SHOWBIG; smd->domain->effector_weights = BKE_add_effector_weights(NULL); } else if(smd->type & MOD_SMOKE_TYPE_FLOW) @@ -733,6 +737,8 @@ void smokeModifier_createType(struct SmokeModifierData *smd) /* set some standard values */ smd->flow->density = 1.0; smd->flow->temp = 1.0; + smd->flow->flags = MOD_SMOKE_FLOW_ABSOLUTE; + smd->flow->vel_multi = 1.0; smd->flow->psys = NULL; @@ -862,7 +868,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) { ParticleSystem *psys = sfs->psys; ParticleSettings *part=psys->part; - ParticleData *pa = NULL; + ParticleData *pa = NULL; int p = 0; float *density = smoke_get_density(sds->fluid); float *bigdensity = smoke_turbulence_get_density(sds->wt); @@ -871,7 +877,27 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) float *velocity_y = smoke_get_velocity_y(sds->fluid); float *velocity_z = smoke_get_velocity_z(sds->fluid); unsigned char *obstacle = smoke_get_obstacle(sds->fluid); - int bigres[3]; + int bigres[3]; + short absolute_flow = (sfs->flags & MOD_SMOKE_FLOW_ABSOLUTE); + short high_emission_smoothing = bigdensity ? (smd->domain->flags & MOD_SMOKE_HIGH_SMOOTH) : 0; + + /* + * A temporary volume map used to store whole emissive + * area to be added to smoke density and interpolated + * for high resolution smoke. + */ + float *temp_emission_map = NULL; + + // initialize temp emission map + if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW)) + { + int i; + temp_emission_map = MEM_callocN(sizeof(float) * sds->res[0]*sds->res[1]*sds->res[2], "SmokeTempEmission"); + // set whole volume to 0.0f + for (i=0; ires[0]*sds->res[1]*sds->res[2]; i++) { + temp_emission_map[i] = 0.0f; + } + } // mostly copied from particle code for(p=0, pa=psys->particles; ptotpart; p++, pa++) @@ -905,33 +931,21 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) // heat[index] += sfs->temp * 0.1; // density[index] += sfs->density * 0.1; heat[index] = sfs->temp; - density[index] = sfs->density; + + // Add emitter density to temp emission map + temp_emission_map[index] = sfs->density; // Uses particle velocity as initial velocity for smoke - if(smd->domain->flags & MOD_SMOKE_INITVELOCITY) { - velocity_x[index] = pa->state.vel[0]; - velocity_y[index] = pa->state.vel[1]; - velocity_z[index] = pa->state.vel[2]; - } - - // obstacle[index] |= 2; - // we need different handling for the high-res feature - if(bigdensity) - { - // init all surrounding cells according to amplification, too - int i, j, k; + if(sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY) { - smoke_turbulence_get_res(smd->domain->wt, bigres); + velocity_x[index] = pa->state.vel[0]*sfs->vel_multi; + velocity_y[index] = pa->state.vel[1]*sfs->vel_multi; + velocity_z[index] = pa->state.vel[2]*sfs->vel_multi; + + } + - for(i = 0; i < smd->domain->amplify + 1; i++) - for(j = 0; j < smd->domain->amplify + 1; j++) - for(k = 0; k < smd->domain->amplify + 1; k++) - { - index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k); - bigdensity[index] = sfs->density; - } - } } else if(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow { @@ -954,9 +968,136 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) index = smoke_get_index((smd->domain->amplify + 1)* cell[0] + i, bigres[0], (smd->domain->amplify + 1)* cell[1] + j, bigres[1], (smd->domain->amplify + 1)* cell[2] + k); bigdensity[index] = 0.f; } - } - } // particles loop - } + } + } + } // particles loop + + + // apply emission values + if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW)) { + + // initialize variables + int ii, jj, kk, x, y, z, block_size; + size_t index, index_big; + + smoke_turbulence_get_res(smd->domain->wt, bigres); + block_size = smd->domain->amplify + 1; // high res block size + + + // loop through every low res cell + for(x = 0; x < sds->res[0]; x++) + for(y = 0; y < sds->res[1]; y++) + for(z = 0; z < sds->res[2]; z++) + { + + // neighbour cell emission densities (for high resolution smoke smooth interpolation) + float c000, c001, c010, c011, c100, c101, c110, c111; + + c000 = (x>0 && y>0 && z>0) ? temp_emission_map[smoke_get_index(x-1, sds->res[0], y-1, sds->res[1], z-1)] : 0; + c001 = (x>0 && y>0) ? temp_emission_map[smoke_get_index(x-1, sds->res[0], y-1, sds->res[1], z)] : 0; + c010 = (x>0 && z>0) ? temp_emission_map[smoke_get_index(x-1, sds->res[0], y, sds->res[1], z-1)] : 0; + c011 = (x>0) ? temp_emission_map[smoke_get_index(x-1, sds->res[0], y, sds->res[1], z)] : 0; + + c100 = (y>0 && z>0) ? temp_emission_map[smoke_get_index(x, sds->res[0], y-1, sds->res[1], z-1)] : 0; + c101 = (y>0) ? temp_emission_map[smoke_get_index(x, sds->res[0], y-1, sds->res[1], z)] : 0; + c110 = (z>0) ? temp_emission_map[smoke_get_index(x, sds->res[0], y, sds->res[1], z-1)] : 0; + c111 = temp_emission_map[smoke_get_index(x, sds->res[0], y, sds->res[1], z)]; // this cell + + + + // get cell index + index = smoke_get_index(x, sds->res[0], y, sds->res[1], z); + + // add emission to low resolution density + if (absolute_flow) {if (temp_emission_map[index]>0) density[index] = temp_emission_map[index];} + else { + density[index] += temp_emission_map[index]; + if (density[index]>1) density[index]=1.0f; + } + + smoke_turbulence_get_res(smd->domain->wt, bigres); + + + + /* + loop through high res blocks if high res enabled + */ + if (bigdensity) + for(ii = 0; ii < block_size; ii++) + for(jj = 0; jj < block_size; jj++) + for(kk = 0; kk < block_size; kk++) + { + + float fx,fy,fz, interpolated_value; + int shift_x, shift_y, shift_z; + + + /* + * Do volume interpolation if emitter smoothing + * is enabled + */ + if (high_emission_smoothing) { + // convert block position to relative + // for interpolation smoothing + fx = (float)ii/block_size + 0.5f/block_size; + fy = (float)jj/block_size + 0.5f/block_size; + fz = (float)kk/block_size + 0.5f/block_size; + + // calculate trilinear interpolation + interpolated_value = c000 * (1-fx) * (1-fy) * (1-fz) + + c100 * fx * (1-fy) * (1-fz) + + c010 * (1-fx) * fy * (1-fz) + + c001 * (1-fx) * (1-fy) * fz + + c101 * fx * (1-fy) * fz + + c011 * (1-fx) * fy * fz + + c110 * fx * fy * (1-fz) + + c111 * fx * fy * fz; + + + // add some contrast / sharpness + // depending on hi-res block size + + interpolated_value = (interpolated_value-0.4f*sfs->density)*(block_size/2) + 0.4f*sfs->density; + if (interpolated_value<0.0f) interpolated_value = 0.0f; + if (interpolated_value>1.0f) interpolated_value = 1.0f; + + // shift smoke block index + // (because pixel center is actually + // in halfway of the low res block) + shift_x = (x < 1) ? 0 : block_size/2; + shift_y = (y < 1) ? 0 : block_size/2; + shift_z = (z < 1) ? 0 : block_size/2; + } + else { + // without interpolation use same low resolution + // block value for all hi-res blocks + interpolated_value = c111; + shift_x = 0; + shift_y = 0; + shift_z = 0; + } + + // get shifted index for current high resolution block + index_big = smoke_get_index(block_size * x + ii - shift_x, bigres[0], block_size * y + jj - shift_y, bigres[1], block_size * z + kk - shift_z); + + // add emission data to high resolution density + if (absolute_flow) {if (interpolated_value > 0) bigdensity[index_big] = interpolated_value;} + else { + bigdensity[index_big] += interpolated_value; + if (bigdensity[index_big]>1) bigdensity[index_big]=1.0f; + } + + } // end of hires loop + + } // end of low res loop + + // free temporary emission map + if (temp_emission_map) MEM_freeN(temp_emission_map); + + } // end emission + + + } else { @@ -970,7 +1111,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) BLI_bvhtree_find_nearest(sfs->bvh->tree, pco, &nearest, sfs->bvh->nearest_callback, sfs->bvh); }*/ - } + } } } if(sds->fluid_group) -- cgit v1.2.3 From 78e5a299900233aa8779f87947edb9f37f9336bf Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Tue, 27 Jul 2010 15:33:21 +0000 Subject: Smoke: - Fix typo in tooltip - Add timeframe independand timesteps --- source/blender/blenkernel/intern/smoke.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 193512b11dc..b106c557b92 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1413,7 +1413,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM { if(sds->flags & MOD_SMOKE_DISSOLVE) smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); - smoke_step(sds->fluid, smd->time); + smoke_step(sds->fluid, smd->time, scene->r.frs_sec / scene->r.frs_sec_base); } // create shadows before writing cache so we get nice shadows for sstartframe, too -- cgit v1.2.3 From 88dcfbaee9be4a08104efc2f4edd20dd8e7957fe Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Tue, 27 Jul 2010 16:09:02 +0000 Subject: == Sculpt == Added a brush reset operator so that a user won't need to reload the default blend to get back default brush settings * New brush.reset operator, resets a brush based on the currently-selected tool * Added UI button in the tools panel TODO: * Only resets sculpt brushes right now, other paint modes should be added * Sculpt polish tool exists only as a Brush, not as a tool; I'd suggest we make it a tool so it can be reset to defaults too --- source/blender/blenkernel/intern/brush.c | 196 +++++++++++++++++++++++++++++-- 1 file changed, 188 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index a8a53e3fbe6..1e4fb13d1df 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -62,25 +62,22 @@ #include "RE_render_ext.h" /* externtex */ #include "RE_shader_ext.h" -/* Datablock add/copy/free/make_local */ - -Brush *add_brush(const char *name) +static void brush_set_defaults(Brush *brush) { - Brush *brush; - - brush= alloc_libblock(&G.main->brush, ID_BR, name); + brush->blend = 0; + brush->flag = 0; /* BRUSH SCULPT TOOL SETTINGS */ - brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */ brush->size= 35; /* radius of the brush in pixels */ brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */ brush->autosmooth_factor= 0.0f; brush->crease_pinch_factor= 0.5f; - brush->sculpt_plane = SCULPT_DISP_DIR_VIEW; + brush->sculpt_plane = SCULPT_DISP_DIR_AREA; brush->plane_offset= 0.0f; /* how far above or below the plane that is found by averaging the faces */ brush->plane_trim= 0.5f; brush->clone.alpha= 0.5f; brush->normal_weight= 0.0f; + brush->flag |= BRUSH_ALPHA_PRESSURE; /* BRUSH PAINT TOOL SETTINGS */ brush->rgb[0]= 1.0f; /* default rgb color of the brush when painting - white */ @@ -102,6 +99,7 @@ Brush *add_brush(const char *name) default_mtex(&brush->mtex); brush->texture_sample_bias= 0; /* value to added to texture samples */ + brush->texture_overlay_alpha= 33; /* brush appearance */ @@ -112,6 +110,19 @@ Brush *add_brush(const char *name) brush->sub_col[0]= 0.39; /* subtract mode color is light blue */ brush->sub_col[1]= 0.39; brush->sub_col[2]= 1.00; +} + +/* Datablock add/copy/free/make_local */ + +Brush *add_brush(const char *name) +{ + Brush *brush; + + brush= alloc_libblock(&G.main->brush, ID_BR, name); + + brush_set_defaults(brush); + + brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */ /* the default alpha falloff curve */ brush_curve_preset(brush, CURVE_PRESET_SMOOTH); @@ -212,6 +223,175 @@ void make_local_brush(Brush *brush) } } +void brush_debug_print_state(Brush *br) +{ + Brush def; + + /* create a fake brush and set it to the defaults */ + memset(&def, 0, sizeof(Brush)); + brush_set_defaults(&def); + +#define BR_TEST(field, t) \ + if(br->field != def.field) \ + printf("br->" #field " = %" #t ";\n", br->field) + +#define BR_TEST_FLAG(_f) \ + if((br->flag & _f) && !(def.flag & _f)) \ + printf("br->flag |= " #_f ";\n"); \ + else if(!(br->flag & _f) && (def.flag & _f)) \ + printf("br->flag &= ~" #_f ";\n") + + + /* print out any non-default brush state */ + BR_TEST(normal_weight, f); + + BR_TEST(blend, d); + BR_TEST(size, d); + + /* br->flag */ + BR_TEST_FLAG(BRUSH_AIRBRUSH); + BR_TEST_FLAG(BRUSH_TORUS); + BR_TEST_FLAG(BRUSH_ALPHA_PRESSURE); + BR_TEST_FLAG(BRUSH_SIZE_PRESSURE); + BR_TEST_FLAG(BRUSH_JITTER_PRESSURE); + BR_TEST_FLAG(BRUSH_SPACING_PRESSURE); + BR_TEST_FLAG(BRUSH_FIXED_TEX); + BR_TEST_FLAG(BRUSH_RAKE); + BR_TEST_FLAG(BRUSH_ANCHORED); + BR_TEST_FLAG(BRUSH_DIR_IN); + BR_TEST_FLAG(BRUSH_SPACE); + BR_TEST_FLAG(BRUSH_SMOOTH_STROKE); + BR_TEST_FLAG(BRUSH_PERSISTENT); + BR_TEST_FLAG(BRUSH_ACCUMULATE); + BR_TEST_FLAG(BRUSH_LOCK_ALPHA); + BR_TEST_FLAG(BRUSH_ORIGINAL_NORMAL); + BR_TEST_FLAG(BRUSH_OFFSET_PRESSURE); + BR_TEST_FLAG(BRUSH_SPACE_ATTEN); + BR_TEST_FLAG(BRUSH_ADAPTIVE_SPACE); + BR_TEST_FLAG(BRUSH_LOCK_SIZE); + BR_TEST_FLAG(BRUSH_TEXTURE_OVERLAY); + BR_TEST_FLAG(BRUSH_EDGE_TO_EDGE); + BR_TEST_FLAG(BRUSH_RESTORE_MESH); + BR_TEST_FLAG(BRUSH_INVERSE_SMOOTH_PRESSURE); + BR_TEST_FLAG(BRUSH_RANDOM_ROTATION); + BR_TEST_FLAG(BRUSH_PLANE_TRIM); + BR_TEST_FLAG(BRUSH_FRONTFACE); + BR_TEST_FLAG(BRUSH_CUSTOM_ICON); + + BR_TEST(jitter, f); + BR_TEST(spacing, d); + BR_TEST(smooth_stroke_radius, d); + BR_TEST(smooth_stroke_factor, f); + BR_TEST(rate, f); + + BR_TEST(alpha, f); + + BR_TEST(sculpt_plane, d); + + BR_TEST(plane_offset, f); + + BR_TEST(autosmooth_factor, f); + + BR_TEST(crease_pinch_factor, f); + + BR_TEST(plane_trim, f); + + BR_TEST(texture_sample_bias, f); + BR_TEST(texture_overlay_alpha, d); + + BR_TEST(add_col[0], f); + BR_TEST(add_col[1], f); + BR_TEST(add_col[2], f); + BR_TEST(sub_col[0], f); + BR_TEST(sub_col[1], f); + BR_TEST(sub_col[2], f); + + printf("\n"); + +#undef BR_TEST +#undef BR_TEST_FLAG +} + +void brush_reset_sculpt(Brush *br) +{ + /* enable this to see any non-default + settings used by a brush: + + brush_debug_print_state(br); + */ + + brush_set_defaults(br); + brush_curve_preset(br, CURVE_PRESET_SMOOTH); + + switch(br->sculpt_tool) { + case SCULPT_TOOL_CLAY: + br->flag |= BRUSH_FRONTFACE; + break; + case SCULPT_TOOL_CREASE: + br->flag |= BRUSH_DIR_IN; + br->alpha = 0.25; + break; + case SCULPT_TOOL_FILL: + br->add_col[1] = 1; + br->sub_col[0] = 0.25; + br->sub_col[1] = 1; + break; + case SCULPT_TOOL_FLATTEN: + br->add_col[1] = 1; + br->sub_col[0] = 0.25; + br->sub_col[1] = 1; + break; + case SCULPT_TOOL_INFLATE: + br->add_col[0] = 0.750000; + br->add_col[1] = 0.750000; + br->add_col[2] = 0.750000; + br->sub_col[0] = 0.250000; + br->sub_col[1] = 0.250000; + br->sub_col[2] = 0.250000; + break; + case SCULPT_TOOL_NUDGE: + br->add_col[0] = 0.250000; + br->add_col[1] = 1.000000; + br->add_col[2] = 0.250000; + break; + case SCULPT_TOOL_PINCH: + br->add_col[0] = 0.750000; + br->add_col[1] = 0.750000; + br->add_col[2] = 0.750000; + br->sub_col[0] = 0.250000; + br->sub_col[1] = 0.250000; + br->sub_col[2] = 0.250000; + break; + case SCULPT_TOOL_SCRAPE: + br->add_col[1] = 1.000000; + br->sub_col[0] = 0.250000; + br->sub_col[1] = 1.000000; + break; + case SCULPT_TOOL_ROTATE: + break; + case SCULPT_TOOL_SMOOTH: + br->flag &= ~BRUSH_SPACE_ATTEN; + br->spacing = 5; + br->add_col[0] = 0.750000; + br->add_col[1] = 0.750000; + br->add_col[2] = 0.750000; + break; + case SCULPT_TOOL_GRAB: + case SCULPT_TOOL_SNAKE_HOOK: + case SCULPT_TOOL_THUMB: + br->size = 75; + br->flag &= ~BRUSH_ALPHA_PRESSURE; + br->flag &= ~BRUSH_SPACE; + br->flag &= ~BRUSH_SPACE_ATTEN; + br->add_col[0] = 0.250000; + br->add_col[1] = 1.000000; + br->add_col[2] = 0.250000; + break; + default: + break; + } +} + /* Library Operations */ int brush_set_nr(Brush **current_brush, int nr, const char *name) -- cgit v1.2.3 From 112711e6a45a8e556bbd3e705ef6313a5b2ddc01 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Tue, 27 Jul 2010 16:18:12 +0000 Subject: Smoke: - Bugfix for using uninitalised velocity in case of PART_PHYS_NO (reported by MiikaH) --- source/blender/blenkernel/intern/smoke.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index b106c557b92..2664a20bd18 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -937,12 +937,11 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) // Uses particle velocity as initial velocity for smoke - if(sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY) { - + if(sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY && (psys->part->phystype != PART_PHYS_NO)) + { velocity_x[index] = pa->state.vel[0]*sfs->vel_multi; velocity_y[index] = pa->state.vel[1]*sfs->vel_multi; velocity_z[index] = pa->state.vel[2]*sfs->vel_multi; - } -- cgit v1.2.3 From b51350fb4f93a1e8c2093f99ccb26ebe81ff3fb9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 28 Jul 2010 13:19:02 +0000 Subject: Fix #22959: uv selection mode was not initialized correctly for new scenes. --- source/blender/blenkernel/intern/scene.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 9d736bd92eb..3c7f6e13445 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -395,6 +395,7 @@ Scene *add_scene(char *name) sce->toolsettings->jointrilimit = 0.8f; sce->toolsettings->selectmode= SCE_SELECT_VERTEX; + sce->toolsettings->uv_selectmode= UV_SELECT_VERTEX; sce->toolsettings->normalsize= 0.1; sce->toolsettings->autokey_mode= U.autokey_mode; -- cgit v1.2.3 From c8b6533ddaf421b51d44af7de4816f41086c9510 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 28 Jul 2010 16:47:12 +0000 Subject: Fix #23071: making vertex parent not correct with subsurf modifier, now it also uses the final derivedmesh for the coordinates in edit mode. --- source/blender/blenkernel/intern/object.c | 59 +++++++++++++------------------ 1 file changed, 25 insertions(+), 34 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 81799a5409d..39e02ee584d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1837,47 +1837,38 @@ static void give_parvert(Object *par, int nr, float *vec) if(par->type==OB_MESH) { Mesh *me= par->data; - em = BKE_mesh_get_editmesh(me); + DerivedMesh *dm; - if(em) { - EditVert *eve; + em = BKE_mesh_get_editmesh(me); + dm = (em)? em->derivedFinal: par->derivedFinal; - for(eve= em->verts.first; eve; eve= eve->next) { - if(eve->keyindex==nr) { - memcpy(vec, eve->co, sizeof(float)*3); - break; + if(dm) { + MVert *mvert= dm->getVertArray(dm); + int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX); + int i, count = 0, vindex, numVerts = dm->getNumVerts(dm); + + /* get the average of all verts with (original index == nr) */ + for(i = 0; i < numVerts; i++) { + vindex= (index)? index[i]: i; + + if(vindex == nr) { + add_v3_v3(vec, mvert[i].co); + count++; } } - BKE_mesh_end_editmesh(me, em); - } - else { - DerivedMesh *dm = par->derivedFinal; - - if(dm) { - MVert *mvert= dm->getVertArray(dm); - int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX); - int i, count = 0, vindex, numVerts = dm->getNumVerts(dm); - - /* get the average of all verts with (original index == nr) */ - for(i = 0; i < numVerts; i++) { - vindex= (index)? index[i]: i; - - if(vindex == nr) { - add_v3_v3(vec, mvert[i].co); - count++; - } - } - if (count==0) { - /* keep as 0,0,0 */ - } else if(count > 0) { - mul_v3_fl(vec, 1.0f / count); - } else { - /* use first index if its out of range */ - dm->getVertCo(dm, 0, vec); - } + if (count==0) { + /* keep as 0,0,0 */ + } else if(count > 0) { + mul_v3_fl(vec, 1.0f / count); + } else { + /* use first index if its out of range */ + dm->getVertCo(dm, 0, vec); } } + + if(em) + BKE_mesh_end_editmesh(me, em); } else if (ELEM(par->type, OB_CURVE, OB_SURF)) { Nurb *nu; -- cgit v1.2.3 From 7ef2e33ea331561691fbc189fa88d34f77ef896e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Jul 2010 00:06:22 +0000 Subject: bugfix [#23075] Point clouds invisible with VBOs --- source/blender/blenkernel/intern/cdderivedmesh.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index a931a87e8c3..fb1e8c00991 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -241,7 +241,8 @@ static void cdDM_drawVerts(DerivedMesh *dm) else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ GPU_vertex_setup(dm); if( !GPU_buffer_legacy(dm) ) { - glDrawArrays(GL_POINTS,0,dm->drawObject->nelements); + if(dm->drawObject->nelements) glDrawArrays(GL_POINTS,0, dm->drawObject->nelements); + else glDrawArrays(GL_POINTS,0, dm->drawObject->nlooseverts); } GPU_buffer_unbind(); } -- cgit v1.2.3 From b1f53d98e4332cfa17b7e30fb8fa11feda5d826e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 29 Jul 2010 22:34:46 +0000 Subject: patch [#23088] 2.5 Text Editor: Preserve indentation with spaces from Fabian Fricke (frigi) --- source/blender/blenkernel/intern/text.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 71c5963c52b..5a6ebb187cf 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2683,19 +2683,20 @@ void uncomment(Text *text) } } -int setcurr_tab (Text *text) +int setcurr_tab_spaces (Text *text, int space) { int i = 0; int test = 0; - char *word = ":"; - char *comm = "#"; + const char *word = ":"; + const char *comm = "#"; + const char indent= (text->flags & TXT_TABSTOSPACES) ? ' ' : '\t'; static char *back_words[]= {"return", "break", "continue", "pass", "yield", NULL}; if (!text) return 0; if (!text->curl) return 0; - - while (text->curl->line[i] == '\t') + + while (text->curl->line[i] == indent) { - //we only count thos tabs that are before any text or before the curs; + //we only count those tabs/spaces that are before any text or before the curs; if (i == text->curc) { return i; @@ -2718,7 +2719,7 @@ int setcurr_tab (Text *text) } } if (indent) { - i++; + i += space; } } @@ -2729,7 +2730,7 @@ int setcurr_tab (Text *text) { if(strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm)) { - i--; + i -= space; } } } -- cgit v1.2.3 From eec131899647cdf17c50553e265a925857f35cfe Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Fri, 30 Jul 2010 00:06:59 +0000 Subject: Preview commit in sculpt brushes broke resetting curves in other areas (rgb curves etc). Fixed by adding a 'slope' parameter to curvemap_reset() to mirror curve presets around Y axis. Also removed curve preset with 'random' icon, wasn't doing what it looked like it should, this was intended only for hue correct node anyway. --- source/blender/blenkernel/intern/brush.c | 2 +- source/blender/blenkernel/intern/colortools.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 1e4fb13d1df..b9d7ea177d4 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -452,7 +452,7 @@ void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; b->curve->preset = preset; - curvemap_reset(cm, &b->curve->clipr, b->curve->preset); + curvemap_reset(cm, &b->curve->clipr, b->curve->preset, CURVEMAP_SLOPE_NEGATIVE); curvemapping_changed(b->curve, 0); } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index a07c18f42f3..11801557c99 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -236,7 +236,7 @@ void curvemap_insert(CurveMap *cuma, float x, float y) cuma->curve= cmp; } -void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset) +void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) { if(cuma->curve) MEM_freeN(cuma->curve); @@ -320,6 +320,20 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset) break; } + /* mirror curve in x direction to have positive slope + * rather than default negative slope */ + if (slope == CURVEMAP_SLOPE_POSITIVE) { + int i, last=cuma->totpoint-1; + CurveMapPoint *newpoints= MEM_dupallocN(cuma->curve); + + for (i=0; itotpoint; i++) { + newpoints[i].y = cuma->curve[last-i].y; + } + + MEM_freeN(cuma->curve); + cuma->curve = newpoints; + } + if(cuma->table) { MEM_freeN(cuma->table); cuma->table= NULL; -- cgit v1.2.3 From 9a9e04edfba277e6315be8a4a400fbda2b1423d3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 30 Jul 2010 00:20:05 +0000 Subject: patch [#23060] ColorRamp python access functions from Dan Eicher (dna) elem = color_ramp.elements.new(position=0.3) color_ramp.elements.remove(elem) - Modified the patch to make generic functions for adding and removing (inline code was in 3 different places) --- source/blender/blenkernel/intern/texture.c | 67 ++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 57816b7e470..d05d8ccbc08 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -403,6 +403,73 @@ void colorband_table_RGBA(ColorBand *coba, float **array, int *size) do_colorband(coba, (float)a/(float)CM_TABLE, &(*array)[a*4]); } +int vergcband(const void *a1, const void *a2) +{ + const CBData *x1=a1, *x2=a2; + + if( x1->pos > x2->pos ) return 1; + else if( x1->pos < x2->pos) return -1; + return 0; +} + +CBData *colorband_element_add(struct ColorBand *coba, float position) +{ + int a; + + if(coba->tot==MAXCOLORBAND) { + return NULL; + } + else if(coba->tot > 0) { + CBData *xnew; + float col[4]; + + do_colorband(coba, position, col); + + xnew = &coba->data[coba->tot]; + xnew->pos = position; + + xnew->r = col[0]; + xnew->g = col[1]; + xnew->b = col[2]; + xnew->a = col[3]; + } + + coba->tot++; + coba->cur = coba->tot-1; + + for(a = 0; a < coba->tot; a++) + coba->data[a].cur = a; + + qsort(coba->data, coba->tot, sizeof(CBData), vergcband); + + for(a = 0; a < coba->tot; a++) { + if(coba->data[a].cur == coba->cur) { + coba->cur = a; + break; + } + } + + return coba->data + coba->cur; +} + +int colorband_element_remove(struct ColorBand *coba, int index) +{ + int a; + + if(coba->tot < 2) + return 0; + + if(index < 0 || index >= coba->tot) + return 0; + + for(a = index; a < coba->tot; a++) { + coba->data[a] = coba->data[a + 1]; + } + if(coba->cur) coba->cur--; + coba->tot--; + return 1; +} + /* ******************* TEX ************************ */ void free_texture(Tex *tex) -- cgit v1.2.3 From 520d12e13e2143cfd54a7696df94cd87e7a51e39 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 30 Jul 2010 01:13:07 +0000 Subject: 3 duplicate functions: bone_flip_name() object_flip_name() flip_side_name() removed object_flip_name() & bone_flip_name(), use flip_side_name() --- source/blender/blenkernel/intern/armature.c | 111 ---------------------------- 1 file changed, 111 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 990993b1077..b9b171780c7 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -245,117 +245,6 @@ Bone *get_named_bone (bArmature *arm, const char *name) return bone; } - -#define IS_SEPARATOR(a) (a=='.' || a==' ' || a=='-' || a=='_') - -/* finds the best possible flipped name. For renaming; check for unique names afterwards */ -/* if strip_number: removes number extensions */ -void bone_flip_name (char *name, int strip_number) -{ - int len; - char prefix[128]={""}; /* The part before the facing */ - char suffix[128]={""}; /* The part after the facing */ - char replace[128]={""}; /* The replacement string */ - char number[128]={""}; /* The number extension string */ - char *index=NULL; - - len= strlen(name); - if(len<3) return; // we don't do names like .R or .L - - /* We first check the case with a .### extension, let's find the last period */ - if(isdigit(name[len-1])) { - index= strrchr(name, '.'); // last occurrence - if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! - if(strip_number==0) - strcpy(number, index); - *index= 0; - len= strlen(name); - } - } - - strcpy (prefix, name); - - /* first case; separator . - _ with extensions r R l L */ - if( IS_SEPARATOR(name[len-2]) ) { - switch(name[len-1]) { - case 'l': - prefix[len-1]= 0; - strcpy(replace, "r"); - break; - case 'r': - prefix[len-1]= 0; - strcpy(replace, "l"); - break; - case 'L': - prefix[len-1]= 0; - strcpy(replace, "R"); - break; - case 'R': - prefix[len-1]= 0; - strcpy(replace, "L"); - break; - } - } - /* case; beginning with r R l L , with separator after it */ - else if( IS_SEPARATOR(name[1]) ) { - switch(name[0]) { - case 'l': - strcpy(replace, "r"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'r': - strcpy(replace, "l"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'L': - strcpy(replace, "R"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - case 'R': - strcpy(replace, "L"); - strcpy(suffix, name+1); - prefix[0]= 0; - break; - } - } - else if(len > 5) { - /* hrms, why test for a separator? lets do the rule 'ultimate left or right' */ - index = BLI_strcasestr(prefix, "right"); - if (index==prefix || index==prefix+len-5) { - if(index[0]=='r') - strcpy (replace, "left"); - else { - if(index[1]=='I') - strcpy (replace, "LEFT"); - else - strcpy (replace, "Left"); - } - *index= 0; - strcpy (suffix, index+5); - } - else { - index = BLI_strcasestr(prefix, "left"); - if (index==prefix || index==prefix+len-4) { - if(index[0]=='l') - strcpy (replace, "right"); - else { - if(index[1]=='E') - strcpy (replace, "RIGHT"); - else - strcpy (replace, "Right"); - } - *index= 0; - strcpy (suffix, index+4); - } - } - } - - sprintf (name, "%s%s%s%s", prefix, replace, suffix, number); -} - /* Finds the best possible extension to the name on a particular axis. (For renaming, check for unique names afterwards) * This assumes that bone names are at most 32 chars long! * strip_number: removes number extensions (TODO: not used) -- cgit v1.2.3 From 449f8ce4feeef8cfa57a8cbe299e0e718b9473b4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 30 Jul 2010 06:09:23 +0000 Subject: bugfix [#22859] Multi-user images cant be made into single user in texure panel. turns out this isnt exactly a bug since support was never written for this but may as well support it. now rna/py can do image.copy() too. --- source/blender/blenkernel/intern/deform.c | 1 + source/blender/blenkernel/intern/image.c | 24 ++++++++++++++++-------- source/blender/blenkernel/intern/library.c | 3 ++- source/blender/blenkernel/intern/node.c | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index ccb6ebe1f1e..5f262c526c3 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -471,6 +471,7 @@ void flip_side_name (char *name, const char *from_name, int strip_number) #undef IS_SEPARATOR sprintf (name, "%s%s%s%s", prefix, replace, suffix, number); + printf("'%s' --> '%s'\n", from_name, name); } float defvert_find_weight(const struct MDeformVert *dvert, int group_num) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ffd0b378f07..77607ae25b6 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -287,17 +287,25 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame) } /* empty image block, of similar type and filename */ -Image *BKE_image_copy(Image *ima) +Image *copy_image(Image *ima) { - Image *new= image_alloc(ima->id.name+2, ima->source, ima->type); + Image *nima= image_alloc(ima->id.name+2, ima->source, ima->type); - BLI_strncpy(new->name, ima->name, sizeof(ima->name)); - - new->gen_x= ima->gen_x; - new->gen_y= ima->gen_y; - new->gen_type= ima->gen_type; + BLI_strncpy(nima->name, ima->name, sizeof(ima->name)); + + nima->flag= ima->flag; + nima->tpageflag= ima->tpageflag; - return new; + nima->gen_x= ima->gen_x; + nima->gen_y= ima->gen_y; + nima->gen_type= ima->gen_type; + + nima->animspeed= ima->animspeed; + + nima->aspx= ima->aspx; + nima->aspy= ima->aspy; + + return nima; } void BKE_image_merge(Image *dest, Image *source) diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index acfaef9eb88..716a0b7d41b 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -262,7 +262,8 @@ int id_copy(ID *id, ID **newid, int test) if(!test) *newid= (ID*)copy_texture((Tex*)id); return 1; case ID_IM: - return 0; /* not implemented */ + if(!test) *newid= (ID*)copy_image((Image*)id); + return 1; case ID_WV: return 0; /* deprecated */ case ID_LT: diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index add011d0950..ff1887b0883 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2565,7 +2565,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) if(ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { if(node->id) { if(node->flag & NODE_DO_OUTPUT) - node->new_node->id= (ID *)BKE_image_copy((Image *)node->id); + node->new_node->id= (ID *)copy_image((Image *)node->id); else node->new_node->id= NULL; } -- cgit v1.2.3 From 9e45fa7f2fb7b7044340c8a9b28b9a3dcc2e4300 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 30 Jul 2010 11:40:23 +0000 Subject: bugfix [#23106] Blender crashes (segfault) when scene strip file is missing --- source/blender/blenkernel/intern/sequencer.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 0651f1a6261..f55cae7eaef 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1800,8 +1800,8 @@ static ImBuf * seq_render_scene_strip_impl( { ImBuf * ibuf = 0; float frame= seq->sfra + nr + seq->anim_startofs; - float oldcfra = seq->scene->r.cfra; - Object *oldcamera= seq->scene->camera; + float oldcfra; + Object *oldcamera; ListBase oldmarkers; /* Hack! This function can be called from do_render_seq(), in that case @@ -1820,21 +1820,20 @@ static ImBuf * seq_render_scene_strip_impl( int doseq; int doseq_gl= G.rendering ? /*(scene->r.seq_flag & R_SEQ_GL_REND)*/ 0 : (scene->r.seq_flag & R_SEQ_GL_PREV); int have_seq= FALSE; - Scene *sce= seq->scene;// *oldsce= scene; + Scene *sce= seq->scene; /* dont refer to seq->scene above this point!, it can be NULL */ int sce_valid= FALSE; - have_seq= (sce->r.scemode & R_DOSEQ) - && sce->ed && sce->ed->seqbase.first; - if(sce) { + have_seq= (sce->r.scemode & R_DOSEQ) && sce->ed && sce->ed->seqbase.first; sce_valid= (sce->camera || have_seq); } - if (!sce_valid) { - return 0; - } + if (!sce_valid) + return NULL; + + oldcfra= seq->scene->r.cfra; + oldcamera= seq->scene->camera; - /* prevent eternal loop */ doseq= scene->r.scemode & R_DOSEQ; scene->r.scemode &= ~R_DOSEQ; -- cgit v1.2.3 From 5251a9b3bf39c1520bdad4c8aa3f6273def76c77 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 30 Jul 2010 11:50:00 +0000 Subject: 2.5: remove vertex normal flip option, this is more harmful than helpful in many cases, and also gave incorrect rim lighting. --- source/blender/blenkernel/intern/mesh.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index cd8b2eb0a8e..66e8c10206c 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -697,7 +697,6 @@ void mball_to_mesh(ListBase *lb, Mesh *me) if(dl==0) return; if(dl->type==DL_INDEX4) { - me->flag= ME_NOPUNOFLIP; me->totvert= dl->nr; me->totface= dl->parts; -- cgit v1.2.3 From ae662b823552c7962e5f3dbf9dbf298b319d2d26 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 30 Jul 2010 11:55:41 +0000 Subject: bugfix [#23105] Scene strips renders out darker (no gamma corection?) --- source/blender/blenkernel/intern/sequencer.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index f55cae7eaef..4f3ad50e294 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1882,8 +1882,12 @@ static ImBuf * seq_render_scene_strip_impl( IMB_saveiff(imb, "/tmp/foo.image", IB_rect | IB_metadata); IMB_freeImBuf(imb); } */ - - } else if (rres.rect32) { + + /* float buffers in the sequencer are not linear */ + ibuf->profile= IB_PROFILE_LINEAR_RGB; + IMB_convert_profile(ibuf, IB_PROFILE_SRGB); + } + else if (rres.rect32) { ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0); memcpy(ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty); } -- cgit v1.2.3 From 1280b6f9024de7c7a3d67cd2dfb80820164bc802 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 31 Jul 2010 01:06:08 +0000 Subject: - add back prefix for ID lists (LF) for linked and fake user for search fields. - remove debug print for left/right name flipping & commented test from the sequencer. --- source/blender/blenkernel/intern/deform.c | 1 - source/blender/blenkernel/intern/library.c | 9 +++++++++ source/blender/blenkernel/intern/sequencer.c | 6 ------ 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 5f262c526c3..ccb6ebe1f1e 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -471,7 +471,6 @@ void flip_side_name (char *name, const char *from_name, int strip_number) #undef IS_SEPARATOR sprintf (name, "%s%s%s%s", prefix, replace, suffix, number); - printf("'%s' --> '%s'\n", from_name, name); } float defvert_find_weight(const struct MDeformVert *dvert, int group_num) diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 716a0b7d41b..6852a487afa 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1394,3 +1394,12 @@ void rename_id(ID *id, char *name) new_id(lb, id, name); } + +void name_uiprefix_id(char *name, ID *id) +{ + name[0] = id->lib ? 'L':' '; + name[1] = id->flag & LIB_FAKEUSER ? 'F':' '; + name[2] = ' '; + + strcpy(name+3, id->name+2); +} diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 4f3ad50e294..df185732d22 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1876,12 +1876,6 @@ static ImBuf * seq_render_scene_strip_impl( addzbuffloatImBuf(ibuf); memcpy(ibuf->zbuf_float, rres.rectz, sizeof(float)*rres.rectx*rres.recty); } - - /* { - ImBuf *imb= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); - IMB_saveiff(imb, "/tmp/foo.image", IB_rect | IB_metadata); - IMB_freeImBuf(imb); - } */ /* float buffers in the sequencer are not linear */ ibuf->profile= IB_PROFILE_LINEAR_RGB; -- cgit v1.2.3 From 5c9cf81cf98c99e52064b0cd45be3b2eaba9e40c Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 31 Jul 2010 10:03:08 +0000 Subject: Audaspace: * Fixed some compiler warnings * Implemented device looping * Note: Scrubbing in the sequencer is broken atm --- source/blender/blenkernel/intern/sound.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index ca39355976b..17ff6615ee7 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -381,10 +381,8 @@ void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, i void sound_start_play_scene(struct Scene *scene) { - AUD_Sound* sound; - sound = AUD_loopSound(scene->sound_scene); - scene->sound_scene_handle = AUD_play(sound, 1); - AUD_unload(sound); + scene->sound_scene_handle = AUD_play(scene->sound_scene, 1); + AUD_setLoop(scene->sound_scene_handle, -1); } void sound_play_scene(struct Scene *scene) @@ -397,8 +395,6 @@ void sound_play_scene(struct Scene *scene) if(status == AUD_STATUS_INVALID) sound_start_play_scene(scene); - AUD_setLoop(scene->sound_scene_handle, -1, -1); - if(status != AUD_STATUS_PLAYING) { AUD_seek(scene->sound_scene_handle, CFRA / FPS); @@ -436,7 +432,7 @@ void sound_seek_scene(struct bContext *C) if(scene->audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer) { - AUD_setLoop(scene->sound_scene_handle, -1, 1 / FPS); + // AUD_XXX TODO: fix scrubbing, it currently doesn't stop playing if(scene->audio.flag & AUDIO_SYNC) AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS); else -- cgit v1.2.3 From ea6730cdd1f3ad77d6cd9ba511b1c632ef225542 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Aug 2010 09:56:00 +0000 Subject: - font object x/yoffset was making text box's wrap text incorrectly. - draw text boxes with the offset applied. (abologies for making font.c even more confusing) --- source/blender/blenkernel/intern/font.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 7ebd0c3f457..46f67adeb4b 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -814,7 +814,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) twidth = char_width(cu, che, info); // Calculate positions - if((tb->w != 0.0) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w) { + if((tb->w != 0.0) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w + cu->xof*cu->fsize) { // fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]); for (j=i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak==0); j--) { if (mem[j]==' ' || mem[j]=='-') { @@ -855,7 +855,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) linedata4[lnr]= wsnr; if ( (tb->h != 0.0) && - ((-(yof-(tb->y/cu->fsize))) > ((tb->h/cu->fsize)-(linedist*cu->fsize))) && + ((-(yof-(tb->y/cu->fsize))) > ((tb->h/cu->fsize)-(linedist*cu->fsize)) - cu->yof) && (cu->totbox > (curbox+1)) ) { maxlen= 0; tb++; -- cgit v1.2.3 From d25747ee751096de2e417a7da1316bf5bf81c25a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 1 Aug 2010 11:00:36 +0000 Subject: bugfix's [#23108] bpy.ops.object.origin_set(type='GEOMETRY_ORIGIN') dosen't work in console [#23115] Crash when moving armature origin - setting the armature in editmode would leave editdata in some cases. - transforming selected linked objects to account for the movement of the obdata was only done for meshes, now do for curves and text3d. - added utility functions for getting curve & mesh bounds. - text3d moving center wasn't working at all. - changed drawobject.c to use BLI_math funcs in more places. - remove some unused code from operator object.origin_set. --- source/blender/blenkernel/intern/curve.c | 117 ++++++++++++++++++++++++++++--- source/blender/blenkernel/intern/mesh.c | 86 +++++++++++++++++------ 2 files changed, 170 insertions(+), 33 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 4142ad7128f..1a30e85c5c4 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -276,7 +276,7 @@ void tex_space_curve(Curve *cu) { DispList *dl; BoundBox *bb; - float *fp, min[3], max[3], loc[3], size[3]; + float *fp, min[3], max[3]; int tot, doit= 0; if(cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); @@ -303,20 +303,15 @@ void tex_space_curve(Curve *cu) min[0] = min[1] = min[2] = -1.0f; max[0] = max[1] = max[2] = 1.0f; } - - loc[0]= (min[0]+max[0])/2.0f; - loc[1]= (min[1]+max[1])/2.0f; - loc[2]= (min[2]+max[2])/2.0f; - - size[0]= (max[0]-min[0])/2.0f; - size[1]= (max[1]-min[1])/2.0f; - size[2]= (max[2]-min[2])/2.0f; boundbox_set_from_min_max(bb, min, max); if(cu->texflag & CU_AUTOSPACE) { - VECCOPY(cu->loc, loc); - VECCOPY(cu->size, size); + mid_v3_v3v3(cu->loc, min, max); + cu->size[0]= (max[0]-min[0])/2.0f; + cu->size[1]= (max[1]-min[1])/2.0f; + cu->size[2]= (max[2]-min[2])/2.0f; + cu->rot[0]= cu->rot[1]= cu->rot[2]= 0.0; if(cu->size[0]==0.0) cu->size[0]= 1.0; @@ -3107,3 +3102,103 @@ ListBase *BKE_curve_nurbs(Curve *cu) return &cu->nurb; } + + +/* basic vertex data functions */ +int curve_bounds(Curve *cu, float min[3], float max[3]) +{ + ListBase *nurb_lb= BKE_curve_nurbs(cu); + Nurb *nu; + + INIT_MINMAX(min, max); + + for(nu= nurb_lb->first; nu; nu= nu->next) + minmaxNurb(nu, min, max); + + return (nurb_lb->first != NULL); +} + +int curve_center_median(Curve *cu, float cent[3]) +{ + ListBase *nurb_lb= BKE_curve_nurbs(cu); + Nurb *nu; + int total= 0; + + zero_v3(cent); + + for(nu= nurb_lb->first; nu; nu= nu->next) { + int i; + + if(nu->type == CU_BEZIER) { + BezTriple *bezt; + i= nu->pntsu; + total += i * 3; + for(bezt= nu->bezt; i--; bezt++) { + add_v3_v3(cent, bezt->vec[0]); + add_v3_v3(cent, bezt->vec[1]); + add_v3_v3(cent, bezt->vec[2]); + } + } + else { + BPoint *bp; + i= nu->pntsu*nu->pntsv; + total += i; + for(bp= nu->bp; i--; bp++) { + add_v3_v3(cent, bp->vec); + } + } + } + + mul_v3_fl(cent, 1.0f/(float)total); + + return (total != 0); +} + +int curve_center_bounds(Curve *cu, float cent[3]) +{ + float min[3], max[3]; + + if(curve_bounds(cu, min, max)) { + mid_v3_v3v3(cent, min, max); + return 1; + } + + return 0; +} + +void curve_translate(Curve *cu, float offset[3], int do_keys) +{ + ListBase *nurb_lb= BKE_curve_nurbs(cu); + Nurb *nu; + int i; + + for(nu= nurb_lb->first; nu; nu= nu->next) { + BezTriple *bezt; + BPoint *bp; + + if(nu->type == CU_BEZIER) { + i= nu->pntsu; + for(bezt= nu->bezt; i--; bezt++) { + add_v3_v3(bezt->vec[0], offset); + add_v3_v3(bezt->vec[1], offset); + add_v3_v3(bezt->vec[2], offset); + } + } + else { + i= nu->pntsu*nu->pntsv; + for(bp= nu->bp; i--; bp++) { + add_v3_v3(bp->vec, offset); + } + } + } + + if (do_keys && cu->key) { + KeyBlock *kb; + for (kb=cu->key->block.first; kb; kb=kb->next) { + float *fp= kb->data; + for (i= kb->totelem; i--; fp+=3) { + add_v3_v3(fp, offset); + } + } + } +} diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 66e8c10206c..ab7b0694836 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -320,33 +320,22 @@ void make_local_mesh(Mesh *me) void boundbox_mesh(Mesh *me, float *loc, float *size) { - MVert *mvert; BoundBox *bb; float min[3], max[3]; float mloc[3], msize[3]; - int a; if(me->bb==0) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); bb= me->bb; - - INIT_MINMAX(min, max); if (!loc) loc= mloc; if (!size) size= msize; - mvert= me->mvert; - for(a=0; atotvert; a++, mvert++) { - DO_MINMAX(mvert->co, min, max); - } - - if(!me->totvert) { + if(!mesh_bounds(me, min, max)) { min[0] = min[1] = min[2] = -1.0f; max[0] = max[1] = max[2] = 1.0f; } - loc[0]= (min[0]+max[0])/2.0f; - loc[1]= (min[1]+max[1])/2.0f; - loc[2]= (min[2]+max[2])/2.0f; + mid_v3_v3v3(loc, min, max); size[0]= (max[0]-min[0])/2.0f; size[1]= (max[1]-min[1])/2.0f; @@ -369,9 +358,9 @@ void tex_space_mesh(Mesh *me) else if(size[a]<0.0 && size[a]> -0.00001) size[a]= -0.00001; } - VECCOPY(me->loc, loc); - VECCOPY(me->size, size); - me->rot[0]= me->rot[1]= me->rot[2]= 0.0; + copy_v3_v3(me->loc, loc); + copy_v3_v3(me->size, size); + zero_v3(me->rot); } } @@ -413,9 +402,7 @@ float *get_mesh_orco_verts(Object *ob) totvert = MIN2(tme->totvert, me->totvert); for(a=0; aco[0]; - vcos[a][1]= mvert->co[1]; - vcos[a][2]= mvert->co[2]; + copy_v3_v3(vcos[a], mvert->co); } return (float*)vcos; @@ -431,9 +418,7 @@ void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert, int inve if(invert) { for(a=0; apv= NULL; } } + +/* basic vertex data functions */ +int mesh_bounds(Mesh *me, float min[3], float max[3]) +{ + int i= me->totvert; + MVert *mvert; + INIT_MINMAX(min, max); + for(mvert= me->mvert; i--; mvert++) { + DO_MINMAX(mvert->co, min, max); + } + + return (me->totvert != 0); +} + +int mesh_center_median(Mesh *me, float cent[3]) +{ + int i= me->totvert; + MVert *mvert; + zero_v3(cent); + for(mvert= me->mvert; i--; mvert++) { + add_v3_v3(cent, mvert->co); + } + mul_v3_fl(cent, 1.0f/(float)me->totvert); + + return (me->totvert != 0); +} + +int mesh_center_bounds(Mesh *me, float cent[3]) +{ + float min[3], max[3]; + + if(mesh_bounds(me, min, max)) { + mid_v3_v3v3(cent, min, max); + return 1; + } + + return 0; +} + +void mesh_translate(Mesh *me, float offset[3], int do_keys) +{ + int i= me->totvert; + MVert *mvert; + for(mvert= me->mvert; i--; mvert++) { + add_v3_v3(mvert->co, offset); + } + + if (do_keys && me->key) { + KeyBlock *kb; + for (kb=me->key->block.first; kb; kb=kb->next) { + float *fp= kb->data; + for (i= kb->totelem; i--; fp+=3) { + add_v3_v3(fp, offset); + } + } + } +} -- cgit v1.2.3 From c34f831757e0985b7523b6e5bbfadd7dd6a2c161 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Sun, 1 Aug 2010 12:16:32 +0000 Subject: Smoke: - Bugfix for display problems in shaded view: Reverting to wire display mode for domain. --- source/blender/blenkernel/intern/smoke.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 2664a20bd18..15c7d3b4678 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -935,7 +935,6 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) // Add emitter density to temp emission map temp_emission_map[index] = sfs->density; - // Uses particle velocity as initial velocity for smoke if(sfs->flags & MOD_SMOKE_FLOW_INITVELOCITY && (psys->part->phystype != PART_PHYS_NO)) { @@ -943,8 +942,6 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) velocity_y[index] = pa->state.vel[1]*sfs->vel_multi; velocity_z[index] = pa->state.vel[2]*sfs->vel_multi; } - - } else if(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow { -- cgit v1.2.3 From 5fa7d1c1b4e7bde1d173caa60af0e273c86b6f0b Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 1 Aug 2010 12:47:49 +0000 Subject: 2.5: code changes to reduce the usage of G.main and pass it along or get it from the context instead. --- source/blender/blenkernel/intern/anim.c | 6 ++-- source/blender/blenkernel/intern/blender.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 42 +++++++++++++-------------- source/blender/blenkernel/intern/material.c | 10 +++---- source/blender/blenkernel/intern/particle.c | 4 +-- source/blender/blenkernel/intern/pointcache.c | 10 +++++-- source/blender/blenkernel/intern/scene.c | 24 +++++++-------- source/blender/blenkernel/intern/sequencer.c | 4 +-- 8 files changed, 52 insertions(+), 50 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 412084f7cd1..c24ec78dc1c 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -289,7 +289,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets) } /* "brew me a list that's sorted a bit faster now depsy" */ - DAG_scene_sort(scene); + DAG_scene_sort(G.main, scene); } /* update scene for current frame */ @@ -299,7 +299,7 @@ static void motionpaths_calc_update_scene(Scene *scene) Base *base, *last=NULL; /* only stuff that moves or needs display still */ - DAG_scene_update_flags(scene, scene->lay); + DAG_scene_update_flags(G.main, scene, scene->lay); /* find the last object with the tag * - all those afterwards are assumed to not be relevant for our calculations @@ -327,7 +327,7 @@ static void motionpaths_calc_update_scene(Scene *scene) * 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 + scene_update_for_newframe(G.main, scene, scene->lay); // XXX this is the best way we can get anything moving #endif } diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 9a624017a16..64d07db024b 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -478,7 +478,7 @@ static int read_undosave(bContext *C, UndoElem *uel) G.fileflags= fileflags; if(success) - DAG_on_load_update(); + DAG_on_load_update(G.main); return success; } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 142f80a350e..1f8360324d5 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -658,7 +658,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O dag_add_relation(dag,scenenode,node,DAG_RL_SCENE, "Scene Relation"); } -struct DagForest *build_dag(struct Scene *sce, short mask) +struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) { Base *base; Object *ob; @@ -695,7 +695,7 @@ struct DagForest *build_dag(struct Scene *sce, short mask) } /* add groups used in current scene objects */ - for(group= G.main->group.first; group; group= group->id.next) { + for(group= bmain->group.first; group; group= group->id.next) { if(group->id.flag & LIB_DOIT) { for(go= group->gobject.first; go; go= go->next) { build_dag_object(dag, scenenode, sce, go->ob, mask); @@ -1605,7 +1605,7 @@ static void dag_editors_update(Main *bmain, ID *id) } /* groups with objects in this scene need to be put in the right order as well */ -static void scene_sort_groups(Scene *sce) +static void scene_sort_groups(Main *bmain, Scene *sce) { Base *base; Group *group; @@ -1613,14 +1613,14 @@ static void scene_sort_groups(Scene *sce) Object *ob; /* test; are group objects all in this scene? */ - for(ob= G.main->object.first; ob; ob= ob->id.next) { + for(ob= bmain->object.first; ob; ob= ob->id.next) { ob->id.flag &= ~LIB_DOIT; ob->id.newid= NULL; /* newid abuse for GroupObject */ } for(base = sce->base.first; base; base= base->next) base->object->id.flag |= LIB_DOIT; - for(group= G.main->group.first; group; group= group->id.next) { + for(group= bmain->group.first; group; group= group->id.next) { for(go= group->gobject.first; go; go= go->next) { if((go->ob->id.flag & LIB_DOIT)==0) break; @@ -1649,7 +1649,7 @@ static void scene_sort_groups(Scene *sce) } /* sort the base list on dependency order */ -void DAG_scene_sort(struct Scene *sce) +void DAG_scene_sort(Main *bmain, Scene *sce) { DagNode *node; DagNodeQueue *nqueue; @@ -1661,7 +1661,7 @@ void DAG_scene_sort(struct Scene *sce) tempbase.first= tempbase.last= NULL; - build_dag(sce, DAG_RL_ALL_BUT_DATA); + build_dag(bmain, sce, DAG_RL_ALL_BUT_DATA); dag_check_cycle(sce->theDag); @@ -1731,7 +1731,7 @@ void DAG_scene_sort(struct Scene *sce) queue_delete(nqueue); /* all groups with objects in this scene gets resorted too */ - scene_sort_groups(sce); + scene_sort_groups(bmain, sce); if(G.f & G_DEBUG) { printf("\nordered\n"); @@ -1926,7 +1926,7 @@ static void dag_scene_flush_layers(Scene *sce, int lay) } /* flushes all recalc flags in objects down the dependency tree */ -void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) +void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, int time) { DagNode *firstnode; DagAdjList *itA; @@ -1935,7 +1935,7 @@ void DAG_scene_flush_update(Scene *sce, unsigned int lay, int time) if(sce->theDag==NULL) { printf("DAG zero... not allowed to happen!\n"); - DAG_scene_sort(sce); + DAG_scene_sort(bmain, sce); } firstnode= sce->theDag->DagNode.first; // always scene node @@ -2135,7 +2135,7 @@ static void dag_object_time_update_flags(Object *ob) } } /* flag all objects that need recalc, for changes in time for example */ -void DAG_scene_update_flags(Scene *scene, unsigned int lay) +void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay) { Base *base; Object *ob; @@ -2157,7 +2157,7 @@ void DAG_scene_update_flags(Scene *scene, unsigned int lay) } /* we do groups each once */ - for(group= G.main->group.first; group; group= group->id.next) { + for(group= bmain->group.first; group; group= group->id.next) { if(group->id.flag & LIB_DOIT) { for(go= group->gobject.first; go; go= go->next) { dag_object_time_update_flags(go->ob); @@ -2166,7 +2166,7 @@ void DAG_scene_update_flags(Scene *scene, unsigned int lay) } for(sce= scene; sce; sce= sce->set) - DAG_scene_flush_update(sce, lay, 1); + DAG_scene_flush_update(bmain, sce, lay, 1); /* test: set time flag, to disable baked systems to update */ for(SETLOOPER(scene, base)) { @@ -2223,21 +2223,19 @@ static void dag_current_scene_layers(Main *bmain, Scene **sce, unsigned int *lay } } -void DAG_ids_flush_update(int time) +void DAG_ids_flush_update(Main *bmain, int time) { - Main *bmain= G.main; Scene *sce; unsigned int lay; dag_current_scene_layers(bmain, &sce, &lay); if(sce) - DAG_scene_flush_update(sce, lay, time); + DAG_scene_flush_update(bmain, sce, lay, time); } -void DAG_on_load_update(void) +void DAG_on_load_update(Main *bmain) { - Main *bmain= G.main; Scene *scene, *sce; Base *base; Object *ob; @@ -2268,7 +2266,7 @@ void DAG_on_load_update(void) } } - for(group= G.main->group.first; group; group= group->id.next) { + for(group= bmain->group.first; group; group= group->id.next) { if(group->id.flag & LIB_DOIT) { for(go= group->gobject.first; go; go= go->next) { if(ELEM5(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) @@ -2282,7 +2280,7 @@ void DAG_on_load_update(void) } /* now tag update flags, to ensure deformers get calculated on redraw */ - DAG_scene_update_flags(scene, lay); + DAG_scene_update_flags(bmain, scene, lay); } } @@ -2394,7 +2392,7 @@ void DAG_id_flush_update(ID *id, short flag) } /* flush to other objects that depend on this one */ - DAG_scene_flush_update(sce, lay, 0); + DAG_scene_flush_update(bmain, sce, lay, 0); } /* recursively descends tree, each node only checked once */ @@ -2477,7 +2475,7 @@ void DAG_id_update_flags(ID *id) } /* set recalcs and flushes */ - DAG_scene_update_flags(sce, lay); + DAG_scene_update_flags(bmain, sce, lay); /* now we clear recalcs, unless color is set */ for(node = sce->theDag->DagNode.first; node; node= node->next) { diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 11c96e9a347..6b79a7b4d62 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -783,14 +783,14 @@ void init_render_material(Material *mat, int r_mode, float *amb) } } -void init_render_materials(int r_mode, float *amb) +void init_render_materials(Main *bmain, int r_mode, float *amb) { Material *ma; /* clear these flags before going over materials, to make sure they * are cleared only once, otherwise node materials contained in other * node materials can go wrong */ - for(ma= G.main->mat.first; ma; ma= ma->id.next) { + for(ma= bmain->mat.first; ma; ma= ma->id.next) { if(ma->id.us) { ma->texco= 0; ma->mapto= 0; @@ -798,7 +798,7 @@ void init_render_materials(int r_mode, float *amb) } /* two steps, first initialize, then or the flags for layers */ - for(ma= G.main->mat.first; ma; ma= ma->id.next) { + for(ma= bmain->mat.first; ma; ma= ma->id.next) { /* is_used flag comes back in convertblender.c */ ma->flag &= ~MA_IS_USED; if(ma->id.us) @@ -815,10 +815,10 @@ void end_render_material(Material *mat) ntreeEndExecTree(mat->nodetree); /* has internal flag to detect it only does it once */ } -void end_render_materials(void) +void end_render_materials(Main *bmain) { Material *ma; - for(ma= G.main->mat.first; ma; ma= ma->id.next) + for(ma= bmain->mat.first; ma; ma= ma->id.next) if(ma->id.us) end_render_material(ma); } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index ed63f011342..52ee0180f43 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3395,7 +3395,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, char *name) psys->flag = PSYS_ENABLED|PSYS_CURRENT; psys->cfra=bsystem_time(scene,ob,scene->r.cfra+1,0.0); - DAG_scene_sort(scene); + DAG_scene_sort(G.main, scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); return md; @@ -3432,7 +3432,7 @@ void object_remove_particle_system(Scene *scene, Object *ob) else ob->mode &= ~OB_MODE_PARTICLE_EDIT; - DAG_scene_sort(scene); + DAG_scene_sort(G.main, scene); DAG_id_flush_update(&ob->id, OB_RECALC_DATA); } static void default_particle_settings(ParticleSettings *part) diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index ced5d116ad0..d44221d2cd3 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2335,7 +2335,7 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old /* Baking */ -void BKE_ptcache_quick_cache_all(Scene *scene) +void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene) { PTCacheBaker baker; @@ -2348,6 +2348,7 @@ void BKE_ptcache_quick_cache_all(Scene *scene) baker.progresscontext=NULL; baker.render=0; baker.anim_init = 0; + baker.main=bmain; baker.scene=scene; baker.quick_step=scene->physics_settings.quick_cache_step; @@ -2362,6 +2363,7 @@ typedef struct { int endframe; int step; int *cfra_ptr; + Main *main; Scene *scene; } ptcache_make_cache_data; @@ -2369,7 +2371,7 @@ 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) { - scene_update_for_newframe(data->scene, data->scene->lay); + scene_update_for_newframe(data->main, data->scene, data->scene->lay); if(G.background) { printf("bake: frame %d :: %d\n", (int)*data->cfra_ptr, data->endframe); } @@ -2382,6 +2384,7 @@ static void *ptcache_make_cache_thread(void *ptr) { /* if bake is not given run simulations to current frame */ void BKE_ptcache_make_cache(PTCacheBaker* baker) { + Main *bmain = baker->main; Scene *scene = baker->scene; Scene *sce; /* SETLOOPER macro only */ Base *base; @@ -2401,6 +2404,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) thread_data.step = baker->quick_step; thread_data.cfra_ptr = &CFRA; thread_data.scene = baker->scene; + thread_data.main = baker->main; G.afbreek = 0; @@ -2570,7 +2574,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) CFRA = cfrao; if(bake) /* already on cfra unless baking */ - scene_update_for_newframe(scene, scene->lay); + scene_update_for_newframe(bmain, scene, scene->lay); if (thread_data.break_operation) WM_cursor_wait(0); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 3c7f6e13445..811f8a81b06 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -531,12 +531,12 @@ void set_scene_bg(Scene *scene) } /* sort baselist */ - DAG_scene_sort(scene); + DAG_scene_sort(G.main, scene); /* ensure dags are built for sets */ for(sce= scene->set; sce; sce= sce->set) if(sce->theDag==NULL) - DAG_scene_sort(sce); + DAG_scene_sort(G.main, sce); /* copy layers and flags from bases to objects */ for(base= scene->base.first; base; base= base->next) { @@ -907,14 +907,14 @@ float BKE_curframe(Scene *scene) return ctime; } -static void scene_update_tagged_recursive(Scene *scene, Scene *scene_parent) +static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scene_parent) { Base *base; /* sets first, we allow per definition current scene to have dependencies on sets, but not the other way around. */ if(scene->set) - scene_update_tagged_recursive(scene->set, scene_parent); + scene_update_tagged_recursive(bmain, scene->set, scene_parent); for(base= scene->base.first; base; base= base->next) { Object *ob= base->object; @@ -930,14 +930,14 @@ static void scene_update_tagged_recursive(Scene *scene, Scene *scene_parent) } /* this is called in main loop, doing tagged updates before redraw */ -void scene_update_tagged(Scene *scene) +void scene_update_tagged(Main *bmain, Scene *scene) { scene->physics_settings.quick_cache_step= 0; /* update all objects: drivers, matrices, displists, etc. flags set by depgraph or manual, no layer check here, gets correct flushed */ - scene_update_tagged_recursive(scene, scene); + scene_update_tagged_recursive(bmain, scene, scene); /* recalc scene animation data here (for sequencer) */ { @@ -949,14 +949,14 @@ void scene_update_tagged(Scene *scene) } if(scene->physics_settings.quick_cache_step) - BKE_ptcache_quick_cache_all(scene); + BKE_ptcache_quick_cache_all(bmain, scene); /* in the future this should handle updates for all datablocks, not only objects and scenes. - brecht */ } /* applies changes right away, does all sets too */ -void scene_update_for_newframe(Scene *sce, unsigned int lay) +void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) { float ctime = BKE_curframe(sce); Scene *sce_iter; @@ -966,13 +966,13 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay) for(sce_iter= sce; sce_iter; sce_iter= sce_iter->set) { if(sce_iter->theDag==NULL) - DAG_scene_sort(sce_iter); + DAG_scene_sort(bmain, sce_iter); } /* Following 2 functions are recursive * so dont call within 'scene_update_tagged_recursive' */ - DAG_scene_update_flags(sce, lay); // only stuff that moves or needs display still + DAG_scene_update_flags(bmain, sce, lay); // only stuff that moves or needs display still /* All 'standard' (i.e. without any dependencies) animation is handled here, * with an 'local' to 'macro' order of evaluation. This should ensure that @@ -980,11 +980,11 @@ void scene_update_for_newframe(Scene *sce, unsigned int lay) * can be overridden by settings from Scene, which owns the Texture through a hierarchy * such as Scene->World->MTex/Texture) can still get correctly overridden. */ - BKE_animsys_evaluate_all_animation(G.main, ctime); + BKE_animsys_evaluate_all_animation(bmain, ctime); /*...done with recusrive funcs */ /* object_handle_update() on all objects, groups and sets */ - scene_update_tagged_recursive(sce, sce); + scene_update_tagged_recursive(bmain, sce, sce); } /* return default layer, also used to patch old files */ diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index df185732d22..aab4e1226b2 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1852,7 +1852,7 @@ static ImBuf * seq_render_scene_strip_impl( if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) { /* opengl offscreen render */ - scene_update_for_newframe(seq->scene, seq->scene->lay); + scene_update_for_newframe(G.main, seq->scene, seq->scene->lay); ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, scene->r.seq_prev_type); } @@ -1865,7 +1865,7 @@ static ImBuf * seq_render_scene_strip_impl( else re= RE_NewRender(sce->id.name); - RE_BlenderFrame(re, sce, NULL, sce->lay, frame); + RE_BlenderFrame(re, G.main, sce, NULL, sce->lay, frame); RE_AcquireResultImage(re, &rres); -- cgit v1.2.3 From f3cca3e1929a59ea8dbf715645bef4712a530ef5 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 1 Aug 2010 12:57:01 +0000 Subject: 2.5: more G.main changes. --- source/blender/blenkernel/intern/blender.c | 2 +- source/blender/blenkernel/intern/scene.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 64d07db024b..1a1f3a724ca 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -313,7 +313,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) BLI_strncpy(G.main->name, filename, FILE_MAX); /* is guaranteed current file */ /* baseflags, groups, make depsgraph, etc */ - set_scene_bg(CTX_data_scene(C)); + set_scene_bg(G.main, CTX_data_scene(C)); MEM_freeN(bfd); } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 811f8a81b06..48cef7e1bde 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -501,7 +501,7 @@ Base *object_in_scene(Object *ob, Scene *sce) return NULL; } -void set_scene_bg(Scene *scene) +void set_scene_bg(Main *bmain, Scene *scene) { Scene *sce; Base *base; @@ -511,18 +511,18 @@ void set_scene_bg(Scene *scene) int flag; /* check for cyclic sets, for reading old files but also for definite security (py?) */ - scene_check_setscene(scene); + scene_check_setscene(bmain, scene); /* can happen when switching modes in other scenes */ if(scene->obedit && !(scene->obedit->mode & OB_MODE_EDIT)) scene->obedit= NULL; /* deselect objects (for dataselect) */ - for(ob= G.main->object.first; ob; ob= ob->id.next) + for(ob= bmain->object.first; ob; ob= ob->id.next) ob->flag &= ~(SELECT|OB_FROMGROUP); /* group flags again */ - for(group= G.main->group.first; group; group= group->id.next) { + for(group= bmain->group.first; group; group= group->id.next) { go= group->gobject.first; while(go) { if(go->ob) go->ob->flag |= OB_FROMGROUP; @@ -531,12 +531,12 @@ void set_scene_bg(Scene *scene) } /* sort baselist */ - DAG_scene_sort(G.main, scene); + DAG_scene_sort(bmain, scene); /* ensure dags are built for sets */ for(sce= scene->set; sce; sce= sce->set) if(sce->theDag==NULL) - DAG_scene_sort(G.main, sce); + DAG_scene_sort(bmain, sce); /* copy layers and flags from bases to objects */ for(base= scene->base.first; base; base= base->next) { @@ -558,11 +558,11 @@ void set_scene_bg(Scene *scene) } /* called from creator.c */ -Scene *set_scene_name(char *name) +Scene *set_scene_name(Main *bmain, char *name) { Scene *sce= (Scene *)find_id("SC", name); if(sce) { - set_scene_bg(sce); + set_scene_bg(bmain, sce); printf("Scene switch: '%s' in file: '%s'\n", name, G.sce); return sce; } @@ -871,7 +871,7 @@ void scene_select_base(Scene *sce, Base *selbase) } /* checks for cycle, returns 1 if it's all OK */ -int scene_check_setscene(Scene *sce) +int scene_check_setscene(Main *bmain, Scene *sce) { Scene *scene; int a, totscene; @@ -879,7 +879,7 @@ int scene_check_setscene(Scene *sce) if(sce->set==NULL) return 1; totscene= 0; - for(scene= G.main->scene.first; scene; scene= scene->id.next) + for(scene= bmain->scene.first; scene; scene= scene->id.next) totscene++; for(a=0, scene=sce; scene->set; scene=scene->set, a++) { -- cgit v1.2.3 From 0be152501e515244f9e565a38dd36819fdc8d78d Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Sun, 1 Aug 2010 15:00:53 +0000 Subject: Smoke: - Bugfix for not cleared smoke sim when doing alt-a and waiting for 2 sim cycles to complete --- source/blender/blenkernel/intern/smoke.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 15c7d3b4678..97eb3aa866c 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -296,7 +296,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive return 1; } - return 1; + return 2; } static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) @@ -1325,6 +1325,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM int startframe, endframe, framenr; float timescale; int cache_result = 0, cache_result_wt = 0; + int did_init = 0; framenr = scene->r.cfra; @@ -1354,7 +1355,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM // printf("startframe: %d, framenr: %d\n", startframe, framenr); - if(!smokeModifier_init(smd, ob, scene, dm)) + if(!(did_init = smokeModifier_init(smd, ob, scene, dm))) { printf("bad smokeModifier_init\n"); return; @@ -1411,8 +1412,18 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM smoke_dissolve(sds->fluid, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); smoke_step(sds->fluid, smd->time, scene->r.frs_sec / scene->r.frs_sec_base); } + else + { + /* Smoke did not load cache and was not reset but we're on startframe */ + /* So now reinit the smoke since it was not done yet */ + if(did_init == 2) + { + smokeModifier_reset(smd); + smokeModifier_init(smd, ob, scene, dm); + } + } - // create shadows before writing cache so we get nice shadows for sstartframe, too + // create shadows before writing cache so we get nice shadows for startframe, too if(get_lamp(scene, light)) smoke_calc_transparency(sds->shadow, smoke_get_density(sds->fluid), sds->p0, sds->p1, sds->res, sds->dx, light, calc_voxel_transp, -7.0*sds->dx); -- cgit v1.2.3 From ec2c52c9c87550d2e551956e0b558e14e8264213 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 2 Aug 2010 16:27:41 +0000 Subject: SCons - remove scons option WITH_BF_FHS, its not needed anymore. - comment WITH_BF_DOCS, was using epydocs which we dont use now. - blenderlite target was broken, always using openmp. - building without python wasnt working. - fixed some warnings. --- source/blender/blenkernel/intern/BME_conversions.c | 4 ++-- source/blender/blenkernel/intern/font.c | 4 ++-- source/blender/blenkernel/intern/texture.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c index d6a00450e4a..64a6e14bc5d 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -391,9 +391,9 @@ void BME_bmesh_to_editmesh(BME_Mesh *bm, BME_TransData_Head *td, EditMesh *em) { if(e->flag & SELECT) eed->f |= SELECT; //XXX if(e->flag & ME_FGON) eed->h= EM_FGON; // 2 different defines! if(e->flag & ME_HIDE) eed->h |= 1; - if(em->selectmode==SCE_SELECT_EDGE) + if(em->selectmode==SCE_SELECT_EDGE) { ; //XXX EM_select_edge(eed, eed->f & SELECT); - + } CustomData_em_copy_data(&bm->edata, &em->edata, e->data, &eed->data); } } diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 46f67adeb4b..f991dee19fe 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -122,8 +122,8 @@ wcsleninu8(wchar_t *src) return len; } -int -static utf8slen(char *src) +static int +utf8slen(char *src) { int size = 0, index = 0; unsigned char c; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index d05d8ccbc08..fe5abbd0868 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -169,8 +169,8 @@ PluginTex *add_plugin_tex(char *str) open_plugin_tex(pit); if(pit->doit==0) { - if(pit->handle==0); //XXX error("no plugin: %s", str); - else ; //XXX error("in plugin: %s", str); + if(pit->handle==0) {;} //XXX error("no plugin: %s", str); + else {;} //XXX error("in plugin: %s", str); MEM_freeN(pit); return NULL; } -- cgit v1.2.3 From 86fc34b924e281ee9273c44c024434bdd6e3f7f2 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Mon, 2 Aug 2010 18:22:34 +0000 Subject: Audaspace: * Added a stopCallback function that is called when the end of a sound is reached. * Fixed the scrubbing not working. * Minor SoundActuator cleanup. --- source/blender/blenkernel/intern/sound.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 17ff6615ee7..264bae31089 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -438,6 +438,10 @@ void sound_seek_scene(struct bContext *C) else AUD_seek(scene->sound_scene_handle, CFRA / FPS); AUD_resume(scene->sound_scene_handle); + if(AUD_getStatus(scene->sound_scrub_handle) != AUD_STATUS_INVALID) + AUD_seek(scene->sound_scrub_handle, 0); + else + scene->sound_scrub_handle = AUD_pauseAfter(scene->sound_scene_handle, 1 / FPS); } else { -- cgit v1.2.3 From 66f32bd7f9191702d561ff6995363d9a98084772 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Aug 2010 00:56:43 +0000 Subject: set origin was setting surfaces as 2D curves, added dupli-group support using the dupli's offset value. --- source/blender/blenkernel/intern/curve.c | 8 +++----- source/blender/blenkernel/intern/mesh.c | 10 +++++----- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 1a30e85c5c4..3d7eb1624f3 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -3105,13 +3105,11 @@ ListBase *BKE_curve_nurbs(Curve *cu) /* basic vertex data functions */ -int curve_bounds(Curve *cu, float min[3], float max[3]) +int minmax_curve(Curve *cu, float min[3], float max[3]) { ListBase *nurb_lb= BKE_curve_nurbs(cu); Nurb *nu; - INIT_MINMAX(min, max); - for(nu= nurb_lb->first; nu; nu= nu->next) minmaxNurb(nu, min, max); @@ -3157,8 +3155,8 @@ int curve_center_median(Curve *cu, float cent[3]) int curve_center_bounds(Curve *cu, float cent[3]) { float min[3], max[3]; - - if(curve_bounds(cu, min, max)) { + INIT_MINMAX(min, max); + if(minmax_curve(cu, min, max)) { mid_v3_v3v3(cent, min, max); return 1; } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index ab7b0694836..7129ecb1d55 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -330,7 +330,8 @@ void boundbox_mesh(Mesh *me, float *loc, float *size) if (!loc) loc= mloc; if (!size) size= msize; - if(!mesh_bounds(me, min, max)) { + INIT_MINMAX(min, max); + if(!minmax_mesh(me, min, max)) { min[0] = min[1] = min[2] = -1.0f; max[0] = max[1] = max[2] = 1.0f; } @@ -1484,11 +1485,10 @@ void mesh_pmv_off(Object *ob, Mesh *me) } /* basic vertex data functions */ -int mesh_bounds(Mesh *me, float min[3], float max[3]) +int minmax_mesh(Mesh *me, float min[3], float max[3]) { int i= me->totvert; MVert *mvert; - INIT_MINMAX(min, max); for(mvert= me->mvert; i--; mvert++) { DO_MINMAX(mvert->co, min, max); } @@ -1512,8 +1512,8 @@ int mesh_center_median(Mesh *me, float cent[3]) int mesh_center_bounds(Mesh *me, float cent[3]) { float min[3], max[3]; - - if(mesh_bounds(me, min, max)) { + INIT_MINMAX(min, max); + if(minmax_mesh(me, min, max)) { mid_v3_v3v3(cent, min, max); return 1; } -- cgit v1.2.3 From 957976882d084d9951760b154f414724d6ddb8be Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Aug 2010 11:25:34 +0000 Subject: build options to disable image formats WITH_CINEON, WITH_HDR. - updated cmake, make & scons. - renamed CMake build options WITH_TIFF -> WITH_IMAGE_TIFF, same for DDS, OPENJPEG etc. --- source/blender/blenkernel/intern/Makefile | 8 ++++++++ source/blender/blenkernel/intern/image.c | 27 +++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile index 15c022592f9..7a4eb52326a 100644 --- a/source/blender/blenkernel/intern/Makefile +++ b/source/blender/blenkernel/intern/Makefile @@ -136,6 +136,14 @@ ifeq ($(WITH_TIFF), true) CPPFLAGS += -DWITH_TIFF endif +ifeq ($(WITH_CINEON), true) + CPPFLAGS += -DWITH_CINEON +endif + +ifeq ($(WITH_HDR), true) + CPPFLAGS += -DWITH_HDR +endif + ifeq ($(OS), darwin) ifeq ($(WITH_BF_OPENMP), true) CPPFLAGS += -DPARALLEL=1 diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 77607ae25b6..d2612e90945 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -660,8 +660,10 @@ int BKE_imtype_to_ftype(int imtype) return TGA; else if(imtype== R_IRIS) return IMAGIC; +#ifdef WITH_HDR else if (imtype==R_RADHDR) return RADHDR; +#endif else if (imtype==R_PNG) return PNG; #ifdef WITH_DDS @@ -670,14 +672,18 @@ int BKE_imtype_to_ftype(int imtype) #endif else if (imtype==R_BMP) return BMP; +#ifdef WITH_TIFF else if (imtype==R_TIFF) return TIF; +#endif else if (imtype==R_OPENEXR || imtype==R_MULTILAYER) return OPENEXR; +#ifdef WITH_CINEON else if (imtype==R_CINEON) return CINEON; else if (imtype==R_DPX) return DPX; +#endif else if (imtype==R_TARGA) return TGA; else if(imtype==R_RAWTGA) @@ -696,8 +702,10 @@ int BKE_ftype_to_imtype(int ftype) return TGA; else if(ftype == IMAGIC) return R_IRIS; +#ifdef WITH_HDR else if (ftype & RADHDR) return R_RADHDR; +#endif else if (ftype & PNG) return R_PNG; #ifdef WITH_DDS @@ -706,14 +714,18 @@ int BKE_ftype_to_imtype(int ftype) #endif else if (ftype & BMP) return R_BMP; +#ifdef WITH_TIFF else if (ftype & TIF) return R_TIFF; +#endif else if (ftype & OPENEXR) return R_OPENEXR; +#ifdef WITH_CINEON else if (ftype & CINEON) return R_CINEON; else if (ftype & DPX) return R_DPX; +#endif else if (ftype & TGA) return R_TARGA; else if(ftype & RAWTGA) @@ -756,10 +768,12 @@ void BKE_add_image_extension(char *string, int imtype) if(!BLI_testextensie(string, ".rgb")) extension= ".rgb"; } +#ifdef WITH_HDR else if(imtype==R_RADHDR) { if(!BLI_testextensie(string, ".hdr")) extension= ".hdr"; } +#endif else if (ELEM5(imtype, R_PNG, R_FFMPEG, R_H264, R_THEORA, R_XVID)) { if(!BLI_testextensie(string, ".png")) extension= ".png"; @@ -790,6 +804,7 @@ void BKE_add_image_extension(char *string, int imtype) extension= ".exr"; } #endif +#ifdef WITH_CINEON else if(imtype==R_CINEON){ if (!BLI_testextensie(string, ".cin")) extension= ".cin"; @@ -798,6 +813,7 @@ void BKE_add_image_extension(char *string, int imtype) if (!BLI_testextensie(string, ".dpx")) extension= ".dpx"; } +#endif else if(imtype==R_TARGA) { if(!BLI_testextensie(string, ".tga")) extension= ".tga"; @@ -1180,12 +1196,17 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt { int ok; - if(imtype==0); - else if(imtype== R_IRIS) + if(imtype==0) { + /* pass */ + } + else if(imtype== R_IRIS) { ibuf->ftype= IMAGIC; + } +#ifdef WITH_HDR else if ((imtype==R_RADHDR)) { ibuf->ftype= RADHDR; } +#endif else if (ELEM5(imtype, R_PNG, R_FFMPEG, R_H264, R_THEORA, R_XVID)) { ibuf->ftype= PNG; @@ -1221,12 +1242,14 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt } #endif +#ifdef WITH_CINEON else if (imtype==R_CINEON) { ibuf->ftype = CINEON; } else if (imtype==R_DPX) { ibuf->ftype = DPX; } +#endif else if (imtype==R_TARGA) { ibuf->ftype= TGA; } -- cgit v1.2.3 From 49370765189d67d4c65750d9bdff12bc369bcf8f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Aug 2010 23:59:42 +0000 Subject: bugfix [#23173] Blender crashes on selecting display color corrected image in image editor notes, - Use our own callback which doesnt exit() blender. - Hard coded 'MONOSCNR.ICM' is bad, should this be a user preference or stored per image? - imb->crect was being set to imb->rect in some cases, disable this because its possible 'rect' gets reallocated and crect becomes freed memory. - when crect cant be created draw pink checkers, so users dont get confused if color correction isnt working. (previously would draw the uncorrected image, if it didnt crash) --- source/blender/blenkernel/intern/colortools.c | 61 ++++++++++++++++++--------- 1 file changed, 40 insertions(+), 21 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 11801557c99..4b694ada7fb 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -782,34 +782,53 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float *vecout, const vecout[2]= curvemap_evaluateF(cumap->cm+2, fac); } + +#ifdef WITH_LCMS +/* basic error handler, if we dont do this blender will exit */ +static int ErrorReportingFunction(int ErrorCode, const char *ErrorText) +{ + fprintf(stderr, "%s:%d\n", ErrorText, ErrorCode); + return 1; +} +#endif + void colorcorrection_do_ibuf(ImBuf *ibuf, const char *profile) { +#ifdef WITH_LCMS if (ibuf->crect == NULL) { -#ifdef WITH_LCMS - cmsHPROFILE imageProfile, proofingProfile; - cmsHTRANSFORM hTransform; + cmsHPROFILE proofingProfile; - ibuf->crect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(int), "imbuf crect"); - - imageProfile = cmsCreate_sRGBProfile(); - proofingProfile = cmsOpenProfileFromFile(profile, "r"); + /* TODO, move to initialization area of code */ + //cmsSetLogErrorHandler(ErrorReportingFunction); + cmsSetErrorHandler(ErrorReportingFunction); + /* will return NULL if the file isn't fount */ + proofingProfile = cmsOpenProfileFromFile(profile, "r"); + cmsErrorAction(LCMS_ERROR_SHOW); - - hTransform = cmsCreateProofingTransform(imageProfile, TYPE_RGBA_8, imageProfile, TYPE_RGBA_8, - proofingProfile, - INTENT_ABSOLUTE_COLORIMETRIC, - INTENT_ABSOLUTE_COLORIMETRIC, - cmsFLAGS_SOFTPROOFING); - - cmsDoTransform(hTransform, ibuf->rect, ibuf->crect, ibuf->x * ibuf->y); - - cmsDeleteTransform(hTransform); - cmsCloseProfile(imageProfile); - cmsCloseProfile(proofingProfile); -#else - ibuf->crect = ibuf->rect; + + if(proofingProfile) { + cmsHPROFILE imageProfile; + cmsHTRANSFORM hTransform; + + ibuf->crect = MEM_mallocN(ibuf->x*ibuf->y*sizeof(int), "imbuf crect"); + + imageProfile = cmsCreate_sRGBProfile(); + + + hTransform = cmsCreateProofingTransform(imageProfile, TYPE_RGBA_8, imageProfile, TYPE_RGBA_8, + proofingProfile, + INTENT_ABSOLUTE_COLORIMETRIC, + INTENT_ABSOLUTE_COLORIMETRIC, + cmsFLAGS_SOFTPROOFING); + + cmsDoTransform(hTransform, ibuf->rect, ibuf->crect, ibuf->x * ibuf->y); + + cmsDeleteTransform(hTransform); + cmsCloseProfile(imageProfile); + cmsCloseProfile(proofingProfile); + } #endif } } -- cgit v1.2.3 From 331d37e04c862821abe978faf05f132fb924b3e8 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Wed, 4 Aug 2010 00:16:18 +0000 Subject: Fix unbalanced {}. --- source/blender/blenkernel/intern/colortools.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 4b694ada7fb..90ffa39c88f 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -829,8 +829,8 @@ void colorcorrection_do_ibuf(ImBuf *ibuf, const char *profile) cmsCloseProfile(imageProfile); cmsCloseProfile(proofingProfile); } -#endif } +#endif } /* only used for image editor curves */ -- cgit v1.2.3 From 708ef646631af236f6a12faa0682f7ad3913d5e0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Aug 2010 04:01:27 +0000 Subject: include cleanup, no functional changes - removed DNA_brush_types.h from DNA_scene_types.h (and some other similar cases) - removed DNA_wave_types.h (never used) - removed Main.wave --- source/blender/blenkernel/intern/action.c | 1 + source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/armature.c | 1 + source/blender/blenkernel/intern/blender.c | 1 + source/blender/blenkernel/intern/curve.c | 1 + source/blender/blenkernel/intern/displist.c | 3 +- source/blender/blenkernel/intern/font.c | 1 + source/blender/blenkernel/intern/ipo.c | 1 + source/blender/blenkernel/intern/lattice.c | 1 + source/blender/blenkernel/intern/library.c | 45 ++++++++-------------- source/blender/blenkernel/intern/object.c | 2 +- source/blender/blenkernel/intern/paint.c | 1 + source/blender/blenkernel/intern/particle_system.c | 1 - source/blender/blenkernel/intern/scene.c | 1 + source/blender/blenkernel/intern/sequencer.c | 1 + source/blender/blenkernel/intern/sound.c | 1 + source/blender/blenkernel/intern/text.c | 4 +- source/blender/blenkernel/intern/world.c | 1 + 18 files changed, 36 insertions(+), 33 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 228860c9287..41ff3fed8a5 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -37,6 +37,7 @@ #include "DNA_armature_types.h" #include "DNA_constraint_types.h" #include "DNA_scene_types.h" +#include "DNA_object_types.h" #include "BKE_animsys.h" #include "BKE_action.h" diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index c24ec78dc1c..89c637d8192 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -49,7 +49,7 @@ #include "DNA_scene_types.h" #include "DNA_vfont_types.h" -#include "BKE_anim.h" +//(INCLUDE_LINT)#include "BKE_anim.h" #include "BKE_curve.h" #include "BKE_DerivedMesh.h" #include "BKE_depsgraph.h" diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b9b171780c7..b86be371d66 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -45,6 +45,7 @@ #include "DNA_meshdata_types.h" #include "DNA_nla_types.h" #include "DNA_scene_types.h" +#include "DNA_object_types.h" #include "BKE_animsys.h" #include "BKE_armature.h" diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 1a1f3a724ca..7c8cea12549 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -52,6 +52,7 @@ #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_sequence_types.h" +#include "DNA_sound_types.h" #include "BLI_blenlib.h" #include "BLI_dynstr.h" diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 3d7eb1624f3..d87a49496ec 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -45,6 +45,7 @@ #include "DNA_key_types.h" #include "DNA_scene_types.h" #include "DNA_vfont_types.h" +#include "DNA_object_types.h" #include "BKE_animsys.h" #include "BKE_anim.h" diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 1cb28fe56d8..09eac8e2d22 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -39,6 +39,7 @@ #include "DNA_curve_types.h" #include "DNA_meshdata_types.h" #include "DNA_scene_types.h" +#include "DNA_object_types.h" #include "DNA_material_types.h" #include "BLI_blenlib.h" @@ -153,7 +154,7 @@ void copy_displist(ListBase *lbn, ListBase *lb) } } -void addnormalsDispList(Object *ob, ListBase *lb) +void addnormalsDispList(ListBase *lb) { DispList *dl = NULL; float *vdata, *ndata, nor[3]; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index f991dee19fe..39b74be3d40 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -46,6 +46,7 @@ #include "DNA_curve_types.h" #include "DNA_vfont_types.h" #include "DNA_scene_types.h" +#include "DNA_object_types.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 64c9bf4bd07..a24f37bf73a 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -54,6 +54,7 @@ #include "DNA_sequence_types.h" #include "DNA_scene_types.h" #include "DNA_world_types.h" +#include "DNA_object_types.h" #include "BLI_math.h" /* windows needs for M_PI */ #include "BLI_blenlib.h" diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 5824afd9ded..3dea1df2353 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -44,6 +44,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_scene_types.h" +#include "DNA_object_types.h" #include "DNA_lattice_types.h" #include "DNA_curve_types.h" #include "DNA_key_types.h" diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 6852a487afa..e935573cf67 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -43,27 +43,29 @@ #include "MEM_guardedalloc.h" /* all types are needed here, in order to do memory operations */ -#include "DNA_scene_types.h" -#include "DNA_mesh_types.h" -#include "DNA_lattice_types.h" -#include "DNA_meta_types.h" -#include "DNA_material_types.h" -#include "DNA_wave_types.h" -#include "DNA_lamp_types.h" +#include "DNA_anim_types.h" +#include "DNA_armature_types.h" +#include "DNA_brush_types.h" #include "DNA_camera_types.h" +#include "DNA_group_types.h" #include "DNA_ipo_types.h" #include "DNA_key_types.h" -#include "DNA_world_types.h" +#include "DNA_lamp_types.h" +#include "DNA_lattice_types.h" +#include "DNA_material_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meta_types.h" +#include "DNA_nla_types.h" +#include "DNA_node_types.h" +#include "DNA_scene_types.h" #include "DNA_screen_types.h" -#include "DNA_vfont_types.h" -#include "DNA_text_types.h" #include "DNA_sound_types.h" -#include "DNA_group_types.h" -#include "DNA_armature_types.h" -#include "DNA_node_types.h" -#include "DNA_nla_types.h" +#include "DNA_text_types.h" +#include "DNA_vfont_types.h" #include "DNA_windowmanager_types.h" -#include "DNA_anim_types.h" +#include "DNA_world_types.h" +#include "DNA_gpencil_types.h" + #include "BLI_blenlib.h" #include "BLI_dynstr.h" @@ -174,8 +176,6 @@ int id_make_local(ID *id, int test) return 1; case ID_IM: return 0; /* not implemented */ - case ID_WV: - return 0; /* deprecated */ case ID_LT: if(!test) { make_local_lattice((Lattice*)id); @@ -264,8 +264,6 @@ int id_copy(ID *id, ID **newid, int test) case ID_IM: if(!test) *newid= (ID*)copy_image((Image*)id); return 1; - case ID_WV: - return 0; /* deprecated */ case ID_LT: if(!test) *newid= (ID*)copy_lattice((Lattice*)id); return 1; @@ -374,8 +372,6 @@ ListBase *which_libbase(Main *mainlib, short type) return &(mainlib->tex); case ID_IM: return &(mainlib->image); - case ID_WV: - return &(mainlib->wave); case ID_LT: return &(mainlib->latt); case ID_LA: @@ -475,7 +471,6 @@ int set_listbasepointers(Main *main, ListBase **lb) lb[a++]= &(main->curve); lb[a++]= &(main->mball); - lb[a++]= &(main->wave); lb[a++]= &(main->latt); lb[a++]= &(main->lamp); lb[a++]= &(main->camera); @@ -542,9 +537,6 @@ static ID *alloc_libblock_notest(short type) case ID_IM: id= MEM_callocN(sizeof(Image), "image"); break; - case ID_WV: - id= MEM_callocN(sizeof(Wave), "wave"); - break; case ID_LT: id= MEM_callocN(sizeof(Lattice), "latt"); break; @@ -746,9 +738,6 @@ void free_libblock(ListBase *lb, void *idv) case ID_IM: free_image((Image *)id); break; - case ID_WV: - /* free_wave(id); */ - break; case ID_LT: free_lattice((Lattice *)id); break; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 39e02ee584d..0f540bfa525 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -283,7 +283,7 @@ void free_object(Object *ob) ob->path= 0; if(ob->adt) BKE_free_animdata((ID *)ob); if(ob->poselib) ob->poselib->id.us--; - if(ob->gpd) ob->gpd->id.us--; + if(ob->gpd) ((ID *)ob->gpd)->us--; if(ob->defbase.first) BLI_freelistN(&ob->defbase); if(ob->pose) diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index fcbe8d65d64..b58e6c459ff 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -30,6 +30,7 @@ #include "DNA_object_types.h" #include "DNA_mesh_types.h" #include "DNA_scene_types.h" +#include "DNA_brush_types.h" #include "BKE_brush.h" #include "BKE_library.h" diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 366d2e37d78..95edfcfe803 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -62,7 +62,6 @@ #include "BLI_listbase.h" #include "BLI_threads.h" -#include "BKE_anim.h" #include "BKE_animsys.h" #include "BKE_boids.h" #include "BKE_cdderivedmesh.h" diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 48cef7e1bde..0f44c02d16d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -42,6 +42,7 @@ #include "DNA_anim_types.h" #include "DNA_group_types.h" +#include "DNA_object_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_sequence_types.h" diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index aab4e1226b2..7f3057bba96 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -39,6 +39,7 @@ #include "DNA_scene_types.h" #include "DNA_anim_types.h" #include "DNA_object_types.h" +#include "DNA_sound_types.h" #include "BKE_animsys.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index ca39355976b..8fd97a80110 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -16,6 +16,7 @@ #include "DNA_sequence_types.h" #include "DNA_packedFile_types.h" #include "DNA_screen_types.h" +#include "DNA_sound_types.h" #include "AUD_C-API.h" diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 5a6ebb187cf..c8f5eb9b187 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -43,6 +43,8 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_text_types.h" +#include "DNA_userdef_types.h" +#include "DNA_object_types.h" #include "BKE_depsgraph.h" #include "BKE_global.h" @@ -479,7 +481,7 @@ void unlink_text(Main *bmain, Text *text) for(scene=bmain->scene.first; scene; scene=scene->id.next) if(scene->r.dometext == text) scene->r.dometext = NULL; - + for(ob=bmain->object.first; ob; ob=ob->id.next) { /* game controllers */ for(cont=ob->controllers.first; cont; cont=cont->next) { diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 6fb1c5ff70c..1d1b5ec16f7 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -36,6 +36,7 @@ #include "DNA_world_types.h" #include "DNA_scene_types.h" +#include "DNA_texture_types.h" #include "BKE_library.h" #include "BKE_animsys.h" -- cgit v1.2.3 From d50cc7826fe50e1e29a2501d2b70c75360a0534e Mon Sep 17 00:00:00 2001 From: Stefan Gartner Date: Wed, 4 Aug 2010 08:42:18 +0000 Subject: == Makefiles == * add support for LCMS (disabled by default, set WITH_LCMS to true to enable it) * fixed typo that prevented TIFF support to be properly enabled * enable ray optimization by default (scons and cmake already did this) * fixed building with libsndfile on darwin (disabled by default) * quicktime: use audaspace headers from $(NAN_AUDASPACE)/include instead of intern * gameengine: add -DWITH_FFMPEG to compiler flags when building with ffmpeg support --- source/blender/blenkernel/intern/Makefile | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile index 7a4eb52326a..eb14914c7ba 100644 --- a/source/blender/blenkernel/intern/Makefile +++ b/source/blender/blenkernel/intern/Makefile @@ -149,3 +149,8 @@ ifeq ($(OS), darwin) CPPFLAGS += -DPARALLEL=1 endif endif + +ifeq ($(WITH_LCMS), true) + CPPFLAGS += -DWITH_LCMS + CPPFLAGS += -I$(BF_LCMS_INC) +endif -- cgit v1.2.3 From 1f77f7b05af24d3117d76d8c2ec43dbee031ab6a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Aug 2010 12:18:07 +0000 Subject: Brush/Paint internal changes - remove brush array for each Paint struct, just use a single brush pointer. - removed rna function based template filtering. - filter brushes using a flag on the brush and the pointer poll function. - set the brushes using a new operator WM_OT_context_set_id(). TODO - remake startup.blend, currently brush groupings are lost. - rewrite WM_OT_context_set_id() to use rna introspection. --- source/blender/blenkernel/intern/brush.c | 68 +++---------------- source/blender/blenkernel/intern/paint.c | 111 +++---------------------------- 2 files changed, 16 insertions(+), 163 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index b9d7ea177d4..905515914b4 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -35,6 +35,7 @@ #include "DNA_brush_types.h" #include "DNA_color_types.h" #include "DNA_scene_types.h" +#include "DNA_object_types.h" #include "DNA_windowmanager_types.h" #include "WM_types.h" @@ -67,6 +68,8 @@ static void brush_set_defaults(Brush *brush) brush->blend = 0; brush->flag = 0; + brush->ob_mode = (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT); + /* BRUSH SCULPT TOOL SETTINGS */ brush->size= 35; /* radius of the brush in pixels */ brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */ @@ -120,6 +123,9 @@ Brush *add_brush(const char *name) brush= alloc_libblock(&G.main->brush, ID_BR, name); + /* enable fake user by default */ + brush->id.flag |= LIB_FAKEUSER; + brush_set_defaults(brush); brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */ @@ -127,10 +133,6 @@ Brush *add_brush(const char *name) /* the default alpha falloff curve */ brush_curve_preset(brush, CURVE_PRESET_SMOOTH); - /* enable fake user by default */ - brush->id.flag |= LIB_FAKEUSER; - brush_toggled_fake_user(brush); - return brush; } @@ -151,7 +153,7 @@ Brush *copy_brush(Brush *brush) /* enable fake user by default */ if (!(brushn->id.flag & LIB_FAKEUSER)) { brushn->id.flag |= LIB_FAKEUSER; - brush_toggled_fake_user(brushn); + brushn->id.us++; } return brushn; @@ -205,7 +207,7 @@ void make_local_brush(Brush *brush) /* enable fake user by default */ if (!(brush->id.flag & LIB_FAKEUSER)) { brush->id.flag |= LIB_FAKEUSER; - brush_toggled_fake_user(brush); + brush->id.us++; } } else if(local && lib) { @@ -393,54 +395,6 @@ void brush_reset_sculpt(Brush *br) } /* Library Operations */ - -int brush_set_nr(Brush **current_brush, int nr, const char *name) -{ - ID *idtest, *id; - - id= (ID*)(*current_brush); - idtest= (ID*)BLI_findlink(&G.main->brush, nr-1); - - if(idtest==0) { /* new brush */ - if(id) idtest= (ID *)copy_brush((Brush *)id); - else idtest= (ID *)add_brush(name); - idtest->us--; - } - if(idtest!=id) { - brush_delete(current_brush); - *current_brush= (Brush *)idtest; - id_us_plus(idtest); - - return 1; - } - - return 0; -} - -int brush_delete(Brush **current_brush) -{ - if (*current_brush) { - (*current_brush)->id.us--; - *current_brush= NULL; - - return 1; - } - - return 0; -} - -void brush_toggled_fake_user(Brush *brush) -{ - ID *id= (ID*)brush; - if(id) { - if(id->flag & LIB_FAKEUSER) { - id_us_plus(id); - } else { - id->us--; - } - } -} - void brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) { CurveMap *cm = NULL; @@ -524,12 +478,6 @@ int brush_clone_image_delete(Brush *brush) return 0; } -void brush_check_exists(Brush **brush, const char *name) -{ - if(*brush==NULL) - brush_set_nr(brush, 1, name); -} - /* Brush Sampling */ void brush_sample_tex(Brush *brush, float *xy, float *rgba) { diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index b58e6c459ff..3343df6b8a7 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -71,91 +71,13 @@ Paint *paint_get_active(Scene *sce) Brush *paint_brush(Paint *p) { - return p && p->brushes ? p->brushes[p->active_brush_index] : NULL; + return p ? p->brush : NULL; } void paint_brush_set(Paint *p, Brush *br) { - if(p && !br) { - /* Setting to NULL removes the current slot */ - paint_brush_slot_remove(p); - } - else if(p) { - int found = 0; - - if(p->brushes) { - int i; - - /* See if there's already a slot with the brush */ - for(i = 0; i < p->brush_count; ++i) { - if(p->brushes[i] == br) { - p->active_brush_index = i; - found = 1; - break; - } - } - - } - - if(!found) { - paint_brush_slot_add(p); - id_us_plus(&br->id); - } - - /* Make sure the current slot is the new brush */ - p->brushes[p->active_brush_index] = br; - } -} - -static void paint_brush_slots_alloc(Paint *p, const int count) -{ - p->brush_count = count; - if(count == 0) - p->brushes = NULL; - else - p->brushes = MEM_callocN(sizeof(Brush*) * count, "Brush slots"); -} - -void paint_brush_slot_add(Paint *p) -{ - if(p) { - Brush **orig = p->brushes; - int orig_count = p->brushes ? p->brush_count : 0; - - /* Increase size of brush slot array */ - paint_brush_slots_alloc(p, orig_count + 1); - if(orig) { - memcpy(p->brushes, orig, sizeof(Brush*) * orig_count); - MEM_freeN(orig); - } - - p->active_brush_index = orig_count; - } -} - -void paint_brush_slot_remove(Paint *p) -{ - if(p && p->brushes) { - Brush **orig = p->brushes; - int src, dst; - - /* Decrease size of brush slot array */ - paint_brush_slots_alloc(p, p->brush_count - 1); - if(p->brushes) { - for(src = 0, dst = 0; dst < p->brush_count; ++src) { - if(src != p->active_brush_index) { - p->brushes[dst] = orig[src]; - ++dst; - } - } - } - MEM_freeN(orig); - - if(p->active_brush_index >= p->brush_count) - p->active_brush_index = p->brush_count - 1; - if(p->active_brush_index < 0) - p->active_brush_index = 0; - } + if(p) + p->brush= br; } int paint_facesel_test(Object *ob) @@ -169,7 +91,8 @@ void paint_init(Paint *p, const char col[3]) /* If there's no brush, create one */ brush = paint_brush(p); - brush_check_exists(&brush, "Brush"); + if(brush == NULL) + brush= add_brush("Brush"); paint_brush_set(p, brush); memcpy(p->paint_cursor_col, col, 3); @@ -180,28 +103,10 @@ void paint_init(Paint *p, const char col[3]) void free_paint(Paint *paint) { - if(paint->brushes) - MEM_freeN(paint->brushes); + /* nothing */ } -void copy_paint(Paint *orig, Paint *new) +void copy_paint(Paint *src, Paint *tar) { - if(orig->brushes) { - int i; - new->brushes = MEM_dupallocN(orig->brushes); - for(i = 0; i < orig->brush_count; ++i) - id_us_plus((ID *)new->brushes[i]); - } -} - -int paint_has_brush(Paint *p, Brush *brush) -{ - int i; - - for (i= 0; i < p->brush_count; i++) { - if (strcmp(brush->id.name+2, p->brushes[i]->id.name+2) == 0) - return 1; - } - - return 0; + tar->brush= src->brush; } -- cgit v1.2.3 From 3840b0c206d02d32a221cb0d53b3339eb73ecb57 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 4 Aug 2010 15:51:52 +0000 Subject: Fix #22869: procedural compositing buffers from texture nodes were not restored correct between localize/merge, bugfix for #21727 only did it one way. --- source/blender/blenkernel/intern/node.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index ff1887b0883..2a4713ee25c 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2651,8 +2651,9 @@ void ntreeLocalMerge(bNodeTree *localtree, bNodeTree *ntree) for(lsock= lnode->outputs.first; lsock; lsock= lsock->next) { if(outsocket_exists(lnode->new_node, lsock->new_sock)) { lsock->new_sock->ns.data= lsock->ns.data; + compbuf_set_node(lsock->new_sock->ns.data, lnode->new_node); lsock->ns.data= NULL; - lsock->new_sock= NULL; + lsock->new_sock= NULL; } } } -- cgit v1.2.3 From 0990e3a9a6e9b1fb89d8aaf2291372cc83278bbc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 4 Aug 2010 16:14:03 +0000 Subject: Fix #23003: setting particle number to 0 was not working correct, committing patch #23119 by Jeroen Bakker to fix this, thanks! --- source/blender/blenkernel/intern/particle_system.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 95edfcfe803..9b9c3ff16b6 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -181,7 +181,7 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) else totpart=new_totpart; - if(totpart && totpart != psys->totpart) { + if(totpart != psys->totpart) { if(psys->edit && psys->free_edit) { psys->free_edit(psys->edit); psys->edit = NULL; -- cgit v1.2.3 From 5f77852a479952560cbbcccab6fcf07b4fd9c0b2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 5 Aug 2010 08:39:25 +0000 Subject: Do not reset bevel/taper object when they've got incorrect type - just do noting in makebevelcurve and calc_taper functions if type is not curve. This avoids DNA changing depended on object recalc. --- source/blender/blenkernel/intern/curve.c | 2 ++ source/blender/blenkernel/intern/displist.c | 11 +---------- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index d87a49496ec..ce43f082688 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1222,6 +1222,8 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) // XXX if( ob == obedit && ob->type == OB_FONT ) return; if(cu->bevobj) { + if (cu->bevobj->type!=OB_CURVE) return; + bevcu= cu->bevobj->data; if(bevcu->ext1==0.0 && bevcu->ext2==0.0) { ListBase bevdisp= {NULL, NULL}; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 09eac8e2d22..a44c5ace298 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1129,7 +1129,7 @@ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) Curve *cu; DispList *dl; - if(taperobj==NULL) return 1.0; + if(taperobj==NULL || taperobj->type!=OB_CURVE) return 1.0; cu= taperobj->data; dl= cu->disp.first; @@ -1682,15 +1682,6 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba float (*deformedVerts)[3]; int numVerts; - /* Bevel and taper objects should always be curves */ - if (cu->bevobj && cu->bevobj->type != OB_CURVE) { - cu->bevobj = NULL; - } - - if (cu->taperobj && cu->taperobj->type != OB_CURVE) { - cu->taperobj = NULL; - } - nubase= BKE_curve_nurbs(cu); BLI_freelistN(&(cu->bev)); -- cgit v1.2.3 From 8c75853bb6cecc70e201e38c7354c36539419324 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 5 Aug 2010 10:50:38 +0000 Subject: bugfix [#23164] Copied Scene Nodes! copying a scene would still have nodes point back to the old scene which would crash (in some cases) or break rendering. --- source/blender/blenkernel/intern/node.c | 13 +++++++++++++ source/blender/blenkernel/intern/scene.c | 9 ++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 2a4713ee25c..36c23216585 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1064,6 +1064,7 @@ bNodeTree *ntreeAddTree(int type) * - internal_select is only 1 when used for duplicating selected nodes (i.e. Shift-D duplicate operator) * - this gets called when executing compositing updates (for threaded previews) * - when the nodetree datablock needs to be copied (i.e. when users get copied) + * - for scene duplication use ntreeSwapID() after so we dont have stale pointers. */ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select) { @@ -1142,6 +1143,18 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select) return newtree; } +/* use when duplicating scenes */ +void ntreeSwitchID(bNodeTree *ntree, ID *id_from, ID *id_to) +{ + bNode *node; + /* for scene duplication only */ + for(node= ntree->nodes.first; node; node= node->next) { + if(node->id==id_from) { + node->id= id_to; + } + } +} + /* *************** preview *********** */ /* if node->preview, then we assume the rect to exist */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 0f44c02d16d..95705ea8c05 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -172,9 +172,12 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) BLI_duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces)); BLI_duplicatelist(&(scen->r.layers), &(sce->r.layers)); BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); - - scen->nodetree= ntreeCopyTree(sce->nodetree, 0); - + + if(sce->nodetree) { + scen->nodetree= ntreeCopyTree(sce->nodetree, 0); + ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); + } + obase= sce->base.first; base= scen->base.first; while(base) { -- cgit v1.2.3 From 6820d13511ac3a96296ab3f7b65d69a45cb732f4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Aug 2010 05:19:00 +0000 Subject: Minor cleanup to lattice.c while looking into [#19525] Curve modifier moves mesh geometry first A subtle change with the curve deform modifier is when a vgroup is used: the mesh bounds were being calculated based on the verts in the group (ignoring their weight). Now ignore verts weighted at 0. --- source/blender/blenkernel/intern/lattice.c | 70 +++++++++++++----------------- 1 file changed, 30 insertions(+), 40 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 3dea1df2353..7d8c7a08690 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -175,7 +175,7 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) bp= lt->def; for (i=0; ipntsu*lt->pntsv*lt->pntsw; i++,bp++) { - VECCOPY(bp->vec, vertexCos[i]); + copy_v3_v3(bp->vec, vertexCos[i]); } MEM_freeN(vertexCos); @@ -474,7 +474,9 @@ static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd, int dloc invert_m4_m4(par->imat, par->obmat); mul_v3_m4v3(cd->dloc, par->imat, ob->obmat[3]); } - else cd->dloc[0]=cd->dloc[1]=cd->dloc[2]= 0.0f; + else { + cd->dloc[0]=cd->dloc[1]=cd->dloc[2]= 0.0f; + } cd->no_rot_axis= 0; } @@ -507,15 +509,15 @@ static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir, if(ctime < 0.0) { sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec); mul_v3_fl(dvec, ctime*(float)path->len); - VECADD(vec, vec, dvec); - if(quat) QUATCOPY(quat, path->data[0].quat); + add_v3_v3(vec, dvec); + if(quat) copy_qt_qt(quat, path->data[0].quat); if(radius) *radius= path->data[0].radius; } else if(ctime > 1.0) { sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec); mul_v3_fl(dvec, (ctime-1.0)*(float)path->len); - VECADD(vec, vec, dvec); - if(quat) QUATCOPY(quat, path->data[path->len-1].quat); + add_v3_v3(vec, dvec); + if(quat) copy_qt_qt(quat, path->data[path->len-1].quat); if(radius) *radius= path->data[path->len-1].radius; /* weight - not used but could be added */ } @@ -608,7 +610,7 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather then * changing the axis before calculating the tilt but serves much the same purpose */ float dir_flat[3]={0,0,0}, q[4]; - VECCOPY(dir_flat, dir); + copy_v3_v3(dir_flat, dir); dir_flat[cd->no_rot_axis-1]= 0.0f; normalize_v3(dir); @@ -686,11 +688,11 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C mul_qt_v3(quat, cent); /* translation */ - VECADD(co, cent, loc); + add_v3_v3v3(co, cent, loc); if(quatp) - QUATCOPY(quatp, quat); - + copy_qt_qt(quatp, quat); + return 1; } return 0; @@ -726,48 +728,36 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh use_vgroups = 0; if(vgroup && vgroup[0] && use_vgroups) { - bDeformGroup *curdef; Mesh *me= target->data; - int index; - - /* find the group (weak loop-in-loop) */ - for(index = 0, curdef = target->defbase.first; curdef; - curdef = curdef->next, index++) - if (!strcmp(curdef->name, vgroup)) - break; + int index= defgroup_name_index(target, vgroup); - if(curdef && (me->dvert || dm)) { + if(index != -1 && (me->dvert || dm)) { MDeformVert *dvert = me->dvert; float vec[3]; - int j; + float weight; INIT_MINMAX(cd.dmin, cd.dmax); for(a = 0; a < numVerts; a++, dvert++) { if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - - for(j = 0; j < dvert->totweight; j++) { - if(dvert->dw[j].def_nr == index) { - mul_m4_v3(cd.curvespace, vertexCos[a]); - DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); - break; - } + + if(defvert_find_weight(dvert, index) > 0.0f) { + mul_m4_v3(cd.curvespace, vertexCos[a]); + DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); } } dvert = me->dvert; for(a = 0; a < numVerts; a++, dvert++) { if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); + + weight= defvert_find_weight(dvert, index); - for(j = 0; j < dvert->totweight; j++) { - if(dvert->dw[j].def_nr == index) { - VECCOPY(vec, vertexCos[a]); - calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); - interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, - dvert->dw[j].weight); - mul_m4_v3(cd.objectspace, vertexCos[a]); - break; - } + if(weight > 0.0f) { + copy_v3_v3(vec, vertexCos[a]); + calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); + interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight); + mul_m4_v3(cd.objectspace, vertexCos[a]); } } } @@ -803,8 +793,8 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco init_curve_deform(cuOb, target, &cd, 0); /* 0 no dloc */ cd.no_rot_axis= no_rot_axis; /* option to only rotate for XY, for example */ - VECCOPY(cd.dmin, orco); - VECCOPY(cd.dmax, orco); + copy_v3_v3(cd.dmin, orco); + copy_v3_v3(cd.dmax, orco); mul_m4_v3(cd.curvespace, vec); @@ -973,7 +963,7 @@ float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3] vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts,"lt_vcos"); for (i=0; idef[i].vec); + copy_v3_v3(vertexCos[i], lt->def[i].vec); } return vertexCos; @@ -985,7 +975,7 @@ void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3]) int i, numVerts = lt->pntsu*lt->pntsv*lt->pntsw; for (i=0; idef[i].vec, vertexCos[i]); + copy_v3_v3(lt->def[i].vec, vertexCos[i]); } } -- cgit v1.2.3 From 14fe11bd8118fcd4f5605305cd23cb269d38fc75 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 6 Aug 2010 08:27:07 +0000 Subject: bugfix [#19525] Curve modifier moves mesh geometry first more of a request then a bug but shows up a strange limitation with curve deform modifier, The mesh bounding box would set the deform axis start/end to map the deformation of the curve to. This means it ignored offset in the object location and object data location (you could use a dummy vertex to trick it). Old files wont change, added an option (next to stretch), called 'Bounds Clamp', old files have this behavior but newly made curves have it disabled. Double checked this gives useful results with stretch on/off and negative axis. --- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/lattice.c | 105 ++++++++++++++++++++--------- source/blender/blenkernel/intern/object.c | 11 ++- 3 files changed, 80 insertions(+), 38 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index ce43f082688..841bd635acf 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -127,7 +127,7 @@ Curve *add_curve(char *name, int type) cu= alloc_libblock(&G.main->curve, ID_CU, name); cu->size[0]= cu->size[1]= cu->size[2]= 1.0; - cu->flag= CU_FRONT|CU_BACK|CU_PATH_RADIUS; + cu->flag= CU_FRONT|CU_BACK|CU_DEFORM_BOUNDS_OFF|CU_PATH_RADIUS; cu->pathlen= 100; cu->resolu= cu->resolv= 12; cu->width= 1.0; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 7d8c7a08690..1eb7b5d2021 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -713,7 +713,18 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh cu->flag |= (CU_PATH|CU_FOLLOW); // needed for path & bevlist init_curve_deform(cuOb, target, &cd, (cu->flag & CU_STRETCH)==0); - + + /* dummy bounds, keep if CU_DEFORM_BOUNDS_OFF is set */ + if(defaxis < 3) { + cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f; + cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f; + } + else { + /* negative, these bounds give a good rest position */ + cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= -1.0f; + cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 0.0f; + } + /* check whether to use vertex groups (only possible if target is a Mesh) * we want either a Mesh with no derived data, or derived data with * deformverts @@ -735,43 +746,77 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh MDeformVert *dvert = me->dvert; float vec[3]; float weight; + - INIT_MINMAX(cd.dmin, cd.dmax); - - for(a = 0; a < numVerts; a++, dvert++) { - if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); + if(cu->flag & CU_DEFORM_BOUNDS_OFF) { + /* dummy bounds */ + cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f; + cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f; - if(defvert_find_weight(dvert, index) > 0.0f) { - mul_m4_v3(cd.curvespace, vertexCos[a]); - DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); + dvert = me->dvert; + for(a = 0; a < numVerts; a++, dvert++) { + if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); + weight= defvert_find_weight(dvert, index); + + if(weight > 0.0f) { + mul_m4_v3(cd.curvespace, vertexCos[a]); + copy_v3_v3(vec, vertexCos[a]); + calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); + interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight); + mul_m4_v3(cd.objectspace, vertexCos[a]); + } } } - - dvert = me->dvert; - for(a = 0; a < numVerts; a++, dvert++) { - if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - - weight= defvert_find_weight(dvert, index); - - if(weight > 0.0f) { - copy_v3_v3(vec, vertexCos[a]); - calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); - interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight); - mul_m4_v3(cd.objectspace, vertexCos[a]); + else { + /* set mesh min/max bounds */ + INIT_MINMAX(cd.dmin, cd.dmax); + + for(a = 0; a < numVerts; a++, dvert++) { + if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); + + if(defvert_find_weight(dvert, index) > 0.0f) { + mul_m4_v3(cd.curvespace, vertexCos[a]); + DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); + } + } + + dvert = me->dvert; + for(a = 0; a < numVerts; a++, dvert++) { + if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); + + weight= defvert_find_weight(dvert, index); + + if(weight > 0.0f) { + copy_v3_v3(vec, vertexCos[a]); + calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL); + interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight); + mul_m4_v3(cd.objectspace, vertexCos[a]); + } } } } - } else { - INIT_MINMAX(cd.dmin, cd.dmax); - - for(a = 0; a < numVerts; a++) { - mul_m4_v3(cd.curvespace, vertexCos[a]); - DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); + } + else { + if(cu->flag & CU_DEFORM_BOUNDS_OFF) { + for(a = 0; a < numVerts; a++) { + mul_m4_v3(cd.curvespace, vertexCos[a]); + calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL); + mul_m4_v3(cd.objectspace, vertexCos[a]); + } } - - for(a = 0; a < numVerts; a++) { - calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL); - mul_m4_v3(cd.objectspace, vertexCos[a]); + else { + /* set mesh min max bounds */ + INIT_MINMAX(cd.dmin, cd.dmax); + + for(a = 0; a < numVerts; a++) { + mul_m4_v3(cd.curvespace, vertexCos[a]); + DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax); + } + + for(a = 0; a < numVerts; a++) { + calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL); + mul_m4_v3(cd.objectspace, vertexCos[a]); + } } } cu->flag = flag; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0f540bfa525..c08a3408505 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1627,10 +1627,7 @@ float bsystem_time(struct Scene *scene, Object *ob, float cfra, float ofs) void object_scale_to_mat3(Object *ob, float mat[][3]) { float vec[3]; - - vec[0]= ob->size[0]+ob->dsize[0]; - vec[1]= ob->size[1]+ob->dsize[1]; - vec[2]= ob->size[2]+ob->dsize[2]; + add_v3_v3v3(vec, ob->size, ob->dsize); size_to_mat3( mat,vec); } @@ -1688,7 +1685,7 @@ void object_mat3_to_rot(Object *ob, float mat[][3], int use_compat) void object_apply_mat4(Object *ob, float mat[][4]) { float mat3[3][3]; - VECCOPY(ob->loc, mat[3]); + copy_v3_v3(ob->loc, mat[3]); mat4_to_size(ob->size, mat); copy_m3_m4(mat3, mat); object_mat3_to_rot(ob, mat3, 0); @@ -1796,7 +1793,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) copy_m4_m4(mat, rmat); } - VECCOPY(mat[3], vec); + copy_v3_v3(mat[3], vec); } } @@ -1823,7 +1820,7 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4]) copy_m4_m4(mat, pchan->pose_mat); /* but for backwards compatibility, the child has to move to the tail */ - VECCOPY(vec, mat[1]); + copy_v3_v3(vec, mat[1]); mul_v3_fl(vec, pchan->bone->length); add_v3_v3(mat[3], vec); } -- cgit v1.2.3 From 0c54337755fb51217701f49396f6534ec7ec3438 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 8 Aug 2010 13:55:30 +0000 Subject: == Sequencer == This fixes: [#23184] Problems with speed control effect strip in the video sequence editor Also: got rid of tstripdata caches in DNA. Fixes some potential crashes in SEQ_IMAGE rendering (s_elem wasn't checked for NULL). --- source/blender/blenkernel/intern/seqeffects.c | 21 +++++---------------- source/blender/blenkernel/intern/sequencer.c | 12 +++--------- 2 files changed, 8 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index c117f51c072..1e1ace0f758 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2968,22 +2968,11 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) fallback_fac = 1.0; - /* if there is no IPO, try to make retiming easy by stretching the + /* if there is no fcurve, try to make retiming easy by stretching the strip */ - // XXX old animation system - seq if (!fcu && seq->seq1->enddisp != seq->seq1->start && seq->seq1->len != 0) { fallback_fac = (float) seq->seq1->len / (float) (seq->seq1->enddisp - seq->seq1->start); - /* FIXME: this strip stretching gets screwed by stripdata - handling one layer up. - - So it currently works by enlarging, never by shrinking! - - (IPOs still work, if used correctly) - */ - if (fallback_fac > 1.0) { - fallback_fac = 1.0; - } } if ((v->flags & SEQ_SPEED_INTEGRATE) != 0) { @@ -3006,8 +2995,8 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) cursor += facf; - if (cursor >= v->length) { - v->frameMap[cfra] = v->length - 1; + if (cursor >= seq->seq1->len) { + v->frameMap[cfra] = seq->seq1->len - 1; } else { v->frameMap[cfra] = cursor; v->lastValidFrame = cfra; @@ -3033,8 +3022,8 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) facf = (float) cfra * fallback_fac; } facf *= v->globalSpeed; - if (facf >= v->length) { - facf = v->length - 1; + if (facf >= seq->seq1->len) { + facf = seq->seq1->len - 1; } else { v->lastValidFrame = cfra; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 7f3057bba96..9d0fcc95c7c 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -899,7 +899,6 @@ static float give_stripelem_index(Sequence *seq, float cfra) { float nr; - if(seq->startdisp >cfra || seq->enddisp <= cfra) return -1; if(seq->len == 0) return -1; if(seq->flag&SEQ_REVERSE_FRAMES) { /*reverse frame in this sequence */ @@ -1993,7 +1992,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra, } else if(seq->type == SEQ_IMAGE) { StripElem * s_elem = give_stripelem(seq, cfra); - if(ibuf == 0) { + if(ibuf == 0 && s_elem) { BLI_join_dirfile(name, seq->strip->dir, s_elem->name); BLI_path_abs(name, G.sce); @@ -2004,7 +2003,8 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra, ibuf = copy_from_ibuf_still(seq,nr,seqrectx,seqrecty); } - if (ibuf == 0 && (ibuf=IMB_loadiffname(name, IB_rect))) { + if (ibuf == 0 && s_elem && + (ibuf = IMB_loadiffname(name, IB_rect))) { /* we don't need both (speed reasons)! */ if (ibuf->rect_float && ibuf->rect) imb_freerectImBuf(ibuf); @@ -3541,12 +3541,6 @@ static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag) // XXX: add F-Curve duplication stuff? - seqn->strip->tstripdata = 0; - seqn->strip->tstripdata_startstill = 0; - seqn->strip->tstripdata_endstill = 0; - seqn->strip->ibuf_startstill = 0; - seqn->strip->ibuf_endstill = 0; - if (seq->strip->crop) { seqn->strip->crop = MEM_dupallocN(seq->strip->crop); } -- cgit v1.2.3 From f46a649965bd15af74e1f53cc3dbc5a1ccc34acf Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 8 Aug 2010 14:21:20 +0000 Subject: This fixes: [#20884] SEQUENCER EFFECT: Animating Speed Control Opacity has no effect [#21308] SEQUENCER EFFECT: Glow ignores Opacity setting --- source/blender/blenkernel/intern/sequencer.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 9d0fcc95c7c..866f907ef9e 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1460,8 +1460,7 @@ int input_have_to_preprocess( mul = seq->mul; - if(seq->blend_mode == SEQ_BLEND_REPLACE && - !(seq->type & SEQ_EFFECT)) { + if(seq->blend_mode == SEQ_BLEND_REPLACE) { mul *= seq->blend_opacity / 100.0; } -- cgit v1.2.3 From 15669532a231b25ef4cddd36720376ec4b8f3dc2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Aug 2010 05:41:51 +0000 Subject: header re-shuffle, some headers contained unneeded refereces to other headers, better include inline with the C files that need them --- source/blender/blenkernel/intern/cloth.c | 8 ++++++++ source/blender/blenkernel/intern/collision.c | 5 +++++ source/blender/blenkernel/intern/implicit.c | 13 +++++++++---- source/blender/blenkernel/intern/modifier.c | 12 +++++++----- source/blender/blenkernel/intern/particle.c | 4 ++++ source/blender/blenkernel/intern/pointcache.c | 1 + source/blender/blenkernel/intern/softbody.c | 5 +++-- 7 files changed, 37 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index b9b1c16c0c4..bebfa4af88e 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -27,6 +27,14 @@ #include "MEM_guardedalloc.h" +#include "DNA_cloth_types.h" +#include "DNA_scene_types.h" +#include "DNA_object_types.h" +#include "DNA_meshdata_types.h" + +#include "BLI_math.h" +#include "BLI_edgehash.h" + #include "BKE_cdderivedmesh.h" #include "BKE_cloth.h" #include "BKE_effect.h" diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 54adc648539..3a9c15f654c 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -37,6 +37,11 @@ #include "DNA_object_types.h" #include "DNA_object_force.h" #include "DNA_scene_types.h" +#include "DNA_meshdata_types.h" + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_edgehash.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 902965bd2f6..d544174b0d4 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -29,16 +29,21 @@ #include "MEM_guardedalloc.h" -#include "BKE_cloth.h" - +#include "DNA_scene_types.h" +#include "DNA_object_types.h" #include "DNA_object_force.h" +#include "DNA_meshdata_types.h" + +#include "BLI_threads.h" +#include "BLI_math.h" +#include "BLI_linklist.h" +#include "BKE_cloth.h" +#include "BKE_collision.h" #include "BKE_effect.h" #include "BKE_global.h" #include "BKE_utildefines.h" -#include "BLI_threads.h" - #define CLOTH_OPENMP_LIMIT 25 #ifdef _WIN32 diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 858e9d6c6d9..ea118e4a53c 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -41,6 +41,8 @@ #include "float.h" #include "DNA_armature_types.h" +#include "DNA_object_types.h" +#include "DNA_meshdata_types.h" #include "BKE_bmesh.h" #include "BKE_cloth.h" @@ -193,7 +195,7 @@ void modifier_copyData(ModifierData *md, ModifierData *target) mti->copyData(md, target); } -int modifier_couldBeCage(Scene *scene, ModifierData *md) +int modifier_couldBeCage(struct Scene *scene, ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -233,7 +235,7 @@ void modifier_setError(ModifierData *md, char *format, ...) * also used in transform_conversion.c, to detect CrazySpace [tm] (2nd arg * then is NULL) */ -int modifiers_getCageIndex(Scene *scene, Object *ob, int *lastPossibleCageIndex_r, int virtual_) +int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *lastPossibleCageIndex_r, int virtual_) { ModifierData *md = (virtual_)? modifiers_getVirtualModifierList(ob): ob->modifiers.first; int i, cageIndex = -1; @@ -283,7 +285,7 @@ int modifiers_isParticleEnabled(Object *ob) return (md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)); } -int modifier_isEnabled(Scene *scene, ModifierData *md, int required_mode) +int modifier_isEnabled(struct Scene *scene, ModifierData *md, int required_mode) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -298,7 +300,7 @@ int modifier_isEnabled(Scene *scene, ModifierData *md, int required_mode) return 1; } -LinkNode *modifiers_calcDataMasks(Scene *scene, Object *ob, ModifierData *md, CustomDataMask dataMask, int required_mode) +LinkNode *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierData *md, CustomDataMask dataMask, int required_mode) { LinkNode *dataMasks = NULL; LinkNode *curr, *prev; @@ -487,7 +489,7 @@ int modifier_isCorrectableDeformed(ModifierData *md) return 0; } -int modifiers_isCorrectableDeformed(Scene *scene, Object *ob) +int modifiers_isCorrectableDeformed(struct Scene *scene, Object *ob) { ModifierData *md = modifiers_getVirtualModifierList(ob); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 52ee0180f43..7b3638f0e33 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -40,12 +40,16 @@ #include "DNA_key_types.h" #include "DNA_material_types.h" #include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" #include "DNA_particle_types.h" #include "DNA_smoke_types.h" +#include "DNA_scene_types.h" +#include "BLI_blenlib.h" #include "BLI_kdtree.h" #include "BLI_rand.h" #include "BLI_threads.h" +#include "BLI_math.h" #include "BKE_anim.h" #include "BKE_animsys.h" diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index d44221d2cd3..6cf49808ec7 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -43,6 +43,7 @@ #include "BLI_blenlib.h" #include "BLI_threads.h" +#include "BLI_math.h" #include "PIL_time.h" diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 4d1994e760b..b8e824ce3d5 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -55,11 +55,12 @@ variables on the UI for now #include "MEM_guardedalloc.h" /* types */ +#include "DNA_object_types.h" +#include "DNA_scene_types.h" +#include "DNA_lattice_types.h" #include "DNA_curve_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "DNA_lattice_types.h" -#include "DNA_scene_types.h" #include "BLI_math.h" #include "BLI_ghash.h" -- cgit v1.2.3 From c0e39df6ac42d137fd51eeea463aace856bf97d4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 10 Aug 2010 06:36:42 +0000 Subject: - Enable shape key switching in edit mode for curves, surfaces and latticies - Disable changing of lattice size if there are shape keys --- source/blender/blenkernel/intern/lattice.c | 18 +++++++++++------- source/blender/blenkernel/intern/object.c | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 1eb7b5d2021..1390f0dbd56 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -225,8 +225,12 @@ void free_lattice(Lattice *lt) if(lt->def) MEM_freeN(lt->def); if(lt->dvert) free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); if(lt->editlatt) { - if(lt->editlatt->def) MEM_freeN(lt->editlatt->def); - if(lt->editlatt->dvert) free_dverts(lt->editlatt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); + Lattice *editlt= lt->editlatt->latt; + + if(editlt->def) MEM_freeN(editlt->def); + if(editlt->dvert) free_dverts(editlt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); + + MEM_freeN(editlt); MEM_freeN(lt->editlatt); } } @@ -295,7 +299,7 @@ void init_latt_deform(Object *oblatt, Object *ob) float fu, fv, fw; int u, v, w; - if(lt->editlatt) lt= lt->editlatt; + if(lt->editlatt) lt= lt->editlatt->latt; bp = lt->def; fp= lt->latticedata= MEM_mallocN(sizeof(float)*3*lt->pntsu*lt->pntsv*lt->pntsw, "latticedata"); @@ -350,7 +354,7 @@ void calc_latt_deform(Object *ob, float *co, float weight) MDeformVert *dvert= lattice_get_deform_verts(ob); - if(lt->editlatt) lt= lt->editlatt; + if(lt->editlatt) lt= lt->editlatt->latt; if(lt->latticedata==NULL) return; if(lt->vgroup[0] && dvert) { @@ -446,7 +450,7 @@ void end_latt_deform(Object *ob) { Lattice *lt= ob->data; - if(lt->editlatt) lt= lt->editlatt; + if(lt->editlatt) lt= lt->editlatt->latt; if(lt->latticedata) MEM_freeN(lt->latticedata); @@ -1002,7 +1006,7 @@ float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3] int i, numVerts; float (*vertexCos)[3]; - if(lt->editlatt) lt= lt->editlatt; + if(lt->editlatt) lt= lt->editlatt->latt; numVerts = *numVerts_r = lt->pntsu*lt->pntsv*lt->pntsw; vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts,"lt_vcos"); @@ -1066,7 +1070,7 @@ struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt) if(oblatt->type == OB_LATTICE) { Lattice *lt = (Lattice*)oblatt->data; - if(lt->editlatt) lt= lt->editlatt; + if(lt->editlatt) lt= lt->editlatt->latt; return lt->dvert; } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index c08a3408505..18eedd63906 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1917,7 +1917,7 @@ static void give_parvert(Object *par, int nr, float *vec) DispList *dl = find_displist(&par->disp, DL_VERTS); float *co = dl?dl->verts:NULL; - if(latt->editlatt) latt= latt->editlatt; + if(latt->editlatt) latt= latt->editlatt->latt; a= latt->pntsu*latt->pntsv*latt->pntsw; count= 0; -- cgit v1.2.3 From ad4fc20ec9efa2352021b06402807d0947912458 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 10 Aug 2010 15:14:19 +0000 Subject: moved idcode functions into their own file (was added as a todo in the comments), these were mixed in with file reading code - BLO_readfile.h bot these functions are not spesific to reading. --- source/blender/blenkernel/intern/idcode.c | 128 ++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 source/blender/blenkernel/intern/idcode.c (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c new file mode 100644 index 00000000000..c9dee00a15c --- /dev/null +++ b/source/blender/blenkernel/intern/idcode.c @@ -0,0 +1,128 @@ +/** + * $Id: readblenentry.c 31028 2010-08-04 04:01:27Z campbellbarton $ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * return info about ID types + */ + +#include +#include + +#include "DNA_ID.h" + +typedef struct { + unsigned short code; + char *name, *plural; + + int flags; +#define IDTYPE_FLAGS_ISLINKABLE (1<<0) +} IDType; + +/* plural need to match rna_main.c's MainCollectionDef */ +static IDType idtypes[]= { + { ID_AC, "Action", "actions", IDTYPE_FLAGS_ISLINKABLE}, + { ID_AR, "Armature", "armatures", IDTYPE_FLAGS_ISLINKABLE}, + { ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE}, + { ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE}, + { ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE}, + { ID_GD, "GPencil", "gpencil", IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */ + { ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE}, + { ID_ID, "ID", "ids", 0}, /* plural is fake */ + { ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE}, + { ID_IP, "Ipo", "ipos", IDTYPE_FLAGS_ISLINKABLE}, /* deprecated */ + { ID_KE, "Key", "keys", 0}, + { ID_LA, "Lamp", "lamps", IDTYPE_FLAGS_ISLINKABLE}, + { ID_LI, "Library", "libraries", 0}, + { ID_LT, "Lattice", "lattices", IDTYPE_FLAGS_ISLINKABLE}, + { ID_MA, "Material", "materials", IDTYPE_FLAGS_ISLINKABLE}, + { ID_MB, "Metaball", "metaballs", IDTYPE_FLAGS_ISLINKABLE}, + { ID_ME, "Mesh", "meshes", IDTYPE_FLAGS_ISLINKABLE}, + { ID_NT, "NodeTree", "node_groups", IDTYPE_FLAGS_ISLINKABLE}, + { ID_OB, "Object", "objects", IDTYPE_FLAGS_ISLINKABLE}, + { ID_PA, "ParticleSettings", "particles", 0}, + { ID_SCE, "Scene", "scenes", IDTYPE_FLAGS_ISLINKABLE}, + { ID_SCR, "Screen", "screens", 0}, + { ID_SEQ, "Sequence", "sequences", 0}, /* not actually ID data */ + { ID_SO, "Sound", "sounds", IDTYPE_FLAGS_ISLINKABLE}, + { ID_TE, "Texture", "textures", IDTYPE_FLAGS_ISLINKABLE}, + { ID_TXT, "Text", "texts", IDTYPE_FLAGS_ISLINKABLE}, + { ID_VF, "VFont", "fonts", IDTYPE_FLAGS_ISLINKABLE}, + { ID_WO, "World", "worlds", IDTYPE_FLAGS_ISLINKABLE}, + { ID_WM, "WindowManager", "window_managers", 0}, +}; +static int nidtypes= sizeof(idtypes)/sizeof(idtypes[0]); + +static IDType *idtype_from_name(const char *str) +{ + int i= nidtypes; + + while (i--) + if (strcmp(str, idtypes[i].name)==0) + return &idtypes[i]; + + return NULL; +} +static IDType *idtype_from_code(int code) +{ + int i= nidtypes; + + while (i--) + if (code==idtypes[i].code) + return &idtypes[i]; + + return NULL; +} + +int BKE_idcode_is_valid(int code) +{ + return idtype_from_code(code)?1:0; +} + +int BKE_idcode_is_linkable(int code) { + IDType *idt= idtype_from_code(code); + return idt?(idt->flags&IDTYPE_FLAGS_ISLINKABLE):0; +} + +const char *BKE_idcode_to_name(int code) +{ + IDType *idt= idtype_from_code(code); + + return idt?idt->name:NULL; +} + +int BKE_idcode_from_name(const char *name) +{ + IDType *idt= idtype_from_name(name); + + return idt?idt->code:0; +} + +const char *BKE_idcode_to_name_plural(int code) +{ + IDType *idt= idtype_from_code(code); + + return idt?idt->plural:NULL; +} -- cgit v1.2.3 From e87552d3e810f9e6a739aa0636e11c6c1886725c Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Tue, 10 Aug 2010 20:33:15 +0000 Subject: SVN maintenance. --- source/blender/blenkernel/intern/idcode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index c9dee00a15c..3e8f400967e 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -1,5 +1,5 @@ /** - * $Id: readblenentry.c 31028 2010-08-04 04:01:27Z campbellbarton $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * -- cgit v1.2.3 From 95aa8cfa4a50b5949e20f1bbecde7703454d9266 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Tue, 10 Aug 2010 21:22:26 +0000 Subject: Update address in license block. --- source/blender/blenkernel/intern/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile index eb14914c7ba..53a9999758c 100644 --- a/source/blender/blenkernel/intern/Makefile +++ b/source/blender/blenkernel/intern/Makefile @@ -15,7 +15,7 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, -# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. # All rights reserved. -- cgit v1.2.3 From aae5c9b58db6edc7672527617da212fe1e68dfdd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Aug 2010 22:36:43 +0000 Subject: - possibly bugfix /w uninitialized vars [#23270] Long directory name segmentation fault in File brower. - in exceptional cases vertcos_to_key() could return with KeyBlock pointing to freed memory. - invalid use of realloc() in BLI_builddir() --- source/blender/blenkernel/intern/key.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 354b3b0e7d8..f4b931ec52b 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1850,9 +1850,12 @@ void vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) tot= count_curveverts(&cu->nurb); } - fp= kb->data= MEM_callocN(tot*elemsize, "key_to_vertcos vertCos"); + if (tot == 0) { + kb->data= NULL; + return; + } - if (tot == 0) return; + fp= kb->data= MEM_callocN(tot*elemsize, "key_to_vertcos vertCos"); /* Copy coords to keyblock */ -- cgit v1.2.3 From 6be46efe6c5e8947facd5c99efc453a04b9da53e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Aug 2010 06:28:46 +0000 Subject: fix for the rna curve interpolation enum, 'ease' was using the same value as Bezier. --- source/blender/blenkernel/intern/curve.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 841bd635acf..358dd1914e7 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1573,7 +1573,7 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float * for(a=0; atilt_interp==3) { /* May as well support for tilt also 2.47 ease interp */ + if (nu->tilt_interp==KEY_CU_EASE) { /* May as well support for tilt also 2.47 ease interp */ *tilt_array = prevbezt->alfa + (bezt->alfa - prevbezt->alfa)*(3.0f*fac*fac - 2.0f*fac*fac*fac); } else { key_curve_position_weights(fac, t, nu->tilt_interp); @@ -1584,7 +1584,7 @@ static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float * } if (radius_array) { - if (nu->radius_interp==3) { + if (nu->radius_interp==KEY_CU_EASE) { /* Support 2.47 ease interp * Note! - this only takes the 2 points into account, * giving much more localized results to changes in radius, sometimes you want that */ -- cgit v1.2.3 From cf84992cb41ab604f8e6241915c566cfcd004c6a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 12 Aug 2010 09:35:39 +0000 Subject: patch [#23280] Generated suffixes of strip names contain random character (revision 31262) from Torsten Rupp (rupp) --- source/blender/blenkernel/intern/nla.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 8d2ad49e7bf..b053d615756 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1265,13 +1265,13 @@ void BKE_nlastrip_validate_name (AnimData *adt, NlaStrip *strip) char *dot; /* Strip off the suffix */ - dot = strchr(strip->name, '.'); + dot = strrchr(strip->name, '.'); if (dot) *dot=0; /* Try different possibilities */ for (number = 1; number <= 999; number++) { /* assemble alternative name */ - BLI_snprintf(tempname, 128, "%s%c%03d", strip->name, ".", number); + BLI_snprintf(tempname, 128, "%s.%03d", strip->name, number); /* if hash doesn't have this, set it */ if (BLI_ghash_haskey(gh, tempname) == 0) { -- cgit v1.2.3 From fd0a02ef1b9a5804d09a4c9bb322b1f0e205a26c Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 12 Aug 2010 10:17:21 +0000 Subject: Fix #23235: crash with editmesh instances & drawing, only the object in object mode should make the editmesh derivedmesh. --- source/blender/blenkernel/intern/object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 18eedd63906..115cfac7627 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2501,7 +2501,7 @@ void object_handle_update(Scene *scene, Object *ob) /* includes all keys and modifiers */ if(ob->type==OB_MESH) { - EditMesh *em = BKE_mesh_get_editmesh(ob->data); + EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; /* evaluate drivers */ // XXX: should we push this to derivedmesh instead? -- cgit v1.2.3 From 982c4c87f7d5d5c3f2a9fea4fb5b2170d25c1968 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 12 Aug 2010 10:35:34 +0000 Subject: Fix #23281: crash with multiresolution and uv project. --- source/blender/blenkernel/intern/subsurf_ccg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 0d7738353df..4c85656dd91 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -69,6 +69,8 @@ static int ccgDM_getVertMapIndex(CCGSubSurf *ss, CCGVert *v); static int ccgDM_getEdgeMapIndex(CCGSubSurf *ss, CCGEdge *e); static int ccgDM_getFaceMapIndex(CCGSubSurf *ss, CCGFace *f); +static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm); + /// static void *arena_alloc(CCGAllocatorHDL a, int numBytes) { @@ -1249,7 +1251,7 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d) static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm) { - if(ccgdm->pbvh && ccgdm->multires.mmd) { + if(ccgdm->pbvh && ccgDM_use_grid_pbvh(ccgdm)) { CCGFace **faces; int totface; -- cgit v1.2.3 From 5fa95f69287bbf4c90734aa700436e9da009cdee Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 12 Aug 2010 16:46:03 +0000 Subject: Fix #22777: duplifaces don't take deforming modifiers into account while in edit mode. --- source/blender/blenkernel/intern/DerivedMesh.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 8b1443403a3..663fbb89b4e 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1189,10 +1189,15 @@ static void emDM_getFace(DerivedMesh *dm, int index, MFace *face_r) static void emDM_copyVertArray(DerivedMesh *dm, MVert *vert_r) { - EditVert *ev = ((EditMeshDerivedMesh *)dm)->em->verts.first; + EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; + EditVert *ev = emdm->em->verts.first; + int i; - for( ; ev; ev = ev->next, ++vert_r) { - VECCOPY(vert_r->co, ev->co); + for(i=0; ev; ev = ev->next, ++vert_r, ++i) { + if(emdm->vertexCos) + copy_v3_v3(vert_r->co, emdm->vertexCos[i]); + else + copy_v3_v3(vert_r->co, ev->co); vert_r->no[0] = ev->no[0] * 32767.0; vert_r->no[1] = ev->no[1] * 32767.0; -- cgit v1.2.3 From bf52b68dcd1864fd35309f9aae19f146da5b774e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Aug 2010 06:30:04 +0000 Subject: minor changes to rna/python. - raise an exception when python calls is_property_set(name) or is_property_hidden(name) and the property does not exist. - added BLI_findstring_ptr(), which finds a named item in a listbase where that name is a pointer to a string. - replaced inline for loops with calls to BLI_findstring_ptr() and IDP_GetPropertyFromGroup(). --- source/blender/blenkernel/intern/idprop.c | 53 +++++++++++++------------------ 1 file changed, 22 insertions(+), 31 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 2ccb33b088a..a0df73d6c42 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -27,6 +27,7 @@ #include #include +#include #include #include "BKE_idprop.h" @@ -491,47 +492,41 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) { IDProperty *loop; - for (loop=group->data.group.first; loop; loop=loop->next) { - if (BSTR_EQ(loop->name, prop->name)) { - BLI_insertlink(&group->data.group, loop, prop); - - BLI_remlink(&group->data.group, loop); - IDP_FreeProperty(loop); - MEM_freeN(loop); - return; - } + if((loop= IDP_GetPropertyFromGroup(group, prop->name))) { + BLI_insertlink(&group->data.group, loop, prop); + + BLI_remlink(&group->data.group, loop); + IDP_FreeProperty(loop); + MEM_freeN(loop); + } + else { + group->len++; + BLI_addtail(&group->data.group, prop); } - - group->len++; - BLI_addtail(&group->data.group, prop); } /*returns 0 if an id property with the same name exists and it failed, or 1 if it succeeded in adding to the group.*/ int IDP_AddToGroup(IDProperty *group, IDProperty *prop) { - IDProperty *loop; - for (loop=group->data.group.first; loop; loop=loop->next) { - if (BSTR_EQ(loop->name, prop->name)) return 0; + if(IDP_GetPropertyFromGroup(group, prop->name) == NULL) { + group->len++; + BLI_addtail(&group->data.group, prop); + return 1; } - group->len++; - BLI_addtail(&group->data.group, prop); - - return 1; + return 0; } int IDP_InsertToGroup(IDProperty *group, IDProperty *previous, IDProperty *pnew) { - IDProperty *loop; - for (loop=group->data.group.first; loop; loop=loop->next) { - if (BSTR_EQ(loop->name, pnew->name)) return 0; + if(IDP_GetPropertyFromGroup(group, pnew->name) == NULL) { + group->len++; + BLI_insertlink(&group->data.group, previous, pnew); + return 1; } - - group->len++; - BLI_insertlink(&group->data.group, previous, pnew); - return 1; + return 0; } void IDP_RemFromGroup(IDProperty *group, IDProperty *prop) @@ -542,11 +537,7 @@ void IDP_RemFromGroup(IDProperty *group, IDProperty *prop) IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name) { - IDProperty *loop; - for (loop=prop->data.group.first; loop; loop=loop->next) { - if (strcmp(loop->name, name)==0) return loop; - } - return NULL; + return (IDProperty *)BLI_findstring(&prop->data.group, name, offsetof(IDProperty, name)); } typedef struct IDPIter { -- cgit v1.2.3 From 9ce2086506dcf16ecc0d5dce7851439ae8818e78 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 13 Aug 2010 10:20:40 +0000 Subject: Fix #23111: file Output node not working when inside a group. --- source/blender/blenkernel/intern/node.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 36c23216585..ea30b33655f 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1855,9 +1855,8 @@ static void node_group_execute(bNodeStack *stack, void *data, bNode *gnode, bNod /* for groups, only execute outputs for edited group */ if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) { - if(gnode->flag & NODE_GROUP_EDIT) - if(node->flag & NODE_DO_OUTPUT) - node->typeinfo->execfunc(data, node, nsin, nsout); + if(node->type==CMP_NODE_OUTPUT_FILE || (gnode->flag & NODE_GROUP_EDIT)) + node->typeinfo->execfunc(data, node, nsin, nsout); } else node->typeinfo->execfunc(data, node, nsin, nsout); -- cgit v1.2.3 From 0738ae7688d19b471b7cde9cc631096a6162b3fc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 13 Aug 2010 14:23:44 +0000 Subject: 2.5: more removal of G.main. --- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/group.c | 9 ++-- source/blender/blenkernel/intern/material.c | 17 +++--- source/blender/blenkernel/intern/mesh.c | 10 ++-- source/blender/blenkernel/intern/object.c | 34 ++++++------ source/blender/blenkernel/intern/pointcache.c | 4 +- source/blender/blenkernel/intern/scene.c | 5 +- source/blender/blenkernel/intern/seqeffects.c | 31 +++++------ source/blender/blenkernel/intern/sequencer.c | 76 +++++++++++++-------------- source/blender/blenkernel/intern/text.c | 6 ++- source/blender/blenkernel/intern/texture.c | 31 ++++++----- source/blender/blenkernel/intern/world.c | 8 +-- 12 files changed, 125 insertions(+), 108 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 1f8360324d5..d498b73be7e 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2180,7 +2180,7 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay) dag_object_time_update_flags(scene->camera); /* and store the info in groupobject */ - for(group= G.main->group.first; group; group= group->id.next) { + for(group= bmain->group.first; group; group= group->id.next) { if(group->id.flag & LIB_DOIT) { for(go= group->gobject.first; go; go= go->next) { go->recalc= go->ob->recalc; diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 6377a6f6ccd..bdf203119c3 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -69,21 +69,22 @@ void free_group_objects(Group *group) void unlink_group(Group *group) { + Main *bmain= G.main; Material *ma; Object *ob; Scene *sce; SceneRenderLayer *srl; ParticleSystem *psys; - for(ma= G.main->mat.first; ma; ma= ma->id.next) { + for(ma= bmain->mat.first; ma; ma= ma->id.next) { if(ma->group==group) ma->group= NULL; } - for(ma= G.main->mat.first; ma; ma= ma->id.next) { + for(ma= bmain->mat.first; ma; ma= ma->id.next) { if(ma->group==group) ma->group= NULL; } - for (sce= G.main->scene.first; sce; sce= sce->id.next) { + for (sce= bmain->scene.first; sce; sce= sce->id.next) { Base *base= sce->base.first; /* ensure objects are not in this group */ @@ -100,7 +101,7 @@ void unlink_group(Group *group) } } - for(ob= G.main->object.first; ob; ob= ob->id.next) { + for(ob= bmain->object.first; ob; ob= ob->id.next) { bActionStrip *strip; if(ob->dup_group==group) { diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 6b79a7b4d62..724536048ce 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -236,6 +236,7 @@ Material *copy_material(Material *ma) void make_local_material(Material *ma) { + Main *bmain= G.main; Object *ob; Mesh *me; Curve *cu; @@ -261,7 +262,7 @@ void make_local_material(Material *ma) } /* test objects */ - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { if(ob->mat) { for(a=0; atotcol; a++) { @@ -274,7 +275,7 @@ void make_local_material(Material *ma) ob= ob->id.next; } /* test meshes */ - me= G.main->mesh.first; + me= bmain->mesh.first; while(me) { if(me->mat) { for(a=0; atotcol; a++) { @@ -287,7 +288,7 @@ void make_local_material(Material *ma) me= me->id.next; } /* test curves */ - cu= G.main->curve.first; + cu= bmain->curve.first; while(cu) { if(cu->mat) { for(a=0; atotcol; a++) { @@ -300,7 +301,7 @@ void make_local_material(Material *ma) cu= cu->id.next; } /* test mballs */ - mb= G.main->mball.first; + mb= bmain->mball.first; while(mb) { if(mb->mat) { for(a=0; atotcol; a++) { @@ -329,7 +330,7 @@ void make_local_material(Material *ma) man->id.us= 0; /* do objects */ - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { if(ob->mat) { for(a=0; atotcol; a++) { @@ -345,7 +346,7 @@ void make_local_material(Material *ma) ob= ob->id.next; } /* do meshes */ - me= G.main->mesh.first; + me= bmain->mesh.first; while(me) { if(me->mat) { for(a=0; atotcol; a++) { @@ -361,7 +362,7 @@ void make_local_material(Material *ma) me= me->id.next; } /* do curves */ - cu= G.main->curve.first; + cu= bmain->curve.first; while(cu) { if(cu->mat) { for(a=0; atotcol; a++) { @@ -377,7 +378,7 @@ void make_local_material(Material *ma) cu= cu->id.next; } /* do mballs */ - mb= G.main->mball.first; + mb= bmain->mball.first; while(mb) { if(mb->mat) { for(a=0; atotcol; a++) { diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 7129ecb1d55..a017b7344d7 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -265,6 +265,7 @@ void make_local_tface(Mesh *me) void make_local_mesh(Mesh *me) { + Main *bmain= G.main; Object *ob; Mesh *men; int local=0, lib=0; @@ -285,7 +286,7 @@ void make_local_mesh(Mesh *me) return; } - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { if( me==get_mesh(ob) ) { if(ob->id.lib) lib= 1; @@ -306,7 +307,7 @@ void make_local_mesh(Mesh *me) men= copy_mesh(me); men->id.us= 0; - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { if( me==get_mesh(ob) ) { if(ob->id.lib==0) { @@ -925,6 +926,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int /* this may fail replacing ob->data, be sure to check ob->type */ void nurbs_to_mesh(Object *ob) { + Main *bmain= G.main; Object *ob1; DerivedMesh *dm= ob->derivedFinal; Mesh *me; @@ -967,13 +969,13 @@ void nurbs_to_mesh(Object *ob) cu->totcol= 0; if(ob->data) { - free_libblock(&G.main->curve, ob->data); + free_libblock(&bmain->curve, ob->data); } ob->data= me; ob->type= OB_MESH; /* other users */ - ob1= G.main->object.first; + ob1= bmain->object.first; while(ob1) { if(ob1->data==cu) { ob1->type= OB_MESH; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 115cfac7627..b43cf72b94b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -322,6 +322,7 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec void unlink_object(Scene *scene, Object *ob) { + Main *bmain= G.main; Object *obt; Material *mat; World *wrld; @@ -343,7 +344,7 @@ void unlink_object(Scene *scene, Object *ob) /* check all objects: parents en bevels and fields, also from libraries */ // FIXME: need to check all animation blocks (drivers) - obt= G.main->object.first; + obt= bmain->object.first; while(obt) { if(obt->proxy==ob) obt->proxy= NULL; @@ -517,7 +518,7 @@ void unlink_object(Scene *scene, Object *ob) } /* materials */ - mat= G.main->mat.first; + mat= bmain->mat.first; while(mat) { for(a=0; atex.first; + tex= bmain->tex.first; while(tex) { if(tex->env) { if(tex->env->object == ob) tex->env->object= NULL; @@ -540,7 +541,7 @@ void unlink_object(Scene *scene, Object *ob) } /* worlds */ - wrld= G.main->world.first; + wrld= bmain->world.first; while(wrld) { if(wrld->id.lib==NULL) { for(a=0; ascene.first; + sce= bmain->scene.first; while(sce) { if(sce->id.lib==NULL) { if(sce->camera==ob) sce->camera= NULL; @@ -585,7 +586,7 @@ void unlink_object(Scene *scene, Object *ob) #if 0 // XXX old animation system /* ipos */ - ipo= G.main->ipo.first; + ipo= bmain->ipo.first; while(ipo) { if(ipo->id.lib==NULL) { IpoCurve *icu; @@ -599,7 +600,7 @@ void unlink_object(Scene *scene, Object *ob) #endif // XXX old animation system /* screens */ - sc= G.main->screen.first; + sc= bmain->screen.first; while(sc) { ScrArea *sa= sc->areabase.first; while(sa) { @@ -664,14 +665,14 @@ void unlink_object(Scene *scene, Object *ob) } /* groups */ - group= G.main->group.first; + group= bmain->group.first; while(group) { rem_from_group(group, ob, NULL, NULL); group= group->id.next; } /* cameras */ - camera= G.main->camera.first; + camera= bmain->camera.first; while(camera) { if (camera->dof_ob==ob) { camera->dof_ob = NULL; @@ -725,6 +726,7 @@ Camera *copy_camera(Camera *cam) void make_local_camera(Camera *cam) { + Main *bmain= G.main; Object *ob; Camera *camn; int local=0, lib=0; @@ -742,7 +744,7 @@ void make_local_camera(Camera *cam) return; } - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { if(ob->data==cam) { if(ob->id.lib) lib= 1; @@ -760,7 +762,7 @@ void make_local_camera(Camera *cam) camn= copy_camera(cam); camn->id.us= 0; - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { if(ob->data==cam) { @@ -873,6 +875,7 @@ Lamp *copy_lamp(Lamp *la) void make_local_lamp(Lamp *la) { + Main *bmain= G.main; Object *ob; Lamp *lan; int local=0, lib=0; @@ -890,7 +893,7 @@ void make_local_lamp(Lamp *la) return; } - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { if(ob->data==la) { if(ob->id.lib) lib= 1; @@ -908,7 +911,7 @@ void make_local_lamp(Lamp *la) lan= copy_lamp(la); lan->id.us= 0; - ob= G.main->object.first; + ob= bmain->object.first; while(ob) { if(ob->data==la) { @@ -1366,6 +1369,7 @@ void expand_local_object(Object *ob) void make_local_object(Object *ob) { + Main *bmain= G.main; Object *obn; Scene *sce; Base *base; @@ -1387,7 +1391,7 @@ void make_local_object(Object *ob) } else { - sce= G.main->scene.first; + sce= bmain->scene.first; while(sce) { base= sce->base.first; while(base) { @@ -1410,7 +1414,7 @@ void make_local_object(Object *ob) obn= copy_object(ob); obn->id.us= 0; - sce= G.main->scene.first; + sce= bmain->scene.first; while(sce) { if(sce->id.lib==0) { base= sce->base.first; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 6cf49808ec7..a35e40d7cf7 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2240,7 +2240,7 @@ void BKE_ptcache_remove(void) static int CONTINUE_PHYSICS = 0; -void BKE_ptcache_set_continue_physics(Scene *scene, int enable) +void BKE_ptcache_set_continue_physics(Main *bmain, Scene *scene, int enable) { Object *ob; @@ -2248,7 +2248,7 @@ void BKE_ptcache_set_continue_physics(Scene *scene, int enable) CONTINUE_PHYSICS = enable; if(CONTINUE_PHYSICS == 0) { - for(ob=G.main->object.first; ob; ob=ob->id.next) + for(ob=bmain->object.first; ob; ob=ob->id.next) if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED)) DAG_id_flush_update(&ob->id, OB_RECALC_DATA); } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 95705ea8c05..42506b66303 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -320,11 +320,12 @@ void free_scene(Scene *sce) Scene *add_scene(char *name) { + Main *bmain= G.main; Scene *sce; ParticleEditSettings *pset; int a; - sce= alloc_libblock(&G.main->scene, ID_SCE, name); + sce= alloc_libblock(&bmain->scene, ID_SCE, name); sce->lay= sce->layact= 1; sce->r.mode= R_GAMMA|R_OSA|R_SHADOW|R_SSS|R_ENVMAP|R_RAYTRACE; @@ -586,7 +587,7 @@ void unlink_scene(Main *bmain, Scene *sce, Scene *newsce) sce1->set= NULL; /* check all sequences */ - clear_scene_in_allseqs(sce); + clear_scene_in_allseqs(bmain, sce); /* check render layer nodes in other scenes */ clear_scene_in_nodes(bmain, sce); diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 1e1ace0f758..461cb075bb0 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -41,6 +41,7 @@ #include "DNA_anim_types.h" #include "BKE_fcurve.h" +#include "BKE_main.h" #include "BKE_plugin_types.h" #include "BKE_sequencer.h" #include "BKE_texture.h" @@ -272,7 +273,7 @@ static ImBuf * IMB_cast_away_list(ImBuf * i) } static struct ImBuf * do_plugin_effect( - Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -523,7 +524,7 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_alphaover_effect( - Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -695,7 +696,7 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf* do_alphaunder_effect( - Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -820,7 +821,7 @@ void do_cross_effect_float(float facf0, float facf1, int x, int y, /* carefull: also used by speed effect! */ static struct ImBuf* do_cross_effect( - Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -1087,7 +1088,7 @@ static void do_gammacross_effect_float(float facf0, float facf1, } static struct ImBuf * do_gammacross_effect( - Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -1205,7 +1206,7 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf * do_add_effect(Scene *scene, Sequence *seq, float cfra, +static struct ImBuf * do_add_effect(Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -1322,7 +1323,7 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_sub_effect( - Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -1536,7 +1537,7 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_mul_effect( - Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -1992,7 +1993,7 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float facf1, } static struct ImBuf * do_wipe_effect( - Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -2143,7 +2144,7 @@ static void do_transform(Scene *scene, Sequence *seq, float facf0, int x, int y, static struct ImBuf * do_transform_effect( - Scene *scene, Sequence *seq,float cfra, + Main *bmain, Scene *scene, Sequence *seq,float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -2661,7 +2662,7 @@ static void do_glow_effect_float(Sequence *seq, float facf0, float facf1, } static struct ImBuf * do_glow_effect( - Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -2722,7 +2723,7 @@ static int early_out_color(struct Sequence *seq, } static struct ImBuf * do_solid_color( - Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -2818,7 +2819,7 @@ static int early_out_multicam(struct Sequence *seq, float facf0, float facf1) } static struct ImBuf * do_multicam( - Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -2842,7 +2843,7 @@ static struct ImBuf * do_multicam( return 0; } - i = give_ibuf_seqbase(scene, x, y, cfra, seq->multicam_source, + i = give_ibuf_seqbase(bmain, scene, x, y, cfra, seq->multicam_source, preview_render_size, seqbasep); if (!i) { return 0; @@ -3122,7 +3123,7 @@ static void get_default_fac_fade(struct Sequence *seq, float cfra, *facf1 /= seq->len; } -static struct ImBuf * do_overdrop_effect(Scene *scene, Sequence *seq, float cfra, +static struct ImBuf * do_overdrop_effect(Main *bmain, Scene *scene, Sequence *seq, float cfra, float facf0, float facf1, int x, int y, int preview_render_size, diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 866f907ef9e..b20bb111cb4 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -554,7 +554,7 @@ void calc_sequence(Scene *scene, Sequence *seq) } /* note: caller should run calc_sequence(scene, seq) after */ -void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) +void reload_sequence_new_file(Main *bmain, Scene *scene, Sequence * seq, int lock_range) { char str[FILE_MAXDIR+FILE_MAXFILE]; int prev_startdisp, prev_enddisp; @@ -621,7 +621,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) seq->strip->len = seq->len; } else if (seq->type == SEQ_SCENE) { /* 'seq->scenenr' should be replaced with something more reliable */ - Scene * sce = G.main->scene.first; + Scene * sce = bmain->scene.first; int nr = 1; while(sce) { @@ -710,12 +710,12 @@ static int clear_scene_in_allseqs_cb(Sequence *seq, void *arg_pt) return 1; } -void clear_scene_in_allseqs(Scene *scene) +void clear_scene_in_allseqs(Main *bmain, Scene *scene) { Scene *scene_iter; /* when a scene is deleted: test all seqs */ - for(scene_iter= G.main->scene.first; scene_iter; scene_iter= scene_iter->id.next) { + for(scene_iter= bmain->scene.first; scene_iter; scene_iter= scene_iter->id.next) { if(scene_iter != scene && scene_iter->ed) { seqbase_recursive_apply(&scene_iter->ed->seqbase, clear_scene_in_allseqs_cb, scene); } @@ -1659,17 +1659,17 @@ static void copy_to_ibuf_still(Sequence * seq, float nr, ********************************************************************** */ static ImBuf* seq_render_strip_stack( - Scene *scene, + Main *bmain, Scene *scene, ListBase *seqbasep, float cfra, int chanshown, int render_size, int seqrectx, int seqrecty); -static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra, +static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra, int render_size, int seqrectx, int seqrecty); static ImBuf* seq_render_effect_strip_impl( - Scene *scene, float cfra, Sequence *seq, int render_size, + Main *bmain, Scene *scene, float cfra, Sequence *seq, int render_size, int seqrectx, int seqrecty) { float fac, facf; @@ -1707,7 +1707,7 @@ static ImBuf* seq_render_effect_strip_impl( early_out = sh.early_out(seq, fac, facf); if (early_out == -1) { /* no input needed */ - out = sh.execute(scene, seq, cfra, fac, facf, + out = sh.execute(bmain, scene, seq, cfra, fac, facf, seqrectx, seqrecty, render_size, 0, 0, 0); goto finish; @@ -1722,7 +1722,7 @@ static ImBuf* seq_render_effect_strip_impl( break; case 1: if (seq->seq1) { - ibuf[0] = seq_render_strip(scene, seq->seq1, cfra, + ibuf[0] = seq_render_strip(bmain, scene, seq->seq1, cfra, render_size, seqrectx, seqrecty); } @@ -1737,7 +1737,7 @@ static ImBuf* seq_render_effect_strip_impl( goto finish; case 2: if (seq->seq2) { - ibuf[1] = seq_render_strip(scene, seq->seq2, cfra, + ibuf[1] = seq_render_strip(bmain, scene, seq->seq2, cfra, render_size, seqrectx, seqrecty); } @@ -1755,19 +1755,19 @@ static ImBuf* seq_render_effect_strip_impl( } if (seq->seq1) { - ibuf[0] = seq_render_strip(scene, seq->seq1, cfra, + ibuf[0] = seq_render_strip(bmain, scene, seq->seq1, cfra, render_size, seqrectx, seqrecty); } if (seq->seq2) { - ibuf[1] = seq_render_strip(scene, seq->seq2, cfra, + ibuf[1] = seq_render_strip(bmain, scene, seq->seq2, cfra, render_size, seqrectx, seqrecty); } if (seq->seq3) { - ibuf[2] = seq_render_strip(scene, seq->seq3, cfra, + ibuf[2] = seq_render_strip(bmain, scene, seq->seq3, cfra, render_size, seqrectx, seqrecty); } @@ -1776,7 +1776,7 @@ static ImBuf* seq_render_effect_strip_impl( goto finish; } - out = sh.execute(scene, seq, cfra, fac, facf, seqrectx, seqrecty, + out = sh.execute(bmain, scene, seq, cfra, fac, facf, seqrectx, seqrecty, render_size, ibuf[0], ibuf[1], ibuf[2]); @@ -1795,7 +1795,7 @@ finish: static ImBuf * seq_render_scene_strip_impl( - Scene * scene, Sequence * seq, float nr, int seqrectx, int seqrecty) + Main *bmain, Scene * scene, Sequence * seq, float nr, int seqrectx, int seqrecty) { ImBuf * ibuf = 0; float frame= seq->sfra + nr + seq->anim_startofs; @@ -1851,7 +1851,7 @@ static ImBuf * seq_render_scene_strip_impl( if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) { /* opengl offscreen render */ - scene_update_for_newframe(G.main, seq->scene, seq->scene->lay); + scene_update_for_newframe(bmain, seq->scene, seq->scene->lay); ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, scene->r.seq_prev_type); } @@ -1864,7 +1864,7 @@ static ImBuf * seq_render_scene_strip_impl( else re= RE_NewRender(sce->id.name); - RE_BlenderFrame(re, G.main, sce, NULL, sce->lay, frame); + RE_BlenderFrame(re, bmain, sce, NULL, sce->lay, frame); RE_AcquireResultImage(re, &rres); @@ -1904,7 +1904,7 @@ static ImBuf * seq_render_scene_strip_impl( return ibuf; } -static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra, +static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra, int render_size, int seqrectx, int seqrecty) { @@ -1929,7 +1929,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra, if(!ibuf && seq->seqbase.first) { meta_ibuf = seq_render_strip_stack( - scene, + bmain, scene, &seq->seqbase, seq->start + nr, 0, render_size, seqrectx, seqrecty); } @@ -1961,7 +1961,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra, /* weeek! */ f_cfra = seq->start + s->frameMap[(int) nr]; - child_ibuf = seq_render_strip(scene, seq->seq1, f_cfra, + child_ibuf = seq_render_strip(bmain, scene, seq->seq1, f_cfra, render_size, seqrectx, seqrecty); } @@ -1985,7 +1985,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra, if(ibuf == 0) { ibuf = seq_render_effect_strip_impl( - scene, cfra, seq, render_size, + bmain, scene, cfra, seq, render_size, seqrectx, seqrecty); } } else if(seq->type == SEQ_IMAGE) { @@ -2061,7 +2061,7 @@ static ImBuf * seq_render_strip(Scene *scene, Sequence * seq, float cfra, } if (ibuf == 0) { - ibuf = seq_render_scene_strip_impl(scene, seq, nr, + ibuf = seq_render_scene_strip_impl(bmain, scene, seq, nr, seqrectx, seqrecty); copy_to_ibuf_still(seq, nr, ibuf); @@ -2129,7 +2129,7 @@ static int seq_get_early_out_for_blend_mode(Sequence * seq) } static ImBuf* seq_render_strip_stack( - Scene *scene, ListBase *seqbasep, float cfra, int chanshown, + Main *bmain, Scene *scene, ListBase *seqbasep, float cfra, int chanshown, int render_size, int seqrectx, int seqrecty) { Sequence* seq_arr[MAXSEQ+1]; @@ -2161,7 +2161,7 @@ static ImBuf* seq_render_strip_stack( } if(count == 1) { - out = seq_render_strip(scene, seq_arr[0], + out = seq_render_strip(bmain, scene, seq_arr[0], cfra, render_size, seqrectx, seqrecty); seq_stripelem_cache_put( @@ -2185,7 +2185,7 @@ static ImBuf* seq_render_strip_stack( break; } if (seq->blend_mode == SEQ_BLEND_REPLACE) { - out = seq_render_strip(scene, seq, cfra, + out = seq_render_strip(bmain, scene, seq, cfra, render_size, seqrectx, seqrecty); break; @@ -2196,7 +2196,7 @@ static ImBuf* seq_render_strip_stack( switch (early_out) { case -1: case 2: - out = seq_render_strip(scene, seq, cfra, + out = seq_render_strip(bmain, scene, seq, cfra, render_size, seqrectx, seqrecty); break; @@ -2209,7 +2209,7 @@ static ImBuf* seq_render_strip_stack( break; case 0: if (i == 0) { - out = seq_render_strip(scene, seq, cfra, + out = seq_render_strip(bmain, scene, seq, cfra, render_size, seqrectx, seqrecty); } @@ -2234,7 +2234,7 @@ static ImBuf* seq_render_strip_stack( if (seq_get_early_out_for_blend_mode(seq) == 0) { struct SeqEffectHandle sh = get_sequence_blend(seq); ImBuf * ibuf1 = out; - ImBuf * ibuf2 = seq_render_strip(scene, seq, cfra, + ImBuf * ibuf2 = seq_render_strip(bmain, scene, seq, cfra, render_size, seqrectx, seqrecty); @@ -2246,11 +2246,11 @@ static ImBuf* seq_render_strip_stack( int y= seqrecty; if (swap_input) { - out = sh.execute(scene, seq, cfra, + out = sh.execute(bmain, scene, seq, cfra, facf, facf, x, y, render_size, ibuf2, ibuf1, 0); } else { - out = sh.execute(scene, seq, cfra, + out = sh.execute(bmain, scene, seq, cfra, facf, facf, x, y, render_size, ibuf1, ibuf2, 0); } @@ -2272,7 +2272,7 @@ static ImBuf* seq_render_strip_stack( * you have to free after usage! */ -ImBuf *give_ibuf_seq(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size) +ImBuf *give_ibuf_seq(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size) { Editing *ed= seq_give_editing(scene, FALSE); int count; @@ -2289,18 +2289,18 @@ ImBuf *give_ibuf_seq(Scene *scene, int rectx, int recty, int cfra, int chanshown } return seq_render_strip_stack( - scene, seqbasep, cfra, chanshown, render_size, rectx, recty); + bmain, scene, seqbasep, cfra, chanshown, render_size, rectx, recty); } -ImBuf *give_ibuf_seqbase(struct Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size, ListBase *seqbasep) +ImBuf *give_ibuf_seqbase(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size, ListBase *seqbasep) { - return seq_render_strip_stack(scene, seqbasep, cfra, chanshown, render_size, rectx, recty); + return seq_render_strip_stack(bmain, scene, seqbasep, cfra, chanshown, render_size, rectx, recty); } -ImBuf *give_ibuf_seq_direct(Scene *scene, int rectx, int recty, int cfra, int render_size, Sequence *seq) +ImBuf *give_ibuf_seq_direct(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int render_size, Sequence *seq) { - return seq_render_strip(scene, seq, cfra, render_size, rectx, recty); + return seq_render_strip(bmain, scene, seq, cfra, render_size, rectx, recty); } #if 0 @@ -2566,13 +2566,13 @@ static void seq_wait_for_prefetch_ready() } #endif -ImBuf *give_ibuf_seq_threaded(Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size) +ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size) { PrefetchQueueElem *e = NULL; int found_something = FALSE; if (seq_thread_shutdown) { - return give_ibuf_seq(scene, rectx, recty, cfra, chanshown, render_size); + return give_ibuf_seq(bmain, scene, rectx, recty, cfra, chanshown, render_size); } while (!e) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index c8f5eb9b187..19bc853276a 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -174,10 +174,11 @@ void free_text(Text *text) Text *add_empty_text(char *name) { + Main *bmain= G.main; Text *ta; TextLine *tmp; - ta= alloc_libblock(&G.main->text, ID_TXT, name); + ta= alloc_libblock(&bmain->text, ID_TXT, name); ta->id.us= 1; ta->name= NULL; @@ -326,6 +327,7 @@ int reopen_text(Text *text) Text *add_text(char *file, const char *relpath) { + Main *bmain= G.main; FILE *fp; int i, llen, len, res; unsigned char *buffer; @@ -341,7 +343,7 @@ Text *add_text(char *file, const char *relpath) fp= fopen(str, "r"); if(fp==NULL) return NULL; - ta= alloc_libblock(&G.main->text, ID_TXT, BLI_path_basename(str)); + ta= alloc_libblock(&bmain->text, ID_TXT, BLI_path_basename(str)); ta->id.us= 1; ta->lines.first= ta->lines.last= NULL; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index fe5abbd0868..9075c64d286 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -602,9 +602,10 @@ void tex_set_type(Tex *tex, int type) Tex *add_texture(const char *name) { + Main *bmain= G.main; Tex *tex; - tex= alloc_libblock(&G.main->tex, ID_TE, name); + tex= alloc_libblock(&bmain->tex, ID_TE, name); default_tex(tex); @@ -726,6 +727,7 @@ Tex *copy_texture(Tex *tex) void make_local_texture(Tex *tex) { + Main *bmain= G.main; Tex *texn; Material *ma; World *wrld; @@ -755,7 +757,7 @@ void make_local_texture(Tex *tex) return; } - ma= G.main->mat.first; + ma= bmain->mat.first; while(ma) { for(a=0; amtex[a] && ma->mtex[a]->tex==tex) { @@ -765,7 +767,7 @@ void make_local_texture(Tex *tex) } ma= ma->id.next; } - la= G.main->lamp.first; + la= bmain->lamp.first; while(la) { for(a=0; amtex[a] && la->mtex[a]->tex==tex) { @@ -775,7 +777,7 @@ void make_local_texture(Tex *tex) } la= la->id.next; } - wrld= G.main->world.first; + wrld= bmain->world.first; while(wrld) { for(a=0; amtex[a] && wrld->mtex[a]->tex==tex) { @@ -785,7 +787,7 @@ void make_local_texture(Tex *tex) } wrld= wrld->id.next; } - br= G.main->brush.first; + br= bmain->brush.first; while(br) { if(br->mtex.tex==tex) { if(br->id.lib) lib= 1; @@ -803,7 +805,7 @@ void make_local_texture(Tex *tex) texn= copy_texture(tex); texn->id.us= 0; - ma= G.main->mat.first; + ma= bmain->mat.first; while(ma) { for(a=0; amtex[a] && ma->mtex[a]->tex==tex) { @@ -816,7 +818,7 @@ void make_local_texture(Tex *tex) } ma= ma->id.next; } - la= G.main->lamp.first; + la= bmain->lamp.first; while(la) { for(a=0; amtex[a] && la->mtex[a]->tex==tex) { @@ -829,7 +831,7 @@ void make_local_texture(Tex *tex) } la= la->id.next; } - wrld= G.main->world.first; + wrld= bmain->world.first; while(wrld) { for(a=0; amtex[a] && wrld->mtex[a]->tex==tex) { @@ -842,7 +844,7 @@ void make_local_texture(Tex *tex) } wrld= wrld->id.next; } - br= G.main->brush.first; + br= bmain->brush.first; while(br) { if(br->mtex.tex==tex) { if(br->id.lib==0) { @@ -860,6 +862,7 @@ void make_local_texture(Tex *tex) void autotexname(Tex *tex) { + Main *bmain= G.main; char texstr[20][15]= {"None" , "Clouds" , "Wood", "Marble", "Magic" , "Blend", "Stucci", "Noise" , "Image", "Plugin", "EnvMap" , "Musgrave", "Voronoi", "DistNoise", "Point Density", "Voxel Data", "", "", "", ""}; @@ -868,7 +871,7 @@ void autotexname(Tex *tex) if(tex) { if(tex->use_nodes) { - new_id(&G.main->tex, (ID *)tex, "Noddy"); + new_id(&bmain->tex, (ID *)tex, "Noddy"); } else if(tex->type==TEX_IMAGE) { @@ -878,12 +881,12 @@ void autotexname(Tex *tex) BLI_splitdirstring(di, fi); strcpy(di, "I."); strcat(di, fi); - new_id(&G.main->tex, (ID *)tex, di); + new_id(&bmain->tex, (ID *)tex, di); } - else new_id(&G.main->tex, (ID *)tex, texstr[tex->type]); + else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); } - else if(tex->type==TEX_PLUGIN && tex->plugin) new_id(&G.main->tex, (ID *)tex, tex->plugin->pname); - else new_id(&G.main->tex, (ID *)tex, texstr[tex->type]); + else if(tex->type==TEX_PLUGIN && tex->plugin) new_id(&bmain->tex, (ID *)tex, tex->plugin->pname); + else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); } } diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 1d1b5ec16f7..233a1433ecb 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -69,9 +69,10 @@ void free_world(World *wrld) World *add_world(char *name) { + Main *bmain= G.main; World *wrld; - wrld= alloc_libblock(&G.main->world, ID_WO, name); + wrld= alloc_libblock(&bmain->world, ID_WO, name); wrld->horr= 0.05f; wrld->horg= 0.05f; @@ -129,6 +130,7 @@ World *copy_world(World *wrld) void make_local_world(World *wrld) { + Main *bmain= G.main; Scene *sce; World *wrldn; int local=0, lib=0; @@ -146,7 +148,7 @@ void make_local_world(World *wrld) return; } - sce= G.main->scene.first; + sce= bmain->scene.first; while(sce) { if(sce->world==wrld) { if(sce->id.lib) lib= 1; @@ -164,7 +166,7 @@ void make_local_world(World *wrld) wrldn= copy_world(wrld); wrldn->id.us= 0; - sce= G.main->scene.first; + sce= bmain->scene.first; while(sce) { if(sce->world==wrld) { if(sce->id.lib==0) { -- cgit v1.2.3 From 96b138d98bc38fd2a4cf3556fc45f7dd6d134a4e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 13 Aug 2010 15:26:37 +0000 Subject: added include for offsetof(), also use , not "string.h" --- source/blender/blenkernel/intern/modifier.c | 10 +++++----- source/blender/blenkernel/intern/smoke.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index ea118e4a53c..c35b1a8b0a8 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -34,11 +34,11 @@ * */ -#include "stddef.h" -#include "string.h" -#include "stdarg.h" -#include "math.h" -#include "float.h" +#include +#include +#include +#include +#include #include "DNA_armature_types.h" #include "DNA_object_types.h" diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 97eb3aa866c..11012843131 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -37,8 +37,8 @@ #include #include -#include "stdio.h" -#include "string.h" /* memset */ +#include +#include /* memset */ #include "BLI_linklist.h" #include "BLI_rand.h" -- cgit v1.2.3 From 728b713d86e69a57aa84a9aa5ce830befec67238 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 15 Aug 2010 15:14:08 +0000 Subject: use more BLI math functions. --- source/blender/blenkernel/intern/DerivedMesh.c | 7 +- source/blender/blenkernel/intern/armature.c | 5 +- source/blender/blenkernel/intern/boids.c | 13 +- source/blender/blenkernel/intern/cdderivedmesh.c | 10 +- source/blender/blenkernel/intern/collision.c | 3 +- source/blender/blenkernel/intern/constraint.c | 215 +++++++-------------- source/blender/blenkernel/intern/effect.c | 6 +- source/blender/blenkernel/intern/implicit.c | 5 +- source/blender/blenkernel/intern/mesh.c | 10 +- source/blender/blenkernel/intern/particle.c | 26 +-- source/blender/blenkernel/intern/particle_system.c | 12 +- source/blender/blenkernel/intern/sketch.c | 3 +- source/blender/blenkernel/intern/softbody.c | 3 +- 13 files changed, 102 insertions(+), 216 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 663fbb89b4e..de7b962e38a 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1407,8 +1407,7 @@ static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob, /* following Mesh convention; we use vertex coordinate itself * for normal in this case */ if (normalize_v3(no)==0.0) { - VECCOPY(no, vertexCos[i]); - normalize_v3(no); + normalize_v3_v3(no, vertexCos[i]); } } } @@ -2590,9 +2589,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) for(j=0; juv[j] : uv[j]); - - VECCOPY(tangent[j], vtang); - normalize_v3(tangent[j]); + normalize_v3_v3(tangent[j], vtang); } } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b86be371d66..41821f34ba8 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1283,9 +1283,8 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) float nor[3], axis[3], target[3]={0,1,0}; float theta; float rMatrix[3][3], bMatrix[3][3]; - - VECCOPY (nor, vec); - normalize_v3(nor); + + normalize_v3_v3(nor, vec); /* Find Axis & Amount for bone matrix*/ cross_v3_v3v3(axis,target,nor); diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 82602a6951d..7ae65d0113a 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -659,9 +659,9 @@ static int rule_fight(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Parti /* attack if in range */ if(closest_dist <= bbd->part->boids->range + pa->size + enemy_pa->size) { float damage = BLI_frand(); - float enemy_dir[3] = {bbd->wanted_co[0],bbd->wanted_co[1],bbd->wanted_co[2]}; + float enemy_dir[3]; - normalize_v3(enemy_dir); + normalize_v3_v3(enemy_dir, bbd->wanted_co); /* fight mode */ bbd->wanted_speed = 0.0f; @@ -786,8 +786,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro if(hit.index>=0) { t = hit.dist/col.ray_len; interp_v3_v3v3(ground_co, col.co1, col.co2, t); - VECCOPY(ground_nor, col.nor); - normalize_v3(ground_nor); + normalize_v3_v3(ground_nor, col.nor); return col.hit_ob; } else { @@ -1115,8 +1114,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) } VECCOPY(old_dir, pa->prev_state.ave); - VECCOPY(wanted_dir, bbd->wanted_co); - new_speed = normalize_v3(wanted_dir); + new_speed = normalize_v3_v3(wanted_dir, bbd->wanted_co); /* first check if we have valid direction we want to go towards */ if(new_speed == 0.0f) { @@ -1356,8 +1354,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* save direction to state.ave unless the boid is falling */ /* (boids can't effect their direction when falling) */ if(bpa->data.mode!=eBoidMode_Falling && len_v3(pa->state.vel) > 0.1*pa->size) { - VECCOPY(pa->state.ave, pa->state.vel); - normalize_v3(pa->state.ave); + normalize_v3_v3(pa->state.ave, pa->state.vel); } /* apply damping */ diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index fb1e8c00991..ca81e216006 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1777,14 +1777,10 @@ void CDDM_calc_normals(DerivedMesh *dm) for(i = 0; i < numVerts; i++, mv++) { float *no = temp_nors[i]; - if (normalize_v3(no) == 0.0) { - VECCOPY(no, mv->co); - normalize_v3(no); - } + if (normalize_v3(no) == 0.0) + normalize_v3_v3(no, mv->co); - mv->no[0] = (short)(no[0] * 32767.0); - mv->no[1] = (short)(no[1] * 32767.0); - mv->no[2] = (short)(no[2] * 32767.0); + normal_float_to_short_v3(mv->no, no); } MEM_freeN(temp_nors); diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 3a9c15f654c..af12d23b2c2 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -691,8 +691,7 @@ CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap if ( distance <= ( epsilon1 + epsilon2 + ALMOST_ZERO ) ) { - VECCOPY ( collpair->normal, collpair->vector ); - normalize_v3( collpair->normal ); + normalize_v3_v3( collpair->normal, collpair->vector ); collpair->distance = distance; collpair->flag = 0; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index aae70c055d0..b415484c1c1 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -256,7 +256,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 /* construct offs_bone the same way it is done in armature.c */ copy_m4_m3(offs_bone, pchan->bone->bone_mat); - VECCOPY(offs_bone[3], pchan->bone->head); + copy_v3_v3(offs_bone[3], pchan->bone->head); offs_bone[3][1]+= pchan->bone->parent->length; if (pchan->bone->flag & BONE_HINGE) { @@ -267,7 +267,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 copy_m4_m4(tmat, pchan->bone->parent->arm_mat); /* the location of actual parent transform */ - VECCOPY(tmat[3], offs_bone[3]); + copy_v3_v3(tmat[3], offs_bone[3]); offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f; mul_m4_v3(pchan->parent->pose_mat, tmat[3]); @@ -309,7 +309,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 /* construct offs_bone the same way it is done in armature.c */ copy_m4_m3(offs_bone, pchan->bone->bone_mat); - VECCOPY(offs_bone[3], pchan->bone->head); + copy_v3_v3(offs_bone[3], pchan->bone->head); offs_bone[3][1]+= pchan->bone->parent->length; if (pchan->bone->flag & BONE_HINGE) { @@ -320,8 +320,8 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 copy_m4_m4(tmat, pchan->bone->parent->arm_mat); /* the location of actual parent transform */ - VECCOPY(tmat[3], offs_bone[3]); - offs_bone[3][0]= offs_bone[3][1]= offs_bone[3][2]= 0.0f; + copy_v3_v3(tmat[3], offs_bone[3]); + zero_v3(offs_bone[3]); mul_m4_v3(pchan->parent->pose_mat, tmat[3]); mul_m4_m4m4(diff_mat, offs_bone, tmat); @@ -400,7 +400,7 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f DerivedMesh *dm = NULL; Mesh *me= ob->data; EditMesh *em = BKE_mesh_get_editmesh(me); - float vec[3] = {0.0f, 0.0f, 0.0f}, tvec[3]; + float vec[3] = {0.0f, 0.0f, 0.0f}; float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3]; float imat[3][3], tmat[3][3]; int dgroup; @@ -477,9 +477,9 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f mul_m3_v3(tmat, normal); normalize_v3(normal); - VECCOPY(plane, tmat[1]); + copy_v3_v3(plane, tmat[1]); - VECCOPY(tmat[2], normal); + copy_v3_v3(tmat[2], normal); cross_v3_v3v3(tmat[0], normal, plane); cross_v3_v3v3(tmat[1], tmat[2], tmat[0]); @@ -488,8 +488,7 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f /* apply the average coordinate as the new location */ - mul_v3_m4v3(tvec, ob->obmat, vec); - VECCOPY(mat[3], tvec); + mul_v3_m4v3(mat[3], ob->obmat, vec); } } @@ -554,7 +553,7 @@ static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][ mul_v3_m4v3(tvec, ob->obmat, vec); /* copy new location to matrix */ - VECCOPY(mat[3], tvec); + copy_v3_v3(mat[3], tvec); } /* generic function to get the appropriate matrix for most target cases */ @@ -819,11 +818,11 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta copy_m4_m4(invmat, data->invmat); /* extract components of both matrices */ - VECCOPY(loc, ct->matrix[3]); + copy_v3_v3(loc, ct->matrix[3]); mat4_to_eulO(eul, ct->rotOrder, ct->matrix); mat4_to_size(size, ct->matrix); - VECCOPY(loco, invmat[3]); + copy_v3_v3(loco, invmat[3]); mat4_to_eulO(eulo, cob->rotOrder, invmat); mat4_to_size(sizo, invmat); @@ -940,9 +939,8 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh float right[3]; float neg = -1; int right_index; - - copy_v3_v3(n, vec); - if (normalize_v3(n) == 0.0) { + + if (normalize_v3_v3(n, vec) == 0.0) { n[0] = 0.0; n[1] = 0.0; n[2] = 1.0; @@ -953,9 +951,7 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh /* n specifies the transformation of the track axis */ if (flags & TARGET_Z_UP) { /* target Z axis is the global up axis */ - u[0] = target_up[0]; - u[1] = target_up[1]; - u[2] = target_up[2]; + copy_v3_v3(u, target_up); } else { /* world Z axis is the global up axis */ @@ -988,20 +984,13 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh m[right_index][1] = neg * right[1]; m[right_index][2] = neg * right[2]; - m[upflag][0] = proj[0]; - m[upflag][1] = proj[1]; - m[upflag][2] = proj[2]; + copy_v3_v3(m[upflag], proj); - m[axis][0] = n[0]; - m[axis][1] = n[1]; - m[axis][2] = n[2]; + copy_v3_v3(m[axis], n); } /* identity matrix - don't do anything if the two axes are the same */ else { - m[0][0]= m[1][1]= m[2][2]= 1.0; - m[0][1]= m[0][2]= 0.0; - m[1][0]= m[1][2]= 0.0; - m[2][0]= m[2][1]= 0.0; + unit_m3(m); } } @@ -1264,7 +1253,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr copy_m4_m4(totmat, rmat); } - VECCOPY(totmat[3], vec); + copy_v3_v3(totmat[3], vec); mul_serie_m4(ct->matrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL); } @@ -1383,7 +1372,7 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t float eul[3]; float size[3]; - VECCOPY(loc, cob->matrix[3]); + copy_v3_v3(loc, cob->matrix[3]); mat4_to_size(size, cob->matrix); mat4_to_eulO(eul, cob->rotOrder, cob->matrix); @@ -1544,7 +1533,7 @@ static void loclike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float offset[3] = {0.0f, 0.0f, 0.0f}; if (data->flag & LOCLIKE_OFFSET) - VECCOPY(offset, cob->matrix[3]); + copy_v3_v3(offset, cob->matrix[3]); if (data->flag & LOCLIKE_X) { cob->matrix[3][0] = ct->matrix[3][0]; @@ -1636,7 +1625,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta float eul[3], obeul[3]; float size[3]; - VECCOPY(loc, cob->matrix[3]); + copy_v3_v3(loc, cob->matrix[3]); mat4_to_size(size, cob->matrix); /* to allow compatible rotations, must get both rotations in the order of the owner... */ @@ -2138,7 +2127,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint } else { /* extract location */ - VECCOPY(vec, tempmat[3]); + copy_v3_v3(vec, tempmat[3]); axis= data->type - 20; } @@ -2294,10 +2283,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * normalize_v3(totmat[1]); /* the x axis is fixed */ - totmat[0][0] = cob->matrix[0][0]; - totmat[0][1] = cob->matrix[0][1]; - totmat[0][2] = cob->matrix[0][2]; - normalize_v3(totmat[0]); + normalize_v3_v3(totmat[0], cob->matrix[0]); /* the z axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); @@ -2311,10 +2297,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * normalize_v3(totmat[2]); /* the x axis is fixed */ - totmat[0][0] = cob->matrix[0][0]; - totmat[0][1] = cob->matrix[0][1]; - totmat[0][2] = cob->matrix[0][2]; - normalize_v3(totmat[0]); + normalize_v3_v3(totmat[0], cob->matrix[0]); /* the z axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); @@ -2329,10 +2312,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * negate_v3(totmat[1]); /* the x axis is fixed */ - totmat[0][0] = cob->matrix[0][0]; - totmat[0][1] = cob->matrix[0][1]; - totmat[0][2] = cob->matrix[0][2]; - normalize_v3(totmat[0]); + normalize_v3_v3(totmat[0], cob->matrix[0]); /* the z axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); @@ -2347,10 +2327,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * negate_v3(totmat[2]); /* the x axis is fixed */ - totmat[0][0] = cob->matrix[0][0]; - totmat[0][1] = cob->matrix[0][1]; - totmat[0][2] = cob->matrix[0][2]; - normalize_v3(totmat[0]); + normalize_v3_v3(totmat[0], cob->matrix[0]); /* the z axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); @@ -2358,9 +2335,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * break; default: { - totmat[0][0] = 1;totmat[0][1] = 0;totmat[0][2] = 0; - totmat[1][0] = 0;totmat[1][1] = 1;totmat[1][2] = 0; - totmat[2][0] = 0;totmat[2][1] = 0;totmat[2][2] = 1; + unit_m3(totmat); } break; } @@ -2377,11 +2352,8 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * normalize_v3(totmat[0]); /* the y axis is fixed */ - totmat[1][0] = cob->matrix[1][0]; - totmat[1][1] = cob->matrix[1][1]; - totmat[1][2] = cob->matrix[1][2]; - normalize_v3(totmat[1]); - + normalize_v3_v3(totmat[1], cob->matrix[1]); + /* the z axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); } @@ -2394,10 +2366,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * normalize_v3(totmat[2]); /* the y axis is fixed */ - totmat[1][0] = cob->matrix[1][0]; - totmat[1][1] = cob->matrix[1][1]; - totmat[1][2] = cob->matrix[1][2]; - normalize_v3(totmat[1]); + normalize_v3_v3(totmat[1], cob->matrix[1]); /* the z axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); @@ -2412,10 +2381,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * negate_v3(totmat[0]); /* the y axis is fixed */ - totmat[1][0] = cob->matrix[1][0]; - totmat[1][1] = cob->matrix[1][1]; - totmat[1][2] = cob->matrix[1][2]; - normalize_v3(totmat[1]); + normalize_v3_v3(totmat[1], cob->matrix[1]); /* the z axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); @@ -2430,10 +2396,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * negate_v3(totmat[2]); /* the y axis is fixed */ - totmat[1][0] = cob->matrix[1][0]; - totmat[1][1] = cob->matrix[1][1]; - totmat[1][2] = cob->matrix[1][2]; - normalize_v3(totmat[1]); + normalize_v3_v3(totmat[1], cob->matrix[1]); /* the z axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); @@ -2441,9 +2404,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * break; default: { - totmat[0][0] = 1;totmat[0][1] = 0;totmat[0][2] = 0; - totmat[1][0] = 0;totmat[1][1] = 1;totmat[1][2] = 0; - totmat[2][0] = 0;totmat[2][1] = 0;totmat[2][2] = 1; + unit_m3(totmat); } break; } @@ -2460,10 +2421,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * normalize_v3(totmat[0]); /* the z axis is fixed */ - totmat[2][0] = cob->matrix[2][0]; - totmat[2][1] = cob->matrix[2][1]; - totmat[2][2] = cob->matrix[2][2]; - normalize_v3(totmat[2]); + normalize_v3_v3(totmat[2], cob->matrix[2]); /* the x axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); @@ -2477,10 +2435,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * normalize_v3(totmat[1]); /* the z axis is fixed */ - totmat[2][0] = cob->matrix[2][0]; - totmat[2][1] = cob->matrix[2][1]; - totmat[2][2] = cob->matrix[2][2]; - normalize_v3(totmat[2]); + normalize_v3_v3(totmat[2], cob->matrix[2]); /* the x axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); @@ -2495,10 +2450,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * negate_v3(totmat[0]); /* the z axis is fixed */ - totmat[2][0] = cob->matrix[2][0]; - totmat[2][1] = cob->matrix[2][1]; - totmat[2][2] = cob->matrix[2][2]; - normalize_v3(totmat[2]); + normalize_v3_v3(totmat[2], cob->matrix[2]); /* the x axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); @@ -2513,10 +2465,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * negate_v3(totmat[1]); /* the z axis is fixed */ - totmat[2][0] = cob->matrix[2][0]; - totmat[2][1] = cob->matrix[2][1]; - totmat[2][2] = cob->matrix[2][2]; - normalize_v3(totmat[2]); + normalize_v3_v3(totmat[2], cob->matrix[2]); /* the x axis gets mapped onto a third orthogonal vector */ cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); @@ -2524,9 +2473,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * break; default: { - totmat[0][0] = 1;totmat[0][1] = 0;totmat[0][2] = 0; - totmat[1][0] = 0;totmat[1][1] = 1;totmat[1][2] = 0; - totmat[2][0] = 0;totmat[2][1] = 0;totmat[2][2] = 1; + unit_m3(totmat); } break; } @@ -2534,19 +2481,13 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * break; default: { - totmat[0][0] = 1;totmat[0][1] = 0;totmat[0][2] = 0; - totmat[1][0] = 0;totmat[1][1] = 1;totmat[1][2] = 0; - totmat[2][0] = 0;totmat[2][1] = 0;totmat[2][2] = 1; + unit_m3(totmat); } break; } /* Block to keep matrix heading */ - tmpmat[0][0] = cob->matrix[0][0];tmpmat[0][1] = cob->matrix[0][1];tmpmat[0][2] = cob->matrix[0][2]; - tmpmat[1][0] = cob->matrix[1][0];tmpmat[1][1] = cob->matrix[1][1];tmpmat[1][2] = cob->matrix[1][2]; - tmpmat[2][0] = cob->matrix[2][0];tmpmat[2][1] = cob->matrix[2][1];tmpmat[2][2] = cob->matrix[2][2]; - normalize_v3(tmpmat[0]); - normalize_v3(tmpmat[1]); - normalize_v3(tmpmat[2]); + copy_m3_m4(tmpmat, cob->matrix); + normalize_m3(tmpmat); invert_m3_m3(invmat, tmpmat); mul_m3_m3m3(tmpmat, totmat, invmat); totmat[0][0] = tmpmat[0][0];totmat[0][1] = tmpmat[0][1];totmat[0][2] = tmpmat[0][2]; @@ -2559,9 +2500,7 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * totmat[1][0],totmat[1][1],totmat[1][2], totmat[2][0],totmat[2][1],totmat[2][2]); if (mdet==0) { - totmat[0][0] = 1;totmat[0][1] = 0;totmat[0][2] = 0; - totmat[1][0] = 0;totmat[1][1] = 1;totmat[1][2] = 0; - totmat[2][0] = 0;totmat[2][1] = 0;totmat[2][2] = 1; + unit_m3(totmat); } /* apply out transformaton to the object */ @@ -2689,7 +2628,7 @@ static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * interp_v3_v3v3(dvec, ct->matrix[3], cob->matrix[3], sfac); /* copy new vector onto owner */ - VECCOPY(cob->matrix[3], dvec); + copy_v3_v3(cob->matrix[3], dvec); } } } @@ -2772,16 +2711,10 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * mat4_to_size(size, cob->matrix); /* store X orientation before destroying obmat */ - xx[0] = cob->matrix[0][0]; - xx[1] = cob->matrix[0][1]; - xx[2] = cob->matrix[0][2]; - normalize_v3(xx); + normalize_v3_v3(xx, cob->matrix[0]); /* store Z orientation before destroying obmat */ - zz[0] = cob->matrix[2][0]; - zz[1] = cob->matrix[2][1]; - zz[2] = cob->matrix[2][2]; - normalize_v3(zz); + normalize_v3_v3(zz, cob->matrix[2]); sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); vec[0] /= size[0]; @@ -2836,9 +2769,7 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * normalize_v3(vec); /* new Y aligns object target connection*/ - totmat[1][0] = -vec[0]; - totmat[1][1] = -vec[1]; - totmat[1][2] = -vec[2]; + negate_v3_v3(totmat[1], vec); switch (data->plane) { case PLANE_X: /* build new Z vector */ @@ -2847,16 +2778,11 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * normalize_v3(orth); /* new Z*/ - totmat[2][0] = orth[0]; - totmat[2][1] = orth[1]; - totmat[2][2] = orth[2]; + copy_v3_v3(totmat[2], orth); /* we decided to keep X plane*/ cross_v3_v3v3(xx, orth, vec); - normalize_v3(xx); - totmat[0][0] = xx[0]; - totmat[0][1] = xx[1]; - totmat[0][2] = xx[2]; + normalize_v3_v3(totmat[0], xx); break; case PLANE_Z: /* build new X vector */ @@ -2865,16 +2791,11 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * normalize_v3(orth); /* new X */ - totmat[0][0] = -orth[0]; - totmat[0][1] = -orth[1]; - totmat[0][2] = -orth[2]; + negate_v3_v3(totmat[0], orth); /* we decided to keep Z */ cross_v3_v3v3(zz, orth, vec); - normalize_v3(zz); - totmat[2][0] = zz[0]; - totmat[2][1] = zz[1]; - totmat[2][2] = zz[2]; + normalize_v3_v3(totmat[2], zz); break; } /* switch (data->plane) */ @@ -3006,10 +2927,10 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar obmat[3][index] = tarmat[3][index] + data->offset; if (data->flag & MINMAX_STICKY) { if (data->flag & MINMAX_STUCK) { - VECCOPY(obmat[3], data->cache); + copy_v3_v3(obmat[3], data->cache); } else { - VECCOPY(data->cache, obmat[3]); + copy_v3_v3(data->cache, obmat[3]); data->flag |= MINMAX_STUCK; } } @@ -3019,7 +2940,7 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar copy_m4_m4(cob->matrix, tmat); } else { - VECCOPY(cob->matrix[3], obmat[3]); + copy_v3_v3(cob->matrix[3], obmat[3]); } } else { @@ -3174,7 +3095,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta copy_m4_m4(obmat, cob->matrix); unit_m4(targetMatrix); - VECCOPY(ownLoc, obmat[3]); + copy_v3_v3(ownLoc, obmat[3]); INIT_MINMAX(curveMin, curveMax) minmax_object(ct->tar, curveMin, curveMax); @@ -3263,14 +3184,14 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* 3. position on curve */ if (where_on_path(ct->tar, curvetime, vec, dir, NULL, NULL, NULL) ) { unit_m4(totmat); - VECCOPY(totmat[3], vec); + copy_v3_v3(totmat[3], vec); mul_serie_m4(targetMatrix, ct->tar->obmat, totmat, NULL, NULL, NULL, NULL, NULL, NULL); } } /* obtain final object position */ - VECCOPY(cob->matrix[3], targetMatrix[3]); + copy_v3_v3(cob->matrix[3], targetMatrix[3]); } } @@ -3362,7 +3283,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * } /* extract components of owner's matrix */ - VECCOPY(loc, cob->matrix[3]); + copy_v3_v3(loc, cob->matrix[3]); mat4_to_eulO(eul, cob->rotOrder, cob->matrix); mat4_to_size(size, cob->matrix); @@ -3556,7 +3477,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr fail = TRUE; break; } - VECCOPY(co, hit.co); + copy_v3_v3(co, hit.co); break; } @@ -3572,7 +3493,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr /* 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); + copy_v3_v3(ct->matrix[3], co); } } } @@ -3584,7 +3505,7 @@ static void shrinkwrap_evaluate (bConstraint *con, bConstraintOb *cob, ListBase /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { - VECCOPY(cob->matrix[3], ct->matrix[3]); + copy_v3_v3(cob->matrix[3], ct->matrix[3]); } } @@ -3668,23 +3589,23 @@ static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * * - the normalisation step at the end should take care of any unwanted scaling * left over in the 3x3 matrix we used */ - VECCOPY(obvec, track_dir_vecs[data->trackflag]); + copy_v3_v3(obvec, track_dir_vecs[data->trackflag]); mul_mat3_m4_v3(cob->matrix, obvec); if (normalize_v3(obvec) == 0.0f) { /* exceptional case - just use the track vector as appropriate */ - VECCOPY(obvec, track_dir_vecs[data->trackflag]); + copy_v3_v3(obvec, track_dir_vecs[data->trackflag]); } /* find the (unit) direction vector going from the owner to the target */ - VECCOPY(obloc, cob->matrix[3]); + copy_v3_v3(obloc, cob->matrix[3]); sub_v3_v3v3(tarvec, ct->matrix[3], obloc); if (normalize_v3(tarvec) == 0.0f) { /* the target is sitting on the owner, so just make them use the same direction vectors */ // FIXME: or would it be better to use the pure direction vector? - VECCOPY(tarvec, obvec); - //VECCOPY(tarvec, track_dir_vecs[data->trackflag]); + copy_v3_v3(tarvec, obvec); + //copy_v3_v3(tarvec, track_dir_vecs[data->trackflag]); } /* determine the axis-angle rotation, which represents the smallest possible rotation @@ -3712,7 +3633,7 @@ static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * mul_m4_m3m4(tmat, rmat, cob->matrix); // m1, m3, m2 copy_m4_m4(cob->matrix, tmat); - VECCOPY(cob->matrix[3], obloc); + copy_v3_v3(cob->matrix[3], obloc); } } @@ -3907,7 +3828,7 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t } else { /* directly use the 'offset' specified as an absolute position instead */ - VECCOPY(pivot, data->offset); + copy_v3_v3(pivot, data->offset); } } diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 5f55814341b..6f6d405dd90 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -662,8 +662,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin where_is_object_time(eff->scene, ob, cfra); /* use z-axis as normal*/ - VECCOPY(efd->nor, ob->obmat[2]); - normalize_v3(efd->nor); + normalize_v3_v3(efd->nor, ob->obmat[2]); /* for vortex the shape chooses between old / new force */ if(eff->pd && eff->pd->shape == PFIELD_SHAPE_PLANE) { @@ -707,8 +706,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin else { /* for some effectors we need the object center every time */ sub_v3_v3v3(efd->vec_to_point2, point->loc, eff->ob->obmat[3]); - VECCOPY(efd->nor2, eff->ob->obmat[2]); - normalize_v3(efd->nor2); + normalize_v3_v3(efd->nor2, eff->ob->obmat[2]); } } diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index d544174b0d4..158f964a846 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1626,9 +1626,8 @@ static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF, CalcFloat4(lX[mfaces[i].v1],lX[mfaces[i].v2],lX[mfaces[i].v3],lX[mfaces[i].v4],triunnormal); else CalcFloat(lX[mfaces[i].v1],lX[mfaces[i].v2],lX[mfaces[i].v3],triunnormal); - - VECCOPY(trinormal, triunnormal); - normalize_v3(trinormal); + + normalize_v3_v3(trinormal, triunnormal); // add wind from v1 VECCOPY(tmp, trinormal); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index a017b7344d7..94131fdbe9d 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1236,14 +1236,10 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, MVert *mv= &mverts[i]; float *no= tnorms[i]; - if (normalize_v3(no)==0.0) { - VECCOPY(no, mv->co); - normalize_v3(no); - } + if (normalize_v3(no)==0.0) + normalize_v3_v3(no, mv->co); - mv->no[0]= (short)(no[0]*32767.0); - mv->no[1]= (short)(no[1]*32767.0); - mv->no[2]= (short)(no[2]*32767.0); + normal_float_to_short_v3(mv->no, no); } MEM_freeN(tnorms); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 7b3638f0e33..681c48b0cf8 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -624,8 +624,7 @@ static float psys_render_projected_area(ParticleSystem *psys, float *center, flo mul_m4_v4(data->viewmat, co); /* compute two vectors orthogonal to view vector */ - VECCOPY(view, co); - normalize_v3(view); + normalize_v3_v3(view, co); ortho_basis_v3v3_v3( ortho1, ortho2,view); /* compute on screen minification */ @@ -1923,8 +1922,7 @@ static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, flo mul_qt_v3(q2,z_vec); VECSUB(vec_from_par,state->co,par->co); - VECCOPY(vec_one,vec_from_par); - radius=normalize_v3(vec_one); + radius= normalize_v3_v3(vec_one, vec_from_par); inp_y=dot_v3v3(y_vec,vec_one); inp_z=dot_v3v3(z_vec,vec_one); @@ -2929,8 +2927,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) if(k == 1) { /* calculate initial tangent for incremental rotations */ VECSUB(tangent, ca->co, (ca - 1)->co); - VECCOPY(prev_tangent, tangent); - normalize_v3(prev_tangent); + normalize_v3_v3(prev_tangent, tangent); /* First rotation is based on emitting face orientation. */ /* This is way better than having flipping rotations resulting */ @@ -3106,8 +3103,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf if(k == 1) { /* calculate initial tangent for incremental rotations */ VECSUB(tangent, ca->co, (ca - 1)->co); - VECCOPY(prev_tangent, tangent); - normalize_v3(prev_tangent); + normalize_v3_v3(prev_tangent, tangent); /* First rotation is based on emitting face orientation. */ /* This is way better than having flipping rotations resulting */ @@ -4371,20 +4367,14 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] onevec[bb->align]=1.0f; if(bb->lock && (bb->align == PART_BB_VIEW)) { - VECCOPY(xvec, bb->ob->obmat[0]); - normalize_v3(xvec); - - VECCOPY(yvec, bb->ob->obmat[1]); - normalize_v3(yvec); - - VECCOPY(zvec, bb->ob->obmat[2]); - normalize_v3(zvec); + normalize_v3_v3(xvec, bb->ob->obmat[0]); + normalize_v3_v3(yvec, bb->ob->obmat[1]); + normalize_v3_v3(zvec, bb->ob->obmat[2]); } else if(bb->align == PART_BB_VEL) { float temp[3]; - VECCOPY(temp, bb->vel); - normalize_v3(temp); + normalize_v3_v3(temp, bb->vel); VECSUB(zvec, bb->ob->obmat[3], bb->vec); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 9b9c3ff16b6..cfbab609f37 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1729,8 +1729,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, mul_qt_v3(rot, vtan); mul_qt_v3(rot, utan); - VECCOPY(p_vel, state.vel); - speed=normalize_v3(p_vel); + speed= normalize_v3_v3(p_vel, state.vel); mul_v3_fl(p_vel, dot_v3v3(r_vel, p_vel)); VECSUB(p_vel, r_vel, p_vel); normalize_v3(p_vel); @@ -1871,18 +1870,15 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* *emitter object orientation */ if(part->ob_vel[0]!=0.0) { - VECCOPY(vec, ob->obmat[0]); - normalize_v3(vec); + normalize_v3_v3(vec, ob->obmat[0]); VECADDFAC(vel, vel, vec, part->ob_vel[0]); } if(part->ob_vel[1]!=0.0) { - VECCOPY(vec, ob->obmat[1]); - normalize_v3(vec); + normalize_v3_v3(vec, ob->obmat[1]); VECADDFAC(vel, vel, vec, part->ob_vel[1]); } if(part->ob_vel[2]!=0.0) { - VECCOPY(vec, ob->obmat[2]); - normalize_v3(vec); + normalize_v3_v3(vec, ob->obmat[2]); VECADDFAC(vel, vel, vec, part->ob_vel[2]); } diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index 33871f78864..7e39cdd1196 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -72,8 +72,7 @@ void sk_initPoint(SK_Point *pt, SK_DrawData *dd, float *no) { if (no) { - VECCOPY(pt->no, no); - normalize_v3(pt->no); + normalize_v3_v3(pt->no, no); } else { diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index b8e824ce3d5..98a50eee146 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -2032,8 +2032,7 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], VECCOPY(vel,avel); if (ci) *intrusion /= ci; if (deflected){ - VECCOPY(facenormal,force); - normalize_v3(facenormal); + normalize_v3_v3(facenormal, force); } return deflected; } -- cgit v1.2.3 From d1759639dc5a02d2ccde16d1c2fb1e951b15f1ea Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 16 Aug 2010 05:46:10 +0000 Subject: - remove unused includes IMB_*, BIF_* & MEM_* - remove MEM_guardedalloc.h from header files (include directly) --- source/blender/blenkernel/intern/BME_Customdata.c | 2 +- source/blender/blenkernel/intern/anim.c | 3 --- source/blender/blenkernel/intern/booleanops_mesh.c | 1 - source/blender/blenkernel/intern/brush.c | 1 - source/blender/blenkernel/intern/depsgraph.c | 10 +++------- source/blender/blenkernel/intern/fmodifier.c | 4 ---- source/blender/blenkernel/intern/material.c | 4 ---- source/blender/blenkernel/intern/modifier.c | 2 ++ source/blender/blenkernel/intern/node.c | 1 - source/blender/blenkernel/intern/paint.c | 1 - source/blender/blenkernel/intern/scene.c | 7 ++----- source/blender/blenkernel/intern/screen.c | 4 ---- source/blender/blenkernel/intern/shrinkwrap.c | 1 - source/blender/blenkernel/intern/world.c | 4 ---- source/blender/blenkernel/intern/writeframeserver.c | 1 - 15 files changed, 8 insertions(+), 38 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/BME_Customdata.c b/source/blender/blenkernel/intern/BME_Customdata.c index d8a6b66d5bb..1087b3a873c 100644 --- a/source/blender/blenkernel/intern/BME_Customdata.c +++ b/source/blender/blenkernel/intern/BME_Customdata.c @@ -36,9 +36,9 @@ #include +#include "MEM_guardedalloc.h" #include "BKE_bmeshCustomData.h" #include "bmesh_private.h" -#include "MEM_guardedalloc.h" /********************* Layer type information **********************/ typedef struct BME_LayerTypeInfo { diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 89c637d8192..e27e3b2cd3f 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -40,7 +40,6 @@ #include "BLI_math.h" #include "BLI_rand.h" - #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_group_types.h" @@ -49,7 +48,6 @@ #include "DNA_scene_types.h" #include "DNA_vfont_types.h" -//(INCLUDE_LINT)#include "BKE_anim.h" #include "BKE_curve.h" #include "BKE_DerivedMesh.h" #include "BKE_depsgraph.h" @@ -66,7 +64,6 @@ #include "BKE_utildefines.h" #include "BKE_depsgraph.h" -#include "ED_curve.h" /* for ED_curve_nurbs */ // XXX bad level call... diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 431e51cf149..dd595fc98b6 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -30,7 +30,6 @@ */ #include "CSG_BooleanOps.h" -#include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 905515914b4..71a43994363 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -39,7 +39,6 @@ #include "DNA_windowmanager_types.h" #include "WM_types.h" -#include "WM_api.h" #include "RNA_access.h" diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index d498b73be7e..382c0690ae3 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -41,6 +41,8 @@ #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" +#include "MEM_guardedalloc.h" + #include "BLI_ghash.h" #include "BKE_animsys.h" @@ -59,13 +61,7 @@ #include "BKE_scene.h" #include "BKE_screen.h" -#include "MEM_guardedalloc.h" - -#ifndef DISABLE_PYTHON -#include "BPY_extern.h" -#endif - - #include "depsgraph_private.h" +#include "depsgraph_private.h" /* Queue and stack operations for dag traversal * diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 3271749643a..124e6365777 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -43,10 +43,6 @@ #include "BKE_idprop.h" #include "BKE_utildefines.h" -#ifndef DISABLE_PYTHON -#include "BPY_extern.h" /* for BPY_eval_driver() */ -#endif - #define SMALL -1.0e-10 #define SELECT 1 diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 724536048ce..9774e97f69b 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -56,10 +56,6 @@ #include "BKE_node.h" #include "BKE_utildefines.h" -#ifndef DISABLE_PYTHON -#include "BPY_extern.h" -#endif - #include "GPU_material.h" /* used in UI and render */ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index c35b1a8b0a8..63f0f1fa091 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -44,6 +44,8 @@ #include "DNA_object_types.h" #include "DNA_meshdata_types.h" +#include "MEM_guardedalloc.h" + #include "BKE_bmesh.h" #include "BKE_cloth.h" #include "BKE_key.h" diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index ea30b33655f..9dca0fa82e4 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -45,7 +45,6 @@ #include "PIL_time.h" -#include "MEM_guardedalloc.h" #include "CMP_node.h" #include "intern/CMP_util.h" /* stupid include path... */ diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 3343df6b8a7..ffb99c10c40 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -25,7 +25,6 @@ * ***** END GPL LICENSE BLOCK ***** */ -#include "MEM_guardedalloc.h" #include "DNA_object_types.h" #include "DNA_mesh_types.h" diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 42506b66303..8793c412d7d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -38,7 +38,6 @@ #else #include #endif -#include "MEM_guardedalloc.h" #include "DNA_anim_types.h" #include "DNA_group_types.h" @@ -47,6 +46,8 @@ #include "DNA_screen_types.h" #include "DNA_sequence_types.h" +#include "MEM_guardedalloc.h" + #include "BKE_anim.h" #include "BKE_animsys.h" #include "BKE_depsgraph.h" @@ -68,10 +69,6 @@ //XXX #include "BIF_previewrender.h" //XXX #include "BIF_editseq.h" -#ifndef DISABLE_PYTHON -#include "BPY_extern.h" -#endif - #include "BLI_math.h" #include "BLI_blenlib.h" diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index a8140cb815d..6f1d32898f9 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -42,10 +42,6 @@ #include "BKE_screen.h" -#ifndef DISABLE_PYTHON -#include "BPY_extern.h" -#endif - /* ************ Spacetype/regiontype handling ************** */ /* keep global; this has to be accessible outside of windowmanager */ diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index bddfeb049a8..01652aaa713 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -51,7 +51,6 @@ #include "BLI_math.h" #include "BLI_editVert.h" -#include "MEM_guardedalloc.h" /* Util macros */ diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 233a1433ecb..42df92443f3 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -44,10 +44,6 @@ #include "BKE_main.h" #include "BKE_icons.h" -#ifndef DISABLE_PYTHON -#include "BPY_extern.h" -#endif - void free_world(World *wrld) { MTex *mtex; diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 0ec8837c0e7..b0c05c31fa1 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -45,7 +45,6 @@ #include -#include "MEM_guardedalloc.h" #include "DNA_userdef_types.h" #include "BKE_global.h" -- cgit v1.2.3 From a91d538f47171a40463016b91c22d39d694d923a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 16 Aug 2010 09:24:18 +0000 Subject: - commit that removed MEM_guardedalloc.h includes broke building with SSE enabled. - all C/C++ files in blender are now utf8 compatible. --- source/blender/blenkernel/intern/fluidsim.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 8a6f0af87d1..04ce6c39694 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -50,7 +50,6 @@ #include "BKE_global.h" #include "BKE_modifier.h" #include "BKE_mesh.h" -#include "BKE_pointcache.h" #include "BKE_utildefines.h" // headers for fluidsim bobj meshes -- cgit v1.2.3 From 7da5d9faec9f6ad170c5c77fe9b59deba6a2acab Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 18 Aug 2010 07:14:10 +0000 Subject: rna renaming, still only adjusting properties that wont be animated (at least its very unlikely). --- source/blender/blenkernel/intern/idcode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index 3e8f400967e..6411959e655 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -48,7 +48,7 @@ static IDType idtypes[]= { { ID_BR, "Brush", "brushes", IDTYPE_FLAGS_ISLINKABLE}, { ID_CA, "Camera", "cameras", IDTYPE_FLAGS_ISLINKABLE}, { ID_CU, "Curve", "curves", IDTYPE_FLAGS_ISLINKABLE}, - { ID_GD, "GPencil", "gpencil", IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */ + { ID_GD, "GPencil", "grease_pencil",IDTYPE_FLAGS_ISLINKABLE}, /* rename gpencil */ { ID_GR, "Group", "groups", IDTYPE_FLAGS_ISLINKABLE}, { ID_ID, "ID", "ids", 0}, /* plural is fake */ { ID_IM, "Image", "images", IDTYPE_FLAGS_ISLINKABLE}, -- cgit v1.2.3 From dfb84553815adaddc1368c5b06e48f91abf5d096 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 20 Aug 2010 16:02:20 +0000 Subject: Fix #23332: crash with screw + bevel modifiers. Since bevel doesn't support mapping yet there's still some weirdness with display of hiding/selection, but there's another bug report open about that. --- source/blender/blenkernel/intern/BME_conversions.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c index 64a6e14bc5d..341eb38b388 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -531,6 +531,7 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm) MFace *mface, *mf; MEdge *medge, *me; MVert *mvert, *mv; + int *origindex; int totface,totedge,totvert,i,bmeshok,len, numTex, numCol; BME_Vert *v1=NULL; @@ -577,13 +578,16 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm) /*Make Verts*/ mvert = CDDM_get_verts(result); + origindex = result->getVertDataArray(result, CD_ORIGINDEX); for(i=0,v1=bm->verts.first,mv=mvert;v1;v1=v1->next,i++,mv++){ VECCOPY(mv->co,v1->co); mv->flag = (unsigned char)v1->flag; mv->bweight = (char)(255.0*v1->bweight); CustomData_from_bmesh_block(&bm->vdata, &result->vertData, &v1->data, i); + origindex[i] = ORIGINDEX_NONE; } medge = CDDM_get_edges(result); + origindex = result->getEdgeDataArray(result, CD_ORIGINDEX); i=0; for(e=bm->edges.first,me=medge;e;e=e->next){ if(e->tflag2){ @@ -600,12 +604,14 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm) me->bweight = (char)(255.0*e->bweight); me->flag = e->flag; CustomData_from_bmesh_block(&bm->edata, &result->edgeData, &e->data, i); + origindex[i] = ORIGINDEX_NONE; me++; i++; } } if(totface){ mface = CDDM_get_faces(result); + origindex = result->getFaceDataArray(result, CD_ORIGINDEX); /*make faces*/ for(i=0,f=bm->polys.first;f;f=f->next){ mf = &mface[i]; @@ -625,6 +631,7 @@ DerivedMesh *BME_bmesh_to_derivedmesh(BME_Mesh *bm, DerivedMesh *dm) mf->flag = (unsigned char)f->flag; CustomData_from_bmesh_block(&bm->pdata, &result->faceData, &f->data, i); BME_DMloops_to_corners(bm, &result->faceData, i, f,numCol,numTex); + origindex[i] = ORIGINDEX_NONE; i++; } } -- cgit v1.2.3 From 6e141b73316c636dbdccc2254e886da55059e9cb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Aug 2010 07:11:40 +0000 Subject: own commit to fix a naming bug caused a new bug. --- source/blender/blenkernel/intern/library.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index e935573cf67..b1492fce9d4 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1094,8 +1094,14 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) left_len= splitIDname(name, left, &nr); /* if new name will be too long, truncate it */ - if(nr>999 && strlen(left)>16) left[16]= 0; - else if(strlen(left)>17) left[17]= 0; + if(nr > 999 && left_len > 16) { + left[16]= 0; + left_len= 16; + } + else if(left_len > 17) { + left[17]= 0; + left_len= 17; + } for(idtest= lb->first; idtest; idtest= idtest->next) { if( (id != idtest) && @@ -1136,10 +1142,11 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* otherwise just continue and use a number suffix */ } - if(nr > 999 && strlen(left) > 16) { + if(nr > 999 && left_len > 16) { /* this would overflow name buffer */ left[16] = 0; - strcpy( name, left ); + /* left_len = 16; */ /* for now this isnt used again */ + memcpy(name, left, sizeof(char) * 16); continue; } /* this format specifier is from hell... */ -- cgit v1.2.3 From 2462d4976ba65a8639445b19e8ac13df7ef1a9fa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Aug 2010 10:52:30 +0000 Subject: possible fix [#23331] Hidden Bones Contribute to Axis Normal cant redo this bug but noticed a number of places where bone selection/hidden state isn't being set properly. --- source/blender/blenkernel/intern/library.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index b1492fce9d4..8c8e4bb034f 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1130,8 +1130,8 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) * rather than just chopping and adding numbers, * shave off the end chars until we have a unique name. * Check the null terminators match as well so we dont get Cube.000 -> Cube.00 */ - if (nr==0 && name[left_len]== left[left_len]) { - int len = strlen(name)-1; + if (nr==0 && name[left_len]== '\0') { + int len = left_len-1; idtest= is_dupid(lb, id, name); while (idtest && len> 1) { -- cgit v1.2.3 From 0bab23633a07942586f963c19d053f26c44d799b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 22 Aug 2010 14:15:28 +0000 Subject: remove inline loops in a few places replace with defgroup_find_name() and BLI_findstring() --- source/blender/blenkernel/intern/action.c | 10 +--------- source/blender/blenkernel/intern/blender.c | 9 +++------ source/blender/blenkernel/intern/context.c | 12 ++++++------ source/blender/blenkernel/intern/deform.c | 2 +- source/blender/blenkernel/intern/key.c | 19 +++++-------------- source/blender/blenkernel/intern/node.c | 8 +------- source/blender/blenkernel/intern/property.c | 10 ++-------- 7 files changed, 19 insertions(+), 51 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 41ff3fed8a5..90a3a6ce664 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -368,20 +368,12 @@ void action_groups_remove_channel (bAction *act, FCurve *fcu) /* Find a group with the given name */ bActionGroup *action_groups_find_named (bAction *act, const char name[]) { - bActionGroup *grp; - /* sanity checks */ if (ELEM3(NULL, act, act->groups.first, name) || (name[0] == 0)) return NULL; /* do string comparisons */ - for (grp= act->groups.first; grp; grp= grp->next) { - if (strcmp(grp->name, name) == 0) - return grp; - } - - /* not found */ - return NULL; + return BLI_findstring(&act->groups, name, offsetof(bActionGroup, name)); } /* *************** Pose channels *************** */ diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 7c8cea12549..292d7be48d6 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -43,6 +43,7 @@ #include #include +#include #include #include // for open @@ -640,12 +641,8 @@ void BKE_undo_number(bContext *C, int nr) /* go back to the last occurance of name in stack */ void BKE_undo_name(bContext *C, const char *name) { - UndoElem *uel; - - for(uel= undobase.last; uel; uel= uel->prev) { - if(strcmp(name, uel->name)==0) - break; - } + UndoElem *uel= BLI_findstring(&undobase, name, offsetof(UndoElem, name)); + if(uel && uel->prev) { curundo= uel->prev; BKE_undo_step(C, 0); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 9520df71b60..24dcb4c5846 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -25,6 +25,9 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include +#include + #include "MEM_guardedalloc.h" #include "DNA_scene_types.h" @@ -47,8 +50,6 @@ #include "BPY_extern.h" #endif -#include - /* struct */ struct bContext { @@ -571,13 +572,12 @@ int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListB static void data_dir_add(ListBase *lb, const char *member) { LinkData *link; - + if(strcmp(member, "scene") == 0) /* exception */ return; - for(link=lb->first; link; link=link->next) - if(strcmp(link->data, member) == 0) - return; + if(BLI_findstring(lb, member, offsetof(LinkData, data))) + return; link= MEM_callocN(sizeof(LinkData), "LinkData"); link->data= (void*)member; diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index ccb6ebe1f1e..91584b6236f 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -176,7 +176,7 @@ void defvert_flip (MDeformVert *dvert, int *flip_map) } -bDeformGroup *defgroup_find_name (Object *ob, char *name) +bDeformGroup *defgroup_find_name (Object *ob, const char *name) { /* return a pointer to the deform group with this name * or return NULL otherwise. diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index f4b931ec52b..708403ab1f7 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -50,6 +50,7 @@ #include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_customdata.h" +#include "BKE_deform.h" #include "BKE_global.h" #include "BKE_key.h" #include "BKE_lattice.h" @@ -1003,7 +1004,6 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * static float *get_weights_array(Object *ob, char *vgroup) { - bDeformGroup *curdef; MDeformVert *dvert= NULL; EditMesh *em= NULL; EditVert *eve; @@ -1030,11 +1030,8 @@ static float *get_weights_array(Object *ob, char *vgroup) if(dvert==NULL) return NULL; /* find the group (weak loop-in-loop) */ - for (curdef = ob->defbase.first; curdef; curdef=curdef->next, index++) - if (!strcmp(curdef->name, vgroup)) - break; - - if(curdef) { + index= defgroup_name_index(ob, vgroup); + if(index >= 0) { float *weights; int i, j; @@ -1539,14 +1536,8 @@ KeyBlock *key_get_keyblock(Key *key, int index) /* get the appropriate KeyBlock given a name to search for */ KeyBlock *key_get_named_keyblock(Key *key, const char name[]) { - KeyBlock *kb; - - if (key && name) { - for (kb= key->block.first; kb; kb= kb->next) { - if (strcmp(name, kb->name)==0) - return kb; - } - } + if (key && name) + return BLI_findstring(&key->block, name, offsetof(KeyBlock, name)); return NULL; } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 9dca0fa82e4..5af2c64da18 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -734,13 +734,7 @@ void nodeGroupSocketUseFlags(bNodeTree *ngroup) /* finds a node based on its name */ bNode *nodeFindNodebyName(bNodeTree *ntree, const char *name) { - bNode *node=NULL; - - for(node= ntree->nodes.first; node; node= node->next) { - if (strcmp(name, node->name) == 0) - break; - } - return node; + return BLI_findstring(&ntree->nodes, name, offsetof(bNode, name)); } /* finds a node based on given socket */ diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index a2ba7c69b93..d8001572b4f 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -180,14 +181,7 @@ void unique_property(bProperty *first, bProperty *prop, int force) bProperty *get_ob_property(Object *ob, char *name) { - bProperty *prop; - - prop= ob->prop.first; - while(prop) { - if( strcmp(prop->name, name)==0 ) return prop; - prop= prop->next; - } - return NULL; + return BLI_findstring(&ob->prop, name, offsetof(bProperty, name)); } void set_ob_property(Object *ob, bProperty *propc) -- cgit v1.2.3