From 11228cb4031c8e0a324d2ffa4463e2fb272f517c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 23 Aug 2010 00:57:19 +0000 Subject: rna: move metaball.active_element to metaball.elements.active added rna funcs... elem = metaball.elements.new() metaball.elements.remove(elem) --- source/blender/blenkernel/intern/mball.c | 49 ++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index e35d8bce886..e6f38e04d76 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -176,6 +176,55 @@ void make_local_mball(MetaBall *mb) } } } + +/* most simple meta-element adding function + * dont do context menipulation here (rna uses) */ +MetaElem *add_metaball_element(MetaBall *mb, const int type) +{ + MetaElem *ml= MEM_callocN(sizeof(MetaElem), "metaelem"); + + unit_qt(ml->quat); + + ml->rad= 2.0; + ml->s= 2.0; + ml->flag= MB_SCALE_RAD; + + switch(type) { + case MB_BALL: + ml->type = MB_BALL; + ml->expx= ml->expy= ml->expz= 1.0; + + break; + case MB_TUBE: + ml->type = MB_TUBE; + ml->expx= ml->expy= ml->expz= 1.0; + + break; + case MB_PLANE: + ml->type = MB_PLANE; + ml->expx= ml->expy= ml->expz= 1.0; + + break; + case MB_ELIPSOID: + ml->type = MB_ELIPSOID; + ml->expx= 1.2f; + ml->expy= 0.8f; + ml->expz= 1.0; + + break; + case MB_CUBE: + ml->type = MB_CUBE; + ml->expx= ml->expy= ml->expz= 1.0; + + break; + default: + break; + } + + BLI_addtail(&mb->elems, ml); + + return ml; +} /** Compute bounding box of all MetaElems/MetaBalls. * * Bounding box is computed from polygonized surface. Object *ob is -- cgit v1.2.3 From f6c323aa42e94c4750f52940b47a0d57b503c1b9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 23 Aug 2010 22:16:45 +0000 Subject: - move more active properties into their collections: scene.active_keying_set --> scene.keying_sets.active ...same for active_uv_texture. active_vertex_color, active_keyconfig, - move mesh.add_uv_layer() and mesh.add_vertex_color() into their collections also have them return the newly created layer and dont set the layer active. uvtex = mesh.uv_layers.new(name) vcol = mesh.vertex_colors.new(name) --- source/blender/blenkernel/intern/customdata.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index dcc0a0b876f..1f4b0f303f7 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1213,7 +1213,7 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, data->layers[index].flag = flag; data->layers[index].data = newlayerdata; - if(name) { + if(name || (name=typeInfo->defaultname)) { strcpy(data->layers[index].name, name); CustomData_set_layer_unique_name(data, index); } @@ -1254,7 +1254,7 @@ void *CustomData_add_layer(CustomData *data, int type, int alloctype, /*same as above but accepts a name*/ void *CustomData_add_layer_named(CustomData *data, int type, int alloctype, - void *layerdata, int totelem, char *name) + void *layerdata, int totelem, const char *name) { CustomDataLayer *layer; -- cgit v1.2.3 From adae794233e168aa4046b560c43db6b48725cc08 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 24 Aug 2010 06:40:28 +0000 Subject: py/rna remove functions now all work in a similar way. - some remove() functions took an int argument rather then the item to remove. - disallow None argument. - raise an error if the item isnt in the collection. --- source/blender/blenkernel/intern/constraint.c | 11 ----------- source/blender/blenkernel/intern/fmodifier.c | 7 ------- 2 files changed, 18 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index b415484c1c1..57e5630da19 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3987,17 +3987,6 @@ int remove_constraint (ListBase *list, bConstraint *con) return 0; } -/* Remove the nth constraint from the given constraint stack */ -int remove_constraint_index (ListBase *list, int index) -{ - bConstraint *con= BLI_findlink(list, index); - - if (con) - return remove_constraint(list, con); - else - return 0; -} - /* Remove all the constraints of the specified type from the given constraint stack */ void remove_constraints_type (ListBase *list, short type, short last_only) { diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 124e6365777..f63b58fe489 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -1087,13 +1087,6 @@ int remove_fmodifier (ListBase *modifiers, FModifier *fcm) } } -/* Remove and free the nth F-Modifier from the given stack */ -int remove_fmodifier_index (ListBase *modifiers, int index) -{ - FModifier *fcm= BLI_findlink(modifiers, index); - return remove_fmodifier(modifiers, fcm); -} - /* Remove all of a given F-Curve's modifiers */ void free_fmodifiers (ListBase *modifiers) { -- cgit v1.2.3 From a992fec4e7d6a47bbffb5a9cdc69677b57cba6cf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Aug 2010 02:32:02 +0000 Subject: bugfix - image filepath in the image view would only be set when first loading a frame. - check to free animated image buffers on opengl render was comparing against the wrong value. --- source/blender/blenkernel/intern/image.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d2612e90945..0e282aa6449 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1979,8 +1979,14 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame ibuf= image_get_ibuf(ima, 0, frame); /* XXX temp stuff? */ - if(ima->lastframe != frame) + if(ima->lastframe != frame) { ima->tpageflag |= IMA_TPAGE_REFRESH; + if(ibuf) { + /* without this the image name only updates + * on first load which is quite confusing */ + BLI_strncpy(ima->name, ibuf->name, sizeof(ima->name)); + } + } ima->lastframe = frame; } else if(ima->type==IMA_TYPE_MULTILAYER) { -- cgit v1.2.3 From b54d16858f54452361921629a150b5115235c5fa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Aug 2010 04:03:38 +0000 Subject: bugfix [#23456] context.main.filepath lost after undo G.sce was being restored after undo but not G.main->name also changed reading a new file so G.main->name gets set to the startup.blend even if its not on the disk, not ideal but would set to otherwise. --- source/blender/blenkernel/intern/blender.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 292d7be48d6..a4f44dd0a48 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -460,13 +460,16 @@ static UndoElem *curundo= NULL; static int read_undosave(bContext *C, UndoElem *uel) { - char scestr[FILE_MAXDIR+FILE_MAXFILE]; + char scestr[FILE_MAXDIR+FILE_MAXFILE]; /* we should eventually just use G.main->name */ + char mainstr[FILE_MAXDIR+FILE_MAXFILE]; int success=0, fileflags; /* This is needed so undoing/redoing doesnt crash with threaded previews going */ WM_jobs_stop_all(CTX_wm_manager(C)); strcpy(scestr, G.sce); /* temporal store */ + strcpy(mainstr, G.main->name); /* temporal store */ + fileflags= G.fileflags; G.fileflags |= G_FILE_NO_UI; @@ -476,7 +479,8 @@ static int read_undosave(bContext *C, UndoElem *uel) success= BKE_read_file_from_memfile(C, &uel->memfile, NULL); /* restore */ - strcpy(G.sce, scestr); + strcpy(G.sce, scestr); /* restore */ + strcpy(G.main->name, mainstr); /* restore */ G.fileflags= fileflags; if(success) -- cgit v1.2.3 From 134e2f001c022129eccbc19b87c48476f547bdb8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Aug 2010 08:57:42 +0000 Subject: bugfix [#23495] unable to pack file, source path not found: "" --- source/blender/blenkernel/intern/packedFile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index b01f570898e..919a724d1ec 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -220,7 +220,7 @@ void packAll(Main *bmain, ReportList *reports) ima->packedfile = newPackedFile(reports, ima->name); for(vf=bmain->vfont.first; vf; vf=vf->id.next) - if(vf->packedfile == NULL && vf->id.lib==NULL) + if(vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, "") != 0) vf->packedfile = newPackedFile(reports, vf->name); for(sound=bmain->sound.first; sound; sound=sound->id.next) -- cgit v1.2.3 From 0edde88d7af6df27412d945a25096ed117a90416 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 25 Aug 2010 16:01:30 +0000 Subject: Fix #23461 and #23474: revision 31517 to simplify code made undo work incorrect, BLI_findstring doesn't work when you need to loop over the list backwards. --- source/blender/blenkernel/intern/blender.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index a4f44dd0a48..052c1851343 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -645,7 +645,11 @@ 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= BLI_findstring(&undobase, name, offsetof(UndoElem, name)); + UndoElem *uel; + + for(uel= undobase.last; uel; uel= uel->prev) + if(strcmp(name, uel->name)==0) + break; if(uel && uel->prev) { curundo= uel->prev; -- cgit v1.2.3 From ea3be03743c8e066b2ef2ffff8f38371ea553fd3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 26 Aug 2010 23:30:15 +0000 Subject: ED_view3d_draw_offscreen_imbuf_simple and ED_view3d_draw_offscreen_imbuf now accept the imbuf flag so they can get the float buffer from opengl directly. --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 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 b20bb111cb4..b6bb5c3a51b 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(bmain, seq->scene, seq->scene->lay); - ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, + ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, IB_rect, scene->r.seq_prev_type); } else { -- cgit v1.2.3 From df4dd70d7bc1f60cb9ea5bbb2da4f0319f6f55b5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 30 Aug 2010 08:28:48 +0000 Subject: various utf8 compatibility fixes - OBJ import/export now work with non utf8 paths. (all exporters and importers need changes like this) - strip non utf8 chars from new ID blocks (also applies to renaming) - set the file rename button to allow non-utf8 chars. --- source/blender/blenkernel/intern/library.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 8c8e4bb034f..64d9a23b6a6 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1185,8 +1185,15 @@ int new_id(ListBase *lb, ID *id, const char *tname) * easier to assign each time then to check if its needed */ name[sizeof(name)-1]= 0; - if(name[0] == '\0') + if(name[0] == '\0') { + /* disallow empty names */ strcpy(name, ID_FALLBACK_NAME); + } + else { + /* disallow non utf8 chars, + * the interface checks for this but new ID's based on file names dont */ + BLI_utf8_invalid_strip(name, strlen(name)); + } result = check_for_dupid(lb, id, name); strcpy(id->name+2, name); @@ -1377,8 +1384,9 @@ void text_idbutton(struct ID *id, char *text) text[4]= 0; } } - else - strcpy(text, ""); + else { + text[0]= '\0'; + } } void rename_id(ID *id, char *name) -- cgit v1.2.3 From 26da3cb99f5f90e895c599902fa77aecc826a2c3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 31 Aug 2010 14:22:00 +0000 Subject: patch [#23585] Fix for [#23553] in File Selector; Multiple Calls of Selector from Alexander Kuznetsov (alexk) bugfix for [#23553] F2 on filebrowser = bug? from the tracker --- snip File Explorer redraws weirdly on second press of F2 if non-default view or file types were selected previously. This patch prohibits second call of file selector in the same window. The bug goes much deeper. If file selector is never closed properly (cancel or select), it never gets released. (at least the handler). If you press F2 or Ctrl-F3 ten times and than "Back to Previous" and repeat all of this several times Blender will freeze. Also after calling file selector at least two times, on cancellation Blender will return to full area independently to what state it was before. --- include small unrelated change to quiet unpack prints when fonts are not found. --- source/blender/blenkernel/intern/font.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 39b74be3d40..c0a60ea6294 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -265,13 +265,11 @@ static PackedFile *get_builtin_packedfile(void) void free_ttfont(void) { struct TmpFont *tf; - - tf= ttfdata.first; - while(tf) { - freePackedFile(tf->pf); + + for(tf= ttfdata.first; tf; tf= tf->next) { + if(tf->pf) freePackedFile(tf->pf); /* NULL when the font file can't be found on disk */ tf->pf= NULL; tf->vfont= NULL; - tf= tf->next; } BLI_freelistN(&ttfdata); } -- cgit v1.2.3 From 41a49a6bc92680cc97872ddf72420756e6ea06c8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 31 Aug 2010 14:56:14 +0000 Subject: simple NULL check to fix a crash when running in background mode --- source/blender/blenkernel/intern/blender.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 052c1851343..d120b42a286 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -231,7 +231,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) curscene= bfd->curscene; if(curscene==NULL) curscene= bfd->main->scene.first; /* and we enforce curscene to be in current screen */ - curscreen->scene= curscene; + if(curscreen) curscreen->scene= curscene; /* can run in bgmode */ /* clear_global will free G.main, here we can still restore pointers */ lib_link_screen_restore(bfd->main, curscreen, curscene); -- cgit v1.2.3 From e5b9ad3817a348cd8e34e073dd0f0497f8d58b1d Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Wed, 1 Sep 2010 08:09:23 +0000 Subject: Added missing ID_NEW() in set_sca_new_poins_ob() as pointed out by Dalai. --- source/blender/blenkernel/intern/sca.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index f5ca7ee3cef..12f82d041f9 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -572,9 +572,22 @@ void set_sca_new_poins_ob(Object *ob) bObjectActuator *oa= act->data; ID_NEW(oa->reference); } - else if(act->type==ACT_SCENE) { - bSceneActuator *sca= act->data; - ID_NEW(sca->camera); + else if(act->type==ACT_MESSAGE) { + bMessageActuator *ma= act->data; + ID_NEW(ma->toObject); + } + else if(act->type==ACT_PARENT) { + bParentActuator *para = act->data; + ID_NEW(para->ob); + } + else if(act->type==ACT_ARMATURE) { + bArmatureActuator *aa = act->data; + ID_NEW(aa->target); + ID_NEW(aa->subtarget); + } + else if(act->type==ACT_PROPERTY) { + bPropertyActuator *pa= act->data; + ID_NEW(pa->ob); } } act= act->next; -- cgit v1.2.3 From e50bdef6833f36d4671ec946500d360b34ea95d1 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 1 Sep 2010 09:47:19 +0000 Subject: Fix for [#23596] Particle Harmonics cache problem * Non-dynamic particles weren't reset properly because they don't use pointcache --- source/blender/blenkernel/intern/particle_system.c | 4 ++++ 1 file changed, 4 insertions(+) (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 cfbab609f37..6eb86a7be87 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4035,6 +4035,10 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) { PARTICLE_P; + /* Particles without dynamics haven't been reset yet because they don't use pointcache */ + if(psys->recalc & PSYS_RECALC_RESET) + psys_reset(psys, PSYS_RESET_ALL); + if(emit_particles(&sim, NULL, cfra)) { free_keyed_keys(psys); distribute_particles(&sim, part->from); -- cgit v1.2.3 From ddbfb05c84d1b20df82d8b1264d897dd55006695 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Sep 2010 04:53:05 +0000 Subject: rna context rename * context.main & bpy.types.Main --> context.blend_data & bpy.types.BlendData * context.manager --> context.window_manager --- source/blender/blenkernel/intern/context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 24dcb4c5846..7928424e47c 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -701,7 +701,7 @@ Main *CTX_data_main(const bContext *C) { Main *bmain; - if(ctx_data_pointer_verify(C, "main", (void*)&bmain)) + if(ctx_data_pointer_verify(C, "blend_data", (void*)&bmain)) return bmain; else return C->data.main; -- cgit v1.2.3 From b75eeac6bd618e7aad7f29f25f47105a884dd8c9 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 2 Sep 2010 05:37:54 +0000 Subject: Fix for [#23274] curve guide force particles to born at the wolrd's origine * Particle emitter location wasn't taken into account properly --- source/blender/blenkernel/intern/particle.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 681c48b0cf8..356f44dd757 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2009,6 +2009,10 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) LOOP_PARTICLES { psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,state.co,0,0,0,0,0); + + mul_m4_v3(sim->ob->obmat, state.co); + mul_mat3_m4_v3(sim->ob->obmat, state.vel); + pd_point_from_particle(sim, pa, &state, &point); for(eff = effectors->first; eff; eff=eff->next) { -- cgit v1.2.3 From d172001ceef06c0479131b33f15a5e9e46251472 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 2 Sep 2010 05:51:02 +0000 Subject: [#23462] Hair display affects rendered quantity --- source/blender/blenkernel/intern/particle.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 356f44dd757..9c3a1597dd9 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -709,6 +709,10 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float data->timeoffset= timeoffset; psys->renderdata= data; + + /* Hair can and has to be recalculated if everything isn't displayed. */ + if(psys->part->disp != 100 && psys->part->type == PART_HAIR) + psys->recalc |= PSYS_RECALC_RESET; } void psys_render_restore(Object *ob, ParticleSystem *psys) -- cgit v1.2.3 From 35535c2cb9dce98dc9eb7dec7337cce40ad6d9d9 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 2 Sep 2010 06:58:54 +0000 Subject: Fix for [#23136] Particle display percentage "forgotten" after render * The actual problem was that the total amount of particles was rendered at all, since only the displayed percentage was calculated correctly. * New behavior is that before baking (baking is always done for full % of particles) the display % is used for rendering too for dynamic particles. * Also added a warning below the display % slider to inform about the situation. --- source/blender/blenkernel/intern/particle_system.c | 28 +++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) (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 6eb86a7be87..fb0282c860b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -106,19 +106,25 @@ /* Reacting to system events */ /************************************************/ -static int get_current_display_percentage(ParticleSystem *psys) +static int particles_are_dynamic(ParticleSystem *psys) { + if(psys->pointcache->flag & PTCACHE_BAKED) + return 0; + + if(psys->part->type == PART_HAIR) + return psys->flag & PSYS_HAIR_DYNAMICS; + else + return ELEM3(psys->part->phystype, PART_PHYS_NEWTON, PART_PHYS_BOIDS, PART_PHYS_FLUID); +} +int psys_get_current_display_percentage(ParticleSystem *psys) { ParticleSettings *part=psys->part; - if(psys->renderdata || (part->child_nbr && part->childtype) - || (psys->pointcache->flag & PTCACHE_BAKING)) + if((psys->renderdata && !particles_are_dynamic(psys)) /* non-dynamic particles can be rendered fully */ + || (part->child_nbr && part->childtype) /* display percentage applies to children */ + || (psys->pointcache->flag & PTCACHE_BAKING)) /* baking is always done with full amount */ return 100; - if(part->phystype==PART_PHYS_KEYED){ - return psys->part->disp; - } - else - return psys->part->disp; + return psys->part->disp; } void psys_reset(ParticleSystem *psys, int mode) @@ -3250,7 +3256,7 @@ static void hair_step(ParticleSimulationData *sim, float cfra) ParticleSystem *psys = sim->psys; /* ParticleSettings *part = psys->part; */ PARTICLE_P; - float disp = (float)get_current_display_percentage(psys)/100.0f; + float disp = (float)psys_get_current_display_percentage(psys)/100.0f; BLI_srandom(psys->seed); @@ -3518,7 +3524,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra) psys_update_effectors(sim); - disp= (float)get_current_display_percentage(psys)/100.0f; + disp= (float)psys_get_current_display_percentage(psys)/100.0f; LOOP_PARTICLES { pa->size = part->size; @@ -3785,7 +3791,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) /* 3. do dynamics */ /* set particles to be not calculated TODO: can't work with pointcache */ - disp= (float)get_current_display_percentage(psys)/100.0f; + disp= (float)psys_get_current_display_percentage(psys)/100.0f; BLI_srandom(psys->seed); LOOP_PARTICLES { -- cgit v1.2.3 From b2ae9d825c96ed73d2396b8da6e0c019a6384ff7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 2 Sep 2010 07:00:34 +0000 Subject: - inconsistent rna names - use 'vertex_group_' as prefix, only ui scripts used this - change curve offset to be 0.0 for its rest/default value (not 1.0) --- source/blender/blenkernel/intern/material.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 9774e97f69b..e6cf0beb861 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -453,7 +453,7 @@ Material *give_current_material(Object *ob, int act) } else { /* in data */ - /* check for inconsistancy */ + /* check for inconsistency */ if(*totcolp < ob->totcol) ob->totcol= *totcolp; if(act>ob->totcol) act= ob->totcol; -- cgit v1.2.3 From 18954a711fc920da3933e71d7705f07337fd13eb Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 2 Sep 2010 07:24:38 +0000 Subject: Fix for [#22329] Particles won't render when display mode is different --- 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 b43cf72b94b..e2dbae92d5c 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2553,7 +2553,7 @@ void object_handle_update(Scene *scene, Object *ob) while(psys) { if(psys_check_enabled(ob, psys)) { /* check use of dupli objects here */ - if(psys->part && psys->part->draw_as == PART_DRAW_REND && + if(psys->part && (psys->part->draw_as == PART_DRAW_REND || G.rendering) && ((psys->part->ren_as == PART_DRAW_OB && psys->part->dup_ob) || (psys->part->ren_as == PART_DRAW_GR && psys->part->dup_group))) ob->transflag |= OB_DUPLIPARTS; -- cgit v1.2.3 From 5db18d474fa2c8b7176806368e5bc0aa68fef325 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 2 Sep 2010 08:06:53 +0000 Subject: "Fix" for [#23621] lattice modifier on particle hair when applied doesn't apply it to the hair * Although not strictly a bug it is the expected behavior and won't mess anything else up. * Note: the lattice is applied to the actual hair keys instead of the calculated strands so the applied result will differ a bit from the original. --- source/blender/blenkernel/intern/particle.c | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 9c3a1597dd9..45662bfbd42 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4431,3 +4431,34 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] VECADDFAC(center, center, yvec, bb->offset[1]); } + +void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) { + ParticleSimulationData sim = {scene, ob, psys, psys_get_modifier(ob, psys)}; + + psys->lattice = psys_get_lattice(&sim); + + if(psys->lattice) { + ParticleData *pa = psys->particles; + HairKey *hkey; + int p, h; + float hairmat[4][4], imat[4][4]; + + for(p=0; ptotpart; p++, pa++) { + psys_mat_hair_to_global(sim.ob, sim.psmd->dm, psys->part->from, pa, hairmat); + invert_m4_m4(imat, hairmat); + + hkey = pa->hair; + for(h=0; htotkey; h++, hkey++) { + mul_m4_v3(hairmat, hkey->co); + calc_latt_deform(psys->lattice, hkey->co, 1.0f); + mul_m4_v3(imat, hkey->co); + } + } + + end_latt_deform(psys->lattice); + psys->lattice= NULL; + + /* protect the applied shape */ + psys->flag |= PSYS_EDITED; + } +} \ No newline at end of file -- cgit v1.2.3 From 2e61c4be9b7d6ec49ac1cb4d1cf4716581fdc969 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 2 Sep 2010 09:11:40 +0000 Subject: Possible fix for [#23334] Particle Mode - Weight editing crashes if large number of particles OR you have added in Particle Mode --- source/blender/blenkernel/intern/particle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 45662bfbd42..a27097f836c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3172,7 +3172,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* at the moment this is only used for weight painting. * will need to move out of this check if its used elsewhere. */ - t2 = birthtime + ((float)(k+1)/(float)steps) * (dietime - birthtime); + t2 = birthtime + ((float)k/(float)steps) * (dietime - birthtime); while (pind.hkey[1]->time < t2) pind.hkey[1]++; pind.hkey[0] = pind.hkey[1] - 1; -- cgit v1.2.3 From f611fa80afc7356fee32a190c426a3f3b2e5f4c8 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 2 Sep 2010 10:26:19 +0000 Subject: Fix for [#23298] Kill particle breaks when baking simulation * Cached particle die times are now read from cached data --- source/blender/blenkernel/intern/particle.c | 18 ++++++++++++++++++ source/blender/blenkernel/intern/particle_system.c | 6 ++++++ 2 files changed, 24 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a27097f836c..a72e44df205 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1121,6 +1121,24 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float return ret == 2; } + +float psys_get_dietime_from_cache(PointCache *cache, int index) { + PTCacheMem *pm; + int dietime = 10000000; /* some max value so that we can default to pa->time+lifetime */ + + for(pm=cache->mem_cache.last; pm; pm=pm->prev) { + if(pm->index_array) { + if(pm->index_array[index]) + return (float)pm->frame; + } + else { + return (float)pm->frame; + } + } + + return (float)dietime; +} + static void init_particle_interpolation(Object *ob, ParticleSystem *psys, ParticleData *pa, ParticleInterpolationData *pind) { diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index fb0282c860b..2cf1e4ca00c 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1983,6 +1983,12 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, pa->dietime = pa->time + pa->lifetime; + if(sim->psys->pointcache && sim->psys->pointcache->flag & PTCACHE_BAKED && + sim->psys->pointcache->mem_cache.first) { + float dietime = psys_get_dietime_from_cache(sim->psys->pointcache, p); + pa->dietime = MIN2(pa->dietime, dietime); + } + if(pa->time > cfra) pa->alive = PARS_UNBORN; else if(pa->dietime <= cfra) -- cgit v1.2.3 From a8269c89469c6d79e882d247097270f3e281d253 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Fri, 3 Sep 2010 03:30:20 +0000 Subject: SVN maintenance. --- source/blender/blenkernel/intern/particle.c | 2 +- source/blender/blenkernel/intern/report.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a72e44df205..94a316a2c94 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4479,4 +4479,4 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) { /* protect the applied shape */ psys->flag |= PSYS_EDITED; } -} \ No newline at end of file +} diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index 173c6c136f2..3773757f5d5 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -273,4 +273,4 @@ Report *BKE_reports_last_displayable(ReportList *reports) } return NULL; -} \ No newline at end of file +} -- cgit v1.2.3 From 1642cb2a80e25eb0c70c514cef5086063f4665dd Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 3 Sep 2010 05:54:09 +0000 Subject: Fix for [#22147] Particle system, fight boids bug (dead particle) --- source/blender/blenkernel/intern/boids.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 7ae65d0113a..54ffda6c0a9 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -910,6 +910,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) if(bpa->data.health <= 0.0f) { pa->alive = PARS_DYING; + pa->dietime = bbd->cfra; return; } -- cgit v1.2.3 From 9659d47d8bc4d19a6d391c604696a2a031838535 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 3 Sep 2010 06:12:40 +0000 Subject: Fix for [#23642] Particle system "Lifetime" setting does not animate --- source/blender/blenkernel/intern/particle_system.c | 35 ++++++++-------------- 1 file changed, 13 insertions(+), 22 deletions(-) (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 2cf1e4ca00c..626b7b1b4f5 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1573,8 +1573,6 @@ void initialize_particle(ParticleSimulationData *sim, ParticleData *pa, int p) /* TODO: needs some work to make most blendtypes generally usefull */ psys_get_texture(sim,ma,pa,&ptex,MAP_PA_INIT); } - - pa->lifetime= part->lifetime*ptex.life; if(part->type==PART_HAIR) pa->time= 0.0f; @@ -1590,25 +1588,6 @@ void initialize_particle(ParticleSimulationData *sim, ParticleData *pa, int p) pa->time= part->sta + (part->end - part->sta)*ptex.time; } - - if(part->type==PART_HAIR){ - pa->lifetime=100.0f; - } - else{ -#if 0 // XXX old animation system - icu=find_ipocurve(psys->part->ipo,PART_EMIT_LIFE); - if(icu){ - calc_icu(icu,100*ptex.time); - pa->lifetime*=icu->curval; - } -#endif // XXX old animation system - - if(part->randlife!=0.0) - pa->lifetime*= 1.0f - part->randlife * BLI_frand(); - } - - pa->dietime= pa->time+pa->lifetime; - if(part->type!=PART_HAIR && part->distr!=PART_DISTR_GRID && part->from != PART_FROM_VERT){ if(ptex.exist < BLI_frand()) pa->flag |= PARS_UNEXIST; @@ -1701,6 +1680,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, part=psys->part; ptex.ivel=1.0; + ptex.life=1.0; /* we need to get every random even if they're not used so that they don't effect eachother */ r_vel[0] = 2.0f * (PSYS_FRAND(p + 10) - 0.5f); @@ -1758,7 +1738,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0); /* get possible textural influence */ - psys_get_texture(sim, give_current_material(sim->ob,part->omat), pa, &ptex, MAP_PA_IVEL); + psys_get_texture(sim, give_current_material(sim->ob,part->omat), pa, &ptex, MAP_PA_IVEL|MAP_PA_LIFE); //if(vg_vel && pa->num != -1) // ptex.ivel*=psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_vel); @@ -1981,6 +1961,17 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, } } + + if(part->type == PART_HAIR){ + pa->lifetime = 100.0f; + } + else{ + pa->lifetime = part->lifetime*ptex.life; + + if(part->randlife != 0.0) + pa->lifetime *= 1.0f - part->randlife * PSYS_FRAND(p + 21); + } + pa->dietime = pa->time + pa->lifetime; if(sim->psys->pointcache && sim->psys->pointcache->flag & PTCACHE_BAKED && -- cgit v1.2.3 From 870469ec0e49f47b61fe9bda27c4b11fdd955d6b Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 3 Sep 2010 06:18:23 +0000 Subject: Fix for [#19950] Object Particles and texture controlled density * The hair strands that were cut based on the texture weren't properly checked for in the duplication code. --- source/blender/blenkernel/intern/anim.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index e27e3b2cd3f..4b9ffb1e374 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1285,6 +1285,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p size = psys_get_child_size(psys, cpa, ctime, 0); } + /* some hair paths might be non-existent so they can't be used for duplication */ + if(hair && + ((a < totpart && psys->pathcache[a]->steps < 0) || + (a >= totpart && psys->childcache[a-totpart]->steps < 0))) + continue; + if(part->ren_as==PART_DRAW_GR) { /* for groups, pick the object based on settings */ if(part->draw&PART_DRAW_RAND_GR) -- cgit v1.2.3 From d0c54d3d0e77f0ed6b73ed5c3ac100ebd5e58660 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Sep 2010 07:25:37 +0000 Subject: use set as a suffix (matches operators) - set_frame() --> frame_set() - set_context_pointer() --> context_pointer_set() material adding works for curves and metaballs, new function to remove materials. materials.link() didnt well fit how this is used elsewhere - order matters - it can be linked more than once. - remove(material), isnt that useful since you need to manage indicies. ... use list style functions instead. materials.append(mat) / materials.pop(index) --- source/blender/blenkernel/intern/material.c | 84 +++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index e6cf0beb861..beffd542427 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -434,6 +434,90 @@ short *give_totcolp(Object *ob) return NULL; } +/* same as above but for ID's */ +Material ***give_matarar_id(ID *id) +{ + switch(GS(id->name)) { + case ID_ME: + return &(((Mesh *)id)->mat); + break; + case ID_CU: + return &(((Curve *)id)->mat); + break; + case ID_MB: + return &(((Curve *)id)->mat); + break; + } + return NULL; +} + +short *give_totcolp_id(ID *id) +{ + switch(GS(id->name)) { + case ID_ME: + return &(((Mesh *)id)->totcol); + break; + case ID_CU: + return &(((Curve *)id)->totcol); + break; + case ID_MB: + return &(((Curve *)id)->totcol); + break; + } + return NULL; +} + +void material_append_id(ID *id, Material *ma) +{ + Material ***matar; + if((matar= give_matarar_id(id))) { + short *totcol= give_totcolp_id(id); + Material **mat= MEM_callocN(sizeof(void *) * (*totcol) + 1, "newmatar"); + if(*totcol) memcpy(mat, *matar, sizeof(void *) * (*totcol)); + if(*matar) MEM_freeN(*matar); + + *matar= mat; + (*matar)[(*totcol)++]= ma; + + id_us_plus((ID *)ma); + test_object_materials(id); + } +} + +Material *material_pop_id(ID *id, int index) +{ + Material *ret= NULL; + Material ***matar; + if((matar= give_matarar_id(id))) { + short *totcol= give_totcolp_id(id); + if(index >= 0 && index < (*totcol)) { + ret= (*matar)[index]; + if(*totcol <= 1) { + *totcol= 0; + MEM_freeN(*matar); + *matar= NULL; + } + else { + Material **mat; + + if(index + 1 != (*totcol)) + memmove((*matar), (*matar) + 1, (*totcol) - (index + 1)); + + (*totcol)--; + + mat= MEM_callocN(sizeof(void *) * (*totcol), "newmatar"); + memcpy(mat, *matar, sizeof(void *) * (*totcol)); + MEM_freeN(*matar); + + *matar= mat; + test_object_materials(id); + } + } + } + + return ret; +} + Material *give_current_material(Object *ob, int act) { Material ***matarar, *ma; -- cgit v1.2.3 From d89d724c461a30a052c55ac9c6ab9616e6cc61c7 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 3 Sep 2010 07:47:10 +0000 Subject: Fix for [#22387] Collider stickiness seems to have broke * Note that this fix might slightly change the simulation results of some files that use the stickiness value, but lowering the value should fix these issues. --- 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 626b7b1b4f5..dbe982c48e0 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3055,7 +3055,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* Stickness to surface */ normalize_v3(nor_vec); - madd_v3_v3fl(pa->state.vel, nor_vec, -pd->pdef_stickness); + madd_v3_v3fl(pa->state.vel, col.nor, -pd->pdef_stickness); } col.t = dt; -- cgit v1.2.3 From 0cf0f5a62225f9f9cc2ed9715274e94dc09ad8b0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Sep 2010 14:53:54 +0000 Subject: rna api - move: material.add_texture(tex, coords, mapto) --> material.texture_slots.add() - added material.texture_slots.create(index), material.texture_slots.clear(index) - texture slot functions also work for lamp and world now. Other minor changes - allow rna functions to set FUNC_NO_SELF and FUNC_USE_SELF_ID at once. - [#23317] Changed some operators' RNA to accept lengths, a modification I made to this patch made it not work as intended, removed this edit so unit buttons appier in the UI for certain operators. - Sphinx doc gen, 2 columns rather then 3, didnt quite fit in some cases. --- source/blender/blenkernel/intern/texture.c | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 9075c64d286..77416f4dd12 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -689,6 +689,49 @@ MTex *add_mtex() return mtex; } +/* slot -1 for first free ID */ +MTex *add_mtex_id(ID *id, int slot) +{ + MTex **mtex_ar; + short act; + + give_active_mtex(id, &mtex_ar, &act); + + if(mtex_ar==NULL) { + return NULL; + } + + if(slot==-1) { + /* find first free */ + int i; + for (i= 0; i < MAX_MTEX; i++) { + if (!mtex_ar[i]) { + slot= i; + break; + } + } + if(slot == -1) { + return NULL; + } + } + else { + /* make sure slot is valid */ + if(slot < 0 || slot >= MAX_MTEX) { + return NULL; + } + } + + if (mtex_ar[slot]) { + id_us_min((ID *)mtex_ar[slot]->tex); + MEM_freeN(mtex_ar[slot]); + mtex_ar[slot]= NULL; + } + + mtex_ar[slot]= add_mtex(); + + return mtex_ar[slot]; +} + /* ------------------------------------------------------------------------- */ Tex *copy_texture(Tex *tex) -- cgit v1.2.3 From 31331fb61d21de7df0066b2f51bc9906c95fc332 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Sep 2010 16:23:31 +0000 Subject: error with allocating memory for a new material array (own fault in recent commit) --- source/blender/blenkernel/intern/material.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index beffd542427..7e52f746ebc 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -472,7 +472,7 @@ void material_append_id(ID *id, Material *ma) Material ***matar; if((matar= give_matarar_id(id))) { short *totcol= give_totcolp_id(id); - Material **mat= MEM_callocN(sizeof(void *) * (*totcol) + 1, "newmatar"); + Material **mat= MEM_callocN(sizeof(void *) * ((*totcol) + 1), "newmatar"); if(*totcol) memcpy(mat, *matar, sizeof(void *) * (*totcol)); if(*matar) MEM_freeN(*matar); -- cgit v1.2.3 From a436adf26d1a31ac89acc7fa316a40b36bbe75b6 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 6 Sep 2010 10:35:32 +0000 Subject: Fix for [#23028] Driver gets remapped when importing 2.49 file * Rotation drivers weren't converted properly from ipos to fcurves. --- source/blender/blenkernel/intern/ipo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index a24f37bf73a..5c0c0fbf0c1 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1301,13 +1301,14 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* correct times for rotation drivers * - need to go from degrees to radians... * - there's only really 1 target to worry about + * - were also degrees/10 */ if (fcu->driver && fcu->driver->variables.first) { DriverVar *dvar= fcu->driver->variables.first; DriverTarget *dtar= &dvar->targets[0]; if (ELEM3(dtar->transChan, DTAR_TRANSCHAN_ROTX, DTAR_TRANSCHAN_ROTY, DTAR_TRANSCHAN_ROTZ)) { - const float fac= (float)M_PI / 180.0f; + const float fac= (float)M_PI / 18.0f; dst->vec[0][0] *= fac; dst->vec[1][0] *= fac; -- cgit v1.2.3 From 629c19ff87c5a456ed3ee9f2c79bf358cbb91478 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 6 Sep 2010 11:29:23 +0000 Subject: bugfix [#23593] using material_slot.material=material_slot.material.copy() causes inescapable loop and blender to hang --- 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 64d9a23b6a6..834e7de5811 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1146,7 +1146,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) /* this would overflow name buffer */ left[16] = 0; /* left_len = 16; */ /* for now this isnt used again */ - memcpy(name, left, sizeof(char) * 16); + memcpy(name, left, sizeof(char) * 17); continue; } /* this format specifier is from hell... */ -- cgit v1.2.3 From 2ffa9e1309bbdacc75d4fc73d5d4df0b92ce4aff Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Tue, 7 Sep 2010 03:02:03 +0000 Subject: == Sculpt == Fixed bug #23654 Brush copy clears its preview, so that the copied brush's icon isn't linked to the old brush --- 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 71a43994363..90ea562be9d 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -147,6 +147,8 @@ Brush *copy_brush(Brush *brush) if (brush->icon_imbuf) brushn->icon_imbuf= IMB_dupImBuf(brush->icon_imbuf); + brushn->preview = NULL; + brushn->curve= curvemapping_copy(brush->curve); /* enable fake user by default */ -- cgit v1.2.3 From f0fe8a559da30900422dc77c2d0ebaf267eba90b Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 8 Sep 2010 11:08:34 +0000 Subject: Partial fix for [#23714] Linked instance group with particles doesn't render properly * Only partial because rendering of dupliobjects / groups with particles isn't yet fully implemented --- source/blender/blenkernel/intern/particle_system.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (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 dbe982c48e0..0d14c3cb9f6 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4077,7 +4077,8 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) psys->cfra = cfra; psys->recalc = 0; - /* save matrix for duplicators */ - invert_m4_m4(psys->imat, ob->obmat); + /* save matrix for duplicators, at rendertime the actual dupliobject's matrix is used so don't update! */ + if(psys->renderdata==0) + invert_m4_m4(psys->imat, ob->obmat); } -- cgit v1.2.3 From 4eaa10aa02994c4609e1c12e38d0eda6355f9077 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 9 Sep 2010 00:14:51 +0000 Subject: == Multires == Fixed bug #23657, "Modifiers dosen't work when you select diffrent mesh for object" Multires modifier now adds empty mdisps if they're missing, rather than displaying a warning Switching an object's mesh will now check for a multires modifier; if found the modifier's total number of levels are reset to match the mesh's mdisps Switching the mesh also forces a multires update so that sculpted changes aren't lost --- source/blender/blenkernel/intern/mesh.c | 6 +++++ source/blender/blenkernel/intern/modifier.c | 17 +++++++++++++++ source/blender/blenkernel/intern/multires.c | 34 +++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 94131fdbe9d..2f8553b06b3 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -51,6 +51,8 @@ #include "BKE_displist.h" #include "BKE_library.h" #include "BKE_material.h" +#include "BKE_modifier.h" +#include "BKE_multires.h" #include "BKE_key.h" /* these 2 are only used by conversion functions */ #include "BKE_curve.h" @@ -492,6 +494,8 @@ Mesh *get_mesh(Object *ob) void set_mesh(Object *ob, Mesh *me) { Mesh *old=0; + + multires_force_update(ob); if(ob==0) return; @@ -504,6 +508,8 @@ void set_mesh(Object *ob, Mesh *me) } test_object_materials((ID *)me); + + test_object_modifiers(ob); } /* ************** make edges in a Mesh, for outside of editmode */ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 63f0f1fa091..43d26f26d1f 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -49,6 +49,7 @@ #include "BKE_bmesh.h" #include "BKE_cloth.h" #include "BKE_key.h" +#include "BKE_multires.h" #include "MOD_modifiertypes.h" @@ -526,5 +527,21 @@ void modifier_freeTemporaryData(ModifierData *md) } } +/* ensure modifier correctness when changing ob->data */ +void test_object_modifiers(Object *ob) +{ + ModifierData *md; + + /* just multires checked for now, since only multires + modifies mesh data */ + + if(ob->type != OB_MESH) return; + for(md = ob->modifiers.first; md; md = md->next) { + if(md->type == eModifierType_Multires) { + MultiresModifierData *mmd = (MultiresModifierData*)md; + multiresModifier_set_levels_from_disps(mmd, ob); + } + } +} diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 56d517f1e13..57f568e6094 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -275,6 +275,40 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm return result; } +/* reset the multires levels to match the number of mdisps */ +void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *ob) +{ + Mesh *me = ob->data; + MDisps *mdisp; + int i; + + mdisp = CustomData_get_layer(&me->fdata, CD_MDISPS); + + if(mdisp) { + for(i = 0; i < me->totface; ++i, ++mdisp) { + int S = me->mface[i].v4 ? 4 : 3; + + if(mdisp->totdisp == 0) continue; + + while(1) { + int side = (1 << (mmd->totlvl-1)) + 1; + int lvl_totdisp = side*side*S; + if(mdisp->totdisp == lvl_totdisp) + break; + else if(mdisp->totdisp < lvl_totdisp) + --mmd->totlvl; + else + ++mmd->totlvl; + + } + } + + mmd->lvl = MIN2(mmd->sculptlvl, mmd->totlvl); + mmd->sculptlvl = MIN2(mmd->sculptlvl, mmd->totlvl); + mmd->renderlvl = MIN2(mmd->renderlvl, mmd->totlvl); + } +} + static void multires_set_tot_mdisps(Mesh *me, int lvl) { MDisps *mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); -- cgit v1.2.3 From a755f9f7ede2e60afa964460e00f613790bf064e Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 9 Sep 2010 07:52:35 +0000 Subject: Fix for [#23734] Force Fields Min/Max don't work *Special case for planar vortex field --- source/blender/blenkernel/intern/effect.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 6f6d405dd90..05fcabd371f 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -667,10 +667,10 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin /* for vortex the shape chooses between old / new force */ if(eff->pd && eff->pd->shape == PFIELD_SHAPE_PLANE) { /* efd->loc is closes point on effector xy-plane */ - float temp[3]; + float temp[3], translate[3]; sub_v3_v3v3(temp, point->loc, ob->obmat[3]); - project_v3_v3v3(efd->loc, temp, efd->nor); - sub_v3_v3v3(efd->loc, point->loc, efd->loc); + project_v3_v3v3(translate, temp, efd->nor); + add_v3_v3v3(efd->loc, ob->obmat[3], translate); } else { VECCOPY(efd->loc, ob->obmat[3]); -- cgit v1.2.3 From 2dbb96b9722ac95420d4677e52b7acc9baaef7bc Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 9 Sep 2010 11:07:07 +0000 Subject: Partial fix for [#21948] Full sample motion blur with cloth - cloth and collision object render issue. * Now cloth reads cache using subframes when rendering. * Cloth cache also was reset every time on the start frame which kind of defeats the point of the caching. --- source/blender/blenkernel/intern/cloth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index bebfa4af88e..be1552a882d 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -446,7 +446,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, return dm; } - if(clmd->sim_parms->reset || (framenr == (startframe - clmd->sim_parms->preroll))) + if(clmd->sim_parms->reset || (framenr == (startframe - clmd->sim_parms->preroll) && clmd->sim_parms->preroll != 0)) { clmd->sim_parms->reset = 0; cache->flag |= PTCACHE_OUTDATED; @@ -512,7 +512,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, } /* try to read from cache */ - cache_result = BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec); + cache_result = BKE_ptcache_read_cache(&pid, (float)framenr+scene->r.subframe, scene->r.frs_sec); if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { implicit_set_positions(clmd); -- cgit v1.2.3 From b6a36a3b894a08d254df9b27faa111f6ba6e8d6a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 12 Sep 2010 14:46:41 +0000 Subject: silance compiler warning. --- 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 4d58ec8212a..487ec78b2bd 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) << 6; + rval ^= ((intptr_t) key->seq) << 6; return rval; } -- cgit v1.2.3 From bd5a62cfcb7ddf4a6c111eede3d4a496902138ee Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 13 Sep 2010 06:08:26 +0000 Subject: bugfix [#23068] Image editor: Update Automatically not updating the compositor. [#23637] Replacing an image used in the compositor crashes [#23343] changes in images doesn't update compositor image nodes --- source/blender/blenkernel/intern/image.c | 12 ++++++++++++ source/blender/blenkernel/intern/node.c | 15 +++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 0e282aa6449..e77183d785f 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -69,6 +69,7 @@ #include "BKE_main.h" #include "BKE_packedFile.h" #include "BKE_scene.h" +#include "BKE_node.h" //XXX #include "BIF_editseq.h" @@ -1447,6 +1448,17 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) } break; } + + /* dont use notifiers because they are not 100% sure to succseed + * this also makes sure all scenes are accounted for. */ + { + Scene *scene; + for(scene= G.main->scene.first; scene; scene= scene->id.next) { + if(scene->nodetree) { + NodeTagIDChanged(scene->nodetree, &ima->id); + } + } + } } /* if layer or pass changes, we need an index for the imbufs list */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 5af2c64da18..135ddbab2b7 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1787,18 +1787,25 @@ void NodeTagChanged(bNodeTree *ntree, bNode *node) } } -void NodeTagIDChanged(bNodeTree *ntree, ID *id) +int NodeTagIDChanged(bNodeTree *ntree, ID *id) { + int change = FALSE; + if(id==NULL) - return; + return change; if(ntree->type==NTREE_COMPOSIT) { bNode *node; - for(node= ntree->nodes.first; node; node= node->next) - if(node->id==id) + for(node= ntree->nodes.first; node; node= node->next) { + if(node->id==id) { + change= TRUE; NodeTagChanged(ntree, node); + } + } } + + return change; } -- cgit v1.2.3 From 74f060bfe5d57ae784dcc9bf7e6c9a565875cdb2 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 13 Sep 2010 11:14:12 +0000 Subject: Fix for [#23729] Smoke / Edit Mode bug --- 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 11012843131..d2d8d5a6e07 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1350,7 +1350,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(framenr > endframe) return; - if(!smd->domain->fluid && (framenr != startframe)) + if(!smd->domain->fluid && (framenr != startframe) && (cache->flag & PTCACHE_BAKED)==0) return; // printf("startframe: %d, framenr: %d\n", startframe, framenr); -- cgit v1.2.3 From ba2a9ae88ec3dd70bfd9ed7099789d0d5befe407 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Mon, 13 Sep 2010 12:56:39 +0000 Subject: Fix [#22612] FFMPEG writes incorrect Xvid FourCC code Reported by Karl Nyman When XVID is chosen for FFMPEG make sure that XVID is written for FourCC code. --- source/blender/blenkernel/intern/writeffmpeg.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 8ebf98ef930..6cd207f628c 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -515,6 +515,7 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex if (codec_id == CODEC_ID_XVID) { /* arghhhh ... */ c->pix_fmt = PIX_FMT_YUV420P; + c->codec_tag = (('D'<<24) + ('I'<<16) + ('V'<<8) + 'X'); } if (codec_id == CODEC_ID_H264) { -- cgit v1.2.3 From ca940016e17273d9b32b6b8717fee972de696979 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 14 Sep 2010 01:43:46 +0000 Subject: Fix for [#20350] particles are offset from emittor in dupli-objects --- source/blender/blenkernel/intern/anim.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 4b9ffb1e374..98bdf3b2e9f 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1357,19 +1357,25 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p VECCOPY(vec, obmat[3]); obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f; - copy_m4_m4(mat, pamat); + /* Normal particles and cached hair live in global space so we need to + * remove the real emitter's transformation before 2nd order duplication. + */ + if(par_space_mat) + mul_m4_m4m4(mat, pamat, psys->imat); + else + copy_m4_m4(mat, pamat); mul_m4_m4m4(tmat, obmat, mat); mul_mat3_m4_fl(tmat, size*scale); - if(part->draw & PART_DRAW_GLOBAL_OB) - VECADD(tmat[3], tmat[3], vec); - if(par_space_mat) mul_m4_m4m4(mat, tmat, par_space_mat); else copy_m4_m4(mat, tmat); + if(part->draw & PART_DRAW_GLOBAL_OB) + VECADD(mat[3], mat[3], vec); + dob= new_dupli_object(lb, ob, mat, ob->lay, counter, OB_DUPLIPARTS, animated); copy_m4_m4(dob->omat, oldobmat); if(G.rendering) -- cgit v1.2.3 From 7245177c26bc6630ce6dd505b6065a2f2c4b4a71 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 14 Sep 2010 01:47:01 +0000 Subject: Fix for a particles memory leak: * Hair wasn't freed properly when changing particles from hair to normal particles. --- source/blender/blenkernel/intern/particle.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 94a316a2c94..07b712c4330 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -384,9 +384,6 @@ void free_hair(Object *ob, ParticleSystem *psys, int dynamics) { PARTICLE_P; - if(psys->part->type != PART_HAIR) - return; - LOOP_PARTICLES { if(pa->hair) MEM_freeN(pa->hair); -- cgit v1.2.3 From baadd70ea1cd2d258dcd38c1b87117a72a5b81ba Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 14 Sep 2010 12:17:09 +0000 Subject: Fix for [#23794] Particle System + FS Motion Blur corrupts some frames and possibly cache --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index a35e40d7cf7..741580048cf 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1454,7 +1454,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) if(!pm && !pf) { if(pid->cache->flag & PTCACHE_DISK_CACHE) { pf=NULL; - while(cfrai > pid->cache->startframe && !pf) { + while(cfrai >= pid->cache->startframe && !pf) { cfrai--; pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); cfra1 = cfrai; -- cgit v1.2.3 From 7eb74100023c6d4423b3f678d82f978e7ce43def Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Sep 2010 05:57:48 +0000 Subject: remove inventor and vrml1 support, we're better of having these legacy formats as addons. --- source/blender/blenkernel/intern/exotic.c | 1685 +---------------------------- 1 file changed, 2 insertions(+), 1683 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index cdefbb54ecf..bd001649bf5 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -449,1328 +449,10 @@ static void read_stl_mesh_ascii(Scene *scene, char *str) #undef STLREADLINE #undef STLREADVERT -/* ***************** INVENTOR ******************* */ - - -#define IV_MAXSTACK 3000000 -#define IV_MAXFIELD 10 -#define IV_MAXCOL 16 - -static float *iv_data_stack; -static float ivcolors[IV_MAXCOL][3]; -static Object *ivsurf; -static ListBase ivbase; - -struct IvNode { - struct IvNode *next, *prev; - char *nodename; - char *fieldname[IV_MAXFIELD]; - int datalen[IV_MAXFIELD]; - float *data[IV_MAXFIELD]; -}; - -static int iv_curcol=0; - -static int iv_colornumber(struct IvNode *iv) -{ - float *fp, fr = 0.0, fg = 0.0, fb = 0.0; - int a; - char *cp; - - /* search back to last material */ - while(iv) { - if( strcmp(iv->nodename, "Material")==0) { - fp= iv->data[0]; - if(fp==0) fp= iv->data[1]; - if(fp) { - fr= fp[0]; - fg= fp[1]; - fb= fp[2]; - } - break; - } - else if( strcmp(iv->nodename, "BaseColor")==0) { - fp= iv->data[0]; - fr= fp[0]; - fg= fp[1]; - fb= fp[2]; - break; - } - else if( strcmp(iv->nodename, "PackedColor")==0) { - cp= (char *)iv->data[0]; - fr= cp[3]/255.0f; - fg= cp[2]/255.0f; - fb= cp[1]/255.0f; - break; - } - iv= iv->prev; - - } - if(iv==0) return 0; - if(iv->datalen[0]<3) return 0; - - for(a=0; a=IV_MAXCOL) a= IV_MAXCOL-1; - iv_curcol= a+1; - ivcolors[a][0]= fr; - ivcolors[a][1]= fg; - ivcolors[a][2]= fb; - - return iv_curcol; -} - -static int iv_finddata(struct IvNode *iv, char *field, int fieldnr) -{ - /* search for "field", count data size and make datablock. return skipdata */ - float *fp; - int len, stackcount, skipdata=0; - char *cpa, terminator, str[64]; - intptr_t i; - - len= strlen(field); - - cpa= iv->nodename+1; - while( *cpa != '}' ) { - - if( *cpa == *field ) { - if( strncmp(cpa, field, len)==0 ) { - iv->fieldname[fieldnr]= cpa; - - /* read until first character */ - cpa+= len; - skipdata+= len; - *cpa= 0; - cpa++; - skipdata++; - - while( *cpa==32 || *cpa==13 || *cpa==10 || *cpa==9) cpa++; - if( *cpa=='[' ) { - terminator= ']'; - cpa++; - skipdata++; - } - else terminator= 13; - - stackcount= 0; - fp= iv_data_stack; - - while( *cpa!=terminator && *cpa != '}' ) { - - /* in fact, isdigit should include the dot and minus */ - if( (isdigit(*cpa) || *cpa=='.' || *cpa=='-') && (isspace(cpa[-1]) || cpa[-1]==0 || cpa[-1]==',') ) { - if(cpa[1]=='x') { - memcpy(str, cpa, 16); - str[16]= 0; - - sscanf(str, "%x", (int *)fp); - } - else { - /* atof doesn't stop after the first float - * in a long string at Windows... so we copy - * the float to a new string then atof... */ - char *cpa_temp = strpbrk(cpa, ", \n"); - i = cpa_temp - cpa; - - if (i>63) *fp= 0.0; - else { - memcpy(str, cpa, i); - str[i]=0; - - *fp= (float) atof(str); - } - } - - stackcount++; - if(stackcount>=IV_MAXSTACK) { - printf("stackoverflow in IV read\n"); - break; - } - fp++; - } - cpa++; - skipdata++; - } - - iv->datalen[fieldnr]= stackcount; - if(stackcount) { - iv->data[fieldnr]= MEM_mallocN(sizeof(float)*stackcount, "iv_finddata"); - memcpy(iv->data[fieldnr], iv_data_stack, sizeof(float)*stackcount); - } - else iv->data[fieldnr]= 0; - - return skipdata; - } - } - cpa++; - skipdata++; - } - - return skipdata; -} - -static void read_iv_index(float *data, float *baseadr, float *index, int nr, int coordtype) -{ - /* write in data: baseadr with offset index (and number nr) */ - float *fp; - int ofs; - - while(nr--) { - ofs= (int) *index; - fp= baseadr+coordtype*ofs; - VECCOPY(data, fp); - data+= 3; - index++; - } -} - - - -static void read_inventor(Scene *scene, char *str, struct ListBase *listb) -{ - struct IvNode *iv, *ivp, *ivn; - char *maindata, *md, *cpa; - float *index, *data, *fp; - int file, filelen, count, lll, face, nr = 0; - int skipdata, ok, a, b, tot, first, colnr, coordtype, polytype, *idata; - struct DispList *dl; - ReportList *reports= NULL; /* XXX */ - - ivbase.first= ivbase.last= 0; - iv_curcol= 0; - ivsurf= 0; - - file= open(str, O_BINARY|O_RDONLY); - if(file== -1) { - BKE_reportf(reports, RPT_ERROR, "Can't read file: %s.", strerror(errno)); - return; - } - - filelen= BLI_filesize(file); - if(filelen < 1) { - close(file); - return; - } - - maindata= MEM_mallocN(filelen, "leesInventor"); - if(read(file, maindata, filelen) < filelen) { - BKE_reportf(reports, RPT_ERROR, "Failed reading file: premature end of file."); - close(file); - return; - } - close(file); - - iv_data_stack= MEM_mallocN(sizeof(float)*IV_MAXSTACK, "ivstack"); - - /* preprocess: remove comments */ - md= maindata+20; - count= 20; - while(count=filelen) break; - } - } - md++; - count++; - } - - - /* now time to collect: which are the nodes and fields? */ - md= maindata; - count= 0; - while(count32 && *cpa<128) cpa--; - cpa++; - *md= 0; - - ok= 0; - skipdata= 0; - iv= MEM_callocN(sizeof(struct IvNode), "leesInventor"); - iv->nodename= cpa; - - if(strcmp(cpa, "Coordinate3")==0 || strcmp(cpa, "Coordinate4")==0) { - skipdata= iv_finddata(iv, "point", 0); - ok= 1; - } - else if(strcmp(cpa, "VertexProperty")==0) { - skipdata= iv_finddata(iv, "vertex", 0); - ok= 1; - } - else if(strcmp(cpa, "IndexedLineSet")==0) { - skipdata= iv_finddata(iv, "coordIndex", 0); - ok= 1; - } - else if(strcmp(cpa, "IndexedTriangleMesh")==0) { - skipdata= iv_finddata(iv, "coordIndex", 0); - ok= 1; - } - else if(strcmp(cpa, "IndexedFaceSet")==0) { - skipdata= iv_finddata(iv, "coordIndex", 0); - ok= 1; - } - else if(strcmp(cpa, "FaceSet")==0) { - skipdata= iv_finddata(iv, "numVertices", 0); - ok= 1; - } - else if(strcmp(cpa, "Material")==0) { - iv_finddata(iv, "diffuseColor", 0); - iv_finddata(iv, "ambientColor", 1); - ok= 1; - } - else if(strcmp(cpa, "BaseColor")==0) { - iv_finddata(iv, "rgb", 0); - ok= 1; - } - else if(strcmp(cpa, "PackedColor")==0) { - iv_finddata(iv, "rgba", 0); - ok= 1; - } - else if(strcmp(cpa, "QuadMesh")==0) { - iv_finddata(iv, "verticesPerColumn", 0); - iv_finddata(iv, "verticesPerRow", 1); - - ok= 1; - } - else if(strcmp(cpa, "IndexedTriangleStripSet")==0) { - skipdata= iv_finddata(iv, "coordIndex", 0); - ok= 1; - } - else if(strcmp(cpa, "TriangleStripSet")==0) { - skipdata= iv_finddata(iv, "numVertices", 0); - ok= 1; - } - else if(strcmp(cpa, "IndexedNurbsSurface")==0 || strcmp(cpa, "NurbsSurface")==0) { - iv_finddata(iv, "numUControlPoints", 0); - iv_finddata(iv, "numVControlPoints", 1); - iv_finddata(iv, "uKnotVector", 2); - iv_finddata(iv, "vKnotVector", 3); - ok= 1; - } - else { - /* to the end */ - while( *md != '}') { - md++; - count++; - if(countnext; - - if( strncmp(iv->nodename, "Indexed", 7)==0) { - /* seek back: same name? */ - - ivp= iv->prev; - while(ivp) { - if(strcmp(iv->nodename, ivp->nodename)==0) break; - - if(strcmp(ivp->nodename, "Coordinate3")==0 || - strcmp(ivp->nodename, "Coordinate4")==0 || - strcmp(ivp->nodename, "VertexProperty")==0) { - ivp= 0; - break; - } - ivp= ivp->prev; - } - - if(ivp) { - /* add iv to ivp */ - - tot= iv->datalen[0] + ivp->datalen[0]; - if(tot) { - data= MEM_mallocN(tot*sizeof(float), "samenvoeg iv"); - memcpy(data, ivp->data[0], sizeof(float)*ivp->datalen[0]); - memcpy(data+ivp->datalen[0], iv->data[0], sizeof(float)*iv->datalen[0]); - - ivp->datalen[0]+= iv->datalen[0]; - MEM_freeN(ivp->data[0]); - ivp->data[0]= data; - - BLI_remlink(&ivbase, iv); - MEM_freeN(iv->data[0]); - MEM_freeN(iv); - } - } - } - - iv= ivn; - } - - - /* convert Nodes to DispLists */ - iv= ivbase.first; - while(iv) { - - /* printf(" Node: %s\n", iv->nodename); */ - /* if(iv->fieldname[0]) printf(" Field: %s len %d\n", iv->fieldname[0], iv->datalen[0]); */ - coordtype= 3; - - if( strcmp(iv->nodename, "IndexedLineSet")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - if(ivp) { - - /* count the nr of lines */ - tot= 0; - index= iv->data[0]; - lll = iv->datalen[0]-1; - for(a=0; atype= DL_SEGM; - dl->nr= 2; - dl->parts= tot/2; - dl->col= colnr; - data= (float *)(dl+1); - - index= iv->data[0]; - for(a=0; adata[0], index, 2, coordtype); - data+= 6; - } - index++; - } - } - } - else if( strcmp(iv->nodename, "FaceSet")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - - if(ivp) { - /* count triangles */ - tot= 0; - - index= iv->data[0]; - polytype= (int) index[0]; - - for(a=0; adatalen[0]; a++) { - if(index[0]== polytype) tot++; /* one kind? */ - index++; - } - - - tot*= polytype; /* nr of vertices */ - dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor4"); - BLI_addtail(listb, dl); - dl->type= DL_POLY; - dl->nr= polytype; - dl->parts= tot/polytype; - dl->col= colnr; - data= (float *)(dl+1); - - index= ivp->data[0]; - first= 1; - for(a=0; adatalen[0]; a++) { - - VECCOPY(data, index); - data+= 3; - index+= 3; - - VECCOPY(data, index); - data+= 3; - index+= 3; - - VECCOPY(data, index); - data+= 3; - index+= 3; - - if(polytype==4) { - VECCOPY(data, index); - data+= 3; - index+= 3; - } - } - } - } - else if( strcmp(iv->nodename, "TriangleStripSet")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - - if(ivp) { - /* count triangles */ - tot= 0; - face= 0; - - index= iv->data[0]; /* strip size */ - - for(a=0; adatalen[0]; a++) { - tot+= (int) index[0]; - face+= ((int) index[0]) - 2; - index++; - } - - dl= MEM_callocN(sizeof(struct DispList), "leesInventor4"); - dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts"); - dl->index= MEM_callocN( face*3*sizeof(int), "dl index"); - - dl->type= DL_INDEX3; - dl->nr= tot; - dl->parts= face; - - BLI_addtail(listb, dl); - dl->col= colnr; - - index= iv->data[0]; /* strip size */ - fp= ivp->data[0]; /* vertices */ - data= dl->verts; - idata= dl->index; - first= 0; - - for(a=0; adatalen[0]; a++) { - - /* vertices */ - for(b=0; bnodename, "IndexedFaceSet")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - if(ivp) { - - /* count triangles */ - face= 0; - index= iv->data[0]; - lll = iv->datalen[0]-2; - for(a=0; adatalen[0]/coordtype; - - if(tot) { - dl= MEM_callocN(sizeof(struct DispList), "leesInventor5"); - BLI_addtail(listb, dl); - dl->type= DL_INDEX3; - dl->nr= tot; - dl->parts= face; - dl->col= colnr; - - dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts"); - dl->index= MEM_callocN(sizeof(int)*3*face, "dl index"); - - /* vertices */ - fp= ivp->data[0]; - data= dl->verts; - for(b=tot; b>0; b--) { - VECCOPY(data, fp); - data+= 3; - fp+= coordtype; - } - - /* indices */ - index= iv->data[0]; - idata= dl->index; - first= 1; - lll=iv->datalen[0]-2; - for(a=0; anodename, "IndexedTriangleMesh")==0 || - strcmp(iv->nodename, "IndexedTriangleStripSet")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - if(ivp) { - - /* count triangles */ - face= 0; - index= iv->data[0]; - lll=iv->datalen[0]-2; - for(a=0; adatalen[0]/coordtype; - - dl= MEM_callocN(sizeof(struct DispList), "leesInventor6"); - BLI_addtail(listb, dl); - dl->type= DL_INDEX3; - dl->nr= tot; - dl->parts= face; - dl->col= colnr; - - dl->verts= MEM_callocN( tot*3*sizeof(float), "dl verts"); - dl->index= MEM_callocN(sizeof(int)*3*face, "dl index"); - - /* vertices */ - fp= ivp->data[0]; - data= dl->verts; - for(b=tot; b>0; b--) { - VECCOPY(data, fp); - data+= 3; - fp+= coordtype; - } - - /* indices */ - index= iv->data[0]; - idata= dl->index; - - lll=iv->datalen[0]-2; - for(a=lll; a>0; a--) { - - if(index[0]!= -1 && index[1]!= -1 && index[2]!= -1) { - idata[0]= (int) index[0]; - idata[1]= (int) index[1]; - idata[2]= (int) index[2]; - idata+= 3; - } - index++; - } - } - } - else if( strcmp(iv->nodename, "QuadMesh")==0 ) { - - colnr= iv_colornumber(iv); - - /* seek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "VertexProperty")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - - if(ivp) { - tot= (int) (floor(*(iv->data[0])+0.5) * floor(*(iv->data[1])+0.5)); - - if(tot>0) { - dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor8"); - BLI_addtail(listb, dl); - dl->type= DL_SURF; - dl->parts= (int) floor(*(iv->data[0])+0.5); - dl->nr= (int) floor(*(iv->data[1])+0.5); - dl->col= colnr; - data= (float *)(dl+1); - memcpy(data, ivp->data[0], tot*3*sizeof(float)); - } - } - } - else if(strcmp(iv->nodename, "IndexedNurbsSurface")==0 || strcmp(iv->nodename, "NurbsSurface")==0) { - - colnr= iv_colornumber(iv); - - /* sek back to data */ - ivp= iv; - while(ivp->prev) { - ivp= ivp->prev; - if( strcmp(ivp->nodename, "Coordinate3")==0 ) { - coordtype= 3; - break; - } - if( strcmp(ivp->nodename, "Coordinate4")==0 ) { - coordtype= 4; - break; - } - } - if(ivp) { - a= (int) *(iv->data[0]); - b= (int) *(iv->data[1]); - - tot= a*b; - - if( (a>=4 || b>=4) && tot>6) { - Object *ob; - Curve *cu; - Nurb *nu; - BPoint *bp; - - if(ivsurf==0) { - ob= add_object(scene, OB_SURF); - ivsurf= ob; - } - else ob= ivsurf; - cu= ob->data; - nu = (Nurb*) MEM_callocN(sizeof(Nurb),"addNurbprim") ; - BLI_addtail(&cu->nurb, nu); - nu->type= CU_NURBS; - - nu->pntsu= a; - nu->pntsv= b; - nu->resolu= 2*a; - nu->resolv= 2*b; - - nu->flagu= 0; - nu->flagv= 0; - - nu->bp = bp = - (BPoint*)MEM_callocN(tot * sizeof(BPoint), "addNurbprim3"); - a= tot; - data= ivp->data[0]; - while(a--) { - VECCOPY(bp->vec, data); - if(coordtype==4) { - bp->vec[3]= data[3]; - mul_v3_fl(bp->vec, 1.0f/data[3]); - } - else bp->vec[3]= 1.0; - data+= coordtype; - bp++; - } - - /* iv->datalen[2] / [3] is number of knots */ - nu->orderu= iv->datalen[2] - nu->pntsu; - nu->orderv= iv->datalen[3] - nu->pntsv; - - nu->knotsu= MEM_mallocN( sizeof(float)*(iv->datalen[2]), "knots"); - memcpy(nu->knotsu, iv->data[2], sizeof(float)*(iv->datalen[2])); - nu->knotsv= MEM_mallocN( sizeof(float)*(iv->datalen[3]), "knots"); - memcpy(nu->knotsv, iv->data[3], sizeof(float)*(iv->datalen[3])); - - switchdirectionNurb(nu); - - } - else { - dl= MEM_callocN(sizeof(struct DispList)+tot*3*sizeof(float), "leesInventor3"); - BLI_addtail(listb, dl); - dl->type= DL_SURF; - dl->nr= (int) *(iv->data[0]); - dl->parts= (int) *(iv->data[1]); - dl->col= colnr; - data= (float *)(dl+1); - - a= tot; - fp= ivp->data[0]; - while(a--) { - VECCOPY(data, fp); - fp+= coordtype; - data+= 3; - } - } - } - } - iv= iv->next; - } - - /* free */ - iv= ivbase.first; - while(iv) { - for(a=0; adata[a]) MEM_freeN(iv->data[a]); - } - iv= iv->next; - } - - BLI_freelistN(&ivbase); - MEM_freeN(maindata); - MEM_freeN(iv_data_stack); - -} - -/* ************************************************************ */ - -static void displist_to_mesh(Scene *scene, DispList *dlfirst) -{ - Object *ob; - Mesh *me; - Material *ma; - DispList *dl; - MVert *mvert; - MFace *mface; - float *data, vec[3], min[3], max[3]; - int a, b, startve, *idata, totedge=0, tottria=0, totquad=0, totvert=0, totface, totcol=0, colnr; - int p1, p2, p3, p4; - unsigned int maxvertidx; - - /* count first */ - INIT_MINMAX(min, max); - - dl= dlfirst; - while(dl) { - - /* PATCH 1 (polyfill) can't be done, there's no listbase here. do that first! */ - /* PATCH 2 */ - if(dl->type==DL_SEGM && dl->nr>2) { - data= (float *)(dl+1); - if(data[0]==data[3*(dl->nr-1)]) { - if(data[1]==data[3*(dl->nr-1)+1]) { - if(data[2]==data[3*(dl->nr-1)+2]) { - dl->type= DL_POLY; - dl->nr--; - } - } - } - } - - /* colors */ - if(dl->col > totcol) totcol= dl->col; - - /* size and count */ - if(dl->type==DL_SURF) { - a= dl->nr; - b= dl->parts; - if(dl->flag & DL_CYCL_U) a++; - if(dl->flag & DL_CYCL_V) b++; - - totquad+= a*b; - - totvert+= dl->nr*dl->parts; - - data= (float *)(dl+1); - for(a= dl->nr*dl->parts; a>0; a--) { - DO_MINMAX(data, min, max); - data+= 3; - } - } - else if(dl->type==DL_POLY) { - if(dl->nr==3 || dl->nr==4) { - if(dl->nr==3) tottria+= dl->parts; - else totquad+= dl->parts; - - totvert+= dl->nr*dl->parts; - - data= (float *)(dl+1); - for(a= dl->nr*dl->parts; a>0; a--) { - DO_MINMAX(data, min, max); - data+= 3; - } - } - else if(dl->nr>4) { - - tottria+= dl->nr*dl->parts; - totvert+= dl->nr*dl->parts; - - data= (float *)(dl+1); - for(a= dl->nr*dl->parts; a>0; a--) { - DO_MINMAX(data, min, max); - data+= 3; - } - - } - } - else if(dl->type==DL_INDEX3) { - tottria+= dl->parts; - totvert+= dl->nr; - - data= dl->verts; - for(a= dl->nr; a>0; a--) { - DO_MINMAX(data, min, max); - data+= 3; - } - } - else if(dl->type==DL_SEGM) { - - tottria+= (dl->nr-1)*dl->parts; - totvert+= dl->nr*dl->parts; - - data= (float *)(dl+1); - for(a= dl->nr*dl->parts; a>0; a--) { - DO_MINMAX(data, min, max); - data+= 3; - } - } - - dl= dl->next; - } - - if(totvert==0) { - return; - } - - vec[0]= (min[0]+max[0])/2; - vec[1]= (min[1]+max[1])/2; - vec[2]= (min[2]+max[2])/2; - - ob= add_object(scene, OB_MESH); - VECCOPY(ob->loc, vec); - where_is_object(scene, ob); - - me= ob->data; - - /* colors */ - if(totcol) { - ob->mat= MEM_callocN(sizeof(void *)*totcol, "ob->mat"); - ob->matbits= MEM_callocN(sizeof(char)*totcol, "ob->matbits"); - me->mat= MEM_callocN(sizeof(void *)*totcol, "me->mat"); - me->totcol= totcol; - ob->totcol= (unsigned char) me->totcol; - ob->actcol= 1; - } - - /* materials */ - for(a=0; amat.first; - while(ma) { - if(ma->mtex[0]==0) { - if(ivcolors[a][0]==ma->r && ivcolors[a][1]==ma->g && ivcolors[a][2]==ma->b) { - me->mat[a]= ma; - ma->id.us++; - break; - } - } - ma= ma->id.next; - } - if(ma==0) { - ma= add_material("ext"); - me->mat[a]= ma; - ma->r= ivcolors[a][0]; - ma->g= ivcolors[a][1]; - ma->b= ivcolors[a][2]; - automatname(ma); - } - } - - totface= totquad+tottria+totedge; - - printf("Import: %d vertices %d faces\n", totvert, totface); - - me->totvert= totvert; - me->totface= totface; - me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, - NULL, me->totvert); - me->mface= CustomData_add_layer(&me->fdata, CD_MFACE, CD_CALLOC, - NULL, me->totface); - maxvertidx= totvert-1; - - mvert= me->mvert; - mface= me->mface; - - startve= 0; - - dl= dlfirst; - while(dl) { - - colnr= dl->col; - if(colnr) colnr--; - - if(dl->type==DL_SURF) { - data= (float *)(dl+1); - - for(a=dl->parts*dl->nr; a>0; a--) { - mvert->co[0]= data[0] -vec[0]; - mvert->co[1]= data[1] -vec[1]; - mvert->co[2]= data[2] -vec[2]; - - data+=3; - mvert++; - } - - for(a=0; aparts; a++) { - - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) - break; - - p1+= startve; - p2+= startve; - p3+= startve; - p4+= startve; - - for(; bnr; b++) { - - mface->v1= p1; - mface->v2= p2; - mface->v3= p4; - mface->v4= p3; - - mface->mat_nr= colnr; - test_index_face(mface, NULL, 0, 4); - - mface++; - - p4= p3; - p3++; - p2= p1; - p1++; - } - } - - startve += dl->parts*dl->nr; - - } - else if(dl->type==DL_POLY) { - - if(dl->nr==3 || dl->nr==4) { - data= (float *)(dl+1); - - for(a=dl->parts*dl->nr; a>0; a--) { - mvert->co[0]= data[0] -vec[0]; - mvert->co[1]= data[1] -vec[1]; - mvert->co[2]= data[2] -vec[2]; - data+=3; - mvert++; - } - - for(a=0; aparts; a++) { - if(dl->nr==3) { - mface->v1= startve+a*dl->nr; - mface->v2= startve+a*dl->nr+1; - mface->v3= startve+a*dl->nr+2; - mface->mat_nr= colnr; - test_index_face(mface, NULL, 0, 3); - mface++; - } - else { - mface->v1= startve+a*dl->nr; - mface->v2= startve+a*dl->nr+1; - mface->v3= startve+a*dl->nr+2; - mface->v4= startve+a*dl->nr+3; - mface->mat_nr= colnr; - test_index_face(mface, NULL, 0, 4); - mface++; - } - } - startve += dl->parts*dl->nr; - } - else if(dl->nr>4) { - data= (float *)(dl+1); - - for(a=dl->parts*dl->nr; a>0; a--) { - mvert->co[0]= data[0] -vec[0]; - mvert->co[1]= data[1] -vec[1]; - mvert->co[2]= data[2] -vec[2]; - - data+=3; - mvert++; - } - - for(b=0; bparts; b++) { - for(a=0; anr; a++) { - mface->v1= startve+a; - - if(a==dl->nr-1) mface->v2= startve; - else mface->v2= startve+a+1; - - mface->mat_nr= colnr; - - mface++; - } - startve += dl->nr; - } - } - } - else if(dl->type==DL_INDEX3) { - data= dl->verts; - - for(a=dl->nr; a>0; a--) { - mvert->co[0]= data[0] -vec[0]; - mvert->co[1]= data[1] -vec[1]; - mvert->co[2]= data[2] -vec[2]; - data+=3; - mvert++; - } - - idata= dl->index; - for(b=dl->parts; b>0; b--) { - mface->v1= startve+idata[0]; - mface->v2= startve+idata[1]; - mface->v3= startve+idata[2]; - mface->mat_nr= colnr; - - if (mface->v1>maxvertidx) mface->v1= maxvertidx; - if (mface->v2>maxvertidx) mface->v2= maxvertidx; - if (mface->v3>maxvertidx) mface->v3= maxvertidx; - - test_index_face(mface, NULL, 0, 3); - mface++; - idata+= 3; - } - startve += dl->nr; - } - else if(dl->type==DL_SEGM) { - data= (float *)(dl+1); - - for(a=dl->parts*dl->nr; a>0; a--) { - mvert->co[0]= data[0] -vec[0]; - mvert->co[1]= data[1] -vec[1]; - mvert->co[2]= data[2] -vec[2]; - data+=3; - mvert++; - } - - for(b=0; bparts; b++) { - for(a=0; anr-1; a++) { - mface->v1= startve+a; - mface->v2= startve+a+1; - mface->mat_nr= colnr; - mface++; - } - startve += dl->nr; - } - } - dl= dl->next; - } - - mesh_add_normals_flags(me); - make_edges(me, 0); -} - -static void displist_to_objects(Scene *scene, ListBase *lbase) -{ - DispList *dl, *first, *prev, *next; - ListBase tempbase; - int maxaantal, curcol, totvert=0, vert; - - /* irst this: is still active */ - if(ivsurf) { - where_is_object(scene, ivsurf); -// XXX docenter_new(); - } - - dl= lbase->first; - while(dl) { - next= dl->next; - - /* PATCH 1: polyfill */ - if(dl->type==DL_POLY && dl->nr>4) { - /* solution: put them together in separate listbase */ - ; - } - /* PATCH 2: poly's of 2 points */ - if(dl->type==DL_POLY && dl->nr==2) dl->type= DL_SEGM; - - dl= next; - } - - /* count vertices */ - - dl= lbase->first; - while(dl) { - - if(dl->type==DL_SURF) totvert+= dl->nr*dl->parts; - else if(dl->type==DL_POLY) { - if(dl->nr==3 || dl->nr==4) totvert+= dl->nr*dl->parts; - else if(dl->nr>4) totvert+= dl->nr*dl->parts; - } - else if(dl->type==DL_INDEX3) totvert+= dl->nr; - else if(dl->type==DL_SEGM) totvert+= dl->nr*dl->parts; - - dl= dl->next; - } - - if(totvert==0) { - - if(ivsurf==0) {}; //XXX error("Found no data"); - if(lbase->first) BLI_freelistN(lbase); - - return; - } - - maxaantal= 32000; - - if(totvert>maxaantal) { - - /* try to put colors together */ - curcol= 0; - tempbase.first= tempbase.last= 0; - - while(lbase->first) { - dl= lbase->first; - while(dl) { - next= dl->next; - if(dl->col==curcol) { - BLI_remlink(lbase, dl); - BLI_addtail(&tempbase, dl); - dl->col= 0; - } - - dl= next; - } - - /* in tempbase are all 'curcol' */ - totvert= 0; - dl= first= tempbase.first; - while(dl) { - vert= 0; - - if(dl->type==DL_SURF) vert= dl->nr*dl->parts; - else if(dl->type==DL_POLY) { - if(dl->nr==3 || dl->nr==4) vert= dl->nr*dl->parts; - else if(dl->nr>4) vert= dl->nr*dl->parts; - } - else if(dl->type==DL_INDEX3) totvert+= dl->nr; - else if(dl->type==DL_SEGM) vert= dl->nr*dl->parts; - - totvert+= vert; - if(totvert > maxaantal || dl->next==0) { - if(dl->next==0) { - displist_to_mesh(scene, first); - } - else if(dl->prev) { - prev= dl->prev; - prev->next= 0; - displist_to_mesh(scene, first); - prev->next= dl; - first= dl; - totvert= 0; - } - } - - dl= dl->next; - } - - freedisplist(&tempbase); - - curcol++; - } - } - else displist_to_mesh(scene, lbase->first); - - freedisplist(lbase); - -} +/* ************************************************************ */ int BKE_read_exotic(Scene *scene, char *name) { - ListBase lbase={0, 0}; int len; gzFile gzfile; char str[32]; @@ -1793,21 +475,7 @@ int BKE_read_exotic(Scene *scene, char *name) if ((*s0 != FORM) && (strncmp(str, "BLEN", 4) != 0) && !BLI_testextensie(name,".blend.gz")) { //XXX waitcursor(1); - if(strncmp(str, "#Inventor V1.0", 14)==0) { - if( strncmp(str+15, "ascii", 5)==0) { - read_inventor(scene, name, &lbase); - displist_to_objects(scene, &lbase); - retval = 1; - } else { - //XXX error("Can only read Inventor 1.0 ascii"); - } - } - else if((strncmp(str, "#VRML V1.0 asc", 14)==0)) { - read_inventor(scene, name, &lbase); - displist_to_objects(scene, &lbase); - retval = 1; - } - else if(is_dxf(name)) { + if(is_dxf(name)) { dxf_read(scene, name); retval = 1; } @@ -1965,7 +633,6 @@ void write_stl(Scene *scene, char *str) //XXX waitcursor(0); } -/* ******************************* WRITE VRML ***************************** */ static void replace_chars(char *str1, char *str2) { @@ -1978,354 +645,6 @@ static void replace_chars(char *str1, char *str2) } } - -static void write_material_vrml(FILE *fp, Material *ma) -{ - char str[32]; - - replace_chars(str, ma->id.name+2); - - fprintf(fp, "\tDEF %s\n", str); - fprintf(fp, "\tMaterial {\n"); - - fprintf(fp, "\t\tdiffuseColor %f %f %f\n", ma->r, ma->g, ma->b); - fprintf(fp, "\t\tspecularColor %f %f %f\n", ma->specr, ma->specg, ma->specb); - fprintf(fp, "\t\tshininess %f \n", ((float)ma->har)/100.0); - fprintf(fp, "\t\ttransparency %f \n", 1.0-ma->alpha); - - fprintf(fp, "\t}\n"); - -} - -unsigned int *mcol_to_vcol(Mesh *me) -{ - MFace *mface; - unsigned int *mcol, *mcoln, *mcolmain; - int a; - - if(me->totface==0 || me->mcol==0) return 0; - - mcoln= mcolmain= MEM_mallocN(sizeof(int)*me->totvert, "mcoln"); - mcol = (unsigned int *)me->mcol; - mface= me->mface; - - for(a=me->totface; a>0; a--, mface++) { - mcoln[mface->v1]= mcol[0]; - mcoln[mface->v2]= mcol[1]; - mcoln[mface->v3]= mcol[2]; - if(mface->v4) mcoln[mface->v4]= mcol[3]; - - mcol+= 4; - } - - return mcolmain; -} - -void mcol_to_rgba(unsigned int col, float *r, float *g, float *b, float *a) -{ - char *cp; - - cp = (char *)&col; - - *r= cp[3]; - *r /= 255.0; - - *g= cp[2]; - *g /= 255.0; - - *b= cp[1]; - *b /= 255.0; - - *a= cp[0]; - *a /= 255.0; -} - -static void write_mesh_vrml(FILE *fp, Mesh *me) -{ - Material *ma; - MVert *mvert; - MFace *mface; - MTFace *tface; - Image *ima; - int a, b, totcol, texind; - char str[32]; - - replace_chars(str, me->id.name+2); - - fprintf(fp, "\tDEF %s\n", str); - fprintf(fp, "\tSeparator {\n"); - - if(me->mtface) { - ima= ((MTFace *)me->mtface)->tpage; - if(ima) { - fprintf(fp, "\t\tTexture2 {\n"); - fprintf(fp, "\t\t\tfilename %s\n", ima->name); - fprintf(fp, "\t\t\twrapS REPEAT \n"); - fprintf(fp, "\t\t\twrapT REPEAT \n"); - fprintf(fp, "\t\t}\n"); - } - } - - if(me->mcol) { - unsigned int *mcol, *mcolmain; - float r, g, b, cola; - - fprintf(fp, "\t\tMaterial {\n"); - fprintf(fp, "\t\t\tdiffuseColor [\n"); - - a= me->totvert; - mcol= mcolmain= mcol_to_vcol(me); - if(mcol) { - while(a--) { - mcol_to_rgba(*mcol, &r, &g, &b, &cola); - fprintf(fp, "\t\t\t\t %f %f %f,\n", r, g, b); - mcol++; - } - MEM_freeN(mcolmain); - } - fprintf(fp, "\t\t\t]\n"); - fprintf(fp, "\t\t}\n"); - - fprintf(fp, "\t\tMaterialBinding { value PER_VERTEX_INDEXED }\n"); - } - - - fprintf(fp, "\t\tCoordinate3 {\n"); - fprintf(fp, "\t\t\tpoint [\n"); - - a= me->totvert; - mvert= me->mvert; - while(a--) { - fprintf(fp, "\t\t\t\t %f %f %f,\n", mvert->co[0], mvert->co[1], mvert->co[2]); - mvert++; - } - fprintf(fp, "\t\t\t]\n"); - fprintf(fp, "\t\t}\n"); - - - totcol= me->totcol; - if(totcol==0) totcol= 1; - texind= 0; // index for uv coords - - for(b=0; bmcol==0) { - if(me->mat) { - ma= me->mat[b]; - if(ma) { - replace_chars(str, ma->id.name+2); - - fprintf(fp, "\t\tUSE %s\n\n", str); - } - } - } - - if(me->mtface) { - fprintf(fp, "\t\tTextureCoordinate2 {\n"); - fprintf(fp, "\t\t\tpoint [\n"); - - a= me->totface; - mface= me->mface; - tface= me->mtface; - while(a--) { - if(mface->mat_nr==b) { - fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[0][0], tface->uv[0][1]); - fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[1][0], tface->uv[1][1]); - fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[2][0], tface->uv[2][1]); - if(mface->v4) fprintf(fp, "\t\t\t\t %f %f,\n", tface->uv[3][0], tface->uv[3][1]); - } - mface++; - tface++; - } - fprintf(fp, "\t\t\t]\n"); - fprintf(fp, "\t\t}\n"); - } - - fprintf(fp, "\t\tIndexedFaceSet {\n"); - fprintf(fp, "\t\t\tcoordIndex [\n"); - - a= me->totface; - mface= me->mface; - while(a--) { - if(mface->mat_nr==b) { - if(mface->v4) fprintf(fp, "\t\t\t\t %d, %d, %d, %d, -1,\n", mface->v1, mface->v2, mface->v3, mface->v4); - else fprintf(fp, "\t\t\t\t %d, %d, %d, -1,\n", mface->v1, mface->v2, mface->v3); - } - mface++; - } - fprintf(fp, "\t\t\t]\n"); - - if(me->mtface) { - fprintf(fp, "\t\t\ttextureCoordIndex [\n"); - - a= me->totface; - mface= me->mface; - while(a--) { - if(mface->mat_nr==b) { - if(mface->v4) { - fprintf(fp, "\t\t\t\t %d, %d, %d, %d, -1,\n", texind, texind+1, texind+2, texind+3); - texind+= 4; - } - else { - fprintf(fp, "\t\t\t\t %d, %d, %d, -1,\n", texind, texind+1, texind+2); - texind+= 3; - } - } - mface++; - } - fprintf(fp, "\t\t\t]\n"); - } - fprintf(fp, "\t\t}\n"); - } - - fprintf(fp, "\t}\n"); -} - -static void write_camera_vrml(FILE *fp, Object *ob) -{ - Camera *cam; - - if(ob==0) return; - invert_m4_m4(ob->imat, ob->obmat); - - fprintf(fp, "\tMatrixTransform {\n"); - - fprintf(fp, "\tmatrix \n"); - - fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[0][0], ob->imat[0][1], ob->imat[0][2], ob->imat[0][3]); - fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[1][0], ob->imat[1][1], ob->imat[1][2], ob->imat[1][3]); - fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[2][0], ob->imat[2][1], ob->imat[2][2], ob->imat[2][3]); - fprintf(fp, "\t\t%f %f %f %f\n", ob->imat[3][0], ob->imat[3][1], ob->imat[3][2], ob->imat[3][3]); - - fprintf(fp, "\t}\n"); - - cam= ob->data; - - fprintf(fp, "\tPerspectiveCamera {\n"); - fprintf(fp, "\t\tfocalDistance %f\n", cam->lens/10.0); - - fprintf(fp, "\t}\n"); - -} - -static void write_object_vrml(FILE *fp, Object *ob) -{ - ID *id; - char str[32]; - - fprintf(fp, "\tSeparator {\n"); - fprintf(fp, "\t\tMatrixTransform {\n"); - - fprintf(fp, "\t\tmatrix \n"); - - fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[0][0], ob->obmat[0][1], ob->obmat[0][2], ob->obmat[0][3]); - fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[1][0], ob->obmat[1][1], ob->obmat[1][2], ob->obmat[1][3]); - fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[2][0], ob->obmat[2][1], ob->obmat[2][2], ob->obmat[2][3]); - fprintf(fp, "\t\t\t%f %f %f %f\n", ob->obmat[3][0], ob->obmat[3][1], ob->obmat[3][2], ob->obmat[3][3]); - - fprintf(fp, "\t\t}\n"); - - id= ob->data; - - replace_chars(str, id->name+2); - - fprintf(fp, "\t\tUSE %s\n", str); - fprintf(fp, "\t}\n"); -} - - -void write_vrml(Scene *scene, char *str) -{ - Mesh *me; - Material *ma; - Base *base; - FILE *fp; - - if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0; - if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0; - if(BLI_testextensie(str,".wrl")==0) strcat(str, ".wrl"); - //XXX saveover() if(saveover(str)==0) return; - - fp= fopen(str, "w"); - - if(fp==NULL) { - //XXX error("Can't write file"); - return; - } - strcpy(temp_dir, str); - - //XXX waitcursor(1); - - /* FIRST: write all the datablocks */ - - fprintf(fp, "#VRML V1.0 ascii\n\n# Blender V%d\n\n# 'Switch' is used as a hack, to ensure it is not part of the drawing\n\n", BLENDER_VERSION); - fprintf(fp, "Separator {\n"); - fprintf(fp, "Switch {\n"); - - ma= G.main->mat.first; - while(ma) { - if(ma->id.us) { - write_material_vrml(fp, ma); - } - ma= ma->id.next; - } - - /* only write meshes we're using in this scene */ - flag_listbase_ids(&G.main->mesh, LIB_DOIT, 0); - - for(base= scene->base.first; base; base= base->next) - if(base->object->type== OB_MESH) - ((ID *)base->object->data)->flag |= LIB_DOIT; - - me= G.main->mesh.first; - while(me) { - if(me->id.flag & LIB_DOIT) { /* is the mesh used in this scene ? */ - write_mesh_vrml(fp, me); - } - me= me->id.next; - } - - /* THEN:Hidden Objects */ - fprintf(fp, "\n\t# Hidden Objects, in invisible layers\n\n"); - base= scene->base.first; - while(base) { - if(base->object->type== OB_MESH) { - if( (base->lay & scene->lay)==0 ) { - write_object_vrml(fp, base->object); - } - } - base= base->next; - } - - fprintf(fp, "}\n"); - fprintf(fp, "\n# Visible Objects\n\n"); - fprintf(fp, "Separator {\n"); - - /* The camera */ - - write_camera_vrml(fp, scene->camera); - - /* THEN:The Objects */ - - base= scene->base.first; - while(base) { - if(base->object->type== OB_MESH) { - if(base->lay & scene->lay) { - write_object_vrml(fp, base->object); - } - } - base= base->next; - } - - fprintf(fp, "}\n"); - fprintf(fp, "}\n"); - - fclose(fp); - - //XXX waitcursor(0); -} - - /* ******************************* WRITE DXF ***************************** */ #define write_group(id,data) fprintf(fp, "%d\n%s\n", id, data) -- cgit v1.2.3 From 9234f29e673632d15f6a19cf5eda675cde392e44 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Sep 2010 06:43:36 +0000 Subject: bugfix [#23405] PNG Images bigger then 2gig wont load with blender. all image formats should be able to load files bigger then 2gig (when its supported) --- source/blender/blenkernel/intern/effect.c | 1 + source/blender/blenkernel/intern/exotic.c | 4 +++- source/blender/blenkernel/intern/fluidsim.c | 1 + source/blender/blenkernel/intern/particle_system.c | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 05fcabd371f..0da5e0da2c4 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -29,6 +29,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index bd001649bf5..973c18531c4 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -29,12 +29,14 @@ * * ***** END GPL LICENSE BLOCK *****/ +#include #include "BLI_storage.h" +#include #include /* isdigit, isspace */ #include #include -#include + #include #include #include diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 04ce6c39694..ef89d39864a 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -28,6 +28,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 0d14c3cb9f6..598dd3c03fe 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -29,6 +29,7 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include #include "BLI_storage.h" /* _LARGEFILE_SOURCE */ #include -- cgit v1.2.3 From 7d8f0fce7a551ff39a86cb5a113df8ae9b0b57cf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Sep 2010 17:37:00 +0000 Subject: patch [#23758] Better handling of UTF chars in UNITS fields (lengths, angles, etc.) from Lorenzo Tozzi (oni_niubbo) with minor edits. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- from the tracker The present situation is this: due to bug#22274, during editing, UTF chars are stripped from buttons with a unit associated (length, angles, etc.). Example: if the button displays '90°' and you click on it with LMB, the editing string will become '90'. The problem arises if you use microns: '34µm' becomes '34' that blender interprets as 34 meters. So clicking on a button and hitting enter won't confirm the previous value, but will change it (very badly also). Of course nobody is using microns in blender, but the problem will arise when we will implement areas and option 'Separate Units' will be enabled. The value '2m² 3cm²' will become '2m' during editing. This patch solves the problem rewriting the string in a smarter way than just stripping the UTF chars: the unit is translated from unit->name_short ('µm') to unit->name_alt ('um'). So clicking on '34µm' the editing string will become '34um'. --- end note: rather then allowing empty strings in name_alt field I made it so if the unit system was the default one a NULL name_alt will just strip the string, since its the default its not needed. --- source/blender/blenkernel/intern/unit.c | 48 +++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 133f858e9ea..963cfdbea1b 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -44,7 +44,8 @@ typedef struct bUnitDef { char *name; char *name_plural; /* abused a bit for the display name */ char *name_short; /* this is used for display*/ - char *name_alt; /* can be NULL */ + char *name_alt; /* keyboard-friendly ASCII-only version of name_short, can be NULL */ + /* if name_short has non-ASCII chars, name_alt should be present */ char *name_display; /* can be NULL */ @@ -76,7 +77,7 @@ static struct bUnitCollection buDummyCollecton = {buDummyDef, 0, 0, sizeof(buDum static struct bUnitDef buMetricLenDef[] = { {"kilometer", "kilometers", "km", NULL, "Kilometers", 1000.0, 0.0, B_UNIT_DEF_NONE}, {"hectometer", "hectometers", "hm", NULL, "100 Meters", 100.0, 0.0, B_UNIT_DEF_SUPPRESS}, - {"dekameter", "dekameters", "dkm",NULL, "10 Meters", 10.0, 0.0, B_UNIT_DEF_SUPPRESS}, + {"dekameter", "dekameters", "dam",NULL, "10 Meters", 10.0, 0.0, B_UNIT_DEF_SUPPRESS}, {"meter", "meters", "m", NULL, "Meters", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {"decimetre", "decimetres", "dm", NULL, "10 Centimeters", 0.1, 0.0, B_UNIT_DEF_SUPPRESS}, {"centimeter", "centimeters", "cm", NULL, "Centimeters", 0.01, 0.0, B_UNIT_DEF_NONE}, @@ -543,6 +544,49 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre return change; } +/* 45µm --> 45um */ +void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, int system, int type) +{ + bUnitCollection *usys = unit_get_system(system, type); + + bUnitDef *unit; + bUnitDef *unit_def= unit_default(usys); + + /* find and substitute all units */ + for(unit= usys->units; unit->name; unit++) { + if(len_max > 0 && (unit->name_alt || unit == unit_def)) + { + char *found= NULL; + + found= unit_find_str(orig_str, unit->name_short); + if(found) { + int offset= found - orig_str; + int len_name= 0; + + /* copy everything before the unit */ + offset= (offsetname_short); + len_max-= offset; + + /* print the alt_name */ + if(unit->name_alt) + len_name= snprintf(str, len_max, "%s", unit->name_alt); + else + len_name= 0; + + len_name= (len_name Date: Thu, 16 Sep 2010 04:19:22 +0000 Subject: - bone roll now in degrees not radians. - rna buttons with units set now use the units base value for snapping. - bone head/tail radius could be set negative. matt: removed a check in ui_is_but_unit() which made angle buttons return false, what was this for? --- source/blender/blenkernel/intern/unit.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 963cfdbea1b..36a4cfea7a0 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -24,6 +24,8 @@ #include #include #include +#include "BKE_unit.h" + #ifdef WIN32 #define _USE_MATH_DEFINES #endif @@ -31,6 +33,7 @@ #include "BLI_winstuff.h" + #define TEMP_STR_SIZE 256 #define SEP_CHR '#' @@ -127,7 +130,8 @@ static struct bUnitDef buNaturalRotDef[] = { }; static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; -#define UNIT_SYSTEM_MAX 3 +#define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 8) / sizeof(void *)) - 1) + static struct bUnitCollection *bUnitSystems[][8] = { {0,0,0,0,0,&buNaturalRotCollection,&buNaturalTimeCollecton,0}, {0,&buMetricLenCollecton, 0,0,0, &buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* metric */ @@ -135,6 +139,8 @@ static struct bUnitCollection *bUnitSystems[][8] = { {0,0,0,0,0,0,0,0} }; + + /* internal, has some option not exposed */ static bUnitCollection *unit_get_system(int system, int type) { @@ -459,7 +465,7 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre bUnitCollection *usys_iter; int system_iter; - for(system_iter= 0; system_iter= B_UNIT_MAXDEF || system < 0 || system > UNIT_SYSTEM_TOT); +} + + void bUnit_GetSystem(void **usys_pt, int *len, int system, int type) { bUnitCollection *usys = unit_get_system(system, type); -- cgit v1.2.3 From 43d2d0c6ea6c74319de455f7ef81b42c597d1e5c Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 16 Sep 2010 20:00:30 +0000 Subject: Bug fix: Boids that could only fly didn't take the ground object into account leading to problems when flying near the ground. Reported by Mike Pan and Dalai Felinto by mail. --- source/blender/blenkernel/intern/boids.c | 65 +++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 17 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 54ffda6c0a9..5bf228b2392 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -240,6 +240,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * mul_v3_fl(bbd->wanted_co, (1.0f - t) * val->personal_space * pa->size); bbd->wanted_speed = sqrt(t) * len_v3(pa->prev_state.vel); + bbd->wanted_speed = MAX2(bbd->wanted_speed, val->min_speed); return 1; } @@ -736,6 +737,7 @@ static void set_boid_values(BoidValues *val, BoidSettings *boids, ParticleData * val->jump_speed = 0.0f; /* no jumping in air */ } } + static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *ground_co, float *ground_nor) { BoidParticle *bpa = pa->boid; @@ -765,16 +767,15 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro if(!bbd->sim->colliders) return NULL; + /* first try to find below boid */ copy_v3_v3(col.co1, pa->state.co); - copy_v3_v3(col.co2, pa->state.co); - add_v3_v3(col.co1, zvec); + sub_v3_v3v3(col.co2, pa->state.co, zvec); sub_v3_v3(col.co2, zvec); sub_v3_v3v3(ray_dir, col.co2, col.co1); col.t = 0.0f; hit.index = -1; hit.dist = col.ray_len = len_v3(ray_dir); - /* find out upmost deflector object */ for(coll = bbd->sim->colliders->first; coll; coll = coll->next){ col.ob = coll->ob; col.md = coll->collmd; @@ -789,14 +790,37 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro normalize_v3_v3(ground_nor, col.nor); return col.hit_ob; } - else { - /* default to z=0 */ - VECCOPY(ground_co, pa->state.co); - ground_co[2] = 0; - ground_nor[0] = ground_nor[1] = 0.0f; - ground_nor[2] = 1.0f; - return NULL; + + /* couldn't find below, so find upmost deflector object */ + add_v3_v3(col.co1, pa->state.co, zvec); + sub_v3_v3v3(col.co2, pa->state.co, zvec); + sub_v3_v3(col.co2, zvec); + sub_v3_v3v3(ray_dir, col.co2, col.co1); + col.t = 0.0f; + hit.index = -1; + hit.dist = col.ray_len = len_v3(ray_dir); + + for(coll = bbd->sim->colliders->first; coll; coll = coll->next){ + col.ob = coll->ob; + col.md = coll->collmd; + + if(col.md && col.md->bvhtree) + BLI_bvhtree_ray_cast(col.md->bvhtree, col.co1, ray_dir, radius, &hit, particle_intersect_face, &col); + } + /* then use that object */ + if(hit.index>=0) { + t = hit.dist/col.ray_len; + interp_v3_v3v3(ground_co, col.co1, col.co2, t); + normalize_v3_v3(ground_nor, col.nor); + return col.hit_ob; } + + /* default to z=0 */ + VECCOPY(ground_co, pa->state.co); + ground_co[2] = 0; + ground_nor[0] = ground_nor[1] = 0.0f; + ground_nor[2] = 1.0f; + return NULL; } } static int boid_rule_applies(ParticleData *pa, BoidSettings *boids, BoidRule *rule) @@ -1226,8 +1250,8 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) VECADDFAC(pa->state.vel, pa->state.vel, acc, dtime); - if(bpa->data.mode != eBoidMode_InAir) - bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor); + //if(bpa->data.mode != eBoidMode_InAir) + bpa->ground = boid_find_ground(bbd, pa, ground_co, ground_nor); /* change modes, constrain movement & keep track of down vector */ switch(bpa->data.mode) { @@ -1255,11 +1279,18 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) boid_find_ground(bbd, pa, ground_co, ground_nor); boid_climb(boids, pa, ground_co, ground_nor); } - /* land boid when belowg ground */ - else if(boids->options & BOID_ALLOW_LAND && pa->state.co[2] <= ground_co[2] + pa->size * boids->height) { - pa->state.co[2] = ground_co[2] + pa->size * boids->height; - pa->state.vel[2] = 0.0f; - bpa->data.mode = eBoidMode_OnLand; + else if(pa->state.co[2] <= ground_co[2] + pa->size * boids->height) { + /* land boid when below ground */ + if(boids->options & BOID_ALLOW_LAND) { + pa->state.co[2] = ground_co[2] + pa->size * boids->height; + pa->state.vel[2] = 0.0f; + bpa->data.mode = eBoidMode_OnLand; + } + /* fly above ground */ + else { + pa->state.co[2] = ground_co[2] + pa->size * boids->height; + pa->state.vel[2] = 0.0f; + } } break; } -- cgit v1.2.3 From e7a393d2e1a41d3332a1092a21bd8db1a5060cb6 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 16 Sep 2010 20:06:10 +0000 Subject: Tiny addition to boids functionality: pitch value * Controls maximum rotation around side vector (as opposed to banking, which controls rotation around forward vector) --- source/blender/blenkernel/intern/boids.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 5bf228b2392..e408f73e6c8 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -1386,7 +1386,9 @@ 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) { - normalize_v3_v3(pa->state.ave, pa->state.vel); + copy_v3_v3(pa->state.ave, pa->state.vel); + pa->state.ave[2] *= bbd->part->boids->pitch; + normalize_v3(pa->state.ave); } /* apply damping */ @@ -1471,6 +1473,7 @@ void boid_default_settings(BoidSettings *boids) boids->landing_smoothness = 3.0f; boids->banking = 1.0f; + boids->pitch = 1.0f; boids->height = 1.0f; boids->health = 1.0f; -- cgit v1.2.3 From 7d0e17922a817d940121d8eaf9f0812ece98b16e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 16 Sep 2010 20:33:46 +0000 Subject: Fix compile error after last commit in boids. --- source/blender/blenkernel/intern/boids.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index e408f73e6c8..69a42e52247 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -792,7 +792,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro } /* couldn't find below, so find upmost deflector object */ - add_v3_v3(col.co1, pa->state.co, zvec); + add_v3_v3v3(col.co1, pa->state.co, zvec); sub_v3_v3v3(col.co2, pa->state.co, zvec); sub_v3_v3(col.co2, zvec); sub_v3_v3v3(ray_dir, col.co2, col.co1); -- cgit v1.2.3 From e546d7666b753480995dc54c0cf68a3011dd28f0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 17 Sep 2010 05:58:06 +0000 Subject: minor changes needed for the next commit. - BKE_add_image_extension now sets the extension rather then appending. (no more image.jpg.tga) - py/rna functions which have no return value now raise an error if a non-None value is returned. - added back the red-alert flag so buttons can have a red highlight if somethings wrong. --- source/blender/blenkernel/intern/image.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index e77183d785f..f3dfd4292c6 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -757,9 +757,9 @@ int BKE_imtype_is_movie(int imtype) return 0; } -void BKE_add_image_extension(char *string, int imtype) +int BKE_add_image_extension(char *string, int imtype) { - char *extension=""; + char *extension= NULL; if(imtype== R_IRIS) { if(!BLI_testextensie(string, ".rgb")) @@ -830,7 +830,12 @@ void BKE_add_image_extension(char *string, int imtype) extension= ".jpg"; } - strcat(string, extension); + if(extension) { + return BLI_replace_extension(string, FILE_MAX, extension); + } + else { + return FALSE; + } } /* could allow access externally - 512 is for long names, 64 is for id names */ -- cgit v1.2.3 From 5452f335d7fd768fda7320419e3581e5309529fe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 17 Sep 2010 09:27:31 +0000 Subject: New optional operator function, check(), it takes the same arguments as execute(). This runs after changing a property and allows correcting incompatible options. Returning True will redraw the UI. Currently this is used for setting the write extension when saving files, so changing the image format also corrects the extension. The same is accessible from python where its used when saving SVG/EPS/PNG files. This fixes: [#23828] obj export problems, [#23760] Exporting OBJ and filetype ending also fixed document submission operator. Now the filename in the file selector is the one used for writing this means we remove the "Save Over" popup which could be overlooked too easily. Instead display the filename field with red tint, and a note in the tooltip. --- source/blender/blenkernel/intern/exotic.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 973c18531c4..9dac409226b 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -577,15 +577,8 @@ void write_stl(Scene *scene, char *str) FILE *fpSTL; int numfacets = 0; ReportList *reports= NULL; /* XXX */ - - if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0; - if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0; - if(BLI_testextensie(str,".stl")==0) strcat(str, ".stl"); - if (BLI_exists(str)) { - ; //XXX if(saveover(str)==0) - //XXX return; - } + /* XXX, operator needs to manage filename extension */ fpSTL= fopen(str, "wb"); @@ -872,15 +865,7 @@ void write_dxf(struct Scene *scene, char *str) Base *base; FILE *fp; - if(BLI_testextensie(str,".blend")) str[ strlen(str)-6]= 0; - if(BLI_testextensie(str,".ble")) str[ strlen(str)-4]= 0; - if(BLI_testextensie(str,".dxf")==0) strcat(str, ".dxf"); - - - if (BLI_exists(str)) { - ; //XXX if(saveover(str)==0) - // return; - } + /* XXX, operator needs to handle overwrite & rename */ fp= fopen(str, "w"); -- cgit v1.2.3 From 84dc5a3b94d033466692f6c878c6cb9054114fdc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 17 Sep 2010 13:52:38 +0000 Subject: bugfix [#23864] Bevel Modifier + UV crashes under certain conditions --- source/blender/blenkernel/intern/subsurf_ccg.c | 2 +- 1 file changed, 1 insertion(+), 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 4c85656dd91..d6486c3ee4d 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1421,7 +1421,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, v DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs); } - if(!doDraw || (setDrawOptions && !setDrawOptions(userData, origIndex))) { + if(!doDraw || (setDrawOptions && (origIndex != ORIGINDEX_NONE) && !setDrawOptions(userData, origIndex))) { a += gridFaces*gridFaces*numVerts; continue; } -- cgit v1.2.3 From b4a4c330540deeb7ea9e5f749e9fbf0768731b68 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 17 Sep 2010 19:02:19 +0000 Subject: Possible fix for all the particles related SIMD SVBVH bugs. * Velocity for particles that were born at exactly integer frames was calculated wrong when they were born. Note: If you had a raytrace acceleration related bug, please clear the pointcache for all particles, toggle a particle setting to reset pointcache and rebake to create a valid simulation. --- 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 598dd3c03fe..5318754951f 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3441,7 +3441,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) else if(part->phystype == PART_PHYS_NO) reset_particle(sim, pa, dtime, cfra); - if(dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){ + if(pa_dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){ switch(part->phystype){ case PART_PHYS_NEWTON: /* do global forces & effectors */ -- cgit v1.2.3 From dea59cc5eb6562272df361c062f7ed226c2b7a36 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Sep 2010 03:55:56 +0000 Subject: warning fixes and minor cmake changes. --- source/blender/blenkernel/intern/effect.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 0da5e0da2c4..4860e7d8eed 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -86,7 +86,6 @@ #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_scene.h" -#include "BKE_screen.h" #include "BKE_utildefines.h" #include "RE_render_ext.h" -- cgit v1.2.3 From b6554136899ef4c86436c42cf0a6d48db090dc93 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Sep 2010 04:08:40 +0000 Subject: bugfix [#23884] Crash On Delete of a Duplicated Object --- source/blender/blenkernel/intern/object.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e2dbae92d5c..bd9651cf381 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1338,6 +1338,8 @@ Object *copy_object(Object *ob) obn->gpulamp.first = obn->gpulamp.last = NULL; obn->pc_ids.first = obn->pc_ids.last = NULL; + + obn->mpath= NULL; return obn; } -- cgit v1.2.3 From a45797fe55cde7e25d601391b3f41ac7a88f4ec6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 18 Sep 2010 14:47:59 +0000 Subject: bugfix [#22767] parenting object causes rotation/scale/location information to be corrupted --- source/blender/blenkernel/intern/object.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index bd9651cf381..f45c0717b26 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1690,11 +1690,29 @@ void object_mat3_to_rot(Object *ob, float mat[][3], int use_compat) /* see pchan_apply_mat4() for the equivalent 'pchan' function */ void object_apply_mat4(Object *ob, float mat[][4]) { - float mat3[3][3]; + float mat3[3][3], tmat[3][3], imat[3][3]; + + /* location */ copy_v3_v3(ob->loc, mat[3]); - mat4_to_size(ob->size, mat); + + /* rotation */ copy_m3_m4(mat3, mat); object_mat3_to_rot(ob, mat3, 0); + + /* scale */ +#if 0 + /* works fine except for neg scales */ + mat4_to_size(ob->size, mat); +#else + /* this is more complicated but works for negative scales */ + object_rot_to_mat3(ob, tmat); + invert_m3_m3(imat, tmat); + mul_m3_m3m3(tmat, imat, mat3); + + ob->size[0]= tmat[0][0]; + ob->size[1]= tmat[1][1]; + ob->size[2]= tmat[2][2]; +#endif } void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ -- cgit v1.2.3 From 2c5aba0c9f25927871b7d35896ac806b4ac8f5d0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Sep 2010 06:47:34 +0000 Subject: bugfix [#22263] Child of constraint - only rotation --- source/blender/blenkernel/intern/constraint.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 57e5630da19..dd32d22d09f 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -850,7 +850,14 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta * the effect of this constraint (i.e. owner is 'parented' to parent) */ copy_m4_m4(tempmat, cob->matrix); - mul_m4_m4m4(cob->matrix, tempmat, parmat); + mul_m4_m4m4(cob->matrix, tempmat, parmat); + + /* without this, changes to scale and rotation can change location + * of a parentless bone or a disconnected bone. Even though its set + * to zero above. */ + if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0]= tempmat[3][0]; + if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1]= tempmat[3][1]; + if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2]= tempmat[3][2]; } } -- cgit v1.2.3 From 7f76c2eab1e4e7accc499f3163f8c2c923f70cde Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Sep 2010 09:09:00 +0000 Subject: bugfix [#20576] Curve modifier and loop cut Quaternion interpolation was skipped which gave ugly stepping with the curve modifier (broke with my curve twist fix) --- source/blender/blenkernel/intern/anim.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 98bdf3b2e9f..6da9f2bbabc 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -640,29 +640,19 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, /* Need to verify the quat interpolation is correct - XXX */ if (quat) { - //float totfac, q1[4], q2[4]; + float totfac, q1[4], q2[4]; - /* checks for totfac are needed when 'fac' is 1.0 key_curve_position_weights can assign zero - * to more then one index in data which can give divide by zero error */ -/* - totfac= data[0]+data[1]; - if(totfac>0.000001) interp_qt_qtqt(q1, p0->quat, p1->quat, data[0] / totfac); - else QUATCOPY(q1, p1->quat); + totfac= data[0]+data[3]; + if(totfac>FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac); + else QUATCOPY(q1, p1->quat); - normalize_qt(q1); - - totfac= data[2]+data[3]; - if(totfac>0.000001) interp_qt_qtqt(q2, p2->quat, p3->quat, data[2] / totfac); - else QUATCOPY(q1, p3->quat); - normalize_qt(q2); + totfac= data[1]+data[2]; + if(totfac>FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac); + else QUATCOPY(q1, p3->quat); totfac = data[0]+data[1]+data[2]+data[3]; - if(totfac>0.000001) interp_qt_qtqt(quat, q1, q2, (data[0]+data[1]) / totfac); - else QUATCOPY(quat, q2); - normalize_qt(quat); - */ - // XXX - find some way to make quat interpolation work correctly, above code fails in rare but nasty cases. - QUATCOPY(quat, p1->quat); + if(totfac>FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1]+data[2]) / totfac); + else QUATCOPY(quat, q2); } if(radius) -- cgit v1.2.3 From b859d355c8dae6ea778f700a412b2eb8ce0417ad Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Sep 2010 13:35:55 +0000 Subject: bugfix [#23739] # (hash) character can't be used in image filenames images would convert hashes to numbers on load but it didnt update properly and this is what image sequences is for. --- source/blender/blenkernel/intern/image.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index f3dfd4292c6..3d16b40a8a6 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1777,8 +1777,6 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) else BLI_path_abs(str, G.sce); - BLI_path_frame(str, cfra, 0); - /* read ibuf */ ibuf = IMB_loadiffname(str, flag); } -- cgit v1.2.3 From b0f36f0317a3b4529f325d6ed96c91d36c22f557 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Sep 2010 02:36:14 +0000 Subject: patch [#23796] Full support for unit buttons: area, volume, mass, velocity and acceleration by Lorenzo Tozzi (oni_niubbo) --- source/blender/blenkernel/intern/unit.c | 184 +++++++++++++++++++++++++++----- 1 file changed, 158 insertions(+), 26 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 36a4cfea7a0..75be48cc885 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -39,8 +39,37 @@ #define SEP_CHR '#' #define SEP_STR "#" -#define EPS 0.000001 - +#define EPS 0.00001 + +#define UN_SC_KM 1000.0f +#define UN_SC_HM 100.0f +#define UN_SC_DAM 10.0f +#define UN_SC_M 1.0f +#define UN_SC_DM 0.1f +#define UN_SC_CM 0.01f +#define UN_SC_MM 0.001f +#define UN_SC_UM 0.000001f + +#define UN_SC_MI 1609.344f +#define UN_SC_FUR 201.168f +#define UN_SC_CH 20.1168f +#define UN_SC_YD 0.9144f +#define UN_SC_FT 0.3048f +#define UN_SC_IN 0.0254f +#define UN_SC_MIL 0.0000254f + +#define UN_SC_MTON 1000.0f /* metric ton */ +#define UN_SC_QL 100.0f +#define UN_SC_KG 1.0f +#define UN_SC_HG 0.1f +#define UN_SC_DAG 0.01f +#define UN_SC_G 0.001f + +#define UN_SC_ITON 907.18474f /* imperial ton */ +#define UN_SC_CWT 45.359237f +#define UN_SC_ST 6.35029318f +#define UN_SC_LB 0.45359237f +#define UN_SC_OZ 0.028349523125f /* define a single unit */ typedef struct bUnitDef { @@ -63,7 +92,7 @@ typedef struct bUnitDef { /* define a single unit */ typedef struct bUnitCollection { struct bUnitDef *units; - int base_unit; /* use for 0.0, or none given */ + int base_unit; /* basic unit index (when user desn't specify unit explicitly) */ int flag; /* options for this system */ int length; /* to quickly find the last item */ } bUnitCollection; @@ -78,14 +107,14 @@ static struct bUnitCollection buDummyCollecton = {buDummyDef, 0, 0, sizeof(buDum /* Lengths */ static struct bUnitDef buMetricLenDef[] = { - {"kilometer", "kilometers", "km", NULL, "Kilometers", 1000.0, 0.0, B_UNIT_DEF_NONE}, - {"hectometer", "hectometers", "hm", NULL, "100 Meters", 100.0, 0.0, B_UNIT_DEF_SUPPRESS}, - {"dekameter", "dekameters", "dam",NULL, "10 Meters", 10.0, 0.0, B_UNIT_DEF_SUPPRESS}, - {"meter", "meters", "m", NULL, "Meters", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"decimetre", "decimetres", "dm", NULL, "10 Centimeters", 0.1, 0.0, B_UNIT_DEF_SUPPRESS}, - {"centimeter", "centimeters", "cm", NULL, "Centimeters", 0.01, 0.0, B_UNIT_DEF_NONE}, - {"millimeter", "millimeters", "mm", NULL, "Millimeters", 0.001, 0.0, B_UNIT_DEF_NONE}, - {"micrometer", "micrometers", "µm", "um", "Micrometers", 0.000001, 0.0, B_UNIT_DEF_NONE}, // micron too? + {"kilometer", "kilometers", "km", NULL, "Kilometers", UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"hectometer", "hectometers", "hm", NULL, "100 Meters", UN_SC_HM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"dekameter", "dekameters", "dam",NULL, "10 Meters", UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"meter", "meters", "m", NULL, "Meters", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"decimetre", "decimetres", "dm", NULL, "10 Centimeters", UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"centimeter", "centimeters", "cm", NULL, "Centimeters", UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"millimeter", "millimeters", "mm", NULL, "Millimeters", UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"micrometer", "micrometers", "µm", "um", "Micrometers", UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, // micron too? /* These get displayed because of float precision problems in the transform header, * could work around, but for now probably people wont use these */ @@ -98,17 +127,121 @@ static struct bUnitDef buMetricLenDef[] = { static struct bUnitCollection buMetricLenCollecton = {buMetricLenDef, 3, 0, sizeof(buMetricLenDef)/sizeof(bUnitDef)}; static struct bUnitDef buImperialLenDef[] = { - {"mile", "miles", "mi", "m", "Miles", 1609.344, 0.0, B_UNIT_DEF_NONE}, - {"furlong", "furlongs", "fur", NULL, "Furlongs",201.168, 0.0, B_UNIT_DEF_SUPPRESS}, - {"chain", "chains", "ch", NULL, "Chains", 0.9144*22.0, 0.0, B_UNIT_DEF_SUPPRESS}, - {"yard", "yards", "yd", NULL, "Yards", 0.9144, 0.0, B_UNIT_DEF_NONE}, - {"foot", "feet", "'", "ft", "Feet", 0.3048, 0.0, B_UNIT_DEF_NONE}, - {"inch", "inches", "\"", "in", "Inches", 0.0254, 0.0, B_UNIT_DEF_NONE}, /* base unit */ - {"thou", "thous", "mil", NULL, "Thous", 0.0000254, 0.0, B_UNIT_DEF_NONE}, + {"mile", "miles", "mi", "m", "Miles", UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, + {"furlong", "furlongs", "fur", NULL, "Furlongs",UN_SC_FUR, 0.0, B_UNIT_DEF_SUPPRESS}, + {"chain", "chains", "ch", NULL, "Chains", UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"yard", "yards", "yd", NULL, "Yards", UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, + {"foot", "feet", "'", "ft", "Feet", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"inch", "inches", "\"", "in", "Inches", UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"thou", "thous", "mil", NULL, "Thous", UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; static struct bUnitCollection buImperialLenCollecton = {buImperialLenDef, 4, 0, sizeof(buImperialLenDef)/sizeof(bUnitDef)}; +/* Areas */ +static struct bUnitDef buMetricAreaDef[] = { + {"square kilometer", "square kilometers", "km²", "km2", "Square Kilometers", UN_SC_KM*UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"square hectometer","square hectometers", "hm²", "hm2", "Square Hectometers", UN_SC_HM*UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, /* hectare */ + {"square dekameter", "square dekameters", "dam²","dam2", "Square Dekameters", UN_SC_DAM*UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, /* are */ + {"square meter", "square meters", "m²", "m2", "Square Meters", UN_SC_M*UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"square decimetre", "square decimetres", "dm²", "dm2", "Square Decimetres", UN_SC_DM*UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"square centimeter", "square centimeters", "cm²", "cm2", "Square Centimeters", UN_SC_CM*UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"square millimeter", "square millimeters", "mm²", "mm2", "Square Millimeters", UN_SC_MM*UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"square micrometer", "square micrometers", "µm²", "um2", "Square Micrometers", UN_SC_UM*UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buMetricAreaCollecton = {buMetricAreaDef, 3, 0, sizeof(buMetricAreaDef)/sizeof(bUnitDef)}; + +static struct bUnitDef buImperialAreaDef[] = { + {"square mile", "square miles", "sq mi", "sq m","Square Miles", UN_SC_MI*UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, + {"square furlong", "square furlongs", "sq fur",NULL, "Square Furlongs", UN_SC_FUR*UN_SC_FUR, 0.0,B_UNIT_DEF_SUPPRESS}, + {"square chain", "square chains", "sq ch", NULL, "Square Chains", UN_SC_CH*UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"square yard", "square yards", "sq yd", NULL, "Square Yards", UN_SC_YD*UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, + {"square foot", "square feet", "sq ft", NULL, "Square Feet", UN_SC_FT*UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"square inch", "square inches", "sq in", NULL, "Square Inches", UN_SC_IN*UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"square thou", "square thous", "sq mil",NULL, "Square Thous", UN_SC_MIL*UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buImperialAreaCollecton = {buImperialAreaDef, 4, 0, sizeof(buImperialAreaDef)/sizeof(bUnitDef)}; + +/* Volumes */ +static struct bUnitDef buMetricVolDef[] = { + {"cubic kilometer", "cubic kilometers", "km³", "km3", "Cubic Kilometers", UN_SC_KM*UN_SC_KM*UN_SC_KM, 0.0, B_UNIT_DEF_NONE}, + {"cubic hectometer","cubic hectometers", "hm³", "hm3", "Cubic Hectometers", UN_SC_HM*UN_SC_HM*UN_SC_HM, 0.0, B_UNIT_DEF_NONE}, + {"cubic dekameter", "cubic dekameters", "dam³","dam3", "Cubic Dekameters", UN_SC_DAM*UN_SC_DAM*UN_SC_DAM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic meter", "cubic meters", "m³", "m3", "Cubic Meters", UN_SC_M*UN_SC_M*UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"cubic decimetre", "cubic decimetres", "dm³", "dm3", "Cubic Decimetres", UN_SC_DM*UN_SC_DM*UN_SC_DM, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic centimeter", "cubic centimeters", "cm³", "cm3", "Cubic Centimeters", UN_SC_CM*UN_SC_CM*UN_SC_CM, 0.0, B_UNIT_DEF_NONE}, + {"cubic millimeter", "cubic millimeters", "mm³", "mm3", "Cubic Millimeters", UN_SC_MM*UN_SC_MM*UN_SC_MM, 0.0, B_UNIT_DEF_NONE}, + {"cubic micrometer", "cubic micrometers", "µm³", "um3", "Cubic Micrometers", UN_SC_UM*UN_SC_UM*UN_SC_UM, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buMetricVolCollecton = {buMetricVolDef, 3, 0, sizeof(buMetricVolDef)/sizeof(bUnitDef)}; + +static struct bUnitDef buImperialVolDef[] = { + {"cubic mile", "cubic miles", "cu mi", "cu m","Cubic Miles", UN_SC_MI*UN_SC_MI*UN_SC_MI, 0.0, B_UNIT_DEF_NONE}, + {"cubic furlong", "cubic furlongs", "cu fur",NULL, "Cubic Furlongs", UN_SC_FUR*UN_SC_FUR*UN_SC_FUR, 0.0,B_UNIT_DEF_SUPPRESS}, + {"cubic chain", "cubic chains", "cu ch", NULL, "Cubic Chains", UN_SC_CH*UN_SC_CH*UN_SC_CH, 0.0, B_UNIT_DEF_SUPPRESS}, + {"cubic yard", "cubic yards", "cu yd", NULL, "Cubic Yards", UN_SC_YD*UN_SC_YD*UN_SC_YD, 0.0, B_UNIT_DEF_NONE}, + {"cubic foot", "cubic feet", "cu ft", NULL, "Cubic Feet", UN_SC_FT*UN_SC_FT*UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"cubic inch", "cubic inches", "cu in", NULL, "Cubic Inches", UN_SC_IN*UN_SC_IN*UN_SC_IN, 0.0, B_UNIT_DEF_NONE}, + {"cubic thou", "cubic thous", "cu mil",NULL, "Cubic Thous", UN_SC_MIL*UN_SC_MIL*UN_SC_MIL, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buImperialVolCollecton = {buImperialVolDef, 4, 0, sizeof(buImperialVolDef)/sizeof(bUnitDef)}; + +/* Mass */ +static struct bUnitDef buMetricMassDef[] = { + {"ton", "tonnes", "ton", "t", "1000 Kilograms", UN_SC_MTON, 0.0, B_UNIT_DEF_NONE}, + {"quintal", "quintals", "ql", "q", "100 Kilograms", UN_SC_QL, 0.0, B_UNIT_DEF_NONE}, + {"kilogram", "kilograms", "kg", NULL, "Kilograms", UN_SC_KG, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"hectogram", "hectograms", "hg", NULL, "Hectograms", UN_SC_HG, 0.0, B_UNIT_DEF_NONE}, + {"dekagram", "dekagrams", "dag",NULL, "10 Grams", UN_SC_DAG, 0.0, B_UNIT_DEF_SUPPRESS}, + {"gram", "grams", "g", NULL, "Grams", UN_SC_G, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buMetricMassCollecton = {buMetricMassDef, 2, 0, sizeof(buMetricMassDef)/sizeof(bUnitDef)}; + +static struct bUnitDef buImperialMassDef[] = { + {"ton", "tonnes", "ton", "t", "Tonnes", UN_SC_ITON, 0.0, B_UNIT_DEF_NONE}, + {"centum weight", "centum weights", "cwt", NULL, "Centum weights", UN_SC_CWT, 0.0, B_UNIT_DEF_NONE}, + {"stone", "stones", "st", NULL, "Stones", UN_SC_ST, 0.0, B_UNIT_DEF_NONE}, + {"pound", "pounds", "lb", NULL, "Pounds", UN_SC_LB, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"ounce", "ounces", "oz", NULL, "Ounces", UN_SC_OZ, 0.0, B_UNIT_DEF_NONE}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buImperialMassCollecton = {buImperialMassDef, 3, 0, sizeof(buImperialMassDef)/sizeof(bUnitDef)}; + +/* Even if user scales the system to a point where km^3 is used, velocity and + * acceleration aren't scaled: that's why we have so few units for them */ + +/* Velocity */ +static struct bUnitDef buMetricVelDef[] = { + {"meter per second", "meters per second", "m/s", NULL, "Meters per second", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"kilometer per hour", "kilometers per hour", "km/h", NULL, "Kilometers per hour", UN_SC_KM/3600.0f, 0.0, B_UNIT_DEF_SUPPRESS}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buMetricVelCollecton = {buMetricVelDef, 0, 0, sizeof(buMetricVelDef)/sizeof(bUnitDef)}; + +static struct bUnitDef buImperialVelDef[] = { + {"foot per second", "feet per second", "ft/s", "fps", "Feet per second", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {"mile per hour", "miles per hour", "mph", NULL, "Miles per hour", UN_SC_MI/3600.0f, 0.0,B_UNIT_DEF_SUPPRESS}, + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buImperialVelCollecton = {buImperialVelDef, 0, 0, sizeof(buImperialVelDef)/sizeof(bUnitDef)}; + +/* Acceleration */ +static struct bUnitDef buMetricAclDef[] = { + {"meter per second squared", "meters per second squared", "m/s²", "m/s2", "Meters per second squared", UN_SC_M, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buMetricAclCollecton = {buMetricAclDef, 0, 0, sizeof(buMetricAclDef)/sizeof(bUnitDef)}; + +static struct bUnitDef buImperialAclDef[] = { + {"foot per second squared", "feet per second squared", "ft/s²", "ft/s2", "Feet per second squared", UN_SC_FT, 0.0, B_UNIT_DEF_NONE}, /* base unit */ + {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} +}; +static struct bUnitCollection buImperialAclCollecton = {buImperialAclDef, 0, 0, sizeof(buImperialAclDef)/sizeof(bUnitDef)}; /* Time */ static struct bUnitDef buNaturalTimeDef[] = { @@ -118,7 +251,7 @@ static struct bUnitDef buNaturalTimeDef[] = { {"minute", "minutes", "min", "m", "Minutes", 60.0, 0.0, B_UNIT_DEF_NONE}, {"second", "seconds", "sec", "s", "Seconds", 1.0, 0.0, B_UNIT_DEF_NONE}, /* base unit */ {"millisecond", "milliseconds", "ms", NULL, "Milliseconds", 0.001, 0.0 , B_UNIT_DEF_NONE}, - {"microsecond", "microseconds", "us", NULL, "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, + {"microsecond", "microseconds", "µs", "us", "Microseconds", 0.000001, 0.0, B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, sizeof(buNaturalTimeDef)/sizeof(bUnitDef)}; @@ -130,13 +263,12 @@ static struct bUnitDef buNaturalRotDef[] = { }; static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; -#define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 8) / sizeof(void *)) - 1) - -static struct bUnitCollection *bUnitSystems[][8] = { - {0,0,0,0,0,&buNaturalRotCollection,&buNaturalTimeCollecton,0}, - {0,&buMetricLenCollecton, 0,0,0, &buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* metric */ - {0,&buImperialLenCollecton, 0,0,0,&buNaturalRotCollection, &buNaturalTimeCollecton,0}, /* imperial */ - {0,0,0,0,0,0,0,0} +#define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 9) / sizeof(void *)) - 1) +static struct bUnitCollection *bUnitSystems[][9] = { + {0, 0, 0, 0, 0, &buNaturalRotCollection, &buNaturalTimeCollecton, 0, 0}, + {0, &buMetricLenCollecton, &buMetricAreaCollecton, &buMetricVolCollecton, &buMetricMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buMetricVelCollecton, &buMetricAclCollecton}, /* metric */ + {0, &buImperialLenCollecton, &buImperialAreaCollecton, &buImperialVolCollecton, &buImperialMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buImperialVelCollecton, &buImperialAclCollecton}, /* imperial */ + {0, 0, 0, 0, 0, 0, 0, 0, 0} }; -- cgit v1.2.3 From e4f3a0efa6cc2fdb6762adb4e9d534b33978cf81 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Sep 2010 02:44:03 +0000 Subject: patch [#23796] Full support for unit buttons: area, volume, mass, velocity and acceleration from Lorenzo Tozzi (oni_niubbo), multiple patches: better_split.diff --- source/blender/blenkernel/intern/unit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 75be48cc885..de22a0e347c 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -395,8 +395,9 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system, if(usys==NULL || usys->units[0].name==NULL) usys= &buDummyCollecton; - - if(split) { + + /* split output makes sense only for length, mass and time */ + if(split && (type==B_UNIT_LENGTH || type==B_UNIT_MASS || type==B_UNIT_TIME)) { int i; bUnitDef *unit_a, *unit_b; double value_a, value_b; -- cgit v1.2.3 From d2bc4a31a05ecac6770ba198490124ee38b42498 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Sep 2010 02:47:08 +0000 Subject: patch [#23796] Full support for unit buttons: area, volume, mass, velocity and acceleration from Lorenzo Tozzi (oni_niubbo), suppress_only_shown.diff --- source/blender/blenkernel/intern/unit.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index de22a0e347c..3d984c7e877 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -583,10 +583,6 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre for(unit= usys->units; unit->name; unit++) { - - if(unit->flag & B_UNIT_DEF_SUPPRESS) - continue; - /* incase there are multiple instances */ while(unit_replace(str, len_max, str_tmp, scale_pref, unit)) change= 1; @@ -603,13 +599,10 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre usys_iter= unit_get_system(system_iter, type); if (usys_iter) { for(unit= usys_iter->units; unit->name; unit++) { - - if((unit->flag & B_UNIT_DEF_SUPPRESS) == 0) { - int ofs = 0; - /* incase there are multiple instances */ - while((ofs=unit_replace(str+ofs, len_max-ofs, str_tmp, scale_pref, unit))) - change= 1; - } + int ofs = 0; + /* incase there are multiple instances */ + while((ofs=unit_replace(str+ofs, len_max-ofs, str_tmp, scale_pref, unit))) + change= 1; } } } @@ -622,10 +615,6 @@ int bUnit_ReplaceString(char *str, int len_max, char *str_prev, double scale_pre if(str_prev) { /* see which units the original value had */ for(unit= usys->units; unit->name; unit++) { - - if(unit->flag & B_UNIT_DEF_SUPPRESS) - continue; - if (unit_find(str_prev, unit)) break; } -- cgit v1.2.3 From 916085247ac4a6d10d8597b1bf7b847903102ce4 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 22 Sep 2010 05:08:52 +0000 Subject: Fix #23925: converting text into a curve looses materials filldisplist worked incorrect with polys when charidx matched but col doesn't Also fixed material loose when converting text/curve to mesh --- source/blender/blenkernel/intern/displist.c | 62 +++++++++++++++++------------ source/blender/blenkernel/intern/mesh.c | 1 + 2 files changed, 37 insertions(+), 26 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index a44c5ace298..d0336d9f786 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -930,7 +930,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) EditFace *efa; DispList *dlnew=0, *dl; float *f1; - int colnr=0, charidx=0, cont=1, tot, a, *index; + int colnr=0, charidx=0, cont=1, tot, a, *index, nextcol= 0; intptr_t totvert; if(dispbase==0) return; @@ -938,38 +938,41 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) while(cont) { cont= 0; - totvert=0; + totvert= 0; + nextcol= 0; dl= dispbase->first; while(dl) { if(dl->type==DL_POLY) { if(charidxcharidx) cont= 1; - else if(charidx==dl->charidx) { - - colnr= dl->col; - charidx= dl->charidx; - - /* make editverts and edges */ - f1= dl->verts; - a= dl->nr; - eve= v1= 0; - - while(a--) { - vlast= eve; - - eve= BLI_addfillvert(f1); - totvert++; + else if(charidx==dl->charidx) { /* character with needed index */ + if(colnr==dl->col) { + /* make editverts and edges */ + f1= dl->verts; + a= dl->nr; + eve= v1= 0; - if(vlast==0) v1= eve; - else { - BLI_addfilledge(vlast, eve); + while(a--) { + vlast= eve; + + eve= BLI_addfillvert(f1); + totvert++; + + if(vlast==0) v1= eve; + else { + BLI_addfilledge(vlast, eve); + } + f1+=3; } - f1+=3; - } - - if(eve!=0 && v1!=0) { - BLI_addfilledge(eve, v1); + + if(eve!=0 && v1!=0) { + BLI_addfilledge(eve, v1); + } + } else if (colnrcol) { + /* got poly with next material at current char */ + cont= 1; + nextcol= 1; } } } @@ -1032,7 +1035,14 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) } BLI_end_edgefill(); - charidx++; + if(nextcol) { + /* stay at current char but fill polys with next material */ + colnr++; + } else { + /* switch to next char and start filling from first material */ + charidx++; + colnr= 0; + } } /* do not free polys, needed for wireframe display */ diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 2f8553b06b3..e9cc21d6887 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -854,6 +854,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int mface->v2= startvert+index[2]; mface->v3= startvert+index[1]; mface->v4= 0; + mface->mat_nr= (unsigned char)dl->col; test_index_face(mface, NULL, 0, 3); if(smooth) mface->flag |= ME_SMOOTH; -- cgit v1.2.3 From b6d28b585001bcee99e60660454313ca63d104c4 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 22 Sep 2010 09:38:11 +0000 Subject: Fix for [#21718] Shrinkwrap's "Project" mode with offset gives wrong results. * normal offset not taken properly into account * wrong usage of BVHTree (epsilon != radius) caused massive slowdowns in calculations, for example just opening test file took about 30 s on my machine, after fix about 0.5 s :) --- source/blender/blenkernel/intern/shrinkwrap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 01652aaa713..f64854f90de 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -337,7 +337,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S } //After sucessufuly build the trees, start projection vertexs - if( bvhtree_from_mesh_faces(&treeData, calc->target, calc->keepDist, 4, 6) + if( bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 4, 6) && (auxMesh == NULL || bvhtree_from_mesh_faces(&auxData, auxMesh, 0.0, 4, 6))) { @@ -383,6 +383,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData); + + if(hit.index != -1) + madd_v3_v3v3fl(hit.co, hit.co, tmp_no, -calc->keepDist); } //Project over negative direction of axis @@ -395,6 +398,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S normal_projection_project_vertex(0, tmp_co, inv_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData); + + if(hit.index != -1) + madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist); } -- cgit v1.2.3 From 6bb0fc3e4fd494acf43111264e2097809a5daf61 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 22 Sep 2010 15:39:43 +0000 Subject: minor changes to text3d editing, skip wchar --> utf-8 conversion on cursor movement. --- source/blender/blenkernel/intern/font.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index c0a60ea6294..47627d09b97 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -1146,7 +1146,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) return NULL; } - if(mode==0) { + if(mode == FO_EDIT) { /* make nurbdata */ unsigned long cha; -- cgit v1.2.3 From db47803de42a5b1ae4e6cd381fa5908b33f96721 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Sep 2010 01:48:31 +0000 Subject: bugfix [#23954] Bone roll keeps changing when switching between EDIT <-> OBJECT mode use lower epsilon value. --- source/blender/blenkernel/intern/armature.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 41821f34ba8..bfd12f7cc5d 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1289,7 +1289,9 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) /* Find Axis & Amount for bone matrix*/ cross_v3_v3v3(axis,target,nor); - if (dot_v3v3(axis,axis) > 0.0000000000001) { + /* was 0.0000000000001, caused bug [#23954], larger values give unstable + * when toggling editmode */ + if (dot_v3v3(axis,axis) > 0.00001) { /* if nor is *not* a multiple of target ... */ normalize_v3(axis); -- cgit v1.2.3 From 2b9a73ff9831aed988bde26ca1fce474ace01cf6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Sep 2010 02:12:33 +0000 Subject: - py/rna's path_resolve function was ignoring the index eg: obj.path_resolve("location[1]") - corrected comment from previous commit --- source/blender/blenkernel/intern/armature.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index bfd12f7cc5d..2e760f53155 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1289,8 +1289,8 @@ void vec_roll_to_mat3(float *vec, float roll, float mat[][3]) /* Find Axis & Amount for bone matrix*/ cross_v3_v3v3(axis,target,nor); - /* was 0.0000000000001, caused bug [#23954], larger values give unstable - * when toggling editmode */ + /* was 0.0000000000001, caused bug [#23954], smaller values give unstable + * roll when toggling editmode */ if (dot_v3v3(axis,axis) > 0.00001) { /* if nor is *not* a multiple of target ... */ normalize_v3(axis); -- cgit v1.2.3 From 7cbed194f425761fbc85b4dd584bad9249c1fd93 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 23 Sep 2010 09:31:13 +0000 Subject: Fix for [#23872] particle deflection in conjunction with SPH particles is apparently buggy * Fix turned into a thorough cleanup and reorganization of particle collision response code. * Collisions are now much more accurate, stable and even a bit more in agreement with real world physics. * Only still remaining problem is rotating/deforming deflector objects, but that's something for the future. * Visible changes should only be positive, i.e. no leaking particles, no strange instabilities etc. --- source/blender/blenkernel/intern/particle_system.c | 271 +++++++++++---------- 1 file changed, 143 insertions(+), 128 deletions(-) (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 5318754951f..3b9ad8d84ec 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2837,11 +2837,18 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B } while(t2); } -/* particle - mesh collision code */ -/* in addition to basic point to surface collisions handles friction & damping,*/ -/* angular momentum <-> linear momentum and swept sphere - mesh collisions */ -/* 1. check for all possible deflectors for closest intersection on particle path */ -/* 2. if deflection was found kill the particle or calculate new coordinates */ +/* Particle - Mesh collision code + * Features: + * - point and swept sphere to mesh surface collisions + * - moving colliders (but not yet rotating or deforming colliders) + * - friction & damping + * - angular momentum <-> linear momentum + * - high accuracy by re-applying particle acceleration after collision + * - behaves relatively well even if limit of 10 collisions per simulation step is exceeded + * Main parts: + * 1. check for all possible deflectors for closest intersection on particle path + * 2. if deflection was found calculate new coordinates or kill the particle + */ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, float cfra){ Object *ground_ob = NULL; ParticleSettings *part = sim->psys->part; @@ -2849,19 +2856,21 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo ParticleCollision col; ColliderCache *coll; BVHTreeRayHit hit; - float ray_dir[3], zerovec[3]={0.0,0.0,0.0}; + float ray_dir[3], acc[3]; float radius = ((part->flag & PART_SIZE_DEFL)?pa->size:0.0f), boid_z = 0.0f; - float timestep = psys_get_timestep(sim); + float timestep = psys_get_timestep(sim) * dfra; + float inv_timestep = 1.0f/timestep; int deflections=0, max_deflections=10; - VECCOPY(col.co1, pa->prev_state.co); - VECCOPY(col.co2, pa->state.co); - - VECCOPY(col.ve1, pa->prev_state.vel); - VECCOPY(col.ve2, pa->state.vel); - mul_v3_fl(col.ve1, timestep * dfra); - mul_v3_fl(col.ve2, timestep * dfra); - + /* get acceleration (from gravity, forcefields etc. to be re-applied after collision) */ + sub_v3_v3v3(acc, pa->state.vel, pa->prev_state.vel); + mul_v3_fl(acc, inv_timestep); + + /* set values for first iteration */ + copy_v3_v3(col.co1, pa->prev_state.co); + copy_v3_v3(col.co2, pa->state.co); + copy_v3_v3(col.ve1, pa->prev_state.vel); + copy_v3_v3(col.ve2, pa->state.vel); col.t = 0.0f; /* override for boids */ @@ -2876,7 +2885,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo if(sim->colliders) while(deflections < max_deflections){ /* 1. */ - VECSUB(ray_dir, col.co2, col.co1); + sub_v3_v3v3(ray_dir, col.co2, col.co1); hit.index = -1; hit.dist = col.ray_len = len_v3(ray_dir); @@ -2904,45 +2913,49 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* 2. */ if(hit.index>=0) { PartDeflect *pd = col.hit_ob->pd; - int through = (BLI_frand() < pd->pdef_perm) ? 1 : 0; float co[3]; /* point of collision */ - float vec[3]; /* movement through collision */ - float acc[3]; /* acceleration */ - float x = hit.dist/col.ray_len; /* location of collision between this iteration */ - float le = len_v3(col.ve1)/col.ray_len; - float ac = len_v3(col.ve2)/col.ray_len - le; /* (taking acceleration into account) */ - float t = (-le + sqrt(le*le + 2*ac*x))/ac; /* time of collision between this iteration */ - float dt = col.t + x * (1.0f - col.t); /* time of collision between frame change*/ - float it = 1.0 - t; + float df = col.t + x * (1.0f - col.t); /* time of collision between frame change*/ + float dt1 = (df - col.t) * timestep; /* iteration time of collision (in seconds) */ + float dt2 = (1.0f - df) * timestep; /* time left after collision (in seconds) */ + int through = (BLI_frand() < pd->pdef_perm) ? 1 : 0; /* did particle pass through the collision surface? */ + + deflections++; interp_v3_v3v3(co, col.co1, col.co2, x); - VECSUB(vec, col.co2, col.co1); - - VECSUB(acc, col.ve2, col.ve1); - mul_v3_fl(col.vel, 1.0f-col.t); + /* make sure we don't hit the current face again */ + /* TODO: could/should this be proportional to pa->size? */ + madd_v3_v3fl(co, col.nor, (through ? -0.0001f : 0.0001f)); /* particle dies in collision */ if(through == 0 && (part->flag & PART_DIE_ON_COL || pd->flag & PDEFLE_KILL_PART)) { pa->alive = PARS_DYING; - pa->dietime = pa->state.time + (cfra - pa->state.time) * dt; - - /* we have to add this for dying particles too so that reactors work correctly */ - VECADDFAC(co, co, col.nor, (through ? -0.0001f : 0.0001f)); + pa->dietime = pa->state.time + (cfra - pa->state.time) * df; - VECCOPY(pa->state.co, co); - interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, dt); - interp_qt_qtqt(pa->state.rot, pa->prev_state.rot, pa->state.rot, dt); - interp_v3_v3v3(pa->state.ave, pa->prev_state.ave, pa->state.ave, dt); + copy_v3_v3(pa->state.co, co); + interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, df); + interp_qt_qtqt(pa->state.rot, pa->prev_state.rot, pa->state.rot, df); + interp_v3_v3v3(pa->state.ave, pa->prev_state.ave, pa->state.ave, df); /* particle is dead so we don't need to calculate further */ - deflections=max_deflections; + return; } + /* figure out velocity and other data after collision */ else { - float nor_vec[3], tan_vec[3], tan_vel[3]; + float v0[3]; /* velocity directly before collision to be modified into velocity directly after collision */ + float v0_nor[3];/* normal component of v0 */ + float v0_tan[3];/* tangential component of v0 */ + float vc_tan[3];/* tangential component of collision surface velocity */ + float check[3]; + float v0_dot, vc_dot, check_dot; float damp, frict; - float inp, inp_v; + + /* get exact velocity right before collision */ + madd_v3_v3v3fl(v0, col.ve1, acc, dt1); + + /* convert collider velocity from 1/framestep to 1/s */ + mul_v3_fl(col.vel, inv_timestep); /* get damping & friction factors */ damp = pd->pdef_damp + pd->pdef_rdamp * 2 * (BLI_frand() - 0.5f); @@ -2952,119 +2965,118 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo CLAMP(frict,0.0,1.0); /* treat normal & tangent components separately */ - inp = dot_v3v3(col.nor, vec); - inp_v = dot_v3v3(col.nor, col.vel); + v0_dot = dot_v3v3(col.nor, v0); + madd_v3_v3v3fl(v0_tan, v0, col.nor, -v0_dot); - VECADDFAC(tan_vec, vec, col.nor, -inp); - VECADDFAC(tan_vel, col.vel, col.nor, -inp_v); - if((part->flag & PART_ROT_DYN)==0) - interp_v3_v3v3(tan_vec, tan_vec, tan_vel, frict); + vc_dot = dot_v3v3(col.nor, col.vel); + madd_v3_v3v3fl(vc_tan, col.vel, col.nor, -vc_dot); - VECCOPY(nor_vec, col.nor); - inp *= 1.0f - damp; - - if(through) - inp_v *= damp; - - /* special case for object hitting the particle from behind */ - if(through==0 && ((inp_v>0 && inp>0 && inp_v>inp) || (inp_v<0 && inp<0 && inp_v linear velocity - slightly more physical and looks even nicer than before */ - if(part->flag & PART_ROT_DYN) { - float surface_vel[3], rot_vel[3], friction[3], dave[3], dvel[3]; - - /* apparent velocity along collision surface */ - VECSUB(surface_vel, tan_vec, tan_vel); + /* handle friction effects (tangential and angular velocity) */ + if(frict > 0.0f) { + /* angular <-> linear velocity */ + if(part->flag & PART_ROT_DYN) { + float vr_tan[3], v1_tan[3], ave[3]; + + /* linear velocity of particle surface */ + cross_v3_v3v3(vr_tan, col.nor, pa->state.ave); + mul_v3_fl(vr_tan, pa->size); - /* direction of rolling friction */ - cross_v3_v3v3(rot_vel, pa->state.ave, col.nor); - /* convert to current dt */ - mul_v3_fl(rot_vel, (timestep*dfra) * (1.0f - col.t)); - mul_v3_fl(rot_vel, pa->size); + /* change to coordinates that move with the collision plane */ + sub_v3_v3v3(v1_tan, v0_tan, vc_tan); + + /* The resulting velocity is a weighted average of particle cm & surface + * velocity. This weight (related to particle's moment of inertia) could + * be made a parameter for angular <-> linear conversion. + */ + madd_v3_v3fl(v1_tan, vr_tan, -0.4); + mul_v3_fl(v1_tan, 1.0f/1.4f); /* 1/(1+0.4) */ - /* apply sliding friction */ - VECSUB(surface_vel, surface_vel, rot_vel); - VECCOPY(friction, surface_vel); + /* rolling friction is around 0.01 of sliding friction (could be made a parameter) */ + mul_v3_fl(v1_tan, 1.0f - 0.01f * frict); - mul_v3_fl(surface_vel, 1.0 - frict); - mul_v3_fl(friction, frict); + /* surface_velocity is opposite to cm velocity */ + mul_v3_v3fl(vr_tan, v1_tan, -1.0f); - /* sliding changes angular velocity */ - cross_v3_v3v3(dave, col.nor, friction); - mul_v3_fl(dave, 1.0f/MAX2(pa->size, 0.001)); + /* get back to global coordinates */ + add_v3_v3(v1_tan, vc_tan); - /* we assume rolling friction is around 0.01 of sliding friction */ - mul_v3_fl(rot_vel, 1.0 - frict*0.01); + /* convert to angular velocity*/ + cross_v3_v3v3(ave, vr_tan, col.nor); + mul_v3_fl(ave, 1.0f/MAX2(pa->size, 0.001)); - /* change in angular velocity has to be added to the linear velocity too */ - cross_v3_v3v3(dvel, dave, col.nor); - mul_v3_fl(dvel, pa->size); - VECADD(rot_vel, rot_vel, dvel); + /* only friction will cause change in linear & angular velocity */ + interp_v3_v3v3(pa->state.ave, pa->state.ave, ave, frict); + interp_v3_v3v3(v0_tan, v0_tan, v1_tan, frict); + } + else { + /* just basic friction (unphysical due to the friction model used in Blender) */ + interp_v3_v3v3(v0_tan, v0_tan, vc_tan, frict); + } + } - VECADD(surface_vel, surface_vel, rot_vel); - VECADD(tan_vec, surface_vel, tan_vel); + /* stickness was possibly added before, so cancel that before calculating new normal velocity */ + /* otherwise particles go flying out of the surface because of high reversed sticky velocity */ + if(v0_dot < 0.0f) { + v0_dot += pd->pdef_stickness; + if(v0_dot > 0.0f) + v0_dot = 0.0f; + } - /* convert back to normal time */ - mul_v3_fl(dave, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); + /* damping and flipping of velocity around normal */ + v0_dot *= 1.0f - damp; + vc_dot *= through ? damp : 1.0f; - mul_v3_fl(pa->state.ave, 1.0 - frict*0.01); - VECADD(pa->state.ave, pa->state.ave, dave); - } + /* special case for object hitting the particle from behind */ + if(through==0 && ((vc_dot>0.0f && v0_dot>0.0f && vc_dot>v0_dot) || (vc_dot<0.0f && v0_dot<0.0f && vc_dotphystype == PART_PHYS_BOIDS && part->boids->options & BOID_ALLOW_LAND) { BoidParticle *bpa = pa->boid; if(bpa->data.mode == eBoidMode_OnLand || co[2] <= boid_z) { co[2] = boid_z; - vec[2] = 0.0f; + v0[2] = 0.0f; } } - - /* set coordinates for next iteration */ - /* apply acceleration to final position, but make sure particle stays above surface */ - madd_v3_v3v3fl(acc, vec, acc, it); - ac = dot_v3v3(acc, col.nor); - if((!through && ac < 0.0f) || (through && ac > 0.0f)) - madd_v3_v3fl(acc, col.nor, -ac); - - VECCOPY(col.co1, co); - VECADDFAC(col.co2, co, acc, it); - - VECCOPY(col.ve1, vec); - VECCOPY(col.ve2, acc); - - if(len_v3(vec) < 0.001 && len_v3v3(pa->state.co, pa->prev_state.co) < 0.001) { - /* kill speed to stop slipping */ - VECCOPY(pa->state.vel,zerovec); - VECCOPY(pa->state.co, co); - if(part->flag & PART_ROT_DYN) { - VECCOPY(pa->state.ave,zerovec); - } - } - else { - VECCOPY(pa->state.co, col.co2); - mul_v3_v3fl(pa->state.vel, acc, 1.0f/MAX2((timestep*dfra) * (1.0f - col.t), 0.00001)); - + if(deflections < max_deflections) { + /* re-apply acceleration to final velocity and location */ + madd_v3_v3v3fl(pa->state.vel, v0, acc, dt2); + madd_v3_v3v3fl(pa->state.co, co, v0, dt2); + madd_v3_v3fl(pa->state.co, acc, 0.5f*dt2*dt2); + + /* make sure particle stays on the right side of the surface */ + sub_v3_v3v3(check, pa->state.co, co); + /* (collision surface has moved during the time too) */ + madd_v3_v3fl(check, col.vel, -dt2); + + check_dot = dot_v3v3(check, col.nor); + if((!through && check_dot < 0.0f) || (through && check_dot > 0.0f)) + madd_v3_v3fl(pa->state.co, col.nor, (through ? -0.0001f : 0.0001f) - check_dot); + /* Stickness to surface */ - normalize_v3(nor_vec); madd_v3_v3fl(pa->state.vel, col.nor, -pd->pdef_stickness); - } - col.t = dt; - } - deflections++; + /* set coordinates for next iteration */ + copy_v3_v3(col.co1, co); + copy_v3_v3(col.co2, pa->state.co); - //reaction_state.time = cfra - (1.0f - dt) * dfra; - //push_reaction(col.ob, psys, p, PART_EVENT_COLLIDE, &reaction_state); + copy_v3_v3(col.ve1, v0); + copy_v3_v3(col.ve2, pa->state.vel); + + col.t = df; + } + else { + /* final chance to prevent failure, so don't do anything fancy */ + copy_v3_v3(pa->state.co, co); + copy_v3_v3(pa->state.vel, v0); + } + } } else return; @@ -3346,6 +3358,8 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) /* frame & time changes */ float dfra, dtime, pa_dtime, pa_dfra=0.0; float birthtime, dietime; + + int invalidParticles=0; /* where have we gone in time since last time */ dfra= cfra - psys->cfra; @@ -3496,6 +3510,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) //push_reaction(ob,psys,p,PART_EVENT_NEAR,&pa->state); } + if (isnan(pa->state.co[0]) || isnan(pa->state.co[1]) || isnan(pa->state.co[2])) {invalidParticles++;} } free_collider_cache(&sim->colliders); -- cgit v1.2.3 From f88ad3f04894d37028bb35ffdbd39636d57a37cb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Sep 2010 12:03:34 +0000 Subject: bugfix [#23595] Texture paint with a node based brush produces artifacts also changed displace modifier not to link object depgraph when not using object texturespace. --- source/blender/blenkernel/intern/brush.c | 16 ++++++++-------- source/blender/blenkernel/intern/particle.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 90ea562be9d..c67db9382f3 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -480,7 +480,7 @@ int brush_clone_image_delete(Brush *brush) } /* Brush Sampling */ -void brush_sample_tex(Brush *brush, float *xy, float *rgba) +void brush_sample_tex(Brush *brush, float *xy, float *rgba, const int thread) { MTex *mtex= &brush->mtex; @@ -493,7 +493,7 @@ void brush_sample_tex(Brush *brush, float *xy, float *rgba) co[1]= xy[1]/radius; co[2]= 0.0f; - hasrgb= externtex(mtex, co, &tin, &tr, &tg, &tb, &ta); + hasrgb= externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, thread); if (hasrgb) { rgba[0]= tr; @@ -547,12 +547,12 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf dstf[3]= alpha*brush_curve_strength_clamp(brush, dist, radius); } else if (texfall == 1) { - brush_sample_tex(brush, xy, dstf); + brush_sample_tex(brush, xy, dstf, 0); } else { dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]); - brush_sample_tex(brush, xy, rgba); + brush_sample_tex(brush, xy, rgba, 0); dstf[0] = rgba[0]*brush->rgb[0]; dstf[1] = rgba[1]*brush->rgb[1]; @@ -583,7 +583,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf dst[3]= FTOCHAR(alpha*brush_curve_strength(brush, dist, radius)); } else if (texfall == 1) { - brush_sample_tex(brush, xy, rgba); + brush_sample_tex(brush, xy, rgba, 0); dst[0]= FTOCHAR(rgba[0]); dst[1]= FTOCHAR(rgba[1]); dst[2]= FTOCHAR(rgba[2]); @@ -592,7 +592,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf else { dist = sqrt(xy[0]*xy[0] + xy[1]*xy[1]); - brush_sample_tex(brush, xy, rgba); + brush_sample_tex(brush, xy, rgba, 0); dst[0] = FTOCHAR(rgba[0]*brush->rgb[0]); dst[1] = FTOCHAR(rgba[1]*brush->rgb[1]); dst[2] = FTOCHAR(rgba[2]*brush->rgb[2]); @@ -739,7 +739,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i xy[0] = x + xoff; xy[1] = y + yoff; - brush_sample_tex(brush, xy, tf); + brush_sample_tex(brush, xy, tf, 0); } bf[0] = tf[0]*mf[0]; @@ -770,7 +770,7 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, i xy[0] = x + xoff; xy[1] = y + yoff; - brush_sample_tex(brush, xy, rgba); + brush_sample_tex(brush, xy, rgba, 0); t[0]= FTOCHAR(rgba[0]); t[1]= FTOCHAR(rgba[1]); t[2]= FTOCHAR(rgba[2]); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 07b712c4330..6b75f5d417c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3686,7 +3686,7 @@ static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float else VECCOPY(texco,orco); - externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3); + externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3, 0); if((event & mtex->pmapto) & MAP_PA_TIME){ if((setvars&MAP_PA_TIME)==0){ ptex->time=0.0; @@ -3740,7 +3740,7 @@ void psys_get_texture(ParticleSimulationData *sim, Material *ma, ParticleData *p psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,0,0,0,texco, 0); } - externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3); + externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3, 0); if((event & mtex->pmapto) & MAP_PA_TIME){ /* the first time has to set the base value for time regardless of blend mode */ -- cgit v1.2.3 From 9b7cc91134b5a173e3afe5b93093e1c3c21310b1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Sep 2010 14:29:51 +0000 Subject: bugfix [#22169] LoopCut and Slide plus ArrayModifier Object offset FirstLast gives crash --- source/blender/blenkernel/intern/mesh.c | 2 +- 1 file changed, 1 insertion(+), 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 e9cc21d6887..6f1cdefbcad 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -440,7 +440,7 @@ void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert, int inve int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) { /* first test if the face is legal */ - if(mface->v3 && mface->v3==mface->v4) { + if((mface->v3 || nr==4) && mface->v3==mface->v4) { mface->v4= 0; nr--; } -- cgit v1.2.3 From 361bd506dcfe97cb7a3c777935bc602fdce519b5 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 24 Sep 2010 07:39:52 +0000 Subject: Fix for [#23970] Memory problem when setting hair amount to zero --- source/blender/blenkernel/intern/particle_system.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (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 3b9ad8d84ec..47a220dcefb 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -195,9 +195,11 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) psys->free_edit = NULL; } - newpars= MEM_callocN(totpart*sizeof(ParticleData), "particles"); - if(psys->part->phystype == PART_PHYS_BOIDS) - newboids= MEM_callocN(totpart*sizeof(BoidParticle), "boid particles"); + if(totpart) { + newpars= MEM_callocN(totpart*sizeof(ParticleData), "particles"); + if(psys->part->phystype == PART_PHYS_BOIDS) + newboids= MEM_callocN(totpart*sizeof(BoidParticle), "boid particles"); + } if(psys->particles) { totsaved=MIN2(psys->totpart,totpart); -- cgit v1.2.3 From 3567eebcc20acbefd393fb8263cd2b750bcf8a93 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 24 Sep 2010 17:47:28 +0000 Subject: Fix for [#23549] Copy rotation don't work if influence is another than 0 or 1 * Replaced constraint result interpolation with much simpler logic, hopefully this doesn't create any unseen complications :) --- source/blender/blenkernel/intern/constraint.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index dd32d22d09f..cec552b8124 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -4409,7 +4409,7 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) } } - /* Solve the constraint */ + /* Solve the constraint and put result in cob->matrix */ cti->evaluate_constraint(con, cob, &targets); /* clear targets after use @@ -4421,23 +4421,13 @@ void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) } /* Interpolate the enforcement, to blend result of constraint into final owner transform */ - /* 1. Remove effects of original matrix from constraint solution ==> delta */ - invert_m4_m4(imat, oldmat); - copy_m4_m4(solution, cob->matrix); - mul_m4_m4m4(delta, solution, imat); - - /* 2. If constraint influence is not full strength, then interpolate - * identity_matrix --> delta_matrix to get the effect the constraint actually exerts - */ + /* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka */ if (enf < 1.0) { - float identity[4][4]; - unit_m4(identity); - blend_m4_m4m4(delta, identity, delta, enf); + float solution[4][4]; + copy_m4_m4(solution, cob->matrix); + blend_m4_m4m4(cob->matrix, oldmat, solution, enf); } - /* 3. Now multiply the delta by the matrix in use before the evaluation */ - mul_m4_m4m4(cob->matrix, delta, oldmat); - /* move owner back into worldspace for next constraint/other business */ if ((con->flag & CONSTRAINT_SPACEONCE) == 0) constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD); -- cgit v1.2.3 From b57e09544a430a585e8665c7064252be1b59ec57 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 24 Sep 2010 17:49:33 +0000 Subject: Fix for [#21875] Copy rotation only on y axies --- source/blender/blenkernel/intern/constraint.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index cec552b8124..59e81293c9f 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1636,8 +1636,9 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta mat4_to_size(size, cob->matrix); /* to allow compatible rotations, must get both rotations in the order of the owner... */ - mat4_to_eulO(eul, cob->rotOrder, ct->matrix); mat4_to_eulO(obeul, cob->rotOrder, cob->matrix); + /* we must get compatible eulers from the beginning because some of them can be modified below (see bug #21875) */ + mat4_to_compatible_eulO(eul, obeul, cob->rotOrder, ct->matrix); if ((data->flag & ROTLIKE_X)==0) eul[0] = obeul[0]; @@ -1669,6 +1670,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[2] *= -1; } + /* good to make eulers compatible again, since we don't know how much they were changed above */ compatible_eul(eul, obeul); loc_eulO_size_to_mat4(cob->matrix, loc, eul, size, cob->rotOrder); } -- cgit v1.2.3 From 9da82e2d685098c84f4b17bbc5232df791d34279 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 25 Sep 2010 16:35:02 +0000 Subject: Fix #23690: threading crash with compositing nodes and scopes view. --- source/blender/blenkernel/intern/image.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 3d16b40a8a6..344f8500075 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2020,14 +2020,9 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); } else if(ima->source == IMA_SRC_VIEWER) { - if(ima->type==IMA_TYPE_R_RESULT) { - /* always verify entirely, not that this shouldn't happen - * during render anyway */ - } - else if(ima->type==IMA_TYPE_COMPOSITE) { - frame= iuser?iuser->framenr:0; - ibuf= image_get_ibuf(ima, 0, frame); - } + /* always verify entirely, not that this shouldn't happen + * as part of texture sampling in rendering anyway, so not + * a big bottleneck */ } *frame_r = frame; -- cgit v1.2.3 From 8babc5056f892f550f9b874a5aebefeaded3f10a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 25 Sep 2010 22:21:35 +0000 Subject: Fix for fix in revision 32122, viewer node wasn't working anymore in some cases. --- source/blender/blenkernel/intern/image.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 344f8500075..a199c1cf738 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2139,10 +2139,15 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) BLI_lock_thread(LOCK_VIEWER); *lock_r= ima; - /* Composite Viewer, all handled in compositor */ - /* fake ibuf, will be filled in compositor */ - ibuf= IMB_allocImBuf(256, 256, 32, IB_rect, 0); - image_assign_ibuf(ima, ibuf, 0, frame); + frame= iuser?iuser->framenr:0; + ibuf= image_get_ibuf(ima, 0, frame); + + if(!ibuf) { + /* Composite Viewer, all handled in compositor */ + /* fake ibuf, will be filled in compositor */ + ibuf= IMB_allocImBuf(256, 256, 32, IB_rect, 0); + image_assign_ibuf(ima, ibuf, 0, frame); + } } } } -- cgit v1.2.3 From 57527cb0ac8b153a4aa89baf655c8d58c488d3a6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 26 Sep 2010 18:29:54 +0000 Subject: - Save MDISPS layer when applying modifier. All sculpting used to disappear before. Save MDISPS if new mesh has got the same faces amount. NOTE: maybe some other layers should be saved? - Apply multires modififier if MDISPS was auto-created. Multires's applyModifier used to return unchanged DM when MDISPS was auto-created. - Set multires totlvl from MDISPS layer when new multires was added to mesh with existing MDISPS layer. --- source/blender/blenkernel/intern/DerivedMesh.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index de7b962e38a..0b3bd106544 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -239,6 +239,15 @@ void DM_to_mesh(DerivedMesh *dm, Mesh *me) if(!CustomData_has_layer(&tmp.fdata, CD_MFACE)) CustomData_add_layer(&tmp.fdata, CD_MFACE, CD_ASSIGN, dm->dupFaceArray(dm), totface); + /* object had got displacement layer, should copy this layer to save sculpted data */ + /* NOTE: maybe some other layers should be copied? nazgul */ + if(CustomData_has_layer(&me->fdata, CD_MDISPS)) { + if (totface == me->totface) { + MDisps *mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); + CustomData_add_layer(&tmp.fdata, CD_MDISPS, CD_DUPLICATE, mdisps, totface); + } + } + mesh_update_customdata_pointers(&tmp); CustomData_free(&me->vdata, me->totvert); -- cgit v1.2.3 From 767a05da44bfb07807b5fa6005d352b56f704903 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 27 Sep 2010 05:02:54 +0000 Subject: bugfix [#24015] Deleting Objects with a Point Density Texture and Rendering Crashes Blender --- source/blender/blenkernel/intern/object.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index f45c0717b26..d9ee67920eb 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -532,12 +532,10 @@ void unlink_object(Scene *scene, Object *ob) } /* textures */ - tex= bmain->tex.first; - while(tex) { - if(tex->env) { - if(tex->env->object == ob) tex->env->object= NULL; - } - tex= tex->id.next; + for(tex= bmain->tex.first; tex; tex= tex->id.next) { + if(tex->env && (ob==tex->env->object)) tex->env->object= NULL; + if(tex->pd && (ob==tex->pd->object)) tex->pd->object= NULL; + if(tex->vd && (ob==tex->vd->object)) tex->vd->object= NULL; } /* worlds */ -- cgit v1.2.3 From 97cc369f72005d9a250abfc3d82ac1c559ca1393 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Mon, 27 Sep 2010 07:37:36 +0000 Subject: Fix: [#24006] writeffmpeg doesn't flush delayed frames - fix attached and [#20843] FFmpeg H264 preset gives "Couldn't initialize codec" Thanks to Leo Sutic for the patch! --- source/blender/blenkernel/intern/writeffmpeg.c | 108 +++++++++++++++++++++++-- 1 file changed, 102 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 6cd207f628c..473c10d6ced 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -160,7 +160,7 @@ static int write_audio_frame(void) pkt.stream_index = audio_stream->index; pkt.flags |= PKT_FLAG_KEY; if (av_interleaved_write_frame(outfile, &pkt) != 0) { - // XXX error("Error writing audio packet"); + fprintf(stderr, "Error writing audio packet!\n"); return -1; } return 0; @@ -290,7 +290,9 @@ static int write_video_frame(RenderData *rd, AVFrame* frame, ReportList *reports packet.data = video_buffer; packet.size = outsize; ret = av_interleaved_write_frame(outfile, &packet); - } else ret = 0; + } else { + ret = 0; + } if (ret != 0) { success= 0; @@ -778,6 +780,69 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report return 1; } +/** + * Writes any delayed frames in the encoder. This function is called before + * closing the encoder. + * + *

+ * Since an encoder may use both past and future frames to predict + * inter-frames (H.264 B-frames, for example), it can output the frames + * in a different order from the one it was given. + * For example, when sending frames 1, 2, 3, 4 to the encoder, it may write + * them in the order 1, 4, 2, 3 - first the two frames used for predition, + * and then the bidirectionally-predicted frames. What this means in practice + * is that the encoder may not immediately produce one output frame for each + * input frame. These delayed frames must be flushed before we close the + * stream. We do this by calling avcodec_encode_video with NULL for the last + * parameter. + *

+ */ +void flush_ffmpeg(void) +{ + int outsize = 0; + int ret = 0; + + AVCodecContext* c = get_codec_from_stream(video_stream); + /* get the delayed frames */ + while (1) { + AVPacket packet; + av_init_packet(&packet); + + outsize = avcodec_encode_video(c, video_buffer, video_buffersize, NULL); + if (outsize < 0) { + fprintf(stderr, "Error encoding delayed frame %d\n", outsize); + break; + } + if (outsize == 0) { + break; + } + if (c->coded_frame->pts != AV_NOPTS_VALUE) { +#ifdef FFMPEG_CODEC_TIME_BASE + packet.pts = av_rescale_q(c->coded_frame->pts, + c->time_base, + video_stream->time_base); +#else + packet.pts = c->coded_frame->pts; +#endif + fprintf(stderr, "Video Frame PTS: %d\n", (int)packet.pts); + } else { + fprintf(stderr, "Video Frame PTS: not set\n"); + } + if (c->coded_frame->key_frame) { + packet.flags |= PKT_FLAG_KEY; + } + packet.stream_index = video_stream->index; + packet.data = video_buffer; + packet.size = outsize; + ret = av_interleaved_write_frame(outfile, &packet); + if (ret != 0) { + fprintf(stderr, "Error writing delayed frame %d\n", ret); + break; + } + } + avcodec_flush_buffers(get_codec_from_stream(video_stream)); +} + /* ********************************************************************** * public interface ********************************************************************** */ @@ -888,7 +953,6 @@ int append_ffmpeg(RenderData *rd, int frame, int *pixels, int rectx, int recty, return success; } - void end_ffmpeg(void) { int i; @@ -905,6 +969,11 @@ void end_ffmpeg(void) audio_mixdown_device = 0; } + if (video_stream && get_codec_from_stream(video_stream)) { + fprintf(stderr, "Flushing delayed frames...\n"); + flush_ffmpeg (); + } + if (outfile) { av_write_trailer(outfile); } @@ -913,8 +982,8 @@ void end_ffmpeg(void) if (video_stream && get_codec_from_stream(video_stream)) { avcodec_close(get_codec_from_stream(video_stream)); - video_stream = 0; printf("zero video stream %p\n", video_stream); + video_stream = 0; } @@ -1195,20 +1264,47 @@ void ffmpeg_set_preset(RenderData *rd, int preset) rd->ffcodecdata.mux_packet_size = 2048; rd->ffcodecdata.mux_rate = 10080000; + /* + * All options here are for x264, but must be set via ffmpeg. + * The names are therefore different - Search for "x264 to FFmpeg option mapping" + * to get a list. + */ + + /* + * Use CABAC coder. Using "coder:1", which should be equivalent, + * crashes Blender for some reason. Either way - this is no big deal. + */ ffmpeg_property_add_string(rd, "video", "coder:vlc"); + + /* + * The other options were taken from the libx264-default.preset + * included in the ffmpeg distribution. + */ ffmpeg_property_add_string(rd, "video", "flags:loop"); ffmpeg_property_add_string(rd, "video", "cmp:chroma"); ffmpeg_property_add_string(rd, "video", "partitions:parti4x4"); ffmpeg_property_add_string(rd, "video", "partitions:partp8x8"); ffmpeg_property_add_string(rd, "video", "partitions:partb8x8"); ffmpeg_property_add_string(rd, "video", "me:hex"); - ffmpeg_property_add_string(rd, "video", "subq:5"); + ffmpeg_property_add_string(rd, "video", "subq:6"); ffmpeg_property_add_string(rd, "video", "me_range:16"); + ffmpeg_property_add_string(rd, "video", "qdiff:4"); ffmpeg_property_add_string(rd, "video", "keyint_min:25"); ffmpeg_property_add_string(rd, "video", "sc_threshold:40"); ffmpeg_property_add_string(rd, "video", "i_qfactor:0.71"); ffmpeg_property_add_string(rd, "video", "b_strategy:1"); - + ffmpeg_property_add_string(rd, "video", "bf:3"); + ffmpeg_property_add_string(rd, "video", "refs:2"); + ffmpeg_property_add_string(rd, "video", "qcomp:0.6"); + ffmpeg_property_add_string(rd, "video", "directpred:3"); + ffmpeg_property_add_string(rd, "video", "trellis:0"); + ffmpeg_property_add_string(rd, "video", "flags2:wpred"); + ffmpeg_property_add_string(rd, "video", "flags2:dct8x8"); + ffmpeg_property_add_string(rd, "video", "flags2:fastpskip"); + ffmpeg_property_add_string(rd, "video", "wpredp:2"); + + // This makes x264 output lossless. Will be a separate option later. + //ffmpeg_property_add_string(rd, "video", "cqp:0"); break; case FFMPEG_PRESET_THEORA: -- cgit v1.2.3 From afa4b855caa874d32d0cd0e02524846da58628c1 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 27 Sep 2010 09:58:37 +0000 Subject: Fixed: Showing pointcached frames in the timeline was terribly slow when using disk cache. * The existence of cached frames was checked each frame causing hundreds of disk operations per frame update. * Pointcache now keeps an updated array of the cached frames for fast "frame exists in cache" queries. * This fix also speeds up some other pointcache operations nicely. --- source/blender/blenkernel/intern/pointcache.c | 92 +++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 741580048cf..f503858a70f 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1876,6 +1876,9 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) else cache->flag |= PTCACHE_FRAMES_SKIPPED; } + + if(cache->cached_frames) + cache->cached_frames[cfra] = 1; if(pf) ptcache_file_close(pf); @@ -1893,6 +1896,9 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) { int len; /* store the length of the string */ + int i; + int sta = pid->cache->startframe; + int end = pid->cache->endframe; /* mode is same as fopen's modes */ DIR *dir; @@ -1936,6 +1942,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) pid->cache->last_exact = MIN2(pid->cache->startframe, 0); BLI_join_dirfile(path_full, path, de->d_name); BLI_delete(path_full, 0, 0); + if(pid->cache->cached_frames) for(i=0; icache->cached_frames[i] = 0; } else { /* read the number of the file */ int frame, len2 = (int)strlen(de->d_name); @@ -1950,6 +1958,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) BLI_join_dirfile(path_full, path, de->d_name); BLI_delete(path_full, 0, 0); + if(frame >=sta && frame <= end) + pid->cache->cached_frames[frame-sta] = 0; } } } @@ -1970,11 +1980,16 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) for(; pm; pm=pm->next) ptcache_free_data(pm); BLI_freelistN(&pid->cache->mem_cache); + + if(pid->cache->cached_frames) for(i=0; icache->cached_frames[i] = 0; } else { while(pm) { if((mode==PTCACHE_CLEAR_BEFORE && pm->frame < cfra) || (mode==PTCACHE_CLEAR_AFTER && pm->frame > cfra) ) { link = pm; + if(pm->frame >=sta && pm->frame <= end) + pid->cache->cached_frames[pm->frame-sta] = 0; ptcache_free_data(pm); pm = pm->next; BLI_freelinkN(&pid->cache->mem_cache, link); @@ -2004,6 +2019,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) } } } + if(pid->cache->cached_frames && cfra>=sta && cfra<=end) + pid->cache->cached_frames[cfra-sta] = 0; break; } @@ -2014,6 +2031,12 @@ int BKE_ptcache_id_exist(PTCacheID *pid, int cfra) { if(!pid->cache) return 0; + + if(cfracache->startframe || cfra > pid->cache->endframe) + return 0; + + if(pid->cache->cached_frames && pid->cache->cached_frames[cfra-pid->cache->startframe]==0) + return 0; if(pid->cache->flag & PTCACHE_DISK_CACHE) { char filename[MAX_PTCACHE_FILE]; @@ -2073,6 +2096,73 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra *endframe += (int)(offset+0.5f); } } + + /* verify cached_frames array is up to date */ + if(cache->cached_frames) { + if(MEM_allocN_len(cache->cached_frames) != sizeof(char) * (cache->endframe-cache->startframe+1)) { + MEM_freeN(cache->cached_frames); + cache->cached_frames = NULL; + } + } + + if(cache->cached_frames==NULL) { + int sta=cache->startframe; + int end=cache->endframe; + int i=0; + + cache->cached_frames = MEM_callocN(sizeof(char) * (cache->endframe-cache->startframe+1), "cached frames array"); + + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + /* mode is same as fopen's modes */ + DIR *dir; + struct dirent *de; + char path[MAX_PTCACHE_PATH]; + char filename[MAX_PTCACHE_FILE]; + char ext[MAX_PTCACHE_PATH]; + int len; /* store the length of the string */ + + ptcache_path(pid, path); + + len = BKE_ptcache_id_filename(pid, filename, (int)cfra, 0, 0); /* no path */ + + dir = opendir(path); + if (dir==NULL) + return; + + snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, pid->stack_index); + + while ((de = readdir(dir)) != NULL) { + if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ + if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */ + /* read the number of the file */ + int frame, len2 = (int)strlen(de->d_name); + char num[7]; + + if (len2 > 15) { /* could crash if trying to copy a string out of this range*/ + BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num)); + frame = atoi(num); + + if(frame >= sta && frame <= end) + cache->cached_frames[frame-sta] = 1; + } + } + } + } + closedir(dir); + } + else { + PTCacheMem *pm= pid->cache->mem_cache.first; + PTCacheMem *link= NULL; + + pm= pid->cache->mem_cache.first; + + while(pm) { + if(pm->frame >= sta && pm->frame <= end) + cache->cached_frames[pm->frame-sta] = 1; + pm = pm->next; + } + } + } } int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) @@ -2293,6 +2383,8 @@ void BKE_ptcache_free(PointCache *cache) BKE_ptcache_free_mem(&cache->mem_cache); if(cache->edit && cache->free_edit) cache->free_edit(cache->edit); + if(cache->cached_frames) + MEM_freeN(cache->cached_frames); MEM_freeN(cache); } void BKE_ptcache_free_list(ListBase *ptcaches) -- cgit v1.2.3 From d6c8b411446793dd23a54734ce8ee621a755ab3e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 27 Sep 2010 12:21:23 +0000 Subject: added CTX_wm_operator_poll_msg_get/set so failing poll functions can set messages when poll fails, at the moment only python uses this but theres nothing python specific. only added 1 message to a poll function, so messages still need to be set in many more places to be useful. --- source/blender/blenkernel/intern/context.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 7928424e47c..a5d96baf049 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -64,6 +64,7 @@ struct bContext { struct ARegion *region; struct ARegion *menu; struct bContextStore *store; + const char *operator_poll_msg; /* reason for poll failing */ } wm; /* data context */ @@ -399,6 +400,16 @@ void CTX_wm_menu_set(bContext *C, ARegion *menu) C->wm.menu= menu; } +void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg) +{ + C->wm.operator_poll_msg= msg; +} + +const char *CTX_wm_operator_poll_msg_get(bContext *C) +{ + return C->wm.operator_poll_msg; +} + /* data context utility functions */ struct bContextDataResult { -- cgit v1.2.3 From 8bc0cfc1ca988749365009eb01ac90dfec2baa50 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 27 Sep 2010 12:24:12 +0000 Subject: Fix: Smoke wasn't using pointcache properly. * The cache was reset almost constantly because smoke didn't save the first frame into cache. Although not necessary for smoke, it's vital to pointcache. * Added info message to smoke cache panel for non saved files. * Now smoke also only updates with a framestep of 1, so that scrubbing the timeline doesn't mess up the simulation. * Among other things fixes report #23731. --- source/blender/blenkernel/intern/smoke.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index d2d8d5a6e07..d0fcde0da58 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1338,10 +1338,17 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM cache_wt = sds->point_cache[1]; BKE_ptcache_id_from_smoke_turbulence(&pid_wt, ob, smd); - if(!smd->domain->fluid) + if(!smd->domain->fluid || framenr == startframe) { BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); + BKE_ptcache_validate(cache, framenr); + cache->flag &= ~PTCACHE_REDO_NEEDED; + BKE_ptcache_id_reset(scene, &pid_wt, PTCACHE_RESET_OUTDATED); + if(cache_wt) { + BKE_ptcache_validate(cache_wt, framenr); + cache_wt->flag &= ~PTCACHE_REDO_NEEDED; + } } if(framenr < startframe) @@ -1368,6 +1375,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM if(cache_result == PTCACHE_READ_EXACT) { BKE_ptcache_validate(cache, framenr); + smd->time = framenr; if(sds->wt) { @@ -1388,14 +1396,21 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM else return; } - - /* only calculate something when we advanced a frame */ - if(framenr == smd->time) + /* only calculate something when we advanced a single frame */ + else if(framenr != (int)smd->time+1) return; tstart(); smoke_calc_domain(scene, ob, smd); + + /* if on second frame, write cache for first frame */ + /* this needs to be done for smoke too so that pointcache works properly */ + if((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) { + BKE_ptcache_write_cache(&pid, startframe); + if(sds->wt) + BKE_ptcache_write_cache(&pid_wt, startframe); + } // set new time smd->time = scene->r.cfra; -- cgit v1.2.3 From 12be522cbe9d4c9ae99555770f546ce6f27b7c21 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 28 Sep 2010 08:47:59 +0000 Subject: Fix for [#24031] Baked Physics with Phsics set to NO can't be freed * Should fix the cause ("no physics" gets baked) and old files that are effected (ui allows freeing if cache isn't really used) --- source/blender/blenkernel/intern/pointcache.c | 21 ++++++++++++++++----- 1 file changed, 16 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 f503858a70f..5007ce68a67 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1008,11 +1008,22 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup } for(psys=ob->particlesystem.first; psys; psys=psys->next) { - if(psys->part) { - pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID"); - BKE_ptcache_id_from_particles(pid, ob, psys); - BLI_addtail(lb, pid); - } + if(psys->part==NULL) + continue; + + /* check to make sure point cache is actually used by the particles */ + if(ELEM(psys->part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) + continue; + + if(psys->part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DYNAMICS)==0) + continue; + + if(psys->part->type == PART_FLUID) + continue; + + pid= MEM_callocN(sizeof(PTCacheID), "PTCacheID"); + BKE_ptcache_id_from_particles(pid, ob, psys); + BLI_addtail(lb, pid); } for(md=ob->modifiers.first; md; md=md->next) { -- cgit v1.2.3 From 26482da2b48343338edcaecd4a483a8f5e1dab8f Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 28 Sep 2010 09:11:24 +0000 Subject: Fix for [#23961] Object hair particles do not render if turned off in viewport --- source/blender/blenkernel/intern/particle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 6b75f5d417c..723ff7faed3 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -272,7 +272,7 @@ int psys_check_enabled(Object *ob, ParticleSystem *psys) } psmd= psys_get_modifier(ob, psys); - if(psys->renderdata) { + if(psys->renderdata || G.rendering) { if(!(psmd->modifier.mode & eModifierMode_Render)) return 0; } -- cgit v1.2.3 From 8d50b283cbc663f08b0c4b0e43ed8fdee4a93549 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 28 Sep 2010 09:27:35 +0000 Subject: Fix for own recent commit 32147 * Pointcache wasn't checked to be valid before allocating the cached frames array --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 5007ce68a67..c3df8f87d21 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2116,7 +2116,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra } } - if(cache->cached_frames==NULL) { + if(cache->cached_frames==NULL && cache->endframe > cache->startframe) { int sta=cache->startframe; int end=cache->endframe; int i=0; -- cgit v1.2.3 From 8df244f20dc4a2d92bbe496f123f2d6578167949 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 28 Sep 2010 10:03:56 +0000 Subject: images bigger then 32k no longer crash blender, use unsigned int for image size rather then short. also check if jpeg fails to allocate an imbuf. --- source/blender/blenkernel/intern/constraint.c | 3 +-- source/blender/blenkernel/intern/image.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 59e81293c9f..fe69f13bbda 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -4358,8 +4358,7 @@ void get_constraint_target_matrix (struct Scene *scene, bConstraint *con, int n, void solve_constraints (ListBase *conlist, bConstraintOb *cob, float ctime) { bConstraint *con; - float solution[4][4], delta[4][4]; - float oldmat[4][4], imat[4][4]; + float oldmat[4][4]; float enf; /* check that there is a valid constraint object to evaluate */ diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a199c1cf738..cb2261932ce 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -382,7 +382,7 @@ Image *BKE_add_image_file(const char *name, int frame) return ima; } -static ImBuf *add_ibuf_size(int width, int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) +static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { ImBuf *ibuf; unsigned char *rect= NULL; @@ -415,7 +415,7 @@ static ImBuf *add_ibuf_size(int width, int height, char *name, int depth, int fl } /* adds new image block, creates ImBuf and initializes color */ -Image *BKE_add_image_size(int width, int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) +Image *BKE_add_image_size(unsigned int width, unsigned int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { /* on save, type is changed to FILE in editsima.c */ Image *ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); -- cgit v1.2.3 From 92fd0680cb007d05fdcc9a787ba181bfe1ce7275 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 28 Sep 2010 10:04:41 +0000 Subject: Fix for [#23732] Smoke / load external cache doesn't work --- source/blender/blenkernel/intern/pointcache.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index c3df8f87d21..95cfb621cf7 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2943,7 +2943,10 @@ void BKE_ptcache_update_info(PTCacheID *pid) totframes++; } - if(totframes && cache->totpoint) + /* smoke doesn't use frame 0 as info frame so can't check based on totpoint */ + if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN && totframes) + sprintf(cache->info, "%i frames found!", totframes); + else if(totframes && cache->totpoint) sprintf(cache->info, "%i points found!", cache->totpoint); else sprintf(cache->info, "No valid data to read!"); -- cgit v1.2.3 From 30bd26d435fdef82a48bd857e48a7d77eb90443f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 28 Sep 2010 11:48:13 +0000 Subject: [#24028] Minor fixes to BLI_math_vector + minor warning fixes. --- source/blender/blenkernel/intern/pointcache.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 95cfb621cf7..784f6e40706 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2119,7 +2119,6 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra if(cache->cached_frames==NULL && cache->endframe > cache->startframe) { int sta=cache->startframe; int end=cache->endframe; - int i=0; cache->cached_frames = MEM_callocN(sizeof(char) * (cache->endframe-cache->startframe+1), "cached frames array"); @@ -2163,7 +2162,6 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra } else { PTCacheMem *pm= pid->cache->mem_cache.first; - PTCacheMem *link= NULL; pm= pid->cache->mem_cache.first; -- cgit v1.2.3 From 33fab0f7d7433e8d942c6eb448a14da05f1a22f2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 29 Sep 2010 06:24:05 +0000 Subject: fix for user counts with text3d bold/italic fonts. --- source/blender/blenkernel/intern/curve.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 358dd1914e7..d13738808d1 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -74,12 +74,22 @@ void unlink_curve(Curve *cu) for(a=0; atotcol; a++) { if(cu->mat[a]) cu->mat[a]->id.us--; - cu->mat[a]= 0; + cu->mat[a]= NULL; } if(cu->vfont) cu->vfont->id.us--; - cu->vfont= 0; + cu->vfont= NULL; + + if(cu->vfontb) cu->vfontb->id.us--; + cu->vfontb= NULL; + + if(cu->vfonti) cu->vfonti->id.us--; + cu->vfonti= NULL; + + if(cu->vfontbi) cu->vfontbi->id.us--; + cu->vfontbi= NULL; + if(cu->key) cu->key->id.us--; - cu->key= 0; + cu->key= NULL; } /* frees editcurve entirely */ @@ -210,9 +220,12 @@ void make_local_curve(Curve *cu) */ if(cu->id.lib==0) return; - - if(cu->vfont) cu->vfont->id.lib= 0; - + + if(cu->vfont) cu->vfont->id.lib= NULL; + if(cu->vfontb) cu->vfontb->id.lib= NULL; + if(cu->vfonti) cu->vfonti->id.lib= NULL; + if(cu->vfontbi) cu->vfontbi->id.lib= NULL; + if(cu->id.us==1) { cu->id.lib= 0; cu->id.flag= LIB_LOCAL; -- cgit v1.2.3 From c5157cda88938177685225bc8f264a4a46883250 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 29 Sep 2010 13:38:43 +0000 Subject: Cleanup of code and ui of sequencer speed effect. * Sequence speed effect was functional in theory, but very difficult to actually use. * Now the effect works as follows: - "Speed Factor" (formerly "speed fade") controls the current speed of the sequence (can be animated). - "Use as speed" (formerly "f-curve velocity") is now the default behavior so that the "speed effect" by default changes the "speed" of the sequence. - "Multiply Speed" (formerly "global speed") is a scale factor that's applied to the calculated frame (can't be animated). - Without animation "Speed Factor" and "Multiply Speed" work exactly the same (in this case "multiply speed" could perhaps be disabled in ui, but currently there's no easy way to check this). - If "Use as speed" is not checked the effect simply remaps the current frame to the given "Frame Number" (can be animated). - "Scale to length" (formerly "f-curve compress y")scales "Frame numbers" from 0.0-1.0 to the length of the target strip to allow easy animation. * Tooltips added for all values and options. * Code for frame blending was nowhere to be seen, so I commented the option out from ui. * This should fix at least bugs #20979 and #21309. --- source/blender/blenkernel/intern/seqeffects.c | 42 ++++++++++----------------- 1 file changed, 15 insertions(+), 27 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 461cb075bb0..4a00922f1d2 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2873,7 +2873,7 @@ static void init_speed_effect(Sequence *seq) v = (SpeedControlVars *)seq->effectdata; v->globalSpeed = 1.0; v->frameMap = 0; - v->flags = 0; + v->flags |= SEQ_SPEED_INTEGRATE; /* should be default behavior */ v->length = 0; } @@ -2936,9 +2936,8 @@ static void store_icu_yrange_speed(struct Sequence * seq, } void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) { - float ctime, div; int cfra; - float fallback_fac; + float fallback_fac = 1.0f; SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; FCurve *fcu= NULL; @@ -2955,7 +2954,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) /* XXX - new in 2.5x. should we use the animation system this way? * The fcurve is needed because many frames need evaluating at once - campbell */ - fcu= id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_fader", 0); + fcu= id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0); if (!v->frameMap || v->length != seq->len) { @@ -2966,17 +2965,12 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) v->frameMap = MEM_callocN(sizeof(float) * v->length, "speedcontrol frameMap"); } - - fallback_fac = 1.0; - /* if there is no fcurve, try to make retiming easy by stretching the - strip */ - 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); - } + /* if there is no fcurve, use value as simple multiplier */ + if (!fcu) + fallback_fac = seq->speed_fader; /* same as speed_factor in rna*/ - if ((v->flags & SEQ_SPEED_INTEGRATE) != 0) { + if (v->flags & SEQ_SPEED_INTEGRATE) { float cursor = 0; float facf; @@ -2985,10 +2979,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) for (cfra = 1; cfra < v->length; cfra++) { if(fcu) { - ctime = seq->startdisp + cfra; - div = 1.0; - - facf = evaluate_fcurve(fcu, ctime/div); + facf = evaluate_fcurve(fcu, seq->startdisp + cfra); } else { facf = fallback_fac; } @@ -3010,19 +3001,16 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) for (cfra = 0; cfra < v->length; cfra++) { if(fcu) { - ctime = seq->startdisp + cfra; - div = 1.0; - - facf = evaluate_fcurve(fcu, ctime / div); - if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) { - facf *= v->length; - } + facf = evaluate_fcurve(fcu, seq->startdisp + cfra); + } else { + facf = fallback_fac; } - - if (!fcu) { - facf = (float) cfra * fallback_fac; + + if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) { + facf *= v->length; } facf *= v->globalSpeed; + if (facf >= seq->seq1->len) { facf = seq->seq1->len - 1; } else { -- cgit v1.2.3 From b01e6fd564ea7a0626cef88f06f13247f8bffb1b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 30 Sep 2010 06:51:32 +0000 Subject: rename makeknots to nurbs_knot_calc_u/v --- source/blender/blenkernel/intern/curve.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index d13738808d1..9578b5185af 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -636,7 +636,7 @@ static void makecyclicknots(float *knots, short pnts, short order) -void makeknots(Nurb *nu, short uv) +static void makeknots(Nurb *nu, short uv) { if(nu->type == CU_NURBS) { if(uv == 1) { @@ -668,6 +668,16 @@ void makeknots(Nurb *nu, short uv) } } +void nurbs_knot_calc_u(Nurb *nu) +{ + makeknots(nu, 1); +} + +void nurbs_knot_calc_v(Nurb *nu) +{ + makeknots(nu, 2); +} + static void basisNurb(float t, short order, short pnts, float *knots, float *basis, int *start, int *end) { float d, e; -- cgit v1.2.3 From 38c3a5f363e8b9391401a2e4c34b11a9c49adc54 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 30 Sep 2010 09:34:22 +0000 Subject: Sequence effect scale to length should work with the original (non-extruded) length of the target strip. --- source/blender/blenkernel/intern/seqeffects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 4a00922f1d2..7b428661c6d 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -3007,7 +3007,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) } if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) { - facf *= v->length; + facf *= seq->seq1->len; } facf *= v->globalSpeed; -- cgit v1.2.3 From 81b6d308a771405ef326b1e4cebbc3359e830a6c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 30 Sep 2010 10:51:36 +0000 Subject: [#23673] Modifier construction gives correct result in viewport but incorrect in render. When there are 2+ consecutive deform modifiers, the second modifier was getting incorrect normals, this only showed up for the displace modifier since its the only deform modifier that uses vertex normals. It would have been easy to fix this by always calculating normals on deform modifiers, but slow. To fix this I added a function to check if a deform modifier needs normals, so the normal calculation function only runs if there are 2 modifiers in a row and the second uses normals. --- source/blender/blenkernel/intern/DerivedMesh.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 0b3bd106544..1f49d519e7d 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1670,6 +1670,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos DerivedMesh *dm, *orcodm, *clothorcodm, *finaldm; int numVerts = me->totvert; int required_mode; + int isPrevDeform= FALSE; md = firstmd = (useDeform<0) ? ob->modifiers.first : modifiers_getVirtualModifierList(ob); @@ -1787,6 +1788,16 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } } + /* if this is not the last modifier in the stack then recalculate the normals + * to avoid giving bogus normals to the next modifier see: [#23673] */ + if(isPrevDeform && mti->dependsOnNormals(md)) { + /* XXX, this covers bug #23673, but we may need normal calc for other types */ + if(dm->type == DM_TYPE_CDDM) { + CDDM_apply_vert_coords(dm, deformedVerts); + CDDM_calc_normals(dm); + } + } + mti->deformVerts(md, ob, dm, deformedVerts, numVerts, useRenderParams, useDeform); } else { DerivedMesh *ndm; @@ -1897,6 +1908,8 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } } + isPrevDeform= (mti->type == eModifierTypeType_OnlyDeform); + /* grab modifiers until index i */ if((index >= 0) && (modifiers_indexInObject(ob, md) >= index)) break; -- cgit v1.2.3 From da4b54cd5dd0f0e4c856626bb5ebbdf07a969668 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 30 Sep 2010 20:19:54 +0000 Subject: Fix #23540: smoke preview shading only used point lamps, now it uses other lamps to if no point lamp is available. --- source/blender/blenkernel/intern/smoke.c | 33 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index d0fcde0da58..965ce9801d7 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -800,20 +800,25 @@ static float calc_voxel_transp(float *result, float *input, int res[3], int *pix static int get_lamp(Scene *scene, float *light) { Base *base_tmp = NULL; - for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) - { - if(base_tmp->object->type == OB_LAMP) - { - Lamp *la = (Lamp *)base_tmp->object->data; - - if(la->type == LA_LOCAL) - { - VECCOPY(light, base_tmp->object->obmat[3]); - return 1; - } - } - } - return 0; + int found_lamp = 0; + + // try to find a lamp, preferably local + for(base_tmp = scene->base.first; base_tmp; base_tmp= base_tmp->next) { + if(base_tmp->object->type == OB_LAMP) { + Lamp *la = base_tmp->object->data; + + if(la->type == LA_LOCAL) { + copy_v3_v3(light, base_tmp->object->obmat[3]); + return 1; + } + else if(!found_lamp) { + copy_v3_v3(light, base_tmp->object->obmat[3]); + found_lamp = 1; + } + } + } + + return found_lamp; } static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) -- cgit v1.2.3 From 4ab6881617789f6db0e1c2f53db92c3c7513fb19 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 30 Sep 2010 22:27:37 +0000 Subject: Fix #23186: use of unitialized memory when creating new faces on a mesh with a multires modifier. --- source/blender/blenkernel/intern/customdata.c | 29 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 1f4b0f303f7..1f867a615b2 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -42,6 +42,7 @@ #include "BLI_blenlib.h" #include "BLI_linklist.h" +#include "BLI_math.h" #include "BLI_mempool.h" #include "BKE_customdata.h" @@ -452,22 +453,27 @@ static void layerSwap_mdisps(void *data, const int *ci) int corners, cornersize, S; /* this function is untested .. */ - corners = mdisp_corners(s); - cornersize = s->totdisp/corners; + if(s->disps) { + corners = mdisp_corners(s); + cornersize = s->totdisp/corners; - d = MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap"); + d = MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap"); - for(S = 0; S < corners; S++) - memcpy(d + cornersize*S, s->disps + cornersize*ci[S], cornersize*3*sizeof(float)); - - if(s->disps) - MEM_freeN(s->disps); - s->disps = d; + for(S = 0; S < corners; S++) + memcpy(d + cornersize*S, s->disps + cornersize*ci[S], cornersize*3*sizeof(float)); + + if(s->disps) + MEM_freeN(s->disps); + s->disps = d; + } } static void layerInterp_mdisps(void **sources, float *weights, float *sub_weights, int count, void *dest) { + MDisps *d = dest; + int i; + // XXX #if 0 MDisps *d = dest; @@ -514,6 +520,11 @@ static void layerInterp_mdisps(void **sources, float *weights, float *sub_weight copy_v3_v3(d->disps[y * st + x], srcdisp); } } +#else + if(d->disps) { + for(i = 0; i < d->totdisp; ++i) + zero_v3(d->disps[i]); + } #endif } -- cgit v1.2.3 From f9884b8137c6689f4c5223262488fd4b3d6827d6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 1 Oct 2010 13:51:48 +0000 Subject: fix [#24083] Crash when opening a certain file own error in recent commit. --- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 1f49d519e7d..5fbce3af95f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1790,7 +1790,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos /* if this is not the last modifier in the stack then recalculate the normals * to avoid giving bogus normals to the next modifier see: [#23673] */ - if(isPrevDeform && mti->dependsOnNormals(md)) { + if(isPrevDeform && mti->dependsOnNormals && mti->dependsOnNormals(md)) { /* XXX, this covers bug #23673, but we may need normal calc for other types */ if(dm->type == DM_TYPE_CDDM) { CDDM_apply_vert_coords(dm, deformedVerts); -- cgit v1.2.3 From 734b7b969db315f5ab548b5a8104fc35f29d0f51 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 1 Oct 2010 21:56:36 +0000 Subject: Fix #23932: compositing nodes with viewer and split viewer node could crash, with two threads writing to the same image. --- source/blender/blenkernel/intern/node.c | 80 ++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 30 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 135ddbab2b7..ad3491b5dba 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1690,6 +1690,50 @@ static int node_recurs_check(bNode *node, bNode ***nsort, int level) return 0xFFF; } + +static void ntreeSetOutput(bNodeTree *ntree) +{ + bNode *node; + + printf("\n"); + + /* find the active outputs, might become tree type dependant handler */ + for(node= ntree->nodes.first; node; node= node->next) { + if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) { + bNode *tnode; + int output= 0; + + /* we need a check for which output node should be tagged like this, below an exception */ + if(node->type==CMP_NODE_OUTPUT_FILE) + continue; + + /* there is more types having output class, each one is checked */ + for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) { + if(tnode->typeinfo->nclass==NODE_CLASS_OUTPUT) { + /* same type, exception for viewer */ + if(tnode->type==node->type || + (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER) && + ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))) { + if(tnode->flag & NODE_DO_OUTPUT) { + output++; + if(output>1) + tnode->flag &= ~NODE_DO_OUTPUT; + } + } + } + } + if(output==0) + node->flag |= NODE_DO_OUTPUT; + + if(node->flag & NODE_DO_OUTPUT) + printf("do output %s\n", node->name); + } + } + + /* here we could recursively set which nodes have to be done, + might be different for editor or for "real" use... */ +} + void ntreeSolveOrder(bNodeTree *ntree) { bNode *node, **nodesort, **nsort; @@ -1738,38 +1782,11 @@ void ntreeSolveOrder(bNodeTree *ntree) } MEM_freeN(nodesort); - - /* find the active outputs, might become tree type dependant handler */ - for(node= ntree->nodes.first; node; node= node->next) { - if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) { - bNode *tnode; - int output= 0; - - /* we need a check for which output node should be tagged like this, below an exception */ - if(node->type==CMP_NODE_OUTPUT_FILE) - continue; - - /* there is more types having output class, each one is checked */ - for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) { - if(tnode->typeinfo->nclass==NODE_CLASS_OUTPUT) { - if(tnode->type==node->type) { - if(tnode->flag & NODE_DO_OUTPUT) { - output++; - if(output>1) - tnode->flag &= ~NODE_DO_OUTPUT; - } - } - } - } - if(output==0) - node->flag |= NODE_DO_OUTPUT; - } - } - - /* here we could recursively set which nodes have to be done, - might be different for editor or for "real" use... */ + + ntreeSetOutput(ntree); } + /* Should be callback! */ /* Do not call execs here */ void NodeTagChanged(bNodeTree *ntree, bNode *node) @@ -2466,6 +2483,9 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) /* fixed seed, for example noise texture */ BLI_srandom(rd->cfra); + /* ensures only a single output node is enabled */ + ntreeSetOutput(ntree); + /* sets need_exec tags in nodes */ curnode = totnode= setExecutableNodes(ntree, &thdata); -- cgit v1.2.3 From 9aa2bde26b833d173166390253fb088d15e909b2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 2 Oct 2010 14:32:03 +0000 Subject: Most likely fix for #23420: viewer node: loses viewer nodes forever. Related to another bug fixed recently, both viewer + split viewer could be set to output to the same image. That also could make node tree localization/sync go wrong. --- source/blender/blenkernel/intern/node.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index ad3491b5dba..cb98c2282bc 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1695,8 +1695,6 @@ static void ntreeSetOutput(bNodeTree *ntree) { bNode *node; - printf("\n"); - /* find the active outputs, might become tree type dependant handler */ for(node= ntree->nodes.first; node; node= node->next) { if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) { @@ -1724,9 +1722,6 @@ static void ntreeSetOutput(bNodeTree *ntree) } if(output==0) node->flag |= NODE_DO_OUTPUT; - - if(node->flag & NODE_DO_OUTPUT) - printf("do output %s\n", node->name); } } @@ -2584,7 +2579,10 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) } /* end animdata uglyness */ - + + /* ensures only a single output node is enabled */ + ntreeSetOutput(ntree); + /* move over the compbufs */ /* right after ntreeCopyTree() oldsock pointers are valid */ for(node= ntree->nodes.first; node; node= node->next) { -- cgit v1.2.3 From 0daa9ec5d9f95d8a4c05c89b35e49a879f1c31b7 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 2 Oct 2010 15:27:55 +0000 Subject: Fix for [#24051] Scrubbing Timeline in VSE with Jack Audio doesn't scrub just plays the audio track There were actually two bugs, the one reported and that the Sync Callback never has been called after someone had to add #ifdefs around the call without checking that the build systems are even configured to add the needed definition, am I right Cam? :P --- source/blender/blenkernel/intern/sound.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 26392132038..5e95b19b64f 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -433,9 +433,11 @@ void sound_seek_scene(struct bContext *C) if(scene->audio.flag & AUDIO_SCRUB && !CTX_wm_screen(C)->animtimer) { - // AUD_XXX TODO: fix scrubbing, it currently doesn't stop playing if(scene->audio.flag & AUDIO_SYNC) + { + AUD_seek(scene->sound_scene_handle, CFRA / FPS); AUD_seekSequencer(scene->sound_scene_handle, CFRA / FPS); + } else AUD_seek(scene->sound_scene_handle, CFRA / FPS); AUD_resume(scene->sound_scene_handle); -- cgit v1.2.3 From 8cb17690f128132ac30eefe7e8917ee8d5333004 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 2 Oct 2010 16:42:12 +0000 Subject: Fix #23785: in the game engine, if an object had an armature modifier + another modifier, it would apply the armature deformation twice. --- source/blender/blenkernel/intern/DerivedMesh.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 5fbce3af95f..01b02653a51 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1671,8 +1671,19 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos int numVerts = me->totvert; int required_mode; int isPrevDeform= FALSE; + int skipVirtualArmature = (useDeform < 0); - md = firstmd = (useDeform<0) ? ob->modifiers.first : modifiers_getVirtualModifierList(ob); + if(!skipVirtualArmature) { + firstmd = modifiers_getVirtualModifierList(ob); + } + else { + /* game engine exception */ + firstmd = ob->modifiers.first; + if(firstmd && firstmd->type == eModifierType_Armature) + firstmd = firstmd->next; + } + + md = firstmd; modifiers_clearErrors(ob); -- cgit v1.2.3 From 314121ee65a5d2aadb9be56afcc31201e0eda596 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Oct 2010 01:18:47 +0000 Subject: - use own string conversion function over PyUnicode_FromString when converting the argv - report errors when files dont load when given from the command line but not running in background mode. --- source/blender/blenkernel/intern/report.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index 3773757f5d5..f69547fd1da 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -127,6 +127,7 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...) va_start(args, format); vprintf(format, args); va_end(args); + fprintf(stdout, "\n"); /* otherise each report needs to include a \n */ fflush(stdout); /* this ensures the message is printed before a crash */ } -- cgit v1.2.3 From 636e555ec2aa862d23470c8c2cd0d48cb1b9125d Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 4 Oct 2010 08:48:50 +0000 Subject: Fix for [#24118] Hair particles can not be edited * Own mistake from a previous fix. --- source/blender/blenkernel/intern/pointcache.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 784f6e40706..e1006cd99cd 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1015,8 +1015,9 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup if(ELEM(psys->part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) continue; - if(psys->part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DYNAMICS)==0) - continue; + /* hair needs to be included in id-list for cache edit mode to work */ + /* if(psys->part->type == PART_HAIR && (psys->flag & PSYS_HAIR_DYNAMICS)==0) */ + /* continue; */ if(psys->part->type == PART_FLUID) continue; -- cgit v1.2.3 From e88b8dac7b7bba016fca80d4d2e83850ed924968 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Oct 2010 15:31:04 +0000 Subject: [#22825] Copy Scenes with Audio Strip Crash. --- source/blender/blenkernel/intern/scene.c | 7 ++++--- source/blender/blenkernel/intern/sequencer.c | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 8793c412d7d..3f41b704f97 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -210,6 +210,9 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) if(type == SCE_COPY_LINK_DATA || type == SCE_COPY_FULL) { ID_NEW(scen->camera); } + + /* before scene copy */ + sound_create_scene(scen); /* world */ if(type == SCE_COPY_FULL) { @@ -221,12 +224,10 @@ Scene *copy_scene(Main *bmain, Scene *sce, int type) if(sce->ed) { scen->ed= MEM_callocN( sizeof(Editing), "addseq"); scen->ed->seqbasep= &scen->ed->seqbase; - seqbase_dupli_recursive(sce, &scen->ed->seqbase, &sce->ed->seqbase, SEQ_DUPE_ALL); + seqbase_dupli_recursive(sce, scen, &scen->ed->seqbase, &sce->ed->seqbase, SEQ_DUPE_ALL); } } - sound_create_scene(scen); - return scen; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index b6bb5c3a51b..430d6f87619 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3531,8 +3531,9 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo } -static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag) +static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence *seq, int dupe_flag) { + Scene *sce_audio= scene_to ? scene_to : scene; Sequence *seqn = MEM_dupallocN(seq); seq->tmp = seqn; @@ -3566,7 +3567,7 @@ static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag) } else if(seq->type == SEQ_SCENE) { seqn->strip->stripdata = 0; if(seq->scene_sound) - seqn->scene_sound = sound_scene_add_scene_sound(scene, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); + seqn->scene_sound = sound_scene_add_scene_sound(sce_audio, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); } else if(seq->type == SEQ_MOVIE) { seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); @@ -3575,7 +3576,7 @@ static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag) seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); if(seq->scene_sound) - seqn->scene_sound = sound_add_scene_sound(scene, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); + seqn->scene_sound = sound_add_scene_sound(sce_audio, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); seqn->sound->id.us++; } else if(seq->type == SEQ_IMAGE) { @@ -3610,13 +3611,13 @@ static Sequence *seq_dupli(struct Scene *scene, Sequence *seq, int dupe_flag) return seqn; } -Sequence * seq_dupli_recursive(struct Scene *scene, Sequence * seq, int dupe_flag) +Sequence * seq_dupli_recursive(struct Scene *scene, struct Scene *scene_to, Sequence * seq, int dupe_flag) { - Sequence * seqn = seq_dupli(scene, seq, dupe_flag); + Sequence * seqn = seq_dupli(scene, scene_to, seq, dupe_flag); if (seq->type == SEQ_META) { Sequence *s; for(s= seq->seqbase.first; s; s = s->next) { - Sequence *n = seq_dupli_recursive(scene, s, dupe_flag); + Sequence *n = seq_dupli_recursive(scene, scene_to, s, dupe_flag); if (n) { BLI_addtail(&seqn->seqbase, n); } @@ -3625,7 +3626,7 @@ Sequence * seq_dupli_recursive(struct Scene *scene, Sequence * seq, int dupe_fla return seqn; } -void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase, int dupe_flag) +void seqbase_dupli_recursive(Scene *scene, Scene *scene_to, ListBase *nseqbase, ListBase *seqbase, int dupe_flag) { Sequence *seq; Sequence *seqn = 0; @@ -3634,7 +3635,7 @@ void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase for(seq= seqbase->first; seq; seq= seq->next) { seq->tmp= NULL; if((seq->flag & SELECT) || (dupe_flag & SEQ_DUPE_ALL)) { - seqn = seq_dupli(scene, seq, dupe_flag); + seqn = seq_dupli(scene, scene_to, seq, dupe_flag); if (seqn) { /*should never fail */ if(dupe_flag & SEQ_DUPE_CONTEXT) { seq->flag &= ~SEQ_ALLSEL; @@ -3643,7 +3644,7 @@ void seqbase_dupli_recursive(Scene *scene, ListBase *nseqbase, ListBase *seqbase BLI_addtail(nseqbase, seqn); if(seq->type==SEQ_META) - seqbase_dupli_recursive(scene, &seqn->seqbase, &seq->seqbase, dupe_flag); + seqbase_dupli_recursive(scene, scene_to, &seqn->seqbase, &seq->seqbase, dupe_flag); if(dupe_flag & SEQ_DUPE_CONTEXT) { if (seq == last_seq) { -- cgit v1.2.3 From f994c6caee126f00f97e7da9fde79bdefadd27ec Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 4 Oct 2010 19:01:25 +0000 Subject: bugfix [#24133] r32303, Mirror Modifier + EditMode + VBO's Problem. drawing the triangle arrays were only broken up by hidden faces, but switches in material were ignored. now check for materual context changes. --- source/blender/blenkernel/intern/cdderivedmesh.c | 67 +++++++++++++++--------- 1 file changed, 42 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index ca81e216006..e2ecf21bd62 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -872,34 +872,51 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us if( !GPU_buffer_legacy(dm) ) { int tottri = dm->drawObject->nelements/3; glShadeModel(GL_SMOOTH); - - for( i = 0; i < tottri; i++ ) { - int actualFace = dm->drawObject->faceRemap[i]; - int drawSmooth = (mf[actualFace].flag & ME_SMOOTH); - int draw = 1; - - if(index) { - orig = index[actualFace]; - if(setDrawOptions && orig == ORIGINDEX_NONE) + + if(tottri == 0) { + /* avoid buffer problems in following code */ + } + if(setDrawOptions == NULL) { + /* just draw the entire face array */ + glDrawArrays(GL_TRIANGLES, 0, (tottri-1) * 3); + } + else { + /* we need to check if the next material changes */ + int next_actualFace= dm->drawObject->faceRemap[0]; + + for( i = 0; i < tottri; i++ ) { + //int actualFace = dm->drawObject->faceRemap[i]; + int actualFace = next_actualFace; + int drawSmooth = (mf[actualFace].flag & ME_SMOOTH); + int draw = 1; + + if(i != tottri-1) + next_actualFace= dm->drawObject->faceRemap[i+1]; + + if(index) { + orig = index[actualFace]; + if(orig == ORIGINDEX_NONE) + draw = 0; + } + else + orig = actualFace; + + if(draw && !setDrawOptions(userData, orig, &drawSmooth)) draw = 0; - } - else - orig = actualFace; - - if(draw && setDrawOptions && !setDrawOptions(userData, orig, &drawSmooth)) - draw = 0; - - /* Goal is to draw as long of a contiguous triangle - array as possible, so draw when we hit either an - invisible triangle or at the end of the array */ - if(!draw || i == tottri - 1) { - if(prevstart != i) - /* Add one to the length (via `draw') - if we're drawing at the end of the array */ - glDrawArrays(GL_TRIANGLES,prevstart*3, (i-prevstart+draw)*3); - prevstart = i + 1; + + /* Goal is to draw as long of a contiguous triangle + array as possible, so draw when we hit either an + invisible triangle or at the end of the array */ + if(!draw || i == tottri - 1 || mf[actualFace].mat_nr != mf[next_actualFace].mat_nr) { + if(prevstart != i) + /* Add one to the length (via `draw') + if we're drawing at the end of the array */ + glDrawArrays(GL_TRIANGLES,prevstart*3, (i-prevstart+draw)*3); + prevstart = i + 1; + } } } + glShadeModel(GL_FLAT); } GPU_buffer_unbind(); -- cgit v1.2.3 From a7258c96512d45f2392e13f5d5c8fb6edf651a00 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Oct 2010 11:16:07 +0000 Subject: - fix for crash when drawing a subsurf after a modifier that lost original indices (bevel/screw/decimate) - fix for own mistake used madd_v3_v3fl rather then mul_v3_v3fl, r32241. --- 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 d6486c3ee4d..b0ea5f979ac 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1619,8 +1619,10 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, if(drawParams) flag = drawParams(tf, mcol, mat_nr); - else + else if(index != ORIGINDEX_NONE) flag= (drawParamsMapped)? drawParamsMapped(userData, index): 1; + else + flag= 1; if (flag == 0) { /* flag 0 == the face is hidden or invisible */ if(tf) tf += gridFaces*gridFaces*numVerts; -- cgit v1.2.3 From 0eeeab515b6b46f907016091b3a89bf5e320c400 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Oct 2010 11:25:34 +0000 Subject: bugfix [#23506] Bevel Modifier display problem This is a more general problem that drawing functions would skip faces when the original index could not be found, screw result for example wasnt visible in editmode too. Fixed by adding a material set argument to DerivedMesh->drawMappedFaces(), this was already being done in some of the other drawing functions. --- source/blender/blenkernel/intern/DerivedMesh.c | 4 +- source/blender/blenkernel/intern/cdderivedmesh.c | 47 ++++++++++++------------ source/blender/blenkernel/intern/subsurf_ccg.c | 21 +++++++---- 3 files changed, 40 insertions(+), 32 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 01b02653a51..eb5d77bb9b0 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -626,7 +626,9 @@ static void emDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *use func(userData, i, cent, emdm->vertexCos?emdm->faceNos[i]:efa->n); } } -static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors) + +/* note, material function is ignored for now. */ +static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs)) { EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; EditFace *efa; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index e2ecf21bd62..b9ca7bfafe3 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -777,7 +777,7 @@ static void cdDM_drawFacesTex(DerivedMesh *dm, int (*setDrawOptions)(MTFace *tfa cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, NULL); } -static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors) +static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs)) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; MVert *mv = cddm->mvert; @@ -798,16 +798,16 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us DEBUG_VBO( "Using legacy code. cdDM_drawMappedFaces\n" ); for(i = 0; i < dm->numFaceData; i++, mf++) { int drawSmooth = (mf->flag & ME_SMOOTH); + int draw= 1; - if(index) { - orig = *index++; - if(setDrawOptions && orig == ORIGINDEX_NONE) - { if(nors) nors += 3; continue; } - } - else - orig = i; + orig= (index==NULL) ? i : *index++; + + if(orig == ORIGINDEX_NONE) + draw= setMaterial(mf->mat_nr + 1, NULL); + else if (setDrawOptions != NULL) + draw= setDrawOptions(userData, orig, &drawSmooth); - if(!setDrawOptions || setDrawOptions(userData, orig, &drawSmooth)) { + if(draw) { unsigned char *cp = NULL; if(useColors && mc) @@ -887,22 +887,19 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us for( i = 0; i < tottri; i++ ) { //int actualFace = dm->drawObject->faceRemap[i]; int actualFace = next_actualFace; - int drawSmooth = (mf[actualFace].flag & ME_SMOOTH); + MFace *mface= mf + actualFace; + int drawSmooth= (mface->flag & ME_SMOOTH); int draw = 1; if(i != tottri-1) next_actualFace= dm->drawObject->faceRemap[i+1]; - - if(index) { - orig = index[actualFace]; - if(orig == ORIGINDEX_NONE) - draw = 0; - } - else - orig = actualFace; - - if(draw && !setDrawOptions(userData, orig, &drawSmooth)) - draw = 0; + + orig= (index==NULL) ? actualFace : index[actualFace]; + + if(orig == ORIGINDEX_NONE) + draw= setMaterial(mface->mat_nr + 1, NULL); + else if (setDrawOptions != NULL) + draw= setDrawOptions(userData, orig, &drawSmooth); /* Goal is to draw as long of a contiguous triangle array as possible, so draw when we hit either an @@ -974,8 +971,12 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo else if(setDrawOptions) { orig = (index)? index[a]: a; - if(orig == ORIGINDEX_NONE) - continue; + if(orig == ORIGINDEX_NONE) { + /* since the material is set by setMaterial(), faces with no + * origin can be assumed to be generated by a modifier */ + + /* continue */ + } else if(!setDrawOptions(userData, orig)) continue; } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index b0ea5f979ac..6323e1e3c79 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1619,11 +1619,12 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, if(drawParams) flag = drawParams(tf, mcol, mat_nr); - else if(index != ORIGINDEX_NONE) + else if (index != ORIGINDEX_NONE) flag= (drawParamsMapped)? drawParamsMapped(userData, index): 1; else - flag= 1; - + flag= GPU_enable_material(mat_nr, NULL) ? 1:0; + + if (flag == 0) { /* flag 0 == the face is hidden or invisible */ if(tf) tf += gridFaces*gridFaces*numVerts; if(mcol) mcol += gridFaces*gridFaces*numVerts*4; @@ -1763,7 +1764,7 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm) } } -static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors) { +static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs)) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; MCol *mcol= NULL; @@ -1795,10 +1796,14 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *u mcol += gridFaces*gridFaces*numVerts*4; } - if (index!=-1) { - int draw; - draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, index, &drawSmooth); - + { + int draw= 1; + + if(index == ORIGINDEX_NONE) + draw= setMaterial(faceFlags ? faceFlags[origIndex*2 + 1] + 1: 1, NULL); /* XXX, no faceFlags no material */ + else if (setDrawOptions) + draw= setDrawOptions(userData, index, &drawSmooth); + if (draw) { if (draw==2) { glEnable(GL_POLYGON_STIPPLE); -- cgit v1.2.3 From 8408997c84d6c4a8b47808422ed73d7d754ff509 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 5 Oct 2010 21:22:33 +0000 Subject: remove some unused code and reduced the scope if some vars (no functional change). --- source/blender/blenkernel/intern/font.c | 8 ++++---- source/blender/blenkernel/intern/idprop.c | 9 ++------- source/blender/blenkernel/intern/image.c | 10 ++++++---- source/blender/blenkernel/intern/unit.c | 3 +-- 4 files changed, 13 insertions(+), 17 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 47627d09b97..131b16b319e 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -514,11 +514,12 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float float *fp, fsize, shear, x, si, co; VFontData *vfd = NULL; VChar *che = NULL; - int i, sel=0; + int i; vfd= vfont_get_data(which_vfont(cu, info)); if (!vfd) return; + /* if (cu->selend < cu->selstart) { if ((charidx >= (cu->selend)) && (charidx <= (cu->selstart-2))) sel= 1; @@ -527,6 +528,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float if ((charidx >= (cu->selstart-1)) && (charidx <= (cu->selend-1))) sel= 1; } + */ /* make a copy at distance ofsx,ofsy with shear*/ fsize= cu->fsize; @@ -1148,14 +1150,12 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) if(mode == FO_EDIT) { /* make nurbdata */ - unsigned long cha; - freeNurblist(&cu->nurb); ct= chartransdata; if (cu->sepchar==0) { for (i= 0; imat_nr > (ob->totcol)) { /* printf("Error: Illegal material index (%d) in text object, setting to 0\n", info->mat_nr); */ diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index a0df73d6c42..639e2062f83 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -421,9 +421,7 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src) IDProperty *loop, *prop; for (prop=src->data.group.first; prop; prop=prop->next) { for (loop=dest->data.group.first; loop; loop=loop->next) { - if (BSTR_EQ(loop->name, prop->name)) { - int copy_done= 0; - + if (strcmp(loop->name, prop->name)==0) { if(prop->type==loop->type) { switch (prop->type) { @@ -431,11 +429,9 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src) case IDP_FLOAT: case IDP_DOUBLE: loop->data= prop->data; - copy_done= 1; break; case IDP_GROUP: IDP_SyncGroupValues(loop, prop); - copy_done= 1; break; default: { @@ -702,7 +698,6 @@ IDProperty *IDP_New(int type, IDPropertyTemplate val, const char *name) case IDP_STRING: { char *st = val.str; - int stlen; prop = MEM_callocN(sizeof(IDProperty), "IDProperty string"); if (st == NULL) { @@ -710,7 +705,7 @@ IDProperty *IDP_New(int type, IDPropertyTemplate val, const char *name) prop->totallen = DEFAULT_ALLOC_FOR_NULL_STRINGS; prop->len = 1; /*NULL string, has len of 1 to account for null byte.*/ } else { - stlen = strlen(st) + 1; + int stlen = strlen(st) + 1; prop->data.pointer = MEM_callocN(stlen, "id property string 2"); prop->len = prop->totallen = stlen; strcpy(prop->data.pointer, st); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index cb2261932ce..6dd1d4280ec 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -596,7 +596,7 @@ void BKE_image_free_all_textures(void) { Tex *tex; Image *ima; - unsigned int totsize= 0; + /* unsigned int totsize= 0; */ for(ima= G.main->image.first; ima; ima= ima->id.next) ima->id.flag &= ~LIB_DOIT; @@ -607,13 +607,14 @@ void BKE_image_free_all_textures(void) for(ima= G.main->image.first; ima; ima= ima->id.next) { if(ima->ibufs.first && (ima->id.flag & LIB_DOIT)) { + /* ImBuf *ibuf; for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) { if(ibuf->mipmap[0]) totsize+= 1.33*ibuf->x*ibuf->y*4; else totsize+= ibuf->x*ibuf->y*4; - } + } */ image_free_buffers(ima); } } @@ -2183,7 +2184,7 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) void BKE_image_user_calc_frame(ImageUser *iuser, int cfra, int fieldnr) { - int imanr, len; + int len; /* here (+fie_ima/2-1) makes sure that division happens correctly */ len= (iuser->fie_ima*iuser->frames)/2; @@ -2192,8 +2193,9 @@ void BKE_image_user_calc_frame(ImageUser *iuser, int cfra, int fieldnr) iuser->framenr= 0; } else { + int imanr; cfra= cfra - iuser->sfra+1; - + /* cyclic */ if(iuser->cycl) { cfra= ( (cfra) % len ); diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 3d984c7e877..25aab77ba9b 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -398,7 +398,6 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system, /* split output makes sense only for length, mass and time */ if(split && (type==B_UNIT_LENGTH || type==B_UNIT_MASS || type==B_UNIT_TIME)) { - int i; bUnitDef *unit_a, *unit_b; double value_a, value_b; @@ -406,7 +405,7 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system, /* check the 2 is a smaller unit */ if(unit_b > unit_a) { - i= unit_as_string(str, len_max, value_a, prec, usys, unit_a, '\0'); + int i= unit_as_string(str, len_max, value_a, prec, usys, unit_a, '\0'); /* is there enough space for at least 1 char of the next unit? */ if(i+2 < len_max) { -- cgit v1.2.3 From 20d0236f10f1ae59734be692e7f42c188152f439 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 6 Oct 2010 07:57:55 +0000 Subject: Fix for [#24134] pointcache memory error (crash) --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index e1006cd99cd..4ec12b3482c 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1890,7 +1890,7 @@ int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) } if(cache->cached_frames) - cache->cached_frames[cfra] = 1; + cache->cached_frames[cfra-cache->startframe] = 1; if(pf) ptcache_file_close(pf); -- cgit v1.2.3 From d50cadbe0dd5a676c23e40b8a2939345442a4f28 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 6 Oct 2010 10:09:44 +0000 Subject: Fix for [#22236] Seg Fault when rendering sequence with speed effect, [#24160] VSE crash * Override the default render name in the case of the sequence renderer scene being included as a strip in the sequencer. * Somebody with deeper insight to the rendering pipeline should probably check if this is the best way to handle this. --- source/blender/blenkernel/intern/sequencer.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 430d6f87619..8c496fea3b0 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1861,6 +1861,15 @@ static ImBuf * seq_render_scene_strip_impl( if(rendering) re= RE_NewRender(" do_build_seq_ibuf"); + /* If the top level scene that does the sequencer rendering is included + * as a strip the default render name for the strip will conflict with + * the original render, so override the name in this case. + * See bugs #22236 and #24160 for examples. + * XXX: Somebody with deeper insight to the rendering pipeline should + * probably check if this is the best way to handle this. -jahka + */ + else if(seq->scene == scene) + re= RE_NewRender("scene_conflict_render"); else re= RE_NewRender(sce->id.name); -- cgit v1.2.3 From 8a4fe62843f8aa311226f543d14bd3e5440ffe7d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 7 Oct 2010 10:04:07 +0000 Subject: misc fixes found with clang's static checker. --- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/library.c | 9 ++++----- source/blender/blenkernel/intern/modifier.c | 4 ++-- source/blender/blenkernel/intern/pointcache.c | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 6da9f2bbabc..b2feb01352e 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -648,7 +648,7 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, totfac= data[1]+data[2]; if(totfac>FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac); - else QUATCOPY(q1, p3->quat); + else QUATCOPY(q2, p3->quat); totfac = data[0]+data[1]+data[2]+data[3]; if(totfac>FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1]+data[2]) / totfac); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 834e7de5811..93e4b5fcfbe 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "MEM_guardedalloc.h" @@ -649,11 +650,9 @@ void *copy_libblock(void *rt) lb= which_libbase(G.main, GS(id->name)); idn= alloc_libblock(lb, GS(id->name), id->name+2); - - if(idn==NULL) { - printf("ERROR: Illegal ID name for %s (Crashing now)\n", id->name); - } - + + assert(idn != NULL); + idn_len= MEM_allocN_len(idn); if(idn_len - sizeof(ID) > 0) { cp= (char *)id; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 43d26f26d1f..d7c95a007e5 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -63,8 +63,8 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) types_init= 0; } - if(type >= 0 && type < NUM_MODIFIER_TYPES && - types[type]->name[0] != '\0') { + /* type unsigned, no need to chech < 0 */ + if(type < NUM_MODIFIER_TYPES && types[type]->name[0] != '\0') { return types[type]; } else { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 4ec12b3482c..a15e66ed843 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1082,7 +1082,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup static int ptcache_path(PTCacheID *pid, char *filename) { - Library *lib= (pid)? pid->ob->id.lib: NULL; + Library *lib= (pid->ob)? pid->ob->id.lib: NULL; const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.sce; size_t i; -- cgit v1.2.3 From c6e2e7aa9374427ae114fcc532e7f2c8a8977874 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 8 Oct 2010 02:08:11 +0000 Subject: move tracking functions into math_rotation.c (no functional changes) --- source/blender/blenkernel/intern/lattice.c | 65 +++++------------------------- 1 file changed, 10 insertions(+), 55 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 1390f0dbd56..71e5049f2cc 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -599,16 +599,6 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C } #endif - - static float q_x90d[4] = {0.70710676908493, 0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180)); - static float q_y90d[4] = {0.70710676908493, 0.0, 0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180)); - static float q_z90d[4] = {0.70710676908493, 0.0, 0.0, 0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, 90 * (M_PI / 180)); - - static float q_nx90d[4] = {0.70710676908493, -0.70710676908493, 0.0, 0.0}; // float rot_axis[3]= {1,0,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180)); - static float q_ny90d[4] = {0.70710676908493, 0.0, -0.70710676908493, 0.0}; // float rot_axis[3]= {0,1,0}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180)); - static float q_nz90d[4] = {0.70710676908493, 0.0, 0.0, -0.70710676908493}; // float rot_axis[3]= {0,0,2}; axis_angle_to_quat(q, rot_axis, -90 * (M_PI / 180)); - - if(cd->no_rot_axis) { /* set by caller */ /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather then @@ -635,53 +625,18 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C * Notice X,Y,Z Up all have light colors and each ordered CCW. * * Now for Neg Up XYZ, the colors are all dark, and ordered clockwise - Campbell + * + * note: moved functions into quat_apply_track/vec_apply_track * */ + copy_qt_qt(quat, new_quat); + copy_v3_v3(cent, co); + + /* zero the axis which is not used, + * the big block of text above now applies to these 3 lines */ + quat_apply_track(quat, axis-1); + vec_apply_track(cent, axis-1); + cent[axis < 4 ? axis-1 : axis-4]= 0.0f; - switch(axis) { - case MOD_CURVE_POSX: - mul_qt_qtqt(quat, new_quat, q_y90d); - - cent[0]= 0.0; - cent[1]= co[2]; - cent[2]= co[1]; - break; - case MOD_CURVE_NEGX: - mul_qt_qtqt(quat, new_quat, q_ny90d); - - cent[0]= 0.0; - cent[1]= -co[1]; - cent[2]= co[2]; - - break; - case MOD_CURVE_POSY: - mul_qt_qtqt(quat, new_quat, q_x90d); - - cent[0]= co[2]; - cent[1]= 0.0; - cent[2]= -co[0]; - break; - case MOD_CURVE_NEGY: - mul_qt_qtqt(quat, new_quat, q_nx90d); - - cent[0]= -co[0]; - cent[1]= 0.0; - cent[2]= -co[2]; - break; - case MOD_CURVE_POSZ: - mul_qt_qtqt(quat, new_quat, q_z90d); - - cent[0]= co[1]; - cent[1]= -co[0]; - cent[2]= 0.0; - break; - case MOD_CURVE_NEGZ: - mul_qt_qtqt(quat, new_quat, q_nz90d); - - cent[0]= co[0]; - cent[1]= -co[1]; - cent[2]= 0.0; - break; - } /* scale if enabled */ if(cu->flag & CU_PATH_RADIUS) -- cgit v1.2.3 From 65b0893df0c82b04701f5f39c725df983c19f0c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 8 Oct 2010 07:29:08 +0000 Subject: bugfix [#21483] Twisting when Dupliframing a Surface Circle (Nurbs) along a Curve. use the curve's twist for follow path constraint and parent-path. --- source/blender/blenkernel/intern/constraint.c | 16 +++++++++++----- source/blender/blenkernel/intern/lattice.c | 2 +- source/blender/blenkernel/intern/object.c | 10 +++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index fe69f13bbda..3df395244f4 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1201,7 +1201,7 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr if (VALID_CONS_TARGET(ct)) { Curve *cu= ct->tar->data; - float q[4], vec[4], dir[3], quat[4], radius, x1; + float vec[4], dir[3], radius; float totmat[4][4]; float curvetime; @@ -1217,7 +1217,8 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr makeDispListCurveTypes(cob->scene, ct->tar, 0); if (cu->path && cu->path->data) { - if ((data->followflag & FOLLOWPATH_STATIC) == 0) { + float quat[4]; + if ((data->followflag & FOLLOWPATH_STATIC) == 0) { /* animated position along curve depending on time */ if (cob->scene) curvetime= bsystem_time(cob->scene, ct->tar, cu->ctime, 0.0) - data->offset; @@ -1238,8 +1239,10 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr curvetime= data->offset_fac; } - if ( where_on_path(ct->tar, curvetime, vec, dir, NULL, &radius, NULL) ) { + if ( where_on_path(ct->tar, curvetime, vec, dir, (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, &radius, NULL) ) { /* quat_pt is quat or NULL*/ if (data->followflag & FOLLOWPATH_FOLLOW) { +#if 0 + float x1, q[4]; vec_to_quat(quat, dir, (short)data->trackflag, (short)data->upflag); normalize_v3(dir); @@ -1249,10 +1252,13 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr q[2]= -x1*dir[1]; q[3]= -x1*dir[2]; mul_qt_qtqt(quat, q, quat); - +#else + quat_apply_track(quat, data->trackflag, data->upflag); +#endif + quat_to_mat4(totmat, quat); } - + if (data->followflag & FOLLOWPATH_RADIUS) { float tmat[4][4], rmat[4][4]; scale_m4_fl(tmat, radius); diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 71e5049f2cc..638cab58229 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -633,7 +633,7 @@ static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, C /* zero the axis which is not used, * the big block of text above now applies to these 3 lines */ - quat_apply_track(quat, axis-1); + quat_apply_track(quat, axis-1, (axis==1 || axis==3) ? 1:0); /* up flag is a dummy, set so no rotation is done */ vec_apply_track(cent, axis-1); cent[axis < 4 ? axis-1 : axis-4]= 0.0f; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index d9ee67920eb..0c437db335b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1791,9 +1791,10 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) /* vec: 4 items! */ - if( where_on_path(par, ctime, vec, dir, NULL, &radius, NULL) ) { + if( where_on_path(par, ctime, vec, dir, cu->flag & CU_FOLLOW ? quat:NULL, &radius, NULL) ) { if(cu->flag & CU_FOLLOW) { +#if 0 vec_to_quat( quat,dir, ob->trackflag, ob->upflag); /* the tilt */ @@ -1804,8 +1805,11 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) q[2]= -x1*dir[1]; q[3]= -x1*dir[2]; mul_qt_qtqt(quat, q, quat); - - quat_to_mat4( mat,quat); +#else + quat_apply_track(quat, ob->trackflag, ob->upflag); +#endif + + quat_to_mat4(mat,quat); } if(cu->flag & CU_PATH_RADIUS) { -- cgit v1.2.3 From 48d2aac250624664cd1db77470af0fc45526f3c9 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 8 Oct 2010 13:08:13 +0000 Subject: Fix for [#24092] F-Curve Cycle doesn't behave properly at end of Cycles (also: possible problem with how the cycle range is determined) * Cycle code had difficulties handling the transitions from one cycle iteration to the next one. * Now the transition frames are handled manually so that: - cycles before the actual fcurve data respect the first datapoint - cycles after the fcurve data respect the last datapoint * Also fixes a bug where the count of "before" cycles was off by one from the given value. --- source/blender/blenkernel/intern/fmodifier.c | 40 ++++++++++++++++++---------- 1 file changed, 26 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index f63b58fe489..5a10f93ac72 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -529,7 +529,7 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float e FMod_Cycles *data= (FMod_Cycles *)fcm->data; float prevkey[2], lastkey[2], cycyofs=0.0f; short side=0, mode=0; - int cycles=0; + int cycles=0, ofs=0; /* check if modifier is first in stack, otherwise disable ourself... */ // FIXME... @@ -571,6 +571,7 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float e side= -1; mode= data->before_mode; cycles= data->before_cycles; + ofs= prevkey[0]; } } else if (evaltime > lastkey[0]) { @@ -578,6 +579,7 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float e side= 1; mode= data->after_mode; cycles= data->after_cycles; + ofs= lastkey[0]; } } if ELEM(0, side, mode) @@ -585,11 +587,8 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float e /* find relative place within a cycle */ { - float cycdx=0, cycdy=0, ofs=0; - float cycle= 0; - - /* ofs is start frame of cycle */ - ofs= prevkey[0]; + float cycdx=0, cycdy=0; + float cycle= 0, cyct=0; /* calculate period and amplitude (total height) of a cycle */ cycdx= lastkey[0] - prevkey[0]; @@ -601,6 +600,9 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float e /* calculate the 'number' of the cycle */ cycle= ((float)side * (evaltime - ofs) / cycdx); + + /* calculate the time inside the cycle */ + cyct= fmod(evaltime - ofs, cycdx); /* check that cyclic is still enabled for the specified time */ if (cycles == 0) { @@ -608,7 +610,7 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float e * as this indicates infinite cycles... */ } - else if (cycle > (cycles+1)) { + else if (cycle > cycles) { /* we are too far away from range to evaluate * TODO: but we should still hold last value... */ @@ -617,26 +619,36 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float e /* check if 'cyclic extrapolation', and thus calculate y-offset for this cycle */ if (mode == FCM_EXTRAPOLATE_CYCLIC_OFFSET) { - cycyofs = (float)floor((evaltime - ofs) / cycdx); + if(side < 0) + cycyofs = (float)floor((evaltime - ofs) / cycdx); + else + cycyofs = (float)ceil((evaltime - ofs) / cycdx); cycyofs *= cycdy; } - + + /* special case for cycle start/end */ + if(cyct == 0.0f) { + evaltime = (side == 1 ? lastkey[0] : prevkey[0]); + + if((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)cycle % 2)) + evaltime = (side == 1 ? prevkey[0] : lastkey[0]); + } /* calculate where in the cycle we are (overwrite evaltime to reflect this) */ - if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle) % 2)) { + else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle+1) % 2)) { /* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse * - for 'before' extrapolation, we need to flip in a different way, otherwise values past * then end of the curve get referenced (result of fmod will be negative, and with different phase) */ if (side < 0) - evaltime= (float)(prevkey[0] - fmod(evaltime-ofs, cycdx)); + evaltime= prevkey[0] - cyct; else - evaltime= (float)(lastkey[0] - fmod(evaltime-ofs, cycdx)); + evaltime= lastkey[0] - cyct; } else { /* the cycle is played normally... */ - evaltime= (float)(fmod(evaltime-ofs, cycdx) + ofs); + evaltime= prevkey[0] + cyct; } - if (evaltime < ofs) evaltime += cycdx; + if (evaltime < prevkey[0]) evaltime += cycdx; } /* store temp data if needed */ -- cgit v1.2.3 From f49fc58df63d42ab451380ea92e55b1265d14e4e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Oct 2010 07:01:56 +0000 Subject: enable building the game engine without bullet for scons & cmake --- source/blender/blenkernel/intern/object.c | 3 ++- 1 file changed, 2 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 0c437db335b..541e8e2b00e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1743,7 +1743,7 @@ int enable_cu_speed= 1; static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) { Curve *cu; - float q[4], vec[4], dir[3], quat[4], radius, x1, ctime; + float vec[4], dir[3], quat[4], radius, ctime; float timeoffs = 0.0, sf_orig = 0.0; unit_m4(mat); @@ -1795,6 +1795,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) if(cu->flag & CU_FOLLOW) { #if 0 + float x1, q[4]; vec_to_quat( quat,dir, ob->trackflag, ob->upflag); /* the tilt */ -- cgit v1.2.3 From 52e6058bb4ee2916f440e7103e4067ec522a144e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 10 Oct 2010 21:39:24 +0000 Subject: [#24204] Packing of image sequence does not work this isnt supported but at least display a warning. --- source/blender/blenkernel/intern/packedFile.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 919a724d1ec..5bbb3506a78 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -214,10 +214,17 @@ void packAll(Main *bmain, ReportList *reports) Image *ima; VFont *vf; bSound *sound; - - for(ima=bmain->image.first; ima; ima=ima->id.next) - if(ima->packedfile == NULL && ima->id.lib==NULL && ELEM3(ima->source, IMA_SRC_FILE, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) - ima->packedfile = newPackedFile(reports, ima->name); + + for(ima=bmain->image.first; ima; ima=ima->id.next) { + if(ima->packedfile == NULL && ima->id.lib==NULL) { + if(ima->source==IMA_SRC_FILE) { + ima->packedfile = newPackedFile(reports, ima->name); + } + else if(ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { + BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name+2); + } + } + } for(vf=bmain->vfont.first; vf; vf=vf->id.next) if(vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, "") != 0) -- cgit v1.2.3 From fab8deb811d0e3cd36b379fd795d3191282f7825 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 11 Oct 2010 04:00:33 +0000 Subject: bugfix [#20761] Bones/Armature: "Inherit Scale" doesn't work if "Inherit Rotation" is disabled --- source/blender/blenkernel/intern/armature.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 2e760f53155..f1f9fe08717 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2239,13 +2239,28 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti offs_bone[3][1]+= parbone->length; /* Compose the matrix for this bone */ - if(bone->flag & BONE_HINGE) { // uses restposition rotation, but actual position + if((bone->flag & BONE_HINGE) && (bone->flag & BONE_NO_SCALE)) { // uses restposition rotation, but actual position float tmat[4][4]; - /* the rotation of the parent restposition */ copy_m4_m4(tmat, parbone->arm_mat); mul_serie_m4(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); } + else if(bone->flag & BONE_HINGE) { // same as above but apply parent scale + float tmat[4][4]; + + /* apply the parent matrix scale */ + float tsmat[4][4], tscale[3]; + + /* the rotation of the parent restposition */ + copy_m4_m4(tmat, parbone->arm_mat); + + /* extract the scale of the parent matrix */ + mat4_to_size(tscale, parchan->pose_mat); + size_to_mat4(tsmat, tscale); + mul_m4_m4m4(tmat, tmat, tsmat); + + mul_serie_m4(pchan->pose_mat, tmat, offs_bone, pchan->chan_mat, NULL, NULL, NULL, NULL, NULL); + } else if(bone->flag & BONE_NO_SCALE) { float orthmat[4][4]; -- cgit v1.2.3 From 7ab02f1ec17b4a48aedb2ab4ec43d0fe2d62c565 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 11 Oct 2010 09:02:19 +0000 Subject: Fix for [#24195] Cloth modifier doesn't work after changing subsurf on the object * Cloth has to reset itself properly on vertex count changes as it can be after a constructive modifier (unlike softbody) --- source/blender/blenkernel/intern/cloth.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index be1552a882d..3f47676d7fd 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -446,7 +446,9 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, return dm; } - if(clmd->sim_parms->reset || (framenr == (startframe - clmd->sim_parms->preroll) && clmd->sim_parms->preroll != 0)) + if(clmd->sim_parms->reset + || (framenr == (startframe - clmd->sim_parms->preroll) && clmd->sim_parms->preroll != 0) + || (clmd->clothObject && result->getNumVerts(result) != clmd->clothObject->numverts)) { clmd->sim_parms->reset = 0; cache->flag |= PTCACHE_OUTDATED; @@ -457,17 +459,6 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, return result; } - /* verify we still have the same number of vertices, if not do nothing. - * note that this should only happen if the number of vertices changes - * during an animation due to a preceding modifier, this should not - * happen because of object changes! */ - if(clmd->clothObject) { - if(result->getNumVerts(result) != clmd->clothObject->numverts) { - BKE_ptcache_invalidate(cache); - return result; - } - } - // unused in the moment, calculated separately in implicit.c clmd->sim_parms->dt = clmd->sim_parms->timescale / clmd->sim_parms->stepsPerFrame; -- cgit v1.2.3 From 4754d6a27d28eb0a244a49f147b588721fcecfbb Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 12 Oct 2010 10:30:29 +0000 Subject: Fix for [#24169] Sequencer segfaults often when scrubbing to frame zero --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 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 8c496fea3b0..040ca832a80 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1005,7 +1005,7 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se } } - for (;b <= chanshown; b++) { + for (;b <= chanshown && b >= 0; b++) { if (video_seq_is_rendered(seq_arr[b])) { seq_arr_out[cnt++] = seq_arr[b]; } -- cgit v1.2.3 From b64098a85af30a1d5f74fbb876e939905a2cc44f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Oct 2010 21:47:13 +0000 Subject: bugfix [#22407] Object level proxies ignore transform of original --- source/blender/blenkernel/intern/object.c | 35 ++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 541e8e2b00e..861904335d7 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1264,6 +1264,17 @@ static void copy_object_pose(Object *obn, Object *ob) } } +static void copy_object_transform(Object *ob_tar, Object *ob_src) +{ + copy_v3_v3(ob_tar->loc, ob_src->loc); + copy_v3_v3(ob_tar->rot, ob_src->rot); + copy_v3_v3(ob_tar->quat, ob_src->quat); + copy_v3_v3(ob_tar->rotAxis, ob_src->rotAxis); + ob_tar->rotAngle= ob_src->rotAngle; + ob_tar->rotmode= ob_src->rotmode; + copy_v3_v3(ob_tar->size, ob_src->size); +} + Object *copy_object(Object *ob) { Object *obn; @@ -1530,23 +1541,23 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) ob->recalc= target->recalc= OB_RECALC_ALL; - /* copy transform */ + /* copy transform + * - gob means this proxy comes from a group, just apply the matrix + * so the object wont move from its dupli-transform. + * + * - no gob means this is being made from a linked object, + * this is closer to making a copy of the object - in-place. */ if(gob) { - VECCOPY(ob->loc, gob->loc); - VECCOPY(ob->rot, gob->rot); - VECCOPY(ob->size, gob->size); - - group_tag_recalc(gob->dup_group); + ob->rotmode= target->rotmode; + mul_m4_m4m4(ob->obmat, target->obmat, gob->obmat); + object_apply_mat4(ob, ob->obmat); } else { - VECCOPY(ob->loc, target->loc); - VECCOPY(ob->rot, target->rot); - VECCOPY(ob->size, target->size); + copy_object_transform(ob, target); + ob->parent= target->parent; /* libdata */ + copy_m4_m4(ob->parentinv, target->parentinv); } - ob->parent= target->parent; /* libdata */ - copy_m4_m4(ob->parentinv, target->parentinv); - /* copy animdata stuff - drivers only for now... */ object_copy_proxy_drivers(ob, target); -- cgit v1.2.3 From 1eda2c85949ed0fa67d3026e078588d0820826ad Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 13 Oct 2010 11:40:59 +0000 Subject: Fix for [#24205] Multilayer EXR files used as input sequence are displayed incorrectly * Image buffer profile wasn't set to linear rgb for multilayer image sequences --- source/blender/blenkernel/intern/image.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 6dd1d4280ec..e356e40c6fd 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1685,6 +1685,7 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f ibuf->flags |= IB_rectfloat; ibuf->mall= IB_rectfloat; ibuf->channels= rpass->channels; + ibuf->profile = IB_PROFILE_LINEAR_RGB; image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, iuser?iuser->multi_index:0, frame); -- cgit v1.2.3 From be32cf8b3218eb0d52eadc99d31f12ed0bbc2ec7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 13 Oct 2010 23:25:08 +0000 Subject: UNUSED() macro so -Wunused-parameter can be used with GCC without so many warnings. applied to python api and exotic.c, removed some args being passed down which were not needed. keyword args for new mathutils types were being ignored when they should raise an error. --- source/blender/blenkernel/intern/exotic.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 9dac409226b..c5431005b18 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -557,7 +557,7 @@ static int write_derivedmesh_stl(FILE *fpSTL, Object *ob, DerivedMesh *dm) return numfacets; } -static int write_object_stl(FILE *fpSTL, Scene *scene, Object *ob, Mesh *me) +static int write_object_stl(FILE *fpSTL, Scene *scene, Object *ob) { int numfacets = 0; DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); @@ -572,7 +572,6 @@ static int write_object_stl(FILE *fpSTL, Scene *scene, Object *ob, Mesh *me) void write_stl(Scene *scene, char *str) { Object *ob; - Mesh *me; Base *base; FILE *fpSTL; int numfacets = 0; @@ -605,9 +604,8 @@ void write_stl(Scene *scene, char *str) if (base->flag & SELECT) { ob = base->object; if (ob->type == OB_MESH) { - me = ob->data; - if (me) - numfacets += write_object_stl(fpSTL, scene, ob, me); + if(ob->data) + numfacets += write_object_stl(fpSTL, scene, ob); } } base= base->next; @@ -978,7 +976,7 @@ static int all_digits(char *str) return 1; } -static int dxf_get_layer_col(char *layer) +static int dxf_get_layer_col(char *UNUSED(layer)) { return 1; } @@ -1016,8 +1014,8 @@ static void myfgets(char *str, int len, FILE *fp) /* three types of enters, \n \r and \r\n */ if(c == '\n') break; if(c=='\r') { - c= getc(dxf_fp); // read the linefeed from stream - if(c != 10) ungetc(c, dxf_fp); // put back, if it's not one... + c= getc(fp); // read the linefeed from stream + if(c != 10) ungetc(c, fp); // put back, if it's not one... break; } } -- cgit v1.2.3 From fbf208d63fe0ba9770cb225726eb94888aa0994d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 14 Oct 2010 06:29:17 +0000 Subject: add UNUSED() to modifiers, also removed some unused args. --- source/blender/blenkernel/intern/modifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index d7c95a007e5..dc2992662c9 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -59,7 +59,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) static int types_init = 1; if (types_init) { - modifier_type_init(types, type); /* MOD_utils.c */ + modifier_type_init(types); /* MOD_utils.c */ types_init= 0; } @@ -492,7 +492,7 @@ int modifier_isCorrectableDeformed(ModifierData *md) return 0; } -int modifiers_isCorrectableDeformed(struct Scene *scene, Object *ob) +int modifiers_isCorrectableDeformed(Object *ob) { ModifierData *md = modifiers_getVirtualModifierList(ob); -- cgit v1.2.3 From d3bf6b7224d63420232464381203d51125dd3374 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 14 Oct 2010 09:01:03 +0000 Subject: Fix for [#24237] Hair dynamics with zero particles generates a segmentation fault --- source/blender/blenkernel/intern/particle.c | 1 + source/blender/blenkernel/intern/particle_system.c | 7 ++++++- source/blender/blenkernel/intern/pointcache.c | 14 +++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 723ff7faed3..ebbb3ea1020 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -402,6 +402,7 @@ void free_hair(Object *ob, ParticleSystem *psys, int dynamics) modifier_free((ModifierData*)psys->clmd); psys->clmd = NULL; + psys->pointcache = BKE_ptcache_add(&psys->ptcaches); } else { cloth_free_modifier(ob, psys->clmd); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 47a220dcefb..fa82d2c5359 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4016,8 +4016,13 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) switch(part->type) { case PART_HAIR: { + /* nothing to do so bail out early */ + if(psys->totpart == 0 && part->totpart == 0) { + psys_free_path_cache(psys, NULL); + free_hair(ob, psys, 0); + } /* (re-)create hair */ - if(hair_needs_recalc(psys)) { + else if(hair_needs_recalc(psys)) { float hcfra=0.0f; int i, recalc = psys->recalc; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index a15e66ed843..f9d2c1c3fec 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2993,13 +2993,17 @@ void BKE_ptcache_update_info(PTCacheID *pid) void BKE_ptcache_validate(PointCache *cache, int framenr) { - cache->flag |= PTCACHE_SIMULATION_VALID; - cache->simframe = framenr; + if(cache) { + cache->flag |= PTCACHE_SIMULATION_VALID; + cache->simframe = framenr; + } } void BKE_ptcache_invalidate(PointCache *cache) { - cache->flag &= ~PTCACHE_SIMULATION_VALID; - cache->simframe = 0; - cache->last_exact = MIN2(cache->startframe, 0); + if(cache) { + cache->flag &= ~PTCACHE_SIMULATION_VALID; + cache->simframe = 0; + cache->last_exact = MIN2(cache->startframe, 0); + } } -- cgit v1.2.3 From 6e2e7c00c1ca2f5053ef989b4d1564c4a1b24e6f Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Thu, 14 Oct 2010 10:34:04 +0000 Subject: fix potential crasher: malloc->calloc --- source/blender/blenkernel/intern/mesh.c | 2 +- 1 file changed, 1 insertion(+), 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 6f1cdefbcad..3e9287dd511 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1221,7 +1221,7 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float **faceNors_r) { float (*tnorms)[3]= MEM_callocN(numVerts*sizeof(*tnorms), "tnorms"); - float *fnors= MEM_mallocN(sizeof(*fnors)*3*numFaces, "meshnormals"); + float *fnors= MEM_callocN(sizeof(*fnors)*3*numFaces, "meshnormals"); int i; for (i=0; i Date: Fri, 15 Oct 2010 05:18:45 +0000 Subject: replace SIDE_OF_LINE macro with line_point_side_v2() inline function. made a number of files build without unused warnings. --- source/blender/blenkernel/intern/displist.c | 2 +- source/blender/blenkernel/intern/library.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index d0336d9f786..2ab7e32a9c6 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -979,7 +979,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) dl= dl->next; } - if(totvert && BLI_edgefill(0, 0)) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { + if(totvert && BLI_edgefill(0)) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { /* count faces */ tot= 0; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 93e4b5fcfbe..3f94992cd11 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -71,6 +71,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BKE_utildefines.h" #include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_library.h" @@ -668,7 +669,7 @@ void *copy_libblock(void *rt) return idn; } -static void free_library(Library *lib) +static void free_library(Library *UNUSED(lib)) { /* no freeing needed for libraries yet */ } @@ -680,7 +681,7 @@ void set_free_windowmanager_cb(void (*func)(bContext *C, wmWindowManager *) ) free_windowmanager_cb= func; } -void animdata_dtar_clear_cb(ID *id, AnimData *adt, void *userdata) +void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata) { ChannelDriver *driver; FCurve *fcu; -- cgit v1.2.3 From f756a047e6ec13762f7f90dd03b72794e986459c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Oct 2010 09:07:19 +0000 Subject: bugfix [#24264] toggle UV selection fails. was using the 4th selection flag on tri's. also some minor changes, removed unused args and corrected some comments. --- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index eb5d77bb9b0..496bcc0f88c 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2237,7 +2237,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) Object *obact = scene->basact?scene->basact->object:NULL; int editing = paint_facesel_test(ob); /* weight paint and face select need original indicies because of selection buffer drawing */ - int needMapping = (ob==obact) && (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT|OB_MODE_VERTEX_PAINT)) || editing); + int needMapping = (ob==obact) && (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT|OB_MODE_VERTEX_PAINT))); clear_mesh_caches(ob); -- cgit v1.2.3 From db09ca106dfddd64e62ca7da4c85e720007aba4b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 15 Oct 2010 12:29:02 +0000 Subject: remove/tag unused args for view*.c, gpu*.c & image*.c --- source/blender/blenkernel/intern/image.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index e356e40c6fd..fec713805e3 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -330,7 +330,7 @@ void BKE_image_merge(Image *dest, Image *source) /* otherwise creates new. */ /* does not load ibuf itself */ /* pass on optional frame for #name images */ -Image *BKE_add_image_file(const char *name, int frame) +Image *BKE_add_image_file(const char *name) { Image *ima; int file, len; @@ -397,7 +397,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, char *name, rect= (unsigned char*)ibuf->rect; } - strcpy(ibuf->name, "//Untitled"); + BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); ibuf->userflags |= IB_BITMAPDIRTY; switch(uvtestgrid) { @@ -1202,7 +1202,8 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimtype, int quality) { int ok; - + (void)subimtype; /* quies unused warnings */ + if(imtype==0) { /* pass */ } -- cgit v1.2.3 From 1807beabf5372f297329b6be2ab3ba89f954d33a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Oct 2010 02:40:31 +0000 Subject: - UNUSED macro wasn't throwing an error with GCC if a var become used. - made interface, windowmanager, readfile build without unused warnings. - re-arranged CMake's source/blender build order so less changed libs are build later, eg: IK, avi --- source/blender/blenkernel/intern/blender.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index d120b42a286..5fcf3c77d3b 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -365,7 +365,7 @@ void BKE_userdef_free(void) 2: OK, and with new user settings */ -int BKE_read_file(bContext *C, char *dir, void *unused, ReportList *reports) +int BKE_read_file(bContext *C, char *dir, ReportList *reports) { BlendFileData *bfd; int retval= 1; @@ -392,7 +392,7 @@ int BKE_read_file(bContext *C, char *dir, void *unused, ReportList *reports) return (bfd?retval:0); } -int BKE_read_file_from_memory(bContext *C, char* filebuf, int filelength, void *unused, ReportList *reports) +int BKE_read_file_from_memory(bContext *C, char* filebuf, int filelength, ReportList *reports) { BlendFileData *bfd; @@ -474,7 +474,7 @@ static int read_undosave(bContext *C, UndoElem *uel) G.fileflags |= G_FILE_NO_UI; if(UNDO_DISK) - success= BKE_read_file(C, uel->str, NULL, NULL); + success= BKE_read_file(C, uel->str, NULL); else success= BKE_read_file_from_memfile(C, &uel->memfile, NULL); @@ -554,7 +554,7 @@ void BKE_write_undo(bContext *C, char *name) if(curundo->prev) prevfile= &(curundo->prev->memfile); memused= MEM_get_memory_in_use(); - success= BLO_write_file_mem(CTX_data_main(C), prevfile, &curundo->memfile, G.fileflags, NULL); + success= BLO_write_file_mem(CTX_data_main(C), prevfile, &curundo->memfile, G.fileflags); curundo->undosize= MEM_get_memory_in_use() - memused; } -- cgit v1.2.3 From 00e3ef9b132db3c9136322bd7de1e50c862e883c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 16 Oct 2010 04:14:26 +0000 Subject: Bugfix #24143: Edit NLA Strips When editing an action used by a NLA strip and editing it 'in place' (controlled by pin icon on green 'tweaking' channel), the animation would only get played back in the action's original frame range while the keyframes were still displayed in the strip-altered positions. --- source/blender/blenkernel/intern/anim_sys.c | 34 ++++++++++++++++++----------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 10c2c1801cb..ea0b2945821 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1607,7 +1607,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) /* 1. get the stack of strips to evaluate at current time (influence calculated here) */ for (nlt=adt->nla_tracks.first; nlt; nlt=nlt->next, track_index++) { - /* if tweaking is on and this strip is the tweaking track, stop on this one */ + /* stop here if tweaking is on and this strip is the tweaking track (it will be the first one that's 'disabled')... */ if ((adt->flag & ADT_NLA_EDIT_ON) && (nlt->flag & NLATRACK_DISABLED)) break; @@ -1634,22 +1634,30 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) */ if ((adt->action) && !(adt->flag & ADT_NLA_SOLO_TRACK)) { /* if there are strips, evaluate action as per NLA rules */ - if (has_strips) { + if ((has_strips) || (adt->actstrip)) { /* make dummy NLA strip, and add that to the stack */ memset(&dummy_strip, 0, sizeof(NlaStrip)); dummy_trackslist.first= dummy_trackslist.last= &dummy_strip; - dummy_strip.act= adt->action; - dummy_strip.remap= adt->remap; - - /* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */ - calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1); - dummy_strip.start = dummy_strip.actstart; - dummy_strip.end = (IS_EQ(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend); - - dummy_strip.blendmode= adt->act_blendmode; - dummy_strip.extendmode= adt->act_extendmode; - dummy_strip.influence= adt->act_influence; + if ((nlt) && !(adt->flag & ADT_NLA_EDIT_NOMAP)) { + /* edit active action in-place according to its active strip, so copy the data */ + memcpy(&dummy_strip, adt->actstrip, sizeof(NlaStrip)); + dummy_strip.next = dummy_strip.prev = NULL; + } + else { + /* set settings of dummy NLA strip from AnimData settings */ + dummy_strip.act= adt->action; + dummy_strip.remap= adt->remap; + + /* action range is calculated taking F-Modifiers into account (which making new strips doesn't do due to the troublesome nature of that) */ + calc_action_range(dummy_strip.act, &dummy_strip.actstart, &dummy_strip.actend, 1); + dummy_strip.start = dummy_strip.actstart; + dummy_strip.end = (IS_EQ(dummy_strip.actstart, dummy_strip.actend)) ? (dummy_strip.actstart + 1.0f): (dummy_strip.actend); + + dummy_strip.blendmode= adt->act_blendmode; + dummy_strip.extendmode= adt->act_extendmode; + dummy_strip.influence= adt->act_influence; + } /* add this to our list of evaluation strips */ nlastrips_ctime_get_strip(&estrips, &dummy_trackslist, -1, ctime); -- cgit v1.2.3 From e5fbd93cecc8527467cfe33a4c74a252c3d39828 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Oct 2010 08:03:28 +0000 Subject: editors/space_* build without unused args warnings --- source/blender/blenkernel/intern/anim_sys.c | 10 +++++----- source/blender/blenkernel/intern/sequencer.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index ea0b2945821..22f5ac181f1 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -565,7 +565,7 @@ void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newNa /* Find the first path that matches the given criteria */ // TODO: do we want some method to perform partial matches too? -KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int group_mode) +KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[], const char rna_path[], int array_index, int UNUSED(group_mode)) { KS_Path *ksp; @@ -767,7 +767,7 @@ void BKE_keyingsets_free (ListBase *list) * - path: original path string (as stored in F-Curve data) * - dst: destination string to write data to */ -static short animsys_remap_path (AnimMapper *remap, char *path, char **dst) +static short animsys_remap_path (AnimMapper *UNUSED(remap), char *path, char **dst) { /* is there a valid remapping table to use? */ //if (remap) { @@ -1693,7 +1693,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) /* Clear all overides */ /* Add or get existing Override for given setting */ -AnimOverride *BKE_animsys_validate_override (PointerRNA *ptr, char *path, int array_index) +AnimOverride *BKE_animsys_validate_override (PointerRNA *UNUSED(ptr), char *UNUSED(path), int UNUSED(array_index)) { // FIXME: need to define how to get overrides return NULL; @@ -1702,7 +1702,7 @@ AnimOverride *BKE_animsys_validate_override (PointerRNA *ptr, char *path, int ar /* -------------------- */ /* Evaluate Overrides */ -static void animsys_evaluate_overrides (PointerRNA *ptr, AnimData *adt, float ctime) +static void animsys_evaluate_overrides (PointerRNA *ptr, AnimData *adt) { AnimOverride *aor; @@ -1801,7 +1801,7 @@ void BKE_animsys_evaluate_animdata (ID *id, AnimData *adt, float ctime, short re * - Overrides are cleared upon frame change and/or keyframing * - It is best that we execute this everytime, so that no errors are likely to occur. */ - animsys_evaluate_overrides(&id_ptr, adt, ctime); + animsys_evaluate_overrides(&id_ptr, adt); /* clear recalc flag now */ adt->recalc= 0; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 040ca832a80..dcd411409f9 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(Main *bmain, Scene *scene, Sequence * seq, int lock_range) +void reload_sequence_new_file(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(Main *bmain, Scene *scene, Sequence * seq, int loc seq->strip->len = seq->len; } else if (seq->type == SEQ_SCENE) { /* 'seq->scenenr' should be replaced with something more reliable */ - Scene * sce = bmain->scene.first; + Scene * sce = G.main->scene.first; int nr = 1; while(sce) { -- cgit v1.2.3 From 7cc5aaf18afd882ee8fefdf773fb83eb2e0f467b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 16 Oct 2010 11:52:30 +0000 Subject: Added panel for accessing the "delta transforms" for Objects (this is closed by default to not clutter that much). This should help silence complaints from some about "dloc",etc. not being easily keyable. It's also a nice way to have instances of animated objects located in different places, by animating either the standard transforms or the deltas, and then modifying by not animating the other version to keep the instances from going to a single point. This was a common newbie problem in 2.4x. --- source/blender/blenkernel/intern/object.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 861904335d7..3df9bd6ed05 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1646,7 +1646,7 @@ void object_scale_to_mat3(Object *ob, float mat[][3]) size_to_mat3( mat,vec); } -// TODO: this should take rotation orders into account later... + void object_rot_to_mat3(Object *ob, float mat[][3]) { float rmat[3][3], dmat[3][3]; @@ -1675,7 +1675,6 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) } /* combine these rotations */ - // XXX is this correct? if errors, change the order of multiplication... mul_m3_m3m3(mat, dmat, rmat); } -- cgit v1.2.3 From 8268a4be71fe326b5b7b43e5e55ef751844dddbc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Oct 2010 14:32:17 +0000 Subject: most unused arg warnings corrected. - removed deprecated bitmap arg from IMB_allocImBuf (plugins will need updating). - mostly tagged UNUSED() since some of these functions look like they may need to have the arguments used later. --- source/blender/blenkernel/intern/BME_tools.c | 4 +- source/blender/blenkernel/intern/DerivedMesh.c | 19 ++-- source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/armature.c | 8 +- source/blender/blenkernel/intern/boids.c | 4 +- source/blender/blenkernel/intern/brush.c | 6 +- source/blender/blenkernel/intern/bvhutils.c | 2 +- source/blender/blenkernel/intern/cdderivedmesh.c | 6 +- source/blender/blenkernel/intern/cloth.c | 22 ++-- source/blender/blenkernel/intern/collision.c | 4 +- source/blender/blenkernel/intern/colortools.c | 10 +- source/blender/blenkernel/intern/constraint.c | 32 +++--- source/blender/blenkernel/intern/curve.c | 8 +- source/blender/blenkernel/intern/customdata.c | 6 +- source/blender/blenkernel/intern/customdata_file.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 4 +- source/blender/blenkernel/intern/displist.c | 4 +- source/blender/blenkernel/intern/effect.c | 4 +- source/blender/blenkernel/intern/fcurve.c | 4 +- source/blender/blenkernel/intern/fmodifier.c | 20 ++-- source/blender/blenkernel/intern/group.c | 3 +- source/blender/blenkernel/intern/image.c | 20 ++-- source/blender/blenkernel/intern/implicit.c | 4 +- source/blender/blenkernel/intern/ipo.c | 4 +- source/blender/blenkernel/intern/key.c | 4 +- source/blender/blenkernel/intern/library.c | 4 +- source/blender/blenkernel/intern/mesh.c | 12 +-- source/blender/blenkernel/intern/multires.c | 6 +- source/blender/blenkernel/intern/nla.c | 2 +- source/blender/blenkernel/intern/object.c | 4 +- source/blender/blenkernel/intern/packedFile.c | 2 +- source/blender/blenkernel/intern/paint.c | 3 +- source/blender/blenkernel/intern/particle.c | 16 +-- source/blender/blenkernel/intern/particle_system.c | 12 +-- source/blender/blenkernel/intern/pointcache.c | 26 ++--- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenkernel/intern/seqeffects.c | 118 ++++++++++----------- source/blender/blenkernel/intern/sequencer.c | 20 ++-- source/blender/blenkernel/intern/smoke.c | 4 +- source/blender/blenkernel/intern/softbody.c | 6 +- source/blender/blenkernel/intern/sound.c | 10 +- source/blender/blenkernel/intern/writeavi.c | 4 +- .../blender/blenkernel/intern/writeframeserver.c | 9 +- 44 files changed, 240 insertions(+), 228 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index 7d9c9a431f8..e5a355e5f24 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -918,7 +918,7 @@ static int BME_face_sharededges(BME_Poly *f1, BME_Poly *f2){ * Returns - * A BME_Mesh pointer to the BMesh passed as a parameter. */ -static BME_Mesh *BME_bevel_initialize(BME_Mesh *bm, int options, int defgrp_index, float angle, BME_TransData_Head *td) { +static BME_Mesh *BME_bevel_initialize(BME_Mesh *bm, int options, int UNUSED(defgrp_index), float angle, BME_TransData_Head *td) { BME_Vert *v; BME_Edge *e; BME_Poly *f; @@ -1162,7 +1162,7 @@ static void bmesh_dissolve_disk(BME_Mesh *bm, BME_Vert *v){ //BME_JEKV(bm,v->edge,v); } } -static BME_Mesh *BME_bevel_mesh(BME_Mesh *bm, float value, int res, int options, int defgrp_index, BME_TransData_Head *td) { +static BME_Mesh *BME_bevel_mesh(BME_Mesh *bm, float value, int res, int options, int UNUSED(defgrp_index), BME_TransData_Head *td) { BME_Vert *v, *nv; BME_Edge *e, *oe; BME_Loop *l, *l2; diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 496bcc0f88c..e70dde1474a 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -517,7 +517,7 @@ static void emDM_drawMappedEdges(DerivedMesh *dm, int (*setDrawOptions)(void *us glEnd(); } } -static void emDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges) +static void emDM_drawEdges(DerivedMesh *dm, int UNUSED(drawLooseEdges), int UNUSED(drawAllEdges)) { emDM_drawMappedEdges(dm, NULL, NULL); } @@ -628,7 +628,7 @@ static void emDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *use } /* note, material function is ignored for now. */ -static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors, int (*setMaterial)(int, void *attribs)) +static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int UNUSED(useColors), int (*setMaterial)(int, void *attribs)) { EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; EditFace *efa; @@ -1326,8 +1326,7 @@ static void emDM_release(DerivedMesh *dm) } } -static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, Object *ob, - float (*vertexCos)[3]) +static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, float (*vertexCos)[3]) { EditMeshDerivedMesh *emdm = MEM_callocN(sizeof(*emdm), "emdm"); @@ -2023,7 +2022,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri modifiers_clearErrors(ob); if(cage_r && cageIndex == -1) { - *cage_r = getEditMeshDerivedMesh(em, ob, NULL); + *cage_r = getEditMeshDerivedMesh(em, NULL); } dm = NULL; @@ -2156,7 +2155,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri *cage_r = dm; } else { *cage_r = - getEditMeshDerivedMesh(em, ob, + getEditMeshDerivedMesh(em, deformedVerts ? MEM_dupallocN(deformedVerts) : NULL); } } @@ -2180,7 +2179,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri } else if (!deformedVerts && cage_r && *cage_r) { *final_r = *cage_r; } else { - *final_r = getEditMeshDerivedMesh(em, ob, deformedVerts); + *final_r = getEditMeshDerivedMesh(em, deformedVerts); deformedVerts = NULL; } @@ -2396,9 +2395,9 @@ DerivedMesh *editmesh_get_derived_cage(Scene *scene, Object *obedit, EditMesh *e return em->derivedCage; } -DerivedMesh *editmesh_get_derived_base(Object *obedit, EditMesh *em) +DerivedMesh *editmesh_get_derived_base(Object *UNUSED(obedit), EditMesh *em) { - return getEditMeshDerivedMesh(em, obedit, NULL); + return getEditMeshDerivedMesh(em, NULL); } @@ -2484,7 +2483,7 @@ int editmesh_get_first_deform_matrices(Scene *scene, Object *ob, EditMesh *em, f if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatricesEM) { if(!defmats) { - dm= getEditMeshDerivedMesh(em, ob, NULL); + dm= getEditMeshDerivedMesh(em, NULL); deformedVerts= editmesh_getVertexCos(em, &numVerts); defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats"); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 90a3a6ce664..5a96575452b 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1091,7 +1091,7 @@ void copy_pose_result(bPose *to, bPose *from) /* For the calculation of the effects of an Action at the given frame on an object * This is currently only used for the Action Constraint */ -void what_does_obaction (Scene *scene, Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) +void what_does_obaction (Scene *UNUSED(scene), Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) { bActionGroup *agrp= action_groups_find_named(act, groupname); diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index b2feb01352e..7b52d9c586a 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1138,7 +1138,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa dm->release(dm); } -static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level, int animated) +static void new_particle_duplilist(ListBase *lb, ID *UNUSED(id), Scene *scene, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level, int animated) { GroupObject *go; Object *ob=0, **oblist=0, obcopy, *obcopylist=0; diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index f1f9fe08717..f0c39e6373e 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -252,7 +252,7 @@ Bone *get_named_bone (bArmature *arm, const char *name) * axis: the axis to name on * head/tail: the head/tail co-ordinate of the bone on the specified axis */ -int bone_autoside_name (char *name, int strip_number, short axis, float head, float tail) +int bone_autoside_name (char *name, int UNUSED(strip_number), short axis, float head, float tail) { unsigned int len; char basename[32]={""}; @@ -1057,7 +1057,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, /* ************ END Armature Deform ******************* */ -void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int root, int posed) +void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int UNUSED(root), int UNUSED(posed)) { copy_m4_m4(M_accumulatedMatrix, bone->arm_mat); } @@ -1616,7 +1616,7 @@ typedef struct tSplineIK_Tree { /* ----------- */ /* Tag the bones in the chain formed by the given bone for IK */ -static void splineik_init_tree_from_pchan(Scene *scene, Object *ob, bPoseChannel *pchan_tip) +static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPoseChannel *pchan_tip) { bPoseChannel *pchan, *pchanRoot=NULL; bPoseChannel *pchanChain[255]; @@ -1785,7 +1785,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *ob, bPoseChannel } /* Tag which bones are members of Spline IK chains */ -static void splineik_init_tree(Scene *scene, Object *ob, float ctime) +static void splineik_init_tree(Scene *scene, Object *ob, float UNUSED(ctime)) { bPoseChannel *pchan; diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 69a42e52247..cfe16e089cf 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -58,7 +58,7 @@ typedef struct BoidValues { static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val, ParticleData *pa, float fuzziness); -static int rule_none(BoidRule *rule, BoidBrainData *data, BoidValues *val, ParticleData *pa) +static int rule_none(BoidRule *rule, BoidBrainData *UNUSED(data), BoidValues *val, ParticleData *pa) { return 0; } @@ -823,7 +823,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro return NULL; } } -static int boid_rule_applies(ParticleData *pa, BoidSettings *boids, BoidRule *rule) +static int boid_rule_applies(ParticleData *pa, BoidSettings *UNUSED(boids), BoidRule *rule) { BoidParticle *bpa = pa->boid; diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index c67db9382f3..d894aef4ac5 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -530,7 +530,7 @@ void brush_imbuf_new(Brush *brush, short flt, short texfall, int bufsize, ImBuf if (*outbuf) ibuf= *outbuf; else - ibuf= IMB_allocImBuf(bufsize, bufsize, 32, imbflag, 0); + ibuf= IMB_allocImBuf(bufsize, bufsize, 32, imbflag); if (flt) { for (y=0; y < ibuf->y; y++) { @@ -796,11 +796,11 @@ static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, float imbflag= (cache->flt)? IB_rectfloat: IB_rect; if (!cache->ibuf) - cache->ibuf= IMB_allocImBuf(diameter, diameter, 32, imbflag, 0); + cache->ibuf= IMB_allocImBuf(diameter, diameter, 32, imbflag); ibuf= cache->ibuf; oldtexibuf= cache->texibuf; - cache->texibuf= IMB_allocImBuf(diameter, diameter, 32, imbflag, 0); + cache->texibuf= IMB_allocImBuf(diameter, diameter, 32, imbflag); if (oldtexibuf) { srcx= srcy= 0; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 1b7257519b1..671bcb36680 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -42,7 +42,7 @@ /* Math stuff for ray casting on mesh faces and for nearest surface */ -static float ray_tri_intersection(const BVHTreeRay *ray, const float m_dist, const float *v0, const float *v1, const float *v2) +static float ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_dist), const float *v0, const float *v1, const float *v2) { float dist; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index b9ca7bfafe3..eb895d62f17 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -418,7 +418,7 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm) static void cdDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], - int fast, int (*setMaterial)(int, void *attribs)) + int UNUSED(fast), int (*setMaterial)(int, void *attribs)) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; MVert *mvert = cddm->mvert; @@ -1489,7 +1489,7 @@ DerivedMesh *CDDM_new(int numVerts, int numEdges, int numFaces) return dm; } -DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *ob) +DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob)) { CDDerivedMesh *cddm = cdDM_create("CDDM_from_mesh dm"); DerivedMesh *dm = &cddm->dm; @@ -1518,7 +1518,7 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *ob) return dm; } -DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *me) +DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *UNUSED(me)) { DerivedMesh *dm = CDDM_new(BLI_countlist(&em->verts), BLI_countlist(&em->edges), diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 3f47676d7fd..e7e94c407f1 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -87,7 +87,7 @@ static CM_SOLVER_DEF solvers [] = /* Prototypes for internal functions. */ static void cloth_to_object (Object *ob, ClothModifierData *clmd, DerivedMesh *dm); -static void cloth_from_mesh ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm ); +static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ); static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float framenr, int first); static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ); static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ); @@ -423,7 +423,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul /************************************************ * clothModifier_do - main simulation function ************************************************/ -DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc) +DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { DerivedMesh *result; PointCache *cache; @@ -546,7 +546,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, } /* frees all */ -void cloth_free_modifier ( Object *ob, ClothModifierData *clmd ) +void cloth_free_modifier(ClothModifierData *clmd ) { Cloth *cloth = NULL; @@ -804,7 +804,7 @@ static void cloth_apply_vgroup ( ClothModifierData *clmd, DerivedMesh *dm ) } } -static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float framenr, int first) +static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *dm, float UNUSED(framenr), int first) { int i = 0; MVert *mvert = NULL; @@ -817,7 +817,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d // If we have a clothObject, free it. if ( clmd->clothObject != NULL ) { - cloth_free_modifier ( ob, clmd ); + cloth_free_modifier ( clmd ); if(G.rt > 0) printf("cloth_free_modifier cloth_from_object\n"); } @@ -841,7 +841,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d if ( !dm ) return 0; - cloth_from_mesh ( ob, clmd, dm ); + cloth_from_mesh ( clmd, dm ); // create springs clmd->clothObject->springs = NULL; @@ -897,7 +897,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d if ( !cloth_build_springs ( clmd, dm ) ) { - cloth_free_modifier ( ob, clmd ); + cloth_free_modifier ( clmd ); modifier_setError ( & ( clmd->modifier ), "Can't build springs." ); printf("cloth_free_modifier cloth_build_springs\n"); return 0; @@ -931,7 +931,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d return 1; } -static void cloth_from_mesh ( Object *ob, ClothModifierData *clmd, DerivedMesh *dm ) +static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) { unsigned int numverts = dm->getNumVerts ( dm ); unsigned int numfaces = dm->getNumFaces ( dm ); @@ -943,7 +943,7 @@ static void cloth_from_mesh ( Object *ob, ClothModifierData *clmd, DerivedMesh * clmd->clothObject->verts = MEM_callocN ( sizeof ( ClothVertex ) * clmd->clothObject->numverts, "clothVertex" ); if ( clmd->clothObject->verts == NULL ) { - cloth_free_modifier ( ob, clmd ); + cloth_free_modifier ( clmd ); modifier_setError ( & ( clmd->modifier ), "Out of memory on allocating clmd->clothObject->verts." ); printf("cloth_free_modifier clmd->clothObject->verts\n"); return; @@ -954,7 +954,7 @@ static void cloth_from_mesh ( Object *ob, ClothModifierData *clmd, DerivedMesh * clmd->clothObject->mfaces = MEM_callocN ( sizeof ( MFace ) * clmd->clothObject->numfaces, "clothMFaces" ); if ( clmd->clothObject->mfaces == NULL ) { - cloth_free_modifier ( ob, clmd ); + cloth_free_modifier ( clmd ); modifier_setError ( & ( clmd->modifier ), "Out of memory on allocating clmd->clothObject->mfaces." ); printf("cloth_free_modifier clmd->clothObject->mfaces\n"); return; @@ -1006,7 +1006,7 @@ int cloth_add_spring ( ClothModifierData *clmd, unsigned int indexA, unsigned in return 0; } -static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *edgehash, LinkNode **edgelist) +static void cloth_free_errorsprings(Cloth *cloth, EdgeHash *UNUSED(edgehash), LinkNode **edgelist) { unsigned int i = 0; diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index af12d23b2c2..5c9cc441b95 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -79,7 +79,7 @@ void collision_move_object ( CollisionModifierData *collmd, float step, float pr bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 ); } -BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert *x, unsigned int numverts, float epsilon ) +BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert *x, unsigned int UNUSED(numverts), float epsilon ) { BVHTree *tree; float co[12]; @@ -106,7 +106,7 @@ BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert return tree; } -void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces, MVert *x, MVert *xnew, int numverts, int moving ) +void bvhtree_update_from_mvert ( BVHTree * bvhtree, MFace *faces, int numfaces, MVert *x, MVert *xnew, int UNUSED(numverts), int moving ) { int i; MFace *mfaces = faces; diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 90ffa39c88f..83ed65a1bf2 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -53,7 +53,7 @@ #include "IMB_imbuf_types.h" -void floatbuf_to_srgb_byte(float *rectf, unsigned char *rectc, int x1, int x2, int y1, int y2, int w) +void floatbuf_to_srgb_byte(float *rectf, unsigned char *rectc, int x1, int x2, int y1, int y2, int UNUSED(w)) { int x, y; float *rf= rectf; @@ -74,7 +74,7 @@ void floatbuf_to_srgb_byte(float *rectf, unsigned char *rectc, int x1, int x2, i } } -void floatbuf_to_byte(float *rectf, unsigned char *rectc, int x1, int x2, int y1, int y2, int w) +void floatbuf_to_byte(float *rectf, unsigned char *rectc, int x1, int x2, int y1, int y2, int UNUSED(w)) { int x, y; float *rf= rectf; @@ -356,7 +356,7 @@ void curvemap_sethandle(CurveMap *cuma, int type) /* *********************** Making the tables and display ************** */ /* reduced copy of garbled calchandleNurb() code in curve.c */ -static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) +static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *next, int UNUSED(mode)) { float *p1,*p2,*p3,pt[3]; float dx1,dy1, dx,dy, vx,vy, len,len1,len2; @@ -830,6 +830,10 @@ void colorcorrection_do_ibuf(ImBuf *ibuf, const char *profile) cmsCloseProfile(proofingProfile); } } +#else + /* unused */ + (void)ibuf; + (void)profile; #endif } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 3df395244f4..5dad01a126f 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -655,7 +655,7 @@ static bConstraintTypeInfo CTI_CONSTRNAME = { /* This function should be used for the get_target_matrix member of all * constraints that are not picky about what happens to their target matrix. */ -static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float ctime) +static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); @@ -1107,7 +1107,7 @@ static void kinematic_flush_tars (bConstraint *con, ListBase *list, short nocopy } } -static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float ctime) +static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { bKinematicConstraint *data= con->data; @@ -1195,7 +1195,7 @@ static void followpath_flush_tars (bConstraint *con, ListBase *list, short nocop } } -static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float ctime) +static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { bFollowPathConstraint *data= con->data; @@ -1330,7 +1330,7 @@ static bConstraintTypeInfo CTI_FOLLOWPATH = { /* --------- Limit Location --------- */ -static void loclimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void loclimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bLocLimitConstraint *data = con->data; @@ -1378,7 +1378,7 @@ static bConstraintTypeInfo CTI_LOCLIMIT = { /* -------- Limit Rotation --------- */ -static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bRotLimitConstraint *data = con->data; float loc[3]; @@ -1437,7 +1437,7 @@ static bConstraintTypeInfo CTI_ROTLIMIT = { /* --------- Limit Scaling --------- */ -static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bSizeLimitConstraint *data = con->data; float obsize[3], size[3]; @@ -1831,7 +1831,7 @@ static void translike_flush_tars (bConstraint *con, ListBase *list, short nocopy } } -static void translike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void translike_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) { bConstraintTarget *ct= targets->first; @@ -1867,7 +1867,7 @@ static void samevolume_new_data (void *cdata) data->volume = 1.0f; } -static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bSameVolumeConstraint *data= con->data; @@ -1981,7 +1981,7 @@ static void pycon_id_looper (bConstraint *con, ConstraintIDFunc func, void *user } /* Whether this approach is maintained remains to be seen (aligorith) */ -static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float ctime) +static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { #ifndef DISABLE_PYTHON bPythonConstraint *data= con->data; @@ -2105,7 +2105,7 @@ static void actcon_flush_tars (bConstraint *con, ListBase *list, short nocopy) } } -static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float ctime) +static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { extern void chan_calc_mat(bPoseChannel *chan); bActionConstraint *data = con->data; @@ -2196,7 +2196,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint } } -static void actcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void actcon_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) { bConstraintTarget *ct= targets->first; @@ -3076,7 +3076,7 @@ static void clampto_flush_tars (bConstraint *con, ListBase *list, short nocopy) } } -static void clampto_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float ctime) +static void clampto_get_tarmat (bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) { Curve *cu= ct->tar->data; @@ -3410,7 +3410,7 @@ static void shrinkwrap_flush_tars (bConstraint *con, ListBase *list, short nocop } -static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float ctime) +static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data; @@ -3513,7 +3513,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr } } -static void shrinkwrap_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void shrinkwrap_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) { bConstraintTarget *ct= targets->first; @@ -3729,7 +3729,7 @@ static void splineik_flush_tars (bConstraint *con, ListBase *list, short nocopy) } } -static void splineik_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float ctime) +static void splineik_get_tarmat (bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) { Curve *cu= ct->tar->data; @@ -4161,7 +4161,7 @@ void id_loop_constraints (ListBase *conlist, ConstraintIDFunc func, void *userda /* ......... */ /* helper for copy_constraints(), to be used for making sure that ID's are valid */ -static void con_extern_cb(bConstraint *con, ID **idpoin, void *userdata) +static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, void *UNUSED(userData)) { if (*idpoin && (*idpoin)->lib) id_lib_extern(*idpoin); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 9578b5185af..a7dd80bff4d 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2951,7 +2951,7 @@ void switchdirectionNurb(Nurb *nu) } -float (*curve_getVertexCos(Curve *cu, ListBase *lb, int *numVerts_r))[3] +float (*curve_getVertexCos(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3] { int i, numVerts = *numVerts_r = count_curveverts(lb); float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos"); @@ -2979,7 +2979,7 @@ float (*curve_getVertexCos(Curve *cu, ListBase *lb, int *numVerts_r))[3] return cos; } -void curve_applyVertexCos(Curve *cu, ListBase *lb, float (*vertexCos)[3]) +void curve_applyVertexCos(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos)[3]) { float *co = vertexCos[0]; Nurb *nu; @@ -3004,7 +3004,7 @@ void curve_applyVertexCos(Curve *cu, ListBase *lb, float (*vertexCos)[3]) } } -float (*curve_getKeyVertexCos(Curve *cu, ListBase *lb, float *key))[3] +float (*curve_getKeyVertexCos(Curve *UNUSED(cu), ListBase *lb, float *key))[3] { int i, numVerts = count_curveverts(lb); float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos"); @@ -3035,7 +3035,7 @@ float (*curve_getKeyVertexCos(Curve *cu, ListBase *lb, float *key))[3] return cos; } -void curve_applyKeyVertexTilts(Curve *cu, ListBase *lb, float *key) +void curve_applyKeyVertexTilts(Curve *UNUSED(cu), ListBase *lb, float *key) { Nurb *nu; int i; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 1f867a615b2..f4db8e953f9 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -468,8 +468,8 @@ static void layerSwap_mdisps(void *data, const int *ci) } } -static void layerInterp_mdisps(void **sources, float *weights, float *sub_weights, - int count, void *dest) +static void layerInterp_mdisps(void **UNUSED(sources), float *weights, float *sub_weights, + int UNUSED(count), void *dest) { MDisps *d = dest; int i; @@ -2503,7 +2503,7 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in cdf_free(cdf); } -void CustomData_external_add(CustomData *data, ID *id, int type, int totelem, const char *filename) +void CustomData_external_add(CustomData *data, ID *id, int type, int UNUSED(totelem), const char *filename) { CustomDataExternal *external= data->external; CustomDataLayer *layer; diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index 65a0d731beb..5954ac1b022 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -379,7 +379,7 @@ int cdf_write_open(CDataFile *cdf, char *filename) return 1; } -int cdf_write_layer(CDataFile *cdf, CDataFileLayer *blay) +int cdf_write_layer(CDataFile *UNUSED(cdf), CDataFileLayer *UNUSED(blay)) { return 1; } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 382c0690ae3..d95b7010993 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -846,7 +846,7 @@ DagNode * dag_get_sub_node (DagForest *forest,void * fob) return node; } -static void dag_add_parent_relation(DagForest *forest, DagNode *fob1, DagNode *fob2, short rel, char *name) +static void dag_add_parent_relation(DagForest *UNUSED(forest), DagNode *fob1, DagNode *fob2, short rel, char *name) { DagAdjList *itA = fob2->parent; @@ -2280,7 +2280,7 @@ void DAG_on_load_update(Main *bmain) } } -static void dag_id_flush_update__isDependentTexture(void *userData, Object *ob, ID **idpoin) +static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUSED(ob), ID **idpoin) { struct { ID *id; int is_dependent; } *data = userData; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 2ab7e32a9c6..d1830cb8243 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -289,7 +289,7 @@ static void init_fastshade_shadeinput(Render *re) shi.combinedflag= -1; } -static Render *fastshade_get_render(Scene *scene) +static Render *fastshade_get_render(Scene *UNUSED(scene)) { // XXX 2.5: this crashes combined with previewrender // due to global R so disabled for now @@ -1117,7 +1117,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) } -static void curve_to_filledpoly(Curve *cu, ListBase *nurb, ListBase *dispbase) +static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dispbase) { if(cu->flag & CU_3D) return; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 4860e7d8eed..f4fae3ed3c6 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -410,7 +410,7 @@ void pd_point_from_soft(Scene *scene, float *loc, float *vel, int index, Effecte /************************************************/ // triangle - ray callback function -static void eff_tri_ray_hit(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) +static void eff_tri_ray_hit(void *UNUSED(userData), int UNUSED(index), const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit) { // whenever we hit a bounding box, we don't check further hit->dist = -1; @@ -515,7 +515,7 @@ static float falloff_func_rad(PartDeflect *pd, float fac) return falloff_func(fac, pd->flag&PFIELD_USEMINR, pd->minrad, pd->flag&PFIELD_USEMAXR, pd->maxrad, pd->f_power_r); } -float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, EffectorWeights *weights) +float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNUSED(point), EffectorWeights *weights) { float temp[3]; float falloff = weights ? weights->weight[0] * weights->weight[eff->pd->forcefield] : 1.0f; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 43f01199b69..1575f69209f 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -556,7 +556,7 @@ void bezt_add_to_cfra_elem (ListBase *lb, BezTriple *bezt) /* Basic sampling callback which acts as a wrapper for evaluate_fcurve() * 'data' arg here is unneeded here... */ -float fcurve_samplingcb_evalcurve (FCurve *fcu, void *data, float evaltime) +float fcurve_samplingcb_evalcurve (FCurve *fcu, void *UNUSED(data), float evaltime) { /* assume any interference from drivers on the curve is intended... */ return evaluate_fcurve(fcu, evaltime); @@ -1331,7 +1331,7 @@ float driver_get_variable_value (ChannelDriver *driver, DriverVar *dvar) * - "evaltime" is the frame at which F-Curve is being evaluated * - has to return a float value */ -static float evaluate_driver (ChannelDriver *driver, float evaltime) +static float evaluate_driver (ChannelDriver *driver, float UNUSED(evaltime)) { DriverVar *dvar; diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 5a10f93ac72..6660442b14a 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -190,7 +190,7 @@ static void fcm_generator_verify (FModifier *fcm) } } -static void fcm_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime) +static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { FMod_Generator *data= (FMod_Generator *)fcm->data; @@ -303,7 +303,7 @@ static double sinc (double x) return sin(M_PI * x) / (M_PI * x); } -static void fcm_fn_generator_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime) +static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)fcm->data; double arg= data->phase_multiplier*evaltime + data->phase_offset; @@ -432,7 +432,7 @@ static void fcm_envelope_verify (FModifier *fcm) } } -static void fcm_envelope_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime) +static void fcm_envelope_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { FMod_Envelope *env= (FMod_Envelope *)fcm->data; FCM_EnvelopeData *fed, *prevfed, *lastfed; @@ -524,7 +524,7 @@ static void fcm_cycles_new_data (void *mdata) data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC; } -static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float evaltime) +static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime) { FMod_Cycles *data= (FMod_Cycles *)fcm->data; float prevkey[2], lastkey[2], cycyofs=0.0f; @@ -664,7 +664,7 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float cvalue, float e return evaltime; } -static void fcm_cycles_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime) +static void fcm_cycles_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) { tFCMED_Cycles *edata= (tFCMED_Cycles *)fcm->edata; @@ -708,7 +708,7 @@ static void fcm_noise_new_data (void *mdata) data->modification = FCM_NOISE_MODIF_REPLACE; } -static void fcm_noise_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime) +static void fcm_noise_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { FMod_Noise *data= (FMod_Noise *)fcm->data; float noise; @@ -800,7 +800,7 @@ static void fcm_python_copy (FModifier *fcm, FModifier *src) pymod->prop = IDP_CopyProperty(opymod->prop); } -static void fcm_python_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime) +static void fcm_python_evaluate (FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *UNUSED(cvalue), float UNUSED(evaltime)) { #ifndef DISABLE_PYTHON //FMod_Python *data= (FMod_Python *)fcm->data; @@ -829,7 +829,7 @@ static FModifierTypeInfo FMI_PYTHON = { /* Limits F-Curve Modifier --------------------------- */ -static float fcm_limits_time (FCurve *fcu, FModifier *fcm, float cvalue, float evaltime) +static float fcm_limits_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime) { FMod_Limits *data= (FMod_Limits *)fcm->data; @@ -843,7 +843,7 @@ static float fcm_limits_time (FCurve *fcu, FModifier *fcm, float cvalue, float e return evaltime; } -static void fcm_limits_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, float evaltime) +static void fcm_limits_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) { FMod_Limits *data= (FMod_Limits *)fcm->data; @@ -880,7 +880,7 @@ static void fcm_stepped_new_data (void *mdata) data->step_size = 2.0f; } -static float fcm_stepped_time (FCurve *fcu, FModifier *fcm, float cvalue, float evaltime) +static float fcm_stepped_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime) { FMod_Stepped *data= (FMod_Stepped *)fcm->data; int snapblock; diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index bdf203119c3..5a031d62fcb 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -42,6 +42,7 @@ #include "BLI_blenlib.h" +#include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_group.h" #include "BKE_library.h" @@ -327,7 +328,7 @@ static void group_replaces_nla(Object *parent, Object *target, char mode) you can draw everything, leaves tags in objects to signal it needs further updating */ /* note: does not work for derivedmesh and render... it recreates all again in convertblender.c */ -void group_handle_recalc_and_update(Scene *scene, Object *parent, Group *group) +void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group *group) { GroupObject *go; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index fec713805e3..d750300291b 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -103,8 +103,8 @@ static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ if (ibuf->rect) { /* make copies */ - tbuf1 = IMB_allocImBuf(ibuf->x, (short)(ibuf->y >> 1), (unsigned char)32, (int)IB_rect, (unsigned char)0); - tbuf2 = IMB_allocImBuf(ibuf->x, (short)(ibuf->y >> 1), (unsigned char)32, (int)IB_rect, (unsigned char)0); + tbuf1 = IMB_allocImBuf(ibuf->x, (short)(ibuf->y >> 1), (unsigned char)32, (int)IB_rect); + tbuf2 = IMB_allocImBuf(ibuf->x, (short)(ibuf->y >> 1), (unsigned char)32, (int)IB_rect); ibuf->x *= 2; @@ -131,8 +131,8 @@ static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ if (ibuf->rect) { /* make copies */ - tbuf1 = IMB_allocImBuf(ibuf->x, (short)(ibuf->y >> 1), (unsigned char)32, IB_rect, 0); - tbuf2 = IMB_allocImBuf(ibuf->x, (short)(ibuf->y >> 1), (unsigned char)32, IB_rect, 0); + tbuf1 = IMB_allocImBuf(ibuf->x, (short)(ibuf->y >> 1), (unsigned char)32, IB_rect); + tbuf2 = IMB_allocImBuf(ibuf->x, (short)(ibuf->y >> 1), (unsigned char)32, IB_rect); ibuf->x *= 2; @@ -389,11 +389,11 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, char *name, float *rect_float= NULL; if (floatbuf) { - ibuf= IMB_allocImBuf(width, height, depth, IB_rectfloat, 0); + ibuf= IMB_allocImBuf(width, height, depth, IB_rectfloat); rect_float= (float*)ibuf->rect_float; } else { - ibuf= IMB_allocImBuf(width, height, depth, IB_rect, 0); + ibuf= IMB_allocImBuf(width, height, depth, IB_rect); rect= (unsigned char*)ibuf->rect; } @@ -1681,7 +1681,7 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f if(rpass) { // printf("load from pass %s\n", rpass->name); /* since we free render results, we copy the rect */ - ibuf= IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0, 0); + ibuf= IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); ibuf->rect_float= MEM_dupallocN(rpass->rect); ibuf->flags |= IB_rectfloat; ibuf->mall= IB_rectfloat; @@ -1831,7 +1831,7 @@ static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) RenderPass *rpass= BKE_image_multilayer_index(ima->rr, iuser); if(rpass) { - ibuf= IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0, 0); + ibuf= IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); image_initialize_after_load(ima, ibuf); @@ -1938,7 +1938,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ /* make ibuf if needed, and initialize it */ if(ibuf==NULL) { - ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, 0, 0); + ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, 0); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); } @@ -2148,7 +2148,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) if(!ibuf) { /* Composite Viewer, all handled in compositor */ /* fake ibuf, will be filled in compositor */ - ibuf= IMB_allocImBuf(256, 256, 32, IB_rect, 0); + ibuf= IMB_allocImBuf(256, 256, 32, IB_rect); image_assign_ibuf(ima, ibuf, 0, frame); } } diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 158f964a846..9baaf7e5abc 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -726,7 +726,7 @@ typedef struct Implicit_Data fmatrix3x3 *A, *dFdV, *dFdX, *S, *P, *Pinv, *bigI, *M; } Implicit_Data; -int implicit_init (Object *ob, ClothModifierData *clmd) +int implicit_init (Object *UNUSED(ob), ClothModifierData *clmd) { unsigned int i = 0; unsigned int pinned = 0; @@ -1555,7 +1555,7 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec free_collider_cache(&colliders); } -static void cloth_calc_force(ClothModifierData *clmd, float frame, lfVector *lF, lfVector *lX, lfVector *lV, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, ListBase *effectors, float time, fmatrix3x3 *M) +static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVector *lF, lfVector *lX, lfVector *lV, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, ListBase *effectors, float time, fmatrix3x3 *M) { /* Collect forces and derivatives: F,dFdX,dFdV */ Cloth *cloth = clmd->clothObject; diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 5c0c0fbf0c1..846592f0f2f 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -317,7 +317,7 @@ static char *constraint_adrcodes_to_paths (int adrcode, int *array_index) * NOTE: as we don't have access to the keyblock where the data comes from (for now), * we'll just use numerical indicies for now... */ -static char *shapekey_adrcodes_to_paths (int adrcode, int *array_index) +static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) { static char buf[128]; @@ -331,7 +331,7 @@ static char *shapekey_adrcodes_to_paths (int adrcode, int *array_index) } /* MTex (Texture Slot) types */ -static char *mtex_adrcodes_to_paths (int adrcode, int *array_index) +static char *mtex_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) { char *base=NULL, *prop=NULL; static char buf[128]; diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 708403ab1f7..aa9d0b4f57c 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1163,7 +1163,7 @@ 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) +static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, float UNUSED(ctime), char *out, int tot) { Nurb *nu; int a, step; @@ -1657,7 +1657,7 @@ void curve_to_key(Curve *cu, KeyBlock *kb, ListBase *nurb) } } -void key_to_curve(KeyBlock *kb, Curve *cu, ListBase *nurb) +void key_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb) { Nurb *nu; BezTriple *bezt; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 3f94992cd11..1e08432c271 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -337,7 +337,7 @@ int id_unlink(ID *id, int test) break; case ID_OB: if(test) return 1; - unlink_object(NULL, (Object*)id); + unlink_object((Object*)id); break; } @@ -822,7 +822,7 @@ void free_libblock_us(ListBase *lb, void *idv) /* test users */ else printf("ERROR block %s users %d\n", id->name, id->us); } if(id->us==0) { - if( GS(id->name)==ID_OB ) unlink_object(NULL, (Object *)id); + if( GS(id->name)==ID_OB ) unlink_object((Object *)id); free_libblock(lb, id); } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 3e9287dd511..faefbdacb45 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -71,7 +71,7 @@ EditMesh *BKE_mesh_get_editmesh(Mesh *me) return me->edit_mesh; } -void BKE_mesh_end_editmesh(Mesh *me, EditMesh *em) +void BKE_mesh_end_editmesh(Mesh *UNUSED(me), EditMesh *UNUSED(em)) { } @@ -561,7 +561,7 @@ static void mfaces_strip_loose(MFace *mface, int *totface) } /* Create edges based on known verts and faces */ -static void make_edges_mdata(MVert *allvert, MFace *allface, int totvert, int totface, +static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, int UNUSED(totvert), int totface, int old, MEdge **alledge, int *_totedge) { MFace *mface; @@ -1441,7 +1441,7 @@ void mesh_pmv_free(PartialVisibility *pv) MEM_freeN(pv); } -void mesh_pmv_revert(Object *ob, Mesh *me) +void mesh_pmv_revert(Mesh *me) { if(me->pv) { unsigned i; @@ -1480,10 +1480,10 @@ void mesh_pmv_revert(Object *ob, Mesh *me) } } -void mesh_pmv_off(Object *ob, Mesh *me) +void mesh_pmv_off(Mesh *me) { - if(ob && me->pv) { - mesh_pmv_revert(ob, me); + if(me->pv) { + mesh_pmv_revert(me); MEM_freeN(me->pv); me->pv= NULL; } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 57f568e6094..b0ab947d478 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -456,7 +456,7 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv return multires_dm_create_from_derived(&mmd, 1, dm, ob, 0, 0); } -static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal) +static DerivedMesh *subsurf_dm_create_local(Object *UNUSED(ob), DerivedMesh *dm, int lvl, int simple, int optimal) { SubsurfModifierData smd; @@ -780,7 +780,7 @@ void multires_stitch_grids(Object *ob) } DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int local_mmd, DerivedMesh *dm, Object *ob, - int useRenderParams, int isFinalCalc) + int useRenderParams, int UNUSED(isFinalCalc)) { Mesh *me= ob->data; DerivedMesh *result; @@ -874,7 +874,7 @@ static void old_mdisps_bilinear(float out[3], float (*disps)[3], int st, float u add_v3_v3v3(out, d2[0], d2[1]); } -static void old_mdisps_rotate(int S, int newside, int oldside, int x, int y, float *u, float *v) +static void old_mdisps_rotate(int S, int UNUSED(newside), int oldside, int x, int y, float *u, float *v) { float offset = oldside*0.5f - 0.5f; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index b053d615756..09ba967e265 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1585,7 +1585,7 @@ void BKE_nla_tweakmode_exit (AnimData *adt) /* Baking Tools ------------------------------------------- */ -void BKE_nla_bake (Scene *scene, ID *id, AnimData *adt, int flag) +void BKE_nla_bake (Scene *scene, ID *id, AnimData *adt, int UNUSED(flag)) { /* verify that data is valid diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 3df9bd6ed05..17e488c8353 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -320,7 +320,7 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec } } -void unlink_object(Scene *scene, Object *ob) +void unlink_object(Object *ob) { Main *bmain= G.main; Object *obt; @@ -1617,7 +1617,7 @@ void disable_speed_curve(int val) // XXX THIS CRUFT NEEDS SERIOUS RECODING ASAP! /* ob can be NULL */ -float bsystem_time(struct Scene *scene, Object *ob, float cfra, float ofs) +float bsystem_time(struct Scene *scene, Object *UNUSED(ob), float cfra, float ofs) { /* returns float ( see BKE_curframe in scene.c) */ cfra += scene->r.subframe; diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 5bbb3506a78..78340288836 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -486,7 +486,7 @@ int unpackSound(ReportList *reports, bSound *sound, int how) freePackedFile(sound->packedfile); sound->packedfile = 0; - sound_load(NULL, sound); + sound_load(sound); ret_value = RET_OK; } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index ffb99c10c40..116ed3c8ef2 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -31,6 +31,7 @@ #include "DNA_scene_types.h" #include "DNA_brush_types.h" +#include "BKE_utildefines.h" #include "BKE_brush.h" #include "BKE_library.h" #include "BKE_paint.h" @@ -100,7 +101,7 @@ void paint_init(Paint *p, const char col[3]) p->flags |= PAINT_SHOW_BRUSH; } -void free_paint(Paint *paint) +void free_paint(Paint *UNUSED(paint)) { /* nothing */ } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index ebbb3ea1020..f7345d6159a 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -380,7 +380,7 @@ void psys_free_settings(ParticleSettings *part) fluid_free_settings(part->fluid); } -void free_hair(Object *ob, ParticleSystem *psys, int dynamics) +void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics) { PARTICLE_P; @@ -405,7 +405,7 @@ void free_hair(Object *ob, ParticleSystem *psys, int dynamics) psys->pointcache = BKE_ptcache_add(&psys->ptcaches); } else { - cloth_free_modifier(ob, psys->clmd); + cloth_free_modifier(psys->clmd); } } @@ -1052,7 +1052,7 @@ typedef struct ParticleInterpolationData { } ParticleInterpolationData; /* Assumes pointcache->mem_cache exists, so for disk cached particles call psys_make_temp_pointcache() before use */ /* It uses ParticleInterpolationData->pm to store the current memory cache frame so it's thread safe. */ -static void get_pointcache_keys_for_time(Object *ob, PointCache *cache, PTCacheMem **cur, int index, float t, ParticleKey *key1, ParticleKey *key2) +static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache, PTCacheMem **cur, int index, float t, ParticleKey *key1, ParticleKey *key2) { static PTCacheMem *pm = NULL; @@ -1803,7 +1803,7 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys) /* Particles on a shape */ /************************************************/ /* ready for future use */ -static void psys_particle_on_shape(int distr, int index, float *fuv, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) +static void psys_particle_on_shape(int UNUSED(distr), int index, float *UNUSED(fuv), float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) { /* TODO */ float zerovec[3]={0.0f,0.0f,0.0f}; @@ -2185,7 +2185,7 @@ static void do_rough_end(float *loc, float mat[4][4], float t, float fac, float VECADDFAC(state->co,state->co,mat[0],rough[0]); VECADDFAC(state->co,state->co,mat[1],rough[1]); } -static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheKey *ca, int k, int steps, float *rootco, float effector, float dfra, float cfra, float *length, float *vec) +static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheKey *ca, int k, int steps, float *rootco, float effector, float dfra, float UNUSED(cfra), float *length, float *vec) { float force[3] = {0.0f,0.0f,0.0f}; ParticleKey eff_key; @@ -3339,7 +3339,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m triatomat(v[0], v[1], v[2], (osface)? osface->uv: NULL, mat); } -void psys_mat_hair_to_object(Object *ob, DerivedMesh *dm, short from, ParticleData *pa, float hairmat[][4]) +void psys_mat_hair_to_object(Object *UNUSED(ob), DerivedMesh *dm, short from, ParticleData *pa, float hairmat[][4]) { float vec[3]; @@ -3818,7 +3818,7 @@ float psys_get_child_time(ParticleSystem *psys, ChildParticle *cpa, float cfra, return (cfra-time)/life; } -float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float cfra, float *pa_time) +float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float UNUSED(cfra), float *UNUSED(pa_time)) { ParticleSettings *part = psys->part; float size; // time XXX @@ -4249,7 +4249,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta } } -void psys_get_dupli_texture(Object *ob, ParticleSettings *part, ParticleSystemModifierData *psmd, ParticleData *pa, ChildParticle *cpa, float *uv, float *orco) +void psys_get_dupli_texture(Object *UNUSED(ob), ParticleSettings *part, ParticleSystemModifierData *psmd, ParticleData *pa, ChildParticle *cpa, float *uv, float *orco) { MFace *mface; MTFace *mtface; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index fa82d2c5359..8ab4117c8a1 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1437,7 +1437,7 @@ static void distribute_particles_on_dm(ParticleSimulationData *sim, int from) } /* ready for future use, to emit particles without geometry */ -static void distribute_particles_on_shape(ParticleSimulationData *sim, int from) +static void distribute_particles_on_shape(ParticleSimulationData *sim, int UNUSED(from)) { ParticleSystem *psys = sim->psys; PARTICLE_P; @@ -2289,7 +2289,7 @@ static void psys_update_effectors(ParticleSimulationData *sim) In theory, there could be unlimited implementation of SPH simulators **************************************************/ -void particle_fluidsim(ParticleSystem *psys, ParticleData *pa, ParticleSettings *part, ParticleSimulationData *sim, float dfra, float cfra, float mass){ +void particle_fluidsim(ParticleSystem *psys, ParticleData *pa, ParticleSettings *part, ParticleSimulationData *sim, float dfra, float UNUSED(cfra), float mass){ /**************************************************************************************************************** * This code uses in some parts adapted algorithms from the pseduo code as outlined in the Research paper * Titled: Particle-based Viscoelastic Fluid Simulation. @@ -3284,7 +3284,7 @@ static void hair_step(ParticleSimulationData *sim, float cfra) psys_calc_dmcache(sim->ob, sim->psmd->dm, psys); if(psys->clmd) - cloth_free_modifier(sim->ob, psys->clmd); + cloth_free_modifier(psys->clmd); } /* dynamics with cloth simulation */ @@ -3298,7 +3298,7 @@ static void hair_step(ParticleSimulationData *sim, float cfra) psys->flag |= PSYS_HAIR_UPDATED; } -static void save_hair(ParticleSimulationData *sim, float cfra){ +static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra)){ Object *ob = sim->ob; ParticleSystem *psys = sim->psys; HairKey *key, *root; @@ -3574,7 +3574,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra) } } -static void particles_fluid_step(ParticleSimulationData *sim, int cfra) +static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) { ParticleSystem *psys = sim->psys; if(psys->particles){ @@ -3682,7 +3682,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int cfra) #endif // DISABLE_ELBEEM } -static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float cfra) +static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float UNUSED(cfra)) { ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index f9d2c1c3fec..3896d523b11 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -132,7 +132,7 @@ static int ptcache_write_basic_header(PTCacheFile *pf) return 1; } /* Softbody functions */ -static int ptcache_write_softbody(int index, void *soft_v, void **data, int cfra) +static int ptcache_write_softbody(int index, void *soft_v, void **data, int UNUSED(cfra)) { SoftBody *soft= soft_v; BodyPoint *bp = soft->bpoint + index; @@ -142,7 +142,7 @@ static int ptcache_write_softbody(int index, void *soft_v, void **data, int cfra return 1; } -static void ptcache_read_softbody(int index, void *soft_v, void **data, float frs_sec, float cfra, float *old_data) +static void ptcache_read_softbody(int index, void *soft_v, void **data, float UNUSED(frs_sec), float UNUSED(cfra), float *old_data) { SoftBody *soft= soft_v; BodyPoint *bp = soft->bpoint + index; @@ -156,7 +156,7 @@ static void ptcache_read_softbody(int index, void *soft_v, void **data, float fr PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, 0, bp->vec); } } -static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, float UNUSED(frs_sec), float cfra, float cfra1, float cfra2, float *old_data) { SoftBody *soft= soft_v; BodyPoint *bp = soft->bpoint + index; @@ -188,7 +188,7 @@ static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, f VECCOPY(bp->pos, keys->co); VECCOPY(bp->vec, keys->vel); } -static int ptcache_totpoint_softbody(void *soft_v, int cfra) +static int ptcache_totpoint_softbody(void *soft_v, int UNUSED(cfra)) { SoftBody *soft= soft_v; return soft->totpoint; @@ -348,7 +348,7 @@ static void ptcache_interpolate_particle(int index, void *psys_v, void **data, f pa->state.time = cfra; } -static int ptcache_totpoint_particle(void *psys_v, int cfra) +static int ptcache_totpoint_particle(void *psys_v, int UNUSED(cfra)) { ParticleSystem *psys = psys_v; return psys->totpart; @@ -493,7 +493,7 @@ static int ptcache_totwrite_particle(void *psys_v, int cfra) //} // /* Cloth functions */ -static int ptcache_write_cloth(int index, void *cloth_v, void **data, int cfra) +static int ptcache_write_cloth(int index, void *cloth_v, void **data, int UNUSED(cfra)) { ClothModifierData *clmd= cloth_v; Cloth *cloth= clmd->clothObject; @@ -505,7 +505,7 @@ static int ptcache_write_cloth(int index, void *cloth_v, void **data, int cfra) return 1; } -static void ptcache_read_cloth(int index, void *cloth_v, void **data, float frs_sec, float cfra, float *old_data) +static void ptcache_read_cloth(int index, void *cloth_v, void **data, float UNUSED(frs_sec), float UNUSED(cfra), float *old_data) { ClothModifierData *clmd= cloth_v; Cloth *cloth= clmd->clothObject; @@ -522,7 +522,7 @@ static void ptcache_read_cloth(int index, void *cloth_v, void **data, float frs_ PTCACHE_DATA_TO(data, BPHYS_DATA_XCONST, 0, vert->xconst); } } -static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, float UNUSED(frs_sec), float cfra, float cfra1, float cfra2, float *old_data) { ClothModifierData *clmd= cloth_v; Cloth *cloth= clmd->clothObject; @@ -558,7 +558,7 @@ static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, flo /* should vert->xconst be interpolated somehow too? - jahka */ } -static int ptcache_totpoint_cloth(void *cloth_v, int cfra) +static int ptcache_totpoint_cloth(void *cloth_v, int UNUSED(cfra)) { ClothModifierData *clmd= cloth_v; return clmd->clothObject ? clmd->clothObject->numverts : 0; @@ -635,7 +635,7 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p } /* Smoke functions */ -static int ptcache_totpoint_smoke(void *smoke_v, int cfra) +static int ptcache_totpoint_smoke(void *smoke_v, int UNUSED(cfra)) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; SmokeDomainSettings *sds = smd->domain; @@ -648,7 +648,7 @@ static int ptcache_totpoint_smoke(void *smoke_v, int cfra) } /* Smoke functions */ -static int ptcache_totpoint_smoke_turbulence(void *smoke_v, int cfra) +static int ptcache_totpoint_smoke_turbulence(void *smoke_v, int UNUSED(cfra)) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; SmokeDomainSettings *sds = smd->domain; @@ -671,6 +671,8 @@ static int ptcache_compress_write(PTCacheFile *pf, unsigned char *in, unsigned i unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); size_t sizeOfIt = 5; + (void)mode; /* unused when building w/o compression */ + #ifdef WITH_LZO out_len= LZO_OUT_LEN(in_len); if(mode == 1) { @@ -2220,7 +2222,7 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) cache->flag &= ~PTCACHE_REDO_NEEDED; if(pid->type == PTCACHE_TYPE_CLOTH) - cloth_free_modifier(pid->ob, pid->calldata); + cloth_free_modifier(pid->calldata); else if(pid->type == PTCACHE_TYPE_SOFTBODY) sbFreeSimulation(pid->calldata); else if(pid->type == PTCACHE_TYPE_PARTICLES) diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 3f41b704f97..fde180cadc6 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -106,7 +106,7 @@ void free_qtcodecdata(QuicktimeCodecData *qcd) } } -Scene *copy_scene(Main *bmain, Scene *sce, int type) +Scene *copy_scene(Scene *sce, int type) { Scene *scen; ToolSettings *ts; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 7b428661c6d..7ce5dcc3884 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -53,7 +53,7 @@ #include "RNA_access.h" /* **** XXX **** */ -static void error(const char *error, ...) {} +static void error(const char *UNUSED(error), ...) {} #define INT 96 #define FLO 128 @@ -77,15 +77,15 @@ static struct ImBuf * prepare_effect_imbufs( if (!ibuf1 && !ibuf2 && !ibuf3) { /* hmmm, global float option ? */ - out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect, 0); + out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect); } 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); + out = IMB_allocImBuf((short)x, (short)y, 32, IB_rectfloat); } else { - out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect, 0); + out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect); } if (ibuf1 && !ibuf1->rect_float && out->rect_float) { @@ -273,9 +273,9 @@ static ImBuf * IMB_cast_away_list(ImBuf * i) } static struct ImBuf * do_plugin_effect( - Main *bmain, Scene *scene, Sequence *seq, float cfra, + Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float cfra, float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -370,8 +370,8 @@ static struct ImBuf * do_plugin_effect( return out; } -static int do_plugin_early_out(struct Sequence *seq, - float facf0, float facf1) +static int do_plugin_early_out(struct Sequence *UNUSED(seq), + float UNUSED(facf0), float UNUSED(facf1)) { return 0; } @@ -524,9 +524,9 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_alphaover_effect( - Main *bmain, Scene *scene, Sequence *seq, float cfra, + Main *bmain, Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -696,9 +696,9 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf* do_alphaunder_effect( - Main *bmain, Scene *scene, Sequence *seq, float cfra, + Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -821,9 +821,9 @@ 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( - Main *bmain, Scene *scene, Sequence *seq, float cfra, + Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -976,19 +976,19 @@ static void build_gammatabs() } } -static void init_gammacross(Sequence * seq) +static void init_gammacross(Sequence * UNUSED(seq)) { } -static void load_gammacross(Sequence * seq) +static void load_gammacross(Sequence * UNUSED(seq)) { } -static void free_gammacross(Sequence * seq) +static void free_gammacross(Sequence * UNUSED(seq)) { } -static void do_gammacross_effect_byte(float facf0, float facf1, +static void do_gammacross_effect_byte(float facf0, float UNUSED(facf1), int x, int y, unsigned char *rect1, unsigned char *rect2, @@ -1044,7 +1044,7 @@ static void do_gammacross_effect_byte(float facf0, float facf1, } -static void do_gammacross_effect_float(float facf0, float facf1, +static void do_gammacross_effect_float(float facf0, float UNUSED(facf1), int x, int y, float *rect1, float *rect2, float *out) @@ -1088,9 +1088,9 @@ static void do_gammacross_effect_float(float facf0, float facf1, } static struct ImBuf * do_gammacross_effect( - Main *bmain, Scene *scene, Sequence *seq, float cfra, + Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -1206,9 +1206,9 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf * do_add_effect(Main *bmain, Scene *scene, Sequence *seq, float cfra, +static struct ImBuf * do_add_effect(Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -1323,9 +1323,9 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_sub_effect( - Main *bmain, Scene *scene, Sequence *seq, float cfra, + Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -1537,9 +1537,9 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_mul_effect( - Main *bmain, Scene *scene, Sequence *seq, float cfra, + Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -1876,7 +1876,7 @@ static void copy_wipe_effect(Sequence *dst, Sequence *src) dst->effectdata = MEM_dupallocN(src->effectdata); } -static void do_wipe_effect_byte(Sequence *seq, float facf0, float facf1, +static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), int x, int y, unsigned char *rect1, unsigned char *rect2, unsigned char *out) @@ -1934,7 +1934,7 @@ static void do_wipe_effect_byte(Sequence *seq, float facf0, float facf1, } } -static void do_wipe_effect_float(Sequence *seq, float facf0, float facf1, +static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1), int x, int y, float *rect1, float *rect2, float *out) @@ -1993,9 +1993,9 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float facf1, } static struct ImBuf * do_wipe_effect( - Main *bmain, Scene *scene, Sequence *seq, float cfra, + Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float UNUSED(cfra), float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -2111,7 +2111,7 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out } } -static void do_transform(Scene *scene, Sequence *seq, float facf0, int x, int y, +static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x, int y, struct ImBuf *ibuf1,struct ImBuf *out) { TransformVars *transform = (TransformVars *)seq->effectdata; @@ -2144,9 +2144,9 @@ static void do_transform(Scene *scene, Sequence *seq, float facf0, int x, int y, static struct ImBuf * do_transform_effect( - Main *bmain, Scene *scene, Sequence *seq,float cfra, - float facf0, float facf1, int x, int y, - int preview_render_size, + Main *UNUSED(bmain), Scene *scene, Sequence *seq,float UNUSED(cfra), + float facf0, float UNUSED(facf1), int x, int y, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -2631,7 +2631,7 @@ static void copy_glow_effect(Sequence *dst, Sequence *src) } //void do_glow_effect(Cast *cast, float facf0, float facf1, int xo, int yo, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *outbuf, ImBuf *use) -static void do_glow_effect_byte(Sequence *seq, float facf0, float facf1, +static void do_glow_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), int x, int y, char *rect1, char *rect2, char *out) { @@ -2646,7 +2646,7 @@ static void do_glow_effect_byte(Sequence *seq, float facf0, float facf1, RVAddBitmaps_byte (inbuf , outbuf, outbuf, x, y); } -static void do_glow_effect_float(Sequence *seq, float facf0, float facf1, +static void do_glow_effect_float(Sequence *seq, float facf0, float UNUSED(facf1), int x, int y, float *rect1, float *rect2, float *out) { @@ -2662,9 +2662,9 @@ static void do_glow_effect_float(Sequence *seq, float facf0, float facf1, } static struct ImBuf * do_glow_effect( - Main *bmain, Scene *scene, Sequence *seq, float cfra, + Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float UNUSED(cfra), float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -2716,16 +2716,16 @@ static void copy_solid_color(Sequence *dst, Sequence *src) dst->effectdata = MEM_dupallocN(src->effectdata); } -static int early_out_color(struct Sequence *seq, - float facf0, float facf1) +static int early_out_color(struct Sequence *UNUSED(seq), + float UNUSED(facf0), float UNUSED(facf1)) { return -1; } static struct ImBuf * do_solid_color( - Main *bmain, Scene *scene, Sequence *seq, float cfra, + Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float UNUSED(cfra), float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -2813,14 +2813,14 @@ static int num_inputs_multicam() return 0; } -static int early_out_multicam(struct Sequence *seq, float facf0, float facf1) +static int early_out_multicam(struct Sequence *UNUSED(seq), float UNUSED(facf0), float UNUSED(facf1)) { return -1; } static struct ImBuf * do_multicam( Main *bmain, Scene *scene, Sequence *seq, float cfra, - float facf0, float facf1, int x, int y, + float UNUSED(facf0), float UNUSED(facf1), int x, int y, int preview_render_size, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) @@ -2907,8 +2907,8 @@ static void copy_speed_effect(Sequence *dst, Sequence *src) v->length = 0; } -static int early_out_speed(struct Sequence *seq, - float facf0, float facf1) +static int early_out_speed(struct Sequence *UNUSED(seq), + float UNUSED(facf0), float UNUSED(facf1)) { return 1; } @@ -3039,22 +3039,22 @@ static void do_speed_effect(Sequence * seq,int cfra, ********************************************************************** */ -static void init_noop(struct Sequence *seq) +static void init_noop(struct Sequence *UNUSED(seq)) { } -static void load_noop(struct Sequence *seq) +static void load_noop(struct Sequence *UNUSED(seq)) { } -static void init_plugin_noop(struct Sequence *seq, const char * fname) +static void init_plugin_noop(struct Sequence *UNUSED(seq), const char *UNUSED(fname)) { } -static void free_noop(struct Sequence *seq) +static void free_noop(struct Sequence *UNUSED(seq)) { } @@ -3064,13 +3064,13 @@ static int num_inputs_default() return 2; } -static int early_out_noop(struct Sequence *seq, - float facf0, float facf1) +static int early_out_noop(struct Sequence *UNUSED(seq), + float UNUSED(facf0), float UNUSED(facf1)) { return 0; } -static int early_out_fade(struct Sequence *seq, +static int early_out_fade(struct Sequence *UNUSED(seq), float facf0, float facf1) { if (facf0 == 0.0 && facf1 == 0.0) { @@ -3081,7 +3081,7 @@ static int early_out_fade(struct Sequence *seq, return 0; } -static int early_out_mul_input2(struct Sequence *seq, +static int early_out_mul_input2(struct Sequence *UNUSED(seq), float facf0, float facf1) { if (facf0 == 0.0 && facf1 == 0.0) { @@ -3090,13 +3090,13 @@ static int early_out_mul_input2(struct Sequence *seq, return 0; } -static void store_icu_yrange_noop(struct Sequence * seq, +static void store_icu_yrange_noop(struct Sequence * UNUSED(seq), short adrcode, float * ymin, float * ymax) { /* defaults are fine */ } -static void get_default_fac_noop(struct Sequence *seq, float cfra, +static void get_default_fac_noop(struct Sequence *UNUSED(seq), float UNUSED(cfra), float * facf0, float * facf1) { *facf0 = *facf1 = 1.0; @@ -3111,10 +3111,10 @@ static void get_default_fac_fade(struct Sequence *seq, float cfra, *facf1 /= seq->len; } -static struct ImBuf * do_overdrop_effect(Main *bmain, Scene *scene, Sequence *seq, float cfra, +static struct ImBuf * do_overdrop_effect(Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, int x, int y, - int preview_render_size, + int UNUSED(preview_render_size), struct ImBuf * ibuf1, struct ImBuf * ibuf2, struct ImBuf * ibuf3) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index dcd411409f9..6d087837302 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1021,7 +1021,7 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se #define PROXY_MAXFILE (2*FILE_MAXDIR+FILE_MAXFILE) -static int seq_proxy_get_fname(Scene *scene, Sequence * seq, int cfra, char * name, int render_size) +static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, char * name, int render_size) { int frameno; char dir[FILE_MAXDIR]; @@ -1444,7 +1444,7 @@ static void color_balance(Sequence * seq, ImBuf* ibuf, float mul) */ int input_have_to_preprocess( - Scene *scene, Sequence * seq, float cfra, int seqrectx, int seqrecty) + Scene *UNUSED(scene), Sequence * seq, float UNUSED(cfra), int UNUSED(seqrectx), int UNUSED(seqrecty)) { float mul; @@ -1476,7 +1476,7 @@ int input_have_to_preprocess( } static ImBuf * input_preprocess( - Scene *scene, Sequence *seq, float cfra, int seqrectx, int seqrecty, + Scene *scene, Sequence *seq, float UNUSED(cfra), int seqrectx, int seqrecty, ImBuf * ibuf) { float mul; @@ -1521,9 +1521,9 @@ static ImBuf * input_preprocess( ImBuf * i; if (ibuf->rect_float) { - i = IMB_allocImBuf(dx, dy,32, IB_rectfloat, 0); + i = IMB_allocImBuf(dx, dy,32, IB_rectfloat); } else { - i = IMB_allocImBuf(dx, dy,32, IB_rect, 0); + i = IMB_allocImBuf(dx, dy,32, IB_rect); } IMB_rectcpy(i, ibuf, @@ -1787,7 +1787,7 @@ finish: if (!out) { out = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); + (short)seqrectx, (short)seqrecty, 32, IB_rect); } return out; @@ -1878,7 +1878,7 @@ static ImBuf * seq_render_scene_strip_impl( RE_AcquireResultImage(re, &rres); if(rres.rectf) { - ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat, 0); + ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rectfloat); memcpy(ibuf->rect_float, rres.rectf, 4*sizeof(float)*rres.rectx*rres.recty); if(rres.rectz) { addzbuffloatImBuf(ibuf); @@ -1890,7 +1890,7 @@ static ImBuf * seq_render_scene_strip_impl( IMB_convert_profile(ibuf, IB_PROFILE_SRGB); } else if (rres.rect32) { - ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect, 0); + ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, IB_rect); memcpy(ibuf->rect, rres.rect32, 4*rres.rectx*rres.recty); } @@ -2079,7 +2079,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float if (!ibuf) { ibuf = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, 32, IB_rect, 0); + (short)seqrectx, (short)seqrecty, 32, IB_rect); } if (ibuf->x != seqrectx || ibuf->y != seqrecty) { @@ -2213,7 +2213,7 @@ static ImBuf* seq_render_strip_stack( if (i == 0) { out = IMB_allocImBuf( (short)seqrectx, (short)seqrecty, - 32, IB_rect, 0); + 32, IB_rect); } break; case 0: diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 965ce9801d7..d1eed94d330 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -435,7 +435,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) } /*! init triangle divisions */ -void calcTriangleDivs(Object *ob, MVert *verts, int numverts, MFace *faces, int numfaces, int numtris, int **tridivs, float cell_len) +void calcTriangleDivs(Object *ob, MVert *verts, int UNUSED(numverts), MFace *faces, int numfaces, int numtris, int **tridivs, float cell_len) { // mTriangleDivs1.resize( faces.size() ); // mTriangleDivs2.resize( faces.size() ); @@ -1270,7 +1270,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) } } } -void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, int useRenderParams, int isFinalCalc) +void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) { if((smd->type & MOD_SMOKE_TYPE_FLOW)) { diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 98a50eee146..58aa171e97b 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -171,7 +171,7 @@ static void Vec3PlusStVec(float *v, float s, float *v1); /*physical unit of force is [kg * m / sec^2]*/ -static float sb_grav_force_scale(Object *ob) +static float sb_grav_force_scale(Object *UNUSED(ob)) /* since unit of g is [m/sec^2] and F = mass * g we rescale unit mass of node to 1 gramm put it to a function here, so we can add user options later without touching simulation code */ @@ -179,7 +179,7 @@ static float sb_grav_force_scale(Object *ob) return (0.001f); } -static float sb_fric_force_scale(Object *ob) +static float sb_fric_force_scale(Object *UNUSED(ob)) /* rescaling unit of drag [1 / sec] to somehow reasonable put it to a function here, so we can add user options later without touching simulation code */ @@ -1029,7 +1029,7 @@ static int query_external_colliders(Scene *scene, Object *me) /* +++ the aabb "force" section*/ -static int sb_detect_aabb_collisionCached( float force[3], unsigned int par_layer,struct Object *vertexowner,float time) +static int sb_detect_aabb_collisionCached( float force[3], unsigned int par_layer,struct Object *vertexowner,float UNUSED(time)) { Object *ob; SoftBody *sb=vertexowner->soft; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 5e95b19b64f..bf8e2d348ac 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -79,7 +79,7 @@ void sound_init_once() AUD_initOnce(); } -void sound_init(struct Main *bmain) +void sound_init(void) { AUD_DeviceSpecs specs; int device, buffersize; @@ -141,7 +141,7 @@ struct bSound* sound_new_file(struct Main *bmain, char* filename) BLI_strncpy(sound->name, filename, FILE_MAX); // XXX unused currently sound->type = SOUND_TYPE_FILE; - sound_load(bmain, sound); + sound_load(sound); if(!sound->playback_handle) { @@ -167,7 +167,7 @@ struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source) sound->child_sound = source; sound->type = SOUND_TYPE_BUFFER; - sound_load(CTX_data_main(C), sound); + sound_load(sound); if(!sound->playback_handle) { @@ -193,7 +193,7 @@ struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, floa sound->end = end; sound->type = SOUND_TYPE_LIMITER; - sound_load(CTX_data_main(C), sound); + sound_load(sound); if(!sound->playback_handle) { @@ -234,7 +234,7 @@ void sound_delete_cache(struct bSound* sound) } } -void sound_load(struct Main *bmain, struct bSound* sound) +void sound_load(struct bSound* sound) { if(sound) { diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 00614ef0f4f..8363ff13ef9 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -137,6 +137,8 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL int quality; double framerate; + (void)scene; /* unused */ + filepath_avi(name, rd); sframe = (rd->sfra); @@ -175,7 +177,7 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL return 1; } -static int append_avi(RenderData *rd, int frame, int *pixels, int rectx, int recty, ReportList *reports) +static int append_avi(RenderData *UNUSED(rd), int frame, int *pixels, int rectx, int recty, ReportList *UNUSED(reports)) { unsigned int *rt1, *rt2, *rectot; int x, y; diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index b0c05c31fa1..bbc441f3622 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -47,6 +47,7 @@ #include "DNA_userdef_types.h" +#include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_report.h" @@ -96,10 +97,12 @@ static int closesocket(int fd) } #endif -int start_frameserver(struct Scene *scene, RenderData *rd, int rectx, int recty, ReportList *reports) +int start_frameserver(struct Scene *scene, RenderData *UNUSED(rd), int rectx, int recty, ReportList *reports) { struct sockaddr_in addr; int arg = 1; + + (void)scene; /* unused */ if (!startup_socket_system()) { BKE_report(reports, RPT_ERROR, "Can't startup socket system"); @@ -243,7 +246,7 @@ static int handle_request(RenderData *rd, char * req) return -1; } -int frameserver_loop(RenderData *rd, ReportList *reports) +int frameserver_loop(RenderData *rd, ReportList *UNUSED(reports)) { fd_set readfds; struct timeval tv; @@ -350,7 +353,7 @@ static void serve_ppm(int *pixels, int rectx, int recty) connsock = -1; } -int append_frameserver(RenderData *rd, int frame, int *pixels, int rectx, int recty, ReportList *reports) +int append_frameserver(RenderData *UNUSED(rd), int frame, int *pixels, int rectx, int recty, ReportList *UNUSED(reports)) { fprintf(stderr, "Serving frame: %d\n", frame); if (write_ppm) { -- cgit v1.2.3 From fe693b4631b604e502cfd40078a1fcad9e03dc58 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sat, 16 Oct 2010 14:49:56 +0000 Subject: Revert overaggressive parameter removal: Main struct is used in audio when Jack support is enabled. --- source/blender/blenkernel/intern/sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index bf8e2d348ac..ca1fd80b406 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -79,7 +79,7 @@ void sound_init_once() AUD_initOnce(); } -void sound_init(void) +void sound_init(struct Main *bmain) { AUD_DeviceSpecs specs; int device, buffersize; -- cgit v1.2.3 From 3b6564a821e8797942132ad30f93af810952237a Mon Sep 17 00:00:00 2001 From: Elia Sarti Date: Sat, 16 Oct 2010 17:28:52 +0000 Subject: Fix for [#24292] When rendering with the stamp feature the scene opt. affects the seq. strip placement Fixed typo. --- source/blender/blenkernel/intern/image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d750300291b..8ba7cde519d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1161,7 +1161,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i } if (stamp_data.strip[0]) { - BLF_width_and_height(mono, stamp_data.scene, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.strip, &w, &h); h= h_fixed; /* Top right corner, with an extra space because blenfont is too strict! */ x= width - w - pad; -- cgit v1.2.3 From 28e144db920699a13e6cd196ac91f13e11b2877c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 16 Oct 2010 20:43:16 +0000 Subject: Fix #24139: Edge loop + Multi-Resolution modifier results weird artifacts - mdisp_corners used to return incorrect number of verts in some cases - fixed memory corruption when face changed vertex count in edit mode (forgot displacement for such faces atm, could be changed in the future) --- source/blender/blenkernel/intern/customdata.c | 34 ++++++++++++++++++++------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index f4db8e953f9..58cd08f1c4c 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -442,8 +442,15 @@ static void mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, fl static int mdisp_corners(MDisps *s) { - /* silly trick because we don't get it from callback */ - return (s->totdisp % (3*3) == 0)? 3: 4; + int lvl= 13; + + while(lvl > 0) { + int side = (1 << (lvl-1)) + 1; + if ((s->totdisp % (side*side)) == 0) return s->totdisp / (side*side); + lvl--; + } + + return 0; } static void layerSwap_mdisps(void *data, const int *ci) @@ -452,19 +459,28 @@ static void layerSwap_mdisps(void *data, const int *ci) float (*d)[3] = NULL; int corners, cornersize, S; - /* this function is untested .. */ if(s->disps) { - corners = mdisp_corners(s); - cornersize = s->totdisp/corners; + int nverts= (ci[1] == 3) ? 4 : 3; /* silly way to know vertex count of face */ + corners= mdisp_corners(s); + cornersize= s->totdisp/corners; + + if(corners!=nverts) { + /* happens when face changed vertex count in edit mode + if it happened, just forgot displacement */ - d = MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap"); + MEM_freeN(s->disps); + s->disps= NULL; + s->totdisp= 0; /* flag to update totdisp */ + return; + } + + d= MEM_callocN(sizeof(float) * 3 * s->totdisp, "mdisps swap"); for(S = 0; S < corners; S++) memcpy(d + cornersize*S, s->disps + cornersize*ci[S], cornersize*3*sizeof(float)); - if(s->disps) - MEM_freeN(s->disps); - s->disps = d; + MEM_freeN(s->disps); + s->disps= d; } } -- cgit v1.2.3 From 30b79ddcc6e2737add3a7ebd49b167c1776e4087 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 17 Oct 2010 06:38:56 +0000 Subject: - fixed remaining unused warnings. - omit render code from this warning (cmake only), until render branch is merged. - moved -Wunused-parameter warning to apply to all C code in blender (not just ./source/blender), (cmake only). --- source/blender/blenkernel/intern/BME_tools.c | 14 +++++++------- source/blender/blenkernel/intern/CCGSubSurf.c | 19 +++++++++++++------ source/blender/blenkernel/intern/DerivedMesh.c | 2 ++ source/blender/blenkernel/intern/boids.c | 6 +++--- source/blender/blenkernel/intern/customdata.c | 16 ++++++++-------- source/blender/blenkernel/intern/implicit.c | 6 +++--- source/blender/blenkernel/intern/nla.c | 2 +- source/blender/blenkernel/intern/particle.c | 6 +++--- source/blender/blenkernel/intern/seqeffects.c | 14 +++++++------- source/blender/blenkernel/intern/softbody.c | 22 +++++++++++----------- source/blender/blenkernel/intern/sound.c | 2 ++ source/blender/blenkernel/intern/subsurf_ccg.c | 8 ++++---- 12 files changed, 64 insertions(+), 53 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index e5a355e5f24..444bc10d562 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -107,7 +107,7 @@ float *BME_new_transdata_float(BME_TransData_Head *td) { return BLI_memarena_alloc(td->ma, sizeof(float)); } -static int BME_is_nonmanifold_vert(BME_Mesh *bm, BME_Vert *v) { +static int BME_is_nonmanifold_vert(BME_Mesh *UNUSED(bm), BME_Vert *v) { BME_Edge *e, *oe; BME_Loop *l; int len, count, flag; @@ -217,7 +217,7 @@ static void BME_data_interp_from_verts(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, #endif -static void BME_data_facevert_edgesplit(BME_Mesh *bm, BME_Vert *v1, BME_Vert *v2, BME_Vert *v, BME_Edge *e1, float fac){ +static void BME_data_facevert_edgesplit(BME_Mesh *bm, BME_Vert *v1, BME_Vert *UNUSED(v2), BME_Vert *v, BME_Edge *e1, float fac){ void *src[2]; float w[2]; BME_Loop *l=NULL, *v1loop = NULL, *vloop = NULL, *v2loop = NULL; @@ -356,7 +356,7 @@ static int BME_bevel_get_vec(float *vec, BME_Vert *v1, BME_Vert *v2, BME_TransDa * vec2 is the direction of projection (pointing away from vec1) * up_vec is used for orientation (expected to be normalized) * returns the length of the projected vector that lies along vec1 */ -static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *td) { +static float BME_bevel_project_vec(float *vec1, float *vec2, float *up_vec, int is_forward, BME_TransData_Head *UNUSED(td)) { float factor, vec3[3], tmp[3],c1,c2; cross_v3_v3v3(tmp,vec1,vec2); @@ -582,7 +582,7 @@ static float BME_bevel_set_max(BME_Vert *v1, BME_Vert *v2, float value, BME_Tran return max; } -static BME_Vert *BME_bevel_wire(BME_Mesh *bm, BME_Vert *v, float value, int res, int options, BME_TransData_Head *td) { +static BME_Vert *BME_bevel_wire(BME_Mesh *bm, BME_Vert *v, float value, int res, int UNUSED(options), BME_TransData_Head *td) { BME_Vert *ov1, *ov2, *v1, *v2; ov1 = BME_edge_getothervert(v->edge, v); @@ -607,7 +607,7 @@ static BME_Vert *BME_bevel_wire(BME_Mesh *bm, BME_Vert *v, float value, int res, return v1; } -static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int options, float *up_vec, BME_TransData_Head *td) { +static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int UNUSED(options), float *up_vec, BME_TransData_Head *td) { BME_Vert *v1, *v2, *kv; BME_Loop *kl=NULL, *nl; BME_Edge *e; @@ -708,7 +708,7 @@ static BME_Loop *BME_bevel_edge(BME_Mesh *bm, BME_Loop *l, float value, int opti return l; } -static BME_Loop *BME_bevel_vert(BME_Mesh *bm, BME_Loop *l, float value, int options, float *up_vec, BME_TransData_Head *td) { +static BME_Loop *BME_bevel_vert(BME_Mesh *bm, BME_Loop *l, float value, int UNUSED(options), float *up_vec, BME_TransData_Head *td) { BME_Vert *v1, *v2; BME_Poly *f; @@ -859,7 +859,7 @@ static void BME_bevel_add_vweight(BME_TransData_Head *td, BME_Mesh *bm, BME_Vert } } -static float BME_bevel_get_angle(BME_Mesh *bm, BME_Edge *e, BME_Vert *v) { +static float BME_bevel_get_angle(BME_Mesh *UNUSED(bm), BME_Edge *e, BME_Vert *v) { BME_Vert *v1, *v2; BME_Loop *l1, *l2; float vec1[3], vec2[3], vec3[3], vec4[3]; diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index bbd68fb797b..1cd5ae381c4 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -15,6 +15,13 @@ #define CCG_INLINE inline #endif +/* copied from BKE_utildefines.h ugh */ +#ifdef __GNUC__ +# define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) +#else +# define UNUSED(x) x +#endif + /* used for normalize_v3 in BLI_math_vector * float.h's FLT_EPSILON causes trouble with subsurf normals - campbell */ #define EPSILON (1.0e-35f) @@ -185,13 +192,13 @@ static int _ehashIterator_isStopped(EHashIterator *ehi) { /***/ -static void *_stdAllocator_alloc(CCGAllocatorHDL a, int numBytes) { +static void *_stdAllocator_alloc(CCGAllocatorHDL UNUSED(a), int numBytes) { return malloc(numBytes); } -static void *_stdAllocator_realloc(CCGAllocatorHDL a, void *ptr, int newSize, int oldSize) { +static void *_stdAllocator_realloc(CCGAllocatorHDL UNUSED(a), void *ptr, int newSize, int UNUSED(oldSize)) { return realloc(ptr, newSize); } -static void _stdAllocator_free(CCGAllocatorHDL a, void *ptr) { +static void _stdAllocator_free(CCGAllocatorHDL UNUSED(a), void *ptr) { free(ptr); } @@ -2601,7 +2608,7 @@ float ccgSubSurf_getEdgeCrease(CCGEdge *e) { /* Face accessors */ -CCGFaceHDL ccgSubSurf_getFaceFaceHandle(CCGSubSurf *ss, CCGFace *f) { +CCGFaceHDL ccgSubSurf_getFaceFaceHandle(CCGSubSurf *UNUSED(ss), CCGFace *f) { return f->fHDL; } int ccgSubSurf_getFaceAge(CCGSubSurf *ss, CCGFace *f) { @@ -2619,14 +2626,14 @@ void *ccgSubSurf_getFaceUserData(CCGSubSurf *ss, CCGFace *f) { int ccgSubSurf_getFaceNumVerts(CCGFace *f) { return f->numVerts; } -CCGVert *ccgSubSurf_getFaceVert(CCGSubSurf *ss, CCGFace *f, int index) { +CCGVert *ccgSubSurf_getFaceVert(CCGSubSurf *UNUSED(ss), CCGFace *f, int index) { if (index<0 || index>=f->numVerts) { return NULL; } else { return FACE_getVerts(f)[index]; } } -CCGEdge *ccgSubSurf_getFaceEdge(CCGSubSurf *ss, CCGFace *f, int index) { +CCGEdge *ccgSubSurf_getFaceEdge(CCGSubSurf *UNUSED(ss), CCGFace *f, int index) { if (index<0 || index>=f->numVerts) { return NULL; } else { diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index e70dde1474a..2e8922dec1b 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -633,6 +633,8 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm; EditFace *efa; int i, draw; + + (void)setMaterial; /* unused */ if (emdm->vertexCos) { EditVert *eve; diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index cfe16e089cf..943cf20720e 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -58,7 +58,7 @@ typedef struct BoidValues { static int apply_boid_rule(BoidBrainData *bbd, BoidRule *rule, BoidValues *val, ParticleData *pa, float fuzziness); -static int rule_none(BoidRule *rule, BoidBrainData *UNUSED(data), BoidValues *val, ParticleData *pa) +static int rule_none(BoidRule *UNUSED(rule), BoidBrainData *UNUSED(data), BoidValues *UNUSED(val), ParticleData *UNUSED(pa)) { return 0; } @@ -344,7 +344,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * return ret; } -static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa) +static int rule_separate(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues *val, ParticleData *pa) { KDTreeNearest *ptn = NULL; ParticleTarget *pt; @@ -384,7 +384,7 @@ static int rule_separate(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, Pa } return ret; } -static int rule_flock(BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa) +static int rule_flock(BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues *UNUSED(val), ParticleData *pa) { KDTreeNearest ptn[11]; float vec[3] = {0.0f, 0.0f, 0.0f}, loc[3] = {0.0f, 0.0f, 0.0f}; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 58cd08f1c4c..7f91df3b281 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -145,7 +145,7 @@ static void linklist_free_simple(void *link) } static void layerInterp_mdeformvert(void **sources, float *weights, - float *sub_weights, int count, void *dest) + float *UNUSED(sub_weights), int count, void *dest) { MDeformVert *dvert = dest; LinkNode *dest_dw = NULL; /* a list of lists of MDeformWeight pointers */ @@ -203,7 +203,7 @@ static void layerInterp_mdeformvert(void **sources, float *weights, static void layerInterp_msticky(void **sources, float *weights, - float *sub_weights, int count, void *dest) + float *UNUSED(sub_weights), int count, void *dest) { float co[2], w; MSticky *mst; @@ -484,8 +484,8 @@ static void layerSwap_mdisps(void *data, const int *ci) } } -static void layerInterp_mdisps(void **UNUSED(sources), float *weights, float *sub_weights, - int UNUSED(count), void *dest) +static void layerInterp_mdisps(void **UNUSED(sources), float *UNUSED(weights), + float *UNUSED(sub_weights), int UNUSED(count), void *dest) { MDisps *d = dest; int i; @@ -563,7 +563,7 @@ static void layerCopy_mdisps(const void *source, void *dest, int count) } } -static void layerFree_mdisps(void *data, int count, int size) +static void layerFree_mdisps(void *data, int count, int UNUSED(size)) { int i; MDisps *d = data; @@ -609,7 +609,7 @@ static int layerWrite_mdisps(CDataFile *cdf, void *data, int count) return 1; } -static size_t layerFilesize_mdisps(CDataFile *cdf, void *data, int count) +static size_t layerFilesize_mdisps(CDataFile *UNUSED(cdf), void *data, int count) { MDisps *d = data; size_t size = 0; @@ -2349,7 +2349,7 @@ static void customdata_external_filename(char filename[FILE_MAX], ID *id, Custom BLI_path_abs(filename, path); } -void CustomData_external_reload(CustomData *data, ID *id, CustomDataMask mask, int totelem) +void CustomData_external_reload(CustomData *data, ID *UNUSED(id), CustomDataMask mask, int totelem) { CustomDataLayer *layer; const LayerTypeInfo *typeInfo; @@ -2519,7 +2519,7 @@ void CustomData_external_write(CustomData *data, ID *id, CustomDataMask mask, in cdf_free(cdf); } -void CustomData_external_add(CustomData *data, ID *id, int type, int UNUSED(totelem), const char *filename) +void CustomData_external_add(CustomData *data, ID *UNUSED(id), int type, int UNUSED(totelem), const char *filename) { CustomDataExternal *external= data->external; CustomDataLayer *layer; diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 9baaf7e5abc..e0077ec7d26 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1218,7 +1218,7 @@ DO_INLINE void dfdx_damp(float to[3][3], float dir[3],float length,const float } -DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, lfVector *lF, lfVector *X, lfVector *V, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, float time) +DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, lfVector *UNUSED(lF), lfVector *X, lfVector *V, fmatrix3x3 *UNUSED(dFdV), fmatrix3x3 *UNUSED(dFdX), float time) { Cloth *cloth = clmd->clothObject; ClothVertex *verts = cloth->verts; @@ -1353,7 +1353,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, } } -DO_INLINE void cloth_apply_spring_force(ClothModifierData *clmd, ClothSpring *s, lfVector *lF, lfVector *X, lfVector *V, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX) +DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSpring *s, lfVector *lF, lfVector *UNUSED(X), lfVector *UNUSED(V), fmatrix3x3 *dFdV, fmatrix3x3 *dFdX) { if(s->flags & CLOTH_SPRING_FLAG_NEEDED) { @@ -1708,7 +1708,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec // printf("\n"); } -static void simulate_implicit_euler(lfVector *Vnew, lfVector *lX, lfVector *lV, lfVector *lF, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, float dt, fmatrix3x3 *A, lfVector *B, lfVector *dV, fmatrix3x3 *S, lfVector *z, lfVector *olddV, fmatrix3x3 *P, fmatrix3x3 *Pinv, fmatrix3x3 *M, fmatrix3x3 *bigI) +static void simulate_implicit_euler(lfVector *Vnew, lfVector *UNUSED(lX), lfVector *lV, lfVector *lF, fmatrix3x3 *dFdV, fmatrix3x3 *dFdX, float dt, fmatrix3x3 *A, lfVector *B, lfVector *dV, fmatrix3x3 *S, lfVector *z, lfVector *olddV, fmatrix3x3 *UNUSED(P), fmatrix3x3 *UNUSED(Pinv), fmatrix3x3 *M, fmatrix3x3 *UNUSED(bigI)) { unsigned int numverts = dFdV[0].vcount; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 09ba967e265..67c3e746a63 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1585,7 +1585,7 @@ void BKE_nla_tweakmode_exit (AnimData *adt) /* Baking Tools ------------------------------------------- */ -void BKE_nla_bake (Scene *scene, ID *id, AnimData *adt, int UNUSED(flag)) +void BKE_nla_bake (Scene *scene, ID *UNUSED(id), AnimData *adt, int UNUSED(flag)) { /* verify that data is valid diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index f7345d6159a..624587338c9 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1647,7 +1647,7 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, float * return DMCACHE_NOTFOUND; } -static int psys_map_index_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache, float *fw, float foffset, int *mapindex, float *mapfw) +static int psys_map_index_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache, float *fw, float UNUSED(foffset), int *mapindex, float *mapfw) { if(index < 0) return 0; @@ -1803,7 +1803,7 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys) /* Particles on a shape */ /************************************************/ /* ready for future use */ -static void psys_particle_on_shape(int UNUSED(distr), int index, float *UNUSED(fuv), float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) +static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float *UNUSED(fuv), float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) { /* TODO */ float zerovec[3]={0.0f,0.0f,0.0f}; @@ -2185,7 +2185,7 @@ static void do_rough_end(float *loc, float mat[4][4], float t, float fac, float VECADDFAC(state->co,state->co,mat[0],rough[0]); VECADDFAC(state->co,state->co,mat[1],rough[1]); } -static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheKey *ca, int k, int steps, float *rootco, float effector, float dfra, float UNUSED(cfra), float *length, float *vec) +static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheKey *ca, int k, int steps, float *UNUSED(rootco), float effector, float UNUSED(dfra), float UNUSED(cfra), float *length, float *vec) { float force[3] = {0.0f,0.0f,0.0f}; ParticleKey eff_key; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 7ce5dcc3884..6477c6b4f75 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -524,7 +524,7 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_alphaover_effect( - Main *bmain, Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), + Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), float facf0, float facf1, int x, int y, int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, @@ -2633,7 +2633,7 @@ static void copy_glow_effect(Sequence *dst, Sequence *src) //void do_glow_effect(Cast *cast, float facf0, float facf1, int xo, int yo, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *outbuf, ImBuf *use) static void do_glow_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), int x, int y, char *rect1, - char *rect2, char *out) + char *UNUSED(rect2), char *out) { unsigned char *outbuf=(unsigned char *)out; unsigned char *inbuf=(unsigned char *)rect1; @@ -2648,7 +2648,7 @@ static void do_glow_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), static void do_glow_effect_float(Sequence *seq, float facf0, float UNUSED(facf1), int x, int y, - float *rect1, float *rect2, float *out) + float *rect1, float *UNUSED(rect2), float *out) { float *outbuf = out; float *inbuf = rect1; @@ -2822,8 +2822,8 @@ static struct ImBuf * do_multicam( Main *bmain, Scene *scene, Sequence *seq, float cfra, float UNUSED(facf0), float UNUSED(facf1), int x, int y, int preview_render_size, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) + struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), + struct ImBuf *UNUSED(ibuf3)) { struct ImBuf * i; struct ImBuf * out; @@ -2914,7 +2914,7 @@ static int early_out_speed(struct Sequence *UNUSED(seq), } static void store_icu_yrange_speed(struct Sequence * seq, - short adrcode, float * ymin, float * ymax) + short UNUSED(adrcode), float * ymin, float * ymax) { SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; @@ -3091,7 +3091,7 @@ static int early_out_mul_input2(struct Sequence *UNUSED(seq), } static void store_icu_yrange_noop(struct Sequence * UNUSED(seq), - short adrcode, float * ymin, float * ymax) + short UNUSED(adrcode), float *UNUSED(ymin), float *UNUSED(ymax)) { /* defaults are fine */ } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 58aa171e97b..978b3c9864f 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -678,7 +678,7 @@ static void add_mesh_quad_diag_springs(Object *ob) } } -static void add_2nd_order_roller(Object *ob,float stiffness,int *counter, int addsprings) +static void add_2nd_order_roller(Object *ob,float UNUSED(stiffness), int *counter, int addsprings) { /*assume we have a softbody*/ SoftBody *sb= ob->soft; /* is supposed to be there */ @@ -1029,7 +1029,7 @@ static int query_external_colliders(Scene *scene, Object *me) /* +++ the aabb "force" section*/ -static int sb_detect_aabb_collisionCached( float force[3], unsigned int par_layer,struct Object *vertexowner,float UNUSED(time)) +static int sb_detect_aabb_collisionCached( float UNUSED(force[3]), unsigned int UNUSED(par_layer),struct Object *vertexowner,float UNUSED(time)) { Object *ob; SoftBody *sb=vertexowner->soft; @@ -1094,7 +1094,7 @@ static int sb_detect_aabb_collisionCached( float force[3], unsigned int par_laye /* +++ the face external section*/ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float face_v3[3],float *damp, - float force[3], unsigned int par_layer,struct Object *vertexowner,float time) + float force[3], unsigned int UNUSED(par_layer),struct Object *vertexowner,float time) { Object *ob; GHash *hash; @@ -1192,7 +1192,7 @@ static int sb_detect_face_pointCached(float face_v1[3],float face_v2[3],float fa static int sb_detect_face_collisionCached(float face_v1[3],float face_v2[3],float face_v3[3],float *damp, - float force[3], unsigned int par_layer,struct Object *vertexowner,float time) + float force[3], unsigned int UNUSED(par_layer),struct Object *vertexowner,float time) { Object *ob; GHash *hash; @@ -1418,7 +1418,7 @@ static void scan_for_ext_face_forces(Object *ob,float timenow) /* +++ the spring external section*/ static int sb_detect_edge_collisionCached(float edge_v1[3],float edge_v2[3],float *damp, - float force[3], unsigned int par_layer,struct Object *vertexowner,float time) + float force[3], unsigned int UNUSED(par_layer),struct Object *vertexowner,float time) { Object *ob; GHash *hash; @@ -1659,7 +1659,7 @@ static void *exec_scan_for_ext_spring_forces(void *data) return 0; } -static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,int totsprings,int *ptr_to_break_func()) +static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,int totsprings,int *UNUSED(ptr_to_break_func())) { ListBase *do_effector = NULL; ListBase threads; @@ -1749,7 +1749,7 @@ static int choose_winner(float*w, float* pos,float*a,float*b,float*c,float*ca,fl static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], float *damp, - float force[3], unsigned int par_layer,struct Object *vertexowner, + float force[3], unsigned int UNUSED(par_layer), struct Object *vertexowner, float time,float vel[3], float *intrusion) { Object *ob= NULL; @@ -2084,7 +2084,7 @@ static void dfdv_goal(int ia, int ic,float factor) for(i=0;i<3;i++) nlMatrixAdd(ia+i,ic+i,factor); } */ -static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float forcetime,int nl_flags) +static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UNUSED(forcetime), int nl_flags) { SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bp1,*bp2; @@ -2175,7 +2175,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float fo /* since this is definitely the most CPU consuming task here .. try to spread it */ /* core function _softbody_calc_forces_slice_in_a_thread */ /* result is int to be able to flag user break */ -static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, float forcetime, float timenow,int ifirst,int ilast,int *ptr_to_break_func(),ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) +static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, float forcetime, float timenow,int ifirst,int ilast,int *UNUSED(ptr_to_break_func()),ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) { float iks; int bb,do_selfcollision,do_springcollision,do_aero; @@ -2386,7 +2386,7 @@ static void *exec_softbody_calc_forces(void *data) return 0; } -static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow,int totpoint,int *ptr_to_break_func(),struct ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) +static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow,int totpoint,int *UNUSED(ptr_to_break_func()),struct ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) { ListBase threads; SB_thread_context *sb_threads; @@ -2444,7 +2444,7 @@ static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float t MEM_freeN(sb_threads); } -static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, float timenow, int nl_flags) +static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, float timenow, int UNUSED(nl_flags)) { /* rule we never alter free variables :bp->vec bp->pos in here ! * this will ruin adaptive stepsize AKA heun! (BM) diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index ca1fd80b406..b2e5209a4fc 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -110,6 +110,8 @@ void sound_init(struct Main *bmain) #ifdef WITH_JACK AUD_setSyncCallback(sound_sync_callback, bmain); +#else + (void)bmain; /* unused */ #endif } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 6323e1e3c79..26bd981db4a 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -83,13 +83,13 @@ static void *arena_realloc(CCGAllocatorHDL a, void *ptr, int newSize, int oldSiz } return p2; } -static void arena_free(CCGAllocatorHDL a, void *ptr) { +static void arena_free(CCGAllocatorHDL UNUSED(a), void *UNUSED(ptr)) { } static void arena_release(CCGAllocatorHDL a) { BLI_memarena_free(a); } -static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAging, int useArena, int useFlatSubdiv) { +static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, int useAging, int useArena, int UNUSED(useFlatSubdiv)) { CCGMeshIFC ifc; CCGSubSurf *ccgSS; @@ -1146,7 +1146,7 @@ static void ccgDM_drawVerts(DerivedMesh *dm) { ccgFaceIterator_free(fi); glEnd(); } -static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges) { +static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(drawAllEdges)) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); @@ -1514,7 +1514,7 @@ static void ccgDM_drawFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, void *a dm->drawMappedFacesGLSL(dm, setMaterial, NULL, NULL); } -static void ccgDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned char *col1, unsigned char *col2) { +static void ccgDM_drawFacesColored(DerivedMesh *dm, int UNUSED(useTwoSided), unsigned char *col1, unsigned char *col2) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); -- cgit v1.2.3 From d6d1f3cb68f59566fbfa0f23ccaaa4b84a073247 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sun, 17 Oct 2010 09:01:37 +0000 Subject: Reverting Cam's audio code changes from revision 32517. Part of it has been reverted by Nathan already. Cam: next time please check, why a parameter is unused before you remove it! --- source/blender/blenkernel/intern/packedFile.c | 2 +- source/blender/blenkernel/intern/sound.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 78340288836..5bbb3506a78 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -486,7 +486,7 @@ int unpackSound(ReportList *reports, bSound *sound, int how) freePackedFile(sound->packedfile); sound->packedfile = 0; - sound_load(sound); + sound_load(NULL, sound); ret_value = RET_OK; } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index b2e5209a4fc..5c3047942f7 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -143,7 +143,7 @@ struct bSound* sound_new_file(struct Main *bmain, char* filename) BLI_strncpy(sound->name, filename, FILE_MAX); // XXX unused currently sound->type = SOUND_TYPE_FILE; - sound_load(sound); + sound_load(bmain, sound); if(!sound->playback_handle) { @@ -169,7 +169,7 @@ struct bSound* sound_new_buffer(struct bContext *C, struct bSound *source) sound->child_sound = source; sound->type = SOUND_TYPE_BUFFER; - sound_load(sound); + sound_load(CTX_data_main(C), sound); if(!sound->playback_handle) { @@ -195,7 +195,7 @@ struct bSound* sound_new_limiter(struct bContext *C, struct bSound *source, floa sound->end = end; sound->type = SOUND_TYPE_LIMITER; - sound_load(sound); + sound_load(CTX_data_main(C), sound); if(!sound->playback_handle) { @@ -236,7 +236,7 @@ void sound_delete_cache(struct bSound* sound) } } -void sound_load(struct bSound* sound) +void sound_load(struct Main *UNUSED(bmain), struct bSound* sound) { if(sound) { @@ -266,6 +266,7 @@ void sound_load(struct bSound* sound) if(sound->id.lib) path = sound->id.lib->filepath; else + // XXX this should be fixed! path = /*bmain ? bmain->name :*/ G.sce; BLI_path_abs(fullpath, path); -- cgit v1.2.3 From 7db9558cf6fc64545dcdb1c0291ec943a10600db Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Oct 2010 02:36:43 +0000 Subject: bugfix [#24291] Error parenting a child with any negative scaling coordinate the bug was in object_apply_mat4(), caused by applying a non-normalized matrix to the rotation. Blender 2.4x also had this problem, surprising nobody noticed!. --- source/blender/blenkernel/intern/object.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 17e488c8353..79030e3adfa 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1698,29 +1698,28 @@ void object_mat3_to_rot(Object *ob, float mat[][3], int use_compat) /* see pchan_apply_mat4() for the equivalent 'pchan' function */ void object_apply_mat4(Object *ob, float mat[][4]) { - float mat3[3][3], tmat[3][3], imat[3][3]; + float mat3[3][3]; /* obmat -> 3x3 */ + float mat3_n[3][3]; /* obmat -> normalized, 3x3 */ + float imat3_n[3][3]; /* obmat -> normalized & inverted, 3x3 */ /* location */ copy_v3_v3(ob->loc, mat[3]); /* rotation */ copy_m3_m4(mat3, mat); - object_mat3_to_rot(ob, mat3, 0); - + /* so scale doesnt interfear with rotation [#24291] */ + normalize_m3_m3(mat3_n, mat3); + + object_mat3_to_rot(ob, mat3_n, 0); + /* scale */ -#if 0 - /* works fine except for neg scales */ - mat4_to_size(ob->size, mat); -#else - /* this is more complicated but works for negative scales */ - object_rot_to_mat3(ob, tmat); - invert_m3_m3(imat, tmat); - mul_m3_m3m3(tmat, imat, mat3); - - ob->size[0]= tmat[0][0]; - ob->size[1]= tmat[1][1]; - ob->size[2]= tmat[2][2]; -#endif + /* note: mat4_to_size(ob->size, mat) fails for negative scale */ + invert_m3_m3(imat3_n, mat3_n); + mul_m3_m3m3(mat3, imat3_n, mat3); + + ob->size[0]= mat3[0][0]; + ob->size[1]= mat3[1][1]; + ob->size[2]= mat3[2][2]; } void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ -- cgit v1.2.3 From 4d37cf90b9d9d8ed2f0339c8ccd72481e29a4514 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Oct 2010 06:41:16 +0000 Subject: remove G.sce, use G.main->name instead. Both stored the filename of the blend file, but G.sce stored the last opened file. This will make blender act differently in some cases since a relative path to the last opened file will no longer resolve (which is correct IMHO since that file isnt open and the path might not even be valid anymore). Tested linking with durian files and rendering to relative paths when no files is loaded however we may need to have some operators give an error if they are used on the default startup.blend. --- source/blender/blenkernel/intern/blender.c | 13 +++++-------- source/blender/blenkernel/intern/customdata.c | 3 ++- source/blender/blenkernel/intern/image.c | 16 ++++++++-------- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/packedFile.c | 6 +++--- source/blender/blenkernel/intern/particle_system.c | 3 ++- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/scene.c | 4 ++-- source/blender/blenkernel/intern/sequencer.c | 12 ++++++------ source/blender/blenkernel/intern/sound.c | 4 ++-- source/blender/blenkernel/intern/text.c | 2 +- source/blender/blenkernel/intern/writeavi.c | 3 ++- source/blender/blenkernel/intern/writeffmpeg.c | 2 +- 13 files changed, 36 insertions(+), 36 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 5fcf3c77d3b..72d194e4d79 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -309,8 +309,8 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) #endif /* these are the same at times, should never copy to the same location */ - if(G.sce != filename) - BLI_strncpy(G.sce, filename, FILE_MAX); + if(G.main->name != filename) + BLI_strncpy(G.main->name, filename, FILE_MAX); BLI_strncpy(G.main->name, filename, FILE_MAX); /* is guaranteed current file */ @@ -410,7 +410,7 @@ int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *report { BlendFileData *bfd; - bfd= BLO_read_from_memfile(CTX_data_main(C), G.sce, memfile, reports); + bfd= BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports); if (bfd) setup_app_data(C, bfd, ""); else @@ -460,14 +460,12 @@ static UndoElem *curundo= NULL; static int read_undosave(bContext *C, UndoElem *uel) { - char scestr[FILE_MAXDIR+FILE_MAXFILE]; /* we should eventually just use G.main->name */ char mainstr[FILE_MAXDIR+FILE_MAXFILE]; int success=0, fileflags; /* This is needed so undoing/redoing doesnt crash with threaded previews going */ WM_jobs_stop_all(CTX_wm_manager(C)); - - strcpy(scestr, G.sce); /* temporal store */ + strcpy(mainstr, G.main->name); /* temporal store */ fileflags= G.fileflags; @@ -479,7 +477,6 @@ static int read_undosave(bContext *C, UndoElem *uel) success= BKE_read_file_from_memfile(C, &uel->memfile, NULL); /* restore */ - strcpy(G.sce, scestr); /* restore */ strcpy(G.main->name, mainstr); /* restore */ G.fileflags= fileflags; @@ -720,7 +717,7 @@ void BKE_undo_save_quit(void) Main *BKE_undo_get_main(Scene **scene) { Main *mainp= NULL; - BlendFileData *bfd= BLO_read_from_memfile(G.main, G.sce, &curundo->memfile, NULL); + BlendFileData *bfd= BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL); if(bfd) { mainp= bfd->main; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 7f91df3b281..9c4f0d790ca 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -48,6 +48,7 @@ #include "BKE_customdata.h" #include "BKE_customdata_file.h" #include "BKE_global.h" +#include "BKE_main.h" #include "BKE_utildefines.h" /* number of layers to add when growing a CustomData object */ @@ -2343,7 +2344,7 @@ int CustomData_verify_versions(struct CustomData *data, int index) static void customdata_external_filename(char filename[FILE_MAX], ID *id, CustomDataExternal *external) { - char *path = (id->lib)? id->lib->filepath: G.sce; + char *path = (id->lib)? id->lib->filepath: G.main->name; BLI_strncpy(filename, external->filename, FILE_MAX); BLI_path_abs(filename, path); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 8ba7cde519d..09622b2acfe 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -338,7 +338,7 @@ Image *BKE_add_image_file(const char *name) char str[FILE_MAX], strtest[FILE_MAX]; BLI_strncpy(str, name, sizeof(str)); - BLI_path_abs(str, G.sce); + BLI_path_abs(str, G.main->name); /* exists? */ file= open(str, O_BINARY|O_RDONLY); @@ -349,7 +349,7 @@ Image *BKE_add_image_file(const char *name) for(ima= G.main->image.first; ima; ima= ima->id.next) { if(ima->source!=IMA_SRC_VIEWER && ima->source!=IMA_SRC_GENERATED) { BLI_strncpy(strtest, ima->name, sizeof(ima->name)); - BLI_path_abs(strtest, G.sce); + BLI_path_abs(strtest, G.main->name); if( strcmp(strtest, str)==0 ) { if(ima->anim==NULL || ima->id.us==0) { @@ -861,8 +861,8 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) if (scene->r.stamp & R_STAMP_FILENAME) { if (G.relbase_valid) { - if (do_prefix) sprintf(stamp_data->file, "File %s", G.sce); - else sprintf(stamp_data->file, "%s", G.sce); + if (do_prefix) sprintf(stamp_data->file, "File %s", G.main->name); + else sprintf(stamp_data->file, "%s", G.main->name); } else { if (do_prefix) strcpy(stamp_data->file, "File "); else strcpy(stamp_data->file, ""); @@ -1311,7 +1311,7 @@ void BKE_makepicstring(char *string, char *base, int frame, int imtype, int use_ { if (string==NULL) return; BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ - BLI_path_abs(string, G.sce); + BLI_path_abs(string, G.main->name); BLI_path_frame(string, frame, 4); if(use_ext) @@ -1609,7 +1609,7 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) if(ima->id.lib) BLI_path_abs(name, ima->id.lib->filepath); else - BLI_path_abs(name, G.sce); + BLI_path_abs(name, G.main->name); flag= IB_rect|IB_multilayer; if(ima->flag & IMA_DO_PREMUL) @@ -1717,7 +1717,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) if(ima->id.lib) BLI_path_abs(str, ima->id.lib->filepath); else - BLI_path_abs(str, G.sce); + BLI_path_abs(str, G.main->name); ima->anim = openanim(str, IB_rect); @@ -1778,7 +1778,7 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) if(ima->id.lib) BLI_path_abs(str, ima->id.lib->filepath); else - BLI_path_abs(str, G.sce); + BLI_path_abs(str, G.main->name); /* read ibuf */ ibuf = IMB_loadiffname(str, flag); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 1e08432c271..dfc82152e8c 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1234,7 +1234,7 @@ static void image_fix_relative_path(Image *ima) if(ima->id.lib==NULL) return; if(strncmp(ima->name, "//", 2)==0) { BLI_path_abs(ima->name, ima->id.lib->filepath); - BLI_path_rel(ima->name, G.sce); + BLI_path_rel(ima->name, G.main->name); } } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 5bbb3506a78..33f1949c5ac 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -179,7 +179,7 @@ PackedFile *newPackedFile(ReportList *reports, char *filename) // convert relative filenames to absolute filenames strcpy(name, filename); - BLI_path_abs(name, G.sce); + BLI_path_abs(name, G.main->name); // open the file // and create a PackedFile structure @@ -274,7 +274,7 @@ int writePackedFile(ReportList *reports, char *filename, PackedFile *pf, int gui if (guimode) {} //XXX waitcursor(1); strcpy(name, filename); - BLI_path_abs(name, G.sce); + BLI_path_abs(name, G.main->name); if (BLI_exists(name)) { for (number = 1; number <= 999; number++) { @@ -339,7 +339,7 @@ int checkPackedFile(char *filename, PackedFile *pf) char name[FILE_MAXDIR + FILE_MAXFILE]; strcpy(name, filename); - BLI_path_abs(name, G.sce); + BLI_path_abs(name, G.main->name); if (stat(name, &st)) { ret_val = PF_NOFILE; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 8ab4117c8a1..71ec1114848 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -63,6 +63,7 @@ #include "BLI_listbase.h" #include "BLI_threads.h" +#include "BKE_main.h" #include "BKE_animsys.h" #include "BKE_boids.h" #include "BKE_cdderivedmesh.h" @@ -3607,7 +3608,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) // ok, start loading strcpy(filename, fss->surfdataPath); strcat(filename, suffix); - BLI_path_abs(filename, G.sce); + BLI_path_abs(filename, G.main->name); BLI_path_frame(filename, curFrame, 0); // fixed #frame-no strcat(filename, suffix2); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 3896d523b11..37d2b103ef0 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1085,7 +1085,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup static int ptcache_path(PTCacheID *pid, char *filename) { Library *lib= (pid->ob)? pid->ob->id.lib: NULL; - const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.sce; + const char *blendfilename= (lib && (pid->cache->flag & PTCACHE_IGNORE_LIBPATH)==0) ? lib->filepath: G.main->name; size_t i; if(pid->cache->flag & PTCACHE_EXTERNAL) { diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index fde180cadc6..e399e0bb83d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -566,11 +566,11 @@ Scene *set_scene_name(Main *bmain, char *name) Scene *sce= (Scene *)find_id("SC", name); if(sce) { set_scene_bg(bmain, sce); - printf("Scene switch: '%s' in file: '%s'\n", name, G.sce); + printf("Scene switch: '%s' in file: '%s'\n", name, G.main->name); return sce; } - printf("Can't find scene: '%s' in file: '%s'\n", name, G.sce); + printf("Can't find scene: '%s' in file: '%s'\n", name, G.main->name); return NULL; } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 6d087837302..21b7cfd010c 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -579,7 +579,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) if (seq->type != SEQ_SCENE && seq->type != SEQ_META && seq->type != SEQ_IMAGE) { BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(str, G.sce); + BLI_path_abs(str, G.main->name); } if (seq->type == SEQ_IMAGE) { @@ -1044,7 +1044,7 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { BLI_join_dirfile(name, dir, seq->strip->proxy->file); - BLI_path_abs(name, G.sce); + BLI_path_abs(name, G.main->name); return TRUE; } @@ -1071,7 +1071,7 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c render_size); } - BLI_path_abs(name, G.sce); + BLI_path_abs(name, G.main->name); BLI_path_frame(name, frameno, 0); @@ -2002,7 +2002,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float if(ibuf == 0 && s_elem) { BLI_join_dirfile(name, seq->strip->dir, s_elem->name); - BLI_path_abs(name, G.sce); + BLI_path_abs(name, G.main->name); ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); } @@ -2038,7 +2038,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float BLI_join_dirfile(name, seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(name, G.sce); + BLI_path_abs(name, G.main->name); seq->anim = openanim( name, IB_rect | @@ -3492,7 +3492,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo struct anim *an; BLI_strncpy(path, seq_load->path, sizeof(path)); - BLI_path_abs(path, G.sce); + BLI_path_abs(path, G.main->name); an = openanim(path, IB_rect); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 5c3047942f7..cc941c81131 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -131,7 +131,7 @@ struct bSound* sound_new_file(struct Main *bmain, char* filename) strcpy(str, filename); - path = /*bmain ? bmain->name :*/ G.sce; + path = /*bmain ? bmain->name :*/ G.main->name; BLI_path_abs(str, path); @@ -267,7 +267,7 @@ void sound_load(struct Main *UNUSED(bmain), struct bSound* sound) path = sound->id.lib->filepath; else // XXX this should be fixed! - path = /*bmain ? bmain->name :*/ G.sce; + path = /*bmain ? bmain->name :*/ G.main->name; BLI_path_abs(fullpath, path); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 19bc853276a..bb1a1a88a09 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -241,7 +241,7 @@ int reopen_text(Text *text) if (!text || !text->name) return 0; BLI_strncpy(str, text->name, FILE_MAXDIR+FILE_MAXFILE); - BLI_path_abs(str, G.sce); + BLI_path_abs(str, G.main->name); fp= fopen(str, "r"); if(fp==NULL) return 0; diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 8363ff13ef9..de708f216fd 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -40,6 +40,7 @@ #include "BLI_blenlib.h" #include "BKE_global.h" +#include "BKE_main.h" #include "BKE_report.h" #include "BKE_utildefines.h" #include "BKE_writeavi.h" @@ -119,7 +120,7 @@ static void filepath_avi (char *string, RenderData *rd) if (string==NULL) return; strcpy(string, rd->pic); - BLI_path_abs(string, G.sce); + BLI_path_abs(string, G.main->name); BLI_make_existing_file(string); diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 473c10d6ced..ec998e68e00 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -857,7 +857,7 @@ void filepath_ffmpeg(char* string, RenderData* rd) { if (!string || !exts) return; strcpy(string, rd->pic); - BLI_path_abs(string, G.sce); + BLI_path_abs(string, G.main->name); BLI_make_existing_file(string); -- cgit v1.2.3 From 9bd94eebc4d240203b89c7a0a3dfe800859ca636 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Mon, 18 Oct 2010 07:24:08 +0000 Subject: _DEBUG -> DEBUG --- source/blender/blenkernel/intern/writeffmpeg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index ec998e68e00..aae26da02dd 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -19,7 +19,7 @@ #include #include -#if defined(_WIN32) && defined(_DEBUG) && !defined(__MINGW32__) && !defined(__CYGWIN__) +#if defined(_WIN32) && defined(DEBUG) && !defined(__MINGW32__) && !defined(__CYGWIN__) /* This does not seem necessary or present on MSVC 8, but may be needed in earlier versions? */ #if _MSC_VER < 1400 #include -- cgit v1.2.3 From c092a18fcbfead6ed2936c74f504ece9f08e96d2 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 18 Oct 2010 08:17:04 +0000 Subject: [#24209] Texture Forcefields: Use Object Coordinates produces incorrect results (patch included) * Original patch provided by Alexander Beels and modified a bit by me. --- source/blender/blenkernel/intern/effect.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index f4fae3ed3c6..70e814ef956 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -264,6 +264,9 @@ static void add_object_to_effectors(ListBase **effectors, Scene *scene, Effector eff = new_effector_cache(scene, ob, NULL, ob->pd); + /* make sure imat is up to date */ + invert_m4_m4(ob->imat, ob->obmat); + BLI_addtail(*effectors, eff); } static void add_particles_to_effectors(ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src) @@ -774,7 +777,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP } if(eff->pd->flag & PFIELD_TEX_OBJECT) { - mul_m4_v3(eff->ob->obmat, tex_co); + mul_m4_v3(eff->ob->imat, tex_co); } hasrgb = multitex_ext(eff->pd->tex, tex_co, NULL,NULL, 0, result); -- cgit v1.2.3 From 58683fa993e11d7bf888050e359b864f865d7c41 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 18 Oct 2010 11:21:22 +0000 Subject: enable DEBUG define in CMake and scons, also change booleans debug option to BOP_DEBUG, which was used inconsistently, and had to add a define for superlu. --- 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 79030e3adfa..5237335e8ca 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1708,7 +1708,7 @@ void object_apply_mat4(Object *ob, float mat[][4]) /* rotation */ copy_m3_m4(mat3, mat); /* so scale doesnt interfear with rotation [#24291] */ - normalize_m3_m3(mat3_n, mat3); + normalize_m3_m3(mat3_n, (const float(*)[3])mat3); object_mat3_to_rot(ob, mat3_n, 0); -- cgit v1.2.3 From 106867910ea09fa63b04480dc83b20d67bdb4e09 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Oct 2010 01:21:22 +0000 Subject: use unsigned int for all layers. --- source/blender/blenkernel/intern/anim.c | 6 ++++-- source/blender/blenkernel/intern/object.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 7b52d9c586a..a4e791aa6b3 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -843,7 +843,8 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl GroupObject * go = NULL; EditMesh *em; float vec[3], no[3], pmat[4][4]; - int lay, totvert, a, oblay; + int totvert, a, oblay; + unsigned int lay; copy_m4_m4(pmat, par->obmat); @@ -1153,8 +1154,9 @@ static void new_particle_duplilist(ListBase *lb, ID *UNUSED(id), Scene *scene, O float ctime, pa_time, scale = 1.0f; float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size=0.0; float (*obmat)[4], (*oldobmat)[4]; - int lay, a, b, counter, hair = 0; + int a, b, counter, hair = 0; int totpart, totchild, totgroup=0, pa_num; + unsigned int lay; if(psys==0) return; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 5237335e8ca..b91a66fd69f 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1476,7 +1476,7 @@ static void armature_set_id_extern(Object *ob) { bArmature *arm= ob->data; bPoseChannel *pchan; - int lay= arm->layer_protected; + unsigned int lay= arm->layer_protected; for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { if(!(pchan->bone->layer & lay)) -- cgit v1.2.3 From 0aa2eee3eff83cc4a6160a292219b20ac579481a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Oct 2010 05:36:16 +0000 Subject: bugfix with applying the object matrix with negative scales. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fixes report by ronan ducluzeau Scale default cube on X axis to -1. Rotate it on X axis to 33°. Parent cube to lamp. Clear parent and keep offset. Cube's scaling value on X axis pass from -1 to 1 Cube's rotation value on Z axis pass from 0° to 180° --- source/blender/blenkernel/intern/object.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index b91a66fd69f..142e41918dd 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1704,12 +1704,18 @@ void object_apply_mat4(Object *ob, float mat[][4]) /* location */ copy_v3_v3(ob->loc, mat[3]); - - /* rotation */ + + /* rotation & scale are linked, we need to create the mat's + * for these together since they are related. */ copy_m3_m4(mat3, mat); /* so scale doesnt interfear with rotation [#24291] */ normalize_m3_m3(mat3_n, (const float(*)[3])mat3); + if(mat3_n[0][0] < 0.0f) negate_v3(mat3_n[0]); + if(mat3_n[1][1] < 0.0f) negate_v3(mat3_n[1]); + if(mat3_n[2][2] < 0.0f) negate_v3(mat3_n[2]); + + /* rotation */ object_mat3_to_rot(ob, mat3_n, 0); /* scale */ -- cgit v1.2.3 From ff5cbabffd4d1bcfc8ff1c110e7f9d6d74c94f54 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 19 Oct 2010 10:26:53 +0000 Subject: Fix for [#24313] Displacement modifier is not respecting animated texture channels. --- source/blender/blenkernel/intern/texture.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 77416f4dd12..da3dea37220 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1337,13 +1337,11 @@ int BKE_texture_dependsOnTime(const struct Tex *texture) else if( texture->ima && ELEM(texture->ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { return 1; - } -#if 0 // XXX old animation system - else if(texture->ipo) { - // assume any ipo means the texture is animated + } + else if(texture->adt) { + // assume anything in adt means the texture is animated return 1; } -#endif // XXX old animation system return 0; } -- cgit v1.2.3 From 5f2764d84929bd20787e8ee356689f24a24a5210 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 19 Oct 2010 11:51:31 +0000 Subject: Fix for [#24299] Changing Curves on rendered Pass scewes pass up seriously ;-) * The number of pass channels wasn't taken properly into account when applying curves. --- 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 83ed65a1bf2..2d4e0ac8c08 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -869,7 +869,7 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) if(ibuf->channels) stride= ibuf->channels; - for(pixel= ibuf->x*ibuf->y; pixel>0; pixel--, pix_in+=stride, pix_out+=4) { + for(pixel= ibuf->x*ibuf->y; pixel>0; pixel--, pix_in+=stride, pix_out+=stride) { if(stride<3) { col[0]= curvemap_evaluateF(cumap->cm, *pix_in); -- cgit v1.2.3 From d1fe2dd9676eceab9ece337cb478c312d3c5c1aa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 19 Oct 2010 12:21:57 +0000 Subject: bugfix [#24309] Reloading file with incorrect path location. the cu->ctime was never set if the frame wasnt changed, so adding a curve and parenting could be done without a frame change leaving the cu->ctime value at zero. changing the frame or rendering after this would make the parent relationship jump. Set the curve->ctime in object_handle_update(), this way its set on file load and when linking in new curves. Another option is to do this when parenting but probably this would miss other cases where its needed. --- source/blender/blenkernel/intern/object.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 142e41918dd..1d7d5b6e243 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2560,6 +2560,12 @@ void object_handle_update(Scene *scene, Object *ob) makeDispListMBall(scene, ob); } else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { + if(ob->type==OB_CURVE) { + /* cu->ctime is set on frame change but this is not enough when + * adding new curves, appending etc. This assignment could be moved + * but this ensures its always set esp before parenting: [#24309] */ + ((Curve *)ob->data)->ctime= ctime; + } makeDispListCurveTypes(scene, ob, 0); } else if(ELEM(ob->type, OB_CAMERA, OB_LAMP)) { -- cgit v1.2.3 From 7110a4a288bed770ce03534e4508e05e7e1e2d78 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Wed, 20 Oct 2010 01:17:18 +0000 Subject: == Sculpt == Fixed bug #22634, sculpting/multires and wireframe display mode glitches * Changed ccgdm edge drawing to always use face griddata rather than edge data, since edge data is not updated during sculpting. --- source/blender/blenkernel/intern/subsurf_ccg.c | 73 +++++++++++--------------- 1 file changed, 32 insertions(+), 41 deletions(-) (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 26bd981db4a..4b810059464 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1146,71 +1146,62 @@ static void ccgDM_drawVerts(DerivedMesh *dm) { ccgFaceIterator_free(fi); glEnd(); } + static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(drawAllEdges)) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; - CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); - int i, edgeSize = ccgSubSurf_getEdgeSize(ss); int gridSize = ccgSubSurf_getGridSize(ss); + int start, end, step; int useAging; ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL); - for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) { - CCGEdge *e = ccgEdgeIterator_getCurrent(ei); - DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); - - if (!drawLooseEdges && !ccgSubSurf_getEdgeNumFaces(e)) - continue; - - if (useAging && !(G.f&G_BACKBUFSEL)) { - int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4; - glColor3ub(0, ageCol>0?ageCol:0, 0); - } - - glBegin(GL_LINE_STRIP); - for (i=0; idrawInteriorEdges) + return; if (useAging && !(G.f&G_BACKBUFSEL)) { glColor3ub(0, 0, 0); } - if (ccgdm->drawInteriorEdges) { - for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { - CCGFace *f = ccgFaceIterator_getCurrent(fi); - int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); + if(drawLooseEdges) { + start = 0; + end = gridSize; + step = gridSize - 1; + } + else if(ccgdm->drawInteriorEdges) { + start = 1; + end = gridSize - 1; + step = 1; + } + + if(drawLooseEdges && ccgdm->drawInteriorEdges) + step = 1; - for (S=0; S Date: Wed, 20 Oct 2010 09:18:55 +0000 Subject: [#24267] Hook fails after Solidify Solidify modifier wasn't assigning origindex values. - BLI_math.h array functions: range_vni(), mul_vn_fl(), mul_vn_vn_fl(), add_vn_vn(), fill_vni(). - define 'AT' as __FILE__ ":" STRINGIFY(__LINE__), useful for quick debug prints. --- source/blender/blenkernel/intern/DerivedMesh.c | 10 +++------- source/blender/blenkernel/intern/cdderivedmesh.c | 2 ++ 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 2e8922dec1b..c213a5a4ce2 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1840,17 +1840,13 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos /* constructive modifiers need to have an origindex * otherwise they wont have anywhere to copy the data from */ if(needMapping) { - int *index, i; DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); DM_add_face_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); - index = DM_get_vert_data_layer(dm, CD_ORIGINDEX); - for(i=0; inumVertData; i++) *index++= i; - index = DM_get_edge_data_layer(dm, CD_ORIGINDEX); - for(i=0; inumEdgeData; i++) *index++= i; - index = DM_get_face_data_layer(dm, CD_ORIGINDEX); - for(i=0; inumFaceData; i++) *index++= i; + range_vni(DM_get_vert_data_layer(dm, CD_ORIGINDEX), dm->numVertData, 0); + range_vni(DM_get_edge_data_layer(dm, CD_ORIGINDEX), dm->numEdgeData, 0); + range_vni(DM_get_face_data_layer(dm, CD_ORIGINDEX), dm->numFaceData, 0); } } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index eb895d62f17..20987e15c4d 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1686,6 +1686,8 @@ DerivedMesh *CDDM_copy(DerivedMesh *source) return dm; } +/* note, the CD_ORIGINDEX layers are all 0, so if there is a direct + * relationship betwen mesh data this needs to be set by the caller. */ DerivedMesh *CDDM_from_template(DerivedMesh *source, int numVerts, int numEdges, int numFaces) { -- cgit v1.2.3 From 1998fa59ae90c2346910dc622df0356a8644c28f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 20 Oct 2010 13:51:37 +0000 Subject: fix for fix [#24336] evaluation time - curve has no effect committed r32598 to fix [#24309] Reloading file with incorrect path location. Setting the curves ctime when updating the object data overrode the animated value. For now just set the ctime on newly added curves with will work as the user expects in most cases. This is weak design IMHO because the ctime value can be set to anything but is reset on changing frames even if its not keyed. With curves created via python or linked in this can still result in a bad ctime value. --- source/blender/blenkernel/intern/object.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 1d7d5b6e243..142e41918dd 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2560,12 +2560,6 @@ void object_handle_update(Scene *scene, Object *ob) makeDispListMBall(scene, ob); } else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - if(ob->type==OB_CURVE) { - /* cu->ctime is set on frame change but this is not enough when - * adding new curves, appending etc. This assignment could be moved - * but this ensures its always set esp before parenting: [#24309] */ - ((Curve *)ob->data)->ctime= ctime; - } makeDispListCurveTypes(scene, ob, 0); } else if(ELEM(ob->type, OB_CAMERA, OB_LAMP)) { -- cgit v1.2.3 From 16b04834b3e1046118787d40531bf38f73ec9c76 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Oct 2010 01:08:12 +0000 Subject: improved fix for [#24267] Hook fails after Solidify Rather then have the modifier calculate ORIGINDEX weather its needed or not (incorrect if it wasn't the first modifier on the stack), create ORIGINDEX layer initially if any of the modifiers use it. This way hook also works after Mirror and Screw modifiers which have the ORIGINDEX layer copied implicitly with DM_copy_vert_data(). This wasn't possible to check for before because this flag was always enabled so it would be passed to DM_set_only_copy(). Now just add the flag whenever calling DM_set_only_copy(). --- source/blender/blenkernel/intern/DerivedMesh.c | 41 ++++++++++++++------------ 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c213a5a4ce2..3d87b77dec9 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1693,9 +1693,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos if(useRenderParams) required_mode = eModifierMode_Render; else required_mode = eModifierMode_Realtime; - /* we always want to keep original indices */ - dataMask |= CD_MASK_ORIGINDEX; - datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode); curr = datamasks; @@ -1816,6 +1813,12 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } else { DerivedMesh *ndm; + /* determine which data layers are needed by following modifiers */ + if(curr->next) + nextmask= (CustomDataMask)GET_INT_FROM_POINTER(curr->next->link); + else + nextmask= dataMask; + /* apply vertex coordinates or build a DerivedMesh as necessary */ if(dm) { if(deformedVerts) { @@ -1837,9 +1840,15 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos if((dataMask & CD_MASK_WEIGHT_MCOL) && (ob->mode & OB_MODE_WEIGHT_PAINT)) add_weight_mcol_dm(ob, dm); - /* constructive modifiers need to have an origindex - * otherwise they wont have anywhere to copy the data from */ - if(needMapping) { + /* Constructive modifiers need to have an origindex + * otherwise they wont have anywhere to copy the data from. + * + * Also create ORIGINDEX data if any of the following modifiers + * requests it, this way Mirror, Solidify etc will keep ORIGINDEX + * data by using generic DM_copy_vert_data() functions. + */ + if(needMapping || (nextmask & CD_MASK_ORIGINDEX)) { + /* calc */ DM_add_vert_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); DM_add_edge_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); DM_add_face_layer(dm, CD_ORIGINDEX, CD_CALLOC, NULL); @@ -1850,11 +1859,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } } - /* determine which data layers are needed by following modifiers */ - if(curr->next) - nextmask= (CustomDataMask)GET_INT_FROM_POINTER(curr->next->link); - else - nextmask= dataMask; /* set the DerivedMesh to only copy needed data */ mask= (CustomDataMask)GET_INT_FROM_POINTER(curr->link); @@ -1891,7 +1895,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos orcodm= create_orco_dm(ob, me, NULL, CD_ORCO); nextmask &= ~CD_MASK_ORCO; - DM_set_only_copy(orcodm, nextmask); + DM_set_only_copy(orcodm, nextmask | CD_MASK_ORIGINDEX); ndm = mti->applyModifier(md, ob, orcodm, useRenderParams, 0); if(ndm) { @@ -1907,7 +1911,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos clothorcodm= create_orco_dm(ob, me, NULL, CD_CLOTH_ORCO); nextmask &= ~CD_MASK_CLOTH_ORCO; - DM_set_only_copy(clothorcodm, nextmask); + DM_set_only_copy(clothorcodm, nextmask | CD_MASK_ORIGINDEX); ndm = mti->applyModifier(md, ob, clothorcodm, useRenderParams, 0); if(ndm) { @@ -2025,9 +2029,6 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri dm = NULL; md = modifiers_getVirtualModifierList(ob); - - /* we always want to keep original indices */ - dataMask |= CD_MASK_ORIGINDEX; datamasks = modifiers_calcDataMasks(scene, ob, md, dataMask, required_mode); @@ -2106,7 +2107,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri orcodm= create_orco_dm(ob, ob->data, em, CD_ORCO); mask &= ~CD_MASK_ORCO; - DM_set_only_copy(orcodm, mask); + DM_set_only_copy(orcodm, mask | CD_MASK_ORIGINDEX); if (mti->applyModifierEM) ndm = mti->applyModifierEM(md, ob, em, orcodm); @@ -2121,9 +2122,11 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri } /* set the DerivedMesh to only copy needed data */ - DM_set_only_copy(dm, (CustomDataMask)GET_INT_FROM_POINTER(curr->link)); + mask= (CustomDataMask)GET_INT_FROM_POINTER(curr->link); /* CD_MASK_ORCO may have been cleared above */ - if(((CustomDataMask)GET_INT_FROM_POINTER(curr->link)) & CD_MASK_ORIGSPACE) + DM_set_only_copy(dm, mask | CD_MASK_ORIGINDEX); + + if(mask & CD_MASK_ORIGSPACE) if(!CustomData_has_layer(&dm->faceData, CD_ORIGSPACE)) DM_add_face_layer(dm, CD_ORIGSPACE, CD_DEFAULT, NULL); -- cgit v1.2.3 From fec8292df190c2a38623823bec0b1b78867b1017 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Oct 2010 01:10:22 +0000 Subject: remove unused args for some modifiers, no functional change. --- source/blender/blenkernel/intern/cloth.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenkernel/intern/smoke.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index e7e94c407f1..f1b167b38c7 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -423,7 +423,7 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul /************************************************ * clothModifier_do - main simulation function ************************************************/ -DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) +DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, DerivedMesh *dm) { DerivedMesh *result; PointCache *cache; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 71ec1114848..34abe45981c 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3260,7 +3260,7 @@ static void do_hair_dynamics(ParticleSimulationData *sim) psys->clmd->point_cache = psys->pointcache; psys->clmd->sim_parms->effector_weights = psys->part->effector_weights; - psys->hair_out_dm = clothModifier_do(psys->clmd, sim->scene, sim->ob, dm, 0, 0); + psys->hair_out_dm = clothModifier_do(psys->clmd, sim->scene, sim->ob, dm); psys->clmd->sim_parms->effector_weights = NULL; } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index d1eed94d330..a7e664bf2bf 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1270,7 +1270,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) } } } -void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) +void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm) { if((smd->type & MOD_SMOKE_TYPE_FLOW)) { -- cgit v1.2.3 From 98621570877f884e5fa178268d68cbcfd21d585d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Oct 2010 04:21:09 +0000 Subject: fix for fix [#24344] crash on adding new image when composite is open and there is no Nodetree also use const prefix in solidify modifier where possible. --- source/blender/blenkernel/intern/node.c | 2 +- 1 file changed, 1 insertion(+), 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 cb98c2282bc..6b53e538f8e 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1803,7 +1803,7 @@ int NodeTagIDChanged(bNodeTree *ntree, ID *id) { int change = FALSE; - if(id==NULL) + if(ELEM(NULL, id, ntree)) return change; if(ntree->type==NTREE_COMPOSIT) { -- cgit v1.2.3 From ec6b9948ace08c3925486a009147af2fe0a6e4f0 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Thu, 21 Oct 2010 07:29:15 +0000 Subject: Include BLI_math.h instead of math.h. Silence a warning. --- source/blender/blenkernel/intern/unit.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 25aab77ba9b..83ace49eb67 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -26,11 +26,7 @@ #include #include "BKE_unit.h" -#ifdef WIN32 -#define _USE_MATH_DEFINES -#endif -#include - +#include "BLI_math.h" #include "BLI_winstuff.h" @@ -687,7 +683,7 @@ void bUnit_ToUnitAltName(char *str, int len_max, char *orig_str, int system, int found= unit_find_str(orig_str, unit->name_short); if(found) { - int offset= found - orig_str; + int offset= (int)(found - orig_str); int len_name= 0; /* copy everything before the unit */ -- cgit v1.2.3 From 107b274fb8e43246054348733ff32bb38f742eba Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Thu, 21 Oct 2010 07:39:18 +0000 Subject: Enable /WX in blenkernel Silence warnings --- source/blender/blenkernel/intern/writeffmpeg.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index aae26da02dd..30a804be637 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1058,6 +1058,8 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int IDPropertyTemplate val; int idp_type; char name[256]; + + val.i = 0; avcodec_get_context_defaults(&c); @@ -1065,8 +1067,6 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int parent = c.av_class->option + parent_index; if (!rd->ffcodecdata.properties) { - IDPropertyTemplate val; - rd->ffcodecdata.properties = IDP_New(IDP_GROUP, val, "ffmpeg"); } @@ -1075,8 +1075,6 @@ IDProperty *ffmpeg_property_add(RenderData *rd, char * type, int opt_index, int rd->ffcodecdata.properties, (char*) type); if (!group) { - IDPropertyTemplate val; - group = IDP_New(IDP_GROUP, val, (char*) type); IDP_AddToGroup(rd->ffcodecdata.properties, group); } -- cgit v1.2.3 From c9d16d0ddb01c06bddbb5178ad1ae4829d8ab7ab Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Thu, 21 Oct 2010 08:32:53 +0000 Subject: /WX enabled for MSVC in CMake too. Warning fixes. --- source/blender/blenkernel/intern/cloth.c | 11 ++++++----- source/blender/blenkernel/intern/collision.c | 14 +++++++------- source/blender/blenkernel/intern/colortools.c | 3 ++- source/blender/blenkernel/intern/fmodifier.c | 6 +++--- source/blender/blenkernel/intern/implicit.c | 12 ++++++------ source/blender/blenkernel/intern/ipo.c | 4 ++-- source/blender/blenkernel/intern/multires.c | 11 ++++++----- source/blender/blenkernel/intern/sequencer.c | 4 +--- source/blender/blenkernel/intern/text.c | 4 ++-- source/blender/blenkernel/intern/writeffmpeg.c | 2 +- 10 files changed, 36 insertions(+), 35 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index f1b167b38c7..f8772cd802f 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -385,7 +385,8 @@ static int do_step_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul Cloth *cloth; ListBase *effectors = NULL; MVert *mvert; - int i, ret = 0; + unsigned int i = 0; + int ret = 0; /* simulate 1 frame forward */ cloth = clmd->clothObject; @@ -1044,10 +1045,10 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) Cloth *cloth = clmd->clothObject; ClothSpring *spring = NULL, *tspring = NULL, *tspring2 = NULL; unsigned int struct_springs = 0, shear_springs=0, bend_springs = 0; - int i = 0; - int numverts = dm->getNumVerts ( dm ); - int numedges = dm->getNumEdges ( dm ); - int numfaces = dm->getNumFaces ( dm ); + unsigned int i = 0; + unsigned int numverts = (unsigned int)dm->getNumVerts ( dm ); + unsigned int numedges = (unsigned int)dm->getNumEdges ( dm ); + unsigned int numfaces = (unsigned int)dm->getNumFaces ( dm ); MEdge *medge = CDDM_get_edges ( dm ); MFace *mface = CDDM_get_faces ( dm ); int index2 = 0; // our second vertex index diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 5c9cc441b95..62b587029e1 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -83,7 +83,7 @@ BVHTree *bvhtree_build_from_mvert ( MFace *mfaces, unsigned int numfaces, MVert { BVHTree *tree; float co[12]; - int i; + unsigned int i; MFace *tface = mfaces; tree = BLI_bvhtree_new ( numfaces*2, epsilon, 4, 26 ); @@ -1342,12 +1342,12 @@ static void add_collision_object(Object ***objs, int *numobj, int *maxobj, Objec // return all collision objects in scene // collision object will exclude self -Object **get_collisionobjects(Scene *scene, Object *self, Group *group, int *numcollobj) +Object **get_collisionobjects(Scene *scene, Object *self, Group *group, unsigned int *numcollobj) { Base *base; Object **objs; GroupObject *go; - int numobj= 0, maxobj= 100; + unsigned int numobj= 0, maxobj= 100; objs= MEM_callocN(sizeof(Object *)*maxobj, "CollisionObjectsArray"); @@ -1503,12 +1503,12 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl { Cloth *cloth= clmd->clothObject; BVHTree *cloth_bvh= cloth->bvhtree; - int i=0, numfaces = 0, numverts = 0, k, l, j; + unsigned int i=0, numfaces = 0, numverts = 0, k, l, j; int rounds = 0; // result counts applied collisions; ic is for debug output; ClothVertex *verts = NULL; int ret = 0, ret2 = 0; Object **collobjs = NULL; - int numcollobj = 0; + unsigned int numcollobj = 0; if ((clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_COLLOBJ) || cloth_bvh==NULL) return 0; @@ -1605,11 +1605,11 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl //////////////////////////////////////////////////////////// if ( clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_SELF ) { - for(l = 0; l < clmd->coll_parms->self_loop_count; l++) + for(l = 0; l < (unsigned int)clmd->coll_parms->self_loop_count; l++) { // TODO: add coll quality rounds again BVHTreeOverlap *overlap = NULL; - int result = 0; + unsigned int result = 0; // collisions = 1; verts = cloth->verts; // needed for openMP diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 2d4e0ac8c08..86d7cbf0133 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -1004,7 +1004,8 @@ DO_INLINE void save_sample_line(Scopes *scopes, const int idx, const float fx, f void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) { - int x, y, c, n, nl; + int x, y, c; + unsigned int n, nl; double div, divl; float *rf=NULL; unsigned char *rc=NULL; diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 6660442b14a..c900f178ca7 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -146,7 +146,7 @@ static void fcm_generator_verify (FModifier *fcm) nc= MEM_callocN(sizeof(float)*(data->poly_order+1), "FMod_Generator_Coefs"); if (data->coefficients) { - if (data->arraysize > (data->poly_order+1)) + if ((int)data->arraysize > (data->poly_order+1)) memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order+1)); else memcpy(nc, data->coefficients, sizeof(float)*data->arraysize); @@ -172,7 +172,7 @@ static void fcm_generator_verify (FModifier *fcm) nc= MEM_callocN(sizeof(float)*(data->poly_order*2), "FMod_Generator_Coefs"); if (data->coefficients) { - if (data->arraysize > (data->poly_order * 2)) + if (data->arraysize > (unsigned int)(data->poly_order * 2)) memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order * 2)); else memcpy(nc, data->coefficients, sizeof(float)*data->arraysize); @@ -240,7 +240,7 @@ static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float * unsigned int i; /* for each coefficient pair, solve for that bracket before accumulating in value by multiplying */ - for (cp=data->coefficients, i=0; (cp) && (i < data->poly_order); cp+=2, i++) + for (cp=data->coefficients, i=0; (cp) && (i < (unsigned int)data->poly_order); cp+=2, i++) value *= (cp[0]*evaltime + cp[1]); /* only if something changed, write *cvalue in one go */ diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index e0077ec7d26..6ca95752887 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1425,7 +1425,7 @@ typedef struct HairGridVert { by Lena Petrovic, Mark Henne and John Anderson * Pixar Technical Memo #06-08, Pixar Animation Studios */ -static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVector *lV, int numverts) +static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVector *lX, lfVector *lV, unsigned int numverts) { /* TODO: This is an initial implementation and should be made much better in due time. * What should at least be implemented is a grid size parameter and a smoothing kernel @@ -1441,10 +1441,10 @@ static void hair_velocity_smoothing(ClothModifierData *clmd, lfVector *lF, lfVec /* 2.0f is an experimental value that seems to give good results */ float smoothfac = 2.0f * clmd->sim_parms->velocity_smooth; float collfac = 2.0f * clmd->sim_parms->collider_friction; - int v = 0; - int i = 0; - int j = 0; - int k = 0; + unsigned int v = 0; + unsigned int i = 0; + int j = 0; + int k = 0; INIT_MINMAX(gmin, gmax); @@ -1559,7 +1559,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec { /* Collect forces and derivatives: F,dFdX,dFdV */ Cloth *cloth = clmd->clothObject; - int i = 0; + unsigned int i = 0; float spring_air = clmd->sim_parms->Cvi * 0.01f; /* viscosity of air scaled in percent */ float gravity[3] = {0.0f, 0.0f, 0.0f}; float tm2[3][3] = {{-spring_air,0,0}, {0,-spring_air,0},{0,0,-spring_air}}; diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 846592f0f2f..b6a6607e062 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1123,7 +1123,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * { AdrBit2Path *abp; FCurve *fcu; - int i=0, totbits; + unsigned int i=0, totbits; /* allocate memory for a new F-Curve */ fcu= MEM_callocN(sizeof(FCurve), "FCurve"); @@ -1174,7 +1174,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * abp= adrcode_bitmaps_to_paths(icu->blocktype, icu->adrcode, &totbits); if (abp && totbits) { FCurve *fcurve; - int b; + unsigned int b; if (G.f & G_DEBUG) printf("\tconvert bitflag ipocurve, totbits = %d \n", totbits); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index b0ab947d478..91f15d1ee6c 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1158,18 +1158,19 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) MultiresLevel *lvl, *lvl1; Multires *mr= me->mr; MVert *vsrc, *vdst; - int src, dst; + unsigned int src, dst; int st = multires_side_tot[totlvl - 1] - 1; int extedgelen = multires_side_tot[totlvl] - 2; int *vvmap; // inorder for dst, map to src int crossedgelen; - int i, j, s, x, totvert, tottri, totquad; + int s, x, tottri, totquad; + unsigned int i, j, totvert; src = 0; dst = 0; vsrc = mr->verts; vdst = dm->getVertArray(dm); - totvert = dm->getNumVerts(dm); + totvert = (unsigned int)dm->getNumVerts(dm); vvmap = MEM_callocN(sizeof(int) * totvert, "multires vvmap"); lvl1 = mr->levels.first; @@ -1260,7 +1261,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) fmem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires fmem"); emem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires emem"); lvl = lvl1; - for(i = 0; i < mr->level_count - 1; ++i) { + for(i = 0; i < (unsigned int)mr->level_count - 1; ++i) { create_old_vert_face_map(fmap + i, fmem + i, lvl->faces, lvl->totvert, lvl->totface); create_old_vert_edge_map(emap + i, emem + i, lvl->edges, lvl->totvert, lvl->totedge); lvl = lvl->next; @@ -1297,7 +1298,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) lvl = lvl->next; - for(i = 0; i < mr->level_count - 1; ++i) { + for(i = 0; i < (unsigned int)(mr->level_count - 1); ++i) { MEM_freeN(fmap[i]); MEM_freeN(fmem[i]); MEM_freeN(emap[i]); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 21b7cfd010c..5950a4630b7 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -62,8 +62,6 @@ #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" - - #include "BKE_context.h" #include "BKE_sound.h" #include "AUD_C-API.h" @@ -3219,7 +3217,7 @@ void seq_offset_animdata(Scene *scene, Sequence *seq, int ofs) for (fcu= scene->adt->action->curves.first; fcu; fcu= fcu->next) { if(strstr(fcu->rna_path, "sequence_editor.sequences_all[") && strstr(fcu->rna_path, str)) { - int i; + unsigned int i; for (i = 0; i < fcu->totvert; i++) { BezTriple *bezt= &fcu->bezt[i]; bezt->vec[0][0] += ofs; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index bb1a1a88a09..cb3c0c08cc0 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -991,8 +991,8 @@ void txt_move_to (Text *text, unsigned int line, unsigned int ch, short sel) if ((*linep)->next) *linep= (*linep)->next; else break; } - if (ch>(*linep)->len) - ch= (*linep)->len; + if (ch>(unsigned int)((*linep)->len)) + ch= (unsigned int)((*linep)->len); *charp= ch; if(!sel) txt_pop_sel(text); diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 30a804be637..0ec38a035aa 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -955,7 +955,7 @@ int append_ffmpeg(RenderData *rd, int frame, int *pixels, int rectx, int recty, void end_ffmpeg(void) { - int i; + unsigned int i; fprintf(stderr, "Closing ffmpeg...\n"); -- cgit v1.2.3 From 76a0de3a0d80421b805a3f36a11d5d49089c62d2 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 21 Oct 2010 10:28:06 +0000 Subject: Changes to "evaluation time" for Curves: After discussions with Campbell regarding #24336 and #24309, we've decided to make this property for curves to only get set when an F-Curve explicitly animates it. As a consequence... - ALL OLD FILES using follow-path constraints that depended on this changed behaviour will currently need manual patching to add an appropriate F-Curve - Ctrl-P (Parenting to Curves -> Follow Path option) will now automatically create such F-Curves mimicking the old behaviour so that creating camera-following-path setups still works smoothly. - Directly adding a Follow Path constraint bypasses this, so you'll need to manually add such F-Curves if you need them. The main problem with the old approach was that there were many cases in which curve data could get added but the ctime would be incorrect until a frame change (i.e. on render) flushed this. --- source/blender/blenkernel/intern/anim_sys.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 22f5ac181f1..e03799ff938 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1872,22 +1872,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) EVAL_ANIM_IDS(main->mball.first, ADT_RECALC_ANIM); /* curves */ - /* we need to perform a special hack here to ensure that the ctime - * value of the curve gets set in case there's no animation for that - * - it needs to be set before animation is evaluated just so that - * animation can successfully override... - * - it shouldn't get set when calculating drivers... - */ - for (id= main->curve.first; id; id= id->next) { - AnimData *adt= BKE_animdata_from_id(id); - Curve *cu= (Curve *)id; - - /* set ctime variable for curve */ - cu->ctime= ctime; - - /* now execute animation data on top of this as per normal */ - BKE_animsys_evaluate_animdata(id, adt, ctime, ADT_RECALC_ANIM); - } + EVAL_ANIM_IDS(main->curve.first, ADT_RECALC_ANIM); /* armatures */ EVAL_ANIM_IDS(main->armature.first, ADT_RECALC_ANIM); -- cgit v1.2.3 From cfcf82803a9e0d590800152a060ff9f97b123184 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 21 Oct 2010 17:00:38 +0000 Subject: Temporary fix for sequencer bugs #22925, #21429, #21783, #24165 * This fix is really only a bandage, as the underlying issue is that sequencer preview render doesn't yet use the job system. * The sequencer preview can start a full render of the scene, and this can collide with other preview/actual renders in many cases. * Drawing the sequencer preview is now disabled when an other render is in progress, but the sequence preview rendering could have already been started before the other render, so this doesn't really fix anything. * For now only OpenGL rendering can be used for the sequencer preview reliably until it's reimplemented using the job system. * Using the job system in the future can handle the clashes between different renders properly and will give users a nice progress bar to indicate something is happening while the preview is recalculated. --- source/blender/blenkernel/intern/sequencer.c | 59 ++++++++++++++++++---------- 1 file changed, 38 insertions(+), 21 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 5950a4630b7..53930cee68b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1801,7 +1801,8 @@ static ImBuf * seq_render_scene_strip_impl( Object *oldcamera; ListBase oldmarkers; - /* Hack! This function can be called from do_render_seq(), in that case + /* Old info: + 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). @@ -1813,9 +1814,27 @@ static ImBuf * seq_render_scene_strip_impl( and since G.rendering is uhm, gone... (Peter) */ + /* New info: + Using the same name for the renders works just fine as the do_render_seq() + render is not used while the scene strips are rendered. + + However rendering from UI (through sequencer_preview_area_draw) can crash in + very many cases since other renders (material preview, an actual render etc.) + can be started while this sequence preview render is running. The only proper + solution is to make the sequencer preview render a proper job, which can be + stopped when needed. This would also give a nice progress bar for the preview + space so that users know there's something happening. + + As a result the active scene now only uses OpenGL rendering for the sequencer + preview. This is far from nice, but is the only way to prevent crashes at this + time. + + -jahka + */ + 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 doseq_gl= G.rendering ? /*(scene->r.seq_flag & R_SEQ_GL_REND)*/ 0 : /*(scene->r.seq_flag & R_SEQ_GL_PREV)*/ 1; int have_seq= FALSE; Scene *sce= seq->scene; /* dont refer to seq->scene above this point!, it can be NULL */ int sce_valid= FALSE; @@ -1848,30 +1867,28 @@ static ImBuf * seq_render_scene_strip_impl( #endif if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == scene || have_seq==0) && seq->scene->camera) { + /* for old scened this can be uninitialized, should probably be added to do_versions at some point if the functionality stays */ + if(scene->r.seq_prev_type==0) + scene->r.seq_prev_type = 3 /* ==OB_SOLID */; + /* opengl offscreen render */ scene_update_for_newframe(bmain, seq->scene, seq->scene->lay); - ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, IB_rect, - scene->r.seq_prev_type); + ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, IB_rect, scene->r.seq_prev_type); } else { - Render *re; + Render *re = RE_GetRender(sce->id.name); RenderResult rres; - - if(rendering) - re= RE_NewRender(" do_build_seq_ibuf"); - /* If the top level scene that does the sequencer rendering is included - * as a strip the default render name for the strip will conflict with - * the original render, so override the name in this case. - * See bugs #22236 and #24160 for examples. - * XXX: Somebody with deeper insight to the rendering pipeline should - * probably check if this is the best way to handle this. -jahka - */ - else if(seq->scene == scene) - re= RE_NewRender("scene_conflict_render"); - else - re= RE_NewRender(sce->id.name); - - RE_BlenderFrame(re, bmain, sce, NULL, sce->lay, frame); + + /* XXX: this if can be removed when sequence preview rendering uses the job system */ + if(rendering || scene != sce) { + if(re==NULL) + re= RE_NewRender(sce->id.name); + + RE_BlenderFrame(re, bmain, sce, NULL, sce->lay, frame); + + /* restore previous state after it was toggled on & off by RE_BlenderFrame */ + G.rendering = rendering; + } RE_AcquireResultImage(re, &rres); -- cgit v1.2.3 From 8259321a5f022e8d8209057cd3bf00593f4aef17 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Oct 2010 22:45:54 +0000 Subject: fix warnings --- source/blender/blenkernel/intern/collision.c | 4 ++-- source/blender/blenkernel/intern/ipo.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 62b587029e1..d39e550192b 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1307,7 +1307,7 @@ static int cloth_collision_moving ( ClothModifierData *clmd, CollisionModifierDa } #endif -static void add_collision_object(Object ***objs, int *numobj, int *maxobj, Object *ob, Object *self, int level) +static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned int *maxobj, Object *ob, Object *self, int level) { CollisionModifierData *cmd= NULL; @@ -1545,7 +1545,7 @@ int cloth_bvh_objcollision (Object *ob, ClothModifierData * clmd, float step, fl Object *collob= collobjs[i]; CollisionModifierData *collmd = (CollisionModifierData*)modifiers_findByType(collob, eModifierType_Collision); BVHTreeOverlap *overlap = NULL; - int result = 0; + unsigned int result = 0; if(!collmd->bvhtree) continue; diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index b6a6607e062..a8e0aa81156 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1123,7 +1123,8 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * { AdrBit2Path *abp; FCurve *fcu; - unsigned int i=0, totbits; + unsigned int i=0; + int totbits; /* allocate memory for a new F-Curve */ fcu= MEM_callocN(sizeof(FCurve), "FCurve"); -- cgit v1.2.3 From 2fe940f8df9c4513ad1ad0674f49818417450984 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Oct 2010 03:56:50 +0000 Subject: Fix for snapping pose bones with axis-angle rotation. - armature_mat_pose_to_bone() was missing axis-angle check. - added loc_axisangle_size_to_mat4() for completeness. - use 'const' prefix where possible in math rotation functions. --- source/blender/blenkernel/intern/armature.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index f0c39e6373e..f77992262a7 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1108,12 +1108,19 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm /* paranoia: prevent crashes with no pose-channel supplied */ if (pchan==NULL) return; - + /* get the inverse matrix of the pchan's transforms */ - if (pchan->rotmode) - loc_eul_size_to_mat4(pc_trans, pchan->loc, pchan->eul, pchan->size); - else + switch(pchan->rotmode) { + case ROT_MODE_QUAT: loc_quat_size_to_mat4(pc_trans, pchan->loc, pchan->quat, pchan->size); + break; + case ROT_MODE_AXISANGLE: + loc_axisangle_size_to_mat4(pc_trans, pchan->loc, pchan->rotAxis, pchan->rotAngle, pchan->size); + break; + default: /* euler */ + loc_eul_size_to_mat4(pc_trans, pchan->loc, pchan->eul, pchan->size); + } + invert_m4_m4(inv_trans, pc_trans); /* Remove the pchan's transforms from it's pose_mat. -- cgit v1.2.3 From 347900a3d6a9bd1b53fb8b8e48c4d7e9f7011ffe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 22 Oct 2010 06:25:14 +0000 Subject: [#21331] Pose snap not working in some cases The bone option 'Local Location' (flag BONE_NO_LOCAL_LOCATION) makes the location apply differently so snap to cursor failed for pose bones. --- source/blender/blenkernel/intern/armature.c | 45 +++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index f77992262a7..0eaef5f250f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1105,21 +1105,42 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm { float pc_trans[4][4], inv_trans[4][4]; float pc_posemat[4][4], inv_posemat[4][4]; - + float pose_mat[4][4]; + /* paranoia: prevent crashes with no pose-channel supplied */ if (pchan==NULL) return; - /* get the inverse matrix of the pchan's transforms */ - switch(pchan->rotmode) { - case ROT_MODE_QUAT: - loc_quat_size_to_mat4(pc_trans, pchan->loc, pchan->quat, pchan->size); - break; - case ROT_MODE_AXISANGLE: - loc_axisangle_size_to_mat4(pc_trans, pchan->loc, pchan->rotAxis, pchan->rotAngle, pchan->size); - break; - default: /* euler */ - loc_eul_size_to_mat4(pc_trans, pchan->loc, pchan->eul, pchan->size); + /* default flag */ + if((pchan->bone->flag & BONE_NO_LOCAL_LOCATION)==0) { + /* get the inverse matrix of the pchan's transforms */ + switch(pchan->rotmode) { + case ROT_MODE_QUAT: + loc_quat_size_to_mat4(pc_trans, pchan->loc, pchan->quat, pchan->size); + break; + case ROT_MODE_AXISANGLE: + loc_axisangle_size_to_mat4(pc_trans, pchan->loc, pchan->rotAxis, pchan->rotAngle, pchan->size); + break; + default: /* euler */ + loc_eul_size_to_mat4(pc_trans, pchan->loc, pchan->eul, pchan->size); + } + + copy_m4_m4(pose_mat, pchan->pose_mat); } + else { + /* local location, this is not default, different calculation + * note: only tested for location with pose bone snapping. + * If this is not useful in other cases the BONE_NO_LOCAL_LOCATION + * case may have to be split into its own function. */ + unit_m4(pc_trans); + copy_v3_v3(pc_trans[3], pchan->loc); + + /* use parents rotation/scale space + own absolute position */ + if(pchan->parent) copy_m4_m4(pose_mat, pchan->parent->pose_mat); + else unit_m4(pose_mat); + + copy_v3_v3(pose_mat[3], pchan->pose_mat[3]); + } + invert_m4_m4(inv_trans, pc_trans); @@ -1127,7 +1148,7 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm * This should leave behind the effects of restpose + * parenting + constraints */ - mul_m4_m4m4(pc_posemat, inv_trans, pchan->pose_mat); + mul_m4_m4m4(pc_posemat, inv_trans, pose_mat); /* get the inverse of the leftovers so that we can remove * that component from the supplied matrix -- cgit v1.2.3 From d3ac70909ef88eb3a76ab9f875491bbb62ed2bf0 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 22 Oct 2010 11:38:10 +0000 Subject: Bugfix #20708: segmented bones don't work well with spline IK There was a slight discreptancy between the tail values calculated on the spline before the head was displaced for the "chain offset" option and after this operation. However, only the original version got set. This small difference resulted in B-Bones thinking that the endpoints of the bones were in places that they were not in, hence causing the curly patterns observed in the report. --- source/blender/blenkernel/intern/armature.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 0eaef5f250f..029b3c2e141 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2018,7 +2018,9 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o /* finally, store the new transform */ copy_m4_m4(pchan->pose_mat, poseMat); VECCOPY(pchan->pose_head, poseHead); - VECCOPY(pchan->pose_tail, poseTail); + + /* recalculate tail, as it's now outdated after the head gets adjusted above! */ + where_is_pose_bone_tail(pchan); /* done! */ pchan->flag |= POSE_DONE; @@ -2231,6 +2233,15 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha } } +/* calculate tail of posechannel */ +void where_is_pose_bone_tail(bPoseChannel *pchan) +{ + float vec[3]; + + VECCOPY(vec, pchan->pose_mat[1]); + mul_v3_fl(vec, pchan->bone->length); + add_v3_v3v3(pchan->pose_tail, pchan->pose_head, vec); +} /* The main armature solver, does all constraints excluding IK */ /* pchan is validated, as having bone and parent pointer @@ -2364,9 +2375,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti /* calculate head */ VECCOPY(pchan->pose_head, pchan->pose_mat[3]); /* calculate tail */ - VECCOPY(vec, pchan->pose_mat[1]); - mul_v3_fl(vec, bone->length); - add_v3_v3v3(pchan->pose_tail, pchan->pose_head, vec); + where_is_pose_bone_tail(pchan); } /* This only reads anim data from channels, and writes to channels */ -- cgit v1.2.3 From dad9423dd605eab60f19f4e76ad7b71ff37be827 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Fri, 22 Oct 2010 14:04:54 +0000 Subject: Include BLI_storage.h where zlib.h is also included. Some systems need _LARGESOURCE64_FILE defined for zlib to not throw errors. --- source/blender/blenkernel/intern/exotic.c | 1 + source/blender/blenkernel/intern/particle_system.c | 1 + 2 files changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index c5431005b18..5e2ca921ef2 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -64,6 +64,7 @@ #include "BKE_utildefines.h" #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_storage.h" #include "BKE_blender.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 34abe45981c..be616d9922c 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -62,6 +62,7 @@ #include "BLI_kdopbvh.h" #include "BLI_listbase.h" #include "BLI_threads.h" +#include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */ #include "BKE_main.h" #include "BKE_animsys.h" -- cgit v1.2.3 From 2d9be2226a7b8ec35f3055743f3d6e381fe78757 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 23 Oct 2010 16:03:31 +0000 Subject: warning fixes. --- source/blender/blenkernel/intern/constraint.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 5dad01a126f..c3f05e497f1 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -2015,6 +2015,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) { #ifdef DISABLE_PYTHON + (void)con; (void)cob; (void)targets; /* unused */ return; #else bPythonConstraint *data= con->data; -- cgit v1.2.3 From 1de1d6537ee208b9e57b293c816bacc2e8fb990f Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Sun, 24 Oct 2010 00:09:23 +0000 Subject: Fully disable AUD's FFTW3 usage. --- source/blender/blenkernel/intern/curve.c | 3 +-- source/blender/blenkernel/intern/customdata.c | 3 +-- source/blender/blenkernel/intern/effect.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index a7dd80bff4d..06ba066efdd 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1939,11 +1939,10 @@ static void make_bevel_list_3D_tangent(BevList *bl) /* make perpendicular, modify tan in place, is ok */ float cross_tmp[3]; - float zero[3] = {0,0,0}; cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir); normalize_v3(cross_tmp); - tri_to_quat( bevp1->quat,zero, cross_tmp, bevp1->tan); /* XXX - could be faster */ + tri_to_quat( bevp1->quat, (float [3]){0,0,0}, cross_tmp, bevp1->tan); /* XXX - could be faster */ bevp0= bevp1; bevp1= bevp2; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 9c4f0d790ca..3eec7611697 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -502,8 +502,7 @@ static void layerInterp_mdisps(void **UNUSED(sources), float *UNUSED(weights), /* Initialize the destination */ for(i = 0; i < d->totdisp; ++i) { - float z[3] = {0,0,0}; - copy_v3_v3(d->disps[i], z); + zero_v3(d->disps[i]); } /* For now, some restrictions on the input */ diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 70e814ef956..47606c39937 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -1007,8 +1007,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we else if(eff->pd->forcefield == PFIELD_TEXTURE) do_texture_effector(eff, &efd, point, force); else { - float temp1[3]={0,0,0}, temp2[3]; - VECCOPY(temp1, force); + float temp1[3]={force[0], force[1], force[2]}, temp2[3]; do_physical_effector(eff, &efd, point, force); -- cgit v1.2.3 From ea5670f4b597828bfb0170f9b659d19ebdb5ab33 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 24 Oct 2010 02:02:37 +0000 Subject: Fixed bug #24364, "subsurf modifier causes wire-only meshes to disappear in object mode." * Re-added code to draw loose edge --- source/blender/blenkernel/intern/subsurf_ccg.c | 42 +++++++++++++++++--------- 1 file changed, 27 insertions(+), 15 deletions(-) (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 4b810059464..51cee333370 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1151,8 +1151,10 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); + CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); int gridSize = ccgSubSurf_getGridSize(ss); - int start, end, step; + int edgeSize = ccgSubSurf_getEdgeSize(ss); + int step; int useAging; ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL); @@ -1165,20 +1167,12 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw glColor3ub(0, 0, 0); } - if(drawLooseEdges) { - start = 0; - end = gridSize; - step = gridSize - 1; - } - else if(ccgdm->drawInteriorEdges) { - start = 1; - end = gridSize - 1; - step = 1; - } - - if(drawLooseEdges && ccgdm->drawInteriorEdges) + if(ccgdm->drawInteriorEdges) step = 1; + else + step = gridSize - 1; + /* draw edges using face grids */ for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { CCGFace *f = ccgFaceIterator_getCurrent(fi); int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); @@ -1186,13 +1180,13 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw for (S=0; S Date: Sun, 24 Oct 2010 07:02:19 +0000 Subject: bugfix [#24357] Font folder can be specified but is not opened - open operator was incorrectly checking if the font path was set. - rna ID editable check was also incorrect, checking the ID name rather then the filename. - use define FO_BUILTIN_NAME rather then "". --- source/blender/blenkernel/intern/font.c | 18 +++++++++--------- source/blender/blenkernel/intern/packedFile.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 131b16b319e..58917e75a43 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -305,7 +305,7 @@ static VFontData *vfont_get_data(VFont *vfont) if (!vfont->data) { PackedFile *pf; - if (BLI_streq(vfont->name, "")) { + if (strcmp(vfont->name, FO_BUILTIN_NAME)==0) { pf= get_builtin_packedfile(); } else { if (vfont->packedfile) { @@ -342,7 +342,7 @@ static VFontData *vfont_get_data(VFont *vfont) if(!pf) { printf("Font file doesn't exist: %s\n", vfont->name); - strcpy(vfont->name, ""); + strcpy(vfont->name, FO_BUILTIN_NAME); pf= get_builtin_packedfile(); } } @@ -367,7 +367,7 @@ VFont *load_vfont(char *name) int is_builtin; struct TmpFont *tmpfnt; - if (BLI_streq(name, "")) { + if (strcmp(name, FO_BUILTIN_NAME)==0) { strcpy(filename, name); pf= get_builtin_packedfile(); @@ -403,8 +403,8 @@ VFont *load_vfont(char *name) vfont->packedfile = pf; } - // Do not add to temporary listbase - if(strcmp(filename, "")) + // Do not add FO_BUILTIN_NAME to temporary listbase + if(strcmp(filename, FO_BUILTIN_NAME)) { tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); tmpfnt->pf= tpf; @@ -443,10 +443,10 @@ VFont *get_builtin_font(void) VFont *vf; for (vf= G.main->vfont.first; vf; vf= vf->id.next) - if (BLI_streq(vf->name, "")) + if (strcmp(vf->name, FO_BUILTIN_NAME)==0) return vf; - return load_vfont(""); + return load_vfont(FO_BUILTIN_NAME); } static VChar *find_vfont_char(VFontData *vfd, intptr_t character) @@ -781,10 +781,10 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) /* * The character wasn't in the current curve base so load it - * But if the font is then do not try loading since + * But if the font is FO_BUILTIN_NAME then do not try loading since * whole font is in the memory already */ - if(che == NULL && strcmp(vfont->name, "")) { + if(che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) { BLI_vfontchar_from_freetypefont(vfont, ascii); } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 33f1949c5ac..e8223caed41 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -227,7 +227,7 @@ void packAll(Main *bmain, ReportList *reports) } for(vf=bmain->vfont.first; vf; vf=vf->id.next) - if(vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, "") != 0) + if(vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0) vf->packedfile = newPackedFile(reports, vf->name); for(sound=bmain->sound.first; sound; sound=sound->id.next) -- cgit v1.2.3 From 715fa82769a2d239bdf73701719ae354ca527c59 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 24 Oct 2010 12:45:47 +0000 Subject: Make sure separation between modifier keys is communicated from GHOST upwards too (BGE at least uses this). --- source/blender/blenkernel/intern/curve.c | 3 ++- source/blender/blenkernel/intern/customdata.c | 3 ++- source/blender/blenkernel/intern/effect.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 06ba066efdd..a7dd80bff4d 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1939,10 +1939,11 @@ static void make_bevel_list_3D_tangent(BevList *bl) /* make perpendicular, modify tan in place, is ok */ float cross_tmp[3]; + float zero[3] = {0,0,0}; cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir); normalize_v3(cross_tmp); - tri_to_quat( bevp1->quat, (float [3]){0,0,0}, cross_tmp, bevp1->tan); /* XXX - could be faster */ + tri_to_quat( bevp1->quat,zero, cross_tmp, bevp1->tan); /* XXX - could be faster */ bevp0= bevp1; bevp1= bevp2; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 3eec7611697..9c4f0d790ca 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -502,7 +502,8 @@ static void layerInterp_mdisps(void **UNUSED(sources), float *UNUSED(weights), /* Initialize the destination */ for(i = 0; i < d->totdisp; ++i) { - zero_v3(d->disps[i]); + float z[3] = {0,0,0}; + copy_v3_v3(d->disps[i], z); } /* For now, some restrictions on the input */ diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 47606c39937..70e814ef956 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -1007,7 +1007,8 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we else if(eff->pd->forcefield == PFIELD_TEXTURE) do_texture_effector(eff, &efd, point, force); else { - float temp1[3]={force[0], force[1], force[2]}, temp2[3]; + float temp1[3]={0,0,0}, temp2[3]; + VECCOPY(temp1, force); do_physical_effector(eff, &efd, point, force); -- cgit v1.2.3 From a301d2c898ed353aa6902a4893574ab24b7a2b4e Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 24 Oct 2010 12:54:52 +0000 Subject: Remove the unsigned, since totbits is signed too. --- source/blender/blenkernel/intern/ipo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index a8e0aa81156..5ed6beaf376 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1175,7 +1175,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * abp= adrcode_bitmaps_to_paths(icu->blocktype, icu->adrcode, &totbits); if (abp && totbits) { FCurve *fcurve; - unsigned int b; + int b; if (G.f & G_DEBUG) printf("\tconvert bitflag ipocurve, totbits = %d \n", totbits); -- cgit v1.2.3 From acef2ca4c5cc1dcdff0edc7af79f8772186a2c3d Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Mon, 25 Oct 2010 02:58:32 +0000 Subject: Closing #24367 (Incorrect behaviour for Optimal Display option) and reopening #22634 (sculpting/multires and wireframe display mode glitches) * Reverting my earlier changes to subsurf edge drawing; seems to be causing more bugs than the minor bug it fixed. --- source/blender/blenkernel/intern/subsurf_ccg.c | 85 +++++++++++++------------- 1 file changed, 41 insertions(+), 44 deletions(-) (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 51cee333370..26bd981db4a 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1146,74 +1146,71 @@ static void ccgDM_drawVerts(DerivedMesh *dm) { ccgFaceIterator_free(fi); glEnd(); } - static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(drawAllEdges)) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; - CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); + CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); + int i, edgeSize = ccgSubSurf_getEdgeSize(ss); int gridSize = ccgSubSurf_getGridSize(ss); - int edgeSize = ccgSubSurf_getEdgeSize(ss); - int step; int useAging; ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL); - /* nothing to do */ - if(!drawLooseEdges && !ccgdm->drawInteriorEdges) - return; + for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) { + CCGEdge *e = ccgEdgeIterator_getCurrent(ei); + DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); + + if (!drawLooseEdges && !ccgSubSurf_getEdgeNumFaces(e)) + continue; + + if (useAging && !(G.f&G_BACKBUFSEL)) { + int ageCol = 255-ccgSubSurf_getEdgeAge(ss, e)*4; + glColor3ub(0, ageCol>0?ageCol:0, 0); + } + + glBegin(GL_LINE_STRIP); + for (i=0; idrawInteriorEdges) - step = 1; - else - step = gridSize - 1; + if (ccgdm->drawInteriorEdges) { + for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { + CCGFace *f = ccgFaceIterator_getCurrent(fi); + int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); - /* draw edges using face grids */ - for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { - CCGFace *f = ccgFaceIterator_getCurrent(fi); - int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); + for (S=0; S Date: Mon, 25 Oct 2010 06:59:18 +0000 Subject: first part of bugfix [#24376] Fly mode disturbs the rotation or scale of the camera object object_apply_mat4 was incorrectly negating the matrix values, This worked in most cases but even when it worked would end up with negative scales too often. now when no negative scale is used they will all stay positive and from my tests it works in all cases now. --- source/blender/blenkernel/intern/object.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 142e41918dd..96f90473814 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1709,11 +1709,13 @@ void object_apply_mat4(Object *ob, float mat[][4]) * for these together since they are related. */ copy_m3_m4(mat3, mat); /* so scale doesnt interfear with rotation [#24291] */ + /* note: this is a workaround for negative matrix not working for rotation conversion, FIXME */ normalize_m3_m3(mat3_n, (const float(*)[3])mat3); - if(mat3_n[0][0] < 0.0f) negate_v3(mat3_n[0]); - if(mat3_n[1][1] < 0.0f) negate_v3(mat3_n[1]); - if(mat3_n[2][2] < 0.0f) negate_v3(mat3_n[2]); - + if(is_negative_m3(mat3_n)) { + negate_v3(mat3_n[0]); + negate_v3(mat3_n[1]); + negate_v3(mat3_n[2]); + } /* rotation */ object_mat3_to_rot(ob, mat3_n, 0); -- cgit v1.2.3 From 904f82b49fb8a5169deaab707fe01333c077119f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 25 Oct 2010 07:12:29 +0000 Subject: bugfix [#24376] Fly mode disturbs the rotation or scale of the camera object --- source/blender/blenkernel/intern/object.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 96f90473814..9d93fac8ad0 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1550,7 +1550,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) if(gob) { ob->rotmode= target->rotmode; mul_m4_m4m4(ob->obmat, target->obmat, gob->obmat); - object_apply_mat4(ob, ob->obmat); + object_apply_mat4(ob, ob->obmat, FALSE); } else { copy_object_transform(ob, target); @@ -1678,7 +1678,7 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) mul_m3_m3m3(mat, dmat, rmat); } -void object_mat3_to_rot(Object *ob, float mat[][3], int use_compat) +void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) { if (ob->rotmode == ROT_MODE_QUAT) mat3_to_quat(ob->quat, mat); @@ -1696,7 +1696,7 @@ void object_mat3_to_rot(Object *ob, float mat[][3], int use_compat) } /* see pchan_apply_mat4() for the equivalent 'pchan' function */ -void object_apply_mat4(Object *ob, float mat[][4]) +void object_apply_mat4(Object *ob, float mat[][4], short use_compat) { float mat3[3][3]; /* obmat -> 3x3 */ float mat3_n[3][3]; /* obmat -> normalized, 3x3 */ @@ -1718,7 +1718,7 @@ void object_apply_mat4(Object *ob, float mat[][4]) } /* rotation */ - object_mat3_to_rot(ob, mat3_n, 0); + object_mat3_to_rot(ob, mat3_n, use_compat); /* scale */ /* note: mat4_to_size(ob->size, mat) fails for negative scale */ -- cgit v1.2.3 From d327f08f9a948ac59f90379577366e7a807a2e64 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 25 Oct 2010 08:03:05 +0000 Subject: Fix #24255: Multires object gets modified when joining it to another multires object. Fix #22018: joining objects with different multires levels loses levesl from the higher multires object - Synchronyze mulires subdivision level when joining objects - Apply scale on MDISP layer when applying scale - Re-calculate MDISP when joining scaled objects --- source/blender/blenkernel/intern/multires.c | 204 +++++++++++++++++++++++++++- 1 file changed, 197 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 91f15d1ee6c..b6e48a12676 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -46,6 +46,7 @@ #include "BKE_scene.h" #include "BKE_subsurf.h" #include "BKE_utildefines.h" +#include "BKE_object.h" #include "CCGSubSurf.h" @@ -89,6 +90,34 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData * return NULL; } +/* used for applying scale on mdisps layer and syncing subdivide levels when joining objects */ +static MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob) +{ + ModifierData *md; + MultiresModifierData *mmd= NULL, *firstmmd= NULL; + + /* find first active multires modifier */ + for(md = ob->modifiers.first; md; md = md->next) { + if(md->type == eModifierType_Multires) { + if(!firstmmd) + firstmmd= (MultiresModifierData*)md; + + if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) { + mmd= (MultiresModifierData*)md; + break; + } + } + } + + if(!mmd) { + /* active multires have not been found + try to use first one */ + return firstmmd; + } + + return mmd; +} + static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render) { if(render) @@ -389,11 +418,9 @@ static void multires_copy_dm_grid(DMGridData *gridA, DMGridData *gridB, int size } } -/* direction=1 for delete higher, direction=0 for lower (not implemented yet) */ -void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int direction) +static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) { - Mesh *me = get_mesh(ob); - int lvl = multires_get_level(ob, mmd, 0); + Mesh *me = (Mesh*)ob->data; int levels = mmd->totlvl - lvl; MDisps *mdisps; @@ -403,7 +430,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire multires_force_update(ob); - if(mdisps && levels > 0 && direction == 1) { + if(mdisps && levels > 0) { if(lvl > 0) { int nsize = multires_side_tot[lvl]; int hsize = multires_side_tot[mmd->totlvl]; @@ -442,6 +469,27 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire multires_set_tot_level(ob, mmd, lvl); } +/* direction=1 for delete higher, direction=0 for lower (not implemented yet) */ +void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int direction) +{ + Mesh *me = get_mesh(ob); + int lvl = multires_get_level(ob, mmd, 0); + int levels = mmd->totlvl - lvl; + MDisps *mdisps; + + multires_set_tot_mdisps(me, mmd->totlvl); + CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); + mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); + + multires_force_update(ob); + + if(mdisps && levels > 0 && direction == 1) { + multires_del_higher(mmd, ob, lvl); + } + + multires_set_tot_level(ob, mmd, lvl); +} + static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple) { MultiresModifierData mmd; @@ -471,12 +519,11 @@ static DerivedMesh *subsurf_dm_create_local(Object *UNUSED(ob), DerivedMesh *dm, return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0); } -void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) +void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl, int updateblock, int simple) { Mesh *me = ob->data; MDisps *mdisps; int lvl= mmd->totlvl; - int totlvl= mmd->totlvl+1; if(totlvl > multires_max_levels) return; @@ -549,6 +596,11 @@ void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updat multires_set_tot_level(ob, mmd, totlvl); } +void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) +{ + multires_subdivide(mmd, ob, mmd->totlvl+1, updateblock, simple); +} + static void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData **gridData, float t[3]) { if(axis == 0) { @@ -1386,3 +1438,141 @@ void multires_load_old(Object *ob, Mesh *me) me->mr= NULL; } +static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) +{ + MultiresModifierData *mmd= get_multires_modifier(scene, ob); + MultiresModifierData *to_mmd= get_multires_modifier(scene, to_ob); + + if(!mmd) { + /* object could have MDISP even when there is no multires modifier + this could lead to troubles due to i've got no idea how mdisp could be + upsampled correct without modifier data. + just remove mdisps if no multires present (nazgul) */ + + Mesh *me= (Mesh*)ob->data; + + CustomData_external_remove(&me->fdata, &me->id, CD_MDISPS, me->totface); + CustomData_free_layer_active(&me->fdata, CD_MDISPS, me->totface); + } + + if(!mmd || !to_mmd) return; + + if(mmd->totlvl>to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl); + else multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple); +} + +void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) +{ + DerivedMesh *dm= NULL, *cddm= NULL, *subdm= NULL; + DMGridData **gridData, **subGridData; + Mesh *me= (Mesh*)ob->data; + MFace *mface= me->mface; + MVert *mvert= NULL; + MDisps *mdisps; + int *gridOffset; + int i, numGrids, gridSize, dGridSize, dSkip, totvert; + float (*vertCos)[3] = NULL; + MultiresModifierData *mmd= get_multires_modifier(scene, ob); + + CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); + mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); + + if(!mdisps || !mmd) return; + + + /* unscaled multires with applied displacement */ + subdm= get_multires_dm(scene, mmd, ob); + + /* prepare scaled CDDM to create ccgDN */ + cddm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); + + totvert= cddm->getNumVerts(cddm); + vertCos= MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos"); + cddm->getVertCos(cddm, vertCos); + for(i=0; igetVertArray(cddm); + + /* scaled ccgDM for tangent space of object with applied scale */ + dm= subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0); + cddm->release(cddm); + + numGrids= dm->getNumGrids(dm); + gridSize= dm->getGridSize(dm); + gridData= dm->getGridData(dm); + gridOffset= dm->getGridOffset(dm); + subGridData= subdm->getGridData(subdm); + + dGridSize= multires_side_tot[mmd->totlvl]; + dSkip= (dGridSize-1)/(gridSize-1); + + #pragma omp parallel for private(i) if(me->totface*gridSize*gridSize*4 >= CCG_OMP_LIMIT) + for(i = 0; i < me->totface; ++i) { + const int numVerts= mface[i].v4 ? 4 : 3; + MDisps *mdisp= &mdisps[i]; + int S, x, y, gIndex = gridOffset[i]; + + for(S = 0; S < numVerts; ++S, ++gIndex) { + DMGridData *grid= gridData[gIndex]; + DMGridData *subgrid= subGridData[gIndex]; + float (*dispgrid)[3]= &mdisp->disps[S*dGridSize*dGridSize]; + + for(y = 0; y < gridSize; y++) { + for(x = 0; x < gridSize; x++) { + float *co= grid[x + y*gridSize].co; + float *sco= subgrid[x + y*gridSize].co; + float *no= grid[x + y*gridSize].no; + float *data= dispgrid[dGridSize*y*dSkip + x*dSkip]; + float mat[3][3], tx[3], ty[3], disp[3]; + + /* construct tangent space matrix */ + grid_tangent(gridSize, gIndex, x, y, 0, gridData, tx); + normalize_v3(tx); + + grid_tangent(gridSize, gIndex, x, y, 1, gridData, ty); + normalize_v3(ty); + + column_vectors_to_mat3(mat, tx, ty, no); + + /* scale subgrid coord and calculate displacement */ + mul_m3_v3(smat, sco); + sub_v3_v3v3(disp, sco, co); + + /* convert difference to tangent space */ + invert_m3(mat); + mul_v3_m3v3(data, mat, disp); + } + } + } + } + + dm->release(dm); + subdm->release(subdm); +} + +void multiresModifier_scale_disp(Scene *scene, Object *ob) +{ + float smat[3][3]; + + /* object's scale matrix */ + object_scale_to_mat3(ob, smat); + + multires_apply_smat(scene, ob, smat); +} + +void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob) +{ + float smat[3][3], tmat[3][3], mat[3][3]; + multires_sync_levels(scene, ob, to_ob); + + /* construct scale matrix for displacement */ + object_scale_to_mat3(to_ob, tmat); + invert_m3(tmat); + object_scale_to_mat3(ob, smat); + mul_m3_m3m3(mat, smat, tmat); + + multires_apply_smat(scene, ob, mat); +} -- cgit v1.2.3 From f8ec6b8654962cd2fc77b9941f35c8127d37fc90 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 26 Oct 2010 12:48:07 +0000 Subject: move matrix decomposition out of object.c into BLI_math_matrix function: mat4_to_loc_rot_size(), use this now for pchan_apply_mat4() to support negative scale, visual keying now uses compatible eulers. also added access to this in python's mathutils.Matrix() loc, quat, scale = matrix.decompose() --- source/blender/blenkernel/intern/armature.c | 40 +++++++++++----------- source/blender/blenkernel/intern/object.c | 51 +++++++---------------------- 2 files changed, 30 insertions(+), 61 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 029b3c2e141..b44bf751a8a 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1177,32 +1177,30 @@ void armature_loc_pose_to_bone(bPoseChannel *pchan, float *inloc, float *outloc) VECCOPY(outloc, nLocMat[3]); } +/* same as object_mat3_to_rot() */ +void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat) +{ + switch(pchan->rotmode) { + case ROT_MODE_QUAT: + mat3_to_quat(pchan->quat, mat); + break; + case ROT_MODE_AXISANGLE: + mat3_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, mat); + break; + default: /* euler */ + if(use_compat) mat3_to_compatible_eulO(pchan->eul, pchan->eul, pchan->rotmode, mat); + else mat3_to_eulO(pchan->eul, pchan->rotmode, mat); + } +} /* Apply a 4x4 matrix to the pose bone, * similar to object_apply_mat4() */ -void pchan_apply_mat4(bPoseChannel *pchan, float mat[][4]) +void pchan_apply_mat4(bPoseChannel *pchan, float mat[][4], short use_compat) { - /* location */ - copy_v3_v3(pchan->loc, mat[3]); - - /* scale */ - mat4_to_size(pchan->size, mat); - - /* rotation */ - if (pchan->rotmode == ROT_MODE_AXISANGLE) { - float tmp_quat[4]; - - /* need to convert to quat first (in temp var)... */ - mat4_to_quat(tmp_quat, mat); - quat_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, tmp_quat); - } - else if (pchan->rotmode == ROT_MODE_QUAT) { - mat4_to_quat(pchan->quat, mat); - } - else { - mat4_to_eulO(pchan->eul, pchan->rotmode, mat); - } + float rot[3][3]; + mat4_to_loc_rot_size(pchan->loc, rot, pchan->size, mat); + pchan_mat3_to_rot(pchan, rot, use_compat); } /* Remove rest-position effects from pose-transform for obtaining diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 9d93fac8ad0..5ade08478a2 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1680,54 +1680,25 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) { - if (ob->rotmode == ROT_MODE_QUAT) + switch(ob->rotmode) { + case ROT_MODE_QUAT: mat3_to_quat(ob->quat, mat); - else if (ob->rotmode == ROT_MODE_AXISANGLE) + break; + case ROT_MODE_AXISANGLE: mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat); - else { - if(use_compat) { - float eul[3]; - VECCOPY(eul, ob->rot); - mat3_to_compatible_eulO(ob->rot, eul, ob->rotmode, mat); - } - else - mat3_to_eulO(ob->rot, ob->rotmode, mat); + break; + default: /* euler */ + if(use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, mat); + else mat3_to_eulO(ob->rot, ob->rotmode, mat); } } /* see pchan_apply_mat4() for the equivalent 'pchan' function */ void object_apply_mat4(Object *ob, float mat[][4], short use_compat) { - float mat3[3][3]; /* obmat -> 3x3 */ - float mat3_n[3][3]; /* obmat -> normalized, 3x3 */ - float imat3_n[3][3]; /* obmat -> normalized & inverted, 3x3 */ - - /* location */ - copy_v3_v3(ob->loc, mat[3]); - - /* rotation & scale are linked, we need to create the mat's - * for these together since they are related. */ - copy_m3_m4(mat3, mat); - /* so scale doesnt interfear with rotation [#24291] */ - /* note: this is a workaround for negative matrix not working for rotation conversion, FIXME */ - normalize_m3_m3(mat3_n, (const float(*)[3])mat3); - if(is_negative_m3(mat3_n)) { - negate_v3(mat3_n[0]); - negate_v3(mat3_n[1]); - negate_v3(mat3_n[2]); - } - - /* rotation */ - object_mat3_to_rot(ob, mat3_n, use_compat); - - /* scale */ - /* note: mat4_to_size(ob->size, mat) fails for negative scale */ - invert_m3_m3(imat3_n, mat3_n); - mul_m3_m3m3(mat3, imat3_n, mat3); - - ob->size[0]= mat3[0][0]; - ob->size[1]= mat3[1][1]; - ob->size[2]= mat3[2][2]; + float rot[3][3]; + mat4_to_loc_rot_size(ob->loc, rot, ob->size, mat); + object_mat3_to_rot(ob, rot, use_compat); } void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ -- cgit v1.2.3 From d5f66ea92584ce0d707387c9daebd05913c7209a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 26 Oct 2010 16:55:38 +0000 Subject: partial bugfix [#24002] Constraint "Limit rotation" doesn't work properly this fixes the obvious problems but there are still some rotation jumping when clamping in some cases. --- source/blender/blenkernel/intern/constraint.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index c3f05e497f1..4d6ef612c83 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1381,6 +1381,7 @@ static bConstraintTypeInfo CTI_LOCLIMIT = { static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bRotLimitConstraint *data = con->data; + float eul_zero[3]= {0.0f, 0.0f, 0.0f}; float loc[3]; float eul[3]; float size[3]; @@ -1388,8 +1389,9 @@ static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *U copy_v3_v3(loc, cob->matrix[3]); mat4_to_size(size, cob->matrix); - mat4_to_eulO(eul, cob->rotOrder, cob->matrix); - + /* use compat function because it uses the rotation without axis flipping [#24002] */ + mat4_to_compatible_eulO(eul, eul_zero, cob->rotOrder, cob->matrix); + /* constraint data uses radians internally */ /* limiting of euler values... */ -- cgit v1.2.3 From e3f8bcbe88543244ae0d06c53bb5f5f18fed03cb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 26 Oct 2010 23:28:10 +0000 Subject: bugfix #24334] Filename looses all parts after a dot when saving replacing the extension could remove the frame number added to a path when writing images, so just add the extension rather then replacing even though it gives odd names at times. eg: foo.png0001.tga --- source/blender/blenkernel/intern/image.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 09622b2acfe..1345c6c9b61 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -832,7 +832,10 @@ int BKE_add_image_extension(char *string, int imtype) } if(extension) { - return BLI_replace_extension(string, FILE_MAX, extension); + /* prefer this in many cases to avoid .png.tga, but in certain cases it breaks */ + /* return BLI_replace_extension(string, FILE_MAX, extension); */ + strcat(string, extension); + return TRUE; } else { return FALSE; -- cgit v1.2.3 From 7a569402078e4d4cb5b905645e8466e653bf6e1a Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 27 Oct 2010 14:56:53 +0000 Subject: Fix for [#24401] Fluid particles leak through walls of moving object --- source/blender/blenkernel/intern/particle_system.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (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 be616d9922c..a4c0776f5df 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3076,8 +3076,8 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo col.t = df; } else { - /* final chance to prevent failure, so don't do anything fancy */ - copy_v3_v3(pa->state.co, co); + /* final chance to prevent failure, so stick to the surface and hope for the best */ + madd_v3_v3v3fl(pa->state.co, co, col.vel, dt2); copy_v3_v3(pa->state.vel, v0); } } -- cgit v1.2.3 From 35807b20be55d49261d5fd2d837b65eb543e5472 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 27 Oct 2010 16:36:25 +0000 Subject: bugfix [#24418] NLA Crashes blender on Undo --- source/blender/blenkernel/intern/anim_sys.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index e03799ff938..52c5edc53a0 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1641,6 +1641,11 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) if ((nlt) && !(adt->flag & ADT_NLA_EDIT_NOMAP)) { /* edit active action in-place according to its active strip, so copy the data */ + + /* this is cleared on undo */ + if(adt->actstrip == NULL) { + adt->actstrip= BKE_nlastrip_find_active(nlt); + } memcpy(&dummy_strip, adt->actstrip, sizeof(NlaStrip)); dummy_strip.next = dummy_strip.prev = NULL; } -- cgit v1.2.3 From b7c8df231bd04b17b1e7b9965d247b7b62fa06d2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 28 Oct 2010 10:12:57 +0000 Subject: partial bugfix [#24425] Blender 2.54 Beta crashes when starting rendering Fix for one of the causes of crashing. Applying armature deform wasn't thread safe since the pose bones had deform data written into them when deforming a mesh. This fixes crashing immediately, on every render for me but blender still crashes calculating the subsurf sometimes. --- source/blender/blenkernel/intern/armature.c | 101 +++++++++++++++++----------- 1 file changed, 60 insertions(+), 41 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b44bf751a8a..3bec79eb352 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -577,7 +577,13 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) /* ************ Armature Deform ******************* */ -static void pchan_b_bone_defmats(bPoseChannel *pchan, int use_quaternion) +typedef struct bPoseChanDeform { + Mat4 *b_bone_mats; + DualQuat *dual_quat; + DualQuat *b_bone_dual_quats; +} bPoseChanDeform; + +static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info, int use_quaternion) { Bone *bone= pchan->bone; Mat4 *b_bone= b_bone_spline_setup(pchan, 0); @@ -589,11 +595,11 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, int use_quaternion) /* allocate b_bone matrices and dual quats */ b_bone_mats= MEM_mallocN((1+bone->segments)*sizeof(Mat4), "BBone defmats"); - pchan->b_bone_mats= b_bone_mats; + pdef_info->b_bone_mats= b_bone_mats; if(use_quaternion) { b_bone_dual_quats= MEM_mallocN((bone->segments)*sizeof(DualQuat), "BBone dqs"); - pchan->b_bone_dual_quats= b_bone_dual_quats; + pdef_info->b_bone_dual_quats= b_bone_dual_quats; } /* first matrix is the inverse arm_mat, to bring points in local bone space @@ -618,9 +624,9 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, int use_quaternion) } } -static void b_bone_deform(bPoseChannel *pchan, Bone *bone, float *co, DualQuat *dq, float defmat[][3]) +static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float *co, DualQuat *dq, float defmat[][3]) { - Mat4 *b_bone= pchan->b_bone_mats; + Mat4 *b_bone= pdef_info->b_bone_mats; float (*mat)[4]= b_bone[0].mat; float segment, y; int a; @@ -637,7 +643,7 @@ static void b_bone_deform(bPoseChannel *pchan, Bone *bone, float *co, DualQuat * CLAMP(a, 0, bone->segments-1); if(dq) { - copy_dq_dq(dq, &((DualQuat*)pchan->b_bone_dual_quats)[a]); + copy_dq_dq(dq, &(pdef_info->b_bone_dual_quats)[a]); } else { mul_m4_v3(b_bone[a+1].mat, co); @@ -711,7 +717,7 @@ static void pchan_deform_mat_add(bPoseChannel *pchan, float weight, float bbonem add_m3_m3m3(mat, mat, wmat); } -static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, float mat[][3], float *co) +static float dist_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, float *vec, DualQuat *dq, float mat[][3], float *co) { Bone *bone= pchan->bone; float fac, contrib=0.0; @@ -732,7 +738,7 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo if(vec) { if(bone->segments>1) // applies on cop and bbonemat - b_bone_deform(pchan, bone, cop, NULL, (mat)?bbonemat:NULL); + b_bone_deform(pdef_info, bone, cop, NULL, (mat)?bbonemat:NULL); else mul_m4_v3(pchan->chan_mat, cop); @@ -745,11 +751,11 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo } else { if(bone->segments>1) { - b_bone_deform(pchan, bone, cop, &bbonedq, NULL); + b_bone_deform(pdef_info, bone, cop, &bbonedq, NULL); add_weighted_dq_dq(dq, &bbonedq, fac); } else - add_weighted_dq_dq(dq, pchan->dual_quat, fac); + add_weighted_dq_dq(dq, pdef_info->dual_quat, fac); } } } @@ -757,7 +763,7 @@ static float dist_bone_deform(bPoseChannel *pchan, float *vec, DualQuat *dq, flo return contrib; } -static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, DualQuat *dq, float mat[][3], float *co, float *contrib) +static void pchan_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, float weight, float *vec, DualQuat *dq, float mat[][3], float *co, float *contrib) { float cop[3], bbonemat[3][3]; DualQuat bbonedq; @@ -770,7 +776,7 @@ static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, Dua if(vec) { if(pchan->bone->segments>1) // applies on cop and bbonemat - b_bone_deform(pchan, pchan->bone, cop, NULL, (mat)?bbonemat:NULL); + b_bone_deform(pdef_info, pchan->bone, cop, NULL, (mat)?bbonemat:NULL); else mul_m4_v3(pchan->chan_mat, cop); @@ -783,11 +789,11 @@ static void pchan_bone_deform(bPoseChannel *pchan, float weight, float *vec, Dua } else { if(pchan->bone->segments>1) { - b_bone_deform(pchan, pchan->bone, cop, &bbonedq, NULL); + b_bone_deform(pdef_info, pchan->bone, cop, &bbonedq, NULL); add_weighted_dq_dq(dq, &bbonedq, weight); } else - add_weighted_dq_dq(dq, pchan->dual_quat, weight); + add_weighted_dq_dq(dq, pdef_info->dual_quat, weight); } (*contrib)+=weight; @@ -798,8 +804,11 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, int numVerts, int deformflag, float (*prevCos)[3], const char *defgrp_name) { + bPoseChanDeform *pdef_info_array; + bPoseChanDeform *pdef_info= NULL; bArmature *arm= armOb->data; bPoseChannel *pchan, **defnrToPC = NULL; + int *defnrToPCIndex= NULL; MDeformVert *dverts = NULL; bDeformGroup *dg; DualQuat *dualquats= NULL; @@ -823,20 +832,24 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, /* bone defmats are already in the channels, chan_mat */ /* initialize B_bone matrices and dual quaternions */ + totchan= BLI_countlist(&armOb->pose->chanbase); + if(use_quaternion) { - totchan= BLI_countlist(&armOb->pose->chanbase); dualquats= MEM_callocN(sizeof(DualQuat)*totchan, "dualquats"); } + + pdef_info_array= MEM_callocN(sizeof(bPoseChanDeform)*totchan, "bPoseChanDeform"); totchan= 0; - for(pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next) { + pdef_info= pdef_info_array; + for(pchan= armOb->pose->chanbase.first; pchan; pchan= pchan->next, pdef_info++) { if(!(pchan->bone->flag & BONE_NO_DEFORM)) { if(pchan->bone->segments > 1) - pchan_b_bone_defmats(pchan, use_quaternion); + pchan_b_bone_defmats(pchan, pdef_info, use_quaternion); if(use_quaternion) { - pchan->dual_quat= &dualquats[totchan++]; - mat4_to_dquat( pchan->dual_quat,pchan->bone->arm_mat, pchan->chan_mat); + pdef_info->dual_quat= &dualquats[totchan++]; + mat4_to_dquat( pdef_info->dual_quat,pchan->bone->arm_mat, pchan->chan_mat); } } } @@ -872,15 +885,19 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, else if(dverts) use_dverts = 1; if(use_dverts) { - defnrToPC = MEM_callocN(sizeof(*defnrToPC) * numGroups, - "defnrToBone"); + defnrToPC = MEM_callocN(sizeof(*defnrToPC) * numGroups, "defnrToBone"); + defnrToPCIndex = MEM_callocN(sizeof(*defnrToPCIndex) * numGroups, "defnrToIndex"); for(i = 0, dg = target->defbase.first; dg; i++, dg = dg->next) { defnrToPC[i] = get_pose_channel(armOb->pose, dg->name); /* exclude non-deforming bones */ if(defnrToPC[i]) { - if(defnrToPC[i]->bone->flag & BONE_NO_DEFORM) + if(defnrToPC[i]->bone->flag & BONE_NO_DEFORM) { defnrToPC[i]= NULL; + } + else { + defnrToPCIndex[i]= BLI_findindex(&armOb->pose->chanbase, defnrToPC[i]); + } } } } @@ -951,10 +968,10 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, for(j = 0; j < dvert->totweight; j++){ int index = dvert->dw[j].def_nr; - pchan = index < numGroups?defnrToPC[index]:NULL; - if(pchan) { + if(index < numGroups && (pchan= defnrToPC[index])) { float weight = dvert->dw[j].weight; - Bone *bone = pchan->bone; + Bone *bone= pchan->bone; + pdef_info= pdef_info_array + defnrToPCIndex[index]; deformed = 1; @@ -965,25 +982,27 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, bone->rad_tail, bone->dist); } - pchan_bone_deform(pchan, weight, vec, dq, smat, co, &contrib); + pchan_bone_deform(pchan, pdef_info, weight, vec, dq, smat, co, &contrib); } } /* if there are vertexgroups but not groups with bones * (like for softbody groups) */ if(deformed == 0 && use_envelope) { - for(pchan = armOb->pose->chanbase.first; pchan; - pchan = pchan->next) { + pdef_info= pdef_info_array; + for(pchan= armOb->pose->chanbase.first; pchan; + pchan= pchan->next, pdef_info++) { if(!(pchan->bone->flag & BONE_NO_DEFORM)) - contrib += dist_bone_deform(pchan, vec, dq, smat, co); + contrib += dist_bone_deform(pchan, pdef_info, vec, dq, smat, co); } } } else if(use_envelope) { + pdef_info= pdef_info_array; for(pchan = armOb->pose->chanbase.first; pchan; - pchan = pchan->next) { + pchan = pchan->next, pdef_info++) { if(!(pchan->bone->flag & BONE_NO_DEFORM)) - contrib += dist_bone_deform(pchan, vec, dq, smat, co); + contrib += dist_bone_deform(pchan, pdef_info, vec, dq, smat, co); } } @@ -1039,20 +1058,20 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, if(dualquats) MEM_freeN(dualquats); if(defnrToPC) MEM_freeN(defnrToPC); - + if(defnrToPCIndex) MEM_freeN(defnrToPCIndex); + /* free B_bone matrices */ - for(pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next) { - if(pchan->b_bone_mats) { - MEM_freeN(pchan->b_bone_mats); - pchan->b_bone_mats = NULL; + pdef_info= pdef_info_array; + for(pchan = armOb->pose->chanbase.first; pchan; pchan = pchan->next, pdef_info++) { + if(pdef_info->b_bone_mats) { + MEM_freeN(pdef_info->b_bone_mats); } - if(pchan->b_bone_dual_quats) { - MEM_freeN(pchan->b_bone_dual_quats); - pchan->b_bone_dual_quats = NULL; + if(pdef_info->b_bone_dual_quats) { + MEM_freeN(pdef_info->b_bone_dual_quats); } - - pchan->dual_quat = NULL; } + + MEM_freeN(pdef_info_array); } /* ************ END Armature Deform ******************* */ -- cgit v1.2.3 From 6a9a49f8afe1e5825dc182eedff57a1c4d4290fe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 29 Oct 2010 07:11:45 +0000 Subject: bugfix for grease pencil freeing order. it was freed before objects which would then decrease its usercount - accessing freed memory. Also fixed error in own last commit. --- source/blender/blenkernel/intern/library.c | 9 +++++---- 1 file changed, 5 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 dfc82152e8c..dc3c120ab19 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -452,11 +452,13 @@ int set_listbasepointers(Main *main, ListBase **lb) { int a = 0; - /* BACKWARDS! also watch order of free-ing! (mesh<->mat) */ - + /* BACKWARDS! also watch order of free-ing! (mesh<->mat), first items freed last. + * This is important because freeing data decreases usercounts of other datablocks, + * if this data is its self freed it can crash. */ lb[a++]= &(main->ipo); lb[a++]= &(main->action); // xxx moved here to avoid problems when freeing with animato (aligorith) lb[a++]= &(main->key); + lb[a++]= &(main->gpencil); /* referenced by nodes, objects, view, scene etc, before to free after. */ lb[a++]= &(main->nodetree); lb[a++]= &(main->image); lb[a++]= &(main->tex); @@ -483,14 +485,13 @@ int set_listbasepointers(Main *main, ListBase **lb) lb[a++]= &(main->brush); lb[a++]= &(main->script); lb[a++]= &(main->particle); - + lb[a++]= &(main->world); lb[a++]= &(main->screen); lb[a++]= &(main->object); lb[a++]= &(main->scene); lb[a++]= &(main->library); lb[a++]= &(main->wm); - lb[a++]= &(main->gpencil); lb[a]= NULL; -- cgit v1.2.3 From 210915e3c722a04920eaa18e2faad793189659c6 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 30 Oct 2010 08:51:50 +0000 Subject: Fix for items 3 and 8 of [#24443] Trying to bake a smoke simulation crashes blender, and other smoke bugs. --- source/blender/blenkernel/intern/smoke.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index a7e664bf2bf..aafa2d9870c 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -629,9 +629,6 @@ void smokeModifier_reset(struct SmokeModifierData *smd) smd->domain->fluid = NULL; } - smd->domain->point_cache[0]->flag |= PTCACHE_OUTDATED; - smd->domain->point_cache[1]->flag |= PTCACHE_OUTDATED; - smokeModifier_reset_turbulence(smd); smd->time = -1; @@ -1412,6 +1409,10 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM /* if on second frame, write cache for first frame */ /* this needs to be done for smoke too so that pointcache works properly */ if((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) { + // create shadows straight after domain initialization 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); + BKE_ptcache_write_cache(&pid, startframe); if(sds->wt) BKE_ptcache_write_cache(&pid_wt, startframe); @@ -1443,7 +1444,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } } - // create shadows before writing cache so we get nice shadows for startframe, too + // create shadows before writing cache so they get stored 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 d29d972e335daad56a7ba6b552db9aa8d870adfe Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 30 Oct 2010 15:20:48 +0000 Subject: Fix for [#23318] SEQUENCER EFFECT: Glow blur amount should be relative --- source/blender/blenkernel/intern/seqeffects.c | 16 +++++++--------- source/blender/blenkernel/intern/sequencer.c | 9 +++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 6477c6b4f75..66cad5090f8 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2631,32 +2631,30 @@ static void copy_glow_effect(Sequence *dst, Sequence *src) } //void do_glow_effect(Cast *cast, float facf0, float facf1, int xo, int yo, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *outbuf, ImBuf *use) -static void do_glow_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), +static void do_glow_effect_byte(Sequence *seq, int render_size, float facf0, float UNUSED(facf1), int x, int y, char *rect1, char *UNUSED(rect2), char *out) { unsigned char *outbuf=(unsigned char *)out; unsigned char *inbuf=(unsigned char *)rect1; GlowVars *glow = (GlowVars *)seq->effectdata; - int size= 100; // renderdata XXX RVIsolateHighlights_byte(inbuf, outbuf , x, y, glow->fMini*765, glow->fBoost * facf0, glow->fClamp); - RVBlurBitmap2_byte (outbuf, x, y, glow->dDist * (size / 100.0f),glow->dQuality); + RVBlurBitmap2_byte (outbuf, x, y, glow->dDist * (render_size / 100.0f),glow->dQuality); if (!glow->bNoComp) RVAddBitmaps_byte (inbuf , outbuf, outbuf, x, y); } -static void do_glow_effect_float(Sequence *seq, float facf0, float UNUSED(facf1), +static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, float UNUSED(facf1), int x, int y, float *rect1, float *UNUSED(rect2), float *out) { float *outbuf = out; float *inbuf = rect1; GlowVars *glow = (GlowVars *)seq->effectdata; - int size= 100; // renderdata XXX RVIsolateHighlights_float(inbuf, outbuf , x, y, glow->fMini*3.0f, glow->fBoost * facf0, glow->fClamp); - RVBlurBitmap2_float (outbuf, x, y, glow->dDist * (size / 100.0f),glow->dQuality); + RVBlurBitmap2_float (outbuf, x, y, glow->dDist * (render_size / 100.0f),glow->dQuality); if (!glow->bNoComp) RVAddBitmaps_float (inbuf , outbuf, outbuf, x, y); } @@ -2664,19 +2662,19 @@ static void do_glow_effect_float(Sequence *seq, float facf0, float UNUSED(facf1) static struct ImBuf * do_glow_effect( Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float UNUSED(cfra), float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + int 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, + do_glow_effect_float(seq, render_size, facf0, facf1, x, y, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { - do_glow_effect_byte(seq, + do_glow_effect_byte(seq, render_size, facf0, facf1, x, y, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 53930cee68b..fcf574e1f1f 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1686,6 +1686,15 @@ static ImBuf* seq_render_effect_strip_impl( goto finish; } + /* Override render size here, effects need to get the actual + * ratio so they can scale appropriately. This whole business + * with render size, proxy size, and seqrectx, etc. is a bit + * complicated and should probably be cleaned up and handled + * properly way before we get to this point. -jahka + * (fix for bug #23318) + */ + render_size = 100*seqrectx/scene->r.xsch; + 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; -- cgit v1.2.3 From 44e60266269236234146066ab80aff4fa83722d8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 30 Oct 2010 18:42:11 +0000 Subject: the pivot constraint was translating when the pivot was offset along the rotation axis. fixed by projecting the pivot along the axis of rotation and subtracting this from the pivot. --- source/blender/blenkernel/intern/constraint.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 4d6ef612c83..9629be330d9 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3812,6 +3812,10 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t float pivot[3], vec[3]; float rotMat[3][3]; + + /* pivot correction */ + float axis[3], angle; + float dvec[3]; /* firstly, check if pivoting should take place based on the current rotation */ if (data->rotAxis != PIVOTCON_AXIS_NONE) { @@ -3854,7 +3858,15 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t // TODO: perhaps we might want to include scaling based on the pivot too? copy_m3_m4(rotMat, cob->matrix); normalize_m3(rotMat); - + + + /* correct the pivot by the rotation axis otherwise the pivot translates when it shouldnt */ + mat3_to_axis_angle(axis, &angle, rotMat); + sub_v3_v3v3(vec, pivot, cob->matrix[3]); + project_v3_v3v3(dvec, vec, axis); + sub_v3_v3(pivot, dvec); + + /* perform the pivoting... */ /* 1. take the vector from owner to the pivot */ sub_v3_v3v3(vec, pivot, cob->matrix[3]); -- cgit v1.2.3 From 90e9970094bc6907aec41b581e5b9144551734ae Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 30 Oct 2010 19:29:11 +0000 Subject: change mat4_to_eulO, mat3_to_eulO to calculate 2 rotations and return the smallest one. mat4_to_eul & mat3_to_eul are already working this way. Without this we get problems with constraints, eg: rotation on the Y axis over 90d can be represented by setting the X and Z to -PI, Y would decrease to 0 (infact 180d). --- source/blender/blenkernel/intern/constraint.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 9629be330d9..1892f6f0a27 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1381,16 +1381,14 @@ static bConstraintTypeInfo CTI_LOCLIMIT = { static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bRotLimitConstraint *data = con->data; - float eul_zero[3]= {0.0f, 0.0f, 0.0f}; float loc[3]; float eul[3]; float size[3]; copy_v3_v3(loc, cob->matrix[3]); mat4_to_size(size, cob->matrix); - - /* use compat function because it uses the rotation without axis flipping [#24002] */ - mat4_to_compatible_eulO(eul, eul_zero, cob->rotOrder, cob->matrix); + + mat4_to_eulO(eul, cob->rotOrder, cob->matrix); /* constraint data uses radians internally */ -- cgit v1.2.3 From 97d2ca8a3309e3b74990430672e74b1239f76636 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 30 Oct 2010 21:55:17 +0000 Subject: Sequence editor code cleanup * The logic in some parts of the sequencer code was rather cryptic, so I cleaned it up a bit. * There should be no functional changes what so ever from these changes. --- source/blender/blenkernel/intern/sequencer.c | 631 +++++++++++---------------- 1 file changed, 250 insertions(+), 381 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index fcf574e1f1f..c379ca43f82 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -372,7 +372,7 @@ void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq) do_seq_count(seqbase, totseq); if(*totseq==0) { - *seqar= 0; + *seqar= NULL; return; } *seqar= MEM_mallocN(sizeof(void *)* *totseq, "seqar"); @@ -411,8 +411,7 @@ static void do_build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int depth, seq->depth= depth; if(seq->seqbase.first && (test & BUILD_SEQAR_COUNT_CHILDREN)) { - do_build_seqar_cb(&seq->seqbase, seqar, depth+1, - test_func); + do_build_seqar_cb(&seq->seqbase, seqar, depth+1, test_func); } if (test & BUILD_SEQAR_COUNT_CURRENT) { **seqar= seq; @@ -431,7 +430,7 @@ void build_seqar_cb(ListBase *seqbase, Sequence ***seqar, int *totseq, do_seq_count_cb(seqbase, totseq, test_func); if(*totseq==0) { - *seqar= 0; + *seqar= NULL; return; } *seqar= MEM_mallocN(sizeof(void *)* *totseq, "seqar"); @@ -471,7 +470,7 @@ static void seq_update_sound_bounds_recursive(Scene *scene, Sequence *metaseq) if(seq->type == SEQ_META) { seq_update_sound_bounds_recursive(scene, seq); } - else if((seq->type == SEQ_SOUND) || (seq->type == SEQ_SCENE)) { + else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) { if(seq->scene_sound) { int startofs = seq->startofs; int endofs = seq->endofs; @@ -502,8 +501,8 @@ void calc_sequence(Scene *scene, Sequence *seq) if(seq->type & SEQ_EFFECT) { /* pointers */ - if(seq->seq2==0) seq->seq2= seq->seq1; - if(seq->seq3==0) seq->seq3= seq->seq1; + if(seq->seq2==NULL) seq->seq2= seq->seq1; + if(seq->seq3==NULL) seq->seq3= seq->seq1; /* effecten go from seq1 -> seq2: test */ @@ -558,9 +557,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) int prev_startdisp, prev_enddisp; /* note: dont rename the strip, will break animation curves */ - if (!(seq->type == SEQ_MOVIE || seq->type == SEQ_IMAGE || - seq->type == SEQ_SOUND || - seq->type == SEQ_SCENE || seq->type == SEQ_META)) { + if (ELEM5(seq->type, SEQ_MOVIE, SEQ_IMAGE, SEQ_SOUND, SEQ_SCENE, SEQ_META)==0) { return; } @@ -574,13 +571,14 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) new_tstripdata(seq); - if (seq->type != SEQ_SCENE && seq->type != SEQ_META && - seq->type != SEQ_IMAGE) { + if (ELEM3(seq->type, SEQ_SCENE, SEQ_META, SEQ_IMAGE)==0) { BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(str, G.main->name); } - if (seq->type == SEQ_IMAGE) { + switch(seq->type) { + case SEQ_IMAGE: + { /* Hack? */ size_t olen = MEM_allocN_len(seq->strip->stripdata)/sizeof(struct StripElem); @@ -591,7 +589,9 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) seq->len = 0; } seq->strip->len = seq->len; - } else if (seq->type == SEQ_MOVIE) { + break; + } + case SEQ_MOVIE: if(seq->anim) IMB_free_anim(seq->anim); seq->anim = openanim(str, IB_rect | ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0)); @@ -609,7 +609,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) seq->len = 0; } seq->strip->len = seq->len; - } else if (seq->type == SEQ_SOUND) { + case SEQ_SOUND: seq->len = ceil(AUD_getInfo(seq->sound->playback_handle).length * FPS); seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; @@ -617,7 +617,9 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) seq->len = 0; } seq->strip->len = seq->len; - } else if (seq->type == SEQ_SCENE) { + break; + case SEQ_SCENE: + { /* 'seq->scenenr' should be replaced with something more reliable */ Scene * sce = G.main->scene.first; int nr = 1; @@ -643,6 +645,8 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) seq->len = 0; } seq->strip->len = seq->len; + break; + } } free_proxy_seq(seq); @@ -804,7 +808,7 @@ static char *give_seqname_by_type(int type) case SEQ_MULTICAM: return "Multicam"; case SEQ_SPEED: return "Speed"; default: - return 0; + return NULL; } } @@ -896,19 +900,24 @@ static void multibuf(ImBuf *ibuf, float fmul) static float give_stripelem_index(Sequence *seq, float cfra) { float nr; + int sta = seq->start; + int end = seq->start+seq->len-1; if(seq->len == 0) return -1; + if(seq->flag&SEQ_REVERSE_FRAMES) { /*reverse frame in this sequence */ - if(cfra <= seq->start) nr= seq->len-1; - else if(cfra >= seq->start+seq->len-1) nr= 0; - else nr= (seq->start + seq->len - 1) - cfra; + if(cfra <= sta) nr= seq->len-1; + else if(cfra >= end) nr= 0; + else nr= end - cfra; } else { - if(cfra <= seq->start) nr= 0; - else if(cfra >= seq->start+seq->len-1) nr= seq->len-1; - else nr= cfra-seq->start; + if(cfra <= sta) nr= 0; + else if(cfra >= end) nr= seq->len-1; + else nr= cfra - sta; } + if (seq->strobe < 1.0) seq->strobe = 1.0; + if (seq->strobe > 1.0) { nr -= fmod((double)nr, (double)seq->strobe); } @@ -920,14 +929,10 @@ StripElem *give_stripelem(Sequence *seq, int cfra) { StripElem *se= seq->strip->stripdata; - if(seq->type == SEQ_MOVIE) { - /* use the first */ - } - else { + if(seq->type != SEQ_MOVIE) { /* movie use the first */ int nr = (int) give_stripelem_index(seq, cfra); - if (nr == -1) return 0; - if (se == 0) return 0; + if (nr == -1 || se == 0) return 0; se += nr + seq->anim_startofs; } @@ -964,9 +969,7 @@ int evaluate_seq_frame(Scene *scene, int cfra) static int video_seq_is_rendered(Sequence * seq) { - return (seq - && !(seq->flag & SEQ_MUTE) - && seq->type != SEQ_SOUND); + return (seq && !(seq->flag & SEQ_MUTE) && seq->type != SEQ_SOUND); } static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Sequence ** seq_arr_out) @@ -1028,13 +1031,11 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c return FALSE; } - if ((seq->flag & SEQ_USE_PROXY_CUSTOM_DIR) - || (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE)) { + if (seq->flag & (SEQ_USE_PROXY_CUSTOM_DIR|SEQ_USE_PROXY_CUSTOM_FILE)) { strcpy(dir, seq->strip->proxy->dir); } else { - if (seq->type == SEQ_IMAGE || seq->type == SEQ_MOVIE) { - snprintf(dir, FILE_MAXDIR, "%s/BL_proxy", - seq->strip->dir); + if (ELEM(seq->type, SEQ_IMAGE, SEQ_MOVIE)) { + snprintf(dir, FILE_MAXDIR, "%s/BL_proxy", seq->strip->dir); } else { return FALSE; } @@ -1049,30 +1050,25 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c /* generate a separate proxy directory for each preview size */ - if (seq->type == SEQ_IMAGE) { - StripElem * se = give_stripelem(seq, cfra); - snprintf(name, PROXY_MAXFILE, "%s/images/%d/%s_proxy", - dir, render_size, se->name); + switch(seq->type) { + case SEQ_IMAGE: + snprintf(name, PROXY_MAXFILE, "%s/images/%d/%s_proxy", dir, + render_size, give_stripelem(seq, cfra)->name); frameno = 1; - } else if (seq->type == SEQ_MOVIE) { - frameno = (int) give_stripelem_index(seq, cfra) - + seq->anim_startofs; - + break; + case SEQ_MOVIE: + 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 { - frameno = (int) give_stripelem_index(seq, cfra) - + seq->anim_startofs; - - snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, - render_size); + seq->strip->stripdata->name, render_size); + break; + default: + frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; + snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, render_size); } BLI_path_abs(name, G.main->name); BLI_path_frame(name, frameno, 0); - strcat(name, ".jpg"); return TRUE; @@ -1092,24 +1088,22 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in } if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { - 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)) { + int frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; + if (seq->strip->proxy->anim == NULL) { + if (seq_proxy_get_fname(scene, seq, cfra, name, render_size)==0) { return 0; } seq->strip->proxy->anim = openanim(name, IB_rect); } - if (!seq->strip->proxy->anim) { + if (seq->strip->proxy->anim==NULL) { return 0; } return IMB_anim_absolute(seq->strip->proxy->anim, frameno); } - if (!seq_proxy_get_fname(scene, seq, cfra, name, render_size)) { + if (seq_proxy_get_fname(scene, seq, cfra, name, render_size)==0) { return 0; } @@ -1378,8 +1372,7 @@ static void color_balance_byte_float(Sequence * seq, ImBuf* ibuf, float mul) 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); + make_cb_table_float(cb.lift[c], cb.gain[c], cb.gamma[c], cb_tab[c], mul); } for (i = 0; i < 256; i++) { @@ -1446,13 +1439,8 @@ int input_have_to_preprocess( { 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)) { + if (seq->flag & (SEQ_FILTERY|SEQ_USE_CROP|SEQ_USE_TRANSFORM|SEQ_FLIPX| + SEQ_FLIPY|SEQ_USE_COLOR_BALANCE|SEQ_MAKE_PREMUL)) { return TRUE; } @@ -1474,8 +1462,7 @@ int input_have_to_preprocess( } static ImBuf * input_preprocess( - Scene *scene, Sequence *seq, float UNUSED(cfra), int seqrectx, int seqrecty, - ImBuf * ibuf) + Scene *scene, Sequence *seq, float UNUSED(cfra), int seqrectx, int seqrecty, ImBuf * ibuf) { float mul; @@ -1486,7 +1473,7 @@ static ImBuf * input_preprocess( IMB_filtery(ibuf); } - if(seq->flag & SEQ_USE_CROP || seq->flag & SEQ_USE_TRANSFORM) { + if(seq->flag & (SEQ_USE_CROP|SEQ_USE_TRANSFORM)) { StripCrop c; StripTransform t; int sx,sy,dx,dy; @@ -1511,23 +1498,13 @@ static ImBuf * input_preprocess( dy = scene->r.ysch; } - if (c.top + c.bottom >= ibuf->y || - c.left + c.right >= ibuf->x || - t.xofs >= dx || t.yofs >= dy) { + if (c.top + c.bottom >= ibuf->y || c.left + c.right >= ibuf->x || + t.xofs >= dx || t.yofs >= dy) { make_black_ibuf(ibuf); } else { - ImBuf * i; + ImBuf * i = IMB_allocImBuf(dx, dy,32, ibuf->rect_float ? IB_rectfloat : IB_rect); - if (ibuf->rect_float) { - i = IMB_allocImBuf(dx, dy,32, IB_rectfloat); - } else { - i = IMB_allocImBuf(dx, dy,32, IB_rect); - } - - IMB_rectcpy(i, ibuf, - t.xofs, t.yofs, - c.left, c.bottom, - sx, sy); + IMB_rectcpy(i, ibuf, t.xofs, t.yofs, c.left, c.bottom, sx, sy); IMB_freeImBuf(ibuf); @@ -1602,11 +1579,9 @@ static ImBuf * input_preprocess( if(ibuf->x != seqrectx || ibuf->y != seqrecty ) { if(scene->r.mode & R_OSA) { - IMB_scaleImBuf(ibuf, - (short)seqrectx, (short)seqrecty); + IMB_scaleImBuf(ibuf, (short)seqrectx, (short)seqrecty); } else { - IMB_scalefastImBuf(ibuf, - (short)seqrectx, (short)seqrecty); + IMB_scalefastImBuf(ibuf, (short)seqrectx, (short)seqrecty); } } return ibuf; @@ -1656,34 +1631,32 @@ static void copy_to_ibuf_still(Sequence * seq, float nr, strip rendering functions ********************************************************************** */ -static ImBuf* seq_render_strip_stack( - Main *bmain, Scene *scene, - ListBase *seqbasep, float cfra, int chanshown, int render_size, - int seqrectx, int seqrecty); +static ImBuf* seq_render_strip_stack( Main *bmain, Scene *scene, ListBase *seqbasep, + float cfra, int chanshown, int render_size, int seqrectx, int seqrecty); static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra, - int render_size, - int seqrectx, int seqrecty); + int render_size, int seqrectx, int seqrecty); -static ImBuf* seq_render_effect_strip_impl( - Main *bmain, Scene *scene, float cfra, Sequence *seq, int render_size, - int seqrectx, int seqrecty) +static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra, + Sequence *seq, int render_size, int seqrectx, int seqrecty) { float fac, facf; int early_out; int i; - int must_preprocess = FALSE; - struct SeqEffectHandle sh = get_sequence_effect(seq); FCurve *fcu= NULL; ImBuf * ibuf[3]; - ImBuf * out = 0; + Sequence *input[3]; + ImBuf * out = NULL; + + ibuf[0] = ibuf[1] = ibuf[2] = NULL; - ibuf[0] = ibuf[1] = ibuf[2] = 0; + input[0] = seq->seq1; input[1] = seq->seq2; input[2] = seq->seq3; if (!sh.execute) { /* effect not supported in this version... */ - goto finish; + out = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); + return out; } /* Override render size here, effects need to get the actual @@ -1695,12 +1668,14 @@ static ImBuf* seq_render_effect_strip_impl( */ render_size = 100*seqrectx/scene->r.xsch; - if ((seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) != 0) { + if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) { 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 ((scene->r.mode & R_FIELDS)==0) + 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 ) { @@ -1713,88 +1688,58 @@ static ImBuf* seq_render_effect_strip_impl( early_out = sh.early_out(seq, fac, facf); - if (early_out == -1) { /* no input needed */ + switch (early_out) { + case EARLY_NO_INPUT: out = sh.execute(bmain, scene, seq, cfra, fac, facf, - seqrectx, seqrecty, render_size, - 0, 0, 0); - goto finish; - } - - - must_preprocess = input_have_to_preprocess( - scene, seq, cfra, seqrectx, seqrecty); + seqrectx, seqrecty, render_size, NULL, NULL, NULL); + case EARLY_DO_EFFECT: + for(i=0; i<3; i++) { + if(input[i]) + ibuf[i] = seq_render_strip(bmain, scene, input[i], cfra, + render_size, seqrectx, seqrecty); + } - switch (early_out) { - case 0: + if (ibuf[0] && ibuf[1]) { + out = sh.execute(bmain, scene, seq, cfra, fac, facf, seqrectx, seqrecty, + render_size, ibuf[0], ibuf[1], ibuf[2]); + } break; - case 1: - if (seq->seq1) { - ibuf[0] = seq_render_strip(bmain, scene, seq->seq1, cfra, - render_size, - seqrectx, seqrecty); + case EARLY_USE_INPUT_1: + if (input[0]) { + ibuf[0] = seq_render_strip(bmain, scene, input[0], cfra, + render_size, seqrectx, seqrecty); } if (ibuf[0]) { - if (must_preprocess) { + if (input_have_to_preprocess(scene, seq, cfra, seqrectx, seqrecty)) { out = IMB_dupImBuf(ibuf[0]); } else { out = ibuf[0]; IMB_refImBuf(out); } } - goto finish; - case 2: - if (seq->seq2) { - ibuf[1] = seq_render_strip(bmain, scene, seq->seq2, cfra, - render_size, - seqrectx, seqrecty); + break; + case EARLY_USE_INPUT_2: + if (input[1]) { + ibuf[1] = seq_render_strip(bmain, scene, input[1], cfra, + render_size, seqrectx, seqrecty); } if (ibuf[1]) { - if (must_preprocess) { + if (input_have_to_preprocess(scene, seq, cfra, seqrectx, seqrecty)) { out = IMB_dupImBuf(ibuf[1]); } else { out = ibuf[1]; IMB_refImBuf(out); } } - goto finish; - default: - goto finish; - } - - if (seq->seq1) { - ibuf[0] = seq_render_strip(bmain, scene, seq->seq1, cfra, - render_size, - seqrectx, seqrecty); - } - - if (seq->seq2) { - ibuf[1] = seq_render_strip(bmain, scene, seq->seq2, cfra, - render_size, - seqrectx, seqrecty); - } - - if (seq->seq3) { - ibuf[2] = seq_render_strip(bmain, scene, seq->seq3, cfra, - render_size, - seqrectx, seqrecty); - } - - if (!ibuf[0] || !ibuf[1]) { - goto finish; + break; } - out = sh.execute(bmain, scene, seq, cfra, fac, facf, seqrectx, seqrecty, - render_size, - ibuf[0], ibuf[1], ibuf[2]); - -finish: for (i = 0; i < 3; i++) { IMB_freeImBuf(ibuf[i]); } - if (!out) { - out = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, 32, IB_rect); + if (out == NULL) { + out = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); } return out; @@ -1938,185 +1883,143 @@ static ImBuf * seq_render_scene_strip_impl( } static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra, - int render_size, - int seqrectx, int seqrecty) + int render_size, int seqrectx, int seqrecty) { + ImBuf * ibuf = NULL; 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); + int use_preprocess = input_have_to_preprocess(scene, seq, cfra, seqrectx, seqrecty); float nr = give_stripelem_index(seq, cfra); + /* all effects are handled similarly with the exception of speed effect */ + int type = (seq->type & SEQ_EFFECT && seq->type != SEQ_SPEED) ? SEQ_EFFECT : seq->type; + ibuf = seq_stripelem_cache_get(seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF); + + if (ibuf == NULL) + ibuf = copy_from_ibuf_still(seq,nr,seqrectx,seqrecty); + /* currently, we cache preprocessed images */ - if (ibuf) { + if (ibuf) use_preprocess = FALSE; - } - if(seq->type == SEQ_META) { - ImBuf * meta_ibuf = 0; + if (ibuf == NULL) + ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); - if (ibuf == 0) { - ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); - } + if(ibuf == NULL) switch(type) { + case SEQ_META: + { + ImBuf * meta_ibuf = NULL; - if(!ibuf && seq->seqbase.first) { - meta_ibuf = seq_render_strip_stack( - bmain, scene, - &seq->seqbase, seq->start + nr, 0, - render_size, seqrectx, seqrecty); - } + if(seq->seqbase.first) + meta_ibuf = seq_render_strip_stack(bmain, scene, &seq->seqbase, + seq->start + nr, 0, render_size, seqrectx, seqrecty); - if(!ibuf && meta_ibuf) { - ibuf = meta_ibuf; - if(ibuf && use_preprocess) { - struct ImBuf * i = IMB_dupImBuf(ibuf); + if(meta_ibuf) { + ibuf = meta_ibuf; + if(ibuf && use_preprocess) { + struct ImBuf * i = IMB_dupImBuf(ibuf); - IMB_freeImBuf(ibuf); + IMB_freeImBuf(ibuf); - ibuf = i; + ibuf = i; + } } + break; } - } else if(seq->type == SEQ_SPEED) { - ImBuf * child_ibuf = 0; - - if (ibuf == 0) { - ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); - } + case SEQ_SPEED: + { + ImBuf * child_ibuf = NULL; - if (ibuf == 0) { float f_cfra; - SpeedControlVars * s - = (SpeedControlVars *)seq->effectdata; + SpeedControlVars * s = (SpeedControlVars *)seq->effectdata; sequence_effect_speed_rebuild_map(scene, seq, 0); /* weeek! */ f_cfra = seq->start + s->frameMap[(int) nr]; - child_ibuf = seq_render_strip(bmain, scene, seq->seq1, f_cfra, - render_size, - seqrectx, seqrecty); - } + child_ibuf = seq_render_strip(bmain, scene, seq->seq1, f_cfra, render_size, + seqrectx, seqrecty); - if (!ibuf && child_ibuf) { - ibuf = child_ibuf; - if(ibuf && use_preprocess) { - struct ImBuf * i = IMB_dupImBuf(ibuf); + if (child_ibuf) { + ibuf = child_ibuf; + if(ibuf && use_preprocess) { + struct ImBuf * i = IMB_dupImBuf(ibuf); - IMB_freeImBuf(ibuf); + IMB_freeImBuf(ibuf); - ibuf = i; + ibuf = i; + } } + break; } - } else if(seq->type & SEQ_EFFECT) { - /* should the effect be recalculated? */ - - if (ibuf == 0) { - ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); - } - - if(ibuf == 0) { - ibuf = seq_render_effect_strip_impl( - bmain, scene, cfra, seq, render_size, - seqrectx, seqrecty); - } - } else if(seq->type == SEQ_IMAGE) { - StripElem * s_elem = give_stripelem(seq, cfra); - - if(ibuf == 0 && s_elem) { - BLI_join_dirfile(name, seq->strip->dir, s_elem->name); - BLI_path_abs(name, G.main->name); - - ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); + case SEQ_EFFECT: + { + ibuf = seq_render_effect_strip_impl(bmain, scene, cfra, seq, render_size, + seqrectx, seqrecty); + break; } + case SEQ_IMAGE: + { + StripElem * s_elem = give_stripelem(seq, cfra); - if (ibuf == 0) { - ibuf = copy_from_ibuf_still(seq,nr,seqrectx,seqrecty); - } + if (s_elem) { + BLI_join_dirfile(name, seq->strip->dir, s_elem->name); + BLI_path_abs(name, G.main->name); + } - 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); + if (s_elem && (ibuf = IMB_loadiffname(name, IB_rect))) { + /* we don't need both (speed reasons)! */ + if (ibuf->rect_float && ibuf->rect) + imb_freerectImBuf(ibuf); - /* 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); + /* 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); - 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); + copy_to_ibuf_still(seq, nr, ibuf); + } + break; } - - if (ibuf == 0) { + case SEQ_MOVIE: + { if(seq->anim==0) { - BLI_join_dirfile(name, - seq->strip->dir, - seq->strip->stripdata->name); + BLI_join_dirfile(name, seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(name, G.main->name); - seq->anim = openanim( - name, IB_rect | - ((seq->flag & SEQ_FILTERY) - ? IB_animdeinterlace : 0)); + 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); + 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) { + if (ibuf && ibuf->rect_float && ibuf->rect) imb_freerectImBuf(ibuf); - } } copy_to_ibuf_still(seq, nr, ibuf); + break; } - - } 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(bmain, scene, seq, nr, - seqrectx, seqrecty); + case SEQ_SCENE: + { // scene can be NULL after deletions + ibuf = seq_render_scene_strip_impl(bmain, scene, seq, nr, seqrectx, seqrecty); copy_to_ibuf_still(seq, nr, ibuf); + break; } } - if (!ibuf) { - ibuf = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, 32, IB_rect); - } + if (ibuf == NULL) + ibuf = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); - if (ibuf->x != seqrectx || ibuf->y != seqrecty) { + if (ibuf->x != seqrectx || ibuf->y != seqrecty) use_preprocess = TRUE; - } - if (use_preprocess) { - ibuf = input_preprocess(scene, seq, cfra, seqrectx, - seqrecty, ibuf); - } + if (use_preprocess) + ibuf = input_preprocess(scene, seq, cfra, seqrectx, seqrecty, ibuf); - seq_stripelem_cache_put( - seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF, ibuf); + seq_stripelem_cache_put(seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF, ibuf); return ibuf; } @@ -2132,9 +2035,7 @@ static int seq_must_swap_input_in_blend_mode(Sequence * seq) /* bad hack, to fix crazy input ordering of those two effects */ - if (seq->blend_mode == SEQ_ALPHAOVER || - seq->blend_mode == SEQ_ALPHAUNDER || - seq->blend_mode == SEQ_OVERDROP) { + if (ELEM3(seq->blend_mode, SEQ_ALPHAOVER, SEQ_ALPHAUNDER, SEQ_OVERDROP)) { swap_input = TRUE; } @@ -2147,15 +2048,15 @@ static int seq_get_early_out_for_blend_mode(Sequence * seq) float facf = seq->blend_opacity / 100.0; int early_out = sh.early_out(seq, facf, facf); - if (early_out < 1) { + if (ELEM(early_out, EARLY_DO_EFFECT, EARLY_NO_INPUT)) { return early_out; } if (seq_must_swap_input_in_blend_mode(seq)) { - if (early_out == 2) { - return 1; - } else if (early_out == 1) { - return 2; + if (early_out == EARLY_USE_INPUT_2) { + return EARLY_USE_INPUT_1; + } else if (early_out == EARLY_USE_INPUT_1) { + return EARLY_USE_INPUT_2; } } return early_out; @@ -2168,13 +2069,12 @@ static ImBuf* seq_render_strip_stack( Sequence* seq_arr[MAXSEQ+1]; int count; int i; - ImBuf* out = 0; + ImBuf* out = NULL; - count = get_shown_sequences(seqbasep, cfra, chanshown, - (Sequence **)&seq_arr); + count = get_shown_sequences(seqbasep, cfra, chanshown, (Sequence **)&seq_arr); - if (!count) { - return 0; + if (count == 0) { + return NULL; } #if 0 /* commentind since this breaks keyframing, since it resets the value on draw */ @@ -2185,22 +2085,15 @@ static ImBuf* seq_render_strip_stack( } #endif - out = seq_stripelem_cache_get( - seq_arr[count - 1], - seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP); + out = seq_stripelem_cache_get(seq_arr[count - 1], seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP); if (out) { return out; } if(count == 1) { - out = seq_render_strip(bmain, scene, seq_arr[0], - cfra, render_size, - seqrectx, seqrecty); - seq_stripelem_cache_put( - seq_arr[0], - seqrectx, seqrecty, cfra, - SEQ_STRIPELEM_IBUF_COMP, out); + out = seq_render_strip(bmain, 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; } @@ -2208,43 +2101,33 @@ static ImBuf* seq_render_strip_stack( for (i = count - 1; i >= 0; i--) { int early_out; - Sequence * seq = seq_arr[i]; + Sequence *seq = seq_arr[i]; - out = seq_stripelem_cache_get( - seq, - seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP); + out = seq_stripelem_cache_get(seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP); if (out) { break; } if (seq->blend_mode == SEQ_BLEND_REPLACE) { - out = seq_render_strip(bmain, scene, seq, cfra, - render_size, - seqrectx, seqrecty); + out = seq_render_strip(bmain, scene, seq, cfra, render_size, seqrectx, seqrecty); break; } early_out = seq_get_early_out_for_blend_mode(seq); switch (early_out) { - case -1: - case 2: - out = seq_render_strip(bmain, scene, seq, cfra, - render_size, - seqrectx, seqrecty); + case EARLY_NO_INPUT: + case EARLY_USE_INPUT_2: + out = seq_render_strip(bmain, scene, seq, cfra, render_size, seqrectx, seqrecty); break; - case 1: + case EARLY_USE_INPUT_1: if (i == 0) { - out = IMB_allocImBuf( - (short)seqrectx, (short)seqrecty, - 32, IB_rect); + out = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); } break; - case 0: + case EARLY_DO_EFFECT: if (i == 0) { - out = seq_render_strip(bmain, scene, seq, cfra, - render_size, - seqrectx, seqrecty); + out = seq_render_strip(bmain, scene, seq, cfra, render_size, seqrectx, seqrecty); } break; @@ -2254,9 +2137,7 @@ static ImBuf* seq_render_strip_stack( } } - seq_stripelem_cache_put( - seq_arr[i], seqrectx, seqrecty, cfra, - SEQ_STRIPELEM_IBUF_COMP, out); + seq_stripelem_cache_put(seq_arr[i], seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP, out); i++; @@ -2264,37 +2145,32 @@ static ImBuf* seq_render_strip_stack( for (; i < count; i++) { Sequence * seq = seq_arr[i]; - if (seq_get_early_out_for_blend_mode(seq) == 0) { + if (seq_get_early_out_for_blend_mode(seq) == EARLY_DO_EFFECT) { struct SeqEffectHandle sh = get_sequence_blend(seq); ImBuf * ibuf1 = out; - ImBuf * ibuf2 = seq_render_strip(bmain, scene, seq, cfra, - render_size, - seqrectx, seqrecty); + ImBuf * ibuf2 = seq_render_strip(bmain, scene, seq, cfra, render_size, + seqrectx, seqrecty); float facf = seq->blend_opacity / 100.0; - int swap_input - = seq_must_swap_input_in_blend_mode(seq); + int swap_input = seq_must_swap_input_in_blend_mode(seq); int x= seqrectx; int y= seqrecty; if (swap_input) { - out = sh.execute(bmain, scene, seq, cfra, - facf, facf, x, y, render_size, - ibuf2, ibuf1, 0); + out = sh.execute(bmain, scene, seq, cfra, facf, facf, x, y, + render_size, ibuf2, ibuf1, 0); } else { - out = sh.execute(bmain, scene, seq, cfra, - facf, facf, x, y, render_size, - ibuf1, ibuf2, 0); + out = sh.execute(bmain, scene, seq, cfra, facf, facf, x, y, + render_size, ibuf1, ibuf2, 0); } IMB_freeImBuf(ibuf1); IMB_freeImBuf(ibuf2); } - seq_stripelem_cache_put( - seq_arr[i], seqrectx, seqrecty, cfra, - SEQ_STRIPELEM_IBUF_COMP, out); + seq_stripelem_cache_put(seq_arr[i], seqrectx, seqrecty, cfra, + SEQ_STRIPELEM_IBUF_COMP, out); } return out; @@ -2321,8 +2197,8 @@ ImBuf *give_ibuf_seq(Main *bmain, Scene *scene, int rectx, int recty, int cfra, seqbasep= ed->seqbasep; } - return seq_render_strip_stack( - bmain, 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_seqbase(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int render_size, ListBase *seqbasep) @@ -2543,8 +2419,7 @@ static void seq_stop_threads() } #endif -void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, - int render_size) +void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, int render_size) { PrefetchQueueElem *e; if (seq_thread_shutdown) { @@ -2730,8 +2605,7 @@ void free_imbuf_seq(Scene *scene, ListBase * seqbase, int check_mem_usage, } } if(seq->type==SEQ_META) { - free_imbuf_seq(scene, &seq->seqbase, FALSE, - keep_file_handles); + free_imbuf_seq(scene, &seq->seqbase, FALSE, keep_file_handles); } if(seq->type==SEQ_SCENE) { /* FIXME: recurs downwards, @@ -2855,11 +2729,7 @@ void seq_tx_set_final_right(Sequence *seq, int val) since they work a bit differently to normal image seq's (during transform) */ int seq_single_check(Sequence *seq) { - if ( seq->len==1 && (seq->type == SEQ_IMAGE || seq->type == SEQ_COLOR - || seq->type == SEQ_MULTICAM)) - return 1; - else - return 0; + return (seq->len==1 && ELEM3(seq->type, SEQ_IMAGE, SEQ_COLOR, SEQ_MULTICAM)); } /* check if the selected seq's reference unselected seq's */ @@ -2881,17 +2751,20 @@ int seqbase_isolated_sel_check(ListBase *seqbase) /* test relationships */ for(seq= seqbase->first; seq; seq= seq->next) { + if((seq->type & SEQ_EFFECT)==0) + continue; + if(seq->flag & SELECT) { - if(seq->type & SEQ_EFFECT) { - if(seq->seq1 && (seq->seq1->flag & SELECT)==0) return FALSE; - if(seq->seq2 && (seq->seq2->flag & SELECT)==0) return FALSE; - if(seq->seq3 && (seq->seq3->flag & SELECT)==0) return FALSE; - } + if( (seq->seq1 && (seq->seq1->flag & SELECT)==0) || + (seq->seq2 && (seq->seq2->flag & SELECT)==0) || + (seq->seq3 && (seq->seq3->flag & SELECT)==0) ) + return FALSE; } - else if(seq->type & SEQ_EFFECT) { - if(seq->seq1 && (seq->seq1->flag & SELECT)) return FALSE; - if(seq->seq2 && (seq->seq2->flag & SELECT)) return FALSE; - if(seq->seq3 && (seq->seq3->flag & SELECT)) return FALSE; + else { + if( (seq->seq1 && (seq->seq1->flag & SELECT)) || + (seq->seq2 && (seq->seq2->flag & SELECT)) || + (seq->seq3 && (seq->seq3->flag & SELECT)) ) + return FALSE; } } @@ -2968,12 +2841,8 @@ int seq_tx_test(Sequence * seq) static int seq_overlap(Sequence *seq1, Sequence *seq2) { - if(seq1 != seq2) - if(seq1->machine==seq2->machine) - if(((seq1->enddisp <= seq2->startdisp) || (seq1->startdisp >= seq2->enddisp))==0) - return 1; - - return 0; + return (seq1 != seq2 && seq1->machine == seq2->machine && + ((seq1->enddisp <= seq2->startdisp) || (seq1->startdisp >= seq2->enddisp))==0); } int seq_test_overlap(ListBase * seqbasep, Sequence *test) @@ -3140,7 +3009,7 @@ static void seq_update_muting_recursive(Scene *scene, ListBase *seqbasep, Sequen seq_update_muting_recursive(scene, &seq->seqbase, metaseq, seqmute); } - else if((seq->type == SEQ_SOUND) || (seq->type == SEQ_SCENE)) { + else if(ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) { if(seq->scene_sound) { sound_mute_scene_sound(scene, seq->scene_sound, seqmute); } -- cgit v1.2.3 From 0876fce0094ad3e37be4b197ef8850757eacd37b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 31 Oct 2010 04:11:39 +0000 Subject: rename and negate DISABLE_PYTHON --> WITH_PYTHON --- source/blender/blenkernel/intern/constraint.c | 10 +++++----- source/blender/blenkernel/intern/context.c | 4 ++-- source/blender/blenkernel/intern/exotic.c | 6 +++--- source/blender/blenkernel/intern/fcurve.c | 12 ++++++------ source/blender/blenkernel/intern/fmodifier.c | 4 ++-- source/blender/blenkernel/intern/node.c | 2 +- source/blender/blenkernel/intern/object.c | 2 +- source/blender/blenkernel/intern/script.c | 2 +- source/blender/blenkernel/intern/text.c | 6 +++--- 9 files changed, 24 insertions(+), 24 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 1892f6f0a27..5f387500dd1 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -70,7 +70,7 @@ #include "BKE_shrinkwrap.h" #include "BKE_mesh.h" -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON #include "BPY_extern.h" #endif @@ -1983,7 +1983,7 @@ static void pycon_id_looper (bConstraint *con, ConstraintIDFunc func, void *user /* Whether this approach is maintained remains to be seen (aligorith) */ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON bPythonConstraint *data= con->data; #endif @@ -2003,7 +2003,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT constraint_target_to_mat4(cob->scene, ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); /* only execute target calculation if allowed */ -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON if (G.f & G_SCRIPT_AUTOEXEC) BPY_pyconstraint_target(data, ct); #endif @@ -2014,7 +2014,7 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) { -#ifdef DISABLE_PYTHON +#ifndef WITH_PYTHON (void)con; (void)cob; (void)targets; /* unused */ return; #else @@ -2034,7 +2034,7 @@ static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targ /* Now, run the actual 'constraint' function, which should only access the matrices */ BPY_pyconstraint_eval(data, cob, targets); -#endif /* DISABLE_PYTHON */ +#endif /* WITH_PYTHON */ } static bConstraintTypeInfo CTI_PYTHON = { diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index a5d96baf049..e1a7ef7bbef 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -46,7 +46,7 @@ #include "BKE_main.h" #include "BKE_screen.h" -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON #include "BPY_extern.h" #endif @@ -425,7 +425,7 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res int ret= 0; memset(result, 0, sizeof(bContextDataResult)); -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON if(CTX_py_dict_get(C)) { return BPY_context_get(C, member, result); // if (BPY_context_get(C, member, result)) diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 5e2ca921ef2..a1af728c562 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -79,7 +79,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_curve.h" -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON #include "BPY_extern.h" #endif @@ -489,7 +489,7 @@ int BKE_read_exotic(Scene *scene, char *name) read_stl_mesh_binary(scene, name); retval = 1; } -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON // TODO: this should not be in the kernel... else { // unknown format, call Python importloader if (BPY_call_importloader(name)) { @@ -499,7 +499,7 @@ int BKE_read_exotic(Scene *scene, char *name) } } -#endif /* DISABLE_PYTHON */ +#endif /* WITH_PYTHON */ //XXX waitcursor(0); } } diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 1575f69209f..75029af4b10 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -53,7 +53,7 @@ #include "RNA_access.h" -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON #include "BPY_extern.h" #endif @@ -1174,7 +1174,7 @@ void driver_free_variable (ChannelDriver *driver, DriverVar *dvar) else MEM_freeN(dvar); -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON /* since driver variables are cached, the expression needs re-compiling too */ if(driver->type==DRIVER_TYPE_PYTHON) driver->flag |= DRIVER_FLAG_RENAMEVAR; @@ -1231,7 +1231,7 @@ DriverVar *driver_add_new_variable (ChannelDriver *driver) /* set the default type to 'single prop' */ driver_change_variable_type(dvar, DVAR_TYPE_SINGLE_PROP); -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON /* since driver variables are cached, the expression needs re-compiling too */ if(driver->type==DRIVER_TYPE_PYTHON) driver->flag |= DRIVER_FLAG_RENAMEVAR; @@ -1258,7 +1258,7 @@ void fcurve_free_driver(FCurve *fcu) driver_free_variable(driver, dvar); } -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON /* free compiled driver expression */ if (driver->expr_comp) BPY_DECREF(driver->expr_comp); @@ -1406,7 +1406,7 @@ static float evaluate_driver (ChannelDriver *driver, float UNUSED(evaltime)) case DRIVER_TYPE_PYTHON: /* expression */ { -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON /* check for empty or invalid expression */ if ( (driver->expression[0] == '\0') || (driver->flag & DRIVER_FLAG_INVALID) ) @@ -1420,7 +1420,7 @@ static float evaluate_driver (ChannelDriver *driver, float UNUSED(evaltime)) */ driver->curval= BPY_eval_driver(driver); } -#endif /* DISABLE_PYTHON*/ +#endif /* WITH_PYTHON*/ } break; diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index c900f178ca7..5ef41d17d63 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -802,13 +802,13 @@ static void fcm_python_copy (FModifier *fcm, FModifier *src) static void fcm_python_evaluate (FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *UNUSED(cvalue), float UNUSED(evaltime)) { -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON //FMod_Python *data= (FMod_Python *)fcm->data; /* FIXME... need to implement this modifier... * It will need it execute a script using the custom properties */ -#endif /* DISABLE_PYTHON */ +#endif /* WITH_PYTHON */ } static FModifierTypeInfo FMI_PYTHON = { diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 6b53e538f8e..41c4fece1a4 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -27,7 +27,7 @@ * ***** END GPL LICENSE BLOCK ***** */ -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON #include #endif diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 5ade08478a2..e006c48aca5 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -96,7 +96,7 @@ #include "LBM_fluidsim.h" -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON #include "BPY_extern.h" #endif diff --git a/source/blender/blenkernel/intern/script.c b/source/blender/blenkernel/intern/script.c index c07032f71d7..6ffac09e843 100644 --- a/source/blender/blenkernel/intern/script.c +++ b/source/blender/blenkernel/intern/script.c @@ -36,7 +36,7 @@ /* -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON #include "BPY_extern.h" // Blender Python library #endif */ diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index cb3c0c08cc0..09910481bf9 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -53,7 +53,7 @@ #include "BKE_text.h" #include "BKE_utildefines.h" -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON #include "BPY_extern.h" #endif @@ -167,7 +167,7 @@ void free_text(Text *text) if(text->name) MEM_freeN(text->name); MEM_freeN(text->undo_buf); -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON if (text->compiled) BPY_free_compiled_text(text); #endif } @@ -683,7 +683,7 @@ int txt_get_span (TextLine *from, TextLine *to) static void txt_make_dirty (Text *text) { text->flags |= TXT_ISDIRTY; -#ifndef DISABLE_PYTHON +#ifdef WITH_PYTHON if (text->compiled) BPY_free_compiled_text(text); #endif } -- cgit v1.2.3 From 3367ef8b6591b62b1b76f07fccb310485f6d45c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 31 Oct 2010 15:39:37 +0000 Subject: initialize structs to zero rather then using memset(). --- source/blender/blenkernel/intern/action.c | 3 +-- source/blender/blenkernel/intern/brush.c | 8 ++------ source/blender/blenkernel/intern/constraint.c | 3 +-- source/blender/blenkernel/intern/context.c | 3 +-- source/blender/blenkernel/intern/multires.c | 6 ++---- source/blender/blenkernel/intern/seqeffects.c | 8 ++------ source/blender/blenkernel/intern/sequencer.c | 7 ++----- source/blender/blenkernel/intern/shrinkwrap.c | 3 +-- source/blender/blenkernel/intern/subsurf_ccg.c | 4 +--- 9 files changed, 13 insertions(+), 32 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 5a96575452b..902807126c9 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1134,10 +1134,9 @@ void what_does_obaction (Scene *UNUSED(scene), Object *ob, Object *workob, bPose animsys_evaluate_action_group(&id_ptr, act, agrp, NULL, cframe); } else { - AnimData adt; + AnimData adt= {0}; /* init animdata, and attach to workob */ - memset(&adt, 0, sizeof(AnimData)); workob->adt= &adt; adt.recalc= ADT_RECALC_ANIM; diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index d894aef4ac5..7a10f9082e5 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -228,10 +228,8 @@ 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 def= {{0}}; brush_set_defaults(&def); #define BR_TEST(field, t) \ @@ -1098,11 +1096,9 @@ unsigned int *brush_gen_texture_cache(Brush *br, int half_side) { unsigned int *texcache = NULL; MTex *mtex = &br->mtex; - TexResult texres; + TexResult texres= {0}; int hasrgb, ix, iy; int side = half_side * 2; - - memset(&texres, 0, sizeof(TexResult)); if(mtex->tex) { float x, y, step = 2.0 / side, co[3]; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 5f387500dd1..bf694732b46 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3427,8 +3427,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr BVHTreeRayHit hit; BVHTreeNearest nearest; - BVHTreeFromMesh treeData; - memset(&treeData, 0, sizeof(treeData)); + BVHTreeFromMesh treeData= {0}; nearest.index = -1; nearest.dist = FLT_MAX; diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index e1a7ef7bbef..899ae6031d6 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -554,8 +554,7 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member) return result.list; } else { - ListBase list; - memset(&list, 0, sizeof(list)); + ListBase list= {NULL, NULL}; return list; } } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index b6e48a12676..5324d5dde62 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -492,9 +492,8 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple) { - MultiresModifierData mmd; + MultiresModifierData mmd= {{0}}; - memset(&mmd, 0, sizeof(MultiresModifierData)); mmd.lvl = lvl; mmd.sculptlvl = lvl; mmd.renderlvl = lvl; @@ -506,9 +505,8 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv static DerivedMesh *subsurf_dm_create_local(Object *UNUSED(ob), DerivedMesh *dm, int lvl, int simple, int optimal) { - SubsurfModifierData smd; + SubsurfModifierData smd= {{0}}; - memset(&smd, 0, sizeof(SubsurfModifierData)); smd.levels = smd.renderLevels = lvl; smd.flags |= eSubsurfModifierFlag_SubsurfUv; if(simple) diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 66cad5090f8..b8307a9fb04 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -3260,9 +3260,7 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) struct SeqEffectHandle get_sequence_effect(Sequence * seq) { - struct SeqEffectHandle rval; - - memset(&rval, 0, sizeof(struct SeqEffectHandle)); + struct SeqEffectHandle rval= {0}; if (seq->type & SEQ_EFFECT) { rval = get_sequence_effect_impl(seq->type); @@ -3277,9 +3275,7 @@ struct SeqEffectHandle get_sequence_effect(Sequence * seq) struct SeqEffectHandle get_sequence_blend(Sequence * seq) { - struct SeqEffectHandle rval; - - memset(&rval, 0, sizeof(struct SeqEffectHandle)); + struct SeqEffectHandle rval= {0}; if (seq->blend_mode != 0) { rval = get_sequence_effect_impl(seq->blend_mode); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index c379ca43f82..0207340bd32 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1474,13 +1474,10 @@ static ImBuf * input_preprocess( } if(seq->flag & (SEQ_USE_CROP|SEQ_USE_TRANSFORM)) { - StripCrop c; - StripTransform t; + StripCrop c= {0}; + StripTransform t= {0}; int sx,sy,dx,dy; - memset(&c, 0, sizeof(StripCrop)); - memset(&t, 0, sizeof(StripTransform)); - if(seq->flag & SEQ_USE_CROP && seq->strip->crop) { c = *seq->strip->crop; } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index f64854f90de..4746341876f 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -559,8 +559,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Scene *scene, Object //Using vertexs positions/normals as if a subsurface was applied if(smd->subsurfLevels) { - SubsurfModifierData ssmd; - memset(&ssmd, 0, sizeof(ssmd)); + SubsurfModifierData ssmd= {{0}}; ssmd.subdivType = ME_CC_SUBSURF; //catmull clark ssmd.levels = smd->subsurfLevels; //levels diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 26bd981db4a..56491b8d692 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1357,7 +1357,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, v CCGSubSurf *ss = ccgdm->ss; CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); GPUVertexAttribs gattribs; - DMVertexAttribs attribs; + DMVertexAttribs attribs= {{{0}}}; MTFace *tf = dm->getFaceDataArray(dm, CD_MTFACE); int gridSize = ccgSubSurf_getGridSize(ss); int gridFaces = gridSize - 1; @@ -1374,8 +1374,6 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, v transp = GPU_get_material_blend_mode(); orig_transp = transp; - memset(&attribs, 0, sizeof(attribs)); - #define PASSATTRIB(dx, dy, vert) { \ if(attribs.totorco) { \ index = getFaceIndex(ss, f, S, x+dx, y+dy, edgeSize, gridSize); \ -- cgit v1.2.3 From daa4feaaeae4312eb23f66b948b668a7e9dc1959 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 1 Nov 2010 07:19:41 +0000 Subject: bugfix [#24477] Can easily create bones with duplicate names - fixed this error 7 different functions (deform groups, uv layers & similar). - support for numbers over 999. - renamed splitIDname() to BLI_split_name_num(), moved to BLI_path_utils --- source/blender/blenkernel/intern/customdata.c | 93 ++++++++++++--------------- source/blender/blenkernel/intern/deform.c | 68 ++++++++------------ source/blender/blenkernel/intern/library.c | 33 +--------- source/blender/blenkernel/intern/mball.c | 18 +++--- source/blender/blenkernel/intern/nla.c | 32 ++++----- 5 files changed, 92 insertions(+), 152 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 9c4f0d790ca..c1aaa869876 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2249,69 +2249,56 @@ static int CustomData_is_property_layer(int type) return 0; } -void CustomData_set_layer_unique_name(CustomData *data, int index) +static int cd_layer_find_dupe(CustomData *data, const char *name, int type, int index) { - char tempname[64]; - int number, i, type; - char *dot, *name; - CustomDataLayer *layer, *nlayer= &data->layers[index]; - const LayerTypeInfo *typeInfo= layerType_getInfo(nlayer->type); - - if (!typeInfo->defaultname) - return; - - type = nlayer->type; - name = nlayer->name; - - if (name[0] == '\0') - BLI_strncpy(nlayer->name, typeInfo->defaultname, sizeof(nlayer->name)); - + int i; /* see if there is a duplicate */ for(i=0; itotlayer; i++) { - layer = &data->layers[i]; - - if(CustomData_is_property_layer(type)){ - if(i!=index && CustomData_is_property_layer(layer->type) && - strcmp(layer->name, name)==0) - break; - - } - else{ - if(i!=index && layer->type==type && strcmp(layer->name, name)==0) - break; + if(i != index) { + CustomDataLayer *layer= &data->layers[i]; + + if(CustomData_is_property_layer(type)) { + if(CustomData_is_property_layer(layer->type) && strcmp(layer->name, name)==0) { + return 1; + } + } + else{ + if(i!=index && layer->type==type && strcmp(layer->name, name)==0) { + return 1; + } + } } } + + return 0; +} - if(i == data->totlayer) - return; +void CustomData_set_layer_unique_name(CustomData *data, int index) +{ + CustomDataLayer *nlayer= &data->layers[index]; + const LayerTypeInfo *typeInfo= layerType_getInfo(nlayer->type); - /* strip off the suffix */ - dot = strchr(nlayer->name, '.'); - if(dot) *dot=0; - - for(number=1; number <=999; number++) { - sprintf(tempname, "%s.%03d", nlayer->name, number); + if (!typeInfo->defaultname) + return; - for(i=0; itotlayer; i++) { - layer = &data->layers[i]; - - if(CustomData_is_property_layer(type)){ - if(i!=index && CustomData_is_property_layer(layer->type) && - strcmp(layer->name, tempname)==0) + if (nlayer->name[0] == '\0') + BLI_strncpy(nlayer->name, typeInfo->defaultname, sizeof(nlayer->name)); - break; + if(cd_layer_find_dupe(data, nlayer->name, nlayer->type, index)) { + /* note: this block is used in other places, when changing logic apply to all others, search this message */ + char tempname[sizeof(nlayer->name)]; + char left[sizeof(nlayer->name)]; + int number; + int len= BLI_split_name_num(left, &number, nlayer->name); + do { /* nested while loop looks bad but likely it wont run most times */ + while(BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", left, number) >= sizeof(tempname)) { + if(len > 0) left[--len]= '\0'; /* word too long */ + else number= 0; /* reset, must be a massive number */ } - else{ - if(i!=index && layer->type==type && strcmp(layer->name, tempname)==0) - break; - } - } - - if(i == data->totlayer) { - BLI_strncpy(nlayer->name, tempname, sizeof(nlayer->name)); - return; - } - } + } while(number++, cd_layer_find_dupe(data, tempname, nlayer->type, index)); + + BLI_strncpy(nlayer->name, tempname, sizeof(nlayer->name)); + } } int CustomData_verify_versions(struct CustomData *data, int index) diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 91584b6236f..10fbd247c84 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -304,14 +304,23 @@ int defgroup_flip_index(Object *ob, int index, int use_default) return (flip_index==-1 && use_default) ? index : flip_index; } -void defgroup_unique_name (bDeformGroup *dg, Object *ob) +static int defgroup_find_name_dupe(const char *name, bDeformGroup *dg, Object *ob) { bDeformGroup *curdef; - int number; - int exists = 0; - char tempname[64]; - char *dot; + for (curdef = ob->defbase.first; curdef; curdef=curdef->next) { + if (dg!=curdef) { + if (!strcmp(curdef->name, name)) { + return 1; + } + } + } + + return 0; +} + +void defgroup_unique_name (bDeformGroup *dg, Object *ob) +{ if (!ob) return; @@ -320,44 +329,23 @@ void defgroup_unique_name (bDeformGroup *dg, Object *ob) /* give it default name first */ strcpy (dg->name, "Group"); } - - /* See if we even need to do this */ - for (curdef = ob->defbase.first; curdef; curdef=curdef->next) { - if (dg!=curdef) { - if (!strcmp(curdef->name, dg->name)) { - exists = 1; - break; - } - } - } - - if (!exists) - return; - /* Strip off the suffix */ - dot=strchr(dg->name, '.'); - if (dot) - *dot=0; - - for (number = 1; number <=999; number++) { - sprintf (tempname, "%s.%03d", dg->name, number); - - exists = 0; - for (curdef=ob->defbase.first; curdef; curdef=curdef->next) { - if (dg!=curdef) { - if (!strcmp (curdef->name, tempname)) { - exists = 1; - break; - } + if(defgroup_find_name_dupe(dg->name, dg, ob)) { + /* note: this block is used in other places, when changing logic apply to all others, search this message */ + char tempname[sizeof(dg->name)]; + char left[sizeof(dg->name)]; + int number; + int len= BLI_split_name_num(left, &number, dg->name); + do { /* nested while loop looks bad but likely it wont run most times */ + while(BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", left, number) >= sizeof(tempname)) { + if(len > 0) left[--len]= '\0'; /* word too long */ + else number= 0; /* reset, must be a massive number */ } - } - if (!exists) { - BLI_strncpy (dg->name, tempname, 32); - return; - } - } -} + } while(number++, defgroup_find_name_dupe(tempname, dg, ob)); + BLI_strncpy(dg->name, tempname, sizeof(dg->name)); + } +} /* finds the best possible flipped name. For renaming; check for unique names afterwards */ /* if strip_number: removes number extensions */ diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index dc3c120ab19..4227c633c0b 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -984,35 +984,6 @@ void IMAnames_to_pupstring(char **str, char *title, char *extraops, ListBase *lb BLI_dynstr_free(pupds); } - -/* used by buttons.c library.c mball.c */ -int splitIDname(char *name, char *left, int *nr) -{ - int a; - - *nr= 0; - strncpy(left, name, 21); - - a= strlen(name); - if(a>1 && name[a-1]=='.') return a; - - while(a--) { - if( name[a]=='.' ) { - left[a]= 0; - *nr= atol(name+a+1); - return a; - } - if( isdigit(name[a])==0 ) break; - - left[a]= 0; - } - - for(a= 0; name[a]; a++) - left[a]= name[a]; - - return a; -} - static void sort_alpha_id(ListBase *lb, ID *id) { ID *idtest; @@ -1092,7 +1063,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) memset(in_use, 0, sizeof(in_use)); /* get name portion, number portion ("name.number") */ - left_len= splitIDname(name, left, &nr); + left_len= BLI_split_name_num(left, &nr, name); /* if new name will be too long, truncate it */ if(nr > 999 && left_len > 16) { @@ -1109,7 +1080,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) (idtest->lib == NULL) && (*name == *(idtest->name+2)) && (strncmp(name, idtest->name+2, left_len)==0) && - (splitIDname(idtest->name+2, leftest, &nrtest) == left_len) + (BLI_split_name_num(leftest, &nrtest, idtest->name+2) == left_len) ) { if(nrtest < sizeof(in_use)) in_use[nrtest]= 1; /* mark as used */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index e6f38e04d76..fd3bc47da9e 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -330,8 +330,8 @@ int is_mball_basis_for(Object *ob1, Object *ob2) int basis1nr, basis2nr; char basis1name[32], basis2name[32]; - splitIDname(ob1->id.name+2, basis1name, &basis1nr); - splitIDname(ob2->id.name+2, basis2name, &basis2nr); + BLI_split_name_num(basis1name, &basis1nr, ob1->id.name+2); + BLI_split_name_num(basis2name, &basis2nr, ob2->id.name+2); if(!strcmp(basis1name, basis2name)) return is_basis_mball(ob1); else return 0; @@ -352,7 +352,7 @@ void copy_mball_properties(Scene *scene, Object *active_object) int basisnr, obnr; char basisname[32], obname[32]; - splitIDname(active_object->id.name+2, basisname, &basisnr); + BLI_split_name_num(basisname, &basisnr, active_object->id.name+2); /* XXX recursion check, see scene.c, just too simple code this next_object() */ if(F_ERROR==next_object(&sce_iter, 0, 0, 0)) @@ -361,7 +361,7 @@ void copy_mball_properties(Scene *scene, Object *active_object) while(next_object(&sce_iter, 1, &base, &ob)) { if (ob->type==OB_MBALL) { if(ob!=active_object){ - splitIDname(ob->id.name+2, obname, &obnr); + BLI_split_name_num(obname, &obnr, ob->id.name+2); /* Object ob has to be in same "group" ... it means, that it has to have * same base of its name */ @@ -394,8 +394,8 @@ Object *find_basis_mball(Scene *scene, Object *basis) MetaElem *ml=NULL; int basisnr, obnr; char basisname[32], obname[32]; - - splitIDname(basis->id.name+2, basisname, &basisnr); + + BLI_split_name_num(basisname, &basisnr, basis->id.name+2); totelem= 0; /* XXX recursion check, see scene.c, just too simple code this next_object() */ @@ -415,7 +415,7 @@ Object *find_basis_mball(Scene *scene, Object *basis) else ml= mb->elems.first; } else{ - splitIDname(ob->id.name+2, obname, &obnr); + BLI_split_name_num(obname, &obnr, ob->id.name+2); /* object ob has to be in same "group" ... it means, that it has to have * same base of its name */ @@ -1572,7 +1572,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ invert_m4_m4(obinv, ob->obmat); a= 0; - splitIDname(ob->id.name+2, obname, &obnr); + BLI_split_name_num(obname, &obnr, ob->id.name+2); /* make main array */ next_object(&sce_iter, 0, 0, 0); @@ -1593,7 +1593,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ char name[32]; int nr; - splitIDname(bob->id.name+2, name, &nr); + BLI_split_name_num(name, &nr, bob->id.name+2); if( strcmp(obname, name)==0 ) { mb= bob->data; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 67c3e746a63..6c8eb69703f 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1260,27 +1260,21 @@ void BKE_nlastrip_validate_name (AnimData *adt, NlaStrip *strip) * - in an extreme case, it might not be able to find a name, but then everything else in Blender would fail too :) */ if (BLI_ghash_haskey(gh, strip->name)) { - char tempname[128]; - int number = 1; - char *dot; - - /* Strip off the suffix */ - 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.%03d", strip->name, number); - - /* if hash doesn't have this, set it */ - if (BLI_ghash_haskey(gh, tempname) == 0) { - BLI_strncpy(strip->name, tempname, sizeof(strip->name)); - break; + /* note: this block is used in other places, when changing logic apply to all others, search this message */ + char tempname[sizeof(strip->name)]; + char left[sizeof(strip->name)]; + int number; + int len= BLI_split_name_num(left, &number, strip->name); + do { /* nested while loop looks bad but likely it wont run most times */ + while(BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", left, number) >= sizeof(tempname)) { + if(len > 0) left[--len]= '\0'; /* word too long */ + else number= 0; /* reset, must be a massive number */ } - } - } + } while(number++, BLI_ghash_haskey(gh, tempname)); + BLI_strncpy(strip->name, tempname, sizeof(strip->name)); + } + /* free the hash... */ BLI_ghash_free(gh, NULL, NULL); } -- cgit v1.2.3 From f890b00851317a9acd8e4f784b99bf2986c8b872 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Mon, 1 Nov 2010 18:55:12 +0000 Subject: Sequencer: fix for the fix of: #23318 also known as: broken multicam strip caused by other fix. Calculated render_size where it belongs (within the glow effect) and restored old functionality. also: renamed render_size to preview_render_size at all relevant places, where the naming wasn't used correctly. Hopefully it's now a little bit more clear. render_size := render size from scene (just rescales width/height) preview_render_size := preview render size from sequencer preview, controls the resolution and the use of sequencer proxy sources --- source/blender/blenkernel/intern/seqeffects.c | 6 +- source/blender/blenkernel/intern/sequencer.c | 111 ++++++++++++-------------- 2 files changed, 55 insertions(+), 62 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index b8307a9fb04..f5dc04ca569 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2660,14 +2660,16 @@ static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, fl } static struct ImBuf * do_glow_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float UNUSED(cfra), + Main *UNUSED(bmain), Scene * scene, Sequence *seq, float UNUSED(cfra), float facf0, float facf1, int x, int y, - int render_size, + int UNUSED(preview_render_size), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + int render_size = 100*x/scene->r.xsch; + if (out->rect_float) { do_glow_effect_float(seq, render_size, facf0, facf1, x, y, diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 0207340bd32..ef470821d22 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1022,7 +1022,7 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se #define PROXY_MAXFILE (2*FILE_MAXDIR+FILE_MAXFILE) -static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, char * name, int render_size) +static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, char * name, int preview_render_size) { int frameno; char dir[FILE_MAXDIR]; @@ -1053,17 +1053,17 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c switch(seq->type) { case SEQ_IMAGE: snprintf(name, PROXY_MAXFILE, "%s/images/%d/%s_proxy", dir, - render_size, give_stripelem(seq, cfra)->name); + preview_render_size, give_stripelem(seq, cfra)->name); frameno = 1; break; case SEQ_MOVIE: frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; snprintf(name, PROXY_MAXFILE, "%s/%s/%d/####", dir, - seq->strip->stripdata->name, render_size); + seq->strip->stripdata->name, preview_render_size); break; default: frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; - snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, render_size); + snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, preview_render_size); } BLI_path_abs(name, G.main->name); @@ -1074,7 +1074,7 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c return TRUE; } -static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, int render_size) +static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, int preview_render_size) { char name[PROXY_MAXFILE]; @@ -1083,14 +1083,14 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in } /* rendering at 100% ? No real sense in proxy-ing, right? */ - if (render_size == 100) { + if (preview_render_size == 100) { return 0; } if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { int frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; if (seq->strip->proxy->anim == NULL) { - if (seq_proxy_get_fname(scene, seq, cfra, name, render_size)==0) { + if (seq_proxy_get_fname(scene, seq, cfra, name, preview_render_size)==0) { return 0; } @@ -1103,7 +1103,7 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in return IMB_anim_absolute(seq->strip->proxy->anim, frameno); } - if (seq_proxy_get_fname(scene, seq, cfra, name, render_size)==0) { + if (seq_proxy_get_fname(scene, seq, cfra, name, preview_render_size)==0) { return 0; } @@ -1116,9 +1116,9 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in #if 0 static void do_build_seq_ibuf(Scene *scene, Sequence * seq, TStripElem *se, int cfra, - int build_proxy_run, int render_size); + int build_proxy_run, int preview_render_size); -static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int render_size, int seqrectx, int seqrecty) +static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int preview_render_size, int seqrectx, int seqrecty) { char name[PROXY_MAXFILE]; int quality; @@ -1132,7 +1132,7 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int re } /* rendering at 100% ? No real sense in proxy-ing, right? */ - if (render_size == 100) { + if (preview_render_size == 100) { return; } @@ -1141,7 +1141,7 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int re return; } - if (!seq_proxy_get_fname(scene, seq, cfra, name, render_size)) { + if (!seq_proxy_get_fname(scene, seq, cfra, name, preview_render_size)) { return; } @@ -1155,15 +1155,15 @@ static void seq_proxy_build_frame(Scene *scene, Sequence * seq, int cfra, int re se->ibuf = 0; } - do_build_seq_ibuf(scene, seq, se, cfra, TRUE, render_size, + do_build_seq_ibuf(scene, seq, se, cfra, TRUE, preview_render_size, seqrectx, seqrecty); if (!se->ibuf) { return; } - rectx= (render_size*scene->r.xsch)/100; - recty= (render_size*scene->r.ysch)/100; + rectx= (preview_render_size*scene->r.xsch)/100; + recty= (preview_render_size*scene->r.ysch)/100; ibuf = se->ibuf; @@ -1629,14 +1629,14 @@ static void copy_to_ibuf_still(Sequence * seq, float nr, ********************************************************************** */ static ImBuf* seq_render_strip_stack( Main *bmain, Scene *scene, ListBase *seqbasep, - float cfra, int chanshown, int render_size, int seqrectx, int seqrecty); + float cfra, int chanshown, int preview_render_size, int seqrectx, int seqrecty); static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra, - int render_size, int seqrectx, int seqrecty); + int preview_render_size, int seqrectx, int seqrecty); static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra, - Sequence *seq, int render_size, int seqrectx, int seqrecty) + Sequence *seq, int preview_render_size, int seqrectx, int seqrecty) { float fac, facf; int early_out; @@ -1656,15 +1656,6 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra return out; } - /* Override render size here, effects need to get the actual - * ratio so they can scale appropriately. This whole business - * with render size, proxy size, and seqrectx, etc. is a bit - * complicated and should probably be cleaned up and handled - * properly way before we get to this point. -jahka - * (fix for bug #23318) - */ - render_size = 100*seqrectx/scene->r.xsch; - if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) { sh.get_default_fac(seq, cfra, &fac, &facf); @@ -1688,23 +1679,23 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra switch (early_out) { case EARLY_NO_INPUT: out = sh.execute(bmain, scene, seq, cfra, fac, facf, - seqrectx, seqrecty, render_size, NULL, NULL, NULL); + seqrectx, seqrecty, preview_render_size, NULL, NULL, NULL); case EARLY_DO_EFFECT: for(i=0; i<3; i++) { if(input[i]) ibuf[i] = seq_render_strip(bmain, scene, input[i], cfra, - render_size, seqrectx, seqrecty); + preview_render_size, seqrectx, seqrecty); } if (ibuf[0] && ibuf[1]) { out = sh.execute(bmain, scene, seq, cfra, fac, facf, seqrectx, seqrecty, - render_size, ibuf[0], ibuf[1], ibuf[2]); + preview_render_size, ibuf[0], ibuf[1], ibuf[2]); } break; case EARLY_USE_INPUT_1: if (input[0]) { ibuf[0] = seq_render_strip(bmain, scene, input[0], cfra, - render_size, seqrectx, seqrecty); + preview_render_size, seqrectx, seqrecty); } if (ibuf[0]) { if (input_have_to_preprocess(scene, seq, cfra, seqrectx, seqrecty)) { @@ -1718,7 +1709,7 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra case EARLY_USE_INPUT_2: if (input[1]) { ibuf[1] = seq_render_strip(bmain, scene, input[1], cfra, - render_size, seqrectx, seqrecty); + preview_render_size, seqrectx, seqrecty); } if (ibuf[1]) { if (input_have_to_preprocess(scene, seq, cfra, seqrectx, seqrecty)) { @@ -1880,7 +1871,7 @@ static ImBuf * seq_render_scene_strip_impl( } static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra, - int render_size, int seqrectx, int seqrecty) + int preview_render_size, int seqrectx, int seqrecty) { ImBuf * ibuf = NULL; char name[FILE_MAXDIR+FILE_MAXFILE]; @@ -1899,7 +1890,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float use_preprocess = FALSE; if (ibuf == NULL) - ibuf = seq_proxy_fetch(scene, seq, cfra, render_size); + ibuf = seq_proxy_fetch(scene, seq, cfra, preview_render_size); if(ibuf == NULL) switch(type) { case SEQ_META: @@ -1908,7 +1899,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float if(seq->seqbase.first) meta_ibuf = seq_render_strip_stack(bmain, scene, &seq->seqbase, - seq->start + nr, 0, render_size, seqrectx, seqrecty); + seq->start + nr, 0, preview_render_size, seqrectx, seqrecty); if(meta_ibuf) { ibuf = meta_ibuf; @@ -1934,7 +1925,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float /* weeek! */ f_cfra = seq->start + s->frameMap[(int) nr]; - child_ibuf = seq_render_strip(bmain, scene, seq->seq1, f_cfra, render_size, + child_ibuf = seq_render_strip(bmain, scene, seq->seq1, f_cfra, preview_render_size, seqrectx, seqrecty); if (child_ibuf) { @@ -1951,7 +1942,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float } case SEQ_EFFECT: { - ibuf = seq_render_effect_strip_impl(bmain, scene, cfra, seq, render_size, + ibuf = seq_render_effect_strip_impl(bmain, scene, cfra, seq, preview_render_size, seqrectx, seqrecty); break; } @@ -2061,7 +2052,7 @@ static int seq_get_early_out_for_blend_mode(Sequence * seq) static ImBuf* seq_render_strip_stack( Main *bmain, Scene *scene, ListBase *seqbasep, float cfra, int chanshown, - int render_size, int seqrectx, int seqrecty) + int preview_render_size, int seqrectx, int seqrecty) { Sequence* seq_arr[MAXSEQ+1]; int count; @@ -2089,7 +2080,7 @@ static ImBuf* seq_render_strip_stack( } if(count == 1) { - out = seq_render_strip(bmain, scene, seq_arr[0], cfra, render_size, seqrectx, seqrecty); + out = seq_render_strip(bmain, scene, seq_arr[0], cfra, preview_render_size, seqrectx, seqrecty); seq_stripelem_cache_put(seq_arr[0], seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP, out); return out; @@ -2106,7 +2097,7 @@ static ImBuf* seq_render_strip_stack( break; } if (seq->blend_mode == SEQ_BLEND_REPLACE) { - out = seq_render_strip(bmain, scene, seq, cfra, render_size, seqrectx, seqrecty); + out = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, seqrectx, seqrecty); break; } @@ -2115,7 +2106,7 @@ static ImBuf* seq_render_strip_stack( switch (early_out) { case EARLY_NO_INPUT: case EARLY_USE_INPUT_2: - out = seq_render_strip(bmain, scene, seq, cfra, render_size, seqrectx, seqrecty); + out = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, seqrectx, seqrecty); break; case EARLY_USE_INPUT_1: if (i == 0) { @@ -2124,7 +2115,7 @@ static ImBuf* seq_render_strip_stack( break; case EARLY_DO_EFFECT: if (i == 0) { - out = seq_render_strip(bmain, scene, seq, cfra, render_size, seqrectx, seqrecty); + out = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, seqrectx, seqrecty); } break; @@ -2145,7 +2136,7 @@ static ImBuf* seq_render_strip_stack( if (seq_get_early_out_for_blend_mode(seq) == EARLY_DO_EFFECT) { struct SeqEffectHandle sh = get_sequence_blend(seq); ImBuf * ibuf1 = out; - ImBuf * ibuf2 = seq_render_strip(bmain, scene, seq, cfra, render_size, + ImBuf * ibuf2 = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, seqrectx, seqrecty); float facf = seq->blend_opacity / 100.0; @@ -2156,10 +2147,10 @@ static ImBuf* seq_render_strip_stack( if (swap_input) { out = sh.execute(bmain, scene, seq, cfra, facf, facf, x, y, - render_size, ibuf2, ibuf1, 0); + preview_render_size, ibuf2, ibuf1, 0); } else { out = sh.execute(bmain, scene, seq, cfra, facf, facf, x, y, - render_size, ibuf1, ibuf2, 0); + preview_render_size, ibuf1, ibuf2, 0); } IMB_freeImBuf(ibuf1); @@ -2178,7 +2169,7 @@ static ImBuf* seq_render_strip_stack( * you have to free after usage! */ -ImBuf *give_ibuf_seq(Main *bmain, 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 preview_render_size) { Editing *ed= seq_give_editing(scene, FALSE); int count; @@ -2195,18 +2186,18 @@ ImBuf *give_ibuf_seq(Main *bmain, Scene *scene, int rectx, int recty, int cfra, } return seq_render_strip_stack(bmain, scene, seqbasep, cfra, chanshown, - render_size, rectx, recty); + preview_render_size, rectx, recty); } -ImBuf *give_ibuf_seqbase(Main *bmain, 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 preview_render_size, ListBase *seqbasep) { - return seq_render_strip_stack(bmain, scene, seqbasep, cfra, chanshown, render_size, rectx, recty); + return seq_render_strip_stack(bmain, scene, seqbasep, cfra, chanshown, preview_render_size, rectx, recty); } -ImBuf *give_ibuf_seq_direct(Main *bmain, 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 preview_render_size, Sequence *seq) { - return seq_render_strip(bmain, scene, seq, cfra, render_size, rectx, recty); + return seq_render_strip(bmain, scene, seq, cfra, preview_render_size, rectx, recty); } #if 0 @@ -2258,7 +2249,7 @@ typedef struct PrefetchQueueElem { int recty; int cfra; int chanshown; - int render_size; + int preview_render_size; int monoton_cfra; @@ -2306,7 +2297,7 @@ static void *seq_prefetch_thread(void * This_) if (e->cfra >= s_last) { e->ibuf = give_ibuf_seq_impl(This->scene, e->rectx, e->recty, e->cfra, e->chanshown, - e->render_size); + e->preview_render_size); } pthread_mutex_lock(&queue_lock); @@ -2416,7 +2407,7 @@ static void seq_stop_threads() } #endif -void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, int render_size) +void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, int preview_render_size) { PrefetchQueueElem *e; if (seq_thread_shutdown) { @@ -2428,7 +2419,7 @@ void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, i e->recty = recty; e->cfra = cfra; e->chanshown = chanshown; - e->render_size = render_size; + e->preview_render_size = preview_render_size; e->monoton_cfra = monoton_cfra++; pthread_mutex_lock(&queue_lock); @@ -2471,13 +2462,13 @@ static void seq_wait_for_prefetch_ready() } #endif -ImBuf *give_ibuf_seq_threaded(Main *bmain, 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 preview_render_size) { PrefetchQueueElem *e = NULL; int found_something = FALSE; if (seq_thread_shutdown) { - return give_ibuf_seq(bmain, scene, rectx, recty, cfra, chanshown, render_size); + return give_ibuf_seq(bmain, scene, rectx, recty, cfra, chanshown, preview_render_size); } while (!e) { @@ -2489,7 +2480,7 @@ ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, i chanshown == e->chanshown && rectx == e->rectx && recty == e->recty && - render_size == e->render_size) { + preview_render_size == e->preview_render_size) { success = TRUE; found_something = TRUE; break; @@ -2502,7 +2493,7 @@ ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, i chanshown == e->chanshown && rectx == e->rectx && recty == e->recty && - render_size == e->render_size) { + preview_render_size == e->preview_render_size) { found_something = TRUE; break; } @@ -2519,7 +2510,7 @@ ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, i chanshown == tslot->current->chanshown && rectx == tslot->current->rectx && recty == tslot->current->recty && - render_size== tslot->current->render_size){ + preview_render_size== tslot->current->preview_render_size){ found_something = TRUE; break; } -- cgit v1.2.3 From 5fb6c942b7932904b53d6a04de8b7a02be7f0f75 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 2 Nov 2010 10:55:49 +0000 Subject: Fix #24485: Applying scale to multires object end up in a blender crash Fixed multires_apply_smat to work properly with different current and total subdivision levels. --- source/blender/blenkernel/intern/multires.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 5324d5dde62..bf1cd9b9994 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1471,15 +1471,19 @@ void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) int i, numGrids, gridSize, dGridSize, dSkip, totvert; float (*vertCos)[3] = NULL; MultiresModifierData *mmd= get_multires_modifier(scene, ob); + MultiresModifierData high_mmd; CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); if(!mdisps || !mmd) return; + /* we need derived mesh created from highest resolution */ + high_mmd= *mmd; + high_mmd.lvl= high_mmd.totlvl; /* unscaled multires with applied displacement */ - subdm= get_multires_dm(scene, mmd, ob); + subdm= get_multires_dm(scene, &high_mmd, ob); /* prepare scaled CDDM to create ccgDN */ cddm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); @@ -1495,7 +1499,7 @@ void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) mvert= cddm->getVertArray(cddm); /* scaled ccgDM for tangent space of object with applied scale */ - dm= subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0); + dm= subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0); cddm->release(cddm); numGrids= dm->getNumGrids(dm); @@ -1504,7 +1508,7 @@ void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) gridOffset= dm->getGridOffset(dm); subGridData= subdm->getGridData(subdm); - dGridSize= multires_side_tot[mmd->totlvl]; + dGridSize= multires_side_tot[high_mmd.totlvl]; dSkip= (dGridSize-1)/(gridSize-1); #pragma omp parallel for private(i) if(me->totface*gridSize*gridSize*4 >= CCG_OMP_LIMIT) -- cgit v1.2.3 From 5d7ed88f17c7a253c81ee48c147149d73dd88e6a Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 2 Nov 2010 12:18:49 +0000 Subject: Fix #24436: GLSL + Node material gives wrong color. --- source/blender/blenkernel/intern/node.c | 4 +--- 1 file changed, 1 insertion(+), 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 41c4fece1a4..6c4c566f5b1 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2718,7 +2718,7 @@ static void gpu_from_node_stack(ListBase *sockets, bNodeStack **ns, GPUNodeStack gs[i].name = ""; gs[i].hasinput= ns[i]->hasinput && ns[i]->data; - gs[i].hasoutput= ns[i]->hasinput && ns[i]->data; + gs[i].hasoutput= ns[i]->hasoutput && ns[i]->data; gs[i].sockettype= ns[i]->sockettype; } @@ -2732,8 +2732,6 @@ static void data_from_gpu_stack(ListBase *sockets, bNodeStack **ns, GPUNodeStack for (sock=sockets->first, i=0; sock; sock=sock->next, i++) { ns[i]->data= gs[i].link; - ns[i]->hasinput= gs[i].hasinput && gs[i].link; - ns[i]->hasoutput= gs[i].hasoutput; ns[i]->sockettype= gs[i].sockettype; } } -- cgit v1.2.3 From 369a5cc29e80d0ac30f9db444f2c0f9c1da32e01 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 2 Nov 2010 13:12:30 +0000 Subject: fix for compiling with the c90 standard, support for non-static variable initializers is a c99 feature. --- source/blender/blenkernel/intern/anim.c | 6 +++++- source/blender/blenkernel/intern/boids.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index a4e791aa6b3..500161fee2e 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1145,7 +1145,6 @@ static void new_particle_duplilist(ListBase *lb, ID *UNUSED(id), Scene *scene, O Object *ob=0, **oblist=0, obcopy, *obcopylist=0; DupliObject *dob; ParticleDupliWeight *dw; - ParticleSimulationData sim = {scene, par, psys, psys_get_modifier(par, psys)}; ParticleSettings *part; ParticleData *pa; ChildParticle *cpa=0; @@ -1180,6 +1179,11 @@ static void new_particle_duplilist(ListBase *lb, ID *UNUSED(id), Scene *scene, O lay= scene->lay; if((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { + ParticleSimulationData sim= {0}; + sim.scene= scene; + sim.ob= par; + sim.psys= psys; + sim.psmd= psys_get_modifier(par, psys); /* first check for loops (particle system object used as dupli object) */ if(part->ren_as == PART_DRAW_OB) { diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 943cf20720e..5c2c0721972 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -1257,7 +1257,11 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) switch(bpa->data.mode) { case eBoidMode_InAir: { - float grav[3] = {0.0f, 0.0f, bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f}; + float grav[3]; + + grav[0]= 0.0f; + grav[1]= 0.0f; + grav[2]= bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f; /* don't take forward acceleration into account (better banking) */ if(dot_v3v3(bpa->data.acc, pa->state.vel) > 0.0f) { @@ -1296,7 +1300,12 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) } case eBoidMode_Falling: { - float grav[3] = {0.0f, 0.0f, bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f}; + float grav[3]; + + grav[0]= 0.0f; + grav[1]= 0.0f; + grav[2]= bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f; + /* gather apparent gravity */ VECADDFAC(bpa->gravity, bpa->gravity, grav, dtime); -- cgit v1.2.3 From 130088300bec57aa0f11042bb09e48a67417a514 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 2 Nov 2010 15:21:43 +0000 Subject: Fix for [#24501] Apeend object with cloth sim from another file crash. --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 37d2b103ef0..bd37abc266b 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2002,7 +2002,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) if((mode==PTCACHE_CLEAR_BEFORE && pm->frame < cfra) || (mode==PTCACHE_CLEAR_AFTER && pm->frame > cfra) ) { link = pm; - if(pm->frame >=sta && pm->frame <= end) + if(pid->cache->cached_frames && pm->frame >=sta && pm->frame <= end) pid->cache->cached_frames[pm->frame-sta] = 0; ptcache_free_data(pm); pm = pm->next; -- cgit v1.2.3 From 09435ec149b499fabb112114bcdd24a9b3dc6cda Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 2 Nov 2010 21:16:41 +0000 Subject: Oops, particle collisions didn't take simulation subframes into account at all. * This caused nearly all particles to leak through the collision surface if simulation subframes were used and the collision object was moving. * In addition to fixing this I also did some more cleanup of the collision code and refined some of the comments. --- source/blender/blenkernel/intern/boids.c | 12 ++++-- source/blender/blenkernel/intern/particle_system.c | 50 ++++++++++++---------- 2 files changed, 37 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 5c2c0721972..1bde0639055 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -205,7 +205,9 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * add_v3_v3v3(col.co2, pa->prev_state.co, pa->prev_state.vel); sub_v3_v3v3(ray_dir, col.co2, col.co1); mul_v3_fl(ray_dir, acbr->look_ahead); - col.t = 0.0f; + col.f = 0.0f; + col.cfra = fmod(bbd->cfra-bbd->dfra, 1.0f); + col.dfra = bbd->dfra; hit.index = -1; hit.dist = col.ray_len = len_v3(ray_dir); @@ -772,7 +774,9 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro sub_v3_v3v3(col.co2, pa->state.co, zvec); sub_v3_v3(col.co2, zvec); sub_v3_v3v3(ray_dir, col.co2, col.co1); - col.t = 0.0f; + col.f = 0.0f; + col.cfra = fmod(bbd->cfra-bbd->dfra, 1.0f); + col.dfra = bbd->dfra; hit.index = -1; hit.dist = col.ray_len = len_v3(ray_dir); @@ -796,7 +800,9 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro sub_v3_v3v3(col.co2, pa->state.co, zvec); sub_v3_v3(col.co2, zvec); sub_v3_v3v3(ray_dir, col.co2, col.co1); - col.t = 0.0f; + col.f = 0.0f; + col.cfra = fmod(bbd->cfra-bbd->dfra, 1.0f); + col.dfra = bbd->dfra; hit.index = -1; hit.dist = col.ray_len = len_v3(ray_dir); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index a4c0776f5df..504105d5950 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2777,23 +2777,26 @@ void particle_intersect_face(void *userdata, int index, const BVHTreeRay *ray, B MVert *x = col->md->x; MVert *v = col->md->current_v; float vel[3], co1[3], co2[3], uv[2], ipoint[3], temp[3], t; + float x0[3], x1[3], x2[3], x3[3]; + float *t0=x0, *t1=x1, *t2=x2, *t3=(face->v4 ? x3 : NULL); - float *t0, *t1, *t2, *t3; - t0 = x[ face->v1 ].co; - t1 = x[ face->v2 ].co; - t2 = x[ face->v3 ].co; - t3 = face->v4 ? x[ face->v4].co : NULL; + /* move collision face to start of timestep */ + madd_v3_v3v3fl(t0, x[face->v1].co, v[face->v1].co, col->cfra); + madd_v3_v3v3fl(t1, x[face->v2].co, v[face->v2].co, col->cfra); + madd_v3_v3v3fl(t2, x[face->v3].co, v[face->v3].co, col->cfra); + if(t3) + madd_v3_v3v3fl(t3, x[face->v4].co, v[face->v4].co, col->cfra); /* calculate average velocity of face */ - VECCOPY(vel, v[ face->v1 ].co); - VECADD(vel, vel, v[ face->v2 ].co); - VECADD(vel, vel, v[ face->v3 ].co); - mul_v3_fl(vel, 0.33334f); + copy_v3_v3(vel, v[ face->v1 ].co); + add_v3_v3(vel, v[ face->v2 ].co); + add_v3_v3(vel, v[ face->v3 ].co); + mul_v3_fl(vel, 0.33334f*col->dfra); /* substract face velocity, in other words convert to a coordinate system where only the particle moves */ - VECADDFAC(co1, col->co1, vel, -col->t); - VECSUB(co2, col->co2, vel); + madd_v3_v3v3fl(co1, col->co1, vel, -col->f); + sub_v3_v3v3(co2, col->co2, vel); do { @@ -2875,7 +2878,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo copy_v3_v3(col.co2, pa->state.co); copy_v3_v3(col.ve1, pa->prev_state.vel); copy_v3_v3(col.ve2, pa->state.vel); - col.t = 0.0f; + col.f = 0.0f; /* override for boids */ if(part->phystype == PART_PHYS_BOIDS) { @@ -2893,6 +2896,9 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo hit.index = -1; hit.dist = col.ray_len = len_v3(ray_dir); + col.cfra = fmod(cfra-dfra, 1.0f); + col.dfra = dfra; + /* even if particle is stationary we want to check for moving colliders */ /* if hit.dist is zero the bvhtree_ray_cast will just ignore everything */ if(hit.dist == 0.0f) @@ -2917,11 +2923,11 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* 2. */ if(hit.index>=0) { PartDeflect *pd = col.hit_ob->pd; - float co[3]; /* point of collision */ - float x = hit.dist/col.ray_len; /* location of collision between this iteration */ - float df = col.t + x * (1.0f - col.t); /* time of collision between frame change*/ - float dt1 = (df - col.t) * timestep; /* iteration time of collision (in seconds) */ - float dt2 = (1.0f - df) * timestep; /* time left after collision (in seconds) */ + float co[3]; /* point of collision */ + float x = hit.dist/col.ray_len; /* location factor of collision between this iteration */ + float f = col.f + x * (1.0f - col.f); /* time factor of collision between timestep */ + float dt1 = (f - col.f) * timestep; /* time since previous collision (in seconds) */ + float dt2 = (1.0f - f) * timestep; /* time left after collision (in seconds) */ int through = (BLI_frand() < pd->pdef_perm) ? 1 : 0; /* did particle pass through the collision surface? */ deflections++; @@ -2935,12 +2941,12 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* particle dies in collision */ if(through == 0 && (part->flag & PART_DIE_ON_COL || pd->flag & PDEFLE_KILL_PART)) { pa->alive = PARS_DYING; - pa->dietime = pa->state.time + (cfra - pa->state.time) * df; + pa->dietime = pa->state.time + (cfra - pa->state.time) * f; copy_v3_v3(pa->state.co, co); - interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, df); - interp_qt_qtqt(pa->state.rot, pa->prev_state.rot, pa->state.rot, df); - interp_v3_v3v3(pa->state.ave, pa->prev_state.ave, pa->state.ave, df); + interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, f); + interp_qt_qtqt(pa->state.rot, pa->prev_state.rot, pa->state.rot, f); + interp_v3_v3v3(pa->state.ave, pa->prev_state.ave, pa->state.ave, f); /* particle is dead so we don't need to calculate further */ return; @@ -3073,7 +3079,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo copy_v3_v3(col.ve1, v0); copy_v3_v3(col.ve2, pa->state.vel); - col.t = df; + col.f = f; } else { /* final chance to prevent failure, so stick to the surface and hope for the best */ -- cgit v1.2.3 From 6b767b8018cbf5ca5657cad842271d8d6327ddd0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 3 Nov 2010 01:56:02 +0000 Subject: fix [#24499] Consistency Issue with LassoSelect/ExtendOption Added extend option to lasso. also... - selecting bones wasn't checking their layer of if they were hidden in a number of places. - fixed memory leak. small unrealed changes - added PBONE_VISIBLE macro - renamed functions used for paint selectoin from *_tface to paintface_*. sine they no longer have anything todo with tface's. - removed scanfill include from BLI_blenlib.h, this is only used in very few places and quite specific. Noticed lasso select is broken for metaballs and face mask mode but this has been the case for a while, will look into it next. --- source/blender/blenkernel/intern/displist.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index d1830cb8243..a8032f5a40d 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -45,6 +45,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_editVert.h" +#include "BLI_scanfill.h" #include "BKE_global.h" #include "BKE_displist.h" -- cgit v1.2.3 From fe8d5b81b09462d2344a50b32bfd2d8df5c6d886 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 3 Nov 2010 06:31:53 +0000 Subject: use c90 compatible static initializers. --- source/blender/blenkernel/intern/depsgraph.c | 6 ++++-- source/blender/blenkernel/intern/effect.c | 6 +++++- source/blender/blenkernel/intern/font.c | 8 ++++++-- source/blender/blenkernel/intern/particle.c | 7 ++++++- source/blender/blenkernel/intern/pointcache.c | 8 ++++++-- source/blender/blenkernel/intern/shrinkwrap.c | 4 ++-- source/blender/blenkernel/intern/unit.c | 3 ++- 7 files changed, 31 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index d95b7010993..21ef1c03e3a 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2350,8 +2350,10 @@ void DAG_id_flush_update(ID *id, short flag) /* set flags based on textures - can influence depgraph via modifiers */ if(idtype == ID_TE) { for(obt=bmain->object.first; obt; obt= obt->id.next) { - struct { ID *id; int is_dependent; } data = {id, 0}; - + struct { ID *id; int is_dependent; } data; + data.id= id; + data.is_dependent= 0; + modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data); if (data.is_dependent) obt->recalc |= OB_RECALC_DATA; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 70e814ef956..24a95c58e36 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -628,7 +628,6 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin } } else if(eff->psys) { - ParticleSimulationData sim = {eff->scene, eff->ob, eff->psys, NULL, NULL}; ParticleData *pa = eff->psys->particles + *efd->index; ParticleKey state; @@ -636,6 +635,11 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin if(eff->psys == point->psys && *efd->index == point->index) ; else { + ParticleSimulationData sim= {0}; + sim.scene= eff->scene; + sim.ob= eff->ob; + sim.psys= eff->psys; + /* TODO: time from actual previous calculated frame (step might not be 1) */ state.time = cfra - 1.0; ret = psys_get_particle_state(&sim, *efd->index, &state, 0); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 58917e75a43..0b27aaeb0ba 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -1193,8 +1193,12 @@ 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]= {ct->xof, ct->yof, 0.0f}; - + float vecyo[3]; + + vecyo[0]= ct->xof; + vecyo[1]= ct->yof; + vecyo[2]= 0.0f; + mem[0] = ascii; mem[1] = 0; custrinfo[0]= *info; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 624587338c9..65b898a2807 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3221,7 +3221,12 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf edit->totcached = totpart; if(psys) { - ParticleSimulationData sim = {scene, ob, psys, psys_get_modifier(ob, psys), NULL}; + ParticleSimulationData sim= {0}; + sim.scene= scene; + sim.ob= ob; + sim.psys= psys; + sim.psmd= psys_get_modifier(ob, psys); + psys_cache_child_paths(&sim, cfra, 1); } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index bd37abc266b..002e8c9de0f 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -199,13 +199,17 @@ static int ptcache_write_particle(int index, void *psys_v, void **data, int cfra ParticleSystem *psys= psys_v; ParticleData *pa = psys->particles + index; BoidParticle *boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL; - float times[3] = {pa->time, pa->dietime, pa->lifetime}; + float times[3]; int step = psys->pointcache->step; /* No need to store unborn or died particles outside cache step bounds */ if(data[BPHYS_DATA_INDEX] && (cfra < pa->time - step || cfra > pa->dietime + step)) return 0; - + + times[0]= pa->time; + times[1]= pa->dietime; + times[2]= pa->lifetime; + PTCACHE_DATA_FROM(data, BPHYS_DATA_INDEX, &index); PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, pa->state.co); PTCACHE_DATA_FROM(data, BPHYS_DATA_VELOCITY, pa->state.vel); diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 4746341876f..a6daaf36ff6 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -391,8 +391,8 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S //Project over negative direction of axis if(use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR) { - float inv_no[3] = { -tmp_no[0], -tmp_no[1], -tmp_no[2] }; - + float inv_no[3]; + negate_v3_v3(inv_no, tmp_no); if(auxData.tree) normal_projection_project_vertex(0, tmp_co, inv_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 83ace49eb67..1240b85393b 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -334,7 +334,8 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC /* Convert to a string */ { - char conv_str[6] = {'%', '.', '0'+prec, 'l', 'f', '\0'}; /* "%.2lf" when prec is 2, must be under 10 */ + char conv_str[6] = {'%', '.', '0', 'l', 'f', '\0'}; /* "%.2lf" when prec is 2, must be under 10 */ + conv_str[2] += prec; len= snprintf(str, len_max, conv_str, (float)value_conv); if(len >= len_max) -- cgit v1.2.3 From c31536fc534156559fb19d008323b28a3dc4ef5f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 3 Nov 2010 08:46:14 +0000 Subject: bugfix [#24445] NLA reverse option flickers UnMapping the reversed NLA strips timing was incorrect. --- source/blender/blenkernel/intern/nla.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 6c8eb69703f..423ccb00e8e 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -362,7 +362,7 @@ static float nlastrip_get_frame_actionclip (NlaStrip *strip, float cframe, short return strip->end - scale*(cframe - strip->actstart); } else if (mode == NLATIME_CONVERT_UNMAP) { - return strip->actend - (strip->end - cframe) / scale; + return (strip->end + (strip->actstart * scale - cframe)) / scale; } else /* if (mode == NLATIME_CONVERT_EVAL) */{ if (IS_EQ(cframe, strip->end) && IS_EQ(strip->repeat, ((int)strip->repeat))) { -- cgit v1.2.3 From ee4b32c41a4a20cd82d10af7fefd9b20e29a77f3 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 3 Nov 2010 16:51:25 +0000 Subject: Fix for [#21958] Dupli group doesn't show up if linked on a layer that is different from the group layer * Object layer flag was set too soon for group duplication. --- source/blender/blenkernel/intern/anim.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 500161fee2e..547d3f7a738 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -796,6 +796,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n DupliObject *dob; vertexDupliData *vdd= userData; float vec[3], q2[4], mat[3][3], tmat[4][4], obmat[4][4]; + int origlay; mul_v3_m4v3(vec, vdd->pmat, co); sub_v3_v3(vec, vdd->pmat[3]); @@ -818,7 +819,14 @@ static void vertex_dupli__mapFunc(void *userData, int index, float *co, float *n copy_m4_m4(tmat, obmat); mul_m4_m4m3(obmat, tmat, mat); } + + origlay = vdd->ob->lay; + dob= new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS, vdd->animated); + + /* restore the original layer so that each dupli will have proper dob->origlay */ + vdd->ob->lay = origlay; + if(vdd->orco) VECCOPY(dob->orco, vdd->orco[index]); @@ -928,6 +936,14 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl vertex_dupli__mapFunc(&vdd, a, vec, no, NULL); } } + if(sce) { + /* Set proper layer in case of scene looping, + * in case of groups the object layer will be + * changed when it's duplicated due to the + * group duplication. + */ + ob->lay = vdd.par->lay; + } break; } -- cgit v1.2.3 From 81fe9d2d04f463c2bbaea599d067beeca6ae2dac Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 3 Nov 2010 21:23:02 +0000 Subject: workaround [#24392] 2d Image paint editor: no clone/smear/soften tools etc the brush system matches the brush mode with the object mode, but this doesn't work for 2D image view paint. since the poll() function doesnt have access to the context, for now just check if no paint modes are active, default to texture paint. --- 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 7a10f9082e5..649b3e3ad9b 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -67,7 +67,7 @@ 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->ob_mode = OB_MODE_ALL_PAINT; /* BRUSH SCULPT TOOL SETTINGS */ brush->size= 35; /* radius of the brush in pixels */ -- cgit v1.2.3 From f478cef43b845f007cb6340df761cb43ff62c762 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 4 Nov 2010 16:00:28 +0000 Subject: Fix #24388: multires base mesh - MDisp should be re-allocated if face changed amount of vertices - Allocate disps array in layerSwap_mdisps to prevent loosing all highres data --- source/blender/blenkernel/intern/customdata.c | 20 ++---- source/blender/blenkernel/intern/multires.c | 87 +++++++++++++++++++++------ 2 files changed, 72 insertions(+), 35 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index c1aaa869876..cd476d8491b 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -50,6 +50,7 @@ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_utildefines.h" +#include "BKE_multires.h" /* number of layers to add when growing a CustomData object */ #define CUSTOMDATA_GROW 5 @@ -441,19 +442,6 @@ static void mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, fl } #endif -static int mdisp_corners(MDisps *s) -{ - int lvl= 13; - - while(lvl > 0) { - int side = (1 << (lvl-1)) + 1; - if ((s->totdisp % (side*side)) == 0) return s->totdisp / (side*side); - lvl--; - } - - return 0; -} - static void layerSwap_mdisps(void *data, const int *ci) { MDisps *s = data; @@ -462,7 +450,7 @@ static void layerSwap_mdisps(void *data, const int *ci) if(s->disps) { int nverts= (ci[1] == 3) ? 4 : 3; /* silly way to know vertex count of face */ - corners= mdisp_corners(s); + corners= multires_mdisp_corners(s); cornersize= s->totdisp/corners; if(corners!=nverts) { @@ -470,8 +458,8 @@ static void layerSwap_mdisps(void *data, const int *ci) if it happened, just forgot displacement */ MEM_freeN(s->disps); - s->disps= NULL; - s->totdisp= 0; /* flag to update totdisp */ + s->totdisp= (s->totdisp/corners)*nverts; + s->disps= MEM_callocN(s->totdisp*sizeof(float)*3, "mdisp swap"); return; } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index bf1cd9b9994..23a81e53728 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -305,33 +305,45 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm } /* reset the multires levels to match the number of mdisps */ -void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *ob) +static int get_levels_from_disps(Object *ob) { Mesh *me = ob->data; MDisps *mdisp; - int i; + int i, totlvl= 0; mdisp = CustomData_get_layer(&me->fdata, CD_MDISPS); - if(mdisp) { - for(i = 0; i < me->totface; ++i, ++mdisp) { - int S = me->mface[i].v4 ? 4 : 3; - - if(mdisp->totdisp == 0) continue; - - while(1) { - int side = (1 << (mmd->totlvl-1)) + 1; - int lvl_totdisp = side*side*S; - if(mdisp->totdisp == lvl_totdisp) - break; - else if(mdisp->totdisp < lvl_totdisp) - --mmd->totlvl; - else - ++mmd->totlvl; - - } + for(i = 0; i < me->totface; ++i, ++mdisp) { + int S = me->mface[i].v4 ? 4 : 3; + + if(mdisp->totdisp == 0) continue; + + while(1) { + int side = (1 << (totlvl-1)) + 1; + int lvl_totdisp = side*side*S; + if(mdisp->totdisp == lvl_totdisp) + break; + else if(mdisp->totdisp < lvl_totdisp) + --totlvl; + else + ++totlvl; + } + } + return totlvl; +} + +/* reset the multires levels to match the number of mdisps */ +void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *ob) +{ + Mesh *me = ob->data; + MDisps *mdisp; + + mdisp = CustomData_get_layer(&me->fdata, CD_MDISPS); + + if(mdisp) { + mmd->totlvl = get_levels_from_disps(ob); mmd->lvl = MIN2(mmd->sculptlvl, mmd->totlvl); mmd->sculptlvl = MIN2(mmd->sculptlvl, mmd->totlvl); mmd->renderlvl = MIN2(mmd->renderlvl, mmd->totlvl); @@ -1555,6 +1567,19 @@ void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) subdm->release(subdm); } +int multires_mdisp_corners(MDisps *s) +{ + int lvl= 13; + + while(lvl > 0) { + int side = (1 << (lvl-1)) + 1; + if ((s->totdisp % (side*side)) == 0) return s->totdisp / (side*side); + lvl--; + } + + return 0; +} + void multiresModifier_scale_disp(Scene *scene, Object *ob) { float smat[3][3]; @@ -1578,3 +1603,27 @@ void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob) multires_apply_smat(scene, ob, mat); } + +/* update multires data after topology changing */ +void multires_topology_changed(Object *ob) +{ + Mesh *me= (Mesh*)ob->data; + MDisps *mdisp= CustomData_get_layer(&me->fdata, CD_MDISPS); + int i; + + if(!mdisp) return; + + for(i = 0; i < me->totface; i++, mdisp++) { + int corners= multires_mdisp_corners(mdisp); + int nvert= me->mface[i].v4 ? 4 : 3; + + if(corners!=nvert) { + mdisp->totdisp= (mdisp->totdisp/corners)*nvert; + + if(mdisp->disps) + MEM_freeN(mdisp->disps); + + mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology"); + } + } +} -- cgit v1.2.3 From 27de85af37f936030c73622b52d2f8ef084cb287 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 4 Nov 2010 17:02:32 +0000 Subject: Fix for [#24513] VSE curves displaced from effect when source is moved numerically --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 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 ef470821d22..4a8c47f1f71 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2848,7 +2848,7 @@ int seq_test_overlap(ListBase * seqbasep, Sequence *test) } -static void seq_translate(Scene *evil_scene, Sequence *seq, int delta) +void seq_translate(Scene *evil_scene, Sequence *seq, int delta) { seq_offset_animdata(evil_scene, seq, delta); seq->start += delta; -- cgit v1.2.3 From 8bbf27dfbd8c3831541653f14de4e8b0bdf83259 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 4 Nov 2010 20:17:38 +0000 Subject: Temporary fix for "freezing when pointcache is baked": * WM_timecursor is broken somehow, so pointcache baking makes the cursor disappear. * For user this seems like blender has frozen although it's just a matter of no progress indication. * This fix just sets the default "busy" cursor for the whole duration of baking and reports progress in the console. * If there's and easy fix for this then it should probably be done straight away, but I want to re-implement baking using the job system soon anyways, so a proper fix for this is not strictly necessary. --- source/blender/blenkernel/intern/pointcache.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 002e8c9de0f..35e0441739e 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2607,6 +2607,8 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) thread_data.break_operation = FALSE; thread_data.thread_ended = FALSE; old_progress = -1; + + WM_cursor_wait(1); if(G.background) { ptcache_make_cache_thread((void*)&thread_data); @@ -2690,6 +2692,8 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) else if (baker->progressend) baker->progressend(baker->progresscontext); + WM_cursor_wait(0); + /* TODO: call redraw all windows somehow */ } /* Helpers */ -- cgit v1.2.3 From 52865a51408fba9c871caff82ca0acb71a37d2d7 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 5 Nov 2010 00:09:45 +0000 Subject: Bugfix #24535: File saved with NLA Strip in Tweakmode crashes on reload Now the active strip doesn't just get cleared on fileload, but is relinked properly. I had originally intended that files shouldn't be able to be saved with NLA data still in Tweakmode, but this turns out to be a bit more troublesome to get working as that would make undo keep popping out of this mode too. Also reverting 32743 (bugfix for 24418), which was a hack around this. --- source/blender/blenkernel/intern/anim_sys.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 52c5edc53a0..e03799ff938 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1641,11 +1641,6 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) if ((nlt) && !(adt->flag & ADT_NLA_EDIT_NOMAP)) { /* edit active action in-place according to its active strip, so copy the data */ - - /* this is cleared on undo */ - if(adt->actstrip == NULL) { - adt->actstrip= BKE_nlastrip_find_active(nlt); - } memcpy(&dummy_strip, adt->actstrip, sizeof(NlaStrip)); dummy_strip.next = dummy_strip.prev = NULL; } -- cgit v1.2.3 From e179c92a278160ad3a1523a17ef272f6f3547f46 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Nov 2010 07:35:21 +0000 Subject: tedious string copying changes - use sizeof() in more places. - fixed some off by 1 bugs copying strings. setting curve font family for instance was 1 char too short. - replace strncpy and strcpy with BLI_strncpy --- source/blender/blenkernel/intern/action.c | 8 ++++---- source/blender/blenkernel/intern/anim_sys.c | 11 ++++------- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/blender.c | 4 ++-- source/blender/blenkernel/intern/constraint.c | 2 +- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/font.c | 2 +- source/blender/blenkernel/intern/ipo.c | 6 +++--- source/blender/blenkernel/intern/library.c | 2 +- 9 files changed, 18 insertions(+), 21 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 902807126c9..227f2eadf4c 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -408,7 +408,7 @@ bPoseChannel *verify_pose_channel(bPose *pose, const char *name) /* If not, create it and add it */ chan = MEM_callocN(sizeof(bPoseChannel), "verifyPoseChannel"); - strncpy(chan->name, name, 31); + BLI_strncpy(chan->name, name, sizeof(chan->name)); /* init vars to prevent math errors */ chan->quat[0] = chan->rotAxis[1]= 1.0f; chan->size[0] = chan->size[1] = chan->size[2] = 1.0f; @@ -774,7 +774,7 @@ void pose_add_group (Object *ob) return; grp= MEM_callocN(sizeof(bActionGroup), "PoseGroup"); - strcpy(grp->name, "Group"); + BLI_strncpy(grp->name, "Group", sizeof(grp->name)); BLI_addtail(&pose->agroups, grp); BLI_uniquename(&pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name)); @@ -1119,8 +1119,8 @@ void what_does_obaction (Scene *UNUSED(scene), Object *ob, Object *workob, bPose workob->pose= pose; /* need to set pose too, since this is used for both types of Action Constraint */ - strcpy(workob->parsubstr, ob->parsubstr); - strcpy(workob->id.name, "OB"); /* we don't use real object name, otherwise RNA screws with the real thing */ + BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr)); + BLI_strncpy(workob->id.name, "OB", sizeof(workob->id.name)); /* we don't use real object name, otherwise RNA screws with the real thing */ /* if we're given a group to use, it's likely to be more efficient (though a bit more dangerous) */ if (agrp) { diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index e03799ff938..febe8005317 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -614,12 +614,9 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho /* allocate new KeyingSet */ ks= MEM_callocN(sizeof(KeyingSet), "KeyingSet"); - - if (name) - strncpy(ks->name, name, sizeof(ks->name)); - else - strcpy(ks->name, "KeyingSet"); - + + BLI_strncpy(ks->name, name ? name : "KeyingSet", sizeof(ks->name)); + ks->flag= flag; ks->keyingflag= keyingflag; @@ -667,7 +664,7 @@ KS_Path *BKE_keyingset_add_path (KeyingSet *ks, ID *id, const char group_name[], if (group_name) BLI_snprintf(ksp->group, 64, group_name); else - strcpy(ksp->group, ""); + ksp->group[0]= '\0'; /* store additional info for relative paths (just in case user makes the set relative) */ if (id) diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 3bec79eb352..ea01421a0ea 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -260,7 +260,7 @@ int bone_autoside_name (char *name, int UNUSED(strip_number), short axis, float len= strlen(name); if (len == 0) return 0; - strcpy(basename, name); + BLI_strncpy(basename, name, sizeof(basename)); /* Figure out extension to append: * - The extension to append is based upon the axis that we are working on. diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 72d194e4d79..9b2c1805069 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -460,13 +460,13 @@ static UndoElem *curundo= NULL; static int read_undosave(bContext *C, UndoElem *uel) { - char mainstr[FILE_MAXDIR+FILE_MAXFILE]; + char mainstr[sizeof(G.main->name)]; int success=0, fileflags; /* This is needed so undoing/redoing doesnt crash with threaded previews going */ WM_jobs_stop_all(CTX_wm_manager(C)); - strcpy(mainstr, G.main->name); /* temporal store */ + BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */ fileflags= G.fileflags; G.fileflags |= G_FILE_NO_UI; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index bf694732b46..a561df49e94 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -674,7 +674,7 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain ct= MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ \ ct->tar= datatar; \ - strcpy(ct->subtarget, datasubtarget); \ + BLI_strncpy(ct->subtarget, datasubtarget, sizeof(ct->subtarget)); \ ct->space= con->tarspace; \ ct->flag= CONSTRAINT_TAR_TEMP; \ \ diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index a7dd80bff4d..b6b6dde3cdc 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -155,7 +155,7 @@ Curve *add_curve(char *name, int type) cu->vfont= cu->vfontb= cu->vfonti= cu->vfontbi= get_builtin_font(); cu->vfont->id.us+=4; cu->str= MEM_mallocN(12, "str"); - strcpy(cu->str, "Text"); + BLI_strncpy(cu->str, "Text", 12); cu->len= cu->pos= 4; cu->strinfo= MEM_callocN(12*sizeof(CharInfo), "strinfo new"); cu->totbox= cu->actbox= 1; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 0b27aaeb0ba..5fdb9549179 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -394,7 +394,7 @@ VFont *load_vfont(char *name) /* if there's a font name, use it for the ID name */ if (strcmp(vfd->name, "")!=0) { - BLI_strncpy(vfont->id.name+2, vfd->name, 21); + BLI_strncpy(vfont->id.name+2, vfd->name, sizeof(vfont->id.name)-2); } BLI_strncpy(vfont->name, name, sizeof(vfont->name)); diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 5ed6beaf376..7914bc2b640 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1017,13 +1017,13 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) dtar= &dvar->targets[0]; dtar->id= (ID *)idriver->ob; if (idriver->name[0]) - BLI_strncpy(dtar->pchan_name, idriver->name, 32); + BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); /* second bone target (name was stored in same var as the first one) */ dtar= &dvar->targets[1]; dtar->id= (ID *)idriver->ob; if (idriver->name[0]) // xxx... for safety - BLI_strncpy(dtar->pchan_name, idriver->name+DRIVER_NAME_OFFS, 32); + BLI_strncpy(dtar->pchan_name, idriver->name+DRIVER_NAME_OFFS, sizeof(dtar->pchan_name)); } else { /* only a single variable, of type 'transform channel' */ @@ -1034,7 +1034,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) dtar= &dvar->targets[0]; dtar->id= (ID *)idriver->ob; if (idriver->name[0]) - BLI_strncpy(dtar->pchan_name, idriver->name, 32); + BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode); dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */ } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 4227c633c0b..ed9907b6869 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1365,7 +1365,7 @@ void rename_id(ID *id, char *name) { ListBase *lb; - strncpy(id->name+2, name, 21); + BLI_strncpy(id->name+2, name, sizeof(id->name)-2); lb= which_libbase(G.main, GS(id->name) ); new_id(lb, id, name); -- cgit v1.2.3 From e202aa6e6609d957db48c0ae8bbce54c0aa454f0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Nov 2010 09:01:00 +0000 Subject: dont change the file paths of sequence images, this is weak design because you can easily have 2 image users with different frame numbers so this ends up being which ever was last loaded. Modified to image user template to show the current filename of the image. --- source/blender/blenkernel/intern/image.c | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 1345c6c9b61..2719563f829 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1571,15 +1571,10 @@ static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr) /* common stuff to do with images after loading */ static void image_initialize_after_load(Image *ima, ImBuf *ibuf) { - - /* preview is NULL when it has never been used as an icon before */ if(G.background==0 && ima->preview==NULL) BKE_icon_changed(BKE_icon_getid(&ima->id)); - - /* stringcodes also in ibuf, ibuf->name is used to retrieve original (buttons) */ - BLI_strncpy(ibuf->name, ima->name, FILE_MAX); - + /* fields */ if (ima->flag & IMA_FIELDS) { if(ima->flag & IMA_STD_FIELD) de_interlace_st(ibuf); @@ -1604,11 +1599,10 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) ima->tpageflag |= IMA_TPAGE_REFRESH; ima->lastframe= frame; - - BLI_stringdec(ima->name, head, tail, &numlen); - BLI_stringenc(ima->name, head, tail, numlen, frame); BLI_strncpy(name, ima->name, sizeof(name)); - + BLI_stringdec(name, head, tail, &numlen); + BLI_stringenc(name, head, tail, numlen, frame); + if(ima->id.lib) BLI_path_abs(name, ima->id.lib->filepath); else @@ -1753,8 +1747,7 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) return ibuf; } -/* cfra used for # code, Image can only have this # for all its users - * warning, 'iuser' can be NULL */ +/* warning, 'iuser' can be NULL */ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) { struct ImBuf *ibuf; @@ -2002,11 +1995,6 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame /* XXX temp stuff? */ if(ima->lastframe != frame) { ima->tpageflag |= IMA_TPAGE_REFRESH; - if(ibuf) { - /* without this the image name only updates - * on first load which is quite confusing */ - BLI_strncpy(ima->name, ibuf->name, sizeof(ima->name)); - } } ima->lastframe = frame; } @@ -2109,9 +2097,6 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) /* only 1 layer/pass stored in imbufs, no exrhandle anim storage, no saving */ ibuf= image_load_sequence_multilayer(ima, iuser, frame); } - - if(ibuf) - BLI_strncpy(ima->name, ibuf->name, sizeof(ima->name)); } else if(ima->source==IMA_SRC_FILE) { -- cgit v1.2.3 From 66b274766a0584a74a63bb2b039f2a71e5b48534 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 5 Nov 2010 13:37:18 +0000 Subject: minor c90 compat edits. (no functional changes). --- source/blender/blenkernel/intern/blender.c | 1 - source/blender/blenkernel/intern/implicit.c | 4 +++- source/blender/blenkernel/intern/multires.c | 7 ++++++- source/blender/blenkernel/intern/particle.c | 6 +++++- source/blender/blenkernel/intern/particle_system.c | 15 +++++++++++---- source/blender/blenkernel/intern/shrinkwrap.c | 7 +------ 6 files changed, 26 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 9b2c1805069..d2b437d9833 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -32,7 +32,6 @@ #ifndef _WIN32 #include // for read close - #include // for MAXPATHLEN #else #include // for open close read #define open _open diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 6ca95752887..bdf71a8c6f0 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1562,13 +1562,15 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec unsigned int i = 0; float spring_air = clmd->sim_parms->Cvi * 0.01f; /* viscosity of air scaled in percent */ float gravity[3] = {0.0f, 0.0f, 0.0f}; - float tm2[3][3] = {{-spring_air,0,0}, {0,-spring_air,0},{0,0,-spring_air}}; + float tm2[3][3] = {{0}}; MFace *mfaces = cloth->mfaces; unsigned int numverts = cloth->numverts; LinkNode *search = cloth->springs; lfVector *winvec; EffectedPoint epoint; + tm2[0][0]= tm2[1][1]= tm2[2][2]= -spring_air; + /* global acceleration (gravitation) */ if(clmd->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { VECCOPY(gravity, clmd->scene->physics_settings.gravity); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 23a81e53728..329ef377c52 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1073,7 +1073,12 @@ static void create_old_vert_edge_map(ListBase **map, IndexNode **mem, const Mult static MultiresFace *find_old_face(ListBase *map, MultiresFace *faces, int v1, int v2, int v3, int v4) { IndexNode *n1; - int v[4] = {v1, v2, v3, v4}, i, j; + int v[4], i, j; + + v[0]= v1; + v[1]= v2; + v[2]= v3; + v[3]= v4; for(n1 = map[v1].first; n1; n1 = n1->next) { int fnd[4] = {0, 0, 0, 0}; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 65b898a2807..0dc0b67b377 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4454,7 +4454,11 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) { - ParticleSimulationData sim = {scene, ob, psys, psys_get_modifier(ob, psys)}; + ParticleSimulationData sim= {0}; + sim.scene= scene; + sim.ob= ob; + sim.psys= psys; + sim.psmd= psys_get_modifier(ob, psys); psys->lattice = psys_get_lattice(&sim); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 504105d5950..2b045647661 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1705,9 +1705,10 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, r_phase = PSYS_FRAND(p + 20); if(part->from==PART_FROM_PARTICLE){ - ParticleSimulationData tsim = {sim->scene, psys->target_ob ? psys->target_ob : ob, NULL, NULL}; float speed; - + ParticleSimulationData tsim= {0}; + tsim.scene= sim->scene; + tsim.ob= psys->target_ob ? psys->target_ob : ob; tsim.psys = BLI_findlink(&tsim.ob->particlesystem, sim->psys->target_psys-1); state.time = pa->time; @@ -2057,12 +2058,14 @@ void psys_count_keyed_targets(ParticleSimulationData *sim) static void set_keyed_keys(ParticleSimulationData *sim) { ParticleSystem *psys = sim->psys; - ParticleSimulationData ksim = {sim->scene, NULL, NULL, NULL}; + ParticleSimulationData ksim= {0}; ParticleTarget *pt; PARTICLE_P; ParticleKey *key; int totpart = psys->totpart, k, totkeys = psys->totkeyed; + ksim.scene= sim->scene; + /* no proper targets so let's clear and bail out */ if(psys->totkeyed==0) { free_keyed_keys(psys); @@ -3989,7 +3992,7 @@ static int hair_needs_recalc(ParticleSystem *psys) * then advances in to actual particle calculations depending on particle type */ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) { - ParticleSimulationData sim = {scene, ob, psys, NULL, NULL}; + ParticleSimulationData sim= {0}; ParticleSettings *part = psys->part; float cfra; @@ -4000,6 +4003,10 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) return; cfra= BKE_curframe(scene); + + sim.scene= scene; + sim.ob= ob; + sim.psys= psys; sim.psmd= psys_get_modifier(ob, psys); /* system was already updated from modifier stack */ diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index a6daaf36ff6..936fb1bfeab 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -49,14 +49,9 @@ #include "BKE_subsurf.h" #include "BLI_math.h" -#include "BLI_editVert.h" - /* Util macros */ -#define TO_STR(a) #a -#define JOIN(a,b) a##b - #define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n")) /* Benchmark macros */ @@ -90,7 +85,7 @@ typedef void ( *Shrinkwrap_ForeachVertexCallback) (DerivedMesh *target, float *c DerivedMesh *object_get_derived_final(struct Scene *scene, Object *ob, CustomDataMask dataMask) { Mesh *me= ob->data; - EditMesh *em = BKE_mesh_get_editmesh(me); + struct EditMesh *em = BKE_mesh_get_editmesh(me); if (em) { -- cgit v1.2.3 From e8501edae25905b76b6ac602f70ac06a9082b1de Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 5 Nov 2010 14:00:31 +0000 Subject: Read external mdisp when hamdling topology changes --- source/blender/blenkernel/intern/multires.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 329ef377c52..f4e9dcf742b 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1613,9 +1613,12 @@ void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob) void multires_topology_changed(Object *ob) { Mesh *me= (Mesh*)ob->data; - MDisps *mdisp= CustomData_get_layer(&me->fdata, CD_MDISPS); + MDisps *mdisp= NULL; int i; + CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); + mdisp= CustomData_get_layer(&me->fdata, CD_MDISPS); + if(!mdisp) return; for(i = 0; i < me->totface; i++, mdisp++) { -- cgit v1.2.3 From a1c7cccae4356e66ebd7b2b01fec6e738d007a43 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 6 Nov 2010 06:22:25 +0000 Subject: Fix bug with unneeded outline for filled 2d curves when converted to mesh - Revert of my old change in curve->mesh conversion - Do not ignore DL_POLYs for surfaces -- they will never be filled, but ignore them for 2d curves -- they'll be filled with INDEX3 parts. --- source/blender/blenkernel/intern/mesh.c | 46 +++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index faefbdacb45..f5a563faa6f 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -751,9 +751,13 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int float *data; int a, b, ofs, vertcount, startvert, totvert=0, totvlak=0; int p1, p2, p3, p4, *index; + int conv_polys= 0; cu= ob->data; + conv_polys|= cu->flag & CU_3D; /* 2d polys are filled with DL_INDEX3 displists */ + conv_polys|= ob->type == OB_SURF; /* surf polys are never filled */ + /* count */ dl= dispbase->first; while(dl) { @@ -762,8 +766,10 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int totvlak+= dl->parts*(dl->nr-1); } else if(dl->type==DL_POLY) { - totvert+= dl->parts*dl->nr; - totvlak+= dl->parts*dl->nr; + if(conv_polys) { + totvert+= dl->parts*dl->nr; + totvlak+= dl->parts*dl->nr; + } } else if(dl->type==DL_SURF) { totvert+= dl->parts*dl->nr; @@ -815,24 +821,26 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int } else if(dl->type==DL_POLY) { - startvert= vertcount; - a= dl->parts*dl->nr; - data= dl->verts; - while(a--) { - VECCOPY(mvert->co, data); - data+=3; - vertcount++; - mvert++; - } + if(conv_polys) { + startvert= vertcount; + a= dl->parts*dl->nr; + data= dl->verts; + while(a--) { + VECCOPY(mvert->co, data); + data+=3; + vertcount++; + mvert++; + } - for(a=0; aparts; a++) { - ofs= a*dl->nr; - for(b=0; bnr; b++) { - mface->v1= startvert+ofs+b; - if(b==dl->nr-1) mface->v2= startvert+ofs; - else mface->v2= startvert+ofs+b+1; - if(smooth) mface->flag |= ME_SMOOTH; - mface++; + for(a=0; aparts; a++) { + ofs= a*dl->nr; + for(b=0; bnr; b++) { + mface->v1= startvert+ofs+b; + if(b==dl->nr-1) mface->v2= startvert+ofs; + else mface->v2= startvert+ofs+b+1; + if(smooth) mface->flag |= ME_SMOOTH; + mface++; + } } } } -- cgit v1.2.3 From b0e62b0351bf056f4f5b8454c70ee1c24bad35c9 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 6 Nov 2010 22:03:42 +0000 Subject: Fix for [#24560] Cloth pinning breaks (when parenting?) * Changing the pin group needs to redo the whole cloth object. * Also, parent updates weren't flushed properly to pointcache in depsgraph. --- source/blender/blenkernel/intern/depsgraph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 21ef1c03e3a..c4ee97c21c5 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1858,7 +1858,7 @@ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int for(itA = node->child; itA; itA= itA->next) { if(itA->node->type==ID_OB) { if(itA->node->lasttime!=curtime) { - ob= (Object*)(node->ob); + ob= (Object*)(itA->node->ob); if(reset || (ob->recalc & OB_RECALC_ALL)) { if(BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) -- cgit v1.2.3 From fbcaa502ca8e71390e3f43ee9cc18b1ccfe840a2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Nov 2010 05:59:35 +0000 Subject: bugfix [#24574] setting location gained from a matrix_world.copy().translation_part() (visual loc) after constraints causes NAN in object location after python script ends shrinkwrap constraint was dividing by zero. also the shrinkwrap UI was incorrectly trying to draw a subtarget. --- source/blender/blenkernel/intern/constraint.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index a561df49e94..5dff21d8af4 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3462,7 +3462,9 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr BLI_bvhtree_find_nearest(treeData.tree, co, &nearest, treeData.nearest_callback, &treeData); dist = len_v3v3(co, nearest.co); - interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */ + if(dist != 0.0f) { + interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */ + } space_transform_invert(&transform, co); break; -- cgit v1.2.3 From 20b16e4074eb0b015a94bd5738c76dafaca250db Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 7 Nov 2010 08:49:07 +0000 Subject: de-duplicate unique naming logic, was used in 7 different places, convert into a function call. --- source/blender/blenkernel/intern/customdata.c | 36 ++++++++++++--------------- source/blender/blenkernel/intern/deform.c | 35 ++++++++------------------ source/blender/blenkernel/intern/library.c | 4 +-- source/blender/blenkernel/intern/mball.c | 16 ++++++------ source/blender/blenkernel/intern/nla.c | 21 +++++----------- 5 files changed, 43 insertions(+), 69 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index cd476d8491b..beb6c085d64 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -34,6 +34,7 @@ #include #include +#include #include "MEM_guardedalloc.h" @@ -41,6 +42,7 @@ #include "DNA_ID.h" #include "BLI_blenlib.h" +#include "BLI_path_util.h" #include "BLI_linklist.h" #include "BLI_math.h" #include "BLI_mempool.h" @@ -2261,32 +2263,26 @@ static int cd_layer_find_dupe(CustomData *data, const char *name, int type, int return 0; } -void CustomData_set_layer_unique_name(CustomData *data, int index) +static int customdata_unique_check(void *arg, const char *name) { + struct {CustomData *data; int type; int index;} *data_arg= arg; + return cd_layer_find_dupe(data_arg->data, name, data_arg->type, data_arg->index); +} + +void CustomData_set_layer_unique_name(CustomData *data, int index) +{ CustomDataLayer *nlayer= &data->layers[index]; const LayerTypeInfo *typeInfo= layerType_getInfo(nlayer->type); + struct {CustomData *data; int type; int index;} data_arg; + data_arg.data= data; + data_arg.type= nlayer->type; + data_arg.index= index; + if (!typeInfo->defaultname) return; - - if (nlayer->name[0] == '\0') - BLI_strncpy(nlayer->name, typeInfo->defaultname, sizeof(nlayer->name)); - - if(cd_layer_find_dupe(data, nlayer->name, nlayer->type, index)) { - /* note: this block is used in other places, when changing logic apply to all others, search this message */ - char tempname[sizeof(nlayer->name)]; - char left[sizeof(nlayer->name)]; - int number; - int len= BLI_split_name_num(left, &number, nlayer->name); - do { /* nested while loop looks bad but likely it wont run most times */ - while(BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", left, number) >= sizeof(tempname)) { - if(len > 0) left[--len]= '\0'; /* word too long */ - else number= 0; /* reset, must be a massive number */ - } - } while(number++, cd_layer_find_dupe(data, tempname, nlayer->type, index)); - - BLI_strncpy(nlayer->name, tempname, sizeof(nlayer->name)); - } + + BLI_uniquename_cb(customdata_unique_check, &data_arg, typeInfo->defaultname, '.', nlayer->name, sizeof(nlayer->name)); } int CustomData_verify_versions(struct CustomData *data, int index) diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 10fbd247c84..2eecc6d5c1b 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -319,32 +319,19 @@ static int defgroup_find_name_dupe(const char *name, bDeformGroup *dg, Object *o return 0; } +static int defgroup_unique_check(void *arg, const char *name) +{ + struct {Object *ob; void *dg;} *data= arg; + return defgroup_find_name_dupe(name, data->dg, data->ob); +} + void defgroup_unique_name (bDeformGroup *dg, Object *ob) -{ - if (!ob) - return; - - /* See if we are given an empty string */ - if (dg->name[0] == '\0') { - /* give it default name first */ - strcpy (dg->name, "Group"); - } - - if(defgroup_find_name_dupe(dg->name, dg, ob)) { - /* note: this block is used in other places, when changing logic apply to all others, search this message */ - char tempname[sizeof(dg->name)]; - char left[sizeof(dg->name)]; - int number; - int len= BLI_split_name_num(left, &number, dg->name); - do { /* nested while loop looks bad but likely it wont run most times */ - while(BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", left, number) >= sizeof(tempname)) { - if(len > 0) left[--len]= '\0'; /* word too long */ - else number= 0; /* reset, must be a massive number */ - } - } while(number++, defgroup_find_name_dupe(tempname, dg, ob)); +{ + struct {Object *ob; void *dg;} data; + data.ob= ob; + data.dg= dg; - BLI_strncpy(dg->name, tempname, sizeof(dg->name)); - } + BLI_uniquename_cb(defgroup_unique_check, &data, "Group", '.', dg->name, sizeof(dg->name)); } /* finds the best possible flipped name. For renaming; check for unique names afterwards */ diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index ed9907b6869..34351f9b113 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1063,7 +1063,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) memset(in_use, 0, sizeof(in_use)); /* get name portion, number portion ("name.number") */ - left_len= BLI_split_name_num(left, &nr, name); + left_len= BLI_split_name_num(left, &nr, name, '.'); /* if new name will be too long, truncate it */ if(nr > 999 && left_len > 16) { @@ -1080,7 +1080,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) (idtest->lib == NULL) && (*name == *(idtest->name+2)) && (strncmp(name, idtest->name+2, left_len)==0) && - (BLI_split_name_num(leftest, &nrtest, idtest->name+2) == left_len) + (BLI_split_name_num(leftest, &nrtest, idtest->name+2, '.') == left_len) ) { if(nrtest < sizeof(in_use)) in_use[nrtest]= 1; /* mark as used */ diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index fd3bc47da9e..dc343e0d6c2 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -330,8 +330,8 @@ int is_mball_basis_for(Object *ob1, Object *ob2) int basis1nr, basis2nr; char basis1name[32], basis2name[32]; - BLI_split_name_num(basis1name, &basis1nr, ob1->id.name+2); - BLI_split_name_num(basis2name, &basis2nr, ob2->id.name+2); + BLI_split_name_num(basis1name, &basis1nr, ob1->id.name+2, '.'); + BLI_split_name_num(basis2name, &basis2nr, ob2->id.name+2, '.'); if(!strcmp(basis1name, basis2name)) return is_basis_mball(ob1); else return 0; @@ -352,7 +352,7 @@ void copy_mball_properties(Scene *scene, Object *active_object) int basisnr, obnr; char basisname[32], obname[32]; - BLI_split_name_num(basisname, &basisnr, active_object->id.name+2); + BLI_split_name_num(basisname, &basisnr, active_object->id.name+2, '.'); /* XXX recursion check, see scene.c, just too simple code this next_object() */ if(F_ERROR==next_object(&sce_iter, 0, 0, 0)) @@ -361,7 +361,7 @@ void copy_mball_properties(Scene *scene, Object *active_object) while(next_object(&sce_iter, 1, &base, &ob)) { if (ob->type==OB_MBALL) { if(ob!=active_object){ - BLI_split_name_num(obname, &obnr, ob->id.name+2); + BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); /* Object ob has to be in same "group" ... it means, that it has to have * same base of its name */ @@ -395,7 +395,7 @@ Object *find_basis_mball(Scene *scene, Object *basis) int basisnr, obnr; char basisname[32], obname[32]; - BLI_split_name_num(basisname, &basisnr, basis->id.name+2); + BLI_split_name_num(basisname, &basisnr, basis->id.name+2, '.'); totelem= 0; /* XXX recursion check, see scene.c, just too simple code this next_object() */ @@ -415,7 +415,7 @@ Object *find_basis_mball(Scene *scene, Object *basis) else ml= mb->elems.first; } else{ - BLI_split_name_num(obname, &obnr, ob->id.name+2); + BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); /* object ob has to be in same "group" ... it means, that it has to have * same base of its name */ @@ -1572,7 +1572,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ invert_m4_m4(obinv, ob->obmat); a= 0; - BLI_split_name_num(obname, &obnr, ob->id.name+2); + BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); /* make main array */ next_object(&sce_iter, 0, 0, 0); @@ -1593,7 +1593,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ char name[32]; int nr; - BLI_split_name_num(name, &nr, bob->id.name+2); + BLI_split_name_num(name, &nr, bob->id.name+2, '.'); if( strcmp(obname, name)==0 ) { mb= bob->data; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 423ccb00e8e..910de5c6763 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1204,6 +1204,11 @@ void BKE_nlastrip_validate_fcurves (NlaStrip *strip) } } +static int nla_editbone_name_check(void *arg, const char *name) +{ + return BLI_ghash_haskey((GHash *)arg, (void *)name); +} + /* Sanity Validation ------------------------------------ */ /* Find (and set) a unique name for a strip from the whole AnimData block @@ -1259,21 +1264,7 @@ void BKE_nlastrip_validate_name (AnimData *adt, NlaStrip *strip) /* if the hash-table has a match for this name, try other names... * - in an extreme case, it might not be able to find a name, but then everything else in Blender would fail too :) */ - if (BLI_ghash_haskey(gh, strip->name)) { - /* note: this block is used in other places, when changing logic apply to all others, search this message */ - char tempname[sizeof(strip->name)]; - char left[sizeof(strip->name)]; - int number; - int len= BLI_split_name_num(left, &number, strip->name); - do { /* nested while loop looks bad but likely it wont run most times */ - while(BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", left, number) >= sizeof(tempname)) { - if(len > 0) left[--len]= '\0'; /* word too long */ - else number= 0; /* reset, must be a massive number */ - } - } while(number++, BLI_ghash_haskey(gh, tempname)); - - BLI_strncpy(strip->name, tempname, sizeof(strip->name)); - } + BLI_uniquename_cb(nla_editbone_name_check, (void *)gh, "NlaStrip", '.', strip->name, sizeof(strip->name)); /* free the hash... */ BLI_ghash_free(gh, NULL, NULL); -- cgit v1.2.3 From f15187cfcdfcc4f1210ce2b9ff7caba804411867 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 8 Nov 2010 11:19:53 +0000 Subject: Fix for [#24597] Option External in Smoke cache affects settings of start and end frame of simulation * Don't change anything in the pointcache unless a valid external cache is found. --- source/blender/blenkernel/intern/pointcache.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 35e0441739e..bceff487543 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2847,6 +2847,8 @@ void BKE_ptcache_load_external(PTCacheID *pid) PointCache *cache = pid->cache; int len; /* store the length of the string */ int info = 0; + int start = MAXFRAME; + int end = -1; /* mode is same as fopen's modes */ DIR *dir; @@ -2858,10 +2860,6 @@ void BKE_ptcache_load_external(PTCacheID *pid) if(!cache) return; - cache->startframe = MAXFRAME; - cache->endframe = -1; - cache->totpoint = 0; - ptcache_path(pid, path); len = BKE_ptcache_id_filename(pid, filename, 1, 0, 0); /* no path */ @@ -2887,8 +2885,8 @@ void BKE_ptcache_load_external(PTCacheID *pid) frame = atoi(num); if(frame) { - cache->startframe = MIN2(cache->startframe, frame); - cache->endframe = MAX2(cache->endframe, frame); + start = MIN2(start, frame); + end = MAX2(end, frame); } else info = 1; @@ -2898,9 +2896,13 @@ void BKE_ptcache_load_external(PTCacheID *pid) } closedir(dir); - if(cache->startframe != MAXFRAME) { + if(start != MAXFRAME) { PTCacheFile *pf; + cache->startframe = start; + cache->endframe = end; + cache->totpoint = 0; + /* read totpoint from info file (frame 0) */ if(info) { pf= ptcache_file_open(pid, PTCACHE_FILE_READ, 0); @@ -2931,10 +2933,10 @@ void BKE_ptcache_load_external(PTCacheID *pid) ptcache_file_close(pf); } } + cache->flag |= (PTCACHE_BAKED|PTCACHE_DISK_CACHE|PTCACHE_SIMULATION_VALID); + cache->flag &= ~(PTCACHE_OUTDATED|PTCACHE_FRAMES_SKIPPED); } - cache->flag &= ~(PTCACHE_OUTDATED|PTCACHE_FRAMES_SKIPPED); - BKE_ptcache_update_info(pid); } -- cgit v1.2.3 From 8647dbc0a60576aeb69b9431c02a1273290ee32d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 8 Nov 2010 14:00:23 +0000 Subject: Fix crash when creating new faces in edit mode - Do not check corners count if totdisp is set to 0 - Allocate memory for such mdisps to prevent the whole disp layer erasing --- source/blender/blenkernel/intern/multires.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index f4e9dcf742b..5dfae6599aa 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1614,17 +1614,31 @@ void multires_topology_changed(Object *ob) { Mesh *me= (Mesh*)ob->data; MDisps *mdisp= NULL; - int i; + int i, totlvl; CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisp= CustomData_get_layer(&me->fdata, CD_MDISPS); if(!mdisp) return; + totlvl= get_levels_from_disps(ob); + for(i = 0; i < me->totface; i++, mdisp++) { - int corners= multires_mdisp_corners(mdisp); + int corners= 0; int nvert= me->mface[i].v4 ? 4 : 3; + /* allocate memory for mdisp, the whole disp layer would be erased otherwise */ + if(!mdisp->totdisp) { + int side = multires_side_tot[totlvl]; + + mdisp->totdisp= nvert*side*side; + mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology"); + + continue; + } + + corners= multires_mdisp_corners(mdisp); + if(corners!=nvert) { mdisp->totdisp= (mdisp->totdisp/corners)*nvert; -- cgit v1.2.3 From f9487fba3994c1a09803f7a80cb69fe28b914a90 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 8 Nov 2010 14:39:36 +0000 Subject: Fixed own mistake from previous commit -- get_levels_from_disps can't be used when handling topology changes. Added grid size detection based on totdisp and corners count. --- source/blender/blenkernel/intern/multires.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 5dfae6599aa..3ebbc44766e 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1613,26 +1613,33 @@ void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob) void multires_topology_changed(Object *ob) { Mesh *me= (Mesh*)ob->data; - MDisps *mdisp= NULL; - int i, totlvl; + MDisps *mdisp= NULL, *cur= NULL; + int i, grid= 0, corners; CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisp= CustomData_get_layer(&me->fdata, CD_MDISPS); if(!mdisp) return; - totlvl= get_levels_from_disps(ob); + cur= mdisp; + for(i = 0; i < me->totface; i++, cur++) { + if(mdisp->totdisp) { + corners= multires_mdisp_corners(mdisp); + grid= mdisp->totdisp / corners; + + break; + } + } for(i = 0; i < me->totface; i++, mdisp++) { - int corners= 0; int nvert= me->mface[i].v4 ? 4 : 3; /* allocate memory for mdisp, the whole disp layer would be erased otherwise */ if(!mdisp->totdisp) { - int side = multires_side_tot[totlvl]; - - mdisp->totdisp= nvert*side*side; - mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology"); + if(grid) { + mdisp->totdisp= nvert*grid; + mdisp->disps= MEM_callocN(mdisp->totdisp*sizeof(float)*3, "mdisp topology"); + } continue; } -- cgit v1.2.3 From 7fd87de47bbf45bb15cd9e37c2a98d0b729bf16c Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 8 Nov 2010 19:03:42 +0000 Subject: Small bug, reported by Andy in irc: Image editor & texture properties, add new Image, inits 'start' now to frame 1 for sequences. Added triple-X warning in Image Open operator, it uses SpaceImage whilst it can be called from other editors. Code is safe but not correct. --- source/blender/blenkernel/intern/texture.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index da3dea37220..6a5e5a007f3 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -573,6 +573,7 @@ void default_tex(Tex *tex) tex->iuser.fie_ima= 2; tex->iuser.ok= 1; tex->iuser.frames= 100; + tex->iuser.sfra= 1; tex->preview = NULL; } -- cgit v1.2.3 From c4967b5dde966a3342a835fc8831fa170f856a97 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 8 Nov 2010 22:32:28 +0000 Subject: bugfix [#24616] Apply Visual Transform doesn't always apply location - object updates were not being flushed, so children weren't updating. - apply the matrix relative to the parent, added this as an option to object_apply_mat4() which allows assigning the worldspace matrix in python without worrying about the parent. --- source/blender/blenkernel/intern/object.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e006c48aca5..9512aa3a1ce 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1550,7 +1550,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) if(gob) { ob->rotmode= target->rotmode; mul_m4_m4m4(ob->obmat, target->obmat, gob->obmat); - object_apply_mat4(ob, ob->obmat, FALSE); + object_apply_mat4(ob, ob->obmat, FALSE, TRUE); } else { copy_object_transform(ob, target); @@ -1694,11 +1694,25 @@ void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) } /* see pchan_apply_mat4() for the equivalent 'pchan' function */ -void object_apply_mat4(Object *ob, float mat[][4], short use_compat) +void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const short use_parent) { float rot[3][3]; - mat4_to_loc_rot_size(ob->loc, rot, ob->size, mat); - object_mat3_to_rot(ob, rot, use_compat); + + if(use_parent && ob->parent) { + float rmat[4][4], diff_mat[4][4], imat[4][4]; + mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat); + invert_m4_m4(imat, diff_mat); + mul_m4_m4m4(rmat, mat, imat); /* get the parent relative matrix */ + object_apply_mat4(ob, rmat, use_compat, FALSE); + + /* same as below, use rmat rather then mat */ + mat4_to_loc_rot_size(ob->loc, rot, ob->size, rmat); + object_mat3_to_rot(ob, rot, use_compat); + } + else { + mat4_to_loc_rot_size(ob->loc, rot, ob->size, mat); + object_mat3_to_rot(ob, rot, use_compat); + } } void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ @@ -2127,7 +2141,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ copy_m3_m4(originmat, tmat); // origin, voor help line - if( (ob->partype & 15)==PARSKEL ) { + if( (ob->partype & PARTYPE)==PARSKEL ) { VECCOPY(ob->orig, par->obmat[3]); } else { -- cgit v1.2.3 From 989aea3ed003092af0ded3177441bf05f33aaf24 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Nov 2010 09:34:03 +0000 Subject: copying a camera would copy its animation data (and action datablocks) twice. --- source/blender/blenkernel/intern/object.c | 1 - 1 file changed, 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 9512aa3a1ce..9c76db2b2b5 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -715,7 +715,6 @@ Camera *copy_camera(Camera *cam) Camera *camn; camn= copy_libblock(cam); - camn->adt= BKE_copy_animdata(cam->adt); return camn; } -- cgit v1.2.3 From 7a62c05204782c77cb02a6f133aed4dc116f7d70 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Nov 2010 09:53:17 +0000 Subject: bugfix [#24403] Object.copy() duplicates armature action now duplicating ID data wont duplicate actions by default and the user preference is used with duplicate operators. --- source/blender/blenkernel/intern/anim_sys.c | 35 +++++++++++++++++++++++------ source/blender/blenkernel/intern/library.c | 10 ++++----- source/blender/blenkernel/intern/node.c | 2 +- source/blender/blenkernel/intern/scene.c | 4 +++- 4 files changed, 37 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index febe8005317..e50d4880fbe 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -36,8 +36,10 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BKE_library.h" #include "BLI_dynstr.h" + #include "DNA_anim_types.h" #include "DNA_scene_types.h" @@ -175,7 +177,7 @@ void BKE_free_animdata (ID *id) /* Freeing -------------------------------------------- */ /* Make a copy of the given AnimData - to be used when copying datablocks */ -AnimData *BKE_copy_animdata (AnimData *adt) +AnimData *BKE_copy_animdata (AnimData *adt, const short do_action) { AnimData *dadt; @@ -185,9 +187,15 @@ AnimData *BKE_copy_animdata (AnimData *adt) dadt= MEM_dupallocN(adt); /* make a copy of action - at worst, user has to delete copies... */ - dadt->action= copy_action(adt->action); - dadt->tmpact= copy_action(adt->tmpact); - + if(do_action) { + dadt->action= copy_action(adt->action); + dadt->tmpact= copy_action(adt->tmpact); + } + else { + id_us_plus((ID *)dadt->action); + id_us_plus((ID *)dadt->tmpact); + } + /* duplicate NLA data */ copy_nladata(&dadt->nla_tracks, &adt->nla_tracks); @@ -201,7 +209,7 @@ AnimData *BKE_copy_animdata (AnimData *adt) return dadt; } -int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from) +int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from, const short do_action) { AnimData *adt; @@ -213,13 +221,26 @@ int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from) adt = BKE_animdata_from_id(id_from); if (adt) { IdAdtTemplate *iat = (IdAdtTemplate *)id_to; - iat->adt= BKE_copy_animdata(adt); + iat->adt= BKE_copy_animdata(adt, do_action); } return 1; } - +void BKE_copy_animdata_id_action(struct ID *id) +{ + AnimData *adt= BKE_animdata_from_id(id); + if(adt) { + if(adt->action) { + ((ID *)adt->action)->us--; + adt->action= copy_action(adt->action); + } + if(adt->tmpact) { + ((ID *)adt->tmpact)->us--; + adt->tmpact= copy_action(adt->tmpact); + } + } +} /* Make Local -------------------------------------------- */ diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 34351f9b113..c3bcb3dc69a 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -620,24 +620,24 @@ void *alloc_libblock(ListBase *lb, short type, const char *name) /* by spec, animdata is first item after ID */ /* and, trust that BKE_animdata_from_id() will only find AnimData for valid ID-types */ -static void id_copy_animdata(ID *id) +static void id_copy_animdata(ID *id, const short do_action) { AnimData *adt= BKE_animdata_from_id(id); if (adt) { IdAdtTemplate *iat = (IdAdtTemplate *)id; - iat->adt= BKE_copy_animdata(iat->adt); + iat->adt= BKE_copy_animdata(iat->adt, do_action); /* could be set to FALSE, need to investigate */ } } /* material nodes use this since they are not treated as libdata */ -void copy_libblock_data(ID *id, const ID *id_from) +void copy_libblock_data(ID *id, const ID *id_from, const short do_action) { if (id_from->properties) id->properties = IDP_CopyProperty(id_from->properties); /* the duplicate should get a copy of the animdata */ - id_copy_animdata(id); + id_copy_animdata(id, do_action); } /* used everywhere in blenkernel */ @@ -665,7 +665,7 @@ void *copy_libblock(void *rt) id->newid= idn; idn->flag |= LIB_NEW; - copy_libblock_data(idn, id); + copy_libblock_data(idn, id, FALSE); return idn; } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 6c4c566f5b1..7b25c38648d 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1077,7 +1077,7 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select) newtree= copy_libblock(ntree); } else { newtree= MEM_dupallocN(ntree); - copy_libblock_data(&newtree->id, &ntree->id); /* copy animdata and ID props */ + copy_libblock_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */ } newtree->nodes.first= newtree->nodes.last= NULL; newtree->links.first= newtree->links.last= NULL; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index e399e0bb83d..df02b3d12d2 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -171,7 +171,7 @@ Scene *copy_scene(Scene *sce, int type) BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); if(sce->nodetree) { - scen->nodetree= ntreeCopyTree(sce->nodetree, 0); + scen->nodetree= ntreeCopyTree(sce->nodetree, 0); /* copies actions */ ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); } @@ -216,9 +216,11 @@ Scene *copy_scene(Scene *sce, int type) /* world */ if(type == SCE_COPY_FULL) { + BKE_copy_animdata_id_action((ID *)scen); if(scen->world) { id_us_plus((ID *)scen->world); scen->world= copy_world(scen->world); + BKE_copy_animdata_id_action((ID *)scen->world); } if(sce->ed) { -- cgit v1.2.3 From db4c2b80163731fddd7c1356f5503cd19610e772 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 9 Nov 2010 10:40:03 +0000 Subject: remove unused scene members 'jumpframe' and 'ima' --- source/blender/blenkernel/intern/scene.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index df02b3d12d2..06be370c7d3 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -128,7 +128,6 @@ Scene *copy_scene(Scene *sce, int type) id_us_plus((ID *)scen->world); id_us_plus((ID *)scen->set); - id_us_plus((ID *)scen->ima); id_us_plus((ID *)scen->gm.dome.warptext); scen->ed= NULL; @@ -444,8 +443,7 @@ Scene *add_scene(char *name) pset->brush[a].count= 10; } pset->brush[PE_BRUSH_CUT].strength= 100; - - sce->jumpframe = 10; + sce->r.ffcodecdata.audio_mixrate = 44100; sce->audio.distance_model = 2.0; -- cgit v1.2.3 From b874bdc227e779c443976b1f512115aece0ddc77 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 9 Nov 2010 11:17:00 +0000 Subject: Fix for [#24580] and [#24600] * Particles didn't want to stay cached, even if there were no actual chages. * Particle states weren't set properly for times before actual simulation start. --- source/blender/blenkernel/intern/particle_system.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (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 2b045647661..3de01b61779 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -136,9 +136,12 @@ void psys_reset(ParticleSystem *psys, int mode) if(ELEM(mode, PSYS_RESET_ALL, PSYS_RESET_DEPSGRAPH)) { if(mode == PSYS_RESET_ALL || !(psys->flag & PSYS_EDITED)) { - psys_free_particles(psys); + /* don't free if not absolutely necessary */ + if(psys->totpart != psys->part->totpart) { + psys_free_particles(psys); + psys->totpart= 0; + } - psys->totpart= 0; psys->totkeyed= 0; psys->flag &= ~(PSYS_HAIR_DONE|PSYS_KEYED); @@ -3750,14 +3753,14 @@ static void system_step(ParticleSimulationData *sim, float cfra) /* simulation is only active during a specific period */ if(framenr < startframe) { - psys_reset(psys, PSYS_RESET_CACHE_MISS); + /* set correct particle state and reset particles */ + cached_step(sim, cfra); return; } else if(framenr > endframe) { framenr= endframe; } - - if(framenr == startframe) { + else if(framenr == startframe) { BKE_ptcache_id_reset(sim->scene, use_cache, PTCACHE_RESET_OUTDATED); BKE_ptcache_validate(cache, framenr); cache->flag &= ~PTCACHE_REDO_NEEDED; -- cgit v1.2.3 From 2b96175608a898f5fd00a56250551878e40ec9be Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 9 Nov 2010 11:26:00 +0000 Subject: Bug fix: cutting a sequencer movie strip with sound could crash in some cases. --- source/blender/blenkernel/intern/sequencer.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 4a8c47f1f71..5bc087fcd85 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -610,6 +610,8 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) } seq->strip->len = seq->len; case SEQ_SOUND: + if(!seq->sound) + return; seq->len = ceil(AUD_getInfo(seq->sound->playback_handle).length * FPS); seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; -- cgit v1.2.3 From 9471855be5a2d83ececd54641fde533871069b13 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 10 Nov 2010 04:58:37 +0000 Subject: correct some comments and fix for allocating more memory then needed for animation paths. --- source/blender/blenkernel/intern/anim.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 547d3f7a738..6bbcecce2f7 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -436,6 +436,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) /* free curve path data * NOTE: frees the path itself! + * NOTE: this is increasingly innacurate with non-uniform BevPoint subdivisions [#24633] */ void free_path(Path *path) { @@ -444,7 +445,7 @@ void free_path(Path *path) } /* calculate a curve-deform path for a curve - * - only called from displist.c -> makeDispListCurveTypes + * - only called from displist.c -> do_makeDispListCurveTypes */ void calc_curvepath(Object *ob) { @@ -507,7 +508,7 @@ void calc_curvepath(Object *ob) /* the path verts in path->data */ /* now also with TILT value */ - pp= path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint)*4*path->len, "pathdata"); // XXX - why *4? - in 2.4x each element was 4 and the size was 16, so better leave for now - Campbell + pp= path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint)*path->len, "pathdata"); bevp= bevpfirst; bevpn= bevp+1; @@ -637,7 +638,6 @@ int where_on_path(Object *ob, float ctime, float *vec, float *dir, float *quat, vec[1]= data[0]*p0->vec[1] + data[1]*p1->vec[1] + data[2]*p2->vec[1] + data[3]*p3->vec[1] ; /* Y */ vec[2]= data[0]*p0->vec[2] + data[1]*p1->vec[2] + data[2]*p2->vec[2] + data[3]*p3->vec[2] ; /* Z */ vec[3]= data[0]*p0->vec[3] + data[1]*p1->vec[3] + data[2]*p2->vec[3] + data[3]*p3->vec[3] ; /* Tilt, should not be needed since we have quat still used */ - /* Need to verify the quat interpolation is correct - XXX */ if (quat) { float totfac, q1[4], q2[4]; -- cgit v1.2.3 From 4b45a42b48ea7c787452cd5c7c16eea09be3864c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 10 Nov 2010 08:24:15 +0000 Subject: Removed unused code from multires module --- source/blender/blenkernel/intern/multires.c | 62 ----------------------------- 1 file changed, 62 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 3ebbc44766e..5e3c147a99f 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -180,68 +180,6 @@ void multires_force_render_update(Object *ob) multires_force_update(ob); } -/* XXX */ -#if 0 -void multiresModifier_join(Object *ob) -{ - Base *base = NULL; - int highest_lvl = 0; - - /* First find the highest level of subdivision */ - base = FIRSTBASE; - while(base) { - if(TESTBASELIB_BGMODE(v3d, scene, base) && base->object->type==OB_MESH) { - ModifierData *md; - for(md = base->object->modifiers.first; md; md = md->next) { - if(md->type == eModifierType_Multires) { - int totlvl = ((MultiresModifierData*)md)->totlvl; - if(totlvl > highest_lvl) - highest_lvl = totlvl; - - /* Ensure that all updates are processed */ - multires_force_update(base->object); - } - } - } - base = base->next; - } - - /* No multires meshes selected */ - if(highest_lvl == 0) - return; - - /* Subdivide all the displacements to the highest level */ - base = FIRSTBASE; - while(base) { - if(TESTBASELIB_BGMODE(v3d, scene, base) && base->object->type==OB_MESH) { - ModifierData *md = NULL; - MultiresModifierData *mmd = NULL; - - for(md = base->object->modifiers.first; md; md = md->next) { - if(md->type == eModifierType_Multires) - mmd = (MultiresModifierData*)md; - } - - /* If the object didn't have multires enabled, give it a new modifier */ - if(!mmd) { - md = base->object->modifiers.first; - - while(md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) - md = md->next; - - mmd = (MultiresModifierData*)modifier_new(eModifierType_Multires); - BLI_insertlinkbefore(&base->object->modifiers, md, mmd); - modifier_unique_name(&base->object->modifiers, mmd); - } - - if(mmd) - multiresModifier_subdivide(mmd, base->object, highest_lvl - mmd->totlvl, 0, 0); - } - base = base->next; - } -} -#endif - int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd, Object *ob, DerivedMesh *srcdm) { -- cgit v1.2.3 From cf673cf80a157d13b7cae837cfde58be8d734620 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 11 Nov 2010 09:56:39 +0000 Subject: Fix #24643: Nurbs Surface Preview resolution overrides render resolution NURBS surfaces always used resol{u,v} from spline and never used curve's render resolutions. Now, if curve's render resolution is non-zero then it'll override resolution for all splines when rendering (in needed direction only, ofcource). --- source/blender/blenkernel/intern/curve.c | 47 +++++++++++++++++------------ source/blender/blenkernel/intern/displist.c | 19 ++++++++---- 2 files changed, 41 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index b6b6dde3cdc..0a6e3df2830 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -741,16 +741,16 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas } -void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride) +void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride, int resolu, int resolv) /* coord_array has to be 3*4*resolu*resolv in size, and zero-ed */ { BPoint *bp; float *basisu, *basis, *basisv, *sum, *fp, *in; float u, v, ustart, uend, ustep, vstart, vend, vstep, sumdiv; - int i, j, iofs, jofs, cycl, len, resolu, resolv; + int i, j, iofs, jofs, cycl, len, curu, curv; int istart, iend, jsta, jen, *jstart, *jend, ratcomp; - int totu = nu->pntsu*nu->resolu, totv = nu->pntsv*nu->resolv; + int totu = nu->pntsu*resolu, totv = nu->pntsv*resolv; if(nu->knotsu==NULL || nu->knotsv==NULL) return; if(nu->orderu>nu->pntsu) return; @@ -807,9 +807,9 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride) else cycl= 0; v= vstart; basis= basisv; - resolv= totv; - while(resolv--) { - basisNurb(v, nu->orderv, (short)(nu->pntsv+cycl), nu->knotsv, basis, jstart+resolv, jend+resolv); + curv= totv; + while(curv--) { + basisNurb(v, nu->orderv, (short)(nu->pntsv+cycl), nu->knotsv, basis, jstart+curv, jend+curv); basis+= KNOTSV(nu); v+= vstep; } @@ -818,17 +818,17 @@ void makeNurbfaces(Nurb *nu, float *coord_array, int rowstride) else cycl= 0; in= coord_array; u= ustart; - resolu= totu; - while(resolu--) { + curu= totu; + while(curu--) { basisNurb(u, nu->orderu, (short)(nu->pntsu+cycl), nu->knotsu, basisu, &istart, &iend); basis= basisv; - resolv= totv; - while(resolv--) { + curv= totv; + while(curv--) { - jsta= jstart[resolv]; - jen= jend[resolv]; + jsta= jstart[curv]; + jen= jend[curv]; /* calculate sum */ sumdiv= 0.0; @@ -1056,10 +1056,13 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float float *make_orco_surf(Object *ob) { + /* Note: this function is used in convertblender only atm, so + * suppose nonzero curve's render resolution should always be used */ Curve *cu= ob->data; Nurb *nu; int a, b, tot=0; int sizeu, sizev; + int resolu, resolv; float *fp, *coord_array; /* first calculate the size of the datablock */ @@ -1073,9 +1076,12 @@ float *make_orco_surf(Object *ob) See also convertblender.c: init_render_surf() */ + + resolu= cu->resolu_ren ? cu->resolu_ren : nu->resolu; + resolv= cu->resolv_ren ? cu->resolv_ren : nu->resolv; - sizeu = nu->pntsu*nu->resolu; - sizev = nu->pntsv*nu->resolv; + sizeu = nu->pntsu*resolu; + sizev = nu->pntsv*resolv; if (nu->flagu & CU_NURB_CYCLIC) sizeu++; if (nu->flagv & CU_NURB_CYCLIC) sizev++; if(nu->pntsv>1) tot+= sizeu * sizev; @@ -1087,9 +1093,12 @@ float *make_orco_surf(Object *ob) nu= cu->nurb.first; while(nu) { + resolu= cu->resolu_ren ? cu->resolu_ren : nu->resolu; + resolv= cu->resolv_ren ? cu->resolv_ren : nu->resolv; + if(nu->pntsv>1) { - sizeu = nu->pntsu*nu->resolu; - sizev = nu->pntsv*nu->resolv; + sizeu = nu->pntsu*resolu; + sizev = nu->pntsv*resolv; if (nu->flagu & CU_NURB_CYCLIC) sizeu++; if (nu->flagv & CU_NURB_CYCLIC) sizev++; @@ -1110,10 +1119,10 @@ float *make_orco_surf(Object *ob) } } else { - float *_tdata= MEM_callocN((nu->pntsu*nu->resolu) * (nu->pntsv*nu->resolv) *3*sizeof(float), "temp data"); + float *_tdata= MEM_callocN((nu->pntsu*resolu) * (nu->pntsv*resolv) *3*sizeof(float), "temp data"); float *tdata= _tdata; - makeNurbfaces(nu, tdata, 0); + makeNurbfaces(nu, tdata, 0, resolu, resolv); for(b=0; bflagv & CU_NURB_CYCLIC)) use_a= 0; - tdata = _tdata + 3 * (use_b * (nu->pntsv*nu->resolv) + use_a); + tdata = _tdata + 3 * (use_b * (nu->pntsv*resolv) + use_a); fp[0]= (tdata[0]-cu->loc[0])/cu->size[0]; fp[1]= (tdata[1]-cu->loc[1])/cu->size[1]; diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index a8032f5a40d..9ec23abd842 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1614,8 +1614,15 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, for (nu=nubase->first; nu; nu=nu->next) { if(forRender || nu->hide==0) { + int resolu= nu->resolu, resolv= nu->resolv; + + if(forRender){ + if(cu->resolu_ren) resolu= cu->resolu_ren; + if(cu->resolv_ren) resolv= cu->resolv_ren; + } + if(nu->pntsv==1) { - len= SEGMENTSU(nu)*nu->resolu; + len= SEGMENTSU(nu)*resolu; dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); @@ -1634,10 +1641,10 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, if(nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; else dl->type= DL_SEGM; - makeNurbcurve(nu, data, NULL, NULL, NULL, nu->resolu, 3*sizeof(float)); + makeNurbcurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float)); } else { - len= (nu->pntsu*nu->resolu) * (nu->pntsv*nu->resolv); + len= (nu->pntsu*resolu) * (nu->pntsv*resolv); dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); @@ -1653,12 +1660,12 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, data= dl->verts; dl->type= DL_SURF; - dl->parts= (nu->pntsu*nu->resolu); /* in reverse, because makeNurbfaces works that way */ - dl->nr= (nu->pntsv*nu->resolv); + dl->parts= (nu->pntsu*resolu); /* in reverse, because makeNurbfaces works that way */ + dl->nr= (nu->pntsv*resolv); if(nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */ if(nu->flagu & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_V; - makeNurbfaces(nu, data, 0); + makeNurbfaces(nu, data, 0, resolu, resolv); /* gl array drawing: using indices */ displist_surf_indices(dl); -- cgit v1.2.3 From 7d80a4a067c34b176322b136171678e6886d3b57 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 11 Nov 2010 10:01:10 +0000 Subject: Get rid of G.rendering in curve_to_displist --- source/blender/blenkernel/intern/displist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 9ec23abd842..979bd13a35d 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -789,7 +789,7 @@ void reshadeall_displist(Scene *scene) /* ****************** make displists ********************* */ -static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) +static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, int forRender) { Nurb *nu; DispList *dl; @@ -802,7 +802,7 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase) while(nu) { if(nu->hide==0) { - if(G.rendering && cu->resolu_ren!=0) + if(forRender && cu->resolu_ren!=0) resolu= cu->resolu_ren; else resolu= nu->resolu; @@ -1718,7 +1718,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba /* no bevel or extrude, and no width correction? */ if (!dlbev.first && cu->width==1.0f) { - curve_to_displist(cu, nubase, dispbase); + curve_to_displist(cu, nubase, dispbase, forRender); } else { float widfac= cu->width-1.0; BevList *bl= cu->bev.first; -- cgit v1.2.3 From e3db157074cf8da508cde24b313acb6520194b93 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 11 Nov 2010 10:07:33 +0000 Subject: NLA Transform Bugfix: Transforming strips into locked tracks meant that they were not unlocked properly (i.e. they stayed as temporary "meta" strips). This is now taken into account as part of the step which checks if there's any space for them in those tracks. --- source/blender/blenkernel/intern/nla.c | 9 +++++++-- 1 file changed, 7 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 910de5c6763..5996bdc9f9a 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -916,9 +916,14 @@ void BKE_nlatrack_set_active (ListBase *tracks, NlaTrack *nlt_a) /* Check if there is any space in the given track to add a strip of the given length */ short BKE_nlatrack_has_space (NlaTrack *nlt, float start, float end) { - /* sanity checks */ - if ((nlt == NULL) || IS_EQ(start, end)) + /* sanity checks + * - track must exist + * - track must be editable + * - bounds cannot be equal (0-length is nasty) + */ + if ((nlt == NULL) || (nlt->flag & NLATRACK_PROTECTED) || IS_EQ(start, end)) return 0; + if (start > end) { puts("BKE_nlatrack_has_space() error... start and end arguments swapped"); SWAP(float, start, end); -- cgit v1.2.3 From 1659e3fca76a60da1de2427113633ca06aac33e5 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 11 Nov 2010 17:03:09 +0000 Subject: Bug fix: memoryleak when using smoke heat/velocity data as texture * In addition to fixing the memleak it's much better to always copy the voxeldata to the texture. Smoke data can change at any time due to some changes, so we can't depend on that data. * Thanks to MiikaH for finding this! --- source/blender/blenkernel/intern/texture.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 6a5e5a007f3..595b85955b8 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1286,8 +1286,7 @@ void BKE_free_pointdensity(PointDensity *pd) void BKE_free_voxeldatadata(struct VoxelData *vd) { if (vd->dataset) { - if(vd->file_format != TEX_VD_SMOKE) - MEM_freeN(vd->dataset); + MEM_freeN(vd->dataset); vd->dataset = NULL; } -- cgit v1.2.3 From c69bc46c98d09f85f6f408b0e3bd5008565d7402 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 11 Nov 2010 17:59:52 +0000 Subject: Smoke now uses the start and end of cached data properly when outside the cached frame range. * Patch by MiikaH. --- source/blender/blenkernel/intern/smoke.c | 14 +++++++++++--- 1 file changed, 11 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 aafa2d9870c..c1090326fd9 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1353,13 +1353,17 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } } - if(framenr < startframe) + if(!smd->domain->fluid && (framenr != startframe) && (cache->flag & PTCACHE_BAKED)==0) return; + if(framenr < startframe) + framenr = startframe; + if(framenr > endframe) - return; + framenr = endframe; - if(!smd->domain->fluid && (framenr != startframe) && (cache->flag & PTCACHE_BAKED)==0) + /* If already viewing a pre/after frame, no need to reload */ + if ((smd->time == framenr) && (framenr != scene->r.cfra)) return; // printf("startframe: %d, framenr: %d\n", startframe, framenr); @@ -1402,6 +1406,10 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM else if(framenr != (int)smd->time+1) return; + /* don't simulate if viewing start frame, but scene frame is not real start frame */ + if (framenr != scene->r.cfra) + return; + tstart(); smoke_calc_domain(scene, ob, smd); -- cgit v1.2.3 From ee7bf4dab58131923906108013316826b8669ca2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 12 Nov 2010 11:16:04 +0000 Subject: take delta's into account when applying the objects matrix (dloc, drot, dsize). Now object_apply_mat4() can be used as the reverse of object_to_mat4(). Noticeable result is fly mode and 'Apply Visual Transform' dont jump when deltas are used, also means setting matrix from python works as expected. --- source/blender/blenkernel/intern/object.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 9c76db2b2b5..a10901d15d6 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1682,13 +1682,17 @@ void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) switch(ob->rotmode) { case ROT_MODE_QUAT: mat3_to_quat(ob->quat, mat); + sub_v4_v4(ob->quat, ob->dquat); break; case ROT_MODE_AXISANGLE: mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat); + sub_v3_v3(ob->rotAxis, ob->drotAxis); + ob->rotAngle -= ob->drotAngle; break; default: /* euler */ if(use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, mat); else mat3_to_eulO(ob->rot, ob->rotmode, mat); + sub_v3_v3(ob->rot, ob->drot); } } @@ -1712,6 +1716,10 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const mat4_to_loc_rot_size(ob->loc, rot, ob->size, mat); object_mat3_to_rot(ob, rot, use_compat); } + + sub_v3_v3(ob->loc, ob->dloc); + sub_v3_v3(ob->size, ob->dsize); + /* object_mat3_to_rot handles delta rotations */ } void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ -- cgit v1.2.3 From 2fbfd11f8db0cc6dbb0afc0a018e951f10f2a42c Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Sat, 13 Nov 2010 13:44:45 +0000 Subject: Fix for [#24654] Sound Actuator doesn't find the file when Blender is reopened. --- source/blender/blenkernel/intern/packedFile.c | 6 +++--- source/blender/blenkernel/intern/sound.c | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index e8223caed41..7d7f73222fa 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -467,7 +467,7 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how) return (ret_value); } -int unpackSound(ReportList *reports, bSound *sound, int how) +int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how) { char localname[FILE_MAXDIR + FILE_MAX], fi[FILE_MAX]; char *newname; @@ -486,7 +486,7 @@ int unpackSound(ReportList *reports, bSound *sound, int how) freePackedFile(sound->packedfile); sound->packedfile = 0; - sound_load(NULL, sound); + sound_load(bmain, sound); ret_value = RET_OK; } @@ -536,6 +536,6 @@ void unpackAll(Main *bmain, ReportList *reports, int how) for(sound=bmain->sound.first; sound; sound=sound->id.next) if(sound->packedfile) - unpackSound(reports, sound, how); + unpackSound(bmain, reports, sound, how); } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index cc941c81131..4a9a5fa881b 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -236,7 +236,7 @@ void sound_delete_cache(struct bSound* sound) } } -void sound_load(struct Main *UNUSED(bmain), struct bSound* sound) +void sound_load(struct Main *bmain, struct bSound* sound) { if(sound) { @@ -266,8 +266,7 @@ void sound_load(struct Main *UNUSED(bmain), struct bSound* sound) if(sound->id.lib) path = sound->id.lib->filepath; else - // XXX this should be fixed! - path = /*bmain ? bmain->name :*/ G.main->name; + path = bmain->name; BLI_path_abs(fullpath, path); @@ -277,7 +276,7 @@ void sound_load(struct Main *UNUSED(bmain), struct bSound* sound) /* or else load it from disk */ else sound->handle = AUD_load(fullpath); - } // XXX + } // XXX unused currently #if 0 break; -- cgit v1.2.3 From ba965b0f7adc6b9dc2774ae8806924afe1e966b2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 14 Nov 2010 19:06:39 +0000 Subject: Seamless texture used for beveled curve is now really seamless (thanks to Mario G. Kishalmi aka lmg) --- 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 0a6e3df2830..79e0393cdca 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1212,8 +1212,8 @@ float *make_orco_curve(Scene *scene, Object *ob) for (u=0; uflag & CU_UV_ORCO) { - fp[0]= 2.0f*u/(dl->parts-1) - 1.0f; - fp[1]= 2.0f*v/(dl->nr-1) - 1.0f; + fp[0]= 2.0f*u/(sizev - 1) - 1.0f; + fp[1]= 2.0f*v/(sizeu - 1) - 1.0f; fp[2]= 0.0; } else { float *vert; -- cgit v1.2.3 From 4661fb03a9f5836abb3a2eeb3cc2b67b2d4ecc81 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 15 Nov 2010 08:03:20 +0000 Subject: bugfix [#24704] UV editor: [x] modified does not update on change of modifiers - VBO UV Edge display wasn't allocating a large enough array for drawing. - VBO UV Edge drawing was using an edge flag with faces. - notifier for modifiers updating the UV window. --- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- 1 file changed, 1 insertion(+), 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 20987e15c4d..b820ad00305 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -289,7 +289,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) GPU_uvedge_setup(dm); if( !GPU_buffer_legacy(dm) ) { for(i = 0; i < dm->numFaceData; i++, mf++) { - if(mf->flag&ME_LOOSEEDGE) { + if(!(mf->flag&ME_HIDE)) { draw = 1; } else { -- cgit v1.2.3 From 5182fa2e05f20f9d4fc90851d75f276c0cb1f1bc Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 15 Nov 2010 09:15:23 +0000 Subject: Fix for [#24724] Emission settings of Particles with no physics are stuck to Previous newtonian settings. --- 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 3de01b61779..cb72dc4ddd1 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4083,7 +4083,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if(psys->recalc & PSYS_RECALC_RESET) psys_reset(psys, PSYS_RESET_ALL); - if(emit_particles(&sim, NULL, cfra)) { + if(emit_particles(&sim, NULL, cfra) || (psys->recalc & PSYS_RECALC_RESET)) { free_keyed_keys(psys); distribute_particles(&sim, part->from); initialize_all_particles(&sim); -- cgit v1.2.3 From fd30c383dc74942373395738779ddc432bb70174 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 15 Nov 2010 10:48:48 +0000 Subject: Bugfix #24719: Layer ipocurves from Blender 2.49 wrongly ported to Blender 2.5x Found and fixed a few problems here, but strangely I don't recall seeing any of these a few months ago when this conversion (probably last) worked well ... --- source/blender/blenkernel/intern/ipo.c | 50 ++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 7914bc2b640..5dc1cc2d746 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -111,27 +111,26 @@ typedef struct AdrBit2Path { /* Object layers */ static AdrBit2Path ob_layer_bits[]= { - {(1<<0), "layer", 0}, - {(1<<1), "layer", 1}, - {(1<<2), "layer", 2}, - {(1<<3), "layer", 3}, - {(1<<4), "layer", 4}, - {(1<<5), "layer", 5}, - {(1<<6), "layer", 6}, - {(1<<7), "layer", 7}, - {(1<<8), "layer", 8}, - {(1<<9), "layer", 9}, - {(1<<10), "layer", 10}, - {(1<<11), "layer", 11}, - {(1<<12), "layer", 12}, - {(1<<13), "layer", 13}, - {(1<<14), "layer", 14}, - {(1<<15), "layer", 15}, - {(1<<16), "layer", 16}, - {(1<<17), "layer", 17}, - {(1<<18), "layer", 18}, - {(1<<19), "layer", 19}, - {(1<<20), "layer", 20} + {(1<<0), "layers", 0}, + {(1<<1), "layers", 1}, + {(1<<2), "layers", 2}, + {(1<<3), "layers", 3}, + {(1<<4), "layers", 4}, + {(1<<5), "layers", 5}, + {(1<<6), "layers", 6}, + {(1<<7), "layers", 7}, + {(1<<8), "layers", 8}, + {(1<<9), "layers", 9}, + {(1<<10), "layers", 10}, + {(1<<11), "layers", 11}, + {(1<<12), "layers", 12}, + {(1<<13), "layers", 13}, + {(1<<14), "layers", 14}, + {(1<<15), "layers", 15}, + {(1<<16), "layers", 16}, + {(1<<17), "layers", 17}, + {(1<<18), "layers", 18}, + {(1<<19), "layers", 19} }; /* Material mode */ @@ -1123,7 +1122,6 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * { AdrBit2Path *abp; FCurve *fcu; - unsigned int i=0; int totbits; /* allocate memory for a new F-Curve */ @@ -1189,6 +1187,8 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * 3) filter the keyframes for the flag of interest */ for (b=0; b < totbits; b++, abp++) { + unsigned int i=0; + /* make a copy of existing base-data if not the last curve */ if (b < (totbits-1)) fcurve= copy_fcurve(fcu); @@ -1212,7 +1212,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * fcurve->bezt= MEM_callocN(sizeof(BezTriple)*fcurve->totvert, "BezTriples"); /* loop through copying all BezTriples individually, as we need to modify a few things */ - for (dst=fcurve->bezt, src=icu->bezt; i < fcurve->totvert; i++, dst++, src++) { + for (dst=fcurve->bezt, src=icu->bezt, i=0; i < fcurve->totvert; i++, dst++, src++) { /* firstly, copy BezTriple data */ *dst= *src; @@ -1240,6 +1240,8 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * } } else { + unsigned int i=0; + /* get rna-path * - we will need to set the 'disabled' flag if no path is able to be made (for now) */ @@ -1260,7 +1262,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * fcu->bezt= MEM_callocN(sizeof(BezTriple)*fcu->totvert, "BezTriples"); /* loop through copying all BezTriples individually, as we need to modify a few things */ - for (dst=fcu->bezt, src=icu->bezt; i < fcu->totvert; i++, dst++, src++) { + for (dst=fcu->bezt, src=icu->bezt, i=0; i < fcu->totvert; i++, dst++, src++) { /* firstly, copy BezTriple data */ *dst= *src; -- cgit v1.2.3 From f59b67564110c37d822c58e70a6634405e9ed55a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 16 Nov 2010 02:23:20 +0000 Subject: patch [#24742] materials.pop() doesn't decrement user count from Dan Eicher (dna) --- source/blender/blenkernel/intern/material.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 7e52f746ebc..b41d4bae1cb 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -492,6 +492,7 @@ Material *material_pop_id(ID *id, int index) short *totcol= give_totcolp_id(id); if(index >= 0 && index < (*totcol)) { ret= (*matar)[index]; + id_us_min((ID *)ret); if(*totcol <= 1) { *totcol= 0; MEM_freeN(*matar); -- cgit v1.2.3 From 1e245cc58928ad40c9e665f3aede685a9485ea21 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 16 Nov 2010 14:40:46 +0000 Subject: option to write images to a files on single frame renders, this isn't accessed by the UI at the moment, but could eventually be used for saving test-renders. The main reason to have this is so renders can be scripted to write to a specific file without having to do annoying tricks like set a dummy start/end frame range, render an animation and work out the current frame image will be written to, then rename after rendering. Also made some 'char *' args into 'const char *' --- source/blender/blenkernel/intern/image.c | 6 ++++-- source/blender/blenkernel/intern/sequencer.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 2719563f829..a2435801ac6 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1310,12 +1310,14 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimt } -void BKE_makepicstring(char *string, char *base, int frame, int imtype, int use_ext) +void BKE_makepicstring(char *string, const char *base, int frame, int imtype, const short use_ext, const short use_frames) { if (string==NULL) return; BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ BLI_path_abs(string, G.main->name); - BLI_path_frame(string, frame, 4); + + if(use_frames) + BLI_path_frame(string, frame, 4); if(use_ext) BKE_add_image_extension(string, imtype); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 5bc087fcd85..4272e317cc7 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1828,7 +1828,7 @@ static ImBuf * seq_render_scene_strip_impl( if(re==NULL) re= RE_NewRender(sce->id.name); - RE_BlenderFrame(re, bmain, sce, NULL, sce->lay, frame); + RE_BlenderFrame(re, bmain, sce, NULL, sce->lay, frame, FALSE); /* restore previous state after it was toggled on & off by RE_BlenderFrame */ G.rendering = rendering; -- cgit v1.2.3 From 303646fbd4df3a35d5613a1e091b6a2f81c10255 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 16 Nov 2010 16:39:35 +0000 Subject: Fix for [#24706] 2.55 beta Hair now only rendering small fuzzy blob --- source/blender/blenkernel/intern/particle_system.c | 2 ++ 1 file changed, 2 insertions(+) (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 cb72dc4ddd1..ef3d8eb7dda 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4061,6 +4061,8 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) psys->flag |= PSYS_HAIR_DONE; psys->recalc = recalc; } + else if(psys->flag & PSYS_EDITED) + psys->flag |= PSYS_HAIR_DONE; if(psys->flag & PSYS_HAIR_DONE) hair_step(&sim, cfra); -- cgit v1.2.3 From c658141fad11ae9b60602e458f8abbf9c3c9e87c Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 16 Nov 2010 16:56:21 +0000 Subject: Fix for [#24750] Particles draw percentage setting is not working in No Physics mode --- source/blender/blenkernel/intern/particle_system.c | 6 ++++++ 1 file changed, 6 insertions(+) (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 ef3d8eb7dda..f58ab63ff81 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4080,6 +4080,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) case PART_PHYS_KEYED: { PARTICLE_P; + float disp = (float)psys_get_current_display_percentage(psys)/100.0f; /* Particles without dynamics haven't been reset yet because they don't use pointcache */ if(psys->recalc & PSYS_RECALC_RESET) @@ -4097,6 +4098,11 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); reset_particle(&sim, pa, 0.0, cfra); + + if(PSYS_FRAND(p) > disp) + pa->flag |= PARS_NO_DISP; + else + pa->flag &= ~PARS_NO_DISP; } if(part->phystype == PART_PHYS_KEYED) { -- cgit v1.2.3 From 2d6cf9ee6b5864117a32fcbcaaadbee2bce8a930 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 17 Nov 2010 01:50:25 +0000 Subject: the 'Multi' option was not being copied with the armature modifier. --- source/blender/blenkernel/intern/armature.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index ea01421a0ea..11016ea620f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -813,9 +813,9 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, bDeformGroup *dg; DualQuat *dualquats= NULL; float obinv[4][4], premat[4][4], postmat[4][4]; - int use_envelope = deformflag & ARM_DEF_ENVELOPE; - int use_quaternion = deformflag & ARM_DEF_QUATERNION; - int invert_vgroup= deformflag & ARM_DEF_INVERT_VGROUP; + const short use_envelope = deformflag & ARM_DEF_ENVELOPE; + const short use_quaternion = deformflag & ARM_DEF_QUATERNION; + const short invert_vgroup= deformflag & ARM_DEF_INVERT_VGROUP; int numGroups = 0; /* safety for vertexgroup index overflow */ int i, target_totvert = 0; /* safety for vertexgroup overflow */ int use_dverts = 0; -- cgit v1.2.3 From 51dcbdde033f6e8e55c4b1b4a47ca0624a6571ee Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 17 Nov 2010 09:45:45 +0000 Subject: use 'const char *' by default with RNA functions except when the value is flagged as PROP_THICK_WRAP. Also use const char in many other parts of blenders code. Currently this gives warnings for setting operator id, label and description since these are an exception and allocated beforehand. --- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/blender.c | 6 +++--- source/blender/blenkernel/intern/context.c | 2 +- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/customdata.c | 6 +++--- source/blender/blenkernel/intern/exotic.c | 20 ++++++++++---------- source/blender/blenkernel/intern/font.c | 2 +- source/blender/blenkernel/intern/group.c | 2 +- source/blender/blenkernel/intern/image.c | 6 +++--- source/blender/blenkernel/intern/key.c | 2 +- source/blender/blenkernel/intern/lattice.c | 2 +- source/blender/blenkernel/intern/library.c | 4 ++-- source/blender/blenkernel/intern/material.c | 2 +- source/blender/blenkernel/intern/mball.c | 2 +- source/blender/blenkernel/intern/mesh.c | 2 +- source/blender/blenkernel/intern/object.c | 14 +++++++------- source/blender/blenkernel/intern/packedFile.c | 2 +- source/blender/blenkernel/intern/particle.c | 4 ++-- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenkernel/intern/text.c | 6 +++--- source/blender/blenkernel/intern/world.c | 2 +- 21 files changed, 46 insertions(+), 46 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 11016ea620f..f01bfd98324 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -69,7 +69,7 @@ /* **************** Generic Functions, data level *************** */ -bArmature *add_armature(char *name) +bArmature *add_armature(const char *name) { bArmature *arm; diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index d2b437d9833..bda31448f3f 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -197,7 +197,7 @@ static void clean_paths(Main *main) /* context matching */ /* handle no-ui case */ -static void setup_app_data(bContext *C, BlendFileData *bfd, char *filename) +static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename) { bScreen *curscreen= NULL; Scene *curscene= NULL; @@ -364,7 +364,7 @@ void BKE_userdef_free(void) 2: OK, and with new user settings */ -int BKE_read_file(bContext *C, char *dir, ReportList *reports) +int BKE_read_file(bContext *C, const char *dir, ReportList *reports) { BlendFileData *bfd; int retval= 1; @@ -486,7 +486,7 @@ static int read_undosave(bContext *C, UndoElem *uel) } /* name can be a dynamic string */ -void BKE_write_undo(bContext *C, char *name) +void BKE_write_undo(bContext *C, const char *name) { uintptr_t maxmem, totmem, memused; int nr, success; diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 899ae6031d6..fe010d812b1 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -108,7 +108,7 @@ void CTX_free(bContext *C) /* store */ -bContextStore *CTX_store_add(ListBase *contexts, char *name, PointerRNA *ptr) +bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *ptr) { bContextStoreEntry *entry; bContextStore *ctx, *lastctx; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 79e0393cdca..42d1c13c9ac 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -130,7 +130,7 @@ void free_curve(Curve *cu) if(cu->tb) MEM_freeN(cu->tb); } -Curve *add_curve(char *name, int type) +Curve *add_curve(const char *name, int type) { Curve *cu; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index beb6c085d64..1ef1cefa120 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -984,7 +984,7 @@ int CustomData_get_layer_index(const CustomData *data, int type) return -1; } -int CustomData_get_named_layer_index(const CustomData *data, int type, char *name) +int CustomData_get_named_layer_index(const CustomData *data, int type, const char *name) { int i; @@ -1371,7 +1371,7 @@ void *CustomData_duplicate_referenced_layer(struct CustomData *data, int type) } void *CustomData_duplicate_referenced_layer_named(struct CustomData *data, - int type, char *name) + int type, const char *name) { CustomDataLayer *layer; int layer_index; @@ -1603,7 +1603,7 @@ void *CustomData_get_layer_n(const CustomData *data, int type, int n) } void *CustomData_get_layer_named(const struct CustomData *data, int type, - char *name) + const char *name) { int layer_index = CustomData_get_named_layer_index(data, type, name); if(layer_index < 0) return NULL; diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index a1af728c562..c16d566c7c5 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -85,11 +85,11 @@ #include "zlib.h" -static int is_dxf(char *str); -static void dxf_read(Scene *scene, char *filename); -static int is_stl(char *str); +static int is_dxf(const char *str); +static void dxf_read(Scene *scene, const char *filename); +static int is_stl(const char *str); -static int is_stl_ascii(char *str) +static int is_stl_ascii(const char *str) { FILE *fpSTL; char buffer[1000]; @@ -114,7 +114,7 @@ static int is_stl_ascii(char *str) return 1; } -static int is_stl(char *str) +static int is_stl(const char *str) { int i; i = strlen(str) - 3; @@ -190,7 +190,7 @@ static void mesh_add_normals_flags(Mesh *me) } } -static void read_stl_mesh_binary(Scene *scene, char *str) +static void read_stl_mesh_binary(Scene *scene, const char *str) { FILE *fpSTL; Object *ob; @@ -314,7 +314,7 @@ static void read_stl_mesh_binary(Scene *scene, char *str) STLBAILOUT("Bad vertex!"); \ ++totvert; \ } -static void read_stl_mesh_ascii(Scene *scene, char *str) +static void read_stl_mesh_ascii(Scene *scene, const char *str) { FILE *fpSTL; char buffer[2048], *cp; @@ -454,7 +454,7 @@ static void read_stl_mesh_ascii(Scene *scene, char *str) /* ************************************************************ */ -int BKE_read_exotic(Scene *scene, char *name) +int BKE_read_exotic(Scene *scene, const char *name) { int len; gzFile gzfile; @@ -1069,7 +1069,7 @@ static char val[256]; static short error_exit=0; static short hasbumped=0; -static int is_dxf(char *str) +static int is_dxf(const char *str) { dxf_line=0; @@ -2207,7 +2207,7 @@ static void dxf_read_3dface(Scene *scene, int noob) hasbumped=1; } -static void dxf_read(Scene *scene, char *filename) +static void dxf_read(Scene *scene, const char *filename) { Mesh *lastMe = G.main->mesh.last; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 5fdb9549179..1b5760fc5f1 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -358,7 +358,7 @@ static VFontData *vfont_get_data(VFont *vfont) return vfont->data; } -VFont *load_vfont(char *name) +VFont *load_vfont(const char *name) { char filename[FILE_MAXFILE]; VFont *vfont= NULL; diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 5a031d62fcb..e125f3d4bd7 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -128,7 +128,7 @@ void unlink_group(Group *group) group->id.us= 0; } -Group *add_group(char *name) +Group *add_group(const char *name) { Group *group; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index a2435801ac6..36709c03cf2 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -382,7 +382,7 @@ Image *BKE_add_image_file(const char *name) return ima; } -static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) +static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { ImBuf *ibuf; unsigned char *rect= NULL; @@ -415,7 +415,7 @@ static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, char *name, } /* adds new image block, creates ImBuf and initializes color */ -Image *BKE_add_image_size(unsigned int width, unsigned int height, char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) +Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { /* on save, type is changed to FILE in editsima.c */ Image *ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); @@ -1202,7 +1202,7 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) if (stamp_data.rendertime[0]) IMB_metadata_change_field (ibuf, "RenderTime", stamp_data.rendertime); } -int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, char *name, int imtype, int subimtype, int quality) +int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality) { int ok; (void)subimtype; /* quies unused warnings */ diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index aa9d0b4f57c..c18085b2d73 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1441,7 +1441,7 @@ Key *ob_get_key(Object *ob) return NULL; } -KeyBlock *add_keyblock(Key *key, char *name) +KeyBlock *add_keyblock(Key *key, const char *name) { KeyBlock *kb; float curpos= -0.1; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 638cab58229..73d77e850fd 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -181,7 +181,7 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) MEM_freeN(vertexCos); } -Lattice *add_lattice(char *name) +Lattice *add_lattice(const char *name) { Lattice *lt; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index c3bcb3dc69a..52f5bee075b 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -852,7 +852,7 @@ void free_main(Main *mainvar) /* ***************** ID ************************ */ -ID *find_id(char *type, char *name) /* type: "OB" or "MA" etc */ +ID *find_id(char *type, const char *name) /* type: "OB" or "MA" etc */ { ListBase *lb= which_libbase(G.main, GS(type)); return BLI_findstring(lb, name, offsetof(ID, name) + 2); @@ -1012,7 +1012,7 @@ static void sort_alpha_id(ListBase *lb, ID *id) * Check to see if there is an ID with the same name as 'name'. * Returns the ID if so, if not, returns NULL */ -static ID *is_dupid(ListBase *lb, ID *id, char *name) +static ID *is_dupid(ListBase *lb, ID *id, const char *name) { ID *idtest=NULL; diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index b41d4bae1cb..8096f0277bb 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -185,7 +185,7 @@ void init_material(Material *ma) ma->preview = NULL; } -Material *add_material(char *name) +Material *add_material(const char *name) { Material *ma; diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index dc343e0d6c2..a31a16ba606 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -93,7 +93,7 @@ void free_mball(MetaBall *mb) if(mb->disp.first) freedisplist(&mb->disp); } -MetaBall *add_mball(char *name) +MetaBall *add_mball(const char *name) { MetaBall *mb; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index f5a563faa6f..eb413187544 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -184,7 +184,7 @@ void free_dverts(MDeformVert *dvert, int totvert) MEM_freeN (dvert); } -Mesh *add_mesh(char *name) +Mesh *add_mesh(const char *name) { Mesh *me; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index a10901d15d6..99375c9fb20 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -693,7 +693,7 @@ int exist_object(Object *obtest) return 0; } -void *add_camera(char *name) +void *add_camera(const char *name) { Camera *cam; @@ -794,7 +794,7 @@ float dof_camera(Object *ob) return cam->YF_dofdist; } -void *add_lamp(char *name) +void *add_lamp(const char *name) { Lamp *la; @@ -989,7 +989,7 @@ static char *get_obdata_defname(int type) } /* more general add: creates minimum required data, but without vertices etc. */ -Object *add_only_object(int type, char *name) +Object *add_only_object(int type, const char *name) { Object *ob; @@ -2899,7 +2899,7 @@ void object_delete_ptcache(Object *ob, int index) /* shape key utility function */ /************************* Mesh ************************/ -static KeyBlock *insert_meshkey(Scene *scene, Object *ob, char *name, int from_mix) +static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int from_mix) { Mesh *me= ob->data; Key *key= me->key; @@ -2930,7 +2930,7 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, char *name, int from_m return kb; } /************************* Lattice ************************/ -static KeyBlock *insert_lattkey(Scene *scene, Object *ob, char *name, int from_mix) +static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int from_mix) { Lattice *lt= ob->data; Key *key= lt->key; @@ -2962,7 +2962,7 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, char *name, int from_m return kb; } /************************* Curve ************************/ -static KeyBlock *insert_curvekey(Scene *scene, Object *ob, char *name, int from_mix) +static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int from_mix) { Curve *cu= ob->data; Key *key= cu->key; @@ -2998,7 +2998,7 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, char *name, int from_ return kb; } -KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, char *name, int from_mix) +KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, const char *name, int from_mix) { if(ob->type==OB_MESH) return insert_meshkey(scene, ob, name, from_mix); else if ELEM(ob->type, OB_CURVE, OB_SURF)return insert_curvekey(scene, ob, name, from_mix); diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 7d7f73222fa..3921dfbc394 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -162,7 +162,7 @@ PackedFile *newPackedFileMemory(void *mem, int memlen) return pf; } -PackedFile *newPackedFile(ReportList *reports, char *filename) +PackedFile *newPackedFile(ReportList *reports, const char *filename) { PackedFile *pf = NULL; int file, filelen; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 0dc0b67b377..2eff81b96a6 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3386,7 +3386,7 @@ void psys_mat_hair_to_global(Object *ob, DerivedMesh *dm, short from, ParticleDa /************************************************/ /* ParticleSettings handling */ /************************************************/ -ModifierData *object_add_particle_system(Scene *scene, Object *ob, char *name) +ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *name) { ParticleSystem *psys; ModifierData *md; @@ -3543,7 +3543,7 @@ static void default_particle_settings(ParticleSettings *part) } -ParticleSettings *psys_new_settings(char *name, Main *main) +ParticleSettings *psys_new_settings(const char *name, Main *main) { ParticleSettings *part; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 06be370c7d3..00ef0344a9a 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -317,7 +317,7 @@ void free_scene(Scene *sce) sound_destroy_scene(sce); } -Scene *add_scene(char *name) +Scene *add_scene(const char *name) { Main *bmain= G.main; Scene *sce; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 09910481bf9..bdb8d11945c 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -172,7 +172,7 @@ void free_text(Text *text) #endif } -Text *add_empty_text(char *name) +Text *add_empty_text(const char *name) { Main *bmain= G.main; Text *ta; @@ -325,7 +325,7 @@ int reopen_text(Text *text) return 1; } -Text *add_text(char *file, const char *relpath) +Text *add_text(const char *file, const char *relpath) { Main *bmain= G.main; FILE *fp; @@ -559,7 +559,7 @@ void clear_text(Text *text) /* called directly from rna */ txt_make_dirty(text); } -void write_text(Text *text, char *str) /* called directly from rna */ +void write_text(Text *text, const char *str) /* called directly from rna */ { int oldstate; diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 42df92443f3..a86b039e918 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -63,7 +63,7 @@ void free_world(World *wrld) } -World *add_world(char *name) +World *add_world(const char *name) { Main *bmain= G.main; World *wrld; -- cgit v1.2.3 From f7137610390804b8016240bc6401540a912e2495 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 17 Nov 2010 12:02:36 +0000 Subject: Keyframing Operators: Improved Error Messages * Keyframing operators now use the reports system for displaying all its error messages. - The benefit of this is that users no longer need to check the console for error messages if keyframing fails. - Unfortunately, reports are not currently viewable in any space/view in Blender, so... * Added a temporary operator (UI_OT_reports_to_textblock), which can be accessed in the UI from the button which appears in place of the icon when more than one report exists. This dumps the current list of reports to a textblock "Recent Reports", from which they can be viewed. This isn't really nice, but at least we now have a way to view these again, which makes debugging some things a pain. * Bugfix #24606 - when trying to add keyframes to F-Curves with F-Modifiers already which alter the curve significantly enough that the keyframes will have no effect, there are now warnings which aim to alleviate any confusion. --- source/blender/blenkernel/intern/fcurve.c | 103 +++++++++++++++++++++++++++--- 1 file changed, 93 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 75029af4b10..2f886d8ab43 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -163,7 +163,7 @@ void copy_fcurves (ListBase *dst, ListBase *src) } } -/* --------------------- Finding -------------------------- */ +/* ----------------- Finding F-Curves -------------------------- */ /* high level function to get an fcurve from C without having the rna */ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, char *prop_name, int index) @@ -298,36 +298,36 @@ int list_find_data_fcurves (ListBase *dst, ListBase *src, const char *dataPrefix return matches; } -FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven) +FCurve *rna_get_fcurve (PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven) { FCurve *fcu= NULL; *driven= 0; /* there must be some RNA-pointer + property combon */ - if(prop && ptr->id.data && RNA_property_animateable(ptr, prop)) { + if (prop && ptr->id.data && RNA_property_animateable(ptr, prop)) { AnimData *adt= BKE_animdata_from_id(ptr->id.data); char *path; - if(adt) { - if((adt->action && adt->action->curves.first) || (adt->drivers.first)) { + if (adt) { + if ((adt->action && adt->action->curves.first) || (adt->drivers.first)) { /* XXX this function call can become a performance bottleneck */ path= RNA_path_from_ID_to_property(ptr, prop); - if(path) { + if (path) { /* animation takes priority over drivers */ - if(adt->action && adt->action->curves.first) + if (adt->action && adt->action->curves.first) fcu= list_find_fcurve(&adt->action->curves, path, rnaindex); /* if not animated, check if driven */ - if(!fcu && (adt->drivers.first)) { + if (!fcu && (adt->drivers.first)) { fcu= list_find_fcurve(&adt->drivers, path, rnaindex); - if(fcu) + if (fcu) *driven= 1; } - if(fcu && action) + if (fcu && action) *action= adt->action; MEM_freeN(path); @@ -339,6 +339,8 @@ FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction return fcu; } +/* ----------------- Finding Keyframes/Extents -------------------------- */ + /* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */ #define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */ @@ -520,6 +522,87 @@ void calc_fcurve_range (FCurve *fcu, float *start, float *end) } } +/* ----------------- Status Checks -------------------------- */ + +/* Are keyframes on F-Curve of any use? + * Usability of keyframes refers to whether they should be displayed, + * and also whether they will have any influence on the final result. + */ +short fcurve_are_keyframes_usable (FCurve *fcu) +{ + /* F-Curve must exist */ + if (fcu == NULL) + return 0; + + /* F-Curve must not have samples - samples are mutually exclusive of keyframes */ + if (fcu->fpt) + return 0; + + /* if it has modifiers, none of these should "drastically" alter the curve */ + if (fcu->modifiers.first) { + FModifier *fcm; + + /* check modifiers from last to first, as last will be more influential */ + // TODO: optionally, only check modifier if it is the active one... + for (fcm = fcu->modifiers.last; fcm; fcm = fcm->prev) { + /* ignore if muted/disabled */ + if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) + continue; + + /* type checks */ + switch (fcm->type) { + /* clearly harmless - do nothing */ + case FMODIFIER_TYPE_CYCLES: + case FMODIFIER_TYPE_STEPPED: + case FMODIFIER_TYPE_NOISE: + break; + + /* sometimes harmful - depending on whether they're "additive" or not */ + case FMODIFIER_TYPE_GENERATOR: + { + FMod_Generator *data = (FMod_Generator *)fcm->data; + + if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) + return 0; + } + break; + case FMODIFIER_TYPE_FN_GENERATOR: + { + FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data; + + if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) + return 0; + } + break; + + /* always harmful - cannot allow */ + default: + return 0; + } + } + } + + /* keyframes are usable */ + return 1; +} + +/* Can keyframes be added to F-Curve? + * Keyframes can only be added if they are already visible + */ +short fcurve_is_keyframable (FCurve *fcu) +{ + /* F-Curve's keyframes must be "usable" (i.e. visible + have an effect on final result) */ + if (fcurve_are_keyframes_usable(fcu) == 0) + return 0; + + /* F-Curve must currently be editable too */ + if ( (fcu->flag & FCURVE_PROTECTED) || ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) ) + return 0; + + /* F-Curve is keyframable */ + return 1; +} + /* ***************************** Keyframe Column Tools ********************************* */ /* add a BezTriple to a column */ -- cgit v1.2.3 From 7045ef617fa097e6f9a7919f36c5a494ce046a7b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Nov 2010 03:03:17 +0000 Subject: - many settings in a new scene didn't match the startup.blend defaults, copied into scene.c. - view3d metaball panel wasn't updated for rna name change 'location' -> 'co' --- source/blender/blenkernel/intern/scene.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 00ef0344a9a..ec4495be82d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -338,26 +338,41 @@ Scene *add_scene(const char *name) sce->r.yasp= 1; sce->r.xparts= 8; sce->r.yparts= 8; - sce->r.size= 25; + sce->r.mblur_samples= 1; + sce->r.filtertype= R_FILTER_MITCH; + sce->r.size= 50; sce->r.planes= 24; + sce->r.imtype= R_PNG; sce->r.quality= 90; + sce->r.displaymode= R_OUTPUT_AREA; sce->r.framapto= 100; sce->r.images= 100; sce->r.framelen= 1.0; - sce->r.frs_sec= 25; + sce->r.blurfac= 0.5; + sce->r.frs_sec= 24; sce->r.frs_sec_base= 1; + sce->r.edgeint= 10; sce->r.ocres = 128; sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT; + sce->r.gauss= 1.0; + + /* deprecated but keep for upwards compat */ + sce->r.postgamma= 1.0; + sce->r.posthue= 0.0; + sce->r.postsat= 1.0; sce->r.bake_mode= 1; /* prevent to include render stuff here */ - sce->r.bake_filter= 8; + sce->r.bake_filter= 2; sce->r.bake_osa= 5; sce->r.bake_flag= R_BAKE_CLEAR; sce->r.bake_normal_space= R_BAKE_SPACE_TANGENT; - sce->r.scemode= R_DOCOMP|R_DOSEQ|R_EXTENSION; - sce->r.stamp= R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_SCENE|R_STAMP_CAMERA|R_STAMP_RENDERTIME; + sce->r.stamp= R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE|R_STAMP_FILENAME|R_STAMP_RENDERTIME; sce->r.stamp_font_id= 12; + sce->r.fg_stamp[0]= sce->r.fg_stamp[1]= sce->r.fg_stamp[2]= 0.8f; + sce->r.fg_stamp[3]= 1.0f; + sce->r.bg_stamp[0]= sce->r.bg_stamp[1]= sce->r.bg_stamp[2]= 0.0f; + sce->r.bg_stamp[3]= 0.25f; sce->r.seq_prev_type= OB_SOLID; sce->r.seq_rend_type= OB_SOLID; @@ -445,6 +460,9 @@ Scene *add_scene(const char *name) pset->brush[PE_BRUSH_CUT].strength= 100; sce->r.ffcodecdata.audio_mixrate = 44100; + sce->r.ffcodecdata.audio_volume = 1.0f; + + BLI_strncpy(sce->r.engine, "BLENDER_RENDER", sizeof(sce->r.engine)); sce->audio.distance_model = 2.0; sce->audio.doppler_factor = 1.0; @@ -470,8 +488,8 @@ Scene *add_scene(const char *name) sce->gm.dome.resbuf = 1.0f; sce->gm.dome.tilt = 0; - sce->gm.xplay= 800; - sce->gm.yplay= 600; + sce->gm.xplay= 640; + sce->gm.yplay= 480; sce->gm.freqplay= 60; sce->gm.depth= 32; -- cgit v1.2.3 From 48524d6e9122c323a43ef9fc8ba30b20e101308c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Nov 2010 04:26:50 +0000 Subject: fix [#24780] Metaballs are not drawn correctly in new scenes this is a can of worms, at the moment blender depends on broken behavior for metaballs: find_basis_mball() can return a metaball object that fails a is_basis_mball() check which makes this logic very confusing (added note about this in mball.c). Metaballs needs a refactor however at least make drawing fail consistently, For wire draw is_basis_mball() wasn't being checked, for solid drawing it was (hence the strange wire frame). For now the motherball needs to exist in the main scene else it wont work. --- source/blender/blenkernel/intern/mball.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index a31a16ba606..94ffaaea947 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -309,6 +309,19 @@ float *make_orco_mball(Object *ob, ListBase *dispbase) return orcodata; } + +/* Note on mball basis stuff 2.5x (this is a can of worms) + * This really needs a rewrite/refactorm its totally broken in anything other then basic cases + * Multiple Scenes + Set Scenes & mixing mball basis SHOULD work but fails to update the depsgraph on rename + * and linking into scenes or removal of basis mball. so take care when changing this code. + * + * Main idiot thing here is that the system returns find_basis_mball() objects which fail a is_basis_mball() test. + * + * Not only that but the depsgraph and ther areas depend on this behavior!, so making small fixes here isnt worth it. + * - campbell + */ + + /** \brief Test, if Object *ob is basic MetaBall. * * It test last character of Object ID name. If last character @@ -385,6 +398,8 @@ void copy_mball_properties(Scene *scene, Object *active_object) * its name. All MetaBalls with same base of name can be * blended. MetaBalls with different basic name can't be * blended. + * + * warning!, is_basis_mball() can fail on returned object, see long note above. */ Object *find_basis_mball(Scene *scene, Object *basis) { -- cgit v1.2.3 From 223e70467eda76bbed5b9736206306be6027a2dc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Nov 2010 05:05:06 +0000 Subject: bugfix [#24777] Scale both markers and keyframes at the same time? sync marker option worked for translate and extend but not for scale in the dope sheet. --- source/blender/blenkernel/intern/scene.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index ec4495be82d..edbace71c6d 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -859,6 +859,21 @@ int scene_marker_tfm_extend(Scene *scene, int delta, int flag, int frame, char s return tot; } +int scene_marker_tfm_scale(struct Scene *scene, float value, int flag) +{ + TimeMarker *marker; + int tot= 0; + + for (marker= scene->markers.first; marker; marker= marker->next) { + if ((marker->flag & flag) == flag) { + marker->frame= CFRA + (int)floorf(((float)(marker->frame - CFRA) * value) + 0.5f); + tot++; + } + } + + return tot; +} + Base *scene_add_base(Scene *sce, Object *ob) { Base *b= MEM_callocN(sizeof(*b), "scene_add_base"); -- cgit v1.2.3 From 3ae670fc02f9e4eadf3c92f8c8c30df81e4aaaf2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 18 Nov 2010 14:10:09 +0000 Subject: fix [#24786] Setting Rotation Units to Radians doesn't affect the UI [33146] --- source/blender/blenkernel/intern/unit.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 1240b85393b..4cb59a2ee86 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -255,6 +255,8 @@ static struct bUnitCollection buNaturalTimeCollecton = {buNaturalTimeDef, 3, 0, static struct bUnitDef buNaturalRotDef[] = { {"degree", "degrees", "°", NULL, "Degrees", M_PI/180.0, 0.0, B_UNIT_DEF_NONE}, +// {"radian", "radians", "r", NULL, "Radians", 1.0, 0.0, B_UNIT_DEF_NONE}, +// {"turn", "turns", "t", NULL, "Turns", 1.0/(M_PI*2.0), 0.0,B_UNIT_DEF_NONE}, {NULL, NULL, NULL, NULL, NULL, 0.0, 0.0} }; static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, sizeof(buNaturalRotDef)/sizeof(bUnitDef)}; -- cgit v1.2.3 From 71721f02fc8ae1cfab254bfe575fdf27f849c5c1 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 18 Nov 2010 19:12:36 +0000 Subject: Algorithm fix for fluid particles: * The SPH fluid particle algorithm was implemented a bit wrong. This problem could for example result in the fluid moving sideways after being dropped straight to a horizontal collision surface, a very big no-no as far as real world physics are concerned! * After some extensive code shuffling the algorithm is now much more true to the paper it was implemented from, and more importantly now the physics should be correct too! * The main thing was that fluids calculations can effect many particles simultaneously, so just a single loop through all particles can't work properly. As a side note this also means that the actual fluid algorithm can't be made threaded :( * To make things work I also had to reshuffle some general particle physics code, but there should be no functional changes what so ever to other physics types, so poke me immediately if something strange happens. Note to users: these changes will most probably effect the way previously done sph fluid simulations look, so some parameter tweaking will be needed to get things back looking the way they were. --- source/blender/blenkernel/intern/particle_system.c | 366 +++++++++++---------- 1 file changed, 190 insertions(+), 176 deletions(-) (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 f58ab63ff81..210919eb6da 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2291,132 +2291,121 @@ static void psys_update_effectors(ParticleSimulationData *sim) precalc_guides(sim, sim->psys->effectors); } -/************************************************* +/********************************************************************************************************* SPH fluid physics - In theory, there could be unlimited implementation - of SPH simulators -**************************************************/ -void particle_fluidsim(ParticleSystem *psys, ParticleData *pa, ParticleSettings *part, ParticleSimulationData *sim, float dfra, float UNUSED(cfra), float mass){ -/**************************************************************************************************************** -* This code uses in some parts adapted algorithms from the pseduo code as outlined in the Research paper -* Titled: Particle-based Viscoelastic Fluid Simulation. -* Authors: Simon Clavet, Philippe Beaudoin and Pierre Poulin -* -* Website: http://www.iro.umontreal.ca/labs/infographie/papers/Clavet-2005-PVFS/ -* Presented at Siggraph, (2005) -* -*****************************************************************************************************************/ - KDTree *tree = psys->tree; + In theory, there could be unlimited implementation of SPH simulators + + This code uses in some parts adapted algorithms from the pseduo code as outlined in the Research paper: + + Titled: Particle-based Viscoelastic Fluid Simulation. + Authors: Simon Clavet, Philippe Beaudoin and Pierre Poulin + Website: http://www.iro.umontreal.ca/labs/infographie/papers/Clavet-2005-PVFS/ + + Presented at Siggraph, (2005) + +***********************************************************************************************************/ +static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData *pa, ParticleSettings *part, float dtime, float mass, float *gravity) +{ + SPHFluidSettings *fluid = psys->part->fluid; KDTreeNearest *ptn = NULL; - - SPHFluidSettings *fluid = part->fluid; - ParticleData *second_particle; + ParticleData *npa; - float start[3], end[3], v[3]; float temp[3]; - float q, radius, D; - float p, pnear, pressure_near, pressure; - float dtime = dfra * psys_get_timestep(sim); + float q, q1, u, I, D; + float pressure_near, pressure; + float p=0, pnear=0; + + float radius = fluid->radius; float omega = fluid->viscosity_omega; - float beta = fluid->viscosity_omega; + float beta = fluid->viscosity_beta; float massfactor = 1.0f/mass; - int n, neighbours; - - - radius = fluid->radius; + float spring_k = fluid->spring_k; + float L = fluid->rest_length; - VECCOPY(start, pa->prev_state.co); - VECCOPY(end, pa->state.co); + int n, neighbours = BLI_kdtree_range_search(psys->tree, radius, pa->prev_state.co, NULL, &ptn); + int index = own_psys ? pa - psys->particles : -1; - VECCOPY(v, pa->state.vel); - - neighbours = BLI_kdtree_range_search(tree, radius, start, NULL, &ptn); - - /* use ptn[n].co to store relative direction */ - for(n=1; n 0.f || beta > 0.f) { - float u, I; - - for(n=1; nparticles + ptn[n].index; - q = ptn[n].dist/radius; - - sub_v3_v3v3(temp, v, second_particle->prev_state.vel); - - u = dot_v3v3(ptn[n].co, temp); + /* pressure and near pressure */ + for(n=own_psys?1:0; nprev_state.co); + mul_v3_fl(ptn[n].co, 1.f/ptn[n].dist); + q = ptn[n].dist/radius; - if (u > 0){ - I = dtime * ((1-q) * (omega * u + beta * u*u)) * 0.5f; - madd_v3_v3fl(v, ptn[n].co, -I * massfactor); - } - } - } + if(q < 1.f) { + q1 = 1.f - q; - /* Hooke's spring force */ - if (fluid->spring_k > 0.f) { - float D, L = fluid->rest_length; - for(n=1; nspring_k * (1.f - L) * (L - ptn[n].dist/radius); - madd_v3_v3fl(v, ptn[n].co, -D * massfactor); + p += q1*q1; + pnear += q1*q1*q1; } } - /* Update particle position */ - VECADDFAC(end, start, v, dtime); - /* Double Density Relaxation - Algorithm 2 */ - p = 0; - pnear = 0; - for(n=1; nmass; - pnear *= part->mass; + p *= mass; + pnear *= mass; pressure = fluid->stiffness_k * (p - fluid->rest_density); pressure_near = fluid->stiffness_knear * pnear; - for(n=1; nparticles + ptn[n].index; + q = ptn[n].dist/radius; + q1 = 1.f-q; + + /* Double Density Relaxation - Algorithm 2 (can't be thread safe!)*/ + D = dtime * dtime * (pressure + pressure_near*q1)*q1 * 0.5f; + madd_v3_v3fl(pa->state.co, ptn[n].co, -D * massfactor); + if(own_psys) + madd_v3_v3fl(npa->state.co, ptn[n].co, D * massfactor); + + if(index < ptn[n].index) { + /* Viscosity - Algorithm 5 */ + if(omega > 0.f || beta > 0.f) { + sub_v3_v3v3(temp, pa->state.vel, npa->state.vel); + u = dot_v3v3(ptn[n].co, temp); + + if (u > 0){ + I = dtime * (q1 * (omega * u + beta * u*u)) * 0.5f; + madd_v3_v3fl(pa->state.vel, ptn[n].co, -I * massfactor); + + if(own_psys) + madd_v3_v3fl(npa->state.vel, ptn[n].co, I * massfactor); + } + } - D = dtime * dtime * (pressure*(1-q) + pressure_near*(1-q)*(1-q))* 0.5f; - madd_v3_v3fl(end, ptn[n].co, -D * massfactor); - } + /* Hooke's spring force */ + if(spring_k > 0.f) { + /* L is a factor of radius */ + D = 0.5 * dtime * dtime * 10.f * fluid->spring_k * (1.f - L) * (L - q); + + madd_v3_v3fl(pa->state.co, ptn[n].co, -D * massfactor); + if(own_psys) + madd_v3_v3fl(npa->state.co, ptn[n].co, D * massfactor); + } + } + } /* Artificial buoyancy force in negative gravity direction */ - if (fluid->buoyancy >= 0.f && psys_uses_gravity(sim)) { + if (fluid->buoyancy >= 0.f && gravity) { float B = -dtime * dtime * fluid->buoyancy * (p - fluid->rest_density) * 0.5f; - madd_v3_v3fl(end, sim->scene->physics_settings.gravity, -B * massfactor); + madd_v3_v3fl(pa->state.co, gravity, -B * massfactor); } - /* apply final result and recalculate velocity */ - VECCOPY(pa->state.co, end); - sub_v3_v3v3(pa->state.vel, end, start); - mul_v3_fl(pa->state.vel, 1.f/dtime); - - if(ptn){ MEM_freeN(ptn); ptn=NULL;} + if(ptn) + MEM_freeN(ptn); } -static void apply_particle_fluidsim(ParticleSystem *psys, ParticleData *pa, ParticleSettings *part, ParticleSimulationData *sim, float dfra, float cfra){ +static void apply_particle_fluidsim(Object *ob, ParticleSystem *psys, ParticleData *pa, float dtime, float *gravity){ ParticleTarget *pt; -// float dtime = dfra*psys_get_timestep(sim); - float particle_mass = part->mass; - particle_fluidsim(psys, pa, part, sim, dfra, cfra, particle_mass); + particle_fluidsim(psys, 1, pa, psys->part, dtime, psys->part->mass, gravity); /*----check other SPH systems (Multifluids) , each fluid has its own parameters---*/ - for(pt=sim->psys->targets.first; pt; pt=pt->next) { - ParticleSystem *epsys = psys_get_target_system(sim->ob, pt); + for(pt=psys->targets.first; pt; pt=pt->next) { + ParticleSystem *epsys = psys_get_target_system(ob, pt); if(epsys) - particle_fluidsim(epsys, pa, epsys->part, sim, dfra, cfra, particle_mass); + particle_fluidsim(epsys, 0, pa, epsys->part, dtime, psys->part->mass, gravity); } /*----------------------------------------------------------------*/ } @@ -3372,17 +3361,15 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) /* current time */ float ctime; /* frame & time changes */ - float dfra, dtime, pa_dtime, pa_dfra=0.0; + float dfra, dtime; float birthtime, dietime; - - int invalidParticles=0; /* where have we gone in time since last time */ dfra= cfra - psys->cfra; timestep = psys_get_timestep(sim); - dtime= dfra*timestep; ctime= cfra*timestep; + dtime= dfra*timestep; if(dfra<0.0){ LOOP_EXISTING_PARTICLES { @@ -3402,33 +3389,40 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) if(part->type != PART_HAIR) sim->colliders = get_collider_cache(sim->scene, NULL, NULL); - if(part->phystype==PART_PHYS_BOIDS){ - ParticleTarget *pt = psys->targets.first; - bbd.sim = sim; - bbd.part = part; - bbd.cfra = cfra; - bbd.dfra = dfra; - bbd.timestep = timestep; + /* initialize physics type specific stuff */ + switch(part->phystype) { + case PART_PHYS_BOIDS: + { + ParticleTarget *pt = psys->targets.first; + bbd.sim = sim; + bbd.part = part; + bbd.cfra = cfra; + bbd.dfra = dfra; + bbd.timestep = timestep; - psys_update_particle_tree(psys, cfra); + psys_update_particle_tree(psys, cfra); - boids_precalc_rules(part, cfra); + boids_precalc_rules(part, cfra); - for(; pt; pt=pt->next) { - if(pt->ob) - psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); + for(; pt; pt=pt->next) { + if(pt->ob) + psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); + } + break; } - } - else if(part->phystype==PART_PHYS_FLUID){ - ParticleTarget *pt = psys->targets.first; - psys_update_particle_tree(psys, cfra); - - for(; pt; pt=pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */ - if(pt->ob) psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); + case PART_PHYS_FLUID: + { + ParticleTarget *pt = psys->targets.first; + psys_update_particle_tree(psys, cfra); + + for(; pt; pt=pt->next) { /* Updating others systems particle tree for fluid-fluid interaction */ + if(pt->ob) + psys_update_particle_tree(BLI_findlink(&pt->ob->particlesystem, pt->psys-1), cfra); + } + break; } } - - /* main loop: calculate physics for all particles */ + /* initialize all particles for dynamics */ LOOP_SHOWN_PARTICLES { copy_particle_key(&pa->prev_state,&pa->state,1); @@ -3436,29 +3430,22 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) if(part->randsize > 0.0) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); - ///* reactions can change birth time so they need to be checked first */ - //if(psys->reactevents.first && ELEM(pa->alive,PARS_DEAD,PARS_KILLED)==0) - // react_to_events(psys,p); - birthtime = pa->time; dietime = birthtime + pa->lifetime; - pa_dfra = dfra; - pa_dtime = dtime; - + /* store this, so we can do multiple loops over particles */ + pa->state.time = dfra; if(dietime <= cfra && psys->cfra < dietime){ /* particle dies some time between this and last step */ - pa_dfra = dietime - ((birthtime > psys->cfra) ? birthtime : psys->cfra); - pa_dtime = pa_dfra * timestep; + pa->state.time = dietime - ((birthtime > psys->cfra) ? birthtime : psys->cfra); pa->alive = PARS_DYING; } else if(birthtime <= cfra && birthtime >= psys->cfra){ /* particle is born some time between this and last step*/ - reset_particle(sim, pa, dtime, cfra); + reset_particle(sim, pa, dfra*timestep, cfra); pa->alive = PARS_ALIVE; - pa_dfra = cfra - birthtime; - pa_dtime = pa_dfra*timestep; + pa->state.time = cfra - birthtime; } else if(dietime < cfra){ /* nothing to be done when particle is dead */ @@ -3471,62 +3458,89 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) else if(part->phystype == PART_PHYS_NO) reset_particle(sim, pa, dtime, cfra); - if(pa_dfra>0.0 && ELEM(pa->alive,PARS_ALIVE,PARS_DYING)){ - switch(part->phystype){ - case PART_PHYS_NEWTON: - /* do global forces & effectors */ - apply_particle_forces(sim, p, pa_dfra, cfra); - + if(ELEM(pa->alive, PARS_ALIVE, PARS_DYING)==0 || (pa->flag & (PARS_UNEXIST|PARS_NO_DISP))) + pa->state.time = -1.f; + } + + switch(part->phystype) { + case PART_PHYS_NEWTON: + { + LOOP_DYNAMIC_PARTICLES { + /* do global forces & effectors */ + apply_particle_forces(sim, p, pa->state.time, cfra); + + /* deflection */ + if(sim->colliders) + deflect_particle(sim, p, pa->state.time, cfra); + + /* rotations */ + rotate_particle(part, pa, pa->state.time, timestep); + } + break; + } + case PART_PHYS_BOIDS: + { + LOOP_DYNAMIC_PARTICLES { + bbd.goal_ob = NULL; + + boid_brain(&bbd, p, pa); + + if(pa->alive != PARS_DYING) { + boid_body(&bbd, pa); + /* deflection */ if(sim->colliders) - deflect_particle(sim, p, pa_dfra, cfra); - - /* rotations */ - rotate_particle(part, pa, pa_dfra, timestep); - break; - case PART_PHYS_BOIDS: - { - bbd.goal_ob = NULL; - boid_brain(&bbd, p, pa); - if(pa->alive != PARS_DYING) { - boid_body(&bbd, pa); - - /* deflection */ - if(sim->colliders) - deflect_particle(sim, p, pa_dfra, cfra); - } - break; + deflect_particle(sim, p, pa->state.time, cfra); } - case PART_PHYS_FLUID: - { - /* do global forces & effectors */ - apply_particle_forces(sim, p, pa_dfra, cfra); + } + break; + } + case PART_PHYS_FLUID: + { + float *gravity = NULL; - /* do fluid sim */ - apply_particle_fluidsim(psys, pa, part, sim, pa_dfra, cfra); + if(psys_uses_gravity(sim)) + gravity = sim->scene->physics_settings.gravity; - /* deflection */ - if(sim->colliders) - deflect_particle(sim, p, pa_dfra, cfra); - - /* rotations, SPH particles are not physical particles, just interpolation particles, thus rotation has not a direct sense for them */ - rotate_particle(part, pa, pa_dfra, timestep); - break; - } + /* do global forces & effectors */ + LOOP_DYNAMIC_PARTICLES { + apply_particle_forces(sim, p, pa->state.time, cfra); + /* in fluids forces only effect velocity */ + copy_v3_v3(pa->state.co, pa->prev_state.co); } - if(pa->alive == PARS_DYING){ - //push_reaction(ob,psys,p,PART_EVENT_DEATH,&pa->state); + /* actual fluids calculations (not threadsafe!) */ + LOOP_DYNAMIC_PARTICLES { + apply_particle_fluidsim(sim->ob, psys, pa, pa->state.time*timestep, gravity); + } + + /* apply velocity, collisions and rotation */ + LOOP_DYNAMIC_PARTICLES { + /* velocity holds forces and viscosity, so apply them before collisions */ + madd_v3_v3fl(pa->state.co, pa->state.vel, pa->state.time*timestep); + + /* calculate new velocity based on new-old location */ + sub_v3_v3v3(pa->state.vel, pa->state.co, pa->prev_state.co); + mul_v3_fl(pa->state.vel, 1.f/(pa->state.time*timestep)); - pa->alive=PARS_DEAD; - pa->state.time=pa->dietime; + if(sim->colliders) + deflect_particle(sim, p, pa->state.time, cfra); + + /* SPH particles are not physical particles, just interpolation particles, thus rotation has not a direct sense for them */ + rotate_particle(part, pa, pa->state.time, timestep); } - else - pa->state.time=cfra; + break; + } + } - //push_reaction(ob,psys,p,PART_EVENT_NEAR,&pa->state); + /* finalize particle state and time after dynamics */ + LOOP_DYNAMIC_PARTICLES { + if(pa->alive == PARS_DYING){ + pa->alive=PARS_DEAD; + pa->state.time=pa->dietime; } - if (isnan(pa->state.co[0]) || isnan(pa->state.co[1]) || isnan(pa->state.co[2])) {invalidParticles++;} + else + pa->state.time=cfra; } free_collider_cache(&sim->colliders); -- cgit v1.2.3 From b83cc77b14cec7a7e5925d36c86beee7e6b45845 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 18 Nov 2010 23:48:55 +0000 Subject: Bugfix #24795: Typo fix in particle_system.c Also, fixed indention in armature.c (stupid space-based indention) --- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index f01bfd98324..b5fde5329df 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2410,7 +2410,7 @@ void where_is_pose (Scene *scene, Object *ob) if(ELEM(NULL, arm, scene)) return; if((ob->pose==NULL) || (ob->pose->flag & POSE_RECALC)) - armature_rebuild_pose(ob, arm); + armature_rebuild_pose(ob, arm); ctime= bsystem_time(scene, ob, (float)scene->r.cfra, 0.0); /* not accurate... */ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 210919eb6da..6215e963c27 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2296,7 +2296,7 @@ static void psys_update_effectors(ParticleSimulationData *sim) In theory, there could be unlimited implementation of SPH simulators - This code uses in some parts adapted algorithms from the pseduo code as outlined in the Research paper: + This code uses in some parts adapted algorithms from the pseudo code as outlined in the Research paper: Titled: Particle-based Viscoelastic Fluid Simulation. Authors: Simon Clavet, Philippe Beaudoin and Pierre Poulin -- cgit v1.2.3 From 0b74aab939c24a6999a67cbe58584957b69d6f49 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Nov 2010 01:06:46 +0000 Subject: remove unused argument. --- source/blender/blenkernel/intern/particle_system.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (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 6215e963c27..63f2d692c6d 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2305,7 +2305,7 @@ static void psys_update_effectors(ParticleSimulationData *sim) Presented at Siggraph, (2005) ***********************************************************************************************************/ -static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData *pa, ParticleSettings *part, float dtime, float mass, float *gravity) +static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData *pa, float dtime, float mass, float *gravity) { SPHFluidSettings *fluid = psys->part->fluid; KDTreeNearest *ptn = NULL; @@ -2398,14 +2398,14 @@ static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData * static void apply_particle_fluidsim(Object *ob, ParticleSystem *psys, ParticleData *pa, float dtime, float *gravity){ ParticleTarget *pt; - particle_fluidsim(psys, 1, pa, psys->part, dtime, psys->part->mass, gravity); + particle_fluidsim(psys, 1, pa, dtime, psys->part->mass, gravity); /*----check other SPH systems (Multifluids) , each fluid has its own parameters---*/ for(pt=psys->targets.first; pt; pt=pt->next) { ParticleSystem *epsys = psys_get_target_system(ob, pt); if(epsys) - particle_fluidsim(epsys, 0, pa, epsys->part, dtime, psys->part->mass, gravity); + particle_fluidsim(epsys, 0, pa, dtime, psys->part->mass, gravity); } /*----------------------------------------------------------------*/ } -- cgit v1.2.3 From 5a093689570d27df5ecd7394284a670fc32234b5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Nov 2010 02:14:18 +0000 Subject: use 'const char *' for imbuf and file ops. --- source/blender/blenkernel/intern/idprop.c | 4 ++-- source/blender/blenkernel/intern/packedFile.c | 4 ++-- source/blender/blenkernel/intern/sound.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 639e2062f83..c837f02279b 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -341,7 +341,7 @@ IDProperty *IDP_CopyString(IDProperty *prop) } -void IDP_AssignString(IDProperty *prop, char *st, int maxlen) +void IDP_AssignString(IDProperty *prop, const char *st, int maxlen) { int stlen; @@ -356,7 +356,7 @@ void IDP_AssignString(IDProperty *prop, char *st, int maxlen) BLI_strncpy(prop->data.pointer, st, stlen); } -void IDP_ConcatStringC(IDProperty *prop, char *st) +void IDP_ConcatStringC(IDProperty *prop, const char *st) { int newlen; diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 3921dfbc394..c278bf3b3d2 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -263,7 +263,7 @@ static char *find_new_name(char *name) */ -int writePackedFile(ReportList *reports, char *filename, PackedFile *pf, int guimode) +int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, int guimode) { int file, number, remove_tmp = FALSE; int ret_value = RET_OK; @@ -331,7 +331,7 @@ PF_NOFILE - the original file doens't exist */ -int checkPackedFile(char *filename, PackedFile *pf) +int checkPackedFile(const char *filename, PackedFile *pf) { struct stat st; int ret_val, i, len, file; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 4a9a5fa881b..443ed1f7987 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -120,7 +120,7 @@ void sound_exit() AUD_exit(); } -struct bSound* sound_new_file(struct Main *bmain, char* filename) +struct bSound* sound_new_file(struct Main *bmain, const char *filename) { bSound* sound = NULL; -- cgit v1.2.3 From 18200f5f8711e630adb729b8bffffb5893fd0c02 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Nov 2010 06:21:39 +0000 Subject: bugfix for pivot constraint. - no rotation resulted in NAN location. - subtraction of pivot done in wrong order made the constraint give odd results when rotating on more then 1 axis. --- source/blender/blenkernel/intern/constraint.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 5dff21d8af4..076dae41e6a 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3814,7 +3814,6 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t /* pivot correction */ float axis[3], angle; - float dvec[3]; /* firstly, check if pivoting should take place based on the current rotation */ if (data->rotAxis != PIVOTCON_AXIS_NONE) { @@ -3861,14 +3860,16 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t /* correct the pivot by the rotation axis otherwise the pivot translates when it shouldnt */ mat3_to_axis_angle(axis, &angle, rotMat); - sub_v3_v3v3(vec, pivot, cob->matrix[3]); - project_v3_v3v3(dvec, vec, axis); - sub_v3_v3(pivot, dvec); - + if(angle) { + float dvec[3]; + sub_v3_v3v3(vec, pivot, cob->matrix[3]); + project_v3_v3v3(dvec, vec, axis); + sub_v3_v3(pivot, dvec); + } /* perform the pivoting... */ /* 1. take the vector from owner to the pivot */ - sub_v3_v3v3(vec, pivot, cob->matrix[3]); + sub_v3_v3v3(vec, cob->matrix[3], pivot); /* 2. rotate this vector by the rotation of the object... */ mul_m3_v3(rotMat, vec); /* 3. make the rotation in terms of the pivot now */ -- cgit v1.2.3 From 39de1914abb3ba8dac522c849bf744c8558d5756 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Nov 2010 07:31:24 +0000 Subject: bugfix [#24796] Drivers are ineffective on Text & Curve obj. geometry parameters also added note that adjusting bone radius changes the parent bone for connected child bones, and fix typo on failing to read startup.blend (both pointed out by MikeS on IRC) --- source/blender/blenkernel/intern/object.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 99375c9fb20..35e57829c65 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2551,9 +2551,13 @@ void object_handle_update(Scene *scene, Object *ob) makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH); } else if(ob->type==OB_MBALL) { + /* evaluate drivers */ + BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); makeDispListMBall(scene, ob); } else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { + /* evaluate drivers */ + BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); makeDispListCurveTypes(scene, ob, 0); } else if(ELEM(ob->type, OB_CAMERA, OB_LAMP)) { -- cgit v1.2.3 From ab7282391730c76364228081597ab0f3d912a280 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Nov 2010 07:40:17 +0000 Subject: edit on last commit, for calculating drivers on obdata just check for animdata rather then the object type. also use switch rather then if checks. --- source/blender/blenkernel/intern/object.c | 71 ++++++++++++++++--------------- 1 file changed, 36 insertions(+), 35 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 35e57829c65..fe557dfefa0 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2534,52 +2534,53 @@ void object_handle_update(Scene *scene, Object *ob) if (G.f & G_DEBUG) printf("recalcdata %s\n", ob->id.name+2); - - /* includes all keys and modifiers */ - if(ob->type==OB_MESH) { - EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; - - /* evaluate drivers */ - // XXX: should we push this to derivedmesh instead? - BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); - - // here was vieweditdatamask? XXX - if(em) { - makeDerivedMesh(scene, ob, em, CD_MASK_BAREMESH); - BKE_mesh_end_editmesh(ob->data, em); - } else - makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH); - } - else if(ob->type==OB_MBALL) { - /* evaluate drivers */ - BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); - makeDispListMBall(scene, ob); - } - else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - /* evaluate drivers */ - BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); - makeDispListCurveTypes(scene, ob, 0); - } - else if(ELEM(ob->type, OB_CAMERA, OB_LAMP)) { + + if(adt) { /* evaluate drivers */ + // XXX: for mesh types, should we push this to derivedmesh instead? BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); } - else if(ob->type==OB_LATTICE) { - lattice_calc_modifiers(scene, ob); - } - else if(ob->type==OB_ARMATURE) { - /* evaluate drivers */ - BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS); - + + /* includes all keys and modifiers */ + switch(ob->type) { + case OB_MESH: + { + EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; + // here was vieweditdatamask? XXX + if(em) { + makeDerivedMesh(scene, ob, em, CD_MASK_BAREMESH); + BKE_mesh_end_editmesh(ob->data, em); + } else + makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH); + } + break; + + case OB_ARMATURE: if(ob->id.lib && ob->proxy_from) { - copy_pose_result(ob->pose, ob->proxy_from->pose); // printf("pose proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name); + copy_pose_result(ob->pose, ob->proxy_from->pose); } else { where_is_pose(scene, ob); } + break; + + case OB_MBALL: + makeDispListMBall(scene, ob); + break; + + case OB_CURVE: + case OB_SURF: + case OB_FONT: + makeDispListCurveTypes(scene, ob, 0); + break; + + case OB_LATTICE: + lattice_calc_modifiers(scene, ob); + break; } + if(ob->particlesystem.first) { ParticleSystem *tpsys, *psys; DerivedMesh *dm; -- cgit v1.2.3 From bf14b214813c48beea1c9ca50e58b6002ec869a6 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 20 Nov 2010 18:54:58 +0000 Subject: == Multires == Fixed bug #20620, "VertColors and Flat/Soft imported from 2.49 are wrong (MultiRes)" reported by Manuel R. * Added function to load level-0 vertex colors * Added function to load level-0 face flags * Warning: the 2.5 multires modifier doesn't support multires vertex colors or multires face flags; that data will be lost if you import it into 2.5. --- source/blender/blenkernel/intern/multires.c | 49 +++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 5e3c147a99f..7f7433f8965 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1325,6 +1325,52 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) multires_mvert_to_ss(dm, vdst); } +/* Copy the first-level vcol data to the mesh, if it exists */ +/* Warning: higher-level vcol data will be lost */ +static void multires_load_old_vcols(Mesh *me) +{ + MultiresLevel *lvl; + MultiresColFace *colface; + MCol *mcol; + int i, j; + + if(!(lvl = me->mr->levels.first)) + return; + + if(!(colface = lvl->colfaces)) + return; + + /* older multires format never supported multiple vcol layers, + so we can assume the active vcol layer is the correct one */ + if(!(mcol = CustomData_get_layer(&me->fdata, CD_MCOL))) + return; + + for(i = 0; i < me->totface; ++i) { + for(j = 0; j < 4; ++j) { + mcol[i*4 + j].a = colface[i].col[j].a; + mcol[i*4 + j].r = colface[i].col[j].r; + mcol[i*4 + j].g = colface[i].col[j].g; + mcol[i*4 + j].b = colface[i].col[j].b; + } + } +} + +/* Copy the first-level face-flag data to the mesh */ +static void multires_load_old_face_flags(Mesh *me) +{ + MultiresLevel *lvl; + MultiresFace *faces; + int i; + + if(!(lvl = me->mr->levels.first)) + return; + + if(!(faces = lvl->faces)) + return; + + for(i = 0; i < me->totface; ++i) + me->mface[i].flag = faces[i].flag; +} void multires_load_old(Object *ob, Mesh *me) { @@ -1386,6 +1432,9 @@ void multires_load_old(Object *ob, Mesh *me) memset(&me->mr->vdata, 0, sizeof(CustomData)); memset(&me->mr->fdata, 0, sizeof(CustomData)); + multires_load_old_vcols(me); + multires_load_old_face_flags(me); + /* Remove the old multires */ multires_free(me->mr); me->mr= NULL; -- cgit v1.2.3 From d016f52c21ec303c9d6729d7ef819e367965c36c Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 21 Nov 2010 18:46:50 +0000 Subject: Bugfix #22611 (Well, while testing this report I found this fix!) Blender could crash after rendering a 2.4 or 2.5 file The context before/during/after file reads is still fishy. Need a more clear & clean mind to really check it from scratch again. --- source/blender/blenkernel/intern/blender.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index bda31448f3f..170b2702a57 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -237,6 +237,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename } /* free G.main Main database */ + CTX_wm_manager_set(C, NULL); clear_global(); G.main= bfd->main; -- cgit v1.2.3 From a0517e63381822651d6dc1582bdddebb141ef936 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 21 Nov 2010 20:00:31 +0000 Subject: == Sequencer == * documented and rewrote the render interface of the sequencer. (now, the geometry / render_type / etc. settings are stored within a seperate structure called SeqRenderData that is passed within the code.) * that fixes * cache problems, since the caching system didn't keep track of proxy files vs. final renders. * is a necessary step, to bring back frame blending in speed effect (the SeqRenderData structure elements are already there) * will make motion blur render options available within the sequencer! * this patch also fixes: * "easy retiming" using speed effects. (in Blender 2.49, you could add a speed effect and resize the source track to retime it to that length) * adds labels for the Original dimensions for Image + Movie tracks (worked in 2.49, too) --- source/blender/blenkernel/intern/seqcache.c | 31 +-- source/blender/blenkernel/intern/seqeffects.c | 220 ++++++++--------- source/blender/blenkernel/intern/sequencer.c | 339 ++++++++++++++++---------- 3 files changed, 331 insertions(+), 259 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 487ec78b2bd..73351edbdd5 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -42,8 +42,7 @@ typedef struct seqCacheKey { struct Sequence * seq; - int rectx; - int recty; + SeqRenderData context; float cfra; seq_stripelem_ibuf_t type; } seqCacheKey; @@ -64,7 +63,7 @@ static int ibufs_rem = 0; static unsigned int HashHash(void *key_) { seqCacheKey * key = (seqCacheKey*) key_; - unsigned int rval = key->rectx + key->recty; + unsigned int rval = seq_hash_render_data(&key->context); rval ^= *(unsigned int*) &key->cfra; rval += key->type; @@ -99,21 +98,7 @@ static int HashCmp(void *a_, void *b_) 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; + return seq_cmp_render_data(&a->context, &b->context); } static void HashKeyFree(void *key) @@ -192,7 +177,7 @@ void seq_stripelem_cache_cleanup() } struct ImBuf * seq_stripelem_cache_get( - struct Sequence * seq, int rectx, int recty, + SeqRenderData context, struct Sequence * seq, float cfra, seq_stripelem_ibuf_t type) { seqCacheKey key; @@ -207,8 +192,7 @@ struct ImBuf * seq_stripelem_cache_get( } key.seq = seq; - key.rectx = rectx; - key.recty = recty; + key.context = context; key.cfra = cfra - seq->start; key.type = type; @@ -224,7 +208,7 @@ struct ImBuf * seq_stripelem_cache_get( } void seq_stripelem_cache_put( - struct Sequence * seq, int rectx, int recty, + SeqRenderData context, struct Sequence * seq, float cfra, seq_stripelem_ibuf_t type, struct ImBuf * i) { seqCacheKey * key; @@ -243,8 +227,7 @@ void seq_stripelem_cache_put( key = (seqCacheKey*) BLI_mempool_alloc(keypool); key->seq = seq; - key->rectx = rectx; - key->recty = recty; + key->context = context; key->cfra = cfra - seq->start; key->type = type; diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index f5dc04ca569..2efef52ed3e 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -69,11 +69,13 @@ enum { }; static struct ImBuf * prepare_effect_imbufs( - int x, int y, + SeqRenderData context, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { struct ImBuf * out; + int x = context.rectx; + int y = context.recty; if (!ibuf1 && !ibuf2 && !ibuf3) { /* hmmm, global float option ? */ @@ -273,9 +275,8 @@ static ImBuf * IMB_cast_away_list(ImBuf * i) } static struct ImBuf * do_plugin_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float cfra, - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *seq, float cfra, + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { @@ -285,7 +286,9 @@ static struct ImBuf * do_plugin_effect( old plugins) do very bad stuff with imbuf-internals */ - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + int x = context.rectx; + int y = context.recty; if(seq->plugin && seq->plugin->doit) { @@ -524,22 +527,21 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_alphaover_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_alphaover_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_alphaover_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } @@ -696,22 +698,22 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf* do_alphaunder_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs( + context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_alphaunder_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_alphaunder_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } @@ -821,22 +823,22 @@ 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( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs( + context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_cross_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_cross_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } @@ -1088,24 +1090,24 @@ static void do_gammacross_effect_float(float facf0, float UNUSED(facf1), } static struct ImBuf * do_gammacross_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, + Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); build_gammatabs(); if (out->rect_float) { do_gammacross_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_gammacross_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } @@ -1206,22 +1208,22 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf * do_add_effect(Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), +static struct ImBuf * do_add_effect(SeqRenderData context, + Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_add_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_add_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } @@ -1323,22 +1325,21 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_sub_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_sub_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_sub_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (char*) ibuf1->rect, (char*) ibuf2->rect, (char*) out->rect); } @@ -1537,22 +1538,21 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, } static struct ImBuf * do_mul_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_mul_effect_float( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, ibuf1->rect_float, ibuf2->rect_float, out->rect_float); } else { do_mul_effect_byte( - facf0, facf1, x, y, + facf0, facf1, context.rectx, context.recty, (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, (unsigned char*) out->rect); } @@ -1993,24 +1993,23 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1) } static struct ImBuf * do_wipe_effect( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_wipe_effect_float(seq, - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_wipe_effect_byte(seq, - facf0, facf1, x, y, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, + (unsigned char*) out->rect); } return out; @@ -2062,8 +2061,8 @@ static void copy_transform_effect(Sequence *dst, Sequence *src) } static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out, - float scale_x, float scale_y, float translate_x, float translate_y, - float rotate, int interpolation) + float scale_x, float scale_y, float translate_x, float translate_y, + float rotate, int interpolation) { int xo, yo, xi, yi; float xt, yt, xr, yr; @@ -2144,15 +2143,15 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x static struct ImBuf * do_transform_effect( - Main *UNUSED(bmain), Scene *scene, Sequence *seq,float UNUSED(cfra), - float facf0, float UNUSED(facf1), int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *seq,float UNUSED(cfra), + float facf0, float UNUSED(facf1), struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); - do_transform(scene, seq, facf0, x, y, ibuf1, out); + do_transform(context.scene, seq, facf0, + context.rectx, context.recty, ibuf1, out); return out; } @@ -2660,26 +2659,27 @@ static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, fl } static struct ImBuf * do_glow_effect( - Main *UNUSED(bmain), Scene * scene, Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); - int render_size = 100*x/scene->r.xsch; + int render_size = 100*context.rectx/context.scene->r.xsch; if (out->rect_float) { do_glow_effect_float(seq, render_size, - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, + context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_glow_effect_byte(seq, render_size, - facf0, facf1, x, y, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, + context.rectx, context.recty, + (char*) ibuf1->rect, (char*) ibuf2->rect, + (char*) out->rect); } return out; @@ -2723,18 +2723,19 @@ static int early_out_color(struct Sequence *UNUSED(seq), } static struct ImBuf * do_solid_color( - Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, int x, int y, - int UNUSED(preview_render_size), + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, struct ImBuf *ibuf1, struct ImBuf *ibuf2, struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); SolidColorVars *cv = (SolidColorVars *)seq->effectdata; unsigned char *rect; float *rect_float; + int x = context.rectx; + int y = context.recty; if (out->rect) { unsigned char col0[3]; @@ -2819,9 +2820,8 @@ static int early_out_multicam(struct Sequence *UNUSED(seq), float UNUSED(facf0), } static struct ImBuf * do_multicam( - Main *bmain, Scene *scene, Sequence *seq, float cfra, - float UNUSED(facf0), float UNUSED(facf1), int x, int y, - int preview_render_size, + SeqRenderData context, Sequence *seq, float cfra, + float UNUSED(facf0), float UNUSED(facf1), struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), struct ImBuf *UNUSED(ibuf3)) { @@ -2834,7 +2834,7 @@ static struct ImBuf * do_multicam( return 0; } - ed = scene->ed; + ed = context.scene->ed; if (!ed) { return 0; } @@ -2843,13 +2843,12 @@ static struct ImBuf * do_multicam( return 0; } - i = give_ibuf_seqbase(bmain, scene, x, y, cfra, seq->multicam_source, - preview_render_size, seqbasep); + i = give_ibuf_seqbase(context, cfra, seq->multicam_source, seqbasep); if (!i) { return 0; } - if (input_have_to_preprocess(scene, seq, cfra, x, y)) { + if (input_have_to_preprocess(context, seq, cfra)) { out = IMB_dupImBuf(i); IMB_freeImBuf(i); } else { @@ -2940,6 +2939,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) float fallback_fac = 1.0f; SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; FCurve *fcu= NULL; + int flags = v->flags; /* if not already done, load / initialize data */ get_sequence_effect(seq); @@ -2965,12 +2965,25 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) v->frameMap = MEM_callocN(sizeof(float) * v->length, "speedcontrol frameMap"); } - - /* if there is no fcurve, use value as simple multiplier */ - if (!fcu) - fallback_fac = seq->speed_fader; /* same as speed_factor in rna*/ - if (v->flags & SEQ_SPEED_INTEGRATE) { + fallback_fac = 1.0; + + if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) { + if (seq->seq1->enddisp != seq->seq1->start + && seq->seq1->len != 0) { + fallback_fac = (float) seq->seq1->len / + (float) (seq->seq1->enddisp - seq->seq1->start); + flags = SEQ_SPEED_INTEGRATE; + fcu = NULL; + } + } else { + /* if there is no fcurve, use value as simple multiplier */ + if (!fcu) { + fallback_fac = seq->speed_fader; /* same as speed_factor in rna*/ + } + } + + if (flags & SEQ_SPEED_INTEGRATE) { float cursor = 0; float facf; @@ -3006,7 +3019,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) facf = fallback_fac; } - if (v->flags & SEQ_SPEED_COMPRESS_IPO_Y) { + if (flags & SEQ_SPEED_COMPRESS_IPO_Y) { facf *= seq->seq1->len; } facf *= v->globalSpeed; @@ -3021,19 +3034,6 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) } } -/* - simply reuse do_cross_effect for blending... - -static void do_speed_effect(Sequence * seq,int cfra, - float facf0, float facf1, int x, int y, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3, struct ImBuf *out) -{ - -} -*/ - - /* ********************************************************************** sequence effect factory ********************************************************************** */ @@ -3111,15 +3111,17 @@ static void get_default_fac_fade(struct Sequence *seq, float cfra, *facf1 /= seq->len; } -static struct ImBuf * do_overdrop_effect(Main *UNUSED(bmain), Scene *UNUSED(scene), Sequence *UNUSED(seq), float UNUSED(cfra), +static struct ImBuf * do_overdrop_effect(SeqRenderData context, + Sequence *UNUSED(seq), + float UNUSED(cfra), float facf0, float facf1, - int x, int y, - int UNUSED(preview_render_size), struct ImBuf * ibuf1, struct ImBuf * ibuf2, struct ImBuf * ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(x, y, ibuf1, ibuf2, ibuf3); + struct ImBuf * out = prepare_effect_imbufs(context,ibuf1, ibuf2, ibuf3); + int x = context.rectx; + int y = context.recty; if (out->rect_float) { do_drop_effect_float( diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 4272e317cc7..9059d35cac3 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -242,6 +242,94 @@ void seq_free_editing(Scene *scene) MEM_freeN(ed); } +/* ********************************************************************** + * sequencer pipeline functions + ********************************************************************** */ + +SeqRenderData seq_new_render_data( + struct Main * bmain, struct Scene * scene, + int rectx, int recty, int preview_render_size) +{ + SeqRenderData rval; + + rval.bmain = bmain; + rval.scene = scene; + rval.rectx = rectx; + rval.recty = recty; + rval.preview_render_size = preview_render_size; + rval.motion_blur_samples = 0; + rval.motion_blur_shutter = 0; + + return rval; +} + +int seq_cmp_render_data(SeqRenderData * a, SeqRenderData * b) +{ + if (a->preview_render_size < b->preview_render_size) { + return -1; + } + if (a->preview_render_size > b->preview_render_size) { + 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; + } + + if (a->bmain < b->bmain) { + return -1; + } + if (a->bmain > b->bmain) { + return 1; + } + + if (a->scene < b->scene) { + return -1; + } + if (a->scene > b->scene) { + return 1; + } + + if (a->motion_blur_shutter < b->motion_blur_shutter) { + return -1; + } + if (a->motion_blur_shutter > b->motion_blur_shutter) { + return 1; + } + + if (a->motion_blur_samples < b->motion_blur_samples) { + return -1; + } + if (a->motion_blur_samples > b->motion_blur_samples) { + return 1; + } + + return 0; +} + +unsigned int seq_hash_render_data(SeqRenderData * a) +{ + unsigned int rval = a->rectx + a->recty; + + rval ^= a->preview_render_size; + rval ^= ((intptr_t) a->bmain) << 6; + rval ^= ((intptr_t) a->scene) << 6; + rval ^= (int) (a->motion_blur_shutter * 100.0) << 10; + rval ^= a->motion_blur_samples << 24; + + return rval; +} + /* ************************* itterator ************************** */ /* *************** (replaces old WHILE_SEQ) ********************* */ /* **************** use now SEQ_BEGIN() SEQ_END ***************** */ @@ -1024,7 +1112,7 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se #define PROXY_MAXFILE (2*FILE_MAXDIR+FILE_MAXFILE) -static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, char * name, int preview_render_size) +static int seq_proxy_get_fname(SeqRenderData context, Sequence * seq, int cfra, char * name) { int frameno; char dir[FILE_MAXDIR]; @@ -1055,17 +1143,19 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c switch(seq->type) { case SEQ_IMAGE: snprintf(name, PROXY_MAXFILE, "%s/images/%d/%s_proxy", dir, - preview_render_size, give_stripelem(seq, cfra)->name); + context.preview_render_size, + give_stripelem(seq, cfra)->name); frameno = 1; break; case SEQ_MOVIE: frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; snprintf(name, PROXY_MAXFILE, "%s/%s/%d/####", dir, - seq->strip->stripdata->name, preview_render_size); + seq->strip->stripdata->name, context.preview_render_size); break; default: frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; - snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, preview_render_size); + snprintf(name, PROXY_MAXFILE, "%s/proxy_misc/%d/####", dir, + context.preview_render_size); } BLI_path_abs(name, G.main->name); @@ -1076,7 +1166,7 @@ static int seq_proxy_get_fname(Scene *UNUSED(scene), Sequence * seq, int cfra, c return TRUE; } -static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, int preview_render_size) +static struct ImBuf * seq_proxy_fetch(SeqRenderData context, Sequence * seq, int cfra) { char name[PROXY_MAXFILE]; @@ -1085,14 +1175,14 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in } /* rendering at 100% ? No real sense in proxy-ing, right? */ - if (preview_render_size == 100) { + if (context.preview_render_size == 100) { return 0; } if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { int frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; if (seq->strip->proxy->anim == NULL) { - if (seq_proxy_get_fname(scene, seq, cfra, name, preview_render_size)==0) { + if (seq_proxy_get_fname(context, seq, cfra, name)==0) { return 0; } @@ -1105,7 +1195,7 @@ static struct ImBuf * seq_proxy_fetch(Scene *scene, Sequence * seq, int cfra, in return IMB_anim_absolute(seq->strip->proxy->anim, frameno); } - if (seq_proxy_get_fname(scene, seq, cfra, name, preview_render_size)==0) { + if (seq_proxy_get_fname(context, seq, cfra, name) == 0) { return 0; } @@ -1437,12 +1527,12 @@ static void color_balance(Sequence * seq, ImBuf* ibuf, float mul) */ int input_have_to_preprocess( - Scene *UNUSED(scene), Sequence * seq, float UNUSED(cfra), int UNUSED(seqrectx), int UNUSED(seqrecty)) + SeqRenderData UNUSED(context), Sequence * seq, float cfra) { float mul; if (seq->flag & (SEQ_FILTERY|SEQ_USE_CROP|SEQ_USE_TRANSFORM|SEQ_FLIPX| - SEQ_FLIPY|SEQ_USE_COLOR_BALANCE|SEQ_MAKE_PREMUL)) { + SEQ_FLIPY|SEQ_USE_COLOR_BALANCE|SEQ_MAKE_PREMUL)) { return TRUE; } @@ -1464,7 +1554,7 @@ int input_have_to_preprocess( } static ImBuf * input_preprocess( - Scene *scene, Sequence *seq, float UNUSED(cfra), int seqrectx, int seqrecty, ImBuf * ibuf) + SeqRenderData context, Sequence *seq, float UNUSED(cfra), ImBuf * ibuf) { float mul; @@ -1493,8 +1583,8 @@ static ImBuf * input_preprocess( dy = sy; if (seq->flag & SEQ_USE_TRANSFORM) { - dx = scene->r.xsch; - dy = scene->r.ysch; + dx = context.scene->r.xsch; + dy = context.scene->r.ysch; } if (c.top + c.bottom >= ibuf->y || c.left + c.right >= ibuf->x || @@ -1576,30 +1666,30 @@ static ImBuf * input_preprocess( } - if(ibuf->x != seqrectx || ibuf->y != seqrecty ) { - if(scene->r.mode & R_OSA) { - IMB_scaleImBuf(ibuf, (short)seqrectx, (short)seqrecty); + if(ibuf->x != context.rectx || ibuf->y != context.recty ) { + if(context.scene->r.mode & R_OSA) { + IMB_scaleImBuf(ibuf, (short)context.rectx, (short)context.recty); } else { - IMB_scalefastImBuf(ibuf, (short)seqrectx, (short)seqrecty); + IMB_scalefastImBuf(ibuf, (short)context.rectx, (short)context.recty); } } return ibuf; } -static ImBuf * copy_from_ibuf_still(Sequence * seq, float nr, - int seqrectx, int seqrecty) +static ImBuf * copy_from_ibuf_still(SeqRenderData context, Sequence * seq, + float nr) { ImBuf * rval = 0; ImBuf * ibuf = 0; if (nr == 0) { ibuf = seq_stripelem_cache_get( - seq, seqrectx, seqrecty, seq->start, + context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL); } if (nr == seq->len - 1) { ibuf = seq_stripelem_cache_get( - seq, seqrectx, seqrecty, seq->start, + context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL); } @@ -1611,17 +1701,17 @@ static ImBuf * copy_from_ibuf_still(Sequence * seq, float nr, return rval; } -static void copy_to_ibuf_still(Sequence * seq, float nr, +static void copy_to_ibuf_still(SeqRenderData context, Sequence * seq, float nr, ImBuf * ibuf) { if (nr == 0) { seq_stripelem_cache_put( - seq, 0, 0, seq->start, + context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf); } if (nr == seq->len - 1) { seq_stripelem_cache_put( - seq, 0, 0, seq->start, + context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL, ibuf); } } @@ -1630,15 +1720,15 @@ static void copy_to_ibuf_still(Sequence * seq, float nr, strip rendering functions ********************************************************************** */ -static ImBuf* seq_render_strip_stack( Main *bmain, Scene *scene, ListBase *seqbasep, - float cfra, int chanshown, int preview_render_size, int seqrectx, int seqrecty); +static ImBuf* seq_render_strip_stack( + SeqRenderData context, ListBase *seqbasep, float cfra, int chanshown); -static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra, - int preview_render_size, int seqrectx, int seqrecty); +static ImBuf * seq_render_strip( + SeqRenderData context, Sequence * seq, float cfra); -static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra, - Sequence *seq, int preview_render_size, int seqrectx, int seqrecty) +static ImBuf* seq_render_effect_strip_impl( + SeqRenderData context, Sequence *seq, float cfra) { float fac, facf; int early_out; @@ -1654,21 +1744,22 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra input[0] = seq->seq1; input[1] = seq->seq2; input[2] = seq->seq3; if (!sh.execute) { /* effect not supported in this version... */ - out = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); + out = IMB_allocImBuf((short)context.rectx, + (short)context.recty, 32, IB_rect); return out; } if (seq->flag & SEQ_USE_EFFECT_DEFAULT_FADE) { sh.get_default_fac(seq, cfra, &fac, &facf); - if ((scene->r.mode & R_FIELDS)==0) + if ((context.scene->r.mode & R_FIELDS)==0) facf= fac; } else { - fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "effect_fader", 0); + fcu = id_data_find_fcurve(&context.scene->id, seq, &RNA_Sequence, "effect_fader", 0); if (fcu) { fac = facf = evaluate_fcurve(fcu, cfra); - if( scene->r.mode & R_FIELDS ) { + if( context.scene->r.mode & R_FIELDS ) { facf = evaluate_fcurve(fcu, cfra + 0.5); } } else { @@ -1680,27 +1771,26 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra switch (early_out) { case EARLY_NO_INPUT: - out = sh.execute(bmain, scene, seq, cfra, fac, facf, - seqrectx, seqrecty, preview_render_size, NULL, NULL, NULL); + out = sh.execute(context, seq, cfra, fac, facf, + NULL, NULL, NULL); case EARLY_DO_EFFECT: for(i=0; i<3; i++) { if(input[i]) - ibuf[i] = seq_render_strip(bmain, scene, input[i], cfra, - preview_render_size, seqrectx, seqrecty); + ibuf[i] = seq_render_strip( + context, input[i], cfra); } if (ibuf[0] && ibuf[1]) { - out = sh.execute(bmain, scene, seq, cfra, fac, facf, seqrectx, seqrecty, - preview_render_size, ibuf[0], ibuf[1], ibuf[2]); + out = sh.execute(context, seq, cfra, fac, facf, + ibuf[0], ibuf[1], ibuf[2]); } break; case EARLY_USE_INPUT_1: if (input[0]) { - ibuf[0] = seq_render_strip(bmain, scene, input[0], cfra, - preview_render_size, seqrectx, seqrecty); + ibuf[0] = seq_render_strip(context, input[0], cfra); } if (ibuf[0]) { - if (input_have_to_preprocess(scene, seq, cfra, seqrectx, seqrecty)) { + if (input_have_to_preprocess(context, seq, cfra)) { out = IMB_dupImBuf(ibuf[0]); } else { out = ibuf[0]; @@ -1710,11 +1800,10 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra break; case EARLY_USE_INPUT_2: if (input[1]) { - ibuf[1] = seq_render_strip(bmain, scene, input[1], cfra, - preview_render_size, seqrectx, seqrecty); + ibuf[1] = seq_render_strip(context, input[1], cfra); } if (ibuf[1]) { - if (input_have_to_preprocess(scene, seq, cfra, seqrectx, seqrecty)) { + if (input_have_to_preprocess(context, seq, cfra)) { out = IMB_dupImBuf(ibuf[1]); } else { out = ibuf[1]; @@ -1729,7 +1818,7 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra } if (out == NULL) { - out = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); + out = IMB_allocImBuf((short)context.rectx, (short)context.recty, 32, IB_rect); } return out; @@ -1737,7 +1826,7 @@ static ImBuf* seq_render_effect_strip_impl(Main *bmain, Scene *scene, float cfra static ImBuf * seq_render_scene_strip_impl( - Main *bmain, Scene * scene, Sequence * seq, float nr, int seqrectx, int seqrecty) + SeqRenderData context, Sequence * seq, float nr) { ImBuf * ibuf = 0; float frame= seq->sfra + nr + seq->anim_startofs; @@ -1795,8 +1884,8 @@ static ImBuf * seq_render_scene_strip_impl( oldcamera= seq->scene->camera; /* prevent eternal loop */ - doseq= scene->r.scemode & R_DOSEQ; - scene->r.scemode &= ~R_DOSEQ; + doseq= context.scene->r.scemode & R_DOSEQ; + context.scene->r.scemode &= ~R_DOSEQ; seq->scene->r.cfra= frame; if(seq->scene_camera) @@ -1810,25 +1899,25 @@ static ImBuf * seq_render_scene_strip_impl( 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) { + if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == context.scene || have_seq==0) && seq->scene->camera) { /* for old scened this can be uninitialized, should probably be added to do_versions at some point if the functionality stays */ - if(scene->r.seq_prev_type==0) - scene->r.seq_prev_type = 3 /* ==OB_SOLID */; + if(context.scene->r.seq_prev_type==0) + context.scene->r.seq_prev_type = 3 /* ==OB_SOLID */; /* opengl offscreen render */ - scene_update_for_newframe(bmain, seq->scene, seq->scene->lay); - ibuf= sequencer_view3d_cb(seq->scene, seqrectx, seqrecty, IB_rect, scene->r.seq_prev_type); + scene_update_for_newframe(context.bmain, seq->scene, seq->scene->lay); + ibuf= sequencer_view3d_cb(seq->scene, context.rectx, context.recty, IB_rect, context.scene->r.seq_prev_type); } else { Render *re = RE_GetRender(sce->id.name); RenderResult rres; /* XXX: this if can be removed when sequence preview rendering uses the job system */ - if(rendering || scene != sce) { + if(rendering || context.scene != sce) { if(re==NULL) re= RE_NewRender(sce->id.name); - RE_BlenderFrame(re, bmain, sce, NULL, sce->lay, frame, FALSE); + RE_BlenderFrame(re, context.bmain, sce, NULL, sce->lay, frame, FALSE); /* restore previous state after it was toggled on & off by RE_BlenderFrame */ G.rendering = rendering; @@ -1859,7 +1948,7 @@ static ImBuf * seq_render_scene_strip_impl( } /* restore */ - scene->r.scemode |= doseq; + context.scene->r.scemode |= doseq; seq->scene->r.cfra = oldcfra; seq->scene->camera= oldcamera; @@ -1872,27 +1961,26 @@ static ImBuf * seq_render_scene_strip_impl( return ibuf; } -static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float cfra, - int preview_render_size, int seqrectx, int seqrecty) +static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfra) { ImBuf * ibuf = NULL; char name[FILE_MAXDIR+FILE_MAXFILE]; - int use_preprocess = input_have_to_preprocess(scene, seq, cfra, seqrectx, seqrecty); + int use_preprocess = input_have_to_preprocess(context, seq, cfra); float nr = give_stripelem_index(seq, cfra); /* all effects are handled similarly with the exception of speed effect */ int type = (seq->type & SEQ_EFFECT && seq->type != SEQ_SPEED) ? SEQ_EFFECT : seq->type; - ibuf = seq_stripelem_cache_get(seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF); + ibuf = seq_stripelem_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF); if (ibuf == NULL) - ibuf = copy_from_ibuf_still(seq,nr,seqrectx,seqrecty); + ibuf = copy_from_ibuf_still(context, seq, nr); /* currently, we cache preprocessed images */ if (ibuf) use_preprocess = FALSE; if (ibuf == NULL) - ibuf = seq_proxy_fetch(scene, seq, cfra, preview_render_size); + ibuf = seq_proxy_fetch(context, seq, cfra); if(ibuf == NULL) switch(type) { case SEQ_META: @@ -1900,8 +1988,9 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float ImBuf * meta_ibuf = NULL; if(seq->seqbase.first) - meta_ibuf = seq_render_strip_stack(bmain, scene, &seq->seqbase, - seq->start + nr, 0, preview_render_size, seqrectx, seqrecty); + meta_ibuf = seq_render_strip_stack( + context, &seq->seqbase, + seq->start + nr, 0); if(meta_ibuf) { ibuf = meta_ibuf; @@ -1922,13 +2011,12 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float float f_cfra; SpeedControlVars * s = (SpeedControlVars *)seq->effectdata; - sequence_effect_speed_rebuild_map(scene, seq, 0); + sequence_effect_speed_rebuild_map(context.scene,seq, 0); /* weeek! */ f_cfra = seq->start + s->frameMap[(int) nr]; - child_ibuf = seq_render_strip(bmain, scene, seq->seq1, f_cfra, preview_render_size, - seqrectx, seqrecty); + child_ibuf = seq_render_strip(context,seq->seq1,f_cfra); if (child_ibuf) { ibuf = child_ibuf; @@ -1944,8 +2032,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float } case SEQ_EFFECT: { - ibuf = seq_render_effect_strip_impl(bmain, scene, cfra, seq, preview_render_size, - seqrectx, seqrecty); + ibuf = seq_render_effect_strip_impl(context, seq, cfra); break; } case SEQ_IMAGE: @@ -1966,7 +2053,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float if(ibuf->profile == IB_PROFILE_LINEAR_RGB) IMB_convert_profile(ibuf, IB_PROFILE_NONE); - copy_to_ibuf_still(seq, nr, ibuf); + copy_to_ibuf_still(context, seq, nr, ibuf); } break; } @@ -1977,7 +2064,7 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float BLI_path_abs(name, G.main->name); seq->anim = openanim(name, IB_rect | - ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0)); + ((seq->flag & SEQ_FILTERY) ? IB_animdeinterlace : 0)); } if(seq->anim) { @@ -1988,28 +2075,28 @@ static ImBuf * seq_render_strip(Main *bmain, Scene *scene, Sequence * seq, float imb_freerectImBuf(ibuf); } - copy_to_ibuf_still(seq, nr, ibuf); + copy_to_ibuf_still(context, seq, nr, ibuf); break; } case SEQ_SCENE: { // scene can be NULL after deletions - ibuf = seq_render_scene_strip_impl(bmain, scene, seq, nr, seqrectx, seqrecty); + ibuf = seq_render_scene_strip_impl(context, seq, nr); - copy_to_ibuf_still(seq, nr, ibuf); + copy_to_ibuf_still(context, seq, nr, ibuf); break; } } if (ibuf == NULL) - ibuf = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); + ibuf = IMB_allocImBuf((short)context.rectx, (short)context.recty, 32, IB_rect); - if (ibuf->x != seqrectx || ibuf->y != seqrecty) + if (ibuf->x != context.rectx || ibuf->y != context.recty) use_preprocess = TRUE; if (use_preprocess) - ibuf = input_preprocess(scene, seq, cfra, seqrectx, seqrecty, ibuf); + ibuf = input_preprocess(context, seq, cfra, ibuf); - seq_stripelem_cache_put(seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF, ibuf); + seq_stripelem_cache_put(context, seq, cfra, SEQ_STRIPELEM_IBUF, ibuf); return ibuf; } @@ -2053,8 +2140,7 @@ static int seq_get_early_out_for_blend_mode(Sequence * seq) } static ImBuf* seq_render_strip_stack( - Main *bmain, Scene *scene, ListBase *seqbasep, float cfra, int chanshown, - int preview_render_size, int seqrectx, int seqrecty) + SeqRenderData context, ListBase *seqbasep, float cfra, int chanshown) { Sequence* seq_arr[MAXSEQ+1]; int count; @@ -2075,15 +2161,17 @@ static ImBuf* seq_render_strip_stack( } #endif - out = seq_stripelem_cache_get(seq_arr[count - 1], seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP); + out = seq_stripelem_cache_get(context, seq_arr[count - 1], + cfra, SEQ_STRIPELEM_IBUF_COMP); if (out) { return out; } if(count == 1) { - out = seq_render_strip(bmain, scene, seq_arr[0], cfra, preview_render_size, seqrectx, seqrecty); - seq_stripelem_cache_put(seq_arr[0], seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP, out); + out = seq_render_strip(context, seq_arr[0], cfra); + seq_stripelem_cache_put(context, seq_arr[0], cfra, + SEQ_STRIPELEM_IBUF_COMP, out); return out; } @@ -2093,13 +2181,14 @@ static ImBuf* seq_render_strip_stack( int early_out; Sequence *seq = seq_arr[i]; - out = seq_stripelem_cache_get(seq, seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP); + out = seq_stripelem_cache_get( + context, seq, cfra, SEQ_STRIPELEM_IBUF_COMP); if (out) { break; } if (seq->blend_mode == SEQ_BLEND_REPLACE) { - out = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, seqrectx, seqrecty); + out = seq_render_strip(context, seq, cfra); break; } @@ -2108,16 +2197,16 @@ static ImBuf* seq_render_strip_stack( switch (early_out) { case EARLY_NO_INPUT: case EARLY_USE_INPUT_2: - out = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, seqrectx, seqrecty); + out = seq_render_strip(context, seq, cfra); break; case EARLY_USE_INPUT_1: if (i == 0) { - out = IMB_allocImBuf((short)seqrectx, (short)seqrecty, 32, IB_rect); + out = IMB_allocImBuf((short)context.rectx, (short)context.recty, 32, IB_rect); } break; case EARLY_DO_EFFECT: if (i == 0) { - out = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, seqrectx, seqrecty); + out = seq_render_strip(context, seq, cfra); } break; @@ -2127,7 +2216,8 @@ static ImBuf* seq_render_strip_stack( } } - seq_stripelem_cache_put(seq_arr[i], seqrectx, seqrecty, cfra, SEQ_STRIPELEM_IBUF_COMP, out); + seq_stripelem_cache_put(context, seq_arr[i], cfra, + SEQ_STRIPELEM_IBUF_COMP, out); i++; @@ -2138,29 +2228,27 @@ static ImBuf* seq_render_strip_stack( if (seq_get_early_out_for_blend_mode(seq) == EARLY_DO_EFFECT) { struct SeqEffectHandle sh = get_sequence_blend(seq); ImBuf * ibuf1 = out; - ImBuf * ibuf2 = seq_render_strip(bmain, scene, seq, cfra, preview_render_size, - seqrectx, seqrecty); + ImBuf * ibuf2 = seq_render_strip(context, seq, cfra); float facf = seq->blend_opacity / 100.0; int swap_input = seq_must_swap_input_in_blend_mode(seq); - int x= seqrectx; - int y= seqrecty; - if (swap_input) { - out = sh.execute(bmain, scene, seq, cfra, facf, facf, x, y, - preview_render_size, ibuf2, ibuf1, 0); + out = sh.execute(context, seq, cfra, + facf, facf, + ibuf2, ibuf1, 0); } else { - out = sh.execute(bmain, scene, seq, cfra, facf, facf, x, y, - preview_render_size, ibuf1, ibuf2, 0); + out = sh.execute(context, seq, cfra, + facf, facf, + ibuf1, ibuf2, 0); } IMB_freeImBuf(ibuf1); IMB_freeImBuf(ibuf2); } - seq_stripelem_cache_put(seq_arr[i], seqrectx, seqrecty, cfra, - SEQ_STRIPELEM_IBUF_COMP, out); + seq_stripelem_cache_put(context, seq_arr[i], cfra, + SEQ_STRIPELEM_IBUF_COMP, out); } return out; @@ -2171,9 +2259,9 @@ static ImBuf* seq_render_strip_stack( * you have to free after usage! */ -ImBuf *give_ibuf_seq(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int preview_render_size) +ImBuf *give_ibuf_seq(SeqRenderData context, float cfra, int chanshown) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed= seq_give_editing(context.scene, FALSE); int count; ListBase *seqbasep; @@ -2187,19 +2275,18 @@ ImBuf *give_ibuf_seq(Main *bmain, Scene *scene, int rectx, int recty, int cfra, seqbasep= ed->seqbasep; } - return seq_render_strip_stack(bmain, scene, seqbasep, cfra, chanshown, - preview_render_size, rectx, recty); + return seq_render_strip_stack(context, seqbasep, cfra, chanshown); } -ImBuf *give_ibuf_seqbase(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int preview_render_size, ListBase *seqbasep) +ImBuf *give_ibuf_seqbase(SeqRenderData context, float cfra, int chanshown, ListBase *seqbasep) { - return seq_render_strip_stack(bmain, scene, seqbasep, cfra, chanshown, preview_render_size, rectx, recty); + return seq_render_strip_stack(context, seqbasep, cfra, chanshown); } -ImBuf *give_ibuf_seq_direct(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int preview_render_size, Sequence *seq) +ImBuf *give_ibuf_seq_direct(SeqRenderData context, float cfra, Sequence *seq) { - return seq_render_strip(bmain, scene, seq, cfra, preview_render_size, rectx, recty); + return seq_render_strip(context, seq, cfra); } #if 0 @@ -2249,7 +2336,7 @@ typedef struct PrefetchQueueElem { int rectx; int recty; - int cfra; + float cfra; int chanshown; int preview_render_size; @@ -2409,7 +2496,7 @@ static void seq_stop_threads() } #endif -void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, int preview_render_size) +void give_ibuf_prefetch_request(SeqRenderData context, float cfra, int chanshown) { PrefetchQueueElem *e; if (seq_thread_shutdown) { @@ -2417,11 +2504,11 @@ void give_ibuf_prefetch_request(int rectx, int recty, int cfra, int chanshown, i } e = MEM_callocN(sizeof(PrefetchQueueElem), "prefetch_queue_elem"); - e->rectx = rectx; - e->recty = recty; + e->rectx = context.rectx; + e->recty = context.recty; e->cfra = cfra; e->chanshown = chanshown; - e->preview_render_size = preview_render_size; + e->preview_render_size = context.preview_render_size; e->monoton_cfra = monoton_cfra++; pthread_mutex_lock(&queue_lock); @@ -2464,13 +2551,13 @@ static void seq_wait_for_prefetch_ready() } #endif -ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, int cfra, int chanshown, int preview_render_size) +ImBuf *give_ibuf_seq_threaded(SeqRenderData context, float cfra, int chanshown) { PrefetchQueueElem *e = NULL; int found_something = FALSE; if (seq_thread_shutdown) { - return give_ibuf_seq(bmain, scene, rectx, recty, cfra, chanshown, preview_render_size); + return give_ibuf_seq(context, cfra, chanshown); } while (!e) { @@ -2480,9 +2567,9 @@ ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, i for (e = prefetch_done.first; e; e = e->next) { if (cfra == e->cfra && chanshown == e->chanshown && - rectx == e->rectx && - recty == e->recty && - preview_render_size == e->preview_render_size) { + context.rectx == e->rectx && + context.recty == e->recty && + context.preview_render_size == e->preview_render_size) { success = TRUE; found_something = TRUE; break; @@ -2493,9 +2580,9 @@ ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, i for (e = prefetch_wait.first; e; e = e->next) { if (cfra == e->cfra && chanshown == e->chanshown && - rectx == e->rectx && - recty == e->recty && - preview_render_size == e->preview_render_size) { + context.rectx == e->rectx && + context.recty == e->recty && + context.preview_render_size == e->preview_render_size) { found_something = TRUE; break; } @@ -2510,9 +2597,9 @@ ImBuf *give_ibuf_seq_threaded(Main *bmain, Scene *scene, int rectx, int recty, i if (tslot->current && cfra == tslot->current->cfra && chanshown == tslot->current->chanshown && - rectx == tslot->current->rectx && - recty == tslot->current->recty && - preview_render_size== tslot->current->preview_render_size){ + context.rectx == tslot->current->rectx && + context.recty == tslot->current->recty && + context.preview_render_size== tslot->current->preview_render_size){ found_something = TRUE; break; } -- cgit v1.2.3 From bb36378a3a4c6b16b7c142f2b7d776a4a131069c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Nov 2010 05:36:49 +0000 Subject: rename hide_tooltips_python to show_ ..., tag unused variable with recent sequencer commits. --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 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 9059d35cac3..b98976729c4 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1527,7 +1527,7 @@ static void color_balance(Sequence * seq, ImBuf* ibuf, float mul) */ int input_have_to_preprocess( - SeqRenderData UNUSED(context), Sequence * seq, float cfra) + SeqRenderData UNUSED(context), Sequence * seq, float UNUSED(cfra)) { float mul; -- cgit v1.2.3 From 77dff3f9863638a5a95a1ee7e6fc2b0e9b3b8357 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Nov 2010 06:18:49 +0000 Subject: fix for fix r33219, reports. Set a valid WM after running UNDO. [#24849] changing objects to another layer causes segmentation fault [#24848] Using an operator outside of edit mode crashes blender [#24844] Crash related to the subdivision (aka subsurf) modifier [#24843] ctrl+z crashes blender --- source/blender/blenkernel/intern/blender.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 170b2702a57..9c748565c1a 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -243,6 +243,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename G.main= bfd->main; CTX_data_main_set(C, G.main); + CTX_wm_manager_set(C, G.main->wm.first); if (bfd->user) { -- cgit v1.2.3 From 0191c2f7764a951d3bd996dfd5e47a6c0b8b56c0 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 22 Nov 2010 11:21:33 +0000 Subject: Reverting fix for yesterday's commit that broke Undo. --- source/blender/blenkernel/intern/blender.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 9c748565c1a..e1e4f3b15ac 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -237,13 +237,12 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename } /* free G.main Main database */ - CTX_wm_manager_set(C, NULL); +// CTX_wm_manager_set(C, NULL); clear_global(); G.main= bfd->main; CTX_data_main_set(C, G.main); - CTX_wm_manager_set(C, G.main->wm.first); if (bfd->user) { -- cgit v1.2.3 From 4a20c386fd14553a03f64bb433a2c3d335a971fe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 22 Nov 2010 14:16:11 +0000 Subject: bugfix [#20768] Project Snap Broken --- source/blender/blenkernel/intern/bvhutils.c | 39 +++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 671bcb36680..882295b931c 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -36,6 +36,7 @@ #include "BKE_DerivedMesh.h" #include "BKE_utildefines.h" +#include "BLI_editVert.h" #include "BLI_math.h" #include "MEM_guardedalloc.h" @@ -577,16 +578,34 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis); if(tree != NULL) { - for(i = 0; i < numFaces; i++) - { - float co[4][3]; - VECCOPY(co[0], vert[ face[i].v1 ].co); - VECCOPY(co[1], vert[ face[i].v2 ].co); - VECCOPY(co[2], vert[ face[i].v3 ].co); - if(face[i].v4) - VECCOPY(co[3], vert[ face[i].v4 ].co); - - BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); + /* XXX, for snap only, em & dm are assumed to be aligned, since dm is the em's cage */ + EditMesh *em= data->em_evil; + if(em) { + EditFace *efa= em->faces.first; + for(i = 0; i < numFaces; i++, efa= efa->next) { + if(!(efa->f & 1) && efa->h==0 && !((efa->v1->f&1)+(efa->v2->f&1)+(efa->v3->f&1)+(efa->v4?efa->v4->f&1:0))) { + float co[4][3]; + VECCOPY(co[0], vert[ face[i].v1 ].co); + VECCOPY(co[1], vert[ face[i].v2 ].co); + VECCOPY(co[2], vert[ face[i].v3 ].co); + if(face[i].v4) + VECCOPY(co[3], vert[ face[i].v4 ].co); + + BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); + } + } + } + else { + for(i = 0; i < numFaces; i++) { + float co[4][3]; + VECCOPY(co[0], vert[ face[i].v1 ].co); + VECCOPY(co[1], vert[ face[i].v2 ].co); + VECCOPY(co[2], vert[ face[i].v3 ].co); + if(face[i].v4) + VECCOPY(co[3], vert[ face[i].v4 ].co); + + BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); + } } BLI_bvhtree_balance(tree); -- cgit v1.2.3 From e1506d1f12e57e126bcd9560dd8c98fbe9f40c5e Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 22 Nov 2010 23:59:00 +0000 Subject: Partial fix for #24773: Material Nodes - there isn't able to set keys on Mapping coordinates Playback now works. The problem was that material/texture nodetrees were getting ignored completely, as I was assuming that all of these existed in the main->nodetree collection when in fact only the "group" nodetrees lived there. I don't really agree with this, but that's the way it is... TODO: animation editor support still to come --- source/blender/blenkernel/intern/anim_sys.c | 41 +++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index e50d4880fbe..deb4e51950c 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -39,9 +39,10 @@ #include "BKE_library.h" #include "BLI_dynstr.h" - #include "DNA_anim_types.h" +#include "DNA_material_types.h" #include "DNA_scene_types.h" +#include "DNA_texture_types.h" #include "BKE_animsys.h" #include "BKE_action.h" @@ -1839,7 +1840,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) if (G.f & G_DEBUG) printf("Evaluate all animation - %f \n", ctime); - /* macro for less typing + /* macros for less typing * - only evaluate animation data for id if it has users (and not just fake ones) * - whether animdata exists is checked for by the evaluation function, though taking * this outside of the function may make things slightly faster? @@ -1851,6 +1852,24 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) BKE_animsys_evaluate_animdata(id, adt, ctime, aflag); \ } \ } + /* another macro for the "embedded" nodetree cases + * - this is like EVAL_ANIM_IDS, but this handles the case "embedded nodetrees" + * (i.e. scene/material/texture->nodetree) which we need a special exception + * for, otherwise they'd get skipped + * - ntp = "node tree parent" = datablock where node tree stuff resides + */ +#define EVAL_ANIM_NODETREE_IDS(first, NtId_Type, aflag) \ + for (id= first; id; id= id->next) { \ + if (ID_REAL_USERS(id) > 0) { \ + AnimData *adt= BKE_animdata_from_id(id); \ + NtId_Type *ntp= (NtId_Type *)id; \ + if (ntp->nodetree) { \ + AnimData *adt2= BKE_animdata_from_id((ID *)ntp->nodetree); \ + BKE_animsys_evaluate_animdata((ID *)ntp->nodetree, adt2, ctime, ADT_RECALC_ANIM); \ + } \ + BKE_animsys_evaluate_animdata(id, adt, ctime, aflag); \ + } \ + } /* optimisation: * when there are no actions, don't go over database and loop over heaps of datablocks, @@ -1871,13 +1890,13 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) EVAL_ANIM_IDS(main->nodetree.first, ADT_RECALC_ANIM); /* textures */ - EVAL_ANIM_IDS(main->tex.first, ADT_RECALC_ANIM); + EVAL_ANIM_NODETREE_IDS(main->tex.first, Tex, ADT_RECALC_ANIM); /* lamps */ EVAL_ANIM_IDS(main->lamp.first, ADT_RECALC_ANIM); /* materials */ - EVAL_ANIM_IDS(main->mat.first, ADT_RECALC_ANIM); + EVAL_ANIM_NODETREE_IDS(main->mat.first, Material, ADT_RECALC_ANIM); /* cameras */ EVAL_ANIM_IDS(main->camera.first, ADT_RECALC_ANIM); @@ -1912,19 +1931,7 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) EVAL_ANIM_IDS(main->world.first, ADT_RECALC_ANIM); /* scenes */ - for (id= main->scene.first; id; id= id->next) { - AnimData *adt= BKE_animdata_from_id(id); - Scene *scene= (Scene *)id; - - /* do compositing nodes first (since these aren't included in main tree) */ - if (scene->nodetree) { - AnimData *adt2= BKE_animdata_from_id((ID *)scene->nodetree); - BKE_animsys_evaluate_animdata((ID *)scene->nodetree, adt2, ctime, ADT_RECALC_ANIM); - } - - /* now execute scene animation data as per normal */ - BKE_animsys_evaluate_animdata(id, adt, ctime, ADT_RECALC_ANIM); - } + EVAL_ANIM_NODETREE_IDS(main->scene.first, Scene, ADT_RECALC_ANIM); } /* ***************************************** */ -- cgit v1.2.3 From ce2295999e5fc667f3574b9c53cba04155bd1546 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Nov 2010 08:44:21 +0000 Subject: use zero initializers instead of memset(), also change PointerRNA_NULL from an extern into a define. --- source/blender/blenkernel/intern/anim.c | 6 ++---- source/blender/blenkernel/intern/anim_sys.c | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 6bbcecce2f7..b58bd8c7f3e 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1441,7 +1441,7 @@ static Object *find_family_object(Object **obar, char *family, char ch) static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, int animated) { - Object *ob, *obar[256]; + Object *ob, *obar[256]= {0}; Curve *cu; struct chartrans *ct, *chartransdata; float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof; @@ -1456,9 +1456,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i chartransdata= BKE_text_to_curve(scene, par, FO_DUPLI); if(chartransdata==0) return; - - memset(obar, 0, 256*sizeof(void *)); - + cu= par->data; slen= strlen(cu->str); fsize= cu->fsize; diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index deb4e51950c..580f94ba3b8 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1610,9 +1610,6 @@ void nladata_flush_channels (ListBase *channels) */ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) { - ListBase dummy_trackslist = {NULL, NULL}; - NlaStrip dummy_strip; - NlaTrack *nlt; short track_index=0; short has_strips = 0; @@ -1655,7 +1652,9 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) /* if there are strips, evaluate action as per NLA rules */ if ((has_strips) || (adt->actstrip)) { /* make dummy NLA strip, and add that to the stack */ - memset(&dummy_strip, 0, sizeof(NlaStrip)); + NlaStrip dummy_strip= {0}; + ListBase dummy_trackslist; + dummy_trackslist.first= dummy_trackslist.last= &dummy_strip; if ((nlt) && !(adt->flag & ADT_NLA_EDIT_NOMAP)) { -- cgit v1.2.3 From 4aeeee88198b97ede58b09188f588746b0dfe8f1 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 23 Nov 2010 14:04:05 +0000 Subject: Cached smoke wasn't being drawn on file load before going to simulation start frame. --- source/blender/blenkernel/intern/smoke.c | 4 +++- 1 file changed, 3 insertions(+), 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 c1090326fd9..e649c442a2d 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1353,9 +1353,11 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } } - if(!smd->domain->fluid && (framenr != startframe) && (cache->flag & PTCACHE_BAKED)==0) + if(!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD)==0 && (cache->flag & PTCACHE_BAKED)==0) return; + smd->domain->flags &= ~MOD_SMOKE_FILE_LOAD; + if(framenr < startframe) framenr = startframe; -- cgit v1.2.3 From 0e9b664fce0ab0c3d5bbf9042c76ffdff8c60fbc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Nov 2010 14:14:06 +0000 Subject: Changes to the ortho grid drawing based on discussion with Ton. - ortho grid now draws scaled by the view3d 'Scale' setting, venomgfx noticed this was missing. - so as not to confuse add scale next to unit display text, so rather then "Metres" it shows "Metres x 1.5" otherwise its confusing that grid lines are not in exact units. - changed grid spacing to grid scale (needed for more logical behavior with units) - when units are enabled grey out subdivisions. --- source/blender/blenkernel/intern/unit.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 4cb59a2ee86..54ecef75108 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -69,13 +69,13 @@ /* define a single unit */ typedef struct bUnitDef { - char *name; - char *name_plural; /* abused a bit for the display name */ - char *name_short; /* this is used for display*/ - char *name_alt; /* keyboard-friendly ASCII-only version of name_short, can be NULL */ + const char *name; + const char *name_plural; /* abused a bit for the display name */ + const char *name_short; /* this is used for display*/ + const char *name_alt; /* keyboard-friendly ASCII-only version of name_short, can be NULL */ /* if name_short has non-ASCII chars, name_alt should be present */ - char *name_display; /* can be NULL */ + const char *name_display; /* can be NULL */ double scalar; double bias; /* not used yet, needed for converting temperature */ @@ -421,7 +421,7 @@ void bUnit_AsString(char *str, int len_max, double value, int prec, int system, } -static char *unit_find_str(char *str, char *substr) +static char *unit_find_str(char *str, const char *substr) { char *str_found; @@ -476,7 +476,7 @@ static int ch_is_op(char op) } } -static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit, char *replace_str) +static int unit_scale_str(char *str, int len_max, char *str_tmp, double scale_pref, bUnitDef *unit, const char *replace_str) { char *str_found; @@ -755,11 +755,11 @@ void bUnit_GetSystem(void **usys_pt, int *len, int system, int type) *len= usys->length; } -char *bUnit_GetName(void *usys_pt, int index) +const char *bUnit_GetName(void *usys_pt, int index) { return ((bUnitCollection *)usys_pt)->units[index].name; } -char *bUnit_GetNameDisplay(void *usys_pt, int index) +const char *bUnit_GetNameDisplay(void *usys_pt, int index) { return ((bUnitCollection *)usys_pt)->units[index].name_display; } -- cgit v1.2.3 From 513f0142fb113552b908ce174ef5eb614dd59db6 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 23 Nov 2010 14:40:27 +0000 Subject: Fix for [#19706] Smoke 'sticks' to Collision objects initial position * Smoke got emitted inside collision cells, so it got stuck there. --- source/blender/blenkernel/intern/smoke.c | 203 ++++++++++++++++--------------- 1 file changed, 102 insertions(+), 101 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index e649c442a2d..ee19e779cc5 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -824,9 +824,109 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) GroupObject *go = NULL; Base *base = NULL; + // do collisions, needs to be done before emission, so that smoke isn't emitted inside collision cells + if(1) + { + Object *otherobj = NULL; + ModifierData *md = NULL; + + if(sds->coll_group) // we use groups since we have 2 domains + go = sds->coll_group->gobject.first; + else + base = scene->base.first; + + while(base || go) + { + otherobj = NULL; + if(sds->coll_group) + { + if(go->ob) + otherobj = go->ob; + } + else + otherobj = base->object; + if(!otherobj) + { + if(sds->coll_group) + go = go->next; + else + base= base->next; + continue; + } + md = modifiers_findByType(otherobj, eModifierType_Smoke); + + // check for active smoke modifier + if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) + { + SmokeModifierData *smd2 = (SmokeModifierData *)md; + + if((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll && smd2->coll->points) + { + // we got nice collision object + SmokeCollSettings *scs = smd2->coll; + size_t i, j; + unsigned char *obstacles = smoke_get_obstacle(smd->domain->fluid); + + for(i = 0; i < scs->numpoints; i++) + { + int badcell = 0; + size_t index = 0; + int cell[3]; + + // 1. get corresponding cell + get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, &scs->points[3 * i], cell, 0); + + // check if cell is valid (in the domain boundary) + for(j = 0; j < 3; j++) + if((cell[j] > sds->res[j] - 1) || (cell[j] < 0)) + { + badcell = 1; + break; + } + + if(badcell) + continue; + // 2. set cell values (heat, density and velocity) + index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); + + // printf("cell[0]: %d, cell[1]: %d, cell[2]: %d\n", cell[0], cell[1], cell[2]); + // printf("res[0]: %d, res[1]: %d, res[2]: %d, index: %d\n\n", sds->res[0], sds->res[1], sds->res[2], index); + obstacles[index] = 1; + // for moving gobstacles + /* + const LbmFloat maxVelVal = 0.1666; + const LbmFloat maxusqr = maxVelVal*maxVelVal*3. *1.5; + + LbmVec objvel = vec2L((mMOIVertices[n]-mMOIVerticesOld[n]) /dvec); + { + const LbmFloat usqr = (objvel[0]*objvel[0]+objvel[1]*objvel[1]+objvel[2]*objvel[2])*1.5; + USQRMAXCHECK(usqr, objvel[0],objvel[1],objvel[2], mMaxVlen, mMxvx,mMxvy,mMxvz); + if(usqr>maxusqr) { + // cutoff at maxVelVal + for(int jj=0; jj<3; jj++) { + if(objvel[jj]>0.) objvel[jj] = maxVelVal; + if(objvel[jj]<0.) objvel[jj] = -maxVelVal; + } + } + } + const LbmFloat dp=dot(objvel, vec2L((*pNormals)[n]) ); + const LbmVec oldov=objvel; // debug + objvel = vec2L((*pNormals)[n]) *dp; + */ + } + } + } + + if(sds->coll_group) + go = go->next; + else + base= base->next; + } + } + // do flows and fluids if(1) - { + { Object *otherobj = NULL; ModifierData *md = NULL; if(sds->fluid_group) // we use groups since we have 2 domains @@ -928,7 +1028,7 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) continue; // 2. set cell values (heat, density and velocity) index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); - if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) && !(obstacle[index] & 2)) // this is inflow + if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) && !(obstacle[index])) // this is inflow { // heat[index] += sfs->temp * 0.1; // density[index] += sfs->density * 0.1; @@ -1167,105 +1267,6 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) pdEndEffectors(&effectors); } - // do collisions - if(1) - { - Object *otherobj = NULL; - ModifierData *md = NULL; - - if(sds->coll_group) // we use groups since we have 2 domains - go = sds->coll_group->gobject.first; - else - base = scene->base.first; - - while(base || go) - { - otherobj = NULL; - if(sds->coll_group) - { - if(go->ob) - otherobj = go->ob; - } - else - otherobj = base->object; - if(!otherobj) - { - if(sds->coll_group) - go = go->next; - else - base= base->next; - continue; - } - md = modifiers_findByType(otherobj, eModifierType_Smoke); - - // check for active smoke modifier - if(md && md->mode & (eModifierMode_Realtime | eModifierMode_Render)) - { - SmokeModifierData *smd2 = (SmokeModifierData *)md; - - if((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll && smd2->coll->points) - { - // we got nice collision object - SmokeCollSettings *scs = smd2->coll; - size_t i, j; - unsigned char *obstacles = smoke_get_obstacle(smd->domain->fluid); - - for(i = 0; i < scs->numpoints; i++) - { - int badcell = 0; - size_t index = 0; - int cell[3]; - - // 1. get corresponding cell - get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, &scs->points[3 * i], cell, 0); - - // check if cell is valid (in the domain boundary) - for(j = 0; j < 3; j++) - if((cell[j] > sds->res[j] - 1) || (cell[j] < 0)) - { - badcell = 1; - break; - } - - if(badcell) - continue; - // 2. set cell values (heat, density and velocity) - index = smoke_get_index(cell[0], sds->res[0], cell[1], sds->res[1], cell[2]); - - // printf("cell[0]: %d, cell[1]: %d, cell[2]: %d\n", cell[0], cell[1], cell[2]); - // printf("res[0]: %d, res[1]: %d, res[2]: %d, index: %d\n\n", sds->res[0], sds->res[1], sds->res[2], index); - obstacles[index] = 1; - // for moving gobstacles - /* - const LbmFloat maxVelVal = 0.1666; - const LbmFloat maxusqr = maxVelVal*maxVelVal*3. *1.5; - - LbmVec objvel = vec2L((mMOIVertices[n]-mMOIVerticesOld[n]) /dvec); - { - const LbmFloat usqr = (objvel[0]*objvel[0]+objvel[1]*objvel[1]+objvel[2]*objvel[2])*1.5; - USQRMAXCHECK(usqr, objvel[0],objvel[1],objvel[2], mMaxVlen, mMxvx,mMxvy,mMxvz); - if(usqr>maxusqr) { - // cutoff at maxVelVal - for(int jj=0; jj<3; jj++) { - if(objvel[jj]>0.) objvel[jj] = maxVelVal; - if(objvel[jj]<0.) objvel[jj] = -maxVelVal; - } - } - } - const LbmFloat dp=dot(objvel, vec2L((*pNormals)[n]) ); - const LbmVec oldov=objvel; // debug - objvel = vec2L((*pNormals)[n]) *dp; - */ - } - } - } - - if(sds->coll_group) - go = go->next; - else - base= base->next; - } - } } void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm) { -- cgit v1.2.3 From 68b49aa981e146d7a7afde3e83305445bcc5ca3e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 Nov 2010 17:14:03 +0000 Subject: use unit system for the grid floor (was only ortho before). --- source/blender/blenkernel/intern/unit.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 54ecef75108..69a43ac60f0 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -755,6 +755,11 @@ void bUnit_GetSystem(void **usys_pt, int *len, int system, int type) *len= usys->length; } +int bUnit_GetBaseUnit(void *usys_pt) +{ + return ((bUnitCollection *)usys_pt)->base_unit; +} + const char *bUnit_GetName(void *usys_pt, int index) { return ((bUnitCollection *)usys_pt)->units[index].name; -- cgit v1.2.3 From c88991adee301a94c0df38e06c8f2d9225792dfa Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 23 Nov 2010 19:06:54 +0000 Subject: Small feature fix: zero-user blocks get indicated with "0" again in browsing. --- 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 52f5bee075b..8ce89182a3a 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1374,7 +1374,7 @@ void rename_id(ID *id, char *name) void name_uiprefix_id(char *name, ID *id) { name[0] = id->lib ? 'L':' '; - name[1] = id->flag & LIB_FAKEUSER ? 'F':' '; + name[1] = id->flag & LIB_FAKEUSER ? 'F': (id->us==0)?'0':' '; name[2] = ' '; strcpy(name+3, id->name+2); -- cgit v1.2.3 From 40d7da495e67b9230354a217d8ec0f36f86b5685 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Nov 2010 14:05:09 +0000 Subject: correction while looking into another bug, setup_app_data() will always free window manages if mode==0, but had left the contexts manager variable which could be used later. --- source/blender/blenkernel/intern/blender.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index e1e4f3b15ac..6911e7fd581 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -262,7 +262,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename G.winpos= bfd->winpos; G.displaymode= bfd->displaymode; G.fileflags= bfd->fileflags; - + CTX_wm_manager_set(C, bfd->main->wm.first); CTX_wm_screen_set(C, bfd->curscreen); CTX_data_scene_set(C, bfd->curscreen->scene); CTX_wm_area_set(C, NULL); -- cgit v1.2.3 From c7c034fedb87e0ff3cf80f4f388bacad51434617 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 24 Nov 2010 14:05:53 +0000 Subject: Fix #24782: proxy armature Layer state not saved with file. Was in 2.4x but not ported to 2.5x, implemented a bit different now to fit RNA better. --- source/blender/blenkernel/intern/armature.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b5fde5329df..1943c82766e 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1456,10 +1456,6 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected if(error) return; - /* exception, armature local layer should be proxied too */ - if (pose->proxy_layer) - ((bArmature *)ob->data)->layer= pose->proxy_layer; - /* clear all transformation values from library */ rest_pose(frompose); -- cgit v1.2.3 From bc9f1642bdd2e44e417721c4b5bb120c0e94e257 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Nov 2010 16:54:18 +0000 Subject: fix for crash canceling fly mode. --- source/blender/blenkernel/intern/image.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 36709c03cf2..8be52022dce 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2169,6 +2169,7 @@ void BKE_image_release_ibuf(Image *ima, void *lock) } } +/* warning, this can allocate generated images */ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) { return BKE_image_acquire_ibuf(ima, iuser, NULL); -- cgit v1.2.3 From 337f95dfabda563f0f55194207adfd7217255642 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 24 Nov 2010 17:13:02 +0000 Subject: Bugfix #24887 Crash in snapping, bvh tree. Wrong check for numFaces here. Fixed the crash by adding test for face pointer, but not sure what the coder intended here. Needs investigation, left XXX remark. --- source/blender/blenkernel/intern/bvhutils.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 882295b931c..863dc0984b8 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -578,11 +578,12 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis); if(tree != NULL) { + /* XXX numFaces is from different mesh as em_evil, made loop check for efa too */ /* XXX, for snap only, em & dm are assumed to be aligned, since dm is the em's cage */ EditMesh *em= data->em_evil; if(em) { EditFace *efa= em->faces.first; - for(i = 0; i < numFaces; i++, efa= efa->next) { + for(i = 0; i < numFaces, efa; i++, efa= efa->next) { if(!(efa->f & 1) && efa->h==0 && !((efa->v1->f&1)+(efa->v2->f&1)+(efa->v3->f&1)+(efa->v4?efa->v4->f&1:0))) { float co[4][3]; VECCOPY(co[0], vert[ face[i].v1 ].co); -- cgit v1.2.3 From 2c70b1785c02f8f2c3ac8aeae279a9b8a484d141 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Nov 2010 18:02:35 +0000 Subject: bugfix [#24887] Crash on snapping verts on other object now the derived mesh and the editmesh will always have matching faces. --- source/blender/blenkernel/intern/bvhutils.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 863dc0984b8..882295b931c 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -578,12 +578,11 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis); if(tree != NULL) { - /* XXX numFaces is from different mesh as em_evil, made loop check for efa too */ /* XXX, for snap only, em & dm are assumed to be aligned, since dm is the em's cage */ EditMesh *em= data->em_evil; if(em) { EditFace *efa= em->faces.first; - for(i = 0; i < numFaces, efa; i++, efa= efa->next) { + for(i = 0; i < numFaces; i++, efa= efa->next) { if(!(efa->f & 1) && efa->h==0 && !((efa->v1->f&1)+(efa->v2->f&1)+(efa->v3->f&1)+(efa->v4?efa->v4->f&1:0))) { float co[4][3]; VECCOPY(co[0], vert[ face[i].v1 ].co); -- cgit v1.2.3 From 9371a800b7855648469a58a0ef4ddb08eaf943cf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 24 Nov 2010 21:33:07 +0000 Subject: drivers could reference invalid index values outside the bounds of the array. --- source/blender/blenkernel/intern/fcurve.c | 39 ++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 2f886d8ab43..888eae3ed78 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -934,31 +934,44 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) /* get property to read from, and get value as appropriate */ if (RNA_path_resolve_full(&id_ptr, dtar->rna_path, &ptr, &prop, &index)) { - switch (RNA_property_type(prop)) { - case PROP_BOOLEAN: - if (RNA_property_array_length(&ptr, prop)) + if(RNA_property_array_check(&ptr, prop)) { + /* array */ + if (index < RNA_property_array_length(&ptr, prop)) { + switch (RNA_property_type(prop)) { + case PROP_BOOLEAN: value= (float)RNA_property_boolean_get_index(&ptr, prop, index); - else - value= (float)RNA_property_boolean_get(&ptr, prop); + break; + case PROP_INT: + value= (float)RNA_property_int_get_index(&ptr, prop, index); + break; + case PROP_FLOAT: + value= RNA_property_float_get_index(&ptr, prop, index); + break; + default: + break; + } + } + } + else { + /* not an array */ + switch (RNA_property_type(prop)) { + case PROP_BOOLEAN: + value= (float)RNA_property_boolean_get(&ptr, prop); break; case PROP_INT: - if (RNA_property_array_length(&ptr, prop)) - value= (float)RNA_property_int_get_index(&ptr, prop, index); - else - value= (float)RNA_property_int_get(&ptr, prop); + value= (float)RNA_property_int_get(&ptr, prop); break; case PROP_FLOAT: - if (RNA_property_array_length(&ptr, prop)) - value= RNA_property_float_get_index(&ptr, prop, index); - else - value= RNA_property_float_get(&ptr, prop); + value= RNA_property_float_get(&ptr, prop); break; case PROP_ENUM: value= (float)RNA_property_enum_get(&ptr, prop); break; default: break; + } } + } else { if (G.f & G_DEBUG) -- cgit v1.2.3 From 9f18e066fc373d39dea40f288dcaf10e9a049e6e Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 24 Nov 2010 23:36:36 +0000 Subject: Spline IK Bugfix: Binding code had off-by-1 error, which meant that when "Even Divisions" was disabled the length of the wrong bone would get used. This error was most noticeable when the lengths of the bones were quite different - for example, a chain with 3 bones of increasing length. Thanks to "Julius" on BlenderArtists for catching this. Cheers! --- Also, simplified the binding code loop a bit to prevent this sort of error in future. --- source/blender/blenkernel/intern/anim_sys.c | 2 +- source/blender/blenkernel/intern/armature.c | 29 +++++++++++++---------------- 2 files changed, 14 insertions(+), 17 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 580f94ba3b8..ae683dab7b2 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1654,7 +1654,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) /* make dummy NLA strip, and add that to the stack */ NlaStrip dummy_strip= {0}; ListBase dummy_trackslist; - + dummy_trackslist.first= dummy_trackslist.last= &dummy_strip; if ((nlt) && !(adt->flag & ADT_NLA_EDIT_NOMAP)) { diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 1943c82766e..d2861a8942c 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1730,28 +1730,25 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos ikData->numpoints= ikData->chainlen+1; ikData->points= MEM_callocN(sizeof(float)*ikData->numpoints, "Spline IK Binding"); + /* bind 'tip' of chain (i.e. first joint = tip of bone with the Spline IK Constraint) */ + ikData->points[0] = 1.0f; + /* perform binding of the joints to parametric positions along the curve based * proportion of the total length that each bone occupies */ for (i = 0; i < segcount; i++) { - if (i != 0) { - /* 'head' joints - * - 2 methods; the one chosen depends on whether we've got usable lengths - */ - if ((ikData->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || (totLength == 0.0f)) { - /* 1) equi-spaced joints */ - ikData->points[i]= ikData->points[i-1] - segmentLen; - } - else { - /* 2) to find this point on the curve, we take a step from the previous joint - * a distance given by the proportion that this bone takes - */ - ikData->points[i]= ikData->points[i-1] - (boneLengths[i] / totLength); - } + /* 'head' joints, travelling towards the root of the chain + * - 2 methods; the one chosen depends on whether we've got usable lengths + */ + if ((ikData->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || (totLength == 0.0f)) { + /* 1) equi-spaced joints */ + ikData->points[i+1]= ikData->points[i] - segmentLen; } else { - /* 'tip' of chain, special exception for the first joint */ - ikData->points[0]= 1.0f; + /* 2) to find this point on the curve, we take a step from the previous joint + * a distance given by the proportion that this bone takes + */ + ikData->points[i+1]= ikData->points[i] - (boneLengths[i] / totLength); } } -- cgit v1.2.3 From 22b3f2228f1e324cb80856bda726f499a12e025e Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 25 Nov 2010 11:38:55 +0000 Subject: Possible fix for the issue that came up in [#24890] Vector Blur node is Buggy * Apparently some compilers don't respect proper operator precedence, so added some parentheses around to make inline conditionals unambiguous. --- source/blender/blenkernel/intern/pointcache.c | 40 +++++++++++++-------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index bceff487543..4d22b22ae31 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1230,7 +1230,7 @@ static int ptcache_file_read_data(PTCacheFile *pf) int i; for(i=0; idata_types & (1<cur[i], 1, ptcache_data_size[i])) + if((pf->data_types & (1<cur[i], 1, ptcache_data_size[i])) return 0; } @@ -1241,7 +1241,7 @@ static int ptcache_file_write_data(PTCacheFile *pf) int i; for(i=0; idata_types & (1<cur[i], 1, ptcache_data_size[i])) + if((pf->data_types & (1<cur[i], 1, ptcache_data_size[i])) return 0; } @@ -1295,14 +1295,14 @@ static void ptcache_file_init_pointers(PTCacheFile *pf) { int data_types = pf->data_types; - pf->cur[BPHYS_DATA_INDEX] = data_types & (1<data.index : NULL; - pf->cur[BPHYS_DATA_LOCATION] = data_types & (1<data.loc : NULL; - pf->cur[BPHYS_DATA_VELOCITY] = data_types & (1<data.vel : NULL; - pf->cur[BPHYS_DATA_ROTATION] = data_types & (1<data.rot : NULL; - pf->cur[BPHYS_DATA_AVELOCITY] = data_types & (1<data.ave : NULL; - pf->cur[BPHYS_DATA_SIZE] = data_types & (1<data.size : NULL; - pf->cur[BPHYS_DATA_TIMES] = data_types & (1<data.times : NULL; - pf->cur[BPHYS_DATA_BOIDS] = data_types & (1<data.boids : NULL; + pf->cur[BPHYS_DATA_INDEX] = (data_types & (1<data.index : NULL; + pf->cur[BPHYS_DATA_LOCATION] = (data_types & (1<data.loc : NULL; + pf->cur[BPHYS_DATA_VELOCITY] = (data_types & (1<data.vel : NULL; + pf->cur[BPHYS_DATA_ROTATION] = (data_types & (1<data.rot : NULL; + pf->cur[BPHYS_DATA_AVELOCITY] = (data_types & (1<data.ave : NULL; + pf->cur[BPHYS_DATA_SIZE] = (data_types & (1<data.size : NULL; + pf->cur[BPHYS_DATA_TIMES] = (data_types & (1<data.times : NULL; + pf->cur[BPHYS_DATA_BOIDS] = (data_types & (1<data.boids : NULL; } static void ptcache_file_seek_pointers(int index, PTCacheFile *pf) @@ -1329,7 +1329,7 @@ static void ptcache_file_seek_pointers(int index, PTCacheFile *pf) } else { for(i=0; idata_types & (1<data_types & (1<fp, 8 + 3*sizeof(int) + index * size, SEEK_SET); @@ -1343,7 +1343,7 @@ void BKE_ptcache_mem_init_pointers(PTCacheMem *pm) int i; for(i=0; icur[i] = data_types & (1<data[i] : NULL; + pm->cur[i] = ((data_types & (1<data[i] : NULL); } void BKE_ptcache_mem_incr_pointers(PTCacheMem *pm) @@ -1528,12 +1528,12 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) if(pm) { BKE_ptcache_mem_init_pointers(pm); totpoint = pm->totpoint; - index = pm->data_types & (1<cur[BPHYS_DATA_INDEX] : &i; + index = ((pm->data_types & (1<cur[BPHYS_DATA_INDEX] : &i); } if(pm2) { BKE_ptcache_mem_init_pointers(pm2); totpoint2 = pm2->totpoint; - index2 = pm2->data_types & (1<cur[BPHYS_DATA_INDEX] : &i; + index2 = ((pm2->data_types & (1<cur[BPHYS_DATA_INDEX] : &i); } if(pf) { if(ptcache_file_read_header_begin(pf)) { @@ -1545,7 +1545,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) else if(pid->read_header(pf)) { ptcache_file_init_pointers(pf); totpoint = pf->totpoint; - index = pf->data_types & (1<data.index : &i; + index = ((pf->data_types & (1<data.index : &i); } } else { @@ -1564,7 +1564,7 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) else if(pid->read_header(pf2)) { ptcache_file_init_pointers(pf2); totpoint2 = pf2->totpoint; - index2 = pf2->data_types & (1<data.index : &i; + index2 = ((pf2->data_types & (1<data.index : &i); } } else { @@ -1608,14 +1608,14 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) } else { if(pid->read_elem && (pm || ptcache_file_read_data(pf))) - pid->read_elem(*index, pid->calldata, pm ? pm->cur : pf->cur, frs_sec, cfra1 ? (float)cfra1 : (float)cfrai, NULL); + pid->read_elem(*index, pid->calldata, (pm ? pm->cur : pf->cur), frs_sec, (cfra1 ? (float)cfra1 : (float)cfrai), NULL); else if(pid->read_elem) { error = 1; break; } } if(pm) { BKE_ptcache_mem_incr_pointers(pm); - index = pm->data_types & (1<cur[BPHYS_DATA_INDEX] : &i; + index = ((pm->data_types & (1<cur[BPHYS_DATA_INDEX] : &i); } } } @@ -1667,13 +1667,13 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) if(pm2) { BKE_ptcache_mem_incr_pointers(pm2); - index2 = pm2->data_types & (1<cur[BPHYS_DATA_INDEX] : &i; + index2 = ((pm2->data_types & (1<cur[BPHYS_DATA_INDEX] : &i); } } } if(pm || pf) - ret = (pm2 || pf2) ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT; + ret = ((pm2 || pf2) ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT); else if(pm2 || pf2) { ret = PTCACHE_READ_OLD; pid->cache->simframe = old_frame; -- cgit v1.2.3 From 5d0b3a5230dd8ff10efcdec21931e1c6de88d700 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 25 Nov 2010 22:13:40 +0000 Subject: Smoke domain resolutions were calculated wrong for non-cube domains in some cases. --- source/blender/blenkernel/intern/smoke.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index ee19e779cc5..8822d0cb4c9 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -177,7 +177,7 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive if(size[0] > size[1]) { - if(size[0] > size[1]) + if(size[0] > size[2]) { scale = res / size[0]; smd->domain->dx = size[0] / res; @@ -187,11 +187,11 @@ int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, Derive } else { - scale = res / size[1]; - smd->domain->dx = size[1] / res; - smd->domain->res[1] = res; + scale = res / size[2]; + smd->domain->dx = size[2] / res; + smd->domain->res[2] = res; smd->domain->res[0] = (int)(size[0] * scale + 0.5); - smd->domain->res[2] = (int)(size[2] * scale + 0.5); + smd->domain->res[1] = (int)(size[1] * scale + 0.5); } } else -- cgit v1.2.3 From cf0820d6285c3a9379dd529ee50dcf39e2efa21c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 26 Nov 2010 16:33:42 +0000 Subject: change monospace font to be an extern, not good final design but better then loading the same font 3 times. need to load twice still because render may use the font in a thread. --- source/blender/blenkernel/intern/image.c | 24 +++++------------------- source/blender/blenkernel/intern/image_gen.c | 9 +++++---- 2 files changed, 10 insertions(+), 23 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 8be52022dce..b624feeaf9d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -985,29 +985,13 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } } -// XXX - Bad level call. -extern int datatoc_bmonofont_ttf_size; -extern char datatoc_bmonofont_ttf[]; - -// XXX - copied from text_font_begin ! Change all the BLF_* here -static int mono= -1; - -int stamp_font_begin(int size) -{ - if (mono == -1) - mono= BLF_load_mem_unique("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); - - BLF_aspect(mono, 1.0); - BLF_size(mono, size, 72); - return(mono); // XXX This is for image_gen.c!! -} - void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels) { struct StampData stamp_data; float w, h, pad; int x, y; float h_fixed; + const int mono= blf_mono_font_render; // XXX if (!rect && !rectf) return; @@ -1018,8 +1002,10 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i if(scene->r.stamp_font_id < 8) scene->r.stamp_font_id= 12; - stamp_font_begin(scene->r.stamp_font_id); - + /* set before return */ + BLF_aspect(mono, 1.0); + BLF_size(mono, scene->r.stamp_font_id, 72); + BLF_buffer(mono, rectf, rect, width, height, channels); BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); pad= BLF_width(mono, "--"); diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 9248ce69280..b765cf29a3d 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -298,16 +298,17 @@ static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int } /* defined in image.c */ -extern int stamp_font_begin(int size); static void checker_board_text(unsigned char *rect, float *rect_float, int width, int height, int step, int outline) { - int x, y, mono; + int x, y; int pen_x, pen_y; char text[3]= {'A', '1', '\0'}; + const int mono= blf_mono_font; + + BLF_aspect(mono, 1.0); + BLF_size(mono, 54, 72); /* hard coded size! */ - /* hard coded size! */ - mono= stamp_font_begin(54); BLF_buffer(mono, rect_float, rect, width, height, 4); for(y= 0; y < height; y+=step) -- cgit v1.2.3 From 8f4d8ad5bc173ab38a18c380dc5a5161eab6aa17 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 26 Nov 2010 18:13:27 +0000 Subject: Fix #24914: 3D text glitch and crash Crash was caused by invalid utf8 sequence pasteing from the clipboard. Prevent memory corruption by giving utf8slen() the same rules of bytes checking as utf8towchar() does. --- source/blender/blenkernel/intern/font.c | 40 +++++++++++++++------------------ 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 1b5760fc5f1..500ccf0781b 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -124,31 +124,27 @@ wcsleninu8(wchar_t *src) } static int -utf8slen(char *src) +utf8slen(const char *strc) { - int size = 0, index = 0; - unsigned char c; - - c = src[index++]; - while(c) - { - if((c & 0x80) == 0) - { - index += 0; - } - else if((c & 0xe0) == 0xe0) - { - index += 2; - } - else - { - index += 1; + int len=0; + + while(*strc) { + if ((*strc & 0xe0) == 0xc0) { + if((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00) + strc++; + } else if ((*strc & 0xf0) == 0xe0) { + if((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00) + strc += 2; + } else if ((*strc & 0xf8) == 0xf0) { + if((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00) + strc += 3; } - size += 1; - c = src[index++]; + + strc++; + len++; } - - return size; + + return len; } -- cgit v1.2.3 From 34ea1cf0b23977ab76b23b06f6ceb1fda5631f88 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 28 Nov 2010 06:03:30 +0000 Subject: minor changes to the python api. - pep8 script was giving an error on non utf8 scons source files. - use PyList_SET_ITEM macro when list type is ensured. - all mathutils types use subtypes to create new types when available. - use defines MAT3_UNITY, MAT4_UNITY to initialize unit matrices. --- source/blender/blenkernel/intern/armature.c | 9 +++------ source/blender/blenkernel/intern/constraint.c | 11 +++++------ source/blender/blenkernel/intern/particle.c | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index d2861a8942c..b4bdb516ab3 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -590,7 +590,7 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info Mat4 *b_bone_rest= b_bone_spline_setup(pchan, 1); Mat4 *b_bone_mats; DualQuat *b_bone_dual_quats= NULL; - float tmat[4][4]; + float tmat[4][4]= MAT4_UNITY; int a; /* allocate b_bone matrices and dual quats */ @@ -611,7 +611,6 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info - translate over the curve to the bbone mat space - transform with b_bone matrix - transform back into global space */ - unit_m4(tmat); for(a=0; asegments; a++) { invert_m4_m4(tmat, b_bone_rest[a].mat); @@ -1104,11 +1103,10 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4]) */ void armature_loc_world_to_pose(Object *ob, float *inloc, float *outloc) { - float xLocMat[4][4]; + float xLocMat[4][4]= MAT4_UNITY; float nLocMat[4][4]; /* build matrix for location */ - unit_m4(xLocMat); VECCOPY(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ @@ -1184,11 +1182,10 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm */ void armature_loc_pose_to_bone(bPoseChannel *pchan, float *inloc, float *outloc) { - float xLocMat[4][4]; + float xLocMat[4][4]= MAT4_UNITY; float nLocMat[4][4]; /* build matrix for location */ - unit_m4(xLocMat); VECCOPY(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 076dae41e6a..f15e0bc3144 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1202,12 +1202,11 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr if (VALID_CONS_TARGET(ct)) { Curve *cu= ct->tar->data; float vec[4], dir[3], radius; - float totmat[4][4]; + float totmat[4][4]= MAT4_UNITY; float curvetime; - - unit_m4(totmat); + unit_m4(ct->matrix); - + /* note: when creating constraints that follow path, the curve gets the CU_PATH set now, * currently for paths to work it needs to go through the bevlist/displist system (ton) */ @@ -3106,11 +3105,11 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* only evaluate if there is a target and it is a curve */ if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_CURVE)) { Curve *cu= data->tar->data; - float obmat[4][4], targetMatrix[4][4], ownLoc[3]; + float obmat[4][4], ownLoc[3]; float curveMin[3], curveMax[3]; + float targetMatrix[4][4]= MAT4_UNITY; copy_m4_m4(obmat, cob->matrix); - unit_m4(targetMatrix); copy_v3_v3(ownLoc, obmat[3]); INIT_MINMAX(curveMin, curveMax) diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 2eff81b96a6..9c2efe395dc 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4359,7 +4359,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa normalize_v3(side); cross_v3_v3v3(nor, vec, side); - unit_m4(mat); + unit_m4(mat); VECCOPY(mat[0], vec); VECCOPY(mat[1], side); VECCOPY(mat[2], nor); -- cgit v1.2.3 From b7d0715284e1177ab8c31a998358d23b5d0b11dd Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 28 Nov 2010 16:36:36 +0000 Subject: Bugfix #24953 Compositor: If scene render size changed, a Texture node didn't get tagged to re-render, using previous size instead. --- source/blender/blenkernel/intern/node.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 7b25c38648d..4c88cbfaa55 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2907,6 +2907,8 @@ void ntreeCompositTagRender(Scene *curscene) for(node= sce->nodetree->nodes.first; node; node= node->next) { if(node->id==(ID *)curscene || node->type==CMP_NODE_COMPOSITE) NodeTagChanged(sce->nodetree, node); + else if(node->type==CMP_NODE_TEXTURE) /* uses scene sizex/sizey */ + NodeTagChanged(sce->nodetree, node); } } } -- cgit v1.2.3 From 510920a299478cdd50ce8ce4ff43d14eb4e2c2e4 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sun, 28 Nov 2010 18:23:21 +0000 Subject: == Sequencer == This fixes Orig Dimension display (mostly). * orx, ory both didn't get calculated, if dimension already matched * putting them into Strip instead of StripData ment, that using images of different dimensions in one strip could lead to incorrect results Still TODO: on file open, timeline display happens before preview display which means: orig_width and height are calculated after the first draw of N-keys dialog. You have to hit refresh (or scrub one frame) to get the right values displayed. --- source/blender/blenkernel/intern/sequencer.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index b98976729c4..9eafb3fb3e3 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1558,9 +1558,6 @@ static ImBuf * input_preprocess( { float mul; - seq->strip->orx= ibuf->x; - seq->strip->ory= ibuf->y; - if((seq->flag & SEQ_FILTERY) && seq->type != SEQ_MOVIE) { IMB_filtery(ibuf); } @@ -2054,6 +2051,9 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr IMB_convert_profile(ibuf, IB_PROFILE_NONE); copy_to_ibuf_still(context, seq, nr, ibuf); + + s_elem->orig_width = ibuf->x; + s_elem->orig_height = ibuf->y; } break; } @@ -2073,7 +2073,10 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr /* we don't need both (speed reasons)! */ if (ibuf && ibuf->rect_float && ibuf->rect) imb_freerectImBuf(ibuf); - + if (ibuf) { + seq->strip->stripdata->orig_width = ibuf->x; + seq->strip->stripdata->orig_height = ibuf->y; + } } copy_to_ibuf_still(context, seq, nr, ibuf); break; -- cgit v1.2.3 From 04d374194756516c8b7a15fff99bfa72a2239f75 Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Mon, 29 Nov 2010 07:37:20 +0000 Subject: Fix [#24964] HISTOGRAM: Inconsistency in spaces --- source/blender/blenkernel/intern/colortools.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 86d7cbf0133..1be1b9b9ad0 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -956,13 +956,11 @@ void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size) DO_INLINE int get_bin_float(float f) { - int bin= (int)(f*255); + int bin= (int)((f*255) + 0.5); /* 0.5 to prevent quantisation differences */ /* note: clamp integer instead of float to avoid problems with NaN */ CLAMP(bin, 0, 255); - - //return (int) (((f + 0.25) / 1.5) * 255); - + return bin; } -- cgit v1.2.3 From 17cd5811e767df5bc7247648e3cbe52e39575f56 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 30 Nov 2010 21:31:18 +0000 Subject: Smoke now uses only one point cache where both normal and high resolution smoke are stored together: * Separate caches were causing quite a lot of problems both in principle and practice. * For example it doesn't really make sense to have different frame ranges for normal and high resolution smoke, but this was fully possible before. * Also to fully bake the smoke you had to do a "Bake All Dynamics", which completely defeats the whole point of the feature! * As a result of this change the smoke cache usage is much much simpler and less error prone. * This is quite a big change, but hopefully there should be less rather than more problems as a result :) Some other related changes: * Changing the cache name now works for disk caches properly too, it now just renames the cache files so should be faster too! * Smoke is now always forced to disk cache with step 1 on file load as there were some strange cases where smoke was trying to use memory cache. * Disabled smoke debug prints from console. * Disabled changing smoke parameters when smoke is baked. Note to users: The unfortunate side effect of this is that old high resolution simulations have to be baked again, but in return you get much better and more logical functionality. Sorry none the less! --- source/blender/blenkernel/intern/pointcache.c | 175 ++++++++++++++------------ source/blender/blenkernel/intern/smoke.c | 102 ++++----------- 2 files changed, 123 insertions(+), 154 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 4d22b22ae31..440a3136108 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -725,6 +725,7 @@ static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; SmokeDomainSettings *sds = smd->domain; + int ret = 0; if(sds->fluid) { size_t res = sds->res[0]*sds->res[1]*sds->res[2]; @@ -755,16 +756,9 @@ static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v) MEM_freeN(out); - return 1; + ret = 1; } - return 0; -} -static int ptcache_write_smoke_turbulence(PTCacheFile *pf, void *smoke_v) -{ - SmokeModifierData *smd= (SmokeModifierData *)smoke_v; - SmokeDomainSettings *sds = smd->domain; - if(sds->wt) { int res_big_array[3]; int res_big; @@ -796,11 +790,13 @@ static int ptcache_write_smoke_turbulence(PTCacheFile *pf, void *smoke_v) ptcache_compress_write(pf, (unsigned char *)tcw, in_len, out, mode); MEM_freeN(out); - return 1; + ret = 1; } - return 0; + + return ret; } + // forward decleration static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size); @@ -877,33 +873,27 @@ static void ptcache_read_smoke(PTCacheFile *pf, void *smoke_v) ptcache_compress_read(pf, (unsigned char*)obstacles, (unsigned int)res); ptcache_file_read(pf, &dt, 1, sizeof(float)); ptcache_file_read(pf, &dx, 1, sizeof(float)); - } -} -static void ptcache_read_smoke_turbulence(PTCacheFile *pf, void *smoke_v) -{ - SmokeModifierData *smd= (SmokeModifierData *)smoke_v; - SmokeDomainSettings *sds = smd->domain; - - if(sds->fluid) { - int res = sds->res[0]*sds->res[1]*sds->res[2]; - int res_big, res_big_array[3]; - float *dens, *densold, *tcu, *tcv, *tcw; - unsigned int out_len = sizeof(float)*(unsigned int)res; - unsigned int out_len_big; + if(pf->data_types & (1<wt) { + int res = sds->res[0]*sds->res[1]*sds->res[2]; + int res_big, res_big_array[3]; + float *dens, *densold, *tcu, *tcv, *tcw; + unsigned int out_len = sizeof(float)*(unsigned int)res; + unsigned int out_len_big; - smoke_turbulence_get_res(sds->wt, res_big_array); - res_big = res_big_array[0]*res_big_array[1]*res_big_array[2]; - out_len_big = sizeof(float) * (unsigned int)res_big; + smoke_turbulence_get_res(sds->wt, res_big_array); + res_big = res_big_array[0]*res_big_array[1]*res_big_array[2]; + out_len_big = sizeof(float) * (unsigned int)res_big; - smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw); + smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw); - ptcache_compress_read(pf, (unsigned char*)dens, out_len_big); - ptcache_compress_read(pf, (unsigned char*)densold, out_len_big); + ptcache_compress_read(pf, (unsigned char*)dens, out_len_big); + ptcache_compress_read(pf, (unsigned char*)densold, out_len_big); - ptcache_compress_read(pf, (unsigned char*)tcu, out_len); - ptcache_compress_read(pf, (unsigned char*)tcv, out_len); - ptcache_compress_read(pf, (unsigned char*)tcw, out_len); + ptcache_compress_read(pf, (unsigned char*)tcu, out_len); + ptcache_compress_read(pf, (unsigned char*)tcv, out_len); + ptcache_compress_read(pf, (unsigned char*)tcw, out_len); + } } } @@ -936,41 +926,13 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo pid->write_header= ptcache_write_basic_header; pid->read_header= ptcache_read_basic_header; - pid->data_types= (1<data_types= 0; pid->info_types= 0; -} -void BKE_ptcache_id_from_smoke_turbulence(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd) -{ - SmokeDomainSettings *sds = smd->domain; - - memset(pid, 0, sizeof(PTCacheID)); - - pid->ob= ob; - pid->calldata= smd; - - pid->type= PTCACHE_TYPE_SMOKE_HIGHRES; - pid->stack_index= sds->point_cache[1]->index; - - pid->cache= sds->point_cache[1]; - pid->cache_ptr= &sds->point_cache[1]; - pid->ptcaches= &sds->ptcaches[1]; - - pid->totpoint= pid->totwrite= ptcache_totpoint_smoke_turbulence; - - pid->write_elem= NULL; - pid->read_elem= NULL; - - pid->read_stream = ptcache_read_smoke_turbulence; - pid->write_stream = ptcache_write_smoke_turbulence; - - pid->interpolate_elem= NULL; - - pid->write_header= ptcache_write_basic_header; - pid->read_header= ptcache_read_basic_header; - - pid->data_types= (1<info_types= 0; + if(sds->fluid) + pid->data_types |= (1<wt) + pid->data_types |= (1<cache->name); + + /* get "from" filename */ + strcpy(pid->cache->name, from); + + len = BKE_ptcache_id_filename(pid, old_filename, 0, 0, 0); /* no path */ + + ptcache_path(pid, path); + dir = opendir(path); + if(dir==NULL) { + strcpy(pid->cache->name, old_name); + return; + } + + snprintf(ext, sizeof(ext), "_%02d"PTCACHE_EXT, pid->stack_index); + + /* put new name into cache */ + strcpy(pid->cache->name, to); + + while ((de = readdir(dir)) != NULL) { + if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ + if (strncmp(old_filename, de->d_name, len ) == 0) { /* do we have the right prefix */ + /* read the number of the file */ + int frame, len2 = (int)strlen(de->d_name); + char num[7]; + + if (len2 > 15) { /* could crash if trying to copy a string out of this range*/ + BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num)); + frame = atoi(num); + + BLI_join_dirfile(old_path_full, path, de->d_name); + BKE_ptcache_id_filename(pid, new_path_full, frame, 1, 1); + BLI_rename(old_path_full, new_path_full); + } + } + } + } + + strcpy(pid->cache->name, old_name); +} + void BKE_ptcache_load_external(PTCacheID *pid) { /*todo*/ @@ -2965,14 +2975,25 @@ void BKE_ptcache_update_info(PTCacheID *pid) } if(cache->flag & PTCACHE_DISK_CACHE) { - int cfra = cache->startframe; + if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) + { + int totpoint = pid->totpoint(pid->calldata, 0); - for(; cfra<=cache->endframe; cfra++) { - if(BKE_ptcache_id_exist(pid, cfra)) - totframes++; + if(cache->totpoint > totpoint) + sprintf(mem_info, "%i cells + High Resolution cached", totpoint); + else + sprintf(mem_info, "%i cells cached"); } + else { + int cfra = cache->startframe; - sprintf(mem_info, "%i frames on disk", totframes); + for(; cfra<=cache->endframe; cfra++) { + if(BKE_ptcache_id_exist(pid, cfra)) + totframes++; + } + + sprintf(mem_info, "%i frames on disk", totframes); + } } else { PTCacheMem *pm = cache->mem_cache.first; diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 8822d0cb4c9..8fd9c48cc61 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -554,8 +554,6 @@ static void smokeModifier_freeDomain(SmokeModifierData *smd) BKE_ptcache_free_list(&(smd->domain->ptcaches[0])); smd->domain->point_cache[0] = NULL; - BKE_ptcache_free_list(&(smd->domain->ptcaches[1])); - smd->domain->point_cache[1] = NULL; MEM_freeN(smd->domain); smd->domain = NULL; @@ -695,10 +693,9 @@ void smokeModifier_createType(struct SmokeModifierData *smd) smd->domain->point_cache[0]->flag |= PTCACHE_DISK_CACHE; smd->domain->point_cache[0]->step = 1; - smd->domain->point_cache[1] = BKE_ptcache_add(&(smd->domain->ptcaches[1])); - smd->domain->point_cache[1]->flag |= PTCACHE_DISK_CACHE; - smd->domain->point_cache[1]->step = 1; - + /* Deprecated */ + smd->domain->point_cache[1] = NULL; + smd->domain->ptcaches[1].first = smd->domain->ptcaches[1].last = NULL; /* set some standard values */ smd->domain->fluid = NULL; smd->domain->wt = NULL; @@ -1323,35 +1320,22 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM float light[3]; PointCache *cache = NULL; PTCacheID pid; - PointCache *cache_wt = NULL; - PTCacheID pid_wt; int startframe, endframe, framenr; float timescale; - int cache_result = 0, cache_result_wt = 0; - int did_init = 0; framenr = scene->r.cfra; - printf("time: %d\n", scene->r.cfra); + //printf("time: %d\n", scene->r.cfra); cache = sds->point_cache[0]; BKE_ptcache_id_from_smoke(&pid, ob, smd); BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, ×cale); - cache_wt = sds->point_cache[1]; - BKE_ptcache_id_from_smoke_turbulence(&pid_wt, ob, smd); - if(!smd->domain->fluid || framenr == startframe) { BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); BKE_ptcache_validate(cache, framenr); cache->flag &= ~PTCACHE_REDO_NEEDED; - - BKE_ptcache_id_reset(scene, &pid_wt, PTCACHE_RESET_OUTDATED); - if(cache_wt) { - BKE_ptcache_validate(cache_wt, framenr); - cache_wt->flag &= ~PTCACHE_REDO_NEEDED; - } } if(!smd->domain->fluid && (framenr != startframe) && (smd->domain->flags & MOD_SMOKE_FILE_LOAD)==0 && (cache->flag & PTCACHE_BAKED)==0) @@ -1359,11 +1343,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM smd->domain->flags &= ~MOD_SMOKE_FILE_LOAD; - if(framenr < startframe) - framenr = startframe; - - if(framenr > endframe) - framenr = endframe; + CLAMP(framenr, startframe, endframe); /* If already viewing a pre/after frame, no need to reload */ if ((smd->time == framenr) && (framenr != scene->r.cfra)) @@ -1371,42 +1351,21 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM // printf("startframe: %d, framenr: %d\n", startframe, framenr); - if(!(did_init = smokeModifier_init(smd, ob, scene, dm))) + if(smokeModifier_init(smd, ob, scene, dm)==0) { printf("bad smokeModifier_init\n"); return; } /* try to read from cache */ - cache_result = BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec); - // printf("cache_result: %d\n", cache_result); - - if(cache_result == PTCACHE_READ_EXACT) - { + if(BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec) == PTCACHE_READ_EXACT) { BKE_ptcache_validate(cache, framenr); smd->time = framenr; - - if(sds->wt) - { - cache_result_wt = BKE_ptcache_read_cache(&pid_wt, (float)framenr, scene->r.frs_sec); - - if(cache_result_wt == PTCACHE_READ_EXACT) - { - BKE_ptcache_validate(cache_wt, framenr); - - return; - } - else - { - ; /* don't return in the case we only got low res cache but no high res cache */ - /* we still need to calculate the high res cache */ - } - } - else - return; + return; } + /* only calculate something when we advanced a single frame */ - else if(framenr != (int)smd->time+1) + if(framenr != (int)smd->time+1) return; /* don't simulate if viewing start frame, but scene frame is not real start frame */ @@ -1418,15 +1377,19 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM smoke_calc_domain(scene, ob, smd); /* if on second frame, write cache for first frame */ - /* this needs to be done for smoke too so that pointcache works properly */ if((int)smd->time == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) { // create shadows straight after domain initialization 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); - BKE_ptcache_write_cache(&pid, startframe); if(sds->wt) - BKE_ptcache_write_cache(&pid_wt, startframe); + { + if(sds->flags & MOD_SMOKE_DISSOLVE) + smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); + smoke_turbulence_step(sds->wt, sds->fluid); + } + + BKE_ptcache_write_cache(&pid, startframe); } // set new time @@ -1444,39 +1407,24 @@ 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 they get stored 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); - - BKE_ptcache_validate(cache, framenr); - BKE_ptcache_write_cache(&pid, framenr); if(sds->wt) { - if(framenr!=startframe) - { - if(sds->flags & MOD_SMOKE_DISSOLVE) - smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); - smoke_turbulence_step(sds->wt, sds->fluid); - } - - BKE_ptcache_validate(cache_wt, framenr); - BKE_ptcache_write_cache(&pid_wt, framenr); + if(sds->flags & MOD_SMOKE_DISSOLVE) + smoke_dissolve_wavelet(sds->wt, sds->diss_speed, sds->flags & MOD_SMOKE_DISSOLVE_LOG); + smoke_turbulence_step(sds->wt, sds->fluid); } + + BKE_ptcache_validate(cache, framenr); + if(framenr != startframe) + BKE_ptcache_write_cache(&pid, framenr); tend(); - printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() ); + //printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() ); } } -- cgit v1.2.3 From 89abb9f2d2470cf808fd1f42c67d82355d1ade8e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 30 Nov 2010 23:38:31 +0000 Subject: bugfix [#22638] Alpha channel not saved when using texture paint check for alpha channel while saving images that have been painted onto. It would be nicer to do this while in paint mode except this isn't so simple with project paint using multiple images at once. --- source/blender/blenkernel/intern/image.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index b624feeaf9d..31eae70f159 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1188,6 +1188,29 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) if (stamp_data.rendertime[0]) IMB_metadata_change_field (ibuf, "RenderTime", stamp_data.rendertime); } +int BKE_alphatest_ibuf(ImBuf *ibuf) +{ + int tot; + if(ibuf->rect_float) { + float *buf= ibuf->rect_float; + for(tot= ibuf->x * ibuf->y; tot--; buf+=4) { + if(buf[3] < 1.0f) { + return TRUE; + } + } + } + else if (ibuf->rect) { + unsigned char *buf= (unsigned char *)ibuf->rect; + for(tot= ibuf->x * ibuf->y; tot--; buf+=4) { + if(buf[3] != 255) { + return TRUE; + } + } + } + + return FALSE; +} + int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality) { int ok; -- cgit v1.2.3 From b5ba824cf28e61cea21042bf58ef628bef6a2d13 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Dec 2010 02:28:08 +0000 Subject: patch from JacobF on IRC, copy smoke settings. double checked none of these are used for runtime. --- source/blender/blenkernel/intern/smoke.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 8fd9c48cc61..b449ebb89ac 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -773,6 +773,9 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData tsmd->domain->viewsettings = smd->domain->viewsettings; tsmd->domain->fluid_group = smd->domain->fluid_group; tsmd->domain->coll_group = smd->domain->coll_group; + tsmd->domain->vorticity = smd->domain->vorticity; + tsmd->domain->time_scale = smd->domain->time_scale; + tsmd->domain->border_collisions = smd->domain->border_collisions; MEM_freeN(tsmd->domain->effector_weights); tsmd->domain->effector_weights = MEM_dupallocN(smd->domain->effector_weights); @@ -781,6 +784,8 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData tsmd->flow->temp = smd->flow->temp; tsmd->flow->psys = smd->flow->psys; tsmd->flow->type = smd->flow->type; + tsmd->flow->flags = smd->flow->flags; + tsmd->flow->vel_multi = smd->flow->vel_multi; } else if (tsmd->coll) { ; /* leave it as initialised, collision settings is mostly caches */ -- cgit v1.2.3 From ad0dd98f26bc681c92a0a1893c17a3bc484a0cb5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Dec 2010 02:40:13 +0000 Subject: fix for some mistakes in recent commit. --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 440a3136108..c989db9dfd1 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2982,7 +2982,7 @@ void BKE_ptcache_update_info(PTCacheID *pid) if(cache->totpoint > totpoint) sprintf(mem_info, "%i cells + High Resolution cached", totpoint); else - sprintf(mem_info, "%i cells cached"); + sprintf(mem_info, "%i cells cached", totpoint); } else { int cfra = cache->startframe; -- cgit v1.2.3 From f5f332892cd12a4323650504b33de40f529d2b8a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Dec 2010 05:59:11 +0000 Subject: workaround [#24958] Cloth pinning not working detailed explanation as to why this is needed in report. --- source/blender/blenkernel/intern/cloth.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index f8772cd802f..946d03d388a 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -447,6 +447,11 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, return dm; } + /* XXX, workaround for bug [#24958], see report for more info */ + if(CustomData_has_layer(&dm->vertData, CD_MDEFORMVERT) && !CustomData_has_layer(&result->vertData, CD_MDEFORMVERT)) { + DM_add_vert_layer(result, CD_MDEFORMVERT, CD_DUPLICATE, dm->getVertDataArray(dm, CD_MDEFORMVERT)); + } + if(clmd->sim_parms->reset || (framenr == (startframe - clmd->sim_parms->preroll) && clmd->sim_parms->preroll != 0) || (clmd->clothObject && result->getNumVerts(result) != clmd->clothObject->numverts)) -- cgit v1.2.3 From b36ab837780c513ab38f56294092816e1fd67af9 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 1 Dec 2010 12:23:10 +0000 Subject: Fix for [#24958] Cloth pinning not working * Cloth now uses the original derived mesh for simulation and a new dm only for applying the simulation result. * Reverted Campbell's temporary workaround r33406. --- source/blender/blenkernel/intern/cloth.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 946d03d388a..be715fac352 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -447,11 +447,6 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, return dm; } - /* XXX, workaround for bug [#24958], see report for more info */ - if(CustomData_has_layer(&dm->vertData, CD_MDEFORMVERT) && !CustomData_has_layer(&result->vertData, CD_MDEFORMVERT)) { - DM_add_vert_layer(result, CD_MDEFORMVERT, CD_DUPLICATE, dm->getVertDataArray(dm, CD_MDEFORMVERT)); - } - if(clmd->sim_parms->reset || (framenr == (startframe - clmd->sim_parms->preroll) && clmd->sim_parms->preroll != 0) || (clmd->clothObject && result->getNumVerts(result) != clmd->clothObject->numverts)) @@ -473,10 +468,10 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, BKE_ptcache_invalidate(cache); /* do simulation */ - if(!do_init_cloth(ob, clmd, result, framenr)) + if(!do_init_cloth(ob, clmd, dm, framenr)) return result; - do_step_cloth(ob, clmd, result, framenr); + do_step_cloth(ob, clmd, dm, framenr); cloth_to_object(ob, clmd, result); return result; @@ -497,12 +492,12 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, framedelta= -1; /* initialize simulation data if it didn't exist already */ - if(!do_init_cloth(ob, clmd, result, framenr)) + if(!do_init_cloth(ob, clmd, dm, framenr)) return result; if((framenr == startframe) && (clmd->sim_parms->preroll == 0)) { BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED); - do_init_cloth(ob, clmd, result, framenr); + do_init_cloth(ob, clmd, dm, framenr); BKE_ptcache_validate(cache, framenr); cache->flag &= ~PTCACHE_REDO_NEEDED; return result; @@ -540,7 +535,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, /* do simulation */ BKE_ptcache_validate(cache, framenr); - if(!do_step_cloth(ob, clmd, result, framenr)) { + if(!do_step_cloth(ob, clmd, dm, framenr)) { BKE_ptcache_invalidate(cache); } else -- cgit v1.2.3 From 024b0f92d52cc2a6851d1b58aa68c58a644c4cb4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 1 Dec 2010 23:40:21 +0000 Subject: fixed crash with rigid body constraints not having their child pointer read correctly. --- source/blender/blenkernel/intern/constraint.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index f15e0bc3144..c1a6200bf60 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -2996,6 +2996,7 @@ static void rbj_id_looper (bConstraint *con, ConstraintIDFunc func, void *userda /* target only */ func(con, (ID**)&data->tar, userdata); + func(con, (ID**)&data->child, userdata); } static int rbj_get_tars (bConstraint *con, ListBase *list) -- cgit v1.2.3 From 1dbc93b540ade1d7883bb9e3080e4581ddf2c4dc Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 2 Dec 2010 04:06:02 +0000 Subject: Additional fix for #24958 Cloth pinning not working * Don't assume that the original dm given to cloth modifier is a cddm --- source/blender/blenkernel/intern/cloth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index be715fac352..b781b18862c 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -936,7 +936,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) { unsigned int numverts = dm->getNumVerts ( dm ); unsigned int numfaces = dm->getNumFaces ( dm ); - MFace *mface = CDDM_get_faces(dm); + MFace *mface = dm->getFaceArray( dm ); unsigned int i = 0; /* Allocate our vertices. */ @@ -1049,8 +1049,8 @@ static int cloth_build_springs ( ClothModifierData *clmd, DerivedMesh *dm ) unsigned int numverts = (unsigned int)dm->getNumVerts ( dm ); unsigned int numedges = (unsigned int)dm->getNumEdges ( dm ); unsigned int numfaces = (unsigned int)dm->getNumFaces ( dm ); - MEdge *medge = CDDM_get_edges ( dm ); - MFace *mface = CDDM_get_faces ( dm ); + MEdge *medge = dm->getEdgeArray ( dm ); + MFace *mface = dm->getFaceArray ( dm ); int index2 = 0; // our second vertex index LinkNode **edgelist = NULL; EdgeHash *edgehash = NULL; -- cgit v1.2.3 From 5ca7c1b0f88ec3f48a83dc641f864d6ee4979ae2 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 2 Dec 2010 14:52:07 +0000 Subject: Fix for [#25006] Particle system crash (missing check for negative index) --- source/blender/blenkernel/intern/particle_system.c | 5 +++++ 1 file changed, 5 insertions(+) (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 63f2d692c6d..f4af518d137 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -340,6 +340,11 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys) /* cache the verts/faces! */ LOOP_PARTICLES { + if(pa->num < 0) { + pa->num_dmcache = -1; + continue; + } + if(psys->part->from == PART_FROM_VERT) { if(nodearray[pa->num]) pa->num_dmcache= GET_INT_FROM_POINTER(nodearray[pa->num]->link); -- cgit v1.2.3 From 30179f4dc66ff45a5e0077962c0151d7e7865ca1 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 2 Dec 2010 16:12:55 +0000 Subject: IRC comment fix: Option "free all texture-images" after render, was also freeing unsaved painted images. Now it skips them. --- source/blender/blenkernel/intern/image.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 31eae70f159..da1d59a0835 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -607,15 +607,21 @@ void BKE_image_free_all_textures(void) for(ima= G.main->image.first; ima; ima= ima->id.next) { if(ima->ibufs.first && (ima->id.flag & LIB_DOIT)) { - /* ImBuf *ibuf; + for(ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) { - if(ibuf->mipmap[0]) + /* escape when image is painted on */ + if(ibuf->userflags & IB_BITMAPDIRTY) + break; + + /* if(ibuf->mipmap[0]) totsize+= 1.33*ibuf->x*ibuf->y*4; else - totsize+= ibuf->x*ibuf->y*4; - } */ - image_free_buffers(ima); + totsize+= ibuf->x*ibuf->y*4;*/ + + } + if(ibuf==NULL) + image_free_buffers(ima); } } /* printf("freed total %d MB\n", totsize/(1024*1024)); */ -- cgit v1.2.3 From b45c3363fd65a734a87d0917988fda6ae9d9df3c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Dec 2010 01:52:28 +0000 Subject: fix for some pedantic warnings. --- source/blender/blenkernel/intern/deform.c | 4 ++-- source/blender/blenkernel/intern/pointcache.c | 2 ++ source/blender/blenkernel/intern/smoke.c | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 2eecc6d5c1b..ad797736a85 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -463,7 +463,7 @@ float defvert_array_find_weight_safe(const struct MDeformVert *dvert, int index, } -MDeformWeight *defvert_find_index(const MDeformVert *dvert, int defgroup) +MDeformWeight *defvert_find_index(const MDeformVert *dvert, const int defgroup) { if(dvert && defgroup >= 0) { MDeformWeight *dw = dvert->dw; @@ -479,7 +479,7 @@ MDeformWeight *defvert_find_index(const MDeformVert *dvert, int defgroup) /* Ensures that mv has a deform weight entry for the specified defweight group */ /* Note this function is mirrored in editmesh_tools.c, for use for editvertices */ -MDeformWeight *defvert_verify_index(MDeformVert *dv, int defgroup) +MDeformWeight *defvert_verify_index(MDeformVert *dv, const int defgroup) { MDeformWeight *newdw; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index c989db9dfd1..fb0d04b7473 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -652,6 +652,7 @@ static int ptcache_totpoint_smoke(void *smoke_v, int UNUSED(cfra)) } /* Smoke functions */ +#if 0 static int ptcache_totpoint_smoke_turbulence(void *smoke_v, int UNUSED(cfra)) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; @@ -663,6 +664,7 @@ static int ptcache_totpoint_smoke_turbulence(void *smoke_v, int UNUSED(cfra)) else return 0; } +#endif // forward decleration static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index b449ebb89ac..cca02dde25d 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -110,6 +110,8 @@ static void tend ( void ) { gettimeofday ( &_tend,&tz ); } + +#if 0 // unused static double tval() { double t1, t2; @@ -118,6 +120,7 @@ static double tval() return t2-t1; } #endif +#endif struct Object; struct Scene; -- cgit v1.2.3 From cfc1b133f664b024acc460e0204bb0bea66a83d3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Dec 2010 03:44:39 +0000 Subject: updates to patch from Dan Eicher, allow adding a NodeGroup through bpy.data.node_groups.new(name, type) made some minor changes. --- source/blender/blenkernel/intern/node.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 4c88cbfaa55..7f6fcdbdf40 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -496,9 +496,7 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) return NULL; /* OK! new nodetree */ - ngroup= alloc_libblock(&G.main->nodetree, ID_NT, "NodeGroup"); - ngroup->type= ntree->type; - ngroup->alltypes= ntree->alltypes; + ngroup= ntreeAddTree("NodeGroup", ntree->type, TRUE); /* move nodes over */ for(node= ntree->nodes.first; node; node= nextn) { @@ -884,6 +882,11 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) bNode *node= NULL; bNodeType *ntype= NULL; + if (ngroup && BLI_findindex(&G.main->nodetree, ngroup)==-1) { + printf("nodeAddNodeType() error: '%s' not in main->nodetree\n", ngroup->id.name); + return NULL; + } + if(type>=NODE_DYNAMIC_MENU) { int a=0, idx= type-NODE_DYNAMIC_MENU; ntype= ntree->alltypes.first; @@ -1034,21 +1037,22 @@ void nodeRemSocketLinks(bNodeTree *ntree, bNodeSocket *sock) } -bNodeTree *ntreeAddTree(int type) +bNodeTree *ntreeAddTree(const char *name, int type, const short is_group) { - bNodeTree *ntree= MEM_callocN(sizeof(bNodeTree), "new node tree"); + bNodeTree *ntree; + + if (is_group) + ntree= alloc_libblock(&G.main->nodetree, ID_NT, name); + else { + ntree= MEM_callocN(sizeof(bNodeTree), "new node tree"); + *( (short *)ntree->id.name )= type; + BLI_strncpy(ntree->id.name+2, name, sizeof(ntree->id.name)); + } + ntree->type= type; ntree->alltypes.first = NULL; ntree->alltypes.last = NULL; - /* this helps RNA identify ID pointers as nodetree */ - if(ntree->type==NTREE_SHADER) - BLI_strncpy(ntree->id.name, "NTShader Nodetree", sizeof(ntree->id.name)); - else if(ntree->type==NTREE_COMPOSIT) - BLI_strncpy(ntree->id.name, "NTCompositing Nodetree", sizeof(ntree->id.name)); - else if(ntree->type==NTREE_TEXTURE) - BLI_strncpy(ntree->id.name, "NTTexture Nodetree", sizeof(ntree->id.name)); - ntreeInitTypes(ntree); return ntree; } -- cgit v1.2.3 From aca76ddb502cbf0ee7888c3356f9f35240919410 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 3 Dec 2010 12:08:59 +0000 Subject: Fix for [#24899] Sequence Transform strips don't apply animation properly to scale. * Rendering a scene strip updated all animation data to it's frame, so fcurves were left with the wrong value. * Now the animation data is recalculated to original frame after rendering each scene strip. --- source/blender/blenkernel/intern/sequencer.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 9eafb3fb3e3..f5842fbe72d 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2085,6 +2085,9 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr { // scene can be NULL after deletions ibuf = seq_render_scene_strip_impl(context, seq, nr); + /* Scene strips update all animation, so we need to restore original state.*/ + BKE_animsys_evaluate_all_animation(context.bmain, cfra); + copy_to_ibuf_still(context, seq, nr, ibuf); break; } -- cgit v1.2.3 From cd972535027a73ba70069051fe9038b6a8b5696a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Dec 2010 12:30:59 +0000 Subject: - added GCC warning -Wstrict-prototypes - fixed bug in paste material, exposed by stricter warnings. - removed/renamed various shadowed vars. - removed BGE lamp.colour, only allow lamp.color attribute. --- source/blender/blenkernel/intern/cloth.c | 2 +- source/blender/blenkernel/intern/constraint.c | 2 +- source/blender/blenkernel/intern/fmodifier.c | 2 +- source/blender/blenkernel/intern/icons.c | 2 +- source/blender/blenkernel/intern/implicit.c | 2 +- source/blender/blenkernel/intern/material.c | 2 +- source/blender/blenkernel/intern/seqeffects.c | 26 +++++++++++----------- source/blender/blenkernel/intern/softbody.c | 6 ++--- source/blender/blenkernel/intern/suggestions.c | 4 ++-- source/blender/blenkernel/intern/text.c | 2 +- .../blender/blenkernel/intern/writeframeserver.c | 8 +++---- 11 files changed, 29 insertions(+), 29 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index b781b18862c..2469f7f7dbe 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -65,7 +65,7 @@ void tend ( void ) { gettimeofday ( &_tend,&tz ); } -double tval() +double tval(void) { double t1, t2; t1 = ( double ) _tstart.tv_sec + ( double ) _tstart.tv_usec/ ( 1000*1000 ); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index c1a6200bf60..f92f2326aeb 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3903,7 +3903,7 @@ static bConstraintTypeInfo *constraintsTypeInfo[NUM_CONSTRAINT_TYPES]; static short CTI_INIT= 1; /* when non-zero, the list needs to be updated */ /* This function only gets called when CTI_INIT is non-zero */ -static void constraints_init_typeinfo () { +static void constraints_init_typeinfo (void) { constraintsTypeInfo[0]= NULL; /* 'Null' Constraint */ constraintsTypeInfo[1]= &CTI_CHILDOF; /* ChildOf Constraint */ constraintsTypeInfo[2]= &CTI_TRACKTO; /* TrackTo Constraint */ diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 5ef41d17d63..1ed8241325e 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -932,7 +932,7 @@ static FModifierTypeInfo *fmodifiersTypeInfo[FMODIFIER_NUM_TYPES]; static short FMI_INIT= 1; /* when non-zero, the list needs to be updated */ /* This function only gets called when FMI_INIT is non-zero */ -static void fmods_init_typeinfo () +static void fmods_init_typeinfo (void) { fmodifiersTypeInfo[0]= NULL; /* 'Null' F-Curve Modifier */ fmodifiersTypeInfo[1]= &FMI_GENERATOR; /* Generator F-Curve Modifier */ diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 78306705d6b..30e4318e256 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -76,7 +76,7 @@ static void icon_free(void *val) /* create an id for a new icon and make sure that ids from deleted icons get reused after the integer number range is used up */ -static int get_next_free_id() +static int get_next_free_id(void) { int startId = gFirstIconId; diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index bdf71a8c6f0..3d6710b186d 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -85,7 +85,7 @@ static void itend(void) { gettimeofday(&_itend,&itz); } -double itval() +double itval(void) { double t1, t2; t1 = (double)_itstart.tv_sec + (double)_itstart.tv_usec/(1000*1000); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 8096f0277bb..ac61acac56a 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1402,7 +1402,7 @@ void paste_matcopybuf(Material *ma) MEM_freeN(ma->nodetree); } - GPU_materials_free(ma); + GPU_material_free(ma); id= (ma->id); memcpy(ma, &matcopybuf, sizeof(Material)); diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 2efef52ed3e..c11b51b9dd4 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -119,8 +119,8 @@ static struct ImBuf * prepare_effect_imbufs( static void open_plugin_seq(PluginSeq *pis, const char *seqname) { - int (*version)(); - void* (*alloc_private)(); + int (*version)(void); + void* (*alloc_private)(void); char *cp; /* to be sure: (is tested for) */ @@ -143,7 +143,7 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname) if (pis->handle != 0) { /* find the address of the version function */ - version= (int (*)())PIL_dynlib_find_symbol(pis->handle, "plugin_seq_getversion"); + version= (int (*)(void))PIL_dynlib_find_symbol(pis->handle, "plugin_seq_getversion"); if (test_dlerr(pis->name, "plugin_seq_getversion")) return; if (version != 0) { @@ -177,7 +177,7 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname) return; } } - alloc_private = (void* (*)())PIL_dynlib_find_symbol( + alloc_private = (void* (*)(void))PIL_dynlib_find_symbol( pis->handle, "plugin_seq_alloc_private_data"); if (alloc_private) { pis->instance_private_data = alloc_private(); @@ -246,7 +246,7 @@ static void init_plugin(Sequence * seq, const char * fname) /* * FIXME: should query plugin! Could be generator, that needs zero inputs... */ -static int num_inputs_plugin() +static int num_inputs_plugin(void) { return 1; } @@ -969,7 +969,7 @@ static void gamtabs(float gamma) } -static void build_gammatabs() +static void build_gammatabs(void) { if (gamma_tabs_init == FALSE) { gamtabs(2.0f); @@ -1860,7 +1860,7 @@ static void init_wipe_effect(Sequence *seq) seq->effectdata = MEM_callocN(sizeof(struct WipeVars), "wipevars"); } -static int num_inputs_wipe() +static int num_inputs_wipe(void) { return 1; } @@ -2044,7 +2044,7 @@ static void init_transform_effect(Sequence *seq) transform->uniform_scale=0; } -static int num_inputs_transform() +static int num_inputs_transform(void) { return 1; } @@ -2613,7 +2613,7 @@ static void init_glow_effect(Sequence *seq) glow->bNoComp = 0; } -static int num_inputs_glow() +static int num_inputs_glow(void) { return 1; } @@ -2700,7 +2700,7 @@ static void init_solid_color(Sequence *seq) cv->col[0] = cv->col[1] = cv->col[2] = 0.5; } -static int num_inputs_color() +static int num_inputs_color(void) { return 0; } @@ -2809,7 +2809,7 @@ static struct ImBuf * do_solid_color( ********************************************************************** */ /* no effect inputs for multicam, we use give_ibuf_seq */ -static int num_inputs_multicam() +static int num_inputs_multicam(void) { return 0; } @@ -2884,7 +2884,7 @@ static void load_speed_effect(Sequence * seq) v->length = 0; } -static int num_inputs_speed() +static int num_inputs_speed(void) { return 1; } @@ -3059,7 +3059,7 @@ static void free_noop(struct Sequence *UNUSED(seq)) } -static int num_inputs_default() +static int num_inputs_default(void) { return 2; } diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 978b3c9864f..ceee544d1b8 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1659,7 +1659,7 @@ static void *exec_scan_for_ext_spring_forces(void *data) return 0; } -static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,int totsprings,int *UNUSED(ptr_to_break_func())) +static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,int totsprings,int *UNUSED(ptr_to_break_func(void))) { ListBase *do_effector = NULL; ListBase threads; @@ -2175,7 +2175,7 @@ static void sb_spring_force(Object *ob,int bpi,BodySpring *bs,float iks,float UN /* since this is definitely the most CPU consuming task here .. try to spread it */ /* core function _softbody_calc_forces_slice_in_a_thread */ /* result is int to be able to flag user break */ -static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, float forcetime, float timenow,int ifirst,int ilast,int *UNUSED(ptr_to_break_func()),ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) +static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, float forcetime, float timenow,int ifirst,int ilast,int *UNUSED(ptr_to_break_func(void)),ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) { float iks; int bb,do_selfcollision,do_springcollision,do_aero; @@ -2386,7 +2386,7 @@ static void *exec_softbody_calc_forces(void *data) return 0; } -static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow,int totpoint,int *UNUSED(ptr_to_break_func()),struct ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) +static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow,int totpoint,int *UNUSED(ptr_to_break_func(void)),struct ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) { ListBase threads; SB_thread_context *sb_threads; diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c index 1b720c1adaa..7d39203cefc 100644 --- a/source/blender/blenkernel/intern/suggestions.c +++ b/source/blender/blenkernel/intern/suggestions.c @@ -54,7 +54,7 @@ static int txttl_cmp(const char *first, const char *second, int len) { return cmp; } -static void txttl_free_suggest() { +static void txttl_free_suggest(void) { SuggItem *item, *prev; for (item = suggestions.last; item; item=prev) { prev = item->prev; @@ -66,7 +66,7 @@ static void txttl_free_suggest() { suggestions.top = 0; } -static void txttl_free_docs() { +static void txttl_free_docs(void) { if (documentation) { MEM_freeN(documentation); documentation = NULL; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index bdb8d11945c..b78525d4f4e 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -93,7 +93,7 @@ TMARK_EDITALL is set the group ID defines which other markers should be edited. The mrk->clr field is used to visually group markers where the flags may not match. A template system, for example, may allow editing of repeating tokens (in one group) but include other marked positions (in another group) all in the -same template with the same colour. +same template with the same color. Undo -- diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index bbc441f3622..3bdfd6c6b74 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -77,16 +77,16 @@ static int select_was_interrupted_by_signal() return (WSAGetLastError() == WSAEINTR); } #else -static int startup_socket_system() +static int startup_socket_system(void) { return 1; } -static void shutdown_socket_system() +static void shutdown_socket_system(void) { } -static int select_was_interrupted_by_signal() +static int select_was_interrupted_by_signal(void) { return (errno == EINTR); } @@ -367,7 +367,7 @@ int append_frameserver(RenderData *UNUSED(rd), int frame, int *pixels, int rectx return 0; } -void end_frameserver() +void end_frameserver(void) { if (connsock != -1) { closesocket(connsock); -- cgit v1.2.3 From 8934b617394ae4508968e5676526c9c4427e7b06 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 3 Dec 2010 14:35:03 +0000 Subject: Fix #25017: Bezier Curve Deform Twisting after adding Shape Keys - Invalid step was used in curve_applyKeyVertexTilts - Minor cleanup in editcurve stuff --- source/blender/blenkernel/intern/curve.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 42d1c13c9ac..d5d13c9badd 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -3056,7 +3056,7 @@ void curve_applyKeyVertexTilts(Curve *UNUSED(cu), ListBase *lb, float *key) for(i=0; ipntsu; i++,bezt++) { key+=3*3; bezt->alfa= *key; - key++; + key+=3; } } else { -- cgit v1.2.3 From 7c86a1a95cbc643fdbbf8c28f0422face8a15a19 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Dec 2010 16:45:04 +0000 Subject: compile fixes for mingw32. --- source/blender/blenkernel/intern/cloth.c | 2 +- source/blender/blenkernel/intern/implicit.c | 2 +- source/blender/blenkernel/intern/smoke.c | 2 +- source/blender/blenkernel/intern/writeframeserver.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 2469f7f7dbe..7473ff6875a 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -49,7 +49,7 @@ void tstart ( void ) void tend ( void ) { } -double tval() +double tval( void ) { return 0; } diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 3d6710b186d..e19f36a2a0b 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -63,7 +63,7 @@ static void itend(void) { QueryPerformanceCounter(&_itend); } -double itval() +double itval(void) { return ((double)_itend.QuadPart - (double)_itstart.QuadPart)/((double)ifreq.QuadPart); diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index cca02dde25d..1833cc4eeac 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -94,7 +94,7 @@ static void tend ( void ) { QueryPerformanceCounter ( &liCurrentTime ); } -static double tval() +static double tval( void ) { return ((double)( (liCurrentTime.QuadPart - liStartTime.QuadPart)* (double)1000.0/(double)liFrequency.QuadPart )); } diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 3bdfd6c6b74..dd63c266491 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -62,17 +62,17 @@ static int render_height; #if defined(_WIN32) -static int startup_socket_system() +static int startup_socket_system(void) { WSADATA wsa; return (WSAStartup(MAKEWORD(2,0),&wsa) == 0); } -static void shutdown_socket_system() +static void shutdown_socket_system(void) { WSACleanup(); } -static int select_was_interrupted_by_signal() +static int select_was_interrupted_by_signal(void) { return (WSAGetLastError() == WSAEINTR); } -- cgit v1.2.3 From 263830f0004481cd4921f03f4242d7c80794b08d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Dec 2010 17:05:21 +0000 Subject: Enabled GCC -Wwrite-strings warning for CMake and replaced many 'char's for 'const char's,. Only one functional change where Transform orientations passed "" to BIF_createTransformOrientation() which could then have the value written into. --- source/blender/blenkernel/intern/BME_Customdata.c | 2 +- source/blender/blenkernel/intern/anim_sys.c | 10 ++++---- source/blender/blenkernel/intern/context.c | 4 +-- source/blender/blenkernel/intern/customdata.c | 6 ++--- source/blender/blenkernel/intern/depsgraph.c | 8 +++--- source/blender/blenkernel/intern/fcurve.c | 4 +-- source/blender/blenkernel/intern/gpencil.c | 2 +- source/blender/blenkernel/intern/idcode.c | 2 +- source/blender/blenkernel/intern/image.c | 2 +- source/blender/blenkernel/intern/ipo.c | 29 +++++++++++----------- source/blender/blenkernel/intern/library.c | 8 +++--- source/blender/blenkernel/intern/modifier.c | 2 +- source/blender/blenkernel/intern/node.c | 6 ++--- source/blender/blenkernel/intern/object.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 4 +-- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/property.c | 2 +- source/blender/blenkernel/intern/report.c | 14 ++++++----- source/blender/blenkernel/intern/seqcache.c | 10 ++++---- source/blender/blenkernel/intern/sequencer.c | 10 ++++---- source/blender/blenkernel/intern/text.c | 10 ++++---- source/blender/blenkernel/intern/writeffmpeg.c | 2 +- 22 files changed, 72 insertions(+), 69 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 1087b3a873c..b64efa811de 100644 --- a/source/blender/blenkernel/intern/BME_Customdata.c +++ b/source/blender/blenkernel/intern/BME_Customdata.c @@ -43,7 +43,7 @@ /********************* Layer type information **********************/ typedef struct BME_LayerTypeInfo { int size; - char *defaultname; + const char *defaultname; void (*copy)(const void *source, void *dest, int count); void (*free)(void *data, int count, int size); void (*interp)(void **sources, float *weights, float *sub_weights, int count, void *dest); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index ae683dab7b2..e48183ac479 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -294,7 +294,7 @@ static short check_rna_path_is_valid (ID *owner_id, char *path) /* Check if some given RNA Path needs fixing - free the given path and set a new one as appropriate * NOTE: we assume that oldName and newName have [" "] padding around them */ -static char *rna_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, char *oldpath, int verify_paths) +static char *rna_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, char *oldpath, int verify_paths) { char *prefixPtr= strstr(oldpath, prefix); char *oldNamePtr= strstr(oldpath, oldName); @@ -352,7 +352,7 @@ static char *rna_path_rename_fix (ID *owner_id, char *prefix, char *oldName, cha } /* Check RNA-Paths for a list of F-Curves */ -static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, ListBase *curves, int verify_paths) +static void fcurves_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, ListBase *curves, int verify_paths) { FCurve *fcu; @@ -365,7 +365,7 @@ static void fcurves_path_rename_fix (ID *owner_id, char *prefix, char *oldName, } /* Check RNA-Paths for a list of Drivers */ -static void drivers_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, char *oldKey, char *newKey, ListBase *curves, int verify_paths) +static void drivers_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, char *oldKey, char *newKey, ListBase *curves, int verify_paths) { FCurve *fcu; @@ -405,7 +405,7 @@ static void drivers_path_rename_fix (ID *owner_id, char *prefix, char *oldName, } /* Fix all RNA-Paths for Actions linked to NLA Strips */ -static void nlastrips_path_rename_fix (ID *owner_id, char *prefix, char *oldName, char *newName, ListBase *strips, int verify_paths) +static void nlastrips_path_rename_fix (ID *owner_id, const char *prefix, char *oldName, char *newName, ListBase *strips, int verify_paths) { NlaStrip *strip; @@ -425,7 +425,7 @@ static void nlastrips_path_rename_fix (ID *owner_id, char *prefix, char *oldName * NOTE: it is assumed that the structure we're replacing is <["><"]> * i.e. pose.bones["Bone"] */ -void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, char *prefix, char *oldName, char *newName, int oldSubscript, int newSubscript, int verify_paths) +void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, const char *prefix, char *oldName, char *newName, int oldSubscript, int newSubscript, int verify_paths) { NlaTrack *nlt; char *oldN, *newN; diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index fe010d812b1..96dbe727505 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -773,7 +773,7 @@ int CTX_data_mode_enum(const bContext *C) /* would prefer if we can use the enum version below over this one - Campbell */ /* must be aligned with above enum */ -static char *data_mode_strings[] = { +static const char *data_mode_strings[] = { "mesh_edit", "curve_edit", "surface_edit", @@ -790,7 +790,7 @@ static char *data_mode_strings[] = { "objectmode", 0 }; -char *CTX_data_mode_string(const bContext *C) +const char *CTX_data_mode_string(const bContext *C) { return data_mode_strings[CTX_data_mode_enum(C)]; } diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 1ef1cefa120..1a3d31bdcf8 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -60,9 +60,9 @@ /********************* Layer type information **********************/ typedef struct LayerTypeInfo { int size; /* the memory size of one element of this layer's data */ - char *structname; /* name of the struct used, for file writing */ + const char *structname; /* name of the struct used, for file writing */ int structnum; /* number of structs per element, for file writing */ - char *defaultname; /* default layer name */ + const char *defaultname; /* default layer name */ /* a function to copy count elements of this layer's data * (deep copy if appropriate) @@ -2212,7 +2212,7 @@ void CustomData_from_bmesh_block(const CustomData *source, CustomData *dest, } -void CustomData_file_write_info(int type, char **structname, int *structnum) +void CustomData_file_write_info(int type, const char **structname, int *structnum) { const LayerTypeInfo *typeInfo = layerType_getInfo(type); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index c4ee97c21c5..65a58b02377 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -846,7 +846,7 @@ DagNode * dag_get_sub_node (DagForest *forest,void * fob) return node; } -static void dag_add_parent_relation(DagForest *UNUSED(forest), DagNode *fob1, DagNode *fob2, short rel, char *name) +static void dag_add_parent_relation(DagForest *UNUSED(forest), DagNode *fob1, DagNode *fob2, short rel, const char *name) { DagAdjList *itA = fob2->parent; @@ -868,7 +868,7 @@ static void dag_add_parent_relation(DagForest *UNUSED(forest), DagNode *fob1, Da fob2->parent = itA; } -void dag_add_relation(DagForest *forest, DagNode *fob1, DagNode *fob2, short rel, char *name) +void dag_add_relation(DagForest *forest, DagNode *fob1, DagNode *fob2, short rel, const char *name) { DagAdjList *itA = fob1->child; @@ -893,7 +893,7 @@ void dag_add_relation(DagForest *forest, DagNode *fob1, DagNode *fob2, short rel fob1->child = itA; } -static char *dag_node_name(DagNode *node) +static const char *dag_node_name(DagNode *node) { if(node->ob == NULL) return "null"; @@ -938,7 +938,7 @@ static int dag_node_print_dependency_recurs(DagNode *node, DagNode *endnode) return 0; } -static void dag_node_print_dependency_cycle(DagForest *dag, DagNode *startnode, DagNode *endnode, char *name) +static void dag_node_print_dependency_cycle(DagForest *dag, DagNode *startnode, DagNode *endnode, const char *name) { DagNode *node; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 888eae3ed78..325e64bf768 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -166,7 +166,7 @@ void copy_fcurves (ListBase *dst, ListBase *src) /* ----------------- Finding F-Curves -------------------------- */ /* high level function to get an fcurve from C without having the rna */ -FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, char *prop_name, int index) +FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *prop_name, int index) { /* anim vars */ AnimData *adt= BKE_animdata_from_id(id); @@ -884,7 +884,7 @@ typedef struct DriverVarTypeInfo { /* allocation of target slots */ int num_targets; /* number of target slots required */ - char *target_names[MAX_DRIVER_TARGETS]; /* UI names that should be given to the slots */ + const char *target_names[MAX_DRIVER_TARGETS]; /* UI names that should be given to the slots */ int target_flags[MAX_DRIVER_TARGETS]; /* flags defining the requirements for each slot */ } DriverVarTypeInfo; diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 5612d69ed76..80f26277689 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -190,7 +190,7 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd) } /* add a new gp-datablock */ -bGPdata *gpencil_data_addnew (char name[]) +bGPdata *gpencil_data_addnew (const char name[]) { bGPdata *gpd; diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index 6411959e655..359603e9a50 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -35,7 +35,7 @@ typedef struct { unsigned short code; - char *name, *plural; + const char *name, *plural; int flags; #define IDTYPE_FLAGS_ISLINKABLE (1<<0) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index da1d59a0835..5c48569575e 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -766,7 +766,7 @@ int BKE_imtype_is_movie(int imtype) int BKE_add_image_extension(char *string, int imtype) { - char *extension= NULL; + const char *extension= NULL; if(imtype== R_IRIS) { if(!BLI_testextensie(string, ".rgb")) diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 5dc1cc2d746..7a32562d3d7 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -102,7 +102,7 @@ void free_ipo (Ipo *ipo) /* Mapping Table for bitflag <-> RNA path */ typedef struct AdrBit2Path { int bit; - char *path; + const char *path; int array_index; } AdrBit2Path; @@ -171,7 +171,7 @@ static AdrBit2Path *adrcode_bitmaps_to_paths (int blocktype, int adrcode, int *t /* ADRCODE to RNA-Path Conversion Code - Standard */ /* Object types */ -static char *ob_adrcodes_to_paths (int adrcode, int *array_index) +static const char *ob_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -252,7 +252,7 @@ static char *ob_adrcodes_to_paths (int adrcode, int *array_index) /* PoseChannel types * NOTE: pchan name comes from 'actname' added earlier... */ -static char *pchan_adrcodes_to_paths (int adrcode, int *array_index) +static const char *pchan_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -296,7 +296,7 @@ static char *pchan_adrcodes_to_paths (int adrcode, int *array_index) } /* Constraint types */ -static char *constraint_adrcodes_to_paths (int adrcode, int *array_index) +static const char *constraint_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -330,9 +330,9 @@ static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) } /* MTex (Texture Slot) types */ -static char *mtex_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) +static const char *mtex_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) { - char *base=NULL, *prop=NULL; + const char *base=NULL, *prop=NULL; static char buf[128]; /* base part of path */ @@ -400,7 +400,7 @@ static char *mtex_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) } /* Texture types */ -static char *texture_adrcodes_to_paths (int adrcode, int *array_index) +static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -480,7 +480,7 @@ static char *texture_adrcodes_to_paths (int adrcode, int *array_index) } /* Material Types */ -static char *material_adrcodes_to_paths (int adrcode, int *array_index) +static const char *material_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -564,7 +564,7 @@ static char *material_adrcodes_to_paths (int adrcode, int *array_index) } /* Camera Types */ -static char *camera_adrcodes_to_paths (int adrcode, int *array_index) +static const char *camera_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -604,7 +604,7 @@ static char *camera_adrcodes_to_paths (int adrcode, int *array_index) } /* Lamp Types */ -static char *lamp_adrcodes_to_paths (int adrcode, int *array_index) +static const char *lamp_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -646,7 +646,7 @@ static char *lamp_adrcodes_to_paths (int adrcode, int *array_index) } /* Sound Types */ -static char *sound_adrcodes_to_paths (int adrcode, int *array_index) +static const char *sound_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -669,7 +669,7 @@ static char *sound_adrcodes_to_paths (int adrcode, int *array_index) } /* World Types */ -static char *world_adrcodes_to_paths (int adrcode, int *array_index) +static const char *world_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -722,7 +722,7 @@ static char *world_adrcodes_to_paths (int adrcode, int *array_index) } /* Particle Types */ -static char *particle_adrcodes_to_paths (int adrcode, int *array_index) +static const char *particle_adrcodes_to_paths (int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ *array_index= 0; @@ -800,7 +800,8 @@ static char *particle_adrcodes_to_paths (int adrcode, int *array_index) static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence * seq, int *array_index) { DynStr *path= BLI_dynstr_new(); - char *propname=NULL, *rpath=NULL; + const char *propname=NULL; + char *rpath=NULL; char buf[512]; int dummy_index= 0; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 8ce89182a3a..8e1220dde24 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -852,7 +852,7 @@ void free_main(Main *mainvar) /* ***************** ID ************************ */ -ID *find_id(char *type, const char *name) /* type: "OB" or "MA" etc */ +ID *find_id(const char *type, const char *name) /* type: "OB" or "MA" etc */ { ListBase *lb= which_libbase(G.main, GS(type)); return BLI_findstring(lb, name, offsetof(ID, name) + 2); @@ -941,7 +941,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor /* used by headerbuttons.c buttons.c editobject.c editseq.c */ /* if nr==NULL no MAX_IDPUP, this for non-header browsing */ -void IDnames_to_pupstring(char **str, char *title, char *extraops, ListBase *lb, ID *link, short *nr) +void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr) { DynStr *pupds= BLI_dynstr_new(); @@ -963,7 +963,7 @@ void IDnames_to_pupstring(char **str, char *title, char *extraops, ListBase *lb, } /* skips viewer images */ -void IMAnames_to_pupstring(char **str, char *title, char *extraops, ListBase *lb, ID *link, short *nr) +void IMAnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr) { DynStr *pupds= BLI_dynstr_new(); @@ -1361,7 +1361,7 @@ void text_idbutton(struct ID *id, char *text) } } -void rename_id(ID *id, char *name) +void rename_id(ID *id, const char *name) { ListBase *lb; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index dc2992662c9..6381315a8ca 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -216,7 +216,7 @@ int modifier_sameTopology(ModifierData *md) return ( mti->type == eModifierTypeType_OnlyDeform || mti->type == eModifierTypeType_Nonconstructive); } -void modifier_setError(ModifierData *md, char *format, ...) +void modifier_setError(ModifierData *md, const char *format, ...) { char buffer[2048]; va_list ap; diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 7f6fcdbdf40..120e6466608 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3220,7 +3220,7 @@ static void remove_dynamic_typeinfos(ListBase *list) if(ntype->inputs) { bNodeSocketType *sock= ntype->inputs; while(sock->type!=-1) { - MEM_freeN(sock->name); + MEM_freeN((void *)sock->name); sock++; } MEM_freeN(ntype->inputs); @@ -3228,13 +3228,13 @@ static void remove_dynamic_typeinfos(ListBase *list) if(ntype->outputs) { bNodeSocketType *sock= ntype->outputs; while(sock->type!=-1) { - MEM_freeN(sock->name); + MEM_freeN((void *)sock->name); sock++; } MEM_freeN(ntype->outputs); } if(ntype->name) { - MEM_freeN(ntype->name); + MEM_freeN((void *)ntype->name); } MEM_freeN(ntype); } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index fe557dfefa0..5f2a10c0b3e 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -969,7 +969,7 @@ static void *add_obdata_from_type(int type) } } -static char *get_obdata_defname(int type) +static const char *get_obdata_defname(int type) { switch (type) { case OB_MESH: return "Mesh"; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index f4af518d137..4e393af1a1c 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3625,8 +3625,8 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) FluidsimSettings *fss= fluidmd->fss; ParticleSettings *part = psys->part; ParticleData *pa=0; - char *suffix = "fluidsurface_particles_####"; - char *suffix2 = ".gz"; + const char *suffix = "fluidsurface_particles_####"; + const char *suffix2 = ".gz"; char filename[256]; char debugStrBuffer[256]; int curFrame = sim->scene->r.cfra -1; // warning - sync with derived mesh fsmesh loading diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index fb0d04b7473..f7af3c68814 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1233,7 +1233,7 @@ static int ptcache_file_read_header_begin(PTCacheFile *pf) static int ptcache_file_write_header_begin(PTCacheFile *pf) { - char *bphysics = "BPHYSICS"; + const char *bphysics = "BPHYSICS"; if(fwrite(bphysics, sizeof(char), 8, pf->fp) != 8) return 0; diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index d8001572b4f..dd57fef50c5 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -179,7 +179,7 @@ void unique_property(bProperty *first, bProperty *prop, int force) } } -bProperty *get_ob_property(Object *ob, char *name) +bProperty *get_ob_property(Object *ob, const char *name) { return BLI_findstring(&ob->prop, name, offsetof(bProperty, name)); } diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index f69547fd1da..5df912c871d 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -44,7 +44,7 @@ #endif #endif -static char *report_type_str(int type) +static const char *report_type_str(int type) { switch(type) { case RPT_DEBUG: return "Debug"; @@ -82,7 +82,7 @@ void BKE_reports_clear(ReportList *reports) while (report) { report_next= report->next; - MEM_freeN(report->message); + MEM_freeN((void *)report->message); MEM_freeN(report); report= report_next; } @@ -105,13 +105,15 @@ void BKE_report(ReportList *reports, ReportType type, const char *message) } if(reports && (reports->flag & RPT_STORE) && (type >= reports->storelevel)) { + char *message_alloc; report= MEM_callocN(sizeof(Report), "Report"); report->type= type; report->typestr= report_type_str(type); len= strlen(message); - report->message= MEM_callocN(sizeof(char)*(len+1), "ReportMessage"); - memcpy(report->message, message, sizeof(char)*(len+1)); + message_alloc= MEM_callocN(sizeof(char)*(len+1), "ReportMessage"); + memcpy(message_alloc, message, sizeof(char)*(len+1)); + report->message= message_alloc; report->len= len; BLI_addtail(&reports->list, report); } @@ -163,7 +165,7 @@ void BKE_reports_prepend(ReportList *reports, const char *prepend) BLI_dynstr_append(ds, prepend); BLI_dynstr_append(ds, report->message); - MEM_freeN(report->message); + MEM_freeN((void *)report->message); report->message= BLI_dynstr_get_cstring(ds); report->len= BLI_dynstr_get_len(ds); @@ -188,7 +190,7 @@ void BKE_reports_prependf(ReportList *reports, const char *prepend, ...) va_end(args); BLI_dynstr_append(ds, report->message); - MEM_freeN(report->message); + MEM_freeN((void *)report->message); report->message= BLI_dynstr_get_cstring(ds); report->len= BLI_dynstr_get_len(ds); diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 73351edbdd5..b25c533ad4c 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -60,9 +60,9 @@ static struct BLI_mempool * keypool = 0; static int ibufs_in = 0; static int ibufs_rem = 0; -static unsigned int HashHash(void *key_) +static unsigned int HashHash(const void *key_) { - seqCacheKey * key = (seqCacheKey*) key_; + const seqCacheKey *key = (seqCacheKey*) key_; unsigned int rval = seq_hash_render_data(&key->context); rval ^= *(unsigned int*) &key->cfra; @@ -72,10 +72,10 @@ static unsigned int HashHash(void *key_) return rval; } -static int HashCmp(void *a_, void *b_) +static int HashCmp(const void *a_, const void *b_) { - seqCacheKey * a = (seqCacheKey*) a_; - seqCacheKey * b = (seqCacheKey*) b_; + const seqCacheKey * a = (seqCacheKey*) a_; + const seqCacheKey * b = (seqCacheKey*) b_; if (a->seq < b->seq) { return -1; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index f5842fbe72d..fac773b2c6f 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -263,7 +263,7 @@ SeqRenderData seq_new_render_data( return rval; } -int seq_cmp_render_data(SeqRenderData * a, SeqRenderData * b) +int seq_cmp_render_data(const SeqRenderData * a, const SeqRenderData * b) { if (a->preview_render_size < b->preview_render_size) { return -1; @@ -317,7 +317,7 @@ int seq_cmp_render_data(SeqRenderData * a, SeqRenderData * b) return 0; } -unsigned int seq_hash_render_data(SeqRenderData * a) +unsigned int seq_hash_render_data(const SeqRenderData * a) { unsigned int rval = a->rectx + a->recty; @@ -875,7 +875,7 @@ void seqbase_unique_name_recursive(ListBase *seqbasep, struct Sequence *seq) strcpy(seq->name+2, sui.name_dest); } -static char *give_seqname_by_type(int type) +static const char *give_seqname_by_type(int type) { switch(type) { case SEQ_META: return "Meta"; @@ -902,9 +902,9 @@ static char *give_seqname_by_type(int type) } } -char *give_seqname(Sequence *seq) +const char *give_seqname(Sequence *seq) { - char * name = give_seqname_by_type(seq->type); + const char *name = give_seqname_by_type(seq->type); if (!name) { if(seq->typeformat= NULL; } -static TextLine *txt_new_line(char *str) +static TextLine *txt_new_line(const char *str) { TextLine *tmp; @@ -1431,7 +1431,7 @@ void txt_print_undo(Text *text) { int i= 0; int op; - char *ops; + const char *ops; int linep, charp; dump_buffer(text); @@ -2470,7 +2470,7 @@ void indent(Text *text) int len, num; char *tmp; - char *add = "\t"; + const char *add = "\t"; int indentlen = 1; /* hardcoded: TXT_TABSIZE = 4 spaces: */ @@ -2531,7 +2531,7 @@ void indent(Text *text) void unindent(Text *text) { int num = 0; - char *remove = "\t"; + const char *remove = "\t"; int indent = 1; /* hardcoded: TXT_TABSIZE = 4 spaces: */ @@ -2694,7 +2694,7 @@ int setcurr_tab_spaces (Text *text, int space) const char *word = ":"; const char *comm = "#"; const char indent= (text->flags & TXT_TABSTOSPACES) ? ' ' : '\t'; - static char *back_words[]= {"return", "break", "continue", "pass", "yield", NULL}; + static const char *back_words[]= {"return", "break", "continue", "pass", "yield", NULL}; if (!text) return 0; if (!text->curl) return 0; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 0ec38a035aa..bb00e6de5ce 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -69,7 +69,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -extern void do_init_ffmpeg(); +extern void do_init_ffmpeg(void); static int ffmpeg_type = 0; static int ffmpeg_codec = CODEC_ID_MPEG4; -- cgit v1.2.3 From 990b487c730ac192405682fa45232f6542cdd14c Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 3 Dec 2010 17:31:34 +0000 Subject: Bugfix #25026 Nurbs edit: 'switch order' crashed when order was higher than amount of points. --- source/blender/blenkernel/intern/curve.c | 63 +++++++++++++++++--------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index d5d13c9badd..9be64e27d20 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2906,38 +2906,41 @@ void switchdirectionNurb(Nurb *nu) bp2--; } if(nu->type == CU_NURBS) { - /* inverse knots */ - a= KNOTSU(nu); - fp1= nu->knotsu; - fp2= fp1+(a-1); - a/= 2; - while(fp1!=fp2 && a>0) { - SWAP(float, *fp1, *fp2); - a--; - fp1++; - fp2--; - } - /* and make in increasing order again */ - a= KNOTSU(nu); - fp1= nu->knotsu; - fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect"); - while(a--) { - fp2[0]= fabs(fp1[1]-fp1[0]); - fp1++; - fp2++; - } - - a= KNOTSU(nu)-1; - fp1= nu->knotsu; - fp2= tempf; - fp1[0]= 0.0; - fp1++; - while(a--) { - fp1[0]= fp1[-1]+fp2[0]; + /* no knots for too short paths */ + if(nu->knotsu) { + /* inverse knots */ + a= KNOTSU(nu); + fp1= nu->knotsu; + fp2= fp1+(a-1); + a/= 2; + while(fp1!=fp2 && a>0) { + SWAP(float, *fp1, *fp2); + a--; + fp1++; + fp2--; + } + /* and make in increasing order again */ + a= KNOTSU(nu); + fp1= nu->knotsu; + fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect"); + while(a--) { + fp2[0]= fabs(fp1[1]-fp1[0]); + fp1++; + fp2++; + } + + a= KNOTSU(nu)-1; + fp1= nu->knotsu; + fp2= tempf; + fp1[0]= 0.0; fp1++; - fp2++; + while(a--) { + fp1[0]= fp1[-1]+fp2[0]; + fp1++; + fp2++; + } + MEM_freeN(tempf); } - MEM_freeN(tempf); } } else { -- cgit v1.2.3 From fa4bbbb249bf9706e9c71d34748fbde87fa385fb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 4 Dec 2010 13:00:28 +0000 Subject: Maintenance, - remove some redundant declarations - changed VertexTangent and Path structs to avoid compiler alignment padding. --- source/blender/blenkernel/intern/colortools.c | 2 +- source/blender/blenkernel/intern/node.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 1be1b9b9ad0..1b3d100c3f8 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -43,7 +43,7 @@ #include "BKE_colortools.h" #include "BKE_curve.h" -#include "BKE_ipo.h" +#include "BKE_fcurve.h" #include "BKE_utildefines.h" #include "BLI_blenlib.h" diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 120e6466608..8db64e190a2 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1972,7 +1972,6 @@ static void composit_begin_exec(bNodeTree *ntree, int is_group) /* copy stack compbufs to sockets */ static void composit_end_exec(bNodeTree *ntree, int is_group) { - extern void print_compbuf(char *str, struct CompBuf *cbuf); bNode *node; bNodeStack *ns; int a; -- cgit v1.2.3 From 8c467a9c8a0a305182874f7acbaf0d29d82948e6 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 5 Dec 2010 01:48:49 +0000 Subject: Fix for [#25036] boids particle from 2.49 opened in 2.5 is crash !? * Old boids didn't have all of the necessary data for the new system. * Changed the particles code so that a check for all necessary data is always done before starting actual dynamics calculations. --- source/blender/blenkernel/intern/particle_system.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (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 4e393af1a1c..931339d90b4 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3964,7 +3964,7 @@ static void fluid_default_settings(ParticleSettings *part){ fluid->buoyancy = 0.f; } -static void psys_changed_physics(ParticleSimulationData *sim) +static void psys_prepare_physics(ParticleSimulationData *sim) { ParticleSettings *part = sim->psys->part; @@ -4047,8 +4047,9 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if(psys->recalc & PSYS_RECALC_TYPE) psys_changed_type(&sim); - else if(psys->recalc & PSYS_RECALC_PHYS) - psys_changed_physics(&sim); + + /* setup necessary physics type dependent additional data if it doesn't yet exist */ + psys_prepare_physics(&sim); switch(part->type) { case PART_HAIR: -- cgit v1.2.3 From b110c7c8f2c5fafa6412e01d21d751a884bfe8b2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 5 Dec 2010 18:59:23 +0000 Subject: Dependency graph: changed DAG_id_flush_update to DAG_id_tag_update. Now it only tags the ID and does the actual flush/update delayed, before the next redraw. For objects the update was already delayed, just flushing wasn't yet. This should help performance in python and animation editors, by making calls to RNA property update quicker. Still need to add calls in a few places where this was previously avoided due to bad performance. --- source/blender/blenkernel/intern/depsgraph.c | 163 +++++++++++++------------- source/blender/blenkernel/intern/mesh.c | 4 - source/blender/blenkernel/intern/particle.c | 4 +- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/scene.c | 2 + source/blender/blenkernel/intern/text.c | 2 +- 6 files changed, 88 insertions(+), 89 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 65a58b02377..97a27405db3 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -52,6 +52,7 @@ #include "BKE_global.h" #include "BKE_group.h" #include "BKE_key.h" +#include "BKE_library.h" #include "BKE_main.h" #include "BKE_mball.h" #include "BKE_modifier.h" @@ -2290,26 +2291,21 @@ static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUS } } -void DAG_id_flush_update(ID *id, short flag) +static void dag_id_flush_update(Scene *sce, ID *id) { Main *bmain= G.main; - Scene *sce; Object *obt, *ob= NULL; short idtype; - unsigned int lay; - dag_current_scene_layers(bmain, &sce, &lay); - - if(!id || !sce || !sce->theDag) - return; + /* here we flush a few things before actual scene wide flush, mostly + due to only objects and not other datablocks being in the depsgraph */ /* set flags & pointcache for object */ if(GS(id->name) == ID_OB) { ob= (Object*)id; - ob->recalc |= (flag & OB_RECALC_ALL); BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH); - if(flag & OB_RECALC_DATA) { + if(ob->recalc & OB_RECALC_DATA) { /* all users of this ob->data should be checked */ id= ob->data; @@ -2374,23 +2370,90 @@ void DAG_id_flush_update(ID *id, short flag) /* set flags based on particle settings */ if(idtype == ID_PA) { ParticleSystem *psys; - for(obt=bmain->object.first; obt; obt= obt->id.next) { - for(psys=obt->particlesystem.first; psys; psys=psys->next) { - if(&psys->part->id == id) { + for(obt=bmain->object.first; obt; obt= obt->id.next) + for(psys=obt->particlesystem.first; psys; psys=psys->next) + if(&psys->part->id == id) BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); - obt->recalc |= (flag & OB_RECALC_ALL); - psys->recalc |= (flag & PSYS_RECALC); - } - } - } } /* update editors */ dag_editors_update(bmain, id); } +} + +void DAG_ids_flush_tagged(Main *bmain) +{ + ListBase *lbarray[MAX_LIBARRAY]; + Scene *sce; + unsigned int lay; + int a, have_tag = 0; + + dag_current_scene_layers(bmain, &sce, &lay); + + if(!sce || !sce->theDag) + return; + + /* loop over all ID types */ + a = set_listbasepointers(bmain, lbarray); + + while(a--) { + ListBase *lb = lbarray[a]; + ID *id = lb->first; + + /* we tag based on first ID type character to avoid + looping over all ID's in case there are no tags */ + if(id && bmain->id_tag_update[id->name[0]]) { + for(; id; id=id->next) { + if(id->flag & LIB_ID_RECALC) { + dag_id_flush_update(sce, id); + id->flag &= ~LIB_ID_RECALC; + } + } + + have_tag = 1; + } + } - /* flush to other objects that depend on this one */ - DAG_scene_flush_update(bmain, sce, lay, 0); + if(have_tag) { + /* clear tags */ + memset(bmain->id_tag_update, 0, sizeof(bmain->id_tag_update)); + + /* flush changes to other objects */ + DAG_scene_flush_update(bmain, sce, lay, 0); + } +} + +void DAG_id_tag_update(ID *id, short flag) +{ + Main *bmain= G.main; + + /* tag ID for update */ + id->flag |= LIB_ID_RECALC; + bmain->id_tag_update[id->name[0]] = 1; + + /* flag is for objects and particle systems */ + if(flag) { + Object *ob; + ParticleSystem *psys; + short idtype = GS(id->name); + + if(idtype == ID_OB) { + /* only quick tag */ + ob = (Object*)id; + ob->recalc |= (flag & OB_RECALC_ALL); + } + else if(idtype == ID_PA) { + /* this is weak still, should be done delayed as well */ + for(ob=bmain->object.first; ob; ob=ob->id.next) { + for(psys=ob->particlesystem.first; psys; psys=psys->next) { + if(&psys->part->id == id) { + ob->recalc |= (flag & OB_RECALC_ALL); + psys->recalc |= (flag & PSYS_RECALC); + } + } + } + } + } } /* recursively descends tree, each node only checked once */ @@ -2423,68 +2486,6 @@ static int parent_check_node(DagNode *node, int curtime) return DAG_WHITE; } -/* all nodes that influence this object get tagged, for calculating the exact - position of this object at a given timeframe */ -void DAG_id_update_flags(ID *id) -{ - Main *bmain= G.main; - Scene *sce; - DagNode *node; - DagAdjList *itA; - Object *ob; - unsigned int lay; - - dag_current_scene_layers(bmain, &sce, &lay); - - if(!id || !sce || !sce->theDag) - return; - - /* objects only currently */ - if(GS(id->name) != ID_OB) - return; - - ob= (Object*)id; - - /* tag nodes unchecked */ - for(node = sce->theDag->DagNode.first; node; node= node->next) - node->color = DAG_WHITE; - - node= dag_find_node(sce->theDag, ob); - - /* object not in scene? then handle group exception. needs to be dagged once too */ - if(node==NULL) { - Group *group= NULL; - while( (group = find_group(ob, group)) ) { - GroupObject *go; - /* primitive; tag all... this call helps building groups for particles */ - for(go= group->gobject.first; go; go= go->next) - go->ob->recalc= OB_RECALC_ALL; - } - } - else { - - node->color = DAG_GRAY; - - sce->theDag->time++; - node= sce->theDag->DagNode.first; - for(itA = node->child; itA; itA= itA->next) { - if(itA->node->type==ID_OB && itA->node->lasttime!=sce->theDag->time) - itA->node->color= parent_check_node(itA->node, sce->theDag->time); - } - - /* set recalcs and flushes */ - 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) { - if(node->type==ID_OB && node->color==DAG_WHITE) { - Object *ob= node->ob; - ob->recalc= 0; - } - } - } -} - /* ******************* DAG FOR ARMATURE POSE ***************** */ /* we assume its an armature with pose */ diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index eb413187544..7a72207ff69 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1222,8 +1222,6 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) mf->flag &= ~ME_SMOOTH; } } - -// XXX do this in caller DAG_id_flush_update(&me->id, OB_RECALC_DATA); } void mesh_calc_normals(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float **faceNors_r) @@ -1483,8 +1481,6 @@ void mesh_pmv_revert(Mesh *me) me->pv->edge_map= NULL; MEM_freeN(me->pv->vert_map); me->pv->vert_map= NULL; - -// XXX do this in caller DAG_id_flush_update(&me->id, OB_RECALC_DATA); } } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 9c2efe395dc..6fec4775769 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3425,7 +3425,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->cfra=bsystem_time(scene,ob,scene->r.cfra+1,0.0); DAG_scene_sort(G.main, scene); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); return md; } @@ -3462,7 +3462,7 @@ void object_remove_particle_system(Scene *scene, Object *ob) ob->mode &= ~OB_MODE_PARTICLE_EDIT; DAG_scene_sort(G.main, scene); - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_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 f7af3c68814..cd45a39f2c9 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2313,7 +2313,7 @@ void BKE_ptcache_set_continue_physics(Main *bmain, Scene *scene, int enable) if(CONTINUE_PHYSICS == 0) { 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); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } } } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index edbace71c6d..9bbadbacb37 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -968,6 +968,8 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen /* this is called in main loop, doing tagged updates before redraw */ void scene_update_tagged(Main *bmain, Scene *scene) { + DAG_ids_flush_tagged(bmain); + scene->physics_settings.quick_cache_step= 0; /* update all objects: drivers, matrices, displists, etc. flags set diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index f6833596883..6e0289e907b 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -521,7 +521,7 @@ void unlink_text(Main *bmain, Text *text) } if(update) - DAG_id_flush_update(&ob->id, OB_RECALC_DATA); + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } /* pynodes */ -- cgit v1.2.3 From 9668c29ba00ed830109665ea132b6292cdfe9e2a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 5 Dec 2010 23:14:48 +0000 Subject: bpath iterator updates - loop over sequencer plugin and texture voxel paths. - fix leak in python bpy.utils.blend_path() and use PyUnicode_DecodeFSDefault() to ensure correct paths with different encodings. - operators to make paths absolute & relative now redraw the view. --- source/blender/blenkernel/intern/depsgraph.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 97a27405db3..fe6b320d0bd 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2456,6 +2456,7 @@ void DAG_id_tag_update(ID *id, short flag) } } +#if 0 // UNUSED /* recursively descends tree, each node only checked once */ /* node is checked to be of type object */ static int parent_check_node(DagNode *node, int curtime) @@ -2485,6 +2486,7 @@ static int parent_check_node(DagNode *node, int curtime) return DAG_WHITE; } +#endif /* ******************* DAG FOR ARMATURE POSE ***************** */ -- cgit v1.2.3 From 2f366d1544ecc5618d7190b779ccc75f2f144d0a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 5 Dec 2010 23:50:55 +0000 Subject: use BLI_strnlen rather then strlen when comparing against fixed lengths. --- source/blender/blenkernel/intern/exotic.c | 12 ++++++------ source/blender/blenkernel/intern/ipo.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index c16d566c7c5..51fd5e1e4c6 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -1171,10 +1171,10 @@ static void dxf_get_mesh(Scene *scene, Mesh** m, Object** o, int noob) *o = add_object(scene, OB_MESH); ob = *o; - if (strlen(entname)) new_id(&G.main->object, (ID *)ob, entname); - else if (strlen(layname)) new_id(&G.main->object, (ID *)ob, layname); + if (entname[0]) new_id(&G.main->object, (ID *)ob, entname); + else if (layname[0]) new_id(&G.main->object, (ID *)ob, layname); - if (strlen(layname)) ob->lay= dxf_get_layer_num(scene, layname); + if (layname[0]) ob->lay= dxf_get_layer_num(scene, layname); else ob->lay= scene->lay; // not nice i know... but add_object() sets active base, which needs layer setting too (ton) scene->basact->lay= ob->lay; @@ -1193,8 +1193,8 @@ static void dxf_get_mesh(Scene *scene, Mesh** m, Object** o, int noob) ((ID *)me)->us=0; - if (strlen(entname)) new_id(&G.main->mesh, (ID *)me, entname); - else if (strlen(layname)) new_id(&G.main->mesh, (ID *)me, layname); + if (entname[0]) new_id(&G.main->mesh, (ID *)me, entname); + else if (layname[0]) new_id(&G.main->mesh, (ID *)me, layname); vcenter = zerovec; } @@ -2395,7 +2395,7 @@ static void dxf_read(Scene *scene, const char *filename) I leave it commented out here as warning (ton) */ //for (i=0; itotcol; i++) ob->mat[i]= ((Mesh*)ob->data)->mat[i]; - if (strlen(layname)) ob->lay= dxf_get_layer_num(scene, layname); + if (layname[0]) ob->lay= dxf_get_layer_num(scene, layname); else ob->lay= scene->lay; /* link to scene */ diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 7a32562d3d7..5be8bda4cd9 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1197,7 +1197,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * fcurve= fcu; /* set path */ - fcurve->rna_path= BLI_strdupn(abp->path, strlen(abp->path)); + fcurve->rna_path= BLI_strdup(abp->path); fcurve->array_index= abp->array_index; /* convert keyframes -- cgit v1.2.3 From 60063d538389d4ad2e4a268da2ba058baf768807 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 6 Dec 2010 00:52:30 +0000 Subject: - converted path cleaning on file load to use bPath Iterator functions - image & font and sequence paths were being cleaned but not multires, voxel & sound paths. - skip fixing file paths on undo. - simplify bpath alloc and free functions, also pass Main structure so as not to rely on G.main, (needed for file load). --- source/blender/blenkernel/intern/blender.c | 61 ++++++++++++------------------ 1 file changed, 24 insertions(+), 37 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 6911e7fd581..6ceb75f2f83 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -55,6 +55,7 @@ #include "DNA_sound_types.h" #include "BLI_blenlib.h" +#include "BLI_bpath.h" #include "BLI_dynstr.h" #include "BLI_path_util.h" @@ -154,49 +155,32 @@ static void clear_global(void) /* make sure path names are correct for OS */ static void clean_paths(Main *main) { - Image *image= main->image.first; - bSound *sound= main->sound.first; - Scene *scene= main->scene.first; - Editing *ed; - Sequence *seq; - Strip *strip; - - while(image) { - BLI_clean(image->name); - image= image->id.next; - } - - while(sound) { - BLI_clean(sound->name); - sound= sound->id.next; + struct BPathIterator *bpi; + char filepath_expanded[1024]; + Scene *scene; + + for(BLI_bpathIterator_init(&bpi, main, main->name); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) { + BLI_bpathIterator_getPath(bpi, filepath_expanded); + + BLI_clean(filepath_expanded); + + BLI_bpathIterator_setPath(bpi, filepath_expanded); } - - while(scene) { - ed= seq_give_editing(scene, 0); - if(ed) { - seq= ed->seqbasep->first; - while(seq) { - if(seq->plugin) { - BLI_clean(seq->plugin->name); - } - strip= seq->strip; - while(strip) { - BLI_clean(strip->dir); - strip= strip->next; - } - seq= seq->next; - } - } + + BLI_bpathIterator_free(bpi); + + for(scene= main->scene.first; scene; scene= scene->id.next) { BLI_clean(scene->r.backbuf); BLI_clean(scene->r.pic); - - scene= scene->id.next; } } /* context matching */ /* handle no-ui case */ +/* note, this is called on Undo so any slow conversion functions here + * should be avoided or check (mode!='u') */ + static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename) { bScreen *curscreen= NULL; @@ -210,9 +194,12 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename else mode= 0; recover= (G.fileflags & G_FILE_RECOVER); - - clean_paths(bfd->main); - + + /* Only make filepaths compatible when loading for real (not undo) */ + if(mode != 'u') { + clean_paths(bfd->main); + } + /* XXX here the complex windowmanager matching */ /* no load screens? */ -- cgit v1.2.3 From a724918cf3997cbd1fc33c663d1a76441c2deeb0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 6 Dec 2010 02:32:16 +0000 Subject: bugfix [#22663] object material slots not updated for library data --- source/blender/blenkernel/intern/material.c | 82 ++++++++++++----------------- 1 file changed, 34 insertions(+), 48 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index ac61acac56a..90017ba3d5b 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -590,67 +590,53 @@ Material *give_node_material(Material *ma) /* from misc_util: flip the bytes from x */ /* #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */ -void test_object_materials(ID *id) +void resize_object_material(Object *ob, const short totcol) { - /* make the ob mat-array same size as 'ob->data' mat-array */ - Object *ob; - Mesh *me; - Curve *cu; - MetaBall *mb; Material **newmatar; char *newmatbits; - int totcol=0; - if(id==0) return; - - if( GS(id->name)==ID_ME ) { - me= (Mesh *)id; - totcol= me->totcol; + if(totcol==0) { + if(ob->totcol) { + MEM_freeN(ob->mat); + MEM_freeN(ob->matbits); + ob->mat= NULL; + ob->matbits= NULL; + } } - else if( GS(id->name)==ID_CU ) { - cu= (Curve *)id; - totcol= cu->totcol; + else if(ob->totcoltotcol) { + memcpy(newmatar, ob->mat, sizeof(void *)*ob->totcol); + memcpy(newmatbits, ob->matbits, sizeof(char)*ob->totcol); + MEM_freeN(ob->mat); + MEM_freeN(ob->matbits); + } + ob->mat= newmatar; + ob->matbits= newmatbits; } - else if( GS(id->name)==ID_MB ) { - mb= (MetaBall *)id; - totcol= mb->totcol; + ob->totcol= totcol; + if(ob->totcol && ob->actcol==0) ob->actcol= 1; + if(ob->actcol>ob->totcol) ob->actcol= ob->totcol; +} + +void test_object_materials(ID *id) +{ + /* make the ob mat-array same size as 'ob->data' mat-array */ + Object *ob; + short *totcol; + + if(id || (totcol=give_totcolp_id(id))==NULL) { + return; } - else return; - ob= G.main->object.first; - while(ob) { - + for(ob= G.main->object.first; ob; ob= ob->id.next) { if(ob->data==id) { - - if(totcol==0) { - if(ob->totcol) { - MEM_freeN(ob->mat); - MEM_freeN(ob->matbits); - ob->mat= NULL; - ob->matbits= NULL; - } - } - else if(ob->totcoltotcol) { - memcpy(newmatar, ob->mat, sizeof(void *)*ob->totcol); - memcpy(newmatbits, ob->matbits, sizeof(char)*ob->totcol); - MEM_freeN(ob->mat); - MEM_freeN(ob->matbits); - } - ob->mat= newmatar; - ob->matbits= newmatbits; - } - ob->totcol= totcol; - if(ob->totcol && ob->actcol==0) ob->actcol= 1; - if(ob->actcol>ob->totcol) ob->actcol= ob->totcol; + resize_object_material(ob, *totcol); } - ob= ob->id.next; } } - void assign_material(Object *ob, Material *ma, int act) { Material *mao, **matar, ***matarar; -- cgit v1.2.3 From 2c7a2a6a419f5d73baa958238f64a91d51ee7fae Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 6 Dec 2010 17:41:12 +0000 Subject: Sync fix with render branch. Solves crash with ob->bb not found. --- source/blender/blenkernel/intern/displist.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 979bd13a35d..a6957d6ead1 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1203,6 +1203,8 @@ void makeDispListMBall(Scene *scene, Object *ob) void makeDispListMBall_forRender(Scene *scene, Object *ob, ListBase *dispbase) { metaball_polygonize(scene, ob, dispbase); + tex_space_mball(ob); + object_deform_mball(ob, dispbase); } -- cgit v1.2.3 From 48614fbc2af024d613845b03d632e544f8127261 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Dec 2010 01:56:32 +0000 Subject: Added an assert() check for normalized quats which exposed a number of bugs where normalized quat was incorrectly assumed. This would have made bug #25003 very simple to find. - Objects had their quats normalized when calculating their matrix, this is inconstant with pose bones and isn't useful for animation. Also it wasn't normalizing the delta rotation so these would give bad rotations. - Converting between rotation modes BKE_rotMode_change_values() assumed normal length quat. changing quat to euler rotation for eg could change the bone. - Clear rotation and transform were not normalizing the quat when 4d loc was disabled on quat rotation, corrected and also made it so the quat scale is restored after conversion so animations curves dont jump. There is 1 case in mat3_to_quat_is_ok() where quat_to_mat3 on an unnormalized quat is needed, for this I had to add an ugly static function quat_to_mat3_no_assert(), but overall its worthwhile IMHO to be able to find incorrect use of rotation conversion. --- source/blender/blenkernel/intern/anim.c | 14 +++++++++----- source/blender/blenkernel/intern/armature.c | 5 +++-- source/blender/blenkernel/intern/object.c | 14 +++++++++----- 3 files changed, 21 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index b58bd8c7f3e..b479bd5ef28 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1339,12 +1339,16 @@ static void new_particle_duplilist(ListBase *lb, ID *UNUSED(id), Scene *scene, O else { /* first key */ state.time = ctime; - if(psys_get_particle_state(&sim, a, &state, 0) == 0) + if(psys_get_particle_state(&sim, a, &state, 0) == 0) { continue; - - quat_to_mat4( pamat,state.rot); - VECCOPY(pamat[3], state.co); - pamat[3][3]= 1.0f; + } + else { + float tquat[4]; + normalize_qt_qt(tquat, state.rot); + quat_to_mat4(pamat, tquat); + copy_v3_v3(pamat[3], state.co); + pamat[3][3]= 1.0f; + } } if(part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) { diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b4bdb516ab3..0d1d08af44c 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1248,6 +1248,7 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa } else if (oldMode == ROT_MODE_QUAT) { /* quat to euler */ + normalize_qt(quat); quat_to_eulO( eul, newMode,quat); } /* else { no conversion needed } */ @@ -1270,6 +1271,7 @@ void BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], floa } else if (oldMode == ROT_MODE_QUAT) { /* quat to axis angle */ + normalize_qt(quat); quat_to_axis_angle( axis, angle,quat); } @@ -2092,8 +2094,7 @@ void pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4]) * but if this proves to be too problematic, switch back to the old system of operating directly on * the stored copy */ - QUATCOPY(quat, pchan->quat); - normalize_qt(quat); + normalize_qt_qt(quat, pchan->quat); quat_to_mat3(rmat, quat); } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 5f2a10c0b3e..b98927db877 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1668,9 +1668,13 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) } else { /* quats are normalised before use to eliminate scaling issues */ - normalize_qt(ob->quat); - quat_to_mat3( rmat,ob->quat); - quat_to_mat3( dmat,ob->dquat); + float tquat[4]; + + normalize_qt_qt(tquat, ob->quat); + quat_to_mat3(rmat, tquat); + + normalize_qt_qt(tquat, ob->quat); + quat_to_mat3(dmat, tquat); } /* combine these rotations */ @@ -1818,8 +1822,8 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) #else quat_apply_track(quat, ob->trackflag, ob->upflag); #endif - - quat_to_mat4(mat,quat); + normalize_qt(quat); + quat_to_mat4(mat, quat); } if(cu->flag & CU_PATH_RADIUS) { -- cgit v1.2.3 From d624d1cbddf9ee51108e7eb89a6cfd7044fd57c0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Dec 2010 04:12:15 +0000 Subject: pass along the context to extension functions, this was already being done in all cases except for the render engine. this allows python to NULL its internal context while scripts are not running. --- source/blender/blenkernel/intern/context.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 96dbe727505..9740c969ec7 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -179,7 +179,7 @@ void CTX_py_init_set(bContext *C, int value) C->data.py_init= value; } -void *CTX_py_dict_get(bContext *C) +void *CTX_py_dict_get(const bContext *C) { return C->data.py_context; } -- cgit v1.2.3 From 1e57d8c4e7c37b09b761a538d408056f512afd0b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Dec 2010 05:39:14 +0000 Subject: bugfix [#25073] Rendered image goes dim when saved from python batch script --- source/blender/blenkernel/intern/image.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 5c48569575e..6cd0c89157a 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1983,6 +1983,9 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ibuf->flags &= ~IB_zbuffloat; } + /* since its possible to access the buffer from the image directly, set the profile [#25073] */ + ibuf->profile= (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_NONE; + ibuf->dither= dither; ima->ok= IMA_OK_LOADED; -- cgit v1.2.3 From 46990b49045d52278cdc082b9ef577ffcee5619f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 7 Dec 2010 08:52:12 +0000 Subject: fix for own mistake, reported [#25076] Creating new empty crashes Blender --- source/blender/blenkernel/intern/material.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 90017ba3d5b..2af7fc3b70a 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -626,7 +626,7 @@ void test_object_materials(ID *id) Object *ob; short *totcol; - if(id || (totcol=give_totcolp_id(id))==NULL) { + if(id==NULL || (totcol=give_totcolp_id(id))==NULL) { return; } -- cgit v1.2.3 From d3f9b0d05ad6faffd440bab6efc0345cc0f5d32c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 7 Dec 2010 10:15:09 +0000 Subject: Bugfix #25049: Compositing Nodes not Keyframable An error seems to have been introduced to the node-tree building at some point, which means that the ID-type for data-attached node trees was incorrect (i.e. scene->nodetree->id.name = NTREE_COMPOSIT instead of ID_NT). This in turn meant that the ID AnimData availability poll would fail, as the ID-type could not be determined. --- source/blender/blenkernel/intern/node.c | 2 +- 1 file changed, 1 insertion(+), 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 8db64e190a2..4b158f4b405 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1045,7 +1045,7 @@ bNodeTree *ntreeAddTree(const char *name, int type, const short is_group) ntree= alloc_libblock(&G.main->nodetree, ID_NT, name); else { ntree= MEM_callocN(sizeof(bNodeTree), "new node tree"); - *( (short *)ntree->id.name )= type; + *( (short *)ntree->id.name )= ID_NT; /* not "type", as that is ntree->type */ BLI_strncpy(ntree->id.name+2, name, sizeof(ntree->id.name)); } -- cgit v1.2.3 From 1a8665ac4551913e25138109ad10196c2958b6d3 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 7 Dec 2010 22:17:58 +0000 Subject: Fix for [#25079] Duplicating object with particles system on it make Blender crashs * pointcache->cached_frames wasn't set to NULL when copying pointcaches * also set pointcache->edit to null just in case --- source/blender/blenkernel/intern/pointcache.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index cd45a39f2c9..4e804cf14f7 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2380,6 +2380,8 @@ static PointCache *ptcache_copy(PointCache *cache) /* hmm, should these be copied over instead? */ ncache->mem_cache.first = NULL; ncache->mem_cache.last = NULL; + ncache->cached_frames = NULL; + ncache->edit = NULL; ncache->flag= 0; ncache->simframe= 0; -- cgit v1.2.3 From 40af167b0986edb02a5c151dfe785e8ab0aa6548 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 8 Dec 2010 11:02:56 +0000 Subject: Bug fix: normal (from particles) child particles didn't use the rough parameters properly * Also child particles didn't do particle trail properly. --- source/blender/blenkernel/intern/particle.c | 57 ++++++++++++++++++--------- source/blender/blenkernel/intern/pointcache.c | 10 ++++- 2 files changed, 48 insertions(+), 19 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 6fec4775769..374d5a20b1c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3904,26 +3904,38 @@ static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *pte int i = cpa - sim->psys->child; int guided = 0; + float kink_freq = part->kink_freq; + float rough1 = part->rough1; + float rough2 = part->rough2; + float rough_end = part->rough_end; + + if(ptex) { + kink_freq *= ptex->kink; + rough1 *= ptex->rough1; + rough2 *= ptex->rough2; + rough_end *= ptex->roughe; + } + if(part->flag & PART_CHILD_EFFECT) /* state is safe to cast, since only co and vel are used */ guided = do_guides(sim->psys->effectors, (ParticleKey*)state, cpa->parent, t); if(guided==0){ - if(part->kink) - do_prekink(state, par, par_rot, t, part->kink_freq * ptex->kink, part->kink_shape, + if(kink_freq > 0.f) + do_prekink(state, par, par_rot, t, kink_freq, part->kink_shape, part->kink_amp, part->kink, part->kink_axis, sim->ob->obmat); - do_clump(state, par, t, part->clumpfac, part->clumppow, ptex->clump); + do_clump(state, par, t, part->clumpfac, part->clumppow, ptex ? ptex->clump : 1.f); } - if(part->rough1 != 0.0 && ptex->rough1 != 0.0) - do_rough(orco, mat, t, ptex->rough1*part->rough1, part->rough1_size, 0.0, state); + if(rough1 > 0.f) + do_rough(orco, mat, t, rough1, part->rough1_size, 0.0, state); - if(part->rough2 != 0.0 && ptex->rough2 != 0.0) - do_rough(sim->psys->frand + ((i + 27) % (PSYS_FRAND_COUNT - 3)), mat, t, ptex->rough2*part->rough2, part->rough2_size, part->rough2_thres, state); + if(rough2 > 0.f) + do_rough(sim->psys->frand + ((i + 27) % (PSYS_FRAND_COUNT - 3)), mat, t, rough2, part->rough2_size, part->rough2_thres, state); - if(part->rough_end != 0.0 && ptex->roughe != 0.0) - do_rough_end(sim->psys->frand + ((i + 27) % (PSYS_FRAND_COUNT - 3)), mat, t, ptex->roughe*part->rough_end, part->rough_end_shape, state); + if(rough_end > 0.f) + do_rough_end(sim->psys->frand + ((i + 27) % (PSYS_FRAND_COUNT - 3)), mat, t, rough_end, part->rough_end_shape, state); } /* get's hair (or keyed) particles state at the "path time" specified in state->time */ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey *state, int vel) @@ -4033,7 +4045,10 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * pa = psys->particles + cpa->parent; - psys_mat_hair_to_global(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat); + if(part->type == PART_HAIR) + psys_mat_hair_to_global(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat); + else + unit_m4(hairmat); pa=0; } @@ -4049,9 +4064,16 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * cpa_num=pa->num; cpa_fuv=pa->fuv; - psys_particle_on_emitter(psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa_fuv,pa->foffset,co,0,0,0,orco,0); + - psys_mat_hair_to_global(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat); + if(part->type == PART_HAIR) { + psys_particle_on_emitter(psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa_fuv,pa->foffset,co,0,0,0,orco,0); + psys_mat_hair_to_global(sim->ob, sim->psmd->dm, psys->part->from, pa, hairmat); + } + else { + copy_v3_v3(orco, cpa->fuv); + unit_m4(hairmat); + } } /* correct child ipo timing */ @@ -4185,18 +4207,17 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta } else{ if(cpa){ + float mat[4][4]; ParticleKey *key1; float t = (cfra - pa->time) / pa->lifetime; key1=&pa->state; offset_child(cpa, key1, state, part->childflat, part->childrad); - + CLAMP(t,0.0,1.0); - if(part->kink) /* TODO: part->kink_freq*pa_kink */ - do_prekink(state,key1,key1->rot,t,part->kink_freq,part->kink_shape,part->kink_amp,part->kink,part->kink_axis,sim->ob->obmat); - - /* TODO: pa_clump vgroup */ - do_clump(state,key1,t,part->clumpfac,part->clumppow,1.0); + + unit_m4(mat); + do_child_modifiers(sim, NULL, key1, key1->rot, cpa, cpa->fuv, mat, state, t); if(psys->lattice) calc_latt_deform(sim->psys->lattice, state->co,1.0f); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 4e804cf14f7..4711e61c767 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -228,7 +228,15 @@ void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, flo { PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, index, key->co); PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, index, key->vel); - PTCACHE_DATA_TO(data, BPHYS_DATA_ROTATION, index, key->rot); + + /* no rotation info, so make something nice up */ + if(data[BPHYS_DATA_ROTATION]==NULL) { + vec_to_quat( key->rot, key->vel, OB_NEGX, OB_POSZ); + } + else { + PTCACHE_DATA_TO(data, BPHYS_DATA_ROTATION, index, key->rot); + } + PTCACHE_DATA_TO(data, BPHYS_DATA_AVELOCITY, index, key->ave); key->time = time; } -- cgit v1.2.3 From 071b61259bbbe9c3b4d6da2410b6914ecb89200e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 8 Dec 2010 14:40:14 +0000 Subject: increase grease pencil user count when copying objects. --- 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 b98927db877..fba227eb479 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1322,8 +1322,8 @@ Object *copy_object(Object *ob) /* increase user numbers */ id_us_plus((ID *)obn->data); + id_us_plus((ID *)obn->gpd); id_lib_extern((ID *)obn->dup_group); - for(a=0; atotcol; a++) id_us_plus((ID *)obn->mat[a]); -- cgit v1.2.3 From ad35b37f2d082d6618c44d14cb9b8d98f25563fc Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 9 Dec 2010 15:49:05 +0000 Subject: Bugfix #25120 and #25119 and numerous future bugs! Two isses: - Material assigning to MetaBalls used wrong pointer (copy paste error, casting badly). - Checking for node-material used wrong RNA pointer (confusing void stuff going on here!) The error leads to corruption in data and/or random crashes. Better update svn now! --- source/blender/blenkernel/intern/material.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 2af7fc3b70a..420aca12a20 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -445,7 +445,7 @@ Material ***give_matarar_id(ID *id) return &(((Curve *)id)->mat); break; case ID_MB: - return &(((Curve *)id)->mat); + return &(((MetaBall *)id)->mat); break; } return NULL; @@ -461,7 +461,7 @@ short *give_totcolp_id(ID *id) return &(((Curve *)id)->totcol); break; case ID_MB: - return &(((Curve *)id)->totcol); + return &(((MetaBall *)id)->totcol); break; } return NULL; @@ -530,6 +530,10 @@ Material *give_current_material(Object *ob, int act) totcolp= give_totcolp(ob); if(totcolp==NULL || ob->totcol==0) return NULL; + if(act<0) { + printf("no!\n"); + } + if(act>ob->totcol) act= ob->totcol; else if(act<=0) act= 1; -- cgit v1.2.3 From 545cc4803e8e9e7418aba98b2c1bec72fa629146 Mon Sep 17 00:00:00 2001 From: Diego Borghetti Date: Thu, 9 Dec 2010 22:27:55 +0000 Subject: Change the BLF_aspect function to handle 3d text. This is need to properly handle 3d text (dalai work on GE), before the BLF_aspect only take one argument, and the result was a call to: glScalef(aspect, aspect, 1.0) Now the three value are store in the font (x, y and z) and also need to be enable using BLF_enable(BLF_ASPECT). By default all the code that don't have BLF_ASPECT enable work with a scale of 1.0 (so nothing change to the current UI). I also remove all the call of BLF_aspect(fontid, 1.0) found in the editors, because is disable by default, so no need any more. Campbell the only thing to check is the python api, right now I modify the api to from: BLF_aspect(fontid, aspect) to: BLF_aspect(fontid, aspect, aspect, 1.0) This is to avoid break the api, but now you need add the BLF_ASPECT option to the function py_blf_enable and in some point change py_blf_aspect to take 3 arguments. --- source/blender/blenkernel/intern/image.c | 1 - source/blender/blenkernel/intern/image_gen.c | 1 - 2 files changed, 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 6cd0c89157a..efa8a824663 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1009,7 +1009,6 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i scene->r.stamp_font_id= 12; /* set before return */ - BLF_aspect(mono, 1.0); BLF_size(mono, scene->r.stamp_font_id, 72); BLF_buffer(mono, rectf, rect, width, height, channels); diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index b765cf29a3d..a2d41920217 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -306,7 +306,6 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width char text[3]= {'A', '1', '\0'}; const int mono= blf_mono_font; - BLF_aspect(mono, 1.0); BLF_size(mono, 54, 72); /* hard coded size! */ BLF_buffer(mono, rect_float, rect, width, height, 4); -- cgit v1.2.3 From b27f52ce2434d703dfafa3f98e74ff6e42027386 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 10 Dec 2010 04:10:21 +0000 Subject: bugfix [#25154] .MXF files should be included as a known video file type in the sequencer [#25159] Vertex locations dont read correctly and are not labeled correctly in the properties bar. - non rna buttons can now have units set. - calls with invalid units system now raises an assert(). - include .mxf in filter. --- source/blender/blenkernel/intern/unit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 69a43ac60f0..1b04589c1f2 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "BKE_unit.h" #include "BLI_math.h" @@ -274,6 +275,7 @@ static struct bUnitCollection *bUnitSystems[][9] = { /* internal, has some option not exposed */ static bUnitCollection *unit_get_system(int system, int type) { + assert((system > -1) && (system < UNIT_SYSTEM_TOT) && (type > -1) && (type < B_UNIT_TYPE_TOT)); return bUnitSystems[system][type]; /* select system to use, metric/imperial/other? */ } @@ -738,7 +740,7 @@ double bUnit_BaseScalar(int system, int type) /* external access */ int bUnit_IsValid(int system, int type) { - return !(type < 0 || type >= B_UNIT_MAXDEF || system < 0 || system > UNIT_SYSTEM_TOT); + return !(system < 0 || system > UNIT_SYSTEM_TOT || type < 0 || type > B_UNIT_TYPE_TOT); } -- cgit v1.2.3 From fe19e5336bfa819be3ed018cb7e05ca835ed72be Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 10 Dec 2010 08:29:46 +0000 Subject: Fix for [#25095] Particle systems and object with collision modifier bug * Collisions didn't take emitter object layer into account --- source/blender/blenkernel/intern/effect.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 24a95c58e36..51f2203b525 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -432,7 +432,7 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect return visibility; if(!colls) - colls = get_collider_cache(eff->scene, NULL, NULL); + colls = get_collider_cache(eff->scene, eff->ob, NULL); if(!colls) return visibility; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 931339d90b4..333ca91d4b9 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3392,7 +3392,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) psys_update_effectors(sim); if(part->type != PART_HAIR) - sim->colliders = get_collider_cache(sim->scene, NULL, NULL); + sim->colliders = get_collider_cache(sim->scene, sim->ob, NULL); /* initialize physics type specific stuff */ switch(part->phystype) { -- cgit v1.2.3 From f610c9b8a223b53165b6772dc0b1f3f676f36370 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 10 Dec 2010 10:34:12 +0000 Subject: Bug fix: child particles weren't always updated correctly * Calling update_children(..) is very light if there's nothing to update, so it doesn't matter if it's called every time the particle system is updated. --- source/blender/blenkernel/intern/particle_system.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (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 333ca91d4b9..60f54cfebf2 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3555,8 +3555,12 @@ 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 && sim->psys->totchild != get_psys_tot_child(sim->scene, sim->psys)) - distribute_particles(sim, PART_FROM_CHILD); + else if(sim->psys->part->childtype) { + if(sim->psys->totchild != get_psys_tot_child(sim->scene, sim->psys)) + distribute_particles(sim, PART_FROM_CHILD); + else + ; /* Children are up to date, nothing to do. */ + } else psys_free_children(sim->psys); } @@ -3876,8 +3880,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) BKE_ptcache_write_cache(use_cache, framenr); } - if(init) - update_children(sim); + update_children(sim); /* cleanup */ if(psys->lattice){ -- cgit v1.2.3 From 826cf81d34b7778b75fee93f1905e227ea9c0515 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 12 Dec 2010 17:59:48 +0000 Subject: Unlinking material crashed, missing NULL check. --- source/blender/blenkernel/intern/depsgraph.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index fe6b320d0bd..6a97fa21aa5 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2427,6 +2427,8 @@ void DAG_id_tag_update(ID *id, short flag) { Main *bmain= G.main; + if(id==NULL) return; + /* tag ID for update */ id->flag |= LIB_ID_RECALC; bmain->id_tag_update[id->name[0]] = 1; -- cgit v1.2.3 From 1474b32456f26ead36b50d787d99f9b1769b27e8 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 13 Dec 2010 06:31:49 +0000 Subject: Lattices now have AnimData This allows manual (point by point) animation of their control verts, although many other settings cannot really be animated with any visible effects yet. Interestingly, lattices also had IPO block pointers, though they were never really used (AFAIK). Todo: - Animation Editor support has yet to be added. I've got a few other things to add to, so will group those changes together. --- source/blender/blenkernel/intern/anim_sys.c | 5 ++++- source/blender/blenkernel/intern/lattice.c | 11 +++++++---- source/blender/blenkernel/intern/mball.c | 5 ++++- 3 files changed, 15 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index e48183ac479..b595d22e88c 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -73,7 +73,7 @@ short id_type_can_have_animdata (ID *id) switch (GS(id->name)) { /* has AnimData */ case ID_OB: - case ID_ME: case ID_MB: case ID_CU: case ID_AR: + case ID_ME: case ID_MB: case ID_CU: case ID_AR: case ID_LT: case ID_KE: case ID_PA: case ID_MA: case ID_TE: case ID_NT: @@ -1913,6 +1913,9 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) /* armatures */ EVAL_ANIM_IDS(main->armature.first, ADT_RECALC_ANIM); + /* lattices */ + EVAL_ANIM_IDS(main->latt.first, ADT_RECALC_ANIM); + /* meshes */ EVAL_ANIM_IDS(main->mesh.first, ADT_RECALC_ANIM); diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 73d77e850fd..891d42c4a76 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -49,6 +49,7 @@ #include "DNA_curve_types.h" #include "DNA_key_types.h" +#include "BKE_animsys.h" #include "BKE_anim.h" #include "BKE_cdderivedmesh.h" #include "BKE_displist.h" @@ -203,10 +204,6 @@ Lattice *copy_lattice(Lattice *lt) ltn= copy_libblock(lt); ltn->def= MEM_dupallocN(lt->def); - -#if 0 // XXX old animation system - id_us_plus((ID *)ltn->ipo); -#endif // XXX old animation system ltn->key= copy_key(ltn->key); if(ltn->key) ltn->key->from= (ID *)ltn; @@ -233,6 +230,12 @@ void free_lattice(Lattice *lt) MEM_freeN(editlt); MEM_freeN(lt->editlatt); } + + /* free animation data */ + if (lt->adt) { + BKE_free_animdata(<->id); + lt->adt= NULL; + } } diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 94ffaaea947..03cbd9e41fd 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -86,7 +86,10 @@ void free_mball(MetaBall *mb) { unlink_mball(mb); - if(mb->adt) BKE_free_animdata((ID *)mb); + if(mb->adt) { + BKE_free_animdata((ID *)mb); + mb->adt = NULL; + } if(mb->mat) MEM_freeN(mb->mat); if(mb->bb) MEM_freeN(mb->bb); BLI_freelistN(&mb->elems); -- cgit v1.2.3 From 4cd06a6526ddb837d445a25c081dce75c2ece979 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 13 Dec 2010 09:39:14 +0000 Subject: Fix for [#25185] Toggling hair dynamics without deleting cache leaves hair disattached when mesh animation is controlled by deformers - discussed with Jahka on IRC on Sat --- source/blender/blenkernel/intern/particle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 374d5a20b1c..a81406f0af1 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2795,7 +2795,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) ParticleSettings *part = psys->part; ParticleCacheKey *ca, **cache= psys->pathcache; - DerivedMesh *hair_dm = psys->hair_out_dm; + DerivedMesh *hair_dm = (psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) ? psys->hair_out_dm : NULL; ParticleKey result; @@ -2828,7 +2828,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) BLI_srandom(psys->seed); keyed = psys->flag & PSYS_KEYED; - baked = !hair_dm && psys->pointcache->mem_cache.first; + baked = psys->pointcache->mem_cache.first && psys->part->type != PART_HAIR; /* clear out old and create new empty path cache */ psys_free_path_cache(psys, psys->edit); -- cgit v1.2.3 From c85adcc2e439b7ecfede6e01a6e21f2f6258406b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 13 Dec 2010 10:24:05 +0000 Subject: Use mdisps layer from edit_mesh when adding/removing multires modifier when object is in edit mode. --- source/blender/blenkernel/intern/multires.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 7f7433f8965..802bc32f571 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -37,6 +37,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_pbvh.h" +#include "BLI_editVert.h" #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" @@ -278,7 +279,10 @@ void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *o Mesh *me = ob->data; MDisps *mdisp; - mdisp = CustomData_get_layer(&me->fdata, CD_MDISPS); + if(me->edit_mesh) + mdisp = CustomData_get_layer(&me->edit_mesh->fdata, CD_MDISPS); + else + mdisp = CustomData_get_layer(&me->fdata, CD_MDISPS); if(mdisp) { mmd->totlvl = get_levels_from_disps(ob); -- cgit v1.2.3 From 7bf5d9449c615120169eb290a3a8f46e53157340 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 13 Dec 2010 10:45:24 +0000 Subject: "Fix" for [#25184] Forces for growing hair - update inconsistency - as discussed with Jahka on Saturday on IRC * New option to "Regrow hair" for each frame. * This was perhaps more a feature request, but there was a similar useful feature called "animated hair" in particles at some point. * The previous behavior for hair growing was inconsistent to say the least, so this is a nice option to have. --- source/blender/blenkernel/intern/particle.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a81406f0af1..2ec90eb29db 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3473,7 +3473,7 @@ static void default_particle_settings(ParticleSettings *part) part->bb_uv_split=1; part->bb_align=PART_BB_VIEW; part->bb_split_offset=PART_BB_OFF_LINEAR; - part->flag=PART_REACT_MULTIPLE|PART_HAIR_GEOMETRY|PART_EDISTR|PART_TRAND; + part->flag=PART_EDISTR|PART_TRAND; part->sta= 1.0; part->end= 200.0; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 60f54cfebf2..c7a65b8a5ee 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4006,7 +4006,7 @@ static void psys_prepare_physics(ParticleSimulationData *sim) static int hair_needs_recalc(ParticleSystem *psys) { if(!(psys->flag & PSYS_EDITED) && (!psys->edit || !psys->edit->edited) && - ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_RESET)) { + ((psys->flag & PSYS_HAIR_DONE)==0 || psys->recalc & PSYS_RECALC_RESET || (psys->part->flag & PART_HAIR_REGROW && !psys->edit))) { return 1; } -- cgit v1.2.3 From 4d5afa04f8a927041cbcee32b0cf74e5c0a173e1 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 13 Dec 2010 18:22:59 +0000 Subject: Bugfix #23420 Compositor/Image viewer In 2.4x viewer nodes had animation playback. Not restored yet. However, when loading such older files the viewer never showed any result. --- source/blender/blenkernel/intern/image.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index efa8a824663..eb85db89835 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2149,7 +2149,8 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) BLI_lock_thread(LOCK_VIEWER); *lock_r= ima; - frame= iuser?iuser->framenr:0; + /* XXX anim play for viewer nodes not yet supported */ + frame= 0; // XXX iuser?iuser->framenr:0; ibuf= image_get_ibuf(ima, 0, frame); if(!ibuf) { -- cgit v1.2.3 From 991eac85ff682f66fdf5e73638fb5ebb66cf5bd2 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 13 Dec 2010 21:22:30 +0000 Subject: Initial implementation of mdisps layer interpolation Sculpt data shouldn't be lost when making topology changes without quads<->tris face converison. General idea: - Go through all grid points of each corner and convert per-corner coordiante to per-face cooredinate - Apply weights and convert new point to per-corner coordinate - Use bilinear interpolation to get needed displacement vector Some additional work was necessery: - Two neighbour corners could have different displacements along common boundary. multires_mdisp_smooth_bounds() makes displacement "symmetrical" - Point could change it's corner, so displacement vector should be flipped in some way. In some cases it's not only flipping, because corner could be mapped with some rotation. It's not solved for triangular faces yet, so only z-axis displacement would be interpolated for tris. More limitations: - Interpolation will give incorrect result after quad<->triangle face conversion. - When face normal was fillped displacement would change it's direction too. --- source/blender/blenkernel/intern/customdata.c | 298 ++++++++++++++++++++++---- source/blender/blenkernel/intern/multires.c | 127 +++++++++++ 2 files changed, 383 insertions(+), 42 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 1a3d31bdcf8..67d485d2dc3 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -396,7 +396,6 @@ static void layerDefault_origspace_face(void *data, int count) osf[i] = default_osf; } -#if 0 /* Adapted from sculptmode.c */ static void mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, float v) { @@ -442,7 +441,6 @@ static void mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, fl add_v3_v3v3(out, d2[0], d2[1]); } -#endif static void layerSwap_mdisps(void *data, const int *ci) { @@ -475,64 +473,280 @@ static void layerSwap_mdisps(void *data, const int *ci) } } -static void layerInterp_mdisps(void **UNUSED(sources), float *UNUSED(weights), - float *UNUSED(sub_weights), int UNUSED(count), void *dest) +static void mdisp_get_crn_rect(int face_side, float crn[3][4][2]) { - MDisps *d = dest; - int i; + float offset = face_side*0.5f - 0.5f; + float mid[2]; - // XXX -#if 0 + mid[0] = offset * 4 / 3; + mid[1] = offset * 2 / 3; + + crn[0][0][0] = mid[0]; crn[0][0][1] = mid[1]; + crn[0][1][0] = offset; crn[0][1][1] = 0; + crn[0][2][0] = 0; crn[0][2][1] = 0; + crn[0][3][0] = offset; crn[0][3][1] = offset; + + crn[1][0][0] = mid[0]; crn[1][0][1] = mid[1]; + crn[1][1][0] = offset * 2; crn[1][1][1] = offset; + crn[1][2][0] = offset * 2; crn[1][2][1] = 0; + crn[1][3][0] = offset; crn[1][3][1] = 0; + + crn[2][0][0] = mid[0]; crn[2][0][1] = mid[1]; + crn[2][1][0] = offset; crn[2][1][1] = offset; + crn[2][2][0] = offset * 2; crn[2][2][1] = offset * 2; + crn[2][3][0] = offset * 2; crn[2][3][1] = offset; +} + +static void mdisp_rot_crn_to_face(int S, int corners, int face_side, float x, float y, float *u, float *v) +{ + float offset = face_side*0.5f - 0.5f; + + if(corners == 4) { + if(S == 1) { *u= offset + x; *v = offset - y; } + if(S == 2) { *u= offset + y; *v = offset + x; } + if(S == 3) { *u= offset - x; *v = offset + y; } + if(S == 0) { *u= offset - y; *v = offset - x; } + } else { + float crn[3][4][2], vec[4][2]; + float p[2]; + + mdisp_get_crn_rect(face_side, crn); + + interp_v2_v2v2(vec[0], crn[S][0], crn[S][1], x / offset); + interp_v2_v2v2(vec[1], crn[S][3], crn[S][2], x / offset); + interp_v2_v2v2(vec[2], crn[S][0], crn[S][3], y / offset); + interp_v2_v2v2(vec[3], crn[S][1], crn[S][2], y / offset); + + isect_seg_seg_v2_point(vec[0], vec[1], vec[2], vec[3], p); + + (*u) = p[0]; + (*v) = p[1]; + } +} + +static int mdisp_pt_in_crn(float p[2], float crn[4][2]) +{ + float v[2][2]; + float a[2][2]; + + sub_v2_v2v2(v[0], crn[1], crn[0]); + sub_v2_v2v2(v[1], crn[3], crn[0]); + + sub_v2_v2v2(a[0], p, crn[0]); + sub_v2_v2v2(a[1], crn[2], crn[0]); + + if(cross_v2v2(a[0], v[0]) * cross_v2v2(a[1], v[0]) < 0) + return 0; + + if(cross_v2v2(a[0], v[1]) * cross_v2v2(a[1], v[1]) < 0) + return 0; + + return 1; +} + +static void face_to_crn_interp(float u, float v, float v1[2], float v2[2], float v3[2], float v4[2], float *x) +{ + float a = (v4[1]-v3[1])*v2[0]+(-v4[1]+v3[1])*v1[0]+(-v2[1]+v1[1])*v4[0]+(v2[1]-v1[1])*v3[0]; + float b = (v3[1]-v)*v2[0]+(v4[1]-2*v3[1]+v)*v1[0]+(-v4[1]+v3[1]+v2[1]-v1[1])*u+(v4[0]-v3[0])*v-v1[1]*v4[0]+(-v2[1]+2*v1[1])*v3[0]; + float c = (v3[1]-v)*v1[0]+(-v3[1]+v1[1])*u+v3[0]*v-v1[1]*v3[0]; + float d = b * b - 4 * a * c; + float x1, x2; + + if(a == 0) { + *x = -c / b; + return; + } + + x1 = (-b - sqrtf(d)) / (2 * a); + x2 = (-b + sqrtf(d)) / (2 * a); + + *x = maxf(x1, x2); +} + +static int mdisp_rot_face_to_crn(int corners, int face_side, float u, float v, float *x, float *y) +{ + float offset = face_side*0.5f - 0.5f; + int S; + + if (corners == 4) { + if(u <= offset && v <= offset) S = 0; + else if(u > offset && v <= offset) S = 1; + else if(u > offset && v > offset) S = 2; + else if(u <= offset && v >= offset) S = 3; + + if(S == 0) { + *y = offset - u; + *x = offset - v; + } else if(S == 1) { + *x = u - offset; + *y = offset - v; + } else if(S == 2) { + *y = u - offset; + *x = v - offset; + } else if(S == 3) { + *x= offset - u; + *y = v - offset; + } + } else { + float crn[3][4][2]; + float p[2] = {u, v}; + + mdisp_get_crn_rect(face_side, crn); + + for (S = 0; S < 3; ++S) { + if (mdisp_pt_in_crn(p, crn[S])) + break; + } + + face_to_crn_interp(u, v, crn[S][0], crn[S][1], crn[S][3], crn[S][2], &p[0]); + face_to_crn_interp(u, v, crn[S][0], crn[S][3], crn[S][1], crn[S][2], &p[1]); + + *x = p[0] * offset; + *y = p[1] * offset; + } + + return S; +} + +static void mdisp_apply_weight(int S, int corners, int x, int y, int face_side, + float crn_weight[4][2], float *u_r, float *v_r) +{ + float u, v, xl, yl; + float mid1[2], mid2[2], mid3[2]; + + mdisp_rot_crn_to_face(S, corners, face_side, x, y, &u, &v); + + if(corners == 4) { + xl = u / (face_side - 1); + yl = v / (face_side - 1); + + mid1[0] = crn_weight[0][0] * (1 - xl) + crn_weight[1][0] * xl; + mid1[1] = crn_weight[0][1] * (1 - xl) + crn_weight[1][1] * xl; + mid2[0] = crn_weight[3][0] * (1 - xl) + crn_weight[2][0] * xl; + mid2[1] = crn_weight[3][1] * (1 - xl) + crn_weight[2][1] * xl; + mid3[0] = mid1[0] * (1 - yl) + mid2[0] * yl; + mid3[1] = mid1[1] * (1 - yl) + mid2[1] * yl; + } else { + yl = v / (face_side - 1); + + if(v == face_side - 1) xl = 1; + else xl = 1 - (face_side - 1 - u) / (face_side - 1 - v); + + mid1[0] = crn_weight[0][0] * (1 - xl) + crn_weight[1][0] * xl; + mid1[1] = crn_weight[0][1] * (1 - xl) + crn_weight[1][1] * xl; + mid3[0] = mid1[0] * (1 - yl) + crn_weight[2][0] * yl; + mid3[1] = mid1[1] * (1 - yl) + crn_weight[2][1] * yl; + } + + *u_r = mid3[0]; + *v_r = mid3[1]; +} + +static void mdisp_flip_disp(int S, int corners, float axis_x[2], float axis_y[2], float disp[3]) +{ + float crn_x[2], crn_y[2]; + float vx[2], vy[2], coord[2]; + + if (corners == 4) { + float x[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; + float y[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}}; + + copy_v2_v2(crn_x, x[S]); + copy_v2_v2(crn_y, y[S]); + + mul_v2_v2fl(vx, crn_x, disp[0]); + mul_v2_v2fl(vy, crn_y, disp[1]); + add_v2_v2v2(coord, vx, vy); + + project_v2_v2v2(vx, coord, axis_x); + project_v2_v2v2(vy, coord, axis_y); + + disp[0] = len_v2(vx); + disp[1] = len_v2(vy); + + if(dot_v2v2(vx, axis_x) < 0) + disp[0] = -disp[0]; + + if(dot_v2v2(vy, axis_y) < 0) + disp[1] = -disp[1]; + } else { + /* XXX: it was very overhead code to support displacement flipping + for case of tris without visible profit. + Maybe its not really big limitation? for now? (nazgul) */ + disp[0] = 0; + disp[1] = 0; + } +} + +static void layerInterp_mdisps(void **sources, float *UNUSED(weights), + float *sub_weights, int count, void *dest) +{ MDisps *d = dest; MDisps *s = NULL; int st, stl; int i, x, y; - float crn[4][2]; + int side, S, dst_corners, src_corners; + float crn_weight[4][2]; float (*sw)[4] = NULL; + float (*disps)[3], (*out)[3]; - /* Initialize the destination */ - for(i = 0; i < d->totdisp; ++i) { - float z[3] = {0,0,0}; - copy_v3_v3(d->disps[i], z); + s = sources[0]; + dst_corners = multires_mdisp_corners(d); + src_corners = multires_mdisp_corners(d); + + /* XXX: For now, some restrictions on the input + should be implemented to allow quad<->tris face conversion */ + if(count != 1 || !sub_weights || dst_corners != src_corners) { + for(i = 0; i < d->totdisp; ++i) + zero_v3(d->disps[i]); + + return; } - /* For now, some restrictions on the input */ - if(count != 1 || !sub_weights) return; + /* Initialize the destination */ + out = disps = MEM_callocN(3*d->totdisp*sizeof(float), "iterp disps"); - st = sqrt(d->totdisp); + side = sqrt(d->totdisp / dst_corners); + st = (side<<1)-1; stl = st - 1; - sw = (void*)sub_weights; + sw= (void*)sub_weights; for(i = 0; i < 4; ++i) { - crn[i][0] = 0 * sw[i][0] + stl * sw[i][1] + stl * sw[i][2] + 0 * sw[i][3]; - crn[i][1] = 0 * sw[i][0] + 0 * sw[i][1] + stl * sw[i][2] + stl * sw[i][3]; + crn_weight[i][0] = 0 * sw[i][0] + stl * sw[i][1] + stl * sw[i][2] + 0 * sw[i][3]; + crn_weight[i][1] = 0 * sw[i][0] + 0 * sw[i][1] + stl * sw[i][2] + stl * sw[i][3]; } - s = sources[0]; - for(y = 0; y < st; ++y) { - for(x = 0; x < st; ++x) { - /* One suspects this code could be cleaner. */ - float xl = (float)x / (st - 1); - float yl = (float)y / (st - 1); - float mid1[2] = {crn[0][0] * (1 - xl) + crn[1][0] * xl, - crn[0][1] * (1 - xl) + crn[1][1] * xl}; - float mid2[2] = {crn[3][0] * (1 - xl) + crn[2][0] * xl, - crn[3][1] * (1 - xl) + crn[2][1] * xl}; - float mid3[2] = {mid1[0] * (1 - yl) + mid2[0] * yl, - mid1[1] * (1 - yl) + mid2[1] * yl}; - - float srcdisp[3]; - - mdisps_bilinear(srcdisp, s->disps, st, mid3[0], mid3[1]); - copy_v3_v3(d->disps[y * st + x], srcdisp); + multires_mdisp_smooth_bounds(s); + + out = disps; + for(S = 0; S < dst_corners; S++) { + float base[2], axis_x[2], axis_y[2]; + + mdisp_apply_weight(S, dst_corners, 0, 0, st, crn_weight, &base[0], &base[1]); + mdisp_apply_weight(S, dst_corners, side-1, 0, st, crn_weight, &axis_x[0], &axis_x[1]); + mdisp_apply_weight(S, dst_corners, 0, side-1, st, crn_weight, &axis_y[0], &axis_y[1]); + + sub_v3_v3(axis_x, base); + sub_v3_v3(axis_y, base); + normalize_v2(axis_x); + normalize_v2(axis_y); + + for(y = 0; y < side; ++y) { + for(x = 0; x < side; ++x, ++out) { + int crn; + float face_u, face_v, crn_u, crn_v; + + mdisp_apply_weight(S, dst_corners, x, y, st, crn_weight, &face_u, &face_v); + crn = mdisp_rot_face_to_crn(src_corners, st, face_u, face_v, &crn_u, &crn_v); + + mdisps_bilinear((*out), &s->disps[crn*side*side], side, crn_u, crn_v); + mdisp_flip_disp(crn, dst_corners, axis_x, axis_y, *out); + } } } -#else - if(d->disps) { - for(i = 0; i < d->totdisp; ++i) - zero_v3(d->disps[i]); - } -#endif + + MEM_freeN(d->disps); + d->disps = disps; } static void layerCopy_mdisps(const void *source, void *dest, int count) diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 802bc32f571..2224b3d8d49 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1647,3 +1647,130 @@ void multires_topology_changed(Object *ob) } } } + +/* makes displacement along grid boundary symmetrical */ +void multires_mdisp_smooth_bounds(MDisps *disps) +{ + int x, y, side, S, corners; + float (*out)[3]; + + corners = multires_mdisp_corners(disps); + side = sqrt(disps->totdisp / corners); + + out = disps->disps; + for(S = 0; S < corners; S++) { + for(y = 0; y < side; ++y) { + for(x = 0; x < side; ++x, ++out) { + float (*dispgrid)[3]; + float *data; + + if(x != 0 && y != 0) continue; + + if(corners == 4) { + if(S == 0) { + if(y == 0) { + dispgrid = &disps->disps[1*side*side]; + data = dispgrid[side * x + 0]; + + (*out)[0] = (*out)[0] + data[1]; + (*out)[1] = (*out)[1] - data[0]; + (*out)[2] = (*out)[2] + data[2]; + + mul_v3_fl(*out, 0.5); + + data[0] = -(*out)[1]; + data[1] = (*out)[0]; + data[2] = (*out)[2]; + } else if (x == 0) { + dispgrid = &disps->disps[3 * side * side]; + data = dispgrid[side * 0 + y]; + + (*out)[0] = (*out)[0] - data[1]; + (*out)[1] = (*out)[1] + data[0]; + (*out)[2] = (*out)[2] + data[2]; + + mul_v3_fl(*out, 0.5); + + data[0] = (*out)[1]; + data[1] = -(*out)[0]; + data[2] = (*out)[2]; + } + } else if (S == 2) { + if(y == 0) { + dispgrid = &disps->disps[3 * side * side]; + data = dispgrid[side * x + 0]; + + (*out)[0] = (*out)[0] + data[1]; + (*out)[1] = (*out)[1] - data[0]; + (*out)[2] = (*out)[2] + data[2]; + + mul_v3_fl(*out, 0.5); + + data[0] = -(*out)[1]; + data[1] = (*out)[0]; + data[2] = (*out)[2]; + } else if(x == 0) { + dispgrid = &disps->disps[1 * side * side]; + data = dispgrid[side * 0 + y]; + + (*out)[0] = (*out)[0] - data[1]; + (*out)[1] = (*out)[1] + data[0]; + (*out)[2] = (*out)[2] + data[2]; + + mul_v3_fl(*out, 0.5); + + data[0] = (*out)[1]; + data[1] = -(*out)[0]; + data[2] = (*out)[2]; + } + } + } else if (corners == 3) { + if(S == 0) { + if(y == 0) { + dispgrid = &disps->disps[1*side*side]; + data = dispgrid[side * x + 0]; + + (*out)[0] = (*out)[0] + data[1]; + (*out)[1] = (*out)[1] - data[0]; + (*out)[2] = (*out)[2] + data[2]; + + mul_v3_fl(*out, 0.5); + + data[0] = -(*out)[1]; + data[1] = (*out)[0]; + data[2] = (*out)[2]; + } else if (x == 0) { + dispgrid = &disps->disps[2 * side * side]; + data = dispgrid[side * 0 + y]; + + (*out)[0] = (*out)[0] - data[1]; + (*out)[1] = (*out)[1] + data[0]; + (*out)[2] = (*out)[2] + data[2]; + + mul_v3_fl(*out, 0.5); + + data[0] = (*out)[1]; + data[1] = -(*out)[0]; + data[2] = (*out)[2]; + } + } else if (S == 2) { + if(x == 0) { + dispgrid = &disps->disps[1 * side * side]; + data = dispgrid[side * 0 + y]; + + (*out)[0] = (*out)[0] - data[1]; + (*out)[1] = (*out)[1] + data[0]; + (*out)[2] = (*out)[2] + data[2]; + + mul_v3_fl(*out, 0.5); + + data[0] = (*out)[1]; + data[1] = -(*out)[0]; + data[2] = (*out)[2]; + } + } + } + } + } + } +} -- cgit v1.2.3 From 98f642dd31c3d73d41f37df67d8d1f83693e2d26 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Tue, 14 Dec 2010 03:30:30 +0000 Subject: Fixed bug #23922, Sculpting - Textured display draws incorrectly Root cause is that some drawing modes don't work with PBVH drawing. Worked around by adding a call to update mesh normals from the PBVH so that sculpted changes appear correctly in those "unsupported" modes. (They'll still draw much more slowly than solid, but should at least appear correct now.) --- source/blender/blenkernel/intern/cdderivedmesh.c | 23 +++++++++++++++++++++++ source/blender/blenkernel/intern/subsurf_ccg.c | 2 +- 2 files changed, 24 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 b820ad00305..cd0872807a0 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -226,6 +226,21 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) return cddm->pbvh; } +/* update vertex normals so that drawing smooth faces works during sculpt + TODO: proper fix is to support the pbvh in all drawing modes */ +static void cdDM_update_normals_from_pbvh(DerivedMesh *dm) +{ + CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + float (*face_nors)[3]; + + if(!cddm->pbvh || !cddm->pbvh_draw || !dm->numFaceData) + return; + + face_nors = CustomData_get_layer(&dm->faceData, CD_NORMAL); + + BLI_pbvh_update(cddm->pbvh, PBVH_UpdateNormals, face_nors); +} + static void cdDM_drawVerts(DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; @@ -538,6 +553,8 @@ static void cdDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha if(col1 && col2) glEnable(GL_CULL_FACE); + cdDM_update_normals_from_pbvh(dm); + if( GPU_buffer_legacy(dm) ) { DEBUG_VBO( "Using legacy code. cdDM_drawFacesColored\n" ); glShadeModel(GL_SMOOTH); @@ -617,6 +634,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, if(!mcol) mcol = dm->getFaceDataArray(dm, CD_MCOL); + cdDM_update_normals_from_pbvh(dm); + if( GPU_buffer_legacy(dm) ) { DEBUG_VBO( "Using legacy code. cdDM_drawFacesTex_common\n" ); for(i = 0; i < dm->numFaceData; i++, mf++) { @@ -792,6 +811,8 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us if(!mc) mc = DM_get_face_data_layer(dm, CD_MCOL); + cdDM_update_normals_from_pbvh(dm); + /* back-buffer always uses legacy since VBO's would need the * color array temporarily overwritten for drawing, then reset. */ if( GPU_buffer_legacy(dm) || G.f & G_BACKBUFSEL) { @@ -938,6 +959,8 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo int transp, new_transp, orig_transp; int orig, *index = dm->getFaceDataArray(dm, CD_ORIGINDEX); + cdDM_update_normals_from_pbvh(dm); + matnr = -1; smoothnormal = 0; dodraw = 0; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 56491b8d692..6f6e6844f0b 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1245,7 +1245,7 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d) no[1] = b_dZ*a_cX - b_dX*a_cZ; no[2] = b_dX*a_cY - b_dY*a_cX; - /* don't normalize, GL_NORMALIZE is be enabled */ + /* don't normalize, GL_NORMALIZE is enabled */ glNormal3fv(no); } -- cgit v1.2.3 From 2dc61df9eac381042af2b9a675ac645ee88449dc Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 14 Dec 2010 15:49:36 +0000 Subject: Fix for [#25206] Particles system can't start at frame 0 * The basic problem is that frame 0 can't be cached, so the correct solution is to read frame 1 and interpolate backwards from that state. --- source/blender/blenkernel/intern/particle.c | 24 ++++++++++++++++------ source/blender/blenkernel/intern/particle_system.c | 1 + 2 files changed, 19 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 2ec90eb29db..187071941bf 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4229,18 +4229,21 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta else if(pa->prev_state.time==state->time) copy_particle_key(state, &pa->prev_state, 1); else { + float dfra, frs_sec = sim->scene->r.frs_sec; /* let's interpolate to try to be as accurate as possible */ - if(pa->state.time + 2.0f > state->time && pa->prev_state.time - 2.0f < state->time) { - ParticleKey keys[4]; - float dfra, keytime, frs_sec = sim->scene->r.frs_sec; - + if(pa->state.time + 2.0f >= state->time && pa->prev_state.time - 2.0f <= state->time) { if(pa->prev_state.time >= pa->state.time) { - /* prev_state is wrong so let's not use it, this can happen at frame 1 or particle birth */ + /* prev_state is wrong so let's not use it, this can happen at frames 1, 0 or particle birth */ + dfra = state->time - pa->state.time; + copy_particle_key(state, &pa->state, 1); - VECADDFAC(state->co, state->co, state->vel, (state->time-pa->state.time)/frs_sec); + madd_v3_v3v3fl(state->co, state->co, state->vel, dfra/frs_sec); } else { + ParticleKey keys[4]; + float keytime; + copy_particle_key(keys+1, &pa->prev_state, 1); copy_particle_key(keys+2, &pa->state, 1); @@ -4261,6 +4264,15 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta interp_qt_qtqt(state->rot, keys[1].rot, keys[2].rot, keytime); } } + else if(pa->state.time + 1.f >= state->time && pa->state.time - 1.f <= state->time) { + /* linear interpolation using only pa->state */ + + dfra = state->time - pa->state.time; + + copy_particle_key(state, &pa->state, 1); + + madd_v3_v3v3fl(state->co, state->co, state->vel, dfra/frs_sec); + } else { /* extrapolating over big ranges is not accurate so let's just give something close to reasonable back */ copy_particle_key(state, &pa->state, 0); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index c7a65b8a5ee..9eed401adbb 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3776,6 +3776,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) /* simulation is only active during a specific period */ if(framenr < startframe) { + BKE_ptcache_read_cache(use_cache, startframe, sim->scene->r.frs_sec); /* set correct particle state and reset particles */ cached_step(sim, cfra); return; -- cgit v1.2.3 From bc64d8dcd852443e387d374a35f57bd9e1c38963 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 15 Dec 2010 16:15:52 +0000 Subject: Bugfix, irc report: Stamp info was calling log10 on zero, when end-frame was zero. Caused crash! Thanks Sergey for report. --- source/blender/blenkernel/intern/image.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index eb85db89835..4a40982b62e 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -940,8 +940,13 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) if (scene->r.stamp & R_STAMP_FRAME) { char format[32]; - if (do_prefix) sprintf(format, "Frame %%0%di", 1 + (int) log10(scene->r.efra)); - else sprintf(format, "%%0%di", 1 + (int) log10(scene->r.efra)); + int digits= 1; + + if(scene->r.efra>9) + digits= 1 + (int) log10(scene->r.efra); + + if (do_prefix) sprintf(format, "Frame %%0%di", digits); + else sprintf(format, "%%0%di", digits); sprintf (stamp_data->frame, format, scene->r.cfra); } else { stamp_data->frame[0] = '\0'; -- cgit v1.2.3 From 6b2b56c35eaf1ea8d2b0d0edd2412288f0e67e19 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 15 Dec 2010 17:05:34 +0000 Subject: Fix for [#25218] No smoke is emitted when particle system starts and ends on same frame * Depsgraph wasn't updated properly for smoke flow collision object dependencies. * Smoke also wasn't properly using the actual emission frame of the flow particles. * There was a lot of bloated logic in some parts of particle code so this fix turned into a small scale cleanup operation. ** As a result particle updating and cache usage should be a bit more stable too. --- source/blender/blenkernel/intern/particle.c | 17 +++-- source/blender/blenkernel/intern/particle_system.c | 81 ++++++++-------------- source/blender/blenkernel/intern/pointcache.c | 8 ++- source/blender/blenkernel/intern/smoke.c | 39 +++++++---- 4 files changed, 68 insertions(+), 77 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 187071941bf..a7506f2114b 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -4193,11 +4193,11 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta if(pa) { if(!always) - if((pa->alive==PARS_UNBORN && (part->flag & PART_UNBORN)==0) - || (pa->alive==PARS_DEAD && (part->flag & PART_DIED)==0)) + if((cfra < pa->time && (part->flag & PART_UNBORN)==0) + || (cfra > pa->dietime && (part->flag & PART_DIED)==0)) return 0; - state->time = MIN2(state->time, pa->dietime); + cfra = MIN2(cfra, pa->dietime); } if(sim->psys->flag & PSYS_KEYED){ @@ -4223,16 +4223,15 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta calc_latt_deform(sim->psys->lattice, state->co,1.0f); } else{ - if(pa->state.time==state->time || ELEM(part->phystype,PART_PHYS_NO,PART_PHYS_KEYED) - || pa->prev_state.time <= 0.0f) + if(pa->state.time==cfra || ELEM(part->phystype,PART_PHYS_NO,PART_PHYS_KEYED)) copy_particle_key(state, &pa->state, 1); - else if(pa->prev_state.time==state->time) + else if(pa->prev_state.time==cfra) copy_particle_key(state, &pa->prev_state, 1); else { float dfra, frs_sec = sim->scene->r.frs_sec; /* let's interpolate to try to be as accurate as possible */ - if(pa->state.time + 2.0f >= state->time && pa->prev_state.time - 2.0f <= state->time) { - if(pa->prev_state.time >= pa->state.time) { + if(pa->state.time + 2.f >= state->time && pa->prev_state.time - 2.f <= state->time) { + if(pa->prev_state.time >= pa->state.time || pa->prev_state.time < 0.f) { /* prev_state is wrong so let's not use it, this can happen at frames 1, 0 or particle birth */ dfra = state->time - pa->state.time; @@ -4258,7 +4257,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta psys_interpolate_particle(-1, keys, keytime, state, 1); /* convert back to real velocity */ - mul_v3_fl(state->vel, 1.0f / (dfra * timestep)); + mul_v3_fl(state->vel, 1.f / (dfra * timestep)); interp_v3_v3v3(state->ave, keys[1].ave, keys[2].ave, keytime); interp_qt_qtqt(state->rot, keys[1].rot, keys[2].rot, keytime); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 9eed401adbb..7e65cf26fd2 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3749,80 +3749,59 @@ static void system_step(ParticleSimulationData *sim, float cfra) ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; PointCache *cache = psys->pointcache; - PTCacheID pid, *use_cache = NULL; + PTCacheID ptcacheid, *pid = NULL; PARTICLE_P; - int oldtotpart; - float disp; /*, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; */ - int init= 0, emit= 0; //, only_children_changed= 0; - int framenr, framedelta, startframe = 0, endframe = 100; - - framenr= (int)sim->scene->r.cfra; - framedelta= framenr - cache->simframe; + float disp, cache_cfra = cfra; /*, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; */ + int startframe = 0, endframe = 100; /* cache shouldn't be used for hair or "continue physics" */ if(part->type != PART_HAIR && BKE_ptcache_get_continue_physics() == 0) { - BKE_ptcache_id_from_particles(&pid, sim->ob, psys); - use_cache = &pid; - } - - if(use_cache) { - psys_clear_temp_pointcache(sim->psys); + psys_clear_temp_pointcache(psys); /* set suitable cache range automatically */ if((cache->flag & (PTCACHE_BAKING|PTCACHE_BAKED))==0) - psys_get_pointcache_start_end(sim->scene, sim->psys, &cache->startframe, &cache->endframe); + psys_get_pointcache_start_end(sim->scene, psys, &cache->startframe, &cache->endframe); + + pid = &ptcacheid; + BKE_ptcache_id_from_particles(pid, sim->ob, psys); - BKE_ptcache_id_time(&pid, sim->scene, 0.0f, &startframe, &endframe, NULL); + BKE_ptcache_id_time(pid, sim->scene, 0.0f, &startframe, &endframe, NULL); - /* simulation is only active during a specific period */ - if(framenr < startframe) { - BKE_ptcache_read_cache(use_cache, startframe, sim->scene->r.frs_sec); - /* set correct particle state and reset particles */ - cached_step(sim, cfra); - return; - } - else if(framenr > endframe) { - framenr= endframe; - } - else if(framenr == startframe) { - BKE_ptcache_id_reset(sim->scene, use_cache, PTCACHE_RESET_OUTDATED); - BKE_ptcache_validate(cache, framenr); + /* clear everythin on start frame */ + if((int)cfra == startframe) { + BKE_ptcache_id_reset(sim->scene, pid, PTCACHE_RESET_OUTDATED); + BKE_ptcache_validate(cache, startframe); cache->flag &= ~PTCACHE_REDO_NEEDED; } + + CLAMP(cache_cfra, startframe, endframe); } -/* 1. emit particles */ - - /* verify if we need to reallocate */ - oldtotpart = psys->totpart; - - emit = emit_particles(sim, use_cache, cfra); - if(use_cache && emit > 0) - BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_ALL, cfra); - init = emit*emit + (psys->recalc & PSYS_RECALC_RESET); - - if(init) { +/* 1. emit particles and redo particles if needed */ + if(emit_particles(sim, pid, cfra) || psys->recalc & PSYS_RECALC_RESET) { distribute_particles(sim, part->from); initialize_all_particles(sim); - reset_all_particles(sim, 0.0, cfra, oldtotpart); + reset_all_particles(sim, 0.0, cfra, 0); /* flag for possible explode modifiers after this system */ sim->psmd->flag |= eParticleSystemFlag_Pars; + + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, cfra); } /* 2. try to read from the cache */ - if(use_cache) { - int cache_result = BKE_ptcache_read_cache(use_cache, cfra, sim->scene->r.frs_sec); + if(pid) { + int cache_result = BKE_ptcache_read_cache(pid, cache_cfra, sim->scene->r.frs_sec); 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); + BKE_ptcache_validate(cache, (int)cache_cfra); if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) - BKE_ptcache_write_cache(use_cache, framenr); + BKE_ptcache_write_cache(pid, (int)cache_cfra); return; } @@ -3837,7 +3816,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) /* if on second frame, write cache for first frame */ if(psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) - BKE_ptcache_write_cache(use_cache, startframe); + BKE_ptcache_write_cache(pid, startframe); } else BKE_ptcache_invalidate(cache); @@ -3860,7 +3839,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) /* handle negative frame start at the first frame by doing * all the steps before the first frame */ - if(framenr == startframe && part->sta < startframe) + if((int)cfra == startframe && part->sta < startframe) totframesback = (startframe - (int)part->sta); for(dframe=-totframesback; dframe<=0; dframe++) { @@ -3875,10 +3854,10 @@ static void system_step(ParticleSimulationData *sim, float cfra) } /* 4. only write cache starting from second frame */ - if(use_cache) { - BKE_ptcache_validate(cache, framenr); - if(framenr != startframe) - BKE_ptcache_write_cache(use_cache, framenr); + if(pid) { + BKE_ptcache_validate(cache, (int)cache_cfra); + if((int)cache_cfra != startframe) + BKE_ptcache_write_cache(pid, (int)cache_cfra); } update_children(sim); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 4711e61c767..c43f53cc4af 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1883,8 +1883,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) { int len; /* store the length of the string */ int i; - int sta = pid->cache->startframe; - int end = pid->cache->endframe; + int sta, end; /* mode is same as fopen's modes */ DIR *dir; @@ -1894,9 +1893,12 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) char path_full[MAX_PTCACHE_FILE]; char ext[MAX_PTCACHE_PATH]; - if(!pid->cache || pid->cache->flag & PTCACHE_BAKED) + if(!pid || !pid->cache || pid->cache->flag & PTCACHE_BAKED) return; + sta = pid->cache->startframe; + end = pid->cache->endframe; + #ifndef DURIAN_POINTCACHE_LIB_OK /* don't allow clearing for linked objects */ if(pid->ob->id.lib) diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 1833cc4eeac..08871cfeec7 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -973,9 +973,9 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) if(sfs && sfs->psys && sfs->psys->part && sfs->psys->part->type==PART_EMITTER) // is particle system selected { + ParticleSimulationData sim; ParticleSystem *psys = sfs->psys; ParticleSettings *part=psys->part; - ParticleData *pa = NULL; int p = 0; float *density = smoke_get_density(sds->fluid); float *bigdensity = smoke_turbulence_get_density(sds->wt); @@ -995,6 +995,10 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) */ float *temp_emission_map = NULL; + sim.scene = scene; + sim.ob = otherobj; + sim.psys = psys; + // initialize temp emission map if(!(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW)) { @@ -1007,19 +1011,26 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) } // mostly copied from particle code - for(p=0, pa=psys->particles; ptotpart; p++, pa++) - { - int cell[3]; - size_t i = 0; - size_t index = 0; - int badcell = 0; - if(pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0) continue; - else if(pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0) continue; - else if(pa->flag & (PARS_UNEXIST+PARS_NO_DISP)) continue; + for(p=0; ptotpart; p++) + { + int cell[3]; + size_t i = 0; + size_t index = 0; + int badcell = 0; + ParticleKey state; + + if(psys->particles[p].flag & (PARS_NO_DISP|PARS_UNEXIST)) + continue; + + state.time = smd->time; + + if(psys_get_particle_state(&sim, p, &state, 0) == 0) + continue; + // VECCOPY(pos, pa->state.co); // mul_m4_v3(ob->imat, pos); // 1. get corresponding cell - get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, pa->state.co, cell, 0); + get_cell(smd->domain->p0, smd->domain->res, smd->domain->dx, state.co, cell, 0); // check if cell is valid (in the domain boundary) for(i = 0; i < 3; i++) { @@ -1045,9 +1056,9 @@ 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 && (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; + velocity_x[index] = state.vel[0]*sfs->vel_multi; + velocity_y[index] = state.vel[1]*sfs->vel_multi; + velocity_z[index] = state.vel[2]*sfs->vel_multi; } } else if(sfs->type & MOD_SMOKE_FLOW_TYPE_OUTFLOW) // outflow -- cgit v1.2.3 From 7e10a9e6ce3d788e28ee39c9d2e94605d2a0ba47 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 15 Dec 2010 17:36:08 +0000 Subject: ensure pasted graph keys are always selected. --- source/blender/blenkernel/intern/smoke.c | 1 - 1 file changed, 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 08871cfeec7..adaab2046dc 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -975,7 +975,6 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd) { ParticleSimulationData sim; ParticleSystem *psys = sfs->psys; - ParticleSettings *part=psys->part; int p = 0; float *density = smoke_get_density(sds->fluid); float *bigdensity = smoke_turbulence_get_density(sds->wt); -- cgit v1.2.3 From e15f34b35fce21c89fdff956402a3671caf18a8b Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Thu, 16 Dec 2010 03:39:51 +0000 Subject: Fixed bug [#22634] sculpting/multires and wireframe display mode glitches Added a call to flush sculpting face grid changes out to ccgsubsurf's other data (in particular, to edge grids) Hopefully correct fix this time :) --- source/blender/blenkernel/intern/subsurf_ccg.c | 33 ++++++++++++++------------ 1 file changed, 18 insertions(+), 15 deletions(-) (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 6f6e6844f0b..874fd0fef17 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1146,6 +1146,22 @@ static void ccgDM_drawVerts(DerivedMesh *dm) { ccgFaceIterator_free(fi); glEnd(); } + +static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm) +{ + if(ccgdm->pbvh && ccgDM_use_grid_pbvh(ccgdm)) { + CCGFace **faces; + int totface; + + BLI_pbvh_get_grid_updates(ccgdm->pbvh, 1, (void***)&faces, &totface); + if(totface) { + ccgSubSurf_updateFromFaces(ccgdm->ss, 0, faces, totface); + ccgSubSurf_updateNormals(ccgdm->ss, faces, totface); + MEM_freeN(faces); + } + } +} + static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(drawAllEdges)) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; CCGSubSurf *ss = ccgdm->ss; @@ -1155,6 +1171,8 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int UNUSED(draw int gridSize = ccgSubSurf_getGridSize(ss); int useAging; + ccgdm_pbvh_update(ccgdm); + ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL); for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) { @@ -1249,21 +1267,6 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d) glNormal3fv(no); } -static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm) -{ - if(ccgdm->pbvh && ccgDM_use_grid_pbvh(ccgdm)) { - CCGFace **faces; - int totface; - - BLI_pbvh_get_grid_updates(ccgdm->pbvh, 1, (void***)&faces, &totface); - if(totface) { - ccgSubSurf_updateFromFaces(ccgdm->ss, 0, faces, totface); - ccgSubSurf_updateNormals(ccgdm->ss, faces, totface); - MEM_freeN(faces); - } - } -} - /* Only used by non-editmesh types */ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, int (*setMaterial)(int, void *attribs)) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; -- cgit v1.2.3 From 919d3413216818ef794dc897831d39059ac73f16 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 16 Dec 2010 13:43:20 +0000 Subject: Bugfix #24976 revisited Multi-layer images: clicking on the "Source" popup freed all memory for multilayers, even when choosing the same "File" entry again. Now it should work :) --- source/blender/blenkernel/intern/image.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 4a40982b62e..f2a100134b3 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1440,7 +1440,9 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) } } - image_free_buffers(ima); + /* force reload on first use, but not for multilayer, that makes nodes and buttons in ui drawing fail */ + if(ima->type!=IMA_TYPE_MULTILAYER) + image_free_buffers(ima); ima->ok= 1; if(iuser) -- cgit v1.2.3 From eecfc0fbb2892875d29879ebcb82289941ac4b1d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 16 Dec 2010 19:26:54 +0000 Subject: bugfix [#25208] randomize transform doesn't work on objects with keyframes Surprising this wasnt noticed in a much more obvious case: - Key Location, Move, Rotate, Undo-Rotate >> Resets to keyed location as well. This was happening because DAG_on_load_update() was called on read_undosave(), flagging 'ob->adt->recalc |= ADT_RECALC_ANIM;' Fix by adding an option to DAG_on_load_update(), not to recalculate time flags. --- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/blender.c | 6 ++- source/blender/blenkernel/intern/depsgraph.c | 65 +++++++++++++++------------- source/blender/blenkernel/intern/scene.c | 2 +- 4 files changed, 42 insertions(+), 33 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index b479bd5ef28..c372855b3eb 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -296,7 +296,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(G.main, scene, scene->lay); + DAG_scene_update_flags(G.main, scene, scene->lay, TRUE); /* find the last object with the tag * - all those afterwards are assumed to not be relevant for our calculations diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 6ceb75f2f83..b782d3a92a9 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -467,8 +467,10 @@ static int read_undosave(bContext *C, UndoElem *uel) strcpy(G.main->name, mainstr); /* restore */ G.fileflags= fileflags; - if(success) - DAG_on_load_update(G.main); + if(success) { + /* important not to update time here, else non keyed tranforms are lost */ + DAG_on_load_update(G.main, FALSE); + } return success; } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 6a97fa21aa5..2ac3946cb98 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1923,7 +1923,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(Main *bmain, Scene *sce, unsigned int lay, int time) +void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const short time) { DagNode *firstnode; DagAdjList *itA; @@ -2132,50 +2132,57 @@ 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(Main *bmain, Scene *scene, unsigned int lay) +/* do_time: make this optional because undo resets objects to their animated locations without this */ +void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const short do_time) { Base *base; Object *ob; Group *group; GroupObject *go; Scene *sce; - + /* set ob flags where animated systems are */ for(SETLOOPER(scene, base)) { ob= base->object; - - /* now if DagNode were part of base, the node->lay could be checked... */ - /* we do all now, since the scene_flush checks layers and clears recalc flags even */ - dag_object_time_update_flags(ob); - + + if(do_time) { + /* now if DagNode were part of base, the node->lay could be checked... */ + /* we do all now, since the scene_flush checks layers and clears recalc flags even */ + dag_object_time_update_flags(ob); + } + /* handled in next loop */ - if(ob->dup_group) + if(ob->dup_group) ob->dup_group->id.flag |= LIB_DOIT; - } - - /* we do groups each once */ - 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); + } + + if(do_time) { + /* we do groups each once */ + 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); + } } } } - + for(sce= scene; sce; sce= sce->set) DAG_scene_flush_update(bmain, sce, lay, 1); - /* test: set time flag, to disable baked systems to update */ - for(SETLOOPER(scene, base)) { - ob= base->object; - if(ob->recalc) - ob->recalc |= OB_RECALC_TIME; + if(do_time) { + /* test: set time flag, to disable baked systems to update */ + for(SETLOOPER(scene, base)) { + ob= base->object; + if(ob->recalc) + ob->recalc |= OB_RECALC_TIME; + } + + /* hrmf... an exception to look at once, for invisible camera object we do it over */ + if(scene->camera) + dag_object_time_update_flags(scene->camera); } - - /* hrmf... an exception to look at once, for invisible camera object we do it over */ - if(scene->camera) - dag_object_time_update_flags(scene->camera); - + /* and store the info in groupobject */ for(group= bmain->group.first; group; group= group->id.next) { if(group->id.flag & LIB_DOIT) { @@ -2231,7 +2238,7 @@ void DAG_ids_flush_update(Main *bmain, int time) DAG_scene_flush_update(bmain, sce, lay, time); } -void DAG_on_load_update(Main *bmain) +void DAG_on_load_update(Main *bmain, const short do_time) { Scene *scene, *sce; Base *base; @@ -2277,7 +2284,7 @@ void DAG_on_load_update(Main *bmain) } /* now tag update flags, to ensure deformers get calculated on redraw */ - DAG_scene_update_flags(bmain, scene, lay); + DAG_scene_update_flags(bmain, scene, lay, do_time); } } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 9bbadbacb37..58b7f95f9c8 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1010,7 +1010,7 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) /* Following 2 functions are recursive * so dont call within 'scene_update_tagged_recursive' */ - DAG_scene_update_flags(bmain, sce, lay); // only stuff that moves or needs display still + DAG_scene_update_flags(bmain, sce, lay, TRUE); // 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 -- cgit v1.2.3 From 9f3edfecfc20766df107a0c19d883bbd895ffeec Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Fri, 17 Dec 2010 08:08:35 +0000 Subject: This fixes [#25011] Opacity IPO not refreshing with still images (should be better named: animation of any prefiltering parameters using still images didn't work out as expected) And this issue by private mail by Ton: "I tried to debug a memory-free error; very simple case: - add image strip - click on strip at 2 places - quit blender" --- source/blender/blenkernel/intern/sequencer.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index fac773b2c6f..74a38d785e4 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1683,8 +1683,7 @@ static ImBuf * copy_from_ibuf_still(SeqRenderData context, Sequence * seq, ibuf = seq_stripelem_cache_get( context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL); - } - if (nr == seq->len - 1) { + } else if (nr == seq->len - 1) { ibuf = seq_stripelem_cache_get( context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL); @@ -1705,7 +1704,8 @@ static void copy_to_ibuf_still(SeqRenderData context, Sequence * seq, float nr, seq_stripelem_cache_put( context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf); - } + } + if (nr == seq->len - 1) { seq_stripelem_cache_put( context, seq, seq->start, @@ -1969,13 +1969,14 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr ibuf = seq_stripelem_cache_get(context, seq, cfra, SEQ_STRIPELEM_IBUF); - if (ibuf == NULL) - ibuf = copy_from_ibuf_still(context, seq, nr); - - /* currently, we cache preprocessed images */ + /* currently, we cache preprocessed images in SEQ_STRIPELEM_IBUF, + but not(!) on SEQ_STRIPELEM_IBUF_ENDSTILL and ..._STARTSTILL */ if (ibuf) use_preprocess = FALSE; + if (ibuf == NULL) + ibuf = copy_from_ibuf_still(context, seq, nr); + if (ibuf == NULL) ibuf = seq_proxy_fetch(context, seq, cfra); -- cgit v1.2.3 From 0ec7f95245478baa4b3608888d70db72cca5348b Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Fri, 17 Dec 2010 08:53:49 +0000 Subject: == Sequencer == Sequence effect rendering of color generator did some rather strange fall through, because of a missing break statement. (Noone got hurt, but better add that break, just in case) --- source/blender/blenkernel/intern/sequencer.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 74a38d785e4..17d63fa2349 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1770,6 +1770,7 @@ static ImBuf* seq_render_effect_strip_impl( case EARLY_NO_INPUT: out = sh.execute(context, seq, cfra, fac, facf, NULL, NULL, NULL); + break; case EARLY_DO_EFFECT: for(i=0; i<3; i++) { if(input[i]) -- cgit v1.2.3 From 48abe2a27f81db5068ab8a2d6c6849d72b109e5d Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 17 Dec 2010 13:13:32 +0000 Subject: Big fix: particle pointcache was cleared fully on any particle setting change * Now only the cache after current frame is cleared. * Probably own fault from my last commit. --- 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 7e65cf26fd2..8cfc9c3e4af 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3786,7 +3786,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) /* flag for possible explode modifiers after this system */ sim->psmd->flag |= eParticleSystemFlag_Pars; - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, cfra); + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfra); } /* 2. try to read from the cache */ -- cgit v1.2.3 From e5e039d626656ac430cd750f5761adfa8d94a98a Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 17 Dec 2010 14:20:20 +0000 Subject: Bugfix #25264 Bad user counting went on, ID users could be set zero whilst having Fake user set. Also ensured the code using the BKE calls for increment/decrement. --- source/blender/blenkernel/intern/library.c | 10 ++++++++-- 1 file changed, 8 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 8e1220dde24..ce9e7ddf0ce 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -138,8 +138,14 @@ void id_us_plus(ID *id) void id_us_min(ID *id) { - if(id) - id->us--; + if(id) { + if(id->us<2 && (id->flag & LIB_FAKEUSER)) + id->us= 1; + else if(id->us<=0) + printf("ID user decrement error: %s \n", id->name); + else + id->us--; + } } int id_make_local(ID *id, int test) -- cgit v1.2.3 From 902b239aa8de92d559c7b431eaa4321d9dc2b7cf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 17 Dec 2010 15:37:59 +0000 Subject: no functional changes: SETLOOPER macro assumed a scene was defined called 'sce' used to loop over, now make this an argument, helps to make it clear what's going on. --- source/blender/blenkernel/intern/collision.c | 8 ++++---- source/blender/blenkernel/intern/depsgraph.c | 17 +++++++++-------- source/blender/blenkernel/intern/pointcache.c | 6 +++--- source/blender/blenkernel/intern/scene.c | 10 +++++----- 4 files changed, 21 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index d39e550192b..b2d587151b1 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1358,9 +1358,9 @@ Object **get_collisionobjects(Scene *scene, Object *self, Group *group, unsigned add_collision_object(&objs, &numobj, &maxobj, go->ob, self, 0); } else { - Scene *sce; /* for SETLOOPER macro */ + Scene *sce_iter; /* add objects in same layer in scene */ - for(SETLOOPER(scene, base)) { + for(SETLOOPER(scene, sce_iter, base)) { if(base->lay & self->lay) add_collision_object(&objs, &numobj, &maxobj, base->object, self, 0); @@ -1417,11 +1417,11 @@ ListBase *get_collider_cache(Scene *scene, Object *self, Group *group) add_collider_cache_object(&objs, go->ob, self, 0); } else { - Scene *sce; /* for SETLOOPER macro */ + Scene *sce_iter; Base *base; /* add objects in same layer in scene */ - for(SETLOOPER(scene, base)) { + for(SETLOOPER(scene, sce_iter, base)) { if(!self || (base->lay & self->lay)) add_collider_cache_object(&objs, base->object, self, 0); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 2ac3946cb98..1904e63c2ba 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2139,10 +2139,10 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s Object *ob; Group *group; GroupObject *go; - Scene *sce; + Scene *sce_iter; /* set ob flags where animated systems are */ - for(SETLOOPER(scene, base)) { + for(SETLOOPER(scene, sce_iter, base)) { ob= base->object; if(do_time) { @@ -2167,12 +2167,12 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s } } - for(sce= scene; sce; sce= sce->set) - DAG_scene_flush_update(bmain, sce, lay, 1); + for(sce_iter= scene; sce_iter; sce_iter= sce_iter->set) + DAG_scene_flush_update(bmain, sce_iter, lay, 1); if(do_time) { /* test: set time flag, to disable baked systems to update */ - for(SETLOOPER(scene, base)) { + for(SETLOOPER(scene, sce_iter, base)) { ob= base->object; if(ob->recalc) ob->recalc |= OB_RECALC_TIME; @@ -2240,7 +2240,7 @@ void DAG_ids_flush_update(Main *bmain, int time) void DAG_on_load_update(Main *bmain, const short do_time) { - Scene *scene, *sce; + Scene *scene; Base *base; Object *ob; Group *group; @@ -2251,15 +2251,16 @@ void DAG_on_load_update(Main *bmain, const short do_time) dag_current_scene_layers(bmain, &scene, &lay); if(scene && scene->theDag) { + Scene *sce_iter; /* derivedmeshes and displists are not saved to file so need to be remade, tag them so they get remade in the scene update loop, note armature poses or object matrices are preserved and do not require updates, so we skip those */ dag_scene_flush_layers(scene, lay); - for(SETLOOPER(scene, base)) { + for(SETLOOPER(scene, sce_iter, base)) { ob= base->object; - node= (sce->theDag)? dag_get_node(sce->theDag, ob): NULL; + node= (sce_iter->theDag)? dag_get_node(sce_iter->theDag, ob): NULL; oblay= (node)? node->lay: ob->lay; if(oblay & lay) { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index c43f53cc4af..d131a3c3592 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2464,7 +2464,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) { Main *bmain = baker->main; Scene *scene = baker->scene; - Scene *sce; /* SETLOOPER macro only */ + Scene *sce_iter; /* SETLOOPER macro only */ Base *base; ListBase pidlist; PTCacheID *pid = baker->pid; @@ -2535,7 +2535,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache->flag &= ~PTCACHE_BAKED; } } - else for(SETLOOPER(scene, base)) { + else for(SETLOOPER(scene, sce_iter, base)) { /* cache/bake everything in the scene */ BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); @@ -2624,7 +2624,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) BKE_ptcache_write_cache(pid, 0); } } - else for(SETLOOPER(scene, base)) { + else for(SETLOOPER(scene, sce_iter, base)) { BKE_ptcache_ids_from_object(&pidlist, base->object, scene, MAX_DUPLI_RECUR); for(pid=pidlist.first; pid; pid=pid->next) { diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 58b7f95f9c8..7a8c4efb51a 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1077,20 +1077,20 @@ float get_render_aosss_error(RenderData *r, float error) } /* helper function for the SETLOOPER macro */ -Base *_setlooper_base_step(Scene **sce, Base *base) +Base *_setlooper_base_step(Scene **sce_iter, Base *base) { if(base && base->next) { /* common case, step to the next */ return base->next; } - else if(base==NULL && (*sce)->base.first) { + else if(base==NULL && (*sce_iter)->base.first) { /* first time looping, return the scenes first base */ - return (Base *)(*sce)->base.first; + return (Base *)(*sce_iter)->base.first; } else { /* reached the end, get the next base in the set */ - while((*sce= (*sce)->set)) { - base= (Base *)(*sce)->base.first; + while((*sce_iter= (*sce_iter)->set)) { + base= (Base *)(*sce_iter)->base.first; if(base) { return base; } -- cgit v1.2.3 From f90a2123eedc6cb82cfe9ad1c2ab64ba2f1e0c38 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 17 Dec 2010 15:51:42 +0000 Subject: no functional change: only check against OB_RECALC_ALL but don't use for assignment. Makes adding new flags give ambiguous results and also makes it less easy to tell whats intended. In some places it looks like OB_RECALC_TIME should be left out too. --- source/blender/blenkernel/intern/exotic.c | 2 +- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/object.c | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 51fd5e1e4c6..53c3534bce3 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -2376,7 +2376,7 @@ static void dxf_read(Scene *scene, const char *filename) ob->dupon= 1; ob->dupoff= 0; ob->dupsta= 1; ob->dupend= 100; - ob->recalc= OB_RECALC_ALL; /* needed because of weird way of adding libdata directly */ + ob->recalc= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; /* needed because of weird way of adding libdata directly */ ob->data= obdata; ((ID*)ob->data)->us++; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index ce9e7ddf0ce..cac0b64a6b6 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -450,7 +450,7 @@ void recalc_all_library_objects(Main *main) /* flag for full recalc */ for(ob=main->object.first; ob; ob=ob->id.next) if(ob->id.lib) - ob->recalc |= OB_RECALC_ALL; + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } /* note: MAX_LIBARRAY define should match this code */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index fba227eb479..54bc07b548d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -316,7 +316,7 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec if (*obpoin==unlinkOb) { *obpoin = NULL; - ob->recalc |= OB_RECALC_ALL; // XXX: should this just be OB_RECALC_DATA? + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; // XXX: should this just be OB_RECALC_DATA? } } @@ -357,7 +357,7 @@ void unlink_object(Object *ob) if(obt->parent==ob) { obt->parent= NULL; - obt->recalc |= OB_RECALC_ALL; + obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } modifiers_foreachObjectLink(obt, unlink_object__unlinkModifierLinks, ob); @@ -367,15 +367,15 @@ void unlink_object(Object *ob) if(cu->bevobj==ob) { cu->bevobj= NULL; - obt->recalc |= OB_RECALC_ALL; + obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } if(cu->taperobj==ob) { cu->taperobj= NULL; - obt->recalc |= OB_RECALC_ALL; + obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } if(cu->textoncurve==ob) { cu->textoncurve= NULL; - obt->recalc |= OB_RECALC_ALL; + obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } } else if(obt->type==OB_ARMATURE && obt->pose) { @@ -1078,7 +1078,7 @@ Object *add_object(struct Scene *scene, int type) base= scene_add_base(scene, ob); scene_select_base(scene, base); - ob->recalc |= OB_RECALC_ALL; + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; return ob; } @@ -1538,7 +1538,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) ob->proxy_group= gob; id_lib_extern(&target->id); - ob->recalc= target->recalc= OB_RECALC_ALL; + ob->recalc= target->recalc= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; /* copy transform * - gob means this proxy comes from a group, just apply the matrix -- cgit v1.2.3 From fd90685a48f6fae30e6731bc4a805930e776f117 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 17 Dec 2010 19:05:10 +0000 Subject: remove some paranoid NULL checks, since the pointers are used already. --- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- 1 file changed, 1 insertion(+), 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 cd0872807a0..d6c91c3c908 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -199,7 +199,6 @@ static int can_pbvh_draw(Object *ob, DerivedMesh *dm) static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; - Mesh *me= (ob)? ob->data: NULL; if(!ob) { cddm->pbvh= NULL; @@ -217,6 +216,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) this derivedmesh is just original mesh. it's the multires subsurf dm that this is actually for, to support a pbvh on a modified mesh */ if(!cddm->pbvh && ob->type == OB_MESH) { + Mesh *me= ob->data; cddm->pbvh = BLI_pbvh_new(); cddm->pbvh_draw = can_pbvh_draw(ob, dm); BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert, -- cgit v1.2.3 From 8b28c24d16386db7e68326d8607de5d20c9833b0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 17 Dec 2010 20:13:54 +0000 Subject: Fix #25272: shrinkwrap with dependency cycle could lead to eternal loop and increasing memory usage. Modifiers should never call mesh_get_derived_final or similar, only use ob->derivedFinal if it exists, if the dependencies are set correct and there are no cycles, it will be there. --- source/blender/blenkernel/intern/constraint.c | 2 +- source/blender/blenkernel/intern/shrinkwrap.c | 30 +++++++++++++-------------- 2 files changed, 16 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 f92f2326aeb..bb0fc23c02c 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3423,7 +3423,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr float dist; SpaceTransform transform; - DerivedMesh *target = object_get_derived_final(cob->scene, ct->tar, CD_MASK_BAREMESH); + DerivedMesh *target = object_get_derived_final(ct->tar); BVHTreeRayHit hit; BVHTreeNearest nearest; diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 936fb1bfeab..16e4933332c 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -48,6 +48,7 @@ #include "BKE_mesh.h" #include "BKE_subsurf.h" +#include "BLI_editVert.h" #include "BLI_math.h" @@ -82,21 +83,18 @@ typedef void ( *Shrinkwrap_ForeachVertexCallback) (DerivedMesh *target, float *c /* get derived mesh */ //TODO is anyfunction that does this? returning the derivedFinal witouth we caring if its in edit mode or not? -DerivedMesh *object_get_derived_final(struct Scene *scene, Object *ob, CustomDataMask dataMask) +DerivedMesh *object_get_derived_final(Object *ob) { Mesh *me= ob->data; - struct EditMesh *em = BKE_mesh_get_editmesh(me); + EditMesh *em = BKE_mesh_get_editmesh(me); - if (em) - { - DerivedMesh *final = NULL; - editmesh_get_derived_cage_and_final(scene, ob, em, &final, dataMask); - + if(em) { + DerivedMesh *dm = em->derivedFinal; BKE_mesh_end_editmesh(me, em); - return final; + return dm; } - else - return mesh_get_derived_final(scene, ob, dataMask); + + return ob->derivedFinal; } /* Space transform */ @@ -282,7 +280,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa } -static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct Scene *scene) +static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) { int i; @@ -327,7 +325,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, struct S if(calc->smd->auxTarget) { - auxMesh = object_get_derived_final(scene, calc->smd->auxTarget, CD_MASK_BAREMESH); + auxMesh = object_get_derived_final(calc->smd->auxTarget); + if(!auxMesh) + return; space_transform_setup( &local2aux, calc->ob, calc->smd->auxTarget); } @@ -499,7 +499,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) } /* Main shrinkwrap function */ -void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Scene *scene, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts) +void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts) { DerivedMesh *ss_mesh = NULL; @@ -530,7 +530,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Scene *scene, Object if(smd->target) { - calc.target = object_get_derived_final(scene, smd->target, CD_MASK_BAREMESH); + calc.target = object_get_derived_final(smd->target); //TODO there might be several "bugs" on non-uniform scales matrixs //because it will no longer be nearest surface, not sphere projection @@ -587,7 +587,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Scene *scene, Object break; case MOD_SHRINKWRAP_PROJECT: - BENCH(shrinkwrap_calc_normal_projection(&calc, scene)); + BENCH(shrinkwrap_calc_normal_projection(&calc)); break; case MOD_SHRINKWRAP_NEAREST_VERTEX: -- cgit v1.2.3 From ee762ce93f8f5591793445ab678ed0ea58703003 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 18 Dec 2010 09:32:27 +0000 Subject: Fix for mistake in own commit * Was a bit too eager to clean up, so all particles got reset when changing a particle value when animation was playing. --- source/blender/blenkernel/intern/particle_system.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (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 8cfc9c3e4af..f112689a63b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3752,7 +3752,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) PTCacheID ptcacheid, *pid = NULL; PARTICLE_P; float disp, cache_cfra = cfra; /*, *vg_vel= 0, *vg_tan= 0, *vg_rot= 0, *vg_size= 0; */ - int startframe = 0, endframe = 100; + int startframe = 0, endframe = 100, oldtotpart = 0; /* cache shouldn't be used for hair or "continue physics" */ if(part->type != PART_HAIR && BKE_ptcache_get_continue_physics() == 0) { @@ -3778,10 +3778,12 @@ static void system_step(ParticleSimulationData *sim, float cfra) } /* 1. emit particles and redo particles if needed */ + oldtotpart = psys->totpart; if(emit_particles(sim, pid, cfra) || psys->recalc & PSYS_RECALC_RESET) { distribute_particles(sim, part->from); initialize_all_particles(sim); - reset_all_particles(sim, 0.0, cfra, 0); + /* reset only just created particles (on startframe all particles are recreated) */ + reset_all_particles(sim, 0.0, cfra, oldtotpart); /* flag for possible explode modifiers after this system */ sim->psmd->flag |= eParticleSystemFlag_Pars; -- cgit v1.2.3 From a93411629811ec20f576895c0cb515b9abd7ec19 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 18 Dec 2010 09:46:52 +0000 Subject: Fix for [#25282] Crash when weting initial mesh pressets with a smoke simulation --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index d131a3c3592..8c5d38b63a3 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1946,7 +1946,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) BLI_join_dirfile(path_full, path, de->d_name); BLI_delete(path_full, 0, 0); - if(frame >=sta && frame <= end) + if(pid->cache->cached_frames && frame >=sta && frame <= end) pid->cache->cached_frames[frame-sta] = 0; } } -- cgit v1.2.3 From b58dbbd51b298acede888a4005d13982417a6bee Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 18 Dec 2010 15:03:31 +0000 Subject: Extreme makeover of pointcache code: * Pointcache code was quite ugly looking and complicated, so here are mostly just cosmetic adjustments, but some improved logic also. * Slight cleanup of pointcache ui too. * Shouldn't have any functional changes what so ever, so poke me right away if something seems off. --- source/blender/blenkernel/intern/cloth.c | 8 +- source/blender/blenkernel/intern/particle_system.c | 8 +- source/blender/blenkernel/intern/pointcache.c | 1355 +++++++++----------- source/blender/blenkernel/intern/smoke.c | 6 +- source/blender/blenkernel/intern/softbody.c | 8 +- 5 files changed, 636 insertions(+), 749 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 7473ff6875a..f644b28b137 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -504,7 +504,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, } /* try to read from cache */ - cache_result = BKE_ptcache_read_cache(&pid, (float)framenr+scene->r.subframe, scene->r.frs_sec); + cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe, scene->r.frs_sec); if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { implicit_set_positions(clmd); @@ -513,7 +513,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, BKE_ptcache_validate(cache, framenr); if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) - BKE_ptcache_write_cache(&pid, framenr); + BKE_ptcache_write(&pid, framenr); return result; } @@ -528,7 +528,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, /* if on second frame, write cache for first frame */ if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) - BKE_ptcache_write_cache(&pid, startframe); + BKE_ptcache_write(&pid, startframe); clmd->sim_parms->timescale *= framenr - cache->simframe; @@ -539,7 +539,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, BKE_ptcache_invalidate(cache); } else - BKE_ptcache_write_cache(&pid, framenr); + BKE_ptcache_write(&pid, framenr); cloth_to_object (ob, clmd, result); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index f112689a63b..aca8bf848a2 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3793,7 +3793,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) /* 2. try to read from the cache */ if(pid) { - int cache_result = BKE_ptcache_read_cache(pid, cache_cfra, sim->scene->r.frs_sec); + int cache_result = BKE_ptcache_read(pid, cache_cfra, sim->scene->r.frs_sec); if(ELEM(cache_result, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED)) { cached_step(sim, cfra); @@ -3803,7 +3803,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) BKE_ptcache_validate(cache, (int)cache_cfra); if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) - BKE_ptcache_write_cache(pid, (int)cache_cfra); + BKE_ptcache_write(pid, (int)cache_cfra); return; } @@ -3818,7 +3818,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) /* if on second frame, write cache for first frame */ if(psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) - BKE_ptcache_write_cache(pid, startframe); + BKE_ptcache_write(pid, startframe); } else BKE_ptcache_invalidate(cache); @@ -3859,7 +3859,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) if(pid) { BKE_ptcache_validate(cache, (int)cache_cfra); if((int)cache_cfra != startframe) - BKE_ptcache_write_cache(pid, (int)cache_cfra); + BKE_ptcache_write(pid, (int)cache_cfra); } update_children(sim); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 8c5d38b63a3..b87347f4975 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -106,8 +106,12 @@ int ptcache_data_size[] = { sizeof(BoidData) // case BPHYS_DATA_BOIDS: }; +/* forward declerations */ +static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size); +static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size); + /* Common functions */ -static int ptcache_read_basic_header(PTCacheFile *pf) +static int ptcache_basic_header_read(PTCacheFile *pf) { int error=0; @@ -120,7 +124,7 @@ static int ptcache_read_basic_header(PTCacheFile *pf) return !error; } -static int ptcache_write_basic_header(PTCacheFile *pf) +static int ptcache_basic_header_write(PTCacheFile *pf) { /* Custom functions should write these basic elements too! */ if(!fwrite(&pf->totpoint, sizeof(int), 1, pf->fp)) @@ -132,7 +136,7 @@ static int ptcache_write_basic_header(PTCacheFile *pf) return 1; } /* Softbody functions */ -static int ptcache_write_softbody(int index, void *soft_v, void **data, int UNUSED(cfra)) +static int ptcache_softbody_write(int index, void *soft_v, void **data, int UNUSED(cfra)) { SoftBody *soft= soft_v; BodyPoint *bp = soft->bpoint + index; @@ -142,7 +146,7 @@ static int ptcache_write_softbody(int index, void *soft_v, void **data, int UNUS return 1; } -static void ptcache_read_softbody(int index, void *soft_v, void **data, float UNUSED(frs_sec), float UNUSED(cfra), float *old_data) +static void ptcache_softbody_read(int index, void *soft_v, void **data, float UNUSED(frs_sec), float UNUSED(cfra), float *old_data) { SoftBody *soft= soft_v; BodyPoint *bp = soft->bpoint + index; @@ -156,7 +160,7 @@ static void ptcache_read_softbody(int index, void *soft_v, void **data, float UN PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, 0, bp->vec); } } -static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, float UNUSED(frs_sec), float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_softbody_interpolate(int index, void *soft_v, void **data, float UNUSED(frs_sec), float cfra, float cfra1, float cfra2, float *old_data) { SoftBody *soft= soft_v; BodyPoint *bp = soft->bpoint + index; @@ -188,13 +192,29 @@ static void ptcache_interpolate_softbody(int index, void *soft_v, void **data, f VECCOPY(bp->pos, keys->co); VECCOPY(bp->vec, keys->vel); } -static int ptcache_totpoint_softbody(void *soft_v, int UNUSED(cfra)) +static int ptcache_softbody_totpoint(void *soft_v, int UNUSED(cfra)) { SoftBody *soft= soft_v; return soft->totpoint; } /* Particle functions */ -static int ptcache_write_particle(int index, void *psys_v, void **data, int cfra) +void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, float time) +{ + PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, index, key->co); + PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, index, key->vel); + + /* no rotation info, so make something nice up */ + if(data[BPHYS_DATA_ROTATION]==NULL) { + vec_to_quat( key->rot, key->vel, OB_NEGX, OB_POSZ); + } + else { + PTCACHE_DATA_TO(data, BPHYS_DATA_ROTATION, index, key->rot); + } + + PTCACHE_DATA_TO(data, BPHYS_DATA_AVELOCITY, index, key->ave); + key->time = time; +} +static int ptcache_particle_write(int index, void *psys_v, void **data, int cfra) { ParticleSystem *psys= psys_v; ParticleData *pa = psys->particles + index; @@ -224,23 +244,7 @@ static int ptcache_write_particle(int index, void *psys_v, void **data, int cfra /* return flag 1+1=2 for newly born particles to copy exact birth location to previously cached frame */ return 1 + (pa->state.time >= pa->time && pa->prev_state.time <= pa->time); } -void BKE_ptcache_make_particle_key(ParticleKey *key, int index, void **data, float time) -{ - PTCACHE_DATA_TO(data, BPHYS_DATA_LOCATION, index, key->co); - PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, index, key->vel); - - /* no rotation info, so make something nice up */ - if(data[BPHYS_DATA_ROTATION]==NULL) { - vec_to_quat( key->rot, key->vel, OB_NEGX, OB_POSZ); - } - else { - PTCACHE_DATA_TO(data, BPHYS_DATA_ROTATION, index, key->rot); - } - - PTCACHE_DATA_TO(data, BPHYS_DATA_AVELOCITY, index, key->ave); - key->time = time; -} -static void ptcache_read_particle(int index, void *psys_v, void **data, float frs_sec, float cfra, float *old_data) +static void ptcache_particle_read(int index, void *psys_v, void **data, float frs_sec, float cfra, float *old_data) { ParticleSystem *psys= psys_v; ParticleData *pa; @@ -298,7 +302,7 @@ static void ptcache_read_particle(int index, void *psys_v, void **data, float fr vec_to_quat( pa->state.rot,pa->state.vel, OB_NEGX, OB_POSZ); } } -static void ptcache_interpolate_particle(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_particle_interpolate(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) { ParticleSystem *psys= psys_v; ParticleData *pa; @@ -360,12 +364,12 @@ static void ptcache_interpolate_particle(int index, void *psys_v, void **data, f pa->state.time = cfra; } -static int ptcache_totpoint_particle(void *psys_v, int UNUSED(cfra)) +static int ptcache_particle_totpoint(void *psys_v, int UNUSED(cfra)) { ParticleSystem *psys = psys_v; return psys->totpart; } -static int ptcache_totwrite_particle(void *psys_v, int cfra) +static int ptcache_particle_totwrite(void *psys_v, int cfra) { ParticleSystem *psys = psys_v; ParticleData *pa= psys->particles; @@ -378,134 +382,8 @@ static int ptcache_totwrite_particle(void *psys_v, int cfra) return totwrite; } -//static int ptcache_write_particle_stream(PTCacheFile *pf, PTCacheMem *pm, void *psys_v) -//{ -// ParticleSystem *psys= psys_v; -// ParticleData *pa = psys->particles; -// BoidParticle *boid = NULL; -// float times[3]; -// int i = 0; -// -// if(!pf && !pm) -// return 0; -// -// for(i=0; itotpart; i++, pa++) { -// -// if(data[BPHYS_DATA_INDEX]) { -// int step = psys->pointcache->step; -// /* No need to store unborn or died particles */ -// if(pa->time - step > pa->state.time || pa->dietime + step < pa->state.time) -// continue; -// } -// -// times[0] = pa->time; -// times[1] = pa->dietime; -// times[2] = pa->lifetime; -// -// PTCACHE_DATA_FROM(data, BPHYS_DATA_INDEX, &index); -// PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, pa->state.co); -// PTCACHE_DATA_FROM(data, BPHYS_DATA_VELOCITY, pa->state.vel); -// PTCACHE_DATA_FROM(data, BPHYS_DATA_ROTATION, pa->state.rot); -// PTCACHE_DATA_FROM(data, BPHYS_DATA_AVELOCITY, pa->state.ave); -// PTCACHE_DATA_FROM(data, BPHYS_DATA_SIZE, &pa->size); -// PTCACHE_DATA_FROM(data, BPHYS_DATA_TIMES, times); -// -// boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL; -// if(boid) -// PTCACHE_DATA_FROM(data, BPHYS_DATA_BOIDS, &boid->data); -// -// if(pf && !ptcache_file_write_data(pf)) -// return 0; -// -// if(pm) -// BKE_ptcache_mem_incr_pointers(pm); -// } -// -// return 1; -//} -//static void ptcache_read_particle_stream(PTCacheFile *pf, PTCacheMem *pm, void *psys_v, void **data, float frs_sec, float cfra, float *old_data) -//{ -// ParticleSystem *psys= psys_v; -// ParticleData *pa = psys->particles + index; -// BoidParticle *boid = (psys->part->phystype == PART_PHYS_BOIDS) ? pa->boid : NULL; -// -// if(cfra > pa->state.time) -// memcpy(&pa->prev_state, &pa->state, sizeof(ParticleKey)); -// -// if(old_data){ -// /* old format cache */ -// memcpy(&pa->state, old_data, sizeof(ParticleKey)); -// return; -// } -// -// BKE_ptcache_make_particle_key(&pa->state, 0, data, cfra); -// -// if(data[BPHYS_DATA_SIZE]) -// PTCACHE_DATA_TO(data, BPHYS_DATA_SIZE, 0, &pa->size); -// -// if(data[BPHYS_DATA_TIMES]) { -// float times[3]; -// PTCACHE_DATA_TO(data, BPHYS_DATA_TIMES, 0, ×); -// pa->time = times[0]; -// pa->dietime = times[1]; -// pa->lifetime = times[2]; -// } -// -// if(boid) -// PTCACHE_DATA_TO(data, BPHYS_DATA_BOIDS, 0, &boid->data); -// -// /* determine velocity from previous location */ -// if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { -// if(cfra > pa->prev_state.time) { -// sub_v3_v3v3(pa->state.vel, pa->state.co, pa->prev_state.co); -// mul_v3_fl(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); -// } -// else { -// sub_v3_v3v3(pa->state.vel, pa->prev_state.co, pa->state.co); -// mul_v3_fl(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); -// } -// } -// -// /* determine rotation from velocity */ -// if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_ROTATION]) { -// vec_to_quat( pa->state.rot,pa->state.vel, OB_POSX, OB_POSZ); -// } -//} -//static void ptcache_interpolate_particle_stream(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) -//{ -// ParticleSystem *psys= psys_v; -// ParticleData *pa = psys->particles + index; -// ParticleKey keys[4]; -// float dfra; -// -// cfra = MIN2(cfra, pa->dietime); -// cfra1 = MIN2(cfra1, pa->dietime); -// cfra2 = MIN2(cfra2, pa->dietime); -// -// if(cfra1 == cfra2) -// return; -// -// memcpy(keys+1, &pa->state, sizeof(ParticleKey)); -// if(old_data) -// memcpy(keys+2, old_data, sizeof(ParticleKey)); -// else -// BKE_ptcache_make_particle_key(keys+2, 0, data, cfra2); -// -// dfra = cfra2 - cfra1; -// -// mul_v3_fl(keys[1].vel, dfra / frs_sec); -// mul_v3_fl(keys[2].vel, dfra / frs_sec); -// -// psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1); -// interp_qt_qtqt(pa->state.rot, keys[1].rot,keys[2].rot, (cfra - cfra1) / dfra); -// -// mul_v3_fl(pa->state.vel, frs_sec / dfra); -// -// pa->state.time = cfra; -//} -// /* Cloth functions */ -static int ptcache_write_cloth(int index, void *cloth_v, void **data, int UNUSED(cfra)) +static int ptcache_cloth_write(int index, void *cloth_v, void **data, int UNUSED(cfra)) { ClothModifierData *clmd= cloth_v; Cloth *cloth= clmd->clothObject; @@ -517,7 +395,7 @@ static int ptcache_write_cloth(int index, void *cloth_v, void **data, int UNUSED return 1; } -static void ptcache_read_cloth(int index, void *cloth_v, void **data, float UNUSED(frs_sec), float UNUSED(cfra), float *old_data) +static void ptcache_cloth_read(int index, void *cloth_v, void **data, float UNUSED(frs_sec), float UNUSED(cfra), float *old_data) { ClothModifierData *clmd= cloth_v; Cloth *cloth= clmd->clothObject; @@ -534,7 +412,7 @@ static void ptcache_read_cloth(int index, void *cloth_v, void **data, float UNUS PTCACHE_DATA_TO(data, BPHYS_DATA_XCONST, 0, vert->xconst); } } -static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, float UNUSED(frs_sec), float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_cloth_interpolate(int index, void *cloth_v, void **data, float UNUSED(frs_sec), float cfra, float cfra1, float cfra2, float *old_data) { ClothModifierData *clmd= cloth_v; Cloth *cloth= clmd->clothObject; @@ -570,114 +448,14 @@ static void ptcache_interpolate_cloth(int index, void *cloth_v, void **data, flo /* should vert->xconst be interpolated somehow too? - jahka */ } -static int ptcache_totpoint_cloth(void *cloth_v, int UNUSED(cfra)) +static int ptcache_cloth_totpoint(void *cloth_v, int UNUSED(cfra)) { ClothModifierData *clmd= cloth_v; return clmd->clothObject ? clmd->clothObject->numverts : 0; } -/* Creating ID's */ -void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) -{ - memset(pid, 0, sizeof(PTCacheID)); - - pid->ob= ob; - pid->calldata= sb; - pid->type= PTCACHE_TYPE_SOFTBODY; - pid->cache= sb->pointcache; - pid->cache_ptr= &sb->pointcache; - pid->ptcaches= &sb->ptcaches; - pid->totpoint= pid->totwrite= ptcache_totpoint_softbody; - - pid->write_elem= ptcache_write_softbody; - pid->write_stream = NULL; - pid->read_stream = NULL; - pid->read_elem= ptcache_read_softbody; - pid->interpolate_elem= ptcache_interpolate_softbody; - - pid->write_header= ptcache_write_basic_header; - pid->read_header= ptcache_read_basic_header; - - pid->data_types= (1<info_types= 0; - - pid->stack_index = pid->cache->index; -} - -void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys) -{ - memset(pid, 0, sizeof(PTCacheID)); - - pid->ob= ob; - pid->calldata= psys; - pid->type= PTCACHE_TYPE_PARTICLES; - pid->stack_index= psys->pointcache->index; - pid->cache= psys->pointcache; - pid->cache_ptr= &psys->pointcache; - pid->ptcaches= &psys->ptcaches; - - if(psys->part->type != PART_HAIR) - pid->flag |= PTCACHE_VEL_PER_SEC; - - pid->write_elem= ptcache_write_particle; - pid->write_stream = NULL; - pid->read_stream = NULL; - pid->read_elem= ptcache_read_particle; - pid->interpolate_elem= ptcache_interpolate_particle; - - pid->totpoint= ptcache_totpoint_particle; - pid->totwrite= ptcache_totwrite_particle; - - pid->write_header= ptcache_write_basic_header; - pid->read_header= ptcache_read_basic_header; - - pid->data_types= (1<part->phystype == PART_PHYS_BOIDS) - pid->data_types|= (1<part->rotmode!=PART_ROT_VEL - || psys->part->avemode!=PART_AVE_SPIN || psys->part->avefac!=0.0f) - pid->data_types|= (1<part->flag & PART_ROT_DYN) - pid->data_types|= (1<info_types= (1<domain; - - if(sds->fluid) { - return sds->res[0]*sds->res[1]*sds->res[2]; - } - else - return 0; -} - -/* Smoke functions */ -#if 0 -static int ptcache_totpoint_smoke_turbulence(void *smoke_v, int UNUSED(cfra)) -{ - SmokeModifierData *smd= (SmokeModifierData *)smoke_v; - SmokeDomainSettings *sds = smd->domain; - - if(sds->wt) { - return sds->res_wt[0]*sds->res_wt[1]*sds->res_wt[2]; - } - else - return 0; -} -#endif - -// forward decleration -static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size); - -static int ptcache_compress_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode) +static int ptcache_compress_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode) { int r = 0; unsigned char compressed = 0; @@ -731,7 +509,66 @@ static int ptcache_compress_write(PTCacheFile *pf, unsigned char *in, unsigned i return r; } -static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v) +static int ptcache_compress_read(PTCacheFile *pf, unsigned char *result, unsigned int len) +{ + int r = 0; + unsigned char compressed = 0; + unsigned int in_len; +#ifdef WITH_LZO + unsigned int out_len = len; + size_t sizeOfIt = 5; +#endif + unsigned char *in; + unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); + + ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char)); + if(compressed) { + ptcache_file_read(pf, &in_len, 1, sizeof(unsigned int)); + if(in_len==0) { + /* do nothing */ + } + else { + in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer"); + ptcache_file_read(pf, in, in_len, sizeof(unsigned char)); +#ifdef WITH_LZO + if(compressed == 1) + r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL); +#endif +#ifdef WITH_LZMA + if(compressed == 2) + { + size_t leni = in_len, leno = out_len; + ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int)); + ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char)); + r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt); + } +#endif + MEM_freeN(in); + } + } + else { + ptcache_file_read(pf, result, len, sizeof(unsigned char)); + } + + MEM_freeN(props); + + return r; +} + +static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra)) +{ + SmokeModifierData *smd= (SmokeModifierData *)smoke_v; + SmokeDomainSettings *sds = smd->domain; + + if(sds->fluid) { + return sds->res[0]*sds->res[1]*sds->res[2]; + } + else + return 0; +} + + +static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; SmokeDomainSettings *sds = smd->domain; @@ -807,56 +644,8 @@ static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v) } -// forward decleration -static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size); - -static int ptcache_compress_read(PTCacheFile *pf, unsigned char *result, unsigned int len) -{ - int r = 0; - unsigned char compressed = 0; - unsigned int in_len; -#ifdef WITH_LZO - unsigned int out_len = len; - size_t sizeOfIt = 5; -#endif - unsigned char *in; - unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); - - ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char)); - if(compressed) { - ptcache_file_read(pf, &in_len, 1, sizeof(unsigned int)); - if(in_len==0) { - /* do nothing */ - } - else { - in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer"); - ptcache_file_read(pf, in, in_len, sizeof(unsigned char)); -#ifdef WITH_LZO - if(compressed == 1) - r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL); -#endif -#ifdef WITH_LZMA - if(compressed == 2) - { - size_t leni = in_len, leno = out_len; - ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int)); - ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char)); - r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt); - } -#endif - MEM_freeN(in); - } - } - else { - ptcache_file_read(pf, result, len, sizeof(unsigned char)); - } - - MEM_freeN(props); - - return r; -} -static void ptcache_read_smoke(PTCacheFile *pf, void *smoke_v) +static void ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; SmokeDomainSettings *sds = smd->domain; @@ -907,6 +696,102 @@ static void ptcache_read_smoke(PTCacheFile *pf, void *smoke_v) } } +/* Creating ID's */ +void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) +{ + memset(pid, 0, sizeof(PTCacheID)); + + pid->ob= ob; + pid->calldata= sb; + pid->type= PTCACHE_TYPE_SOFTBODY; + pid->cache= sb->pointcache; + pid->cache_ptr= &sb->pointcache; + pid->ptcaches= &sb->ptcaches; + pid->totpoint= pid->totwrite= ptcache_softbody_totpoint; + + pid->write_elem= ptcache_softbody_write; + pid->write_stream = NULL; + pid->read_stream = NULL; + pid->read_elem= ptcache_softbody_read; + pid->interpolate_elem= ptcache_softbody_interpolate; + + pid->write_header= ptcache_basic_header_write; + pid->read_header= ptcache_basic_header_read; + + pid->data_types= (1<info_types= 0; + + pid->stack_index = pid->cache->index; +} + +void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys) +{ + memset(pid, 0, sizeof(PTCacheID)); + + pid->ob= ob; + pid->calldata= psys; + pid->type= PTCACHE_TYPE_PARTICLES; + pid->stack_index= psys->pointcache->index; + pid->cache= psys->pointcache; + pid->cache_ptr= &psys->pointcache; + pid->ptcaches= &psys->ptcaches; + + if(psys->part->type != PART_HAIR) + pid->flag |= PTCACHE_VEL_PER_SEC; + + pid->write_elem= ptcache_particle_write; + pid->write_stream = NULL; + pid->read_stream = NULL; + pid->read_elem= ptcache_particle_read; + pid->interpolate_elem= ptcache_particle_interpolate; + + pid->totpoint= ptcache_particle_totpoint; + pid->totwrite= ptcache_particle_totwrite; + + pid->write_header= ptcache_basic_header_write; + pid->read_header= ptcache_basic_header_read; + + pid->data_types= (1<part->phystype == PART_PHYS_BOIDS) + pid->data_types|= (1<part->rotmode!=PART_ROT_VEL + || psys->part->avemode!=PART_AVE_SPIN || psys->part->avefac!=0.0f) + pid->data_types|= (1<part->flag & PART_ROT_DYN) + pid->data_types|= (1<info_types= (1<ob= ob; + pid->calldata= clmd; + pid->type= PTCACHE_TYPE_CLOTH; + pid->stack_index= clmd->point_cache->index; + pid->cache= clmd->point_cache; + pid->cache_ptr= &clmd->point_cache; + pid->ptcaches= &clmd->ptcaches; + pid->totpoint= pid->totwrite= ptcache_cloth_totpoint; + + pid->write_elem= ptcache_cloth_write; + pid->write_stream = NULL; + pid->read_stream = NULL; + pid->read_elem= ptcache_cloth_read; + pid->interpolate_elem= ptcache_cloth_interpolate; + + pid->write_header= ptcache_basic_header_write; + pid->read_header= ptcache_basic_header_read; + + pid->data_types= (1<info_types= 0; +} + void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd) { SmokeDomainSettings *sds = smd->domain; @@ -923,18 +808,18 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo pid->cache_ptr= &(sds->point_cache[0]); pid->ptcaches= &(sds->ptcaches[0]); - pid->totpoint= pid->totwrite= ptcache_totpoint_smoke; + pid->totpoint= pid->totwrite= ptcache_smoke_totpoint; pid->write_elem= NULL; pid->read_elem= NULL; - pid->read_stream = ptcache_read_smoke; - pid->write_stream = ptcache_write_smoke; + pid->read_stream = ptcache_smoke_read; + pid->write_stream = ptcache_smoke_write; pid->interpolate_elem= NULL; - pid->write_header= ptcache_write_basic_header; - pid->read_header= ptcache_read_basic_header; + pid->write_header= ptcache_basic_header_write; + pid->read_header= ptcache_basic_header_read; pid->data_types= 0; pid->info_types= 0; @@ -945,32 +830,6 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo pid->data_types |= (1<ob= ob; - pid->calldata= clmd; - pid->type= PTCACHE_TYPE_CLOTH; - pid->stack_index= clmd->point_cache->index; - pid->cache= clmd->point_cache; - pid->cache_ptr= &clmd->point_cache; - pid->ptcaches= &clmd->ptcaches; - pid->totpoint= pid->totwrite= ptcache_totpoint_cloth; - - pid->write_elem= ptcache_write_cloth; - pid->write_stream = NULL; - pid->read_stream = NULL; - pid->read_elem= ptcache_read_cloth; - pid->interpolate_elem= ptcache_interpolate_cloth; - - pid->write_header= ptcache_write_basic_header; - pid->read_header= ptcache_read_basic_header; - - pid->data_types= (1<info_types= 0; -} - void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int duplis) { PTCacheID *pid; @@ -1090,7 +949,7 @@ static int ptcache_path(PTCacheID *pid, char *filename) return BLI_add_slash(filename); /* new strlen() */ } -static int BKE_ptcache_id_filename(PTCacheID *pid, char *filename, int cfra, short do_path, short do_ext) +static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_path, short do_ext) { int len=0; char *idname; @@ -1155,7 +1014,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) #endif if (!G.relbase_valid && (pid->cache->flag & PTCACHE_EXTERNAL)==0) return NULL; /* save blend file before using disk pointcache */ - BKE_ptcache_id_filename(pid, filename, cfra, 1, 1); + ptcache_filename(pid, filename, cfra, 1, 1); if (mode==PTCACHE_FILE_READ) { if (!BLI_exists(filename)) { @@ -1175,6 +1034,7 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) pf= MEM_mallocN(sizeof(PTCacheFile), "PTCacheFile"); pf->fp= fp; + pf->old_format = 0; return pf; } @@ -1193,7 +1053,7 @@ static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size) { return (fwrite(f, size, tot, pf->fp) == tot); } -static int ptcache_file_read_data(PTCacheFile *pf) +static int ptcache_file_data_read(PTCacheFile *pf) { int i; @@ -1204,7 +1064,7 @@ static int ptcache_file_read_data(PTCacheFile *pf) return 1; } -static int ptcache_file_write_data(PTCacheFile *pf) +static int ptcache_file_data_write(PTCacheFile *pf) { int i; @@ -1215,7 +1075,7 @@ static int ptcache_file_write_data(PTCacheFile *pf) return 1; } -static int ptcache_file_read_header_begin(PTCacheFile *pf) +static int ptcache_file_header_begin_read(PTCacheFile *pf) { int error=0; char bphysics[8]; @@ -1239,7 +1099,7 @@ static int ptcache_file_read_header_begin(PTCacheFile *pf) } -static int ptcache_file_write_header_begin(PTCacheFile *pf) +static int ptcache_file_header_begin_write(PTCacheFile *pf) { const char *bphysics = "BPHYSICS"; @@ -1259,7 +1119,7 @@ int BKE_ptcache_data_size(int data_type) return ptcache_data_size[data_type]; } -static void ptcache_file_init_pointers(PTCacheFile *pf) +static void ptcache_file_pointers_init(PTCacheFile *pf) { int data_types = pf->data_types; @@ -1273,7 +1133,7 @@ static void ptcache_file_init_pointers(PTCacheFile *pf) pf->cur[BPHYS_DATA_BOIDS] = (data_types & (1<data.boids : NULL; } -static void ptcache_file_seek_pointers(int index, PTCacheFile *pf) +static void ptcache_file_pointers_seek(int index, PTCacheFile *pf) { int i, size=0; int data_types = pf->data_types; @@ -1303,9 +1163,9 @@ static void ptcache_file_seek_pointers(int index, PTCacheFile *pf) fseek(pf->fp, 8 + 3*sizeof(int) + index * size, SEEK_SET); } - ptcache_file_init_pointers(pf); + ptcache_file_pointers_init(pf); } -void BKE_ptcache_mem_init_pointers(PTCacheMem *pm) +void BKE_ptcache_mem_pointers_init(PTCacheMem *pm) { int data_types = pm->data_types; int i; @@ -1314,7 +1174,7 @@ void BKE_ptcache_mem_init_pointers(PTCacheMem *pm) pm->cur[i] = ((data_types & (1<data[i] : NULL); } -void BKE_ptcache_mem_incr_pointers(PTCacheMem *pm) +void BKE_ptcache_mem_pointers_incr(PTCacheMem *pm) { int i; @@ -1323,7 +1183,7 @@ void BKE_ptcache_mem_incr_pointers(PTCacheMem *pm) pm->cur[i] = (char*)pm->cur[i] + ptcache_data_size[i]; } } -int BKE_ptcache_mem_seek_pointers(int point_index, PTCacheMem *pm) +int BKE_ptcache_mem_pointers_seek(int point_index, PTCacheMem *pm) { int data_types = pm->data_types; int i, index = pm->index_array ? pm->index_array[point_index] - 1 : point_index; @@ -1342,7 +1202,7 @@ int BKE_ptcache_mem_seek_pointers(int point_index, PTCacheMem *pm) return 1; } -static void ptcache_alloc_data(PTCacheMem *pm) +static void ptcache_data_alloc(PTCacheMem *pm) { int data_types = pm->data_types; int totpoint = pm->totpoint; @@ -1353,7 +1213,7 @@ static void ptcache_alloc_data(PTCacheMem *pm) pm->data[i] = MEM_callocN(totpoint * ptcache_data_size[i], "PTCache Data"); } } -static void ptcache_free_data(PTCacheMem *pm) +static void ptcache_data_free(PTCacheMem *pm) { void **data = pm->data; int i; @@ -1368,7 +1228,7 @@ static void ptcache_free_data(PTCacheMem *pm) pm->index_array = NULL; } } -static void ptcache_copy_data(void *from[], void *to[]) +static void ptcache_data_copy(void *from[], void *to[]) { int i; for(i=0; itype==PTCACHE_TYPE_SOFTBODY) return 6 * sizeof(float); @@ -1393,268 +1253,302 @@ static int ptcache_pid_old_elemsize(PTCacheID *pid) return 0; } -/* reads cache from disk or memory */ -/* possible to get old or interpolated result */ -int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) +static void *ptcache_find_frame(PTCacheID *pid, int frame) { - PTCacheFile *pf=NULL, *pf2=NULL; - PTCacheMem *pm=NULL, *pm2=NULL; - float old_data1[14], old_data2[14]; - int cfrai = (int)cfra; - int old_elemsize = ptcache_pid_old_elemsize(pid); - int i; - - int cfra1 = 0, cfra2 = 0; - int totpoint = 0, totpoint2 = 0; - int *index = &i, *index2 = &i; - int use_old = 0, old_frame = 0; - - int ret = 0, error = 0; - - /* nothing to read to */ - if(pid->totpoint(pid->calldata, (int)cfra) == 0) - return 0; - - if(pid->cache->flag & PTCACHE_READ_INFO) { - pid->cache->flag &= ~PTCACHE_READ_INFO; - BKE_ptcache_read_cache(pid, 0, frs_sec); + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, frame); + if(pf) + pf->frame = frame; + return pf; } - - - /* first check if we have the actual frame cached */ - if(cfra == (float)cfrai) { - if(pid->cache->flag & PTCACHE_DISK_CACHE) { - pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); - } - else { - pm = pid->cache->mem_cache.first; - - for(; pm; pm=pm->next) { - if(pm->frame == cfrai) - break; - } + else { + PTCacheMem *pm = pid->cache->mem_cache.first; + for(; pm; pm=pm->next) { + if(pm->frame == frame) + break; } + return (void*)pm; } +} - /* no exact cache frame found so try to find cached frames around cfra */ - if(!pm && !pf) { - if(pid->cache->flag & PTCACHE_DISK_CACHE) { - pf=NULL; - while(cfrai >= pid->cache->startframe && !pf) { - cfrai--; - pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); - cfra1 = cfrai; - } +static void ptcache_find_frames_around(PTCacheID *pid, int frame, void **cache1, void **cache2) +{ + int cfra1=frame, cfra2=frame; - old_frame = cfrai; + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + PTCacheFile *pf=NULL; + PTCacheFile *pf2=NULL; - cfrai = (int)cfra; - while(cfrai < pid->cache->endframe && !pf2) { - cfrai++; - pf2= ptcache_file_open(pid, PTCACHE_FILE_READ, cfrai); - cfra2 = cfrai; - } + while(cfra1 >= pid->cache->startframe && pf==NULL) { + cfra1--; + pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cfra1); + } - if(pf && !pf2) { - pf2 = pf; - pf = NULL; - } + if(pf) + pf->frame = cfra1; + + while(cfra2 < pid->cache->endframe && !pf2) { + cfra2++; + pf2= ptcache_file_open(pid, PTCACHE_FILE_READ, cfra2); } - else if(pid->cache->mem_cache.first){ - pm = pid->cache->mem_cache.first; - while(pm->next && pm->next->frame < cfra) - pm= pm->next; + if(pf2) + pf2->frame = cfra2; - if(pm) { - old_frame = pm->frame; - cfra1 = pm->frame; - } + if(pf && !pf2) { + pf2 = pf; + pf = NULL; + } - pm2 = pid->cache->mem_cache.last; + *cache1 = (void*)pf; + *cache2 = (void*)pf2; + } + else if(pid->cache->mem_cache.first){ + PTCacheMem *pm = pid->cache->mem_cache.first; + PTCacheMem *pm2 = pid->cache->mem_cache.last; - if(pm2 && pm2->frame < cfra) - pm2 = NULL; - else { - while(pm2->prev && pm2->prev->frame > cfra) - pm2= pm2->prev; + while(pm->next && pm->next->frame < frame) + pm= pm->next; - if(pm2) - cfra2 = pm2->frame; - } + if(pm2 && pm2->frame < frame) + pm2 = NULL; + else { + while(pm2->prev && pm2->prev->frame > frame) + pm2= pm2->prev; + } - if(pm && !pm2) { - pm2 = pm; - pm = NULL; - } + if(pm && !pm2) { + pm2 = pm; + pm = NULL; } - } - if(!pm && !pm2 && !pf && !pf2) + *cache1 = (void*)pm; + *cache2 = (void*)pm2; + } +} +static int ptcache_read_init(PTCacheID *pid, void **cache, int *totpoint) +{ + if(*cache==NULL) return 0; - if(pm) { - BKE_ptcache_mem_init_pointers(pm); - totpoint = pm->totpoint; - index = ((pm->data_types & (1<cur[BPHYS_DATA_INDEX] : &i); - } - if(pm2) { - BKE_ptcache_mem_init_pointers(pm2); - totpoint2 = pm2->totpoint; - index2 = ((pm2->data_types & (1<cur[BPHYS_DATA_INDEX] : &i); - } - if(pf) { - if(ptcache_file_read_header_begin(pf)) { + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + PTCacheFile *pf = (PTCacheFile *)(*cache); + + if(ptcache_file_header_begin_read(pf)) { if(pf->type != pid->type) { /* todo report error */ ptcache_file_close(pf); - pf = NULL; + *cache = NULL; + return 0; } else if(pid->read_header(pf)) { - ptcache_file_init_pointers(pf); - totpoint = pf->totpoint; - index = ((pf->data_types & (1<data.index : &i); + ptcache_file_pointers_init(pf); + *totpoint = pf->totpoint; } } else { /* fall back to old cache file format */ - use_old = 1; - totpoint = pid->totpoint(pid->calldata, (int) cfra); + pf->old_format = 1; + *totpoint = pid->totpoint(pid->calldata, (int) pf->frame); } + return pf->frame; } - if(pf2) { - if(ptcache_file_read_header_begin(pf2)) { - if(pf2->type != pid->type) { - /* todo report error */ - ptcache_file_close(pf2); - pf2 = NULL; + else { + PTCacheMem *pm = (PTCacheMem *)(*cache); + + BKE_ptcache_mem_pointers_init(pm); + *totpoint = pm->totpoint; + return pm->frame; + } +} +static int ptcache_read(PTCacheID *pid, void *cache, int totpoint, float frs_sec) +{ + int i; + int *index = &i; + + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + PTCacheFile *pf = (PTCacheFile *)cache; + if(pf->old_format) { + int old_elemsize = ptcache_old_elemsize(pid); + float old_data[14]; + + for(i=0; iread_elem(i, pid->calldata, NULL, frs_sec, (float)pf->frame, old_data); + else + return 0; + } + } + else { + if(pf->data_types & (1<data.index; + + for(i=0; iread_elem(*index, pid->calldata, pf->cur, frs_sec, (float)pf->frame, NULL); + else + return 0; } - else if(pid->read_header(pf2)) { - ptcache_file_init_pointers(pf2); - totpoint2 = pf2->totpoint; - index2 = ((pf2->data_types & (1<data.index : &i); + } + } + else { + PTCacheMem *pm = (PTCacheMem *)cache; + + for(i=0; idata_types & (1<cur[BPHYS_DATA_INDEX]; + + pid->read_elem(*index, pid->calldata, pm->cur, frs_sec, (float)pm->frame, NULL); + + BKE_ptcache_mem_pointers_incr(pm); + } + } + + return 1; +} +static int ptcache_interpolate(PTCacheID *pid, void *cache1, void *cache2, int totpoint, float cfra, float frs_sec) +{ + int i; + int *index = &i; + + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + PTCacheFile *pf1 = (PTCacheFile *)cache1; + PTCacheFile *pf2 = (PTCacheFile *)cache2; + if(pf2->old_format) { + int old_elemsize = ptcache_old_elemsize(pid); + float old_data[14]; + + for(i=0; iinterpolate_elem(i, pid->calldata, NULL, frs_sec, cfra, (float)pf1->frame, (float)pf2->frame, old_data); + else + return 0; } } else { - /* fall back to old cache file format */ - use_old = 1; - totpoint2 = pid->totpoint(pid->calldata, (int) cfra); + if(pf2->data_types & (1<data.index; + + for(i=0; iinterpolate_elem(*index, pid->calldata, pf2->cur, frs_sec, cfra, (float)pf1->frame, (float)pf2->frame, NULL); + else + return 0; + } + } + } + else { + PTCacheMem *pm1 = (PTCacheMem *)cache1; + PTCacheMem *pm2 = (PTCacheMem *)cache2; + + for(i=0; idata_types & (1<cur[BPHYS_DATA_INDEX]; + + pid->interpolate_elem(*index, pid->calldata, pm2->cur, frs_sec, cfra, (float)pm1->frame, (float)pm2->frame, NULL); + BKE_ptcache_mem_pointers_incr(pm2); } } + return 1; +} +/* reads cache from disk or memory */ +/* possible to get old or interpolated result */ +int BKE_ptcache_read(PTCacheID *pid, float cfra, float frs_sec) +{ + void *cache1=NULL, *cache2=NULL; + int cfrai = (int)cfra, cfra1=0, cfra2=0; + int totpoint = 0, totpoint2 = 0; + int ret = 0; + + /* nothing to read to */ + if(pid->totpoint(pid->calldata, cfrai) == 0) + return 0; + + if(pid->cache->flag & PTCACHE_READ_INFO) { + pid->cache->flag &= ~PTCACHE_READ_INFO; + BKE_ptcache_read(pid, 0, frs_sec); + } + + /* first check if we have the actual frame cached */ + if(cfra == (float)cfrai) + cache1 = ptcache_find_frame(pid, cfrai); + + /* no exact cache frame found so try to find cached frames around cfra */ + if(cache1==NULL) + ptcache_find_frames_around(pid, cfrai, &cache1, &cache2); + + if(cache1==NULL && cache2==NULL) + return 0; + + cfra1 = ptcache_read_init(pid, &cache1, &totpoint); + cfra2 = ptcache_read_init(pid, &cache2, &totpoint2); + /* don't read old cache if already simulated past cached frame */ - if(!pm && !pf && cfra1 && cfra1 <= pid->cache->simframe) - error = 1; + if(!cache1 && cfra1 && cfra1 <= pid->cache->simframe) + goto cleanup; if(cfra1 && cfra1==cfra2) - error = 1; + goto cleanup; - if(!error) - { - if(pf && pid->read_stream) { + if(cache1) { + if(pid->read_stream) { if(totpoint != pid->totpoint(pid->calldata, (int) cfra)) - error = 1; + goto cleanup; else { - // we have stream writing here - pid->read_stream(pf, pid->calldata); + // we have stream reading here + pid->read_stream((PTCacheFile *)cache1, pid->calldata); } } - } - - if((pid->data_types & (1<totpoint(pid->calldata, (int) cfra)); - - if(!error) - { - for(i=0; iread_elem && ptcache_file_read(pf, (void*)old_data1, 1, old_elemsize)) - pid->read_elem(i, pid->calldata, NULL, frs_sec, cfra, old_data1); - else if(pid->read_elem) - { error = 1; break; } - } - else { - if(pid->read_elem && (pm || ptcache_file_read_data(pf))) - pid->read_elem(*index, pid->calldata, (pm ? pm->cur : pf->cur), frs_sec, (cfra1 ? (float)cfra1 : (float)cfrai), NULL); - else if(pid->read_elem) - { error = 1; break; } - } + else if(pid->read_elem) { + if((pid->data_types & (1<totpoint(pid->calldata, (int) cfra)); - if(pm) { - BKE_ptcache_mem_incr_pointers(pm); - index = ((pm->data_types & (1<cur[BPHYS_DATA_INDEX] : &i); - } + if(ptcache_read(pid, cache1, totpoint, frs_sec)==0) + goto cleanup; } } - if(!error) - { - if(pf2 && pid->read_stream) { + if(cache2) { + if(pid->read_stream) { if(totpoint2 != pid->totpoint(pid->calldata, (int) cfra)) - error = 1; + goto cleanup; else { - // we have stream writing here - pid->read_stream(pf2, pid->calldata); + // we have stream reading here + pid->read_stream((PTCacheFile *)cache2, pid->calldata); } } - } - - if((pid->data_types & (1<totpoint(pid->calldata, (int) cfra)); + else if(pid->read_elem) { + if((pid->data_types & (1<totpoint(pid->calldata, (int) cfra)); - if(!error) - { - for(i=0; iread_elem && ptcache_file_read(pf2, (void*)old_data2, 1, old_elemsize)) { - if(!pf && pf2) - pid->read_elem(i, pid->calldata, NULL, frs_sec, (float)cfra2, old_data2); - else if(pid->interpolate_elem) - pid->interpolate_elem(i, pid->calldata, NULL, frs_sec, cfra, (float)cfra1, (float)cfra2, old_data2); - else - { error = 1; break; } - } - else if(pid->read_elem) - { error = 1; break; } + if(cache1 && cache2 && pid->interpolate_elem) { + if(ptcache_interpolate(pid, cache1, cache2, totpoint2, cfra, frs_sec)==0) + goto cleanup; } else { - if(pid->read_elem && (pm2 || ptcache_file_read_data(pf2))) { - if((!pf && pf2) || (!pm && pm2)) - pid->read_elem(*index2, pid->calldata, pm2 ? pm2->cur : pf2->cur, frs_sec, (float)cfra2, NULL); - else if(pid->interpolate_elem) - pid->interpolate_elem(*index2, pid->calldata, pm2 ? pm2->cur : pf2->cur, frs_sec, cfra, (float)cfra1, (float)cfra2, NULL); - else - { error = 1; break; } - } - else if(pid->read_elem) - { error = 1; break; } - } - - if(pm2) { - BKE_ptcache_mem_incr_pointers(pm2); - index2 = ((pm2->data_types & (1<cur[BPHYS_DATA_INDEX] : &i); + if(ptcache_read(pid, cache2, totpoint2, frs_sec)==0) + goto cleanup; } } } - if(pm || pf) - ret = ((pm2 || pf2) ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT); - else if(pm2 || pf2) { + if(cache1) + ret = (cache2 ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT); + else if(cache2) { ret = PTCACHE_READ_OLD; - pid->cache->simframe = old_frame; + pid->cache->simframe = ((pid->cache->flag & PTCACHE_DISK_CACHE) ? + ((PTCacheFile*)cache2)->frame : ((PTCacheMem*)cache2)->frame); } - if(pf) { - ptcache_file_close(pf); - pf = NULL; - } +cleanup: - if(pf2) { - ptcache_file_close(pf2); - pf = NULL; + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + if(cache1) + ptcache_file_close((PTCacheFile*)cache1); + if(cache2) + ptcache_file_close((PTCacheFile*)cache2); } if((pid->cache->flag & PTCACHE_QUICK_CACHE)==0) { @@ -1671,9 +1565,8 @@ int BKE_ptcache_read_cache(PTCacheID *pid, float cfra, float frs_sec) } } - return (error ? 0 : ret); + return ret; } -/* TODO for later */ static void ptcache_make_index_array(PTCacheMem *pm, int totpoint) { int i, *index; @@ -1692,187 +1585,174 @@ static void ptcache_make_index_array(PTCacheMem *pm, int totpoint) for(i=0; itotpoint; i++, index++) pm->index_array[*index] = i + 1; } + +static int ptcache_write_needed(PTCacheID *pid, int cfra, int *overwrite) +{ + PointCache *cache = pid->cache; + int ofra = 0, efra = cache->endframe; + + /* allways start from scratch on the first frame */ + if(cfra && cfra == cache->startframe) { + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, cfra); + cache->flag &= ~PTCACHE_REDO_NEEDED; + return 1; + } + + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + if(cfra==0 && cache->startframe > 0) + return 1; + + /* find last cached frame */ + while(efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra)) + efra--; + + /* find second last cached frame */ + ofra = efra-1; + while(ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra)) + ofra--; + } + else { + PTCacheMem *pm = cache->mem_cache.last; + /* don't write info file in memory */ + if(cfra == 0) + return 0; + + if(pm == NULL) + return 1; + + efra = pm->frame; + ofra = (pm->prev ? pm->prev->frame : efra - cache->step); + } + + if(efra >= cache->startframe && cfra > efra) { + if(ofra >= cache->startframe && efra - ofra < cache->step) { + /* overwrite previous frame */ + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, efra); + *overwrite = 1; + } + return 1; + } + + return 0; +} /* writes cache to disk or memory */ -int BKE_ptcache_write_cache(PTCacheID *pid, int cfra) +int BKE_ptcache_write(PTCacheID *pid, int cfra) { PointCache *cache = pid->cache; PTCacheFile *pf= NULL, *pf2= NULL; - int i; + int i, ret = 0; int totpoint = pid->totpoint(pid->calldata, cfra); - int add = 0, overwrite = 0; + int overwrite = 0; if(totpoint == 0 || (cfra ? pid->data_types == 0 : pid->info_types == 0)) return 0; - if(cache->flag & PTCACHE_DISK_CACHE) { - int ofra=0, efra = cache->endframe; - - if(cfra==0 && cache->startframe > 0) - add = 1; - /* allways start from scratch on the first frame */ - else if(cfra == cache->startframe) { - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, cfra); - cache->flag &= ~PTCACHE_REDO_NEEDED; - add = 1; - } - else { - /* find last cached frame */ - while(efra > cache->startframe && !BKE_ptcache_id_exist(pid, efra)) - efra--; - - /* find second last cached frame */ - ofra = efra-1; - while(ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra)) - ofra--; - - if(efra >= cache->startframe && cfra > efra) { - if(ofra >= cache->startframe && efra - ofra < cache->step) - overwrite = 1; - else - add = 1; - } - } - - if(add || overwrite) { - if(overwrite) - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, efra); + if(ptcache_write_needed(pid, cfra, &overwrite)==0) + return 0; - pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra); - if(!pf) - return 0; + if(cache->flag & PTCACHE_DISK_CACHE) { + pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra); + if(!pf) + goto cleanup; - pf->type = pid->type; - pf->totpoint = cfra ? pid->totwrite(pid->calldata, cfra) : totpoint; - pf->data_types = cfra ? pid->data_types : pid->info_types; + pf->type = pid->type; + pf->totpoint = cfra ? pid->totwrite(pid->calldata, cfra) : totpoint; + pf->data_types = cfra ? pid->data_types : pid->info_types; - if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) { - ptcache_file_close(pf); - return 0; - } + if(!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)) + goto cleanup; - ptcache_file_init_pointers(pf); + ptcache_file_pointers_init(pf); - if(pf && pid->write_stream) { - // we have stream writing here - pid->write_stream(pf, pid->calldata); - } - else - for(i=0; iwrite_elem) { - int write = pid->write_elem(i, pid->calldata, pf->cur, cfra); - if(write) { - if(!ptcache_file_write_data(pf)) { - ptcache_file_close(pf); - if(pf2) ptcache_file_close(pf2); - return 0; - } - /* newly born particles have to be copied to previous cached frame */ - else if(overwrite && write == 2) { - if(!pf2) { - pf2 = ptcache_file_open(pid, PTCACHE_FILE_UPDATE, ofra); - if(!pf2) { - ptcache_file_close(pf); - return 0; - } - pf2->type = pid->type; - pf2->totpoint = totpoint; - pf2->data_types = pid->data_types; - } - ptcache_file_seek_pointers(i, pf2); - pid->write_elem(i, pid->calldata, pf2->cur, cfra); - if(!ptcache_file_write_data(pf2)) { - ptcache_file_close(pf); - ptcache_file_close(pf2); - return 0; - } - } + if(pid->write_stream) { + // we have stream writing here + pid->write_stream(pf, pid->calldata); + } + else if(pid->write_elem){ + for(i=0; iwrite_elem(i, pid->calldata, pf->cur, cfra); + if(write) { + if(!ptcache_file_data_write(pf)) + goto cleanup; + + /* newly born particles have to be copied to previous cached frame */ + if(overwrite && write == 2) { + if(!pf2) { + /* find and initialize previous frame */ + int ofra = cfra-1; + while(ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra)) + ofra--; + + pf2 = ptcache_file_open(pid, PTCACHE_FILE_UPDATE, ofra); + if(!pf2) + goto cleanup; + + pf2->type = pid->type; + pf2->totpoint = totpoint; + pf2->data_types = pid->data_types; } + ptcache_file_pointers_seek(i, pf2); + pid->write_elem(i, pid->calldata, pf2->cur, cfra); + if(!ptcache_file_data_write(pf2)) + goto cleanup; } } + } } } else { PTCacheMem *pm; PTCacheMem *pm2; - pm2 = cache->mem_cache.first; - - /* don't write info file in memory */ - if(cfra==0) - return 1; - /* allways start from scratch on the first frame */ - if(cfra == cache->startframe) { - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, cfra); - cache->flag &= ~PTCACHE_REDO_NEEDED; - add = 1; - } - else if (cache->mem_cache.last) { - pm2 = cache->mem_cache.last; - - if(pm2 && cfra > pm2->frame) { - if(pm2->prev && pm2->frame - pm2->prev->frame < cache->step) - overwrite = 1; - else - add = 1; - } - } - else - add = 1; - - if(add || overwrite) { - if(overwrite) - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, pm2->frame); + pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); - pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); - - pm->totpoint = pid->totwrite(pid->calldata, cfra); - pm->data_types = cfra ? pid->data_types : pid->info_types; + pm->totpoint = pid->totwrite(pid->calldata, cfra); + pm->data_types = cfra ? pid->data_types : pid->info_types; - ptcache_alloc_data(pm); - BKE_ptcache_mem_init_pointers(pm); + ptcache_data_alloc(pm); + BKE_ptcache_mem_pointers_init(pm); + if(pid->write_elem) { for(i=0; iwrite_elem) { - int write = pid->write_elem(i, pid->calldata, pm->cur, cfra); - if(write) { - BKE_ptcache_mem_incr_pointers(pm); - - /* newly born particles have to be copied to previous cached frame */ - if(overwrite && write == 2) { - pm2 = cache->mem_cache.last; - if(BKE_ptcache_mem_seek_pointers(i, pm2)) - pid->write_elem(i, pid->calldata, pm2->cur, cfra); - } + int write = pid->write_elem(i, pid->calldata, pm->cur, cfra); + if(write) { + BKE_ptcache_mem_pointers_incr(pm); + + /* newly born particles have to be copied to previous cached frame */ + if(overwrite && write == 2) { + pm2 = cache->mem_cache.last; + if(BKE_ptcache_mem_pointers_seek(i, pm2)) + pid->write_elem(i, pid->calldata, pm2->cur, cfra); } } } - ptcache_make_index_array(pm, pid->totpoint(pid->calldata, cfra)); - - pm->frame = cfra; - BLI_addtail(&cache->mem_cache, pm); } + ptcache_make_index_array(pm, pid->totpoint(pid->calldata, cfra)); + + pm->frame = cfra; + BLI_addtail(&cache->mem_cache, pm); } - if(add || overwrite) { - if(cfra - cache->last_exact == 1 - || cfra == cache->startframe) { - cache->last_exact = cfra; - cache->flag &= ~PTCACHE_FRAMES_SKIPPED; - } - else - cache->flag |= PTCACHE_FRAMES_SKIPPED; + if(cfra - cache->last_exact == 1 || cfra == cache->startframe) { + cache->last_exact = cfra; + cache->flag &= ~PTCACHE_FRAMES_SKIPPED; } + else + cache->flag |= PTCACHE_FRAMES_SKIPPED; if(cache->cached_frames) cache->cached_frames[cfra-cache->startframe] = 1; - + + ret = 1; + +cleanup: if(pf) ptcache_file_close(pf); if(pf2) ptcache_file_close(pf2); BKE_ptcache_update_info(pid); - return 1; + return ret; } /* youll need to close yourself after! * mode - PTCACHE_CLEAR_ALL, @@ -1915,7 +1795,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) if(pid->cache->flag & PTCACHE_DISK_CACHE) { ptcache_path(pid, path); - len = BKE_ptcache_id_filename(pid, filename, cfra, 0, 0); /* no path */ + len = ptcache_filename(pid, filename, cfra, 0, 0); /* no path */ dir = opendir(path); if (dir==NULL) @@ -1966,7 +1846,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) /*we want startframe if the cache starts before zero*/ pid->cache->last_exact = MIN2(pid->cache->startframe, 0); for(; pm; pm=pm->next) - ptcache_free_data(pm); + ptcache_data_free(pm); BLI_freelistN(&pid->cache->mem_cache); if(pid->cache->cached_frames) for(i=0; icache->cached_frames && pm->frame >=sta && pm->frame <= end) pid->cache->cached_frames[pm->frame-sta] = 0; - ptcache_free_data(pm); + ptcache_data_free(pm); pm = pm->next; BLI_freelinkN(&pid->cache->mem_cache, link); } @@ -1992,7 +1872,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) case PTCACHE_CLEAR_FRAME: if(pid->cache->flag & PTCACHE_DISK_CACHE) { if(BKE_ptcache_id_exist(pid, cfra)) { - BKE_ptcache_id_filename(pid, filename, cfra, 1, 1); /* no path */ + ptcache_filename(pid, filename, cfra, 1, 1); /* no path */ BLI_delete(filename, 0, 0); } } @@ -2001,7 +1881,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) for(; pm; pm=pm->next) { if(pm->frame == cfra) { - ptcache_free_data(pm); + ptcache_data_free(pm); BLI_freelinkN(&pid->cache->mem_cache, pm); break; } @@ -2015,7 +1895,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) BKE_ptcache_update_info(pid); } -int BKE_ptcache_id_exist(PTCacheID *pid, int cfra) +int BKE_ptcache_id_exist(PTCacheID *pid, int cfra) { if(!pid->cache) return 0; @@ -2029,7 +1909,7 @@ int BKE_ptcache_id_exist(PTCacheID *pid, int cfra) if(pid->cache->flag & PTCACHE_DISK_CACHE) { char filename[MAX_PTCACHE_FILE]; - BKE_ptcache_id_filename(pid, filename, cfra, 1, 1); + ptcache_filename(pid, filename, cfra, 1, 1); return BLI_exists(filename); } @@ -2110,7 +1990,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra ptcache_path(pid, path); - len = BKE_ptcache_id_filename(pid, filename, (int)cfra, 0, 0); /* no path */ + len = ptcache_filename(pid, filename, (int)cfra, 0, 0); /* no path */ dir = opendir(path); if (dir==NULL) @@ -2151,7 +2031,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra } } -int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) +int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) { PointCache *cache; int reset, clear, after; @@ -2214,7 +2094,7 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) return (reset || clear || after); } -int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) +int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) { PTCacheID pid; ParticleSystem *psys; @@ -2328,7 +2208,7 @@ void BKE_ptcache_set_continue_physics(Main *bmain, Scene *scene, int enable) } } -int BKE_ptcache_get_continue_physics() +int BKE_ptcache_get_continue_physics() { return CONTINUE_PHYSICS; } @@ -2356,7 +2236,7 @@ void BKE_ptcache_free_mem(ListBase *mem_cache) if(pm) { for(; pm; pm=pm->next) - ptcache_free_data(pm); + ptcache_data_free(pm); BLI_freelistN(mem_cache); } @@ -2430,7 +2310,7 @@ void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene) baker.scene=scene; baker.quick_step=scene->physics_settings.quick_cache_step; - BKE_ptcache_make_cache(&baker); + BKE_ptcache_bake(&baker); } /* Simulation thread, no need for interlocks as data written in both threads @@ -2443,10 +2323,10 @@ typedef struct { int *cfra_ptr; Main *main; Scene *scene; -} ptcache_make_cache_data; +} ptcache_bake_data; -static void *ptcache_make_cache_thread(void *ptr) { - ptcache_make_cache_data *data = (ptcache_make_cache_data*)ptr; +static void *ptcache_bake_thread(void *ptr) { + ptcache_bake_data *data = (ptcache_bake_data*)ptr; for(; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) { scene_update_for_newframe(data->main, data->scene, data->scene->lay); @@ -2460,7 +2340,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) +void BKE_ptcache_bake(PTCacheBaker* baker) { Main *bmain = baker->main; Scene *scene = baker->scene; @@ -2475,7 +2355,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) int bake = baker->bake; int render = baker->render; ListBase threads; - ptcache_make_cache_data thread_data; + ptcache_bake_data thread_data; int progress, old_progress; thread_data.endframe = baker->anim_init ? scene->r.sfra : CFRA; @@ -2580,10 +2460,10 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) WM_cursor_wait(1); if(G.background) { - ptcache_make_cache_thread((void*)&thread_data); + ptcache_bake_thread((void*)&thread_data); } else { - BLI_init_threads(&threads, ptcache_make_cache_thread, 1); + BLI_init_threads(&threads, ptcache_bake_thread, 1); BLI_insert_thread(&threads, (void*)&thread_data); while (thread_data.thread_ended == FALSE) { @@ -2621,7 +2501,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) cache->flag |= PTCACHE_BAKED; /* write info file */ if(cache->flag & PTCACHE_DISK_CACHE) - BKE_ptcache_write_cache(pid, 0); + BKE_ptcache_write(pid, 0); } } else for(SETLOOPER(scene, sce_iter, base)) { @@ -2644,7 +2524,7 @@ void BKE_ptcache_make_cache(PTCacheBaker* baker) if(bake) { cache->flag |= PTCACHE_BAKED; if(cache->flag & PTCACHE_DISK_CACHE) - BKE_ptcache_write_cache(pid, 0); + BKE_ptcache_write(pid, 0); } } BLI_freelistN(&pidlist); @@ -2681,7 +2561,7 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid) pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); if(pf) { - if(!ptcache_file_read_header_begin(pf)) { + if(!ptcache_file_header_begin_read(pf)) { printf("Can't yet convert old cache format\n"); cache->flag |= PTCACHE_DISK_CACHE; ptcache_file_close(pf); @@ -2700,24 +2580,24 @@ void BKE_ptcache_disk_to_mem(PTCacheID *pid) pm->data_types = pf->data_types; pm->frame = cfra; - ptcache_alloc_data(pm); - BKE_ptcache_mem_init_pointers(pm); - ptcache_file_init_pointers(pf); + ptcache_data_alloc(pm); + BKE_ptcache_mem_pointers_init(pm); + ptcache_file_pointers_init(pf); for(i=0; itotpoint; i++) { - if(!ptcache_file_read_data(pf)) { + if(!ptcache_file_data_read(pf)) { printf("Error reading from disk cache\n"); cache->flag |= PTCACHE_DISK_CACHE; - ptcache_free_data(pm); + ptcache_data_free(pm); MEM_freeN(pm); ptcache_file_close(pf); return; } - ptcache_copy_data(pf->cur, pm->cur); - BKE_ptcache_mem_incr_pointers(pm); + ptcache_data_copy(pf->cur, pm->cur); + BKE_ptcache_mem_pointers_incr(pm); } ptcache_make_index_array(pm, pid->totpoint(pid->calldata, cfra)); @@ -2748,10 +2628,10 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid) pf->totpoint = pm->totpoint; pf->type = pid->type; - BKE_ptcache_mem_init_pointers(pm); - ptcache_file_init_pointers(pf); + BKE_ptcache_mem_pointers_init(pm); + ptcache_file_pointers_init(pf); - if(!ptcache_file_write_header_begin(pf) || !pid->write_header(pf)) { + if(!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)) { if (G.f & G_DEBUG) printf("Error writing to disk cache\n"); cache->flag &= ~PTCACHE_DISK_CACHE; @@ -2761,8 +2641,8 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid) } for(i=0; itotpoint; i++) { - ptcache_copy_data(pm->cur, pf->cur); - if(!ptcache_file_write_data(pf)) { + ptcache_data_copy(pm->cur, pf->cur); + if(!ptcache_file_data_write(pf)) { if (G.f & G_DEBUG) printf("Error writing to disk cache\n"); cache->flag &= ~PTCACHE_DISK_CACHE; @@ -2770,14 +2650,14 @@ void BKE_ptcache_mem_to_disk(PTCacheID *pid) ptcache_file_close(pf); return; } - BKE_ptcache_mem_incr_pointers(pm); + BKE_ptcache_mem_pointers_incr(pm); } ptcache_file_close(pf); /* write info file */ if(cache->flag & PTCACHE_BAKED) - BKE_ptcache_write_cache(pid, 0); + BKE_ptcache_write(pid, 0); } else if (G.f & G_DEBUG) @@ -2807,6 +2687,13 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) cache->last_exact = last_exact; + if(cache->cached_frames) { + MEM_freeN(cache->cached_frames); + cache->cached_frames=NULL; + } + + BKE_ptcache_id_time(pid, NULL, 0.0f, NULL, NULL, NULL); + BKE_ptcache_update_info(pid); } @@ -2829,7 +2716,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to) /* get "from" filename */ strcpy(pid->cache->name, from); - len = BKE_ptcache_id_filename(pid, old_filename, 0, 0, 0); /* no path */ + len = ptcache_filename(pid, old_filename, 0, 0, 0); /* no path */ ptcache_path(pid, path); dir = opendir(path); @@ -2855,7 +2742,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to) frame = atoi(num); BLI_join_dirfile(old_path_full, path, de->d_name); - BKE_ptcache_id_filename(pid, new_path_full, frame, 1, 1); + ptcache_filename(pid, new_path_full, frame, 1, 1); BLI_rename(old_path_full, new_path_full); } } @@ -2886,7 +2773,7 @@ void BKE_ptcache_load_external(PTCacheID *pid) ptcache_path(pid, path); - len = BKE_ptcache_id_filename(pid, filename, 1, 0, 0); /* no path */ + len = ptcache_filename(pid, filename, 1, 0, 0); /* no path */ dir = opendir(path); if (dir==NULL) @@ -2932,7 +2819,7 @@ void BKE_ptcache_load_external(PTCacheID *pid) pf= ptcache_file_open(pid, PTCACHE_FILE_READ, 0); if(pf) { - if(ptcache_file_read_header_begin(pf)) { + if(ptcache_file_header_begin_read(pf)) { if(pf->type == pid->type && pid->read_header(pf)) { cache->totpoint = pf->totpoint; cache->flag |= PTCACHE_READ_INFO; @@ -2947,7 +2834,7 @@ void BKE_ptcache_load_external(PTCacheID *pid) /* or from any old format cache file */ else { float old_data[14]; - int elemsize = ptcache_pid_old_elemsize(pid); + int elemsize = ptcache_old_elemsize(pid); pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cache->startframe); if(pf) { diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index adaab2046dc..babe4209a31 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1376,7 +1376,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } /* try to read from cache */ - if(BKE_ptcache_read_cache(&pid, (float)framenr, scene->r.frs_sec) == PTCACHE_READ_EXACT) { + if(BKE_ptcache_read(&pid, (float)framenr, scene->r.frs_sec) == PTCACHE_READ_EXACT) { BKE_ptcache_validate(cache, framenr); smd->time = framenr; return; @@ -1407,7 +1407,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM smoke_turbulence_step(sds->wt, sds->fluid); } - BKE_ptcache_write_cache(&pid, startframe); + BKE_ptcache_write(&pid, startframe); } // set new time @@ -1439,7 +1439,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM BKE_ptcache_validate(cache, framenr); if(framenr != startframe) - BKE_ptcache_write_cache(&pid, framenr); + BKE_ptcache_write(&pid, framenr); tend(); //printf ( "Frame: %d, Time: %f\n", (int)smd->time, ( float ) tval() ); diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index ceee544d1b8..4653562e5f4 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -4134,7 +4134,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i } /* try to read from cache */ - cache_result = BKE_ptcache_read_cache(&pid, framenr, scene->r.frs_sec); + cache_result = BKE_ptcache_read(&pid, framenr, scene->r.frs_sec); if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { softbody_to_object(ob, vertexCos, numVerts, sb->local); @@ -4142,7 +4142,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i BKE_ptcache_validate(cache, framenr); if(cache_result == PTCACHE_READ_INTERPOLATED && cache->flag & PTCACHE_REDO_NEEDED) - BKE_ptcache_write_cache(&pid, framenr); + BKE_ptcache_write(&pid, framenr); return; } @@ -4157,7 +4157,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i /* if on second frame, write cache for first frame */ if(cache->simframe == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) - BKE_ptcache_write_cache(&pid, startframe); + BKE_ptcache_write(&pid, startframe); softbody_update_positions(ob, sb, vertexCos, numVerts); @@ -4170,6 +4170,6 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i softbody_to_object(ob, vertexCos, numVerts, 0); BKE_ptcache_validate(cache, framenr); - BKE_ptcache_write_cache(&pid, framenr); + BKE_ptcache_write(&pid, framenr); } -- cgit v1.2.3 From e93a7aa849ddefee9a5fb9e97764502adff7f83c Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 18 Dec 2010 18:56:21 +0000 Subject: FILTER="^\[[ 0123456789][ 0123456789][ 0123456789]\%] \|Linking \(C\|CXX\) static library\|Building \(C\|CXX\) object \|Built target " Bugfix #25280 Image: sequence option was hardcoded to assume "first frame" was always picture "001". Made it impossible to have a sequence of images starting with picture like "000" Note that by allowing to render a first frame as 000 in Blender, things mess up a bit here. Things work now as follows: - Start Frame = 1 : Image 001 on frame 1 - Start Frame = 0 : Image 001 on frame 0 - Start Frame =-1 : Image 000 on frame 0 ;) This is of course the lack of proper control for image sequences. Definite something to work on; best idea I have now is a new setting that defines the Image Number to be "first frame". That way you can map that number on any Blender frame. Or it makes it more confusing? :) For the doc department: the proper meaning of "Start Frame" now is: "The blender frame a sequence starts playing, assuming the sequence starts with image #1" Tooltop was fixed accordingly (Also fixed 'remove doubles' to show more precision in toolbar) --- source/blender/blenkernel/intern/image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index f2a100134b3..70bfc96f0a2 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -2221,7 +2221,7 @@ void BKE_image_user_calc_frame(ImageUser *iuser, int cfra, int fieldnr) if(cfra==0) cfra= len; } - if(cfra<1) cfra= 1; + if(cfra<0) cfra= 0; else if(cfra>len) cfra= len; /* convert current frame to current field */ -- cgit v1.2.3 From d920bf50725dcfab52b96f8cb096c17d7590c589 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 18 Dec 2010 21:16:37 +0000 Subject: Mistake in previous own commit, checking the wrong cache frame. --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index b87347f4975..3962c6a7500 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1485,7 +1485,7 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, float frs_sec) cfra2 = ptcache_read_init(pid, &cache2, &totpoint2); /* don't read old cache if already simulated past cached frame */ - if(!cache1 && cfra1 && cfra1 <= pid->cache->simframe) + if(!cache1 && cfra2 && cfra2 <= pid->cache->simframe) goto cleanup; if(cfra1 && cfra1==cfra2) goto cleanup; -- cgit v1.2.3 From 686420b15d2f4feda760bd19c93394df71ddfb1d Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 19 Dec 2010 13:50:31 +0000 Subject: Option "Make Single user" now also makes animations local. Note that the menu option "Animation" only was working for Object level animations, so I've changed the many name accordingly. --- source/blender/blenkernel/intern/material.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 420aca12a20..30df1887077 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -203,9 +203,6 @@ Material *copy_material(Material *ma) man= copy_libblock(ma); -#if 0 // XXX old animation system - id_us_plus((ID *)man->ipo); -#endif // XXX old animation system id_lib_extern((ID *)man->group); for(a=0; a Date: Sun, 19 Dec 2010 20:12:12 +0000 Subject: Bugfix #25301 Preview render for node shaders broke, caused by localizing materials last week, to prevent thread crashes. Fixed now. Also added a temp fix to draw color-management corrected node previews default. Will follow scene setting tomorrow. Also: SSS in nodes doesn't render yet. Was issue in 2.4 too... --- source/blender/blenkernel/intern/material.c | 34 +++++++ source/blender/blenkernel/intern/node.c | 137 +++++++++++++++++----------- 2 files changed, 118 insertions(+), 53 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 30df1887077..cac41e457a6 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -44,6 +44,7 @@ #include "DNA_scene_types.h" #include "BLI_math.h" +#include "BLI_listbase.h" #include "BKE_animsys.h" #include "BKE_displist.h" @@ -196,6 +197,7 @@ Material *add_material(const char *name) return ma; } +/* XXX keep synced with next function */ Material *copy_material(Material *ma) { Material *man; @@ -227,6 +229,38 @@ Material *copy_material(Material *ma) return man; } +/* XXX (see above) material copy without adding to main dbase */ +Material *localize_material(Material *ma) +{ + Material *man; + int a; + + man= copy_libblock(ma); + BLI_remlink(&G.main->mat, man); + + for(a=0; amtex[a]) { + man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial"); + memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex)); + /* free_material decrements! */ + id_us_plus((ID *)man->mtex[a]->tex); + } + } + + if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col); + if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec); + + if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview); + + if(ma->nodetree) { + man->nodetree= ntreeLocalize(ma->nodetree); + } + + man->gpumaterial.first= man->gpumaterial.last= NULL; + + return man; +} + void make_local_material(Material *ma) { Main *bmain= G.main; diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 4b158f4b405..663a2d8844c 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1186,12 +1186,12 @@ static void node_init_preview(bNode *node, int xsize, int ysize) } if(node->preview->rect==NULL) { - node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(float)*4, "node preview rect"); + node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(char)*4, "node preview rect"); node->preview->xsize= xsize; node->preview->ysize= ysize; } else - memset(node->preview->rect, 0, 4*xsize + xsize*ysize*sizeof(float)*4); + memset(node->preview->rect, 0, 4*xsize + xsize*ysize*sizeof(char)*4); } void ntreeInitPreview(bNodeTree *ntree, int xsize, int ysize) @@ -1241,12 +1241,18 @@ void nodeAddToPreview(bNode *node, float *col, int x, int y) if(x>=0 && y>=0) { if(xxsize && yysize) { unsigned char *tar= preview->rect+ 4*((preview->xsize*y) + x); - //if(tar[0]==0.0f) { - tar[0]= FTOCHAR(col[0]); - tar[1]= FTOCHAR(col[1]); - tar[2]= FTOCHAR(col[2]); + + if(TRUE) { + tar[0]= FTOCHAR(linearrgb_to_srgb(col[0])); + tar[1]= FTOCHAR(linearrgb_to_srgb(col[1])); + tar[2]= FTOCHAR(linearrgb_to_srgb(col[2])); + } + else { + tar[0]= FTOCHAR(col[0]); + tar[1]= FTOCHAR(col[1]); + tar[2]= FTOCHAR(col[2]); + } tar[3]= FTOCHAR(col[3]); - //} } //else printf("prv out bound x y %d %d\n", x, y); } @@ -1699,33 +1705,36 @@ static void ntreeSetOutput(bNodeTree *ntree) { bNode *node; - /* find the active outputs, might become tree type dependant handler */ - for(node= ntree->nodes.first; node; node= node->next) { - if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) { - bNode *tnode; - int output= 0; - - /* we need a check for which output node should be tagged like this, below an exception */ - if(node->type==CMP_NODE_OUTPUT_FILE) - continue; - - /* there is more types having output class, each one is checked */ - for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) { - if(tnode->typeinfo->nclass==NODE_CLASS_OUTPUT) { - /* same type, exception for viewer */ - if(tnode->type==node->type || - (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER) && - ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))) { - if(tnode->flag & NODE_DO_OUTPUT) { - output++; - if(output>1) - tnode->flag &= ~NODE_DO_OUTPUT; + if(ntree->type==NTREE_COMPOSIT) { + + /* find the active outputs, might become tree type dependant handler */ + for(node= ntree->nodes.first; node; node= node->next) { + if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) { + bNode *tnode; + int output= 0; + + /* we need a check for which output node should be tagged like this, below an exception */ + if(node->type==CMP_NODE_OUTPUT_FILE) + continue; + + /* there is more types having output class, each one is checked */ + for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) { + if(tnode->typeinfo->nclass==NODE_CLASS_OUTPUT) { + /* same type, exception for viewer */ + if(tnode->type==node->type || + (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER) && + ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER))) { + if(tnode->flag & NODE_DO_OUTPUT) { + output++; + if(output>1) + tnode->flag &= ~NODE_DO_OUTPUT; + } } } } + if(output==0) + node->flag |= NODE_DO_OUTPUT; } - if(output==0) - node->flag |= NODE_DO_OUTPUT; } } @@ -2586,8 +2595,6 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) /* ensures only a single output node is enabled */ ntreeSetOutput(ntree); - /* move over the compbufs */ - /* right after ntreeCopyTree() oldsock pointers are valid */ for(node= ntree->nodes.first; node; node= node->next) { /* store new_node pointer to original */ @@ -2595,22 +2602,27 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) /* ensure new user input gets handled ok */ node->need_exec= 0; - if(ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { - if(node->id) { - if(node->flag & NODE_DO_OUTPUT) - node->new_node->id= (ID *)copy_image((Image *)node->id); - else - node->new_node->id= NULL; - } - } - - for(sock= node->outputs.first; sock; sock= sock->next) { + if(ntree->type==NTREE_COMPOSIT) { + /* move over the compbufs */ + /* right after ntreeCopyTree() oldsock pointers are valid */ - sock->new_sock->ns.data= sock->ns.data; - compbuf_set_node(sock->new_sock->ns.data, node->new_node); + if(ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { + if(node->id) { + if(node->flag & NODE_DO_OUTPUT) + node->new_node->id= (ID *)copy_image((Image *)node->id); + else + node->new_node->id= NULL; + } + } - sock->ns.data= NULL; - sock->new_sock->new_sock= sock; + for(sock= node->outputs.first; sock; sock= sock->next) { + + sock->new_sock->ns.data= sock->ns.data; + compbuf_set_node(sock->new_sock->ns.data, node->new_node); + + sock->ns.data= NULL; + sock->new_sock->new_sock= sock; + } } } @@ -2638,19 +2650,38 @@ static int outsocket_exists(bNode *node, bNodeSocket *testsock) /* sync local composite with real tree */ /* local composite is supposed to be running, be careful moving previews! */ +/* is called by jobs manager, outside threads, so it doesnt happen during draw */ void ntreeLocalSync(bNodeTree *localtree, bNodeTree *ntree) { bNode *lnode; - /* move over the compbufs and previews */ - for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) { - if( (lnode->exec & NODE_READY) && !(lnode->exec & NODE_SKIPPED) ) { + if(ntree->type==NTREE_COMPOSIT) { + /* move over the compbufs and previews */ + for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) { + if( (lnode->exec & NODE_READY) && !(lnode->exec & NODE_SKIPPED) ) { + if(node_exists(ntree, lnode->new_node)) { + + if(lnode->preview && lnode->preview->rect) { + node_free_preview(lnode->new_node); + lnode->new_node->preview= lnode->preview; + lnode->preview= NULL; + } + } + } + } + } + else if(ntree->type==NTREE_SHADER) { + /* copy over contents of previews */ + for(lnode= localtree->nodes.first; lnode; lnode= lnode->next) { if(node_exists(ntree, lnode->new_node)) { + bNode *node= lnode->new_node; - if(lnode->preview && lnode->preview->rect) { - node_free_preview(lnode->new_node); - lnode->new_node->preview= lnode->preview; - lnode->preview= NULL; + if(node->preview && node->preview->rect) { + if(lnode->preview && lnode->preview->rect) { + int xsize= node->preview->xsize; + int ysize= node->preview->ysize; + memcpy(node->preview->rect, lnode->preview->rect, 4*xsize + xsize*ysize*sizeof(char)*4); + } } } } -- cgit v1.2.3 From fad7121ca3bf150aeb1753873969778391629e0c Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Sun, 19 Dec 2010 20:23:30 +0000 Subject: Apply [#25296] Fix for [#24636] Bug reported by Dominique Lorre Fix submitted by Jeroen Bakker When importing COLLADA files, the name of a custom data layer can be longer than 32 bytes. Make sure only 32 bytes are copied. --- source/blender/blenkernel/intern/customdata.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 67d485d2dc3..abd78ffe148 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1444,9 +1444,8 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, data->layers[index].type = type; data->layers[index].flag = flag; data->layers[index].data = newlayerdata; - if(name || (name=typeInfo->defaultname)) { - strcpy(data->layers[index].name, name); + BLI_strncpy(data->layers[index].name, name, 32); CustomData_set_layer_unique_name(data, index); } else -- cgit v1.2.3 From 3bed4cbf2b4c09dcb62197b8a8c4ec4224abc8b7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Dec 2010 03:59:22 +0000 Subject: fix [#25283] Edge length display difficult to read - made theme colors for mesh edge len & face angle/area display. - use %g rather then %f for float display, trims unneeded zeros. - store cached 2d and 3d text color as bytes rather then floats, compare when drawing to avoid setting the context. - use unsigned char for more color functions, avoids casting to glColorubv(). --- source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/text.c | 2 +- 2 files 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 17d63fa2349..d35fee2addc 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1609,7 +1609,7 @@ static ImBuf * input_preprocess( if(seq->sat != 1.0f) { /* inline for now, could become an imbuf function */ int i; - char *rct= (char *)ibuf->rect; + unsigned char *rct= (unsigned char *)ibuf->rect; float *rctf= ibuf->rect_float; const float sat= seq->sat; float hsv[3]; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 6e0289e907b..bbdc188d580 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2746,7 +2746,7 @@ int setcurr_tab_spaces (Text *text, int space) /*********************************/ /* Creates and adds a marker to the list maintaining sorted order */ -void txt_add_marker(Text *text, TextLine *line, int start, int end, char color[4], int group, int flags) { +void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsigned char color[4], int group, int flags) { TextMarker *tmp, *marker; marker= MEM_mallocN(sizeof(TextMarker), "text_marker"); -- cgit v1.2.3 From 09debd69baaa4ae655dac0ef2e4355a335b70b5c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 20 Dec 2010 07:45:24 +0000 Subject: change the resolution for new surfaces to 4x4, since 12x12 used to be the total number of subdivisions along the U/V of the nurbs surface but now its multiplied by the number of segments. --- source/blender/blenkernel/intern/curve.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 9be64e27d20..6368c139baf 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -139,7 +139,7 @@ Curve *add_curve(const char *name, int type) cu->size[0]= cu->size[1]= cu->size[2]= 1.0; cu->flag= CU_FRONT|CU_BACK|CU_DEFORM_BOUNDS_OFF|CU_PATH_RADIUS; cu->pathlen= 100; - cu->resolu= cu->resolv= 12; + cu->resolu= cu->resolv= (type == OB_SURF) ? 4 : 12; cu->width= 1.0; cu->wordspace = 1.0; cu->spacing= cu->linedist= 1.0; -- cgit v1.2.3 From 97197b54cf3473e29d3c5626fc30926a236454a1 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 20 Dec 2010 11:08:29 +0000 Subject: Bugfix #25309 Code cleanup to allow switching active output nodes in Compositor made shader nodes output not set correctly. Now you can have multiple output nodes in shaders too, and switch on click-activate. --- source/blender/blenkernel/intern/node.c | 45 ++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 663a2d8844c..f52a538cc00 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1705,21 +1705,22 @@ static void ntreeSetOutput(bNodeTree *ntree) { bNode *node; - if(ntree->type==NTREE_COMPOSIT) { - - /* find the active outputs, might become tree type dependant handler */ - for(node= ntree->nodes.first; node; node= node->next) { - if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) { - bNode *tnode; - int output= 0; - - /* we need a check for which output node should be tagged like this, below an exception */ - if(node->type==CMP_NODE_OUTPUT_FILE) - continue; - - /* there is more types having output class, each one is checked */ - for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) { - if(tnode->typeinfo->nclass==NODE_CLASS_OUTPUT) { + /* find the active outputs, might become tree type dependant handler */ + for(node= ntree->nodes.first; node; node= node->next) { + if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) { + bNode *tnode; + int output= 0; + + /* we need a check for which output node should be tagged like this, below an exception */ + if(node->type==CMP_NODE_OUTPUT_FILE) + continue; + + /* there is more types having output class, each one is checked */ + for(tnode= ntree->nodes.first; tnode; tnode= tnode->next) { + if(tnode->typeinfo->nclass==NODE_CLASS_OUTPUT) { + + if(ntree->type==NTREE_COMPOSIT) { + /* same type, exception for viewer */ if(tnode->type==node->type || (ELEM(tnode->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER) && @@ -1731,10 +1732,20 @@ static void ntreeSetOutput(bNodeTree *ntree) } } } + else { + /* same type */ + if(tnode->type==node->type) { + if(tnode->flag & NODE_DO_OUTPUT) { + output++; + if(output>1) + tnode->flag &= ~NODE_DO_OUTPUT; + } + } + } } - if(output==0) - node->flag |= NODE_DO_OUTPUT; } + if(output==0) + node->flag |= NODE_DO_OUTPUT; } } -- cgit v1.2.3 From b0f87a17460578382cabb8447934cb045eee223a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 21 Dec 2010 14:49:34 +0000 Subject: rename addlisttolist() to BLI_movelisttolist() name was misleading because the list items were removed from the source list. (no functional changes) --- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/ipo.c | 4 ++-- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 0d1d08af44c..22d27dc2fde 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1500,7 +1500,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected */ extract_proxylocal_constraints(&proxylocal_constraints, &pchan->constraints); copy_constraints(&pchanw.constraints, &pchanp->constraints, FALSE); - addlisttolist(&pchanw.constraints, &proxylocal_constraints); + BLI_movelisttolist(&pchanw.constraints, &proxylocal_constraints); /* constraints - set target ob pointer to own object */ for (con= pchanw.constraints.first; con; con= con->next) { diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 5be8bda4cd9..a040c27caa0 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1516,14 +1516,14 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], } /* add F-Curves to action */ - addlisttolist(&adt->action->curves, &anim); + BLI_movelisttolist(&adt->action->curves, &anim); } /* deal with drivers */ if (drivers.first) { if (G.f & G_DEBUG) printf("\thas drivers \n"); /* add drivers to end of driver stack */ - addlisttolist(&adt->drivers, &drivers); + BLI_movelisttolist(&adt->drivers, &drivers); } } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 3962c6a7500..7a8d3a8b19c 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -890,7 +890,7 @@ void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int dup 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); + BLI_movelisttolist(lb, &lb_dupli_pid); if(lb_dupli_pid.first) printf("Adding Dupli\n"); } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index d35fee2addc..19f872fbd40 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -790,7 +790,7 @@ void sort_seq(Scene *scene) } } - addlisttolist(&seqbase, &effbase); + BLI_movelisttolist(&seqbase, &effbase); *(ed->seqbasep)= seqbase; } @@ -3234,7 +3234,7 @@ void seq_dupe_animdata(Scene *scene, char *name_from, char *name_to) BKE_animdata_fix_paths_rename(&scene->id, scene->adt, "sequence_editor.sequences_all", name_from, name_to, 0, 0, 0); /* add the original fcurves back */ - addlisttolist(&scene->adt->action->curves, &lb); + BLI_movelisttolist(&scene->adt->action->curves, &lb); } /* XXX - hackish function needed to remove all fcurves belonging to a sequencer strip */ -- cgit v1.2.3 From fae8dc5a735d6e47d96d5757fbc51a33b45a4cea Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 21 Dec 2010 15:10:09 +0000 Subject: Error/Warning report flipping. An operator Error throws up a menu, a Warning only a flashy header print. In mesh editmode the menus for simple failures got very annoying, like "Already a face" for Fkey on a face. Proposal is to use warning for contextual failures, like: - wrong selection - unsupported combination - wrong modes And use errors for cases you really need user attention, for example when issues are invisble or potentially damaging work. - Memory failures - Files not found List can grow in future :) let's test this for mesh now. I'll tackle this for other ops later after review. (Also changed: loopcut disabled when editmode shows deformed result) --- source/blender/blenkernel/intern/modifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 6381315a8ca..f8fdc9e32a4 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -236,7 +236,8 @@ void modifier_setError(ModifierData *md, const char *format, ...) * there * * also used in transform_conversion.c, to detect CrazySpace [tm] (2nd arg - * then is NULL) + * then is NULL) + * also used for some mesh tools to give warnings */ int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *lastPossibleCageIndex_r, int virtual_) { -- cgit v1.2.3 From 9d756fb761ba24a884e9663b779b8807adcdb805 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 22 Dec 2010 09:30:13 +0000 Subject: Fix for [#25339] Rendering Fluid's Float Particals cause crash when utilizng raytracing * Fluidsim particles hadn't really been working at all for who knows how long, even in viewport! --- source/blender/blenkernel/intern/particle_system.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (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 aca8bf848a2..1f36f0845a2 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3663,9 +3663,8 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) part->sta=part->end = 1.0f; part->lifetime = sim->scene->r.efra + 1; - /* initialize particles */ + /* allocate particles */ realloc_particles(sim, part->totpart); - initialize_all_particles(sim); // set up reading mask readMask = fss->typeFlags; @@ -3697,6 +3696,9 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) pa->state.rot[0] = 1.0; pa->state.rot[1] = pa->state.rot[2] = pa->state.rot[3] = 0.0; + pa->time = 1.f; + pa->dietime = sim->scene->r.efra + 1; + pa->lifetime = sim->scene->r.efra; pa->alive = PARS_ALIVE; //if(a<25) fprintf(stderr,"FSPARTICLE debug set %s , a%d = %f,%f,%f , life=%f \n", filename, a, pa->co[0],pa->co[1],pa->co[2], pa->lifetime ); } else { -- cgit v1.2.3 From 01bb474d4f6e1ed3936894417119ae0baac177a8 Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Wed, 22 Dec 2010 16:07:57 +0000 Subject: Audio: Function to get channel count of a sound, for [#25062] Sound Actuator - Positional Audio. --- source/blender/blenkernel/intern/sound.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 443ed1f7987..3dc2221e0c8 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -484,3 +484,12 @@ int sound_read_sound_buffer(struct bSound* sound, float* buffer, int length, flo return AUD_readSound(limiter, buffer, length); AUD_unload(limiter); } + +int sound_get_channels(struct bSound* sound) +{ + AUD_SoundInfo info; + + info = AUD_getInfo(sound->playback_handle); + + return info.specs.channels; +} -- cgit v1.2.3 From 2811707b927acea0223080eea59346e8e3fe2947 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 22 Dec 2010 21:38:06 +0000 Subject: Fixed stupid typo with detecting corners of source mdisp. Haven't noticed before because destination is a copy of source for now, so there would be always the same count of corners. --- source/blender/blenkernel/intern/customdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index abd78ffe148..e178beaaa50 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -692,7 +692,7 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights), s = sources[0]; dst_corners = multires_mdisp_corners(d); - src_corners = multires_mdisp_corners(d); + src_corners = multires_mdisp_corners(s); /* XXX: For now, some restrictions on the input should be implemented to allow quad<->tris face conversion */ -- cgit v1.2.3 From c046ae14be2e0142c3ea9c5d81b946594043c3f7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Dec 2010 04:16:31 +0000 Subject: Fix for multiple modifier stack calculations per frame. Since 2.5x blender has been using CD_MASK_BAREMESH for updating objects since object_handle_update() no longer has access to G.curscreen to calculate the mask from viewports. The problem with this is after an initial calculation, CD_MASK_MTFACE may be required on draw, so it would recalculate the modifier stack multiple times per frame. One case which caused this is armature animated mesh with texface in a dupligroup. Fix this by having customdata_mask member in the scene, this isn't great design but at least fixes the bug and only changes a few files. --- source/blender/blenkernel/intern/object.c | 6 +++--- source/blender/blenkernel/intern/scene.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 54bc07b548d..07fee83a405 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2550,12 +2550,12 @@ void object_handle_update(Scene *scene, Object *ob) case OB_MESH: { EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; - // here was vieweditdatamask? XXX + BKE_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH); if(em) { - makeDerivedMesh(scene, ob, em, CD_MASK_BAREMESH); + makeDerivedMesh(scene, ob, em, scene->customdata_mask); /* was CD_MASK_BAREMESH */ BKE_mesh_end_editmesh(ob->data, em); } else - makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH); + makeDerivedMesh(scene, ob, NULL, scene->customdata_mask); } break; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 7a8c4efb51a..9aeb9a89c90 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -946,6 +946,7 @@ float BKE_curframe(Scene *scene) static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scene_parent) { Base *base; + scene->customdata_mask= scene_parent->customdata_mask; /* sets first, we allow per definition current scene to have dependencies on sets, but not the other way around. */ -- cgit v1.2.3 From f543fe1500740d1d8adc03d61a3506cf800e80fc Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Thu, 23 Dec 2010 13:16:56 +0000 Subject: Bugfix #25341 Child-of constraint issue: on adding, it wasn't checking owner correctly for Bones, resulting in a constraint working in wrong space; it looked as if transform was applied double when moving the object. Only adding via Py API went wrong btw. Also found a silly check for drawing constraints, which caused constraint initialization to happen for every object on every redraw! Implementation note: con->flag CONSTRAINT_SPACEONCE was only used for child-of constraints in Bones, so I've patched it on file reading to always set the flag. Marked with XXX, so it can be removed one day. Now at least things get corrected well for imported armatures. --- source/blender/blenkernel/intern/constraint.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index bb0fc23c02c..b0932533ea6 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -861,6 +861,7 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta } } +/* XXX note, con->flag should be CONSTRAINT_SPACEONCE for bone-childof, patched in readfile.c */ static bConstraintTypeInfo CTI_CHILDOF = { CONSTRAINT_TYPE_CHILDOF, /* type */ sizeof(bChildOfConstraint), /* size */ -- cgit v1.2.3 From 31eadb358d0f186c5e9912dd1ac0bbeaf5786cf3 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 26 Dec 2010 13:01:02 +0000 Subject: Fix for IRC reported bug from lmg: VBO enabled, GLSL shading and bevel modifier leads to crash when entering edit mode Bevel modifier doe not support remapping still, so added check about original index in cdDM_drawFacesTex_common. Now it works like VBO-less drawing for that special case. --- source/blender/blenkernel/intern/cdderivedmesh.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index d6c91c3c908..8030a3655ad 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -744,6 +744,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, if( !GPU_buffer_legacy(dm) ) { glShadeModel( GL_SMOOTH ); + lastFlag = 0; for(i = 0; i < dm->drawObject->nelements/3; i++) { int actualFace = dm->drawObject->faceRemap[i]; int flag = 1; @@ -754,6 +755,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, else { if(index) { orig = index[actualFace]; + if(orig == ORIGINDEX_NONE) continue; if(drawParamsMapped) flag = drawParamsMapped(userData, orig); } -- cgit v1.2.3 From b2be78c0ccbeb24995584ad7d5c70ae9f49ef04a Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 27 Dec 2010 19:26:38 +0000 Subject: Bugfix #25392 Compositor: Texture node didn't use texture-nodes itself. Now composites initialize texture nodes correctly. Also reviewed the fix for crashing texture nodes for displace. It appears texture nodes also are used for sculpt/paint brushes, in these cases it can be allowed again. But, don't do this during rendering for now! --- source/blender/blenkernel/intern/node.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index f52a538cc00..0513593a0e0 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2474,6 +2474,25 @@ static bNode *getExecutableNode(bNodeTree *ntree) return NULL; } +/* check if texture nodes need exec or end */ +static void ntree_composite_texnode(bNodeTree *ntree, int init) +{ + bNode *node; + + for(node= ntree->nodes.first; node; node= node->next) { + if(node->type==CMP_NODE_TEXTURE && node->id) { + Tex *tex= (Tex *)node->id; + if(tex->nodetree && tex->use_nodes) { + /* has internal flag to detect it only does it once */ + if(init) + ntreeBeginExecTree(tex->nodetree); + else + ntreeEndExecTree(tex->nodetree); + } + } + } + +} /* optimized tree execute test for compositing */ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) @@ -2489,6 +2508,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) ntreeInitPreview(ntree, 0, 0); ntreeBeginExecTree(ntree); + ntree_composite_texnode(ntree, 1); /* prevent unlucky accidents */ if(G.background) -- cgit v1.2.3 From 71da1e96d174fe23da58af3119ccc7c653357585 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 28 Dec 2010 05:45:15 +0000 Subject: Drivers Code Cleanups and UI Tweaks: - Adding drivers from the UI (not from py-scripts though) will now automatically add a "Transform Channel" driver variable to the newly created drivers. This makes setting up drivers a bit more convenient for the most commonly used case. - Drivers now report their errors using the Reports system instead of writing these directly to the console. - Clarified some comments to be more insightful about the "why's" of some design decisions, and related formatting/cleanup tweaks - Reduced scope of "path" vars to just the scope they're required in - Removed some unused defines from a failed experiment in the original Keying Sets code ("templates" and "template flags") which was superseeded by the more flexible + nicer "Builtin KeyingSets" --- source/blender/blenkernel/intern/fcurve.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 325e64bf768..f2bc586f15c 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1329,7 +1329,7 @@ DriverVar *driver_add_new_variable (ChannelDriver *driver) #ifdef WITH_PYTHON /* since driver variables are cached, the expression needs re-compiling too */ - if(driver->type==DRIVER_TYPE_PYTHON) + if (driver->type==DRIVER_TYPE_PYTHON) driver->flag |= DRIVER_FLAG_RENAMEVAR; #endif -- cgit v1.2.3 From 26104c7611c193a4d389789d8e5f13c2a71fa30b Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 28 Dec 2010 06:18:56 +0000 Subject: - Silencing some gcc warnings (yay! I can finally use this setup again) - Graph Editor "Active Keyframe" panel now displays more descriptive error messages. In particular, hopefully this helps to alert users of the default generator modifier for Driver F-Curves - The first F-Modifier added to a list is now set to be active one for that list. --- source/blender/blenkernel/intern/fmodifier.c | 6 +++++- source/blender/blenkernel/intern/key.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 1ed8241325e..0376d75d651 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -1009,9 +1009,13 @@ FModifier *add_fmodifier (ListBase *modifiers, int type) fcm->flag = FMODIFIER_FLAG_EXPANDED; BLI_addtail(modifiers, fcm); + /* tag modifier as "active" if no other modifiers exist in the stack yet */ + if (modifiers->first == modifiers->last) + fcm->flag |= FMODIFIER_FLAG_ACTIVE; + /* add modifier's data */ fcm->data= MEM_callocN(fmi->size, fmi->structName); - + /* init custom settings if necessary */ if (fmi->new_data) fmi->new_data(fcm->data); diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index c18085b2d73..8cdfbaf9e2a 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1191,7 +1191,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot) if(key->slurph && key->type!=KEY_RELATIVE) { Nurb *nu; - int mode, i= 0, remain= 0, estep, count; + int mode=0, i= 0, remain= 0, estep=0, count=0; delta= (float)key->slurph / tot; -- cgit v1.2.3 From 7115a8d200fbc04dc824649796a6b8a52bd36d97 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 29 Dec 2010 05:20:19 +0000 Subject: Consistency cleanups for AnimData stuff: Some AnimData looping functions were not updated to take into account the addition of AnimData for some additional datatypes (i.e. meshes and lattices) as well as the changes to make nested nodetrees (i.e. for Material and Texture nodes). --- source/blender/blenkernel/intern/anim_sys.c | 123 +++++++++++++++++----------- 1 file changed, 77 insertions(+), 46 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index b595d22e88c..41c6969cdce 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -465,44 +465,73 @@ void BKE_animdata_fix_paths_rename (ID *owner_id, AnimData *adt, const char *pre /* Whole Database Ops -------------------------------------------- */ /* apply the given callback function on all data in main database */ -void BKE_animdata_main_cb (Main *main, ID_AnimData_Edit_Callback func, void *user_data) +void BKE_animdata_main_cb (Main *mainptr, ID_AnimData_Edit_Callback func, void *user_data) { ID *id; + /* standard data version */ #define ANIMDATA_IDS_CB(first) \ for (id= first; id; id= id->next) { \ AnimData *adt= BKE_animdata_from_id(id); \ if (adt) func(id, adt, user_data); \ } - - ANIMDATA_IDS_CB(main->nodetree.first); /* nodes */ - ANIMDATA_IDS_CB(main->tex.first); /* textures */ - ANIMDATA_IDS_CB(main->lamp.first); /* lamps */ - ANIMDATA_IDS_CB(main->mat.first); /* materials */ - ANIMDATA_IDS_CB(main->camera.first); /* cameras */ - ANIMDATA_IDS_CB(main->key.first); /* shapekeys */ - ANIMDATA_IDS_CB(main->mball.first); /* metaballs */ - ANIMDATA_IDS_CB(main->curve.first); /* curves */ - ANIMDATA_IDS_CB(main->armature.first); /* armatures */ - ANIMDATA_IDS_CB(main->mesh.first); /* meshes */ - ANIMDATA_IDS_CB(main->particle.first); /* particles */ - ANIMDATA_IDS_CB(main->object.first); /* objects */ - ANIMDATA_IDS_CB(main->world.first); /* worlds */ - - /* scenes */ - for (id= main->scene.first; id; id= id->next) { - AnimData *adt= BKE_animdata_from_id(id); - Scene *scene= (Scene *)id; - - /* do compositing nodes first (since these aren't included in main tree) */ - if (scene->nodetree) { - AnimData *adt2= BKE_animdata_from_id((ID *)scene->nodetree); - if (adt2) func(id, adt2, user_data); - } - - /* now fix scene animation data as per normal */ - if (adt) func((ID *)id, adt, user_data); + + /* "embedded" nodetree cases (i.e. scene/material/texture->nodetree) */ +#define ANIMDATA_NODETREE_IDS_CB(first, NtId_Type) \ + for (id= first; id; id= id->next) { \ + AnimData *adt= BKE_animdata_from_id(id); \ + NtId_Type *ntp= (NtId_Type *)id; \ + if (ntp->nodetree) { \ + AnimData *adt2= BKE_animdata_from_id((ID *)ntp); \ + if (adt2) func(id, adt2, user_data); \ + } \ + if (adt) func(id, adt, user_data); \ } + + /* nodes */ + ANIMDATA_IDS_CB(mainptr->nodetree.first); + + /* textures */ + ANIMDATA_NODETREE_IDS_CB(mainptr->tex.first, Tex); + + /* lamps */ + ANIMDATA_IDS_CB(mainptr->lamp.first); + + /* materials */ + ANIMDATA_NODETREE_IDS_CB(mainptr->mat.first, Material); + + /* cameras */ + ANIMDATA_IDS_CB(mainptr->camera.first); + + /* shapekeys */ + ANIMDATA_IDS_CB(mainptr->key.first); + + /* metaballs */ + ANIMDATA_IDS_CB(mainptr->mball.first); + + /* curves */ + ANIMDATA_IDS_CB(mainptr->curve.first); + + /* armatures */ + ANIMDATA_IDS_CB(mainptr->armature.first); + + /* lattices */ + ANIMDATA_IDS_CB(mainptr->latt.first); + + /* meshes */ + ANIMDATA_IDS_CB(mainptr->mesh.first); + + /* particles */ + ANIMDATA_IDS_CB(mainptr->particle.first); + + /* objects */ + ANIMDATA_IDS_CB(mainptr->object.first); + + /* worlds */ + ANIMDATA_IDS_CB(mainptr->world.first); + + /* scenes */ + ANIMDATA_NODETREE_IDS_CB(mainptr->scene.first, Scene); } /* Fix all RNA-Paths throughout the database (directly access the Global.main version) @@ -525,17 +554,29 @@ void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newNa BKE_animdata_fix_paths_rename(id, adt, prefix, oldName, newName, 0, 0, 1);\ } + /* another version of this macro for nodetrees */ +#define RENAMEFIX_ANIM_NODETREE_IDS(first, NtId_Type) \ + for (id= first; id; id= id->next) { \ + AnimData *adt= BKE_animdata_from_id(id); \ + NtId_Type *ntp= (NtId_Type *)id; \ + if (ntp->nodetree) { \ + AnimData *adt2= BKE_animdata_from_id((ID *)ntp); \ + BKE_animdata_fix_paths_rename((ID *)ntp, adt2, prefix, oldName, newName, 0, 0, 1);\ + } \ + BKE_animdata_fix_paths_rename(id, adt, prefix, oldName, newName, 0, 0, 1);\ + } + /* nodes */ RENAMEFIX_ANIM_IDS(mainptr->nodetree.first); /* textures */ - RENAMEFIX_ANIM_IDS(mainptr->tex.first); + RENAMEFIX_ANIM_NODETREE_IDS(mainptr->tex.first, Tex); /* lamps */ RENAMEFIX_ANIM_IDS(mainptr->lamp.first); /* materials */ - RENAMEFIX_ANIM_IDS(mainptr->mat.first); + RENAMEFIX_ANIM_NODETREE_IDS(mainptr->mat.first, Material); /* cameras */ RENAMEFIX_ANIM_IDS(mainptr->camera.first); @@ -552,8 +593,11 @@ void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newNa /* armatures */ RENAMEFIX_ANIM_IDS(mainptr->armature.first); + /* lattices */ + RENAMEFIX_ANIM_IDS(mainptr->latt.first); + /* meshes */ - // TODO... + RENAMEFIX_ANIM_IDS(mainptr->mesh.first); /* particles */ RENAMEFIX_ANIM_IDS(mainptr->particle.first); @@ -565,19 +609,7 @@ void BKE_all_animdata_fix_paths_rename (char *prefix, char *oldName, char *newNa RENAMEFIX_ANIM_IDS(mainptr->world.first); /* scenes */ - for (id= mainptr->scene.first; id; id= id->next) { - AnimData *adt= BKE_animdata_from_id(id); - Scene *scene= (Scene *)id; - - /* do compositing nodes first (since these aren't included in main tree) */ - if (scene->nodetree) { - AnimData *adt2= BKE_animdata_from_id((ID *)scene->nodetree); - BKE_animdata_fix_paths_rename((ID *)scene->nodetree, adt2, prefix, oldName, newName, 0, 0, 1); - } - - /* now fix scene animation data as per normal */ - BKE_animdata_fix_paths_rename((ID *)id, adt, prefix, oldName, newName, 0, 0, 1); - } + RENAMEFIX_ANIM_NODETREE_IDS(mainptr->scene.first, Scene); } /* *********************************** */ @@ -1901,7 +1933,6 @@ void BKE_animsys_evaluate_all_animation (Main *main, float ctime) EVAL_ANIM_IDS(main->camera.first, ADT_RECALC_ANIM); /* shapekeys */ - // TODO: we probably need the same hack as for curves (ctime-hack) EVAL_ANIM_IDS(main->key.first, ADT_RECALC_ANIM); /* metaballs */ -- cgit v1.2.3 From 92172b779e28fdd9321dd298bd14a3c93371bcbe Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 29 Dec 2010 11:51:53 +0000 Subject: Bugfix [#24163] Unable to animate INSIDE a group node in the compositor This commit fixes the original bug reported here by adding some methods to move the relevant F-Curves (and drivers) over to the new Node-Tree's (i.e. group-node) AnimData. Animated nodes which subsequently get grouped will still be able to animate as a result of this commit. TODO's: - Ungrouping now will not yet merge the animation back (or at least copy it) - Buttons for nodes freshly grouped do not correctly show animated status indicators for some reason, yet normal animation does --- source/blender/blenkernel/intern/action.c | 15 ++- source/blender/blenkernel/intern/anim_sys.c | 170 ++++++++++++++++++++++++++++ source/blender/blenkernel/intern/node.c | 38 ++++++- 3 files changed, 220 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 227f2eadf4c..fdd51dd207f 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -96,7 +96,6 @@ void make_local_action(bAction *act) if (act->id.us==1) { act->id.lib= 0; act->id.flag= LIB_LOCAL; - //make_local_action_channels(act); new_id(0, (ID *)act, 0); return; } @@ -376,6 +375,20 @@ bActionGroup *action_groups_find_named (bAction *act, const char name[]) return BLI_findstring(&act->groups, name, offsetof(bActionGroup, name)); } +/* Clear all 'temp' flags on all groups */ +void action_groups_clear_tempflags (bAction *act) +{ + bActionGroup *agrp; + + /* sanity checks */ + if (ELEM(NULL, act, act->groups.first)) + return; + + /* flag clearing loop */ + for (agrp = act->groups.first; agrp; agrp = agrp->next) + agrp->flag &= ~AGRP_TEMP; +} + /* *************** Pose channels *************** */ /* usually used within a loop, so we got a N^2 slowdown */ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 41c6969cdce..e8a9851b0d9 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -276,6 +276,176 @@ void BKE_animdata_make_local(AnimData *adt) make_local_strips(&nlt->strips); } +/* Sub-ID Regrouping ------------------------------------------- */ + +/* helper heuristic for determining if a path is compatible with the basepath + * < path: (str) full RNA-path from some data (usually an F-Curve) to compare + * < basepath: (str) shorter path fragment to look for + * > returns (bool) whether there is a match + */ +static short animpath_matches_basepath (const char path[], const char basepath[]) +{ + /* we need start of path to be basepath */ + return (path && basepath) && (strstr(path, basepath) == path); +} + +/* Move F-Curves in src action to dst action, setting up all the necessary groups + * for this to happen, but only if the F-Curves being moved have the appropriate + * "base path". + * - This is used when data moves from one datablock to another, causing the + * F-Curves to need to be moved over too + */ +void action_move_fcurves_by_basepath (bAction *srcAct, bAction *dstAct, const char basepath[]) +{ + FCurve *fcu, *fcn=NULL; + + /* sanity checks */ + if ELEM3(NULL, srcAct, dstAct, basepath) { + if (G.f & G_DEBUG) { + printf("ERROR: action_partition_fcurves_by_basepath(%p, %p, %p) has insufficient info to work with\n", + srcAct, dstAct, basepath); + } + return; + } + + /* clear 'temp' flags on all groups in src, as we'll be needing them later + * to identify groups that we've managed to empty out here + */ + action_groups_clear_tempflags(srcAct); + + /* iterate over all src F-Curves, moving over the ones that need to be moved */ + for (fcu = srcAct->curves.first; fcu; fcu = fcn) { + /* store next pointer in case we move stuff */ + fcn = fcu->next; + + /* should F-Curve be moved over? + * - we only need the start of the path to match basepath + */ + if (animpath_matches_basepath(fcu->rna_path, basepath)) { + bActionGroup *agrp = NULL; + + /* if grouped... */ + if (fcu->grp) { + /* make sure there will be a matching group on the other side for the migrants */ + agrp = action_groups_find_named(dstAct, fcu->grp->name); + + if (agrp == NULL) { + /* add a new one with a similar name (usually will be the same though) */ + agrp = action_groups_add_new(dstAct, fcu->grp->name); + } + + /* old groups should be tagged with 'temp' flags so they can be removed later + * if we remove everything from them + */ + fcu->grp->flag |= AGRP_TEMP; + } + + /* perform the migration now */ + action_groups_remove_channel(srcAct, fcu); + + if (agrp) + action_groups_add_channel(dstAct, agrp, fcu); + else + BLI_addtail(&dstAct->curves, fcu); + } + } + + /* cleanup groups (if present) */ + if (srcAct->groups.first) { + bActionGroup *agrp, *grp=NULL; + + for (agrp = srcAct->groups.first; agrp; agrp = grp) { + grp = agrp->next; + + /* only tagged groups need to be considered - clearing these tags or removing them */ + if (agrp->flag & AGRP_TEMP) { + /* if group is empty and tagged, then we can remove as this operation + * moved out all the channels that were formerly here + */ + if (agrp->channels.first == NULL) + BLI_freelinkN(&srcAct->groups, agrp); + else + agrp->flag &= ~AGRP_TEMP; + } + } + } +} + +/* Transfer the animation data from srcID to dstID where the srcID + * animation data is based off "basepath", creating new AnimData and + * associated data as necessary + */ +void BKE_animdata_separate_by_basepath (ID *srcID, ID *dstID, ListBase *basepaths) +{ + AnimData *srcAdt=NULL, *dstAdt=NULL; + LinkData *ld; + + /* sanity checks */ + if ELEM(NULL, srcID, dstID) { + if (G.f & G_DEBUG) + printf("ERROR: no source or destination ID to separate AnimData with\n"); + return; + } + + /* get animdata from src, and create for destination (if needed) */ + srcAdt = BKE_animdata_from_id(srcID); + dstAdt = BKE_id_add_animdata(dstID); + + if ELEM(NULL, srcAdt, dstAdt) { + if (G.f & G_DEBUG) + printf("ERROR: no AnimData for this pair of ID's\n"); + return; + } + + /* active action */ + if (srcAdt->action) { + /* set up an action if necessary, and name it in a similar way so that it can be easily found again */ + if (dstAdt->action == NULL) { + dstAdt->action = add_empty_action(srcAdt->action->id.name+2); + } + else if (dstAdt->action == srcAdt->action) { + printf("Argh! Source and Destination share animation! ('%s' and '%s' both use '%s') Making new empty action\n", + srcID, dstID, srcAdt->action); + + // TODO: review this... + id_us_min(dstAdt->action); + dstAdt->action = add_empty_action(dstAdt->action->id.name+2); + } + + /* loop over base paths, trying to fix for each one... */ + for (ld = basepaths->first; ld; ld = ld->next) { + const char *basepath = (const char *)ld->data; + action_move_fcurves_by_basepath(srcAdt->action, dstAdt->action, basepath); + } + } + + /* drivers */ + if (srcAdt->drivers.first) { + FCurve *fcu, *fcn=NULL; + + /* check each driver against all the base paths to see if any should go */ + for (fcu = srcAdt->drivers.first; fcu; fcu = fcn) { + fcn = fcu->next; + + /* try each basepath in turn, but stop on the first one which works */ + for (ld = basepaths->first; ld; ld = ld->next) { + const char *basepath = (const char *)ld->data; + + if (animpath_matches_basepath(fcu->rna_path, basepath)) { + /* just need to change lists */ + BLI_remlink(&srcAdt->drivers, fcu); + BLI_addtail(&dstAdt->drivers, fcu); + + // TODO: add depsgraph flushing calls? + + /* can stop now, as moved already */ + break; + } + } + } + } +} + /* Path Validation -------------------------------------------- */ /* Check if a given RNA Path is valid, by tracing it from the given ID, and seeing if we can resolve it */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 0513593a0e0..f85def22566 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -36,11 +36,13 @@ #include #include "DNA_anim_types.h" +#include "DNA_action_types.h" #include "RNA_access.h" +#include "BKE_animsys.h" +#include "BKE_action.h" #include "BKE_fcurve.h" -#include "BKE_animsys.h" /* BKE_free_animdata only */ #include "PIL_time.h" @@ -460,6 +462,7 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) bNode *node, *gnode, *nextn; bNodeSocket *sock; bNodeTree *ngroup; + ListBase anim_basepaths = {NULL, NULL}; float min[2], max[2]; int totnode=0; @@ -502,11 +505,27 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) for(node= ntree->nodes.first; node; node= nextn) { nextn= node->next; if(node->flag & NODE_SELECT) { + /* keep track of this node's RNA "base" path (the part of the pat identifying the node) + * if the old nodetree has animation data which potentially covers this node + */ + if (ntree->adt) { + PointerRNA ptr; + char *path; + + RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr); + path = RNA_path_from_ID_to_struct(&ptr); + + if (path) + BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); + } + + /* change node-collection membership */ BLI_remlink(&ntree->nodes, node); BLI_addtail(&ngroup->nodes, node); + node->locx-= 0.5f*(min[0]+max[0]); node->locy-= 0.5f*(min[1]+max[1]); - + /* set socket own_index to zero since it can still have a value * from being in a group before, otherwise it doesn't get a unique * index in group_verify_own_indices */ @@ -526,6 +545,21 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) } } + /* move animation data over */ + if (ntree->adt) { + LinkData *ld, *ldn=NULL; + + BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths); + + /* paths + their wrappers need to be freed */ + for (ld = anim_basepaths.first; ld; ld = ld->next) { + ldn = ld->next; + + MEM_freeN(ld->data); + BLI_freelinkN(&anim_basepaths, ld); + } + } + /* now we can make own group typeinfo */ ntreeMakeOwnType(ngroup); -- cgit v1.2.3 From 32b23b2b822d5229d05ef3d14144f9e16240d2ad Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 29 Dec 2010 12:18:59 +0000 Subject: Bugfix [#24163] (PART 2) Unable to animate INSIDE a group node in the compositor Now ungrouping grouped-nodes copies the animation back to the main nodetree. This means that it is now possible to successfully roundtrip group/un-group nodes and their animation data. --- This should also be done for the Separate Armature operator... hmm... --- source/blender/blenkernel/intern/node.c | 48 ++++++++++++++++++++++++++++++++- 1 file changed, 47 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 f85def22566..db11b42ee1e 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -805,6 +805,7 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode) bNodeLink *link, *linkn; bNode *node, *nextn; bNodeTree *ngroup, *wgroup; + ListBase anim_basepaths = {NULL, NULL}; int index; ngroup= (bNodeTree *)gnode->id; @@ -813,16 +814,38 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode) /* clear new pointers, set in copytree */ for(node= ntree->nodes.first; node; node= node->next) node->new_node= NULL; - + + /* wgroup is a temporary copy of the NodeTree we're merging in + * - all of wgroup's nodes are transferred across to their new home + * - ngroup (i.e. the source NodeTree) is left unscathed + */ wgroup= ntreeCopyTree(ngroup, 0); /* add the nodes into the ntree */ for(node= wgroup->nodes.first; node; node= nextn) { nextn= node->next; + + /* keep track of this node's RNA "base" path (the part of the pat identifying the node) + * if the old nodetree has animation data which potentially covers this node + */ + if (wgroup->adt) { + PointerRNA ptr; + char *path; + + RNA_pointer_create(&wgroup->id, &RNA_Node, node, &ptr); + path = RNA_path_from_ID_to_struct(&ptr); + + if (path) + BLI_addtail(&anim_basepaths, BLI_genericNodeN(path)); + } + + /* migrate node */ BLI_remlink(&wgroup->nodes, node); BLI_addtail(&ntree->nodes, node); + node->locx+= gnode->locx; node->locy+= gnode->locy; + node->flag |= NODE_SELECT; } /* and the internal links */ @@ -831,6 +854,29 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode) BLI_remlink(&wgroup->links, link); BLI_addtail(&ntree->links, link); } + + /* and copy across the animation */ + if (wgroup->adt) { + LinkData *ld, *ldn=NULL; + bAction *waction; + + /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */ + waction = wgroup->adt->action = copy_action(wgroup->adt->action); + + /* now perform the moving */ + BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths); + + /* paths + their wrappers need to be freed */ + for (ld = anim_basepaths.first; ld; ld = ld->next) { + ldn = ld->next; + + MEM_freeN(ld->data); + BLI_freelinkN(&anim_basepaths, ld); + } + + /* free temp action too */ + free_libblock(&G.main->action, waction); + } /* restore links to and from the gnode */ for(link= ntree->links.first; link; link= link->next) { -- cgit v1.2.3 From f22a3c16b148fe0c02c92347f063df45019b3814 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 29 Dec 2010 12:27:03 +0000 Subject: Silencing some compiler warnings (gcc) --- source/blender/blenkernel/intern/particle.c | 6 +++--- source/blender/blenkernel/intern/sequencer.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index a7506f2114b..95e14542e28 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1158,7 +1158,7 @@ static void init_particle_interpolation(Object *ob, ParticleSystem *psys, Partic pind->dietime = (key + pa->totkey - 1)->time; } else if(pind->cache) { - float start, end; + float start=0.0f, end=0.0f; get_pointcache_keys_for_time(ob, pind->cache, &pind->pm, -1, 0.0f, NULL, NULL); pind->birthtime = pa ? pa->time : pind->cache->startframe; pind->dietime = pa ? pa->dietime : pind->cache->endframe; @@ -2807,7 +2807,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) float birthtime = 0.0, dietime = 0.0; float t, time = 0.0, dfra = 1.0, frs_sec = sim->scene->r.frs_sec; float col[4] = {0.5f, 0.5f, 0.5f, 1.0f}; - float prev_tangent[3], hairmat[4][4]; + float prev_tangent[3] = {0.0f, 0.0f, 0.0f}, hairmat[4][4]; float rotmat[3][3]; int k; int steps = (int)pow(2.0, (double)(psys->renderdata ? part->ren_step : part->draw_step)); @@ -3025,7 +3025,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf float birthtime = 0.0, dietime = 0.0; float t, time = 0.0, keytime = 0.0, frs_sec; - float hairmat[4][4], rotmat[3][3], prev_tangent[3]; + float hairmat[4][4], rotmat[3][3], prev_tangent[3] = {0.0f, 0.0f, 0.0f}; int k, i; int steps = (int)pow(2.0, (double)pset->draw_step); int totpart = edit->totpoint, recalc_set=0; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 19f872fbd40..1b5d1093373 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -642,7 +642,7 @@ void calc_sequence(Scene *scene, Sequence *seq) void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) { char str[FILE_MAXDIR+FILE_MAXFILE]; - int prev_startdisp, prev_enddisp; + int prev_startdisp=0, prev_enddisp=0; /* note: dont rename the strip, will break animation curves */ if (ELEM5(seq->type, SEQ_MOVIE, SEQ_IMAGE, SEQ_SOUND, SEQ_SCENE, SEQ_META)==0) { -- cgit v1.2.3 From b67692a1302f49eafe5202ed9e6d1af14bf6fb24 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 30 Dec 2010 05:41:17 +0000 Subject: Various pedantic fixes to satisfy compilers. --- source/blender/blenkernel/intern/anim_sys.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index e8a9851b0d9..3252b1f71b2 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -405,10 +405,10 @@ void BKE_animdata_separate_by_basepath (ID *srcID, ID *dstID, ListBase *basepath } else if (dstAdt->action == srcAdt->action) { printf("Argh! Source and Destination share animation! ('%s' and '%s' both use '%s') Making new empty action\n", - srcID, dstID, srcAdt->action); + srcID->id.name, dstID->id.name, srcAdt->action->id.name); // TODO: review this... - id_us_min(dstAdt->action); + id_us_min(&dstAdt->action->id); dstAdt->action = add_empty_action(dstAdt->action->id.name+2); } -- cgit v1.2.3 From 9fa2f9ffb6f4c885faf549909f9833e75bd18d7f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 30 Dec 2010 05:47:34 +0000 Subject: Doh! --- source/blender/blenkernel/intern/anim_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 3252b1f71b2..b81d611065d 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -405,7 +405,7 @@ void BKE_animdata_separate_by_basepath (ID *srcID, ID *dstID, ListBase *basepath } else if (dstAdt->action == srcAdt->action) { printf("Argh! Source and Destination share animation! ('%s' and '%s' both use '%s') Making new empty action\n", - srcID->id.name, dstID->id.name, srcAdt->action->id.name); + srcID->name, dstID->name, srcAdt->action->id.name); // TODO: review this... id_us_min(&dstAdt->action->id); -- cgit v1.2.3 From a8406439938d3eb405c144a50d87100f48f77c7e Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 31 Dec 2010 04:09:15 +0000 Subject: Bugfix [#25414] Entering a newline before a : still indents it Fixed by patch attached by submitter. Cheers Jacob F (racoon)! If you write something like... def do_something: ...and press return it makes the new line with a tab which is good, but if you want to move the def line down to make room above it by pressing return while your caret is at the start of the line it indents the new line which has the def statement on it. Attached patch just checks if it's checking for a colon after the caret and returns if it is. --- source/blender/blenkernel/intern/text.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index bbdc188d580..bb3a31a0977 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2710,9 +2710,13 @@ int setcurr_tab_spaces (Text *text, int space) } if(strstr(text->curl->line, word)) { - //if we find a : then add a tab but not if it is in a comment + /* if we find a ':' on this line, then add a tab but not if it is: + * 1) in a comment + * 2) within an identifier + * 3) after the cursor (text->curc), i.e. when creating space before a function def [#25414] + */ int a, indent = 0; - for(a=0; text->curl->line[a] != '\0'; a++) + for(a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++) { if (text->curl->line[a]=='#') { break; -- cgit v1.2.3 From c68e3913ed861b4a932cc47029997f74e6d795cd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 31 Dec 2010 11:51:00 +0000 Subject: fix [#25429] Armature modifier and inverted vertex group - the invert flag was only being used for multi-modifier, but there is no reason not to use this in normal cases as well. - Armature modifier RNA name 'vertex_group' was incorrectly named 'vertex_group_multi_modifier' (own fault), confusion was caused by 'invert_vertex_group_multi_modifier' which was correct. --- source/blender/blenkernel/intern/armature.c | 16 ++++++---------- source/blender/blenkernel/intern/deform.c | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 22d27dc2fde..6b21e45ddd9 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -936,19 +936,15 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, dvert = NULL; if(armature_def_nr >= 0 && dvert) { - armature_weight = 0.0f; /* a def group was given, so default to 0 */ - for(j = 0; j < dvert->totweight; j++) { - if(dvert->dw[j].def_nr == armature_def_nr) { - armature_weight = dvert->dw[j].weight; - break; - } + armature_weight= defvert_find_weight(dvert, armature_def_nr); + + if(invert_vgroup) { + armature_weight= 1.0f-armature_weight; } + /* hackish: the blending factor can be used for blending with prevCos too */ if(prevCos) { - if(invert_vgroup) - prevco_weight= 1.0f-armature_weight; - else - prevco_weight= armature_weight; + prevco_weight= armature_weight; armature_weight= 1.0f; } } diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index ad797736a85..937681fcdc3 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -448,7 +448,7 @@ void flip_side_name (char *name, const char *from_name, int strip_number) sprintf (name, "%s%s%s%s", prefix, replace, suffix, number); } -float defvert_find_weight(const struct MDeformVert *dvert, int group_num) +float defvert_find_weight(const struct MDeformVert *dvert, const int group_num) { MDeformWeight *dw= defvert_find_index(dvert, group_num); return dw ? dw->weight : 0.0f; -- cgit v1.2.3 From c169ccc711edc182d4983f59c1124aee91e7acd5 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Fri, 31 Dec 2010 20:01:38 +0000 Subject: Silence more compiler warnings. --- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/blenkernel/intern/font.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index e178beaaa50..03d31549214 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -611,7 +611,7 @@ static int mdisp_rot_face_to_crn(int corners, int face_side, float u, float v, f static void mdisp_apply_weight(int S, int corners, int x, int y, int face_side, float crn_weight[4][2], float *u_r, float *v_r) { - float u, v, xl, yl; + float u = 0.f, v = 0.f, xl, yl; float mid1[2], mid2[2], mid3[2]; mdisp_rot_crn_to_face(S, corners, face_side, x, y, &u, &v); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 500ccf0781b..ec63975a3c0 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -670,7 +670,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) VFont *vfont, *oldvfont; VFontData *vfd= NULL; Curve *cu; - CharInfo *info, *custrinfo; + CharInfo *info = NULL, *custrinfo; TextBox *tb; VChar *che; struct chartrans *chartransdata=NULL, *ct; -- cgit v1.2.3 From a6a2512f47fb0019ea3cb68b2cb303d7933daa67 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 2 Jan 2011 06:52:47 +0000 Subject: Pointcache code cleanup and disk cache compression options: * Massive reorganization of pointcache code, things are now cleaner than ever. * For all but smoke the cache is first written to memory when using disk cache and after that written to disk in one operation. This allows less disk operations and the possibility to compress the data before writing it to disk. * Previously only smoke cache could be compressed, now the same options exist for other physics types too (when using disk cache). For now the default compression option is still "no compression", but if there aren't any problems this can be set to "light compression" as it's actually faster than no compression in most cases since there's less data to write to the disk. Based on quick tests heavy compression can reduce the file size down to 1/3rd of the original size, but is really slow compared to other options, so it should be used only if file size is critical! * The pointcache code wasn't really 64bit compatible (for disk cache) until now, so this update should fix some crashes on 64bit builds too. Now all integer data that's saved to disk uses 32 bit unsigned integers, so simulations done on 64bit should load fine on 32bit machines and vice versa. (Important disk cache simulations made on 64bit builds should be converted to memory cache in a revision before this commit). * There are also the beginnings of extradata handling code in pointcache in anticipation of adding the dynamic springs for particle fluids (the springs need to be stored as extradata into point cache). * Particles were being read from the cache with a slightly wrong framerate. In most cases this probably wasn't noticeable, but none the less the code is now correct in every way. * Small other fixes here and there & some cosmetic changes to cache panel, but over all there should be no functional changes other than the new disk cache compression options. * This whole re-organization also seems to fix bug #25436 and hopefully shouldn't introduce any new ones! --- source/blender/blenkernel/intern/cloth.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 4 +- source/blender/blenkernel/intern/pointcache.c | 1311 +++++++++++--------- source/blender/blenkernel/intern/smoke.c | 2 +- source/blender/blenkernel/intern/softbody.c | 2 +- 5 files changed, 731 insertions(+), 590 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index f644b28b137..b283120249e 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -504,7 +504,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, } /* try to read from cache */ - cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe, scene->r.frs_sec); + cache_result = BKE_ptcache_read(&pid, (float)framenr+scene->r.subframe); if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { implicit_set_positions(clmd); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 1f36f0845a2..94350ac30fa 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2244,7 +2244,9 @@ void psys_make_temp_pointcache(Object *ob, ParticleSystem *psys) if(cache->flag & PTCACHE_DISK_CACHE && cache->mem_cache.first == NULL) { PTCacheID pid; BKE_ptcache_id_from_particles(&pid, ob, psys); + cache->flag &= ~PTCACHE_DISK_CACHE; BKE_ptcache_disk_to_mem(&pid); + cache->flag |= PTCACHE_DISK_CACHE; } } static void psys_clear_temp_pointcache(ParticleSystem *psys) @@ -3795,7 +3797,7 @@ static void system_step(ParticleSimulationData *sim, float cfra) /* 2. try to read from the cache */ if(pid) { - int cache_result = BKE_ptcache_read(pid, cache_cfra, sim->scene->r.frs_sec); + int cache_result = BKE_ptcache_read(pid, cache_cfra); if(ELEM(cache_result, PTCACHE_READ_EXACT, PTCACHE_READ_INTERPOLATED)) { cached_step(sim, cfra); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 7a8d3a8b19c..6b08f17713d 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -96,7 +96,7 @@ #define DURIAN_POINTCACHE_LIB_OK 1 int ptcache_data_size[] = { - sizeof(int), // BPHYS_DATA_INDEX + sizeof(uint32_t), // BPHYS_DATA_INDEX 3 * sizeof(float), // BPHYS_DATA_LOCATION: 3 * sizeof(float), // BPHYS_DATA_VELOCITY: 4 * sizeof(float), // BPHYS_DATA_ROTATION: @@ -107,30 +107,38 @@ int ptcache_data_size[] = { }; /* forward declerations */ -static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size); -static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size); +static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, size_t len); +static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, size_t in_len, unsigned char *out, int mode); +static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, size_t size); +static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, size_t size); /* Common functions */ static int ptcache_basic_header_read(PTCacheFile *pf) { + uint32_t totpoint, data_types; int error=0; /* Custom functions should read these basic elements too! */ - if(!error && !fread(&pf->totpoint, sizeof(int), 1, pf->fp)) + if(!error && !fread(&totpoint, sizeof(int), 1, pf->fp)) error = 1; + pf->totpoint = totpoint; - if(!error && !fread(&pf->data_types, sizeof(int), 1, pf->fp)) + if(!error && !fread(&data_types, sizeof(int), 1, pf->fp)) error = 1; + pf->data_types = data_types; return !error; } static int ptcache_basic_header_write(PTCacheFile *pf) { + uint32_t totpoint = pf->totpoint; + uint32_t data_types = pf->data_types; + /* Custom functions should write these basic elements too! */ - if(!fwrite(&pf->totpoint, sizeof(int), 1, pf->fp)) + if(!fwrite(&totpoint, sizeof(int), 1, pf->fp)) return 0; - if(!fwrite(&pf->data_types, sizeof(int), 1, pf->fp)) + if(!fwrite(&data_types, sizeof(int), 1, pf->fp)) return 0; return 1; @@ -146,7 +154,7 @@ static int ptcache_softbody_write(int index, void *soft_v, void **data, int UNU return 1; } -static void ptcache_softbody_read(int index, void *soft_v, void **data, float UNUSED(frs_sec), float UNUSED(cfra), float *old_data) +static void ptcache_softbody_read(int index, void *soft_v, void **data, float UNUSED(cfra), float *old_data) { SoftBody *soft= soft_v; BodyPoint *bp = soft->bpoint + index; @@ -160,7 +168,7 @@ static void ptcache_softbody_read(int index, void *soft_v, void **data, float UN PTCACHE_DATA_TO(data, BPHYS_DATA_VELOCITY, 0, bp->vec); } } -static void ptcache_softbody_interpolate(int index, void *soft_v, void **data, float UNUSED(frs_sec), float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_softbody_interpolate(int index, void *soft_v, void **data, float cfra, float cfra1, float cfra2, float *old_data) { SoftBody *soft= soft_v; BodyPoint *bp = soft->bpoint + index; @@ -244,11 +252,12 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfr /* return flag 1+1=2 for newly born particles to copy exact birth location to previously cached frame */ return 1 + (pa->state.time >= pa->time && pa->prev_state.time <= pa->time); } -static void ptcache_particle_read(int index, void *psys_v, void **data, float frs_sec, float cfra, float *old_data) +static void ptcache_particle_read(int index, void *psys_v, void **data, float cfra, float *old_data) { ParticleSystem *psys= psys_v; ParticleData *pa; BoidParticle *boid; + float timestep = 0.04f*psys->part->timetweak; if(index >= psys->totpart) return; @@ -289,11 +298,11 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float fr if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { if(cfra > pa->prev_state.time) { sub_v3_v3v3(pa->state.vel, pa->state.co, pa->prev_state.co); - mul_v3_fl(pa->state.vel, (cfra - pa->prev_state.time) / frs_sec); + mul_v3_fl(pa->state.vel, (cfra - pa->prev_state.time) * timestep); } else { sub_v3_v3v3(pa->state.vel, pa->prev_state.co, pa->state.co); - mul_v3_fl(pa->state.vel, (pa->prev_state.time - cfra) / frs_sec); + mul_v3_fl(pa->state.vel, (pa->prev_state.time - cfra) * timestep); } } @@ -302,12 +311,12 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float fr vec_to_quat( pa->state.rot,pa->state.vel, OB_NEGX, OB_POSZ); } } -static void ptcache_particle_interpolate(int index, void *psys_v, void **data, float frs_sec, float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_particle_interpolate(int index, void *psys_v, void **data, float cfra, float cfra1, float cfra2, float *old_data) { ParticleSystem *psys= psys_v; ParticleData *pa; ParticleKey keys[4]; - float dfra; + float dfra, timestep = 0.04f*psys->part->timetweak; if(index >= psys->totpart) return; @@ -335,11 +344,11 @@ static void ptcache_particle_interpolate(int index, void *psys_v, void **data, f if(data[BPHYS_DATA_LOCATION] && !data[BPHYS_DATA_VELOCITY]) { if(keys[1].time > keys[2].time) { sub_v3_v3v3(keys[2].vel, keys[1].co, keys[2].co); - mul_v3_fl(keys[2].vel, (keys[1].time - keys[2].time) / frs_sec); + mul_v3_fl(keys[2].vel, (keys[1].time - keys[2].time) * timestep); } else { sub_v3_v3v3(keys[2].vel, keys[2].co, keys[1].co); - mul_v3_fl(keys[2].vel, (keys[2].time - keys[1].time) / frs_sec); + mul_v3_fl(keys[2].vel, (keys[2].time - keys[1].time) * timestep); } } @@ -353,13 +362,13 @@ static void ptcache_particle_interpolate(int index, void *psys_v, void **data, f dfra = cfra2 - cfra1; - mul_v3_fl(keys[1].vel, dfra / frs_sec); - mul_v3_fl(keys[2].vel, dfra / frs_sec); + mul_v3_fl(keys[1].vel, dfra * timestep); + mul_v3_fl(keys[2].vel, dfra * timestep); psys_interpolate_particle(-1, keys, (cfra - cfra1) / dfra, &pa->state, 1); interp_qt_qtqt(pa->state.rot, keys[1].rot, keys[2].rot, (cfra - cfra1) / dfra); - mul_v3_fl(pa->state.vel, frs_sec / dfra); + mul_v3_fl(pa->state.vel, 1.f / (dfra * timestep)); pa->state.time = cfra; } @@ -376,6 +385,9 @@ static int ptcache_particle_totwrite(void *psys_v, int cfra) int p, step = psys->pointcache->step; int totwrite = 0; + if(cfra == 0) + return psys->totpart; + for(p=0; ptotpart; p++,pa++) totwrite += (cfra >= pa->time - step && cfra <= pa->dietime + step); @@ -395,7 +407,7 @@ static int ptcache_cloth_write(int index, void *cloth_v, void **data, int UNUSE return 1; } -static void ptcache_cloth_read(int index, void *cloth_v, void **data, float UNUSED(frs_sec), float UNUSED(cfra), float *old_data) +static void ptcache_cloth_read(int index, void *cloth_v, void **data, float UNUSED(cfra), float *old_data) { ClothModifierData *clmd= cloth_v; Cloth *cloth= clmd->clothObject; @@ -412,7 +424,7 @@ static void ptcache_cloth_read(int index, void *cloth_v, void **data, float UNUS PTCACHE_DATA_TO(data, BPHYS_DATA_XCONST, 0, vert->xconst); } } -static void ptcache_cloth_interpolate(int index, void *cloth_v, void **data, float UNUSED(frs_sec), float cfra, float cfra1, float cfra2, float *old_data) +static void ptcache_cloth_interpolate(int index, void *cloth_v, void **data, float cfra, float cfra1, float cfra2, float *old_data) { ClothModifierData *clmd= cloth_v; Cloth *cloth= clmd->clothObject; @@ -455,106 +467,6 @@ static int ptcache_cloth_totpoint(void *cloth_v, int UNUSED(cfra)) } /* Smoke functions */ -static int ptcache_compress_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode) -{ - int r = 0; - unsigned char compressed = 0; - unsigned int out_len= 0; - unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); - size_t sizeOfIt = 5; - - (void)mode; /* unused when building w/o compression */ - -#ifdef WITH_LZO - out_len= LZO_OUT_LEN(in_len); - if(mode == 1) { - LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS); - - r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem); - if (!(r == LZO_E_OK) || (out_len >= in_len)) - compressed = 0; - else - compressed = 1; - } -#endif -#ifdef WITH_LZMA - if(mode == 2) { - - r = LzmaCompress(out, (size_t *)&out_len, in, in_len,//assume sizeof(char)==1.... - props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2); - - if(!(r == SZ_OK) || (out_len >= in_len)) - compressed = 0; - else - compressed = 2; - } -#endif - - ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char)); - if(compressed) { - ptcache_file_write(pf, &out_len, 1, sizeof(unsigned int)); - ptcache_file_write(pf, out, out_len, sizeof(unsigned char)); - } - else - ptcache_file_write(pf, in, in_len, sizeof(unsigned char)); - - if(compressed == 2) - { - ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int)); - ptcache_file_write(pf, props, sizeOfIt, sizeof(unsigned char)); - } - - MEM_freeN(props); - - return r; -} - -static int ptcache_compress_read(PTCacheFile *pf, unsigned char *result, unsigned int len) -{ - int r = 0; - unsigned char compressed = 0; - unsigned int in_len; -#ifdef WITH_LZO - unsigned int out_len = len; - size_t sizeOfIt = 5; -#endif - unsigned char *in; - unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); - - ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char)); - if(compressed) { - ptcache_file_read(pf, &in_len, 1, sizeof(unsigned int)); - if(in_len==0) { - /* do nothing */ - } - else { - in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer"); - ptcache_file_read(pf, in, in_len, sizeof(unsigned char)); -#ifdef WITH_LZO - if(compressed == 1) - r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL); -#endif -#ifdef WITH_LZMA - if(compressed == 2) - { - size_t leni = in_len, leno = out_len; - ptcache_file_read(pf, &sizeOfIt, 1, sizeof(unsigned int)); - ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char)); - r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt); - } -#endif - MEM_freeN(in); - } - } - else { - ptcache_file_read(pf, result, len, sizeof(unsigned char)); - } - - MEM_freeN(props); - - return r; -} - static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra)) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; @@ -566,8 +478,6 @@ static int ptcache_smoke_totpoint(void *smoke_v, int UNUSED(cfra)) else return 0; } - - static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; @@ -586,18 +496,18 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v) smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles); - ptcache_compress_write(pf, (unsigned char *)sds->shadow, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)dens, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)densold, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)heat, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)heatold, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vx, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vy, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vz, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vxold, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vyold, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)vzold, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)obstacles, (unsigned int)res, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)sds->shadow, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)densold, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)heat, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)heatold, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)vx, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)vy, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)vz, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)vxold, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)vyold, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)vzold, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)obstacles, (unsigned int)res, out, mode); ptcache_file_write(pf, &dt, 1, sizeof(float)); ptcache_file_write(pf, &dx, 1, sizeof(float)); @@ -627,14 +537,14 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v) smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw); out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len_big), "pointcache_lzo_buffer"); - ptcache_compress_write(pf, (unsigned char *)dens, in_len_big, out, mode); - ptcache_compress_write(pf, (unsigned char *)densold, in_len_big, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)dens, in_len_big, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)densold, in_len_big, out, mode); MEM_freeN(out); out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len), "pointcache_lzo_buffer"); - ptcache_compress_write(pf, (unsigned char *)tcu, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)tcv, in_len, out, mode); - ptcache_compress_write(pf, (unsigned char *)tcw, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)tcu, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)tcv, in_len, out, mode); + ptcache_file_compressed_write(pf, (unsigned char *)tcw, in_len, out, mode); MEM_freeN(out); ret = 1; @@ -642,9 +552,6 @@ static int ptcache_smoke_write(PTCacheFile *pf, void *smoke_v) return ret; } - - - static void ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) { SmokeModifierData *smd= (SmokeModifierData *)smoke_v; @@ -658,18 +565,18 @@ static void ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles); - ptcache_compress_read(pf, (unsigned char *)sds->shadow, out_len); - ptcache_compress_read(pf, (unsigned char*)dens, out_len); - ptcache_compress_read(pf, (unsigned char*)densold, out_len); - ptcache_compress_read(pf, (unsigned char*)heat, out_len); - ptcache_compress_read(pf, (unsigned char*)heatold, out_len); - ptcache_compress_read(pf, (unsigned char*)vx, out_len); - ptcache_compress_read(pf, (unsigned char*)vy, out_len); - ptcache_compress_read(pf, (unsigned char*)vz, out_len); - ptcache_compress_read(pf, (unsigned char*)vxold, out_len); - ptcache_compress_read(pf, (unsigned char*)vyold, out_len); - ptcache_compress_read(pf, (unsigned char*)vzold, out_len); - ptcache_compress_read(pf, (unsigned char*)obstacles, (unsigned int)res); + ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)densold, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)heat, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)heatold, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)vx, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)vy, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)vz, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)vxold, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)vyold, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)vzold, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)obstacles, (unsigned int)res); ptcache_file_read(pf, &dt, 1, sizeof(float)); ptcache_file_read(pf, &dx, 1, sizeof(float)); @@ -686,12 +593,12 @@ static void ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw); - ptcache_compress_read(pf, (unsigned char*)dens, out_len_big); - ptcache_compress_read(pf, (unsigned char*)densold, out_len_big); + ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len_big); + ptcache_file_compressed_read(pf, (unsigned char*)densold, out_len_big); - ptcache_compress_read(pf, (unsigned char*)tcu, out_len); - ptcache_compress_read(pf, (unsigned char*)tcv, out_len); - ptcache_compress_read(pf, (unsigned char*)tcw, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)tcu, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)tcv, out_len); + ptcache_file_compressed_read(pf, (unsigned char*)tcw, out_len); } } } @@ -709,21 +616,25 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb) pid->ptcaches= &sb->ptcaches; pid->totpoint= pid->totwrite= ptcache_softbody_totpoint; - pid->write_elem= ptcache_softbody_write; - pid->write_stream = NULL; - pid->read_stream = NULL; - pid->read_elem= ptcache_softbody_read; - pid->interpolate_elem= ptcache_softbody_interpolate; + pid->write_point = ptcache_softbody_write; + pid->read_point = ptcache_softbody_read; + pid->interpolate_point = ptcache_softbody_interpolate; + + pid->write_stream = NULL; + pid->read_stream = NULL; - pid->write_header= ptcache_basic_header_write; - pid->read_header= ptcache_basic_header_read; + pid->write_extra_data = NULL; + pid->read_extra_data = NULL; + pid->interpolate_extra_data = NULL; + + pid->write_header = ptcache_basic_header_write; + pid->read_header = ptcache_basic_header_read; pid->data_types= (1<info_types= 0; pid->stack_index = pid->cache->index; } - void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys) { memset(pid, 0, sizeof(PTCacheID)); @@ -739,19 +650,24 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p if(psys->part->type != PART_HAIR) pid->flag |= PTCACHE_VEL_PER_SEC; - pid->write_elem= ptcache_particle_write; - pid->write_stream = NULL; - pid->read_stream = NULL; - pid->read_elem= ptcache_particle_read; - pid->interpolate_elem= ptcache_particle_interpolate; + pid->totpoint = ptcache_particle_totpoint; + pid->totwrite = ptcache_particle_totwrite; - pid->totpoint= ptcache_particle_totpoint; - pid->totwrite= ptcache_particle_totwrite; + pid->write_point = ptcache_particle_write; + pid->read_point = ptcache_particle_read; + pid->interpolate_point = ptcache_particle_interpolate; - pid->write_header= ptcache_basic_header_write; - pid->read_header= ptcache_basic_header_read; + pid->write_stream = NULL; + pid->read_stream = NULL; - pid->data_types= (1<write_extra_data = NULL; + pid->read_extra_data = NULL; + pid->interpolate_extra_data = NULL; + + pid->write_header = ptcache_basic_header_write; + pid->read_header = ptcache_basic_header_read; + + pid->data_types = (1<part->phystype == PART_PHYS_BOIDS) pid->data_types|= (1<info_types= (1<ptcaches= &clmd->ptcaches; pid->totpoint= pid->totwrite= ptcache_cloth_totpoint; - pid->write_elem= ptcache_cloth_write; - pid->write_stream = NULL; - pid->read_stream = NULL; - pid->read_elem= ptcache_cloth_read; - pid->interpolate_elem= ptcache_cloth_interpolate; + pid->write_point = ptcache_cloth_write; + pid->read_point = ptcache_cloth_read; + pid->interpolate_point = ptcache_cloth_interpolate; + + pid->write_stream = NULL; + pid->read_stream = NULL; + + pid->write_extra_data = NULL; + pid->read_extra_data = NULL; + pid->interpolate_extra_data = NULL; - pid->write_header= ptcache_basic_header_write; - pid->read_header= ptcache_basic_header_read; + pid->write_header = ptcache_basic_header_write; + pid->read_header = ptcache_basic_header_read; pid->data_types= (1<info_types= 0; } - void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd) { SmokeDomainSettings *sds = smd->domain; @@ -810,16 +729,19 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo pid->totpoint= pid->totwrite= ptcache_smoke_totpoint; - pid->write_elem= NULL; - pid->read_elem= NULL; + pid->write_point = NULL; + pid->read_point = NULL; + pid->interpolate_point = NULL; - pid->read_stream = ptcache_smoke_read; - pid->write_stream = ptcache_smoke_write; - - pid->interpolate_elem= NULL; + pid->read_stream = ptcache_smoke_read; + pid->write_stream = ptcache_smoke_write; + + pid->write_extra_data = NULL; + pid->read_extra_data = NULL; + pid->interpolate_extra_data = NULL; - pid->write_header= ptcache_basic_header_write; - pid->read_header= ptcache_basic_header_read; + pid->write_header = ptcache_basic_header_write; + pid->read_header = ptcache_basic_header_read; pid->data_types= 0; pid->info_types= 0; @@ -829,7 +751,6 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo if(sds->wt) pid->data_types |= (1<fp= fp; pf->old_format = 0; + pf->frame = cfra; return pf; } - static void ptcache_file_close(PTCacheFile *pf) { fclose(pf->fp); MEM_freeN(pf); } -static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, int size) +static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, size_t len) +{ + int r = 0; + unsigned char compressed = 0; + size_t in_len; +#ifdef WITH_LZO + size_t out_len = len; + size_t sizeOfIt = 5; +#endif + unsigned char *in; + unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); + + ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char)); + if(compressed) { + uint32_t size; + ptcache_file_read(pf, &size, 1, sizeof(uint32_t)); + in_len = (size_t)size; + if(in_len==0) { + /* do nothing */ + } + else { + in = (unsigned char *)MEM_callocN(sizeof(unsigned char)*in_len, "pointcache_compressed_buffer"); + ptcache_file_read(pf, in, in_len, sizeof(unsigned char)); +#ifdef WITH_LZO + if(compressed == 1) + r = lzo1x_decompress_safe(in, (lzo_uint)in_len, result, (lzo_uint *)&out_len, NULL); +#endif +#ifdef WITH_LZMA + if(compressed == 2) + { + size_t leni = in_len, leno = out_len; + ptcache_file_read(pf, &size, 1, sizeof(unsigned int)); + sizeOfIt = (size_t)size; + ptcache_file_read(pf, props, sizeOfIt, sizeof(unsigned char)); + r = LzmaUncompress(result, &leno, in, &leni, props, sizeOfIt); + } +#endif + MEM_freeN(in); + } + } + else { + ptcache_file_read(pf, result, len, sizeof(unsigned char)); + } + + MEM_freeN(props); + + return r; +} +static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, size_t in_len, unsigned char *out, int mode) +{ + int r = 0; + unsigned char compressed = 0; + size_t out_len= 0; + unsigned char *props = MEM_callocN(16*sizeof(char), "tmp"); + size_t sizeOfIt = 5; + + (void)mode; /* unused when building w/o compression */ + +#ifdef WITH_LZO + out_len= LZO_OUT_LEN(in_len); + if(mode == 1) { + LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS); + + r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem); + if (!(r == LZO_E_OK) || (out_len >= in_len)) + compressed = 0; + else + compressed = 1; + } +#endif +#ifdef WITH_LZMA + if(mode == 2) { + + r = LzmaCompress(out, (size_t *)&out_len, in, in_len,//assume sizeof(char)==1.... + props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2); + + if(!(r == SZ_OK) || (out_len >= in_len)) + compressed = 0; + else + compressed = 2; + } +#endif + + ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char)); + if(compressed) { + uint32_t size = (uint32_t) out_len; + ptcache_file_write(pf, &size, 1, sizeof(uint32_t)); + ptcache_file_write(pf, out, out_len, sizeof(unsigned char)); + } + else + ptcache_file_write(pf, in, in_len, sizeof(unsigned char)); + + if(compressed == 2) + { + uint32_t size = (uint32_t) sizeOfIt; + ptcache_file_write(pf, &sizeOfIt, 1, sizeof(uint32_t)); + ptcache_file_write(pf, props, sizeOfIt, sizeof(unsigned char)); + } + + MEM_freeN(props); + + return r; +} +static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, size_t size) { return (fread(f, size, tot, pf->fp) == tot); } -static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, int size) +static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, size_t size) { return (fwrite(f, size, tot, pf->fp) == tot); } @@ -1077,6 +1100,7 @@ static int ptcache_file_data_write(PTCacheFile *pf) } static int ptcache_file_header_begin_read(PTCacheFile *pf) { + uint32_t typeflag=0; int error=0; char bphysics[8]; @@ -1088,8 +1112,11 @@ static int ptcache_file_header_begin_read(PTCacheFile *pf) if(!error && strncmp(bphysics, "BPHYSICS", 8)) error = 1; - if(!error && !fread(&pf->type, sizeof(int), 1, pf->fp)) + if(!error && !fread(&typeflag, sizeof(uint32_t), 1, pf->fp)) error = 1; + + pf->type = (typeflag & PTCACHE_TYPEFLAG_TYPEMASK); + pf->flag = (typeflag & PTCACHE_TYPEFLAG_FLAGMASK); /* if there was an error set file as it was */ if(error) @@ -1097,22 +1124,20 @@ static int ptcache_file_header_begin_read(PTCacheFile *pf) return !error; } - - static int ptcache_file_header_begin_write(PTCacheFile *pf) { const char *bphysics = "BPHYSICS"; + uint32_t typeflag = pf->type + pf->flag; if(fwrite(bphysics, sizeof(char), 8, pf->fp) != 8) return 0; - if(!fwrite(&pf->type, sizeof(int), 1, pf->fp)) + if(!fwrite(&typeflag, sizeof(uint32_t), 1, pf->fp)) return 0; return 1; } - /* Data pointer handling */ int BKE_ptcache_data_size(int data_type) { @@ -1239,8 +1264,15 @@ static void ptcache_data_copy(void *from[], void *to[]) } } +static void ptcache_extra_free(PTCacheMem *pm) +{ + PTCacheExtra *extra = pm->extradata.first; - + for(; extra; extra=extra->next) { + if(extra->data) + MEM_freeN(extra->data); + } +} static int ptcache_old_elemsize(PTCacheID *pid) { if(pid->type==PTCACHE_TYPE_SOFTBODY) @@ -1253,78 +1285,248 @@ static int ptcache_old_elemsize(PTCacheID *pid) return 0; } -static void *ptcache_find_frame(PTCacheID *pid, int frame) +static void ptcache_find_frames_around(PTCacheID *pid, int frame, int *fra1, int *fra2) { if(pid->cache->flag & PTCACHE_DISK_CACHE) { - PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, frame); - if(pf) - pf->frame = frame; - return pf; + int cfra1=frame-1, cfra2=frame+1; + + while(cfra1 >= pid->cache->startframe && !BKE_ptcache_id_exist(pid, cfra1)) + cfra1--; + + if(cfra1 < pid->cache->startframe) + cfra1 = 0; + + while(cfra2 <= pid->cache->endframe && !BKE_ptcache_id_exist(pid, cfra2)) + cfra2++; + + if(cfra2 > pid->cache->endframe) + cfra2 = 0; + + if(cfra1 && !cfra2) { + *fra1 = 0; + *fra2 = cfra1; + } + else { + *fra1 = cfra1; + *fra2 = cfra2; + } } - else { + else if(pid->cache->mem_cache.first) { PTCacheMem *pm = pid->cache->mem_cache.first; - for(; pm; pm=pm->next) { - if(pm->frame == frame) - break; + PTCacheMem *pm2 = pid->cache->mem_cache.last; + + while(pm->next && pm->next->frame < frame) + pm= pm->next; + + if(pm2 && pm2->frame < frame) + pm2 = NULL; + else { + while(pm2->prev && pm2->prev->frame > frame) + pm2= pm2->prev; + } + + if(pm && !pm2) { + *fra1 = 0; + *fra2 = pm->frame; + } + else { + *fra1 = pm->frame; + *fra2 = pm2->frame; } - return (void*)pm; } } +static void ptcache_make_index_array(PTCacheMem *pm, int totpoint) +{ + int i, *index; + + if(pm->index_array) { + MEM_freeN(pm->index_array); + pm->index_array = NULL; + } + + if(!pm->data[BPHYS_DATA_INDEX]) + return; + + pm->index_array = MEM_callocN(totpoint * sizeof(int), "PTCacheMem index_array"); + index = pm->data[BPHYS_DATA_INDEX]; + + for(i=0; itotpoint; i++, index++) + pm->index_array[*index] = i + 1; +} -static void ptcache_find_frames_around(PTCacheID *pid, int frame, void **cache1, void **cache2) +static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) { - int cfra1=frame, cfra2=frame; + PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); + PTCacheMem *pm = NULL; + int i, error = 1; - if(pid->cache->flag & PTCACHE_DISK_CACHE) { - PTCacheFile *pf=NULL; - PTCacheFile *pf2=NULL; + if(pf == NULL) + goto cleanup; - while(cfra1 >= pid->cache->startframe && pf==NULL) { - cfra1--; - pf= ptcache_file_open(pid, PTCACHE_FILE_READ, cfra1); + if(!ptcache_file_header_begin_read(pf)) + goto cleanup; + + if(pf->type != pid->type || !pid->read_header(pf)) + goto cleanup; + + pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); + + pm->totpoint = pf->totpoint; + pm->data_types = pf->data_types; + pm->frame = pf->frame; + + ptcache_data_alloc(pm); + + if(pf->flag & PTCACHE_TYPEFLAG_COMPRESS) { + for(i=0; itotpoint*ptcache_data_size[i]; + if(pf->data_types & (1<data[i]), out_len); + } + } + else { + BKE_ptcache_mem_pointers_init(pm); + ptcache_file_pointers_init(pf); + + for(i=0; itotpoint; i++) { + if(!ptcache_file_data_read(pf)) { + printf("Error reading from disk cache\n"); + goto cleanup; + } + ptcache_data_copy(pf->cur, pm->cur); + BKE_ptcache_mem_pointers_incr(pm); } + } - if(pf) - pf->frame = cfra1; + if(pf->flag & PTCACHE_TYPEFLAG_EXTRADATA) { + uint32_t extratype = 0; + uint32_t value; - while(cfra2 < pid->cache->endframe && !pf2) { - cfra2++; - pf2= ptcache_file_open(pid, PTCACHE_FILE_READ, cfra2); + while(ptcache_file_read(pf, &extratype, 1, sizeof(uint32_t))) { + PTCacheExtra *extra = MEM_callocN(sizeof(PTCacheExtra), "Pointcache extradata"); + + extra->type = extratype; + + ptcache_file_read(pf, &value, 1, sizeof(uint32_t)); + extra->flag = value; + ptcache_file_read(pf, &value, 1, sizeof(uint32_t)); + extra->totdata = value; + ptcache_file_read(pf, &value, 1, sizeof(uint32_t)); + extra->datasize = value; + + extra->data = MEM_callocN(extra->totdata * extra->datasize, "Pointcache extradata->data"); + + if(pf->flag & PTCACHE_TYPEFLAG_COMPRESS) + ptcache_file_compressed_read(pf, (unsigned char*)(extra->data), extra->totdata*extra->datasize); + else + ptcache_file_read(pf, extra->data, extra->totdata, extra->datasize); + + BLI_addtail(&pm->extradata, extra); } + } + + ptcache_make_index_array(pm, pid->totpoint(pid->calldata, pm->frame)); + + error = 0; + +cleanup: + if(error && pm) { + ptcache_data_free(pm); + ptcache_extra_free(pm); + MEM_freeN(pm); + pm = NULL; + } - if(pf2) - pf2->frame = cfra2; + if(pf) + ptcache_file_close(pf); + + return pm; +} +static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) +{ + PTCacheFile *pf = NULL; + int i, ret = 0; + + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, pm->frame); + + pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame); + + if(pf==NULL) + goto cleanup; + + pf->data_types = pm->data_types; + pf->totpoint = pm->totpoint; + pf->type = pid->type; + pf->flag = 0; + + if(pm->extradata.first) + pf->flag |= PTCACHE_TYPEFLAG_EXTRADATA; + + if(pid->cache->compression) + pf->flag |= PTCACHE_TYPEFLAG_COMPRESS; + + if(!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)) + goto cleanup; + + if(pid->cache->compression) { + for(i=0; idata[i]) { + unsigned int in_len = pm->totpoint*ptcache_data_size[i]; + unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer"); + ptcache_file_compressed_write(pf, (unsigned char*)(pm->data[i]), in_len, out, pid->cache->compression); + MEM_freeN(out); + } + } + } + else { + BKE_ptcache_mem_pointers_init(pm); + ptcache_file_pointers_init(pf); - if(pf && !pf2) { - pf2 = pf; - pf = NULL; + for(i=0; itotpoint; i++) { + ptcache_data_copy(pm->cur, pf->cur); + if(!ptcache_file_data_write(pf)) + goto cleanup; + BKE_ptcache_mem_pointers_incr(pm); } - - *cache1 = (void*)pf; - *cache2 = (void*)pf2; } - else if(pid->cache->mem_cache.first){ - PTCacheMem *pm = pid->cache->mem_cache.first; - PTCacheMem *pm2 = pid->cache->mem_cache.last; - while(pm->next && pm->next->frame < frame) - pm= pm->next; + if(pm->extradata.first) { + PTCacheExtra *extra = pm->extradata.first; + uint32_t value; - if(pm2 && pm2->frame < frame) - pm2 = NULL; - else { - while(pm2->prev && pm2->prev->frame > frame) - pm2= pm2->prev; - } + for(; extra; extra=extra->next) { + if(extra->data == NULL || extra->totdata == 0) + continue; - if(pm && !pm2) { - pm2 = pm; - pm = NULL; + value = extra->type; + ptcache_file_write(pf, &value, 1, sizeof(uint32_t)); + value = extra->flag; + ptcache_file_write(pf, &value, 1, sizeof(uint32_t)); + value = extra->totdata; + ptcache_file_write(pf, &value, 1, sizeof(uint32_t)); + value = extra->datasize; + ptcache_file_write(pf, &value, 1, sizeof(uint32_t)); + + if(pid->cache->compression) { + unsigned int in_len = extra->totdata * extra->datasize; + unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer"); + ptcache_file_compressed_write(pf, (unsigned char*)(extra->data), in_len, out, pid->cache->compression); + MEM_freeN(out); + } + else { + ptcache_file_write(pf, extra->data, extra->totdata, extra->datasize); + } } - - *cache1 = (void*)pm; - *cache2 = (void*)pm2; } + + ret = 1; +cleanup: + ptcache_file_close(pf); + + if (ret == 0 && G.f & G_DEBUG) + printf("Error writing to disk cache\n"); + + return ret; } static int ptcache_read_init(PTCacheID *pid, void **cache, int *totpoint) { @@ -1361,92 +1563,126 @@ static int ptcache_read_init(PTCacheID *pid, void **cache, int *totpoint) return pm->frame; } } -static int ptcache_read(PTCacheID *pid, void *cache, int totpoint, float frs_sec) +static int ptcache_read_stream(PTCacheID *pid, int cfra) +{ + PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); + int error = 1; + + if(pf == NULL || pid->read_stream == NULL) + goto cleanup; + + if(!ptcache_file_header_begin_read(pf)) + goto cleanup; + + if(pf->type != pid->type || !pid->read_header(pf)) + goto cleanup; + + if(pf->totpoint != pid->totpoint(pid->calldata, cfra)) + goto cleanup; + + ptcache_file_pointers_init(pf); + + // we have stream reading here + pid->read_stream(pf, pid->calldata); + + error = 0; + +cleanup: + if(pf) + ptcache_file_close(pf); + + return !error; +} +static int ptcache_read(PTCacheID *pid, int cfra) { + PTCacheMem *pm = NULL; int i; int *index = &i; + /* get a memory cache to read from */ if(pid->cache->flag & PTCACHE_DISK_CACHE) { - PTCacheFile *pf = (PTCacheFile *)cache; - if(pf->old_format) { - int old_elemsize = ptcache_old_elemsize(pid); - float old_data[14]; - - for(i=0; iread_elem(i, pid->calldata, NULL, frs_sec, (float)pf->frame, old_data); - else - return 0; - } - } - else { - if(pf->data_types & (1<data.index; - - for(i=0; iread_elem(*index, pid->calldata, pf->cur, frs_sec, (float)pf->frame, NULL); - else - return 0; - } - } + pm = ptcache_disk_frame_to_mem(pid, cfra); } else { - PTCacheMem *pm = (PTCacheMem *)cache; + pm = pid->cache->mem_cache.first; + + while(pm && pm->frame != cfra) + pm = pm->next; + } + + /* read the cache */ + if(pm) { + int totpoint = pm->totpoint; + + if((pid->data_types & (1<totpoint(pid->calldata, cfra)); + + BKE_ptcache_mem_pointers_init(pm); for(i=0; idata_types & (1<cur[BPHYS_DATA_INDEX]; - pid->read_elem(*index, pid->calldata, pm->cur, frs_sec, (float)pm->frame, NULL); + pid->read_point(*index, pid->calldata, pm->cur, (float)pm->frame, NULL); BKE_ptcache_mem_pointers_incr(pm); } + + if(pid->read_extra_data && pm->extradata.first) + pid->read_extra_data(pid->calldata, pm, (float)pm->frame); + + /* clean up temporary memory cache */ + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + ptcache_data_free(pm); + ptcache_extra_free(pm); + MEM_freeN(pm); + } } return 1; } -static int ptcache_interpolate(PTCacheID *pid, void *cache1, void *cache2, int totpoint, float cfra, float frs_sec) +static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2) { + PTCacheMem *pm = NULL; int i; int *index = &i; + /* get a memory cache to read from */ if(pid->cache->flag & PTCACHE_DISK_CACHE) { - PTCacheFile *pf1 = (PTCacheFile *)cache1; - PTCacheFile *pf2 = (PTCacheFile *)cache2; - if(pf2->old_format) { - int old_elemsize = ptcache_old_elemsize(pid); - float old_data[14]; - - for(i=0; iinterpolate_elem(i, pid->calldata, NULL, frs_sec, cfra, (float)pf1->frame, (float)pf2->frame, old_data); - else - return 0; - } - } - else { - if(pf2->data_types & (1<data.index; - - for(i=0; iinterpolate_elem(*index, pid->calldata, pf2->cur, frs_sec, cfra, (float)pf1->frame, (float)pf2->frame, NULL); - else - return 0; - } - } + pm = ptcache_disk_frame_to_mem(pid, cfra2); } else { - PTCacheMem *pm1 = (PTCacheMem *)cache1; - PTCacheMem *pm2 = (PTCacheMem *)cache2; + pm = pid->cache->mem_cache.first; + + while(pm && pm->frame != cfra2) + pm = pm->next; + } + + /* read the cache */ + if(pm) { + int totpoint = pm->totpoint; + + if((pid->data_types & (1<totpoint(pid->calldata, (int)cfra)); + + BKE_ptcache_mem_pointers_init(pm); for(i=0; idata_types & (1<cur[BPHYS_DATA_INDEX]; + if(pm->data_types & (1<cur[BPHYS_DATA_INDEX]; + + pid->interpolate_point(*index, pid->calldata, pm->cur, cfra, (float)cfra1, (float)cfra2, NULL); + BKE_ptcache_mem_pointers_incr(pm); + } - pid->interpolate_elem(*index, pid->calldata, pm2->cur, frs_sec, cfra, (float)pm1->frame, (float)pm2->frame, NULL); - BKE_ptcache_mem_pointers_incr(pm2); + if(pid->interpolate_extra_data && pm->extradata.first) + pid->interpolate_extra_data(pid->calldata, pm, cfra, (float)cfra1, (float)cfra2); + + /* clean up temporary memory cache */ + if(pid->cache->flag & PTCACHE_DISK_CACHE) { + ptcache_data_free(pm); + ptcache_extra_free(pm); + MEM_freeN(pm); } } @@ -1454,11 +1690,9 @@ static int ptcache_interpolate(PTCacheID *pid, void *cache1, void *cache2, int t } /* reads cache from disk or memory */ /* possible to get old or interpolated result */ -int BKE_ptcache_read(PTCacheID *pid, float cfra, float frs_sec) +int BKE_ptcache_read(PTCacheID *pid, float cfra) { - void *cache1=NULL, *cache2=NULL; int cfrai = (int)cfra, cfra1=0, cfra2=0; - int totpoint = 0, totpoint2 = 0; int ret = 0; /* nothing to read to */ @@ -1467,88 +1701,49 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra, float frs_sec) if(pid->cache->flag & PTCACHE_READ_INFO) { pid->cache->flag &= ~PTCACHE_READ_INFO; - BKE_ptcache_read(pid, 0, frs_sec); + ptcache_read(pid, 0); } /* first check if we have the actual frame cached */ - if(cfra == (float)cfrai) - cache1 = ptcache_find_frame(pid, cfrai); + if(cfra == (float)cfrai && BKE_ptcache_id_exist(pid, cfrai)) + cfra1 = cfrai; /* no exact cache frame found so try to find cached frames around cfra */ - if(cache1==NULL) - ptcache_find_frames_around(pid, cfrai, &cache1, &cache2); + if(cfra1 == 0) + ptcache_find_frames_around(pid, cfrai, &cfra1, &cfra2); - if(cache1==NULL && cache2==NULL) + if(cfra1 == 0 && cfra2 == 0) return 0; - cfra1 = ptcache_read_init(pid, &cache1, &totpoint); - cfra2 = ptcache_read_init(pid, &cache2, &totpoint2); - /* don't read old cache if already simulated past cached frame */ - if(!cache1 && cfra2 && cfra2 <= pid->cache->simframe) - goto cleanup; - if(cfra1 && cfra1==cfra2) - goto cleanup; - - if(cache1) { - if(pid->read_stream) { - if(totpoint != pid->totpoint(pid->calldata, (int) cfra)) - goto cleanup; - else - { - // we have stream reading here - pid->read_stream((PTCacheFile *)cache1, pid->calldata); - } - } - else if(pid->read_elem) { - if((pid->data_types & (1<totpoint(pid->calldata, (int) cfra)); + if(cfra1 == 0 && cfra2 && cfra2 <= pid->cache->simframe) + return 0; + if(cfra1 && cfra1 == cfra2) + return 0; - if(ptcache_read(pid, cache1, totpoint, frs_sec)==0) - goto cleanup; - } + if(cfra1) { + if(pid->read_stream) + ptcache_read_stream(pid, cfra1); + else if(pid->read_point) + ptcache_read(pid, cfra1); } - if(cache2) { - if(pid->read_stream) { - if(totpoint2 != pid->totpoint(pid->calldata, (int) cfra)) - goto cleanup; + if(cfra2) { + if(pid->read_stream) + ptcache_read_stream(pid, cfra2); + else if(pid->read_point) { + if(cfra1 && cfra2 && pid->interpolate_point) + ptcache_interpolate(pid, cfra, cfra1, cfra2); else - { - // we have stream reading here - pid->read_stream((PTCacheFile *)cache2, pid->calldata); - } - } - else if(pid->read_elem) { - if((pid->data_types & (1<totpoint(pid->calldata, (int) cfra)); - - if(cache1 && cache2 && pid->interpolate_elem) { - if(ptcache_interpolate(pid, cache1, cache2, totpoint2, cfra, frs_sec)==0) - goto cleanup; - } - else { - if(ptcache_read(pid, cache2, totpoint2, frs_sec)==0) - goto cleanup; - } + ptcache_read(pid, cfra2); } } - if(cache1) - ret = (cache2 ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT); - else if(cache2) { + if(cfra1) + ret = (cfra2 ? PTCACHE_READ_INTERPOLATED : PTCACHE_READ_EXACT); + else if(cfra2) { ret = PTCACHE_READ_OLD; - pid->cache->simframe = ((pid->cache->flag & PTCACHE_DISK_CACHE) ? - ((PTCacheFile*)cache2)->frame : ((PTCacheMem*)cache2)->frame); - } - -cleanup: - - if(pid->cache->flag & PTCACHE_DISK_CACHE) { - if(cache1) - ptcache_file_close((PTCacheFile*)cache1); - if(cache2) - ptcache_file_close((PTCacheFile*)cache2); + pid->cache->simframe = cfra2; } if((pid->cache->flag & PTCACHE_QUICK_CACHE)==0) { @@ -1561,31 +1756,114 @@ cleanup: if(cfra <= pid->cache->last_exact) pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED; - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai,pid->cache->last_exact)); + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai, pid->cache->last_exact)); } } return ret; } -static void ptcache_make_index_array(PTCacheMem *pm, int totpoint) +static int ptcache_write_stream(PTCacheID *pid, int cfra, int totpoint) { - int i, *index; + PTCacheFile *pf = NULL; + int ret = 0; + + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, cfra); - if(pm->index_array) { - MEM_freeN(pm->index_array); - pm->index_array = NULL; - } + pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra); - if(!pm->data[BPHYS_DATA_INDEX]) - return; + if(pf==NULL) + goto cleanup; - pm->index_array = MEM_callocN(totpoint * sizeof(int), "PTCacheMem index_array"); - index = pm->data[BPHYS_DATA_INDEX]; + pf->data_types = pid->data_types; + pf->totpoint = totpoint; + pf->type = pid->type; + pf->flag = 0; - for(i=0; itotpoint; i++, index++) - pm->index_array[*index] = i + 1; + if(!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)) + goto cleanup; + + if(pid->write_stream) + pid->write_stream(pf, pid->calldata); + + ret = 1; +cleanup: + ptcache_file_close(pf); + + if (ret == 0 && G.f & G_DEBUG) + printf("Error writing to disk cache\n"); + + return ret; } +static int ptcache_write(PTCacheID *pid, int cfra, int overwrite) +{ + PointCache *cache = pid->cache; + PTCacheMem *pm=NULL, *pm2=NULL; + int totpoint = pid->totpoint(pid->calldata, cfra); + int i, error = 0; + + pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); + + pm->totpoint = pid->totwrite(pid->calldata, cfra); + pm->data_types = cfra ? pid->data_types : pid->info_types; + + ptcache_data_alloc(pm); + BKE_ptcache_mem_pointers_init(pm); + + if(overwrite) { + if(cache->flag & PTCACHE_DISK_CACHE) { + PTCacheFile *pf = NULL; + int fra = cfra-1; + + while(fra >= cache->startframe && !BKE_ptcache_id_exist(pid, fra)) + fra--; + + pm2 = ptcache_disk_frame_to_mem(pid, fra); + } + else + pm2 = cache->mem_cache.last; + } + + if(pid->write_point) { + for(i=0; iwrite_point(i, pid->calldata, pm->cur, cfra); + if(write) { + BKE_ptcache_mem_pointers_incr(pm); + + /* newly born particles have to be copied to previous cached frame */ + if(overwrite && write == 2 && pm2 && BKE_ptcache_mem_pointers_seek(i, pm2)) + pid->write_point(i, pid->calldata, pm2->cur, cfra); + } + } + } + + if(pid->write_extra_data) + pid->write_extra_data(pid->calldata, pm, cfra); + + pm->frame = cfra; + + if(cache->flag & PTCACHE_DISK_CACHE) { + error += !ptcache_mem_frame_to_disk(pid, pm); + + if(pm) { + ptcache_data_free(pm); + ptcache_extra_free(pm); + MEM_freeN(pm); + } + if(pm2) { + error += !ptcache_mem_frame_to_disk(pid, pm2); + ptcache_data_free(pm2); + ptcache_extra_free(pm2); + MEM_freeN(pm2); + } + } + else { + ptcache_make_index_array(pm, pid->totpoint(pid->calldata, cfra)); + BLI_addtail(&cache->mem_cache, pm); + } + + return error; +} static int ptcache_write_needed(PTCacheID *pid, int cfra, int *overwrite) { PointCache *cache = pid->cache; @@ -1639,10 +1917,8 @@ static int ptcache_write_needed(PTCacheID *pid, int cfra, int *overwrite) int BKE_ptcache_write(PTCacheID *pid, int cfra) { PointCache *cache = pid->cache; - PTCacheFile *pf= NULL, *pf2= NULL; - int i, ret = 0; int totpoint = pid->totpoint(pid->calldata, cfra); - int overwrite = 0; + int overwrite = 0, error = 0; if(totpoint == 0 || (cfra ? pid->data_types == 0 : pid->info_types == 0)) return 0; @@ -1650,109 +1926,29 @@ int BKE_ptcache_write(PTCacheID *pid, int cfra) if(ptcache_write_needed(pid, cfra, &overwrite)==0) return 0; - if(cache->flag & PTCACHE_DISK_CACHE) { - pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra); - if(!pf) - goto cleanup; - - pf->type = pid->type; - pf->totpoint = cfra ? pid->totwrite(pid->calldata, cfra) : totpoint; - pf->data_types = cfra ? pid->data_types : pid->info_types; - - if(!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)) - goto cleanup; - - ptcache_file_pointers_init(pf); - - if(pid->write_stream) { - // we have stream writing here - pid->write_stream(pf, pid->calldata); - } - else if(pid->write_elem){ - for(i=0; iwrite_elem(i, pid->calldata, pf->cur, cfra); - if(write) { - if(!ptcache_file_data_write(pf)) - goto cleanup; - - /* newly born particles have to be copied to previous cached frame */ - if(overwrite && write == 2) { - if(!pf2) { - /* find and initialize previous frame */ - int ofra = cfra-1; - while(ofra > cache->startframe && !BKE_ptcache_id_exist(pid, ofra)) - ofra--; - - pf2 = ptcache_file_open(pid, PTCACHE_FILE_UPDATE, ofra); - if(!pf2) - goto cleanup; - - pf2->type = pid->type; - pf2->totpoint = totpoint; - pf2->data_types = pid->data_types; - } - ptcache_file_pointers_seek(i, pf2); - pid->write_elem(i, pid->calldata, pf2->cur, cfra); - if(!ptcache_file_data_write(pf2)) - goto cleanup; - } - } - } - } + if(pid->write_stream) { + ptcache_write_stream(pid, cfra, totpoint); } - else { - PTCacheMem *pm; - PTCacheMem *pm2; - - pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); - - pm->totpoint = pid->totwrite(pid->calldata, cfra); - pm->data_types = cfra ? pid->data_types : pid->info_types; - - ptcache_data_alloc(pm); - BKE_ptcache_mem_pointers_init(pm); - - if(pid->write_elem) { - for(i=0; iwrite_elem(i, pid->calldata, pm->cur, cfra); - if(write) { - BKE_ptcache_mem_pointers_incr(pm); - - /* newly born particles have to be copied to previous cached frame */ - if(overwrite && write == 2) { - pm2 = cache->mem_cache.last; - if(BKE_ptcache_mem_pointers_seek(i, pm2)) - pid->write_elem(i, pid->calldata, pm2->cur, cfra); - } - } - } - } - ptcache_make_index_array(pm, pid->totpoint(pid->calldata, cfra)); - - pm->frame = cfra; - BLI_addtail(&cache->mem_cache, pm); + else if(pid->write_point) { + error += ptcache_write(pid, cfra, overwrite); } + /* Mark frames skipped if more than 1 frame forwards since last non-skipped frame. */ if(cfra - cache->last_exact == 1 || cfra == cache->startframe) { cache->last_exact = cfra; cache->flag &= ~PTCACHE_FRAMES_SKIPPED; } - else + /* Don't mark skipped when writing info file (frame 0) */ + else if(cfra) cache->flag |= PTCACHE_FRAMES_SKIPPED; + /* Update timeline cache display */ if(cache->cached_frames) cache->cached_frames[cfra-cache->startframe] = 1; - ret = 1; - -cleanup: - if(pf) ptcache_file_close(pf); - - if(pf2) ptcache_file_close(pf2); - BKE_ptcache_update_info(pid); - return ret; + return !error; } /* youll need to close yourself after! * mode - PTCACHE_CLEAR_ALL, @@ -1845,8 +2041,10 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) if(mode == PTCACHE_CLEAR_ALL) { /*we want startframe if the cache starts before zero*/ pid->cache->last_exact = MIN2(pid->cache->startframe, 0); - for(; pm; pm=pm->next) + for(; pm; pm=pm->next) { ptcache_data_free(pm); + ptcache_extra_free(pm); + } BLI_freelistN(&pid->cache->mem_cache); if(pid->cache->cached_frames) for(i=0; icache->cached_frames && pm->frame >=sta && pm->frame <= end) pid->cache->cached_frames[pm->frame-sta] = 0; ptcache_data_free(pm); + ptcache_extra_free(pm); pm = pm->next; BLI_freelinkN(&pid->cache->mem_cache, link); } @@ -1882,6 +2081,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) for(; pm; pm=pm->next) { if(pm->frame == cfra) { ptcache_data_free(pm); + ptcache_extra_free(pm); BLI_freelinkN(&pid->cache->mem_cache, pm); break; } @@ -1894,7 +2094,6 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) BKE_ptcache_update_info(pid); } - int BKE_ptcache_id_exist(PTCacheID *pid, int cfra) { if(!pid->cache) @@ -1923,7 +2122,6 @@ int BKE_ptcache_id_exist(PTCacheID *pid, int cfra) return 0; } } - void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startframe, int *endframe, float *timescale) { Object *ob; @@ -2030,7 +2228,6 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra } } } - int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) { PointCache *cache; @@ -2093,7 +2290,6 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) return (reset || clear || after); } - int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) { PTCacheID pid; @@ -2235,8 +2431,10 @@ void BKE_ptcache_free_mem(ListBase *mem_cache) PTCacheMem *pm = mem_cache->first; if(pm) { - for(; pm; pm=pm->next) + for(; pm; pm=pm->next) { ptcache_data_free(pm); + ptcache_extra_free(pm); + } BLI_freelistN(mem_cache); } @@ -2549,120 +2747,51 @@ void BKE_ptcache_bake(PTCacheBaker* baker) void BKE_ptcache_disk_to_mem(PTCacheID *pid) { PointCache *cache = pid->cache; - PTCacheFile *pf; - PTCacheMem *pm; - + PTCacheMem *pm = NULL; + int baked = cache->flag & PTCACHE_BAKED; int cfra, sfra = cache->startframe, efra = cache->endframe; - int i; - - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); - - for(cfra=sfra; cfra <= efra; cfra++) { - pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); - if(pf) { - if(!ptcache_file_header_begin_read(pf)) { - printf("Can't yet convert old cache format\n"); - cache->flag |= PTCACHE_DISK_CACHE; - ptcache_file_close(pf); - return; - } + /* Remove possible bake flag to allow clear */ + cache->flag &= ~PTCACHE_BAKED; - if(pf->type != pid->type || !pid->read_header(pf)) { - cache->flag |= PTCACHE_DISK_CACHE; - ptcache_file_close(pf); - return; - } - - pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); - - pm->totpoint = pf->totpoint; - pm->data_types = pf->data_types; - pm->frame = cfra; - - ptcache_data_alloc(pm); - BKE_ptcache_mem_pointers_init(pm); - ptcache_file_pointers_init(pf); - - for(i=0; itotpoint; i++) { - if(!ptcache_file_data_read(pf)) { - printf("Error reading from disk cache\n"); - - cache->flag |= PTCACHE_DISK_CACHE; - - ptcache_data_free(pm); - MEM_freeN(pm); - ptcache_file_close(pf); + /* PTCACHE_DISK_CACHE flag was cleared already */ + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); - return; - } - ptcache_data_copy(pf->cur, pm->cur); - BKE_ptcache_mem_pointers_incr(pm); - } + /* restore possible bake flag */ + cache->flag |= baked; - ptcache_make_index_array(pm, pid->totpoint(pid->calldata, cfra)); + for(cfra=sfra; cfra <= efra; cfra++) { + pm = ptcache_disk_frame_to_mem(pid, cfra); + if(pm) BLI_addtail(&pid->cache->mem_cache, pm); - - ptcache_file_close(pf); - } } - } void BKE_ptcache_mem_to_disk(PTCacheID *pid) { PointCache *cache = pid->cache; - PTCacheFile *pf; - PTCacheMem *pm; - int i; + PTCacheMem *pm = cache->mem_cache.first; + int baked = cache->flag & PTCACHE_BAKED; - pm = cache->mem_cache.first; + /* Remove possible bake flag to allow clear */ + cache->flag &= ~PTCACHE_BAKED; + /* PTCACHE_DISK_CACHE flag was set already */ BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); - for(; pm; pm=pm->next) { - pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame); - - if(pf) { - pf->data_types = pm->data_types; - pf->totpoint = pm->totpoint; - pf->type = pid->type; - - BKE_ptcache_mem_pointers_init(pm); - ptcache_file_pointers_init(pf); - - if(!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)) { - if (G.f & G_DEBUG) - printf("Error writing to disk cache\n"); - cache->flag &= ~PTCACHE_DISK_CACHE; - - ptcache_file_close(pf); - return; - } - - for(i=0; itotpoint; i++) { - ptcache_data_copy(pm->cur, pf->cur); - if(!ptcache_file_data_write(pf)) { - if (G.f & G_DEBUG) - printf("Error writing to disk cache\n"); - cache->flag &= ~PTCACHE_DISK_CACHE; - - ptcache_file_close(pf); - return; - } - BKE_ptcache_mem_pointers_incr(pm); - } - - ptcache_file_close(pf); + /* restore possible bake flag */ + cache->flag |= baked; - /* write info file */ - if(cache->flag & PTCACHE_BAKED) - BKE_ptcache_write(pid, 0); + for(; pm; pm=pm->next) { + if(ptcache_mem_frame_to_disk(pid, pm)==0) { + cache->flag &= ~PTCACHE_DISK_CACHE; + break; } - else - if (G.f & G_DEBUG) - printf("Error creating disk cache file\n"); } + + /* write info file */ + if(cache->flag & PTCACHE_BAKED) + BKE_ptcache_write(pid, 0); } void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) { @@ -2854,6 +2983,7 @@ void BKE_ptcache_load_external(PTCacheID *pid) void BKE_ptcache_update_info(PTCacheID *pid) { PointCache *cache = pid->cache; + PTCacheExtra *extra = NULL; int totframes = 0; char mem_info[64]; @@ -2903,7 +3033,16 @@ void BKE_ptcache_update_info(PTCacheID *pid) for(; pm; pm=pm->next) { for(i=0; idata[i] ? MEM_allocN_len(pm->data[i]) : 0.0f; + bytes += MEM_allocN_len(pm->data[i]); + + for(extra=pm->extradata.first; extra; extra=extra->next) { + bytes += MEM_allocN_len(extra->data); + bytes += sizeof(PTCacheExtra); + } + + bytes += MEM_allocN_len(pm->index_array); + bytes += sizeof(PTCacheMem); + totframes++; } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index babe4209a31..9a0f278bcd0 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1376,7 +1376,7 @@ void smokeModifier_do(SmokeModifierData *smd, Scene *scene, Object *ob, DerivedM } /* try to read from cache */ - if(BKE_ptcache_read(&pid, (float)framenr, scene->r.frs_sec) == PTCACHE_READ_EXACT) { + if(BKE_ptcache_read(&pid, (float)framenr) == PTCACHE_READ_EXACT) { BKE_ptcache_validate(cache, framenr); smd->time = framenr; return; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 4653562e5f4..eb56331acfb 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -4134,7 +4134,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i } /* try to read from cache */ - cache_result = BKE_ptcache_read(&pid, framenr, scene->r.frs_sec); + cache_result = BKE_ptcache_read(&pid, framenr); if(cache_result == PTCACHE_READ_EXACT || cache_result == PTCACHE_READ_INTERPOLATED) { softbody_to_object(ob, vertexCos, numVerts, sb->local); -- cgit v1.2.3 From 8c86d2da3ab732a3ec0915c6e0328c09f99e15f1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 2 Jan 2011 10:13:17 +0000 Subject: Quiet warnings from last commit. Janne: could you check if ptcache_file_pointers_seek() & ptcache_read_init() can be removed? --- source/blender/blenkernel/intern/anim_sys.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index b81d611065d..1ddf6a73abd 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -886,7 +886,7 @@ KS_Path *BKE_keyingset_add_path (KeyingSet *ks, ID *id, const char group_name[], /* just store absolute info */ ksp->id= id; if (group_name) - BLI_snprintf(ksp->group, 64, group_name); + BLI_strncpy(ksp->group, group_name, sizeof(ksp->group)); else ksp->group[0]= '\0'; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 6b08f17713d..24edead4751 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1059,7 +1059,6 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, siz if(compressed == 2) { - uint32_t size = (uint32_t) sizeOfIt; ptcache_file_write(pf, &sizeOfIt, 1, sizeof(uint32_t)); ptcache_file_write(pf, props, sizeOfIt, sizeof(unsigned char)); } @@ -1158,6 +1157,7 @@ static void ptcache_file_pointers_init(PTCacheFile *pf) pf->cur[BPHYS_DATA_BOIDS] = (data_types & (1<data.boids : NULL; } +#if 0 // UNUSED static void ptcache_file_pointers_seek(int index, PTCacheFile *pf) { int i, size=0; @@ -1190,6 +1190,8 @@ static void ptcache_file_pointers_seek(int index, PTCacheFile *pf) ptcache_file_pointers_init(pf); } +#endif + void BKE_ptcache_mem_pointers_init(PTCacheMem *pm) { int data_types = pm->data_types; @@ -1528,6 +1530,8 @@ cleanup: return ret; } + +#if 0 // UNUSED static int ptcache_read_init(PTCacheID *pid, void **cache, int *totpoint) { if(*cache==NULL) @@ -1563,6 +1567,8 @@ static int ptcache_read_init(PTCacheID *pid, void **cache, int *totpoint) return pm->frame; } } +#endif + static int ptcache_read_stream(PTCacheID *pid, int cfra) { PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); @@ -1811,7 +1817,6 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite) if(overwrite) { if(cache->flag & PTCACHE_DISK_CACHE) { - PTCacheFile *pf = NULL; int fra = cfra-1; while(fra >= cache->startframe && !BKE_ptcache_id_exist(pid, fra)) -- cgit v1.2.3 From a7ceeafd71534b21163b189a42af07358672d1c7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 2 Jan 2011 11:06:50 +0000 Subject: - correct typos in comments. - move boxpack struct out of the public header. --- source/blender/blenkernel/intern/mball.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 03cbd9e41fd..8658d7e482f 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -737,7 +737,7 @@ void accum_mballfaces(int i1, int i2, int i3, int i4) void *new_pgn_element(int size) { /* during polygonize 1000s of elements are allocated - * and never freed inbetween. Freeing only done at the end. + * and never freed in between. Freeing only done at the end. */ int blocksize= 16384; static int offs= 0; /* the current free address */ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 94350ac30fa..f0af7e8684b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -350,7 +350,7 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys) pa->num_dmcache= GET_INT_FROM_POINTER(nodearray[pa->num]->link); } else { /* FROM_FACE/FROM_VOLUME */ - /* Note that somtimes the pa->num is over the nodearray size, this is bad, maybe there is a better place to fix this, + /* Note that sometimes the pa->num is over the nodearray size, this is bad, maybe there is a better place to fix this, * but for now passing NULL is OK. every face will be searched for the particle so its slower - Campbell */ pa->num_dmcache= psys_particle_dm_face_lookup(ob, dm, pa->num, pa->fuv, pa->num < totelem ? nodearray[pa->num] : NULL); } -- cgit v1.2.3 From 7b865b5ce8053bd10a864aa7287cf8885be31d4c Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 2 Jan 2011 13:57:06 +0000 Subject: Crash fix for pointcache... bad goto's here. --- source/blender/blenkernel/intern/pointcache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 24edead4751..2285d79c165 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1793,7 +1793,8 @@ static int ptcache_write_stream(PTCacheID *pid, int cfra, int totpoint) ret = 1; cleanup: - ptcache_file_close(pf); + if(pf) + ptcache_file_close(pf); if (ret == 0 && G.f & G_DEBUG) printf("Error writing to disk cache\n"); -- cgit v1.2.3 From 76f0569a862aa56c99cd25977fa2c2061de2a117 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 2 Jan 2011 16:43:28 +0000 Subject: Multires math function used for layer interpolation moved from customdata.c to multires.c No functional changes --- source/blender/blenkernel/intern/customdata.c | 253 +------------------------- source/blender/blenkernel/intern/multires.c | 209 ++++++++++++++++++++- 2 files changed, 209 insertions(+), 253 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 03d31549214..ee3477585f8 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -396,52 +396,6 @@ static void layerDefault_origspace_face(void *data, int count) osf[i] = default_osf; } -/* Adapted from sculptmode.c */ -static void mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, float v) -{ - int x, y, x2, y2; - const int st_max = st - 1; - float urat, vrat, uopp; - float d[4][3], d2[2][3]; - - if(u < 0) - u = 0; - else if(u >= st) - u = st_max; - if(v < 0) - v = 0; - else if(v >= st) - v = st_max; - - x = floor(u); - y = floor(v); - x2 = x + 1; - y2 = y + 1; - - if(x2 >= st) x2 = st_max; - if(y2 >= st) y2 = st_max; - - urat = u - x; - vrat = v - y; - uopp = 1 - urat; - - copy_v3_v3(d[0], disps[y * st + x]); - copy_v3_v3(d[1], disps[y * st + x2]); - copy_v3_v3(d[2], disps[y2 * st + x]); - copy_v3_v3(d[3], disps[y2 * st + x2]); - mul_v3_fl(d[0], uopp); - mul_v3_fl(d[1], urat); - mul_v3_fl(d[2], uopp); - mul_v3_fl(d[3], urat); - - add_v3_v3v3(d2[0], d[0], d[1]); - add_v3_v3v3(d2[1], d[2], d[3]); - mul_v3_fl(d2[0], 1 - vrat); - mul_v3_fl(d2[1], vrat); - - add_v3_v3v3(out, d2[0], d2[1]); -} - static void layerSwap_mdisps(void *data, const int *ci) { MDisps *s = data; @@ -473,211 +427,6 @@ static void layerSwap_mdisps(void *data, const int *ci) } } -static void mdisp_get_crn_rect(int face_side, float crn[3][4][2]) -{ - float offset = face_side*0.5f - 0.5f; - float mid[2]; - - mid[0] = offset * 4 / 3; - mid[1] = offset * 2 / 3; - - crn[0][0][0] = mid[0]; crn[0][0][1] = mid[1]; - crn[0][1][0] = offset; crn[0][1][1] = 0; - crn[0][2][0] = 0; crn[0][2][1] = 0; - crn[0][3][0] = offset; crn[0][3][1] = offset; - - crn[1][0][0] = mid[0]; crn[1][0][1] = mid[1]; - crn[1][1][0] = offset * 2; crn[1][1][1] = offset; - crn[1][2][0] = offset * 2; crn[1][2][1] = 0; - crn[1][3][0] = offset; crn[1][3][1] = 0; - - crn[2][0][0] = mid[0]; crn[2][0][1] = mid[1]; - crn[2][1][0] = offset; crn[2][1][1] = offset; - crn[2][2][0] = offset * 2; crn[2][2][1] = offset * 2; - crn[2][3][0] = offset * 2; crn[2][3][1] = offset; -} - -static void mdisp_rot_crn_to_face(int S, int corners, int face_side, float x, float y, float *u, float *v) -{ - float offset = face_side*0.5f - 0.5f; - - if(corners == 4) { - if(S == 1) { *u= offset + x; *v = offset - y; } - if(S == 2) { *u= offset + y; *v = offset + x; } - if(S == 3) { *u= offset - x; *v = offset + y; } - if(S == 0) { *u= offset - y; *v = offset - x; } - } else { - float crn[3][4][2], vec[4][2]; - float p[2]; - - mdisp_get_crn_rect(face_side, crn); - - interp_v2_v2v2(vec[0], crn[S][0], crn[S][1], x / offset); - interp_v2_v2v2(vec[1], crn[S][3], crn[S][2], x / offset); - interp_v2_v2v2(vec[2], crn[S][0], crn[S][3], y / offset); - interp_v2_v2v2(vec[3], crn[S][1], crn[S][2], y / offset); - - isect_seg_seg_v2_point(vec[0], vec[1], vec[2], vec[3], p); - - (*u) = p[0]; - (*v) = p[1]; - } -} - -static int mdisp_pt_in_crn(float p[2], float crn[4][2]) -{ - float v[2][2]; - float a[2][2]; - - sub_v2_v2v2(v[0], crn[1], crn[0]); - sub_v2_v2v2(v[1], crn[3], crn[0]); - - sub_v2_v2v2(a[0], p, crn[0]); - sub_v2_v2v2(a[1], crn[2], crn[0]); - - if(cross_v2v2(a[0], v[0]) * cross_v2v2(a[1], v[0]) < 0) - return 0; - - if(cross_v2v2(a[0], v[1]) * cross_v2v2(a[1], v[1]) < 0) - return 0; - - return 1; -} - -static void face_to_crn_interp(float u, float v, float v1[2], float v2[2], float v3[2], float v4[2], float *x) -{ - float a = (v4[1]-v3[1])*v2[0]+(-v4[1]+v3[1])*v1[0]+(-v2[1]+v1[1])*v4[0]+(v2[1]-v1[1])*v3[0]; - float b = (v3[1]-v)*v2[0]+(v4[1]-2*v3[1]+v)*v1[0]+(-v4[1]+v3[1]+v2[1]-v1[1])*u+(v4[0]-v3[0])*v-v1[1]*v4[0]+(-v2[1]+2*v1[1])*v3[0]; - float c = (v3[1]-v)*v1[0]+(-v3[1]+v1[1])*u+v3[0]*v-v1[1]*v3[0]; - float d = b * b - 4 * a * c; - float x1, x2; - - if(a == 0) { - *x = -c / b; - return; - } - - x1 = (-b - sqrtf(d)) / (2 * a); - x2 = (-b + sqrtf(d)) / (2 * a); - - *x = maxf(x1, x2); -} - -static int mdisp_rot_face_to_crn(int corners, int face_side, float u, float v, float *x, float *y) -{ - float offset = face_side*0.5f - 0.5f; - int S; - - if (corners == 4) { - if(u <= offset && v <= offset) S = 0; - else if(u > offset && v <= offset) S = 1; - else if(u > offset && v > offset) S = 2; - else if(u <= offset && v >= offset) S = 3; - - if(S == 0) { - *y = offset - u; - *x = offset - v; - } else if(S == 1) { - *x = u - offset; - *y = offset - v; - } else if(S == 2) { - *y = u - offset; - *x = v - offset; - } else if(S == 3) { - *x= offset - u; - *y = v - offset; - } - } else { - float crn[3][4][2]; - float p[2] = {u, v}; - - mdisp_get_crn_rect(face_side, crn); - - for (S = 0; S < 3; ++S) { - if (mdisp_pt_in_crn(p, crn[S])) - break; - } - - face_to_crn_interp(u, v, crn[S][0], crn[S][1], crn[S][3], crn[S][2], &p[0]); - face_to_crn_interp(u, v, crn[S][0], crn[S][3], crn[S][1], crn[S][2], &p[1]); - - *x = p[0] * offset; - *y = p[1] * offset; - } - - return S; -} - -static void mdisp_apply_weight(int S, int corners, int x, int y, int face_side, - float crn_weight[4][2], float *u_r, float *v_r) -{ - float u = 0.f, v = 0.f, xl, yl; - float mid1[2], mid2[2], mid3[2]; - - mdisp_rot_crn_to_face(S, corners, face_side, x, y, &u, &v); - - if(corners == 4) { - xl = u / (face_side - 1); - yl = v / (face_side - 1); - - mid1[0] = crn_weight[0][0] * (1 - xl) + crn_weight[1][0] * xl; - mid1[1] = crn_weight[0][1] * (1 - xl) + crn_weight[1][1] * xl; - mid2[0] = crn_weight[3][0] * (1 - xl) + crn_weight[2][0] * xl; - mid2[1] = crn_weight[3][1] * (1 - xl) + crn_weight[2][1] * xl; - mid3[0] = mid1[0] * (1 - yl) + mid2[0] * yl; - mid3[1] = mid1[1] * (1 - yl) + mid2[1] * yl; - } else { - yl = v / (face_side - 1); - - if(v == face_side - 1) xl = 1; - else xl = 1 - (face_side - 1 - u) / (face_side - 1 - v); - - mid1[0] = crn_weight[0][0] * (1 - xl) + crn_weight[1][0] * xl; - mid1[1] = crn_weight[0][1] * (1 - xl) + crn_weight[1][1] * xl; - mid3[0] = mid1[0] * (1 - yl) + crn_weight[2][0] * yl; - mid3[1] = mid1[1] * (1 - yl) + crn_weight[2][1] * yl; - } - - *u_r = mid3[0]; - *v_r = mid3[1]; -} - -static void mdisp_flip_disp(int S, int corners, float axis_x[2], float axis_y[2], float disp[3]) -{ - float crn_x[2], crn_y[2]; - float vx[2], vy[2], coord[2]; - - if (corners == 4) { - float x[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; - float y[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}}; - - copy_v2_v2(crn_x, x[S]); - copy_v2_v2(crn_y, y[S]); - - mul_v2_v2fl(vx, crn_x, disp[0]); - mul_v2_v2fl(vy, crn_y, disp[1]); - add_v2_v2v2(coord, vx, vy); - - project_v2_v2v2(vx, coord, axis_x); - project_v2_v2v2(vy, coord, axis_y); - - disp[0] = len_v2(vx); - disp[1] = len_v2(vy); - - if(dot_v2v2(vx, axis_x) < 0) - disp[0] = -disp[0]; - - if(dot_v2v2(vy, axis_y) < 0) - disp[1] = -disp[1]; - } else { - /* XXX: it was very overhead code to support displacement flipping - for case of tris without visible profit. - Maybe its not really big limitation? for now? (nazgul) */ - disp[0] = 0; - disp[1] = 0; - } -} - static void layerInterp_mdisps(void **sources, float *UNUSED(weights), float *sub_weights, int count, void *dest) { @@ -739,7 +488,7 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights), mdisp_apply_weight(S, dst_corners, x, y, st, crn_weight, &face_u, &face_v); crn = mdisp_rot_face_to_crn(src_corners, st, face_u, face_v, &crn_u, &crn_v); - mdisps_bilinear((*out), &s->disps[crn*side*side], side, crn_u, crn_v); + old_mdisps_bilinear((*out), &s->disps[crn*side*side], side, crn_u, crn_v); mdisp_flip_disp(crn, dst_corners, axis_x, axis_y, *out); } } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 2224b3d8d49..68ee0d0d0cd 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -837,7 +837,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca ***************************/ /* Adapted from sculptmode.c */ -static void old_mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, float v) +void old_mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, float v) { int x, y, x2, y2; const int st_max = st - 1; @@ -1774,3 +1774,210 @@ void multires_mdisp_smooth_bounds(MDisps *disps) } } } + +/***************** Multires interpolation stuff *****************/ + +static void mdisp_get_crn_rect(int face_side, float crn[3][4][2]) +{ + float offset = face_side*0.5f - 0.5f; + float mid[2]; + + mid[0] = offset * 4 / 3; + mid[1] = offset * 2 / 3; + + crn[0][0][0] = mid[0]; crn[0][0][1] = mid[1]; + crn[0][1][0] = offset; crn[0][1][1] = 0; + crn[0][2][0] = 0; crn[0][2][1] = 0; + crn[0][3][0] = offset; crn[0][3][1] = offset; + + crn[1][0][0] = mid[0]; crn[1][0][1] = mid[1]; + crn[1][1][0] = offset * 2; crn[1][1][1] = offset; + crn[1][2][0] = offset * 2; crn[1][2][1] = 0; + crn[1][3][0] = offset; crn[1][3][1] = 0; + + crn[2][0][0] = mid[0]; crn[2][0][1] = mid[1]; + crn[2][1][0] = offset; crn[2][1][1] = offset; + crn[2][2][0] = offset * 2; crn[2][2][1] = offset * 2; + crn[2][3][0] = offset * 2; crn[2][3][1] = offset; +} + +static int mdisp_pt_in_crn(float p[2], float crn[4][2]) +{ + float v[2][2]; + float a[2][2]; + + sub_v2_v2v2(v[0], crn[1], crn[0]); + sub_v2_v2v2(v[1], crn[3], crn[0]); + + sub_v2_v2v2(a[0], p, crn[0]); + sub_v2_v2v2(a[1], crn[2], crn[0]); + + if(cross_v2v2(a[0], v[0]) * cross_v2v2(a[1], v[0]) < 0) + return 0; + + if(cross_v2v2(a[0], v[1]) * cross_v2v2(a[1], v[1]) < 0) + return 0; + + return 1; +} + +static void face_to_crn_interp(float u, float v, float v1[2], float v2[2], float v3[2], float v4[2], float *x) +{ + float a = (v4[1]-v3[1])*v2[0]+(-v4[1]+v3[1])*v1[0]+(-v2[1]+v1[1])*v4[0]+(v2[1]-v1[1])*v3[0]; + float b = (v3[1]-v)*v2[0]+(v4[1]-2*v3[1]+v)*v1[0]+(-v4[1]+v3[1]+v2[1]-v1[1])*u+(v4[0]-v3[0])*v-v1[1]*v4[0]+(-v2[1]+2*v1[1])*v3[0]; + float c = (v3[1]-v)*v1[0]+(-v3[1]+v1[1])*u+v3[0]*v-v1[1]*v3[0]; + float d = b * b - 4 * a * c; + float x1, x2; + + if(a == 0) { + *x = -c / b; + return; + } + + x1 = (-b - sqrtf(d)) / (2 * a); + x2 = (-b + sqrtf(d)) / (2 * a); + + *x = maxf(x1, x2); +} + +void mdisp_rot_crn_to_face(int S, int corners, int face_side, float x, float y, float *u, float *v) +{ + float offset = face_side*0.5f - 0.5f; + + if(corners == 4) { + if(S == 1) { *u= offset + x; *v = offset - y; } + if(S == 2) { *u= offset + y; *v = offset + x; } + if(S == 3) { *u= offset - x; *v = offset + y; } + if(S == 0) { *u= offset - y; *v = offset - x; } + } else { + float crn[3][4][2], vec[4][2]; + float p[2]; + + mdisp_get_crn_rect(face_side, crn); + + interp_v2_v2v2(vec[0], crn[S][0], crn[S][1], x / offset); + interp_v2_v2v2(vec[1], crn[S][3], crn[S][2], x / offset); + interp_v2_v2v2(vec[2], crn[S][0], crn[S][3], y / offset); + interp_v2_v2v2(vec[3], crn[S][1], crn[S][2], y / offset); + + isect_seg_seg_v2_point(vec[0], vec[1], vec[2], vec[3], p); + + (*u) = p[0]; + (*v) = p[1]; + } +} + +int mdisp_rot_face_to_crn(int corners, int face_side, float u, float v, float *x, float *y) +{ + float offset = face_side*0.5f - 0.5f; + int S; + + if (corners == 4) { + if(u <= offset && v <= offset) S = 0; + else if(u > offset && v <= offset) S = 1; + else if(u > offset && v > offset) S = 2; + else if(u <= offset && v >= offset) S = 3; + + if(S == 0) { + *y = offset - u; + *x = offset - v; + } else if(S == 1) { + *x = u - offset; + *y = offset - v; + } else if(S == 2) { + *y = u - offset; + *x = v - offset; + } else if(S == 3) { + *x= offset - u; + *y = v - offset; + } + } else { + float crn[3][4][2]; + float p[2] = {u, v}; + + mdisp_get_crn_rect(face_side, crn); + + for (S = 0; S < 3; ++S) { + if (mdisp_pt_in_crn(p, crn[S])) + break; + } + + face_to_crn_interp(u, v, crn[S][0], crn[S][1], crn[S][3], crn[S][2], &p[0]); + face_to_crn_interp(u, v, crn[S][0], crn[S][3], crn[S][1], crn[S][2], &p[1]); + + *x = p[0] * offset; + *y = p[1] * offset; + } + + return S; +} + +void mdisp_apply_weight(int S, int corners, int x, int y, int face_side, + float crn_weight[4][2], float *u_r, float *v_r) +{ + float u, v, xl, yl; + float mid1[2], mid2[2], mid3[2]; + + mdisp_rot_crn_to_face(S, corners, face_side, x, y, &u, &v); + + if(corners == 4) { + xl = u / (face_side - 1); + yl = v / (face_side - 1); + + mid1[0] = crn_weight[0][0] * (1 - xl) + crn_weight[1][0] * xl; + mid1[1] = crn_weight[0][1] * (1 - xl) + crn_weight[1][1] * xl; + mid2[0] = crn_weight[3][0] * (1 - xl) + crn_weight[2][0] * xl; + mid2[1] = crn_weight[3][1] * (1 - xl) + crn_weight[2][1] * xl; + mid3[0] = mid1[0] * (1 - yl) + mid2[0] * yl; + mid3[1] = mid1[1] * (1 - yl) + mid2[1] * yl; + } else { + yl = v / (face_side - 1); + + if(v == face_side - 1) xl = 1; + else xl = 1 - (face_side - 1 - u) / (face_side - 1 - v); + + mid1[0] = crn_weight[0][0] * (1 - xl) + crn_weight[1][0] * xl; + mid1[1] = crn_weight[0][1] * (1 - xl) + crn_weight[1][1] * xl; + mid3[0] = mid1[0] * (1 - yl) + crn_weight[2][0] * yl; + mid3[1] = mid1[1] * (1 - yl) + crn_weight[2][1] * yl; + } + + *u_r = mid3[0]; + *v_r = mid3[1]; +} + +void mdisp_flip_disp(int S, int corners, float axis_x[2], float axis_y[2], float disp[3]) +{ + float crn_x[2], crn_y[2]; + float vx[2], vy[2], coord[2]; + + if (corners == 4) { + float x[4][2] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; + float y[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}}; + + copy_v2_v2(crn_x, x[S]); + copy_v2_v2(crn_y, y[S]); + + mul_v2_v2fl(vx, crn_x, disp[0]); + mul_v2_v2fl(vy, crn_y, disp[1]); + add_v2_v2v2(coord, vx, vy); + + project_v2_v2v2(vx, coord, axis_x); + project_v2_v2v2(vy, coord, axis_y); + + disp[0] = len_v2(vx); + disp[1] = len_v2(vy); + + if(dot_v2v2(vx, axis_x) < 0) + disp[0] = -disp[0]; + + if(dot_v2v2(vy, axis_y) < 0) + disp[1] = -disp[1]; + } else { + /* XXX: it was very overhead code to support displacement flipping + for case of tris without visible profit. + Maybe its not really big limitation? for now? (nazgul) */ + disp[0] = 0; + disp[1] = 0; + } +} -- cgit v1.2.3 From 24e80665d8272198783cd6a634cb47a7d289fb1c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 2 Jan 2011 17:08:25 +0000 Subject: New customdata layer callback: validate Used to validate displacement allocation size after face copying to match face vertex and displacement corners count. --- source/blender/blenkernel/intern/customdata.c | 34 ++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index ee3477585f8..2d4e65f8f94 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -104,6 +104,11 @@ typedef struct LayerTypeInfo { /* a function to determine file size */ size_t (*filesize)(CDataFile *cdf, void *data, int count); + + /* a function to validate layer contents depending on + * sub-elements count + */ + void (*validate)(void *source, int sub_elements); } LayerTypeInfo; static void layerCopy_mdeformvert(const void *source, void *dest, @@ -517,6 +522,20 @@ static void layerCopy_mdisps(const void *source, void *dest, int count) } } +static void layerValidate_mdisps(void *data, int sub_elements) +{ + MDisps *disps = data; + if(disps->disps) { + int corners = multires_mdisp_corners(disps); + + if(corners != sub_elements) { + MEM_freeN(disps->disps); + disps->totdisp = disps->totdisp / corners * sub_elements; + disps->disps = MEM_callocN(3*disps->totdisp*sizeof(float), "layerValidate_mdisps"); + } + } +} + static void layerFree_mdisps(void *data, int count, int UNUSED(size)) { int i; @@ -768,7 +787,8 @@ const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL, layerDefault_mloopcol}, {sizeof(float)*3*4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, {sizeof(MDisps), "MDisps", 1, NULL, layerCopy_mdisps, - layerFree_mdisps, layerInterp_mdisps, layerSwap_mdisps, NULL, layerRead_mdisps, layerWrite_mdisps, layerFilesize_mdisps}, + layerFree_mdisps, layerInterp_mdisps, layerSwap_mdisps, NULL, layerRead_mdisps, layerWrite_mdisps, + layerFilesize_mdisps, layerValidate_mdisps}, {sizeof(MCol)*4, "MCol", 4, "WeightCol", NULL, NULL, layerInterp_mcol, layerSwap_mcol, layerDefault_mcol}, {sizeof(MCol)*4, "MCol", 4, "IDCol", NULL, NULL, layerInterp_mcol, @@ -1691,6 +1711,18 @@ void CustomData_em_copy_data(const CustomData *source, CustomData *dest, } } +void CustomData_em_validate_data(CustomData *data, void *block, int sub_elements) +{ + int i; + for(i = 0; i < data->totlayer; i++) { + const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[i].type); + char *leayer_data = (char*)block + data->layers[i].offset; + + if(typeInfo->validate) + typeInfo->validate(leayer_data, sub_elements); + } +} + void *CustomData_em_get(const CustomData *data, void *block, int type) { int layer_index; -- cgit v1.2.3 From 78162fa7936761ef0aafbc641f1a1b0d9a3fb1ec Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 2 Jan 2011 17:38:22 +0000 Subject: Splitting quad into triangles and merging triangles into quad should work correct with sculpting data now. Joining two triangles could give incorrect sculpting result for special topologies, but it's that case that can't be nicely handled with our layers architecture. --- source/blender/blenkernel/intern/customdata.c | 47 ++++++++++++++++++++++++--- source/blender/blenkernel/intern/multires.c | 44 +++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 2d4e65f8f94..f7606a344c9 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -441,16 +441,55 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights), int i, x, y; int side, S, dst_corners, src_corners; float crn_weight[4][2]; - float (*sw)[4] = NULL; + float (*sw)[4] = (void*)sub_weights; float (*disps)[3], (*out)[3]; s = sources[0]; dst_corners = multires_mdisp_corners(d); src_corners = multires_mdisp_corners(s); - /* XXX: For now, some restrictions on the input - should be implemented to allow quad<->tris face conversion */ - if(count != 1 || !sub_weights || dst_corners != src_corners) { + if(sub_weights && count == 2 && src_corners == 3) { + src_corners = multires_mdisp_corners(sources[1]); + + /* special case -- converting two triangles to quad */ + if(src_corners == 3 && dst_corners == 4) { + MDisps tris[2]; + int vindex[4] = {0}; + + S = 0; + for(i = 0; i < 2; i++) + for(y = 0; y < 4; y++) + for(x = 0; x < 4; x++) + if(sw[x+i*4][y]) + vindex[x] = y; + + for(i = 0; i < 2; i++) { + float sw[4][4] = {{0}}; + int a = 7 & ~(1 << vindex[i*2] | 1 << vindex[i*2+1]); + + sw[0][vindex[i*2+1]] = 1; + sw[1][vindex[i*2]] = 1; + + for(x = 0; x < 3; x++) + if(a & (1 << x)) + sw[2][x] = 1; + + tris[i] = *((MDisps*)sources[i]); + tris[i].disps = MEM_dupallocN(tris[i].disps); + layerInterp_mdisps(&sources[i], NULL, (float*)sw, 1, &tris[i]); + } + + mdisp_join_tris(d, &tris[0], &tris[1]); + + for(i = 0; i < 2; i++) + MEM_freeN(tris[i].disps); + + return; + } + } + + /* For now, some restrictions on the input */ + if(count != 1 || !sub_weights) { for(i = 0; i < d->totdisp; ++i) zero_v3(d->disps[i]); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 68ee0d0d0cd..84350127968 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1981,3 +1981,47 @@ void mdisp_flip_disp(int S, int corners, float axis_x[2], float axis_y[2], float disp[1] = 0; } } + +/* Join two triangular displacements into one quad + Corners mapping: + 2 -------- 3 + | \ tri2 | + | \ | + | tri1 \ | + 0 -------- 1 */ +void mdisp_join_tris(MDisps *dst, MDisps *tri1, MDisps *tri2) +{ + int side, st; + int S, x, y, crn; + float face_u, face_v, crn_u, crn_v; + float (*out)[3]; + MDisps *src; + + if(dst->disps) + MEM_freeN(dst->disps); + + side = sqrt(tri1->totdisp / 3); + st = (side<<1)-1; + + dst->totdisp = 4 * side * side; + out = dst->disps = MEM_callocN(3*dst->totdisp*sizeof(float), "join disps"); + + for(S = 0; S < 4; S++) + for(y = 0; y < side; ++y) + for(x = 0; x < side; ++x, ++out) { + mdisp_rot_crn_to_face(S, 4, st, x, y, &face_u, &face_v); + face_u = st - 1 - face_u; + + if(face_v > face_u) { + src = tri2; + face_u = st - 1 - face_u; + face_v = st - 1 - face_v; + } else src = tri1; + + crn = mdisp_rot_face_to_crn(3, st, face_u, face_v, &crn_u, &crn_v); + + old_mdisps_bilinear((*out), &src->disps[crn*side*side], side, crn_u, crn_v); + (*out)[0] = 0; + (*out)[1] = 0; + } +} -- cgit v1.2.3 From fe44c6596d6de906f1534f139b980e6d0a205bac Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 2 Jan 2011 18:10:33 +0000 Subject: Small changes to new pointcache code: * Removed the unused fuctions spotted by Campbel. * Removed the gotos to make Ton happy. * Added better debug prints to disk cache operations. * Fixed a memory unmap error that seemed to happen on a test file. --- source/blender/blenkernel/intern/pointcache.c | 286 ++++++++++---------------- 1 file changed, 113 insertions(+), 173 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 2285d79c165..b8e8508da26 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -961,8 +961,10 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) } static void ptcache_file_close(PTCacheFile *pf) { - fclose(pf->fp); - MEM_freeN(pf); + if(pf) { + fclose(pf->fp); + MEM_freeN(pf); + } } static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, size_t len) @@ -1157,41 +1159,6 @@ static void ptcache_file_pointers_init(PTCacheFile *pf) pf->cur[BPHYS_DATA_BOIDS] = (data_types & (1<data.boids : NULL; } -#if 0 // UNUSED -static void ptcache_file_pointers_seek(int index, PTCacheFile *pf) -{ - int i, size=0; - int data_types = pf->data_types; - - if(data_types & (1<fp, 8 + sizeof(int), SEEK_SET); - fread(&totpoint, sizeof(int), 1, pf->fp); - - totpoint++; - - fseek(pf->fp, 8 + sizeof(int), SEEK_SET); - fwrite(&totpoint, sizeof(int), 1, pf->fp); - - fseek(pf->fp, 0, SEEK_END); - } - else { - for(i=0; idata_types & (1<fp, 8 + 3*sizeof(int) + index * size, SEEK_SET); - } - - ptcache_file_pointers_init(pf); -} -#endif - void BKE_ptcache_mem_pointers_init(PTCacheMem *pm) { int data_types = pm->data_types; @@ -1360,47 +1327,49 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) { PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); PTCacheMem *pm = NULL; - int i, error = 1; + int i, error = 0; if(pf == NULL) - goto cleanup; + return 0; if(!ptcache_file_header_begin_read(pf)) - goto cleanup; + error = 1; - if(pf->type != pid->type || !pid->read_header(pf)) - goto cleanup; - - pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); + if(!error && (pf->type != pid->type || !pid->read_header(pf))) + error = 1; - pm->totpoint = pf->totpoint; - pm->data_types = pf->data_types; - pm->frame = pf->frame; + if(!error) { + pm = MEM_callocN(sizeof(PTCacheMem), "Pointcache mem"); - ptcache_data_alloc(pm); + pm->totpoint = pf->totpoint; + pm->data_types = pf->data_types; + pm->frame = pf->frame; - if(pf->flag & PTCACHE_TYPEFLAG_COMPRESS) { - for(i=0; itotpoint*ptcache_data_size[i]; - if(pf->data_types & (1<data[i]), out_len); + ptcache_data_alloc(pm); + + if(pf->flag & PTCACHE_TYPEFLAG_COMPRESS) { + for(i=0; itotpoint*ptcache_data_size[i]; + if(pf->data_types & (1<data[i]), out_len); + } } - } - else { - BKE_ptcache_mem_pointers_init(pm); - ptcache_file_pointers_init(pf); + else { + BKE_ptcache_mem_pointers_init(pm); + ptcache_file_pointers_init(pf); - for(i=0; itotpoint; i++) { - if(!ptcache_file_data_read(pf)) { - printf("Error reading from disk cache\n"); - goto cleanup; + for(i=0; itotpoint; i++) { + if(!ptcache_file_data_read(pf)) { + error = 1; + break; + } + ptcache_data_copy(pf->cur, pm->cur); + BKE_ptcache_mem_pointers_incr(pm); } - ptcache_data_copy(pf->cur, pm->cur); - BKE_ptcache_mem_pointers_incr(pm); } } - if(pf->flag & PTCACHE_TYPEFLAG_EXTRADATA) { + if(!error && pf->flag & PTCACHE_TYPEFLAG_EXTRADATA) { uint32_t extratype = 0; uint32_t value; @@ -1427,11 +1396,9 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) } } - ptcache_make_index_array(pm, pid->totpoint(pid->calldata, pm->frame)); - - error = 0; + if(!error) + ptcache_make_index_array(pm, pid->totpoint(pid->calldata, pm->frame)); -cleanup: if(error && pm) { ptcache_data_free(pm); ptcache_extra_free(pm); @@ -1439,22 +1406,27 @@ cleanup: pm = NULL; } - if(pf) - ptcache_file_close(pf); + ptcache_file_close(pf); + + if (error && G.f & G_DEBUG) + printf("Error reading from disk cache\n"); return pm; } static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) { PTCacheFile *pf = NULL; - int i, ret = 0; + int i, error = 0; BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, pm->frame); pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, pm->frame); - if(pf==NULL) - goto cleanup; + if(pf==NULL) { + if (G.f & G_DEBUG) + printf("Error opening disk cache file for writing\n"); + return 0; + } pf->data_types = pm->data_types; pf->totpoint = pm->totpoint; @@ -1468,31 +1440,35 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) pf->flag |= PTCACHE_TYPEFLAG_COMPRESS; if(!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)) - goto cleanup; + error = 1; - if(pid->cache->compression) { - for(i=0; idata[i]) { - unsigned int in_len = pm->totpoint*ptcache_data_size[i]; - unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer"); - ptcache_file_compressed_write(pf, (unsigned char*)(pm->data[i]), in_len, out, pid->cache->compression); - MEM_freeN(out); + if(!error) { + if(pid->cache->compression) { + for(i=0; idata[i]) { + unsigned int in_len = pm->totpoint*ptcache_data_size[i]; + unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer"); + ptcache_file_compressed_write(pf, (unsigned char*)(pm->data[i]), in_len, out, pid->cache->compression); + MEM_freeN(out); + } } } - } - else { - BKE_ptcache_mem_pointers_init(pm); - ptcache_file_pointers_init(pf); + else { + BKE_ptcache_mem_pointers_init(pm); + ptcache_file_pointers_init(pf); - for(i=0; itotpoint; i++) { - ptcache_data_copy(pm->cur, pf->cur); - if(!ptcache_file_data_write(pf)) - goto cleanup; - BKE_ptcache_mem_pointers_incr(pm); + for(i=0; itotpoint; i++) { + ptcache_data_copy(pm->cur, pf->cur); + if(!ptcache_file_data_write(pf)) { + error = 1; + break; + } + BKE_ptcache_mem_pointers_incr(pm); + } } } - if(pm->extradata.first) { + if(!error && pm->extradata.first) { PTCacheExtra *extra = pm->extradata.first; uint32_t value; @@ -1521,83 +1497,47 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) } } - ret = 1; -cleanup: ptcache_file_close(pf); - if (ret == 0 && G.f & G_DEBUG) + if (error && G.f & G_DEBUG) printf("Error writing to disk cache\n"); - return ret; -} - -#if 0 // UNUSED -static int ptcache_read_init(PTCacheID *pid, void **cache, int *totpoint) -{ - if(*cache==NULL) - return 0; - - if(pid->cache->flag & PTCACHE_DISK_CACHE) { - PTCacheFile *pf = (PTCacheFile *)(*cache); - - if(ptcache_file_header_begin_read(pf)) { - if(pf->type != pid->type) { - /* todo report error */ - ptcache_file_close(pf); - *cache = NULL; - return 0; - } - else if(pid->read_header(pf)) { - ptcache_file_pointers_init(pf); - *totpoint = pf->totpoint; - } - } - else { - /* fall back to old cache file format */ - pf->old_format = 1; - *totpoint = pid->totpoint(pid->calldata, (int) pf->frame); - } - return pf->frame; - } - else { - PTCacheMem *pm = (PTCacheMem *)(*cache); - - BKE_ptcache_mem_pointers_init(pm); - *totpoint = pm->totpoint; - return pm->frame; - } + return error==0; } -#endif static int ptcache_read_stream(PTCacheID *pid, int cfra) { PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); - int error = 1; + int error = 0; + + if(pid->read_stream == NULL) + return 0; - if(pf == NULL || pid->read_stream == NULL) - goto cleanup; + if(pf == NULL) { + if (G.f & G_DEBUG) + printf("Error opening disk cache file for reading\n"); + return 0; + } if(!ptcache_file_header_begin_read(pf)) - goto cleanup; - - if(pf->type != pid->type || !pid->read_header(pf)) - goto cleanup; + error = 1; - if(pf->totpoint != pid->totpoint(pid->calldata, cfra)) - goto cleanup; + if(!error && (pf->type != pid->type || !pid->read_header(pf))) + error = 1; - ptcache_file_pointers_init(pf); + if(!error && pf->totpoint != pid->totpoint(pid->calldata, cfra)) + error = 1; - // we have stream reading here - pid->read_stream(pf, pid->calldata); + if(!error) { + ptcache_file_pointers_init(pf); - error = 0; + // we have stream reading here + pid->read_stream(pf, pid->calldata); + } -cleanup: - if(pf) - ptcache_file_close(pf); + ptcache_file_close(pf); - return !error; + return error == 0; } static int ptcache_read(PTCacheID *pid, int cfra) { @@ -1771,35 +1711,35 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra) static int ptcache_write_stream(PTCacheID *pid, int cfra, int totpoint) { PTCacheFile *pf = NULL; - int ret = 0; + int error = 0; BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, cfra); pf = ptcache_file_open(pid, PTCACHE_FILE_WRITE, cfra); - if(pf==NULL) - goto cleanup; + if(pf==NULL) { + if (G.f & G_DEBUG) + printf("Error opening disk cache file for writing\n"); + return 0; + } pf->data_types = pid->data_types; pf->totpoint = totpoint; pf->type = pid->type; pf->flag = 0; - if(!ptcache_file_header_begin_write(pf) || !pid->write_header(pf)) - goto cleanup; + if(!error && (!ptcache_file_header_begin_write(pf) || !pid->write_header(pf))) + error = 1; - if(pid->write_stream) + if(!error && pid->write_stream) pid->write_stream(pf, pid->calldata); - ret = 1; -cleanup: - if(pf) - ptcache_file_close(pf); - - if (ret == 0 && G.f & G_DEBUG) + ptcache_file_close(pf); + + if (error && G.f & G_DEBUG) printf("Error writing to disk cache\n"); - return ret; + return error == 0; } static int ptcache_write(PTCacheID *pid, int cfra, int overwrite) { @@ -1964,7 +1904,6 @@ int BKE_ptcache_write(PTCacheID *pid, int cfra) void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) { int len; /* store the length of the string */ - int i; int sta, end; /* mode is same as fopen's modes */ @@ -2012,8 +1951,6 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) pid->cache->last_exact = MIN2(pid->cache->startframe, 0); BLI_join_dirfile(path_full, path, de->d_name); BLI_delete(path_full, 0, 0); - if(pid->cache->cached_frames) for(i=0; icache->cached_frames[i] = 0; } else { /* read the number of the file */ int frame, len2 = (int)strlen(de->d_name); @@ -2037,6 +1974,9 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) } } closedir(dir); + + if(mode == PTCACHE_CLEAR_ALL && pid->cache->cached_frames) + memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames)); } else { PTCacheMem *pm= pid->cache->mem_cache.first; @@ -2053,8 +1993,8 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) } BLI_freelistN(&pid->cache->mem_cache); - if(pid->cache->cached_frames) for(i=0; icache->cached_frames[i] = 0; + if(pid->cache->cached_frames) + memset(pid->cache->cached_frames, 0, MEM_allocN_len(pid->cache->cached_frames)); } else { while(pm) { if((mode==PTCACHE_CLEAR_BEFORE && pm->frame < cfra) || @@ -2811,6 +2751,11 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) return; } + if(cache->cached_frames) { + MEM_freeN(cache->cached_frames); + cache->cached_frames=NULL; + } + if(cache->flag & PTCACHE_DISK_CACHE) BKE_ptcache_mem_to_disk(pid); else @@ -2822,11 +2767,6 @@ void BKE_ptcache_toggle_disk_cache(PTCacheID *pid) cache->last_exact = last_exact; - if(cache->cached_frames) { - MEM_freeN(cache->cached_frames); - cache->cached_frames=NULL; - } - BKE_ptcache_id_time(pid, NULL, 0.0f, NULL, NULL, NULL); BKE_ptcache_update_info(pid); -- cgit v1.2.3 From 5d6c76c6a3914ce26d6584b96568e9647aa7d991 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 2 Jan 2011 19:00:32 +0000 Subject: Spelling fix: itterator->iterator --- source/blender/blenkernel/intern/sequencer.c | 2 +- 1 file changed, 1 insertion(+), 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 1b5d1093373..03d4f3da889 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -330,7 +330,7 @@ unsigned int seq_hash_render_data(const SeqRenderData * a) return rval; } -/* ************************* itterator ************************** */ +/* ************************* iterator ************************** */ /* *************** (replaces old WHILE_SEQ) ********************* */ /* **************** use now SEQ_BEGIN() SEQ_END ***************** */ -- cgit v1.2.3 From 05cfe50436a97b45c36e3a044faaf15c266066c0 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 2 Jan 2011 19:46:32 +0000 Subject: Bugfix #25446 (and todo item) The icons for materials were always lagging or not updating at all. I also found it suspicious slow... It appeared that the icons now store a "mip level", where for every change in Materials 2 render jobs for icons were started, one for 32x32 pix, one for 96x96. The latter was cancelling out the first job almost always. Also made preview renders detect size, to set amount of tiles to be rendered. Small icons use 1 part, larger previews 16 now. All in all, behaves much smoother now! But, will also update the thread Jobs manager to allow "delayed jobs" like for icons, these are aggressively put as first in the jobs list. --- source/blender/blenkernel/intern/material.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index cac41e457a6..dae00636370 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -85,7 +85,8 @@ void free_material(Material *ma) BKE_free_animdata((ID *)ma); - BKE_previewimg_free(&ma->preview); + if(ma->preview) + BKE_previewimg_free(&ma->preview); BKE_icon_delete((struct ID*)ma); ma->id.icon_id = 0; @@ -250,7 +251,7 @@ Material *localize_material(Material *ma) if(ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col); if(ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec); - if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview); + man->preview = NULL; if(ma->nodetree) { man->nodetree= ntreeLocalize(ma->nodetree); -- cgit v1.2.3 From 1ba9dde22d07633d41eea6db10320a14422a2448 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 3 Jan 2011 04:59:57 +0000 Subject: - add in asserts for unlikely cases of invalid ID types being assigned to key->from. - mode duplicate pointer/offset code into a static function. --- source/blender/blenkernel/intern/key.c | 222 ++++++++++++++++----------------- 1 file changed, 111 insertions(+), 111 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 8cdfbaf9e2a..5a46d73201f 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -61,9 +61,9 @@ #include "RNA_access.h" - -#define KEY_BPOINT 1 -#define KEY_BEZTRIPLE 2 +#define KEY_MODE_DUMMY 0 /* use where mode isn't checked for */ +#define KEY_MODE_BPOINT 1 +#define KEY_MODE_BEZTRIPLE 2 // old defines from DNA_ipo_types.h for data-type #define IPO_FLOAT 4 @@ -523,36 +523,53 @@ static char *key_block_get_data(Key *key, KeyBlock *actkb, KeyBlock *kb, char ** return kb->data; } -static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *actkb, KeyBlock *kb, float *weights, int mode) + +/* currently only the first value of 'ofs' may be set. */ +static short key_pointer_size(const Key *key, const int mode, int *poinsize, int *ofs) +{ + if(key->from==NULL) { + return FALSE; + } + + switch(GS(key->from->name)) { + case ID_ME: + *ofs= sizeof(float)*3; + *poinsize= *ofs; + break; + case ID_LT: + *ofs= sizeof(float)*3; + *poinsize= *ofs; + break; + case ID_CU: + if(mode == KEY_MODE_BPOINT) { + *ofs= sizeof(float)*4; + *poinsize= *ofs; + } else { + ofs[0]= sizeof(float)*12; + *poinsize= (*ofs) / 3; + } + + break; + default: + BKE_assert(!"invalid 'key->from' ID type"); + return FALSE; + } + + return TRUE; +} + +static void cp_key(const int start, int end, const int tot, char *poin, Key *key, KeyBlock *actkb, KeyBlock *kb, float *weights, const int mode) { float ktot = 0.0, kd = 0.0; int elemsize, poinsize = 0, a, *ofsp, ofs[32], flagflo=0; char *k1, *kref, *freek1, *freekref; char *cp, elemstr[8]; - if(key->from==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; - poinsize= ofs[0]; - }else { - ofs[0]= sizeof(float)*12; - poinsize= ofs[0]/3; - } + /* currently always 0, in future key_pointer_size may assign */ + ofs[1]= 0; - ofs[1]= 0; - } + if(!key_pointer_size(key, mode, &poinsize, &ofs[0])) + return; if(end>tot) end= tot; @@ -584,7 +601,7 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * else k1+= start*key->elemsize; } - if(mode==KEY_BEZTRIPLE) { + if(mode == KEY_MODE_BEZTRIPLE) { elemstr[0]= 1; elemstr[1]= IPO_BEZTRIPLE; elemstr[2]= 0; @@ -592,11 +609,11 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * /* just do it here, not above! */ elemsize= key->elemsize; - if(mode==KEY_BEZTRIPLE) elemsize*= 3; + if(mode == KEY_MODE_BEZTRIPLE) elemsize*= 3; for(a=start; aelemstr; - if(mode==KEY_BEZTRIPLE) cp= elemstr; + if(mode == KEY_MODE_BEZTRIPLE) cp= elemstr; ofsp= ofs; @@ -619,8 +636,14 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * case IPO_BEZTRIPLE: memcpy(poin, k1, sizeof(float)*12); break; + default: + /* should never happen */ + if(freek1) MEM_freeN(freek1); + if(freekref) MEM_freeN(freekref); + BKE_assert(!"invalid 'cp[1]'"); + return; } - + poin+= ofsp[0]; cp+= 2; ofsp++; } @@ -639,14 +662,14 @@ static void cp_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * kref+= elemsize; } - if(mode==KEY_BEZTRIPLE) a+=2; + if(mode == KEY_MODE_BEZTRIPLE) a+=2; } if(freek1) MEM_freeN(freek1); if(freekref) MEM_freeN(freekref); } -static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, int start, int end, char *out, int tot) +static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const int start, int end, char *out, const int tot) { Nurb *nu; int a, step, a1, a2; @@ -658,7 +681,7 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, int st a1= MAX2(a, start); a2= MIN2(a+step, end); - if(a1bezt) { step= 3*nu->pntsu; @@ -667,45 +690,26 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, int st a1= MAX2(a, start); a2= MIN2(a+step, end); - if(a1from==NULL) return; + int poinsize; - 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; - poinsize= ofs[0]; - } else { - ofs[0]= sizeof(float)*12; - poinsize= ofs[0] / 3; - } + /* currently always 0, in future key_pointer_size may assign */ + ofs[1]= 0; - ofs[1]= 0; - } + if(!key_pointer_size(key, mode, &poinsize, &ofs[0])) + return; if(end>tot) end= tot; @@ -716,7 +720,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock /* just here, not above! */ elemsize= key->elemsize; - if(mode==KEY_BEZTRIPLE) elemsize*= 3; + if(mode == KEY_MODE_BEZTRIPLE) elemsize*= 3; /* step 1 init */ cp_key(start, end, tot, basispoin, key, actkb, key->refkey, NULL, mode); @@ -752,7 +756,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock weight= icuval; cp= key->elemstr; - if(mode==KEY_BEZTRIPLE) cp= elemstr; + if(mode == KEY_MODE_BEZTRIPLE) cp= elemstr; ofsp= ofs; @@ -768,8 +772,14 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock case IPO_BEZTRIPLE: rel_flerp(12, (float *)poin, (float *)reffrom, (float *)from, weight); break; + default: + /* should never happen */ + if(freefrom) MEM_freeN(freefrom); + if(freereffrom) MEM_freeN(freereffrom); + BKE_assert(!"invalid 'cp[1]'"); + return; } - + poin+= ofsp[0]; cp+= 2; @@ -779,7 +789,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock reffrom+= elemsize; from+= elemsize; - if(mode==KEY_BEZTRIPLE) b+= 2; + if(mode == KEY_MODE_BEZTRIPLE) b+= 2; if(weights) weights++; } @@ -791,7 +801,7 @@ void do_rel_key(int start, int end, int tot, char *basispoin, Key *key, KeyBlock } -static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock *actkb, KeyBlock **k, float *t, int mode) +static void do_key(const int start, int end, const int tot, char *poin, Key *key, KeyBlock *actkb, KeyBlock **k, float *t, const int mode) { float k1tot = 0.0, k2tot = 0.0, k3tot = 0.0, k4tot = 0.0; float k1d = 0.0, k2d = 0.0, k3d = 0.0, k4d = 0.0; @@ -800,29 +810,11 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * char *k1, *k2, *k3, *k4, *freek1, *freek2, *freek3, *freek4; char *cp, elemstr[8];; - if(key->from==0) return; + /* currently always 0, in future key_pointer_size may assign */ + ofs[1]= 0; - 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; - poinsize= ofs[0]; - } else { - ofs[0]= sizeof(float)*12; - poinsize= ofs[0] / 3; - } - - ofs[1]= 0; - } + if(!key_pointer_size(key, mode, &poinsize, &ofs[0])) + return; if(end>tot) end= tot; @@ -924,12 +916,12 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * /* only here, not above! */ elemsize= key->elemsize; - if(mode==KEY_BEZTRIPLE) elemsize*= 3; + if(mode == KEY_MODE_BEZTRIPLE) elemsize*= 3; for(a=start; aelemstr; - if(mode==KEY_BEZTRIPLE) cp= elemstr; + if(mode == KEY_MODE_BEZTRIPLE) cp= elemstr; ofsp= ofs; @@ -945,6 +937,14 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * case IPO_BEZTRIPLE: flerp(12, (void *)poin, (void *)k1, (void *)k2, (void *)k3, (void *)k4, t); break; + default: + /* should never happen */ + if(freek1) MEM_freeN(freek1); + if(freek2) MEM_freeN(freek2); + if(freek3) MEM_freeN(freek3); + if(freek4) MEM_freeN(freek4); + BKE_assert(!"invalid 'cp[1]'"); + return; } poin+= ofsp[0]; @@ -993,7 +993,7 @@ static void do_key(int start, int end, int tot, char *poin, Key *key, KeyBlock * else k4+= elemsize; } - if(mode==KEY_BEZTRIPLE) a+= 2; + if(mode == KEY_MODE_BEZTRIPLE) a+= 2; } if(freek1) MEM_freeN(freek1); @@ -1067,7 +1067,7 @@ static float *get_weights_array(Object *ob, char *vgroup) return NULL; } -static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, int tot) +static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int tot) { KeyBlock *k[4], *actkb= ob_get_keyblock(ob); float cfra, ctime, t[4], delta; @@ -1102,9 +1102,9 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, int tot) flag= setkeys(ctime, &key->block, k, t, 0); if(flag==0) - do_key(a, a+step, tot, (char *)out, key, actkb, k, t, 0); + do_key(a, a+step, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY); else - cp_key(a, a+step, tot, (char *)out, key, actkb, k[2], NULL, 0); + cp_key(a, a+step, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY); } } else { @@ -1114,7 +1114,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, int tot) for(kb= key->block.first; kb; kb= kb->next) kb->weights= get_weights_array(ob, kb->vgroup); - do_rel_key(0, tot, tot, (char *)out, key, actkb, 0); + do_rel_key(0, tot, tot, (char *)out, key, actkb, KEY_MODE_DUMMY); for(kb= key->block.first; kb; kb= kb->next) { if(kb->weights) MEM_freeN(kb->weights); @@ -1137,14 +1137,14 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, int tot) flag= setkeys(ctime, &key->block, k, t, 0); if(flag==0) - do_key(0, tot, tot, (char *)out, key, actkb, k, t, 0); + do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY); else - cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, 0); + cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY); } } } -static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float *t, char *out, int tot) +static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float *t, char *out, const int tot) { Nurb *nu; int a, step; @@ -1152,18 +1152,18 @@ static void do_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock **k, float for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) { if(nu->bp) { step= nu->pntsu*nu->pntsv; - do_key(a, a+step, tot, out, key, actkb, k, t, KEY_BPOINT); + do_key(a, a+step, tot, out, key, actkb, k, t, KEY_MODE_BPOINT); } else if(nu->bezt) { step= 3*nu->pntsu; - do_key(a, a+step, tot, out, key, actkb, k, t, KEY_BEZTRIPLE); + do_key(a, a+step, tot, out, key, actkb, k, t, KEY_MODE_BEZTRIPLE); } else step= 0; } } -static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, float UNUSED(ctime), char *out, int tot) +static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, float UNUSED(ctime), char *out, const int tot) { Nurb *nu; int a, step; @@ -1171,18 +1171,18 @@ static void do_rel_cu_key(Curve *cu, Key *key, KeyBlock *actkb, float UNUSED(cti for(a=0, nu=cu->nurb.first; nu; nu=nu->next, a+=step) { if(nu->bp) { step= nu->pntsu*nu->pntsv; - do_rel_key(a, a+step, tot, out, key, actkb, KEY_BPOINT); + do_rel_key(a, a+step, tot, out, key, actkb, KEY_MODE_BPOINT); } else if(nu->bezt) { step= 3*nu->pntsu; - do_rel_key(a, a+step, tot, out, key, actkb, KEY_BEZTRIPLE); + do_rel_key(a, a+step, tot, out, key, actkb, KEY_MODE_BEZTRIPLE); } else step= 0; } } -static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot) +static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const int tot) { Curve *cu= ob->data; KeyBlock *k[4], *actkb= ob_get_keyblock(ob); @@ -1206,11 +1206,11 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot) for(nu=cu->nurb.first; nu; nu=nu->next) { if(nu->bp) { - mode= KEY_BPOINT; + mode= KEY_MODE_BPOINT; estep= nu->pntsu*nu->pntsv; } else if(nu->bezt) { - mode= KEY_BEZTRIPLE; + mode= KEY_MODE_BEZTRIPLE; estep= 3*nu->pntsu; } else @@ -1230,7 +1230,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot) } count= MIN2(remain, estep); - if (mode == KEY_BEZTRIPLE) { + if (mode == KEY_MODE_BEZTRIPLE) { count += 3 - count % 3; } @@ -1268,7 +1268,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, int tot) } } -static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, int tot) +static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int tot) { Lattice *lt= ob->data; KeyBlock *k[4], *actkb= ob_get_keyblock(ob); @@ -1294,9 +1294,9 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, int tot) flag= setkeys(ctime, &key->block, k, t, 0); if(flag==0) - do_key(a, a+1, tot, (char *)out, key, actkb, k, t, 0); + do_key(a, a+1, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY); else - cp_key(a, a+1, tot, (char *)out, key, actkb, k[2], NULL, 0); + cp_key(a, a+1, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY); } } else { @@ -1306,7 +1306,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, int tot) for(kb= key->block.first; kb; kb= kb->next) kb->weights= get_weights_array(ob, kb->vgroup); - do_rel_key(0, tot, tot, (char *)out, key, actkb, 0); + do_rel_key(0, tot, tot, (char *)out, key, actkb, KEY_MODE_DUMMY); for(kb= key->block.first; kb; kb= kb->next) { if(kb->weights) MEM_freeN(kb->weights); @@ -1326,9 +1326,9 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, int tot) flag= setkeys(ctime, &key->block, k, t, 0); if(flag==0) - do_key(0, tot, tot, (char *)out, key, actkb, k, t, 0); + do_key(0, tot, tot, (char *)out, key, actkb, k, t, KEY_MODE_DUMMY); else - cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, 0); + cp_key(0, tot, tot, (char *)out, key, actkb, k[2], NULL, KEY_MODE_DUMMY); } } -- cgit v1.2.3 From 35422ac536467ccddcaa17014b87aa3ed041a068 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 3 Jan 2011 09:09:30 +0000 Subject: rna/api move Object.update(...) to ID.update(). since depsgraph update function can now be called on ID types. also changed how update flags work. obj.update(scene, 1, 1, 1) ... is now obj.update({'OBJECT', 'DATA', 'TIME'}) Don't pass scene anymore. This was used for recalculating text but I think this is better dont in a different function. --- source/blender/blenkernel/intern/depsgraph.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 1904e63c2ba..81a6b4a19e2 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2463,6 +2463,9 @@ void DAG_id_tag_update(ID *id, short flag) } } } + else { + BKE_assert(!"invalid flag for this 'idtype'"); + } } } -- cgit v1.2.3 From 8a2a7687f4a7eecd49996251303b5eaed23d995d Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 3 Jan 2011 12:48:16 +0000 Subject: Bugfix #25457 After loading file, the Undo-push happened too early, causing an undo for the first action to show animated setups wrong. (material.c: removed old crap) --- source/blender/blenkernel/intern/material.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index dae00636370..3f18e7f3723 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1341,7 +1341,6 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) /* copy/paste buffer, if we had a propper py api that would be better */ Material matcopybuf; -// MTex mtexcopybuf; static short matcopied=0; void clear_matcopybuf(void) @@ -1352,7 +1351,6 @@ void clear_matcopybuf(void) void free_matcopybuf(void) { -// extern MTex mtexcopybuf; /* buttons.c */ int a; for(a=0; anodetree= ntreeCopyTree(matcopybuf.nodetree, 0); - - /* - BIF_preview_changed(ID_MA); - BIF_undo_push("Paste material settings"); - scrarea_queue_winredraw(curarea); - */ } -- cgit v1.2.3 From 2ad8175597d1306429a4246ad14e470b506f7b3b Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 3 Jan 2011 15:50:08 +0000 Subject: Todo: Material nodes - On each re-render, the node image was cleared. Skipping this gives nicer pictures - Node render was using AA, but unfortunately only 1 sample for Nodes is being stored. Disable AA render for now, nice speedup too. --- source/blender/blenkernel/intern/node.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index db11b42ee1e..bd126ab12c2 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1270,8 +1270,7 @@ static void node_init_preview(bNode *node, int xsize, int ysize) node->preview->xsize= xsize; node->preview->ysize= ysize; } - else - memset(node->preview->rect, 0, 4*xsize + xsize*ysize*sizeof(char)*4); + /* no clear, makes nicer previews */ } void ntreeInitPreview(bNodeTree *ntree, int xsize, int ysize) -- cgit v1.2.3 From 522615536952c02fababd72ab9106c0a68a8071d Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 3 Jan 2011 19:45:08 +0000 Subject: Memory for bevelSplitFlag wasn't duplicated in copy_displist. Also corrected memory allocation comment for this array. --- source/blender/blenkernel/intern/displist.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index a6957d6ead1..0ee85624bee 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -150,7 +150,10 @@ void copy_displist(ListBase *lbn, ListBase *lb) dln->index= MEM_dupallocN(dl->index); dln->col1= MEM_dupallocN(dl->col1); dln->col2= MEM_dupallocN(dl->col2); - + + if(dl->bevelSplitFlag) + dln->bevelSplitFlag= MEM_dupallocN(dl->bevelSplitFlag); + dl= dl->next; } } @@ -1790,7 +1793,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba /* CU_2D conflicts with R_NOPUNOFLIP */ dl->rt= nu->flag & ~CU_2D; - dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "col2"); + dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "bevelSplitFlag"); bevp= (BevPoint *)(bl+1); /* for each point of poly make a bevel piece */ -- cgit v1.2.3 From 9cafe19c707971f916060f94c40660e6b65a30e3 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 4 Jan 2011 08:56:25 +0000 Subject: - use BKE_keyingset_free_path where paths were being freed inline. - rna_path was being freed when null, printing errors. --- source/blender/blenkernel/intern/anim_sys.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 1ddf6a73abd..abe5b50664f 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -916,10 +916,11 @@ void BKE_keyingset_free_path (KeyingSet *ks, KS_Path *ksp) /* sanity check */ if ELEM(NULL, ks, ksp) return; - + /* free RNA-path info */ - MEM_freeN(ksp->rna_path); - + if(ksp->rna_path) + MEM_freeN(ksp->rna_path); + /* free path itself */ BLI_freelinkN(&ks->paths, ksp); } -- cgit v1.2.3 From 221187bcbda208e442ecfe0a081170f927c399df Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 4 Jan 2011 12:31:42 +0000 Subject: comment assert and ensure meshes are always calculated with CD_MASK_BAREMESH, scene->customdata_mask should be corrected in background mode but for now this is ok. --- source/blender/blenkernel/intern/object.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 07fee83a405..a2b6163321b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2549,6 +2549,7 @@ void object_handle_update(Scene *scene, Object *ob) switch(ob->type) { case OB_MESH: { +#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask' EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; BKE_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH); if(em) { @@ -2556,6 +2557,16 @@ void object_handle_update(Scene *scene, Object *ob) BKE_mesh_end_editmesh(ob->data, em); } else makeDerivedMesh(scene, ob, NULL, scene->customdata_mask); + +#else /* ensure CD_MASK_BAREMESH for now */ + EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; + if(em) { + makeDerivedMesh(scene, ob, em, scene->customdata_mask | CD_MASK_BAREMESH); /* was CD_MASK_BAREMESH */ + BKE_mesh_end_editmesh(ob->data, em); + } else + makeDerivedMesh(scene, ob, NULL, scene->customdata_mask | CD_MASK_BAREMESH); +#endif + } break; -- cgit v1.2.3 From 96b646c68dd9f62f7655b7eee902bddb908e12a5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 5 Jan 2011 02:08:54 +0000 Subject: edits for BPY_extern.h functions, no functional changes - remove unused code. - BPY_run_python_script() split in 2, BPY_filepath_exec, BPY_text_exec - renamed funcs. --- source/blender/blenkernel/intern/constraint.c | 2 +- source/blender/blenkernel/intern/context.c | 4 ++-- source/blender/blenkernel/intern/exotic.c | 7 +------ source/blender/blenkernel/intern/fcurve.c | 2 +- source/blender/blenkernel/intern/text.c | 4 ++-- 5 files changed, 7 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index b0932533ea6..b6e68a71bc9 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -2033,7 +2033,7 @@ static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targ #endif /* Now, run the actual 'constraint' function, which should only access the matrices */ - BPY_pyconstraint_eval(data, cob, targets); + BPY_pyconstraint_exec(data, cob, targets); #endif /* WITH_PYTHON */ } diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 9740c969ec7..09321ddea81 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -427,8 +427,8 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res memset(result, 0, sizeof(bContextDataResult)); #ifdef WITH_PYTHON if(CTX_py_dict_get(C)) { - return BPY_context_get(C, member, result); -// if (BPY_context_get(C, member, result)) + return BPY_context_member_get(C, member, result); +// if (BPY_context_member_get(C, member, result)) // return 1; } #endif diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 53c3534bce3..e695c40401a 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -492,12 +492,7 @@ int BKE_read_exotic(Scene *scene, const char *name) #ifdef WITH_PYTHON // TODO: this should not be in the kernel... else { // unknown format, call Python importloader - if (BPY_call_importloader(name)) { - retval = 1; - } else { - //XXX error("Unknown file type or error, check console"); - } - + /* pass */ } #endif /* WITH_PYTHON */ //XXX waitcursor(0); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index f2bc586f15c..4a596b079cf 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1514,7 +1514,7 @@ static float evaluate_driver (ChannelDriver *driver, float UNUSED(evaltime)) /* this evaluates the expression using Python,and returns its result: * - on errors it reports, then returns 0.0f */ - driver->curval= BPY_eval_driver(driver); + driver->curval= BPY_driver_exec(driver); } #endif /* WITH_PYTHON*/ } diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index bb3a31a0977..44a8141adff 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -168,7 +168,7 @@ void free_text(Text *text) if(text->name) MEM_freeN(text->name); MEM_freeN(text->undo_buf); #ifdef WITH_PYTHON - if (text->compiled) BPY_free_compiled_text(text); + if (text->compiled) BPY_text_free_code(text); #endif } @@ -684,7 +684,7 @@ static void txt_make_dirty (Text *text) { text->flags |= TXT_ISDIRTY; #ifdef WITH_PYTHON - if (text->compiled) BPY_free_compiled_text(text); + if (text->compiled) BPY_text_free_code(text); #endif } -- cgit v1.2.3 From 370adc51ffa31af482b94b3ba15f601987e29a40 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 5 Jan 2011 05:33:27 +0000 Subject: py api function to tag all ID blocks, was available in 2.4x as. bpy.data.meshes.tag = True But this was only useful for setting so make it a function for 2.5x. bpy.data.objects.tag(False) X3D: use tagging rather then a name dictionary, this fixes a bug where library name overlaps could mix up names. --- source/blender/blenkernel/intern/library.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index cac0b64a6b6..08adfdc1960 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1257,18 +1257,36 @@ static void lib_indirect_test_id(ID *id, Library *lib) } } -void tag_main(struct Main *mainvar, int tag) +void tag_main_lb(ListBase *lb, const short tag) { - ListBase *lbarray[MAX_LIBARRAY]; ID *id; + if(tag) { + for(id= lb->first; id; id= id->next) { + id->flag |= LIB_DOIT; + } + } + else { + for(id= lb->first; id; id= id->next) { + id->flag &= ~LIB_DOIT; + } + } +} + +void tag_main_idcode(struct Main *mainvar, const short type, const short tag) +{ + ListBase *lb= which_libbase(mainvar, type); + + tag_main_lb(lb, tag); +} + +void tag_main(struct Main *mainvar, const short tag) +{ + ListBase *lbarray[MAX_LIBARRAY]; int a; a= set_listbasepointers(mainvar, lbarray); while(a--) { - for(id= lbarray[a]->first; id; id= id->next) { - if(tag) id->flag |= LIB_DOIT; - else id->flag &= ~LIB_DOIT; - } + tag_main_lb(lbarray[a], tag); } } -- cgit v1.2.3 From 7a7760e938fc16acaa60d7a2e9c06167213536b3 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 5 Jan 2011 08:52:13 +0000 Subject: Fix for [#25492] Cached particles are killed too early * Own mistake from the sph particle fluids fix. --- 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 f0af7e8684b..f57364dfdef 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2943,7 +2943,7 @@ static void deflect_particle(ParticleSimulationData *sim, int p, float dfra, flo /* particle dies in collision */ if(through == 0 && (part->flag & PART_DIE_ON_COL || pd->flag & PDEFLE_KILL_PART)) { pa->alive = PARS_DYING; - pa->dietime = pa->state.time + (cfra - pa->state.time) * f; + pa->dietime = sim->psys->cfra + (cfra - sim->psys->cfra) * f; copy_v3_v3(pa->state.co, co); interp_v3_v3v3(pa->state.vel, pa->prev_state.vel, pa->state.vel, f); -- cgit v1.2.3 From 64c3ea272e7be85c0f589a6f28eae28d7e7d0a9e Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 5 Jan 2011 10:40:38 +0000 Subject: Todo item: linked curve objects behaves incorrect with modifiers Use object's displists for storing deformed tesselated curve. Was unable to totally get rid of curve's displist because of how texture space is calculating. --- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- source/blender/blenkernel/intern/curve.c | 4 ++-- source/blender/blenkernel/intern/depsgraph.c | 13 ------------ source/blender/blenkernel/intern/displist.c | 27 +++++++++++++++++------- source/blender/blenkernel/intern/mesh.c | 2 +- 5 files changed, 23 insertions(+), 25 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 8030a3655ad..efdfdbc986f 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1644,7 +1644,7 @@ DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *UNUSED(me)) DerivedMesh *CDDM_from_curve(Object *ob) { - return CDDM_from_curve_customDB(ob, &((Curve *)ob->data)->disp); + return CDDM_from_curve_customDB(ob, &ob->disp); } DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 6368c139baf..6dd3eb43e29 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1266,10 +1266,10 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) makeDispListCurveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0); dl= bevdisp.first; } else { - dl= bevcu->disp.first; + dl= cu->bevobj->disp.first; if(dl==0) { makeDispListCurveTypes(scene, cu->bevobj, 0); - dl= bevcu->disp.first; + dl= cu->bevobj->disp.first; } } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 81a6b4a19e2..2429c098ec9 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2330,23 +2330,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) idtype= GS(id->name); if(ELEM7(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR)) { - int first_ob= 1; for(obt=bmain->object.first; obt; obt= obt->id.next) { if(!(ob && obt == ob) && obt->data == id) { - - /* try to avoid displist recalculation for linked curves */ - if (!first_ob && ELEM(obt->type, OB_CURVE, OB_SURF)) { - /* if curve object has got derivedFinal it means this - object has got constructive modifiers and object - should be recalculated anyhow */ - if (!obt->derivedFinal) - continue; - } - obt->recalc |= OB_RECALC_DATA; BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); - - first_ob= 0; } } } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 0ee85624bee..612d0d4fe38 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -660,7 +660,7 @@ void shadeDispList(Scene *scene, Base *base) /* now we need the normals */ cu= ob->data; - dl= cu->disp.first; + dl= ob->disp.first; while(dl) { extern Material defmaterial; /* material.c */ @@ -1140,16 +1140,14 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis */ float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) { - Curve *cu; DispList *dl; if(taperobj==NULL || taperobj->type!=OB_CURVE) return 1.0; - cu= taperobj->data; - dl= cu->disp.first; + dl= taperobj->disp.first; if(dl==NULL) { makeDispListCurveTypes(scene, taperobj, 0); - dl= cu->disp.first; + dl= taperobj->disp.first; } if(dl) { float fac= ((float)cur)/(float)(tot-1); @@ -1678,6 +1676,11 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, } } + /* make copy of 'undeformed" displist for texture space calculation + actually, it's not totally undeformed -- pre-tesselation modifiers are + already applied, thats how it worked for years, so keep for compatibility (sergey) */ + copy_displist(&cu->disp, dispbase); + if (!forRender) { tex_space_curve(cu); } @@ -1851,6 +1854,11 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if(cu->flag & CU_PATH) calc_curvepath(ob); + /* make copy of 'undeformed" displist for texture space calculation + actually, it's not totally undeformed -- pre-tesselation modifiers are + already applied, thats how it worked for years, so keep for compatibility (sergey) */ + copy_displist(&cu->disp, dispbase); + if (!forRender) { tex_space_curve(cu); } @@ -1865,13 +1873,16 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) { - Curve *cu = ob->data; + Curve *cu= ob->data; ListBase *dispbase; freedisplist(&(ob->disp)); - dispbase= &(cu->disp); + dispbase= &(ob->disp); freedisplist(dispbase); + /* free displist used for textspace */ + freedisplist(&cu->disp); + do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco); if (ob->derivedFinal) { @@ -1941,7 +1952,7 @@ static void boundbox_displist(Object *ob) if(cu->bb==0) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); bb= cu->bb; - dl= cu->disp.first; + dl= ob->disp.first; while (dl) { if(dl->type==DL_INDEX3) tot= dl->nr; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 7a72207ff69..03fab0718da 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -735,7 +735,7 @@ void mball_to_mesh(ListBase *lb, Mesh *me) int nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert, MEdge **alledge, int *totedge, MFace **allface, int *totface) { - return nurbs_to_mdata_customdb(ob, &((Curve *)ob->data)->disp, + return nurbs_to_mdata_customdb(ob, &ob->disp, allvert, totvert, alledge, totedge, allface, totface); } -- cgit v1.2.3 From 0daebd0ed6e77ef5fd8d4c788d6e73572d9e98b8 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 5 Jan 2011 12:04:06 +0000 Subject: Fix #25316: distorted subsurf UV in some cases. To counter distortion at seams, we add extra creasing in the UV mesh, to keep it from shrinking, leading to distorted UVs, but this wasn't always working right, so tweaked the conditions. --- source/blender/blenkernel/intern/CCGSubSurf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 1cd5ae381c4..35ba8caedb0 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -1521,7 +1521,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, } } - if (seam && seamEdges < 2) + if (seamEdges < 2 || seamEdges != v->numEdges) seam = 0; if (!v->numEdges) { @@ -1949,7 +1949,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { } } - if (seam && seamEdges < 2) + if (seamEdges < 2 || seamEdges != v->numEdges) seam = 0; if (!v->numEdges) { -- cgit v1.2.3 From 8e29c7b76f23028e679e7dc97c90eba795604b5d Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 5 Jan 2011 13:15:29 +0000 Subject: Material slots: on adding a new one, the material datablock is now copied again like in 2.4x. This can result in material datablocks you don't need, but not doing it seems to cause too much confusion. --- source/blender/blenkernel/intern/material.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 3f18e7f3723..2d123302c3d 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -786,6 +786,13 @@ int object_add_material_slot(Object *ob) ma= give_current_material(ob, ob->actcol); + if(ma == NULL) + ma= add_material("Material"); + else + ma= copy_material(ma); + + id_us_min(&ma->id); + assign_material(ob, ma, ob->totcol+1); ob->actcol= ob->totcol; return TRUE; -- cgit v1.2.3 From 91d352024b8fd6eb21e73db2c3893f732f41ebde Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 5 Jan 2011 15:58:44 +0000 Subject: Get rid of uninitialized variable and malicios derived mesh relising. Pointer by llvn analyzer. --- source/blender/blenkernel/intern/multires.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 84350127968..a3c13b36dcf 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -197,7 +197,7 @@ int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd, return 1; } - mrdm->release(mrdm); + if(mrdm) mrdm->release(mrdm); return 0; } @@ -1870,7 +1870,7 @@ void mdisp_rot_crn_to_face(int S, int corners, int face_side, float x, float y, int mdisp_rot_face_to_crn(int corners, int face_side, float u, float v, float *x, float *y) { float offset = face_side*0.5f - 0.5f; - int S; + int S = 0; if (corners == 4) { if(u <= offset && v <= offset) S = 0; -- cgit v1.2.3 From 5f64450726e1efbfad97525bb36bfea2c51afa09 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 6 Jan 2011 01:29:13 +0000 Subject: remove assignments which are unused. --- source/blender/blenkernel/intern/displist.c | 2 -- source/blender/blenkernel/intern/pointcache.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 612d0d4fe38..8c32733dd66 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -625,7 +625,6 @@ void shadeDispList(Scene *scene, Base *base) Object *ob= base->object; DispList *dl, *dlob; Material *ma = NULL; - Curve *cu; Render *re; float imat[3][3], mat[4][4], vec[3]; float *fp, *nor, n1[3]; @@ -659,7 +658,6 @@ void shadeDispList(Scene *scene, Base *base) if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { /* now we need the normals */ - cu= ob->data; dl= ob->disp.first; while(dl) { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index b8e8508da26..c886c252d61 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -115,7 +115,7 @@ static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, size_t size); /* Common functions */ static int ptcache_basic_header_read(PTCacheFile *pf) { - uint32_t totpoint, data_types; + uint32_t totpoint, data_types= 0; int error=0; /* Custom functions should read these basic elements too! */ -- cgit v1.2.3 From 109d3b84545ea8cd60e6f42d2f72c2a2d19f7283 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 Jan 2011 04:30:02 +0000 Subject: bugfix [#25519] particlesystem, type hair, hair dynamics enabled: crash with amount 0 --- source/blender/blenkernel/intern/particle_system.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (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 f57364dfdef..0e22697d0a7 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3297,8 +3297,8 @@ static void hair_step(ParticleSimulationData *sim, float cfra) cloth_free_modifier(psys->clmd); } - /* dynamics with cloth simulation */ - if(psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) + /* dynamics with cloth simulation, psys->particles can be NULL with 0 particles [#25519] */ + if(psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS && psys->particles) do_hair_dynamics(sim); /* following lines were removed r29079 but cause bug [#22811], see report for details */ -- cgit v1.2.3 From a13267463425d22f69d3d1d313df921e6c1238f9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 Jan 2011 06:50:29 +0000 Subject: patch [#25490] Fix for [#22096] Blender tries to open non-blend file from Alexander Kuznetsov (alexk) with edits. From the report: Blender assumed that all files are .blend as retval = 0; Now retval is initialized as file cannot be open (-1) for gzopen fail and directory case retval = -2; is defined for not supported formats This must be assigned before #ifdef WITH_PYTHON because this part can be missing Finally retval = 0; if it is a .blend file --- also made other edits. - exotic.c's blend header checking was sloppy, didn't check data was actually read, only checked first 4 bytes and had a check for "blend.gz" extension which is unnecessary. - use defines to help readability for BKE_read_exotic & BKE_read_file return values. - no need to check for a NULL pointer before calling BKE_reportf(). (will just print to the console) - print better reports when the file fails to load. --- source/blender/blenkernel/intern/blender.c | 8 +----- source/blender/blenkernel/intern/exotic.c | 41 +++++++++++++++--------------- 2 files changed, 22 insertions(+), 27 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index b782d3a92a9..b218632e8e5 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -346,12 +346,6 @@ void BKE_userdef_free(void) BLI_freelistN(&U.addons); } -/* returns: - 0: no load file - 1: OK - 2: OK, and with new user settings -*/ - int BKE_read_file(bContext *C, const char *dir, ReportList *reports) { BlendFileData *bfd; @@ -459,7 +453,7 @@ static int read_undosave(bContext *C, UndoElem *uel) G.fileflags |= G_FILE_NO_UI; if(UNDO_DISK) - success= BKE_read_file(C, uel->str, NULL); + success= (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL); else success= BKE_read_file_from_memfile(C, &uel->memfile, NULL); diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index e695c40401a..30cad2b6d2f 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -74,7 +74,7 @@ #include "BKE_object.h" #include "BKE_material.h" #include "BKE_report.h" - +#include "BKE_exotic.h" #include "BKE_displist.h" #include "BKE_DerivedMesh.h" #include "BKE_curve.h" @@ -458,49 +458,50 @@ int BKE_read_exotic(Scene *scene, const char *name) { int len; gzFile gzfile; - char str[32]; - int *s0 = (int*) str; - int retval = 0; + int head[2]; + int retval; // make sure we're not trying to read a directory.... len= strlen(name); - if (name[len-1] !='/' && name[len-1] != '\\') { + if (ELEM(name[len-1], '/', '\\')) { + retval= BKE_READ_EXOTIC_FAIL_PATH; + } + else { gzfile = gzopen(name,"rb"); - if (NULL == gzfile ) { - //XXX error("Can't open file: %s", name); - retval= -1; - } else { - gzread(gzfile, str, 31); + if (gzfile == NULL) { + retval= BKE_READ_EXOTIC_FAIL_OPEN; + } + else { + len= gzread(gzfile, &head, sizeof(head)); gzclose(gzfile); - if ((*s0 != FORM) && (strncmp(str, "BLEN", 4) != 0) && !BLI_testextensie(name,".blend.gz")) { - + if (len == sizeof(head) && (head[0] == BLEN && head[1] == DER_)) { + retval= BKE_READ_EXOTIC_OK_BLEND; + } + else { //XXX waitcursor(1); if(is_dxf(name)) { dxf_read(scene, name); - retval = 1; + retval= BKE_READ_EXOTIC_OK_OTHER; } else if(is_stl(name)) { if (is_stl_ascii(name)) read_stl_mesh_ascii(scene, name); else read_stl_mesh_binary(scene, name); - retval = 1; + retval= BKE_READ_EXOTIC_OK_OTHER; } -#ifdef WITH_PYTHON - // TODO: this should not be in the kernel... - else { // unknown format, call Python importloader - /* pass */ + else { + retval= BKE_READ_EXOTIC_FAIL_FORMAT; } -#endif /* WITH_PYTHON */ //XXX waitcursor(0); } } } - return (retval); + return retval; } -- cgit v1.2.3 From f3a00259e240535c69814951edff24d0d89833db Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 Jan 2011 07:36:51 +0000 Subject: bugfix [#25457] Lack of update on undoing a lattice rig --- source/blender/blenkernel/intern/depsgraph.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 2429c098ec9..5fdb8f0206a 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2264,7 +2264,7 @@ void DAG_on_load_update(Main *bmain, const short do_time) oblay= (node)? node->lay: ob->lay; if(oblay & lay) { - if(ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL)) + if(ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) ob->recalc |= OB_RECALC_DATA; if(ob->dup_group) ob->dup_group->id.flag |= LIB_DOIT; @@ -2274,7 +2274,7 @@ void DAG_on_load_update(Main *bmain, const short do_time) 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)) + if(ELEM6(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) go->ob->recalc |= OB_RECALC_DATA; if(go->ob->proxy_from) go->ob->recalc |= OB_RECALC_OB; -- cgit v1.2.3 From 7fe16a24a4f9c8d53bff5e11fdb9fb3d60a4b898 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 Jan 2011 08:59:00 +0000 Subject: fix for error in own commit r34143 --- source/blender/blenkernel/intern/exotic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 30cad2b6d2f..2c08e772a1a 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -474,7 +474,7 @@ int BKE_read_exotic(Scene *scene, const char *name) retval= BKE_READ_EXOTIC_FAIL_OPEN; } else { - len= gzread(gzfile, &head, sizeof(head)); + len= gzread(gzfile, head, sizeof(head)); gzclose(gzfile); if (len == sizeof(head) && (head[0] == BLEN && head[1] == DER_)) { -- cgit v1.2.3 From 41c00063dd43f1a653747129bdb29dcdb13818dd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 Jan 2011 09:47:05 +0000 Subject: another error in commit r34143, was using the define's 'BLEN' & 'DER_' however the latter is incorrect since DER- is used for 64bit blend files. removed the define. --- source/blender/blenkernel/intern/exotic.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 2c08e772a1a..d19226b2478 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -458,7 +458,7 @@ int BKE_read_exotic(Scene *scene, const char *name) { int len; gzFile gzfile; - int head[2]; + char header[7]; int retval; // make sure we're not trying to read a directory.... @@ -474,10 +474,9 @@ int BKE_read_exotic(Scene *scene, const char *name) retval= BKE_READ_EXOTIC_FAIL_OPEN; } else { - len= gzread(gzfile, head, sizeof(head)); + len= gzread(gzfile, header, sizeof(header)); gzclose(gzfile); - - if (len == sizeof(head) && (head[0] == BLEN && head[1] == DER_)) { + if (len == sizeof(header) && strncmp(header, "BLENDER", 7) == 0) { retval= BKE_READ_EXOTIC_OK_BLEND; } else { -- cgit v1.2.3 From 96128ee69f00fb4a91155f63608c23a2ee5a45a6 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 7 Jan 2011 10:13:30 +0000 Subject: Fix for [#25506] Hair showing up in places not assigned by a weightmap * Two separate bugs, with very similar symptoms. * The distribution binary search didn't work correctly in cases where there were a lot of faces with 0 weights. * Maximum distribution sum should have been exactly 1, but due to the wonderful nature of floats this wasn't the case at all. --- source/blender/blenkernel/intern/particle_system.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (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 0e22697d0a7..08fe931693e 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -616,15 +616,21 @@ static void psys_uv_to_w(float u, float v, int quad, float *w) } } +/* Find the index in "sum" array before "value" is crossed. */ static int binary_search_distribution(float *sum, int n, float value) { int mid, low=0, high=n; + if(value == 0.f) + return 0; + while(low <= high) { mid= (low + high)/2; - if(sum[mid] <= value && value <= sum[mid+1]) + + if(sum[mid] < value && value <= sum[mid+1]) return mid; - else if(sum[mid] > value) + + if(sum[mid] >= value) high= mid - 1; else if(sum[mid] < value) low= mid + 1; @@ -1297,7 +1303,8 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, float pos; for(p=0; p Date: Fri, 7 Jan 2011 10:38:17 +0000 Subject: Fix for [#25526] Inmediate crash when changing amount of particles in a particle system * Point cache index array doesn't necessarily have all particles if the particles were re-allocated recently. --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index c886c252d61..4d96f0508d1 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1182,7 +1182,7 @@ int BKE_ptcache_mem_pointers_seek(int point_index, PTCacheMem *pm) int data_types = pm->data_types; int i, index = pm->index_array ? pm->index_array[point_index] - 1 : point_index; - if(index < 0) { + if(index < 0 || point_index >= MEM_allocN_len(pm->index_array)/sizeof(int)) { /* Can't give proper location without reallocation, so don't give any location. * Some points will be cached improperly, but this only happens with simulation * steps bigger than cache->step, so the cache has to be recalculated anyways -- cgit v1.2.3 From 29efbf8a04c66a6c0e71c63140185a603d4e684b Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 7 Jan 2011 11:24:34 +0000 Subject: New hair child options: * Renamed children to "simple" and "interpolated" as this is easier to explain and more descriptive than "from particles" and "from faces". * Also shuffled the child ui around a bit to make it clearer. * Child seed parameter allows to change the seed for children independent of the main seed value. * Long hair mode for interpolated children: - Making even haircuts was impossible before as the child strand lengths were even, but their root coordinates were not similar in relation to the parent strands. - The "long hair" option uses the tips of the parent strands to calculate the child strand tips. * Hair parting options: - Hair parting can now be calculated dynamically on the fly when in 2.49 there was a cumbersome way of using emitter mesh seams to define parting lines. - For long hair parting can be created by a tip distance/root distance threshold. For example setting the minimum threshold to 2.0 creates partings between children belonging to parents with tip distance of three times the root distance ((1+2)*root distance). - For short hair the parting thresholds are used as angles between the root directions. * New kink parameters: - Kink flatness calculates kink into a shape that would have been achieved with an actual curling iron. - Kink amplitude clump determines how much the main clump value effects the kink amplitude. - The beginning of kink is now smoothed to make the hair look more natural close to the roots. * Some bugs fixed along the way too: - Child parent's were not determined correctly in some cases. - Children didn't always look correct in particle mode. - Changing child parameters caused actual particles to be recalculated. * Also cleaned up some deprecated code. All in all there should be no real changes to how old files look (except perhaps a bit better!), but the new options should make hair/fur creation a bit more enjoyable. I'll try to make a video demonstrating the new stuff shortly. --- source/blender/blenkernel/intern/particle.c | 792 +++++++++++---------- source/blender/blenkernel/intern/particle_system.c | 112 +-- source/blender/blenkernel/intern/pointcache.c | 9 +- 3 files changed, 411 insertions(+), 502 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 95e14542e28..d3a0cd5df7c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1862,144 +1862,184 @@ static float vert_weight(MDeformVert *dvert, int group) return 0.0; } -static void do_prekink(ParticleKey *state, ParticleKey *par, float *par_rot, float time, float freq, float shape, float amplitude, short type, short axis, float obmat[][4]) +static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float time, float freq, float shape, float amplitude, float flat, short type, short axis, float obmat[][4], int smooth_start) { - float vec[3]={0.0,0.0,0.0}, q1[4]={1,0,0,0},q2[4]; - float t; + float kink[3]={1.f,0.f,0.f}, par_vec[3], q1[4]={1.f,0.f,0.f,0.f}; + float t, dt=1.f, result[3]; - CLAMP(time,0.0,1.0); + if(par == NULL || type == PART_KINK_NO) + return; + + CLAMP(time, 0.f, 1.f); if(shape!=0.0f && type!=PART_KINK_BRAID) { if(shape<0.0f) - time= (float)pow(time, 1.0+shape); + time= (float)pow(time, 1.f+shape); else - time= (float)pow(time, 1.0/(1.0-shape)); + time= (float)pow(time, 1.f/(1.f-shape)); } - t=time; + t = time * freq *(float)M_PI; + + if(smooth_start) { + dt = fabs(t); + /* smooth the beginning of kink */ + CLAMP(dt, 0.f, (float)M_PI); + dt = sin(dt/2.f); + } - t*=(float)M_PI*freq; + if(type != PART_KINK_RADIAL) { + float temp[3]; - if(par==0) return; + kink[axis]=1.f; - switch(type){ - case PART_KINK_CURL: - vec[axis]=1.0; - if(par_rot) - QUATCOPY(q2,par_rot) - else - vec_to_quat( q2,par->vel,axis,(axis+1)%3); - mul_qt_v3(q2,vec); - mul_v3_fl(vec,amplitude); - VECADD(state->co,state->co,vec); + if(obmat) + mul_mat3_m4_v3(obmat, kink); + + if(par_rot) + mul_qt_v3(par_rot, kink); - VECSUB(vec,state->co,par->co); + /* make sure kink is normal to strand */ + project_v3_v3v3(temp, kink, par->vel); + sub_v3_v3(kink, temp); + normalize_v3(kink); + } - if(t!=0.0) - axis_angle_to_quat(q1,par->vel,t); - - mul_qt_v3(q1,vec); - - VECADD(state->co,par->co,vec); - break; - case PART_KINK_RADIAL: - VECSUB(vec,state->co,par->co); + copy_v3_v3(result, state->co); + sub_v3_v3v3(par_vec, par->co, state->co); - normalize_v3(vec); - mul_v3_fl(vec,amplitude*(float)sin(t)); + switch(type) { + case PART_KINK_CURL: + { + mul_v3_fl(par_vec, -1.f); - VECADD(state->co,state->co,vec); - break; - case PART_KINK_WAVE: - vec[axis]=1.0; - if(obmat) - mul_mat3_m4_v3(obmat,vec); + if(flat > 0.f) { + float proj[3]; + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(par_vec, proj, -flat); - if(par_rot) - mul_qt_v3(par_rot,vec); + project_v3_v3v3(proj, par_vec, kink); + madd_v3_v3fl(par_vec, proj, -flat); + } - project_v3_v3v3(q1,vec,par->vel); - - VECSUB(vec,vec,q1); - normalize_v3(vec); + axis_angle_to_quat(q1, kink, (float)M_PI/2.f); - mul_v3_fl(vec,amplitude*(float)sin(t)); + mul_qt_v3(q1, par_vec); - VECADD(state->co,state->co,vec); - break; - case PART_KINK_BRAID: - if(par){ - float y_vec[3]={0.0,1.0,0.0}; - float z_vec[3]={0.0,0.0,1.0}; - float vec_from_par[3], vec_one[3], radius, state_co[3]; - float inp_y,inp_z,length; - - if(par_rot) - QUATCOPY(q2,par_rot) - else - vec_to_quat(q2,par->vel,axis,(axis+1)%3); - mul_qt_v3(q2,y_vec); - mul_qt_v3(q2,z_vec); - - VECSUB(vec_from_par,state->co,par->co); - radius= normalize_v3_v3(vec_one, vec_from_par); + madd_v3_v3fl(par_vec, kink, amplitude); - inp_y=dot_v3v3(y_vec,vec_one); - inp_z=dot_v3v3(z_vec,vec_one); + /* rotate kink vector around strand tangent */ + if(t!=0.f) { + axis_angle_to_quat(q1, par->vel, t); + mul_qt_v3(q1, par_vec); + } - if(inp_y>0.5){ - VECCOPY(state_co,y_vec); + add_v3_v3v3(result, par->co, par_vec); + break; + } + case PART_KINK_RADIAL: + { + if(flat > 0.f) { + float proj[3]; + /* flatten along strand */ + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(result, proj, flat); + } - mul_v3_fl(y_vec,amplitude*(float)cos(t)); - mul_v3_fl(z_vec,amplitude/2.0f*(float)sin(2.0f*t)); - } - else if(inp_z>0.0){ - VECCOPY(state_co,z_vec); - mul_v3_fl(state_co,(float)sin(M_PI/3.0f)); - VECADDFAC(state_co,state_co,y_vec,-0.5f); + madd_v3_v3fl(result, par_vec, -amplitude*(float)sin(t)); + break; + } + case PART_KINK_WAVE: + { + madd_v3_v3fl(result, kink, amplitude*(float)sin(t)); - mul_v3_fl(y_vec,-amplitude*(float)cos(t + M_PI/3.0f)); - mul_v3_fl(z_vec,amplitude/2.0f*(float)cos(2.0f*t + M_PI/6.0f)); - } - else{ - VECCOPY(state_co,z_vec); - mul_v3_fl(state_co,-(float)sin(M_PI/3.0f)); - VECADDFAC(state_co,state_co,y_vec,-0.5f); + if(flat > 0.f) { + float proj[3]; + /* flatten along wave */ + project_v3_v3v3(proj, par_vec, kink); + madd_v3_v3fl(result, proj, flat); - mul_v3_fl(y_vec,amplitude*(float)-sin(t+M_PI/6.0f)); - mul_v3_fl(z_vec,amplitude/2.0f*(float)-sin(2.0f*t+M_PI/3.0f)); - } + /* flatten along strand */ + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(result, proj, flat); + } + break; + } + case PART_KINK_BRAID: + { + float y_vec[3]={0.f,1.f,0.f}; + float z_vec[3]={0.f,0.f,1.f}; + float vec_one[3], radius, state_co[3]; + float inp_y, inp_z, length; - mul_v3_fl(state_co,amplitude); - VECADD(state_co,state_co,par->co); - VECSUB(vec_from_par,state->co,state_co); + mul_qt_v3(par_rot, y_vec); + mul_qt_v3(par_rot, z_vec); + + mul_v3_fl(par_vec, -1.f); + radius= normalize_v3_v3(vec_one, par_vec); - length=normalize_v3(vec_from_par); - mul_v3_fl(vec_from_par,MIN2(length,amplitude/2.0f)); + inp_y=dot_v3v3(y_vec, vec_one); + inp_z=dot_v3v3(z_vec, vec_one); - VECADD(state_co,par->co,y_vec); - VECADD(state_co,state_co,z_vec); - VECADD(state_co,state_co,vec_from_par); + if(inp_y>0.5){ + copy_v3_v3(state_co, y_vec); - shape=(2.0f*(float)M_PI)*(1.0f+shape); + mul_v3_fl(y_vec, amplitude*(float)cos(t)); + mul_v3_fl(z_vec, amplitude/2.f*(float)sin(2.f*t)); + } + else if(inp_z>0.0){ + mul_v3_v3fl(state_co, z_vec, (float)sin(M_PI/3.f)); + VECADDFAC(state_co,state_co,y_vec,-0.5f); - if(tco,state->co,state_co,shape); - } - else{ - VECCOPY(state->co,state_co); - } - } - break; + mul_v3_fl(y_vec, -amplitude * (float)cos(t + M_PI/3.f)); + mul_v3_fl(z_vec, amplitude/2.f * (float)cos(2.f*t + M_PI/6.f)); + } + else{ + mul_v3_v3fl(state_co, z_vec, -(float)sin(M_PI/3.f)); + madd_v3_v3fl(state_co, y_vec, -0.5f); + + mul_v3_fl(y_vec, amplitude * (float)-sin(t + M_PI/6.f)); + mul_v3_fl(z_vec, amplitude/2.f * (float)-sin(2.f*t + M_PI/3.f)); + } + + mul_v3_fl(state_co, amplitude); + add_v3_v3(state_co, par->co); + sub_v3_v3v3(par_vec, state->co, state_co); + + length = normalize_v3(par_vec); + mul_v3_fl(par_vec, MIN2(length, amplitude/2.f)); + + add_v3_v3v3(state_co, par->co, y_vec); + add_v3_v3(state_co, z_vec); + add_v3_v3(state_co, par_vec); + + shape = 2.f*(float)M_PI * (1.f+shape); + + if(tco, state->co, result, dt); + else + copy_v3_v3(state->co, result); } -static void do_clump(ParticleKey *state, ParticleKey *par, float time, float clumpfac, float clumppow, float pa_clump) +static float do_clump(ParticleKey *state, ParticleKey *par, float time, float clumpfac, float clumppow, float pa_clump) { + float clump = 0.f; + if(par && clumpfac!=0.0){ - float clump, cpow; + float cpow; if(clumppow<0.0) cpow=1.0f+clumppow; @@ -2010,8 +2050,11 @@ static void do_clump(ParticleKey *state, ParticleKey *par, float time, float clu clump = -clumpfac*pa_clump*(float)pow(1.0-(double)time,(double)cpow); else clump = clumpfac*pa_clump*(float)pow((double)time,(double)cpow); + interp_v3_v3v3(state->co,state->co,par->co,clump); } + + return clump; } void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) { @@ -2124,7 +2167,7 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) } par.co[0] = par.co[1] = par.co[2] = 0.0f; VECCOPY(key.co, vec_to_point); - do_prekink(&key, &par, 0, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, pd->kink, pd->kink_axis, 0); + do_kink(&key, &par, 0, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, 0.f, pd->kink, pd->kink_axis, 0, 0); do_clump(&key, &par, guidetime, pd->clump_fac, pd->clump_pow, 1.0f); VECCOPY(vec_to_point, key.co); @@ -2229,20 +2272,23 @@ static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *st return k; } } -static void offset_child(ChildParticle *cpa, ParticleKey *par, ParticleKey *child, float flat, float radius) +static void offset_child(ChildParticle *cpa, ParticleKey *par, float *par_rot, ParticleKey *child, float flat, float radius) { - VECCOPY(child->co,cpa->fuv); - mul_v3_fl(child->co,radius); + copy_v3_v3(child->co, cpa->fuv); + mul_v3_fl(child->co, radius); child->co[0]*=flat; - VECCOPY(child->vel,par->vel); - - mul_qt_v3(par->rot,child->co); + copy_v3_v3(child->vel, par->vel); - QUATCOPY(child->rot,par->rot); + if(par_rot) { + mul_qt_v3(par_rot, child->co); + copy_qt_qt(child->rot, par_rot); + } + else + unit_qt(child->rot); - VECADD(child->co,child->co,par->co); + add_v3_v3(child->co, par->co); } float *psys_cache_vgroup(DerivedMesh *dm, ParticleSystem *psys, int vgroup) { @@ -2372,12 +2418,9 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c if(totchild==0) return 0; /* init random number generator */ - if(ctx->sim.psys->part->flag & PART_ANIM_BRANCHING) - seed= 31415926 + ctx->sim.psys->seed + (int)cfra; - else - seed= 31415926 + ctx->sim.psys->seed; + seed= 31415926 + ctx->sim.psys->seed; - if(part->flag & PART_BRANCHING || ctx->editupdate || totchild < 10000) + if(ctx->editupdate || totchild < 10000) totthread= 1; for(i=0; ictx; Object *ob= ctx->sim.ob; @@ -2428,44 +2471,29 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle ParticleSettings *part = psys->part; ParticleCacheKey **cache= psys->childcache; ParticleCacheKey **pcache= psys_in_edit_mode(ctx->sim.scene, psys) ? psys->edit->pathcache : psys->pathcache; - ParticleCacheKey *state, *par = NULL, *key[4]; - ParticleData *pa=NULL; + ParticleCacheKey *child, *par = NULL, *key[4]; ParticleTexture ptex; - float *cpa_fuv=0, *par_rot=0; - float co[3], orco[3], ornor[3], hairmat[4][4], t, cpa_1st[3], dvec[3]; - float branch_begin, branch_end, branch_prob, rough_rand; + float *cpa_fuv=0, *par_rot=0, rot[4]; + float orco[3], ornor[3], hairmat[4][4], t, dvec[3], off1[4][3], off2[4][3]; float length, max_length = 1.0f, cur_length = 0.0f; - float eff_length, eff_vec[3]; - int k, cpa_num; + float eff_length, eff_vec[3], weight[4]; + int k, cpa_num, maxw=0; short cpa_from; if(!pcache) return; - if(part->flag & PART_BRANCHING) { - branch_begin=rng_getFloat(thread->rng_path); - branch_end=branch_begin+(1.0f-branch_begin)*rng_getFloat(thread->rng_path); - branch_prob=rng_getFloat(thread->rng_path); - rough_rand=rng_getFloat(thread->rng_path); - } - else { - branch_begin= 0.0f; - branch_end= 0.0f; - branch_prob= 0.0f; - rough_rand= 0.0f; - } - - if(itotpart){ - branch_begin=0.0f; - branch_end=1.0f; - branch_prob=0.0f; - } - if(ctx->between){ + ParticleData *pa = psys->particles + cpa->pa[0]; int w, needupdate; - float foffset; - - if(ctx->editupdate && !(part->flag & PART_BRANCHING)) { + float foffset, wsum=0.f; + float co[3]; + float p_min = part->parting_min; + float p_max = part->parting_max; + /* Virtual parents don't work nicely with parting. */ + float p_fac = part->parents > 0.f ? 0.f : part->parting_fac; + + if(ctx->editupdate) { needupdate= 0; w= 0; while(w<4 && cpa->pa[w]>=0) { @@ -2479,223 +2507,223 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if(!needupdate) return; else - memset(keys, 0, sizeof(*keys)*(ctx->steps+1)); + memset(child_keys, 0, sizeof(*child_keys)*(ctx->steps+1)); } /* get parent paths */ - w= 0; - while(w<4 && cpa->pa[w]>=0){ - key[w] = pcache[cpa->pa[w]]; - w++; + for(w=0; w<4; w++) { + if(cpa->pa[w] >= 0) { + key[w] = pcache[cpa->pa[w]]; + weight[w] = cpa->w[w]; + } + else { + key[w] = pcache[0]; + weight[w] = 0.f; + } + } + + /* modify weights to create parting */ + if(p_fac > 0.f) { + for(w=0; w<4; w++) { + if(w && weight[w] > 0.f) { + float d; + if(part->flag & PART_CHILD_LONG_HAIR) { + /* For long hair use tip distance/root distance as parting factor instead of root to tip angle. */ + float d1 = len_v3v3(key[0]->co, key[w]->co); + float d2 = len_v3v3((key[0]+key[0]->steps-1)->co, (key[w]+key[w]->steps-1)->co); + + d = d1 > 0.f ? d2/d1 - 1.f : 10000.f; + } + else { + float v1[3], v2[3]; + sub_v3_v3v3(v1, (key[0]+key[0]->steps-1)->co, key[0]->co); + sub_v3_v3v3(v2, (key[w]+key[w]->steps-1)->co, key[w]->co); + normalize_v3(v1); + normalize_v3(v2); + + d = saacos(dot_v3v3(v1, v2)) * 180.f / M_PI; + } + + if(p_max > p_min) + d = (d - p_min)/(p_max - p_min); + else + d = (d - p_min) <= 0.f ? 0.f : 1.f; + + CLAMP(d, 0.f, 1.f); + + if(d > 0.f) + weight[w] *= (1.f - d); + } + wsum += weight[w]; + } + for(w=0; w<4; w++) + weight[w] /= wsum; + + interp_v4_v4v4(weight, cpa->w, weight, p_fac); } /* get the original coordinates (orco) for texture usage */ cpa_num = cpa->num; - foffset= cpa->foffset; + foffset = cpa->foffset; cpa_fuv = cpa->fuv; cpa_from = PART_FROM_FACE; psys_particle_on_emitter(ctx->sim.psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa->fuv,foffset,co,ornor,0,0,orco,0); - if(part->path_start==0.0f) { - /* we need to save the actual root position of the child for positioning it accurately to the surface of the emitter */ - VECCOPY(cpa_1st,co); - mul_m4_v3(ob->obmat,cpa_1st); - } + mul_m4_v3(ob->obmat, co); - pa = psys->particles + cpa->pa[0]; + for(w=0; w<4; w++) + sub_v3_v3v3(off1[w], co, key[w]->co); psys_mat_hair_to_global(ob, ctx->sim.psmd->dm, psys->part->from, pa, hairmat); - - pa=0; } else{ - if(ctx->editupdate && !(part->flag & PART_BRANCHING)) { + ParticleData *pa = psys->particles + cpa->parent; + float co[3]; + if(ctx->editupdate) { if(!(psys->edit->points[cpa->parent].flag & PEP_EDIT_RECALC)) return; - memset(keys, 0, sizeof(*keys)*(ctx->steps+1)); + memset(child_keys, 0, sizeof(*child_keys)*(ctx->steps+1)); } /* get the parent path */ - key[0]=pcache[cpa->parent]; + key[0] = pcache[cpa->parent]; /* get the original coordinates (orco) for texture usage */ - pa=psys->particles+cpa->parent; - - cpa_from=part->from; - cpa_num=pa->num; - cpa_fuv=pa->fuv; + cpa_from = part->from; + cpa_num = pa->num; + cpa_fuv = pa->fuv; psys_particle_on_emitter(ctx->sim.psmd,cpa_from,cpa_num,DMCACHE_ISCHILD,cpa_fuv,pa->foffset,co,ornor,0,0,orco,0); psys_mat_hair_to_global(ob, ctx->sim.psmd->dm, psys->part->from, pa, hairmat); } - keys->steps = ctx->steps; - - /* correct child ipo timing */ -#if 0 // XXX old animation system - if((part->flag&PART_ABS_TIME)==0 && part->ipo){ - float dsta=part->end-part->sta; - calc_ipo(part->ipo, 100.0f*(ctx->cfra-(part->sta+dsta*cpa->rand[1]))/(part->lifetime*(1.0f - part->randlife*cpa->rand[0]))); - execute_ipo((ID *)part, part->ipo); - } -#endif // XXX old animation system + child_keys->steps = ctx->steps; /* get different child parameters from textures & vgroups */ get_child_modifier_parameters(part, ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex); if(ptex.exist < PSYS_FRAND(i + 24)) { - keys->steps = -1; + child_keys->steps = -1; return; } /* create the child path */ - for(k=0,state=keys; k<=ctx->steps; k++,state++){ + for(k=0,child=child_keys; k<=ctx->steps; k++,child++){ if(ctx->between){ int w=0; - state->co[0] = state->co[1] = state->co[2] = 0.0f; - state->vel[0] = state->vel[1] = state->vel[2] = 0.0f; - state->rot[0] = state->rot[1] = state->rot[2] = state->rot[3] = 0.0f; + zero_v3(child->co); + zero_v3(child->vel); + unit_qt(child->rot); - //QUATCOPY(state->rot,key[0]->rot); + for(w=0; w<4; w++) { + copy_v3_v3(off2[w], off1[w]); - /* child position is the weighted sum of parent positions */ - while(w<4 && cpa->pa[w]>=0){ - state->co[0] += cpa->w[w] * key[w]->co[0]; - state->co[1] += cpa->w[w] * key[w]->co[1]; - state->co[2] += cpa->w[w] * key[w]->co[2]; - - state->vel[0] += cpa->w[w] * key[w]->vel[0]; - state->vel[1] += cpa->w[w] * key[w]->vel[1]; - state->vel[2] += cpa->w[w] * key[w]->vel[2]; - key[w]++; - w++; - } - if(part->path_start==0.0f) { - if(k==0){ - /* calculate the offset between actual child root position and first position interpolated from parents */ - VECSUB(cpa_1st,cpa_1st,state->co); + if(part->flag & PART_CHILD_LONG_HAIR) { + /* Use parent rotation (in addition to emission location) to determine child offset. */ + if(k) + mul_qt_v3((key[w]+k)->rot, off2[w]); + + /* Fade the effect of rotation for even lengths in the end */ + project_v3_v3v3(dvec, off2[w], (key[w]+k)->vel); + madd_v3_v3fl(off2[w], dvec, -(float)k/(float)ctx->steps); } - /* apply offset for correct positioning */ - VECADD(state->co,state->co,cpa_1st); + + add_v3_v3(off2[w], (key[w]+k)->co); } + + /* child position is the weighted sum of parent positions */ + interp_v3_v3v3v3v3(child->co, off2[0], off2[1], off2[2], off2[3], weight); + interp_v3_v3v3v3v3(child->vel, (key[0]+k)->vel, (key[1]+k)->vel, (key[2]+k)->vel, (key[3]+k)->vel, weight); + + copy_qt_qt(child->rot, (key[0]+k)->rot); } else{ + if(k) { + mul_qt_qtqt(rot, (key[0]+k)->rot, key[0]->rot); + par_rot = rot; + } + else { + par_rot = key[0]->rot; + } /* offset the child from the parent position */ - offset_child(cpa, (ParticleKey*)key[0], (ParticleKey*)state, part->childflat, part->childrad); - - key[0]++; + offset_child(cpa, (ParticleKey*)(key[0]+k), par_rot, (ParticleKey*)child, part->childflat, part->childrad); } } /* apply effectors */ if(part->flag & PART_CHILD_EFFECT) { - for(k=0,state=keys; k<=ctx->steps; k++,state++) { + for(k=0,child=child_keys; k<=ctx->steps; k++,child++) { if(k) { - do_path_effectors(&ctx->sim, cpa->pa[0], state, k, ctx->steps, keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec); + do_path_effectors(&ctx->sim, cpa->pa[0], child, k, ctx->steps, child_keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec); } else { - sub_v3_v3v3(eff_vec,(state+1)->co,state->co); - eff_length= len_v3(eff_vec); + sub_v3_v3v3(eff_vec, (child+1)->co, child->co); + eff_length = len_v3(eff_vec); } } } - for(k=0,state=keys; k<=ctx->steps; k++,state++){ - t=(float)k/(float)ctx->steps; + for(k=0,child=child_keys; k<=ctx->steps; k++,child++){ + t = (float)k/(float)ctx->steps; + + if(ctx->totparent) + /* this is now threadsafe, virtual parents are calculated before rest of children */ + par = (i >= ctx->totparent) ? cache[cpa->parent] : NULL; + else if(cpa->parent >= 0) + par = pcache[cpa->parent]; - if(ctx->totparent){ - if(i>=ctx->totparent) { - /* this is now threadsafe, virtual parents are calculated before rest of children */ - par = cache[cpa->parent] + k; + if(par) { + if(k) { + mul_qt_qtqt(rot, (par+k)->rot, par->rot); + par_rot = rot; } - else - par=0; - } - else if(cpa->parent>=0){ - par=pcache[cpa->parent]+k; - par_rot = par->rot; + else { + par_rot = par->rot; + } + par += k; } /* apply different deformations to the child path */ - do_child_modifiers(&ctx->sim, &ptex, (ParticleKey *)par, par_rot, cpa, orco, hairmat, (ParticleKey *)state, t); - - /* TODO: better branching */ - //if(part->flag & PART_BRANCHING && ctx->between == 0 && part->flag & PART_ANIM_BRANCHING) - // rough_t = t * rough_rand; - //else - // rough_t = t; - - /* TODO: better branching */ - //if(part->flag & PART_BRANCHING && ctx->between==0){ - // if(branch_prob > part->branch_thres){ - // branchfac=0.0f; - // } - // else{ - // if(part->flag & PART_SYMM_BRANCHING){ - // if(t < branch_begin || t > branch_end) - // branchfac=0.0f; - // else{ - // if((t-branch_begin)/(branch_end-branch_begin)<0.5) - // branchfac=2.0f*(t-branch_begin)/(branch_end-branch_begin); - // else - // branchfac=2.0f*(branch_end-t)/(branch_end-branch_begin); - - // CLAMP(branchfac,0.0f,1.0f); - // } - // } - // else{ - // if(t < branch_begin){ - // branchfac=0.0f; - // } - // else{ - // branchfac=(t-branch_begin)/((1.0f-branch_begin)*0.5f); - // CLAMP(branchfac,0.0f,1.0f); - // } - // } - // } - - // if(itotpart) - // interp_v3_v3v3(state->co, (pcache[i] + k)->co, state->co, branchfac); - // else - // /* this is not threadsafe, but should only happen for - // * branching particles particles, which are not threaded */ - // interp_v3_v3v3(state->co, (cache[i - psys->totpart] + k)->co, state->co, branchfac); - //} + do_child_modifiers(&ctx->sim, &ptex, (ParticleKey *)par, par_rot, cpa, orco, hairmat, (ParticleKey *)child, t); /* we have to correct velocity because of kink & clump */ if(k>1){ - VECSUB((state-1)->vel,state->co,(state-2)->co); - mul_v3_fl((state-1)->vel,0.5); + sub_v3_v3v3((child-1)->vel, child->co, (child-2)->co); + mul_v3_fl((child-1)->vel, 0.5); if(ctx->ma && (part->draw & PART_DRAW_MAT_COL)) - get_strand_normal(ctx->ma, ornor, cur_length, (state-1)->vel); + get_strand_normal(ctx->ma, ornor, cur_length, (child-1)->vel); } if(k == ctx->steps) - VECSUB(state->vel,state->co,(state-1)->co); + sub_v3_v3v3(child->vel, child->co, (child-1)->co); /* check if path needs to be cut before actual end of data points */ if(k){ - VECSUB(dvec,state->co,(state-1)->co); - length=1.0f/(float)ctx->steps; - k=check_path_length(k,keys,state,max_length,&cur_length,length,dvec); + sub_v3_v3v3(dvec, child->co, (child-1)->co); + length = 1.0f/(float)ctx->steps; + k = check_path_length(k, child_keys, child, max_length, &cur_length, length, dvec); } else{ /* initialize length calculation */ - max_length= ptex.length; - cur_length= 0.0f; + max_length = ptex.length; + cur_length = 0.0f; } if(ctx->ma && (part->draw & PART_DRAW_MAT_COL)) { - VECCOPY(state->col, &ctx->ma->r) - get_strand_normal(ctx->ma, ornor, cur_length, state->vel); + VECCOPY(child->col, &ctx->ma->r) + get_strand_normal(ctx->ma, ornor, cur_length, child->vel); } } + + /* Hide virtual parents */ + if(i < ctx->totparent) + child_keys->steps = -1; } static void *exec_child_path_cache(void *data) @@ -2742,7 +2770,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd totchild= ctx->totchild; totparent= ctx->totparent; - if(editupdate && sim->psys->childcache && !(part->flag & PART_BRANCHING) && totchild == sim->psys->totchildcache) { + if(editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) { cache = sim->psys->childcache; } else { @@ -2783,6 +2811,43 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd psys_threads_free(pthreads); } +/* figure out incremental rotations along path starting from unit quat */ +static void cache_key_incremental_rotation(ParticleCacheKey *key0, ParticleCacheKey *key1, ParticleCacheKey *key2, float *prev_tangent, int i) +{ + float cosangle, angle, tangent[3], normal[3], q[4]; + + switch(i) { + case 0: + /* start from second key */ + break; + case 1: + /* calculate initial tangent for incremental rotations */ + sub_v3_v3v3(prev_tangent, key0->co, key1->co); + normalize_v3(prev_tangent); + unit_qt(key1->rot); + break; + default: + sub_v3_v3v3(tangent, key0->co, key1->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(key1->rot, key2->rot); + } + else { + angle= saacos(cosangle); + cross_v3_v3v3(normal, prev_tangent, tangent); + axis_angle_to_quat( q,normal, angle); + mul_qt_qtqt(key1->rot, q, key2->rot); + } + + copy_v3_v3(prev_tangent, tangent); + } +} /* Calculates paths ready for drawing/rendering. */ /* -Usefull for making use of opengl vertex arrays for super fast strand drawing. */ /* -Makes child strands possible and creates them too into the cache. */ @@ -2895,22 +2960,19 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /*--interpolate actual path from data points--*/ for(k=0, ca=cache[p]; k<=steps; k++, ca++){ time = (float)k / (float)steps; - t = birthtime + time * (dietime - birthtime); - result.time = -t; - do_particle_interpolation(psys, p, pa, t, frs_sec, &pind, &result); + copy_v3_v3(ca->co, result.co); /* dynamic hair is in object space */ /* keyed and baked are already in global space */ if(hair_dm) - mul_m4_v3(sim->ob->obmat, result.co); + mul_m4_v3(sim->ob->obmat, ca->co); else if(!keyed && !baked && !(psys->flag & PSYS_GLOBAL_HAIR)) - mul_m4_v3(hairmat, result.co); + mul_m4_v3(hairmat, ca->co); - VECCOPY(ca->co, result.co); - VECCOPY(ca->col, col); + copy_v3_v3(ca->col, col); } /*--modify paths and calculate rotation & velocity--*/ @@ -2945,54 +3007,25 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /* 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); - normalize_v3_v3(prev_tangent, 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); - } - - VECCOPY(prev_tangent, tangent); - } + cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k); if(k == steps) - QUATCOPY(ca->rot, (ca - 1)->rot); - + copy_qt_qt(ca->rot, (ca - 1)->rot); /* set velocity */ - VECSUB(ca->vel, ca->co, (ca-1)->co); + sub_v3_v3v3(ca->vel, ca->co, (ca-1)->co); if(k==1) - VECCOPY((ca-1)->vel, ca->vel); + copy_v3_v3((ca-1)->vel, ca->vel); } + /* 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(cache[p]->rot, rotmat); } psys->totcached = totpart; @@ -3047,12 +3080,8 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; - if(pset->brushtype == PE_BRUSH_WEIGHT){ - /* use weight painting colors now... */ -#if 0 - sel_col[0] = sel_col[1] = sel_col[2] = 1.0f; - nosel_col[0] = nosel_col[1] = nosel_col[2] = 0.0f; -#endif + if(pset->brushtype == PE_BRUSH_WEIGHT) { + ;/* use weight painting colors now... */ } else{ sel_col[0] = (float)edit->sel_col[0] / 255.0f; @@ -3093,9 +3122,9 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf if(psys) { psys_mat_hair_to_global(ob, psmd->dm, psys->part->from, pa, hairmat); - VECCOPY(rotmat[0], hairmat[2]); - VECCOPY(rotmat[1], hairmat[1]); - VECCOPY(rotmat[2], hairmat[0]); + copy_v3_v3(rotmat[0], hairmat[2]); + copy_v3_v3(rotmat[1], hairmat[1]); + copy_v3_v3(rotmat[2], hairmat[0]); } birthtime = pind.birthtime; @@ -3109,66 +3138,32 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /*--interpolate actual path from data points--*/ for(k=0, ca=cache[i]; k<=steps; k++, ca++){ time = (float)k / (float)steps; - t = birthtime + time * (dietime - birthtime); - result.time = -t; - do_particle_interpolation(psys, i, pa, t, frs_sec, &pind, &result); + copy_v3_v3(ca->co, result.co); /* non-hair points are already in global space */ if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { - mul_m4_v3(hairmat, result.co); + mul_m4_v3(hairmat, ca->co); - /* create rotations for proper creation of children */ 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); - normalize_v3_v3(prev_tangent, 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); - } - - VECCOPY(prev_tangent, tangent); - } + cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k); if(k == steps) - QUATCOPY(ca->rot, (ca - 1)->rot); - } + copy_qt_qt(ca->rot, (ca - 1)->rot); - } + /* set velocity */ + sub_v3_v3v3(ca->vel, ca->co, (ca - 1)->co); - VECCOPY(ca->co, result.co); - - ca->vel[0] = ca->vel[1] = 0.0f; - ca->vel[1] = 1.0f; + if(k==1) + copy_v3_v3((ca - 1)->vel, ca->vel); + } + } + else { + ca->vel[0] = ca->vel[1] = 0.0f; + ca->vel[1] = 1.0f; + } /* selection coloring in edit mode */ if(pset->brushtype==PE_BRUSH_WEIGHT){ @@ -3216,6 +3211,16 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf ca->time = t; } + if(psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { + /* 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(cache[i]->rot, rotmat); + } } edit->totcached = totpart; @@ -3492,6 +3497,7 @@ static void default_particle_settings(ParticleSettings *part) part->adapt_angle= 5; part->adapt_pix= 3; part->kink_axis= 2; + part->kink_amp_clump= 1.f; part->reactevent= PART_EVENT_DEATH; part->disp=100; part->from= PART_FROM_FACE; @@ -3921,11 +3927,15 @@ static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *pte guided = do_guides(sim->psys->effectors, (ParticleKey*)state, cpa->parent, t); if(guided==0){ - if(kink_freq > 0.f) - do_prekink(state, par, par_rot, t, kink_freq, part->kink_shape, - part->kink_amp, part->kink, part->kink_axis, sim->ob->obmat); - - do_clump(state, par, t, part->clumpfac, part->clumppow, ptex ? ptex->clump : 1.f); + float clump = do_clump(state, par, t, part->clumpfac, part->clumppow, ptex ? ptex->clump : 1.f); + + if(kink_freq != 0.f) { + float kink_amp = part->kink_amp * (1.f - part->kink_amp_clump * clump); + + do_kink(state, par, par_rot, t, kink_freq, part->kink_shape, + kink_amp, part->kink_flat, part->kink, part->kink_axis, + sim->ob->obmat, sim->psys->part->childtype == PART_CHILD_FACES); + } } if(rough1 > 0.f) @@ -4114,7 +4124,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * } else{ /* offset the child from the parent position */ - offset_child(cpa, keys, state, part->childflat, part->childrad); + offset_child(cpa, keys, keys->rot, state, part->childflat, part->childrad); } par = keys; @@ -4212,7 +4222,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta float t = (cfra - pa->time) / pa->lifetime; key1=&pa->state; - offset_child(cpa, key1, state, part->childflat, part->childrad); + offset_child(cpa, key1, key1->rot, state, part->childflat, part->childrad); CLAMP(t,0.0,1.0); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 08fe931693e..71cb3128506 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -654,7 +654,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData DerivedMesh *dm= ctx->dm; ParticleData *tpa; /* ParticleSettings *part= ctx->sim.psys->part; */ - float *v1, *v2, *v3, *v4, nor[3], orco1[3], co1[3], co2[3], nor1[3], ornor1[3]; + float *v1, *v2, *v3, *v4, nor[3], orco1[3], co1[3], co2[3], nor1[3]; float cur_d, min_d, randu, randv; int from= ctx->from; int cfrom= ctx->cfrom; @@ -795,12 +795,9 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData int parent[10]; float pweight[10]; - /*do_seams= (part->flag&PART_CHILD_SEAMS && ctx->seams);*/ - - psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,0,0,orco1,ornor1); + psys_particle_on_dm(dm,cfrom,cpa->num,DMCACHE_ISCHILD,cpa->fuv,cpa->foffset,co1,nor1,NULL,NULL,orco1,NULL); transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1); - //maxw = BLI_kdtree_find_n_nearest(ctx->tree,(do_seams)?10:4,orco1,ornor1,ptn); - maxw = BLI_kdtree_find_n_nearest(ctx->tree,4,orco1,ornor1,ptn); + maxw = BLI_kdtree_find_n_nearest(ctx->tree,4,orco1,NULL,ptn); maxd=ptn[maxw-1].dist; mind=ptn[0].dist; @@ -815,63 +812,6 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData parent[w]=-1; pweight[w]=0.0f; } - //if(do_seams){ - // ParticleSeam *seam=ctx->seams; - // float temp[3],temp2[3],tan[3]; - // float inp,cur_len,min_len=10000.0f; - // int min_seam=0, near_vert=0; - // /* find closest seam */ - // for(i=0; itotseam; i++, seam++){ - // sub_v3_v3v3(temp,co1,seam->v0); - // inp=dot_v3v3(temp,seam->dir)/seam->length2; - // if(inp<0.0f){ - // cur_len=len_v3v3(co1,seam->v0); - // } - // else if(inp>1.0f){ - // cur_len=len_v3v3(co1,seam->v1); - // } - // else{ - // copy_v3_v3(temp2,seam->dir); - // mul_v3_fl(temp2,inp); - // cur_len=len_v3v3(temp,temp2); - // } - // if(cur_len1.0f) near_vert=1; - // else near_vert=0; - // } - // } - // seam=ctx->seams+min_seam; - // - // copy_v3_v3(temp,seam->v0); - // - // if(near_vert){ - // if(near_vert==-1) - // sub_v3_v3v3(tan,co1,seam->v0); - // else{ - // sub_v3_v3v3(tan,co1,seam->v1); - // copy_v3_v3(temp,seam->v1); - // } - - // normalize_v3(tan); - // } - // else{ - // copy_v3_v3(tan,seam->tan); - // sub_v3_v3v3(temp2,co1,temp); - // if(dot_v3v3(tan,temp2)<0.0f) - // negate_v3(tan); - // } - // for(w=0; w=0){ @@ -1007,6 +947,8 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, if(from==PART_FROM_CHILD){ distr=PART_DISTR_RAND; + BLI_srandom(31415926 + psys->seed + psys->child_seed); + if(part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){ dm= finaldm; children=1; @@ -1023,50 +965,6 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, totpart=get_psys_tot_child(scene, psys); cfrom=from=PART_FROM_FACE; - - //if(part->flag&PART_CHILD_SEAMS){ - // MEdge *ed, *medge=dm->getEdgeDataArray(dm,CD_MEDGE); - // MVert *mvert=dm->getVertDataArray(dm,CD_MVERT); - // int totedge=dm->getNumEdges(dm); - - // for(p=0, ed=medge; pflag&ME_SEAM) - // totseam++; - - // if(totseam){ - // ParticleSeam *cur_seam=seams=MEM_callocN(totseam*sizeof(ParticleSeam),"Child Distribution Seams"); - // float temp[3],temp2[3]; - - // for(p=0, ed=medge; pflag&ME_SEAM){ - // copy_v3_v3(cur_seam->v0,(mvert+ed->v1)->co); - // copy_v3_v3(cur_seam->v1,(mvert+ed->v2)->co); - - // sub_v3_v3v3(cur_seam->dir,cur_seam->v1,cur_seam->v0); - - // cur_seam->length2=len_v3(cur_seam->dir); - // cur_seam->length2*=cur_seam->length2; - - // temp[0]=(float)((mvert+ed->v1)->no[0]); - // temp[1]=(float)((mvert+ed->v1)->no[1]); - // temp[2]=(float)((mvert+ed->v1)->no[2]); - // temp2[0]=(float)((mvert+ed->v2)->no[0]); - // temp2[1]=(float)((mvert+ed->v2)->no[1]); - // temp2[2]=(float)((mvert+ed->v2)->no[2]); - - // add_v3_v3v3(cur_seam->nor,temp,temp2); - // normalize_v3(cur_seam->nor); - - // cross_v3_v3v3(cur_seam->tan,cur_seam->dir,cur_seam->nor); - - // normalize_v3(cur_seam->tan); - - // cur_seam++; - // } - // } - // } - // - //} } else{ /* no need to figure out distribution */ diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 4d96f0508d1..9ad00247dc2 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2252,17 +2252,18 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) } for(psys=ob->particlesystem.first; psys; psys=psys->next) { - /* Baked cloth hair has to be checked first, because we don't want to reset */ + /* children or just redo can be calculated without reseting anything */ + if(psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD) + skip = 1; + /* Baked cloth hair has to be checked too, because we don't want to reset */ /* particles or cloth in that case -jahka */ - if(psys->clmd) { + else if(psys->clmd) { BKE_ptcache_id_from_cloth(&pid, ob, psys->clmd); if(mode == PSYS_RESET_ALL || !(psys->part->type == PART_HAIR && (pid.cache->flag & PTCACHE_BAKED))) reset |= BKE_ptcache_id_reset(scene, &pid, mode); else skip = 1; } - else if(psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD) - skip = 1; if(skip == 0 && psys->part) { BKE_ptcache_id_from_particles(&pid, ob, psys); -- cgit v1.2.3 From 3c6077e8ec59a2d2c74cf87ec1b54a5e168e7aa6 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 7 Jan 2011 11:38:28 +0000 Subject: Bug fix: particle point cache was reset on start frame if particles had grid distribution even if there were no changes. --- source/blender/blenkernel/intern/particle_system.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (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 71cb3128506..207a9b8f839 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -130,6 +130,16 @@ int psys_get_current_display_percentage(ParticleSystem *psys) return psys->part->disp; } +static int tot_particles(ParticleSystem *psys, PTCacheID *pid) +{ + if(pid && psys->pointcache->flag & PTCACHE_EXTERNAL) + return pid->cache->totpoint; + else if(psys->part->distr == PART_DISTR_GRID && psys->part->from != PART_FROM_VERT) + return psys->part->grid_res * psys->part->grid_res * psys->part->grid_res; + else + return psys->part->totpart; +} + void psys_reset(ParticleSystem *psys, int mode) { PARTICLE_P; @@ -137,7 +147,7 @@ void psys_reset(ParticleSystem *psys, int mode) if(ELEM(mode, PSYS_RESET_ALL, PSYS_RESET_DEPSGRAPH)) { if(mode == PSYS_RESET_ALL || !(psys->flag & PSYS_EDITED)) { /* don't free if not absolutely necessary */ - if(psys->totpart != psys->part->totpart) { + if(psys->totpart != tot_particles(psys, NULL)) { psys_free_particles(psys); psys->totpart= 0; } @@ -3633,14 +3643,7 @@ static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float UNU ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; int oldtotpart = psys->totpart; - int totpart = oldtotpart; - - if(pid && psys->pointcache->flag & PTCACHE_EXTERNAL) - totpart = pid->cache->totpoint; - else if(part->distr == PART_DISTR_GRID && part->from != PART_FROM_VERT) - totpart = part->grid_res*part->grid_res*part->grid_res; - else - totpart = psys->part->totpart; + int totpart = tot_particles(psys, pid); if(totpart != oldtotpart) realloc_particles(sim, totpart); -- cgit v1.2.3 From c8e0ca44a3c5d49be01f90a49b98a9ee8f875d36 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 7 Jan 2011 14:42:01 +0000 Subject: Improved bump mapping patch by M.G. Kishalmi (lmg) and M.S. Mikkelsen (sparky). Many thanks to them! For comparison, see here: http://kishalmi.servus.at/3D/bumpcode/ Based on algorithm in: Mikkelsen M. S.: Simulation of Wrinkled Surfaces Revisited. http://jbit.net/~sparky/sfgrad_bump/mm_sfgrad_bump.pdf This fixes bugs: #24591: Artefacts/strange normal mapping when anti-aliasing is on #24735: Error at the Normal function. #24962: Normals are not calculated correctly if anti-aliasing is off #25103: Weird artefacts in Normal This will break render compatibility a bit, but fixing this bugs would have also done that, so in this case it should be acceptable. Patch committed with these modifications: * Bump method Old/3-Tap/5-Tap option in UI, 3-Tap is default * Only compute normal perturbation vectors when needed * Fix some middle of block variable definitions for MSVC --- source/blender/blenkernel/intern/material.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 2d123302c3d..c8fb921285c 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -816,10 +816,10 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) ma->texco |= mtex->texco; ma->mapto |= mtex->mapto; - if(r_mode & R_OSA) { - if ELEM3(mtex->tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP) ma->texco |= TEXCO_OSA; - else if(mtex->texflag & MTEX_NEW_BUMP) ma->texco |= TEXCO_OSA; // NEWBUMP: need texture derivatives for procedurals as well - } + + /* always get derivatives for these textures */ + if ELEM3(mtex->tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP) ma->texco |= TEXCO_OSA; + else if(mtex->texflag & MTEX_NEW_BUMP) ma->texco |= TEXCO_OSA; if(ma->texco & (TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM|TEXCO_STRAND|TEXCO_STRESS)) needuv= 1; else if(ma->texco & (TEXCO_GLOB|TEXCO_UV|TEXCO_OBJECT|TEXCO_SPEED)) needuv= 1; -- cgit v1.2.3 From 8f21a43535cb200c0569566a1b012aec883aa53c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 Jan 2011 18:36:47 +0000 Subject: split BKE_utildefines.h, now it only has blender specific defines like GS() MAKE_ID, FILE_MAXDIR, moved the generic defines to BLI_utildefines.h. no functional changes. --- source/blender/blenkernel/intern/BME_conversions.c | 4 +++- source/blender/blenkernel/intern/BME_eulers.c | 2 +- source/blender/blenkernel/intern/BME_structure.c | 3 ++- source/blender/blenkernel/intern/BME_tools.c | 4 +++- source/blender/blenkernel/intern/DerivedMesh.c | 1 + source/blender/blenkernel/intern/action.c | 9 +++++---- source/blender/blenkernel/intern/anim.c | 1 + source/blender/blenkernel/intern/anim_sys.c | 3 ++- source/blender/blenkernel/intern/armature.c | 1 + source/blender/blenkernel/intern/blender.c | 1 + source/blender/blenkernel/intern/boids.c | 2 ++ source/blender/blenkernel/intern/brush.c | 1 + source/blender/blenkernel/intern/bvhutils.c | 4 +++- source/blender/blenkernel/intern/cdderivedmesh.c | 13 +++++++------ source/blender/blenkernel/intern/cloth.c | 1 + source/blender/blenkernel/intern/collision.c | 1 + source/blender/blenkernel/intern/colortools.c | 7 ++++--- source/blender/blenkernel/intern/constraint.c | 1 + source/blender/blenkernel/intern/curve.c | 2 ++ source/blender/blenkernel/intern/customdata.c | 1 + source/blender/blenkernel/intern/customdata_file.c | 1 + source/blender/blenkernel/intern/depsgraph.c | 9 +++++---- source/blender/blenkernel/intern/displist.c | 2 +- source/blender/blenkernel/intern/effect.c | 1 + source/blender/blenkernel/intern/exotic.c | 3 ++- source/blender/blenkernel/intern/fcurve.c | 1 + source/blender/blenkernel/intern/fluidsim.c | 1 + source/blender/blenkernel/intern/fmodifier.c | 1 + source/blender/blenkernel/intern/font.c | 3 +-- source/blender/blenkernel/intern/gpencil.c | 2 +- source/blender/blenkernel/intern/group.c | 1 + source/blender/blenkernel/intern/icons.c | 1 + source/blender/blenkernel/intern/image.c | 1 + source/blender/blenkernel/intern/implicit.c | 1 + source/blender/blenkernel/intern/ipo.c | 1 + source/blender/blenkernel/intern/key.c | 1 + source/blender/blenkernel/intern/lattice.c | 1 + source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/material.c | 1 + source/blender/blenkernel/intern/mball.c | 1 + source/blender/blenkernel/intern/mesh.c | 12 ++++++------ source/blender/blenkernel/intern/modifier.c | 4 +++- source/blender/blenkernel/intern/multires.c | 1 + source/blender/blenkernel/intern/nla.c | 1 + source/blender/blenkernel/intern/object.c | 1 + source/blender/blenkernel/intern/packedFile.c | 1 + source/blender/blenkernel/intern/paint.c | 2 ++ source/blender/blenkernel/intern/particle.c | 6 +++--- source/blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 1 + source/blender/blenkernel/intern/report.c | 1 + source/blender/blenkernel/intern/scene.c | 9 +++++---- source/blender/blenkernel/intern/seqcache.c | 1 + source/blender/blenkernel/intern/seqeffects.c | 1 + source/blender/blenkernel/intern/sequencer.c | 14 ++++++++------ source/blender/blenkernel/intern/shrinkwrap.c | 8 ++++---- source/blender/blenkernel/intern/sketch.c | 1 + source/blender/blenkernel/intern/smoke.c | 1 + source/blender/blenkernel/intern/softbody.c | 1 + source/blender/blenkernel/intern/subsurf_ccg.c | 13 +++++++------ source/blender/blenkernel/intern/text.c | 1 + source/blender/blenkernel/intern/texture.c | 3 +-- source/blender/blenkernel/intern/writeavi.c | 1 + source/blender/blenkernel/intern/writeframeserver.c | 2 ++ 64 files changed, 123 insertions(+), 62 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 341eb38b388..e80d4827155 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -38,10 +38,12 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_edgehash.h" +#include "BLI_utildefines.h" + #include "BKE_mesh.h" #include "BKE_cdderivedmesh.h" -#include "BLI_edgehash.h" //XXX #include "BIF_editmesh.h" //XXX #include "editmesh.h" #include "bmesh_private.h" diff --git a/source/blender/blenkernel/intern/BME_eulers.c b/source/blender/blenkernel/intern/BME_eulers.c index 036cd4a23e2..cd9429982dc 100644 --- a/source/blender/blenkernel/intern/BME_eulers.c +++ b/source/blender/blenkernel/intern/BME_eulers.c @@ -33,7 +33,7 @@ */ #include "MEM_guardedalloc.h" - +#include "BLI_utildefines.h" #include "bmesh_private.h" diff --git a/source/blender/blenkernel/intern/BME_structure.c b/source/blender/blenkernel/intern/BME_structure.c index de3eb94beac..9463d22e3be 100644 --- a/source/blender/blenkernel/intern/BME_structure.c +++ b/source/blender/blenkernel/intern/BME_structure.c @@ -33,8 +33,9 @@ */ #include -#include "MEM_guardedalloc.h" +#include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BKE_bmesh.h" /** * MISC utility functions. diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index 444bc10d562..0c8352ad8b0 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -38,8 +38,10 @@ #include "DNA_meshdata_types.h" #include "DNA_object_types.h" -#include "BKE_bmesh.h" #include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_bmesh.h" /*split this all into a seperate bevel.c file in src*/ diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 3d87b77dec9..3b8da3975a0 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -43,6 +43,7 @@ #include "BLI_math.h" #include "BLI_memarena.h" #include "BLI_pbvh.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_displist.h" diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index fdd51dd207f..bd36e1b2720 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -39,6 +39,11 @@ #include "DNA_scene_types.h" #include "DNA_object_types.h" +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" +#include "BLI_ghash.h" + #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_anim.h" @@ -53,10 +58,6 @@ #include "BIK_api.h" -#include "BLI_blenlib.h" -#include "BLI_ghash.h" -#include "BLI_math.h" - #include "RNA_access.h" /* *********************** NOTE ON POSE AND ACTION ********************** diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index c372855b3eb..8cac3860e79 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -39,6 +39,7 @@ #include "BLI_editVert.h" #include "BLI_math.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index abe5b50664f..e46c1179111 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -36,8 +36,8 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" -#include "BKE_library.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_material_types.h" @@ -50,6 +50,7 @@ #include "BKE_nla.h" #include "BKE_global.h" #include "BKE_main.h" +#include "BKE_library.h" #include "BKE_utildefines.h" #include "RNA_access.h" diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 6b21e45ddd9..0367d854169 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -36,6 +36,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_armature_types.h" diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index b218632e8e5..7d75912f31d 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -58,6 +58,7 @@ #include "BLI_bpath.h" #include "BLI_dynstr.h" #include "BLI_path_util.h" +#include "BLI_utildefines.h" #include "IMB_imbuf.h" diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 1bde0639055..85ee3760849 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -41,6 +41,8 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_kdtree.h" +#include "BLI_utildefines.h" + #include "BKE_collision.h" #include "BKE_effect.h" #include "BKE_boids.h" diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 649b3e3ad9b..a78d2ecaaa2 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -45,6 +45,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "BKE_brush.h" #include "BKE_colortools.h" diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 882295b931c..0d3825fa8a8 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -34,9 +34,11 @@ #include "DNA_meshdata_types.h" +#include "BLI_editVert.h" +#include "BLI_utildefines.h" + #include "BKE_DerivedMesh.h" #include "BKE_utildefines.h" -#include "BLI_editVert.h" #include "BLI_math.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index efdfdbc986f..956972e8d5b 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -36,17 +36,18 @@ #include #include "BIF_gl.h" -#include "BKE_cdderivedmesh.h" -#include "BKE_global.h" -#include "BKE_mesh.h" -#include "BKE_paint.h" -#include "BKE_utildefines.h" - #include "BLI_blenlib.h" #include "BLI_edgehash.h" #include "BLI_editVert.h" #include "BLI_math.h" #include "BLI_pbvh.h" +#include "BLI_utildefines.h" + +#include "BKE_cdderivedmesh.h" +#include "BKE_global.h" +#include "BKE_mesh.h" +#include "BKE_paint.h" +#include "BKE_utildefines.h" #include "DNA_meshdata_types.h" #include "DNA_object_types.h" diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index b283120249e..4b14e64ee27 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -34,6 +34,7 @@ #include "BLI_math.h" #include "BLI_edgehash.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_cloth.h" diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index b2d587151b1..8f028914ece 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -42,6 +42,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_edgehash.h" +#include "BLI_utildefines.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 1b3d100c3f8..282a055e04c 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -41,14 +41,15 @@ #include "DNA_color_types.h" #include "DNA_curve_types.h" +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + #include "BKE_colortools.h" #include "BKE_curve.h" #include "BKE_fcurve.h" #include "BKE_utildefines.h" -#include "BLI_blenlib.h" -#include "BLI_math.h" - #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index b6e68a71bc9..ad6b3b8f837 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -39,6 +39,7 @@ #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 6dd3eb43e29..b5550768e55 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -35,8 +35,10 @@ #include #include "MEM_guardedalloc.h" + #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_curve_types.h" #include "DNA_material_types.h" diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index f7606a344c9..134b0e10280 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -46,6 +46,7 @@ #include "BLI_linklist.h" #include "BLI_math.h" #include "BLI_mempool.h" +#include "BLI_utildefines.h" #include "BKE_customdata.h" #include "BKE_customdata_file.h" diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index 5954ac1b022..ebc21344810 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -28,6 +28,7 @@ #include "BLI_fileops.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_customdata_file.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 5fdb8f0206a..61865f5579c 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -29,7 +29,11 @@ #include #include +#include "MEM_guardedalloc.h" + #include "BLI_winstuff.h" +#include "BLI_utildefines.h" +#include "BLI_ghash.h" #include "DNA_anim_types.h" #include "DNA_camera_types.h" @@ -41,10 +45,6 @@ #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" -#include "MEM_guardedalloc.h" - -#include "BLI_ghash.h" - #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_effect.h" @@ -61,6 +61,7 @@ #include "BKE_pointcache.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_utildefines.h" #include "depsgraph_private.h" diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 8c32733dd66..53e33ee9bd8 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -35,7 +35,6 @@ #include "MEM_guardedalloc.h" - #include "DNA_curve_types.h" #include "DNA_meshdata_types.h" #include "DNA_scene_types.h" @@ -46,6 +45,7 @@ #include "BLI_math.h" #include "BLI_editVert.h" #include "BLI_scanfill.h" +#include "BLI_utildefines.h" #include "BKE_global.h" #include "BKE_displist.h" diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 51f2203b525..aeec2a588c7 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -59,6 +59,7 @@ #include "BLI_listbase.h" #include "BLI_noise.h" #include "BLI_rand.h" +#include "BLI_utildefines.h" #include "PIL_time.h" diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index d19226b2478..612ea84abe5 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -61,11 +61,12 @@ #include "DNA_camera_types.h" #include "DNA_scene_types.h" -#include "BKE_utildefines.h" #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_storage.h" +#include "BLI_utildefines.h" +#include "BKE_utildefines.h" #include "BKE_blender.h" #include "BKE_global.h" #include "BKE_main.h" diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 4a596b079cf..16d332c3bcb 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -41,6 +41,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_fcurve.h" #include "BKE_animsys.h" diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index ef89d39864a..c4db31d732d 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -43,6 +43,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_customdata.h" diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 0376d75d651..40636fe59d1 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -38,6 +38,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" /* windows needs for M_PI */ +#include "BLI_utildefines.h" #include "BKE_fcurve.h" #include "BKE_idprop.h" diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index ec63975a3c0..9a9d67a01f8 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -41,6 +41,7 @@ #include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_vfontdata.h" +#include "BLI_utildefines.h" #include "DNA_packedFile_types.h" #include "DNA_curve_types.h" @@ -49,9 +50,7 @@ #include "DNA_object_types.h" #include "BKE_utildefines.h" - #include "BKE_packedFile.h" - #include "BKE_library.h" #include "BKE_font.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 80f26277689..4d02697920b 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -33,8 +33,8 @@ #include "MEM_guardedalloc.h" - #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_gpencil_types.h" diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index e125f3d4bd7..3b82114fe35 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -41,6 +41,7 @@ #include "DNA_particle_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_utildefines.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 30e4318e256..1df272fad30 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -40,6 +40,7 @@ #include "DNA_world_types.h" #include "DNA_brush_types.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BKE_icons.h" diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 70bfc96f0a2..301588deaa2 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -60,6 +60,7 @@ #include "BLI_blenlib.h" #include "BLI_threads.h" +#include "BLI_utildefines.h" #include "BKE_bmfont.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index e19f36a2a0b..b810e028b62 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -37,6 +37,7 @@ #include "BLI_threads.h" #include "BLI_math.h" #include "BLI_linklist.h" +#include "BLI_utildefines.h" #include "BKE_cloth.h" #include "BKE_collision.h" diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index a040c27caa0..cc890683d7b 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -59,6 +59,7 @@ #include "BLI_math.h" /* windows needs for M_PI */ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 5a46d73201f..a4958940b62 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -39,6 +39,7 @@ #include "BLI_blenlib.h" #include "BLI_editVert.h" #include "BLI_math_vector.h" +#include "BLI_utildefines.h" #include "DNA_anim_types.h" #include "DNA_key_types.h" diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 891d42c4a76..15761dce4b3 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -40,6 +40,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 08adfdc1960..6af7df67fa9 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -67,9 +67,9 @@ #include "DNA_world_types.h" #include "DNA_gpencil_types.h" - #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "BKE_utildefines.h" #include "BKE_animsys.h" diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index c8fb921285c..887b1fe48a3 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -45,6 +45,7 @@ #include "BLI_math.h" #include "BLI_listbase.h" +#include "BLI_utildefines.h" #include "BKE_animsys.h" #include "BKE_displist.h" diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 8658d7e482f..bd1c009adc7 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -48,6 +48,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 03fab0718da..15ececd0d42 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -43,6 +43,12 @@ #include "DNA_meshdata_types.h" #include "DNA_ipo_types.h" +#include "BLI_blenlib.h" +#include "BLI_editVert.h" +#include "BLI_math.h" +#include "BLI_edgehash.h" +#include "BLI_utildefines.h" + #include "BKE_animsys.h" #include "BKE_main.h" #include "BKE_DerivedMesh.h" @@ -60,12 +66,6 @@ #include "BKE_object.h" #include "BKE_utildefines.h" -#include "BLI_blenlib.h" -#include "BLI_editVert.h" -#include "BLI_math.h" -#include "BLI_edgehash.h" - - EditMesh *BKE_mesh_get_editmesh(Mesh *me) { return me->edit_mesh; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index f8fdc9e32a4..cc3d6a96092 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -40,11 +40,13 @@ #include #include +#include "MEM_guardedalloc.h" + #include "DNA_armature_types.h" #include "DNA_object_types.h" #include "DNA_meshdata_types.h" -#include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BKE_bmesh.h" #include "BKE_cloth.h" diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index a3c13b36dcf..79de12e1ce8 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -38,6 +38,7 @@ #include "BLI_math.h" #include "BLI_pbvh.h" #include "BLI_editVert.h" +#include "BLI_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 5996bdc9f9a..fc7950e29c3 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "DNA_anim_types.h" diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index a2b6163321b..e564a32056f 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -57,6 +57,7 @@ #include "BLI_editVert.h" #include "BLI_math.h" #include "BLI_pbvh.h" +#include "BLI_utildefines.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index c278bf3b3d2..12ebaf7578a 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -47,6 +47,7 @@ #include "DNA_packedFile_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_utildefines.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 116ed3c8ef2..945131b60b2 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -31,6 +31,8 @@ #include "DNA_scene_types.h" #include "DNA_brush_types.h" +#include "BLI_utildefines.h" + #include "BKE_utildefines.h" #include "BKE_brush.h" #include "BKE_library.h" diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index d3a0cd5df7c..27a19ecf1a5 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -46,10 +46,11 @@ #include "DNA_scene_types.h" #include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.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" @@ -2477,7 +2478,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle float orco[3], ornor[3], hairmat[4][4], t, dvec[3], off1[4][3], off2[4][3]; float length, max_length = 1.0f, cur_length = 0.0f; float eff_length, eff_vec[3], weight[4]; - int k, cpa_num, maxw=0; + int k, cpa_num; short cpa_from; if(!pcache) @@ -2749,7 +2750,6 @@ static void *exec_child_path_cache(void *data) void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupdate) { - ParticleSettings *part = sim->psys->part; ParticleThread *pthreads; ParticleThreadContext *ctx; ParticleCacheKey **cache; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 207a9b8f839..646f8080b5c 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -63,6 +63,7 @@ #include "BLI_listbase.h" #include "BLI_threads.h" #include "BLI_storage.h" /* For _LARGEFILE64_SOURCE; zlib needs this on some systems */ +#include "BLI_utildefines.h" #include "BKE_main.h" #include "BKE_animsys.h" @@ -3641,7 +3642,6 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) static int emit_particles(ParticleSimulationData *sim, PTCacheID *pid, float UNUSED(cfra)) { ParticleSystem *psys = sim->psys; - ParticleSettings *part = psys->part; int oldtotpart = psys->totpart; int totpart = tot_particles(psys, pid); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 9ad00247dc2..6f52803f6b2 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -44,6 +44,7 @@ #include "BLI_blenlib.h" #include "BLI_threads.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "PIL_time.h" diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index 5df912c871d..1dd27987cf8 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -29,6 +29,7 @@ #include "BLI_blenlib.h" #include "BLI_dynstr.h" +#include "BLI_utildefines.h" #include "BKE_report.h" #include "BKE_global.h" /* G.background only */ diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 9aeb9a89c90..ded32de48d3 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -39,6 +39,8 @@ #include #endif +#include "MEM_guardedalloc.h" + #include "DNA_anim_types.h" #include "DNA_group_types.h" #include "DNA_object_types.h" @@ -46,7 +48,9 @@ #include "DNA_screen_types.h" #include "DNA_sequence_types.h" -#include "MEM_guardedalloc.h" +#include "BLI_math.h" +#include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_anim.h" #include "BKE_animsys.h" @@ -69,9 +73,6 @@ //XXX #include "BIF_previewrender.h" //XXX #include "BIF_editseq.h" -#include "BLI_math.h" -#include "BLI_blenlib.h" - //XXX #include "nla.h" #ifdef WIN32 diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index b25c533ad4c..122e186bcd7 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -32,6 +32,7 @@ #include "DNA_sequence_types.h" #include "BKE_sequencer.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_mempool.h" #include diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index c11b51b9dd4..2d31cf7ba46 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -35,6 +35,7 @@ #include "PIL_dynlib.h" #include "BLI_math.h" /* windows needs for M_PI */ +#include "BLI_utildefines.h" #include "DNA_scene_types.h" #include "DNA_sequence_types.h" diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 03d4f3da889..4a3c80afaa8 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -41,6 +41,14 @@ #include "DNA_object_types.h" #include "DNA_sound_types.h" +#include "BLI_math.h" +#include "BLI_fileops.h" +#include "BLI_listbase.h" +#include "BLI_path_util.h" +#include "BLI_string.h" +#include "BLI_threads.h" +#include "BLI_utildefines.h" + #include "BKE_animsys.h" #include "BKE_global.h" #include "BKE_image.h" @@ -51,12 +59,6 @@ #include "RNA_access.h" #include "RE_pipeline.h" -#include "BLI_math.h" -#include "BLI_fileops.h" -#include "BLI_listbase.h" -#include "BLI_path_util.h" -#include "BLI_string.h" -#include "BLI_threads.h" #include #include "IMB_imbuf.h" diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 16e4933332c..ee39e639a99 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -40,6 +40,10 @@ #include "DNA_mesh_types.h" #include "DNA_scene_types.h" +#include "BLI_editVert.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + #include "BKE_shrinkwrap.h" #include "BKE_DerivedMesh.h" #include "BKE_lattice.h" @@ -48,10 +52,6 @@ #include "BKE_mesh.h" #include "BKE_subsurf.h" -#include "BLI_editVert.h" -#include "BLI_math.h" - - /* Util macros */ #define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n")) diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index 7e39cdd1196..a81f49ddc58 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -31,6 +31,7 @@ #include "BLI_blenlib.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BKE_sketch.h" #include "BKE_utildefines.h" diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 9a0f278bcd0..41732ff3735 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -48,6 +48,7 @@ #include "BLI_edgehash.h" #include "BLI_kdtree.h" #include "BLI_kdopbvh.h" +#include "BLI_utildefines.h" #include "BKE_bvhutils.h" #include "BKE_cdderivedmesh.h" diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index eb56331acfb..6814f28f51c 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -63,6 +63,7 @@ variables on the UI for now #include "DNA_meshdata_types.h" #include "BLI_math.h" +#include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_threads.h" diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 874fd0fef17..02b3d858a5f 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -41,6 +41,13 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BLI_blenlib.h" +#include "BLI_edgehash.h" +#include "BLI_math.h" +#include "BLI_memarena.h" +#include "BLI_pbvh.h" +#include "BLI_utildefines.h" + #include "BKE_cdderivedmesh.h" #include "BKE_global.h" #include "BKE_mesh.h" @@ -50,12 +57,6 @@ #include "BKE_subsurf.h" #include "BKE_utildefines.h" -#include "BLI_blenlib.h" -#include "BLI_edgehash.h" -#include "BLI_math.h" -#include "BLI_memarena.h" -#include "BLI_pbvh.h" - #include "BIF_gl.h" #include "BIF_glutil.h" diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 44a8141adff..8d73c0c32ae 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -36,6 +36,7 @@ #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "DNA_constraint_types.h" #include "DNA_controller_types.h" diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 595b85955b8..11c0ce74b4a 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -38,11 +38,10 @@ #include "PIL_dynlib.h" - - #include "BLI_blenlib.h" #include "BLI_math.h" #include "BLI_kdopbvh.h" +#include "BLI_utildefines.h" #include "DNA_key_types.h" #include "DNA_object_types.h" diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index de708f216fd..0bfc0065b1a 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -38,6 +38,7 @@ #include "DNA_scene_types.h" #include "BLI_blenlib.h" +#include "BLI_utildefines.h" #include "BKE_global.h" #include "BKE_main.h" diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index dd63c266491..625a9168271 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -47,6 +47,8 @@ #include "DNA_userdef_types.h" +#include "BLI_utildefines.h" + #include "BKE_utildefines.h" #include "BKE_global.h" #include "BKE_report.h" -- cgit v1.2.3 From 89c9aaaa25cc7ce60c305d8e30e1c008cb117cf1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 Jan 2011 19:18:31 +0000 Subject: remove references to BKE_utildefines where its not needed. - move GS() define into DNA_ID.h - add BLI_utildefines as an automatic include with makesrna generated files. --- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/blender.c | 2 +- source/blender/blenkernel/intern/boids.c | 2 +- source/blender/blenkernel/intern/bvhutils.c | 4 ++-- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- source/blender/blenkernel/intern/cloth.c | 2 +- source/blender/blenkernel/intern/collision.c | 2 +- source/blender/blenkernel/intern/colortools.c | 2 +- source/blender/blenkernel/intern/constraint.c | 2 +- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/customdata_file.c | 2 +- source/blender/blenkernel/intern/effect.c | 2 +- source/blender/blenkernel/intern/exotic.c | 2 +- source/blender/blenkernel/intern/fluidsim.c | 2 +- source/blender/blenkernel/intern/fmodifier.c | 2 +- source/blender/blenkernel/intern/gpencil.c | 2 +- source/blender/blenkernel/intern/group.c | 2 +- source/blender/blenkernel/intern/image.c | 1 + source/blender/blenkernel/intern/implicit.c | 2 +- source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/key.c | 2 +- source/blender/blenkernel/intern/lattice.c | 2 +- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/material.c | 2 +- source/blender/blenkernel/intern/mball.c | 2 +- source/blender/blenkernel/intern/mesh.c | 2 +- source/blender/blenkernel/intern/multires.c | 2 +- source/blender/blenkernel/intern/nla.c | 2 +- source/blender/blenkernel/intern/node.c | 3 +-- source/blender/blenkernel/intern/object.c | 2 +- source/blender/blenkernel/intern/paint.c | 2 +- source/blender/blenkernel/intern/particle.c | 2 +- source/blender/blenkernel/intern/particle_system.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 1 + source/blender/blenkernel/intern/report.c | 2 +- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 2 ++ source/blender/blenkernel/intern/shrinkwrap.c | 4 ++-- source/blender/blenkernel/intern/sketch.c | 2 +- source/blender/blenkernel/intern/smoke.c | 2 +- source/blender/blenkernel/intern/subsurf_ccg.c | 2 +- source/blender/blenkernel/intern/text.c | 2 +- source/blender/blenkernel/intern/writeavi.c | 2 +- source/blender/blenkernel/intern/writeframeserver.c | 2 +- 46 files changed, 49 insertions(+), 46 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 3b8da3975a0..aeb1f525943 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -53,7 +53,7 @@ #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_texture.h" -#include "BKE_utildefines.h" + #include "BLO_sys_types.h" // for intptr_t support diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index bd36e1b2720..08b57ba18a3 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -53,7 +53,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_utildefines.h" + #include "BKE_idprop.h" #include "BIK_api.h" diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 0367d854169..1a219939b77 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -64,7 +64,7 @@ #include "BKE_lattice.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_utildefines.h" + #include "BIK_api.h" #include "BKE_sketch.h" diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 7d75912f31d..1d616c77f04 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -82,7 +82,7 @@ #include "BLO_readfile.h" #include "BLO_writefile.h" -#include "BKE_utildefines.h" // O_BINARY FALSE +#include "BKE_utildefines.h" #include "WM_api.h" // XXXXX BAD, very BAD dependency (bad level call) - remove asap, elubie diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 85ee3760849..228827bab68 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -47,7 +47,7 @@ #include "BKE_effect.h" #include "BKE_boids.h" #include "BKE_particle.h" -#include "BKE_utildefines.h" + #include "BKE_modifier.h" #include "RNA_enum_types.h" diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 0d3825fa8a8..db7b9b276a2 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -23,7 +23,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): André Pinto. + * Contributor(s): Andr Pinto. * * ***** END GPL LICENSE BLOCK ***** */ @@ -38,7 +38,7 @@ #include "BLI_utildefines.h" #include "BKE_DerivedMesh.h" -#include "BKE_utildefines.h" + #include "BLI_math.h" #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 956972e8d5b..a0750308a2d 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -47,7 +47,7 @@ #include "BKE_global.h" #include "BKE_mesh.h" #include "BKE_paint.h" -#include "BKE_utildefines.h" + #include "DNA_meshdata_types.h" #include "DNA_object_types.h" diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 4b14e64ee27..8cc3a3fc07a 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -42,7 +42,7 @@ #include "BKE_global.h" #include "BKE_modifier.h" #include "BKE_pointcache.h" -#include "BKE_utildefines.h" + #ifdef _WIN32 void tstart ( void ) diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 8f028914ece..e7dff52db62 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -50,7 +50,7 @@ #include "BKE_mesh.h" #include "BKE_object.h" #include "BKE_modifier.h" -#include "BKE_utildefines.h" + #include "BKE_DerivedMesh.h" #ifdef USE_BULLET #include "Bullet-C-Api.h" diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 282a055e04c..1bfefef4b71 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -48,7 +48,7 @@ #include "BKE_colortools.h" #include "BKE_curve.h" #include "BKE_fcurve.h" -#include "BKE_utildefines.h" + #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index ad6b3b8f837..c497132fa99 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -53,7 +53,7 @@ #include "DNA_scene_types.h" #include "DNA_text_types.h" -#include "BKE_utildefines.h" + #include "BKE_action.h" #include "BKE_anim.h" /* for the curve calculation part */ #include "BKE_armature.h" diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index b5550768e55..13a53629d9b 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -59,7 +59,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_utildefines.h" // VECCOPY + #include "ED_curve.h" diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index ebc21344810..6fb79a0df28 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -32,7 +32,7 @@ #include "BKE_customdata_file.h" #include "BKE_global.h" -#include "BKE_utildefines.h" + /************************* File Format Definitions ***************************/ diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index aeec2a588c7..a79a5fddf00 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -87,7 +87,7 @@ #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_scene.h" -#include "BKE_utildefines.h" + #include "RE_render_ext.h" #include "RE_shader_ext.h" diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 612ea84abe5..641313b564c 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -66,7 +66,7 @@ #include "BLI_storage.h" #include "BLI_utildefines.h" -#include "BKE_utildefines.h" + #include "BKE_blender.h" #include "BKE_global.h" #include "BKE_main.h" diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index c4db31d732d..3db9731310c 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -52,7 +52,7 @@ #include "BKE_global.h" #include "BKE_modifier.h" #include "BKE_mesh.h" -#include "BKE_utildefines.h" + // headers for fluidsim bobj meshes #include diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 40636fe59d1..e4aeb45a209 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -42,7 +42,7 @@ #include "BKE_fcurve.h" #include "BKE_idprop.h" -#include "BKE_utildefines.h" + #define SMALL -1.0e-10 #define SELECT 1 diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 4d02697920b..c3e2d7ffcf4 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -42,7 +42,7 @@ #include "BKE_gpencil.h" #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_utildefines.h" + /* ************************************************** */ diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 3b82114fe35..e48ec8ac288 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -43,7 +43,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" -#include "BKE_utildefines.h" + #include "BKE_global.h" #include "BKE_group.h" #include "BKE_library.h" diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 301588deaa2..58e3b4ba552 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -71,6 +71,7 @@ #include "BKE_packedFile.h" #include "BKE_scene.h" #include "BKE_node.h" +#include "BKE_utildefines.h" //XXX #include "BIF_editseq.h" diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index b810e028b62..0df456a443d 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -43,7 +43,7 @@ #include "BKE_collision.h" #include "BKE_effect.h" #include "BKE_global.h" -#include "BKE_utildefines.h" + #define CLOTH_OPENMP_LIMIT 25 diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index cc890683d7b..b4dd81ce356 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -61,7 +61,7 @@ #include "BLI_dynstr.h" #include "BLI_utildefines.h" -#include "BKE_utildefines.h" + #include "BKE_animsys.h" #include "BKE_action.h" diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index a4958940b62..328fb1b6a49 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -58,7 +58,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_utildefines.h" + #include "RNA_access.h" diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 15761dce4b3..be3ec62374f 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -61,7 +61,7 @@ #include "BKE_main.h" #include "BKE_mesh.h" #include "BKE_modifier.h" -#include "BKE_utildefines.h" + #include "BKE_deform.h" //XXX #include "BIF_editdeform.h" diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 6af7df67fa9..66b6d43d259 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -71,7 +71,7 @@ #include "BLI_dynstr.h" #include "BLI_utildefines.h" -#include "BKE_utildefines.h" + #include "BKE_animsys.h" #include "BKE_context.h" #include "BKE_library.h" diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 887b1fe48a3..c22384a6bdc 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -56,7 +56,7 @@ #include "BKE_material.h" #include "BKE_mesh.h" #include "BKE_node.h" -#include "BKE_utildefines.h" + #include "GPU_material.h" diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index bd1c009adc7..6e48b922424 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -50,7 +50,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" -#include "BKE_utildefines.h" + #include "BKE_global.h" #include "BKE_main.h" diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 15ececd0d42..dc4838366c4 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -64,7 +64,7 @@ #include "BKE_curve.h" /* -- */ #include "BKE_object.h" -#include "BKE_utildefines.h" + EditMesh *BKE_mesh_get_editmesh(Mesh *me) { diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 79de12e1ce8..34a057788a2 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -47,7 +47,7 @@ #include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_subsurf.h" -#include "BKE_utildefines.h" + #include "BKE_object.h" #include "CCGSubSurf.h" diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index fc7950e29c3..72466261e14 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -47,7 +47,7 @@ #include "BKE_nla.h" #include "BKE_global.h" #include "BKE_library.h" -#include "BKE_utildefines.h" + #include "RNA_access.h" #include "nla_private.h" diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index bd126ab12c2..7e9fe01e621 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -43,11 +43,10 @@ #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_fcurve.h" - +#include "BKE_utildefines.h" #include "PIL_time.h" - #include "CMP_node.h" #include "intern/CMP_util.h" /* stupid include path... */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e564a32056f..c943b2fcfed 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -59,7 +59,7 @@ #include "BLI_pbvh.h" #include "BLI_utildefines.h" -#include "BKE_utildefines.h" + #include "BKE_main.h" #include "BKE_global.h" diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 945131b60b2..853338d0722 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -33,7 +33,7 @@ #include "BLI_utildefines.h" -#include "BKE_utildefines.h" + #include "BKE_brush.h" #include "BKE_library.h" #include "BKE_paint.h" diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 27a19ecf1a5..018b882f7a2 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -62,7 +62,7 @@ #include "BKE_group.h" #include "BKE_main.h" #include "BKE_lattice.h" -#include "BKE_utildefines.h" + #include "BKE_displist.h" #include "BKE_particle.h" #include "BKE_object.h" diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 646f8080b5c..45016e2db73 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -74,7 +74,7 @@ #include "BKE_effect.h" #include "BKE_particle.h" #include "BKE_global.h" -#include "BKE_utildefines.h" + #include "BKE_DerivedMesh.h" #include "BKE_object.h" #include "BKE_material.h" diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 6f52803f6b2..317723aef7f 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -64,6 +64,7 @@ #include "BKE_smoke.h" #include "BKE_softbody.h" #include "BKE_utildefines.h" + #include "BIK_api.h" /* both in intern */ diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index 1dd27987cf8..a22b36b9524 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -33,7 +33,7 @@ #include "BKE_report.h" #include "BKE_global.h" /* G.background only */ -#include "BKE_utildefines.h" + #include #include diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index ded32de48d3..94eed530ad6 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -67,7 +67,7 @@ #include "BKE_scene.h" #include "BKE_sequencer.h" #include "BKE_world.h" -#include "BKE_utildefines.h" + #include "BKE_sound.h" //XXX #include "BIF_previewrender.h" diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 4a3c80afaa8..5f25e419eec 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -57,6 +57,8 @@ #include "BKE_fcurve.h" #include "BKE_scene.h" #include "RNA_access.h" +#include "BKE_utildefines.h" + #include "RE_pipeline.h" #include diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index ee39e639a99..753e31d565b 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -22,7 +22,7 @@ * * The Original Code is: all of this file. * - * Contributor(s): André Pinto + * Contributor(s): Andr Pinto * * ***** END GPL LICENSE BLOCK ***** */ @@ -47,7 +47,7 @@ #include "BKE_shrinkwrap.h" #include "BKE_DerivedMesh.h" #include "BKE_lattice.h" -#include "BKE_utildefines.h" + #include "BKE_deform.h" #include "BKE_mesh.h" #include "BKE_subsurf.h" diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index a81f49ddc58..06c6e0f197a 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -34,7 +34,7 @@ #include "BLI_utildefines.h" #include "BKE_sketch.h" -#include "BKE_utildefines.h" + #include "DNA_userdef_types.h" diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 41732ff3735..8039d729842 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -59,7 +59,7 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_smoke.h" -#include "BKE_utildefines.h" + #include "DNA_customdata_types.h" #include "DNA_group_types.h" diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 02b3d858a5f..40fe71ded23 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -55,7 +55,7 @@ #include "BKE_paint.h" #include "BKE_scene.h" #include "BKE_subsurf.h" -#include "BKE_utildefines.h" + #include "BIF_gl.h" #include "BIF_glutil.h" diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 8d73c0c32ae..5ae35aaa266 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -52,7 +52,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_text.h" -#include "BKE_utildefines.h" + #ifdef WITH_PYTHON #include "BPY_extern.h" diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 0bfc0065b1a..014a15de1ef 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -43,7 +43,7 @@ #include "BKE_global.h" #include "BKE_main.h" #include "BKE_report.h" -#include "BKE_utildefines.h" + #include "BKE_writeavi.h" #include "AVI_avi.h" diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 625a9168271..eb1c66604f8 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -49,7 +49,7 @@ #include "BLI_utildefines.h" -#include "BKE_utildefines.h" + #include "BKE_global.h" #include "BKE_report.h" -- cgit v1.2.3 From 473838aec99d81595def7634d61a48118e84b8ff Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Fri, 7 Jan 2011 21:12:47 +0000 Subject: Fix for bug [#21534] Multires modifier strange deformations This adds the "Apply Base" feature from my gsoc2010 branch. Apply Base partially applies the modifier, in that the mesh is reshaped to more closely match the deformed mesh. The upper-level displacements are recalculated so that the highest multires level appears unchanged. Multires does not currently deal well with too large displacements. An easy-to-reproduce example: create any mesh type, add multires, subdivide a few times, then use the sculpt grab brush to drag the entire mesh over a few units. At the highest level, and at level 0, the mesh looks fine, but all of the intervening levels will have ugly spikes on them. This patch doesn't help with situations where you can't modify the base mesh, but otherwise works around the problem fairly well (albeit with a heuristic, not an exact solution.) --- source/blender/blenkernel/intern/multires.c | 122 ++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 34a057788a2..6c1b8fb6047 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -472,6 +472,128 @@ static DerivedMesh *subsurf_dm_create_local(Object *UNUSED(ob), DerivedMesh *dm, return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0); } + + +/* assumes no is normalized; return value's sign is negative if v is on + the other side of the plane */ +static float v3_dist_from_plane(float v[3], float center[3], float no[3]) +{ + float s[3]; + sub_v3_v3v3(s, v, center); + return dot_v3v3(s, no); +} + +void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) +{ + DerivedMesh *cddm, *dispdm, *origdm; + Mesh *me; + ListBase *fmap; + float (*origco)[3]; + int i, j, offset, totlvl; + + multires_force_update(ob); + + me = get_mesh(ob); + totlvl = mmd->totlvl; + + /* nothing to do */ + if(!totlvl) + return; + + /* XXX - probably not necessary to regenerate the cddm so much? */ + + /* generate highest level with displacements */ + cddm = CDDM_from_mesh(me, NULL); + DM_set_only_copy(cddm, CD_MASK_BAREMESH); + dispdm = multires_dm_create_local(ob, cddm, totlvl, totlvl, 0); + cddm->release(cddm); + + /* copy the new locations of the base verts into the mesh */ + offset = dispdm->getNumVerts(dispdm) - me->totvert; + for(i = 0; i < me->totvert; ++i) { + dispdm->getVertCo(dispdm, offset + i, me->mvert[i].co); + } + + /* heuristic to produce a better-fitting base mesh */ + + cddm = CDDM_from_mesh(me, NULL); + fmap = cddm->getFaceMap(ob, cddm); + origco = MEM_callocN(sizeof(float)*3*me->totvert, "multires apply base origco"); + for(i = 0; i < me->totvert ;++i) + copy_v3_v3(origco[i], me->mvert[i].co); + + for(i = 0; i < me->totvert; ++i) { + IndexNode *n; + float avg_no[3] = {0,0,0}, center[3] = {0,0,0}, push[3]; + float dist; + int tot; + + /* don't adjust verts not used by at least one face */ + if(!fmap[i].first) + continue; + + /* find center */ + for(n = fmap[i].first, tot = 0; n; n = n->next) { + MFace *f = &me->mface[n->index]; + int S = f->v4 ? 4 : 3; + + /* this double counts, not sure if that's bad or good */ + for(j = 0; j < S; ++j) { + int vndx = (&f->v1)[j]; + if(vndx != i) { + add_v3_v3(center, origco[vndx]); + ++tot; + } + } + } + mul_v3_fl(center, 1.0f / tot); + + /* find normal */ + for(n = fmap[i].first; n; n = n->next) { + MFace *f = &me->mface[n->index]; + int S = f->v4 ? 4 : 3; + float v[4][3], no[3]; + + for(j = 0; j < S; ++j) { + int vndx = (&f->v1)[j]; + if(vndx == i) + copy_v3_v3(v[j], center); + else + copy_v3_v3(v[j], origco[vndx]); + } + + if(S == 4) + normal_quad_v3(no, v[0], v[1], v[2], v[3]); + else + normal_tri_v3(no, v[0], v[1], v[2]); + add_v3_v3(avg_no, no); + } + normalize_v3(avg_no); + + /* push vertex away from the plane */ + dist = v3_dist_from_plane(me->mvert[i].co, center, avg_no); + copy_v3_v3(push, avg_no); + mul_v3_fl(push, dist); + add_v3_v3(me->mvert[i].co, push); + + } + + MEM_freeN(origco); + cddm->release(cddm); + + /* subdivide the mesh to highest level without displacements */ + cddm = CDDM_from_mesh(me, NULL); + DM_set_only_copy(cddm, CD_MASK_BAREMESH); + origdm = subsurf_dm_create_local(ob, cddm, totlvl, 0, 0); + cddm->release(cddm); + + /* calc disps */ + multiresModifier_disp_run(dispdm, me, 1, 0, origdm->getGridData(origdm), totlvl); + + origdm->release(origdm); + dispdm->release(dispdm); +} + void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl, int updateblock, int simple) { Mesh *me = ob->data; -- cgit v1.2.3 From d3d5fe42bf4fd07dfd9638b5e18ec2d2e7422b94 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 Jan 2011 10:23:36 +0000 Subject: fixed a case with occlusion where uninitialized variable could be used. also removed unused vars. can_pbvh_draw() had a NULL check which is never needed (callers check for this), a NULL ob would have crashed the function anyway. --- source/blender/blenkernel/intern/cdderivedmesh.c | 2 +- 1 file changed, 1 insertion(+), 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 a0750308a2d..8bb336d1c4d 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -190,7 +190,7 @@ static ListBase *cdDM_getFaceMap(Object *ob, DerivedMesh *dm) static int can_pbvh_draw(Object *ob, DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; - Mesh *me= (ob)? ob->data: NULL; + Mesh *me= ob->data; if(ob->sculpt->modifiers_active) return 0; -- cgit v1.2.3 From 39e7848ca17eb76bf5877a063a6a72ecb8ec011c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 Jan 2011 11:08:51 +0000 Subject: fix for using freed memory with animation/group/ungroup code. --- source/blender/blenkernel/intern/node.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 7e9fe01e621..c4d54cd6296 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -551,7 +551,7 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) BKE_animdata_separate_by_basepath(&ntree->id, &ngroup->id, &anim_basepaths); /* paths + their wrappers need to be freed */ - for (ld = anim_basepaths.first; ld; ld = ld->next) { + for (ld = anim_basepaths.first; ld; ld = ldn) { ldn = ld->next; MEM_freeN(ld->data); @@ -866,7 +866,7 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode) BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths); /* paths + their wrappers need to be freed */ - for (ld = anim_basepaths.first; ld; ld = ld->next) { + for (ld = anim_basepaths.first; ld; ld = ldn) { ldn = ld->next; MEM_freeN(ld->data); -- cgit v1.2.3 From 3b74074aec8ad551f210fda9ed13cf654d98876f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 8 Jan 2011 12:43:44 +0000 Subject: remove unused code & variables. --- source/blender/blenkernel/intern/DerivedMesh.c | 11 ++--------- source/blender/blenkernel/intern/cloth.c | 7 +------ source/blender/blenkernel/intern/colortools.c | 12 ++++++++---- source/blender/blenkernel/intern/font.c | 5 ++++- source/blender/blenkernel/intern/modifier.c | 4 ++-- source/blender/blenkernel/intern/particle_system.c | 3 +-- source/blender/blenkernel/intern/seqeffects.c | 7 +------ source/blender/blenkernel/intern/subsurf_ccg.c | 1 - source/blender/blenkernel/intern/text.c | 4 +--- 9 files changed, 20 insertions(+), 34 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index aeb1f525943..cdf2991f532 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2602,15 +2602,8 @@ void DM_add_tangent_layer(DerivedMesh *dm) /* write tangent to layer */ for(i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++, tangent+=4) { len= (mf->v4)? 4 : 3; - - if(mtface) { - uv1= tf->uv[0]; - uv2= tf->uv[1]; - uv3= tf->uv[2]; - uv4= tf->uv[3]; - } - else { - uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; + + if(mtface == NULL) { map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 8cc3a3fc07a..cc54468a1de 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -431,7 +431,7 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, PointCache *cache; PTCacheID pid; float timescale; - int framedelta, framenr, startframe, endframe; + int framenr, startframe, endframe; int cache_result; clmd->scene= scene; /* nice to pass on later :) */ @@ -487,11 +487,6 @@ DerivedMesh *clothModifier_do(ClothModifierData *clmd, Scene *scene, Object *ob, framenr= endframe; } - if(cache->flag & PTCACHE_SIMULATION_VALID) - framedelta= framenr - cache->simframe; - else - framedelta= -1; - /* initialize simulation data if it didn't exist already */ if(!do_init_cloth(ob, clmd, dm, framenr)) return result; diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 1bfefef4b71..7cf6b21e2f1 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -1012,6 +1012,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) int savedlines, saveline; float rgb[3], ycc[3], luma; int ycc_mode=-1; + const short is_float = (ibuf->rect_float != NULL); + + if (ibuf->rect==NULL && ibuf->rect_float==NULL) return; if (scopes->ok == 1 ) return; @@ -1019,6 +1022,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) /* hmmmm */ if (!(ELEM(ibuf->channels, 3, 4))) return; + scopes->hist.channels = 3; scopes->hist.x_resolution = 256; @@ -1073,9 +1077,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) scopes->waveform_3= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3"); scopes->vecscope= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel"); - if (ibuf->rect_float) + if (is_float) rf = ibuf->rect_float; - else if (ibuf->rect) + else rc = (unsigned char *)ibuf->rect; for (y = 0; y < ibuf->y; y++) { @@ -1084,13 +1088,13 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) } else saveline=0; for (x = 0; x < ibuf->x; x++) { - if (ibuf->rect_float) { + if (is_float) { if (use_color_management) linearrgb_to_srgb_v3_v3(rgb, rf); else copy_v3_v3(rgb, rf); } - else if (ibuf->rect) { + else { for (c=0; c<3; c++) rgb[c] = rc[c] * INV_255; } diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 9a9d67a01f8..ecaa15c8f7d 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -859,12 +859,15 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) yof= cu->yof + tb->y/cu->fsize; } + /* XXX, has been unused for years, need to check if this is useful, r4613 r5282 - campbell */ +#if 0 if(ascii == '\n' || ascii == '\r') xof = cu->xof; else xof= cu->xof + (tb->x/cu->fsize); - +#else xof= cu->xof + (tb->x/cu->fsize); +#endif lnr++; cnr= 0; wsnr= 0; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index cc3d6a96092..03091b9b0a4 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -149,14 +149,14 @@ ModifierData *modifiers_findByName(Object *ob, const char *name) void modifiers_clearErrors(Object *ob) { ModifierData *md = ob->modifiers.first; - int qRedraw = 0; + /* int qRedraw = 0; */ for (; md; md=md->next) { if (md->error) { MEM_freeN(md->error); md->error = NULL; - qRedraw = 1; + /* qRedraw = 1; */ } } } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 45016e2db73..3534a7dba37 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3488,7 +3488,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra) ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; PARTICLE_P; - float disp, birthtime, dietime; + float disp, dietime; BLI_srandom(psys->seed); @@ -3503,7 +3503,6 @@ static void cached_step(ParticleSimulationData *sim, float cfra) psys->lattice= psys_get_lattice(sim); - birthtime = pa->time; dietime = pa->dietime; /* update alive status and push events */ diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 2d31cf7ba46..2f90da2296b 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1592,15 +1592,10 @@ static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo // This function calculates the blur band for the wipe effects static float in_band(WipeZone *wipezone,float width,float dist,float perc,int side,int dir) { - float t1,t2,alpha,percwidth; + float t1,t2,alpha; if(width == 0) return (float)side; - - if(side == 1) - percwidth = width * perc; - else - percwidth = width * (1 - perc); if(width < dist) return side; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 40fe71ded23..e139820be32 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1373,7 +1373,6 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, v ccgdm_pbvh_update(ccgdm); doDraw = 0; - numVerts = 0; matnr = -1; transp = GPU_get_material_blend_mode(); orig_transp = transp; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 5ae35aaa266..0b5347ca304 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1233,7 +1233,7 @@ int txt_find_string(Text *text, char *findstr, int wrap) { TextLine *tl, *startl; char *s= NULL; - int oldcl, oldsl, oldcc, oldsc; + int oldcl, oldsl; if (!text || !text->curl || !text->sell) return 0; @@ -1242,8 +1242,6 @@ int txt_find_string(Text *text, char *findstr, int wrap) oldcl= txt_get_span(text->lines.first, text->curl); oldsl= txt_get_span(text->lines.first, text->sell); tl= startl= text->sell; - oldcc= text->curc; - oldsc= text->selc; s= strstr(&tl->line[text->selc], findstr); while (!s) { -- cgit v1.2.3 From 17dd29cb850927bf47e86db48e2d33c544cfc786 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 8 Jan 2011 15:35:15 +0000 Subject: Bugfix, own collection New displist code for curves/text copied display lists without checking for freeing existing ones. Caused some memleaking. --- source/blender/blenkernel/intern/displist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 53e33ee9bd8..674836ac859 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -138,7 +138,7 @@ void copy_displist(ListBase *lbn, ListBase *lb) { DispList *dln, *dl; - lbn->first= lbn->last= 0; + freedisplist(lbn); dl= lb->first; while(dl) { -- cgit v1.2.3 From 70a828d5a5d0bd49765b281c01ca27cf188e3fca Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 9 Jan 2011 01:17:56 +0000 Subject: remove unused vars, comment some which look like they could be useful still. have makesrna.c omit unused _data definitions for rna funcs with no args. --- source/blender/blenkernel/intern/DerivedMesh.c | 4 ++-- source/blender/blenkernel/intern/cloth.c | 2 -- source/blender/blenkernel/intern/softbody.c | 5 +++-- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index cdf2991f532..bee0b476f9f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1284,7 +1284,7 @@ static void *emDM_getFaceDataArray(DerivedMesh *dm, int type) EditFace *efa; char *data, *emdata; void *datalayer; - int index, offset, size; + int index, size; datalayer = DM_get_face_data_layer(dm, type); if(datalayer) @@ -1296,7 +1296,7 @@ static void *emDM_getFaceDataArray(DerivedMesh *dm, int type) index = CustomData_get_layer_index(&em->fdata, type); if(index != -1) { - offset = em->fdata.layers[index].offset; + /* int offset = em->fdata.layers[index].offset; */ /* UNUSED */ size = CustomData_sizeof(type); DM_add_face_layer(dm, type, CD_CALLOC, NULL); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index cc54468a1de..39cb1346eb7 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -164,7 +164,6 @@ static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float eps BVHTree *bvhtree; Cloth *cloth; ClothVertex *verts; - MFace *mfaces; float co[12]; if(!clmd) @@ -176,7 +175,6 @@ static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float eps return NULL; verts = cloth->verts; - mfaces = cloth->mfaces; // in the moment, return zero if no faces there if(!cloth->numverts) diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 6814f28f51c..e38f1bb545c 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -2453,7 +2453,8 @@ static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, fl SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bproot; ListBase *do_effector = NULL; - float iks, gravity; + float gravity; + /* float iks; */ float fieldfactor = -1.0f, windfactor = 0.25; int do_deflector,do_selfcollision,do_springcollision,do_aero; @@ -2465,7 +2466,7 @@ static void softbody_calc_forcesEx(Scene *scene, Object *ob, float forcetime, fl do_springcollision=do_deflector && (ob->softflag & OB_SB_EDGES) &&(ob->softflag & OB_SB_EDGECOLL); do_aero=((sb->aeroedge)&& (ob->softflag & OB_SB_EDGES)); - iks = 1.0f/(1.0f-sb->inspring)-1.0f ;/* inner spring constants function */ + /* iks = 1.0f/(1.0f-sb->inspring)-1.0f; */ /* inner spring constants function */ /* UNUSED */ bproot= sb->bpoint; /* need this for proper spring addressing */ if (do_springcollision || do_aero) -- cgit v1.2.3 From e32bbef017df64a99acedd4f3f4ba32713c50a3b Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 9 Jan 2011 07:41:51 +0000 Subject: Fix for [#25544] Blender crashes when changing the particles emission amount * I've getting bad feelings about the point cache index_array for a while (cause for this bug too), so from now on memory cache uses a simple binary search directly on the index data to handle queries to specific data points. * This is a bit slower than just checking from a dedicated array, but it's much less error prone, uses less memory and makes the code more readable too, so it's not a tough choice. --- source/blender/blenkernel/intern/particle.c | 38 +++++----------- source/blender/blenkernel/intern/pointcache.c | 65 ++++++++++++++------------- 2 files changed, 47 insertions(+), 56 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 018b882f7a2..26f96d0c304 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1056,6 +1056,7 @@ typedef struct ParticleInterpolationData { static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache, PTCacheMem **cur, int index, float t, ParticleKey *key1, ParticleKey *key2) { static PTCacheMem *pm = NULL; + int index1, index2; if(index < 0) { /* initialize */ *cur = cache->mem_cache.first; @@ -1070,15 +1071,19 @@ static void get_pointcache_keys_for_time(Object *UNUSED(ob), PointCache *cache, pm = *cur; - BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame); - if(pm->prev->index_array && pm->prev->index_array[index] == 0) + index2 = BKE_ptcache_mem_index_find(pm, index); + index1 = BKE_ptcache_mem_index_find(pm->prev, index); + + BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame); + if(index1 < 0) copy_particle_key(key1, key2, 1); else - BKE_ptcache_make_particle_key(key1, pm->prev->index_array ? pm->prev->index_array[index] - 1 : index, pm->prev->data, (float)pm->prev->frame); + BKE_ptcache_make_particle_key(key1, index1, pm->prev->data, (float)pm->prev->frame); } else if(cache->mem_cache.first) { pm = cache->mem_cache.first; - BKE_ptcache_make_particle_key(key2, pm->index_array ? pm->index_array[index] - 1 : index, pm->data, (float)pm->frame); + index2 = BKE_ptcache_mem_index_find(pm, index); + BKE_ptcache_make_particle_key(key2, index2, pm->data, (float)pm->frame); copy_particle_key(key1, key2, 1); } } @@ -1089,14 +1094,7 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float int ret = 0; for(pm=cache->mem_cache.first; pm; pm=pm->next) { - if(pm->index_array) { - if(pm->index_array[index]) { - *start = pm->frame; - ret++; - break; - } - } - else { + if(BKE_ptcache_mem_index_find(pm, index) >= 0) { *start = pm->frame; ret++; break; @@ -1104,14 +1102,7 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float } for(pm=cache->mem_cache.last; pm; pm=pm->prev) { - if(pm->index_array) { - if(pm->index_array[index]) { - *end = pm->frame; - ret++; - break; - } - } - else { + if(BKE_ptcache_mem_index_find(pm, index) >= 0) { *end = pm->frame; ret++; break; @@ -1126,13 +1117,8 @@ float psys_get_dietime_from_cache(PointCache *cache, int index) { int dietime = 10000000; /* some max value so that we can default to pa->time+lifetime */ for(pm=cache->mem_cache.last; pm; pm=pm->prev) { - if(pm->index_array) { - if(pm->index_array[index]) - return (float)pm->frame; - } - else { + if(BKE_ptcache_mem_index_find(pm, index) >= 0) return (float)pm->frame; - } } return (float)dietime; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 317723aef7f..1d58f276117 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1161,6 +1161,39 @@ static void ptcache_file_pointers_init(PTCacheFile *pf) pf->cur[BPHYS_DATA_BOIDS] = (data_types & (1<data.boids : NULL; } +/* Check to see if point number "index" is in pm, uses binary search for index data. */ +int BKE_ptcache_mem_index_find(PTCacheMem *pm, int index) +{ + if(pm->data[BPHYS_DATA_INDEX]) { + uint32_t key = index; + uint32_t *data = pm->data[BPHYS_DATA_INDEX]; + uint32_t mid, low = 0, high = pm->totpoint - 1; + + if(key < *data || key > *(data+high)) + return -1; + + /* check simple case for continuous indexes first */ + if(data[key-*data]==key) + return key-*data; + + while(low <= high) { + mid= (low + high)/2; + + if(data[mid] > key) + high = mid - 1; + else if(data[mid] < key) + low = mid + 1; + else + return mid; + } + + return -1; + } + else { + return (index < pm->totpoint ? index : -1); + } +} + void BKE_ptcache_mem_pointers_init(PTCacheMem *pm) { int data_types = pm->data_types; @@ -1182,9 +1215,9 @@ void BKE_ptcache_mem_pointers_incr(PTCacheMem *pm) int BKE_ptcache_mem_pointers_seek(int point_index, PTCacheMem *pm) { int data_types = pm->data_types; - int i, index = pm->index_array ? pm->index_array[point_index] - 1 : point_index; + int i, index = BKE_ptcache_mem_index_find(pm, point_index); - if(index < 0 || point_index >= MEM_allocN_len(pm->index_array)/sizeof(int)) { + if(index < 0) { /* Can't give proper location without reallocation, so don't give any location. * Some points will be cached improperly, but this only happens with simulation * steps bigger than cache->step, so the cache has to be recalculated anyways @@ -1218,11 +1251,6 @@ static void ptcache_data_free(PTCacheMem *pm) if(data[i]) MEM_freeN(data[i]); } - - if(pm->index_array) { - MEM_freeN(pm->index_array); - pm->index_array = NULL; - } } static void ptcache_data_copy(void *from[], void *to[]) { @@ -1306,24 +1334,6 @@ static void ptcache_find_frames_around(PTCacheID *pid, int frame, int *fra1, int } } } -static void ptcache_make_index_array(PTCacheMem *pm, int totpoint) -{ - int i, *index; - - if(pm->index_array) { - MEM_freeN(pm->index_array); - pm->index_array = NULL; - } - - if(!pm->data[BPHYS_DATA_INDEX]) - return; - - pm->index_array = MEM_callocN(totpoint * sizeof(int), "PTCacheMem index_array"); - index = pm->data[BPHYS_DATA_INDEX]; - - for(i=0; itotpoint; i++, index++) - pm->index_array[*index] = i + 1; -} static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) { @@ -1398,9 +1408,6 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) } } - if(!error) - ptcache_make_index_array(pm, pid->totpoint(pid->calldata, pm->frame)); - if(error && pm) { ptcache_data_free(pm); ptcache_extra_free(pm); @@ -1806,7 +1813,6 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite) } } else { - ptcache_make_index_array(pm, pid->totpoint(pid->calldata, cfra)); BLI_addtail(&cache->mem_cache, pm); } @@ -2989,7 +2995,6 @@ void BKE_ptcache_update_info(PTCacheID *pid) bytes += sizeof(PTCacheExtra); } - bytes += MEM_allocN_len(pm->index_array); bytes += sizeof(PTCacheMem); totframes++; -- cgit v1.2.3 From 00b8c9e7eaef445be425f06111c91a92edf4406b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 9 Jan 2011 15:12:08 +0000 Subject: rename BKE_assert() --> BLI_assert(). --- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/key.c | 8 ++++---- source/blender/blenkernel/intern/object.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 61865f5579c..71c3e76c207 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2452,7 +2452,7 @@ void DAG_id_tag_update(ID *id, short flag) } } else { - BKE_assert(!"invalid flag for this 'idtype'"); + BLI_assert(!"invalid flag for this 'idtype'"); } } } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 328fb1b6a49..0955ccd170e 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -552,7 +552,7 @@ static short key_pointer_size(const Key *key, const int mode, int *poinsize, int break; default: - BKE_assert(!"invalid 'key->from' ID type"); + BLI_assert(!"invalid 'key->from' ID type"); return FALSE; } @@ -641,7 +641,7 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key /* should never happen */ if(freek1) MEM_freeN(freek1); if(freekref) MEM_freeN(freekref); - BKE_assert(!"invalid 'cp[1]'"); + BLI_assert(!"invalid 'cp[1]'"); return; } @@ -777,7 +777,7 @@ void do_rel_key(const int start, int end, const int tot, char *basispoin, Key *k /* should never happen */ if(freefrom) MEM_freeN(freefrom); if(freereffrom) MEM_freeN(freereffrom); - BKE_assert(!"invalid 'cp[1]'"); + BLI_assert(!"invalid 'cp[1]'"); return; } @@ -944,7 +944,7 @@ static void do_key(const int start, int end, const int tot, char *poin, Key *key if(freek2) MEM_freeN(freek2); if(freek3) MEM_freeN(freek3); if(freek4) MEM_freeN(freek4); - BKE_assert(!"invalid 'cp[1]'"); + BLI_assert(!"invalid 'cp[1]'"); return; } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index c943b2fcfed..0ac98256b07 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2552,7 +2552,7 @@ void object_handle_update(Scene *scene, Object *ob) { #if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask' EditMesh *em = (ob == scene->obedit)? BKE_mesh_get_editmesh(ob->data): NULL; - BKE_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH); + BLI_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH); if(em) { makeDerivedMesh(scene, ob, em, scene->customdata_mask); /* was CD_MASK_BAREMESH */ BKE_mesh_end_editmesh(ob->data, em); -- cgit v1.2.3 From 1786923afc85ede081dc3ed1a3970965a61dd761 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 9 Jan 2011 18:23:41 +0000 Subject: Replace uint32_t in pointcache code with unsigned int as it's supported in dna * Not strictly necessary right now, but better for future. * Struct data (only boids at the moment) is now written as structs (with dna) so they work between 64 and 32 bit machines too. --- source/blender/blenkernel/intern/pointcache.c | 137 ++++++++++++-------------- 1 file changed, 61 insertions(+), 76 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 1d58f276117..eb0601b413e 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -98,49 +98,43 @@ #define DURIAN_POINTCACHE_LIB_OK 1 int ptcache_data_size[] = { - sizeof(uint32_t), // BPHYS_DATA_INDEX - 3 * sizeof(float), // BPHYS_DATA_LOCATION: - 3 * sizeof(float), // BPHYS_DATA_VELOCITY: - 4 * sizeof(float), // BPHYS_DATA_ROTATION: - 3 * sizeof(float), // BPHYS_DATA_AVELOCITY: /* also BPHYS_DATA_XCONST */ - sizeof(float), // BPHYS_DATA_SIZE: - 3 * sizeof(float), // BPHYS_DATA_TIMES: - sizeof(BoidData) // case BPHYS_DATA_BOIDS: + sizeof(unsigned int), // BPHYS_DATA_INDEX + 3 * sizeof(float), // BPHYS_DATA_LOCATION + 3 * sizeof(float), // BPHYS_DATA_VELOCITY + 4 * sizeof(float), // BPHYS_DATA_ROTATION + 3 * sizeof(float), // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST + sizeof(float), // BPHYS_DATA_SIZE + 3 * sizeof(float), // BPHYS_DATA_TIMES + sizeof(BoidData) // case BPHYS_DATA_BOIDS }; /* forward declerations */ -static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, size_t len); -static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, size_t in_len, unsigned char *out, int mode); -static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, size_t size); -static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, size_t size); +static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, unsigned int len); +static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode); +static int ptcache_file_write(PTCacheFile *pf, void *f, unsigned int tot, unsigned int size); +static int ptcache_file_read(PTCacheFile *pf, void *f, unsigned int tot, unsigned int size); /* Common functions */ static int ptcache_basic_header_read(PTCacheFile *pf) { - uint32_t totpoint, data_types= 0; int error=0; /* Custom functions should read these basic elements too! */ - if(!error && !fread(&totpoint, sizeof(int), 1, pf->fp)) + if(!error && !fread(&pf->totpoint, sizeof(unsigned int), 1, pf->fp)) error = 1; - pf->totpoint = totpoint; - if(!error && !fread(&data_types, sizeof(int), 1, pf->fp)) + if(!error && !fread(&pf->data_types, sizeof(unsigned int), 1, pf->fp)) error = 1; - pf->data_types = data_types; return !error; } static int ptcache_basic_header_write(PTCacheFile *pf) { - uint32_t totpoint = pf->totpoint; - uint32_t data_types = pf->data_types; - /* Custom functions should write these basic elements too! */ - if(!fwrite(&totpoint, sizeof(int), 1, pf->fp)) + if(!fwrite(&pf->totpoint, sizeof(unsigned int), 1, pf->fp)) return 0; - if(!fwrite(&data_types, sizeof(int), 1, pf->fp)) + if(!fwrite(&pf->data_types, sizeof(unsigned int), 1, pf->fp)) return 0; return 1; @@ -969,7 +963,7 @@ static void ptcache_file_close(PTCacheFile *pf) } } -static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, size_t len) +static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, unsigned int len) { int r = 0; unsigned char compressed = 0; @@ -983,8 +977,8 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, ptcache_file_read(pf, &compressed, 1, sizeof(unsigned char)); if(compressed) { - uint32_t size; - ptcache_file_read(pf, &size, 1, sizeof(uint32_t)); + unsigned int size; + ptcache_file_read(pf, &size, 1, sizeof(unsigned int)); in_len = (size_t)size; if(in_len==0) { /* do nothing */ @@ -1017,7 +1011,7 @@ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, return r; } -static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, size_t in_len, unsigned char *out, int mode) +static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode) { int r = 0; unsigned char compressed = 0; @@ -1042,7 +1036,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, siz #ifdef WITH_LZMA if(mode == 2) { - r = LzmaCompress(out, (size_t *)&out_len, in, in_len,//assume sizeof(char)==1.... + r = LzmaCompress(out, &out_len, in, in_len,//assume sizeof(char)==1.... props, &sizeOfIt, 5, 1 << 24, 3, 0, 2, 32, 2); if(!(r == SZ_OK) || (out_len >= in_len)) @@ -1054,8 +1048,8 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, siz ptcache_file_write(pf, &compressed, 1, sizeof(unsigned char)); if(compressed) { - uint32_t size = (uint32_t) out_len; - ptcache_file_write(pf, &size, 1, sizeof(uint32_t)); + unsigned int size = out_len; + ptcache_file_write(pf, &size, 1, sizeof(unsigned int)); ptcache_file_write(pf, out, out_len, sizeof(unsigned char)); } else @@ -1063,19 +1057,20 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, siz if(compressed == 2) { - ptcache_file_write(pf, &sizeOfIt, 1, sizeof(uint32_t)); - ptcache_file_write(pf, props, sizeOfIt, sizeof(unsigned char)); + unsigned int size = sizeOfIt; + ptcache_file_write(pf, &sizeOfIt, 1, sizeof(unsigned int)); + ptcache_file_write(pf, props, size, sizeof(unsigned char)); } MEM_freeN(props); return r; } -static int ptcache_file_read(PTCacheFile *pf, void *f, size_t tot, size_t size) +static int ptcache_file_read(PTCacheFile *pf, void *f, unsigned int tot, unsigned int size) { return (fread(f, size, tot, pf->fp) == tot); } -static int ptcache_file_write(PTCacheFile *pf, void *f, size_t tot, size_t size) +static int ptcache_file_write(PTCacheFile *pf, void *f, unsigned int tot, unsigned int size) { return (fwrite(f, size, tot, pf->fp) == tot); } @@ -1103,7 +1098,7 @@ static int ptcache_file_data_write(PTCacheFile *pf) } static int ptcache_file_header_begin_read(PTCacheFile *pf) { - uint32_t typeflag=0; + unsigned int typeflag=0; int error=0; char bphysics[8]; @@ -1115,7 +1110,7 @@ static int ptcache_file_header_begin_read(PTCacheFile *pf) if(!error && strncmp(bphysics, "BPHYSICS", 8)) error = 1; - if(!error && !fread(&typeflag, sizeof(uint32_t), 1, pf->fp)) + if(!error && !fread(&typeflag, sizeof(unsigned int), 1, pf->fp)) error = 1; pf->type = (typeflag & PTCACHE_TYPEFLAG_TYPEMASK); @@ -1130,12 +1125,12 @@ static int ptcache_file_header_begin_read(PTCacheFile *pf) static int ptcache_file_header_begin_write(PTCacheFile *pf) { const char *bphysics = "BPHYSICS"; - uint32_t typeflag = pf->type + pf->flag; + unsigned int typeflag = pf->type + pf->flag; if(fwrite(bphysics, sizeof(char), 8, pf->fp) != 8) return 0; - if(!fwrite(&typeflag, sizeof(uint32_t), 1, pf->fp)) + if(!fwrite(&typeflag, sizeof(unsigned int), 1, pf->fp)) return 0; return 1; @@ -1162,26 +1157,25 @@ static void ptcache_file_pointers_init(PTCacheFile *pf) } /* Check to see if point number "index" is in pm, uses binary search for index data. */ -int BKE_ptcache_mem_index_find(PTCacheMem *pm, int index) +int BKE_ptcache_mem_index_find(PTCacheMem *pm, unsigned int index) { if(pm->data[BPHYS_DATA_INDEX]) { - uint32_t key = index; - uint32_t *data = pm->data[BPHYS_DATA_INDEX]; - uint32_t mid, low = 0, high = pm->totpoint - 1; + unsigned int *data = pm->data[BPHYS_DATA_INDEX]; + unsigned int mid, low = 0, high = pm->totpoint - 1; - if(key < *data || key > *(data+high)) + if(index < *data || index > *(data+high)) return -1; /* check simple case for continuous indexes first */ - if(data[key-*data]==key) - return key-*data; + if(data[index-*data]==index) + return index-*data; while(low <= high) { mid= (low + high)/2; - if(data[mid] > key) + if(data[mid] > index) high = mid - 1; - else if(data[mid] < key) + else if(data[mid] < index) low = mid + 1; else return mid; @@ -1284,7 +1278,7 @@ static int ptcache_old_elemsize(PTCacheID *pid) return 0; } -static void ptcache_find_frames_around(PTCacheID *pid, int frame, int *fra1, int *fra2) +static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *fra1, int *fra2) { if(pid->cache->flag & PTCACHE_DISK_CACHE) { int cfra1=frame-1, cfra2=frame+1; @@ -1339,7 +1333,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) { PTCacheFile *pf = ptcache_file_open(pid, PTCACHE_FILE_READ, cfra); PTCacheMem *pm = NULL; - int i, error = 0; + unsigned int i, error = 0; if(pf == NULL) return 0; @@ -1382,20 +1376,16 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) } if(!error && pf->flag & PTCACHE_TYPEFLAG_EXTRADATA) { - uint32_t extratype = 0; - uint32_t value; + unsigned int extratype = 0; - while(ptcache_file_read(pf, &extratype, 1, sizeof(uint32_t))) { + while(ptcache_file_read(pf, &extratype, 1, sizeof(unsigned int))) { PTCacheExtra *extra = MEM_callocN(sizeof(PTCacheExtra), "Pointcache extradata"); extra->type = extratype; - ptcache_file_read(pf, &value, 1, sizeof(uint32_t)); - extra->flag = value; - ptcache_file_read(pf, &value, 1, sizeof(uint32_t)); - extra->totdata = value; - ptcache_file_read(pf, &value, 1, sizeof(uint32_t)); - extra->datasize = value; + ptcache_file_read(pf, &extra->flag, 1, sizeof(unsigned int)); + ptcache_file_read(pf, &extra->totdata, 1, sizeof(unsigned int)); + ptcache_file_read(pf, &extra->datasize, 1, sizeof(unsigned int)); extra->data = MEM_callocN(extra->totdata * extra->datasize, "Pointcache extradata->data"); @@ -1425,7 +1415,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) { PTCacheFile *pf = NULL; - int i, error = 0; + unsigned int i, error = 0; BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_FRAME, pm->frame); @@ -1479,20 +1469,15 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) if(!error && pm->extradata.first) { PTCacheExtra *extra = pm->extradata.first; - uint32_t value; for(; extra; extra=extra->next) { if(extra->data == NULL || extra->totdata == 0) continue; - value = extra->type; - ptcache_file_write(pf, &value, 1, sizeof(uint32_t)); - value = extra->flag; - ptcache_file_write(pf, &value, 1, sizeof(uint32_t)); - value = extra->totdata; - ptcache_file_write(pf, &value, 1, sizeof(uint32_t)); - value = extra->datasize; - ptcache_file_write(pf, &value, 1, sizeof(uint32_t)); + ptcache_file_write(pf, &extra->type, 1, sizeof(unsigned int)); + ptcache_file_write(pf, &extra->flag, 1, sizeof(unsigned int)); + ptcache_file_write(pf, &extra->totdata, 1, sizeof(unsigned int)); + ptcache_file_write(pf, &extra->datasize, 1, sizeof(unsigned int)); if(pid->cache->compression) { unsigned int in_len = extra->totdata * extra->datasize; @@ -1868,7 +1853,7 @@ static int ptcache_write_needed(PTCacheID *pid, int cfra, int *overwrite) return 0; } /* writes cache to disk or memory */ -int BKE_ptcache_write(PTCacheID *pid, int cfra) +int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra) { PointCache *cache = pid->cache; int totpoint = pid->totpoint(pid->calldata, cfra); @@ -1909,10 +1894,10 @@ int BKE_ptcache_write(PTCacheID *pid, int cfra) */ /* Clears & resets */ -void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) +void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) { - int len; /* store the length of the string */ - int sta, end; + unsigned int len; /* store the length of the string */ + unsigned int sta, end; /* mode is same as fopen's modes */ DIR *dir; @@ -1961,7 +1946,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, int cfra) BLI_delete(path_full, 0, 0); } else { /* read the number of the file */ - int frame, len2 = (int)strlen(de->d_name); + unsigned int frame, len2 = (int)strlen(de->d_name); char num[7]; if (len2 > 15) { /* could crash if trying to copy a string out of this range*/ @@ -2126,8 +2111,8 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra } if(cache->cached_frames==NULL && cache->endframe > cache->startframe) { - int sta=cache->startframe; - int end=cache->endframe; + unsigned int sta=cache->startframe; + unsigned int end=cache->endframe; cache->cached_frames = MEM_callocN(sizeof(char) * (cache->endframe-cache->startframe+1), "cached frames array"); @@ -2138,7 +2123,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra char path[MAX_PTCACHE_PATH]; char filename[MAX_PTCACHE_FILE]; char ext[MAX_PTCACHE_PATH]; - int len; /* store the length of the string */ + unsigned int len; /* store the length of the string */ ptcache_path(pid, path); @@ -2154,7 +2139,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra if (strstr(de->d_name, ext)) { /* do we have the right extension?*/ if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */ /* read the number of the file */ - int frame, len2 = (int)strlen(de->d_name); + unsigned int frame, len2 = (int)strlen(de->d_name); char num[7]; if (len2 > 15) { /* could crash if trying to copy a string out of this range*/ -- cgit v1.2.3 From 9231ff41604039ca55f1da4945a077cfab9e1e84 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 9 Jan 2011 19:09:41 +0000 Subject: Viscoelastic springs for sph particle fluids, original patch by Stephen Whitehorn (chickencoop) * Viscoelastic springs between the fluid particles can simulate all kinds of viscous and elastic substances, such as jelly and honey. This is achieved by creating springs dynamically between neighboring particles and adjusting their rest length based on stretching/compression. * This nearly completes the currently intended functionality for particle fluids. The last missing thing is a surfacing extraction algorithm, which is needed for a proper representation of a sph fluid. * I also cleaned up and renamed some of the fluid parameters to make the ui a bit easier to understand. * One addition to the patch is an option to use "initial rest length" for the springs, which uses the lengths between the particles at the time of spring creation as the spring rest lengths instead of interaction radius/2. This makes the fluid keep it's original shape better (good for very viscoelastic materials), but can create large density differences inside the fluid (not really physically correct for a fluid). * Viscoelastic springs are stored in point cache as extra data. --- source/blender/blenkernel/intern/particle.c | 3 + source/blender/blenkernel/intern/particle_system.c | 178 ++++++++++++++++++--- source/blender/blenkernel/intern/pointcache.c | 70 ++++++-- 3 files changed, 221 insertions(+), 30 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 26f96d0c304..279190b9f9c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -561,6 +561,9 @@ void psys_free(Object *ob, ParticleSystem * psys) BLI_freelistN(&psys->targets); BLI_kdtree_free(psys->tree); + + if(psys->fluid_springs) + MEM_freeN(psys->fluid_springs); pdEndEffectors(&psys->effectors); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 3534a7dba37..fac79270bc1 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -54,6 +54,7 @@ #include "DNA_ipo_types.h" // XXX old animation system stuff... to be removed! #include "DNA_listBase.h" +#include "BLI_edgehash.h" #include "BLI_rand.h" #include "BLI_jitter.h" #include "BLI_math.h" @@ -182,6 +183,13 @@ void psys_reset(ParticleSystem *psys, int mode) /* reset point cache */ BKE_ptcache_invalidate(psys->pointcache); + + if(psys->fluid_springs) { + MEM_freeN(psys->fluid_springs); + psys->fluid_springs = NULL; + } + + psys->tot_fluidsprings = psys->alloc_fluidsprings = 0; } static void realloc_particles(ParticleSimulationData *sim, int new_totpart) @@ -2228,32 +2236,79 @@ static void psys_update_effectors(ParticleSimulationData *sim) Presented at Siggraph, (2005) ***********************************************************************************************************/ -static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData *pa, float dtime, float mass, float *gravity) +#define PSYS_FLUID_SPRINGS_INITIAL_SIZE 256 +ParticleSpring *add_fluid_spring(ParticleSystem *psys, ParticleSpring *spring) +{ + /* Are more refs required? */ + if(psys->alloc_fluidsprings == 0 || psys->fluid_springs == NULL) { + psys->alloc_fluidsprings = PSYS_FLUID_SPRINGS_INITIAL_SIZE; + psys->fluid_springs = (ParticleSpring*)MEM_callocN(psys->alloc_fluidsprings * sizeof(ParticleSpring), "Particle Fluid Springs"); + } + else if(psys->tot_fluidsprings == psys->alloc_fluidsprings) { + /* Double the number of refs allocated */ + psys->alloc_fluidsprings *= 2; + psys->fluid_springs = (ParticleSpring*)MEM_reallocN(psys->fluid_springs, psys->alloc_fluidsprings * sizeof(ParticleSpring)); + } + + memcpy(psys->fluid_springs + psys->tot_fluidsprings, spring, sizeof(ParticleSpring)); + psys->tot_fluidsprings++; + + return psys->fluid_springs + psys->tot_fluidsprings - 1; +} + +void delete_fluid_spring(ParticleSystem *psys, int j) +{ + if (j != psys->tot_fluidsprings - 1) + psys->fluid_springs[j] = psys->fluid_springs[psys->tot_fluidsprings - 1]; + + psys->tot_fluidsprings--; + + if (psys->tot_fluidsprings < psys->alloc_fluidsprings/2 && psys->alloc_fluidsprings > PSYS_FLUID_SPRINGS_INITIAL_SIZE){ + psys->alloc_fluidsprings /= 2; + psys->fluid_springs = (ParticleSpring*)MEM_reallocN(psys->fluid_springs, psys->alloc_fluidsprings * sizeof(ParticleSpring)); + } +} + +EdgeHash *build_fluid_springhash(ParticleSystem *psys) +{ + EdgeHash *springhash = NULL; + ParticleSpring *spring = psys->fluid_springs; + int i = 0; + + springhash = BLI_edgehash_new(); + + for(i=0, spring=psys->fluid_springs; itot_fluidsprings; i++, spring++) + BLI_edgehash_insert(springhash, spring->particle_index[0], spring->particle_index[1], SET_INT_IN_POINTER(i+1)); + + return springhash; +} +static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData *pa, float dtime, float mass, float *gravity, EdgeHash *springhash) { SPHFluidSettings *fluid = psys->part->fluid; KDTreeNearest *ptn = NULL; ParticleData *npa; + ParticleSpring *spring = NULL; float temp[3]; - float q, q1, u, I, D; + float q, q1, u, I, D, rij, d, Lij; float pressure_near, pressure; float p=0, pnear=0; - float radius = fluid->radius; float omega = fluid->viscosity_omega; float beta = fluid->viscosity_beta; float massfactor = 1.0f/mass; float spring_k = fluid->spring_k; - float L = fluid->rest_length; + float h = fluid->radius; + float L = fluid->rest_length * fluid->radius; - int n, neighbours = BLI_kdtree_range_search(psys->tree, radius, pa->prev_state.co, NULL, &ptn); - int index = own_psys ? pa - psys->particles : -1; + int n, neighbours = BLI_kdtree_range_search(psys->tree, h, pa->prev_state.co, NULL, &ptn); + int spring_index = 0, index = own_psys ? pa - psys->particles : -1; /* pressure and near pressure */ for(n=own_psys?1:0; nprev_state.co); mul_v3_fl(ptn[n].co, 1.f/ptn[n].dist); - q = ptn[n].dist/radius; + q = ptn[n].dist/h; if(q < 1.f) { q1 = 1.f - q; @@ -2272,7 +2327,8 @@ static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData * for(n=own_psys?1:0; nparticles + ptn[n].index; - q = ptn[n].dist/radius; + rij = ptn[n].dist; + q = rij/h; q1 = 1.f-q; /* Double Density Relaxation - Algorithm 2 (can't be thread safe!)*/ @@ -2296,14 +2352,40 @@ static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData * } } - /* Hooke's spring force */ if(spring_k > 0.f) { - /* L is a factor of radius */ - D = 0.5 * dtime * dtime * 10.f * fluid->spring_k * (1.f - L) * (L - q); + /* Viscoelastic spring force - Algorithm 4*/ + if (fluid->flag & SPH_VISCOELASTIC_SPRINGS && springhash){ + spring_index = GET_INT_FROM_POINTER(BLI_edgehash_lookup(springhash, index, ptn[n].index)); + + if(spring_index) { + spring = psys->fluid_springs + spring_index - 1; + } + else { + ParticleSpring temp_spring; + temp_spring.particle_index[0] = index; + temp_spring.particle_index[1] = ptn[n].index; + temp_spring.rest_length = (fluid->flag & SPH_CURRENT_REST_LENGTH) ? rij : L; + temp_spring.delete_flag = 0; + + spring = add_fluid_spring(psys, &temp_spring); + } + + Lij = spring->rest_length; + d = fluid->yield_ratio * Lij; - madd_v3_v3fl(pa->state.co, ptn[n].co, -D * massfactor); - if(own_psys) - madd_v3_v3fl(npa->state.co, ptn[n].co, D * massfactor); + if (rij > Lij + d) // Stretch, 25 is just a multiplier for plasticity_constant value to counter default dtime of 1/25 + spring->rest_length += dtime * 25.f * fluid->plasticity_constant * (rij - Lij - d); + else if(rij < Lij - d) // Compress + spring->rest_length -= dtime * 25.f * fluid->plasticity_constant * (Lij - d - rij); + } + else { /* PART_SPRING_HOOKES - Hooke's spring force */ + /* L is a factor of radius */ + D = 0.5 * dtime * dtime * 10.f * fluid->spring_k * (1.f - L/h) * (L - rij); + + madd_v3_v3fl(pa->state.co, ptn[n].co, -D * massfactor); + if(own_psys) + madd_v3_v3fl(npa->state.co, ptn[n].co, D * massfactor); + } } } } @@ -2318,21 +2400,63 @@ static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData * MEM_freeN(ptn); } -static void apply_particle_fluidsim(Object *ob, ParticleSystem *psys, ParticleData *pa, float dtime, float *gravity){ +static void apply_particle_fluidsim(Object *ob, ParticleSystem *psys, ParticleData *pa, float dtime, float *gravity, EdgeHash *springhash){ ParticleTarget *pt; - particle_fluidsim(psys, 1, pa, dtime, psys->part->mass, gravity); + particle_fluidsim(psys, 1, pa, dtime, psys->part->mass, gravity, springhash); /*----check other SPH systems (Multifluids) , each fluid has its own parameters---*/ for(pt=psys->targets.first; pt; pt=pt->next) { ParticleSystem *epsys = psys_get_target_system(ob, pt); if(epsys) - particle_fluidsim(epsys, 0, pa, dtime, psys->part->mass, gravity); + particle_fluidsim(epsys, 0, pa, dtime, psys->part->mass, gravity, NULL); } /*----------------------------------------------------------------*/ } +static void apply_fluid_springs(ParticleSystem *psys, ParticleSettings *part, float timestep){ + SPHFluidSettings *fluid = psys->part->fluid; + ParticleData *pa1, *pa2; + ParticleSpring *spring = psys->fluid_springs; + + float h = fluid->radius; + float massfactor = 1.0f/psys->part->mass; + float D, Rij[3], rij, Lij; + int i; + + if((fluid->flag & SPH_VISCOELASTIC_SPRINGS)==0 || fluid->spring_k == 0.f) + return; + + /* Loop through the springs */ + for(i=0; itot_fluidsprings; i++, spring++) { + Lij = spring->rest_length; + + if (Lij > h) { + spring->delete_flag = 1; + } + else { + pa1 = psys->particles + spring->particle_index[0]; + pa2 = psys->particles + spring->particle_index[1]; + + sub_v3_v3v3(Rij, pa2->prev_state.co, pa1->prev_state.co); + rij = normalize_v3(Rij); + + /* Calculate displacement and apply value */ + D = 0.5f * timestep * timestep * 10.f * fluid->spring_k * (1.f - Lij/h) * (Lij - rij); + + madd_v3_v3fl(pa1->state.co, Rij, -D * pa1->state.time * pa1->state.time * massfactor); + madd_v3_v3fl(pa2->state.co, Rij, D * pa2->state.time * pa2->state.time * massfactor); + } + } + + /* Loop through springs backwaqrds - for efficient delete function */ + for (i=psys->tot_fluidsprings-1; i >= 0; i--) { + if(psys->fluid_springs[i].delete_flag) + delete_fluid_spring(psys, i); + } +} + /************************************************/ /* Newtonian physics */ /************************************************/ @@ -3420,6 +3544,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) } case PART_PHYS_FLUID: { + EdgeHash *springhash = build_fluid_springhash(psys); float *gravity = NULL; if(psys_uses_gravity(sim)) @@ -3434,9 +3559,12 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) /* actual fluids calculations (not threadsafe!) */ LOOP_DYNAMIC_PARTICLES { - apply_particle_fluidsim(sim->ob, psys, pa, pa->state.time*timestep, gravity); + apply_particle_fluidsim(sim->ob, psys, pa, pa->state.time*timestep, gravity, springhash); } + /* Apply springs to particles */ + apply_fluid_springs(psys, part, timestep); + /* apply velocity, collisions and rotation */ LOOP_DYNAMIC_PARTICLES { /* velocity holds forces and viscosity, so apply them before collisions */ @@ -3452,6 +3580,11 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) /* SPH particles are not physical particles, just interpolation particles, thus rotation has not a direct sense for them */ rotate_particle(part, pa, pa->state.time, timestep); } + + if(springhash) { + BLI_edgehash_free(springhash, NULL); + springhash = NULL; + } break; } } @@ -3696,6 +3829,13 @@ static void system_step(ParticleSimulationData *sim, float cfra) /* reset only just created particles (on startframe all particles are recreated) */ reset_all_particles(sim, 0.0, cfra, oldtotpart); + if (psys->fluid_springs) { + MEM_freeN(psys->fluid_springs); + psys->fluid_springs = NULL; + } + + psys->tot_fluidsprings = psys->alloc_fluidsprings = 0; + /* flag for possible explode modifiers after this system */ sim->psmd->flag |= eParticleSystemFlag_Pars; @@ -3851,6 +3991,8 @@ static void fluid_default_settings(ParticleSettings *part){ fluid->radius = 0.5f; fluid->spring_k = 0.f; + fluid->plasticity_constant = 0.1f; + fluid->yield_ratio = 0.1f; fluid->rest_length = 0.5f; fluid->viscosity_omega = 2.f; fluid->viscosity_beta = 0.f; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index eb0601b413e..5408e57f10d 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -390,6 +390,48 @@ static int ptcache_particle_totwrite(void *psys_v, int cfra) return totwrite; } +static void ptcache_particle_extra_write(void *psys_v, PTCacheMem *pm, int UNUSED(cfra)) +{ + ParticleSystem *psys = psys_v; + PTCacheExtra *extra = NULL; + + if(psys->part->phystype == PART_PHYS_FLUID && + psys->part->fluid && psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS && + psys->tot_fluidsprings && psys->fluid_springs) { + + extra = MEM_callocN(sizeof(PTCacheExtra), "Point cache: fluid extra data"); + + extra->type = BPHYS_EXTRA_FLUID_SPRINGS; + extra->totdata = psys->tot_fluidsprings; + + extra->data = MEM_callocN(extra->totdata * ptcache_extra_datasize[extra->type], "Point cache: extra data"); + memcpy(extra->data, psys->fluid_springs, extra->totdata * ptcache_extra_datasize[extra->type]); + + BLI_addtail(&pm->extradata, extra); + } +} + +static int ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float UNUSED(cfra)) +{ + ParticleSystem *psys = psys_v; + PTCacheExtra *extra = pm->extradata.first; + + for(; extra; extra=extra->next) { + switch(extra->type) { + case BPHYS_EXTRA_FLUID_SPRINGS: + { + if(psys->fluid_springs) + MEM_freeN(psys->fluid_springs); + + psys->fluid_springs = MEM_dupallocN(extra->data); + psys->tot_fluidsprings = psys->alloc_fluidsprings = extra->totdata; + break; + } + } + } + return 1; +} + /* Cloth functions */ static int ptcache_cloth_write(int index, void *cloth_v, void **data, int UNUSED(cfra)) { @@ -667,6 +709,10 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p if(psys->part->phystype == PART_PHYS_BOIDS) pid->data_types|= (1<part->phystype == PART_PHYS_FLUID && psys->part->fluid && psys->part->fluid->flag & SPH_VISCOELASTIC_SPRINGS) { + pid->write_extra_data = ptcache_particle_extra_write; + pid->read_extra_data = ptcache_particle_extra_read; + } if(psys->part->rotmode!=PART_ROT_VEL || psys->part->avemode!=PART_AVE_SPIN || psys->part->avefac!=0.0f) @@ -1261,9 +1307,13 @@ static void ptcache_extra_free(PTCacheMem *pm) { PTCacheExtra *extra = pm->extradata.first; - for(; extra; extra=extra->next) { - if(extra->data) - MEM_freeN(extra->data); + if(extra) { + for(; extra; extra=extra->next) { + if(extra->data) + MEM_freeN(extra->data); + } + + BLI_freelistN(&pm->extradata); } } static int ptcache_old_elemsize(PTCacheID *pid) @@ -1383,16 +1433,14 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) extra->type = extratype; - ptcache_file_read(pf, &extra->flag, 1, sizeof(unsigned int)); ptcache_file_read(pf, &extra->totdata, 1, sizeof(unsigned int)); - ptcache_file_read(pf, &extra->datasize, 1, sizeof(unsigned int)); - extra->data = MEM_callocN(extra->totdata * extra->datasize, "Pointcache extradata->data"); + extra->data = MEM_callocN(extra->totdata * ptcache_extra_datasize[extra->type], "Pointcache extradata->data"); if(pf->flag & PTCACHE_TYPEFLAG_COMPRESS) - ptcache_file_compressed_read(pf, (unsigned char*)(extra->data), extra->totdata*extra->datasize); + ptcache_file_compressed_read(pf, (unsigned char*)(extra->data), extra->totdata*ptcache_extra_datasize[extra->type]); else - ptcache_file_read(pf, extra->data, extra->totdata, extra->datasize); + ptcache_file_read(pf, extra->data, extra->totdata, ptcache_extra_datasize[extra->type]); BLI_addtail(&pm->extradata, extra); } @@ -1475,18 +1523,16 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) continue; ptcache_file_write(pf, &extra->type, 1, sizeof(unsigned int)); - ptcache_file_write(pf, &extra->flag, 1, sizeof(unsigned int)); ptcache_file_write(pf, &extra->totdata, 1, sizeof(unsigned int)); - ptcache_file_write(pf, &extra->datasize, 1, sizeof(unsigned int)); if(pid->cache->compression) { - unsigned int in_len = extra->totdata * extra->datasize; + unsigned int in_len = extra->totdata * ptcache_extra_datasize[extra->type]; unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer"); ptcache_file_compressed_write(pf, (unsigned char*)(extra->data), in_len, out, pid->cache->compression); MEM_freeN(out); } else { - ptcache_file_write(pf, extra->data, extra->totdata, extra->datasize); + ptcache_file_write(pf, extra->data, extra->totdata, ptcache_extra_datasize[extra->type]); } } } -- cgit v1.2.3 From 83806d40429f3c847a3265cdb1cfe20bf6b08c3d Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 10 Jan 2011 02:20:30 +0000 Subject: Bug fix: particles dying in collisions could lead to crash in some cases * Forgot to check for index range in own recent pointcache commit. --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 5408e57f10d..c4f1690e474 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1213,7 +1213,7 @@ int BKE_ptcache_mem_index_find(PTCacheMem *pm, unsigned int index) return -1; /* check simple case for continuous indexes first */ - if(data[index-*data]==index) + if(index-*data < high && data[index-*data] == index) return index-*data; while(low <= high) { -- cgit v1.2.3 From d9c6f51ee25e4c3d56a9e06fb8e544f230174744 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 10 Jan 2011 02:40:24 +0000 Subject: Compiler warning fixes for the same point cache things Joshua tried to fix earlier, don't know why I didn't notice these before. --- source/blender/blenkernel/intern/pointcache.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index c4f1690e474..6b3584c1832 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -97,7 +97,7 @@ /* could be made into a pointcache option */ #define DURIAN_POINTCACHE_LIB_OK 1 -int ptcache_data_size[] = { +static int ptcache_data_size[] = { sizeof(unsigned int), // BPHYS_DATA_INDEX 3 * sizeof(float), // BPHYS_DATA_LOCATION 3 * sizeof(float), // BPHYS_DATA_VELOCITY @@ -108,6 +108,11 @@ int ptcache_data_size[] = { sizeof(BoidData) // case BPHYS_DATA_BOIDS }; +static int ptcache_extra_datasize[] = { + 0, + sizeof(ParticleSpring) +}; + /* forward declerations */ static int ptcache_file_compressed_read(PTCacheFile *pf, unsigned char *result, unsigned int len); static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, unsigned int in_len, unsigned char *out, int mode); -- cgit v1.2.3 From a9faad8b37b0b3eedc803f2a4d400b8f2af5e6dc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 10 Jan 2011 03:55:47 +0000 Subject: comment unused vars from subsurf code. --- source/blender/blenkernel/intern/subsurf_ccg.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (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 e139820be32..e75dc27c7b5 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -314,7 +314,7 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, CCGFace **faceMap; MTFace *tf; CCGFaceIterator *fi; - int index, gridSize, gridFaces, edgeSize, totface, x, y, S; + int index, gridSize, gridFaces, /*edgeSize,*/ totface, x, y, S; MTFace *dmtface = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, n); MTFace *tface = CustomData_get_layer_n(&result->faceData, CD_MTFACE, n); @@ -331,7 +331,7 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, /* get some info from CCGSubSurf */ totface = ccgSubSurf_getNumFaces(uvss); - edgeSize = ccgSubSurf_getEdgeSize(uvss); + /* edgeSize = ccgSubSurf_getEdgeSize(uvss); */ /*UNUSED*/ gridSize = ccgSubSurf_getGridSize(uvss); gridFaces = gridSize - 1; @@ -689,7 +689,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med) /* this edge comes from face data */ int lastface = ccgSubSurf_getNumFaces(ss) - 1; CCGFace *f; - int x, y, grid, numVerts; + int x, y, grid /*, numVerts*/; int offset; int gridSize = ccgSubSurf_getGridSize(ss); int edgeSize = ccgSubSurf_getEdgeSize(ss); @@ -701,7 +701,7 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med) ++i; f = ccgdm->faceMap[i].face; - numVerts = ccgSubSurf_getFaceNumVerts(f); + /* numVerts = ccgSubSurf_getFaceNumVerts(f); */ /*UNUSED*/ gridSideEdges = gridSize - 1; gridInternalEdges = (gridSideEdges - 1) * gridSideEdges * 2; @@ -766,7 +766,7 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf) int gridFaces = gridSideEdges * gridSideEdges; int i; CCGFace *f; - int numVerts; + /*int numVerts;*/ int offset; int grid; int x, y; @@ -780,7 +780,7 @@ static void ccgDM_getFinalFace(DerivedMesh *dm, int faceNum, MFace *mf) ++i; f = ccgdm->faceMap[i].face; - numVerts = ccgSubSurf_getFaceNumVerts(f); + /*numVerts = ccgSubSurf_getFaceNumVerts(f);*/ /*UNUSED*/ offset = faceNum - ccgdm->faceMap[i].startFace; grid = offset / gridFaces; @@ -2147,14 +2147,14 @@ static void ccgdm_create_grids(DerivedMesh *dm) DMGridAdjacency *gridAdjacency, *adj; CCGFace **gridFaces; int *gridOffset; - int index, numFaces, numGrids, S, gIndex, gridSize; + int index, numFaces, numGrids, S, gIndex /*, gridSize*/; if(ccgdm->gridData) return; numGrids = ccgDM_getNumGrids(dm); numFaces = ccgSubSurf_getNumFaces(ss); - gridSize = ccgDM_getGridSize(dm); + /*gridSize = ccgDM_getGridSize(dm);*/ /*UNUSED*/ /* compute offset into grid array for each face */ gridOffset = MEM_mallocN(sizeof(int)*numFaces, "ccgdm.gridOffset"); @@ -2333,7 +2333,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, int edgeSize; int gridSize; int gridFaces; - int gridSideVerts; + /*int gridSideVerts;*/ int gridSideEdges; int gridInternalEdges; MEdge *medge = NULL; @@ -2431,8 +2431,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, edgeSize = ccgSubSurf_getEdgeSize(ss); gridSize = ccgSubSurf_getGridSize(ss); gridFaces = gridSize - 1; - gridSideVerts = gridSize - 2; - /*gridInternalVerts = gridSideVerts * gridSideVerts; - as yet, unused */ + /*gridSideVerts = gridSize - 2;*/ /*UNUSED*/ + /*gridInternalVerts = gridSideVerts * gridSideVerts; */ /*UNUSED*/ gridSideEdges = gridSize - 1; gridInternalEdges = (gridSideEdges - 1) * gridSideEdges * 2; -- cgit v1.2.3 From ede0d855229713ee383d114cf3c6fecc4ff30464 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 10 Jan 2011 03:58:07 +0000 Subject: comment/remove various unused vars, also make rna function for new images require width and hight args. --- source/blender/blenkernel/intern/curve.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 13a53629d9b..2678b077b66 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1746,7 +1746,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) if(bl->poly== -1) { /* check its not cyclic */ /* skip the first point */ - bevp0= bevp1; + /* bevp0= bevp1; */ bevp1= bevp2; bevp2++; nr--; @@ -1777,7 +1777,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) normalize_qt(bevp1->quat); - bevp0= bevp1; + /* bevp0= bevp1; */ /* UNUSED */ bevp1= bevp2; bevp2++; } @@ -1956,7 +1956,7 @@ static void make_bevel_list_3D_tangent(BevList *bl) normalize_v3(cross_tmp); tri_to_quat( bevp1->quat,zero, cross_tmp, bevp1->tan); /* XXX - could be faster */ - bevp0= bevp1; + /* bevp0= bevp1; */ /* UNUSED */ bevp1= bevp2; bevp2++; } -- cgit v1.2.3 From 5feb46d8146f7f00fca02d575e489ec880ca15e0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 10 Jan 2011 05:17:53 +0000 Subject: callback function ptcache_particle_extra_read() was incorrect type, also fix some other compiler warnings with recent commits. --- source/blender/blenkernel/intern/particle_system.c | 4 ++-- source/blender/blenkernel/intern/pointcache.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (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 fac79270bc1..4cfcad4dbb6 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2415,7 +2415,7 @@ static void apply_particle_fluidsim(Object *ob, ParticleSystem *psys, ParticleDa /*----------------------------------------------------------------*/ } -static void apply_fluid_springs(ParticleSystem *psys, ParticleSettings *part, float timestep){ +static void apply_fluid_springs(ParticleSystem *psys, float timestep){ SPHFluidSettings *fluid = psys->part->fluid; ParticleData *pa1, *pa2; ParticleSpring *spring = psys->fluid_springs; @@ -3563,7 +3563,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) } /* Apply springs to particles */ - apply_fluid_springs(psys, part, timestep); + apply_fluid_springs(psys, timestep); /* apply velocity, collisions and rotation */ LOOP_DYNAMIC_PARTICLES { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 6b3584c1832..37ce6c94eb7 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -416,7 +416,7 @@ static void ptcache_particle_extra_write(void *psys_v, PTCacheMem *pm, int UNUSE } } -static int ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float UNUSED(cfra)) +static void ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float UNUSED(cfra)) { ParticleSystem *psys = psys_v; PTCacheExtra *extra = pm->extradata.first; @@ -434,7 +434,6 @@ static int ptcache_particle_extra_read(void *psys_v, PTCacheMem *pm, float UNUSE } } } - return 1; } /* Cloth functions */ -- cgit v1.2.3 From fded5e5ce5451a10055f615a0d4c83d902aac107 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Jan 2011 07:38:16 +0000 Subject: comment/remove unused vars from particle and multires code. also remove calls to dm->getFaceDataArray() within a loop for particle grid distribution, instead call this once at the start and reuse the result. --- source/blender/blenkernel/intern/multires.c | 10 ++----- source/blender/blenkernel/intern/particle.c | 7 +++-- source/blender/blenkernel/intern/particle_system.c | 34 ++++++++++------------ 3 files changed, 22 insertions(+), 29 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 6c1b8fb6047..ed0b1bfceca 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1299,7 +1299,6 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) unsigned int i, j, totvert; src = 0; - dst = 0; vsrc = mr->verts; vdst = dm->getVertArray(dm); totvert = (unsigned int)dm->getNumVerts(dm); @@ -1428,7 +1427,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) dst = ldst; } - lvl = lvl->next; + /*lvl = lvl->next;*/ /*UNUSED*/ for(i = 0; i < (unsigned int)(mr->level_count - 1); ++i) { MEM_freeN(fmap[i]); @@ -1596,10 +1595,9 @@ void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) DMGridData **gridData, **subGridData; Mesh *me= (Mesh*)ob->data; MFace *mface= me->mface; - MVert *mvert= NULL; MDisps *mdisps; int *gridOffset; - int i, numGrids, gridSize, dGridSize, dSkip, totvert; + int i, /*numGrids,*/ gridSize, dGridSize, dSkip, totvert; float (*vertCos)[3] = NULL; MultiresModifierData *mmd= get_multires_modifier(scene, ob); MultiresModifierData high_mmd; @@ -1627,13 +1625,11 @@ void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) CDDM_apply_vert_coords(cddm, vertCos); MEM_freeN(vertCos); - mvert= cddm->getVertArray(cddm); - /* scaled ccgDM for tangent space of object with applied scale */ dm= subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0); cddm->release(cddm); - numGrids= dm->getNumGrids(dm); + /*numGrids= dm->getNumGrids(dm);*/ /*UNUSED*/ gridSize= dm->getGridSize(dm); gridData= dm->getGridData(dm); gridOffset= dm->getGridOffset(dm); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 279190b9f9c..db826b83864 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -197,7 +197,7 @@ void psys_set_current_num(Object *ob, int index) } Object *psys_find_object(Scene *scene, ParticleSystem *psys) { - Base *base = scene->base.first; + Base *base; ParticleSystem *tpsys; for(base = scene->base.first; base; base = base->next) { @@ -3953,7 +3953,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * float t, frs_sec = sim->scene->r.frs_sec; float co[3], orco[3]; float hairmat[4][4]; - int totparent = 0; + /*int totparent = 0;*/ /*UNUSED*/ int totpart = psys->totpart; int totchild = psys->totchild; short between = 0, edit = 0; @@ -4009,11 +4009,12 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * t = psys_get_child_time(psys, cpa, -state->time, NULL, NULL); if(totchild && part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){ +#if 0 /* totparent is UNUSED */ totparent=(int)(totchild*part->parents*0.3); if(G.rendering && part->child_nbr && part->ren_child_nbr) totparent*=(float)part->child_nbr/(float)part->ren_child_nbr; - +#endif /* part->parents could still be 0 so we can't test with totparent */ between=1; } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 4cfcad4dbb6..27adeaa2430 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -467,13 +467,13 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) else if(ELEM(from,PART_FROM_FACE,PART_FROM_VOLUME)){ float co1[3], co2[3]; - MFace *mface=0; + MFace *mface= NULL, *mface_array; float v1[3], v2[3], v3[3], v4[4], lambda; int a, a1, a2, a0mul, a1mul, a2mul, totface; int amax= from==PART_FROM_FACE ? 3 : 1; totface=dm->getNumFaces(dm); - mface=dm->getFaceDataArray(dm,CD_MFACE); + mface_array= dm->getFaceDataArray(dm,CD_MFACE); for(a=0; agetFaceDataArray(dm,CD_MFACE); + mface= mface_array; pa=psys->particles + a1*a1mul + a2*a2mul; VECCOPY(co1,pa->fuv); @@ -533,7 +533,7 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) } if(psys->part->flag & PART_GRID_INVERT){ - for(i=0,pa=psys->particles; iparticles + res*(i*res + j); for(k=0; ktree){ KDTreeNearest ptn[10]; int w,maxw;//, do_seams; - float maxd,mind,dd,totw=0.0; + float maxd,mind,/*dd,*/totw=0.0; int parent[10]; float pweight[10]; @@ -820,7 +820,7 @@ static void psys_thread_distribute_particle(ParticleThread *thread, ParticleData maxd=ptn[maxw-1].dist; mind=ptn[0].dist; - dd=maxd-mind; + /*dd=maxd-mind;*/ /*UNUSED*/ /* the weights here could be done better */ for(w=0; wdistr; - pa=psys->particles; + if(from==PART_FROM_VERT){ MVert *mv= dm->getVertDataArray(dm, CD_MVERT); float (*orcodata)[3]= dm->getVertDataArray(dm, CD_ORCO); @@ -1073,7 +1073,7 @@ static int psys_threads_init_distribution(ParticleThread *threads, Scene *scene, } if(tot==0){ - no_distr=1; + /*no_distr=1;*/ /*UNUSED*/ if(children){ if(G.f & G_DEBUG) fprintf(stderr,"Particle child distribution error: Nothing to emit from!\n"); @@ -2272,7 +2272,7 @@ void delete_fluid_spring(ParticleSystem *psys, int j) EdgeHash *build_fluid_springhash(ParticleSystem *psys) { EdgeHash *springhash = NULL; - ParticleSpring *spring = psys->fluid_springs; + ParticleSpring *spring; int i = 0; springhash = BLI_edgehash_new(); @@ -2469,7 +2469,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra ParticleKey states[5], tkey; float timestep = psys_get_timestep(sim); float force[3],impulse[3],dx[4][3],dv[4][3],oldpos[3]; - float dtime=dfra*timestep, time, pa_mass=part->mass, fac, fra=sim->psys->cfra; + float dtime=dfra*timestep, time, pa_mass=part->mass, fac /*, fra=sim->psys->cfra*/; int i, steps=1; /* maintain angular velocity */ @@ -2542,7 +2542,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra if(i==0){ VECADDFAC(states[1].co,states->co,states->vel,dtime*0.5f); VECADDFAC(states[1].vel,states->vel,force,dtime*0.5f); - fra=sim->psys->cfra+0.5f*dfra; + /*fra=sim->psys->cfra+0.5f*dfra;*/ } else{ VECADDFAC(pa->state.co,states->co,states[1].vel,dtime); @@ -2559,7 +2559,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra VECADDFAC(states[1].co,states->co,dx[0],0.5f); VECADDFAC(states[1].vel,states->vel,dv[0],0.5f); - fra=sim->psys->cfra+0.5f*dfra; + /*fra=sim->psys->cfra+0.5f*dfra;*/ break; case 1: VECADDFAC(dx[1],states->vel,dv[0],0.5f); @@ -2578,7 +2578,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra VECADD(states[3].co,states->co,dx[2]); VECADD(states[3].vel,states->vel,dv[2]); - fra=cfra; + /*fra=cfra;*/ break; case 3: VECADD(dx[3],states->vel,dv[2]); @@ -3353,15 +3353,12 @@ static void save_hair(ParticleSimulationData *sim, float UNUSED(cfra)){ ParticleSystem *psys = sim->psys; HairKey *key, *root; PARTICLE_P; - int totpart; invert_m4_m4(ob->imat, ob->obmat); psys->lattice= psys_get_lattice(sim); if(psys->totpart==0) return; - - totpart=psys->totpart; /* save new keys for elements if needed */ LOOP_PARTICLES { @@ -3684,7 +3681,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) char filename[256]; char debugStrBuffer[256]; int curFrame = sim->scene->r.cfra -1; // warning - sync with derived mesh fsmesh loading - int p, j, numFileParts, totpart; + int p, j, totpart; int readMask, activeParts = 0, fileParts = 0; gzFile gzf; @@ -3706,7 +3703,6 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) } gzread(gzf, &totpart, sizeof(totpart)); - numFileParts = totpart; totpart = (G.rendering)?totpart:(part->disp*totpart)/100; part->totpart= totpart; -- cgit v1.2.3 From 5bcee8cd0ad11f93cc067c3c251676e7c921ce74 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 11 Jan 2011 07:40:31 +0000 Subject: remove misc unused vars and correct theme name for face angles. --- source/blender/blenkernel/intern/sequencer.c | 11 ++++------- source/blender/blenkernel/intern/text.c | 1 - 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 5f25e419eec..9ffc04c5191 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -728,10 +728,8 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) if (sce) { seq->scene = sce; - } else { - sce = seq->scene; } - + seq->len= seq->scene->r.efra - seq->scene->r.sfra + 1; seq->len -= seq->anim_startofs; seq->len -= seq->anim_endofs; @@ -3386,7 +3384,6 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo Scene *scene= CTX_data_scene(C); /* only for active seq */ Sequence *seq; Strip *strip; - StripElem *se; seq = alloc_sequence(seqbasep, seq_load->start_frame, seq_load->channel); seq->type= SEQ_IMAGE; @@ -3397,7 +3394,7 @@ Sequence *sequencer_add_image_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo strip->len = seq->len = seq_load->len ? seq_load->len : 1; strip->us= 1; - strip->stripdata= se= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); + strip->stripdata= MEM_callocN(seq->len*sizeof(StripElem), "stripelem"); BLI_strncpy(strip->dir, seq_load->path, sizeof(strip->dir)); seq_load_apply(scene, seq, seq_load); @@ -3467,7 +3464,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo Scene *scene= CTX_data_scene(C); /* only for sound */ char path[sizeof(seq_load->path)]; - Sequence *seq, *soundseq; /* generic strip vars */ + Sequence *seq; /* generic strip vars */ Strip *strip; StripElem *se; @@ -3506,7 +3503,7 @@ Sequence *sequencer_add_movie_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo int start_frame_back= seq_load->start_frame; seq_load->channel++; - soundseq = sequencer_add_sound_strip(C, seqbasep, seq_load); + sequencer_add_sound_strip(C, seqbasep, seq_load); seq_load->start_frame= start_frame_back; seq_load->channel--; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 0b5347ca304..20492b99048 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2218,7 +2218,6 @@ static void txt_combine_lines (Text *text, TextLine *linea, TextLine *lineb) } while (mrk && mrk->lineno==lineno); } if (lineno==-1) lineno= txt_get_span(text->lines.first, lineb); - if (!mrk) mrk= text->markers.first; tmp= MEM_mallocN(linea->len+lineb->len+1, "textline_string"); -- cgit v1.2.3 From 37b903e32c90562eeefcd1d3f93aa7f725a9729f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 11 Jan 2011 22:06:44 +0000 Subject: Fix #25594: Adding mesh while in edit mode with multires - crash. That primitives, which used ri crash blender, flips normals just after creation and this normals flipping calls layers interpolation, but MDISPS layer contains no data still. Just added checking to layerInterp_mdisps. --- source/blender/blenkernel/intern/customdata.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 134b0e10280..57f66a37343 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -445,6 +445,10 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights), float (*sw)[4] = (void*)sub_weights; float (*disps)[3], (*out)[3]; + /* happens when flipping normals of newly created mesh */ + if(!d->totdisp) + return; + s = sources[0]; dst_corners = multires_mdisp_corners(d); src_corners = multires_mdisp_corners(s); -- cgit v1.2.3 From bbdf47aa0bd964be143ae03fb488ce13fa2228bd Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 12 Jan 2011 01:36:12 +0000 Subject: Patch [#24808] B-Bone display size Submitted by Dan Eicher (dna) Adds the ability to resize b-bones (ctrl+alt+S) using the python api Bone.bbone_x Bone.bbone_z --- 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 72466261e14..595614ef1e7 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1210,13 +1210,13 @@ void BKE_nlastrip_validate_fcurves (NlaStrip *strip) } } +/* Sanity Validation ------------------------------------ */ + static int nla_editbone_name_check(void *arg, const char *name) { return BLI_ghash_haskey((GHash *)arg, (void *)name); } -/* Sanity Validation ------------------------------------ */ - /* Find (and set) a unique name for a strip from the whole AnimData block * Uses a similar method to the BLI method, but is implemented differently * as we need to ensure that the name is unique over several lists of tracks, -- cgit v1.2.3 From 63018144badeb10c858504c918a3f66047c068b0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 12 Jan 2011 03:41:12 +0000 Subject: remove redundant assignments & unused vars. also minor functional changes - OBJECT_OT_make_links_data() type property is now assigned to the operator property (so popup menu can find it) - removing BG image now returns cancelled if no image is removed. --- source/blender/blenkernel/intern/displist.c | 1 - source/blender/blenkernel/intern/font.c | 2 +- source/blender/blenkernel/intern/image.c | 8 ++++---- source/blender/blenkernel/intern/implicit.c | 4 ++-- source/blender/blenkernel/intern/particle.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 4 ---- 6 files changed, 8 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 674836ac859..424d15f6a7e 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1795,7 +1795,6 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba dl->rt= nu->flag & ~CU_2D; dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((bl->nr+0x1F)>>5), "bevelSplitFlag"); - bevp= (BevPoint *)(bl+1); /* for each point of poly make a bevel piece */ bevp= (BevPoint *)(bl+1); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index ecaa15c8f7d..9684e18b949 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -696,7 +696,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) // Create unicode string utf8len = utf8slen(cu->str); - tmp = mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem"); + mem = MEM_callocN(((utf8len + 1) * sizeof(wchar_t)), "convertedmem"); utf8towchar(mem, cu->str); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 58e3b4ba552..d8876705ebb 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -914,10 +914,10 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } if (scene->r.stamp & R_STAMP_TIME) { - int h, m, s, f; - h= m= s= f= 0; - f = (int)(scene->r.cfra % scene->r.frs_sec); - s = (int)(scene->r.cfra / scene->r.frs_sec); + int f = (int)(scene->r.cfra % scene->r.frs_sec); + int s = (int)(scene->r.cfra / scene->r.frs_sec); + int h= 0; + int m= 0; if (s) { m = (int)(s / 60); diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 0df456a443d..fc9c41070dc 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1229,7 +1229,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, float vel[3]; float k = 0.0f; float L = s->restlen; - float cb = clmd->sim_parms->structural; + float cb; /* = clmd->sim_parms->structural; */ /*UNUSED*/ float nullf[3] = {0,0,0}; float stretch_force[3] = {0,0,0}; @@ -1566,7 +1566,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec float tm2[3][3] = {{0}}; MFace *mfaces = cloth->mfaces; unsigned int numverts = cloth->numverts; - LinkNode *search = cloth->springs; + LinkNode *search; lfVector *winvec; EffectedPoint epoint; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index db826b83864..7c3e90dc375 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2847,7 +2847,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) ParticleEditSettings *pset = &sim->scene->toolsettings->particle; ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; - ParticleCacheKey *ca, **cache= psys->pathcache; + ParticleCacheKey *ca, **cache; DerivedMesh *hair_dm = (psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) ? psys->hair_out_dm : NULL; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 37ce6c94eb7..0044c86f4f7 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2025,8 +2025,6 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) PTCacheMem *pm= pid->cache->mem_cache.first; PTCacheMem *link= NULL; - pm= pid->cache->mem_cache.first; - if(mode == PTCACHE_CLEAR_ALL) { /*we want startframe if the cache starts before zero*/ pid->cache->last_exact = MIN2(pid->cache->startframe, 0); @@ -2207,8 +2205,6 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra else { PTCacheMem *pm= pid->cache->mem_cache.first; - pm= pid->cache->mem_cache.first; - while(pm) { if(pm->frame >= sta && pm->frame <= end) cache->cached_frames[pm->frame-sta] = 1; -- cgit v1.2.3 From 4e15c169c69d3f7bb0d05ab4fc9d4762e2427e9a Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 12 Jan 2011 10:01:33 +0000 Subject: Fix for [#25572] crash when changing vertex group density in particle mode * Hair was freed & redone on changes, but particle mode data wasn't updated. --- source/blender/blenkernel/intern/particle_system.c | 6 ++++++ 1 file changed, 6 insertions(+) (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 27adeaa2430..06056e0ecc9 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4100,6 +4100,12 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) free_hair(ob, psys, 0); + if(psys->edit && psys->free_edit) { + psys->free_edit(psys->edit); + psys->edit = NULL; + psys->free_edit = NULL; + } + /* first step is negative so particles get killed and reset */ psys->cfra= 1.0f; -- cgit v1.2.3 From 792f3b11f952be344ef24bc5879883a156b0e04f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 12 Jan 2011 16:53:27 +0000 Subject: bugfix [#24774] Lattice modifier+Dupligroup+Texture solid=weird result new 2.5x code was not passing group recalc flags onto objects within them. --- source/blender/blenkernel/intern/group.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index e48ec8ac288..3b8daced657 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -364,17 +364,22 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group scene->r.cfra= cfrao; } else -#endif +#else { - /* only do existing tags, as set by regular depsgraph */ + /* use 2 loops to avoid updating objects multiple times */ for(go= group->gobject.first; go; go= go->next) { - if(go->ob) { - if(go->ob->recalc) { - object_handle_update(scene, go->ob); - } + if(go->ob && go->recalc) { + go->ob->recalc |= go->recalc; + } + } + + for(go= group->gobject.first; go; go= go->next) { + if(go->ob && go->recalc) { + object_handle_update(scene, go->ob); } } } +#endif } Object *group_get_member_with_action(Group *group, bAction *act) -- cgit v1.2.3 From 604d029ddf164e87eb453d83c59e65c2f16f8879 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Wed, 12 Jan 2011 18:00:23 +0000 Subject: Bugfix #25570 The tool-redo depends on a working undo system, so it can rewind a step and then redo operator with new settings. When a user disables undo, this won't work. Now the properties for redo operator (toolbar, F6) will grey out when a redo isn't possible. --- source/blender/blenkernel/intern/blender.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 1d616c77f04..56869e503dd 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -638,6 +638,22 @@ void BKE_undo_name(bContext *C, const char *name) } } +/* name optional */ +int BKE_undo_valid(const char *name) +{ + if(name) { + UndoElem *uel; + + for(uel= undobase.last; uel; uel= uel->prev) + if(strcmp(name, uel->name)==0) + break; + + return uel && uel->prev; + } + + return undobase.last != undobase.first; +} + char *BKE_undo_menu_string(void) { -- cgit v1.2.3 From 8227b3d463955d887a987fe546d8eefa2757a982 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 13 Jan 2011 04:53:55 +0000 Subject: remove/comment unused vars also removed unnecessary NULL checks (where the pointer was used later without checking). --- source/blender/blenkernel/intern/anim.c | 4 +--- source/blender/blenkernel/intern/collision.c | 4 ++-- source/blender/blenkernel/intern/customdata.c | 4 ++-- source/blender/blenkernel/intern/multires.c | 4 ++-- 4 files changed, 7 insertions(+), 9 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 8cac3860e79..68a949ed25a 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1172,7 +1172,6 @@ static void new_particle_duplilist(ListBase *lb, ID *UNUSED(id), Scene *scene, O float (*obmat)[4], (*oldobmat)[4]; int a, b, counter, hair = 0; int totpart, totchild, totgroup=0, pa_num; - unsigned int lay; if(psys==0) return; @@ -1193,8 +1192,7 @@ static void new_particle_duplilist(ListBase *lb, ID *UNUSED(id), Scene *scene, O totchild = psys->totchild; BLI_srandom(31415926 + psys->seed); - - lay= scene->lay; + if((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { ParticleSimulationData sim= {0}; sim.scene= scene; diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index e7dff52db62..8cdfd60b9a7 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1457,13 +1457,13 @@ static void cloth_bvh_objcollisions_nearcheck ( ClothModifierData * clmd, Collis static int cloth_bvh_objcollisions_resolve ( ClothModifierData * clmd, CollisionModifierData *collmd, CollPair *collisions, CollPair *collisions_index) { Cloth *cloth = clmd->clothObject; - int i=0, j = 0, numfaces = 0, numverts = 0; + int i=0, j = 0, /*numfaces = 0,*/ numverts = 0; ClothVertex *verts = NULL; int ret = 0; int result = 0; float tnull[3] = {0,0,0}; - numfaces = clmd->clothObject->numfaces; + /*numfaces = clmd->clothObject->numfaces;*/ /*UNUSED*/ numverts = clmd->clothObject->numverts; verts = cloth->verts; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 57f66a37343..94bb771aecd 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -893,13 +893,13 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, void CustomData_merge(const struct CustomData *source, struct CustomData *dest, CustomDataMask mask, int alloctype, int totelem) { - const LayerTypeInfo *typeInfo; + /*const LayerTypeInfo *typeInfo;*/ CustomDataLayer *layer, *newlayer; int i, type, number = 0, lasttype = -1, lastactive = 0, lastrender = 0, lastclone = 0, lastmask = 0, lastflag = 0; for(i = 0; i < source->totlayer; ++i) { layer = &source->layers[i]; - typeInfo = layerType_getInfo(layer->type); + /*typeInfo = layerType_getInfo(layer->type);*/ /*UNUSED*/ type = layer->type; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index ed0b1bfceca..0fb19685f25 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -707,7 +707,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, int invert, int MFace *mface = me->mface; MDisps *mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); int *gridOffset; - int i, numGrids, gridSize, dGridSize, dSkip; + int i, /*numGrids,*/ gridSize, dGridSize, dSkip; if(!mdisps) { if(invert) @@ -716,7 +716,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, int invert, int return; } - numGrids = dm->getNumGrids(dm); + /*numGrids = dm->getNumGrids(dm);*/ /*UNUSED*/ gridSize = dm->getGridSize(dm); gridData = dm->getGridData(dm); gridOffset = dm->getGridOffset(dm); -- cgit v1.2.3 From d2e6ea65c3f2e2c721d1c0c5fc19b842f9d4de05 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 13 Jan 2011 10:14:03 +0000 Subject: revert r34284, this fix was incorrect. --- source/blender/blenkernel/intern/group.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 3b8daced657..e48ec8ac288 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -364,22 +364,17 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group scene->r.cfra= cfrao; } else -#else +#endif { - /* use 2 loops to avoid updating objects multiple times */ - for(go= group->gobject.first; go; go= go->next) { - if(go->ob && go->recalc) { - go->ob->recalc |= go->recalc; - } - } - + /* only do existing tags, as set by regular depsgraph */ for(go= group->gobject.first; go; go= go->next) { - if(go->ob && go->recalc) { - object_handle_update(scene, go->ob); + if(go->ob) { + if(go->ob->recalc) { + object_handle_update(scene, go->ob); + } } } } -#endif } Object *group_get_member_with_action(Group *group, bAction *act) -- cgit v1.2.3 From 4cc4a73a9e228e0eee682a5220c3ed77572f02af Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 13 Jan 2011 19:16:35 +0000 Subject: feature request from colin levy, camera lens stamp. --- source/blender/blenkernel/intern/image.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index d8876705ebb..3d69f51851f 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -54,6 +54,7 @@ #include "DNA_packedFile_types.h" #include "DNA_scene_types.h" +#include "DNA_object_types.h" #include "DNA_camera_types.h" #include "DNA_sequence_types.h" #include "DNA_userdef_types.h" @@ -859,6 +860,7 @@ typedef struct StampData { char time[512]; char frame[512]; char camera[64]; + char cameralens[64]; char scene[64]; char strip[64]; char rendertime[64]; @@ -955,7 +957,7 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } if (scene->r.stamp & R_STAMP_CAMERA) { - if (scene->camera) strcpy(text, ((Camera *) scene->camera)->id.name+2); + if (scene->camera) strcpy(text, scene->camera->id.name+2); else strcpy(text, ""); if (do_prefix) sprintf(stamp_data->camera, "Camera %s", text); @@ -964,6 +966,18 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) stamp_data->camera[0] = '\0'; } + if (scene->r.stamp & R_STAMP_CAMERALENS) { + if (scene->camera && scene->camera->type == OB_CAMERA) { + sprintf(text, "%.2f", ((Camera *)scene->camera->data)->lens); + } + else strcpy(text, ""); + + if (do_prefix) sprintf(stamp_data->cameralens, "Lens %s", text); + else sprintf(stamp_data->cameralens, "%s", text); + } else { + stamp_data->cameralens[0] = '\0'; + } + if (scene->r.stamp & R_STAMP_SCENE) { if (do_prefix) sprintf(stamp_data->scene, "Scene %s", scene->id.name+2); else sprintf(stamp_data->scene, "%s", scene->id.name+2); @@ -1145,6 +1159,18 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2); BLF_position(mono, x, y+3, 0.0); BLF_draw_buffer(mono, stamp_data.camera); + + /* space width. */ + x += w + pad; + } + + if (stamp_data.cameralens[0]) { + BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h= h_fixed; + + /* extra space for background. */ + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2); + BLF_position(mono, x, y+3, 0.0); + BLF_draw_buffer(mono, stamp_data.cameralens); } if (stamp_data.scene[0]) { @@ -1195,6 +1221,7 @@ void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) if (stamp_data.time[0]) IMB_metadata_change_field (ibuf, "Time", stamp_data.time); if (stamp_data.frame[0]) IMB_metadata_change_field (ibuf, "Frame", stamp_data.frame); if (stamp_data.camera[0]) IMB_metadata_change_field (ibuf, "Camera", stamp_data.camera); + if (stamp_data.cameralens[0]) IMB_metadata_change_field (ibuf, "Lens", stamp_data.cameralens); if (stamp_data.scene[0]) IMB_metadata_change_field (ibuf, "Scene", stamp_data.scene); if (stamp_data.strip[0]) IMB_metadata_change_field (ibuf, "Strip", stamp_data.strip); if (stamp_data.rendertime[0]) IMB_metadata_change_field (ibuf, "RenderTime", stamp_data.rendertime); -- cgit v1.2.3 From af4bc28c44f08629ba2bd6afb406edfe19011b63 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Fri, 14 Jan 2011 05:19:04 +0000 Subject: Bugfix [#25617] HOME Key in fcurve editor doesn't center properly * When euler-rotation F-Curves had a single keyframe only, the view would be artifically extended to fill up to 57 (this comes from the radians to degrees calculations) due to a combination of the bounds- finding function enforcing a minimum separation of 1 unit between min/max. This has now been moved to the operator-level where it gets applied AFTER these conversions have taken effect * F-Curves with samples only (i.e. baked F-Curves) would be ignored by these operators. Was caused by using a poll calback that only considered whether there were keyframes. Hopefully this is sufficient; otherwise a hybrid poll method will be needed. --- source/blender/blenkernel/intern/fcurve.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 16d332c3bcb..87dff0a58b6 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -472,11 +472,7 @@ void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, flo foundvert=1; } - /* minimum sizes are 1.0f */ if (foundvert) { - if (xminv == xmaxv) xmaxv += 1.0f; - if (yminv == ymaxv) ymaxv += 1.0f; - if (xmin) *xmin= xminv; if (xmax) *xmax= xmaxv; @@ -484,10 +480,13 @@ void calc_fcurve_bounds (FCurve *fcu, float *xmin, float *xmax, float *ymin, flo if (ymax) *ymax= ymaxv; } else { + if (G.f & G_DEBUG) + printf("F-Curve calc bounds didn't find anything, so assuming minimum bounds of 1.0\n"); + if (xmin) *xmin= 0.0f; - if (xmax) *xmax= 0.0f; + if (xmax) *xmax= 1.0f; - if (ymin) *ymin= 1.0f; + if (ymin) *ymin= 0.0f; if (ymax) *ymax= 1.0f; } } -- cgit v1.2.3 From 439140d6aedba79045eca52ba7a905d9e4a34d8a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 14 Jan 2011 16:57:53 +0000 Subject: Todo item #19816: Wave modifier does not affect Curve Paths Added new option for applyong modifiers on splines' points. This moves tesselation point and path would be affected by modifiers which are applied on splines' points. --- source/blender/blenkernel/intern/displist.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 424d15f6a7e..3bb62f817cd 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1220,10 +1220,20 @@ static ModifierData *curve_get_tesselate_point(Scene *scene, Object *ob, int for preTesselatePoint = NULL; for (; md; md=md->next) { + ModifierTypeInfo *mti = modifierType_getInfo(md->type); + if (!modifier_isEnabled(scene, md, required_mode)) continue; + if (mti->type == eModifierTypeType_Constructive) return preTesselatePoint; if (ELEM3(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) { - preTesselatePoint = md; + preTesselatePoint = md; + + /* this modifiers are moving point of tesselation automatically + (some of them even can't be applied on tesselated curve), set flag + for incformation button in modifier's header */ + md->mode |= eModifierMode_ApplyOnSpline; + } else if(md->mode&eModifierMode_ApplyOnSpline) { + preTesselatePoint = md; } } -- cgit v1.2.3 From eac31a2eceb6601967484301c5f25b7a138f623b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 14 Jan 2011 21:06:28 +0000 Subject: remove unused vars & avoid some clang warnings. --- source/blender/blenkernel/intern/cdderivedmesh.c | 6 ++---- source/blender/blenkernel/intern/font.c | 8 +++----- source/blender/blenkernel/intern/idprop.c | 1 - source/blender/blenkernel/intern/seqeffects.c | 4 ++-- source/blender/blenkernel/intern/text.c | 1 - 5 files changed, 7 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 8bb336d1c4d..71e704fe6c8 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -958,14 +958,13 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo MFace *mface = cddm->mface; MTFace *tf = dm->getFaceDataArray(dm, CD_MTFACE); float (*nors)[3] = dm->getFaceDataArray(dm, CD_NORMAL); - int a, b, dodraw, smoothnormal, matnr, new_matnr; + int a, b, dodraw, matnr, new_matnr; int transp, new_transp, orig_transp; int orig, *index = dm->getFaceDataArray(dm, CD_ORIGINDEX); cdDM_update_normals_from_pbvh(dm); matnr = -1; - smoothnormal = 0; dodraw = 0; transp = GPU_get_material_blend_mode(); orig_transp = transp; @@ -979,6 +978,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo glBegin(GL_QUADS); for(a = 0; a < dm->numFaceData; a++, mface++) { + const int smoothnormal = (mface->flag & ME_SMOOTH); new_matnr = mface->mat_nr + 1; if(new_matnr != matnr) { @@ -1023,8 +1023,6 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } } - smoothnormal = (mface->flag & ME_SMOOTH); - if(!smoothnormal) { if(nors) { glNormal3fv(nors[a]); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 9684e18b949..1d7ce197cba 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -757,7 +757,6 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) for (i = 0 ; i<=slen ; i++) { makebreak: // Characters in the list - che = vfd->characters.first; info = &(custrinfo[i]); ascii = mem[i]; if(info->flag & CU_CHINFO_SMALLCAPS) { @@ -1042,10 +1041,9 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) che= find_vfont_char(vfd, ascii); twidth = char_width(cu, che, info); - - dtime= distfac*0.35f*twidth; /* why not 0.5? */ - dtime= distfac*0.5f*twidth; /* why not 0.5? */ - + + dtime= distfac*0.5f*twidth; + ctime= timeofs + distfac*( ct->xof - minx); CLAMP(ctime, 0.0, 1.0); diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index c837f02279b..633d3aeafb9 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -440,7 +440,6 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src) BLI_insertlinkafter(&dest->data.group, loop, copy); BLI_remlink(&dest->data.group, tmp); - loop = copy; IDP_FreeProperty(tmp); MEM_freeN(tmp); diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 2f90da2296b..36f618d04a9 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2730,8 +2730,8 @@ static struct ImBuf * do_solid_color( unsigned char *rect; float *rect_float; - int x = context.rectx; - int y = context.recty; + /*int x = context.rectx;*/ /*UNUSED*/ + /*int y = context.recty;*/ /*UNUSED*/ if (out->rect) { unsigned char col0[3]; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 20492b99048..1bd41c7aa86 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -280,7 +280,6 @@ int reopen_text(Text *text) text->mtime= st.st_mtime; text->nlines=0; - i=0; llen=0; for(i=0; i Date: Fri, 14 Jan 2011 21:45:49 +0000 Subject: error in last commit, also skip getting vars for wm_operator_reports() when there are no reports. --- source/blender/blenkernel/intern/seqeffects.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 36f618d04a9..11075fe402e 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2730,8 +2730,8 @@ static struct ImBuf * do_solid_color( unsigned char *rect; float *rect_float; - /*int x = context.rectx;*/ /*UNUSED*/ - /*int y = context.recty;*/ /*UNUSED*/ + int x; /*= context.rectx;*/ /*UNUSED*/ + int y; /*= context.recty;*/ /*UNUSED*/ if (out->rect) { unsigned char col0[3]; -- cgit v1.2.3 From 7297169a7491c85e9bdb9d9c80aaa54fce587232 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 15 Jan 2011 12:00:15 +0000 Subject: Fix for [#25637] curveguide forcefield(Kink: Braid) + particlesystem cause crash by Null Pointer in some cases * Missing null pointer check. --- source/blender/blenkernel/intern/particle.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 7c3e90dc375..5526edf0a8c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1962,8 +1962,10 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float float vec_one[3], radius, state_co[3]; float inp_y, inp_z, length; - mul_qt_v3(par_rot, y_vec); - mul_qt_v3(par_rot, z_vec); + if(par_rot) { + mul_qt_v3(par_rot, y_vec); + mul_qt_v3(par_rot, z_vec); + } mul_v3_fl(par_vec, -1.f); radius= normalize_v3_v3(vec_one, par_vec); -- cgit v1.2.3 From 9d2292ef7e39756d249797a6b972076f096f2750 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 17 Jan 2011 08:31:57 +0000 Subject: misc maintenance changes - metaball tessellation functuion was calculating density when it didn't need to. - image drawing was using a float as a loop counter, in extreme cases this could cause an infinite loop. - remove/comment unused vars. --- source/blender/blenkernel/intern/mball.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 6e48b922424..a22fc165de7 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -1422,7 +1422,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) int i, j, k, c_i, c_j, c_k; int index[3]={1,0,-1}; float f =0.0f; - float in_v, out_v; + float in_v /*, out_v*/; MB_POINT workp; float tmp_v, workp_v, max_len, len, dx, dy, dz, nx, ny, nz, MAXN; @@ -1483,7 +1483,7 @@ void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) calc_mballco(ml, (float *)&out); - out_v = mbproc->function(out.x, out.y, out.z); + /*out_v = mbproc->function(out.x, out.y, out.z);*/ /*UNUSED*/ /* find "first points" on Implicit Surface of MetaElemnt ml */ workp.x = in.x; @@ -1582,8 +1582,8 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ Object *bob; MetaBall *mb; MetaElem *ml; - float size, totsize, (*mat)[4] = NULL, (*imat)[4] = NULL, obinv[4][4], obmat[4][4], vec[3]; - float temp1[4][4], temp2[4][4], temp3[4][4]; //max=0.0; + float size, totsize, obinv[4][4], obmat[4][4], vec[3]; + //float max=0.0; int a, obnr, zero_size=0; char obname[32]; @@ -1602,7 +1602,6 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ ml= NULL; if(bob==ob && (base->flag & OB_FROMDUPLI)==0) { - mat= imat= 0; mb= ob->data; if(mb->editelems) ml= mb->editelems->first; @@ -1649,6 +1648,8 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ while(ml) { if(!(ml->flag & MB_HIDE)) { int i; + float temp1[4][4], temp2[4][4], temp3[4][4]; + float (*mat)[4] = NULL, (*imat)[4] = NULL; float max_x, max_y, max_z, min_x, min_y, min_z; max_x = max_y = max_z = -3.4e38; -- cgit v1.2.3 From 4b7930dbbd8a11fb5db3e1cc81ca9ca5b0a69fc0 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 17 Jan 2011 15:16:08 +0000 Subject: Bugfix #25681 Python API allowed to make links with input->output reversed. Now node api checks for this case and flips order. --- source/blender/blenkernel/intern/node.c | 58 +++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index c4d54cd6296..fd0edd83c7d 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1082,15 +1082,61 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal) return nnode; } +/* fromsock and tosock can be NULL */ +/* also used via rna api, so we check for proper input output direction */ bNodeLink *nodeAddLink(bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock) { - bNodeLink *link= MEM_callocN(sizeof(bNodeLink), "link"); + bNodeSocket *sock; + bNodeLink *link= NULL; + int from= 0, to= 0; + + if(fromsock) { + /* test valid input */ + for(sock= fromnode->outputs.first; sock; sock= sock->next) + if(sock==fromsock) + break; + if(sock) + from= 1; /* OK */ + else { + for(sock= fromnode->inputs.first; sock; sock= sock->next) + if(sock==fromsock) + break; + if(sock) + from= -1; /* OK but flip */ + } + } + if(tosock) { + for(sock= tonode->inputs.first; sock; sock= sock->next) + if(sock==tosock) + break; + if(sock) + to= 1; /* OK */ + else { + for(sock= tonode->outputs.first; sock; sock= sock->next) + if(sock==tosock) + break; + if(sock) + to= -1; /* OK but flip */ + } + } - BLI_addtail(&ntree->links, link); - link->fromnode= fromnode; - link->fromsock= fromsock; - link->tonode= tonode; - link->tosock= tosock; + /* this allows NULL sockets to work */ + if(from >= 0 && to >= 0) { + link= MEM_callocN(sizeof(bNodeLink), "link"); + BLI_addtail(&ntree->links, link); + link->fromnode= fromnode; + link->fromsock= fromsock; + link->tonode= tonode; + link->tosock= tosock; + } + else if(from <= 0 && to <= 0) { + link= MEM_callocN(sizeof(bNodeLink), "link"); + BLI_addtail(&ntree->links, link); + link->fromnode= tonode; + link->fromsock= tosock; + link->tonode= fromnode; + link->tosock= fromsock; + } return link; } -- cgit v1.2.3 From 86baf7c937c4bcac1c9ebf516e2aa2a79ec2f6fc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 18 Jan 2011 00:10:11 +0000 Subject: option for the path iterator to loop over packed files so their dir separator can be switched on file load. --- source/blender/blenkernel/intern/blender.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 56869e503dd..bc11c276210 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -160,7 +160,7 @@ static void clean_paths(Main *main) char filepath_expanded[1024]; Scene *scene; - for(BLI_bpathIterator_init(&bpi, main, main->name); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) { + for(BLI_bpathIterator_init(&bpi, main, main->name, BPATH_USE_PACKED); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) { BLI_bpathIterator_getPath(bpi, filepath_expanded); BLI_clean(filepath_expanded); -- cgit v1.2.3 From 8cf1184c045d37b7aecd5b8a08ecefefeed17850 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 18 Jan 2011 01:58:19 +0000 Subject: bad spelling; 'indicies' --> 'indices' --- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/blenkernel/intern/fcurve.c | 2 +- source/blender/blenkernel/intern/ipo.c | 2 +- 3 files changed, 3 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 bee0b476f9f..c733a560620 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2237,7 +2237,7 @@ static void mesh_build_data(Scene *scene, Object *ob, CustomDataMask dataMask) { Object *obact = scene->basact?scene->basact->object:NULL; int editing = paint_facesel_test(ob); - /* weight paint and face select need original indicies because of selection buffer drawing */ + /* weight paint and face select need original indices because of selection buffer drawing */ int needMapping = (ob==obact) && (editing || (ob->mode & (OB_MODE_WEIGHT_PAINT|OB_MODE_VERTEX_PAINT))); clear_mesh_caches(ob); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 87dff0a58b6..ef1ac582c1e 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -221,7 +221,7 @@ FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array for (fcu= list->first; fcu; fcu= fcu->next) { /* simple string-compare (this assumes that they have the same root...) */ if (fcu->rna_path && !strcmp(fcu->rna_path, rna_path)) { - /* now check indicies */ + /* now check indices */ if (fcu->array_index == array_index) return fcu; } diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index b4dd81ce356..db995fd4f1d 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -315,7 +315,7 @@ static const char *constraint_adrcodes_to_paths (int adrcode, int *array_index) /* ShapeKey types * NOTE: as we don't have access to the keyblock where the data comes from (for now), - * we'll just use numerical indicies for now... + * we'll just use numerical indices for now... */ static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) { -- cgit v1.2.3 From fb97780fdf4d6cd6b8ad0cdbc6582ae235be121c Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 18 Jan 2011 09:25:37 +0000 Subject: Bug fix: particle dynamics were being calculated if point cache was only half baked (reported by Michael Fox in #blendercoders) * When a simulation is baked no dynamics calculations should happen anymore (even outside of baked frame range) since these can be very time consuming and baked simulations are supposed to be fast! --- source/blender/blenkernel/intern/particle_system.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (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 06056e0ecc9..6ec08e76606 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3854,14 +3854,15 @@ static void system_step(ParticleSimulationData *sim, float cfra) return; } + /* Cache is supposed to be baked, but no data was found so bail out */ + else if(cache->flag & PTCACHE_BAKED) { + psys_reset(psys, PSYS_RESET_CACHE_MISS); + return; + } else if(cache_result == PTCACHE_READ_OLD) { psys->cfra = (float)cache->simframe; cached_step(sim, psys->cfra); } - else if(cfra != startframe && ( /*sim->ob->id.lib ||*/ (cache->flag & PTCACHE_BAKED))) { /* 2.4x disabled lib, but this can be used in some cases, testing further - campbell */ - psys_reset(psys, PSYS_RESET_CACHE_MISS); - return; - } /* if on second frame, write cache for first frame */ if(psys->cfra == startframe && (cache->flag & PTCACHE_OUTDATED || cache->last_exact==0)) -- cgit v1.2.3 From bee3d783939441946591f4b891394f0cf16cc12d Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 18 Jan 2011 13:28:18 +0000 Subject: Added a check in nodeGroupVerify to detect if a tree is actually a group tree. This is necessary to avoid the group-in-group error if the function is called for a tree that already contains group nodes. --- source/blender/blenkernel/intern/node.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index fd0edd83c7d..a6f03c0c3ec 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -615,6 +615,12 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) /* should become callbackable... */ void nodeVerifyGroup(bNodeTree *ngroup) { + /* XXX nodeVerifyGroup is sometimes called for non-group trees. + * This is not the best way to check if a tree is a group, + * trees should get their own flag for this! + */ + if (!ngroup->owntype) + return; /* group changed, so we rebuild the type definition */ ntreeMakeOwnType(ngroup); -- cgit v1.2.3 From 083be9023271ad057365917bf289e10d6524a9fc Mon Sep 17 00:00:00 2001 From: Konrad Kleine Date: Tue, 18 Jan 2011 15:02:58 +0000 Subject: Fix for "[#25700] 2.56: Rotation Mode: Quaternion shows wrong orientation of the object". There was a small typing error that made object and armatures rotate twice the magnitude when in quaternion rotation mode. --- 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 0ac98256b07..43a13b27736 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1674,7 +1674,7 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) normalize_qt_qt(tquat, ob->quat); quat_to_mat3(rmat, tquat); - normalize_qt_qt(tquat, ob->quat); + normalize_qt_qt(tquat, ob->dquat); quat_to_mat3(dmat, tquat); } -- cgit v1.2.3 From dddb9aa30f96961023f02846c97c955e1f2b5f0c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 18 Jan 2011 23:38:36 +0000 Subject: NLA Editor: Swap Strips (Alt-F) and Bugfixes 1) Added a new operator to swap the order of strips within a track (Alt-F). This makes it possible to select two strips (or more precisely, two islands of consecutive + selected strips) in a single track and change the order in which the appear without needing a extra tracks to perform the move through. As usual, the non-overlapping rules apply, so there may be some cases where swapping in this way is not possible without adjusting the intermediate strips first manually. Otherwise, everything just gets too tricky to manage deciding what adjustments should be done to the obstructing strips to make a fit. 2) Freeing meta-strips didn't free their local data properly (i.e. modifiers they may have had). 3) Adding strips to tracks, where the endframes for the strips overlapped would cause problems with incorrect ordering of strips. I still need to double-check whether evaluation works ok in this case... --- source/blender/blenkernel/intern/nla.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 595614ef1e7..ea2948f305e 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -514,7 +514,7 @@ short BKE_nlastrips_has_space (ListBase *strips, float start, float end) /* if start frame of strip is past the target end-frame, that means that * we've gone past the window we need to check for, so things are fine */ - if (strip->start > end) + if (strip->start >= end) return 1; /* if the end of the strip is greater than either of the boundaries, the range @@ -591,7 +591,7 @@ short BKE_nlastrips_add_strip (ListBase *strips, NlaStrip *strip) /* find the right place to add the strip to the nominated track */ for (ns= strips->first; ns; ns= ns->next) { /* if current strip occurs after the new strip, add it before */ - if (ns->start > strip->end) { + if (ns->start >= strip->end) { BLI_insertlinkbefore(strips, ns, strip); not_added= 0; break; @@ -683,7 +683,7 @@ void BKE_nlastrips_clear_metastrip (ListBase *strips, NlaStrip *strip) } /* free the meta-strip now */ - BLI_freelinkN(strips, strip); + free_nlastrip(strips, strip); } /* Remove meta-strips (i.e. flatten the list of strips) from the top-level of the list of strips -- cgit v1.2.3 From 6cadef1fb12061ae40a5c2662d121305bc51fa8f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 19 Jan 2011 23:05:02 +0000 Subject: NLA backend code cleanups: Ensure all user-count management is done via id_us_*() functions instead of direct access, for more security --- source/blender/blenkernel/intern/nla.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index ea2948f305e..6db03909aa3 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -78,7 +78,7 @@ void free_nlastrip (ListBase *strips, NlaStrip *strip) /* remove reference to action */ if (strip->act) - strip->act->id.us--; + id_us_min(&strip->act->id); /* free remapping info */ //if (strip->remap) @@ -160,7 +160,7 @@ NlaStrip *copy_nlastrip (NlaStrip *strip) /* increase user-count of action */ if (strip_d->act) - strip_d->act->id.us++; + id_us_plus(&strip_d->act->id); /* copy F-Curves and modifiers */ copy_fcurves(&strip_d->fcurves, &strip->fcurves); @@ -1438,7 +1438,7 @@ void BKE_nla_action_pushdown (AnimData *adt) /* do other necessary work on strip */ if (strip) { /* clear reference to action now that we've pushed it onto the stack */ - adt->action->id.us--; + id_us_min(&adt->action->id); adt->action= NULL; /* if the strip is the first one in the track it lives in, check if there -- cgit v1.2.3 From ac058624ae45d67f6260962882ea5f09c6afcea4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 20 Jan 2011 07:41:25 +0000 Subject: fix for bug where python functions were not raising exceptions because reports were not added to the list in background mode. --- source/blender/blenkernel/intern/report.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index a22b36b9524..e623c095ac7 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -96,11 +96,9 @@ void BKE_report(ReportList *reports, ReportType type, const char *message) Report *report; int len; - /* exception, print and return in background, no reason to store a list */ - if(G.background) - reports= NULL; - - if(!reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) { + /* in background mode always print otherwise there are cases the errors wont be displayed, + * but still add to the report list since this is used for python exception handling */ + if(G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) { printf("%s: %s\n", report_type_str(type), message); fflush(stdout); /* this ensures the message is printed before a crash */ } -- cgit v1.2.3 From 09ceb859b7ea9945556ff40799375bd8139234e7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 20 Jan 2011 07:44:58 +0000 Subject: no functional change, - remove G.flag, its not used anywhere (and confusing with G.f). - also remove strcpy where memory locations may overlap. --- source/blender/blenkernel/intern/blender.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index bc11c276210..6e08df0f465 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -299,8 +299,6 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filename /* these are the same at times, should never copy to the same location */ if(G.main->name != filename) BLI_strncpy(G.main->name, filename, FILE_MAX); - - BLI_strncpy(G.main->name, filename, FILE_MAX); /* is guaranteed current file */ /* baseflags, groups, make depsgraph, etc */ set_scene_bg(G.main, CTX_data_scene(C)); -- cgit v1.2.3 From 799e9c48c1a210386873ae01a0f208675eafffe7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 22 Jan 2011 03:50:09 +0000 Subject: comment dead code and fix 2 missing NULL checks (pointer used after NULL check and checking against incorrect pointer before use). --- source/blender/blenkernel/intern/implicit.c | 5 +++-- source/blender/blenkernel/intern/particle.c | 4 ++-- source/blender/blenkernel/intern/particle_system.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index fc9c41070dc..8004f23c22a 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1317,8 +1317,9 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, VECSUB(extent, X[s->ij], tvect); - dot = INPR(extent, extent); - length = sqrt(dot); + // SEE MSG BELOW (these are UNUSED) + // dot = INPR(extent, extent); + // length = sqrt(dot); k = clmd->sim_parms->goalspring; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 5526edf0a8c..87c39abd561 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2743,7 +2743,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd { ParticleThread *pthreads; ParticleThreadContext *ctx; - ParticleCacheKey **cache; + /*ParticleCacheKey **cache;*/ /*UNUSED*/ ListBase threads; int i, totchild, totparent, totthread; @@ -2762,7 +2762,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd totparent= ctx->totparent; if(editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) { - cache = sim->psys->childcache; + /*cache = sim->psys->childcache;*/ /*UNUSED*/ } else { /* clear out old and create new empty path cache */ diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 6ec08e76606..62bfde601f6 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3403,7 +3403,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) PARTICLE_P; float timestep; /* current time */ - float ctime; + /* float ctime; */ /*UNUSED*/ /* frame & time changes */ float dfra, dtime; float birthtime, dietime; @@ -3412,7 +3412,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) dfra= cfra - psys->cfra; timestep = psys_get_timestep(sim); - ctime= cfra*timestep; + /*ctime= cfra*timestep;*/ /*UNUSED*/ dtime= dfra*timestep; if(dfra<0.0){ -- cgit v1.2.3 From 11491201451fbb5e1510979df8d7335ed0ee790f Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 22 Jan 2011 14:13:36 +0000 Subject: Temporary fix for [#25735] Softbody don't work in linked groups, not generate cache * The whole case of lib linking and pointcaches is not very well defined currently, but this fix sets the behavior of sb to the same as other physics currently. * A proper fix will be easy to implement after a good physics baking ui is added. --- source/blender/blenkernel/intern/softbody.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index e38f1bb545c..3ba18fee615 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -4151,7 +4151,7 @@ void sbObjectStep(Scene *scene, Object *ob, float cfra, float (*vertexCos)[3], i else if(cache_result==PTCACHE_READ_OLD) { ; /* do nothing */ } - else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { + else if(/*ob->id.lib || */(cache->flag & PTCACHE_BAKED)) { /* "library linking & pointcaches" has to be solved properly at some point */ /* if baked and nothing in cache, do nothing */ BKE_ptcache_invalidate(cache); return; -- cgit v1.2.3 From fc66b3f2efcb5b7579f06c1966900b2ecf3c1310 Mon Sep 17 00:00:00 2001 From: Benoit Bolsee Date: Sun, 23 Jan 2011 17:17:21 +0000 Subject: BGE: support modifiers without mapping to original mesh both graphically and physically, fixes bug #24942 and #25286. Support for physics is done by skiping the modifiers that don't support mapping to original mesh. This mapping is required to report the hit polygon to the application by the rayCast() function. Support for graphics is done by using the same render function that blender uses for the 3D view. This guantees equal result. Limitation: there is still a known bug if all these conditions are met: - Display list enabled - Old tex face with a several textures mapped to the same material - no armature or shape keys - active modifiers In this case, only a part of the mesh will be rendered with the wrong texture. To avoid this bug, use the GLSL materials or make sure to have 1 material=1 texture in your old tex face objects. --- source/blender/blenkernel/intern/DerivedMesh.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index c733a560620..a2ef625c6e6 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2358,6 +2358,16 @@ DerivedMesh *mesh_create_derived_no_virtual(Scene *scene, Object *ob, float (*ve return final; } +DerivedMesh *mesh_create_derived_physics(Scene *scene, Object *ob, float (*vertCos)[3], + CustomDataMask dataMask) +{ + DerivedMesh *final; + + mesh_calc_modifiers(scene, ob, vertCos, NULL, &final, 0, -1, 1, dataMask, -1, 0); + + return final; +} + DerivedMesh *mesh_create_derived_no_deform_render(Scene *scene, Object *ob, float (*vertCos)[3], CustomDataMask dataMask) -- cgit v1.2.3 From c0e74f9dce632795ed6e083436353b4df4d7e62c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 25 Jan 2011 06:54:57 +0000 Subject: fix [#25748] Addons register parameters/functions more than once - values were added to both the classes __dict__ as well as the internal StructRNA. - made properties available from the type since this is where the python api assigns them: >>> bpy.types.Scene.frame_start - rename RNA_struct_type_properties() -> RNA_struct_type_properties(), added RNA_struct_type_find_property() --- source/blender/blenkernel/intern/node.c | 2 +- 1 file changed, 1 insertion(+), 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 a6f03c0c3ec..85c82dbf9bc 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3119,7 +3119,7 @@ static int node_animation_properties(bNodeTree *ntree, bNode *node) /* check to see if any of the node's properties have fcurves */ RNA_pointer_create((ID *)ntree, &RNA_Node, node, &ptr); - lb = RNA_struct_defined_properties(ptr.type); + lb = RNA_struct_type_properties(ptr.type); for (link=lb->first; link; link=link->next) { int driven, len=1, index; -- cgit v1.2.3 From 0f375d8980f1c6b8bb71ab902c228a07a31a5da3 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 25 Jan 2011 17:08:43 +0000 Subject: Fix for [#25781] Bake cache for particles fails at end , ALT + A not * Missing check for info frame (frame 0). --- source/blender/blenkernel/intern/pointcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 0044c86f4f7..65bf055886e 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1932,7 +1932,7 @@ int BKE_ptcache_write(PTCacheID *pid, unsigned int cfra) cache->flag |= PTCACHE_FRAMES_SKIPPED; /* Update timeline cache display */ - if(cache->cached_frames) + if(cfra && cache->cached_frames) cache->cached_frames[cfra-cache->startframe] = 1; BKE_ptcache_update_info(pid); -- cgit v1.2.3 From 307c10486de9fe264838b898931cae9db92f6ee9 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 26 Jan 2011 13:02:47 +0000 Subject: Fix for [#25797] Hair partcle crash when vertexgroup length enabled * Rounding errors could give vgroup weights of slightly over 1.0 to particles in some cases. --- source/blender/blenkernel/intern/particle.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 87c39abd561..61bedb0b230 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1001,6 +1001,8 @@ static float interpolate_particle_value(float v1, float v2, float v3, float v4, value= w[0]*v1 + w[1]*v2 + w[2]*v3; if(four) value += w[3]*v4; + + CLAMP(value, 0.f, 1.f); return value; } -- cgit v1.2.3 From 0fb785aaa735351b6ba6676660bd82892a0f8cf0 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 26 Jan 2011 22:01:51 +0000 Subject: Removing some old stuff from old animation system that isn't needed anymore (shapekeys stuff) --- source/blender/blenkernel/intern/key.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 0955ccd170e..a3c8ea0c194 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -154,10 +154,6 @@ Key *copy_key(Key *key) keyn= copy_libblock(key); -#if 0 // XXX old animation system - keyn->ipo= copy_ipo(key->ipo); -#endif // XXX old animation system - BLI_duplicatelist(&keyn->block, &key->block); kb= key->block.first; @@ -185,10 +181,6 @@ void make_local_key(Key *key) key->id.lib= 0; new_id(0, (ID *)key, 0); - -#if 0 // XXX old animation system - make_local_ipo(key->ipo); -#endif // XXX old animation system } /* Sort shape keys and Ipo curves after a change. This assumes that at most -- cgit v1.2.3 From 50e09b15a99333ed657f70a8a38bf28d5849506e Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 26 Jan 2011 23:33:08 +0000 Subject: Bugfix [#25707] / Todo Item: "Local Space" for Object constraining For Constraints, there's now a working "Local" Space for Objects without parents. This is defined as relative to the object's rotated set of axes which results from rotation that gets set via "rotation" transform properties. I'm not sure whether this different behaviour between parented and unparented objects will be too confusing (and thus require separate settings + a round of version patching), so I'll wait until we get proper testing from experienced riggers first. --- source/blender/blenkernel/intern/constraint.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index c497132fa99..c61f3ba3683 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -372,7 +372,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 else { /* objects */ if (from==CONSTRAINT_SPACE_WORLD && to==CONSTRAINT_SPACE_LOCAL) { - /* check if object has a parent - otherwise this won't work */ + /* check if object has a parent */ if (ob->parent) { /* 'subtract' parent's effects from owner */ mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat); @@ -380,6 +380,18 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 copy_m4_m4(tempmat, mat); mul_m4_m4m4(mat, tempmat, imat); } + else { + /* Local space in this case will have to be defined as local to the owner's + * transform-property-rotated axes. So subtract this rotation component. + */ + object_to_mat4(ob, diff_mat); + normalize_m4(diff_mat); + zero_v3(diff_mat[3]); + + invert_m4_m4(imat, diff_mat); + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, imat); + } } else if (from==CONSTRAINT_SPACE_LOCAL && to==CONSTRAINT_SPACE_WORLD) { /* check that object has a parent - otherwise this won't work */ @@ -389,6 +401,17 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 mul_m4_m4m4(diff_mat, ob->parentinv, ob->parent->obmat); mul_m4_m4m4(mat, tempmat, diff_mat); } + else { + /* Local space in this case will have to be defined as local to the owner's + * transform-property-rotated axes. So add back this rotation component. + */ + object_to_mat4(ob, diff_mat); + normalize_m4(diff_mat); + zero_v3(diff_mat[3]); + + copy_m4_m4(tempmat, mat); + mul_m4_m4m4(mat, tempmat, diff_mat); + } } } } -- cgit v1.2.3 From 18aece4424f29b7d560373843fd41002862aa575 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 27 Jan 2011 01:29:40 +0000 Subject: Bugfix [#25823] When objects are parented to the same objects that they have some rotation-affecting constraint (i.e. Track To and Copy Rotation) targetting, transforming the objects (directly, using GKEY -> grab) becomes unreliable. This was caused by a typo in some code checking for some OB_NO_CONSTRAINTS under "flag" instead of "transflag" --- 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 43a13b27736..0b9798f861b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -2068,7 +2068,7 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) } /* solve constraints */ - if (ob->constraints.first && !(ob->flag & OB_NO_CONSTRAINTS)) { + if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) { bConstraintOb *cob; cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); -- cgit v1.2.3 From 8fa9a916395652cab6c4fcebb17be677fd6091d1 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 27 Jan 2011 12:21:14 +0000 Subject: Fixing some clang reported issues in particle code. * Not really bugs, but some code cleanup and clarification. --- source/blender/blenkernel/intern/particle.c | 23 ++++++---------------- source/blender/blenkernel/intern/particle_system.c | 14 +++++++++---- 2 files changed, 16 insertions(+), 21 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 61bedb0b230..492b78f7365 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1469,7 +1469,7 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or } else { VECCOPY(orco, vec); - if(ornor) + if(ornor && nor) VECCOPY(ornor, nor); } } @@ -1961,7 +1961,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float { float y_vec[3]={0.f,1.f,0.f}; float z_vec[3]={0.f,0.f,1.f}; - float vec_one[3], radius, state_co[3]; + float vec_one[3], state_co[3]; float inp_y, inp_z, length; if(par_rot) { @@ -1970,7 +1970,6 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float } mul_v3_fl(par_vec, -1.f); - radius= normalize_v3_v3(vec_one, par_vec); inp_y=dot_v3v3(y_vec, vec_one); inp_z=dot_v3v3(z_vec, vec_one); @@ -2745,7 +2744,6 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd { ParticleThread *pthreads; ParticleThreadContext *ctx; - /*ParticleCacheKey **cache;*/ /*UNUSED*/ ListBase threads; int i, totchild, totparent, totthread; @@ -2764,7 +2762,7 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd totparent= ctx->totparent; if(editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) { - /*cache = sim->psys->childcache;*/ /*UNUSED*/ + ; /* just overwrite the existing cache */ } else { /* clear out old and create new empty path cache */ @@ -3102,6 +3100,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* should init_particle_interpolation set this ? */ if(pset->brushtype==PE_BRUSH_WEIGHT){ pind.hkey[0] = NULL; + /* pa != NULL since the weight brush is only available for hair */ pind.hkey[1] = pa->hair; } @@ -3957,7 +3956,6 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * float t, frs_sec = sim->scene->r.frs_sec; float co[3], orco[3]; float hairmat[4][4]; - /*int totparent = 0;*/ /*UNUSED*/ int totpart = psys->totpart; int totchild = psys->totchild; short between = 0, edit = 0; @@ -3967,11 +3965,8 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * float *cpa_fuv; int cpa_num; short cpa_from; - //if(psys_in_edit_mode(scene, psys)){ - // if((psys->edit_path->flag & PSYS_EP_SHOW_CHILD)==0) - // totchild=0; - // edit=1; - //} + /* initialize keys to zero */ + memset(keys, 0, 4*sizeof(ParticleKey)); t=state->time; CLAMP(t, 0.0, 1.0); @@ -4013,12 +4008,6 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * t = psys_get_child_time(psys, cpa, -state->time, NULL, NULL); if(totchild && part->from!=PART_FROM_PARTICLE && part->childtype==PART_CHILD_FACES){ -#if 0 /* totparent is UNUSED */ - totparent=(int)(totchild*part->parents*0.3); - - if(G.rendering && part->child_nbr && part->ren_child_nbr) - totparent*=(float)part->child_nbr/(float)part->ren_child_nbr; -#endif /* part->parents could still be 0 so we can't test with totparent */ between=1; } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 62bfde601f6..e35504d73d7 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -223,6 +223,15 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) newpars= MEM_callocN(totpart*sizeof(ParticleData), "particles"); if(psys->part->phystype == PART_PHYS_BOIDS) newboids= MEM_callocN(totpart*sizeof(BoidParticle), "boid particles"); + + if(ELEM(NULL, newpars, newboids)) { + /* allocation error! */ + if(newpars) + MEM_freeN(newpars); + if(newboids) + MEM_freeN(newboids); + return; + } } if(psys->particles) { @@ -3402,8 +3411,6 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) BoidBrainData bbd; PARTICLE_P; float timestep; - /* current time */ - /* float ctime; */ /*UNUSED*/ /* frame & time changes */ float dfra, dtime; float birthtime, dietime; @@ -3412,7 +3419,6 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) dfra= cfra - psys->cfra; timestep = psys_get_timestep(sim); - /*ctime= cfra*timestep;*/ /*UNUSED*/ dtime= dfra*timestep; if(dfra<0.0){ @@ -3675,7 +3681,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) if( fluidmd && fluidmd->fss) { FluidsimSettings *fss= fluidmd->fss; ParticleSettings *part = psys->part; - ParticleData *pa=0; + ParticleData *pa=NULL; const char *suffix = "fluidsurface_particles_####"; const char *suffix2 = ".gz"; char filename[256]; -- cgit v1.2.3 From ce7f7d6e5fe98ab6fc1a7bfee3635851dce48421 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 27 Jan 2011 12:36:48 +0000 Subject: r34526 removed a line which had an unused return value but still needed to run. --- source/blender/blenkernel/intern/particle.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 492b78f7365..11ea82803eb 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1970,6 +1970,7 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float } mul_v3_fl(par_vec, -1.f); + normalize_v3_v3(vec_one, par_vec); inp_y=dot_v3v3(y_vec, vec_one); inp_z=dot_v3v3(z_vec, vec_one); -- cgit v1.2.3 From ba9dacbd3dc7e0ff80b2bb7e54dd2c1532db5512 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Thu, 27 Jan 2011 17:29:22 +0000 Subject: Silly mistake in own previous commit, now we have particles again! --- source/blender/blenkernel/intern/particle_system.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (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 e35504d73d7..a0948e61708 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -221,16 +221,18 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) if(totpart) { newpars= MEM_callocN(totpart*sizeof(ParticleData), "particles"); - if(psys->part->phystype == PART_PHYS_BOIDS) + if(newpars == NULL) + return; + + if(psys->part->phystype == PART_PHYS_BOIDS) { newboids= MEM_callocN(totpart*sizeof(BoidParticle), "boid particles"); - if(ELEM(NULL, newpars, newboids)) { - /* allocation error! */ - if(newpars) - MEM_freeN(newpars); - if(newboids) - MEM_freeN(newboids); - return; + if(newboids == NULL) { + /* allocation error! */ + if(newpars) + MEM_freeN(newpars); + return; + } } } -- cgit v1.2.3 From a68a44817a7f3c0da43f7349911e6924929ec223 Mon Sep 17 00:00:00 2001 From: Daniel Salazar Date: Thu, 27 Jan 2011 21:05:01 +0000 Subject: More logical ordering of Empty draw types. Made Plain Axes default for new empties --- 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 0b9798f861b..9df55b825b7 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1019,7 +1019,7 @@ Object *add_only_object(int type, const char *name) unit_m4(ob->parentinv); unit_m4(ob->obmat); ob->dt= OB_TEXTURE; - ob->empty_drawtype= OB_ARROWS; + ob->empty_drawtype= OB_PLAINAXES; ob->empty_drawsize= 1.0; if(type==OB_CAMERA || type==OB_LAMP) { -- cgit v1.2.3 From 53b83262c5ee5a2e71c23a3702cef8eef604f94b Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 28 Jan 2011 00:59:42 +0000 Subject: Fix for [#25713] VSE shows and renders wrong straight alpha gradient even after convert to premul is checked * Caching of the start and end stills were just referencing the original imbuf (which got premultiplied after the caching), so as a result most of the time the premul was applied twice. * Now the start and end stills are stored in the cache as duplicates of the original (non modified) imbuf. --- source/blender/blenkernel/intern/seqcache.c | 5 +++-- source/blender/blenkernel/intern/sequencer.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 122e186bcd7..78cd4bb51fe 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -232,8 +232,9 @@ void seq_stripelem_cache_put( key->cfra = cfra - seq->start; key->type = type; - /* we want our own version */ - IMB_refImBuf(i); + /* Normally we want our own version, but start and end stills are duplicates of the original. */ + if(ELEM(type, SEQ_STRIPELEM_IBUF_STARTSTILL, SEQ_STRIPELEM_IBUF_ENDSTILL)==0) + IMB_refImBuf(i); e = (seqCacheEntry*) BLI_mempool_alloc(entrypool); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 9ffc04c5191..973f14d690c 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1705,13 +1705,13 @@ static void copy_to_ibuf_still(SeqRenderData context, Sequence * seq, float nr, if (nr == 0) { seq_stripelem_cache_put( context, seq, seq->start, - SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf); + SEQ_STRIPELEM_IBUF_STARTSTILL, IMB_dupImBuf(ibuf)); } if (nr == seq->len - 1) { seq_stripelem_cache_put( context, seq, seq->start, - SEQ_STRIPELEM_IBUF_ENDSTILL, ibuf); + SEQ_STRIPELEM_IBUF_ENDSTILL, IMB_dupImBuf(ibuf)); } } -- cgit v1.2.3 From 73f48ef3f83332deb0fb19da85e2aae9248b9b51 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 28 Jan 2011 13:14:01 +0000 Subject: Fix for [#25843] Multiple Scene Strip in Sequencer, bad scrubbing for armatures in viewport * Sequencer didn't restore the scene properly after drawing a frame other than the current frame. --- source/blender/blenkernel/intern/sequencer.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 973f14d690c..beda03e2257 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1952,6 +1952,8 @@ static ImBuf * seq_render_scene_strip_impl( seq->scene->r.cfra = oldcfra; seq->scene->camera= oldcamera; + if(frame != oldcfra) + scene_update_for_newframe(context.bmain, seq->scene, seq->scene->lay); #ifdef DURIAN_CAMERA_SWITCH /* stooping to new low's in hackyness :( */ -- cgit v1.2.3 From c709524dc9a2489c9f0af7107ad5246952d2250f Mon Sep 17 00:00:00 2001 From: "M.G. Kishalmi" Date: Sat, 29 Jan 2011 11:56:11 +0000 Subject: new bumpmapping options for the renderer oldbump -> original newbump -> compatible *new* -> default (3tap) *new* -> best quality (5tap) the latter two have an option to apply bumpmapping in viewspace - much like displacement mapping objectspace - default (scales with the object) texturespace - much like normal mapping (scales) --- source/blender/blenkernel/intern/material.c | 2 +- source/blender/blenkernel/intern/texture.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index c22384a6bdc..c49d8310789 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -820,7 +820,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) /* always get derivatives for these textures */ if ELEM3(mtex->tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP) ma->texco |= TEXCO_OSA; - else if(mtex->texflag & MTEX_NEW_BUMP) ma->texco |= TEXCO_OSA; + else if(mtex->texflag & (MTEX_COMPAT_BUMP|MTEX_3TAP_BUMP|MTEX_5TAP_BUMP)) ma->texco |= TEXCO_OSA; if(ma->texco & (TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM|TEXCO_STRAND|TEXCO_STRESS)) needuv= 1; else if(ma->texco & (TEXCO_GLOB|TEXCO_UV|TEXCO_OBJECT|TEXCO_SPEED)) needuv= 1; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 11c0ce74b4a..48903fa5f5f 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -630,7 +630,8 @@ void default_mtex(MTex *mtex) mtex->size[1]= 1.0; mtex->size[2]= 1.0; mtex->tex= 0; - mtex->texflag= MTEX_NEW_BUMP; + mtex->texflag= MTEX_3TAP_BUMP; + mtex->texflag= MTEX_BUMP_OBJECTSPACE; mtex->colormodel= 0; mtex->r= 1.0; mtex->g= 0.0; -- cgit v1.2.3 From 89c617a1168294037b8878752b82daa1311a7b73 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 30 Jan 2011 15:29:22 +0000 Subject: remove nan-makefiles --- source/blender/blenkernel/intern/Makefile | 156 ------------------------------ 1 file changed, 156 deletions(-) delete mode 100644 source/blender/blenkernel/intern/Makefile (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/Makefile b/source/blender/blenkernel/intern/Makefile deleted file mode 100644 index 53a9999758c..00000000000 --- a/source/blender/blenkernel/intern/Makefile +++ /dev/null @@ -1,156 +0,0 @@ -# -# $Id$ -# -# ***** 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 ***** -# -# - -LIBNAME = blenkernel -DIR = $(OCGDIR)/blender/$(LIBNAME) - -include nan_compile.mk - -CFLAGS += $(LEVEL_1_C_WARNINGS) - -# OpenGL and Python -CPPFLAGS += -I$(NAN_GLEW)/include -CPPFLAGS += -I$(OPENGL_HEADERS) -CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) - -CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include -CPPFLAGS += -I../../../../intern/memutil -CPPFLAGS += -I$(NAN_AUDASPACE)/include -# Reference to the types in makesdna and imbuf -CPPFLAGS += -I../../makesdna -CPPFLAGS += -I../../makesrna -CPPFLAGS += -I../../imbuf -CPPFLAGS += -I../../ikplugin -# This mod uses the BLI and BLO module -CPPFLAGS += -I../../blenlib -CPPFLAGS += -I../../blenloader -CPPFLAGS += -I../../python -CPPFLAGS += -I../../blenfont -# This is bad level, remove eventually -CPPFLAGS += -I../../windowmanager -# also avi is used -CPPFLAGS += -I../../avi -CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include - -# we still refer to /include a bit... -CPPFLAGS += -I../../editors/include - -# to include the render stuff: -CPPFLAGS += -I../../render/extern/include - -# for sound -#CPPFLAGS += -I../../../kernel/gen_system -CPPFLAGS += $(NAN_SDLCFLAGS) - -CPPFLAGS += -I$(NAN_IKSOLVER)/include -CPPFLAGS += -I$(NAN_DECIMATION)/include -CPPFLAGS += -I$(NAN_ELBEEM)/include -CPPFLAGS += -I$(NAN_OPENNL)/include -CPPFLAGS += -I$(NAN_BSP)/include -CPPFLAGS += -I$(NAN_SMOKE)/include - -# path to zlib -CPPFLAGS += -I$(NAN_ZLIB)/include - -#path to nodes -CPPFLAGS += -I../../nodes - -#path to gpu -CPPFLAGS += -I../../gpu - -#modifiers got moved -CPPFLAGS += -I../../modifiers - -# path to our own external headerfiles -CPPFLAGS += -I.. - -CPPFLAGS += -I$(NAN_FREETYPE)/include -CPPFLAGS += -I$(NAN_FREETYPE)/include/freetype2 - -# path to bullet2, for cloth -ifeq ($(NAN_USE_BULLET), true) - CPPFLAGS += -I$(NAN_BULLET2)/include -endif - -# lzo and lzma, for pointcache -ifeq ($(WITH_LZO),true) - CPPFLAGS += -I$(NAN_LZO)/minilzo - CPPFLAGS += -DWITH_LZO -endif - -ifeq ($(WITH_LZO),true) - CPPFLAGS += -I$(NAN_LZMA) - CPPFLAGS += -DWITH_LZMA -endif - -ifeq ($(WITH_FFMPEG),true) - CPPFLAGS += -DWITH_FFMPEG - CPPFLAGS += $(NAN_FFMPEGCFLAGS) -endif - -ifeq ($(WITH_OPENEXR), true) - CPPFLAGS += -DWITH_OPENEXR -endif - -ifeq ($(WITH_DDS), true) - CPPFLAGS += -DWITH_DDS -endif - -ifeq ($(WITH_OPENJPEG), true) - CPPFLAGS += -DWITH_OPENJPEG -endif - -ifeq ($(WITH_QUICKTIME), true) - CPPFLAGS += -I../../quicktime - CPPFLAGS += -DWITH_QUICKTIME -endif - -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 - endif -endif - -ifeq ($(WITH_LCMS), true) - CPPFLAGS += -DWITH_LCMS - CPPFLAGS += -I$(BF_LCMS_INC) -endif -- cgit v1.2.3 From d5da54e1e648c264cadc77fd43d80d4ef29688f2 Mon Sep 17 00:00:00 2001 From: "M.G. Kishalmi" Date: Sun, 30 Jan 2011 16:24:23 +0000 Subject: bugfix #25867 fix for objectspace bumpmapping --- source/blender/blenkernel/intern/texture.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 48903fa5f5f..de08a3b1813 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -630,8 +630,7 @@ void default_mtex(MTex *mtex) mtex->size[1]= 1.0; mtex->size[2]= 1.0; mtex->tex= 0; - mtex->texflag= MTEX_3TAP_BUMP; - mtex->texflag= MTEX_BUMP_OBJECTSPACE; + mtex->texflag= MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE; mtex->colormodel= 0; mtex->r= 1.0; mtex->g= 0.0; -- cgit v1.2.3 From 14d8921fff3563a3ba1127fe55bf4b558f42566a Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 30 Jan 2011 17:55:48 +0000 Subject: Total displacement levels should be set in multires_topology_changed --- source/blender/blenkernel/intern/multires.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 0fb19685f25..c67abc47e6f 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1720,11 +1720,15 @@ void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob) } /* update multires data after topology changing */ -void multires_topology_changed(Object *ob) +void multires_topology_changed(Scene *scene, Object *ob) { Mesh *me= (Mesh*)ob->data; MDisps *mdisp= NULL, *cur= NULL; int i, grid= 0, corners; + MultiresModifierData *mmd= get_multires_modifier(scene, ob); + + if(mmd) + multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); mdisp= CustomData_get_layer(&me->fdata, CD_MDISPS); -- cgit v1.2.3 From 329e2d8037050e06d16984924a412e8b32ad4351 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 31 Jan 2011 20:02:51 +0000 Subject: Todo issue: sculpting on deformed mesh Used a crazyspace approach (like in edit mode), but only modifiers with deformMatricies are allowed atm (currently shapekeys and armature modifiers only). All the rest modifiers had an warning message that they aren't applied because of sculpt mode. Deformation of multires is also unsupported. With all this restictions users will always see the actual "layer" (or maybe mesh state would be more correct word) they are sculpting on. Internal changes: - All modifiers could have deformMatricies callback (the same as deformMatriciesEM but for non-edit mode usage) - Added function to build crazyspace for sculpting (sculpt_get_deform_matrices), but it could be generalized for usage in other painting modes (particle edit mode, i.e) Todo: - Implement crazyspace correction to support all kinds of deformation modifiers - Maybe deformation of multires isn't so difficult? - And maybe we could avoid extra bad-level-stub for ED_sculpt_modifiers_changed without code duplicating? --- source/blender/blenkernel/intern/DerivedMesh.c | 81 +++++++++++++++++++++--- source/blender/blenkernel/intern/cdderivedmesh.c | 12 ++++ source/blender/blenkernel/intern/multires.c | 16 +++-- source/blender/blenkernel/intern/object.c | 7 ++ source/blender/blenkernel/intern/subsurf_ccg.c | 62 +++--------------- 5 files changed, 109 insertions(+), 69 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index a2ef625c6e6..658d29f0046 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -53,6 +53,7 @@ #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_texture.h" +#include "BKE_multires.h" #include "BLO_sys_types.h" // for intptr_t support @@ -65,6 +66,8 @@ #include "GPU_extensions.h" #include "GPU_material.h" +#include "ED_sculpt.h" /* for ED_sculpt_modifiers_changed */ + /////////////////////////////////// /////////////////////////////////// @@ -1676,6 +1679,12 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos int required_mode; int isPrevDeform= FALSE; int skipVirtualArmature = (useDeform < 0); + MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0); + int has_multires = mmd != NULL, multires_applied = 0; + int sculpt_mode = ob->mode & OB_MODE_SCULPT && ob->sculpt; + + if(mmd && !mmd->sculptlvl) + has_multires = 0; if(!skipVirtualArmature) { firstmd = modifiers_getVirtualModifierList(ob); @@ -1714,6 +1723,12 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue; if(mti->type == eModifierTypeType_OnlyDeform) { + if(sculpt_mode && !has_multires) + if(!ELEM(md->type, eModifierType_Armature, eModifierType_ShapeKey)) { + modifier_setError(md, "Not supported in sculpt mode."); + continue; + } + if(!deformedVerts) deformedVerts = mesh_getVertexCos(me, &numVerts); @@ -1759,13 +1774,18 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos ModifierTypeInfo *mti = modifierType_getInfo(md->type); md->scene= scene; - + if(!modifier_isEnabled(scene, md, required_mode)) continue; if(mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue; if((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) { modifier_setError(md, "Modifier requires original data, bad stack position."); continue; } + if(sculpt_mode && (!has_multires || multires_applied)) + if(md->type != eModifierType_Armature || multires_applied) { + modifier_setError(md, "Not supported in sculpt mode."); + continue; + } if(needMapping && !modifier_supportsMapping(md)) continue; if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue; @@ -1928,6 +1948,9 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos /* grab modifiers until index i */ if((index >= 0) && (modifiers_indexInObject(ob, md) >= index)) break; + + if(sculpt_mode && md->type == eModifierType_Multires) + multires_applied = 1; } for(md=firstmd; md; md=md->next) @@ -2222,14 +2245,9 @@ static void clear_mesh_caches(Object *ob) ob->derivedDeform->release(ob->derivedDeform); ob->derivedDeform= NULL; } - /* we free pbvh on changes, except during sculpt since it can't deal with - changing PVBH node organization, we hope topology does not change in - the meantime .. weak */ - if(ob->sculpt && ob->sculpt->pbvh) { - if(!ob->sculpt->cache) { - BLI_pbvh_free(ob->sculpt->pbvh); - ob->sculpt->pbvh= NULL; - } + + if(ob->sculpt) { + ED_sculpt_modifiers_changed(ob); } } @@ -2523,6 +2541,51 @@ int editmesh_get_first_deform_matrices(Scene *scene, Object *ob, EditMesh *em, f return numleft; } +void sculpt_get_deform_matrices(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]) +{ + ModifierData *md; + DerivedMesh *dm; + int a, numVerts= 0; + float (*defmats)[3][3]= NULL, (*deformedVerts)[3]= NULL; + MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0); + int has_multires = mmd != NULL && mmd->sculptlvl > 0; + + if(has_multires) { + *deformmats= NULL; + *deformcos= NULL; + return; + } + + dm= NULL; + md= modifiers_getVirtualModifierList(ob); + + for(; md; md= md->next) { + ModifierTypeInfo *mti= modifierType_getInfo(md->type); + + if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; + + if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatrices) { + if(!defmats) { + Mesh *me= (Mesh*)ob->data; + dm= getMeshDerivedMesh(me, ob, NULL); + deformedVerts= mesh_getVertexCos(me, &numVerts); + defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats"); + + for(a=0; adeformMatrices(md, ob, dm, deformedVerts, defmats, numVerts); + } + } + + if(dm) + dm->release(dm); + + *deformmats= defmats; + *deformcos= deformedVerts; +} + /* ******************* GLSL ******************** */ void DM_add_tangent_layer(DerivedMesh *dm) diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 71e704fe6c8..932be711938 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -76,6 +76,7 @@ typedef struct { /* Cached */ struct PBVH *pbvh; int pbvh_draw; + /* Mesh connectivity */ struct ListBase *fmap; struct IndexNode *fmap_mem; @@ -222,6 +223,17 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) cddm->pbvh_draw = can_pbvh_draw(ob, dm); BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert, me->totface, me->totvert); + + if(ob->sculpt->modifiers_active) { + float (*vertCos)[3]; + int totvert; + + totvert= dm->getNumVerts(dm); + vertCos= MEM_callocN(3*totvert*sizeof(float), "cdDM_getPBVH vertCos"); + dm->getVertCos(dm, vertCos); + BLI_pbvh_apply_vertCos(cddm->pbvh, vertCos); + MEM_freeN(vertCos); + } } return cddm->pbvh; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index c67abc47e6f..2a3052d10c9 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -92,8 +92,10 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData * return NULL; } -/* used for applying scale on mdisps layer and syncing subdivide levels when joining objects */ -static MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob) +/* used for applying scale on mdisps layer and syncing subdivide levels when joining objects + use_first - return first multires modifier if all multires'es are disabled +*/ +MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_first) { ModifierData *md; MultiresModifierData *mmd= NULL, *firstmmd= NULL; @@ -111,7 +113,7 @@ static MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob) } } - if(!mmd) { + if(!mmd && use_first) { /* active multires have not been found try to use first one */ return firstmmd; @@ -1568,8 +1570,8 @@ void multires_load_old(Object *ob, Mesh *me) static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) { - MultiresModifierData *mmd= get_multires_modifier(scene, ob); - MultiresModifierData *to_mmd= get_multires_modifier(scene, to_ob); + MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1); + MultiresModifierData *to_mmd= get_multires_modifier(scene, to_ob, 1); if(!mmd) { /* object could have MDISP even when there is no multires modifier @@ -1599,7 +1601,7 @@ void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) int *gridOffset; int i, /*numGrids,*/ gridSize, dGridSize, dSkip, totvert; float (*vertCos)[3] = NULL; - MultiresModifierData *mmd= get_multires_modifier(scene, ob); + MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1); MultiresModifierData high_mmd; CustomData_external_read(&me->fdata, &me->id, CD_MASK_MDISPS, me->totface); @@ -1725,7 +1727,7 @@ void multires_topology_changed(Scene *scene, Object *ob) Mesh *me= (Mesh*)ob->data; MDisps *mdisp= NULL, *cur= NULL; int i, grid= 0, corners; - MultiresModifierData *mmd= get_multires_modifier(scene, ob); + MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1); if(mmd) multires_set_tot_mdisps(me, mmd->totlvl); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 9df55b825b7..0d3fb7107f0 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -246,6 +246,13 @@ void free_sculptsession(Object *ob) if(ss->layer_co) MEM_freeN(ss->layer_co); + if(ss->orig_cos) + MEM_freeN(ss->orig_cos); + if(ss->deform_cos) + MEM_freeN(ss->deform_cos); + if(ss->deform_imats) + MEM_freeN(ss->deform_imats); + MEM_freeN(ss); ob->sculpt = NULL; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index e75dc27c7b5..a2d3016099d 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -70,8 +70,6 @@ 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) { @@ -1150,7 +1148,7 @@ static void ccgDM_drawVerts(DerivedMesh *dm) { static void ccgdm_pbvh_update(CCGDerivedMesh *ccgdm) { - if(ccgdm->pbvh && ccgDM_use_grid_pbvh(ccgdm)) { + if(ccgdm->pbvh) { CCGFace **faces; int totface; @@ -2240,28 +2238,10 @@ static ListBase *ccgDM_getFaceMap(Object *ob, DerivedMesh *dm) return ccgdm->fmap; } -static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm) -{ - ModifierData *md; - MultiresModifierData *mmd= ccgdm->multires.mmd; - - /* in sync with sculpt mode, only use multires grid pbvh if we are - the last enabled modifier in the stack, otherwise we use the base - mesh */ - if(!mmd) - return 0; - - for(md=mmd->modifier.next; md; md= md->next) - if(modifier_isEnabled(mmd->modifier.scene, md, eModifierMode_Realtime)) - return 0; - - return 1; -} - static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) { CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; - int gridSize, numGrids, grid_pbvh; + int gridSize, numGrids; if(!ob) { ccgdm->pbvh= NULL; @@ -2271,21 +2251,8 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) if(!ob->sculpt) return NULL; - grid_pbvh = ccgDM_use_grid_pbvh(ccgdm); - - if(ob->sculpt->pbvh) { - if(grid_pbvh) { - /* pbvh's grids, gridadj and gridfaces points to data inside ccgdm - but this can be freed on ccgdm release, this updates the pointers - when the ccgdm gets remade, the assumption is that the topology - does not change. */ - ccgdm_create_grids(dm); - BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void**)ccgdm->gridFaces); - } - + if(ob->sculpt->pbvh) ccgdm->pbvh = ob->sculpt->pbvh; - ccgdm->pbvh_draw = grid_pbvh; - } if(ccgdm->pbvh) return ccgdm->pbvh; @@ -2293,25 +2260,14 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) /* no pbvh exists yet, we need to create one. only in case of multires we build a pbvh over the modified mesh, in other cases the base mesh is being sculpted, so we build a pbvh from that. */ - if(grid_pbvh) { - ccgdm_create_grids(dm); - - gridSize = ccgDM_getGridSize(dm); - numGrids = ccgDM_getNumGrids(dm); + ccgdm_create_grids(dm); - ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new(); - BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, - numGrids, gridSize, (void**)ccgdm->gridFaces); - ccgdm->pbvh_draw = 1; - } - else if(ob->type == OB_MESH) { - Mesh *me= ob->data; + gridSize = ccgDM_getGridSize(dm); + numGrids = ccgDM_getNumGrids(dm); - ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new(); - BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert, - me->totface, me->totvert); - ccgdm->pbvh_draw = 0; - } + ob->sculpt->pbvh= ccgdm->pbvh = BLI_pbvh_new(); + BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, + numGrids, gridSize, (void**)ccgdm->gridFaces); return ccgdm->pbvh; } -- cgit v1.2.3 From 6fcc13a78694176ee76b0c811129c3b7fa4fd7f0 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Feb 2011 00:41:15 +0000 Subject: disable assert [#25877] Driven shapekeys: incorrect assertions in depsgraph.c --- source/blender/blenkernel/intern/depsgraph.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 71c3e76c207..cedf4e93247 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -2452,7 +2452,9 @@ void DAG_id_tag_update(ID *id, short flag) } } else { - BLI_assert(!"invalid flag for this 'idtype'"); + /* disable because this is called on various ID types automatically. + * where printing warning is not useful. for now just ignore */ + /* BLI_assert(!"invalid flag for this 'idtype'"); */ } } } -- cgit v1.2.3 From ffe7bde02c5725993e9c1986bbc8a83174adbbb8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Feb 2011 12:37:53 +0000 Subject: correct fix for bug #23871, __main__ module was being overwritten in nested functions, so on returning from calling operators the __main__ module could be cleared and imported modules turn into None calling bpy.ops.wm.read_factory_settings() ... would clear a scripts namespace if running directly, not in a module. Fix by backing up and restoring the __main__ module. Also found BKE_reportf wasnt printing all reports in background mode as BKE_report() was doing. --- source/blender/blenkernel/intern/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index e623c095ac7..044e1350be1 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -124,7 +124,7 @@ void BKE_reportf(ReportList *reports, ReportType type, const char *format, ...) Report *report; va_list args; - if(!reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) { + if(G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) { va_start(args, format); vprintf(format, args); va_end(args); -- cgit v1.2.3 From bc36e39c233d61b3dbefedb7fa4f98228d225a94 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Feb 2011 21:24:59 +0000 Subject: fix issue #2 raised by report: [#25894] Problems with properties across files --- source/blender/blenkernel/intern/object.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 0d3fb7107f0..625410324a3 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -59,11 +59,9 @@ #include "BLI_pbvh.h" #include "BLI_utildefines.h" - - #include "BKE_main.h" #include "BKE_global.h" - +#include "BKE_idprop.h" #include "BKE_armature.h" #include "BKE_action.h" #include "BKE_bullet.h" @@ -1605,7 +1603,17 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) armature_set_id_extern(ob); } - + + /* copy IDProperties */ + if(ob->id.properties) { + IDP_FreeProperty(ob->id.properties); + MEM_freeN(ob->id.properties); + ob->id.properties= NULL; + } + if(target->id.properties) { + ob->id.properties= IDP_CopyProperty(target->id.properties); + } + /* copy drawtype info */ ob->dt= target->dt; } -- cgit v1.2.3 From 95df65f1b55d311be4171f71bb106f9c7d193a79 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 2 Feb 2011 00:40:55 +0000 Subject: - some parts of the code to remove rotation were not removing axis/angle rotation (only functional change of this commit). - use BLI_math functions for removing rotations from objects and pose channels. - add unit_axis_angle() to avoid setting the Y axis inline anywhere rotation needs removing. --- source/blender/blenkernel/intern/action.c | 20 ++++++++------------ source/blender/blenkernel/intern/object.c | 11 +++++++---- 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 08b57ba18a3..3bfdbdc4fc9 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -424,7 +424,8 @@ bPoseChannel *verify_pose_channel(bPose *pose, const char *name) BLI_strncpy(chan->name, name, sizeof(chan->name)); /* init vars to prevent math errors */ - chan->quat[0] = chan->rotAxis[1]= 1.0f; + unit_qt(chan->quat); + unit_axis_angle(chan->rotAxis, &chan->rotAngle); chan->size[0] = chan->size[1] = chan->size[2] = 1.0f; chan->limitmin[0]= chan->limitmin[1]= chan->limitmin[2]= -180.0f; @@ -1041,7 +1042,6 @@ void extract_pose_from_pose(bPose *pose, const bPose *src) void rest_pose(bPose *pose) { bPoseChannel *pchan; - int i; if (!pose) return; @@ -1050,16 +1050,12 @@ void rest_pose(bPose *pose) memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset)); for (pchan=pose->chanbase.first; pchan; pchan= pchan->next) { - for (i=0; i<3; i++) { - pchan->loc[i]= 0.0f; - pchan->quat[i+1]= 0.0f; - pchan->eul[i]= 0.0f; - pchan->size[i]= 1.0f; - pchan->rotAxis[i]= 0.0f; - } - pchan->quat[0]= pchan->rotAxis[1]= 1.0f; - pchan->rotAngle= 0.0f; - + zero_v3(pchan->loc); + zero_v3(pchan->eul); + unit_qt(pchan->quat); + unit_axis_angle(pchan->rotAxis, &pchan->rotAngle); + pchan->size[0]= pchan->size[1]= pchan->size[2]= 1.0f; + pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE); } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 625410324a3..5704814e97b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1013,10 +1013,13 @@ Object *add_only_object(int type, const char *name) * but rotations default to quaternions */ ob->rotmode= ROT_MODE_EUL; - /* axis-angle must not have a 0,0,0 axis, so set y-axis as default... */ - ob->rotAxis[1]= ob->drotAxis[1]= 1.0f; - /* quaternions should be 1,0,0,0 by default.... */ - ob->quat[0]= ob->dquat[0]= 1.0f; + + unit_axis_angle(ob->rotAxis, &ob->rotAngle); + unit_axis_angle(ob->drotAxis, &ob->drotAngle); + + unit_qt(ob->quat); + unit_qt(ob->dquat); + /* rotation locks should be 4D for 4 component rotations by default... */ ob->protectflag = OB_LOCK_ROT4D; -- cgit v1.2.3 From c57cd7c5bdb9a45516da9fa8310e903e921f7fc8 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 2 Feb 2011 01:01:01 +0000 Subject: bugfix for setting the worldspace matrix of an object which used quaternion rotation and deltas, was subtracting the values rather then multiplying by the inverse. effected 'Apply Visual Transform' & pythons obj.matrix_world = mat --- source/blender/blenkernel/intern/object.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 5704814e97b..36350f23b6d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1704,8 +1704,13 @@ void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) { switch(ob->rotmode) { case ROT_MODE_QUAT: - mat3_to_quat(ob->quat, mat); - sub_v4_v4(ob->quat, ob->dquat); + { + float dquat[4]; + mat3_to_quat(ob->quat, mat); + normalize_qt_qt(dquat, ob->dquat); + invert_qt(dquat); + mul_qt_qtqt(ob->quat, dquat, ob->quat); + } break; case ROT_MODE_AXISANGLE: mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat); -- cgit v1.2.3 From 4e8a8d1e8f59c2b97ce064d52fdab290ca8b2f3d Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 4 Feb 2011 15:48:13 +0000 Subject: Improvements for particle grid distribution: * Particles that aren't shown are now actually deleted (huge memory savings for flat objects). * Grid distribution for flat objects is now done on the surface object surface without offset. * Invert grid option wasn't in ui and it didn't work for non-volume grids. * New parameter to randomize the grid point locations. * Resolution soft/hard limits changed to even 50/250. --- source/blender/blenkernel/intern/particle_system.c | 77 ++++++++++++++++++++-- 1 file changed, 70 insertions(+), 7 deletions(-) (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 a0948e61708..4d3a908edb0 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -137,9 +137,9 @@ static int tot_particles(ParticleSystem *psys, PTCacheID *pid) if(pid && psys->pointcache->flag & PTCACHE_EXTERNAL) return pid->cache->totpoint; else if(psys->part->distr == PART_DISTR_GRID && psys->part->from != PART_FROM_VERT) - return psys->part->grid_res * psys->part->grid_res * psys->part->grid_res; + return psys->part->grid_res * psys->part->grid_res * psys->part->grid_res - psys->totunexist; else - return psys->part->totpart; + return psys->part->totpart - psys->totunexist; } void psys_reset(ParticleSystem *psys, int mode) @@ -439,9 +439,14 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) size[(axis+1)%3] = MIN2(size[(axis+1)%3],res); size[(axis+2)%3] = MIN2(size[(axis+2)%3],res); - min[0]+=d/2.0f; - min[1]+=d/2.0f; - min[2]+=d/2.0f; + size[0] = MAX2(size[0], 1); + size[1] = MAX2(size[1], 1); + size[2] = MAX2(size[2], 1); + + /* no full offset for flat/thin objects */ + min[0]+= d < delta[0] ? d/2.f : delta[0]/2.f; + min[1]+= d < delta[1] ? d/2.f : delta[1]/2.f; + min[2]+= d < delta[2] ? d/2.f : delta[2]/2.f; for(i=0,p=0,pa=psys->particles; iparticles + a1*a1mul + a2*a2mul; VECCOPY(co1,pa->fuv); - co1[a]-=d/2.0f; + co1[a]-= d < delta[a] ? d/2.f : delta[a]/2.f; VECCOPY(co2,co1); co2[a]+=delta[a] + 0.001f*d; co1[a]-=0.001f*d; @@ -553,6 +558,18 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) } } } + + if(psys->part->grid_rand > 0.f) { + float rfac = d * psys->part->grid_rand; + for(p=0,pa=psys->particles; ptotpart; p++,pa++){ + if(pa->flag & PARS_UNEXIST) + continue; + + pa->fuv[0] += rfac * (PSYS_FRAND(p + 31) - 0.5f); + pa->fuv[1] += rfac * (PSYS_FRAND(p + 32) - 0.5f); + pa->fuv[2] += rfac * (PSYS_FRAND(p + 33) - 0.5f); + } + } } /* modified copy from rayshade.c */ @@ -1554,8 +1571,51 @@ static void initialize_all_particles(ParticleSimulationData *sim) ParticleSystem *psys = sim->psys; PARTICLE_P; - LOOP_PARTICLES + psys->totunexist = 0; + + LOOP_PARTICLES { initialize_particle(sim, pa, p); + if(pa->flag & PARS_UNEXIST) + psys->totunexist++; + } + + /* Free unexisting particles. */ + if(psys->totpart && psys->totunexist == psys->totpart) { + if(psys->particles->boid) + MEM_freeN(psys->particles->boid); + + MEM_freeN(psys->particles); + psys->particles = NULL; + psys->totpart = psys->totunexist = 0; + } + + if(psys->totunexist) { + int newtotpart = psys->totpart - psys->totunexist; + ParticleData *npa, *newpars; + + npa = newpars = MEM_callocN(newtotpart * sizeof(ParticleData), "particles"); + + for(p=0, pa=psys->particles; pflag & PARS_UNEXIST) + pa++; + + memcpy(npa, pa, sizeof(ParticleData)); + } + + if(psys->particles->boid) + MEM_freeN(psys->particles->boid); + MEM_freeN(psys->particles); + psys->particles = newpars; + psys->totpart -= psys->totunexist; + + if(psys->particles->boid) { + BoidParticle *newboids = MEM_callocN(psys->totpart * sizeof(BoidParticle), "boid particles"); + + LOOP_PARTICLES + pa->boid = newboids++; + + } + } if(psys->part->type != PART_FLUID) { #if 0 // XXX old animation system @@ -4091,6 +4151,9 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if(psys->recalc & PSYS_RECALC_TYPE) psys_changed_type(&sim); + if(psys->recalc & PSYS_RECALC_RESET) + psys->totunexist = 0; + /* setup necessary physics type dependent additional data if it doesn't yet exist */ psys_prepare_physics(&sim); -- cgit v1.2.3 From 4925581820db4c0ddfe6e2fb818e4834509dfca0 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 4 Feb 2011 16:10:30 +0000 Subject: Fix #25933: Drag Dog stroke method uses Jitter if set for other stroke method, but no jitter available. Manually disable jitter usage for anchored and drag dot brush stroke metdhods. Jitter slider is hidden in UI for this strokes so users can't set it to 0 by hand and even if this slider would be visible in UI jitter gives wierd result for this stroke methods. --- source/blender/blenkernel/intern/brush.c | 8 +++++++- 1 file changed, 7 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 a78d2ecaaa2..b1931ebe0a7 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -907,7 +907,13 @@ static void brush_apply_pressure(BrushPainter *painter, Brush *brush, float pres void brush_jitter_pos(Brush *brush, float *pos, float *jitterpos) { - if(brush->jitter){ + int use_jitter= brush->jitter != 0; + + /* jitter-ed brush gives wierd and unpredictable result for this + kinds of stroke, so manyally disable jitter usage (sergey) */ + use_jitter&= (brush->flag & (BRUSH_RESTORE_MESH|BRUSH_ANCHORED)) == 0; + + if(use_jitter){ float rand_pos[2]; const int radius= brush_size(brush); const int diameter= 2*radius; -- cgit v1.2.3 From 90cf78eb5409a77c912b90fb812a4391e31897ae Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 5 Feb 2011 13:19:14 +0000 Subject: Fix bones moving when changing between editmode and posemode. Patch #25901 by Tobias Oelgarte. Bone transformations would be converted back and forth between different representations when changing modes, which due to numerical errors could lead to bone transformations slowly changing as you edit the armature. Now the editmode head, tail and roll values are stored in bones and used directly when entering edit mode. Head and tail were already there but now we ensure they are the exact same value, roll was not yet there, so we have a version patch for it. The sub version was incremented to 1 for the version patch. --- source/blender/blenkernel/intern/armature.c | 7 ------- 1 file changed, 7 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 1a219939b77..14c4b6f97ab 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1401,13 +1401,6 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) VECCOPY(bone->arm_mat[3], bone->head); } - /* head */ - VECCOPY(bone->arm_head, bone->arm_mat[3]); - /* tail is in current local coord system */ - VECCOPY(vec, bone->arm_mat[1]); - mul_v3_fl(vec, bone->length); - add_v3_v3v3(bone->arm_tail, bone->arm_head, vec); - /* and the kiddies */ prevbone= bone; for(bone= bone->childbase.first; bone; bone= bone->next) { -- cgit v1.2.3 From 04299657a7eaee212b983b27bed6b66793f7a985 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 5 Feb 2011 13:41:29 +0000 Subject: Raytrace modifications from the Render Branch. These should not have any effect on render results, except in some cases with you have overlapping faces, where the noise seems to be slightly reduced. There are some performance improvements, for simple scenes I wouldn't expect more than 5-10% to be cut off the render time, for sintel scenes we got about 50% on average, that's with millions of polygons on intel quad cores. This because memory access / cache misses were the main bottleneck for those scenes, and the optimizations improve that. Interal changes: * Remove RE_raytrace.h, raytracer is now only used by render engine again. * Split non-public parts rayobject.h into rayobject_internal.h, hopefully makes it clearer how the API is used. * Added rayintersection.h to contain some of the stuff from RE_raytrace.h * Change Isect.vec/labda to Isect.dir/dist, previously vec was sometimes normalized and sometimes not, confusing... now dir is always normalized and dist contains the distance. * Change VECCOPY and similar to BLI_math functions. * Force inlining of auxiliary functions for ray-triangle/quad intersection, helps a few percentages. * Reorganize svbvh code so all the traversal functions are in one file * Don't do test for root so that push_childs can be inlined * Make shadow a template parameter so it doesn't need to be runtime checked * Optimization in raytree building, was computing bounding boxes more often than necessary. * Leave out logf() factor in SAH, makes tree build quicker with no noticeable influence on raytracing on performance? * Set max childs to 4, simplifies traversal code a bit, but also seems to help slightly in general. * Store child pointers and child bb just as fixed arrays of size 4 in nodes, nearly all nodes have this many children, so overall it actually reduces memory usage a bit and avoids a pointer indirection. --- 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 94eed530ad6..853e9e108d6 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -374,6 +374,7 @@ Scene *add_scene(const char *name) sce->r.fg_stamp[3]= 1.0f; sce->r.bg_stamp[0]= sce->r.bg_stamp[1]= sce->r.bg_stamp[2]= 0.0f; sce->r.bg_stamp[3]= 0.25f; + sce->r.raytrace_options = R_RAYTRACE_USE_INSTANCES; sce->r.seq_prev_type= OB_SOLID; sce->r.seq_rend_type= OB_SOLID; -- cgit v1.2.3 From dbce60448f3bd3cee291a482986740507fcce0f5 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Sat, 5 Feb 2011 15:11:29 +0000 Subject: This fixes: [#25608] Video Sequence Editor: problem using cut on a strip with a custom proxy file. --- source/blender/blenkernel/intern/sequencer.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index beda03e2257..6aca23b8011 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -3541,6 +3541,7 @@ static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence if (seq->strip->proxy) { seqn->strip->proxy = MEM_dupallocN(seq->strip->proxy); + seqn->strip->proxy->anim = 0; } if (seq->strip->color_balance) { -- cgit v1.2.3 From 0ea9271f43e7e8ef914d33244d658ad7b5720f1f Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 6 Feb 2011 15:50:00 +0000 Subject: Bug fix: Particles in dupligroups were mostly drawn properly in 3d view, but rendering them was a real mess. * After countless different bugs particles should now render correctly inside dupligroups. * Only particles with metaball visualization are still problematic, this is mostly due to the ancient metaball code. * I'll also add a test file for some of the situations, so that hopefully these cases stay fixed :) --- source/blender/blenkernel/intern/anim.c | 6 +++--- source/blender/blenkernel/intern/particle.c | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 68a949ed25a..ab1da04e683 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1156,7 +1156,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa dm->release(dm); } -static void new_particle_duplilist(ListBase *lb, ID *UNUSED(id), Scene *scene, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level, int animated) +static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level, int animated) { GroupObject *go; Object *ob=0, **oblist=0, obcopy, *obcopylist=0; @@ -1375,7 +1375,7 @@ static void new_particle_duplilist(ListBase *lb, ID *UNUSED(id), Scene *scene, O /* Normal particles and cached hair live in global space so we need to * remove the real emitter's transformation before 2nd order duplication. */ - if(par_space_mat) + if(par_space_mat && GS(id->name) != ID_GR) mul_m4_m4m4(mat, pamat, psys->imat); else copy_m4_m4(mat, pamat); @@ -1391,7 +1391,7 @@ static void new_particle_duplilist(ListBase *lb, ID *UNUSED(id), Scene *scene, O if(part->draw & PART_DRAW_GLOBAL_OB) VECADD(mat[3], mat[3], vec); - dob= new_dupli_object(lb, ob, mat, ob->lay, counter, OB_DUPLIPARTS, animated); + dob= new_dupli_object(lb, ob, mat, ob->lay, counter, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated); copy_m4_m4(dob->omat, oldobmat); if(G.rendering) psys_get_dupli_texture(par, part, sim.psmd, pa, cpa, dob->uv, dob->orco); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 11ea82803eb..f6b97dcb78e 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1194,12 +1194,12 @@ static void mvert_to_particle(ParticleKey *key, MVert *mvert, HairKey *hkey) key->time = hkey->time; } -static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData *pa, float t, float frs_sec, ParticleInterpolationData *pind, ParticleKey *result) +static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData *pa, float t, ParticleInterpolationData *pind, ParticleKey *result) { PTCacheEditPoint *point = pind->epoint; ParticleKey keys[4]; int point_vel = (point && point->keys->vel); - float real_t, dfra, keytime; + float real_t, dfra, keytime, invdt; /* billboards wont fill in all of these, so start cleared */ memset(keys, 0, sizeof(keys)); @@ -1338,11 +1338,12 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData dfra = keys[2].time - keys[1].time; keytime = (real_t - keys[1].time) / dfra; + invdt = dfra * 0.04f * psys->part->timetweak; /* convert velocity to timestep size */ if(pind->keyed || pind->cache || point_vel){ - mul_v3_fl(keys[1].vel, dfra / frs_sec); - mul_v3_fl(keys[2].vel, dfra / frs_sec); + mul_v3_fl(keys[1].vel, invdt); + mul_v3_fl(keys[2].vel, invdt); interp_qt_qtqt(result->rot,keys[1].rot,keys[2].rot,keytime); } @@ -1353,7 +1354,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData /* the velocity needs to be converted back from cubic interpolation */ if(pind->keyed || pind->cache || point_vel) - mul_v3_fl(result->vel, frs_sec / dfra); + mul_v3_fl(result->vel, 1.f/invdt); } /************************************************/ /* Particles on a dm */ @@ -2954,7 +2955,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) time = (float)k / (float)steps; t = birthtime + time * (dietime - birthtime); result.time = -t; - do_particle_interpolation(psys, p, pa, t, frs_sec, &pind, &result); + do_particle_interpolation(psys, p, pa, t, &pind, &result); copy_v3_v3(ca->co, result.co); /* dynamic hair is in object space */ @@ -3133,7 +3134,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf time = (float)k / (float)steps; t = birthtime + time * (dietime - birthtime); result.time = -t; - do_particle_interpolation(psys, i, pa, t, frs_sec, &pind, &result); + do_particle_interpolation(psys, i, pa, t, &pind, &result); copy_v3_v3(ca->co, result.co); /* non-hair points are already in global space */ @@ -3954,7 +3955,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * ParticleThreadContext ctx; /* fake thread context for child modifiers */ ParticleInterpolationData pind; - float t, frs_sec = sim->scene->r.frs_sec; + float t; float co[3], orco[3]; float hairmat[4][4]; int totpart = psys->totpart; @@ -3982,7 +3983,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * * account when subdividing for instance */ pind.dm = psys_in_edit_mode(sim->scene, psys) ? NULL : psys->hair_out_dm; init_particle_interpolation(sim->ob, psys, pa, &pind); - do_particle_interpolation(psys, p, pa, t, frs_sec, &pind, state); + do_particle_interpolation(psys, p, pa, t, &pind, state); if(!keyed && !cached) { if((pa->flag & PARS_REKEY)==0) { -- cgit v1.2.3 From 216f9af08e88398b7e2f805d241734ec80879180 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sun, 6 Feb 2011 17:36:42 +0000 Subject: Two in one: - Bugfix #25937 Child-of constraint now behaves like regular parent-child relationship when all options are set. This prevents the errors that can happen when decomposing non-uniform matrices. - Todo item The area corner hotspots for splitting/merging were far too narrow. Now it uses a circular distance to detect whether the hotspot is active. Also cleaned up drawing code for it. --- source/blender/blenkernel/intern/constraint.c | 111 +++++++++++++++----------- 1 file changed, 64 insertions(+), 47 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index c61f3ba3683..e653a6198ca 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -834,54 +834,71 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { - float parmat[4][4], invmat[4][4], tempmat[4][4]; - float loc[3], eul[3], size[3]; - float loco[3], eulo[3], sizo[3]; - - /* get offset (parent-inverse) matrix */ - copy_m4_m4(invmat, data->invmat); - - /* extract components of both matrices */ - copy_v3_v3(loc, ct->matrix[3]); - mat4_to_eulO(eul, ct->rotOrder, ct->matrix); - mat4_to_size(size, ct->matrix); - - copy_v3_v3(loco, invmat[3]); - mat4_to_eulO(eulo, cob->rotOrder, invmat); - mat4_to_size(sizo, invmat); - - /* disable channels not enabled */ - if (!(data->flag & CHILDOF_LOCX)) loc[0]= loco[0]= 0.0f; - if (!(data->flag & CHILDOF_LOCY)) loc[1]= loco[1]= 0.0f; - if (!(data->flag & CHILDOF_LOCZ)) loc[2]= loco[2]= 0.0f; - if (!(data->flag & CHILDOF_ROTX)) eul[0]= eulo[0]= 0.0f; - if (!(data->flag & CHILDOF_ROTY)) eul[1]= eulo[1]= 0.0f; - if (!(data->flag & CHILDOF_ROTZ)) eul[2]= eulo[2]= 0.0f; - if (!(data->flag & CHILDOF_SIZEX)) size[0]= sizo[0]= 1.0f; - if (!(data->flag & CHILDOF_SIZEY)) size[1]= sizo[1]= 1.0f; - if (!(data->flag & CHILDOF_SIZEZ)) size[2]= sizo[2]= 1.0f; - - /* make new target mat and offset mat */ - loc_eulO_size_to_mat4(ct->matrix, loc, eul, size, ct->rotOrder); - loc_eulO_size_to_mat4(invmat, loco, eulo, sizo, cob->rotOrder); - - /* multiply target (parent matrix) by offset (parent inverse) to get - * the effect of the parent that will be exherted on the owner - */ - mul_m4_m4m4(parmat, invmat, ct->matrix); + float parmat[4][4]; - /* now multiply the parent matrix by the owner matrix to get the - * the effect of this constraint (i.e. owner is 'parented' to parent) - */ - copy_m4_m4(tempmat, cob->matrix); - mul_m4_m4m4(cob->matrix, tempmat, parmat); - - /* without this, changes to scale and rotation can change location - * of a parentless bone or a disconnected bone. Even though its set - * to zero above. */ - if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0]= tempmat[3][0]; - if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1]= tempmat[3][1]; - if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2]= tempmat[3][2]; + /* simple matrix parenting */ + if(data->flag == CHILDOF_ALL) { + + /* multiply target (parent matrix) by offset (parent inverse) to get + * the effect of the parent that will be exherted on the owner + */ + mul_m4_m4m4(parmat, data->invmat, ct->matrix); + + /* now multiply the parent matrix by the owner matrix to get the + * the effect of this constraint (i.e. owner is 'parented' to parent) + */ + mul_m4_m4m4(cob->matrix, cob->matrix, parmat); + } + else { + float invmat[4][4], tempmat[4][4]; + float loc[3], eul[3], size[3]; + float loco[3], eulo[3], sizo[3]; + + /* get offset (parent-inverse) matrix */ + copy_m4_m4(invmat, data->invmat); + + /* extract components of both matrices */ + copy_v3_v3(loc, ct->matrix[3]); + mat4_to_eulO(eul, ct->rotOrder, ct->matrix); + mat4_to_size(size, ct->matrix); + + copy_v3_v3(loco, invmat[3]); + mat4_to_eulO(eulo, cob->rotOrder, invmat); + mat4_to_size(sizo, invmat); + + /* disable channels not enabled */ + if (!(data->flag & CHILDOF_LOCX)) loc[0]= loco[0]= 0.0f; + if (!(data->flag & CHILDOF_LOCY)) loc[1]= loco[1]= 0.0f; + if (!(data->flag & CHILDOF_LOCZ)) loc[2]= loco[2]= 0.0f; + if (!(data->flag & CHILDOF_ROTX)) eul[0]= eulo[0]= 0.0f; + if (!(data->flag & CHILDOF_ROTY)) eul[1]= eulo[1]= 0.0f; + if (!(data->flag & CHILDOF_ROTZ)) eul[2]= eulo[2]= 0.0f; + if (!(data->flag & CHILDOF_SIZEX)) size[0]= sizo[0]= 1.0f; + if (!(data->flag & CHILDOF_SIZEY)) size[1]= sizo[1]= 1.0f; + if (!(data->flag & CHILDOF_SIZEZ)) size[2]= sizo[2]= 1.0f; + + /* make new target mat and offset mat */ + loc_eulO_size_to_mat4(ct->matrix, loc, eul, size, ct->rotOrder); + loc_eulO_size_to_mat4(invmat, loco, eulo, sizo, cob->rotOrder); + + /* multiply target (parent matrix) by offset (parent inverse) to get + * the effect of the parent that will be exherted on the owner + */ + mul_m4_m4m4(parmat, invmat, ct->matrix); + + /* now multiply the parent matrix by the owner matrix to get the + * the effect of this constraint (i.e. owner is 'parented' to parent) + */ + copy_m4_m4(tempmat, cob->matrix); + mul_m4_m4m4(cob->matrix, tempmat, parmat); + + /* without this, changes to scale and rotation can change location + * of a parentless bone or a disconnected bone. Even though its set + * to zero above. */ + if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0]= tempmat[3][0]; + if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1]= tempmat[3][1]; + if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2]= tempmat[3][2]; + } } } -- cgit v1.2.3 From a018bfba9ad925e563dfa7f1512b2e5925547ea1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 7 Feb 2011 01:45:52 +0000 Subject: comment unused var --- source/blender/blenkernel/intern/particle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index f6b97dcb78e..12aa40a23d8 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2863,7 +2863,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) PARTICLE_P; float birthtime = 0.0, dietime = 0.0; - float t, time = 0.0, dfra = 1.0, frs_sec = sim->scene->r.frs_sec; + float t, time = 0.0, dfra = 1.0 /* , frs_sec = sim->scene->r.frs_sec*/ /*UNUSED*/; float col[4] = {0.5f, 0.5f, 0.5f, 1.0f}; float prev_tangent[3] = {0.0f, 0.0f, 0.0f}, hairmat[4][4]; float rotmat[3][3]; -- cgit v1.2.3 From ad8c79405ac053bafea606ee954c4324d066d5fa Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 7 Feb 2011 05:05:41 +0000 Subject: Type checks for internal ID-Property UI min/max/tip & use defines to get values from ID-Props. Probably wouldn't cause a problem but manually editing these types through python could easily crash blender. also changed cmake, stub-makefile default build dir to be lower case and leave out architecture string, easier for documentation. Use ../build/linux/ rather then ../build/Linux_i686/ --- source/blender/blenkernel/intern/idprop.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 633d3aeafb9..7829d9b5e0d 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -535,6 +535,12 @@ IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name) return (IDProperty *)BLI_findstring(&prop->data.group, name, offsetof(IDProperty, name)); } +IDProperty *IDP_GetPropertyTypeFromGroup(IDProperty *prop, const char *name, const char type) +{ + IDProperty *idprop= IDP_GetPropertyFromGroup(prop, name); + return (idprop && idprop->type == type) ? idprop : NULL; +} + typedef struct IDPIter { void *next; IDProperty *parent; -- cgit v1.2.3 From 2070356a329969be2287e6f8f7575a7e45d13543 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Mon, 7 Feb 2011 09:33:36 +0000 Subject: A simplified way of defining bNodeType structs. Instead of doing full struct member initialization for each node, this uses a couple of helper functions now. This will make it easier to change and extend the bNodeSocket interface in the future. Two examples (normal and mapping shader nodes) included, the rest should be converted too. --- source/blender/blenkernel/intern/node.c | 50 +++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 85c82dbf9bc..f6487bf1d19 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -43,6 +43,7 @@ #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_fcurve.h" +#include "BKE_node.h" #include "BKE_utildefines.h" #include "PIL_time.h" @@ -3232,6 +3233,51 @@ int ntreeTexTagAnimated(bNodeTree *ntree) /* ************* node definition init ********** */ +void node_type_init(bNodeType *ntype, int type, const char *name, short nclass, short flag, + struct bNodeSocketType *inputs, struct bNodeSocketType *outputs) +{ + memset(ntype, 0, sizeof(bNodeType)); + + ntype->type = type; + ntype->name = name; + ntype->nclass = nclass; + ntype->flag = flag; + + ntype->inputs = inputs; + ntype->outputs = outputs; + + /* default size values */ + ntype->width = 140; + ntype->minwidth = 100; + ntype->maxwidth = 320; +} + +void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth) +{ + ntype->width = width; + ntype->minwidth = minwidth; + ntype->maxwidth = maxwidth; +} + +void node_type_storage(bNodeType *ntype, const char *storagename, void (*initfunc)(struct bNode *), void (*freestoragefunc)(struct bNode *), void (*copystoragefunc)(struct bNode *, struct bNode *)) +{ + strncpy(ntype->storagename, storagename, sizeof(ntype->storagename)); + ntype->initfunc = initfunc; + ntype->copystoragefunc = copystoragefunc; + ntype->freestoragefunc = freestoragefunc; +} + +void node_type_exec(struct bNodeType *ntype, void (*execfunc)(void *data, struct bNode *, struct bNodeStack **, struct bNodeStack **)) +{ + ntype->execfunc = execfunc; +} + +void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out)) +{ + ntype->gpufunc = gpufunc; +} + + static bNodeType *is_nodetype_registered(ListBase *typelist, int type, ID *id) { bNodeType *ntype= typelist->first; @@ -3337,9 +3383,9 @@ static void registerShaderNodes(ListBase *ntypelist) nodeRegisterType(ntypelist, &sh_node_mix_rgb); nodeRegisterType(ntypelist, &sh_node_valtorgb); nodeRegisterType(ntypelist, &sh_node_rgbtobw); - nodeRegisterType(ntypelist, &sh_node_normal); + register_node_type_sh_normal(ntypelist); nodeRegisterType(ntypelist, &sh_node_geom); - nodeRegisterType(ntypelist, &sh_node_mapping); + register_node_type_sh_mapping(ntypelist); nodeRegisterType(ntypelist, &sh_node_curve_vec); nodeRegisterType(ntypelist, &sh_node_curve_rgb); nodeRegisterType(ntypelist, &sh_node_math); -- cgit v1.2.3 From cddaa815d6b46e900f2f475ceb1b379efeb6b8e4 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 7 Feb 2011 10:54:55 +0000 Subject: Fix for [#25955] Hair paths under force field influence look jagged * Effectors were applied wrong for hair. --- source/blender/blenkernel/intern/particle.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 12aa40a23d8..7421c43dc10 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2246,12 +2246,13 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK normalize_v3(force); - VECADDFAC(ca->co, (ca-1)->co, force, *length); - - if(k < steps) { + if(k < steps) sub_v3_v3v3(vec, (ca+1)->co, ca->co); + + madd_v3_v3v3fl(ca->co, (ca-1)->co, force, *length); + + if(k < steps) *length = len_v3(vec); - } } static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *state, float max_length, float *cur_length, float length, float *dvec) { -- cgit v1.2.3 From 44fb6bd1fa9f34b1f648f57aa3543512d3af4c48 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Mon, 7 Feb 2011 11:43:33 +0000 Subject: Hair ui simplification: * There were a lot of settings in the particle panels that made no sense for simple hair and only cluttered up the ui. * Now these settings are hidden by default unless "advanced" hair options are shown. * Without advanced options the particle velocity controls are replaced by a simple "hair length" value, which actually corresponds to the grown hair length in blender units. * Some hair effector options that are actually very useful were not shown in ui. These are now found in the "field weights" panel. --- source/blender/blenkernel/intern/particle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 7421c43dc10..5f45e06cfc4 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3473,7 +3473,7 @@ static void default_particle_settings(ParticleSettings *part) part->bb_uv_split=1; part->bb_align=PART_BB_VIEW; part->bb_split_offset=PART_BB_OFF_LINEAR; - part->flag=PART_EDISTR|PART_TRAND; + part->flag=PART_EDISTR|PART_TRAND|PART_HIDE_ADVANCED_HAIR; part->sta= 1.0; part->end= 200.0; -- cgit v1.2.3 From 926f168e445c11c9826f32f7e3cc4917bc14a30f Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Mon, 7 Feb 2011 12:28:04 +0000 Subject: AnimSys Todo: Scene/CompoNode Driver Hacks Drivers for Scene, World, and Compositing Nodes now "work" (well, sort-of)! Previously they were strictly restricted to object- accessible data only; now they can function across the board (give or take some weak spots). Although there is still no depsgraph support so that these properties update properly when their source controls are changed (this will probably require a lot more work), they can still update under other circumstances (i.e. frame change and/or manual refresh flushing via mouse movement, etc.) As the depsgraph tagging support is lacking, these just get always executed for now, which might potentially be quite sluggish, though it is hoped that there are so few of these top-level datablocks with drivers hooked up that this is barely an issue in practice. At least I haven't noticed any substantial slowdowns for animation playback, so it should probably be fine. --- source/blender/blenkernel/intern/scene.c | 61 ++++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 10 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 853e9e108d6..95f39db9d6f 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -945,27 +945,68 @@ float BKE_curframe(Scene *scene) return ctime; } +/* drivers support/hacks + * - this method is called from scene_update_tagged_recursive(), so gets included in viewport + render + * - these are always run since the depsgraph can't handle non-object data + * - these happen after objects are all done so that we can read in their final transform values, + * though this means that objects can't refer to scene info for guidance... + */ +static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene) +{ + float ctime = BKE_curframe(scene); + + /* scene itself */ + if (scene->adt && scene->adt->drivers.first) { + BKE_animsys_evaluate_animdata(&scene->id, scene->adt, ctime, ADT_RECALC_DRIVERS); + } + + /* world */ + // TODO: what about world textures? but then those have nodes too... + if (scene->world) { + ID *wid = (ID *)scene->world; + AnimData *adt= BKE_animdata_from_id(wid); + + if (adt && adt->drivers.first) + BKE_animsys_evaluate_animdata(wid, adt, ctime, ADT_RECALC_DRIVERS); + } + + /* nodes */ + if (scene->nodetree) { + ID *nid = (ID *)scene->nodetree; + AnimData *adt= BKE_animdata_from_id(nid); + + if (adt && adt->drivers.first) + BKE_animsys_evaluate_animdata(nid, adt, ctime, ADT_RECALC_DRIVERS); + } +} + static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scene_parent) { Base *base; + + scene->customdata_mask= scene_parent->customdata_mask; /* sets first, we allow per definition current scene to have dependencies on sets, but not the other way around. */ - if(scene->set) + if (scene->set) scene_update_tagged_recursive(bmain, scene->set, scene_parent); - - for(base= scene->base.first; base; base= base->next) { + + /* scene objects */ + for (base= scene->base.first; base; base= base->next) { Object *ob= base->object; - + object_handle_update(scene_parent, ob); - + if(ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) group_handle_recalc_and_update(scene_parent, ob, ob->dup_group); /* always update layer, so that animating layers works */ base->lay= ob->lay; } + + /* scene drivers... */ + scene_update_drivers(bmain, scene); } /* this is called in main loop, doing tagged updates before redraw */ @@ -982,14 +1023,14 @@ void scene_update_tagged(Main *bmain, Scene *scene) /* recalc scene animation data here (for sequencer) */ { - float ctime = BKE_curframe(scene); AnimData *adt= BKE_animdata_from_id(&scene->id); - - if(adt && (adt->recalc & ADT_RECALC_ANIM)) + float ctime = BKE_curframe(scene); + + if (adt && (adt->recalc & ADT_RECALC_ANIM)) BKE_animsys_evaluate_animdata(&scene->id, adt, ctime, 0); } - - if(scene->physics_settings.quick_cache_step) + + if (scene->physics_settings.quick_cache_step) BKE_ptcache_quick_cache_all(bmain, scene); /* in the future this should handle updates for all datablocks, not -- cgit v1.2.3 From bd023c443b9619ddfa467da79755204885b61a89 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 7 Feb 2011 13:02:44 +0000 Subject: remove mat_nr from MVert struct, saves 4 bytes per vertex. used to be used for halo's --- source/blender/blenkernel/intern/DerivedMesh.c | 6 ++---- source/blender/blenkernel/intern/cdderivedmesh.c | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 658d29f0046..a58aff6d4dc 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1122,8 +1122,7 @@ static void emDM_getVert(DerivedMesh *dm, int index, MVert *vert_r) vert_r->no[1] = ev->no[1] * 32767.0; vert_r->no[2] = ev->no[2] * 32767.0; - /* TODO what to do with vert_r->flag and vert_r->mat_nr? */ - vert_r->mat_nr = 0; + /* TODO what to do with vert_r->flag? */ vert_r->bweight = (unsigned char) (ev->bweight*255.0f); } @@ -1220,8 +1219,7 @@ static void emDM_copyVertArray(DerivedMesh *dm, MVert *vert_r) vert_r->no[1] = ev->no[1] * 32767.0; vert_r->no[2] = ev->no[2] * 32767.0; - /* TODO what to do with vert_r->flag and vert_r->mat_nr? */ - vert_r->mat_nr = 0; + /* TODO what to do with vert_r->flag? */ vert_r->flag = 0; vert_r->bweight = (unsigned char) (ev->bweight*255.0f); } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 932be711938..0006e5bfa38 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1604,7 +1604,6 @@ DerivedMesh *CDDM_from_editmesh(EditMesh *em, Mesh *UNUSED(me)) mv->no[2] = eve->no[2] * 32767.0; mv->bweight = (unsigned char) (eve->bweight * 255.0f); - mv->mat_nr = 0; mv->flag = 0; *index = i; -- cgit v1.2.3 From 5c421c328e963fe27725e6961e60de74cca87c7f Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 7 Feb 2011 16:41:57 +0000 Subject: Todo/feature request When using masks or other simple 3D elements in composites, doing a layer re-rendering on a node is a bit clumsy all the time. This commit does two things to help: - new hotkey "Z" in node editor automatically finds render layer that changed and re-renders it + composites - option "Auto Render" does same, but then after every transform edit in 3D window The latter is experimental; real & proper system for this requires full threaded render support (like previews). But it works! Demo file: http://download.blender.org/demo/test/auto_composite.blend Important fix: After any render, all the render layers were tagged "changed", which caused any edit to first totally recomposte everthing. Now it only composites changes. Implementation notes - DAG scene flush now sets 'changed' flags in render layer nodes - Added notifier for 'transform finished' to trigger the update, this is temporarily. --- source/blender/blenkernel/intern/depsgraph.c | 26 ++++++++++++++++++++++++++ source/blender/blenkernel/intern/node.c | 20 ++++++++++++++++---- 2 files changed, 42 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index cedf4e93247..0c5c72627cb 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -41,6 +41,7 @@ #include "DNA_lattice_types.h" #include "DNA_key_types.h" #include "DNA_mesh_types.h" +#include "DNA_node_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_windowmanager_types.h" @@ -54,6 +55,7 @@ #include "BKE_key.h" #include "BKE_library.h" #include "BKE_main.h" +#include "BKE_node.h" #include "BKE_mball.h" #include "BKE_modifier.h" #include "BKE_object.h" @@ -1923,6 +1925,28 @@ static void dag_scene_flush_layers(Scene *sce, int lay) flush_layer_node(sce, itA->node, lasttime); } +static void dag_tag_renderlayers(Scene *sce, unsigned int lay) +{ + if(sce->nodetree) { + bNode *node; + Base *base; + unsigned int lay_changed; + + for(base= sce->base.first; base; base= base->next) + if(base->lay & lay) + if(base->object->recalc) + lay_changed |= base->lay; + + for(node= sce->nodetree->nodes.first; node; node= node->next) { + if(node->id==(ID *)sce) { + SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); + if(srl && (srl->lay & lay_changed)) + NodeTagChanged(sce->nodetree, node); + } + } + } +} + /* flushes all recalc flags in objects down the dependency tree */ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const short time) { @@ -1967,6 +1991,8 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho } } } + + dag_tag_renderlayers(sce, lay); } static int object_modifiers_use_time(Object *ob) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index f6487bf1d19..69f01633192 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3182,10 +3182,7 @@ int ntreeCompositTagAnimated(bNodeTree *ntree) NodeTagChanged(ntree, node); tagged= 1; } - else if(node->type==CMP_NODE_R_LAYERS) { - NodeTagChanged(ntree, node); - tagged= 1; - } + /* here was tag render layer, but this is called after a render, so re-composites fail */ else if(node->type==NODE_GROUP) { if( ntreeCompositTagAnimated((bNodeTree *)node->id) ) { NodeTagChanged(ntree, node); @@ -3210,6 +3207,21 @@ void ntreeCompositTagGenerators(bNodeTree *ntree) } } +/* XXX after render animation system gets a refresh, this call allows composite to end clean */ +void ntreeClearTags(bNodeTree *ntree) +{ + bNode *node; + + if(ntree==NULL) return; + + for(node= ntree->nodes.first; node; node= node->next) { + node->need_exec= 0; + if(node->type==NODE_GROUP) + ntreeClearTags((bNodeTree *)node->id); + } +} + + int ntreeTexTagAnimated(bNodeTree *ntree) { bNode *node; -- cgit v1.2.3 From 0d8416acc7fa39a8519043e6e57006a203622644 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 7 Feb 2011 22:48:23 +0000 Subject: minor edits, no functional changes. - BGE was getting MCol array and not using it. - use list lookup functions for getting constraint from pose bone. - use const char * in more places. --- source/blender/blenkernel/intern/constraint.c | 6 +++--- source/blender/blenkernel/intern/scene.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index e653a6198ca..1e3ff7142a1 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -419,7 +419,7 @@ void constraint_mat_convertspace (Object *ob, bPoseChannel *pchan, float mat[][4 /* ------------ General Target Matrix Tools ---------- */ /* function that sets the given matrix based on given vertex group in mesh */ -static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, float mat[][4]) +static void contarget_get_mesh_mat (Scene *scene, Object *ob, const char *substring, float mat[][4]) { DerivedMesh *dm = NULL; Mesh *me= ob->data; @@ -524,7 +524,7 @@ static void contarget_get_mesh_mat (Scene *scene, Object *ob, char *substring, f } /* function that sets the given matrix based on given vertex group in lattice */ -static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][4]) +static void contarget_get_lattice_mat (Object *ob, const char *substring, float mat[][4]) { Lattice *lt= (Lattice *)ob->data; @@ -582,7 +582,7 @@ static void contarget_get_lattice_mat (Object *ob, char *substring, float mat[][ /* generic function to get the appropriate matrix for most target cases */ /* The cases where the target can be object data have not been implemented */ -static void constraint_target_to_mat4 (Scene *scene, Object *ob, char *substring, float mat[][4], short from, short to, float headtail) +static void constraint_target_to_mat4 (Scene *scene, Object *ob, const char *substring, float mat[][4], short from, short to, float headtail) { /* Case OBJECT */ if (!strlen(substring)) { diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 95f39db9d6f..b6768a746fb 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -581,7 +581,7 @@ void set_scene_bg(Main *bmain, Scene *scene) } /* called from creator.c */ -Scene *set_scene_name(Main *bmain, char *name) +Scene *set_scene_name(Main *bmain, const char *name) { Scene *sce= (Scene *)find_id("SC", name); if(sce) { -- cgit v1.2.3 From 1befe8ba4ad0104a8c935f5fdbe51ae927567848 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Feb 2011 00:18:00 +0000 Subject: un-initialized flag used with commit r34695. --- source/blender/blenkernel/intern/depsgraph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 0c5c72627cb..61fafa60831 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1930,7 +1930,7 @@ static void dag_tag_renderlayers(Scene *sce, unsigned int lay) if(sce->nodetree) { bNode *node; Base *base; - unsigned int lay_changed; + unsigned int lay_changed= 0; for(base= sce->base.first; base; base= base->next) if(base->lay & lay) -- cgit v1.2.3 From 98268ba40fb23d1af413114d469ab08b412d5b49 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Feb 2011 01:43:16 +0000 Subject: fix [#25801] Shrinkwrap Offset problems with Project mode. The positive result from the previous ray-cast is used again, inadvertently negating the offset from the first hit (acts as if no offset is applied). --- source/blender/blenkernel/intern/shrinkwrap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 753e31d565b..75a955a09a9 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -384,7 +384,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) } //Project over negative direction of axis - if(use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR) + if(use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1) { float inv_no[3]; negate_v3_v3(inv_no, tmp_no); -- cgit v1.2.3 From 0242a96f3bc0d844c6ca1c3916671b891de10d9f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 8 Feb 2011 02:09:59 +0000 Subject: Change in behavior to shrinkwrap modifier's offset value with negative enabled. - negative ray casts would invert the offset direction. this meant if positive and negative were enabled at once and the mesh was slightly inside & outside the object it wrapped, the offset would be applied in opposite directions. This way the offset is always along the vertex normal. - allow negative offset from RNA, could be useful and no benefit to disable. --- source/blender/blenkernel/intern/shrinkwrap.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 75a955a09a9..48d9a4e0dee 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -378,9 +378,6 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) normal_projection_project_vertex(0, tmp_co, tmp_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData); - - if(hit.index != -1) - madd_v3_v3v3fl(hit.co, hit.co, tmp_no, -calc->keepDist); } //Project over negative direction of axis @@ -393,14 +390,12 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) normal_projection_project_vertex(0, tmp_co, inv_no, &local2aux, auxData.tree, &hit, auxData.raycast_callback, &auxData); normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, inv_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData); - - if(hit.index != -1) - madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist); } if(hit.index != -1) { + madd_v3_v3v3fl(hit.co, hit.co, tmp_no, calc->keepDist); interp_v3_v3v3(co, co, hit.co, weight); } } -- cgit v1.2.3 From 9d6f9e74d4ad76269146e36697a21679c7d5aaa5 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 8 Feb 2011 05:51:20 +0000 Subject: Bugfix [#25814] ChildOf constraint: double transformation in object mode with drivers ChildOf constraints added using the PoseBone.constraints.new() method via Python scripts instead of using the operator (this latter method is still the preferred/recommended method) were not getting some critical flags set, causing errors arising from space conversions being performed more than once. --- source/blender/blenkernel/intern/constraint.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 1e3ff7142a1..be9e7609a64 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -4148,6 +4148,21 @@ static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const c constraints_set_active(list, con); } + /* set type+owner specific immutable settings */ + // TODO: does action constraint need anything here - i.e. spaceonce? + switch (type) { + case CONSTRAINT_TYPE_CHILDOF: + { + /* if this constraint is being added to a posechannel, make sure + * the constraint gets evaluated in pose-space */ + if (pchan) { + con->ownspace = CONSTRAINT_SPACE_POSE; + con->flag |= CONSTRAINT_SPACEONCE; + } + } + break; + } + return con; } -- cgit v1.2.3 From 803c7fb4d49b51de750751a5707ebc57c653b959 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 8 Feb 2011 09:02:16 +0000 Subject: Finished the node type definition cleanup started in r34682. All static node types should now use the node_type_* definition helpers to initialize their bNodeType structs. --- source/blender/blenkernel/intern/node.c | 271 ++++++++++++++++---------------- 1 file changed, 139 insertions(+), 132 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 69f01633192..cbb0ef7b854 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3245,7 +3245,7 @@ int ntreeTexTagAnimated(bNodeTree *ntree) /* ************* node definition init ********** */ -void node_type_init(bNodeType *ntype, int type, const char *name, short nclass, short flag, +void node_type_base(bNodeType *ntype, int type, const char *name, short nclass, short flag, struct bNodeSocketType *inputs, struct bNodeSocketType *outputs) { memset(ntype, 0, sizeof(bNodeType)); @@ -3264,6 +3264,11 @@ void node_type_init(bNodeType *ntype, int type, const char *name, short nclass, ntype->maxwidth = 320; } +void node_type_init(bNodeType *ntype, void (*initfunc)(struct bNode *)) +{ + ntype->initfunc = initfunc; +} + void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwidth) { ntype->width = width; @@ -3271,10 +3276,12 @@ void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwid ntype->maxwidth = maxwidth; } -void node_type_storage(bNodeType *ntype, const char *storagename, void (*initfunc)(struct bNode *), void (*freestoragefunc)(struct bNode *), void (*copystoragefunc)(struct bNode *, struct bNode *)) +void node_type_storage(bNodeType *ntype, const char *storagename, void (*freestoragefunc)(struct bNode *), void (*copystoragefunc)(struct bNode *, struct bNode *)) { - strncpy(ntype->storagename, storagename, sizeof(ntype->storagename)); - ntype->initfunc = initfunc; + if (storagename) + strncpy(ntype->storagename, storagename, sizeof(ntype->storagename)); + else + ntype->storagename[0] = '\0'; ntype->copystoragefunc = copystoragefunc; ntype->freestoragefunc = freestoragefunc; } @@ -3316,146 +3323,146 @@ void nodeRegisterType(ListBase *typelist, const bNodeType *ntype) static void registerCompositNodes(ListBase *ntypelist) { nodeRegisterType(ntypelist, &node_group_typeinfo); - nodeRegisterType(ntypelist, &cmp_node_rlayers); - nodeRegisterType(ntypelist, &cmp_node_image); - nodeRegisterType(ntypelist, &cmp_node_texture); - nodeRegisterType(ntypelist, &cmp_node_value); - nodeRegisterType(ntypelist, &cmp_node_rgb); - nodeRegisterType(ntypelist, &cmp_node_curve_time); - - nodeRegisterType(ntypelist, &cmp_node_composite); - nodeRegisterType(ntypelist, &cmp_node_viewer); - nodeRegisterType(ntypelist, &cmp_node_splitviewer); - nodeRegisterType(ntypelist, &cmp_node_output_file); - nodeRegisterType(ntypelist, &cmp_node_view_levels); - - nodeRegisterType(ntypelist, &cmp_node_curve_rgb); - nodeRegisterType(ntypelist, &cmp_node_mix_rgb); - nodeRegisterType(ntypelist, &cmp_node_hue_sat); - nodeRegisterType(ntypelist, &cmp_node_brightcontrast); - nodeRegisterType(ntypelist, &cmp_node_gamma); - nodeRegisterType(ntypelist, &cmp_node_invert); - nodeRegisterType(ntypelist, &cmp_node_alphaover); - nodeRegisterType(ntypelist, &cmp_node_zcombine); - nodeRegisterType(ntypelist, &cmp_node_colorbalance); - nodeRegisterType(ntypelist, &cmp_node_huecorrect); - - nodeRegisterType(ntypelist, &cmp_node_normal); - nodeRegisterType(ntypelist, &cmp_node_curve_vec); - nodeRegisterType(ntypelist, &cmp_node_map_value); - nodeRegisterType(ntypelist, &cmp_node_normalize); - - nodeRegisterType(ntypelist, &cmp_node_filter); - nodeRegisterType(ntypelist, &cmp_node_blur); - nodeRegisterType(ntypelist, &cmp_node_dblur); - nodeRegisterType(ntypelist, &cmp_node_bilateralblur); - nodeRegisterType(ntypelist, &cmp_node_vecblur); - nodeRegisterType(ntypelist, &cmp_node_dilateerode); - nodeRegisterType(ntypelist, &cmp_node_defocus); - - nodeRegisterType(ntypelist, &cmp_node_valtorgb); - nodeRegisterType(ntypelist, &cmp_node_rgbtobw); - nodeRegisterType(ntypelist, &cmp_node_setalpha); - nodeRegisterType(ntypelist, &cmp_node_idmask); - nodeRegisterType(ntypelist, &cmp_node_math); - nodeRegisterType(ntypelist, &cmp_node_seprgba); - nodeRegisterType(ntypelist, &cmp_node_combrgba); - nodeRegisterType(ntypelist, &cmp_node_sephsva); - nodeRegisterType(ntypelist, &cmp_node_combhsva); - nodeRegisterType(ntypelist, &cmp_node_sepyuva); - nodeRegisterType(ntypelist, &cmp_node_combyuva); - nodeRegisterType(ntypelist, &cmp_node_sepycca); - nodeRegisterType(ntypelist, &cmp_node_combycca); - nodeRegisterType(ntypelist, &cmp_node_premulkey); - - nodeRegisterType(ntypelist, &cmp_node_diff_matte); - nodeRegisterType(ntypelist, &cmp_node_distance_matte); - nodeRegisterType(ntypelist, &cmp_node_chroma_matte); - nodeRegisterType(ntypelist, &cmp_node_color_matte); - nodeRegisterType(ntypelist, &cmp_node_channel_matte); - nodeRegisterType(ntypelist, &cmp_node_color_spill); - nodeRegisterType(ntypelist, &cmp_node_luma_matte); - - nodeRegisterType(ntypelist, &cmp_node_translate); - nodeRegisterType(ntypelist, &cmp_node_rotate); - nodeRegisterType(ntypelist, &cmp_node_scale); - nodeRegisterType(ntypelist, &cmp_node_flip); - nodeRegisterType(ntypelist, &cmp_node_crop); - nodeRegisterType(ntypelist, &cmp_node_displace); - nodeRegisterType(ntypelist, &cmp_node_mapuv); - nodeRegisterType(ntypelist, &cmp_node_glare); - nodeRegisterType(ntypelist, &cmp_node_tonemap); - nodeRegisterType(ntypelist, &cmp_node_lensdist); + register_node_type_cmp_rlayers(ntypelist); + register_node_type_cmp_image(ntypelist); + register_node_type_cmp_texture(ntypelist); + register_node_type_cmp_value(ntypelist); + register_node_type_cmp_rgb(ntypelist); + register_node_type_cmp_curve_time(ntypelist); + + register_node_type_cmp_composite(ntypelist); + register_node_type_cmp_viewer(ntypelist); + register_node_type_cmp_splitviewer(ntypelist); + register_node_type_cmp_output_file(ntypelist); + register_node_type_cmp_view_levels(ntypelist); + + register_node_type_cmp_curve_rgb(ntypelist); + register_node_type_cmp_mix_rgb(ntypelist); + register_node_type_cmp_hue_sat(ntypelist); + register_node_type_cmp_brightcontrast(ntypelist); + register_node_type_cmp_gamma(ntypelist); + register_node_type_cmp_invert(ntypelist); + register_node_type_cmp_alphaover(ntypelist); + register_node_type_cmp_zcombine(ntypelist); + register_node_type_cmp_colorbalance(ntypelist); + register_node_type_cmp_huecorrect(ntypelist); + + register_node_type_cmp_normal(ntypelist); + register_node_type_cmp_curve_vec(ntypelist); + register_node_type_cmp_map_value(ntypelist); + register_node_type_cmp_normalize(ntypelist); + + register_node_type_cmp_filter(ntypelist); + register_node_type_cmp_blur(ntypelist); + register_node_type_cmp_dblur(ntypelist); + register_node_type_cmp_bilateralblur(ntypelist); + register_node_type_cmp_vecblur(ntypelist); + register_node_type_cmp_dilateerode(ntypelist); + register_node_type_cmp_defocus(ntypelist); + + register_node_type_cmp_valtorgb(ntypelist); + register_node_type_cmp_rgbtobw(ntypelist); + register_node_type_cmp_setalpha(ntypelist); + register_node_type_cmp_idmask(ntypelist); + register_node_type_cmp_math(ntypelist); + register_node_type_cmp_seprgba(ntypelist); + register_node_type_cmp_combrgba(ntypelist); + register_node_type_cmp_sephsva(ntypelist); + register_node_type_cmp_combhsva(ntypelist); + register_node_type_cmp_sepyuva(ntypelist); + register_node_type_cmp_combyuva(ntypelist); + register_node_type_cmp_sepycca(ntypelist); + register_node_type_cmp_combycca(ntypelist); + register_node_type_cmp_premulkey(ntypelist); + + register_node_type_cmp_diff_matte(ntypelist); + register_node_type_cmp_distance_matte(ntypelist); + register_node_type_cmp_chroma_matte(ntypelist); + register_node_type_cmp_color_matte(ntypelist); + register_node_type_cmp_channel_matte(ntypelist); + register_node_type_cmp_color_spill(ntypelist); + register_node_type_cmp_luma_matte(ntypelist); + + register_node_type_cmp_translate(ntypelist); + register_node_type_cmp_rotate(ntypelist); + register_node_type_cmp_scale(ntypelist); + register_node_type_cmp_flip(ntypelist); + register_node_type_cmp_crop(ntypelist); + register_node_type_cmp_displace(ntypelist); + register_node_type_cmp_mapuv(ntypelist); + register_node_type_cmp_glare(ntypelist); + register_node_type_cmp_tonemap(ntypelist); + register_node_type_cmp_lensdist(ntypelist); } static void registerShaderNodes(ListBase *ntypelist) { nodeRegisterType(ntypelist, &node_group_typeinfo); - nodeRegisterType(ntypelist, &sh_node_output); - nodeRegisterType(ntypelist, &sh_node_mix_rgb); - nodeRegisterType(ntypelist, &sh_node_valtorgb); - nodeRegisterType(ntypelist, &sh_node_rgbtobw); + register_node_type_sh_output(ntypelist); + register_node_type_sh_mix_rgb(ntypelist); + register_node_type_sh_valtorgb(ntypelist); + register_node_type_sh_rgbtobw(ntypelist); register_node_type_sh_normal(ntypelist); - nodeRegisterType(ntypelist, &sh_node_geom); + register_node_type_sh_geom(ntypelist); register_node_type_sh_mapping(ntypelist); - nodeRegisterType(ntypelist, &sh_node_curve_vec); - nodeRegisterType(ntypelist, &sh_node_curve_rgb); - nodeRegisterType(ntypelist, &sh_node_math); - nodeRegisterType(ntypelist, &sh_node_vect_math); - nodeRegisterType(ntypelist, &sh_node_squeeze); - nodeRegisterType(ntypelist, &sh_node_camera); - nodeRegisterType(ntypelist, &sh_node_material); - nodeRegisterType(ntypelist, &sh_node_material_ext); - nodeRegisterType(ntypelist, &sh_node_value); - nodeRegisterType(ntypelist, &sh_node_rgb); - nodeRegisterType(ntypelist, &sh_node_texture); - nodeRegisterType(ntypelist, &node_dynamic_typeinfo); - nodeRegisterType(ntypelist, &sh_node_invert); - nodeRegisterType(ntypelist, &sh_node_seprgb); - nodeRegisterType(ntypelist, &sh_node_combrgb); - nodeRegisterType(ntypelist, &sh_node_hue_sat); + register_node_type_sh_curve_vec(ntypelist); + register_node_type_sh_curve_rgb(ntypelist); + register_node_type_sh_math(ntypelist); + register_node_type_sh_vect_math(ntypelist); + register_node_type_sh_squeeze(ntypelist); + register_node_type_sh_camera(ntypelist); + register_node_type_sh_material(ntypelist); + register_node_type_sh_material_ext(ntypelist); + register_node_type_sh_value(ntypelist); + register_node_type_sh_rgb(ntypelist); + register_node_type_sh_texture(ntypelist); + register_node_type_sh_dynamic(ntypelist); + register_node_type_sh_invert(ntypelist); + register_node_type_sh_seprgb(ntypelist); + register_node_type_sh_combrgb(ntypelist); + register_node_type_sh_hue_sat(ntypelist); } static void registerTextureNodes(ListBase *ntypelist) { nodeRegisterType(ntypelist, &node_group_typeinfo); - nodeRegisterType(ntypelist, &tex_node_math); - nodeRegisterType(ntypelist, &tex_node_mix_rgb); - nodeRegisterType(ntypelist, &tex_node_valtorgb); - nodeRegisterType(ntypelist, &tex_node_rgbtobw); - nodeRegisterType(ntypelist, &tex_node_valtonor); - nodeRegisterType(ntypelist, &tex_node_curve_rgb); - nodeRegisterType(ntypelist, &tex_node_curve_time); - nodeRegisterType(ntypelist, &tex_node_invert); - nodeRegisterType(ntypelist, &tex_node_hue_sat); - nodeRegisterType(ntypelist, &tex_node_coord); - nodeRegisterType(ntypelist, &tex_node_distance); - nodeRegisterType(ntypelist, &tex_node_compose); - nodeRegisterType(ntypelist, &tex_node_decompose); - - nodeRegisterType(ntypelist, &tex_node_output); - nodeRegisterType(ntypelist, &tex_node_viewer); - - nodeRegisterType(ntypelist, &tex_node_checker); - nodeRegisterType(ntypelist, &tex_node_texture); - nodeRegisterType(ntypelist, &tex_node_bricks); - nodeRegisterType(ntypelist, &tex_node_image); - - nodeRegisterType(ntypelist, &tex_node_rotate); - nodeRegisterType(ntypelist, &tex_node_translate); - nodeRegisterType(ntypelist, &tex_node_scale); - nodeRegisterType(ntypelist, &tex_node_at); - - nodeRegisterType(ntypelist, &tex_node_proc_voronoi); - nodeRegisterType(ntypelist, &tex_node_proc_blend); - nodeRegisterType(ntypelist, &tex_node_proc_magic); - nodeRegisterType(ntypelist, &tex_node_proc_marble); - nodeRegisterType(ntypelist, &tex_node_proc_clouds); - nodeRegisterType(ntypelist, &tex_node_proc_wood); - nodeRegisterType(ntypelist, &tex_node_proc_musgrave); - nodeRegisterType(ntypelist, &tex_node_proc_noise); - nodeRegisterType(ntypelist, &tex_node_proc_stucci); - nodeRegisterType(ntypelist, &tex_node_proc_distnoise); + register_node_type_tex_math(ntypelist); + register_node_type_tex_mix_rgb(ntypelist); + register_node_type_tex_valtorgb(ntypelist); + register_node_type_tex_rgbtobw(ntypelist); + register_node_type_tex_valtonor(ntypelist); + register_node_type_tex_curve_rgb(ntypelist); + register_node_type_tex_curve_time(ntypelist); + register_node_type_tex_invert(ntypelist); + register_node_type_tex_hue_sat(ntypelist); + register_node_type_tex_coord(ntypelist); + register_node_type_tex_distance(ntypelist); + register_node_type_tex_compose(ntypelist); + register_node_type_tex_decompose(ntypelist); + + register_node_type_tex_output(ntypelist); + register_node_type_tex_viewer(ntypelist); + + register_node_type_tex_checker(ntypelist); + register_node_type_tex_texture(ntypelist); + register_node_type_tex_bricks(ntypelist); + register_node_type_tex_image(ntypelist); + + register_node_type_tex_rotate(ntypelist); + register_node_type_tex_translate(ntypelist); + register_node_type_tex_scale(ntypelist); + register_node_type_tex_at(ntypelist); + + register_node_type_tex_proc_voronoi(ntypelist); + register_node_type_tex_proc_blend(ntypelist); + register_node_type_tex_proc_magic(ntypelist); + register_node_type_tex_proc_marble(ntypelist); + register_node_type_tex_proc_clouds(ntypelist); + register_node_type_tex_proc_wood(ntypelist); + register_node_type_tex_proc_musgrave(ntypelist); + register_node_type_tex_proc_noise(ntypelist); + register_node_type_tex_proc_stucci(ntypelist); + register_node_type_tex_proc_distnoise(ntypelist); } static void remove_dynamic_typeinfos(ListBase *list) -- cgit v1.2.3 From 37f55ec1947be503e8452e81b4ebc48be3d3d540 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 8 Feb 2011 09:14:18 +0000 Subject: Group node type info is now also initialized with helper functions. --- source/blender/blenkernel/intern/node.c | 37 +++++++++++++++------------------ 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index cbb0ef7b854..16ea9856733 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -265,22 +265,16 @@ void ntreeVerifyTypes(bNodeTree *ntree) /* ************** Group stuff ********** */ -bNodeType node_group_typeinfo= { - /* next,prev */ NULL, NULL, - /* type code */ NODE_GROUP, - /* name */ "Group", - /* width+range */ 120, 60, 200, - /* class+opts */ NODE_CLASS_GROUP, NODE_OPTIONS, - /* input sock */ NULL, - /* output sock */ NULL, - /* storage */ "", - /* execfunc */ NULL, - /* butfunc */ NULL, - /* initfunc */ NULL, - /* freestoragefunc */ NULL, - /* copystoragefunc */ NULL, - /* id */ NULL -}; +/* XXX group typeinfo struct is used directly in ntreeMakeOwnType, needs cleanup */ +static bNodeType ntype_group; + +void register_node_type_group(ListBase *lb) +{ + node_type_base(&ntype_group, NODE_GROUP, "Group", NODE_CLASS_GROUP, NODE_OPTIONS, NULL, NULL); + node_type_size(&ntype_group, 120, 60, 200); + + nodeRegisterType(lb, &ntype_group); +} /* tag internal sockets */ static void group_tag_internal_sockets(bNodeTree *ngroup) @@ -380,7 +374,7 @@ void ntreeMakeOwnType(bNodeTree *ngroup) /* make own type struct */ ngroup->owntype= MEM_callocN(sizeof(bNodeType), "group type"); - *ngroup->owntype= node_group_typeinfo; /* copy data, for init */ + *ngroup->owntype= ntype_group; /* copy data, for init */ /* input type arrays */ if(totin) { @@ -3322,7 +3316,8 @@ void nodeRegisterType(ListBase *typelist, const bNodeType *ntype) static void registerCompositNodes(ListBase *ntypelist) { - nodeRegisterType(ntypelist, &node_group_typeinfo); + register_node_type_group(ntypelist); + register_node_type_cmp_rlayers(ntypelist); register_node_type_cmp_image(ntypelist); register_node_type_cmp_texture(ntypelist); @@ -3397,7 +3392,8 @@ static void registerCompositNodes(ListBase *ntypelist) static void registerShaderNodes(ListBase *ntypelist) { - nodeRegisterType(ntypelist, &node_group_typeinfo); + register_node_type_group(ntypelist); + register_node_type_sh_output(ntypelist); register_node_type_sh_mix_rgb(ntypelist); register_node_type_sh_valtorgb(ntypelist); @@ -3425,7 +3421,8 @@ static void registerShaderNodes(ListBase *ntypelist) static void registerTextureNodes(ListBase *ntypelist) { - nodeRegisterType(ntypelist, &node_group_typeinfo); + register_node_type_group(ntypelist); + register_node_type_tex_math(ntypelist); register_node_type_tex_mix_rgb(ntypelist); register_node_type_tex_valtorgb(ntypelist); -- cgit v1.2.3 From 24db3d17aafd1b2027cd62afd39b2d648e8ec7d5 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 8 Feb 2011 12:54:32 +0000 Subject: Per-type node labels and customizable names. The label displayed in the node header is now by default the node type string. A custom label callback can be implemented to display more detailed information. This is currently used by group nodes, which display their internal tree name, and math, vector math, mix and filter nodes, which use their internal operation sub-type. Also the node tree selection/naming box for groups is now displayed only on open groups, to make it clearer that this is the internal type of the group and get a cleaner main tree. --- source/blender/blenkernel/intern/node.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 16ea9856733..5a69d2a6ca3 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -268,10 +268,17 @@ void ntreeVerifyTypes(bNodeTree *ntree) /* XXX group typeinfo struct is used directly in ntreeMakeOwnType, needs cleanup */ static bNodeType ntype_group; +/* groups display their internal tree name as label */ +const char *group_label(bNode *node) +{ + return node->id->name+2; +} + void register_node_type_group(ListBase *lb) { node_type_base(&ntype_group, NODE_GROUP, "Group", NODE_CLASS_GROUP, NODE_OPTIONS, NULL, NULL); node_type_size(&ntype_group, 120, 60, 200); + node_type_label(&ntype_group, group_label); nodeRegisterType(lb, &ntype_group); } @@ -3290,6 +3297,10 @@ void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *m ntype->gpufunc = gpufunc; } +void node_type_label(struct bNodeType *ntype, const char *(*labelfunc)(struct bNode *)) +{ + ntype->labelfunc = labelfunc; +} static bNodeType *is_nodetype_registered(ListBase *typelist, int type, ID *id) { -- cgit v1.2.3 From aff23c92cc48b2e4b36cc0e5c56c2aabc72d6335 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 9 Feb 2011 00:51:30 +0000 Subject: Bugfix [#25990] backward compatibility with ShapeKey Actions :: 2.49 -> 2.50 Actionified ShapeKey IPO-blocks (i.e. "Shape Key Actions") would have an action channel with the hardcoded name, "Shape", and this action would be assigned to Object level (although ShapeKey blocks had their own IPO-block slot, only Objects could have actions, so actionifying ShapeKey IPO-blocks would wrap a ShapeKey block's IPO's to an Object- level action). Hence, the path conversions code would wrongly interpret this action channel as referring to a Pose Channel instead, thus creating some invalid paths with a 'pose.bones["Shape"]' prefix wrongly getting tacked on. To ensure that the converted animation can work out of the box, a 'data.shape_keys' prefix is now used instead so that these actions can still be Object-rooted while still being able to correctly control the Shape Keys. This is because there's no easy way to identify and then shift such action from Object-level to ShapeKey- level within the conversion code. The consequence though is that such converted ShapeKey actions CAN ONLY BE USED THROUGH OBJECT LEVEL (i.e. via Action NOT ShapeKey editor). Secondly, the Action/ShapeKey editor version patching code has been modified so that if a ShapeKey editor view was active when loading an old 2.4x file, the action gets cleared from the view. This is because of this didn't make semantic sense: the ShapeKey editor is for ShapeKey-rooted actions, while the Action Editor is for Object-rooted actions. The converted files though let Object-level actions be shown in either one. --- source/blender/blenkernel/intern/ipo.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index db995fd4f1d..d8ebe40db16 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -914,8 +914,17 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co sprintf(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname); } else if (actname && actname[0]) { - /* Pose-Channel */ - sprintf(buf, "pose.bones[\"%s\"]", actname); + if ((blocktype == ID_OB) && strcmp(actname, "Object")==0) { + /* Actionified "Object" IPO's... no extra path stuff needed */ + } + else if ((blocktype == ID_KE) && strcmp(actname, "Shape")==0) { + /* Actionified "Shape" IPO's - these are forced onto object level via the action container there... */ + strcpy(buf, "data.shape_keys"); + } + else { + /* Pose-Channel */ + sprintf(buf, "pose.bones[\"%s\"]", actname); + } } else if (constname && constname[0]) { /* Constraint in Object */ -- cgit v1.2.3 From f56d1a5e2c41b722f096113267889ebb4ce25a2a Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 9 Feb 2011 01:16:11 +0000 Subject: Old animation conversion code cleanups: - Tidying up some inconsistent formatting - Names of old IPO blocks are now included in the names used for new actions. These are included after a "CDA:" prefix, (i.e. "_C_onverted _D_ata _A_ction:"), which makes it easier to browse through these actions later. --- source/blender/blenkernel/intern/ipo.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index d8ebe40db16..41639a619b3 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -709,6 +709,11 @@ static const char *world_adrcodes_to_paths (int adrcode, int *array_index) *array_index= 1; return "stars.color"; case WO_STAR_B: *array_index= 2; return "stars.color"; */ + case WO_STAR_R: + case WO_STAR_G: + case WO_STAR_B: + printf("WARNING: WO_STAR_R/G/B deprecated\n"); + return NULL; case WO_STARDIST: return "stars.min_distance"; @@ -798,7 +803,7 @@ static const char *particle_adrcodes_to_paths (int adrcode, int *array_index) * - array_index - index in property's array (if applicable) to use * - return - the allocated path... */ -static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence * seq, int *array_index) +static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence *seq, int *array_index) { DynStr *path= BLI_dynstr_new(); const char *propname=NULL; @@ -932,8 +937,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co } else if (seq) { /* Sequence names in Scene */ - sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", - seq->name+2); + sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", seq->name+2); } else strcpy(buf, ""); /* empty string */ @@ -1330,20 +1334,17 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * } } - /* correct values for sequencer curves, - that were not locked to frame */ - - if (seq && - (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) { + /* correct values for sequencer curves, that were not locked to frame */ + if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) { double mul= (seq->enddisp-seq->startdisp)/100.0f; double offset= seq->startdisp; dst->vec[0][0] *= mul; dst->vec[0][0] += offset; - + dst->vec[1][0] *= mul; dst->vec[1][0] += offset; - + dst->vec[2][0] *= mul; dst->vec[2][0] += offset; } @@ -1490,7 +1491,7 @@ static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase * This assumes that AnimData has been added already. Separation of drivers * from animation data is accomplished here too... */ -static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], Sequence * seq) +static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq) { AnimData *adt= BKE_animdata_from_id(id); ListBase anim = {NULL, NULL}; @@ -1521,8 +1522,12 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], if (G.f & G_DEBUG) printf("\thas anim \n"); /* try to get action */ if (adt->action == NULL) { - adt->action= add_empty_action("ConvData_Action"); // XXX we need a better name for this - if (G.f & G_DEBUG) printf("\t\tadded new action \n"); + char nameBuf[MAX_ID_NAME]; + + BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name+2); + + adt->action= add_empty_action(nameBuf); + if (G.f & G_DEBUG) printf("\t\tadded new action - '%s' \n", nameBuf); } /* add F-Curves to action */ @@ -1878,7 +1883,7 @@ void do_versions_ipos_to_animato(Main *main) to different DNA variables later (semi-hack (tm) ) */ - switch(seq->type) { + switch (seq->type) { case SEQ_IMAGE: case SEQ_META: case SEQ_SCENE: -- cgit v1.2.3 From 3e8ddef8e570757dab6fd9b51aa0088e03d4aaaf Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2011 02:28:11 +0000 Subject: move validation into blender kernel so it can be called by internal modifier funcs more easily. --- source/blender/blenkernel/intern/mesh_validate.c | 259 +++++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 source/blender/blenkernel/intern/mesh_validate.c (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c new file mode 100644 index 00000000000..4cef8c5560e --- /dev/null +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -0,0 +1,259 @@ +/** + * $Id: mesh_ops.c 34569 2011-01-30 16:19:08Z ton $ + * + * ***** 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) 2011 Blender Foundation. + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include +#include +#include +#include + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BLI_utildefines.h" +#include "BLI_edgehash.h" + +#include "BKE_DerivedMesh.h" + +#include "MEM_guardedalloc.h" + +#include "ED_mesh.h" + +typedef struct SearchFace { + unsigned int v[4]; + unsigned int index; +} SearchFace; + +static int uint_cmp(const void *v1, const void *v2) +{ + const unsigned int x1= GET_INT_FROM_POINTER(v1), x2= GET_INT_FROM_POINTER(v2); + + if( x1 > x2 ) return 1; + else if( x1 < x2 ) return -1; + return 0; +} + +static int search_face_cmp(const void *v1, const void *v2) +{ + const SearchFace *sfa= v1, *sfb= v2; + + if (sfa->v[0] > sfb->v[0]) return 1; + else if (sfa->v[0] < sfb->v[0]) return -1; + + if (sfa->v[1] > sfb->v[1]) return 1; + else if (sfa->v[1] < sfb->v[1]) return -1; + + if (sfa->v[2] > sfb->v[2]) return 1; + else if (sfa->v[2] < sfb->v[2]) return -1; + + if (sfa->v[3] > sfb->v[3]) return 1; + else if (sfa->v[3] < sfb->v[3]) return -1; + + return 0; +} + +void BKE_mesh_validate_arrays(MVert *UNUSED(mverts), int totvert, MEdge *medges, int totedge, MFace *mfaces, int totface) +{ +// MVert *mv; + MEdge *med; + MFace *mf; + int i; + + EdgeHash *edge_hash = BLI_edgehash_new(); + + SearchFace *search_faces= MEM_callocN(sizeof(SearchFace) * totface, "search faces"); + SearchFace *sf; + SearchFace *sf_prev; + + printf("ED_mesh_validate: verts(%d), edges(%d), faces(%d)\n", totvert, totedge, totface); + + if(totedge==0 && totface != 0) { + printf(" locical error, %d faces and 0 edges\n", totface); + } + + for(i=0, med=medges; iv1 == med->v2) { + printf(" edge %d: has matching verts, both %d\n", i, med->v1); + } + if(med->v1 < 0 || med->v1 >= totvert) { + printf(" edge %d: v1 index out of range, %d\n", i, med->v1); + } + if(med->v2 < 0 || med->v2 >= totvert) { + printf(" edge %d: v2 index out of range, %d\n", i, med->v2); + } + + if(BLI_edgehash_haskey(edge_hash, med->v1, med->v2)) { + printf(" edge %d: is a duplicate of, %d\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2))); + } + + BLI_edgehash_insert(edge_hash, med->v1, med->v2, SET_INT_IN_POINTER(i)); + } + + for(i=0, mf=mfaces; iv4 ? 3:2; + do { + fverts[fidx]= *(&mf->v1 + fidx); + if(fverts[fidx] < 0 || fverts[fidx] >= totvert) { + printf(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, fverts[fidx]); + } + } while (fidx--); + + if(mf->v4) { + if(mf->v1 == mf->v2) printf(" face %d: verts invalid, v1/v2 both %d\n", i, mf->v1); + if(mf->v1 == mf->v3) printf(" face %d: verts invalid, v1/v3 both %d\n", i, mf->v1); + if(mf->v1 == mf->v4) printf(" face %d: verts invalid, v1/v4 both %d\n", i, mf->v1); + + if(mf->v2 == mf->v3) printf(" face %d: verts invalid, v2/v3 both %d\n", i, mf->v2); + if(mf->v2 == mf->v4) printf(" face %d: verts invalid, v2/v4 both %d\n", i, mf->v2); + + if(mf->v3 == mf->v4) printf(" face %d: verts invalid, v3/v4 both %d\n", i, mf->v3); + + if(totedge) { + if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) printf(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); + if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) printf(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); + if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v4)) printf(" face %d: edge v3/v4 (%d,%d) is missing egde data\n", i, mf->v3, mf->v4); + if(!BLI_edgehash_haskey(edge_hash, mf->v4, mf->v1)) printf(" face %d: edge v4/v1 (%d,%d) is missing egde data\n", i, mf->v4, mf->v1); + } + /* TODO, avoid double lookop */ + /* + fedges[0]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v1, mf->v2)); + fedges[1]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v2, mf->v3)); + fedges[2]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v3, mf->v4)); + fedges[3]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v4, mf->v1)); + */ + qsort(fverts, 4, sizeof(int), uint_cmp); + } + else { + if(mf->v1 == mf->v2) printf(" face %d: verts invalid, v1/v2 both %d\n", i, mf->v1); + if(mf->v1 == mf->v3) printf(" face %d: verts invalid, v1/v3 both %d\n", i, mf->v1); + + if(mf->v2 == mf->v3) printf(" face %d: verts invalid, v2/v3 both %d\n", i, mf->v2); + + if(totedge) { + if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) printf(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); + if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) printf(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); + if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v1)) printf(" face %d: edge v3/v1 (%d,%d) is missing egde data\n", i, mf->v3, mf->v1); + } + /* TODO, avoid double lookop */ + /* + fedges[0]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v1, mf->v2)); + fedges[1]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v2, mf->v3)); + fedges[2]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v3, mf->v1)); + */ + qsort(fverts, 3, sizeof(int), uint_cmp); + } + + search_faces[i].index = i; + + if(mf->v4) { + search_faces[i].v[0] = fverts[0]; + search_faces[i].v[1] = fverts[1]; + search_faces[i].v[2] = fverts[2]; + search_faces[i].v[3] = fverts[3]; + } + else { + search_faces[i].v[0] = fverts[0]; + search_faces[i].v[1] = fverts[1]; + search_faces[i].v[2] = fverts[2]; + search_faces[i].v[3] = UINT_MAX; + } + } + + qsort(search_faces, totface, sizeof(SearchFace), search_face_cmp); + + sf= search_faces; + sf_prev= sf; + sf++; + + for(i=1; iv, sf_prev->v, sizeof(sf_prev->v)) == 0) { + /* slow, could be smarter here */ + MFace *mf= mfaces + sf->index; + MFace *mf_prev= mfaces + sf_prev->index; + int size_expect, size_found; + + EdgeHash *eh_tmp= BLI_edgehash_new(); + if(mf->v4) { + BLI_edgehash_insert(eh_tmp, mf->v1, mf->v2, NULL); + BLI_edgehash_insert(eh_tmp, mf->v2, mf->v3, NULL); + BLI_edgehash_insert(eh_tmp, mf->v3, mf->v4, NULL); + BLI_edgehash_insert(eh_tmp, mf->v4, mf->v1, NULL); + + BLI_edgehash_insert(eh_tmp, mf_prev->v1, mf_prev->v2, NULL); + BLI_edgehash_insert(eh_tmp, mf_prev->v2, mf_prev->v3, NULL); + BLI_edgehash_insert(eh_tmp, mf_prev->v3, mf_prev->v4, NULL); + BLI_edgehash_insert(eh_tmp, mf_prev->v4, mf_prev->v1, NULL); + + size_expect= 4; + } + else { + BLI_edgehash_insert(eh_tmp, mf->v1, mf->v2, NULL); + BLI_edgehash_insert(eh_tmp, mf->v2, mf->v3, NULL); + BLI_edgehash_insert(eh_tmp, mf->v3, mf->v1, NULL); + + BLI_edgehash_insert(eh_tmp, mf_prev->v1, mf_prev->v2, NULL); + BLI_edgehash_insert(eh_tmp, mf_prev->v2, mf_prev->v3, NULL); + BLI_edgehash_insert(eh_tmp, mf_prev->v3, mf_prev->v1, NULL); + + size_expect= 3; + } + + size_found= BLI_edgehash_size(eh_tmp); + BLI_edgehash_free(eh_tmp, NULL); + + if(size_found != size_expect) { + printf(" face %d & %d: are duplicates ", sf->index, sf_prev->index); + if(mf->v4) { + printf("(%d,%d,%d,%d) ", mf->v1, mf->v2, mf->v3, mf->v4); + printf("(%d,%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4); + } + else { + printf("(%d,%d,%d) ", mf->v1, mf->v2, mf->v3); + printf("(%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3); + } + } + } + } + + BLI_edgehash_free(edge_hash, NULL); + MEM_freeN(search_faces); + + printf("BKE_mesh_validate: finished\n\n"); +} + +void BKE_mesh_validate(Mesh *me) +{ + printf("MESH: %s\n", me->id.name+2); + BKE_mesh_validate_arrays(me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface); +} + +void BKE_mesh_validate_dm(DerivedMesh *dm) +{ + BKE_mesh_validate_arrays(dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), dm->getFaceArray(dm), dm->getNumFaces(dm)); +} -- cgit v1.2.3 From 5e1eb9b4d3006f81456698964d8bd5da0a28eb0c Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Wed, 9 Feb 2011 03:48:40 +0000 Subject: SVN maintenance. --- source/blender/blenkernel/intern/mesh_validate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 4cef8c5560e..9cec9da15ba 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -1,5 +1,5 @@ /** - * $Id: mesh_ops.c 34569 2011-01-30 16:19:08Z ton $ + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * -- cgit v1.2.3 From f6733d90e57fe8dce473f05b4bf0b4e6d4559ecd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2011 03:49:59 +0000 Subject: bugfix [#25523] Face extrude will crash Blender if array and subsurf modifier are added to mesh object test_index_face() failed to fix indices like (6,0,0,6), making it (0,6,6,0). --- source/blender/blenkernel/intern/mesh.c | 2 +- 1 file changed, 1 insertion(+), 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 dc4838366c4..bd4f631c380 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -444,7 +444,7 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) mface->v4= 0; nr--; } - if(mface->v2 && mface->v2==mface->v3) { + if((mface->v2 || mface->v4) && mface->v2==mface->v3) { mface->v3= mface->v4; mface->v4= 0; nr--; -- cgit v1.2.3 From 08841476983f490c4dbf16934bc05602bbd4d5c5 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2011 04:45:53 +0000 Subject: fix [#25968] Crash on changing merge distance in array modifier with edgesplit modifier in chain --- source/blender/blenkernel/intern/mesh.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index bd4f631c380..d948b049881 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -456,6 +456,32 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) nr--; } + /* check corrupt cases, bowtie geometry, cant handle these because edge data wont exist so just return 0 */ + if(nr==3) { + if( + /* real edges */ + mface->v1==mface->v2 || + mface->v2==mface->v3 || + mface->v3==mface->v1 + ) { + return 0; + } + } + else if(nr==4) { + if( + /* real edges */ + mface->v1==mface->v2 || + mface->v2==mface->v3 || + mface->v3==mface->v4 || + mface->v4==mface->v1 || + /* across the face */ + mface->v1==mface->v3 || + mface->v2==mface->v4 + ) { + return 0; + } + } + /* prevent a zero at wrong index location */ if(nr==3) { if(mface->v3==0) { -- cgit v1.2.3 From 5aa72b87262c1dd310c5dba7cd772b3d6b02a427 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2011 15:13:20 +0000 Subject: BKE_mesh_validate() now corrects invalid meshes (optionally), added access for python so it can correct for bad imported geometry - mesh.validate(). --- source/blender/blenkernel/intern/mesh.c | 17 ++ source/blender/blenkernel/intern/mesh_validate.c | 355 ++++++++++++++++------- 2 files changed, 267 insertions(+), 105 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index d948b049881..7ae3e73d919 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -704,6 +704,23 @@ void mesh_strip_loose_faces(Mesh *me) me->totface = b; } +void mesh_strip_loose_edges(Mesh *me) +{ + int a,b; + + for (a=b=0; atotedge; a++) { + if (me->medge[a].v1==me->medge[a].v2) { + if (a!=b) { + memcpy(&me->medge[b],&me->medge[a],sizeof(me->medge[b])); + CustomData_copy_data(&me->edata, &me->edata, a, b, 1); + CustomData_free_elem(&me->edata, a, 1); + } + b++; + } + } + me->totedge = b; +} + void mball_to_mesh(ListBase *lb, Mesh *me) { DispList *dl; diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 9cec9da15ba..84b7307b820 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -31,6 +31,8 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" +#include "BLO_sys_types.h" + #include "BLI_utildefines.h" #include "BLI_edgehash.h" @@ -38,13 +40,47 @@ #include "MEM_guardedalloc.h" -#include "ED_mesh.h" +#include "BKE_mesh.h" + +#define SELECT 1 typedef struct SearchFace { unsigned int v[4]; unsigned int index; } SearchFace; +typedef union { + uint32_t verts[2]; + int64_t edval; +} EdgeStore; + +static void edge_store_assign(uint32_t verts[2], const uint32_t v1, const uint32_t v2) +{ + if(v1 < v2) { + verts[0]= v1; + verts[1]= v2; + } + else { + verts[0]= v2; + verts[1]= v1; + } +} + +static void edge_store_from_mface_quad(EdgeStore es[3], MFace *mf) +{ + edge_store_assign(es[0].verts, mf->v1, mf->v2); + edge_store_assign(es[1].verts, mf->v2, mf->v3); + edge_store_assign(es[2].verts, mf->v3, mf->v4); + edge_store_assign(es[2].verts, mf->v4, mf->v1); +} + +static void edge_store_from_mface_tri(EdgeStore es[3], MFace *mf) +{ + edge_store_assign(es[0].verts, mf->v1, mf->v2); + edge_store_assign(es[1].verts, mf->v2, mf->v3); + edge_store_assign(es[2].verts, mf->v3, mf->v1); +} + static int uint_cmp(const void *v1, const void *v2) { const unsigned int x1= GET_INT_FROM_POINTER(v1), x2= GET_INT_FROM_POINTER(v2); @@ -73,187 +109,296 @@ static int search_face_cmp(const void *v1, const void *v2) return 0; } -void BKE_mesh_validate_arrays(MVert *UNUSED(mverts), int totvert, MEdge *medges, int totedge, MFace *mfaces, int totface) +void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge *medges, int totedge, MFace *mfaces, int totface, const short do_verbose, const short do_fixes) { +# define PRINT if(do_verbose) printf +# define REMOVE_EDGE_TAG(_med) { _med->v2= _med->v1; do_edge_free= 1; } +# define REMOVE_FACE_TAG(_mf) { _mf->v3=0; do_face_free= 1; } + // MVert *mv; MEdge *med; MFace *mf; int i; + int do_face_free= FALSE; + int do_edge_free= FALSE; + + int do_edge_recalc= FALSE; + EdgeHash *edge_hash = BLI_edgehash_new(); SearchFace *search_faces= MEM_callocN(sizeof(SearchFace) * totface, "search faces"); SearchFace *sf; SearchFace *sf_prev; + int totsearchface= 0; - printf("ED_mesh_validate: verts(%d), edges(%d), faces(%d)\n", totvert, totedge, totface); + BLI_assert(!(do_fixes && me == NULL)); - if(totedge==0 && totface != 0) { - printf(" locical error, %d faces and 0 edges\n", totface); + PRINT("ED_mesh_validate: verts(%d), edges(%d), faces(%d)\n", totvert, totedge, totface); + + if(totedge == 0 && totface != 0) { + PRINT(" locical error, %d faces and 0 edges\n", totface); + do_edge_recalc= TRUE; } - for(i=0, med=medges; iv1 == med->v2) { - printf(" edge %d: has matching verts, both %d\n", i, med->v1); + PRINT(" edge %d: has matching verts, both %d\n", i, med->v1); + remove= do_fixes; } - if(med->v1 < 0 || med->v1 >= totvert) { - printf(" edge %d: v1 index out of range, %d\n", i, med->v1); + if(med->v1 >= totvert) { + PRINT(" edge %d: v1 index out of range, %d\n", i, med->v1); + remove= do_fixes; } - if(med->v2 < 0 || med->v2 >= totvert) { - printf(" edge %d: v2 index out of range, %d\n", i, med->v2); + if(med->v2 >= totvert) { + PRINT(" edge %d: v2 index out of range, %d\n", i, med->v2); + remove= do_fixes; } if(BLI_edgehash_haskey(edge_hash, med->v1, med->v2)) { - printf(" edge %d: is a duplicate of, %d\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2))); + PRINT(" edge %d: is a duplicate of, %d\n", i, GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, med->v1, med->v2))); + remove= do_fixes; } - BLI_edgehash_insert(edge_hash, med->v1, med->v2, SET_INT_IN_POINTER(i)); + if(remove == FALSE){ + BLI_edgehash_insert(edge_hash, med->v1, med->v2, SET_INT_IN_POINTER(i)); + } + else { + REMOVE_EDGE_TAG(med); + } } for(i=0, mf=mfaces; iv4 ? 3:2; do { fverts[fidx]= *(&mf->v1 + fidx); - if(fverts[fidx] < 0 || fverts[fidx] >= totvert) { - printf(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, fverts[fidx]); + if(fverts[fidx] >= totvert) { + PRINT(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, fverts[fidx]); + remove= do_fixes; } } while (fidx--); - if(mf->v4) { - if(mf->v1 == mf->v2) printf(" face %d: verts invalid, v1/v2 both %d\n", i, mf->v1); - if(mf->v1 == mf->v3) printf(" face %d: verts invalid, v1/v3 both %d\n", i, mf->v1); - if(mf->v1 == mf->v4) printf(" face %d: verts invalid, v1/v4 both %d\n", i, mf->v1); + if(remove == FALSE) { + if(mf->v4) { + if(mf->v1 == mf->v2) { PRINT(" face %d: verts invalid, v1/v2 both %d\n", i, mf->v1); remove= do_fixes; } + if(mf->v1 == mf->v3) { PRINT(" face %d: verts invalid, v1/v3 both %d\n", i, mf->v1); remove= do_fixes; } + if(mf->v1 == mf->v4) { PRINT(" face %d: verts invalid, v1/v4 both %d\n", i, mf->v1); remove= do_fixes; } - if(mf->v2 == mf->v3) printf(" face %d: verts invalid, v2/v3 both %d\n", i, mf->v2); - if(mf->v2 == mf->v4) printf(" face %d: verts invalid, v2/v4 both %d\n", i, mf->v2); + if(mf->v2 == mf->v3) { PRINT(" face %d: verts invalid, v2/v3 both %d\n", i, mf->v2); remove= do_fixes; } + if(mf->v2 == mf->v4) { PRINT(" face %d: verts invalid, v2/v4 both %d\n", i, mf->v2); remove= do_fixes; } - if(mf->v3 == mf->v4) printf(" face %d: verts invalid, v3/v4 both %d\n", i, mf->v3); + if(mf->v3 == mf->v4) { PRINT(" face %d: verts invalid, v3/v4 both %d\n", i, mf->v3); remove= do_fixes; } + } + else { + if(mf->v1 == mf->v2) { PRINT(" faceT %d: verts invalid, v1/v2 both %d\n", i, mf->v1); remove= do_fixes; } + if(mf->v1 == mf->v3) { PRINT(" faceT %d: verts invalid, v1/v3 both %d\n", i, mf->v1); remove= do_fixes; } - if(totedge) { - if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) printf(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); - if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) printf(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); - if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v4)) printf(" face %d: edge v3/v4 (%d,%d) is missing egde data\n", i, mf->v3, mf->v4); - if(!BLI_edgehash_haskey(edge_hash, mf->v4, mf->v1)) printf(" face %d: edge v4/v1 (%d,%d) is missing egde data\n", i, mf->v4, mf->v1); + if(mf->v2 == mf->v3) { PRINT(" faceT %d: verts invalid, v2/v3 both %d\n", i, mf->v2); remove= do_fixes; } } - /* TODO, avoid double lookop */ - /* - fedges[0]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v1, mf->v2)); - fedges[1]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v2, mf->v3)); - fedges[2]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v3, mf->v4)); - fedges[3]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v4, mf->v1)); - */ - qsort(fverts, 4, sizeof(int), uint_cmp); - } - else { - if(mf->v1 == mf->v2) printf(" face %d: verts invalid, v1/v2 both %d\n", i, mf->v1); - if(mf->v1 == mf->v3) printf(" face %d: verts invalid, v1/v3 both %d\n", i, mf->v1); - if(mf->v2 == mf->v3) printf(" face %d: verts invalid, v2/v3 both %d\n", i, mf->v2); + if(remove == FALSE) { + if(totedge) { + if(mf->v4) { + if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) { PRINT(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); do_edge_recalc= TRUE; } + if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) { PRINT(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); do_edge_recalc= TRUE; } + if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v4)) { PRINT(" face %d: edge v3/v4 (%d,%d) is missing egde data\n", i, mf->v3, mf->v4); do_edge_recalc= TRUE; } + if(!BLI_edgehash_haskey(edge_hash, mf->v4, mf->v1)) { PRINT(" face %d: edge v4/v1 (%d,%d) is missing egde data\n", i, mf->v4, mf->v1); do_edge_recalc= TRUE; } + } + else { + if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) { PRINT(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); do_edge_recalc= TRUE; } + if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) { PRINT(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); do_edge_recalc= TRUE; } + if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v1)) { PRINT(" face %d: edge v3/v1 (%d,%d) is missing egde data\n", i, mf->v3, mf->v1); do_edge_recalc= TRUE; } + } + } - if(totedge) { - if(!BLI_edgehash_haskey(edge_hash, mf->v1, mf->v2)) printf(" face %d: edge v1/v2 (%d,%d) is missing egde data\n", i, mf->v1, mf->v2); - if(!BLI_edgehash_haskey(edge_hash, mf->v2, mf->v3)) printf(" face %d: edge v2/v3 (%d,%d) is missing egde data\n", i, mf->v2, mf->v3); - if(!BLI_edgehash_haskey(edge_hash, mf->v3, mf->v1)) printf(" face %d: edge v3/v1 (%d,%d) is missing egde data\n", i, mf->v3, mf->v1); - } - /* TODO, avoid double lookop */ - /* - fedges[0]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v1, mf->v2)); - fedges[1]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v2, mf->v3)); - fedges[2]= GET_INT_FROM_POINTER(BLI_edgehash_lookup(edge_hash, mf->v3, mf->v1)); - */ - qsort(fverts, 3, sizeof(int), uint_cmp); - } + search_faces[totsearchface].index = i; - search_faces[i].index = i; + if(mf->v4) { + qsort(fverts, 4, sizeof(unsigned int), uint_cmp); + search_faces[i].v[0] = fverts[0]; + search_faces[i].v[1] = fverts[1]; + search_faces[i].v[2] = fverts[2]; + search_faces[i].v[3] = fverts[3]; + } + else { + qsort(fverts, 3, sizeof(unsigned int), uint_cmp); + search_faces[i].v[0] = fverts[0]; + search_faces[i].v[1] = fverts[1]; + search_faces[i].v[2] = fverts[2]; + search_faces[i].v[3] = UINT_MAX; + } - if(mf->v4) { - search_faces[i].v[0] = fverts[0]; - search_faces[i].v[1] = fverts[1]; - search_faces[i].v[2] = fverts[2]; - search_faces[i].v[3] = fverts[3]; + totsearchface++; + } } - else { - search_faces[i].v[0] = fverts[0]; - search_faces[i].v[1] = fverts[1]; - search_faces[i].v[2] = fverts[2]; - search_faces[i].v[3] = UINT_MAX; + if(remove) { + REMOVE_FACE_TAG(mf); } } - qsort(search_faces, totface, sizeof(SearchFace), search_face_cmp); + qsort(search_faces, totsearchface, sizeof(SearchFace), search_face_cmp); sf= search_faces; sf_prev= sf; sf++; - for(i=1; iv, sf_prev->v, sizeof(sf_prev->v)) == 0) { /* slow, could be smarter here */ MFace *mf= mfaces + sf->index; MFace *mf_prev= mfaces + sf_prev->index; - int size_expect, size_found; - - EdgeHash *eh_tmp= BLI_edgehash_new(); - if(mf->v4) { - BLI_edgehash_insert(eh_tmp, mf->v1, mf->v2, NULL); - BLI_edgehash_insert(eh_tmp, mf->v2, mf->v3, NULL); - BLI_edgehash_insert(eh_tmp, mf->v3, mf->v4, NULL); - BLI_edgehash_insert(eh_tmp, mf->v4, mf->v1, NULL); - BLI_edgehash_insert(eh_tmp, mf_prev->v1, mf_prev->v2, NULL); - BLI_edgehash_insert(eh_tmp, mf_prev->v2, mf_prev->v3, NULL); - BLI_edgehash_insert(eh_tmp, mf_prev->v3, mf_prev->v4, NULL); - BLI_edgehash_insert(eh_tmp, mf_prev->v4, mf_prev->v1, NULL); + EdgeStore es[4]; + EdgeStore es_prev[4]; - size_expect= 4; + if(mf->v4) { + edge_store_from_mface_quad(es, mf); + edge_store_from_mface_quad(es_prev, mf_prev); + + if( + ELEM4(es[0].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval, es_prev[3].edval) && + ELEM4(es[1].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval, es_prev[3].edval) && + ELEM4(es[2].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval, es_prev[3].edval) && + ELEM4(es[3].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval, es_prev[3].edval) + ) { + PRINT(" face %d & %d: are duplicates ", sf->index, sf_prev->index); + PRINT("(%d,%d,%d,%d) ", mf->v1, mf->v2, mf->v3, mf->v4); + PRINT("(%d,%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4); + remove= do_fixes; + } } else { - BLI_edgehash_insert(eh_tmp, mf->v1, mf->v2, NULL); - BLI_edgehash_insert(eh_tmp, mf->v2, mf->v3, NULL); - BLI_edgehash_insert(eh_tmp, mf->v3, mf->v1, NULL); - - BLI_edgehash_insert(eh_tmp, mf_prev->v1, mf_prev->v2, NULL); - BLI_edgehash_insert(eh_tmp, mf_prev->v2, mf_prev->v3, NULL); - BLI_edgehash_insert(eh_tmp, mf_prev->v3, mf_prev->v1, NULL); - - size_expect= 3; - } - - size_found= BLI_edgehash_size(eh_tmp); - BLI_edgehash_free(eh_tmp, NULL); - - if(size_found != size_expect) { - printf(" face %d & %d: are duplicates ", sf->index, sf_prev->index); - if(mf->v4) { - printf("(%d,%d,%d,%d) ", mf->v1, mf->v2, mf->v3, mf->v4); - printf("(%d,%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4); - } - else { - printf("(%d,%d,%d) ", mf->v1, mf->v2, mf->v3); - printf("(%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3); + edge_store_from_mface_tri(es, mf); + edge_store_from_mface_tri(es_prev, mf); + if( + ELEM3(es[0].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval) && + ELEM3(es[1].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval) && + ELEM3(es[2].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval) + ) { + PRINT(" face %d & %d: are duplicates ", sf->index, sf_prev->index); + PRINT("(%d,%d,%d) ", mf->v1, mf->v2, mf->v3); + PRINT("(%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3); + remove= do_fixes; } } } + + if(remove) { + REMOVE_FACE_TAG(mf); + /* keep sf_prev */ + } + else { + sf_prev= sf; + } } BLI_edgehash_free(edge_hash, NULL); MEM_freeN(search_faces); - printf("BKE_mesh_validate: finished\n\n"); + PRINT("BKE_mesh_validate: finished\n\n"); + +# undef PRINT +# undef REMOVE_EDGE_TAG +# undef REMOVE_FACE_TAG + + if(me) { + if(do_face_free) { + mesh_strip_loose_faces(me); + } + + if (do_edge_free) { + mesh_strip_loose_edges(me); + } + + if(do_fixes && do_edge_recalc) { + BKE_mesh_calc_edges(me, TRUE); + } + } } void BKE_mesh_validate(Mesh *me) { printf("MESH: %s\n", me->id.name+2); - BKE_mesh_validate_arrays(me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface); + BKE_mesh_validate_arrays(me, me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface, TRUE, TRUE); } void BKE_mesh_validate_dm(DerivedMesh *dm) { - BKE_mesh_validate_arrays(dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), dm->getFaceArray(dm), dm->getNumFaces(dm)); + BKE_mesh_validate_arrays(NULL, dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), dm->getFaceArray(dm), dm->getNumFaces(dm), TRUE, FALSE); +} + + +void BKE_mesh_calc_edges(Mesh *mesh, int update) +{ + CustomData edata; + EdgeHashIterator *ehi; + MFace *mf = mesh->mface; + MEdge *med, *med_orig; + EdgeHash *eh = BLI_edgehash_new(); + int i, totedge, totface = mesh->totface; + + if(mesh->totedge==0) + update= 0; + + if(update) { + /* assume existing edges are valid + * useful when adding more faces and generating edges from them */ + med= mesh->medge; + for(i= 0; itotedge; i++, med++) + BLI_edgehash_insert(eh, med->v1, med->v2, med); + } + + for (i = 0; i < totface; i++, mf++) { + if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2)) + BLI_edgehash_insert(eh, mf->v1, mf->v2, NULL); + if (!BLI_edgehash_haskey(eh, mf->v2, mf->v3)) + BLI_edgehash_insert(eh, mf->v2, mf->v3, NULL); + + if (mf->v4) { + if (!BLI_edgehash_haskey(eh, mf->v3, mf->v4)) + BLI_edgehash_insert(eh, mf->v3, mf->v4, NULL); + if (!BLI_edgehash_haskey(eh, mf->v4, mf->v1)) + BLI_edgehash_insert(eh, mf->v4, mf->v1, NULL); + } else { + if (!BLI_edgehash_haskey(eh, mf->v3, mf->v1)) + BLI_edgehash_insert(eh, mf->v3, mf->v1, NULL); + } + } + + totedge = BLI_edgehash_size(eh); + + /* write new edges into a temporary CustomData */ + memset(&edata, 0, sizeof(edata)); + CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge); + + ehi = BLI_edgehashIterator_new(eh); + med = CustomData_get_layer(&edata, CD_MEDGE); + for(i = 0; !BLI_edgehashIterator_isDone(ehi); + BLI_edgehashIterator_step(ehi), ++i, ++med) { + + if(update && (med_orig=BLI_edgehashIterator_getValue(ehi))) { + *med= *med_orig; /* copy from the original */ + } else { + BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2); + med->flag = ME_EDGEDRAW|ME_EDGERENDER|SELECT; /* select for newly created meshes which are selected [#25595] */ + } + } + BLI_edgehashIterator_free(ehi); + + /* free old CustomData and assign new one */ + CustomData_free(&mesh->edata, mesh->totedge); + mesh->edata = edata; + mesh->totedge = totedge; + + mesh->medge = CustomData_get_layer(&mesh->edata, CD_MEDGE); + + BLI_edgehash_free(eh, NULL); } -- cgit v1.2.3 From 97c57abfa32387fab14cb0d575c10c3908131088 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 9 Feb 2011 15:32:39 +0000 Subject: fix [#25994] Meshes with no vertices gets NaN location on setting origin to geometry --- source/blender/blenkernel/intern/mesh.c | 5 ++++- 1 file changed, 4 insertions(+), 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 7ae3e73d919..24b680703f9 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1556,7 +1556,10 @@ int mesh_center_median(Mesh *me, float cent[3]) for(mvert= me->mvert; i--; mvert++) { add_v3_v3(cent, mvert->co); } - mul_v3_fl(cent, 1.0f/(float)me->totvert); + /* otherwise we get NAN for 0 verts */ + if(me->totvert) { + mul_v3_fl(cent, 1.0f/(float)me->totvert); + } return (me->totvert != 0); } -- cgit v1.2.3 From 30ada8fdd3b847844e49f0a0cce0124460821b31 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Feb 2011 04:48:49 +0000 Subject: fix [#26003] Twice applied modifier with Convert to mesh with several multi-user objects convert_exec could do with a re-write, getting quite confusing. update md5's for ctest results and some renaming in mesh_validate code. --- source/blender/blenkernel/intern/mesh_validate.c | 77 ++++++++++++------------ 1 file changed, 38 insertions(+), 39 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 84b7307b820..e45d3a48047 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -44,15 +44,15 @@ #define SELECT 1 -typedef struct SearchFace { +typedef struct SortFace { unsigned int v[4]; unsigned int index; -} SearchFace; +} SortFace; typedef union { uint32_t verts[2]; int64_t edval; -} EdgeStore; +} EdgeUUID; static void edge_store_assign(uint32_t verts[2], const uint32_t v1, const uint32_t v2) { @@ -66,7 +66,7 @@ static void edge_store_assign(uint32_t verts[2], const uint32_t v1, const uint3 } } -static void edge_store_from_mface_quad(EdgeStore es[3], MFace *mf) +static void edge_store_from_mface_quad(EdgeUUID es[3], MFace *mf) { edge_store_assign(es[0].verts, mf->v1, mf->v2); edge_store_assign(es[1].verts, mf->v2, mf->v3); @@ -74,7 +74,7 @@ static void edge_store_from_mface_quad(EdgeStore es[3], MFace *mf) edge_store_assign(es[2].verts, mf->v4, mf->v1); } -static void edge_store_from_mface_tri(EdgeStore es[3], MFace *mf) +static void edge_store_from_mface_tri(EdgeUUID es[3], MFace *mf) { edge_store_assign(es[0].verts, mf->v1, mf->v2); edge_store_assign(es[1].verts, mf->v2, mf->v3); @@ -92,7 +92,7 @@ static int uint_cmp(const void *v1, const void *v2) static int search_face_cmp(const void *v1, const void *v2) { - const SearchFace *sfa= v1, *sfb= v2; + const SortFace *sfa= v1, *sfb= v2; if (sfa->v[0] > sfb->v[0]) return 1; else if (sfa->v[0] < sfb->v[0]) return -1; @@ -127,10 +127,10 @@ void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdg EdgeHash *edge_hash = BLI_edgehash_new(); - SearchFace *search_faces= MEM_callocN(sizeof(SearchFace) * totface, "search faces"); - SearchFace *sf; - SearchFace *sf_prev; - int totsearchface= 0; + SortFace *sort_faces= MEM_callocN(sizeof(SortFace) * totface, "search faces"); + SortFace *sf; + SortFace *sf_prev; + int totsortface= 0; BLI_assert(!(do_fixes && me == NULL)); @@ -217,24 +217,24 @@ void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdg } } - search_faces[totsearchface].index = i; + sort_faces[totsortface].index = i; if(mf->v4) { qsort(fverts, 4, sizeof(unsigned int), uint_cmp); - search_faces[i].v[0] = fverts[0]; - search_faces[i].v[1] = fverts[1]; - search_faces[i].v[2] = fverts[2]; - search_faces[i].v[3] = fverts[3]; + sort_faces[i].v[0] = fverts[0]; + sort_faces[i].v[1] = fverts[1]; + sort_faces[i].v[2] = fverts[2]; + sort_faces[i].v[3] = fverts[3]; } else { qsort(fverts, 3, sizeof(unsigned int), uint_cmp); - search_faces[i].v[0] = fverts[0]; - search_faces[i].v[1] = fverts[1]; - search_faces[i].v[2] = fverts[2]; - search_faces[i].v[3] = UINT_MAX; + sort_faces[i].v[0] = fverts[0]; + sort_faces[i].v[1] = fverts[1]; + sort_faces[i].v[2] = fverts[2]; + sort_faces[i].v[3] = UINT_MAX; } - totsearchface++; + totsortface++; } } if(remove) { @@ -242,13 +242,13 @@ void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdg } } - qsort(search_faces, totsearchface, sizeof(SearchFace), search_face_cmp); + qsort(sort_faces, totsortface, sizeof(SortFace), search_face_cmp); - sf= search_faces; + sf= sort_faces; sf_prev= sf; sf++; - for(i=1; iv, sf_prev->v, sizeof(sf_prev->v)) == 0) { @@ -256,18 +256,18 @@ void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdg MFace *mf= mfaces + sf->index; MFace *mf_prev= mfaces + sf_prev->index; - EdgeStore es[4]; - EdgeStore es_prev[4]; + EdgeUUID eu[4]; + EdgeUUID eu_prev[4]; if(mf->v4) { - edge_store_from_mface_quad(es, mf); - edge_store_from_mface_quad(es_prev, mf_prev); + edge_store_from_mface_quad(eu, mf); + edge_store_from_mface_quad(eu_prev, mf_prev); if( - ELEM4(es[0].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval, es_prev[3].edval) && - ELEM4(es[1].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval, es_prev[3].edval) && - ELEM4(es[2].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval, es_prev[3].edval) && - ELEM4(es[3].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval, es_prev[3].edval) + ELEM4(eu[0].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval, eu_prev[3].edval) && + ELEM4(eu[1].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval, eu_prev[3].edval) && + ELEM4(eu[2].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval, eu_prev[3].edval) && + ELEM4(eu[3].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval, eu_prev[3].edval) ) { PRINT(" face %d & %d: are duplicates ", sf->index, sf_prev->index); PRINT("(%d,%d,%d,%d) ", mf->v1, mf->v2, mf->v3, mf->v4); @@ -276,12 +276,12 @@ void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdg } } else { - edge_store_from_mface_tri(es, mf); - edge_store_from_mface_tri(es_prev, mf); + edge_store_from_mface_tri(eu, mf); + edge_store_from_mface_tri(eu_prev, mf); if( - ELEM3(es[0].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval) && - ELEM3(es[1].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval) && - ELEM3(es[2].edval, es_prev[0].edval, es_prev[1].edval, es_prev[2].edval) + ELEM3(eu[0].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval) && + ELEM3(eu[1].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval) && + ELEM3(eu[2].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval) ) { PRINT(" face %d & %d: are duplicates ", sf->index, sf_prev->index); PRINT("(%d,%d,%d) ", mf->v1, mf->v2, mf->v3); @@ -293,7 +293,7 @@ void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdg if(remove) { REMOVE_FACE_TAG(mf); - /* keep sf_prev */ + /* keep sf_prev incase next face also matches*/ } else { sf_prev= sf; @@ -301,7 +301,7 @@ void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdg } BLI_edgehash_free(edge_hash, NULL); - MEM_freeN(search_faces); + MEM_freeN(sort_faces); PRINT("BKE_mesh_validate: finished\n\n"); @@ -335,7 +335,6 @@ void BKE_mesh_validate_dm(DerivedMesh *dm) BKE_mesh_validate_arrays(NULL, dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), dm->getFaceArray(dm), dm->getNumFaces(dm), TRUE, FALSE); } - void BKE_mesh_calc_edges(Mesh *mesh, int update) { CustomData edata; -- cgit v1.2.3 From 264c8c21623c3b011494e169f0571c410331e553 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Feb 2011 09:29:31 +0000 Subject: mesh.validate() now returns True if any corrections were made. tested that correcting invalid meshes works by generating random meshes and checking that only the first call to mesh.validate() makes changes. found 2 bugs in mesh validation. - face sorting array wasn't assigned correct indices. - removing invalid edges used wrong comparison. --- source/blender/blenkernel/intern/mesh.c | 2 +- source/blender/blenkernel/intern/mesh_validate.c | 38 ++++++++++-------------- 2 files changed, 17 insertions(+), 23 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 24b680703f9..2953fb17e90 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -709,7 +709,7 @@ void mesh_strip_loose_edges(Mesh *me) int a,b; for (a=b=0; atotedge; a++) { - if (me->medge[a].v1==me->medge[a].v2) { + if (me->medge[a].v1!=me->medge[a].v2) { if (a!=b) { memcpy(&me->medge[b],&me->medge[a],sizeof(me->medge[b])); CustomData_copy_data(&me->edata, &me->edata, a, b, 1); diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index e45d3a48047..35a23a17115 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -109,7 +109,7 @@ static int search_face_cmp(const void *v1, const void *v2) return 0; } -void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge *medges, int totedge, MFace *mfaces, int totface, const short do_verbose, const short do_fixes) +int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge *medges, int totedge, MFace *mfaces, int totface, const short do_verbose, const short do_fixes) { # define PRINT if(do_verbose) printf # define REMOVE_EDGE_TAG(_med) { _med->v2= _med->v1; do_edge_free= 1; } @@ -169,17 +169,15 @@ void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdg } } - for(i=0, mf=mfaces; iv4 ? 3:2; do { - fverts[fidx]= *(&mf->v1 + fidx); - if(fverts[fidx] >= totvert) { - PRINT(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, fverts[fidx]); + sf->v[fidx]= *(&mf->v1 + fidx); + if(sf->v[fidx] >= totvert) { + PRINT(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, sf->v[fidx]); remove= do_fixes; } } while (fidx--); @@ -220,21 +218,15 @@ void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdg sort_faces[totsortface].index = i; if(mf->v4) { - qsort(fverts, 4, sizeof(unsigned int), uint_cmp); - sort_faces[i].v[0] = fverts[0]; - sort_faces[i].v[1] = fverts[1]; - sort_faces[i].v[2] = fverts[2]; - sort_faces[i].v[3] = fverts[3]; + qsort(sf->v, 4, sizeof(unsigned int), uint_cmp); } else { - qsort(fverts, 3, sizeof(unsigned int), uint_cmp); - sort_faces[i].v[0] = fverts[0]; - sort_faces[i].v[1] = fverts[1]; - sort_faces[i].v[2] = fverts[2]; - sort_faces[i].v[3] = UINT_MAX; + qsort(sf->v, 3, sizeof(unsigned int), uint_cmp); + sf->v[3] = UINT_MAX; } totsortface++; + sf++; } } if(remove) { @@ -322,17 +314,19 @@ void BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdg BKE_mesh_calc_edges(me, TRUE); } } + + return (do_face_free || do_edge_free || do_edge_recalc); } -void BKE_mesh_validate(Mesh *me) +int BKE_mesh_validate(Mesh *me, int do_verbose) { printf("MESH: %s\n", me->id.name+2); - BKE_mesh_validate_arrays(me, me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface, TRUE, TRUE); + return BKE_mesh_validate_arrays(me, me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface, do_verbose, TRUE); } -void BKE_mesh_validate_dm(DerivedMesh *dm) +int BKE_mesh_validate_dm(DerivedMesh *dm) { - BKE_mesh_validate_arrays(NULL, dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), dm->getFaceArray(dm), dm->getNumFaces(dm), TRUE, FALSE); + return BKE_mesh_validate_arrays(NULL, dm->getVertArray(dm), dm->getNumVerts(dm), dm->getEdgeArray(dm), dm->getNumEdges(dm), dm->getFaceArray(dm), dm->getNumFaces(dm), TRUE, FALSE); } void BKE_mesh_calc_edges(Mesh *mesh, int update) -- cgit v1.2.3 From 7daabec53482a5b0700f19a0d03ed7ae60d1e1a2 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Feb 2011 12:34:52 +0000 Subject: mesh validation: bugfix for removing doubles, another fix coming... --- source/blender/blenkernel/intern/mesh_validate.c | 31 ++++++++++++++---------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 35a23a17115..5d8a2bdeb72 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -66,12 +66,12 @@ static void edge_store_assign(uint32_t verts[2], const uint32_t v1, const uint3 } } -static void edge_store_from_mface_quad(EdgeUUID es[3], MFace *mf) +static void edge_store_from_mface_quad(EdgeUUID es[4], MFace *mf) { edge_store_assign(es[0].verts, mf->v1, mf->v2); edge_store_assign(es[1].verts, mf->v2, mf->v3); edge_store_assign(es[2].verts, mf->v3, mf->v4); - edge_store_assign(es[2].verts, mf->v4, mf->v1); + edge_store_assign(es[3].verts, mf->v4, mf->v1); } static void edge_store_from_mface_tri(EdgeUUID es[3], MFace *mf) @@ -83,7 +83,8 @@ static void edge_store_from_mface_tri(EdgeUUID es[3], MFace *mf) static int uint_cmp(const void *v1, const void *v2) { - const unsigned int x1= GET_INT_FROM_POINTER(v1), x2= GET_INT_FROM_POINTER(v2); + const unsigned int x1= *(const unsigned int *)v1; + const unsigned int x2= *(const unsigned int *)v2; if( x1 > x2 ) return 1; else if( x1 < x2 ) return -1; @@ -97,16 +98,19 @@ static int search_face_cmp(const void *v1, const void *v2) if (sfa->v[0] > sfb->v[0]) return 1; else if (sfa->v[0] < sfb->v[0]) return -1; - if (sfa->v[1] > sfb->v[1]) return 1; + else if (sfa->v[1] > sfb->v[1]) return 1; else if (sfa->v[1] < sfb->v[1]) return -1; - if (sfa->v[2] > sfb->v[2]) return 1; + else if (sfa->v[2] > sfb->v[2]) return 1; else if (sfa->v[2] < sfb->v[2]) return -1; - if (sfa->v[3] > sfb->v[3]) return 1; + else if (sfa->v[3] > sfb->v[3]) return 1; else if (sfa->v[3] < sfb->v[3]) return -1; - return 0; +// else if (sfb->index > sfa->index) return 1; +// else if (sfb->index < sfa->index) return -1; + else return 0; + } int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge *medges, int totedge, MFace *mfaces, int totface, const short do_verbose, const short do_fixes) @@ -118,6 +122,7 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge // MVert *mv; MEdge *med; MFace *mf; + MFace *mf_prev; int i; int do_face_free= FALSE; @@ -175,7 +180,7 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge fidx = mf->v4 ? 3:2; do { - sf->v[fidx]= *(&mf->v1 + fidx); + sf->v[fidx]= *(&(mf->v1) + fidx); if(sf->v[fidx] >= totvert) { PRINT(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, sf->v[fidx]); remove= do_fixes; @@ -215,7 +220,7 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge } } - sort_faces[totsortface].index = i; + sf->index = i; if(mf->v4) { qsort(sf->v, 4, sizeof(unsigned int), uint_cmp); @@ -245,12 +250,12 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge /* on a valid mesh, code below will never run */ if(memcmp(sf->v, sf_prev->v, sizeof(sf_prev->v)) == 0) { /* slow, could be smarter here */ - MFace *mf= mfaces + sf->index; - MFace *mf_prev= mfaces + sf_prev->index; - EdgeUUID eu[4]; EdgeUUID eu_prev[4]; + mf= mfaces + sf->index; + mf_prev= mfaces + sf_prev->index; + if(mf->v4) { edge_store_from_mface_quad(eu, mf); edge_store_from_mface_quad(eu_prev, mf_prev); @@ -269,7 +274,7 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge } else { edge_store_from_mface_tri(eu, mf); - edge_store_from_mface_tri(eu_prev, mf); + edge_store_from_mface_tri(eu_prev, mf_prev); if( ELEM3(eu[0].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval) && ELEM3(eu[1].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval) && -- cgit v1.2.3 From 1817a045b47985e9edb3ccdbbfc5ea9f79c8d363 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 10 Feb 2011 14:13:13 +0000 Subject: mesh validation remove duplicate faces didn't always work, now it _should_ all work correctly. --- source/blender/blenkernel/intern/mesh_validate.c | 103 +++++++++-------------- 1 file changed, 40 insertions(+), 63 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 5d8a2bdeb72..e5aacdf2cf9 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -44,16 +44,17 @@ #define SELECT 1 -typedef struct SortFace { - unsigned int v[4]; - unsigned int index; -} SortFace; - typedef union { uint32_t verts[2]; int64_t edval; } EdgeUUID; +typedef struct SortFace { +// unsigned int v[4]; + EdgeUUID es[4]; + unsigned int index; +} SortFace; + static void edge_store_assign(uint32_t verts[2], const uint32_t v1, const uint32_t v2) { if(v1 < v2) { @@ -79,12 +80,13 @@ static void edge_store_from_mface_tri(EdgeUUID es[3], MFace *mf) edge_store_assign(es[0].verts, mf->v1, mf->v2); edge_store_assign(es[1].verts, mf->v2, mf->v3); edge_store_assign(es[2].verts, mf->v3, mf->v1); + es[3].verts[0] = es[3].verts[1] = UINT_MAX; } -static int uint_cmp(const void *v1, const void *v2) +static int int64_cmp(const void *v1, const void *v2) { - const unsigned int x1= *(const unsigned int *)v1; - const unsigned int x2= *(const unsigned int *)v2; + const int64_t x1= *(const int64_t *)v1; + const int64_t x2= *(const int64_t *)v2; if( x1 > x2 ) return 1; else if( x1 < x2 ) return -1; @@ -95,21 +97,18 @@ static int search_face_cmp(const void *v1, const void *v2) { const SortFace *sfa= v1, *sfb= v2; - if (sfa->v[0] > sfb->v[0]) return 1; - else if (sfa->v[0] < sfb->v[0]) return -1; + if (sfa->es[0].edval > sfb->es[0].edval) return 1; + else if (sfa->es[0].edval < sfb->es[0].edval) return -1; - else if (sfa->v[1] > sfb->v[1]) return 1; - else if (sfa->v[1] < sfb->v[1]) return -1; + else if (sfa->es[1].edval > sfb->es[1].edval) return 1; + else if (sfa->es[1].edval < sfb->es[1].edval) return -1; - else if (sfa->v[2] > sfb->v[2]) return 1; - else if (sfa->v[2] < sfb->v[2]) return -1; + else if (sfa->es[2].edval > sfb->es[2].edval) return 1; + else if (sfa->es[2].edval < sfb->es[2].edval) return -1; - else if (sfa->v[3] > sfb->v[3]) return 1; - else if (sfa->v[3] < sfb->v[3]) return -1; - -// else if (sfb->index > sfa->index) return 1; -// else if (sfb->index < sfa->index) return -1; - else return 0; + else if (sfa->es[3].edval > sfb->es[3].edval) return 1; + else if (sfa->es[3].edval < sfb->es[3].edval) return -1; + else return 0; } @@ -177,12 +176,13 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge for(i=0, mf=mfaces, sf=sort_faces; iv4 ? 3:2; do { - sf->v[fidx]= *(&(mf->v1) + fidx); - if(sf->v[fidx] >= totvert) { - PRINT(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, sf->v[fidx]); + fv[fidx]= *(&(mf->v1) + fidx); + if(fv[fidx] >= totvert) { + PRINT(" face %d: 'v%d' index out of range, %d\n", i, fidx + 1, fv[fidx]); remove= do_fixes; } } while (fidx--); @@ -223,11 +223,13 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge sf->index = i; if(mf->v4) { - qsort(sf->v, 4, sizeof(unsigned int), uint_cmp); + edge_store_from_mface_quad(sf->es, mf); + + qsort(sf->es, 4, sizeof(int64_t), int64_cmp); } else { - qsort(sf->v, 3, sizeof(unsigned int), uint_cmp); - sf->v[3] = UINT_MAX; + edge_store_from_mface_tri(sf->es, mf); + qsort(sf->es, 3, sizeof(int64_t), int64_cmp); } totsortface++; @@ -248,53 +250,28 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), int totvert, MEdge for(i=1; iv, sf_prev->v, sizeof(sf_prev->v)) == 0) { - /* slow, could be smarter here */ - EdgeUUID eu[4]; - EdgeUUID eu_prev[4]; - + if(memcmp(sf->es, sf_prev->es, sizeof(sf_prev->es)) == 0) { mf= mfaces + sf->index; - mf_prev= mfaces + sf_prev->index; - if(mf->v4) { - edge_store_from_mface_quad(eu, mf); - edge_store_from_mface_quad(eu_prev, mf_prev); - - if( - ELEM4(eu[0].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval, eu_prev[3].edval) && - ELEM4(eu[1].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval, eu_prev[3].edval) && - ELEM4(eu[2].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval, eu_prev[3].edval) && - ELEM4(eu[3].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval, eu_prev[3].edval) - ) { - PRINT(" face %d & %d: are duplicates ", sf->index, sf_prev->index); - PRINT("(%d,%d,%d,%d) ", mf->v1, mf->v2, mf->v3, mf->v4); - PRINT("(%d,%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4); - remove= do_fixes; + if(do_verbose) { + mf_prev= mfaces + sf_prev->index; + if(mf->v4) { + PRINT(" face %d & %d: are duplicates (%d,%d,%d,%d) (%d,%d,%d,%d)\n", sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf->v4, mf_prev->v1, mf_prev->v2, mf_prev->v3, mf_prev->v4); } - } - else { - edge_store_from_mface_tri(eu, mf); - edge_store_from_mface_tri(eu_prev, mf_prev); - if( - ELEM3(eu[0].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval) && - ELEM3(eu[1].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval) && - ELEM3(eu[2].edval, eu_prev[0].edval, eu_prev[1].edval, eu_prev[2].edval) - ) { - PRINT(" face %d & %d: are duplicates ", sf->index, sf_prev->index); - PRINT("(%d,%d,%d) ", mf->v1, mf->v2, mf->v3); - PRINT("(%d,%d,%d)\n", mf_prev->v1, mf_prev->v2, mf_prev->v3); - remove= do_fixes; + else { + PRINT(" face %d & %d: are duplicates (%d,%d,%d) (%d,%d,%d)\n", sf->index, sf_prev->index, mf->v1, mf->v2, mf->v3, mf_prev->v1, mf_prev->v2, mf_prev->v3); } } - } - if(remove) { - REMOVE_FACE_TAG(mf); - /* keep sf_prev incase next face also matches*/ + remove= do_fixes; } else { sf_prev= sf; } + + if(remove) { + REMOVE_FACE_TAG(mf); + } } BLI_edgehash_free(edge_hash, NULL); -- cgit v1.2.3 From 9fea58ca9184dd48995feecf4f8eb5d2f0fcf399 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Fri, 11 Feb 2011 07:46:06 +0000 Subject: Made group label callback function static. --- source/blender/blenkernel/intern/node.c | 2 +- 1 file changed, 1 insertion(+), 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 5a69d2a6ca3..d9e7680a2d8 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -269,7 +269,7 @@ void ntreeVerifyTypes(bNodeTree *ntree) static bNodeType ntype_group; /* groups display their internal tree name as label */ -const char *group_label(bNode *node) +static const char *group_label(bNode *node) { return node->id->name+2; } -- cgit v1.2.3 From 69e72ea42790e5db142365cba46adbd23ecf3b4c Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Fri, 11 Feb 2011 09:37:58 +0000 Subject: Removed the internal_select parameter from ntreeCopyTree. This was used just in one place when duplicating nodes, which is not an actual copying of the tree. The node duplicate operator now copies selected nodes itself. --- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/material.c | 6 +-- source/blender/blenkernel/intern/node.c | 66 ++++++++++++----------------- source/blender/blenkernel/intern/scene.c | 2 +- source/blender/blenkernel/intern/texture.c | 2 +- 5 files changed, 34 insertions(+), 44 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 66b6d43d259..6eb5399404a 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -310,7 +310,7 @@ int id_copy(ID *id, ID **newid, int test) if(!test) *newid= (ID*)copy_action((bAction*)id); return 1; case ID_NT: - if(!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id, 0); + if(!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id); return 1; case ID_BR: if(!test) *newid= (ID*)copy_brush((Brush*)id); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index c49d8310789..152323dfb4d 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -223,7 +223,7 @@ Material *copy_material(Material *ma) if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview); if(ma->nodetree) { - man->nodetree= ntreeCopyTree(ma->nodetree, 0); /* 0 == full new tree */ + man->nodetree= ntreeCopyTree(ma->nodetree); /* 0 == full new tree */ } man->gpumaterial.first= man->gpumaterial.last= NULL; @@ -1401,7 +1401,7 @@ void copy_matcopybuf(Material *ma) matcopybuf.mtex[a]= MEM_dupallocN(mtex); } } - matcopybuf.nodetree= ntreeCopyTree(ma->nodetree, 0); + matcopybuf.nodetree= ntreeCopyTree(ma->nodetree); matcopybuf.preview= NULL; matcopybuf.gpumaterial.first= matcopybuf.gpumaterial.last= NULL; matcopied= 1; @@ -1446,5 +1446,5 @@ void paste_matcopybuf(Material *ma) } } - ma->nodetree= ntreeCopyTree(matcopybuf.nodetree, 0); + ma->nodetree= ntreeCopyTree(matcopybuf.nodetree); } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index d9e7680a2d8..218539b311a 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -826,7 +826,7 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode) * - all of wgroup's nodes are transferred across to their new home * - ngroup (i.e. the source NodeTree) is left unscathed */ - wgroup= ntreeCopyTree(ngroup, 0); + wgroup= ntreeCopyTree(ngroup); /* add the nodes into the ntree */ for(node= wgroup->nodes.first; node; node= nextn) { @@ -926,7 +926,7 @@ void nodeCopyGroup(bNode *gnode) bNodeSocket *sock; gnode->id->us--; - gnode->id= (ID *)ntreeCopyTree((bNodeTree *)gnode->id, 0); + gnode->id= (ID *)ntreeCopyTree((bNodeTree *)gnode->id); /* new_sock was set in nodeCopyNode */ for(sock=gnode->inputs.first; sock; sock=sock->next) @@ -1191,12 +1191,11 @@ bNodeTree *ntreeAddTree(const char *name, int type, const short is_group) } /* Warning: this function gets called during some rather unexpected times - * - 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) +bNodeTree *ntreeCopyTree(bNodeTree *ntree) { bNodeTree *newtree; bNode *node, *nnode, *last; @@ -1206,34 +1205,26 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select) if(ntree==NULL) return NULL; - if(internal_select==0) { - /* is ntree part of library? */ - for(newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next) - if(newtree==ntree) break; - if(newtree) { - newtree= copy_libblock(ntree); - } else { - newtree= MEM_dupallocN(ntree); - copy_libblock_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */ - } - newtree->nodes.first= newtree->nodes.last= NULL; - newtree->links.first= newtree->links.last= NULL; + /* is ntree part of library? */ + for(newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next) + if(newtree==ntree) break; + if(newtree) { + newtree= copy_libblock(ntree); + } else { + newtree= MEM_dupallocN(ntree); + copy_libblock_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */ } - else - newtree= ntree; + newtree->nodes.first= newtree->nodes.last= NULL; + newtree->links.first= newtree->links.last= NULL; - last= ntree->nodes.last; + last = ntree->nodes.last; for(node= ntree->nodes.first; node; node= node->next) { - node->new_node= NULL; - if(internal_select==0 || (node->flag & NODE_SELECT)) { - nnode= nodeCopyNode(newtree, node, internal_select); /* sets node->new */ - if(internal_select) { - node->flag &= ~(NODE_SELECT|NODE_ACTIVE); - nnode->flag |= NODE_SELECT; - } - } - if(node==last) break; + nnode= nodeCopyNode(newtree, node, 0); /* sets node->new */ + + /* make sure we don't copy new nodes again! */ + if (node==last) + break; } /* check for copying links */ @@ -1257,15 +1248,14 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree, int internal_select) } /* own type definition for group usage */ - if(internal_select==0) { - if(ntree->owntype) { - newtree->owntype= MEM_dupallocN(ntree->owntype); - if(ntree->owntype->inputs) - newtree->owntype->inputs= MEM_dupallocN(ntree->owntype->inputs); - if(ntree->owntype->outputs) - newtree->owntype->outputs= MEM_dupallocN(ntree->owntype->outputs); - } + if(ntree->owntype) { + newtree->owntype= MEM_dupallocN(ntree->owntype); + if(ntree->owntype->inputs) + newtree->owntype->inputs= MEM_dupallocN(ntree->owntype->inputs); + if(ntree->owntype->outputs) + newtree->owntype->outputs= MEM_dupallocN(ntree->owntype->outputs); } + /* weird this is required... there seem to be link pointers wrong still? */ /* anyhoo, doing this solves crashes on copying entire tree (copy scene) and delete nodes */ ntreeSolveOrder(newtree); @@ -1573,7 +1563,7 @@ void ntreeMakeLocal(bNodeTree *ntree) } else if(local && lib) { /* this is the mixed case, we copy the tree and assign it to local users */ - bNodeTree *newtree= ntreeCopyTree(ntree, 0); + bNodeTree *newtree= ntreeCopyTree(ntree); newtree->id.us= 0; @@ -2741,7 +2731,7 @@ bNodeTree *ntreeLocalize(bNodeTree *ntree) } /* node copy func */ - ltree= ntreeCopyTree(ntree, 0); + ltree= ntreeCopyTree(ntree); if(adt) { AnimData *ladt= BKE_animdata_from_id(<ree->id); diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index b6768a746fb..1611116f0af 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -171,7 +171,7 @@ Scene *copy_scene(Scene *sce, int type) BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); if(sce->nodetree) { - scen->nodetree= ntreeCopyTree(sce->nodetree, 0); /* copies actions */ + scen->nodetree= ntreeCopyTree(sce->nodetree); /* copies actions */ ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index de08a3b1813..57c629d5544 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -760,7 +760,7 @@ Tex *copy_texture(Tex *tex) if(tex->nodetree) { ntreeEndExecTree(tex->nodetree); - texn->nodetree= ntreeCopyTree(tex->nodetree, 0); /* 0 == full new tree */ + texn->nodetree= ntreeCopyTree(tex->nodetree); /* 0 == full new tree */ } return texn; -- cgit v1.2.3 From dcf7642f76bc4f1d2899249f7ce9b5c24c4fafad Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 11 Feb 2011 14:59:19 +0000 Subject: Bug fix for problem 2 in [#25973] Bake End Frame Not Configurable * External caches didn't load for smoke straight away. Smoke caches store all necessary info in every file, so no need to try to look for an info file. --- source/blender/blenkernel/intern/pointcache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 65bf055886e..bd919d2166d 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2929,8 +2929,10 @@ void BKE_ptcache_load_external(PTCacheID *pid) cache->endframe = end; cache->totpoint = 0; + if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) + ; /*necessary info in every file*/ /* read totpoint from info file (frame 0) */ - if(info) { + else if(info) { pf= ptcache_file_open(pid, PTCACHE_FILE_READ, 0); if(pf) { -- cgit v1.2.3 From f9fb95b9c1f58b95c861b0bc9bc6bf8218ec839c Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 11 Feb 2011 15:15:35 +0000 Subject: Made some function from DerivedMesh.c be avaliable from other modules. Some naming changes to make naming more uniform. No functional changes. It's necessery for further crazyspace changes and improvenments. --- source/blender/blenkernel/intern/DerivedMesh.c | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index a58aff6d4dc..be9cda6c58f 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -432,7 +432,7 @@ void DM_swap_face_data(DerivedMesh *dm, int index, const int *corner_indices) /// -static DerivedMesh *getMeshDerivedMesh(Mesh *me, Object *ob, float (*vertCos)[3]) +DerivedMesh *mesh_create_derived(Mesh *me, Object *ob, float (*vertCos)[3]) { DerivedMesh *dm = CDDM_from_mesh(me, ob); @@ -1330,7 +1330,7 @@ static void emDM_release(DerivedMesh *dm) } } -static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, float (*vertexCos)[3]) +DerivedMesh *editmesh_get_derived(EditMesh *em, float (*vertexCos)[3]) { EditMeshDerivedMesh *emdm = MEM_callocN(sizeof(*emdm), "emdm"); @@ -1447,11 +1447,11 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, Modifier float (*deformedVerts)[3] = mesh_getVertexCos(me, &numVerts); mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, 0, 0); - dm = getMeshDerivedMesh(me, ob, deformedVerts); + dm = mesh_create_derived(me, ob, deformedVerts); MEM_freeN(deformedVerts); } else { - DerivedMesh *tdm = getMeshDerivedMesh(me, ob, NULL); + DerivedMesh *tdm = mesh_create_derived(me, ob, NULL); dm = mti->applyModifier(md, ob, tdm, 0, 0); if(tdm != dm) tdm->release(tdm); @@ -2003,7 +2003,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos BLI_linklist_free(datamasks, NULL); } -static float (*editmesh_getVertexCos(EditMesh *em, int *numVerts_r))[3] +float (*editmesh_get_vertex_cos(EditMesh *em, int *numVerts_r))[3] { int i, numVerts = *numVerts_r = BLI_countlist(&em->verts); float (*cos)[3]; @@ -2017,7 +2017,7 @@ static float (*editmesh_getVertexCos(EditMesh *em, int *numVerts_r))[3] return cos; } -static int editmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *dm) +int editmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *dm) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); int required_mode = eModifierMode_Realtime | eModifierMode_Editmode; @@ -2046,7 +2046,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri modifiers_clearErrors(ob); if(cage_r && cageIndex == -1) { - *cage_r = getEditMeshDerivedMesh(em, NULL); + *cage_r = editmesh_get_derived(em, NULL); } dm = NULL; @@ -2088,7 +2088,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri MEM_mallocN(sizeof(*deformedVerts) * numVerts, "dfmv"); dm->getVertCos(dm, deformedVerts); } else { - deformedVerts = editmesh_getVertexCos(em, &numVerts); + deformedVerts = editmesh_get_vertex_cos(em, &numVerts); } } @@ -2178,7 +2178,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri *cage_r = dm; } else { *cage_r = - getEditMeshDerivedMesh(em, + editmesh_get_derived(em, deformedVerts ? MEM_dupallocN(deformedVerts) : NULL); } } @@ -2202,7 +2202,7 @@ static void editmesh_calc_modifiers(Scene *scene, Object *ob, EditMesh *em, Deri } else if (!deformedVerts && cage_r && *cage_r) { *final_r = *cage_r; } else { - *final_r = getEditMeshDerivedMesh(em, deformedVerts); + *final_r = editmesh_get_derived(em, deformedVerts); deformedVerts = NULL; } @@ -2425,7 +2425,7 @@ DerivedMesh *editmesh_get_derived_cage(Scene *scene, Object *obedit, EditMesh *e DerivedMesh *editmesh_get_derived_base(Object *UNUSED(obedit), EditMesh *em) { - return getEditMeshDerivedMesh(em, NULL); + return editmesh_get_derived(em, NULL); } @@ -2511,8 +2511,8 @@ int editmesh_get_first_deform_matrices(Scene *scene, Object *ob, EditMesh *em, f if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatricesEM) { if(!defmats) { - dm= getEditMeshDerivedMesh(em, NULL); - deformedVerts= editmesh_getVertexCos(em, &numVerts); + dm= editmesh_get_derived(em, NULL); + deformedVerts= editmesh_get_vertex_cos(em, &numVerts); defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats"); for(a=0; atype==eModifierTypeType_OnlyDeform && mti->deformMatrices) { if(!defmats) { Mesh *me= (Mesh*)ob->data; - dm= getMeshDerivedMesh(me, ob, NULL); + dm= mesh_create_derived(me, ob, NULL); deformedVerts= mesh_getVertexCos(me, &numVerts); defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats"); -- cgit v1.2.3 From 7f5dbb7de08fadd5bc81adc9067744fffe6c1cf8 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 11 Feb 2011 17:43:56 +0000 Subject: Fix #26040: Crash converting curve to mesh Really stupid mistake :) --- source/blender/blenkernel/intern/mesh.c | 2 +- 1 file changed, 1 insertion(+), 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 2953fb17e90..8117a626c03 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -832,7 +832,7 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MVert **allvert, int } *allvert= mvert= MEM_callocN(sizeof (MVert) * totvert, "nurbs_init mvert"); - *allface= mface= MEM_callocN(sizeof (MVert) * totvert, "nurbs_init mface"); + *allface= mface= MEM_callocN(sizeof (MVert) * totvlak, "nurbs_init mface"); /* verts and faces */ vertcount= 0; -- cgit v1.2.3 From 92672d0c1c2797d0068f5f71b13b5e521253b618 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Feb 2011 05:12:26 +0000 Subject: quiet some clang warnings. --- source/blender/blenkernel/intern/depsgraph.c | 12 ++++++------ source/blender/blenkernel/intern/image.c | 6 +++--- source/blender/blenkernel/intern/softbody.c | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 61fafa60831..6db4e0ac081 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1079,7 +1079,7 @@ void graph_bfs(void) minheight = pos[node->BFS_dist]; itA = node->child; while(itA != NULL) { - if((itA->node->color == DAG_WHITE) ) { + if(itA->node->color == DAG_WHITE) { itA->node->color = DAG_GRAY; itA->node->BFS_dist = node->BFS_dist + 1; itA->node->k = (float) minheight; @@ -1226,7 +1226,7 @@ DagNodeQueue * graph_dfs(void) itA = node->child; while(itA != NULL) { - if((itA->node->color == DAG_WHITE) ) { + if(itA->node->color == DAG_WHITE) { itA->node->DFS_dvtm = time; itA->node->color = DAG_GRAY; @@ -1480,7 +1480,7 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) itA = node->child; while(itA != NULL) { - if((itA->node->color == DAG_WHITE) ) { + if(itA->node->color == DAG_WHITE) { itA->node->DFS_dvtm = time; itA->node->color = DAG_GRAY; @@ -1514,7 +1514,7 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) { itA = node->child; while(itA != NULL) { - if((itA->node->ob == ob2) ) { + if(itA->node->ob == ob2) { return itA->node->type; } itA = itA->next; @@ -1686,7 +1686,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) itA = node->child; while(itA != NULL) { - if((itA->node->color == DAG_WHITE) ) { + if(itA->node->color == DAG_WHITE) { itA->node->DFS_dvtm = time; itA->node->color = DAG_GRAY; @@ -2622,7 +2622,7 @@ void DAG_pose_sort(Object *ob) itA = node->child; while(itA != NULL) { - if((itA->node->color == DAG_WHITE) ) { + if(itA->node->color == DAG_WHITE) { itA->node->color = DAG_GRAY; push_stack(nqueue,itA->node); skip = 1; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 3d69f51851f..37d1e65144d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1262,7 +1262,7 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int ibuf->ftype= IMAGIC; } #ifdef WITH_HDR - else if ((imtype==R_RADHDR)) { + else if (imtype==R_RADHDR) { ibuf->ftype= RADHDR; } #endif @@ -1274,11 +1274,11 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int } #ifdef WITH_DDS - else if ((imtype==R_DDS)) { + else if (imtype==R_DDS) { ibuf->ftype= DDS; } #endif - else if ((imtype==R_BMP)) { + else if (imtype==R_BMP) { ibuf->ftype= BMP; } #ifdef WITH_TIFF diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 3ba18fee615..3704792d9d4 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -698,12 +698,12 @@ static void add_2nd_order_roller(Object *ob,float UNUSED(stiffness), int *counte bs = sb->bspring + bp->springs[b-1]; /*nasty thing here that springs have two ends so here we have to make sure we examine the other */ - if (( v0 == bs->v1) ){ + if (v0 == bs->v1){ bpo =sb->bpoint+bs->v2; notthis = bs->v2; } else { - if (( v0 == bs->v2) ){ + if (v0 == bs->v2){ bpo =sb->bpoint+bs->v1; notthis = bs->v1; } -- cgit v1.2.3 From 5af9e5fda96bbf47ebf6bb5cfdd6b67bcbb365cb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Feb 2011 09:09:52 +0000 Subject: - resource leak in pointcache, opendir without closedir() - reading pointcache was using an incorrect, always NULL variable. - commented NDof code, was giving warnings and isnt used now. --- source/blender/blenkernel/intern/pointcache.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index bd919d2166d..84331e1b318 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2863,6 +2863,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to) } } } + closedir(dir); strcpy(pid->cache->name, old_name); } -- cgit v1.2.3 From 3396f73c1719db18500d4741d4fc21d6bba9423c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Feb 2011 09:58:28 +0000 Subject: fix for possible (but unlikely) problem with strncpy not adding \0 and then extending the string with strcat. use BLI_snprintf instead. --- source/blender/blenkernel/intern/particle_system.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (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 4d3a908edb0..2e2decdf84d 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3744,8 +3744,6 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) FluidsimSettings *fss= fluidmd->fss; ParticleSettings *part = psys->part; ParticleData *pa=NULL; - const char *suffix = "fluidsurface_particles_####"; - const char *suffix2 = ".gz"; char filename[256]; char debugStrBuffer[256]; int curFrame = sim->scene->r.cfra -1; // warning - sync with derived mesh fsmesh loading @@ -3755,14 +3753,13 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) // XXX if(ob==G.obedit) // off... // return; - + // ok, start loading - strcpy(filename, fss->surfdataPath); - strcat(filename, suffix); + BLI_snprintf(filename, sizeof(filename), "%sfluidsurface_particles_####.gz", fss->surfdataPath); + BLI_path_abs(filename, G.main->name); BLI_path_frame(filename, curFrame, 0); // fixed #frame-no - strcat(filename, suffix2); - + gzf = gzopen(filename, "rb"); if (!gzf) { snprintf(debugStrBuffer,256,"readFsPartData::error - Unable to open file for reading '%s' \n", filename); -- cgit v1.2.3 From 9e9e028f059f29d493dc020dda965a9bea8ffd6b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Feb 2011 10:18:21 +0000 Subject: access past array bounds in layerInterp_mdisps, also make some vars const. --- source/blender/blenkernel/intern/customdata.c | 4 ++-- source/blender/blenkernel/intern/multires.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 94bb771aecd..0ed479b899a 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -524,8 +524,8 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights), mdisp_apply_weight(S, dst_corners, side-1, 0, st, crn_weight, &axis_x[0], &axis_x[1]); mdisp_apply_weight(S, dst_corners, 0, side-1, st, crn_weight, &axis_y[0], &axis_y[1]); - sub_v3_v3(axis_x, base); - sub_v3_v3(axis_y, base); + sub_v2_v2(axis_x, base); + sub_v2_v2(axis_y, base); normalize_v2(axis_x); normalize_v2(axis_y); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 2a3052d10c9..2601adbcb5e 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -962,7 +962,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, int loca ***************************/ /* Adapted from sculptmode.c */ -void old_mdisps_bilinear(float out[3], float (*disps)[3], int st, float u, float v) +void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, float v) { int x, y, x2, y2; const int st_max = st - 1; @@ -1965,7 +1965,7 @@ static void face_to_crn_interp(float u, float v, float v1[2], float v2[2], float *x = maxf(x1, x2); } -void mdisp_rot_crn_to_face(int S, int corners, int face_side, float x, float y, float *u, float *v) +void mdisp_rot_crn_to_face(const int S, const int corners, const int face_side, const float x, const float y, float *u, float *v) { float offset = face_side*0.5f - 0.5f; @@ -1992,9 +1992,9 @@ void mdisp_rot_crn_to_face(int S, int corners, int face_side, float x, float y, } } -int mdisp_rot_face_to_crn(int corners, int face_side, float u, float v, float *x, float *y) +int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y) { - float offset = face_side*0.5f - 0.5f; + const float offset = face_side*0.5f - 0.5f; int S = 0; if (corners == 4) { @@ -2037,7 +2037,7 @@ int mdisp_rot_face_to_crn(int corners, int face_side, float u, float v, float *x return S; } -void mdisp_apply_weight(int S, int corners, int x, int y, int face_side, +void mdisp_apply_weight(const int S, const int corners, int x, int y, const int face_side, float crn_weight[4][2], float *u_r, float *v_r) { float u, v, xl, yl; @@ -2071,7 +2071,7 @@ void mdisp_apply_weight(int S, int corners, int x, int y, int face_side, *v_r = mid3[1]; } -void mdisp_flip_disp(int S, int corners, float axis_x[2], float axis_y[2], float disp[3]) +void mdisp_flip_disp(const int S, const int corners, const float axis_x[2], const float axis_y[2], float disp[3]) { float crn_x[2], crn_y[2]; float vx[2], vy[2], coord[2]; -- cgit v1.2.3 From c8c86aa6a12a253680aa266ce1c5d51b1b39005a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Feb 2011 14:25:54 +0000 Subject: - fix leak on STL loading if realloc fails. - transform code was using sprintf reading and writing the same string (undefined behavior). - softbody had unneeded NULL check. --- source/blender/blenkernel/intern/exotic.c | 8 +++++++- source/blender/blenkernel/intern/softbody.c | 4 +--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 641313b564c..ba36a826afe 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -364,10 +364,16 @@ static void read_stl_mesh_ascii(Scene *scene, const char *str) * sure we have enough storage for some more faces */ if ( (totface) && ( (totface % 10000) == 0 ) ) { + float *vertdata_old= vertdata; ++numtenthousand; vertdata = realloc(vertdata, numtenthousand*3*30000*sizeof(float)); - if (!vertdata) { STLALLOCERROR; } + if (!vertdata) { + if(vertdata_old) { + free(vertdata_old); + } + STLALLOCERROR; + } } /* Don't read normal, but check line for proper syntax anyway diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 3704792d9d4..19f7884b4cf 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1647,9 +1647,7 @@ static void scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow) ListBase *do_effector = NULL; do_effector = pdInitEffectors(scene, ob, NULL, sb->effector_weights); - if (sb){ - _scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector); - } + _scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector); pdEndEffectors(&do_effector); } -- cgit v1.2.3 From fafbd9d71b95776d1c7583476de74fccefab7f10 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 12 Feb 2011 14:38:34 +0000 Subject: Particles todo item: particle textures * Effecting particle properties with textures was possible in 2.49, but not in 2.5 anymore. * Now particles have their own textures (available in texture panel for objects with particle systems), which are totally separate from the material textures. * Currently a basic set of particle properties is available for texture control. Some others could still be added, but the whole system is not intended as an "change anything with a texture" as this kind of functionality will be provided with node particles in the future much better. * Combined with the previously added "particle texture coordinates" this new functionality also solves the problem of animating particle properties through the particle lifetime nicely. * Currently the textures only use the intensity of the texture in "multiply" blending mode, so in order for the textures to effect a particle parameter there has to be a non-zero value defined for the parameter in the particle settings. Other blend modes can be added later if they're considered useful enough. --- source/blender/blenkernel/intern/depsgraph.c | 24 ++ source/blender/blenkernel/intern/particle.c | 241 +++++++------- source/blender/blenkernel/intern/particle_system.c | 359 ++++++++------------- source/blender/blenkernel/intern/texture.c | 41 ++- 4 files changed, 318 insertions(+), 347 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 6db4e0ac081..07a47f84af5 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -40,6 +40,7 @@ #include "DNA_group_types.h" #include "DNA_lattice_types.h" #include "DNA_key_types.h" +#include "DNA_material_types.h" #include "DNA_mesh_types.h" #include "DNA_node_types.h" #include "DNA_scene_types.h" @@ -2375,6 +2376,29 @@ static void dag_id_flush_update(Scene *sce, ID *id) modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data); if (data.is_dependent) obt->recalc |= OB_RECALC_DATA; + + /* particle settings can use the texture as well */ + if(obt->particlesystem.first) { + ParticleSystem *psys = obt->particlesystem.first; + MTex **mtexp, *mtex; + int a; + for(; psys; psys=psys->next) { + mtexp = psys->part->mtex; + for(a=0; atex == (Tex*)id) { + obt->recalc |= OB_RECALC_DATA; + + if(mtex->mapto & PAMAP_INIT) + psys->recalc |= PSYS_RECALC_RESET; + if(mtex->mapto & PAMAP_CHILD) + psys->recalc |= PSYS_RECALC_CHILD; + + BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); + } + } + } + } } } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 5f45e06cfc4..38fd11b086f 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -77,8 +77,6 @@ #include "RE_render_ext.h" -static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, - float *fuv, float *orco, ParticleTexture *ptex, int event); static void get_child_modifier_parameters(ParticleSettings *part, ParticleThreadContext *ctx, ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex); static void do_child_modifiers(ParticleSimulationData *sim, @@ -2860,6 +2858,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) Material *ma; ParticleInterpolationData pind; + ParticleTexture ptex; PARTICLE_P; @@ -2909,8 +2908,8 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /*---first main loop: create all actual particles' paths---*/ LOOP_SHOWN_PARTICLES { if(!psys->totchild) { - BLI_srandom(psys->seed + p); - pa_length = 1.0f - part->randlength * BLI_frand(); + psys_get_texture(sim, pa, &ptex, PAMAP_LENGTH, 0.f); + pa_length = ptex.length * (1.0f - part->randlength * PSYS_FRAND(psys->seed + p)); if(vg_length) pa_length *= psys_particle_value_from_verts(psmd->dm,part->from,pa,vg_length); } @@ -3674,82 +3673,128 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, fl return 1; } -static void get_cpa_texture(DerivedMesh *dm, Material *ma, int face_index, float *fw, float *orco, ParticleTexture *ptex, int event) +#define SET_PARTICLE_TEXTURE(type, pvalue, texfac) if((event & mtex->mapto) & type) {pvalue = texture_value_blend(def, pvalue, value, texfac, blend);} +#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) if(event & type) { if(pvalue < 0.f) pvalue = 1.f+pvalue; CLAMP(pvalue, 0.0, 1.0); } +#define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue) if(event & type) { CLAMP(pvalue, -1.0, 1.0); } + +static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSettings *part, ParticleData *par, int child_index, int face_index, float *fw, float *orco, ParticleTexture *ptex, int event, float cfra) { - MTex *mtex; + MTex *mtex, **mtexp = part->mtex; int m,setvars=0; - float value, rgba[4], texco[3]; + float value, rgba[4], texvec[3]; - if(ma) for(m=0; mmtex[m]; - if(mtex && (ma->septex & (1<pmapto){ + ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp = + ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink = + ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.f; + + ptex->length= 1.0f - part->randlength * PSYS_FRAND(child_index + 26); + ptex->length*= part->clength_thres < PSYS_FRAND(child_index + 27) ? part->clength : 1.0f; + + for(m=0; mmapto){ float def=mtex->def_var; short blend=mtex->blendtype; + short texco = mtex->texco; - if((mtex->texco & TEXCO_UV) && fw) { - if(!get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texco)) - VECCOPY(texco,orco); - } - else - VECCOPY(texco,orco); + if(ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID)) + texco = TEXCO_GLOB; - externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3, 0); - if((event & mtex->pmapto) & MAP_PA_TIME){ - if((setvars&MAP_PA_TIME)==0){ - ptex->time=0.0; - setvars|=MAP_PA_TIME; - } - ptex->time= texture_value_blend(mtex->def_var,ptex->time,value,mtex->timefac,blend); + switch(texco) { + case TEXCO_GLOB: + copy_v3_v3(texvec, par->state.co); + break; + case TEXCO_OBJECT: + copy_v3_v3(texvec, par->state.co); + if(mtex->object) + mul_m4_v3(mtex->object->imat, texvec); + break; + case TEXCO_UV: + if(fw && get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texvec)) + break; + /* no break, failed to get uv's, so let's try orco's */ + case TEXCO_ORCO: + copy_v3_v3(texvec, orco); + break; + case TEXCO_PARTICLE: + /* texture coordinates in range [-1,1] */ + texvec[0] = 2.f * (cfra - par->time)/(par->dietime-par->time) - 1.f; + texvec[1] = 0.f; + texvec[2] = 0.f; + break; } - if((event & mtex->pmapto) & MAP_PA_LENGTH) - ptex->length= texture_value_blend(def,ptex->length,value,mtex->lengthfac,blend); - if((event & mtex->pmapto) & MAP_PA_CLUMP) - ptex->clump= texture_value_blend(def,ptex->clump,value,mtex->clumpfac,blend); - if((event & mtex->pmapto) & MAP_PA_KINK) - ptex->kink= texture_value_blend(def,ptex->kink,value,mtex->kinkfac,blend); - if((event & mtex->pmapto) & MAP_PA_ROUGH) + + externtex(mtex, texvec, &value, rgba, rgba+1, rgba+2, rgba+3, 0); + + if((event & mtex->mapto) & PAMAP_ROUGH) ptex->rough1= ptex->rough2= ptex->roughe= texture_value_blend(def,ptex->rough1,value,mtex->roughfac,blend); - if((event & mtex->pmapto) & MAP_PA_DENS) - ptex->exist= texture_value_blend(def,ptex->exist,value,mtex->padensfac,blend); + + SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac); + SET_PARTICLE_TEXTURE(PAMAP_CLUMP, ptex->clump, mtex->clumpfac); + SET_PARTICLE_TEXTURE(PAMAP_KINK, ptex->kink, mtex->kinkfac); + SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac); } } - if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); } - if(event & MAP_PA_LENGTH) { CLAMP(ptex->length,0.0,1.0); } - if(event & MAP_PA_CLUMP) { CLAMP(ptex->clump,0.0,1.0); } - if(event & MAP_PA_KINK) { CLAMP(ptex->kink,0.0,1.0); } - if(event & MAP_PA_ROUGH) { - CLAMP(ptex->rough1,0.0,1.0); - CLAMP(ptex->rough2,0.0,1.0); - CLAMP(ptex->roughe,0.0,1.0); - } - if(event & MAP_PA_DENS) { CLAMP(ptex->exist,0.0,1.0); } + + CLAMP_PARTICLE_TEXTURE_POS(PAMAP_LENGTH, ptex->length); + CLAMP_PARTICLE_TEXTURE_POS(PAMAP_CLUMP, ptex->clump); + CLAMP_PARTICLE_TEXTURE_POS(PAMAP_KINK, ptex->kink); + CLAMP_PARTICLE_TEXTURE_POS(PAMAP_ROUGH, ptex->rough1); + CLAMP_PARTICLE_TEXTURE_POS(PAMAP_DENS, ptex->exist); } -void psys_get_texture(ParticleSimulationData *sim, Material *ma, ParticleData *pa, ParticleTexture *ptex, int event) +void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTexture *ptex, int event, float cfra) { + ParticleSettings *part = sim->psys->part; + MTex **mtexp = part->mtex; MTex *mtex; int m; - float value, rgba[4], co[3], texco[3]; + float value, rgba[4], co[3], texvec[3]; int setvars=0; - if(ma) for(m=0; mmtex[m]; - if(mtex && (ma->septex & (1<pmapto){ + /* initialize ptex */ + ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp = + ptex->gravity = ptex->field = ptex->length = ptex->clump = ptex->kink = + ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.f; + + ptex->time = (float)(pa - sim->psys->particles)/(float)sim->psys->totpart; + + for(m=0; mmapto){ float def=mtex->def_var; short blend=mtex->blendtype; + short texco = mtex->texco; - if((mtex->texco & TEXCO_UV) && ELEM(sim->psys->part->from, PART_FROM_FACE, PART_FROM_VOLUME)) { - if(!get_particle_uv(sim->psmd->dm, pa, 0, pa->fuv, mtex->uvname, texco)) { - /* failed to get uv's, let's try orco's */ - psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,0,0,0,texco, 0); - } - } - else { - psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,0,0,0,texco, 0); + if(ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID)) + texco = TEXCO_GLOB; + + switch(texco) { + case TEXCO_GLOB: + copy_v3_v3(texvec, pa->state.co); + break; + case TEXCO_OBJECT: + copy_v3_v3(texvec, pa->state.co); + if(mtex->object) + mul_m4_v3(mtex->object->imat, texvec); + break; + case TEXCO_UV: + if(get_particle_uv(sim->psmd->dm, pa, 0, pa->fuv, mtex->uvname, texvec)) + break; + /* no break, failed to get uv's, so let's try orco's */ + case TEXCO_ORCO: + psys_particle_on_emitter(sim->psmd,sim->psys->part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,0,0,0,texvec, 0); + break; + case TEXCO_PARTICLE: + /* texture coordinates in range [-1,1] */ + texvec[0] = 2.f * (cfra - pa->time)/(pa->dietime-pa->time) - 1.f; + texvec[1] = 0.f; + texvec[2] = 0.f; + break; } - externtex(mtex, texco, &value, rgba, rgba+1, rgba+2, rgba+3, 0); + externtex(mtex, texvec, &value, rgba, rgba+1, rgba+2, rgba+3, 0); - if((event & mtex->pmapto) & MAP_PA_TIME){ + if((event & mtex->mapto) & PAMAP_TIME) { /* the first time has to set the base value for time regardless of blend mode */ if((setvars&MAP_PA_TIME)==0){ int flip= (mtex->timefac < 0.0f); @@ -3761,32 +3806,26 @@ void psys_get_texture(ParticleSimulationData *sim, Material *ma, ParticleData *p else ptex->time= texture_value_blend(def,ptex->time,value,mtex->timefac,blend); } - if((event & mtex->pmapto) & MAP_PA_LIFE) - ptex->life= texture_value_blend(def,ptex->life,value,mtex->lifefac,blend); - if((event & mtex->pmapto) & MAP_PA_DENS) - ptex->exist= texture_value_blend(def,ptex->exist,value,mtex->padensfac,blend); - if((event & mtex->pmapto) & MAP_PA_SIZE) - ptex->size= texture_value_blend(def,ptex->size,value,mtex->sizefac,blend); - if((event & mtex->pmapto) & MAP_PA_IVEL) - ptex->ivel= texture_value_blend(def,ptex->ivel,value,mtex->ivelfac,blend); - if((event & mtex->pmapto) & MAP_PA_PVEL) - texture_rgb_blend(ptex->pvel,rgba,ptex->pvel,value,mtex->pvelfac,blend); - if((event & mtex->pmapto) & MAP_PA_LENGTH) - ptex->length= texture_value_blend(def,ptex->length,value,mtex->lengthfac,blend); - if((event & mtex->pmapto) & MAP_PA_CLUMP) - ptex->clump= texture_value_blend(def,ptex->clump,value,mtex->clumpfac,blend); - if((event & mtex->pmapto) & MAP_PA_KINK) - ptex->kink= texture_value_blend(def,ptex->kink,value,mtex->kinkfac,blend); - } - } - if(event & MAP_PA_TIME) { CLAMP(ptex->time,0.0,1.0); } - if(event & MAP_PA_LIFE) { CLAMP(ptex->life,0.0,1.0); } - if(event & MAP_PA_DENS) { CLAMP(ptex->exist,0.0,1.0); } - if(event & MAP_PA_SIZE) { CLAMP(ptex->size,0.0,1.0); } - if(event & MAP_PA_IVEL) { CLAMP(ptex->ivel,0.0,1.0); } - if(event & MAP_PA_LENGTH) { CLAMP(ptex->length,0.0,1.0); } - if(event & MAP_PA_CLUMP) { CLAMP(ptex->clump,0.0,1.0); } - if(event & MAP_PA_KINK) { CLAMP(ptex->kink,0.0,1.0); } + SET_PARTICLE_TEXTURE(PAMAP_LIFE, ptex->life, mtex->lifefac) + SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac) + SET_PARTICLE_TEXTURE(PAMAP_SIZE, ptex->size, mtex->sizefac) + SET_PARTICLE_TEXTURE(PAMAP_IVEL, ptex->ivel, mtex->ivelfac) + SET_PARTICLE_TEXTURE(PAMAP_FIELD, ptex->field, mtex->fieldfac) + SET_PARTICLE_TEXTURE(PAMAP_GRAVITY, ptex->gravity, mtex->gravityfac) + SET_PARTICLE_TEXTURE(PAMAP_DAMP, ptex->damp, mtex->dampfac) + SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac) + } + } + + CLAMP_PARTICLE_TEXTURE_POS(PAMAP_TIME, ptex->time) + CLAMP_PARTICLE_TEXTURE_POS(PAMAP_LIFE, ptex->life) + CLAMP_PARTICLE_TEXTURE_POS(PAMAP_DENS, ptex->exist) + CLAMP_PARTICLE_TEXTURE_POS(PAMAP_SIZE, ptex->size) + CLAMP_PARTICLE_TEXTURE_POSNEG(PAMAP_IVEL, ptex->ivel) + CLAMP_PARTICLE_TEXTURE_POSNEG(PAMAP_FIELD, ptex->field) + CLAMP_PARTICLE_TEXTURE_POSNEG(PAMAP_GRAVITY, ptex->gravity) + CLAMP_PARTICLE_TEXTURE_POS(PAMAP_DAMP, ptex->damp) + CLAMP_PARTICLE_TEXTURE_POS(PAMAP_LENGTH, ptex->length) } /************************************************/ /* Particle State */ @@ -3829,28 +3868,8 @@ float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float UNUSED ParticleSettings *part = psys->part; float size; // time XXX - if(part->childtype==PART_CHILD_FACES){ + if(part->childtype==PART_CHILD_FACES) size=part->size; - -#if 0 // XXX old animation system - if((part->flag&PART_ABS_TIME)==0 && part->ipo){ - IpoCurve *icu; - - if(pa_time) - time=*pa_time; - else - time=psys_get_child_time(psys,cpa,cfra,NULL,NULL); - - /* correction for lifetime */ - calc_ipo(part->ipo, 100*time); - - for(icu = part->ipo->curve.first; icu; icu=icu->next) { - if(icu->adrcode == PART_SIZE) - size = icu->curval; - } - } -#endif // XXX old animation system - } else size=psys->particles[cpa->parent].size; @@ -3866,19 +3885,7 @@ static void get_child_modifier_parameters(ParticleSettings *part, ParticleThread ParticleSystem *psys = ctx->sim.psys; int i = cpa - psys->child; - ptex->length= 1.0f - part->randlength * PSYS_FRAND(i + 26); - ptex->clump=1.0; - ptex->kink=1.0; - ptex->rough1= 1.0; - ptex->rough2= 1.0; - ptex->roughe= 1.0; - ptex->exist= 1.0; - ptex->effector= 1.0; - - ptex->length*= part->clength_thres < PSYS_FRAND(i + 27) ? part->clength : 1.0f; - - get_cpa_texture(ctx->dm,ctx->ma,cpa_num,cpa_fuv,orco,ptex, - MAP_PA_DENS|MAP_PA_LENGTH|MAP_PA_CLUMP|MAP_PA_KINK|MAP_PA_ROUGH); + get_cpa_texture(ctx->dm, psys, part, psys->particles + cpa->pa[0], i, cpa_num, cpa_fuv, orco, ptex, PAMAP_DENS|PAMAP_CHILD, psys->cfra); if(ptex->exist < PSYS_FRAND(i + 24)) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 2e2decdf84d..409e9876599 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1519,62 +1519,37 @@ void psys_threads_free(ParticleThread *threads) /* set particle parameters that don't change during particle's life */ void initialize_particle(ParticleSimulationData *sim, ParticleData *pa, int p) { - ParticleSettings *part = sim->psys->part; + ParticleSystem *psys = sim->psys; + ParticleSettings *part = psys->part; ParticleTexture ptex; - Material *ma=0; - //IpoCurve *icu=0; // XXX old animation system - int totpart; - - totpart=sim->psys->totpart; - - ptex.life=ptex.size=ptex.exist=ptex.length=1.0; - ptex.time=(float)p/(float)totpart; - - BLI_srandom(sim->psys->seed + p + 125); - - if(part->from!=PART_FROM_PARTICLE && part->type!=PART_FLUID){ - ma=give_current_material(sim->ob,part->omat); - - /* TODO: needs some work to make most blendtypes generally usefull */ - psys_get_texture(sim,ma,pa,&ptex,MAP_PA_INIT); - } - - if(part->type==PART_HAIR) - pa->time= 0.0f; - //else if(part->type==PART_REACTOR && (part->flag&PART_REACT_STA_END)==0) - // pa->time= 300000.0f; /* max frame */ - else{ - //icu=find_ipocurve(psys->part->ipo,PART_EMIT_TIME); - //if(icu){ - // calc_icu(icu,100*ptex.time); - // ptex.time=icu->curval; - //} - pa->time= part->sta + (part->end - part->sta)*ptex.time; - } + pa->flag &= ~PARS_UNEXIST; - if(part->type!=PART_HAIR && part->distr!=PART_DISTR_GRID && part->from != PART_FROM_VERT){ - if(ptex.exist < BLI_frand()) + if(part->from != PART_FROM_PARTICLE && part->type != PART_FLUID) { + psys_get_texture(sim, pa, &ptex, PAMAP_INIT, 0.f); + + if(ptex.exist < PSYS_FRAND(p+125)) pa->flag |= PARS_UNEXIST; - else - pa->flag &= ~PARS_UNEXIST; + + pa->time = (part->type == PART_HAIR) ? 0.f : part->sta + (part->end - part->sta)*ptex.time; } - pa->hair_index=0; + pa->hair_index = 0; /* we can't reset to -1 anymore since we've figured out correct index in distribute_particles */ /* usage other than straight after distribute has to handle this index by itself - jahka*/ //pa->num_dmcache = DMCACHE_NOTFOUND; /* assume we dont have a derived mesh face */ } static void initialize_all_particles(ParticleSimulationData *sim) { - //IpoCurve *icu=0; // XXX old animation system ParticleSystem *psys = sim->psys; PARTICLE_P; psys->totunexist = 0; LOOP_PARTICLES { - initialize_particle(sim, pa, p); + if((pa->flag & PARS_UNEXIST)==0) + initialize_particle(sim, pa, p); + if(pa->flag & PARS_UNEXIST) psys->totunexist++; } @@ -1616,60 +1591,6 @@ static void initialize_all_particles(ParticleSimulationData *sim) } } - - if(psys->part->type != PART_FLUID) { -#if 0 // XXX old animation system - icu=find_ipocurve(psys->part->ipo,PART_EMIT_FREQ); - if(icu){ - float time=psys->part->sta, end=psys->part->end; - float v1, v2, a=0.0f, t1,t2, d; - - p=0; - pa=psys->particles; - - - calc_icu(icu,time); - v1=icu->curval; - if(v1<0.0f) v1=0.0f; - - calc_icu(icu,time+1.0f); - v2=icu->curval; - if(v2<0.0f) v2=0.0f; - - for(p=0, pa=psys->particles; pcurval; - } - if(timetime=time+((float)(p+1)-a)/v1; - } - else{ - d=(float)sqrt(v1*v1-2.0f*(v2-v1)*(a-(float)(p+1))); - t1=(-v1+d)/(v2-v1); - t2=(-v1-d)/(v2-v1); - - /* the root between 0-1 is the correct one */ - if(t1>0.0f && t1<=1.0f) - pa->time=time+t1; - else - pa->time=time+t2; - } - } - - pa->dietime = pa->time+pa->lifetime; - pa->flag &= ~PARS_UNEXIST; - } - for(; pflag |= PARS_UNEXIST; - } - } -#endif // XXX old animation system - } } /* sets particle to the emitter surface with initial velocity & rotation */ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, float cfra) @@ -1678,35 +1599,14 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, ParticleSystem *psys = sim->psys; ParticleSettings *part; ParticleTexture ptex; - ParticleKey state; - //IpoCurve *icu=0; // XXX old animation system float fac, phasefac, nor[3]={0,0,0},loc[3],vel[3]={0.0,0.0,0.0},rot[4],q2[4]; float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3]={0.0,0.0,0.0}; float x_vec[3]={1.0,0.0,0.0}, utan[3]={0.0,1.0,0.0}, vtan[3]={0.0,0.0,1.0}, rot_vec[3]={0.0,0.0,0.0}; - float q_phase[4], r_phase; + float q_phase[4]; int p = pa - psys->particles; part=psys->part; - - ptex.ivel=1.0; - ptex.life=1.0; - - /* we need to get every random even if they're not used so that they don't effect eachother */ - r_vel[0] = 2.0f * (PSYS_FRAND(p + 10) - 0.5f); - r_vel[1] = 2.0f * (PSYS_FRAND(p + 11) - 0.5f); - r_vel[2] = 2.0f * (PSYS_FRAND(p + 12) - 0.5f); - - r_ave[0] = 2.0f * (PSYS_FRAND(p + 13) - 0.5f); - r_ave[1] = 2.0f * (PSYS_FRAND(p + 14) - 0.5f); - r_ave[2] = 2.0f * (PSYS_FRAND(p + 15) - 0.5f); - - r_rot[0] = 2.0f * (PSYS_FRAND(p + 16) - 0.5f); - r_rot[1] = 2.0f * (PSYS_FRAND(p + 17) - 0.5f); - r_rot[2] = 2.0f * (PSYS_FRAND(p + 18) - 0.5f); - r_rot[3] = 2.0f * (PSYS_FRAND(p + 19) - 0.5f); - normalize_qt(r_rot); - - r_phase = PSYS_FRAND(p + 20); +#if 0 /* deprecated code */ if(part->from==PART_FROM_PARTICLE){ float speed; ParticleSimulationData tsim= {0}; @@ -1733,79 +1633,93 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, VECCOPY(pa->fuv, loc); /* abusing pa->fuv (not used for "from particle") for storing emit location */ } else{ - /* get precise emitter matrix if particle is born */ - if(part->type!=PART_HAIR && pa->time < cfra && pa->time >= sim->psys->cfra) { - /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */ - BKE_animsys_evaluate_animdata(&sim->ob->id, sim->ob->adt, pa->time, ADT_RECALC_ANIM); - where_is_object_time(sim->scene, sim->ob, pa->time); - } +#endif + /* get precise emitter matrix if particle is born */ + if(part->type!=PART_HAIR && pa->time < cfra && pa->time >= sim->psys->cfra) { + /* we have to force RECALC_ANIM here since where_is_objec_time only does drivers */ + BKE_animsys_evaluate_animdata(&sim->ob->id, sim->ob->adt, pa->time, ADT_RECALC_ANIM); + where_is_object_time(sim->scene, sim->ob, pa->time); + } - /* get birth location from object */ - if(part->tanfac!=0.0) - psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0); - else - psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0); + /* get birth location from object */ + if(part->tanfac != 0.f) + psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,utan,vtan,0,0); + else + psys_particle_on_emitter(sim->psmd, part->from,pa->num, pa->num_dmcache, pa->fuv,pa->foffset,loc,nor,0,0,0,0); - /* get possible textural influence */ - psys_get_texture(sim, give_current_material(sim->ob,part->omat), pa, &ptex, MAP_PA_IVEL|MAP_PA_LIFE); + /* get possible textural influence */ + psys_get_texture(sim, pa, &ptex, PAMAP_IVEL|PAMAP_LIFE, cfra); - //if(vg_vel && pa->num != -1) - // ptex.ivel*=psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_vel); - - /* particles live in global space so */ - /* let's convert: */ - /* -location */ - mul_m4_v3(ob->obmat,loc); + /* particles live in global space so */ + /* let's convert: */ + /* -location */ + mul_m4_v3(ob->obmat, loc); - /* -normal */ - mul_mat3_m4_v3(ob->obmat,nor); - normalize_v3(nor); - - /* -tangent */ - if(part->tanfac!=0.0){ - //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f; - float phase=0.0f; - mul_v3_fl(vtan,-(float)cos(M_PI*(part->tanphase+phase))); - fac=-(float)sin(M_PI*(part->tanphase+phase)); - VECADDFAC(vtan,vtan,utan,fac); - - mul_mat3_m4_v3(ob->obmat,vtan); - - VECCOPY(utan,nor); - mul_v3_fl(utan,dot_v3v3(vtan,nor)); - VECSUB(vtan,vtan,utan); + /* -normal */ + mul_mat3_m4_v3(ob->obmat, nor); + normalize_v3(nor); + + /* -tangent */ + if(part->tanfac!=0.0){ + //float phase=vg_rot?2.0f*(psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_rot)-0.5f):0.0f; + float phase=0.0f; + mul_v3_fl(vtan,-(float)cos(M_PI*(part->tanphase+phase))); + fac=-(float)sin(M_PI*(part->tanphase+phase)); + VECADDFAC(vtan,vtan,utan,fac); + + mul_mat3_m4_v3(ob->obmat,vtan); + + VECCOPY(utan,nor); + mul_v3_fl(utan,dot_v3v3(vtan,nor)); + VECSUB(vtan,vtan,utan); - normalize_v3(vtan); - } + normalize_v3(vtan); + } - /* -velocity */ - if(part->randfac!=0.0){ - mul_mat3_m4_v3(ob->obmat,r_vel); - normalize_v3(r_vel); - } + /* -velocity */ + if(part->randfac!=0.0){ + r_vel[0] = 2.0f * (PSYS_FRAND(p + 10) - 0.5f); + r_vel[1] = 2.0f * (PSYS_FRAND(p + 11) - 0.5f); + r_vel[2] = 2.0f * (PSYS_FRAND(p + 12) - 0.5f); - /* -angular velocity */ - if(part->avemode==PART_AVE_RAND){ - mul_mat3_m4_v3(ob->obmat,r_ave); - normalize_v3(r_ave); - } + mul_mat3_m4_v3(ob->obmat, r_vel); + normalize_v3(r_vel); + } + + /* -angular velocity */ + if(part->avemode==PART_AVE_RAND){ + r_ave[0] = 2.0f * (PSYS_FRAND(p + 13) - 0.5f); + r_ave[1] = 2.0f * (PSYS_FRAND(p + 14) - 0.5f); + r_ave[2] = 2.0f * (PSYS_FRAND(p + 15) - 0.5f); + + mul_mat3_m4_v3(ob->obmat,r_ave); + normalize_v3(r_ave); + } - /* -rotation */ - if(part->randrotfac != 0.0f){ - mat4_to_quat(rot,ob->obmat); - mul_qt_qtqt(r_rot,r_rot,rot); - } + /* -rotation */ + if(part->randrotfac != 0.0f){ + r_rot[0] = 2.0f * (PSYS_FRAND(p + 16) - 0.5f); + r_rot[1] = 2.0f * (PSYS_FRAND(p + 17) - 0.5f); + r_rot[2] = 2.0f * (PSYS_FRAND(p + 18) - 0.5f); + r_rot[3] = 2.0f * (PSYS_FRAND(p + 19) - 0.5f); + normalize_qt(r_rot); + + mat4_to_quat(rot,ob->obmat); + mul_qt_qtqt(r_rot,r_rot,rot); + } +#if 0 } +#endif if(part->phystype==PART_PHYS_BOIDS && pa->boid) { BoidParticle *bpa = pa->boid; float dvec[3], q[4], mat[3][3]; - VECCOPY(pa->state.co,loc); + copy_v3_v3(pa->state.co,loc); /* boids don't get any initial velocity */ - pa->state.vel[0]=pa->state.vel[1]=pa->state.vel[2]=0.0f; + zero_v3(pa->state.vel); /* boids store direction in ave */ if(fabs(nor[2])==1.0f) { @@ -1844,66 +1758,56 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* -velocity from: */ /* *reactions */ - if(dtime>0.0f){ - VECSUB(vel,pa->state.vel,pa->prev_state.vel); + if(dtime > 0.f){ + sub_v3_v3v3(vel, pa->state.vel, pa->prev_state.vel); } /* *emitter velocity */ - if(dtime!=0.0 && part->obfac!=0.0){ - VECSUB(vel,loc,pa->state.co); - mul_v3_fl(vel,part->obfac/dtime); + if(dtime != 0.f && part->obfac != 0.f){ + sub_v3_v3v3(vel, loc, pa->state.co); + mul_v3_fl(vel, part->obfac/dtime); } /* *emitter normal */ - if(part->normfac!=0.0) - VECADDFAC(vel,vel,nor,part->normfac); + if(part->normfac != 0.f) + madd_v3_v3fl(vel, nor, part->normfac); /* *emitter tangent */ - if(sim->psmd && part->tanfac!=0.0) - VECADDFAC(vel,vel,vtan,part->tanfac); - //VECADDFAC(vel,vel,vtan,part->tanfac*(vg_tan?psys_particle_value_from_verts(sim->psmd->dm,part->from,pa,vg_tan):1.0f)); + if(sim->psmd && part->tanfac != 0.f) + madd_v3_v3fl(vel, vtan, part->tanfac); /* *emitter object orientation */ - if(part->ob_vel[0]!=0.0) { + if(part->ob_vel[0] != 0.f) { normalize_v3_v3(vec, ob->obmat[0]); - VECADDFAC(vel, vel, vec, part->ob_vel[0]); + madd_v3_v3fl(vel, vec, part->ob_vel[0]); } - if(part->ob_vel[1]!=0.0) { + if(part->ob_vel[1] != 0.f) { normalize_v3_v3(vec, ob->obmat[1]); - VECADDFAC(vel, vel, vec, part->ob_vel[1]); + madd_v3_v3fl(vel, vec, part->ob_vel[1]); } - if(part->ob_vel[2]!=0.0) { + if(part->ob_vel[2] != 0.f) { normalize_v3_v3(vec, ob->obmat[2]); - VECADDFAC(vel, vel, vec, part->ob_vel[2]); + madd_v3_v3fl(vel, vec, part->ob_vel[2]); } /* *texture */ /* TODO */ /* *random */ - if(part->randfac!=0.0) - VECADDFAC(vel,vel,r_vel,part->randfac); + if(part->randfac != 0.f) + madd_v3_v3fl(vel, r_vel, part->randfac); /* *particle */ - if(part->partfac!=0.0) - VECADDFAC(vel,vel,p_vel,part->partfac); - - //icu=find_ipocurve(psys->part->ipo,PART_EMIT_VEL); - //if(icu){ - // calc_icu(icu,100*((pa->time-part->sta)/(part->end-part->sta))); - // ptex.ivel*=icu->curval; - //} - - mul_v3_fl(vel,ptex.ivel); + if(part->partfac != 0.f) + madd_v3_v3fl(vel, p_vel, part->partfac); - VECCOPY(pa->state.vel,vel); + mul_v3_v3fl(pa->state.vel, vel, ptex.ivel); /* -location from emitter */ - VECCOPY(pa->state.co,loc); + copy_v3_v3(pa->state.co,loc); /* -rotation */ - pa->state.rot[0]=1.0; - pa->state.rot[1]=pa->state.rot[2]=pa->state.rot[3]=0.0; + unit_qt(pa->state.rot); if(part->rotmode){ /* create vector into which rotation is aligned */ @@ -1939,7 +1843,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* rotation phase */ phasefac = part->phasefac; if(part->randphasefac != 0.0f) - phasefac += part->randphasefac * r_phase; + phasefac += part->randphasefac * PSYS_FRAND(p + 20); axis_angle_to_quat( q_phase,x_vec, phasefac*(float)M_PI); /* combine base rotation & phase */ @@ -1948,25 +1852,19 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, /* -angular velocity */ - pa->state.ave[0] = pa->state.ave[1] = pa->state.ave[2] = 0.0; + zero_v3(pa->state.ave); if(part->avemode){ switch(part->avemode){ case PART_AVE_SPIN: - VECCOPY(pa->state.ave,vel); + copy_v3_v3(pa->state.ave, vel); break; case PART_AVE_RAND: - VECCOPY(pa->state.ave,r_ave); + copy_v3_v3(pa->state.ave, r_ave); break; } normalize_v3(pa->state.ave); mul_v3_fl(pa->state.ave,part->avefac); - - //icu=find_ipocurve(psys->part->ipo,PART_EMIT_AVE); - //if(icu){ - // calc_icu(icu,100*((pa->time-part->sta)/(part->end-part->sta))); - // mul_v3_fl(pa->state.ave,icu->curval); - //} } } @@ -1975,7 +1873,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, pa->lifetime = 100.0f; } else{ - pa->lifetime = part->lifetime*ptex.life; + pa->lifetime = part->lifetime * ptex.life; if(part->randlife != 0.0) pa->lifetime *= 1.0f - part->randlife * PSYS_FRAND(p + 21); @@ -2002,15 +1900,9 @@ static void reset_all_particles(ParticleSimulationData *sim, float dtime, float { ParticleData *pa; int p, totpart=sim->psys->totpart; - //float *vg_vel=psys_cache_vgroup(sim->psmd->dm,sim->psys,PSYS_VG_VEL); - //float *vg_tan=psys_cache_vgroup(sim->psmd->dm,sim->psys,PSYS_VG_TAN); - //float *vg_rot=psys_cache_vgroup(sim->psmd->dm,sim->psys,PSYS_VG_ROT); for(p=from, pa=sim->psys->particles+from; pmass, fac /*, fra=sim->psys->cfra*/; int i, steps=1; + ParticleTexture ptex; + + psys_get_texture(sim, pa, &ptex, PAMAP_PHYSICS, cfra); /* maintain angular velocity */ VECCOPY(pa->state.ave,pa->prev_state.ave); @@ -2575,6 +2470,9 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra if(part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR) pdDoEffectors(sim->psys->effectors, sim->colliders, part->effector_weights, &epoint, force, impulse); + mul_v3_fl(force, ptex.field); + mul_v3_fl(impulse, ptex.field); + /* calculate air-particle interaction */ if(part->dragfac!=0.0f){ fac=-part->dragfac*pa->size*pa->size*len_v3(states[i].vel); @@ -2595,10 +2493,7 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra if(psys_uses_gravity(sim) /* normal gravity is too strong for hair so it's disabled by default */ && (part->type != PART_HAIR || part->effector_weights->flag & EFF_WEIGHT_DO_HAIR)) { - float gravity[3]; - VECCOPY(gravity, sim->scene->physics_settings.gravity); - mul_v3_fl(gravity, part->effector_weights->global_gravity); - VECADD(force,force,gravity); + madd_v3_v3fl(force, sim->scene->physics_settings.gravity, part->effector_weights->global_gravity * ptex.gravity); } /* calculate next state */ @@ -2679,8 +2574,8 @@ static void apply_particle_forces(ParticleSimulationData *sim, int p, float dfra } /* damp affects final velocity */ - if(part->dampfac!=0.0) - mul_v3_fl(pa->state.vel,1.0f-part->dampfac); + if(part->dampfac != 0.f) + mul_v3_fl(pa->state.vel, 1.f - part->dampfac * ptex.damp); VECCOPY(pa->state.ave, states->ave); @@ -3471,6 +3366,7 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) ParticleSystem *psys = sim->psys; ParticleSettings *part=psys->part; BoidBrainData bbd; + ParticleTexture ptex; PARTICLE_P; float timestep; /* frame & time changes */ @@ -3485,7 +3381,8 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) if(dfra<0.0){ LOOP_EXISTING_PARTICLES { - pa->size = part->size; + psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra); + pa->size = part->size*ptex.size; if(part->randsize > 0.0) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); @@ -3538,7 +3435,9 @@ static void dynamics_step(ParticleSimulationData *sim, float cfra) LOOP_SHOWN_PARTICLES { copy_particle_key(&pa->prev_state,&pa->state,1); - pa->size = part->size; + psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra); + + pa->size = part->size*ptex.size; if(part->randsize > 0.0) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); @@ -3685,6 +3584,7 @@ static void cached_step(ParticleSimulationData *sim, float cfra) { ParticleSystem *psys = sim->psys; ParticleSettings *part = psys->part; + ParticleTexture ptex; PARTICLE_P; float disp, dietime; @@ -3695,7 +3595,8 @@ static void cached_step(ParticleSimulationData *sim, float cfra) disp= (float)psys_get_current_display_percentage(psys)/100.0f; LOOP_PARTICLES { - pa->size = part->size; + psys_get_texture(sim, pa, &ptex, PAMAP_SIZE, cfra); + pa->size = part->size*ptex.size; if(part->randsize > 0.0) pa->size *= 1.0f - part->randsize * PSYS_FRAND(p + 1); diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 57c629d5544..0129e709505 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -51,6 +51,7 @@ #include "DNA_brush_types.h" #include "DNA_node_types.h" #include "DNA_color_types.h" +#include "DNA_particle_types.h" #include "IMB_imbuf.h" @@ -671,7 +672,9 @@ void default_mtex(MTex *mtex) mtex->lifefac= 1.0f; mtex->sizefac= 1.0f; mtex->ivelfac= 1.0f; - mtex->pvelfac= 1.0f; + mtex->dampfac= 1.0f; + mtex->gravityfac= 1.0f; + mtex->fieldfac= 1.0f; mtex->normapspace= MTEX_NSPACE_TANGENT; } @@ -1167,6 +1170,42 @@ void set_current_brush_texture(Brush *br, Tex *newtex) } } +Tex *give_current_particle_texture(ParticleSettings *part) +{ + MTex *mtex= NULL; + Tex *tex= NULL; + + if(!part) return 0; + + mtex= part->mtex[(int)(part->texact)]; + if(mtex) tex= mtex->tex; + + return tex; +} + +void set_current_particle_texture(ParticleSettings *part, Tex *newtex) +{ + int act= part->texact; + + if(part->mtex[act] && part->mtex[act]->tex) + id_us_min(&part->mtex[act]->tex->id); + + if(newtex) { + if(!part->mtex[act]) { + part->mtex[act]= add_mtex(); + part->mtex[act]->texco= TEXCO_ORCO; + part->mtex[act]->blendtype= MTEX_MUL; + } + + part->mtex[act]->tex= newtex; + id_us_plus(&newtex->id); + } + else if(part->mtex[act]) { + MEM_freeN(part->mtex[act]); + part->mtex[act]= NULL; + } +} + /* ------------------------------------------------------------------------- */ EnvMap *BKE_add_envmap(void) -- cgit v1.2.3 From 55f68c36574779ae2fac3652466584628b22c633 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Feb 2011 16:54:24 +0000 Subject: fix for more warnings. - modifier code was using sizeof() without knowing the sizeof the array when clearing the modifier type array. - use BLI_snprintf rather then sprintf where the size of the string is known. - particle drawing code kept a reference to stack float values (not a problem at the moment but would crash if accessed later). --- source/blender/blenkernel/intern/blender.c | 8 ++-- source/blender/blenkernel/intern/deform.c | 8 ++-- source/blender/blenkernel/intern/image.c | 64 ++++++++++------------------- source/blender/blenkernel/intern/library.c | 6 +-- source/blender/blenkernel/intern/modifier.c | 7 ++-- 5 files changed, 37 insertions(+), 56 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 6e08df0f465..222d416e2f0 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -124,9 +124,9 @@ void initglobals(void) ENDIAN_ORDER= (((char*)&ENDIAN_ORDER)[0])? L_ENDIAN: B_ENDIAN; if(BLENDER_SUBVERSION) - sprintf(versionstr, "www.blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION); + BLI_snprintf(versionstr, sizeof(versionstr), "www.blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION); else - sprintf(versionstr, "www.blender.org %d", BLENDER_VERSION); + BLI_snprintf(versionstr, sizeof(versionstr), "www.blender.org %d", BLENDER_VERSION); #ifdef _WIN32 // FULLSCREEN G.windowstate = G_WINDOWSTATE_USERDEF; @@ -314,7 +314,7 @@ static int handle_subversion_warning(Main *main) char str[128]; - sprintf(str, "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile); + BLI_snprintf(str, sizeof(str), "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile); // XXX error(str); } return 1; @@ -520,7 +520,7 @@ void BKE_write_undo(bContext *C, const char *name) counter++; counter= counter % U.undosteps; - sprintf(numstr, "%d.blend", counter); + BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter); BLI_make_file_string("/", tstr, btempdir, numstr); success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL, NULL); diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 937681fcdc3..1b63e4fd5d1 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -339,10 +339,10 @@ void defgroup_unique_name (bDeformGroup *dg, Object *ob) void flip_side_name (char *name, const char *from_name, int strip_number) { int len; - char prefix[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The part before the facing */ - char suffix[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The part after the facing */ - char replace[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The replacement string */ - char number[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The number extension string */ + char prefix[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The part before the facing */ + char suffix[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The part after the facing */ + char replace[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The replacement string */ + char number[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The number extension string */ char *index=NULL; len= strlen(from_name); diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 37d1e65144d..4092abb07d4 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -873,32 +873,23 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) time_t t; if (scene->r.stamp & R_STAMP_FILENAME) { - if (G.relbase_valid) { - if (do_prefix) sprintf(stamp_data->file, "File %s", G.main->name); - else sprintf(stamp_data->file, "%s", G.main->name); - } else { - if (do_prefix) strcpy(stamp_data->file, "File "); - else strcpy(stamp_data->file, ""); - } + BLI_snprintf(stamp_data->file, sizeof(stamp_data->file), do_prefix ? "File %s":"%s", G.relbase_valid ? G.main->name:""); } else { stamp_data->file[0] = '\0'; } if (scene->r.stamp & R_STAMP_NOTE) { /* Never do prefix for Note */ - sprintf(stamp_data->note, "%s", scene->r.stamp_udata); + BLI_snprintf(stamp_data->note, sizeof(stamp_data->note), "%s", scene->r.stamp_udata); } else { stamp_data->note[0] = '\0'; } if (scene->r.stamp & R_STAMP_DATE) { - - t = time (NULL); - tl = localtime (&t); - sprintf (text, "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec); - - if (do_prefix) sprintf(stamp_data->date, "Date %s", text); - else sprintf(stamp_data->date, "%s", text); + t = time(NULL); + tl = localtime(&t); + BLI_snprintf(text, sizeof(text), "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec); + BLI_snprintf(stamp_data->date, sizeof(stamp_data->date), do_prefix ? "Date %s":"%s", text); } else { stamp_data->date[0] = '\0'; } @@ -908,9 +899,8 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) if (name) strcpy(text, name); else strcpy(text, ""); - - if (do_prefix) sprintf(stamp_data->marker, "Marker %s", text); - else sprintf(stamp_data->marker, "%s", text); + + BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s":"%s", text); } else { stamp_data->marker[0] = '\0'; } @@ -932,12 +922,11 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } if (scene->r.frs_sec < 100) - sprintf (text, "%02d:%02d:%02d.%02d", h, m, s, f); + BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%02d", h, m, s, f); else - sprintf (text, "%02d:%02d:%02d.%03d", h, m, s, f); - - if (do_prefix) sprintf(stamp_data->time, "Time %s", text); - else sprintf(stamp_data->time, "%s", text); + BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%03d", h, m, s, f); + + BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Time %s":"%s", text); } else { stamp_data->time[0] = '\0'; } @@ -948,39 +937,32 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) if(scene->r.efra>9) digits= 1 + (int) log10(scene->r.efra); - - if (do_prefix) sprintf(format, "Frame %%0%di", digits); - else sprintf(format, "%%0%di", digits); - sprintf (stamp_data->frame, format, scene->r.cfra); + + BLI_snprintf(format, sizeof(format), do_prefix ? "Frame %%0%di":"%%0%di", digits); + BLI_snprintf (stamp_data->frame, sizeof(stamp_data->frame), format, scene->r.cfra); } else { stamp_data->frame[0] = '\0'; } if (scene->r.stamp & R_STAMP_CAMERA) { - if (scene->camera) strcpy(text, scene->camera->id.name+2); - else strcpy(text, ""); - - if (do_prefix) sprintf(stamp_data->camera, "Camera %s", text); - else sprintf(stamp_data->camera, "%s", text); + BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s":"%s", scene->camera ? scene->camera->id.name+2 : ""); } else { stamp_data->camera[0] = '\0'; } if (scene->r.stamp & R_STAMP_CAMERALENS) { if (scene->camera && scene->camera->type == OB_CAMERA) { - sprintf(text, "%.2f", ((Camera *)scene->camera->data)->lens); + BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)scene->camera->data)->lens); } else strcpy(text, ""); - if (do_prefix) sprintf(stamp_data->cameralens, "Lens %s", text); - else sprintf(stamp_data->cameralens, "%s", text); + BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s":"%s", text); } else { stamp_data->cameralens[0] = '\0'; } if (scene->r.stamp & R_STAMP_SCENE) { - if (do_prefix) sprintf(stamp_data->scene, "Scene %s", scene->id.name+2); - else sprintf(stamp_data->scene, "%s", scene->id.name+2); + BLI_snprintf(stamp_data->scene, sizeof(stamp_data->scene), do_prefix ? "Scene %s":"%s", scene->id.name+2); } else { stamp_data->scene[0] = '\0'; } @@ -990,9 +972,8 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) if (seq) strcpy(text, seq->name+2); else strcpy(text, ""); - - if (do_prefix) sprintf(stamp_data->strip, "Strip %s", text); - else sprintf(stamp_data->strip, "%s", text); + + BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s":"%s", text); } else { stamp_data->strip[0] = '\0'; } @@ -1004,8 +985,7 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) { BLI_timestr(stats->lastframetime, text); - if (do_prefix) sprintf(stamp_data->rendertime, "RenderTime %s", text); - else sprintf(stamp_data->rendertime, "%s", text); + BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s":"%s", text); } else { stamp_data->rendertime[0] = '\0'; } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 6eb5399404a..671f4d91922 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -920,7 +920,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor BLI_dynstr_append(pupds, buf); BLI_dynstr_append(pupds, id->name+2); - sprintf(buf, "%%x%d", i+1); + BLI_snprintf(buf, sizeof(buf), "%%x%d", i+1); BLI_dynstr_append(pupds, buf); /* icon */ @@ -931,7 +931,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor case ID_IM: /* fall through */ case ID_WO: /* fall through */ case ID_LA: /* fall through */ - sprintf(buf, "%%i%d", BKE_icon_getid(id) ); + BLI_snprintf(buf, sizeof(buf), "%%i%d", BKE_icon_getid(id) ); BLI_dynstr_append(pupds, buf); break; default: @@ -1128,7 +1128,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) continue; } /* this format specifier is from hell... */ - sprintf(name, "%s.%.3d", left, nr); + BLI_snprintf(name, sizeof(id->name) - 2,"%s.%.3d", left, nr); return 1; } diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 03091b9b0a4..6f8075310c7 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -57,7 +57,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) { - static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]; + static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]= {0}; static int types_init = 1; if (types_init) { @@ -220,12 +220,13 @@ int modifier_sameTopology(ModifierData *md) void modifier_setError(ModifierData *md, const char *format, ...) { - char buffer[2048]; + char buffer[512]; va_list ap; va_start(ap, format); - vsprintf(buffer, format, ap); + vsnprintf(buffer, sizeof(buffer), format, ap); va_end(ap); + buffer[sizeof(buffer) - 1]= '\0'; if (md->error) MEM_freeN(md->error); -- cgit v1.2.3 From d909e61d99d760e9c5ae0c9e29804ac609bf7b5f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sat, 12 Feb 2011 17:51:02 +0000 Subject: Sculpting on deformed mesh ========================== Removed limitation of armatured-only objects for sculpting -- now all deformation modifiers are allowed in sculpt mode. Use crazyspace corrections like from transformation modules was used to support all deformation modifiers. Internal change: all crazyspace-related functions were noved to crazyspace.c P.S. Brush could make quite unexpected deformation for meshes which are deformed in specified way. Got patch for this and discussing with Brecht if it's really needed or maybe it could be done in better way. --- source/blender/blenkernel/intern/DerivedMesh.c | 107 +------------------------ 1 file changed, 1 insertion(+), 106 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index be9cda6c58f..eedc2636991 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1721,12 +1721,6 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos if(useDeform < 0 && mti->dependsOnTime && mti->dependsOnTime(md)) continue; if(mti->type == eModifierTypeType_OnlyDeform) { - if(sculpt_mode && !has_multires) - if(!ELEM(md->type, eModifierType_Armature, eModifierType_ShapeKey)) { - modifier_setError(md, "Not supported in sculpt mode."); - continue; - } - if(!deformedVerts) deformedVerts = mesh_getVertexCos(me, &numVerts); @@ -1780,7 +1774,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos continue; } if(sculpt_mode && (!has_multires || multires_applied)) - if(md->type != eModifierType_Armature || multires_applied) { + if(mti->type != eModifierTypeType_OnlyDeform || multires_applied) { modifier_setError(md, "Not supported in sculpt mode."); continue; } @@ -2485,105 +2479,6 @@ float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob) return vertexcosnos; } -/* ********* crazyspace *************** */ - -int editmesh_get_first_deform_matrices(Scene *scene, Object *ob, EditMesh *em, float (**deformmats)[3][3], float (**deformcos)[3]) -{ - ModifierData *md; - DerivedMesh *dm; - int i, a, numleft = 0, numVerts = 0; - int cageIndex = modifiers_getCageIndex(scene, ob, NULL, 1); - float (*defmats)[3][3] = NULL, (*deformedVerts)[3] = NULL; - - modifiers_clearErrors(ob); - - dm = NULL; - md = modifiers_getVirtualModifierList(ob); - - /* compute the deformation matrices and coordinates for the first - modifiers with on cage editing that are enabled and support computing - deform matrices */ - for(i = 0; md && i <= cageIndex; i++, md = md->next) { - ModifierTypeInfo *mti = modifierType_getInfo(md->type); - - if(!editmesh_modifier_is_enabled(scene, md, dm)) - continue; - - if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatricesEM) { - if(!defmats) { - dm= editmesh_get_derived(em, NULL); - deformedVerts= editmesh_get_vertex_cos(em, &numVerts); - defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats"); - - for(a=0; adeformMatricesEM(md, ob, em, dm, deformedVerts, defmats, - numVerts); - } - else - break; - } - - for(; md && i <= cageIndex; md = md->next, i++) - if(editmesh_modifier_is_enabled(scene, md, dm) && modifier_isCorrectableDeformed(md)) - numleft++; - - if(dm) - dm->release(dm); - - *deformmats= defmats; - *deformcos= deformedVerts; - - return numleft; -} - -void sculpt_get_deform_matrices(Scene *scene, Object *ob, float (**deformmats)[3][3], float (**deformcos)[3]) -{ - ModifierData *md; - DerivedMesh *dm; - int a, numVerts= 0; - float (*defmats)[3][3]= NULL, (*deformedVerts)[3]= NULL; - MultiresModifierData *mmd= get_multires_modifier(scene, ob, 0); - int has_multires = mmd != NULL && mmd->sculptlvl > 0; - - if(has_multires) { - *deformmats= NULL; - *deformcos= NULL; - return; - } - - dm= NULL; - md= modifiers_getVirtualModifierList(ob); - - for(; md; md= md->next) { - ModifierTypeInfo *mti= modifierType_getInfo(md->type); - - if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; - - if(mti->type==eModifierTypeType_OnlyDeform && mti->deformMatrices) { - if(!defmats) { - Mesh *me= (Mesh*)ob->data; - dm= mesh_create_derived(me, ob, NULL); - deformedVerts= mesh_getVertexCos(me, &numVerts); - defmats= MEM_callocN(sizeof(*defmats)*numVerts, "defmats"); - - for(a=0; adeformMatrices(md, ob, dm, deformedVerts, defmats, numVerts); - } - } - - if(dm) - dm->release(dm); - - *deformmats= defmats; - *deformcos= deformedVerts; -} - /* ******************* GLSL ******************** */ void DM_add_tangent_layer(DerivedMesh *dm) -- cgit v1.2.3 From 0a83817672a6ec908eb5f4dd85a48ffa6e97736c Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 12 Feb 2011 17:54:24 +0000 Subject: Small particle effectors update: * Greetings from farsthary: particle rotation is now taken into account for particle effector direction. ** This gives all kinds of new possibilities as he shows in his blog http://farsthary.wordpress.com/2011/02/08/vortex-particle-simple-tut/. **The only modification I made to his patch was to use the actual rotated particle direction as the effector direction as this defaults to the particle velocity vector, so no actual new options are needed. * I also added an "effector amount" setting for particle effectors so that only a part of the particles can be considered as effectors. This makes it possible to create simple "farsthary vortexes" with only one particle system. * Also some tiny reorganization of the falloff min/max values for a nicer ui. --- source/blender/blenkernel/intern/effect.c | 29 ++++++++++++++++++++--------- source/blender/blenkernel/intern/particle.c | 2 -- 2 files changed, 20 insertions(+), 11 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index a79a5fddf00..43ca7435712 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -651,11 +651,15 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin // eff->flag |= PE_VELOCITY_TO_IMPULSE; //} - VECCOPY(efd->loc, state.co); - VECCOPY(efd->nor, state.vel); - if(real_velocity) { - VECCOPY(efd->vel, state.vel); - } + copy_v3_v3(efd->loc, state.co); + + /* rather than use the velocity use rotated x-axis (defaults to velocity) */ + efd->nor[0] = 1.f; + efd->nor[1] = efd->nor[2] = 0.f; + mul_qt_v3(state.rot, efd->nor); + + if(real_velocity) + copy_v3_v3(efd->vel, state.vel); efd->size = pa->size; } @@ -720,7 +724,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin return ret; } -static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int *tot, int *p) +static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int *tot, int *p, int *step) { if(eff->pd->shape == PFIELD_SHAPE_POINTS) { efd->index = p; @@ -753,6 +757,13 @@ static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoin *p= point->index % eff->psys->totpart; *tot= *p + 1; } + + if(eff->psys->part->effector_amount) { + int totpart = eff->psys->totpart; + int amount = eff->psys->part->effector_amount; + + *step = (totpart > amount) ? totpart/amount : 1; + } } else { *p = 0; @@ -990,7 +1001,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we */ EffectorCache *eff; EffectorData efd; - int p=0, tot = 1; + int p=0, tot = 1, step = 1; /* Cycle through collected objects, get total of (1/(gravity_strength * dist^gravity_power)) */ /* Check for min distance here? (yes would be cool to add that, ton) */ @@ -998,9 +1009,9 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we if(effectors) for(eff = effectors->first; eff; eff=eff->next) { /* object effectors were fully checked to be OK to evaluate! */ - get_effector_tot(eff, &efd, point, &tot, &p); + get_effector_tot(eff, &efd, point, &tot, &p, &step); - for(; pnormfac= 1.0f; - part->reactshape=1.0f; - part->mass=1.0; part->size=0.05; part->childsize=1.0; -- cgit v1.2.3 From 54b2127fadd53ccabeeee6b7bc75a10495643255 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sat, 12 Feb 2011 21:54:50 +0000 Subject: Fix for [#25857] create_dupli_list incorrect behaviour with particle systems * Particle duplis are now always created with render percentage if G.rendering is set. * This is not yet a perfect solution (hair for example won't yet work correctly), but it's good to have even partial functionality here until a proper way to handle this is implemented. --- source/blender/blenkernel/intern/anim.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index ab1da04e683..2c52e0b0c49 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1173,6 +1173,8 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p int a, b, counter, hair = 0; int totpart, totchild, totgroup=0, pa_num; + int no_draw_flag = PARS_UNEXIST; + if(psys==0) return; /* simple preventing of too deep nested groups */ @@ -1185,6 +1187,9 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if(!psys_check_enabled(par, psys)) return; + + if(G.rendering == 0) + no_draw_flag |= PARS_NO_DISP; ctime = bsystem_time(scene, par, (float)scene->r.cfra, 0.0); @@ -1280,7 +1285,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p for(pa=psys->particles,counter=0; aflag & (PARS_UNEXIST+PARS_NO_DISP)) + if(pa->flag & no_draw_flag) continue; pa_num = pa->num; -- cgit v1.2.3 From 9e03a0d4762b4734fe7ccb20e03b4a3c8f939620 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 13 Feb 2011 02:55:23 +0000 Subject: remove unused var --- source/blender/blenkernel/intern/particle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 1817d85990e..b2f4b6bdc97 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3678,7 +3678,7 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, fl static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSettings *part, ParticleData *par, int child_index, int face_index, float *fw, float *orco, ParticleTexture *ptex, int event, float cfra) { MTex *mtex, **mtexp = part->mtex; - int m,setvars=0; + int m; float value, rgba[4], texvec[3]; ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp = -- cgit v1.2.3 From 867fc4b463ef39ea16103f18f332c3d259624d29 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 13 Feb 2011 03:21:27 +0000 Subject: enforce string limits (reported by pedantic checking tools & some developers). mostly replace strcpy with BLI_strncpy and multiple strcat's with a BLI_snprintf(). also fix possible crash if CWD isnt available. --- source/blender/blenkernel/intern/armature.c | 17 ++++++++--------- source/blender/blenkernel/intern/blender.c | 4 ++-- source/blender/blenkernel/intern/boids.c | 2 +- source/blender/blenkernel/intern/constraint.c | 2 +- source/blender/blenkernel/intern/deform.c | 6 +++--- source/blender/blenkernel/intern/exotic.c | 2 +- source/blender/blenkernel/intern/font.c | 11 ++++++----- source/blender/blenkernel/intern/idprop.c | 4 ++-- source/blender/blenkernel/intern/object.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 8 ++++---- source/blender/blenkernel/intern/sequencer.c | 8 ++++---- 11 files changed, 33 insertions(+), 33 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 14c4b6f97ab..e23fe357141 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -248,16 +248,15 @@ Bone *get_named_bone (bArmature *arm, const char *name) } /* 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) * axis: the axis to name on * head/tail: the head/tail co-ordinate of the bone on the specified axis */ -int bone_autoside_name (char *name, int UNUSED(strip_number), short axis, float head, float tail) +int bone_autoside_name (char name[MAXBONENAME], int UNUSED(strip_number), short axis, float head, float tail) { unsigned int len; - char basename[32]={""}; - char extension[5]={""}; + char basename[MAXBONENAME]= ""; + char extension[5]= ""; len= strlen(name); if (len == 0) return 0; @@ -350,13 +349,13 @@ int bone_autoside_name (char *name, int UNUSED(strip_number), short axis, float } } } - - if ((32 - len) < strlen(extension) + 1) { /* add 1 for the '.' */ + + if ((MAXBONENAME - len) < strlen(extension) + 1) { /* add 1 for the '.' */ strncpy(name, basename, len-strlen(extension)); } - - sprintf(name, "%s.%s", basename, extension); - + + BLI_snprintf(name, MAXBONENAME, "%s.%s", basename, extension); + return 1; } diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 222d416e2f0..828f7ca0fa3 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -457,7 +457,7 @@ static int read_undosave(bContext *C, UndoElem *uel) success= BKE_read_file_from_memfile(C, &uel->memfile, NULL); /* restore */ - strcpy(G.main->name, mainstr); /* restore */ + BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */ G.fileflags= fileflags; if(success) { @@ -525,7 +525,7 @@ void BKE_write_undo(bContext *C, const char *name) success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL, NULL); - strcpy(curundo->str, tstr); + BLI_strncpy(curundo->str, tstr, sizeof(curundo->str)); } else { MemFile *prevfile=NULL; diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 228827bab68..ae4882b0eca 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -1470,7 +1470,7 @@ BoidRule *boid_new_rule(int type) rule->type = type; rule->flag |= BOIDRULE_IN_AIR|BOIDRULE_ON_LAND; - strcpy(rule->name, boidrule_type_items[type-1].name); + BLI_strncpy(rule->name, boidrule_type_items[type-1].name, sizeof(rule->name)); return rule; } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index be9e7609a64..086cd237be8 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -752,7 +752,7 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstrain bConstraintTarget *ctn = ct->next; \ if (nocopy == 0) { \ datatar= ct->tar; \ - strcpy(datasubtarget, ct->subtarget); \ + BLI_strncpy(datasubtarget, ct->subtarget, sizeof(datasubtarget)); \ con->tarspace= (char)ct->space; \ } \ \ diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 1b63e4fd5d1..2014dfe6d0a 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -348,20 +348,20 @@ void flip_side_name (char *name, const char *from_name, int strip_number) len= strlen(from_name); if(len<3) return; // we don't do names like .R or .L - strcpy(name, from_name); + BLI_strncpy(name, from_name, sizeof(name)); /* 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); + BLI_strncpy(number, index, sizeof(number)); *index= 0; len= strlen(name); } } - strcpy (prefix, name); + BLI_strncpy(prefix, name, sizeof(prefix)); #define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_') diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index ba36a826afe..469fc39be10 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -1652,7 +1652,7 @@ static void dxf_read_arc(Scene *scene, int noob) cent[2]= center[2]; dxf_get_mesh(scene, &me, &ob, noob); - strcpy(oldllay, layname); + BLI_strncpy(oldllay, layname, sizeof(oldllay)); if(ob) VECCOPY(ob->loc, cent); dxf_add_mat (ob, me, color, layname); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 1d7ce197cba..9de8af2c981 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -96,13 +96,14 @@ chtoutf8(unsigned long c, char *o) void wcs2utf8s(char *dst, wchar_t *src) { - char ch[5]; + /* NULL terminator not needed */ + char ch[4]; while(*src) { - memset(ch, 0, 5); + memset(ch, 0, sizeof(ch)); chtoutf8(*src++, ch); - strcat(dst, ch); + dst= strncat(dst, ch, sizeof(ch)); } } @@ -363,14 +364,14 @@ VFont *load_vfont(const char *name) struct TmpFont *tmpfnt; if (strcmp(name, FO_BUILTIN_NAME)==0) { - strcpy(filename, name); + BLI_strncpy(filename, name, sizeof(filename)); pf= get_builtin_packedfile(); is_builtin= 1; } else { char dir[FILE_MAXDIR]; - strcpy(dir, name); + BLI_strncpy(dir, name, sizeof(dir)); BLI_splitdirstring(dir, filename); pf= newPackedFile(NULL, name); diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 7829d9b5e0d..f8025d38f74 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -711,9 +711,9 @@ IDProperty *IDP_New(int type, IDPropertyTemplate val, const char *name) prop->len = 1; /*NULL string, has len of 1 to account for null byte.*/ } else { int stlen = strlen(st) + 1; - prop->data.pointer = MEM_callocN(stlen, "id property string 2"); + prop->data.pointer = MEM_mallocN(stlen, "id property string 2"); prop->len = prop->totallen = stlen; - strcpy(prop->data.pointer, st); + memcpy(prop->data.pointer, st, stlen); } break; } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 36350f23b6d..5d5271bba8c 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1078,7 +1078,7 @@ Object *add_object(struct Scene *scene, int type) Base *base; char name[32]; - strcpy(name, get_obdata_defname(type)); + BLI_strncpy(name, get_obdata_defname(type), sizeof(name)); ob = add_only_object(type, name); ob->data= add_obdata_from_type(type); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 84331e1b318..69699c85203 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1992,7 +1992,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) if (strncmp(filename, de->d_name, len ) == 0) { /* do we have the right prefix */ if (mode == PTCACHE_CLEAR_ALL) { pid->cache->last_exact = MIN2(pid->cache->startframe, 0); - BLI_join_dirfile(path_full, path, de->d_name); + BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); BLI_delete(path_full, 0, 0); } else { /* read the number of the file */ @@ -2006,7 +2006,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) if((mode==PTCACHE_CLEAR_BEFORE && frame < cfra) || (mode==PTCACHE_CLEAR_AFTER && frame > cfra) ) { - BLI_join_dirfile(path_full, path, de->d_name); + BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); BLI_delete(path_full, 0, 0); if(pid->cache->cached_frames && frame >=sta && frame <= end) pid->cache->cached_frames[frame-sta] = 0; @@ -2354,7 +2354,7 @@ void BKE_ptcache_remove(void) if( strcmp(de->d_name, ".")==0 || strcmp(de->d_name, "..")==0) { /* do nothing */ } else if (strstr(de->d_name, PTCACHE_EXT)) { /* do we have the right extension?*/ - BLI_join_dirfile(path_full, path, de->d_name); + BLI_join_dirfile(path_full, sizeof(path_full), path, de->d_name); BLI_delete(path_full, 0, 0); } else { rmdir = 0; /* unknown file, dont remove the dir */ @@ -2856,7 +2856,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, char *from, char *to) BLI_strncpy(num, de->d_name + (strlen(de->d_name) - 15), sizeof(num)); frame = atoi(num); - BLI_join_dirfile(old_path_full, path, de->d_name); + BLI_join_dirfile(old_path_full, sizeof(old_path_full), path, de->d_name); ptcache_filename(pid, new_path_full, frame, 1, 1); BLI_rename(old_path_full, new_path_full); } diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 6aca23b8011..8f07ed48803 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -664,7 +664,7 @@ void reload_sequence_new_file(Scene *scene, Sequence * seq, int lock_range) new_tstripdata(seq); if (ELEM3(seq->type, SEQ_SCENE, SEQ_META, SEQ_IMAGE)==0) { - BLI_join_dirfile(str, seq->strip->dir, seq->strip->stripdata->name); + BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(str, G.main->name); } @@ -1134,7 +1134,7 @@ static int seq_proxy_get_fname(SeqRenderData context, Sequence * seq, int cfra, } if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { - BLI_join_dirfile(name, dir, seq->strip->proxy->file); + BLI_join_dirfile(name, FILE_MAX, dir, seq->strip->proxy->file); /* XXX, not real length */ BLI_path_abs(name, G.main->name); return TRUE; @@ -2043,7 +2043,7 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr StripElem * s_elem = give_stripelem(seq, cfra); if (s_elem) { - BLI_join_dirfile(name, seq->strip->dir, s_elem->name); + BLI_join_dirfile(name, sizeof(name), seq->strip->dir, s_elem->name); BLI_path_abs(name, G.main->name); } @@ -2066,7 +2066,7 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr case SEQ_MOVIE: { if(seq->anim==0) { - BLI_join_dirfile(name, seq->strip->dir, seq->strip->stripdata->name); + BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(name, G.main->name); seq->anim = openanim(name, IB_rect | -- cgit v1.2.3 From 90f543ba3aa5d6ee3b436a96d648cd190f66f513 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sun, 13 Feb 2011 07:39:43 +0000 Subject: Reverting part of 34810 The changes here were breaking old rigs, for example the right eyeball in the Sintel rig (which uses the Mirror Modifier and its vertex-group mirroring functionality) --- source/blender/blenkernel/intern/deform.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 2014dfe6d0a..b90ded5c78d 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -348,20 +348,20 @@ void flip_side_name (char *name, const char *from_name, int strip_number) len= strlen(from_name); if(len<3) return; // we don't do names like .R or .L - BLI_strncpy(name, from_name, sizeof(name)); + strcpy(name, from_name); /* 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) - BLI_strncpy(number, index, sizeof(number)); + strcpy(number, index); *index= 0; len= strlen(name); } } - BLI_strncpy(prefix, name, sizeof(prefix)); + strcpy(prefix, name); #define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_') -- cgit v1.2.3 From 0955c664aa7c5fc5f0bd345c58219c40f04ab9c1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 13 Feb 2011 10:52:18 +0000 Subject: fix for warnings from Sparse static source code checker, mostly BKE/BLI and python functions. - use NULL rather then 0 where possible (makes code & function calls more readable IMHO). - set static variables and functions (exposed some unused vars/funcs). - use func(void) rather then func() for definitions. --- source/blender/blenkernel/intern/CCGSubSurf.c | 4 +- source/blender/blenkernel/intern/action.c | 12 ++-- source/blender/blenkernel/intern/anim.c | 21 +++---- source/blender/blenkernel/intern/anim_sys.c | 6 +- source/blender/blenkernel/intern/armature.c | 12 ++-- source/blender/blenkernel/intern/blender.c | 6 +- source/blender/blenkernel/intern/bmfont.c | 1 + source/blender/blenkernel/intern/brush.c | 18 +++--- source/blender/blenkernel/intern/cdderivedmesh.c | 22 ++++---- source/blender/blenkernel/intern/collision.c | 8 +-- source/blender/blenkernel/intern/constraint.c | 2 +- source/blender/blenkernel/intern/context.c | 4 +- source/blender/blenkernel/intern/curve.c | 53 +++++++++--------- source/blender/blenkernel/intern/customdata.c | 14 ++--- source/blender/blenkernel/intern/deform.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/displist.c | 20 +++---- source/blender/blenkernel/intern/effect.c | 8 +-- source/blender/blenkernel/intern/exotic.c | 9 +-- source/blender/blenkernel/intern/fcurve.c | 4 +- source/blender/blenkernel/intern/font.c | 28 +++++----- source/blender/blenkernel/intern/icons.c | 22 ++++---- source/blender/blenkernel/intern/idcode.c | 2 + source/blender/blenkernel/intern/idprop.c | 6 +- source/blender/blenkernel/intern/image.c | 10 ++-- source/blender/blenkernel/intern/image_gen.c | 2 + source/blender/blenkernel/intern/ipo.c | 2 +- source/blender/blenkernel/intern/key.c | 24 ++++---- source/blender/blenkernel/intern/lattice.c | 12 ++-- source/blender/blenkernel/intern/library.c | 18 +++--- source/blender/blenkernel/intern/material.c | 36 ++++++------ source/blender/blenkernel/intern/mball.c | 52 ++++++++--------- source/blender/blenkernel/intern/mesh.c | 38 ++++++------- source/blender/blenkernel/intern/modifier.c | 2 +- source/blender/blenkernel/intern/multires.c | 8 +-- source/blender/blenkernel/intern/nla.c | 4 +- source/blender/blenkernel/intern/node.c | 8 +-- source/blender/blenkernel/intern/object.c | 38 ++++++------- source/blender/blenkernel/intern/packedFile.c | 4 +- source/blender/blenkernel/intern/particle.c | 20 +++---- source/blender/blenkernel/intern/particle_system.c | 11 ++-- source/blender/blenkernel/intern/property.c | 4 +- source/blender/blenkernel/intern/sca.c | 14 ++--- source/blender/blenkernel/intern/screen.c | 2 +- source/blender/blenkernel/intern/seqcache.c | 28 +++++----- source/blender/blenkernel/intern/seqeffects.c | 60 ++++++++++---------- source/blender/blenkernel/intern/sequencer.c | 65 +++++++++++----------- source/blender/blenkernel/intern/shrinkwrap.c | 2 +- source/blender/blenkernel/intern/sketch.c | 4 +- source/blender/blenkernel/intern/softbody.c | 12 ++-- source/blender/blenkernel/intern/sound.c | 6 +- source/blender/blenkernel/intern/suggestions.c | 16 +++--- source/blender/blenkernel/intern/texture.c | 62 ++++++++++----------- source/blender/blenkernel/intern/unit.c | 8 +-- source/blender/blenkernel/intern/world.c | 11 ++-- 55 files changed, 437 insertions(+), 432 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 35ba8caedb0..8c265a1f8c9 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -397,7 +397,7 @@ static CCGEdge *_vert_findEdgeTo(CCGVert *v, CCGVert *vQ) { (e->v1==v && e->v0==vQ)) return e; } - return 0; + return NULL; } static int _vert_isBoundary(CCGVert *v) { int i; @@ -599,7 +599,7 @@ static CCG_INLINE void *_face_getIFCoEdge(CCGFace *f, CCGEdge *e, int lvl, int e static float *_face_getIFNoEdge(CCGFace *f, CCGEdge *e, int lvl, int eX, int eY, int levels, int dataSize, int normalDataOffset) { return (float*) ((byte*) _face_getIFCoEdge(f, e, lvl, eX, eY, levels, dataSize) + normalDataOffset); } -void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, int levels, int dataSize) { +static void _face_calcIFNo(CCGFace *f, int lvl, int S, int x, int y, float *no, int levels, int dataSize) { float *a = _face_getIFCo(f, lvl, S, x+0, y+0, levels, dataSize); float *b = _face_getIFCo(f, lvl, S, x+1, y+0, levels, dataSize); float *c = _face_getIFCo(f, lvl, S, x+1, y+1, levels, dataSize); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 3bfdbdc4fc9..328f2ccdc75 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -93,11 +93,11 @@ void make_local_action(bAction *act) bAction *actn; int local=0, lib=0; - if (act->id.lib==0) return; + if (act->id.lib==NULL) return; if (act->id.us==1) { - act->id.lib= 0; + act->id.lib= NULL; act->id.flag= LIB_LOCAL; - new_id(0, (ID *)act, 0); + new_id(NULL, (ID *)act, NULL); return; } @@ -113,10 +113,10 @@ void make_local_action(bAction *act) #endif if(local && lib==0) { - act->id.lib= 0; + act->id.lib= NULL; act->id.flag= LIB_LOCAL; //make_local_action_channels(act); - new_id(0, (ID *)act, 0); + new_id(NULL, (ID *)act, NULL); } else if(local && lib) { actn= copy_action(act); @@ -1144,7 +1144,7 @@ void what_does_obaction (Scene *UNUSED(scene), Object *ob, Object *workob, bPose animsys_evaluate_action_group(&id_ptr, act, agrp, NULL, cframe); } else { - AnimData adt= {0}; + AnimData adt= {NULL}; /* init animdata, and attach to workob */ workob->adt= &adt; diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 2c52e0b0c49..8fdfca33efb 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -64,6 +64,7 @@ #include "BKE_scene.h" #include "BKE_utildefines.h" #include "BKE_depsgraph.h" +#include "BKE_anim.h" // XXX bad level call... @@ -1159,12 +1160,12 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level, int animated) { GroupObject *go; - Object *ob=0, **oblist=0, obcopy, *obcopylist=0; + Object *ob=NULL, **oblist=NULL, obcopy, *obcopylist=NULL; DupliObject *dob; ParticleDupliWeight *dw; ParticleSettings *part; ParticleData *pa; - ChildParticle *cpa=0; + ChildParticle *cpa=NULL; ParticleKey state; ParticleCacheKey *cache; float ctime, pa_time, scale = 1.0f; @@ -1175,14 +1176,14 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p int no_draw_flag = PARS_UNEXIST; - if(psys==0) return; + if(psys==NULL) return; /* simple preventing of too deep nested groups */ if(level>MAX_DUPLI_RECUR) return; part=psys->part; - if(part==0) + if(part==NULL) return; if(!psys_check_enabled(par, psys)) @@ -1199,7 +1200,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p BLI_srandom(31415926 + psys->seed); if((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { - ParticleSimulationData sim= {0}; + ParticleSimulationData sim= {NULL}; sim.scene= scene; sim.ob= par; sim.psys= psys; @@ -1298,7 +1299,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p pa_num = a; pa_time = psys->particles[cpa->parent].time; - size = psys_get_child_size(psys, cpa, ctime, 0); + size = psys_get_child_size(psys, cpa, ctime, NULL); } /* some hair paths might be non-existent so they can't be used for duplication */ @@ -1329,11 +1330,11 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p /* hair we handle separate and compute transform based on hair keys */ if(a < totpart) { cache = psys->pathcache[a]; - psys_get_dupli_path_transform(&sim, pa, 0, cache, pamat, &scale); + psys_get_dupli_path_transform(&sim, pa, NULL, cache, pamat, &scale); } else { cache = psys->childcache[a-totpart]; - psys_get_dupli_path_transform(&sim, 0, cpa, cache, pamat, &scale); + psys_get_dupli_path_transform(&sim, NULL, cpa, cache, pamat, &scale); } VECCOPY(pamat[3], cache->co); @@ -1449,7 +1450,7 @@ static Object *find_family_object(Object **obar, char *family, char ch) static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, int animated) { - Object *ob, *obar[256]= {0}; + Object *ob, *obar[256]= {NULL}; Curve *cu; struct chartrans *ct, *chartransdata; float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof; @@ -1463,7 +1464,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i /* in par the family name is stored, use this to find the other objects */ chartransdata= BKE_text_to_curve(scene, par, FO_DUPLI); - if(chartransdata==0) return; + if(chartransdata==NULL) return; cu= par->data; slen= strlen(cu->str); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index e46c1179111..499a1ac6ed8 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -809,7 +809,7 @@ KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[] eq_id= 0; /* path */ - if ((ksp->rna_path==0) || strcmp(rna_path, ksp->rna_path)) + if ((ksp->rna_path==NULL) || strcmp(rna_path, ksp->rna_path)) eq_path= 0; /* index - need to compare whole-array setting too... */ @@ -1856,7 +1856,7 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) /* if there are strips, evaluate action as per NLA rules */ if ((has_strips) || (adt->actstrip)) { /* make dummy NLA strip, and add that to the stack */ - NlaStrip dummy_strip= {0}; + NlaStrip dummy_strip= {NULL}; ListBase dummy_trackslist; dummy_trackslist.first= dummy_trackslist.last= &dummy_strip; @@ -1915,11 +1915,13 @@ static void animsys_evaluate_nla (PointerRNA *ptr, AnimData *adt, float ctime) /* Clear all overides */ /* Add or get existing Override for given setting */ +#if 0 AnimOverride *BKE_animsys_validate_override (PointerRNA *UNUSED(ptr), char *UNUSED(path), int UNUSED(array_index)) { // FIXME: need to define how to get overrides return NULL; } +#endif /* -------------------- */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index e23fe357141..cc01438fd5d 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -136,19 +136,19 @@ void make_local_armature(bArmature *arm) Object *ob; bArmature *newArm; - if (arm->id.lib==0) + if (arm->id.lib==NULL) return; if (arm->id.us==1) { - arm->id.lib= 0; + arm->id.lib= NULL; arm->id.flag= LIB_LOCAL; - new_id(0, (ID*)arm, 0); + new_id(NULL, (ID*)arm, NULL); return; } if(local && lib==0) { - arm->id.lib= 0; + arm->id.lib= NULL; arm->id.flag= LIB_LOCAL; - new_id(0, (ID *)arm, 0); + new_id(NULL, (ID *)arm, NULL); } else if(local && lib) { newArm= copy_armature(arm); @@ -158,7 +158,7 @@ void make_local_armature(bArmature *arm) while(ob) { if(ob->data==arm) { - if(ob->id.lib==0) { + if(ob->id.lib==NULL) { ob->data= newArm; newArm->id.us++; arm->id.us--; diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 828f7ca0fa3..e34b4bef8d4 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -88,10 +88,10 @@ Global G; UserDef U; -ListBase WMlist= {NULL, NULL}; +/* ListBase = {NULL, NULL}; */ short ENDIAN_ORDER; -char versionstr[48]= ""; +static char versionstr[48]= ""; /* ********** free ********** */ @@ -350,7 +350,7 @@ int BKE_read_file(bContext *C, const char *dir, ReportList *reports) BlendFileData *bfd; int retval= 1; - if(strstr(dir, BLENDER_STARTUP_FILE)==0) /* dont print user-pref loading */ + if(strstr(dir, BLENDER_STARTUP_FILE)==NULL) /* dont print user-pref loading */ printf("read blend: %s\n", dir); bfd= BLO_read_from_file(dir, reports); diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index e2a6c04450b..aa0669903c5 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -54,6 +54,7 @@ #include "BKE_global.h" #include "IMB_imbuf_types.h" +#include "BKE_bmfont.h" #include "BKE_bmfont_types.h" void printfGlyph(bmGlyph * glyph) diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index b1931ebe0a7..4ad3b8bb3cf 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -186,13 +186,13 @@ void make_local_brush(Brush *brush) Scene *scene; int local= 0, lib= 0; - if(brush->id.lib==0) return; + if(brush->id.lib==NULL) return; if(brush->clone.image) { /* special case: ima always local immediately */ - brush->clone.image->id.lib= 0; + brush->clone.image->id.lib= NULL; brush->clone.image->id.flag= LIB_LOCAL; - new_id(0, (ID *)brush->clone.image, 0); + new_id(NULL, (ID *)brush->clone.image, NULL); } for(scene= G.main->scene.first; scene; scene=scene->id.next) @@ -202,9 +202,9 @@ void make_local_brush(Brush *brush) } if(local && lib==0) { - brush->id.lib= 0; + brush->id.lib= NULL; brush->id.flag= LIB_LOCAL; - new_id(0, (ID *)brush, 0); + new_id(NULL, (ID *)brush, NULL); /* enable fake user by default */ if (!(brush->id.flag & LIB_FAKEUSER)) { @@ -219,7 +219,7 @@ void make_local_brush(Brush *brush) for(scene= G.main->scene.first; scene; scene=scene->id.next) if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) - if(scene->id.lib==0) { + if(scene->id.lib==NULL) { paint_brush_set(&scene->toolsettings->imapaint.paint, brushn); brushn->id.us++; brush->id.us--; @@ -227,10 +227,10 @@ void make_local_brush(Brush *brush) } } -void brush_debug_print_state(Brush *br) +static void brush_debug_print_state(Brush *br) { /* create a fake brush and set it to the defaults */ - Brush def= {{0}}; + Brush def= {{NULL}}; brush_set_defaults(&def); #define BR_TEST(field, t) \ @@ -424,7 +424,7 @@ int brush_texture_set_nr(Brush *brush, int nr) id= (ID *)brush->mtex.tex; idtest= (ID*)BLI_findlink(&G.main->tex, nr-1); - if(idtest==0) { /* new tex */ + if(idtest==NULL) { /* new tex */ if(id) idtest= (ID *)copy_texture((Tex *)id); else idtest= (ID *)add_texture("Tex"); idtest->us--; diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 0006e5bfa38..abf2257877b 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -729,7 +729,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, GPU_vertex_setup( dm ); GPU_normal_setup( dm ); GPU_uv_setup( dm ); - if( col != 0 ) { + if( col != NULL ) { /*if( realcol && dm->drawObject->colType == CD_TEXTURE_MCOL ) { col = 0; } else if( mcol && dm->drawObject->colType == CD_MCOL ) { @@ -983,7 +983,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo glShadeModel(GL_SMOOTH); - if( GPU_buffer_legacy(dm) || setDrawOptions != 0 ) { + if( GPU_buffer_legacy(dm) || setDrawOptions != NULL ) { DEBUG_VBO( "Using legacy code. cdDM_drawMappedFacesGLSL\n" ); memset(&attribs, 0, sizeof(attribs)); @@ -1086,8 +1086,8 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo glEnd(); } else { - GPUBuffer *buffer = 0; - char *varray = 0; + GPUBuffer *buffer = NULL; + char *varray = NULL; int numdata = 0, elementsize = 0, offset; int start = 0, numfaces = 0, prevdraw = 0, curface = 0; int i; @@ -1124,9 +1124,9 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo if( numdata != 0 ) { - GPU_buffer_free(buffer,0); + GPU_buffer_free(buffer, NULL); - buffer = 0; + buffer = NULL; } } @@ -1164,16 +1164,16 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } if( numdata != 0 ) { elementsize = GPU_attrib_element_size( datatypes, numdata ); - buffer = GPU_buffer_alloc( elementsize*dm->drawObject->nelements, 0 ); - if( buffer == 0 ) { + buffer = GPU_buffer_alloc( elementsize*dm->drawObject->nelements, NULL ); + if( buffer == NULL ) { GPU_buffer_unbind(); dm->drawObject->legacy = 1; return; } varray = GPU_buffer_lock_stream(buffer); - if( varray == 0 ) { + if( varray == NULL ) { GPU_buffer_unbind(); - GPU_buffer_free(buffer, 0); + GPU_buffer_free(buffer, NULL); dm->drawObject->legacy = 1; return; } @@ -1312,7 +1312,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } GPU_buffer_unbind(); } - GPU_buffer_free( buffer, 0 ); + GPU_buffer_free( buffer, NULL ); } glShadeModel(GL_FLAT); diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 8cdfd60b9a7..02b3de83ee1 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -164,8 +164,8 @@ Collision modifier code end */ #define mySWAP(a,b) do { double tmp = b ; b = a ; a = tmp ; } while(0) - -int +#if 0 /* UNUSED */ +static int gsl_poly_solve_cubic (double a, double b, double c, double *x0, double *x1, double *x2) { @@ -255,7 +255,7 @@ gsl_poly_solve_cubic (double a, double b, double c, * * copied from GSL */ -int +static int gsl_poly_solve_quadratic (double a, double b, double c, double *x0, double *x1) { @@ -313,7 +313,7 @@ gsl_poly_solve_quadratic (double a, double b, double c, return 0; } } - +#endif /* UNUSED */ diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 086cd237be8..b3f83019ff1 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -3469,7 +3469,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr BVHTreeRayHit hit; BVHTreeNearest nearest; - BVHTreeFromMesh treeData= {0}; + BVHTreeFromMesh treeData= {NULL}; nearest.index = -1; nearest.dist = FLT_MAX; diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 09321ddea81..58a7944f78b 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -85,7 +85,7 @@ struct bContext { /* context */ -bContext *CTX_create() +bContext *CTX_create(void) { bContext *C; @@ -788,7 +788,7 @@ static const char *data_mode_strings[] = { "texturepaint", "particlemode", "objectmode", - 0 + NULL }; const char *CTX_data_mode_string(const bContext *C) { diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 2678b077b66..5dc62f2c7af 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -174,7 +174,7 @@ Curve *copy_curve(Curve *cu) int a; cun= copy_libblock(cu); - cun->nurb.first= cun->nurb.last= 0; + cun->nurb.first= cun->nurb.last= NULL; duplicateNurblist( &(cun->nurb), &(cu->nurb)); cun->mat= MEM_dupallocN(cu->mat); @@ -190,9 +190,9 @@ Curve *copy_curve(Curve *cu) cun->key= copy_key(cu->key); if(cun->key) cun->key->from= (ID *)cun; - cun->disp.first= cun->disp.last= 0; - cun->bev.first= cun->bev.last= 0; - cun->path= 0; + cun->disp.first= cun->disp.last= NULL; + cun->bev.first= cun->bev.last= NULL; + cun->path= NULL; cun->editnurb= NULL; cun->editfont= NULL; @@ -212,7 +212,7 @@ Curve *copy_curve(Curve *cu) void make_local_curve(Curve *cu) { - Object *ob = 0; + Object *ob = NULL; Curve *cun; int local=0, lib=0; @@ -221,7 +221,7 @@ void make_local_curve(Curve *cu) * - mixed: do a copy */ - if(cu->id.lib==0) return; + if(cu->id.lib==NULL) return; if(cu->vfont) cu->vfont->id.lib= NULL; if(cu->vfontb) cu->vfontb->id.lib= NULL; @@ -229,9 +229,9 @@ void make_local_curve(Curve *cu) if(cu->vfontbi) cu->vfontbi->id.lib= NULL; if(cu->id.us==1) { - cu->id.lib= 0; + cu->id.lib= NULL; cu->id.flag= LIB_LOCAL; - new_id(0, (ID *)cu, 0); + new_id(NULL, (ID *)cu, NULL); return; } @@ -245,9 +245,9 @@ void make_local_curve(Curve *cu) } if(local && lib==0) { - cu->id.lib= 0; + cu->id.lib= NULL; cu->id.flag= LIB_LOCAL; - new_id(0, (ID *)cu, 0); + new_id(NULL, (ID *)cu, NULL); } else if(local && lib) { cun= copy_curve(cu); @@ -257,7 +257,7 @@ void make_local_curve(Curve *cu) while(ob) { if(ob->data==cu) { - if(ob->id.lib==0) { + if(ob->id.lib==NULL) { ob->data= cun; cun->id.us++; cu->id.us--; @@ -381,12 +381,12 @@ int count_curveverts_without_handles(ListBase *nurb) void freeNurb(Nurb *nu) { - if(nu==0) return; + if(nu==NULL) return; if(nu->bezt) MEM_freeN(nu->bezt); - nu->bezt= 0; + nu->bezt= NULL; if(nu->bp) MEM_freeN(nu->bp); - nu->bp= 0; + nu->bp= NULL; if(nu->knotsu) MEM_freeN(nu->knotsu); nu->knotsu= NULL; if(nu->knotsv) MEM_freeN(nu->knotsv); @@ -402,7 +402,7 @@ void freeNurblist(ListBase *lb) { Nurb *nu, *next; - if(lb==0) return; + if(lb==NULL) return; nu= lb->first; while(nu) { @@ -410,7 +410,7 @@ void freeNurblist(ListBase *lb) freeNurb(nu); nu= next; } - lb->first= lb->last= 0; + lb->first= lb->last= NULL; } Nurb *duplicateNurb(Nurb *nu) @@ -419,7 +419,7 @@ Nurb *duplicateNurb(Nurb *nu) int len; newnu= (Nurb*)MEM_mallocN(sizeof(Nurb),"duplicateNurb"); - if(newnu==0) return 0; + if(newnu==NULL) return NULL; memcpy(newnu, nu, sizeof(Nurb)); if(nu->bezt) { @@ -615,7 +615,7 @@ static void makecyclicknots(float *knots, short pnts, short order) { int a, b, order2, c; - if(knots==0) return; + if(knots==NULL) return; order2=order-1; @@ -918,7 +918,7 @@ void makeNurbcurve(Nurb *nu, float *coord_array, float *tilt_array, float *radiu if(nu->knotsu==NULL) return; if(nu->orderu>nu->pntsu) return; - if(coord_array==0) return; + if(coord_array==NULL) return; /* allocate and initialize */ len= nu->pntsu; @@ -1269,7 +1269,7 @@ void makebevelcurve(Scene *scene, Object *ob, ListBase *disp, int forRender) dl= bevdisp.first; } else { dl= cu->bevobj->disp.first; - if(dl==0) { + if(dl==NULL) { makeDispListCurveTypes(scene, cu->bevobj, 0); dl= cu->bevobj->disp.first; } @@ -1811,8 +1811,6 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) int nr; float q[4]; - float cross_tmp[3]; - bevel_list_calc_bisect(bl); bevp2= (BevPoint *)(bl+1); @@ -1829,6 +1827,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) float angle= angle_normalized_v3v3(bevp0->dir, bevp1->dir); if(angle > 0.0f) { /* otherwise we can keep as is */ + float cross_tmp[3]; cross_v3_v3v3(cross_tmp, bevp0->dir, bevp1->dir); axis_angle_to_quat(q, cross_tmp, angle); mul_qt_qtqt(bevp1->quat, q, bevp0->quat); @@ -2426,7 +2425,7 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) p2= bezt->vec[1]; - if(prev==0) { + if(prev==NULL) { p3= next->vec[1]; pt[0]= 2*p2[0]- p3[0]; pt[1]= 2*p2[1]- p3[1]; @@ -2435,7 +2434,7 @@ void calchandleNurb(BezTriple *bezt, BezTriple *prev, BezTriple *next, int mode) } else p1= prev->vec[1]; - if(next==0) { + if(next==NULL) { pt[0]= 2*p2[0]- p1[0]; pt[1]= 2*p2[1]- p1[1]; pt[2]= 2*p2[2]- p1[2]; @@ -2616,7 +2615,7 @@ void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */ a= nu->pntsu; bezt= nu->bezt; if(nu->flagu & CU_NURB_CYCLIC) prev= bezt+(a-1); - else prev= 0; + else prev= NULL; next= bezt+1; while(a--) { @@ -2624,7 +2623,7 @@ void calchandlesNurb(Nurb *nu) /* first, if needed, set handle flags */ prev= bezt; if(a==1) { if(nu->flagu & CU_NURB_CYCLIC) next= nu->bezt; - else next= 0; + else next= NULL; } else next++; @@ -2683,7 +2682,7 @@ void autocalchandlesNurb(Nurb *nu, int flag) BezTriple *bezt2, *bezt1, *bezt0; int i, align, leftsmall, rightsmall; - if(nu==0 || nu->bezt==0) return; + if(nu==NULL || nu->bezt==NULL) return; bezt2 = nu->bezt; bezt1 = bezt2 + (nu->pntsu-1); diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 0ed479b899a..7788f9f28a2 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -469,19 +469,19 @@ static void layerInterp_mdisps(void **sources, float *UNUSED(weights), vindex[x] = y; for(i = 0; i < 2; i++) { - float sw[4][4] = {{0}}; + float sw_m4[4][4] = {{0}}; int a = 7 & ~(1 << vindex[i*2] | 1 << vindex[i*2+1]); - sw[0][vindex[i*2+1]] = 1; - sw[1][vindex[i*2]] = 1; + sw_m4[0][vindex[i*2+1]] = 1; + sw_m4[1][vindex[i*2]] = 1; for(x = 0; x < 3; x++) if(a & (1 << x)) - sw[2][x] = 1; + sw_m4[2][x] = 1; tris[i] = *((MDisps*)sources[i]); tris[i].disps = MEM_dupallocN(tris[i].disps); - layerInterp_mdisps(&sources[i], NULL, (float*)sw, 1, &tris[i]); + layerInterp_mdisps(&sources[i], NULL, (float*)sw_m4, 1, &tris[i]); } mdisp_join_tris(d, &tris[0], &tris[1]); @@ -803,7 +803,7 @@ static void layerDefault_mcol(void *data, int count) -const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { +static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { {sizeof(MVert), "MVert", 1, NULL, NULL, NULL, NULL, NULL, NULL}, {sizeof(MSticky), "MSticky", 1, NULL, NULL, NULL, layerInterp_msticky, NULL, NULL}, @@ -842,7 +842,7 @@ const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL} }; -const char *LAYERTYPENAMES[CD_NUMTYPES] = { +static const char *LAYERTYPENAMES[CD_NUMTYPES] = { /* 0-4 */ "CDMVert", "CDMSticky", "CDMDeformVert", "CDMEdge", "CDMFace", /* 5-9 */ "CDMTFace", "CDMCol", "CDOrigIndex", "CDNormal", "CDFlags", /* 10-14 */ "CDMFloatProperty", "CDMIntProperty","CDMStringProperty", "CDOrigSpace", "CDOrco", diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index b90ded5c78d..7f51cfdc8b6 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -50,7 +50,7 @@ void defgroup_copy_list (ListBase *outbase, ListBase *inbase) { bDeformGroup *defgroup, *defgroupn; - outbase->first= outbase->last= 0; + outbase->first= outbase->last= NULL; for (defgroup = inbase->first; defgroup; defgroup=defgroup->next){ defgroupn= defgroup_duplicate(defgroup); diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 07a47f84af5..d102a83d69f 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -278,7 +278,7 @@ int queue_count(struct DagNodeQueue *queue){ } -DagForest * dag_init() +DagForest *dag_init(void) { DagForest *forest; /* use callocN to init all zero */ diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 3bb62f817cd..837c3bd8356 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -121,7 +121,7 @@ DispList *find_displist(ListBase *lb, int type) dl= dl->next; } - return 0; + return NULL; } int displist_has_faces(ListBase *lb) @@ -930,13 +930,13 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) { EditVert *eve, *v1, *vlast; EditFace *efa; - DispList *dlnew=0, *dl; + DispList *dlnew=NULL, *dl; float *f1; int colnr=0, charidx=0, cont=1, tot, a, *index, nextcol= 0; intptr_t totvert; - if(dispbase==0) return; - if(dispbase->first==0) return; + if(dispbase==NULL) return; + if(dispbase->first==NULL) return; while(cont) { cont= 0; @@ -953,7 +953,7 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) /* make editverts and edges */ f1= dl->verts; a= dl->nr; - eve= v1= 0; + eve= v1= NULL; while(a--) { vlast= eve; @@ -961,14 +961,14 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) eve= BLI_addfillvert(f1); totvert++; - if(vlast==0) v1= eve; + if(vlast==NULL) v1= eve; else { BLI_addfilledge(vlast, eve); } f1+=3; } - if(eve!=0 && v1!=0) { + if(eve!=NULL && v1!=NULL) { BLI_addfilledge(eve, v1); } } else if (colnrcol) { @@ -1058,7 +1058,7 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) float *fp, *fp1; int a, dpoly; - front.first= front.last= back.first= back.last= 0; + front.first= front.last= back.first= back.last= NULL; dl= dispbase->first; while(dl) { @@ -1944,7 +1944,7 @@ void imagestodisplist(void) /* this is confusing, there's also min_max_object, appplying the obmat... */ static void boundbox_displist(Object *ob) { - BoundBox *bb=0; + BoundBox *bb=NULL; float min[3], max[3]; DispList *dl; float *vert; @@ -1956,7 +1956,7 @@ static void boundbox_displist(Object *ob) Curve *cu= ob->data; int doit= 0; - if(cu->bb==0) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); + if(cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); bb= cu->bb; dl= ob->disp.first; diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 43ca7435712..ddfc58b7491 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -166,7 +166,7 @@ PartEff *give_parteff(Object *ob) if(paf->type==EFF_PARTICLE) return paf; paf= paf->next; } - return 0; + return NULL; } void free_effect(Effect *eff) @@ -636,7 +636,7 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin if(eff->psys == point->psys && *efd->index == point->index) ; else { - ParticleSimulationData sim= {0}; + ParticleSimulationData sim= {NULL}; sim.scene= eff->scene; sim.ob= eff->ob; sim.psys= eff->psys; @@ -781,7 +781,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP if(!eff->pd->tex) return; - result[0].nor = result[1].nor = result[2].nor = result[3].nor = 0; + result[0].nor = result[1].nor = result[2].nor = result[3].nor = NULL; strength= eff->pd->f_strength * efd->falloff; @@ -845,7 +845,7 @@ static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedP add_v3_v3(total_force, force); } -void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force) +static void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force) { PartDeflect *pd = eff->pd; RNG *rng = pd->rng; diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 469fc39be10..e7596001400 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -513,9 +513,6 @@ int BKE_read_exotic(Scene *scene, const char *name) /* ************************ WRITE ************************** */ - -char temp_dir[160]= {0, 0}; - static void write_vert_stl(Object *ob, MVert *verts, int index, FILE *fpSTL) { float vert[3]; @@ -588,7 +585,6 @@ void write_stl(Scene *scene, char *str) BKE_reportf(reports, RPT_ERROR, "Can't open file: %s.", strerror(errno)); return; } - strcpy(temp_dir, str); //XXX waitcursor(1); @@ -874,7 +870,6 @@ void write_dxf(struct Scene *scene, char *str) //XXX error("Can't write file"); return; } - strcpy(temp_dir, str); //XXX waitcursor(1); @@ -1134,7 +1129,7 @@ static void dxf_add_mat (Object *ob, Mesh *me, float color[3], char *layer) ma= G.main->mat.first; while(ma) { - if(ma->mtex[0]==0) { + if(ma->mtex[0]==NULL) { if(color[0]==ma->r && color[1]==ma->g && color[2]==ma->b) { me->mat[0]= ma; ma->id.us++; @@ -1143,7 +1138,7 @@ static void dxf_add_mat (Object *ob, Mesh *me, float color[3], char *layer) } ma= ma->id.next; } - if(ma==0) { + if(ma==NULL) { ma= add_material("ext"); me->mat[0]= ma; ma->r= color[0]; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index ef1ac582c1e..fc5aecb5def 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1202,7 +1202,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) /* ......... */ /* Table of Driver Varaiable Type Info Data */ -DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = { +static DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = { BEGIN_DVAR_TYPEDEF(DVAR_TYPE_SINGLE_PROP) dvar_eval_singleProp, /* eval callback */ 1, /* number of targets used */ @@ -1233,7 +1233,7 @@ DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = { }; /* Get driver variable typeinfo */ -DriverVarTypeInfo *get_dvar_typeinfo (int type) +static DriverVarTypeInfo *get_dvar_typeinfo (int type) { /* check if valid type */ if ((type >= 0) && (type < MAX_DVAR_TYPES)) diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 9de8af2c981..bf0427e4fee 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -208,7 +208,7 @@ int utf8towchar(wchar_t *w, char *c) /* The vfont code */ void free_vfont(struct VFont *vf) { - if (vf == 0) return; + if (vf == NULL) return; if (vf->data) { while(vf->data->characters.first) @@ -476,7 +476,7 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i nu2->flagu = CU_NURB_CYCLIC; bp = (BPoint*)MEM_callocN(4 * sizeof(BPoint),"underline_bp"); - if (bp == 0){ + if (bp == NULL){ MEM_freeN(nu2); return; } @@ -544,10 +544,10 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float bezt1 = nu1->bezt; if (bezt1){ nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb),"duplichar_nurb"); - if (nu2 == 0) break; + if (nu2 == NULL) break; memcpy(nu2, nu1, sizeof(struct Nurb)); nu2->resolu= cu->resolu; - nu2->bp = 0; + nu2->bp = NULL; nu2->knotsu = nu2->knotsv = NULL; nu2->flag= CU_SMOOTH; nu2->charidx = charidx; @@ -562,7 +562,7 @@ static void buildchar(Curve *cu, unsigned long character, CharInfo *info, float i = nu2->pntsu; bezt2 = (BezTriple*)MEM_mallocN(i * sizeof(BezTriple),"duplichar_bezt2"); - if (bezt2 == 0){ + if (bezt2 == NULL){ MEM_freeN(nu2); break; } @@ -686,14 +686,14 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) /* renark: do calculations including the trailing '\0' of a string because the cursor can be at that location */ - if(ob->type!=OB_FONT) return 0; + if(ob->type!=OB_FONT) return NULL; // Set font data cu= (Curve *) ob->data; vfont= cu->vfont; - if(cu->str == NULL) return 0; - if(vfont == NULL) return 0; + if(cu->str == NULL) return NULL; + if(vfont == NULL) return NULL; // Create unicode string utf8len = utf8slen(cu->str); @@ -723,7 +723,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) if(!vfd) { if(mem) MEM_freeN(mem); - return 0; + return NULL; } /* calc offset and rotation of each char */ @@ -787,11 +787,11 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) che= find_vfont_char(vfd, ascii); /* No VFont found */ - if (vfont==0) { + if (vfont==NULL) { if(mem) MEM_freeN(mem); MEM_freeN(chartransdata); - return 0; + return NULL; } if (vfont != oldvfont) { @@ -804,7 +804,7 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) if(mem) MEM_freeN(mem); MEM_freeN(chartransdata); - return 0; + return NULL; } twidth = char_width(cu, che, info); @@ -1219,7 +1219,5 @@ struct chartrans *BKE_text_to_curve(Scene *scene, Object *ob, int mode) MEM_freeN(mem); MEM_freeN(chartransdata); - return 0; + return NULL; } - - diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index 1df272fad30..b575305171a 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -106,14 +106,14 @@ void BKE_icons_init(int first_dyn_id) gIcons = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "icons_init gh"); } -void BKE_icons_free() +void BKE_icons_free(void) { if(gIcons) - BLI_ghash_free(gIcons, 0, icon_free); + BLI_ghash_free(gIcons, NULL, icon_free); gIcons = NULL; } -struct PreviewImage* BKE_previewimg_create() +struct PreviewImage* BKE_previewimg_create(void) { PreviewImage* prv_img = NULL; int i; @@ -219,7 +219,7 @@ PreviewImage* BKE_previewimg_get(ID *id) void BKE_icon_changed(int id) { - Icon* icon = 0; + Icon* icon = NULL; if (!id || G.background) return; @@ -242,7 +242,7 @@ void BKE_icon_changed(int id) int BKE_icon_getid(struct ID* id) { - Icon* new_icon = 0; + Icon* new_icon = NULL; if (!id || G.background) return 0; @@ -263,8 +263,8 @@ int BKE_icon_getid(struct ID* id) new_icon->type = GS(id->name); /* next two lines make sure image gets created */ - new_icon->drawinfo = 0; - new_icon->drawinfo_free = 0; + new_icon->drawinfo = NULL; + new_icon->drawinfo_free = NULL; BLI_ghash_insert(gIcons, SET_INT_IN_POINTER(id->icon_id), new_icon); @@ -273,13 +273,13 @@ int BKE_icon_getid(struct ID* id) Icon* BKE_icon_get(int icon_id) { - Icon* icon = 0; + Icon* icon = NULL; icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id)); if (!icon) { printf("BKE_icon_get: Internal error, no icon for icon ID: %d\n", icon_id); - return 0; + return NULL; } return icon; @@ -287,7 +287,7 @@ Icon* BKE_icon_get(int icon_id) void BKE_icon_set(int icon_id, struct Icon* icon) { - Icon* old_icon = 0; + Icon* old_icon = NULL; old_icon = BLI_ghash_lookup(gIcons, SET_INT_IN_POINTER(icon_id)); @@ -305,6 +305,6 @@ void BKE_icon_delete(struct ID* id) if (!id->icon_id) return; /* no icon defined for library object */ - BLI_ghash_remove(gIcons, SET_INT_IN_POINTER(id->icon_id), 0, icon_free); + BLI_ghash_remove(gIcons, SET_INT_IN_POINTER(id->icon_id), NULL, icon_free); id->icon_id = 0; } diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index 359603e9a50..17f7dd06e29 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -33,6 +33,8 @@ #include "DNA_ID.h" +#include "BKE_idcode.h" + typedef struct { unsigned short code; const char *name, *plural; diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index f8025d38f74..97fbcce1aec 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -266,7 +266,7 @@ void IDP_FreeArray(IDProperty *prop) return newp; } -IDProperty *IDP_CopyArray(IDProperty *prop) +static IDProperty *IDP_CopyArray(IDProperty *prop) { IDProperty *newp = idp_generic_copy(prop); @@ -328,7 +328,7 @@ IDProperty *IDP_NewString(const char *st, const char *name, int maxlen) return prop; } -IDProperty *IDP_CopyString(IDProperty *prop) +static IDProperty *IDP_CopyString(IDProperty *prop) { IDProperty *newp = idp_generic_copy(prop); @@ -402,7 +402,7 @@ void IDP_UnlinkID(IDProperty *prop) /*-------- Group Functions -------*/ /*checks if a property with the same name as prop exists, and if so replaces it.*/ -IDProperty *IDP_CopyGroup(IDProperty *prop) +static IDProperty *IDP_CopyGroup(IDProperty *prop) { IDProperty *newp = idp_generic_copy(prop), *link; newp->len = prop->len; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 4092abb07d4..64327b2005d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -100,7 +100,7 @@ static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ { struct ImBuf * tbuf1, * tbuf2; - if (ibuf == 0) return; + if (ibuf == NULL) return; if (ibuf->flags & IB_fields) return; ibuf->flags |= IB_fields; @@ -128,7 +128,7 @@ static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ { struct ImBuf * tbuf1, * tbuf2; - if (ibuf == 0) return; + if (ibuf == NULL) return; if (ibuf->flags & IB_fields) return; ibuf->flags |= IB_fields; @@ -514,7 +514,7 @@ static void tag_all_images_time() } #endif -void free_old_images() +void free_old_images(void) { Image *ima; static int lasttime = 0; @@ -1359,7 +1359,7 @@ struct anim *openanim(char *name, int flags) struct ImBuf *ibuf; anim = IMB_open_anim(name, flags); - if (anim == NULL) return(0); + if (anim == NULL) return NULL; ibuf = IMB_anim_absolute(anim, 0); if (ibuf == NULL) { @@ -1368,7 +1368,7 @@ struct anim *openanim(char *name, int flags) else printf("anim file doesn't exist: %s\n", name); IMB_free_anim(anim); - return(0); + return NULL; } IMB_freeImBuf(ibuf); diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index a2d41920217..c21e347d6d8 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -25,6 +25,8 @@ #include #include + +#include "BKE_image.h" #include "BLI_math_color.h" #include "BLF_api.h" diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 41639a619b3..329058b3115 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -62,7 +62,7 @@ #include "BLI_utildefines.h" - +#include "BKE_ipo.h" #include "BKE_animsys.h" #include "BKE_action.h" #include "BKE_fcurve.h" diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index a3c8ea0c194..3681dc910cd 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -150,7 +150,7 @@ Key *copy_key(Key *key) Key *keyn; KeyBlock *kbn, *kb; - if(key==0) return 0; + if(key==NULL) return NULL; keyn= copy_libblock(key); @@ -177,10 +177,10 @@ void make_local_key(Key *key) * - only local users: set flag * - mixed: make copy */ - if(key==0) return; + if(key==NULL) return; - key->id.lib= 0; - new_id(0, (ID *)key, 0); + key->id.lib= NULL; + new_id(NULL, (ID *)key, NULL); } /* Sort shape keys and Ipo curves after a change. This assumes that at most @@ -365,14 +365,14 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl) /* if(fac<0.0 || fac>1.0) return 1; */ - if(k1->next==0) return 1; + if(k1->next==NULL) return 1; if(cycl) { /* pre-sort */ k[2]= k1->next; k[3]= k[2]->next; - if(k[3]==0) k[3]=k1; + if(k[3]==NULL) k[3]=k1; while(k1) { - if(k1->next==0) k[0]=k1; + if(k1->next==NULL) k[0]=k1; k1=k1->next; } k1= k[1]; @@ -393,13 +393,13 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float *t, int cycl) k[2]= k1->next; t[2]= k[2]->pos; k[3]= k[2]->next; - if(k[3]==0) k[3]= k[2]; + if(k[3]==NULL) k[3]= k[2]; t[3]= k[3]->pos; k1= k[3]; } while( t[2]next==0) { + if(k1->next==NULL) { if(cycl) { k1= firstkey; ofs+= dpos; @@ -1081,7 +1081,7 @@ static void do_mesh_key(Scene *scene, Object *ob, Key *key, char *out, const int for(a=0; aipo, KEY_SPEED, &ctime)==0) { ctime /= 100.0; @@ -1213,7 +1213,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in while (a < estep) { if (remain <= 0) { cfra+= delta; - ctime= bsystem_time(scene, 0, cfra, 0.0f); // XXX old cruft + ctime= bsystem_time(scene, NULL, 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 @@ -1276,7 +1276,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int for(a=0; aipo, KEY_SPEED, &ctime)==0) { ctime /= 100.0; diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index be3ec62374f..bd7fdfebe97 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -251,11 +251,11 @@ void make_local_lattice(Lattice *lt) * - mixed: make copy */ - if(lt->id.lib==0) return; + if(lt->id.lib==NULL) return; if(lt->id.us==1) { - lt->id.lib= 0; + lt->id.lib= NULL; lt->id.flag= LIB_LOCAL; - new_id(0, (ID *)lt, 0); + new_id(NULL, (ID *)lt, NULL); return; } @@ -269,9 +269,9 @@ void make_local_lattice(Lattice *lt) } if(local && lib==0) { - lt->id.lib= 0; + lt->id.lib= NULL; lt->id.flag= LIB_LOCAL; - new_id(0, (ID *)lt, 0); + new_id(NULL, (ID *)lt, NULL); } else if(local && lib) { ltn= copy_lattice(lt); @@ -281,7 +281,7 @@ void make_local_lattice(Lattice *lt) while(ob) { if(ob->data==lt) { - if(ob->id.lib==0) { + if(ob->id.lib==NULL) { ob->data= ltn; ltn->id.us++; lt->id.us--; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 671f4d91922..99fcd3f4a50 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -419,7 +419,7 @@ ListBase *which_libbase(Main *mainlib, short type) case ID_GD: return &(mainlib->gpencil); } - return 0; + return NULL; } /* Flag all ids in listbase */ @@ -688,7 +688,7 @@ void set_free_windowmanager_cb(void (*func)(bContext *C, wmWindowManager *) ) free_windowmanager_cb= func; } -void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata) +static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata) { ChannelDriver *driver; FCurve *fcu; @@ -1007,7 +1007,7 @@ static void sort_alpha_id(ListBase *lb, ID *id) idtest= idtest->next; } /* as last */ - if(idtest==0) { + if(idtest==NULL) { BLI_addtail(lb, id); } } @@ -1189,7 +1189,7 @@ int new_id(ListBase *lb, ID *id, const char *tname) } /* next to indirect usage in read/writefile also in editobject.c scene.c */ -void clear_id_newpoins() +void clear_id_newpoins(void) { ListBase *lbarray[MAX_LIBARRAY]; ID *id; @@ -1199,7 +1199,7 @@ void clear_id_newpoins() while(a--) { id= lbarray[a]->first; while(id) { - id->newid= 0; + id->newid= NULL; id->flag &= ~LIB_NEW; id= id->next; } @@ -1293,7 +1293,7 @@ void tag_main(struct Main *mainvar, const short tag) /* if lib!=NULL, only all from lib local */ void all_local(Library *lib, int untagged_only) { - ListBase *lbarray[MAX_LIBARRAY], tempbase={0, 0}; + ListBase *lbarray[MAX_LIBARRAY], tempbase={NULL, NULL}; ID *id, *idn; int a; @@ -1322,7 +1322,7 @@ void all_local(Library *lib, int untagged_only) image_fix_relative_path((Image *)id); id->lib= NULL; - new_id(lbarray[a], id, 0); /* new_id only does it with double names */ + new_id(lbarray[a], id, NULL); /* new_id only does it with double names */ sort_alpha_id(lbarray[a], id); } } @@ -1334,7 +1334,7 @@ void all_local(Library *lib, int untagged_only) while( (id=tempbase.first) ) { BLI_remlink(&tempbase, id); BLI_addtail(lbarray[a], id); - new_id(lbarray[a], id, 0); + new_id(lbarray[a], id, NULL); } } @@ -1355,7 +1355,7 @@ void test_idbutton(char *name) lb= which_libbase(G.main, GS(name-2) ); - if(lb==0) return; + if(lb==NULL) return; /* search for id */ idtest= BLI_findstring(lb, name, offsetof(ID, name) + 2); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 152323dfb4d..954de9c86e2 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -278,11 +278,11 @@ void make_local_material(Material *ma) * - mixed: make copy */ - if(ma->id.lib==0) return; + if(ma->id.lib==NULL) return; if(ma->id.us==1) { - ma->id.lib= 0; + ma->id.lib= NULL; ma->id.flag= LIB_LOCAL; - new_id(0, (ID *)ma, 0); + new_id(NULL, (ID *)ma, NULL); for(a=0; amtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex); } @@ -344,14 +344,14 @@ void make_local_material(Material *ma) } if(local && lib==0) { - ma->id.lib= 0; + ma->id.lib= NULL; ma->id.flag= LIB_LOCAL; for(a=0; amtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex); } - new_id(0, (ID *)ma, 0); + new_id(NULL, (ID *)ma, NULL); } else if(local && lib) { @@ -364,7 +364,7 @@ void make_local_material(Material *ma) if(ob->mat) { for(a=0; atotcol; a++) { if(ob->mat[a]==ma) { - if(ob->id.lib==0) { + if(ob->id.lib==NULL) { ob->mat[a]= man; man->id.us++; ma->id.us--; @@ -380,7 +380,7 @@ void make_local_material(Material *ma) if(me->mat) { for(a=0; atotcol; a++) { if(me->mat[a]==ma) { - if(me->id.lib==0) { + if(me->id.lib==NULL) { me->mat[a]= man; man->id.us++; ma->id.us--; @@ -396,7 +396,7 @@ void make_local_material(Material *ma) if(cu->mat) { for(a=0; atotcol; a++) { if(cu->mat[a]==ma) { - if(cu->id.lib==0) { + if(cu->id.lib==NULL) { cu->mat[a]= man; man->id.us++; ma->id.us--; @@ -412,7 +412,7 @@ void make_local_material(Material *ma) if(mb->mat) { for(a=0; atotcol; a++) { if(mb->mat[a]==ma) { - if(mb->id.lib==0) { + if(mb->id.lib==NULL) { mb->mat[a]= man; man->id.us++; ma->id.us--; @@ -583,7 +583,7 @@ Material *give_current_material(Object *ob, int act) matarar= give_matarar(ob); if(matarar && *matarar) ma= (*matarar)[act-1]; - else ma= 0; + else ma= NULL; } @@ -593,7 +593,7 @@ Material *give_current_material(Object *ob, int act) ID *material_from(Object *ob, int act) { - if(ob==0) return 0; + if(ob==NULL) return NULL; if(ob->totcol==0) return ob->data; if(act==0) act= 1; @@ -688,7 +688,7 @@ void assign_material(Object *ob, Material *ma, int act) totcolp= give_totcolp(ob); matarar= give_matarar(ob); - if(totcolp==0 || matarar==0) return; + if(totcolp==NULL || matarar==NULL) return; if(act > *totcolp) { matar= MEM_callocN(sizeof(void *)*act, "matarray1"); @@ -782,7 +782,7 @@ int object_add_material_slot(Object *ob) { Material *ma; - if(ob==0) return FALSE; + if(ob==NULL) return FALSE; if(ob->totcol>=MAXMAT) return FALSE; ma= give_current_material(ob, ob->actcol); @@ -964,7 +964,7 @@ int material_in_material(Material *parmat, Material *mat) /* ****************** */ -char colname_array[125][20]= { +static char colname_array[125][20]= { "Black","DarkRed","HalfRed","Red","Red", "DarkGreen","DarkOlive","Brown","Chocolate","OrangeRed", "HalfGreen","GreenOlive","DryOlive","Goldenrod","DarkOrange", @@ -997,7 +997,7 @@ void automatname(Material *ma) int nr, r, g, b; float ref; - if(ma==0) return; + if(ma==NULL) return; if(ma->mode & MA_SHLESS) ref= 1.0; else ref= ma->ref; @@ -1045,7 +1045,7 @@ int object_remove_material_slot(Object *ob) if(*totcolp==0) { MEM_freeN(*matarar); - *matarar= 0; + *matarar= NULL; } actcol= ob->actcol; @@ -1068,7 +1068,7 @@ int object_remove_material_slot(Object *ob) if(obt->totcol==0) { MEM_freeN(obt->mat); MEM_freeN(obt->matbits); - obt->mat= 0; + obt->mat= NULL; obt->matbits= NULL; } } @@ -1349,7 +1349,7 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) /* copy/paste buffer, if we had a propper py api that would be better */ Material matcopybuf; -static short matcopied=0; +static short matcopied= 0; void clear_matcopybuf(void) { diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index a22fc165de7..d89bc3cd6f2 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -77,7 +77,7 @@ void unlink_mball(MetaBall *mb) for(a=0; atotcol; a++) { if(mb->mat[a]) mb->mat[a]->id.us--; - mb->mat[a]= 0; + mb->mat[a]= NULL; } } @@ -142,9 +142,9 @@ void make_local_mball(MetaBall *mb) * - mixed: make copy */ - if(mb->id.lib==0) return; + if(mb->id.lib==NULL) return; if(mb->id.us==1) { - mb->id.lib= 0; + mb->id.lib= NULL; mb->id.flag= LIB_LOCAL; return; } @@ -159,7 +159,7 @@ void make_local_mball(MetaBall *mb) } if(local && lib==0) { - mb->id.lib= 0; + mb->id.lib= NULL; mb->id.flag= LIB_LOCAL; } else if(local && lib) { @@ -170,7 +170,7 @@ void make_local_mball(MetaBall *mb) while(ob) { if(ob->data==mb) { - if(ob->id.lib==0) { + if(ob->id.lib==NULL) { ob->data= mbn; mbn->id.us++; mb->id.us--; @@ -242,7 +242,7 @@ void tex_space_mball(Object *ob) float *data, min[3], max[3], loc[3], size[3]; int tot, doit=0; - if(ob->bb==0) ob->bb= MEM_callocN(sizeof(BoundBox), "mb boundbox"); + if(ob->bb==NULL) ob->bb= MEM_callocN(sizeof(BoundBox), "mb boundbox"); bb= ob->bb; /* Weird one, this. */ @@ -372,7 +372,7 @@ void copy_mball_properties(Scene *scene, Object *active_object) BLI_split_name_num(basisname, &basisnr, active_object->id.name+2, '.'); /* XXX recursion check, see scene.c, just too simple code this next_object() */ - if(F_ERROR==next_object(&sce_iter, 0, 0, 0)) + if(F_ERROR==next_object(&sce_iter, 0, NULL, NULL)) return; while(next_object(&sce_iter, 1, &base, &ob)) { @@ -418,7 +418,7 @@ Object *find_basis_mball(Scene *scene, Object *basis) totelem= 0; /* XXX recursion check, see scene.c, just too simple code this next_object() */ - if(F_ERROR==next_object(&sce_iter, 0, 0, 0)) + if(F_ERROR==next_object(&sce_iter, 0, NULL, NULL)) return NULL; while(next_object(&sce_iter, 1, &base, &ob)) { @@ -698,8 +698,8 @@ float metaball(float x, float y, float z) /* ******************************************** */ -int *indices=NULL; -int totindex, curindex; +static int *indices=NULL; +static int totindex, curindex; void accum_mballfaces(int i1, int i2, int i3, int i4) @@ -742,8 +742,8 @@ void *new_pgn_element(int size) */ int blocksize= 16384; static int offs= 0; /* the current free address */ - static struct pgn_elements *cur= 0; - static ListBase lb= {0, 0}; + static struct pgn_elements *cur= NULL; + static ListBase lb= {NULL, NULL}; void *adr; if(size>10000 || size==0) { @@ -925,14 +925,14 @@ void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, i newc.corners[FLIP(c3, bit)] = corn3; newc.corners[FLIP(c4, bit)] = corn4; - if(newc.corners[0]==0) newc.corners[0] = setcorner(p, i, j, k); - if(newc.corners[1]==0) newc.corners[1] = setcorner(p, i, j, k+1); - if(newc.corners[2]==0) newc.corners[2] = setcorner(p, i, j+1, k); - if(newc.corners[3]==0) newc.corners[3] = setcorner(p, i, j+1, k+1); - if(newc.corners[4]==0) newc.corners[4] = setcorner(p, i+1, j, k); - if(newc.corners[5]==0) newc.corners[5] = setcorner(p, i+1, j, k+1); - if(newc.corners[6]==0) newc.corners[6] = setcorner(p, i+1, j+1, k); - if(newc.corners[7]==0) newc.corners[7] = setcorner(p, i+1, j+1, k+1); + if(newc.corners[0]==NULL) newc.corners[0] = setcorner(p, i, j, k); + if(newc.corners[1]==NULL) newc.corners[1] = setcorner(p, i, j, k+1); + if(newc.corners[2]==NULL) newc.corners[2] = setcorner(p, i, j+1, k); + if(newc.corners[3]==NULL) newc.corners[3] = setcorner(p, i, j+1, k+1); + if(newc.corners[4]==NULL) newc.corners[4] = setcorner(p, i+1, j, k); + if(newc.corners[5]==NULL) newc.corners[5] = setcorner(p, i+1, j, k+1); + if(newc.corners[6]==NULL) newc.corners[6] = setcorner(p, i+1, j+1, k); + if(newc.corners[7]==NULL) newc.corners[7] = setcorner(p, i+1, j+1, k+1); p->cubes->cube= newc; } @@ -1031,7 +1031,7 @@ void makecubetable (void) for (c = 0; c < 8; c++) pos[c] = MB_BIT(i, c); for (e = 0; e < 12; e++) if (!done[e] && (pos[corner1[e]] != pos[corner2[e]])) { - INTLIST *ints = 0; + INTLIST *ints = NULL; INTLISTS *lists = (INTLISTS *) MEM_callocN(sizeof(INTLISTS), "mball_intlist"); int start = e, edge = e; @@ -1080,7 +1080,7 @@ void BKE_freecubetable(void) MEM_freeN(lists); lists= nlists; } - cubetable[i]= 0; + cubetable[i]= NULL; } } @@ -1594,7 +1594,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); /* make main array */ - next_object(&sce_iter, 0, 0, 0); + next_object(&sce_iter, 0, NULL, NULL); while(next_object(&sce_iter, 1, &base, &bob)) { if(bob->type==OB_MBALL) { @@ -2174,7 +2174,7 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) if(G.moving && mb->flag==MB_UPDATE_FAST) return; curindex= totindex= 0; - indices= 0; + indices= NULL; thresh= mb->thresh; /* total number of MetaElems (totelem) is precomputed in find_basis_mball() function */ @@ -2229,7 +2229,7 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) mbproc.function = metaball; mbproc.size = width; mbproc.bounds = nr_cubes; - mbproc.cubes= 0; + mbproc.cubes= NULL; mbproc.delta = width/(float)(RES*RES); polygonize(&mbproc, mb); @@ -2251,7 +2251,7 @@ void metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) dl->parts= curindex; dl->index= indices; - indices= 0; + indices= NULL; a= mbproc.vertices.count; dl->verts= ve= MEM_mallocN(sizeof(float)*3*a, "mballverts"); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 8117a626c03..3c56cb4663b 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -98,11 +98,11 @@ void unlink_mesh(Mesh *me) { int a; - if(me==0) return; + if(me==NULL) return; for(a=0; atotcol; a++) { if(me->mat[a]) me->mat[a]->id.us--; - me->mat[a]= 0; + me->mat[a]= NULL; } if(me->key) { @@ -110,9 +110,9 @@ void unlink_mesh(Mesh *me) if (me->key->id.us == 0 && me->key->ipo ) me->key->ipo->id.us--; } - me->key= 0; + me->key= NULL; - if(me->texcomesh) me->texcomesh= 0; + if(me->texcomesh) me->texcomesh= NULL; } @@ -255,9 +255,9 @@ void make_local_tface(Mesh *me) if(tface->tpage) { ima= tface->tpage; if(ima->id.lib) { - ima->id.lib= 0; + ima->id.lib= NULL; ima->id.flag= LIB_LOCAL; - new_id(0, (ID *)ima, 0); + new_id(NULL, (ID *)ima, NULL); } } } @@ -277,11 +277,11 @@ void make_local_mesh(Mesh *me) * - mixed: make copy */ - if(me->id.lib==0) return; + if(me->id.lib==NULL) return; if(me->id.us==1) { - me->id.lib= 0; + me->id.lib= NULL; me->id.flag= LIB_LOCAL; - new_id(0, (ID *)me, 0); + new_id(NULL, (ID *)me, NULL); if(me->mtface) make_local_tface(me); @@ -298,9 +298,9 @@ void make_local_mesh(Mesh *me) } if(local && lib==0) { - me->id.lib= 0; + me->id.lib= NULL; me->id.flag= LIB_LOCAL; - new_id(0, (ID *)me, 0); + new_id(NULL, (ID *)me, NULL); if(me->mtface) make_local_tface(me); @@ -312,7 +312,7 @@ void make_local_mesh(Mesh *me) ob= bmain->object.first; while(ob) { if( me==get_mesh(ob) ) { - if(ob->id.lib==0) { + if(ob->id.lib==NULL) { set_mesh(ob, men); } } @@ -327,7 +327,7 @@ void boundbox_mesh(Mesh *me, float *loc, float *size) float min[3], max[3]; float mloc[3], msize[3]; - if(me->bb==0) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); + if(me->bb==NULL) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); bb= me->bb; if (!loc) loc= mloc; @@ -512,18 +512,18 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) Mesh *get_mesh(Object *ob) { - if(ob==0) return 0; + if(ob==NULL) return NULL; if(ob->type==OB_MESH) return ob->data; - else return 0; + else return NULL; } void set_mesh(Object *ob, Mesh *me) { - Mesh *old=0; + Mesh *old=NULL; multires_force_update(ob); - if(ob==0) return; + if(ob==NULL) return; if(ob->type==OB_MESH) { old= ob->data; @@ -730,7 +730,7 @@ void mball_to_mesh(ListBase *lb, Mesh *me) int a, *index; dl= lb->first; - if(dl==0) return; + if(dl==NULL) return; if(dl->type==DL_INDEX4) { me->totvert= dl->nr; @@ -1023,7 +1023,7 @@ void nurbs_to_mesh(Object *ob) tex_space_mesh(me); - cu->mat= 0; + cu->mat= NULL; cu->totcol= 0; if(ob->data) { diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 6f8075310c7..db0c649d290 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -57,7 +57,7 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) { - static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]= {0}; + static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]= {NULL}; static int types_init = 1; if (types_init) { diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 2601adbcb5e..29726ccbc99 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -449,7 +449,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple) { - MultiresModifierData mmd= {{0}}; + MultiresModifierData mmd= {{NULL}}; mmd.lvl = lvl; mmd.sculptlvl = lvl; @@ -462,7 +462,7 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv static DerivedMesh *subsurf_dm_create_local(Object *UNUSED(ob), DerivedMesh *dm, int lvl, int simple, int optimal) { - SubsurfModifierData smd= {{0}}; + SubsurfModifierData smd= {{NULL}}; smd.levels = smd.renderLevels = lvl; smd.flags |= eSubsurfModifierFlag_SubsurfUv; @@ -596,7 +596,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) dispdm->release(dispdm); } -void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl, int updateblock, int simple) +static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl, int updateblock, int simple) { Mesh *me = ob->data; MDisps *mdisps; @@ -1591,7 +1591,7 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) else multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple); } -void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) +static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) { DerivedMesh *dm= NULL, *cddm= NULL, *subdm= NULL; DMGridData **gridData, **subGridData; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 6db03909aa3..da0f3f8a448 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1320,7 +1320,7 @@ static void nlastrip_get_endpoint_overlaps (NlaStrip *strip, NlaTrack *track, fl } /* Determine auto-blending for the given strip */ -void BKE_nlastrip_validate_autoblends (NlaTrack *nlt, NlaStrip *nls) +static void BKE_nlastrip_validate_autoblends (NlaTrack *nlt, NlaStrip *nls) { float *ps=NULL, *pe=NULL; float *ns=NULL, *ne=NULL; @@ -1576,7 +1576,7 @@ void BKE_nla_tweakmode_exit (AnimData *adt) /* Baking Tools ------------------------------------------- */ -void BKE_nla_bake (Scene *scene, ID *UNUSED(id), AnimData *adt, int UNUSED(flag)) +static void BKE_nla_bake (Scene *scene, ID *UNUSED(id), AnimData *adt, int UNUSED(flag)) { /* verify that data is valid diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 218539b311a..057d90dc8bb 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1499,9 +1499,9 @@ void ntreeMakeLocal(bNodeTree *ntree) if(ntree->id.lib==NULL) return; if(ntree->id.us==1) { - ntree->id.lib= 0; + ntree->id.lib= NULL; ntree->id.flag= LIB_LOCAL; - new_id(0, (ID *)ntree, 0); + new_id(NULL, (ID *)ntree, NULL); return; } @@ -1559,7 +1559,7 @@ void ntreeMakeLocal(bNodeTree *ntree) if(local && lib==0) { ntree->id.lib= NULL; ntree->id.flag= LIB_LOCAL; - new_id(0, (ID *)ntree, 0); + new_id(NULL, (ID *)ntree, NULL); } else if(local && lib) { /* this is the mixed case, we copy the tree and assign it to local users */ @@ -2437,7 +2437,7 @@ static void *exec_composite_node(void *node_v) } node->exec |= NODE_READY; - return 0; + return NULL; } /* return total of executable nodes, for timecursor */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 5d5271bba8c..6149f7d380b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -273,7 +273,7 @@ void free_object(Object *ob) else if(ob->type==OB_CURVE) unlink_curve(ob->data); else if(ob->type==OB_MBALL) unlink_mball(ob->data); } - ob->data= 0; + ob->data= NULL; } for(a=0; atotcol; a++) { @@ -281,12 +281,12 @@ void free_object(Object *ob) } if(ob->mat) MEM_freeN(ob->mat); if(ob->matbits) MEM_freeN(ob->matbits); - ob->mat= 0; - ob->matbits= 0; + ob->mat= NULL; + ob->matbits= NULL; if(ob->bb) MEM_freeN(ob->bb); - ob->bb= 0; + ob->bb= NULL; if(ob->path) free_path(ob->path); - ob->path= 0; + ob->path= NULL; if(ob->adt) BKE_free_animdata((ID *)ob); if(ob->poselib) ob->poselib->id.us--; if(ob->gpd) ((ID *)ob->gpd)->us--; @@ -739,11 +739,11 @@ void make_local_camera(Camera *cam) * - mixed: make copy */ - if(cam->id.lib==0) return; + if(cam->id.lib==NULL) return; if(cam->id.us==1) { - cam->id.lib= 0; + cam->id.lib= NULL; cam->id.flag= LIB_LOCAL; - new_id(0, (ID *)cam, 0); + new_id(NULL, (ID *)cam, NULL); return; } @@ -757,9 +757,9 @@ void make_local_camera(Camera *cam) } if(local && lib==0) { - cam->id.lib= 0; + cam->id.lib= NULL; cam->id.flag= LIB_LOCAL; - new_id(0, (ID *)cam, 0); + new_id(NULL, (ID *)cam, NULL); } else if(local && lib) { camn= copy_camera(cam); @@ -769,7 +769,7 @@ void make_local_camera(Camera *cam) while(ob) { if(ob->data==cam) { - if(ob->id.lib==0) { + if(ob->id.lib==NULL) { ob->data= camn; camn->id.us++; cam->id.us--; @@ -888,11 +888,11 @@ void make_local_lamp(Lamp *la) * - mixed: make copy */ - if(la->id.lib==0) return; + if(la->id.lib==NULL) return; if(la->id.us==1) { - la->id.lib= 0; + la->id.lib= NULL; la->id.flag= LIB_LOCAL; - new_id(0, (ID *)la, 0); + new_id(NULL, (ID *)la, NULL); return; } @@ -906,9 +906,9 @@ void make_local_lamp(Lamp *la) } if(local && lib==0) { - la->id.lib= 0; + la->id.lib= NULL; la->id.flag= LIB_LOCAL; - new_id(0, (ID *)la, 0); + new_id(NULL, (ID *)la, NULL); } else if(local && lib) { lan= copy_lamp(la); @@ -918,7 +918,7 @@ void make_local_lamp(Lamp *la) while(ob) { if(ob->data==la) { - if(ob->id.lib==0) { + if(ob->id.lib==NULL) { ob->data= lan; lan->id.us++; la->id.us--; @@ -1127,7 +1127,7 @@ BulletSoftBody *copy_bulletsoftbody(BulletSoftBody *bsb) return bsbn; } -ParticleSystem *copy_particlesystem(ParticleSystem *psys) +static ParticleSystem *copy_particlesystem(ParticleSystem *psys) { ParticleSystem *psysn; ParticleData *pa; @@ -2262,7 +2262,7 @@ void what_does_parent(Scene *scene, Object *ob, Object *workob) where_is_object(scene, workob); } -BoundBox *unit_boundbox() +BoundBox *unit_boundbox(void) { BoundBox *bb; float min[3] = {-1.0f,-1.0f,-1.0f}, max[3] = {-1.0f,-1.0f,-1.0f}; diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 12ebaf7578a..1fc0a2259fb 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -459,7 +459,7 @@ int unpackVFont(ReportList *reports, VFont *vfont, int how) if (newname != NULL) { ret_value = RET_OK; freePackedFile(vfont->packedfile); - vfont->packedfile = 0; + vfont->packedfile = NULL; strcpy(vfont->name, newname); MEM_freeN(newname); } @@ -485,7 +485,7 @@ int unpackSound(Main *bmain, ReportList *reports, bSound *sound, int how) MEM_freeN(newname); freePackedFile(sound->packedfile); - sound->packedfile = 0; + sound->packedfile = NULL; sound_load(bmain, sound); diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index b2f4b6bdc97..3204a1c38e7 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -157,21 +157,21 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf ParticleSystem *psys_get_current(Object *ob) { ParticleSystem *psys; - if(ob==0) return 0; + if(ob==NULL) return NULL; for(psys=ob->particlesystem.first; psys; psys=psys->next){ if(psys->flag & PSYS_CURRENT) return psys; } - return 0; + return NULL; } short psys_get_current_num(Object *ob) { ParticleSystem *psys; short i; - if(ob==0) return 0; + if(ob==NULL) return 0; for(psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++) if(psys->flag & PSYS_CURRENT) @@ -184,7 +184,7 @@ void psys_set_current_num(Object *ob, int index) ParticleSystem *psys; short i; - if(ob==0) return; + if(ob==NULL) return; for(psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++) { if(i == index) @@ -209,7 +209,7 @@ Object *psys_find_object(Scene *scene, ParticleSystem *psys) } Object *psys_get_lattice(ParticleSimulationData *sim) { - Object *lattice=0; + Object *lattice=NULL; if(psys_in_edit_mode(sim->scene, sim->psys)==0){ @@ -223,7 +223,7 @@ Object *psys_get_lattice(ParticleSimulationData *sim) } } if(lattice) - init_latt_deform(lattice,0); + init_latt_deform(lattice, NULL); } return lattice; @@ -358,7 +358,7 @@ int psys_uses_gravity(ParticleSimulationData *sim) /************************************************/ /* Freeing stuff */ /************************************************/ -void fluid_free_settings(SPHFluidSettings *fluid) +static void fluid_free_settings(SPHFluidSettings *fluid) { if(fluid) MEM_freeN(fluid); @@ -459,7 +459,7 @@ void psys_free_children(ParticleSystem *psys) { if(psys->child) { MEM_freeN(psys->child); - psys->child=0; + psys->child= NULL; psys->totchild=0; } @@ -529,7 +529,7 @@ void psys_free(Object *ob, ParticleSystem * psys) if(psys->child){ MEM_freeN(psys->child); - psys->child = 0; + psys->child = NULL; psys->totchild = 0; } @@ -550,7 +550,7 @@ void psys_free(Object *ob, ParticleSystem * psys) if(psys->part){ psys->part->id.us--; - psys->part=0; + psys->part=NULL; } BKE_ptcache_free_list(&psys->ptcaches); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 409e9876599..e29293a3087 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -120,7 +120,8 @@ static int particles_are_dynamic(ParticleSystem *psys) { else return ELEM3(psys->part->phystype, PART_PHYS_NEWTON, PART_PHYS_BOIDS, PART_PHYS_FLUID); } -int psys_get_current_display_percentage(ParticleSystem *psys) + +static int psys_get_current_display_percentage(ParticleSystem *psys) { ParticleSettings *part=psys->part; @@ -173,7 +174,7 @@ void psys_reset(ParticleSystem *psys, int mode) /* reset children */ if(psys->child) { MEM_freeN(psys->child); - psys->child= 0; + psys->child= NULL; } psys->totchild= 0; @@ -277,7 +278,7 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) if(psys->child) { MEM_freeN(psys->child); - psys->child=0; + psys->child=NULL; psys->totchild=0; } } @@ -312,7 +313,7 @@ static void alloc_child_particles(ParticleSystem *psys, int tot) } MEM_freeN(psys->child); - psys->child=0; + psys->child=NULL; psys->totchild=0; } @@ -401,7 +402,7 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys) static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) { - ParticleData *pa=0; + ParticleData *pa=NULL; float min[3], max[3], delta[3], d; MVert *mv, *mvert = dm->getVertDataArray(dm,0); int totvert=dm->getNumVerts(dm), from=psys->part->from; diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index dd57fef50c5..e907b628242 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -43,6 +43,8 @@ #include "BLI_blenlib.h" +#include "BKE_property.h" + void free_property(bProperty *prop) { @@ -93,7 +95,7 @@ void init_property(bProperty *prop) /* also use when property changes type */ if(prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin); - prop->poin= 0; + prop->poin= NULL; prop->data= 0; diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 12f82d041f9..c8ef834fbbb 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -86,7 +86,7 @@ void copy_sensors(ListBase *lbn, ListBase *lbo) { bSensor *sens, *sensn; - lbn->first= lbn->last= 0; + lbn->first= lbn->last= NULL; sens= lbo->first; while(sens) { sensn= copy_sensor(sens); @@ -253,7 +253,7 @@ void copy_controllers(ListBase *lbn, ListBase *lbo) { bController *cont, *contn; - lbn->first= lbn->last= 0; + lbn->first= lbn->last= NULL; cont= lbo->first; while(cont) { contn= copy_controller(cont); @@ -267,7 +267,7 @@ void init_controller(bController *cont) /* also use when controller changes type, leave actuators... */ if(cont->data) MEM_freeN(cont->data); - cont->data= 0; + cont->data= NULL; switch(cont->type) { case CONT_EXPRESSION: @@ -375,7 +375,7 @@ void copy_actuators(ListBase *lbn, ListBase *lbo) { bActuator *act, *actn; - lbn->first= lbn->last= 0; + lbn->first= lbn->last= NULL; act= lbo->first; while(act) { actn= copy_actuator(act); @@ -393,7 +393,7 @@ void init_actuator(bActuator *act) bSoundActuator *sa; if(act->data) MEM_freeN(act->data); - act->data= 0; + act->data= NULL; switch(act->type) { case ACT_ACTION: @@ -512,7 +512,7 @@ void clear_sca_new_poins_ob(Object *ob) } } -void clear_sca_new_poins() +void clear_sca_new_poins(void) { Object *ob; @@ -595,7 +595,7 @@ void set_sca_new_poins_ob(Object *ob) } -void set_sca_new_poins() +void set_sca_new_poins(void) { Object *ob; diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 6f1d32898f9..58900e603e3 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -109,7 +109,7 @@ ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid) } -const ListBase *BKE_spacetypes_list() +const ListBase *BKE_spacetypes_list(void) { return &spacetypes; } diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 78cd4bb51fe..1c40ef020be 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -54,10 +54,10 @@ typedef struct seqCacheEntry 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 GHash * hash = NULL; +static MEM_CacheLimiterC * limitor = NULL; +static struct BLI_mempool * entrypool = NULL; +static struct BLI_mempool * keypool = NULL; static int ibufs_in = 0; static int ibufs_rem = 0; @@ -119,8 +119,8 @@ static void HashValFree(void *val) ibufs_rem++; } - e->ibuf = 0; - e->c_handle = 0; + e->ibuf = NULL; + e->c_handle = NULL; BLI_mempool_free(entrypool, e); } @@ -135,12 +135,12 @@ static void IMB_seq_cache_destructor(void * p) IMB_freeImBuf(e->ibuf); ibufs_rem++; - e->ibuf = 0; - e->c_handle = 0; + e->ibuf = NULL; + e->c_handle = NULL; } } -void seq_stripelem_cache_init() +void seq_stripelem_cache_init(void) { hash = BLI_ghash_new(HashHash, HashCmp, "seq stripelem cache hash"); limitor = new_MEM_CacheLimiter( IMB_seq_cache_destructor ); @@ -149,7 +149,7 @@ void seq_stripelem_cache_init() keypool = BLI_mempool_create(sizeof(seqCacheKey), 64, 64, 0); } -void seq_stripelem_cache_destruct() +void seq_stripelem_cache_destruct(void) { if (!entrypool) { return; @@ -160,7 +160,7 @@ void seq_stripelem_cache_destruct() BLI_mempool_destroy(keypool); } -void seq_stripelem_cache_cleanup() +void seq_stripelem_cache_cleanup(void) { if (!entrypool) { seq_stripelem_cache_init(); @@ -185,7 +185,7 @@ struct ImBuf * seq_stripelem_cache_get( seqCacheEntry * e; if (!seq) { - return 0; + return NULL; } if (!entrypool) { @@ -205,7 +205,7 @@ struct ImBuf * seq_stripelem_cache_get( MEM_CacheLimiter_touch(e->c_handle); return e->ibuf; } - return 0; + return NULL; } void seq_stripelem_cache_put( @@ -239,7 +239,7 @@ void seq_stripelem_cache_put( e = (seqCacheEntry*) BLI_mempool_alloc(entrypool); e->ibuf = i; - e->c_handle = 0; + e->c_handle = NULL; BLI_ghash_remove(hash, key, HashKeyFree, HashValFree); BLI_ghash_insert(hash, key, e); diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 11075fe402e..da90ce4a715 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -125,12 +125,12 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname) char *cp; /* to be sure: (is tested for) */ - pis->doit= 0; - pis->pname= 0; - pis->varstr= 0; - pis->cfra= 0; + pis->doit= NULL; + pis->pname= NULL; + pis->varstr= NULL; + pis->cfra= NULL; pis->version= 0; - pis->instance_private_data = 0; + pis->instance_private_data = NULL; /* clear the error list */ PIL_dynlib_get_error_as_string(NULL); @@ -142,12 +142,12 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname) pis->handle= PIL_dynlib_open(pis->name); if(test_dlerr(pis->name, pis->name)) return; - if (pis->handle != 0) { + if (pis->handle != NULL) { /* find the address of the version function */ version= (int (*)(void))PIL_dynlib_find_symbol(pis->handle, "plugin_seq_getversion"); if (test_dlerr(pis->name, "plugin_seq_getversion")) return; - if (version != 0) { + if (version != NULL) { pis->version= version(); if (pis->version >= 2 && pis->version <= 6) { int (*info_func)(PluginInfo *); @@ -201,11 +201,11 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname) strncpy(pis->name, str, FILE_MAXDIR+FILE_MAXFILE); open_plugin_seq(pis, seqname); - if(pis->doit==0) { - if(pis->handle==0) error("no plugin: %s", str); + if(pis->doit==NULL) { + if(pis->handle==NULL) error("no plugin: %s", str); else error("in plugin: %s", str); MEM_freeN(pis); - return 0; + return NULL; } /* default values */ @@ -222,7 +222,7 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname) static void free_plugin_seq(PluginSeq *pis) { - if(pis==0) return; + if(pis==NULL) return; /* no PIL_dynlib_close: same plugin can be opened multiple times with 1 handle */ @@ -270,7 +270,7 @@ static void copy_plugin(Sequence * dst, Sequence * src) static ImBuf * IMB_cast_away_list(ImBuf * i) { if (!i) { - return 0; + return NULL; } return (ImBuf*) (((void**) i) + 2); } @@ -383,7 +383,7 @@ static int do_plugin_early_out(struct Sequence *UNUSED(seq), static void free_plugin(struct Sequence * seq) { free_plugin_seq(seq->plugin); - seq->plugin = 0; + seq->plugin = NULL; } /* ********************************************************************** @@ -554,7 +554,7 @@ static struct ImBuf * do_alphaover_effect( ALPHA UNDER ********************************************************************** */ -void do_alphaunder_effect_byte( +static void do_alphaunder_effect_byte( float facf0, float facf1, int x, int y, char *rect1, char *rect2, char *out) { @@ -726,7 +726,7 @@ static struct ImBuf* do_alphaunder_effect( CROSS ********************************************************************** */ -void do_cross_effect_byte(float facf0, float facf1, int x, int y, +static void do_cross_effect_byte(float facf0, float facf1, int x, int y, char *rect1, char *rect2, char *out) { @@ -774,7 +774,7 @@ void do_cross_effect_byte(float facf0, float facf1, int x, int y, } } -void do_cross_effect_float(float facf0, float facf1, int x, int y, +static void do_cross_effect_float(float facf0, float facf1, int x, int y, float *rect1, float *rect2, float *out) { float fac1, fac2, fac3, fac4; @@ -1864,7 +1864,7 @@ static int num_inputs_wipe(void) static void free_wipe_effect(Sequence *seq) { if(seq->effectdata)MEM_freeN(seq->effectdata); - seq->effectdata = 0; + seq->effectdata = NULL; } static void copy_wipe_effect(Sequence *dst, Sequence *src) @@ -2048,7 +2048,7 @@ static int num_inputs_transform(void) static void free_transform_effect(Sequence *seq) { if(seq->effectdata)MEM_freeN(seq->effectdata); - seq->effectdata = 0; + seq->effectdata = NULL; } static void copy_transform_effect(Sequence *dst, Sequence *src) @@ -2617,7 +2617,7 @@ static int num_inputs_glow(void) static void free_glow_effect(Sequence *seq) { if(seq->effectdata)MEM_freeN(seq->effectdata); - seq->effectdata = 0; + seq->effectdata = NULL; } static void copy_glow_effect(Sequence *dst, Sequence *src) @@ -2704,7 +2704,7 @@ static int num_inputs_color(void) static void free_solid_color(Sequence *seq) { if(seq->effectdata)MEM_freeN(seq->effectdata); - seq->effectdata = 0; + seq->effectdata = NULL; } static void copy_solid_color(Sequence *dst, Sequence *src) @@ -2827,21 +2827,21 @@ static struct ImBuf * do_multicam( ListBase * seqbasep; if (seq->multicam_source == 0 || seq->multicam_source >= seq->machine) { - return 0; + return NULL; } ed = context.scene->ed; if (!ed) { - return 0; + return NULL; } seqbasep = seq_seqbase(&ed->seqbase, seq); if (!seqbasep) { - return 0; + return NULL; } i = give_ibuf_seqbase(context, cfra, seq->multicam_source, seqbasep); if (!i) { - return 0; + return NULL; } if (input_have_to_preprocess(context, seq, cfra)) { @@ -2867,7 +2867,7 @@ static void init_speed_effect(Sequence *seq) v = (SpeedControlVars *)seq->effectdata; v->globalSpeed = 1.0; - v->frameMap = 0; + v->frameMap = NULL; v->flags |= SEQ_SPEED_INTEGRATE; /* should be default behavior */ v->length = 0; } @@ -2876,7 +2876,7 @@ static void load_speed_effect(Sequence * seq) { SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; - v->frameMap = 0; + v->frameMap = NULL; v->length = 0; } @@ -2890,7 +2890,7 @@ static void free_speed_effect(Sequence *seq) SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; if(v->frameMap) MEM_freeN(v->frameMap); if(seq->effectdata) MEM_freeN(seq->effectdata); - seq->effectdata = 0; + seq->effectdata = NULL; } static void copy_speed_effect(Sequence *dst, Sequence *src) @@ -2898,7 +2898,7 @@ static void copy_speed_effect(Sequence *dst, Sequence *src) SpeedControlVars * v; dst->effectdata = MEM_dupallocN(src->effectdata); v = (SpeedControlVars *)dst->effectdata; - v->frameMap = 0; + v->frameMap = NULL; v->length = 0; } @@ -3260,7 +3260,7 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) struct SeqEffectHandle get_sequence_effect(Sequence * seq) { - struct SeqEffectHandle rval= {0}; + struct SeqEffectHandle rval= {NULL}; if (seq->type & SEQ_EFFECT) { rval = get_sequence_effect_impl(seq->type); @@ -3275,7 +3275,7 @@ struct SeqEffectHandle get_sequence_effect(Sequence * seq) struct SeqEffectHandle get_sequence_blend(Sequence * seq) { - struct SeqEffectHandle rval= {0}; + struct SeqEffectHandle rval= {NULL}; if (seq->blend_mode != 0) { rval = get_sequence_effect_impl(seq->blend_mode); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 8f07ed48803..9537931faec 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -135,7 +135,7 @@ static void free_proxy_seq(Sequence *seq) { if (seq->strip && seq->strip->proxy && seq->strip->proxy->anim) { IMB_free_anim(seq->strip->proxy->anim); - seq->strip->proxy->anim = 0; + seq->strip->proxy->anim = NULL; } } @@ -429,7 +429,7 @@ void seq_end(SeqIterator *iter) * in metastrips!) ********************************************************************** */ - +#if 0 /* UNUSED */ static void do_seq_count(ListBase *seqbase, int *totseq) { Sequence *seq; @@ -456,7 +456,7 @@ static void do_build_seqar(ListBase *seqbase, Sequence ***seqar, int depth) } } -void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq) +static void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq) { Sequence **tseqar; @@ -473,6 +473,7 @@ void build_seqar(ListBase *seqbase, Sequence ***seqar, int *totseq) do_build_seqar(seqbase, seqar, 0); *seqar= tseqar; } +#endif /* UNUSED */ static void do_seq_count_cb(ListBase *seqbase, int *totseq, int (*test_func)(Sequence * seq)) @@ -762,8 +763,8 @@ void sort_seq(Scene *scene) if(ed==NULL) return; - seqbase.first= seqbase.last= 0; - effbase.first= effbase.last= 0; + seqbase.first= seqbase.last= NULL; + effbase.first= effbase.last= NULL; while( (seq= ed->seqbasep->first) ) { BLI_remlink(ed->seqbasep, seq); @@ -777,7 +778,7 @@ void sort_seq(Scene *scene) } seqt= seqt->next; } - if(seqt==0) BLI_addtail(&effbase, seq); + if(seqt==NULL) BLI_addtail(&effbase, seq); } else { seqt= seqbase.first; @@ -788,7 +789,7 @@ void sort_seq(Scene *scene) } seqt= seqt->next; } - if(seqt==0) BLI_addtail(&seqbase, seq); + if(seqt==NULL) BLI_addtail(&seqbase, seq); } } @@ -933,7 +934,7 @@ static void make_black_ibuf(ImBuf *ibuf) float *rect_float; int tot; - if(ibuf==0 || (ibuf->rect==0 && ibuf->rect_float==0)) return; + if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) return; tot= ibuf->x*ibuf->y; @@ -1024,7 +1025,7 @@ StripElem *give_stripelem(Sequence *seq, int cfra) if(seq->type != SEQ_MOVIE) { /* movie use the first */ int nr = (int) give_stripelem_index(seq, cfra); - if (nr == -1 || se == 0) return 0; + if (nr == -1 || se == NULL) return NULL; se += nr + seq->anim_startofs; } @@ -1076,7 +1077,7 @@ static int get_shown_sequences( ListBase * seqbasep, int cfra, int chanshown, Se if(evaluate_seq_frame_gen(seq_arr, seqbasep, cfra)) { if (b > 0) { - if (seq_arr[b] == 0) { + if (seq_arr[b] == NULL) { return 0; } } else { @@ -1173,38 +1174,38 @@ static struct ImBuf * seq_proxy_fetch(SeqRenderData context, Sequence * seq, int char name[PROXY_MAXFILE]; if (!(seq->flag & SEQ_USE_PROXY)) { - return 0; + return NULL; } /* rendering at 100% ? No real sense in proxy-ing, right? */ if (context.preview_render_size == 100) { - return 0; + return NULL; } if (seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) { int frameno = (int) give_stripelem_index(seq, cfra) + seq->anim_startofs; if (seq->strip->proxy->anim == NULL) { if (seq_proxy_get_fname(context, seq, cfra, name)==0) { - return 0; + return NULL; } seq->strip->proxy->anim = openanim(name, IB_rect); } if (seq->strip->proxy->anim==NULL) { - return 0; + return NULL; } return IMB_anim_absolute(seq->strip->proxy->anim, frameno); } if (seq_proxy_get_fname(context, seq, cfra, name) == 0) { - return 0; + return NULL; } if (BLI_exists(name)) { return IMB_loadiffname(name, IB_rect); } else { - return 0; + return NULL; } } @@ -1659,7 +1660,7 @@ static ImBuf * input_preprocess( } if(seq->flag & SEQ_MAKE_PREMUL) { - if(ibuf->depth == 32 && ibuf->zbuf == 0) { + if(ibuf->depth == 32 && ibuf->zbuf == NULL) { IMB_premultiply_alpha(ibuf); } } @@ -1678,8 +1679,8 @@ static ImBuf * input_preprocess( static ImBuf * copy_from_ibuf_still(SeqRenderData context, Sequence * seq, float nr) { - ImBuf * rval = 0; - ImBuf * ibuf = 0; + ImBuf * rval = NULL; + ImBuf * ibuf = NULL; if (nr == 0) { ibuf = seq_stripelem_cache_get( @@ -1828,7 +1829,7 @@ static ImBuf* seq_render_effect_strip_impl( static ImBuf * seq_render_scene_strip_impl( SeqRenderData context, Sequence * seq, float nr) { - ImBuf * ibuf = 0; + ImBuf * ibuf = NULL; float frame= seq->sfra + nr + seq->anim_startofs; float oldcfra; Object *oldcamera; @@ -2065,7 +2066,7 @@ static ImBuf * seq_render_strip(SeqRenderData context, Sequence * seq, float cfr } case SEQ_MOVIE: { - if(seq->anim==0) { + if(seq->anim==NULL) { BLI_join_dirfile(name, sizeof(name), seq->strip->dir, seq->strip->stripdata->name); BLI_path_abs(name, G.main->name); @@ -2248,11 +2249,11 @@ static ImBuf* seq_render_strip_stack( if (swap_input) { out = sh.execute(context, seq, cfra, facf, facf, - ibuf2, ibuf1, 0); + ibuf2, ibuf1, NULL); } else { out = sh.execute(context, seq, cfra, facf, facf, - ibuf1, ibuf2, 0); + ibuf1, ibuf2, NULL); } IMB_freeImBuf(ibuf1); @@ -2641,7 +2642,7 @@ ImBuf *give_ibuf_seq_threaded(SeqRenderData context, float cfra, int chanshown) } } - return e ? e->ibuf : 0; + return e ? e->ibuf : NULL; } /* Functions to free imbuf and anim data on changes */ @@ -2650,7 +2651,7 @@ static void free_anim_seq(Sequence *seq) { if(seq->anim) { IMB_free_anim(seq->anim); - seq->anim = 0; + seq->anim = NULL; } } @@ -3541,7 +3542,7 @@ static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence if (seq->strip->proxy) { seqn->strip->proxy = MEM_dupallocN(seq->strip->proxy); - seqn->strip->proxy->anim = 0; + seqn->strip->proxy->anim = NULL; } if (seq->strip->color_balance) { @@ -3550,19 +3551,19 @@ static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence } if(seq->type==SEQ_META) { - seqn->strip->stripdata = 0; + seqn->strip->stripdata = NULL; - seqn->seqbase.first= seqn->seqbase.last= 0; + seqn->seqbase.first= seqn->seqbase.last= NULL; /* WATCH OUT!!! - This metastrip is not recursively duplicated here - do this after!!! */ /* - seq_dupli_recursive(&seq->seqbase,&seqn->seqbase);*/ } else if(seq->type == SEQ_SCENE) { - seqn->strip->stripdata = 0; + seqn->strip->stripdata = NULL; if(seq->scene_sound) seqn->scene_sound = sound_scene_add_scene_sound(sce_audio, seqn, seq->startdisp, seq->enddisp, seq->startofs + seq->anim_startofs); } else if(seq->type == SEQ_MOVIE) { seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); - seqn->anim= 0; + seqn->anim= NULL; } else if(seq->type == SEQ_SOUND) { seqn->strip->stripdata = MEM_dupallocN(seq->strip->stripdata); @@ -3585,7 +3586,7 @@ static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence sh.copy(seq, seqn); } - seqn->strip->stripdata = 0; + seqn->strip->stripdata = NULL; } else { fprintf(stderr, "Aiiiiekkk! sequence type not " @@ -3620,7 +3621,7 @@ Sequence * seq_dupli_recursive(struct Scene *scene, struct Scene *scene_to, Sequ void seqbase_dupli_recursive(Scene *scene, Scene *scene_to, ListBase *nseqbase, ListBase *seqbase, int dupe_flag) { Sequence *seq; - Sequence *seqn = 0; + Sequence *seqn = NULL; Sequence *last_seq = seq_active_get(scene); for(seq= seqbase->first; seq; seq= seq->next) { diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 48d9a4e0dee..29c29fb5158 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -102,7 +102,7 @@ void space_transform_from_matrixs(SpaceTransform *data, float local[4][4], float { float itarget[4][4]; invert_m4_m4(itarget, target); - mul_serie_m4(data->local2target, itarget, local, 0, 0, 0, 0, 0, 0); + mul_serie_m4(data->local2target, itarget, local, NULL, NULL, NULL, NULL, NULL, NULL); invert_m4_m4(data->target2local, data->local2target); } diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index 06c6e0f197a..1d5f9b4c463 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -54,7 +54,7 @@ void freeSketch(SK_Sketch *sketch) MEM_freeN(sketch); } -SK_Sketch* createSketch() +SK_Sketch* createSketch(void) { SK_Sketch *sketch; @@ -102,7 +102,7 @@ void sk_freeStroke(SK_Stroke *stk) MEM_freeN(stk); } -SK_Stroke* sk_createStroke() +SK_Stroke* sk_createStroke(void) { SK_Stroke *stk; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 19f7884b4cf..ca8df76311d 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -161,7 +161,7 @@ typedef struct SB_thread_context { #define BFF_CLOSEVERT 2 /* collider vertex repulses face */ -float SoftHeunTol = 1.0f; /* humm .. this should be calculated from sb parameters and sizes */ +static float SoftHeunTol = 1.0f; /* humm .. this should be calculated from sb parameters and sizes */ /* local prototypes */ static void free_softbody_intern(SoftBody *sb); @@ -261,7 +261,7 @@ float operations still /* just an ID here to reduce the prob for killing objects ** ob->sumohandle points to we should not kill :) */ -const int CCD_SAVETY = 190561; +static const int CCD_SAVETY = 190561; typedef struct ccdf_minmax{ float minx,miny,minz,maxx,maxy,maxz; @@ -549,7 +549,7 @@ static void ccd_build_deflector_hash(Scene *scene, Object *vertexowner, GHash *h } /*+++ only with deflecting set */ - if(ob->pd && ob->pd->deflect && BLI_ghash_lookup(hash, ob) == 0) { + if(ob->pd && ob->pd->deflect && BLI_ghash_lookup(hash, ob) == NULL) { DerivedMesh *dm= NULL; if(ob->softflag & OB_SB_COLLFINAL) /* so maybe someone wants overkill to collide with subsurfed */ @@ -1655,7 +1655,7 @@ static void *exec_scan_for_ext_spring_forces(void *data) { SB_thread_context *pctx = (SB_thread_context*)data; _scan_for_ext_spring_forces(pctx->scene, pctx->ob, pctx->timenow, pctx->ifirst, pctx->ilast, pctx->do_effector); - return 0; + return NULL; } static void sb_sfesf_threads_run(Scene *scene, struct Object *ob, float timenow,int totsprings,int *UNUSED(ptr_to_break_func(void))) @@ -2382,7 +2382,7 @@ static void *exec_softbody_calc_forces(void *data) { SB_thread_context *pctx = (SB_thread_context*)data; _softbody_calc_forces_slice_in_a_thread(pctx->scene, pctx->ob, pctx->forcetime, pctx->timenow, pctx->ifirst, pctx->ilast, NULL, pctx->do_effector,pctx->do_deflector,pctx->fieldfactor,pctx->windfactor); - return 0; + return NULL; } static void sb_cf_threads_run(Scene *scene, Object *ob, float forcetime, float timenow,int totpoint,int *UNUSED(ptr_to_break_func(void)),struct ListBase *do_effector,int do_deflector,float fieldfactor, float windfactor) @@ -3822,7 +3822,7 @@ void SB_estimate_transform(Object *ob,float lloc[3],float lrot[3][3],float lscal { BodyPoint *bp; ReferenceVert *rp; - SoftBody *sb = 0; + SoftBody *sb = NULL; float (*opos)[3]; float (*rpos)[3]; float com[3],rcom[3]; diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 3dc2221e0c8..be6c4d22f9c 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -74,7 +74,7 @@ void sound_force_device(int device) force_device = device; } -void sound_init_once() +void sound_init_once(void) { AUD_initOnce(); } @@ -115,7 +115,7 @@ void sound_init(struct Main *bmain) #endif } -void sound_exit() +void sound_exit(void) { AUD_exit(); } @@ -382,7 +382,7 @@ void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, i AUD_moveSequencer(scene->sound_scene, handle, startframe / FPS, endframe / FPS, frameskip / FPS); } -void sound_start_play_scene(struct Scene *scene) +static void sound_start_play_scene(struct Scene *scene) { scene->sound_scene_handle = AUD_play(scene->sound_scene, 1); AUD_setLoop(scene->sound_scene_handle, -1); diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c index 7d39203cefc..b506ac55371 100644 --- a/source/blender/blenkernel/intern/suggestions.c +++ b/source/blender/blenkernel/intern/suggestions.c @@ -77,7 +77,7 @@ static void txttl_free_docs(void) { /* General tool functions */ /**************************/ -void free_texttools() { +void free_texttools(void) { txttl_free_suggest(); txttl_free_docs(); } @@ -191,15 +191,15 @@ void texttool_suggest_prefix(const char *prefix) { } } -void texttool_suggest_clear() { +void texttool_suggest_clear(void) { txttl_free_suggest(); } -SuggItem *texttool_suggest_first() { +SuggItem *texttool_suggest_first(void) { return suggestions.firstmatch; } -SuggItem *texttool_suggest_last() { +SuggItem *texttool_suggest_last(void) { return suggestions.lastmatch; } @@ -207,11 +207,11 @@ void texttool_suggest_select(SuggItem *sel) { suggestions.selected = sel; } -SuggItem *texttool_suggest_selected() { +SuggItem *texttool_suggest_selected(void) { return suggestions.selected; } -int *texttool_suggest_top() { +int *texttool_suggest_top(void) { return &suggestions.top; } @@ -243,10 +243,10 @@ void texttool_docs_show(const char *docs) { documentation[len] = '\0'; } -char *texttool_docs_get() { +char *texttool_docs_get(void) { return documentation; } -void texttool_docs_clear() { +void texttool_docs_clear(void) { txttl_free_docs(); } diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 0129e709505..6bd64e1e2f5 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -93,14 +93,14 @@ void open_plugin_tex(PluginTex *pit) int (*version)(void); /* init all the happy variables */ - pit->doit= 0; - pit->pname= 0; - pit->stnames= 0; - pit->varstr= 0; - pit->result= 0; - pit->cfra= 0; + pit->doit= NULL; + pit->pname= NULL; + pit->stnames= NULL; + pit->varstr= NULL; + pit->result= NULL; + pit->cfra= NULL; pit->version= 0; - pit->instance_init= 0; + pit->instance_init= NULL; /* clear the error list */ PIL_dynlib_get_error_as_string(NULL); @@ -113,12 +113,12 @@ void open_plugin_tex(PluginTex *pit) pit->handle= PIL_dynlib_open(pit->name); if(test_dlerr(pit->name, pit->name)) return; - if (pit->handle != 0) { + if (pit->handle != NULL) { /* find the address of the version function */ version= (int (*)(void)) PIL_dynlib_find_symbol(pit->handle, "plugin_tex_getversion"); if (test_dlerr(pit->name, "plugin_tex_getversion")) return; - if (version != 0) { + if (version != NULL) { pit->version= version(); if( pit->version >= 2 && pit->version <=6) { int (*info_func)(PluginInfo *); @@ -168,8 +168,8 @@ PluginTex *add_plugin_tex(char *str) strcpy(pit->name, str); open_plugin_tex(pit); - if(pit->doit==0) { - if(pit->handle==0) {;} //XXX error("no plugin: %s", str); + if(pit->doit==NULL) { + if(pit->handle==NULL) {;} //XXX error("no plugin: %s", str); else {;} //XXX error("in plugin: %s", str); MEM_freeN(pit); return NULL; @@ -193,7 +193,7 @@ PluginTex *add_plugin_tex(char *str) void free_plugin_tex(PluginTex *pit) { - if(pit==0) return; + if(pit==NULL) return; /* no PIL_dynlib_close: same plugin can be opened multiple times, 1 handle */ MEM_freeN(pit); @@ -619,7 +619,7 @@ void default_mtex(MTex *mtex) { mtex->texco= TEXCO_ORCO; mtex->mapto= MAP_COL; - mtex->object= 0; + mtex->object= NULL; mtex->projx= PROJ_X; mtex->projy= PROJ_Y; mtex->projz= PROJ_Z; @@ -630,7 +630,7 @@ void default_mtex(MTex *mtex) mtex->size[0]= 1.0; mtex->size[1]= 1.0; mtex->size[2]= 1.0; - mtex->tex= 0; + mtex->tex= NULL; mtex->texflag= MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE; mtex->colormodel= 0; mtex->r= 1.0; @@ -681,7 +681,7 @@ void default_mtex(MTex *mtex) /* ------------------------------------------------------------------------- */ -MTex *add_mtex() +MTex *add_mtex(void) { MTex *mtex; @@ -743,7 +743,7 @@ Tex *copy_texture(Tex *tex) texn= copy_libblock(tex); if(texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima); - else texn->ima= 0; + else texn->ima= NULL; #if 0 // XXX old animation system id_us_plus((ID *)texn->ipo); @@ -786,19 +786,19 @@ void make_local_texture(Tex *tex) * - mixed: make copy */ - if(tex->id.lib==0) return; + if(tex->id.lib==NULL) return; /* special case: ima always local immediately */ if(tex->ima) { - tex->ima->id.lib= 0; + tex->ima->id.lib= NULL; tex->ima->id.flag= LIB_LOCAL; - new_id(0, (ID *)tex->ima, 0); + new_id(NULL, (ID *)tex->ima, NULL); } if(tex->id.us==1) { - tex->id.lib= 0; + tex->id.lib= NULL; tex->id.flag= LIB_LOCAL; - new_id(0, (ID *)tex, 0); + new_id(NULL, (ID *)tex, NULL); return; } @@ -843,9 +843,9 @@ void make_local_texture(Tex *tex) } if(local && lib==0) { - tex->id.lib= 0; + tex->id.lib= NULL; tex->id.flag= LIB_LOCAL; - new_id(0, (ID *)tex, 0); + new_id(NULL, (ID *)tex, NULL); } else if(local && lib) { texn= copy_texture(tex); @@ -855,7 +855,7 @@ void make_local_texture(Tex *tex) while(ma) { for(a=0; amtex[a] && ma->mtex[a]->tex==tex) { - if(ma->id.lib==0) { + if(ma->id.lib==NULL) { ma->mtex[a]->tex= texn; texn->id.us++; tex->id.us--; @@ -868,7 +868,7 @@ void make_local_texture(Tex *tex) while(la) { for(a=0; amtex[a] && la->mtex[a]->tex==tex) { - if(la->id.lib==0) { + if(la->id.lib==NULL) { la->mtex[a]->tex= texn; texn->id.us++; tex->id.us--; @@ -881,7 +881,7 @@ void make_local_texture(Tex *tex) while(wrld) { for(a=0; amtex[a] && wrld->mtex[a]->tex==tex) { - if(wrld->id.lib==0) { + if(wrld->id.lib==NULL) { wrld->mtex[a]->tex= texn; texn->id.us++; tex->id.us--; @@ -893,7 +893,7 @@ void make_local_texture(Tex *tex) br= bmain->brush.first; while(br) { if(br->mtex.tex==tex) { - if(br->id.lib==0) { + if(br->id.lib==NULL) { br->mtex.tex= texn; texn->id.us++; tex->id.us--; @@ -943,8 +943,8 @@ Tex *give_current_object_texture(Object *ob) Material *ma; Tex *tex= NULL; - if(ob==0) return 0; - if(ob->totcol==0 && !(ob->type==OB_LAMP)) return 0; + if(ob==NULL) return NULL; + if(ob->totcol==0 && !(ob->type==OB_LAMP)) return NULL; if(ob->type==OB_LAMP) { tex= give_current_lamp_texture(ob->data); @@ -1124,7 +1124,7 @@ Tex *give_current_world_texture(World *world) MTex *mtex= NULL; Tex *tex= NULL; - if(!world) return 0; + if(!world) return NULL; mtex= world->mtex[(int)(world->texact)]; if(mtex) tex= mtex->tex; @@ -1175,7 +1175,7 @@ Tex *give_current_particle_texture(ParticleSettings *part) MTex *mtex= NULL; Tex *tex= NULL; - if(!part) return 0; + if(!part) return NULL; mtex= part->mtex[(int)(part->texact)]; if(mtex) tex= mtex->tex; diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 1b04589c1f2..c3a34e1942f 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -264,10 +264,10 @@ static struct bUnitCollection buNaturalRotCollection = {buNaturalRotDef, 0, 0, s #define UNIT_SYSTEM_TOT (((sizeof(bUnitSystems) / 9) / sizeof(void *)) - 1) static struct bUnitCollection *bUnitSystems[][9] = { - {0, 0, 0, 0, 0, &buNaturalRotCollection, &buNaturalTimeCollecton, 0, 0}, - {0, &buMetricLenCollecton, &buMetricAreaCollecton, &buMetricVolCollecton, &buMetricMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buMetricVelCollecton, &buMetricAclCollecton}, /* metric */ - {0, &buImperialLenCollecton, &buImperialAreaCollecton, &buImperialVolCollecton, &buImperialMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buImperialVelCollecton, &buImperialAclCollecton}, /* imperial */ - {0, 0, 0, 0, 0, 0, 0, 0, 0} + {NULL, NULL, NULL, NULL, NULL, &buNaturalRotCollection, &buNaturalTimeCollecton, NULL, NULL}, + {NULL, &buMetricLenCollecton, &buMetricAreaCollecton, &buMetricVolCollecton, &buMetricMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buMetricVelCollecton, &buMetricAclCollecton}, /* metric */ + {NULL, &buImperialLenCollecton, &buImperialAreaCollecton, &buImperialVolCollecton, &buImperialMassCollecton, &buNaturalRotCollection, &buNaturalTimeCollecton, &buImperialVelCollecton, &buImperialAclCollecton}, /* imperial */ + {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL} }; diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index a86b039e918..5412e44f0eb 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -38,6 +38,7 @@ #include "DNA_scene_types.h" #include "DNA_texture_types.h" +#include "BKE_world.h" #include "BKE_library.h" #include "BKE_animsys.h" #include "BKE_global.h" @@ -136,11 +137,11 @@ void make_local_world(World *wrld) * - mixed: make copy */ - if(wrld->id.lib==0) return; + if(wrld->id.lib==NULL) return; if(wrld->id.us==1) { - wrld->id.lib= 0; + wrld->id.lib= NULL; wrld->id.flag= LIB_LOCAL; - new_id(0, (ID *)wrld, 0); + new_id(NULL, (ID *)wrld, NULL); return; } @@ -156,7 +157,7 @@ void make_local_world(World *wrld) if(local && lib==0) { wrld->id.lib= 0; wrld->id.flag= LIB_LOCAL; - new_id(0, (ID *)wrld, 0); + new_id(NULL, (ID *)wrld, NULL); } else if(local && lib) { wrldn= copy_world(wrld); @@ -165,7 +166,7 @@ void make_local_world(World *wrld) sce= bmain->scene.first; while(sce) { if(sce->world==wrld) { - if(sce->id.lib==0) { + if(sce->id.lib==NULL) { sce->world= wrldn; wrldn->id.us++; wrld->id.us--; -- cgit v1.2.3 From fed5393043cd8c0c9282cc3bd8e0c8db2aa3ea24 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 13 Feb 2011 11:45:04 +0000 Subject: Fix for [#26053] Blender Crash with Particules Textures * Particle textures weren't handled properly on texture slot move operations. --- source/blender/blenkernel/intern/texture.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 6bd64e1e2f5..cf4fcbb4def 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -1051,6 +1051,10 @@ int give_active_mtex(ID *id, MTex ***mtex_ar, short *act) *mtex_ar= ((Lamp *)id)->mtex; if(act) *act= (((Lamp *)id)->texact); break; + case ID_PA: + *mtex_ar= ((ParticleSettings *)id)->mtex; + if(act) *act= (((ParticleSettings *)id)->texact); + break; default: *mtex_ar = NULL; if(act) *act= 0; -- cgit v1.2.3 From 7eb51a012b95df36c3529f6c7699273918fee341 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 13 Feb 2011 12:35:26 +0000 Subject: Some more fixes for particle textures: * Moving a texture slot didn't keep the moved slot active. * Copy & paste for particle textures didn't work. * New textures weren't freed properly. --- source/blender/blenkernel/intern/particle.c | 8 ++++++++ source/blender/blenkernel/intern/texture.c | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 3204a1c38e7..d1d5c13c3dd 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -366,6 +366,8 @@ static void fluid_free_settings(SPHFluidSettings *fluid) void psys_free_settings(ParticleSettings *part) { + MTex *mtex; + int a; BKE_free_animdata(&part->id); free_partdeflect(part->pd); free_partdeflect(part->pd2); @@ -377,6 +379,12 @@ void psys_free_settings(ParticleSettings *part) boid_free_settings(part->boids); fluid_free_settings(part->fluid); + + for(a=0; amtex[a]; + if(mtex && mtex->tex) mtex->tex->id.us--; + if(mtex) MEM_freeN(mtex); + } } void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics) diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index cf4fcbb4def..c22b1d32849 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -779,6 +779,7 @@ void make_local_texture(Tex *tex) World *wrld; Lamp *la; Brush *br; + ParticleSettings *pa; int a, local=0, lib=0; /* - only lib users: do nothing @@ -841,6 +842,16 @@ void make_local_texture(Tex *tex) } br= br->id.next; } + pa= bmain->particle.first; + while(pa) { + for(a=0; amtex[a] && pa->mtex[a]->tex==tex) { + if(pa->id.lib) lib= 1; + else local= 1; + } + } + pa= pa->id.next; + } if(local && lib==0) { tex->id.lib= NULL; @@ -901,6 +912,19 @@ void make_local_texture(Tex *tex) } br= br->id.next; } + pa= bmain->particle.first; + while(pa) { + for(a=0; amtex[a] && pa->mtex[a]->tex==tex) { + if(pa->id.lib==NULL) { + pa->mtex[a]->tex= texn; + texn->id.us++; + tex->id.us--; + } + } + } + pa= pa->id.next; + } } } @@ -1079,6 +1103,9 @@ void set_active_mtex(ID *id, short act) case ID_LA: ((Lamp *)id)->texact= act; break; + case ID_PA: + ((ParticleSettings *)id)->texact= act; + break; } } -- cgit v1.2.3 From c68a59175e8284a3475886152ecb886c6fae0f39 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 13 Feb 2011 13:07:12 +0000 Subject: corrected error from commit r34810. --- source/blender/blenkernel/intern/deform.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 7f51cfdc8b6..7967013c2d4 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -335,33 +335,34 @@ void defgroup_unique_name (bDeformGroup *dg, Object *ob) } /* finds the best possible flipped name. For renaming; check for unique names afterwards */ -/* if strip_number: removes number extensions */ -void flip_side_name (char *name, const char *from_name, int strip_number) +/* if strip_number: removes number extensions + * note: dont use sizeof() for 'name' or 'from_name' */ +void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_NAME], int strip_number) { int len; - char prefix[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The part before the facing */ - char suffix[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The part after the facing */ - char replace[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The replacement string */ - char number[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The number extension string */ + char prefix[MAX_VGROUP_NAME]= ""; /* The part before the facing */ + char suffix[MAX_VGROUP_NAME]= ""; /* The part after the facing */ + char replace[MAX_VGROUP_NAME]= ""; /* The replacement string */ + char number[MAX_VGROUP_NAME]= ""; /* The number extension string */ char *index=NULL; - len= strlen(from_name); + len= BLI_strnlen(from_name, MAX_VGROUP_NAME); if(len<3) return; // we don't do names like .R or .L - strcpy(name, from_name); + BLI_strncpy(name, from_name, MAX_VGROUP_NAME); /* 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); + BLI_strncpy(number, index, sizeof(number)); *index= 0; - len= strlen(name); + len= BLI_strnlen(name, MAX_VGROUP_NAME); } } - strcpy(prefix, name); + BLI_strncpy(prefix, name, sizeof(prefix)); #define IS_SEPARATOR(a) ((a)=='.' || (a)==' ' || (a)=='-' || (a)=='_') @@ -445,7 +446,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); + BLI_snprintf (name, MAX_VGROUP_NAME, "%s%s%s%s", prefix, replace, suffix, number); } float defvert_find_weight(const struct MDeformVert *dvert, const int group_num) -- cgit v1.2.3 From 7b4c4183f38a423f8129af132ef676771fb79459 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Sun, 13 Feb 2011 13:50:19 +0000 Subject: Small addition to particle grid distribution: * New option to distribute particles in a hexagonal grid. * This is much more stable for fluids than normal grid distribution and looks quite nice otherwise too :) * Also some small scale code cleanup of grid distribution code. --- source/blender/blenkernel/intern/particle_system.c | 68 +++++++++++++--------- 1 file changed, 42 insertions(+), 26 deletions(-) (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 e29293a3087..65bd4f110b4 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -411,8 +411,8 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) mv=mvert; /* find bounding box of dm */ - VECCOPY(min,mv->co); - VECCOPY(max,mv->co); + copy_v3_v3(min, mv->co); + copy_v3_v3(max, mv->co); mv++; for(i=1; i=delta[1])?0:((delta[1]>=delta[2])?1:2); - + axis = (delta[0]>=delta[1]) ? 0 : ((delta[1]>=delta[2]) ? 1 : 2); + d = delta[axis]/(float)res; - size[axis]=res; - size[(axis+1)%3]=(int)ceil(delta[(axis+1)%3]/d); - size[(axis+2)%3]=(int)ceil(delta[(axis+2)%3]/d); + size[axis] = res; + size[(axis+1)%3] = (int)ceil(delta[(axis+1)%3]/d); + size[(axis+2)%3] = (int)ceil(delta[(axis+2)%3]/d); /* float errors grrr.. */ size[(axis+1)%3] = MIN2(size[(axis+1)%3],res); @@ -452,11 +452,11 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) for(i=0,p=0,pa=psys->particles; ifuv[0]=min[0]+(float)i*d; - pa->fuv[1]=min[1]+(float)j*d; - pa->fuv[2]=min[2]+(float)k*d; + pa->fuv[0] = min[0] + (float)i*d; + pa->fuv[1] = min[1] + (float)j*d; + pa->fuv[2] = min[2] + (float)k*d; pa->flag |= PARS_UNEXIST; - pa->hair_index=0; /* abused in volume calculation */ + pa->hair_index = 0; /* abused in volume calculation */ } } } @@ -467,9 +467,9 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) pa=psys->particles; - min[0]-=d/2.0f; - min[1]-=d/2.0f; - min[2]-=d/2.0f; + min[0] -= d/2.0f; + min[1] -= d/2.0f; + min[2] -= d/2.0f; for(i=0,mv=mvert; ico,min); @@ -501,20 +501,20 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) for(a2=0; a2particles + a1*a1mul + a2*a2mul; - VECCOPY(co1,pa->fuv); - co1[a]-= d < delta[a] ? d/2.f : delta[a]/2.f; - VECCOPY(co2,co1); - co2[a]+=delta[a] + 0.001f*d; - co1[a]-=0.001f*d; + pa = psys->particles + a1*a1mul + a2*a2mul; + copy_v3_v3(co1, pa->fuv); + co1[a] -= d < delta[a] ? d/2.f : delta[a]/2.f; + copy_v3_v3(co2, co1); + co2[a] += delta[a] + 0.001f*d; + co1[a] -= 0.001f*d; /* lets intersect the faces */ for(i=0; iv1].co); - VECCOPY(v2,mvert[mface->v2].co); - VECCOPY(v3,mvert[mface->v3].co); + copy_v3_v3(v1, mvert[mface->v1].co); + copy_v3_v3(v2, mvert[mface->v2].co); + copy_v3_v3(v3, mvert[mface->v3].co); - if(isect_axial_line_tri_v3(a,co1, co2, v2, v3, v1, &lambda)){ + if(isect_axial_line_tri_v3(a, co1, co2, v2, v3, v1, &lambda)){ if(from==PART_FROM_FACE) (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST; else /* store number of intersections */ @@ -522,9 +522,9 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) } if(mface->v4){ - VECCOPY(v4,mvert[mface->v4].co); + copy_v3_v3(v4, mvert[mface->v4].co); - if(isect_axial_line_tri_v3(a,co1, co2, v4, v1, v3, &lambda)){ + if(isect_axial_line_tri_v3(a, co1, co2, v4, v1, v3, &lambda)){ if(from==PART_FROM_FACE) (pa+(int)(lambda*size[a])*a0mul)->flag &= ~PARS_UNEXIST; else @@ -549,6 +549,22 @@ static void distribute_particles_in_grid(DerivedMesh *dm, ParticleSystem *psys) } } + if(psys->part->flag & PART_GRID_HEXAGONAL) { + for(i=0,p=0,pa=psys->particles; ifuv[0] += d/2.f; + + if(k%2) { + pa->fuv[0] += d/2.f; + pa->fuv[1] += d/2.f; + } + } + } + } + } + if(psys->part->flag & PART_GRID_INVERT){ for(i=0; i Date: Sun, 13 Feb 2011 15:02:21 +0000 Subject: warning cleanup. - fix mistake with grease pencil UI (&& was intended but & used). - use (void) rather then () across _all_ blenders code. - a few minor edits, don't shadow stack variables in roll calculation & avoid running memset() for VBO vertex map. --- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/suggestions.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 69699c85203..c2ec463c708 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -2390,7 +2390,7 @@ void BKE_ptcache_set_continue_physics(Main *bmain, Scene *scene, int enable) } } -int BKE_ptcache_get_continue_physics() +int BKE_ptcache_get_continue_physics(void) { return CONTINUE_PHYSICS; } diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c index b506ac55371..7ec6d84d285 100644 --- a/source/blender/blenkernel/intern/suggestions.c +++ b/source/blender/blenkernel/intern/suggestions.c @@ -88,7 +88,7 @@ void texttool_text_set_active(Text *text) { activeToolText = text; } -void texttool_text_clear() { +void texttool_text_clear(void) { free_texttools(); activeToolText = NULL; } -- cgit v1.2.3 From 8ea0b4685cadd7c7bede9017d07a296bab635469 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Feb 2011 03:15:55 +0000 Subject: misc small changes: - rename rna collection structs Main prefix to BlendData: eg, MainObjects --> BlendDataObjects - printing python collection now prints its type (when available) - renamed shadowed vars in bpy_rna.c. - when making functions static I also made debugging/test functions static, reverse and add definitions to headers instead. --- 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 4ad3b8bb3cf..473be5a3ee0 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -227,7 +227,7 @@ void make_local_brush(Brush *brush) } } -static void brush_debug_print_state(Brush *br) +void brush_debug_print_state(Brush *br) { /* create a fake brush and set it to the defaults */ Brush def= {{NULL}}; -- cgit v1.2.3 From 8b7482892b2ecb456be60b42fe1625156d19e954 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Feb 2011 17:55:27 +0000 Subject: made most variables which are only used in a single file and not defined in header static for blenlib, blenkernel and editors. --- source/blender/blenkernel/intern/CCGSubSurf.c | 6 +++--- source/blender/blenkernel/intern/armature.c | 4 ++-- source/blender/blenkernel/intern/collision.c | 4 ++-- source/blender/blenkernel/intern/constraint.c | 3 +-- source/blender/blenkernel/intern/object.c | 3 ++- source/blender/blenkernel/intern/particle_system.c | 6 +++--- source/blender/blenkernel/intern/smoke.c | 2 +- source/blender/blenkernel/intern/writeframeserver.c | 3 +-- 8 files changed, 15 insertions(+), 16 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 8c265a1f8c9..1d6aa9bd6d7 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -239,15 +239,15 @@ static int _edge_isBoundary(CCGEdge *e); /***/ -enum { +static enum { Vert_eEffected= (1<<0), Vert_eChanged= (1<<1), Vert_eSeam= (1<<2), } VertFlags; -enum { +static enum { Edge_eEffected= (1<<0), } CCGEdgeFlags; -enum { +static enum { Face_eEffected= (1<<0), } FaceFlags; diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index cc01438fd5d..3174954423f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -2100,7 +2100,7 @@ void pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4]) /* loc/rot/size to mat4 */ /* used in constraint.c too */ -void chan_calc_mat(bPoseChannel *pchan) +void pchan_calc_mat(bPoseChannel *pchan) { /* this is just a wrapper around the copy of this function which calculates the matrix * and stores the result in any given channel @@ -2256,7 +2256,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti parchan= pchan->parent; /* this gives a chan_mat with actions (ipos) results */ - if(do_extra) chan_calc_mat(pchan); + if(do_extra) pchan_calc_mat(pchan); else unit_m4(pchan->chan_mat); /* construct the posemat based on PoseChannels, that we do before applying constraints */ diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 02b3de83ee1..3c0453c82a5 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -482,7 +482,7 @@ DO_INLINE void collision_interpolateOnTriangle ( float to[3], float v1[3], float } -int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, CollPair *collision_end ) +static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifierData *collmd, CollPair *collpair, CollPair *collision_end ) { int result = 0; Cloth *cloth1; @@ -598,7 +598,7 @@ int cloth_collision_response_static ( ClothModifierData *clmd, CollisionModifier } //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 ) +static CollPair* cloth_collision ( ModifierData *md1, ModifierData *md2, BVHTreeOverlap *overlap, CollPair *collpair ) { ClothModifierData *clmd = ( ClothModifierData * ) md1; CollisionModifierData *collmd = ( CollisionModifierData * ) md2; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index b3f83019ff1..e7efc09ec6e 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -2149,7 +2149,6 @@ static void actcon_flush_tars (bConstraint *con, ListBase *list, short nocopy) static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { - extern void chan_calc_mat(bPoseChannel *chan); bActionConstraint *data = con->data; if (VALID_CONS_TARGET(ct)) { @@ -2217,7 +2216,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint what_does_obaction(cob->scene, cob->ob, &workob, pose, data->act, pchan->name, t); /* convert animation to matrices for use here */ - chan_calc_mat(tchan); + pchan_calc_mat(tchan); copy_m4_m4(ct->matrix, tchan->chan_mat); /* Clean up */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 6149f7d380b..d0f2232a683 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1626,7 +1626,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) /* there is also a timing calculation in drawobject() */ -int no_speed_curve= 0; +static int no_speed_curve= 0; void disable_speed_curve(int val) { @@ -1775,6 +1775,7 @@ void object_to_mat4(Object *ob, float mat[][4]) add_v3_v3v3(mat[3], ob->loc, ob->dloc); } +/* extern */ int enable_cu_speed= 1; static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 65bd4f110b4..c1a6558aea3 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2217,7 +2217,7 @@ static void psys_update_effectors(ParticleSimulationData *sim) ***********************************************************************************************************/ #define PSYS_FLUID_SPRINGS_INITIAL_SIZE 256 -ParticleSpring *add_fluid_spring(ParticleSystem *psys, ParticleSpring *spring) +static ParticleSpring *add_fluid_spring(ParticleSystem *psys, ParticleSpring *spring) { /* Are more refs required? */ if(psys->alloc_fluidsprings == 0 || psys->fluid_springs == NULL) { @@ -2236,7 +2236,7 @@ ParticleSpring *add_fluid_spring(ParticleSystem *psys, ParticleSpring *spring) return psys->fluid_springs + psys->tot_fluidsprings - 1; } -void delete_fluid_spring(ParticleSystem *psys, int j) +static void delete_fluid_spring(ParticleSystem *psys, int j) { if (j != psys->tot_fluidsprings - 1) psys->fluid_springs[j] = psys->fluid_springs[psys->tot_fluidsprings - 1]; @@ -2249,7 +2249,7 @@ void delete_fluid_spring(ParticleSystem *psys, int j) } } -EdgeHash *build_fluid_springhash(ParticleSystem *psys) +static EdgeHash *build_fluid_springhash(ParticleSystem *psys) { EdgeHash *springhash = NULL; ParticleSpring *spring; diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 8039d729842..1d80e989da4 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -135,7 +135,7 @@ static void fill_scs_points(Object *ob, DerivedMesh *dm, SmokeCollSettings *scs) #define TRI_UVOFFSET (1./4.) -int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, DerivedMesh *dm) +static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, DerivedMesh *dm) { if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain && !smd->domain->fluid) { diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index eb1c66604f8..3cb3d7e038b 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -49,11 +49,10 @@ #include "BLI_utildefines.h" - +#include "BKE_writeframeserver.h" #include "BKE_global.h" #include "BKE_report.h" - #include "DNA_scene_types.h" static int sock; -- cgit v1.2.3 From 20553d4064e790f42fe707b8b6c5e6451e983eb7 Mon Sep 17 00:00:00 2001 From: "M.G. Kishalmi" Date: Mon, 14 Feb 2011 18:18:46 +0000 Subject: This commit will switch blender to use tangent space generated within the two files mikktspace.h and mikktspace.c. These are standalone files which can be redistributed into any other application and regenerate the same tangent spaces. The implementation is independent of the ordering of faces and the vertex ordering of faces. --- source/blender/blenkernel/intern/DerivedMesh.c | 266 ++- source/blender/blenkernel/intern/cdderivedmesh.c | 20 +- source/blender/blenkernel/intern/customdata.c | 2 +- source/blender/blenkernel/intern/mikktspace.c | 1886 ++++++++++++++++++++++ source/blender/blenkernel/intern/subsurf_ccg.c | 2 +- 5 files changed, 2103 insertions(+), 73 deletions(-) create mode 100644 source/blender/blenkernel/intern/mikktspace.c (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index eedc2636991..79e23b77306 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -948,7 +948,7 @@ static void emDM_drawMappedFacesGLSL(DerivedMesh *dm, } \ if(attribs.tottang) { \ float *tang = attribs.tang.array[i*4 + vert]; \ - glVertexAttrib3fvARB(attribs.tang.glIndex, tang); \ + glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ } \ } @@ -2481,6 +2481,111 @@ float *mesh_get_mapped_verts_nors(Scene *scene, Object *ob) /* ******************* GLSL ******************** */ +typedef struct +{ + float * precomputedFaceNormals; + MTFace * mtface; // texture coordinates + MFace * mface; // indices + MVert * mvert; // vertices & normals + float (*orco)[3]; + float (*tangent)[4]; // destination + int numFaces; + +} SGLSLMeshToTangent; + +// interface +#include "mikktspace.h" + +static int GetNumFaces(const SMikkTSpaceContext * pContext) +{ + SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData; + return pMesh->numFaces; +} + +static int GetNumVertsOfFace(const SMikkTSpaceContext * pContext, const int face_num) +{ + SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData; + return pMesh->mface[face_num].v4!=0 ? 4 : 3; +} + +static void GetPosition(const SMikkTSpaceContext * pContext, float fPos[], const int face_num, const int vert_index) +{ + //assert(vert_index>=0 && vert_index<4); + SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData; + unsigned int indices[] = { pMesh->mface[face_num].v1, pMesh->mface[face_num].v2, + pMesh->mface[face_num].v3, pMesh->mface[face_num].v4 }; + VECCOPY(fPos, pMesh->mvert[indices[vert_index]].co); +} + +static void GetTextureCoordinate(const SMikkTSpaceContext * pContext, float fUV[], const int face_num, const int vert_index) +{ + //assert(vert_index>=0 && vert_index<4); + SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData; + + if(pMesh->mtface!=NULL) + { + float * uv = pMesh->mtface[face_num].uv[vert_index]; + fUV[0]=uv[0]; fUV[1]=uv[1]; + } + else + { + unsigned int indices[] = { pMesh->mface[face_num].v1, pMesh->mface[face_num].v2, + pMesh->mface[face_num].v3, pMesh->mface[face_num].v4 }; + + map_to_sphere( &fUV[0], &fUV[1],pMesh->orco[indices[vert_index]][0], pMesh->orco[indices[vert_index]][1], pMesh->orco[indices[vert_index]][2]); + } +} + +static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const int face_num, const int vert_index) +{ + //assert(vert_index>=0 && vert_index<4); + SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData; + unsigned int indices[] = { pMesh->mface[face_num].v1, pMesh->mface[face_num].v2, + pMesh->mface[face_num].v3, pMesh->mface[face_num].v4 }; + + const int smoothnormal = (pMesh->mface[face_num].flag & ME_SMOOTH); + if(!smoothnormal) // flat + { + if(pMesh->precomputedFaceNormals) + { + VECCOPY(fNorm, &pMesh->precomputedFaceNormals[3*face_num]); + } + else + { + float nor[3]; + float * p0, * p1, * p2; + const int iGetNrVerts = pMesh->mface[face_num].v4!=0 ? 4 : 3; + p0 = pMesh->mvert[indices[0]].co; p1 = pMesh->mvert[indices[1]].co; p2 = pMesh->mvert[indices[2]].co; + if(iGetNrVerts==4) + { + float * p3 = pMesh->mvert[indices[3]].co; + normal_quad_v3( nor, p0, p1, p2, p3); + } + else { + normal_tri_v3(nor, p0, p1, p2); + } + VECCOPY(fNorm, nor); + } + } + else + { + int i=0; + short * no = pMesh->mvert[indices[vert_index]].no; + for(i=0; i<3; i++) + fNorm[i]=no[i]/32767.0f; + normalize_v3(fNorm); + } +} +static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int face_num, const int iVert) +{ + //assert(vert_index>=0 && vert_index<4); + SGLSLMeshToTangent * pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData; + float * pRes = pMesh->tangent[4*face_num+iVert]; + VECCOPY(pRes, fvTangent); + pRes[3]=fSign; +} + + void DM_add_tangent_layer(DerivedMesh *dm) { /* mesh vars */ @@ -2489,14 +2594,17 @@ void DM_add_tangent_layer(DerivedMesh *dm) MVert *mvert, *v1, *v2, *v3, *v4; MemArena *arena= NULL; VertexTangent **vtangents= NULL; - float (*orco)[3]= NULL, (*tangent)[3]; + float (*orco)[3]= NULL, (*tangent)[4]; float *uv1, *uv2, *uv3, *uv4, *vtang; float fno[3], tang[3], uv[4][2]; - int i, j, len, mf_vi[4], totvert, totface; + int i, j, len, mf_vi[4], totvert, totface, iCalcNewMethod; + float *nors; if(CustomData_get_layer_index(&dm->faceData, CD_TANGENT) != -1) return; + nors = dm->getFaceDataArray(dm, CD_NORMAL); + /* check we have all the needed layers */ totvert= dm->getNumVerts(dm); totface= dm->getNumFaces(dm); @@ -2519,72 +2627,108 @@ void DM_add_tangent_layer(DerivedMesh *dm) arena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "tangent layer arena"); BLI_memarena_use_calloc(arena); vtangents= MEM_callocN(sizeof(VertexTangent*)*totvert, "VertexTangent"); - - /* sum tangents at connected vertices */ - for(i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++) { - v1= &mvert[mf->v1]; - v2= &mvert[mf->v2]; - v3= &mvert[mf->v3]; - - if (mf->v4) { - v4= &mvert[mf->v4]; - normal_quad_v3( fno,v4->co, v3->co, v2->co, v1->co); - } - else { - v4= NULL; - normal_tri_v3( fno,v3->co, v2->co, v1->co); - } - - if(mtface) { - uv1= tf->uv[0]; - uv2= tf->uv[1]; - uv3= tf->uv[2]; - uv4= tf->uv[3]; - } - else { - uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; - map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); - map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); - map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); - if(v4) - map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); - } + + // new computation method + iCalcNewMethod = 1; + if(iCalcNewMethod!=0) + { + SGLSLMeshToTangent mesh2tangent; + SMikkTSpaceContext sContext; + SMikkTSpaceInterface sInterface; + memset(&mesh2tangent, 0, sizeof(SGLSLMeshToTangent)); + memset(&sContext, 0, sizeof(SMikkTSpaceContext)); + memset(&sInterface, 0, sizeof(SMikkTSpaceInterface)); + + mesh2tangent.precomputedFaceNormals = nors; + mesh2tangent.mtface = mtface; + mesh2tangent.mface = mface; + mesh2tangent.mvert = mvert; + mesh2tangent.orco = orco; + mesh2tangent.tangent = tangent; + mesh2tangent.numFaces = totface; + + sContext.m_pUserData = &mesh2tangent; + sContext.m_pInterface = &sInterface; + sInterface.m_getNumFaces = GetNumFaces; + sInterface.m_getNumVerticesOfFace = GetNumVertsOfFace; + sInterface.m_getPosition = GetPosition; + sInterface.m_getTexCoord = GetTextureCoordinate; + sInterface.m_getNormal = GetNormal; + sInterface.m_setTSpaceBasic = SetTSpace; + + // 0 if failed + iCalcNewMethod = genTangSpaceDefault(&sContext); + } + + if(!iCalcNewMethod) + { + /* sum tangents at connected vertices */ + for(i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++) { + v1= &mvert[mf->v1]; + v2= &mvert[mf->v2]; + v3= &mvert[mf->v3]; + + if (mf->v4) { + v4= &mvert[mf->v4]; + normal_quad_v3( fno,v4->co, v3->co, v2->co, v1->co); + } + else { + v4= NULL; + normal_tri_v3( fno,v3->co, v2->co, v1->co); + } - tangent_from_uv(uv1, uv2, uv3, v1->co, v2->co, v3->co, fno, tang); - sum_or_add_vertex_tangent(arena, &vtangents[mf->v1], tang, uv1); - sum_or_add_vertex_tangent(arena, &vtangents[mf->v2], tang, uv2); - sum_or_add_vertex_tangent(arena, &vtangents[mf->v3], tang, uv3); + if(mtface) { + uv1= tf->uv[0]; + uv2= tf->uv[1]; + uv3= tf->uv[2]; + uv4= tf->uv[3]; + } + else { + uv1= uv[0]; uv2= uv[1]; uv3= uv[2]; uv4= uv[3]; + map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); + map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); + map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); + if(v4) + map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); + } - if(mf->v4) { - v4= &mvert[mf->v4]; - - tangent_from_uv(uv1, uv3, uv4, v1->co, v3->co, v4->co, fno, tang); + tangent_from_uv(uv1, uv2, uv3, v1->co, v2->co, v3->co, fno, tang); sum_or_add_vertex_tangent(arena, &vtangents[mf->v1], tang, uv1); + sum_or_add_vertex_tangent(arena, &vtangents[mf->v2], tang, uv2); sum_or_add_vertex_tangent(arena, &vtangents[mf->v3], tang, uv3); - sum_or_add_vertex_tangent(arena, &vtangents[mf->v4], tang, uv4); + + if(mf->v4) { + v4= &mvert[mf->v4]; + + tangent_from_uv(uv1, uv3, uv4, v1->co, v3->co, v4->co, fno, tang); + sum_or_add_vertex_tangent(arena, &vtangents[mf->v1], tang, uv1); + sum_or_add_vertex_tangent(arena, &vtangents[mf->v3], tang, uv3); + sum_or_add_vertex_tangent(arena, &vtangents[mf->v4], tang, uv4); + } } - } - /* write tangent to layer */ - for(i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++, tangent+=4) { - len= (mf->v4)? 4 : 3; - - if(mtface == NULL) { - map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); - map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); - map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); - if(len==4) - map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); - } + /* write tangent to layer */ + for(i=0, tf=mtface, mf=mface; i < totface; mf++, tf++, i++, tangent+=4) { + len= (mf->v4)? 4 : 3; + + if(mtface == NULL) { + map_to_sphere( &uv[0][0], &uv[0][1],orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); + map_to_sphere( &uv[1][0], &uv[1][1],orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); + map_to_sphere( &uv[2][0], &uv[2][1],orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); + if(len==4) + map_to_sphere( &uv[3][0], &uv[3][1],orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); + } - mf_vi[0]= mf->v1; - mf_vi[1]= mf->v2; - mf_vi[2]= mf->v3; - mf_vi[3]= mf->v4; + mf_vi[0]= mf->v1; + mf_vi[1]= mf->v2; + mf_vi[2]= mf->v3; + mf_vi[3]= mf->v4; - for(j=0; juv[j] : uv[j]); - normalize_v3_v3(tangent[j], vtang); + for(j=0; juv[j] : uv[j]); + normalize_v3_v3(tangent[j], vtang); + ((float *) tangent[j])[3]=1.0f; + } } } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index abf2257877b..9a04c75db07 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1066,7 +1066,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } \ if(attribs.tottang) { \ float *tang = attribs.tang.array[a*4 + vert]; \ - glVertexAttrib3fvARB(attribs.tang.glIndex, tang); \ + glVertexAttrib4fvARB(attribs.tang.glIndex, tang); \ } \ if(smoothnormal) \ glNormal3sv(mvert[index].no); \ @@ -1158,7 +1158,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } if(attribs.tottang) { datatypes[numdata].index = attribs.tang.glIndex; - datatypes[numdata].size = 3; + datatypes[numdata].size = 4; datatypes[numdata].type = GL_FLOAT; numdata++; } @@ -1248,12 +1248,12 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } if(attribs.tottang) { float *tang = attribs.tang.array[a*4 + 0]; - VECCOPY((float *)&varray[elementsize*curface*3+offset], tang); + QUATCOPY((float *)&varray[elementsize*curface*3+offset], tang); tang = attribs.tang.array[a*4 + 1]; - VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize], tang); + QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize], tang); tang = attribs.tang.array[a*4 + 2]; - VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); - offset += sizeof(float)*3; + QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); + offset += sizeof(float)*4; } } curface++; @@ -1288,12 +1288,12 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, int (*setMaterial)(int, vo } if(attribs.tottang) { float *tang = attribs.tang.array[a*4 + 2]; - VECCOPY((float *)&varray[elementsize*curface*3+offset], tang); + QUATCOPY((float *)&varray[elementsize*curface*3+offset], tang); tang = attribs.tang.array[a*4 + 3]; - VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize], tang); + QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize], tang); tang = attribs.tang.array[a*4 + 0]; - VECCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); - offset += sizeof(float)*3; + QUATCOPY((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); + offset += sizeof(float)*4; } } curface++; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 7788f9f28a2..87fe545644a 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -829,7 +829,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { {sizeof(MTexPoly), "MTexPoly", 1, "Face Texture", NULL, NULL, NULL, NULL, NULL}, {sizeof(MLoopUV), "MLoopUV", 1, "UV coord", NULL, NULL, layerInterp_mloopuv, NULL, NULL}, {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL, layerDefault_mloopcol}, - {sizeof(float)*3*4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + {sizeof(float)*4*4, "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, {sizeof(MDisps), "MDisps", 1, NULL, layerCopy_mdisps, layerFree_mdisps, layerInterp_mdisps, layerSwap_mdisps, NULL, layerRead_mdisps, layerWrite_mdisps, layerFilesize_mdisps, layerValidate_mdisps}, diff --git a/source/blender/blenkernel/intern/mikktspace.c b/source/blender/blenkernel/intern/mikktspace.c new file mode 100644 index 00000000000..83623a13db8 --- /dev/null +++ b/source/blender/blenkernel/intern/mikktspace.c @@ -0,0 +1,1886 @@ +/** + * Copyright (C) 2011 by Morten S. Mikkelsen + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ + +#include +#include +#include +#include +#include +#include +#include "mikktspace.h" + +#define TFALSE 0 +#define TTRUE 1 + +#ifndef M_PI +#define M_PI 3.1415926535897932384626433832795 +#endif + +#define INTERNAL_RND_SORT_SEED 39871946 + +// internal structure +typedef struct +{ + float x, y, z; +} SVec3; + +tbool veq( const SVec3 v1, const SVec3 v2 ) +{ + return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z); +} + +const SVec3 vadd( const SVec3 v1, const SVec3 v2 ) +{ + SVec3 vRes; + + vRes.x = v1.x + v2.x; + vRes.y = v1.y + v2.y; + vRes.z = v1.z + v2.z; + + return vRes; +} + + +const SVec3 vsub( const SVec3 v1, const SVec3 v2 ) +{ + SVec3 vRes; + + vRes.x = v1.x - v2.x; + vRes.y = v1.y - v2.y; + vRes.z = v1.z - v2.z; + + return vRes; +} + +const SVec3 vscale(const float fS, const SVec3 v) +{ + SVec3 vRes; + + vRes.x = fS * v.x; + vRes.y = fS * v.y; + vRes.z = fS * v.z; + + return vRes; +} + +float LengthSquared( const SVec3 v ) +{ + return v.x*v.x + v.y*v.y + v.z*v.z; +} + +float Length( const SVec3 v ) +{ + return sqrtf(LengthSquared(v)); +} + +const SVec3 Normalize( const SVec3 v ) +{ + return vscale(1 / Length(v), v); +} + +const float vdot( const SVec3 v1, const SVec3 v2) +{ + return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; +} + + +tbool NotZero(const float fX) +{ + // could possibly use FLT_EPSILON instead + return fabsf(fX) > FLT_MIN; +} + +tbool VNotZero(const SVec3 v) +{ + // might change this to an epsilon based test + return NotZero(v.x) || NotZero(v.y) || NotZero(v.z); +} + + + +typedef struct +{ + int iNrFaces; + int * pTriMembers; +} SSubGroup; + +typedef struct +{ + int iNrFaces; + int * pFaceIndices; + int iVertexRepresentitive; + tbool bOrientPreservering; +} SGroup; + +// +#define MARK_DEGENERATE 1 +#define QUAD_ONE_DEGEN_TRI 2 +#define GROUP_WITH_ANY 4 +#define ORIENT_PRESERVING 8 + + + +typedef struct +{ + int FaceNeighbors[3]; + SGroup * AssignedGroup[3]; + + // normalized first order face derivatives + SVec3 vOs, vOt; + float fMagS, fMagT; // original magnitudes + + // determines if the current and the next triangle are a quad. + int iOrgFaceNumber; + int iFlag, iTSpacesOffs; + unsigned char vert_num[4]; +} STriInfo; + +typedef struct +{ + SVec3 vOs; + float fMagS; + SVec3 vOt; + float fMagT; + int iCounter; // this is to average back into quads. + tbool bOrient; +} STSpace; + +int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); +void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); +void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); +int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn); +tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[], + const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, + const SMikkTSpaceContext * pContext); + +int MakeIndex(const int iFace, const int iVert) +{ + assert(iVert>=0 && iVert<4 && iFace>=0); + return (iFace<<2) | (iVert&0x3); +} + +void IndexToData(int * piFace, int * piVert, const int iIndexIn) +{ + piVert[0] = iIndexIn&0x3; + piFace[0] = iIndexIn>>2; +} + +const STSpace AvgTSpace(const STSpace * pTS0, const STSpace * pTS1) +{ + STSpace ts_res; + + // this if is important. Due to floating point precision + // averaging when ts0==ts1 will cause a slight difference + // which results in tangent space splits later on + if(pTS0->fMagS==pTS1->fMagS && pTS0->fMagT==pTS1->fMagT && + veq(pTS0->vOs,pTS1->vOs) && veq(pTS0->vOt, pTS1->vOt)) + { + ts_res.fMagS = pTS0->fMagS; + ts_res.fMagT = pTS0->fMagT; + ts_res.vOs = pTS0->vOs; + ts_res.vOt = pTS0->vOt; + } + else + { + ts_res.fMagS = 0.5f*(pTS0->fMagS+pTS1->fMagS); + ts_res.fMagT = 0.5f*(pTS0->fMagT+pTS1->fMagT); + ts_res.vOs = vadd(pTS0->vOs,pTS1->vOs); + ts_res.vOt = vadd(pTS0->vOt,pTS1->vOt); + if( VNotZero(ts_res.vOs) ) ts_res.vOs = Normalize(ts_res.vOs); + if( VNotZero(ts_res.vOt) ) ts_res.vOt = Normalize(ts_res.vOt); + } + + return ts_res; +} + + + +const SVec3 GetPosition(const SMikkTSpaceContext * pContext, const int index); +const SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index); +const SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index); + + +// degen triangles +void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris); +void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris); + + +tbool genTangSpaceDefault(const SMikkTSpaceContext * pContext) +{ + return genTangSpace(pContext, 180.0f); +} + +tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThreshold) +{ + // count nr_triangles + int * piTriListIn = NULL, * piGroupTrianglesBuffer = NULL; + STriInfo * pTriInfos = NULL; + SGroup * pGroups = NULL; + STSpace * psTspace = NULL; + int iNrTrianglesIn = 0, f=0, t=0, i=0; + int iNrTSPaces = 0, iTotTris = 0, iDegenTriangles = 0, iNrMaxGroups = 0; + int iNrActiveGroups = 0, index = 0; + const int iNrFaces = pContext->m_pInterface->m_getNumFaces(pContext); + tbool bRes = TFALSE; + const float fThresCos = (const float) cos((fAngularThreshold*M_PI)/180); + + // verify all call-backs have been set + if( pContext->m_pInterface->m_getNumFaces==NULL || + pContext->m_pInterface->m_getNumVerticesOfFace==NULL || + pContext->m_pInterface->m_getPosition==NULL || + pContext->m_pInterface->m_getNormal==NULL || + pContext->m_pInterface->m_getTexCoord==NULL ) + return TFALSE; + + // count triangles on supported faces + for(f=0; fm_pInterface->m_getNumVerticesOfFace(pContext, f); + if(verts==3) ++iNrTrianglesIn; + else if(verts==4) iNrTrianglesIn += 2; + } + if(iNrTrianglesIn<=0) return TFALSE; + + // allocate memory for an index list + piTriListIn = (int *) malloc(sizeof(int)*3*iNrTrianglesIn); + pTriInfos = (STriInfo *) malloc(sizeof(STriInfo)*iNrTrianglesIn); + if(piTriListIn==NULL || pTriInfos==NULL) + { + if(piTriListIn!=NULL) free(piTriListIn); + if(pTriInfos!=NULL) free(pTriInfos); + return TFALSE; + } + + // make an initial triangle --> face index list + iNrTSPaces = GenerateInitialVerticesIndexList(pTriInfos, piTriListIn, pContext, iNrTrianglesIn); + + // make a welded index list of identical positions and attributes (pos, norm, texc) + //printf("gen welded index list begin\n"); + GenerateSharedVerticesIndexList(piTriListIn, pContext, iNrTrianglesIn); + //printf("gen welded index list end\n"); + + // Mark all degenerate triangles + iTotTris = iNrTrianglesIn; + iNrTrianglesIn = 0; + iDegenTriangles = 0; + for(t=0; tm_pInterface->m_getNumVerticesOfFace(pContext, f); + if(verts!=3 && verts!=4) continue; + + + // I've decided to let degenerate triangles and group-with-anythings + // vary between left/right hand coordinate systems at the vertices. + // All healthy triangles on the other hand are built to always be either or. + + /*// force the coordinate system orientation to be uniform for every face. + // (this is already the case for good triangles but not for + // degenerate ones and those with bGroupWithAnything==true) + bool bOrient = psTspace[index].bOrient; + if(psTspace[index].iCounter == 0) // tspace was not derived from a group + { + // look for a space created in GenerateTSpaces() by iCounter>0 + bool bNotFound = true; + int i=1; + while(i 0) bNotFound=false; + else ++i; + } + if(!bNotFound) bOrient = psTspace[index+i].bOrient; + }*/ + + // set data + for(i=0; ivOs.x, pTSpace->vOs.y, pTSpace->vOs.z}; + float bitang[] = {pTSpace->vOt.x, pTSpace->vOt.y, pTSpace->vOt.z}; + if(pContext->m_pInterface->m_setTSpace!=NULL) + pContext->m_pInterface->m_setTSpace(pContext, tang, bitang, pTSpace->fMagS, pTSpace->fMagT, pTSpace->bOrient, f, i); + if(pContext->m_pInterface->m_setTSpaceBasic!=NULL) + pContext->m_pInterface->m_setTSpaceBasic(pContext, tang, pTSpace->bOrient==TTRUE ? 1.0f : (-1.0f), f, i); + + ++index; + } + } + + free(psTspace); + + + return TTRUE; +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +typedef struct +{ + float vert[3]; + int index; +} STmpVert; + +const int g_iCells = 2048; + +// it is IMPORTANT that this function is called to evaluate the hash since +// inlining could potentially reorder instructions and generate different +// results for the same effective input value fVal. +volatile int FindGridCell(const float fMin, const float fMax, const float fVal) +{ + const float fIndex = (g_iCells-1) * ((fVal-fMin)/(fMax-fMin)); + const int iIndex = fIndex<0?0:((int) (fIndex+0.5f)); + return iIndex vP.x) vMin.x = vP.x; + else if(vMax.x < vP.x) vMax.x = vP.x; + if(vMin.y > vP.y) vMin.y = vP.y; + else if(vMax.y < vP.y) vMax.y = vP.y; + if(vMin.z > vP.z) vMin.z = vP.z; + else if(vMax.z < vP.z) vMax.z = vP.z; + } + + vDim = vsub(vMax,vMin); + iChannel = 0; + fMin = vMin.x; fMax=vMax.x; + if(vDim.y>vDim.x && vDim.y>vDim.z) + { + iChannel=1; + fMin = vMin.y, fMax=vMax.y; + } + else if(vDim.z>vDim.x) + { + iChannel=2; + fMin = vMin.z, fMax=vMax.z; + } + + // make allocations + piHashTable = (int *) malloc(sizeof(int)*iNrTrianglesIn*3); + piHashCount = (int *) malloc(sizeof(int)*g_iCells); + piHashOffsets = (int *) malloc(sizeof(int)*g_iCells); + piHashCount2 = (int *) malloc(sizeof(int)*g_iCells); + + if(piHashTable==NULL || piHashCount==NULL || piHashOffsets==NULL || piHashCount2==NULL) + { + if(piHashTable!=NULL) free(piHashTable); + if(piHashCount!=NULL) free(piHashCount); + if(piHashOffsets!=NULL) free(piHashOffsets); + if(piHashCount2!=NULL) free(piHashCount2); + GenerateSharedVerticesIndexListSlow(piTriList_in_and_out, pContext, iNrTrianglesIn); + return; + } + memset(piHashCount, 0, sizeof(int)*g_iCells); + memset(piHashCount2, 0, sizeof(int)*g_iCells); + + // count amount of elements in each cell unit + for(i=0; i<(iNrTrianglesIn*3); i++) + { + const int index = piTriList_in_and_out[i]; + const SVec3 vP = GetPosition(pContext, index); + const float fVal = iChannel==0 ? vP.x : (iChannel==1 ? vP.y : vP.z); + const int iCell = FindGridCell(fMin, fMax, fVal); + ++piHashCount[iCell]; + } + + // evaluate start index of each cell. + piHashOffsets[0]=0; + for(k=1; kpTmpVert[l].vert[c]) fvMin[c]=pTmpVert[l].vert[c]; + else if(fvMax[c]dx && dy>dz) channel=1; + else if(dz>dx) channel=2; + + fSep = 0.5f*(fvMax[channel]+fvMin[channel]); + + // terminate recursion when the separation/average value + // is no longer strictly between fMin and fMax values. + if(fSep>=fvMax[channel] || fSep<=fvMin[channel]) + { + // complete the weld + for(l=iL_in; l<=iR_in; l++) + { + int i = pTmpVert[l].index; + const int index = piTriList_in_and_out[i]; + const SVec3 vP = GetPosition(pContext, index); + const SVec3 vN = GetNormal(pContext, index); + const SVec3 vT = GetTexCoord(pContext, index); + + tbool bNotFound = TTRUE; + int l2=iL_in, i2rec=-1; + while(l20); // at least 2 entries + + // seperate (by fSep) all points between iL_in and iR_in in pTmpVert[] + while(iL < iR) + { + tbool bReadyLeftSwap = TFALSE, bReadyRightSwap = TFALSE; + while((!bReadyLeftSwap) && iL=iL_in && iL<=iR_in); + bReadyLeftSwap = !(pTmpVert[iL].vert[channel]=iL_in && iR<=iR_in); + bReadyRightSwap = pTmpVert[iR].vert[channel]m_pInterface->m_getNumFaces(pContext); f++) + { + const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f); + if(verts!=3 && verts!=4) continue; + + pTriInfos[iDstTriIndex].iOrgFaceNumber = f; + pTriInfos[iDstTriIndex].iTSpacesOffs = iTSpacesOffs; + + if(verts==3) + { + unsigned char * pVerts = pTriInfos[iDstTriIndex].vert_num; + pVerts[0]=0; pVerts[1]=1; pVerts[2]=2; + piTriList_out[iDstTriIndex*3+0] = MakeIndex(f, 0); + piTriList_out[iDstTriIndex*3+1] = MakeIndex(f, 1); + piTriList_out[iDstTriIndex*3+2] = MakeIndex(f, 2); + ++iDstTriIndex; // next + } + else + { + { + pTriInfos[iDstTriIndex+1].iOrgFaceNumber = f; + pTriInfos[iDstTriIndex+1].iTSpacesOffs = iTSpacesOffs; + } + + { + // need an order independent way to evaluate + // tspace on quads. This is done by splitting + // along the shortest diagonal. + const int i0 = MakeIndex(f, 0); + const int i1 = MakeIndex(f, 1); + const int i2 = MakeIndex(f, 2); + const int i3 = MakeIndex(f, 3); + const SVec3 T0 = GetTexCoord(pContext, i0); + const SVec3 T1 = GetTexCoord(pContext, i1); + const SVec3 T2 = GetTexCoord(pContext, i2); + const SVec3 T3 = GetTexCoord(pContext, i3); + const float distSQ_02 = LengthSquared(vsub(T2,T0)); + const float distSQ_13 = LengthSquared(vsub(T3,T1)); + tbool bQuadDiagIs_02; + if(distSQ_02m_pInterface->m_getPosition(pContext, pos, iF, iI); + res.x=pos[0]; res.y=pos[1]; res.z=pos[2]; + return res; +} + +const SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index) +{ + int iF, iI; + SVec3 res; float norm[3]; + IndexToData(&iF, &iI, index); + pContext->m_pInterface->m_getNormal(pContext, norm, iF, iI); + res.x=norm[0]; res.y=norm[1]; res.z=norm[2]; + return res; +} + +const SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index) +{ + int iF, iI; + SVec3 res; float texc[2]; + IndexToData(&iF, &iI, index); + pContext->m_pInterface->m_getTexCoord(pContext, texc, iF, iI); + res.x=texc[0]; res.y=texc[1]; res.z=1.0f; + return res; +} + +///////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////// + +typedef union +{ + struct + { + int i0, i1, f; + }; + int array[3]; +} SEdge; + +void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int piTriListIn[], const int iNrTrianglesIn); +void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], const int iNrTrianglesIn); + +// returns the texture area times 2 +float CalcTexArea(const SMikkTSpaceContext * pContext, const int indices[]) +{ + const SVec3 t1 = GetTexCoord(pContext, indices[0]); + const SVec3 t2 = GetTexCoord(pContext, indices[1]); + const SVec3 t3 = GetTexCoord(pContext, indices[2]); + + const float t21x = t2.x-t1.x; + const float t21y = t2.y-t1.y; + const float t31x = t3.x-t1.x; + const float t31y = t3.y-t1.y; + + const float fSignedAreaSTx2 = t21x*t31y - t21y*t31x; + + return fSignedAreaSTx2<0 ? (-fSignedAreaSTx2) : fSignedAreaSTx2; +} + +void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn) +{ + int f=0, i=0, t=0; + // pTriInfos[f].iFlag is cleared in GenerateInitialVerticesIndexList() which is called before this function. + + // generate neighbor info list + for(f=0; f0 ? ORIENT_PRESERVING : 0); + + if( NotZero(fSignedAreaSTx2) ) + { + const float fAbsArea = fabsf(fSignedAreaSTx2); + const float fLenOs = Length(vOs); + const float fLenOt = Length(vOt); + const float fS = (pTriInfos[f].iFlag&ORIENT_PRESERVING)==0 ? (-1.0f) : 1.0f; + if( NotZero(fLenOs) ) pTriInfos[f].vOs = vscale(fS/fLenOs, vOs); + if( NotZero(fLenOt) ) pTriInfos[f].vOt = vscale(fS/fLenOt, vOt); + + // evaluate magnitudes prior to normalization of vOs and vOt + pTriInfos[f].fMagS = fLenOs / fAbsArea; + pTriInfos[f].fMagT = fLenOt / fAbsArea; + + // if this is a good triangle + if( NotZero(pTriInfos[f].fMagS) && NotZero(pTriInfos[f].fMagT)) + pTriInfos[f].iFlag &= (~GROUP_WITH_ANY); + } + } + + // force otherwise healthy quads to a fixed orientation + while(t<(iNrTrianglesIn-1)) + { + const int iFO_a = pTriInfos[t].iOrgFaceNumber; + const int iFO_b = pTriInfos[t+1].iOrgFaceNumber; + if(iFO_a==iFO_b) // this is a quad + { + const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + + // bad triangles should already have been removed by + // DegenPrologue(), but just in case check bIsDeg_a and bIsDeg_a are false + if((bIsDeg_a||bIsDeg_b)==TFALSE) + { + const tbool bOrientA = (pTriInfos[t].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + const tbool bOrientB = (pTriInfos[t+1].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + // if this happens the quad has extremely bad mapping!! + if(bOrientA!=bOrientB) + { + //printf("found quad with bad mapping\n"); + tbool bChooseOrientFirstTri = TFALSE; + if((pTriInfos[t+1].iFlag&GROUP_WITH_ANY)!=0) bChooseOrientFirstTri = TTRUE; + else if( CalcTexArea(pContext, &piTriListIn[t*3+0]) >= CalcTexArea(pContext, &piTriListIn[(t+1)*3+0]) ) + bChooseOrientFirstTri = TTRUE; + + // force match + { + const int t0 = bChooseOrientFirstTri ? t : (t+1); + const int t1 = bChooseOrientFirstTri ? (t+1) : t; + pTriInfos[t1].iFlag &= (~ORIENT_PRESERVING); // clear first + pTriInfos[t1].iFlag |= (pTriInfos[t0].iFlag&ORIENT_PRESERVING); // copy bit + } + } + } + t += 2; + } + else + ++t; + } + + // match up edge pairs + { + SEdge * pEdges = (SEdge *) malloc(sizeof(SEdge)*iNrTrianglesIn*3); + if(pEdges==NULL) + BuildNeighborsSlow(pTriInfos, piTriListIn, iNrTrianglesIn); + else + { + BuildNeighborsFast(pTriInfos, pEdges, piTriListIn, iNrTrianglesIn); + + free(pEdges); + } + } +} + +///////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////// + +tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[], const int iMyTriIndex, SGroup * pGroup); +void AddTriToGroup(SGroup * pGroup, const int iTriIndex); + +int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn) +{ + const int iNrMaxGroups = iNrTrianglesIn*3; + int iNrActiveGroups = 0; + int iOffset = 0, f=0, i=0; + for(f=0; fiVertexRepresentitive = vert_index; + pTriInfos[f].AssignedGroup[i]->bOrientPreservering = (pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0; + pTriInfos[f].AssignedGroup[i]->iNrFaces = 0; + pTriInfos[f].AssignedGroup[i]->pFaceIndices = &piGroupTrianglesBuffer[iOffset]; + ++iNrActiveGroups; + + AddTriToGroup(pTriInfos[f].AssignedGroup[i], f); + bOrPre = (pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + neigh_indexL = pTriInfos[f].FaceNeighbors[i]; + neigh_indexR = pTriInfos[f].FaceNeighbors[i>0?(i-1):2]; + if(neigh_indexL>=0) // neighbor + { + const tbool bAnswer = + AssignRecur(piTriListIn, pTriInfos, neigh_indexL, + pTriInfos[f].AssignedGroup[i] ); + + const tbool bOrPre2 = (pTriInfos[neigh_indexL].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + const tbool bDiff = bOrPre!=bOrPre2 ? TTRUE : TFALSE; + assert(bAnswer || bDiff); + } + if(neigh_indexR>=0) // neighbor + { + const tbool bAnswer = + AssignRecur(piTriListIn, pTriInfos, neigh_indexR, + pTriInfos[f].AssignedGroup[i] ); + + const tbool bOrPre2 = (pTriInfos[neigh_indexR].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + const tbool bDiff = bOrPre!=bOrPre2 ? TTRUE : TFALSE; + assert(bAnswer || bDiff); + } + + // update offset + iOffset += pTriInfos[f].AssignedGroup[i]->iNrFaces; + // since the groups are disjoint a triangle can never + // belong to more than 3 groups. Subsequently something + // is completely screwed if this assertion ever hits. + assert(iOffset <= iNrMaxGroups); + } + } + } + + return iNrActiveGroups; +} + +void AddTriToGroup(SGroup * pGroup, const int iTriIndex) +{ + pGroup->pFaceIndices[pGroup->iNrFaces] = iTriIndex; + ++pGroup->iNrFaces; +} + +tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[], + const int iMyTriIndex, SGroup * pGroup) +{ + STriInfo * pMyTriInfo = &psTriInfos[iMyTriIndex]; + + // track down vertex + const int iVertRep = pGroup->iVertexRepresentitive; + const int * pVerts = &piTriListIn[3*iMyTriIndex+0]; + int i=-1; + if(pVerts[0]==iVertRep) i=0; + else if(pVerts[1]==iVertRep) i=1; + else if(pVerts[2]==iVertRep) i=2; + assert(i>=0 && i<3); + + // early out + if(pMyTriInfo->AssignedGroup[i] == pGroup) return TTRUE; + else if(pMyTriInfo->AssignedGroup[i]!=NULL) return TFALSE; + if((pMyTriInfo->iFlag&GROUP_WITH_ANY)!=0) + { + // first to group with a group-with-anything triangle + // determines it's orientation. + // This is the only existing order dependency in the code!! + if( pMyTriInfo->AssignedGroup[0] == NULL && + pMyTriInfo->AssignedGroup[1] == NULL && + pMyTriInfo->AssignedGroup[2] == NULL ) + { + pMyTriInfo->iFlag &= (~ORIENT_PRESERVING); + pMyTriInfo->iFlag |= (pGroup->bOrientPreservering ? ORIENT_PRESERVING : 0); + } + } + { + const tbool bOrient = (pMyTriInfo->iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; + if(bOrient != pGroup->bOrientPreservering) return TFALSE; + } + + AddTriToGroup(pGroup, iMyTriIndex); + pMyTriInfo->AssignedGroup[i] = pGroup; + + { + const int neigh_indexL = pMyTriInfo->FaceNeighbors[i]; + const int neigh_indexR = pMyTriInfo->FaceNeighbors[i>0?(i-1):2]; + if(neigh_indexL>=0) + AssignRecur(piTriListIn, psTriInfos, neigh_indexL, pGroup); + if(neigh_indexR>=0) + AssignRecur(piTriListIn, psTriInfos, neigh_indexR, pGroup); + } + + + + return TTRUE; +} + +///////////////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////////////// + +tbool CompareSubGroups(const SSubGroup * pg1, const SSubGroup * pg2); +void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed); +STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriListIn[], const STriInfo pTriInfos[], const SMikkTSpaceContext * pContext, const int iVertexRepresentitive); + +tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[], + const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, + const SMikkTSpaceContext * pContext) +{ + STSpace * pSubGroupTspace = NULL; + SSubGroup * pUniSubGroups = NULL; + int * pTmpMembers = NULL; + int iMaxNrFaces=0, iUniqueTspaces=0, g=0, i=0; + for(g=0; giNrFaces; i++) // triangles + { + const int f = pGroup->pFaceIndices[i]; // triangle number + int index=-1, iVertIndex=-1, iOF_1=-1, iMembers=0, j=0, l=0; + SSubGroup tmp_group; + tbool bFound; + SVec3 n, vOs, vOt; + if(pTriInfos[f].AssignedGroup[0]==pGroup) index=0; + else if(pTriInfos[f].AssignedGroup[1]==pGroup) index=1; + else if(pTriInfos[f].AssignedGroup[2]==pGroup) index=2; + assert(index>=0 && index<3); + + iVertIndex = piTriListIn[f*3+index]; + assert(iVertIndex==pGroup->iVertexRepresentitive); + + // is normalized already + n = GetNormal(pContext, iVertIndex); + + // project + vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n)); + vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n)); + if( VNotZero(vOs) ) vOs = Normalize(vOs); + if( VNotZero(vOt) ) vOt = Normalize(vOt); + + // original face number + iOF_1 = pTriInfos[f].iOrgFaceNumber; + + iMembers = 0; + for(j=0; jiNrFaces; j++) + { + const int t = pGroup->pFaceIndices[j]; // triangle number + const int iOF_2 = pTriInfos[t].iOrgFaceNumber; + + // project + SVec3 vOs2 = vsub(pTriInfos[t].vOs, vscale(vdot(n,pTriInfos[t].vOs), n)); + SVec3 vOt2 = vsub(pTriInfos[t].vOt, vscale(vdot(n,pTriInfos[t].vOt), n)); + if( VNotZero(vOs2) ) vOs2 = Normalize(vOs2); + if( VNotZero(vOt2) ) vOt2 = Normalize(vOt2); + + { + const tbool bAny = ( (pTriInfos[f].iFlag | pTriInfos[t].iFlag) & GROUP_WITH_ANY )!=0 ? TTRUE : TFALSE; + // make sure triangles which belong to the same quad are joined. + const tbool bSameOrgFace = iOF_1==iOF_2 ? TTRUE : TFALSE; + + const float fCosS = vdot(vOs,vOs2); + const float fCosT = vdot(vOt,vOt2); + + assert(f!=t || bSameOrgFace); // sanity check + if(bAny || bSameOrgFace || (fCosS>fThresCos && fCosT>fThresCos)) + pTmpMembers[iMembers++] = t; + } + } + + // sort pTmpMembers + tmp_group.iNrFaces = iMembers; + tmp_group.pTriMembers = pTmpMembers; + if(iMembers>1) + { + unsigned int uSeed = INTERNAL_RND_SORT_SEED; // could replace with a random seed? + QuickSort(pTmpMembers, 0, iMembers-1, uSeed); + } + + // look for an existing match + bFound = TFALSE; + l=0; + while(liVertexRepresentitive); + ++iUniqueSubGroups; + } + + // output tspace + { + const int iOffs = pTriInfos[f].iTSpacesOffs; + const int iVert = pTriInfos[f].vert_num[index]; + STSpace * pTS_out = &psTspace[iOffs+iVert]; + assert(pTS_out->iCounter<2); + assert(((pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0) == pGroup->bOrientPreservering); + if(pTS_out->iCounter==1) + { + *pTS_out = AvgTSpace(pTS_out, &pSubGroupTspace[l]); + pTS_out->iCounter = 2; // update counter + pTS_out->bOrient = pGroup->bOrientPreservering; + } + else + { + assert(pTS_out->iCounter==0); + *pTS_out = pSubGroupTspace[l]; + pTS_out->iCounter = 1; // update counter + pTS_out->bOrient = pGroup->bOrientPreservering; + } + } + } + + // clean up and offset iUniqueTspaces + for(s=0; s=0 && i<3); + + // project + index = piTriListIn[3*f+i]; + n = GetNormal(pContext, index); + vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n)); + vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n)); + if( VNotZero(vOs) ) vOs = Normalize(vOs); + if( VNotZero(vOt) ) vOt = Normalize(vOt); + + i2 = piTriListIn[3*f + (i<2?(i+1):0)]; + i1 = piTriListIn[3*f + i]; + i0 = piTriListIn[3*f + (i>0?(i-1):2)]; + + p0 = GetPosition(pContext, i0); + p1 = GetPosition(pContext, i1); + p2 = GetPosition(pContext, i2); + v1 = vsub(p0,p1); + v2 = vsub(p2,p1); + + // project + v1 = vsub(v1, vscale(vdot(n,v1),n)); if( VNotZero(v1) ) v1 = Normalize(v1); + v2 = vsub(v2, vscale(vdot(n,v2),n)); if( VNotZero(v2) ) v2 = Normalize(v2); + + // weight contribution by the angle + // between the two edge vectors + fCos = vdot(v1,v2); fCos=fCos>1?1:(fCos<(-1) ? (-1) : fCos); + fAngle = (const float) acos(fCos); + fMagS = pTriInfos[f].fMagS; + fMagT = pTriInfos[f].fMagT; + + res.vOs=vadd(res.vOs, vscale(fAngle,vOs)); + res.vOt=vadd(res.vOt,vscale(fAngle,vOt)); + res.fMagS+=(fAngle*fMagS); + res.fMagT+=(fAngle*fMagT); + fAngleSum += fAngle; + } + } + + // normalize + if( VNotZero(res.vOs) ) res.vOs = Normalize(res.vOs); + if( VNotZero(res.vOt) ) res.vOt = Normalize(res.vOt); + if(fAngleSum>0) + { + res.fMagS /= fAngleSum; + res.fMagT /= fAngleSum; + } + + return res; +} + +tbool CompareSubGroups(const SSubGroup * pg1, const SSubGroup * pg2) +{ + tbool bStillSame=TTRUE; + int i=0; + if(pg1->iNrFaces!=pg2->iNrFaces) return TFALSE; + while(iiNrFaces && bStillSame) + { + bStillSame = pg1->pTriMembers[i]==pg2->pTriMembers[i] ? TTRUE : TFALSE; + if(bStillSame) ++i; + } + return bStillSame; +} + +void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed) +{ + int iL, iR, n, index, iMid, iTmp; + + // Random + unsigned int t=uSeed&31; + t=(uSeed<>(32-t)); + uSeed=uSeed+t+3; + // Random end + + iL=iLeft; iR=iRight; + n = (iR-iL)+1; + assert(n>=0); + index = (int) (uSeed%n); + + iMid=pSortBuffer[index + iL]; + iTmp; + + do + { + while(pSortBuffer[iL] < iMid) + ++iL; + while(pSortBuffer[iR] > iMid) + --iR; + + if(iL <= iR) + { + iTmp = pSortBuffer[iL]; + pSortBuffer[iL] = pSortBuffer[iR]; + pSortBuffer[iR] = iTmp; + ++iL; --iR; + } + } + while(iL <= iR); + + if(iLeft < iR) + QuickSort(pSortBuffer, iLeft, iR, uSeed); + if(iL < iRight) + QuickSort(pSortBuffer, iL, iRight, uSeed); +} + +///////////////////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////////////////// + +void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int channel, unsigned int uSeed); +void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int indices[], const int i0_in, const int i1_in); + +void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int piTriListIn[], const int iNrTrianglesIn) +{ + // build array of edges + unsigned int uSeed = INTERNAL_RND_SORT_SEED; // could replace with a random seed? + int iEntries=0, iCurStartIndex=-1, f=0, i=0; + for(f=0; f pSortBuffer[iRight].array[channel]) + { + sTmp = pSortBuffer[iLeft]; + pSortBuffer[iLeft] = pSortBuffer[iRight]; + pSortBuffer[iRight] = sTmp; + } + return; + } + + // Random + t=uSeed&31; + t=(uSeed<>(32-t)); + uSeed=uSeed+t+3; + // Random end + + iL=iLeft, iR=iRight; + n = (iR-iL)+1; + assert(n>=0); + index = (int) (uSeed%n); + + iMid=pSortBuffer[index + iL].array[channel]; + + do + { + while(pSortBuffer[iL].array[channel] < iMid) + ++iL; + while(pSortBuffer[iR].array[channel] > iMid) + --iR; + + if(iL <= iR) + { + sTmp = pSortBuffer[iL]; + pSortBuffer[iL] = pSortBuffer[iR]; + pSortBuffer[iR] = sTmp; + ++iL; --iR; + } + } + while(iL <= iR); + + if(iLeft < iR) + QuickSortEdges(pSortBuffer, iLeft, iR, channel, uSeed); + if(iL < iRight) + QuickSortEdges(pSortBuffer, iL, iRight, channel, uSeed); +} + +// resolve ordering and edge number +void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int indices[], const int i0_in, const int i1_in) +{ + *edgenum_out = -1; + + // test if first index is on the edge + if(indices[0]==i0_in || indices[0]==i1_in) + { + // test if second index is on the edge + if(indices[1]==i0_in || indices[1]==i1_in) + { + edgenum_out[0]=0; // first edge + i0_out[0]=indices[0]; + i1_out[0]=indices[1]; + } + else + { + edgenum_out[0]=2; // third edge + i0_out[0]=indices[2]; + i1_out[0]=indices[0]; + } + } + else + { + // only second and third index is on the edge + edgenum_out[0]=1; // second edge + i0_out[0]=indices[1]; + i1_out[0]=indices[2]; + } +} + + +///////////////////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////// Degenerate triangles //////////////////////////////////// + +void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris) +{ + int iNextGoodTriangleSearchIndex=-1; + tbool bStillFindingGoodOnes; + + // locate quads with only one good triangle + int t=0; + while(t<(iTotTris-1)) + { + const int iFO_a = pTriInfos[t].iOrgFaceNumber; + const int iFO_b = pTriInfos[t+1].iOrgFaceNumber; + if(iFO_a==iFO_b) // this is a quad + { + const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; + if((bIsDeg_a^bIsDeg_b)!=0) + { + pTriInfos[t].iFlag |= QUAD_ONE_DEGEN_TRI; + pTriInfos[t+1].iFlag |= QUAD_ONE_DEGEN_TRI; + } + t += 2; + } + else + ++t; + } + + // reorder list so all degen triangles are moved to the back + // without reordering the good triangles + iNextGoodTriangleSearchIndex = 1; + t=0; + bStillFindingGoodOnes = TTRUE; + while(t (t+1)); + + // swap triangle t0 and t1 + if(!bJustADegenerate) + { + int i=0; + for(i=0; i<3; i++) + { + const int index = piTriList_out[t0*3+i]; + piTriList_out[t0*3+i] = piTriList_out[t1*3+i]; + piTriList_out[t1*3+i] = index; + } + { + const STriInfo tri_info = pTriInfos[t0]; + pTriInfos[t0] = pTriInfos[t1]; + pTriInfos[t1] = tri_info; + } + } + else + bStillFindingGoodOnes = TFALSE; // this is not supposed to happen + } + + if(bStillFindingGoodOnes) ++t; + } + + assert(bStillFindingGoodOnes); // code will still work. + assert(iNrTrianglesIn == t); +} + +void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris) +{ + int t=0, i=0; + // deal with degenerate triangles + // punishment for degenerate triangles is O(N^2) + for(t=iNrTrianglesIn; t Date: Mon, 14 Feb 2011 18:20:10 +0000 Subject: more vars made static --- source/blender/blenkernel/intern/writeavi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 014a15de1ef..e946ce06aa2 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -214,7 +214,7 @@ static int append_avi(RenderData *UNUSED(rd), int frame, int *pixels, int rectx, return 1; } -void end_avi(void) +static void end_avi(void) { if (avi == NULL) return; -- cgit v1.2.3 From 07e9cfef810d2639b6d83c0d09f63f3b7c7c4898 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 15 Feb 2011 03:20:12 +0000 Subject: fix warnings. --- source/blender/blenkernel/intern/mikktspace.c | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mikktspace.c b/source/blender/blenkernel/intern/mikktspace.c index 83623a13db8..fae8c4edc8d 100644 --- a/source/blender/blenkernel/intern/mikktspace.c +++ b/source/blender/blenkernel/intern/mikktspace.c @@ -41,12 +41,12 @@ typedef struct float x, y, z; } SVec3; -tbool veq( const SVec3 v1, const SVec3 v2 ) +static tbool veq( const SVec3 v1, const SVec3 v2 ) { return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z); } -const SVec3 vadd( const SVec3 v1, const SVec3 v2 ) +static const SVec3 vadd( const SVec3 v1, const SVec3 v2 ) { SVec3 vRes; @@ -58,7 +58,7 @@ const SVec3 vadd( const SVec3 v1, const SVec3 v2 ) } -const SVec3 vsub( const SVec3 v1, const SVec3 v2 ) +static const SVec3 vsub( const SVec3 v1, const SVec3 v2 ) { SVec3 vRes; @@ -69,7 +69,7 @@ const SVec3 vsub( const SVec3 v1, const SVec3 v2 ) return vRes; } -const SVec3 vscale(const float fS, const SVec3 v) +static const SVec3 vscale(const float fS, const SVec3 v) { SVec3 vRes; @@ -80,34 +80,34 @@ const SVec3 vscale(const float fS, const SVec3 v) return vRes; } -float LengthSquared( const SVec3 v ) +static float LengthSquared( const SVec3 v ) { return v.x*v.x + v.y*v.y + v.z*v.z; } -float Length( const SVec3 v ) +static float Length( const SVec3 v ) { return sqrtf(LengthSquared(v)); } -const SVec3 Normalize( const SVec3 v ) +static const SVec3 Normalize( const SVec3 v ) { return vscale(1 / Length(v), v); } -const float vdot( const SVec3 v1, const SVec3 v2) +static const float vdot( const SVec3 v1, const SVec3 v2) { return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; } -tbool NotZero(const float fX) +static tbool NotZero(const float fX) { // could possibly use FLT_EPSILON instead return fabsf(fX) > FLT_MIN; } -tbool VNotZero(const SVec3 v) +static tbool VNotZero(const SVec3 v) { // might change this to an epsilon based test return NotZero(v.x) || NotZero(v.y) || NotZero(v.z); @@ -170,19 +170,19 @@ tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGro const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, const SMikkTSpaceContext * pContext); -int MakeIndex(const int iFace, const int iVert) +static int MakeIndex(const int iFace, const int iVert) { assert(iVert>=0 && iVert<4 && iFace>=0); return (iFace<<2) | (iVert&0x3); } -void IndexToData(int * piFace, int * piVert, const int iIndexIn) +static void IndexToData(int * piFace, int * piVert, const int iIndexIn) { piVert[0] = iIndexIn&0x3; piFace[0] = iIndexIn>>2; } -const STSpace AvgTSpace(const STSpace * pTS0, const STSpace * pTS1) +static const STSpace AvgTSpace(const STSpace * pTS0, const STSpace * pTS1) { STSpace ts_res; @@ -429,12 +429,12 @@ typedef struct int index; } STmpVert; -const int g_iCells = 2048; +static const int g_iCells = 2048; // it is IMPORTANT that this function is called to evaluate the hash since // inlining could potentially reorder instructions and generate different // results for the same effective input value fVal. -volatile int FindGridCell(const float fMin, const float fMax, const float fVal) +static volatile int FindGridCell(const float fMin, const float fMax, const float fVal) { const float fIndex = (g_iCells-1) * ((fVal-fMin)/(fMax-fMin)); const int iIndex = fIndex<0?0:((int) (fIndex+0.5f)); @@ -915,7 +915,7 @@ void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int piTriLis void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], const int iNrTrianglesIn); // returns the texture area times 2 -float CalcTexArea(const SMikkTSpaceContext * pContext, const int indices[]) +static float CalcTexArea(const SMikkTSpaceContext * pContext, const int indices[]) { const SVec3 t1 = GetTexCoord(pContext, indices[0]); const SVec3 t2 = GetTexCoord(pContext, indices[1]); @@ -1455,7 +1455,7 @@ void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed) index = (int) (uSeed%n); iMid=pSortBuffer[index + iL]; - iTmp; + do { -- cgit v1.2.3 From 3ce233e28d51fb31cf13e8791052e503ecae96ec Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 15 Feb 2011 09:24:35 +0000 Subject: Move mikktspace code to own library, so it is clear that it is also intended as a standalone library for use in other applications that want the same tangent space as Blender. This also keeps blenkernel clean(er) from extra math functions. --- source/blender/blenkernel/intern/mikktspace.c | 1886 ------------------------- 1 file changed, 1886 deletions(-) delete mode 100644 source/blender/blenkernel/intern/mikktspace.c (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/mikktspace.c b/source/blender/blenkernel/intern/mikktspace.c deleted file mode 100644 index fae8c4edc8d..00000000000 --- a/source/blender/blenkernel/intern/mikktspace.c +++ /dev/null @@ -1,1886 +0,0 @@ -/** - * Copyright (C) 2011 by Morten S. Mikkelsen - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * 3. This notice may not be removed or altered from any source distribution. - */ - -#include -#include -#include -#include -#include -#include -#include "mikktspace.h" - -#define TFALSE 0 -#define TTRUE 1 - -#ifndef M_PI -#define M_PI 3.1415926535897932384626433832795 -#endif - -#define INTERNAL_RND_SORT_SEED 39871946 - -// internal structure -typedef struct -{ - float x, y, z; -} SVec3; - -static tbool veq( const SVec3 v1, const SVec3 v2 ) -{ - return (v1.x == v2.x) && (v1.y == v2.y) && (v1.z == v2.z); -} - -static const SVec3 vadd( const SVec3 v1, const SVec3 v2 ) -{ - SVec3 vRes; - - vRes.x = v1.x + v2.x; - vRes.y = v1.y + v2.y; - vRes.z = v1.z + v2.z; - - return vRes; -} - - -static const SVec3 vsub( const SVec3 v1, const SVec3 v2 ) -{ - SVec3 vRes; - - vRes.x = v1.x - v2.x; - vRes.y = v1.y - v2.y; - vRes.z = v1.z - v2.z; - - return vRes; -} - -static const SVec3 vscale(const float fS, const SVec3 v) -{ - SVec3 vRes; - - vRes.x = fS * v.x; - vRes.y = fS * v.y; - vRes.z = fS * v.z; - - return vRes; -} - -static float LengthSquared( const SVec3 v ) -{ - return v.x*v.x + v.y*v.y + v.z*v.z; -} - -static float Length( const SVec3 v ) -{ - return sqrtf(LengthSquared(v)); -} - -static const SVec3 Normalize( const SVec3 v ) -{ - return vscale(1 / Length(v), v); -} - -static const float vdot( const SVec3 v1, const SVec3 v2) -{ - return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z; -} - - -static tbool NotZero(const float fX) -{ - // could possibly use FLT_EPSILON instead - return fabsf(fX) > FLT_MIN; -} - -static tbool VNotZero(const SVec3 v) -{ - // might change this to an epsilon based test - return NotZero(v.x) || NotZero(v.y) || NotZero(v.z); -} - - - -typedef struct -{ - int iNrFaces; - int * pTriMembers; -} SSubGroup; - -typedef struct -{ - int iNrFaces; - int * pFaceIndices; - int iVertexRepresentitive; - tbool bOrientPreservering; -} SGroup; - -// -#define MARK_DEGENERATE 1 -#define QUAD_ONE_DEGEN_TRI 2 -#define GROUP_WITH_ANY 4 -#define ORIENT_PRESERVING 8 - - - -typedef struct -{ - int FaceNeighbors[3]; - SGroup * AssignedGroup[3]; - - // normalized first order face derivatives - SVec3 vOs, vOt; - float fMagS, fMagT; // original magnitudes - - // determines if the current and the next triangle are a quad. - int iOrgFaceNumber; - int iFlag, iTSpacesOffs; - unsigned char vert_num[4]; -} STriInfo; - -typedef struct -{ - SVec3 vOs; - float fMagS; - SVec3 vOt; - float fMagT; - int iCounter; // this is to average back into quads. - tbool bOrient; -} STSpace; - -int GenerateInitialVerticesIndexList(STriInfo pTriInfos[], int piTriList_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); -void GenerateSharedVerticesIndexList(int piTriList_in_and_out[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); -void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn); -int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn); -tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[], - const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, - const SMikkTSpaceContext * pContext); - -static int MakeIndex(const int iFace, const int iVert) -{ - assert(iVert>=0 && iVert<4 && iFace>=0); - return (iFace<<2) | (iVert&0x3); -} - -static void IndexToData(int * piFace, int * piVert, const int iIndexIn) -{ - piVert[0] = iIndexIn&0x3; - piFace[0] = iIndexIn>>2; -} - -static const STSpace AvgTSpace(const STSpace * pTS0, const STSpace * pTS1) -{ - STSpace ts_res; - - // this if is important. Due to floating point precision - // averaging when ts0==ts1 will cause a slight difference - // which results in tangent space splits later on - if(pTS0->fMagS==pTS1->fMagS && pTS0->fMagT==pTS1->fMagT && - veq(pTS0->vOs,pTS1->vOs) && veq(pTS0->vOt, pTS1->vOt)) - { - ts_res.fMagS = pTS0->fMagS; - ts_res.fMagT = pTS0->fMagT; - ts_res.vOs = pTS0->vOs; - ts_res.vOt = pTS0->vOt; - } - else - { - ts_res.fMagS = 0.5f*(pTS0->fMagS+pTS1->fMagS); - ts_res.fMagT = 0.5f*(pTS0->fMagT+pTS1->fMagT); - ts_res.vOs = vadd(pTS0->vOs,pTS1->vOs); - ts_res.vOt = vadd(pTS0->vOt,pTS1->vOt); - if( VNotZero(ts_res.vOs) ) ts_res.vOs = Normalize(ts_res.vOs); - if( VNotZero(ts_res.vOt) ) ts_res.vOt = Normalize(ts_res.vOt); - } - - return ts_res; -} - - - -const SVec3 GetPosition(const SMikkTSpaceContext * pContext, const int index); -const SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index); -const SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index); - - -// degen triangles -void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris); -void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris); - - -tbool genTangSpaceDefault(const SMikkTSpaceContext * pContext) -{ - return genTangSpace(pContext, 180.0f); -} - -tbool genTangSpace(const SMikkTSpaceContext * pContext, const float fAngularThreshold) -{ - // count nr_triangles - int * piTriListIn = NULL, * piGroupTrianglesBuffer = NULL; - STriInfo * pTriInfos = NULL; - SGroup * pGroups = NULL; - STSpace * psTspace = NULL; - int iNrTrianglesIn = 0, f=0, t=0, i=0; - int iNrTSPaces = 0, iTotTris = 0, iDegenTriangles = 0, iNrMaxGroups = 0; - int iNrActiveGroups = 0, index = 0; - const int iNrFaces = pContext->m_pInterface->m_getNumFaces(pContext); - tbool bRes = TFALSE; - const float fThresCos = (const float) cos((fAngularThreshold*M_PI)/180); - - // verify all call-backs have been set - if( pContext->m_pInterface->m_getNumFaces==NULL || - pContext->m_pInterface->m_getNumVerticesOfFace==NULL || - pContext->m_pInterface->m_getPosition==NULL || - pContext->m_pInterface->m_getNormal==NULL || - pContext->m_pInterface->m_getTexCoord==NULL ) - return TFALSE; - - // count triangles on supported faces - for(f=0; fm_pInterface->m_getNumVerticesOfFace(pContext, f); - if(verts==3) ++iNrTrianglesIn; - else if(verts==4) iNrTrianglesIn += 2; - } - if(iNrTrianglesIn<=0) return TFALSE; - - // allocate memory for an index list - piTriListIn = (int *) malloc(sizeof(int)*3*iNrTrianglesIn); - pTriInfos = (STriInfo *) malloc(sizeof(STriInfo)*iNrTrianglesIn); - if(piTriListIn==NULL || pTriInfos==NULL) - { - if(piTriListIn!=NULL) free(piTriListIn); - if(pTriInfos!=NULL) free(pTriInfos); - return TFALSE; - } - - // make an initial triangle --> face index list - iNrTSPaces = GenerateInitialVerticesIndexList(pTriInfos, piTriListIn, pContext, iNrTrianglesIn); - - // make a welded index list of identical positions and attributes (pos, norm, texc) - //printf("gen welded index list begin\n"); - GenerateSharedVerticesIndexList(piTriListIn, pContext, iNrTrianglesIn); - //printf("gen welded index list end\n"); - - // Mark all degenerate triangles - iTotTris = iNrTrianglesIn; - iNrTrianglesIn = 0; - iDegenTriangles = 0; - for(t=0; tm_pInterface->m_getNumVerticesOfFace(pContext, f); - if(verts!=3 && verts!=4) continue; - - - // I've decided to let degenerate triangles and group-with-anythings - // vary between left/right hand coordinate systems at the vertices. - // All healthy triangles on the other hand are built to always be either or. - - /*// force the coordinate system orientation to be uniform for every face. - // (this is already the case for good triangles but not for - // degenerate ones and those with bGroupWithAnything==true) - bool bOrient = psTspace[index].bOrient; - if(psTspace[index].iCounter == 0) // tspace was not derived from a group - { - // look for a space created in GenerateTSpaces() by iCounter>0 - bool bNotFound = true; - int i=1; - while(i 0) bNotFound=false; - else ++i; - } - if(!bNotFound) bOrient = psTspace[index+i].bOrient; - }*/ - - // set data - for(i=0; ivOs.x, pTSpace->vOs.y, pTSpace->vOs.z}; - float bitang[] = {pTSpace->vOt.x, pTSpace->vOt.y, pTSpace->vOt.z}; - if(pContext->m_pInterface->m_setTSpace!=NULL) - pContext->m_pInterface->m_setTSpace(pContext, tang, bitang, pTSpace->fMagS, pTSpace->fMagT, pTSpace->bOrient, f, i); - if(pContext->m_pInterface->m_setTSpaceBasic!=NULL) - pContext->m_pInterface->m_setTSpaceBasic(pContext, tang, pTSpace->bOrient==TTRUE ? 1.0f : (-1.0f), f, i); - - ++index; - } - } - - free(psTspace); - - - return TTRUE; -} - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -typedef struct -{ - float vert[3]; - int index; -} STmpVert; - -static const int g_iCells = 2048; - -// it is IMPORTANT that this function is called to evaluate the hash since -// inlining could potentially reorder instructions and generate different -// results for the same effective input value fVal. -static volatile int FindGridCell(const float fMin, const float fMax, const float fVal) -{ - const float fIndex = (g_iCells-1) * ((fVal-fMin)/(fMax-fMin)); - const int iIndex = fIndex<0?0:((int) (fIndex+0.5f)); - return iIndex vP.x) vMin.x = vP.x; - else if(vMax.x < vP.x) vMax.x = vP.x; - if(vMin.y > vP.y) vMin.y = vP.y; - else if(vMax.y < vP.y) vMax.y = vP.y; - if(vMin.z > vP.z) vMin.z = vP.z; - else if(vMax.z < vP.z) vMax.z = vP.z; - } - - vDim = vsub(vMax,vMin); - iChannel = 0; - fMin = vMin.x; fMax=vMax.x; - if(vDim.y>vDim.x && vDim.y>vDim.z) - { - iChannel=1; - fMin = vMin.y, fMax=vMax.y; - } - else if(vDim.z>vDim.x) - { - iChannel=2; - fMin = vMin.z, fMax=vMax.z; - } - - // make allocations - piHashTable = (int *) malloc(sizeof(int)*iNrTrianglesIn*3); - piHashCount = (int *) malloc(sizeof(int)*g_iCells); - piHashOffsets = (int *) malloc(sizeof(int)*g_iCells); - piHashCount2 = (int *) malloc(sizeof(int)*g_iCells); - - if(piHashTable==NULL || piHashCount==NULL || piHashOffsets==NULL || piHashCount2==NULL) - { - if(piHashTable!=NULL) free(piHashTable); - if(piHashCount!=NULL) free(piHashCount); - if(piHashOffsets!=NULL) free(piHashOffsets); - if(piHashCount2!=NULL) free(piHashCount2); - GenerateSharedVerticesIndexListSlow(piTriList_in_and_out, pContext, iNrTrianglesIn); - return; - } - memset(piHashCount, 0, sizeof(int)*g_iCells); - memset(piHashCount2, 0, sizeof(int)*g_iCells); - - // count amount of elements in each cell unit - for(i=0; i<(iNrTrianglesIn*3); i++) - { - const int index = piTriList_in_and_out[i]; - const SVec3 vP = GetPosition(pContext, index); - const float fVal = iChannel==0 ? vP.x : (iChannel==1 ? vP.y : vP.z); - const int iCell = FindGridCell(fMin, fMax, fVal); - ++piHashCount[iCell]; - } - - // evaluate start index of each cell. - piHashOffsets[0]=0; - for(k=1; kpTmpVert[l].vert[c]) fvMin[c]=pTmpVert[l].vert[c]; - else if(fvMax[c]dx && dy>dz) channel=1; - else if(dz>dx) channel=2; - - fSep = 0.5f*(fvMax[channel]+fvMin[channel]); - - // terminate recursion when the separation/average value - // is no longer strictly between fMin and fMax values. - if(fSep>=fvMax[channel] || fSep<=fvMin[channel]) - { - // complete the weld - for(l=iL_in; l<=iR_in; l++) - { - int i = pTmpVert[l].index; - const int index = piTriList_in_and_out[i]; - const SVec3 vP = GetPosition(pContext, index); - const SVec3 vN = GetNormal(pContext, index); - const SVec3 vT = GetTexCoord(pContext, index); - - tbool bNotFound = TTRUE; - int l2=iL_in, i2rec=-1; - while(l20); // at least 2 entries - - // seperate (by fSep) all points between iL_in and iR_in in pTmpVert[] - while(iL < iR) - { - tbool bReadyLeftSwap = TFALSE, bReadyRightSwap = TFALSE; - while((!bReadyLeftSwap) && iL=iL_in && iL<=iR_in); - bReadyLeftSwap = !(pTmpVert[iL].vert[channel]=iL_in && iR<=iR_in); - bReadyRightSwap = pTmpVert[iR].vert[channel]m_pInterface->m_getNumFaces(pContext); f++) - { - const int verts = pContext->m_pInterface->m_getNumVerticesOfFace(pContext, f); - if(verts!=3 && verts!=4) continue; - - pTriInfos[iDstTriIndex].iOrgFaceNumber = f; - pTriInfos[iDstTriIndex].iTSpacesOffs = iTSpacesOffs; - - if(verts==3) - { - unsigned char * pVerts = pTriInfos[iDstTriIndex].vert_num; - pVerts[0]=0; pVerts[1]=1; pVerts[2]=2; - piTriList_out[iDstTriIndex*3+0] = MakeIndex(f, 0); - piTriList_out[iDstTriIndex*3+1] = MakeIndex(f, 1); - piTriList_out[iDstTriIndex*3+2] = MakeIndex(f, 2); - ++iDstTriIndex; // next - } - else - { - { - pTriInfos[iDstTriIndex+1].iOrgFaceNumber = f; - pTriInfos[iDstTriIndex+1].iTSpacesOffs = iTSpacesOffs; - } - - { - // need an order independent way to evaluate - // tspace on quads. This is done by splitting - // along the shortest diagonal. - const int i0 = MakeIndex(f, 0); - const int i1 = MakeIndex(f, 1); - const int i2 = MakeIndex(f, 2); - const int i3 = MakeIndex(f, 3); - const SVec3 T0 = GetTexCoord(pContext, i0); - const SVec3 T1 = GetTexCoord(pContext, i1); - const SVec3 T2 = GetTexCoord(pContext, i2); - const SVec3 T3 = GetTexCoord(pContext, i3); - const float distSQ_02 = LengthSquared(vsub(T2,T0)); - const float distSQ_13 = LengthSquared(vsub(T3,T1)); - tbool bQuadDiagIs_02; - if(distSQ_02m_pInterface->m_getPosition(pContext, pos, iF, iI); - res.x=pos[0]; res.y=pos[1]; res.z=pos[2]; - return res; -} - -const SVec3 GetNormal(const SMikkTSpaceContext * pContext, const int index) -{ - int iF, iI; - SVec3 res; float norm[3]; - IndexToData(&iF, &iI, index); - pContext->m_pInterface->m_getNormal(pContext, norm, iF, iI); - res.x=norm[0]; res.y=norm[1]; res.z=norm[2]; - return res; -} - -const SVec3 GetTexCoord(const SMikkTSpaceContext * pContext, const int index) -{ - int iF, iI; - SVec3 res; float texc[2]; - IndexToData(&iF, &iI, index); - pContext->m_pInterface->m_getTexCoord(pContext, texc, iF, iI); - res.x=texc[0]; res.y=texc[1]; res.z=1.0f; - return res; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////// - -typedef union -{ - struct - { - int i0, i1, f; - }; - int array[3]; -} SEdge; - -void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int piTriListIn[], const int iNrTrianglesIn); -void BuildNeighborsSlow(STriInfo pTriInfos[], const int piTriListIn[], const int iNrTrianglesIn); - -// returns the texture area times 2 -static float CalcTexArea(const SMikkTSpaceContext * pContext, const int indices[]) -{ - const SVec3 t1 = GetTexCoord(pContext, indices[0]); - const SVec3 t2 = GetTexCoord(pContext, indices[1]); - const SVec3 t3 = GetTexCoord(pContext, indices[2]); - - const float t21x = t2.x-t1.x; - const float t21y = t2.y-t1.y; - const float t31x = t3.x-t1.x; - const float t31y = t3.y-t1.y; - - const float fSignedAreaSTx2 = t21x*t31y - t21y*t31x; - - return fSignedAreaSTx2<0 ? (-fSignedAreaSTx2) : fSignedAreaSTx2; -} - -void InitTriInfo(STriInfo pTriInfos[], const int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn) -{ - int f=0, i=0, t=0; - // pTriInfos[f].iFlag is cleared in GenerateInitialVerticesIndexList() which is called before this function. - - // generate neighbor info list - for(f=0; f0 ? ORIENT_PRESERVING : 0); - - if( NotZero(fSignedAreaSTx2) ) - { - const float fAbsArea = fabsf(fSignedAreaSTx2); - const float fLenOs = Length(vOs); - const float fLenOt = Length(vOt); - const float fS = (pTriInfos[f].iFlag&ORIENT_PRESERVING)==0 ? (-1.0f) : 1.0f; - if( NotZero(fLenOs) ) pTriInfos[f].vOs = vscale(fS/fLenOs, vOs); - if( NotZero(fLenOt) ) pTriInfos[f].vOt = vscale(fS/fLenOt, vOt); - - // evaluate magnitudes prior to normalization of vOs and vOt - pTriInfos[f].fMagS = fLenOs / fAbsArea; - pTriInfos[f].fMagT = fLenOt / fAbsArea; - - // if this is a good triangle - if( NotZero(pTriInfos[f].fMagS) && NotZero(pTriInfos[f].fMagT)) - pTriInfos[f].iFlag &= (~GROUP_WITH_ANY); - } - } - - // force otherwise healthy quads to a fixed orientation - while(t<(iNrTrianglesIn-1)) - { - const int iFO_a = pTriInfos[t].iOrgFaceNumber; - const int iFO_b = pTriInfos[t+1].iOrgFaceNumber; - if(iFO_a==iFO_b) // this is a quad - { - const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; - const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; - - // bad triangles should already have been removed by - // DegenPrologue(), but just in case check bIsDeg_a and bIsDeg_a are false - if((bIsDeg_a||bIsDeg_b)==TFALSE) - { - const tbool bOrientA = (pTriInfos[t].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; - const tbool bOrientB = (pTriInfos[t+1].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; - // if this happens the quad has extremely bad mapping!! - if(bOrientA!=bOrientB) - { - //printf("found quad with bad mapping\n"); - tbool bChooseOrientFirstTri = TFALSE; - if((pTriInfos[t+1].iFlag&GROUP_WITH_ANY)!=0) bChooseOrientFirstTri = TTRUE; - else if( CalcTexArea(pContext, &piTriListIn[t*3+0]) >= CalcTexArea(pContext, &piTriListIn[(t+1)*3+0]) ) - bChooseOrientFirstTri = TTRUE; - - // force match - { - const int t0 = bChooseOrientFirstTri ? t : (t+1); - const int t1 = bChooseOrientFirstTri ? (t+1) : t; - pTriInfos[t1].iFlag &= (~ORIENT_PRESERVING); // clear first - pTriInfos[t1].iFlag |= (pTriInfos[t0].iFlag&ORIENT_PRESERVING); // copy bit - } - } - } - t += 2; - } - else - ++t; - } - - // match up edge pairs - { - SEdge * pEdges = (SEdge *) malloc(sizeof(SEdge)*iNrTrianglesIn*3); - if(pEdges==NULL) - BuildNeighborsSlow(pTriInfos, piTriListIn, iNrTrianglesIn); - else - { - BuildNeighborsFast(pTriInfos, pEdges, piTriListIn, iNrTrianglesIn); - - free(pEdges); - } - } -} - -///////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////// - -tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[], const int iMyTriIndex, SGroup * pGroup); -void AddTriToGroup(SGroup * pGroup, const int iTriIndex); - -int Build4RuleGroups(STriInfo pTriInfos[], SGroup pGroups[], int piGroupTrianglesBuffer[], const int piTriListIn[], const int iNrTrianglesIn) -{ - const int iNrMaxGroups = iNrTrianglesIn*3; - int iNrActiveGroups = 0; - int iOffset = 0, f=0, i=0; - for(f=0; fiVertexRepresentitive = vert_index; - pTriInfos[f].AssignedGroup[i]->bOrientPreservering = (pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0; - pTriInfos[f].AssignedGroup[i]->iNrFaces = 0; - pTriInfos[f].AssignedGroup[i]->pFaceIndices = &piGroupTrianglesBuffer[iOffset]; - ++iNrActiveGroups; - - AddTriToGroup(pTriInfos[f].AssignedGroup[i], f); - bOrPre = (pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; - neigh_indexL = pTriInfos[f].FaceNeighbors[i]; - neigh_indexR = pTriInfos[f].FaceNeighbors[i>0?(i-1):2]; - if(neigh_indexL>=0) // neighbor - { - const tbool bAnswer = - AssignRecur(piTriListIn, pTriInfos, neigh_indexL, - pTriInfos[f].AssignedGroup[i] ); - - const tbool bOrPre2 = (pTriInfos[neigh_indexL].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; - const tbool bDiff = bOrPre!=bOrPre2 ? TTRUE : TFALSE; - assert(bAnswer || bDiff); - } - if(neigh_indexR>=0) // neighbor - { - const tbool bAnswer = - AssignRecur(piTriListIn, pTriInfos, neigh_indexR, - pTriInfos[f].AssignedGroup[i] ); - - const tbool bOrPre2 = (pTriInfos[neigh_indexR].iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; - const tbool bDiff = bOrPre!=bOrPre2 ? TTRUE : TFALSE; - assert(bAnswer || bDiff); - } - - // update offset - iOffset += pTriInfos[f].AssignedGroup[i]->iNrFaces; - // since the groups are disjoint a triangle can never - // belong to more than 3 groups. Subsequently something - // is completely screwed if this assertion ever hits. - assert(iOffset <= iNrMaxGroups); - } - } - } - - return iNrActiveGroups; -} - -void AddTriToGroup(SGroup * pGroup, const int iTriIndex) -{ - pGroup->pFaceIndices[pGroup->iNrFaces] = iTriIndex; - ++pGroup->iNrFaces; -} - -tbool AssignRecur(const int piTriListIn[], STriInfo psTriInfos[], - const int iMyTriIndex, SGroup * pGroup) -{ - STriInfo * pMyTriInfo = &psTriInfos[iMyTriIndex]; - - // track down vertex - const int iVertRep = pGroup->iVertexRepresentitive; - const int * pVerts = &piTriListIn[3*iMyTriIndex+0]; - int i=-1; - if(pVerts[0]==iVertRep) i=0; - else if(pVerts[1]==iVertRep) i=1; - else if(pVerts[2]==iVertRep) i=2; - assert(i>=0 && i<3); - - // early out - if(pMyTriInfo->AssignedGroup[i] == pGroup) return TTRUE; - else if(pMyTriInfo->AssignedGroup[i]!=NULL) return TFALSE; - if((pMyTriInfo->iFlag&GROUP_WITH_ANY)!=0) - { - // first to group with a group-with-anything triangle - // determines it's orientation. - // This is the only existing order dependency in the code!! - if( pMyTriInfo->AssignedGroup[0] == NULL && - pMyTriInfo->AssignedGroup[1] == NULL && - pMyTriInfo->AssignedGroup[2] == NULL ) - { - pMyTriInfo->iFlag &= (~ORIENT_PRESERVING); - pMyTriInfo->iFlag |= (pGroup->bOrientPreservering ? ORIENT_PRESERVING : 0); - } - } - { - const tbool bOrient = (pMyTriInfo->iFlag&ORIENT_PRESERVING)!=0 ? TTRUE : TFALSE; - if(bOrient != pGroup->bOrientPreservering) return TFALSE; - } - - AddTriToGroup(pGroup, iMyTriIndex); - pMyTriInfo->AssignedGroup[i] = pGroup; - - { - const int neigh_indexL = pMyTriInfo->FaceNeighbors[i]; - const int neigh_indexR = pMyTriInfo->FaceNeighbors[i>0?(i-1):2]; - if(neigh_indexL>=0) - AssignRecur(piTriListIn, psTriInfos, neigh_indexL, pGroup); - if(neigh_indexR>=0) - AssignRecur(piTriListIn, psTriInfos, neigh_indexR, pGroup); - } - - - - return TTRUE; -} - -///////////////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////////////// - -tbool CompareSubGroups(const SSubGroup * pg1, const SSubGroup * pg2); -void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed); -STSpace EvalTspace(int face_indices[], const int iFaces, const int piTriListIn[], const STriInfo pTriInfos[], const SMikkTSpaceContext * pContext, const int iVertexRepresentitive); - -tbool GenerateTSpaces(STSpace psTspace[], const STriInfo pTriInfos[], const SGroup pGroups[], - const int iNrActiveGroups, const int piTriListIn[], const float fThresCos, - const SMikkTSpaceContext * pContext) -{ - STSpace * pSubGroupTspace = NULL; - SSubGroup * pUniSubGroups = NULL; - int * pTmpMembers = NULL; - int iMaxNrFaces=0, iUniqueTspaces=0, g=0, i=0; - for(g=0; giNrFaces; i++) // triangles - { - const int f = pGroup->pFaceIndices[i]; // triangle number - int index=-1, iVertIndex=-1, iOF_1=-1, iMembers=0, j=0, l=0; - SSubGroup tmp_group; - tbool bFound; - SVec3 n, vOs, vOt; - if(pTriInfos[f].AssignedGroup[0]==pGroup) index=0; - else if(pTriInfos[f].AssignedGroup[1]==pGroup) index=1; - else if(pTriInfos[f].AssignedGroup[2]==pGroup) index=2; - assert(index>=0 && index<3); - - iVertIndex = piTriListIn[f*3+index]; - assert(iVertIndex==pGroup->iVertexRepresentitive); - - // is normalized already - n = GetNormal(pContext, iVertIndex); - - // project - vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n)); - vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n)); - if( VNotZero(vOs) ) vOs = Normalize(vOs); - if( VNotZero(vOt) ) vOt = Normalize(vOt); - - // original face number - iOF_1 = pTriInfos[f].iOrgFaceNumber; - - iMembers = 0; - for(j=0; jiNrFaces; j++) - { - const int t = pGroup->pFaceIndices[j]; // triangle number - const int iOF_2 = pTriInfos[t].iOrgFaceNumber; - - // project - SVec3 vOs2 = vsub(pTriInfos[t].vOs, vscale(vdot(n,pTriInfos[t].vOs), n)); - SVec3 vOt2 = vsub(pTriInfos[t].vOt, vscale(vdot(n,pTriInfos[t].vOt), n)); - if( VNotZero(vOs2) ) vOs2 = Normalize(vOs2); - if( VNotZero(vOt2) ) vOt2 = Normalize(vOt2); - - { - const tbool bAny = ( (pTriInfos[f].iFlag | pTriInfos[t].iFlag) & GROUP_WITH_ANY )!=0 ? TTRUE : TFALSE; - // make sure triangles which belong to the same quad are joined. - const tbool bSameOrgFace = iOF_1==iOF_2 ? TTRUE : TFALSE; - - const float fCosS = vdot(vOs,vOs2); - const float fCosT = vdot(vOt,vOt2); - - assert(f!=t || bSameOrgFace); // sanity check - if(bAny || bSameOrgFace || (fCosS>fThresCos && fCosT>fThresCos)) - pTmpMembers[iMembers++] = t; - } - } - - // sort pTmpMembers - tmp_group.iNrFaces = iMembers; - tmp_group.pTriMembers = pTmpMembers; - if(iMembers>1) - { - unsigned int uSeed = INTERNAL_RND_SORT_SEED; // could replace with a random seed? - QuickSort(pTmpMembers, 0, iMembers-1, uSeed); - } - - // look for an existing match - bFound = TFALSE; - l=0; - while(liVertexRepresentitive); - ++iUniqueSubGroups; - } - - // output tspace - { - const int iOffs = pTriInfos[f].iTSpacesOffs; - const int iVert = pTriInfos[f].vert_num[index]; - STSpace * pTS_out = &psTspace[iOffs+iVert]; - assert(pTS_out->iCounter<2); - assert(((pTriInfos[f].iFlag&ORIENT_PRESERVING)!=0) == pGroup->bOrientPreservering); - if(pTS_out->iCounter==1) - { - *pTS_out = AvgTSpace(pTS_out, &pSubGroupTspace[l]); - pTS_out->iCounter = 2; // update counter - pTS_out->bOrient = pGroup->bOrientPreservering; - } - else - { - assert(pTS_out->iCounter==0); - *pTS_out = pSubGroupTspace[l]; - pTS_out->iCounter = 1; // update counter - pTS_out->bOrient = pGroup->bOrientPreservering; - } - } - } - - // clean up and offset iUniqueTspaces - for(s=0; s=0 && i<3); - - // project - index = piTriListIn[3*f+i]; - n = GetNormal(pContext, index); - vOs = vsub(pTriInfos[f].vOs, vscale(vdot(n,pTriInfos[f].vOs), n)); - vOt = vsub(pTriInfos[f].vOt, vscale(vdot(n,pTriInfos[f].vOt), n)); - if( VNotZero(vOs) ) vOs = Normalize(vOs); - if( VNotZero(vOt) ) vOt = Normalize(vOt); - - i2 = piTriListIn[3*f + (i<2?(i+1):0)]; - i1 = piTriListIn[3*f + i]; - i0 = piTriListIn[3*f + (i>0?(i-1):2)]; - - p0 = GetPosition(pContext, i0); - p1 = GetPosition(pContext, i1); - p2 = GetPosition(pContext, i2); - v1 = vsub(p0,p1); - v2 = vsub(p2,p1); - - // project - v1 = vsub(v1, vscale(vdot(n,v1),n)); if( VNotZero(v1) ) v1 = Normalize(v1); - v2 = vsub(v2, vscale(vdot(n,v2),n)); if( VNotZero(v2) ) v2 = Normalize(v2); - - // weight contribution by the angle - // between the two edge vectors - fCos = vdot(v1,v2); fCos=fCos>1?1:(fCos<(-1) ? (-1) : fCos); - fAngle = (const float) acos(fCos); - fMagS = pTriInfos[f].fMagS; - fMagT = pTriInfos[f].fMagT; - - res.vOs=vadd(res.vOs, vscale(fAngle,vOs)); - res.vOt=vadd(res.vOt,vscale(fAngle,vOt)); - res.fMagS+=(fAngle*fMagS); - res.fMagT+=(fAngle*fMagT); - fAngleSum += fAngle; - } - } - - // normalize - if( VNotZero(res.vOs) ) res.vOs = Normalize(res.vOs); - if( VNotZero(res.vOt) ) res.vOt = Normalize(res.vOt); - if(fAngleSum>0) - { - res.fMagS /= fAngleSum; - res.fMagT /= fAngleSum; - } - - return res; -} - -tbool CompareSubGroups(const SSubGroup * pg1, const SSubGroup * pg2) -{ - tbool bStillSame=TTRUE; - int i=0; - if(pg1->iNrFaces!=pg2->iNrFaces) return TFALSE; - while(iiNrFaces && bStillSame) - { - bStillSame = pg1->pTriMembers[i]==pg2->pTriMembers[i] ? TTRUE : TFALSE; - if(bStillSame) ++i; - } - return bStillSame; -} - -void QuickSort(int* pSortBuffer, int iLeft, int iRight, unsigned int uSeed) -{ - int iL, iR, n, index, iMid, iTmp; - - // Random - unsigned int t=uSeed&31; - t=(uSeed<>(32-t)); - uSeed=uSeed+t+3; - // Random end - - iL=iLeft; iR=iRight; - n = (iR-iL)+1; - assert(n>=0); - index = (int) (uSeed%n); - - iMid=pSortBuffer[index + iL]; - - - do - { - while(pSortBuffer[iL] < iMid) - ++iL; - while(pSortBuffer[iR] > iMid) - --iR; - - if(iL <= iR) - { - iTmp = pSortBuffer[iL]; - pSortBuffer[iL] = pSortBuffer[iR]; - pSortBuffer[iR] = iTmp; - ++iL; --iR; - } - } - while(iL <= iR); - - if(iLeft < iR) - QuickSort(pSortBuffer, iLeft, iR, uSeed); - if(iL < iRight) - QuickSort(pSortBuffer, iL, iRight, uSeed); -} - -///////////////////////////////////////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////////////////////////////////////////// - -void QuickSortEdges(SEdge * pSortBuffer, int iLeft, int iRight, const int channel, unsigned int uSeed); -void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int indices[], const int i0_in, const int i1_in); - -void BuildNeighborsFast(STriInfo pTriInfos[], SEdge * pEdges, const int piTriListIn[], const int iNrTrianglesIn) -{ - // build array of edges - unsigned int uSeed = INTERNAL_RND_SORT_SEED; // could replace with a random seed? - int iEntries=0, iCurStartIndex=-1, f=0, i=0; - for(f=0; f pSortBuffer[iRight].array[channel]) - { - sTmp = pSortBuffer[iLeft]; - pSortBuffer[iLeft] = pSortBuffer[iRight]; - pSortBuffer[iRight] = sTmp; - } - return; - } - - // Random - t=uSeed&31; - t=(uSeed<>(32-t)); - uSeed=uSeed+t+3; - // Random end - - iL=iLeft, iR=iRight; - n = (iR-iL)+1; - assert(n>=0); - index = (int) (uSeed%n); - - iMid=pSortBuffer[index + iL].array[channel]; - - do - { - while(pSortBuffer[iL].array[channel] < iMid) - ++iL; - while(pSortBuffer[iR].array[channel] > iMid) - --iR; - - if(iL <= iR) - { - sTmp = pSortBuffer[iL]; - pSortBuffer[iL] = pSortBuffer[iR]; - pSortBuffer[iR] = sTmp; - ++iL; --iR; - } - } - while(iL <= iR); - - if(iLeft < iR) - QuickSortEdges(pSortBuffer, iLeft, iR, channel, uSeed); - if(iL < iRight) - QuickSortEdges(pSortBuffer, iL, iRight, channel, uSeed); -} - -// resolve ordering and edge number -void GetEdge(int * i0_out, int * i1_out, int * edgenum_out, const int indices[], const int i0_in, const int i1_in) -{ - *edgenum_out = -1; - - // test if first index is on the edge - if(indices[0]==i0_in || indices[0]==i1_in) - { - // test if second index is on the edge - if(indices[1]==i0_in || indices[1]==i1_in) - { - edgenum_out[0]=0; // first edge - i0_out[0]=indices[0]; - i1_out[0]=indices[1]; - } - else - { - edgenum_out[0]=2; // third edge - i0_out[0]=indices[2]; - i1_out[0]=indices[0]; - } - } - else - { - // only second and third index is on the edge - edgenum_out[0]=1; // second edge - i0_out[0]=indices[1]; - i1_out[0]=indices[2]; - } -} - - -///////////////////////////////////////////////////////////////////////////////////////////// -/////////////////////////////////// Degenerate triangles //////////////////////////////////// - -void DegenPrologue(STriInfo pTriInfos[], int piTriList_out[], const int iNrTrianglesIn, const int iTotTris) -{ - int iNextGoodTriangleSearchIndex=-1; - tbool bStillFindingGoodOnes; - - // locate quads with only one good triangle - int t=0; - while(t<(iTotTris-1)) - { - const int iFO_a = pTriInfos[t].iOrgFaceNumber; - const int iFO_b = pTriInfos[t+1].iOrgFaceNumber; - if(iFO_a==iFO_b) // this is a quad - { - const tbool bIsDeg_a = (pTriInfos[t].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; - const tbool bIsDeg_b = (pTriInfos[t+1].iFlag&MARK_DEGENERATE)!=0 ? TTRUE : TFALSE; - if((bIsDeg_a^bIsDeg_b)!=0) - { - pTriInfos[t].iFlag |= QUAD_ONE_DEGEN_TRI; - pTriInfos[t+1].iFlag |= QUAD_ONE_DEGEN_TRI; - } - t += 2; - } - else - ++t; - } - - // reorder list so all degen triangles are moved to the back - // without reordering the good triangles - iNextGoodTriangleSearchIndex = 1; - t=0; - bStillFindingGoodOnes = TTRUE; - while(t (t+1)); - - // swap triangle t0 and t1 - if(!bJustADegenerate) - { - int i=0; - for(i=0; i<3; i++) - { - const int index = piTriList_out[t0*3+i]; - piTriList_out[t0*3+i] = piTriList_out[t1*3+i]; - piTriList_out[t1*3+i] = index; - } - { - const STriInfo tri_info = pTriInfos[t0]; - pTriInfos[t0] = pTriInfos[t1]; - pTriInfos[t1] = tri_info; - } - } - else - bStillFindingGoodOnes = TFALSE; // this is not supposed to happen - } - - if(bStillFindingGoodOnes) ++t; - } - - assert(bStillFindingGoodOnes); // code will still work. - assert(iNrTrianglesIn == t); -} - -void DegenEpilogue(STSpace psTspace[], STriInfo pTriInfos[], int piTriListIn[], const SMikkTSpaceContext * pContext, const int iNrTrianglesIn, const int iTotTris) -{ - int t=0, i=0; - // deal with degenerate triangles - // punishment for degenerate triangles is O(N^2) - for(t=iNrTrianglesIn; t Date: Tue, 15 Feb 2011 15:03:49 +0000 Subject: Fix for [#26083] Animated Particle Textures have no effect * Duplicating particle settings didn't duplicate texture slots. --- source/blender/blenkernel/intern/particle.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index d1d5c13c3dd..5fc22bd842a 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3566,13 +3566,22 @@ ParticleSettings *psys_new_settings(const char *name, Main *main) ParticleSettings *psys_copy_settings(ParticleSettings *part) { ParticleSettings *partn; - + int a; + partn= copy_libblock(part); if(partn->pd) partn->pd= MEM_dupallocN(part->pd); if(partn->pd2) partn->pd2= MEM_dupallocN(part->pd2); partn->effector_weights = MEM_dupallocN(part->effector_weights); partn->boids = boid_copy_settings(part->boids); + + for(a=0; amtex[a]) { + partn->mtex[a]= MEM_mallocN(sizeof(MTex), "psys_copy_tex"); + memcpy(partn->mtex[a], part->mtex[a], sizeof(MTex)); + id_us_plus((ID *)partn->mtex[a]->tex); + } + } return partn; } -- cgit v1.2.3 From ac1e2fc977671bb55263811a1f009392a7b64d6c Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 16 Feb 2011 09:59:29 +0000 Subject: Bugfix [#22535] Dupliframes with keyframe Anim are broken So, it turns out that dupliframes weren't that bad to restore... the old version didn't do truly accurate transform freezing as it didn't update ancestors too. However, as a modelling tool, this will probably suffice. --- source/blender/blenkernel/intern/anim.c | 70 ++++++++++++++++++++----------- source/blender/blenkernel/intern/object.c | 6 +-- 2 files changed, 49 insertions(+), 27 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 8fdfca33efb..875132d2776 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -49,6 +49,7 @@ #include "DNA_scene_types.h" #include "DNA_vfont_types.h" +#include "BKE_animsys.h" #include "BKE_curve.h" #include "BKE_DerivedMesh.h" #include "BKE_depsgraph.h" @@ -742,41 +743,62 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, int animated) { extern int enable_cu_speed; /* object.c */ - Object copyob; - DupliObject *dob; - int cfrao, ok; + int cfrao = scene->r.cfra; + float omat[4][4]; - /* simple preventing of too deep nested groups */ - if(level>MAX_DUPLI_RECUR) return; + /* simple prevention of too deep nested groups */ + if (level > MAX_DUPLI_RECUR) return; - cfrao= scene->r.cfra; - if(ob->parent==NULL && ob->constraints.first==NULL) return; - - if(ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0; - copyob= *ob; /* store transform info */ - - for(scene->r.cfra= ob->dupsta; scene->r.cfra<=ob->dupend; scene->r.cfra++) { - - ok= 1; - if(ob->dupoff) { + /* if we don't have any data/settings which will lead to object movement, + * don't waste time trying, as it will all look the same... + */ + if (ob->parent==NULL && ob->constraints.first==NULL && ob->adt==NULL) + return; + if (ob->adt->action==NULL && ob->adt->nla_tracks.first==NULL && ob->adt->drivers.first==NULL) + return; + + /* make a copy of the object's original transform matrix */ + copy_m4_m4(omat, ob->obmat); + + /* duplicate over the required range */ + if (ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0; + + for (scene->r.cfra= ob->dupsta; scene->r.cfra<=ob->dupend; scene->r.cfra++) { + short ok= 1; + + /* - dupoff = how often a frames within the range shouldn't be made into duplis + * - dupon = the length of each "skipping" block in frames + */ + if (ob->dupoff) { ok= scene->r.cfra - ob->dupsta; ok= ok % (ob->dupon+ob->dupoff); - if(ok < ob->dupon) ok= 1; - else ok= 0; + ok= (ok < ob->dupon); } - if(ok) { -#if 0 // XXX old animation system - do_ob_ipo(scene, ob); -#endif // XXX old animation system + + if (ok) { + DupliObject *dob; + + /* WARNING: doing animation updates in this way is not terribly accurate, as the dependencies + * and/or other objects which may affect this object's transforms are not updated either. + * However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine! + */ + BKE_animsys_evaluate_animdata(&ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */ where_is_object_time(scene, ob, (float)scene->r.cfra); + dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated); - copy_m4_m4(dob->omat, copyob.obmat); + copy_m4_m4(dob->omat, omat); } } - *ob= copyob; /* restore transform info */ - scene->r.cfra= cfrao; enable_cu_speed= 1; + + /* reset frame to original frame, then re-evaluate animation as above + * as 2.5 animation data may have far-reaching consequences + */ + scene->r.cfra= cfrao; + + BKE_animsys_evaluate_animdata(&ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */ + where_is_object_time(scene, ob, (float)scene->r.cfra); } typedef struct vertexDupliData { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index d0f2232a683..06f641fb28a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1688,10 +1688,10 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) else { /* quats are normalised before use to eliminate scaling issues */ float tquat[4]; - + normalize_qt_qt(tquat, ob->quat); quat_to_mat3(rmat, tquat); - + normalize_qt_qt(tquat, ob->dquat); quat_to_mat3(dmat, tquat); } @@ -1735,7 +1735,7 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const invert_m4_m4(imat, diff_mat); mul_m4_m4m4(rmat, mat, imat); /* get the parent relative matrix */ object_apply_mat4(ob, rmat, use_compat, FALSE); - + /* same as below, use rmat rather then mat */ mat4_to_loc_rot_size(ob->loc, rot, ob->size, rmat); object_mat3_to_rot(ob, rot, use_compat); -- cgit v1.2.3 From 2c4fb98522d152c7ec8e973a72bdbacff95158a3 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Wed, 16 Feb 2011 21:54:41 +0000 Subject: Bugfix [#26106] No instant visual feed back for Dupliframes, parenting problem and crash - It turns out we still need the "copyob" still, if for nothing other than making sure that the unkeyed transforms can get restored. This was removed originally as I thought that just reevaluating the animation would work. - Removed a buggy line of logic that was causing crashes when there was no animation data. It's better to just assume that if animation data exists, that something exists there. - Make Duplicates Real was not clearing data such as the new animation data or constraints. --- source/blender/blenkernel/intern/anim.c | 19 +++++++++++++------ source/blender/blenkernel/intern/object.c | 9 +++++++-- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 875132d2776..08d506f94b8 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -743,8 +743,8 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, int animated) { extern int enable_cu_speed; /* object.c */ + Object copyob = {{NULL}}; int cfrao = scene->r.cfra; - float omat[4][4]; /* simple prevention of too deep nested groups */ if (level > MAX_DUPLI_RECUR) return; @@ -754,11 +754,13 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, */ if (ob->parent==NULL && ob->constraints.first==NULL && ob->adt==NULL) return; - if (ob->adt->action==NULL && ob->adt->nla_tracks.first==NULL && ob->adt->drivers.first==NULL) - return; - /* make a copy of the object's original transform matrix */ - copy_m4_m4(omat, ob->obmat); + /* make a copy of the object's original data (before any dupli-data overwrites it) + * as we'll need this to keep track of unkeyed data + * - this doesn't take into account other data that can be reached from the object, + * for example it's shapekeys or bones, hence the need for an update flush at the end + */ + copyob = *ob; /* duplicate over the required range */ if (ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0; @@ -786,7 +788,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, where_is_object_time(scene, ob, (float)scene->r.cfra); dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated); - copy_m4_m4(dob->omat, omat); + copy_m4_m4(dob->omat, copyob.obmat); } } @@ -799,6 +801,11 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, BKE_animsys_evaluate_animdata(&ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */ where_is_object_time(scene, ob, (float)scene->r.cfra); + + /* but, to make sure unkeyed object transforms are still sane, + * let's copy object's original data back over + */ + *ob = copyob; } typedef struct vertexDupliData { diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 06f641fb28a..21a53d5365a 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -1809,12 +1809,17 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) * we divide the curvetime calculated in the previous step by the length of the path, to get a time * factor, which then gets clamped to lie within 0.0 - 1.0 range */ - ctime= cu->ctime / cu->pathlen; + if (IS_EQ(cu->pathlen, 0.0f) == 0) + ctime= cu->ctime / cu->pathlen; + else + ctime= cu->ctime; + CLAMP(ctime, 0.0, 1.0); } else { ctime= scene->r.cfra - give_timeoffset(ob); - ctime /= cu->pathlen; + if (IS_EQ(cu->pathlen, 0.0f) == 0) + ctime /= cu->pathlen; CLAMP(ctime, 0.0, 1.0); } -- cgit v1.2.3 From 1b25f48542b85f61e9fb6044e5ec0b1985a7906a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 17 Feb 2011 12:05:09 +0000 Subject: clear some unused warnings --- source/blender/blenkernel/intern/CCGSubSurf.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 1d6aa9bd6d7..3564c93681a 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -239,17 +239,17 @@ static int _edge_isBoundary(CCGEdge *e); /***/ -static enum { +enum { Vert_eEffected= (1<<0), Vert_eChanged= (1<<1), Vert_eSeam= (1<<2), -} VertFlags; -static enum { +} /*VertFlags*/; +enum { Edge_eEffected= (1<<0), -} CCGEdgeFlags; -static enum { +} /*CCGEdgeFlags*/; +enum { Face_eEffected= (1<<0), -} FaceFlags; +} /*FaceFlags*/; struct _CCGVert { CCGVert *next; /* EHData.next */ -- cgit v1.2.3 From 27e812d69702c43313af8a5521841fd7f4da69f1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 17 Feb 2011 22:34:41 +0000 Subject: Clear some compiler warnings by commenting some functions, adding others to headers. left in warnings where functions obviously need to get ported to 2.5x still. Also, render stamp seq strip works again. --- source/blender/blenkernel/intern/image.c | 5 ++--- source/blender/blenkernel/intern/sequencer.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 64327b2005d..dc690f45709 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -72,10 +72,9 @@ #include "BKE_packedFile.h" #include "BKE_scene.h" #include "BKE_node.h" +#include "BKE_sequencer.h" /* seq_foreground_frame_get() */ #include "BKE_utildefines.h" -//XXX #include "BIF_editseq.h" - #include "BLF_api.h" #include "PIL_time.h" @@ -968,7 +967,7 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } if (scene->r.stamp & R_STAMP_SEQSTRIP) { - Sequence *seq= NULL; //XXX = get_foreground_frame_seq(scene->r.cfra); + Sequence *seq= seq_foreground_frame_get(scene, scene->r.cfra); if (seq) strcpy(text, seq->name+2); else strcpy(text, ""); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 9537931faec..2785878fb08 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2965,6 +2965,28 @@ void seq_translate(Scene *evil_scene, Sequence *seq, int delta) calc_sequence_disp(evil_scene, seq); } +Sequence *seq_foreground_frame_get(Scene *scene, int frame) +{ + Editing *ed= seq_give_editing(scene, FALSE); + Sequence *seq, *best_seq=NULL; + int best_machine = -1; + + if(!ed) return NULL; + + for (seq=ed->seqbasep->first; seq; seq= seq->next) { + if(seq->flag & SEQ_MUTE || seq->startdisp > frame || seq->enddisp <= frame) + continue; + /* only use elements you can see - not */ + if (ELEM5(seq->type, SEQ_IMAGE, SEQ_META, SEQ_SCENE, SEQ_MOVIE, SEQ_COLOR)) { + if (seq->machine > best_machine) { + best_seq = seq; + best_machine = seq->machine; + } + } + } + return best_seq; +} + /* return 0 if there werent enough space */ int shuffle_seq(ListBase * seqbasep, Sequence *test, Scene *evil_scene) { -- cgit v1.2.3 From 6a9734821dd93a936e54fdc2bb75f376ddceecc6 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 18 Feb 2011 00:17:46 +0000 Subject: Particle textures didn't use original coordinates properly for grid distribution. --- source/blender/blenkernel/intern/particle.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 5fc22bd842a..bbc597788fe 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1831,9 +1831,11 @@ static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float * void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor){ if(psmd){ if(psmd->psys->part->distr==PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT){ - if(vec){ - VECCOPY(vec,fuv); - } + if(vec) + copy_v3_v3(vec,fuv); + + if(orco) + copy_v3_v3(orco, fuv); return; } /* we cant use the num_dmcache */ @@ -3780,7 +3782,7 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex short blend=mtex->blendtype; short texco = mtex->texco; - if(ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID)) + if(texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID)) texco = TEXCO_GLOB; switch(texco) { -- cgit v1.2.3 From fd155103a23d8648a64ad74c7c97fa373f441599 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 18 Feb 2011 00:21:19 +0000 Subject: Particle fluid settings weren't copied when particle settings were copied. * Also removed some unnecessary null checks. --- source/blender/blenkernel/intern/particle.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index bbc597788fe..4609e64c271 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3571,9 +3571,10 @@ ParticleSettings *psys_copy_settings(ParticleSettings *part) int a; partn= copy_libblock(part); - if(partn->pd) partn->pd= MEM_dupallocN(part->pd); - if(partn->pd2) partn->pd2= MEM_dupallocN(part->pd2); - partn->effector_weights = MEM_dupallocN(part->effector_weights); + partn->pd= MEM_dupallocN(part->pd); + partn->pd2= MEM_dupallocN(part->pd2); + partn->effector_weights= MEM_dupallocN(part->effector_weights); + partn->fluid= MEM_dupallocN(part->fluid); partn->boids = boid_copy_settings(part->boids); -- cgit v1.2.3 From 13f9715e1cfa36787577f11b933c26d7da365e47 Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Fri, 18 Feb 2011 15:21:52 +0000 Subject: Bug fix: with bigger than 1 cache step dead particles didn't alway stay dead * Particle die time wasn't properly taken into account when reading from the cache. --- source/blender/blenkernel/intern/pointcache.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index c2ec463c708..b7ece436ee2 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -280,6 +280,8 @@ static void ptcache_particle_read(int index, void *psys_v, void **data, float cf /* set frames cached before birth to birth time */ if(cfra < pa->time) pa->state.time = pa->time; + else if(cfra > pa->dietime) + pa->state.time = pa->dietime; if(data[BPHYS_DATA_SIZE]) PTCACHE_DATA_TO(data, BPHYS_DATA_SIZE, 0, &pa->size); -- cgit v1.2.3 From c09e8b34348518e0f81dfed0d7aea61f852bf26f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 19 Feb 2011 09:01:28 +0000 Subject: fix for string wrap backface culling not working when one of the objects was rotated. also skip calculating the dot product if its not needed. --- source/blender/blenkernel/intern/shrinkwrap.c | 32 +++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 29c29fb5158..a75bc2164c3 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -255,22 +255,26 @@ int normal_projection_project_vertex(char options, const float *vert, const floa BLI_bvhtree_ray_cast(tree, co, no, 0.0f, &hit_tmp, callback, userdata); - if(hit_tmp.index != -1) - { - float dot = INPR( dir, hit_tmp.no); - - if(((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) - || ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f)) - return FALSE; //Ignore hit - + if(hit_tmp.index != -1) { + /* invert the normal first so face culling works on rotated objects */ + if(transf) { + space_transform_invert_normal(transf, hit_tmp.no); + } - //Inverting space transform (TODO make coeherent with the initial dist readjust) - if(transf) - { - space_transform_invert( transf, hit_tmp.co ); - space_transform_invert_normal( transf, hit_tmp.no ); + if (options & (MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE|MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) { + /* apply backface */ + const float dot= dot_v3v3(dir, hit_tmp.no); + if( ((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) || + ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f) + ) { + return FALSE; /* Ignore hit */ + } + } - hit_tmp.dist = len_v3v3( (float*)vert, hit_tmp.co ); + if(transf) { + /* Inverting space transform (TODO make coeherent with the initial dist readjust) */ + space_transform_invert(transf, hit_tmp.co); + hit_tmp.dist = len_v3v3((float *)vert, hit_tmp.co); } memcpy(hit, &hit_tmp, sizeof(hit_tmp) ); -- cgit v1.2.3 From 9ee1b3930fef6404f197a56363bee4f846bc2bb7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 19 Feb 2011 12:05:20 +0000 Subject: set main() argv functions to be const char * also set minimum cmake version to 2.8 --- source/blender/blenkernel/intern/sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index be6c4d22f9c..9c157f57d49 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -55,7 +55,7 @@ static void sound_sync_callback(void* data, int mode, float time) } #endif -int sound_define_from_str(char *str) +int sound_define_from_str(const char *str) { if (BLI_strcaseeq(str, "NULL")) return AUD_NULL_DEVICE; -- cgit v1.2.3 From 6481921b9ad3d6e50a2aaa2f4a03e2fefcb14a94 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Sat, 19 Feb 2011 14:32:34 +0000 Subject: Bugfix #26015 A very Bad Bug! On every draw-object, a function free_old_images() was called which was freeing "unused" images during renders/bakes This was a left-over from 2.4x code, missed it altogether. I'm sure this fix will solve a lot of render crashing... :) --- source/blender/blenkernel/intern/image.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index dc690f45709..8a15f63243c 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -526,6 +526,10 @@ void free_old_images(void) if (U.textimeout == 0 || ctime % U.texcollectrate || ctime == lasttime) return; + /* of course not! */ + if (G.rendering) + return; + lasttime = ctime; ima= G.main->image.first; @@ -2182,10 +2186,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) BLI_unlock_thread(LOCK_IMAGE); } - /* we assuming that if it is not rendering, it's also not multithreaded - * (a somewhat weak assumption) */ - if(G.rendering==0) - tag_image_time(ima); + tag_image_time(ima); return ibuf; } -- cgit v1.2.3 From 8c4e95da48b3b896f012d7a1b7c89841270c40c6 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Sun, 20 Feb 2011 15:35:01 +0000 Subject: Fix for crash when sculpting on multires object during playback - Restored BLI_pbvh_grids_update stuff; - Marc all nodes as changes in ED_sculpt_modifiers_changed, so draw_buffers would be keept correct. --- source/blender/blenkernel/intern/subsurf_ccg.c | 10 +++++++++- 1 file changed, 9 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 0889f490e79..9b4b9a78dd4 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2251,8 +2251,16 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) if(!ob->sculpt) return NULL; - if(ob->sculpt->pbvh) + if(ob->sculpt->pbvh) { + /* pbvh's grids, gridadj and gridfaces points to data inside ccgdm + but this can be freed on ccgdm release, this updates the pointers + when the ccgdm gets remade, the assumption is that the topology + does not change. */ + ccgdm_create_grids(dm); + BLI_pbvh_grids_update(ob->sculpt->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, (void**)ccgdm->gridFaces); + ccgdm->pbvh = ob->sculpt->pbvh; + } if(ccgdm->pbvh) return ccgdm->pbvh; -- cgit v1.2.3 From 1c7a422f78805a0533d9623c3f11f682f0c98083 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Mon, 21 Feb 2011 13:47:49 +0000 Subject: Big node groups improvement patch. Node group trees now have their own lists of input/output sockets. Those can be linked to internal nodes just like links between regular nodes. In addition group sockets can be renamed and have a defined order, which can be modified, and they can be removed again. More details can be found in the patch tracker description (#24883) and on the code.blender.org development blog. --- source/blender/blenkernel/intern/node.c | 1099 ++++++++++++++++--------------- 1 file changed, 557 insertions(+), 542 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 057d90dc8bb..cebbab45928 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -31,12 +31,17 @@ #include #endif +#include "MEM_guardedalloc.h" + #include #include #include #include "DNA_anim_types.h" #include "DNA_action_types.h" +#include "DNA_node_types.h" + +#include "BLI_listbase.h" #include "RNA_access.h" @@ -45,6 +50,7 @@ #include "BKE_fcurve.h" #include "BKE_node.h" #include "BKE_utildefines.h" +#include "BKE_node.h" #include "PIL_time.h" @@ -64,22 +70,14 @@ ListBase node_all_textures = {NULL, NULL}; /* ************** Type stuff ********** */ -static bNodeType *node_get_type(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) +static bNodeType *node_get_type(bNodeTree *ntree, int type, ID *id) { - if(type==NODE_GROUP) { - if(ngroup && GS(ngroup->id.name)==ID_NT) { - return ngroup->owntype; - } - return NULL; - } - else { - bNodeType *ntype = ntree->alltypes.first; - for(; ntype; ntype= ntype->next) - if(ntype->type==type && id==ntype->id ) - return ntype; - - return NULL; - } + bNodeType *ntype = ntree->alltypes.first; + for(; ntype; ntype= ntype->next) + if(ntype->type==type && id==ntype->id ) + return ntype; + + return NULL; } void ntreeInitTypes(bNodeTree *ntree) @@ -102,11 +100,11 @@ void ntreeInitTypes(bNodeTree *ntree) if(node->type==NODE_DYNAMIC) { bNodeType *stype= NULL; if(node->id==NULL) { /* empty script node */ - stype= node_get_type(ntree, node->type, NULL, NULL); + stype= node_get_type(ntree, node->type, NULL); } else { /* not an empty script node */ - stype= node_get_type(ntree, node->type, NULL, node->id); + stype= node_get_type(ntree, node->type, node->id); if(!stype) { - stype= node_get_type(ntree, node->type, NULL, NULL); + stype= node_get_type(ntree, node->type, NULL); /* needed info if the pynode script fails now: */ if (node->id) node->storage= ntree; } else { @@ -118,7 +116,7 @@ void ntreeInitTypes(bNodeTree *ntree) if(node->typeinfo) node->typeinfo->initfunc(node); } else { - node->typeinfo= node_get_type(ntree, node->type, (bNodeTree *)node->id, NULL); + node->typeinfo= node_get_type(ntree, node->type, NULL); } if(node->typeinfo==NULL) { @@ -152,9 +150,6 @@ static bNodeSocket *node_add_socket_type(ListBase *lb, bNodeSocketType *stype) else sock->limit= stype->limit; sock->type= stype->type; - sock->to_index= stype->own_index; - sock->tosock= stype->internsock; - sock->ns.vec[0]= stype->val1; sock->ns.vec[1]= stype->val2; sock->ns.vec[2]= stype->val3; @@ -168,6 +163,30 @@ static bNodeSocket *node_add_socket_type(ListBase *lb, bNodeSocketType *stype) return sock; } +static bNodeSocket *node_add_group_socket(ListBase *lb, bNodeSocket *gsock) +{ + bNodeSocket *sock= MEM_callocN(sizeof(bNodeSocket), "sock"); + + /* make a copy of the group socket */ + *sock = *gsock; + sock->link = NULL; + sock->next = sock->prev = NULL; + sock->new_sock = NULL; + sock->ns.data = NULL; + + sock->own_index = gsock->own_index; + sock->groupsock = gsock; + /* XXX hack: group socket input/output roles are inverted internally, + * need to change the limit value when making actual node sockets from them. + */ + sock->limit = (gsock->limit==1 ? 0xFFF : 1); + + if(lb) + BLI_addtail(lb, sock); + + return sock; +} + static void node_rem_socket(bNodeTree *ntree, ListBase *lb, bNodeSocket *sock) { bNodeLink *link, *next; @@ -188,18 +207,16 @@ static bNodeSocket *verify_socket(ListBase *lb, bNodeSocketType *stype) bNodeSocket *sock; for(sock= lb->first; sock; sock= sock->next) { - /* both indices are zero for non-groups, otherwise it's a unique index */ - if(sock->to_index==stype->own_index) - if(strncmp(sock->name, stype->name, NODE_MAXSTR)==0) - break; + if(strncmp(sock->name, stype->name, NODE_MAXSTR)==0) + break; } if(sock) { sock->type= stype->type; /* in future, read this from tydefs! */ if(stype->limit==0) sock->limit= 0xFFF; else sock->limit= stype->limit; + sock->ns.min= stype->min; sock->ns.max= stype->max; - sock->tosock= stype->internsock; BLI_remlink(lb, sock); @@ -210,6 +227,37 @@ static bNodeSocket *verify_socket(ListBase *lb, bNodeSocketType *stype) } } +static bNodeSocket *verify_group_socket(ListBase *lb, bNodeSocket *gsock) +{ + bNodeSocket *sock; + + for(sock= lb->first; sock; sock= sock->next) { + if(sock->own_index==gsock->own_index) + break; + } + if(sock) { + sock->groupsock = gsock; + + strcpy(sock->name, gsock->name); + sock->type= gsock->type; + + /* XXX hack: group socket input/output roles are inverted internally, + * need to change the limit value when making actual node sockets from them. + */ + sock->limit = (gsock->limit==1 ? 0xFFF : 1); + + sock->ns.min= gsock->ns.min; + sock->ns.max= gsock->ns.max; + + BLI_remlink(lb, sock); + + return sock; + } + else { + return node_add_group_socket(NULL, gsock); + } +} + static void verify_socket_list(bNodeTree *ntree, ListBase *lb, bNodeSocketType *stype_first) { bNodeSocketType *stype; @@ -238,15 +286,41 @@ static void verify_socket_list(bNodeTree *ntree, ListBase *lb, bNodeSocketType * } } -void nodeVerifyType(bNodeTree *ntree, bNode *node) +static void verify_group_socket_list(bNodeTree *ntree, ListBase *lb, ListBase *glb) { - bNodeType *ntype= node->typeinfo; + bNodeSocket *gsock; - if(ntype) { - /* might add some other verify stuff here */ - - verify_socket_list(ntree, &node->inputs, ntype->inputs); - verify_socket_list(ntree, &node->outputs, ntype->outputs); + /* step by step compare */ + for (gsock= glb->first; gsock; gsock=gsock->next) { + /* abusing new_sock pointer for verification here! only used inside this function */ + gsock->new_sock= verify_group_socket(lb, gsock); + } + /* leftovers are removed */ + while(lb->first) + node_rem_socket(ntree, lb, lb->first); + /* and we put back the verified sockets */ + for (gsock= glb->first; gsock; gsock=gsock->next) { + BLI_addtail(lb, gsock->new_sock); + gsock->new_sock = NULL; + } +} + +void nodeVerifyType(bNodeTree *ntree, bNode *node) +{ + /* node groups don't have static sock lists, but use external sockets from the tree instead */ + if (node->type==NODE_GROUP) { + bNodeTree *ngroup= (bNodeTree*)node->id; + if (ngroup) { + verify_group_socket_list(ntree, &node->inputs, &ngroup->inputs); + verify_group_socket_list(ntree, &node->outputs, &ngroup->outputs); + } + } + else { + bNodeType *ntype= node->typeinfo; + if(ntype) { + verify_socket_list(ntree, &node->inputs, ntype->inputs); + verify_socket_list(ntree, &node->outputs, ntype->outputs); + } } } @@ -283,176 +357,20 @@ void register_node_type_group(ListBase *lb) nodeRegisterType(lb, &ntype_group); } -/* tag internal sockets */ -static void group_tag_internal_sockets(bNodeTree *ngroup) +static bNodeSocket *find_group_node_input(bNode *gnode, bNodeSocket *gsock) { - bNode *node; bNodeSocket *sock; - bNodeLink *link; - - /* clear intern tag, but check already for hidden sockets */ - for(node= ngroup->nodes.first; node; node= node->next) { - for(sock= node->inputs.first; sock; sock= sock->next) - sock->intern= sock->flag & SOCK_HIDDEN; - for(sock= node->outputs.first; sock; sock= sock->next) - sock->intern= sock->flag & (SOCK_HIDDEN|SOCK_UNAVAIL); - } - /* set tag */ - for(link= ngroup->links.first; link; link= link->next) { - link->fromsock->intern= 1; - link->tosock->intern= 1; - } - - /* remove link pointer to external links (only happens on create group) */ - for(node= ngroup->nodes.first; node; node= node->next) { - for(sock= node->inputs.first; sock; sock= sock->next) - if(sock->intern==0) - sock->link= NULL; - } - - /* set all intern sockets to own_index zero, makes sure that later use won't mixup */ - for(node= ngroup->nodes.first; node; node= node->next) { - for(sock= node->inputs.first; sock; sock= sock->next) - if(sock->intern) - sock->own_index= 0; - for(sock= node->outputs.first; sock; sock= sock->next) - if(sock->intern) - sock->own_index= 0; - } -} - -/* after editing group, new sockets are zero */ -/* this routine ensures unique identifiers for zero sockets that are exposed */ -static void group_verify_own_indices(bNodeTree *ngroup) -{ - bNode *node; - bNodeSocket *sock; - - for(node= ngroup->nodes.first; node; node= node->next) { - for(sock= node->inputs.first; sock; sock= sock->next) - if(sock->own_index==0 && sock->intern==0) - sock->own_index= ++(ngroup->cur_index); - for(sock= node->outputs.first; sock; sock= sock->next) - if(sock->own_index==0 && sock->intern==0) - sock->own_index= ++(ngroup->cur_index); - } - //printf("internal index %d\n", ngroup->cur_index); -} - - -/* nodetrees can be used as groups, so we need typeinfo structs generated */ -void ntreeMakeOwnType(bNodeTree *ngroup) -{ - bNode *node; - bNodeSocket *sock; - int totin= 0, totout=0, a; - - /* tags socket when internal linked */ - group_tag_internal_sockets(ngroup); - - /* ensure all sockets have own unique id */ - group_verify_own_indices(ngroup); - - /* counting stats */ - for(node= ngroup->nodes.first; node; node= node->next) { - if(node->type==NODE_GROUP) - break; - for(sock= node->inputs.first; sock; sock= sock->next) - if(sock->intern==0) - totin++; - for(sock= node->outputs.first; sock; sock= sock->next) - if(sock->intern==0) - totout++; - } - /* debug: nodetrees in nodetrees not handled yet */ - if(node) { - printf("group in group, not supported yet\n"); - return; - } - - /* free own type struct */ - if(ngroup->owntype) { - if(ngroup->owntype->inputs) - MEM_freeN(ngroup->owntype->inputs); - if(ngroup->owntype->outputs) - MEM_freeN(ngroup->owntype->outputs); - MEM_freeN(ngroup->owntype); - } - - /* make own type struct */ - ngroup->owntype= MEM_callocN(sizeof(bNodeType), "group type"); - *ngroup->owntype= ntype_group; /* copy data, for init */ - - /* input type arrays */ - if(totin) { - bNodeSocketType *stype; - bNodeSocketType *inputs= MEM_callocN(sizeof(bNodeSocketType)*(totin+1), "bNodeSocketType"); - a= 0; - - for(node= ngroup->nodes.first; node; node= node->next) { - /* nodes are presumed fully verified, stype and socket list are in sync */ - stype= node->typeinfo->inputs; - for(sock= node->inputs.first; sock; sock= sock->next, stype++) { - if(sock->intern==0) { - /* debug only print */ - if(stype==NULL || stype->type==-1) printf("group verification error %s\n", ngroup->id.name); - - inputs[a]= *stype; - inputs[a].own_index= sock->own_index; - inputs[a].internsock= sock; - a++; - } - } - } - inputs[a].type= -1; /* terminator code */ - ngroup->owntype->inputs= inputs; - } - - /* output type arrays */ - if(totout) { - bNodeSocketType *stype; - bNodeSocketType *outputs= MEM_callocN(sizeof(bNodeSocketType)*(totout+1), "bNodeSocketType"); - a= 0; - - for(node= ngroup->nodes.first; node; node= node->next) { - /* nodes are presumed fully verified, stype and socket list are in sync */ - stype= node->typeinfo->outputs; - for(sock= node->outputs.first; sock; sock= sock->next, stype++) { - if(sock->intern==0) { - /* debug only print */ - if(stype==NULL || stype->type==-1) printf("group verification error %s\n", ngroup->id.name); - - outputs[a]= *stype; - outputs[a].own_index= sock->own_index; - outputs[a].internsock= sock; - a++; - } - } - } - outputs[a].type= -1; /* terminator code */ - ngroup->owntype->outputs= outputs; - } - - /* voila, the nodetree has the full definition for generating group-node instances! */ -} - - -static bNodeSocket *groupnode_find_tosock(bNode *gnode, int index) -{ - bNodeSocket *sock; - - for(sock= gnode->inputs.first; sock; sock= sock->next) - if(sock->to_index==index) + for (sock=gnode->inputs.first; sock; sock=sock->next) + if (sock->groupsock == gsock) return sock; return NULL; } -static bNodeSocket *groupnode_find_fromsock(bNode *gnode, int index) +static bNodeSocket *find_group_node_output(bNode *gnode, bNodeSocket *gsock) { bNodeSocket *sock; - - for(sock= gnode->outputs.first; sock; sock= sock->next) - if(sock->to_index==index) + for (sock=gnode->outputs.first; sock; sock=sock->next) + if (sock->groupsock == gsock) return sock; return NULL; } @@ -461,8 +379,8 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) { bNodeLink *link, *linkn; bNode *node, *gnode, *nextn; - bNodeSocket *sock; bNodeTree *ngroup; + bNodeSocket *gsock; ListBase anim_basepaths = {NULL, NULL}; float min[2], max[2]; int totnode=0; @@ -485,9 +403,9 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) /* check if all connections are OK, no unselected node has both inputs and outputs to a selection */ for(link= ntree->links.first; link; link= link->next) { - if(link->fromnode->flag & NODE_SELECT) + if(link->fromnode && link->tonode && link->fromnode->flag & NODE_SELECT) link->tonode->done |= 1; - if(link->tonode->flag & NODE_SELECT) + if(link->fromnode && link->tonode && link->tonode->flag & NODE_SELECT) link->fromnode->done |= 2; } @@ -526,26 +444,9 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) node->locx-= 0.5f*(min[0]+max[0]); node->locy-= 0.5f*(min[1]+max[1]); - - /* set socket own_index to zero since it can still have a value - * from being in a group before, otherwise it doesn't get a unique - * index in group_verify_own_indices */ - for(sock= node->inputs.first; sock; sock= sock->next) - sock->own_index= 0; - for(sock= node->outputs.first; sock; sock= sock->next) - sock->own_index= 0; } } - /* move links over */ - for(link= ntree->links.first; link; link= linkn) { - linkn= link->next; - if(link->fromnode->flag & link->tonode->flag & NODE_SELECT) { - BLI_remlink(&ntree->links, link); - BLI_addtail(&ngroup->links, link); - } - } - /* move animation data over */ if (ntree->adt) { LinkData *ld, *ldn=NULL; @@ -561,9 +462,6 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) } } - /* now we can make own group typeinfo */ - ntreeMakeOwnType(ngroup); - /* make group node */ gnode= nodeAddNodeType(ntree, NODE_GROUP, ngroup, NULL); gnode->locx= 0.5f*(min[0]+max[0]); @@ -573,35 +471,29 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) for(link= ntree->links.first; link; link= linkn) { linkn= link->next; - if(link->tonode->flag & NODE_SELECT) { - link->tonode= gnode; - sock= groupnode_find_tosock(gnode, link->tosock->own_index); - if(sock==NULL) { - nodeRemLink(ntree, link); - printf("Removed link, cannot mix internal and external sockets in group\n"); - } - else link->tosock= sock; + if(link->fromnode && link->tonode && (link->fromnode->flag & link->tonode->flag & NODE_SELECT)) { + BLI_remlink(&ntree->links, link); + BLI_addtail(&ngroup->links, link); } - else if(link->fromnode->flag & NODE_SELECT) { - link->fromnode= gnode; - sock= groupnode_find_fromsock(gnode, link->fromsock->own_index); - if(sock==NULL) { - nodeRemLink(ntree, link); - printf("Removed link, cannot mix internal and external sockets in group\n"); - } - else link->fromsock= sock; + else if(link->tonode && (link->tonode->flag & NODE_SELECT)) { + gsock = nodeAddGroupSocketCopy(ngroup, link->tosock, SOCK_IN); + link->tosock->link = nodeAddLink(ngroup, NULL, gsock, link->tonode, link->tosock); + link->tosock = node_add_group_socket(&gnode->inputs, gsock); + link->tonode = gnode; } - } - - /* initialize variables of unused input sockets */ - for(node= ngroup->nodes.first; node; node= node->next) { - for(sock= node->inputs.first; sock; sock= sock->next) { - if(sock->intern==0) { - bNodeSocket *nsock= groupnode_find_tosock(gnode, sock->own_index); - if(nsock) { - QUATCOPY(nsock->ns.vec, sock->ns.vec); - } + else if(link->fromnode && (link->fromnode->flag & NODE_SELECT)) { + /* search for existing group node socket */ + for (gsock=ngroup->outputs.first; gsock; gsock=gsock->next) + if (gsock->link && gsock->link->fromsock==link->fromsock) + break; + if (!gsock) { + gsock = nodeAddGroupSocketCopy(ngroup, link->fromsock, SOCK_OUT); + gsock->link = nodeAddLink(ngroup, link->fromnode, link->fromsock, NULL, gsock); + link->fromsock = node_add_group_socket(&gnode->outputs, gsock); } + else + link->fromsock = find_group_node_output(gnode, gsock); + link->fromnode = gnode; } } @@ -611,41 +503,21 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) return gnode; } -/* note: ungroup: group_indices zero! */ - /* here's a nasty little one, need to check users... */ /* should become callbackable... */ void nodeVerifyGroup(bNodeTree *ngroup) { - /* XXX nodeVerifyGroup is sometimes called for non-group trees. - * This is not the best way to check if a tree is a group, - * trees should get their own flag for this! - */ - if (!ngroup->owntype) - return; - /* group changed, so we rebuild the type definition */ - ntreeMakeOwnType(ngroup); +// ntreeMakeGroupSockets(ngroup); if(ngroup->type==NTREE_SHADER) { Material *ma; for(ma= G.main->mat.first; ma; ma= ma->id.next) { if(ma->nodetree) { bNode *node; - - /* find if group is in tree */ for(node= ma->nodetree->nodes.first; node; node= node->next) if(node->id == (ID *)ngroup) - break; - - if(node) { - /* set all type pointers OK */ - ntreeInitTypes(ma->nodetree); - - for(node= ma->nodetree->nodes.first; node; node= node->next) - if(node->id == (ID *)ngroup) - nodeVerifyType(ma->nodetree, node); - } + nodeVerifyType(ma->nodetree, node); } } } @@ -654,20 +526,9 @@ void nodeVerifyGroup(bNodeTree *ngroup) for(sce= G.main->scene.first; sce; sce= sce->id.next) { if(sce->nodetree) { bNode *node; - - /* find if group is in tree */ for(node= sce->nodetree->nodes.first; node; node= node->next) if(node->id == (ID *)ngroup) - break; - - if(node) { - /* set all type pointers OK */ - ntreeInitTypes(sce->nodetree); - - for(node= sce->nodetree->nodes.first; node; node= node->next) - if(node->id == (ID *)ngroup) - nodeVerifyType(sce->nodetree, node); - } + nodeVerifyType(sce->nodetree, node); } } } @@ -676,20 +537,9 @@ void nodeVerifyGroup(bNodeTree *ngroup) for(tx= G.main->tex.first; tx; tx= tx->id.next) { if(tx->nodetree) { bNode *node; - - /* find if group is in tree */ for(node= tx->nodetree->nodes.first; node; node= node->next) if(node->id == (ID *)ngroup) - break; - - if(node) { - /* set all type pointers OK */ - ntreeInitTypes(tx->nodetree); - - for(node= tx->nodetree->nodes.first; node; node= node->next) - if(node->id == (ID *)ngroup) - nodeVerifyType(tx->nodetree, node); - } + nodeVerifyType(tx->nodetree, node); } } } @@ -716,15 +566,15 @@ void nodeGroupSocketUseFlags(bNodeTree *ngroup) for(ma= G.main->mat.first; ma; ma= ma->id.next) { if(ma->nodetree) { for(node= ma->nodetree->nodes.first; node; node= node->next) { - if(node->id==(ID *)ngroup) { + if(node->id==&ngroup->id) { for(sock= node->inputs.first; sock; sock= sock->next) if(sock->link) - if(sock->tosock) - sock->tosock->flag |= SOCK_IN_USE; + if(sock->groupsock) + sock->groupsock->flag |= SOCK_IN_USE; for(sock= node->outputs.first; sock; sock= sock->next) if(nodeCountSocketLinks(ma->nodetree, sock)) - if(sock->tosock) - sock->tosock->flag |= SOCK_IN_USE; + if(sock->groupsock) + sock->groupsock->flag |= SOCK_IN_USE; } } } @@ -738,12 +588,12 @@ void nodeGroupSocketUseFlags(bNodeTree *ngroup) if(node->id==(ID *)ngroup) { for(sock= node->inputs.first; sock; sock= sock->next) if(sock->link) - if(sock->tosock) - sock->tosock->flag |= SOCK_IN_USE; + if(sock->groupsock) + sock->groupsock->flag |= SOCK_IN_USE; for(sock= node->outputs.first; sock; sock= sock->next) if(nodeCountSocketLinks(sce->nodetree, sock)) - if(sock->tosock) - sock->tosock->flag |= SOCK_IN_USE; + if(sock->groupsock) + sock->groupsock->flag |= SOCK_IN_USE; } } } @@ -757,12 +607,12 @@ void nodeGroupSocketUseFlags(bNodeTree *ngroup) if(node->id==(ID *)ngroup) { for(sock= node->inputs.first; sock; sock= sock->next) if(sock->link) - if(sock->tosock) - sock->tosock->flag |= SOCK_IN_USE; + if(sock->groupsock) + sock->groupsock->flag |= SOCK_IN_USE; for(sock= node->outputs.first; sock; sock= sock->next) if(nodeCountSocketLinks(tx->nodetree, sock)) - if(sock->tosock) - sock->tosock->flag |= SOCK_IN_USE; + if(sock->groupsock) + sock->groupsock->flag |= SOCK_IN_USE; } } } @@ -813,7 +663,6 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode) bNode *node, *nextn; bNodeTree *ngroup, *wgroup; ListBase anim_basepaths = {NULL, NULL}; - int index; ngroup= (bNodeTree *)gnode->id; if(ngroup==NULL) return 0; @@ -855,7 +704,66 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode) node->flag |= NODE_SELECT; } - /* and the internal links */ + + /* restore external links to and from the gnode */ + for(link= ntree->links.first; link; link= link->next) { + if (link->fromnode==gnode) { + if (link->fromsock->groupsock) { + bNodeSocket *gsock= link->fromsock->groupsock; + if (gsock->link) { + if (gsock->link->fromnode) { + /* NB: using the new internal copies here! the groupsock pointer still maps to the old tree */ + link->fromnode = (gsock->link->fromnode ? gsock->link->fromnode->new_node : NULL); + link->fromsock = gsock->link->fromsock->new_sock; + } + else { + /* group output directly maps to group input */ + bNodeSocket *insock= find_group_node_input(gnode, gsock->link->fromsock); + if (insock->link) { + link->fromnode = insock->link->fromnode; + link->fromsock = insock->link->fromsock; + } + } + } + else { + /* constant group output: copy the stack value to the external socket. + * the link is kept here until all possible external users have been fixed. + */ + QUATCOPY(link->tosock->ns.vec, gsock->ns.vec); + } + } + } + } + /* remove internal output links, these are not used anymore */ + for(link=wgroup->links.first; link; link= linkn) { + linkn = link->next; + if (!link->tonode) + nodeRemLink(wgroup, link); + } + /* restore links from internal nodes */ + for(link= wgroup->links.first; link; link= link->next) { + /* indicates link to group input */ + if (!link->fromnode) { + /* NB: can't use find_group_node_input here, + * because gnode sockets still point to the old tree! + */ + bNodeSocket *insock; + for (insock= gnode->inputs.first; insock; insock= insock->next) + if (insock->groupsock->new_sock == link->fromsock) + break; + if (insock->link) { + link->fromnode = insock->link->fromnode; + link->fromsock = insock->link->fromsock; + } + else { + /* uses group constant input. copy the input value and remove the dead link. */ + QUATCOPY(link->tosock->ns.vec, insock->ns.vec); + nodeRemLink(wgroup, link); + } + } + } + + /* add internal links to the ntree */ for(link= wgroup->links.first; link; link= linkn) { linkn= link->next; BLI_remlink(&wgroup->links, link); @@ -884,37 +792,15 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode) /* free temp action too */ free_libblock(&G.main->action, waction); } - - /* restore links to and from the gnode */ - for(link= ntree->links.first; link; link= link->next) { - if(link->tonode==gnode) { - /* link->tosock->tosock is on the node we look for */ - nodeFindNode(ngroup, link->tosock->tosock, &nextn, &index); - if(nextn==NULL) printf("wrong stuff!\n"); - else if(nextn->new_node==NULL) printf("wrong stuff too!\n"); - else { - link->tonode= nextn->new_node; - link->tosock= BLI_findlink(&link->tonode->inputs, index); - } - } - else if(link->fromnode==gnode) { - /* link->fromsock->tosock is on the node we look for */ - nodeFindNode(ngroup, link->fromsock->tosock, &nextn, &index); - if(nextn==NULL) printf("1 wrong stuff!\n"); - else if(nextn->new_node==NULL) printf("1 wrong stuff too!\n"); - else { - link->fromnode= nextn->new_node; - link->fromsock= BLI_findlink(&link->fromnode->outputs, index); - } - } - } - - /* remove the gnode & work tree */ - free_libblock(&G.main->nodetree, wgroup); + /* delete the group instance. this also removes old input links! */ nodeFreeNode(ntree, gnode); + /* free the group tree (takes care of user count) */ + free_libblock(&G.main->nodetree, wgroup); + /* solve order goes fine, but the level tags not... doing it twice works for now. solve this once */ + /* XXX is this still necessary with new groups? it may have been caused by non-updated sock->link pointers. lukas */ ntreeSolveOrder(ntree); ntreeSolveOrder(ntree); @@ -930,34 +816,126 @@ void nodeCopyGroup(bNode *gnode) /* new_sock was set in nodeCopyNode */ for(sock=gnode->inputs.first; sock; sock=sock->next) - if(sock->tosock) - sock->tosock= sock->tosock->new_sock; + if(sock->groupsock) + sock->groupsock= sock->groupsock->new_sock; for(sock=gnode->outputs.first; sock; sock=sock->next) - if(sock->tosock) - sock->tosock= sock->tosock->new_sock; + if(sock->groupsock) + sock->groupsock= sock->groupsock->new_sock; +} + +bNodeSocket *nodeAddGroupSocket(bNodeTree *ngroup, const char *name, int type, int in_out) +{ + bNodeSocket *gsock = MEM_callocN(sizeof(bNodeSocket), "bNodeSocket"); + + strncpy(gsock->name, name, sizeof(gsock->name)); + gsock->type = type; + gsock->ns.min = INT_MIN; + gsock->ns.max = INT_MAX; + zero_v4(gsock->ns.vec); + gsock->ns.data = NULL; + gsock->flag = 0; + + gsock->next = gsock->prev = NULL; + gsock->new_sock = NULL; + gsock->link = NULL; + gsock->ns.data = NULL; + /* assign new unique index */ + gsock->own_index = ngroup->cur_index++; + gsock->limit = (in_out==SOCK_IN ? 0xFFF : 1); + + BLI_addtail(in_out==SOCK_IN ? &ngroup->inputs : &ngroup->outputs, gsock); + + return gsock; +} + +bNodeSocket *nodeAddGroupSocketCopy(bNodeTree *ngroup, bNodeSocket *copy, int in_out) +{ + bNodeSocket *gsock = MEM_callocN(sizeof(bNodeSocket), "bNodeSocket"); + + /* copy name type and data */ + strcpy(gsock->name, copy->name); + gsock->type = copy->type; + gsock->ns = copy->ns; + gsock->ns.data = NULL; + gsock->flag = copy->flag; + + gsock->next = gsock->prev = NULL; + gsock->new_sock = NULL; + gsock->groupsock = NULL; + gsock->link = NULL; + /* assign new unique index */ + gsock->own_index = ngroup->cur_index++; + gsock->limit = (in_out==SOCK_IN ? 0xFFF : 1); + + BLI_addtail(in_out==SOCK_IN ? &ngroup->inputs : &ngroup->outputs, gsock); + + return gsock; +} + +void nodeAddAllGroupSockets(bNodeTree *ngroup) +{ + bNode *node; + bNodeSocket *sock, *gsock; + + for (node=ngroup->nodes.first; node; node=node->next) { + for (sock=node->inputs.first; sock; sock=sock->next) { + if (!sock->link && !(sock->flag & SOCK_HIDDEN)) { + gsock = nodeAddGroupSocketCopy(ngroup, sock, SOCK_IN); + sock->link = nodeAddLink(ngroup, NULL, gsock, node, sock); + } + } + for (sock=node->outputs.first; sock; sock=sock->next) { + if (nodeCountSocketLinks(ngroup, sock)==0 && !(sock->flag & SOCK_HIDDEN)) { + gsock = nodeAddGroupSocketCopy(ngroup, sock, SOCK_OUT); + gsock->link = nodeAddLink(ngroup, node, sock, NULL, gsock); + } + } + } +} + +void nodeRemGroupSocket(bNodeTree *ngroup, bNodeSocket *gsock, int in_out) +{ + nodeRemSocketLinks(ngroup, gsock); + switch (in_out) { + case SOCK_IN: BLI_remlink(&ngroup->inputs, gsock); break; + case SOCK_OUT: BLI_remlink(&ngroup->outputs, gsock); break; + } } /* ************** Add stuff ********** */ void nodeAddSockets(bNode *node, bNodeType *ntype) { - bNodeSocketType *stype; - - if(ntype->inputs) { - stype= ntype->inputs; - while(stype->type != -1) { - node_add_socket_type(&node->inputs, stype); - stype++; + if (node->type==NODE_GROUP) { + bNodeTree *ntree= (bNodeTree*)node->id; + if (ntree) { + bNodeSocket *gsock; + for (gsock=ntree->inputs.first; gsock; gsock=gsock->next) + node_add_group_socket(&node->inputs, gsock); + for (gsock=ntree->outputs.first; gsock; gsock=gsock->next) + node_add_group_socket(&node->outputs, gsock); } } - if(ntype->outputs) { - stype= ntype->outputs; - while(stype->type != -1) { - node_add_socket_type(&node->outputs, stype); - stype++; + else { + bNodeSocketType *stype; + + if(ntype->inputs) { + stype= ntype->inputs; + while(stype->type != -1) { + node_add_socket_type(&node->inputs, stype); + stype++; + } + } + if(ntype->outputs) { + stype= ntype->outputs; + while(stype->type != -1) { + node_add_socket_type(&node->outputs, stype); + stype++; + } } } } + /* Find the first available, non-duplicate name for a given node */ void nodeUniqueName(bNodeTree *ntree, bNode *node) { @@ -986,7 +964,7 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) ntype= ntype->next; } } else - ntype= node_get_type(ntree, type, ngroup, id); + ntype= node_get_type(ntree, type, id); node= MEM_callocN(sizeof(bNode), "new node"); BLI_addtail(&ntree->nodes, node); @@ -1050,7 +1028,7 @@ void nodeUpdateType(bNodeTree *ntree, bNode* node, bNodeType *ntype) /* keep socket listorder identical, for copying links */ /* ntree is the target tree */ -bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal) +bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node) { bNode *nnode= MEM_callocN(sizeof(bNode), "dupli node"); bNodeSocket *sock, *oldsock; @@ -1064,15 +1042,11 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node, int internal) oldsock= node->inputs.first; for(sock= nnode->inputs.first; sock; sock= sock->next, oldsock= oldsock->next) { oldsock->new_sock= sock; - if(internal) - sock->own_index= 0; } BLI_duplicatelist(&nnode->outputs, &node->outputs); oldsock= node->outputs.first; for(sock= nnode->outputs.first; sock; sock= sock->next, oldsock= oldsock->next) { - if(internal) - sock->own_index= 0; sock->stack_index= 0; sock->ns.data= NULL; oldsock->new_sock= sock; @@ -1098,7 +1072,7 @@ bNodeLink *nodeAddLink(bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNodeLink *link= NULL; int from= 0, to= 0; - if(fromsock) { + if(fromnode) { /* test valid input */ for(sock= fromnode->outputs.first; sock; sock= sock->next) if(sock==fromsock) @@ -1113,7 +1087,7 @@ bNodeLink *nodeAddLink(bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, from= -1; /* OK but flip */ } } - if(tosock) { + if(tonode) { for(sock= tonode->inputs.first; sock; sock= sock->next) if(sock==tosock) break; @@ -1199,9 +1173,8 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree) { bNodeTree *newtree; bNode *node, *nnode, *last; - bNodeLink *link, *nlink; - bNodeSocket *sock; - int a; + bNodeLink *link; + bNodeSocket *gsock, *oldgsock; if(ntree==NULL) return NULL; @@ -1220,45 +1193,34 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree) last = ntree->nodes.last; for(node= ntree->nodes.first; node; node= node->next) { node->new_node= NULL; - nnode= nodeCopyNode(newtree, node, 0); /* sets node->new */ - - /* make sure we don't copy new nodes again! */ - if (node==last) - break; + nnode= nodeCopyNode(newtree, node); /* sets node->new */ + if(node==last) break; } - /* check for copying links */ - for(link= ntree->links.first; link; link= link->next) { - if(link->fromnode==NULL || link->tonode==NULL); - else if(link->fromnode->new_node && link->tonode->new_node) { - nlink= nodeAddLink(newtree, link->fromnode->new_node, NULL, link->tonode->new_node, NULL); - /* sockets were copied in order */ - for(a=0, sock= link->fromnode->outputs.first; sock; sock= sock->next, a++) { - if(sock==link->fromsock) - break; - } - nlink->fromsock= BLI_findlink(&link->fromnode->new_node->outputs, a); - - for(a=0, sock= link->tonode->inputs.first; sock; sock= sock->next, a++) { - if(sock==link->tosock) - break; - } - nlink->tosock= BLI_findlink(&link->tonode->new_node->inputs, a); - } + /* socket definition for group usage */ + BLI_duplicatelist(&newtree->inputs, &ntree->inputs); + for(gsock= newtree->inputs.first, oldgsock= ntree->inputs.first; gsock; gsock=gsock->next, oldgsock=oldgsock->next) { + oldgsock->new_sock= gsock; + gsock->groupsock = (oldgsock->groupsock ? oldgsock->groupsock->new_sock : NULL); } - /* own type definition for group usage */ - if(ntree->owntype) { - newtree->owntype= MEM_dupallocN(ntree->owntype); - if(ntree->owntype->inputs) - newtree->owntype->inputs= MEM_dupallocN(ntree->owntype->inputs); - if(ntree->owntype->outputs) - newtree->owntype->outputs= MEM_dupallocN(ntree->owntype->outputs); + BLI_duplicatelist(&newtree->outputs, &ntree->outputs); + for(gsock= newtree->outputs.first, oldgsock= ntree->outputs.first; gsock; gsock=gsock->next, oldgsock=oldgsock->next) { + oldgsock->new_sock= gsock; + gsock->groupsock = (oldgsock->groupsock ? oldgsock->groupsock->new_sock : NULL); + } + + /* copy links */ + BLI_duplicatelist(&newtree->links, &ntree->links); + for(link= newtree->links.first; link; link= link->next) { + link->fromnode = (link->fromnode ? link->fromnode->new_node : NULL); + link->fromsock = (link->fromsock ? link->fromsock->new_sock : NULL); + link->tonode = (link->tonode ? link->tonode->new_node : NULL); + link->tosock = (link->tosock ? link->tosock->new_sock : NULL); + /* update the link socket's pointer */ + if (link->tosock) + link->tosock->link = link; } - - /* weird this is required... there seem to be link pointers wrong still? */ - /* anyhoo, doing this solves crashes on copying entire tree (copy scene) and delete nodes */ - ntreeSolveOrder(newtree); return newtree; } @@ -1397,7 +1359,8 @@ void nodeUnlinkNode(bNodeTree *ntree, bNode *node) if(link->fromnode==node) { lb= &node->outputs; - NodeTagChanged(ntree, link->tonode); + if (link->tonode) + NodeTagChanged(ntree, link->tonode); } else if(link->tonode==node) lb= &node->inputs; @@ -1467,13 +1430,8 @@ void ntreeFreeTree(bNodeTree *ntree) nodeFreeNode(ntree, node); } - if(ntree->owntype) { - if(ntree->owntype->inputs) - MEM_freeN(ntree->owntype->inputs); - if(ntree->owntype->outputs) - MEM_freeN(ntree->owntype->outputs); - MEM_freeN(ntree->owntype); - } + BLI_freelistN(&ntree->inputs); + BLI_freelistN(&ntree->outputs); } void ntreeFreeCache(bNodeTree *ntree) @@ -1807,7 +1765,7 @@ static int node_recurs_check(bNode *node, bNode ***nsort, int level) if(sock->link) { has_inputlinks= 1; fromnode= sock->link->fromnode; - if(fromnode->done==0) { + if(fromnode && fromnode->done==0) { fromnode->level= node_recurs_check(fromnode, nsort, level); } } @@ -1893,6 +1851,9 @@ void ntreeSolveOrder(bNodeTree *ntree) for(sock= node->inputs.first; sock; sock= sock->next) sock->link= NULL; } + /* clear group socket links */ + for(sock= ntree->outputs.first; sock; sock= sock->next) + sock->link= NULL; if(totnode==0) return; @@ -1970,33 +1931,40 @@ int NodeTagIDChanged(bNodeTree *ntree, ID *id) /* ******************* executing ************* */ +/* for a given socket, find the actual stack entry */ +static bNodeStack *get_socket_stack(bNodeStack *stack, bNodeSocket *sock, bNodeStack **gin) +{ + switch (sock->stack_type) { + case SOCK_STACK_LOCAL: + return stack + sock->stack_index; + case SOCK_STACK_EXTERN: + return (gin ? gin[sock->stack_index] : NULL); + case SOCK_STACK_CONST: + return sock->stack_ptr; + } + return NULL; +} + /* see notes at ntreeBeginExecTree */ -static void group_node_get_stack(bNode *node, bNodeStack *stack, bNodeStack **in, bNodeStack **out, bNodeStack **gin, bNodeStack **gout) +static void node_get_stack(bNode *node, bNodeStack *stack, bNodeStack **in, bNodeStack **out, bNodeStack **gin) { bNodeSocket *sock; /* build pointer stack */ - for(sock= node->inputs.first; sock; sock= sock->next) { - if(sock->intern) { - /* yep, intern can have link or is hidden socket */ - if(sock->link) - *(in++)= stack + sock->link->fromsock->stack_index; - else - *(in++)= &sock->ns; + if (in) { + for(sock= node->inputs.first; sock; sock= sock->next) { + *(in++) = get_socket_stack(stack, sock, gin); } - else - *(in++)= gin[sock->stack_index_ext]; } - for(sock= node->outputs.first; sock; sock= sock->next) { - if(sock->intern) - *(out++)= stack + sock->stack_index; - else - *(out++)= gout[sock->stack_index_ext]; + if (out) { + for(sock= node->outputs.first; sock; sock= sock->next) { + *(out++) = get_socket_stack(stack, sock, gin); + } } } -static void node_group_execute(bNodeStack *stack, void *data, bNode *gnode, bNodeStack **in, bNodeStack **out) +static void node_group_execute(bNodeStack *stack, void *data, bNode *gnode, bNodeStack **in) { bNode *node; bNodeTree *ntree= (bNodeTree *)gnode->id; @@ -2009,7 +1977,7 @@ static void node_group_execute(bNodeStack *stack, void *data, bNode *gnode, bNod for(node= ntree->nodes.first; node; node= node->next) { if(node->typeinfo->execfunc) { - group_node_get_stack(node, stack, nsin, nsout, in, out); + node_get_stack(node, stack, nsin, nsout, in); /* for groups, only execute outputs for edited group */ if(node->typeinfo->nclass==NODE_CLASS_OUTPUT) { @@ -2020,25 +1988,92 @@ static void node_group_execute(bNodeStack *stack, void *data, bNode *gnode, bNod node->typeinfo->execfunc(data, node, nsin, nsout); } } +} + +static int set_stack_indexes_default(bNode *node, int index) +{ + bNodeSocket *sock; - /* free internal group output nodes */ - if(ntree->type==NTREE_COMPOSIT) { - for(node= ntree->nodes.first; node; node= node->next) { - if(node->typeinfo->execfunc) { - bNodeSocket *sock; - - for(sock= node->outputs.first; sock; sock= sock->next) { - if(sock->intern) { - bNodeStack *ns= stack + sock->stack_index; - if(ns->data) { - free_compbuf(ns->data); - ns->data= NULL; - } - } - } + for (sock=node->inputs.first; sock; sock=sock->next) { + if (sock->link && sock->link->fromsock) { + sock->stack_type = sock->link->fromsock->stack_type; + sock->stack_index = sock->link->fromsock->stack_index; + sock->stack_ptr = sock->link->fromsock->stack_ptr; + } + else { + sock->stack_type = SOCK_STACK_CONST; + sock->stack_index = -1; + sock->stack_ptr = &sock->ns; + } + } + + for (sock=node->outputs.first; sock; sock=sock->next) { + sock->stack_type = SOCK_STACK_LOCAL; + sock->stack_index = index++; + sock->stack_ptr = NULL; + } + + return index; +} + +static int ntree_begin_exec_tree(bNodeTree *ntree); +static int set_stack_indexes_group(bNode *node, int index) +{ + bNodeTree *ngroup= (bNodeTree*)node->id; + bNodeSocket *sock; + + if((ngroup->init & NTREE_TYPE_INIT)==0) + ntreeInitTypes(ngroup); + + node->stack_index = index; + index += ntree_begin_exec_tree(ngroup); + + for (sock=node->inputs.first; sock; sock=sock->next) { + if (sock->link && sock->link->fromsock) { + sock->stack_type = sock->link->fromsock->stack_type; + sock->stack_index = sock->link->fromsock->stack_index; + sock->stack_ptr = sock->link->fromsock->stack_ptr; + } + else { + sock->stack_type = SOCK_STACK_CONST; + sock->stack_index = -1; + sock->stack_ptr = &sock->ns; + } + } + + /* identify group node outputs from internal group sockets */ + for(sock= node->outputs.first; sock; sock= sock->next) { + if (sock->groupsock) { + bNodeSocket *insock, *gsock = sock->groupsock; + switch (gsock->stack_type) { + case SOCK_STACK_EXTERN: + /* extern stack is resolved for this group node instance */ + insock= find_group_node_input(node, gsock->link->fromsock); + sock->stack_type = insock->stack_type; + sock->stack_index = insock->stack_index; + sock->stack_ptr = insock->stack_ptr; + break; + case SOCK_STACK_LOCAL: + sock->stack_type = SOCK_STACK_LOCAL; + /* local stack index must be offset by group node instance */ + sock->stack_index = gsock->stack_index + node->stack_index; + sock->stack_ptr = NULL; + break; + case SOCK_STACK_CONST: + sock->stack_type = SOCK_STACK_CONST; + sock->stack_index = -1; + sock->stack_ptr = gsock->stack_ptr; + break; } } + else { + sock->stack_type = SOCK_STACK_LOCAL; + sock->stack_index = index++; + sock->stack_ptr = NULL; + } } + + return index; } /* recursively called for groups */ @@ -2047,31 +2082,42 @@ static void node_group_execute(bNodeStack *stack, void *data, bNode *gnode, bNod static int ntree_begin_exec_tree(bNodeTree *ntree) { bNode *node; - bNodeSocket *sock; - int index= 0, index_in= 0, index_out= 0; + bNodeSocket *gsock; + int index= 0, i; if((ntree->init & NTREE_TYPE_INIT)==0) ntreeInitTypes(ntree); + /* group inputs are numbered 0..totinputs, so external stack can easily be addressed */ + i = 0; + for(gsock=ntree->inputs.first; gsock; gsock = gsock->next) { + gsock->stack_type = SOCK_STACK_EXTERN; + gsock->stack_index = i++; + gsock->stack_ptr = NULL; + } + /* create indices for stack, check preview */ for(node= ntree->nodes.first; node; node= node->next) { - - for(sock= node->inputs.first; sock; sock= sock->next) { - if(sock->intern==0) - sock->stack_index_ext= index_in++; - } - - for(sock= node->outputs.first; sock; sock= sock->next) { - sock->stack_index= index++; - if(sock->intern==0) - sock->stack_index_ext= index_out++; + /* XXX can this be done by a generic one-for-all function? + * otherwise should use node-type callback. + */ + if(node->type==NODE_GROUP) + index = set_stack_indexes_group(node, index); + else + index = set_stack_indexes_default(node, index); + } + + /* group outputs */ + for(gsock=ntree->outputs.first; gsock; gsock = gsock->next) { + if (gsock->link && gsock->link->fromsock) { + gsock->stack_type = gsock->link->fromsock->stack_type; + gsock->stack_index = gsock->link->fromsock->stack_index; + gsock->stack_ptr = gsock->link->fromsock->stack_ptr; } - - if(node->type==NODE_GROUP) { - if(node->id) { - node->stack_index= index; - index+= ntree_begin_exec_tree((bNodeTree *)node->id); - } + else { + gsock->stack_type = SOCK_STACK_CONST; + gsock->stack_index = -1; + gsock->stack_ptr = &gsock->ns; } } @@ -2079,7 +2125,7 @@ static int ntree_begin_exec_tree(bNodeTree *ntree) } /* copy socket compbufs to stack, initialize usage of curve nodes */ -static void composit_begin_exec(bNodeTree *ntree, int is_group) +static void composit_begin_exec(bNodeTree *ntree, bNodeStack *stack) { bNode *node; bNodeSocket *sock; @@ -2089,16 +2135,14 @@ static void composit_begin_exec(bNodeTree *ntree, int is_group) /* initialize needed for groups */ node->exec= 0; - if(is_group==0) { - for(sock= node->outputs.first; sock; sock= sock->next) { - bNodeStack *ns= ntree->stack + sock->stack_index; - - if(sock->ns.data) { - ns->data= sock->ns.data; - sock->ns.data= NULL; - } + for(sock= node->outputs.first; sock; sock= sock->next) { + bNodeStack *ns= get_socket_stack(stack, sock, NULL); + if(ns && sock->ns.data) { + ns->data= sock->ns.data; + sock->ns.data= NULL; } } + /* cannot initialize them while using in threads */ if(ELEM4(node->type, CMP_NODE_TIME, CMP_NODE_CURVE_VEC, CMP_NODE_CURVE_RGB, CMP_NODE_HUECORRECT)) { curvemapping_initialize(node->storage); @@ -2106,52 +2150,39 @@ static void composit_begin_exec(bNodeTree *ntree, int is_group) curvemapping_premultiply(node->storage, 0); } if(node->type==NODE_GROUP) - composit_begin_exec((bNodeTree *)node->id, 1); + composit_begin_exec((bNodeTree *)node->id, stack + node->stack_index); } } /* copy stack compbufs to sockets */ -static void composit_end_exec(bNodeTree *ntree, int is_group) +static void composit_end_exec(bNodeTree *ntree, bNodeStack *stack) { bNode *node; bNodeStack *ns; - int a; for(node= ntree->nodes.first; node; node= node->next) { - if(is_group==0) { - bNodeSocket *sock; + bNodeSocket *sock; - for(sock= node->outputs.first; sock; sock= sock->next) { - ns= ntree->stack + sock->stack_index; - if(ns->data) { - sock->ns.data= ns->data; - ns->data= NULL; - } + for(sock= node->outputs.first; sock; sock= sock->next) { + ns = get_socket_stack(stack, sock, NULL); + if(ns && ns->data) { + sock->ns.data= ns->data; + ns->data= NULL; } } + if(node->type==CMP_NODE_CURVE_RGB) curvemapping_premultiply(node->storage, 1); if(node->type==NODE_GROUP) - composit_end_exec((bNodeTree *)node->id, 1); + composit_end_exec((bNodeTree *)node->id, stack + node->stack_index); node->need_exec= 0; } - - if(is_group==0) { - /* internally, group buffers are not stored */ - for(ns= ntree->stack, a=0; astacksize; a++, ns++) { - if(ns->data) { - printf("freed leftover buffer from stack\n"); - free_compbuf(ns->data); - ns->data= NULL; - } - } - } } -static void group_tag_used_outputs(bNode *gnode, bNodeStack *stack) +static void group_tag_used_outputs(bNode *gnode, bNodeStack *stack, bNodeStack **gin) { bNodeTree *ntree= (bNodeTree *)gnode->id; bNode *node; @@ -2163,15 +2194,8 @@ static void group_tag_used_outputs(bNode *gnode, bNodeStack *stack) bNodeSocket *sock; for(sock= node->inputs.first; sock; sock= sock->next) { - if(sock->intern) { - if(sock->link) { - bNodeStack *ns= stack + sock->link->fromsock->stack_index; - ns->hasoutput= 1; - ns->sockettype= sock->link->fromsock->type; - } - else - sock->ns.sockettype= sock->type; - } + bNodeStack *ns = get_socket_stack(stack, sock, gin); + ns->hasoutput= 1; } } } @@ -2231,6 +2255,8 @@ static void tex_end_exec(bNodeTree *ntree) void ntreeBeginExecTree(bNodeTree *ntree) { + bNodeStack *nsin[MAX_SOCKET]; /* arbitrary... watch this */ + /* let's make it sure */ if(ntree->init & NTREE_EXEC_INIT) return; @@ -2262,13 +2288,9 @@ void ntreeBeginExecTree(bNodeTree *ntree) node->need_exec= 1; for(sock= node->inputs.first; sock; sock= sock->next) { - if(sock->link) { - ns= ntree->stack + sock->link->fromsock->stack_index; - ns->hasoutput= 1; - ns->sockettype= sock->link->fromsock->type; - } - else - sock->ns.sockettype= sock->type; + ns = get_socket_stack(ntree->stack, sock, NULL); + if (ns) + ns->hasoutput = 1; if(sock->link) { bNodeLink *link= sock->link; @@ -2282,13 +2304,14 @@ void ntreeBeginExecTree(bNodeTree *ntree) } } - if(node->type==NODE_GROUP && node->id) - group_tag_used_outputs(node, ntree->stack); - + if(node->type==NODE_GROUP && node->id) { + node_get_stack(node, ntree->stack, nsin, NULL, NULL); + group_tag_used_outputs(node, ntree->stack, nsin); + } } if(ntree->type==NTREE_COMPOSIT) - composit_begin_exec(ntree, 0); + composit_begin_exec(ntree, ntree->stack); } ntree->init |= NTREE_EXEC_INIT; @@ -2296,14 +2319,24 @@ void ntreeBeginExecTree(bNodeTree *ntree) void ntreeEndExecTree(bNodeTree *ntree) { + bNodeStack *ns; if(ntree->init & NTREE_EXEC_INIT) { bNodeThreadStack *nts; int a; /* another callback candidate! */ - if(ntree->type==NTREE_COMPOSIT) - composit_end_exec(ntree, 0); + if(ntree->type==NTREE_COMPOSIT) { + composit_end_exec(ntree, ntree->stack); + + for(ns= ntree->stack, a=0; astacksize; a++, ns++) { + if(ns->data) { + printf("freed leftover buffer from stack\n"); + free_compbuf(ns->data); + ns->data= NULL; + } + } + } else if(ntree->type==NTREE_TEXTURE) tex_end_exec(ntree); @@ -2327,23 +2360,6 @@ void ntreeEndExecTree(bNodeTree *ntree) } } -static void node_get_stack(bNode *node, bNodeStack *stack, bNodeStack **in, bNodeStack **out) -{ - bNodeSocket *sock; - - /* build pointer stack */ - for(sock= node->inputs.first; sock; sock= sock->next) { - if(sock->link) - *(in++)= stack + sock->link->fromsock->stack_index; - else - *(in++)= &sock->ns; - } - - for(sock= node->outputs.first; sock; sock= sock->next) { - *(out++)= stack + sock->stack_index; - } -} - /* nodes are presorted, so exec is in order of list */ void ntreeExecTree(bNodeTree *ntree, void *callerdata, int thread) { @@ -2356,7 +2372,7 @@ void ntreeExecTree(bNodeTree *ntree, void *callerdata, int thread) /* only when initialized */ if((ntree->init & NTREE_EXEC_INIT)==0) ntreeBeginExecTree(ntree); - + /* composite does 1 node per thread, so no multiple stacks needed */ if(ntree->type==NTREE_COMPOSIT) { stack= ntree->stack; @@ -2369,12 +2385,12 @@ void ntreeExecTree(bNodeTree *ntree, void *callerdata, int thread) for(node= ntree->nodes.first; node; node= node->next) { if(node->need_exec) { if(node->typeinfo->execfunc) { - node_get_stack(node, stack, nsin, nsout); + node_get_stack(node, stack, nsin, nsout, NULL); node->typeinfo->execfunc(callerdata, node, nsin, nsout); } else if(node->type==NODE_GROUP && node->id) { - node_get_stack(node, stack, nsin, nsout); - node_group_execute(stack, callerdata, node, nsin, nsout); + node_get_stack(node, stack, nsin, NULL, NULL); + node_group_execute(stack, callerdata, node, nsin); } } } @@ -2420,7 +2436,7 @@ static void *exec_composite_node(void *node_v) bNode *node= node_v; ThreadData *thd= (ThreadData *)node->threaddata; - node_get_stack(node, thd->stack, nsin, nsout); + node_get_stack(node, thd->stack, nsin, nsout, NULL); if((node->flag & NODE_MUTED) && (!node_only_value(node))) { /* viewers we execute, for feedback to user */ @@ -2433,7 +2449,7 @@ static void *exec_composite_node(void *node_v) node->typeinfo->execfunc(thd->rd, node, nsin, nsout); } else if(node->type==NODE_GROUP && node->id) { - node_group_execute(thd->stack, thd->rd, node, nsin, nsout); + node_group_execute(thd->stack, thd->rd, node, nsin); } node->exec |= NODE_READY; @@ -2461,7 +2477,7 @@ static int setExecutableNodes(bNodeTree *ntree, ThreadData *thd) for(node= ntree->nodes.first; node; node= node->next) { int a; - node_get_stack(node, thd->stack, nsin, nsout); + node_get_stack(node, thd->stack, nsin, nsout, NULL); /* test the outputs */ /* skip value-only nodes (should be in type!) */ @@ -2526,7 +2542,7 @@ static int setExecutableNodes(bNodeTree *ntree, ThreadData *thd) for(node= ntree->nodes.first; node; node= node->next) { if(node->need_exec==0 && node_only_value(node)) { if(node->typeinfo->execfunc) { - node_get_stack(node, thd->stack, nsin, nsout); + node_get_stack(node, thd->stack, nsin, nsout, NULL); node->typeinfo->execfunc(thd->rd, node, nsin, nsout); } } @@ -2564,8 +2580,8 @@ static void freeExecutableNode(bNodeTree *ntree) for(node= ntree->nodes.first; node; node= node->next) { if(node->exec & NODE_FREEBUFS) { for(sock= node->outputs.first; sock; sock= sock->next) { - bNodeStack *ns= ntree->stack + sock->stack_index; - if(ns->data) { + bNodeStack *ns= get_socket_stack(ntree->stack, sock, NULL); + if(ns && ns->data) { free_compbuf(ns->data); ns->data= NULL; // printf("freed buf node %s \n", node->name); @@ -2585,7 +2601,7 @@ static bNode *getExecutableNode(bNodeTree *ntree) /* input sockets should be ready */ for(sock= node->inputs.first; sock; sock= sock->next) { - if(sock->link) + if(sock->link && sock->link->fromnode) if((sock->link->fromnode->exec & NODE_READY)==0) break; } @@ -2656,7 +2672,6 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview) if(BLI_available_threads(&threads)) { node= getExecutableNode(ntree); if(node) { - if(ntree->progress && totnode) ntree->progress(ntree->prh, (1.0 - curnode/(float)totnode)); if(ntree->stats_draw) { @@ -2923,7 +2938,7 @@ static void data_from_gpu_stack(ListBase *sockets, bNodeStack **ns, GPUNodeStack } } -static void gpu_node_group_execute(bNodeStack *stack, GPUMaterial *mat, bNode *gnode, bNodeStack **in, bNodeStack **out) +static void gpu_node_group_execute(bNodeStack *stack, GPUMaterial *mat, bNode *gnode, bNodeStack **in) { bNode *node; bNodeTree *ntree= (bNodeTree *)gnode->id; @@ -2938,7 +2953,7 @@ static void gpu_node_group_execute(bNodeStack *stack, GPUMaterial *mat, bNode *g for(node= ntree->nodes.first; node; node= node->next) { if(node->typeinfo->gpufunc) { - group_node_get_stack(node, stack, nsin, nsout, in, out); + node_get_stack(node, stack, nsin, nsout, in); doit = 0; @@ -2976,15 +2991,15 @@ void ntreeGPUMaterialNodes(bNodeTree *ntree, GPUMaterial *mat) for(node= ntree->nodes.first; node; node= node->next) { if(node->typeinfo->gpufunc) { - node_get_stack(node, stack, nsin, nsout); + node_get_stack(node, stack, nsin, nsout, NULL); gpu_from_node_stack(&node->inputs, nsin, gpuin); gpu_from_node_stack(&node->outputs, nsout, gpuout); if(node->typeinfo->gpufunc(mat, node, gpuin, gpuout)) data_from_gpu_stack(&node->outputs, nsout, gpuout); } else if(node->type==NODE_GROUP && node->id) { - node_get_stack(node, stack, nsin, nsout); - gpu_node_group_execute(stack, mat, node, nsin, nsout); + node_get_stack(node, stack, nsin, nsout, NULL); + gpu_node_group_execute(stack, mat, node, nsin); } } -- cgit v1.2.3 From 33887fa41dcc010a8543e8bc78d1b2de23fcd099 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 21 Feb 2011 18:06:52 +0000 Subject: Bugfix #26116 Node materials with 'ray transparency' set now work again. Fix provided by Ervin Weber, thanks a lot! --- source/blender/blenkernel/intern/material.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 954de9c86e2..0b1cbd60432 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -872,7 +872,7 @@ static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode if(ma!=basemat) { do_init_render_material(ma, r_mode, amb); basemat->texco |= ma->texco; - basemat->mode_l |= ma->mode_l; + basemat->mode_l |= ma->mode_l & ~(MA_TRANSP|MA_ZTRANSP|MA_RAYTRANSP); } } else if(node->type==NODE_GROUP) -- cgit v1.2.3 From 4fb730d6d0f20db2d35b36237d5778a40bdec076 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Mon, 21 Feb 2011 18:18:37 +0000 Subject: Fixed do_versions for node groups which contain nodes that have changed sockets. do_versions is running before the lib_verify_nodetree function updates socket lists of nodes. This means that when adding unlinked sockets in do_versions to restore older node groups, the new sockets are not taken into account. To fix this a temporary node tree flag has been introduced, which delays actual group socket do_version until the group tree internal nodes have been updated. After that the unlinked group sockets are exposed (like old node groups did), then the external sockets look up the new index, so that external links to group instances are preserved. --- source/blender/blenkernel/intern/node.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index cebbab45928..7fd0a2d661a 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -878,14 +878,23 @@ void nodeAddAllGroupSockets(bNodeTree *ngroup) bNode *node; bNodeSocket *sock, *gsock; + printf("Verifying group '%s':\n", ngroup->id.name+2); for (node=ngroup->nodes.first; node; node=node->next) { + printf("\tNode '%s':\n", node->name); for (sock=node->inputs.first; sock; sock=sock->next) { + printf("\t\tInput '%s': link=%p, hidden=%d\n", sock->name, sock->link, (sock->flag & SOCK_HIDDEN)); +// if (sock->link) { +// if (sock->link->fromnode) +// printf("fromnode=%s ", sock->link->fromnode->name); +// printf("fromsock=%s") +// } if (!sock->link && !(sock->flag & SOCK_HIDDEN)) { gsock = nodeAddGroupSocketCopy(ngroup, sock, SOCK_IN); sock->link = nodeAddLink(ngroup, NULL, gsock, node, sock); } } for (sock=node->outputs.first; sock; sock=sock->next) { + printf("\t\tOutput '%s': #links=%d, hidden=%d\n", sock->name, nodeCountSocketLinks(ngroup, sock), (sock->flag & SOCK_HIDDEN)); if (nodeCountSocketLinks(ngroup, sock)==0 && !(sock->flag & SOCK_HIDDEN)) { gsock = nodeAddGroupSocketCopy(ngroup, sock, SOCK_OUT); gsock->link = nodeAddLink(ngroup, node, sock, NULL, gsock); -- cgit v1.2.3 From 8b5d019139698383145d8613b457b69e063b3421 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 22 Feb 2011 07:58:49 +0000 Subject: Fixed missing initialization of node stack entries. --- source/blender/blenkernel/intern/node.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 7fd0a2d661a..c614b6910c2 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2195,18 +2195,24 @@ static void group_tag_used_outputs(bNode *gnode, bNodeStack *stack, bNodeStack * { bNodeTree *ntree= (bNodeTree *)gnode->id; bNode *node; + bNodeSocket *sock; stack+= gnode->stack_index; for(node= ntree->nodes.first; node; node= node->next) { if(node->typeinfo->execfunc) { - bNodeSocket *sock; - for(sock= node->inputs.first; sock; sock= sock->next) { bNodeStack *ns = get_socket_stack(stack, sock, gin); ns->hasoutput= 1; } } + + /* set stack types (for local stack entries) */ + for(sock= node->outputs.first; sock; sock= sock->next) { + bNodeStack *ns = get_socket_stack(stack, sock, NULL); + if (ns) + ns->sockettype = sock->type; + } } } @@ -2313,6 +2319,13 @@ void ntreeBeginExecTree(bNodeTree *ntree) } } + /* set stack types (for local stack entries) */ + for(sock= node->outputs.first; sock; sock= sock->next) { + ns = get_socket_stack(ntree->stack, sock, NULL); + if (ns) + ns->sockettype = sock->type; + } + if(node->type==NODE_GROUP && node->id) { node_get_stack(node, ntree->stack, nsin, NULL, NULL); group_tag_used_outputs(node, ntree->stack, nsin); -- cgit v1.2.3 From 99d3b68d70b204f4a73dba67eec8077c3dd7fa15 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 22 Feb 2011 12:19:27 +0000 Subject: fix for uninitialized stack variable in displaying the modifier template. --- source/blender/blenkernel/intern/modifier.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index db0c649d290..7439a47a746 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -247,6 +247,11 @@ int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *lastPossibleCag ModifierData *md = (virtual_)? modifiers_getVirtualModifierList(ob): ob->modifiers.first; int i, cageIndex = -1; + if(lastPossibleCageIndex_r) { + /* ensure the value is initialized */ + *lastPossibleCageIndex_r= -1; + } + /* Find the last modifier acting on the cage. */ for (i=0; md; i++,md=md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); -- cgit v1.2.3 From 354fc0076e4f4bb6bc95e9d3ed260dd38d7910dc Mon Sep 17 00:00:00 2001 From: Joerg Mueller Date: Tue, 22 Feb 2011 16:32:05 +0000 Subject: Fix for [#26160] Blender Crashes when undoing Was trying to free audio data from sequencer strips that don't even have audio. Corrected the error in several ways so this will definitely not happen again :-) --- 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 2785878fb08..69d8713ec8b 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -193,7 +193,7 @@ void seq_free_sequence(Scene *scene, Sequence *seq) if (ed->act_seq==seq) ed->act_seq= NULL; - if(seq->scene_sound) + if(seq->scene_sound && ELEM(seq->type, SEQ_SOUND, SEQ_SCENE)) sound_remove_scene_sound(scene, seq->scene_sound); seq_free_animdata(scene, seq); @@ -3399,6 +3399,7 @@ Sequence *alloc_sequence(ListBase *lb, int cfra, int machine) seq->mul= 1.0; seq->blend_opacity = 100.0; seq->volume = 1.0f; + seq->scene_sound = NULL; return seq; } -- cgit v1.2.3 From b3c60ef3eae01b08eeb63cb574397f720fc2acbe Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 22 Feb 2011 20:24:06 +0000 Subject: Added RNA functions to group tree inputs/outputs for exposing internal sockets or adding custom sockets by name and type (fixes #26171). Changed a few function names for groups for consistency. --- source/blender/blenkernel/intern/node.c | 66 ++++++++++----------------------- 1 file changed, 20 insertions(+), 46 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index c614b6910c2..93d0a45ae94 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -476,7 +476,7 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) BLI_addtail(&ngroup->links, link); } else if(link->tonode && (link->tonode->flag & NODE_SELECT)) { - gsock = nodeAddGroupSocketCopy(ngroup, link->tosock, SOCK_IN); + gsock = nodeGroupAddSocket(ngroup, link->tosock->name, link->tosock->type, SOCK_IN); link->tosock->link = nodeAddLink(ngroup, NULL, gsock, link->tonode, link->tosock); link->tosock = node_add_group_socket(&gnode->inputs, gsock); link->tonode = gnode; @@ -487,7 +487,7 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) if (gsock->link && gsock->link->fromsock==link->fromsock) break; if (!gsock) { - gsock = nodeAddGroupSocketCopy(ngroup, link->fromsock, SOCK_OUT); + gsock = nodeGroupAddSocket(ngroup, link->fromsock->name, link->fromsock->type, SOCK_OUT); gsock->link = nodeAddLink(ngroup, link->fromnode, link->fromsock, NULL, gsock); link->fromsock = node_add_group_socket(&gnode->outputs, gsock); } @@ -505,7 +505,7 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) /* here's a nasty little one, need to check users... */ /* should become callbackable... */ -void nodeVerifyGroup(bNodeTree *ngroup) +void nodeGroupVerify(bNodeTree *ngroup) { /* group changed, so we rebuild the type definition */ // ntreeMakeGroupSockets(ngroup); @@ -627,21 +627,27 @@ bNode *nodeFindNodebyName(bNodeTree *ntree, const char *name) } /* finds a node based on given socket */ -int nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **nodep, int *sockindex) +int nodeFindNode(bNodeTree *ntree, bNodeSocket *sock, bNode **nodep, int *sockindex, int *in_out) { bNode *node; bNodeSocket *tsock; int index= 0; for(node= ntree->nodes.first; node; node= node->next) { - for(index=0, tsock= node->inputs.first; tsock; tsock= tsock->next, index++) - if(tsock==sock) + for(index=0, tsock= node->inputs.first; tsock; tsock= tsock->next, index++) { + if(tsock==sock) { + if (in_out) *in_out= SOCK_IN; break; + } + } if(tsock) break; - for(index=0, tsock= node->outputs.first; tsock; tsock= tsock->next, index++) - if(tsock==sock) + for(index=0, tsock= node->outputs.first; tsock; tsock= tsock->next, index++) { + if(tsock==sock) { + if (in_out) *in_out= SOCK_OUT; break; + } + } if(tsock) break; } @@ -807,7 +813,7 @@ int nodeGroupUnGroup(bNodeTree *ntree, bNode *gnode) return 1; } -void nodeCopyGroup(bNode *gnode) +void nodeGroupCopy(bNode *gnode) { bNodeSocket *sock; @@ -824,7 +830,7 @@ void nodeCopyGroup(bNode *gnode) sock->groupsock= sock->groupsock->new_sock; } -bNodeSocket *nodeAddGroupSocket(bNodeTree *ngroup, const char *name, int type, int in_out) +bNodeSocket *nodeGroupAddSocket(bNodeTree *ngroup, const char *name, int type, int in_out) { bNodeSocket *gsock = MEM_callocN(sizeof(bNodeSocket), "bNodeSocket"); @@ -849,61 +855,29 @@ bNodeSocket *nodeAddGroupSocket(bNodeTree *ngroup, const char *name, int type, i return gsock; } -bNodeSocket *nodeAddGroupSocketCopy(bNodeTree *ngroup, bNodeSocket *copy, int in_out) -{ - bNodeSocket *gsock = MEM_callocN(sizeof(bNodeSocket), "bNodeSocket"); - - /* copy name type and data */ - strcpy(gsock->name, copy->name); - gsock->type = copy->type; - gsock->ns = copy->ns; - gsock->ns.data = NULL; - gsock->flag = copy->flag; - - gsock->next = gsock->prev = NULL; - gsock->new_sock = NULL; - gsock->groupsock = NULL; - gsock->link = NULL; - /* assign new unique index */ - gsock->own_index = ngroup->cur_index++; - gsock->limit = (in_out==SOCK_IN ? 0xFFF : 1); - - BLI_addtail(in_out==SOCK_IN ? &ngroup->inputs : &ngroup->outputs, gsock); - - return gsock; -} - -void nodeAddAllGroupSockets(bNodeTree *ngroup) +void nodeGroupExposeAllSockets(bNodeTree *ngroup) { bNode *node; bNodeSocket *sock, *gsock; - printf("Verifying group '%s':\n", ngroup->id.name+2); for (node=ngroup->nodes.first; node; node=node->next) { - printf("\tNode '%s':\n", node->name); for (sock=node->inputs.first; sock; sock=sock->next) { - printf("\t\tInput '%s': link=%p, hidden=%d\n", sock->name, sock->link, (sock->flag & SOCK_HIDDEN)); -// if (sock->link) { -// if (sock->link->fromnode) -// printf("fromnode=%s ", sock->link->fromnode->name); -// printf("fromsock=%s") -// } if (!sock->link && !(sock->flag & SOCK_HIDDEN)) { - gsock = nodeAddGroupSocketCopy(ngroup, sock, SOCK_IN); + gsock = nodeGroupAddSocket(ngroup, sock->name, sock->type, SOCK_IN); sock->link = nodeAddLink(ngroup, NULL, gsock, node, sock); } } for (sock=node->outputs.first; sock; sock=sock->next) { printf("\t\tOutput '%s': #links=%d, hidden=%d\n", sock->name, nodeCountSocketLinks(ngroup, sock), (sock->flag & SOCK_HIDDEN)); if (nodeCountSocketLinks(ngroup, sock)==0 && !(sock->flag & SOCK_HIDDEN)) { - gsock = nodeAddGroupSocketCopy(ngroup, sock, SOCK_OUT); + gsock = nodeGroupAddSocket(ngroup, sock->name, sock->type, SOCK_OUT); gsock->link = nodeAddLink(ngroup, node, sock, NULL, gsock); } } } } -void nodeRemGroupSocket(bNodeTree *ngroup, bNodeSocket *gsock, int in_out) +void nodeGroupRemoveSocket(bNodeTree *ngroup, bNodeSocket *gsock, int in_out) { nodeRemSocketLinks(ngroup, gsock); switch (in_out) { -- cgit v1.2.3 From e7750aa6ed4c448d4a39cf399b02f6b86c676816 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Tue, 22 Feb 2011 20:49:34 +0000 Subject: Convenience fix: Exposing internal sockets now copies the default input value to the group sockets. The "expose" function on group inputs/outputs has an optional parameter "add_link", which can be used to prevent the automatic linking. --- source/blender/blenkernel/intern/node.c | 18 +++++++++++++++--- 1 file changed, 15 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 93d0a45ae94..d645bcd8329 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -476,7 +476,7 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) BLI_addtail(&ngroup->links, link); } else if(link->tonode && (link->tonode->flag & NODE_SELECT)) { - gsock = nodeGroupAddSocket(ngroup, link->tosock->name, link->tosock->type, SOCK_IN); + gsock = nodeGroupExposeSocket(ngroup, link->tosock, SOCK_IN); link->tosock->link = nodeAddLink(ngroup, NULL, gsock, link->tonode, link->tosock); link->tosock = node_add_group_socket(&gnode->inputs, gsock); link->tonode = gnode; @@ -487,7 +487,7 @@ bNode *nodeMakeGroupFromSelected(bNodeTree *ntree) if (gsock->link && gsock->link->fromsock==link->fromsock) break; if (!gsock) { - gsock = nodeGroupAddSocket(ngroup, link->fromsock->name, link->fromsock->type, SOCK_OUT); + gsock = nodeGroupExposeSocket(ngroup, link->fromsock, SOCK_OUT); gsock->link = nodeAddLink(ngroup, link->fromnode, link->fromsock, NULL, gsock); link->fromsock = node_add_group_socket(&gnode->outputs, gsock); } @@ -836,6 +836,7 @@ bNodeSocket *nodeGroupAddSocket(bNodeTree *ngroup, const char *name, int type, i strncpy(gsock->name, name, sizeof(gsock->name)); gsock->type = type; + gsock->ns.sockettype = type; gsock->ns.min = INT_MIN; gsock->ns.max = INT_MAX; zero_v4(gsock->ns.vec); @@ -855,6 +856,14 @@ bNodeSocket *nodeGroupAddSocket(bNodeTree *ngroup, const char *name, int type, i return gsock; } +bNodeSocket *nodeGroupExposeSocket(bNodeTree *ngroup, bNodeSocket *sock, int in_out) +{ + bNodeSocket *gsock= nodeGroupAddSocket(ngroup, sock->name, sock->type, in_out); + /* initialize the default socket value */ + QUATCOPY(gsock->ns.vec, sock->ns.vec); + return gsock; +} + void nodeGroupExposeAllSockets(bNodeTree *ngroup) { bNode *node; @@ -864,13 +873,16 @@ void nodeGroupExposeAllSockets(bNodeTree *ngroup) for (sock=node->inputs.first; sock; sock=sock->next) { if (!sock->link && !(sock->flag & SOCK_HIDDEN)) { gsock = nodeGroupAddSocket(ngroup, sock->name, sock->type, SOCK_IN); + /* initialize the default socket value */ + QUATCOPY(gsock->ns.vec, sock->ns.vec); sock->link = nodeAddLink(ngroup, NULL, gsock, node, sock); } } for (sock=node->outputs.first; sock; sock=sock->next) { - printf("\t\tOutput '%s': #links=%d, hidden=%d\n", sock->name, nodeCountSocketLinks(ngroup, sock), (sock->flag & SOCK_HIDDEN)); if (nodeCountSocketLinks(ngroup, sock)==0 && !(sock->flag & SOCK_HIDDEN)) { gsock = nodeGroupAddSocket(ngroup, sock->name, sock->type, SOCK_OUT); + /* initialize the default socket value */ + QUATCOPY(gsock->ns.vec, sock->ns.vec); gsock->link = nodeAddLink(ngroup, node, sock, NULL, gsock); } } -- cgit v1.2.3 From 9416daf97eef06f90d5230eeac0a5995d06be00c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 23 Feb 2011 09:12:55 +0000 Subject: remove unused functions, note: BPY_class_validate() could come in handy later if we need to check classes for properties/functions but for now there is no point in keeping it in. --- source/blender/blenkernel/intern/displist.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 837c3bd8356..b59109c3f2a 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1936,11 +1936,6 @@ float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int return orco; } -void imagestodisplist(void) -{ - /* removed */ -} - /* this is confusing, there's also min_max_object, appplying the obmat... */ static void boundbox_displist(Object *ob) { -- cgit v1.2.3 From 5a70edc4afd2f878b1d62168a2dd86edfe66a5fb Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Wed, 23 Feb 2011 10:42:27 +0000 Subject: Possible fix for [#26190] Changing particle amount crashes * In some cases fluid particles could be born at the exact same locations. Now these cases are just ignored and such particles don't effect each other. --- source/blender/blenkernel/intern/particle_system.c | 8 ++++++++ 1 file changed, 8 insertions(+) (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 c1a6558aea3..fd792168c6b 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -2286,6 +2286,10 @@ static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData * /* pressure and near pressure */ for(n=own_psys?1:0; nprev_state.co); mul_v3_fl(ptn[n].co, 1.f/ptn[n].dist); q = ptn[n].dist/h; @@ -2305,6 +2309,10 @@ static void particle_fluidsim(ParticleSystem *psys, int own_psys, ParticleData * /* main calculations */ for(n=own_psys?1:0; nparticles + ptn[n].index; rij = ptn[n].dist; -- cgit v1.2.3 From 5b607701a7541c328cc058e10bd7a8c6d0c998ab Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Wed, 23 Feb 2011 10:52:22 +0000 Subject: doxygen: prevent GPL license block from being parsed as doxygen comment. --- source/blender/blenkernel/intern/BME_Customdata.c | 2 +- source/blender/blenkernel/intern/BME_conversions.c | 2 +- source/blender/blenkernel/intern/BME_eulers.c | 2 +- source/blender/blenkernel/intern/BME_mesh.c | 2 +- source/blender/blenkernel/intern/BME_structure.c | 2 +- source/blender/blenkernel/intern/BME_tools.c | 2 +- source/blender/blenkernel/intern/DerivedMesh.c | 2 +- source/blender/blenkernel/intern/action.c | 2 +- source/blender/blenkernel/intern/anim.c | 2 +- source/blender/blenkernel/intern/anim_sys.c | 2 +- source/blender/blenkernel/intern/armature.c | 2 +- source/blender/blenkernel/intern/bmesh_private.h | 2 +- source/blender/blenkernel/intern/bmfont.c | 2 +- source/blender/blenkernel/intern/brush.c | 2 +- source/blender/blenkernel/intern/bvhutils.c | 2 +- source/blender/blenkernel/intern/constraint.c | 2 +- source/blender/blenkernel/intern/context.c | 2 +- source/blender/blenkernel/intern/depsgraph.c | 2 +- source/blender/blenkernel/intern/fcurve.c | 2 +- source/blender/blenkernel/intern/fluidsim.c | 2 +- source/blender/blenkernel/intern/fmodifier.c | 2 +- source/blender/blenkernel/intern/gpencil.c | 2 +- source/blender/blenkernel/intern/icons.c | 2 +- source/blender/blenkernel/intern/idcode.c | 2 +- source/blender/blenkernel/intern/idprop.c | 2 +- source/blender/blenkernel/intern/lattice.c | 2 +- source/blender/blenkernel/intern/library.c | 2 +- source/blender/blenkernel/intern/mball.c | 2 +- source/blender/blenkernel/intern/mesh_validate.c | 2 +- source/blender/blenkernel/intern/nla.c | 2 +- source/blender/blenkernel/intern/node.c | 2 +- source/blender/blenkernel/intern/packedFile.c | 2 +- source/blender/blenkernel/intern/pointcache.c | 2 +- source/blender/blenkernel/intern/report.c | 2 +- source/blender/blenkernel/intern/sca.c | 2 +- source/blender/blenkernel/intern/seqcache.c | 2 +- source/blender/blenkernel/intern/seqeffects.c | 2 +- source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/shrinkwrap.c | 2 +- source/blender/blenkernel/intern/sketch.c | 2 +- source/blender/blenkernel/intern/smoke.c | 2 +- source/blender/blenkernel/intern/subsurf_ccg.c | 2 +- source/blender/blenkernel/intern/suggestions.c | 2 +- source/blender/blenkernel/intern/unit.c | 2 +- source/blender/blenkernel/intern/writeavi.c | 2 +- 45 files changed, 45 insertions(+), 45 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 b64efa811de..d2c00d21df3 100644 --- a/source/blender/blenkernel/intern/BME_Customdata.c +++ b/source/blender/blenkernel/intern/BME_Customdata.c @@ -1,4 +1,4 @@ -/** +/* * BME_customdata.c jan 2007 * * Custom Data functions for Bmesh diff --git a/source/blender/blenkernel/intern/BME_conversions.c b/source/blender/blenkernel/intern/BME_conversions.c index e80d4827155..4f1102bb828 100644 --- a/source/blender/blenkernel/intern/BME_conversions.c +++ b/source/blender/blenkernel/intern/BME_conversions.c @@ -1,4 +1,4 @@ -/** +/* * BME_mesh.c jan 2007 * * BMesh mesh level functions. diff --git a/source/blender/blenkernel/intern/BME_eulers.c b/source/blender/blenkernel/intern/BME_eulers.c index cd9429982dc..9d68866bc99 100644 --- a/source/blender/blenkernel/intern/BME_eulers.c +++ b/source/blender/blenkernel/intern/BME_eulers.c @@ -1,4 +1,4 @@ -/** +/* * BME_eulers.c jan 2007 * * BMesh Euler construction API. diff --git a/source/blender/blenkernel/intern/BME_mesh.c b/source/blender/blenkernel/intern/BME_mesh.c index 1bb419937b0..ca5d0b412ed 100644 --- a/source/blender/blenkernel/intern/BME_mesh.c +++ b/source/blender/blenkernel/intern/BME_mesh.c @@ -1,4 +1,4 @@ -/** +/* * BME_mesh.c jan 2007 * * BMesh mesh level functions. diff --git a/source/blender/blenkernel/intern/BME_structure.c b/source/blender/blenkernel/intern/BME_structure.c index 9463d22e3be..8970e7ff705 100644 --- a/source/blender/blenkernel/intern/BME_structure.c +++ b/source/blender/blenkernel/intern/BME_structure.c @@ -1,4 +1,4 @@ -/** +/* * BME_structure.c jan 2007 * * Low level routines for manipulating the BMesh structure. diff --git a/source/blender/blenkernel/intern/BME_tools.c b/source/blender/blenkernel/intern/BME_tools.c index 0c8352ad8b0..2b28fb705fd 100644 --- a/source/blender/blenkernel/intern/BME_tools.c +++ b/source/blender/blenkernel/intern/BME_tools.c @@ -1,4 +1,4 @@ -/** +/* * BME_tools.c jan 2007 * * Functions for changing the topology of a mesh. diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 79e23b77306..ed636e95b96 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 328f2ccdc75..14a0f71f824 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 08d506f94b8..a8c369a9b7b 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1,4 +1,4 @@ -/** anim.c +/* anim.c * * * $Id$ diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 499a1ac6ed8..77d0f008c2b 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 3174954423f..49c151947a4 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/bmesh_private.h b/source/blender/blenkernel/intern/bmesh_private.h index 713194c9806..b14383378ab 100644 --- a/source/blender/blenkernel/intern/bmesh_private.h +++ b/source/blender/blenkernel/intern/bmesh_private.h @@ -1,4 +1,4 @@ -/** +/* * BME_private.h jan 2007 * * low level, 'private' function prototypes for bmesh kernel. diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index aa0669903c5..1d4bdf8bf44 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -1,4 +1,4 @@ -/** +/* * bmfont.c * * 04-10-2000 frank diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 473be5a3ee0..15404acc105 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index db7b9b276a2..949be31354c 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -1,4 +1,4 @@ -/** +/* * * $Id$ * diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index e7efc09ec6e..827dddf34d3 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 58a7944f78b..a80b6dfab7d 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index d102a83d69f..c437c4fe61f 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index fc5aecb5def..b50943ba9f1 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 3db9731310c..bfbe18d439e 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -1,4 +1,4 @@ -/** +/* * fluidsim.c * * diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index e4aeb45a209..f979973f55d 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index c3e2d7ffcf4..abd7c12ff70 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/icons.c b/source/blender/blenkernel/intern/icons.c index b575305171a..8ce3847bf08 100644 --- a/source/blender/blenkernel/intern/icons.c +++ b/source/blender/blenkernel/intern/icons.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index 17f7dd06e29..6c8b5329711 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 97fbcce1aec..b3119f317a5 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index bd7fdfebe97..b0f90ef8042 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -1,4 +1,4 @@ -/** +/* * lattice.c * * diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 99fcd3f4a50..05d1e5841dc 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index d89bc3cd6f2..4f44875b7ea 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -1,4 +1,4 @@ -/** mball.c +/* mball.c * * MetaBalls are created from a single Object (with a name without number in it), * here the DispList and BoundBox also is located. diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index e5aacdf2cf9..8b0b7a041dc 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index da0f3f8a448..df012c47f66 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index d645bcd8329..943a33acf13 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 1fc0a2259fb..981b3b31e71 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -1,4 +1,4 @@ -/** +/* * blenkernel/packedFile.c - (cleaned up mar-01 nzc) * * $Id$ diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index b7ece436ee2..509569b7d5f 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1,4 +1,4 @@ -/** +/* * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index 044e1350be1..fa2e867d483 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index c8ef834fbbb..c004e254572 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/seqcache.c b/source/blender/blenkernel/intern/seqcache.c index 1c40ef020be..df81bcd1593 100644 --- a/source/blender/blenkernel/intern/seqcache.c +++ b/source/blender/blenkernel/intern/seqcache.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index da90ce4a715..7ddd1fbd6bb 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 69d8713ec8b..83e28db771a 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index a75bc2164c3..f2c456cc465 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -1,4 +1,4 @@ -/** +/* * shrinkwrap.c * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index 1d5f9b4c463..8917d2946bd 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -1,4 +1,4 @@ -/** +/* * * $Id$ * diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 1d80e989da4..b2d3ddf2e52 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1,4 +1,4 @@ -/** +/* * smoke.c * * $Id$ diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 9b4b9a78dd4..5697c29db5d 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/suggestions.c b/source/blender/blenkernel/intern/suggestions.c index 7ec6d84d285..052b545cfb4 100644 --- a/source/blender/blenkernel/intern/suggestions.c +++ b/source/blender/blenkernel/intern/suggestions.c @@ -1,4 +1,4 @@ -/** +/* * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index c3a34e1942f..26105eea245 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -1,4 +1,4 @@ -/** +/* * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index e946ce06aa2..1c1febf2609 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -1,4 +1,4 @@ -/** +/* * Functions for writing avi-format files. * Added interface for generic movie support (ton) * -- cgit v1.2.3 From 4fe21e0b4f44e1fcf87b36c8d27da11340998b4c Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Wed, 23 Feb 2011 13:50:41 +0000 Subject: The material "Dynamic" node (disabled anyway) had incomplete base type initialization, which made it appear as an empty item in the input node category. --- source/blender/blenkernel/intern/node.c | 2 +- 1 file changed, 1 insertion(+), 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 943a33acf13..631c4e76115 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -3436,7 +3436,7 @@ static void registerShaderNodes(ListBase *ntypelist) register_node_type_sh_value(ntypelist); register_node_type_sh_rgb(ntypelist); register_node_type_sh_texture(ntypelist); - register_node_type_sh_dynamic(ntypelist); +// register_node_type_sh_dynamic(ntypelist); register_node_type_sh_invert(ntypelist); register_node_type_sh_seprgb(ntypelist); register_node_type_sh_combrgb(ntypelist); -- cgit v1.2.3 From 00c05c84048857391a4f30042721f79c60798814 Mon Sep 17 00:00:00 2001 From: "Guillermo S. Romero" Date: Wed, 23 Feb 2011 18:03:40 +0000 Subject: Clean up headers a bit more. --- source/blender/blenkernel/intern/cloth.c | 52 ++++++++++++------------ source/blender/blenkernel/intern/collision.c | 56 +++++++++++++------------- source/blender/blenkernel/intern/exotic.c | 8 ++-- source/blender/blenkernel/intern/fluidsim.c | 3 +- source/blender/blenkernel/intern/implicit.c | 56 +++++++++++++------------- source/blender/blenkernel/intern/paint.c | 4 +- source/blender/blenkernel/intern/pointcache.c | 3 +- source/blender/blenkernel/intern/shrinkwrap.c | 2 +- source/blender/blenkernel/intern/unit.c | 1 + source/blender/blenkernel/intern/writeffmpeg.c | 2 + 10 files changed, 97 insertions(+), 90 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 39cb1346eb7..09f18514277 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -1,29 +1,29 @@ -/* cloth.c -* -* -* ***** 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) Blender Foundation -* All rights reserved. -* -* Contributor(s): Daniel Genrich -* -* ***** END GPL LICENSE BLOCK ***** -*/ +/* + * $Id$ + * + * ***** 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) Blender Foundation + * All rights reserved. + * + * Contributor(s): Daniel Genrich + * + * ***** END GPL LICENSE BLOCK ***** + */ #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 3c0453c82a5..623ba26e86d 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -1,31 +1,31 @@ -/* collision.c -* -* -* ***** 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) Blender Foundation -* All rights reserved. -* -* The Original Code is: all of this file. -* -* Contributor(s): none yet. -* -* ***** END GPL LICENSE BLOCK ***** -*/ +/* + * $Id$ + * + * ***** 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) Blender Foundation + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index e7596001400..4a6638ff3a0 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -1,4 +1,5 @@ -/* exotic.c +/* + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -20,14 +21,15 @@ * All rights reserved. * * - * Contributor(s): + * Contributor(s): * - Martin DeMello * Added dxf_read_arc, dxf_read_ellipse and dxf_read_lwpolyline * Copyright (C) 2004 by Etheract Software Labs * * - Blender Foundation * - * ***** END GPL LICENSE BLOCK *****/ + * ***** END GPL LICENSE BLOCK **** + */ #include #include "BLI_storage.h" diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index bfbe18d439e..bb56a5b176a 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -1,6 +1,5 @@ /* - * fluidsim.c - * + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 8004f23c22a..207c667f335 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -1,31 +1,31 @@ -/* implicit.c -* -* -* ***** 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) Blender Foundation -* All rights reserved. -* -* The Original Code is: all of this file. -* -* Contributor(s): none yet. -* -* ***** END GPL LICENSE BLOCK ***** -*/ +/* + * $Id$ + * + * ***** 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) Blender Foundation + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ #include "MEM_guardedalloc.h" diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 853338d0722..e53888127f2 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1,4 +1,6 @@ /* + * $Id$ + * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -23,7 +25,7 @@ * Contributor(s): none yet. * * ***** END GPL LICENSE BLOCK ***** - */ + */ #include "DNA_object_types.h" diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 509569b7d5f..6ea14606660 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1,4 +1,5 @@ /* + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -19,7 +20,7 @@ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. * All rights reserved. * -* Contributor(s): Campbell Barton + * Contributor(s): Campbell Barton * * ***** END GPL LICENSE BLOCK ***** */ diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index f2c456cc465..53fefa685b9 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -1,5 +1,5 @@ /* - * shrinkwrap.c + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 26105eea245..b071f2c9da5 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -1,4 +1,5 @@ /* + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index bb00e6de5ce..f3b759113ff 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -1,4 +1,6 @@ /* + * $Id$ + * * ffmpeg-write support * * Partial Copyright (c) 2006 Peter Schlaile -- cgit v1.2.3 From 04d04f64011a06255f91faf4445947d162b5a9f0 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Thu, 24 Feb 2011 15:48:09 +0000 Subject: Fixed memory leak in group nodes. Only buffers from exposed sockets should remain after group execution. --- source/blender/blenkernel/intern/node.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 631c4e76115..7f8a27bd947 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1983,6 +1983,33 @@ static void node_group_execute(bNodeStack *stack, void *data, bNode *gnode, bNod node->typeinfo->execfunc(data, node, nsin, nsout); } } + + /* free internal buffers */ + if (ntree->type==NTREE_COMPOSIT) { + bNodeSocket *sock; + bNodeStack *ns; + for (sock=ntree->outputs.first; sock; sock=sock->next) { + /* use the hasoutput flag to tag external sockets */ + if (sock->stack_type==SOCK_STACK_LOCAL) { + ns= get_socket_stack(stack, sock, in); + ns->hasoutput = 0; + } + } + /* now free all stacks that are not used from outside */ + for (node=ntree->nodes.first; node; node=node->next) { + for (sock=node->outputs.first; sock; sock=sock->next) { + if (sock->stack_type==SOCK_STACK_LOCAL ) { + ns= get_socket_stack(stack, sock, in); + if (ns->hasoutput!=0 && ns->data) { + free_compbuf(ns->data); + ns->data = NULL; + /* reset the flag */ + ns->hasoutput = 1; + } + } + } + } + } } static int set_stack_indexes_default(bNode *node, int index) -- cgit v1.2.3 From 09e8a8222c96c7c3e25980a4109ec3d53cf83def Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 25 Feb 2011 11:25:11 +0000 Subject: needed for building without python --- source/blender/blenkernel/intern/node.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 7f8a27bd947..15ad3a7809a 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "DNA_anim_types.h" #include "DNA_action_types.h" -- cgit v1.2.3