diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-04-24 02:08:18 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2011-04-24 02:08:18 +0400 |
commit | bd860f89e75a10cae56be31f97fcd6aa9eb13b8e (patch) | |
tree | 4ad82db39475b754b9bb4c1c439033ce46e0c62e /source/blender | |
parent | 2497af95a11122e6c30d42dd7bff5d8f239269ac (diff) | |
parent | 040a049fb17af2e690219ec7f48f601a6d2189c4 (diff) |
Merged changes in the trunk up to revision 36301.
Diffstat (limited to 'source/blender')
270 files changed, 4401 insertions, 3216 deletions
diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c index ce414cd15fe..82bf3a3d21b 100644 --- a/source/blender/avi/intern/avi.c +++ b/source/blender/avi/intern/avi.c @@ -402,7 +402,7 @@ int AVI_is_avi (const char *name) { /* at least one video track is needed */ return (movie_tracks != 0); - + } AviError AVI_open_movie (const char *name, AviMovie *movie) { diff --git a/source/blender/avi/intern/codecs.c b/source/blender/avi/intern/codecs.c index 47a5fc192fd..9d3da333957 100644 --- a/source/blender/avi/intern/codecs.c +++ b/source/blender/avi/intern/codecs.c @@ -42,102 +42,102 @@ #include "rgb32.h" void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size) { - if (from == to) - return buffer; - - if (from != AVI_FORMAT_RGB24 && - to != AVI_FORMAT_RGB24) - return avi_format_convert(movie, stream, - avi_format_convert (movie, stream, buffer, from, AVI_FORMAT_RGB24, size), - AVI_FORMAT_RGB24, to, size); - - switch (to) { - case AVI_FORMAT_RGB24: - switch (from) { + if (from == to) + return buffer; + + if (from != AVI_FORMAT_RGB24 && + to != AVI_FORMAT_RGB24) + return avi_format_convert(movie, stream, + avi_format_convert (movie, stream, buffer, from, AVI_FORMAT_RGB24, size), + AVI_FORMAT_RGB24, to, size); + + switch (to) { + case AVI_FORMAT_RGB24: + switch (from) { + case AVI_FORMAT_AVI_RGB: + buffer = avi_converter_from_avi_rgb (movie, stream, buffer, size); + break; + case AVI_FORMAT_MJPEG: + buffer = avi_converter_from_mjpeg (movie, stream, buffer, size); + break; + case AVI_FORMAT_RGB32: + buffer = avi_converter_from_rgb32 (movie, stream, buffer, size); + break; + default: + break; + } + break; case AVI_FORMAT_AVI_RGB: - buffer = avi_converter_from_avi_rgb (movie, stream, buffer, size); - break; + buffer = avi_converter_to_avi_rgb (movie, stream, buffer, size); + break; case AVI_FORMAT_MJPEG: - buffer = avi_converter_from_mjpeg (movie, stream, buffer, size); - break; + buffer = avi_converter_to_mjpeg (movie, stream, buffer, size); + break; case AVI_FORMAT_RGB32: - buffer = avi_converter_from_rgb32 (movie, stream, buffer, size); - break; + buffer = avi_converter_to_rgb32 (movie, stream, buffer, size); + break; default: - break; + break; } - break; - case AVI_FORMAT_AVI_RGB: - buffer = avi_converter_to_avi_rgb (movie, stream, buffer, size); - break; - case AVI_FORMAT_MJPEG: - buffer = avi_converter_to_mjpeg (movie, stream, buffer, size); - break; - case AVI_FORMAT_RGB32: - buffer = avi_converter_to_rgb32 (movie, stream, buffer, size); - break; - default: - break; - } - return buffer; + return buffer; } int avi_get_data_id (AviFormat format, int stream) { - char fcc[5]; + char fcc[5]; - if (avi_get_format_type (format) == FCC("vids")) - sprintf (fcc,"%2.2ddc",stream); - else if (avi_get_format_type (format) == FCC("auds")) - sprintf (fcc,"%2.2ddc",stream); - else - return 0; + if (avi_get_format_type (format) == FCC("vids")) + sprintf (fcc,"%2.2ddc",stream); + else if (avi_get_format_type (format) == FCC("auds")) + sprintf (fcc,"%2.2ddc",stream); + else + return 0; - return FCC(fcc); + return FCC(fcc); } int avi_get_format_type (AviFormat format) { - switch (format) { - case AVI_FORMAT_RGB24: - case AVI_FORMAT_RGB32: - case AVI_FORMAT_AVI_RGB: - case AVI_FORMAT_MJPEG: - return FCC("vids"); - break; - default: - return 0; - break; - } + switch (format) { + case AVI_FORMAT_RGB24: + case AVI_FORMAT_RGB32: + case AVI_FORMAT_AVI_RGB: + case AVI_FORMAT_MJPEG: + return FCC("vids"); + break; + default: + return 0; + break; + } } int avi_get_format_fcc (AviFormat format) { - switch (format) { - case AVI_FORMAT_RGB24: - case AVI_FORMAT_RGB32: - case AVI_FORMAT_AVI_RGB: - return FCC("DIB "); - break; - case AVI_FORMAT_MJPEG: - return FCC("MJPG"); - break; - default: - return 0; - break; - } + switch (format) { + case AVI_FORMAT_RGB24: + case AVI_FORMAT_RGB32: + case AVI_FORMAT_AVI_RGB: + return FCC("DIB "); + break; + case AVI_FORMAT_MJPEG: + return FCC("MJPG"); + break; + default: + return 0; + break; + } } int avi_get_format_compression (AviFormat format) { - switch (format) { - case AVI_FORMAT_RGB24: - case AVI_FORMAT_RGB32: - case AVI_FORMAT_AVI_RGB: - return 0; - break; - case AVI_FORMAT_MJPEG: - return FCC("MJPG"); - break; - default: - return 0; - break; - } + switch (format) { + case AVI_FORMAT_RGB24: + case AVI_FORMAT_RGB32: + case AVI_FORMAT_AVI_RGB: + return 0; + break; + case AVI_FORMAT_MJPEG: + return FCC("MJPG"); + break; + default: + return 0; + break; + } } diff --git a/source/blender/avi/intern/options.c b/source/blender/avi/intern/options.c index 533bce2c8ea..edb708d8a69 100644 --- a/source/blender/avi/intern/options.c +++ b/source/blender/avi/intern/options.c @@ -53,77 +53,77 @@ AviError AVI_set_compress_option (AviMovie *movie, int option_type, int stream, switch (option_type) { case AVI_OPTION_TYPE_MAIN: switch (option) { - case AVI_OPTION_WIDTH: - movie->header->Width = *((int *) opt_data); - movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3; - - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - ((AviBitmapInfoHeader *) movie->streams[i].sf)->Width = *((int *) opt_data); - movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; - movie->streams[i].sh.right = *((int *) opt_data); - ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } + case AVI_OPTION_WIDTH: + movie->header->Width = *((int *) opt_data); + movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3; + + for (i=0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + ((AviBitmapInfoHeader *) movie->streams[i].sf)->Width = *((int *) opt_data); + movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; + movie->streams[i].sh.right = *((int *) opt_data); + ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; + fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); + awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); } + } + + break; - break; - - case AVI_OPTION_HEIGHT: - movie->header->Height = *((int *) opt_data); - movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3; - - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - ((AviBitmapInfoHeader *) movie->streams[i].sf)->Height = *((int *) opt_data); - movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; - movie->streams[i].sh.bottom = *((int *) opt_data); - ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } + case AVI_OPTION_HEIGHT: + movie->header->Height = *((int *) opt_data); + movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3; + + for (i=0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + ((AviBitmapInfoHeader *) movie->streams[i].sf)->Height = *((int *) opt_data); + movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; + movie->streams[i].sh.bottom = *((int *) opt_data); + ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; + fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); + awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); } + } + + break; - break; - - case AVI_OPTION_QUALITY: - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - movie->streams[i].sh.Quality = (*((int *) opt_data))*100; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } + case AVI_OPTION_QUALITY: + for (i=0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + movie->streams[i].sh.Quality = (*((int *) opt_data))*100; + fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); + awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); } - break; - - case AVI_OPTION_FRAMERATE: - if (1000000/(*((double *) opt_data))) - movie->header->MicroSecPerFrame = 1000000/(*((double *) opt_data)); - - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - movie->streams[i].sh.Scale = movie->header->MicroSecPerFrame; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } + } + break; + + case AVI_OPTION_FRAMERATE: + if (1000000/(*((double *) opt_data))) + movie->header->MicroSecPerFrame = 1000000/(*((double *) opt_data)); + + for (i=0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + movie->streams[i].sh.Scale = movie->header->MicroSecPerFrame; + fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); + awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); } - + } + } - fseek (movie->fp, movie->offset_table[0], SEEK_SET); - awrite (movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); + fseek (movie->fp, movie->offset_table[0], SEEK_SET); + awrite (movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); - break; - case AVI_OPTION_TYPE_STRH: - break; - case AVI_OPTION_TYPE_STRF: - break; - default: - return AVI_ERROR_OPTION; - break; - } + break; + case AVI_OPTION_TYPE_STRH: + break; + case AVI_OPTION_TYPE_STRF: + break; + default: + return AVI_ERROR_OPTION; + break; + } - return AVI_ERROR_NONE; + return AVI_ERROR_NONE; } diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 3365ebd6bfe..83d65f3b1f4 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -51,7 +51,7 @@ extern "C" { /* used by packaging tools */ /* can be left blank, otherwise a,b,c... etc with no quotes */ -#define BLENDER_VERSION_CHAR +#define BLENDER_VERSION_CHAR a /* alpha/beta/rc/release, docs use this */ #define BLENDER_VERSION_CYCLE release diff --git a/source/blender/blenkernel/BKE_sketch.h b/source/blender/blenkernel/BKE_sketch.h index f42d733d583..360a95bfb24 100644 --- a/source/blender/blenkernel/BKE_sketch.h +++ b/source/blender/blenkernel/BKE_sketch.h @@ -152,7 +152,7 @@ void sk_endContinuousStroke(SK_Stroke *stk); void sk_updateNextPoint(SK_Sketch *sketch, SK_Stroke *stk); -void sk_initDrawData(SK_DrawData *dd, short mval[2]); +void sk_initDrawData(SK_DrawData *dd, const short mval[2]); void sk_deleteSelectedStrokes(SK_Sketch *sketch); void sk_selectAllSketch(SK_Sketch *sketch, int mode); diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index a6b98b8ea88..136ce416037 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -89,6 +89,7 @@ void txt_split_curline (struct Text *text); void txt_backspace_char (struct Text *text); void txt_backspace_word (struct Text *text); int txt_add_char (struct Text *text, char add); +int txt_add_raw_char (struct Text *text, char add); int txt_replace_char (struct Text *text, char add); void txt_export_to_object (struct Text *text); void txt_export_to_objects(struct Text *text); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 46b9e1c48f5..9187d07a39f 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -24,6 +24,11 @@ # # ***** END GPL LICENSE BLOCK ***** +if(WITH_CODEC_FFMPEG) + # FFMPEG gives warnigns which are hard to avoid across multiple versions. + remove_strict_flags() +endif() + set(INC . ../avi diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 7bf893a3d60..3ff19b01b6c 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -1206,6 +1206,39 @@ static void animsys_evaluate_drivers (PointerRNA *ptr, AnimData *adt, float ctim /* ***************************************** */ /* Actions Evaluation */ +/* strictly not necessary for actual "evaluation", but it is a useful safety check + * to reduce the amount of times that users end up having to "revive" wrongly-assigned + * actions + */ +static void action_idcode_patch_check (ID *id, bAction *act) +{ + int idcode = 0; + + /* just in case */ + if (ELEM(NULL, id, act)) + return; + else + idcode = GS(id->name); + + /* the actual checks... hopefully not too much of a performance hit in the long run... */ + if (act->idroot == 0) { + /* use the current root if not set already (i.e. newly created actions and actions from 2.50-2.57 builds) + * - this has problems if there are 2 users, and the first one encountered is the invalid one + * in which case, the user will need to manually fix this (?) + */ + act->idroot = idcode; + } + else if (act->idroot != idcode) { + /* only report this error if debug mode is enabled (to save performance everywhere else) */ + if (G.f & G_DEBUG) { + printf("AnimSys Safety Check Failed: Action '%s' is not meant to be used from ID-Blocks of type %d such as '%s'\n", + act->id.name+2, idcode, id->name); + } + } +} + +/* ----------------------------------------- */ + /* Evaluate Action Group */ void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup *agrp, AnimMapper *remap, float ctime) { @@ -1215,6 +1248,8 @@ void animsys_evaluate_action_group (PointerRNA *ptr, bAction *act, bActionGroup if ELEM(NULL, act, agrp) return; if ((remap) && (remap->target != act)) remap= NULL; + action_idcode_patch_check(ptr->id.data, act); + /* if group is muted, don't evaluated any of the F-Curve */ if (agrp->flag & AGRP_MUTED) return; @@ -1238,6 +1273,8 @@ void animsys_evaluate_action (PointerRNA *ptr, bAction *act, AnimMapper *remap, if (act == NULL) return; if ((remap) && (remap->target != act)) remap= NULL; + action_idcode_patch_check(ptr->id.data, act); + /* calculate then execute each curve */ animsys_evaluate_fcurves(ptr, &act->curves, remap, ctime); } @@ -1637,6 +1674,17 @@ static void nlastrip_evaluate_actionclip (PointerRNA *ptr, ListBase *channels, L FCurve *fcu; float evaltime; + /* sanity checks for action */ + if (strip == NULL) + return; + + if (strip->act == NULL) { + printf("NLA-Strip Eval Error: Strip '%s' has no Action\n", strip->name); + return; + } + + action_idcode_patch_check(ptr->id.data, strip->act); + /* join this strip's modifiers to the parent's modifiers (own modifiers first) */ nlaeval_fmodifiers_join_stacks(&tmp_modifiers, &strip->modifiers, modifiers); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index ddfa738449d..a79637eea73 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -214,6 +214,11 @@ bArmature *copy_armature(bArmature *arm) }; newArm->act_bone= newActBone; + + newArm->edbo= NULL; + newArm->act_edbone= NULL; + newArm->sketch= NULL; + return newArm; } @@ -1226,10 +1231,10 @@ void pchan_apply_mat4(bPoseChannel *pchan, float mat[][4], short use_compat) */ void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]) { - float imat[4][4]; - - invert_m4_m4(imat, arm_mat); - mul_m4_m4m4(delta_mat, pose_mat, imat); + float imat[4][4]; + + invert_m4_m4(imat, arm_mat); + mul_m4_m4m4(delta_mat, pose_mat, imat); } /* **************** Rotation Mode Conversions ****************************** */ diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 96b6ec357f9..ac532cca7c6 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1119,12 +1119,12 @@ float brush_curve_strength_clamp(Brush *br, float p, const float len) * used for sculpt only */ float brush_curve_strength(Brush *br, float p, const float len) { - if(p >= len) - p= 1.0f; - else - p= p/len; + if(p >= len) + p= 1.0f; + else + p= p/len; - return curvemapping_evaluateF(br->curve, 0, p); + return curvemapping_evaluateF(br->curve, 0, p); } /* TODO: should probably be unified with BrushPainter stuff? */ diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index cbe7382c3a9..0b29b29e60f 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -197,8 +197,20 @@ static int can_pbvh_draw(Object *ob, DerivedMesh *dm) { CDDerivedMesh *cddm = (CDDerivedMesh*) dm; Mesh *me= ob->data; + int deformed= 0; - if(ob->sculpt->modifiers_active) return 0; + /* active modifiers means extra deformation, which can't be handled correct + on bith of PBVH and sculpt "layer" levels, so use PBVH only for internal brush + stuff and show final DerivedMesh so user would see actual object shape */ + deformed|= ob->sculpt->modifiers_active; + + /* as in case with modifiers, we can't synchronize deformation made against + PBVH and non-locked keyblock, so also use PBVH only for brushes and + final DM to give final result to user */ + deformed|= ob->sculpt->kb && (ob->shapeflag&OB_SHAPE_LOCK) == 0; + + if(deformed) + return 0; return (cddm->mvert == me->mvert) || ob->sculpt->kb; } diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 88b6ca296c7..ebdbbfcf7b4 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -856,10 +856,10 @@ static int cloth_collision_response_moving( ClothModifierData *clmd, CollisionMo #if 0 static float projectPointOntoLine(float *p, float *a, float *b) { - float ba[3], pa[3]; - VECSUB(ba, b, a); - VECSUB(pa, p, a); - return INPR(pa, ba) / INPR(ba, ba); + float ba[3], pa[3]; + VECSUB(ba, b, a); + VECSUB(pa, p, a); + return INPR(pa, ba) / INPR(ba, ba); } static void calculateEENormal(float *np1, float *np2, float *np3, float *np4,float *out_normal) diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 46f3e124bcc..1d7481b365a 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -793,7 +793,7 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float *vecout, const /* basic error handler, if we dont do this blender will exit */ static int ErrorReportingFunction(int ErrorCode, const char *ErrorText) { - fprintf(stderr, "%s:%d\n", ErrorText, ErrorCode); + fprintf(stderr, "%s:%d\n", ErrorText, ErrorCode); return 1; } #endif diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 7a5e0d5c33d..34e5fef8074 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -201,6 +201,7 @@ Curve *copy_curve(Curve *cu) cun->editnurb= NULL; cun->editfont= NULL; + cun->selboxes= NULL; #if 0 // XXX old animation system /* single user ipo too */ @@ -1025,19 +1026,19 @@ void forward_diff_bezier(float q0, float q1, float q2, float q3, float *p, int i rt2= 3.0f*(q0-2.0f*q1+q2)/f; f*= it; rt3= (q3-q0+3.0f*(q1-q2))/f; - - q0= rt0; + + q0= rt0; q1= rt1+rt2+rt3; q2= 2*rt2+6*rt3; q3= 6*rt3; - - for(a=0; a<=it; a++) { + + for(a=0; a<=it; a++) { *p= q0; p = (float *)(((char *)p)+stride); q0+= q1; - q1+= q2; - q2+= q3; - } + q1+= q2; + q2+= q3; + } } static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float *p3, float *p, int it, int stride) @@ -1047,7 +1048,7 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float * * This could also be optimized like forward_diff_bezier */ int a; - for(a=0; a<=it; a++) { + for(a=0; a<=it; a++) { float t = (float)a / (float)it; int i; @@ -1056,7 +1057,7 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float } normalize_v3(p); p = (float *)(((char *)p)+stride); - } + } } /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ @@ -1091,7 +1092,7 @@ float *make_orco_surf(Object *ob) sizev = nu->pntsv*resolv; if (nu->flagu & CU_NURB_CYCLIC) sizeu++; if (nu->flagv & CU_NURB_CYCLIC) sizev++; - if(nu->pntsv>1) tot+= sizeu * sizev; + if(nu->pntsv>1) tot+= sizeu * sizev; nu= nu->next; } diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index a81dcfb990f..0696653d2e4 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -254,7 +254,6 @@ int defgroup_find_index (Object *ob, bDeformGroup *dg) if (eg == NULL) return -1; return def_nr; - } /* note, must be freed */ @@ -361,7 +360,7 @@ void flip_side_name (char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP index= strrchr(name, '.'); // last occurrence if (index && isdigit(index[1]) ) { // doesnt handle case bone.1abc2 correct..., whatever! if(strip_number==0) - BLI_strncpy(number, index, sizeof(number)); + BLI_strncpy(number, index, sizeof(number)); *index= 0; len= BLI_strnlen(name, MAX_VGROUP_NAME); } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index ff49c64ebf4..94fbcd9ccb4 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -492,7 +492,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } } } - + /* softbody collision */ if ((ob->type==OB_MESH) || (ob->type==OB_CURVE) || (ob->type==OB_LATTICE)) { if(modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob) || ob->particlesystem.first) @@ -1092,10 +1092,10 @@ void graph_bfs(void) push_queue(nqueue,itA->node); } - else { + else { fprintf(stderr,"bfs not dag tree edge color :%i \n",itA->node->color); } - + itA = itA->next; } @@ -1225,7 +1225,7 @@ DagNodeQueue * graph_dfs(void) while(nqueue->count) { //graph_print_queue(nqueue); - skip = 0; + skip = 0; node = get_top_node_queue(nqueue); minheight = pos[node->DFS_dist]; @@ -1253,7 +1253,7 @@ DagNodeQueue * graph_dfs(void) */ /*if (node->DFS_dist >= itA->node->DFS_dist) itA->node->DFS_dist = node->DFS_dist + 1; - + fprintf(stderr,"dfs forward or cross edge :%15s %i-%i %15s %i-%i \n", ((ID *) node->ob)->name, node->DFS_dvtm, @@ -1287,17 +1287,17 @@ DagNodeQueue * graph_dfs(void) /* fprintf(stderr,"DFS node : %20s %i %i %i %i\n",((ID *) node->ob)->name,node->BFS_dist, node->DFS_dist, node->DFS_dvtm, node->DFS_fntm ); */ - push_stack(retqueue,node); + push_stack(retqueue,node); } } } node = node->next; } while (node); -// fprintf(stderr,"i size : %i \n", maxpos); - +// fprintf(stderr,"i size : %i \n", maxpos); + queue_delete(nqueue); - return(retqueue); + return(retqueue); } /* unused */ diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index c8e5998774d..b5194ca2f89 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1869,9 +1869,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba already applied, thats how it worked for years, so keep for compatibility (sergey) */ copy_displist(&cu->disp, dispbase); - if (!forRender) { - tex_space_curve(cu); - } + if (!forRender) { + tex_space_curve(cu); + } if(!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); diff --git a/source/blender/blenkernel/intern/exotic.c b/source/blender/blenkernel/intern/exotic.c index 7cb3adf96bf..ae773818438 100644 --- a/source/blender/blenkernel/intern/exotic.c +++ b/source/blender/blenkernel/intern/exotic.c @@ -138,22 +138,22 @@ static int is_stl(const char *str) return 1; } -#define READSTLVERT { \ - if (fread(mvert->co, sizeof(float), 3, fpSTL) != 3) { \ - char error_msg[255]; \ - MEM_freeN(vertdata); \ - MEM_freeN(facedata); \ - fclose(fpSTL); \ - sprintf(error_msg, "Problems reading face %d!", i); \ - return; \ - } \ - else { \ - if (ENDIAN_ORDER==B_ENDIAN) { \ - SWITCH_INT(mvert->co[0]); \ - SWITCH_INT(mvert->co[1]); \ - SWITCH_INT(mvert->co[2]); \ - } \ - } \ +#define READSTLVERT { \ + if (fread(mvert->co, sizeof(float), 3, fpSTL) != 3) { \ + char error_msg[255]; \ + MEM_freeN(vertdata); \ + MEM_freeN(facedata); \ + fclose(fpSTL); \ + sprintf(error_msg, "Problems reading face %d!", i); \ + return; \ + } \ + else { \ + if (ENDIAN_ORDER==B_ENDIAN) { \ + SWITCH_INT(mvert->co[0]); \ + SWITCH_INT(mvert->co[1]); \ + SWITCH_INT(mvert->co[2]); \ + } \ + } \ } static void simple_vertex_normal_blend(short *no, short *ble) @@ -889,7 +889,7 @@ void write_dxf(struct Scene *scene, char *str) write_group(0, "SECTION"); write_group(2, "BLOCKS"); - + /* only write meshes we're using in this scene */ flag_listbase_ids(&G.main->mesh, LIB_DOIT, 0); @@ -1608,7 +1608,7 @@ static void dxf_read_arc(Scene *scene, int noob) dia = (float) atof(val); } else if (id==62) { int colorid= atoi(val); - + CLAMP(colorid, 1, 255); dxf_col_to_rgb(colorid, &color[0], &color[1], &color[2]); } else if (id==67) { diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 67be3e71101..80962de9730 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -78,9 +78,12 @@ IDProperty *IDP_NewIDPArray(const char *name) IDProperty *IDP_CopyIDPArray(IDProperty *array) { - IDProperty *narray = MEM_dupallocN(array), *tmp; + /* dont use MEM_dupallocN because this may be part of an array */ + IDProperty *narray = MEM_mallocN(sizeof(IDProperty), "IDP_CopyIDPArray"), *tmp; int i; - + + *narray= *array; + narray->data.pointer = MEM_dupallocN(array->data.pointer); for (i=0; i<narray->len; i++) { /*ok, the copy functions always allocate a new structure, diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 8f6408f1939..5b237665290 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -80,10 +80,10 @@ void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int widt int checkerwidth= 32, dark= 1; int x, y; - + unsigned char *rect_orig= rect; float *rect_float_orig= rect_float; - + float h=0.0, hoffs=0.0, hue=0.0, s=0.9, v=0.9, r, g, b; @@ -191,7 +191,7 @@ static void checker_board_color_fill(unsigned char *rect, float *rect_float, int for(y= 0; y < height; y++) { - + val= 0.1 + (y * (0.4 / height)); /* use a number lower then 1.0 else its too bright */ for(x= 0; x < width; x++) { @@ -316,17 +316,17 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width BLF_size(mono, 54, 72); /* hard coded size! */ BLF_buffer(mono, rect_float, rect, width, height, 4); - + for(y= 0; y < height; y+=step) { text[1]= '1'; - + for(x= 0; x < width; x+=step) { /* hard coded offset */ pen_x = x + 33; pen_y = y + 44; - + /* terribly crappy outline font! */ BLF_buffer_col(mono, 1.0, 1.0, 1.0, 1.0); @@ -338,7 +338,7 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width BLF_draw_buffer(mono, text); BLF_position(mono, pen_x, pen_y+outline, 0.0); BLF_draw_buffer(mono, text); - + BLF_position(mono, pen_x-outline, pen_y-outline, 0.0); BLF_draw_buffer(mono, text); BLF_position(mono, pen_x+outline, pen_y+outline, 0.0); @@ -351,12 +351,12 @@ static void checker_board_text(unsigned char *rect, float *rect_float, int width BLF_buffer_col(mono, 0.0, 0.0, 0.0, 1.0); BLF_position(mono, pen_x, pen_y, 0.0); BLF_draw_buffer(mono, text); - + text[1]++; } text[0]++; } - + /* cleanup the buffer. */ BLF_buffer(mono, NULL, NULL, 0, 0, 0); } diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 08e0ad4f3ff..4f921f005f4 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1372,7 +1372,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * This does not assume that any ID or AnimData uses it, but does assume that * it is given two lists, which it will perform driver/animation-data separation. */ -static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], Sequence * seq, ListBase *animgroups, ListBase *anim, ListBase *drivers) +static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq, ListBase *animgroups, ListBase *anim, ListBase *drivers) { IpoCurve *icu; @@ -1416,8 +1416,7 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], /* if this IPO block doesn't have any users after this one, free... */ ipo->id.us--; - if ( (ipo->id.us == 0) || ((ipo->id.us == 1) && (ipo->id.flag & LIB_FAKEUSER)) ) - { + if (ID_REAL_USERS(ipo) <= 0) { IpoCurve *icn; for (icu= ipo->curve.first; icu; icu= icn) { @@ -1668,7 +1667,6 @@ void do_versions_ipos_to_animato(Main *main) { ListBase drivers = {NULL, NULL}; ID *id; - AnimData *adt; if (main == NULL) { printf("Argh! Main is NULL in do_versions_ipos_to_animato() \n"); @@ -1697,7 +1695,7 @@ void do_versions_ipos_to_animato(Main *main) /* check if object has any animation data */ if (ob->nlastrips.first) { /* Add AnimData block */ - adt= BKE_id_add_animdata(id); + BKE_id_add_animdata(id); /* IPO first to take into any non-NLA'd Object Animation */ if (ob->ipo) { @@ -1720,7 +1718,7 @@ void do_versions_ipos_to_animato(Main *main) } else if ((ob->ipo) || (ob->action)) { /* Add AnimData block */ - adt= BKE_id_add_animdata(id); + AnimData *adt= BKE_id_add_animdata(id); /* Action first - so that Action name get conserved */ if (ob->action) { @@ -1804,6 +1802,13 @@ void do_versions_ipos_to_animato(Main *main) BLI_freelinkN(&ob->constraintChannels, conchan); } } + + /* object's action will always be object-rooted */ + { + AnimData *adt= BKE_animdata_from_id(id); + if (adt && adt->action) + adt->action->idroot = ID_OB; + } } /* shapekeys */ @@ -1818,10 +1823,14 @@ void do_versions_ipos_to_animato(Main *main) */ if (key->ipo) { /* Add AnimData block */ - adt= BKE_id_add_animdata(id); + AnimData *adt= BKE_id_add_animdata(id); /* Convert Shapekey data... */ ipo_to_animdata(id, key->ipo, NULL, NULL, NULL); + + if (adt->action) + adt->action->idroot = key->ipo->blocktype; + key->ipo->id.us--; key->ipo= NULL; } @@ -1836,10 +1845,14 @@ void do_versions_ipos_to_animato(Main *main) /* we're only interested in the IPO */ if (ma->ipo) { /* Add AnimData block */ - adt= BKE_id_add_animdata(id); + AnimData *adt= BKE_id_add_animdata(id); /* Convert Material data... */ ipo_to_animdata(id, ma->ipo, NULL, NULL, NULL); + + if (adt->action) + adt->action->idroot = ma->ipo->blocktype; + ma->ipo->id.us--; ma->ipo= NULL; } @@ -1854,10 +1867,14 @@ void do_versions_ipos_to_animato(Main *main) /* we're only interested in the IPO */ if (wo->ipo) { /* Add AnimData block */ - adt= BKE_id_add_animdata(id); + AnimData *adt= BKE_id_add_animdata(id); /* Convert World data... */ ipo_to_animdata(id, wo->ipo, NULL, NULL, NULL); + + if (adt->action) + adt->action->idroot = wo->ipo->blocktype; + wo->ipo->id.us--; wo->ipo= NULL; } @@ -1870,7 +1887,7 @@ void do_versions_ipos_to_animato(Main *main) if (ed && ed->seqbasep) { Sequence * seq; - adt= BKE_id_add_animdata(id); + AnimData *adt= BKE_id_add_animdata(id); SEQ_BEGIN(ed, seq) { IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL; @@ -1904,6 +1921,10 @@ void do_versions_ipos_to_animato(Main *main) /* convert IPO */ ipo_to_animdata((ID *)scene, seq->ipo, NULL, NULL, seq); + + if (adt->action) + adt->action->idroot = ID_SCE; /* scene-rooted */ + seq->ipo->id.us--; seq->ipo = NULL; } @@ -1921,10 +1942,14 @@ void do_versions_ipos_to_animato(Main *main) /* we're only interested in the IPO */ if (te->ipo) { /* Add AnimData block */ - adt= BKE_id_add_animdata(id); + AnimData *adt= BKE_id_add_animdata(id); /* Convert Texture data... */ ipo_to_animdata(id, te->ipo, NULL, NULL, NULL); + + if (adt->action) + adt->action->idroot = te->ipo->blocktype; + te->ipo->id.us--; te->ipo= NULL; } @@ -1939,10 +1964,14 @@ void do_versions_ipos_to_animato(Main *main) /* we're only interested in the IPO */ if (ca->ipo) { /* Add AnimData block */ - adt= BKE_id_add_animdata(id); + AnimData *adt= BKE_id_add_animdata(id); /* Convert Camera data... */ ipo_to_animdata(id, ca->ipo, NULL, NULL, NULL); + + if (adt->action) + adt->action->idroot = ca->ipo->blocktype; + ca->ipo->id.us--; ca->ipo= NULL; } @@ -1957,10 +1986,14 @@ void do_versions_ipos_to_animato(Main *main) /* we're only interested in the IPO */ if (la->ipo) { /* Add AnimData block */ - adt= BKE_id_add_animdata(id); + AnimData *adt= BKE_id_add_animdata(id); /* Convert Lamp data... */ ipo_to_animdata(id, la->ipo, NULL, NULL, NULL); + + if (adt->action) + adt->action->idroot = la->ipo->blocktype; + la->ipo->id.us--; la->ipo= NULL; } @@ -1975,10 +2008,14 @@ void do_versions_ipos_to_animato(Main *main) /* we're only interested in the IPO */ if (cu->ipo) { /* Add AnimData block */ - adt= BKE_id_add_animdata(id); + AnimData *adt= BKE_id_add_animdata(id); /* Convert Curve data... */ ipo_to_animdata(id, cu->ipo, NULL, NULL, NULL); + + if (adt->action) + adt->action->idroot = cu->ipo->blocktype; + cu->ipo->id.us--; cu->ipo= NULL; } @@ -2001,6 +2038,10 @@ void do_versions_ipos_to_animato(Main *main) if (G.f & G_DEBUG) printf("\tconverting action %s \n", id->name+2); + /* if old action, it will be object-only... */ + if (act->chanbase.first) + act->idroot = ID_OB; + /* be careful! some of the actions we encounter will be converted ones... */ action_to_animato(NULL, act, &act->groups, &act->curves, &drivers); } @@ -2018,6 +2059,7 @@ void do_versions_ipos_to_animato(Main *main) /* add a new action for this, and convert all data into that action */ new_act= add_empty_action("ConvIPO_Action"); // XXX need a better name... ipo_to_animato(NULL, ipo, NULL, NULL, NULL, NULL, &new_act->curves, &drivers); + new_act->idroot = ipo->blocktype; } /* clear fake-users, and set user-count to zero to make sure it is cleared on file-save */ diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 9d93bb1c25d..d308ccbf876 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -219,7 +219,9 @@ Lattice *copy_lattice(Lattice *lt) ltn->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); copy_dverts(ltn->dvert, lt->dvert, tot); } - + + ltn->editlatt= NULL; + return ltn; } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 68123360a5f..a9bd72f43fa 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -1171,7 +1171,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) int new_id(ListBase *lb, ID *id, const char *tname) { int result; - char name[22]; + char name[MAX_ID_NAME-2]; /* if library, don't rename */ if(id->lib) return 0; diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index c6a3ddedb6a..000bdc138a4 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -1315,12 +1315,12 @@ void ramp_blend(int type, float *r, float *g, float *b, float fac, float *col) case MA_RAMP_SOFT: if (g){ float scr, scg, scb; - + /* first calculate non-fac based Screen mix */ scr = 1.0f - (1.0f - col[0]) * (1.0f - *r); scg = 1.0f - (1.0f - col[1]) * (1.0f - *g); scb = 1.0f - (1.0f - col[2]) * (1.0f - *b); - + *r = facm*(*r) + fac*(((1.0f - *r) * col[0] * (*r)) + (*r * scr)); *g = facm*(*g) + fac*(((1.0f - *g) * col[1] * (*g)) + (*g * scg)); *b = facm*(*b) + fac*(((1.0f - *b) * col[2] * (*b)) + (*b * scb)); diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index e6e32be9634..e19a508658e 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -132,6 +132,9 @@ MetaBall *copy_mball(MetaBall *mb) id_us_plus((ID *)mbn->mat[a]); } mbn->bb= MEM_dupallocN(mb->bb); + + mbn->editelems= NULL; + mbn->lastelem= NULL; return mbn; } @@ -187,7 +190,7 @@ void make_local_mball(MetaBall *mb) } /* most simple meta-element adding function - * dont do context menipulation here (rna uses) */ + * don't do context manipulation here (rna uses) */ MetaElem *add_metaball_element(MetaBall *mb, const int type) { MetaElem *ml= MEM_callocN(sizeof(MetaElem), "metaelem"); @@ -237,14 +240,14 @@ MetaElem *add_metaball_element(MetaBall *mb, const int type) /** Compute bounding box of all MetaElems/MetaBalls. * * Bounding box is computed from polygonized surface. Object *ob is - * basic MetaBall (usaualy with name Meta). All other MetaBalls (whith + * basic MetaBall (usually with name Meta). All other MetaBalls (with * names Meta.001, Meta.002, etc) are included in this Bounding Box. */ void tex_space_mball(Object *ob) { DispList *dl; BoundBox *bb; - float *data, min[3], max[3], loc[3], size[3]; + float *data, min[3], max[3] /*, loc[3], size[3] */; int tot, doit=0; if(ob->bb==NULL) ob->bb= MEM_callocN(sizeof(BoundBox), "mb boundbox"); @@ -272,7 +275,7 @@ void tex_space_mball(Object *ob) min[0] = min[1] = min[2] = -1.0f; max[0] = max[1] = max[2] = 1.0f; } - + /* loc[0]= (min[0]+max[0])/2.0f; loc[1]= (min[1]+max[1])/2.0f; loc[2]= (min[2]+max[2])/2.0f; @@ -280,7 +283,7 @@ void tex_space_mball(Object *ob) size[0]= (max[0]-min[0])/2.0f; size[1]= (max[1]-min[1])/2.0f; size[2]= (max[2]-min[2])/2.0f; - + */ boundbox_set_from_min_max(bb, min, max); } @@ -320,14 +323,14 @@ float *make_orco_mball(Object *ob, ListBase *dispbase) } /* Note on mball basis stuff 2.5x (this is a can of worms) - * This really needs a rewrite/refactorm its totally broken in anything other then basic cases + * This really needs a rewrite/refactor its totally broken in anything other then basic cases * Multiple Scenes + Set Scenes & mixing mball basis SHOULD work but fails to update the depsgraph on rename * and linking into scenes or removal of basis mball. so take care when changing this code. * * Main idiot thing here is that the system returns find_basis_mball() objects which fail a is_basis_mball() test. * - * Not only that but the depsgraph and ther areas depend on this behavior!, so making small fixes here isnt worth it. - * - campbell + * Not only that but the depsgraph and their areas depend on this behavior!, so making small fixes here isn't worth it. + * - Campbell */ @@ -725,7 +728,7 @@ void accum_mballfaces(int i1, int i2, int i3, int i4) cur= indices+4*curindex; - /* diplists now support array drawing, we treat trias as fake quad */ + /* displists now support array drawing, we treat tri's as fake quad */ cur[0]= i1; cur[1]= i2; @@ -1315,7 +1318,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, dy = pos.y - neg.y; dz = pos.z - neg.z; -/* Aproximation by linear interpolation is faster then binary subdivision, +/* Approximation by linear interpolation is faster then binary subdivision, * but it results sometimes (mb->thresh < 0.2) into the strange results */ if((mb->thresh > 0.2f) && (f==1)){ if((dy == 0.0f) && (dz == 0.0f)){ @@ -1373,7 +1376,7 @@ void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, p->x = 0.5f*(pos.x + neg.x); p->y = 0.5f*(pos.y + neg.y); p->z = 0.5f*(pos.z + neg.z); - + if (i++ == RES) return; if ((function(p->x, p->y, p->z)) > 0.0f){ @@ -1625,7 +1628,7 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ } } - /* when metaball object hase zero scale, then MetaElem ot this MetaBall + /* when metaball object has zero scale, then MetaElem to this MetaBall * will not be put to mainb array */ if(bob->size[0]==0.0f || bob->size[1]==0.0f || bob->size[2]==0.0f) { zero_size= 1; @@ -1688,11 +1691,11 @@ float init_meta(Scene *scene, Object *ob) /* return totsize */ mul_m4_m4m4(temp2, bob->obmat, obinv); /* MetaBall transformation */ mul_m4_m4m4(mat, temp1, temp2); - + invert_m4_m4(imat,mat); - + mainb[a]->rad2= ml->rad*ml->rad; - + mainb[a]->mat= (float*) mat; mainb[a]->imat= (float*) imat; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 29ddd3a55e5..532e96f3031 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -236,6 +236,8 @@ Mesh *copy_mesh(Mesh *me) } men->mselect= NULL; + men->edit_mesh= NULL; + men->pv= NULL; /* looks like this is no-longer supported but NULL just incase */ men->bb= MEM_dupallocN(men->bb); @@ -1463,7 +1465,7 @@ void create_vert_edge_map(ListBase **map, IndexNode **mem, const MEdge *medge, c (*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert edge map"); (*mem) = MEM_callocN(sizeof(IndexNode) * totedge * 2, "vert edge map mem"); node = *mem; - + /* Find the users */ for(i = 0; i < totedge; ++i){ for(j = 0; j < 2; ++j, ++node) { diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index dc1f80ce1d4..b8b57b6bac0 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -56,7 +56,6 @@ #include "BKE_fcurve.h" #include "BKE_node.h" #include "BKE_utildefines.h" -#include "BKE_node.h" #include "PIL_time.h" @@ -968,6 +967,11 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup, ID *id) } else ntype= node_get_type(ntree, type, id); + if(ntype == NULL) { + printf("nodeAddNodeType() error: '%d' type invalid\n", type); + return NULL; + } + node= MEM_callocN(sizeof(bNode), "new node"); BLI_addtail(&ntree->nodes, node); node->typeinfo= ntype; @@ -1998,11 +2002,23 @@ static void node_group_execute(bNodeStack *stack, void *data, bNode *gnode, bNod if (ntree->type==NTREE_COMPOSIT) { bNodeSocket *sock; bNodeStack *ns; + + /* clear hasoutput on all local stack data, + * only the group output will be used from now on + */ + for (node=ntree->nodes.first; node; node=node->next) { + for (sock=node->outputs.first; sock; sock=sock->next) { + if (sock->stack_type==SOCK_STACK_LOCAL) { + ns= get_socket_stack(stack, sock, in); + ns->hasoutput = 0; + } + } + } + /* use the hasoutput flag to tag external sockets */ for (sock=ntree->outputs.first; sock; sock=sock->next) { - /* use the hasoutput flag to tag external sockets */ if (sock->stack_type==SOCK_STACK_LOCAL) { ns= get_socket_stack(stack, sock, in); - ns->hasoutput = 0; + ns->hasoutput = 1; } } /* now free all stacks that are not used from outside */ @@ -2010,11 +2026,9 @@ static void node_group_execute(bNodeStack *stack, void *data, bNode *gnode, bNod for (sock=node->outputs.first; sock; sock=sock->next) { if (sock->stack_type==SOCK_STACK_LOCAL ) { ns= get_socket_stack(stack, sock, in); - if (ns->hasoutput!=0 && ns->data) { + if (ns->hasoutput==0 && ns->data) { free_compbuf(ns->data); ns->data = NULL; - /* reset the flag */ - ns->hasoutput = 1; } } } @@ -2236,6 +2250,10 @@ static void group_tag_used_outputs(bNode *gnode, bNodeStack *stack, bNodeStack * if (ns) ns->sockettype = sock->type; } + + /* non-composite trees do all nodes by default */ + if (ntree->type!=NTREE_COMPOSIT) + node->need_exec = 1; } } @@ -2321,7 +2339,7 @@ void ntreeBeginExecTree(bNodeTree *ntree) for(node= ntree->nodes.first; node; node= node->next) { bNodeSocket *sock; - /* composite has own need_exec tag handling */ + /* non-composite trees do all nodes by default */ if(ntree->type!=NTREE_COMPOSIT) node->need_exec= 1; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ccd78d639f6..00ebf9ff5a8 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -210,8 +210,8 @@ void object_link_modifiers(struct Object *ob, struct Object *from) BLI_addtail(&ob->modifiers, nmd); } - copy_object_particlesystems(from, ob); - copy_object_softbody(from, ob); + copy_object_particlesystems(ob, from); + copy_object_softbody(ob, from); // TODO: smoke?, cloth? } @@ -2281,7 +2281,7 @@ void what_does_parent(Scene *scene, Object *ob, Object *workob) workob->constraints.first = ob->constraints.first; workob->constraints.last = ob->constraints.last; - strcpy(workob->parsubstr, ob->parsubstr); + BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr)); where_is_object(scene, workob); } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 662929f95fc..e80289c75ae 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -264,17 +264,10 @@ static void psys_create_frand(ParticleSystem *psys) int psys_check_enabled(Object *ob, ParticleSystem *psys) { ParticleSystemModifierData *psmd; - Mesh *me; if(psys->flag & PSYS_DISABLED || psys->flag & PSYS_DELETE || !psys->part) return 0; - if(ob->type == OB_MESH) { - me= (Mesh*)ob->data; - if(me->mr && me->mr->current != 1) - return 0; - } - psmd= psys_get_modifier(ob, psys); if(psys->renderdata || G.rendering) { if(!(psmd->modifier.mode & eModifierMode_Render)) @@ -4371,7 +4364,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa float loc[3], nor[3], vec[3], side[3], len, obrotmat[4][4], qmat[4][4]; float xvec[3] = {-1.0, 0.0, 0.0}, q[4], nmat[3][3]; - sub_v3_v3v3(vec, (cache+cache->steps-1)->co, cache->co); + sub_v3_v3v3(vec, (cache+cache->steps)->co, cache->co); len= normalize_v3(vec); if(psys->part->rotmode) { @@ -4431,22 +4424,22 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] xvec[0] = 1.0f; xvec[1] = 0.0f; xvec[2] = 0.0f; yvec[0] = 0.0f; yvec[1] = 1.0f; yvec[2] = 0.0f; - /* can happen with bad pointcache or physics calculation - * since this becomes geometry, nan's and inf's crash raytrace code. - * better not allow this. */ - if( !finite(bb->vec[0]) || !finite(bb->vec[1]) || !finite(bb->vec[2]) || - !finite(bb->vel[0]) || !finite(bb->vel[1]) || !finite(bb->vel[2]) ) - { - zero_v3(bb->vec); - zero_v3(bb->vel); - - zero_v3(xvec); - zero_v3(yvec); - zero_v3(zvec); - zero_v3(center); - - return; - } + /* can happen with bad pointcache or physics calculation + * since this becomes geometry, nan's and inf's crash raytrace code. + * better not allow this. */ + if( !finite(bb->vec[0]) || !finite(bb->vec[1]) || !finite(bb->vec[2]) || + !finite(bb->vel[0]) || !finite(bb->vel[1]) || !finite(bb->vel[2]) ) + { + zero_v3(bb->vec); + zero_v3(bb->vel); + + zero_v3(xvec); + zero_v3(yvec); + zero_v3(zvec); + zero_v3(center); + + return; + } if(bb->align < PART_BB_VIEW) onevec[bb->align]=1.0f; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 1c05b854ef7..666ba31faed 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -644,7 +644,7 @@ static void hammersley_create(float *out, int n, int seed, float amount) for (p = 0.5, kk = k; kk; p *= 0.5, kk >>= 1) if (kk & 1) /* kk mod 2 = 1 */ t += p; - + out[2*k + 0]= fmod((double)k/(double)n + offs[0], 1.0); out[2*k + 1]= fmod(t + offs[1], 1.0); } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index a8447e2a12a..179aab064b4 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1003,15 +1003,15 @@ static PTCacheFile *ptcache_file_open(PTCacheID *pid, int mode, int cfra) fp = fopen(filename, "rb+"); } - if (!fp) - return NULL; - + if (!fp) + return NULL; + pf= MEM_mallocN(sizeof(PTCacheFile), "PTCacheFile"); pf->fp= fp; pf->old_format = 0; pf->frame = cfra; - - return pf; + + return pf; } static void ptcache_file_close(PTCacheFile *pf) { @@ -1308,8 +1308,8 @@ static void ptcache_data_copy(void *from[], void *to[]) { int i; for(i=0; i<BPHYS_TOT_DATA; i++) { - /* note, durian file 03.4b_comp crashes if to[i] is not tested - * its NULL, not sure if this should be fixed elsewhere but for now its needed */ + /* note, durian file 03.4b_comp crashes if to[i] is not tested + * its NULL, not sure if this should be fixed elsewhere but for now its needed */ if(from[i] && to[i]) memcpy(to[i], from[i], ptcache_data_size[i]); } @@ -1373,11 +1373,13 @@ static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int * while(pm->next && pm->next->frame < frame) pm= pm->next; - if(pm2 && pm2->frame < frame) + if(pm2->frame < frame) { pm2 = NULL; + } else { - while(pm2->prev && pm2->prev->frame > frame) + while(pm2->prev && pm2->prev->frame > frame) { pm2= pm2->prev; + } } if(pm && !pm2) { diff --git a/source/blender/blenkernel/intern/report.c b/source/blender/blenkernel/intern/report.c index ed3739e897d..f84d98a31b4 100644 --- a/source/blender/blenkernel/intern/report.c +++ b/source/blender/blenkernel/intern/report.c @@ -101,7 +101,7 @@ void BKE_report(ReportList *reports, ReportType type, const char *message) Report *report; int len; - /* in background mode always print otherwise there are cases the errors wont be displayed, + /* in background mode always print otherwise there are cases the errors wont be displayed, * but still add to the report list since this is used for python exception handling */ if(G.background || !reports || ((reports->flag & RPT_PRINT) && (type >= reports->printlevel))) { printf("%s: %s\n", report_type_str(type), message); diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 38dc7fd5106..16cef67ea6d 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -333,12 +333,12 @@ void free_actuator(bActuator *act) if(act->data) { switch (act->type) { - case ACT_SOUND: - sa = (bSoundActuator *) act->data; - if(sa->sound) - id_us_min((ID *) sa->sound); - break; - } + case ACT_SOUND: + sa = (bSoundActuator *) act->data; + if(sa->sound) + id_us_min((ID *) sa->sound); + break; + } MEM_freeN(act->data); } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 09a4481164c..29ab052a099 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -1088,23 +1088,23 @@ float get_render_aosss_error(RenderData *r, float error) /* helper function for the SETLOOPER macro */ Base *_setlooper_base_step(Scene **sce_iter, Base *base) { - if(base && base->next) { - /* common case, step to the next */ - return base->next; - } + if(base && base->next) { + /* common case, step to the next */ + return base->next; + } else if(base==NULL && (*sce_iter)->base.first) { - /* first time looping, return the scenes first base */ + /* first time looping, return the scenes first base */ return (Base *)(*sce_iter)->base.first; - } - else { - /* reached the end, get the next base in the set */ + } + else { + /* reached the end, get the next base in the set */ while((*sce_iter= (*sce_iter)->set)) { base= (Base *)(*sce_iter)->base.first; - if(base) { - return base; - } - } - } + if(base) { + return base; + } + } + } - return NULL; + return NULL; } diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 3dfef2e9d78..aa91cff03b9 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -1675,15 +1675,15 @@ float hyp3,hyp4,b4,b5 output = in_band(wipezone,width,hyp,facf0,1,1); else output = in_band(wipezone,width,hyp,facf0,0,1); - } + } else { if(b1 < b2) output = in_band(wipezone,width,hyp,facf0,0,1); else output = in_band(wipezone,width,hyp,facf0,1,1); - } + } break; - + case DO_DOUBLE_WIPE: if(!wipe->forward) facf0 = 1.0f-facf0; // Go the other direction @@ -1726,45 +1726,45 @@ float hyp3,hyp4,b4,b5 output = in_band(wipezone,hwidth,hyp2,facf0,1,1) * in_band(wipezone,hwidth,hyp,facf0,1,1); } if(!wipe->forward)output = 1-output; - break; - case DO_CLOCK_WIPE: + break; + case DO_CLOCK_WIPE: /* temp1: angle of effect center in rads temp2: angle of line through (halfx,halfy) and (x,y) in rads temp3: angle of low side of blur temp4: angle of high side of blur */ - output = 1.0f - facf0; - widthf = wipe->edgeWidth*2.0f*(float)M_PI; - temp1 = 2.0f * (float)M_PI * facf0; - - if(wipe->forward){ - temp1 = 2.0f*(float)M_PI - temp1; - } - - x = x - halfx; - y = y - halfy; - - temp2 = asin(abs(y)/sqrt(x*x + y*y)); - if(x <= 0 && y >= 0) temp2 = (float)M_PI - temp2; - else if(x<=0 && y <= 0) temp2 += (float)M_PI; - else if(x >= 0 && y <= 0) temp2 = 2.0f*(float)M_PI - temp2; - - if(wipe->forward){ - temp3 = temp1-(widthf*0.5f)*facf0; - temp4 = temp1+(widthf*0.5f)*(1-facf0); - } else{ - temp3 = temp1-(widthf*0.5f)*(1-facf0); - temp4 = temp1+(widthf*0.5f)*facf0; + output = 1.0f - facf0; + widthf = wipe->edgeWidth*2.0f*(float)M_PI; + temp1 = 2.0f * (float)M_PI * facf0; + + if(wipe->forward){ + temp1 = 2.0f*(float)M_PI - temp1; + } + + x = x - halfx; + y = y - halfy; + + temp2 = asin(abs(y)/sqrt(x*x + y*y)); + if(x <= 0 && y >= 0) temp2 = (float)M_PI - temp2; + else if(x<=0 && y <= 0) temp2 += (float)M_PI; + else if(x >= 0 && y <= 0) temp2 = 2.0f*(float)M_PI - temp2; + + if(wipe->forward){ + temp3 = temp1-(widthf*0.5f)*facf0; + temp4 = temp1+(widthf*0.5f)*(1-facf0); + } else{ + temp3 = temp1-(widthf*0.5f)*(1-facf0); + temp4 = temp1+(widthf*0.5f)*facf0; } - if (temp3 < 0) temp3 = 0; - if (temp4 > 2.0f*(float)M_PI) temp4 = 2.0f*(float)M_PI; - - - if(temp2 < temp3) output = 0; - else if (temp2 > temp4) output = 1; - else output = (temp2-temp3)/(temp4-temp3); - if(x == 0 && y == 0) output = 1; + if (temp3 < 0) temp3 = 0; + if (temp4 > 2.0f*(float)M_PI) temp4 = 2.0f*(float)M_PI; + + + if(temp2 < temp3) output = 0; + else if (temp2 > temp4) output = 1; + else output = (temp2-temp3)/(temp4-temp3); + if(x == 0 && y == 0) output = 1; if(output != output) output = 1; if(wipe->forward) output = 1 - output; break; @@ -1840,12 +1840,12 @@ float hyp3,hyp4,b4,b5 hwidth = width*0.5f; temp1 = (halfx-(halfx)*facf0); - pointdist = sqrt(temp1*temp1 + temp1*temp1); - - temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y)); - if(temp2 > pointdist) output = in_band(wipezone,hwidth,fabs(temp2-pointdist),facf0,0,1); - else output = in_band(wipezone,hwidth,fabs(temp2-pointdist),facf0,1,1); - + pointdist = sqrt(temp1*temp1 + temp1*temp1); + + temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y)); + if(temp2 > pointdist) output = in_band(wipezone,hwidth,fabs(temp2-pointdist),facf0,0,1); + else output = in_band(wipezone,hwidth,fabs(temp2-pointdist),facf0,1,1); + if(!wipe->forward) output = 1-output; break; diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index a765c9ee8f0..b2e6f5290c3 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -845,7 +845,7 @@ typedef struct SeqUniqueInfo { /* static void seqbase_unique_name(ListBase *seqbasep, Sequence *seq) { - BLI_uniquename(seqbasep, seq, "Sequence", '.', offsetof(Sequence, name), SEQ_NAME_MAXSTR); + BLI_uniquename(seqbasep, seq, "Sequence", '.', offsetof(Sequence, name), SEQ_NAME_MAXSTR); }*/ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui) diff --git a/source/blender/blenkernel/intern/sketch.c b/source/blender/blenkernel/intern/sketch.c index 6e234a9d115..ec0f5d1316b 100644 --- a/source/blender/blenkernel/intern/sketch.c +++ b/source/blender/blenkernel/intern/sketch.c @@ -543,7 +543,7 @@ int sk_stroke_filtermval(SK_DrawData *dd) return retval; } -void sk_initDrawData(SK_DrawData *dd, short mval[2]) +void sk_initDrawData(SK_DrawData *dd, const short mval[2]) { dd->mval[0] = mval[0]; dd->mval[1] = mval[1]; diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index 90581870070..4405bce3d51 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -1470,20 +1470,20 @@ static float calc_voxel_transp(float *result, float *input, int res[3], int *pix long long smoke_get_mem_req(int xres, int yres, int zres, int amplify) { - int totalCells = xres * yres * zres; - int amplifiedCells = totalCells * amplify * amplify * amplify; + int totalCells = xres * yres * zres; + int amplifiedCells = totalCells * amplify * amplify * amplify; - // print out memory requirements - long long int coarseSize = sizeof(float) * totalCells * 22 + - sizeof(unsigned char) * totalCells; + // print out memory requirements + long long int coarseSize = sizeof(float) * totalCells * 22 + + sizeof(unsigned char) * totalCells; - long long int fineSize = sizeof(float) * amplifiedCells * 7 + // big grids - sizeof(float) * totalCells * 8 + // small grids - sizeof(float) * 128 * 128 * 128; // noise tile + long long int fineSize = sizeof(float) * amplifiedCells * 7 + // big grids + sizeof(float) * totalCells * 8 + // small grids + sizeof(float) * 128 * 128 * 128; // noise tile - long long int totalMB = (coarseSize + fineSize) / (1024 * 1024); + long long int totalMB = (coarseSize + fineSize) / (1024 * 1024); - return totalMB; + return totalMB; } static void bresenham_linie_3D(int x1, int y1, int z1, int x2, int y2, int z2, float *tRay, bresenham_callback cb, float *result, float *input, int res[3], float correct) diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 0578b155272..30d2816769c 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1648,12 +1648,12 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, static void scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow) { - SoftBody *sb = ob->soft; - ListBase *do_effector = NULL; + SoftBody *sb = ob->soft; + ListBase *do_effector = NULL; - do_effector = pdInitEffectors(scene, ob, NULL, sb->effector_weights); - _scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector); - pdEndEffectors(&do_effector); + do_effector = pdInitEffectors(scene, ob, NULL, sb->effector_weights); + _scan_for_ext_spring_forces(scene, ob, timenow, 0, sb->totspring, do_effector); + pdEndEffectors(&do_effector); } static void *exec_scan_for_ext_spring_forces(void *data) @@ -2216,50 +2216,50 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo /* naive ball self collision */ /* needs to be done if goal snaps or not */ if(do_selfcollision){ - int attached; - BodyPoint *obp; - BodySpring *bs; - int c,b; - float velcenter[3],dvel[3],def[3]; - float distance; - float compare; - float bstune = sb->ballstiff; - - for(c=sb->totpoint, obp= sb->bpoint; c>=ifirst+bb; c--, obp++) { - compare = (obp->colball + bp->colball); - sub_v3_v3v3(def, bp->pos, obp->pos); - /* rather check the AABBoxes before ever calulating the real distance */ - /* mathematically it is completly nuts, but performace is pretty much (3) times faster */ - if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue; - distance = normalize_v3(def); - if (distance < compare ){ - /* exclude body points attached with a spring */ - attached = 0; - for(b=obp->nofsprings;b>0;b--){ - bs = sb->bspring + obp->springs[b-1]; - if (( ilast-bb == bs->v2) || ( ilast-bb == bs->v1)){ - attached=1; - continue;} - } - if (!attached){ - float f = bstune/(distance) + bstune/(compare*compare)*distance - 2.0f*bstune/compare ; + int attached; + BodyPoint *obp; + BodySpring *bs; + int c,b; + float velcenter[3],dvel[3],def[3]; + float distance; + float compare; + float bstune = sb->ballstiff; + + for(c=sb->totpoint, obp= sb->bpoint; c>=ifirst+bb; c--, obp++) { + compare = (obp->colball + bp->colball); + sub_v3_v3v3(def, bp->pos, obp->pos); + /* rather check the AABBoxes before ever calulating the real distance */ + /* mathematically it is completly nuts, but performace is pretty much (3) times faster */ + if ((ABS(def[0]) > compare) || (ABS(def[1]) > compare) || (ABS(def[2]) > compare)) continue; + distance = normalize_v3(def); + if (distance < compare ){ + /* exclude body points attached with a spring */ + attached = 0; + for(b=obp->nofsprings;b>0;b--){ + bs = sb->bspring + obp->springs[b-1]; + if (( ilast-bb == bs->v2) || ( ilast-bb == bs->v1)){ + attached=1; + continue;} + } + if (!attached){ + float f = bstune/(distance) + bstune/(compare*compare)*distance - 2.0f*bstune/compare ; - mid_v3_v3v3(velcenter, bp->vec, obp->vec); - sub_v3_v3v3(dvel,velcenter,bp->vec); - mul_v3_fl(dvel,_final_mass(ob,bp)); + mid_v3_v3v3(velcenter, bp->vec, obp->vec); + sub_v3_v3v3(dvel,velcenter,bp->vec); + mul_v3_fl(dvel,_final_mass(ob,bp)); - Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def); - Vec3PlusStVec(bp->force,sb->balldamp,dvel); + Vec3PlusStVec(bp->force,f*(1.0f-sb->balldamp),def); + Vec3PlusStVec(bp->force,sb->balldamp,dvel); - /* exploit force(a,b) == -force(b,a) part2/2 */ - sub_v3_v3v3(dvel,velcenter,obp->vec); - mul_v3_fl(dvel,_final_mass(ob,bp)); + /* exploit force(a,b) == -force(b,a) part2/2 */ + sub_v3_v3v3(dvel,velcenter,obp->vec); + mul_v3_fl(dvel,_final_mass(ob,bp)); - Vec3PlusStVec(obp->force,sb->balldamp,dvel); - Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def); - } + Vec3PlusStVec(obp->force,sb->balldamp,dvel); + Vec3PlusStVec(obp->force,-f*(1.0f-sb->balldamp),def); } } + } } /* naive ball self collision done */ @@ -2930,7 +2930,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* now we have individual masses */ /* claim a minimum mass for vertex */ if (_final_mass(ob,bp) > 0.009999f) timeovermass = forcetime/_final_mass(ob,bp); - else timeovermass = forcetime/0.009999f; + else timeovermass = forcetime/0.009999f; if(_final_goal(ob,bp) < SOFTGOALSNAP){ diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 3041a4c59e6..b9bf10bdf39 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -2696,7 +2696,7 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) int numFaces = ccgSubSurf_getVertNumFaces(v); float *co; int i; - + edge_sum[0]= edge_sum[1]= edge_sum[2]= 0.0; face_sum[0]= face_sum[1]= face_sum[2]= 0.0; diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index e7b85ec9b17..db07fae9245 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -1348,9 +1348,19 @@ char *txt_sel_to_buf (Text *text) return buf; } +static void txt_shift_markers(Text *text, int lineno, int count) +{ + TextMarker *marker; + + for (marker=text->markers.first; marker; marker= marker->next) + if (marker->lineno>=lineno) { + marker->lineno+= count; + } +} + void txt_insert_buf(Text *text, const char *in_buffer) { - int i=0, l=0, j, u, len; + int i=0, l=0, j, u, len, lineno= -1, count= 0; TextLine *add; if (!text) return; @@ -1365,7 +1375,7 @@ void txt_insert_buf(Text *text, const char *in_buffer) /* Read the first line (or as close as possible */ while (in_buffer[i] && in_buffer[i]!='\n') { - txt_add_char(text, in_buffer[i]); + txt_add_raw_char(text, in_buffer[i]); i++; } @@ -1375,6 +1385,7 @@ void txt_insert_buf(Text *text, const char *in_buffer) /* Read as many full lines as we can */ len= strlen(in_buffer); + lineno= txt_get_span(text->lines.first, text->curl); while (i<len) { l=0; @@ -1387,14 +1398,25 @@ void txt_insert_buf(Text *text, const char *in_buffer) add= txt_new_linen(in_buffer +(i-l), l); BLI_insertlinkbefore(&text->lines, text->curl, add); i++; + count++; } else { + if(count) { + txt_shift_markers(text, lineno, count); + count= 0; + } + for (j= i-l; j<i && j<(int)strlen(in_buffer); j++) { - txt_add_char(text, in_buffer[j]); + txt_add_raw_char(text, in_buffer[j]); } break; } } - + + if(count) { + txt_shift_markers(text, lineno, count); + count= 0; + } + undoing= u; } @@ -2375,7 +2397,7 @@ static void txt_convert_tab_to_spaces (Text *text) txt_insert_buf(text, sb); } -int txt_add_char (Text *text, char add) +static int txt_add_char_intern (Text *text, char add, int replace_tabs) { int len, lineno; char *tmp; @@ -2390,7 +2412,7 @@ int txt_add_char (Text *text, char add) } /* insert spaces rather then tabs */ - if (add == '\t' && text->flags & TXT_TABSTOSPACES) { + if (add == '\t' && replace_tabs) { txt_convert_tab_to_spaces(text); return 1; } @@ -2428,6 +2450,16 @@ int txt_add_char (Text *text, char add) return 1; } +int txt_add_char (Text *text, char add) +{ + return txt_add_char_intern(text, add, text->flags & TXT_TABSTOSPACES); +} + +int txt_add_raw_char (Text *text, char add) +{ + return txt_add_char_intern(text, add, 0); +} + void txt_delete_selected(Text *text) { txt_delete_sel(text); @@ -2595,7 +2627,7 @@ void comment(Text *text) if (!text) return; if (!text->curl) return; - if (!text->sell) return;// Need to change this need to check if only one line is selected ot more then one + if (!text->sell) return;// Need to change this need to check if only one line is selected to more then one num = 0; while (TRUE) diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 37e604fa0cb..b89e576a562 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -95,7 +95,7 @@ typedef struct bUnitDef { /* define a single unit */ typedef struct bUnitCollection { struct bUnitDef *units; - int base_unit; /* basic unit index (when user desn't specify unit explicitly) */ + int base_unit; /* basic unit index (when user doesn't specify unit explicitly) */ int flag; /* options for this system */ int length; /* to quickly find the last item */ } bUnitCollection; diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 73e23bd2a05..ba7f9bdd415 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -158,7 +158,7 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL avi = MEM_mallocN (sizeof(AviMovie), "avimovie"); /* RPW 11-21-2002 - if (rd->imtype != AVI_FORMAT_MJPEG) format = AVI_FORMAT_AVI_RGB; + if (rd->imtype != AVI_FORMAT_MJPEG) format = AVI_FORMAT_AVI_RGB; */ if (rd->imtype != R_AVIJPEG ) format = AVI_FORMAT_AVI_RGB; else format = AVI_FORMAT_MJPEG; diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 3174c65beac..8937612b41b 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -44,8 +44,8 @@ extern "C" { /********************************** Polygons *********************************/ -void cent_tri_v3(float r[3], float a[3], float b[3], float c[3]); -void cent_quad_v3(float r[3], float a[3], float b[3], float c[3], float d[3]); +void cent_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]); +void cent_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]); float normal_tri_v3(float r[3], const float a[3], const float b[3], const float c[3]); float normal_quad_v3(float r[3], const float a[3], const float b[3], const float c[3], const float d[3]); @@ -54,17 +54,17 @@ float area_tri_v2(const float a[2], const float b[2], const float c[2]); float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2]); float area_tri_v3(const float a[3], const float b[3], const float c[3]); float area_quad_v3(const float a[3], const float b[3], const float c[3], const float d[3]); -float area_poly_v3(int nr, float verts[][3], float normal[3]); +float area_poly_v3(int nr, float verts[][3], const float normal[3]); /********************************* Distance **********************************/ -float dist_to_line_v2(float p[2], float l1[2], float l2[2]); -float dist_to_line_segment_v2(float p[2], float l1[2], float l2[2]); +float dist_to_line_v2(const float p[2], const float l1[2], const float l2[2]); +float dist_to_line_segment_v2(const float p[2], const float l1[2], const float l2[2]); -float dist_to_line_segment_v3(float p[3], float l1[3], float l2[3]); +float dist_to_line_segment_v3(const float p[3], const float l1[3], const float l2[3]); float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]); float closest_to_line_v2(float r[2], const float p[2], const float l1[2], const float l2[2]); -void closest_to_line_segment_v3(float r[3], float p[3], float l1[3], float l2[3]); +void closest_to_line_segment_v3(float r[3], const float p[3], const float l1[3], const float l2[3]); /******************************* Intersection ********************************/ @@ -78,7 +78,7 @@ void closest_to_line_segment_v3(float r[3], float p[3], float l1[3], float l2[3] int isect_line_line_v2(const float a1[2], const float a2[2], const float b1[2], const float b2[2]); int isect_line_line_v2_short(const short a1[2], const short a2[2], const short b1[2], const short b2[2]); -int isect_seg_seg_v2_point(const float *v1, const float *v2, const float *v3, const float *v4, float vi[2]); +int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[2], const float v4[2], float vi[2]); /* Returns the number of point of interests * 0 - lines are colinear @@ -86,57 +86,57 @@ int isect_seg_seg_v2_point(const float *v1, const float *v2, const float *v3, co * 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) respectively * */ -int isect_line_line_v3(float v1[3], float v2[3], - float v3[3], float v4[3], float i1[3], float i2[3]); -int isect_line_line_strict_v3(float v1[3], float v2[3], - float v3[3], float v4[3], float vi[3], float *lambda); +int isect_line_line_v3(const float v1[3], const float v2[3], + const float v3[3], const float v4[3], float i1[3], float i2[3]); +int isect_line_line_strict_v3(const float v1[3], const float v2[3], + const float v3[3], const float v4[3], float vi[3], float *lambda); /* line/ray triangle */ -int isect_line_tri_v3(float p1[3], float p2[3], - float v0[3], float v1[3], float v2[3], float *lambda, float *uv); -int isect_ray_tri_v3(float p1[3], float d[3], - float v0[3], float v1[3], float v2[3], float *lambda, float *uv); -int isect_ray_tri_threshold_v3(float p1[3], float d[3], - float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float threshold); -int isect_ray_tri_epsilon_v3(float p1[3], float d[3], - float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float epsilon); +int isect_line_tri_v3(const float p1[3], const float p2[3], + const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2]); +int isect_ray_tri_v3(const float p1[3], const float d[3], + const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2]); +int isect_ray_tri_threshold_v3(const float p1[3], const float d[3], + const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2], const float threshold); +int isect_ray_tri_epsilon_v3(const float p1[3], const float d[3], + const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2], const float epsilon); /* point in polygon */ -int isect_point_quad_v2(float p[2], float a[2], float b[2], float c[2], float d[2]); +int isect_point_quad_v2(const float p[2], const float a[2], const float b[2], const float c[2], const float d[2]); -int isect_point_tri_v2(float v1[2], float v2[2], float v3[2], float pt[2]); -int isect_point_tri_v2_int(int x1, int y1, int x2, int y2, int a, int b); -int isect_point_tri_prism_v3(float p[3], float v1[3], float v2[3], float v3[3]); +int isect_point_tri_v2(const float v1[2], const float v2[2], const float v3[2], const float pt[2]); +int isect_point_tri_v2_int(const int x1, const int y1, const int x2, const int y2, const int a, const int b); +int isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3]); -void isect_point_quad_uv_v2(float v0[2], float v1[2], float v2[2], float v3[2], - float pt[2], float *uv); -void isect_point_face_uv_v2(int isquad, float v0[2], float v1[2], float v2[2], - float v3[2], float pt[2], float *uv); +void isect_point_quad_uv_v2(const float v0[2], const float v1[2], const float v2[2], const float v3[2], + const float pt[2], float *uv); +void isect_point_face_uv_v2(const int isquad, const float v0[2], const float v1[2], const float v2[2], + const float v3[2], const float pt[2], float *uv); /* other */ -int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, - float v0[3], float v1[3], float v2[3], float *lambda, float *ipoint); +int isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const float radius, + const float v0[3], const float v1[3], const float v2[3], float *lambda, float ipoint[3]); -int isect_axial_line_tri_v3(int axis, float co1[3], float co2[3], - float v0[3], float v1[3], float v2[3], float *lambda); +int isect_axial_line_tri_v3(const int axis, const float co1[3], const float co2[3], + const float v0[3], const float v1[3], const float v2[3], float *lambda); -int isect_aabb_aabb_v3(float min1[3], float max1[3], float min2[3], float max2[3]); +int isect_aabb_aabb_v3(const float min1[3], const float max1[3], const float min2[3], const float max2[3]); -int clip_line_plane(float clipco[3], float plane[4], float co[3]); +int clip_line_plane(float p1[3], float p2[3], const float plane[4]); -void plot_line_v2v2i(int p1[2], int p2[2], int (*callback)(int, int, void *), void *userData); +void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, void *), void *userData); /****************************** Interpolation ********************************/ /* tri or quad, d can be NULL */ void interp_weights_face_v3(float w[4], - float a[3], float b[3], float c[3], float d[3], float p[3]); -void interp_weights_poly_v3(float w[], float v[][3], int n, float p[3]); + const float a[3], const float b[3], const float c[3], const float d[3], const float p[3]); +void interp_weights_poly_v3(float w[], float v[][3], const int n, const float p[3]); void interp_cubic_v3(float x[3], float v[3], - float x1[3], float v1[3], float x2[3], float v2[3], float t); + const float x1[3], const float v1[3], const float x2[3], const float v2[3], const float t); -int interp_sparse_array(float *array, int list_size, float invalid); +int interp_sparse_array(float *array, const int list_size, const float invalid); void barycentric_transform(float pt_tar[3], float const pt_src[3], const float tri_tar_p1[3], const float tri_tar_p2[3], const float tri_tar_p3[3], @@ -152,22 +152,22 @@ void lookat_m4(float mat[4][4], float vx, float vy, void polarview_m4(float mat[4][4], float dist, float azimuth, float incidence, float twist); -void perspective_m4(float mat[4][4], float left, float right, - float bottom, float top, float nearClip, float farClip); -void orthographic_m4(float mat[4][4], float left, float right, - float bottom, float top, float nearClip, float farClip); +void perspective_m4(float mat[4][4], const float left, const float right, + const float bottom, const float top, const float nearClip, const float farClip); +void orthographic_m4(float mat[4][4], const float left, const float right, + const float bottom, const float top, const float nearClip, const float farClip); void window_translate_m4(float winmat[][4], float perspmat[][4], - float x, float y); + const float x, const float y); int box_clip_bounds_m4(float boundbox[2][3], - float bounds[4], float winmat[4][4]); + const float bounds[4], float winmat[4][4]); void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], float mat[4][4]); /********************************** Mapping **********************************/ -void map_to_tube(float *u, float *v, float x, float y, float z); -void map_to_sphere(float *u, float *v, float x, float y, float z); +void map_to_tube(float *u, float *v, const float x, const float y, const float z); +void map_to_sphere(float *u, float *v, const float x, const float y, const float z); /********************************** Normals **********************************/ @@ -182,11 +182,11 @@ typedef struct VertexTangent { float tang[3], uv[2]; } VertexTangent; -float *find_vertex_tangent(VertexTangent *vtang, float *uv); +float *find_vertex_tangent(VertexTangent *vtang, const float uv[2]); void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, - float *tang, float *uv); -void tangent_from_uv(float *uv1, float *uv2, float *uv3, - float *co1, float *co2, float *co3, float *n, float *tang); + const float tang[3], const float uv[2]); +void tangent_from_uv(float uv1[2], float uv2[2], float uv3[2], + float co1[3], float co2[3], float co3[3], float n[3], float tang[3]); /******************************** Vector Clouds ******************************/ @@ -202,14 +202,14 @@ void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight, 4 = (2,-2), 5 = (2,-1), 6 = (2,0), 7 = (2,1), 8 = (2,2) */ MINLINE void zero_sh(float r[9]); -MINLINE void copy_sh_sh(float r[9], float a[9]); -MINLINE void mul_sh_fl(float r[9], float f); -MINLINE void add_sh_shsh(float r[9], float a[9], float b[9]); - -MINLINE float eval_shv3(float r[9], float v[3]); -MINLINE float diffuse_shv3(float r[9], float v[3]); -MINLINE void vec_fac_to_sh(float r[9], float v[3], float f); -MINLINE void madd_sh_shfl(float r[9], float sh[3], float f); +MINLINE void copy_sh_sh(float r[9], const float a[9]); +MINLINE void mul_sh_fl(float r[9], const float f); +MINLINE void add_sh_shsh(float r[9], const float a[9], const float b[9]); + +MINLINE float eval_shv3(float r[9], const float v[3]); +MINLINE float diffuse_shv3(float r[9], const float v[3]); +MINLINE void vec_fac_to_sh(float r[9], const float v[3], const float f); +MINLINE void madd_sh_shfl(float r[9], const float sh[3], const float f); /********************************* Form Factor *******************************/ diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 0144dea3960..ff08ef4dba9 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -175,7 +175,7 @@ unsigned int BLI_ghashutil_inthash(const void *ptr) { key += ~(key << 9); key ^= (key >> 17); - return (unsigned int)(key & 0xffffffff); + return (unsigned int)(key & 0xffffffff); } int BLI_ghashutil_intcmp(const void *a, const void *b) { diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index 4c16363f6d3..8c7e097d239 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -174,7 +174,7 @@ void boxPack2D(boxPack *boxarray, const int len, float *tot_width, float *tot_he vertex_pack_indices = MEM_mallocN( len*3*sizeof(int), "boxPack Indices"); for (box=boxarray, box_index=0, i=0; box_index < len; box_index++, box++) { - + vert->blb = vert->brb = vert->tlb =\ vert->isect_cache[0] = vert->isect_cache[1] =\ vert->isect_cache[2] = vert->isect_cache[3] = NULL; @@ -260,17 +260,17 @@ void boxPack2D(boxPack *boxarray, const int len, float *tot_width, float *tot_he if (vert->free & quad_flags[j]) { switch (j) { case BL: - SET_BOXRIGHT(box, vert->x); - SET_BOXTOP(box, vert->y); - break; + SET_BOXRIGHT(box, vert->x); + SET_BOXTOP(box, vert->y); + break; case TR: - SET_BOXLEFT(box, vert->x); - SET_BOXBOTTOM(box, vert->y); - break; + SET_BOXLEFT(box, vert->x); + SET_BOXBOTTOM(box, vert->y); + break; case TL: - SET_BOXRIGHT(box, vert->x); - SET_BOXBOTTOM(box, vert->y); - break; + SET_BOXRIGHT(box, vert->x); + SET_BOXBOTTOM(box, vert->y); + break; case BR: SET_BOXLEFT(box, vert->x); SET_BOXTOP(box, vert->y); diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 2407078fc76..2e0f4b483b1 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -133,13 +133,13 @@ int BLI_is_writable(const char *filename) int BLI_touch(const char *file) { - FILE *f = fopen(file,"r+b"); - if (f != NULL) { + FILE *f = fopen(file,"r+b"); + if (f != NULL) { char c = getc(f); rewind(f); putc(c,f); } else { - f = fopen(file,"wb"); + f = fopen(file,"wb"); } if (f) { fclose(f); diff --git a/source/blender/blenlib/intern/math_color.c b/source/blender/blenlib/intern/math_color.c index 85636d23f6f..512086f0e17 100644 --- a/source/blender/blenlib/intern/math_color.c +++ b/source/blender/blenlib/intern/math_color.c @@ -463,14 +463,14 @@ int constrain_rgb(float *r, float *g, float *b) float w; /* Amount of white needed is w = - min(0, *r, *g, *b) */ - + w = (0 < *r) ? 0 : *r; w = (w < *g) ? w : *g; w = (w < *b) ? w : *b; w = -w; /* Add just enough white to make r, g, b all positive. */ - + if (w > 0) { *r += w; *g += w; *b += w; return 1; /* Color modified to fit RGB gamut */ diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 9fa5775c6a1..4af56c66dde 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -41,14 +41,14 @@ /********************************** Polygons *********************************/ -void cent_tri_v3(float *cent, float *v1, float *v2, float *v3) +void cent_tri_v3(float cent[3], const float v1[3], const float v2[3], const float v3[3]) { cent[0]= 0.33333f*(v1[0]+v2[0]+v3[0]); cent[1]= 0.33333f*(v1[1]+v2[1]+v3[1]); cent[2]= 0.33333f*(v1[2]+v2[2]+v3[2]); } -void cent_quad_v3(float *cent, float *v1, float *v2, float *v3, float *v4) +void cent_quad_v3(float cent[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3]) { cent[0]= 0.25f*(v1[0]+v2[0]+v3[0]+v4[0]); cent[1]= 0.25f*(v1[1]+v2[1]+v3[1]+v4[1]); @@ -99,7 +99,7 @@ float area_tri_v2(const float v1[2], const float v2[2], const float v3[2]) float area_tri_signed_v2(const float v1[2], const float v2[2], const float v3[2]) { - return 0.5f * ((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0])); + return 0.5f * ((v1[0]-v2[0])*(v2[1]-v3[1]) + (v1[1]-v2[1])*(v3[0]-v2[0])); } float area_quad_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3]) /* only convex Quadrilaterals */ @@ -131,7 +131,7 @@ float area_tri_v3(const float v1[3], const float v2[3], const float v3[3]) /* T return (len/2.0f); } -float area_poly_v3(int nr, float verts[][3], float *normal) +float area_poly_v3(int nr, float verts[][3], const float normal[3]) { float x, y, z, area, max; float *cur, *prev; @@ -165,7 +165,7 @@ float area_poly_v3(int nr, float verts[][3], float *normal) /* distance v1 to line v2-v3 */ /* using Hesse formula, NO LINE PIECE! */ -float dist_to_line_v2(float *v1, float *v2, float *v3) +float dist_to_line_v2(const float v1[2], const float v2[2], const float v3[2]) { float a[2],deler; @@ -179,7 +179,7 @@ float dist_to_line_v2(float *v1, float *v2, float *v3) } /* distance v1 to line-piece v2-v3 */ -float dist_to_line_segment_v2(float *v1, float *v2, float *v3) +float dist_to_line_segment_v2(const float v1[2], const float v2[2], const float v3[2]) { float labda, rc[2], pt[2], len; @@ -208,11 +208,11 @@ float dist_to_line_segment_v2(float *v1, float *v2, float *v3) rc[0]= pt[0]-v1[0]; rc[1]= pt[1]-v1[1]; - return (float)sqrt(rc[0]*rc[0]+ rc[1]*rc[1]); + return sqrtf(rc[0]*rc[0]+ rc[1]*rc[1]); } /* point closest to v1 on line v2-v3 in 3D */ -void closest_to_line_segment_v3(float *closest, float v1[3], float v2[3], float v3[3]) +void closest_to_line_segment_v3(float closest[3], const float v1[3], const float v2[3], const float v3[3]) { float lambda, cp[3]; @@ -227,7 +227,7 @@ void closest_to_line_segment_v3(float *closest, float v1[3], float v2[3], float } /* distance v1 to line-piece v2-v3 in 3D */ -float dist_to_line_segment_v3(float *v1, float *v2, float *v3) +float dist_to_line_segment_v3(const float v1[3], const float v2[3], const float v3[3]) { float closest[3]; @@ -239,7 +239,7 @@ float dist_to_line_segment_v3(float *v1, float *v2, float *v3) /******************************* Intersection ********************************/ /* intersect Line-Line, shorts */ -int isect_line_line_v2_short(const short *v1, const short *v2, const short *v3, const short *v4) +int isect_line_line_v2_short(const short v1[2], const short v2[2], const short v3[2], const short v4[2]) { float div, labda, mu; @@ -258,7 +258,7 @@ int isect_line_line_v2_short(const short *v1, const short *v2, const short *v3, } /* intersect Line-Line, floats */ -int isect_line_line_v2(const float *v1, const float *v2, const float *v3, const float *v4) +int isect_line_line_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]) { float div, labda, mu; @@ -279,7 +279,7 @@ int isect_line_line_v2(const float *v1, const float *v2, const float *v3, const /* get intersection point of two 2D segments and return intersection type: -1: colliniar 1: intersection */ -int isect_seg_seg_v2_point(const float *v1, const float *v2, const float *v3, const float *v4, float vi[2]) +int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[2], const float v4[2], float vi[2]) { float a1, a2, b1, b2, c1, c2, d; float u, v; @@ -354,8 +354,8 @@ int isect_seg_seg_v2_point(const float *v1, const float *v2, const float *v3, co 1: intersection */ -static short IsectLLPt2Df(float x0,float y0,float x1,float y1, - float x2,float y2,float x3,float y3, float *xi,float *yi) +static short IsectLLPt2Df(const float x0, const float y0, const float x1, const float y1, + const float x2, const float y2, const float x3, const float y3, float *xi,float *yi) { /* @@ -405,7 +405,7 @@ static short IsectLLPt2Df(float x0,float y0,float x1,float y1, /* point in tri */ -int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2]) +int isect_point_tri_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2]) { if (line_point_side_v2(v1,v2,pt)>=0.0f) { if (line_point_side_v2(v2,v3,pt)>=0.0f) { @@ -424,7 +424,7 @@ int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2]) return 0; } /* point in quad - only convex quads */ -int isect_point_quad_v2(float pt[2], float v1[2], float v2[2], float v3[2], float v4[2]) +int isect_point_quad_v2(const float pt[2], const float v1[2], const float v2[2], const float v3[2], const float v4[2]) { if (line_point_side_v2(v1,v2,pt)>=0.0f) { if (line_point_side_v2(v2,v3,pt)>=0.0f) { @@ -451,7 +451,7 @@ int isect_point_quad_v2(float pt[2], float v1[2], float v2[2], float v3[2], floa test if the line starting at p1 ending at p2 intersects the triangle v0..v2 return non zero if it does */ -int isect_line_tri_v3(float p1[3], float p2[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv) +int isect_line_tri_v3(const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2]) { float p[3], s[3], d[3], e1[3], e2[3], q[3]; @@ -473,7 +473,7 @@ int isect_line_tri_v3(float p1[3], float p2[3], float v0[3], float v1[3], float cross_v3_v3v3(q, s, e1); - v = f * dot_v3v3(d, q); + v = f * dot_v3v3(d, q); if ((v < 0.0f)||((u + v) > 1.0f)) return 0; *lambda = f * dot_v3v3(e2, q); @@ -491,7 +491,7 @@ int isect_line_tri_v3(float p1[3], float p2[3], float v0[3], float v1[3], float test if the ray starting at p1 going in d direction intersects the triangle v0..v2 return non zero if it does */ -int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv) +int isect_ray_tri_v3(const float p1[3], const float d[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2]) { float p[3], s[3], e1[3], e2[3], q[3]; float a, f, u, v; @@ -519,7 +519,7 @@ int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2 *lambda = f * dot_v3v3(e2, q); if ((*lambda < 0.0f)) return 0; - if(uv) { + if(uv) { uv[0]= u; uv[1]= v; } @@ -527,41 +527,41 @@ int isect_ray_tri_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2 return 1; } -int isect_ray_tri_epsilon_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float epsilon) +int isect_ray_tri_epsilon_v3(const float p1[3], const float d[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float uv[2], const float epsilon) { - float p[3], s[3], e1[3], e2[3], q[3]; - float a, f, u, v; + float p[3], s[3], e1[3], e2[3], q[3]; + float a, f, u, v; - sub_v3_v3v3(e1, v1, v0); - sub_v3_v3v3(e2, v2, v0); + sub_v3_v3v3(e1, v1, v0); + sub_v3_v3v3(e2, v2, v0); - cross_v3_v3v3(p, d, e2); - a = dot_v3v3(e1, p); - if (a == 0.0f) return 0; - f = 1.0f/a; + cross_v3_v3v3(p, d, e2); + a = dot_v3v3(e1, p); + if (a == 0.0f) return 0; + f = 1.0f/a; - sub_v3_v3v3(s, p1, v0); + sub_v3_v3v3(s, p1, v0); - u = f * dot_v3v3(s, p); - if ((u < -epsilon)||(u > 1.0f+epsilon)) return 0; + u = f * dot_v3v3(s, p); + if ((u < -epsilon)||(u > 1.0f+epsilon)) return 0; - cross_v3_v3v3(q, s, e1); + cross_v3_v3v3(q, s, e1); - v = f * dot_v3v3(d, q); - if ((v < -epsilon)||((u + v) > 1.0f+epsilon)) return 0; + v = f * dot_v3v3(d, q); + if ((v < -epsilon)||((u + v) > 1.0f+epsilon)) return 0; - *lambda = f * dot_v3v3(e2, q); - if ((*lambda < 0.0f)) return 0; + *lambda = f * dot_v3v3(e2, q); + if ((*lambda < 0.0f)) return 0; - if(uv) { - uv[0]= u; - uv[1]= v; - } + if(uv) { + uv[0]= u; + uv[1]= v; + } - return 1; + return 1; } -int isect_ray_tri_threshold_v3(float p1[3], float d[3], float v0[3], float v1[3], float v2[3], float *lambda, float *uv, float threshold) +int isect_ray_tri_threshold_v3(const float p1[3], const float d[3], const float v0[3], const float v1[3], const float v2[3], float *lambda, float *uv, const float threshold) { float p[3], s[3], e1[3], e2[3], q[3]; float a, f, u, v; @@ -614,7 +614,7 @@ int isect_ray_tri_threshold_v3(float p1[3], float d[3], float v0[3], float v1[3] /* Adapted from the paper by Kasper Fauerby */ /* "Improved Collision detection and Response" */ -static int getLowestRoot(float a, float b, float c, float maxR, float* root) +static int getLowestRoot(const float a, const float b, const float c, const float maxR, float *root) { // Check if a solution exists float determinant = b*b - 4.0f*a*c; @@ -651,7 +651,7 @@ static int getLowestRoot(float a, float b, float c, float maxR, float* root) return 0; } -int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, float v0[3], float v1[3], float v2[3], float *lambda, float *ipoint) +int isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const float radius, const float v0[3], const float v1[3], const float v2[3], float *lambda, float ipoint[3]) { float e1[3], e2[3], e3[3], point[3], vel[3], /*dist[3],*/ nor[3], temp[3], bv[3]; float a, b, c, d, e, x, y, z, radius2=radius*radius; @@ -848,7 +848,7 @@ int isect_sweeping_sphere_tri_v3(float p1[3], float p2[3], float radius, float v return found_by_sweep; } -int isect_axial_line_tri_v3(int axis, float p1[3], float p2[3], float v0[3], float v1[3], float v2[3], float *lambda) +int isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3], const float v0[3], const float v1[3], const float v2[3], float *lambda) { float p[3], e1[3], e2[3]; float u, v, f; @@ -897,7 +897,7 @@ int isect_axial_line_tri_v3(int axis, float p1[3], float p2[3], float v0[3], flo * 1 - lines are coplanar, i1 is set to intersection * 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) respectively * */ -int isect_line_line_v3(float v1[3], float v2[3], float v3[3], float v4[3], float i1[3], float i2[3]) +int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float i1[3], float i2[3]) { float a[3], b[3], c[3], ab[3], cb[3], dir1[3], dir2[3]; float d; @@ -961,7 +961,7 @@ int isect_line_line_v3(float v1[3], float v2[3], float v3[3], float v4[3], float /* Intersection point strictly between the two lines * 0 when no intersection is found * */ -int isect_line_line_strict_v3(float v1[3], float v2[3], float v3[3], float v4[3], float vi[3], float *lambda) +int isect_line_line_strict_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float vi[3], float *lambda) { float a[3], b[3], c[3], ab[3], cb[3], ca[3], dir1[3], dir2[3]; float d; @@ -1014,7 +1014,7 @@ int isect_line_line_strict_v3(float v1[3], float v2[3], float v3[3], float v4[3] } } -int isect_aabb_aabb_v3(float min1[3], float max1[3], float min2[3], float max2[3]) +int isect_aabb_aabb_v3(const float min1[3], const float max1[3], const float min2[3], const float max2[3]) { return (min1[0]<max2[0] && min1[1]<max2[1] && min1[2]<max2[2] && min2[0]<max1[0] && min2[1]<max1[1] && min2[2]<max1[2]); @@ -1058,7 +1058,7 @@ static float lambda_cp_line(float p[3], float l1[3], float l2[3]) #endif /* Similar to LineIntersectsTriangleUV, except it operates on a quad and in 2d, assumes point is in quad */ -void isect_point_quad_uv_v2(float v0[2], float v1[2], float v2[2], float v3[2], float pt[2], float *uv) +void isect_point_quad_uv_v2(const float v0[2], const float v1[2], const float v2[2], const float v3[2], const float pt[2], float *uv) { float x0,y0, x1,y1, wtot, v2d[2], w1, w2; @@ -1152,7 +1152,7 @@ void isect_point_quad_uv_v2(float v0[2], float v1[2], float v2[2], float v3[2], } /* same as above but does tri's and quads, tri's are a bit of a hack */ -void isect_point_face_uv_v2(int isquad, float v0[2], float v1[2], float v2[2], float v3[2], float pt[2], float *uv) +void isect_point_face_uv_v2(const int isquad, const float v0[2], const float v1[2], const float v2[2], const float v3[2], const float pt[2], float *uv) { if (isquad) { isect_point_quad_uv_v2(v0, v1, v2, v3, pt, uv); @@ -1238,7 +1238,7 @@ int isect_point_tri_v2(float v0[2], float v1[2], float v2[2], float pt[2]) x1,y1-- x2,y1 */ -int isect_point_tri_v2_int(int x1, int y1, int x2, int y2, int a, int b) +int isect_point_tri_v2_int(const int x1, const int y1, const int x2, const int y2, const int a, const int b) { float v1[2], v2[2], v3[2], p[2]; @@ -1257,7 +1257,7 @@ int isect_point_tri_v2_int(int x1, int y1, int x2, int y2, int a, int b) return isect_point_tri_v2(p, v1, v2, v3); } -static int point_in_slice(float p[3], float v1[3], float l1[3], float l2[3]) +static int point_in_slice(const float p[3], const float v1[3], const float l1[3], const float l2[3]) { /* what is a slice ? @@ -1305,7 +1305,7 @@ static int point_in_slice_m(float p[3],float origin[3],float normal[3],float lns } #endif -int isect_point_tri_prism_v3(float p[3], float v1[3], float v2[3], float v3[3]) +int isect_point_tri_prism_v3(const float p[3], const float v1[3], const float v2[3], const float v3[3]) { if(!point_in_slice(p,v1,v2,v3)) return 0; if(!point_in_slice(p,v2,v3,v1)) return 0; @@ -1313,7 +1313,7 @@ int isect_point_tri_prism_v3(float p[3], float v1[3], float v2[3], float v3[3]) return 1; } -int clip_line_plane(float p1[3], float p2[3], float plane[4]) +int clip_line_plane(float p1[3], float p2[3], const float plane[4]) { float dp[3], n[3], div, t, pc[3]; @@ -1363,7 +1363,7 @@ int clip_line_plane(float p1[3], float p2[3], float plane[4]) } -void plot_line_v2v2i(int p1[2], int p2[2], int (*callback)(int, int, void *), void *userData) +void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, void *), void *userData) { int x1= p1[0]; int y1= p1[1]; @@ -1429,12 +1429,12 @@ void plot_line_v2v2i(int p1[2], int p2[2], int (*callback)(int, int, void *), vo /****************************** Interpolation ********************************/ -static float tri_signed_area(float *v1, float *v2, float *v3, int i, int j) +static float tri_signed_area(const float v1[3], const float v2[3], const float v3[3], const int i, const int j) { return 0.5f*((v1[i]-v2[i])*(v2[j]-v3[j]) + (v1[j]-v2[j])*(v3[i]-v2[i])); } -static int barycentric_weights(float *v1, float *v2, float *v3, float *co, float *n, float *w) +static int barycentric_weights(const float v1[3], const float v2[3], const float v3[3], const float co[3], const float n[3], float w[3]) { float xn, yn, zn, a1, a2, a3, asum; short i, j; @@ -1468,7 +1468,7 @@ static int barycentric_weights(float *v1, float *v2, float *v3, float *co, float return 0; } -void interp_weights_face_v3(float *w,float *v1, float *v2, float *v3, float *v4, float *co) +void interp_weights_face_v3(float w[4], const float v1[3], const float v2[3], const float v3[3], const float v4[3], const float co[3]) { float w2[3]; @@ -1524,22 +1524,22 @@ void interp_weights_face_v3(float *w,float *v1, float *v2, float *v3, float *v4, * note: using area_tri_signed_v2 means locations outside the triangle are correctly weighted */ void barycentric_weights_v2(const float v1[2], const float v2[2], const float v3[2], const float co[2], float w[3]) { - float wtot_inv, wtot; + float wtot_inv, wtot; - w[0] = area_tri_signed_v2(v2, v3, co); - w[1] = area_tri_signed_v2(v3, v1, co); - w[2] = area_tri_signed_v2(v1, v2, co); - wtot = w[0]+w[1]+w[2]; + w[0] = area_tri_signed_v2(v2, v3, co); + w[1] = area_tri_signed_v2(v3, v1, co); + w[2] = area_tri_signed_v2(v1, v2, co); + wtot = w[0]+w[1]+w[2]; - if (wtot != 0.0f) { - wtot_inv = 1.0f/wtot; + if (wtot != 0.0f) { + wtot_inv = 1.0f/wtot; - w[0] = w[0]*wtot_inv; - w[1] = w[1]*wtot_inv; - w[2] = w[2]*wtot_inv; - } - else /* dummy values for zero area face */ - w[0] = w[1] = w[2] = 1.0f/3.0f; + w[0] = w[0]*wtot_inv; + w[1] = w[1]*wtot_inv; + w[2] = w[2]*wtot_inv; + } + else /* dummy values for zero area face */ + w[0] = w[1] = w[2] = 1.0f/3.0f; } /* given 2 triangles in 3D space, and a point in relation to the first triangle. @@ -1592,7 +1592,7 @@ void barycentric_transform(float pt_tar[3], float const pt_src[3], /* given an array with some invalid values this function interpolates valid values * replacing the invalid ones */ -int interp_sparse_array(float *array, int list_size, float skipval) +int interp_sparse_array(float *array, int const list_size, const float skipval) { int found_invalid = 0; int found_valid = 0; @@ -1672,7 +1672,7 @@ int interp_sparse_array(float *array, int list_size, float skipval) /* Mean value weights - smooth interpolation weights for polygons with * more than 3 vertices */ -static float mean_value_half_tan(float *v1, float *v2, float *v3) +static float mean_value_half_tan(const float v1[3], const float v2[3], const float v3[3]) { float d2[3], d3[3], cross[3], area, dot, len; @@ -1690,7 +1690,7 @@ static float mean_value_half_tan(float *v1, float *v2, float *v3) return (len - dot)/area; } -void interp_weights_poly_v3(float *w,float v[][3], int n, float *co) +void interp_weights_poly_v3(float *w, float v[][3], const int n, const float co[3]) { float totweight, t1, t2, len, *vmid, *vprev, *vnext; int i; @@ -1716,7 +1716,7 @@ void interp_weights_poly_v3(float *w,float v[][3], int n, float *co) } /* (x1,v1)(t1=0)------(x2,v2)(t2=1), 0<t<1 --> (x,v)(t) */ -void interp_cubic_v3(float *x, float *v,float *x1, float *v1, float *x2, float *v2, float t) +void interp_cubic_v3(float x[3], float v[3], const float x1[3], const float v1[3], const float x2[3], const float v2[3], const float t) { float a[3],b[3]; float t2= t*t; @@ -1742,7 +1742,7 @@ void interp_cubic_v3(float *x, float *v,float *x1, float *v1, float *x2, float * /***************************** View & Projection *****************************/ -void orthographic_m4(float matrix[][4],float left, float right, float bottom, float top, float nearClip, float farClip) +void orthographic_m4(float matrix[][4], const float left, const float right, const float bottom, const float top, const float nearClip, const float farClip) { float Xdelta, Ydelta, Zdelta; @@ -1761,7 +1761,7 @@ void orthographic_m4(float matrix[][4],float left, float right, float bottom, fl matrix[3][2] = -(farClip + nearClip)/Zdelta; } -void perspective_m4(float mat[][4],float left, float right, float bottom, float top, float nearClip, float farClip) +void perspective_m4(float mat[][4],float left, const float right, const float bottom, const float top, const float nearClip, const float farClip) { float Xdelta, Ydelta, Zdelta; @@ -1786,7 +1786,7 @@ void perspective_m4(float mat[][4],float left, float right, float bottom, float } /* translate a matrix created by orthographic_m4 or perspective_m4 in XY coords (used to jitter the view) */ -void window_translate_m4(float winmat[][4], float perspmat[][4], float x, float y) +void window_translate_m4(float winmat[][4], float perspmat[][4], const float x, const float y) { if(winmat[2][3] == -1.0f) { /* in the case of a win-matrix, this means perspective always */ @@ -1890,7 +1890,7 @@ void lookat_m4(float mat[][4],float vx, float vy, float vz, float px, float py, translate_m4(mat,-vx,-vy,-vz); /* translate viewpoint to origin */ } -int box_clip_bounds_m4(float boundbox[2][3], float bounds[4], float winmat[4][4]) +int box_clip_bounds_m4(float boundbox[2][3], const float bounds[4], float winmat[4][4]) { float mat[4][4], vec[4]; int a, fl, flag= -1; @@ -1950,7 +1950,7 @@ void box_minmax_bounds_m4(float min[3], float max[3], float boundbox[2][3], floa /********************************** Mapping **********************************/ -void map_to_tube(float *u, float *v,float x, float y, float z) +void map_to_tube(float *u, float *v, const float x, const float y, const float z) { float len; @@ -1963,7 +1963,7 @@ void map_to_tube(float *u, float *v,float x, float y, float z) *v = *u = 0.0f; /* to avoid un-initialized variables */ } -void map_to_sphere(float *u, float *v,float x, float y, float z) +void map_to_sphere(float *u, float *v, const float x, const float y, const float z) { float len; @@ -1971,9 +1971,8 @@ void map_to_sphere(float *u, float *v,float x, float y, float z) if(len > 0.0f) { if(x==0.0f && y==0.0f) *u= 0.0f; /* othwise domain error */ else *u = (1.0f - atan2f(x,y) / (float)M_PI) / 2.0f; - - z/=len; - *v = 1.0f - (float)saacos(z)/(float)M_PI; + + *v = 1.0f - (float)saacos(z/len)/(float)M_PI; } else { *v = *u = 0.0f; /* to avoid un-initialized variables */ } @@ -2033,7 +2032,7 @@ void accumulate_vertex_normals(float n1[3], float n2[3], float n3[3], /* from BKE_mesh.h */ #define STD_UV_CONNECT_LIMIT 0.0001f -void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, float *tang, float *uv) +void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, const float tang[3], const float uv[2]) { VertexTangent *vt; @@ -2056,7 +2055,7 @@ void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, float *tang, *vtang= vt; } -float *find_vertex_tangent(VertexTangent *vtang, float *uv) +float *find_vertex_tangent(VertexTangent *vtang, const float uv[2]) { VertexTangent *vt; static float nulltang[3] = {0.0f, 0.0f, 0.0f}; @@ -2068,7 +2067,7 @@ float *find_vertex_tangent(VertexTangent *vtang, float *uv) return nulltang; /* shouldn't happen, except for nan or so */ } -void tangent_from_uv(float *uv1, float *uv2, float *uv3, float *co1, float *co2, float *co3, float *n, float *tang) +void tangent_from_uv(float uv1[2], float uv2[2], float uv3[3], float co1[3], float co2[3], float co3[3], float n[3], float tang[3]) { float s1= uv2[0] - uv1[0]; float s2= uv3[0] - uv1[0]; @@ -2262,14 +2261,14 @@ void vcloud_estimate_transform(int list_size, float (*pos)[3], float *weight,flo /******************************* Form Factor *********************************/ -static void vec_add_dir(float r[3], float v1[3], float v2[3], float fac) +static void vec_add_dir(float r[3], const float v1[3], const float v2[3], const float fac) { r[0]= v1[0] + fac*(v2[0] - v1[0]); r[1]= v1[1] + fac*(v2[1] - v1[1]); r[2]= v1[2] + fac*(v2[2] - v1[2]); } -static int ff_visible_quad(float p[3], float n[3], float v0[3], float v1[3], float v2[3], float q0[3], float q1[3], float q2[3], float q3[3]) +static int ff_visible_quad(const float p[3], const float n[3], const float v0[3], const float v1[3], const float v2[3], float q0[3], float q1[3], float q2[3], float q3[3]) { static const float epsilon = 1e-6f; float c, sd[3]; @@ -2605,7 +2604,7 @@ static float ff_quad_form_factor(float *p, float *n, float *q0, float *q1, float aresult = (_mm_set_ps1(n[0])*gx + _mm_set_ps1(n[1])*gy + _mm_set_ps1(n[2])*gz)*angle; /* sum together */ - result= (fresult[0] + fresult[1] + fresult[2] + fresult[3])*(0.5f/(float)M_PI); + result= (fresult[0] + fresult[1] + fresult[2] + fresult[3])*(0.5f/(float)M_PI); result= MAX2(result, 0.0f); return result; @@ -2628,7 +2627,7 @@ static void ff_normalize(float n[3]) } } -static float ff_quad_form_factor(float *p, float *n, float *q0, float *q1, float *q2, float *q3) +static float ff_quad_form_factor(const float p[3], const float n[3], const float q0[3], const float q1[3], const float q2[3], const float q3[3]) { float r0[3], r1[3], r2[3], r3[3], g0[3], g1[3], g2[3], g3[3]; float a1, a2, a3, a4, dot1, dot2, dot3, dot4, result; diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index 48fcbcfe140..41dce131c17 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -42,12 +42,12 @@ MINLINE void zero_sh(float r[9]) memset(r, 0, sizeof(float)*9); } -MINLINE void copy_sh_sh(float r[9], float a[9]) +MINLINE void copy_sh_sh(float r[9], const float a[9]) { memcpy(r, a, sizeof(float)*9); } -MINLINE void mul_sh_fl(float r[9], float f) +MINLINE void mul_sh_fl(float r[9], const float f) { int i; @@ -55,7 +55,7 @@ MINLINE void mul_sh_fl(float r[9], float f) r[i] *= f; } -MINLINE void add_sh_shsh(float r[9], float a[9], float b[9]) +MINLINE void add_sh_shsh(float r[9], const float a[9], const float b[9]) { int i; @@ -74,7 +74,7 @@ MINLINE float dot_shsh(float a[9], float b[9]) return r; } -MINLINE float diffuse_shv3(float sh[9], float v[3]) +MINLINE float diffuse_shv3(float sh[9], const float v[3]) { /* See formula (13) in: "An Efficient Representation for Irradiance Environment Maps" */ @@ -96,7 +96,7 @@ MINLINE float diffuse_shv3(float sh[9], float v[3]) return sum; } -MINLINE void vec_fac_to_sh(float r[9], float v[3], float f) +MINLINE void vec_fac_to_sh(float r[9], const float v[3], const float f) { /* See formula (3) in: "An Efficient Representation for Irradiance Environment Maps" */ @@ -122,7 +122,7 @@ MINLINE void vec_fac_to_sh(float r[9], float v[3], float f) copy_sh_sh(r, sh); } -MINLINE float eval_shv3(float sh[9], float v[3]) +MINLINE float eval_shv3(float sh[9], const float v[3]) { float tmp[9]; @@ -130,7 +130,7 @@ MINLINE float eval_shv3(float sh[9], float v[3]) return dot_shsh(tmp, sh); } -MINLINE void madd_sh_shfl(float r[9], float sh[3], float f) +MINLINE void madd_sh_shfl(float r[9], const float sh[3], const float f) { float tmp[9]; diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index 9a36f000624..75520bb8ba0 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -315,7 +315,7 @@ MINLINE float dot_v3v3(const float a[3], const float b[3]) MINLINE float cross_v2v2(const float a[2], const float b[2]) { - return a[0]*b[1] - a[1]*b[0]; + return a[0]*b[1] - a[1]*b[0]; } MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]) diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index 49a09dd7b15..5d80edebbef 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -1098,7 +1098,7 @@ static float dist_Minkovsky4(float x, float y, float z, float e) /* Minkovsky, general case, slow, maybe too slow to be useful */ static float dist_Minkovsky(float x, float y, float z, float e) { - return pow(pow(fabs(x), e) + pow(fabs(y), e) + pow(fabs(z), e), 1.0/e); + return pow(pow(fabs(x), e) + pow(fabs(y), e) + pow(fabs(z), e), 1.0/e); } @@ -1275,18 +1275,18 @@ static float voronoi_CrS(float x, float y, float z) /* returns unsigned cellnoise */ static float cellNoiseU(float x, float y, float z) { - int xi = (int)(floor(x)); - int yi = (int)(floor(y)); - int zi = (int)(floor(z)); - unsigned int n = xi + yi*1301 + zi*314159; - n ^= (n<<13); - return ((float)(n*(n*n*15731 + 789221) + 1376312589) / 4294967296.0); + int xi = (int)(floor(x)); + int yi = (int)(floor(y)); + int zi = (int)(floor(z)); + unsigned int n = xi + yi*1301 + zi*314159; + n ^= (n<<13); + return ((float)(n*(n*n*15731 + 789221) + 1376312589) / 4294967296.0); } /* idem, signed */ float cellNoise(float x, float y, float z) { - return (2.0*cellNoiseU(x, y, z)-1.0); + return (2.0*cellNoiseU(x, y, z)-1.0); } /* returns a vector/point/color in ca, using point hasharray directly */ diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index f7115b4d46f..1a47a93ab51 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -324,8 +324,8 @@ void BLI_cleanup_path(const char *relabase, char *dir) /* Note, this should really be moved to the file selector, * since this function is used in many areas */ if(strcmp(dir, ".")==0) { /* happens for example in FILE_MAIN */ - get_default_root(dir); - return; + get_default_root(dir); + return; } while ( (start = strstr(dir, "\\..\\")) ) { @@ -353,9 +353,9 @@ void BLI_cleanup_path(const char *relabase, char *dir) } #else if(dir[0]=='.') { /* happens, for example in FILE_MAIN */ - dir[0]= '/'; - dir[1]= 0; - return; + dir[0]= '/'; + dir[1]= 0; + return; } /* support for odd paths: eg /../home/me --> /home/me @@ -525,7 +525,7 @@ int BLI_parent_dir(char *path) BLI_add_slash(tmp); strcat(tmp, parent_dir); BLI_cleanup_dir(NULL, tmp); - + if (!BLI_testextensie(tmp, parent_dir)) { BLI_strncpy(path, tmp, sizeof(tmp)); return 1; @@ -1144,6 +1144,8 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check) ok= get_path_system(path, NULL, NULL, NULL, ver); break; default: + path[0]= '\0'; /* incase do_check is false */ + ok= FALSE; BLI_assert(!"incorrect ID"); } diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index a2fa69bfcd9..95a43a998d3 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -672,7 +672,7 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter) parents, this order is necessary for e.g. computing bounding boxes */ while(iter->stacksize) { - /* pop node */ + /* pop node */ iter->stacksize--; node= iter->stack[iter->stacksize].node; @@ -709,30 +709,30 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter) static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter) { - PBVHNode *node; - - while(iter->stacksize) { - /* pop node */ - iter->stacksize--; - node= iter->stack[iter->stacksize].node; - - /* on a mesh with no faces this can happen - * can remove this check if we know meshes have at least 1 face */ - if(node==NULL) return NULL; - - if(iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */ - - if(node->flag & PBVH_Leaf) { - /* immediately hit leaf node */ - return node; - } - else { - pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset+1, 0); - pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset, 0); - } - } - - return NULL; + PBVHNode *node; + + while(iter->stacksize) { + /* pop node */ + iter->stacksize--; + node= iter->stack[iter->stacksize].node; + + /* on a mesh with no faces this can happen + * can remove this check if we know meshes have at least 1 face */ + if(node==NULL) return NULL; + + if(iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */ + + if(node->flag & PBVH_Leaf) { + /* immediately hit leaf node */ + return node; + } + else { + pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset+1, 0); + pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset, 0); + } + } + + return NULL; } void BLI_pbvh_search_gather(PBVH *bvh, @@ -793,59 +793,59 @@ void BLI_pbvh_search_callback(PBVH *bvh, } typedef struct node_tree { - PBVHNode* data; + PBVHNode* data; - struct node_tree* left; - struct node_tree* right; + struct node_tree* left; + struct node_tree* right; } node_tree; static void node_tree_insert(node_tree* tree, node_tree* new_node) { - if (new_node->data->tmin < tree->data->tmin) { - if (tree->left) { - node_tree_insert(tree->left, new_node); - } - else { - tree->left = new_node; - } - } - else { - if (tree->right) { - node_tree_insert(tree->right, new_node); - } - else { - tree->right = new_node; - } - } + if (new_node->data->tmin < tree->data->tmin) { + if (tree->left) { + node_tree_insert(tree->left, new_node); + } + else { + tree->left = new_node; + } + } + else { + if (tree->right) { + node_tree_insert(tree->right, new_node); + } + else { + tree->right = new_node; + } + } } static void traverse_tree(node_tree* tree, BLI_pbvh_HitOccludedCallback hcb, void* hit_data, float* tmin) { - if (tree->left) traverse_tree(tree->left, hcb, hit_data, tmin); + if (tree->left) traverse_tree(tree->left, hcb, hit_data, tmin); - hcb(tree->data, hit_data, tmin); + hcb(tree->data, hit_data, tmin); - if (tree->right) traverse_tree(tree->right, hcb, hit_data, tmin); + if (tree->right) traverse_tree(tree->right, hcb, hit_data, tmin); } static void free_tree(node_tree* tree) { - if (tree->left) { - free_tree(tree->left); - tree->left = 0; - } + if (tree->left) { + free_tree(tree->left); + tree->left = 0; + } - if (tree->right) { - free_tree(tree->right); - tree->right = 0; - } + if (tree->right) { + free_tree(tree->right); + tree->right = 0; + } - free(tree); + free(tree); } float BLI_pbvh_node_get_tmin(PBVHNode* node) { - return node->tmin; + return node->tmin; } static void BLI_pbvh_search_callback_occluded(PBVH *bvh, @@ -1129,7 +1129,7 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot GHash *map; void *face, **faces; unsigned i; - int tot; + int tot; map = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "pbvh_get_grid_updates gh"); @@ -1318,17 +1318,17 @@ static int ray_face_intersection(float ray_start[3], float ray_normal[3], float *t0, float *t1, float *t2, float *t3, float *fdist) { - float dist; - - if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist, NULL, 0.1f) && dist < *fdist) || - (t3 && isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist, NULL, 0.1f) && dist < *fdist)) - { - *fdist = dist; - return 1; - } - else { - return 0; - } + float dist; + + if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist, NULL, 0.1f) && dist < *fdist) || + (t3 && isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist, NULL, 0.1f) && dist < *fdist)) + { + *fdist = dist; + return 1; + } + else { + return 0; + } } int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3], diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index d626ca4bf09..ee5bd17c901 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -381,64 +381,64 @@ static const char trailingBytesForUTF8[256] = { int BLI_utf8_invalid_byte(const char *str, int length) { - const unsigned char *p, *pend = (unsigned char*)str + length; - unsigned char c; - int ab; - - for (p = (unsigned char*)str; p < pend; p++) { - c = *p; - if (c < 128) - continue; - if ((c & 0xc0) != 0xc0) - goto utf8_error; - ab = trailingBytesForUTF8[c]; - if (length < ab) - goto utf8_error; - length -= ab; - - p++; - /* Check top bits in the second byte */ - if ((*p & 0xc0) != 0x80) - goto utf8_error; - - /* Check for overlong sequences for each different length */ - switch (ab) { - /* Check for xx00 000x */ - case 1: - if ((c & 0x3e) == 0) goto utf8_error; - continue; /* We know there aren't any more bytes to check */ - - /* Check for 1110 0000, xx0x xxxx */ - case 2: - if (c == 0xe0 && (*p & 0x20) == 0) goto utf8_error; - break; - - /* Check for 1111 0000, xx00 xxxx */ - case 3: - if (c == 0xf0 && (*p & 0x30) == 0) goto utf8_error; - break; - - /* Check for 1111 1000, xx00 0xxx */ - case 4: - if (c == 0xf8 && (*p & 0x38) == 0) goto utf8_error; - break; - - /* Check for leading 0xfe or 0xff, - and then for 1111 1100, xx00 00xx */ - case 5: - if (c == 0xfe || c == 0xff || - (c == 0xfc && (*p & 0x3c) == 0)) goto utf8_error; - break; - } - - /* Check for valid bytes after the 2nd, if any; all must start 10 */ - while (--ab > 0) { - if ((*(p+1) & 0xc0) != 0x80) goto utf8_error; + const unsigned char *p, *pend = (unsigned char*)str + length; + unsigned char c; + int ab; + + for (p = (unsigned char*)str; p < pend; p++) { + c = *p; + if (c < 128) + continue; + if ((c & 0xc0) != 0xc0) + goto utf8_error; + ab = trailingBytesForUTF8[c]; + if (length < ab) + goto utf8_error; + length -= ab; + + p++; + /* Check top bits in the second byte */ + if ((*p & 0xc0) != 0x80) + goto utf8_error; + + /* Check for overlong sequences for each different length */ + switch (ab) { + /* Check for xx00 000x */ + case 1: + if ((c & 0x3e) == 0) goto utf8_error; + continue; /* We know there aren't any more bytes to check */ + + /* Check for 1110 0000, xx0x xxxx */ + case 2: + if (c == 0xe0 && (*p & 0x20) == 0) goto utf8_error; + break; + + /* Check for 1111 0000, xx00 xxxx */ + case 3: + if (c == 0xf0 && (*p & 0x30) == 0) goto utf8_error; + break; + + /* Check for 1111 1000, xx00 0xxx */ + case 4: + if (c == 0xf8 && (*p & 0x38) == 0) goto utf8_error; + break; + + /* Check for leading 0xfe or 0xff, + and then for 1111 1100, xx00 00xx */ + case 5: + if (c == 0xfe || c == 0xff || + (c == 0xfc && (*p & 0x3c) == 0)) goto utf8_error; + break; + } + + /* Check for valid bytes after the 2nd, if any; all must start 10 */ + while (--ab > 0) { + if ((*(p+1) & 0xc0) != 0x80) goto utf8_error; p++; /* do this after so we get usable offset - campbell */ - } - } + } + } - return -1; + return -1; utf8_error: diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index 90754e7d2bb..596ab2b0470 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -307,21 +307,21 @@ int check_file_chars(char *filename) #include <string.h> char* dirname(char *path) { - char *p; - if( path == NULL || *path == '\0' ) - return "."; - p = path + strlen(path) - 1; - while( *p == '/' ) { - if( p == path ) - return path; - *p-- = '\0'; - } - while( p >= path && *p != '/' ) - p--; - return - p < path ? "." : - p == path ? "/" : - (*p = '\0', path); + char *p; + if( path == NULL || *path == '\0' ) + return "."; + p = path + strlen(path) - 1; + while( *p == '/' ) { + if( p == path ) + return path; + *p-- = '\0'; + } + while( p >= path && *p != '/' ) + p--; + return + p < path ? "." : + p == path ? "/" : + (*p = '\0', path); } /* End of copied part */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index da228f930e3..55577f54889 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -291,6 +291,8 @@ static void *oldnewmap_lookup_and_inc(OldNewMap *onm, void *addr) { int i; + if(addr==NULL) return NULL; + if (onm->lasthit<onm->nentries-1) { OldNew *entry= &onm->entries[++onm->lasthit]; @@ -1205,7 +1207,7 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain) /* used entries were restored, so we put them to zero */ for (i=0; i<fd->imamap->nentries; i++, entry++) { - if (entry->nr>0) + if (entry->nr>0) entry->newp= NULL; } @@ -1864,6 +1866,10 @@ static void lib_link_nladata_strips(FileData *fd, ID *id, ListBase *list) /* reassign the counted-reference to action */ strip->act = newlibadr_us(fd, id->lib, strip->act); + + /* fix action id-root (i.e. if it comes from a pre 2.57 .blend file) */ + if ((strip->act) && (strip->act->idroot == 0)) + strip->act->idroot = GS(id->name); } } @@ -1957,6 +1963,12 @@ static void lib_link_animdata(FileData *fd, ID *id, AnimData *adt) adt->action= newlibadr_us(fd, id->lib, adt->action); adt->tmpact= newlibadr_us(fd, id->lib, adt->tmpact); + /* fix action id-roots (i.e. if they come from a pre 2.57 .blend file) */ + if ((adt->action) && (adt->action->idroot == 0)) + adt->action->idroot = GS(id->name); + if ((adt->tmpact) && (adt->tmpact->idroot == 0)) + adt->tmpact->idroot = GS(id->name); + /* link drivers */ lib_link_fcurves(fd, id, &adt->drivers); @@ -3401,15 +3413,19 @@ static void lib_link_mesh(FileData *fd, Main *main) static void direct_link_dverts(FileData *fd, int count, MDeformVert *mdverts) { - int i; + int i; - if (!mdverts) + if (mdverts == NULL) { return; + } - for (i=0; i<count; i++) { - mdverts[i].dw=newdataadr(fd, mdverts[i].dw); - if (!mdverts[i].dw) - mdverts[i].totweight=0; + for (i= count; i > 0; i--, mdverts++) { + if(mdverts->dw) { + mdverts->dw= newdataadr(fd, mdverts->dw); + } + if (mdverts->dw == NULL) { + mdverts->totweight= 0; + } } } @@ -3679,7 +3695,7 @@ static void lib_link_object(FileData *fd, Main *main) ob->gpd= newlibadr_us(fd, ob->id.lib, ob->gpd); ob->duplilist= NULL; - + ob->id.flag -= LIB_NEEDLINK; /* if id.us==0 a new base will be created later on */ @@ -6650,7 +6666,7 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) ar->v2d.max[0]= MAXFRAMEF; ar->v2d.max[1]= FLT_MAX; - + ar->v2d.minzoom= 0.01f; ar->v2d.maxzoom= 50; ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); @@ -10124,7 +10140,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) { char str[FILE_MAX]; BLI_join_dirfile(str, sizeof(str), seq->strip->dir, seq->strip->stripdata->name); - BLI_path_abs(str, G.main->name); + BLI_path_abs(str, main->name); seq->sound = sound_new_file(main, str); } /* don't know, if anybody used that diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index cb535fd7320..874dc2237e5 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -3302,7 +3302,7 @@ void ANIM_channel_draw_widgets (bAnimContext *ac, bAnimListElem *ale, uiBlock *b { bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); View2D *v2d= &ac->ar->v2d; - float y, ymid, ytext; + float y, ymid /*, ytext*/; short offset; /* sanity checks - don't draw anything */ @@ -3321,7 +3321,7 @@ void ANIM_channel_draw_widgets (bAnimContext *ac, bAnimListElem *ale, uiBlock *b y= (ymaxc - yminc)/2 + yminc; ymid= y - 7; /* y-coordinates for text is only 4 down from middle */ - ytext= y - 4; + /* ytext= y - 4; */ /* no button backdrop behind icons */ uiBlockSetEmboss(block, UI_EMBOSSN); diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 1256c76bfa8..795e3ec8341 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -534,7 +534,7 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) /* run the given check on the 3 handles * - check should be a macro, which takes the handle index as its single arg, which it substitutes later - * - requires that a var, of type short, is named 'ok', and has been initialised ot 0 + * - requires that a var, of type short, is named 'ok', and has been initialized to 0 */ #define KEYFRAME_OK_CHECKS(check) \ { \ diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 07069a69c40..f111339b963 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -113,7 +113,7 @@ void delete_fcurve_keys(FCurve *fcu) if(fcu->bezt==NULL) /* ignore baked curves */ return; - + /* Delete selected BezTriples */ for (i=0; i < fcu->totvert; i++) { if (fcu->bezt[i].f2 & SELECT) { diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 278fa4ccab4..cb93d2bf70b 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1287,7 +1287,7 @@ void ANIM_OT_keyframe_delete (wmOperatorType *ot) PropertyRNA *prop; /* identifiers */ - ot->name= "Delete Keyframe"; + ot->name= "Delete Keying-Set Keyframe"; ot->idname= "ANIM_OT_keyframe_delete"; ot->description= "Delete keyframes on the current frame for all properties in the specified Keying Set"; diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 7a6141540bd..86dc2182e03 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -206,7 +206,7 @@ void POSE_OT_propagate(struct wmOperatorType *ot); /* editarmature.c */ EditBone *make_boneList(struct ListBase *edbo, struct ListBase *bones, struct EditBone *parent, struct Bone *actBone); -void BIF_sk_selectStroke(struct bContext *C, short mval[2], short extend); +void BIF_sk_selectStroke(struct bContext *C, const short mval[2], short extend); /* duplicate method */ void preEditBoneDuplicate(struct ListBase *editbones); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 4e77cebf27d..f0f33ec3258 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -416,7 +416,9 @@ void ED_armature_from_edit(Object *obedit) newBone->flag= eBone->flag; if (eBone == arm->act_edbone) { - newBone->flag |= BONE_SELECTED; /* important, editbones can be active with only 1 point selected */ + /* don't change active selection, this messes up separate which uses + * editmode toggle and can separate active bone which is de-selected originally */ + /* newBone->flag |= BONE_SELECTED; */ /* important, editbones can be active with only 1 point selected */ arm->act_edbone= NULL; arm->act_bone= newBone; } @@ -504,6 +506,10 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) ebone->rad_head *= scale; ebone->rad_tail *= scale; ebone->dist *= scale; + + /* we could be smarter and scale by the matrix along the x & z axis */ + ebone->xwidth *= scale; + ebone->zwidth *= scale; } /* Turn the list into an armature */ @@ -993,7 +999,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) static void separated_armature_fix_links(Object *origArm, Object *newArm) { Object *ob; - bPoseChannel *pchan, *pcha, *pchb; + bPoseChannel *pchan; bConstraint *con; ListBase *opchans, *npchans; @@ -1020,38 +1026,23 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) * - the target isn't origArm/newArm itself * - the target is one that can be found in newArm/origArm */ - if ((ct->tar == origArm) && (ct->subtarget[0] != 0)) { - for (pcha=npchans->first, pchb=npchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) { - /* check if either one matches */ - if ( (strcmp(pcha->name, ct->subtarget)==0) || - (strcmp(pchb->name, ct->subtarget)==0) ) - { + if (ct->subtarget[0] != 0) { + if (ct->tar == origArm) { + if(BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) { ct->tar= newArm; - break; } - - /* check if both ends have met (to stop checking) */ - if (pcha == pchb) break; - } - } - else if ((ct->tar == newArm) && (ct->subtarget[0] != 0)) { - for (pcha=opchans->first, pchb=opchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) { - /* check if either one matches */ - if ( (strcmp(pcha->name, ct->subtarget)==0) || - (strcmp(pchb->name, ct->subtarget)==0) ) - { + } + else if (ct->tar == newArm) { + if(BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) { ct->tar= origArm; - break; } - - /* check if both ends have met (to stop checking) */ - if (pcha == pchb) break; - } + } } } - - if (cti->flush_constraint_targets) + + if (cti->flush_constraint_targets) { cti->flush_constraint_targets(con, &targets, 0); + } } } } @@ -1073,58 +1064,33 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) * - the target isn't origArm/newArm itself * - the target is one that can be found in newArm/origArm */ - if ((ct->tar == origArm) && (ct->subtarget[0] != 0)) { - for (pcha=npchans->first, pchb=npchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) { - /* check if either one matches */ - if ( (strcmp(pcha->name, ct->subtarget)==0) || - (strcmp(pchb->name, ct->subtarget)==0) ) - { + if(ct->subtarget[0] != '\0') { + if (ct->tar == origArm) { + if(BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) { ct->tar= newArm; - break; } - - /* check if both ends have met (to stop checking) */ - if (pcha == pchb) break; - } - } - else if ((ct->tar == newArm) && (ct->subtarget[0] != 0)) { - for (pcha=opchans->first, pchb=opchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) { - /* check if either one matches */ - if ( (strcmp(pcha->name, ct->subtarget)==0) || - (strcmp(pchb->name, ct->subtarget)==0) ) - { + } + else if (ct->tar == newArm) { + if(BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) { ct->tar= origArm; - break; } - - /* check if both ends have met (to stop checking) */ - if (pcha == pchb) break; - } + } } } - - if (cti->flush_constraint_targets) + + if (cti->flush_constraint_targets) { cti->flush_constraint_targets(con, &targets, 0); + } } } } /* See if an object is parented to this armature */ - if ((ob->parent) && (ob->parent == origArm)) { + if (ob->parent && (ob->parent == origArm)) { /* Is object parented to a bone of this src armature? */ - if (ob->partype==PARBONE) { - /* bone name in object */ - for (pcha=npchans->first, pchb=npchans->last; pcha && pchb; pcha=pcha->next, pchb=pchb->prev) { - /* check if either one matches */ - if ( (strcmp(pcha->name, ob->parsubstr)==0) || - (strcmp(pchb->name, ob->parsubstr)==0) ) - { - ob->parent= newArm; - break; - } - - /* check if both ends have met (to stop checking) */ - if (pcha == pchb) break; + if ((ob->partype == PARBONE) && (ob->parsubstr[0] != '\0')) { + if(BLI_findstring(npchans, ob->parsubstr, offsetof(bPoseChannel, name))) { + ob->parent= newArm; } } } @@ -1732,7 +1698,7 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) /* does bones and points */ /* note that BONE ROOT only gets drawn for root bones (or without IK) */ -static EditBone *get_nearest_editbonepoint (ViewContext *vc, short mval[2], ListBase *edbo, int findunsel, int *selmask) +static EditBone *get_nearest_editbonepoint (ViewContext *vc, const short mval[2], ListBase *edbo, int findunsel, int *selmask) { EditBone *ebone; rcti rect; @@ -1992,7 +1958,7 @@ static int ebone_select_flag(EditBone *ebone) } /* context: editmode armature in view3d */ -int mouse_armature(bContext *C, short mval[2], int extend) +int mouse_armature(bContext *C, const short mval[2], int extend) { Object *obedit= CTX_data_edit_object(C); bArmature *arm= obedit->data; @@ -2758,7 +2724,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* cancel if nothing selected */ if (CTX_DATA_COUNT(C, selected_bones) == 0) - return OPERATOR_CANCELLED; + return OPERATOR_CANCELLED; ED_armature_sync_selection(arm->edbo); // XXX why is this needed? @@ -5840,7 +5806,7 @@ EditBone * test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *ar lastBone = subdivideArcBy(arm, arm->edbo, iter, invmat, tmat, nextAdaptativeSubdivision); } - return lastBone; + return lastBone; } float arcLengthRatio(ReebArc *arc) diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index bd05f7f6581..b750bd5ef1c 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -1536,7 +1536,7 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm) Scene *scene = CTX_data_scene(C); EditBone *ebone; RigGraph *rg; - + rg = newRigGraph(); if (obedit == ob) @@ -1588,7 +1588,7 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm Scene *scene = CTX_data_scene(C); EditBone *ebone; RigGraph *rg; - + rg = newRigGraph(); if (obedit == ob) @@ -2829,7 +2829,7 @@ void BIF_retargetArmature(bContext *C) { RigGraph *rigg; bArmature *arm; - + arm = ob->data; /* Put the armature into editmode */ diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 4b83af30799..158c0d23ddc 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -2157,7 +2157,7 @@ static void sk_applyGesture(bContext *C, SK_Sketch *sketch) /********************************************/ -static int sk_selectStroke(bContext *C, SK_Sketch *sketch, short mval[2], int extend) +static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const short mval[2], int extend) { ViewContext vc; rcti rect; @@ -2473,7 +2473,7 @@ static int sketch_delete(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(ev return OPERATOR_FINISHED; } -void BIF_sk_selectStroke(bContext *C, short mval[2], short extend) +void BIF_sk_selectStroke(bContext *C, const short mval[2], short extend) { ToolSettings *ts = CTX_data_tool_settings(C); SK_Sketch *sketch = contextSketch(C, 0); diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 67773d358d0..b99605e65c1 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -471,7 +471,7 @@ static void heat_ray_tree_create(LaplacianSystem *sys) static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) { - BVHTreeRayHit hit; + BVHTreeRayHit hit; BVHCallbackUserData data; MFace *mface; float end[3]; @@ -1123,7 +1123,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], det = INPR(edge1, pvec); if (det == 0.0f) - return 0; + return 0; inv_det = 1.0f / det; /* calculate distance from vert0 to ray origin */ @@ -1132,7 +1132,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], /* calculate U parameter and test bounds */ u = INPR(tvec, pvec) * inv_det; if (u < -EPSILON || u > 1.0f+EPSILON) - return 0; + return 0; /* prepare to test V parameter */ cross_v3_v3v3(qvec, tvec, edge1); @@ -1140,7 +1140,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], /* calculate V parameter and test bounds */ v = INPR(dir, qvec) * inv_det; if (v < -EPSILON || u + v > 1.0f+EPSILON) - return 0; + return 0; isectco[0]= (1.0f - u - v)*vert0[0] + u*vert1[0] + v*vert2[0]; isectco[1]= (1.0f - u - v)*vert0[1] + u*vert1[1] + v*vert2[1]; diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 203d76086b3..3d6888d87dc 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -989,11 +989,11 @@ static float pose_propagate_get_boneHoldEndFrame (Object *ob, tPChanFCurveLink * } /* get reference value from F-Curve using RNA */ -static float pose_propagate_get_refVal (Object *ob, FCurve *fcu) +static short pose_propagate_get_refVal (Object *ob, FCurve *fcu, float *value) { PointerRNA id_ptr, ptr; PropertyRNA *prop; - float value; + short found= FALSE; /* base pointer is always the object -> id_ptr */ RNA_id_pointer_create(&ob->id, &id_ptr); @@ -1002,44 +1002,48 @@ static float pose_propagate_get_refVal (Object *ob, FCurve *fcu) if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) { if (RNA_property_array_check(&ptr, prop)) { /* array */ - if (fcu->array_index < RNA_property_array_length(&ptr, prop)) { + if (fcu->array_index < RNA_property_array_length(&ptr, prop)) { + found= TRUE; switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - value= (float)RNA_property_boolean_get_index(&ptr, prop, fcu->array_index); + *value= (float)RNA_property_boolean_get_index(&ptr, prop, fcu->array_index); break; case PROP_INT: - value= (float)RNA_property_int_get_index(&ptr, prop, fcu->array_index); + *value= (float)RNA_property_int_get_index(&ptr, prop, fcu->array_index); break; case PROP_FLOAT: - value= RNA_property_float_get_index(&ptr, prop, fcu->array_index); + *value= RNA_property_float_get_index(&ptr, prop, fcu->array_index); break; default: + found= FALSE; break; } } } else { /* not an array */ + found= TRUE; switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - value= (float)RNA_property_boolean_get(&ptr, prop); + *value= (float)RNA_property_boolean_get(&ptr, prop); break; case PROP_INT: - value= (float)RNA_property_int_get(&ptr, prop); + *value= (float)RNA_property_int_get(&ptr, prop); break; case PROP_ENUM: - value= (float)RNA_property_enum_get(&ptr, prop); + *value= (float)RNA_property_enum_get(&ptr, prop); break; case PROP_FLOAT: - value= RNA_property_float_get(&ptr, prop); + *value= RNA_property_float_get(&ptr, prop); break; default: + found= FALSE; break; } } } - return value; + return found; } /* propagate just works along each F-Curve in turn */ @@ -1062,7 +1066,8 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, * doesn't need to firstly keyframe the pose (though this doesn't mean that * they can't either) */ - refVal = pose_propagate_get_refVal(ob, fcu); + if( !pose_propagate_get_refVal(ob, fcu, &refVal)) + return; /* find the first keyframe to start propagating from * - if there's a keyframe on the current frame, we probably want to save this value there too diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index e9892c62a68..719362d82c5 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -1509,7 +1509,7 @@ static int pose_group_deselect_exec (bContext *C, wmOperator *UNUSED(op)) void POSE_OT_group_deselect (wmOperatorType *ot) { /* identifiers */ - ot->name= "Deselecte Bone Group"; + ot->name= "Deselect Bone Group"; ot->idname= "POSE_OT_group_deselect"; ot->description= "Deselect bones of active Bone Group"; diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index 490d4c587f9..04501243acb 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -2572,7 +2572,7 @@ ReebGraph * generateReebGraph(EditMesh *em, int subdivisions) int totfaces; int countfaces = 0; #endif - + rg = newReebGraph(); rg->resolution = subdivisions; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 4ef5f80dcf6..1ab7acef861 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -2855,7 +2855,7 @@ static void subdividenurb(Object *obedit, int number_cuts) int a, b, sel, amount, *usel, *vsel, i; float factor; - // printf("*** subdivideNurb: entering subdivide\n"); + // printf("*** subdivideNurb: entering subdivide\n"); for(nu= editnurb->nurbs.first; nu; nu= nu->next) { amount= 0; @@ -3031,7 +3031,7 @@ static void subdividenurb(Object *obedit, int number_cuts) /* This is a very strange test ... */ /** Subdivide NURB surfaces - nzc 30-5-'00 - - + Subdivision of a NURB curve can be effected by adding a control point (insertion of a knot), or by raising the degree of the functions used to build the NURB. The @@ -3231,8 +3231,7 @@ static void subdividenurb(Object *obedit, int number_cuts) MEM_freeN(nu->bp); nu->bp= bpnew; nu->pntsu+= sel; - nurbs_knot_calc_u(nu); /* shift knots - forward */ + nurbs_knot_calc_u(nu); /* shift knots forward */ } } } @@ -3581,7 +3580,7 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot) /* identifiers */ ot->name= "Set Spline Type"; - ot->description = "Set type of actibe spline"; + ot->description = "Set type of active spline"; ot->idname= "CURVE_OT_spline_type_set"; /* api callbacks */ @@ -4171,7 +4170,7 @@ void CURVE_OT_make_segment(wmOperatorType *ot) /***************** pick select from 3d view **********************/ -int mouse_nurb(bContext *C, short mval[2], int extend) +int mouse_nurb(bContext *C, const short mval[2], int extend) { Object *obedit= CTX_data_edit_object(C); Curve *cu= obedit->data; @@ -4413,11 +4412,10 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) Nurb *nu, *newnu= NULL; BezTriple *bezt, *newbezt = NULL; BPoint *bp, *newbp = NULL; - float mat[3][3],imat[3][3], temp[3]; + float imat[4][4], temp[3]; int ok= 0; - copy_m3_m4(mat, obedit->obmat); - invert_m3_m3(imat,mat); + invert_m4_m4(imat, obedit->obmat); findselectedNurbvert(&editnurb->nurbs, &nu, &bezt, &bp); @@ -4451,10 +4449,14 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) temp[0] = 1; temp[1] = 0; temp[2] = 0; + copy_v3_v3(newbezt->vec[1], location); - sub_v3_v3(newbezt->vec[1], obedit->obmat[3]); - sub_v3_v3v3(newbezt->vec[0], newbezt->vec[1],temp); - add_v3_v3v3(newbezt->vec[2], newbezt->vec[1],temp); + sub_v3_v3v3(newbezt->vec[0], newbezt->vec[1], temp); + add_v3_v3v3(newbezt->vec[2], newbezt->vec[1], temp); + + mul_m4_v3(imat, newbezt->vec[0]); + mul_m4_v3(imat, newbezt->vec[1]); + mul_m4_v3(imat, newbezt->vec[2]); ok= 1; nu= newnu; @@ -4473,9 +4475,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) newnu->orderu= 2; newnu->pntsu= 1; - copy_v3_v3(newbp->vec, location); - sub_v3_v3(newbp->vec, obedit->obmat[3]); - mul_m3_v3(imat,newbp->vec); + mul_v3_m4v3(newbp->vec, imat, location); newbp->vec[3]= 1.0; newnu->knotsu= newnu->knotsv= NULL; @@ -4555,9 +4555,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) copy_v3_v3(newbezt->vec[2], bezt->vec[2]); } else { - copy_v3_v3(newbezt->vec[1], location); - sub_v3_v3(newbezt->vec[1], obedit->obmat[3]); - mul_m3_v3(imat,newbezt->vec[1]); + mul_v3_m4v3(newbezt->vec[1], imat, location); sub_v3_v3v3(temp, newbezt->vec[1],temp); add_v3_v3v3(newbezt->vec[0], bezt->vec[0],temp); add_v3_v3v3(newbezt->vec[2], bezt->vec[2],temp); @@ -4622,9 +4620,7 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) copy_v3_v3(newbp->vec, bp->vec); } else { - copy_v3_v3(newbp->vec, location); - sub_v3_v3(newbp->vec, obedit->obmat[3]); - mul_m3_v3(imat,newbp->vec); + mul_v3_m4v3(newbp->vec, imat, location); newbp->vec[3]= 1.0; if(!newnu && nu->orderu<4 && nu->orderu<=nu->pntsu) @@ -4666,17 +4662,37 @@ static int add_vertex_exec(bContext *C, wmOperator *op) static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) { RegionView3D *rv3d= CTX_wm_region_view3d(C); - ViewContext vc; - float location[3] = {0.0f, 0.0f, 0.0f}; - short mval[2]; if(rv3d && !RNA_property_is_set(op->ptr, "location")) { + Curve *cu; + ViewContext vc; + float location[3]; + short mval[2]; + + Nurb *nu; + BezTriple *bezt; + BPoint *bp; + view3d_set_viewcontext(C, &vc); + cu= vc.obedit->data; + + findselectedNurbvert(&cu->editnurb->nurbs, &nu, &bezt, &bp); + + if(bezt) { + mul_v3_m4v3(location, vc.obedit->obmat, bezt->vec[1]); + } + else if (bp) { + mul_v3_m4v3(location, vc.obedit->obmat, bp->vec); + } + else { + copy_v3_v3(location, give_cursor(vc.scene, vc.v3d)); + } + mval[0]= event->x - vc.ar->winrct.xmin; mval[1]= event->y - vc.ar->winrct.ymin; - view3d_get_view_aligned_coordinate(&vc, location, mval); + view3d_get_view_aligned_coordinate(&vc, location, mval, TRUE); RNA_float_set_array(op->ptr, "location", location); } @@ -4980,8 +4996,8 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event int a, location[2], deselect; deselect= RNA_boolean_get(op->ptr, "deselect"); - location[0]= event->x - ar->winrct.xmin; - location[1]= event->y - ar->winrct.ymin; + location[0]= event->x - ar->winrct.xmin; + location[1]= event->y - ar->winrct.ymin; view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); @@ -5622,7 +5638,7 @@ static int duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) void CURVE_OT_duplicate(wmOperatorType *ot) { /* identifiers */ - ot->name= "Duplicate"; + ot->name= "Duplicate Curve"; ot->description = "Duplicate selected control points and segments between them"; ot->idname= "CURVE_OT_duplicate"; @@ -6647,7 +6663,7 @@ static int add_primitive_bezier_circle_exec(bContext *C, wmOperator *op) void CURVE_OT_primitive_bezier_circle_add(wmOperatorType *ot) { /* identifiers */ - ot->name= "Add Circle"; + ot->name= "Add Bezier Circle"; ot->description= "Construct a Bezier Circle"; ot->idname= "CURVE_OT_primitive_bezier_circle_add"; diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 88842f36efd..649ff9e953a 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1715,7 +1715,7 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) void FONT_OT_open(wmOperatorType *ot) { /* identifiers */ - ot->name= "Open"; + ot->name= "Open Font"; ot->idname= "FONT_OT_open"; /* api callbacks */ diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 79fcbb0e49d..d95f64c31e1 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -219,9 +219,11 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, con subcol= uiLayoutColumn(col, 1); uiItemR(subcol, &ptr, "use_onion_skinning", 0, "Onion Skinning", ICON_NONE); uiItemR(subcol, &ptr, "ghost_range_max", 0, "Frames", ICON_NONE); // XXX shorter name here? i.e. GStep - - if(is_v3d) { - uiItemR(subcol, &ptr, "show_x_ray", 0, "X-Ray", ICON_NONE); + + /* 3d-view specific drawing options */ + if (is_v3d) { + subcol= uiLayoutColumn(col, 0); + uiItemR(subcol, &ptr, "show_x_ray", 0, "X-Ray", ICON_NONE); } } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 17e7c0c221b..04391d0c531 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -239,7 +239,7 @@ static short gp_stroke_filtermval (tGPsdata *p, int mval[2], int pmval[2]) /* convert screen-coordinates to buffer-coordinates */ // XXX this method needs a total overhaul! -static void gp_stroke_convertcoords (tGPsdata *p, short mval[], float out[], float *depth) +static void gp_stroke_convertcoords (tGPsdata *p, short mval[2], float out[3], float *depth) { bGPdata *gpd= p->gpd; diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h index fcd56277b87..36923736068 100644 --- a/source/blender/editors/include/ED_armature.h +++ b/source/blender/editors/include/ED_armature.h @@ -117,7 +117,7 @@ void ED_armature_deselect_all_visible(struct Object *obedit); int ED_do_pose_selectbuffer(struct Scene *scene, struct Base *base, unsigned int *buffer, short hits, short extend); -int mouse_armature(struct bContext *C, short mval[2], int extend); +int mouse_armature(struct bContext *C, const short mval[2], int extend); int join_armature_exec(struct bContext *C, struct wmOperator *op); struct Bone *get_indexed_bone (struct Object *ob, int index); float ED_rollBoneToVector(EditBone *bone, const float new_up_axis[3], const short axis_only); diff --git a/source/blender/editors/include/ED_curve.h b/source/blender/editors/include/ED_curve.h index 08a63a470c1..cfafd38ed15 100644 --- a/source/blender/editors/include/ED_curve.h +++ b/source/blender/editors/include/ED_curve.h @@ -66,7 +66,7 @@ void free_editNurb (struct Object *obedit); void free_curve_editNurb (struct Curve *cu); -int mouse_nurb (struct bContext *C, short mval[2], int extend); +int mouse_nurb (struct bContext *C, const short mval[2], int extend); struct Nurb *add_nurbs_primitive(struct bContext *C, float mat[4][4], int type, int newob); diff --git a/source/blender/editors/include/ED_mball.h b/source/blender/editors/include/ED_mball.h index 504cc4e2d52..a742be7337c 100644 --- a/source/blender/editors/include/ED_mball.h +++ b/source/blender/editors/include/ED_mball.h @@ -42,7 +42,7 @@ void ED_keymap_metaball(struct wmKeyConfig *keyconf); struct MetaElem *add_metaball_primitive(struct bContext *C, float mat[4][4], int type, int newname); -int mouse_mball(struct bContext *C, short mval[2], int extend); +int mouse_mball(struct bContext *C, const short mval[2], int extend); void free_editMball(struct Object *obedit); void make_editMball(struct Object *obedit); diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index 054e46971b5..c3c843154e5 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -169,7 +169,7 @@ void EM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct Object extern unsigned int em_vertoffs, em_solidoffs, em_wireoffs; void EM_cache_x_mirror_vert(struct Object *ob, struct EditMesh *em); -int mouse_mesh(struct bContext *C, short mval[2], short extend); +int mouse_mesh(struct bContext *C, const short mval[2], short extend); int EM_check_backbuf(unsigned int index); int EM_mask_init_backbuf_border(struct ViewContext *vc, short mcords[][2], short tot, short xmin, short ymin, short xmax, short ymax); void EM_free_backbuf(void); @@ -187,7 +187,7 @@ void EM_automerge(struct Scene *scene, struct Object *obedit, int update); /* editface.c */ void paintface_flush_flags(struct Object *ob); struct MTFace *EM_get_active_mtface(struct EditMesh *em, struct EditFace **act_efa, struct MCol **mcol, int sloppy); -int paintface_mouse_select(struct bContext *C, struct Object *ob, short mval[2], int extend); +int paintface_mouse_select(struct bContext *C, struct Object *ob, const short mval[2], int extend); int do_paintface_box_select(struct ViewContext *vc, struct rcti *rect, int select, int extend); void paintface_deselect_all_visible(struct Object *ob, int action, short flush_flags); void paintface_select_linked(struct bContext *C, struct Object *ob, short mval[2], int mode); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index ce6a9d609db..3b27fb45f5d 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -126,7 +126,7 @@ void ED_object_constraint_update(struct Object *ob); void ED_object_constraint_dependency_update(struct Main *bmain, struct Scene *scene, struct Object *ob); /* object_lattice.c */ -int mouse_lattice(struct bContext *C, short mval[2], int extend); +int mouse_lattice(struct bContext *C, const short mval[2], int extend); void undo_push_lattice(struct bContext *C, const char *name); /* object_lattice.c */ diff --git a/source/blender/editors/include/ED_particle.h b/source/blender/editors/include/ED_particle.h index 7b4a2e6fe16..f29284fe64d 100644 --- a/source/blender/editors/include/ED_particle.h +++ b/source/blender/editors/include/ED_particle.h @@ -60,9 +60,9 @@ void PE_hide_keys_time(struct Scene *scene, struct PTCacheEdit *edit, float cfra void PE_update_object(struct Scene *scene, struct Object *ob, int useflag); /* selection tools */ -int PE_mouse_particles(struct bContext *C, short *mval, int extend); +int PE_mouse_particles(struct bContext *C, const short mval[2], int extend); int PE_border_select(struct bContext *C, struct rcti *rect, int select, int extend); -int PE_circle_select(struct bContext *C, int selecting, short *mval, float rad); +int PE_circle_select(struct bContext *C, int selecting, const short mval[2], float rad); int PE_lasso_select(struct bContext *C, short mcords[][2], short moves, short extend, short select); void PE_deselect_all_visible(struct PTCacheEdit *edit); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index c741c41ff5e..a3e99e6358e 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -80,9 +80,9 @@ typedef struct ViewDepths { float *give_cursor(struct Scene *scene, struct View3D *v3d); int initgrabz(struct RegionView3D *rv3d, float x, float y, float z); -void window_to_3d(struct ARegion *ar, float *vec, short mx, short my); -void window_to_3d_delta(struct ARegion *ar, float *vec, short mx, short my); -void window_to_3d_vector(struct ARegion *ar, float *vec, short mx, short my); +void window_to_3d(struct ARegion *ar, float out[3], short mx, short my); +void window_to_3d_delta(struct ARegion *ar, float out[3], short mx, short my); +void window_to_3d_vector(struct ARegion *ar, float out[3], short mx, short my); void view3d_unproject(struct bglMats *mats, float out[3], const short x, const short y, const float z); /* Depth buffer */ @@ -95,14 +95,14 @@ void request_depth_update(struct RegionView3D *rv3d); void view3d_calculate_clipping(struct BoundBox *bb, float planes[4][4], struct bglMats *mats, struct rcti *rect); -void project_short(struct ARegion *ar, float *vec, short *adr); -void project_short_noclip(struct ARegion *ar, float *vec, short *adr); +void project_short(struct ARegion *ar, const float vec[3], short adr[2]); +void project_short_noclip(struct ARegion *ar, const float vec[3], short adr[2]); -void project_int(struct ARegion *ar, float *vec, int *adr); -void project_int_noclip(struct ARegion *ar, float *vec, int *adr); +void project_int(struct ARegion *ar, const float vec[3], int adr[2]); +void project_int_noclip(struct ARegion *ar, const float vec[3], int adr[2]); -void project_float(struct ARegion *ar, float *vec, float *adr); -void project_float_noclip(struct ARegion *ar, float *vec, float *adr); +void project_float(struct ARegion *ar, const float vec[3], float adr[2]); +void project_float_noclip(struct ARegion *ar, const float vec[3], float adr[2]); void viewvector(struct RegionView3D *rv3d, float coord[3], float vec[3]); @@ -113,7 +113,7 @@ int get_view3d_cliprange(struct View3D *v3d, struct RegionView3D *rv3d, float *c int get_view3d_viewplane(struct View3D *v3d, struct RegionView3D *rv3d, int winxi, int winyi, struct rctf *viewplane, float *clipsta, float *clipend, float *pixsize); int get_view3d_ortho(struct View3D *v3d, struct RegionView3D *rv3d); void view3d_get_object_project_mat(struct RegionView3D *v3d, struct Object *ob, float pmat[4][4]); -void view3d_project_float(struct ARegion *a, float *vec, float *adr, float mat[4][4]); +void view3d_project_float(struct ARegion *a, const float vec[3], float adr[2], float mat[4][4]); void view3d_calc_camera_border(struct Scene *scene, struct ARegion *ar, struct RegionView3D *rv3d, struct View3D *v3d, struct rctf *viewborder_r, short do_shift); /* drawobject.c iterators */ @@ -124,7 +124,7 @@ void nurbs_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData void lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BPoint *bp, int x, int y), void *userData); void ED_view3d_local_clipping(struct RegionView3D *rv3d, float mat[][4]); -int view3d_test_clipping(struct RegionView3D *rv3d, float *vec, int local); +int view3d_test_clipping(struct RegionView3D *rv3d, const float vec[3], const int local); void view3d_align_axis_to_vector(struct View3D *v3d, struct RegionView3D *rv3d, int axisidx, float vec[3]); float view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]); @@ -133,18 +133,18 @@ void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]); /* backbuffer select and draw support */ void view3d_validate_backbuf(struct ViewContext *vc); struct ImBuf *view3d_read_backbuf(struct ViewContext *vc, short xmin, short ymin, short xmax, short ymax); -unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, short mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, +unsigned int view3d_sample_backbuf_rect(struct ViewContext *vc, const short mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, void *handle, unsigned int (*indextest)(void *handle, unsigned int index)); unsigned int view3d_sample_backbuf(struct ViewContext *vc, int x, int y); /* draws and does a 4x4 sample */ -int view_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, short *mval, float mouse_worldloc[3]); +int view_autodist(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, const short mval[2], float mouse_worldloc[3]); /* only draw so view_autodist_simple can be called many times after */ int view_autodist_init(struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode); -int view_autodist_simple(struct ARegion *ar, short mval[2], float mouse_worldloc[3], int margin, float *force_depth); -int view_autodist_depth(struct ARegion *ar, short mval[2], int margin, float *depth); -int view_autodist_depth_segment(struct ARegion *ar, short mval_sta[2], short mval_end[2], int margin, float *depth); +int view_autodist_simple(struct ARegion *ar, const short mval[2], float mouse_worldloc[3], int margin, float *force_depth); +int view_autodist_depth(struct ARegion *ar, const short mval[2], int margin, float *depth); +int view_autodist_depth_segment(struct ARegion *ar, const short mval_sta[2], const short mval_end[2], int margin, float *depth); /* select */ #define MAXPICKBUF 10000 @@ -153,7 +153,7 @@ short view3d_opengl_select(struct ViewContext *vc, unsigned int *buffer, unsigne void view3d_set_viewcontext(struct bContext *C, struct ViewContext *vc); void view3d_operator_needs_opengl(const struct bContext *C); void view3d_region_operator_needs_opengl(struct wmWindow *win, struct ARegion *ar); -void view3d_get_view_aligned_coordinate(struct ViewContext *vc, float *fp, short mval[2]); +int view3d_get_view_aligned_coordinate(struct ViewContext *vc, float fp[3], const short mval[2], const short do_fallback); void view3d_get_transformation(struct ARegion *ar, struct RegionView3D *rv3d, struct Object *ob, struct bglMats *mats); /* XXX should move to BLI_math */ @@ -176,7 +176,7 @@ struct ImBuf *ED_view3d_draw_offscreen_imbuf(struct Scene *scene, struct View3D struct ImBuf *ED_view3d_draw_offscreen_imbuf_simple(Scene *scene, int width, int height, unsigned int flag, int drawtype, char err_out[256]); -Base *ED_view3d_give_base_under_cursor(struct bContext *C, short *mval); +Base *ED_view3d_give_base_under_cursor(struct bContext *C, const short mval[2]); void ED_view3d_quadview_update(struct ScrArea *sa, struct ARegion *ar, short do_clip); int ED_view3d_lock(struct RegionView3D *rv3d); diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 5b59baf9ea2..108f06a5cb6 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -370,7 +370,7 @@ static void ui_popup_bounds_block(const bContext *C, uiBlock *block, int bounds_ /* and we adjust the position to fit within window */ width= block->maxx - block->minx; height= block->maxy - block->miny; - + /* avoid divide by zero below, caused by calling with no UI, but better not crash */ oldwidth= oldwidth > 0 ? oldwidth : MAX2(1, width); oldheight= oldheight > 0 ? oldheight : MAX2(1, height); @@ -1284,7 +1284,7 @@ double ui_get_but_val(uiBut *but) else if( but->pointype == FLO ) { value= *(float *)but->poin; } - + return value; } @@ -1390,7 +1390,7 @@ int ui_get_but_string_max_length(uiBut *but) if(ELEM(but->type, TEX, SEARCH_MENU)) return but->hardmax; else if(but->type == IDPOIN) - return sizeof(((ID*)NULL)->name)-2; + return MAX_ID_NAME-2; else return UI_MAX_DRAW_STR; } @@ -1541,6 +1541,52 @@ void ui_get_but_string(uiBut *but, char *str, int maxlen) } } +#ifdef WITH_PYTHON + +static int ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char *str, double *value) +{ + char str_unit_convert[256]; + const int unit_type= uiButGetUnitType(but); + Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); + + BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert)); + + /* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */ + bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type>>16); + + return (BPY_button_exec(C, str_unit_convert, value, TRUE) != -1); +} + +static int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double *value) +{ + int ok= FALSE; + + if(str[0] != '\0') { + int is_unit_but= ui_is_but_unit(but); + /* only enable verbose if we won't run again with units */ + if(BPY_button_exec(C, str, value, is_unit_but==FALSE) != -1) { + /* if the value parsed ok without unit conversion this button may still need a unit multiplier */ + if(is_unit_but) { + char str_new[128]; + + BLI_snprintf(str_new, sizeof(str_new), "%f", *value); + ok= ui_set_but_string_eval_num_unit(C, but, str_new, value); + } + else { + ok= TRUE; /* parse normal string via py (no unit conversion needed) */ + } + } + else if(is_unit_but) { + /* parse failed, this is a unit but so run replacements and parse again */ + ok= ui_set_but_string_eval_num_unit(C, but, str, value); + } + } + + return ok; +} + +#endif // WITH_PYTHON + int ui_set_but_string(bContext *C, uiBut *but, const char *str) { if(but->rnaprop && ELEM3(but->type, TEX, IDPOIN, SEARCH_MENU)) { @@ -1601,32 +1647,7 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) double value; #ifdef WITH_PYTHON - int ok= FALSE; - - if(str[0] != '\0') { - int is_unit_but= ui_is_but_unit(but); - /* only enable verbose if we won't run again with units */ - if(BPY_button_exec(C, str, &value, is_unit_but==FALSE) != -1) { - ok= TRUE; /* parse normal string via py (no unit conversion needed) */ - } - else if(is_unit_but) { - /* parse failed, this is a unit but so run replacements and parse again */ - char str_unit_convert[256]; - const int unit_type= uiButGetUnitType(but); - Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); - - BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert)); - - /* ugly, use the draw string to get the value, this could cause problems if it includes some text which resolves to a unit */ - bUnit_ReplaceString(str_unit_convert, sizeof(str_unit_convert), but->drawstr, ui_get_but_scale_unit(but, 1.0), scene->unit.system, unit_type>>16); - - if(BPY_button_exec(C, str_unit_convert, &value, TRUE) != -1) { - ok= TRUE; - } - } - } - - if(ok == FALSE) { + if(ui_set_but_string_eval_num(C, but, str, &value) == FALSE) { return 0; } #else @@ -2072,6 +2093,8 @@ void ui_check_but(uiBut *but) str= strcat(str, "Alt "); if(but->modifier_key & KM_OSKEY) str= strcat(str, "Cmd "); + + (void)str; /* UNUSED */ } else strcat(but->drawstr, "Press a key "); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index d3aa5bc9132..cf11effc57b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4898,7 +4898,7 @@ static void button_activate_state(bContext *C, uiBut *but, uiHandleButtonState s } else { if(button_modal_state(data->state)) - WM_event_remove_ui_handler(&data->window->modalhandlers, ui_handler_region_menu, NULL, data); + WM_event_remove_ui_handler(&data->window->modalhandlers, ui_handler_region_menu, NULL, data, 1); /* 1 = postpone free */ } } @@ -6154,7 +6154,7 @@ static void ui_handler_remove_popup(bContext *C, void *userdata) void UI_add_region_handlers(ListBase *handlers) { - WM_event_remove_ui_handler(handlers, ui_handler_region, ui_handler_remove_region, NULL); + WM_event_remove_ui_handler(handlers, ui_handler_region, ui_handler_remove_region, NULL, 0); WM_event_add_ui_handler(NULL, handlers, ui_handler_region, ui_handler_remove_region, NULL); } @@ -6165,7 +6165,7 @@ void UI_add_popup_handlers(bContext *C, ListBase *handlers, uiPopupBlockHandle * void UI_remove_popup_handlers(ListBase *handlers, uiPopupBlockHandle *popup) { - WM_event_remove_ui_handler(handlers, ui_handler_popup, ui_handler_remove_popup, popup); + WM_event_remove_ui_handler(handlers, ui_handler_popup, ui_handler_remove_popup, popup, 0); } diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index a208eee1649..7dc27805b40 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1196,10 +1196,10 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s #endif name= BLI_strdup(name_ui); iconid= ui_id_icon_get((bContext*)C, id, 1); - } + } else { name= RNA_struct_name_get_alloc(&itemptr, NULL, 0); - iconid = 0; + iconid = 0; } if(name) { diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index b47194ba1b4..6677f2b1bae 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1211,7 +1211,7 @@ static void panel_activate_state(const bContext *C, Panel *pa, uiHandlePanelStat MEM_freeN(data); pa->activedata= NULL; - WM_event_remove_ui_handler(&win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa); + WM_event_remove_ui_handler(&win->modalhandlers, ui_handler_panel, ui_handler_remove_panel, pa, 0); } else { if(!data) { diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 4457ec6b323..1a240f34757 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2326,6 +2326,7 @@ static void confirm_operator(bContext *C, wmOperator *op, const char *title, con s= buf; if (title) s+= sprintf(s, "%s%%t|%s", title, item); + (void)s; handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf); diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index f22c8eb4bfe..1ec125c2f26 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -52,7 +52,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind { uiBut *but=NULL; const char *propname= RNA_property_identifier(prop); - char prop_item[sizeof(((IDProperty *)NULL)->name)+4]; /* size of the ID prop name + room for [""] */ + char prop_item[MAX_IDPROP_NAME+4]; /* size of the ID prop name + room for [""] */ int arraylen= RNA_property_array_length(ptr, prop); /* support for custom props */ diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index fc29a18154a..90a83009c4d 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1171,13 +1171,13 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB /* uiWidgetStateColors - char inner_anim[4]; - char inner_anim_sel[4]; - char inner_key[4]; - char inner_key_sel[4]; - char inner_driven[4]; - char inner_driven_sel[4]; - float blend; + char inner_anim[4]; + char inner_anim_sel[4]; + char inner_key[4]; + char inner_key_sel[4]; + char inner_driven[4]; + char inner_driven_sel[4]; + float blend; */ @@ -1192,15 +1192,15 @@ static struct uiWidgetStateColors wcol_state_colors= { }; /* uiWidgetColors - float outline[3]; - float inner[4]; - float inner_sel[4]; - float item[3]; - float text[3]; - float text_sel[3]; - - short shaded; - float shadetop, shadedown; + float outline[3]; + float inner[4]; + float inner_sel[4]; + float item[3]; + float text[3]; + float text_sel[3]; + + short shaded; + float shadetop, shadedown; */ static struct uiWidgetColors wcol_num= { diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 123f9e2044f..62b191c2c6e 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1048,7 +1048,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) static void VIEW2D_OT_zoom(wmOperatorType *ot) { /* identifiers */ - ot->name= "Zoom View"; + ot->name= "Zoom 2D View"; ot->description= "Zoom in/out the view"; ot->idname= "VIEW2D_OT_zoom"; diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index af3716b4677..9cec034af28 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -98,7 +98,7 @@ void paintface_flush_flags(Object *ob) } /* returns 0 if not found, otherwise 1 */ -static int facesel_face_pick(struct bContext *C, Mesh *me, short *mval, unsigned int *index, short rect) +static int facesel_face_pick(struct bContext *C, Mesh *me, const short mval[2], unsigned int *index, short rect) { ViewContext vc; view3d_set_viewcontext(C, &vc); @@ -716,7 +716,7 @@ void seam_mark_clear_tface(Scene *scene, short mode) } #endif -int paintface_mouse_select(struct bContext *C, Object *ob, short mval[2], int extend) +int paintface_mouse_select(struct bContext *C, Object *ob, const short mval[2], int extend) { Mesh *me; MFace *mface, *msel; diff --git a/source/blender/editors/mesh/editmesh.c b/source/blender/editors/mesh/editmesh.c index 0165b9794ca..ec08bfccda3 100644 --- a/source/blender/editors/mesh/editmesh.c +++ b/source/blender/editors/mesh/editmesh.c @@ -1177,13 +1177,14 @@ void load_editMesh(Scene *scene, Object *obedit) } if(act_is_basis) { /* active key is a base */ + float (*fp)[3]= actkey->data; i=0; ofs= MEM_callocN(sizeof(float) * 3 * em->totvert, "currkey->data"); eve= em->verts.first; mvert = me->mvert; while(eve) { if(eve->keyindex>=0) - VECSUB(ofs[i], mvert->co, oldverts[eve->keyindex].co); + VECSUB(ofs[i], mvert->co, fp[eve->keyindex]); eve= eve->next; i++; diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index ec84d7f830f..b3492a5fb09 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -139,7 +139,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) /* call extrude? */ if(done) { - short rot_src= RNA_boolean_get(op->ptr, "rotate_source"); + const short rot_src= RNA_boolean_get(op->ptr, "rotate_source"); EditEdge *eed; float vec[3], cent[3], mat[3][3]; float nor[3]= {0.0, 0.0, 0.0}; @@ -198,7 +198,7 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) copy_v3_v3(min, cent); mul_m4_v3(vc.obedit->obmat, min); // view space - view3d_get_view_aligned_coordinate(&vc, min, event->mval); + view3d_get_view_aligned_coordinate(&vc, min, event->mval, TRUE); mul_m4_v3(vc.obedit->imat, min); // back in object space sub_v3_v3(min, cent); @@ -246,20 +246,16 @@ static int dupli_extrude_cursor(bContext *C, wmOperator *op, wmEvent *event) } else if(vc.em->selectmode & SCE_SELECT_VERTEX) { - float mat[3][3],imat[3][3]; - float *curs= give_cursor(vc.scene, vc.v3d); + float imat[4][4]; + const float *curs= give_cursor(vc.scene, vc.v3d); copy_v3_v3(min, curs); - view3d_get_view_aligned_coordinate(&vc, min, event->mval); - + view3d_get_view_aligned_coordinate(&vc, min, event->mval, TRUE); + eve= addvertlist(vc.em, 0, NULL); - copy_m3_m4(mat, vc.obedit->obmat); - invert_m3_m3(imat, mat); - - copy_v3_v3(eve->co, min); - mul_m3_v3(imat, eve->co); - sub_v3_v3v3(eve->co, eve->co, vc.obedit->obmat[3]); + invert_m4_m4(imat, vc.obedit->obmat); + mul_v3_m4v3(eve->co, imat, min); eve->f= SELECT; } @@ -1758,7 +1754,7 @@ static int mesh_duplicate_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev void MESH_OT_duplicate(wmOperatorType *ot) { /* identifiers */ - ot->name= "Duplicate"; + ot->name= "Duplicate Mesh"; ot->description= "Duplicate selected vertices, edges or faces"; ot->idname= "MESH_OT_duplicate"; diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index a5042f1d6d8..1ae6fb0bd98 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -140,8 +140,7 @@ void EM_automerge(Scene *scene, Object *obedit, int update) int len; if ((scene->toolsettings->automerge) && - (obedit && obedit->type==OB_MESH && (obedit->mode & OB_MODE_EDIT)) && - (me->mr==NULL) + (obedit && obedit->type==OB_MESH && (obedit->mode & OB_MODE_EDIT)) ) { EditMesh *em= me->edit_mesh; @@ -2062,7 +2061,7 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot) /* ***************** loop select (non modal) ************** */ -static void mouse_mesh_loop(bContext *C, short mval[2], short extend, short ring) +static void mouse_mesh_loop(bContext *C, const short mval[2], short extend, short ring) { ViewContext vc; EditMesh *em; @@ -2150,7 +2149,7 @@ void MESH_OT_loop_select(wmOperatorType *ot) /* ******************* mesh shortest path select, uses prev-selected edge ****************** */ /* since you want to create paths with multiple selects, it doesn't have extend option */ -static void mouse_mesh_shortest_path(bContext *C, short mval[2]) +static void mouse_mesh_shortest_path(bContext *C, const short mval[2]) { ViewContext vc; EditMesh *em; @@ -2283,7 +2282,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot) /* here actual select happens */ /* gets called via generic mouse select operator */ -int mouse_mesh(bContext *C, short mval[2], short extend) +int mouse_mesh(bContext *C, const short mval[2], short extend) { ViewContext vc; EditVert *eve; @@ -2452,7 +2451,7 @@ static int select_linked_limited_invoke(ViewContext *vc, short all, short sel) if (!change) return OPERATOR_CANCELLED; - if (!sel) /* make sure de-selecting faces didnt de-select the verts/edges connected to selected faces, this is common with boundries */ + if (!sel) /* make sure de-selecting faces didnt de-select the verts/edges connected to selected faces, this is common with boundaries */ for(efa= em->faces.first; efa; efa= efa->next) if (efa->f & SELECT) EM_select_face(efa, 1); @@ -2582,7 +2581,7 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", ""); - RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", "Limit selection by seam boundries (faces only)"); + RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", "Limit selection by seam boundaries (faces only)"); } @@ -2671,7 +2670,7 @@ void MESH_OT_select_linked(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", "Limit selection by seam boundries (faces only)"); + RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", "Limit selection by seam boundaries (faces only)"); } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 4741f3c7723..5901a36980c 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2755,7 +2755,7 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float // Beauty Long Edges else { - for(j=0;j<2;j++) { + for(j=0;j<2;j++) { hold = -1; for(i=0;i<4;i++) { if(length[i] < 0) { @@ -2969,8 +2969,8 @@ void esubdivideflag(Object *obedit, EditMesh *em, int flag, float smooth, float } } } - if(em->selectmode & SCE_SELECT_VERTEX) { - for(eed = em->edges.first;eed;eed = eed->next) { + if(em->selectmode & SCE_SELECT_VERTEX) { + for(eed = em->edges.first;eed;eed = eed->next) { if(eed->f & SELECT) { eed->v1->f |= SELECT; eed->v2->f |= SELECT; @@ -3643,7 +3643,7 @@ static void edge_rotate(EditMesh *em, wmOperator *op, EditEdge *eed, int dir) return; /* how many edges does each face have */ - if(face[0]->e4) fac1= 4; + if(face[0]->e4) fac1= 4; else fac1= 3; if(face[1]->e4) fac2= 4; @@ -4061,8 +4061,8 @@ useless: } // Make sure loop is not 2 edges of same face if(ct > 1) { - BKE_report(op->reports, RPT_ERROR, "Loop crosses itself"); - return 0; + BKE_report(op->reports, RPT_ERROR, "Loop crosses itself"); + return 0; } } // Get # of selected verts @@ -4179,11 +4179,11 @@ useless: for(eed=em->edges.first;eed;eed=eed->next) { if(editedge_containsVert(eed, ev)) { if(!(eed->f & SELECT)) { - if(!tempsv->up) { - tempsv->up = eed; - } else if (!(tempsv->down)) { - tempsv->down = eed; - } + if(!tempsv->up) { + tempsv->up = eed; + } else if (!(tempsv->down)) { + tempsv->down = eed; + } } } } @@ -4195,33 +4195,33 @@ useless: for(efa = em->faces.first;efa;efa=efa->next) { if(editface_containsEdge(efa, eed)) { if(editedge_containsVert(efa->e1, ev) && efa->e1 != eed) { - if(!tempsv->up) { - tempsv->up = efa->e1; - } else if (!(tempsv->down)) { - tempsv->down = efa->e1; - } + if(!tempsv->up) { + tempsv->up = efa->e1; + } else if (!(tempsv->down)) { + tempsv->down = efa->e1; + } } if(editedge_containsVert(efa->e2, ev) && efa->e2 != eed) { - if(!tempsv->up) { - tempsv->up = efa->e2; - } else if (!(tempsv->down)) { - tempsv->down = efa->e2; - } + if(!tempsv->up) { + tempsv->up = efa->e2; + } else if (!(tempsv->down)) { + tempsv->down = efa->e2; + } } if(editedge_containsVert(efa->e3, ev) && efa->e3 != eed) { - if(!tempsv->up) { - tempsv->up = efa->e3; - } else if (!(tempsv->down)) { - tempsv->down = efa->e3; - } + if(!tempsv->up) { + tempsv->up = efa->e3; + } else if (!(tempsv->down)) { + tempsv->down = efa->e3; + } } if(efa->e4) { if(editedge_containsVert(efa->e4, ev) && efa->e4 != eed) { - if(!tempsv->up) { - tempsv->up = efa->e4; - } else if (!(tempsv->down)) { - tempsv->down = efa->e4; - } + if(!tempsv->up) { + tempsv->up = efa->e4; + } else if (!(tempsv->down)) { + tempsv->down = efa->e4; + } } } @@ -4665,7 +4665,7 @@ useless: mvalo[0] = -1; } else if(ELEM(event, RIGHTARROWKEY, WHEELUPMOUSE)) { // Scroll through Control Edges look = vertlist; - while(look) { + while(look) { if(nearest == (EditVert*)look->link) { if(look->next == NULL) { nearest = (EditVert*)vertlist->link; @@ -4679,7 +4679,7 @@ useless: } } else if(ELEM(event, LEFTARROWKEY, WHEELDOWNMOUSE)) { // Scroll through Control Edges look = vertlist; - while(look) { + while(look) { if(look->next) { if(look->next->link == nearest) { nearest = (EditVert*)look->link; @@ -4817,7 +4817,7 @@ void mesh_set_face_flags(EditMesh *em, short mode) add_numbut(12, TOG|SHO, "Sort", 0, 0, &m_sort, NULL); if (!do_clever_numbuts((mode ? "Set Flags" : "Clear Flags"), 13, REDRAW)) - return; + return; /* these 2 cant both be on */ if (mode) /* are we seeting*/ @@ -4857,7 +4857,7 @@ void mesh_set_face_flags(EditMesh *em, short mode) /********************** Rip Operator *************************/ /* helper to find edge for edge_rip */ -static float mesh_rip_edgedist(ARegion *ar, float mat[][4], float *co1, float *co2, short *mval) +static float mesh_rip_edgedist(ARegion *ar, float mat[][4], float *co1, float *co2, const short mval[2]) { float vec1[3], vec2[3], mvalf[2]; @@ -5414,7 +5414,7 @@ static void freecollections(ListBase *allcollections) /*Begin UV Edge Collapse Code Like Edge subdivide, Edge Collapse should handle UV's intelligently, but since UV's are a per-face attribute, normal edge collapse will fail - in areas such as the boundries of 'UV islands'. So for each edge collection we need to build a set of 'welded' UV vertices and edges for it. + in areas such as the boundaries of 'UV islands'. So for each edge collection we need to build a set of 'welded' UV vertices and edges for it. The welded UV edges can then be sorted and collapsed. */ typedef struct wUV{ diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 1c10128cee8..d95c71b68ba 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -229,6 +229,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) { wmKeyMap *keymap; wmKeyMapItem *kmi; + int i; keymap= WM_keymap_find(keyconf, "Mesh", 0, 0); keymap->poll= ED_operator_editmesh; @@ -322,6 +323,12 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) WM_keymap_add_menu(keymap, "VIEW3D_MT_uv_map", UKEY, KM_PRESS, 0, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0); + /* useful stuff from object-mode */ + for (i=0; i<=5; i++) { + kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0); + RNA_int_set(kmi->ptr, "level", i); + } + ED_object_generic_keymap(keyconf, keymap, 3); } diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index d47e02dc63c..b67f9d6de29 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -314,7 +314,7 @@ static int duplicate_metaelems_invoke(bContext *C, wmOperator *op, wmEvent *UNUS void MBALL_OT_duplicate_metaelems(wmOperatorType *ot) { /* identifiers */ - ot->name= "Duplicate"; + ot->name= "Duplicate Metaelements"; ot->description= "Delete selected metaelement(s)"; ot->idname= "MBALL_OT_duplicate_metaelems"; @@ -455,7 +455,7 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot) /* Select MetaElement with mouse click (user can select radius circle or * stiffness circle) */ -int mouse_mball(bContext *C, short mval[2], int extend) +int mouse_mball(bContext *C, const short mval[2], int extend) { static MetaElem *startelem=NULL; Object *obedit= CTX_data_edit_object(C); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 39e3f47eb6e..c425ef5a36a 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1704,7 +1704,7 @@ void OBJECT_OT_duplicate(wmOperatorType *ot) PropertyRNA *prop; /* identifiers */ - ot->name= "Duplicate"; + ot->name= "Duplicate Objects"; ot->description = "Duplicate selected objects"; ot->idname= "OBJECT_OT_duplicate"; diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index b4a358150e8..b513bab3924 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -189,9 +189,18 @@ static void finish_bake_internal(BakeRender *bkr) for(ima= G.main->image.first; ima; ima= ima->id.next) { if(ima->ok==IMA_OK_LOADED) { ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); - if(ibuf && (ibuf->userflags & IB_BITMAPDIRTY)) { - GPU_free_image(ima); - imb_freemipmapImBuf(ibuf); + if(ibuf) { + if(ibuf->userflags & IB_BITMAPDIRTY) { + GPU_free_image(ima); + imb_freemipmapImBuf(ibuf); + } + + /* freed when baking is done, but if its canceled we need to free here */ + if (ibuf->userdata) { + printf("freed\n"); + MEM_freeN(ibuf->userdata); + ibuf->userdata= NULL; + } } } } diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 1fa17c34dd0..b1ab68ff087 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -238,8 +238,8 @@ static int group_add_exec(bContext *C, wmOperator *UNUSED(op)) if(ob == NULL) return OPERATOR_CANCELLED; - group= add_group("Group"); - add_to_group(group, ob, scene, NULL); + group= add_group("Group"); + add_to_group(group, ob, scene, NULL); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -264,12 +264,12 @@ static int group_link_exec(bContext *C, wmOperator *op) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; - Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group")); + Group *group= BLI_findlink(&CTX_data_main(C)->group, RNA_enum_get(op->ptr, "group")); if(ELEM(NULL, ob, group)) return OPERATOR_CANCELLED; - add_to_group(group, ob, scene, NULL); + add_to_group(group, ob, scene, NULL); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 72bf3b52b74..198c8cab7fa 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -318,7 +318,7 @@ static void findnearestLattvert__doClosest(void *userData, BPoint *bp, int x, in } } -static BPoint *findnearestLattvert(ViewContext *vc, short mval[2], int sel) +static BPoint *findnearestLattvert(ViewContext *vc, const short mval[2], int sel) { /* sel==1: selected gets a disadvantage */ /* in nurb and bezt or bp the nearest is written */ @@ -336,7 +336,7 @@ static BPoint *findnearestLattvert(ViewContext *vc, short mval[2], int sel) return data.bp; } -int mouse_lattice(bContext *C, short mval[2], int extend) +int mouse_lattice(bContext *C, const short mval[2], int extend) { ViewContext vc; BPoint *bp= NULL; diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 197634941f8..04152369a7e 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -220,7 +220,7 @@ void ED_operatormacros_object(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + ot= WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", OPTYPE_UNDO|OPTYPE_REGISTER); if(ot) { WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); otmacro= WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 1aa6de18bad..086d458f3e0 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -402,7 +402,7 @@ void OBJECT_OT_proxy_make (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - RNA_def_string(ot->srna, "object", "", 19, "Proxy Object", "Name of lib-linked/grouped object to make a proxy for."); + RNA_def_string(ot->srna, "object", "", MAX_ID_NAME-2, "Proxy Object", "Name of lib-linked/grouped object to make a proxy for."); prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Type", "Group object"); /* XXX, relies on hard coded ID at the moment */ RNA_def_enum_funcs(prop, proxy_group_object_itemf); ot->prop= prop; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index e6bb65b1a84..04600080eb8 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -54,6 +54,7 @@ #include "BKE_object.h" #include "BKE_report.h" #include "BKE_multires.h" +#include "BKE_armature.h" #include "RNA_define.h" #include "RNA_access.h" @@ -389,13 +390,6 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - bArmature *arm; - Mesh *me; - Curve *cu; - Nurb *nu; - BPoint *bp; - BezTriple *bezt; - MVert *mvert; float rsmat[3][3], tmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale; int a, change = 0; @@ -403,28 +397,27 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { if(ob->type==OB_MESH) { - me= ob->data; - - if(ID_REAL_USERS(me) > 1) { + if(ID_REAL_USERS(ob->data) > 1) { BKE_report(reports, RPT_ERROR, "Can't apply to a multi user mesh, doing nothing."); return OPERATOR_CANCELLED; } } else if(ob->type==OB_ARMATURE) { - arm= ob->data; - - if(ID_REAL_USERS(arm) > 1) { + if(ID_REAL_USERS(ob->data) > 1) { BKE_report(reports, RPT_ERROR, "Can't apply to a multi user armature, doing nothing."); return OPERATOR_CANCELLED; } } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { - cu= ob->data; - - if(ID_REAL_USERS(cu) > 1) { + Curve *cu; + + if(ID_REAL_USERS(ob->data) > 1) { BKE_report(reports, RPT_ERROR, "Can't apply to a multi user curve, doing nothing."); return OPERATOR_CANCELLED; } + + cu= ob->data; + if(!(cu->flag & CU_3D) && (apply_rot || apply_loc)) { BKE_report(reports, RPT_ERROR, "Neither rotation nor location could be applied to a 2d curve, doing nothing."); return OPERATOR_CANCELLED; @@ -477,8 +470,9 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo /* apply to object data */ if(ob->type==OB_MESH) { - me= ob->data; - + Mesh *me= ob->data; + MVert *mvert; + multiresModifier_scale_disp(scene, ob); /* adjust data */ @@ -504,7 +498,11 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo ED_armature_apply_transform(ob, mat); } else if(ELEM(ob->type, OB_CURVE, OB_SURF)) { - cu= ob->data; + Curve *cu= ob->data; + + Nurb *nu; + BPoint *bp; + BezTriple *bezt; scale = mat3_to_scale(rsmat); @@ -539,6 +537,10 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo } where_is_object(scene, ob); + if(ob->type==OB_ARMATURE) { + where_is_pose(scene, ob); /* needed for bone parents */ + } + ignore_parent_tx(bmain, scene, ob); DAG_id_tag_update(&ob->id, OB_RECALC_OB|OB_RECALC_DATA); @@ -864,6 +866,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) /* do_inverse_offset= TRUE; */ /* docenter_armature() handles this */ where_is_object(scene, ob); + where_is_pose(scene, ob); /* needed for bone parents */ + ignore_parent_tx(bmain, scene, ob); if(obedit) @@ -880,6 +884,10 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) add_v3_v3(ob->loc, centn); where_is_object(scene, ob); + if(ob->type==OB_ARMATURE) { + where_is_pose(scene, ob); /* needed for bone parents */ + } + ignore_parent_tx(bmain, scene, ob); /* other users? */ @@ -896,6 +904,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) add_v3_v3(ob_other->loc, centn); where_is_object(scene, ob_other); + if(ob_other->type==OB_ARMATURE) { + where_is_pose(scene, ob_other); /* needed for bone parents */ + } ignore_parent_tx(bmain, scene, ob_other); } } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 76c917291a8..53562caf1b5 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -348,7 +348,7 @@ static void ED_vgroup_nr_vert_remove(Object *ob, int def_nr, int vertnum) */ if(dvert->dw[i].def_nr == def_nr) { dvert->totweight--; - + /* if there are still other deform weights * attached to this vert then remove this * deform weight, and reshuffle the others @@ -457,10 +457,10 @@ static void ED_vgroup_nr_vert_add(Object *ob, int def_nr, int vertnum, float wei MEM_freeN(dv->dw); } dv->dw=newdw; - + dv->dw[dv->totweight].weight=weight; dv->dw[dv->totweight].def_nr=def_nr; - + dv->totweight++; break; } @@ -508,7 +508,7 @@ void ED_vgroup_vert_remove(Object *ob, bDeformGroup *dg, int vertnum) static float get_vert_def_nr(Object *ob, int def_nr, int vertnum) { - MDeformVert *dvert; + MDeformVert *dvert= NULL; EditVert *eve; Mesh *me; int i; @@ -519,7 +519,9 @@ static float get_vert_def_nr(Object *ob, int def_nr, int vertnum) if(me->edit_mesh) { eve= BLI_findlink(&me->edit_mesh->verts, vertnum); - if(!eve) return 0.0f; + if(!eve) { + return 0.0f; + } dvert= CustomData_em_get(&me->edit_mesh->vdata, eve->data, CD_MDEFORMVERT); vertnum= 0; } diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 3f2fcaab94a..1c9f9e60e14 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -338,7 +338,7 @@ typedef struct PEData { DerivedMesh *dm; PTCacheEdit *edit; - short *mval; + const short *mval; rcti *rect; float rad; float dist; @@ -1369,7 +1369,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot) /************************ pick select operator ************************/ -int PE_mouse_particles(bContext *C, short *mval, int extend) +int PE_mouse_particles(bContext *C, const short mval[2], int extend) { PEData data; Scene *scene= CTX_data_scene(C); @@ -1574,7 +1574,7 @@ int PE_border_select(bContext *C, rcti *rect, int select, int extend) /************************ circle select operator ************************/ -int PE_circle_select(bContext *C, int selecting, short *mval, float rad) +int PE_circle_select(bContext *C, int selecting, const short mval[2], float rad) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -2445,7 +2445,7 @@ static int weight_set_exec(bContext *C, wmOperator *op) HairKey *hkey; float weight; ParticleBrushData *brush= &pset->brush[pset->brushtype]; - float factor= RNA_float_get(op->ptr, "factor"); + float factor= RNA_float_get(op->ptr, "factor"); weight= brush->strength; edit= psys->edit; @@ -2477,8 +2477,8 @@ void PARTICLE_OT_weight_set(wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - RNA_def_float(ot->srna, "factor", 1, 0, 1, "Factor", "", 0, 1); + + RNA_def_float(ot->srna, "factor", 1, 0, 1, "Factor", "", 0, 1); } /************************ cursor drawing *******************************/ diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 857a36c3029..ce434413a5f 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -54,6 +54,7 @@ #include "BKE_report.h" #include "BKE_sequencer.h" #include "BKE_screen.h" +#include "BKE_scene.h" #include "WM_api.h" #include "WM_types.h" @@ -735,7 +736,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) if(RNA_property_is_set(op->ptr, "layer")) { SceneRenderLayer *rl; Scene *scn; - char scene_name[19], rl_name[RE_MAXNAME]; + char scene_name[MAX_ID_NAME-2], rl_name[RE_MAXNAME]; RNA_string_get(op->ptr, "layer", rl_name); RNA_string_get(op->ptr, "scene", scene_name); @@ -744,6 +745,10 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) rl = (SceneRenderLayer *)BLI_findstring(&scene->r.layers, rl_name, offsetof(SceneRenderLayer, name)); if (scn && rl) { + /* camera switch wont have updated */ + scn->r.cfra= scene->r.cfra; + scene_camera_switch_update(scn); + scene = scn; srl = rl; } @@ -823,7 +828,7 @@ void RENDER_OT_render(wmOperatorType *ot) RNA_def_boolean(ot->srna, "animation", 0, "Animation", "Render files from the animation range of this scene"); RNA_def_boolean(ot->srna, "write_still", 0, "Write Image", "Save rendered the image to the output path (used only when animation is disabled)"); RNA_def_string(ot->srna, "layer", "", RE_MAXNAME, "Render Layer", "Single render layer to re-render"); - RNA_def_string(ot->srna, "scene", "", 19, "Scene", "Re-render single layer in this scene"); + RNA_def_string(ot->srna, "scene", "", MAX_ID_NAME-2, "Scene", "Re-render single layer in this scene"); } /* ****************************** opengl render *************************** */ diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 5a80799fc3b..1882d849116 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1457,7 +1457,7 @@ void ED_region_header(const bContext *C, ARegion *ar) UI_view2d_view_ortho(&ar->v2d); xco= maxco= 8; - yco= HEADERY-3; + yco= HEADERY-4; /* draw all headers types */ for(ht= ar->type->headertypes.first; ht; ht= ht->next) { diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 39da86b1962..a0a2ede11ef 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1627,7 +1627,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) } else { ScrArea *newa; - char newname[20]; + char newname[MAX_ID_NAME-2]; oldscreen= win->screen; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 901f3d7c5f1..56a27da54df 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -3346,7 +3346,7 @@ static int open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSE { if(drag->type==WM_DRAG_PATH) { if(drag->icon==ICON_FILE_BLEND) - return 1; + return 1; } return 0; } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 01a9a75ca13..5caf72a4a2f 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -486,22 +486,22 @@ static int project_bucket_offset_safe(const ProjPaintState *ps, const float proj /* still use 2D X,Y space but this works for verts transformed by a perspective matrix, using their 4th component as a weight */ static void barycentric_weights_v2_persp(float v1[4], float v2[4], float v3[4], float co[2], float w[3]) { - float wtot_inv, wtot; + float wtot_inv, wtot; - w[0] = area_tri_signed_v2(v2, v3, co) / v1[3]; - w[1] = area_tri_signed_v2(v3, v1, co) / v2[3]; - w[2] = area_tri_signed_v2(v1, v2, co) / v3[3]; - wtot = w[0]+w[1]+w[2]; + w[0] = area_tri_signed_v2(v2, v3, co) / v1[3]; + w[1] = area_tri_signed_v2(v3, v1, co) / v2[3]; + w[2] = area_tri_signed_v2(v1, v2, co) / v3[3]; + wtot = w[0]+w[1]+w[2]; - if (wtot != 0.0f) { - wtot_inv = 1.0f/wtot; + if (wtot != 0.0f) { + wtot_inv = 1.0f/wtot; - w[0] = w[0]*wtot_inv; - w[1] = w[1]*wtot_inv; - w[2] = w[2]*wtot_inv; - } - else /* dummy values for zero area face */ - w[0] = w[1] = w[2] = 1.0f/3.0f; + w[0] = w[0]*wtot_inv; + w[1] = w[1]*wtot_inv; + w[2] = w[2]*wtot_inv; + } + else /* dummy values for zero area face */ + w[0] = w[1] = w[2] = 1.0f/3.0f; } static float VecZDepthOrtho(float pt[2], float v1[3], float v2[3], float v3[3], float w[3]) @@ -1740,7 +1740,7 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s */ if((bucket_bounds->xmin <= cent[0] && bucket_bounds->xmax >= cent[0]) || (bucket_bounds->ymin <= cent[1] && bucket_bounds->ymax >= cent[1]) ) { - return 1; + return 1; } /* out of bounds left */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index ad1d55c336b..e4385131db1 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -175,10 +175,15 @@ static int sculpt_has_active_modifiers(Scene *scene, Object *ob) int sculpt_modifiers_active(Scene *scene, Object *ob) { ModifierData *md; + Mesh *me= (Mesh*)ob->data; MultiresModifierData *mmd= sculpt_multires_active(scene, ob); if(mmd) return 0; + /* non-locked shaoe keys could be handled in the same way as deformed mesh */ + if((ob->shapeflag&OB_SHAPE_LOCK)==0 && me->key && ob->shapenr) + return 1; + md= modifiers_getVirtualModifierList(ob); /* exception for shape keys because we can edit those */ @@ -1882,9 +1887,9 @@ static void calc_sculpt_plane(Sculpt *sd, Object *ob, PBVHNode **nodes, int totn /* Projects a point onto a plane along the plane's normal */ static void point_plane_project(float intr[3], float co[3], float plane_normal[3], float plane_center[3]) { - sub_v3_v3v3(intr, co, plane_center); - mul_v3_v3fl(intr, plane_normal, dot_v3v3(plane_normal, intr)); - sub_v3_v3v3(intr, co, intr); + sub_v3_v3v3(intr, co, plane_center); + mul_v3_v3fl(intr, plane_normal, dot_v3v3(plane_normal, intr)); + sub_v3_v3v3(intr, co, intr); } static int plane_trim(StrokeCache *cache, Brush *brush, float val[3]) @@ -1894,23 +1899,23 @@ static int plane_trim(StrokeCache *cache, Brush *brush, float val[3]) static int plane_point_side_flip(float co[3], float plane_normal[3], float plane_center[3], int flip) { - float delta[3]; - float d; + float delta[3]; + float d; - sub_v3_v3v3(delta, co, plane_center); - d = dot_v3v3(plane_normal, delta); + sub_v3_v3v3(delta, co, plane_center); + d = dot_v3v3(plane_normal, delta); - if (flip) d = -d; + if (flip) d = -d; - return d <= 0.0f; + return d <= 0.0f; } static int plane_point_side(float co[3], float plane_normal[3], float plane_center[3]) { - float delta[3]; + float delta[3]; - sub_v3_v3v3(delta, co, plane_center); - return dot_v3v3(plane_normal, delta) <= 0.0f; + sub_v3_v3v3(delta, co, plane_center); + return dot_v3v3(plane_normal, delta) <= 0.0f; } static float get_offset(Sculpt *sd, SculptSession *ss) @@ -2708,7 +2713,7 @@ void sculpt_update_mesh_elements(Scene *scene, Object *ob, int need_fmap) ss->modifiers_active= sculpt_modifiers_active(scene, ob); - if((ob->shapeflag & OB_SHAPE_LOCK) && !mmd) ss->kb= ob_get_keyblock(ob); + if(!mmd) ss->kb= ob_get_keyblock(ob); else ss->kb= NULL; if(mmd) { @@ -3342,7 +3347,7 @@ static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss) sculpt_update_tex(sd, ss); } -static int sculpt_brush_stroke_init(bContext *C, ReportList *reports) +static int sculpt_brush_stroke_init(bContext *C, ReportList *UNUSED(reports)) { Scene *scene= CTX_data_scene(C); Object *ob= CTX_data_active_object(C); @@ -3350,11 +3355,6 @@ static int sculpt_brush_stroke_init(bContext *C, ReportList *reports) SculptSession *ss = CTX_data_active_object(C)->sculpt; Brush *brush = paint_brush(&sd->paint); - if(ob_get_key(ob) && !(ob->shapeflag & OB_SHAPE_LOCK)) { - BKE_report(reports, RPT_ERROR, "Shape key sculpting requires a locked shape."); - return 0; - } - view3d_operator_needs_opengl(C); sculpt_brush_init_tex(sd, ss); diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index a07f4ff0f5f..3716baad474 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -219,7 +219,7 @@ static int sound_unpack_exec(bContext *C, wmOperator *op) /* find the suppplied image by name */ if (RNA_property_is_set(op->ptr, "id")) { - char sndname[22]; + char sndname[MAX_ID_NAME-2]; RNA_string_get(op->ptr, "id", sndname); sound = BLI_findstring(&CTX_data_main(C)->sound, sndname, offsetof(ID, name) + 2); } @@ -254,7 +254,7 @@ static int sound_unpack_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even if(G.fileflags & G_AUTOPACK) BKE_report(op->reports, RPT_WARNING, "AutoPack is enabled, so image will be packed again on file save."); - unpack_menu(C, "SOUND_OT_unpack", sound->id.name+2, sound->name, "audio", sound->packedfile); + unpack_menu(C, "SOUND_OT_unpack", sound->id.name+2, sound->name, "sounds", sound->packedfile); return OPERATOR_FINISHED; } @@ -276,7 +276,7 @@ static void SOUND_OT_unpack(wmOperatorType *ot) /* properties */ RNA_def_enum(ot->srna, "method", unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack."); - RNA_def_string(ot->srna, "id", "", 21, "Sound Name", "Sound datablock name to unpack."); /* XXX, weark!, will fail with library, name collisions */ + RNA_def_string(ot->srna, "id", "", MAX_ID_NAME-2, "Sound Name", "Sound datablock name to unpack."); /* XXX, weark!, will fail with library, name collisions */ } /* ******************************************************* */ diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index b3aa9349da8..b30db6680e5 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -1220,7 +1220,7 @@ void ACTION_OT_keyframe_type (wmOperatorType *ot) /* identifiers */ ot->name= "Set Keyframe Type"; ot->idname= "ACTION_OT_keyframe_type"; - ot->description= "Set type of keyframe for the seleced keyframes"; + ot->description= "Set type of keyframe for the selected keyframes"; /* api callbacks */ ot->invoke= WM_menu_invoke; diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 06ff061f5ea..10a1fe62cca 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -112,7 +112,7 @@ static SpaceLink *action_new(const bContext *C) ar->v2d.max[0]= MAXFRAMEF; ar->v2d.max[1]= FLT_MAX; - + ar->v2d.minzoom= 0.01f; ar->v2d.maxzoom= 50; ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); @@ -365,8 +365,13 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_ANIMATION: + /* for NLA tweakmode enter/exit, need complete refresh */ + if (wmn->data == ND_NLA_ACTCHANGE) { + saction->flag |= SACTION_TEMP_NEEDCHANSYNC; + ED_area_tag_refresh(sa); + } /* for selection changes of animation data, we can just redraw... otherwise autocolor might need to be done again */ - if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED)) + else if (ELEM(wmn->data, ND_KEYFRAME, ND_ANIMCHAN) && (wmn->action == NA_SELECTED)) ED_area_tag_redraw(sa); else ED_area_tag_refresh(sa); @@ -416,9 +421,9 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn) static void action_header_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ - switch(wmn->category) { + switch (wmn->category) { case NC_SCENE: - switch(wmn->data) { + switch (wmn->data) { case ND_OB_ACTIVE: ED_region_tag_redraw(ar); break; diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 22170bb439f..890a6cf545a 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -182,8 +182,8 @@ static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(eve static void path_drop_copy(wmDrag *drag, wmDropBox *drop) { - char pathname[FILE_MAXDIR+FILE_MAXFILE+2]; - snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path); + char pathname[FILE_MAXDIR+FILE_MAXFILE+2]; + snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path); RNA_string_set(drop->ptr, "text", pathname); } diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 775f06ea7a4..4eddeaaaf9f 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -363,7 +363,7 @@ static int file_select_all_exec(bContext *C, wmOperator *UNUSED(op)) int numfiles = filelist_numfiles(sfile->files); int i; int is_selected = 0; - + sel.first = 0; sel.last = numfiles-1; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index ea3512b456d..04fe2ebf828 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -493,7 +493,7 @@ void ED_fileselect_init_layout(struct SpaceFile *sfile, struct ARegion *ar) layout->tile_h = textheight*3/2; layout->height= (int)(v2d->cur.ymax - v2d->cur.ymin - 2*layout->tile_border_y); layout->rows = layout->height / (layout->tile_h + 2*layout->tile_border_y); - + column_widths(sfile->files, layout); if (params->display == FILE_SHORTDISPLAY) { diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 17e7b1b5b18..fb1144b4fa8 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -766,7 +766,7 @@ void GRAPH_OT_properties(wmOperatorType *ot) ot->exec= graph_properties; ot->poll= ED_operator_graphedit_active; - + /* flags */ ot->flag= 0; } diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 3dffb924434..52b48e1f9fd 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -447,7 +447,7 @@ static int is_preview_allowed(ScrArea *cur) for(sa=G.curscreen->areabase.first; sa; sa= sa->next) { if(sa!=cur && sa->spacetype==SPACE_IMAGE) { if(image_preview_active(sa, NULL, NULL)) - return 0; + return 0; } } /* check image type */ diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index d76374ec3f4..0f361b43de6 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -45,6 +45,7 @@ #include "PIL_time.h" +#include "BLI_math.h" #include "BLI_threads.h" #include "BLI_string.h" #include "BLI_utildefines.h" @@ -132,29 +133,23 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar) BKE_image_release_renderresult(scene, ima); } -void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf) +void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf) { char str[256]; - int ofs= 0; - - ofs += BLI_snprintf(str + ofs, sizeof(str)-ofs, "X: %4d Y: %4d ", x, y); - if(cp) - ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| R: %3d G: %3d B: %3d A: %3d ", cp[0], cp[1], cp[2], cp[3]); - - if(fp) { - if(channels==4) - ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| R: %.4f G: %.4f B: %.4f A: %.4f ", fp[0], fp[1], fp[2], fp[3]); - else if(channels==1) - ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| Val: %.4f ", fp[0]); - else if(channels==3) - ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| R: %.4f G: %.4f B: %.4f ", fp[0], fp[1], fp[2]); - } - - if(zp) - ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| Z: %.4f ", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff)); - if(zpf) - ofs+= BLI_snprintf(str + ofs, sizeof(str)-ofs, "| Z: %.3f ", *zpf); - (void)ofs; /* quiet clang */ + float dx= 6; + /* text colors */ + /* XXX colored text not allowed in Blender UI */ + #if 0 + unsigned char red[3] = {255, 50, 50}; + unsigned char green[3] = {0, 255, 0}; + unsigned char blue[3] = {100, 100, 255}; + #else + unsigned char red[3] = {255, 255, 255}; + unsigned char green[3] = {255, 255, 255}; + unsigned char blue[3] = {255, 255, 255}; + #endif + float hue=0, sat=0, val=0, lum=0, u=0, v=0; + float col[4], finalcol[4]; glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); @@ -163,14 +158,182 @@ void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *f glColor4ub(0, 0, 0, 190); glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20); glDisable(GL_BLEND); - + + BLF_size(blf_mono_font, 11, 72); + glColor3ub(255, 255, 255); - + sprintf(str, "X:%-4d Y:%-4d |", x, y); // UI_DrawString(6, 6, str); // works ok but fixed width is nicer. - BLF_size(blf_mono_font, 11, 72); - BLF_position(blf_mono_font, 6, 6, 0); + BLF_position(blf_mono_font, dx, 6, 0); BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + if(zp) { + glColor3ub(255, 255, 255); + sprintf(str, " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff)); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + } + if(zpf) { + glColor3ub(255, 255, 255); + sprintf(str, " Z:%-.3f |", *zpf); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + } + + if(channels >= 3) { + glColor3ubv(red); + if (fp) + sprintf(str, " R:%-.4f", fp[0]); + else if (cp) + sprintf(str, " R:%-3d", cp[0]); + else + sprintf(str, " R:-"); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + glColor3ubv(green); + if (fp) + sprintf(str, " G:%-.4f", fp[1]); + else if (cp) + sprintf(str, " G:%-3d", cp[1]); + else + sprintf(str, " G:-"); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + glColor3ubv(blue); + if (fp) + sprintf(str, " B:%-.4f", fp[2]); + else if (cp) + sprintf(str, " B:%-3d", cp[2]); + else + sprintf(str, " B:-"); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + if(channels == 4) { + glColor3ub(255, 255, 255); + if (fp) + sprintf(str, " A:%-.4f", fp[3]); + else if (cp) + sprintf(str, " A:%-3d", cp[3]); + else + sprintf(str, "- "); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + } + } + /* color rectangle */ + if (channels==1) { + if (fp) + col[0] = col[1] = col[2] = fp[0]; + else if (cp) + col[0] = col[1] = col[2] = (float)cp[0]/255.0f; + else + col[0] = col[1] = col[2] = 0.0f; + } + else if (channels==3) { + if (fp) + copy_v3_v3(col, fp); + else if (cp) { + col[0] = (float)cp[0]/255.0f; + col[1] = (float)cp[1]/255.0f; + col[2] = (float)cp[2]/255.0f; + } + else + zero_v3(col); + } + else if (channels==4) { + if (fp) + copy_v4_v4(col, fp); + else if (cp) { + col[0] = (float)cp[0]/255.0f; + col[1] = (float)cp[1]/255.0f; + col[2] = (float)cp[2]/255.0f; + col[3] = (float)cp[3]/255.0f; + } + else + zero_v4(col); + } + if (color_manage) { + linearrgb_to_srgb_v3_v3(finalcol, col); + finalcol[3] = col[3]; + } + else { + copy_v4_v4(finalcol, col); + } + glDisable(GL_BLEND); + glColor3fv(finalcol); + dx += 5; + glBegin(GL_QUADS); + glVertex2f(dx, 3); + glVertex2f(dx, 17); + glVertex2f(dx+30, 17); + glVertex2f(dx+30, 3); + glEnd(); + dx += 35; + + glColor3ub(255, 255, 255); + if(channels == 1) { + if (fp) { + rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val); + rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v); + } + else if (cp) { + rgb_to_hsv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &hue, &sat, &val); + rgb_to_yuv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &lum, &u, &v); + } + + sprintf(str, "V:%-.4f", val); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + sprintf(str, " L:%-.4f", lum); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + } + else if(channels >= 3) { + if (fp) { + rgb_to_hsv(fp[0], fp[1], fp[2], &hue, &sat, &val); + rgb_to_yuv(fp[0], fp[1], fp[2], &lum, &u, &v); + } + else if (cp) { + rgb_to_hsv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &hue, &sat, &val); + rgb_to_yuv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &lum, &u, &v); + } + + sprintf(str, "H:%-.4f", hue); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + sprintf(str, " S:%-.4f", sat); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + sprintf(str, " V:%-.4f", val); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + sprintf(str, " L:%-.4f", lum); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + } + + (void)dx; } /* image drawing */ diff --git a/source/blender/editors/space_image/image_intern.h b/source/blender/editors/space_image/image_intern.h index 5857e62e78a..e9e77ddf430 100644 --- a/source/blender/editors/space_image/image_intern.h +++ b/source/blender/editors/space_image/image_intern.h @@ -60,7 +60,7 @@ void IMAGE_OT_toolbox(struct wmOperatorType *ot); /* image_draw.c */ void draw_image_main(struct SpaceImage *sima, struct ARegion *ar, struct Scene *scene); -void draw_image_info(struct ARegion *ar, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf); +void draw_image_info(struct ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp, int *zp, float *zpf); void draw_image_grease_pencil(struct bContext *C, short onlyv2d); /* image_ops.c */ diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 41939969fa4..ab435395d62 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -768,13 +768,13 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) Image *ima= NULL; if(sima) { - ima= sima->image; + ima= sima->image; } if (ima==NULL) { - Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; - if(tex && tex->type==TEX_IMAGE) - ima= tex->ima; + Tex *tex= CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; + if(tex && tex->type==TEX_IMAGE) + ima= tex->ima; } if(ima) @@ -1279,7 +1279,7 @@ static int image_new_exec(bContext *C, wmOperator *op) Image *ima; PointerRNA ptr, idptr; PropertyRNA *prop; - char name[22]; + char name[MAX_ID_NAME-2]; float color[4]; int width, height, floatbuf, uvtestgrid, alpha; @@ -1352,7 +1352,7 @@ void IMAGE_OT_new(wmOperatorType *ot) ot->flag= OPTYPE_UNDO; /* properties */ - RNA_def_string(ot->srna, "name", "untitled", 21, "Name", "Image datablock name."); + RNA_def_string(ot->srna, "name", "untitled", MAX_ID_NAME-2, "Name", "Image datablock name."); RNA_def_int(ot->srna, "width", 1024, 1, INT_MAX, "Width", "Image width.", 1, 16384); RNA_def_int(ot->srna, "height", 1024, 1, INT_MAX, "Height", "Image height.", 1, 16384); prop= RNA_def_float_color(ot->srna, "color", 4, NULL, 0.0f, FLT_MAX, "Color", "Default fill color.", 0.0f, 1.0f); @@ -1538,7 +1538,7 @@ static int image_unpack_exec(bContext *C, wmOperator *op) /* find the suppplied image by name */ if (RNA_property_is_set(op->ptr, "id")) { - char imaname[22]; + char imaname[MAX_ID_NAME-2]; RNA_string_get(op->ptr, "id", imaname); ima = BLI_findstring(&CTX_data_main(C)->image, imaname, offsetof(ID, name) + 2); if (!ima) ima = CTX_data_edit_image(C); @@ -1604,7 +1604,7 @@ void IMAGE_OT_unpack(wmOperatorType *ot) /* properties */ RNA_def_enum(ot->srna, "method", unpack_method_items, PF_USE_LOCAL, "Method", "How to unpack."); - RNA_def_string(ot->srna, "id", "", 21, "Image Name", "Image datablock name to unpack."); /* XXX, weark!, will fail with library, name collisions */ + RNA_def_string(ot->srna, "id", "", MAX_ID_NAME-2, "Image Name", "Image datablock name to unpack."); /* XXX, weark!, will fail with library, name collisions */ } /******************** sample image operator ********************/ @@ -1632,7 +1632,8 @@ static void sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info) { ImageSampleInfo *info= arg_info; if(info->draw) { - draw_image_info(ar, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp); + /* no color management needed for images (color_manage=0) */ + draw_image_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp); } } diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c index dc730e961fc..638bfe57608 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -581,7 +581,7 @@ static void LOGIC_OT_sensor_move(wmOperatorType *ot) { /* identifiers */ ot->name= "Move Sensor"; - ot->description = "Move Densor"; + ot->description = "Move Sensor"; ot->idname= "LOGIC_OT_sensor_move"; /* api callbacks */ diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 66e19cf0400..bce492f5a04 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -2200,28 +2200,28 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo } case ACT_CAMERA: - ysize= 48; - - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + ysize= 48; + + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - ca= act->data; - - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object"); - uiDefButF(block, NUM, 0, "Height:", xco+10+(width-20)/2, yco-24, (width-20)/2, 19, &ca->height, 0.0, 20.0, 0, 0, ""); + ca= act->data; + + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-24, (width-20)/2, 19, &(ca->ob), "Look at this Object"); + uiDefButF(block, NUM, 0, "Height:", xco+10+(width-20)/2, yco-24, (width-20)/2, 19, &ca->height, 0.0, 20.0, 0, 0, ""); - uiDefButF(block, NUM, 0, "Min:", xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, ""); + uiDefButF(block, NUM, 0, "Min:", xco+10, yco-44, (width-60)/2, 19, &ca->min, 0.0, 20.0, 0, 0, ""); - if(ca->axis==0) ca->axis= 'x'; - uiDefButS(block, ROW, 0, "X", xco+10+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'x', 0, 0, "Camera tries to get behind the X axis"); - uiDefButS(block, ROW, 0, "Y", xco+30+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'y', 0, 0, "Camera tries to get behind the Y axis"); + if(ca->axis==0) ca->axis= 'x'; + uiDefButS(block, ROW, 0, "X", xco+10+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'x', 0, 0, "Camera tries to get behind the X axis"); + uiDefButS(block, ROW, 0, "Y", xco+30+(width-60)/2, yco-44, 20, 19, &ca->axis, 4.0, (float)'y', 0, 0, "Camera tries to get behind the Y axis"); - uiDefButF(block, NUM, 0, "Max:", xco+20+(width)/2, yco-44, (width-60)/2, 19, &ca->max, 0.0, 20.0, 0, 0, ""); + uiDefButF(block, NUM, 0, "Max:", xco+20+(width)/2, yco-44, (width-60)/2, 19, &ca->max, 0.0, 20.0, 0, 0, ""); + + yco-= ysize; + + break; - yco-= ysize; - - break; - case ACT_EDIT_OBJECT: eoa= act->data; @@ -2230,7 +2230,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo ysize = 92; glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+10, yco-44, (width-20)/2, 19, &(eoa->ob), "Add this Object and all its children (cant be on an visible layer)"); uiDefButI(block, NUM, 0, "Time:", xco+10+(width-20)/2, yco-44, (width-20)/2, 19, &eoa->time, 0.0, 2000.0, 0, 0, "Duration the new Object lives"); @@ -2311,15 +2311,15 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &eoa->type, 0.0, 0.0, 0, 0, ""); yco-= ysize; - + break; - - case ACT_CONSTRAINT: + + case ACT_CONSTRAINT: coa= act->data; if (coa->type == ACT_CONST_TYPE_LOC) { ysize= 69; - + glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); @@ -2451,69 +2451,69 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo break; case ACT_SCENE: - sca= act->data; + sca= act->data; - if(sca->type==ACT_SCENE_RESTART) { - ysize= 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } - else if(sca->type==ACT_SCENE_CAMERA) { - - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera. Leave empty to refer to self object"); - } - else if(sca->type==ACT_SCENE_SET) { + if(sca->type==ACT_SCENE_RESTART) { + ysize= 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } + else if(sca->type==ACT_SCENE_CAMERA) { + + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+40, yco-44, (width-80), 19, &(sca->camera), "Set this Camera. Leave empty to refer to self object"); + } + else if(sca->type==ACT_SCENE_SET) { - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene"); - } + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Set this Scene"); + } else if(sca->type==ACT_SCENE_ADD_FRONT) { - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene"); - } + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add an Overlay Scene"); + } else if(sca->type==ACT_SCENE_ADD_BACK) { - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene"); - } + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Add a Background Scene"); + } else if(sca->type==ACT_SCENE_REMOVE) { - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene"); - } + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Remove a Scene"); + } else if(sca->type==ACT_SCENE_SUSPEND) { - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene"); - } + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Pause a Scene"); + } else if(sca->type==ACT_SCENE_RESUME) { - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - - uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene"); - } + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + + uiDefIDPoinBut(block, test_scenepoin_but, ID_SCE, 1, "SCE:", xco+40, yco-44, (width-80), 19, &(sca->scene), "Unpause a Scene"); + } str= "Scene %t|Restart %x0|Set Scene %x1|Set Camera %x2|Add OverlayScene %x3|Add BackgroundScene %x4|Remove Scene %x5|Suspend Scene %x6|Resume Scene %x7"; uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &sca->type, 0.0, 0.0, 0, 0, ""); @@ -2850,41 +2850,41 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo yco -= ysize; break; case ACT_PARENT: - parAct = act->data; + parAct = act->data; - if(parAct->type==ACT_PARENT_SET) { + if(parAct->type==ACT_PARENT_SET) { - ysize= 48; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+95, yco-24, (width-100), 19, &(parAct->ob), "Set this object as parent"); + ysize= 48; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + uiDefIDPoinBut(block, test_obpoin_but, ID_OB, 1, "OB:", xco+95, yco-24, (width-100), 19, &(parAct->ob), "Set this object as parent"); uiBlockBeginAlign(block); uiDefButBitS(block, TOGN, ACT_PARENT_COMPOUND, B_REDR, - "Compound", - xco + 5, yco - 44, (width - 10)/2, 19, &parAct->flag, - 0.0, 0.0, 0, 0, - "Add this object shape to the parent shape (only if the parent shape is already compound)"); + "Compound", + xco + 5, yco - 44, (width - 10)/2, 19, &parAct->flag, + 0.0, 0.0, 0, 0, + "Add this object shape to the parent shape (only if the parent shape is already compound)"); uiDefButBitS(block, TOGN, ACT_PARENT_GHOST, B_REDR, - "Ghost", - xco + 5 + ((width - 10)/2), yco - 44, (width - 10)/2, 19, &parAct->flag, - 0.0, 0.0, 0, 0, - "Make this object ghost while parented (only if not compound)"); + "Ghost", + xco + 5 + ((width - 10)/2), yco - 44, (width - 10)/2, 19, &parAct->flag, + 0.0, 0.0, 0, 0, + "Make this object ghost while parented (only if not compound)"); uiBlockEndAlign(block); - } - else if(parAct->type==ACT_PARENT_REMOVE) { - - ysize= 28; - glRects(xco, yco-ysize, xco+width, yco); - uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - } + } + else if(parAct->type==ACT_PARENT_REMOVE) { + + ysize= 28; + glRects(xco, yco-ysize, xco+width, yco); + uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); + } str= "Parent %t|Set Parent %x0|Remove Parent %x1"; uiDefButI(block, MENU, B_REDR, str, xco+5, yco-24, parAct->type==1?(width-80):90, 19, &parAct->type, 0.0, 0.0, 0, 0, ""); - yco-= ysize; - break; + yco-= ysize; + break; case ACT_ARMATURE: - armAct = act->data; + armAct = act->data; if (ob->type == OB_ARMATURE) { str= "Constraint %t|Run armature %x0|Enable %x1|Disable %x2|Set target %x3|Set weight %x4"; @@ -2922,8 +2922,8 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo } glRects(xco, yco-ysize, xco+width, yco); uiEmboss((float)xco, (float)yco-ysize, (float)xco+width, (float)yco, 1); - yco-= ysize; - break; + yco-= ysize; + break; default: ysize= 4; diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index b2d1ffbe790..17cd7ae41bd 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -505,7 +505,7 @@ void NLA_OT_properties(wmOperatorType *ot) ot->exec= nla_properties; ot->poll= ED_operator_nla_active; - + /* flags */ ot->flag= 0; } diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index d058ea746b6..77c91b28a63 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -271,6 +271,12 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) //printf("Add strip - actname = '%s' \n", actname); return OPERATOR_CANCELLED; } + else if (act->idroot == 0) { + /* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */ + BKE_reportf(op->reports, RPT_WARNING, + "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", + act->id.name+2); + } /* get a list of the editable tracks being shown in the NLA * - this is limited to active ones for now, but could be expanded to @@ -289,6 +295,16 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) AnimData *adt= ale->adt; NlaStrip *strip= NULL; + /* sanity check: only apply actions of the right type for this ID + * NOTE: in the case that this hasn't been set, we've already warned the user about this already + */ + if ((act->idroot) && (act->idroot != GS(ale->id->name))) { + BKE_reportf(op->reports, RPT_ERROR, + "Couldn't add action '%s' as it cannot be used relative to ID-blocks of type '%s'", + act->id.name+2, ale->id->name); + continue; + } + /* create a new strip, and offset it to start on the current frame */ strip= add_nlastrip(act); @@ -1002,7 +1018,7 @@ void NLA_OT_mute_toggle (wmOperatorType *ot) /* identifiers */ ot->name= "Toggle Muting"; ot->idname= "NLA_OT_mute_toggle"; - ot->description= "Mute or un-muted selected strips"; + ot->description= "Mute or un-mute selected strips"; /* api callbacks */ ot->exec= nlaedit_toggle_mute_exec; @@ -1384,7 +1400,7 @@ void NLA_OT_action_sync_length (wmOperatorType *ot) /* identifiers */ ot->name= "Sync Action Length"; ot->idname= "NLA_OT_action_sync_length"; - ot->description= "Sychronise the length of the referenced Action with the lengths used in the strip"; + ot->description= "Synchronise the length of the referenced Action with the lengths used in the strip"; /* api callbacks */ ot->exec= nlaedit_sync_actlen_exec; @@ -1803,7 +1819,7 @@ void NLA_OT_fmodifier_add (wmOperatorType *ot) /* identifiers */ ot->name= "Add F-Modifier"; ot->idname= "NLA_OT_fmodifier_add"; - ot->description= "Add F-Modifier of the secified type to the selected NLA-Strips"; + ot->description= "Add F-Modifier of the specified type to the selected NLA-Strips"; /* api callbacks */ ot->invoke= nla_fmodifier_add_invoke; diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 941a88c5c40..90f9996e392 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -159,7 +159,7 @@ static SpaceLink *nla_new(const bContext *C) ar->v2d.max[0]= MAXFRAMEF; ar->v2d.max[1]= 10000.0f; - + ar->v2d.minzoom= 0.01f; ar->v2d.maxzoom= 50; ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index ff135fbe464..68b9170b837 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -518,7 +518,7 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point PointerRNA scn_ptr; PropertyRNA *prop; const char *layer_name; - char scene_name[19]; + char scene_name[MAX_ID_NAME-2]; uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL); @@ -730,22 +730,22 @@ static void node_composit_buts_flip(uiLayout *layout, bContext *UNUSED(C), Point static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiLayout *col; - + uiItemR(layout, ptr, "use_crop_size", 0, NULL, ICON_NONE); - uiItemR(layout, ptr, "relative", 0, NULL, ICON_NONE); + uiItemR(layout, ptr, "relative", 0, NULL, ICON_NONE); col= uiLayoutColumn(layout, 1); - if (RNA_boolean_get(ptr, "relative")){ - uiItemR(col, ptr, "rel_min_x", 0, "Left", ICON_NONE); - uiItemR(col, ptr, "rel_max_x", 0, "Right", ICON_NONE); - uiItemR(col, ptr, "rel_min_y", 0, "Up", ICON_NONE); - uiItemR(col, ptr, "rel_max_y", 0, "Down", ICON_NONE); - } else { - uiItemR(col, ptr, "min_x", 0, "Left", ICON_NONE); - uiItemR(col, ptr, "max_x", 0, "Right", ICON_NONE); - uiItemR(col, ptr, "min_y", 0, "Up", ICON_NONE); - uiItemR(col, ptr, "max_y", 0, "Down", ICON_NONE); - } + if (RNA_boolean_get(ptr, "relative")){ + uiItemR(col, ptr, "rel_min_x", 0, "Left", ICON_NONE); + uiItemR(col, ptr, "rel_max_x", 0, "Right", ICON_NONE); + uiItemR(col, ptr, "rel_min_y", 0, "Up", ICON_NONE); + uiItemR(col, ptr, "rel_max_y", 0, "Down", ICON_NONE); + } else { + uiItemR(col, ptr, "min_x", 0, "Left", ICON_NONE); + uiItemR(col, ptr, "max_x", 0, "Right", ICON_NONE); + uiItemR(col, ptr, "min_y", 0, "Up", ICON_NONE); + uiItemR(col, ptr, "max_y", 0, "Down", ICON_NONE); + } } static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -834,26 +834,26 @@ static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C) { uiLayout *row, *col; - uiItemL(layout, "Despill Channel:", ICON_NONE); - row =uiLayoutRow(layout,0); + uiItemL(layout, "Despill Channel:", ICON_NONE); + row =uiLayoutRow(layout,0); uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - col= uiLayoutColumn(layout, 0); - uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); + col= uiLayoutColumn(layout, 0); + uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); - if(RNA_enum_get(ptr, "limit_method")==0) { - uiItemL(col, "Limiting Channel:", ICON_NONE); - row=uiLayoutRow(col,0); - uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - } + if(RNA_enum_get(ptr, "limit_method")==0) { + uiItemL(col, "Limiting Channel:", ICON_NONE); + row=uiLayoutRow(col,0); + uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + } - uiItemR(col, ptr, "ratio", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemR(col, ptr, "use_unspill", 0, NULL, ICON_NONE); - if (RNA_enum_get(ptr, "use_unspill")== 1) { - uiItemR(col, ptr, "unspill_red", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemR(col, ptr, "unspill_green", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - uiItemR(col, ptr, "unspill_blue", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - } + uiItemR(col, ptr, "ratio", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(col, ptr, "use_unspill", 0, NULL, ICON_NONE); + if (RNA_enum_get(ptr, "use_unspill")== 1) { + uiItemR(col, ptr, "unspill_red", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(col, ptr, "unspill_green", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(col, ptr, "unspill_blue", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + } } static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -865,9 +865,9 @@ static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE); col= uiLayoutColumn(layout, 1); - /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */ + /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */ uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE); - /*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now*/ + /*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now*/ } static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -884,24 +884,24 @@ static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED( { uiLayout *col, *row; - uiItemL(layout, "Color Space:", ICON_NONE); + uiItemL(layout, "Color Space:", ICON_NONE); row= uiLayoutRow(layout, 0); uiItemR(row, ptr, "color_space", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - col=uiLayoutColumn(layout, 0); - uiItemL(col, "Key Channel:", ICON_NONE); + col=uiLayoutColumn(layout, 0); + uiItemL(col, "Key Channel:", ICON_NONE); row= uiLayoutRow(col, 0); uiItemR(row, ptr, "matte_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); col =uiLayoutColumn(layout, 0); - uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); - if(RNA_enum_get(ptr, "limit_method")==0) { - uiItemL(col, "Limiting Channel:", ICON_NONE); - row=uiLayoutRow(col,0); - uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); - } - + uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE); + if(RNA_enum_get(ptr, "limit_method")==0) { + uiItemL(col, "Limiting Channel:", ICON_NONE); + row=uiLayoutRow(col,0); + uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE); + } + uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE); uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE); } @@ -957,7 +957,7 @@ static void node_composit_buts_scale(uiLayout *layout, bContext *UNUSED(C), Poin static void node_composit_buts_rotate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE); + uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE); } static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) @@ -1123,7 +1123,7 @@ static void node_composit_set_butfunc(bNodeType *ntype) break; case CMP_NODE_OUTPUT_FILE: ntype->uifunc= node_composit_buts_file_output; - break; + break; case CMP_NODE_DIFF_MATTE: ntype->uifunc=node_composit_buts_diff_matte; break; @@ -1142,9 +1142,9 @@ static void node_composit_set_butfunc(bNodeType *ntype) case CMP_NODE_SCALE: ntype->uifunc= node_composit_buts_scale; break; - case CMP_NODE_ROTATE: - ntype->uifunc=node_composit_buts_rotate; - break; + case CMP_NODE_ROTATE: + ntype->uifunc=node_composit_buts_rotate; + break; case CMP_NODE_CHANNEL_MATTE: ntype->uifunc= node_composit_buts_channel_matte; break; @@ -1168,16 +1168,16 @@ static void node_composit_set_butfunc(bNodeType *ntype) break; case CMP_NODE_VIEW_LEVELS: ntype->uifunc=node_composit_buts_view_levels; - break; + break; case CMP_NODE_COLORBALANCE: ntype->uifunc=node_composit_buts_colorbalance; - break; + break; case CMP_NODE_HUECORRECT: ntype->uifunc=node_composit_buts_huecorrect; - break; + break; case CMP_NODE_ZCOMBINE: ntype->uifunc=node_composit_buts_zcombine; - break; + break; case CMP_NODE_COMBYCCA: case CMP_NODE_SEPYCCA: ntype->uifunc=node_composit_buts_ycc; @@ -1442,45 +1442,207 @@ void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage) } } -void draw_nodespace_color_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp) +void draw_nodespace_color_info(ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp) { char str[256]; - int ofs; - - ofs= sprintf(str, "X: %4d Y: %4d ", x, y); + float dx= 6; + /* text colors */ + /* XXX colored text not allowed in Blender UI */ + #if 0 + unsigned char red[3] = {255, 50, 50}; + unsigned char green[3] = {0, 255, 0}; + unsigned char blue[3] = {100, 100, 255}; + #else + unsigned char red[3] = {255, 255, 255}; + unsigned char green[3] = {255, 255, 255}; + unsigned char blue[3] = {255, 255, 255}; + #endif + float hue=0, sat=0, val=0, lum=0, u=0, v=0; + float col[4], finalcol[4]; + + glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); + glEnable(GL_BLEND); + + /* noisy, high contrast make impossible to read if lower alpha is used. */ + glColor4ub(0, 0, 0, 190); + glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20); + glDisable(GL_BLEND); + + BLF_size(blf_mono_font, 11, 72); + + glColor3ub(255, 255, 255); + sprintf(str, "X:%-4d Y:%-4d |", x, y); + // UI_DrawString(6, 6, str); // works ok but fixed width is nicer. + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + #if 0 /* XXX no Z value in compo backdrop atm */ + if(zp) { + glColor3ub(255, 255, 255); + sprintf(str, " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff)); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + } + if(zpf) { + glColor3ub(255, 255, 255); + sprintf(str, " Z:%-.3f |", *zpf); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + } + #endif - if(channels==4) { - if(cp) - ofs+= sprintf(str+ofs, "| R: %3d G: %3d B: %3d A: %3d ", cp[0], cp[1], cp[2], cp[3]); + if(channels >= 3) { + glColor3ubv(red); + if (fp) + sprintf(str, " R:%-.4f", fp[0]); + else if (cp) + sprintf(str, " R:%-3d", cp[0]); + else + sprintf(str, " R:-"); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + glColor3ubv(green); + if (fp) + sprintf(str, " G:%-.4f", fp[1]); + else if (cp) + sprintf(str, " G:%-3d", cp[1]); + else + sprintf(str, " G:-"); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + glColor3ubv(blue); if (fp) - ofs+= sprintf(str+ofs, "| R: %.4f G: %.4f B: %.4f A: %.4f ", fp[0], fp[1], fp[2], fp[3]); + sprintf(str, " B:%-.4f", fp[2]); + else if (cp) + sprintf(str, " B:%-3d", cp[2]); + else + sprintf(str, " B:-"); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + if(channels == 4) { + glColor3ub(255, 255, 255); + if (fp) + sprintf(str, " A:%-.4f", fp[3]); + else if (cp) + sprintf(str, " A:%-3d", cp[3]); + else + sprintf(str, "- "); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + } } - else if(channels==1) { - if(cp) - ofs+= sprintf(str+ofs, "| Val: %3d ", cp[0]); + + /* color rectangle */ + if (channels==1) { if (fp) - ofs+= sprintf(str+ofs, "| Val: %.4f ", fp[0]); + col[0] = col[1] = col[2] = fp[0]; + else if (cp) + col[0] = col[1] = col[2] = (float)cp[0]/255.0f; + else + col[0] = col[1] = col[2] = 0.0f; } - else if(channels==3) { - if(cp) - ofs+= sprintf(str+ofs, "| R: %3d G: %3d B: %3d ", cp[0], cp[1], cp[2]); + else if (channels==3) { if (fp) - ofs+= sprintf(str+ofs, "| R: %.4f G: %.4f B: %.4f ", fp[0], fp[1], fp[2]); + copy_v3_v3(col, fp); + else if (cp) { + col[0] = (float)cp[0]/255.0f; + col[1] = (float)cp[1]/255.0f; + col[2] = (float)cp[2]/255.0f; + } + else + zero_v3(col); + } + else if (channels==4) { + if (fp) + copy_v4_v4(col, fp); + else if (cp) { + col[0] = (float)cp[0]/255.0f; + col[1] = (float)cp[1]/255.0f; + col[2] = (float)cp[2]/255.0f; + col[3] = (float)cp[3]/255.0f; + } + else + zero_v4(col); + } + if (color_manage) { + linearrgb_to_srgb_v3_v3(finalcol, col); + finalcol[3] = col[3]; + } + else { + copy_v4_v4(finalcol, col); } - - glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); - glEnable(GL_BLEND); - - glColor4f(.0,.0,.0,.25); - glRecti(0.0, 0.0, ar->winrct.xmax - ar->winrct.xmin + 1, 20); glDisable(GL_BLEND); - + glColor3fv(finalcol); + dx += 5; + glBegin(GL_QUADS); + glVertex2f(dx, 3); + glVertex2f(dx, 17); + glVertex2f(dx+30, 17); + glVertex2f(dx+30, 3); + glEnd(); + dx += 35; + glColor3ub(255, 255, 255); - - // UI_DrawString(6, 6, str); // works ok but fixed width is nicer. - BLF_size(blf_mono_font, 11, 72); - BLF_position(blf_mono_font, 6, 6, 0); - BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + if(channels == 1) { + if (fp) { + rgb_to_hsv(fp[0], fp[0], fp[0], &hue, &sat, &val); + rgb_to_yuv(fp[0], fp[0], fp[0], &lum, &u, &v); + } + else if (cp) { + rgb_to_hsv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &hue, &sat, &val); + rgb_to_yuv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &lum, &u, &v); + } + + sprintf(str, "V:%-.4f", val); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + sprintf(str, " L:%-.4f", lum); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + } + else if(channels >= 3) { + if (fp) { + rgb_to_hsv(fp[0], fp[1], fp[2], &hue, &sat, &val); + rgb_to_yuv(fp[0], fp[1], fp[2], &lum, &u, &v); + } + else if (cp) { + rgb_to_hsv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &hue, &sat, &val); + rgb_to_yuv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &lum, &u, &v); + } + + sprintf(str, "H:%-.4f", hue); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + sprintf(str, " S:%-.4f", sat); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + sprintf(str, " V:%-.4f", val); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + + sprintf(str, " L:%-.4f", lum); + BLF_position(blf_mono_font, dx, 6, 0); + BLF_draw_ascii(blf_mono_font, str, sizeof(str)); + dx += BLF_width(blf_mono_font, str); + } } #if 0 diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 3877e7abf5e..22bbd93de00 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -460,6 +460,19 @@ void snode_set_context(SpaceNode *snode, Scene *scene) node_tree_from_ID(snode->id, &snode->nodetree, &snode->edittree, NULL); } +static void snode_tag_changed(SpaceNode *snode, bNode *node) +{ + bNode *gnode; + + if (node) + NodeTagChanged(snode->edittree, node); + + /* if inside group, tag entire group */ + gnode= node_tree_get_editgroup(snode->nodetree); + if(gnode) + NodeTagIDChanged(snode->nodetree, gnode->id); +} + void node_set_active(SpaceNode *snode, bNode *node) { nodeSetActive(snode->edittree, node); @@ -508,14 +521,7 @@ void node_set_active(SpaceNode *snode, bNode *node) node->flag |= NODE_DO_OUTPUT; if(was_output==0) { - bNode *gnode; - - NodeTagChanged(snode->edittree, node); - - /* if inside group, tag entire group */ - gnode= node_tree_get_editgroup(snode->nodetree); - if(gnode) - NodeTagIDChanged(snode->nodetree, gnode->id); + snode_tag_changed(snode, node); ED_node_changed_update(snode->id, node); } @@ -1029,7 +1035,7 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, wmEvent *event) MEM_freeN(nvm); op->customdata= NULL; - + WM_event_add_notifier(C, NC_SPACE|ND_SPACE_NODE, NULL); return OPERATOR_FINISHED; @@ -1136,11 +1142,12 @@ typedef struct ImageSampleInfo { int draw; } ImageSampleInfo; -static void sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info) +static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) { ImageSampleInfo *info= arg_info; - draw_nodespace_color_info(ar, info->channels, info->x, info->y, info->col, info->colf); + draw_nodespace_color_info(ar, (CTX_data_scene(C)->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels, + info->x, info->y, info->col, info->colf); } static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) @@ -1553,7 +1560,7 @@ static void node_link_viewer(SpaceNode *snode, bNode *tonode) link->fromsock= sock; } ntreeSolveOrder(snode->edittree); - NodeTagChanged(snode->edittree, node); + snode_tag_changed(snode, node); } } } @@ -1896,7 +1903,7 @@ void snode_autoconnect(SpaceNode *snode, int allow_multiple, int replace) if (replace) nodeRemSocketLinks(snode->edittree, sock_to); nodeAddLink(snode->edittree, node_fr, sock_fr, node_to, sock_to); - NodeTagChanged(snode->edittree, node_to); + snode_tag_changed(snode, node_to); ++numlinks; break; } @@ -1960,7 +1967,7 @@ bNode *node_add_node(SpaceNode *snode, Scene *scene, int type, float locx, float if(node->id) id_us_plus(node->id); - NodeTagChanged(snode->edittree, node); + snode_tag_changed(snode, node); } if(snode->nodetree->type==NTREE_TEXTURE) { @@ -2135,8 +2142,7 @@ static int node_link_modal(bContext *C, wmOperator *op, wmEvent *event) case MIDDLEMOUSE: if(link->tosock && link->fromsock) { /* send changed events for original tonode and new */ - if(link->tonode) - NodeTagChanged(snode->edittree, link->tonode); + snode_tag_changed(snode, link->tonode); /* we might need to remove a link */ if(in_out==SOCK_OUT) @@ -2209,7 +2215,7 @@ static int node_link_init(SpaceNode *snode, bNodeLinkDrag *nldrag) if(link) { /* send changed event to original tonode */ if(link->tonode) - NodeTagChanged(snode->edittree, link->tonode); + snode_tag_changed(snode, link->tonode); nldrag->node= link->fromnode; nldrag->sock= link->fromsock; @@ -2363,7 +2369,7 @@ static int cut_links_exec(bContext *C, wmOperator *op) next= link->next; if(cut_links_intersect(link, mcoords, i)) { - NodeTagChanged(snode->edittree, link->tonode); + snode_tag_changed(snode, link->tonode); nodeRemLink(snode->edittree, link); } } @@ -2746,7 +2752,7 @@ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op)) if(node->flag & SELECT) { if(node->inputs.first && node->outputs.first) { node->flag ^= NODE_MUTED; - NodeTagChanged(snode->edittree, node); + snode_tag_changed(snode, node); } } } diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index 205cf099776..fc1b579d1e1 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -90,7 +90,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link); void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 ); int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol); void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage); -void draw_nodespace_color_info(ARegion *ar, int channels, int x, int y, char *cp, float *fp); +void draw_nodespace_color_info(struct ARegion *ar, int color_manage, int channels, int x, int y, char *cp, float *fp); /* node_edit.c */ void node_tree_from_ID(ID *id, bNodeTree **ntree, bNodeTree **edittree, int *treetype); diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 4aa56ef370d..78368d91378 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -70,7 +70,7 @@ static bNode *node_under_mouse(bNodeTree *ntree, int mx, int my) /* ****** Click Select ****** */ -static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, short *mval, short extend) +static bNode *node_mouse_select(SpaceNode *snode, ARegion *ar, const short mval[2], short extend) { bNode *node; float mx, my; diff --git a/source/blender/editors/space_node/node_state.c b/source/blender/editors/space_node/node_state.c index 6172f212aef..1ae36b077af 100644 --- a/source/blender/editors/space_node/node_state.c +++ b/source/blender/editors/space_node/node_state.c @@ -158,7 +158,7 @@ static int do_header_hidden_node(bNode *node, float mx, float my) return 0; } -static int node_toggle_visibility(SpaceNode *snode, ARegion *ar, short *mval) +static int node_toggle_visibility(SpaceNode *snode, ARegion *ar, const short mval[2]) { bNode *node; float mx, my; diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index c0e9e8e22e1..1c2f604a650 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -232,7 +232,7 @@ static void node_area_listener(ScrArea *sa, wmNotifier *wmn) if(type==NTREE_COMPOSIT) { Scene *scene= wmn->window->screen->scene; - /* note that NodeTagIDChanged is alredy called by BKE_image_signal() on all + /* note that NodeTagIDChanged is already called by BKE_image_signal() on all * scenes so really this is just to know if the images is used in the compo else * painting on images could become very slow when the compositor is open. */ if(NodeTagIDChanged(scene->nodetree, wmn->reference)) diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c index d8a9c24b167..4862f557384 100644 --- a/source/blender/editors/space_outliner/outliner.c +++ b/source/blender/editors/space_outliner/outliner.c @@ -1340,8 +1340,8 @@ static void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) int show_opened= (soops->treestore==NULL); /* on first view, we open scenes */ if(soops->tree.first && (soops->storeflag & SO_TREESTORE_REDRAW)) - return; - + return; + outliner_free_tree(&soops->tree); outliner_storage_cleanup(soops); @@ -1729,7 +1729,7 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) /* identifiers */ ot->name= "Toggle Renderability"; ot->idname= "OUTLINER_OT_renderability_toggle"; - ot->description= "Toggle the renderbility of selected items"; + ot->description= "Toggle the renderability of selected items"; /* callbacks */ ot->exec= outliner_toggle_renderability_exec; @@ -3533,8 +3533,8 @@ static EnumPropertyItem prop_group_op_types[] = { {2, "LOCAL", 0, "Make Local", ""}, {3, "LINK", 0, "Link Group Objects to Scene", ""}, {4, "TOGVIS", 0, "Toggle Visible", ""}, - {5, "TOGSEL", 0, "Toggle Selectable", ""}, - {6, "TOGREN", 0, "Toggle Renderable", ""}, + {5, "TOGSEL", 0, "Toggle Selectable", ""}, + {6, "TOGREN", 0, "Toggle Renderable", ""}, {0, NULL, 0, NULL, NULL} }; @@ -3561,7 +3561,7 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op) else if(event==3) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); ED_undo_push(C, "Link Group Objects to Scene"); - } + } WM_event_add_notifier(C, NC_GROUP, NULL); @@ -4662,16 +4662,24 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene Object *ob= (Object *)tselem->id; if(ob==OBACT || (ob->flag & SELECT)) { - char col[4]; + char col[4]= {0, 0, 0, 0}; - active= 2; + /* outliner active ob: always white text, circle color now similar to view3d */ + + active= 2; /* means it draws a color circle */ if(ob==OBACT) { - UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col); - /* so black text is drawn when active and not selected */ - if (ob->flag & SELECT) active= 1; + if(ob->flag & SELECT) { + UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col); + col[3]= 100; + } + + active= 1; /* means it draws white text */ } - else UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); - col[3]= 100; + else if(ob->flag & SELECT) { + UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); + col[3]= 100; + } + glColor4ubv((GLubyte *)col); } @@ -5242,7 +5250,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar if(tselem->type==0 && te->idcode==ID_GR){ int restrict_bool; gr = (Group *)tselem->id; - + uiBlockSetEmboss(block, UI_EMBOSSN); restrict_bool= group_restrict_flag(gr, OB_RESTRICT_VIEW); @@ -5258,7 +5266,7 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); uiBlockSetEmboss(block, UI_EMBOSS); - } + } /* scene render layers and passes have toggle-able flags too! */ else if(tselem->type==TSE_R_LAYER) { uiBlockSetEmboss(block, UI_EMBOSSN); @@ -5660,7 +5668,7 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa if(tselem->type==TSE_EBONE) len = sizeof(((EditBone*) 0)->name); else if (tselem->type==TSE_MODIFIER) len = sizeof(((ModifierData*) 0)->name); else if(tselem->id && GS(tselem->id->name)==ID_LI) len = sizeof(((Library*) 0)->name); - else len= sizeof(((ID*) 0)->name)-2; + else len= MAX_ID_NAME-2; dx= (int)UI_GetStringWidth(te->name); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 115d1ad7bae..92fae3d4820 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -284,7 +284,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i } -Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, short mval[2]) +Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const short mval[2]) { Sequence *seq; Editing *ed= seq_give_editing(scene, FALSE); @@ -614,7 +614,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen } } } - + /* make sequence selection a little bit more intuitive for 3 strips: the last-strip should be sequence3 */ if (seq3 != NULL && seq2 != NULL) { @@ -1666,7 +1666,7 @@ static int sequencer_add_duplicate_invoke(bContext *C, wmOperator *op, wmEvent * void SEQUENCER_OT_duplicate(wmOperatorType *ot) { /* identifiers */ - ot->name= "Duplicate"; + ot->name= "Duplicate Strips"; ot->idname= "SEQUENCER_OT_duplicate"; ot->description="Duplicate the selected strips"; diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index f29919476cc..9a4796ced5e 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -61,7 +61,7 @@ void seq_reset_imageofs(struct SpaceSeq *sseq); struct View2D; void seq_rectf(struct Sequence *seq, struct rctf *rectf); void boundbox_seq(struct Scene *scene, struct rctf *rect); -struct Sequence *find_nearest_seq(struct Scene *scene, struct View2D *v2d, int *hand, short mval[2]); +struct Sequence *find_nearest_seq(struct Scene *scene, struct View2D *v2d, int *hand, const short mval[2]); struct Sequence *find_neighboring_sequence(struct Scene *scene, struct Sequence *test, int lr, int sel); void deselect_all_seq(struct Scene *scene); void recurs_sel_seq(struct Sequence *seqm); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 5325bed15fd..c0c928dcb24 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -290,7 +290,7 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) void TEXT_OT_open(wmOperatorType *ot) { /* identifiers */ - ot->name= "Open"; + ot->name= "Open Text Block"; ot->idname= "TEXT_OT_open"; ot->description= "Open a new text data block"; @@ -1483,7 +1483,7 @@ static int text_get_cursor_rel(SpaceText* st, ARegion *ar, TextLine *linein, int } } - return selc; + return selc; } static int cursor_skip_find_line(SpaceText* st, ARegion *ar, @@ -2283,7 +2283,7 @@ static int scroll_bar_invoke(bContext *C, wmOperator *op, wmEvent *event) SpaceText *st= CTX_wm_space_text(C); ARegion *ar= CTX_wm_region(C); TextScroll *tsc; - short *mval= event->mval; + const short *mval= event->mval; int zone= -1; if(RNA_property_is_set(op->ptr, "lines")) @@ -2694,7 +2694,7 @@ static int line_number_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *even SpaceText *st= CTX_wm_space_text(C); Text *text= CTX_data_edit_text(C); ARegion *ar= CTX_wm_region(C); - short *mval= event->mval; + const short *mval= event->mval; double time; static int jump_to= 0; static double last_jump= 0; diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 1c830b7022a..78538a6f16d 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -189,7 +189,7 @@ void view3d_clr_clipping(void) } } -static int test_clipping(float *vec, float clip[][4]) +static int test_clipping(const float vec[3], float clip[][4]) { float view[3]; copy_v3_v3(view, vec); @@ -205,7 +205,7 @@ static int test_clipping(float *vec, float clip[][4]) /* for 'local' ED_view3d_local_clipping must run first * then all comparisons can be done in localspace */ -int view3d_test_clipping(RegionView3D *rv3d, float *vec, int local) +int view3d_test_clipping(RegionView3D *rv3d, const float vec[3], const int local) { return test_clipping(vec, local ? rv3d->clip_local : rv3d->clip); } @@ -993,7 +993,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) cpack(0x4040FF); glRectf(x3, y3, x4, y4); } - + /* safety border */ if (ca && (ca->flag & CAM_SHOWTITLESAFE)) { fac= 0.1; @@ -1172,7 +1172,7 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax, } /* smart function to sample a rect spiralling outside, nice for backbuf selection */ -unsigned int view3d_sample_backbuf_rect(ViewContext *vc, short mval[2], int size, +unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const short mval[2], int size, unsigned int min, unsigned int max, int *dist, short strict, void *handle, unsigned int (*indextest)(void *handle, unsigned int index)) { diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index ca5213e357b..b377bb20baa 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -285,6 +285,7 @@ typedef struct ViewOpsData { float oldquat[4]; float trackvec[3]; + float mousevec[3]; /* dolly only */ float reverse, dist0; float grid, far; short axis_snap; /* view rotate only */ @@ -346,9 +347,9 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) vod->origy= vod->oldy= event->y; vod->origkey= event->type; /* the key that triggered the operator. */ vod->use_dyn_ofs= (U.uiflag & USER_ORBIT_SELECTION) ? 1:0; + copy_v3_v3(vod->ofs, rv3d->ofs); if (vod->use_dyn_ofs) { - copy_v3_v3(vod->ofs, rv3d->ofs); /* If there's no selection, lastofs is unmodified and last value since static */ calculateTransformCenter(C, V3D_CENTROID, lastofs); negate_v3_v3(vod->dyn_ofs, lastofs); @@ -394,6 +395,9 @@ static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event) } } + /* for dolly */ + window_to_3d_vector(vod->ar, vod->mousevec, (vod->oldx - vod->ar->winrct.xmin)-(vod->ar->winx)/2, (vod->oldy - vod->ar->winrct.ymin)-(vod->ar->winy)/2); + /* lookup, we dont pass on v3d to prevent confusement */ vod->grid= v3d->grid; vod->far= v3d->far; @@ -1075,16 +1079,28 @@ static void view_zoom_mouseloc(ARegion *ar, float dfac, int mx, int my) } -static void viewzoom_apply(ViewOpsData *vod, int x, int y, short viewzoom) +static void viewzoom_apply(ViewOpsData *vod, int x, int y, const short viewzoom, const short zoom_invert) { float zfac=1.0; if(viewzoom==USER_ZOOM_CONT) { double time= PIL_check_seconds_timer(); float time_step= (float)(time - vod->timer_lastdraw); + float fac; + + if (U.uiflag & USER_ZOOM_HORIZ) { + fac= (float)(x - vod->origx); + } + else { + fac= (float)(y - vod->origy); + } + + if(zoom_invert) { + fac= -fac; + } // oldstyle zoom - zfac = 1.0f + (((float)(vod->origx - x + vod->origy - y) / 20.0f) * time_step); + zfac = 1.0f + ((fac / 20.0f) * time_step); vod->timer_lastdraw= time; } else if(viewzoom==USER_ZOOM_SCALE) { @@ -1102,7 +1118,7 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, short viewzoom) else { /* USER_ZOOM_DOLLY */ float len1, len2; - if (U.uiflag & USER_ZOOM_DOLLY_HORIZ) { + if (U.uiflag & USER_ZOOM_HORIZ) { len1 = (vod->ar->winrct.xmax - x) + 5; len2 = (vod->ar->winrct.xmax - vod->origx) + 5; } @@ -1110,14 +1126,15 @@ static void viewzoom_apply(ViewOpsData *vod, int x, int y, short viewzoom) len1 = (vod->ar->winrct.ymax - y) + 5; len2 = (vod->ar->winrct.ymax - vod->origy) + 5; } - if (U.uiflag & USER_ZOOM_INVERT) + if (zoom_invert) { SWAP(float, len1, len2); + } zfac = vod->dist0 * (2.0f * ((len2/len1)-1.0f) + 1.0f) / vod->rv3d->dist; } if(zfac != 1.0f && zfac*vod->rv3d->dist > 0.001f * vod->grid && - zfac * vod->rv3d->dist < 10.0f * vod->far) + zfac * vod->rv3d->dist < 10.0f * vod->far) view_zoom_mouseloc(vod->ar, zfac, vod->oldx, vod->oldy); @@ -1179,7 +1196,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, wmEvent *event) } if(event_code==VIEW_APPLY) { - viewzoom_apply(vod, event->x, event->y, U.viewzoom); + viewzoom_apply(vod, event->x, event->y, U.viewzoom, (U.uiflag & USER_ZOOM_INVERT) != 0); } else if (event_code==VIEW_CONFIRM) { request_depth_update(vod->rv3d); @@ -1249,6 +1266,7 @@ static int viewzoom_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +/* viewdolly_invoke() copied this function, changes here may apply there */ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) { /* if one or the other zoom position aren't set, set from event */ @@ -1272,18 +1290,16 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) vod= op->customdata; if (event->type == MOUSEZOOM) { - if (U.uiflag & USER_ZOOM_INVERT) /* Bypass Zoom invert flag */ - SWAP(int, event->x, event->prevx); + /* Bypass Zoom invert flag for track pads (pass FALSE always) */ - if (U.uiflag & USER_ZOOM_DOLLY_HORIZ) { + if (U.uiflag & USER_ZOOM_HORIZ) { vod->origx = vod->oldx = event->x; - viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY); + viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY, FALSE); } else { - /* Set y move = x move as MOUSEZOOM uses only x axis to pass magnification value */ vod->origy = vod->oldy = vod->origy + event->x - event->prevx; - viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY); + viewzoom_apply(vod, event->prevx, event->prevy, USER_ZOOM_DOLLY, FALSE); } request_depth_update(vod->rv3d); @@ -1310,7 +1326,7 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event) void VIEW3D_OT_zoom(wmOperatorType *ot) { /* identifiers */ - ot->name= "Zoom view"; + ot->name= "Zoom View"; ot->description = "Zoom in/out in the view"; ot->idname= "VIEW3D_OT_zoom"; @@ -1328,6 +1344,232 @@ void VIEW3D_OT_zoom(wmOperatorType *ot) RNA_def_int(ot->srna, "my", 0, 0, INT_MAX, "Zoom Position Y", "", 0, INT_MAX); } + +/* ************************ viewdolly ******************************** */ +static void view_dolly_mouseloc(ARegion *ar, float orig_ofs[3], float dvec[3], float dfac) +{ + RegionView3D *rv3d= ar->regiondata; + madd_v3_v3v3fl(rv3d->ofs, orig_ofs, dvec, 1.0 - dfac); +} + +static void viewdolly_apply(ViewOpsData *vod, int x, int y, const short zoom_invert) +{ + float zfac=1.0; + + { + float len1, len2; + + if (U.uiflag & USER_ZOOM_HORIZ) { + len1 = (vod->ar->winrct.xmax - x) + 5; + len2 = (vod->ar->winrct.xmax - vod->origx) + 5; + } + else { + len1 = (vod->ar->winrct.ymax - y) + 5; + len2 = (vod->ar->winrct.ymax - vod->origy) + 5; + } + if (zoom_invert) + SWAP(float, len1, len2); + + zfac = 1.0 + ((len2 - len1) * 0.01 * vod->rv3d->dist); + } + + if(zfac != 1.0f) + view_dolly_mouseloc(vod->ar, vod->ofs, vod->mousevec, zfac); + + if(vod->rv3d->viewlock & RV3D_BOXVIEW) + view3d_boxview_sync(vod->sa, vod->ar); + + ED_region_tag_redraw(vod->ar); +} + + +static int viewdolly_modal(bContext *C, wmOperator *op, wmEvent *event) +{ + ViewOpsData *vod= op->customdata; + short event_code= VIEW_PASS; + + /* execute the events */ + if(event->type==MOUSEMOVE) { + event_code= VIEW_APPLY; + } + else if(event->type==EVT_MODAL_MAP) { + switch (event->val) { + case VIEW_MODAL_CONFIRM: + event_code= VIEW_CONFIRM; + break; + case VIEWROT_MODAL_SWITCH_MOVE: + WM_operator_name_call(C, "VIEW3D_OT_move", WM_OP_INVOKE_DEFAULT, NULL); + event_code= VIEW_CONFIRM; + break; + case VIEWROT_MODAL_SWITCH_ROTATE: + WM_operator_name_call(C, "VIEW3D_OT_rotate", WM_OP_INVOKE_DEFAULT, NULL); + event_code= VIEW_CONFIRM; + break; + } + } + else if(event->type==vod->origkey && event->val==KM_RELEASE) { + event_code= VIEW_CONFIRM; + } + + if(event_code==VIEW_APPLY) { + viewdolly_apply(vod, event->x, event->y, (U.uiflag & USER_ZOOM_INVERT) != 0); + } + else if (event_code==VIEW_CONFIRM) { + request_depth_update(vod->rv3d); + viewops_data_free(C, op); + + return OPERATOR_FINISHED; + } + + return OPERATOR_RUNNING_MODAL; +} + +static int viewdolly_exec(bContext *C, wmOperator *op) +{ + View3D *v3d; + RegionView3D *rv3d; + ScrArea *sa; + ARegion *ar; + float mousevec[3]; + + int delta= RNA_int_get(op->ptr, "delta"); + int mx, my; + + if(op->customdata) { + ViewOpsData *vod= op->customdata; + + sa= vod->sa; + ar= vod->ar; + copy_v3_v3(mousevec, vod->mousevec); + } + else { + sa= CTX_wm_area(C); + ar= CTX_wm_region(C); + normalize_v3_v3(mousevec, ((RegionView3D *)ar->regiondata)->viewinv[2]); + } + + v3d= sa->spacedata.first; + rv3d= ar->regiondata; + + /* overwrite the mouse vector with the view direction (zoom into the center) */ + if((U.uiflag & USER_ZOOM_TO_MOUSEPOS) == 0) { + normalize_v3_v3(mousevec, rv3d->viewinv[2]); + } + + mx= RNA_property_is_set(op->ptr, "mx") ? RNA_int_get(op->ptr, "mx") : ar->winx / 2; + my= RNA_property_is_set(op->ptr, "my") ? RNA_int_get(op->ptr, "my") : ar->winy / 2; + + + + if(delta < 0) { + view_dolly_mouseloc(ar, rv3d->ofs, mousevec, 1.2f); + } + else { + view_dolly_mouseloc(ar, rv3d->ofs, mousevec, .83333f); + } + + if(rv3d->viewlock & RV3D_BOXVIEW) + view3d_boxview_sync(sa, ar); + + request_depth_update(rv3d); + ED_region_tag_redraw(ar); + + viewops_data_free(C, op); + + return OPERATOR_FINISHED; +} + +/* copied from viewzoom_invoke(), changes here may apply there */ +static int viewdolly_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + /* if one or the other zoom position aren't set, set from event */ + if (!RNA_property_is_set(op->ptr, "mx") || !RNA_property_is_set(op->ptr, "my")) + { + RNA_int_set(op->ptr, "mx", event->x); + RNA_int_set(op->ptr, "my", event->y); + } + + if(RNA_property_is_set(op->ptr, "delta")) { + /* makes op->customdata */ + viewops_data_create(C, op, event); + viewdolly_exec(C, op); + } + else { + ViewOpsData *vod; + + /* makes op->customdata */ + viewops_data_create(C, op, event); + + vod= op->customdata; + + /* overwrite the mouse vector with the view direction (zoom into the center) */ + if((U.uiflag & USER_ZOOM_TO_MOUSEPOS) == 0) { + normalize_v3_v3(vod->mousevec, vod->rv3d->viewinv[2]); + } + + if (event->type == MOUSEZOOM) { + /* Bypass Zoom invert flag for track pads (pass FALSE always) */ + + if (U.uiflag & USER_ZOOM_HORIZ) { + vod->origx = vod->oldx = event->x; + viewdolly_apply(vod, event->prevx, event->prevy, FALSE); + } + else { + + /* Set y move = x move as MOUSEZOOM uses only x axis to pass magnification value */ + vod->origy = vod->oldy = vod->origy + event->x - event->prevx; + viewdolly_apply(vod, event->prevx, event->prevy, FALSE); + } + request_depth_update(vod->rv3d); + + viewops_data_free(C, op); + return OPERATOR_FINISHED; + } + else { + /* add temp handler */ + WM_event_add_modal_handler(C, op); + + return OPERATOR_RUNNING_MODAL; + } + } + return OPERATOR_FINISHED; +} + +/* like ED_operator_region_view3d_active but check its not in ortho view */ +static int viewdolly_poll(bContext *C) +{ + RegionView3D *rv3d= CTX_wm_region_view3d(C); + + if (rv3d && rv3d->persp == RV3D_PERSP) { + return 1; + } + + return 0; +} + +void VIEW3D_OT_dolly(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Dolly view"; + ot->description = "Dolly in/out in the view"; + ot->idname= "VIEW3D_OT_dolly"; + + /* api callbacks */ + ot->invoke= viewdolly_invoke; + ot->exec= viewdolly_exec; + ot->modal= viewdolly_modal; + ot->poll= viewdolly_poll; + + /* flags */ + ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + + RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX); + RNA_def_int(ot->srna, "mx", 0, 0, INT_MAX, "Zoom Position X", "", 0, INT_MAX); + RNA_def_int(ot->srna, "my", 0, 0, INT_MAX, "Zoom Position Y", "", 0, INT_MAX); +} + + + static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in 2.4x */ { ARegion *ar= CTX_wm_region(C); @@ -1678,7 +1920,7 @@ void VIEW3D_OT_render_border(wmOperatorType *ot) { /* identifiers */ ot->name= "Set Render Border"; - ot->description = "Set the boundries of the border render and enables border render "; + ot->description = "Set the boundaries of the border render and enables border render "; ot->idname= "VIEW3D_OT_render_border"; /* api callbacks */ @@ -2565,10 +2807,10 @@ void VIEW3D_OT_cursor3d(wmOperatorType *ot) ot->invoke= set_3dcursor_invoke; ot->poll= ED_operator_view3d_active; - + /* flags */ // ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - + /* rna later */ } @@ -2650,7 +2892,7 @@ void VIEW3D_OT_enable_manipulator(wmOperatorType *ot) /* ************************* below the line! *********************** */ -static float view_autodist_depth_margin(ARegion *ar, short mval[2], int margin) +static float view_autodist_depth_margin(ARegion *ar, const short mval[2], int margin) { ViewDepths depth_temp= {0}; rcti rect; @@ -2678,7 +2920,7 @@ static float view_autodist_depth_margin(ARegion *ar, short mval[2], int margin) } /* XXX todo Zooms in on a border drawn by the user */ -int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, short *mval, float mouse_worldloc[3] ) //, float *autodist ) +int view_autodist(Scene *scene, ARegion *ar, View3D *v3d, const short mval[2], float mouse_worldloc[3] ) //, float *autodist ) { bglMats mats; /* ZBuffer depth vars */ float depth_close= FLT_MAX; @@ -2721,7 +2963,7 @@ int view_autodist_init(Scene *scene, ARegion *ar, View3D *v3d, int mode) //, flo } // no 4x4 sampling, run view_autodist_init first -int view_autodist_simple(ARegion *ar, short *mval, float mouse_worldloc[3], int margin, float *force_depth) //, float *autodist ) +int view_autodist_simple(ARegion *ar, const short mval[2], float mouse_worldloc[3], int margin, float *force_depth) //, float *autodist ) { bglMats mats; /* ZBuffer depth vars, could cache? */ float depth; @@ -2749,7 +2991,7 @@ int view_autodist_simple(ARegion *ar, short *mval, float mouse_worldloc[3], int return 1; } -int view_autodist_depth(struct ARegion *ar, short mval[2], int margin, float *depth) +int view_autodist_depth(struct ARegion *ar, const short mval[2], int margin, float *depth) { *depth= view_autodist_depth_margin(ar, mval, margin); @@ -2776,7 +3018,7 @@ static int depth_segment_cb(int x, int y, void *userData) } } -int view_autodist_depth_segment(struct ARegion *ar, short mval_sta[2], short mval_end[2], int margin, float *depth) +int view_autodist_depth_segment(struct ARegion *ar, const short mval_sta[2], const short mval_end[2], int margin, float *depth) { struct { struct ARegion *ar; int margin; float depth; } data = {NULL}; int p1[2]; diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 7d84a47bddf..ce770aaae6a 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -793,7 +793,7 @@ static int flyApply(bContext *C, FlyInfo *fly) /* transform the parent or the camera? */ if(fly->root_parent) { Object *ob_update; - + float view_mat[4][4]; float prev_view_imat[4][4]; float diff_mat[4][4]; diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index 246ed853cc8..939c44a0514 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -313,7 +313,7 @@ static char *view3d_modeselect_pup(Scene *scene) if (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) || modifiers_findByType(ob, eModifierType_Softbody)) { str += sprintf(str, formatstr, "Particle Mode", OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE); } - + (void)str; return (string); } @@ -485,12 +485,12 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) /* NDOF */ /* Not implemented yet - if (G.ndofdevice ==0 ) { + if (G.ndofdevice ==0 ) { uiDefIconTextButC(block, ICONTEXTROW,B_NDOF, ICON_NDOF_TURN, ndof_pup(), 0,0,XIC+10,YIC, &(v3d->ndofmode), 0, 3.0, 0, 0, "Ndof mode"); - + uiDefIconButC(block, TOG, B_NDOF, ICON_NDOF_DOM, - 0,0,XIC,YIC, - &v3d->ndoffilter, 0, 1, 0, 0, "dominant axis"); + 0,0,XIC,YIC, + &v3d->ndoffilter, 0, 1, 0, 0, "dominant axis"); } */ @@ -513,7 +513,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) uiDefButS(block, MENU, B_MAN_MODE, str_menu,0,0,70,YIC, &v3d->twmode, 0, 0, 0, 0, "Transform Orientation"); MEM_freeN((void *)str_menu); } - + if(obedit==NULL && v3d->localvd==NULL) { unsigned int ob_lay = ob ? ob->lay : 0; diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index d66a3b99911..12ad01e3977 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -68,6 +68,7 @@ void view3d_operatortypes(void); /* view3d_edit.c */ void VIEW3D_OT_zoom(struct wmOperatorType *ot); +void VIEW3D_OT_dolly(struct wmOperatorType *ot); void VIEW3D_OT_zoom_camera_1_to_1(struct wmOperatorType *ot); void VIEW3D_OT_move(struct wmOperatorType *ot); void VIEW3D_OT_rotate(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 30ca1638d34..4942030c516 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -63,6 +63,7 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_move); WM_operatortype_append(VIEW3D_OT_zoom); WM_operatortype_append(VIEW3D_OT_zoom_camera_1_to_1); + WM_operatortype_append(VIEW3D_OT_dolly); WM_operatortype_append(VIEW3D_OT_view_all); WM_operatortype_append(VIEW3D_OT_viewnumpad); WM_operatortype_append(VIEW3D_OT_view_orbit); @@ -129,6 +130,7 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "VIEW3D_OT_rotate", MIDDLEMOUSE, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_move", MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_zoom", MIDDLEMOUSE, KM_PRESS, KM_CTRL, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_dolly", MIDDLEMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index bd19112f924..f51a780787e 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -93,21 +93,33 @@ void view3d_set_viewcontext(bContext *C, ViewContext *vc) vc->obedit= CTX_data_edit_object(C); } -void view3d_get_view_aligned_coordinate(ViewContext *vc, float *fp, short mval[2]) +int view3d_get_view_aligned_coordinate(ViewContext *vc, float fp[3], const short mval[2], const short do_fallback) { float dvec[3]; - short mx, my; - - mx= mval[0]; - my= mval[1]; - - project_short_noclip(vc->ar, fp, mval); - + short mval_cpy[2]; + + mval_cpy[0]= mval[0]; + mval_cpy[1]= mval[1]; + + project_short_noclip(vc->ar, fp, mval_cpy); + initgrabz(vc->rv3d, fp[0], fp[1], fp[2]); - - if(mval[0]!=IS_CLIPPED) { - window_to_3d_delta(vc->ar, dvec, mval[0]-mx, mval[1]-my); + + if(mval_cpy[0]!=IS_CLIPPED) { + window_to_3d_delta(vc->ar, dvec, mval_cpy[0]-mval[0], mval_cpy[1]-mval[1]); sub_v3_v3(fp, dvec); + + return TRUE; + } + else { + /* fallback to the view center */ + if(do_fallback) { + negate_v3_v3(fp, vc->rv3d->ofs); + return view3d_get_view_aligned_coordinate(vc, fp, mval, FALSE); + } + else { + return FALSE; + } } } @@ -669,10 +681,10 @@ static void do_lasso_select_armature(ViewContext *vc, short mcords[][2], short m change= TRUE; } if(lasso_inside(mcords, moves, sco2[0], sco2[1])) { - if(select) ebone->flag |= BONE_TIPSEL; - else ebone->flag &= ~BONE_TIPSEL; - didpoint= 1; - change= TRUE; + if(select) ebone->flag |= BONE_TIPSEL; + else ebone->flag &= ~BONE_TIPSEL; + didpoint= 1; + change= TRUE; } /* if one of points selected, we skip the bone itself */ if(didpoint==0 && lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) { @@ -941,7 +953,7 @@ static void deselectall_except(Scene *scene, Base *b) /* deselect all except b } } -static Base *mouse_select_menu(bContext *C, ViewContext *vc, unsigned int *buffer, int hits, short *mval, short extend) +static Base *mouse_select_menu(bContext *C, ViewContext *vc, unsigned int *buffer, int hits, const short mval[2], short extend) { short baseCount = 0; short ok; @@ -1027,7 +1039,7 @@ static Base *mouse_select_menu(bContext *C, ViewContext *vc, unsigned int *buffe /* we want a select buffer with bones, if there are... */ /* so check three selection levels and compare */ -static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buffer, short *mval) +static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buffer, const short mval[2]) { rcti rect; int offs; @@ -1084,7 +1096,7 @@ static short mixed_bones_object_selectbuffer(ViewContext *vc, unsigned int *buff } /* returns basact */ -static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int hits, short *mval, Base *startbase, int has_bones) +static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int hits, const short mval[2], Base *startbase, int has_bones) { Scene *scene= vc->scene; View3D *v3d= vc->v3d; @@ -1177,7 +1189,7 @@ static Base *mouse_select_eval_buffer(ViewContext *vc, unsigned int *buffer, int } /* mval comes from event->mval, only use within region handlers */ -Base *ED_view3d_give_base_under_cursor(bContext *C, short *mval) +Base *ED_view3d_give_base_under_cursor(bContext *C, const short mval[2]) { ViewContext vc; Base *basact= NULL; @@ -1202,7 +1214,7 @@ Base *ED_view3d_give_base_under_cursor(bContext *C, short *mval) } /* mval is region coords */ -static int mouse_select(bContext *C, short *mval, short extend, short obcenter, short enumerate) +static int mouse_select(bContext *C, const short mval[2], short extend, short obcenter, short enumerate) { ViewContext vc; ARegion *ar= CTX_wm_region(C); @@ -1920,7 +1932,7 @@ static void mesh_circle_doSelectFace(void *userData, EditFace *efa, int x, int y } } -static void mesh_circle_select(ViewContext *vc, int select, short *mval, float rad) +static void mesh_circle_select(ViewContext *vc, int select, const short mval[2], float rad) { ToolSettings *ts= vc->scene->toolsettings; int bbsel; @@ -1965,7 +1977,7 @@ static void mesh_circle_select(ViewContext *vc, int select, short *mval, float r EM_selectmode_flush(vc->em); } -static void paint_facesel_circle_select(ViewContext *vc, int select, short *mval, float rad) +static void paint_facesel_circle_select(ViewContext *vc, int select, const short mval[2], float rad) { Object *ob= vc->obact; Mesh *me = ob?ob->data:NULL; @@ -2012,7 +2024,7 @@ static void nurbscurve_circle_doSelect(void *userData, Nurb *UNUSED(nu), BPoint } } } -static void nurbscurve_circle_select(ViewContext *vc, int select, short *mval, float rad) +static void nurbscurve_circle_select(ViewContext *vc, int select, const short mval[2], float rad) { struct {ViewContext *vc; short select, mval[2]; float radius; } data; @@ -2039,7 +2051,7 @@ static void latticecurve_circle_doSelect(void *userData, BPoint *bp, int x, int bp->f1 = data->select?(bp->f1|SELECT):(bp->f1&~SELECT); } } -static void lattice_circle_select(ViewContext *vc, int select, short *mval, float rad) +static void lattice_circle_select(ViewContext *vc, int select, const short mval[2], float rad) { struct {ViewContext *vc; short select, mval[2]; float radius; } data; @@ -2071,7 +2083,7 @@ static short pchan_circle_doSelectJoint(void *userData, bPoseChannel *pchan, int } return 0; } -static void pose_circle_select(ViewContext *vc, int select, short *mval, float rad) +static void pose_circle_select(ViewContext *vc, int select, const short mval[2], float rad) { struct {ViewContext *vc; short select, mval[2]; float radius; } data; bPose *pose = vc->obact->pose; @@ -2139,7 +2151,7 @@ static short armature_circle_doSelectJoint(void *userData, EditBone *ebone, int } return 0; } -static void armature_circle_select(ViewContext *vc, int select, short *mval, float rad) +static void armature_circle_select(ViewContext *vc, int select, const short mval[2], float rad) { struct {ViewContext *vc; short select, mval[2]; float radius; } data; bArmature *arm= vc->obedit->data; @@ -2198,7 +2210,7 @@ static void armature_circle_select(ViewContext *vc, int select, short *mval, flo /** Callbacks for circle selection in Editmode */ -static void obedit_circle_select(ViewContext *vc, short select, short *mval, float rad) +static void obedit_circle_select(ViewContext *vc, short select, const short mval[2], float rad) { switch(vc->obedit->type) { case OB_MESH: @@ -2234,7 +2246,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) int select; select= (gesture_mode==GESTURE_MODAL_SELECT); - + if( CTX_data_edit_object(C) || paint_facesel_test(obact) || (obact && (obact->mode & (OB_MODE_PARTICLE_EDIT|OB_MODE_POSE))) ) { diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index f007b46dd95..a3d42aa5579 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -788,9 +788,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op)) VECCOPY(curs, centroid); } else { - curs[0]= (min[0]+max[0])/2; - curs[1]= (min[1]+max[1])/2; - curs[2]= (min[2]+max[2])/2; + mid_v3_v3v3(curs, min, max); } MEM_freeN(transvmain); transvmain= NULL; @@ -828,9 +826,7 @@ static int snap_curs_to_sel(bContext *C, wmOperator *UNUSED(op)) VECCOPY(curs, centroid); } else { - curs[0]= (min[0]+max[0])/2; - curs[1]= (min[1]+max[1])/2; - curs[2]= (min[2]+max[2])/2; + mid_v3_v3v3(curs, min, max); } } } diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index f98b2dc934f..6dae0938f54 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -646,25 +646,25 @@ int initgrabz(RegionView3D *rv3d, float x, float y, float z) } /* always call initgrabz */ -void window_to_3d(ARegion *ar, float *vec, short mx, short my) +void window_to_3d(ARegion *ar, float out[3], short mx, short my) { RegionView3D *rv3d= ar->regiondata; float dx= ((float)(mx-(ar->winx/2)))*rv3d->zfac/(ar->winx/2); float dy= ((float)(my-(ar->winy/2)))*rv3d->zfac/(ar->winy/2); - float fz= rv3d->persmat[0][3]*vec[0]+ rv3d->persmat[1][3]*vec[1]+ rv3d->persmat[2][3]*vec[2]+ rv3d->persmat[3][3]; + float fz= rv3d->persmat[0][3]*out[0]+ rv3d->persmat[1][3]*out[1]+ rv3d->persmat[2][3]*out[2]+ rv3d->persmat[3][3]; fz= fz/rv3d->zfac; - vec[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy+ rv3d->persinv[2][0]*fz)-rv3d->ofs[0]; - vec[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy+ rv3d->persinv[2][1]*fz)-rv3d->ofs[1]; - vec[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy+ rv3d->persinv[2][2]*fz)-rv3d->ofs[2]; + out[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy+ rv3d->persinv[2][0]*fz)-rv3d->ofs[0]; + out[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy+ rv3d->persinv[2][1]*fz)-rv3d->ofs[1]; + out[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy+ rv3d->persinv[2][2]*fz)-rv3d->ofs[2]; } /* always call initgrabz */ /* only to detect delta motion */ -void window_to_3d_delta(ARegion *ar, float *vec, short mx, short my) +void window_to_3d_delta(ARegion *ar, float out[3], short mx, short my) { RegionView3D *rv3d= ar->regiondata; float dx, dy; @@ -672,15 +672,15 @@ void window_to_3d_delta(ARegion *ar, float *vec, short mx, short my) dx= 2.0f*mx*rv3d->zfac/ar->winx; dy= 2.0f*my*rv3d->zfac/ar->winy; - vec[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy); - vec[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy); - vec[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy); + out[0]= (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy); + out[1]= (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy); + out[2]= (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy); } /* doesn't rely on initgrabz */ /* for perspective view, get the vector direction to * the mouse cursor as a normalized vector */ -void window_to_3d_vector(ARegion *ar, float *vec, short mx, short my) +void window_to_3d_vector(ARegion *ar, float out[3], short mx, short my) { RegionView3D *rv3d= ar->regiondata; float dx, dy; @@ -692,11 +692,11 @@ void window_to_3d_vector(ARegion *ar, float *vec, short mx, short my) /* normalize here so vecs are proportional to eachother */ normalize_v3_v3(viewvec, rv3d->viewinv[2]); - vec[0]= viewvec[0] - (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy); - vec[1]= viewvec[1] - (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy); - vec[2]= viewvec[2] - (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy); + out[0]= viewvec[0] - (rv3d->persinv[0][0]*dx + rv3d->persinv[1][0]*dy); + out[1]= viewvec[1] - (rv3d->persinv[0][1]*dx + rv3d->persinv[1][1]*dy); + out[2]= viewvec[2] - (rv3d->persinv[0][2]*dx + rv3d->persinv[1][2]*dy); - normalize_v3(vec); + normalize_v3(out); } float read_cached_depth(ViewContext *vc, int x, int y) @@ -740,7 +740,7 @@ void view3d_unproject(bglMats *mats, float out[3], const short x, const short y, } /* use above call to get projecting mat */ -void view3d_project_float(ARegion *ar, float *vec, float *adr, float mat[4][4]) +void view3d_project_float(ARegion *ar, const float vec[3], float adr[2], float mat[4][4]) { float vec4[4]; @@ -793,7 +793,7 @@ int boundbox_clip(RegionView3D *rv3d, float obmat[][4], BoundBox *bb) return 0; } -void project_short(ARegion *ar, float *vec, short *adr) /* clips */ +void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */ { RegionView3D *rv3d= ar->regiondata; float fx, fy, vec4[4]; @@ -824,7 +824,7 @@ void project_short(ARegion *ar, float *vec, short *adr) /* clips */ } } -void project_int(ARegion *ar, float *vec, int *adr) +void project_int(ARegion *ar, const float vec[3], int adr[2]) { RegionView3D *rv3d= ar->regiondata; float fx, fy, vec4[4]; @@ -849,7 +849,7 @@ void project_int(ARegion *ar, float *vec, int *adr) } } -void project_int_noclip(ARegion *ar, float *vec, int *adr) +void project_int_noclip(ARegion *ar, const float vec[3], int adr[2]) { RegionView3D *rv3d= ar->regiondata; float fx, fy, vec4[4]; @@ -873,7 +873,7 @@ void project_int_noclip(ARegion *ar, float *vec, int *adr) } } -void project_short_noclip(ARegion *ar, float *vec, short *adr) +void project_short_noclip(ARegion *ar, const float vec[3], short adr[2]) { RegionView3D *rv3d= ar->regiondata; float fx, fy, vec4[4]; @@ -899,7 +899,7 @@ void project_short_noclip(ARegion *ar, float *vec, short *adr) } } -void project_float(ARegion *ar, float *vec, float *adr) +void project_float(ARegion *ar, const float vec[3], float adr[2]) { RegionView3D *rv3d= ar->regiondata; float vec4[4]; @@ -916,7 +916,7 @@ void project_float(ARegion *ar, float *vec, float *adr) } } -void project_float_noclip(ARegion *ar, float *vec, float *adr) +void project_float_noclip(ARegion *ar, const float vec[3], float adr[2]) { RegionView3D *rv3d= ar->regiondata; float vec4[4]; @@ -939,25 +939,25 @@ void project_float_noclip(ARegion *ar, float *vec, float *adr) int get_view3d_ortho(View3D *v3d, RegionView3D *rv3d) { - Camera *cam; - - if(rv3d->persp==RV3D_CAMOB) { - if(v3d->camera && v3d->camera->type==OB_CAMERA) { - cam= v3d->camera->data; - - if(cam && cam->type==CAM_ORTHO) - return 1; - else - return 0; - } - else - return 0; - } - - if(rv3d->persp==RV3D_ORTHO) - return 1; - - return 0; + Camera *cam; + + if(rv3d->persp==RV3D_CAMOB) { + if(v3d->camera && v3d->camera->type==OB_CAMERA) { + cam= v3d->camera->data; + + if(cam && cam->type==CAM_ORTHO) + return 1; + else + return 0; + } + else + return 0; + } + + if(rv3d->persp==RV3D_ORTHO) + return 1; + + return 0; } /* copies logic of get_view3d_viewplane(), keep in sync */ @@ -1670,6 +1670,7 @@ void VIEW3D_OT_localview(wmOperatorType *ot) /* api callbacks */ ot->exec= localview_exec; + ot->flag= OPTYPE_UNDO; /* localview changes object layer bitflags */ ot->poll= ED_operator_view3d_active; } diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 539d01b9541..4475ce20199 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2283,7 +2283,7 @@ int handleEventWarp(TransInfo *t, wmEvent *event) return status; } -int Warp(TransInfo *t, short UNUSED(mval[2])) +int Warp(TransInfo *t, const short UNUSED(mval[2])) { TransData *td = t->data; float vec[3], circumfac, dist, phi0, co, si, *curs, cursor[3], gcursor[3]; @@ -2431,7 +2431,7 @@ int handleEventShear(TransInfo *t, wmEvent *event) } -int Shear(TransInfo *t, short UNUSED(mval[2])) +int Shear(TransInfo *t, const short UNUSED(mval[2])) { TransData *td = t->data; float vec[3]; @@ -2697,7 +2697,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) { constraintTransLim(t, td); } -int Resize(TransInfo *t, short mval[2]) +int Resize(TransInfo *t, const short mval[2]) { TransData *td; float size[3], mat[3][3]; @@ -2802,7 +2802,7 @@ void initToSphere(TransInfo *t) t->val /= (float)t->total; } -int ToSphere(TransInfo *t, short UNUSED(mval[2])) +int ToSphere(TransInfo *t, const short UNUSED(mval[2])) { float vec[3]; float ratio, radius; @@ -3149,7 +3149,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) } } -int Rotation(TransInfo *t, short UNUSED(mval[2])) +int Rotation(TransInfo *t, const short UNUSED(mval[2])) { char str[128]; @@ -3255,7 +3255,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a } } -int Trackball(TransInfo *t, short UNUSED(mval[2])) +int Trackball(TransInfo *t, const short UNUSED(mval[2])) { char str[128]; float axis1[3], axis2[3]; @@ -3477,7 +3477,7 @@ static void applyTranslation(TransInfo *t, float vec[3]) { } /* uses t->vec to store actual translation in */ -int Translation(TransInfo *t, short UNUSED(mval[2])) +int Translation(TransInfo *t, const short UNUSED(mval[2])) { char str[250]; @@ -3544,7 +3544,7 @@ void initShrinkFatten(TransInfo *t) -int ShrinkFatten(TransInfo *t, short UNUSED(mval[2])) +int ShrinkFatten(TransInfo *t, const short UNUSED(mval[2])) { float vec[3]; float distance; @@ -3619,7 +3619,7 @@ void initTilt(TransInfo *t) -int Tilt(TransInfo *t, short UNUSED(mval[2])) +int Tilt(TransInfo *t, const short UNUSED(mval[2])) { TransData *td = t->data; int i; @@ -3691,7 +3691,7 @@ void initCurveShrinkFatten(TransInfo *t) t->flag |= T_NO_CONSTRAINT; } -int CurveShrinkFatten(TransInfo *t, short UNUSED(mval[2])) +int CurveShrinkFatten(TransInfo *t, const short UNUSED(mval[2])) { TransData *td = t->data; float ratio; @@ -3759,7 +3759,7 @@ void initPushPull(TransInfo *t) } -int PushPull(TransInfo *t, short UNUSED(mval[2])) +int PushPull(TransInfo *t, const short UNUSED(mval[2])) { float vec[3], axis[3]; float distance; @@ -3892,7 +3892,7 @@ int handleEventBevel(TransInfo *t, wmEvent *event) return 0; } -int Bevel(TransInfo *t, short UNUSED(mval[2])) +int Bevel(TransInfo *t, const short UNUSED(mval[2])) { float distance,d; int i; @@ -3960,7 +3960,7 @@ void initBevelWeight(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int BevelWeight(TransInfo *t, short UNUSED(mval[2])) +int BevelWeight(TransInfo *t, const short UNUSED(mval[2])) { TransData *td = t->data; float weight; @@ -4033,7 +4033,7 @@ void initCrease(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int Crease(TransInfo *t, short UNUSED(mval[2])) +int Crease(TransInfo *t, const short UNUSED(mval[2])) { TransData *td = t->data; float crease; @@ -4101,6 +4101,7 @@ void initBoneSize(TransInfo *t) t->idx_max = 2; t->num.idx_max = 2; t->num.flag |= NUM_NULL_ONE; + t->num.flag |= NUM_AFFECT_ALL; t->snap[0] = 0.0f; t->snap[1] = 0.1f; t->snap[2] = t->snap[1] * 0.1f; @@ -4151,7 +4152,7 @@ static void ElementBoneSize(TransInfo *t, TransData *td, float mat[3][3]) td->loc[1]= oldy; } -int BoneSize(TransInfo *t, short mval[2]) +int BoneSize(TransInfo *t, const short mval[2]) { TransData *td = t->data; float size[3], mat[3][3]; @@ -4227,7 +4228,7 @@ void initBoneEnvelope(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int BoneEnvelope(TransInfo *t, short UNUSED(mval[2])) +int BoneEnvelope(TransInfo *t, const short UNUSED(mval[2])) { TransData *td = t->data; float ratio; @@ -4484,11 +4485,11 @@ static int createSlideVerts(TransInfo *t) for(eed=em->edges.first;eed;eed=eed->next) { if(editedge_containsVert(eed, ev)) { if(!(eed->f & SELECT)) { - if(!tempsv->up) { - tempsv->up = eed; - } else if (!(tempsv->down)) { - tempsv->down = eed; - } + if(!tempsv->up) { + tempsv->up = eed; + } else if (!(tempsv->down)) { + tempsv->down = eed; + } } } } @@ -4500,33 +4501,33 @@ static int createSlideVerts(TransInfo *t) for(efa = em->faces.first;efa;efa=efa->next) { if(editface_containsEdge(efa, eed)) { if(editedge_containsVert(efa->e1, ev) && efa->e1 != eed) { - if(!tempsv->up) { - tempsv->up = efa->e1; - } else if (!(tempsv->down)) { - tempsv->down = efa->e1; - } + if(!tempsv->up) { + tempsv->up = efa->e1; + } else if (!(tempsv->down)) { + tempsv->down = efa->e1; + } } if(editedge_containsVert(efa->e2, ev) && efa->e2 != eed) { - if(!tempsv->up) { - tempsv->up = efa->e2; - } else if (!(tempsv->down)) { - tempsv->down = efa->e2; - } + if(!tempsv->up) { + tempsv->up = efa->e2; + } else if (!(tempsv->down)) { + tempsv->down = efa->e2; + } } if(editedge_containsVert(efa->e3, ev) && efa->e3 != eed) { - if(!tempsv->up) { - tempsv->up = efa->e3; - } else if (!(tempsv->down)) { - tempsv->down = efa->e3; - } + if(!tempsv->up) { + tempsv->up = efa->e3; + } else if (!(tempsv->down)) { + tempsv->down = efa->e3; + } } if(efa->e4) { if(editedge_containsVert(efa->e4, ev) && efa->e4 != eed) { - if(!tempsv->up) { - tempsv->up = efa->e4; - } else if (!(tempsv->down)) { - tempsv->down = efa->e4; - } + if(!tempsv->up) { + tempsv->up = efa->e4; + } else if (!(tempsv->down)) { + tempsv->down = efa->e4; + } } } @@ -4961,7 +4962,7 @@ int doEdgeSlide(TransInfo *t, float perc) return 1; } -int EdgeSlide(TransInfo *t, short UNUSED(mval[2])) +int EdgeSlide(TransInfo *t, const short UNUSED(mval[2])) { char str[50]; float final; @@ -5020,7 +5021,7 @@ void initBoneRoll(TransInfo *t) t->flag |= T_NO_CONSTRAINT|T_NO_PROJECT; } -int BoneRoll(TransInfo *t, short UNUSED(mval[2])) +int BoneRoll(TransInfo *t, const short UNUSED(mval[2])) { TransData *td = t->data; int i; @@ -5081,7 +5082,7 @@ void initBakeTime(TransInfo *t) t->num.increment = t->snap[1]; } -int BakeTime(TransInfo *t, short mval[2]) +int BakeTime(TransInfo *t, const short mval[2]) { TransData *td = t->data; float time; @@ -5156,7 +5157,7 @@ void initMirror(TransInfo *t) } } -int Mirror(TransInfo *t, short UNUSED(mval[2])) +int Mirror(TransInfo *t, const short UNUSED(mval[2])) { TransData *td; float size[3], mat[3][3]; @@ -5233,7 +5234,7 @@ void initAlign(TransInfo *t) initMouseInputMode(t, &t->mouse, INPUT_NONE); } -int Align(TransInfo *t, short UNUSED(mval[2])) +int Align(TransInfo *t, const short UNUSED(mval[2])) { TransData *td = t->data; float center[3]; @@ -5336,7 +5337,7 @@ static void applySeqSlide(TransInfo *t, float val[2]) { } } -int SeqSlide(TransInfo *t, short UNUSED(mval[2])) +int SeqSlide(TransInfo *t, const short UNUSED(mval[2])) { char str[200]; @@ -5452,7 +5453,7 @@ static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, TransData2D *td2d, /* snap key to nearest frame? */ if (autosnap == SACTSNAP_FRAME) { const Scene *scene= t->scene; - const short doTime= 0; //XXX doesn't work - getAnimEdit_DrawTime(t); + const short doTime= 0; //getAnimEdit_DrawTime(t); // NOTE: this works, but may be confusing behaviour given the option's label, hence disabled const double secf= FPS; double val; @@ -5626,7 +5627,7 @@ static void applyTimeTranslate(TransInfo *t, float UNUSED(sval)) } } -int TimeTranslate(TransInfo *t, short mval[2]) +int TimeTranslate(TransInfo *t, const short mval[2]) { View2D *v2d = (View2D *)t->view; float cval[2], sval[2]; @@ -5756,7 +5757,7 @@ static void applyTimeSlide(TransInfo *t, float sval) } } -int TimeSlide(TransInfo *t, short mval[2]) +int TimeSlide(TransInfo *t, const short mval[2]) { View2D *v2d = (View2D *)t->view; float cval[2], sval[2]; @@ -5881,7 +5882,7 @@ static void applyTimeScale(TransInfo *t) { } } -int TimeScale(TransInfo *t, short UNUSED(mval[2])) +int TimeScale(TransInfo *t, const short UNUSED(mval[2])) { char str[200]; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index b0bd4ccc5eb..b94f2cc525a 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -242,7 +242,7 @@ typedef struct TransData { } TransData; typedef struct MouseInput { - void (*apply)(struct TransInfo *, struct MouseInput *, short [2], float [3]); + void (*apply)(struct TransInfo *, struct MouseInput *, const short [2], float [3]); void (*post)(struct TransInfo *, float [3]); short imval[2]; /* initial mouse position */ @@ -261,7 +261,7 @@ typedef struct TransInfo { int options; /* current context/options for transform */ float val; /* init value for some transformations (and rotation angle) */ float fac; /* factor for distance based transform */ - int (*transform)(struct TransInfo *, short *); + int (*transform)(struct TransInfo *, const short *); /* transform function pointer */ int (*handleEvent)(struct TransInfo *, struct wmEvent *); /* event handler function pointer RETURN 1 if redraw is needed */ @@ -467,81 +467,81 @@ void removeAspectRatio(TransInfo *t, float *vec); void initWarp(TransInfo *t); int handleEventWarp(TransInfo *t, struct wmEvent *event); -int Warp(TransInfo *t, short mval[2]); +int Warp(TransInfo *t, const short mval[2]); void initShear(TransInfo *t); int handleEventShear(TransInfo *t, struct wmEvent *event); -int Shear(TransInfo *t, short mval[2]); +int Shear(TransInfo *t, const short mval[2]); void initResize(TransInfo *t); -int Resize(TransInfo *t, short mval[2]); +int Resize(TransInfo *t, const short mval[2]); void initTranslation(TransInfo *t); -int Translation(TransInfo *t, short mval[2]); +int Translation(TransInfo *t, const short mval[2]); void initToSphere(TransInfo *t); -int ToSphere(TransInfo *t, short mval[2]); +int ToSphere(TransInfo *t, const short mval[2]); void initRotation(TransInfo *t); -int Rotation(TransInfo *t, short mval[2]); +int Rotation(TransInfo *t, const short mval[2]); void initShrinkFatten(TransInfo *t); -int ShrinkFatten(TransInfo *t, short mval[2]); +int ShrinkFatten(TransInfo *t, const short mval[2]); void initTilt(TransInfo *t); -int Tilt(TransInfo *t, short mval[2]); +int Tilt(TransInfo *t, const short mval[2]); void initCurveShrinkFatten(TransInfo *t); -int CurveShrinkFatten(TransInfo *t, short mval[2]); +int CurveShrinkFatten(TransInfo *t, const short mval[2]); void initTrackball(TransInfo *t); -int Trackball(TransInfo *t, short mval[2]); +int Trackball(TransInfo *t, const short mval[2]); void initPushPull(TransInfo *t); -int PushPull(TransInfo *t, short mval[2]); +int PushPull(TransInfo *t, const short mval[2]); void initBevel(TransInfo *t); int handleEventBevel(TransInfo *t, struct wmEvent *event); -int Bevel(TransInfo *t, short mval[2]); +int Bevel(TransInfo *t, const short mval[2]); void initBevelWeight(TransInfo *t); -int BevelWeight(TransInfo *t, short mval[2]); +int BevelWeight(TransInfo *t, const short mval[2]); void initCrease(TransInfo *t); -int Crease(TransInfo *t, short mval[2]); +int Crease(TransInfo *t, const short mval[2]); void initBoneSize(TransInfo *t); -int BoneSize(TransInfo *t, short mval[2]); +int BoneSize(TransInfo *t, const short mval[2]); void initBoneEnvelope(TransInfo *t); -int BoneEnvelope(TransInfo *t, short mval[2]); +int BoneEnvelope(TransInfo *t, const short mval[2]); void initBoneRoll(TransInfo *t); -int BoneRoll(TransInfo *t, short mval[2]); +int BoneRoll(TransInfo *t, const short mval[2]); void initEdgeSlide(TransInfo *t); -int EdgeSlide(TransInfo *t, short mval[2]); +int EdgeSlide(TransInfo *t, const short mval[2]); void initTimeTranslate(TransInfo *t); -int TimeTranslate(TransInfo *t, short mval[2]); +int TimeTranslate(TransInfo *t, const short mval[2]); void initTimeSlide(TransInfo *t); -int TimeSlide(TransInfo *t, short mval[2]); +int TimeSlide(TransInfo *t, const short mval[2]); void initTimeScale(TransInfo *t); -int TimeScale(TransInfo *t, short mval[2]); +int TimeScale(TransInfo *t, const short mval[2]); void initBakeTime(TransInfo *t); -int BakeTime(TransInfo *t, short mval[2]); +int BakeTime(TransInfo *t, const short mval[2]); void initMirror(TransInfo *t); -int Mirror(TransInfo *t, short mval[2]); +int Mirror(TransInfo *t, const short mval[2]); void initAlign(TransInfo *t); -int Align(TransInfo *t, short mval[2]); +int Align(TransInfo *t, const short mval[2]); void initSeqSlide(TransInfo *t); -int SeqSlide(TransInfo *t, short mval[2]); +int SeqSlide(TransInfo *t, const short mval[2]); void drawPropCircle(const struct bContext *C, TransInfo *t); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 0012334cf92..5793b1c6579 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -243,7 +243,13 @@ static void axisProjection(TransInfo *t, float axis[3], float in[3], float out[3 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 */ + if(!finite(out[0])) out[0]= 0.0f; + if(!finite(out[1])) out[1]= 0.0f; + if(!finite(out[2])) out[2]= 0.0f; } } } @@ -870,7 +876,7 @@ static void setNearestAxis3d(TransInfo *t) axis[1] = (float)(icoord[1] - t->center2d[1]); axis[2] = 0.0f; - if (normalize_v3(axis) != 0.0f) { + if (normalize_v3(axis) != 0.0f) { project_v3_v3v3(proj, mvec, axis); sub_v3_v3v3(axis, mvec, proj); len[i] = normalize_v3(axis); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 04783cce634..5e960593bd7 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -3745,7 +3745,7 @@ static void SeqTransInfo(TransInfo *t, Sequence *seq, int *recursive, int *count } } #endif - + /* for extend we need to do some tricks */ if (t->mode == TFM_TIME_EXTEND) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index a527472e50d..cf169dd587e 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -964,7 +964,22 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) t->options |= CTX_EDGE; } - t->spacetype = sa ? sa->spacetype : SPACE_EMPTY; /* background mode */ + + /* Assign the space type, some exceptions for running in different mode */ + if(sa == NULL) { + /* background mode */ + t->spacetype= SPACE_EMPTY; + } + else if ((ar == NULL) && (sa->spacetype == SPACE_VIEW3D)) { + /* running in the text editor */ + t->spacetype= SPACE_EMPTY; + } + else { + /* normal operation */ + t->spacetype= sa->spacetype; + } + + if(t->spacetype == SPACE_VIEW3D) { View3D *v3d = sa->spacedata.first; diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 45ed983fce5..5097c12d785 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -43,7 +43,7 @@ /* ************************** INPUT FROM MOUSE *************************** */ -static void InputVector(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) +static void InputVector(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { float vec[3], dvec[3]; if(mi->precision) @@ -61,7 +61,7 @@ static void InputVector(TransInfo *t, MouseInput *mi, short mval[2], float outpu } -static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], float output[3]) +static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) { float ratio, precise_ratio, dx, dy; if(mi->precision) @@ -87,7 +87,7 @@ static void InputSpring(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], flo output[0] = ratio; } -static void InputSpringFlip(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) +static void InputSpringFlip(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { InputSpring(t, mi, mval, output); @@ -100,7 +100,7 @@ static void InputSpringFlip(TransInfo *t, MouseInput *mi, short mval[2], float o } } -static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], float output[3]) +static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) { if(mi->precision) @@ -118,7 +118,7 @@ static void InputTrackBall(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], output[1] *= mi->factor; } -static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) { +static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { float x, pad; pad = t->ar->winx / 10; @@ -135,7 +135,7 @@ static void InputHorizontalRatio(TransInfo *t, MouseInput *mi, short mval[2], fl output[0] = (x - pad) / (t->ar->winx - 2 * pad); } -static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) { +static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { float vec[3]; InputVector(t, mi, mval, vec); @@ -144,7 +144,7 @@ static void InputHorizontalAbsolute(TransInfo *t, MouseInput *mi, short mval[2], output[0] = dot_v3v3(t->viewinv[0], vec) * 2.0f; } -static void InputVerticalRatio(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) { +static void InputVerticalRatio(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { float y, pad; pad = t->ar->winy / 10; @@ -160,7 +160,7 @@ static void InputVerticalRatio(TransInfo *t, MouseInput *mi, short mval[2], floa output[0] = (y - pad) / (t->ar->winy - 2 * pad); } -static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, short mval[2], float output[3]) { +static void InputVerticalAbsolute(TransInfo *t, MouseInput *mi, const short mval[2], float output[3]) { float vec[3]; InputVector(t, mi, mval, vec); @@ -185,7 +185,7 @@ void setCustomPoints(TransInfo *UNUSED(t), MouseInput *mi, short start[2], short data[3] = end[1]; } -static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], float output[3]) +static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) { float length; float distance; @@ -218,7 +218,7 @@ static void InputCustomRatio(TransInfo *UNUSED(t), MouseInput *mi, short mval[2] } } -static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, short mval[2], float output[3]) +static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const short mval[2], float output[3]) { double dx2 = mval[0] - mi->center[0]; double dy2 = mval[1] - mi->center[1]; diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index da1a1b91654..2fa094c6b8b 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -1487,7 +1487,7 @@ void BIF_draw_manipulator(const bContext *C) } } -static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, short *mval, float hotspot) +static int manipulator_selectbuf(ScrArea *sa, ARegion *ar, const short mval[2], float hotspot) { View3D *v3d= sa->spacedata.first; RegionView3D *rv3d= ar->regiondata; diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c index 8008d76344d..a2b32ec7cf8 100644 --- a/source/blender/editors/util/crazyspace.c +++ b/source/blender/editors/util/crazyspace.c @@ -400,7 +400,7 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3 if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; if(mti->type==eModifierTypeType_OnlyDeform) { - /* skip leading modifiers which have been alredy + /* skip leading modifiers which have been already handled in sculpt_get_first_deform_matrices */ if(mti->deformMatrices && !deformed) continue; diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index b2a76681bff..8d73da0063c 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -434,7 +434,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) float pointsize; int drawfaces, interpedges; Image *ima= sima->image; - + em= BKE_mesh_get_editmesh(me); activetf= EM_get_active_mtface(em, &efa_act, NULL, 0); /* will be set to NULL if hidden */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index af6efcea5fc..494cf7dee83 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -1787,7 +1787,7 @@ static void UV_OT_select(wmOperatorType *ot) { /* identifiers */ ot->name= "Select"; - ot->description= "Select UV vertice"; + ot->description= "Select UV vertices"; ot->idname= "UV_OT_select"; ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; @@ -2331,7 +2331,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) int x, y, radius, width, height, select; float zoomx, zoomy, offset[2], ellipse[2]; int gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); - + /* get operator properties */ select= (gesture_mode == GESTURE_MODAL_SELECT); x= RNA_int_get(op->ptr, "x"); diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 23af1eafdb7..a9ee65b027b 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -595,7 +595,7 @@ static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v) if (e->flag & PEDGE_SELECT) v->flag |= PVERT_SELECT; - if (e->flag & PEDGE_PIN) { + if (e->flag & PEDGE_PIN) { pinuv[0] += e->orig_uv[0]*handle->aspx; pinuv[1] += e->orig_uv[1]*handle->aspy; npins++; @@ -1142,7 +1142,7 @@ static void p_chart_boundaries(PChart *chart, int *nboundaries, PEdge **outer) (*nboundaries)++; len = 0.0f; - + be = e; do { be->flag |= PEDGE_DONE; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index cc5efd9a6ca..eece7fba91c 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -629,7 +629,7 @@ static void uv_map_rotation_matrix(float result[][4], RegionView3D *rv3d, Object rotside[1][0]= (float)sin(sideangle); rotside[1][1]= (float)cos(sideangle); rotside[2][2]= 1.0f; - + upangle= (float)M_PI*upangledeg/180.0f; rotup[1][1]= (float)cos(upangle)/radius; rotup[1][2]= -(float)sin(upangle)/radius; diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index d87fe865826..25be2e2aeb4 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -210,8 +210,8 @@ static int is_pow2_limit(int num) /* take texture clamping into account */ /* XXX: texturepaint not global! - if (G.f & G_TEXTUREPAINT) - return 1;*/ + if (G.f & G_TEXTUREPAINT) + return 1;*/ if (U.glreslimit != 0 && num > U.glreslimit) return 0; @@ -222,8 +222,8 @@ static int is_pow2_limit(int num) static int smaller_pow2_limit(int num) { /* XXX: texturepaint not global! - if (G.f & G_TEXTUREPAINT) - return 1;*/ + if (G.f & G_TEXTUREPAINT) + return 1;*/ /* take texture clamping into account */ if (U.glreslimit != 0 && num > U.glreslimit) @@ -793,7 +793,7 @@ static ListBase image_free_queue = {NULL, NULL}; static void gpu_queue_image_for_free(Image *ima) { - Image *cpy = MEM_dupallocN(ima); + Image *cpy = MEM_dupallocN(ima); BLI_lock_thread(LOCK_OPENGL); BLI_addtail(&image_free_queue, cpy); diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 453eb995113..f6352a96878 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -119,8 +119,8 @@ void GPU_extensions_init(void) glGetIntegerv(GL_RED_BITS, &r); glGetIntegerv(GL_GREEN_BITS, &g); glGetIntegerv(GL_BLUE_BITS, &b); - GG.colordepth = r+g+b; /* assumes same depth for RGB */ - + GG.colordepth = r+g+b; /* assumes same depth for RGB */ + vendor = (const char*)glGetString(GL_VENDOR); renderer = (const char*)glGetString(GL_RENDERER); @@ -141,7 +141,7 @@ void GPU_extensions_init(void) else if(strstr(vendor, "Intel") || /* src/mesa/drivers/dri/intel/intel_context.c */ strstr(renderer, "Mesa DRI Intel") || - strstr(renderer, "Mesa DRI Mobile Intel")) { + strstr(renderer, "Mesa DRI Mobile Intel")) { GG.device = GPU_DEVICE_INTEL; GG.driver = GPU_DRIVER_OFFICIAL; } @@ -210,7 +210,7 @@ int GPU_non_power_of_two_support(void) int GPU_color_depth(void) { - return GG.colordepth; + return GG.colordepth; } int GPU_print_error(const char *str) @@ -1218,15 +1218,15 @@ void GPU_pixelbuffer_texture(GPUTexture *tex, GPUPixelBuffer *pb) int i; glBindTexture(GL_TEXTURE_RECTANGLE_EXT, tex->bindcode); - - for (i = 0; i < pb->numbuffers; i++) { + + for (i = 0; i < pb->numbuffers; i++) { glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, pb->bindcode[pb->current]); glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT, pb->datasize, NULL, - GL_STREAM_DRAW_ARB); - + GL_STREAM_DRAW_ARB); + pixels = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, GL_WRITE_ONLY); /*memcpy(pixels, _oImage.data(), pb->datasize);*/ - + if (!glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT)) { fprintf(stderr, "Could not unmap opengl PBO\n"); break; diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index c2c9c89ad10..6404ae3de75 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -24,6 +24,11 @@ # # ***** END GPL LICENSE BLOCK ***** +if(WITH_CODEC_FFMPEG) + # FFMPEG gives warnigns which are hard to avoid across multiple versions. + remove_strict_flags() +endif() + set(INC . ../avi diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index a964f345b2b..4de96bb17bc 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -185,7 +185,7 @@ static ImBuf * movie_fetchibuf(struct anim * anim, int position) { if (anim->interlacing == DM_IMAGE_INTERLACED_EVEN) { rect1 = ibuf->rect + (ibuf->x * ibuf->y) - 1; rect2 = rect1 - ibuf->x; - + for (size = ibuf->x * (ibuf->y - 1); size > 0; size--){ *rect1-- = *rect2--; } diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index 32dae3c982e..0759d97e69f 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -95,9 +95,9 @@ int imb_is_a_jpeg(unsigned char *mem) { //---------------------------------------------------------- typedef struct my_error_mgr { - struct jpeg_error_mgr pub; /* "public" fields */ + struct jpeg_error_mgr pub; /* "public" fields */ - jmp_buf setjmp_buffer; /* for return to caller */ + jmp_buf setjmp_buffer; /* for return to caller */ } my_error_mgr; typedef my_error_mgr * my_error_ptr; diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 6ebb86f646d..9bc4ba6776c 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -74,7 +74,7 @@ struct ImBuf *IMB_half_x(struct ImBuf *ibuf1) _p1 = (uchar *) ibuf1->rect; dest=(uchar *) ibuf2->rect; - + _p1f = ibuf1->rect_float; destf= ibuf2->rect_float; @@ -271,7 +271,7 @@ struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1) for(x = ibuf2->x ; x>0 ; x--) *dest1++ = *dest2++ = *p1++; dest1 = dest2; } - if (do_float) { + if (do_float) { dest2f = dest1f + (4*ibuf2->x); for(x = ibuf2->x*4 ; x>0 ; x--) *dest1f++ = *dest2f++ = *p1f++; dest1f = dest2f; @@ -600,7 +600,7 @@ static void enlarge_picture_float( if ((int) y_src == src_height - 1) { line2 = line1; } - + x_src = 0; for (x_dst = 0; x_dst < dst_width; x_dst++) { const float weight1x = (float)(1.0 - (x_src - (int) x_src)); diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index 1f2eebbedc0..3e17665fa39 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -108,19 +108,19 @@ typedef enum { } UnsafeCharacterSet; static const unsigned char acceptable[96] = { - /* A table of the ASCII chars from space (32) to DEL (127) */ - /* ! " # $ % & ' ( ) * + , - . / */ - 0x00,0x3F,0x20,0x20,0x28,0x00,0x2C,0x3F,0x3F,0x3F,0x3F,0x2A,0x28,0x3F,0x3F,0x1C, - /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ - 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x38,0x20,0x20,0x2C,0x20,0x20, - /* @ A B C D E F G H I J K L M N O */ - 0x38,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, - /* P Q R S T U V W X Y Z [ \ ] ^ _ */ - 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x20,0x3F, - /* ` a b c d e f g h i j k l m n o */ - 0x20,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, - /* p q r s t u v w x y z { | } ~ DEL */ - 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x3F,0x20 + /* A table of the ASCII chars from space (32) to DEL (127) */ + /* ! " # $ % & ' ( ) * + , - . / */ + 0x00,0x3F,0x20,0x20,0x28,0x00,0x2C,0x3F,0x3F,0x3F,0x3F,0x2A,0x28,0x3F,0x3F,0x1C, + /* 0 1 2 3 4 5 6 7 8 9 : ; < = > ? */ + 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x38,0x20,0x20,0x2C,0x20,0x20, + /* @ A B C D E F G H I J K L M N O */ + 0x38,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, + /* P Q R S T U V W X Y Z [ \ ] ^ _ */ + 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x20,0x3F, + /* ` a b c d e f g h i j k l m n o */ + 0x20,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F, + /* p q r s t u v w x y z { | } ~ DEL */ + 0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x20,0x20,0x20,0x3F,0x20 }; static const char hex[17] = "0123456789abcdef"; diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 155696fb199..67d20d56466 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -605,8 +605,7 @@ void imb_loadtiletiff(ImBuf *ibuf, unsigned char *mem, size_t size, int tx, int return; } - if(TIFFSetDirectory(image, ibuf->miplevel)) { - /* allocate the image buffer */ + if(TIFFSetDirectory(image, ibuf->miplevel)) { /* allocate the image buffer */ TIFFGetField(image, TIFFTAG_IMAGEWIDTH, &width); TIFFGetField(image, TIFFTAG_IMAGELENGTH, &height); diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 9d916321c3e..6562d602b8d 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -487,6 +487,9 @@ typedef struct bAction { int flag; /* settings for this action */ int active_marker; /* index of the active marker */ + + int idroot; /* type of ID-blocks that action can be assigned to (if 0, will be set to whatever ID first evaluates it) */ + int pad; } bAction; diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index ae7f5e65316..6ad60ac2df9 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -100,7 +100,7 @@ typedef struct Mesh { short totcol; - struct Multires *mr; /* Multiresolution modeling data */ + struct Multires *mr; /* deprecated multiresolution modeling data, only keep for loading old files */ struct PartialVisibility *pv; } Mesh; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 1eff1c3c640..1be67a4501b 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -476,7 +476,7 @@ extern UserDef U; /* from blenkernel blender.c */ #define USER_MENUFIXEDORDER (1 << 23) #define USER_CONTINUOUS_MOUSE (1 << 24) #define USER_ZOOM_INVERT (1 << 25) -#define USER_ZOOM_DOLLY_HORIZ (1 << 26) +#define USER_ZOOM_HORIZ (1 << 26) /* for CONTINUE and DOLLY zoom */ #define USER_SPLASH_DISABLE (1 << 27) #define USER_HIDE_RECENT (1 << 28) #define USER_SHOW_THUMBNAILS (1 << 29) diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index e0e521a81d5..4e9b023b326 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -576,33 +576,33 @@ char *DNA_struct_get_compareflags(SDNA *sdna, SDNA *newsdna) /* compare length and amount of elems */ if( spcur[1] == spold[1]) { - if( newsdna->typelens[spcur[0]] == sdna->typelens[spold[0]] ) { - - /* same length, same amount of elems, now per type and name */ - b= spold[1]; - spold+= 2; - spcur+= 2; - while(b > 0) { - str1= newsdna->types[spcur[0]]; - str2= sdna->types[spold[0]]; - if(strcmp(str1, str2)!=0) break; - - str1= newsdna->names[spcur[1]]; - str2= sdna->names[spold[1]]; - if(strcmp(str1, str2)!=0) break; - - /* same type and same name, now pointersize */ - if(ispointer(str1)) { - if(sdna->pointerlen!=newsdna->pointerlen) break; - } - - b--; - spold+= 2; - spcur+= 2; - } - if(b==0) compflags[a]= 1; - - } + if( newsdna->typelens[spcur[0]] == sdna->typelens[spold[0]] ) { + + /* same length, same amount of elems, now per type and name */ + b= spold[1]; + spold+= 2; + spcur+= 2; + while(b > 0) { + str1= newsdna->types[spcur[0]]; + str2= sdna->types[spold[0]]; + if(strcmp(str1, str2)!=0) break; + + str1= newsdna->names[spcur[1]]; + str2= sdna->names[spold[1]]; + if(strcmp(str1, str2)!=0) break; + + /* same type and same name, now pointersize */ + if(ispointer(str1)) { + if(sdna->pointerlen!=newsdna->pointerlen) break; + } + + b--; + spold+= 2; + spcur+= 2; + } + if(b==0) compflags[a]= 1; + + } } } diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index e5f6d60de84..23706ee01e3 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -1067,7 +1067,7 @@ int make_structDNA(char *baseDirectory, FILE *file) MEM_freeN(names); MEM_freeN(types); MEM_freeN(typelens); - MEM_freeN(alphalens); + MEM_freeN(alphalens); MEM_freeN(structs); if (debugSDNA > -1) printf("done.\n"); diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 7f0518b4a79..68c2f930180 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -30,11 +30,87 @@ remove_strict_flags() # message(STATUS "Configuring makesrna") -file(GLOB DEFSRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") -file(GLOB APISRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*_api.c") -list(REMOVE_ITEM DEFSRC rna_access.c rna_define.c makesrna.c) -list(REMOVE_ITEM DEFSRC ${APISRC}) - +# files rna_access.c rna_define.c makesrna.c intentionally excluded. +set(DEFSRC + rna_ID.c + rna_action.c + rna_actuator.c + rna_animation.c + rna_animviz.c + rna_armature.c + rna_boid.c + rna_brush.c + rna_camera.c + rna_cloth.c + rna_color.c + rna_constraint.c + rna_context.c + rna_controller.c + rna_curve.c + rna_fcurve.c + rna_fluidsim.c + rna_gpencil.c + rna_group.c + rna_image.c + rna_key.c + rna_lamp.c + rna_lattice.c + rna_linestyle.c + rna_main.c + rna_material.c + rna_mesh.c + rna_meta.c + rna_modifier.c + rna_nla.c + rna_nodetree.c + rna_object.c + rna_object_force.c + rna_packedfile.c + rna_particle.c + rna_pose.c + rna_property.c + rna_render.c + rna_rna.c + rna_scene.c + rna_screen.c + rna_sculpt_paint.c + rna_sensor.c + rna_sequencer.c + rna_smoke.c + rna_sound.c + rna_space.c + rna_test.c + rna_text.c + rna_texture.c + rna_timeline.c + rna_ui.c + rna_userdef.c + rna_vfont.c + rna_wm.c + rna_world.c +) + +set(APISRC + rna_action_api.c + rna_actuator_api.c + rna_animation_api.c + rna_armature_api.c + rna_controller_api.c + rna_fcurve_api.c + rna_image_api.c + rna_main_api.c + rna_material_api.c + rna_mesh_api.c + rna_object_api.c + rna_pose_api.c + rna_scene_api.c + rna_sensor_api.c + rna_sequencer_api.c + rna_text_api.c + rna_ui_api.c + rna_wm_api.c +) + string(REGEX REPLACE "rna_([a-zA-Z0-9_-]*).c" "${CMAKE_CURRENT_BINARY_DIR}/rna_\\1_gen.c" GENSRC "${DEFSRC}") set_source_files_properties(GENSRC PROPERTIES GENERATED true) diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 6905cac43e5..e2c25972bdf 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -446,7 +446,7 @@ static void rna_def_ID(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", "Unique datablock ID name"); RNA_def_property_string_funcs(prop, "rna_ID_name_get", "rna_ID_name_length", "rna_ID_name_set"); - RNA_def_property_string_maxlength(prop, sizeof(((ID*)NULL)->name)-2); + RNA_def_property_string_maxlength(prop, MAX_ID_NAME-2); RNA_def_property_editable_func(prop, "rna_ID_name_editable"); RNA_def_property_update(prop, NC_ID|NA_RENAME, NULL); RNA_def_struct_name_property(srna, prop); diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 2e71cfc959e..d4d45db6db9 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -30,6 +30,7 @@ #include <stdlib.h> #include "RNA_define.h" +#include "RNA_enum_types.h" #include "rna_internal.h" @@ -194,6 +195,56 @@ static void rna_Action_frame_range_get(PointerRNA *ptr,float *values) calc_action_range(ptr->id.data, values, values+1, 1); } + +/* used to check if an action (value pointer) is suitable to be assigned to the ID-block that is ptr */ +int rna_Action_id_poll(PointerRNA *ptr, PointerRNA value) +{ + ID *srcId = (ID *)ptr->id.data; + bAction *act = (bAction *)value.id.data; + + if (act) { + /* there can still be actions that will have undefined id-root + * (i.e. floating "action-library" members) which we will not + * be able to resolve an idroot for automatically, so let these through + */ + if (act->idroot == 0) + return 1; + else if (srcId) + return GS(srcId->name) == act->idroot; + } + + return 0; +} + +/* used to check if an action (value pointer) can be assigned to Action Editor given current mode */ +int rna_Action_actedit_assign_poll(PointerRNA *ptr, PointerRNA value) +{ + SpaceAction *saction = (SpaceAction *)ptr->data; + bAction *act = (bAction *)value.id.data; + + if (act) { + /* there can still be actions that will have undefined id-root + * (i.e. floating "action-library" members) which we will not + * be able to resolve an idroot for automatically, so let these through + */ + if (act->idroot == 0) + return 1; + + if (saction) { + if (saction->mode == SACTCONT_ACTION) { + /* this is only Object-level for now... */ + return act->idroot == ID_OB; + } + else if (saction->mode == SACTCONT_SHAPEKEY) { + /* obviously shapekeys only */ + return act->idroot == ID_KE; + } + } + } + + return 0; +} + #else static void rna_def_dopesheet(BlenderRNA *brna) @@ -521,34 +572,43 @@ static void rna_def_action(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - + srna= RNA_def_struct(brna, "Action", "ID"); RNA_def_struct_sdna(srna, "bAction"); RNA_def_struct_ui_text(srna, "Action", "A collection of F-Curves for animation"); RNA_def_struct_ui_icon(srna, ICON_ACTION); - + + /* collections */ prop= RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "curves", NULL); RNA_def_property_struct_type(prop, "FCurve"); RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the Action"); rna_def_action_fcurves(brna, prop); - + prop= RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "groups", NULL); RNA_def_property_struct_type(prop, "ActionGroup"); RNA_def_property_ui_text(prop, "Groups", "Convenient groupings of F-Curves"); rna_def_action_groups(brna, prop); - + prop= RNA_def_property(srna, "pose_markers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "markers", NULL); RNA_def_property_struct_type(prop, "TimelineMarker"); RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this Action, for labeling poses"); rna_def_action_pose_markers(brna, prop); - + + /* properties */ prop= RNA_def_float_vector(srna, "frame_range" , 2 , NULL , 0, 0, "Frame Range" , "The final frame range of all fcurves within this action" , 0 , 0); RNA_def_property_float_funcs(prop, "rna_Action_frame_range_get" , NULL, NULL); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - + + /* special "type" limiter - should not really be edited in general, but is still available/editable in 'emergencies' */ + prop= RNA_def_property(srna, "id_root", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "idroot"); + RNA_def_property_enum_items(prop, id_type_items); + RNA_def_property_ui_text(prop, "ID Root Type", "Type of ID-block that action can be used on. DO NOT CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING"); + + /* API calls */ RNA_api_action(srna); } diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 863c30f8ef2..2afba954be3 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -497,18 +497,18 @@ static void rna_Actuator_Armature_update(Main *bmain, Scene *scene, PointerRNA * /* note: the following set functions exists only to avoid id refcounting */ static void rna_Actuator_editobject_mesh_set(PointerRNA *ptr, PointerRNA value) { - bActuator *act = (bActuator *)ptr->data; - bEditObjectActuator *eoa = (bEditObjectActuator *) act->data; + bActuator *act = (bActuator *)ptr->data; + bEditObjectActuator *eoa = (bEditObjectActuator *) act->data; - eoa->me = value.data; + eoa->me = value.data; } static void rna_Actuator_action_action_set(PointerRNA *ptr, PointerRNA value) { - bActuator *act = (bActuator *)ptr->data; - bActionActuator *aa = (bActionActuator *) act->data; + bActuator *act = (bActuator *)ptr->data; + bActionActuator *aa = (bActionActuator *) act->data; - aa->act = value.data; + aa->act = value.data; } #else @@ -579,8 +579,8 @@ static void rna_def_action_actuator(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Action"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Action", ""); - /* note: custom set function is ONLY to avoid rna setting a user for this. */ - RNA_def_property_pointer_funcs(prop, NULL, "rna_Actuator_action_action_set", NULL, NULL); + /* note: custom set function is ONLY to avoid rna setting a user for this. */ + RNA_def_property_pointer_funcs(prop, NULL, "rna_Actuator_action_action_set", NULL, NULL); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "use_continue_last_frame", PROP_BOOLEAN, PROP_NONE); @@ -1811,8 +1811,8 @@ static void rna_def_shape_action_actuator(BlenderRNA *brna) RNA_def_property_struct_type(prop, "Action"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Action", ""); - /* note: custom set function is ONLY to avoid rna setting a user for this. */ - RNA_def_property_pointer_funcs(prop, NULL, "rna_Actuator_action_action_set", NULL, NULL); + /* note: custom set function is ONLY to avoid rna setting a user for this. */ + RNA_def_property_pointer_funcs(prop, NULL, "rna_Actuator_action_action_set", NULL, NULL); RNA_def_property_update(prop, NC_LOGIC, NULL); prop= RNA_def_property(srna, "use_continue_last_frame", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 17d2e27c462..8e210a7a4cb 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -70,6 +70,41 @@ static int rna_AnimData_action_editable(PointerRNA *ptr) return 1; } +static void rna_AnimData_action_set(PointerRNA *ptr, PointerRNA value) +{ + ID *ownerId = (ID *)ptr->id.data; + AnimData *adt = (AnimData *)ptr->data; + + /* assume that AnimData's action can in fact be edited... */ + if ((value.data) && (ownerId)) { + bAction *act = (bAction *)value.data; + + /* action must have same type as owner */ + if (ownerId) { + if (ELEM(act->idroot, 0, GS(ownerId->name))) { + /* can set */ + adt->action = act; + } + else { + /* cannot set */ + printf("ERROR: Couldn't set Action '%s' onto ID '%s', as it doesn't have suitably rooted paths for this purpose\n", + act->id.name+2, ownerId->name); + } + } + else { + /* cannot tell if we can set, so let's just be generous... */ + printf("Warning: Set Action '%s' onto AnimData block with an unknown ID-owner. May have attached invalid data\n", + act->id.name+2); + + adt->action = act; + } + } + else { + /* just clearing the action... */ + adt->action = NULL; + } +} + /* ****************************** */ /* wrapper for poll callback */ @@ -739,6 +774,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_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? */ diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 74857115bc5..f3f79cde617 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -111,7 +111,7 @@ static void rna_Brush_reset_icon(Brush *br, const char *UNUSED(type)) if(id->icon_id >= BIFICONID_LAST) { BKE_icon_delete(id); BKE_previewimg_free_id(id); - } + } id->icon_id = 0; } diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index d8f0abfd7e2..966e679f0fe 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -1329,7 +1329,7 @@ static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", 4); RNA_def_property_ui_text(prop, "Limit Z", "Use minimum/maximum z limit"); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - + prop= RNA_def_property(srna, "use_angular_limit_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", 8); RNA_def_property_ui_text(prop, "Angular X Limit", "Use minimum/maximum x angular limit"); @@ -1344,7 +1344,6 @@ static void rna_def_constraint_rigid_body_joint(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", 32); RNA_def_property_ui_text(prop, "Angular Z Limit", "Use minimum/maximum z angular limit"); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); - } static void rna_def_constraint_clamp_to(BlenderRNA *brna) @@ -2044,7 +2043,7 @@ void RNA_def_constraint(BlenderRNA *brna) prop= RNA_def_property(srna, "is_valid", PROP_BOOLEAN, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_DISABLE); - RNA_def_property_ui_text(prop, "Disabled", "Constraint has invalid settings and will not be evaluated"); + RNA_def_property_ui_text(prop, "Valid", "Constraint has valid settings and can be evaluated"); // TODO: setting this to true must ensure that all others in stack are turned off too... prop= RNA_def_property(srna, "active", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index 12d27bc80c2..92c762098c7 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -56,24 +56,24 @@ static struct StructRNA* rna_Controller_refine(struct PointerRNA *ptr) bController *controller= (bController*)ptr->data; switch(controller->type) { - case CONT_LOGIC_AND: - return &RNA_AndController; - case CONT_LOGIC_OR: - return &RNA_OrController; - case CONT_LOGIC_NAND: - return &RNA_NandController; - case CONT_LOGIC_NOR: - return &RNA_NorController; - case CONT_LOGIC_XOR: - return &RNA_XorController; - case CONT_LOGIC_XNOR: - return &RNA_XnorController; - case CONT_EXPRESSION: - return &RNA_ExpressionController; - case CONT_PYTHON: - return &RNA_PythonController; - default: - return &RNA_Controller; + case CONT_LOGIC_AND: + return &RNA_AndController; + case CONT_LOGIC_OR: + return &RNA_OrController; + case CONT_LOGIC_NAND: + return &RNA_NandController; + case CONT_LOGIC_NOR: + return &RNA_NorController; + case CONT_LOGIC_XOR: + return &RNA_XorController; + case CONT_LOGIC_XNOR: + return &RNA_XnorController; + case CONT_EXPRESSION: + return &RNA_ExpressionController; + case CONT_PYTHON: + return &RNA_PythonController; + default: + return &RNA_Controller; } } diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index ec0f9277653..ec640531fa0 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -947,7 +947,7 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) /* strings */ prop= RNA_def_property(srna, "family", PROP_STRING, PROP_NONE); - RNA_def_property_string_maxlength(prop, (sizeof((ID *)NULL)->name)-2); + RNA_def_property_string_maxlength(prop, MAX_ID_NAME-2); RNA_def_property_ui_text(prop, "Object Font", "Use Blender Objects as font characters. Give font objects a common name followed by the character it represents, eg. familya, familyb etc, and turn on Verts Duplication"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index efb5bf0244c..1b18f88efcc 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -164,8 +164,8 @@ static void rna_DriverTarget_update_name(Main *bmain, Scene *scene, PointerRNA * /* note: this function exists only to avoid id refcounting */ static void rna_DriverTarget_id_set(PointerRNA *ptr, PointerRNA value) { - DriverTarget *dtar= (DriverTarget*)ptr->data; - dtar->id= value.data; + DriverTarget *dtar= (DriverTarget*)ptr->data; + dtar->id= value.data; } static StructRNA *rna_DriverTarget_id_typef(PointerRNA *ptr) @@ -1044,7 +1044,7 @@ static void rna_def_drivertarget(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ID"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_editable_func(prop, "rna_DriverTarget_id_editable"); - /* note: custom set function is ONLY to avoid rna setting a user for this. */ + /* note: custom set function is ONLY to avoid rna setting a user for this. */ RNA_def_property_pointer_funcs(prop, NULL, "rna_DriverTarget_id_set", "rna_DriverTarget_id_typef", NULL); RNA_def_property_ui_text(prop, "ID", "ID-block that the specific property used can be found from (id_type property must be set first)"); RNA_def_property_update(prop, 0, "rna_DriverTarget_update_data"); diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index 228b00e7937..423b4e4f76b 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -309,7 +309,7 @@ static void rna_def_gpencil_data(BlenderRNA *brna) static EnumPropertyItem draw_mode_items[] = { {GP_DATA_VIEWALIGN, "CURSOR", 0, "Cursor", "Draw stroke at the 3D cursor"}, - {0, "VIEW", 0, "View", "Stick stroke to the view "}, /* weired, GP_DATA_VIEWALIGN is inverted */ + {0, "VIEW", 0, "View", "Stick stroke to the view "}, /* weird, GP_DATA_VIEWALIGN is inverted */ {GP_DATA_VIEWALIGN|GP_DATA_DEPTH_VIEW, "SURFACE", 0, "Surface", "Stick stroke to surfaces"}, {GP_DATA_VIEWALIGN|GP_DATA_DEPTH_STROKE, "STROKE", 0, "Stroke", "Stick stroke to other strokes"}, {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 091ec073f61..2d5c26199d6 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -155,7 +155,7 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int ibuf= BKE_image_get_ibuf(image, NULL); - if(ibuf == NULL || ibuf->rect == NULL ) { + if(ibuf == NULL || ibuf->rect == NULL ) { BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name+2); return (int)GL_INVALID_OPERATION; } diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 70f3deb6e13..7df31fc12f9 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -223,6 +223,9 @@ int rna_Curve_object_poll(struct PointerRNA *ptr, struct PointerRNA value); int rna_Lattice_object_poll(struct PointerRNA *ptr, struct PointerRNA value); int rna_Mesh_object_poll(struct PointerRNA *ptr, struct PointerRNA value); +/* basic poll functions for actions (to prevent actions getting set in wrong places) */ +int rna_Action_id_poll(struct PointerRNA *ptr, struct PointerRNA value); +int rna_Action_actedit_assign_poll(struct PointerRNA *ptr, struct PointerRNA value); char *rna_TextureSlot_path(struct PointerRNA *ptr); diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 09837579949..9bf5f53f8b7 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -426,6 +426,7 @@ static void rna_def_nlastrip(BlenderRNA *brna) /* Action */ prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Action_id_poll"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Action", "Action referenced by this strip"); RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 0dd536b64c2..b6d0f77c5a5 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -462,7 +462,7 @@ static bNode *rna_NodeTree_node_new(bNodeTree *ntree, bContext *C, ReportList *r node = nodeAddNodeType(ntree, type, group, NULL); if (node == NULL) { - BKE_reportf(reports, RPT_ERROR, "Unable to create node"); + BKE_reportf(reports, RPT_ERROR, "Unable to create node"); } else { nodeGroupVerify(ntree); /* update group node socket links*/ @@ -1668,8 +1668,8 @@ static void def_cmp_channel_matte(StructRNA *srna) prop = RNA_def_property(srna, "limit_channel", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "channel"); - RNA_def_property_enum_items(prop, prop_tri_channel_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_channel_itemf"); + RNA_def_property_enum_items(prop, prop_tri_channel_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_channel_itemf"); RNA_def_property_ui_text(prop, "Limit Channel", "Limit by this channels value"); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); @@ -1843,10 +1843,10 @@ static void def_cmp_crop(StructRNA *srna) RNA_def_property_ui_text(prop, "Crop Image Size", "Whether to crop the size of the input image"); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1); - RNA_def_property_ui_text(prop, "Relative", "Use relative values to crop image"); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "relative", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "custom2", 1); + RNA_def_property_ui_text(prop, "Relative", "Use relative values to crop image"); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); RNA_def_struct_sdna_from(srna, "NodeTwoXYs", "storage"); @@ -1874,29 +1874,29 @@ static void def_cmp_crop(StructRNA *srna) RNA_def_property_ui_text(prop, "Y2", ""); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); - prop = RNA_def_property(srna, "rel_min_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "fac_x1"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "X1", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "rel_max_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "fac_x2"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "X2", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "rel_min_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "fac_y1"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Y1", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "rel_max_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "fac_y2"); - RNA_def_property_range(prop, 0.0, 1.0); - RNA_def_property_ui_text(prop, "Y2", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + prop = RNA_def_property(srna, "rel_min_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fac_x1"); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "X1", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "rel_max_x", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fac_x2"); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "X2", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "rel_min_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fac_y1"); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "Y1", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "rel_max_y", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "fac_y2"); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "Y2", ""); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); } static void def_cmp_dblur(StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index babc413e274..436418324e2 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -101,7 +101,7 @@ EnumPropertyItem metaelem_type_items[] = { #define OBTYPE_CU_CURVE {OB_CURVE, "CURVE", 0, "Curve", ""} #define OBTYPE_CU_SURF {OB_SURF, "SURFACE", 0, "Surface", ""} #define OBTYPE_CU_FONT {OB_FONT, "FONT", 0, "Font", ""} - + EnumPropertyItem object_type_items[] = { {OB_MESH, "MESH", 0, "Mesh", ""}, OBTYPE_CU_CURVE, @@ -1059,6 +1059,9 @@ static PointerRNA rna_Object_collision_get(PointerRNA *ptr) { Object *ob= (Object*)ptr->id.data; + if(ob->type != OB_MESH) + return PointerRNA_NULL; + /* weak */ if(!ob->pd) ob->pd= object_add_collision_fields(0); diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 2a369ba9044..d6af04f2475 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -87,10 +87,10 @@ static Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int int cage = !apply_modifiers; /* perform the mesh extraction based on type */ - switch (ob->type) { - case OB_FONT: - case OB_CURVE: - case OB_SURF: + switch (ob->type) { + case OB_FONT: + case OB_CURVE: + case OB_SURF: /* copies object and modifiers (but not the data) */ tmpobj= copy_object(ob); @@ -130,7 +130,7 @@ static Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int free_libblock_us( &G.main->object, tmpobj ); break; - case OB_MBALL: + case OB_MBALL: /* metaballs don't have modifiers, so just convert to mesh */ ob = find_basis_mball( sce, ob ); /* todo, re-generatre for render-res */ @@ -138,9 +138,9 @@ static Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int tmpmesh = add_mesh("Mesh"); mball_to_mesh( &ob->disp, tmpmesh ); - break; + break; - case OB_MESH: + case OB_MESH: /* copies object and modifiers (but not the data) */ if (cage) { /* copies the data */ @@ -165,10 +165,10 @@ static Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int } break; - default: + default: BKE_report(reports, RPT_ERROR, "Object does not have geometry data"); - return NULL; - } + return NULL; + } /* Copy materials to new mesh */ switch (ob->type) { diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 9aedcab1301..0619f5e19b6 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -322,10 +322,21 @@ static void rna_PointCache_frame_step_range(PointerRNA *ptr, int *min, int *max) static char *rna_CollisionSettings_path(PointerRNA *ptr) { + /* both methods work ok, but return the shorter path */ +#if 0 Object *ob= (Object*)ptr->id.data; ModifierData *md = (ModifierData *)modifiers_findByType(ob, eModifierType_Collision); - - return BLI_sprintfN("modifiers[\"%s\"].settings", md->name); + + if(md) { + return BLI_sprintfN("modifiers[\"%s\"].settings", md->name); + } + else { + return BLI_strdup(""); + } +#else + /* more reliable */ + return BLI_strdup("collision"); +#endif } static int rna_SoftBodySettings_use_edges_get(PointerRNA *ptr) @@ -809,7 +820,7 @@ static void rna_def_pointcache(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_EXTERNAL); RNA_def_property_ui_text(prop, "External", "Read cache from an external location"); RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); - + prop= RNA_def_property(srna, "use_library_path", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PTCACHE_IGNORE_LIBPATH); RNA_def_property_ui_text(prop, "Library Path", "Use this files path when library linked into another file."); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index fe164cbd3c1..9fd5fafc712 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -1092,24 +1092,24 @@ static void rna_def_fluid_settings(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "SPH Fluid Settings", "Settings for particle fluids physics"); /* Fluid settings */ - prop= RNA_def_property(srna, "spring_force", PROP_FLOAT, PROP_NONE); + prop= RNA_def_property(srna, "spring_force", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "spring_k"); - RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); - RNA_def_property_ui_text(prop, "Spring Force", "Spring force"); + RNA_def_property_ui_text(prop, "Spring Force", "Spring force"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); - - prop= RNA_def_property(srna, "fluid_radius", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "radius"); - RNA_def_property_range(prop, 0.0f, 20.0f); + + prop= RNA_def_property(srna, "fluid_radius", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "radius"); + RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3); RNA_def_property_ui_text(prop, "Interaction Radius", "Fluid interaction radius"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); - prop= RNA_def_property(srna, "rest_length", PROP_FLOAT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 2.0f); + prop= RNA_def_property(srna, "rest_length", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, 2.0f); RNA_def_property_ui_text(prop, "Rest Length", "Spring rest length (factor of particle radius)"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); prop= RNA_def_property(srna, "use_viscoelastic_springs", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_VISCOELASTIC_SPRINGS); @@ -1121,70 +1121,70 @@ static void rna_def_fluid_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Initial Rest Length", "Use the initial length as spring rest length instead of 2 * particle size"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); - prop= RNA_def_property(srna, "plasticity", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "plasticity_constant"); - RNA_def_property_range(prop, 0.0f, 100.0f); - RNA_def_property_ui_text(prop, "Plasticity", "How much the spring rest length can change after the elastic limit is crossed"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); + prop= RNA_def_property(srna, "plasticity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "plasticity_constant"); + RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_ui_text(prop, "Plasticity", "How much the spring rest length can change after the elastic limit is crossed"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop= RNA_def_property(srna, "yield_ratio", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "yield_ratio"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Elastic Limit", "How much the spring has to be stretched/compressed in order to change it's rest length"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); - prop= RNA_def_property(srna, "yield_ratio", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "yield_ratio"); - RNA_def_property_range(prop, 0.0f, 1.0f); - RNA_def_property_ui_text(prop, "Elastic Limit", "How much the spring has to be stretched/compressed in order to change it's rest length"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); + prop= RNA_def_property(srna, "spring_frames", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_ui_text(prop, "Spring Frames", "Create springs for this number of frames since particles birth (0 is always)"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); - prop= RNA_def_property(srna, "spring_frames", PROP_INT, PROP_NONE); - RNA_def_property_range(prop, 0.0f, 100.0f); - RNA_def_property_ui_text(prop, "Spring Frames", "Create springs for this number of frames since particles birth (0 is always)"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); - - /* Viscosity */ - prop= RNA_def_property(srna, "linear_viscosity", PROP_FLOAT, PROP_NONE); + /* Viscosity */ + prop= RNA_def_property(srna, "linear_viscosity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "viscosity_omega"); - RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); - RNA_def_property_ui_text(prop, "Viscosity", "Linear viscosity"); + RNA_def_property_ui_text(prop, "Viscosity", "Linear viscosity"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); - - prop= RNA_def_property(srna, "stiff_viscosity", PROP_FLOAT, PROP_NONE); + + prop= RNA_def_property(srna, "stiff_viscosity", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "viscosity_beta"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3); - RNA_def_property_ui_text(prop, "Stiff viscosity", "Creates viscosity for expanding fluid)"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); + RNA_def_property_ui_text(prop, "Stiff viscosity", "Creates viscosity for expanding fluid)"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); /* Double density relaxation */ - prop= RNA_def_property(srna, "stiffness", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "stiffness_k"); - RNA_def_property_range(prop, 0.0f, 100.0f); + prop= RNA_def_property(srna, "stiffness", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "stiffness_k"); + RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_range(prop, 0.0f, 10.0f, 1, 3); - RNA_def_property_ui_text(prop, "Stiffness", "How incompressible the fluid is"); + RNA_def_property_ui_text(prop, "Stiffness", "How incompressible the fluid is"); RNA_def_property_update(prop, 0, "rna_Particle_reset"); - - prop= RNA_def_property(srna, "repulsion", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "stiffness_knear"); + + prop= RNA_def_property(srna, "repulsion", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "stiffness_knear"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3); - RNA_def_property_ui_text(prop, "Repulsion Factor", "How strongly the fluid tries to keep from clustering (factor of stiffness)"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); - - prop= RNA_def_property(srna, "rest_density", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Repulsion Factor", "How strongly the fluid tries to keep from clustering (factor of stiffness)"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop= RNA_def_property(srna, "rest_density", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rest_density"); - RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_range(prop, 0.0f, 2.0f, 1, 3); - RNA_def_property_ui_text(prop, "Rest Density", "Fluid rest density"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); - + RNA_def_property_ui_text(prop, "Rest Density", "Fluid rest density"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + /* Buoyancy */ prop= RNA_def_property(srna, "buoyancy", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "buoyancy"); - RNA_def_property_range(prop, 0.0f, 10.0f); + RNA_def_property_float_sdna(prop, NULL, "buoyancy"); + RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_range(prop, 0.0f, 1.0f, 1, 3); - RNA_def_property_ui_text(prop, "Buoyancy", "Artificial buoyancy force in negative gravity direction based on pressure differences inside the fluid"); - RNA_def_property_update(prop, 0, "rna_Particle_reset"); + RNA_def_property_ui_text(prop, "Buoyancy", "Artificial buoyancy force in negative gravity direction based on pressure differences inside the fluid"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); /* Factor flags */ - + prop= RNA_def_property(srna, "factor_repulsion", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SPH_FAC_REPULSION); RNA_def_property_ui_text(prop, "Factor Repulsion", "Repulsion is a factor of stiffness"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 69c41f20e88..cd4dc566cad 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3551,6 +3551,7 @@ void RNA_def_scene(BlenderRNA *brna) /* Layers */ prop= RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); // this seems to be too much trouble with depsgraph updates/etc. currently (20110420) RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); RNA_def_property_array(prop, 20); RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_layer_set"); diff --git a/source/blender/makesrna/intern/rna_sensor.c b/source/blender/makesrna/intern/rna_sensor.c index e19816a42f6..5bf398ae3a7 100644 --- a/source/blender/makesrna/intern/rna_sensor.c +++ b/source/blender/makesrna/intern/rna_sensor.c @@ -243,10 +243,10 @@ static void rna_Sensor_Armature_update(Main *bmain, Scene *scene, PointerRNA *pt /* note: the following set functions exists only to avoid id refcounting */ static void rna_Sensor_touch_material_set(PointerRNA *ptr, PointerRNA value) { - bSensor *sens = (bSensor *)ptr->data; - bTouchSensor *ts = (bTouchSensor *) sens->data; + bSensor *sens = (bSensor *)ptr->data; + bTouchSensor *ts = (bTouchSensor *) sens->data; - ts->ma = value.data; + ts->ma = value.data; } #else diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 3d9d8a8e9f4..b5b980aca5b 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -539,13 +539,22 @@ static void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value) st->top= 0; } +static void rna_SpaceTextEditor_updateEdited(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + SpaceText *st= (SpaceText*)ptr->data; + + if(st->text) + WM_main_add_notifier(NC_TEXT|NA_EDITED, st->text); +} + + /* Space Properties */ /* note: this function exists only to avoid id refcounting */ static void rna_SpaceProperties_pin_id_set(PointerRNA *ptr, PointerRNA value) { - SpaceButs *sbuts= (SpaceButs*)(ptr->data); - sbuts->pinid= value.data; + SpaceButs *sbuts= (SpaceButs*)(ptr->data); + sbuts->pinid= value.data; } static StructRNA *rna_SpaceProperties_pin_id_typef(PointerRNA *ptr) @@ -644,7 +653,32 @@ static void rna_ConsoleLine_cursor_index_range(PointerRNA *ptr, int *min, int *m static void rna_SpaceDopeSheetEditor_action_set(PointerRNA *ptr, PointerRNA value) { SpaceAction *saction= (SpaceAction*)(ptr->data); - saction->action= value.data; + bAction *act = (bAction*)value.data; + + if ((act == NULL) || (act->idroot == 0)) { + /* just set if we're clearing the action or if the action is "amorphous" still */ + saction->action= act; + } + else { + /* action to set must strictly meet the mode criteria... */ + if (saction->mode == SACTCONT_ACTION) { + /* currently, this is "object-level" only, until we have some way of specifying this */ + if (act->idroot == ID_OB) + saction->action = act; + else + printf("ERROR: cannot assign Action '%s' to Action Editor, as action is not object-level animation\n", act->id.name+2); + } + else if (saction->mode == SACTCONT_SHAPEKEY) { + /* as the name says, "shapekey-level" only... */ + if (act->idroot == ID_KE) + saction->action = act; + else + printf("ERROR: cannot assign Action '%s' to Shape Key Editor, as action doesn't animate Shape Keys\n", act->id.name+2); + } + else { + printf("ACK: who's trying to set an action while not in a mode displaying a single Action only?\n"); + } + } } static void rna_SpaceDopeSheetEditor_action_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -1418,7 +1452,7 @@ static void rna_def_space_buttons(BlenderRNA *brna) prop= RNA_def_property(srna, "pin_id", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "pinid"); RNA_def_property_struct_type(prop, "ID"); - /* note: custom set function is ONLY to avoid rna setting a user for this. */ + /* note: custom set function is ONLY to avoid rna setting a user for this. */ RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceProperties_pin_id_set", "rna_SpaceProperties_pin_id_typef", NULL); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_PROPERTIES, "rna_SpaceProperties_pin_id_update"); @@ -1699,7 +1733,7 @@ static void rna_def_space_text(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "tabnumber"); RNA_def_property_range(prop, 2, 8); RNA_def_property_ui_text(prop, "Tab Width", "Number of spaces to display tabs with"); - RNA_def_property_update(prop, NC_TEXT|NA_EDITED, NULL); + RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TEXT, "rna_SpaceTextEditor_updateEdited"); prop= RNA_def_property(srna, "font_size", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "lheight"); @@ -1771,7 +1805,7 @@ static void rna_def_space_dopesheet(BlenderRNA *brna) /* data */ prop= RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceDopeSheetEditor_action_set", NULL, NULL); + RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceDopeSheetEditor_action_set", NULL, "rna_Action_actedit_assign_poll"); RNA_def_property_ui_text(prop, "Action", "Action displayed and edited in this space"); RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, "rna_SpaceDopeSheetEditor_action_update"); @@ -2355,7 +2389,7 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "zoom"); RNA_def_property_float_default(prop, 1.0f); RNA_def_property_range(prop, 0.01f, FLT_MAX); - RNA_def_property_ui_range(prop, 0.01, 100, 1, 2); + RNA_def_property_ui_range(prop, 0.01, 100, 1, 2); RNA_def_property_ui_text(prop, "Backdrop Zoom", "Backdrop zoom factor"); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_NODE_VIEW, NULL); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 82eb5d1d0c9..d8eec152831 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1638,6 +1638,7 @@ static void rna_def_texture_voxeldata(BlenderRNA *brna) prop= RNA_def_property(srna, "resolution", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resol"); + RNA_def_property_range(prop, 1, 100000); RNA_def_property_ui_text(prop, "Resolution", "Resolution of the voxel grid"); RNA_def_property_update(prop, 0, "rna_Texture_voxeldata_update"); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 84a6725807a..a914d875490 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1988,7 +1988,7 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_VIEWPORTNAME); RNA_def_property_ui_text(prop, "Show View Name", "Show the name of the view's direction in each 3D View"); RNA_def_property_update(prop, 0, "rna_userdef_update"); - + prop= RNA_def_property(srna, "show_splash", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "uiflag", USER_SPLASH_DISABLE); RNA_def_property_ui_text(prop, "Show Splash", "Display splash screen on startup"); @@ -2651,8 +2651,8 @@ static void rna_def_userdef_input(BlenderRNA *brna) {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem view_zoom_axes[] = { - {0, "VERTICAL", 0, "Vertical", "Zooms in and out based on vertical mouse movement"}, - {USER_ZOOM_DOLLY_HORIZ, "HORIZONTAL", 0, "Horizontal", "Zooms in and out based on horizontal mouse movement"}, + {0, "VERTICAL", 0, "Vertical", "Zooms in and out based on vertical mouse movement"}, + {USER_ZOOM_HORIZ, "HORIZONTAL", 0, "Horizontal", "Zooms in and out based on horizontal mouse movement"}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "UserPreferencesInput", NULL); @@ -2676,7 +2676,7 @@ static void rna_def_userdef_input(BlenderRNA *brna) RNA_def_property_enum_items(prop, view_zoom_axes); RNA_def_property_ui_text(prop, "Zoom Axis", "Axis of mouse movement to zoom in or out on"); - prop= RNA_def_property(srna, "invert_mouse_wheel_zoom", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "invert_mouse_zoom", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_ZOOM_INVERT); RNA_def_property_ui_text(prop, "Invert Zoom Direction", "Invert the axis of mouse movement for zooming"); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index a6b6ae26ca5..4c79c27e0de 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1232,7 +1232,7 @@ static void rna_def_macro_operator(BlenderRNA *brna) #ifdef WITH_PYTHON RNA_def_struct_register_funcs(srna, "rna_MacroOperator_register", "rna_Operator_unregister"); #endif - + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_string_funcs(prop, "rna_Operator_name_get", "rna_Operator_name_length", NULL); diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 3a34b048aa3..90954fef1c7 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -313,60 +313,60 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, else /* if the offset has no translation, just make one copy */ count = 1; - } + } - if(count < 1) - count = 1; + if(count < 1) + count = 1; /* allocate memory for count duplicates (including original) plus * start and end caps */ - finalVerts = dm->getNumVerts(dm) * count; - finalEdges = dm->getNumEdges(dm) * count; - finalFaces = dm->getNumFaces(dm) * count; - if(start_cap) { - finalVerts += start_cap->getNumVerts(start_cap); - finalEdges += start_cap->getNumEdges(start_cap); - finalFaces += start_cap->getNumFaces(start_cap); - } - if(end_cap) { - finalVerts += end_cap->getNumVerts(end_cap); - finalEdges += end_cap->getNumEdges(end_cap); - finalFaces += end_cap->getNumFaces(end_cap); - } - result = CDDM_from_template(dm, finalVerts, finalEdges, finalFaces); - - /* calculate the offset matrix of the final copy (for merging) */ - unit_m4(final_offset); - - for(j=0; j < count - 1; j++) { - mul_m4_m4m4(tmp_mat, final_offset, offset); - copy_m4_m4(final_offset, tmp_mat); - } - - numVerts = numEdges = numFaces = 0; - mvert = CDDM_get_verts(result); - - for (i = 0; i < maxVerts; i++) { - indexMap[i].merge = -1; /* default to no merge */ - indexMap[i].merge_final = 0; /* default to no merge */ - } - - for (i = 0; i < maxVerts; i++) { - MVert *inMV; - MVert *mv = &mvert[numVerts]; - MVert *mv2; - float co[3]; - - inMV = &src_mvert[i]; - - DM_copy_vert_data(dm, result, i, numVerts, 1); - *mv = *inMV; - numVerts++; - - indexMap[i].new = numVerts - 1; - - copy_v3_v3(co, mv->co); + finalVerts = dm->getNumVerts(dm) * count; + finalEdges = dm->getNumEdges(dm) * count; + finalFaces = dm->getNumFaces(dm) * count; + if(start_cap) { + finalVerts += start_cap->getNumVerts(start_cap); + finalEdges += start_cap->getNumEdges(start_cap); + finalFaces += start_cap->getNumFaces(start_cap); + } + if(end_cap) { + finalVerts += end_cap->getNumVerts(end_cap); + finalEdges += end_cap->getNumEdges(end_cap); + finalFaces += end_cap->getNumFaces(end_cap); + } + result = CDDM_from_template(dm, finalVerts, finalEdges, finalFaces); + + /* calculate the offset matrix of the final copy (for merging) */ + unit_m4(final_offset); + + for(j=0; j < count - 1; j++) { + mul_m4_m4m4(tmp_mat, final_offset, offset); + copy_m4_m4(final_offset, tmp_mat); + } + + numVerts = numEdges = numFaces = 0; + mvert = CDDM_get_verts(result); + + for (i = 0; i < maxVerts; i++) { + indexMap[i].merge = -1; /* default to no merge */ + indexMap[i].merge_final = 0; /* default to no merge */ + } + + for (i = 0; i < maxVerts; i++) { + MVert *inMV; + MVert *mv = &mvert[numVerts]; + MVert *mv2; + float co[3]; + + inMV = &src_mvert[i]; + + DM_copy_vert_data(dm, result, i, numVerts, 1); + *mv = *inMV; + numVerts++; + + indexMap[i].new = numVerts - 1; + + copy_v3_v3(co, mv->co); /* Attempts to merge verts from one duplicate with verts from the * next duplicate which are closer than amd->merge_dist. @@ -374,405 +374,405 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, * If verts are merged in the first duplicate pair, they are merged * in all pairs. */ - if((count > 1) && (amd->flags & MOD_ARR_MERGE)) { - float tmp_co[3]; - mul_v3_m4v3(tmp_co, offset, mv->co); - - for(j = 0; j < maxVerts; j++) { - /* if vertex already merged, don't use it */ - if( indexMap[j].merge != -1 ) continue; - - inMV = &src_mvert[j]; - /* if this vert is within merge limit, merge */ - if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist)) { - indexMap[i].merge = j; - - /* test for merging with final copy of merge target */ - if(amd->flags & MOD_ARR_MERGEFINAL) { - copy_v3_v3(tmp_co, inMV->co); - inMV = &src_mvert[i]; - mul_m4_v3(final_offset, tmp_co); - if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist)) - indexMap[i].merge_final = 1; - } - break; - } - } - } - - /* if no merging, generate copies of this vert */ - if(indexMap[i].merge < 0) { - for(j=0; j < count - 1; j++) { - mv2 = &mvert[numVerts]; - - DM_copy_vert_data(result, result, numVerts - 1, numVerts, 1); - *mv2 = *mv; - numVerts++; - - mul_m4_v3(offset, co); - copy_v3_v3(mv2->co, co); - } - } else if(indexMap[i].merge != i && indexMap[i].merge_final) { + if((count > 1) && (amd->flags & MOD_ARR_MERGE)) { + float tmp_co[3]; + mul_v3_m4v3(tmp_co, offset, mv->co); + + for(j = 0; j < maxVerts; j++) { + /* if vertex already merged, don't use it */ + if( indexMap[j].merge != -1 ) continue; + + inMV = &src_mvert[j]; + /* if this vert is within merge limit, merge */ + if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist)) { + indexMap[i].merge = j; + + /* test for merging with final copy of merge target */ + if(amd->flags & MOD_ARR_MERGEFINAL) { + copy_v3_v3(tmp_co, inMV->co); + inMV = &src_mvert[i]; + mul_m4_v3(final_offset, tmp_co); + if(compare_len_v3v3(tmp_co, inMV->co, amd->merge_dist)) + indexMap[i].merge_final = 1; + } + break; + } + } + } + + /* if no merging, generate copies of this vert */ + if(indexMap[i].merge < 0) { + for(j=0; j < count - 1; j++) { + mv2 = &mvert[numVerts]; + + DM_copy_vert_data(result, result, numVerts - 1, numVerts, 1); + *mv2 = *mv; + numVerts++; + + mul_m4_v3(offset, co); + copy_v3_v3(mv2->co, co); + } + } else if(indexMap[i].merge != i && indexMap[i].merge_final) { /* if this vert is not merging with itself, and it is merging * with the final copy of its merge target, remove the first copy */ - numVerts--; - DM_free_vert_data(result, numVerts, 1); - } - } + numVerts--; + DM_free_vert_data(result, numVerts, 1); + } + } - /* make a hashtable so we can avoid duplicate edges from merging */ - edges = BLI_edgehash_new(); + /* make a hashtable so we can avoid duplicate edges from merging */ + edges = BLI_edgehash_new(); - maxEdges = dm->getNumEdges(dm); - medge = CDDM_get_edges(result); - for(i = 0; i < maxEdges; i++) { - MEdge inMED; - MEdge med; - MEdge *med2; - int vert1, vert2; + maxEdges = dm->getNumEdges(dm); + medge = CDDM_get_edges(result); + for(i = 0; i < maxEdges; i++) { + MEdge inMED; + MEdge med; + MEdge *med2; + int vert1, vert2; - dm->getEdge(dm, i, &inMED); + dm->getEdge(dm, i, &inMED); - med = inMED; - med.v1 = indexMap[inMED.v1].new; - med.v2 = indexMap[inMED.v2].new; + med = inMED; + med.v1 = indexMap[inMED.v1].new; + med.v2 = indexMap[inMED.v2].new; /* if vertices are to be merged with the final copies of their * merge targets, calculate that final copy */ - if(indexMap[inMED.v1].merge_final) { - med.v1 = calc_mapping(indexMap, indexMap[inMED.v1].merge, - count - 1); - } - if(indexMap[inMED.v2].merge_final) { - med.v2 = calc_mapping(indexMap, indexMap[inMED.v2].merge, - count - 1); - } - - if(med.v1 == med.v2) continue; - - /* XXX Unfortunately the calc_mapping returns sometimes numVerts... leads to bad crashes */ - if(med.v1 >= numVerts) - med.v1= numVerts-1; - if(med.v2 >= numVerts) - med.v2= numVerts-1; - - if (initFlags) { - med.flag |= ME_EDGEDRAW | ME_EDGERENDER; - } - - if(!BLI_edgehash_haskey(edges, med.v1, med.v2)) { - DM_copy_edge_data(dm, result, i, numEdges, 1); - medge[numEdges] = med; - numEdges++; - - BLI_edgehash_insert(edges, med.v1, med.v2, NULL); - } - - for(j = 1; j < count; j++) - { - vert1 = calc_mapping(indexMap, inMED.v1, j); - vert2 = calc_mapping(indexMap, inMED.v2, j); - - /* edge could collapse to single point after mapping */ - if(vert1 == vert2) continue; - - /* XXX Unfortunately the calc_mapping returns sometimes numVerts... leads to bad crashes */ - if(vert1 >= numVerts) - vert1= numVerts-1; - if(vert2 >= numVerts) - vert2= numVerts-1; - - /* avoid duplicate edges */ - if(!BLI_edgehash_haskey(edges, vert1, vert2)) { - med2 = &medge[numEdges]; - - DM_copy_edge_data(dm, result, i, numEdges, 1); - *med2 = med; - numEdges++; - - med2->v1 = vert1; - med2->v2 = vert2; - - BLI_edgehash_insert(edges, med2->v1, med2->v2, NULL); - } - } - } - - maxFaces = dm->getNumFaces(dm); - mface = CDDM_get_faces(result); - for (i=0; i < maxFaces; i++) { - MFace inMF; - MFace *mf = &mface[numFaces]; - - dm->getFace(dm, i, &inMF); - - DM_copy_face_data(dm, result, i, numFaces, 1); - *mf = inMF; - - mf->v1 = indexMap[inMF.v1].new; - mf->v2 = indexMap[inMF.v2].new; - mf->v3 = indexMap[inMF.v3].new; - if(inMF.v4) - mf->v4 = indexMap[inMF.v4].new; + if(indexMap[inMED.v1].merge_final) { + med.v1 = calc_mapping(indexMap, indexMap[inMED.v1].merge, + count - 1); + } + if(indexMap[inMED.v2].merge_final) { + med.v2 = calc_mapping(indexMap, indexMap[inMED.v2].merge, + count - 1); + } + + if(med.v1 == med.v2) continue; + + /* XXX Unfortunately the calc_mapping returns sometimes numVerts... leads to bad crashes */ + if(med.v1 >= numVerts) + med.v1= numVerts-1; + if(med.v2 >= numVerts) + med.v2= numVerts-1; + + if (initFlags) { + med.flag |= ME_EDGEDRAW | ME_EDGERENDER; + } + + if(!BLI_edgehash_haskey(edges, med.v1, med.v2)) { + DM_copy_edge_data(dm, result, i, numEdges, 1); + medge[numEdges] = med; + numEdges++; + + BLI_edgehash_insert(edges, med.v1, med.v2, NULL); + } + + for(j = 1; j < count; j++) + { + vert1 = calc_mapping(indexMap, inMED.v1, j); + vert2 = calc_mapping(indexMap, inMED.v2, j); + + /* edge could collapse to single point after mapping */ + if(vert1 == vert2) continue; + + /* XXX Unfortunately the calc_mapping returns sometimes numVerts... leads to bad crashes */ + if(vert1 >= numVerts) + vert1= numVerts-1; + if(vert2 >= numVerts) + vert2= numVerts-1; + + /* avoid duplicate edges */ + if(!BLI_edgehash_haskey(edges, vert1, vert2)) { + med2 = &medge[numEdges]; + + DM_copy_edge_data(dm, result, i, numEdges, 1); + *med2 = med; + numEdges++; + + med2->v1 = vert1; + med2->v2 = vert2; + + BLI_edgehash_insert(edges, med2->v1, med2->v2, NULL); + } + } + } + + maxFaces = dm->getNumFaces(dm); + mface = CDDM_get_faces(result); + for (i=0; i < maxFaces; i++) { + MFace inMF; + MFace *mf = &mface[numFaces]; + + dm->getFace(dm, i, &inMF); + + DM_copy_face_data(dm, result, i, numFaces, 1); + *mf = inMF; + + mf->v1 = indexMap[inMF.v1].new; + mf->v2 = indexMap[inMF.v2].new; + mf->v3 = indexMap[inMF.v3].new; + if(inMF.v4) + mf->v4 = indexMap[inMF.v4].new; /* if vertices are to be merged with the final copies of their * merge targets, calculate that final copy */ - if(indexMap[inMF.v1].merge_final) - mf->v1 = calc_mapping(indexMap, indexMap[inMF.v1].merge, count-1); - if(indexMap[inMF.v2].merge_final) - mf->v2 = calc_mapping(indexMap, indexMap[inMF.v2].merge, count-1); - if(indexMap[inMF.v3].merge_final) - mf->v3 = calc_mapping(indexMap, indexMap[inMF.v3].merge, count-1); - if(inMF.v4 && indexMap[inMF.v4].merge_final) - mf->v4 = calc_mapping(indexMap, indexMap[inMF.v4].merge, count-1); - - if(test_index_face_maxvert(mf, &result->faceData, numFaces, inMF.v4?4:3, numVerts) < 3) - continue; - - numFaces++; - - /* if the face has fewer than 3 vertices, don't create it */ - if(mf->v3 == 0 || (mf->v1 && (mf->v1 == mf->v3 || mf->v1 == mf->v4))) { - numFaces--; - DM_free_face_data(result, numFaces, 1); - } - - for(j = 1; j < count; j++) - { - MFace *mf2 = &mface[numFaces]; - - DM_copy_face_data(dm, result, i, numFaces, 1); - *mf2 = *mf; - - mf2->v1 = calc_mapping(indexMap, inMF.v1, j); - mf2->v2 = calc_mapping(indexMap, inMF.v2, j); - mf2->v3 = calc_mapping(indexMap, inMF.v3, j); - if (inMF.v4) - mf2->v4 = calc_mapping(indexMap, inMF.v4, j); - - numFaces++; - - /* if the face has fewer than 3 vertices, don't create it */ - if(test_index_face_maxvert(mf2, &result->faceData, numFaces-1, inMF.v4?4:3, numVerts) < 3) { - numFaces--; - DM_free_face_data(result, numFaces, 1); - } - } - } - - /* add start and end caps */ - if(start_cap) { - float startoffset[4][4]; - MVert *cap_mvert; - MEdge *cap_medge; - MFace *cap_mface; - int *origindex; - int *vert_map; - int capVerts, capEdges, capFaces; - - capVerts = start_cap->getNumVerts(start_cap); - capEdges = start_cap->getNumEdges(start_cap); - capFaces = start_cap->getNumFaces(start_cap); - cap_mvert = start_cap->getVertArray(start_cap); - cap_medge = start_cap->getEdgeArray(start_cap); - cap_mface = start_cap->getFaceArray(start_cap); - - invert_m4_m4(startoffset, offset); - - vert_map = MEM_callocN(sizeof(*vert_map) * capVerts, - "arrayModifier_doArray vert_map"); - - origindex = result->getVertDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capVerts; i++) { - MVert *mv = &cap_mvert[i]; - short merged = 0; - - if(amd->flags & MOD_ARR_MERGE) { - float tmp_co[3]; - MVert *in_mv; - int j; - - copy_v3_v3(tmp_co, mv->co); - mul_m4_v3(startoffset, tmp_co); - - for(j = 0; j < maxVerts; j++) { - in_mv = &src_mvert[j]; - /* if this vert is within merge limit, merge */ - if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) { - vert_map[i] = calc_mapping(indexMap, j, 0); - merged = 1; - break; - } - } - } - - if(!merged) { - DM_copy_vert_data(start_cap, result, i, numVerts, 1); - mvert[numVerts] = *mv; - mul_m4_v3(startoffset, mvert[numVerts].co); - origindex[numVerts] = ORIGINDEX_NONE; - - vert_map[i] = numVerts; - - numVerts++; - } - } - origindex = result->getEdgeDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capEdges; i++) { - int v1, v2; - - v1 = vert_map[cap_medge[i].v1]; - v2 = vert_map[cap_medge[i].v2]; - - if(!BLI_edgehash_haskey(edges, v1, v2)) { - DM_copy_edge_data(start_cap, result, i, numEdges, 1); - medge[numEdges] = cap_medge[i]; - medge[numEdges].v1 = v1; - medge[numEdges].v2 = v2; - origindex[numEdges] = ORIGINDEX_NONE; - - numEdges++; - } - } - origindex = result->getFaceDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capFaces; i++) { - DM_copy_face_data(start_cap, result, i, numFaces, 1); - mface[numFaces] = cap_mface[i]; - mface[numFaces].v1 = vert_map[mface[numFaces].v1]; - mface[numFaces].v2 = vert_map[mface[numFaces].v2]; - mface[numFaces].v3 = vert_map[mface[numFaces].v3]; - if(mface[numFaces].v4) { - mface[numFaces].v4 = vert_map[mface[numFaces].v4]; - - test_index_face_maxvert(&mface[numFaces], &result->faceData, - numFaces, 4, numVerts); - } - else - { - test_index_face(&mface[numFaces], &result->faceData, - numFaces, 3); - } - - origindex[numFaces] = ORIGINDEX_NONE; - - numFaces++; - } - - MEM_freeN(vert_map); - start_cap->release(start_cap); - } - - if(end_cap) { - float endoffset[4][4]; - MVert *cap_mvert; - MEdge *cap_medge; - MFace *cap_mface; - int *origindex; - int *vert_map; - int capVerts, capEdges, capFaces; - - capVerts = end_cap->getNumVerts(end_cap); - capEdges = end_cap->getNumEdges(end_cap); - capFaces = end_cap->getNumFaces(end_cap); - cap_mvert = end_cap->getVertArray(end_cap); - cap_medge = end_cap->getEdgeArray(end_cap); - cap_mface = end_cap->getFaceArray(end_cap); - - mul_m4_m4m4(endoffset, final_offset, offset); - - vert_map = MEM_callocN(sizeof(*vert_map) * capVerts, - "arrayModifier_doArray vert_map"); - - origindex = result->getVertDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capVerts; i++) { - MVert *mv = &cap_mvert[i]; - short merged = 0; - - if(amd->flags & MOD_ARR_MERGE) { - float tmp_co[3]; - MVert *in_mv; - int j; - - copy_v3_v3(tmp_co, mv->co); - mul_m4_v3(offset, tmp_co); - - for(j = 0; j < maxVerts; j++) { - in_mv = &src_mvert[j]; - /* if this vert is within merge limit, merge */ - if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) { - vert_map[i] = calc_mapping(indexMap, j, count - 1); - merged = 1; - break; - } - } - } - - if(!merged) { - DM_copy_vert_data(end_cap, result, i, numVerts, 1); - mvert[numVerts] = *mv; - mul_m4_v3(endoffset, mvert[numVerts].co); - origindex[numVerts] = ORIGINDEX_NONE; - - vert_map[i] = numVerts; - - numVerts++; - } - } - origindex = result->getEdgeDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capEdges; i++) { - int v1, v2; - - v1 = vert_map[cap_medge[i].v1]; - v2 = vert_map[cap_medge[i].v2]; - - if(!BLI_edgehash_haskey(edges, v1, v2)) { - DM_copy_edge_data(end_cap, result, i, numEdges, 1); - medge[numEdges] = cap_medge[i]; - medge[numEdges].v1 = v1; - medge[numEdges].v2 = v2; - origindex[numEdges] = ORIGINDEX_NONE; - - numEdges++; - } - } - origindex = result->getFaceDataArray(result, CD_ORIGINDEX); - for(i = 0; i < capFaces; i++) { - DM_copy_face_data(end_cap, result, i, numFaces, 1); - mface[numFaces] = cap_mface[i]; - mface[numFaces].v1 = vert_map[mface[numFaces].v1]; - mface[numFaces].v2 = vert_map[mface[numFaces].v2]; - mface[numFaces].v3 = vert_map[mface[numFaces].v3]; - if(mface[numFaces].v4) { - mface[numFaces].v4 = vert_map[mface[numFaces].v4]; - - test_index_face(&mface[numFaces], &result->faceData, - numFaces, 4); - } - else - { - test_index_face(&mface[numFaces], &result->faceData, - numFaces, 3); - } - origindex[numFaces] = ORIGINDEX_NONE; - - numFaces++; - } - - MEM_freeN(vert_map); - end_cap->release(end_cap); - } - - BLI_edgehash_free(edges, NULL); - MEM_freeN(indexMap); - - CDDM_lower_num_verts(result, numVerts); - CDDM_lower_num_edges(result, numEdges); - CDDM_lower_num_faces(result, numFaces); - - return result; + if(indexMap[inMF.v1].merge_final) + mf->v1 = calc_mapping(indexMap, indexMap[inMF.v1].merge, count-1); + if(indexMap[inMF.v2].merge_final) + mf->v2 = calc_mapping(indexMap, indexMap[inMF.v2].merge, count-1); + if(indexMap[inMF.v3].merge_final) + mf->v3 = calc_mapping(indexMap, indexMap[inMF.v3].merge, count-1); + if(inMF.v4 && indexMap[inMF.v4].merge_final) + mf->v4 = calc_mapping(indexMap, indexMap[inMF.v4].merge, count-1); + + if(test_index_face_maxvert(mf, &result->faceData, numFaces, inMF.v4?4:3, numVerts) < 3) + continue; + + numFaces++; + + /* if the face has fewer than 3 vertices, don't create it */ + if(mf->v3 == 0 || (mf->v1 && (mf->v1 == mf->v3 || mf->v1 == mf->v4))) { + numFaces--; + DM_free_face_data(result, numFaces, 1); + } + + for(j = 1; j < count; j++) + { + MFace *mf2 = &mface[numFaces]; + + DM_copy_face_data(dm, result, i, numFaces, 1); + *mf2 = *mf; + + mf2->v1 = calc_mapping(indexMap, inMF.v1, j); + mf2->v2 = calc_mapping(indexMap, inMF.v2, j); + mf2->v3 = calc_mapping(indexMap, inMF.v3, j); + if (inMF.v4) + mf2->v4 = calc_mapping(indexMap, inMF.v4, j); + + numFaces++; + + /* if the face has fewer than 3 vertices, don't create it */ + if(test_index_face_maxvert(mf2, &result->faceData, numFaces-1, inMF.v4?4:3, numVerts) < 3) { + numFaces--; + DM_free_face_data(result, numFaces, 1); + } + } + } + + /* add start and end caps */ + if(start_cap) { + float startoffset[4][4]; + MVert *cap_mvert; + MEdge *cap_medge; + MFace *cap_mface; + int *origindex; + int *vert_map; + int capVerts, capEdges, capFaces; + + capVerts = start_cap->getNumVerts(start_cap); + capEdges = start_cap->getNumEdges(start_cap); + capFaces = start_cap->getNumFaces(start_cap); + cap_mvert = start_cap->getVertArray(start_cap); + cap_medge = start_cap->getEdgeArray(start_cap); + cap_mface = start_cap->getFaceArray(start_cap); + + invert_m4_m4(startoffset, offset); + + vert_map = MEM_callocN(sizeof(*vert_map) * capVerts, + "arrayModifier_doArray vert_map"); + + origindex = result->getVertDataArray(result, CD_ORIGINDEX); + for(i = 0; i < capVerts; i++) { + MVert *mv = &cap_mvert[i]; + short merged = 0; + + if(amd->flags & MOD_ARR_MERGE) { + float tmp_co[3]; + MVert *in_mv; + int j; + + copy_v3_v3(tmp_co, mv->co); + mul_m4_v3(startoffset, tmp_co); + + for(j = 0; j < maxVerts; j++) { + in_mv = &src_mvert[j]; + /* if this vert is within merge limit, merge */ + if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) { + vert_map[i] = calc_mapping(indexMap, j, 0); + merged = 1; + break; + } + } + } + + if(!merged) { + DM_copy_vert_data(start_cap, result, i, numVerts, 1); + mvert[numVerts] = *mv; + mul_m4_v3(startoffset, mvert[numVerts].co); + origindex[numVerts] = ORIGINDEX_NONE; + + vert_map[i] = numVerts; + + numVerts++; + } + } + origindex = result->getEdgeDataArray(result, CD_ORIGINDEX); + for(i = 0; i < capEdges; i++) { + int v1, v2; + + v1 = vert_map[cap_medge[i].v1]; + v2 = vert_map[cap_medge[i].v2]; + + if(!BLI_edgehash_haskey(edges, v1, v2)) { + DM_copy_edge_data(start_cap, result, i, numEdges, 1); + medge[numEdges] = cap_medge[i]; + medge[numEdges].v1 = v1; + medge[numEdges].v2 = v2; + origindex[numEdges] = ORIGINDEX_NONE; + + numEdges++; + } + } + origindex = result->getFaceDataArray(result, CD_ORIGINDEX); + for(i = 0; i < capFaces; i++) { + DM_copy_face_data(start_cap, result, i, numFaces, 1); + mface[numFaces] = cap_mface[i]; + mface[numFaces].v1 = vert_map[mface[numFaces].v1]; + mface[numFaces].v2 = vert_map[mface[numFaces].v2]; + mface[numFaces].v3 = vert_map[mface[numFaces].v3]; + if(mface[numFaces].v4) { + mface[numFaces].v4 = vert_map[mface[numFaces].v4]; + + test_index_face_maxvert(&mface[numFaces], &result->faceData, + numFaces, 4, numVerts); + } + else + { + test_index_face(&mface[numFaces], &result->faceData, + numFaces, 3); + } + + origindex[numFaces] = ORIGINDEX_NONE; + + numFaces++; + } + + MEM_freeN(vert_map); + start_cap->release(start_cap); + } + + if(end_cap) { + float endoffset[4][4]; + MVert *cap_mvert; + MEdge *cap_medge; + MFace *cap_mface; + int *origindex; + int *vert_map; + int capVerts, capEdges, capFaces; + + capVerts = end_cap->getNumVerts(end_cap); + capEdges = end_cap->getNumEdges(end_cap); + capFaces = end_cap->getNumFaces(end_cap); + cap_mvert = end_cap->getVertArray(end_cap); + cap_medge = end_cap->getEdgeArray(end_cap); + cap_mface = end_cap->getFaceArray(end_cap); + + mul_m4_m4m4(endoffset, final_offset, offset); + + vert_map = MEM_callocN(sizeof(*vert_map) * capVerts, + "arrayModifier_doArray vert_map"); + + origindex = result->getVertDataArray(result, CD_ORIGINDEX); + for(i = 0; i < capVerts; i++) { + MVert *mv = &cap_mvert[i]; + short merged = 0; + + if(amd->flags & MOD_ARR_MERGE) { + float tmp_co[3]; + MVert *in_mv; + int j; + + copy_v3_v3(tmp_co, mv->co); + mul_m4_v3(offset, tmp_co); + + for(j = 0; j < maxVerts; j++) { + in_mv = &src_mvert[j]; + /* if this vert is within merge limit, merge */ + if(compare_len_v3v3(tmp_co, in_mv->co, amd->merge_dist)) { + vert_map[i] = calc_mapping(indexMap, j, count - 1); + merged = 1; + break; + } + } + } + + if(!merged) { + DM_copy_vert_data(end_cap, result, i, numVerts, 1); + mvert[numVerts] = *mv; + mul_m4_v3(endoffset, mvert[numVerts].co); + origindex[numVerts] = ORIGINDEX_NONE; + + vert_map[i] = numVerts; + + numVerts++; + } + } + origindex = result->getEdgeDataArray(result, CD_ORIGINDEX); + for(i = 0; i < capEdges; i++) { + int v1, v2; + + v1 = vert_map[cap_medge[i].v1]; + v2 = vert_map[cap_medge[i].v2]; + + if(!BLI_edgehash_haskey(edges, v1, v2)) { + DM_copy_edge_data(end_cap, result, i, numEdges, 1); + medge[numEdges] = cap_medge[i]; + medge[numEdges].v1 = v1; + medge[numEdges].v2 = v2; + origindex[numEdges] = ORIGINDEX_NONE; + + numEdges++; + } + } + origindex = result->getFaceDataArray(result, CD_ORIGINDEX); + for(i = 0; i < capFaces; i++) { + DM_copy_face_data(end_cap, result, i, numFaces, 1); + mface[numFaces] = cap_mface[i]; + mface[numFaces].v1 = vert_map[mface[numFaces].v1]; + mface[numFaces].v2 = vert_map[mface[numFaces].v2]; + mface[numFaces].v3 = vert_map[mface[numFaces].v3]; + if(mface[numFaces].v4) { + mface[numFaces].v4 = vert_map[mface[numFaces].v4]; + + test_index_face(&mface[numFaces], &result->faceData, + numFaces, 4); + } + else + { + test_index_face(&mface[numFaces], &result->faceData, + numFaces, 3); + } + origindex[numFaces] = ORIGINDEX_NONE; + + numFaces++; + } + + MEM_freeN(vert_map); + end_cap->release(end_cap); + } + + BLI_edgehash_free(edges, NULL); + MEM_freeN(indexMap); + + CDDM_lower_num_verts(result, numVerts); + CDDM_lower_num_edges(result, numEdges); + CDDM_lower_num_faces(result, numFaces); + + return result; } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index 1cf67ac8cae..e293be5886d 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -212,17 +212,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, !BLI_ghashIterator_isDone(hashIter); BLI_ghashIterator_step(hashIter) ) { - MVert source; - MVert *dest; - int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter)); - int newIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(hashIter)); + MVert source; + MVert *dest; + int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter)); + int newIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(hashIter)); - dm->getVert(dm, oldIndex, &source); - dest = CDDM_get_vert(result, newIndex); + dm->getVert(dm, oldIndex, &source); + dest = CDDM_get_vert(result, newIndex); - DM_copy_vert_data(dm, result, oldIndex, newIndex, 1); - *dest = source; - } + DM_copy_vert_data(dm, result, oldIndex, newIndex, 1); + *dest = source; + } BLI_ghashIterator_free(hashIter); /* copy the edges across, remapping indices */ diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 09e29d9ed8e..22ba1447d20 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -175,11 +175,11 @@ static SmoothMesh *smoothmesh_new(int num_verts, int num_edges, int num_faces, { SmoothMesh *mesh = MEM_callocN(sizeof(*mesh), "smoothmesh"); mesh->verts = MEM_callocN(sizeof(*mesh->verts) * max_verts, - "SmoothMesh.verts"); + "SmoothMesh.verts"); mesh->edges = MEM_callocN(sizeof(*mesh->edges) * max_edges, - "SmoothMesh.edges"); + "SmoothMesh.edges"); mesh->faces = MEM_callocN(sizeof(*mesh->faces) * max_faces, - "SmoothMesh.faces"); + "SmoothMesh.faces"); mesh->num_verts = num_verts; mesh->num_edges = num_edges; @@ -280,8 +280,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); @@ -296,8 +296,8 @@ static void smoothmesh_print(SmoothMesh *mesh) printf("%4d: indices={%4d, %4d}, verts={%4d, %4d}", i, - edge->oldIndex, edge->newIndex, - edge->verts[0]->newIndex, edge->verts[1]->newIndex); + 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 +311,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); @@ -339,7 +339,7 @@ static SmoothMesh *smoothmesh_from_derivedmesh(DerivedMesh *dm) totface = dm->getNumFaces(dm); mesh = smoothmesh_new(totvert, totedge, totface, - totvert, totedge, totface); + totvert, totedge, totface); mesh->dm = dm; @@ -410,8 +410,8 @@ static DerivedMesh *CDDM_from_smoothmesh(SmoothMesh *mesh) { DerivedMesh *result = CDDM_from_template(mesh->dm, mesh->num_verts, - mesh->num_edges, - mesh->num_faces); + mesh->num_edges, + mesh->num_faces); MVert *new_verts = CDDM_get_verts(result); MEdge *new_edges = CDDM_get_edges(result); MFace *new_faces = CDDM_get_faces(result); @@ -422,7 +422,7 @@ static DerivedMesh *CDDM_from_smoothmesh(SmoothMesh *mesh) MVert *newMV = &new_verts[vert->newIndex]; DM_copy_vert_data(mesh->dm, result, - vert->oldIndex, vert->newIndex, 1); + vert->oldIndex, vert->newIndex, 1); mesh->dm->getVert(mesh->dm, vert->oldIndex, newMV); } @@ -431,7 +431,7 @@ static DerivedMesh *CDDM_from_smoothmesh(SmoothMesh *mesh) MEdge *newME = &new_edges[edge->newIndex]; DM_copy_edge_data(mesh->dm, result, - edge->oldIndex, edge->newIndex, 1); + edge->oldIndex, edge->newIndex, 1); mesh->dm->getEdge(mesh->dm, edge->oldIndex, newME); newME->v1 = edge->verts[0]->newIndex; newME->v2 = edge->verts[1]->newIndex; @@ -442,7 +442,7 @@ static DerivedMesh *CDDM_from_smoothmesh(SmoothMesh *mesh) MFace *newMF = &new_faces[face->newIndex]; DM_copy_face_data(mesh->dm, result, - face->oldIndex, face->newIndex, 1); + face->oldIndex, face->newIndex, 1); mesh->dm->getFace(mesh->dm, face->oldIndex, newMF); newMF->v1 = face->edges[0]->verts[face->flip[0]]->newIndex; @@ -666,7 +666,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 +702,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 +724,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 +776,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 +800,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,26 +818,26 @@ 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 } - } + } - /* either we came back to the start edge or we found a sharp/loose edge */ - if(linklist_contains(visited_edges, edge2)) - /* we came back to the start edge */ - edge2 = NULL; + /* either we came back to the start edge or we found a sharp/loose edge */ + if(linklist_contains(visited_edges, edge2)) + /* we came back to the start edge */ + edge2 = NULL; - BLI_linklist_free(visited_edges, NULL); + BLI_linklist_free(visited_edges, NULL); #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); + printf("=== END === find_other_sharp_edge(edge = %4d, vert = %4d), " + "returning edge %d\n", + edge->newIndex, vert->newIndex, edge2 ? edge2->newIndex : -1); #endif - return edge2; + return edge2; } static void split_single_vert(SmoothVert *vert, SmoothFace *face, @@ -911,7 +911,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); @@ -956,7 +956,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 +969,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 +1042,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 } @@ -1078,31 +1078,31 @@ static void tag_and_count_extra_edges(SmoothMesh *mesh, float split_angle, /* (the edge can only be sharp if we're checking angle or flag, * and it has at least 2 faces) */ - /* if we're checking the sharp flag and it's set, good */ - if((flags & MOD_EDGESPLIT_FROMFLAG) && (edge->flag & ME_SHARP)) { - /* this edge is sharp */ - sharp = 1; - - (*extra_edges)++; - } else if(flags & MOD_EDGESPLIT_FROMANGLE) { - /* we know the edge has 2 faces, so check the angle */ - SmoothFace *face1 = edge->faces->link; - SmoothFace *face2 = edge->faces->next->link; - float edge_angle_cos = dot_v3v3(face1->normal, - face2->normal); - - if(edge_angle_cos < threshold) { - /* this edge is sharp */ - sharp = 1; - - (*extra_edges)++; - } - } - } + /* if we're checking the sharp flag and it's set, good */ + if((flags & MOD_EDGESPLIT_FROMFLAG) && (edge->flag & ME_SHARP)) { + /* this edge is sharp */ + sharp = 1; + + (*extra_edges)++; + } else if(flags & MOD_EDGESPLIT_FROMANGLE) { + /* we know the edge has 2 faces, so check the angle */ + SmoothFace *face1 = edge->faces->link; + SmoothFace *face2 = edge->faces->next->link; + float edge_angle_cos = dot_v3v3(face1->normal, + face2->normal); + + if(edge_angle_cos < threshold) { + /* this edge is sharp */ + sharp = 1; + + (*extra_edges)++; + } + } + } - /* set/clear sharp flag appropriately */ - if(sharp) edge->flag |= ME_SHARP; - else edge->flag &= ~ME_SHARP; + /* set/clear sharp flag appropriately */ + if(sharp) edge->flag |= ME_SHARP; + else edge->flag &= ~ME_SHARP; } } @@ -1244,7 +1244,7 @@ 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); + mesh->num_verts, mesh->num_edges); #endif result = CDDM_from_smoothmesh(mesh); diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 924035538da..f1bc0d33fd8 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -997,19 +997,19 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, createFacepa(emd,psmd,derivedData); } - /* 2. create new mesh */ - if(emd->flag & eExplodeFlag_EdgeCut){ - int *facepa = emd->facepa; - DerivedMesh *splitdm=cutEdges(emd,dm); - DerivedMesh *explode=explodeMesh(emd, psmd, md->scene, ob, splitdm); - - MEM_freeN(emd->facepa); - emd->facepa=facepa; - splitdm->release(splitdm); - return explode; - } - else - return explodeMesh(emd, psmd, md->scene, ob, derivedData); + /* 2. create new mesh */ + if(emd->flag & eExplodeFlag_EdgeCut){ + int *facepa = emd->facepa; + DerivedMesh *splitdm=cutEdges(emd,dm); + DerivedMesh *explode=explodeMesh(emd, psmd, md->scene, ob, splitdm); + + MEM_freeN(emd->facepa); + emd->facepa=facepa; + splitdm->release(splitdm); + return explode; + } + else + return explodeMesh(emd, psmd, md->scene, ob, derivedData); } return derivedData; } @@ -1019,7 +1019,7 @@ ModifierTypeInfo modifierType_Explode = { /* name */ "Explode", /* structName */ "ExplodeModifierData", /* structSize */ sizeof(ExplodeModifierData), - /* type */ eModifierTypeType_Nonconstructive, + /* type */ eModifierTypeType_Constructive, /* flags */ eModifierTypeFlag_AcceptsMesh, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_alphaOver.c b/source/blender/nodes/intern/CMP_nodes/CMP_alphaOver.c index cba7e150633..9dcdfaf21e6 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_alphaOver.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_alphaOver.c @@ -142,7 +142,7 @@ static void node_composit_exec_alphaover(void *UNUSED(data), bNode *node, bNodeS static void node_alphaover_init(bNode* node) { - node->storage= MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"); + node->storage= MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"); } void register_node_type_cmp_alphaover(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_blur.c b/source/blender/nodes/intern/CMP_nodes/CMP_blur.c index 1031ab3d360..2b33126b3a7 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_blur.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_blur.c @@ -715,7 +715,7 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN static void node_composit_init_blur(bNode* node) { - node->storage= MEM_callocN(sizeof(NodeBlurData), "node blur data"); + node->storage= MEM_callocN(sizeof(NodeBlurData), "node blur data"); } void register_node_type_cmp_blur(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c index cdd360dc0fe..b32c531d8f9 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_channelMatte.c @@ -74,34 +74,34 @@ static void do_channel_matte(bNode *node, float *out, float *in) float alpha=0.0; switch(c->algorithm) { - case 0: { /* Alpha=key_channel-limit channel */ - int key_channel=node->custom2-1; - int limit_channel=c->channel-1; - alpha=in[key_channel]-in[limit_channel]; - break; - } - case 1: { /* Alpha=G-MAX(R, B) */ - switch(node->custom2) { + case 0: { /* Alpha=key_channel-limit channel */ + int key_channel=node->custom2-1; + int limit_channel=c->channel-1; + alpha=in[key_channel]-in[limit_channel]; + break; + } + case 1: { /* Alpha=G-MAX(R, B) */ + switch(node->custom2) { case 1: { - alpha=in[0]-MAX2(in[1],in[2]); - break; - } + alpha=in[0]-MAX2(in[1],in[2]); + break; + } case 2: { - alpha=in[1]-MAX2(in[0],in[2]); - break; - } + alpha=in[1]-MAX2(in[0],in[2]); + break; + } case 3: { - alpha=in[2]-MAX2(in[0],in[1]); - break; - } + alpha=in[2]-MAX2(in[0],in[1]); + break; + } default: break; - } - } - default: - break; - } - + } + } + default: + break; + } + /*flip because 0.0 is transparent, not 1.0*/ alpha=1-alpha; @@ -124,7 +124,6 @@ static void do_channel_matte(bNode *node, float *out, float *in) else { out[3]=in[3]; } - } static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out) @@ -132,7 +131,7 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack CompBuf *cbuf; CompBuf *outbuf; - if(in[0]->hasinput==0) return; + if(in[0]->hasinput==0) return; if(in[0]->data==NULL) return; if(out[0]->hasoutput==0 && out[1]->hasoutput==0) return; @@ -142,24 +141,24 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack /*convert to colorspace*/ switch(node->custom1) { - case CMP_NODE_CHANNEL_MATTE_CS_RGB: - break; - case CMP_NODE_CHANNEL_MATTE_CS_HSV: /*HSV*/ - composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_rgba_to_hsva, CB_RGBA); - break; - case CMP_NODE_CHANNEL_MATTE_CS_YUV: /*YUV*/ - composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_rgba_to_yuva, CB_RGBA); - break; - case CMP_NODE_CHANNEL_MATTE_CS_YCC: /*YCC*/ - composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_normalized_rgba_to_ycca2, CB_RGBA); - break; - default: - break; + case CMP_NODE_CHANNEL_MATTE_CS_RGB: + break; + case CMP_NODE_CHANNEL_MATTE_CS_HSV: /*HSV*/ + composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_rgba_to_hsva, CB_RGBA); + break; + case CMP_NODE_CHANNEL_MATTE_CS_YUV: /*YUV*/ + composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_rgba_to_yuva, CB_RGBA); + break; + case CMP_NODE_CHANNEL_MATTE_CS_YCC: /*YCC*/ + composit1_pixel_processor(node, outbuf, cbuf, in[1]->vec, do_normalized_rgba_to_ycca2, CB_RGBA); + break; + default: + break; } /*use the selected channel information to do the key */ composit1_pixel_processor(node, outbuf, outbuf, in[1]->vec, do_channel_matte, CB_RGBA); - + /*convert back to RGB colorspace in place*/ switch(node->custom1) { case CMP_NODE_CHANNEL_MATTE_CS_RGB: /*RGB*/ @@ -189,17 +188,17 @@ static void node_composit_exec_channel_matte(void *data, bNode *node, bNodeStack static void node_composit_init_channel_matte(bNode *node) { - NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); - node->storage=c; - c->t1= 1.0f; - c->t2= 0.0f; - c->t3= 0.0f; - c->fsize= 0.0f; - c->fstrength= 0.0f; - c->algorithm=1; /*max channel limiting */ - c->channel=1; /* limit by red */ - node->custom1= 1; /* RGB channel */ - node->custom2= 2; /* Green Channel */ + NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); + node->storage=c; + c->t1= 1.0f; + c->t2= 0.0f; + c->t3= 0.0f; + c->fsize= 0.0f; + c->fstrength= 0.0f; + c->algorithm=1; /*max channel limiting */ + c->channel=1; /* limit by red */ + node->custom1= 1; /* RGB channel */ + node->custom2= 2; /* Green Channel */ } void register_node_type_cmp_channel_matte(ListBase *lb) @@ -215,4 +214,3 @@ void register_node_type_cmp_channel_matte(ListBase *lb) nodeRegisterType(lb, &ntype); } - diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c index fc0e9b3ee4b..03230f2e212 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_chromaMatte.c @@ -49,17 +49,17 @@ static bNodeSocketType cmp_node_chroma_out[]={ static void do_rgba_to_ycca_normalized(bNode *UNUSED(node), float *out, float *in) { - rgb_to_ycc(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601); + rgb_to_ycc(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601); - //normalize to 0..1.0 - out[0]=out[0]/255.0; - out[1]=out[1]/255.0; - out[2]=out[2]/255.0; + //normalize to 0..1.0 + out[0]=out[0]/255.0; + out[1]=out[1]/255.0; + out[2]=out[2]/255.0; - //rescale to -1.0..1.0 - out[0]=(out[0]*2.0)-1.0; - out[1]=(out[1]*2.0)-1.0; - out[2]=(out[2]*2.0)-1.0; + //rescale to -1.0..1.0 + out[0]=(out[0]*2.0)-1.0; + out[1]=(out[1]*2.0)-1.0; + out[2]=(out[2]*2.0)-1.0; // out[0]=((out[0])-16)/255.0; // out[1]=((out[1])-128)/255.0; @@ -69,16 +69,16 @@ static void do_rgba_to_ycca_normalized(bNode *UNUSED(node), float *out, float *i static void do_ycca_to_rgba_normalized(bNode *UNUSED(node), float *out, float *in) { - /*un-normalize the normalize from above */ - in[0]=(in[0]+1.0)/2.0; - in[1]=(in[1]+1.0)/2.0; - in[2]=(in[2]+1.0)/2.0; + /*un-normalize the normalize from above */ + in[0]=(in[0]+1.0)/2.0; + in[1]=(in[1]+1.0)/2.0; + in[2]=(in[2]+1.0)/2.0; - in[0]=(in[0]*255.0); - in[1]=(in[1]*255.0); - in[2]=(in[2]*255.0); + in[0]=(in[0]*255.0); + in[1]=(in[1]*255.0); + in[2]=(in[2]*255.0); -// in[0]=(in[0]*255.0)+16; + // in[0]=(in[0]*255.0)+16; // in[1]=(in[1]*255.0)+128; // in[2]=(in[2]*255.0)+128; ycc_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601); @@ -88,41 +88,41 @@ static void do_ycca_to_rgba_normalized(bNode *UNUSED(node), float *out, float *i static void do_chroma_key(bNode *node, float *out, float *in) { NodeChroma *c; - float x, z, alpha; - float theta, beta, angle, angle2; - float kfg; + float x, z, alpha; + float theta, beta, angle, angle2; + float kfg; c=node->storage; - /* Algorithm from book "Video Demistified," does not include the spill reduction part */ + /* Algorithm from book "Video Demistified," does not include the spill reduction part */ /* find theta, the angle that the color space should be rotated based on key*/ - theta=atan2(c->key[2], c->key[1]); + theta=atan2(c->key[2], c->key[1]); /*rotate the cb and cr into x/z space */ - x=in[1]*cos(theta)+in[2]*sin(theta); - z=in[2]*cos(theta)-in[1]*sin(theta); + x=in[1]*cos(theta)+in[2]*sin(theta); + z=in[2]*cos(theta)-in[1]*sin(theta); - /*if within the acceptance angle */ - angle=c->t1*M_PI/180.0; /* convert to radians */ - - /* if kfg is <0 then the pixel is outside of the key color */ - kfg=x-(fabs(z)/tan(angle/2.0)); + /*if within the acceptance angle */ + angle=c->t1*M_PI/180.0; /* convert to radians */ + + /* if kfg is <0 then the pixel is outside of the key color */ + kfg=x-(fabs(z)/tan(angle/2.0)); - out[0]=in[0]; - out[1]=in[1]; - out[2]=in[2]; + out[0]=in[0]; + out[1]=in[1]; + out[2]=in[2]; - if(kfg>0.0) { /* found a pixel that is within key color */ - alpha=(1.0-kfg)*(c->fstrength); + if(kfg>0.0) { /* found a pixel that is within key color */ + alpha=(1.0-kfg)*(c->fstrength); - beta=atan2(z,x); - angle2=c->t2*M_PI/180.0; + beta=atan2(z,x); + angle2=c->t2*M_PI/180.0; - /* if beta is within the cutoff angle */ - if(fabs(beta)<(angle2/2.0)) { - alpha=0.0; - } + /* if beta is within the cutoff angle */ + if(fabs(beta)<(angle2/2.0)) { + alpha=0.0; + } /* don't make something that was more transparent less transparent */ if (alpha<in[3]) { @@ -180,13 +180,13 @@ static void node_composit_exec_chroma_matte(void *data, bNode *node, bNodeStack static void node_composit_init_chroma_matte(bNode *node) { - NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); - node->storage= c; - c->t1= 30.0f; - c->t2= 10.0f; - c->t3= 0.0f; - c->fsize= 0.0f; - c->fstrength= 1.0f; + NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); + node->storage= c; + c->t1= 30.0f; + c->t2= 10.0f; + c->t3= 0.0f; + c->fsize= 0.0f; + c->fstrength= 1.0f; } void register_node_type_cmp_chroma_matte(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c index 90916284f1e..151850105b7 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_colorMatte.c @@ -53,14 +53,14 @@ static void do_color_key(bNode *node, float *out, float *in) c=node->storage; - VECCOPY(out, in); + VECCOPY(out, in); - if(fabs(in[0]-c->key[0]) < c->t1 && - fabs(in[1]-c->key[1]) < c->t2 && - fabs(in[2]-c->key[2]) < c->t3) - { - out[3]=0.0; /*make transparent*/ - } + if(fabs(in[0]-c->key[0]) < c->t1 && + fabs(in[1]-c->key[1]) < c->t2 && + fabs(in[2]-c->key[2]) < c->t3) + { + out[3]=0.0; /*make transparent*/ + } else { /*pixel is outside key color */ out[3]=in[3]; /* make pixel just as transparent as it was before */ @@ -108,13 +108,13 @@ static void node_composit_exec_color_matte(void *data, bNode *node, bNodeStack * static void node_composit_init_color_matte(bNode *node) { - NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node color"); - node->storage= c; - c->t1= 0.01f; - c->t2= 0.1f; - c->t3= 0.1f; - c->fsize= 0.0f; - c->fstrength= 1.0f; + NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node color"); + node->storage= c; + c->t1= 0.01f; + c->t2= 0.1f; + c->t3= 0.1f; + c->fsize= 0.0f; + c->fstrength= 1.0f; } void register_node_type_cmp_color_matte(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c b/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c index c9997ba8a75..905d97709c3 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_colorSpill.c @@ -39,8 +39,8 @@ /* ******************* Color Spill Supression ********************************* */ static bNodeSocketType cmp_node_color_spill_in[]={ - {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, - {SOCK_VALUE, 1, "Fac", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + {SOCK_RGBA,1,"Image", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, + {SOCK_VALUE, 1, "Fac", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, {-1,0,""} }; @@ -51,17 +51,17 @@ static bNodeSocketType cmp_node_color_spill_out[]={ static void do_simple_spillmap_red(bNode *node, float* out, float *in) { - NodeColorspill *ncs; + NodeColorspill *ncs; ncs=node->storage; out[0]=in[0]-( ncs->limscale * in[ncs->limchan] ); } static void do_simple_spillmap_red_fac(bNode *node, float* out, float *in, float *fac) { - NodeColorspill *ncs; - ncs=node->storage; + NodeColorspill *ncs; + ncs=node->storage; - out[0] = *fac * (in[0]-( ncs->limscale * in[ncs->limchan])); + out[0] = *fac * (in[0]-( ncs->limscale * in[ncs->limchan])); } static void do_simple_spillmap_green(bNode *node, float* out, float *in) @@ -73,10 +73,10 @@ static void do_simple_spillmap_green(bNode *node, float* out, float *in) static void do_simple_spillmap_green_fac(bNode *node, float* out, float *in, float *fac) { - NodeColorspill *ncs; - ncs=node->storage; + NodeColorspill *ncs; + ncs=node->storage; - out[0] = *fac * (in[1]-( ncs->limscale * in[ncs->limchan])); + out[0] = *fac * (in[1]-( ncs->limscale * in[ncs->limchan])); } static void do_simple_spillmap_blue(bNode *node, float* out, float *in) @@ -88,10 +88,10 @@ static void do_simple_spillmap_blue(bNode *node, float* out, float *in) static void do_simple_spillmap_blue_fac(bNode *node, float* out, float *in, float *fac) { - NodeColorspill *ncs; - ncs=node->storage; + NodeColorspill *ncs; + ncs=node->storage; - out[0] = *fac * (in[2]-( ncs->limscale * in[ncs->limchan])); + out[0] = *fac * (in[2]-( ncs->limscale * in[ncs->limchan])); } static void do_average_spillmap_red(bNode *node, float* out, float *in) @@ -103,10 +103,10 @@ static void do_average_spillmap_red(bNode *node, float* out, float *in) static void do_average_spillmap_red_fac(bNode *node, float* out, float *in, float *fac) { - NodeColorspill *ncs; - ncs=node->storage; + NodeColorspill *ncs; + ncs=node->storage; - out[0] = *fac * (in[0]-(ncs->limscale * avg(in[1], in[2]) )); + out[0] = *fac * (in[0]-(ncs->limscale * avg(in[1], in[2]) )); } static void do_average_spillmap_green(bNode *node, float* out, float *in) @@ -118,10 +118,10 @@ static void do_average_spillmap_green(bNode *node, float* out, float *in) static void do_average_spillmap_green_fac(bNode *node, float* out, float *in, float *fac) { - NodeColorspill *ncs; - ncs=node->storage; + NodeColorspill *ncs; + ncs=node->storage; - out[0] = *fac * (in[0]-(ncs->limscale * avg(in[0], in[2]) )); + out[0] = *fac * (in[0]-(ncs->limscale * avg(in[0], in[2]) )); } static void do_average_spillmap_blue(bNode *node, float* out, float *in) @@ -133,10 +133,10 @@ static void do_average_spillmap_blue(bNode *node, float* out, float *in) static void do_average_spillmap_blue_fac(bNode *node, float* out, float *in, float *fac) { - NodeColorspill *ncs; - ncs=node->storage; + NodeColorspill *ncs; + ncs=node->storage; - out[0] = *fac * (in[0]-(ncs->limscale * avg(in[0], in[1]) )); + out[0] = *fac * (in[0]-(ncs->limscale * avg(in[0], in[1]) )); } static void do_apply_spillmap_red(bNode *node, float* out, float *in, float *map) @@ -189,48 +189,47 @@ static void do_apply_spillmap_blue(bNode *node, float* out, float *in, float *ma static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - /* - Originally based on the information from the book "The Art and Science of Digital Composition" and - discussions from vfxtalk.com.*/ - CompBuf *cbuf; - CompBuf *mask; + /* Originally based on the information from the book "The Art and Science of Digital Composition" and + * discussions from vfxtalk.com .*/ + CompBuf *cbuf; + CompBuf *mask; CompBuf *rgbbuf; CompBuf *spillmap; NodeColorspill *ncs; ncs=node->storage; - /* early out for missing connections */ - if(out[0]->hasoutput==0 ) return; - if(in[0]->hasinput==0) return; - if(in[0]->data==NULL) return; + /* early out for missing connections */ + if(out[0]->hasoutput==0 ) return; + if(in[0]->hasinput==0) return; + if(in[0]->data==NULL) return; - cbuf=typecheck_compbuf(in[0]->data, CB_RGBA); - mask=typecheck_compbuf(in[1]->data, CB_VAL); + cbuf=typecheck_compbuf(in[0]->data, CB_RGBA); + mask=typecheck_compbuf(in[1]->data, CB_VAL); spillmap=alloc_compbuf(cbuf->x, cbuf->y, CB_VAL, 1); rgbbuf=dupalloc_compbuf(cbuf); switch(node->custom1) { - case 1: /*red spill*/ + case 1: /*red spill*/ { switch(node->custom2) { - case 0: /* simple limit */ - { - if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { - composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_red, CB_RGBA); - } else { - composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_red_fac, CB_RGBA, CB_VAL); - } + case 0: /* simple limit */ + { + if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { + composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_red, CB_RGBA); + } else { + composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_red_fac, CB_RGBA, CB_VAL); + } break; } - case 1: /* average limit */ - { - if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { - composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_red, CB_RGBA); - } else { - composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_red_fac, CB_RGBA, CB_VAL); - } + case 1: /* average limit */ + { + if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { + composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_red, CB_RGBA); + } else { + composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_red_fac, CB_RGBA, CB_VAL); + } break; } } @@ -242,59 +241,59 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod composit2_pixel_processor(node, rgbbuf, cbuf, in[0]->vec, spillmap, NULL, do_apply_spillmap_red, CB_RGBA, CB_VAL); break; } - case 2: /*green spill*/ + case 2: /*green spill*/ { switch(node->custom2) { - case 0: /* simple limit */ - { - if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { - composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_green, CB_RGBA); - } else { - composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_green_fac, CB_RGBA, CB_VAL); - } - break; - } - case 1: /* average limit */ - { - if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { - composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_green, CB_RGBA); - } else { - composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_green_fac, CB_RGBA, CB_VAL); - } - break; - } + case 0: /* simple limit */ + { + if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { + composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_green, CB_RGBA); + } else { + composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_green_fac, CB_RGBA, CB_VAL); + } + break; + } + case 1: /* average limit */ + { + if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { + composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_green, CB_RGBA); + } else { + composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_green_fac, CB_RGBA, CB_VAL); + } + break; + } } if(ncs->unspill==0) { ncs->uspillr=0.0f; ncs->uspillg=1.0f; ncs->uspillb=0.0f; - } + } composit2_pixel_processor(node, rgbbuf, cbuf, in[0]->vec, spillmap, NULL, do_apply_spillmap_green, CB_RGBA, CB_VAL); break; } - case 3: /*blue spill*/ + case 3: /*blue spill*/ { switch(node->custom2) { - case 0: /* simple limit */ - { - if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { - composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_blue, CB_RGBA); - } else { - composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_blue_fac, CB_RGBA, CB_VAL); - } - break; - } - case 1: /* average limit */ - { - if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { - composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_blue, CB_RGBA); - } else { - composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_blue_fac, CB_RGBA, CB_VAL); - } - break; - } + case 0: /* simple limit */ + { + if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { + composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_simple_spillmap_blue, CB_RGBA); + } else { + composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_simple_spillmap_blue_fac, CB_RGBA, CB_VAL); + } + break; + } + case 1: /* average limit */ + { + if ((in[1]->data==NULL) && (in[1]->vec[0] >= 1.f)) { + composit1_pixel_processor(node, spillmap, cbuf, in[0]->vec, do_average_spillmap_blue, CB_RGBA); + } else { + composit2_pixel_processor(node, spillmap, cbuf, in[0]->vec, in[1]->data, in[1]->vec, do_average_spillmap_blue_fac, CB_RGBA, CB_VAL); + } + break; + } } if(ncs->unspill==0) { ncs->uspillr=0.0f; @@ -304,27 +303,27 @@ static void node_composit_exec_color_spill(void *UNUSED(data), bNode *node, bNod composit2_pixel_processor(node, rgbbuf, cbuf, in[0]->vec, spillmap, NULL, do_apply_spillmap_blue, CB_RGBA, CB_VAL); break; } - default: - break; + default: + break; } out[0]->data=rgbbuf; if(cbuf!=in[0]->data) free_compbuf(cbuf); - - free_compbuf(spillmap); + + free_compbuf(spillmap); } static void node_composit_init_color_spill(bNode *node) { - NodeColorspill *ncs= MEM_callocN(sizeof(NodeColorspill), "node colorspill"); - node->storage=ncs; - node->custom1= 2; /* green channel */ - node->custom2= 0; /* simple limit algo*/ - ncs->limchan= 0; /* limit by red */ - ncs->limscale= 1.0f; /* limit scaling factor */ - ncs->unspill=0; /* do not use unspill */ + NodeColorspill *ncs= MEM_callocN(sizeof(NodeColorspill), "node colorspill"); + node->storage=ncs; + node->custom1= 2; /* green channel */ + node->custom2= 0; /* simple limit algo*/ + ncs->limchan= 0; /* limit by red */ + ncs->limscale= 1.0f; /* limit scaling factor */ + ncs->unspill=0; /* do not use unspill */ } void register_node_type_cmp_color_spill(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_crop.c b/source/blender/nodes/intern/CMP_nodes/CMP_crop.c index 5a0e2047ed7..0331217f0cb 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_crop.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_crop.c @@ -53,14 +53,14 @@ static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack CompBuf *stackbuf; int x, y; float *srcfp, *outfp; - rcti outputrect; + rcti outputrect; - if(node->custom2) { - ntxy->x1= cbuf->x* ntxy->fac_x1; - ntxy->x2= cbuf->x* ntxy->fac_x2; - ntxy->y1= cbuf->y* ntxy->fac_y1; - ntxy->y2= cbuf->y* ntxy->fac_y2; - } + if(node->custom2) { + ntxy->x1= cbuf->x* ntxy->fac_x1; + ntxy->x2= cbuf->x* ntxy->fac_x2; + ntxy->y1= cbuf->y* ntxy->fac_y1; + ntxy->y2= cbuf->y* ntxy->fac_y2; + } /* check input image size */ if(cbuf->x <= ntxy->x1 + 1) @@ -105,12 +105,12 @@ static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack static void node_composit_init_crop(bNode* node) { - NodeTwoXYs *nxy= MEM_callocN(sizeof(NodeTwoXYs), "node xy data"); - node->storage= nxy; - nxy->x1= 0; - nxy->x2= 0; - nxy->y1= 0; - nxy->y2= 0; + NodeTwoXYs *nxy= MEM_callocN(sizeof(NodeTwoXYs), "node xy data"); + node->storage= nxy; + nxy->x1= 0; + nxy->x2= 0; + nxy->y1= 0; + nxy->y2= 0; } void register_node_type_cmp_crop(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_curves.c b/source/blender/nodes/intern/CMP_nodes/CMP_curves.c index f0b399ae1e8..921c5e21fea 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_curves.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_curves.c @@ -59,9 +59,9 @@ static void node_composit_exec_curves_time(void *data, bNode *node, bNodeStack * static void node_composit_init_curves_time(bNode* node) { - node->custom1= 1; - node->custom2= 250; - node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + node->custom1= 1; + node->custom2= 250; + node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } void register_node_type_cmp_curve_time(ListBase *lb) @@ -102,7 +102,7 @@ static void node_composit_exec_curve_vec(void *UNUSED(data), bNode *node, bNodeS static void node_composit_init_curve_vec(bNode* node) { - node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); + node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); } void register_node_type_cmp_curve_vec(ListBase *lb) @@ -189,7 +189,7 @@ static void node_composit_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeS static void node_composit_init_curve_rgb(bNode* node) { - node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } void register_node_type_cmp_curve_rgb(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c b/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c index 303d5ee01aa..f249e2cff6c 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_defocus.c @@ -859,19 +859,19 @@ static void node_composit_exec_defocus(void *UNUSED(data), bNode *node, bNodeSta static void node_composit_init_defocus(bNode* node) { - /* qdn: defocus node */ - NodeDefocus *nbd = MEM_callocN(sizeof(NodeDefocus), "node defocus data"); - nbd->bktype = 0; - nbd->rotation = 0.f; - nbd->preview = 1; - nbd->gamco = 0; - nbd->samples = 16; - nbd->fstop = 128.f; - nbd->maxblur = 0; - nbd->bthresh = 1.f; - nbd->scale = 1.f; - nbd->no_zbuf = 1; - node->storage = nbd; + /* qdn: defocus node */ + NodeDefocus *nbd = MEM_callocN(sizeof(NodeDefocus), "node defocus data"); + nbd->bktype = 0; + nbd->rotation = 0.f; + nbd->preview = 1; + nbd->gamco = 0; + nbd->samples = 16; + nbd->fstop = 128.f; + nbd->maxblur = 0; + nbd->bthresh = 1.f; + nbd->scale = 1.f; + nbd->no_zbuf = 1; + node->storage = nbd; } void register_node_type_cmp_defocus(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_diffMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_diffMatte.c index f0e112761e3..296053298da 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_diffMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_diffMatte.c @@ -51,35 +51,35 @@ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float * { NodeChroma *c= (NodeChroma *)node->storage; float tolerence=c->t1; - float falloff=c->t2; + float falloff=c->t2; float difference; - float alpha; - - difference=fabs(inColor2[0]-inColor1[0])+ + float alpha; + + difference= fabs(inColor2[0]-inColor1[0])+ fabs(inColor2[1]-inColor1[1])+ fabs(inColor2[2]-inColor1[2]); - /*average together the distances*/ - difference=difference/3.0; + /*average together the distances*/ + difference=difference/3.0; - VECCOPY(outColor, inColor1); + VECCOPY(outColor, inColor1); - /*make 100% transparent*/ - if(difference < tolerence){ - outColor[3]=0.0; + /*make 100% transparent*/ + if(difference < tolerence) { + outColor[3]=0.0; + } + /*in the falloff region, make partially transparent */ + else if(difference < falloff+tolerence) { + difference=difference-tolerence; + alpha=difference/falloff; + /*only change if more transparent than before */ + if(alpha < inColor1[3]) { + outColor[3]=alpha; + } + else { /* leave as before */ + outColor[3]=inColor1[3]; + } } - /*in the falloff region, make partially transparent */ - else if(difference < falloff+tolerence){ - difference=difference-tolerence; - alpha=difference/falloff; - /*only change if more transparent than before */ - if(alpha < inColor1[3]) { - outColor[3]=alpha; - } - else { /* leave as before */ - outColor[3]=inColor1[3]; - } - } else { /*foreground object*/ outColor[3]= inColor1[3]; @@ -90,29 +90,29 @@ static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack ** { CompBuf *outbuf=0; CompBuf *imbuf1=0; - CompBuf *imbuf2=0; + CompBuf *imbuf2=0; NodeChroma *c; - + /*is anything connected?*/ if(out[0]->hasoutput==0 && out[1]->hasoutput==0) return; /*must have an image imput*/ if(in[0]->data==NULL) return; - + imbuf1=typecheck_compbuf(in[0]->data, CB_RGBA); - /* if there's an image, use that, if not use the color */ - if(in[1]->data) { - imbuf2=typecheck_compbuf(in[1]->data, CB_RGBA); - } - + /* if there's an image, use that, if not use the color */ + if(in[1]->data) { + imbuf2=typecheck_compbuf(in[1]->data, CB_RGBA); + } + c=node->storage; outbuf=dupalloc_compbuf(imbuf1); - + /* note, processor gets a keyvals array passed on as buffer constant */ composit2_pixel_processor(node, outbuf, imbuf1, in[0]->vec, imbuf2, in[1]->vec, do_diff_matte, CB_RGBA, CB_RGBA); - + out[0]->data=outbuf; if(out[1]->hasoutput) out[1]->data=valbuf_from_rgbabuf(outbuf, CHAN_A); @@ -127,10 +127,10 @@ static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack ** static void node_composit_init_diff_matte(bNode *node) { - NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); - node->storage= c; - c->t1= 0.1f; - c->t2= 0.1f; + NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); + node->storage= c; + c->t1= 0.1f; + c->t2= 0.1f; } void register_node_type_cmp_diff_matte(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c index d52a47993d2..9139edf8560 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_displace.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_displace.c @@ -53,7 +53,7 @@ static bNodeSocketType cmp_node_displace_out[]= { * in order to take effect */ #define DISPLACE_EPSILON 0.01 -static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float *UNUSED(veccol), CompBuf *xbuf, CompBuf *ybuf, float *xscale, float *yscale) +static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float *UNUSED(veccol), CompBuf *xbuf, CompBuf *ybuf, float *xscale, float *yscale) { ImBuf *ibuf; int x, y; @@ -83,6 +83,10 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float else ys = yscale[0]; + /* clamp x and y displacement to triple image resolution - + * to prevent hangs from huge values mistakenly plugged in eg. z buffers */ + CLAMP(xs, -stackbuf->x*4, stackbuf->x*4); + CLAMP(ys, -stackbuf->y*4, stackbuf->y*4); p_dx = vec[0] * xs; p_dy = vec[1] * ys; @@ -114,7 +118,11 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float ibuf_sample(ibuf, u, v, dxt, dyt, col); qd_setPixel(stackbuf, x, y, col); + + if(node->exec & NODE_BREAK) break; } + + if(node->exec & NODE_BREAK) break; } IMB_freeImBuf(ibuf); @@ -145,7 +153,7 @@ static void do_displace(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *vecbuf, float } -static void node_composit_exec_displace(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, bNodeStack **out) +static void node_composit_exec_displace(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { if(out[0]->hasoutput==0) return; @@ -164,7 +172,7 @@ static void node_composit_exec_displace(void *UNUSED(data), bNode *UNUSED(node), stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ - do_displace(stackbuf, cbuf, vecbuf, in[1]->vec, xbuf, ybuf, in[2]->vec, in[3]->vec); + do_displace(node, stackbuf, cbuf, vecbuf, in[1]->vec, xbuf, ybuf, in[2]->vec, in[3]->vec); out[0]->data= stackbuf; diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_distanceMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_distanceMatte.c index 3eb38465c4f..5f7613464c1 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_distanceMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_distanceMatte.c @@ -53,42 +53,42 @@ static void do_distance_matte(bNode *node, float *out, float *in) { NodeChroma *c= (NodeChroma *)node->storage; float tolerence=c->t1; - float falloff=c->t2; + float falloff=c->t2; float distance; - float alpha; - - distance=sqrt((c->key[0]-in[0])*(c->key[0]-in[0]) + + float alpha; + + distance=sqrt((c->key[0]-in[0])*(c->key[0]-in[0]) + (c->key[1]-in[1])*(c->key[1]-in[1]) + (c->key[2]-in[2])*(c->key[2]-in[2])); - VECCOPY(out, in); - - /*make 100% transparent */ - if(distance < tolerence) { - out[3]=0.0; - } - /*in the falloff region, make partially transparent */ - else if(distance < falloff+tolerence){ - distance=distance-tolerence; - alpha=distance/falloff; - /*only change if more transparent than before */ - if(alpha < in[3]) { - out[3]=alpha; - } - else { /* leave as before */ - out[3]=in[3]; - } - } - else { - out[3]=in[3]; - } + VECCOPY(out, in); + + /*make 100% transparent */ + if(distance < tolerence) { + out[3]=0.0; + } + /*in the falloff region, make partially transparent */ + else if(distance < falloff+tolerence){ + distance=distance-tolerence; + alpha=distance/falloff; + /*only change if more transparent than before */ + if(alpha < in[3]) { + out[3]=alpha; + } + else { /* leave as before */ + out[3]=in[3]; + } + } + else { + out[3]=in[3]; + } } static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { /* - Losely based on the Sequencer chroma key plug-in, but enhanced to work in other color spaces and - uses a differnt difference function (suggested in forums of vfxtalk.com). + Loosely based on the Sequencer chroma key plug-in, but enhanced to work in other color spaces and + uses a different difference function (suggested in forums of vfxtalk.com). */ CompBuf *workbuf; CompBuf *inbuf; @@ -124,10 +124,10 @@ static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStac static void node_composit_init_distance_matte(bNode *node) { - NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); - node->storage= c; - c->t1= 0.1f; - c->t2= 0.1f; + NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); + node->storage= c; + c->t1= 0.1f; + c->t2= 0.1f; } void register_node_type_cmp_distance_matte(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_hueSatVal.c b/source/blender/nodes/intern/CMP_nodes/CMP_hueSatVal.c index 238f9b063c2..7b5511c699c 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_hueSatVal.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_hueSatVal.c @@ -97,11 +97,11 @@ static void node_composit_exec_hue_sat(void *UNUSED(data), bNode *node, bNodeSta static void node_composit_init_hue_sat(bNode* node) { - NodeHueSat *nhs= MEM_callocN(sizeof(NodeHueSat), "node hue sat"); - node->storage= nhs; - nhs->hue= 0.5f; - nhs->sat= 1.0f; - nhs->val= 1.0f; + NodeHueSat *nhs= MEM_callocN(sizeof(NodeHueSat), "node hue sat"); + node->storage= nhs; + nhs->hue= 0.5f; + nhs->sat= 1.0f; + nhs->val= 1.0f; } void register_node_type_cmp_hue_sat(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c b/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c index ce5092e2859..edf6c454285 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_huecorrect.c @@ -53,7 +53,7 @@ static void do_huecorrect(bNode *node, float *out, float *in) /* adjust hue, scaling returned default 0.5 up to 1 */ f = curvemapping_evaluateF(node->storage, 0, hsv[0]); - hsv[0] *= (f * 2.f); + hsv[0] += f-0.5f; /* adjust saturation, scaling returned default 0.5 up to 1 */ f = curvemapping_evaluateF(node->storage, 1, hsv[0]); @@ -63,7 +63,7 @@ static void do_huecorrect(bNode *node, float *out, float *in) f = curvemapping_evaluateF(node->storage, 2, hsv[0]); hsv[2] *= (f * 2.f); - CLAMP(hsv[0], 0.f, 1.f); + hsv[0] = hsv[0] - floor(hsv[0]); /* mod 1.0 */ CLAMP(hsv[1], 0.f, 1.f); /* convert back to rgb */ @@ -81,7 +81,7 @@ static void do_huecorrect_fac(bNode *node, float *out, float *in, float *fac) /* adjust hue, scaling returned default 0.5 up to 1 */ f = curvemapping_evaluateF(node->storage, 0, hsv[0]); - hsv[0] *= (f * 2.f); + hsv[0] += f-0.5f; /* adjust saturation, scaling returned default 0.5 up to 1 */ f = curvemapping_evaluateF(node->storage, 1, hsv[0]); @@ -91,7 +91,7 @@ static void do_huecorrect_fac(bNode *node, float *out, float *in, float *fac) f = curvemapping_evaluateF(node->storage, 2, hsv[0]); hsv[2] *= (f * 2.f); - CLAMP(hsv[0], 0.f, 1.f); + hsv[0] = hsv[0] - floor(hsv[0]); /* mod 1.0 */ CLAMP(hsv[1], 0.f, 1.f); /* convert back to rgb */ diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_image.c b/source/blender/nodes/intern/CMP_nodes/CMP_image.c index 1ea3cf96ad0..3caaad26bae 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_image.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_image.c @@ -294,12 +294,12 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE static void node_composit_init_image(bNode* node) { - ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); - node->storage= iuser; - iuser->frames= 1; - iuser->sfra= 1; - iuser->fie_ima= 2; - iuser->ok= 1; + ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); + node->storage= iuser; + iuser->frames= 1; + iuser->sfra= 1; + iuser->fie_ima= 2; + iuser->ok= 1; } void register_node_type_cmp_image(ListBase *lb) @@ -321,27 +321,27 @@ void register_node_type_cmp_image(ListBase *lb) static CompBuf *compbuf_from_pass(RenderData *rd, RenderLayer *rl, int rectx, int recty, int passcode) { - float *fp= RE_RenderLayerGetPass(rl, passcode); - if(fp) { - CompBuf *buf; - int buftype= CB_VEC3; - - if(ELEM3(passcode, SCE_PASS_Z, SCE_PASS_INDEXOB, SCE_PASS_MIST)) - buftype= CB_VAL; - else if(passcode==SCE_PASS_VECTOR) - buftype= CB_VEC4; - else if(ELEM(passcode, SCE_PASS_COMBINED, SCE_PASS_RGBA)) - buftype= CB_RGBA; - - if(rd->scemode & R_COMP_CROP) - buf= get_cropped_compbuf(&rd->disprect, fp, rectx, recty, buftype); - else { - buf= alloc_compbuf(rectx, recty, buftype, 0); - buf->rect= fp; - } - return buf; - } - return NULL; + float *fp= RE_RenderLayerGetPass(rl, passcode); + if(fp) { + CompBuf *buf; + int buftype= CB_VEC3; + + if(ELEM3(passcode, SCE_PASS_Z, SCE_PASS_INDEXOB, SCE_PASS_MIST)) + buftype= CB_VAL; + else if(passcode==SCE_PASS_VECTOR) + buftype= CB_VEC4; + else if(ELEM(passcode, SCE_PASS_COMBINED, SCE_PASS_RGBA)) + buftype= CB_RGBA; + + if(rd->scemode & R_COMP_CROP) + buf= get_cropped_compbuf(&rd->disprect, fp, rectx, recty, buftype); + else { + buf= alloc_compbuf(rectx, recty, buftype, 0); + buf->rect= fp; + } + return buf; + } + return NULL; } static void node_composit_rlayers_out(RenderData *rd, RenderLayer *rl, bNodeStack **out, int rectx, int recty) @@ -383,51 +383,51 @@ static void node_composit_rlayers_out(RenderData *rd, RenderLayer *rl, bNodeStac static void node_composit_exec_rlayers(void *data, bNode *node, bNodeStack **UNUSED(in), bNodeStack **out) { - Scene *sce= (Scene *)node->id; - Render *re= (sce)? RE_GetRender(sce->id.name): NULL; - RenderData *rd= data; - RenderResult *rr= NULL; - - if(re) - rr= RE_AcquireResultRead(re); - - if(rr) { - SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); - if(srl) { - RenderLayer *rl= RE_GetRenderLayer(rr, srl->name); - if(rl && rl->rectf) { - CompBuf *stackbuf; - - /* we put render rect on stack, cbuf knows rect is from other ibuf when freed! */ - if(rd->scemode & R_COMP_CROP) - stackbuf= get_cropped_compbuf(&rd->disprect, rl->rectf, rr->rectx, rr->recty, CB_RGBA); - else { - stackbuf= alloc_compbuf(rr->rectx, rr->recty, CB_RGBA, 0); - stackbuf->rect= rl->rectf; - } - if(stackbuf==NULL) { - printf("Error; Preview Panel in UV Window returns zero sized image\n"); - } - else { - stackbuf->xof= rr->xof; - stackbuf->yof= rr->yof; + Scene *sce= (Scene *)node->id; + Render *re= (sce)? RE_GetRender(sce->id.name): NULL; + RenderData *rd= data; + RenderResult *rr= NULL; + + if(re) + rr= RE_AcquireResultRead(re); + + if(rr) { + SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); + if(srl) { + RenderLayer *rl= RE_GetRenderLayer(rr, srl->name); + if(rl && rl->rectf) { + CompBuf *stackbuf; + + /* we put render rect on stack, cbuf knows rect is from other ibuf when freed! */ + if(rd->scemode & R_COMP_CROP) + stackbuf= get_cropped_compbuf(&rd->disprect, rl->rectf, rr->rectx, rr->recty, CB_RGBA); + else { + stackbuf= alloc_compbuf(rr->rectx, rr->recty, CB_RGBA, 0); + stackbuf->rect= rl->rectf; + } + if(stackbuf==NULL) { + printf("Error; Preview Panel in UV Window returns zero sized image\n"); + } + else { + stackbuf->xof= rr->xof; + stackbuf->yof= rr->yof; - /* put on stack */ - out[RRES_OUT_IMAGE]->data= stackbuf; + /* put on stack */ + out[RRES_OUT_IMAGE]->data= stackbuf; - if(out[RRES_OUT_ALPHA]->hasoutput) - out[RRES_OUT_ALPHA]->data= valbuf_from_rgbabuf(stackbuf, CHAN_A); + if(out[RRES_OUT_ALPHA]->hasoutput) + out[RRES_OUT_ALPHA]->data= valbuf_from_rgbabuf(stackbuf, CHAN_A); - node_composit_rlayers_out(rd, rl, out, rr->rectx, rr->recty); + node_composit_rlayers_out(rd, rl, out, rr->rectx, rr->recty); - generate_preview(data, node, stackbuf); + generate_preview(data, node, stackbuf); + } } - } - } - } + } + } - if(re) - RE_ReleaseResult(re); + if(re) + RE_ReleaseResult(re); } diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_invert.c b/source/blender/nodes/intern/CMP_nodes/CMP_invert.c index f42bcb576fd..27b0324dfe0 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_invert.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_invert.c @@ -116,7 +116,7 @@ static void node_composit_exec_invert(void *UNUSED(data), bNode *node, bNodeStac static void node_composit_init_invert(bNode *node) { - node->custom1 |= CMP_CHAN_RGB; + node->custom1 |= CMP_CHAN_RGB; } /* custom1 = mix type */ diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_lensdist.c b/source/blender/nodes/intern/CMP_nodes/CMP_lensdist.c index 37c28514679..3a005210c6a 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_lensdist.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_lensdist.c @@ -44,29 +44,36 @@ static bNodeSocketType cmp_node_lensdist_out[]= { { -1, 0, "" } }; - -static void lensDistort(CompBuf* dst, CompBuf* src, float kr, float kg, float kb, int jit, int proj, int fit) +/* assumes *dst is type RGBA */ +static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb, int jit, int proj, int fit) { int x, y, z; const float cx = 0.5f*(float)dst->x, cy = 0.5f*(float)dst->y; if (proj) { // shift - CompBuf* tsrc = dupalloc_compbuf(src); + CompBuf *tsrc = dupalloc_compbuf(src); + for (z=0; z<tsrc->type; ++z) IIR_gauss(tsrc, (kr+0.5f)*(kr+0.5f), z, 1); kr *= 20.f; + for (y=0; y<dst->y; y++) { - fRGB* colp = (fRGB*)&dst->rect[y*dst->x*dst->type]; + fRGB *colp = (fRGB*)&dst->rect[y*dst->x*dst->type]; const float v = (y + 0.5f)/(float)dst->y; + for (x=0; x<dst->x; x++) { const float u = (x + 0.5f)/(float)dst->x; + qd_getPixelLerpChan(tsrc, (u*dst->x + kr) - 0.5f, v*dst->y - 0.5f, 0, colp[x]); if (tsrc->type == CB_VAL) colp[x][1] = tsrc->rect[x + y*tsrc->x]; else colp[x][1] = tsrc->rect[(x + y*tsrc->x)*tsrc->type + 1]; qd_getPixelLerpChan(tsrc, (u*dst->x - kr) - 0.5f, v*dst->y - 0.5f, 2, colp[x]+2); + + /* set alpha */ + colp[x][3]= 1.0f; } } free_compbuf(tsrc); @@ -80,17 +87,20 @@ static void lensDistort(CompBuf* dst, CompBuf* src, float kr, float kg, float kb const float mk = MAX3(kr, kg, kb); const float sc = (fit && (mk > 0.f)) ? (1.f/(1.f + 2.f*mk)) : (1.f/(1.f + mk)); const float drg = 4.f*(kg - kr), dgb = 4.f*(kb - kg); + kr *= 4.f, kg *= 4.f, kb *= 4.f; for (y=0; y<dst->y; y++) { - fRGB* colp = (fRGB*)&dst->rect[y*dst->x*dst->type]; + fRGB *colp = (fRGB*)&dst->rect[y*dst->x*dst->type]; const float v = sc*((y + 0.5f) - cy)/cy; + for (x=0; x<dst->x; x++) { int dr = 0, dg = 0, db = 0; float d, t, ln[6] = {0, 0, 0, 0, 0, 0}; fRGB c1, tc = {0, 0, 0, 0}; const float u = sc*((x + 0.5f) - cx)/cx; int sta = 0, mid = 0, end = 0; + if ((t = 1.f - kr*(u*u + v*v)) >= 0.f) { d = 1.f/(1.f + sqrtf(t)); ln[0] = (u*d + 0.5f)*dst->x - 0.5f, ln[1] = (v*d + 0.5f)*dst->y - 0.5f; @@ -113,6 +123,7 @@ static void lensDistort(CompBuf* dst, CompBuf* src, float kr, float kg, float kb const float dsf = sqrtf(dx*dx + dy*dy) + 1.f; const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf); const float sd = 1.f/(float)ds; + for (z=0; z<ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd; t = 1.f - (kr + tz*drg)*(u*u + v*v); @@ -128,6 +139,7 @@ static void lensDistort(CompBuf* dst, CompBuf* src, float kr, float kg, float kb const float dsf = sqrtf(dx*dx + dy*dy) + 1.f; const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf); const float sd = 1.f/(float)ds; + for (z=0; z<ds; ++z) { const float tz = ((float)z + (jit ? BLI_frand() : 0.5f))*sd; t = 1.f - (kg + tz*dgb)*(u*u + v*v); @@ -144,18 +156,18 @@ static void lensDistort(CompBuf* dst, CompBuf* src, float kr, float kg, float kb if (dg) colp[x][1] = 2.f*tc[1] / (float)dg; if (db) colp[x][2] = 2.f*tc[2] / (float)db; + /* set alpha */ + colp[x][3]= 1.0f; } } - } - } static void node_composit_exec_lensdist(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { CompBuf *new, *img = in[0]->data; - NodeLensDist* nld = node->storage; + NodeLensDist *nld = node->storage; const float k = MAX2(MIN2(in[1]->vec[0], 1.f), -0.999f); // smaller dispersion range for somewhat more control const float d = 0.25f*MAX2(MIN2(in[2]->vec[0], 1.f), 0.f); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_levels.c b/source/blender/nodes/intern/CMP_nodes/CMP_levels.c index 4436be14b5c..2c9f7d97f09 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_levels.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_levels.c @@ -330,7 +330,7 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack * static void node_composit_init_view_levels(bNode* node) { - node->custom1=1; /*All channels*/ + node->custom1=1; /*All channels*/ } void register_node_type_cmp_view_levels(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_lummaMatte.c b/source/blender/nodes/intern/CMP_nodes/CMP_lummaMatte.c index 7ed38996cf8..34e58791932 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_lummaMatte.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_lummaMatte.c @@ -102,10 +102,10 @@ static void node_composit_exec_luma_matte(void *data, bNode *node, bNodeStack ** static void node_composit_init_luma_matte(bNode *node) { - NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); - node->storage=c; - c->t1= 1.0f; - c->t2= 0.0f; + NodeChroma *c= MEM_callocN(sizeof(NodeChroma), "node chroma"); + node->storage=c; + c->t1= 1.0f; + c->t2= 0.0f; } void register_node_type_cmp_luma_matte(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_mapValue.c b/source/blender/nodes/intern/CMP_nodes/CMP_mapValue.c index b4af253ac3a..f14e0fbd804 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_mapValue.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_mapValue.c @@ -81,7 +81,7 @@ static void node_composit_exec_map_value(void *UNUSED(data), bNode *node, bNodeS static void node_composit_init_map_value(bNode* node) { - node->storage= add_mapping(); + node->storage= add_mapping(); } void register_node_type_cmp_map_value(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_math.c b/source/blender/nodes/intern/CMP_nodes/CMP_math.c index 039f7e6fab1..4348fd18759 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_math.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_math.c @@ -102,15 +102,15 @@ static void do_math(bNode *node, float *out, float *in, float *in2) /* Only raise negative numbers by full integers */ if( in[0] >= 0 ) { out[0]= pow(in[0], in2[0]); - } else { - float y_mod_1 = fmod(in2[0], 1); + } else { + float y_mod_1 = fmod(in2[0], 1); /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */ - if (y_mod_1 > 0.999 || y_mod_1 < 0.001) { - out[0]= pow(in[0], floor(in2[0] + 0.5)); - } else { - out[0] = 0.0; - } - } + if (y_mod_1 > 0.999 || y_mod_1 < 0.001) { + out[0]= pow(in[0], floor(in2[0] + 0.5)); + } else { + out[0] = 0.0; + } + } } break; case 11: /* Logarithm */ diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_rotate.c b/source/blender/nodes/intern/CMP_nodes/CMP_rotate.c index 14f25aa442b..b6b1764ff0f 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_rotate.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_rotate.c @@ -49,80 +49,81 @@ static bNodeSocketType cmp_node_rotate_out[]= { /* only supports RGBA nodes now */ static void node_composit_exec_rotate(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - + if(out[0]->hasoutput==0) return; - + if(in[0]->data) { CompBuf *cbuf= typecheck_compbuf(in[0]->data, CB_RGBA); CompBuf *stackbuf= alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* note, this returns zero'd image */ float rad, u, v, s, c, centx, centy, miny, maxy, minx, maxx; int x, y, yo, xo; - ImBuf *ibuf, *obuf; - + ImBuf *ibuf, *obuf; + rad= (M_PI*in[1]->vec[0])/180.0f; - + s= sin(rad); c= cos(rad); centx= cbuf->x/2; centy= cbuf->y/2; - + minx= -centx; maxx= -centx + (float)cbuf->x; miny= -centy; maxy= -centy + (float)cbuf->y; - - - ibuf=IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); - obuf=IMB_allocImBuf(stackbuf->x, stackbuf->y, 32, 0); - - if(ibuf && obuf){ - ibuf->rect_float=cbuf->rect; - obuf->rect_float=stackbuf->rect; - - for(y=miny; y<maxy; y++) { - yo= y+(int)centy; - - for(x=minx; x<maxx;x++) { - u=c*x + y*s + centx; - v=-s*x + c*y + centy; - xo= x+(int)centx; - - switch(node->custom1) { - case 0: - neareast_interpolation(ibuf, obuf, u, v, xo, yo); - break ; - case 1: - bilinear_interpolation(ibuf, obuf, u, v, xo, yo); - break; - case 2: - bicubic_interpolation(ibuf, obuf, u, v, xo, yo); - } - - } + + + ibuf=IMB_allocImBuf(cbuf->x, cbuf->y, 32, 0); + obuf=IMB_allocImBuf(stackbuf->x, stackbuf->y, 32, 0); + + if(ibuf && obuf){ + ibuf->rect_float=cbuf->rect; + obuf->rect_float=stackbuf->rect; + + for(y=miny; y<maxy; y++) { + yo= y+(int)centy; + + for(x=minx; x<maxx;x++) { + u=c*x + y*s + centx; + v=-s*x + c*y + centy; + xo= x+(int)centx; + + switch(node->custom1) { + case 0: + neareast_interpolation(ibuf, obuf, u, v, xo, yo); + break ; + case 1: + bilinear_interpolation(ibuf, obuf, u, v, xo, yo); + break; + case 2: + bicubic_interpolation(ibuf, obuf, u, v, xo, yo); + } + + } } - - /* rotate offset vector too, but why negative rad, ehh?? Has to be replaced with [3][3] matrix once (ton) */ - s= sin(-rad); - c= cos(-rad); - centx= (float)cbuf->xof; centy= (float)cbuf->yof; - stackbuf->xof= (int)( c*centx + s*centy); - stackbuf->yof= (int)(-s*centx + c*centy); + + /* rotate offset vector too, but why negative rad, ehh?? Has to be replaced with [3][3] matrix once (ton) */ + s= sin(-rad); + c= cos(-rad); + centx= (float)cbuf->xof; centy= (float)cbuf->yof; + stackbuf->xof= (int)( c*centx + s*centy); + stackbuf->yof= (int)(-s*centx + c*centy); IMB_freeImBuf(ibuf); IMB_freeImBuf(obuf); } - + /* pass on output and free */ out[0]->data= stackbuf; - if(cbuf!=in[0]->data) + if(cbuf!=in[0]->data) { free_compbuf(cbuf); + } } } static void node_composit_init_rotate(bNode *node) { - node->custom1= 1; /* Bilinear Filter*/ + node->custom1= 1; /* Bilinear Filter*/ } void register_node_type_cmp_rotate(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c b/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c index 4e338c73c39..87c4ed1dac0 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_sepcombHSVA.c @@ -69,7 +69,7 @@ static void node_composit_exec_sephsva(void *UNUSED(data), bNode *node, bNodeSta if(in[0]->data==NULL) { float h, s, v; - rgb_to_hsv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], &h, &s, &v); + rgb_to_hsv(in[0]->vec[0], in[0]->vec[1], in[0]->vec[2], &h, &s, &v); out[0]->vec[0] = h; out[1]->vec[0] = s; @@ -129,46 +129,46 @@ static bNodeSocketType cmp_node_combhsva_out[]= { static void do_comb_hsva(bNode *UNUSED(node), float *out, float *in1, float *in2, float *in3, float *in4) { - float r,g,b; - hsv_to_rgb(in1[0], in2[0], in3[0], &r, &g, &b); + float r,g,b; + hsv_to_rgb(in1[0], in2[0], in3[0], &r, &g, &b); - out[0] = r; - out[1] = g; - out[2] = b; - out[3] = in4[0]; + out[0] = r; + out[1] = g; + out[2] = b; + out[3] = in4[0]; } static void node_composit_exec_combhsva(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - /* stack order out: 1 rgba channels */ - /* stack order in: 4 value channels */ - - /* input no image? then only color operation */ - if((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { - out[0]->vec[0] = in[0]->vec[0]; - out[0]->vec[1] = in[1]->vec[0]; - out[0]->vec[2] = in[2]->vec[0]; - out[0]->vec[3] = in[3]->vec[0]; - } - else { - /* make output size of first available input image */ - CompBuf *cbuf; - CompBuf *stackbuf; - - /* allocate a CompBuf the size of the first available input */ - if (in[0]->data) cbuf = in[0]->data; - else if (in[1]->data) cbuf = in[1]->data; - else if (in[2]->data) cbuf = in[2]->data; - else cbuf = in[3]->data; - - stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ - - composit4_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, - in[2]->data, in[2]->vec, in[3]->data, in[3]->vec, - do_comb_hsva, CB_VAL, CB_VAL, CB_VAL, CB_VAL); - - out[0]->data= stackbuf; - } + /* stack order out: 1 rgba channels */ + /* stack order in: 4 value channels */ + + /* input no image? then only color operation */ + if((in[0]->data==NULL) && (in[1]->data==NULL) && (in[2]->data==NULL) && (in[3]->data==NULL)) { + out[0]->vec[0] = in[0]->vec[0]; + out[0]->vec[1] = in[1]->vec[0]; + out[0]->vec[2] = in[2]->vec[0]; + out[0]->vec[3] = in[3]->vec[0]; + } + else { + /* make output size of first available input image */ + CompBuf *cbuf; + CompBuf *stackbuf; + + /* allocate a CompBuf the size of the first available input */ + if (in[0]->data) cbuf = in[0]->data; + else if (in[1]->data) cbuf = in[1]->data; + else if (in[2]->data) cbuf = in[2]->data; + else cbuf = in[3]->data; + + stackbuf = alloc_compbuf(cbuf->x, cbuf->y, CB_RGBA, 1); /* allocs */ + + composit4_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[1]->data, in[1]->vec, + in[2]->data, in[2]->vec, in[3]->data, in[3]->vec, + do_comb_hsva, CB_VAL, CB_VAL, CB_VAL, CB_VAL); + + out[0]->data= stackbuf; + } } void register_node_type_cmp_combhsva(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_splitViewer.c b/source/blender/nodes/intern/CMP_nodes/CMP_splitViewer.c index 69499f25b39..13cb3bcfed5 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_splitViewer.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_splitViewer.c @@ -143,12 +143,12 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * static void node_composit_init_splitviewer(bNode* node) { - ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); - node->storage= iuser; - iuser->sfra= 1; - iuser->fie_ima= 2; - iuser->ok= 1; - node->custom1= 50; /* default 50% split */ + ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); + node->storage= iuser; + iuser->sfra= 1; + iuser->fie_ima= 2; + iuser->ok= 1; + node->custom1= 50; /* default 50% split */ } void register_node_type_cmp_splitviewer(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_valToRgb.c b/source/blender/nodes/intern/CMP_nodes/CMP_valToRgb.c index fa6b5db89f6..1e1c8c61b46 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_valToRgb.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_valToRgb.c @@ -82,7 +82,7 @@ static void node_composit_exec_valtorgb(void *UNUSED(data), bNode *node, bNodeSt static void node_composit_init_valtorgb(bNode* node) { - node->storage= add_colorband(1); + node->storage= add_colorband(1); } void register_node_type_cmp_valtorgb(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_vecBlur.c b/source/blender/nodes/intern/CMP_nodes/CMP_vecBlur.c index b21418f6698..c43bfa2435a 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_vecBlur.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_vecBlur.c @@ -89,10 +89,10 @@ static void node_composit_exec_vecblur(void *UNUSED(data), bNode *node, bNodeSta static void node_composit_init_vecblur(bNode* node) { - NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur data"); - node->storage= nbd; - nbd->samples= 32; - nbd->fac= 1.0f; + NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur data"); + node->storage= nbd; + nbd->samples= 32; + nbd->fac= 1.0f; } /* custom1: itterations, custom2: maxspeed (0 = nolimit) */ diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_viewer.c b/source/blender/nodes/intern/CMP_nodes/CMP_viewer.c index b3629eb1e16..c4e719efbf9 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_viewer.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_viewer.c @@ -126,11 +126,11 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, static void node_composit_init_viewer(bNode* node) { - ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); - node->storage= iuser; - iuser->sfra= 1; - iuser->fie_ima= 2; - iuser->ok= 1; + ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); + node->storage= iuser; + iuser->sfra= 1; + iuser->fie_ima= 2; + iuser->ok= 1; } void register_node_type_cmp_viewer(ListBase *lb) diff --git a/source/blender/nodes/intern/CMP_util.c b/source/blender/nodes/intern/CMP_util.c index 45e7cf9d3e7..78025f4d964 100644 --- a/source/blender/nodes/intern/CMP_util.c +++ b/source/blender/nodes/intern/CMP_util.c @@ -673,116 +673,116 @@ void generate_preview(void *data, bNode *node, CompBuf *stackbuf) void do_rgba_to_yuva(bNode *UNUSED(node), float *out, float *in) { - rgb_to_yuv(in[0],in[1],in[2], &out[0], &out[1], &out[2]); - out[3]=in[3]; + rgb_to_yuv(in[0],in[1],in[2], &out[0], &out[1], &out[2]); + out[3]=in[3]; } void do_rgba_to_hsva(bNode *UNUSED(node), float *out, float *in) { - rgb_to_hsv(in[0],in[1],in[2], &out[0], &out[1], &out[2]); - out[3]=in[3]; + rgb_to_hsv(in[0],in[1],in[2], &out[0], &out[1], &out[2]); + out[3]=in[3]; } void do_rgba_to_ycca(bNode *UNUSED(node), float *out, float *in) { - rgb_to_ycc(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601); - out[3]=in[3]; + rgb_to_ycc(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601); + out[3]=in[3]; } void do_yuva_to_rgba(bNode *UNUSED(node), float *out, float *in) { - yuv_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2]); - out[3]=in[3]; + yuv_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2]); + out[3]=in[3]; } void do_hsva_to_rgba(bNode *UNUSED(node), float *out, float *in) { - hsv_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2]); - out[3]=in[3]; + hsv_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2]); + out[3]=in[3]; } void do_ycca_to_rgba(bNode *UNUSED(node), float *out, float *in) { - ycc_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601); - out[3]=in[3]; + ycc_to_rgb(in[0],in[1],in[2], &out[0], &out[1], &out[2], BLI_YCC_ITU_BT601); + out[3]=in[3]; } void do_copy_rgba(bNode *UNUSED(node), float *out, float *in) { - QUATCOPY(out, in); + QUATCOPY(out, in); } void do_copy_rgb(bNode *UNUSED(node), float *out, float *in) { - VECCOPY(out, in); - out[3]= 1.0f; + VECCOPY(out, in); + out[3]= 1.0f; } void do_copy_value(bNode *UNUSED(node), float *out, float *in) { - out[0]= in[0]; + out[0]= in[0]; } void do_copy_a_rgba(bNode *UNUSED(node), float *out, float *in, float *fac) { - VECCOPY(out, in); - out[3]= *fac; + VECCOPY(out, in); + out[3]= *fac; } /* only accepts RGBA buffers */ void gamma_correct_compbuf(CompBuf *img, int inversed) { - float *drect; - int x; - - if(img->type!=CB_RGBA) return; - - drect= img->rect; - if(inversed) { - for(x=img->x*img->y; x>0; x--, drect+=4) { - if(drect[0]>0.0f) drect[0]= sqrt(drect[0]); else drect[0]= 0.0f; - if(drect[1]>0.0f) drect[1]= sqrt(drect[1]); else drect[1]= 0.0f; - if(drect[2]>0.0f) drect[2]= sqrt(drect[2]); else drect[2]= 0.0f; - } - } - else { - for(x=img->x*img->y; x>0; x--, drect+=4) { - if(drect[0]>0.0f) drect[0]*= drect[0]; else drect[0]= 0.0f; - if(drect[1]>0.0f) drect[1]*= drect[1]; else drect[1]= 0.0f; - if(drect[2]>0.0f) drect[2]*= drect[2]; else drect[2]= 0.0f; - } - } + float *drect; + int x; + + if(img->type!=CB_RGBA) return; + + drect= img->rect; + if(inversed) { + for(x=img->x*img->y; x>0; x--, drect+=4) { + if(drect[0]>0.0f) drect[0]= sqrt(drect[0]); else drect[0]= 0.0f; + if(drect[1]>0.0f) drect[1]= sqrt(drect[1]); else drect[1]= 0.0f; + if(drect[2]>0.0f) drect[2]= sqrt(drect[2]); else drect[2]= 0.0f; + } + } + else { + for(x=img->x*img->y; x>0; x--, drect+=4) { + if(drect[0]>0.0f) drect[0]*= drect[0]; else drect[0]= 0.0f; + if(drect[1]>0.0f) drect[1]*= drect[1]; else drect[1]= 0.0f; + if(drect[2]>0.0f) drect[2]*= drect[2]; else drect[2]= 0.0f; + } + } } void premul_compbuf(CompBuf *img, int inversed) { - float *drect; - int x; - - if(img->type!=CB_RGBA) return; - - drect= img->rect; - if(inversed) { - for(x=img->x*img->y; x>0; x--, drect+=4) { - if(fabs(drect[3]) < 1e-5f) { - drect[0]= 0.0f; - drect[1]= 0.0f; - drect[2]= 0.0f; - } - else { - drect[0] /= drect[3]; - drect[1] /= drect[3]; - drect[2] /= drect[3]; - } - } - } - else { - for(x=img->x*img->y; x>0; x--, drect+=4) { - drect[0] *= drect[3]; - drect[1] *= drect[3]; - drect[2] *= drect[3]; - } - } + float *drect; + int x; + + if(img->type!=CB_RGBA) return; + + drect= img->rect; + if(inversed) { + for(x=img->x*img->y; x>0; x--, drect+=4) { + if(fabs(drect[3]) < 1e-5f) { + drect[0]= 0.0f; + drect[1]= 0.0f; + drect[2]= 0.0f; + } + else { + drect[0] /= drect[3]; + drect[1] /= drect[3]; + drect[2] /= drect[3]; + } + } + } + else { + for(x=img->x*img->y; x>0; x--, drect+=4) { + drect[0] *= drect[3]; + drect[1] *= drect[3]; + drect[2] *= drect[3]; + } + } } diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_curves.c b/source/blender/nodes/intern/SHD_nodes/SHD_curves.c index 78b5e4c1e56..a39a639897e 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_curves.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_curves.c @@ -59,7 +59,7 @@ static void node_shader_exec_curve_vec(void *UNUSED(data), bNode *node, bNodeSta static void node_shader_init_curve_vec(bNode* node) { - node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); + node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f); } static int gpu_shader_curve_vec(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) @@ -114,7 +114,7 @@ static void node_shader_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeSta static void node_shader_init_curve_rgb(bNode *node) { - node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); + node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); } static int gpu_shader_curve_rgb(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_geom.c b/source/blender/nodes/intern/SHD_nodes/SHD_geom.c index c08d5f3548d..379f54bec57 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_geom.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_geom.c @@ -120,7 +120,7 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(i static void node_shader_init_geometry(bNode *node) { - node->storage= MEM_callocN(sizeof(NodeGeometry), "NodeGeometry"); + node->storage= MEM_callocN(sizeof(NodeGeometry), "NodeGeometry"); } static int gpu_shader_geom(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c b/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c index 528b43ae56e..eb300301ce2 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_mapping.c @@ -71,7 +71,7 @@ static void node_shader_exec_mapping(void *UNUSED(data), bNode *node, bNodeStack static void node_shader_init_mapping(bNode *node) { - node->storage= add_mapping(); + node->storage= add_mapping(); } static int gpu_shader_mapping(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_material.c b/source/blender/nodes/intern/SHD_nodes/SHD_material.c index 317dd07f8fe..40dfbc0edea 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_material.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_material.c @@ -195,7 +195,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, static void node_shader_init_material(bNode* node) { - node->custom1= SH_NODE_MAT_DIFF|SH_NODE_MAT_SPEC; + node->custom1= SH_NODE_MAT_DIFF|SH_NODE_MAT_SPEC; } static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_valToRgb.c b/source/blender/nodes/intern/SHD_nodes/SHD_valToRgb.c index d2538f4c819..86f832c12ee 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_valToRgb.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_valToRgb.c @@ -61,7 +61,7 @@ static void node_shader_exec_valtorgb(void *UNUSED(data), bNode *node, bNodeStac static void node_shader_init_valtorgb(bNode *node) { - node->storage= add_colorband(1); + node->storage= add_colorband(1); } static int gpu_shader_valtorgb(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) @@ -102,10 +102,10 @@ static bNodeSocketType sh_node_rgbtobw_out[]= { static void node_shader_exec_rgbtobw(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, bNodeStack **out) { - /* stack order out: bw */ - /* stack order in: col */ + /* stack order out: bw */ + /* stack order in: col */ - out[0]->vec[0]= in[0]->vec[0]*0.35f + in[0]->vec[1]*0.45f + in[0]->vec[2]*0.2f; + out[0]->vec[0]= in[0]->vec[0]*0.35f + in[0]->vec[1]*0.45f + in[0]->vec[2]*0.2f; } static int gpu_shader_rgbtobw(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c index e388efd17c0..b7af6c748ff 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_curves.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_curves.c @@ -62,9 +62,9 @@ static void time_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out static void time_init(bNode* node) { - node->custom1= 1; - node->custom2= 250; - node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); + node->custom1= 1; + node->custom2= 250; + node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); } void register_node_type_tex_curve_time(ListBase *lb) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_image.c b/source/blender/nodes/intern/TEX_nodes/TEX_image.c index fcb18ab3342..a54ca4bb119 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_image.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_image.c @@ -90,11 +90,11 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) static void init(bNode* node) { - ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); - node->storage= iuser; - iuser->sfra= 1; - iuser->fie_ima= 2; - iuser->ok= 1; + ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "node image user"); + node->storage= iuser; + iuser->sfra= 1; + iuser->fie_ima= 2; + iuser->ok= 1; } void register_node_type_tex_image(ListBase *lb) diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c index e00781741a0..18468bdd55c 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_math.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_math.c @@ -114,14 +114,14 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor /* Only raise negative numbers by full integers */ if( in0 >= 0 ) { out[0]= pow(in0, in1); - } else { - float y_mod_1 = fmod(in1, 1); + } else { + float y_mod_1 = fmod(in1, 1); if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { *out = pow(in0, floor(in1 + 0.5f)); - } else { - *out = 0.0; - } - } + } else { + *out = 0.0; + } + } } break; case 11: /* Logarithm */ diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c index 19fa6c67c09..8f59828081c 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_valToRgb.c @@ -80,12 +80,12 @@ void register_node_type_tex_valtorgb(ListBase *lb) /* **************** RGBTOBW ******************** */ static bNodeSocketType rgbtobw_in[]= { - { SOCK_RGBA, 1, "Color", 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, - { -1, 0, "" } + { SOCK_RGBA, 1, "Color", 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, + { -1, 0, "" } }; static bNodeSocketType rgbtobw_out[]= { - { SOCK_VALUE, 0, "Val", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - { -1, 0, "" } + { SOCK_VALUE, 0, "Val", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, + { -1, 0, "" } }; diff --git a/source/blender/nodes/intern/TEX_util.c b/source/blender/nodes/intern/TEX_util.c index 51b3c6d909f..b5e27ca2ccb 100644 --- a/source/blender/nodes/intern/TEX_util.c +++ b/source/blender/nodes/intern/TEX_util.c @@ -41,7 +41,7 @@ retrieve the color from the delegate. comments: (ton) - + This system needs recode, a node system should rely on the stack, and callbacks for nodes only should evaluate own node, not recursively go over other previous ones. diff --git a/source/blender/python/generic/IDProp.c b/source/blender/python/generic/IDProp.c index 36dc6fca503..ccf498f1550 100644 --- a/source/blender/python/generic/IDProp.c +++ b/source/blender/python/generic/IDProp.c @@ -513,15 +513,15 @@ static PyObject *BPy_IDGroup_MapDataToPy(IDProperty *prop) for (i=0; i<prop->len; i++) { if (prop->subtype == IDP_FLOAT) { PyList_SET_ITEM(seq, i, - PyFloat_FromDouble(((float*)prop->data.pointer)[i])); + PyFloat_FromDouble(((float*)prop->data.pointer)[i])); } else if (prop->subtype == IDP_DOUBLE) { PyList_SET_ITEM(seq, i, - PyFloat_FromDouble(((double*)prop->data.pointer)[i])); + PyFloat_FromDouble(((double*)prop->data.pointer)[i])); } else { PyList_SET_ITEM(seq, i, - PyLong_FromLong(((int*)prop->data.pointer)[i])); + PyLong_FromLong(((int*)prop->data.pointer)[i])); } } return seq; @@ -588,7 +588,7 @@ static PyObject *BPy_IDGroup_Pop(BPy_IDProperty *self, PyObject *value) /*ok something bad happened with the pyobject, so don't remove the prop from the group. if pyform is NULL, then it already should have raised an exception.*/ - return NULL; + return NULL; } IDP_RemFromGroup(self->prop, idprop); diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 2c15755a642..730db73e685 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -132,16 +132,16 @@ static PyObject *Method_##funcname (PyObject *UNUSED(self), PyObject *args) {\ int BGL_typeSize(int type) { switch (type) { - case GL_BYTE: - return sizeof(char); - case GL_SHORT: - return sizeof(short); - case GL_INT: - return sizeof(int); - case GL_FLOAT: - return sizeof(float); - case GL_DOUBLE: - return sizeof(double); + case GL_BYTE: + return sizeof(char); + case GL_SHORT: + return sizeof(short); + case GL_INT: + return sizeof(int); + case GL_FLOAT: + return sizeof(float); + case GL_DOUBLE: + return sizeof(double); } return -1; } @@ -293,7 +293,7 @@ static PyObject *Buffer_item(PyObject *self, int i) size= BGL_typeSize(buf->type); newbuf= (Buffer *) PyObject_NEW(Buffer, &BGL_bufferType); - + Py_INCREF(self); newbuf->parent= self; @@ -307,7 +307,7 @@ static PyObject *Buffer_item(PyObject *self, int i) return (PyObject *) newbuf; } - + return NULL; } @@ -435,7 +435,7 @@ static PyObject *Buffer_dimensions(PyObject *self) Buffer *buffer= (Buffer *) self; PyObject *list= PyList_New(buffer->ndimensions); int i; - + for (i= 0; i<buffer->ndimensions; i++) { PyList_SET_ITEM(list, i, PyLong_FromLong(buffer->dimensions[i])); } @@ -804,7 +804,7 @@ BGLU_Wrap(9, UnProject, GLint, (GLdouble, GLdouble, GLdouble, GLdoubleP, GLdo * {"glAccum", Method_Accumfunc, METH_VARARGS} */ static struct PyMethodDef BGL_methods[] = { - {"Buffer", Method_Buffer, METH_VARARGS, Method_Buffer_doc}, + {"Buffer", Method_Buffer, METH_VARARGS, Method_Buffer_doc}, /* #ifndef __APPLE__ */ MethodDef(Accum), @@ -1641,7 +1641,7 @@ PyObject *BPyInit_bgl(void) EXPP_ADDCONST(GL_TEXTURE_RESIDENT); EXPP_ADDCONST(GL_TEXTURE_BINDING_1D); EXPP_ADDCONST(GL_TEXTURE_BINDING_2D); - + return submodule; } diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c index 0ea4e083e3e..96fe13bf6fc 100644 --- a/source/blender/python/generic/bpy_internal_import.c +++ b/source/blender/python/generic/bpy_internal_import.c @@ -132,7 +132,7 @@ PyObject *bpy_text_import(Text *text) PyObject *bpy_text_import_name(char *name, int *found) { Text *text; - char txtname[22]; /* 21+NULL */ + char txtname[MAX_ID_NAME-2]; int namelen= strlen(name); //XXX Main *maggie= bpy_import_main ? bpy_import_main:G.main; Main *maggie= bpy_import_main; @@ -144,7 +144,7 @@ PyObject *bpy_text_import_name(char *name, int *found) return NULL; } - if (namelen>21-3) return NULL; /* we know this cant be importable, the name is too long for blender! */ + if (namelen >= (MAX_ID_NAME-2) - 3) return NULL; /* we know this cant be importable, the name is too long for blender! */ memcpy(txtname, name, namelen); memcpy(&txtname[namelen], ".py", 4); @@ -304,7 +304,7 @@ static PyObject *blender_reload(PyObject *UNUSED(self), PyObject * module) } else { /* no blender text was found that could import the module - * rause the original error from PyImport_ImportModuleEx */ + * reuse the original error from PyImport_ImportModuleEx */ PyErr_Restore(exception, err, tb); } @@ -326,8 +326,8 @@ PyMethodDef bpy_reload_meth= {"bpy_reload_meth", (PyCFunction)blender_reload, ME * it wont reload scripts between loading different blend files or while making the game. * - use 'clear_all' arg in this case. * - * Since pythons bultins include a full path even for win32. - * even if we remove a python module a reimport will bring it back again. + * Since pythons built-ins include a full path even for win32. + * even if we remove a python module a re-import will bring it back again. */ #if 0 // not used anymore but may still come in handy later diff --git a/source/blender/python/generic/mathutils_geometry.c b/source/blender/python/generic/mathutils_geometry.c index 51b1a9754c9..6031c716807 100644 --- a/source/blender/python/generic/mathutils_geometry.c +++ b/source/blender/python/generic/mathutils_geometry.c @@ -841,10 +841,10 @@ static PyObject *M_Geometry_barycentric_transform(PyObject *UNUSED(self), PyObje vec_t1_tar->size != 3 || vec_t2_tar->size != 3 || vec_t3_tar->size != 3) - { - PyErr_SetString(PyExc_ValueError, "One of more of the vector arguments wasnt a 3D vector"); - return NULL; - } + { + PyErr_SetString(PyExc_ValueError, "One of more of the vector arguments wasnt a 3D vector"); + return NULL; + } barycentric_transform(vec, vec_pt->vec, vec_t1_tar->vec, vec_t2_tar->vec, vec_t3_tar->vec, diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 7182d5f75d0..ec774f44075 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -30,6 +30,12 @@ #include "py_capi_utils.h" +#include "BKE_font.h" /* only for utf8towchar, should replace with py funcs but too late in release now */ + +#ifdef _WIN32 /* BLI_setenv */ +#include "BLI_path_util.h" +#endif + #define PYC_INTERPRETER_ACTIVE (((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current)) != NULL) /* for debugging */ @@ -284,6 +290,48 @@ void PyC_MainModule_Restore(PyObject *main_mod) Py_XDECREF(main_mod); } +/* must be called before Py_Initialize, expects output of BLI_get_folder(BLENDER_PYTHON, NULL) */ +void PyC_SetHomePath(const char *py_path_bundle) +{ + if(py_path_bundle==NULL) { + /* Common enough to have bundled *nix python but complain on OSX/Win */ +#if defined(__APPLE__) || defined(_WIN32) + fprintf(stderr, "Warning! bundled python not found and is expected on this platform. (if you built with CMake: 'install' target may have not been built)\n"); +#endif + return; + } + /* set the environment path */ + printf("found bundled python: %s\n", py_path_bundle); + +#ifdef __APPLE__ + /* OSX allow file/directory names to contain : character (represented as / in the Finder) + but current Python lib (release 3.1.1) doesn't handle these correctly */ + if(strchr(py_path_bundle, ':')) + printf("Warning : Blender application is located in a path containing : or / chars\ + \nThis may make python import function fail\n"); +#endif + +#ifdef _WIN32 + /* cmake/MSVC debug build crashes without this, why only + in this case is unknown.. */ + { + BLI_setenv("PYTHONPATH", py_path_bundle); + } +#endif + + { + static wchar_t py_path_bundle_wchar[1024]; + + /* cant use this, on linux gives bug: #23018, TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 22008 */ + /* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */ + + utf8towchar(py_path_bundle_wchar, py_path_bundle); + + Py_SetPythonHome(py_path_bundle_wchar); + // printf("found python (wchar_t) '%ls'\n", py_path_bundle_wchar); + } +} + /* Would be nice if python had this built in */ void PyC_RunQuicky(const char *filepath, int n, ...) { diff --git a/source/blender/python/generic/py_capi_utils.h b/source/blender/python/generic/py_capi_utils.h index 0b821759bec..1730ad71721 100644 --- a/source/blender/python/generic/py_capi_utils.h +++ b/source/blender/python/generic/py_capi_utils.h @@ -48,4 +48,6 @@ void PyC_RunQuicky(const char *filepath, int n, ...); void PyC_MainModule_Backup(PyObject **main_mod); void PyC_MainModule_Restore(PyObject *main_mod); +void PyC_SetHomePath(const char *py_path_bundle); + #endif // PY_CAPI_UTILS_H diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 414b284695f..e43d3a8e98c 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -46,7 +46,7 @@ #include "BLI_bpath.h" #include "BLI_utildefines.h" - +#include "BKE_main.h" #include "BKE_global.h" /* XXX, G.main only */ #include "BKE_blender.h" @@ -78,12 +78,12 @@ static PyObject *bpy_script_paths(PyObject *UNUSED(self)) { PyObject *ret= PyTuple_New(2); char *path; - + path= BLI_get_folder(BLENDER_USER_SCRIPTS, NULL); PyTuple_SET_ITEM(ret, 0, PyUnicode_FromString(path?path:"")); path= BLI_get_folder(BLENDER_SYSTEM_SCRIPTS, NULL); PyTuple_SET_ITEM(ret, 1, PyUnicode_FromString(path?path:"")); - + return ret; } @@ -113,7 +113,7 @@ static PyObject *bpy_blend_paths(PyObject *UNUSED(self), PyObject *args, PyObjec list= PyList_New(0); - for(BLI_bpathIterator_init(&bpi, G.main, NULL, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) { + for(BLI_bpathIterator_init(&bpi, G.main, G.main->name, 0); !BLI_bpathIterator_isDone(bpi); BLI_bpathIterator_step(bpi)) { /* build the list */ if (absolute) { BLI_bpathIterator_getPathExpanded(bpi, filepath_expanded); diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 27260aed8d2..df31fab6bde 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -255,7 +255,7 @@ float BPY_driver_exec(ChannelDriver *driver) if(use_gil) PyGILState_Release(gilstate); - + if(finite(result)) { return (float)result; } diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 555b42eb6fb..284686048d3 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -164,52 +164,6 @@ void BPY_modules_update(bContext *C) bpy_context_module->ptr.data= (void *)C; } -/* must be called before Py_Initialize */ -#ifndef WITH_PYTHON_MODULE -static void bpy_python_start_path(void) -{ - char *py_path_bundle= BLI_get_folder(BLENDER_PYTHON, NULL); - - if(py_path_bundle==NULL) { - /* Common enough to have bundled *nix python but complain on OSX/Win */ -#if defined(__APPLE__) || defined(_WIN32) - fprintf(stderr, "Warning! bundled python not found and is expected on this platform. (if you built with CMake: 'install' target may have not been built)\n"); -#endif - return; - } - /* set the environment path */ - printf("found bundled python: %s\n", py_path_bundle); - -#ifdef __APPLE__ - /* OSX allow file/directory names to contain : character (represented as / in the Finder) - but current Python lib (release 3.1.1) doesn't handle these correctly */ - if(strchr(py_path_bundle, ':')) - printf("Warning : Blender application is located in a path containing : or / chars\ - \nThis may make python import function fail\n"); -#endif - -#ifdef _WIN32 - /* cmake/MSVC debug build crashes without this, why only - in this case is unknown.. */ - { - BLI_setenv("PYTHONPATH", py_path_bundle); - } -#endif - - { - static wchar_t py_path_bundle_wchar[FILE_MAX]; - - /* cant use this, on linux gives bug: #23018, TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 22008 */ - /* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */ - - utf8towchar(py_path_bundle_wchar, py_path_bundle); - - Py_SetPythonHome(py_path_bundle_wchar); - // printf("found python (wchar_t) '%ls'\n", py_path_bundle_wchar); - } -} -#endif - void BPY_context_set(bContext *C) { BPy_SetContext(C); @@ -242,7 +196,8 @@ void BPY_python_start(int argc, const char **argv) /* must run before python initializes */ PyImport_ExtendInittab(bpy_internal_modules); - bpy_python_start_path(); /* allow to use our own included python */ + /* allow to use our own included python */ + PyC_SetHomePath(BLI_get_folder(BLENDER_PYTHON, NULL)); /* Python 3.2 now looks for '2.57/python/include/python3.2d/pyconfig.h' to parse * from the 'sysconfig' module which is used by 'site', so for now disable site. @@ -713,8 +668,8 @@ static struct PyModuleDef bpy_proxy_def= { }; typedef struct { - PyObject_HEAD - /* Type-specific fields go here. */ + PyObject_HEAD + /* Type-specific fields go here. */ PyObject *mod; } dealloc_obj; diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index e51ea048b92..53d28621ae8 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -129,7 +129,7 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw) } /* this define runs at the start of each function and deals with - * returning a deferred property (to be registed later) */ + * returning a deferred property (to be registered later) */ #define BPY_PROPDEF_HEAD(_func) \ if (PyTuple_GET_SIZE(args) == 1) { \ PyObject *ret; \ @@ -140,7 +140,7 @@ static PyObject *bpy_prop_deferred_return(PyObject *func, PyObject *kw) return ret; \ } \ else if (PyTuple_GET_SIZE(args) > 1) { \ - PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \ + PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \ return NULL; \ } \ srna= srna_from_self(self, #_func"(...):"); \ @@ -762,7 +762,7 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix } 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; } @@ -884,7 +884,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw return ret; } else if (PyTuple_GET_SIZE(args) > 1) { - PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \ + PyErr_SetString(PyExc_ValueError, "all args must be keywords"); \ return NULL; } @@ -948,7 +948,7 @@ PyObject *BPY_rna_props( void ) /* INCREF since its its assumed that all these functions return the * module with a new ref like PyDict_New, since they are passed to - * PyModule_AddObject which steals a ref */ + * PyModule_AddObject which steals a ref */ Py_INCREF(submodule); /* api needs the PyObjects internally */ diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 61ccd0d9310..19cd9df9403 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -144,7 +144,7 @@ struct GHash *id_weakref_pool= NULL; static PyObject *id_free_weakref_cb(PyObject *weakinfo_pair, PyObject *weakref); static PyMethodDef id_free_weakref_cb_def= {"id_free_weakref_cb", (PyCFunction)id_free_weakref_cb, METH_O, NULL}; -/* adds a reference to the list, remember ot decref */ +/* adds a reference to the list, remember to decref */ static GHash *id_weakref_pool_get(ID *id) { GHash *weakinfo_hash= NULL; @@ -548,7 +548,7 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_ #endif // USE_MATHUTILS /* note that PROP_NONE is included as a vector subtype. this is because its handy to - * have x/y access to fcurve keyframes and other fixed size float arrayas of length 2-4. */ + * have x/y access to fcurve keyframes and other fixed size float arrays of length 2-4. */ #define PROP_ALL_VECTOR_SUBTYPES PROP_COORDS: case PROP_TRANSLATION: case PROP_DIRECTION: case PROP_VELOCITY: case PROP_ACCELERATION: case PROP_XYZ: case PROP_XYZ_LENGTH PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) @@ -573,7 +573,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) if (totdim == 1 || (totdim == 2 && subtype == PROP_MATRIX)) { if(!is_thick) - ret= pyrna_prop_CreatePyObject(ptr, prop); /* owned by the Mathutils PyObject */ + ret= pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */ switch(RNA_property_subtype(prop)) { case PROP_ALL_VECTOR_SUBTYPES: @@ -668,7 +668,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) ret= pyrna_prop_array_subscript_slice(NULL, ptr, prop, 0, len, len); } else { - ret= pyrna_prop_CreatePyObject(ptr, prop); /* owned by the Mathutils PyObject */ + ret= pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */ } } #else // USE_MATHUTILS @@ -1670,7 +1670,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P } } else { - /* see if we can coorce into a python type - PropertyType */ + /* see if we can coerce into a python type - PropertyType */ switch (RNA_property_type(prop)) { case PROP_BOOLEAN: { @@ -1744,7 +1744,7 @@ static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self) return RNA_property_collection_length(&self->ptr, self->prop); } -/* bool funcs are for speed, so we can avoid getting the length +/* bool functions are for speed, so we can avoid getting the length * of 1000's of items in a linked list for eg. */ static int pyrna_prop_array_bool(BPy_PropertyRNA *self) { @@ -1885,7 +1885,7 @@ static PyObject *pyrna_prop_array_subscript_slice(BPy_PropertyArrayRNA *self, Po tuple= PyTuple_New(stop - start); - /* PYRNA_PROP_CHECK_OBJ(self) isnt needed, internal use only */ + /* PYRNA_PROP_CHECK_OBJ(self) isn't needed, internal use only */ totdim= RNA_property_array_dimension(ptr, prop, NULL); @@ -2177,7 +2177,7 @@ static int prop_subscript_ass_array_int(BPy_PropertyArrayRNA *self, Py_ssize_t k if(keynum >= 0 && keynum < len) return pyrna_py_to_prop_array_index(self, keynum, value); - PyErr_SetString(PyExc_IndexError, "bpy_prop_array[index]= value: index out of range"); + PyErr_SetString(PyExc_IndexError, "bpy_prop_array[index] = value: index out of range"); return -1; } @@ -2309,7 +2309,7 @@ static int pyrna_struct_contains(BPy_StructRNA *self, PyObject *value) } if(RNA_struct_idprops_check(self->ptr.type)==0) { - PyErr_SetString(PyExc_TypeError, "bpy_struct: this type doesnt support IDProperties"); + PyErr_SetString(PyExc_TypeError, "bpy_struct: this type doesn't support IDProperties"); return -1; } @@ -2942,9 +2942,9 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) #if 0 static int pyrna_struct_pydict_contains(PyObject *self, PyObject *pyname) { - PyObject *dict= *(_PyObject_GetDictPtr((PyObject *)self)); - if (dict==NULL) /* unlikely */ - return 0; + PyObject *dict= *(_PyObject_GetDictPtr((PyObject *)self)); + if (dict==NULL) /* unlikely */ + return 0; return PyDict_Contains(dict, pyname); } @@ -2965,7 +2965,7 @@ static PyObject *pyrna_struct_meta_idprop_getattro(PyObject *cls, PyObject *attr * >>> bpy.types.Scene.foo= BoolProperty() * >>> bpy.types.Scene.foo * <bpy_struct, BooleanProperty("foo")> - * ...rather then returning the defered class register tuple as checked by pyrna_is_deferred_prop() + * ...rather then returning the deferred class register tuple as checked by pyrna_is_deferred_prop() * * Disable for now, this is faking internal behavior in a way thats too tricky to maintain well. */ #if 0 @@ -3024,9 +3024,9 @@ static int pyrna_struct_meta_idprop_setattro(PyObject *cls, PyObject *attr, PyOb * but gets confusing from script writers POV if the assigned value cant be read back. */ } else { - /* remove existing property if its set or we also end up with confusement */ + /* remove existing property if its set or we also end up with confusion */ const char *attr_str= _PyUnicode_AsString(attr); - RNA_def_property_free_identifier(srna, attr_str); /* ignore on failier */ + RNA_def_property_free_identifier(srna, attr_str); /* ignore on failure */ } } else { /* __delattr__ */ @@ -3540,7 +3540,7 @@ static int foreach_parse_args( } /* check 'attr_tot' otherwise we dont know if any values were set - * this isnt ideal because it means running on an empty list may fail silently when its not compatible. */ + * this isn't ideal because it means running on an empty list may fail silently when its not compatible. */ if (*size == 0 && *attr_tot != 0) { PyErr_SetString(PyExc_AttributeError, "attribute does not support foreach method"); return -1; @@ -3705,7 +3705,7 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) if(PyErr_Occurred()) { /* Maybe we could make our own error */ PyErr_Print(); - PyErr_SetString(PyExc_TypeError, "could not access the py sequence"); + PyErr_SetString(PyExc_TypeError, "couldn't access the py sequence"); return NULL; } if (!ok) { @@ -3719,13 +3719,13 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) static char pyrna_prop_collection_foreach_get_doc[] = ".. method:: foreach_get(attr, seq)\n" "\n" -" This is a function to give fast access to attribites within a collection.\n" +" This is a function to give fast access to attributes within a collection.\n" "\n" " .. code-block:: python\n" "\n" " collection.foreach_get(someseq, attr)\n" "\n" -" # Python equivelent\n" +" # Python equivalent\n" " for i in range(len(seq)): someseq[i]= getattr(collection, attr)\n" "\n" ; @@ -3739,13 +3739,13 @@ static PyObject *pyrna_prop_collection_foreach_get(BPy_PropertyRNA *self, PyObje static char pyrna_prop_collection_foreach_set_doc[] = ".. method:: foreach_set(attr, seq)\n" "\n" -" This is a function to give fast access to attribites within a collection.\n" +" This is a function to give fast access to attributes within a collection.\n" "\n" " .. code-block:: python\n" "\n" " collection.foreach_set(seq, attr)\n" "\n" -" # Python equivelent\n" +" # Python equivalent\n" " for i in range(len(seq)): setattr(collection[i], attr, seq[i])\n" "\n" ; @@ -3872,7 +3872,7 @@ static PyObject *pyrna_struct_new(PyTypeObject *type, PyObject *args, PyObject * } else if (PyType_IsSubtype(Py_TYPE(base), &pyrna_struct_Type)) { /* this almost never runs, only when using user defined subclasses of built-in object. - * this isnt common since its NOT related to registerable subclasses. eg: + * this isn't common since its NOT related to registerable subclasses. eg: >>> class MyObSubclass(bpy.types.Object): ... def test_func(self): @@ -4196,7 +4196,7 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw) err= pyrna_py_to_prop(&funcptr, parm, iter.data, item, ""); if(err!=0) { - /* the error generated isnt that useful, so generate it again with a useful prefix + /* the error generated isn't that useful, so generate it again with a useful prefix * could also write a function to prepend to error messages */ char error_prefix[512]; PyErr_Clear(); /* re-raise */ @@ -4214,7 +4214,7 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw) RNA_parameter_list_end(&iter); - /* Check if we gave args that dont exist in the function + /* Check if we gave args that don't exist in the function * printing the error is slow but it should only happen when developing. * the if below is quick, checking if it passed less keyword args then we gave. * (Dont overwrite the error if we have one, otherwise can skip important messages and confuse with args) @@ -5018,7 +5018,7 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna) /* Not 100% needed but useful, * having an instance within a type looks wrong however this instance IS an rna type */ - /* python deals with the curcular ref */ + /* python deals with the circular ref */ RNA_pointer_create(NULL, &RNA_Struct, srna, &ptr); item= pyrna_struct_CreatePyObject(&ptr); @@ -5116,7 +5116,7 @@ static PyObject* pyrna_srna_Subtype(StructRNA *srna) /* stupid/simple case */ if (srna == NULL) { newclass= NULL; /* Nothing to do */ - } /* the class may have alredy been declared & allocated */ + } /* the class may have already been declared & allocated */ else if ((newclass= RNA_struct_py_type_get(srna))) { Py_INCREF(newclass); } /* check if bpy_types.py module has the class defined in it */ @@ -5124,9 +5124,9 @@ static PyObject* pyrna_srna_Subtype(StructRNA *srna) pyrna_subtype_set_rna(newclass, srna); Py_INCREF(newclass); } /* create a new class instance with the C api - * maintly for the purposing of matching the C/rna type hierarchy */ + * mainly for the purposing of matching the C/rna type hierarchy */ else { - /* subclass equivelents + /* subclass equivalents - class myClass(myBase): some='value' # or ... - myClass= type(name='myClass', bases=(myBase,), dict={'__module__':'bpy.types'}) @@ -5356,7 +5356,7 @@ PyObject *BPY_rna_doc(void) #endif -/* pyrna_basetype_* - BPy_BaseTypeRNA is just a BPy_PropertyRNA struct with a differnt type +/* pyrna_basetype_* - BPy_BaseTypeRNA is just a BPy_PropertyRNA struct with a different type * the self->ptr and self->prop are always set to the "structs" collection */ //---------------getattr-------------------------------------------- static PyObject *pyrna_basetype_getattro(BPy_BaseTypeRNA *self, PyObject *pyname) @@ -5463,19 +5463,19 @@ 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); - Py_DECREF(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); + 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); - Py_DECREF(py_srna); + Py_DECREF(py_srna); return NULL; } @@ -5614,7 +5614,7 @@ static int pyrna_deferred_register_class_recursive(StructRNA *srna, PyTypeObject PyTypeObject *py_superclass= (PyTypeObject *)PyTuple_GET_ITEM(py_class->tp_bases, i); /* the rules for using these base classes are not clear, - * 'object' is ofcourse not worth looking into and + * 'object' is of course not worth looking into and * existing subclasses of RNA would cause a lot more dictionary * looping then is needed (SomeOperator would scan Operator.__dict__) * which is harmless but not at all useful. @@ -5875,7 +5875,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param * Although this is annoying to have to impliment a part of pythons typeobject.c:type_call(). */ if(py_class->tp_init) { - /* true in most cases even when the class its self doesnt define an __init__ function. */ + /* true in most cases even when the class its self doesn't define an __init__ function. */ args= PyTuple_New(0); if (py_class->tp_init(py_srna, args, NULL) < 0) { Py_DECREF(py_srna); @@ -5888,7 +5888,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param py_class_instance= py_srna; #else - /* 'almost' all the time calling the class isnt needed. + /* 'almost' all the time calling the class isn't needed. * We could just do... py_class_instance= py_srna; Py_INCREF(py_class_instance); @@ -5977,7 +5977,7 @@ static int bpy_class_call(bContext *C, PointerRNA *ptr, FunctionRNA *func, Param } } else { - /* the error may be alredy set if the class instance couldnt be created */ + /* 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)); err= -1; @@ -6140,7 +6140,7 @@ void pyrna_free_types(void) * There is currently a bug where moving registering a python class does * not properly manage refcounts from the python class, since the srna owns * the python class this should not be so tricky but changing the references as - * youd expect when changing ownership crashes blender on exit so I had to comment out + * you'd expect when changing ownership crashes blender on exit so I had to comment out * the decref. This is not so bad because the leak only happens when re-registering (hold F8) * - Should still be fixed - Campbell * */ @@ -6178,7 +6178,7 @@ 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 alredy 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; } */ @@ -6214,7 +6214,7 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class /* old srna still references us, keep the check incase registering somehow can free it */ if(RNA_struct_py_type_get(srna)) { RNA_struct_py_type_set(srna, NULL); - // Py_DECREF(py_class); // shuld be able to do this XXX since the old rna adds a new ref. + // Py_DECREF(py_class); // should be able to do this XXX since the old rna adds a new ref. } /* Can't use this because it returns a dict proxy diff --git a/source/blender/python/intern/bpy_traceback.c b/source/blender/python/intern/bpy_traceback.c index b5dec7205a6..1a6caa02b0c 100644 --- a/source/blender/python/intern/bpy_traceback.c +++ b/source/blender/python/intern/bpy_traceback.c @@ -38,68 +38,68 @@ static const char *traceback_filepath(PyTracebackObject *tb) /* copied from pythonrun.c, 3.2.0 */ static int parse_syntax_error(PyObject *err, PyObject **message, const char **filename, - int *lineno, int *offset, const char **text) + int *lineno, int *offset, const char **text) { - long hold; - PyObject *v; - - /* old style errors */ - if (PyTuple_Check(err)) - return PyArg_ParseTuple(err, "O(ziiz)", message, filename, - lineno, offset, text); - - /* new style errors. `err' is an instance */ - - if (! (v = PyObject_GetAttrString(err, "msg"))) - goto finally; - *message = v; - - if (!(v = PyObject_GetAttrString(err, "filename"))) - goto finally; - if (v == Py_None) - *filename = NULL; - else if (! (*filename = _PyUnicode_AsString(v))) - goto finally; - - Py_DECREF(v); - if (!(v = PyObject_GetAttrString(err, "lineno"))) - goto finally; - hold = PyLong_AsLong(v); - Py_DECREF(v); - v = NULL; - if (hold < 0 && PyErr_Occurred()) - goto finally; - *lineno = (int)hold; - - if (!(v = PyObject_GetAttrString(err, "offset"))) - goto finally; - if (v == Py_None) { - *offset = -1; - Py_DECREF(v); - v = NULL; + long hold; + PyObject *v; + + /* old style errors */ + if (PyTuple_Check(err)) + return PyArg_ParseTuple(err, "O(ziiz)", message, filename, + lineno, offset, text); + + /* new style errors. `err' is an instance */ + + if (! (v = PyObject_GetAttrString(err, "msg"))) + goto finally; + *message = v; + + if (!(v = PyObject_GetAttrString(err, "filename"))) + goto finally; + if (v == Py_None) + *filename = NULL; + else if (! (*filename = _PyUnicode_AsString(v))) + goto finally; + + Py_DECREF(v); + if (!(v = PyObject_GetAttrString(err, "lineno"))) + goto finally; + hold = PyLong_AsLong(v); + Py_DECREF(v); + v = NULL; + if (hold < 0 && PyErr_Occurred()) + goto finally; + *lineno = (int)hold; + + if (!(v = PyObject_GetAttrString(err, "offset"))) + goto finally; + if (v == Py_None) { + *offset = -1; + Py_DECREF(v); + v = NULL; } else { - hold = PyLong_AsLong(v); - Py_DECREF(v); - v = NULL; - if (hold < 0 && PyErr_Occurred()) - goto finally; - *offset = (int)hold; - } - - if (!(v = PyObject_GetAttrString(err, "text"))) - goto finally; - if (v == Py_None) - *text = NULL; - else if (!PyUnicode_Check(v) || - !(*text = _PyUnicode_AsString(v))) - goto finally; - Py_DECREF(v); - return 1; + hold = PyLong_AsLong(v); + Py_DECREF(v); + v = NULL; + if (hold < 0 && PyErr_Occurred()) + goto finally; + *offset = (int)hold; + } + + if (!(v = PyObject_GetAttrString(err, "text"))) + goto finally; + if (v == Py_None) + *text = NULL; + else if (!PyUnicode_Check(v) || + !(*text = _PyUnicode_AsString(v))) + goto finally; + Py_DECREF(v); + return 1; finally: - Py_XDECREF(v); - return 0; + Py_XDECREF(v); + return 0; } /* end copied function! */ @@ -122,7 +122,7 @@ void python_script_error_jump(const char *filepath, int *lineno, int *offset) if(value) { /* should always be true */ PyObject *message; - const char *filename, *text; + const char *filename, *text; if(parse_syntax_error(value, &message, &filename, lineno, offset, &text)) { /* python adds a '/', prefix, so check for both */ diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index 0d3b036850d..0b5dacac4b2 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -98,7 +98,7 @@ short BPy_errors_to_report(ReportList *reports) pystring= PyC_ExceptionBuffer(); if(pystring==NULL) { - BKE_report(reports, RPT_ERROR, "unknown py-exception, could not convert"); + BKE_report(reports, RPT_ERROR, "unknown py-exception, couldn't convert"); return 0; } diff --git a/source/blender/quicktime/apple/quicktime_import.c b/source/blender/quicktime/apple/quicktime_import.c index 192fd3c4332..2f8cf242697 100644 --- a/source/blender/quicktime/apple/quicktime_import.c +++ b/source/blender/quicktime/apple/quicktime_import.c @@ -101,7 +101,6 @@ void quicktime_init(void) nerr = InitializeQTML(0); if (nerr != noErr) { G.have_quicktime = FALSE; - printf("Error initializing quicktime\n"); } else G.have_quicktime = TRUE; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index c1aea4c90fc..1a19bbe7320 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -2868,17 +2868,10 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) startvert= obr->totvert; data= dl->verts; - n[0]= ob->imat[0][2]; - n[1]= ob->imat[1][2]; - n[2]= ob->imat[2][2]; - normalize_v3(n); - for(a=0; a<dl->nr; a++, data+=3) { ver= RE_findOrAddVert(obr, obr->totvert++); VECCOPY(ver->co, data); - negate_v3_v3(ver->n, n); - mul_m4_v3(mat, ver->co); if (orco) { @@ -2888,21 +2881,41 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) } if(timeoffset==0) { + float tmp[3]; + const int startvlak= obr->totvlak; + + zero_v3(n); index= dl->index; for(a=0; a<dl->parts; a++, index+=3) { - vlr= RE_findOrAddVlak(obr, obr->totvlak++); vlr->v1= RE_findOrAddVert(obr, startvert+index[0]); vlr->v2= RE_findOrAddVert(obr, startvert+index[1]); vlr->v3= RE_findOrAddVert(obr, startvert+index[2]); vlr->v4= NULL; - negate_v3_v3(vlr->n, n); + normal_tri_v3(tmp, vlr->v3->co, vlr->v2->co, vlr->v1->co); + add_v3_v3(n, tmp); vlr->mat= matar[ dl->col ]; vlr->flag= 0; vlr->ec= 0; } + + normalize_v3(n); + + /* vertex normals */ + for(a= startvlak; a<obr->totvlak; a++) { + vlr= RE_findOrAddVlak(obr, a); + + copy_v3_v3(vlr->n, n); + add_v3_v3(vlr->v1->n, vlr->n); + add_v3_v3(vlr->v3->n, vlr->n); + add_v3_v3(vlr->v2->n, vlr->n); + } + for(a=startvert; a<obr->totvert; a++) { + ver= RE_findOrAddVert(obr, a); + normalize_v3(ver->n); + } } } else if (dl->type==DL_SURF) { @@ -3726,7 +3739,7 @@ static GroupObject *add_render_lamp(Render *re, Object *ob) VECCOPY(vec,ob->obmat[2]); normalize_v3(vec); - + InitSunSky(lar->sunsky, la->atm_turbidity, vec, la->horizon_brightness, la->spread, la->sun_brightness, la->sun_size, la->backscattered_light, la->skyblendfac, la->skyblendtype, la->sky_exposure, la->sky_colorspace); diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 264c82e4f47..7d2c7b35247 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -959,7 +959,7 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl rf.xmax= maxx*(ibuf->x); rf.ymin= miny*(ibuf->y); rf.ymax= maxy*(ibuf->y); - + alphaclip = clipx_rctf(&rf, 0.0, (float)(ibuf->x)); alphaclip*= clipy_rctf(&rf, 0.0, (float)(ibuf->y)); alphaclip= MAX2(alphaclip, 0.0f); @@ -1421,7 +1421,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, float *DXT, f ibuf= BKE_image_get_ibuf(ima, &tex->iuser); } if(ibuf==NULL || (ibuf->rect==NULL && ibuf->rect_float==NULL)) - return retval; + return retval; /* mipmap test */ image_mipmap_test(tex, ibuf); @@ -1467,8 +1467,8 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, float *texvec, float *DXT, f if(tex->imaflag & TEX_FILTER_MIN) { /* make sure the filtersize is minimal in pixels (normal, ref map can have miniature pixel dx/dy) */ - float addval= (0.5f * tex->filtersize) / (float) MIN2(ibuf->x, ibuf->y); - + float addval= (0.5f * tex->filtersize) / (float) MIN2(ibuf->x, ibuf->y); + if(addval > minx) minx= addval; if(addval > miny) diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index f788fac1a35..468ce8846a8 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -2181,7 +2181,9 @@ static void render_scene(Render *re, Scene *sce, int cfra) int winx= re->winx, winy= re->winy; sce->r.cfra= cfra; - + + scene_camera_switch_update(sce); + /* exception: scene uses own size (unfinished code) */ if(0) { winx= (sce->r.size*sce->r.xsch)/100; diff --git a/source/blender/render/intern/source/pixelblending.c b/source/blender/render/intern/source/pixelblending.c index a22680c7085..c2e34e2a70d 100644 --- a/source/blender/render/intern/source/pixelblending.c +++ b/source/blender/render/intern/source/pixelblending.c @@ -81,7 +81,7 @@ void addAlphaOverFloat(float *dest, float *source) { /* d = s + (1-alpha_s)d*/ float mul; - + mul= 1.0 - source[3]; dest[0]= (mul*dest[0]) + source[0]; @@ -131,7 +131,7 @@ void addalphaAddfacFloat(float *dest, float *source, char addfac) else #endif dest[1]= c; - + c= (m * dest[2]) + source[2]; #ifdef RE_FLOAT_COLOR_CLIPPING if(c >= RE_FULL_COLOR_FLOAT) dest[2] = RE_FULL_COLOR_FLOAT; @@ -144,7 +144,7 @@ void addalphaAddfacFloat(float *dest, float *source, char addfac) if(c >= RE_FULL_COLOR_FLOAT) dest[3] = RE_FULL_COLOR_FLOAT; else #endif - dest[3]= c; + dest[3]= c; } diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 84523975589..2d42938f6ac 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -290,14 +290,14 @@ int shadeHaloFloat(HaloRen *har, float *col, int zz, int a; if(R.wrld.mode & WO_MIST) { - if(har->type & HA_ONLYSKY) { - /* stars but no mist */ - alpha= har->alfa; - } - else { - /* a bit patchy... */ - alpha= mistfactor(-har->co[2], har->co)*har->alfa; - } + if(har->type & HA_ONLYSKY) { + /* stars but no mist */ + alpha= har->alfa; + } + else { + /* a bit patchy... */ + alpha= mistfactor(-har->co[2], har->co)*har->alfa; + } } else alpha= har->alfa; diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 4147fc4cdd8..b57fe5a8c3b 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -445,7 +445,7 @@ void makeraytree(Render *re) re->i.infostr= "Raytree.. preparing"; re->stats_draw(re->sdh, &re->i); - /* disable options not yet suported by octree, + /* disable options not yet supported by octree, they might actually never be supported (unless people really need it) */ if(re->r.raytrace_structure == R_RAYSTRUCTURE_OCTREE) re->r.raytrace_options &= ~( R_RAYTRACE_USE_INSTANCES | R_RAYTRACE_USE_LOCAL_COORDS); diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 2b98e7a3f96..d8b5055effd 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -2269,7 +2269,7 @@ void do_material_tex(ShadeInput *shi) if(use_compat_bump) { rgbnor = compatible_bump_compute(&compat_bump, shi, mtex, tex, &texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt); - } + } else if(use_ntap_bump) { rgbnor = ntap_bump_compute(&ntap_bump, shi, mtex, tex, &texres, Tnor*stencilTin, co, dx, dy, texvec, dxt, dyt); @@ -3198,7 +3198,7 @@ void do_lamp_tex(LampRen *la, float *lavec, ShadeInput *shi, float *colf, int ef if(la->type==LA_SPOT) { tempvec[0]*= la->spottexfac; tempvec[1]*= la->spottexfac; - /* project from 3d to 2d */ + /* project from 3d to 2d */ tempvec[0] /= -tempvec[2]; tempvec[1] /= -tempvec[2]; } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 6d19846d80a..7a34fc0af50 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1058,14 +1058,14 @@ static void reset_sky_speed(RenderPart *pa, RenderLayer *rl) static unsigned short *make_solid_mask(RenderPart *pa) { - intptr_t *rd= pa->rectdaps; - unsigned short *solidmask, *sp; - int x; - + intptr_t *rd= pa->rectdaps; + unsigned short *solidmask, *sp; + int x; + if(rd==NULL) return NULL; - + sp=solidmask= MEM_mallocN(sizeof(short)*pa->rectx*pa->recty, "solidmask"); - + for(x=pa->rectx*pa->recty; x>0; x--, rd++, sp++) { if(*rd) { PixStr *ps= (PixStr *)*rd; @@ -1077,7 +1077,7 @@ static unsigned short *make_solid_mask(RenderPart *pa) else *sp= 0; } - + return solidmask; } diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index 038d1bd40cb..dcb9a3063e1 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -952,7 +952,7 @@ static int firstreadshadbuf(ShadBuf *shb, ShadSampleBuf *shsample, int **rz, int /* always test borders of shadowbuffer */ if(xs<0) xs= 0; else if(xs>=shb->size) xs= shb->size-1; if(ys<0) ys= 0; else if(ys>=shb->size) ys= shb->size-1; - + /* calc z */ ofs= (ys>>4)*(shb->size>>4) + (xs>>4); ct= shsample->cbuf+ofs; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index db533cf7a42..5da80a07771 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -138,7 +138,7 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr) /* depth >= 1 when ray-shading */ if(shi->depth==0 || shi->volume_depth > 0) { if(R.r.mode & R_RAYTRACE) { - if(shi->ray_mirror!=0.0f || ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) { + if(shi->ray_mirror!=0.0f || ((shi->mode & MA_TRANSP) && (shi->mode & MA_RAYTRANSP) && shr->alpha!=1.0f)) { /* ray trace works on combined, but gives pass info */ ray_trace(shi, shr); } diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index f7ec0050c5d..12e85af7575 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -690,7 +690,7 @@ static void strand_render(Render *re, StrandSegment *sseg, float winmat[][4], St } } } - + static int strand_segment_recursive(Render *re, float winmat[][4], StrandPart *spart, ZSpan *zspan, int totzspan, StrandSegment *sseg, StrandPoint *p1, StrandPoint *p2, int depth) { StrandPoint p; diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index f10398388c1..919c06d81f7 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -142,13 +142,12 @@ void InitSunSky(struct SunSky *sunsky, float turb, float *toSun, float horizon_b float spread,float sun_brightness, float sun_size, float back_scatter, float skyblendfac, short skyblendtype, float sky_exposure, float sky_colorspace) { - - float theta2; + float theta2; float theta3; float T; float T2; float chi; - + sunsky->turbidity = turb; sunsky->horizon_brightness = horizon_brightness; @@ -247,8 +246,8 @@ void GetSkyXYZRadiance(struct SunSky* sunsky, float theta, float phi, float colo float gamma; float x,y,Y,X,Z; float hfade=1, nfade=1; - - + + if (theta>(0.5*M_PI)) { hfade = 1.0-(theta*M_1_PI-0.5)*2.0; hfade = hfade*hfade*(3.0-2.0*hfade); @@ -320,7 +319,7 @@ void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3]) float fTauR, fTauA; float m ; float fAlpha; - + int i; float fLambda[3]; fLambda[0] = 0.65f; diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index 54a8ba99db5..e75ee6ed469 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -414,7 +414,7 @@ void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Material *ma) SWAP(float *,sr,sr0); SWAP(float *,sg,sg0); SWAP(float *,sb,sb0); - + /* main diffusion simulation */ ms_diffuse(sr0, sr, diff, n); ms_diffuse(sg0, sg, diff, n); diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 4cb18c8cdcc..b8cb5c21337 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -64,13 +64,32 @@ #include "texture.h" #include "voxeldata.h" +static int is_vd_res_ok(VoxelData *vd) +{ + /* arbitrary large value so corrupt headers dont break */ + const int min= 1, max= 100000; + return (vd->resol[0] >= min && vd->resol[0] <= max) && + (vd->resol[1] >= min && vd->resol[1] <= max) && + (vd->resol[2] >= min && vd->resol[2] <= max); +} + +/* use size_t because the result may exceed INT_MAX */ +static size_t vd_resol_size(VoxelData *vd) +{ + return (size_t)vd->resol[0] * (size_t)vd->resol[1] * (size_t)vd->resol[2]; +} + static int load_frame_blendervoxel(VoxelData *vd, FILE *fp, int frame) { + const size_t size = vd_resol_size(vd); size_t offset = sizeof(VoxelDataHeader); - int size = (vd->resol[0])*(vd->resol[1])*(vd->resol[2]); + if(is_vd_res_ok(vd) == FALSE) + return 0; + vd->dataset = MEM_mapallocN(sizeof(float)*size, "voxel dataset"); - + if(vd->dataset == NULL) return 0; + if(fseek(fp, frame*size*sizeof(float)+offset, 0) == -1) return 0; if(fread(vd->dataset, sizeof(float), size, fp) != size) @@ -83,19 +102,32 @@ static int load_frame_blendervoxel(VoxelData *vd, FILE *fp, int frame) static int load_frame_raw8(VoxelData *vd, FILE *fp, int frame) { - int size = (vd->resol[0])*(vd->resol[1])*(vd->resol[2]); + const size_t size = vd_resol_size(vd); char *data_c; int i; - + + if(is_vd_res_ok(vd) == FALSE) + return 0; + vd->dataset = MEM_mapallocN(sizeof(float)*size, "voxel dataset"); + if(vd->dataset == NULL) return 0; data_c = (char *)MEM_mallocN(sizeof(char)*size, "temporary voxel file reading storage"); - + if(data_c == NULL) { + MEM_freeN(vd->dataset); + vd->dataset= NULL; + return 0; + } + if(fseek(fp,(frame-1)*size*sizeof(char),0) == -1) { MEM_freeN(data_c); + MEM_freeN(vd->dataset); + vd->dataset= NULL; return 0; } if(fread(data_c, sizeof(char), size, fp) != size) { MEM_freeN(data_c); + MEM_freeN(vd->dataset); + vd->dataset= NULL; return 0; } @@ -138,7 +170,7 @@ static void load_frame_image_sequence(VoxelData *vd, Tex *tex) vd->resol[0] = ibuf->x; vd->resol[1] = ibuf->y; vd->resol[2] = iuser.frames; - vd->dataset = MEM_mapallocN(sizeof(float)*(vd->resol[0])*(vd->resol[1])*(vd->resol[2]), "voxel dataset"); + vd->dataset = MEM_mapallocN(sizeof(float)*vd_resol_size(vd), "voxel dataset"); for (z=0; z < iuser.frames; z++) { @@ -205,12 +237,12 @@ static void init_frame_smoke(VoxelData *vd, float cfra) if(cfra < smd->domain->point_cache[0]->startframe) ; /* don't show smoke before simulation starts, this could be made an option in the future */ else if (vd->smoked_type == TEX_VD_SMOKEHEAT) { - int totRes; + size_t totRes; + size_t i; float *heat; - int i; VECCOPY(vd->resol, smd->domain->res); - totRes = (vd->resol[0])*(vd->resol[1])*(vd->resol[2]); + totRes= vd_resol_size(vd); // scaling heat values from -2.0-2.0 to 0.0-1.0 vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data"); @@ -226,12 +258,12 @@ static void init_frame_smoke(VoxelData *vd, float cfra) //vd->dataset = smoke_get_heat(smd->domain->fluid); } else if (vd->smoked_type == TEX_VD_SMOKEVEL) { - int totRes; + size_t totRes; + size_t i; float *xvel, *yvel, *zvel; - int i; VECCOPY(vd->resol, smd->domain->res); - totRes = (vd->resol[0])*(vd->resol[1])*(vd->resol[2]); + totRes= vd_resol_size(vd); // scaling heat values from -2.0-2.0 to 0.0-1.0 vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data"); @@ -247,7 +279,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) } else { - int totRes; + size_t totRes; float *density; if (smd->domain->flags & MOD_SMOKE_HIGHRES) { @@ -258,8 +290,8 @@ static void init_frame_smoke(VoxelData *vd, float cfra) density = smoke_get_density(smd->domain->fluid); } - totRes = (vd->resol[0])*(vd->resol[1])*(vd->resol[2]); - + /* TODO: is_vd_res_ok(rvd) doesnt check this resolution */ + totRes= vd_resol_size(vd); /* always store copy, as smoke internal data can change */ vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data"); memcpy(vd->dataset, density, sizeof(float)*totRes); @@ -310,9 +342,8 @@ static void cache_voxeldata(struct Render *re, Tex *tex) if(read_voxeldata_header(fp, vd)) load_frame_blendervoxel(vd, fp, curframe-1); - else - fclose(fp); - + + fclose(fp); return; case TEX_VD_RAW_8BIT: BLI_path_abs(path, G.main->name); @@ -320,11 +351,8 @@ static void cache_voxeldata(struct Render *re, Tex *tex) fp = fopen(path,"rb"); if (!fp) return; - if (load_frame_raw8(vd, fp, curframe)) - ; - else - fclose(fp); - + load_frame_raw8(vd, fp, curframe); + fclose(fp); return; } } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 79ee3994386..174b1378f67 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -3856,7 +3856,7 @@ static int addtosamp_shr(ShadeResult *samp_shr, ShadeSample *ssamp, int addpassf ShadeInput *shi= ssamp->shi; ShadeResult *shr= ssamp->shr; - for(sample=0; sample<ssamp->tot; sample++, shi++, shr++) { + for(sample=0; sample<ssamp->tot; sample++, shi++, shr++) { if(shi->mask & (1<<a)) { float fac= (1.0f - samp_shr->combined[3])*shr->combined[3]; diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index dafa05fd974..1b4fff8cd13 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -173,7 +173,7 @@ struct wmEventHandler *WM_event_add_ui_handler(const struct bContext *C, ListBas void (*remove)(struct bContext *C, void *userdata), void *userdata); void WM_event_remove_ui_handler(ListBase *handlers, int (*func)(struct bContext *C, struct wmEvent *event, void *userdata), - void (*remove)(struct bContext *C, void *userdata), void *userdata); + void (*remove)(struct bContext *C, void *userdata), void *userdata, int postpone); void WM_event_remove_area_handler(struct ListBase *handlers, void *area); struct wmEventHandler *WM_event_add_modal_handler(struct bContext *C, struct wmOperator *op); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 2b74d35d59e..feff0393b88 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1452,10 +1452,13 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) /* modal handlers can get removed in this loop, we keep the loop this way */ for(handler= handlers->first; handler; handler= nexthandler) { + nexthandler= handler->next; - - /* optional boundbox */ - if(handler_boundbox_test(handler, event)) { + + /* during this loop, ui handlers for nested menus can tag multiple handlers free */ + if(handler->flag & WM_HANDLER_DO_FREE); + /* optional boundbox */ + else if(handler_boundbox_test(handler, event)) { /* in advance to avoid access to freed event on window close */ always_pass= wm_event_always_pass(event); @@ -1534,9 +1537,21 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) } } - /* XXX fileread case */ - if(CTX_wm_window(C)==NULL) + /* XXX fileread case, if the wm is freed then the handler's + * will have been too so the code below need not run. */ + if(CTX_wm_window(C)==NULL) { return action; + } + + /* XXX code this for all modal ops, and ensure free only happens here */ + + /* modal ui handler can be tagged to be freed */ + if(BLI_findindex(handlers, handler) != -1) { /* could be free'd already by regular modal ops */ + if(handler->flag & WM_HANDLER_DO_FREE) { + BLI_remlink(handlers, handler); + wm_event_free_handler(handler); + } + } } /* test for CLICK event */ @@ -1589,7 +1604,7 @@ static int wm_event_inside_i(wmEvent *event, rcti *rect) if(wm_event_always_pass(event)) return 1; if(BLI_in_rcti(rect, event->x, event->y)) - return 1; + return 1; if(event->type==MOUSEMOVE) { if( BLI_in_rcti(rect, event->prevx, event->prevy)) { return 1; @@ -2067,14 +2082,21 @@ wmEventHandler *WM_event_add_ui_handler(const bContext *C, ListBase *handlers, w return handler; } -void WM_event_remove_ui_handler(ListBase *handlers, wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata) +/* set "postpone" for win->modalhandlers, this is in a running for() loop in wm_handlers_do() */ +void WM_event_remove_ui_handler(ListBase *handlers, wmUIHandlerFunc func, wmUIHandlerRemoveFunc remove, void *userdata, int postpone) { wmEventHandler *handler; for(handler= handlers->first; handler; handler= handler->next) { if(handler->ui_handle == func && handler->ui_remove == remove && handler->ui_userdata == userdata) { - BLI_remlink(handlers, handler); - wm_event_free_handler(handler); + /* handlers will be freed in wm_handlers_do() */ + if(postpone) { + handler->flag |= WM_HANDLER_DO_FREE; + } + else { + BLI_remlink(handlers, handler); + wm_event_free_handler(handler); + } break; } } diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 4a8553e16f6..4ab4eebdfe1 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -270,8 +270,8 @@ static void wm_jobs_test_suspend_stop(wmWindowManager *wm, wmJob *test) /* if new job is render, any render job should be stopped */ if(test->flag & WM_JOB_EXCL_RENDER) - if(0==(steve->flag & WM_JOB_EXCL_RENDER)) - continue; + if(0==(steve->flag & WM_JOB_EXCL_RENDER)) + continue; suspend= 1; diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index 6ad9d1daede..cd110d3bc1a 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -78,6 +78,8 @@ typedef struct wmEventHandler { /* handler flag */ /* after this handler all others are ignored */ #define WM_HANDLER_BLOCKING 1 + /* handler tagged to be freed in wm_handlers_do() */ +#define WM_HANDLER_DO_FREE 2 |