diff --git a/CMakeLists.txt b/CMakeLists.txt index 3711227fdef..a3baf582b9f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -102,8 +102,12 @@ get_blender_version() # Blender internal features option(WITH_INTERNATIONAL "Enable I18N (International fonts and text)" ON) + option(WITH_PYTHON "Enable Embedded Python API (only disable for development)" ON) +option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default (recommend to leave off)" OFF) mark_as_advanced(WITH_PYTHON) # dont want people disabling this unless they really know what they are doing. +mark_as_advanced(WITH_PYTHON_SECURITY) # some distrobutions see this as a security issue, rather then have them patch it, make a build option. + option(WITH_PYTHON_SAFETY "Enable internal API error checking to track invalid data to prevent crash on access (at the expense of some effeciency, only enable for development)." OFF) option(WITH_PYTHON_MODULE "Enable building as a python module (experemental, only enable for development)" OFF) option(WITH_BUILDINFO "Include extra build details (only disable for development & faster builds)" ON) diff --git a/build_files/buildbot/config/user-config-i686.py b/build_files/buildbot/config/user-config-i686.py index 6f0fca18dd4..de8dd93982f 100644 --- a/build_files/buildbot/config/user-config-i686.py +++ b/build_files/buildbot/config/user-config-i686.py @@ -22,20 +22,14 @@ BF_EXPAT_LIB = '' WITH_BF_FFMPEG = True WITH_BF_STATICFFMPEG = True -# Used for linking against system ffmpeg, but it gives pixelization,, so fall back to ffmpeg from 2.52 temporary -#BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \ -# '${BF_FFMPEG_LIBPATH}/libavutil.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libdc1394.a ' + \ -# '${BF_FFMPEG_LIBPATH}/libraw1394.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a ${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ' + \ -# '${BF_FFMPEG_LIBPATH}/libfaad.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \ -# '${BF_FFMPEG_LIBPATH}/libspeex.a ${BF_FFMPEG_LIBPATH}/libbz2.a ${BF_FFMPEG_LIBPATH}/liboil-0.3.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \ -# '${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libgsm.a' - BF_FFMPEG = '/home/sources/staticlibs/ffmpeg' BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib32' -BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libextern_libavformat.a ${BF_FFMPEG_LIBPATH}/libextern_libswscale.a ' + \ - '${BF_FFMPEG_LIBPATH}/libextern_libavcodec.a ${BF_FFMPEG_LIBPATH}/libextern_libavdevice.a ' + \ - '${BF_FFMPEG_LIBPATH}/libextern_libavutil.a ${BF_FFMPEG_LIBPATH}/libextern_xvidcore.a ' + \ - '${BF_FFMPEG_LIBPATH}/libextern_libmp3lame.a ${BF_FFMPEG_LIBPATH}/libextern_x264.a' +BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \ + '${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libavutil.a ' + \ + '${BF_FFMPEG_LIBPATH}/libxvidcore.a ${BF_FFMPEG_LIBPATH}/libx264.a ${BF_FFMPEG_LIBPATH}/libmp3lame.a ' + \ + '${BF_FFMPEG_LIBPATH}/libvpx.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \ + '${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \ + '${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ${BF_FFMPEG_LIBPATH}/liborc-0.4.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a' # Don't depend on system's libstdc++ WITH_BF_STATICCXX = True diff --git a/build_files/buildbot/config/user-config-x86_64.py b/build_files/buildbot/config/user-config-x86_64.py index c44a387c1d6..7bae2d232cd 100644 --- a/build_files/buildbot/config/user-config-x86_64.py +++ b/build_files/buildbot/config/user-config-x86_64.py @@ -22,20 +22,14 @@ BF_EXPAT_LIB = '' WITH_BF_FFMPEG = True WITH_BF_STATICFFMPEG = True -# Used for linking against system ffmpeg, but it gives pixelization,, so fall back to ffmpeg from 2.52 temporary -#BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \ -# '${BF_FFMPEG_LIBPATH}/libavutil.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libdc1394.a ' + \ -# '${BF_FFMPEG_LIBPATH}/libraw1394.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a ${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ' + \ -# '${BF_FFMPEG_LIBPATH}/libfaad.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \ -# '${BF_FFMPEG_LIBPATH}/libspeex.a ${BF_FFMPEG_LIBPATH}/libbz2.a ${BF_FFMPEG_LIBPATH}/liboil-0.3.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \ -# '${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libgsm.a' - BF_FFMPEG = '/home/sources/staticlibs/ffmpeg' BF_FFMPEG_LIBPATH = '${BF_FFMPEG}/lib64' -BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libextern_libavformat.a ${BF_FFMPEG_LIBPATH}/libextern_libswscale.a ' + \ - '${BF_FFMPEG_LIBPATH}/libextern_libavcodec.a ${BF_FFMPEG_LIBPATH}/libextern_libavdevice.a ' + \ - '${BF_FFMPEG_LIBPATH}/libextern_libavutil.a ${BF_FFMPEG_LIBPATH}/libextern_xvidcore.a ' + \ - '${BF_FFMPEG_LIBPATH}/libextern_libmp3lame.a ${BF_FFMPEG_LIBPATH}/libextern_x264.a' +BF_FFMPEG_LIB_STATIC = '${BF_FFMPEG_LIBPATH}/libavformat.a ${BF_FFMPEG_LIBPATH}/libswscale.a ' + \ + '${BF_FFMPEG_LIBPATH}/libavcodec.a ${BF_FFMPEG_LIBPATH}/libavdevice.a ${BF_FFMPEG_LIBPATH}/libavutil.a ' + \ + '${BF_FFMPEG_LIBPATH}/libxvidcore.a ${BF_FFMPEG_LIBPATH}/libx264.a ${BF_FFMPEG_LIBPATH}/libmp3lame.a ' + \ + '${BF_FFMPEG_LIBPATH}/libvpx.a ${BF_FFMPEG_LIBPATH}/libvorbis.a ${BF_FFMPEG_LIBPATH}/libogg.a ' + \ + '${BF_FFMPEG_LIBPATH}/libvorbisenc.a ${BF_FFMPEG_LIBPATH}/libtheora.a ' + \ + '${BF_FFMPEG_LIBPATH}/libschroedinger-1.0.a ${BF_FFMPEG_LIBPATH}/liborc-0.4.a ${BF_FFMPEG_LIBPATH}/libdirac_encoder.a' # Don't depend on system's libstdc++ WITH_BF_STATICCXX = True diff --git a/doc/python_api/examples/bpy.types.Operator.1.py b/doc/python_api/examples/bpy.types.Operator.1.py index 133dc09af46..fc016508d39 100644 --- a/doc/python_api/examples/bpy.types.Operator.1.py +++ b/doc/python_api/examples/bpy.types.Operator.1.py @@ -32,7 +32,7 @@ class SimpleMouseOperator(bpy.types.Operator): def execute(self, context): # rather then printing, use the report function, - # this way the messag appiers in the header, + # this way the message appears in the header, self.report({'INFO'}, "Mouse coords are %d %d" % (self.x, self.y)) return {'FINISHED'} diff --git a/intern/ghost/test/gears/GHOST_C-Test.c b/intern/ghost/test/gears/GHOST_C-Test.c index e8e818abca7..b34a37132b6 100644 --- a/intern/ghost/test/gears/GHOST_C-Test.c +++ b/intern/ghost/test/gears/GHOST_C-Test.c @@ -83,71 +83,71 @@ static void testTimerProc(GHOST_TimerTaskHandle task, GHOST_TUns64 time) static void gearGL(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, GLint teeth, GLfloat tooth_depth) { GLint i; - GLfloat r0, r1, r2; - GLfloat angle, da; - GLfloat u, v, len; + GLfloat r0, r1, r2; + GLfloat angle, da; + GLfloat u, v, len; const double pi = 3.14159264; - r0 = inner_radius; - r1 = (float)(outer_radius - tooth_depth/2.0); - r2 = (float)(outer_radius + tooth_depth/2.0); + r0 = inner_radius; + r1 = (float)(outer_radius - tooth_depth/2.0); + r2 = (float)(outer_radius + tooth_depth/2.0); - da = (float)(2.0*pi / teeth / 4.0); + da = (float)(2.0*pi / teeth / 4.0); - glShadeModel(GL_FLAT); - glNormal3f(0.0, 0.0, 1.0); + glShadeModel(GL_FLAT); + glNormal3f(0.0, 0.0, 1.0); - /* draw front face */ - glBegin(GL_QUAD_STRIP); - for (i=0;i<=teeth;i++) { + /* draw front face */ + glBegin(GL_QUAD_STRIP); + for (i=0;i<=teeth;i++) { angle = (float)(i * 2.0*pi / teeth); glVertex3f((float)(r0*cos(angle)), (float)(r0*sin(angle)), (float)(width*0.5)); glVertex3f((float)(r1*cos(angle)), (float)(r1*sin(angle)), (float)(width*0.5)); glVertex3f((float)(r0*cos(angle)), (float)(r0*sin(angle)), (float)(width*0.5)); glVertex3f((float)(r1*cos(angle+3*da)), (float)(r1*sin(angle+3*da)), (float)(width*0.5)); - } - glEnd(); + } + glEnd(); - /* draw front sides of teeth */ - glBegin(GL_QUADS); - da = (float)(2.0*pi / teeth / 4.0); - for (i=0;iglyph_cache || (!font->b_fbuf && !font->b_cbuf)) @@ -276,13 +276,20 @@ void blf_font_buffer(FontBLF *font, const char *str) /* dont draw beyond the buffer bounds */ int width_clip= g->width; int height_clip= g->height; + int yb_start= g->pitch < 0 ? 0 : g->height-1; if (width_clip + chx > font->bw) width_clip -= chx + width_clip - font->bw; if (height_clip + pen_y > font->bh) height_clip -= pen_y + height_clip - font->bh; - - yb= g->pitch < 0 ? 0 : g->height-1; + /* drawing below the image? */ + if(pen_y < 0) { + yb_start += (g->pitch < 0) ? -pen_y : pen_y; + height_clip += pen_y; + pen_y= 0; + } + if (font->b_fbuf) { + int yb= yb_start; for (y=(chy >= 0 ? 0:-chy); y < height_clip; y++) { for (x=(chx >= 0 ? 0:-chx); x < width_clip; x++) { @@ -311,6 +318,7 @@ void blf_font_buffer(FontBLF *font, const char *str) } if (font->b_cbuf) { + int yb= yb_start; for (y= 0; y < height_clip; y++) { for (x= 0; x < width_clip; x++) { a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f; diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index deb13006eaf..c4e192626e8 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -200,9 +200,9 @@ typedef struct FontBLF { /* the same but unsigned char */ unsigned char *b_cbuf; - /* buffer size. */ - unsigned int bw; - unsigned int bh; + /* buffer size, keep signed so comparisons with negative values work */ + int bw; + int bh; /* number of channels. */ int bch; diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 83d65f3b1f4..6c415010953 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -44,14 +44,14 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather then defining with quotes */ #define BLENDER_VERSION 257 -#define BLENDER_SUBVERSION 0 +#define BLENDER_SUBVERSION 1 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 /* used by packaging tools */ /* can be left blank, otherwise a,b,c... etc with no quotes */ -#define BLENDER_VERSION_CHAR a +#define BLENDER_VERSION_CHAR b /* alpha/beta/rc/release, docs use this */ #define BLENDER_VERSION_CYCLE release diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 8f0ce8c1660..64c29158bd4 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -44,14 +44,16 @@ struct ImBuf; struct Tex; struct anim; struct Scene; +struct Object; /* call from library */ void free_image(struct Image *me); -void BKE_stamp_info(struct Scene *scene, struct ImBuf *ibuf); -void BKE_stamp_buf(struct Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels); +void BKE_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf); +void BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels); int BKE_alphatest_ibuf(struct ImBuf *ibuf); -int BKE_write_ibuf(struct Scene *scene, struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality); +int BKE_write_ibuf_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality); +int BKE_write_ibuf(struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality); void BKE_makepicstring(char *string, const char *base, int frame, int imtype, const short use_ext, const short use_frames); int BKE_add_image_extension(char *string, int imtype); int BKE_ftype_to_imtype(int ftype); diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 523a67eff67..c445408609c 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -55,6 +55,7 @@ struct Material *copy_material(struct Material *ma); struct Material *localize_material(struct Material *ma); struct Material *give_node_material(struct Material *ma); /* returns node material or self */ void make_local_material(struct Material *ma); +void extern_local_matarar(struct Material **matar, short totcol); void automatname(struct Material *); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index ae7ac0dabee..08c150e30e3 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -66,7 +66,6 @@ void free_mesh(struct Mesh *me); struct Mesh *add_mesh(const char *name); struct Mesh *copy_mesh(struct Mesh *me); void mesh_update_customdata_pointers(struct Mesh *me); -void make_local_tface(struct Mesh *me); void make_local_mesh(struct Mesh *me); void boundbox_mesh(struct Mesh *me, float *loc, float *size); void tex_space_mesh(struct Mesh *me); diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index fe757b65970..3a98f892bd8 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -91,7 +91,6 @@ struct Object *add_only_object(int type, const char *name); struct Object *add_object(struct Scene *scene, int type); struct Object *copy_object(struct Object *ob); -void expand_local_object(struct Object *ob); void make_local_object(struct Object *ob); int object_is_libdata(struct Object *ob); int object_data_is_libdata(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 42786e1c9be..57829e957f7 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -330,7 +330,7 @@ struct Sequence *sequencer_add_sound_strip(struct bContext *C, ListBase *seqbase struct Sequence *sequencer_add_movie_strip(struct bContext *C, ListBase *seqbasep, struct SeqLoadInfo *seq_load); /* view3d draw callback, run when not in background view */ -typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, int, int, unsigned int, int, char[256]); +typedef struct ImBuf *(*SequencerDrawView)(struct Scene *, struct Object *, int, int, unsigned int, int, char[256]); extern SequencerDrawView sequencer_view3d_cb; /* copy/paste */ diff --git a/source/blender/blenkernel/BKE_shrinkwrap.h b/source/blender/blenkernel/BKE_shrinkwrap.h index 937a46d68dd..d1fef8b0ce1 100644 --- a/source/blender/blenkernel/BKE_shrinkwrap.h +++ b/source/blender/blenkernel/BKE_shrinkwrap.h @@ -90,7 +90,7 @@ void space_transform_invert(const struct SpaceTransform *data, float *co); * - Normal projection * * ShrinkwrapCalcData encapsulates all needed data for shrinkwrap functions. - * (So that you dont have to pass an enormous ammount of arguments to functions) + * (So that you dont have to pass an enormous amount of arguments to functions) */ struct Object; diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 9187d07a39f..a619be07b6a 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -284,6 +284,10 @@ endif() if(WITH_PYTHON) list(APPEND INC ../python ${PYTHON_INCLUDE_DIRS}) add_definitions(-DWITH_PYTHON) + + if(WITH_PYTHON_SECURITY) + add_definitions(-DWITH_PYTHON_SECURITY) + endif() endif() if(WITH_OPENMP) diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index d6e90ffab14..7d3219d917e 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2558,7 +2558,6 @@ static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const else { const short *no= pMesh->mvert[(&pMesh->mface[face_num].v1)[vert_index]].no; normal_short_to_float_v3(fNorm, no); - normalize_v3(fNorm); /* XXX, is this needed */ } } static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int face_num, const int iVert) diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 5b42948072f..5b49d9a9841 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -95,6 +95,7 @@ bAction *add_empty_action(const char name[]) void make_local_action(bAction *act) { // Object *ob; + Main *bmain= G.main; bAction *actn; int local=0, lib=0; @@ -102,7 +103,7 @@ void make_local_action(bAction *act) if (act->id.us==1) { act->id.lib= NULL; act->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)act, NULL); + new_id(&bmain->action, (ID *)act, NULL); return; } @@ -121,7 +122,7 @@ void make_local_action(bAction *act) act->id.lib= NULL; act->id.flag= LIB_LOCAL; //make_local_action_channels(act); - new_id(NULL, (ID *)act, NULL); + new_id(&bmain->action, (ID *)act, NULL); } else if(local && lib) { actn= copy_action(act); @@ -419,11 +420,11 @@ bPoseChannel *verify_pose_channel(bPose *pose, const char *name) return NULL; /* See if this channel exists */ - for (chan=pose->chanbase.first; chan; chan=chan->next) { - if (!strcmp (name, chan->name)) - return chan; + chan= BLI_findstring(&pose->chanbase, name, offsetof(bPoseChannel, name)); + if(chan) { + return chan; } - + /* If not, create it and add it */ chan = MEM_callocN(sizeof(bPoseChannel), "verifyPoseChannel"); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 3ff19b01b6c..b9c70493aee 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -195,7 +195,7 @@ AnimData *BKE_copy_animdata (AnimData *adt, const short do_action) dadt= MEM_dupallocN(adt); /* make a copy of action - at worst, user has to delete copies... */ - if(do_action) { + if (do_action) { dadt->action= copy_action(adt->action); dadt->tmpact= copy_action(adt->tmpact); } @@ -217,11 +217,11 @@ AnimData *BKE_copy_animdata (AnimData *adt, const short do_action) return dadt; } -int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from, const short do_action) +int BKE_copy_animdata_id (ID *id_to, ID *id_from, const short do_action) { AnimData *adt; - if((id_to && id_from) && (GS(id_to->name) != GS(id_from->name))) + if ((id_to && id_from) && (GS(id_to->name) != GS(id_from->name))) return 0; BKE_free_animdata(id_to); @@ -238,13 +238,13 @@ int BKE_copy_animdata_id(struct ID *id_to, struct ID *id_from, const short do_ac void BKE_copy_animdata_id_action(struct ID *id) { AnimData *adt= BKE_animdata_from_id(id); - if(adt) { - if(adt->action) { - ((ID *)adt->action)->us--; + if (adt) { + if (adt->action) { + id_us_min((ID *)adt->action); adt->action= copy_action(adt->action); } - if(adt->tmpact) { - ((ID *)adt->tmpact)->us--; + if (adt->tmpact) { + id_us_min((ID *)adt->tmpact); adt->tmpact= copy_action(adt->tmpact); } } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index a79637eea73..fd25ebe266f 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -137,39 +137,42 @@ void free_armature(bArmature *arm) void make_local_armature(bArmature *arm) { + Main *bmain= G.main; int local=0, lib=0; Object *ob; - bArmature *newArm; - - if (arm->id.lib==NULL) - return; + + if (arm->id.lib==NULL) return; if (arm->id.us==1) { arm->id.lib= NULL; arm->id.flag= LIB_LOCAL; - new_id(NULL, (ID*)arm, NULL); + new_id(&bmain->armature, (ID*)arm, NULL); return; } - + + for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) { + if(ob->data == arm) { + if(ob->id.lib) lib= 1; + else local= 1; + } + } + if(local && lib==0) { arm->id.lib= NULL; arm->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)arm, NULL); + new_id(&bmain->armature, (ID *)arm, NULL); } else if(local && lib) { - newArm= copy_armature(arm); - newArm->id.us= 0; + bArmature *armn= copy_armature(arm); + armn->id.us= 0; - ob= G.main->object.first; - while(ob) { - if(ob->data==arm) { - + for(ob= bmain->object.first; ob; ob= ob->id.next) { + if(ob->data == arm) { if(ob->id.lib==NULL) { - ob->data= newArm; - newArm->id.us++; + ob->data= armn; + armn->id.us++; arm->id.us--; } } - ob= ob->id.next; } } } diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index d1a181046a6..ce6a95430e3 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -140,8 +140,12 @@ void initglobals(void) G.charstart = 0x0000; G.charmin = 0x0000; G.charmax = 0xffff; - + +#ifndef WITH_PYTHON_SECURITY /* default */ G.f |= G_SCRIPT_AUTOEXEC; +#else + G.f &= ~G_SCRIPT_AUTOEXEC; +#endif } /***/ diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 11ea3384c96..9f808704eee 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -1299,7 +1299,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) bpa->data.mode = eBoidMode_OnLand; } /* fly above ground */ - else { + else if(bpa->ground) { pa->state.co[2] = ground_co[2] + pa->size * boids->height; pa->state.vel[2] = 0.0f; } diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index ac532cca7c6..fa3b756ae27 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -180,14 +180,20 @@ void free_brush(Brush *brush) curvemapping_free(brush->curve); } +static void extern_local_brush(Brush *brush) +{ + id_lib_extern((ID *)brush->mtex.tex); +} + void make_local_brush(Brush *brush) { + /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ - - Brush *brushn; + * - only local users: set flag + * - mixed: make copy + */ + + Main *bmain= G.main; Scene *scene; int local= 0, lib= 0; @@ -197,19 +203,22 @@ void make_local_brush(Brush *brush) /* special case: ima always local immediately */ brush->clone.image->id.lib= NULL; brush->clone.image->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)brush->clone.image, NULL); + new_id(&bmain->brush, (ID *)brush->clone.image, NULL); + extern_local_brush(brush); } - for(scene= G.main->scene.first; scene; scene=scene->id.next) + for(scene= bmain->scene.first; scene && ELEM(0, lib, local); scene=scene->id.next) { if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) { if(scene->id.lib) lib= 1; else local= 1; } + } if(local && lib==0) { brush->id.lib= NULL; brush->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)brush, NULL); + new_id(&bmain->brush, (ID *)brush, NULL); + extern_local_brush(brush); /* enable fake user by default */ if (!(brush->id.flag & LIB_FAKEUSER)) { @@ -218,17 +227,19 @@ void make_local_brush(Brush *brush) } } else if(local && lib) { - brushn= copy_brush(brush); + Brush *brushn= copy_brush(brush); brushn->id.us= 1; /* only keep fake user */ brushn->id.flag |= LIB_FAKEUSER; - for(scene= G.main->scene.first; scene; scene=scene->id.next) - if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) + for(scene= bmain->scene.first; scene; scene=scene->id.next) { + if(paint_brush(&scene->toolsettings->imapaint.paint)==brush) { if(scene->id.lib==NULL) { paint_brush_set(&scene->toolsettings->imapaint.paint, brushn); brushn->id.us++; brush->id.us--; } + } + } } } diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 0b29b29e60f..8bd650b1a42 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -172,11 +172,7 @@ static void cdDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3]) static void cdDM_getVertNo(DerivedMesh *dm, int index, float no_r[3]) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; - short *no = cddm->mvert[index].no; - - no_r[0] = no[0]/32767.f; - no_r[1] = no[1]/32767.f; - no_r[2] = no[2]/32767.f; + normal_short_to_float_v3(no_r, cddm->mvert[index].no); } static ListBase *cdDM_getFaceMap(Object *ob, DerivedMesh *dm) @@ -580,8 +576,9 @@ static void cdDM_drawFacesColored(DerivedMesh *dm, int useTwoSided, unsigned cha /* there's a conflict here... twosided colors versus culling...? */ /* defined by history, only texture faces have culling option */ /* we need that as mesh option builtin, next to double sided lighting */ - if(col1 && col2) + if(col2) { glEnable(GL_CULL_FACE); + } cdDM_update_normals_from_pbvh(dm); @@ -773,6 +770,19 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } if( !GPU_buffer_legacy(dm) ) { + /* warning!, this logic is incorrect, see bug [#27175] + * firstly, there are no checks for changes in context, such as texface image. + * secondly, drawParams() sets the GL context, so checking if there is a change + * from lastFlag is too late once glDrawArrays() runs, since drawing the arrays + * will use the modified, OpenGL settings. + * + * However its tricky to fix this without duplicating the internal logic + * of drawParams(), perhaps we need an argument like... + * drawParams(..., keep_gl_state_but_return_when_changed) ?. + * + * We could also just disable VBO's here, since texface may be deprecated - campbell. + */ + glShadeModel( GL_SMOOTH ); lastFlag = 0; for(i = 0; i < dm->drawObject->nelements/3; i++) { diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index 4e5a1977ab0..55d455bc5d3 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -451,11 +451,10 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res C->data.recursion= 1; - for(entry=C->wm.store->entries.first; entry; entry=entry->next) { - if(strcmp(entry->name, member) == 0) { - result->ptr= entry->ptr; - done= 1; - } + entry= BLI_findstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name)); + if(entry) { + result->ptr= entry->ptr; + done= 1; } } if(done!=1 && recursion < 2 && C->wm.region) { @@ -649,7 +648,7 @@ int CTX_data_equals(const char *member, const char *str) int CTX_data_dir(const char *member) { - return (strcmp(member, "") == 0); + return member[0] == '\0'; } void CTX_data_id_pointer_set(bContextDataResult *result, ID *id) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 34e5fef8074..b104c6c9b30 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -63,7 +63,8 @@ #include "BKE_key.h" #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_object.h" +#include "BKE_object.h" +#include "BKE_material.h" #include "ED_curve.h" @@ -216,10 +217,22 @@ Curve *copy_curve(Curve *cu) return cun; } +static void extern_local_curve(Curve *cu) +{ + id_lib_extern((ID *)cu->vfont); + id_lib_extern((ID *)cu->vfontb); + id_lib_extern((ID *)cu->vfonti); + id_lib_extern((ID *)cu->vfontbi); + + if(cu->mat) { + extern_local_matarar(cu->mat, cu->totcol); + } +} + void make_local_curve(Curve *cu) { - Object *ob = NULL; - Curve *cun; + Main *bmain= G.main; + Object *ob; int local=0, lib=0; /* - when there are only lib users: don't do @@ -229,47 +242,41 @@ void make_local_curve(Curve *cu) if(cu->id.lib==NULL) return; - if(cu->vfont) cu->vfont->id.lib= NULL; - if(cu->vfontb) cu->vfontb->id.lib= NULL; - if(cu->vfonti) cu->vfonti->id.lib= NULL; - if(cu->vfontbi) cu->vfontbi->id.lib= NULL; - if(cu->id.us==1) { cu->id.lib= NULL; cu->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)cu, NULL); + + new_id(&bmain->curve, (ID *)cu, NULL); + extern_local_curve(cu); return; } - - ob= G.main->object.first; - while(ob) { - if(ob->data==cu) { + + for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) { + if(ob->data == cu) { if(ob->id.lib) lib= 1; else local= 1; } - ob= ob->id.next; } - + if(local && lib==0) { cu->id.lib= NULL; cu->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)cu, NULL); + + new_id(&bmain->curve, (ID *)cu, NULL); + extern_local_curve(cu); } else if(local && lib) { - cun= copy_curve(cu); + Curve *cun= copy_curve(cu); cun->id.us= 0; - - ob= G.main->object.first; - while(ob) { + + for(ob= bmain->object.first; ob; ob= ob->id.next) { if(ob->data==cu) { - if(ob->id.lib==NULL) { ob->data= cun; cun->id.us++; cu->id.us--; } } - ob= ob->id.next; } } } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 94fbcd9ccb4..6813d5d18a6 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -1905,7 +1905,9 @@ static void dag_scene_flush_layers(Scene *sce, int lay) } /* ensure cameras are set as if they are on a visible layer, because - they ared still used for rendering or setting the camera view */ + * they ared still used for rendering or setting the camera view + * + * XXX, this wont work for local view / unlocked camera's */ if(sce->camera) { node= dag_get_node(sce->theDag, sce->camera); node->scelay |= lay; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 0c722d81f45..6898615c753 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -386,7 +386,7 @@ VFont *load_vfont(const char *name) vfont->data = vfd; /* if there's a font name, use it for the ID name */ - if (strcmp(vfd->name, "")!=0) { + if (vfd->name[0] != '\0') { BLI_strncpy(vfont->id.name+2, vfd->name, sizeof(vfont->id.name)-2); } BLI_strncpy(vfont->name, name, sizeof(vfont->name)); diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 80962de9730..04fc41e41cc 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -426,35 +426,30 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop) * When values name and types match, copy the values, else ignore */ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src) { - IDProperty *loop, *prop; + IDProperty *other, *prop; for (prop=src->data.group.first; prop; prop=prop->next) { - for (loop=dest->data.group.first; loop; loop=loop->next) { - if (strcmp(loop->name, prop->name)==0) { - if(prop->type==loop->type) { + other= BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name)); + if (other && prop->type==other->type) { + switch (prop->type) { + case IDP_INT: + case IDP_FLOAT: + case IDP_DOUBLE: + other->data= prop->data; + break; + case IDP_GROUP: + IDP_SyncGroupValues(other, prop); + break; + default: + { + IDProperty *tmp= other; + IDProperty *copy= IDP_CopyProperty(prop); - switch (prop->type) { - case IDP_INT: - case IDP_FLOAT: - case IDP_DOUBLE: - loop->data= prop->data; - break; - case IDP_GROUP: - IDP_SyncGroupValues(loop, prop); - break; - default: - { - IDProperty *tmp= loop; - IDProperty *copy= IDP_CopyProperty(prop); + BLI_insertlinkafter(&dest->data.group, other, copy); + BLI_remlink(&dest->data.group, tmp); - BLI_insertlinkafter(&dest->data.group, loop, copy); - BLI_remlink(&dest->data.group, tmp); - - IDP_FreeProperty(tmp); - MEM_freeN(tmp); - } - } + IDP_FreeProperty(tmp); + MEM_freeN(tmp); } - break; } } } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index c44634fed34..28559812f4d 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -880,7 +880,7 @@ typedef struct StampData { char rendertime[64]; } StampData; -static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) +static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int do_prefix) { char text[256]; struct tm *tl; @@ -959,14 +959,14 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } if (scene->r.stamp & R_STAMP_CAMERA) { - BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s":"%s", scene->camera ? scene->camera->id.name+2 : ""); + BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s":"%s", camera ? camera->id.name+2 : ""); } else { stamp_data->camera[0] = '\0'; } if (scene->r.stamp & R_STAMP_CAMERALENS) { - if (scene->camera && scene->camera->type == OB_CAMERA) { - BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)scene->camera->data)->lens); + if (camera && camera->type == OB_CAMERA) { + BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)camera->data)->lens); } else strcpy(text, ""); @@ -1006,18 +1006,18 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix) } } -void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels) +void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels) { struct StampData stamp_data; float w, h, pad; - int x, y; + int x, y, y_ofs; float h_fixed; const int mono= blf_mono_font_render; // XXX if (!rect && !rectf) return; - stampdata(scene, &stamp_data, 1); + stampdata(scene, camera, &stamp_data, 1); /* TODO, do_versions */ if(scene->r.stamp_font_id < 8) @@ -1034,8 +1034,17 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i // BLF_width_and_height(mono, "^|/_AgPpJjlYy", &w, &h_fixed); { rctf box; + float baseline; BLF_boundbox(mono, "^|/_AgPpJjlYy", &box); h_fixed= box.ymax - box.ymin; + + /* crude way to get the decent line from A->j*/ + BLF_boundbox(mono, "A", &box); + baseline= box.ymin; + BLF_boundbox(mono, "j", &box); + y_ofs = (int)(baseline - box.ymin); + if(y_ofs < 0) y_ofs= 0; /* should never happen */ + y_ofs++; } x= 0; @@ -1050,7 +1059,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, w+3, y+h+2); /* and draw the text. */ - BLF_position(mono, x, y, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.file); /* the extra pixel for background. */ @@ -1065,7 +1074,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* and space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+2); - BLF_position(mono, x, y+1, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.note); /* the extra pixel for background. */ @@ -1080,7 +1089,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* and space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+2); - BLF_position(mono, x, y, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.date); /* the extra pixel for background. */ @@ -1095,7 +1104,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* and space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-3, w+3, y+h+2); - BLF_position(mono, x, y, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.rendertime); } @@ -1110,7 +1119,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, w+2, y+h+2); /* and pad the text. */ - BLF_position(mono, x, y+3, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.marker); /* space width. */ @@ -1125,7 +1134,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2); /* and pad the text. */ - BLF_position(mono, x, y+3, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.time); /* space width. */ @@ -1139,7 +1148,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2); /* and pad the text. */ - BLF_position(mono, x, y+3, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.frame); /* space width. */ @@ -1151,7 +1160,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* extra space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2); - BLF_position(mono, x, y+3, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.camera); /* space width. */ @@ -1163,7 +1172,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* extra space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+2, y+h+2); - BLF_position(mono, x, y+3, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.cameralens); } @@ -1177,7 +1186,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y, x+w+3, y+h+2); /* and pad the text. */ - BLF_position(mono, x, y+3, 0.0); + BLF_position(mono, x, y+y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.scene); } @@ -1191,7 +1200,7 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i /* extra space for background. */ buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x, y-3, x+w+pad, y+h+2); - BLF_position(mono, x, y, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.strip); } @@ -1199,14 +1208,14 @@ void BKE_stamp_buf(Scene *scene, unsigned char *rect, float *rectf, int width, i BLF_buffer(mono, NULL, NULL, 0, 0, 0); } -void BKE_stamp_info(Scene *scene, struct ImBuf *ibuf) +void BKE_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf) { struct StampData stamp_data; if (!ibuf) return; /* fill all the data values, no prefix */ - stampdata(scene, &stamp_data, 0); + stampdata(scene, camera, &stamp_data, 0); if (stamp_data.file[0]) IMB_metadata_change_field (ibuf, "File", stamp_data.file); if (stamp_data.note[0]) IMB_metadata_change_field (ibuf, "Note", stamp_data.note); @@ -1244,7 +1253,7 @@ int BKE_alphatest_ibuf(ImBuf *ibuf) return FALSE; } -int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality) +int BKE_write_ibuf(ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality) { int ok; (void)subimtype; /* quies unused warnings */ @@ -1339,9 +1348,6 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int } BLI_make_existing_file(name); - - if(scene && scene->r.stamp & R_STAMP_ALL) - BKE_stamp_info(scene, ibuf); ok = IMB_saveiff(ibuf, name, IB_rect | IB_zbuf | IB_zbuffloat); if (ok == 0) { @@ -1351,6 +1357,14 @@ int BKE_write_ibuf(Scene *scene, ImBuf *ibuf, const char *name, int imtype, int return(ok); } +int BKE_write_ibuf_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality) +{ + if(scene && scene->r.stamp & R_STAMP_ALL) + BKE_stamp_info(scene, camera, ibuf); + + return BKE_write_ibuf(ibuf, name, imtype, subimtype, quality); +} + void BKE_makepicstring(char *string, const char *base, int frame, int imtype, const short use_ext, const short use_frames) { diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index d308ccbf876..f0ac7040deb 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -249,8 +249,8 @@ void free_lattice(Lattice *lt) void make_local_lattice(Lattice *lt) { + Main *bmain= G.main; Object *ob; - Lattice *ltn; int local=0, lib=0; /* - only lib users: do nothing @@ -262,39 +262,34 @@ void make_local_lattice(Lattice *lt) if(lt->id.us==1) { lt->id.lib= NULL; lt->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)lt, NULL); + new_id(&bmain->latt, (ID *)lt, NULL); return; } - ob= G.main->object.first; - while(ob) { + for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) { if(ob->data==lt) { if(ob->id.lib) lib= 1; else local= 1; } - ob= ob->id.next; } if(local && lib==0) { lt->id.lib= NULL; lt->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)lt, NULL); + new_id(&bmain->latt, (ID *)lt, NULL); } else if(local && lib) { - ltn= copy_lattice(lt); + Lattice *ltn= copy_lattice(lt); ltn->id.us= 0; - - ob= G.main->object.first; - while(ob) { + + for(ob= bmain->object.first; ob; ob= ob->id.next) { if(ob->data==lt) { - if(ob->id.lib==NULL) { ob->data= ltn; ltn->id.us++; lt->id.us--; } } - ob= ob->id.next; } } } diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index 000bdc138a4..a063458bdb5 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -268,6 +268,14 @@ Material *localize_material(Material *ma) return man; } +static void extern_local_material(Material *ma) +{ + int i; + for(i=0; i < MAX_MTEX; i++) { + if(ma->mtex[i]) id_lib_extern((ID *)ma->mtex[i]->tex); + } +} + void make_local_material(Material *ma) { Main *bmain= G.main; @@ -287,11 +295,9 @@ void make_local_material(Material *ma) if(ma->id.us==1) { ma->id.lib= NULL; ma->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)ma, NULL); - for(a=0; amtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex); - } - + + new_id(&bmain->mat, (ID *)ma, NULL); + extern_local_material(ma); return; } @@ -351,12 +357,9 @@ void make_local_material(Material *ma) if(local && lib==0) { ma->id.lib= NULL; ma->id.flag= LIB_LOCAL; - - for(a=0; amtex[a]) id_lib_extern((ID *)ma->mtex[a]->tex); - } - - new_id(NULL, (ID *)ma, NULL); + + new_id(&bmain->mat, (ID *)ma, NULL); + extern_local_material(ma); } else if(local && lib) { @@ -430,6 +433,15 @@ void make_local_material(Material *ma) } } +/* for curve, mball, mesh types */ +void extern_local_matarar(struct Material **matar, short totcol) +{ + short i; + for(i= 0; i < totcol; i++) { + id_lib_extern((ID *)matar[i]); + } +} + Material ***give_matarar(Object *ob) { Mesh *me; diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index e19a508658e..555d35726bc 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -67,6 +67,7 @@ #include "BKE_displist.h" #include "BKE_mball.h" #include "BKE_object.h" +#include "BKE_material.h" /* Global variables */ @@ -139,10 +140,17 @@ MetaBall *copy_mball(MetaBall *mb) return mbn; } +static void extern_local_mball(MetaBall *mb) +{ + if(mb->mat) { + extern_local_matarar(mb->mat, mb->totcol); + } +} + void make_local_mball(MetaBall *mb) { + Main *bmain= G.main; Object *ob; - MetaBall *mbn; int local=0, lib=0; /* - only lib users: do nothing @@ -154,37 +162,38 @@ void make_local_mball(MetaBall *mb) if(mb->id.us==1) { mb->id.lib= NULL; mb->id.flag= LIB_LOCAL; + new_id(&bmain->mball, (ID *)mb, NULL); + extern_local_mball(mb); + return; } - - ob= G.main->object.first; - while(ob) { - if(ob->data==mb) { + + for(ob= G.main->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) { + if(ob->data == mb) { if(ob->id.lib) lib= 1; else local= 1; } - ob= ob->id.next; } if(local && lib==0) { mb->id.lib= NULL; mb->id.flag= LIB_LOCAL; + + new_id(&bmain->mball, (ID *)mb, NULL); + extern_local_mball(mb); } else if(local && lib) { - mbn= copy_mball(mb); + MetaBall *mbn= copy_mball(mb); mbn->id.us= 0; - - ob= G.main->object.first; - while(ob) { - if(ob->data==mb) { - + + for(ob= G.main->object.first; ob; ob= ob->id.next) { + if(ob->data == mb) { if(ob->id.lib==NULL) { ob->data= mbn; mbn->id.us++; mb->id.us--; } } - ob= ob->id.next; } } } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 532e96f3031..45a60b842a7 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -247,7 +247,7 @@ Mesh *copy_mesh(Mesh *me) return men; } -void make_local_tface(Mesh *me) +static void make_local_tface(Main *bmain, Mesh *me) { MTFace *tface; Image *ima; @@ -264,7 +264,7 @@ void make_local_tface(Mesh *me) if(ima->id.lib) { ima->id.lib= NULL; ima->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)ima, NULL); + new_id(&bmain->image, (ID *)ima, NULL); } } } @@ -272,58 +272,65 @@ void make_local_tface(Mesh *me) } } +static void expand_local_mesh(Main *bmain, Mesh *me) +{ + id_lib_extern((ID *)me->texcomesh); + + if(me->mtface) { + /* why is this an exception? - should not really make local when extern'ing - campbell */ + make_local_tface(bmain, me); + } + + if(me->mat) { + extern_local_matarar(me->mat, me->totcol); + } +} + void make_local_mesh(Mesh *me) { Main *bmain= G.main; Object *ob; - Mesh *men; int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ - + * - only local users: set flag + * - mixed: make copy + */ + if(me->id.lib==NULL) return; if(me->id.us==1) { me->id.lib= NULL; me->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)me, NULL); - - if(me->mtface) make_local_tface(me); - + + new_id(&bmain->mesh, (ID *)me, NULL); + expand_local_mesh(bmain, me); return; } - - ob= bmain->object.first; - while(ob) { - if( me==get_mesh(ob) ) { + + for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) { + if(me == ob->data) { if(ob->id.lib) lib= 1; else local= 1; } - ob= ob->id.next; } - + if(local && lib==0) { me->id.lib= NULL; me->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)me, NULL); - - if(me->mtface) make_local_tface(me); - + + new_id(&bmain->mesh, (ID *)me, NULL); + expand_local_mesh(bmain, me); } else if(local && lib) { - men= copy_mesh(me); + Mesh *men= copy_mesh(me); men->id.us= 0; - - ob= bmain->object.first; - while(ob) { - if( me==get_mesh(ob) ) { + + for(ob= bmain->object.first; ob; ob= ob->id.next) { + if(me == ob->data) { if(ob->id.lib==NULL) { set_mesh(ob, men); } } - ob= ob->id.next; } } } diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 7c38688c82e..34618a19ae9 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -307,7 +307,9 @@ int BKE_mesh_validate_arrays(Mesh *me, MVert *UNUSED(mverts), unsigned int totve int BKE_mesh_validate(Mesh *me, int do_verbose) { - printf("MESH: %s\n", me->id.name+2); + if(do_verbose) { + printf("MESH: %s\n", me->id.name+2); + } return BKE_mesh_validate_arrays(me, me->mvert, me->totvert, me->medge, me->totedge, me->mface, me->totface, do_verbose, TRUE); } diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index b8b57b6bac0..4b40c07b7a9 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -2244,16 +2244,40 @@ static void group_tag_used_outputs(bNode *gnode, bNodeStack *stack, bNodeStack * } } - /* set stack types (for local stack entries) */ - for(sock= node->outputs.first; sock; sock= sock->next) { - bNodeStack *ns = get_socket_stack(stack, sock, NULL); - if (ns) - ns->sockettype = sock->type; - } - /* non-composite trees do all nodes by default */ if (ntree->type!=NTREE_COMPOSIT) node->need_exec = 1; + + for(sock= node->inputs.first; sock; sock= sock->next) { + bNodeStack *ns = get_socket_stack(stack, sock, gin); + if (ns) { + ns->hasoutput = 1; + + /* sock type is needed to detect rgba or value or vector types */ + if(sock->link && sock->link->fromsock) + ns->sockettype= sock->link->fromsock->type; + else + sock->ns.sockettype= sock->type; + } + + if(sock->link) { + bNodeLink *link= sock->link; + /* this is the test for a cyclic case */ + if(link->fromnode && link->tonode) { + if(link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF); + else { + node->need_exec= 0; + } + } + } + } + + /* set stack types (for local stack entries) */ + for(sock= node->outputs.first; sock; sock= sock->next) { + bNodeStack *ns = get_socket_stack(stack, sock, gin); + if (ns) + ns->sockettype = sock->type; + } } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 00ebf9ff5a8..2721d02eab6 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -97,6 +97,7 @@ #include "BKE_scene.h" #include "BKE_sequencer.h" #include "BKE_softbody.h" +#include "BKE_material.h" #include "LBM_fluidsim.h" @@ -746,51 +747,45 @@ void make_local_camera(Camera *cam) { Main *bmain= G.main; Object *ob; - Camera *camn; int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(cam->id.lib==NULL) return; if(cam->id.us==1) { cam->id.lib= NULL; cam->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)cam, NULL); + new_id(&bmain->camera, (ID *)cam, NULL); return; } - ob= bmain->object.first; - while(ob) { + for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) { if(ob->data==cam) { if(ob->id.lib) lib= 1; else local= 1; } - ob= ob->id.next; } if(local && lib==0) { cam->id.lib= NULL; cam->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)cam, NULL); + new_id(&bmain->camera, (ID *)cam, NULL); } else if(local && lib) { - camn= copy_camera(cam); + Camera *camn= copy_camera(cam); camn->id.us= 0; - ob= bmain->object.first; - while(ob) { - if(ob->data==cam) { - + for(ob= bmain->object.first; ob; ob= ob->id.next) { + if(ob->data == cam) { if(ob->id.lib==NULL) { ob->data= camn; camn->id.us++; cam->id.us--; } } - ob= ob->id.next; } } } @@ -907,7 +902,7 @@ void make_local_lamp(Lamp *la) if(la->id.us==1) { la->id.lib= NULL; la->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)la, NULL); + new_id(&bmain->lamp, (ID *)la, NULL); return; } @@ -923,7 +918,7 @@ void make_local_lamp(Lamp *la) if(local && lib==0) { la->id.lib= NULL; la->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)la, NULL); + new_id(&bmain->lamp, (ID *)la, NULL); } else if(local && lib) { lan= copy_lamp(la); @@ -1376,11 +1371,10 @@ Object *copy_object(Object *ob) return obn; } -void expand_local_object(Object *ob) +static void extern_local_object(Object *ob) { //bActionStrip *strip; ParticleSystem *psys; - int a; #if 0 // XXX old animation system id_lib_extern((ID *)ob->action); @@ -1388,10 +1382,11 @@ void expand_local_object(Object *ob) #endif // XXX old animation system id_lib_extern((ID *)ob->data); id_lib_extern((ID *)ob->dup_group); - - for(a=0; atotcol; a++) { - id_lib_extern((ID *)ob->mat[a]); - } + id_lib_extern((ID *)ob->poselib); + id_lib_extern((ID *)ob->gpd); + + extern_local_matarar(ob->mat, ob->totcol); + #if 0 // XXX old animation system for (strip=ob->nlastrips.first; strip; strip=strip->next) { id_lib_extern((ID *)strip->act); @@ -1404,16 +1399,15 @@ void expand_local_object(Object *ob) void make_local_object(Object *ob) { Main *bmain= G.main; - Object *obn; Scene *sce; Base *base; int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ - + * - only local users: set flag + * - mixed: make copy + */ + if(ob->id.lib==NULL) return; ob->proxy= ob->proxy_from= NULL; @@ -1421,31 +1415,23 @@ void make_local_object(Object *ob) if(ob->id.us==1) { ob->id.lib= NULL; ob->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)ob, NULL); - + new_id(&bmain->object, (ID *)ob, NULL); } else { - sce= bmain->scene.first; - while(sce) { - base= sce->base.first; - while(base) { - if(base->object==ob) { - if(sce->id.lib) lib++; - else local++; - break; - } - base= base->next; + for(sce= bmain->scene.first; sce && ELEM(0, lib, local); sce= sce->id.next) { + if(object_in_scene(ob, sce)) { + if(sce->id.lib) lib= 1; + else local= 1; } - sce= sce->id.next; } - + if(local && lib==0) { ob->id.lib= NULL; ob->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)ob, NULL); + new_id(&bmain->object, (ID *)ob, NULL); } else if(local && lib) { - obn= copy_object(ob); + Object *obn= copy_object(ob); obn->id.us= 0; sce= bmain->scene.first; @@ -1466,7 +1452,7 @@ void make_local_object(Object *ob) } } - expand_local_object(ob); + extern_local_object(ob); } /* @@ -1574,7 +1560,10 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) ob->rotmode= target->rotmode; mul_m4_m4m4(ob->obmat, target->obmat, gob->obmat); if(gob->dup_group) { /* should always be true */ - sub_v3_v3(ob->obmat[3], gob->dup_group->dupli_ofs); + float tvec[3]; + copy_v3_v3(tvec, gob->dup_group->dupli_ofs); + mul_mat3_m4_v3(ob->obmat, tvec); + sub_v3_v3(ob->obmat[3], tvec); } object_apply_mat4(ob, ob->obmat, FALSE, TRUE); } @@ -2570,7 +2559,10 @@ void object_handle_update(Scene *scene, Object *ob) invert_m4_m4(obg->imat, obg->obmat); mul_m4_m4m4(ob->obmat, ob->proxy_from->obmat, obg->imat); if(obg->dup_group) { /* should always be true */ - add_v3_v3(ob->obmat[3], obg->dup_group->dupli_ofs); + float tvec[3]; + copy_v3_v3(tvec, obg->dup_group->dupli_ofs); + mul_mat3_m4_v3(ob->obmat, tvec); + sub_v3_v3(ob->obmat[3], tvec); } } else diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index e80289c75ae..5ec4c36177f 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3030,7 +3030,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) psys->totcached = totpart; - if(psys && psys->lattice){ + if(psys->lattice){ end_latt_deform(psys->lattice); psys->lattice= NULL; } @@ -3589,28 +3589,38 @@ ParticleSettings *psys_copy_settings(ParticleSettings *part) return partn; } +static void expand_local_particlesettings(ParticleSettings *part) +{ + int i; + id_lib_extern((ID *)part->dup_group); + + for(i=0; imtex[i]) id_lib_extern((ID *)part->mtex[i]->tex); + } +} + void make_local_particlesettings(ParticleSettings *part) { + Main *bmain= G.main; Object *ob; - ParticleSettings *par; int local=0, lib=0; /* - only lib users: do nothing - * - only local users: set flag - * - mixed: make copy - */ + * - only local users: set flag + * - mixed: make copy + */ if(part->id.lib==0) return; if(part->id.us==1) { part->id.lib= 0; part->id.flag= LIB_LOCAL; - new_id(0, (ID *)part, 0); + new_id(&bmain->particle, (ID *)part, 0); + expand_local_particlesettings(part); return; } - + /* test objects */ - ob= G.main->object.first; - while(ob) { + for(ob= bmain->object.first; ob && ELEM(0, lib, local); ob= ob->id.next) { ParticleSystem *psys=ob->particlesystem.first; for(; psys; psys=psys->next){ if(psys->part==part) { @@ -3618,31 +3628,28 @@ void make_local_particlesettings(ParticleSettings *part) else local= 1; } } - ob= ob->id.next; } if(local && lib==0) { part->id.lib= 0; part->id.flag= LIB_LOCAL; - new_id(0, (ID *)part, 0); + new_id(&bmain->particle, (ID *)part, 0); + expand_local_particlesettings(part); } else if(local && lib) { - - par= psys_copy_settings(part); - par->id.us= 0; + ParticleSettings *partn= psys_copy_settings(part); + partn->id.us= 0; /* do objects */ - ob= G.main->object.first; - while(ob) { - ParticleSystem *psys=ob->particlesystem.first; - for(; psys; psys=psys->next){ + for(ob= bmain->object.first; ob; ob= ob->id.next) { + ParticleSystem *psys; + for(psys= ob->particlesystem.first; psys; psys=psys->next){ if(psys->part==part && ob->id.lib==0) { - psys->part= par; - par->id.us++; + psys->part= partn; + partn->id.us++; part->id.us--; } } - ob= ob->id.next; } } } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 179aab064b4..64893bb0b5b 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -938,7 +938,7 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p len = ptcache_path(pid, filename); newname += len; } - if(strcmp(pid->cache->name, "")==0 && (pid->cache->flag & PTCACHE_EXTERNAL)==0) { + if(pid->cache->name[0] == '\0' && (pid->cache->flag & PTCACHE_EXTERNAL)==0) { idname = (pid->ob->id.name+2); /* convert chars to hex so they are always a valid filename */ while('\0' != *idname) { @@ -1382,7 +1382,7 @@ static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int * } } - if(pm && !pm2) { + if(!pm2) { *fra1 = 0; *fra2 = pm->frame; } @@ -1844,7 +1844,8 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite) if(cache->flag & PTCACHE_DISK_CACHE) { error += !ptcache_mem_frame_to_disk(pid, pm); - if(pm) { + // if(pm) /* pm is always set */ + { ptcache_data_free(pm); ptcache_extra_free(pm); MEM_freeN(pm); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index b2e6f5290c3..53b66238ec0 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -1858,7 +1858,7 @@ static ImBuf * seq_render_scene_strip_impl( ImBuf * ibuf = NULL; float frame= seq->sfra + nr + seq->anim_startofs; float oldcfra; - Object *oldcamera; + Object *camera; ListBase oldmarkers; /* Old info: @@ -1896,59 +1896,65 @@ static ImBuf * seq_render_scene_strip_impl( int doseq; int doseq_gl= G.rendering ? /*(scene->r.seq_flag & R_SEQ_GL_REND)*/ 0 : /*(scene->r.seq_flag & R_SEQ_GL_PREV)*/ 1; int have_seq= FALSE; - Scene *sce= seq->scene; /* dont refer to seq->scene above this point!, it can be NULL */ - int sce_valid= FALSE; + Scene *scene; - if(sce) { - have_seq= (sce->r.scemode & R_DOSEQ) && sce->ed && sce->ed->seqbase.first; - sce_valid= (sce->camera || have_seq); + /* dont refer to seq->scene above this point!, it can be NULL */ + if(seq->scene == NULL) { + return NULL; } - if (!sce_valid) - return NULL; + scene= seq->scene; - oldcfra= seq->scene->r.cfra; - oldcamera= seq->scene->camera; + have_seq= (scene->r.scemode & R_DOSEQ) && scene->ed && scene->ed->seqbase.first; + + oldcfra= scene->r.cfra; + scene->r.cfra= frame; + + if(seq->scene_camera) + camera= seq->scene_camera; + else { + scene_camera_switch_update(scene); + camera= scene->camera; + } + + if(scene && have_seq==FALSE && camera==NULL) { + scene->r.cfra= oldcfra; + return NULL; + } /* prevent eternal loop */ doseq= context.scene->r.scemode & R_DOSEQ; context.scene->r.scemode &= ~R_DOSEQ; - seq->scene->r.cfra= frame; - if(seq->scene_camera) - seq->scene->camera= seq->scene_camera; - else - scene_camera_switch_update(seq->scene); - #ifdef DURIAN_CAMERA_SWITCH /* stooping to new low's in hackyness :( */ - oldmarkers= seq->scene->markers; - seq->scene->markers.first= seq->scene->markers.last= NULL; + oldmarkers= scene->markers; + scene->markers.first= scene->markers.last= NULL; #endif - if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (seq->scene == context.scene || have_seq==0) && seq->scene->camera) { + if(sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (scene == context.scene || have_seq==0) && camera) { char err_out[256]= "unknown"; /* for old scened this can be uninitialized, should probably be added to do_versions at some point if the functionality stays */ if(context.scene->r.seq_prev_type==0) context.scene->r.seq_prev_type = 3 /* ==OB_SOLID */; /* opengl offscreen render */ - scene_update_for_newframe(context.bmain, seq->scene, seq->scene->lay); - ibuf= sequencer_view3d_cb(seq->scene, context.rectx, context.recty, IB_rect, context.scene->r.seq_prev_type, err_out); + scene_update_for_newframe(context.bmain, scene, scene->lay); + ibuf= sequencer_view3d_cb(scene, camera, context.rectx, context.recty, IB_rect, context.scene->r.seq_prev_type, err_out); if(ibuf == NULL) { fprintf(stderr, "seq_render_scene_strip_impl failed to get opengl buffer: %s\n", err_out); } } else { - Render *re = RE_GetRender(sce->id.name); + Render *re = RE_GetRender(scene->id.name); RenderResult rres; /* XXX: this if can be removed when sequence preview rendering uses the job system */ - if(rendering || context.scene != sce) { + if(rendering || context.scene != scene) { if(re==NULL) - re= RE_NewRender(sce->id.name); + re= RE_NewRender(scene->id.name); - RE_BlenderFrame(re, context.bmain, sce, NULL, sce->lay, frame, FALSE); + RE_BlenderFrame(re, context.bmain, scene, NULL, camera, scene->lay, frame, FALSE); /* restore previous state after it was toggled on & off by RE_BlenderFrame */ G.rendering = rendering; @@ -1981,14 +1987,14 @@ static ImBuf * seq_render_scene_strip_impl( /* restore */ context.scene->r.scemode |= doseq; - seq->scene->r.cfra = oldcfra; - seq->scene->camera= oldcamera; + scene->r.cfra = oldcfra; + if(frame != oldcfra) - scene_update_for_newframe(context.bmain, seq->scene, seq->scene->lay); + scene_update_for_newframe(context.bmain, scene, scene->lay); #ifdef DURIAN_CAMERA_SWITCH /* stooping to new low's in hackyness :( */ - seq->scene->markers= oldmarkers; + scene->markers= oldmarkers; #endif return ibuf; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index b9bf10bdf39..33094313acd 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1541,8 +1541,10 @@ static void ccgDM_drawFacesColored(DerivedMesh *dm, int UNUSED(useTwoSided), uns } glShadeModel(GL_SMOOTH); - if(col1 && col2) + + if(col2) { glEnable(GL_CULL_FACE); + } glBegin(GL_QUADS); for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index db07fae9245..ba5d4282416 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2068,6 +2068,7 @@ void txt_do_redo(Text *text) linep= linep+(text->undo_buf[text->undo_pos]<<8); text->undo_pos++; linep= linep+(text->undo_buf[text->undo_pos]<<16); text->undo_pos++; linep= linep+(text->undo_buf[text->undo_pos]<<24); text->undo_pos++; + (void)linep; break; case UNDO_INDENT: diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index a5412c6269e..866874ee5c8 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -73,7 +73,7 @@ #include "BKE_icons.h" #include "BKE_node.h" #include "BKE_animsys.h" - +#include "BKE_colortools.h" /* ------------------------------------------------------------------------- */ @@ -762,9 +762,8 @@ Tex *copy_texture(Tex *tex) if(texn->coba) texn->coba= MEM_dupallocN(texn->coba); if(texn->env) texn->env= BKE_copy_envmap(texn->env); - if(texn->pd) texn->pd= MEM_dupallocN(texn->pd); + if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); if(texn->vd) texn->vd= MEM_dupallocN(texn->vd); - if(tex->preview) texn->preview = BKE_previewimg_copy(tex->preview); if(tex->nodetree) { @@ -795,14 +794,7 @@ Tex *localize_texture(Tex *tex) texn->env= BKE_copy_envmap(texn->env); id_us_min(&texn->env->ima->id); } - if(texn->pd) { - texn->pd= MEM_dupallocN(texn->pd); - if(texn->pd->coba) { - texn->pd->point_tree = NULL; - texn->pd->coba= MEM_dupallocN(texn->pd->coba); - } - - } + if(texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); if(texn->vd) { texn->vd= MEM_dupallocN(texn->vd); if(texn->vd->dataset) @@ -843,13 +835,13 @@ void make_local_texture(Tex *tex) if(tex->ima) { tex->ima->id.lib= NULL; tex->ima->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)tex->ima, NULL); + new_id(&bmain->image, (ID *)tex->ima, NULL); } if(tex->id.us==1) { tex->id.lib= NULL; tex->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)tex, NULL); + new_id(&bmain->tex, (ID *)tex, NULL); return; } @@ -906,7 +898,7 @@ void make_local_texture(Tex *tex) if(local && lib==0) { tex->id.lib= NULL; tex->id.flag= LIB_LOCAL; - new_id(NULL, (ID *)tex, NULL); + new_id(&bmain->tex, (ID *)tex, NULL); } else if(local && lib) { texn= copy_texture(tex); @@ -1367,6 +1359,13 @@ PointDensity *BKE_add_pointdensity(void) pd->object = NULL; pd->psys = 0; pd->psys_cache_space= TEX_PD_WORLDSPACE; + pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1); + + pd->falloff_curve->preset = CURVE_PRESET_LINE; + pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; + curvemap_reset(pd->falloff_curve->cm, &pd->falloff_curve->clipr, pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE); + curvemapping_changed(pd->falloff_curve, 0); + return pd; } @@ -1378,7 +1377,7 @@ PointDensity *BKE_copy_pointdensity(PointDensity *pd) pdn->point_tree = NULL; pdn->point_data = NULL; if(pdn->coba) pdn->coba= MEM_dupallocN(pdn->coba); - + pdn->falloff_curve = curvemapping_copy(pdn->falloff_curve); /* can be NULL */ return pdn; } @@ -1396,6 +1395,8 @@ void BKE_free_pointdensitydata(PointDensity *pd) MEM_freeN(pd->coba); pd->coba = NULL; } + + curvemapping_free(pd->falloff_curve); /* can be NULL */ } void BKE_free_pointdensity(PointDensity *pd) diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index ff58e8bd0a4..7a76e61c17b 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -43,6 +43,8 @@ #include "DNA_scene_types.h" #include "DNA_texture_types.h" +#include "BLI_utildefines.h" + #include "BKE_world.h" #include "BKE_library.h" #include "BKE_animsys.h" @@ -134,7 +136,6 @@ void make_local_world(World *wrld) { Main *bmain= G.main; Scene *sce; - World *wrldn; int local=0, lib=0; /* - only lib users: do nothing @@ -150,34 +151,30 @@ void make_local_world(World *wrld) return; } - sce= bmain->scene.first; - while(sce) { - if(sce->world==wrld) { + for(sce= bmain->scene.first; sce && ELEM(0, lib, local); sce= sce->id.next) { + if(sce->world == wrld) { if(sce->id.lib) lib= 1; else local= 1; } - sce= sce->id.next; } - + if(local && lib==0) { wrld->id.lib= NULL; wrld->id.flag= LIB_LOCAL; new_id(NULL, (ID *)wrld, NULL); } else if(local && lib) { - wrldn= copy_world(wrld); + World *wrldn= copy_world(wrld); wrldn->id.us= 0; - sce= bmain->scene.first; - while(sce) { - if(sce->world==wrld) { + for(sce= bmain->scene.first; sce; sce= sce->id.next) { + if(sce->world == wrld) { if(sce->id.lib==NULL) { sce->world= wrldn; wrldn->id.us++; wrld->id.us--; } } - sce= sce->id.next; } } } diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 75520bb8ba0..9f6a8afe2d5 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -424,14 +424,14 @@ MINLINE float normalize_v3(float n[3]) return normalize_v3_v3(n, n); } -MINLINE void normal_short_to_float_v3(float *out, const short *in) +MINLINE void normal_short_to_float_v3(float out[3], const short in[3]) { out[0] = in[0]*(1.0f/32767.0f); out[1] = in[1]*(1.0f/32767.0f); out[2] = in[2]*(1.0f/32767.0f); } -MINLINE void normal_float_to_short_v3(short *out, const float *in) +MINLINE void normal_float_to_short_v3(short out[3], const float in[3]) { out[0] = (short)(in[0]*32767.0f); out[1] = (short)(in[1]*32767.0f); diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 891dc47b4ae..22083eda1c8 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -148,7 +148,7 @@ BLO_blendhandle_from_memory( * * @param bh The blendhandle to access. * @param ofblocktype The type of names to get. - * @param totnames The length of the returned list. + * @param tot_names The length of the returned list. * @return A BLI_linklist of strings. The string links * should be freed with malloc. */ @@ -156,7 +156,7 @@ BLO_blendhandle_from_memory( BLO_blendhandle_get_datablock_names( BlendHandle *bh, int ofblocktype, - int *totnames); + int *tot_names); /** * Gets the previews of all the datablocks in a file @@ -165,13 +165,15 @@ BLO_blendhandle_get_datablock_names( * * @param bh The blendhandle to access. * @param ofblocktype The type of names to get. + * @param tot_prev The length of the returned list. * @return A BLI_linklist of PreviewImage. The PreviewImage links * should be freed with malloc. */ struct LinkNode* BLO_blendhandle_get_previews( BlendHandle *bh, - int ofblocktype); + int ofblocktype, + int *tot_prev); /** * Gets the names of all the datablock groups in a diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index ae4ba6629a6..abc469a5355 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -144,7 +144,7 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype, return names; } -LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype) +LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *tot_prev) { FileData *fd= (FileData*) bh; LinkNode *previews= NULL; @@ -153,6 +153,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype) int npreviews = 0; PreviewImage* prv = NULL; PreviewImage* new_prv = NULL; + int tot= 0; for (bhead= blo_firstbhead(fd); bhead; bhead= blo_nextbhead(fd, bhead)) { if (bhead->code==ofblocktype) { @@ -166,6 +167,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype) case ID_LA: /* fall through */ new_prv = MEM_callocN(sizeof(PreviewImage), "newpreview"); BLI_linklist_prepend(&previews, new_prv); + tot++; looking = 1; break; default: @@ -213,7 +215,8 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype) } } - + + *tot_prev= tot; return previews; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 55577f54889..b4ae2c77f0c 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2964,6 +2964,10 @@ static void direct_link_texture(FileData *fd, Tex *tex) if(tex->pd) { tex->pd->point_tree = NULL; tex->pd->coba= newdataadr(fd, tex->pd->coba); + tex->pd->falloff_curve= newdataadr(fd, tex->pd->falloff_curve); + if(tex->pd->falloff_curve) { + direct_link_curvemapping(fd, tex->pd->falloff_curve); + } } tex->vd= newdataadr(fd, tex->vd); @@ -11741,7 +11745,57 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* put compatibility code here until next subversion bump */ { + /* screen view2d settings were not properly initialized [#27164] + * v2d->scroll caused the bug but best reset other values too which are in old blend files only. + * need to make less ugly - possibly an iterator? */ + bScreen *screen; + for(screen= main->screen.first; screen; screen= screen->id.next) { + ScrArea *sa; + /* add regions */ + for(sa= screen->areabase.first; sa; sa= sa->next) { + SpaceLink *sl= sa->spacedata.first; + if(sl->spacetype==SPACE_IMAGE) { + ARegion *ar; + for (ar=sa->regionbase.first; ar; ar= ar->next) { + if(ar->regiontype == RGN_TYPE_WINDOW) { + View2D *v2d= &ar->v2d; + v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0; + } + } + } + for (sl= sa->spacedata.first; sl; sl= sl->next) { + if(sl->spacetype==SPACE_IMAGE) { + ARegion *ar; + for (ar=sl->regionbase.first; ar; ar= ar->next) { + if(ar->regiontype == RGN_TYPE_WINDOW) { + View2D *v2d= &ar->v2d; + v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0; + } + } + } + } + } + } + { + /* Initialize texture point density curve falloff */ + Tex *tex; + for(tex= main->tex.first; tex; tex= tex->id.next) { + if(tex->pd) { + if (tex->pd->falloff_speed_scale == 0.0) + tex->pd->falloff_speed_scale = 100.0; + + if (!tex->pd->falloff_curve) { + tex->pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1); + + tex->pd->falloff_curve->preset = CURVE_PRESET_LINE; + tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; + curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE); + curvemapping_changed(tex->pd->falloff_curve, 0); + } + } + } + } } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 168803ed689..e0b773a5eb5 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -1699,6 +1699,7 @@ static void write_textures(WriteData *wd, ListBase *idbase) if(tex->type == TEX_POINTDENSITY && tex->pd) { writestruct(wd, DATA, "PointDensity", 1, tex->pd); if(tex->pd->coba) writestruct(wd, DATA, "ColorBand", 1, tex->pd->coba); + if(tex->pd->falloff_curve) write_curvemapping(wd, tex->pd->falloff_curve); } if(tex->type == TEX_VOXELDATA && tex->vd) writestruct(wd, DATA, "VoxelData", 1, tex->vd); diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index 0d822c63094..51caf62f6e7 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -38,6 +38,11 @@ extern "C" #include "BKE_scene.h" #include "BKE_context.h" +/* make dummy file */ +#include "BLI_storage.h" +#include "BLI_path_util.h" +#include "BLI_fileops.h" + int collada_import(bContext *C, const char *filepath) { DocumentImporter imp (C, filepath); @@ -48,8 +53,17 @@ extern "C" int collada_export(Scene *sce, const char *filepath) { - DocumentExporter exp; + + /* annoying, collada crashes if file cant be created! [#27162] */ + if(!BLI_exist(filepath)) { + BLI_make_existing_file(filepath); /* makes the dir if its not there */ + if(BLI_touch(filepath) == 0) { + return 0; + } + } + /* end! */ + exp.exportCurrentScene(sce, filepath); return 1; diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 874dc2237e5..a9f586d50dc 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3353,6 +3353,7 @@ void ANIM_channel_draw_widgets (bAnimContext *ac, bAnimListElem *ale, uiBlock *b draw_setting_widget(ac, ale, acf, block, offset, ymid, ACHANNEL_SETTING_SOLO); offset += ICON_WIDTH; } + (void)offset; } /* step 4) draw text... */ diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index adb011e92be..7a8f8129449 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -169,9 +169,9 @@ void ANIM_set_active_channel (bAnimContext *ac, void *data, short datatype, int case ANIMTYPE_DSLAT: { /* need to verify that this data is valid for now */ - // XXX: ale may be null! - if (ale->adt) + if (ale && ale->adt) { ale->adt->flag |= ADT_UI_ACTIVE; + } } break; } @@ -1003,7 +1003,7 @@ static void rearrange_action_channels (bAnimContext *ac, bAction *act, short mod for (agrp= act->groups.first; agrp; agrp= agrp->next) { /* only consider F-Curves if they're visible (group expanded) */ - if (EXPANDED_AGRP(agrp)) { + if (EXPANDED_AGRP(ac, agrp)) { rearrange_animchannel_islands(&agrp->channels, rearrange_func, mode, ANIMTYPE_FCURVE); } } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 54c6c991a5f..be2b6cf9a76 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -1031,7 +1031,7 @@ static int animdata_filter_action (bAnimContext *ac, ListBase *anim_data, bDopeS * but the group isn't expanded... */ if ( (filter_mode & (ANIMFILTER_SEL|ANIMFILTER_UNSEL)) && /* care about selection status */ - (EXPANDED_AGRP(agrp)==0) ) /* group isn't expanded */ + (EXPANDED_AGRP(ac, agrp)==0) ) /* group isn't expanded */ { /* if the group itself isn't selected appropriately, we shouldn't consider it's children either */ if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0) @@ -1090,7 +1090,7 @@ static int animdata_filter_action (bAnimContext *ac, ListBase *anim_data, bDopeS * - group is expanded * - we just need the F-Curves present */ - if ( (!(filter_mode & ANIMFILTER_VISIBLE) || EXPANDED_AGRP(agrp)) || (filter_mode & ANIMFILTER_CURVESONLY) ) + if ( (!(filter_mode & ANIMFILTER_VISIBLE) || EXPANDED_AGRP(ac, agrp)) || (filter_mode & ANIMFILTER_CURVESONLY) ) { /* for the Graph Editor, curves may be set to not be visible in the view to lessen clutter, * but to do this, we need to check that the group doesn't have it's not-visible flag set preventing diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index f0f33ec3258..f4e9c7c5d3e 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -804,7 +804,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann for (ct= targets.first; ct; ct= ct->next) { if (ct->tar == srcArm) { - if (strcmp(ct->subtarget, "")==0) { + if (ct->subtarget[0] == '\0') { ct->tar = tarArm; } else if (strcmp(ct->subtarget, pchan->name)==0) { @@ -851,7 +851,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann for (ct= targets.first; ct; ct= ct->next) { if (ct->tar == srcArm) { - if (strcmp(ct->subtarget, "")==0) { + if (ct->subtarget[0] == '\0') { ct->tar = tarArm; } else if (strcmp(ct->subtarget, pchan->name)==0) { diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 1ab7acef861..cb73f20fe7b 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -951,7 +951,7 @@ static void calc_shapeKeys(Object *obedit) ++i; } - fp+= 3; curofp+= 3; /* alphas */ + fp+= 3; /* alphas */ } else { for (j= 0; j < 3; ++j, ++i) { VECCOPY(fp, bezt->vec[j]); @@ -1234,7 +1234,6 @@ void make_editNurb(Object *obedit) Nurb *nu, *newnu, *nu_act= NULL; KeyBlock *actkey; - if(obedit==NULL) return; set_actNurb(obedit, NULL); @@ -1591,7 +1590,7 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) BPoint *bp, *bpn, *newbp; int a, b, newu, newv, sel; - if(obedit && obedit->type==OB_SURF); + if(obedit->type==OB_SURF); else return OPERATOR_CANCELLED; cu->lastsel= NULL; @@ -5662,7 +5661,7 @@ static int delete_exec(bContext *C, wmOperator *op) Curve *cu= obedit->data; EditNurb *editnurb= cu->editnurb; ListBase *nubase= &editnurb->nurbs; - Nurb *nu, *next, *nu1; + Nurb *nu, *nu1; BezTriple *bezt, *bezt1, *bezt2; BPoint *bp, *bp1, *bp2; int a, cut= 0, type= RNA_enum_get(op->ptr, "type"); @@ -5687,6 +5686,7 @@ static int delete_exec(bContext *C, wmOperator *op) if(type==0) { /* first loop, can we remove entire pieces? */ + Nurb *next; nu= nubase->first; while(nu) { next= nu->next; @@ -5815,7 +5815,6 @@ static int delete_exec(bContext *C, wmOperator *op) nu1= NULL; nuindex= 0; for(nu= nubase->first; nu; nu= nu->next) { - next= nu->next; if(nu->type == CU_BEZIER) { bezt= nu->bezt; for(a=0; apntsu-1; a++) { diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 77b46f8864b..620d1dc51ed 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -253,7 +253,7 @@ typedef enum eAnimFilter_Flags { /* Actions (also used for Dopesheet) */ /* Action Channel Group */ #define EDITABLE_AGRP(agrp) ((agrp->flag & AGRP_PROTECTED)==0) -#define EXPANDED_AGRP(agrp) \ +#define EXPANDED_AGRP(ac, agrp) \ ( ( ((ac)->spacetype == SPACE_IPO) && (agrp->flag & AGRP_EXPANDED_G) ) || \ ( ((ac)->spacetype != SPACE_IPO) && (agrp->flag & AGRP_EXPANDED) ) ) #define SEL_AGRP(agrp) ((agrp->flag & AGRP_SELECTED) || (agrp->flag & AGRP_ACTIVE)) diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index a3e99e6358e..297bd234edd 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -163,6 +163,8 @@ int lasso_inside_edge(short mcords[][2], short moves, int x0, int y0, int x1, in /* get 3d region from context, also if mouse is in header or toolbar */ struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C); +struct ARegion *ED_view3d_context_region_unlock(struct bContext *C); +int ED_operator_rv3d_unlock_poll(struct bContext *C); void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d); @@ -173,7 +175,7 @@ void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct AR int winx, int winy, float viewmat[][4], float winmat[][4]); struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int sizex, int sizey, unsigned int flag, char err_out[256]); -struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, unsigned int flag, int drawtype, char err_out[256]); +struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, struct Object *camera, int width, int height, unsigned int flag, int drawtype, char err_out[256]); Base *ED_view3d_give_base_under_cursor(struct bContext *C, const short mval[2]); @@ -183,5 +185,11 @@ int ED_view3d_lock(struct RegionView3D *rv3d); unsigned int ED_view3d_datamask(struct Scene *scene, struct View3D *v3d); unsigned int ED_viewedit_datamask(struct bScreen *screen); + +/* assigning view matrix */ +void view3d_apply_mat4(float mat[][4], float *ofs, float *quat, float *dist); +void view3d_apply_ob(struct Object *ob, float *ofs, float *quat, float *dist, float *lens); +int view3d_is_ortho(struct View3D *v3d, struct RegionView3D *rv3d); + #endif /* ED_VIEW3D_H */ diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index f8ce278814f..c9b5b9f2848 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -765,8 +765,6 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol) //float alpha; GLint scissor[4]; - if (hist==NULL) { printf("hist is null \n"); return; } - rect.xmin = (float)recti->xmin+1; rect.xmax = (float)recti->xmax-1; rect.ymin = (float)recti->ymin+SCOPE_RESIZE_PAD+2; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 1a240f34757..aa5499110e6 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -362,6 +362,16 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) /* create tooltip data */ data= MEM_callocN(sizeof(uiTooltipData), "uiTooltipData"); + /* special case, enum rna buttons only have enum item description, use general enum description too before the spesific one */ + if(but->rnaprop && RNA_property_type(but->rnaprop) == PROP_ENUM) { + const char *descr= RNA_property_description(but->rnaprop); + if(descr && descr[0]) { + BLI_strncpy(data->lines[data->totline], descr, sizeof(data->lines[0])); + data->color[data->totline]= 0xFFFFFF; + data->totline++; + } + } + if(but->tip && strlen(but->tip)) { BLI_strncpy(data->lines[data->totline], but->tip, sizeof(data->lines[0])); data->color[data->totline]= 0xFFFFFF; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 60afb6ce2c9..7648d5067b4 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -673,6 +673,22 @@ static int modifier_can_delete(ModifierData *md) return 1; } +// Check wheter Modifier is a simulation or not, this is used for switching to the physics/particles context tab +static int modifier_is_simulation(ModifierData *md) +{ + // Physic Tab + if(ELEM6(md->type, eModifierType_Cloth, eModifierType_Collision, eModifierType_Fluidsim, eModifierType_Smoke, eModifierType_Softbody, eModifierType_Surface)) { + return 1; + } + // Particle Tab + else if (md->type == eModifierType_ParticleSystem) { + return 2; + } + else { + return 0; + } +} + static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, ModifierData *md, int index, int cageIndex, int lastCageIndex) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -765,8 +781,13 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, Modif uiBlockEndAlign(block); uiBlockSetEmboss(block, UI_EMBOSSN); - if (modifier_can_delete(md)) + // When Modifier is a simulation, show button to switch to context rather than the delete button. + if (modifier_can_delete(md) && !modifier_is_simulation(md)) uiItemO(row, "", ICON_X, "OBJECT_OT_modifier_remove"); + if (modifier_is_simulation(md) == 1) + uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PHYSICS"); + else if (modifier_is_simulation(md) == 2) + uiItemStringO(row, "", ICON_BUTS, "WM_OT_properties_context_change", "context", "PARTICLES"); uiBlockSetEmboss(block, UI_EMBOSS); } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 90a83009c4d..09e4b153d98 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -575,19 +575,17 @@ static void shadecolors4(char *coltop, char *coldown, const char *color, short s coldown[3]= color[3]; } -static void round_box_shade_col4(const char *col1, const char *col2, float fac) +static void round_box_shade_col4(const char col1[4], const char col2[4], const float fac) { - int faci, facm; unsigned char col[4]; - - faci= floor(255.1f*fac); - facm= 255-faci; - + const int faci= FTOCHAR(fac); + const int facm= 255-faci; + col[0]= (faci*col1[0] + facm*col2[0])>>8; col[1]= (faci*col1[1] + facm*col2[1])>>8; col[2]= (faci*col1[2] + facm*col2[2])>>8; col[3]= (faci*col1[3] + facm*col2[3])>>8; - + glColor4ubv(col); } @@ -2316,7 +2314,7 @@ static void widget_numslider(uiBut *but, uiWidgetColors *wcol, rcti *rect, int s double value; float offs, toffs, fac; char outline[3]; - + widget_init(&wtb); widget_init(&wtb1); diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index b3492a5fb09..fa3619883f4 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -90,21 +90,21 @@ static float icovert[12][3] = { {0.0f,0.0f,200.0f} }; static short icoface[20][3] = { - {1,0,2}, + {2,0,1}, {1,0,5}, - {2,0,3}, - {3,0,4}, - {4,0,5}, + {3,0,2}, + {4,0,3}, + {5,0,4}, {1,5,10}, {2,1,6}, {3,2,7}, {4,3,8}, {5,4,9}, - {10,1,6}, - {6,2,7}, - {7,3,8}, - {8,4,9}, - {9,5,10}, + {6,1,10}, + {7,2,6}, + {8,3,7}, + {9,4,8}, + {10,5,9}, {6,10,11}, {7,6,11}, {8,7,11}, @@ -1081,6 +1081,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se } eve= eve->next; } + recalc_editnormals(em); break; case PRIM_UVSPHERE: /* UVsphere */ @@ -1102,7 +1103,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se eve= addvertlist(em, vec, NULL); eve->f= 1+2+4; if(a==0) v1= eve; - else addedgelist(em, eve->prev, eve, NULL); + else addedgelist(em, eve, eve->prev, NULL); phi+= phid; } @@ -1128,6 +1129,7 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se } eve= eve->next; } + recalc_editnormals(em); break; case PRIM_ICOSPHERE: /* Icosphere */ { @@ -1320,9 +1322,9 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se EM_stats_update(em); /* simple selection flush OK, based on fact it's a single model */ EM_select_flush(em); /* flushes vertex -> edge -> face selection */ - - if(type!=PRIM_PLANE && type!=PRIM_MONKEY) - EM_recalc_normal_direction(em, 0, 0); /* otherwise monkey has eyes in wrong direction */ + + if(!ELEM5(type, PRIM_GRID, PRIM_PLANE, PRIM_ICOSPHERE, PRIM_UVSPHERE, PRIM_MONKEY)) + EM_recalc_normal_direction(em, FALSE, TRUE); /* otherwise monkey has eyes in wrong direction */ BKE_mesh_end_editmesh(obedit->data, em); } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 5901a36980c..a66c72bf329 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -891,13 +891,11 @@ void MESH_OT_split(wmOperatorType *ot) } -static int extrude_repeat_mesh(bContext *C, wmOperator *op) +static int extrude_repeat_mesh_exec(bContext *C, wmOperator *op) { Object *obedit= CTX_data_edit_object(C); EditMesh *em= BKE_mesh_get_editmesh((Mesh *)obedit->data); - RegionView3D *rv3d = ED_view3d_context_rv3d(C); - int steps = RNA_int_get(op->ptr,"steps"); float offs = RNA_float_get(op->ptr,"offset"); @@ -906,9 +904,7 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op) short a; /* dvec */ - dvec[0]= rv3d->persinv[2][0]; - dvec[1]= rv3d->persinv[2][1]; - dvec[2]= rv3d->persinv[2][2]; + RNA_float_get_array(op->ptr, "direction", dvec); normalize_v3(dvec); dvec[0]*= offs; dvec[1]*= offs; @@ -935,6 +931,17 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +/* get center and axis, in global coords */ +static int extrude_repeat_mesh_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + RegionView3D *rv3d= ED_view3d_context_rv3d(C); + + if(rv3d) + RNA_float_set_array(op->ptr, "direction", rv3d->persinv[2]); + + return extrude_repeat_mesh_exec(C, op); +} + void MESH_OT_extrude_repeat(wmOperatorType *ot) { /* identifiers */ @@ -943,15 +950,17 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot) ot->idname= "MESH_OT_extrude_repeat"; /* api callbacks */ - ot->exec= extrude_repeat_mesh; - ot->poll= ED_operator_editmesh_region_view3d; + ot->invoke= extrude_repeat_mesh_invoke; + ot->exec= extrude_repeat_mesh_exec; + ot->poll= ED_operator_editmesh; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* props */ - RNA_def_float(ot->srna, "offset", 2.0f, 0.0f, 100.0f, "Offset", "", 0.0f, FLT_MAX); - RNA_def_int(ot->srna, "steps", 10, 0, 180, "Steps", "", 0, INT_MAX); + RNA_def_float(ot->srna, "offset", 2.0f, 0.0f, 100.0f, "Offset", "", 0.0f, 100.0f); + RNA_def_int(ot->srna, "steps", 10, 0, 180, "Steps", "", 0, 180); + RNA_def_float_vector(ot->srna, "direction", 3, NULL, -FLT_MAX, FLT_MAX, "Direction", "Direction of extrude", -FLT_MAX, FLT_MAX); } /* ************************** spin operator ******************** */ diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index b6940e8f8f9..f3e26cfee36 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -163,6 +163,17 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la } } +static void copy_editface_active_customdata(EditMesh *em, int type, int index) +{ + EditFace *efa; + int n= CustomData_get_active_layer(&em->fdata, type); + + for(efa= em->faces.first; efa; efa= efa->next) { + void *data= CustomData_em_get_n(&em->fdata, efa->data, type, n); + CustomData_em_set_n(&em->fdata, efa->data, type, index, data); + } +} + int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_set) { EditMesh *em; @@ -176,6 +187,10 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s return 0; EM_add_data_layer(em, &em->fdata, CD_MTFACE, name); + + if(layernum) /* copy data from active UV */ + copy_editface_active_customdata(em, CD_MTFACE, layernum); + if(active_set || layernum==0) CustomData_set_layer_active(&em->fdata, CD_MTFACE, layernum); } @@ -234,6 +249,10 @@ int ED_mesh_color_add(bContext *C, Scene *scene, Object *ob, Mesh *me, const cha return 0; EM_add_data_layer(em, &em->fdata, CD_MCOL, name); + + if(layernum) /* copy data from active vertex color layer */ + copy_editface_active_customdata(em, CD_MCOL, layernum); + if(active_set || layernum==0) CustomData_set_layer_active(&em->fdata, CD_MCOL, layernum); } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index cf3ad26ec25..763e82b8b53 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -226,8 +226,9 @@ int join_mesh_exec(bContext *C, wmOperator *op) } if(b==totcol) { matar[b]= ma; - if(ma) - ma->id.us++; + if(ma) { + id_us_plus(&ma->id); + } totcol++; } if(totcol>=MAXMAT-1) diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index ce434413a5f..3890eedeb57 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -421,6 +421,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) unsigned int lay= (v3d)? v3d->lay: scene->lay; const short is_animation= RNA_boolean_get(op->ptr, "animation"); const short is_write_still= RNA_boolean_get(op->ptr, "write_still"); + struct Object *camera_override= v3d ? V3D_CAMERA_LOCAL(v3d) : NULL; if(!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.imtype)) { BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected."); @@ -446,9 +447,9 @@ static int screen_render_exec(bContext *C, wmOperator *op) seq_stripelem_cache_cleanup(); if(is_animation) - RE_BlenderAnim(re, mainp, scene, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports); + RE_BlenderAnim(re, mainp, scene, camera_override, lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, op->reports); else - RE_BlenderFrame(re, mainp, scene, NULL, lay, scene->r.cfra, is_write_still); + RE_BlenderFrame(re, mainp, scene, NULL, camera_override, lay, scene->r.cfra, is_write_still); // no redraw needed, we leave state as we entered it ED_update_for_newframe(mainp, scene, CTX_wm_screen(C), 1); @@ -464,6 +465,7 @@ typedef struct RenderJob { Render *re; wmWindow *win; SceneRenderLayer *srl; + struct Object *camera_override; int lay; short anim, write_still; Image *image; @@ -590,9 +592,9 @@ static void render_startjob(void *rjv, short *stop, short *do_update, float *pro rj->progress= progress; if(rj->anim) - RE_BlenderAnim(rj->re, rj->main, rj->scene, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports); + RE_BlenderAnim(rj->re, rj->main, rj->scene, rj->camera_override, rj->lay, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->r.frame_step, rj->reports); else - RE_BlenderFrame(rj->re, rj->main, rj->scene, rj->srl, rj->lay, rj->scene->r.cfra, rj->write_still); + RE_BlenderFrame(rj->re, rj->main, rj->scene, rj->srl, rj->camera_override, rj->lay, rj->scene->r.cfra, rj->write_still); } static void render_endjob(void *rjv) @@ -679,12 +681,13 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) int jobflag; const short is_animation= RNA_boolean_get(op->ptr, "animation"); const short is_write_still= RNA_boolean_get(op->ptr, "write_still"); + struct Object *camera_override= v3d ? V3D_CAMERA_LOCAL(v3d) : NULL; /* only one render job at a time */ if(WM_jobs_test(CTX_wm_manager(C), scene)) return OPERATOR_CANCELLED; - if(!RE_is_rendering_allowed(scene, op->reports, render_error_reports)) { + if(!RE_is_rendering_allowed(scene, camera_override, op->reports, render_error_reports)) { return OPERATOR_CANCELLED; } @@ -761,6 +764,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) rj->scene= scene; rj->win= CTX_wm_window(C); rj->srl = srl; + rj->camera_override = camera_override; rj->lay = (v3d)? v3d->lay: scene->lay; rj->anim= is_animation; rj->write_still= is_write_still && !is_animation; diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 364b0805237..626fbce1b2e 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -114,6 +114,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) View3D *v3d= oglrender->v3d; RegionView3D *rv3d= oglrender->rv3d; RenderResult *rr; + Object *camera= NULL; ImBuf *ibuf; void *lock; float winmat[4][4]; @@ -140,7 +141,8 @@ static void screen_opengl_render_apply(OGLRender *oglrender) /* render 3d view */ if(rv3d->persp==RV3D_CAMOB && v3d->camera) { /*int is_ortho= scene->r.mode & R_ORTHO;*/ - RE_GetCameraWindow(oglrender->re, v3d->camera, scene->r.cfra, winmat); + camera= v3d->camera; + RE_GetCameraWindow(oglrender->re, camera, scene->r.cfra, winmat); } else { @@ -190,7 +192,8 @@ static void screen_opengl_render_apply(OGLRender *oglrender) else { /* shouldnt suddenly give errors mid-render but possible */ char err_out[256]= "unknown"; - ImBuf *ibuf_view= ED_view3d_draw_offscreen_imbuf_simple(scene, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, err_out); + ImBuf *ibuf_view= ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, oglrender->sizex, oglrender->sizey, IB_rectfloat, OB_SOLID, err_out); + camera= scene->camera; if(ibuf_view) { memcpy(rr->rectf, ibuf_view->rect_float, sizeof(float) * 4 * oglrender->sizex * oglrender->sizey); @@ -204,7 +207,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) /* rr->rectf is now filled with image data */ if((scene->r.stamp & R_STAMP_ALL) && (scene->r.stamp & R_STAMP_DRAW)) - BKE_stamp_buf(scene, NULL, rr->rectf, rr->rectx, rr->recty, 4); + BKE_stamp_buf(scene, camera, NULL, rr->rectf, rr->rectx, rr->recty, 4); RE_ReleaseResult(oglrender->re); @@ -218,7 +221,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) char name[FILE_MAX]; int ok; BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, FALSE); - ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); + ok= BKE_write_ibuf(ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); /* no need to stamp here */ if(ok) printf("OpenGL Render written to '%s'\n", name); else printf("OpenGL Render failed to write '%s'\n", name); } @@ -387,6 +390,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) char name[FILE_MAXDIR+FILE_MAXFILE]; int ok= 0; const short view_context= (oglrender->v3d != NULL); + Object *camera= NULL; /* update animated image textures for gpu, etc, * call before scene_update_for_newframe so modifiers with textuers dont lag 1 frame */ @@ -409,12 +413,17 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) if(oglrender->rv3d->persp==RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) { /* since scene_update_for_newframe() is used rather * then ED_update_for_newframe() the camera needs to be set */ - if(scene_camera_switch_update(scene)) + if(scene_camera_switch_update(scene)) { oglrender->v3d->camera= scene->camera; + } + + camera= oglrender->v3d->camera; } } else { scene_camera_switch_update(scene); + + camera= scene->camera; } /* render into offscreen buffer */ @@ -433,7 +442,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) } else { BKE_makepicstring(name, scene->r.pic, scene->r.cfra, scene->r.imtype, scene->r.scemode & R_EXTENSION, TRUE); - ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); + ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); if(ok==0) { printf("Write error: cannot save %s\n", name); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 239b078a910..1abf5df223c 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -135,14 +135,15 @@ ImBuf* get_brush_icon(Brush *brush) if (path[0]) brush->icon_imbuf= IMB_loadiffname(path, flags); } + + if (brush->icon_imbuf) + BKE_icon_changed(BKE_icon_getid(&brush->id)); } } } if (!(brush->icon_imbuf)) brush->id.icon_id = 0; - else - BKE_icon_changed(BKE_icon_getid(&(brush->id))); return brush->icon_imbuf; } @@ -313,15 +314,6 @@ void ED_preview_free_dbase(void) free_main(pr_main); } -static Object *find_object(ListBase *lb, const char *name) -{ - Object *ob; - for(ob= lb->first; ob; ob= ob->id.next) - if(strcmp(ob->id.name+2, name)==0) - break; - return ob; -} - static int preview_mat_has_sss(Material *mat, bNodeTree *ntree) { if(mat) { @@ -528,12 +520,12 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre if(la && la->type==LA_SUN && (la->sun_effect_type & LA_SUN_EFFECT_SKY)) { sce->lay= 1<world= scene->world; - sce->camera= (Object *)find_object(&pr_main->object, "CameraAtmo"); + sce->camera= (Object *)BLI_findstring(&pr_main->object, "CameraAtmo", offsetof(ID, name)+2); } else { sce->lay= 1<world= NULL; - sce->camera= (Object *)find_object(&pr_main->object, "Camera"); + sce->camera= (Object *)BLI_findstring(&pr_main->object, "Camera", offsetof(ID, name)+2); } sce->r.mode &= ~R_SHADOW; @@ -1256,10 +1248,11 @@ static void icon_preview_startjob(void *customdata, short *stop, short *do_updat br->icon_imbuf= get_brush_icon(br); + memset(sp->pr_rect, 0x888888, sp->sizex*sp->sizey*sizeof(unsigned int)); + if(!(br->icon_imbuf) || !(br->icon_imbuf->rect)) return; - memset(sp->pr_rect, 0x888888, sp->sizex*sp->sizey*sizeof(unsigned int)); icon_copy_rect(br->icon_imbuf, sp->sizex, sp->sizey, sp->pr_rect); *do_update= 1; diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 60b679a38ef..5fde1652243 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -1337,7 +1337,7 @@ static int save_envmap(wmOperator *op, Scene *scene, EnvMap *env, char *str, int /* to save, we first get absolute path */ BLI_path_abs(str, G.main->name); - if (BKE_write_ibuf(scene, ibuf, str, imtype, scene->r.subimtype, scene->r.quality)) { + if (BKE_write_ibuf(ibuf, str, imtype, scene->r.subimtype, scene->r.quality)) { retval = OPERATOR_FINISHED; } else { diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index a0a2ede11ef..e942cfc8b1f 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1133,7 +1133,10 @@ void ED_area_exit(bContext *C, ScrArea *sa) ARegion *ar; if (sa->spacetype == SPACE_FILE) { - ED_fileselect_exit(C, (SpaceFile*)(sa) ? sa->spacedata.first : CTX_wm_space_data(C)); + SpaceLink *sl= sa->spacedata.first; + if(sl && sl->spacetype == SPACE_FILE) { + ED_fileselect_exit(C, (SpaceFile *)sl); + } } CTX_wm_area_set(C, sa); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 56a27da54df..b5f980ab7cb 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1871,6 +1871,8 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot) static int screen_set_exec(bContext *C, wmOperator *op) { bScreen *screen= CTX_wm_screen(C); + bScreen *screen_prev= screen; + ScrArea *sa= CTX_wm_area(C); int tot= BLI_countlist(&CTX_data_main(C)->screen); int delta= RNA_int_get(op->ptr, "delta"); @@ -1879,15 +1881,11 @@ static int screen_set_exec(bContext *C, wmOperator *op) if(screen->temp) return OPERATOR_CANCELLED; - /* return to previous state before switching screens */ - if(sa && sa->full) - ED_screen_full_restore(C, sa); - if(delta==1) { while(tot--) { screen= screen->id.next; if(screen==NULL) screen= CTX_data_main(C)->screen.first; - if(screen->winid==0 && screen->full==0) + if(screen->winid==0 && screen->full==0 && screen != screen_prev) break; } } @@ -1895,7 +1893,7 @@ static int screen_set_exec(bContext *C, wmOperator *op) while(tot--) { screen= screen->id.prev; if(screen==NULL) screen= CTX_data_main(C)->screen.last; - if(screen->winid==0 && screen->full==0) + if(screen->winid==0 && screen->full==0 && screen != screen_prev) break; } } @@ -1903,7 +1901,12 @@ static int screen_set_exec(bContext *C, wmOperator *op) screen= NULL; } - if(screen) { + if(screen && screen_prev != screen) { + /* return to previous state before switching screens */ + if(sa && sa->full) { + ED_screen_full_restore(C, sa); /* may free 'screen_prev' */ + } + ED_screen_set(C, screen); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index c38544fdc37..7bc56879a0f 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -95,7 +95,7 @@ static int screenshot_exec(bContext *C, wmOperator *op) ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); ibuf->rect= scd->dumprect; - BKE_write_ibuf(scene, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality); + BKE_write_ibuf(ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality); IMB_freeImBuf(ibuf); @@ -280,7 +280,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float BKE_makepicstring(name, rd.pic, cfra, rd.imtype, rd.scemode & R_EXTENSION, TRUE); ibuf->rect= sj->dumprect; - ok= BKE_write_ibuf(sj->scene, ibuf, name, rd.imtype, rd.subimtype, rd.quality); + ok= BKE_write_ibuf(ibuf, name, rd.imtype, rd.subimtype, rd.quality); if(ok==0) { printf("Write error: cannot save %s\n", name); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 3b4b828d0f6..577e9739537 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -517,9 +517,6 @@ void ED_keymap_paint(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", RKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.use_rake"); - kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", AKEY, KM_PRESS, KM_SHIFT, 0); - RNA_string_set(kmi->ptr, "data_path", "tool_settings.sculpt.brush.use_airbrush"); - /* Vertex Paint mode */ keymap= WM_keymap_find(keyconf, "Vertex Paint", 0, 0); keymap->poll= vertex_paint_mode_poll; diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 4eddeaaaf9f..5d786c1d00b 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -854,7 +854,7 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) folderlist_pushdir(sfile->folders_prev, sfile->params->dir); folderlist_popdir(sfile->folders_next, sfile->params->dir); - // update folder_prev so we can check for it in folderlist_clear_next() + // update folders_prev so we can check for it in folderlist_clear_next() folderlist_pushdir(sfile->folders_prev, sfile->params->dir); file_change_dir(C, 1); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index f0ffe34476f..0a8ae56c291 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -469,13 +469,12 @@ int folderlist_clear_next(struct SpaceFile *sfile) /* not listbase itself */ void folderlist_free(ListBase* folderlist) { - FolderList *folder; if (folderlist){ + FolderList *folder; for(folder= folderlist->first; folder; folder= folder->next) MEM_freeN(folder->foldername); BLI_freelistN(folderlist); } - folderlist= NULL; } ListBase *folderlist_duplicate(ListBase* folderlist) @@ -1007,7 +1006,7 @@ void filelist_from_library(struct FileList* filelist) { LinkNode *l, *names, *previews; struct ImBuf* ima; - int ok, i, nnames, idcode; + int ok, i, nprevs, nnames, idcode; char filename[FILE_MAXDIR+FILE_MAXFILE]; char dir[FILE_MAX], group[GROUP_MAX]; @@ -1031,17 +1030,18 @@ void filelist_from_library(struct FileList* filelist) idcode= groupname_to_code(group); - // memory for strings is passed into filelist[i].relname - // and free'd in freefilelist - previews = NULL; + /* memory for strings is passed into filelist[i].relname + * and free'd in freefilelist */ if (idcode) { - previews= BLO_blendhandle_get_previews(filelist->libfiledata, idcode); + previews= BLO_blendhandle_get_previews(filelist->libfiledata, idcode, &nprevs); names= BLO_blendhandle_get_datablock_names(filelist->libfiledata, idcode, &nnames); /* ugh, no rewind, need to reopen */ BLO_blendhandle_close(filelist->libfiledata); filelist->libfiledata= BLO_blendhandle_from_file(dir, NULL); } else { + previews= NULL; + nprevs= 0; names= BLO_blendhandle_get_linkable_groups(filelist->libfiledata); nnames= BLI_linklist_length(names); } @@ -1064,7 +1064,10 @@ void filelist_from_library(struct FileList* filelist) } } - if(previews) { + if(previews && (nnames != nprevs)) { + printf("filelist_from_library: error, found %d items, %d previews\n", nnames, nprevs); + } + else if(previews) { for (i=0, l= previews; inext) { PreviewImage *img= l->link; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 04fe2ebf828..968953abf62 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -655,9 +655,10 @@ void ED_fileselect_clear(struct bContext *C, struct SpaceFile *sfile) void ED_fileselect_exit(struct bContext *C, struct SpaceFile *sfile) { if(!sfile) return; - if(sfile->op) + if(sfile->op) { WM_event_fileselect_event(C, sfile->op, EVT_FILESELECT_EXTERNAL_CANCEL); - sfile->op = NULL; + sfile->op = NULL; + } folderlist_free(sfile->folders_prev); folderlist_free(sfile->folders_next); diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 920f477e7eb..6c713d6e469 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -484,11 +484,8 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode) */ for (ce= ked.list.first; ce; ce= ce->next) { /* set frame for validation callback to refer to */ - if (ale) - ked.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); - else - ked.f1= ce->cfra; - + ked.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); + /* select elements with frame number matching cfraelem */ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index ab435395d62..7d4aaf0c70e 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -925,7 +925,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, Scene *scene, wmOpera } BKE_image_release_renderresult(scene, ima); } - else if (BKE_write_ibuf(scene, ibuf, path, sima->imtypenr, scene->r.subimtype, scene->r.quality)) { + else if (BKE_write_ibuf(ibuf, path, sima->imtypenr, scene->r.subimtype, scene->r.quality)) { ok= TRUE; } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 68b9170b837..7d92c308f17 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1643,6 +1643,8 @@ void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int BLF_draw_ascii(blf_mono_font, str, sizeof(str)); dx += BLF_width(blf_mono_font, str); } + + (void)dx; } #if 0 diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 34380fe4fd6..e9559426b81 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -49,15 +49,15 @@ #include "time_intern.h" /* ****************** Start/End Frame Operators *******************************/ - static int time_set_sfra_exec (bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); - int frame= CFRA; - + int frame; + if (scene == NULL) return OPERATOR_CANCELLED; - + + frame= CFRA; /* if 'end frame' (Preview Range or Actual) is less than 'frame', * clamp 'frame' to 'end frame' */ @@ -93,11 +93,13 @@ static void TIME_OT_start_frame_set (wmOperatorType *ot) static int time_set_efra_exec (bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); - int frame= CFRA; - + int frame; + if (scene == NULL) return OPERATOR_CANCELLED; - + + frame= CFRA; + /* if 'start frame' (Preview Range or Actual) is greater than 'frame', * clamp 'frame' to 'end frame' */ diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index e68e1657096..022fa8b64c3 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -1537,7 +1537,7 @@ static void draw_pose_dofs(Object *ob) } if (pchan->ikflag & BONE_IK_XLIMIT) { - /* OpenGL requires rotations in degrees; so we're taking the average angle here */ + /* OpenGL requires rotations in degrees; so we're taking the average angle here */ theta= RAD2DEGF(0.5f * (pchan->limitmin[0] + pchan->limitmax[0])); glRotatef(theta, 1.0f, 0.0f, 0.0f); @@ -1615,10 +1615,17 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { bone= pchan->bone; - if (bone && !(bone->flag & (BONE_HIDDEN_P|BONE_NO_DEFORM|BONE_HIDDEN_PG))) { - if (bone->flag & (BONE_SELECTED)) { - if (bone->layer & arm->layer) - draw_sphere_bone_dist(smat, imat, pchan, NULL); + if (bone) { + /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] + * NOTE: this is the only case with NO_DEFORM==0 flag, as this is for envelope influence drawing + */ + if ( (bone->flag & (BONE_HIDDEN_P|BONE_NO_DEFORM|BONE_HIDDEN_PG))==0 && + ((G.f & G_PICKSEL)==0 || (bone->flag & BONE_UNSELECTABLE)==0) ) + { + if (bone->flag & (BONE_SELECTED)) { + if (bone->layer & arm->layer) + draw_sphere_bone_dist(smat, imat, pchan, NULL); + } } } } @@ -1642,14 +1649,18 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, bone= pchan->bone; arm->layer_used |= bone->layer; - if ( (bone) && !(bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG)) ) { + /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */ + if ( (bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))==0 && + ((G.f & G_PICKSEL)==0 || (bone->flag & BONE_UNSELECTABLE)==0) ) + { if (bone->layer & arm->layer) { int use_custom = (pchan->custom) && !(arm->flag & ARM_NO_CUSTOM); glPushMatrix(); - + if(use_custom && pchan->custom_tx) { glMultMatrixf(pchan->custom_tx->pose_mat); - } else { + } + else { glMultMatrixf(pchan->pose_mat); } @@ -1710,15 +1721,19 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { bone= pchan->bone; - if ((bone) && !(bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))) { + /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */ + if ( (bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))==0 && + ((G.f & G_PICKSEL)==0 || (bone->flag & BONE_UNSELECTABLE)==0) ) + { if (bone->layer & arm->layer) { if (pchan->custom) { if ((dt < OB_SOLID) || (bone->flag & BONE_DRAWWIRE)) { glPushMatrix(); - + if(pchan->custom_tx) { glMultMatrixf(pchan->custom_tx->pose_mat); - } else { + } + else { glMultMatrixf(pchan->pose_mat); } @@ -1788,7 +1803,10 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, bone= pchan->bone; arm->layer_used |= bone->layer; - if ((bone) && !(bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))) { + /* 1) bone must be visible, 2) for OpenGL select-drawing cannot have unselectable [#27194] */ + if ( (bone->flag & (BONE_HIDDEN_P|BONE_HIDDEN_PG))==0 && + ((G.f & G_PICKSEL)==0 || (bone->flag & BONE_UNSELECTABLE)==0) ) + { if (bone->layer & arm->layer) { if ((do_dashed & 1) && (pchan->parent)) { /* Draw a line from our root to the parent's tip @@ -1892,7 +1910,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* patch for several 3d cards (IBM mostly) that crash on glSelect with text drawing */ if ((G.f & G_PICKSEL) == 0) { float vec[3]; - + unsigned char col[4]; float col_f[4]; glGetFloatv(GL_CURRENT_COLOR, col_f); /* incase this is not set below */ @@ -1911,7 +1929,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, else if (dt > OB_WIRE) { UI_GetThemeColor3ubv(TH_TEXT, col); } - + /* Draw names of bone */ if (arm->flag & ARM_DRAWNAMES) { mid_v3_v3v3(vec, pchan->pose_head, pchan->pose_tail); @@ -1924,10 +1942,10 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, copy_m4_m4(bmat, pchan->pose_mat); bone_matrix_translate_y(bmat, pchan->bone->length); glMultMatrixf(bmat); - + glColor3ubv(col); drawaxes(pchan->bone->length*0.25f, OB_ARROWS); - + glPopMatrix(); } } @@ -2440,7 +2458,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, in /* we use color for solid lighting */ glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); glEnable(GL_COLOR_MATERIAL); - glColor3ub(255,0,255); // clear spec + glColor3ub(255,255,255); // clear spec glDisable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index a8cdc99645d..93d86f2d97b 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -156,6 +156,44 @@ RegionView3D *ED_view3d_context_rv3d(bContext *C) return rv3d; } +/* ideally would return an rv3d but in some cases the region is needed too + * so return that, the caller can then access the ar->regiondata */ +ARegion *ED_view3d_context_region_unlock(bContext *C) +{ + ScrArea *sa= CTX_wm_area(C); + if(sa && sa->spacetype==SPACE_VIEW3D) { + ARegion *ar= CTX_wm_region(C); + if(ar) { + RegionView3D *rv3d= ar->regiondata; + if(rv3d && rv3d->viewlock == 0) { + return ar; + } + else { + ARegion *ar_unlock_user= NULL; + ARegion *ar_unlock= NULL; + for(ar= sa->regionbase.first; ar; ar= ar->next) { + /* find the first unlocked rv3d */ + if(ar->regiondata && ar->regiontype == RGN_TYPE_WINDOW) { + rv3d= ar->regiondata; + if(rv3d->viewlock == 0) { + ar_unlock= ar; + if(rv3d->persp==RV3D_PERSP || rv3d->persp==RV3D_CAMOB) { + ar_unlock_user= ar; + break; + } + } + } + } + + /* camera/perspective view get priority when the active region is locked */ + if(ar_unlock_user) return ar_unlock_user; + if(ar_unlock) return ar_unlock; + } + } + } + return NULL; +} + /* Most of the time this isn't needed since you could assume the view matrix was * set while drawing, however when functions like mesh_foreachScreenVert are * called by selection tools, we can't be sure this object was the last. diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 78538a6f16d..1bbad6220ef 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -2212,7 +2212,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in } /* creates own 3d views, used by the sequencer */ -ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, unsigned int flag, int drawtype, char err_out[256]) +ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, Object *camera, int width, int height, unsigned int flag, int drawtype, char err_out[256]) { View3D v3d= {NULL}; ARegion ar= {NULL}; @@ -2223,7 +2223,7 @@ ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height ar.regiondata= &rv3d; ar.regiontype= RGN_TYPE_WINDOW; - v3d.camera= scene->camera; + v3d.camera= camera; v3d.lay= scene->lay; v3d.drawtype = drawtype; v3d.flag2 = V3D_RENDER_OVERRIDE; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index b377bb20baa..2509ae75744 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -790,7 +790,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) View3D *v3d = vod->sa->spacedata.first; if(v3d->camera) { - view3d_settings_from_ob(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); + view3d_apply_ob(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); } if(rv3d->persp==RV3D_CAMOB) { @@ -1635,10 +1635,10 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in if (rv3d->persp==RV3D_CAMOB) { rv3d->persp= RV3D_PERSP; - smooth_view(C, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); + smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); } else { - smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL); + smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, &new_dist, NULL); } } // XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); @@ -1778,10 +1778,10 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) /* like a loca if (rv3d->persp==RV3D_CAMOB) { rv3d->persp= RV3D_PERSP; - smooth_view(C, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); + smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); } else { - smooth_view(C, NULL, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL); + smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL); } /* smooth view does viewlock RV3D_BOXVIEW copy */ @@ -1814,10 +1814,12 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene= CTX_data_scene(C); if (rv3d) { + ARegion *ar= CTX_wm_region(C); + /* non camera center */ float new_ofs[3]; negate_v3_v3(new_ofs, give_cursor(scene, v3d)); - smooth_view(C, NULL, NULL, new_ofs, NULL, NULL, NULL); + smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, NULL, NULL); /* smooth view does viewlock RV3D_BOXVIEW copy */ } @@ -2047,7 +2049,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) new_dist = ((new_dist*scale) >= 0.001f * v3d->grid)? new_dist*scale:0.001f * v3d->grid; } - smooth_view(C, NULL, NULL, new_ofs, NULL, &new_dist, NULL); + smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, &new_dist, NULL); if(rv3d->viewlock & RV3D_BOXVIEW) view3d_boxview_sync(CTX_wm_area(C), ar); @@ -2146,14 +2148,14 @@ static EnumPropertyItem prop_view_items[] = { /* would like to make this a generic function - outside of transform */ -static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, short view, int perspo, int align_active) +static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, float q1, float q2, float q3, float q4, short view, int perspo, int align_active) { - View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d= ar->regiondata; /* no NULL check is needed, poll checks */ float new_quat[4]; new_quat[0]= q1; new_quat[1]= q2; new_quat[2]= q3; new_quat[3]= q4; + normalize_qt(new_quat); if(align_active) { /* align to active object */ @@ -2194,7 +2196,7 @@ static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, s } if(rv3d->viewlock) { - ED_region_tag_redraw(CTX_wm_region(C)); + ED_region_tag_redraw(ar); return; } @@ -2203,14 +2205,14 @@ static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, s if (U.uiflag & USER_AUTOPERSP) rv3d->persp= view ? RV3D_ORTHO : RV3D_PERSP; else if(rv3d->persp==RV3D_CAMOB) rv3d->persp= perspo; - smooth_view(C, v3d->camera, NULL, rv3d->ofs, new_quat, NULL, NULL); + smooth_view(C, v3d, ar, v3d->camera, NULL, rv3d->ofs, new_quat, NULL, NULL); } else { if (U.uiflag & USER_AUTOPERSP) rv3d->persp= view ? RV3D_ORTHO : RV3D_PERSP; else if(rv3d->persp==RV3D_CAMOB) rv3d->persp= perspo; - smooth_view(C, NULL, NULL, NULL, new_quat, NULL, NULL); + smooth_view(C, v3d, ar, NULL, NULL, NULL, new_quat, NULL, NULL); } } @@ -2218,7 +2220,8 @@ static void axis_set_view(bContext *C, float q1, float q2, float q3, float q4, s static int viewnumpad_exec(bContext *C, wmOperator *op) { View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + ARegion *ar= ED_view3d_context_region_unlock(C); + RegionView3D *rv3d= ar->regiondata; /* no NULL check is needed, poll checks */ Scene *scene= CTX_data_scene(C); static int perspo=RV3D_PERSP; int viewnum, align_active, nextperspo; @@ -2240,27 +2243,27 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) switch (viewnum) { case RV3D_VIEW_BOTTOM : - axis_set_view(C, 0.0, -1.0, 0.0, 0.0, viewnum, nextperspo, align_active); + axis_set_view(C, v3d, ar, 0.0, -1.0, 0.0, 0.0, viewnum, nextperspo, align_active); break; case RV3D_VIEW_BACK: - axis_set_view(C, 0.0, 0.0, (float)-cos(M_PI/4.0), (float)-cos(M_PI/4.0), viewnum, nextperspo, align_active); + axis_set_view(C, v3d, ar, 0.0, 0.0, (float)-cos(M_PI/4.0), (float)-cos(M_PI/4.0), viewnum, nextperspo, align_active); break; case RV3D_VIEW_LEFT: - axis_set_view(C, 0.5, -0.5, 0.5, 0.5, viewnum, nextperspo, align_active); + axis_set_view(C, v3d, ar, 0.5, -0.5, 0.5, 0.5, viewnum, nextperspo, align_active); break; case RV3D_VIEW_TOP: - axis_set_view(C, 1.0, 0.0, 0.0, 0.0, viewnum, nextperspo, align_active); + axis_set_view(C, v3d, ar, 1.0, 0.0, 0.0, 0.0, viewnum, nextperspo, align_active); break; case RV3D_VIEW_FRONT: - axis_set_view(C, (float)cos(M_PI/4.0), (float)-sin(M_PI/4.0), 0.0, 0.0, viewnum, nextperspo, align_active); + axis_set_view(C, v3d, ar, (float)cos(M_PI/4.0), (float)-sin(M_PI/4.0), 0.0, 0.0, viewnum, nextperspo, align_active); break; case RV3D_VIEW_RIGHT: - axis_set_view(C, 0.5, -0.5, -0.5, -0.5, viewnum, nextperspo, align_active); + axis_set_view(C, v3d, ar, 0.5, -0.5, -0.5, -0.5, viewnum, nextperspo, align_active); break; case RV3D_VIEW_CAMERA: @@ -2316,13 +2319,13 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) /* finally do snazzy view zooming */ rv3d->persp= RV3D_CAMOB; - smooth_view(C, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); + smooth_view(C, v3d, ar, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); } else{ /* return to settings of last view */ /* does smooth_view too */ - axis_set_view(C, rv3d->lviewquat[0], rv3d->lviewquat[1], rv3d->lviewquat[2], rv3d->lviewquat[3], rv3d->lview, rv3d->lpersp, 0); + axis_set_view(C, v3d, ar, rv3d->lviewquat[0], rv3d->lviewquat[1], rv3d->lviewquat[2], rv3d->lviewquat[3], rv3d->lview, rv3d->lpersp, 0); } } break; @@ -2346,7 +2349,7 @@ void VIEW3D_OT_viewnumpad(wmOperatorType *ot) /* api callbacks */ ot->exec= viewnumpad_exec; - ot->poll= ED_operator_region_view3d_active; + ot->poll= ED_operator_rv3d_unlock_poll; /* flags */ ot->flag= 0; @@ -2364,7 +2367,8 @@ static EnumPropertyItem prop_view_orbit_items[] = { static int vieworbit_exec(bContext *C, wmOperator *op) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + ARegion *ar= ED_view3d_context_region_unlock(C); + RegionView3D *rv3d= ar->regiondata; /* no NULL check is needed, poll checks */ float phi, q1[4], new_quat[4]; int orbitdir; @@ -2398,7 +2402,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) rv3d->view= 0; } - smooth_view(C, NULL, NULL, NULL, new_quat, NULL, NULL); + smooth_view(C, CTX_wm_view3d(C), ar, NULL, NULL, NULL, new_quat, NULL, NULL); } } @@ -2414,7 +2418,7 @@ void VIEW3D_OT_view_orbit(wmOperatorType *ot) /* api callbacks */ ot->exec= vieworbit_exec; - ot->poll= ED_operator_region_view3d_active; + ot->poll= ED_operator_rv3d_unlock_poll; /* flags */ ot->flag= 0; @@ -2470,8 +2474,8 @@ void VIEW3D_OT_view_pan(wmOperatorType *ot) static int viewpersportho_exec(bContext *C, wmOperator *UNUSED(op)) { - ARegion *ar= CTX_wm_region(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + ARegion *ar= ED_view3d_context_region_unlock(C); + RegionView3D *rv3d= ar->regiondata; /* no NULL check is needed, poll checks */ if(rv3d->viewlock==0) { if(rv3d->persp!=RV3D_ORTHO) @@ -2493,12 +2497,13 @@ void VIEW3D_OT_view_persportho(wmOperatorType *ot) /* api callbacks */ ot->exec= viewpersportho_exec; - ot->poll= ED_operator_region_view3d_active; + ot->poll= ED_operator_rv3d_unlock_poll; /* flags */ ot->flag= 0; } + /* ******************** add background image operator **************** */ static BGpic *background_image_add(bContext *C) diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index ce770aaae6a..32deee50fb2 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -540,7 +540,7 @@ static int flyApply(bContext *C, FlyInfo *fly) { #define FLY_ROTATE_FAC 2.5f /* more is faster */ -#define FLY_ZUP_CORRECT_FAC 0.1f /* ammount to correct per step */ +#define FLY_ZUP_CORRECT_FAC 0.1f /* amount to correct per step */ #define FLY_ZUP_CORRECT_ACCEL 0.05f /* increase upright momentum each step */ /* diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 12ad01e3977..717e46800b1 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -147,10 +147,6 @@ void VIEW3D_OT_select_circle(struct wmOperatorType *ot); void VIEW3D_OT_select_border(struct wmOperatorType *ot); void VIEW3D_OT_select_lasso(struct wmOperatorType *ot); -/* view3d_view.c */ -void view3d_settings_from_ob(struct Object *ob, float *ofs, float *quat, float *dist, float *lens); -int view3d_is_ortho(View3D *v3d, RegionView3D *rv3d); - void VIEW3D_OT_smoothview(struct wmOperatorType *ot); void VIEW3D_OT_setcameratoview(struct wmOperatorType *ot); void VIEW3D_OT_object_as_camera(struct wmOperatorType *ot); @@ -162,7 +158,7 @@ int boundbox_clip(RegionView3D *rv3d, float obmat[][4], struct BoundBox *bb); void centerview(struct ARegion *ar, View3D *v3d); -void smooth_view(struct bContext *C, struct Object *, struct Object *, float *ofs, float *quat, float *dist, float *lens); +void smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *, float *ofs, float *quat, float *dist, float *lens); void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 6dae0938f54..8a975eec40f 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -106,9 +106,7 @@ float *give_cursor(Scene *scene, View3D *v3d) /* Gets the lens and clipping values from a camera of lamp type object */ static void object_lens_clip_settings(Object *ob, float *lens, float *clipsta, float *clipend) -{ - if (!ob) return; - +{ if(ob->type==OB_LAMP ) { Lamp *la = ob->data; if (lens) { @@ -137,39 +135,42 @@ static void object_lens_clip_settings(Object *ob, float *lens, float *clipsta, f * * The dist is not modified for this function, if NULL its assimed zero * */ -void view3d_settings_from_ob(Object *ob, float *ofs, float *quat, float *dist, float *lens) +void view3d_apply_mat4(float mat[][4], float *ofs, float *quat, float *dist) { - if (!ob) return; - /* Offset */ if (ofs) - negate_v3_v3(ofs, ob->obmat[3]); + negate_v3_v3(ofs, mat[3]); /* Quat */ if (quat) { float imat[4][4]; - invert_m4_m4(imat, ob->obmat); + invert_m4_m4(imat, mat); mat4_to_quat(quat, imat); } if (dist) { - float tquat[4]; + float nmat[3][3]; float vec[3]; vec[0]= 0.0f; vec[1]= 0.0f; vec[2]= -(*dist); - mat4_to_quat(tquat, ob->obmat); - - mul_qt_v3(tquat, vec); + copy_m3_m4(nmat, mat); + normalize_m3(nmat); + mul_m3_v3(nmat, vec);; sub_v3_v3(ofs, vec); } +} - /* Lens */ - if (lens) +void view3d_apply_ob(Object *ob, float *ofs, float *quat, float *dist, float *lens) +{ + view3d_apply_mat4(ob->obmat, ofs, quat, dist); + + if (lens) { object_lens_clip_settings(ob, lens, NULL, NULL); + } } @@ -189,10 +190,13 @@ struct SmoothViewStore { /* will start timer if appropriate */ /* the arguments are the desired situation */ -void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, float *quat, float *dist, float *lens) +void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera, float *ofs, float *quat, float *dist, float *lens) { - View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + wmWindowManager *wm= CTX_wm_manager(C); + wmWindow *win= CTX_wm_window(C); + ScrArea *sa= CTX_wm_area(C); + + RegionView3D *rv3d= ar->regiondata; struct SmoothViewStore sms= {0}; short ok= FALSE; @@ -210,7 +214,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo if(lens) sms.new_lens= *lens; if (camera) { - view3d_settings_from_ob(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens); + view3d_apply_ob(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens); sms.to_camera= 1; /* restore view3d values in end */ } @@ -235,7 +239,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo /* original values */ if (oldcamera) { sms.orig_dist= rv3d->dist; // below function does weird stuff with it... - view3d_settings_from_ob(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); + view3d_apply_ob(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); } else { copy_v3_v3(sms.orig_ofs, rv3d->ofs); @@ -280,9 +284,9 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo rv3d->sms= MEM_mallocN(sizeof(struct SmoothViewStore), "smoothview v3d"); *rv3d->sms= sms; if(rv3d->smooth_timer) - WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), rv3d->smooth_timer); + WM_event_remove_timer(wm, win, rv3d->smooth_timer); /* TIMER1 is hardcoded in keymap */ - rv3d->smooth_timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER1, 1.0/100.0); /* max 30 frs/sec */ + rv3d->smooth_timer= WM_event_add_timer(wm, win, TIMER1, 1.0/100.0); /* max 30 frs/sec */ ok= TRUE; } @@ -290,8 +294,6 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo /* if we get here nothing happens */ if(ok == FALSE) { - ARegion *ar= CTX_wm_region(C); - if(sms.to_camera==0) { copy_v3_v3(rv3d->ofs, sms.new_ofs); copy_qt_qt(rv3d->viewquat, sms.new_quat); @@ -300,7 +302,7 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo } if(rv3d->viewlock & RV3D_BOXVIEW) - view3d_boxview_copy(CTX_wm_area(C), ar); + view3d_boxview_copy(sa, ar); ED_region_tag_redraw(ar); } @@ -464,19 +466,20 @@ void VIEW3D_OT_setcameratoview(wmOperatorType *ot) static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= CTX_wm_region_view3d(C); + ARegion *ar= ED_view3d_context_region_unlock(C); + RegionView3D *rv3d= ar->regiondata; /* no NULL check is needed, poll checks */ Scene *scene= CTX_data_scene(C); Object *ob = CTX_data_active_object(C); if(ob) { - Object *camera_old= (rv3d->persp == RV3D_CAMOB && scene->camera) ? scene->camera : NULL; + Object *camera_old= (rv3d->persp == RV3D_CAMOB) ? V3D_CAMERA_SCENE(scene, v3d) : NULL; rv3d->persp= RV3D_CAMOB; v3d->camera= ob; if(v3d->scenelock) scene->camera= ob; if(camera_old != ob) /* unlikely but looks like a glitch when set to the same */ - smooth_view(C, camera_old, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); + smooth_view(C, v3d, ar, camera_old, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS|NC_OBJECT|ND_DRAW, CTX_data_scene(C)); } @@ -484,13 +487,11 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static int region3d_unlocked_poll(bContext *C) +int ED_operator_rv3d_unlock_poll(bContext *C) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); - return (rv3d && rv3d->viewlock==0); + return ED_view3d_context_region_unlock(C) != NULL; } - void VIEW3D_OT_object_as_camera(wmOperatorType *ot) { @@ -501,7 +502,7 @@ void VIEW3D_OT_object_as_camera(wmOperatorType *ot) /* api callbacks */ ot->exec= view3d_setobjectascamera_exec; - ot->poll= region3d_unlocked_poll; + ot->poll= ED_operator_rv3d_unlock_poll; /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -1187,14 +1188,14 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short rv3d->persp=RV3D_PERSP; rv3d->dist= 0.0; - view3d_settings_from_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); - smooth_view(NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX + view3d_apply_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); + smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX rv3d->persp=RV3D_CAMOB; /* just to be polite, not needed */ } else { mat3_to_quat( new_quat,tmat); - smooth_view(NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX } } else { mat3_to_quat( rv3d->viewquat,tmat); @@ -1930,11 +1931,11 @@ void view3d_align_axis_to_vector(View3D *v3d, RegionView3D *rv3d, int axisidx, f copy_v3_v3(orig_ofs, rv3d->ofs); rv3d->persp= RV3D_PERSP; rv3d->dist= 0.0; - view3d_settings_from_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); - smooth_view(NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX + view3d_apply_ob(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); + smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); // XXX } else { if (rv3d->persp==RV3D_CAMOB) rv3d->persp= RV3D_PERSP; /* switch out of camera mode */ - smooth_view(NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX + smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); // XXX } } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 4475ce20199..206c8fc0350 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -3151,7 +3151,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) int Rotation(TransInfo *t, const short UNUSED(mval[2])) { - char str[128]; + char str[128], *spos= str; float final; @@ -3177,18 +3177,20 @@ int Rotation(TransInfo *t, const short UNUSED(mval[2])) outputNumInput(&(t->num), c); - sprintf(str, "Rot: %s %s %s", &c[0], t->con.text, t->proptext); + spos+= sprintf(spos, "Rot: %s %s %s", &c[0], t->con.text, t->proptext); /* Clamp between -180 and 180 */ final= angle_wrap_rad(DEG2RADF(final)); } else { - sprintf(str, "Rot: %.2f%s %s", RAD2DEGF(final), t->con.text, t->proptext); + spos += sprintf(spos, "Rot: %.2f%s %s", RAD2DEGF(final), t->con.text, t->proptext); } - if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) - sprintf(str, "%s Proportional size: %.2f", str, t->prop_size); - + if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) { + spos += sprintf(spos, " Proportional size: %.2f", t->prop_size); + } + (void)spos; + t->values[0] = final; applyRotation(t, final, t->axis); @@ -3257,7 +3259,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a int Trackball(TransInfo *t, const short UNUSED(mval[2])) { - char str[128]; + char str[128], *spos= str; float axis1[3], axis2[3]; float mat[3][3], totmat[3][3], smat[3][3]; float phi[2]; @@ -3281,15 +3283,20 @@ int Trackball(TransInfo *t, const short UNUSED(mval[2])) outputNumInput(&(t->num), c); - sprintf(str, "Trackball: %s %s %s", &c[0], &c[20], t->proptext); + spos += sprintf(spos, "Trackball: %s %s %s", &c[0], &c[20], t->proptext); phi[0] = DEG2RADF(phi[0]); phi[1] = DEG2RADF(phi[1]); } else { - sprintf(str, "Trackball: %.2f %.2f %s", RAD2DEGF(phi[0]), RAD2DEGF(phi[1]), t->proptext); + spos += sprintf(spos, "Trackball: %.2f %.2f %s", RAD2DEGF(phi[0]), RAD2DEGF(phi[1]), t->proptext); } + if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) { + spos += sprintf(spos, " Proportional size: %.2f", t->prop_size); + } + (void)spos; + vec_rot_to_mat3( smat,axis1, phi[0]); vec_rot_to_mat3( totmat,axis2, phi[1]); @@ -3345,6 +3352,7 @@ void initTranslation(TransInfo *t) } static void headerTranslation(TransInfo *t, float vec[3], char *str) { + char *spos= str; char tvec[60]; char distvec[20]; char autoik[20]; @@ -3395,24 +3403,26 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { if (t->con.mode & CON_APPLY) { switch(t->num.idx_max) { case 0: - sprintf(str, "D: %s (%s)%s %s %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]); + spos += sprintf(spos, "D: %s (%s)%s %s %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]); break; case 1: - sprintf(str, "D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext, &autoik[0]); + spos += sprintf(spos, "D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext, &autoik[0]); break; case 2: - sprintf(str, "D: %s D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]); + spos += sprintf(spos, "D: %s D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]); } } else { if(t->flag & T_2D_EDIT) - sprintf(str, "Dx: %s Dy: %s (%s)%s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext); + spos += sprintf(spos, "Dx: %s Dy: %s (%s)%s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext); else - sprintf(str, "Dx: %s Dy: %s Dz: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]); + spos += sprintf(spos, "Dx: %s Dy: %s Dz: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]); } - if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) - sprintf(str, "%s Proportional size: %.2f", str, t->prop_size); + if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) { + spos += sprintf(spos, " Proportional size: %.2f", t->prop_size); + } + (void)spos; } static void applyTranslation(TransInfo *t, float vec[3]) { diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 5793b1c6579..16a943baabe 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -185,12 +185,44 @@ static void postConstraintChecks(TransInfo *t, float vec[3], float pvec[3]) { mul_m3_v3(t->con.mtx, vec); } +static void viewAxisCorrectCenter(TransInfo *t, float t_con_center[3]) +{ + if(t->spacetype == SPACE_VIEW3D) { + // View3D *v3d = t->sa->spacedata.first; + const float min_dist= 1.0f; // v3d->near; + float dir[3]; + float l; + + sub_v3_v3v3(dir, t_con_center, t->viewinv[3]); + if(dot_v3v3(dir, t->viewinv[2]) < 0.0f) { + negate_v3(dir); + } + project_v3_v3v3(dir, dir, t->viewinv[2]); + + l= len_v3(dir); + + if(l < min_dist) { + float diff[3]; + normalize_v3_v3(diff, t->viewinv[2]); + mul_v3_fl(diff, min_dist - l); + + sub_v3_v3(t_con_center, diff); + } + } +} + static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3]) { float norm[3], vec[3], factor, angle; + float t_con_center[3]; if(in[0]==0.0f && in[1]==0.0f && in[2]==0.0f) return; + copy_v3_v3(t_con_center, t->con.center); + + /* checks for center being too close to the view center */ + viewAxisCorrectCenter(t, t_con_center); + angle = fabsf(angle_v3v3(axis, t->viewinv[2])); if (angle > (float)M_PI / 2.0f) { angle = (float)M_PI - angle; @@ -217,13 +249,13 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 float norm_center[3]; float plane[3]; - getViewVector(t, t->con.center, norm_center); + getViewVector(t, t_con_center, norm_center); cross_v3_v3v3(plane, norm_center, axis); project_v3_v3v3(vec, in, plane); sub_v3_v3v3(vec, in, vec); - add_v3_v3v3(v, vec, t->con.center); + add_v3_v3v3(v, vec, t_con_center); getViewVector(t, v, norm); /* give arbitrary large value if projection is impossible */ @@ -236,14 +268,14 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 mul_v3_fl(out, -1000000000.0f); } } else { - add_v3_v3v3(v2, t->con.center, axis); + add_v3_v3v3(v2, t_con_center, axis); add_v3_v3v3(v4, v, norm); - isect_line_line_v3(t->con.center, v2, v, v4, i1, i2); + isect_line_line_v3(t_con_center, v2, v, v4, i1, i2); sub_v3_v3v3(v, i2, v); - sub_v3_v3v3(out, i1, t->con.center); + sub_v3_v3v3(out, i1, t_con_center); /* possible some values become nan when * viewpoint and object are both zero */ diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 022e09b3da4..789a262f075 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1670,7 +1670,7 @@ static void removeDoublesPeel(ListBase *depth_peels) { DepthPeel *next_peel = peel->next; - if (peel && next_peel && ABS(peel->depth - next_peel->depth) < 0.0015f) + if (next_peel && ABS(peel->depth - next_peel->depth) < 0.0015f) { peel->next = next_peel->next; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 494cf7dee83..eee7a3d7f69 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1308,59 +1308,6 @@ static void UV_OT_stitch(wmOperatorType *ot) /* ******************** (de)select all operator **************** */ -static int select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) -{ - Scene *scene; - ToolSettings *ts; - Object *obedit; - EditMesh *em; - EditFace *efa; - Image *ima; - MTFace *tf; - - scene= CTX_data_scene(C); - ts= CTX_data_tool_settings(C); - obedit= CTX_data_edit_object(C); - em= BKE_mesh_get_editmesh((Mesh*)obedit->data); - ima= CTX_data_edit_image(C); - - if(ts->uv_flag & UV_SYNC_SELECTION) { - EM_select_swap(em); - } - else { - for(efa= em->faces.first; efa; efa= efa->next) { - tf = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); - - if(uvedit_face_visible(scene, ima, efa, tf)) { - tf->flag ^= TF_SEL1; - tf->flag ^= TF_SEL2; - tf->flag ^= TF_SEL3; - if(efa->v4) tf->flag ^= TF_SEL4; - } - } - } - - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); - - BKE_mesh_end_editmesh(obedit->data, em); - return OPERATOR_FINISHED; -} - -static void UV_OT_select_inverse(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Select Inverse"; - ot->description= "Select inverse of (un)selected UV vertices"; - ot->idname= "UV_OT_select_inverse"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - /* api callbacks */ - ot->exec= select_inverse_exec; - ot->poll= ED_operator_uvedit; -} - -/* ******************** (de)select all operator **************** */ - static int select_all_exec(bContext *C, wmOperator *op) { Scene *scene; @@ -1425,11 +1372,7 @@ static int select_all_exec(bContext *C, wmOperator *op) tf->flag &= ~select_flag; break; case SEL_INVERT: - if ((tf->flag & select_flag) == select_flag) { - tf->flag &= ~select_flag; - } else { - tf->flag &= ~select_flag; - } + tf->flag ^= select_flag; break; } } @@ -3196,7 +3139,6 @@ static void UV_OT_tile_set(wmOperatorType *ot) void ED_operatortypes_uvedit(void) { WM_operatortype_append(UV_OT_select_all); - WM_operatortype_append(UV_OT_select_inverse); WM_operatortype_append(UV_OT_select); WM_operatortype_append(UV_OT_select_loop); WM_operatortype_append(UV_OT_select_linked); @@ -3258,7 +3200,7 @@ void ED_keymap_uvedit(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "UV_OT_unlink_selected", LKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "UV_OT_select_all", AKEY, KM_PRESS, 0, 0); - WM_keymap_add_item(keymap, "UV_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(WM_keymap_add_item(keymap, "UV_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "action", SEL_INVERT); WM_keymap_add_item(keymap, "UV_OT_select_pinned", PKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_menu(keymap, "IMAGE_MT_uvs_weldalign", WKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index eece7fba91c..e1eab55b434 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -170,8 +170,16 @@ static ParamHandle *construct_param_handle(Scene *scene, EditMesh *em, short imp float *uv[4]; int nverts; - if((efa->h) || (sel && (efa->f & SELECT)==0)) - continue; + if(scene->toolsettings->uv_flag & UV_SYNC_SELECTION) { + if(efa->h) { + continue; + } + } + else { + if((efa->h) || (sel && (efa->f & SELECT)==0)) { + continue; + } + } tf= (MTFace *)CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 9bc4ba6776c..f6a6a644977 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -952,6 +952,7 @@ static struct ImBuf *scaledownx(struct ImBuf *ibuf, int newx) ibuf->mall |= IB_rectfloat; ibuf->rect_float = _newrectf; } + (void)rect_size; /* UNUSED in release builds */ ibuf->x = newx; return(ibuf); @@ -1082,6 +1083,7 @@ static struct ImBuf *scaledowny(struct ImBuf *ibuf, int newy) ibuf->mall |= IB_rectfloat; ibuf->rect_float = (float *) _newrectf; } + (void)rect_size; /* UNUSED in release builds */ ibuf->y = newy; return(ibuf); diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 0014e5f3ccd..a72f6d46c97 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1059,6 +1059,9 @@ typedef struct Scene { #define BASACT (scene->basact) #define OBACT (BASACT? BASACT->object: NULL) +#define V3D_CAMERA_LOCAL(v3d) ((!(v3d)->scenelock && (v3d)->camera) ? (v3d)->camera : NULL) +#define V3D_CAMERA_SCENE(scene, v3d) ((!(v3d)->scenelock && (v3d)->camera) ? (v3d)->camera : (scene)->camera) + #define ID_NEW(a) if( (a) && (a)->id.newid ) (a)= (void *)(a)->id.newid #define ID_NEW_US(a) if( (a)->id.newid) {(a)= (void *)(a)->id.newid; (a)->id.us++;} #define ID_NEW_US2(a) if( ((ID *)a)->newid) {(a)= ((ID *)a)->newid; ((ID *)a)->us++;} diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 572a2282d45..e81a9979c12 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -52,6 +52,7 @@ struct Tex; struct Image; struct PreviewImage; struct ImBuf; +struct CurveMapping; typedef struct MTex { @@ -181,9 +182,10 @@ typedef struct PointDensity { short pdpad3[3]; float noise_fac; - float speed_scale; + float speed_scale, falloff_speed_scale, pdpad2; struct ColorBand *coba; /* for time -> color */ + struct CurveMapping *falloff_curve; /* falloff density curve */ } PointDensity; typedef struct VoxelData { @@ -517,6 +519,8 @@ typedef struct TexMapping { #define TEX_PD_FALLOFF_SOFT 2 #define TEX_PD_FALLOFF_CONSTANT 3 #define TEX_PD_FALLOFF_ROOT 4 +#define TEX_PD_FALLOFF_PARTICLE_AGE 5 +#define TEX_PD_FALLOFF_PARTICLE_VEL 6 /* psys_cache_space */ #define TEX_PD_OBJECTLOC 0 @@ -524,8 +528,8 @@ typedef struct TexMapping { #define TEX_PD_WORLDSPACE 2 /* flag */ -#define TEX_PD_TURBULENCE 1 - +#define TEX_PD_TURBULENCE 1 +#define TEX_PD_FALLOFF_CURVE 2 /* noise_influence */ #define TEX_PD_NOISE_STATIC 0 diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 8e210a7a4cb..106c51865fd 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -55,6 +55,7 @@ EnumPropertyItem keyingset_path_grouping_items[] = { #ifdef RNA_RUNTIME #include "BKE_animsys.h" +#include "BKE_fcurve.h" #include "BKE_nla.h" #include "WM_api.h" @@ -457,6 +458,24 @@ static void rna_NlaTrack_active_set(PointerRNA *ptr, PointerRNA value) BKE_nlatrack_set_active(&adt->nla_tracks, track); } + +static FCurve *rna_Driver_from_existing(AnimData *adt, bContext *C, FCurve *src_driver) +{ + /* verify that we've got a driver to duplicate */ + if (ELEM(NULL, src_driver, src_driver->driver)) { + BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "No valid driver data to create copy of"); + return NULL; + } + else { + /* just make a copy of the existing one and add to self */ + FCurve *new_fcu = copy_fcurve(src_driver); + + // XXX: if we impose any ordering on these someday, this will be problematic + BLI_addtail(&adt->drivers, new_fcu); + return new_fcu; + } +} + #else /* helper function for Keying Set -> keying settings */ @@ -724,7 +743,7 @@ static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "new", "rna_NlaTrack_new"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); - RNA_def_function_ui_description(func, "Add a new NLA Tracks"); + RNA_def_function_ui_description(func, "Add a new NLA Track"); RNA_def_pointer(func, "prev", "NlaTrack", "", "NLA Track to add the new one after."); /* return type */ parm = RNA_def_pointer(func, "track", "NlaTrack", "", "New NLA Track."); @@ -745,6 +764,28 @@ static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_update(prop, NC_ANIMATION|ND_NLA|NA_SELECTED, NULL); } +static void rna_api_animdata_drivers(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *parm; + FunctionRNA *func; + + // PropertyRNA *prop; + + RNA_def_property_srna(cprop, "AnimDataDrivers"); + srna= RNA_def_struct(brna, "AnimDataDrivers", NULL); + RNA_def_struct_sdna(srna, "AnimData"); + RNA_def_struct_ui_text(srna, "Drivers", "Collection of Driver F-Curves"); + + func = RNA_def_function(srna, "from_existing", "rna_Driver_from_existing"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Add a new driver given an existing one"); + RNA_def_pointer(func, "src_driver", "FCurve", "", "Existing Driver F-Curve to use as template for a new one"); + /* return type */ + parm = RNA_def_pointer(func, "driver", "FCurve", "", "New Driver F-Curve."); + RNA_def_function_return(func, parm); +} + void rna_def_animdata_common(StructRNA *srna) { PropertyRNA *prop; @@ -774,7 +815,7 @@ void rna_def_animdata(BlenderRNA *brna) /* Active Action */ prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); /* this flag as well as the dynamic test must be defined for this to be editable... */ - RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Action_id_poll"); + RNA_def_property_pointer_funcs(prop, NULL, "rna_AnimData_action_set", NULL, "rna_Action_id_poll"); RNA_def_property_editable_func(prop, "rna_AnimData_action_editable"); RNA_def_property_ui_text(prop, "Action", "Active Action for this datablock"); RNA_def_property_update(prop, NC_ANIMATION, NULL); /* this will do? */ @@ -805,6 +846,8 @@ void rna_def_animdata(BlenderRNA *brna) RNA_def_property_struct_type(prop, "FCurve"); RNA_def_property_ui_text(prop, "Drivers", "The Drivers/Expressions for this datablock"); + rna_api_animdata_drivers(brna, prop); + /* General Settings */ prop= RNA_def_property(srna, "use_nla", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ADT_NLA_EVAL_OFF); diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index f3f79cde617..7bb56380ba5 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -342,22 +342,22 @@ static void rna_def_brush(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem brush_stroke_method_items[] = { - {0, "DOTS", 0, "Dots", ""}, - {BRUSH_RESTORE_MESH, "DRAG_DOT", 0, "Drag Dot", ""}, - {BRUSH_SPACE, "SPACE", 0, "Space", ""}, - {BRUSH_ANCHORED, "ANCHORED", 0, "Anchored", ""}, - {BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", ""}, + {0, "DOTS", 0, "Dots", "Apply paint on each mouse move step"}, + {BRUSH_RESTORE_MESH, "DRAG_DOT", 0, "Drag Dot", "Allows a single dot to be carefully positioned"}, + {BRUSH_SPACE, "SPACE", 0, "Space", "Limit brush application to the distance specified by spacing"}, + {BRUSH_ANCHORED, "ANCHORED", 0, "Anchored", "Keep the brush anchored to the initial location"}, + {BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", "Keep applying paint effect while holding mouse (spray)"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem texture_angle_source_items[] = { - {0, "USER", 0, "User", ""}, - {BRUSH_RAKE, "RAKE", 0, "Rake", ""}, - {BRUSH_RANDOM_ROTATION, "RANDOM", 0, "Random", ""}, + {0, "USER", 0, "User", "Rotate the brush texture by given angle"}, + {BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"}, + {BRUSH_RANDOM_ROTATION, "RANDOM", 0, "Random", "Rotate the brush texture at random"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem texture_angle_source_no_random_items[] = { - {0, "USER", 0, "User", ""}, - {BRUSH_RAKE, "RAKE", 0, "Rake", ""}, + {0, "USER", 0, "User", "Rotate the brush texture by given angle"}, + {BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem brush_sculpt_plane_items[] = { diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index df5bd9f27f3..5872542d10a 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -44,9 +44,9 @@ #include "WM_types.h" static EnumPropertyItem image_source_items[]= { - {IMA_SRC_FILE, "FILE", 0, "File", "Single image file"}, - {IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Sequence", "Multiple image files, as a sequence"}, - {IMA_SRC_MOVIE, "MOVIE", 0, "Movie", "Movie file"}, + {IMA_SRC_FILE, "FILE", 0, "Single Image", "Single image file"}, + {IMA_SRC_SEQUENCE, "SEQUENCE", 0, "Image Sequence", "Multiple image files, as a sequence"}, + {IMA_SRC_MOVIE, "MOVIE", 0, "Movie File", "Movie file"}, {IMA_SRC_GENERATED, "GENERATED", 0, "Generated", "Generated image"}, {IMA_SRC_VIEWER, "VIEWER", 0, "Viewer", "Compositing node viewer"}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 2d5c26199d6..7327c7203b9 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -84,7 +84,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports const float dither_back= ibuf->dither; ibuf->depth= scene->r.planes; ibuf->dither= scene->r.dither_intensity; - if (!BKE_write_ibuf(NULL, ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality)) { + if (!BKE_write_ibuf(ibuf, path, scene->r.imtype, scene->r.subimtype, scene->r.quality)) { BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path); } ibuf->depth= imb_depth_back; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 436418324e2..2ff72c90042 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1826,13 +1826,13 @@ static void rna_def_object(BlenderRNA *brna) prop= RNA_def_property(srna, "track_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "trackflag"); RNA_def_property_enum_items(prop, track_items); - RNA_def_property_ui_text(prop, "Track Axis", "Axis that points in 'forward' direction"); + RNA_def_property_ui_text(prop, "Track Axis", "Axis that points in 'forward' direction (applies to DupliFrame when parent 'Follow' is enabled)"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); prop= RNA_def_property(srna, "up_axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "upflag"); RNA_def_property_enum_items(prop, up_items); - RNA_def_property_ui_text(prop, "Up Axis", "Axis that points in the upward direction"); + RNA_def_property_ui_text(prop, "Up Axis", "Axis that points in the upward direction (applies to DupliFrame when parent 'Follow' is enabled)"); RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_internal_update"); /* proxy */ diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 0619f5e19b6..a4fbd7c160e 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -190,7 +190,7 @@ static void rna_Cache_idname_change(Main *bmain, Scene *scene, PointerRNA *ptr) for(pid=pidlist.first; pid; pid=pid->next) { if(pid->cache==cache) pid2 = pid; - else if(strcmp(cache->name, "") && strcmp(cache->name,pid->cache->name)==0) { + else if(cache->name[0] != '\0' && strcmp(cache->name,pid->cache->name)==0) { /*TODO: report "name exists" to user */ strcpy(cache->name, cache->prev_name); new_name = 0; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index b5b980aca5b..5e261fa2d18 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -384,6 +384,25 @@ static void rna_RegionView3D_view_location_set(PointerRNA *ptr, const float *val negate_v3_v3(rv3d->ofs, values); } +static void rna_RegionView3D_view_rotation_get(PointerRNA *ptr, float *values) +{ + RegionView3D *rv3d= (RegionView3D *)(ptr->data); + invert_qt_qt(values, rv3d->viewquat); +} + +static void rna_RegionView3D_view_rotation_set(PointerRNA *ptr, const float *values) +{ + RegionView3D *rv3d= (RegionView3D *)(ptr->data); + invert_qt_qt(rv3d->viewquat, values); +} + +static void rna_RegionView3D_view_matrix_set(PointerRNA *ptr, const float *values) +{ + RegionView3D *rv3d= (RegionView3D *)(ptr->data); + negate_v3_v3(rv3d->ofs, values); + view3d_apply_mat4((float (*)[4])values, rv3d->ofs, rv3d->viewquat, &rv3d->dist); +} + /* Space Image Editor */ static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr) @@ -1361,9 +1380,10 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop= RNA_def_property(srna, "view_matrix", PROP_FLOAT, PROP_MATRIX); RNA_def_property_float_sdna(prop, NULL, "viewmat"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX: for now, it's too risky for users to do this RNA_def_property_multi_array(prop, 2, matrix_dimsize); + RNA_def_property_float_funcs(prop, NULL, "rna_RegionView3D_view_matrix_set", NULL); RNA_def_property_ui_text(prop, "View Matrix", "Current view matrix of the 3D region"); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); prop= RNA_def_property(srna, "view_perspective", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "persp"); @@ -1382,8 +1402,13 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4); RNA_def_property_update(prop, NC_WINDOW, NULL); - prop= RNA_def_property(srna, "view_rotation", PROP_FLOAT, PROP_QUATERNION); + prop= RNA_def_property(srna, "view_rotation", PROP_FLOAT, PROP_QUATERNION); // cant use because its inverted +#if 0 RNA_def_property_float_sdna(prop, NULL, "viewquat"); +#else + RNA_def_property_array(prop, 4); + RNA_def_property_float_funcs(prop, "rna_RegionView3D_view_rotation_get", "rna_RegionView3D_view_rotation_set", NULL); +#endif RNA_def_property_ui_text(prop, "View Rotation", "Rotation in quaternions (keep normalized)"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); @@ -1411,7 +1436,7 @@ static void rna_def_space_buttons(BlenderRNA *brna) {BCONTEXT_BONE_CONSTRAINT, "BONE_CONSTRAINT", ICON_CONSTRAINT, "Bone Constraints", "Bone Constraints"}, {BCONTEXT_MATERIAL, "MATERIAL", ICON_MATERIAL, "Material", "Material"}, {BCONTEXT_TEXTURE, "TEXTURE", ICON_TEXTURE, "Texture", "Texture"}, - {BCONTEXT_PARTICLE, "PARTICLE", ICON_PARTICLES, "Particle", "Particle"}, + {BCONTEXT_PARTICLE, "PARTICLES", ICON_PARTICLES, "Particles", "Particle"}, {BCONTEXT_PHYSICS, "PHYSICS", ICON_PHYSICS, "Physics", "Physics"}, {0, NULL, 0, NULL, NULL}}; diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index d8eec152831..fc74fc7268d 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1427,6 +1427,8 @@ static void rna_def_texture_pointdensity(BlenderRNA *brna) {TEX_PD_FALLOFF_SOFT, "SOFT", 0, "Soft", ""}, {TEX_PD_FALLOFF_CONSTANT, "CONSTANT", 0, "Constant", "Density is constant within lookup radius"}, {TEX_PD_FALLOFF_ROOT, "ROOT", 0, "Root", ""}, + {TEX_PD_FALLOFF_PARTICLE_AGE, "PARTICLE_AGE", 0, "Particle Age", ""}, + {TEX_PD_FALLOFF_PARTICLE_VEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", ""}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem color_source_items[] = { @@ -1509,12 +1511,30 @@ static void rna_def_texture_pointdensity(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Scale", "Multiplier to bring particle speed within an acceptable range"); RNA_def_property_update(prop, 0, "rna_Texture_update"); + prop= RNA_def_property(srna, "falloff_speed_scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "falloff_speed_scale"); + RNA_def_property_range(prop, 0.001, 100.0); + RNA_def_property_ui_text(prop, "Velocity Scale", "Multiplier to bring particle speed within an acceptable range"); + RNA_def_property_update(prop, 0, "rna_Texture_update"); + + prop= RNA_def_property(srna, "color_ramp", PROP_POINTER, PROP_NEVER_NULL); RNA_def_property_pointer_sdna(prop, NULL, "coba"); RNA_def_property_struct_type(prop, "ColorRamp"); RNA_def_property_ui_text(prop, "Color Ramp", ""); RNA_def_property_update(prop, 0, "rna_Texture_update"); + + prop= RNA_def_property(srna, "falloff_curve", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "falloff_curve"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_ui_text(prop, "Falloff Curve", ""); + RNA_def_property_update(prop, 0, "rna_Texture_update"); + prop= RNA_def_property(srna, "use_falloff_curve", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PD_FALLOFF_CURVE); + RNA_def_property_ui_text(prop, "Falloff Curve", "Use a custom falloff curve"); + RNA_def_property_update(prop, 0, "rna_Texture_update"); + /* Turbulence */ prop= RNA_def_property(srna, "use_turbulence", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", TEX_PD_TURBULENCE); diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index d303f3d2516..7f887eb162a 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -260,6 +260,7 @@ static void displaceModifier_do( float (*tex_co)[3]; if(!dmd->texture) return; + if(dmd->strength == 0.0f) return; defgrp_index = defgroup_name_index(ob, dmd->defgrp_name); @@ -284,7 +285,7 @@ static void displaceModifier_do( break; } } - if(!def_weight) continue; + if(!def_weight || def_weight->weight==0.0f) continue; } texres.nor = NULL; diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 22ba1447d20..8d0aea41b5c 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -38,6 +38,8 @@ /* EdgeSplit modifier: Splits edges in the mesh according to sharpness flag * or edge angle (can be used to achieve autosmoothing) */ +#include + #include "DNA_meshdata_types.h" #include "BLI_listbase.h" @@ -125,6 +127,8 @@ static SmoothVert *smoothvert_copy(SmoothVert *vert, SmoothMesh *mesh) { SmoothVert *copy = &mesh->verts[mesh->num_verts]; + assert(vert != NULL); + if(mesh->num_verts >= mesh->max_verts) { printf("Attempted to add a SmoothMesh vert beyond end of array\n"); return NULL; @@ -280,8 +284,8 @@ static void smoothmesh_print(SmoothMesh *mesh) dm->getVert(dm, vert->oldIndex, &mv); printf("%3d: ind={%3d, %3d}, pos={% 5.1f, % 5.1f, % 5.1f}", - i, vert->oldIndex, vert->newIndex, - mv.co[0], mv.co[1], mv.co[2]); + i, vert->oldIndex, vert->newIndex, + mv.co[0], mv.co[1], mv.co[2]); printf(", faces={"); for(node = vert->faces; node != NULL; node = node->next) { printf(" %d", ((SmoothFace *)node->link)->newIndex); @@ -295,9 +299,9 @@ static void smoothmesh_print(SmoothMesh *mesh) LinkNode *node; printf("%4d: indices={%4d, %4d}, verts={%4d, %4d}", - i, - edge->oldIndex, edge->newIndex, - edge->verts[0]->newIndex, edge->verts[1]->newIndex); + i, + edge->oldIndex, edge->newIndex, + edge->verts[0]->newIndex, edge->verts[1]->newIndex); if(edge->verts[0] == edge->verts[1]) printf(" <- DUPLICATE VERTEX"); printf(", faces={"); for(node = edge->faces; node != NULL; node = node->next) { @@ -311,7 +315,7 @@ static void smoothmesh_print(SmoothMesh *mesh) SmoothFace *face = &mesh->faces[i]; printf("%4d: indices={%4d, %4d}, edges={", i, - face->oldIndex, face->newIndex); + face->oldIndex, face->newIndex); for(j = 0; j < SMOOTHFACE_MAX_EDGES && face->edges[j]; j++) { if(face->flip[j]) printf(" -%-2d", face->edges[j]->newIndex); @@ -514,18 +518,18 @@ static void linklist_copy(LinkNode **target, LinkNode *source) for(; source; source = source->next) { if(node) { node->next = MEM_mallocN(sizeof(*node->next), "nlink_copy"); - node = node->next; -} else { - node = *target = MEM_mallocN(sizeof(**target), "nlink_copy"); -} - node->link = source->link; - node->next = NULL; -} + node = node->next; + } else { + node = *target = MEM_mallocN(sizeof(**target), "nlink_copy"); + } + node->link = source->link; + node->next = NULL; + } } #endif - /* appends source to target if it's not already in target */ - static void linklist_append_unique(LinkNode **target, void *source) +/* appends source to target if it's not already in target */ +static void linklist_append_unique(LinkNode **target, void *source) { LinkNode *node; LinkNode *prev = NULL; @@ -559,7 +563,7 @@ static void linklist_prepend_linklist(LinkNode **list, LinkNode *prepend) node->next = *list; *list = prepend; -} + } } #endif @@ -666,7 +670,7 @@ static void edge_replace_vert(void *ptr, void *userdata) #ifdef EDGESPLIT_DEBUG_3 printf("replacing vert %4d with %4d in edge %4d", - find->newIndex, replace->newIndex, edge->newIndex); + find->newIndex, replace->newIndex, edge->newIndex); printf(": {%4d, %4d}", edge->verts[0]->newIndex, edge->verts[1]->newIndex); #endif @@ -702,15 +706,15 @@ static void face_replace_edge(void *ptr, void *userdata) #ifdef EDGESPLIT_DEBUG_3 printf("replacing edge %4d with %4d in face %4d", - find->newIndex, replace->newIndex, face->newIndex); + find->newIndex, replace->newIndex, face->newIndex); if(face->edges[3]) printf(": {%2d %2d %2d %2d}", - face->edges[0]->newIndex, face->edges[1]->newIndex, - face->edges[2]->newIndex, face->edges[3]->newIndex); + face->edges[0]->newIndex, face->edges[1]->newIndex, + face->edges[2]->newIndex, face->edges[3]->newIndex); else printf(": {%2d %2d %2d}", - face->edges[0]->newIndex, face->edges[1]->newIndex, - face->edges[2]->newIndex); + face->edges[0]->newIndex, face->edges[1]->newIndex, + face->edges[2]->newIndex); #endif for(i = 0; i < SMOOTHFACE_MAX_EDGES && face->edges[i]; i++) { @@ -724,12 +728,12 @@ static void face_replace_edge(void *ptr, void *userdata) #ifdef EDGESPLIT_DEBUG_3 if(face->edges[3]) printf(" -> {%2d %2d %2d %2d}\n", - face->edges[0]->newIndex, face->edges[1]->newIndex, - face->edges[2]->newIndex, face->edges[3]->newIndex); + face->edges[0]->newIndex, face->edges[1]->newIndex, + face->edges[2]->newIndex, face->edges[3]->newIndex); else printf(" -> {%2d %2d %2d}\n", - face->edges[0]->newIndex, face->edges[1]->newIndex, - face->edges[2]->newIndex); + face->edges[0]->newIndex, face->edges[1]->newIndex, + face->edges[2]->newIndex); #endif } @@ -776,7 +780,7 @@ static SmoothEdge *find_other_sharp_edge(SmoothVert *vert, SmoothEdge *edge, Lin LinkNode *visited_edges = NULL; #ifdef EDGESPLIT_DEBUG_1 printf("=== START === find_other_sharp_edge(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); + edge->newIndex, vert->newIndex); #endif /* get a face on which to start */ @@ -800,7 +804,7 @@ static SmoothEdge *find_other_sharp_edge(SmoothVert *vert, SmoothEdge *edge, Lin && !linklist_contains(visited_edges, edge2)) { #ifdef EDGESPLIT_DEBUG_3 printf("current face %4d; current edge %4d\n", face->newIndex, - edge2->newIndex); + edge2->newIndex); #endif /* get the next face */ face = other_face(edge2, face); @@ -818,7 +822,7 @@ static SmoothEdge *find_other_sharp_edge(SmoothVert *vert, SmoothEdge *edge, Lin edge2 = other_edge(face, vert, edge2); #ifdef EDGESPLIT_DEBUG_3 printf("next face %4d; next edge %4d\n", - face->newIndex, edge2->newIndex); + face->newIndex, edge2->newIndex); } else { printf("loose edge: %4d\n", edge2->newIndex); #endif @@ -834,8 +838,8 @@ static SmoothEdge *find_other_sharp_edge(SmoothVert *vert, SmoothEdge *edge, Lin #ifdef EDGESPLIT_DEBUG_1 printf("=== END === find_other_sharp_edge(edge = %4d, vert = %4d), " - "returning edge %d\n", - edge->newIndex, vert->newIndex, edge2 ? edge2->newIndex : -1); + "returning edge %d\n", + edge->newIndex, vert->newIndex, edge2 ? edge2->newIndex : -1); #endif return edge2; } @@ -911,7 +915,7 @@ static void propagate_split(SmoothEdge *edge, SmoothVert *vert, LinkNode *visited_faces = NULL; #ifdef EDGESPLIT_DEBUG_1 printf("=== START === propagate_split(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); + edge->newIndex, vert->newIndex); #endif edge2 = find_other_sharp_edge(vert, edge, &visited_faces); @@ -942,10 +946,13 @@ static void propagate_split(SmoothEdge *edge, SmoothVert *vert, /* vert has more than one fan of faces attached; split it */ vert2 = smoothvert_copy(vert, mesh); - /* replace vert with its copy in visited_faces */ - repdata.find = vert; - repdata.replace = vert2; - BLI_linklist_apply(visited_faces, face_replace_vert, &repdata); + /* fails in rare cases, see [#26993] */ + if(vert2) { + /* replace vert with its copy in visited_faces */ + repdata.find = vert; + repdata.replace = vert2; + BLI_linklist_apply(visited_faces, face_replace_vert, &repdata); + } } } else { /* edge is not loose, so it must be sharp; split it */ @@ -956,7 +963,7 @@ static void propagate_split(SmoothEdge *edge, SmoothVert *vert, BLI_linklist_free(visited_faces, NULL); #ifdef EDGESPLIT_DEBUG_1 printf("=== END === propagate_split(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); + edge->newIndex, vert->newIndex); #endif } @@ -969,7 +976,7 @@ static void split_edge(SmoothEdge *edge, SmoothVert *vert, SmoothMesh *mesh) LinkNode *visited_faces = NULL; #ifdef EDGESPLIT_DEBUG_1 printf("=== START === split_edge(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); + edge->newIndex, vert->newIndex); #endif edge2 = find_other_sharp_edge(vert, edge, &visited_faces); @@ -1042,7 +1049,7 @@ static void split_edge(SmoothEdge *edge, SmoothVert *vert, SmoothMesh *mesh) BLI_linklist_free(visited_faces, NULL); #ifdef EDGESPLIT_DEBUG_1 printf("=== END === split_edge(edge = %4d, vert = %4d)\n", - edge->newIndex, vert->newIndex); + edge->newIndex, vert->newIndex); #endif } @@ -1243,8 +1250,8 @@ static DerivedMesh *edgesplitModifier_do(EdgeSplitModifierData *emd, DerivedMesh #ifdef EDGESPLIT_DEBUG_0 printf("Edgesplit: Estimated %d verts & %d edges, " - "found %d verts & %d edges\n", max_verts, max_edges, - mesh->num_verts, mesh->num_edges); + "found %d verts & %d edges\n", max_verts, max_edges, + mesh->num_verts, mesh->num_edges); #endif result = CDDM_from_smoothmesh(mesh); diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index 2e6d9350148..ea4771b679a 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -56,7 +56,7 @@ /* Clamps/Limits the given coordinate to: limits[0] <= co[axis] <= limits[1] - * The ammount of clamp is saved on dcut */ + * The amount of clamp is saved on dcut */ static void axis_limit(int axis, const float limits[2], float co[3], float dcut[3]) { float val = co[axis]; diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index 6d547867ed8..6dfe5314131 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -263,6 +263,9 @@ static void waveModifier_do(WaveModifierData *md, (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow)); float lifefac = wmd->height; float (*tex_co)[3] = NULL; + const int wmd_axis= wmd->flag & (MOD_WAVE_X|MOD_WAVE_Y); + const float falloff= wmd->falloff; + float falloff_fac= 1.0f; /* when falloff == 0.0f this stays at 1.0f */ if(wmd->flag & MOD_WAVE_NORM && ob->type == OB_MESH) mvert = dm->getVertArray(dm); @@ -306,7 +309,7 @@ static void waveModifier_do(WaveModifierData *md, if(lifefac != 0.0f) { /* avoid divide by zero checks within the loop */ - float falloff_inv= wmd->falloff ? 1.0f / wmd->falloff : 1.0f; + float falloff_inv= falloff ? 1.0f / falloff : 1.0f; int i; for(i = 0; i < numVerts; i++) { @@ -314,51 +317,29 @@ static void waveModifier_do(WaveModifierData *md, float x = co[0] - wmd->startx; float y = co[1] - wmd->starty; float amplit= 0.0f; - float dist = 0.0f; - float falloff_fac = 0.0f; - TexResult texres; - MDeformWeight *def_weight = NULL; + float def_weight= 1.0f; /* get weights */ if(dvert) { - int j; - for(j = 0; j < dvert[i].totweight; ++j) { - if(dvert[i].dw[j].def_nr == defgrp_index) { - def_weight = &dvert[i].dw[j]; - break; - } - } + def_weight= defvert_find_weight(&dvert[i], defgrp_index); /* if this vert isn't in the vgroup, don't deform it */ - if(!def_weight) continue; - } - - if(wmd->texture) { - texres.nor = NULL; - get_texture_value(wmd->texture, tex_co[i], &texres); - } - - /*get dist*/ - if(wmd->flag & MOD_WAVE_X) { - if(wmd->flag & MOD_WAVE_Y){ - dist = (float)sqrt(x*x + y*y); - } - else{ - dist = fabs(x); + if(def_weight == 0.0f) { + continue; } } - else if(wmd->flag & MOD_WAVE_Y) { - dist = fabs(y); - } - falloff_fac = (1.0f - (dist * falloff_inv)); - - if(wmd->flag & MOD_WAVE_X) { - if(wmd->flag & MOD_WAVE_Y) amplit = (float)sqrt(x*x + y*y); - else amplit = x; + switch(wmd_axis) { + case MOD_WAVE_X|MOD_WAVE_Y: + amplit = sqrtf(x*x + y*y); + break; + case MOD_WAVE_X: + amplit = x; + break; + case MOD_WAVE_Y: + amplit = y; + break; } - else if(wmd->flag & MOD_WAVE_Y) - amplit= y; /* this way it makes nice circles */ amplit -= (ctime - wmd->timeoffs) * wmd->speed; @@ -368,22 +349,40 @@ static void waveModifier_do(WaveModifierData *md, + wmd->width; } + if(falloff != 0.0f) { + float dist = 0.0f; + + switch(wmd_axis) { + case MOD_WAVE_X|MOD_WAVE_Y: + dist = sqrtf(x*x + y*y); + break; + case MOD_WAVE_X: + dist = fabsf(x); + break; + case MOD_WAVE_Y: + dist = fabsf(y); + break; + } + + falloff_fac = (1.0f - (dist * falloff_inv)); + CLAMP(falloff_fac, 0.0f, 1.0f); + } + /* GAUSSIAN */ - if(amplit > -wmd->width && amplit < wmd->width) { + if((falloff_fac != 0.0f) && (amplit > -wmd->width) && (amplit < wmd->width)) { amplit = amplit * wmd->narrow; amplit = (float)(1.0f / expf(amplit * amplit) - minfac); /*apply texture*/ - if(wmd->texture) - amplit = amplit * texres.tin; + if(wmd->texture) { + TexResult texres; + texres.nor = NULL; + get_texture_value(wmd->texture, tex_co[i], &texres); + amplit *= texres.tin; + } - /*apply weight*/ - if(def_weight) - amplit = amplit * def_weight->weight; - - /*apply falloff*/ - if (wmd->falloff > 0) - amplit = amplit * falloff_fac; + /*apply weight & falloff */ + amplit *= def_weight * falloff_fac; if(mvert) { /* move along normals */ diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c b/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c index 61a1c5d1c94..1d52e694ea9 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_outputFile.c @@ -78,7 +78,7 @@ static void node_composit_exec_output_file(void *data, bNode *node, bNodeStack * BKE_makepicstring(string, nif->name, rd->cfra, nif->imtype, (rd->scemode & R_EXTENSION), TRUE); - if(0 == BKE_write_ibuf((Scene *)node->id, ibuf, string, nif->imtype, nif->subimtype, nif->imtype==R_OPENEXR?nif->codec:nif->quality)) + if(0 == BKE_write_ibuf(ibuf, string, nif->imtype, nif->subimtype, nif->imtype==R_OPENEXR?nif->codec:nif->quality)) printf("Cannot save Node File Output to %s\n", string); else printf("Saved: %s\n", string); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 284686048d3..acd23887af0 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -370,7 +370,9 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st #endif } else { - PyErr_Format(PyExc_IOError, "Python file \"%s\" could not be opened: %s", fn, strerror(errno)); + PyErr_Format(PyExc_IOError, + "Python file \"%s\" could not be opened: %s", + fn, strerror(errno)); py_result= NULL; } } diff --git a/source/blender/python/intern/bpy_library.c b/source/blender/python/intern/bpy_library.c index 08a0b514a0c..4291fc824e9 100644 --- a/source/blender/python/intern/bpy_library.c +++ b/source/blender/python/intern/bpy_library.c @@ -230,7 +230,9 @@ static PyObject *bpy_lib_enter(BPy_Library *self, PyObject *UNUSED(args)) if(self->blo_handle == NULL) { if(BPy_reports_to_error(&reports, PyExc_IOError, TRUE) != -1) { - PyErr_Format(PyExc_IOError, "load: %s failed to open blend file", self->abspath); + PyErr_Format(PyExc_IOError, + "load: %s failed to open blend file", + self->abspath); } return NULL; } @@ -301,7 +303,9 @@ static PyObject *bpy_lib_exit(BPy_Library *self, PyObject *UNUSED(args)) if(item_str) { if(!BLO_library_append_named_part(NULL, mainl, &(self->blo_handle), item_str, code, self->flag)) { - PyErr_Format(PyExc_KeyError, "load: %s does not contain %s[\"%s\"]", self->abspath, name_plural, item_str); + PyErr_Format(PyExc_KeyError, + "load: %s does not contain %s[\"%s\"]", + self->abspath, name_plural, item_str); err= -1; break; } diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index ebe6e05ee43..c230e952ca1 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -79,14 +79,19 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args) ot= WM_operatortype_find(opname, TRUE); if (ot == NULL) { - PyErr_Format(PyExc_AttributeError, "Polling operator \"bpy.ops.%s\" error, could not be found", opname); + PyErr_Format(PyExc_AttributeError, + "Polling operator \"bpy.ops.%s\" error, " + "could not be found", opname); return NULL; } if(context_str) { if(RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) { char *enum_str= BPy_enum_as_string(operator_context_items); - PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s.poll\" error, expected a string enum in (%.200s)", opname, enum_str); + PyErr_Format(PyExc_TypeError, + "Calling operator \"bpy.ops.%s.poll\" error, " + "expected a string enum in (%.200s)", + opname, enum_str); MEM_freeN(enum_str); return NULL; } @@ -96,7 +101,10 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args) context_dict= NULL; } else if (!PyDict_Check(context_dict)) { - PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s.poll\" error, custom context expected a dict or None, got a %.200s", opname, Py_TYPE(context_dict)->tp_name); + PyErr_Format(PyExc_TypeError, + "Calling operator \"bpy.ops.%s.poll\" error, " + "custom context expected a dict or None, got a %.200s", + opname, Py_TYPE(context_dict)->tp_name); return NULL; } @@ -146,19 +154,27 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) ot= WM_operatortype_find(opname, TRUE); if (ot == NULL) { - PyErr_Format(PyExc_AttributeError, "Calling operator \"bpy.ops.%s\" error, could not be found", opname); + PyErr_Format(PyExc_AttributeError, + "Calling operator \"bpy.ops.%s\" error, " + "could not be found", opname); return NULL; } if(!pyrna_write_check()) { - PyErr_Format(PyExc_RuntimeError, "Calling operator \"bpy.ops.%s\" error, can't modify blend data in this state (drawing/rendering)", opname); + PyErr_Format(PyExc_RuntimeError, + "Calling operator \"bpy.ops.%s\" error, " + "can't modify blend data in this state (drawing/rendering)", + opname); return NULL; } if(context_str) { if(RNA_enum_value_from_id(operator_context_items, context_str, &context)==0) { char *enum_str= BPy_enum_as_string(operator_context_items); - PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s\" error, expected a string enum in (%.200s)", opname, enum_str); + PyErr_Format(PyExc_TypeError, + "Calling operator \"bpy.ops.%s\" error, " + "expected a string enum in (%.200s)", + opname, enum_str); MEM_freeN(enum_str); return NULL; } @@ -168,7 +184,10 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) context_dict= NULL; } else if (!PyDict_Check(context_dict)) { - PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s\" error, custom context expected a dict or None, got a %.200s", opname, Py_TYPE(context_dict)->tp_name); + PyErr_Format(PyExc_TypeError, + "Calling operator \"bpy.ops.%s\" error, " + "custom context expected a dict or None, got a %.200s", + opname, Py_TYPE(context_dict)->tp_name); return NULL; } @@ -179,7 +198,9 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) if(WM_operator_poll_context((bContext*)C, ot, context) == FALSE) { const char *msg= CTX_wm_operator_poll_msg_get(C); - PyErr_Format(PyExc_RuntimeError, "Operator bpy.ops.%.200s.poll() %.200s", opname, msg ? msg : "failed, context is incorrect"); + PyErr_Format(PyExc_RuntimeError, + "Operator bpy.ops.%.200s.poll() %.200s", + opname, msg ? msg : "failed, context is incorrect"); CTX_wm_operator_poll_msg_set(C, NULL); /* better set to NULL else it could be used again */ error_val= -1; } @@ -225,7 +246,9 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) { /* no props */ if (kw != NULL) { - PyErr_Format(PyExc_AttributeError, "Operator \"%s\" does not take any args", opname); + PyErr_Format(PyExc_AttributeError, + "Operator \"%s\" does not take any args", + opname); return NULL; } @@ -281,7 +304,9 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) ot= WM_operatortype_find(opname, TRUE); if (ot == NULL) { - PyErr_Format(PyExc_AttributeError, "_bpy.ops.as_string: operator \"%.200s\"could not be found", opname); + PyErr_Format(PyExc_AttributeError, + "_bpy.ops.as_string: operator \"%.200s\" " + "could not be found", opname); return NULL; } diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 53d28621ae8..6ea52abc5f4 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -223,8 +223,14 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) char *pysubtype= NULL; int subtype= PROP_NONE; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssiO!s:BoolProperty", (char **)kwlist, &id, &id_len, &name, &description, &def, &PySet_Type, &pyopts, &pysubtype)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s#|ssiO!s:BoolProperty", + (char **)kwlist, &id, &id_len, + &name, &description, &def, + &PySet_Type, &pyopts, &pysubtype)) + { return NULL; + } BPY_PROPDEF_SUBTYPE_CHECK(BoolProperty, property_flag_items, property_subtype_number_items) @@ -277,8 +283,14 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject char *pysubtype= NULL; int subtype= PROP_NONE; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssOO!si:BoolVectorProperty", (char **)kwlist, &id, &id_len, &name, &description, &pydef, &PySet_Type, &pyopts, &pysubtype, &size)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s#|ssOO!si:BoolVectorProperty", + (char **)kwlist, &id, &id_len, + &name, &description, &pydef, + &PySet_Type, &pyopts, &pysubtype,&size)) + { return NULL; + } BPY_PROPDEF_SUBTYPE_CHECK(BoolVectorProperty, property_flag_items, property_subtype_array_items) @@ -335,8 +347,15 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) char *pysubtype= NULL; int subtype= PROP_NONE; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssiiiiiiO!s:IntProperty", (char **)kwlist, &id, &id_len, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &PySet_Type, &pyopts, &pysubtype)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s#|ssiiiiiiO!s:IntProperty", + (char **)kwlist, &id, &id_len, + &name, &description, &def, + &min, &max, &soft_min, &soft_max, + &step, &PySet_Type, &pyopts, &pysubtype)) + { return NULL; + } BPY_PROPDEF_SUBTYPE_CHECK(IntProperty, property_flag_items, property_subtype_number_items) @@ -390,8 +409,16 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject char *pysubtype= NULL; int subtype= PROP_NONE; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssOiiiiiO!si:IntVectorProperty", (char **)kwlist, &id, &id_len, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &PySet_Type, &pyopts, &pysubtype, &size)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s#|ssOiiiiiO!si:IntVectorProperty", + (char **)kwlist, &id, &id_len, + &name, &description, &pydef, + &min, &max, &soft_min, &soft_max, + &step, &PySet_Type, &pyopts, + &pysubtype, &size)) + { return NULL; + } BPY_PROPDEF_SUBTYPE_CHECK(IntVectorProperty, property_flag_items, property_subtype_array_items) @@ -454,8 +481,16 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) char *pyunit= NULL; int unit= PROP_UNIT_NONE; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssffffffiO!ss:FloatProperty", (char **)kwlist, &id, &id_len, &name, &description, &def, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &pyunit)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s#|ssffffffiO!ss:FloatProperty", + (char **)kwlist, &id, &id_len, + &name, &description, &def, + &min, &max, &soft_min, &soft_max, + &step, &precision, &PySet_Type, + &pyopts, &pysubtype, &pyunit)) + { return NULL; + } BPY_PROPDEF_SUBTYPE_CHECK(FloatProperty, property_flag_items, property_subtype_number_items) @@ -514,8 +549,16 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec char *pysubtype= NULL; int subtype= PROP_NONE; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|ssOfffffiO!si:FloatVectorProperty", (char **)kwlist, &id, &id_len, &name, &description, &pydef, &min, &max, &soft_min, &soft_max, &step, &precision, &PySet_Type, &pyopts, &pysubtype, &size)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s#|ssOfffffiO!si:FloatVectorProperty", + (char **)kwlist, &id, &id_len, + &name, &description, &pydef, + &min, &max, &soft_min, &soft_max, + &step, &precision, &PySet_Type, + &pyopts, &pysubtype, &size)) + { return NULL; + } BPY_PROPDEF_SUBTYPE_CHECK(FloatVectorProperty, property_flag_items, property_subtype_array_items) @@ -572,8 +615,14 @@ static PyObject *BPy_StringProperty(PyObject *self, PyObject *args, PyObject *kw char *pysubtype= NULL; int subtype= PROP_NONE; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s#|sssiO!s:StringProperty", (char **)kwlist, &id, &id_len, &name, &description, &def, &maxlen, &PySet_Type, &pyopts, &pysubtype)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s#|sssiO!s:StringProperty", + (char **)kwlist, &id, &id_len, + &name, &description, &def, + &maxlen, &PySet_Type, &pyopts, &pysubtype)) + { return NULL; + } BPY_PROPDEF_SUBTYPE_CHECK(StringProperty, property_flag_items, property_subtype_string_items) @@ -607,7 +656,10 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i return NULL; } if(def && !PySet_Check(def)) { - PyErr_Format(PyExc_TypeError, "EnumProperty(...): default option must be a 'set' type when ENUM_FLAG is enabled, not a '%.200s'", Py_TYPE(def)->tp_name); + PyErr_Format(PyExc_TypeError, + "EnumProperty(...): default option must be a 'set' " + "type when ENUM_FLAG is enabled, not a '%.200s'", + Py_TYPE(def)->tp_name); return NULL; } } @@ -615,7 +667,10 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i if(def) { def_cmp= _PyUnicode_AsString(def); if(def_cmp==NULL) { - PyErr_Format(PyExc_TypeError, "EnumProperty(...): default option must be a 'str' type when ENUM_FLAG is disabled, not a '%.200s'", Py_TYPE(def)->tp_name); + PyErr_Format(PyExc_TypeError, + "EnumProperty(...): default option must be a 'str' " + "type when ENUM_FLAG is disabled, not a '%.200s'", + Py_TYPE(def)->tp_name); return NULL; } } @@ -666,7 +721,9 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i if(def && def_used != PySet_GET_SIZE(def)) { MEM_freeN(items); - PyErr_Format(PyExc_TypeError, "EnumProperty(..., default={...}): set has %d unused member(s)", PySet_GET_SIZE(def) - def_used); + PyErr_Format(PyExc_TypeError, + "EnumProperty(..., default={...}): set has %d unused member(s)", + PySet_GET_SIZE(def) - def_used); return NULL; } } @@ -674,7 +731,9 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i if(def && def_used == 0) { MEM_freeN(items); - PyErr_Format(PyExc_TypeError, "EnumProperty(..., default=\'%s\'): not found in enum members", def); + PyErr_Format(PyExc_TypeError, + "EnumProperty(..., default=\'%s\'): not found in enum members", + def); return NULL; } } @@ -714,8 +773,14 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) PyObject *pyopts= NULL; int opts=0; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s#O|ssOO!:EnumProperty", (char **)kwlist, &id, &id_len, &items, &name, &description, &def, &PySet_Type, &pyopts)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s#O|ssOO!:EnumProperty", + (char **)kwlist, &id, &id_len, + &items, &name, &description, + &def, &PySet_Type, &pyopts)) + { return NULL; + } BPY_PROPDEF_CHECK(EnumProperty, property_flag_enum_items) @@ -752,17 +817,23 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix if(PyErr_Occurred()) { PyObject *msg= PyC_ExceptionBuffer(); char *msg_char= _PyUnicode_AsString(msg); - PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from PropertyGroup, failed with: %s", error_prefix, msg_char); + PyErr_Format(PyExc_TypeError, + "%.200s expected an RNA type derived from PropertyGroup, failed with: %s", + error_prefix, msg_char); Py_DECREF(msg); } else { - PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from PropertyGroup, failed with type '%s'", error_prefix, Py_TYPE(value)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s expected an RNA type derived from PropertyGroup, failed with type '%s'", + error_prefix, Py_TYPE(value)->tp_name); } return NULL; } if(!RNA_struct_is_a(srna, &RNA_PropertyGroup)) { - PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from PropertyGroup", error_prefix); + PyErr_Format(PyExc_TypeError, + "%.200s expected an RNA type derived from PropertyGroup", + error_prefix); return NULL; } @@ -797,8 +868,14 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k PyObject *pyopts= NULL; int opts=0; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s#O|ssO!:PointerProperty", (char **)kwlist, &id, &id_len, &type, &name, &description, &PySet_Type, &pyopts)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s#O|ssO!:PointerProperty", + (char **)kwlist, &id, &id_len, + &type, &name, &description, + &PySet_Type, &pyopts)) + { return NULL; + } BPY_PROPDEF_CHECK(PointerProperty, property_flag_items) @@ -844,8 +921,14 @@ static PyObject *BPy_CollectionProperty(PyObject *self, PyObject *args, PyObject PyObject *pyopts= NULL; int opts=0; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s#O|ssO!:CollectionProperty", (char **)kwlist, &id, &id_len, &type, &name, &description, &PySet_Type, &pyopts)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s#O|ssO!:CollectionProperty", + (char **)kwlist, &id, &id_len, + &type, &name, &description, + &PySet_Type, &pyopts)) + { return NULL; + } BPY_PROPDEF_CHECK(CollectionProperty, property_flag_items) @@ -901,8 +984,12 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw char *id=NULL; - if (!PyArg_ParseTupleAndKeywords(args, kw, "s:RemoveProperty", (char **)kwlist, &id)) + if (!PyArg_ParseTupleAndKeywords(args, kw, + "s:RemoveProperty", + (char **)kwlist, &id)) + { return NULL; + } if(RNA_def_property_free_identifier(srna, id) != 1) { PyErr_Format(PyExc_TypeError, "RemoveProperty(): '%s' not a defined dynamic property", id); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 19cd9df9403..74af9761b98 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -91,7 +91,9 @@ int pyrna_prop_validity_check(BPy_PropertyRNA *self) { if(self->ptr.type) return 0; - PyErr_Format(PyExc_ReferenceError, "PropertyRNA of type %.200s.%.200s has been removed", Py_TYPE(self)->tp_name, RNA_property_identifier(self->prop)); + PyErr_Format(PyExc_ReferenceError, + "PropertyRNA of type %.200s.%.200s has been removed", + Py_TYPE(self)->tp_name, RNA_property_identifier(self->prop)); return -1; } @@ -303,7 +305,10 @@ static int rna_id_write_error(PointerRNA *ptr, PyObject *key) /* make a nice string error */ BLI_assert(idtype != NULL); - PyErr_Format(PyExc_AttributeError, "Writing to ID classes in this context is not allowed: %.200s, %.200s datablock, error setting %.200s.%.200s", id->name+2, idtype, RNA_struct_identifier(ptr->type), pyname); + PyErr_Format(PyExc_AttributeError, + "Writing to ID classes in this context is not allowed: " + "%.200s, %.200s datablock, error setting %.200s.%.200s", + id->name+2, idtype, RNA_struct_identifier(ptr->type), pyname); return TRUE; } @@ -392,7 +397,9 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype) #endif // USE_PEDANTIC_WRITE if (!RNA_property_editable_flag(&self->ptr, self->prop)) { - PyErr_Format(PyExc_AttributeError, "bpy_prop \"%.200s.%.200s\" is read-only", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop)); + PyErr_Format(PyExc_AttributeError, + "bpy_prop \"%.200s.%.200s\" is read-only", + RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop)); return -1; } @@ -454,7 +461,9 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp #endif // USE_PEDANTIC_WRITE if (!RNA_property_editable_flag(&self->ptr, self->prop)) { - PyErr_Format(PyExc_AttributeError, "bpy_prop \"%.200s.%.200s\" is read-only", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop)); + PyErr_Format(PyExc_AttributeError, + "bpy_prop \"%.200s.%.200s\" is read-only", + RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop)); return -1; } @@ -509,7 +518,9 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype)) #endif // USE_PEDANTIC_WRITE if (!RNA_property_editable_flag(&self->ptr, self->prop)) { - PyErr_Format(PyExc_AttributeError, "bpy_prop \"%.200s.%.200s\" is read-only", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop)); + PyErr_Format(PyExc_AttributeError, + "bpy_prop \"%.200s.%.200s\" is read-only", + RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop)); return -1; } @@ -684,7 +695,9 @@ int pyrna_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int { if(RNA_enum_value_from_id(item, identifier, value) == 0) { const char *enum_str= BPy_enum_as_string(item); - PyErr_Format(PyExc_TypeError, "%s: '%.200s' not found in (%s)", error_prefix, identifier, enum_str); + PyErr_Format(PyExc_TypeError, + "%s: '%.200s' not found in (%s)", + error_prefix, identifier, enum_str); MEM_freeN((void *)enum_str); return -1; } @@ -1017,7 +1030,9 @@ static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *pr if (param==NULL) { const char *enum_str= pyrna_enum_as_string(ptr, prop); - PyErr_Format(PyExc_TypeError, "%.200s expected a string enum type in (%.200s)", error_prefix, enum_str); + PyErr_Format(PyExc_TypeError, + "%.200s expected a string enum type in (%.200s)", + error_prefix, enum_str); MEM_freeN((void *)enum_str); return 0; } @@ -1028,7 +1043,9 @@ static int pyrna_string_to_enum(PyObject *item, PointerRNA *ptr, PropertyRNA *pr if (!RNA_property_enum_value(BPy_GetContext(), ptr, prop, param, val)) { const char *enum_str= pyrna_enum_as_string(ptr, prop); - PyErr_Format(PyExc_TypeError, "%.200s enum \"%.200s\" not found in (%.200s)", error_prefix, param, enum_str); + PyErr_Format(PyExc_TypeError, + "%.200s enum \"%.200s\" not found in (%.200s)", + error_prefix, param, enum_str); MEM_freeN((void *)enum_str); return 0; } @@ -1053,7 +1070,9 @@ int pyrna_set_to_enum_bitfield(EnumPropertyItem *items, PyObject *value, int *r_ const char *param= _PyUnicode_AsString(key); if(param==NULL) { - PyErr_Format(PyExc_TypeError, "%.200s expected a string, not %.200s", error_prefix, Py_TYPE(key)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s expected a string, not %.200s", + error_prefix, Py_TYPE(key)->tp_name); return -1; } if(pyrna_enum_value_from_id(items, param, &ret, error_prefix) < 0) @@ -1081,7 +1100,9 @@ static int pyrna_prop_to_enum_bitfield(PointerRNA *ptr, PropertyRNA *prop, PyObj } else { if(PySet_GET_SIZE(value)) { - PyErr_Format(PyExc_TypeError, "%.200s: empty enum \"%.200s\" could not have any values assigned", error_prefix, RNA_property_identifier(prop)); + PyErr_Format(PyExc_TypeError, + "%.200s: empty enum \"%.200s\" could not have any values assigned", + error_prefix, RNA_property_identifier(prop)); ret= -1; } else { @@ -1168,9 +1189,11 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val) if(free) MEM_freeN(enum_item); - - /*PyErr_Format(PyExc_AttributeError, "RNA Error: Current value \"%d\" matches no enum", val); - ret= NULL;*/ + /* + PyErr_Format(PyExc_AttributeError, + "RNA Error: Current value \"%d\" matches no enum", val); + ret= NULL; + */ } } @@ -1238,7 +1261,8 @@ PyObject * pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) ret= pyrna_prop_CreatePyObject(ptr, prop); break; default: - PyErr_Format(PyExc_TypeError, "bpy_struct internal error: unknown type '%d' (pyrna_prop_to_py)", type); + PyErr_Format(PyExc_TypeError, + "bpy_struct internal error: unknown type '%d' (pyrna_prop_to_py)", type); ret= NULL; break; } @@ -1263,7 +1287,9 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha if (strcmp(arg_name, "rna_type")==0) continue; if (kw==NULL) { - PyErr_Format(PyExc_TypeError, "%.200s: no keywords, expected \"%.200s\"", error_prefix, arg_name ? arg_name : ""); + PyErr_Format(PyExc_TypeError, + "%.200s: no keywords, expected \"%.200s\"", + error_prefix, arg_name ? arg_name : ""); error_val= -1; break; } @@ -1272,7 +1298,9 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha if (item == NULL) { if(all_args) { - PyErr_Format(PyExc_TypeError, "%.200s: keyword \"%.200s\" missing", error_prefix, arg_name ? arg_name : ""); + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" missing", + error_prefix, arg_name ? arg_name : ""); error_val= -1; /* pyrna_py_to_prop sets the error */ break; } @@ -1297,7 +1325,9 @@ int pyrna_pydict_to_props(PointerRNA *ptr, PyObject *kw, int all_args, const cha arg_name= NULL; } - PyErr_Format(PyExc_TypeError, "%.200s: keyword \"%.200s\" unrecognized", error_prefix, arg_name ? arg_name : ""); + PyErr_Format(PyExc_TypeError, + "%.200s: keyword \"%.200s\" unrecognized", + error_prefix, arg_name ? arg_name : ""); error_val= -1; } @@ -1313,7 +1343,9 @@ static PyObject *pyrna_func_to_py(BPy_DummyPointerRNA *pyrna, FunctionRNA *func) PyObject *ret; if(func==NULL) { - PyErr_Format(PyExc_RuntimeError, "%.200s: type attempted to get NULL function", RNA_struct_identifier(pyrna->ptr.type)); + PyErr_Format(PyExc_RuntimeError, + "%.200s: type attempted to get NULL function", + RNA_struct_identifier(pyrna->ptr.type)); return NULL; } @@ -1365,7 +1397,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb param= PyLong_AsLong(value); if(param < 0) { - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s expected True/False or 0/1, not %.200s", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), Py_TYPE(value)->tp_name); return -1; } else { @@ -1379,11 +1414,18 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb int overflow; long param= PyLong_AsLongAndOverflow(value, &overflow); if(overflow || (param > INT_MAX) || (param < INT_MIN)) { - PyErr_Format(PyExc_ValueError, "%.200s %.200s.%.200s value not in 'int' range (" STRINGIFY(INT_MIN) ", " STRINGIFY(INT_MAX) ")", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop)); + PyErr_Format(PyExc_ValueError, + "%.200s %.200s.%.200s value not in 'int' range " + "(" STRINGIFY(INT_MIN) ", " STRINGIFY(INT_MAX) ")", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop)); return -1; } else if (param==-1 && PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected an int type, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s expected an int type, not %.200s", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), Py_TYPE(value)->tp_name); return -1; } else { @@ -1398,7 +1440,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb { float param= PyFloat_AsDouble(value); if (PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a float type, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s expected a float type, not %.200s", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), Py_TYPE(value)->tp_name); return -1; } else { @@ -1426,7 +1471,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb #endif // USE_STRING_COERCE if (param==NULL) { - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a string type, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s expected a string type, not %.200s", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), Py_TYPE(value)->tp_name); return -1; } else { @@ -1453,13 +1501,20 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb return -1; } else { - PyErr_Format(PyExc_TypeError, "%.200s, %.200s.%.200s is not a bitflag enum type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop)); + PyErr_Format(PyExc_TypeError, + "%.200s, %.200s.%.200s is not a bitflag enum type", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop)); return -1; } } else { const char *enum_str= pyrna_enum_as_string(ptr, prop); - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a string enum or a set of strings in (%.2000s), not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), enum_str, Py_TYPE(value)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s expected a string enum or a set of strings in (%.2000s), not %.200s", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), enum_str, + Py_TYPE(value)->tp_name); MEM_freeN((void *)enum_str); return -1; } @@ -1511,21 +1566,35 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb value_new= value; } else { - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s collection has no type, cant be used as a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptr_type)); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s collection has no type, " + "cant be used as a %.200s type", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), RNA_struct_identifier(ptr_type)); return -1; } } if(!BPy_StructRNA_Check(value) && value != Py_None) { - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptr_type), Py_TYPE(value)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s expected a %.200s type, not %.200s", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), RNA_struct_identifier(ptr_type), + Py_TYPE(value)->tp_name); Py_XDECREF(value_new); return -1; } else if((flag & PROP_NEVER_NULL) && value == Py_None) { - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptr_type)); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), RNA_struct_identifier(ptr_type)); Py_XDECREF(value_new); return -1; } else if(value != Py_None && ((flag & PROP_ID_SELF_CHECK) && ptr->id.data == ((BPy_StructRNA*)value)->ptr.id.data)) { - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s ID type does not support assignment to its self", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop)); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s ID type does not support assignment to its self", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop)); Py_XDECREF(value_new); return -1; } else { @@ -1561,7 +1630,11 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb else { PointerRNA tmp; RNA_pointer_create(NULL, ptr_type, NULL, &tmp); - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type. not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(tmp.type), RNA_struct_identifier(param->ptr.type)); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s expected a %.200s type. not %.200s", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), RNA_struct_identifier(tmp.type), + RNA_struct_identifier(param->ptr.type)); Py_XDECREF(value_new); return -1; } } @@ -1569,7 +1642,11 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb if(raise_error) { PointerRNA tmp; RNA_pointer_create(NULL, ptr_type, NULL, &tmp); - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(tmp.type), RNA_struct_identifier(param->ptr.type)); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s expected a %.200s type, not %.200s", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), RNA_struct_identifier(tmp.type), + RNA_struct_identifier(param->ptr.type)); Py_XDECREF(value_new); return -1; } } @@ -1590,7 +1667,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb /* convert a sequence of dict's into a collection */ if(!PySequence_Check(value)) { - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a sequence for an RNA collection, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s expected a sequence for an RNA collection, not %.200s", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), Py_TYPE(value)->tp_name); return -1; } @@ -1599,13 +1679,20 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb item= PySequence_GetItem(value, i); if(item==NULL) { - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), i); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), i); Py_XDECREF(item); return -1; } if(PyDict_Check(item)==0) { - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a each sequence member to be a dict for an RNA collection, not %.200s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(item)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s expected a each sequence " + "member to be a dict for an RNA collection, not %.200s", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), Py_TYPE(item)->tp_name); Py_XDECREF(item); return -1; } @@ -1622,7 +1709,11 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb PyObject *msg= PyC_ExceptionBuffer(); const char *msg_char= _PyUnicode_AsString(msg); - PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s error converting a member of a collection from a dicts into an RNA collection, failed with: %s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), msg_char); + PyErr_Format(PyExc_TypeError, + "%.200s %.200s.%.200s error converting a member of a collection " + "from a dicts into an RNA collection, failed with: %s", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop), msg_char); Py_DECREF(item); Py_DECREF(msg); @@ -1634,7 +1725,10 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb break; } default: - PyErr_Format(PyExc_AttributeError, "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop)); + PyErr_Format(PyExc_AttributeError, + "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)", + error_prefix, RNA_struct_identifier(ptr->type), + RNA_property_identifier(prop)); return -1; break; } @@ -1793,10 +1887,15 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s else { const int len= RNA_property_collection_length(&self->ptr, self->prop); if(keynum_abs >= len) { - PyErr_Format(PyExc_IndexError, "bpy_prop_collection[index]: index %d out of range, size %d", keynum, len); + PyErr_Format(PyExc_IndexError, + "bpy_prop_collection[index]: " + "index %d out of range, size %d", keynum, len); } else { - PyErr_Format(PyExc_RuntimeError, "bpy_prop_collection[index]: internal error, valid index %d given in %d sized collection but value not found", keynum_abs, len); + PyErr_Format(PyExc_RuntimeError, + "bpy_prop_collection[index]: internal error, " + "valid index %d given in %d sized collection but value not found", + keynum_abs, len); } return NULL; @@ -2005,7 +2104,10 @@ static PyObject *pyrna_prop_collection_subscript(BPy_PropertyRNA *self, PyObject } } else { - PyErr_Format(PyExc_TypeError, "bpy_prop_collection[key]: invalid key, must be a string or an int, not %.200s", Py_TYPE(key)->tp_name); + PyErr_Format(PyExc_TypeError, + "bpy_prop_collection[key]: invalid key, " + "must be a string or an int, not %.200s", + Py_TYPE(key)->tp_name); return NULL; } } @@ -2186,10 +2288,12 @@ static int pyrna_prop_array_ass_subscript(BPy_PropertyArrayRNA *self, PyObject * /* char *keyname= NULL; */ /* not supported yet */ int ret= -1; - PYRNA_PROP_CHECK_INT((BPy_PropertyRNA *)self) + PYRNA_PROP_CHECK_INT((BPy_PropertyRNA *)self); if (!RNA_property_editable_flag(&self->ptr, self->prop)) { - PyErr_Format(PyExc_AttributeError, "bpy_prop_collection: attribute \"%.200s\" from \"%.200s\" is read-only", RNA_property_identifier(self->prop), RNA_struct_identifier(self->ptr.type)); + PyErr_Format(PyExc_AttributeError, + "bpy_prop_collection: attribute \"%.200s\" from \"%.200s\" is read-only", + RNA_property_identifier(self->prop), RNA_struct_identifier(self->ptr.type)); ret= -1; } @@ -2525,7 +2629,9 @@ static PyObject *pyrna_struct_is_property_set(BPy_StructRNA *self, PyObject *arg return NULL; if((prop= RNA_struct_find_property(&self->ptr, name)) == NULL) { - PyErr_Format(PyExc_TypeError, "%.200s.is_property_set(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name); + PyErr_Format(PyExc_TypeError, + "%.200s.is_property_set(\"%.200s\") not found", + RNA_struct_identifier(self->ptr.type), name); return NULL; } @@ -2566,7 +2672,9 @@ static PyObject *pyrna_struct_is_property_hidden(BPy_StructRNA *self, PyObject * return NULL; if((prop= RNA_struct_find_property(&self->ptr, name)) == NULL) { - PyErr_Format(PyExc_TypeError, "%.200s.is_property_hidden(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name); + PyErr_Format(PyExc_TypeError, + "%.200s.is_property_hidden(\"%.200s\") not found", + RNA_struct_identifier(self->ptr.type), name); return NULL; } @@ -2600,7 +2708,9 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args) if(r_prop) { if(index != -1) { if(index >= RNA_property_array_length(&r_ptr, r_prop) || index < 0) { - PyErr_Format(PyExc_TypeError, "%.200s.path_resolve(\"%.200s\") index out of range", RNA_struct_identifier(self->ptr.type), path); + PyErr_Format(PyExc_TypeError, + "%.200s.path_resolve(\"%.200s\") index out of range", + RNA_struct_identifier(self->ptr.type), path); return NULL; } else { @@ -2621,7 +2731,9 @@ static PyObject *pyrna_struct_path_resolve(BPy_StructRNA *self, PyObject *args) } } else { - PyErr_Format(PyExc_TypeError, "%.200s.path_resolve(\"%.200s\") could not be resolved", RNA_struct_identifier(self->ptr.type), path); + PyErr_Format(PyExc_TypeError, + "%.200s.path_resolve(\"%.200s\") could not be resolved", + RNA_struct_identifier(self->ptr.type), path); return NULL; } } @@ -2651,7 +2763,9 @@ static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args) if(name) { prop= RNA_struct_find_property(&self->ptr, name); if(prop==NULL) { - PyErr_Format(PyExc_TypeError, "%.200s.path_from_id(\"%.200s\") not found", RNA_struct_identifier(self->ptr.type), name); + PyErr_Format(PyExc_TypeError, + "%.200s.path_from_id(\"%.200s\") not found", + RNA_struct_identifier(self->ptr.type), name); return NULL; } @@ -2662,8 +2776,16 @@ static PyObject *pyrna_struct_path_from_id(BPy_StructRNA *self, PyObject *args) } if(path==NULL) { - if(name) PyErr_Format(PyExc_TypeError, "%.200s.path_from_id(\"%s\") found but does not support path creation", RNA_struct_identifier(self->ptr.type), name); - else PyErr_Format(PyExc_TypeError, "%.200s.path_from_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type)); + if(name) { + PyErr_Format(PyExc_TypeError, + "%.200s.path_from_id(\"%s\") found but does not support path creation", + RNA_struct_identifier(self->ptr.type), name); + } + else { + PyErr_Format(PyExc_TypeError, + "%.200s.path_from_id() does not support path creation for this type", + RNA_struct_identifier(self->ptr.type)); + } return NULL; } @@ -2690,7 +2812,9 @@ static PyObject *pyrna_prop_path_from_id(BPy_PropertyRNA *self) path= RNA_path_from_ID_to_property(&self->ptr, self->prop); if(path==NULL) { - PyErr_Format(PyExc_TypeError, "%.200s.%.200s.path_from_id() does not support path creation for this type", RNA_struct_identifier(self->ptr.type), RNA_property_identifier(prop)); + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s.path_from_id() does not support path creation for this type", + RNA_struct_identifier(self->ptr.type), RNA_property_identifier(prop)); return NULL; } @@ -2905,7 +3029,9 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) /* should never happen */ BLI_assert(!"Invalid context type"); - PyErr_Format(PyExc_AttributeError, "bpy_struct: Context type invalid %d, can't get \"%.200s\" from context", newtype, name); + PyErr_Format(PyExc_AttributeError, + "bpy_struct: Context type invalid %d, can't get \"%.200s\" from context", + newtype, name); ret= NULL; } } @@ -2993,7 +3119,10 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb const int is_deferred_prop= (value && pyrna_is_deferred_prop(value)); if(srna && !pyrna_write_check() && (is_deferred_prop || RNA_struct_type_find_property(srna, _PyUnicode_AsString(attr)))) { - PyErr_Format(PyExc_AttributeError, "pyrna_struct_meta_idprop_setattro() can't set in readonly state '%.200s.%S'", ((PyTypeObject *)cls)->tp_name, attr); + PyErr_Format(PyExc_AttributeError, + "pyrna_struct_meta_idprop_setattro() " + "can't set in readonly state '%.200s.%S'", + ((PyTypeObject *)cls)->tp_name, attr); return -1; } @@ -3001,7 +3130,9 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb /* allow setting on unregistered classes which can be registered later on */ /* if(value && is_deferred_prop) { - PyErr_Format(PyExc_AttributeError, "pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'", ((PyTypeObject *)cls)->tp_name); + PyErr_Format(PyExc_AttributeError, + "pyrna_struct_meta_idprop_setattro() unable to get srna from class '%.200s'", + ((PyTypeObject *)cls)->tp_name); return -1; } */ @@ -3062,7 +3193,9 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject } else if (name[0] != '_' && (prop= RNA_struct_find_property(&self->ptr, name))) { if (!RNA_property_editable_flag(&self->ptr, prop)) { - PyErr_Format(PyExc_AttributeError, "bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only", RNA_property_identifier(prop), RNA_struct_identifier(self->ptr.type)); + PyErr_Format(PyExc_AttributeError, + "bpy_struct: attribute \"%.200s\" from \"%.200s\" is read-only", + RNA_property_identifier(prop), RNA_struct_identifier(self->ptr.type)); return -1; } } @@ -3533,7 +3666,9 @@ static int foreach_parse_args( /* rna_access.c - rna_raw_access(...) uses this same method */ if(target_tot != (*tot)) { - PyErr_Format(PyExc_TypeError, "foreach_get(attr, sequence) sequence length mismatch given %d, needed %d", *tot, target_tot); + PyErr_Format(PyExc_TypeError, + "foreach_get(attr, sequence) sequence length mismatch given %d, needed %d", + *tot, target_tot); return -1; } #endif @@ -4117,7 +4252,9 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw) } if(self_func==NULL) { - PyErr_Format(PyExc_RuntimeError, "%.200s.(): rna function internal function is NULL, this is a bug. aborting", RNA_struct_identifier(self_ptr->type)); + PyErr_Format(PyExc_RuntimeError, + "%.200s.(): rna function internal function is NULL, this is a bug. aborting", + RNA_struct_identifier(self_ptr->type)); return NULL; } @@ -4146,7 +4283,10 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw) if(pyargs_len + pykw_len > parms_len) { RNA_parameter_list_end(&iter); - PyErr_Format(PyExc_TypeError, "%.200s.%.200s(): takes at most %d arguments, got %d", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), parms_len, pyargs_len + pykw_len); + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s(): takes at most %d arguments, got %d", + RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), + parms_len, pyargs_len + pykw_len); err= -1; } @@ -4185,7 +4325,9 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw) if (item==NULL) { if(flag & PROP_REQUIRED) { - PyErr_Format(PyExc_TypeError, "%.200s.%.200s(): required parameter \"%.200s\" not specified", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), parm_id); + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s(): required parameter \"%.200s\" not specified", + RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), parm_id); err= -1; break; } @@ -4275,7 +4417,10 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw) bad_args_str= BLI_dynstr_get_cstring(bad_args); good_args_str= BLI_dynstr_get_cstring(good_args); - PyErr_Format(PyExc_TypeError, "%.200s.%.200s(): was called with invalid keyword arguments(s) (%s), expected (%s)", RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), bad_args_str, good_args_str); + PyErr_Format(PyExc_TypeError, + "%.200s.%.200s(): was called with invalid keyword arguments(s) (%s), expected (%s)", + RNA_struct_identifier(self_ptr->type), RNA_function_identifier(self_func), + bad_args_str, good_args_str); BLI_dynstr_free(bad_args); BLI_dynstr_free(good_args); @@ -5372,12 +5517,16 @@ static PyObject *pyrna_basetype_getattro(BPy_BaseTypeRNA *self, PyObject *pyname else if (RNA_property_collection_lookup_string(&self->ptr, self->prop, name, &newptr)) { ret= pyrna_struct_Subtype(&newptr); if (ret==NULL) { - PyErr_Format(PyExc_RuntimeError, "bpy.types.%.200s subtype could not be generated, this is a bug!", _PyUnicode_AsString(pyname)); + PyErr_Format(PyExc_RuntimeError, + "bpy.types.%.200s subtype could not be generated, this is a bug!", + _PyUnicode_AsString(pyname)); } } else { #if 0 - PyErr_Format(PyExc_AttributeError, "bpy.types.%.200s RNA_Struct does not exist", _PyUnicode_AsString(pyname)); + PyErr_Format(PyExc_AttributeError, + "bpy.types.%.200s RNA_Struct does not exist", + _PyUnicode_AsString(pyname)); return NULL; #endif /* The error raised here will be displayed */ @@ -5463,18 +5612,25 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, int parent, const char *error_pr } if(py_srna==NULL) { - PyErr_Format(PyExc_RuntimeError, "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)", error_prefix, Py_TYPE(self)->tp_name); + PyErr_Format(PyExc_RuntimeError, + "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)", + error_prefix, Py_TYPE(self)->tp_name); return NULL; } if(!BPy_StructRNA_Check(py_srna)) { - PyErr_Format(PyExc_TypeError, "%.200s, bl_rna attribute wrong type '%.200s' on '%.200s'' instance", error_prefix, Py_TYPE(py_srna)->tp_name, Py_TYPE(self)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s, bl_rna attribute wrong type '%.200s' on '%.200s'' instance", + error_prefix, Py_TYPE(py_srna)->tp_name, + Py_TYPE(self)->tp_name); Py_DECREF(py_srna); return NULL; } if(py_srna->ptr.type != &RNA_Struct) { - PyErr_Format(PyExc_TypeError, "%.200s, bl_rna attribute not a RNA_Struct, on '%.200s'' instance", error_prefix, Py_TYPE(self)->tp_name); + PyErr_Format(PyExc_TypeError, + "%.200s, bl_rna attribute not a RNA_Struct, on '%.200s'' instance", + error_prefix, Py_TYPE(self)->tp_name); Py_DECREF(py_srna); return NULL; } @@ -5533,7 +5689,10 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item PyObject *args_fake; if(*_PyUnicode_AsString(key)=='_') { - PyErr_Format(PyExc_ValueError, "bpy_struct \"%.200s\" registration error: %.200s could not register because the property starts with an '_'\n", RNA_struct_identifier(srna), _PyUnicode_AsString(key)); + PyErr_Format(PyExc_ValueError, + "bpy_struct \"%.200s\" registration error: " + "%.200s could not register because the property starts with an '_'\n", + RNA_struct_identifier(srna), _PyUnicode_AsString(key)); return -1; } py_srna_cobject= PyCapsule_New(srna, NULL, NULL); @@ -5556,7 +5715,10 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item PyErr_Clear(); // PyC_LineSpit(); - PyErr_Format(PyExc_ValueError, "bpy_struct \"%.200s\" registration error: %.200s could not register\n", RNA_struct_identifier(srna), _PyUnicode_AsString(key)); + PyErr_Format(PyExc_ValueError, + "bpy_struct \"%.200s\" registration error: " + "%.200s could not register\n", + RNA_struct_identifier(srna), _PyUnicode_AsString(key)); return -1; } } @@ -5683,7 +5845,9 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun if (base_class) { if (!PyObject_IsSubclass(py_class, base_class)) { - PyErr_Format(PyExc_TypeError, "expected %.200s subclass of class \"%.200s\"", class_type, py_class_name); + PyErr_Format(PyExc_TypeError, + "expected %.200s subclass of class \"%.200s\"", + class_type, py_class_name); return -1; } } @@ -5705,7 +5869,10 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun if (item==NULL) { if ((flag & FUNC_REGISTER_OPTIONAL)==0) { - PyErr_Format(PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", class_type, py_class_name, RNA_function_identifier(func)); + PyErr_Format(PyExc_AttributeError, + "expected %.200s, %.200s class to have an \"%.200s\" attribute", + class_type, py_class_name, + RNA_function_identifier(func)); return -1; } @@ -5715,14 +5882,18 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun Py_DECREF(item); /* no need to keep a ref, the class owns it (technically we should keep a ref but...) */ if(flag & FUNC_NO_SELF) { if (PyMethod_Check(item)==0) { - PyErr_Format(PyExc_TypeError, "expected %.200s, %.200s class \"%.200s\" attribute to be a method, not a %.200s", class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name); + PyErr_Format(PyExc_TypeError, + "expected %.200s, %.200s class \"%.200s\" attribute to be a method, not a %.200s", + class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name); return -1; } item= ((PyMethodObject *)item)->im_func; } else { if (PyFunction_Check(item)==0) { - PyErr_Format(PyExc_TypeError, "expected %.200s, %.200s class \"%.200s\" attribute to be a function, not a %.200s", class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name); + PyErr_Format(PyExc_TypeError, + "expected %.200s, %.200s class \"%.200s\" attribute to be a function, not a %.200s", + class_type, py_class_name, RNA_function_identifier(func), Py_TYPE(item)->tp_name); return -1; } } @@ -5740,7 +5911,10 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun func_arg_count++; if (arg_count != func_arg_count) { - PyErr_Format(PyExc_ValueError, "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d", class_type, py_class_name, RNA_function_identifier(func), func_arg_count, arg_count); + PyErr_Format(PyExc_ValueError, + "expected %.200s, %.200s class \"%.200s\" function to have %d args, found %d", + class_type, py_class_name, RNA_function_identifier(func), + func_arg_count, arg_count); return -1; } } @@ -5782,7 +5956,9 @@ static int bpy_class_validate(PointerRNA *dummyptr, void *py_data, int *have_fun #undef BPY_REPLACEMENT_STRING if (item == NULL && (((flag & PROP_REGISTER_OPTIONAL) != PROP_REGISTER_OPTIONAL))) { - PyErr_Format(PyExc_AttributeError, "expected %.200s, %.200s class to have an \"%.200s\" attribute", class_type, py_class_name, identifier); + PyErr_Format(PyExc_AttributeError, + "expected %.200s, %.200s class to have an \"%.200s\" attribute", + class_type, py_class_name, identifier); return -1; } @@ -5972,14 +6148,18 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param else { PyErr_Print(); PyErr_Clear(); - PyErr_Format(PyExc_TypeError, "could not find function %.200s in %.200s to execute callback", RNA_function_identifier(func), RNA_struct_identifier(ptr->type)); + PyErr_Format(PyExc_TypeError, + "could not find function %.200s in %.200s to execute callback", + RNA_function_identifier(func), RNA_struct_identifier(ptr->type)); err= -1; } } else { /* the error may be already set if the class instance couldn't be created */ if(err != -1) { - PyErr_Format(PyExc_RuntimeError, "could not create instance of %.200s to call callback function %.200s", RNA_struct_identifier(ptr->type), RNA_function_identifier(func)); + PyErr_Format(PyExc_RuntimeError, + "could not create instance of %.200s to call callback function %.200s", + RNA_struct_identifier(ptr->type), RNA_function_identifier(func)); err= -1; } } @@ -5989,7 +6169,10 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param } else { if(ret_len==0 && ret != Py_None) { - PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return None, not %.200s", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), Py_TYPE(ret)->tp_name); + PyErr_Format(PyExc_RuntimeError, + "expected class %.200s, function %.200s to return None, not %.200s", + RNA_struct_identifier(ptr->type), RNA_function_identifier(func), + Py_TYPE(ret)->tp_name); err= -1; } else if(ret_len==1) { @@ -5998,11 +6181,17 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param else if (ret_len > 1) { if(PyTuple_Check(ret)==0) { - PyErr_Format(PyExc_RuntimeError, "expected class %.200s, function %.200s to return a tuple of size %d, not %.200s", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), ret_len, Py_TYPE(ret)->tp_name); + PyErr_Format(PyExc_RuntimeError, + "expected class %.200s, function %.200s to return a tuple of size %d, not %.200s", + RNA_struct_identifier(ptr->type), RNA_function_identifier(func), + ret_len, Py_TYPE(ret)->tp_name); err= -1; } else if (PyTuple_GET_SIZE(ret) != ret_len) { - PyErr_Format(PyExc_RuntimeError, "class %.200s, function %.200s to returned %d items, expected %d", RNA_struct_identifier(ptr->type), RNA_function_identifier(func), PyTuple_GET_SIZE(ret), ret_len); + PyErr_Format(PyExc_RuntimeError, + "class %.200s, function %.200s to returned %d items, expected %d", + RNA_struct_identifier(ptr->type), RNA_function_identifier(func), + PyTuple_GET_SIZE(ret), ret_len); err= -1; } else { @@ -6178,7 +6367,9 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class /* fails in cases, cant use this check but would like to :| */ /* if(RNA_struct_py_type_get(srna)) { - PyErr_Format(PyExc_ValueError, "register_class(...): %.200s's parent class %.200s is already registered, this is not allowed", ((PyTypeObject*)py_class)->tp_name, RNA_struct_identifier(srna)); + PyErr_Format(PyExc_ValueError, + "register_class(...): %.200s's parent class %.200s is already registered, this is not allowed", + ((PyTypeObject*)py_class)->tp_name, RNA_struct_identifier(srna)); return NULL; } */ @@ -6187,7 +6378,10 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class reg= RNA_struct_register(srna); if(!reg) { - PyErr_Format(PyExc_ValueError, "register_class(...): expected a subclass of a registerable rna type (%.200s does not support registration)", RNA_struct_identifier(srna)); + PyErr_Format(PyExc_ValueError, + "register_class(...): expected a subclass of a registerable " + "rna type (%.200s does not support registration)", + RNA_struct_identifier(srna)); return NULL; } @@ -6338,7 +6532,9 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla RNA_PROP_END; if(prop_identifier) { - PyErr_Format(PyExc_RuntimeError, "unregister_class(...): can't unregister %s because %s.%s pointer property is using this", RNA_struct_identifier(srna), RNA_struct_identifier(srna_iter), prop_identifier); + PyErr_Format(PyExc_RuntimeError, + "unregister_class(...): can't unregister %s because %s.%s pointer property is using this", + RNA_struct_identifier(srna), RNA_struct_identifier(srna_iter), prop_identifier); return NULL; } } diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index b7f638b6441..5e53d4101f6 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -53,14 +53,16 @@ /* for keyframes and drivers */ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefix, const char *path, - const char **path_full, int *index) + const char **path_full, int *index) { const int is_idbase= RNA_struct_is_ID(ptr->type); PropertyRNA *prop; PointerRNA r_ptr; if (ptr->data==NULL) { - PyErr_Format(PyExc_TypeError, "%.200s this struct has no data, can't be animated", error_prefix); + PyErr_Format(PyExc_TypeError, + "%.200s this struct has no data, can't be animated", + error_prefix); return -1; } @@ -71,11 +73,15 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi prop= NULL; } else if(r_index != -1) { - PyErr_Format(PyExc_ValueError, "%.200s path includes index, must be a separate argument", error_prefix, path); + PyErr_Format(PyExc_ValueError, + "%.200s path includes index, must be a separate argument", + error_prefix, path); return -1; } else if(ptr->id.data != r_ptr.id.data) { - PyErr_Format(PyExc_ValueError, "%.200s path spans ID blocks", error_prefix, path); + PyErr_Format(PyExc_ValueError, + "%.200s path spans ID blocks", + error_prefix, path); return -1; } } @@ -85,12 +91,16 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi } if (prop==NULL) { - PyErr_Format(PyExc_TypeError, "%.200s property \"%s\" not found", error_prefix, path); + PyErr_Format(PyExc_TypeError, + "%.200s property \"%s\" not found", + error_prefix, path); return -1; } if (!RNA_property_animateable(&r_ptr, prop)) { - PyErr_Format(PyExc_TypeError, "%.200s property \"%s\" not animatable", error_prefix, path); + PyErr_Format(PyExc_TypeError, + "%.200s property \"%s\" not animatable", + error_prefix, path); return -1; } @@ -99,14 +109,18 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi *index= 0; } else { - PyErr_Format(PyExc_TypeError, "%.200s index %d was given while property \"%s\" is not an array", error_prefix, *index, path); + PyErr_Format(PyExc_TypeError, + "%.200s index %d was given while property \"%s\" is not an array", + error_prefix, *index, path); return -1; } } else { int array_len= RNA_property_array_length(&r_ptr, prop); if((*index) < -1 || (*index) >= array_len) { - PyErr_Format(PyExc_TypeError, "%.200s index out of range \"%s\", given %d, array length is %d", error_prefix, path, *index, array_len); + PyErr_Format(PyExc_TypeError, + "%.200s index out of range \"%s\", given %d, array length is %d", + error_prefix, path, *index, array_len); return -1; } } @@ -118,7 +132,9 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi *path_full= RNA_path_from_ID_to_property(&r_ptr, prop); if (*path_full==NULL) { - PyErr_Format(PyExc_TypeError, "%.200s could not make path to \"%s\"", error_prefix, path); + PyErr_Format(PyExc_TypeError, + "%.200s could not make path to \"%s\"", + error_prefix, path); return -1; } } @@ -128,7 +144,7 @@ static int pyrna_struct_anim_args_parse(PointerRNA *ptr, const char *error_prefi /* internal use for insert and delete */ static int pyrna_struct_keyframe_parse(PointerRNA *ptr, PyObject *args, PyObject *kw, const char *parse_str, const char *error_prefix, - const char **path_full, int *index, float *cfra, const char **group_name) /* return values */ + const char **path_full, int *index, float *cfra, const char **group_name) /* return values */ { static const char *kwlist[]= {"data_path", "index", "frame", "group", NULL}; const char *path; @@ -172,7 +188,10 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb PYRNA_STRUCT_CHECK_OBJ(self) - if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1) { + if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, + "s|ifs:bpy_struct.keyframe_insert()", "bpy_struct.keyframe_insert()", + &path_full, &index, &cfra, &group_name) == -1) + { return NULL; } else { @@ -217,7 +236,11 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb PYRNA_STRUCT_CHECK_OBJ(self) - if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, "s|ifs:bpy_struct.keyframe_delete()", "bpy_struct.keyframe_insert()", &path_full, &index, &cfra, &group_name) == -1) { + if(pyrna_struct_keyframe_parse(&self->ptr, args, kw, + "s|ifs:bpy_struct.keyframe_delete()", + "bpy_struct.keyframe_insert()", + &path_full, &index, &cfra, &group_name) == -1) + { return NULL; } else { diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c index 1a6caa02b0c..17f082b79dc 100644 --- a/source/blender/python/intern/bpy_traceback.c +++ b/source/blender/python/intern/bpy_traceback.c @@ -139,8 +139,6 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset) *lineno= -1; } } - - /* this avoids an abort in Python 2.3's garbage collecting */ } else { PyErr_NormalizeException(&exception, &value, (PyObject **)&tb); diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index 0b5dacac4b2..6e321015bc6 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -138,7 +138,9 @@ int PyC_AsArray(void *array, PyObject *value, int length, PyTypeObject *type, co if(value_len != length) { Py_DECREF(value); - PyErr_Format(PyExc_TypeError, "%.200s: invalid sequence length. expected %d, got %d", error_prefix, length, value_len); + PyErr_Format(PyExc_TypeError, + "%.200s: invalid sequence length. expected %d, got %d", + error_prefix, length, value_len); return -1; } @@ -163,14 +165,18 @@ int PyC_AsArray(void *array, PyObject *value, int length, PyTypeObject *type, co } else { Py_DECREF(value_fast); - PyErr_Format(PyExc_TypeError, "%s: internal error %s is invalid", error_prefix, type->tp_name); + PyErr_Format(PyExc_TypeError, + "%s: internal error %s is invalid", + error_prefix, type->tp_name); return -1; } Py_DECREF(value_fast); if(PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, "%s: one or more items could not be used as a %s", error_prefix, type->tp_name); + PyErr_Format(PyExc_TypeError, + "%s: one or more items could not be used as a %s", + error_prefix, type->tp_name); return -1; } diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 38d7b52399f..382c230ceac 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -191,6 +191,7 @@ void RE_InitState (struct Render *re, struct Render *source, struct RenderData * void RE_SetDispRect (struct Render *re, rcti *disprect); /* set up the viewplane/perspective matrix, three choices */ +struct Object *RE_GetCamera(struct Render *re); /* return camera override if set */ void RE_SetCamera(struct Render *re, struct Object *camera); void RE_SetWindow (struct Render *re, rctf *viewplane, float clipsta, float clipend); void RE_SetOrtho (struct Render *re, rctf *viewplane, float clipsta, float clipend); @@ -216,8 +217,8 @@ void RE_init_threadcount(Render *re); void RE_TileProcessor(struct Render *re); /* only RE_NewRender() needed, main Blender render calls */ -void RE_BlenderFrame(struct Render *re, struct Main *bmain, struct Scene *scene, struct SceneRenderLayer *srl, unsigned int lay, int frame, const short write_still); -void RE_BlenderAnim(struct Render *re, struct Main *bmain, struct Scene *scene, unsigned int lay, int sfra, int efra, int tfra, struct ReportList *reports); +void RE_BlenderFrame(struct Render *re, struct Main *bmain, struct Scene *scene, struct SceneRenderLayer *srl, struct Object *camera_override, unsigned int lay, int frame, const short write_still); +void RE_BlenderAnim(struct Render *re, struct Main *bmain, struct Scene *scene, struct Object *camera_override, unsigned int lay, int sfra, int efra, int tfra, struct ReportList *reports); void RE_RenderFreestyleStrokes(struct Render *re, struct Main *bmain, struct Scene *scene); /* main preview render call */ @@ -306,7 +307,7 @@ void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char void RE_engines_init(void); void RE_engines_exit(void); -int RE_is_rendering_allowed(struct Scene *scene, void *erh, void (*error)(void *handle, const char *str)); +int RE_is_rendering_allowed(struct Scene *scene, struct Object *camera_override, void *erh, void (*error)(void *handle, const char *str)); #endif /* RE_PIPELINE_H */ diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 4eeed1b44dc..c0b40b32587 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -182,6 +182,7 @@ struct Render Scene *scene; RenderData r; World wrld; + struct Object *camera_override; unsigned int lay; ListBase parts; @@ -487,6 +488,7 @@ typedef struct VolPrecachePart float bbmin[3]; float voxel[3]; int working, done; + struct Render *re; } VolPrecachePart; typedef struct VolumePrecache diff --git a/source/blender/render/intern/raytrace/reorganize.h b/source/blender/render/intern/raytrace/reorganize.h index 856df6ba320..4df10bd9f84 100644 --- a/source/blender/render/intern/raytrace/reorganize.h +++ b/source/blender/render/intern/raytrace/reorganize.h @@ -133,7 +133,7 @@ void reorganize(Node *root) /* * Prunes useless nodes from trees: - * erases nodes with total ammount of primitives = 0 + * erases nodes with total amount of primitives = 0 * prunes nodes with only one child (except if that child is a primitive) */ template diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 1a19bbe7320..74ce7957dd7 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -164,12 +164,14 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), World *wrld= NULL; HaloRen *har; Scene *scene; - Camera *camera; + Object *camera; + Camera *cam; double dblrand, hlfrand; float vec[4], fx, fy, fz; float fac, starmindist, clipend; float mat[4][4], stargrid, maxrand, maxjit, force, alpha; int x, y, z, sx, sy, sz, ex, ey, ez, done = 0; + unsigned int totstar= 0; if(initfunc) { scene= scenev3d; @@ -179,7 +181,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), scene= re->scene; wrld= &(re->wrld); } - + stargrid = wrld->stardist; /* distance between stars */ maxrand = 2.0; /* amount a star can be shifted (in grid units) */ maxjit = (wrld->starcolnoise); /* amount a color is being shifted */ @@ -204,11 +206,13 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), * y = -z | +z */ - if(scene->camera==NULL || scene->camera->type != OB_CAMERA) + camera= re ? RE_GetCamera(re) : scene->camera; + + if(camera==NULL || camera->type != OB_CAMERA) return; - camera = scene->camera->data; - clipend = camera->clipend; + cam = camera->data; + clipend = cam->clipend; /* convert to grid coordinates */ @@ -294,6 +298,17 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), } } } + + /* break out of the loop if generating stars takes too long */ + if(re && !(totstar % 1000000)) { + if(re->test_break(re->tbh)) { + x= ex + 1; + y= ey + 1; + z= ez + 1; + } + } + + totstar++; } /* do not call blender_test_break() here, since it is used in UI as well, confusing the callback system */ /* main cause is G.afbreek of course, a global again... (ton) */ @@ -1664,7 +1679,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem bb.align = part->bb_align; bb.anim = part->bb_anim; bb.lock = part->draw & PART_DRAW_BB_LOCK; - bb.ob = (part->bb_ob ? part->bb_ob : re->scene->camera); + bb.ob = (part->bb_ob ? part->bb_ob : RE_GetCamera(re)); bb.offset[0] = part->bb_offset[0]; bb.offset[1] = part->bb_offset[1]; bb.split_offset = part->bb_split_offset; @@ -4967,6 +4982,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l Scene *sce; float mat[4][4]; float amb[3]; + Object *camera= RE_GetCamera(re); re->main= bmain; re->scene= scene; @@ -4996,16 +5012,16 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l scene_update_for_newframe(re->main, re->scene, lay); /* if no camera, viewmat should have been set! */ - if(use_camera_view && re->scene->camera) { + if(use_camera_view && camera) { /* called before but need to call again incase of lens animation from the * above call to scene_update_for_newframe, fixes bug. [#22702]. * following calls dont depend on 'RE_SetCamera' */ - RE_SetCamera(re, scene->camera); + RE_SetCamera(re, camera); - normalize_m4(re->scene->camera->obmat); - invert_m4_m4(mat, re->scene->camera->obmat); + normalize_m4(camera->obmat); + invert_m4_m4(mat, camera->obmat); RE_SetView(re, mat); - re->scene->camera->recalc= OB_RECALC_OB; /* force correct matrix for scaled cameras */ + camera->recalc= OB_RECALC_OB; /* force correct matrix for scaled cameras */ } init_render_world(re); /* do first, because of ambient. also requires re->osa set correct */ @@ -5045,9 +5061,13 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l /* don't sort stars */ tothalo= re->tothalo; - if(!re->test_break(re->tbh)) - if(re->wrld.mode & WO_STARS) + if(!re->test_break(re->tbh)) { + if(re->wrld.mode & WO_STARS) { + re->i.infostr= "Creating Starfield"; + re->stats_draw(re->sdh, &re->i); RE_make_stars(re, NULL, NULL, NULL, NULL); + } + } sort_halos(re, tothalo); init_camera_inside_volumes(re); @@ -5126,6 +5146,7 @@ void RE_DataBase_GetView(Render *re, float mat[][4]) static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int lay, int timeoffset) { + Object *camera= RE_GetCamera(re); float mat[4][4]; re->scene= scene; @@ -5149,9 +5170,9 @@ static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int la scene_update_for_newframe(re->main, re->scene, lay); /* if no camera, viewmat should have been set! */ - if(re->scene->camera) { - normalize_m4(re->scene->camera->obmat); - invert_m4_m4(mat, re->scene->camera->obmat); + if(camera) { + normalize_m4(camera->obmat); + invert_m4_m4(mat, camera->obmat); RE_SetView(re, mat); } @@ -5638,6 +5659,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned */ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay, int type, Object *actob) { + Object *camera; float mat[4][4]; float amb[3]; int onlyselected, nolamps; @@ -5679,10 +5701,12 @@ void RE_Database_Baking(Render *re, Main *bmain, Scene *scene, unsigned int lay, if(re->lay & 0xFF000000) lay &= 0xFF000000; + camera= RE_GetCamera(re); + /* if no camera, set unit */ - if(re->scene->camera) { - normalize_m4(re->scene->camera->obmat); - invert_m4_m4(mat, re->scene->camera->obmat); + if(camera) { + normalize_m4(camera->obmat); + invert_m4_m4(mat, camera->obmat); RE_SetView(re, mat); } else { @@ -5746,13 +5770,17 @@ void RE_make_sticky(Scene *scene, View3D *v3d) Render *re; float ho[4], mat[4][4]; int a; - + Object *camera= NULL; + if(v3d==NULL) { printf("Need a 3d view to make sticky\n"); return; } - - if(scene->camera==NULL) { + + if(v3d) camera= V3D_CAMERA_LOCAL(v3d); + if(camera == NULL) camera= scene->camera; + + if(camera==NULL) { printf("Need camera to make sticky\n"); return; } @@ -5765,11 +5793,11 @@ void RE_make_sticky(Scene *scene, View3D *v3d) RE_InitState(re, NULL, &scene->r, NULL, scene->r.xsch, scene->r.ysch, NULL); /* use renderdata and camera to set viewplane */ - RE_SetCamera(re, scene->camera); + RE_SetCamera(re, camera); /* and set view matrix */ - normalize_m4(scene->camera->obmat); - invert_m4_m4(mat, scene->camera->obmat); + normalize_m4(camera->obmat); + invert_m4_m4(mat, camera->obmat); RE_SetView(re, mat); for(base= FIRSTBASE; base; base= base->next) { diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index f87cde27f02..2f09742f130 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -447,6 +447,11 @@ void make_sample_tables(Render *re) /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +struct Object *RE_GetCamera(Render *re) +{ + return re->camera_override ? re->camera_override : re->scene->camera; +} + /* call this after InitState() */ /* per render, there's one persistant viewplane. Parts will set their own viewplanes */ void RE_SetCamera(Render *re, Object *camera) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 468ce8846a8..2e869906d2c 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2002,6 +2002,7 @@ static void merge_renderresult_fields(RenderResult *rr, RenderResult *rr1, Rende /* interleaves 2 frames */ static void do_render_fields_3d(Render *re) { + Object *camera= RE_GetCamera(re); RenderResult *rr1, *rr2= NULL; /* no render result was created, we can safely halve render y */ @@ -2013,7 +2014,7 @@ static void do_render_fields_3d(Render *re) re->i.curfield= 1; /* stats */ /* first field, we have to call camera routine for correct aspect and subpixel offset */ - RE_SetCamera(re, re->scene->camera); + RE_SetCamera(re, camera); if(re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE)==0) do_render_blur_3d(re); else @@ -2033,7 +2034,7 @@ static void do_render_fields_3d(Render *re) if((re->r.mode & R_FIELDSTILL)==0) { re->field_offs = 0.5f; } - RE_SetCamera(re, re->scene->camera); + RE_SetCamera(re, camera); if(re->r.mode & R_MBLUR && (re->r.scemode & R_FULL_SAMPLE)==0) do_render_blur_3d(re); else @@ -2108,8 +2109,9 @@ static void load_backbuffer(Render *re) /* main render routine, no compositing */ static void do_render_fields_blur_3d(Render *re) { + Object *camera= RE_GetCamera(re); /* also check for camera here */ - if(re->scene->camera==NULL) { + if(camera == NULL) { printf("ERROR: Cannot render, no camera\n"); G.afbreek= 1; return; @@ -2120,7 +2122,7 @@ static void do_render_fields_blur_3d(Render *re) load_backbuffer(re); /* now use renderdata and camera to set viewplane */ - RE_SetCamera(re, re->scene->camera); + RE_SetCamera(re, camera); if(re->r.mode & R_FIELDS) do_render_fields_3d(re); @@ -2551,14 +2553,13 @@ static void do_render_composite_fields_blur_3d(Render *re) re->display_draw(re->ddh, re->result, NULL); } -static void renderresult_stampinfo(Scene *scene) +static void renderresult_stampinfo(Render *re) { RenderResult rres; - Render *re= RE_GetRender(scene->id.name); /* this is the basic trick to get the displayed float or char rect from render result */ RE_AcquireResultImage(re, &rres); - BKE_stamp_buf(scene, (unsigned char *)rres.rect32, rres.rectf, rres.rectx, rres.recty, 4); + BKE_stamp_buf(re->scene, RE_GetCamera(re), (unsigned char *)rres.rect32, rres.rectf, rres.rectx, rres.recty, 4); RE_ReleaseResultImage(re); } @@ -2717,16 +2718,16 @@ static void do_render_all_options(Render *re) /* stamp image info here */ if((re->r.stamp & R_STAMP_ALL) && (re->r.stamp & R_STAMP_DRAW)) { - renderresult_stampinfo(re->scene); + renderresult_stampinfo(re); re->display_draw(re->ddh, re->result, NULL); } } -static int check_valid_camera(Scene *scene) +static int check_valid_camera(Scene *scene, Object *camera_override) { int check_comp= 1; - if (scene->camera == NULL) + if (camera_override == NULL && scene->camera == NULL) scene->camera= scene_find_camera(scene); if(scene->r.scemode&R_DOSEQ) { @@ -2771,13 +2772,15 @@ static int check_valid_camera(Scene *scene) node= node->next; } - } else return scene->camera != NULL; + } else { + return (camera_override != NULL || scene->camera != NULL); + } } return 1; } -int RE_is_rendering_allowed(Scene *scene, void *erh, void (*error)(void *handle, const char *str)) +int RE_is_rendering_allowed(Scene *scene, Object *camera_override, void *erh, void (*error)(void *handle, const char *str)) { SceneRenderLayer *srl; @@ -2838,13 +2841,13 @@ int RE_is_rendering_allowed(Scene *scene, void *erh, void (*error)(void *handle, } /* check valid camera, without camera render is OK (compo, seq) */ - if(!check_valid_camera(scene)) { + if(!check_valid_camera(scene, camera_override)) { error(erh, "No camera"); return 0; } /* get panorama & ortho, only after camera is set */ - object_camera_mode(&scene->r, scene->camera); + object_camera_mode(&scene->r, camera_override ? camera_override : scene->camera); /* forbidden combinations */ if(scene->r.mode & R_PANORAMA) { @@ -2905,7 +2908,7 @@ static void update_physics_cache(Render *re, Scene *scene, int UNUSED(anim_init) BKE_ptcache_bake(&baker); } /* evaluating scene options for general Blender render */ -static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *srl, unsigned int lay, int anim, int anim_init) +static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *srl, Object *camera_override, unsigned int lay, int anim, int anim_init) { int winx, winy; rcti disprect; @@ -2933,6 +2936,7 @@ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, Sc re->main= bmain; re->scene= scene; + re->camera_override= camera_override; re->lay= lay; /* not too nice, but it survives anim-border render */ @@ -2973,14 +2977,14 @@ static int render_initialize_from_main(Render *re, Main *bmain, Scene *scene, Sc } /* general Blender frame render call */ -void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *srl, unsigned int lay, int frame, const short write_still) +void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *srl, Object *camera_override, unsigned int lay, int frame, const short write_still) { /* ugly global still... is to prevent preview events and signal subsurfs etc to make full resol */ G.rendering= 1; scene->r.cfra= frame; - if(render_initialize_from_main(re, bmain, scene, srl, lay, 0, 0)) { + if(render_initialize_from_main(re, bmain, scene, srl, camera_override, lay, 0, 0)) { MEM_reset_peak_memory(); do_render_all_options(re); @@ -3006,7 +3010,7 @@ void RE_BlenderFrame(Render *re, Main *bmain, Scene *scene, SceneRenderLayer *sr void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene) { re->result_ok= 0; - if(render_initialize_from_main(re, bmain, scene, NULL, scene->lay, 0, 0)) { + if(render_initialize_from_main(re, bmain, scene, NULL, NULL, scene->lay, 0, 0)) { do_render_fields_blur_3d(re); } re->result_ok= 1; @@ -3016,6 +3020,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R { char name[FILE_MAX]; RenderResult rres; + Object *camera= RE_GetCamera(re); int ok= 1; RE_AcquireResultImage(re, &rres); @@ -3070,7 +3075,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R } } - ok= BKE_write_ibuf(scene, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); + ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, scene->r.imtype, scene->r.subimtype, scene->r.quality); if(ok==0) { printf("Render error: cannot save %s\n", name); @@ -3083,7 +3088,7 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R name[strlen(name)-4]= 0; BKE_add_image_extension(name, R_JPEG90); ibuf->depth= 24; - BKE_write_ibuf(scene, ibuf, name, R_JPEG90, scene->r.subimtype, scene->r.quality); + BKE_write_ibuf_stamp(scene, camera, ibuf, name, R_JPEG90, scene->r.subimtype, scene->r.quality); printf("\nSaved: %s", name); } @@ -3102,14 +3107,14 @@ static int do_write_image_or_movie(Render *re, Scene *scene, bMovieHandle *mh, R } /* saves images to disk */ -void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, unsigned int lay, int sfra, int efra, int tfra, ReportList *reports) +void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_override, unsigned int lay, int sfra, int efra, int tfra, ReportList *reports) { bMovieHandle *mh= BKE_get_movie_handle(scene->r.imtype); int cfrao= scene->r.cfra; int nfra; /* do not fully call for each frame, it initializes & pops output window */ - if(!render_initialize_from_main(re, bmain, scene, NULL, lay, 0, 1)) + if(!render_initialize_from_main(re, bmain, scene, NULL, camera_override, lay, 0, 1)) return; /* ugly global still... is to prevent renderwin events and signal subsurfs etc to make full resol */ @@ -3142,7 +3147,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, unsigned int lay, int char name[FILE_MAX]; /* only border now, todo: camera lens. (ton) */ - render_initialize_from_main(re, bmain, scene, NULL, lay, 1, 0); + render_initialize_from_main(re, bmain, scene, NULL, camera_override, lay, 1, 0); if(nfra!=scene->r.cfra) { /* @@ -3215,6 +3220,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, unsigned int lay, int void RE_PreviewRender(Render *re, Main *bmain, Scene *sce) { + Object *camera; int winx, winy; winx= (sce->r.size*sce->r.xsch)/100; @@ -3226,7 +3232,8 @@ void RE_PreviewRender(Render *re, Main *bmain, Scene *sce) re->scene = sce; re->lay = sce->lay; - RE_SetCamera(re, sce->camera); + camera = RE_GetCamera(re); + RE_SetCamera(re, camera); do_render_3d(re); } diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 7ccf81b7755..d3d3e4d261c 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -47,6 +47,7 @@ #include "BKE_particle.h" #include "BKE_scene.h" #include "BKE_texture.h" +#include "BKE_colortools.h" #include "DNA_meshdata_types.h" #include "DNA_texture_types.h" @@ -69,9 +70,9 @@ static int point_data_used(PointDensity *pd) int pd_bitflag = 0; if (pd->source == TEX_PD_PSYS) { - if ((pd->noise_influence == TEX_PD_NOISE_VEL) || (pd->color_source == TEX_PD_COLOR_PARTVEL) || (pd->color_source == TEX_PD_COLOR_PARTSPEED)) + if ((pd->noise_influence == TEX_PD_NOISE_VEL) || (pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_VEL) || (pd->color_source == TEX_PD_COLOR_PARTVEL) || (pd->color_source == TEX_PD_COLOR_PARTSPEED)) pd_bitflag |= POINT_DATA_VEL; - if ((pd->noise_influence == TEX_PD_NOISE_AGE) || (pd->color_source == TEX_PD_COLOR_PARTAGE)) + if ((pd->noise_influence == TEX_PD_NOISE_AGE) || (pd->color_source == TEX_PD_COLOR_PARTAGE) || (pd->falloff_type == TEX_PD_FALLOFF_PARTICLE_AGE)) pd_bitflag |= POINT_DATA_LIFE; } @@ -180,6 +181,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa } pd->point_data[offset + i] = pa_time; + } } } @@ -331,6 +333,8 @@ typedef struct PointDensityRangeData float *age; int point_data_used; int offset; + struct CurveMapping *density_curve; + float velscale; } PointDensityRangeData; static void accum_density(void *userdata, int index, float squared_dist) @@ -339,6 +343,15 @@ static void accum_density(void *userdata, int index, float squared_dist) const float dist = (pdr->squared_radius - squared_dist) / pdr->squared_radius * 0.5f; float density = 0.0f; + if (pdr->point_data_used & POINT_DATA_VEL) { + pdr->vec[0] += pdr->point_data[index*3 + 0]; //* density; + pdr->vec[1] += pdr->point_data[index*3 + 1]; //* density; + pdr->vec[2] += pdr->point_data[index*3 + 2]; //* density; + } + if (pdr->point_data_used & POINT_DATA_LIFE) { + *pdr->age += pdr->point_data[pdr->offset + index]; // * density; + } + if (pdr->falloff_type == TEX_PD_FALLOFF_STD) density = dist; else if (pdr->falloff_type == TEX_PD_FALLOFF_SMOOTH) @@ -349,21 +362,21 @@ static void accum_density(void *userdata, int index, float squared_dist) density = pdr->squared_radius; else if (pdr->falloff_type == TEX_PD_FALLOFF_ROOT) density = sqrt(dist); + else if (pdr->falloff_type == TEX_PD_FALLOFF_PARTICLE_AGE) + density = dist*MIN2(pdr->point_data[pdr->offset + index], 1.0f); + else if (pdr->falloff_type == TEX_PD_FALLOFF_PARTICLE_VEL) + density = dist*len_v3(pdr->point_data + index*3)*pdr->velscale; - if (pdr->point_data_used & POINT_DATA_VEL) { - pdr->vec[0] += pdr->point_data[index*3 + 0]; //* density; - pdr->vec[1] += pdr->point_data[index*3 + 1]; //* density; - pdr->vec[2] += pdr->point_data[index*3 + 2]; //* density; - } - if (pdr->point_data_used & POINT_DATA_LIFE) { - *pdr->age += pdr->point_data[pdr->offset + index]; // * density; + if (pdr->density_curve && dist != 0.0f) { + density = curvemapping_evaluateF(pdr->density_curve, 0, density/dist)*dist; } *pdr->density += density; } -static void init_pointdensityrangedata(PointDensity *pd, PointDensityRangeData *pdr, float *density, float *vec, float *age) +static void init_pointdensityrangedata(PointDensity *pd, PointDensityRangeData *pdr, + float *density, float *vec, float *age, struct CurveMapping *density_curve, float velscale) { pdr->squared_radius = pd->radius*pd->radius; pdr->density = density; @@ -375,6 +388,8 @@ static void init_pointdensityrangedata(PointDensity *pd, PointDensityRangeData * pdr->noise_influence = pd->noise_influence; pdr->point_data_used = point_data_used(pd); pdr->offset = (pdr->point_data_used & POINT_DATA_VEL)?pd->totpoints*3:0; + pdr->density_curve = density_curve; + pdr->velscale = velscale; } @@ -394,7 +409,8 @@ int pointdensitytex(Tex *tex, float *texvec, TexResult *texres) if ((!pd) || (!pd->point_tree)) return 0; - init_pointdensityrangedata(pd, &pdr, &density, vec, &age); + init_pointdensityrangedata(pd, &pdr, &density, vec, &age, + (pd->flag&TEX_PD_FALLOFF_CURVE ? pd->falloff_curve : NULL), pd->falloff_speed_scale*0.001f); noise_fac = pd->noise_fac * 0.5f; /* better default */ VECCOPY(co, texvec); diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index c4634b261af..b0a7fdd1b36 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -726,7 +726,7 @@ static float Toon_Diff( float *n, float *l, float *v, float size, float smooth ) /* in latter case, only last multiplication uses 'nl' */ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough ) { - float i, nh, nv, vh, realnl, h[3]; + float i/*, nh*/, nv, vh, realnl, h[3]; float a, b, t, A, B; float Lit_A, View_A, Lit_B[3], View_B[3]; @@ -735,8 +735,8 @@ static float OrenNayar_Diff(float nl, float *n, float *l, float *v, float rough h[2]= v[2]+l[2]; normalize_v3(h); - nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; /* Dot product between surface normal and half-way vector */ - if(nh<0.0f) nh = 0.0f; + /* nh= n[0]*h[0]+n[1]*h[1]+n[2]*h[2]; */ /* Dot product between surface normal and half-way vector */ + /* if(nh<0.0f) nh = 0.0f; */ nv= n[0]*v[0]+n[1]*v[1]+n[2]*v[2]; /* Dot product between surface normal and view vector */ if(nv<=0.0f) nv= 0.0f; @@ -1523,19 +1523,19 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) if(lar->shb || (lar->mode & LA_SHAD_RAY)) { visifac= lamp_get_visibility(lar, shi->co, lv, &lampdist); + ir+= 1.0f; + if(visifac <= 0.0f) { - if (shi->mat->shadowonly_flag == MA_SO_OLD) { - ir+= 1.0f; + if (shi->mat->shadowonly_flag == MA_SO_OLD) accum+= 1.0f; - } + continue; } inpr= INPR(shi->vn, lv); if(inpr <= 0.0f) { - if (shi->mat->shadowonly_flag == MA_SO_OLD) { - ir+= 1.0f; + if (shi->mat->shadowonly_flag == MA_SO_OLD) accum+= 1.0f; - } + continue; } @@ -1543,11 +1543,9 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) if (shi->mat->shadowonly_flag == MA_SO_OLD) { /* Old "Shadows Only" */ - ir+= 1.0f; accum+= (1.0f-visifac) + (visifac)*rgb_to_grayscale(shadfac)*shadfac[3]; } else { - ir+= lar->energy; shaded += rgb_to_grayscale(shadfac)*shadfac[3] * visifac * lar->energy; if (shi->mat->shadowonly_flag == MA_SO_SHADOW) { @@ -1563,9 +1561,6 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) accum = 1.0f - accum/ir; } else { - shaded/= ir; - lightness/= ir; - if (shi->mat->shadowonly_flag == MA_SO_SHADOW) { if (lightness > 0.0f) { /* Get shadow value from between 0.0f and non-shadowed lightness */ @@ -1581,10 +1576,11 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) }} shr->alpha= (shi->alpha)*(accum); + if (shr->alpha<0.0f) shr->alpha=0.0f; } else { /* If "fully shaded", use full alpha even on areas that have no lights */ - if (shi->mat->shadowonly_flag == MA_SO_SHADED) shr->alpha=1.0f; + if (shi->mat->shadowonly_flag == MA_SO_SHADED) shr->alpha=shi->alpha; else shr->alpha= 0.f; } } diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index e75ee6ed469..fc3280db771 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -507,6 +507,9 @@ static void *vol_precache_part(void *data) for (x=pa->minx; x < pa->maxx; x++) { co[0] = pa->bbmin[0] + (pa->voxel[0] * (x + 0.5f)); + if (pa->re->test_break && pa->re->test_break(pa->re->tbh)) + break; + /* convert from world->camera space for shading */ mul_v3_m4v3(cco, pa->viewmat, co); @@ -604,6 +607,7 @@ static void precache_init_parts(Render *re, RayObject *tree, ShadeInput *shi, Ob pa->done = 0; pa->working = 0; + pa->re = re; pa->num = i; pa->tree = tree; pa->shi = shi; diff --git a/source/blender/windowmanager/CMakeLists.txt b/source/blender/windowmanager/CMakeLists.txt index db0815efa53..1a056b56eff 100644 --- a/source/blender/windowmanager/CMakeLists.txt +++ b/source/blender/windowmanager/CMakeLists.txt @@ -98,6 +98,10 @@ endif() if(WITH_PYTHON) list(APPEND INC ../python ${PYTHON_INCLUDE_DIRS}) add_definitions(-DWITH_PYTHON) + + if(WITH_PYTHON_SECURITY) + add_definitions(-DWITH_PYTHON_SECURITY) + endif() endif() if(WITH_GAMEENGINE) diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index f5fe98ae4d4..fec60ac3dc8 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -418,6 +418,12 @@ int WM_read_homefile(bContext *C, ReportList *reports, short from_memory) if(success==0) { success = BKE_read_file_from_memory(C, datatoc_startup_blend, datatoc_startup_blend_size, NULL); if (wmbase.first == NULL) wm_clear_default_size(C); + +#ifdef WITH_PYTHON_SECURITY /* not default */ + /* use alternative setting for security nuts + * otherwise we'd need to patch the binary blob - startup.blend.c */ + U.flag |= USER_SCRIPT_AUTOEXEC_DISABLE; +#endif } /* prevent buggy files that had G_FILE_RELATIVE_REMAP written out by mistake. Screws up autosaves otherwise @@ -596,7 +602,7 @@ static ImBuf *blend_file_thumb(Scene *scene, int **thumb_pt) return NULL; /* gets scaled to BLEN_THUMB_SIZE */ - ibuf= ED_view3d_draw_offscreen_imbuf_simple(scene, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, IB_rect, OB_SOLID, err_out); + ibuf= ED_view3d_draw_offscreen_imbuf_simple(scene, scene->camera, BLEN_THUMB_SIZE * 2, BLEN_THUMB_SIZE * 2, IB_rect, OB_SOLID, err_out); if(ibuf) { float aspect= (scene->r.xsch*scene->r.xasp) / (scene->r.ysch*scene->r.yasp); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 3f3a117f389..100dd914026 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1948,11 +1948,14 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "No filename given"); return OPERATOR_CANCELLED; } - + RNA_string_get(op->ptr, "filepath", filename); - collada_export(CTX_data_scene(C), filename); - - return OPERATOR_FINISHED; + if(collada_export(CTX_data_scene(C), filename)) { + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } } static void WM_OT_collada_export(wmOperatorType *ot) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 728557bc99b..60d6698de05 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -241,6 +241,7 @@ void ED_node_generic_update(struct Main *bmain, struct bNodeTree *ntree, struct void ED_view3d_scene_layers_update(struct Main *bmain, struct Scene *scene){} int ED_view3d_scene_layer_set(int lay, const int *values){return 0;} void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar){} +void view3d_apply_mat4(float mat[][4], float *ofs, float *quat, float *dist){} int text_file_modified(struct Text *text){return 0;} void ED_node_shader_default(struct Material *ma){} void ED_screen_animation_timer_update(struct bContext *C, int redraws){} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index 2a5e828fabc..3d18b6c4c08 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -76,6 +76,10 @@ endif() if(WITH_PYTHON) blender_include_dirs(../blender/python) add_definitions(-DWITH_PYTHON) + + if(WITH_PYTHON_SECURITY) + add_definitions(-DWITH_PYTHON_SECURITY) + endif() endif() if(WITH_GAMEENGINE) diff --git a/source/creator/creator.c b/source/creator/creator.c index 86574fb279c..4d27928e63e 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -783,7 +783,7 @@ static int render_frame(int argc, const char **argv, void *data) frame = MIN2(MAXFRAME, MAX2(MINAFRAME, frame)); - RE_BlenderAnim(re, bmain, scene, scene->lay, frame, frame, scene->r.frame_step, &reports); + RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, frame, frame, scene->r.frame_step, &reports); return 1; } else { printf("\nError: frame number must follow '-f / --render-frame'.\n"); @@ -804,7 +804,7 @@ static int render_animation(int UNUSED(argc), const char **UNUSED(argv), void *d Render *re= RE_NewRender(scene->id.name); ReportList reports; BKE_reports_init(&reports, RPT_PRINT); - RE_BlenderAnim(re, bmain, scene, scene->lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, &reports); + RE_BlenderAnim(re, bmain, scene, NULL, scene->lay, scene->r.sfra, scene->r.efra, scene->r.frame_step, &reports); } else { printf("\nError: no blend loaded. cannot use '-a'.\n"); } @@ -1076,10 +1076,22 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 1, "/?", NULL, "\n\tPrint this help text and exit (windows only)", print_help, ba); BLI_argsAdd(ba, 1, "-v", "--version", "\n\tPrint Blender version and exit", print_version, NULL); + + /* only to give help message */ +#ifndef WITH_PYTHON_SECURITY /* default */ +# define PY_ENABLE_AUTO ", (default)" +# define PY_DISABLE_AUTO "" +#else +# define PY_ENABLE_AUTO "" +# define PY_DISABLE_AUTO ", (compiled as non-standard default)" +#endif - BLI_argsAdd(ba, 1, "-y", "--enable-autoexec", "\n\tEnable automatic python script execution (default)", enable_python, NULL); - BLI_argsAdd(ba, 1, "-Y", "--disable-autoexec", "\n\tDisable automatic python script execution (pydrivers, pyconstraints, pynodes)", disable_python, NULL); + BLI_argsAdd(ba, 1, "-y", "--enable-autoexec", "\n\tEnable automatic python script execution" PY_ENABLE_AUTO, enable_python, NULL); + BLI_argsAdd(ba, 1, "-Y", "--disable-autoexec", "\n\tDisable automatic python script execution (pydrivers, pyconstraints, pynodes)" PY_DISABLE_AUTO, disable_python, NULL); +#undef PY_ENABLE_AUTO +#undef PY_DISABLE_AUTO + BLI_argsAdd(ba, 1, "-b", "--background", "\n\tLoad in background (often used for UI-less rendering)", background_mode, NULL); BLI_argsAdd(ba, 1, "-a", NULL, playback_doc, playback_mode, NULL); diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index 4a379f46440..080765c7846 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1514,7 +1514,7 @@ void KX_Scene::LogicUpdateFrame(double curtime, bool frame) void KX_Scene::LogicEndFrame() { m_logicmgr->EndFrame(); - int numobj = m_euthanasyobjects->GetCount(); + int numobj; KX_GameObject* obj;