diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-06-22 14:12:44 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-06-22 14:12:44 +0300 |
commit | 97ee7f8609bed555ff4bd371b7e25d13b2d6a0d6 (patch) | |
tree | 0aadae430c5c7d84c820fd567d815c455227d13d /source | |
parent | 48c58bd9138ad88d8aaa24ad9d6d67e1303e7905 (diff) | |
parent | 493c6b622fe3fb80243dfeac29f9399ac6fc4a8c (diff) |
Merge branch 'master' into blender2.8
Conflicts:
source/blender/blenloader/intern/readfile.c
source/blender/editors/physics/particle_edit.c
Diffstat (limited to 'source')
26 files changed, 247 insertions, 186 deletions
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 98757407e89..812d1c66923 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -628,6 +628,8 @@ bool BKE_vfont_to_curve_ex(Main *bmain, Object *ob, int mode, ListBase *r_nubase bool use_textbox; VChar *che; struct CharTrans *chartransdata = NULL, *ct; + /* Text at the beginning of the last used text-box (use for y-axis alignment). */ + int i_textbox = 0; struct TempLineInfo *lineinfo; float *f, xof, yof, xtrax, linedist; float twidth, maxlen = 0; @@ -830,6 +832,7 @@ makebreak: (cu->totbox > (curbox + 1)) && ((-(yof - tb_scale.y)) > (tb_scale.h - linedist) - yof_scale)) { + i_textbox = i + 1; maxlen = 0; curbox++; @@ -908,10 +911,10 @@ makebreak: /* linedata is now: width of line */ - if (cu->spacemode != CU_LEFT) { + if (cu->spacemode != CU_ALIGN_X_LEFT) { ct = chartransdata; - if (cu->spacemode == CU_RIGHT) { + if (cu->spacemode == CU_ALIGN_X_RIGHT) { struct TempLineInfo *li; for (i = 0, li = lineinfo; i < lnr; i++, li++) { @@ -923,7 +926,7 @@ makebreak: ct++; } } - else if (cu->spacemode == CU_MIDDLE) { + else if (cu->spacemode == CU_ALIGN_X_MIDDLE) { struct TempLineInfo *li; for (i = 0, li = lineinfo; i < lnr; i++, li++) { @@ -935,7 +938,7 @@ makebreak: ct++; } } - else if ((cu->spacemode == CU_FLUSH) && use_textbox) { + else if ((cu->spacemode == CU_ALIGN_X_FLUSH) && use_textbox) { struct TempLineInfo *li; for (i = 0, li = lineinfo; i < lnr; i++, li++) { @@ -956,7 +959,7 @@ makebreak: ct++; } } - else if ((cu->spacemode == CU_JUSTIFY) && use_textbox) { + else if ((cu->spacemode == CU_ALIGN_X_JUSTIFY) && use_textbox) { float curofs = 0.0f; for (i = 0; i <= slen; i++) { for (j = i; @@ -983,6 +986,60 @@ makebreak: } } + /* top-baseline is default, in this case, do nothing */ + if (cu->align_y != CU_ALIGN_Y_TOP_BASELINE) { + if (tb_scale.h != 0.0f) { + /* top and top-baseline are the same when text-boxes are used */ + if (cu->align_y != CU_ALIGN_Y_TOP && i_textbox < slen) { + /* all previous textboxes are 'full', only align the last used text-box */ + float yoff; + int lines; + struct CharTrans *ct_last, *ct_textbox; + + ct_last = chartransdata + slen - 1; + ct_textbox = chartransdata + i_textbox; + + lines = ct_last->linenr - ct_textbox->linenr + 1; + if (mem[slen - 1] == '\n') { + lines++; + } + + if (cu->align_y == CU_ALIGN_Y_BOTTOM) { + yoff = (lines * linedist) - tb_scale.h; + } + else if (cu->align_y == CU_ALIGN_Y_CENTER) { + yoff = 0.5f * ((lines * linedist) - tb_scale.h); + } + + ct = ct_textbox; + for (i = i_textbox - 1; i < slen; i++) { + ct->yof += yoff; + ct++; + } + } + } + else { + /* non text-box case handled separately */ + ct = chartransdata; + float yoff; + + if (cu->align_y == CU_ALIGN_Y_TOP) { + yoff = -linedist; + } + else if (cu->align_y == CU_ALIGN_Y_BOTTOM) { + yoff = (lnr - 1.0f) * linedist; + } + else if (cu->align_y == CU_ALIGN_Y_CENTER) { + yoff = (lnr - 2.0f) * linedist * 0.5f; + } + + for (i = 0; i <= slen; i++) { + ct->yof += yoff; + ct++; + } + } + } + MEM_freeN(lineinfo); /* TEXT ON CURVE */ @@ -1021,13 +1078,13 @@ makebreak: /* path longer than text: spacemode involves */ distfac = 1.0f / distfac; - if (cu->spacemode == CU_RIGHT) { + if (cu->spacemode == CU_ALIGN_X_RIGHT) { timeofs = 1.0f - distfac; } - else if (cu->spacemode == CU_MIDDLE) { + else if (cu->spacemode == CU_ALIGN_X_MIDDLE) { timeofs = (1.0f - distfac) / 2.0f; } - else if (cu->spacemode == CU_FLUSH) { + else if (cu->spacemode == CU_ALIGN_X_FLUSH) { distfac = 1.0f; } } diff --git a/source/blender/blenlib/intern/hash_md5.c b/source/blender/blenlib/intern/hash_md5.c index d98b915983c..c73fe7a3ff1 100644 --- a/source/blender/blenlib/intern/hash_md5.c +++ b/source/blender/blenlib/intern/hash_md5.c @@ -112,7 +112,7 @@ static void md5_init_ctx(struct md5_ctx *ctx) * the 'ctx' context for the next 'len' bytes starting at 'buffer'. * It is necessary that 'len' is a multiple of 64!!! */ -static void md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) +static void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx) { /* These are the four functions used in the four steps of the MD5 algorithm and defined in the RFC 1321. * The first function is a little bit optimized (as found in Colin Plumbs public domain implementation). diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index 3cae95d418e..be893177b3b 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -411,22 +411,23 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil /* Even though directly used libs have been already moved to new main, indirect ones have not. * This is a bit annoying, but we have no choice but to keep them all for now - means some now unused * data may remain in memory, but think we'll have to live with it. */ - Main *libmain; + Main *libmain, *libmain_next; Main *newmain = bfd->main; ListBase new_mainlist = {newmain, newmain}; - for (libmain = oldmain->next; libmain; libmain = libmain->next) { + for (libmain = oldmain->next; libmain; libmain = libmain_next) { + libmain_next = libmain->next; /* Note that LIB_INDIRECT does not work with libraries themselves, so we use non-NULL parent * to detect indirect-linked ones... */ if (libmain->curlib && (libmain->curlib->parent != NULL)) { BLI_remlink(&old_mainlist, libmain); BLI_addtail(&new_mainlist, libmain); } -#if 0 else { +#ifdef PRINT_DEBUG printf("Dropped Main for lib: %s\n", libmain->curlib->id.name); - } #endif + } } /* In any case, we need to move all lib datablocks themselves - those are 'first level data', * getting rid of them would imply updating spaces & co to prevent invalid pointers access. */ diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 3182f5f3055..ea373364376 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -158,53 +158,54 @@ #include <errno.h> -/* - * Remark: still a weak point is the newaddress() function, that doesnt solve reading from - * multiple files at the same time - * - * (added remark: oh, i thought that was solved? will look at that... (ton) - * +/** * READ - * - Existing Library (Main) push or free - * - allocate new Main + * ==== + * + * - Existing Library (#Main) push or free + * - allocate new #Main * - load file - * - read SDNA + * - read #SDNA * - for each LibBlock - * - read LibBlock - * - if a Library - * - make a new Main - * - attach ID's to it - * - else - * - read associated 'direct data' - * - link direct data (internal and to LibBlock) - * - read FileGlobal - * - read USER data, only when indicated (file is ~/X.XX/startup.blend) + * - read LibBlock + * - if a Library + * - make a new #Main + * - attach ID's to it + * - else + * - read associated 'direct data' + * - link direct data (internal and to LibBlock) + * - read #FileGlobal + * - read #USER data, only when indicated (file is ``~/X.XX/startup.blend``) * - free file - * - per Library (per Main) - * - read file - * - read SDNA - * - find LibBlocks and attach IDs to Main - * - if external LibBlock - * - search all Main's - * - or it's already read, - * - or not read yet - * - or make new Main - * - per LibBlock - * - read recursive - * - read associated direct data - * - link direct data (internal and to LibBlock) - * - free file + * - per Library (per #Main) + * - read file + * - read #SDNA + * - find LibBlocks and attach #ID's to #Main + * - if external LibBlock + * - search all #Main's + * - or it's already read, + * - or not read yet + * - or make new #Main + * - per LibBlock + * - read recursive + * - read associated direct data + * - link direct data (internal and to LibBlock) + * - free file * - per Library with unread LibBlocks - * - read file - * - read SDNA - * - per LibBlock - * - read recursive - * - read associated direct data - * - link direct data (internal and to LibBlock) - * - free file - * - join all Mains + * - read file + * - read #SDNA + * - per LibBlock + * - read recursive + * - read associated direct data + * - link direct data (internal and to LibBlock) + * - free file + * - join all #Main's * - link all LibBlocks and indirect pointers to libblocks - * - initialize FileGlobal and copy pointers to Global + * - initialize #FileGlobal and copy pointers to #Global + * + * \note Still a weak point is the new-address function, that doesnt solve reading from + * multiple files at the same time. + * (added remark: oh, i thought that was solved? will look at that... (ton). */ /* use GHash for BHead name-based lookups (speeds up linking) */ @@ -1256,7 +1257,7 @@ void blo_freefiledata(FileData *fd) } if (fd->strm.next_in) { - if (inflateEnd (&fd->strm) != Z_OK) { + if (inflateEnd(&fd->strm) != Z_OK) { printf("close gzip stream error\n"); } } @@ -6650,11 +6651,7 @@ static bool direct_link_screen(FileData *fd, bScreen *sc) } else if (sl->spacetype == SPACE_IMAGE) { SpaceImage *sima = (SpaceImage *)sl; - - sima->cumap = newdataadr(fd, sima->cumap); - if (sima->cumap) - direct_link_curvemapping(fd, sima->cumap); - + sima->iuser.scene = NULL; sima->iuser.ok = 1; sima->scopes.waveform_1 = NULL; @@ -7561,16 +7558,22 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short if (fd->memfile && ELEM(bhead->code, ID_LI, ID_ID)) { const char *idname = bhead_id_name(fd, bhead); - /* printf("Checking %s...\n", idname); */ +#ifdef PRINT_DEBUG + printf("Checking %s...\n", idname); +#endif if (bhead->code == ID_LI) { Main *libmain = fd->old_mainlist->first; /* Skip oldmain itself... */ for (libmain = libmain->next; libmain; libmain = libmain->next) { - /* printf("... against %s: ", libmain->curlib ? libmain->curlib->id.name : "<NULL>"); */ +#ifdef PRINT_DEBUG + printf("... against %s: ", libmain->curlib ? libmain->curlib->id.name : "<NULL>"); +#endif if (libmain->curlib && STREQ(idname, libmain->curlib->id.name)) { Main *oldmain = fd->old_mainlist->first; - /* printf("FOUND!\n"); */ +#ifdef PRINT_DEBUG + printf("FOUND!\n"); +#endif /* In case of a library, we need to re-add its main to fd->mainlist, because if we have later * a missing ID_ID, we need to get the correct lib it is linked to! * Order is crucial, we cannot bulk-add it in BLO_read_from_memfile() like it used to be... */ @@ -7584,13 +7587,19 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short } return blo_nextbhead(fd, bhead); } - /* printf("nothing...\n"); */ +#ifdef PRINT_DEBUG + printf("nothing...\n"); +#endif } } else { - /* printf("... in %s (%s): ", main->curlib ? main->curlib->id.name : "<NULL>", main->curlib ? main->curlib->name : "<NULL>"); */ +#ifdef PRINT_DEBUG + printf("... in %s (%s): ", main->curlib ? main->curlib->id.name : "<NULL>", main->curlib ? main->curlib->name : "<NULL>"); +#endif if ((id = BKE_libblock_find_name_ex(main, GS(idname), idname + 2))) { - /* printf("FOUND!\n"); */ +#ifdef PRINT_DEBUG + printf("FOUND!\n"); +#endif /* Even though we found our linked ID, there is no guarantee its address is still the same... */ if (id != bhead->old) { oldnewmap_insert(fd->libmap, bhead->old, id, GS(id->name)); @@ -7602,7 +7611,9 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, const short } return blo_nextbhead(fd, bhead); } - /* printf("nothing...\n"); */ +#ifdef PRINT_DEBUG + printf("nothing...\n"); +#endif } } @@ -8112,7 +8123,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath) struct BHeadSort { BHead *bhead; - void *old; + const void *old; }; static int verg_bheadsort(const void *v1, const void *v2) diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 6a301e63399..3393be059bd 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -447,7 +447,9 @@ static int endwrite(WriteData *wd) /* ********** WRITE FILE ****************** */ -static void writestruct_at_address(WriteData *wd, int filecode, const char *structname, int nr, void *adr, void *data) +static void writestruct_at_address( + WriteData *wd, int filecode, const char *structname, int nr, + const void *adr, const void *data) { BHead bh; const short *sp; @@ -474,7 +476,9 @@ static void writestruct_at_address(WriteData *wd, int filecode, const char *stru mywrite(wd, data, bh.len); } -static void writestruct(WriteData *wd, int filecode, const char *structname, int nr, void *adr) +static void writestruct( + WriteData *wd, int filecode, const char *structname, int nr, + const void *adr) { writestruct_at_address(wd, filecode, structname, nr, adr, adr); } @@ -491,7 +495,7 @@ static void writedata(WriteData *wd, int filecode, int len, const void *adr) /* /* init BHead */ bh.code = filecode; - bh.old = (void *)adr; /* this is safe to cast from const */ + bh.old = adr; bh.nr = 1; bh.SDNAnr = 0; bh.len = len; @@ -501,9 +505,9 @@ static void writedata(WriteData *wd, int filecode, int len, const void *adr) /* } /* use this to force writing of lists in same order as reading (using link_list) */ -static void writelist(WriteData *wd, int filecode, const char *structname, ListBase *lb) +static void writelist(WriteData *wd, int filecode, const char *structname, const ListBase *lb) { - Link *link = lb->first; + const Link *link = lb->first; while (link) { writestruct(wd, filecode, structname, 1, link); @@ -513,10 +517,10 @@ static void writelist(WriteData *wd, int filecode, const char *structname, ListB /* *************** writing some direct data structs used in more code parts **************** */ /*These functions are used by blender's .blend system for file saving/loading.*/ -void IDP_WriteProperty_OnlyData(IDProperty *prop, void *wd); -void IDP_WriteProperty(IDProperty *prop, void *wd); +void IDP_WriteProperty_OnlyData(const IDProperty *prop, void *wd); +void IDP_WriteProperty(const IDProperty *prop, void *wd); -static void IDP_WriteArray(IDProperty *prop, void *wd) +static void IDP_WriteArray(const IDProperty *prop, void *wd) { /*REMEMBER to set totalen to len in the linking code!!*/ if (prop->data.pointer) { @@ -532,11 +536,11 @@ static void IDP_WriteArray(IDProperty *prop, void *wd) } } -static void IDP_WriteIDPArray(IDProperty *prop, void *wd) +static void IDP_WriteIDPArray(const IDProperty *prop, void *wd) { /*REMEMBER to set totalen to len in the linking code!!*/ if (prop->data.pointer) { - IDProperty *array = prop->data.pointer; + const IDProperty *array = prop->data.pointer; int a; writestruct(wd, DATA, "IDProperty", prop->len, array); @@ -546,13 +550,13 @@ static void IDP_WriteIDPArray(IDProperty *prop, void *wd) } } -static void IDP_WriteString(IDProperty *prop, void *wd) +static void IDP_WriteString(const IDProperty *prop, void *wd) { /*REMEMBER to set totalen to len in the linking code!!*/ writedata(wd, DATA, prop->len, prop->data.pointer); } -static void IDP_WriteGroup(IDProperty *prop, void *wd) +static void IDP_WriteGroup(const IDProperty *prop, void *wd) { IDProperty *loop; @@ -562,7 +566,7 @@ static void IDP_WriteGroup(IDProperty *prop, void *wd) } /* Functions to read/write ID Properties */ -void IDP_WriteProperty_OnlyData(IDProperty *prop, void *wd) +void IDP_WriteProperty_OnlyData(const IDProperty *prop, void *wd) { switch (prop->type) { case IDP_GROUP: @@ -580,13 +584,13 @@ void IDP_WriteProperty_OnlyData(IDProperty *prop, void *wd) } } -void IDP_WriteProperty(IDProperty *prop, void *wd) +void IDP_WriteProperty(const IDProperty *prop, void *wd) { writestruct(wd, DATA, "IDProperty", 1, prop); IDP_WriteProperty_OnlyData(prop, wd); } -static void write_iddata(void *wd, ID *id) +static void write_iddata(void *wd, const ID *id) { /* ID_WM's id->properties are considered runtime only, and never written in .blend file. */ if (id->properties && !ELEM(GS(id->name), ID_WM)) { @@ -594,29 +598,24 @@ static void write_iddata(void *wd, ID *id) } } -static void write_previews(WriteData *wd, PreviewImage *prv) +static void write_previews(WriteData *wd, const PreviewImage *prv_orig) { /* Never write previews when doing memsave (i.e. undo/redo)! */ - if (prv && !wd->current) { - short w = prv->w[1]; - short h = prv->h[1]; - unsigned int *rect = prv->rect[1]; + if (prv_orig && !wd->current) { + PreviewImage prv = *prv_orig; /* don't write out large previews if not requested */ if (!(U.flag & USER_SAVE_PREVIEWS)) { - prv->w[1] = 0; - prv->h[1] = 0; - prv->rect[1] = NULL; + prv.w[1] = 0; + prv.h[1] = 0; + prv.rect[1] = NULL; } - writestruct(wd, DATA, "PreviewImage", 1, prv); - if (prv->rect[0]) writedata(wd, DATA, prv->w[0] * prv->h[0] * sizeof(unsigned int), prv->rect[0]); - if (prv->rect[1]) writedata(wd, DATA, prv->w[1] * prv->h[1] * sizeof(unsigned int), prv->rect[1]); - - /* restore preview, we still want to keep it in memory even if not saved to file */ - if (!(U.flag & USER_SAVE_PREVIEWS) ) { - prv->w[1] = w; - prv->h[1] = h; - prv->rect[1] = rect; + writestruct_at_address(wd, DATA, "PreviewImage", 1, prv_orig, &prv); + if (prv.rect[0]) { + writedata(wd, DATA, prv.w[0] * prv.h[0] * sizeof(unsigned int), prv.rect[0]); + } + if (prv.rect[1]) { + writedata(wd, DATA, prv.w[1] * prv.h[1] * sizeof(unsigned int), prv.rect[1]); } } } @@ -2224,19 +2223,19 @@ static void write_scenes(WriteData *wd, ListBase *scebase) writestruct(wd, DATA, "ToolSettings", 1, tos); if (tos->vpaint) { writestruct(wd, DATA, "VPaint", 1, tos->vpaint); - write_paint (wd, &tos->vpaint->paint); + write_paint(wd, &tos->vpaint->paint); } if (tos->wpaint) { writestruct(wd, DATA, "VPaint", 1, tos->wpaint); - write_paint (wd, &tos->wpaint->paint); + write_paint(wd, &tos->wpaint->paint); } if (tos->sculpt) { writestruct(wd, DATA, "Sculpt", 1, tos->sculpt); - write_paint (wd, &tos->sculpt->paint); + write_paint(wd, &tos->sculpt->paint); } if (tos->uvsculpt) { writestruct(wd, DATA, "UvSculpt", 1, tos->uvsculpt); - write_paint (wd, &tos->uvsculpt->paint); + write_paint(wd, &tos->uvsculpt->paint); } write_paint(wd, &tos->imapaint.paint); @@ -2604,11 +2603,7 @@ static void write_screens(WriteData *wd, ListBase *scrbase) write_soops(wd, so, &tmp_mem_list); } else if (sl->spacetype==SPACE_IMAGE) { - SpaceImage *sima= (SpaceImage *)sl; - writestruct(wd, DATA, "SpaceImage", 1, sl); - if (sima->cumap) - write_curvemapping(wd, sima->cumap); } else if (sl->spacetype==SPACE_TEXT) { writestruct(wd, DATA, "SpaceText", 1, sl); diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 79051a2490f..fff6bea044c 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -1036,6 +1036,7 @@ void BM_face_triangulate( const int quad_method, const int ngon_method, const bool use_tag, + /* use for ngons only! */ MemArena *pf_arena, /* use for MOD_TRIANGULATE_NGON_BEAUTY only! */ diff --git a/source/blender/bmesh/tools/bmesh_decimate_collapse.c b/source/blender/bmesh/tools/bmesh_decimate_collapse.c index acb220bdf21..b4e8bb06afe 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_collapse.c +++ b/source/blender/bmesh/tools/bmesh_decimate_collapse.c @@ -603,9 +603,8 @@ static bool bm_decim_triangulate_begin(BMesh *bm, int *r_edges_tri_tot) faces_double = next; } - BLI_memarena_free(pf_arena); - if (has_ngon) { + BLI_memarena_free(pf_arena); BLI_heap_free(pf_heap, NULL); BLI_edgehash_free(pf_ehash, NULL); } diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc index f5f45dde519..6ac45c99798 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc @@ -116,10 +116,10 @@ string ComponentDepsNode::identifier() const { string &idname = this->owner->name; - char typebuf[7]; + char typebuf[16]; sprintf(typebuf, "(%d)", type); - char layers[7]; + char layers[16]; sprintf(layers, "%d", this->layers); return string(typebuf) + name + " : " + idname + " (Layers: " + layers + ")"; diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index ae6894ac546..fc6f4036d02 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -192,7 +192,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) #define HSV_BANDWIDTH 0.3f /* used to determine the color of F-Curves with FCURVE_COLOR_AUTO_RAINBOW set */ -//void fcurve_rainbow (unsigned int cur, unsigned int tot, float *out) +// void fcurve_rainbow(unsigned int cur, unsigned int tot, float *out) void getcolor_fcurve_rainbow(int cur, int tot, float out[3]) { float hsv[3], fac; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 936d5da8f4f..fbbb9f9e253 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -932,6 +932,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) cu1 = base->object->data; cu1->spacemode = cu->spacemode; + cu1->align_y = cu->align_y; cu1->spacing = cu->spacing; cu1->linedist = cu->linedist; cu1->shear = cu->shear; diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index f340f716ccb..0c0a6c93b3e 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2479,7 +2479,7 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot) { PropertyRNA *prop; - ot->name = "Toggle Fullscreen Area"; + ot->name = "Toggle Maximize Area"; ot->description = "Toggle display selected area as fullscreen/maximized"; ot->idname = "SCREEN_OT_screen_full_area"; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 88b3bc5d8fd..689b89e7b69 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -401,7 +401,7 @@ static void image_undo_end(void) UndoImageTile *tmp_tile = tile->next; deallocsize += allocsize * ((tile->use_float) ? sizeof(float) : sizeof(char)); MEM_freeN(tile->rect.pt); - BLI_freelinkN (lb, tile); + BLI_freelinkN(lb, tile); tile = tmp_tile; } else { diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index e4c26064fec..827f83aa425 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -3717,7 +3717,7 @@ static void project_paint_prepare_all_faces( } /* tfbase here should be non-null! */ - BLI_assert (mloopuv_base != NULL); + BLI_assert(mloopuv_base != NULL); if (is_face_sel && tpage) { ProjPaintFaceCoSS coSS; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 67fbd000b64..aa17cb02fe5 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -1158,7 +1158,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) if (event->val == KM_RELEASE) { copy_v2_fl2(mouse, event->mval[0], event->mval[1]); paint_stroke_line_constrain(stroke, mouse); - paint_stroke_line_end (C, op, stroke, mouse); + paint_stroke_line_end(C, op, stroke, mouse); stroke_done(C, op); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 7a7d67553d1..4f06923c734 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -7416,7 +7416,7 @@ static void createTransPaintCurveVerts(bContext *C, TransInfo *t) for (pcp = pc->points, i = 0; i < pc->tot_points; i++, pcp++) { if (PC_IS_ANY_SEL(pcp)) { - PaintCurvePointToTransData (pcp, td, td2d, tdpc); + PaintCurvePointToTransData(pcp, td, td2d, tdpc); if (pcp->bez.f2 & SELECT) { td += 3; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 5bd9cab4b28..3caa69cb839 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -834,6 +834,14 @@ static void ApplySnapTranslation(TransInfo *t, float vec[3]) vec[1] = point[1] - t->tsnap.snapTarget[1]; } else { + if (t->spacetype == SPACE_VIEW3D) { + if (t->options & CTX_PAINT_CURVE) { + if (ED_view3d_project_float_global(t->ar, point, point, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) { + zero_v3(point); /* no good answer here... */ + } + } + } + sub_v3_v3v3(vec, point, t->tsnap.snapTarget); } } diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index aefaf1a0f54..7972d138b9b 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -230,7 +230,7 @@ GPU_PBVH_Buffers *GPU_build_mesh_pbvh_buffers( const int face_indices_len); GPU_PBVH_Buffers *GPU_build_grid_pbvh_buffers( - int *grid_indices, int totgrid,unsigned int **grid_hidden, int gridsize, const struct CCGKey *key, + int *grid_indices, int totgrid, unsigned int **grid_hidden, int gridsize, const struct CCGKey *key, struct GridCommonGPUBuffer **grid_common_gpu_buffer); GPU_PBVH_Buffers *GPU_build_bmesh_pbvh_buffers(bool smooth_shading); diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index fdadb783815..611ada5b077 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -127,7 +127,7 @@ class Mem_IStream : public Imf::IStream { public: - Mem_IStream (unsigned char *exrbuf, size_t exrsize) : + Mem_IStream(unsigned char *exrbuf, size_t exrsize) : IStream("dummy"), _exrpos(0), _exrsize(exrsize) { _exrbuf = exrbuf; diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 8f711c1b23b..61169e4b1b1 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -230,7 +230,7 @@ typedef struct Curve { /* font part */ short lines; - char spacemode, pad1; + char spacemode, align_y; float spacing, linedist, shear, fsize, wordspace, ulpos, ulheight; float xof, yof; float linewidth; @@ -322,11 +322,19 @@ enum { /* Curve.spacemode */ enum { - CU_LEFT = 0, - CU_MIDDLE = 1, - CU_RIGHT = 2, - CU_JUSTIFY = 3, - CU_FLUSH = 4, + CU_ALIGN_X_LEFT = 0, + CU_ALIGN_X_MIDDLE = 1, + CU_ALIGN_X_RIGHT = 2, + CU_ALIGN_X_JUSTIFY = 3, + CU_ALIGN_X_FLUSH = 4, +}; + +/* Curve.align_y */ +enum { + CU_ALIGN_Y_TOP_BASELINE = 0, + CU_ALIGN_Y_TOP = 1, + CU_ALIGN_Y_CENTER = 2, + CU_ALIGN_Y_BOTTOM = 3, }; /* Nurb.flag */ diff --git a/source/blender/makesdna/DNA_sdna_types.h b/source/blender/makesdna/DNA_sdna_types.h index 28204ebeb88..cb7a371c7c5 100644 --- a/source/blender/makesdna/DNA_sdna_types.h +++ b/source/blender/makesdna/DNA_sdna_types.h @@ -67,7 +67,7 @@ typedef struct SDNA { # typedef struct BHead { int code, len; - void *old; + const void *old; int SDNAnr, nr; } BHead; # diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 2c9b3bb7a66..8f85a62e527 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -875,8 +875,6 @@ typedef struct SpaceImage { struct Image *image; struct ImageUser iuser; - struct CurveMapping *cumap DNA_DEPRECATED; /* was switched to scene's color management settings */ - struct Scopes scopes; /* histogram waveform and vectorscope */ struct Histogram sample_line_hist; /* sample line histogram */ diff --git a/source/blender/makesdna/intern/CMakeLists.txt b/source/blender/makesdna/intern/CMakeLists.txt index 52487edfd2b..b4ada7ffbf1 100644 --- a/source/blender/makesdna/intern/CMakeLists.txt +++ b/source/blender/makesdna/intern/CMakeLists.txt @@ -94,10 +94,11 @@ set(INC_SYS ) set(SRC - ../../blenlib/intern/BLI_mempool.c - ../../blenlib/intern/listbase.c ../../blenlib/intern/BLI_ghash.c + ../../blenlib/intern/BLI_mempool.c + ../../blenlib/intern/endian_switch.c ../../blenlib/intern/hash_mm2a.c + ../../blenlib/intern/listbase.c ) blender_add_lib(bf_dna_blenlib "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index b8783da73ca..99ab29fbdcc 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -43,6 +43,7 @@ #include "MEM_guardedalloc.h" // for MEM_freeN MEM_mallocN MEM_callocN #include "BLI_utildefines.h" +#include "BLI_endian_switch.h" #ifdef WITH_DNA_GHASH # include "BLI_ghash.h" @@ -1126,7 +1127,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) */ int a, mul, elemcount, elen, elena, firststructtypenr; const short *spo, *spc; - char *cpo, *cur, cval; + char *cur; const char *type, *name; if (oldSDNAnr == -1) return; @@ -1150,7 +1151,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) if (spc[0] >= firststructtypenr && !ispointer(name)) { /* struct field type */ /* where does the old data start (is there one?) */ - cpo = find_elem(oldsdna, type, name, spo, data, NULL); + char *cpo = find_elem(oldsdna, type, name, spo, data, NULL); if (cpo) { oldSDNAnr = DNA_struct_find_nr(oldsdna, type); @@ -1167,18 +1168,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) /* non-struct field type */ if (ispointer(name)) { if (oldsdna->pointerlen == 8) { - - mul = DNA_elem_array_size(name); - cpo = cur; - while (mul--) { - cval = cpo[0]; cpo[0] = cpo[7]; cpo[7] = cval; - cval = cpo[1]; cpo[1] = cpo[6]; cpo[6] = cval; - cval = cpo[2]; cpo[2] = cpo[5]; cpo[5] = cval; - cval = cpo[3]; cpo[3] = cpo[4]; cpo[4] = cval; - - cpo += 8; - } - + BLI_endian_switch_int64_array((int64_t *)cur, DNA_elem_array_size(name)); } } else { @@ -1191,14 +1181,7 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) } if (skip == false) { - mul = DNA_elem_array_size(name); - cpo = cur; - while (mul--) { - cval = cpo[0]; - cpo[0] = cpo[1]; - cpo[1] = cval; - cpo += 2; - } + BLI_endian_switch_int16_array((int16_t *)cur, DNA_elem_array_size(name)); } } else if (ELEM(spc[0], SDNA_TYPE_INT, SDNA_TYPE_FLOAT)) { @@ -1206,29 +1189,10 @@ void DNA_struct_switch_endian(SDNA *oldsdna, int oldSDNAnr, char *data) * but turns out we only used for runtime vars and * only once for a struct type thats no longer used. */ - mul = DNA_elem_array_size(name); - cpo = cur; - while (mul--) { - cval = cpo[0]; - cpo[0] = cpo[3]; - cpo[3] = cval; - cval = cpo[1]; - cpo[1] = cpo[2]; - cpo[2] = cval; - cpo += 4; - } + BLI_endian_switch_int32_array((int32_t *)cur, DNA_elem_array_size(name)); } else if (ELEM(spc[0], SDNA_TYPE_INT64, SDNA_TYPE_UINT64, SDNA_TYPE_DOUBLE)) { - mul = DNA_elem_array_size(name); - cpo = cur; - while (mul--) { - cval = cpo[0]; cpo[0] = cpo[7]; cpo[7] = cval; - cval = cpo[1]; cpo[1] = cpo[6]; cpo[6] = cval; - cval = cpo[2]; cpo[2] = cpo[5]; cpo[5] = cval; - cval = cpo[3]; cpo[3] = cpo[4]; cpo[4] = cval; - - cpo += 8; - } + BLI_endian_switch_int64_array((int64_t *)cur, DNA_elem_array_size(name)); } } } diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index cb7a40a9238..fb4ff6f4856 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -952,23 +952,37 @@ static void rna_def_nurbs(BlenderRNA *UNUSED(brna), StructRNA *srna) static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna) { PropertyRNA *prop; - + static EnumPropertyItem prop_align_items[] = { - {CU_LEFT, "LEFT", 0, "Left", "Align text to the left"}, - {CU_MIDDLE, "CENTER", 0, "Center", "Center text"}, - {CU_RIGHT, "RIGHT", 0, "Right", "Align text to the right"}, - {CU_JUSTIFY, "JUSTIFY", 0, "Justify", "Align to the left and the right"}, - {CU_FLUSH, "FLUSH", 0, "Flush", "Align to the left and the right, with equal character spacing"}, + {CU_ALIGN_X_LEFT, "LEFT", 0, "Left", "Align text to the left"}, + {CU_ALIGN_X_MIDDLE, "CENTER", 0, "Center", "Center text"}, + {CU_ALIGN_X_RIGHT, "RIGHT", 0, "Right", "Align text to the right"}, + {CU_ALIGN_X_JUSTIFY, "JUSTIFY", 0, "Justify", "Align to the left and the right"}, + {CU_ALIGN_X_FLUSH, "FLUSH", 0, "Flush", "Align to the left and the right, with equal character spacing"}, {0, NULL, 0, NULL, NULL} }; - + + static EnumPropertyItem prop_align_y_items[] = { + {CU_ALIGN_Y_TOP_BASELINE, "TOP_BASELINE", 0, "Top Base-Line", "Align to top but use the base-line of the text"}, + {CU_ALIGN_Y_TOP, "TOP", 0, "Top", "Align text to the top"}, + {CU_ALIGN_Y_CENTER, "CENTER", 0, "Center", "Align text to the middle"}, + {CU_ALIGN_Y_BOTTOM, "BOTTOM", 0, "Bottom", "Align text to the bottom"}, + {0, NULL, 0, NULL, NULL} + }; + /* Enums */ - prop = RNA_def_property(srna, "align", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(srna, "align_x", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "spacemode"); RNA_def_property_enum_items(prop, prop_align_items); - RNA_def_property_ui_text(prop, "Text Align", "Text align from the object center"); + RNA_def_property_ui_text(prop, "Text Horizontal Align", "Text horizontal align from the object center"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - + + prop = RNA_def_property(srna, "align_y", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "align_y"); + RNA_def_property_enum_items(prop, prop_align_y_items); + RNA_def_property_ui_text(prop, "Text Vertical Align", "Text vertical align from the object center"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + /* number values */ prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fsize"); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 4f9d48450f6..f632dd9aff4 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -793,7 +793,10 @@ static int wm_operator_exec(bContext *C, wmOperator *op, const bool repeat, cons wm_operator_finished(C, op, repeat); } else if (repeat == 0) { - WM_operator_free(op); + /* warning: modal from exec is bad practice, but avoid crashing. */ + if (retval & (OPERATOR_FINISHED | OPERATOR_CANCELLED)) { + WM_operator_free(op); + } } return retval | OPERATOR_HANDLED; diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 6300d2ed3c7..917e2bf5913 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -533,7 +533,7 @@ void WM_exit_ext(bContext *C, const bool do_python) #ifdef WITH_PYTHON /* option not to close python so we can use 'atexit' */ - if (do_python) { + if (do_python && ((C == NULL) || CTX_py_init_get(C))) { /* XXX - old note */ /* before BKE_blender_free so py's gc happens while library still exists */ /* needed at least for a rare sigsegv that can happen in pydrivers */ |