diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-01-22 22:04:35 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-01-22 22:04:35 +0400 |
commit | 4966982a5aa7715e6bd67dcef1babdf8ca3d02e9 (patch) | |
tree | cf96f67b83f89336e3fe2f64aa58345dca818430 /source/blender | |
parent | 0198df7956125180d5b9c50638a0778a3236d88f (diff) | |
parent | df51fd74cf826c42a90212082abb27e99484257a (diff) |
svn merge ^/trunk/blender -r43564:43609
Diffstat (limited to 'source/blender')
104 files changed, 1458 insertions, 664 deletions
diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index a89bfbd50b1..11ab981822e 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -86,7 +86,7 @@ int bone_autoside_name (char name[64], int strip_number, short axis, float head, struct Bone *get_named_bone (struct bArmature *arm, const char *name); -float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, float rad2, float rdist); +float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float rad1, float rad2, float rdist); void where_is_armature (struct bArmature *arm); void where_is_armature_bone(struct Bone *bone, struct Bone *prevbone); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 98fe6e15e67..02266801935 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 261 -#define BLENDER_SUBVERSION 3 +#define BLENDER_SUBVERSION 4 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 7668d5392da..ee3edbb47e7 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -53,7 +53,7 @@ typedef struct Global { struct Main *main; /* strings: lastsaved */ - char ima[256], lib[256]; + char ima[1024], lib[1024]; /* 1024 = FILE_MAX */ /* flag: if != 0 G.main->name contains valid relative base path */ int relbase_valid; diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index 51bcd18fab6..05ba60b8a5b 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -50,7 +50,7 @@ struct Library; typedef struct Main { struct Main *next, *prev; - char name[240]; /* 240 = FILE_MAX */ + char name[1024]; /* 1024 = FILE_MAX */ short versionfile, subversionfile; short minversionfile, minsubversionfile; int revision; /* svn revision of binary that saved file */ diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index b5b3c7e67eb..a6a9bb0c0f6 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -43,9 +43,9 @@ extern "C" { /* these values need to be hardcoded in structs, dna does not recognize defines */ /* also defined in DNA_space_types.h */ #ifndef FILE_MAXDIR -#define FILE_MAXDIR 160 -#define FILE_MAXFILE 80 -#define FILE_MAX 240 +#define FILE_MAXDIR 768 +#define FILE_MAXFILE 256 +#define FILE_MAX 1024 #endif /* this weirdo pops up in two places ... */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 184943490f2..3ef36918f98 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -665,7 +665,7 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float *co, Dua } /* using vec with dist to bone b1 - b2 */ -float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, float rad2, float rdist) +float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float rad1, float rad2, float rdist) { float dist=0.0f; float bdelta[3]; @@ -677,18 +677,18 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl sub_v3_v3v3(pdelta, vec, b1); - a = bdelta[0]*pdelta[0] + bdelta[1]*pdelta[1] + bdelta[2]*pdelta[2]; - hsqr = ((pdelta[0]*pdelta[0]) + (pdelta[1]*pdelta[1]) + (pdelta[2]*pdelta[2])); + a = dot_v3v3(bdelta, pdelta); + hsqr = dot_v3v3(pdelta, pdelta); - if (a < 0.0F){ + if (a < 0.0f) { /* If we're past the end of the bone, do a spherical field attenuation thing */ - dist= ((b1[0]-vec[0])*(b1[0]-vec[0]) +(b1[1]-vec[1])*(b1[1]-vec[1]) +(b1[2]-vec[2])*(b1[2]-vec[2])) ; + dist = len_squared_v3v3(b1, vec); rad= rad1; } - else if (a > l){ + else if (a > l) { /* If we're past the end of the bone, do a spherical field attenuation thing */ - dist= ((b2[0]-vec[0])*(b2[0]-vec[0]) +(b2[1]-vec[1])*(b2[1]-vec[1]) +(b2[2]-vec[2])*(b2[2]-vec[2])) ; - rad= rad2; + dist = len_squared_v3v3(b2, vec); + rad = rad2; } else { dist= (hsqr - (a*a)); @@ -709,7 +709,7 @@ float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, fl if(rdist==0.0f || dist >= l) return 0.0f; else { - a= (float)sqrt(dist)-rad; + a = sqrtf(dist)-rad; return 1.0f-( a*a )/( rdist*rdist ); } } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 3bcbb782e82..7cdd61e1402 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -2777,13 +2777,14 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* store Z orientation before destroying obmat */ normalize_v3_v3(zz, cob->matrix[2]); - sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); - vec[0] /= size[0]; - vec[1] /= size[1]; - vec[2] /= size[2]; - - dist = normalize_v3(vec); - //dist = len_v3v3( ob->obmat[3], targetmat[3]); + dist = len_v3v3(cob->matrix[3], ct->matrix[3]); + /* XXX What was all that for??? Makes the constraint buggy with scaled objects, see #29940. */ +/* sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]);*/ +/* vec[0] /= size[0];*/ +/* vec[1] /= size[1];*/ +/* vec[2] /= size[2];*/ + +/* dist = normalize_v3(vec);*/ /* data->orglength==0 occurs on first run, and after 'R' button is clicked */ if (data->orglength == 0) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 0f1c73c59c1..6536dfb529e 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -368,9 +368,8 @@ void tex_space_curve(Curve *cu) dl= cu->disp.first; while(dl) { - if(dl->type==DL_INDEX3 || dl->type==DL_INDEX3) tot= dl->nr; - else tot= dl->nr*dl->parts; - + tot = ELEM(dl->type, DL_INDEX3, DL_INDEX4) ? dl->nr : dl->nr * dl->parts; + if(tot) doit= 1; fp= dl->verts; while(tot--) { diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 86d3f7763a5..b8d44a07051 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -188,11 +188,12 @@ typedef struct ImgSeqFormatData { Vec3f *barycentricWeights; /* b-weights for all pixel samples */ } ImgSeqFormatData; +#if 0 /* UNUSED */ typedef struct EffVelPoint { float previous_pos[3]; float previous_vel[3]; } EffVelPoint; - +#endif /* adjacency data flags */ #define ADJ_ON_MESH_EDGE (1<<0) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index ce337608cc5..0a80e8a3d56 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1111,9 +1111,9 @@ int BKE_add_image_extension(char *string, const char imtype) if(BLI_testextensie_array(string, imb_ext_image) || (G.have_quicktime && BLI_testextensie_array(string, imb_ext_image_qt))) { return BLI_replace_extension(string, FILE_MAX, extension); - } else { + } + else { return BLI_ensure_extension(string, FILE_MAX, extension); - return TRUE; } } diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 087f82a151e..2d2d16e0e3a 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1991,11 +1991,11 @@ float (*mesh_getVertexCos(Mesh *me, int *numVerts_r))[3] { int i, numVerts = me->totvert; float (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "vertexcos1"); - + if (numVerts_r) *numVerts_r = numVerts; for (i=0; i<numVerts; i++) copy_v3_v3(cos[i], me->mvert[i].co); - + return cos; } diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 3b1dc2973ad..bb8e420451f 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -981,7 +981,7 @@ static void movieclip_build_proxy_ibuf(MovieClip *clip, ImBuf *ibuf, int cfra, i { char name[FILE_MAX]; int quality, rectx, recty; - int size= size= rendersize_to_number(proxy_render_size); + int size= rendersize_to_number(proxy_render_size); ImBuf *scaleibuf; get_proxy_fname(clip, proxy_render_size, undistorted, cfra, name); diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index fd184b9def4..12f403d028f 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -1448,9 +1448,17 @@ void BKE_nla_validate_state (AnimData *adt) */ // TODO: 1 solution is to tie this in with auto-blending... if (strip->extendmode != NLASTRIP_EXTEND_NOTHING) { + /* 1) First strip must be set to extend hold, otherwise, stuff before acts dodgy + * 2) Only overwrite extend mode if *not* changing it will most probably result in + * occlusion problems, which will occur iff + * - blendmode = REPLACE + * - all channels the same (this is fiddly to test, so is currently assumed) + * + * Should fix problems such as [#29869] + */ if (strip == fstrip) strip->extendmode= NLASTRIP_EXTEND_HOLD; - else + else if (strip->blendmode == NLASTRIP_MODE_REPLACE) strip->extendmode= NLASTRIP_EXTEND_HOLD_FORWARD; } } @@ -1542,6 +1550,34 @@ short BKE_nla_tweakmode_enter (AnimData *adt) break; } } + + /* There are situations where we may have multiple strips selected and we want to enter tweakmode on all + * of those at once. Usually in those cases, it will usually just be a single strip per AnimData. + * In such cases, compromise and take the last selected track and/or last selected strip [#28468] + */ + if (activeTrack == NULL) { + /* try last selected track for active strip */ + for (nlt = adt->nla_tracks.last; nlt; nlt = nlt->prev) { + if (nlt->flag & NLATRACK_SELECTED) { + /* assume this is the active track */ + activeTrack= nlt; + + /* try to find active strip */ + activeStrip= BKE_nlastrip_find_active(nlt); + break; + } + } + } + if ((activeTrack) && (activeStrip == NULL)) { + /* no active strip in active or last selected track; compromise for first selected (assuming only single)... */ + for (strip = activeTrack->strips.first; strip; strip= strip->next) { + if (strip->flag & (NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_ACTIVE)) { + activeStrip = strip; + break; + } + } + } + if ELEM3(NULL, activeTrack, activeStrip, activeStrip->act) { if (G.f & G_DEBUG) { printf("NLA tweakmode enter - neither active requirement found \n"); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 52a505998e1..76077fe3a14 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -100,6 +100,7 @@ static void arena_release(CCGAllocatorHDL a) { typedef enum { CCG_USE_AGING = 1, CCG_USE_ARENA = 2, + CCG_CALC_NORMALS = 4, } CCGFlags; static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags flags) { @@ -130,7 +131,7 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl } else { ifc.vertUserSize = ifc.edgeUserSize = ifc.faceUserSize = 8; } - ifc.vertDataSize = sizeof(DMGridData); + ifc.vertDataSize = sizeof(float) * (flags & CCG_CALC_NORMALS ? 6 : 3); if (useArena) { CCGAllocatorIFC allocatorIFC; @@ -150,7 +151,10 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl ccgSubSurf_setUseAgeCounts(ccgSS, 1, 8, 8, 8); } - ccgSubSurf_setCalcVertexNormals(ccgSS, 1, offsetof(DMGridData, no)); + if (flags & CCG_CALC_NORMALS) + ccgSubSurf_setCalcVertexNormals(ccgSS, 1, offsetof(DMGridData, no)); + else + ccgSubSurf_setCalcVertexNormals(ccgSS, 0, 0); return ccgSS; } @@ -380,14 +384,14 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, int numVerts = ccgSubSurf_getFaceNumVerts(f); for (S=0; S<numVerts; S++) { - DMGridData *faceGridData= ccgSubSurf_getFaceGridDataArray(uvss, f, S); + float (*faceGridData)[3]= ccgSubSurf_getFaceGridDataArray(uvss, f, S); for(y = 0; y < gridFaces; y++) { for(x = 0; x < gridFaces; x++) { - float *a = faceGridData[(y + 0)*gridSize + x + 0].co; - float *b = faceGridData[(y + 0)*gridSize + x + 1].co; - float *c = faceGridData[(y + 1)*gridSize + x + 1].co; - float *d = faceGridData[(y + 1)*gridSize + x + 0].co; + float *a = faceGridData[(y + 0)*gridSize + x + 0]; + float *b = faceGridData[(y + 0)*gridSize + x + 1]; + float *c = faceGridData[(y + 1)*gridSize + x + 1]; + float *d = faceGridData[(y + 1)*gridSize + x + 0]; if (tface) { tf->uv[0][0] = a[0]; tf->uv[0][1] = a[1]; @@ -3259,7 +3263,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( if(forEditMode) { int levels= (smd->modifier.scene)? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels): smd->levels; - smd->emCache = _getSubSurf(smd->emCache, levels, useAging); + smd->emCache = _getSubSurf(smd->emCache, levels, useAging|CCG_CALC_NORMALS); ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple); result = getCCGDerivedMesh(smd->emCache, @@ -3273,7 +3277,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( if(levels == 0) return dm; - ss = _getSubSurf(NULL, levels, CCG_USE_ARENA); + ss = _getSubSurf(NULL, levels, CCG_USE_ARENA|CCG_CALC_NORMALS); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); @@ -3303,7 +3307,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( } if(useIncremental && isFinalCalc) { - smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging); + smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging|CCG_CALC_NORMALS); if (!ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple)) { //ccgSubSurf_free(smd->mCache); @@ -3322,7 +3326,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( smd->mCache = NULL; } - ss = _getSubSurf(NULL, levels, CCG_USE_ARENA); + ss = _getSubSurf(NULL, levels, CCG_USE_ARENA|CCG_CALC_NORMALS); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index b8f37a90a4d..ba48db588c4 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -808,13 +808,14 @@ static int txt_utf8_len(const char *src) void txt_move_up(Text *text, short sel) { TextLine **linep; - int *charp, old; + int *charp; + /* int old; */ /* UNUSED */ if (!text) return; if(sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - old= *charp; + /* old= *charp; */ /* UNUSED */ if((*linep)->prev) { int index = txt_utf8_offset_to_index((*linep)->line, *charp); @@ -834,13 +835,14 @@ void txt_move_up(Text *text, short sel) void txt_move_down(Text *text, short sel) { TextLine **linep; - int *charp, old; + int *charp; + /* int old; */ /* UNUSED */ if (!text) return; if(sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - old= *charp; + /* old= *charp; */ /* UNUSED */ if((*linep)->next) { int index = txt_utf8_offset_to_index((*linep)->line, *charp); @@ -1897,6 +1899,10 @@ static unsigned int txt_undo_read_unicode(const char *undo_buf, int *undo_pos, s break; case 4: /* 32-bit unicode symbol */ unicode= txt_undo_read_uint32(undo_buf, undo_pos); + default: + /* should never happen */ + BLI_assert(0); + unicode= 0; } return unicode; @@ -2751,15 +2757,19 @@ void txt_indent(Text *text) /* hardcoded: TXT_TABSIZE = 4 spaces: */ int spaceslen = TXT_TABSIZE; + if (ELEM3(NULL, text, text->curl, text->sell)) { + return; + } + + if (!text) return; + if (!text->curl) return; + if (!text->sell) return; + /* insert spaces rather than tabs */ if (text->flags & TXT_TABSTOSPACES){ add = tab_to_spaces; indentlen = spaceslen; } - - if (!text) return; - if (!text->curl) return; - if (!text->sell) return; num = 0; while (TRUE) @@ -2812,16 +2822,16 @@ void txt_unindent(Text *text) /* hardcoded: TXT_TABSIZE = 4 spaces: */ int spaceslen = TXT_TABSIZE; + if (!text) return; + if (!text->curl) return; + if (!text->sell) return; + /* insert spaces rather than tabs */ if (text->flags & TXT_TABSTOSPACES){ remove = tab_to_spaces; indent = spaceslen; } - if (!text) return; - if (!text->curl) return; - if (!text->sell) return; - while(TRUE) { int i = 0; diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index 3543b847f19..d5f66c0e75f 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -132,19 +132,18 @@ void BLI_kdtree_balance(KDTree *tree) tree->root= kdtree_balance(tree->nodes, tree->totnode, 0); } -static float squared_distance(float *v2, float *v1, float *n1, float *n2) +static float squared_distance(float *v2, float *v1, float *UNUSED(n1), float *n2) { float d[3], dist; - (void)n1; /* unused */ d[0]= v2[0]-v1[0]; d[1]= v2[1]-v1[1]; d[2]= v2[2]-v1[2]; - dist= d[0]*d[0] + d[1]*d[1] + d[2]*d[2]; + dist = dot_v3v3(d, d); - //if(n1 && n2 && n1[0]*n2[0] + n1[1]*n2[1] + n1[2]*n2[2] < 0.0f) - if(n2 && d[0]*n2[0] + d[1]*n2[1] + d[2]*n2[2] < 0.0f) + //if(n1 && n2 && (dot_v3v3(n1, n2) < 0.0f)) + if(n2 && (dot_v3v3(d, n2) < 0.0f)) dist *= 10.0f; return dist; diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index 073b4b5d0c6..cf18fbd57cd 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -390,7 +390,7 @@ void boxPack2D(boxPack *boxarray, const int len, float *tot_width, float *tot_he } else if ( vert->trb && vert->brb && (box == vert->trb || box == vert->brb) ) { if (vert->trb->w > vert->brb->w) { - vert->brb->v[TR]->free &= ~(TRF|TRF); + vert->brb->v[TR]->free &= ~(TLF|TRF); } else if (vert->trb->w < vert->brb->w) { vert->trb->v[BR]->free &= ~(BLF|BRF); } else { /*same*/ diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index d7880e40626..500e27064d7 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2485,8 +2485,9 @@ void tangent_from_uv(float uv1[2], float uv2[2], float uv3[3], float co1[3], flo cross_v3_v3v3(ct, tang, tangv); /* check flip */ - if ((ct[0]*n[0] + ct[1]*n[1] + ct[2]*n[2]) < 0.0f) + if (dot_v3v3(ct, n) < 0.0f) { negate_v3(tang); + } } else { tang[0]= tang[1]= tang[2]= 0.0; diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 5596b6f9f22..b0e6fe51810 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -811,7 +811,7 @@ void single_axis_angle_to_mat3(float mat[3][3], const char axis, const float ang mat[2][2] = 1.0f; break; default: - assert("invalid axis"); + assert(0); } } diff --git a/source/blender/blenlib/intern/noise.c b/source/blender/blenlib/intern/noise.c index e1a08de0dd8..b3cb2856383 100644 --- a/source/blender/blenlib/intern/noise.c +++ b/source/blender/blenlib/intern/noise.c @@ -919,10 +919,6 @@ static float g[512+2][3]= { {-0.944031, -0.326599, -0.045624}, }; - - -#define DOT(a,b) (a[0] * b[0] + a[1] * b[1] + a[2] * b[2]) - #define setup(i,b0,b1,r0,r1) \ t = vec[i] + 10000.0f; \ b0 = ((int)t) & 255; \ diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index 38925ea5238..d63baca883e 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -65,7 +65,7 @@ typedef struct BlendFileData { int fileflags; int displaymode; int globalf; - char filename[240]; /* 240 = FILE_MAX */ + char filename[1024]; /* 1024 = FILE_MAX */ struct bScreen* curscreen; struct Scene* curscene; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 724d6ee2795..91d85d4519f 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -13099,6 +13099,23 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 261 || (main->versionfile == 261 && main->subversionfile < 4)) + { + { + /* set fluidsim rate */ + Object *ob; + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Fluidsim) { + FluidsimSettings *fss = (FluidsimSettings *)md; + fss->animRate = 1.0f; + } + } + } + } + } + /* put compatibility code here until next subversion bump */ { } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index fb484cc6806..1971ffca4df 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -89,6 +89,9 @@ Any case: direct data is ALWAYS after the lib block #include "BLI_winstuff.h" #endif +/* allow writefile to use deprecated functionality (for forward compatibility code) */ +#define DNA_DEPRECATED_ALLOW + #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_actuator_types.h" @@ -654,7 +657,7 @@ static void write_node_socket(WriteData *wd, bNodeSocket *sock) /* forward compatibility code, so older blenders still open */ sock->stack_type = 1; - + if(sock->default_value) { bNodeSocketValueFloat *valfloat; bNodeSocketValueVector *valvector; diff --git a/source/blender/blenpluginapi/iff.h b/source/blender/blenpluginapi/iff.h index 6bd4e5bb2b0..f07e80b36ce 100644 --- a/source/blender/blenpluginapi/iff.h +++ b/source/blender/blenpluginapi/iff.h @@ -63,7 +63,7 @@ typedef struct ImBuf { int channels; /**< amount of channels in rect_float (0 = 4 channel default) */ float dither; /**< random dither value, for conversion from float -> byte rect */ short profile; /** color space/profile preset that the byte rect buffer represents */ - char profile_filename[256]; /** to be implemented properly, specific filename for custom profiles */ + char profile_filename[1024]; /** to be implemented properly, specific filename for custom profiles */ /* mipmapping */ struct ImBuf *mipmap[IB_MIPMAP_LEVELS]; /**< MipMap levels, a series of halved images */ diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 11f07e3051e..e16063b50c6 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -5356,7 +5356,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } } } - + /* See if an object is parented to this armature */ if (ob->parent && (ob->parent->data == arm)) { if (ob->partype==PARBONE) { @@ -5385,17 +5385,15 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } } } - - /* Fix animation data attached to this object */ - // TODO: should we be using the database wide version instead (since drivers may break) - if (ob->adt) { - /* posechannels only... */ - BKE_animdata_fix_paths_rename(&ob->id, ob->adt, "pose.bones", oldname, newname, 0, 0, 1); - } } - + + /* Fix all animdata that may refer to this bone - we can't just do the ones attached to objects, since + * other ID-blocks may have drivers referring to this bone [#29822] + */ + BKE_all_animdata_fix_paths_rename("pose.bones", oldname, newname); + + /* correct view locking */ { - /* correct view locking */ bScreen *screen; for(screen= G.main->screen.first; screen; screen= screen->id.next) { ScrArea *sa; diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 9ec27b69835..a8978a0bbde 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -450,7 +450,7 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo { int i, j; - for (i = 0, j = 0; template_name[i] != '\0' && i < (MAXBONENAME-1) && j < (MAXBONENAME-1); i++) + for (i = 0, j = 0; i < (MAXBONENAME-1) && j < (MAXBONENAME-1) && template_name[i] != '\0'; i++) { if (template_name[i] == '&') { diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index dcddde207f0..eb49f16584b 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -376,6 +376,10 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, bAction *act= ob->poselib; /* never NULL */ TimeMarker *marker; + wmOperatorType *ot = WM_operatortype_find("POSELIB_OT_pose_add", 1); + + BLI_assert(ot != NULL); + /* set the operator execution context correctly */ uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); @@ -383,9 +387,9 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, for (marker= act->markers.first; marker; marker= marker->next) { PointerRNA props_ptr; - props_ptr = uiItemFullO(layout, "POSELIB_OT_pose_add", - marker->name, ICON_ARMATURE_DATA, NULL, - WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr = uiItemFullO_ptr(layout, ot, + marker->name, ICON_ARMATURE_DATA, NULL, + WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_int_set(&props_ptr, "frame", marker->frame); RNA_string_set(&props_ptr, "name", marker->name); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index afaad2e7cb5..4565806702f 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5876,8 +5876,8 @@ static int delete_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) if(obedit->type==OB_SURF) { pup= uiPupMenuBegin(C, "Delete", ICON_NONE); layout= uiPupMenuLayout(pup); - uiItemEnumO(layout, op->type->idname, NULL, 0, "type", 0); - uiItemEnumO(layout, op->type->idname, NULL, 0, "type", 2); + uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 0); + uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 2); uiPupMenuEnd(C, pup); } else { diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index a52012283a3..c996fefe575 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -40,6 +40,7 @@ struct bConstraint; struct bContext; struct bPoseChannel; struct Curve; +struct EnumPropertyItem; struct KeyBlock; struct Lattice; struct Main; @@ -64,6 +65,29 @@ void ED_operatortypes_object(void); void ED_operatormacros_object(void); void ED_keymap_object(struct wmKeyConfig *keyconf); +/* object_relations.c */ +typedef enum eParentType { + PAR_OBJECT, + PAR_ARMATURE, + PAR_ARMATURE_NAME, + PAR_ARMATURE_ENVELOPE, + PAR_ARMATURE_AUTO, + PAR_BONE, + PAR_CURVE, + PAR_FOLLOW, + PAR_PATH_CONST, + PAR_LATTICE, + PAR_VERTEX, + PAR_TRIA +} eParentType; + +extern struct EnumPropertyItem prop_clear_parent_types[]; +extern struct EnumPropertyItem prop_make_parent_types[]; + +int ED_object_parent_set(struct bContext *C, struct wmOperator *op, struct Object *par, int partype); +void ED_object_parent_clear(struct bContext *C, int type); + + /* generic editmode keys like pet * do_pet * 0: No diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index d1f11d60999..3f907004931 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -62,6 +62,7 @@ struct ColorBand; struct CurveMapping; struct Image; struct ImageUser; +struct wmOperatorType; struct uiWidgetColors; struct Tex; struct MTex; @@ -446,6 +447,7 @@ uiBut *uiDefButBitC(uiBlock *block, int type, int bit, int retval, const char *s uiBut *uiDefButR(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip); uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconBut(uiBlock *block, @@ -466,6 +468,7 @@ uiBut *uiDefIconButBitC(uiBlock *block, int type, int bit, int retval, int icon, uiBut *uiDefIconButR(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefIconButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip); uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, @@ -485,6 +488,7 @@ uiBut *uiDefIconTextButBitC(uiBlock *block, int type, int bit, int retval, int i uiBut *uiDefIconTextButR(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, const char *propname, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip); uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); +uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, struct wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip); /* for passing inputs to ButO buttons */ struct PointerRNA *uiButGetOperatorPtrRNA(uiBut *but); @@ -773,6 +777,7 @@ void uiTemplateMarker(struct uiLayout *layout, struct PointerRNA *ptr, const cha /* items */ void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname); +void uiItemEnumO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, const char *propname, int value); void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value); void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value); @@ -781,6 +786,8 @@ void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *op void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value); void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value); + +PointerRNA uiItemFullO_ptr(uiLayout *layout, struct wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag); PointerRNA uiItemFullO(uiLayout *layout, const char *idname, const char *name, int icon, struct IDProperty *properties, int context, int flag); void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon); diff --git a/source/blender/editors/include/UI_interface_icons.h b/source/blender/editors/include/UI_interface_icons.h index e9c213dec35..e5ad51169a8 100644 --- a/source/blender/editors/include/UI_interface_icons.h +++ b/source/blender/editors/include/UI_interface_icons.h @@ -41,7 +41,7 @@ struct Material; typedef struct IconFile { struct IconFile *next, *prev; - char filename[80]; // FILE_MAXFILE size + char filename[256]; // FILE_MAXFILE size int index; } IconFile; diff --git a/source/blender/editors/include/UI_resources.h b/source/blender/editors/include/UI_resources.h index 6e921a0ca8c..d755b17bc98 100644 --- a/source/blender/editors/include/UI_resources.h +++ b/source/blender/editors/include/UI_resources.h @@ -193,8 +193,10 @@ enum { TH_STITCH_PREVIEW_VERT, TH_STITCH_PREVIEW_STITCHABLE, TH_STITCH_PREVIEW_UNSTITCHABLE, - TH_STITCH_PREVIEW_ACTIVE + TH_STITCH_PREVIEW_ACTIVE, + TH_MATCH, /* highlight color for search matches */ + TH_SELECT_HIGHLIGHT /* highlight color for selected outliner item */ }; /* XXX WARNING: previous is saved in file, so do not change order! */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 7ff69277843..8bb9ceb121c 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -800,11 +800,43 @@ static void ui_menu_block_set_keyaccels(uiBlock *block) } } +/* XXX, this code will shorten any allocated string to 'UI_MAX_NAME_STR' + * since this is really long its unlikely to be an issue, + * but this could be supported */ +void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const short do_strip) +{ + + if (do_strip) { + char *cpoin= strchr(but->str, '|'); + if(cpoin) { + *cpoin= '\0'; + } + } + + /* without this, just allow stripping of the shortcut */ + if (shortcut_str) { + char *butstr_orig; + + if (but->str != but->strdata) { + butstr_orig = but->str; /* free after using as source buffer */ + } + else { + butstr_orig = BLI_strdup(but->str); + } + BLI_snprintf(but->strdata, + sizeof(but->strdata), + "%s|%s", + butstr_orig, shortcut_str); + MEM_freeN(butstr_orig); + but->str = but->strdata; + ui_check_but(but); + } +} static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) { uiBut *but; - char buf[512]; + char buf[128]; /* for menu's */ MenuType *mt; @@ -815,18 +847,6 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) if(block->minx != block->maxx) return; - -#define UI_MENU_KEY_STR_CAT \ - char *butstr_orig= BLI_strdup(but->str); \ - BLI_snprintf(but->strdata, \ - sizeof(but->strdata), \ - "%s|%s", \ - butstr_orig, buf); \ - MEM_freeN(butstr_orig); \ - but->str= but->strdata; \ - ui_check_but(but); \ - - for(but=block->buttons.first; but; but=but->next) { if(but->optype) { IDProperty *prop= (but->opptr)? but->opptr->data: NULL; @@ -834,7 +854,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, buf, sizeof(buf))) { - UI_MENU_KEY_STR_CAT + ui_but_add_shortcut(but, buf, FALSE); } } else if ((mt= uiButGetMenuType(but))) { @@ -851,7 +871,7 @@ static void ui_menu_block_set_keymaps(const bContext *C, uiBlock *block) if(WM_key_event_operator_string(C, "WM_OT_call_menu", WM_OP_INVOKE_REGION_WIN, prop_menu, FALSE, buf, sizeof(buf))) { - UI_MENU_KEY_STR_CAT + ui_but_add_shortcut(but, buf, FALSE); } } } @@ -1693,10 +1713,15 @@ static int ui_set_but_string_eval_num_unit(bContext *C, uiBut *but, const char * 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) +#endif /* WITH_PYTHON */ + + +int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, double *value) { int ok= FALSE; +#ifdef WITH_PYTHON + if(str[0] != '\0') { int is_unit_but= ui_is_but_unit(but); /* only enable verbose if we won't run again with units */ @@ -1718,10 +1743,16 @@ static int ui_set_but_string_eval_num(bContext *C, uiBut *but, const char *str, } } +#else /* WITH_PYTHON */ + + value= atof(str); + ok = TRUE; + +#endif /* WITH_PYTHON */ + return ok; } -#endif // WITH_PYTHON int ui_set_but_string(bContext *C, uiBut *but, const char *str) { @@ -1788,13 +1819,9 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) /* number editing */ double value; -#ifdef WITH_PYTHON if(ui_set_but_string_eval_num(C, but, str, &value) == FALSE) { return 0; } -#else - value= atof(str); -#endif // WITH_PYTHON if(!ui_is_but_float(but)) value= (int)floor(value + 0.5); if(but->type==NUMABS) value= fabs(value); @@ -1939,21 +1966,32 @@ static void ui_free_but(const bContext *C, uiBut *but) WM_operator_properties_free(but->opptr); MEM_freeN(but->opptr); } - if(but->func_argN) MEM_freeN(but->func_argN); + + if(but->func_argN) { + MEM_freeN(but->func_argN); + } + if(but->active) { /* XXX solve later, buttons should be free-able without context ideally, * however they may have open tooltips or popup windows, which need to * be closed using a context pointer */ - if(C) + if (C) { ui_button_active_free(C, but); - else - if(but->active) + } + else { + if(but->active) { MEM_freeN(but->active); + } + } + } + if (but->str && but->str != but->strdata) { + MEM_freeN(but->str); } - if(but->str && but->str != but->strdata) MEM_freeN(but->str); ui_free_link(but->link); - if((but->type == BUT_IMAGE) && but->poin) IMB_freeImBuf((struct ImBuf *)but->poin); + if ((but->type == BUT_IMAGE) && but->poin) { + IMB_freeImBuf((struct ImBuf *)but->poin); + } MEM_freeN(but); } @@ -1968,11 +2006,13 @@ void uiFreeBlock(const bContext *C, uiBlock *block) ui_free_but(C, but); } - if(block->unit) + if (block->unit) { MEM_freeN(block->unit); + } - if(block->func_argN) + if (block->func_argN) { MEM_freeN(block->func_argN); + } CTX_store_free_list(&block->contexts); @@ -2639,8 +2679,9 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s str= BLI_dynstr_get_cstring(dynstr); BLI_dynstr_free(dynstr); - if(free) + if (free) { MEM_freeN(item); + } freestr= 1; } @@ -2656,10 +2697,12 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s } } - if(!str) - str= RNA_property_ui_name(prop); - if(free) + if (!str) { + str = RNA_property_ui_name(prop); + } + if (free) { MEM_freeN(item); + } } else { str= RNA_property_ui_name(prop); @@ -2739,9 +2782,10 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s but->a1= ui_get_but_step_unit(but, but->a1); } - if(freestr) + if (freestr) { MEM_freeN((void *)str); - + } + return but; } @@ -2762,16 +2806,12 @@ static uiBut *ui_def_but_rna_propname(uiBlock *block, int type, int retval, cons return but; } -static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +static uiBut *ui_def_but_operator_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; - wmOperatorType *ot; - - ot= WM_operatortype_find(opname, 0); if(!str) { - if(ot) str= ot->name; - else str= opname; + if(ot) str = ot->name; } if ((!tip || tip[0]=='\0') && ot && ot->description) { @@ -2793,6 +2833,12 @@ static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname, return but; } +static uiBut *UNUSED_FUNCTION(ui_def_but_operator)(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +{ + wmOperatorType *ot = WM_operatortype_find(opname, 0); + if (str == NULL && ot == NULL) str = opname; + return ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); +} static uiBut *ui_def_but_operator_text(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) { @@ -2999,13 +3045,20 @@ uiBut *uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int ui_check_but(but); return but; } -uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) + +uiBut *uiDefButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; - but= ui_def_but_operator(block, type, opname, opcontext, str, x1, y1, x2, y2, tip); + but= ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); ui_check_but(but); return but; } +uiBut *uiDefButO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, const char *tip) +{ + wmOperatorType *ot = WM_operatortype_find(opname, 0); + if (str == NULL && ot == NULL) str = opname; + return uiDefButO_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); +} uiBut *uiDefButTextO(uiBlock *block, int type, const char *opname, int opcontext, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) { @@ -3077,13 +3130,19 @@ uiBut *uiDefIconButR_prop(uiBlock *block, int type, int retval, int icon, int x1 ui_check_but_and_iconize(but, icon); return but; } -uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip) + +uiBut *uiDefIconButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; - but= ui_def_but_operator(block, type, opname, opcontext, "", x1, y1, x2, y2, tip); + but= ui_def_but_operator_ptr(block, type, ot, opcontext, "", x1, y1, x2, y2, tip); ui_check_but_and_iconize(but, icon); return but; } +uiBut *uiDefIconButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, int x1, int y1, short x2, short y2, const char *tip) +{ + wmOperatorType *ot = WM_operatortype_find(opname, 0); + return uiDefIconButO_ptr(block, type, ot, opcontext, icon, x1, y1, x2, y2, tip); +} /* Button containing both string label and icon */ uiBut *uiDefIconTextBut(uiBlock *block, int type, int retval, int icon, const char *str, int x1, int y1, short x2, short y2, void *poin, float min, float max, float a1, float a2, const char *tip) @@ -3151,14 +3210,19 @@ uiBut *uiDefIconTextButR_prop(uiBlock *block, int type, int retval, int icon, co but->flag|= UI_ICON_LEFT; return but; } -uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +uiBut *uiDefIconTextButO_ptr(uiBlock *block, int type, wmOperatorType *ot, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) { uiBut *but; - but= ui_def_but_operator(block, type, opname, opcontext, str, x1, y1, x2, y2, tip); + but= ui_def_but_operator_ptr(block, type, ot, opcontext, str, x1, y1, x2, y2, tip); ui_check_but_and_iconize(but, icon); but->flag|= UI_ICON_LEFT; return but; } +uiBut *uiDefIconTextButO(uiBlock *block, int type, const char *opname, int opcontext, int icon, const char *str, int x1, int y1, short x2, short y2, const char *tip) +{ + wmOperatorType *ot = WM_operatortype_find(opname, 0); + return uiDefIconTextButO_ptr(block, type, ot, opcontext, icon, str, x1, y1, x2, y2, tip); +} /* END Button containing both string label and icon */ @@ -3353,8 +3417,9 @@ void uiBlockSetFunc(uiBlock *block, uiButHandleFunc func, void *arg1, void *arg2 void uiBlockSetNFunc(uiBlock *block, uiButHandleFunc func, void *argN, void *arg2) { - if(block->func_argN) + if (block->func_argN) { MEM_freeN(block->func_argN); + } block->funcN= func; block->func_argN= argN; @@ -3383,8 +3448,9 @@ void uiButSetFunc(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2) void uiButSetNFunc(uiBut *but, uiButHandleNFunc funcN, void *argN, void *arg2) { - if(but->func_argN) + if (but->func_argN) { MEM_freeN(but->func_argN); + } but->funcN= funcN; but->func_argN= argN; @@ -3422,8 +3488,9 @@ uiBut *uiDefBlockButN(uiBlock *block, uiBlockCreateFunc func, void *argN, const { uiBut *but= ui_def_but(block, BLOCK, 0, str, x1, y1, x2, y2, NULL, 0.0, 0.0, 0.0, 0.0, tip); but->block_create_func= func; - if(but->func_argN) + if (but->func_argN) { MEM_freeN(but->func_argN); + } but->func_argN= argN; ui_check_but(but); return but; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 3a19bb2a90c..93d8f9c0c8a 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1115,8 +1115,7 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, { static ColorBand but_copypaste_coba = {0}; char buf[UI_MAX_DRAW_STR+1]= {0}; - double val; - + if(mode=='v' && but->lock) return; @@ -1140,17 +1139,16 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, if(but->poin==NULL && but->rnapoin.data==NULL); else if(mode=='c') { - if(ui_is_but_float(but)) - BLI_snprintf(buf, sizeof(buf), "%f", ui_get_but_val(but)); - else - BLI_snprintf(buf, sizeof(buf), "%d", (int)ui_get_but_val(but)); - + ui_get_but_string(but, buf, sizeof(buf)); WM_clipboard_text_set(buf, 0); } else { - if (sscanf(buf, " %lf ", &val) == 1) { + double val; + + if (ui_set_but_string_eval_num(C, but, buf, &val)) { button_activate_state(C, but, BUTTON_STATE_NUM_EDITING); data->value= val; + ui_set_but_string(C, but, buf); button_activate_state(C, but, BUTTON_STATE_EXIT); } } @@ -1703,8 +1701,9 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste changed= 1; } - if(pbuf) + if (pbuf) { MEM_freeN(pbuf); + } } /* cut & copy */ else if (copy || cut) { @@ -4383,31 +4382,19 @@ static void but_shortcut_name_func(bContext *C, void *arg1, int UNUSED(event)) uiBut *but = (uiBut *)arg1; if (but->optype) { - char buf[512], *cpoin; + char shortcut_str[128]; IDProperty *prop= (but->opptr)? but->opptr->data: NULL; /* complex code to change name of button */ if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, TRUE, - buf, sizeof(buf))) + shortcut_str, sizeof(shortcut_str))) { - char *butstr_orig; - - // XXX but->str changed... should not, remove the hotkey from it - cpoin= strchr(but->str, '|'); - if(cpoin) *cpoin= 0; - - butstr_orig= BLI_strdup(but->str); - BLI_snprintf(but->strdata, sizeof(but->strdata), "%s|%s", butstr_orig, buf); - MEM_freeN(butstr_orig); - but->str= but->strdata; - - ui_check_but(but); + ui_but_add_shortcut(but, shortcut_str, TRUE); } else { - /* shortcut was removed */ - cpoin= strchr(but->str, '|'); - if(cpoin) *cpoin= 0; + /* simply strip the shortcut */ + ui_but_add_shortcut(but, NULL, TRUE); } } } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index a7d8c688f43..3feda5d4db4 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -665,7 +665,9 @@ static void init_iconfile_list(struct ListBase *list) for(; i>=0; i--){ MEM_freeN(dir[i].relname); MEM_freeN(dir[i].path); - if (dir[i].string) MEM_freeN(dir[i].string); + if (dir[i].string) { + MEM_freeN(dir[i].string); + } } free(dir); dir= NULL; diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 7d53e7acbc2..2d8de475c4b 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -356,6 +356,7 @@ extern void ui_get_but_string(uiBut *but, char *str, size_t maxlen); extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen); extern int ui_set_but_string(struct bContext *C, uiBut *but, const char *str); extern int ui_get_but_string_max_length(uiBut *but); +extern int ui_set_but_string_eval_num(struct bContext *C, uiBut *but, const char *str, double *value); extern void ui_set_but_default(struct bContext *C, short all); @@ -497,6 +498,7 @@ void ui_resources_free(void); void ui_layout_add_but(uiLayout *layout, uiBut *but); int ui_but_can_align(uiBut *but); void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop); +void ui_but_add_shortcut(uiBut *but, const char *key_str, const short do_strip); /* interface_anim.c */ void ui_but_anim_flag(uiBut *but, float cfra); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index c8c57c12088..b40c618c301 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -499,8 +499,9 @@ static void ui_item_enum_expand(uiLayout *layout, uiBlock *block, PointerRNA *pt } uiBlockSetCurLayout(block, layout); - if(free) + if (free) { MEM_freeN(item); + } } /* callback for keymap item change button */ @@ -621,19 +622,12 @@ static void ui_item_disabled(uiLayout *layout, const char *name) } /* operator items */ -PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, IDProperty *properties, int context, int flag) +PointerRNA uiItemFullO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, IDProperty *properties, int context, int flag) { uiBlock *block= layout->root->block; - wmOperatorType *ot= WM_operatortype_find(opname, 1); uiBut *but; int w; - if(!ot) { - ui_item_disabled(layout, opname); - RNA_warning("unknown operator '%s'", opname); - return PointerRNA_NULL; - } - if(!name) { name= IFACE_(ot->name); } @@ -649,12 +643,18 @@ PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, i if (flag & UI_ITEM_R_NO_BG) uiBlockSetEmboss(block, UI_EMBOSSN); - if(icon && name[0]) - but= uiDefIconTextButO(block, BUT, ot->idname, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL); - else if(icon) - but= uiDefIconButO(block, BUT, ot->idname, context, icon, 0, 0, w, UI_UNIT_Y, NULL); - else - but= uiDefButO(block, BUT, ot->idname, context, name, 0, 0, w, UI_UNIT_Y, NULL); + /* create the button */ + if(icon) { + if (name[0]) { + but = uiDefIconTextButO_ptr(block, BUT, ot, context, icon, name, 0, 0, w, UI_UNIT_Y, NULL); + } + else { + but = uiDefIconButO_ptr(block, BUT, ot, context, icon, 0, 0, w, UI_UNIT_Y, NULL); + } + } + else { + but= uiDefButO_ptr(block, BUT, ot, context, name, 0, 0, w, UI_UNIT_Y, NULL); + } assert(but->optype != NULL); @@ -686,52 +686,90 @@ PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, i return PointerRNA_NULL; } -static const char *ui_menu_enumpropname(uiLayout *layout, const char *opname, const char *propname, int retval) +PointerRNA uiItemFullO(uiLayout *layout, const char *opname, const char *name, int icon, IDProperty *properties, int context, int flag) { - wmOperatorType *ot= WM_operatortype_find(opname, 0); - PointerRNA ptr; - PropertyRNA *prop; + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ - if(!ot || !ot->srna) - return ""; + if(ot) { + return uiItemFullO_ptr(layout, ot, name, icon, properties, context, flag); + } + else { + ui_item_disabled(layout, opname); + RNA_warning("unknown operator '%s'", opname); + return PointerRNA_NULL; + } +} - RNA_pointer_create(NULL, ot->srna, NULL, &ptr); - prop= RNA_struct_find_property(&ptr, propname); +static const char *ui_menu_enumpropname(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int retval) +{ + EnumPropertyItem *item; + int totitem, free; + const char *name; - if(prop) { - EnumPropertyItem *item; - int totitem, free; - const char *name; + RNA_property_enum_items_gettexted(layout->root->block->evil_C, ptr, prop, &item, &totitem, &free); + if (RNA_enum_name(item, retval, &name) == 0) { + name = ""; + } - RNA_property_enum_items_gettexted(layout->root->block->evil_C, &ptr, prop, &item, &totitem, &free); - if(RNA_enum_name(item, retval, &name)) { - if(free) MEM_freeN(item); - return name; - } - - if(free) - MEM_freeN(item); + if (free) { + MEM_freeN(item); } - return ""; + return name; } -void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value) +/* same as below but 'prop' is already known */ +static void uiItemEnumO_ptr__internal(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, PropertyRNA *prop, int value) { PointerRNA ptr; + WM_operator_properties_create_ptr(&ptr, ot); + RNA_property_enum_set(&ptr, prop, value); + + if(!name) + name = ui_menu_enumpropname(layout, &ptr, prop, value); + + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); +} +void uiItemEnumO_ptr(uiLayout *layout, wmOperatorType *ot, const char *name, int icon, const char *propname, int value) +{ + PointerRNA ptr; + PropertyRNA *prop; - WM_operator_properties_create(&ptr, opname); - RNA_enum_set(&ptr, propname, value); + WM_operator_properties_create_ptr(&ptr, ot); + + if ((prop = RNA_struct_find_property(&ptr, propname))) { + /* pass */ + } + else { + RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname); + return; + } + + RNA_property_enum_set(&ptr, prop, value); if(!name) - name= ui_menu_enumpropname(layout, opname, propname, value); + name = ui_menu_enumpropname(layout, &ptr, prop, value); + + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); +} +void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value) +{ + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ + + if(ot) { + uiItemEnumO_ptr(layout, ot, name, icon, propname, value); + } + else { + ui_item_disabled(layout, opname); + RNA_warning("unknown operator '%s'", opname); + } - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname, IDProperty *properties, int context, int flag) { - wmOperatorType *ot= WM_operatortype_find(opname, 1); + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ + PointerRNA ptr; PropertyRNA *prop; uiBut *bt; @@ -744,7 +782,7 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname } RNA_pointer_create(NULL, ot->srna, NULL, &ptr); - prop= RNA_struct_find_property(&ptr, propname); + prop = RNA_struct_find_property(&ptr, propname); /* don't let bad properties slip through */ BLI_assert((prop == NULL) || (RNA_property_type(prop) == PROP_ENUM)); @@ -768,12 +806,13 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname MEM_freeN(tptr.data); } tptr.data= IDP_CopyProperty(properties); - RNA_enum_set(&tptr, propname, item[i].value); + RNA_property_enum_set(&tptr, prop, item[i].value); - uiItemFullO(column, opname, item[i].name, item[i].icon, tptr.data, context, flag); + uiItemFullO_ptr(column, ot, item[i].name, item[i].icon, tptr.data, context, flag); + } + else { + uiItemEnumO_ptr__internal(column, ot, item[i].name, item[i].icon, prop, item[i].value); } - else - uiItemEnumO(column, opname, item[i].name, item[i].icon, propname, item[i].value); } else { if(item[i].name) { @@ -792,8 +831,9 @@ void uiItemsFullEnumO(uiLayout *layout, const char *opname, const char *propname } } - if(free) + if (free) { MEM_freeN(item); + } } } @@ -802,18 +842,26 @@ void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) uiItemsFullEnumO(layout, opname, propname, NULL, layout->root->opcontext, 0); } +#define UI_OPERATOR_ERROR_RET(_ot, _opname) \ + if (ot == NULL) { \ + ui_item_disabled(layout, _opname); \ + RNA_warning("'%s' unknown operator", _opname); \ + return; \ + } (void)0 + /* for use in cases where we have */ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - - /* for getting the enum */ PropertyRNA *prop; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); /* enum lookup */ - if((prop= RNA_struct_find_property(&ptr, propname))) { + if ((prop = RNA_struct_find_property(&ptr, propname))) { /* pass */ } else { @@ -825,33 +873,38 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char /* same as uiItemEnumO */ if(!name) - name= ui_menu_enumpropname(layout, opname, propname, value); + name = ui_menu_enumpropname(layout, &ptr, prop, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value_str) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - - /* for getting the enum */ PropertyRNA *prop; + EnumPropertyItem *item; int value, free; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); /* enum lookup */ if((prop= RNA_struct_find_property(&ptr, propname))) { RNA_property_enum_items_gettexted(layout->root->block->evil_C, &ptr, prop, &item, NULL, &free); if(item==NULL || RNA_enum_value_from_id(item, value_str, &value)==0) { - if(free) MEM_freeN(item); + if(free) { + MEM_freeN(item); + } RNA_warning("%s.%s, enum %s not found", RNA_struct_identifier(ptr.type), propname, value_str); return; } - if(free) + if (free) { MEM_freeN(item); + } } else { RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname); @@ -862,49 +915,61 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char /* same as uiItemEnumO */ if(!name) - name= ui_menu_enumpropname(layout, opname, propname, value); + name = ui_menu_enumpropname(layout, &ptr, prop, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); RNA_boolean_set(&ptr, propname, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); RNA_int_set(&ptr, propname, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, float value) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); RNA_float_set(&ptr, propname, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value) { + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - WM_operator_properties_create(&ptr, opname); + UI_OPERATOR_ERROR_RET(ot, opname); + + WM_operator_properties_create_ptr(&ptr, ot); RNA_string_set(&ptr, propname, value); - uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); + uiItemFullO_ptr(layout, ot, name, icon, ptr.data, layout->root->opcontext, 0); } void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname) @@ -1096,7 +1161,9 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr RNA_property_enum_items_gettexted(layout->root->block->evil_C, ptr, prop, &item, NULL, &free); if(!RNA_enum_value_from_id(item, value, &ivalue)) { - if(free) MEM_freeN(item); + if (free) { + MEM_freeN(item); + } ui_item_disabled(layout, propname); RNA_warning("enum property value not found: %s", value); return; @@ -1109,8 +1176,9 @@ void uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *pr } } - if(free) + if (free) { MEM_freeN(item); + } } void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname) @@ -1160,8 +1228,9 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname } } - if(free) + if (free) { MEM_freeN(item); + } } } @@ -1536,14 +1605,11 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, const char *name, int icon) { - wmOperatorType *ot= WM_operatortype_find(opname, 1); + wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ MenuItemLevel *lvl; - if(!ot) { - ui_item_disabled(layout, opname); - RNA_warning("unknown operator '%s'", opname); - return; - } + UI_OPERATOR_ERROR_RET(ot, opname); + if(!ot->srna) { ui_item_disabled(layout, opname); RNA_warning("operator missing srna '%s'", opname); @@ -2731,8 +2797,9 @@ const char *uiLayoutIntrospect(uiLayout *layout) { DynStr *ds= BLI_dynstr_new(); - if(str) + if (str) { MEM_freeN(str); + } ui_intro_uiLayout(ds, layout); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index c21bc09ff27..d802c8640b8 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -772,8 +772,9 @@ static int uiAlignPanelStep(ScrArea *sa, ARegion *ar, float fac, int drag) ui_panel_copy_offset(pa, pa->paneltab); /* free panelsort array */ - for(ps= panelsort, a=0; a<tot; a++, ps++) + for (ps = panelsort, a = 0; a < tot; a++, ps++) { MEM_freeN(ps->pa); + } MEM_freeN(panelsort); return done; diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index c3cbb9dbe5f..8e336a363df 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -138,8 +138,9 @@ static void menudata_add_item(MenuData *md, const char *str, int retval, int ico static void menudata_free(MenuData *md) { MEM_freeN((void *)md->instr); - if (md->items) + if (md->items) { MEM_freeN(md->items); + } MEM_freeN(md); } @@ -394,8 +395,9 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) } } - if(free) + if (free) { MEM_freeN(item); + } } } @@ -982,8 +984,9 @@ static void ui_searchbox_region_free_cb(ARegion *ar) int a; /* free search data */ - for(a=0; a<data->items.maxitem; a++) + for (a = 0; a < data->items.maxitem; a++) { MEM_freeN(data->items.names[a]); + } MEM_freeN(data->items.names); MEM_freeN(data->items.pointers); MEM_freeN(data->items.icons); @@ -1182,8 +1185,9 @@ void ui_but_search_test(uiBut *but) uiButSetFlag(but, UI_BUT_REDALERT); } - for(x1=0; x1<items->maxitem; x1++) + for (x1 = 0; x1 < items->maxitem; x1++) { MEM_freeN(items->names[x1]); + } MEM_freeN(items->names); MEM_freeN(items); } @@ -2474,7 +2478,7 @@ static void confirm_operator(bContext *C, wmOperator *op, const char *title, con char *s, buf[512]; s= buf; - if (title) s+= sprintf(s, "%s%%t|%s", title, item); + if (title) s+= BLI_snprintf(s, sizeof(buf), "%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_templates.c b/source/blender/editors/interface/interface_templates.c index c8361f56fee..3903271679f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2267,8 +2267,9 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */ /* free name */ - if(namebuf) + if (namebuf) { MEM_freeN(namebuf); + } } void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, PointerRNA *activeptr, const char *activepropname, const char *prop_list, int rows, int maxrows, int listtype) @@ -2372,8 +2373,9 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * icon= list_item_icon_get(C, &itemptr, rnaicon, 0); uiItemL(row, (name)? name: "", icon); - if(name) + if (name) { MEM_freeN((void *)name); + } } i++; diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index ad20ff0b6dd..7cc9febc603 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -452,6 +452,14 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp= ts->camera_path; break; case TH_LOCK_MARKER: cp= ts->lock_marker; break; + + case TH_MATCH: + cp= ts->match; + break; + + case TH_SELECT_HIGHLIGHT: + cp= ts->selected_highlight; + break; } } } @@ -792,6 +800,9 @@ void ui_theme_init_default(void) btheme->toops= btheme->tv3d; SETCOLF(btheme->toops.back, 0.45, 0.45, 0.45, 1.0); + SETCOLF(btheme->toops.match, 0.2, 0.5, 0.2, 0.3); /* highlighting search match - soft green*/ + SETCOLF(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3); + /* space info */ btheme->tinfo= btheme->tv3d; SETCOLF(btheme->tinfo.back, 0.45, 0.45, 0.45, 1.0); @@ -1696,17 +1707,17 @@ void init_userdef_do_versions(void) BLI_addtail(&U.addons, baddon); } } - + if (bmain->versionfile < 260 || (bmain->versionfile == 260 && bmain->subversionfile < 5)) { bTheme *btheme; - + for(btheme= U.themes.first; btheme; btheme= btheme->next) { SETCOL(btheme->tui.panel.header, 0, 0, 0, 25); btheme->tui.icon_alpha= 1.0; } } - - if (bmain->versionfile < 262){ + + if (bmain->versionfile < 261 || (bmain->versionfile == 261 && bmain->subversionfile < 4)) { bTheme *btheme; for(btheme= U.themes.first; btheme; btheme= btheme->next) { SETCOLF(btheme->tima.preview_stitch_face, 0.071, 0.259, 0.694, 0.150); @@ -1715,10 +1726,14 @@ void init_userdef_do_versions(void) SETCOLF(btheme->tima.preview_stitch_stitchable, 0.0, 1.0, 0.0, 1.0); SETCOLF(btheme->tima.preview_stitch_unstitchable, 1.0, 0.0, 0.0, 1.0); SETCOLF(btheme->tima.preview_stitch_active, 0.886, 0.824, 0.765, 0.140); + + SETCOLF(btheme->toops.match, 0.2, 0.5, 0.2, 0.3); + SETCOLF(btheme->toops.selected_highlight, 0.51, 0.53, 0.55, 0.3); } + U.use_16bit_textures = 0; } - + /* GL Texture Garbage Collection (variable abused above!) */ if (U.textimeout == 0) { U.texcollectrate = 60; diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index b8201d762df..3eb8aba7334 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1339,8 +1339,9 @@ void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy) void UI_view2d_grid_free(View2DGrid *grid) { /* only free if there's a grid */ - if (grid) + if (grid) { MEM_freeN(grid); + } } /* *********************************************************************** */ @@ -1754,7 +1755,9 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v void UI_view2d_scrollers_free(View2DScrollers *scrollers) { /* need to free grid as well... */ - if (scrollers->grid) MEM_freeN(scrollers->grid); + if (scrollers->grid) { + MEM_freeN(scrollers->grid); + } MEM_freeN(scrollers); } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index f96da9e5b07..1b289732302 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -46,6 +46,7 @@ #include "DNA_scene_types.h" #include "DNA_speaker_types.h" #include "DNA_vfont_types.h" +#include "DNA_actuator_types.h" #include "BLI_ghash.h" #include "BLI_listbase.h" @@ -1795,8 +1796,22 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base Key *key = ob_get_key(obn); if(dupflag & USER_DUP_ACT) { + bActuator *act; + BKE_copy_animdata_id_action((ID *)obn->data); - if(key) BKE_copy_animdata_id_action((ID*)key); + if(key) { + BKE_copy_animdata_id_action((ID*)key); + } + + /* Update the duplicated action in the action actuators */ + for (act = obn->actuators.first; act; act = act->next) { + if(act->type == ACT_ACTION) { + bActionActuator* actact = (bActionActuator*) act->data; + if(actact->act == ob->adt->action) { + actact->act = obn->adt->action; + } + } + } } if(dupflag & USER_DUP_MAT) { diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 3aa604d48c0..8745c8ca6e6 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -298,7 +298,7 @@ static int make_proxy_invoke (bContext *C, wmOperator *op, wmEvent *evt) uiLayout *layout= uiPupMenuLayout(pup); /* create operator menu item with relevant properties filled in */ - uiItemFullO(layout, op->idname, op->type->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); + uiItemFullO_ptr(layout, op->type, op->type->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); /* present the menu and be done... */ uiPupMenuEnd(C, pup); @@ -419,43 +419,47 @@ void OBJECT_OT_proxy_make (wmOperatorType *ot) /********************** Clear Parent Operator ******************* */ -static EnumPropertyItem prop_clear_parent_types[] = { +EnumPropertyItem prop_clear_parent_types[] = { {0, "CLEAR", 0, "Clear Parent", ""}, {1, "CLEAR_KEEP_TRANSFORM", 0, "Clear and Keep Transformation", ""}, {2, "CLEAR_INVERSE", 0, "Clear Parent Inverse", ""}, {0, NULL, 0, NULL, NULL} }; -/* note, poll should check for editable scene */ -static int parent_clear_exec(bContext *C, wmOperator *op) +void ED_object_parent_clear(bContext *C, int type) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - int type= RNA_enum_get(op->ptr, "type"); - - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { + CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) + { if(ob->parent == NULL) continue; if(type == 0) { ob->parent= NULL; - } + } else if(type == 1) { ob->parent= NULL; object_apply_mat4(ob, ob->obmat, TRUE, FALSE); } else if(type == 2) unit_m4(ob->parentinv); - + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; } CTX_DATA_END; - + DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); +} + +/* note, poll should check for editable scene */ +static int parent_clear_exec(bContext *C, wmOperator *op) +{ + ED_object_parent_clear(C, RNA_enum_get(op->ptr, "type")); return OPERATOR_FINISHED; } @@ -481,35 +485,6 @@ void OBJECT_OT_parent_clear(wmOperatorType *ot) /* ******************** Make Parent Operator *********************** */ -#define PAR_OBJECT 0 -#define PAR_ARMATURE 1 -#define PAR_ARMATURE_NAME 2 -#define PAR_ARMATURE_ENVELOPE 3 -#define PAR_ARMATURE_AUTO 4 -#define PAR_BONE 5 -#define PAR_CURVE 6 -#define PAR_FOLLOW 7 -#define PAR_PATH_CONST 8 -#define PAR_LATTICE 9 -#define PAR_VERTEX 10 -#define PAR_TRIA 11 - -static EnumPropertyItem prop_make_parent_types[] = { - {PAR_OBJECT, "OBJECT", 0, "Object", ""}, - {PAR_ARMATURE, "ARMATURE", 0, "Armature Deform", ""}, - {PAR_ARMATURE_NAME, "ARMATURE_NAME", 0, " With Empty Groups", ""}, - {PAR_ARMATURE_AUTO, "ARMATURE_AUTO", 0, " With Automatic Weights", ""}, - {PAR_ARMATURE_ENVELOPE, "ARMATURE_ENVELOPE", 0, " With Envelope Weights", ""}, - {PAR_BONE, "BONE", 0, "Bone", ""}, - {PAR_CURVE, "CURVE", 0, "Curve Deform", ""}, - {PAR_FOLLOW, "FOLLOW", 0, "Follow Path", ""}, - {PAR_PATH_CONST, "PATH_CONST", 0, "Path Constraint", ""}, - {PAR_LATTICE, "LATTICE", 0, "Lattice Deform", ""}, - {PAR_VERTEX, "VERTEX", 0, "Vertex", ""}, - {PAR_TRIA, "TRIA", 0, "Triangle", ""}, - {0, NULL, 0, NULL, NULL} -}; - void ED_object_parent(Object *ob, Object *par, int type, const char *substr) { if (!par || BKE_object_parent_loop_check(par, ob)) { @@ -527,13 +502,28 @@ void ED_object_parent(Object *ob, Object *par, int type, const char *substr) BLI_strncpy(ob->parsubstr, substr, sizeof(ob->parsubstr)); } -static int parent_set_exec(bContext *C, wmOperator *op) +/* Operator Property */ +EnumPropertyItem prop_make_parent_types[] = { + {PAR_OBJECT, "OBJECT", 0, "Object", ""}, + {PAR_ARMATURE, "ARMATURE", 0, "Armature Deform", ""}, + {PAR_ARMATURE_NAME, "ARMATURE_NAME", 0, " With Empty Groups", ""}, + {PAR_ARMATURE_AUTO, "ARMATURE_AUTO", 0, " With Automatic Weights", ""}, + {PAR_ARMATURE_ENVELOPE, "ARMATURE_ENVELOPE", 0, " With Envelope Weights", ""}, + {PAR_BONE, "BONE", 0, "Bone", ""}, + {PAR_CURVE, "CURVE", 0, "Curve Deform", ""}, + {PAR_FOLLOW, "FOLLOW", 0, "Follow Path", ""}, + {PAR_PATH_CONST, "PATH_CONST", 0, "Path Constraint", ""}, + {PAR_LATTICE, "LATTICE", 0, "Lattice Deform", ""}, + {PAR_VERTEX, "VERTEX", 0, "Vertex", ""}, + {PAR_TRIA, "TRIA", 0, "Triangle", ""}, + {0, NULL, 0, NULL, NULL} +}; + +int ED_object_parent_set(bContext *C, wmOperator *op, Object *par, int partype) { Main *bmain= CTX_data_main(C); Scene *scene= CTX_data_scene(C); - Object *par= ED_object_active_context(C); bPoseChannel *pchan= NULL; - int partype= RNA_enum_get(op->ptr, "type"); int pararm= ELEM4(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO); par->recalc |= OB_RECALC_OB; @@ -541,7 +531,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) /* preconditions */ if(partype==PAR_FOLLOW || partype==PAR_PATH_CONST) { if(par->type!=OB_CURVE) - return OPERATOR_CANCELLED; + return 0; else { Curve *cu= par->data; @@ -572,15 +562,14 @@ static int parent_set_exec(bContext *C, wmOperator *op) if(pchan==NULL) { BKE_report(op->reports, RPT_ERROR, "No active Bone"); - return OPERATOR_CANCELLED; + return 0; } } /* context iterator */ - CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) { - - if(ob!=par) { - + CTX_DATA_BEGIN(C, Object*, ob, selected_editable_objects) + { + if (ob!=par) { if (BKE_object_parent_loop_check(par, ob)) { BKE_report(op->reports, RPT_ERROR, "Loop in parents"); } @@ -589,10 +578,11 @@ static int parent_set_exec(bContext *C, wmOperator *op) /* apply transformation of previous parenting */ /* object_apply_mat4(ob, ob->obmat); */ /* removed because of bug [#23577] */ - + /* set the parent (except for follow-path constraint option) */ - if(partype != PAR_PATH_CONST) + if (partype != PAR_PATH_CONST) { ob->parent= par; + } /* handle types */ if (pchan) @@ -600,9 +590,10 @@ static int parent_set_exec(bContext *C, wmOperator *op) else ob->parsubstr[0]= 0; - if(partype == PAR_PATH_CONST) - ; /* don't do anything here, since this is not technically "parenting" */ - else if( ELEM(partype, PAR_CURVE, PAR_LATTICE) || pararm ) + if (partype == PAR_PATH_CONST) { + /* don't do anything here, since this is not technically "parenting" */ + } + else if (ELEM(partype, PAR_CURVE, PAR_LATTICE) || (pararm)) { /* partype is now set to PAROBJECT so that invisible 'virtual' modifiers don't need to be created * NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, creating the virtual modifiers @@ -612,10 +603,10 @@ static int parent_set_exec(bContext *C, wmOperator *op) /* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses */ // XXX currently this should only happen for meshes, curves, surfaces, and lattices - this stuff isn't available for metas yet - if (ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) + if (ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { ModifierData *md; - + switch (partype) { case PAR_CURVE: /* curve deform */ md= ED_object_modifier_add(op->reports, bmain, scene, ob, NULL, eModifierType_Curve); @@ -682,15 +673,27 @@ static int parent_set_exec(bContext *C, wmOperator *op) } } CTX_DATA_END; - + DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); - - return OPERATOR_FINISHED; + + return 1; +} + +static int parent_set_exec(bContext *C, wmOperator *op) +{ + Object *par= ED_object_active_context(C); + int partype= RNA_enum_get(op->ptr, "type"); + + if(ED_object_parent_set(C, op, par, partype)) + return OPERATOR_FINISHED; + else + return OPERATOR_CANCELLED; } + static int parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { Object *ob= ED_object_active_context(C); diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 6b2847b6182..9289f9794b9 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -873,7 +873,7 @@ static void getVerticalAndHorizontalChange(const float norm[3], float d, const f closest_to_plane_v3(projB, coord, norm, end); // (vertical and horizontal refer to the plane's y and xz respectively) // vertical distance - dists[index] = norm[0]*end[0] + norm[1]*end[1] + norm[2]*end[2] + d; + dists[index] = dot_v3v3(norm, end) + d; // vertical change changes[index][0] = dists[index] - distToStart; //printf("vc %f %f\n", distance(end, projB, 3)-distance(start, projA, 3), changes[index][0]); @@ -1114,7 +1114,7 @@ static void vgroup_fix(Scene *scene, Object *ob, float distToBe, float strength, mag= normalize_v3(norm); if(mag) { /* zeros fix */ d = -dot_v3v3(norm, coord); - /* dist = (norm[0]*m.co[0] + norm[1]*m.co[1] + norm[2]*m.co[2] + d); */ /* UNUSED */ + /* dist = (dot_v3v3(norm, m.co) + d); */ /* UNUSED */ moveCloserToDistanceFromPlane(scene, ob, me, i, norm, coord, d, distToBe, strength, cp); } } diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index d652d2c0e5c..dbc153de108 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -113,6 +113,18 @@ static float get_fluid_viscosity(FluidsimSettings *settings) } } +static float get_fluid_rate(FluidsimSettings *settings) +{ + float rate = 1.0f; /* default rate if not animated... */ + + rate = settings->animRate; + + if (rate < 0.0f) + rate = 0.0f; + + return rate; +} + static void get_fluid_gravity(float *gravity, Scene *scene, FluidsimSettings *fss) { if (scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { @@ -243,7 +255,7 @@ static void init_time(FluidsimSettings *domainSettings, FluidAnimChannels *chann channels->timeAtFrame[0] = channels->timeAtFrame[1] = domainSettings->animStart; // start at index 1 - for(i=2; i<=channels->length; i++) { + for (i=2; i <= channels->length; i++) { channels->timeAtFrame[i] = channels->timeAtFrame[i-1] + channels->aniFrameTime; } } @@ -305,6 +317,8 @@ static void free_domain_channels(FluidAnimChannels *channels) channels->DomainGravity = NULL; MEM_freeN(channels->DomainViscosity); channels->DomainViscosity = NULL; + MEM_freeN(channels->DomainTime); + channels->DomainTime = NULL; } static void free_all_fluidobject_channels(ListBase *fobjects) @@ -351,14 +365,13 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid int length = channels->length; float eval_time; - /* XXX: first init time channel - temporary for now */ - /* init time values (should be done after evaluating animated time curve) */ + /* init time values (assuming that time moves at a constant speed; may be overridden later) */ init_time(domainSettings, channels); /* allocate domain animation channels */ channels->DomainGravity = MEM_callocN( length * (CHANNEL_VEC+1) * sizeof(float), "channel DomainGravity"); channels->DomainViscosity = MEM_callocN( length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainViscosity"); - //channels->DomainTime = MEM_callocN( length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime"); + channels->DomainTime = MEM_callocN( length * (CHANNEL_FLOAT+1) * sizeof(float), "channel DomainTime"); /* allocate fluid objects */ for (base=scene->base.first; base; base= base->next) { @@ -406,10 +419,9 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid for (i=0; i<channels->length; i++) { FluidObject *fobj; float viscosity, gravity[3]; - float timeAtFrame; + float timeAtFrame, time; eval_time = domainSettings->bakeStart + i; - timeAtFrame = channels->timeAtFrame[i+1]; /* XXX: This can't be used due to an anim sys optimisation that ignores recalc object animation, * leaving it for the depgraph (this ignores object animation such as modifier properties though... :/ ) @@ -425,12 +437,24 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid /* now scene data should be current according to animation system, so we fill the channels */ - /* Domain properties - gravity/viscosity/time */ + /* Domain time */ + // TODO: have option for not running sim, time mangling, in which case second case comes in handy + if (channels->DomainTime) { + time = get_fluid_rate(domainSettings) * channels->aniFrameTime; + timeAtFrame = channels->timeAtFrame[i] + time; + + channels->timeAtFrame[i+1] = timeAtFrame; + set_channel(channels->DomainTime, i, &time, i, CHANNEL_FLOAT); + } + else { + timeAtFrame = channels->timeAtFrame[i+1]; + } + + /* Domain properties - gravity/viscosity */ get_fluid_gravity(gravity, scene, domainSettings); set_channel(channels->DomainGravity, timeAtFrame, gravity, i, CHANNEL_VEC); viscosity = get_fluid_viscosity(domainSettings); set_channel(channels->DomainViscosity, timeAtFrame, &viscosity, i, CHANNEL_FLOAT); - // XXX : set_channel(channels->DomainTime, timeAtFrame, &time, i, CHANNEL_VEC); /* object movement */ for (fobj=fobjects->first; fobj; fobj=fobj->next) { @@ -957,38 +981,6 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* reset to original current frame */ scene->r.cfra = origFrame; ED_update_for_newframe(CTX_data_main(C), scene, CTX_wm_screen(C), 1); - - - /* ---- XXX: No Time animation curve for now, leaving this code here for reference - - { int timeIcu[1] = { FLUIDSIM_TIME }; - float timeDef[1] = { 1. }; - - // time channel is a bit special, init by hand... - timeAtIndex = MEM_callocN( (allchannelSize+1)*1*sizeof(float), "fluidsiminit_timeatindex"); - for(i=0; i<=scene->r.efra; i++) { - timeAtIndex[i] = (float)(i-startFrame); - } - fluidsimInitChannel(scene, &channelDomainTime, allchannelSize, timeAtIndex, timeIcu,timeDef, domainSettings->ipo, CHANNEL_FLOAT ); // NDEB - // time channel is a multiplicator for - if(channelDomainTime) { - for(i=0; i<allchannelSize; i++) { - channelDomainTime[i*2+0] = aniFrameTime * channelDomainTime[i*2+0]; - if(channelDomainTime[i*2+0]<0.) channelDomainTime[i*2+0] = 0.; - } - } - timeAtFrame = MEM_callocN( (allchannelSize+1)*1*sizeof(float), "fluidsiminit_timeatframe"); - timeAtFrame[0] = timeAtFrame[1] = domainSettings->animStart; // start at index 1 - if(channelDomainTime) { - for(i=2; i<=allchannelSize; i++) { - timeAtFrame[i] = timeAtFrame[i-1]+channelDomainTime[(i-1)*2+0]; - } - fsset->} else { - for(i=2; i<=allchannelSize; i++) { timeAtFrame[i] = timeAtFrame[i-1]+aniFrameTime; } - } - - } // domain channel init - */ /* ******** init domain object's matrix ******** */ copy_m4_m4(domainMat, fsDomain->obmat); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 0ff0f278f17..c2026b30ab2 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -663,9 +663,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", QKEY, KM_PRESS, 0, 0); RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_uv_sculpt"); - WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, 0, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "temp_relax", 1); + RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "mode", BRUSH_STROKE_NORMAL); + RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "mode", BRUSH_STROKE_INVERT); + RNA_enum_set(WM_keymap_add_item(keymap, "SCULPT_OT_uv_sculpt_stroke", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", BRUSH_STROKE_SMOOTH); ed_keymap_paint_brush_size(keymap, "tool_settings.uv_sculpt.brush.size"); ed_keymap_paint_brush_radial_control(keymap, "uv_sculpt", 0); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index ca8ff23c694..b7511367cc8 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -580,8 +580,7 @@ void vpaint_dogamma(Scene *scene) } */ - -static unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int mfac; @@ -604,7 +603,7 @@ static unsigned int mcol_blend(unsigned int col1, unsigned int col2, int fac) return col; } -static unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int temp; @@ -627,7 +626,7 @@ static unsigned int mcol_add(unsigned int col1, unsigned int col2, int fac) return col; } -static unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int temp; @@ -650,7 +649,7 @@ static unsigned int mcol_sub(unsigned int col1, unsigned int col2, int fac) return col; } -static unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int mfac; @@ -674,7 +673,7 @@ static unsigned int mcol_mul(unsigned int col1, unsigned int col2, int fac) return col; } -static unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int mfac; @@ -702,7 +701,7 @@ static unsigned int mcol_lighten(unsigned int col1, unsigned int col2, int fac) return col; } -static unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac) +BM_INLINE unsigned int mcol_darken(unsigned int col1, unsigned int col2, int fac) { char *cp1, *cp2, *cp; int mfac; @@ -735,18 +734,12 @@ static unsigned int vpaint_blend_tool(const int tool, const unsigned int col, { switch (tool) { case PAINT_BLEND_MIX: - case PAINT_BLEND_BLUR: - return mcol_blend(col, paintcol, alpha_i); - case PAINT_BLEND_ADD: - return mcol_add(col, paintcol, alpha_i); - case PAINT_BLEND_SUB: - return mcol_sub(col, paintcol, alpha_i); - case PAINT_BLEND_MUL: - return mcol_mul(col, paintcol, alpha_i); - case PAINT_BLEND_LIGHTEN: - return mcol_lighten(col, paintcol, alpha_i); - case PAINT_BLEND_DARKEN: - return mcol_darken(col, paintcol, alpha_i); + case PAINT_BLEND_BLUR: return mcol_blend(col, paintcol, alpha_i); + case PAINT_BLEND_ADD: return mcol_add(col, paintcol, alpha_i); + case PAINT_BLEND_SUB: return mcol_sub(col, paintcol, alpha_i); + case PAINT_BLEND_MUL: return mcol_mul(col, paintcol, alpha_i); + case PAINT_BLEND_LIGHTEN: return mcol_lighten(col, paintcol, alpha_i); + case PAINT_BLEND_DARKEN: return mcol_darken(col, paintcol, alpha_i); default: BLI_assert(0); return 0; @@ -881,6 +874,33 @@ static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, return 0.0f; } + +BM_INLINE float wval_blend(const float weight, const float paintval, const float alpha) +{ + return (paintval * alpha) + (weight * (1.0f - alpha)); +} +BM_INLINE float wval_add(const float weight, const float paintval, const float alpha) +{ + return weight + (paintval * alpha); +} +BM_INLINE float wval_sub(const float weight, const float paintval, const float alpha) +{ + return weight - (paintval * alpha); +} +BM_INLINE float wval_mul(const float weight, const float paintval, const float alpha) +{ /* first mul, then blend the fac */ + return ((1.0f - alpha) + (alpha * paintval)) * weight; +} +BM_INLINE float wval_lighten(const float weight, const float paintval, const float alpha) +{ + return (weight < paintval) ? wval_blend(weight, paintval, alpha) : weight; +} +BM_INLINE float wval_darken(const float weight, const float paintval, const float alpha) +{ + return (weight > paintval) ? wval_blend(weight, paintval, alpha) : weight; +} + + /* vpaint has 'vpaint_blend_tool' */ /* result is not clamped from [0-1] */ static float wpaint_blend_tool(const int tool, @@ -890,19 +910,12 @@ static float wpaint_blend_tool(const int tool, { switch (tool) { case PAINT_BLEND_MIX: - case PAINT_BLEND_BLUR: - return (paintval * alpha) + (weight * (1.0f - alpha)); - case PAINT_BLEND_ADD: - return (paintval * alpha) + weight; - case PAINT_BLEND_SUB: - return (paintval * alpha) - weight; - case PAINT_BLEND_MUL: - /* first mul, then blend the fac */ - return ((1.0f - alpha) + alpha * paintval) * weight; - case PAINT_BLEND_LIGHTEN: - return (weight < paintval) ? (paintval * alpha) + (weight * (1.0f - alpha)) : weight; - case PAINT_BLEND_DARKEN: - return (weight > paintval) ? (paintval * alpha) + (weight * (1.0f - alpha)) : weight; + case PAINT_BLEND_BLUR: return wval_blend(weight, paintval, alpha); + case PAINT_BLEND_ADD: return wval_add(weight, paintval, alpha); + case PAINT_BLEND_SUB: return wval_sub(weight, paintval, alpha); + case PAINT_BLEND_MUL: return wval_mul(weight, paintval, alpha); + case PAINT_BLEND_LIGHTEN: return wval_lighten(weight, paintval, alpha); + case PAINT_BLEND_DARKEN: return wval_darken(weight, paintval, alpha); default: BLI_assert(0); return 0.0f; diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 21bbb014eb0..228183d3d8a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -122,24 +122,30 @@ typedef struct UvSculptData{ /* Edges used for adjacency info, used with laplacian smoothing */ UvEdge *uvedges; - /* Need I say more? */ + /* need I say more? */ int totalUvEdges; /* data for initial stroke, used by tools like grab */ UVInitialStroke *initial_stroke; - /* Timer to be used for airbrush-type brush */ + /* timer to be used for airbrush-type brush */ wmTimer *timer; - /* To determine quickly adjacent uvs */ + /* to determine quickly adjacent uvs */ UvElementMap *elementMap; /* uvsmooth Paint for fast reference */ Paint *uvsculpt; + + /* tool to use. duplicating here to change if modifier keys are pressed */ + char tool; + + /* store invert flag here */ + char invert; }UvSculptData; /*********** Improved Laplacian Relaxation Operator ************************/ -/* Original code by Raul Fernandez Hernandez "farsthary" * +/* original code by Raul Fernandez Hernandez "farsthary" * * adapted to uv smoothing by Antony Riakiatakis * ***************************************************************************/ @@ -301,9 +307,8 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event, float alpha, zoomx, zoomy; Brush *brush = paint_brush(sculptdata->uvsculpt); ToolSettings *toolsettings = CTX_data_tool_settings(C); - tool = RNA_boolean_get(op->ptr, "temp_relax")? UV_SCULPT_TOOL_RELAX : toolsettings->uv_sculpt_tool; - - invert = RNA_boolean_get(op->ptr, "invert")? -1 : 1; + tool = sculptdata->tool; + invert = sculptdata->invert? -1 : 1; alpha = brush_alpha(scene, brush); UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]); @@ -475,6 +480,8 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent int island_index = 0; /* Holds, for each UvElement in elementMap, a pointer to its unique uv.*/ int *uniqueUv; + data->tool = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_SMOOTH)? UV_SCULPT_TOOL_RELAX : ts->uv_sculpt_tool; + data->invert = (RNA_enum_get(op->ptr, "mode") == BRUSH_STROKE_INVERT)? 1 : 0; data->uvsculpt = &ts->uvsculpt->paint; @@ -652,7 +659,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent } /* Allocate initial selection for grab tool */ - if(ts->uv_sculpt_tool == UV_SCULPT_TOOL_GRAB){ + if(data->tool){ float radius, radius_root; UvSculptData *sculptdata = (UvSculptData *)op->customdata; SpaceImage *sima; @@ -768,6 +775,13 @@ static int uv_sculpt_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot) { + static EnumPropertyItem stroke_mode_items[] = { + {BRUSH_STROKE_NORMAL, "NORMAL", 0, "Normal", "Apply brush normally"}, + {BRUSH_STROKE_INVERT, "INVERT", 0, "Invert", "Invert action of brush for duration of stroke"}, + {BRUSH_STROKE_SMOOTH, "RELAX", 0, "Relax", "Switch brush to relax mode for duration of stroke"}, + {0} + }; + /* identifiers */ ot->name = "Sculpt UVs"; ot->description = "Sculpt UVs using a brush"; @@ -782,6 +796,5 @@ void SCULPT_OT_uv_sculpt_stroke(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; /* props */ - RNA_def_boolean(ot->srna, "invert", 0, "Invert", "Inverts the operator"); - RNA_def_boolean(ot->srna, "temp_relax", 0, "Relax", "Relax Tool"); + RNA_def_enum(ot->srna, "mode", stroke_mode_items, BRUSH_STROKE_NORMAL, "Mode", "Stroke Mode"); } diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 4c028612320..57981431492 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -1061,7 +1061,6 @@ ID *buttons_context_id_path(const bContext *C) if(ptr->id.data) { return ptr->id.data; - break; } } } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 32fe8498eaf..b5059d157b9 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -586,7 +586,7 @@ const char * filelist_dir(struct FileList* filelist) void filelist_setdir(struct FileList* filelist, const char *dir) { - BLI_strncpy(filelist->dir, dir, FILE_MAX); + BLI_strncpy(filelist->dir, dir, sizeof(filelist->dir)); } void filelist_imgsize(struct FileList* filelist, short w, short h) @@ -853,10 +853,9 @@ static void filelist_read_library(struct FileList* filelist) for(num=0; num<filelist->numfiles; num++, file++) { if(BLO_has_bfile_extension(file->relname)) { char name[FILE_MAX]; - - BLI_strncpy(name, filelist->dir, sizeof(name)); - strcat(name, file->relname); - + + BLI_join_dirfile(name, sizeof(name), filelist->dir, file->relname); + /* prevent current file being used as acceptable dir */ if (BLI_path_cmp(G.main->name, name) != 0) { file->type &= ~S_IFMT; diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 24b2dc9e41c..9df43a85614 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -2069,6 +2069,7 @@ void GRAPH_OT_smooth (wmOperatorType *ot) /* present a special customised popup menu for this, with some filtering */ static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { + wmOperatorType *ot = WM_operatortype_find("GRAPH_OT_fmodifier_add", 1); uiPopupMenu *pup; uiLayout *layout; int i; @@ -2086,7 +2087,7 @@ static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNU continue; /* create operator menu item with relevant properties filled in */ - props_ptr= uiItemFullO(layout, "GRAPH_OT_fmodifier_add", fmi->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO_ptr(layout, ot, fmi->name, ICON_NONE, NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); /* the only thing that gets set from the menu is the type of F-Modifier to add */ RNA_enum_set(&props_ptr, "type", i); /* the following properties are just repeats of existing ones... */ diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 7d475973c09..143173da5bc 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1233,7 +1233,10 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point PropertyRNA *prop; const char *layer_name; char scene_name[MAX_ID_NAME-2]; - + wmOperatorType *ot = WM_operatortype_find("RENDER_OT_render", 1); + + BLI_assert(ot != 0); + uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL); if(!node->id) return; @@ -1249,10 +1252,10 @@ static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, Point scn_ptr = RNA_pointer_get(ptr, "scene"); RNA_string_get(&scn_ptr, "name", scene_name); - WM_operator_properties_create(&op_ptr, "RENDER_OT_render"); + WM_operator_properties_create_ptr(&op_ptr, ot); RNA_string_set(&op_ptr, "layer", layer_name); RNA_string_set(&op_ptr, "scene", scene_name); - uiItemFullO(row, "RENDER_OT_render", "", ICON_RENDER_STILL, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0); + uiItemFullO_ptr(row, ot, "", ICON_RENDER_STILL, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0); } diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index f8abfb6f4c3..0264cf5ad05 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1258,8 +1258,10 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene if ( (SEARCHING_OUTLINER(soops) || (soops->outlinevis==SO_DATABLOCKS && soops->search_string[0]!=0)) && (tselem->flag & TSE_SEARCHMATCH)) { - /* TODO - add search highlight color to theme? */ - glColor4f(0.2f, 0.5f, 0.2f, 0.3f); + char col[4]; + UI_GetThemeColorType4ubv(TH_MATCH, SPACE_OUTLINER, col); + col[3]=100; + glColor4ubv((GLubyte *)col); glRecti(startx, *starty+1, ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1); } @@ -1513,8 +1515,8 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio } /* always draw selection fill before hierarchy */ - UI_GetThemeColor3fv(TH_BACK, col); - glColor3f(col[0]+0.06f, col[1]+0.08f, col[2]+0.10f); + UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col); + glColor3fv(col); starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; outliner_draw_selection(ar, soops, &soops->tree, &starty); diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 0ccbf9127c6..12f4af3637e 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1429,3 +1429,278 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; } + +/* ******************** Parent Drop Operator *********************** */ + +static int parent_drop_exec(bContext *C, wmOperator *op) +{ + Object *par = NULL; + int partype = -1; + char parname[32]; + + partype= RNA_enum_get(op->ptr, "type"); + RNA_string_get(op->ptr, "parent", parname); + par= (Object *)find_id("OB", parname); + + ED_object_parent_set(C, op, par, partype); + + return OPERATOR_FINISHED; +} + +/* Used for drag and drop parenting */ +TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement *te, float *fmval) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeStoreElem *tselem= TREESTORE(te); + + if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { + /* name and first icon */ + if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) { + /* always makes active object */ + if (te->idcode == ID_OB) { + return te; + } + else { + return NULL; + } + } + } + + /* Not it. Let's look at its children. */ + if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) { + for (te = te->subtree.first; te; te = te->next) { + TreeElement *te_valid; + te_valid= outliner_dropzone_parent(C, event, te, fmval); + if (te_valid) return te_valid; + } + } + return NULL; +} + +static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + Object *par= NULL; + Object *ob= NULL; + SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar= CTX_wm_region(C); + Scene *scene= CTX_data_scene(C); + TreeElement *te= NULL; + TreeElement *te_found= NULL; + char childname[MAX_ID_NAME]; + char parname[MAX_ID_NAME]; + int partype= 0; + float fmval[2]; + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); + + /* Find object hovered over */ + for (te= soops->tree.first; te; te= te->next) { + te_found= outliner_dropzone_parent(C, event, te, fmval); + if (te_found) break; + } + + if(te_found) { + RNA_string_set(op->ptr, "parent", te_found->name); + /* Identify parent and child */ + RNA_string_get(op->ptr, "child", childname); + ob= (Object *)find_id("OB", childname); + RNA_string_get(op->ptr, "parent", parname); + par= (Object *)find_id("OB", parname); + + if (ELEM(NULL, ob, par)) { + if (par == NULL) printf("par==NULL\n"); + return OPERATOR_CANCELLED; + } + if (ob == par) { + return OPERATOR_CANCELLED; + } + + /* check dragged object (child) is active */ + if (ob != CTX_data_active_object(C)) + ED_base_object_select(object_in_scene(ob, scene), BA_SELECT); + + if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) { + ED_object_parent_set(C, op, par, partype); + } + else { + /* Menu creation */ + uiPopupMenu *pup= uiPupMenuBegin(C, "Set Parent To", ICON_NONE); + uiLayout *layout= uiPupMenuLayout(pup); + + PointerRNA ptr; + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_OBJECT); + /* Cannot use uiItemEnumO()... have multiple properties to set. */ + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Object", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + /* par becomes parent, make the associated menus */ + if (par->type==OB_ARMATURE) { + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_ARMATURE); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Armature Deform", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_ARMATURE_NAME); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", " With Empty Groups", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_ARMATURE_ENVELOPE); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", " With Envelope Weights", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_ARMATURE_AUTO); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", " With Automatic Weights", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_BONE); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Bone", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + } + else if (par->type==OB_CURVE) { + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_CURVE); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Curve Deform", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_FOLLOW); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Follow Path", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_PATH_CONST); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Path Constraint", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + } + else if (par->type == OB_LATTICE) { + WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); + RNA_string_set(&ptr, "parent", parname); + RNA_string_set(&ptr, "child", childname); + RNA_enum_set(&ptr, "type", PAR_LATTICE); + uiItemFullO(layout, "OUTLINER_OT_parent_drop", "Lattice Deform", 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); + } + + uiPupMenuEnd(C, pup); + + return OPERATOR_CANCELLED; + } + } + else { + return OPERATOR_CANCELLED; + } + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_parent_drop(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Drop to Set Parent"; + ot->description = "Drag to parent in Outliner"; + ot->idname= "OUTLINER_OT_parent_drop"; + + /* api callbacks */ + ot->invoke= parent_drop_invoke; + ot->exec= parent_drop_exec; + + ot->poll= ED_operator_outliner_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_string(ot->srna, "child", "Object", MAX_ID_NAME, "Child", "Child Object"); + RNA_def_string(ot->srna, "parent", "Object", MAX_ID_NAME, "Parent", "Parent Object"); + RNA_def_enum(ot->srna, "type", prop_make_parent_types, 0, "Type", ""); +} + +int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, float *fmval) +{ + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeStoreElem *tselem= TREESTORE(te); + + /* Check for row */ + if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { + /* Ignore drop on scene tree elements */ + if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) { + if ((te->idcode == ID_SCE) && + !ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS)) + { + return 0; + } + // Other codes to ignore? + } + + /* Left or right of: (+), first icon, and name */ + if ((fmval[0] < (te->xs + UI_UNIT_X)) || (fmval[0] > te->xend)) { + return 1; + } + else if (te->idcode != ID_OB) { + return 1; + } + + return 0; // ID_OB, but mouse in undefined dropzone. + } + + /* Not this row. Let's look at its children. */ + if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) { + for (te = te->subtree.first; te; te = te->next) { + if (outliner_dropzone_parent_clear(C, event, te, fmval)) + return 1; + } + } + return 0; +} + +static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +{ + Scene *scene= CTX_data_scene(C); + Object *ob= NULL; + char obname[MAX_ID_NAME]; + + RNA_string_get(op->ptr, "dragged_obj", obname); + ob= (Object *)find_id("OB", obname); + + /* check dragged object (child) is active */ + if (ob != CTX_data_active_object(C)) + ED_base_object_select(object_in_scene(ob, scene), BA_SELECT); + + ED_object_parent_clear(C, RNA_enum_get(op->ptr, "type")); + + return OPERATOR_FINISHED; +} + +void OUTLINER_OT_parent_clear(wmOperatorType *ot) +{ + /* identifiers */ + ot->name= "Drop to Clear Parent"; + ot->description = "Drag to clear parent in outliner"; + ot->idname= "OUTLINER_OT_parent_clear"; + + /* api callbacks */ + ot->invoke= parent_clear_invoke; + + ot->poll= ED_operator_outliner_active; + + /* flags */ + ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; + + /* properties */ + RNA_def_string(ot->srna, "dragged_obj", "Object", MAX_ID_NAME, "Child", "Child Object"); + RNA_def_enum(ot->srna, "type", prop_clear_parent_types, 0, "Type", ""); +} diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index 3b6b4334880..be33fc2e37a 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -188,6 +188,9 @@ void group_toggle_renderability_cb(struct bContext *C, struct Scene *scene, Tree void item_rename_cb(struct bContext *C, struct Scene *scene, TreeElement *te, struct TreeStoreElem *tsep, struct TreeStoreElem *tselem); +TreeElement *outliner_dropzone_parent(struct bContext *C, struct wmEvent *event, struct TreeElement *te, float *fmval); +int outliner_dropzone_parent_clear(struct bContext *C, struct wmEvent *event, struct TreeElement *te, float *fmval); + /* ...................................................... */ void OUTLINER_OT_item_activate(struct wmOperatorType *ot); @@ -215,6 +218,9 @@ void OUTLINER_OT_keyingset_remove_selected(struct wmOperatorType *ot); void OUTLINER_OT_drivers_add_selected(struct wmOperatorType *ot); void OUTLINER_OT_drivers_delete_selected(struct wmOperatorType *ot); +void OUTLINER_OT_parent_drop(struct wmOperatorType *ot); +void OUTLINER_OT_parent_clear(struct wmOperatorType *ot); + /* outliner_tools.c ---------------------------------------------- */ void OUTLINER_OT_operation(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c index 0de26cece93..17434d0f6c9 100644 --- a/source/blender/editors/space_outliner/outliner_ops.c +++ b/source/blender/editors/space_outliner/outliner_ops.c @@ -77,6 +77,9 @@ void outliner_operatortypes(void) WM_operatortype_append(OUTLINER_OT_drivers_add_selected); WM_operatortype_append(OUTLINER_OT_drivers_delete_selected); + + WM_operatortype_append(OUTLINER_OT_parent_drop); + WM_operatortype_append(OUTLINER_OT_parent_clear); } void outliner_keymap(wmKeyConfig *keyconf) diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index 673ddaebc5f..5b20c170362 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -50,6 +50,8 @@ #include "BIF_gl.h" +#include "RNA_access.h" + #include "UI_resources.h" #include "UI_view2d.h" @@ -58,6 +60,7 @@ static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar) { + ListBase *lb; wmKeyMap *keymap; UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); @@ -66,6 +69,88 @@ static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar) keymap= WM_keymap_find(wm->defaultconf, "Outliner", SPACE_OUTLINER, 0); /* don't pass on view2d mask, it's always set with scrollbar space, hide fails */ WM_event_add_keymap_handler_bb(&ar->handlers, keymap, NULL, &ar->winrct); + + /* Add dropboxes */ + lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW); + WM_event_add_dropbox_handler(&ar->handlers, lb); +} + +static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + ARegion *ar= CTX_wm_region(C); + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeElement *te= NULL; + float fmval[2]; + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); + + if(drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if( GS(id->name) == ID_OB ) { + /* Ensure item under cursor is valid drop target */ + /* Find object hovered over */ + for(te= soops->tree.first; te; te= te->next) { + TreeElement *te_valid; + te_valid= outliner_dropzone_parent(C, event, te, fmval); + if(te_valid) return 1; + } + } + } + return 0; +} + +static void outliner_parent_drop_copy(wmDrag *drag, wmDropBox *drop) +{ + ID *id = (ID *)drag->poin; + + RNA_string_set(drop->ptr, "child", id->name+2); +} + +static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, wmEvent *event) +{ + ARegion *ar= CTX_wm_region(C); + SpaceOops *soops= CTX_wm_space_outliner(C); + TreeElement *te= NULL; + float fmval[2]; + + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); + + if(drag->type == WM_DRAG_ID) { + ID *id = (ID *)drag->poin; + if( GS(id->name) == ID_OB ) { + //TODO: Check if no parent? + /* Ensure location under cursor is valid dropzone */ + for(te= soops->tree.first; te; te= te->next) { + if(outliner_dropzone_parent_clear(C, event, te, fmval)) return 1; + } + /* Check if mouse cursor is below the tree */ + te= soops->tree.last; + while(((te->flag & TE_LAZY_CLOSED)==0) && (te->subtree.last)) { + te= te->subtree.last; + } + if(fmval[1] < te->ys) return 1; + } + } + return 0; +} + +static void outliner_parent_clear_copy(wmDrag *drag, wmDropBox *drop) +{ + ID *id = (ID *)drag->poin; + RNA_string_set(drop->ptr, "dragged_obj", id->name+2); + + /* Set to simple parent clear type. Avoid menus for drag and drop if possible. + If desired, user can toggle the different "Clear Parent" types in the operator + menu on tool shelf. */ + RNA_string_set(drop->ptr, "type", 0); +} + +/* region dropbox definition */ +static void outliner_dropboxes(void) +{ + ListBase *lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW); + + WM_dropbox_add(lb, "OUTLINER_OT_parent_drop", outliner_parent_drop_poll, outliner_parent_drop_copy); + WM_dropbox_add(lb, "OUTLINER_OT_parent_clear", outliner_parent_clear_poll, outliner_parent_clear_copy); } static void outliner_main_area_draw(const bContext *C, ARegion *ar) @@ -302,6 +387,7 @@ void ED_spacetype_outliner(void) st->duplicate= outliner_duplicate; st->operatortypes= outliner_operatortypes; st->keymap= outliner_keymap; + st->dropboxes= outliner_dropboxes; /* regions: main window */ art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index b0c2de390a2..7702e952e24 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -96,8 +96,8 @@ static int script_reload_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; #else (void)C; /* unused */ -#endif return OPERATOR_CANCELLED; +#endif } void SCRIPT_OT_reload(wmOperatorType *ot) diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index eab06474546..29583a9356e 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -3187,25 +3187,25 @@ static int text_resolve_conflict_invoke(bContext *C, wmOperator *op, wmEvent *UN /* modified locally and externally, ahhh. offer more possibilites. */ pup= uiPupMenuBegin(C, "File Modified Outside and Inside Blender", ICON_NONE); layout= uiPupMenuLayout(pup); - uiItemEnumO(layout, op->type->idname, "Reload from disk (ignore local changes)", 0, "resolution", RESOLVE_RELOAD); - uiItemEnumO(layout, op->type->idname, "Save to disk (ignore outside changes)", 0, "resolution", RESOLVE_SAVE); - uiItemEnumO(layout, op->type->idname, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL); + uiItemEnumO_ptr(layout, op->type, "Reload from disk (ignore local changes)", 0, "resolution", RESOLVE_RELOAD); + uiItemEnumO_ptr(layout, op->type, "Save to disk (ignore outside changes)", 0, "resolution", RESOLVE_SAVE); + uiItemEnumO_ptr(layout, op->type, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL); uiPupMenuEnd(C, pup); } else { pup= uiPupMenuBegin(C, "File Modified Outside Blender", ICON_NONE); layout= uiPupMenuLayout(pup); - uiItemEnumO(layout, op->type->idname, "Reload from disk", 0, "resolution", RESOLVE_RELOAD); - uiItemEnumO(layout, op->type->idname, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL); - uiItemEnumO(layout, op->type->idname, "Ignore", 0, "resolution", RESOLVE_IGNORE); + uiItemEnumO_ptr(layout, op->type, "Reload from disk", 0, "resolution", RESOLVE_RELOAD); + uiItemEnumO_ptr(layout, op->type, "Make text internal (separate copy)", 0, "resolution", RESOLVE_MAKE_INTERNAL); + uiItemEnumO_ptr(layout, op->type, "Ignore", 0, "resolution", RESOLVE_IGNORE); uiPupMenuEnd(C, pup); } break; case 2: pup= uiPupMenuBegin(C, "File Deleted Outside Blender", ICON_NONE); layout= uiPupMenuLayout(pup); - uiItemEnumO(layout, op->type->idname, "Make text internal", 0, "resolution", RESOLVE_MAKE_INTERNAL); - uiItemEnumO(layout, op->type->idname, "Recreate file", 0, "resolution", RESOLVE_SAVE); + uiItemEnumO_ptr(layout, op->type, "Make text internal", 0, "resolution", RESOLVE_MAKE_INTERNAL); + uiItemEnumO_ptr(layout, op->type, "Recreate file", 0, "resolution", RESOLVE_SAVE); uiPupMenuEnd(C, pup); break; } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 03dc906a84b..f617f673397 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -518,52 +518,54 @@ static void viewops_data_free(bContext *C, wmOperator *op) static const float thres = 0.93f; //cos(20 deg); -#define COS45 0.70710678118654746 +#define COS45 0.7071068 #define SIN45 COS45 -static float snapquats[39][5] = { +#define NUM_SNAP_QUATS 39 + +static const float snapquats[NUM_SNAP_QUATS][5] = { /*{q0, q1, q3, q4, view}*/ - {COS45, -SIN45, 0.0, 0.0, RV3D_VIEW_FRONT}, //front - {0.0, 0.0, -SIN45, -SIN45, RV3D_VIEW_BACK}, //back - {1.0, 0.0, 0.0, 0.0, RV3D_VIEW_TOP}, //top - {0.0, -1.0, 0.0, 0.0, RV3D_VIEW_BOTTOM}, //bottom - {0.5, -0.5, -0.5, -0.5, RV3D_VIEW_RIGHT}, //left - {0.5, -0.5, 0.5, 0.5, RV3D_VIEW_LEFT}, //right + {COS45, -SIN45, 0.0, 0.0, RV3D_VIEW_FRONT}, + {0.0, 0.0, -SIN45, -SIN45, RV3D_VIEW_BACK}, + {1.0, 0.0, 0.0, 0.0, RV3D_VIEW_TOP}, + {0.0, -1.0, 0.0, 0.0, RV3D_VIEW_BOTTOM}, + {0.5, -0.5, -0.5, -0.5, RV3D_VIEW_RIGHT}, + {0.5, -0.5, 0.5, 0.5, RV3D_VIEW_LEFT}, /* some more 45 deg snaps */ - {0.65328145027160645, -0.65328145027160645, 0.27059805393218994, 0.27059805393218994, 0}, - {0.92387950420379639, 0.0, 0.0, 0.38268342614173889, 0}, - {0.0, -0.92387950420379639, 0.38268342614173889, 0.0, 0}, - {0.35355335474014282, -0.85355335474014282, 0.35355338454246521, 0.14644660055637360, 0}, - {0.85355335474014282, -0.35355335474014282, 0.14644660055637360, 0.35355338454246521, 0}, - {0.49999994039535522, -0.49999994039535522, 0.49999997019767761, 0.49999997019767761, 0}, - {0.27059802412986755, -0.65328145027160645, 0.65328145027160645, 0.27059802412986755, 0}, - {0.65328145027160645, -0.27059802412986755, 0.27059802412986755, 0.65328145027160645, 0}, - {0.27059799432754517, -0.27059799432754517, 0.65328139066696167, 0.65328139066696167, 0}, - {0.38268336653709412, 0.0, 0.0, 0.92387944459915161, 0}, - {0.0, -0.38268336653709412, 0.92387944459915161, 0.0, 0}, - {0.14644658565521240, -0.35355335474014282, 0.85355335474014282, 0.35355335474014282, 0}, - {0.35355335474014282, -0.14644658565521240, 0.35355335474014282, 0.85355335474014282, 0}, - {0.0, 0.0, 0.92387944459915161, 0.38268336653709412, 0}, - {-0.0, 0.0, 0.38268336653709412, 0.92387944459915161, 0}, - {-0.27059802412986755, 0.27059802412986755, 0.65328133106231689, 0.65328133106231689, 0}, - {-0.38268339633941650, 0.0, 0.0, 0.92387938499450684, 0}, - {0.0, 0.38268339633941650, 0.92387938499450684, 0.0, 0}, - {-0.14644658565521240, 0.35355338454246521, 0.85355329513549805, 0.35355332493782043, 0}, - {-0.35355338454246521, 0.14644658565521240, 0.35355332493782043, 0.85355329513549805, 0}, - {-0.49999991059303284, 0.49999991059303284, 0.49999985098838806, 0.49999985098838806, 0}, - {-0.27059799432754517, 0.65328145027160645, 0.65328139066696167, 0.27059799432754517, 0}, - {-0.65328145027160645, 0.27059799432754517, 0.27059799432754517, 0.65328139066696167, 0}, - {-0.65328133106231689, 0.65328133106231689, 0.27059793472290039, 0.27059793472290039, 0}, - {-0.92387932538986206, 0.0, 0.0, 0.38268333673477173, 0}, - {0.0, 0.92387932538986206, 0.38268333673477173, 0.0, 0}, - {-0.35355329513549805, 0.85355329513549805, 0.35355329513549805, 0.14644657075405121, 0}, - {-0.85355329513549805, 0.35355329513549805, 0.14644657075405121, 0.35355329513549805, 0}, - {-0.38268330693244934, 0.92387938499450684, 0.0, 0.0, 0}, - {-0.92387938499450684, 0.38268330693244934, 0.0, 0.0, 0}, - {-COS45, 0.0, 0.0, SIN45, 0}, - {COS45, 0.0, 0.0, SIN45, 0}, - {0.0, 0.0, 0.0, 1.0, 0} + { 0.6532815, -0.6532815, 0.2705981, 0.2705981, 0}, + { 0.9238795, 0.0, 0.0, 0.3826834, 0}, + { 0.0, -0.9238795, 0.3826834, 0.0, 0}, + { 0.3535534, -0.8535534, 0.3535534, 0.1464466, 0}, + { 0.8535534, -0.3535534, 0.1464466, 0.3535534, 0}, + { 0.4999999, -0.4999999, 0.5, 0.5, 0}, + { 0.2705980, -0.6532815, 0.6532815, 0.2705980, 0}, + { 0.6532815, -0.2705980, 0.2705980, 0.6532815, 0}, + { 0.2705978, -0.2705980, 0.6532814, 0.6532814, 0}, + { 0.3826834, 0.0, 0.0, 0.9238794, 0}, + { 0.0, -0.3826834, 0.9238794, 0.0, 0}, + { 0.1464466, -0.3535534, 0.8535534, 0.3535534, 0}, + { 0.3535534, -0.1464466, 0.3535534, 0.8535534, 0}, + { 0.0, 0.0, 0.9238794, 0.3826834, 0}, + {-0.0, 0.0, 0.3826834, 0.9238794, 0}, + {-0.2705980, 0.2705980, 0.6532813, 0.6532813, 0}, + {-0.3826834, 0.0, 0.0, 0.9238794, 0}, + { 0.0, 0.3826834, 0.9238794, 0.0, 0}, + {-0.1464466, 0.3535534, 0.8535533, 0.3535533, 0}, + {-0.3535534, 0.1464466, 0.3535533, 0.8535533, 0}, + {-0.4999999, 0.4999999, 0.4999999, 0.4999999, 0}, + {-0.2705980, 0.6532815, 0.6532814, 0.2705980, 0}, + {-0.6532815, 0.2705980, 0.2705980, 0.6532814, 0}, + {-0.6532813, 0.6532813, 0.2705979, 0.2705979, 0}, + {-0.9238793, 0.0, 0.0, 0.3826833, 0}, + { 0.0, 0.9238793, 0.3826833, 0.0, 0}, + {-0.3535533, 0.8535533, 0.3535533, 0.1464466, 0}, + {-0.8535533, 0.3535533, 0.1464466, 0.3535533, 0}, + {-0.3826833, 0.9238794, 0.0, 0.0, 0}, + {-0.9238794, 0.3826833, 0.0, 0.0, 0}, + {-COS45, 0.0, 0.0, SIN45, 0}, + { COS45, 0.0, 0.0, SIN45, 0}, + { 0.0, 0.0, 0.0, 1.0, 0} }; enum { @@ -632,7 +634,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) sub_v3_v3v3(dvec, newvec, vod->trackvec); - si= sqrt(dvec[0]*dvec[0]+ dvec[1]*dvec[1]+ dvec[2]*dvec[2]); + si = len_v3(dvec); si /= (float)(2.0 * TRACKBALLSIZE); cross_v3_v3v3(q1+1, vod->trackvec, newvec); @@ -724,7 +726,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y) mul_qt_v3(viewquat_inv, zaxis); - for (i = 0 ; i < 39; i++){ + for (i = 0 ; i < NUM_SNAP_QUATS; i++){ float view = (int)snapquats[i][4]; float viewquat_inv_test[4]; @@ -961,8 +963,9 @@ void VIEW3D_OT_rotate(wmOperatorType *ot) ot->flag= OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; } -// NDOF utility functions -// (should these functions live in this file?) +/* NDOF utility functions + * (should these functions live in this file?) + */ float ndof_to_axis_angle(struct wmNDOFMotionData* ndof, float axis[3]) { return ndof->dt * normalize_v3_v3(axis, ndof->rvec); @@ -973,7 +976,7 @@ void ndof_to_quat(struct wmNDOFMotionData* ndof, float q[4]) float axis[3]; float angle; - angle= ndof_to_axis_angle(ndof, axis); + angle = ndof_to_axis_angle(ndof, axis); axis_angle_to_quat(q, axis, angle); } @@ -983,69 +986,67 @@ void ndof_to_quat(struct wmNDOFMotionData* ndof, float q[4]) */ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - if (event->type != NDOF_MOTION) { + if (event->type != NDOF_MOTION) return OPERATOR_CANCELLED; - } else { - View3D *v3d= CTX_wm_view3d(C); + View3D *v3d = CTX_wm_view3d(C); RegionView3D* rv3d = CTX_wm_region_view3d(C); wmNDOFMotionData* ndof = (wmNDOFMotionData*) event->customdata; ED_view3d_camera_lock_init(v3d, rv3d); - rv3d->rot_angle = 0.f; // off by default, until changed later this function + rv3d->rot_angle = 0.f; /* off by default, until changed later this function */ if (ndof->progress != P_FINISHING) { const float dt = ndof->dt; - - // tune these until everything feels right + + /* tune these until everything feels right */ const float rot_sensitivity = 1.f; const float zoom_sensitivity = 1.f; const float pan_sensitivity = 1.f; - - // rather have bool, but... - int has_rotation = rv3d->viewlock != RV3D_LOCKED && !is_zero_v3(ndof->rvec); - + + const int has_rotation = rv3d->viewlock != RV3D_LOCKED && !is_zero_v3(ndof->rvec); + float view_inv[4]; invert_qt_qt(view_inv, rv3d->viewquat); - - //#define DEBUG_NDOF_MOTION + + /* #define DEBUG_NDOF_MOTION */ #ifdef DEBUG_NDOF_MOTION printf("ndof: T=(%.2f,%.2f,%.2f) R=(%.2f,%.2f,%.2f) dt=%.3f delivered to 3D view\n", ndof->tx, ndof->ty, ndof->tz, ndof->rx, ndof->ry, ndof->rz, ndof->dt); #endif - - if (ndof->tvec[2]) { - // Zoom! - // velocity should be proportional to the linear velocity attained by rotational motion of same strength - // [got that?] - // proportional to arclength = radius * angle - - float zoom_distance = zoom_sensitivity * rv3d->dist * dt * ndof->tvec[2]; + + if (ndof->tz) { + /* Zoom! + * velocity should be proportional to the linear velocity attained by rotational motion of same strength + * [got that?] + * proportional to arclength = radius * angle + */ + float zoom_distance = zoom_sensitivity * rv3d->dist * dt * ndof->tz; if (U.ndof_flag & NDOF_ZOOM_INVERT) zoom_distance = -zoom_distance; rv3d->dist += zoom_distance; } - + if (rv3d->viewlock == RV3D_LOCKED) { /* rotation not allowed -- explore panning options instead */ - float pan_vec[3] = {ndof->tvec[0], ndof->tvec[1], 0.0f}; + float pan_vec[3] = {ndof->tx, ndof->ty, 0.0f}; mul_v3_fl(pan_vec, pan_sensitivity * rv3d->dist * dt); - + /* transform motion from view to world coordinates */ invert_qt_qt(view_inv, rv3d->viewquat); mul_qt_v3(view_inv, pan_vec); - + /* move center of view opposite of hand motion (this is camera mode, not object mode) */ sub_v3_v3(rv3d->ofs, pan_vec); } - + if (has_rotation) { - + rv3d->view = RV3D_VIEW_USER; - + if (U.flag & USER_TRACKBALL) { float rot[4]; float axis[3]; @@ -1060,44 +1061,46 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) axis[1] = -axis[1]; - // transform rotation axis from view to world coordinates + /* transform rotation axis from view to world coordinates */ mul_qt_v3(view_inv, axis); - - // update the onscreen doo-dad + + /* update the onscreen doo-dad */ rv3d->rot_angle = angle; copy_v3_v3(rv3d->rot_axis, axis); - + axis_angle_to_quat(rot, axis, angle); - // apply rotation + /* apply rotation */ mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); + } else { + /* turntable view code by John Aughey, adapted for 3D mouse by [mce] */ float angle, rot[4]; float xvec[3] = {1,0,0}; - + /* Determine the direction of the x vector (for rotating up and down) */ mul_qt_v3(view_inv, xvec); - + /* Perform the up/down rotation */ - angle = rot_sensitivity * dt * ndof->rvec[0]; + angle = rot_sensitivity * dt * ndof->rx; if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) angle = -angle; rot[0] = cos(angle); mul_v3_v3fl(rot+1, xvec, sin(angle)); mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot); - + /* Perform the orbital rotation */ - angle = rot_sensitivity * dt * ndof->rvec[1]; + angle = rot_sensitivity * dt * ndof->ry; if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) angle = -angle; - - // update the onscreen doo-dad + + /* update the onscreen doo-dad */ rv3d->rot_angle = angle; rv3d->rot_axis[0] = 0; rv3d->rot_axis[1] = 0; rv3d->rot_axis[2] = 1; - + rot[0] = cos(angle); rot[1] = rot[2] = 0.0; rot[3] = sin(angle); @@ -1134,9 +1137,8 @@ void VIEW3D_OT_ndof_orbit(struct wmOperatorType *ot) */ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - if (event->type != NDOF_MOTION) { + if (event->type != NDOF_MOTION) return OPERATOR_CANCELLED; - } else { View3D *v3d= CTX_wm_view3d(C); RegionView3D* rv3d = CTX_wm_region_view3d(C); @@ -1144,13 +1146,13 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) ED_view3d_camera_lock_init(v3d, rv3d); - rv3d->rot_angle = 0.f; // we're panning here! so erase any leftover rotation from other operators + rv3d->rot_angle = 0.f; /* we're panning here! so erase any leftover rotation from other operators */ if (ndof->progress != P_FINISHING) { const float dt = ndof->dt; float view_inv[4]; -#if 0 // ------------------------------------------- zoom with Z - // tune these until everything feels right +#if 0 /* ------------------------------------------- zoom with Z */ + /* tune these until everything feels right */ const float zoom_sensitivity = 1.f; const float pan_sensitivity = 1.f; @@ -1158,18 +1160,18 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) ndof->tx, ndof->ty, 0 }; - // "zoom in" or "translate"? depends on zoom mode in user settings? + /* "zoom in" or "translate"? depends on zoom mode in user settings? */ if (ndof->tz) { float zoom_distance = zoom_sensitivity * rv3d->dist * dt * ndof->tz; rv3d->dist += zoom_distance; } - + mul_v3_fl(pan_vec, pan_sensitivity * rv3d->dist * dt); -#else // ------------------------------------------------------- dolly with Z - float speed = 10.f; // blender units per second - // ^^ this is ok for default cube scene, but should scale with.. something +#else /* ------------------------------------------------------- dolly with Z */ + float speed = 10.f; /* blender units per second */ + /* ^^ this is ok for default cube scene, but should scale with.. something */ - // tune these until everything feels right + /* tune these until everything feels right */ const float forward_sensitivity = 1.f; const float vertical_sensitivity = 0.4f; const float lateral_sensitivity = 0.6f; diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index b46ca538896..7f301123ab8 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -58,6 +58,7 @@ #include "UI_resources.h" #include "WM_types.h" +#include "WM_api.h" #include "RNA_access.h" @@ -165,12 +166,13 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha uiPopupMenu *pup; uiLayout *layout; char line[FILE_MAX + 100]; + wmOperatorType *ot = WM_operatortype_find(opname, 1); pup= uiPupMenuBegin(C, "Unpack file", ICON_NONE); layout= uiPupMenuLayout(pup); strcpy(line, "Remove Pack"); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_REMOVE); RNA_string_set(&props_ptr, "id", id_name); @@ -184,29 +186,29 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha switch(checkPackedFile(local_name, pf)) { case PF_NOFILE: BLI_snprintf(line, sizeof(line), "Create %s", local_name); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_EQUAL: BLI_snprintf(line, sizeof(line), "Use %s (identical)", local_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_DIFFERS: BLI_snprintf(line, sizeof(line), "Use %s (differs)", local_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); BLI_snprintf(line, sizeof(line), "Overwrite %s", local_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_LOCAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); break; @@ -217,28 +219,28 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha switch(checkPackedFile(abs_name, pf)) { case PF_NOFILE: BLI_snprintf(line, sizeof(line), "Create %s", abs_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_EQUAL: BLI_snprintf(line, sizeof(line), "Use %s (identical)", abs_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_DIFFERS: BLI_snprintf(line, sizeof(line), "Use %s (differs)", abs_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); BLI_snprintf(line, sizeof(line), "Overwrite %s", abs_name); - //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL); - props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); + //uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); + props_ptr= uiItemFullO_ptr(layout, ot, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 34602046448..70c94ab0a54 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -916,12 +916,13 @@ static void stitch_select_uv(UvElement *element, StitchState *stitch_state, int } } -static void stitch_calculate_edge_normal(EditMesh *em, UvEdge *edge, float *normal){ +static void stitch_calculate_edge_normal(EditMesh *em, UvEdge *edge, float *normal) +{ UvElement *element = edge->element; EditFace *efa = element->face; MTFace *mt = CustomData_em_get(&em->fdata, efa->data, CD_MTFACE); int nverts = efa->v4?4 : 3; - int index = index = (element->tfindex + 2)%nverts; + int index = (element->tfindex + 2)%nverts; float tangent[2], internal[2]; sub_v2_v2v2(tangent, mt->uv[(element->tfindex + 1)%nverts], mt->uv[element->tfindex]); diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index adf6f4a143b..cb5d6721566 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -50,7 +50,7 @@ struct ImMetaData; #define IB_MIPMAP_LEVELS 20 -#define IB_FILENAME_SIZE 1023 +#define IB_FILENAME_SIZE 1024 /** * \ingroup imbuf diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h index b627baf99bd..a9f020c94e8 100644 --- a/source/blender/imbuf/intern/IMB_anim.h +++ b/source/blender/imbuf/intern/IMB_anim.h @@ -136,9 +136,9 @@ struct anim { int x, y; /* voor op nummer */ - char name[256]; + char name[1024]; /* voor sequence */ - char first[256]; + char first[1024]; /* movie */ void *movie; @@ -189,7 +189,7 @@ struct anim { struct redcode_handle * redcodeCtx; #endif - char index_dir[256]; + char index_dir[768]; int proxies_tried; int indices_tried; diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h index 62608cbbd79..f9d90208078 100644 --- a/source/blender/imbuf/intern/IMB_indexer.h +++ b/source/blender/imbuf/intern/IMB_indexer.h @@ -62,7 +62,7 @@ typedef struct anim_index_entry { } anim_index_entry; struct anim_index { - char name[256]; + char name[1024]; int num_entries; struct anim_index_entry * entries; diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index bfd3bb4b0bf..cb7b8d15d52 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -128,8 +128,8 @@ typedef struct Library { ID id; ID *idblock; struct FileData *filedata; - char name[240]; /* path name used for reading, can be relative and edited in the outliner */ - char filepath[240]; /* absolute filepath, this is only for convenience, + char name[1024]; /* path name used for reading, can be relative and edited in the outliner */ + char filepath[1024]; /* absolute filepath, this is only for convenience, * 'name' is the real path used on file read but in * some cases its useful to access the absolute one, * This is set on file read. diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index f21c589d825..690c3c95964 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -59,7 +59,7 @@ typedef struct Brush { struct ImBuf *icon_imbuf; PreviewImage *preview; - char icon_filepath[240]; /* 240 = FILE_MAX */ + char icon_filepath[1024]; /* 1024 = FILE_MAX */ float normal_weight; diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 33b4107abcb..4855f5eb3a1 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -55,7 +55,7 @@ typedef struct CustomDataLayer { #define MAX_CUSTOMDATA_LAYER_NAME 64 typedef struct CustomDataExternal { - char filename[240]; /* FILE_MAX */ + char filename[1024]; /* FILE_MAX */ } CustomDataExternal; /** structure which stores custom element data associated with mesh elements diff --git a/source/blender/makesdna/DNA_dynamicpaint_types.h b/source/blender/makesdna/DNA_dynamicpaint_types.h index 6dab70c6dee..aff4607da51 100644 --- a/source/blender/makesdna/DNA_dynamicpaint_types.h +++ b/source/blender/makesdna/DNA_dynamicpaint_types.h @@ -128,7 +128,7 @@ typedef struct DynamicPaintSurface { float wave_damping, wave_speed, wave_timescale, wave_spring; char uvlayer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ - char image_output_path[240]; /* 240 = FILE_MAX */ + char image_output_path[1024]; /* 1024 = FILE_MAX */ char output_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ char output_name2[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ /* some surfaces have 2 outputs */ diff --git a/source/blender/makesdna/DNA_fileglobal_types.h b/source/blender/makesdna/DNA_fileglobal_types.h index 31ad628d630..ed9f3cec987 100644 --- a/source/blender/makesdna/DNA_fileglobal_types.h +++ b/source/blender/makesdna/DNA_fileglobal_types.h @@ -51,7 +51,7 @@ typedef struct FileGlobal { int revision; /* svn revision from buildinfo */ int pad; /* file path where this was saved, for recover */ - char filename[240]; /* 240 = FILE_MAX */ + char filename[1024]; /* 1024 = FILE_MAX */ } FileGlobal; diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index efe6c4d2586..8f6cc5bf354 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -69,7 +69,7 @@ typedef struct ImageUser { typedef struct Image { ID id; - char name[240]; /* file path, 240 = FILE_MAX */ + char name[1024]; /* file path, 1024 = FILE_MAX */ ListBase ibufs; /* not written in file */ struct GPUTexture *gputexture; /* not written in file */ diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index d398fcef3ad..f3b14dc5744 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -777,7 +777,7 @@ typedef struct OceanModifierData { int bakestart; int bakeend; - char cachepath[240]; // FILE_MAX + char cachepath[1024]; // FILE_MAX char foamlayername[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ char cached; char geometry_mode; diff --git a/source/blender/makesdna/DNA_movieclip_types.h b/source/blender/makesdna/DNA_movieclip_types.h index c08a5e95e92..1a56c273922 100644 --- a/source/blender/makesdna/DNA_movieclip_types.h +++ b/source/blender/makesdna/DNA_movieclip_types.h @@ -51,7 +51,7 @@ typedef struct MovieClipUser { } MovieClipUser; typedef struct MovieClipProxy { - char dir[160]; /* custom directory for index and proxy files (defaults to BL_proxy) */ + char dir[768]; /* custom directory for index and proxy files (defaults to BL_proxy) */ short tc; /* time code in use */ short quality; /* proxy build quality */ @@ -64,7 +64,7 @@ typedef struct MovieClipProxy { typedef struct MovieClip { ID id; - char name[240]; /* file path, 240 = FILE_MAX */ + char name[1024]; /* file path, 1024 = FILE_MAX */ int source; /* sequence or movie */ int lastframe; /* last accessed frame number */ diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index fe4f6905f42..33ac75912fa 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -85,19 +85,21 @@ typedef struct bNodeSocket { /* execution data */ short stack_index; /* local stack index */ - short stack_type; /* deprecated, kept for forward compatibility */ + /* XXX deprecated, kept for forward compatibility */ + short stack_type DNA_DEPRECATED; int pad3; void *cache; /* cached data from execution */ /* internal data to retrieve relations and groups */ int own_index; /* group socket identifiers, to find matching pairs after reading files */ - int to_index DNA_DEPRECATED; /* XXX deprecated, only used for restoring old group node links */ + /* XXX deprecated, only used for restoring old group node links */ + int to_index DNA_DEPRECATED; struct bNodeSocket *groupsock; struct bNodeLink *link; /* a link pointer, set in ntreeUpdateTree */ - /* DEPRECATED only needed for do_versions */ - bNodeStack ns; /* custom data for inputs, only UI writes in this */ + /* XXX deprecated, socket input values are stored in default_value now. kept for forward compatibility */ + bNodeStack ns DNA_DEPRECATED; /* custom data for inputs, only UI writes in this */ } bNodeSocket; /* sock->type */ @@ -347,7 +349,7 @@ typedef struct NodeHueSat { } NodeHueSat; typedef struct NodeImageFile { - char name[256]; + char name[1024]; /* 1024 = FILE_MAX */ struct ImageFormatData im_format; int sfra, efra; } NodeImageFile; diff --git a/source/blender/makesdna/DNA_object_fluidsim.h b/source/blender/makesdna/DNA_object_fluidsim.h index 022dc53848f..90e6e97bc15 100644 --- a/source/blender/makesdna/DNA_object_fluidsim.h +++ b/source/blender/makesdna/DNA_object_fluidsim.h @@ -89,8 +89,8 @@ typedef struct FluidsimSettings { struct Mesh *meshBB; /* store output path, and file prefix for baked fluid surface */ - /* strlens; 80= FILE_MAXFILE, 160= FILE_MAXDIR */ - char surfdataPath[240]; + /* strlens; 256= FILE_MAXFILE, 768= FILE_MAXDIR */ + char surfdataPath[1024]; /* store start coords of axis aligned bounding box together with size */ /* values are inited during derived mesh display */ @@ -140,8 +140,8 @@ typedef struct FluidsimSettings { int lastgoodframe; - int pad; - + /* Simulation/flow rate control (i.e. old "Fac-Time") */ + float animRate; } FluidsimSettings; /* ob->fluidsimSettings defines */ diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index 41f79546b15..1707c0d3929 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -195,7 +195,7 @@ typedef struct PointCache { char name[64]; char prev_name[64]; char info[64]; - char path[240]; /* file path, 240 = FILE_MAX */ + char path[1024]; /* file path, 1024 = FILE_MAX */ char *cached_frames; /* array of length endframe-startframe+1 with flags to indicate cached frames */ /* can be later used for other per frame flags too if needed */ struct ListBase mem_cache; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 38fc513521b..6b13951348a 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -471,14 +471,14 @@ typedef struct RenderData { float bake_maxdist, bake_biasdist, bake_pad; /* path to render output */ - char pic[240]; /* 240 = FILE_MAX */ + char pic[1024]; /* 1024 = FILE_MAX */ /* stamps flags. */ int stamp; short stamp_font_id, pad3; /* select one of blenders bitmap fonts */ /* stamp info user data. */ - char stamp_udata[160]; + char stamp_udata[768]; /* foreground/background color. */ float fg_stamp[4]; diff --git a/source/blender/makesdna/DNA_sequence_types.h b/source/blender/makesdna/DNA_sequence_types.h index fa501de8d6d..20399e541d7 100644 --- a/source/blender/makesdna/DNA_sequence_types.h +++ b/source/blender/makesdna/DNA_sequence_types.h @@ -41,10 +41,10 @@ struct Ipo; struct Scene; struct bSound; -/* strlens; 80= FILE_MAXFILE, 160= FILE_MAXDIR */ +/* strlens; 256= FILE_MAXFILE, 768= FILE_MAXDIR */ typedef struct StripElem { - char name[80]; + char name[256]; int orig_width, orig_height; } StripElem; @@ -71,10 +71,10 @@ typedef struct StripColorBalance { } StripColorBalance; typedef struct StripProxy { - char dir[160]; // custom directory for index and proxy files + char dir[768]; // custom directory for index and proxy files // (defaults to BL_proxy) - char file[80]; // custom file + char file[256]; // custom file struct anim *anim; // custom proxy anim file short tc; // time code in use @@ -91,7 +91,7 @@ typedef struct Strip { int rt, len, us, done; int startstill, endstill; StripElem *stripdata; - char dir[160]; + char dir[768]; StripProxy *proxy; StripCrop *crop; StripTransform *transform; @@ -100,7 +100,7 @@ typedef struct Strip { typedef struct PluginSeq { - char name[256]; + char name[1024]; /* 1024 = FILE_MAX */ void *handle; char *pname; @@ -191,8 +191,8 @@ typedef struct Editing { /* Context vars, used to be static */ Sequence *act_seq; - char act_imagedir[256]; - char act_sounddir[256]; + char act_imagedir[1024]; /* 1024 = FILE_MAX */ + char act_sounddir[1024]; /* 1024 = FILE_MAX */ int over_ofs, over_cfra; int over_flag, pad; @@ -353,7 +353,7 @@ typedef struct SpeedControlVars { */ -#define SEQ_HAS_PATH(_seq) (ELEM5((_seq)->type, SEQ_MOVIE, SEQ_IMAGE, SEQ_SOUND, SEQ_RAM_SOUND, SEQ_HD_SOUND)) +#define SEQ_HAS_PATH(_seq) (ELEM4((_seq)->type, SEQ_MOVIE, SEQ_IMAGE, SEQ_RAM_SOUND, SEQ_HD_SOUND)) #endif diff --git a/source/blender/makesdna/DNA_sound_types.h b/source/blender/makesdna/DNA_sound_types.h index 82185c811a1..1dab9effa9e 100644 --- a/source/blender/makesdna/DNA_sound_types.h +++ b/source/blender/makesdna/DNA_sound_types.h @@ -49,7 +49,7 @@ typedef struct bSound { /** * The path to the sound file. */ - char name[240]; /* 240 = FILE_MAX */ + char name[1024]; /* 1024 = FILE_MAX */ /** * The packed file. diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index aa7a84c577b..8f986a5f7cc 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -174,10 +174,11 @@ typedef struct SpaceSeq { typedef struct FileSelectParams { char title[32]; /* title, also used for the text of the execute button */ - char dir[240]; /* directory */ - char file[80]; /* file */ - char renamefile[80]; - char renameedit[80]; /* annoying but the first is only used for initialization */ + char dir[1056]; /* directory, FILE_MAX_LIBEXTRA, 1024 + 32, this is for extreme case when 1023 length path + * needs to be linked in, where foo.blend/Armature need adding */ + char file[256]; /* file */ + char renamefile[256]; + char renameedit[256]; /* annoying but the first is only used for initialization */ char filter_glob[64]; /* list of filetypes to filter */ @@ -343,8 +344,9 @@ typedef struct Script { void *py_globaldict; int flags, lastspace; - char scriptname[256]; /* store the script file here so we can re-run it on loading blender, if "Enable Scripts" is on */ - char scriptarg[256]; + /* store the script file here so we can re-run it on loading blender, if "Enable Scripts" is on */ + char scriptname[1024]; /* 1024 = FILE_MAX */ + char scriptarg[256]; /* 1024 = FILE_MAX */ } Script; #define SCRIPT_SET_NULL(_script) _script->py_draw = _script->py_event = _script->py_button = _script->py_browsercallback = _script->py_globaldict = NULL; _script->flags = 0; @@ -622,9 +624,11 @@ enum FileSortTypeE { /* these values need to be hardcoded in structs, dna does not recognize defines */ /* also defined in BKE */ -#define FILE_MAXDIR 160 -#define FILE_MAXFILE 80 -#define FILE_MAX 240 +#define FILE_MAXDIR 768 +#define FILE_MAXFILE 256 +#define FILE_MAX 1024 + +#define FILE_MAX_LIBEXTRA (FILE_MAX + 32) /* filesel types */ #define FILE_UNIX 8 diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index 1cc84669e3b..de844fd2d7f 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -105,7 +105,7 @@ typedef unsigned short dna_ushort_fix; #endif typedef struct PluginTex { - char name[160]; + char name[1024]; void *handle; char *pname; @@ -200,7 +200,7 @@ typedef struct VoxelData { struct Object *object; /* for rendering smoke sims */ float int_multiplier; int still_frame; - char source_path[240]; /* 240 = FILE_MAX */ + char source_path[1024]; /* 1024 = FILE_MAX */ /* temporary data */ float *dataset; diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 44bf11795c1..405e1e33720 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -60,7 +60,7 @@ struct ColorBand; /* first font is the default (index 0), others optional */ typedef struct uiFont { struct uiFont *next, *prev; - char filename[256]; + char filename[1024];/* 1024 = FILE_MAX */ short blf_id; /* from blfont lib */ short uifont_id; /* own id */ short r_to_l; /* fonts that read from left to right */ @@ -158,7 +158,7 @@ typedef struct ThemeUI { uiPanelColors panel; - char iconfile[80]; // FILE_MAXFILE length + char iconfile[256]; // FILE_MAXFILE length float icon_alpha; float pad; @@ -258,6 +258,9 @@ typedef struct ThemeSpace { char preview_stitch_stitchable[4]; char preview_stitch_unstitchable[4]; char preview_stitch_active[4]; + + char match[4]; /* outliner - filter match */ + char selected_highlight[4]; /* outliner - selected item */ } ThemeSpace; @@ -323,16 +326,16 @@ typedef struct SolidLight { typedef struct UserDef { int flag, dupflag; int savetime; - char tempdir[160]; /* FILE_MAXDIR length */ - char fontdir[160]; - char renderdir[240]; /* FILE_MAX length */ - char textudir[160]; - char plugtexdir[160]; - char plugseqdir[160]; - char pythondir[160]; - char sounddir[160]; - char image_editor[240]; /* 240 = FILE_MAX */ - char anim_player[240]; /* 240 = FILE_MAX */ + char tempdir[768]; /* FILE_MAXDIR length */ + char fontdir[768]; + char renderdir[1024]; /* FILE_MAX length */ + char textudir[768]; + char plugtexdir[768]; + char plugseqdir[768]; + char pythondir[768]; + char sounddir[768]; + char image_editor[1024]; /* 1024 = FILE_MAX */ + char anim_player[1024]; /* 1024 = FILE_MAX */ int anim_player_preset; short v2d_min_gridsize; /* minimum spacing between gridlines in View2D grids */ @@ -401,8 +404,6 @@ typedef struct UserDef { float ndof_sensitivity; /* overall sensitivity of 3D mouse */ int ndof_flag; /* flags for 3D mouse */ - char versemaster[160]; - char verseuser[160]; float glalphaclip; short autokey_mode; /* autokeying mode */ diff --git a/source/blender/makesdna/DNA_vfont_types.h b/source/blender/makesdna/DNA_vfont_types.h index 7132751848d..d6168af6028 100644 --- a/source/blender/makesdna/DNA_vfont_types.h +++ b/source/blender/makesdna/DNA_vfont_types.h @@ -42,7 +42,7 @@ struct VFontData; typedef struct VFont { ID id; - char name[256]; + char name[1024]; /* 1024 = FILE_MAX */ struct VFontData *data; struct PackedFile * packedfile; diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index f853e7b8dd9..99a84fc8b39 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -340,6 +340,11 @@ static void rna_def_fluidsim_domain(BlenderRNA *brna) RNA_def_property_range(prop, 0.001, 10); RNA_def_property_ui_text(prop, "Real World Size", "Size of the simulation domain in metres"); + prop= RNA_def_property(srna, "simulation_rate", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "animRate"); + RNA_def_property_range(prop, 0.0, 100.0); + RNA_def_property_ui_text(prop, "Simulation Speed", "Fluid motion rate (0 = stationary, 1 = normal speed)"); + prop= RNA_def_property(srna, "viscosity_preset", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "viscosityMode"); RNA_def_property_enum_items(prop, viscosity_items); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index a04ddec2098..989202f785c 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -3071,7 +3071,7 @@ static void rna_def_node_socket_subtype(BlenderRNA *brna, int type, int subtype, }; #undef SUBTYPE - #define SUBTYPE(socktype, stypename, id, idname) if (subtype==PROP_##id) propsubtype = PROP_##id; + #define SUBTYPE(socktype, stypename, id, idname) if (subtype == (PROP_##id)) propsubtype = PROP_##id; NODE_DEFINE_SUBTYPES #undef SUBTYPE diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index a54a61b8d09..56167fe0dc7 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -3959,7 +3959,7 @@ void RNA_def_scene(BlenderRNA *brna) prop= RNA_def_property(srna, "world", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "World", "World used for rendering the scene"); - RNA_def_property_update(prop, NC_SCENE|ND_WORLD, NULL); + RNA_def_property_update(prop, NC_SCENE|ND_WORLD, "rna_Scene_glsl_update"); prop= RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH); RNA_def_property_float_sdna(prop, NULL, "cursor"); diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 24486c227b7..dc4f3449c1b 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -1312,6 +1312,7 @@ static void rna_def_userdef_theme_space_file(BlenderRNA *brna) static void rna_def_userdef_theme_space_outliner(BlenderRNA *brna) { StructRNA *srna; + PropertyRNA *prop; /* space_outliner */ @@ -1321,6 +1322,16 @@ static void rna_def_userdef_theme_space_outliner(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Theme Outliner", "Theme settings for the Outliner"); rna_def_userdef_theme_spaces_main(srna); + + prop= RNA_def_property(srna, "match", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Filter Match", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop= RNA_def_property(srna, "selected_highlight", PROP_FLOAT, PROP_COLOR_GAMMA); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Selected Highlight", ""); + RNA_def_property_update(prop, 0, "rna_userdef_update"); } static void rna_def_userdef_theme_space_userpref(BlenderRNA *brna) diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index b5439d4103b..6cf2b07142d 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -95,6 +95,7 @@ void fluidsim_init(FluidsimModifierData *fluidmd) fss->animStart = 0.0; fss->animEnd = 4.0; + fss->animRate = 1.0; fss->gstar = 0.005; // used as normgstar fss->maxRefine = -1; // maxRefine is set according to resolutionxyz during bake diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index 473692f123d..e3eec5243fb 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -204,6 +204,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der return dm; dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); + /* If no vertices were ever added to an object's vgroup, dvert might be NULL. */ + if(!dvert) + /* If this modifier is not allowed to add vertices, just return. */ + if(!do_add) + return dm; + /* Else, add a valid data layer! */ + dvert = CustomData_add_layer_named(&dm->vertData, CD_MDEFORMVERT, CD_CALLOC, + NULL, numVerts, wmd->defgrp_name); + /* Ultimate security check. */ + if(!dvert) + return dm; /* Get org weights, assuming 0.0 for vertices not in given vgroup. */ org_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, org_w"); diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 316080ba4a7..f549dc7b789 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -251,6 +251,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der } dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); + /* If no vertices were ever added to an object's vgroup, dvert might be NULL. */ + if(!dvert) + /* If not affecting all vertices, just return. */ + if(wmd->mix_set != MOD_WVG_SET_ALL) + return dm; + /* Else, add a valid data layer! */ + dvert = CustomData_add_layer_named(&dm->vertData, CD_MDEFORMVERT, CD_CALLOC, + NULL, numVerts, wmd->defgrp_name_a); + /* Ultimate security check. */ + if(!dvert) + return dm; /* Find out which vertices to work on. */ tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGMix Modifier, tidx"); diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 22128784dda..bdcd4083a3a 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -378,6 +378,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der return dm; dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); + /* If no vertices were ever added to an object's vgroup, dvert might be NULL. + * As this modifier never add vertices to vgroup, just return. */ + if(!dvert) + return dm; /* Find out which vertices to work on (all vertices in vgroup), and get their relevant weight. */ diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c index 8f468a574a1..f03aff8fb92 100644 --- a/source/blender/nodes/intern/node_socket.c +++ b/source/blender/nodes/intern/node_socket.c @@ -190,7 +190,8 @@ void *node_socket_make_default_value(int type) void node_socket_free_default_value(int UNUSED(type), void *default_value) { /* XXX can just free the pointee for all current socket types. */ - MEM_freeN(default_value); + if (default_value) + MEM_freeN(default_value); } void node_socket_init_default_value(int type, void *default_value) @@ -359,8 +360,8 @@ void node_socket_convert_default_value(int to_type, void *to_default_value, int case SOCK_RGBA: torgba->value[0] = torgba->value[1] = torgba->value[2] = torgba->value[3] = fromfloat->value; break; - break; } + break; case SOCK_INT: switch (to_type) { case SOCK_FLOAT: diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index d94ba8b9441..414ebe47e97 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -374,7 +374,12 @@ static int bpy_struct_id_used(StructRNA *srna, char *identifier) * but being abused from C so we can pass the srna along. * This isnt incorrect since its a python object - but be careful */ PyDoc_STRVAR(BPy_BoolProperty_doc, -".. function:: BoolProperty(name=\"\", description=\"\", default=False, options={'ANIMATABLE'}, subtype='NONE', update=None)\n" +".. function:: BoolProperty(name=\"\", " + "description=\"\", " + "default=False, " + "options={'ANIMATABLE'}, " + "subtype='NONE', " + "update=None)\n" "\n" " Returns a new boolean property definition.\n" "\n" @@ -438,7 +443,13 @@ static PyObject *BPy_BoolProperty(PyObject *self, PyObject *args, PyObject *kw) } PyDoc_STRVAR(BPy_BoolVectorProperty_doc, -".. function:: BoolVectorProperty(name=\"\", description=\"\", default=(False, False, False), options={'ANIMATABLE'}, subtype='NONE', size=3, update=None)\n" +".. function:: BoolVectorProperty(name=\"\", " + "description=\"\", " + "default=(False, False, False), " + "options={'ANIMATABLE'}, " + "subtype='NONE', " + "size=3, " + "update=None)\n" "\n" " Returns a new vector boolean property definition.\n" "\n" @@ -448,7 +459,9 @@ BPY_PROPDEF_DESC_DOC " :type default: sequence\n" " :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE'].\n" " :type options: set\n" -" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', 'COLOR_GAMMA', 'LAYER', 'NONE'].\n" +" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', " + "'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', " + "'XYZ', 'COLOR_GAMMA', 'LAYER', 'NONE'].\n" " :type subtype: string\n" " :arg size: Vector dimensions in [1, and " STRINGIFY(PYRNA_STACK_ARRAY) "].\n" " :type size: int\n" @@ -520,7 +533,15 @@ static PyObject *BPy_BoolVectorProperty(PyObject *self, PyObject *args, PyObject } PyDoc_STRVAR(BPy_IntProperty_doc, -".. function:: IntProperty(name=\"\", description=\"\", default=0, min=-sys.maxint, max=sys.maxint, soft_min=-sys.maxint, soft_max=sys.maxint, step=1, options={'ANIMATABLE'}, subtype='NONE', update=None)\n" +".. function:: IntProperty(name=\"\", " + "description=\"\", " + "default=0, " + "min=-sys.maxint, max=sys.maxint, " + "soft_min=-sys.maxint, soft_max=sys.maxint, " + "step=1, " + "options={'ANIMATABLE'}, " + "subtype='NONE', " + "update=None)\n" "\n" " Returns a new int property definition.\n" "\n" @@ -540,7 +561,8 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) if (srna) { static const char *kwlist[] = {"attr", "name", "description", "default", - "min", "max", "soft_min", "soft_max", "step", "options", "subtype", "update", NULL}; + "min", "max", "soft_min", "soft_max", + "step", "options", "subtype", "update", NULL}; const char *id = NULL, *name = NULL, *description = ""; int id_len; int min = INT_MIN, max = INT_MAX, soft_min = INT_MIN, soft_max = INT_MAX, step = 1, def = 0; @@ -586,7 +608,15 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) } PyDoc_STRVAR(BPy_IntVectorProperty_doc, -".. function:: IntVectorProperty(name=\"\", description=\"\", default=(0, 0, 0), min=-sys.maxint, max=sys.maxint, soft_min=-sys.maxint, soft_max=sys.maxint, options={'ANIMATABLE'}, subtype='NONE', size=3, update=None)\n" +".. function:: IntVectorProperty(name=\"\", " + "description=\"\", " + "default=(0, 0, 0), min=-sys.maxint, max=sys.maxint, " + "soft_min=-sys.maxint, " + "soft_max=sys.maxint, " + "options={'ANIMATABLE'}, " + "subtype='NONE', " + "size=3, " + "update=None)\n" "\n" " Returns a new vector int property definition.\n" "\n" @@ -596,7 +626,9 @@ BPY_PROPDEF_DESC_DOC " :type default: sequence\n" " :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE'].\n" " :type options: set\n" -" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', 'COLOR_GAMMA', 'LAYER', 'NONE'].\n" +" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', " + "'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', " + "'XYZ', 'COLOR_GAMMA', 'LAYER', 'NONE'].\n" " :type subtype: string\n" " :arg size: Vector dimensions in [1, and " STRINGIFY(PYRNA_STACK_ARRAY) "].\n" " :type size: int\n" @@ -673,7 +705,17 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject PyDoc_STRVAR(BPy_FloatProperty_doc, -".. function:: FloatProperty(name=\"\", description=\"\", default=0.0, min=sys.float_info.min, max=sys.float_info.max, soft_min=sys.float_info.min, soft_max=sys.float_info.max, step=3, precision=2, options={'ANIMATABLE'}, subtype='NONE', unit='NONE', update=None)\n" +".. function:: FloatProperty(name=\"\", " + "description=\"\", " + "default=0.0, " + "min=sys.float_info.min, max=sys.float_info.max, " + "soft_min=sys.float_info.min, soft_max=sys.float_info.max, " + "step=3, " + "precision=2, " + "options={'ANIMATABLE'}, " + "subtype='NONE', " + "unit='NONE', " + "update=None)\n" "\n" " Returns a new float property definition.\n" "\n" @@ -750,7 +792,17 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) } PyDoc_STRVAR(BPy_FloatVectorProperty_doc, -".. function:: FloatVectorProperty(name=\"\", description=\"\", default=(0.0, 0.0, 0.0), min=sys.float_info.min, max=sys.float_info.max, soft_min=sys.float_info.min, soft_max=sys.float_info.max, step=3, precision=2, options={'ANIMATABLE'}, subtype='NONE', size=3, update=None)\n" +".. function:: FloatVectorProperty(name=\"\", " + "description=\"\", " + "default=(0.0, 0.0, 0.0), " + "min=sys.float_info.min, max=sys.float_info.max, " + "soft_min=sys.float_info.min, soft_max=sys.float_info.max, " + "step=3, " + "precision=2, " + "options={'ANIMATABLE'}, " + "subtype='NONE', " + "size=3, " + "update=None)\n" "\n" " Returns a new vector float property definition.\n" "\n" @@ -760,7 +812,9 @@ BPY_PROPDEF_DESC_DOC " :type default: sequence\n" " :arg options: Enumerator in ['HIDDEN', 'SKIP_SAVE', 'ANIMATABLE'].\n" " :type options: set\n" -" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', 'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', 'COLOR_GAMMA', 'LAYER', 'NONE'].\n" +" :arg subtype: Enumerator in ['COLOR', 'TRANSLATION', 'DIRECTION', " + "'VELOCITY', 'ACCELERATION', 'MATRIX', 'EULER', 'QUATERNION', 'AXISANGLE', 'XYZ', " + "'COLOR_GAMMA', 'LAYER', 'NONE'].\n" " :type subtype: string\n" BPY_PROPDEF_UNIT_DOC " :arg size: Vector dimensions in [1, and " STRINGIFY(PYRNA_STACK_ARRAY) "].\n" @@ -779,7 +833,8 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec "step", "precision", "options", "subtype", "unit", "size", "update", NULL}; const char *id = NULL, *name = NULL, *description = ""; int id_len; - float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3, def[PYRNA_STACK_ARRAY] = {0.0f}; + float min = -FLT_MAX, max = FLT_MAX, soft_min = -FLT_MAX, soft_max = FLT_MAX, step = 3; + float def[PYRNA_STACK_ARRAY] = {0.0f}; int precision = 2, size = 3; PropertyRNA *prop; PyObject *pydef = NULL; @@ -843,7 +898,13 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec } PyDoc_STRVAR(BPy_StringProperty_doc, -".. function:: StringProperty(name=\"\", description=\"\", default=\"\", maxlen=0, options={'ANIMATABLE'}, subtype='NONE', update=None)\n" +".. function:: StringProperty(name=\"\", " + "description=\"\", " + "default=\"\", " + "maxlen=0, " + "options={'ANIMATABLE'}, " + "subtype='NONE', " + "update=None)\n" "\n" " Returns a new string property definition.\n" "\n" @@ -978,7 +1039,8 @@ static EnumPropertyItem *enum_items_from_py(PyObject *seq_fast, PyObject *def, i (tmp.identifier = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 0), &id_str_size)) && (tmp.name = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 1), &name_str_size)) && (tmp.description = _PyUnicode_AsStringAndSize(PyTuple_GET_ITEM(item, 2), &desc_str_size)) && - (item_size < 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1)) /* TODO, number isnt ensured to be unique from the script author */ + /* TODO, number isnt ensured to be unique from the script author */ + (item_size < 4 || py_long_as_int(PyTuple_GET_ITEM(item, 3), &tmp.value) != -1)) { if (is_enum_flag) { if (item_size < 4) { @@ -1105,7 +1167,8 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt err = -1; } else { - eitems = enum_items_from_py(items_fast, NULL, &defvalue_dummy, (RNA_property_flag(prop) & PROP_ENUM_FLAG) != 0); + eitems = enum_items_from_py(items_fast, NULL, &defvalue_dummy, + (RNA_property_flag(prop) & PROP_ENUM_FLAG) != 0); Py_DECREF(items_fast); @@ -1132,7 +1195,12 @@ static EnumPropertyItem *bpy_props_enum_itemf(struct bContext *C, PointerRNA *pt } PyDoc_STRVAR(BPy_EnumProperty_doc, -".. function:: EnumProperty(items, name=\"\", description=\"\", default=\"\", options={'ANIMATABLE'}, update=None)\n" +".. function:: EnumProperty(items, " + "name=\"\", " + "description=\"\", " + "default=\"\", " + "options={'ANIMATABLE'}, " + "update=None)\n" "\n" " Returns a new enumerator property definition.\n" "\n" @@ -1218,7 +1286,8 @@ static PyObject *BPy_EnumProperty(PyObject *self, PyObject *args, PyObject *kw) return NULL; } - eitems = enum_items_from_py(items_fast, def, &defvalue, (opts & PROP_ENUM_FLAG) != 0); + eitems = enum_items_from_py(items_fast, def, &defvalue, + (opts & PROP_ENUM_FLAG) != 0); Py_DECREF(items_fast); @@ -1287,7 +1356,10 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix } PyDoc_STRVAR(BPy_PointerProperty_doc, -".. function:: PointerProperty(type=\"\", description=\"\", options={'ANIMATABLE'}, update=None)\n" +".. function:: PointerProperty(type=\"\", " + "description=\"\", " + "options={'ANIMATABLE'}, " + "update=None)\n" "\n" " Returns a new pointer property definition.\n" "\n" @@ -1349,7 +1421,10 @@ static PyObject *BPy_PointerProperty(PyObject *self, PyObject *args, PyObject *k } PyDoc_STRVAR(BPy_CollectionProperty_doc, -".. function:: CollectionProperty(items, type=\"\", description=\"\", default=\"\", options={'ANIMATABLE'})\n" +".. function:: CollectionProperty(items, " + "type=\"\", " + "description=\"\", " + "options={'ANIMATABLE'})\n" "\n" " Returns a new collection property definition.\n" "\n" diff --git a/source/blender/quicktime/quicktime_export.h b/source/blender/quicktime/quicktime_export.h index f64521bda35..71827b1e202 100644 --- a/source/blender/quicktime/quicktime_export.h +++ b/source/blender/quicktime/quicktime_export.h @@ -50,10 +50,11 @@ typedef struct QuicktimeCodecTypeDesc { } QuicktimeCodecTypeDesc ; // quicktime movie output functions +struct ImageFormatData; struct RenderData; +struct ReportList; struct Scene; struct wmOperatorType; -struct ReportList; int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports); //for movie handle (BKE writeavi.c now) int append_qt(struct RenderData *rd, int frame, int *pixels, int rectx, int recty, struct ReportList *reports); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index f8f78d83434..30dc401da27 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -671,7 +671,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen float *tav= RE_vertren_get_tangent(obr, ver, 0); if (tav) { /* orthonorm. */ - float tdn = tav[0]*ver->n[0] + tav[1]*ver->n[1] + tav[2]*ver->n[2]; + const float tdn = dot_v3v3(tav, ver->n); tav[0] -= ver->n[0]*tdn; tav[1] -= ver->n[1]*tdn; tav[2] -= ver->n[2]*tdn; @@ -767,7 +767,7 @@ static int as_testvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, float while(asf) { for(a=0; a<4; a++) { if(asf->vlr[a] && asf->vlr[a]!=vlr) { - inp= fabs( vlr->n[0]*asf->vlr[a]->n[0] + vlr->n[1]*asf->vlr[a]->n[1] + vlr->n[2]*asf->vlr[a]->n[2] ); + inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n)); if(inp < thresh) return 1; } } @@ -790,7 +790,7 @@ static VertRen *as_findvertex(VlakRen *vlr, VertRen *UNUSED(ver), ASvert *asv, f if(asf->vlr[a] && asf->vlr[a]!=vlr) { /* this face already made a copy for this vertex! */ if(asf->nver[a]) { - inp= fabs( vlr->n[0]*asf->vlr[a]->n[0] + vlr->n[1]*asf->vlr[a]->n[1] + vlr->n[2]*asf->vlr[a]->n[2] ); + inp = fabsf(dot_v3v3(vlr->n, asf->vlr[a]->n)); if(inp >= thresh) { return asf->nver[a]; } @@ -2158,7 +2158,7 @@ static void make_render_halos(Render *re, ObjectRen *obr, Mesh *UNUSED(me), int copy_v3_v3(view, vec); normalize_v3(view); - zn= nor[0]*view[0]+nor[1]*view[1]+nor[2]*view[2]; + zn = dot_v3v3(nor, view); if(zn>=0.0f) hasize= 0.0f; else hasize*= zn*zn*zn*zn; } @@ -2240,9 +2240,9 @@ static void displace_render_vert(Render *re, ObjectRen *obr, ShadeInput *shi, Ve mul_m4_v3(mat, shi->co); if(imat) { - shi->vn[0]= imat[0][0]*vr->n[0]+imat[0][1]*vr->n[1]+imat[0][2]*vr->n[2]; - shi->vn[1]= imat[1][0]*vr->n[0]+imat[1][1]*vr->n[1]+imat[1][2]*vr->n[2]; - shi->vn[2]= imat[2][0]*vr->n[0]+imat[2][1]*vr->n[1]+imat[2][2]*vr->n[2]; + shi->vn[0] = dot_v3v3(imat[0], vr->n); + shi->vn[1] = dot_v3v3(imat[1], vr->n); + shi->vn[2] = dot_v3v3(imat[2], vr->n); } if (texco & TEXCO_UV) { @@ -4241,7 +4241,7 @@ static void check_non_flat_quads(ObjectRen *obr) flen= normal_tri_v3( nor,vlr->v4->co, vlr->v3->co, vlr->v1->co); if(flen==0.0f) normal_tri_v3( nor,vlr->v4->co, vlr->v2->co, vlr->v1->co); - xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2]; + xn = dot_v3v3(nor, vlr->n); if(ABS(xn) < 0.999995f ) { // checked on noisy fractal grid @@ -4252,11 +4252,11 @@ static void check_non_flat_quads(ObjectRen *obr) /* split direction based on vnorms */ normal_tri_v3( nor,vlr->v1->co, vlr->v2->co, vlr->v3->co); - d1= nor[0]*vlr->v1->n[0] + nor[1]*vlr->v1->n[1] + nor[2]*vlr->v1->n[2]; + d1 = dot_v3v3(nor, vlr->v1->n); normal_tri_v3( nor,vlr->v2->co, vlr->v3->co, vlr->v4->co); - d2= nor[0]*vlr->v2->n[0] + nor[1]*vlr->v2->n[1] + nor[2]*vlr->v2->n[2]; - + d2 = dot_v3v3(nor, vlr->v2->n); + if( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24; else vlr->flag &= ~R_DIVIDE_24; @@ -5267,7 +5267,7 @@ static void speedvector_project(Render *re, float zco[2], const float co[3], con if(vec[0]<0.0f) ang= -ang; zco[0]= ang/pixelphix + zmulx; - ang= 0.5f*(float)M_PI - saacos(vec[1]/sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2])); + ang= 0.5f*(float)M_PI - saacos(vec[1] / len_v3(vec)); zco[1]= ang/pixelphiy + zmuly; } @@ -5487,9 +5487,9 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float * } // transform (=rotate) to cam space - camco[0]= imat[0][0]*fsvec[0] + imat[0][1]*fsvec[1] + imat[0][2]*fsvec[2]; - camco[1]= imat[1][0]*fsvec[0] + imat[1][1]*fsvec[1] + imat[1][2]*fsvec[2]; - camco[2]= imat[2][0]*fsvec[0] + imat[2][1]*fsvec[1] + imat[2][2]*fsvec[2]; + camco[0] = dot_v3v3(imat[0], fsvec); + camco[1] = dot_v3v3(imat[1], fsvec); + camco[2] = dot_v3v3(imat[2], fsvec); // get homogenous coordinates projectvert(camco, winmat, hoco); diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index e20fd85d0f0..782e0b59388 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -1413,7 +1413,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f if(env) { /* sky shading using bent normal */ if(ELEM(envcolor, WO_AOSKYCOL, WO_AOSKYTEX)) { - fac= 0.5f*(1.0f+bn[0]*re->grvec[0]+ bn[1]*re->grvec[1]+ bn[2]*re->grvec[2]); + fac= 0.5f * (1.0f + dot_v3v3(bn, re->grvec)); env[0]= (1.0f-fac)*re->wrld.horr + fac*re->wrld.zenr; env[1]= (1.0f-fac)*re->wrld.horg + fac*re->wrld.zeng; env[2]= (1.0f-fac)*re->wrld.horb + fac*re->wrld.zenb; diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index f261ec41746..24683ec57f7 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -104,7 +104,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) lv[0]= rco[0]-lar->co[0]; lv[1]= rco[1]-lar->co[1]; lv[2]= rco[2]-lar->co[2]; - ld= sqrt(lv[0]*lv[0]+lv[1]*lv[1]+lv[2]*lv[2]); + ld = len_v3(lv); lv[0]/= ld; lv[1]/= ld; lv[2]/= ld; @@ -210,7 +210,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) /* dot product and reflectivity*/ - inp= 1.0-fabs(vn[0]*lv[0] + vn[1]*lv[1] + vn[2]*lv[2]); + inp = 1.0 - fabs(dot_v3v3(vn, lv)); /* inp= cos(0.5*M_PI-acos(inp)); */ @@ -511,7 +511,7 @@ void shadeSkyView(float col_r[3], const float rco[3], const float view[3], const /* Some view vector stuff. */ if(R.wrld.skytype & WO_SKYREAL) { - blend= view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]; + blend = dot_v3v3(view, R.grvec); if(blend<0.0f) skyflag= 0; diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index f9ffc2532eb..6c0386cc8b1 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -471,7 +471,7 @@ void makeraytree(Render *re) sub[i] = max[i]-min[i]; } - re->maxdist= sub[0]*sub[0] + sub[1]*sub[1] + sub[2]*sub[2]; + re->maxdist = dot_v3v3(sub, sub); if(re->maxdist > 0.0f) re->maxdist= sqrt(re->maxdist); re->i.infostr= "Raytree finished"; @@ -598,7 +598,7 @@ static int refraction(float refract[3], const float n[3], const float view[3], f copy_v3_v3(refract, view); - dot= view[0]*n[0] + view[1]*n[1] + view[2]*n[2]; + dot = dot_v3v3(view, n); if(dot>0.0f) { index = 1.0f/index; @@ -1708,7 +1708,7 @@ static int UNUSED_FUNCTION(ray_trace_shadow_rad)(ShadeInput *ship, ShadeResult * counter+=3; counter %= 768; copy_v3_v3(vec, hashvectf+counter); - if(ship->vn[0]*vec[0]+ship->vn[1]*vec[1]+ship->vn[2]*vec[2]>0.0f) { + if (dot_v3v3(ship->vn, vec) > 0.0f) { vec[0]-= vec[0]; vec[1]-= vec[1]; vec[2]-= vec[2]; @@ -1771,7 +1771,7 @@ static void DS_energy(float *sphere, int tot, float vec[3]) for(a=0, fp=sphere; a<tot; a++, fp+=3) { sub_v3_v3v3(force, vec, fp); - fac= force[0]*force[0] + force[1]*force[1] + force[2]*force[2]; + fac = dot_v3v3(force, force); if(fac!=0.0f) { fac= 1.0f/fac; res[0]+= fac*force[0]; @@ -1997,7 +1997,7 @@ static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3]) normalize_v3(view); if(envcolor==WO_AOSKYCOL) { - const float skyfac= 0.5f*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); + const float skyfac= 0.5f * (1.0f + dot_v3v3(view, R.grvec)); env[0]+= (1.0f-skyfac)*R.wrld.horr + skyfac*R.wrld.zenr; env[1]+= (1.0f-skyfac)*R.wrld.horg + skyfac*R.wrld.zeng; env[2]+= (1.0f-skyfac)*R.wrld.horb + skyfac*R.wrld.zenb; @@ -2101,7 +2101,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) while(tot--) { - if ((vec[0]*nrm[0] + vec[1]*nrm[1] + vec[2]*nrm[2]) > bias) { + if (dot_v3v3(vec, nrm) > bias) { /* only ao samples for mask */ if(R.r.mode & R_OSA) { j++; @@ -2135,7 +2135,7 @@ static void ray_ao_spheresamp(ShadeInput *shi, float ao[3], float env[3]) normalize_v3(view); if(envcolor==WO_AOSKYCOL) { - const float fac= 0.5f*(1.0f+view[0]*R.grvec[0]+ view[1]*R.grvec[1]+ view[2]*R.grvec[2]); + const float fac = 0.5f * (1.0f + dot_v3v3(view, R.grvec)); env[0]+= (1.0f-fac)*R.wrld.horr + fac*R.wrld.zenr; env[1]+= (1.0f-fac)*R.wrld.horg + fac*R.wrld.zeng; env[2]+= (1.0f-fac)*R.wrld.horb + fac*R.wrld.zenb; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index c14a768d1ce..88d86d5bd43 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -2068,7 +2068,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v mul_m4_v3(obi->mat, v1); /* from shadepixel() */ - dface= v1[0]*nor[0] + v1[1]*nor[1] + v1[2]*nor[2]; + dface = dot_v3v3(v1, nor); hoco[3]= 1.0f; /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */ @@ -2091,7 +2091,7 @@ static int viewpixel_to_lampbuf(ShadBuf *shb, ObjectInstanceRen *obi, VlakRen *v calc_view_vector(view, x, y); - div= nor[0]*view[0] + nor[1]*view[1] + nor[2]*view[2]; + div = dot_v3v3(nor, view); if (div==0.0f) return 0; diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 580a09d5050..e0b5da817cb 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -608,7 +608,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v if(shi->obi->flag & R_TRANSFORMED) mul_m4_v3(shi->obi->mat, v1); - dface= v1[0]*shi->facenor[0]+v1[1]*shi->facenor[1]+v1[2]*shi->facenor[2]; + dface = dot_v3v3(v1, shi->facenor); /* ortho viewplane cannot intersect using view vector originating in (0,0,0) */ if(R.r.mode & R_ORTHO) { @@ -650,7 +650,7 @@ void shade_input_calc_viewco(ShadeInput *shi, float x, float y, float z, float v else { float div; - div= shi->facenor[0]*view[0] + shi->facenor[1]*view[1] + shi->facenor[2]*view[2]; + div = dot_v3v3(shi->facenor, view); if (div!=0.0f) fac= dface/div; else fac= 0.0f; diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index 3637c2de1fb..66cbb18bc57 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -274,7 +274,7 @@ static float metadensity(Object* ob, const float co[3]) } /* ml->rad2 is not set */ - dist2 = 1.f - ((tp[0]*tp[0] + tp[1]*tp[1] + tp[2]*tp[2]) / (ml->rad*ml->rad)); + dist2 = 1.0f - (dot_v3v3(tp, tp) / (ml->rad * ml->rad)); if (dist2 > 0.f) dens += (ml->flag & MB_NEGATIVE) ? -ml->s*dist2*dist2*dist2 : ml->s*dist2*dist2*dist2; } diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 758cf7bd61c..357eaf2633b 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -526,14 +526,14 @@ typedef struct wmDrag { int icon, type; /* type, see WM_DRAG defines above */ void *poin; - char path[240]; /* FILE_MAX */ + char path[1024]; /* FILE_MAX */ double value; struct ImBuf *imb; /* if no icon but imbuf should be drawn around cursor */ float scale; int sx, sy; - char opname[240]; /* FILE_MAX */ /* if set, draws operator name*/ + char opname[200]; /* if set, draws operator name*/ } wmDrag; /* dropboxes are like keymaps, part of the screen/area/region definition */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 3a3be292f07..7dd2bf7fc51 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -806,7 +806,7 @@ int WM_operator_confirm_message(bContext *C, wmOperator *op, const char *message pup= uiPupMenuBegin(C, IFACE_("OK?"), ICON_QUESTION); layout= uiPupMenuLayout(pup); - uiItemFullO(layout, op->type->idname, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0); + uiItemFullO_ptr(layout, op->type, message, ICON_NONE, properties, WM_OP_EXEC_REGION_WIN, 0); uiPupMenuEnd(C, pup); return OPERATOR_CANCELLED; |