From 4c0bcbf4da991e3a8fe5b01bebbb3dc54fe183f8 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Mon, 5 May 2008 17:26:33 +0000 Subject: fix for bad indexing found by Cyril Brulebois Its making the identity matrix so I just removed the initalizing values that were out of bounds. Kent --- source/blender/blenkernel/intern/constraint.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 88ae02cd418..f60e39769a2 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -1104,9 +1104,9 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh /* identity matrix - don't do anything if the two axes are the same */ else { m[0][0]= m[1][1]= m[2][2]= 1.0; - m[0][1]= m[0][2]= m[0][3]= 0.0; - m[1][0]= m[1][2]= m[1][3]= 0.0; - m[2][0]= m[2][1]= m[2][3]= 0.0; + m[0][1]= m[0][2]= 0.0; + m[1][0]= m[1][2]= 0.0; + m[2][0]= m[2][1]= 0.0; } } -- cgit v1.2.3 From b36fe51c7d85b5ea761d4ba9121001efb75b5c30 Mon Sep 17 00:00:00 2001 From: Kent Mein Date: Mon, 5 May 2008 17:29:11 +0000 Subject: Fixed some indentation, I stumbled across (spaces vs tabs) and also removed return 0 from a void stub. Kent --- source/blender/blenkernel/bad_level_call_stubs/stubs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c index 291dd70c801..c913820205b 100644 --- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c +++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c @@ -355,7 +355,7 @@ TimeMarker *get_frame_marker(int frame){return 0;}; /* editseq.c */ Sequence *get_forground_frame_seq(int frame){return 0;}; -void set_last_seq(Sequence *seq){return 0;}; +void set_last_seq(Sequence *seq){}; /* modifier.c stub */ void harmonic_coordinates_bind(struct MeshDeformModifierData *mmd, -- cgit v1.2.3 From d5ffcda5dcad9c2037f38b965114916566cbd4a7 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 May 2008 17:41:14 +0000 Subject: Fix for bug #10347: particles reset with orbit around selection option, was doing unnecessary dependency graph calls. --- source/blender/src/transform_conversions.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender') diff --git a/source/blender/src/transform_conversions.c b/source/blender/src/transform_conversions.c index f3fec3cfec7..8859194ff9c 100644 --- a/source/blender/src/transform_conversions.c +++ b/source/blender/src/transform_conversions.c @@ -3072,6 +3072,10 @@ static void set_trans_object_base_flags(TransInfo *t) */ Base *base; + /* don't do it if we're not actually going to recalculate anything */ + if(t->mode == TFM_DUMMY) + return; + /* makes sure base flags and object flags are identical */ copy_baseflags(); -- cgit v1.2.3 From 95ed34be4a6bf71e14740ed6232033443484dd86 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 May 2008 17:43:13 +0000 Subject: Fix for bug #10444: environment map crash with qmc. --- source/blender/render/intern/source/envmap.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source/blender') diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 26151ff8b91..12d0efa59e8 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -158,6 +158,7 @@ static Render *envmap_render_copy(Render *re, EnvMap *env) envre->totinstance= re->totinstance; envre->instancetable= re->instancetable; envre->objectinstance= re->objectinstance; + envre->qmcsamplers= re->qmcsamplers; return envre; } @@ -178,6 +179,7 @@ static void envmap_free_render_copy(Render *envre) envre->raytree= NULL; envre->instancetable.first= envre->instancetable.last= NULL; envre->objectinstance= NULL; + envre->qmcsamplers= NULL; RE_FreeRender(envre); } -- cgit v1.2.3 From b6f5679cf5707c2027f6629e8f61c24d14bd54e9 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 5 May 2008 21:10:32 +0000 Subject: Fix for bug #10542: changing particle visualisation type from object to something else didn't work correct. Fix for bug #10478: particle system point cache problem. --- source/blender/blenkernel/intern/particle_system.c | 3 +++ source/blender/src/buttons_object.c | 10 ++++++++++ 2 files changed, 13 insertions(+) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 9dd21cdda4e..596c381b896 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4763,6 +4763,9 @@ static void system_step(Object *ob, ParticleSystem *psys, ParticleSystemModifier psys_update_path_cache(ob,psmd,psys,framenr); } + cache->simframe= framenr; + cache->flag |= PTCACHE_SIMULATION_VALID; + return; } else if(ob->id.lib || (cache->flag & PTCACHE_BAKED)) { diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 37becdc8912..0cfc2047aec 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -3010,6 +3010,16 @@ void do_effects_panels(unsigned short event) case B_PART_INIT_CHILD: case B_PART_RECALC_CHILD: if(psys) { + nr=0; + for(psys=ob->particlesystem.first; psys; psys=psys->next){ + if(ELEM(psys->part->draw_as,PART_DRAW_OB,PART_DRAW_GR)) + nr++; + } + if(nr) + ob->transflag |= OB_DUPLIPARTS; + else + ob->transflag &= ~OB_DUPLIPARTS; + DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA); allqueue(REDRAWVIEW3D, 0); allqueue(REDRAWBUTSOBJECT, 0); -- cgit v1.2.3 From 2b1797d07bfd4549b3c74a127aeb1fa8460dfb87 Mon Sep 17 00:00:00 2001 From: Peter Schlaile Date: Mon, 5 May 2008 22:08:50 +0000 Subject: == FFMPEG == Fixes: [#10703] loading an .avi captured by dosbox causes a segfault We shouldn't try to close a codec, if we haven't managed to open one... :) --- source/blender/imbuf/intern/util.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 4f2a1da5580..632a471ecd0 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -305,13 +305,11 @@ static int isffmpeg (char *filename) { /* Find the decoder for the video stream */ pCodec=avcodec_find_decoder(pCodecCtx->codec_id); if(pCodec==NULL) { - avcodec_close(pCodecCtx); av_close_input_file(pFormatCtx); return 0; } if(avcodec_open(pCodecCtx, pCodec)<0) { - avcodec_close(pCodecCtx); av_close_input_file(pFormatCtx); return 0; } -- cgit v1.2.3 From ee87af1e16f4aef7a8427b55100f545168608c9d Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Tue, 6 May 2008 07:10:30 +0000 Subject: Bugfixes: * NLA scaling was being incorrectly handled with fractional values. This was caused by clamping to integers instead of floats when making sure the scale value was positive. * Added checks to help prevent some weird cases that may sometimes occur and cause problems --- source/blender/blenkernel/intern/action.c | 6 +++--- source/blender/src/drawnla.c | 33 +++++++++++++++++-------------- source/blender/src/editnla.c | 9 +++++++-- 3 files changed, 28 insertions(+), 20 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index c4df1db7627..5fb3d6f869a 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -489,11 +489,11 @@ static float get_actionstrip_frame(bActionStrip *strip, float cframe, int invert { float length, actlength, repeat, scale; - if(strip->repeat == 0.0f) strip->repeat = 1.0f; + if (strip->repeat == 0.0f) strip->repeat = 1.0f; repeat = (strip->flag & ACTSTRIP_USESTRIDE) ? (1.0f) : (strip->repeat); - if(strip->scale == 0.0f) strip->scale= 1.0f; - scale = abs(strip->scale); /* scale must be positive (for now) */ + if (strip->scale == 0.0f) strip->scale= 1.0f; + scale = fabs(strip->scale); /* scale must be positive (for now) */ actlength = strip->actend-strip->actstart; if (actlength == 0.0f) actlength = 1.0f; diff --git a/source/blender/src/drawnla.c b/source/blender/src/drawnla.c index fba55f7f308..c0cd11d27a1 100644 --- a/source/blender/src/drawnla.c +++ b/source/blender/src/drawnla.c @@ -490,39 +490,42 @@ void do_nlabuts(unsigned short event) allqueue (REDRAWNLA, 0); allqueue (REDRAWVIEW3D, 0); break; - case B_NLA_SCALE: + case B_NLA_SCALE: /* adjust end-frame when scale is changed */ { float actlen= strip->actend - strip->actstart; float mapping= strip->scale * strip->repeat; - strip->end = (actlen * mapping) + strip->start; + if (mapping != 0.0f) + strip->end = (actlen * mapping) + strip->start; + else + printf("NLA Scale Error: Scale = %0.4f, Repeat = %0.4f \n", strip->scale, strip->repeat); - allqueue (REDRAWNLA, 0); - allqueue (REDRAWIPO, 0); - allqueue (REDRAWACTION, 0); - allqueue (REDRAWVIEW3D, 0); + allqueue(REDRAWNLA, 0); + allqueue(REDRAWIPO, 0); + allqueue(REDRAWACTION, 0); + allqueue(REDRAWVIEW3D, 0); } break; - case B_NLA_SCALE2: + case B_NLA_SCALE2: /* adjust scale when end-frame is changed */ { float actlen= strip->actend - strip->actstart; float len= strip->end - strip->start; strip->scale= len / (actlen * strip->repeat); - allqueue (REDRAWNLA, 0); - allqueue (REDRAWIPO, 0); - allqueue (REDRAWACTION, 0); - allqueue (REDRAWVIEW3D, 0); + allqueue(REDRAWNLA, 0); + allqueue(REDRAWIPO, 0); + allqueue(REDRAWACTION, 0); + allqueue(REDRAWVIEW3D, 0); } break; case B_NLA_LOCK: synchronize_action_strips(); - allqueue (REDRAWNLA, 0); - allqueue (REDRAWIPO, 0); - allqueue (REDRAWACTION, 0); - allqueue (REDRAWVIEW3D, 0); + allqueue(REDRAWNLA, 0); + allqueue(REDRAWIPO, 0); + allqueue(REDRAWACTION, 0); + allqueue(REDRAWVIEW3D, 0); break; case B_NLA_MOD_ADD: diff --git a/source/blender/src/editnla.c b/source/blender/src/editnla.c index 6d9adda85d0..d758f34949a 100644 --- a/source/blender/src/editnla.c +++ b/source/blender/src/editnla.c @@ -188,11 +188,16 @@ void shift_nlastrips_down(void) { void synchronize_action_strips(void) { Base *base; + Object *ob; bActionStrip *strip; for (base=G.scene->base.first; base; base=base->next) { + /* get object first */ + ob= base->object; + /* step 1: adjust strip-lengths */ - for (strip = base->object->nlastrips.last; strip; strip=strip->prev) { + // FIXME: this seems very buggy + for (strip = ob->nlastrips.last; strip; strip=strip->prev) { if (strip->flag & ACTSTRIP_LOCK_ACTION) { float actstart, actend; @@ -212,7 +217,7 @@ void synchronize_action_strips(void) } /* step 2: adjust blendin/out values for each strip if option is turned on */ - for (strip= base->object->nlastrips.first; strip; strip=strip->next) { + for (strip= ob->nlastrips.first; strip; strip=strip->next) { if (strip->flag & ACTSTRIP_AUTO_BLENDS) { bActionStrip *prev= strip->prev; bActionStrip *next= strip->next; -- cgit v1.2.3 From 04d2a8badc165e91e9db664962dac3794ee5fc0e Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 6 May 2008 08:35:19 +0000 Subject: Fix for bug #10734: mirror modifier crash with no axis enabled for mirroring around. --- source/blender/blenkernel/intern/modifier.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 0cd6035b9dc..ca95d9edc06 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -1506,7 +1506,8 @@ static DerivedMesh *mirrorModifier_applyModifier( result = mirrorModifier__doMirror(mmd, ob, derivedData, 0); - CDDM_calc_normals(result); + if(result != derivedData) + CDDM_calc_normals(result); return result; } -- cgit v1.2.3 From 722f24d15357275ee3efed33fa03f9b27909a604 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 6 May 2008 15:31:17 +0000 Subject: Fix for bug: drawing x-ray and transparency with sets didn't work well, now it draws those type of objects from sets also at the end. --- source/blender/include/BSE_drawview.h | 2 +- source/blender/src/drawobject.c | 4 ++-- source/blender/src/drawview.c | 29 +++++++++++++---------------- 3 files changed, 16 insertions(+), 19 deletions(-) (limited to 'source/blender') diff --git a/source/blender/include/BSE_drawview.h b/source/blender/include/BSE_drawview.h index 09ce87015d9..be1f5581be7 100644 --- a/source/blender/include/BSE_drawview.h +++ b/source/blender/include/BSE_drawview.h @@ -46,7 +46,7 @@ void do_viewbuts(unsigned short event); /* View3DAfter->type */ #define V3D_XRAY 1 #define V3D_TRANSP 2 -void add_view3d_after(struct View3D *v3d, struct Base *base, int type); +void add_view3d_after(struct View3D *v3d, struct Base *base, int type, int flag); void backdrawview3d(int test); void check_backbuf(void); diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index aec0e112b32..181f797dbc9 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -2485,7 +2485,7 @@ static int draw_mesh_object(Base *base, int dt, int flag) } /* init_gl_materials did the proper checking if this is needed */ - if(has_alpha) add_view3d_after(G.vd, base, V3D_TRANSP); + if(has_alpha) add_view3d_after(G.vd, base, V3D_TRANSP, flag); return retval; } @@ -4663,7 +4663,7 @@ void draw_object(Base *base, int flag) if(!(G.f & G_PARTICLEEDIT)) { /* xray and transp are set when it is drawing the 2nd/3rd pass */ if(!G.vd->xray && !G.vd->transp && (ob->dtx & OB_DRAWXRAY)) { - add_view3d_after(G.vd, base, V3D_XRAY); + add_view3d_after(G.vd, base, V3D_XRAY, flag); return; } } diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index b01b7bc151c..1acb7c4373f 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -2663,21 +2663,22 @@ static void view3d_blockhandlers(ScrArea *sa) typedef struct View3DAfter { struct View3DAfter *next, *prev; struct Base *base; - int type; + int type, flag; } View3DAfter; /* temp storage of Objects that need to be drawn as last */ -void add_view3d_after(View3D *v3d, Base *base, int type) +void add_view3d_after(View3D *v3d, Base *base, int type, int flag) { View3DAfter *v3da= MEM_callocN(sizeof(View3DAfter), "View 3d after"); BLI_addtail(&v3d->afterdraw, v3da); v3da->base= base; v3da->type= type; + v3da->flag= flag; } /* clears zbuffer and draws it over */ -static void view3d_draw_xray(View3D *v3d, int flag) +static void view3d_draw_xray(View3D *v3d) { View3DAfter *v3da, *next; int doit= 0; @@ -2692,7 +2693,7 @@ static void view3d_draw_xray(View3D *v3d, int flag) for(v3da= v3d->afterdraw.first; v3da; v3da= next) { next= v3da->next; if(v3da->type==V3D_XRAY) { - draw_object(v3da->base, flag); + draw_object(v3da->base, v3da->flag); BLI_remlink(&v3d->afterdraw, v3da); MEM_freeN(v3da); } @@ -2702,7 +2703,7 @@ static void view3d_draw_xray(View3D *v3d, int flag) } /* disables write in zbuffer and draws it over */ -static void view3d_draw_transp(View3D *v3d, int flag) +static void view3d_draw_transp(View3D *v3d) { View3DAfter *v3da, *next; @@ -2712,7 +2713,7 @@ static void view3d_draw_transp(View3D *v3d, int flag) for(v3da= v3d->afterdraw.first; v3da; v3da= next) { next= v3da->next; if(v3da->type==V3D_TRANSP) { - draw_object(v3da->base, flag); + draw_object(v3da->base, v3da->flag); BLI_remlink(&v3d->afterdraw, v3da); MEM_freeN(v3da); } @@ -3102,9 +3103,7 @@ void drawview3dspace(ScrArea *sa, void *spacedata) } } - /* Transp and X-ray afterdraw stuff */ - view3d_draw_xray(v3d, DRAW_CONSTCOLOR); // clears zbuffer if it is used! - view3d_draw_transp(v3d, DRAW_CONSTCOLOR); + /* Transp and X-ray afterdraw stuff for sets is done later */ } /* then draw not selected and the duplis, but skip editmode object */ @@ -3150,8 +3149,8 @@ void drawview3dspace(ScrArea *sa, void *spacedata) if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID); /* Transp and X-ray afterdraw stuff */ - view3d_draw_xray(v3d, 0); // clears zbuffer if it is used! - view3d_draw_transp(v3d, 0); + view3d_draw_xray(v3d); // clears zbuffer if it is used! + view3d_draw_transp(v3d); if(!retopo && sculptparticle && (obact && (OBACT->dtx & OB_DRAWXRAY))) { if(G.f & G_SCULPTMODE) @@ -3327,9 +3326,7 @@ void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4] } } - /* Transp and X-ray afterdraw stuff */ - view3d_draw_xray(v3d, DRAW_CONSTCOLOR); // clears zbuffer if it is used! - view3d_draw_transp(v3d, DRAW_CONSTCOLOR); + /* Transp and X-ray afterdraw stuff for sets is done later */ } /* first not selected and duplis */ @@ -3367,8 +3364,8 @@ void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4] if(G.scene->radio) RAD_drawall(v3d->drawtype>=OB_SOLID); /* Transp and X-ray afterdraw stuff */ - view3d_draw_xray(v3d, 0); // clears zbuffer if it is used! - view3d_draw_transp(v3d, 0); + view3d_draw_xray(v3d); // clears zbuffer if it is used! + view3d_draw_transp(v3d); if(v3d->flag & V3D_CLIPPING) view3d_clr_clipping(); -- cgit v1.2.3 From 4255f3c7abe5c0bc7e9d2bc407ec6671e6ae6c45 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 May 2008 17:54:55 +0000 Subject: made python add mesh module respect blenders user settings for editmode and view align. added sys.cleanpath() was a patch in the tracker but blender's internal path cleaning is now more general and can be used from python. --- source/blender/python/api2_2x/Blender.c | 8 ++++++-- source/blender/python/api2_2x/Sys.c | 28 +++++++++++++++++++++++++++- source/blender/python/api2_2x/doc/Sys.py | 11 ++++++++++- 3 files changed, 43 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index daba0c36fdf..7c2895d96be 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -545,8 +545,12 @@ static PyObject *Blender_Get( PyObject * self, PyObject * value ) else if(StringEqual( str, "compressfile" )) ret = PyInt_FromLong( (U.flag & USER_FILECOMPRESS) >> 15 ); else if(StringEqual( str, "mipmap" )) - ret = PyInt_FromLong( (U.gameflags & USER_DISABLE_MIPMAP) == 0 ); - else + ret = PyInt_FromLong( (U.gameflags & USER_DISABLE_MIPMAP)!=0 ); + else if(StringEqual( str, "add_view_align" )) + ret = PyInt_FromLong( ((U.flag & USER_ADD_VIEWALIGNED)!=0) ); + else if(StringEqual( str, "add_editmode" )) + ret = PyInt_FromLong( ((U.flag & USER_ADD_EDITMODE)!=0) ); + else return EXPP_ReturnPyObjError( PyExc_AttributeError, "unknown attribute" ); if (ret) return ret; diff --git a/source/blender/python/api2_2x/Sys.c b/source/blender/python/api2_2x/Sys.c index 9de4e344e8c..3863cc12227 100644 --- a/source/blender/python/api2_2x/Sys.c +++ b/source/blender/python/api2_2x/Sys.c @@ -58,6 +58,7 @@ static PyObject *M_sys_exists( PyObject * self, PyObject * value ); static PyObject *M_sys_time( PyObject * self ); static PyObject *M_sys_sleep( PyObject * self, PyObject * args ); static PyObject *M_sys_expandpath( PyObject *self, PyObject *value); +static PyObject *M_sys_cleanpath( PyObject *self, PyObject *value); /*****************************************************************************/ /* The following string definitions are used for documentation strings. */ @@ -120,10 +121,13 @@ static char M_sys_expandpath_doc[] = (path) - the string path to convert.\n\n\ Note: internally Blender paths can contain two special character sequences:\n\ - '//' (at start) for base path directory (the current .blend's dir path);\n\ -- '#' (at ending) for current frame number.\n\n\ +- '#' characters in the filename will be replaced by the frame number.\n\n\ This function expands these to their actual content, returning a valid path.\n\ If the special chars are not found in the given path, it is simply returned."; +static char M_sys_cleanpath_doc[] = +"(path) - Removes parts of a path that are not needed paths such as '../foo/../bar/' and '//./././'"; + /*****************************************************************************/ /* Python method structure definition for Blender.sys module: */ /*****************************************************************************/ @@ -139,6 +143,7 @@ struct PyMethodDef M_sys_methods[] = { {"sleep", M_sys_sleep, METH_VARARGS, M_sys_sleep_doc}, {"time", ( PyCFunction ) M_sys_time, METH_NOARGS, M_sys_time_doc}, {"expandpath", M_sys_expandpath, METH_O, M_sys_expandpath_doc}, + {"cleanpath", M_sys_cleanpath, METH_O, M_sys_cleanpath_doc}, {NULL, NULL, 0, NULL} }; @@ -396,3 +401,24 @@ static PyObject *M_sys_expandpath( PyObject * self, PyObject * value ) return PyString_FromString(expanded); } + +static PyObject *M_sys_cleanpath( PyObject * self, PyObject * value ) +{ + char *path = PyString_AsString(value); + char cleaned[FILE_MAXDIR + FILE_MAXFILE]; + int trailing_slash = 0; + if (!path) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "expected string argument" ); + if (strstr(path, "/") || strstr(path, "\\")) { + trailing_slash = 1; + } + BLI_strncpy(cleaned, path, FILE_MAXDIR + FILE_MAXFILE); + BLI_cleanup_file(NULL, cleaned); + + if (trailing_slash) { + BLI_add_slash(cleaned); + } + + return PyString_FromString(cleaned); +} diff --git a/source/blender/python/api2_2x/doc/Sys.py b/source/blender/python/api2_2x/doc/Sys.py index f1efeeb2344..d7c62f2cb02 100644 --- a/source/blender/python/api2_2x/doc/Sys.py +++ b/source/blender/python/api2_2x/doc/Sys.py @@ -153,7 +153,7 @@ def expandpath (path): Internally, Blender recognizes two special character sequences in paths: - '//' (used at the beginning): means base path -- the current .blend file's dir; - - '#' (used at the end): means current frame number. + - '#' characters in the filename will be replaced by the frame number. The expanded string can be passed to generic python functions that don't understand Blender's internal relative paths. @note: this function is also useful for obtaining the name of the image @@ -165,3 +165,12 @@ def expandpath (path): @rtype: string @return: the expanded (if necessary) path. """ + +def cleanpath (path): + """ + Clean the given 'path' by removing unneeded components such as "/./" and "/test/../" + @type path: string + @param path: a path name. + @rtype: string + @return: the cleaned (if necessary) path. + """ -- cgit v1.2.3 From c0d981f6db057fbe8c5a9483382bab1e20572e38 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 May 2008 18:57:24 +0000 Subject: patches [#10529] -p command line option fix [#8844] Glossy controls Python API --- source/blender/python/api2_2x/Material.c | 88 +++++++++++++++++++++++++++ source/blender/python/api2_2x/doc/Material.py | 12 ++++ 2 files changed, 100 insertions(+) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c index 79deb29bafa..818c58109f3 100644 --- a/source/blender/python/api2_2x/Material.c +++ b/source/blender/python/api2_2x/Material.c @@ -128,6 +128,14 @@ #define EXPP_MAT_FRESNELMIRR_MAX 5.0 #define EXPP_MAT_FRESNELMIRRFAC_MIN 1.0 #define EXPP_MAT_FRESNELMIRRFAC_MAX 5.0 +#define EXPP_MAT_RAYMIRRGLOSS_MIN 0.0 +#define EXPP_MAT_RAYMIRRGLOSS_MAX 1.0 +#define EXPP_MAT_RAYMIRRGLOSSSAMPLES_MIN 0 +#define EXPP_MAT_RAYMIRRGLOSSSAMPLES_MAX 255 +#define EXPP_MAT_RAYTRANSPGLOSS_MIN 0.0 +#define EXPP_MAT_RAYTRANSPGLOSS_MAX 1.0 +#define EXPP_MAT_RAYTRANSPGLOSSSAMPLES_MIN 0 +#define EXPP_MAT_RAYTRANSPGLOSSSAMPLES_MAX 255 #define EXPP_MAT_FILTER_MIN 0.0 #define EXPP_MAT_FILTER_MAX 1.0 #define EXPP_MAT_TRANSLUCENCY_MIN 0.0 @@ -516,6 +524,10 @@ static int Material_setIOR( BPy_Material * self, PyObject * value ); static int Material_setTransDepth( BPy_Material * self, PyObject * value ); static int Material_setFresnelTrans( BPy_Material * self, PyObject * value ); static int Material_setFresnelTransFac( BPy_Material * self, PyObject * value ); +static int Material_setGlossMirr( BPy_Material * self, PyObject * value ); +static int Material_setGlossMirrSamples( BPy_Material * self, PyObject * value ); +static int Material_setGlossTrans( BPy_Material * self, PyObject * value ); +static int Material_setGlossTransSamples( BPy_Material * self, PyObject * value ); static int Material_setRigidBodyFriction( BPy_Material * self, PyObject * value ); static int Material_setRigidBodyRestitution( BPy_Material * self, PyObject * value ); @@ -600,6 +612,10 @@ static PyObject *Material_getIOR( BPy_Material * self ); static PyObject *Material_getTransDepth( BPy_Material * self ); static PyObject *Material_getFresnelTrans( BPy_Material * self ); static PyObject *Material_getFresnelTransFac( BPy_Material * self ); +static PyObject *Material_getGlossMirr( BPy_Material * self ); +static PyObject *Material_getGlossMirrSamples( BPy_Material * self ); +static PyObject *Material_getGlossTrans( BPy_Material * self ); +static PyObject *Material_getGlossTransSamples( BPy_Material * self ); static PyObject *Material_getRigidBodyFriction( BPy_Material * self ); static PyObject *Material_getRigidBodyRestitution( BPy_Material * self ); @@ -720,6 +736,10 @@ static PyMethodDef BPy_Material_methods[] = { "() - Return fresnel power for refractions"}, {"getFresnelMirrFac", ( PyCFunction ) Material_getFresnelMirrFac, METH_NOARGS, "() - Return fresnel power for refractions factor"}, + {"getRayTransGloss", ( PyCFunction ) Material_getGlossTrans, METH_NOARGS, + "() - Return amount refraction glossiness"}, + {"getRayMirrGlossSamples", ( PyCFunction ) Material_getGlossMirrSamples, METH_NOARGS, + "() - Return amount mirror glossiness"}, {"getFilter", ( PyCFunction ) Material_getFilter, METH_NOARGS, "() - Return the amount of filtering when transparent raytrace is enabled"}, {"getTranslucency", ( PyCFunction ) Material_getTranslucency, METH_NOARGS, @@ -825,6 +845,10 @@ static PyMethodDef BPy_Material_methods[] = { "(f) - Set fresnel power for mirror - [0.0, 5.0]"}, {"setFresnelMirrFac", ( PyCFunction ) Matr_oldsetFresnelMirrFac, METH_VARARGS, "(f) - Set blend fac for mirror fresnel - [1.0, 5.0]"}, + {"setRayTransGloss", ( PyCFunction ) Material_setGlossTrans, METH_VARARGS, + "(f) - Set amount refraction glossiness - [0.0, 1.0]"}, + {"setRayMirrGlossSamples", ( PyCFunction ) Material_setGlossMirrSamples, METH_VARARGS, + "(f) - Set amount mirror glossiness - [0.0, 1.0]"}, {"setFilter", ( PyCFunction ) Matr_oldsetFilter, METH_VARARGS, "(f) - Set the amount of filtering when transparent raytrace is enabled"}, {"setTranslucency", ( PyCFunction ) Matr_oldsetTranslucency, METH_VARARGS, @@ -1030,6 +1054,22 @@ static PyGetSetDef BPy_Material_getseters[] = { (getter)Material_getRefracIndex, (setter)Material_setRefracIndex, "Material's Index of Refraction (applies to the \"Blinn\" Specular Shader only", NULL}, + {"glossMir", + (getter)Material_getGlossMirr, (setter)Material_setGlossMirr, + "Reflection glossiness", + NULL}, + {"sampGlossMir", + (getter)Material_getGlossMirrSamples, (setter)Material_setGlossMirrSamples, + "Reflection glossiness", + NULL}, + {"glossTra", + (getter)Material_getGlossTrans, (setter)Material_setGlossTrans, + "Refraction glossiness", + NULL}, + {"sampGlossTra", + (getter)Material_getGlossMirrSamples, (setter)Material_setGlossMirrSamples, + "Refraction glossiness", + NULL}, {"rgbCol", (getter)Material_getRGBCol, (setter)Material_setRGBCol, "Diffuse RGB color triplet", @@ -1578,6 +1618,26 @@ static PyObject *Material_getFresnelTransFac( BPy_Material * self ) return PyFloat_FromDouble( ( double ) self->material->fresnel_tra_i ); } +static PyObject *Material_getGlossMirr( BPy_Material * self ) +{ + return PyFloat_FromDouble( ( double ) self->material->gloss_mir ); +} + +static PyObject *Material_getGlossMirrSamples( BPy_Material * self ) +{ + return PyInt_FromLong( ( long ) self->material->samp_gloss_mir ); +} + +static PyObject *Material_getGlossTrans( BPy_Material * self ) +{ + return PyFloat_FromDouble( ( double ) self->material->gloss_tra ); +} + +static PyObject *Material_getGlossTransSamples( BPy_Material * self ) +{ + return PyInt_FromLong( ( long ) self->material->samp_gloss_tra ); +} + static PyObject* Material_getRigidBodyFriction( BPy_Material * self ) { return PyFloat_FromDouble( ( double ) self->material->friction ); @@ -2058,6 +2118,34 @@ static int Material_setFresnelTransFac( BPy_Material * self, PyObject * value ) EXPP_MAT_FRESNELTRANSFAC_MAX ); } +static int Material_setGlossMirr( BPy_Material * self, PyObject * value ) +{ + return EXPP_setFloatClamped ( value, &self->material->gloss_mir, + EXPP_MAT_RAYMIRRGLOSS_MIN, + EXPP_MAT_RAYMIRRGLOSS_MAX ); +} + +static int Material_setGlossMirrSamples( BPy_Material * self, PyObject * value ) +{ + return EXPP_setIValueClamped ( value, &self->material->samp_gloss_mir, + EXPP_MAT_RAYMIRRGLOSSSAMPLES_MIN, + EXPP_MAT_RAYMIRRGLOSSSAMPLES_MAX, 'h' ); +} + +static int Material_setGlossTrans( BPy_Material * self, PyObject * value ) +{ + return EXPP_setFloatClamped ( value, &self->material->gloss_tra, + EXPP_MAT_RAYTRANSPGLOSS_MIN, + EXPP_MAT_RAYTRANSPGLOSS_MAX ); +} + +static int Material_setGlossTransSamples( BPy_Material * self, PyObject * value ) +{ + return EXPP_setIValueClamped ( value, &self->material->samp_gloss_tra, + EXPP_MAT_RAYTRANSPGLOSSSAMPLES_MIN, + EXPP_MAT_RAYTRANSPGLOSSSAMPLES_MAX, 'h' ); +} + static int Material_setRigidBodyFriction( BPy_Material * self, PyObject * value ) { return EXPP_setFloatClamped ( value, &self->material->friction, diff --git a/source/blender/python/api2_2x/doc/Material.py b/source/blender/python/api2_2x/doc/Material.py index edcdbbb959b..a3496164cd1 100644 --- a/source/blender/python/api2_2x/doc/Material.py +++ b/source/blender/python/api2_2x/doc/Material.py @@ -237,6 +237,18 @@ class Material: @ivar rayMirr: Mirror reflection amount for raytrace. Value is clamped to the range [0.0,1.0]. @type rayMirr: float + @ivar glossMir: Amount of reflection glossy. + Value is clamped to the range [0.0,1.0]. + @type glossMir: float + @ivar sampGloss_mir: Reflection glossy samples. + Value is clamped to the range [1,1024]. + @type sampGloss_mir: int + @ivar glossTra: Amount of refraction glossy. + Value is clamped to the range [0.0,1.0]. + @type glossTra: float + @ivar sampGlossTra: Refraction glossy samples. + Value is clamped to the range [1,1024]. + @type sampGlossTra: int @ivar rayMirrDepth: Amount of raytrace inter-reflections. Value is clamped to the range [0,10]. @type rayMirrDepth: int -- cgit v1.2.3 From 917865b5049acaa2e13b7d40ebf879121c7e2148 Mon Sep 17 00:00:00 2001 From: Andrea Weikert Date: Tue, 6 May 2008 19:29:37 +0000 Subject: == bugfix == [#10312] Append Link (image browser) bug if combined with Open window The only place where the special handling in newspace is relevenant is when opening it with the windowtype_pupmenu. All other overlaying windows( render in image space, scriptspace) should leave imagebrowser/filebrowser space alone. --- source/blender/include/BIF_imasel.h | 1 + source/blender/include/BSE_filesel.h | 1 + source/blender/src/filesel.c | 21 +++++++++++++++++++++ source/blender/src/headerbuttons.c | 2 ++ source/blender/src/imasel.c | 23 +++++++++++++++++++++++ source/blender/src/space.c | 35 ++--------------------------------- 6 files changed, 50 insertions(+), 33 deletions(-) (limited to 'source/blender') diff --git a/source/blender/include/BIF_imasel.h b/source/blender/include/BIF_imasel.h index a3a3b7531d6..cbd547602e1 100644 --- a/source/blender/include/BIF_imasel.h +++ b/source/blender/include/BIF_imasel.h @@ -34,6 +34,7 @@ struct ScrArea; struct ID; void free_imasel(struct SpaceImaSel *simasel); +void reset_imaselspace(struct ScrArea *sa); void clever_numbuts_imasel(void); diff --git a/source/blender/include/BSE_filesel.h b/source/blender/include/BSE_filesel.h index 13e38d50c47..b46b2328ea4 100644 --- a/source/blender/include/BSE_filesel.h +++ b/source/blender/include/BSE_filesel.h @@ -54,6 +54,7 @@ void activate_databrowse(struct ID *id, int idcode, int fromcode, int retval, sh void activate_databrowse_args(struct ID *id, int idcode, int fromcode, short *menup, void (*func)(char *, void *, void *), void *arg1, void *arg2); void filesel_prevspace(void); +void reset_filespace(struct ScrArea *sa); void free_filesel_spec(char *dir); void winqreadfilespace(struct ScrArea *sa, void *spacedata, struct BWinEvent *evt); void main_to_filelist(struct SpaceFile *sfile); diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c index 19372dcbee6..bfff2f10ab6 100644 --- a/source/blender/src/filesel.c +++ b/source/blender/src/filesel.c @@ -1299,6 +1299,27 @@ void activate_databrowse_args(struct ID *id, int idcode, int fromcode, short *me sfile->ipotype= fromcode; } +/* resets a previous file space type */ +/* is used when opening a filebrowser directly from windowtype_pupmenu, + since in that case we don't want any load/save/append/link action +*/ +void reset_filespace(ScrArea *sa) +{ + if (sa->spacetype == SPACE_FILE) { + SpaceFile *sfile= sa->spacedata.first; + + if(sfile->type==FILE_MAIN) { + freefilelist(sfile); + } else { + sfile->type= FILE_UNIX; + } + + sfile->returnfunc= NULL; + sfile->title[0]= 0; + if(sfile->filelist) test_flags_file(sfile); + } +} + void filesel_prevspace() { SpaceFile *sfile= curarea->spacedata.first; diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index b91a8f74f80..81ad135f514 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -1434,6 +1434,8 @@ void do_global_buttons(unsigned short event) break; case B_NEWSPACE: newspace(curarea, curarea->butspacetype); + reset_filespace(curarea); + reset_imaselspace(curarea); break; case B_LOADTEMP: /* is button from space.c */ BIF_read_autosavefile(); diff --git a/source/blender/src/imasel.c b/source/blender/src/imasel.c index be9f489ea49..f502445d329 100644 --- a/source/blender/src/imasel.c +++ b/source/blender/src/imasel.c @@ -80,3 +80,26 @@ void free_imasel(SpaceImaSel *simasel) } } +/* resets a previous imagebrowser space type */ +/* is used when opening an imagebrowser directly from windowtype_pupmenu, + since in that case we don't want any load/save/append/link action +*/ +void reset_imaselspace(ScrArea *sa) +{ + if(sa->spacetype==SPACE_IMASEL) { + SpaceImaSel *simasel= sa->spacedata.first; + if(simasel->type==FILE_MAIN) { + if (simasel->files) { + BIF_filelist_free(simasel->files); + BIF_filelist_settype(simasel->files, FILE_MAIN); + } + } else { + if (simasel->files) { + simasel->type= FILE_UNIX; + BIF_filelist_settype(simasel->files, simasel->type); + } + } + simasel->returnfunc= NULL; + simasel->title[0]= 0; + } +} diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 41e539c3d1a..3cffed48224 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -5611,6 +5611,7 @@ static void init_imaselspace(ScrArea *sa) simasel->files = BIF_filelist_new(); } + /* ******************** SPACE: OOPS ********************** */ extern void drawoopsspace(ScrArea *sa, void *spacedata); @@ -6155,39 +6156,7 @@ void newspace(ScrArea *sa, int type) } } - - /* exception: filespace */ - if(sa->spacetype==SPACE_FILE) { - SpaceFile *sfile= sa->spacedata.first; - - if(sfile->type==FILE_MAIN) { - freefilelist(sfile); - } else { - sfile->type= FILE_UNIX; - } - - sfile->returnfunc= NULL; - sfile->title[0]= 0; - if(sfile->filelist) test_flags_file(sfile); - } - /* exception: imasel space */ - else if(sa->spacetype==SPACE_IMASEL) { - SpaceImaSel *simasel= sa->spacedata.first; - if(simasel->type==FILE_MAIN) { - if (simasel->files) { - BIF_filelist_free(simasel->files); - BIF_filelist_settype(simasel->files, FILE_MAIN); - } - } else { - if (simasel->files) { - simasel->type= FILE_UNIX; - BIF_filelist_settype(simasel->files, simasel->type); - } - } - simasel->returnfunc= NULL; - simasel->title[0]= 0; - } - else if(sa->spacetype==SPACE_OOPS) { + if(sa->spacetype==SPACE_OOPS) { SpaceOops *so= sa->spacedata.first; if(xtra && so->type!=SO_OUTLINER) { so->type= SO_OUTLINER; -- cgit v1.2.3 From 7d2e366e8ff0e58a469974d31d78b9d71ae30b52 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 May 2008 23:58:15 +0000 Subject: fix for [#10180] File Browser buttons disappear after clicking on Window Type button Spent some time looking into what this could break and it seems like a safe change. --- source/blender/src/interface.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index fb5b5e2f187..f324bf3b053 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -2328,6 +2328,7 @@ static int ui_do_but_ICONROW(uiBut *but) ListBase listb= {NULL, NULL}; uiBlock *block; int a; + short event; but->flag |= UI_SELECT; ui_draw_but(but); @@ -2348,13 +2349,17 @@ static int ui_do_but_ICONROW(uiBut *but) this is needs better implementation */ block->win= G.curscreen->mainwin; - uiDoBlocks(&listb, 0, 1); + event= uiDoBlocks(&listb, 0, 1); but->flag &= ~UI_SELECT; ui_check_but(but); ui_draw_but(but); - - return but->retval; + + if (event & UI_RETURN_OK) { + return but->retval; + } else { + return 0; + } } static int ui_do_but_ICONTEXTROW(uiBut *but) @@ -2363,7 +2368,7 @@ static int ui_do_but_ICONTEXTROW(uiBut *but) ListBase listb={NULL, NULL}; int width, a, xmax, ypos; MenuData *md; - + short event; but->flag |= UI_SELECT; ui_draw_but(but); ui_block_flush_back(but->block); // flush because this button creates own blocks loop @@ -2421,7 +2426,7 @@ static int ui_do_but_ICONTEXTROW(uiBut *but) uiBoundsBlock(block, 3); - uiDoBlocks(&listb, 0, 1); + event = uiDoBlocks(&listb, 0, 1); menudata_free(md); @@ -2429,10 +2434,12 @@ static int ui_do_but_ICONTEXTROW(uiBut *but) ui_check_but(but); ui_draw_but(but); - uibut_do_func(but); - - return but->retval; - + if (event & UI_RETURN_OK) { + uibut_do_func(but); + return but->retval; + } else { + return 0; + } } static int ui_do_but_IDPOIN(uiBut *but) -- cgit v1.2.3 From 4aa8dd0b633983b733d0655d583db8cc628a28ed Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 May 2008 00:37:38 +0000 Subject: fix for [#10290] Wire object hid in the back of soled obj. reverse wire draworder logic from r4059, wire-only meshes were not using a depth buffer which meant they would not be visible at all, if they were after an overlapping solid object in the scene (had this problem for peach too). --- source/blender/src/drawobject.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 181f797dbc9..561024fb74b 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -2425,19 +2425,23 @@ static void draw_mesh_fancy(Base *base, int dt, int flag) if (draw_wire) { /* If drawing wire and drawtype is not OB_WIRE then we are * overlaying the wires. + * + * UPDATE bug #10290 - With this wire-only objects can draw + * behind other objects depending on their order in the scene. 2x if 0's below. undo'ing zr's commit: r4059 */ - +#if 0 if (dt!=OB_WIRE) { bglPolygonOffset(1.0); glDepthMask(0); // disable write in zbuffer, selected edge wires show better } - +#endif dm->drawEdges(dm, (dt==OB_WIRE || totface==0)); - +#if 0 if (dt!=OB_WIRE) { glDepthMask(1); bglPolygonOffset(0.0); } +#endif } dm->release(dm); -- cgit v1.2.3 From 5e493eeb19572e4c70c1b4a9c283616995f2df8a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 May 2008 07:57:18 +0000 Subject: Setting frame in python allowed negative numbers (was casting to a short with no clamping!) disable capslock option isnt used anywhere. --- source/blender/python/api2_2x/Blender.c | 3 ++- source/blender/src/space.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index 7c2895d96be..4fc68d138e0 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -246,7 +246,8 @@ static PyObject *Blender_Set( PyObject * self, PyObject * args ) return EXPP_ReturnPyObjError( PyExc_ValueError, "expected an integer" ); - G.scene->r.cfra = (short)PyInt_AsLong( arg ) ; + G.scene->r.cfra = (int)PyInt_AsLong( arg ) ; + CLAMP(G.scene->r.cfra, 1, MAXFRAME); /* update all objects, so python scripts can export all objects in a scene without worrying about the view layers */ diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 3cffed48224..292b1f1bc1e 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -4163,16 +4163,17 @@ void drawinfospace(ScrArea *sa, void *spacedata) &(G.f), 0, 0, 0, 0, "Allow any .blend file to run scripts automatically (unsafe with blend files from an untrusted source)"); uiDefBut(block, LABEL,0,"Keyboard:", - (xpos+edgsp+(3*midsp)+(3*mpref)),y3label,mpref,buth, + (xpos+edgsp+(3*midsp)+(3*mpref)),y2label,mpref,buth, 0, 0, 0, 0, 0, ""); - + /* Not actually used anywhere! */ + /* uiDefButBitI(block, TOG, USER_NO_CAPSLOCK, B_U_CAPSLOCK, "Disable Caps Lock", (xpos+edgsp+(3*midsp)+(3*mpref)),y1,mpref,buth, &(U.flag), 0, 0, 0, 0, "Disables the Caps Lock key when entering text"); - + */ uiDefButBitI(block, TOG, USER_NONUMPAD, 0, "Emulate Numpad", - (xpos+edgsp+(3*midsp)+(3*mpref)),y2,mpref,buth, + (xpos+edgsp+(3*midsp)+(3*mpref)),y1,mpref,buth, &(U.flag), 0, 0, 0, 0, "Causes the 1 to 0 keys to act as the numpad (useful for laptops)"); -- cgit v1.2.3 From fa9b01908f97825c331b68425eba6b21e9fdfaa0 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 May 2008 12:23:51 +0000 Subject: Bugfix: modified the tooltip to indicate that the maximum length option for particle paths applies to children. --- source/blender/src/buttons_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 0cfc2047aec..9a749b6fbd9 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -4415,8 +4415,8 @@ static void object_panel_particle_visual(Object *ob) uiDefButS(block, NUM, B_PART_RECALC, "Steps:", butx,(buty+=buth),butw,buth, &part->draw_step, 0.0, 7.0, 0, 0, "How many steps paths are drawn with (power of 2)"); uiDefButS(block, NUM, B_PART_REDRAW, "Render:", butx,(buty-=buth),butw,buth, &part->ren_step, 0.0, 9.0, 0, 0, "How many steps paths are rendered with (power of 2)"); - uiDefButBitI(block, TOG, PART_ABS_LENGTH, B_PART_RECALC, "Abs Length", butx,(buty-=buth),butw,buth, &part->flag, 0, 0, 0, 0, "Use maximum length in absolute blender units"); - uiDefButF(block, NUM, B_PART_RECALC, "Max Length:", butx,(buty-=buth),butw,buth, &part->abslength, 0.0, 10000.0, 1, 3, "Absolute path length"); + uiDefButBitI(block, TOG, PART_ABS_LENGTH, B_PART_RECALC, "Abs Length", butx,(buty-=buth),butw,buth, &part->flag, 0, 0, 0, 0, "Use maximum length for children"); + uiDefButF(block, NUM, B_PART_RECALC, "Max Length:", butx,(buty-=buth),butw,buth, &part->abslength, 0.0, 10000.0, 1, 3, "Absolute maximum path length for children, in blender units"); uiDefButF(block, NUMSLI, B_PART_RECALC, "RLength:", butx,(buty-=buth),butw,buth, &part->randlength, 0.0, 1.0, 1, 3, "Give path length a random variation"); uiBlockEndAlign(block); -- cgit v1.2.3 From 529a8bb949412ac5cc7203fd583e4f0b28282ddf Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 May 2008 14:58:33 +0000 Subject: Fix for bug #10990: edge render AA issue. --- source/blender/render/intern/source/rendercore.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'source/blender') diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index a18a973979a..9357a060f62 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -849,7 +849,7 @@ static void convert_to_key_alpha(RenderPart *pa, float *rectf) } /* adds only alpha values */ -void edge_enhance_tile(RenderPart *pa, float *rectf) +void edge_enhance_tile(RenderPart *pa, float *rectf, int *rectz) { /* use zbuffer to define edges, add it to the image */ int y, x, col, *rz, *rz1, *rz2, *rz3; @@ -857,13 +857,13 @@ void edge_enhance_tile(RenderPart *pa, float *rectf) float *rf; /* shift values in zbuffer 4 to the right (anti overflows), for filter we need multiplying with 12 max */ - rz= pa->rectz; + rz= rectz; if(rz==NULL) return; for(y=0; yrecty; y++) for(x=0; xrectx; x++, rz++) (*rz)>>= 4; - rz1= pa->rectz; + rz1= rectz; rz2= rz1+pa->rectx; rz3= rz2+pa->rectx; @@ -903,7 +903,7 @@ void edge_enhance_tile(RenderPart *pa, float *rectf) } /* shift back zbuf values, we might need it still */ - rz= pa->rectz; + rz= rectz; for(y=0; yrecty; y++) for(x=0; xrectx; x++, rz++) (*rz)<<= 4; @@ -1012,7 +1012,7 @@ void make_pixelstructs(RenderPart *pa, ZSpan *zspan, int sample, void *data) if(sdata->rl->layflag & SCE_LAY_EDGE) if(R.r.mode & R_EDGE) - edge_enhance_tile(pa, sdata->edgerect); + edge_enhance_tile(pa, sdata->edgerect, zspan->rectz); } /* main call for shading Delta Accum, for OSA */ @@ -1189,7 +1189,7 @@ void zbufshade_tile(RenderPart *pa) if(rl->layflag & SCE_LAY_EDGE) { if(R.r.mode & R_EDGE) { edgerect= MEM_callocN(sizeof(float)*pa->rectx*pa->recty, "rectedge"); - edge_enhance_tile(pa, edgerect); + edge_enhance_tile(pa, edgerect, pa->rectz); } } -- cgit v1.2.3 From bda4e3d19f0861c6af633104ee56bba34961aaa4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 May 2008 15:38:40 +0000 Subject: * added support for exporting dupli objects * option to export modifier applied objects * option to export quads as tri's * added back compress option (will default to enabled if you use .x3dz as the extension) --- source/blender/blenkernel/intern/blender.c | 3 ++- source/blender/makesdna/DNA_userdef_types.h | 5 +++-- source/blender/src/space.c | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 230b7080b38..81f496e97d6 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -383,7 +383,8 @@ static void setup_app_data(BlendFileData *bfd, char *filename) /* special cases, override loaded flags: */ if (G.f & G_DEBUG) bfd->globalf |= G_DEBUG; else bfd->globalf &= ~G_DEBUG; - if (!(G.f & G_DOSCRIPTLINKS)) bfd->globalf &= ~G_DOSCRIPTLINKS; + + if ((U.flag & USER_DONT_DOSCRIPTLINKS)) bfd->globalf &= ~G_DOSCRIPTLINKS; G.f= bfd->globalf; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index c45571cb583..acc1651e9fa 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -224,7 +224,7 @@ extern UserDef U; /* from usiblender.c !!!! */ #define USER_DUPLILINK (1 << 6) #define USER_FSCOLLUM (1 << 7) #define USER_MAT_ON_OB (1 << 8) -#define USER_NO_CAPSLOCK (1 << 9) +/*#define USER_NO_CAPSLOCK (1 << 9)*/ /* not used anywhere */ #define USER_VIEWMOVE (1 << 10) #define USER_TOOLTIPS (1 << 11) #define USER_TWOBUTTONMOUSE (1 << 12) @@ -236,7 +236,8 @@ extern UserDef U; /* from usiblender.c !!!! */ #define USER_ADD_EDITMODE (1 << 18) #define USER_ADD_VIEWALIGNED (1 << 19) #define USER_RELPATHS (1 << 20) -#define USER_DRAGIMMEDIATE (1 << 21) +#define USER_DRAGIMMEDIATE (1 << 21) +#define USER_DONT_DOSCRIPTLINKS (1 << 22) /* viewzom */ #define USER_ZOOM_CONT 0 diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 292b1f1bc1e..e396e078739 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -4158,9 +4158,9 @@ void drawinfospace(ScrArea *sa, void *spacedata) (xpos+edgsp+(1*midsp)+(1*mpref)),y6label,mpref,buth, 0, 0, 0, 0, 0, ""); - uiDefButBitI(block, TOG, G_DOSCRIPTLINKS, REDRAWBUTSSCRIPT, "Enabled by Default", + uiDefButBitI(block, TOGN, USER_DONT_DOSCRIPTLINKS, REDRAWBUTSSCRIPT, "Enabled by Default", (xpos+edgsp+(1*mpref)+(1*midsp)),y5,mpref,buth, - &(G.f), 0, 0, 0, 0, "Allow any .blend file to run scripts automatically (unsafe with blend files from an untrusted source)"); + &(U.flag), 0, 0, 0, 0, "Allow any .blend file to run scripts automatically (unsafe with blend files from an untrusted source)"); uiDefBut(block, LABEL,0,"Keyboard:", (xpos+edgsp+(3*midsp)+(3*mpref)),y2label,mpref,buth, -- cgit v1.2.3 From ad5579ec92796d31d06f2d5287f2356efadb1788 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 May 2008 16:31:49 +0000 Subject: Fix for bug #9676: added warning that particles on multires are not supported on anything else than the first level. --- source/blender/blenkernel/intern/modifier.c | 9 +++++++++ source/blender/blenkernel/intern/particle.c | 7 +++++++ 2 files changed, 16 insertions(+) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index ca95d9edc06..2a8ba878c41 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -5515,6 +5515,7 @@ static void particleSystemModifier_deformVerts( DerivedMesh *dm = derivedData; ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; ParticleSystem * psys=0; + Mesh *me; int needsFree=0; if(ob->particlesystem.first) @@ -5522,6 +5523,14 @@ static void particleSystemModifier_deformVerts( else return; + /* multires check */ + if(ob->type == OB_MESH) { + me= (Mesh*)ob->data; + if(me->mr && me->mr->current != 1) + modifier_setError(md, + "Particles only supported on first multires level."); + } + if(!psys_check_enabled(ob, psys)) return; diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 1eb47fa3da0..2aa0d0ad0b8 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -250,10 +250,17 @@ int psys_in_edit_mode(ParticleSystem *psys) int psys_check_enabled(Object *ob, ParticleSystem *psys) { ParticleSystemModifierData *psmd; + Mesh *me; if(psys->flag & PSYS_DISABLED) return 0; + if(ob->type == OB_MESH) { + me= (Mesh*)ob->data; + if(me->mr && me->mr->current != 1) + return 0; + } + psmd= psys_get_modifier(ob, psys); if(psys->renderdata) { if(!(psmd->modifier.mode & eModifierMode_Render)) -- cgit v1.2.3 From 5da47ddd02352a0860be5899c3d03734e44d0151 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 May 2008 18:33:10 +0000 Subject: fps timer was starting off at 0 fps --- source/blender/src/drawview.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 1acb7c4373f..be009536022 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -3421,7 +3421,7 @@ static void draw_viewport_fps(ScrArea *sa) char printable[16]; int i, tot; - if (lredrawtime == redrawtime) + if (!lredrawtime || !redrawtime) return; printable[0] = '\0'; @@ -3569,7 +3569,7 @@ void inner_play_anim_loop(int init, int mode) last_cfra = -1; cached = cached_dynamics(PSFRA,PEFRA); - redrawtime = 1.0/FPS; + redrawtime = 0.0; redrawtime_index = REDRAW_FRAME_AVERAGE; while(redrawtime_index--) { -- cgit v1.2.3 From 1584d6a0069758d8b594b0e2c412677ab5a8f22f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 May 2008 19:25:43 +0000 Subject: Possible fix for #9691: blender failing to allocate memory when rendering particles on windows, now allocates smaller chunks of memory. --- source/blender/blenkernel/intern/particle.c | 85 +++++++++++++++++----------- source/blender/blenloader/intern/readfile.c | 2 + source/blender/makesdna/DNA_particle_types.h | 22 +++---- 3 files changed, 66 insertions(+), 43 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 2aa0d0ad0b8..fec3da752ff 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -152,6 +152,49 @@ char *psys_menu_string(Object *ob, int for_sb) return str; } + +/* we allocate path cache memory in chunks instead of a big continguous + * chunk, windows' memory allocater fails to find big blocks of memory often */ + +#define PATH_CACHE_BUF_SIZE 1024 + +static ParticleCacheKey **psys_alloc_path_cache_buffers(ListBase *bufs, int tot, int steps) +{ + LinkData *buf; + ParticleCacheKey **cache; + int i, totkey, totbufkey; + + tot= MAX2(tot, 1); + totkey = 0; + cache = MEM_callocN(tot*sizeof(void*), "PathCacheArray"); + + while(totkey < tot) { + totbufkey= MIN2(tot-totkey, PATH_CACHE_BUF_SIZE); + buf= MEM_callocN(sizeof(LinkData), "PathCacheLinkData"); + buf->data= MEM_callocN(sizeof(ParticleCacheKey)*totbufkey*steps, "ParticleCacheKey"); + + for(i=0; idata) + i*steps; + + totkey += totbufkey; + BLI_addtail(bufs, buf); + } + + return cache; +} + +static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *bufs) +{ + LinkData *buf; + + if(cache) + MEM_freeN(cache); + + for(buf= bufs->first; buf; buf=buf->next) + MEM_freeN(buf->data); + BLI_freelistN(bufs); +} + /************************************************/ /* Getting stuff */ /************************************************/ @@ -306,27 +349,16 @@ void free_keyed_keys(ParticleSystem *psys) } void free_child_path_cache(ParticleSystem *psys) { - if(psys->childcache){ - if(psys->childcache[0]) - MEM_freeN(psys->childcache[0]); - - MEM_freeN(psys->childcache); - - psys->childcache = NULL; - psys->totchildcache = 0; - } + psys_free_path_cache_buffers(psys->childcache, &psys->childcachebufs); + psys->childcache = NULL; + psys->totchildcache = 0; } void psys_free_path_cache(ParticleSystem *psys) { - if(psys->pathcache){ - if(psys->pathcache[0]) - MEM_freeN(psys->pathcache[0]); - - MEM_freeN(psys->pathcache); + psys_free_path_cache_buffers(psys->pathcache, &psys->pathcachebufs); + psys->pathcache= NULL; + psys->totcached= 0; - psys->pathcache = NULL; - psys->totcached = 0; - } free_child_path_cache(psys); } void psys_free_children(ParticleSystem *psys) @@ -2257,10 +2289,9 @@ void psys_cache_child_paths(Object *ob, ParticleSystem *psys, float cfra, int ed ParticleSettings *part = psys->part; ParticleThread *pthreads; ParticleThreadContext *ctx; - ParticleCacheKey **cache, *tcache; + ParticleCacheKey **cache; ListBase threads; int i, totchild, totparent, totthread; - unsigned long totchildstep; pthreads= psys_threads_create(ob, psys); @@ -2279,13 +2310,7 @@ void psys_cache_child_paths(Object *ob, ParticleSystem *psys, float cfra, int ed else { /* clear out old and create new empty path cache */ free_child_path_cache(psys); - - cache = psys->childcache = MEM_callocN(totchild*sizeof(void *), "Child path cache array"); - totchildstep= totchild*(ctx->steps + 1); - tcache = MEM_callocN(totchildstep*sizeof(ParticleCacheKey), "Child path cache"); - for(i=0; isteps + 1); - + psys->childcache= psys_alloc_path_cache_buffers(&psys->childcachebufs, totchild, ctx->steps+1); psys->totchildcache = totchild; } @@ -2372,12 +2397,8 @@ void psys_cache_paths(Object *ob, ParticleSystem *psys, float cfra, int editupda else { /* clear out old and create new empty path cache */ psys_free_path_cache(psys); - - /* allocate cache array for fast access and set pointers to contiguous mem block */ - cache = psys->pathcache = MEM_callocN(MAX2(1, totpart) * sizeof(void *), "Path cache array"); - cache[0] = MEM_callocN(totpart * (steps + 1) * sizeof(ParticleCacheKey), "Path cache"); - for(i=1; ipathcachebufs, totpart, steps+1); + psys->pathcache= cache; } if(edit==NULL && psys->soft && psys->softflag & OB_SB_ENABLE) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 24606bd822f..8d315ba37e1 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2615,6 +2615,8 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles) psys->edit = 0; psys->pathcache = 0; psys->childcache = 0; + psys->pathcachebufs.first = psys->pathcachebufs.last = 0; + psys->childcachebufs.first = psys->childcachebufs.last = 0; psys->reactevents.first = psys->reactevents.last = 0; psys->pointcache= newdataadr(fd, psys->pointcache); diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 8122cdd9cc7..e5f781a3365 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -171,24 +171,24 @@ typedef struct ParticleSettings { typedef struct ParticleSystem{ struct ParticleSystem *next, *prev; - ParticleSettings *part; + ParticleSettings *part; /* particle settings */ - ParticleData *particles; + ParticleData *particles; /* (parent) particles */ + ChildParticle *child; /* child particles */ - ChildParticle *child; + struct ParticleEdit *edit; /* particle editmode (runtime) */ - struct ParticleEdit *edit; + struct ParticleCacheKey **pathcache; /* path cache (runtime) */ + struct ParticleCacheKey **childcache; /* child cache (runtime) */ + ListBase pathcachebufs, childcachebufs; /* buffers for the above */ - struct ParticleCacheKey **pathcache; - struct ParticleCacheKey **childcache; - - struct SoftBody *soft; + struct SoftBody *soft; /* hair softbody */ struct Object *target_ob; struct Object *keyed_ob; struct Object *lattice; - struct ListBase effectors, reactevents; + struct ListBase effectors, reactevents; /* runtime */ float imat[4][4]; /* used for duplicators */ float cfra; @@ -196,10 +196,10 @@ typedef struct ParticleSystem{ int flag, totpart, totchild, totcached, totchildcache, rt; short recalc, target_psys, keyed_psys, totkeyed, softflag, bakespace; - char bb_uvname[3][32]; + char bb_uvname[3][32]; /* billboard uv name */ /* if you change these remember to update array lengths to PSYS_TOT_VG! */ - short vgroup[11], vg_neg, rt3[2]; + short vgroup[11], vg_neg, rt3[2]; /* vertex groups */ /* temporary storage during render */ void *renderdata; -- cgit v1.2.3 From 3527c100652f029db7a0e5af27a16456ff5ae1df Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 7 May 2008 20:24:06 +0000 Subject: Fix for bug #10932: area light bug, points behind the lamp could also get lit. --- source/blender/render/intern/source/shadeoutput.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 9f14db2f425..0928042729a 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -477,8 +477,12 @@ static float area_lamp_energy_multisample(LampRen *lar, float *co, float *vn) float *jitlamp= lar->jitter, vec[3]; float area[4][3], intens= 0.0f; int a= lar->ray_totsamp; - - + + /* test if co is behind lamp */ + VECSUB(vec, co, lar->co); + if(INPR(vec, lar->vec) < 0.0f) + return 0.0f; + while(a--) { vec[0]= jitlamp[0]; vec[1]= jitlamp[1]; -- cgit v1.2.3 From 48f6c5b05feecb516a6bc4374fb75de709c626c4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 7 May 2008 20:34:34 +0000 Subject: was missing depgraph update for centering objects in editmode if they were unselected. ctrl+num keys for switching subsurf didnt work in editmode if the object wasnt selected. changed this to only operate on the editmode object. also disallow ctrl+num to change layers for values above 4. --- source/blender/src/editobject.c | 27 ++++++++++++++++++++------- source/blender/src/space.c | 33 +++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 15 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index cdc38ab1d2c..4029e031b63 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -1887,6 +1887,7 @@ void docenter(int centermode) recalc_editnormals(); tot_change++; + DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); } } @@ -3133,9 +3134,15 @@ void flip_subdivison(int level) mode= eModifierMode_Render|eModifierMode_Realtime; if(level == -1) { - for(base= G.scene->base.first; base; base= base->next) - if(((level==-1) && (TESTBASE(base))) || (TESTBASELIB(base))) - object_has_subdivision_particles(base->object, &havesubdiv, &havepart, 0); + if (G.obedit) { + object_has_subdivision_particles(G.obedit, &havesubdiv, &havepart, 0); + } else { + for(base= G.scene->base.first; base; base= base->next) { + if(((level==-1) && (TESTBASE(base))) || (TESTBASELIB(base))) { + object_has_subdivision_particles(base->object, &havesubdiv, &havepart, 0); + } + } + } } else havesubdiv= 1; @@ -3149,10 +3156,16 @@ void flip_subdivison(int level) } else if(havepart) particles= 1; - - for(base= G.scene->base.first; base; base= base->next) - if(((level==-1) && (TESTBASE(base))) || (TESTBASELIB(base))) - object_flip_subdivison_particles(base->object, &set, level, mode, particles, 0); + + if (G.obedit) { + object_flip_subdivison_particles(G.obedit, &set, level, mode, particles, 0); + } else { + for(base= G.scene->base.first; base; base= base->next) { + if(((level==-1) && (TESTBASE(base))) || (TESTBASELIB(base))) { + object_flip_subdivison_particles(base->object, &set, level, mode, particles, 0); + } + } + } countall(); allqueue(REDRAWVIEW3D, 0); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index e396e078739..63836101d49 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -1745,25 +1745,42 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) if ( (G.obedit) && (G.obedit->type==OB_MESH) ) select_faces_by_numverts(5); } + + else if(G.qual==LR_CTRLKEY) {} else do_layer_buttons(4); break; case SIXKEY: - do_layer_buttons(5); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(5); + break; case SEVENKEY: - do_layer_buttons(6); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(6); + break; case EIGHTKEY: - do_layer_buttons(7); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(7); + break; case NINEKEY: - do_layer_buttons(8); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(8); + break; case ZEROKEY: - do_layer_buttons(9); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(9); + break; case MINUSKEY: - do_layer_buttons(10); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(10); + break; case EQUALKEY: - do_layer_buttons(11); break; + if(G.qual==LR_CTRLKEY) {} + else do_layer_buttons(11); + break; case ACCENTGRAVEKEY: - do_layer_buttons(-1); break; + do_layer_buttons(-1); + break; case SPACEKEY: if(G.qual == LR_CTRLKEY) { -- cgit v1.2.3 From 1c7c37deb73fb2997d4f9542f5cc02ea2058eee6 Mon Sep 17 00:00:00 2001 From: Stephen Swaney Date: Wed, 7 May 2008 21:21:15 +0000 Subject: modify script to use long opts; --name vs -n, for example. This makes epy_docgen.sh compatible with epy_docgen-3.sh. I am not sure why we would need both scripts. Perhaps someone with epdoc version 3 can test. --- source/blender/python/api2_2x/doc/epy_docgen.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/doc/epy_docgen.sh b/source/blender/python/api2_2x/doc/epy_docgen.sh index d709ee73190..d4f4463372f 100644 --- a/source/blender/python/api2_2x/doc/epy_docgen.sh +++ b/source/blender/python/api2_2x/doc/epy_docgen.sh @@ -7,6 +7,6 @@ # set posix locale so regex works properly for [A-Z]*.py LC_ALL=POSIX -epydoc -o BPY_API --url "http://www.blender.org" -t API_intro.py \ - -n "Blender" --no-private --no-frames \ +epydoc -o BPY_API --url "http://www.blender.org" --top API_intro.py \ + --name "Blender" --no-private --no-frames \ $( ls [A-Z]*.py ) -- cgit v1.2.3 From 2a8caaa6a0829826b21e83f3ec4734ffb8aa1af9 Mon Sep 17 00:00:00 2001 From: Martin Poirier Date: Wed, 7 May 2008 22:26:47 +0000 Subject: [#10996] Wrong tooltip in "Fields" panel Also fixed typo and insuficiant length of label Longitudinal --- source/blender/src/buttons_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/blender') diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index 9a749b6fbd9..c71caa082e7 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -3422,9 +3422,9 @@ static void object_panel_fields(Object *ob) uiBlockEndAlign(block); } else{ - uiDefButS(block, MENU, B_FIELD_DEP, "Fall-off%t|Cone%x2|Tube%x1|Sphere%x0", 160,180,140,20, &pd->falloff, 0.0, 0.0, 0, 0, tipstr); + uiDefButS(block, MENU, B_FIELD_DEP, "Fall-off%t|Cone%x2|Tube%x1|Sphere%x0", 160,180,140,20, &pd->falloff, 0.0, 0.0, 0, 0, "Fall-off shape"); if(pd->falloff==PFIELD_FALL_TUBE) - uiDefBut(block, LABEL, 0, "Lognitudinal", 160,160,70,20, NULL, 0.0, 0, 0, 0, ""); + uiDefBut(block, LABEL, 0, "Longitudinal", 160,160,140,20, NULL, 0.0, 0, 0, 0, ""); uiBlockBeginAlign(block); uiDefButBitS(block, TOG, PFIELD_POSZ, B_FIELD_CHANGE, "Pos", 160,140,40,20, &pd->flag, 0.0, 0, 0, 0, "Effect only in direction of positive Z axis"); uiDefButF(block, NUM, B_FIELD_CHANGE, "Fall-off: ", 200,140,100,20, &pd->f_power, 0, 10, 10, 0, "Falloff power (real gravitational falloff = 2)"); -- cgit v1.2.3 From 12715ec0fac8f704d55fe9b0e60abc2ba40f76b2 Mon Sep 17 00:00:00 2001 From: Stephen Swaney Date: Wed, 7 May 2008 22:46:20 +0000 Subject: more shell script tweaking. Thanks to gsrb3d for hints. --- source/blender/python/api2_2x/doc/epy_docgen.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/doc/epy_docgen.sh b/source/blender/python/api2_2x/doc/epy_docgen.sh index d4f4463372f..8cbebf82f8d 100644 --- a/source/blender/python/api2_2x/doc/epy_docgen.sh +++ b/source/blender/python/api2_2x/doc/epy_docgen.sh @@ -7,6 +7,5 @@ # set posix locale so regex works properly for [A-Z]*.py LC_ALL=POSIX -epydoc -o BPY_API --url "http://www.blender.org" --top API_intro.py \ - --name "Blender" --no-private --no-frames \ -$( ls [A-Z]*.py ) +epydoc -v -o BPY_API --url "http://www.blender.org" --top API_intro \ + --name "Blender" --no-private --no-frames [A-Z]*.py -- cgit v1.2.3 From 18b20396bc4563ba5e2b14fb232960211861a236 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 May 2008 07:33:20 +0000 Subject: this script isnt needed anymore thanks to stivs and gsr --- source/blender/python/api2_2x/doc/epy_docgen-3.sh | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 source/blender/python/api2_2x/doc/epy_docgen-3.sh (limited to 'source/blender') diff --git a/source/blender/python/api2_2x/doc/epy_docgen-3.sh b/source/blender/python/api2_2x/doc/epy_docgen-3.sh deleted file mode 100644 index ce2bdfef0f8..00000000000 --- a/source/blender/python/api2_2x/doc/epy_docgen-3.sh +++ /dev/null @@ -1,12 +0,0 @@ -# epy_docgen.sh -# generates blender python doc using epydoc -# requires epydoc in your PATH. -# run from the doc directory containing the .py files -# usage: sh epy_docgen.sh - -# set posix locale so regex works properly for [A-Z]*.py -LC_ALL=POSIX - -epydoc -v -o BPY_API --url "http://www.blender.org" --top API_intro \ - --name "Blender" --no-private --no-frames \ -$( ls [A-Z]*.py ) -- cgit v1.2.3 From 205d06f5f4505a2ce0211869a36501fc19877666 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 8 May 2008 08:41:56 +0000 Subject: Fix for bug #11002: particle ipo clump did not allow negative values like the button in the user interface. --- source/blender/blenkernel/intern/ipo.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 0b9f7615bfa..321d4f1d37e 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1917,6 +1917,9 @@ void set_icu_vars(IpoCurve *icu) icu->ymin= 0.0; break; case PART_CLUMP: + icu->ymin= -1.0; + icu->ymax= 1.0; + break; case PART_DRAG: case PART_DAMP: case PART_LENGTH: @@ -1926,6 +1929,7 @@ void set_icu_vars(IpoCurve *icu) case PART_KINK_SHAPE: icu->ymin= -0.999; icu->ymax= 0.999; + break; } } else if(icu->blocktype==ID_CO) { -- cgit v1.2.3 From e71a6bd79ea1982dbed05468cc98def7093e9228 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 8 May 2008 08:59:36 +0000 Subject: NLA - Bugfix: Scale and Repeat fields in NLA Transform Properties panel will now ignore negative values instead of clamping them to a near-zero value, which can easily be confused with the strip being 'destroyed'. This shouldn't affect other interface elements, as this change has only been used here. (Note: negative scaling should be avoided) --- source/blender/include/BIF_interface.h | 1 + source/blender/src/drawnla.c | 6 +++--- source/blender/src/interface.c | 35 ++++++++++++++++++++++------------ source/blender/src/interface_draw.c | 8 +++++++- 4 files changed, 34 insertions(+), 16 deletions(-) (limited to 'source/blender') diff --git a/source/blender/include/BIF_interface.h b/source/blender/include/BIF_interface.h index 24747b9f220..fbd4e4ecd91 100644 --- a/source/blender/include/BIF_interface.h +++ b/source/blender/include/BIF_interface.h @@ -164,6 +164,7 @@ struct AutoComplete; #define BUT_TOGDUAL (33<<9) #define ICONTOGN (34<<9) #define FTPREVIEW (35<<9) +#define NUMABS (36<<9) #define BUTTYPE (63<<9) diff --git a/source/blender/src/drawnla.c b/source/blender/src/drawnla.c index c0cd11d27a1..083d10fd484 100644 --- a/source/blender/src/drawnla.c +++ b/source/blender/src/drawnla.c @@ -638,14 +638,14 @@ static void nla_panel_properties(short cntrl) // NLA_HANDLER_PROPERTIES uiBlockBeginAlign(block); // FIXME: repeat and scale are too cramped! - uiDefButF(block, NUM, B_NLA_SCALE, "Repeat:", 160,100,75,19, &strip->repeat, 0.001, 1000.0f, 100, 0, "Number of times the action should repeat"); + uiDefButF(block, NUMABS, B_NLA_SCALE, "Repeat:", 160,100,75,19, &strip->repeat, 0.001, 1000.0f, 100, 0, "Number of times the action should repeat"); if ((strip->actend - strip->actstart) < 1.0f) { uiBlockSetCol(block, TH_REDALERT); - uiDefButF(block, NUM, B_NLA_SCALE, "Scale:", 235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Please run Alt-S to fix up this error"); + uiDefButF(block, NUMABS, B_NLA_SCALE, "Scale:", 235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Please run Alt-S to fix up this error"); uiBlockSetCol(block, TH_AUTO); } else - uiDefButF(block, NUM, B_NLA_SCALE, "Scale:", 235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Amount the action should be scaled by"); + uiDefButF(block, NUMABS, B_NLA_SCALE, "Scale:", 235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Amount the action should be scaled by"); but= uiDefButC(block, TEX, B_NLA_PANEL, "OffsBone:", 160,80,150,19, strip->offs_bone, 0, 31.0f, 0, 0, "Name of Bone that defines offset for repeat"); uiButSetCompleteFunc(but, autocomplete_bone, (void *)ob); uiDefButBitS(block, TOG, ACTSTRIP_HOLDLASTFRAME, B_NLA_PANEL, "Hold", 160,60,75,19, &strip->flag, 0, 0, 0, 0, "Toggles whether to continue displaying the last frame past the end of the strip"); diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index f324bf3b053..7af6b67bfa3 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -472,7 +472,7 @@ static int ui_but_copy_paste(uiBut *but, char mode) if(mode=='v' && but->lock) return 0; poin= but->poin; - if ELEM3(but->type, NUM, NUMSLI, HSVSLI) { + if ELEM4(but->type, NUM, NUMABS, NUMSLI, HSVSLI) { if(poin==NULL); else if(mode=='c') { @@ -2100,7 +2100,8 @@ static int ui_act_as_text_but(uiBut *but) } if(but->pointype!=FLO) value= (int)value; - + + if(but->type==NUMABS) value= fabs(value); if(valuemax) value= max; @@ -3934,6 +3935,7 @@ static int ui_do_button(uiBlock *block, uiBut *but, uiEvent *uevent) break; case NUM: + case NUMABS: if(uevent->val) retval= ui_do_but_NUM(but); break; @@ -4253,13 +4255,13 @@ static void ui_but_next_edittext(uiBlock *block) but->flag &= ~(UI_ACTIVE|UI_SELECT); for(but= actbut->next; but; but= but->next) { - if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) { + if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) { but->flag |= UI_ACTIVE; return; } } for(but= block->buttons.first; but!=actbut; but= but->next) { - if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) { + if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) { but->flag |= UI_ACTIVE; return; } @@ -4282,13 +4284,13 @@ static void ui_but_prev_edittext(uiBlock *block) but->flag &= ~(UI_ACTIVE|UI_SELECT); for(but= actbut->prev; but; but= but->prev) { - if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) { + if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) { but->flag |= UI_ACTIVE; return; } } for(but= block->buttons.last; but!=actbut; but= but->prev) { - if(ELEM4(but->type, TEX, NUM, NUMSLI, HSVSLI)) { + if(ELEM5(but->type, TEX, NUM, NUMABS, NUMSLI, HSVSLI)) { but->flag |= UI_ACTIVE; return; } @@ -4643,7 +4645,7 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent, int movemouse_quit) //Really nasty... to update the num button from the same butblock for(bt= block->buttons.first; bt; bt= bt->next) { - if(bt->type == NUM) { + if(ELEM(bt->type, NUM, NUMABS)) { ui_check_but(bt); ui_draw_but(bt); } @@ -4669,7 +4671,7 @@ static int ui_do_block(uiBlock *block, uiEvent *uevent, int movemouse_quit) for(bt= block->buttons.first; bt; bt= bt->next) { - if(bt->type == NUM) { + if(ELEM(bt->type, NUM, NUMABS)) { ui_check_but(bt); ui_draw_but(bt); } @@ -5442,8 +5444,15 @@ void ui_check_but(uiBut *but) case HSVSLI: value= ui_get_but_val(but); if(value < but->min) value= but->min; - if(value > but->max) value= but->max; - ui_set_but_val(but, value); + if(value > but->max) value= but->max; + ui_set_but_val(but, value); + break; + + case NUMABS: + value= fabs( ui_get_but_val(but) ); + if(value < but->min) value= but->min; + if(value > but->max) value= but->max; + ui_set_but_val(but, value); break; case ICONTOG: @@ -5485,6 +5494,7 @@ void ui_check_but(uiBut *but) case NUM: case NUMSLI: case HSVSLI: + case NUMABS: value= ui_get_but_val(but); @@ -5574,7 +5584,7 @@ void ui_check_but(uiBut *but) but->ofs= 0; while(but->strwidth > (int)okwidth ) { - if ELEM(but->type, NUM, TEX) { // only these cut off left + if ELEM3(but->type, NUM, NUMABS, TEX) { // only these cut off left but->ofs++; but->strwidth= but->aspect*BIF_GetStringWidth(but->font, but->drawstr+but->ofs, transopts); @@ -5618,6 +5628,7 @@ static int ui_auto_themecol(uiBut *but) case SLI: case NUM: case NUMSLI: + case NUMABS: case HSVSLI: return TH_BUT_NUM; case TEX: @@ -5894,7 +5905,7 @@ static uiBut *ui_def_but(uiBlock *block, int type, int retval, char *str, short but->pos= -1; /* cursor invisible */ - if(but->type==NUM) { /* add a space to name */ + if(ELEM(but->type, NUM, NUMABS)) { /* add a space to name */ slen= strlen(but->str); if(slen>0 && slenstr[slen-1]!=' ') { diff --git a/source/blender/src/interface_draw.c b/source/blender/src/interface_draw.c index 83a3c12bae7..83f1221b1fb 100644 --- a/source/blender/src/interface_draw.c +++ b/source/blender/src/interface_draw.c @@ -846,6 +846,7 @@ static void ui_default_flat(int type, int colorid, float asp, float x1, float y1 /* *** EXTRA DRAWING FOR SPECIFIC CONTROL TYPES *** */ switch(type) { case NUM: + case NUMABS: /* SIDE ARROWS */ /* left */ if(flag & UI_SELECT) { @@ -872,11 +873,12 @@ static void ui_default_slider(int colorid, float fac, float aspect, float x1, fl if(flag & UI_SELECT) BIF_ThemeColorShade(TH_BUT_NUM, -5); - else + else { if(flag & UI_ACTIVE) BIF_ThemeColorShade(TH_BUT_NUM, +35); else BIF_ThemeColorShade(TH_BUT_NUM, +25); + } glRectf(x1, ymid-yc, x2, ymid+yc); @@ -943,6 +945,7 @@ static void ui_draw_default(int type, int colorid, float aspect, float x1, float case TEX: case IDPOIN: case NUM: + case NUMABS: ui_default_flat(type, colorid, aspect, x1, y1, x2, y2, flag); break; case ICONROW: @@ -1026,6 +1029,7 @@ static void ui_draw_oldskool(int type, int colorid, float asp, float x1, float y /* special type decorations */ switch(type) { case NUM: + case NUMABS: if(flag & UI_SELECT) BIF_ThemeColorShade(colorid, -60); else BIF_ThemeColorShade(colorid, -30); ui_default_num_arrows(x1, y1, x2, y2); @@ -1176,6 +1180,7 @@ static void ui_draw_round(int type, int colorid, float asp, float x1, float y1, /* special type decorations */ switch(type) { case NUM: + case NUMABS: BIF_ThemeColorShade(colorid, curshade-60); ui_default_num_arrows(x1, y1, x2, y2); break; @@ -1285,6 +1290,7 @@ static void ui_draw_minimal(int type, int colorid, float asp, float x1, float y1 /* special type decorations */ switch(type) { case NUM: + case NUMABS: if(flag & UI_SELECT) BIF_ThemeColorShade(colorid, -60); else BIF_ThemeColorShade(colorid, -30); ui_default_num_arrows(x1, y1, x2, y2); -- cgit v1.2.3 From 8fdc367e0d0f7edc341af7a1de4302bf46a051fd Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 May 2008 16:33:55 +0000 Subject: 2.46 todo item, added back seam marking tools from UV-face mode. Since these conflict with loop select its now an option from the mesh tools panel. also made it possible to alt+rmb and alt+shift+rmb to mark other edge flags (creases, bevel weights, sharp edges) --- source/blender/include/BDR_editface.h | 5 +- source/blender/makesdna/DNA_scene_types.h | 11 +- source/blender/src/buttons_editing.c | 4 + source/blender/src/editface.c | 205 +++++++++++++++--------------- source/blender/src/editmesh_mods.c | 118 +++++++++++++---- 5 files changed, 214 insertions(+), 129 deletions(-) (limited to 'source/blender') diff --git a/source/blender/include/BDR_editface.h b/source/blender/include/BDR_editface.h index fb6b65c3972..58b344981ca 100644 --- a/source/blender/include/BDR_editface.h +++ b/source/blender/include/BDR_editface.h @@ -32,6 +32,7 @@ struct MTFace; struct EditFace; +struct EditEdge; struct Mesh; struct MCol; @@ -53,6 +54,8 @@ void uv_autocalc_tface(void); void set_texturepaint(void); void get_same_uv(void); void seam_mark_clear_tface(short mode); - +int edgetag_shortest_path(struct EditEdge *source, struct EditEdge *target); +void edgetag_context_set(struct EditEdge *eed, int val); +int edgetag_context_check(struct EditEdge *eed); #endif /* BDR_EDITFACE_H */ diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index e0e8c351d2c..45833695ffe 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -437,7 +437,9 @@ typedef struct ToolSettings { char skgen_postpro_passes; char skgen_subdivisions[3]; - char pad3[5]; + /* Alt+RMB option */ + char edge_mode; + char pad3[4]; } ToolSettings; /* Used by all brushes to store their properties, which can be directly set @@ -783,6 +785,13 @@ typedef struct Scene { #define UVCALC_FILLHOLES 1 #define UVCALC_NO_ASPECT_CORRECT 2 /* would call this UVCALC_ASPECT_CORRECT, except it should be default with old file */ +/* toolsettings->edge_mode */ +#define EDGE_MODE_SELECT 0 +#define EDGE_MODE_TAG_SEAM 1 +#define EDGE_MODE_TAG_SHARP 2 +#define EDGE_MODE_TAG_CREASE 3 +#define EDGE_MODE_TAG_BEVEL 4 + /* toolsettings->particle flag */ #define PE_KEEP_LENGTHS 1 #define PE_LOCK_FIRST 2 diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c index b02e89233e5..94a715162a0 100644 --- a/source/blender/src/buttons_editing.c +++ b/source/blender/src/buttons_editing.c @@ -5070,6 +5070,10 @@ static void editing_panel_mesh_tools1(Object *ob, Mesh *me) uiBlockEndAlign(block); + uiDefButBitS(block, TOG, B_MESH_X_MIRROR, B_DIFF, "X-axis mirror",1125,0,150,19, &G.scene->toolsettings->editbutflag, 0, 0, 0, 0, "While using transforms, mirrors the transformation"); + + uiDefButC(block, MENU, REDRAWBUTSEDIT, "Edge Alt-Select Mode%t|Loop Select%x0|Tag Edges (Seam)%x1|Tag Edges (Sharp)%x2|Tag Edges (Sharp)%x3|Tag Edges (Bevel)%x4",1125,88,150,19, &G.scene->toolsettings->edge_mode, 0, 0, 0, 0, "Operation to use when Alt+RMB on edges, Use Alt+Shift+RMB to tag the shortest path from the active edge"); + uiBlockBeginAlign(block); uiDefButBitI(block, TOG, G_ALLEDGES, 0, "All Edges", 1125, 22,150,19, &G.f, 0, 0, 0, 0, "Displays all edges in object mode without optimization"); uiDefButBitS(block, TOG, B_MESH_X_MIRROR, B_DIFF, "X-axis mirror",1125,0,150,19, &G.scene->toolsettings->editbutflag, 0, 0, 0, 0, "While using transforms, mirrors the transformation"); diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c index c1665332be8..e74401cb622 100644 --- a/source/blender/src/editface.c +++ b/source/blender/src/editface.c @@ -870,14 +870,14 @@ int minmax_tface(float *min, float *max) return ok; } -#define ME_SEAM_DONE ME_SEAM_LAST /* reuse this flag */ +#define ME_SEAM_DONE 2 /* reuse this flag */ -static float seam_cut_cost(Mesh *me, int e1, int e2, int vert) +static float edgetag_cut_cost(EditMesh *em, int e1, int e2, int vert) { - MVert *v = me->mvert + vert; - MEdge *med1 = me->medge + e1, *med2 = me->medge + e2; - MVert *v1 = me->mvert + ((med1->v1 == vert)? med1->v2: med1->v1); - MVert *v2 = me->mvert + ((med2->v1 == vert)? med2->v2: med2->v1); + EditVert *v = EM_get_vert_for_index(vert); + EditEdge *eed1 = EM_get_edge_for_index(e1), *eed2 = EM_get_edge_for_index(e2); + EditVert *v1 = EM_get_vert_for_index( (eed1->v1->tmp.l == vert)? eed1->v2->tmp.l: eed1->v1->tmp.l ); + EditVert *v2 = EM_get_vert_for_index( (eed2->v1->tmp.l == vert)? eed2->v2->tmp.l: eed2->v1->tmp.l ); float cost, d1[3], d2[3]; cost = VecLenf(v1->co, v->co); @@ -891,19 +891,19 @@ static float seam_cut_cost(Mesh *me, int e1, int e2, int vert) return cost; } -static void seam_add_adjacent(Mesh *me, Heap *heap, int mednum, int vertnum, int *nedges, int *edges, int *prevedge, float *cost) +static void edgetag_add_adjacent(EditMesh *em, Heap *heap, int mednum, int vertnum, int *nedges, int *edges, int *prevedge, float *cost) { int startadj, endadj = nedges[vertnum+1]; for (startadj = nedges[vertnum]; startadj < endadj; startadj++) { int adjnum = edges[startadj]; - MEdge *medadj = me->medge + adjnum; + EditEdge *eedadj = EM_get_edge_for_index(adjnum); float newcost; - if (medadj->flag & ME_SEAM_DONE) + if (eedadj->f2 & ME_SEAM_DONE) continue; - newcost = cost[mednum] + seam_cut_cost(me, mednum, adjnum, vertnum); + newcost = cost[mednum] + edgetag_cut_cost(em, mednum, adjnum, vertnum); if (cost[adjnum] > newcost) { cost[adjnum] = newcost; @@ -913,59 +913,93 @@ static void seam_add_adjacent(Mesh *me, Heap *heap, int mednum, int vertnum, int } } -static int seam_shortest_path(Mesh *me, int source, int target) +void edgetag_context_set(EditEdge *eed, int val) { + switch (G.scene->toolsettings->edge_mode) { + case EDGE_MODE_TAG_SEAM: + if (val) {eed->seam = 255;} + else {eed->seam = 0;} + break; + case EDGE_MODE_TAG_SHARP: + if (val) {eed->sharp = 1;} + else {eed->sharp = 0;} + break; + case EDGE_MODE_TAG_CREASE: + if (val) {eed->crease = 1.0f;} + else {eed->crease = 0.0f;} + break; + case EDGE_MODE_TAG_BEVEL: + if (val) {eed->bweight = 1.0f;} + else {eed->bweight = 0.0f;} + break; + } +} + +int edgetag_context_check(EditEdge *eed) +{ + switch (G.scene->toolsettings->edge_mode) { + case EDGE_MODE_TAG_SEAM: + return eed->seam ? 1 : 0; + case EDGE_MODE_TAG_SHARP: + return eed->sharp ? 1 : 0; + case EDGE_MODE_TAG_CREASE: + return eed->crease ? 1 : 0; + case EDGE_MODE_TAG_BEVEL: + return eed->bweight ? 1 : 0; + } + return 0; +} + + +int edgetag_shortest_path(EditEdge *source, EditEdge *target) +{ + EditMesh *em = G.editMesh; + EditEdge *eed; + EditVert *ev; + Heap *heap; EdgeHash *ehash; float *cost; - MEdge *med; - int a, *nedges, *edges, *prevedge, mednum = -1, nedgeswap = 0; - MFace *mf; + int a, totvert=0, totedge=0, *nedges, *edges, *prevedge, mednum = -1, nedgeswap = 0; - /* mark hidden edges as done, so we don't use them */ - ehash = BLI_edgehash_new(); - for (a=0, mf=me->mface; atotface; a++, mf++) { - if (!(mf->flag & ME_HIDE)) { - BLI_edgehash_insert(ehash, mf->v1, mf->v2, NULL); - BLI_edgehash_insert(ehash, mf->v2, mf->v3, NULL); - if (mf->v4) { - BLI_edgehash_insert(ehash, mf->v3, mf->v4, NULL); - BLI_edgehash_insert(ehash, mf->v4, mf->v1, NULL); - } - else - BLI_edgehash_insert(ehash, mf->v3, mf->v1, NULL); - } + /* we need the vert */ + for (ev= em->verts.first, totvert=0; ev; ev= ev->next) { + ev->tmp.l = totvert; + totvert++; } - for (a=0, med=me->medge; atotedge; a++, med++) - if (!BLI_edgehash_haskey(ehash, med->v1, med->v2)) - med->flag |= ME_SEAM_DONE; - - BLI_edgehash_free(ehash, NULL); + for (eed= em->edges.first; eed; eed = eed->next) { + eed->f2 = 0; + if (eed->h) { + eed->f2 |= ME_SEAM_DONE; + } + eed->tmp.l = totedge; + totedge++; + } /* alloc */ - nedges = MEM_callocN(sizeof(*nedges)*me->totvert+1, "SeamPathNEdges"); - edges = MEM_mallocN(sizeof(*edges)*me->totedge*2, "SeamPathEdges"); - prevedge = MEM_mallocN(sizeof(*prevedge)*me->totedge, "SeamPathPrevious"); - cost = MEM_mallocN(sizeof(*cost)*me->totedge, "SeamPathCost"); + nedges = MEM_callocN(sizeof(*nedges)*totvert+1, "SeamPathNEdges"); + edges = MEM_mallocN(sizeof(*edges)*totedge*2, "SeamPathEdges"); + prevedge = MEM_mallocN(sizeof(*prevedge)*totedge, "SeamPathPrevious"); + cost = MEM_mallocN(sizeof(*cost)*totedge, "SeamPathCost"); /* count edges, compute adjacent edges offsets and fill adjacent edges */ - for (a=0, med=me->medge; atotedge; a++, med++) { - nedges[med->v1+1]++; - nedges[med->v2+1]++; + for (eed= em->edges.first; eed; eed = eed->next) { + nedges[eed->v1->tmp.l+1]++; + nedges[eed->v2->tmp.l+1]++; } - for (a=1; atotvert; a++) { + for (a=1; amedge; atotedge; a++, med++) { - edges[nedges[med->v1+1]++] = a; - edges[nedges[med->v2+1]++] = a; + for (a=0, eed= em->edges.first; eed; a++, eed = eed->next) { + edges[nedges[eed->v1->tmp.l+1]++] = a; + edges[nedges[eed->v2->tmp.l+1]++] = a; cost[a] = 1e20f; prevedge[a] = -1; @@ -973,100 +1007,74 @@ static int seam_shortest_path(Mesh *me, int source, int target) /* regular dijkstra shortest path, but over edges instead of vertices */ heap = BLI_heap_new(); - BLI_heap_insert(heap, 0.0f, SET_INT_IN_POINTER(source)); - cost[source] = 0.0f; + BLI_heap_insert(heap, 0.0f, SET_INT_IN_POINTER(source->tmp.l)); + cost[source->tmp.l] = 0.0f; + + EM_init_index_arrays(1, 1, 0); + while (!BLI_heap_empty(heap)) { mednum = GET_INT_FROM_POINTER(BLI_heap_popmin(heap)); - med = me->medge + mednum; + eed = EM_get_edge_for_index( mednum ); - if (mednum == target) + if (mednum == target->tmp.l) break; - if (med->flag & ME_SEAM_DONE) + if (eed->f2 & ME_SEAM_DONE) continue; - med->flag |= ME_SEAM_DONE; + eed->f2 |= ME_SEAM_DONE; - seam_add_adjacent(me, heap, mednum, med->v1, nedges, edges, prevedge, cost); - seam_add_adjacent(me, heap, mednum, med->v2, nedges, edges, prevedge, cost); + edgetag_add_adjacent(em, heap, mednum, eed->v1->tmp.l, nedges, edges, prevedge, cost); + edgetag_add_adjacent(em, heap, mednum, eed->v2->tmp.l, nedges, edges, prevedge, cost); } + MEM_freeN(nedges); MEM_freeN(edges); MEM_freeN(cost); BLI_heap_free(heap, NULL); - for (a=0, med=me->medge; atotedge; a++, med++) - med->flag &= ~ME_SEAM_DONE; + for (eed= em->edges.first; eed; eed = eed->next) { + eed->f2 &= ~ME_SEAM_DONE; + } - if (mednum != target) { + if (mednum != target->tmp.l) { MEM_freeN(prevedge); + EM_free_index_arrays(); return 0; } /* follow path back to source and mark as seam */ - if (mednum == target) { + if (mednum == target->tmp.l) { short allseams = 1; - mednum = target; + mednum = target->tmp.l; do { - med = me->medge + mednum; - if (!(med->flag & ME_SEAM)) { + eed = EM_get_edge_for_index( mednum ); + if (!edgetag_context_check(eed)) { allseams = 0; break; } mednum = prevedge[mednum]; - } while (mednum != source); + } while (mednum != source->tmp.l); - mednum = target; + mednum = target->tmp.l; do { - med = me->medge + mednum; + eed = EM_get_edge_for_index( mednum ); if (allseams) - med->flag &= ~ME_SEAM; + edgetag_context_set(eed, 0); else - med->flag |= ME_SEAM; + edgetag_context_set(eed, 1); mednum = prevedge[mednum]; } while (mednum != -1); } MEM_freeN(prevedge); + EM_free_index_arrays(); return 1; } -static void seam_select(Mesh *me, short *mval, short path) -{ - unsigned int index = 0; - MEdge *medge, *med; - int a, lastindex = -1; - - if (!facesel_edge_pick(me, mval, &index)) - return; - - for (a=0, med=me->medge; atotedge; a++, med++) { - if (med->flag & ME_SEAM_LAST) { - lastindex = a; - med->flag &= ~ME_SEAM_LAST; - break; - } - } - - medge = me->medge + index; - if (!path || (lastindex == -1) || (index == lastindex) || - !seam_shortest_path(me, lastindex, index)) - medge->flag ^= ME_SEAM; - medge->flag |= ME_SEAM_LAST; - - G.f |= G_DRAWSEAMS; - - if (G.rt == 8) - unwrap_lscm(1); - - BIF_undo_push("Mark Seam"); - - object_tface_flags_changed(OBACT, 1); -} - void seam_edgehash_insert_face(EdgeHash *ehash, MFace *mf) { BLI_edgehash_insert(ehash, mf->v1, mf->v2, NULL); @@ -1154,11 +1162,6 @@ void face_select() me = get_mesh(ob); getmouseco_areawin(mval); - if (G.qual & LR_ALTKEY) { - seam_select(me, mval, (G.qual & LR_SHIFTKEY) != 0); - return; - } - if (!facesel_face_pick(me, mval, &index, 1)) return; msel= (((MFace*)me->mface)+index); diff --git a/source/blender/src/editmesh_mods.c b/source/blender/src/editmesh_mods.c index d1873d1fe56..84971e8ce0b 100644 --- a/source/blender/src/editmesh_mods.c +++ b/source/blender/src/editmesh_mods.c @@ -92,6 +92,7 @@ editmesh_mods.c, UI level access, no geometry changes #include "BDR_drawobject.h" #include "BDR_editobject.h" +#include "BDR_editface.h" #include "BSE_drawview.h" #include "BSE_edit.h" @@ -2062,6 +2063,7 @@ void loop_multiselect(int looptype) /* ***************** MAIN MOUSE SELECTION ************** */ /* just to have the functions nice together */ + static void mouse_mesh_loop(void) { EditEdge *eed; @@ -2070,36 +2072,100 @@ static void mouse_mesh_loop(void) eed= findnearestedge(&dist); if(eed) { + if (G.scene->toolsettings->edge_mode == EDGE_MODE_SELECT) { + if((G.qual & LR_SHIFTKEY)==0) EM_clear_flag_all(SELECT); - if((G.qual & LR_SHIFTKEY)==0) EM_clear_flag_all(SELECT); - - if((eed->f & SELECT)==0) select=1; - else if(G.qual & LR_SHIFTKEY) select=0; + if((eed->f & SELECT)==0) select=1; + else if(G.qual & LR_SHIFTKEY) select=0; - if(G.scene->selectmode & SCE_SELECT_FACE) { - faceloop_select(eed, select); - } - else if(G.scene->selectmode & SCE_SELECT_EDGE) { - if(G.qual == (LR_CTRLKEY | LR_ALTKEY) || G.qual == (LR_CTRLKEY | LR_ALTKEY |LR_SHIFTKEY)) - edgering_select(eed, select); - else if(G.qual & LR_ALTKEY) - edgeloop_select(eed, select); - } - else if(G.scene->selectmode & SCE_SELECT_VERTEX) { - if(G.qual == (LR_CTRLKEY | LR_ALTKEY) || G.qual == (LR_CTRLKEY | LR_ALTKEY |LR_SHIFTKEY)) - edgering_select(eed, select); - else if(G.qual & LR_ALTKEY) - edgeloop_select(eed, select); - } + if(G.scene->selectmode & SCE_SELECT_FACE) { + faceloop_select(eed, select); + } + else if(G.scene->selectmode & SCE_SELECT_EDGE) { + if(G.qual == (LR_CTRLKEY | LR_ALTKEY) || G.qual == (LR_CTRLKEY | LR_ALTKEY |LR_SHIFTKEY)) + edgering_select(eed, select); + else if(G.qual & LR_ALTKEY) + edgeloop_select(eed, select); + } + else if(G.scene->selectmode & SCE_SELECT_VERTEX) { + if(G.qual == (LR_CTRLKEY | LR_ALTKEY) || G.qual == (LR_CTRLKEY | LR_ALTKEY |LR_SHIFTKEY)) + edgering_select(eed, select); + else if(G.qual & LR_ALTKEY) + edgeloop_select(eed, select); + } - /* frontbuffer draw of last selected only */ - unified_select_draw(NULL, eed, NULL); + /* frontbuffer draw of last selected only */ + unified_select_draw(NULL, eed, NULL); - EM_selectmode_flush(); - countall(); - allqueue(REDRAWVIEW3D, 0); - if (EM_texFaceCheck()) - allqueue(REDRAWIMAGE, 0); + EM_selectmode_flush(); + countall(); + allqueue(REDRAWVIEW3D, 0); + if (EM_texFaceCheck()) + allqueue(REDRAWIMAGE, 0); + } else { /*(G.scene->toolsettings->edge_mode == EDGE_MODE_TAG_*)*/ + int act = (edgetag_context_check(eed)==0); + int path = 0; + + if (G.qual == (LR_SHIFTKEY | LR_ALTKEY) && G.editMesh->selected.last) { + EditSelection *ese = G.editMesh->selected.last; + + if(ese && ese->type == EDITEDGE) { + EditEdge *eed_act; + eed_act = (EditEdge*)ese->data; + if (eed_act != eed) { + /* If shift is pressed we need to use the last active edge, (if it exists) */ + if (edgetag_shortest_path(eed_act, eed)) { + EM_remove_selection(eed_act, EDITEDGE); + EM_select_edge(eed_act, 0); + path = 1; + } + } + } + } + if (path==0) { + edgetag_context_set(eed, act); /* switch the edge option */ + } + + if (act) { + if ((eed->f & SELECT)==0) { + EM_select_edge(eed, 1); + EM_selectmode_flush(); + countall(); + } + /* even if this is selected it may not be in the selection list */ + EM_store_selection(eed, EDITEDGE); + } else { + if (eed->f & SELECT) { + EM_select_edge(eed, 0); + /* logic is differnt from above here since if this was selected we dont know if its in the selection list or not */ + EM_remove_selection(eed, EDITEDGE); + + EM_selectmode_flush(); + countall(); + } + } + + switch (G.scene->toolsettings->edge_mode) { + case EDGE_MODE_TAG_SEAM: + G.f |= G_DRAWSEAMS; + break; + case EDGE_MODE_TAG_SHARP: + G.f |= G_DRAWSHARP; + break; + case EDGE_MODE_TAG_CREASE: + G.f |= G_DRAWCREASES; + break; + case EDGE_MODE_TAG_BEVEL: + G.f |= G_DRAWBWEIGHTS; + break; + } + + unified_select_draw(NULL, eed, NULL); + + DAG_object_flush_update(G.scene, G.obedit, OB_RECALC_DATA); + allqueue(REDRAWVIEW3D, 0); + } + } } -- cgit v1.2.3