diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-09-19 14:48:15 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-09-19 14:48:15 +0400 |
commit | 1c0bdad8354139593cecb7cbbe3de27d8c5f6017 (patch) | |
tree | 82fada8c6425a9cd8194d0ac06b91981c7b5087a /source | |
parent | 9b7b8464b9b09f4ca74e40624d3d6c8dffb0247e (diff) | |
parent | 226ff0d4da13ac66991f1708251faa5dff3f7dea (diff) |
svn merge -r40222:40344 ^/trunk/blender
Diffstat (limited to 'source')
152 files changed, 1215 insertions, 1135 deletions
diff --git a/source/blender/avi/intern/avirgb.c b/source/blender/avi/intern/avirgb.c index b7f6a58b6d7..7050aec9bf6 100644 --- a/source/blender/avi/intern/avirgb.c +++ b/source/blender/avi/intern/avirgb.c @@ -42,11 +42,6 @@ #include "MEM_guardedalloc.h" #include "avirgb.h" -#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__) -#define WORDS_BIGENDIAN -#endif - - /* implementation */ void *avi_converter_from_avi_rgb (AviMovie *movie, int stream, unsigned char *buffer, int *size) { @@ -63,9 +58,9 @@ void *avi_converter_from_avi_rgb (AviMovie *movie, int stream, unsigned char *bu if (bits==16) { unsigned short *pxl; unsigned char *to; - #ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ unsigned char *pxla; - #endif +#endif buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); @@ -75,19 +70,19 @@ void *avi_converter_from_avi_rgb (AviMovie *movie, int stream, unsigned char *bu while (y--) { pxl= (unsigned short *) (buffer + y * movie->header->Width * 2); - #ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ pxla= (unsigned char *)pxl; - #endif +#endif x= movie->header->Width; while (x--) { - #ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ i= pxla[0]; pxla[0]= pxla[1]; pxla[1]= i; pxla+=2; - #endif +#endif *(to++)= ((*pxl>>10)&0x1f)*8; *(to++)= ((*pxl>>5)&0x1f)*8; diff --git a/source/blender/avi/intern/endian.c b/source/blender/avi/intern/endian.c index a985e8c3d5e..50ec2330beb 100644 --- a/source/blender/avi/intern/endian.c +++ b/source/blender/avi/intern/endian.c @@ -43,11 +43,7 @@ #include "endian.h" #include "avi_intern.h" -#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__) -#define WORDS_BIGENDIAN -#endif - -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ static void invert (int *num) { int new=0,i,j; @@ -79,7 +75,7 @@ static void Ichunk (AviChunk *chunk) { } #endif -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ static void Ilist (AviList *list){ invert (&list->fcc); invert (&list->size); @@ -159,10 +155,10 @@ static void Iindexe (AviIndexEntry *indexe) { invert (&indexe->Offset); invert (&indexe->Size); } -#endif /* WORDS_BIGENDIAN */ +#endif /* __BIG_ENDIAN__ */ void awrite (AviMovie *movie, void *datain, int block, int size, FILE *fp, int type) { -#ifdef WORDS_BIGENDIAN +#ifdef __BIG_ENDIAN__ void *data; data = MEM_mallocN (size, "avi endian"); @@ -209,9 +205,9 @@ void awrite (AviMovie *movie, void *datain, int block, int size, FILE *fp, int t } MEM_freeN (data); -#else /* WORDS_BIGENDIAN */ +#else /* __BIG_ENDIAN__ */ (void)movie; /* unused */ (void)type; /* unused */ fwrite (datain, block, size, fp); -#endif /* WORDS_BIGENDIAN */ +#endif /* __BIG_ENDIAN__ */ } diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index a324d983bb4..b7131800097 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -69,7 +69,7 @@ void BLF_size(int fontid, int size, int dpi); | m[3] m[7] m[11] m[15] | */ -void BLF_matrix(int fontid, double *m); +void BLF_matrix(int fontid, const double m[16]); /* Draw the string using the default font, size and dpi. */ void BLF_draw_default(float x, float y, float z, const char *str, size_t len); diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 7b78bd05fff..9a1c87ea3de 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -6,7 +6,7 @@ * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. + * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -20,7 +20,7 @@ * The Original Code is Copyright (C) 2009 Blender Foundation. * All rights reserved. * - * + * * Contributor(s): Blender Foundation * * ***** END GPL LICENSE BLOCK ***** @@ -83,8 +83,8 @@ int blf_mono_font_render= -1; static FontBLF *BLF_get(int fontid) { if (fontid >= 0 && fontid < BLF_MAX_FONT) - return(global_font[fontid]); - return(NULL); + return global_font[fontid]; + return NULL; } int BLF_init(int points, int dpi) @@ -96,7 +96,7 @@ int BLF_init(int points, int dpi) global_font_points= points; global_font_dpi= dpi; - return(blf_font_init()); + return blf_font_init(); } void BLF_exit(void) @@ -133,9 +133,9 @@ static int blf_search(const char *name) for (i= 0; i < BLF_MAX_FONT; i++) { font= global_font[i]; if (font && (!strcmp(font->name, name))) - return(i); + return i; } - return(-1); + return -1; } int BLF_load(const char *name) @@ -145,24 +145,24 @@ int BLF_load(const char *name) int i; if (!name) - return(-1); + return -1; /* check if we already load this font. */ i= blf_search(name); if (i >= 0) { /*font= global_font[i];*/ /*UNUSED*/ - return(i); + return i; } if (global_font_num+1 >= BLF_MAX_FONT) { printf("Too many fonts!!!\n"); - return(-1); + return -1; } filename= blf_dir_search(name); if (!filename) { printf("Can't find font: %s\n", name); - return(-1); + return -1; } font= blf_font_new(name, filename); @@ -170,13 +170,13 @@ int BLF_load(const char *name) if (!font) { printf("Can't load font: %s\n", name); - return(-1); + return -1; } global_font[global_font_num]= font; i= global_font_num; global_font_num++; - return(i); + return i; } int BLF_load_unique(const char *name) @@ -186,20 +186,20 @@ int BLF_load_unique(const char *name) int i; if (!name) - return(-1); + return -1; /* Don't search in the cache!! make a new * object font, this is for keep fonts threads safe. */ if (global_font_num+1 >= BLF_MAX_FONT) { printf("Too many fonts!!!\n"); - return(-1); + return -1; } filename= blf_dir_search(name); if (!filename) { printf("Can't find font: %s\n", name); - return(-1); + return -1; } font= blf_font_new(name, filename); @@ -207,22 +207,22 @@ int BLF_load_unique(const char *name) if (!font) { printf("Can't load font: %s\n", name); - return(-1); + return -1; } global_font[global_font_num]= font; i= global_font_num; global_font_num++; - return(i); + return i; } void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) + if (font) { blf_font_attach_from_mem(font, mem, mem_size); + } } int BLF_load_mem(const char *name, unsigned char *mem, int mem_size) @@ -231,34 +231,34 @@ int BLF_load_mem(const char *name, unsigned char *mem, int mem_size) int i; if (!name) - return(-1); + return -1; i= blf_search(name); if (i >= 0) { /*font= global_font[i];*/ /*UNUSED*/ - return(i); + return i; } if (global_font_num+1 >= BLF_MAX_FONT) { printf("Too many fonts!!!\n"); - return(-1); + return -1; } if (!mem || !mem_size) { printf("Can't load font: %s from memory!!\n", name); - return(-1); + return -1; } font= blf_font_new_from_mem(name, mem, mem_size); if (!font) { printf("Can't load font: %s from memory!!\n", name); - return(-1); + return -1; } global_font[global_font_num]= font; i= global_font_num; global_font_num++; - return(i); + return i; } int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size) @@ -267,7 +267,7 @@ int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size) int i; if (!name) - return(-1); + return -1; /* * Don't search in the cache, make a new object font! @@ -275,33 +275,33 @@ int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size) */ if (global_font_num+1 >= BLF_MAX_FONT) { printf("Too many fonts!!!\n"); - return(-1); + return -1; } if (!mem || !mem_size) { printf("Can't load font: %s from memory!!\n", name); - return(-1); + return -1; } font= blf_font_new_from_mem(name, mem, mem_size); if (!font) { printf("Can't load font: %s from memory!!\n", name); - return(-1); + return -1; } global_font[global_font_num]= font; i= global_font_num; global_font_num++; - return(i); + return i; } void BLF_enable(int fontid, int option) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) + if (font) { font->flags |= option; + } } const char* BLF_gettext(const char *msgid) @@ -317,36 +317,35 @@ const char* BLF_gettext(const char *msgid) void BLF_disable(int fontid, int option) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) + if (font) { font->flags &= ~option; + } } void BLF_enable_default(int option) { - FontBLF *font; + FontBLF *font= BLF_get(global_font_default); - font= BLF_get(global_font_default); - if (font) + if (font) { font->flags |= option; + } } void BLF_disable_default(int option) { - FontBLF *font; + FontBLF *font= BLF_get(global_font_default); - font= BLF_get(global_font_default); - if (font) + if (font) { font->flags &= ~option; + } } void BLF_aspect(int fontid, float x, float y, float z) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); if (font) { font->aspect[0]= x; font->aspect[1]= y; @@ -354,26 +353,23 @@ void BLF_aspect(int fontid, float x, float y, float z) } } -void BLF_matrix(int fontid, double *m) +void BLF_matrix(int fontid, const double m[16]) { - FontBLF *font; - int i; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); if (font) { - for (i= 0; i < 16; i++) - font->m[i]= m[i]; + memcpy(font->m, m, sizeof(font->m)); } } void BLF_position(int fontid, float x, float y, float z) { - FontBLF *font; - float remainder; - float xa, ya, za; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); if (font) { + float xa, ya, za; + float remainder; + if (font->flags & BLF_ASPECT) { xa= font->aspect[0]; ya= font->aspect[1]; @@ -417,20 +413,20 @@ void BLF_position(int fontid, float x, float y, float z) void BLF_size(int fontid, int size, int dpi) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) + if (font) { blf_font_size(font, size, dpi); + } } void BLF_blur(int fontid, int size) { - FontBLF *font; - - font= BLF_get(fontid); - if (font) + FontBLF *font= BLF_get(fontid); + + if (font) { font->blur= size; + } } void BLF_draw_default(float x, float y, float z, const char *str, size_t len) @@ -472,11 +468,11 @@ void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t l void BLF_rotation_default(float angle) { - FontBLF *font; + FontBLF *font= BLF_get(global_font_default); - font= BLF_get(global_font_default); - if (font) + if (font) { font->angle= angle; + } } static void blf_draw__start(FontBLF *font) @@ -502,6 +498,13 @@ static void blf_draw__start(FontBLF *font) if (font->flags & BLF_ROTATION) glRotatef(font->angle, 0.0f, 0.0f, 1.0f); + + if(font->shadow || font->blur) + glGetFloatv(GL_CURRENT_COLOR, font->orig_col); + + /* always bind the texture for the first glyph */ + font->tex_bind_state= -1; + } static void blf_draw__end(void) @@ -514,7 +517,8 @@ static void blf_draw__end(void) void BLF_draw(int fontid, const char *str, size_t len) { FontBLF *font= BLF_get(fontid); - if (font) { + + if (font && font->glyph_cache) { blf_draw__start(font); blf_font_draw(font, str, len); blf_draw__end(); @@ -524,7 +528,8 @@ void BLF_draw(int fontid, const char *str, size_t len) void BLF_draw_ascii(int fontid, const char *str, size_t len) { FontBLF *font= BLF_get(fontid); - if (font) { + + if (font && font->glyph_cache) { blf_draw__start(font); blf_font_draw_ascii(font, str, len); blf_draw__end(); @@ -533,148 +538,141 @@ void BLF_draw_ascii(int fontid, const char *str, size_t len) void BLF_boundbox(int fontid, const char *str, rctf *box) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) + if (font) { blf_font_boundbox(font, str, box); + } } void BLF_width_and_height(int fontid, const char *str, float *width, float *height) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) + if (font && font->glyph_cache) { blf_font_width_and_height(font, str, width, height); + } } float BLF_width(int fontid, const char *str) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) - return(blf_font_width(font, str)); - return(0.0f); + if (font && font->glyph_cache) { + return blf_font_width(font, str); + } + + return 0.0f; } float BLF_fixed_width(int fontid) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); + + if (font && font->glyph_cache) { + return blf_font_fixed_width(font); + } - font= BLF_get(fontid); - if (font) - return(blf_font_fixed_width(font)); - return(0.0f); + return 0.0f; } float BLF_width_default(const char *str) { - float width; - if (global_font_default == -1) global_font_default= blf_search("default"); if (global_font_default == -1) { printf("Error: Can't found default font!!\n"); - return(0.0f); + return 0.0f; } BLF_size(global_font_default, global_font_points, global_font_dpi); - width= BLF_width(global_font_default, str); - return(width); + return BLF_width(global_font_default, str); } float BLF_height(int fontid, const char *str) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) - return(blf_font_height(font, str)); - return(0.0f); + if (font && font->glyph_cache) { + return blf_font_height(font, str); + } + + return 0.0f; } float BLF_height_max(int fontid) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) { - if(font->glyph_cache) - return(font->glyph_cache->max_glyph_height); + if (font && font->glyph_cache) { + return font->glyph_cache->max_glyph_height; } - return(0.0f); + + return 0.0f; } float BLF_width_max(int fontid) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) { - if(font->glyph_cache) - return(font->glyph_cache->max_glyph_width); + if (font && font->glyph_cache) { + return font->glyph_cache->max_glyph_width; } - return(0.0f); + + return 0.0f; } float BLF_descender(int fontid) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) { - if(font->glyph_cache) - return(font->glyph_cache->descender); + if (font && font->glyph_cache) { + return font->glyph_cache->descender; } - return(0.0f); + + return 0.0f; } float BLF_ascender(int fontid) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) { - if(font->glyph_cache) - return(font->glyph_cache->ascender); + if (font && font->glyph_cache) { + return font->glyph_cache->ascender; } - return(0.0f); + + return 0.0f; } float BLF_height_default(const char *str) { - float height; - if (global_font_default == -1) global_font_default= blf_search("default"); if (global_font_default == -1) { printf("Error: Can't found default font!!\n"); - return(0.0f); + return 0.0f; } BLF_size(global_font_default, global_font_points, global_font_dpi); - height= BLF_height(global_font_default, str); - return(height); + + return BLF_height(global_font_default, str); } void BLF_rotation(int fontid, float angle) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) + if (font) { font->angle= angle; + } } void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); if (font) { font->clip_rec.xmin= xmin; font->clip_rec.ymin= ymin; @@ -685,9 +683,8 @@ void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax) void BLF_clipping_default(float xmin, float ymin, float xmax, float ymax) { - FontBLF *font; + FontBLF *font= BLF_get(global_font_default); - font= BLF_get(global_font_default); if (font) { font->clip_rec.xmin= xmin; font->clip_rec.ymin= ymin; @@ -698,9 +695,8 @@ void BLF_clipping_default(float xmin, float ymin, float xmax, float ymax) void BLF_shadow(int fontid, int level, float r, float g, float b, float a) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); if (font) { font->shadow= level; font->shadow_col[0]= r; @@ -712,9 +708,8 @@ void BLF_shadow(int fontid, int level, float r, float g, float b, float a) void BLF_shadow_offset(int fontid, int x, int y) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); if (font) { font->shadow_x= x; font->shadow_y= y; @@ -723,9 +718,8 @@ void BLF_shadow_offset(int fontid, int x, int y) void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); if (font) { font->b_fbuf= fbuf; font->b_cbuf= cbuf; @@ -737,9 +731,8 @@ void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int void BLF_buffer_col(int fontid, float r, float g, float b, float a) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); if (font) { font->b_col[0]= r; font->b_col[1]= g; @@ -750,9 +743,9 @@ void BLF_buffer_col(int fontid, float r, float g, float b, float a) void BLF_draw_buffer(int fontid, const char *str) { - FontBLF *font; + FontBLF *font= BLF_get(fontid); - font= BLF_get(fontid); - if (font) + if (font && font->glyph_cache && (font->b_fbuf || font->b_cbuf)) { blf_font_buffer(font, str); + } } diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c index fd874d991ea..1c99af0c7a9 100644 --- a/source/blender/blenfont/intern/blf_dir.c +++ b/source/blender/blenfont/intern/blf_dir.c @@ -62,10 +62,10 @@ static DirBLF *blf_dir_find(const char *path) p= global_font_dir.first; while (p) { if (BLI_path_cmp(p->path, path) == 0) - return(p); + return p; p= p->next; } - return(NULL); + return NULL; } void BLF_dir_add(const char *path) @@ -102,7 +102,7 @@ char **BLF_dir_get(int *ndir) count= BLI_countlist(&global_font_dir); if (!count) - return(NULL); + return NULL; dirs= (char **)MEM_mallocN(sizeof(char *) * count, "BLF_dir_get"); p= global_font_dir.first; @@ -113,7 +113,7 @@ char **BLF_dir_get(int *ndir) p= p->next; } *ndir= i; - return(dirs); + return dirs; } void BLF_dir_free(char **dirs, int count) @@ -147,8 +147,8 @@ char *blf_dir_search(const char *file) if (BLI_exist(file)) s= BLI_strdup(file); } - - return(s); + + return s; } #if 0 // UNUSED @@ -171,9 +171,9 @@ int blf_dir_split(const char *str, char *file, int *size) file[i+4]= '\0'; s++; *size= atoi(s); - return(1); + return 1; } - return(0); + return 0; } #endif @@ -188,9 +188,9 @@ char *blf_dir_metrics_search(const char *filename) mfile= BLI_strdup(filename); s= strrchr(mfile, '.'); if (s) { - if (strlen(s) < 4) { + if (BLI_strnlen(s, 4) < 4) { MEM_freeN(mfile); - return(NULL); + return NULL; } s++; s[0]= 'a'; @@ -199,14 +199,14 @@ char *blf_dir_metrics_search(const char *filename) /* first check .afm */ if (BLI_exist(s)) - return(s); + return s; /* and now check .pfm */ s[0]= 'p'; if (BLI_exist(s)) - return(s); + return s; } MEM_freeN(mfile); - return(NULL); + return NULL; } diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 3bec7dd2626..f3f3b759e5c 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -62,7 +62,7 @@ static FT_Library ft_lib; int blf_font_init(void) { - return(FT_Init_FreeType(&ft_lib)); + return FT_Init_FreeType(&ft_lib); } void blf_font_exit(void) @@ -136,26 +136,33 @@ static void blf_font_ensure_ascii_table(FontBLF *font) } \ +#define BLF_KERNING_VARS(_font, _has_kerning, _kern_mode) \ + const short has_kerning= FT_HAS_KERNING((_font)->face); \ + const FT_UInt kern_mode= (has_kerning == 0) ? 0 : \ + (((_font)->flags & BLF_KERNING_DEFAULT) ? \ + ft_kerning_default : FT_KERNING_UNFITTED) \ + \ + + +#define BLF_KERNING_STEP(_font, kern_mode, g_prev, g, delta, pen_x) \ +{ \ + if (g_prev) { \ + delta.x= delta.y= 0; \ + if (FT_Get_Kerning((_font)->face, g_prev->idx, g->idx, kern_mode, &delta) == 0) \ + pen_x += delta.x >> 6; \ + } \ +} \ void blf_font_draw(FontBLF *font, const char *str, unsigned int len) { unsigned int c; - GlyphBLF *g, *g_prev; + GlyphBLF *g, *g_prev= NULL; FT_Vector delta; - int pen_x, pen_y; - int has_kerning, st; - unsigned int i; - GlyphBLF **glyph_ascii_table; - - if (!font->glyph_cache) - return; - glyph_ascii_table= font->glyph_cache->glyph_ascii_table; + int pen_x= 0, pen_y= 0; + unsigned int i= 0; + GlyphBLF **glyph_ascii_table= font->glyph_cache->glyph_ascii_table; - i= 0; - pen_x= 0; - pen_y= 0; - has_kerning= FT_HAS_KERNING(font->face); - g_prev= NULL; + BLF_KERNING_VARS(font, has_kerning, kern_mode); blf_font_ensure_ascii_table(font); @@ -163,25 +170,9 @@ void blf_font_draw(FontBLF *font, const char *str, unsigned int len) BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table); - if (c == 0) - break; - - /* if we don't found a glyph, skip it. */ - if (!g) - continue; - - if (has_kerning && g_prev) { - delta.x= 0; - delta.y= 0; - - if (font->flags & BLF_KERNING_DEFAULT) - st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta); - else - st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta); - - if (st == 0) - pen_x += delta.x >> 6; - } + if (c == 0) break; + if (g == NULL) continue; + if (has_kerning) BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x); /* do not return this loop if clipped, we want every character tested */ blf_glyph_render(font, g, (float)pen_x, (float)pen_y); @@ -194,43 +185,19 @@ void blf_font_draw(FontBLF *font, const char *str, unsigned int len) /* faster version of blf_font_draw, ascii only for view dimensions */ void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len) { - char c; - GlyphBLF *g, *g_prev; + unsigned char c; + GlyphBLF *g, *g_prev= NULL; FT_Vector delta; - int pen_x, pen_y; - int has_kerning, st; - GlyphBLF **glyph_ascii_table; - - if (!font->glyph_cache) - return; - glyph_ascii_table= font->glyph_cache->glyph_ascii_table; + int pen_x= 0, pen_y= 0; + GlyphBLF **glyph_ascii_table= font->glyph_cache->glyph_ascii_table; - pen_x= 0; - pen_y= 0; - has_kerning= FT_HAS_KERNING(font->face); - g_prev= NULL; + BLF_KERNING_VARS(font, has_kerning, kern_mode); blf_font_ensure_ascii_table(font); while ((c= *(str++)) && len--) { - g= glyph_ascii_table[c]; - - /* if we don't found a glyph, skip it. */ - if (!g) - continue; - - if (has_kerning && g_prev) { - delta.x= 0; - delta.y= 0; - - if (font->flags & BLF_KERNING_DEFAULT) - st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta); - else - st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta); - - if (st == 0) - pen_x += delta.x >> 6; - } + if ((g= glyph_ascii_table[c]) == NULL) continue; + if (has_kerning) BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x); /* do not return this loop if clipped, we want every character tested */ blf_glyph_render(font, g, (float)pen_x, (float)pen_y); @@ -240,59 +207,37 @@ void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len) } } +/* Sanity checks are done by BLF_draw_buffer() */ void blf_font_buffer(FontBLF *font, const char *str) { - unsigned char *cbuf; unsigned int c; - unsigned char b_col_char[4]; - GlyphBLF *g, *g_prev; + GlyphBLF *g, *g_prev= NULL; FT_Vector delta; + int pen_x= (int)font->pos[0], pen_y= 0; + unsigned int i= 0; + GlyphBLF **glyph_ascii_table= font->glyph_cache->glyph_ascii_table; + + /* buffer spesific vars*/ + const unsigned char b_col_char[4]= {font->b_col[0] * 255, + font->b_col[1] * 255, + font->b_col[2] * 255, + font->b_col[3] * 255}; + unsigned char *cbuf; + int chx, chy; + int y, x; float a, *fbuf; - int pen_x, y, x; - int has_kerning, st, chx, chy; - unsigned int i; - GlyphBLF **glyph_ascii_table; - if (!font->glyph_cache || (!font->b_fbuf && !font->b_cbuf)) - return; - glyph_ascii_table= font->glyph_cache->glyph_ascii_table; - - i= 0; - pen_x= (int)font->pos[0]; - has_kerning= FT_HAS_KERNING(font->face); - g_prev= NULL; - - b_col_char[0]= font->b_col[0] * 255; - b_col_char[1]= font->b_col[1] * 255; - b_col_char[2]= font->b_col[2] * 255; - b_col_char[3]= font->b_col[3] * 255; + BLF_KERNING_VARS(font, has_kerning, kern_mode); blf_font_ensure_ascii_table(font); while (str[i]) { - int pen_y; BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table); - if (c == 0) - break; - - /* if we don't found a glyph, skip it. */ - if (!g) - continue; - - if (has_kerning && g_prev) { - delta.x= 0; - delta.y= 0; - - if (font->flags & BLF_KERNING_DEFAULT) - st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta); - else - st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta); - - if (st == 0) - pen_x += delta.x >> 6; - } + if (c == 0) break; + if (g == NULL) continue; + if (has_kerning) BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x); chx= pen_x + ((int)g->pos_x); chy= (int)font->pos[1] + g->height; @@ -392,69 +337,41 @@ void blf_font_buffer(FontBLF *font, const char *str) void blf_font_boundbox(FontBLF *font, const char *str, rctf *box) { unsigned int c; - GlyphBLF *g, *g_prev; + GlyphBLF *g, *g_prev= NULL; FT_Vector delta; + int pen_x= 0, pen_y= 0; + unsigned int i= 0; + GlyphBLF **glyph_ascii_table= font->glyph_cache->glyph_ascii_table; + rctf gbox; - int pen_x, pen_y; - int has_kerning, st; - unsigned int i; - GlyphBLF **glyph_ascii_table; - if (!font->glyph_cache) - return; + BLF_KERNING_VARS(font, has_kerning, kern_mode); box->xmin= 32000.0f; box->xmax= -32000.0f; box->ymin= 32000.0f; box->ymax= -32000.0f; - i= 0; - pen_x= 0; - pen_y= 0; - has_kerning= FT_HAS_KERNING(font->face); - g_prev= NULL; - blf_font_ensure_ascii_table(font); - glyph_ascii_table= font->glyph_cache->glyph_ascii_table; while (str[i]) { BLF_UTF8_NEXT_FAST(font, g, str, i, c, glyph_ascii_table); - if (c == 0) - break; - - /* if we don't found a glyph, skip it. */ - if (!g) - continue; - - if (has_kerning && g_prev) { - delta.x= 0; - delta.y= 0; - - if (font->flags & BLF_KERNING_DEFAULT) - st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, ft_kerning_default, &delta); - else - st= FT_Get_Kerning(font->face, g_prev->idx, g->idx, FT_KERNING_UNFITTED, &delta); - - if (st == 0) - pen_x += delta.x >> 6; - } + if (c == 0) break; + if (g == NULL) continue; + if (has_kerning) BLF_KERNING_STEP(font, kern_mode, g_prev, g, delta, pen_x); gbox.xmin= pen_x; gbox.xmax= pen_x + g->advance; gbox.ymin= g->box.ymin + pen_y; gbox.ymax= g->box.ymax + pen_y; - if (gbox.xmin < box->xmin) - box->xmin= gbox.xmin; - if (gbox.ymin < box->ymin) - box->ymin= gbox.ymin; + if (gbox.xmin < box->xmin) box->xmin= gbox.xmin; + if (gbox.ymin < box->ymin) box->ymin= gbox.ymin; - if (gbox.xmax > box->xmax) - box->xmax= gbox.xmax; - if (gbox.ymax > box->ymax) - box->ymax= gbox.ymax; + if (gbox.xmax > box->xmax) box->xmax= gbox.xmax; + if (gbox.ymax > box->ymax) box->ymax= gbox.ymax; pen_x += g->advance; g_prev= g; @@ -473,20 +390,18 @@ void blf_font_width_and_height(FontBLF *font, const char *str, float *width, flo float xa, ya; rctf box; - if (font->glyph_cache) { - if (font->flags & BLF_ASPECT) { - xa= font->aspect[0]; - ya= font->aspect[1]; - } - else { - xa= 1.0f; - ya= 1.0f; - } - - blf_font_boundbox(font, str, &box); - *width= ((box.xmax - box.xmin) * xa); - *height= ((box.ymax - box.ymin) * ya); + if (font->flags & BLF_ASPECT) { + xa= font->aspect[0]; + ya= font->aspect[1]; + } + else { + xa= 1.0f; + ya= 1.0f; } + + blf_font_boundbox(font, str, &box); + *width= ((box.xmax - box.xmin) * xa); + *height= ((box.ymax - box.ymin) * ya); } float blf_font_width(FontBLF *font, const char *str) @@ -494,16 +409,13 @@ float blf_font_width(FontBLF *font, const char *str) float xa; rctf box; - if (!font->glyph_cache) - return(0.0f); - if (font->flags & BLF_ASPECT) xa= font->aspect[0]; else xa= 1.0f; blf_font_boundbox(font, str, &box); - return((box.xmax - box.xmin) * xa); + return (box.xmax - box.xmin) * xa; } float blf_font_height(FontBLF *font, const char *str) @@ -511,36 +423,28 @@ float blf_font_height(FontBLF *font, const char *str) float ya; rctf box; - if (!font->glyph_cache) - return(0.0f); - if (font->flags & BLF_ASPECT) ya= font->aspect[1]; else ya= 1.0f; blf_font_boundbox(font, str, &box); - return((box.ymax - box.ymin) * ya); + return (box.ymax - box.ymin) * ya; } float blf_font_fixed_width(FontBLF *font) { - GlyphBLF *g; - FT_UInt glyph_index; - unsigned int c = ' '; - - if (!font->glyph_cache) - return 0.0f; - - glyph_index= FT_Get_Char_Index(font->face, c); - g= blf_glyph_search(font->glyph_cache, c); - if (!g) - g= blf_glyph_add(font, glyph_index, c); - - /* if we don't find the glyph. */ - if (!g) - return 0.0f; - + const unsigned int c = ' '; + GlyphBLF *g= blf_glyph_search(font->glyph_cache, c); + if (!g) { + g= blf_glyph_add(font, FT_Get_Char_Index(font->face, c), c); + + /* if we don't find the glyph. */ + if (!g) { + return 0.0f; + } + } + return g->advance; } @@ -611,7 +515,7 @@ FontBLF *blf_font_new(const char *name, const char *filename) err= FT_New_Face(ft_lib, filename, 0, &font->face); if (err) { MEM_freeN(font); - return(NULL); + return NULL; } err= FT_Select_Charmap(font->face, ft_encoding_unicode); @@ -619,7 +523,7 @@ FontBLF *blf_font_new(const char *name, const char *filename) printf("Can't set the unicode character map!\n"); FT_Done_Face(font->face); MEM_freeN(font); - return(NULL); + return NULL; } mfile= blf_dir_metrics_search(filename); @@ -631,7 +535,7 @@ FontBLF *blf_font_new(const char *name, const char *filename) font->name= BLI_strdup(name); font->filename= BLI_strdup(filename); blf_font_fill(font); - return(font); + return font; } void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, int mem_size) @@ -653,7 +557,7 @@ FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_siz err= FT_New_Memory_Face(ft_lib, mem, mem_size, 0, &font->face); if (err) { MEM_freeN(font); - return(NULL); + return NULL; } err= FT_Select_Charmap(font->face, ft_encoding_unicode); @@ -661,11 +565,11 @@ FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_siz printf("Can't set the unicode character map!\n"); FT_Done_Face(font->face); MEM_freeN(font); - return(NULL); + return NULL; } font->name= BLI_strdup(name); font->filename= NULL; blf_font_fill(font); - return(font); + return font; } diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 9b39cb65cba..b661005b50b 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -64,10 +64,10 @@ GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi) p= (GlyphCacheBLF *)font->cache.first; while (p) { if (p->size == size && p->dpi == dpi) - return(p); + return p; p= p->next; } - return(NULL); + return NULL; } /* Create a new glyph cache for the current size and dpi. */ @@ -114,7 +114,7 @@ GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) gc->p2_height= 0; BLI_addhead(&font->cache, gc); - return(gc); + return gc; } void blf_glyph_cache_clear(FontBLF *font) @@ -185,7 +185,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) memset((void *)buf, 0, tot_mem); glGenTextures(1, &gc->textures[gc->cur_tex]); - glBindTexture(GL_TEXTURE_2D, gc->textures[gc->cur_tex]); + glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state= gc->textures[gc->cur_tex])); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -204,10 +204,10 @@ GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c) p= gc->bucket[key].first; while (p) { if (p->c == c) - return(p); + return p; p= p->next; } - return(NULL); + return NULL; } GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c) @@ -222,14 +222,14 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c) g= blf_glyph_search(font->glyph_cache, c); if (g) - return(g); + return g; if (sharp) err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_MONO); else err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); /* Sure about NO_* flags? */ if (err) - return(NULL); + return NULL; /* get the glyph. */ slot= font->face->glyph; @@ -248,7 +248,7 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c) } if (err || slot->format != FT_GLYPH_FORMAT_BITMAP) - return(NULL); + return NULL; g= (GlyphBLF *)MEM_mallocN(sizeof(GlyphBLF), "blf_glyph_add"); g->next= NULL; @@ -294,7 +294,7 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c) key= blf_hash(g->c); BLI_addhead(&(font->glyph_cache->bucket[key]), g); - return(g); + return g; } void blf_glyph_free(GlyphBLF *g) @@ -326,23 +326,25 @@ static void blf_texture_draw(float uv[2][2], float dx, float y1, float dx1, floa } -static void blf_texture5_draw(float uv[2][2], float x1, float y1, float x2, float y2) +static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2) { - float soft[25]= { - 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f, - 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f, - 2/60.0f, 5/60.0f, 8/60.0f, 5/60.0f, 2/60.0f, - 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f, - 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f}; + float soft[25]= {1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f, + 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f, + 2/60.0f, 5/60.0f, 8/60.0f, 5/60.0f, 2/60.0f, + 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f, + 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f}; float color[4], *fp= soft; int dx, dy; - - glGetFloatv(GL_CURRENT_COLOR, color); + + color[0]= shadow_col[0]; + color[1]= shadow_col[1]; + color[2]= shadow_col[2]; for(dx=-2; dx<3; dx++) { for(dy=-2; dy<3; dy++, fp++) { - glColor4f(color[0], color[1], color[2], fp[0]*color[3]); + color[3]= *(fp) * shadow_col[3]; + glColor4fv(color); blf_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy); } } @@ -350,17 +352,23 @@ static void blf_texture5_draw(float uv[2][2], float x1, float y1, float x2, floa glColor4fv(color); } -static void blf_texture3_draw(float uv[2][2], float x1, float y1, float x2, float y2) +static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2) { - float soft[9]= {1/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 4/16.0f, 2/16.0f, 1/16.0f, 2/16.0f, 1/16.0f}; + float soft[9]= {1/16.0f, 2/16.0f, 1/16.0f, + 2/16.0f,4/16.0f, 2/16.0f, + 1/16.0f, 2/16.0f, 1/16.0f}; + float color[4], *fp= soft; int dx, dy; - - glGetFloatv(GL_CURRENT_COLOR, color); - + + color[0]= shadow_col[0]; + color[1]= shadow_col[1]; + color[2]= shadow_col[2]; + for(dx=-1; dx<2; dx++) { for(dy=-1; dy<2; dy++, fp++) { - glColor4f(color[0], color[1], color[2], fp[0]*color[3]); + color[3]= *(fp) * shadow_col[3]; + glColor4fv(color); blf_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy); } } @@ -370,18 +378,15 @@ static void blf_texture3_draw(float uv[2][2], float x1, float y1, float x2, floa int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) { - GlyphCacheBLF *gc; - GLint cur_tex; float dx, dx1; float y1, y2; float xo, yo; - float color[4]; if ((!g->width) || (!g->height)) - return(1); + return 1; if (g->build_tex == 0) { - gc= font->glyph_cache; + GlyphCacheBLF *gc= font->glyph_cache; if (font->max_tex_size == -1) glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint *)&font->max_tex_size); @@ -444,31 +449,36 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) if (font->flags & BLF_CLIPPING) { if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], y1 + font->pos[1])) - return(0); + return 0; if (!BLI_in_rctf(&font->clip_rec, dx + font->pos[0], y2 + font->pos[1])) - return(0); + return 0; if (!BLI_in_rctf(&font->clip_rec, dx1 + font->pos[0], y2 + font->pos[1])) - return(0); + return 0; if (!BLI_in_rctf(&font->clip_rec, dx1 + font->pos[0], y1 + font->pos[1])) - return(0); + return 0; } - glGetIntegerv(GL_TEXTURE_2D_BINDING_EXT, &cur_tex); - if (cur_tex != g->tex) - glBindTexture(GL_TEXTURE_2D, g->tex); + if (font->tex_bind_state != g->tex) { + glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state= g->tex)); + } if (font->flags & BLF_SHADOW) { - glGetFloatv(GL_CURRENT_COLOR, color); - glColor4fv(font->shadow_col); - - if (font->shadow == 3) - blf_texture3_draw(g->uv, dx, y1, dx1, y2); - else if (font->shadow == 5) - blf_texture5_draw(g->uv, dx, y1, dx1, y2); - else - blf_texture_draw(g->uv, dx, y1, dx1, y2); - glColor4fv(color); + switch(font->shadow) { + case 3: + blf_texture3_draw(font->shadow_col, g->uv, dx, y1, dx1, y2); + break; + case 5: + blf_texture5_draw(font->shadow_col, g->uv, dx, y1, dx1, y2); + break; + default: + glColor4fv(font->shadow_col); + blf_texture_draw(g->uv, dx, y1, dx1, y2); + break; + } + + glColor4fv(font->orig_col); + x= xo; y= yo; @@ -478,12 +488,17 @@ int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y) y2= y + g->pos_y - g->height; } - if (font->blur==3) - blf_texture3_draw(g->uv, dx, y1, dx1, y2); - else if (font->blur==5) - blf_texture5_draw(g->uv, dx, y1, dx1, y2); - else - blf_texture_draw(g->uv, dx, y1, dx1, y2); + switch(font->blur) { + case 3: + blf_texture3_draw(font->orig_col, g->uv, dx, y1, dx1, y2); + break; + case 5: + blf_texture5_draw(font->orig_col, g->uv, dx, y1, dx1, y2); + break; + default: + blf_texture_draw(g->uv, dx, y1, dx1, y2); + break; + } - return(1); + return 1; } diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index 9840e6446ef..1450ad39ad8 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -161,7 +161,10 @@ typedef struct FontBLF { /* shadow color. */ float shadow_col[4]; - + + /* store color here when drawing shadow or blur. */ + float orig_col[4]; + /* Multiplied this matrix with the current one before * draw the text! see blf_draw__start. */ @@ -179,6 +182,9 @@ typedef struct FontBLF { /* max texture size. */ int max_tex_size; + /* current opengl texture bind, avoids calling glGet */ + int tex_bind_state; + /* font options. */ int flags; diff --git a/source/blender/blenfont/intern/blf_util.c b/source/blender/blenfont/intern/blf_util.c index edd23ac1ba6..cfe77887674 100644 --- a/source/blender/blenfont/intern/blf_util.c +++ b/source/blender/blenfont/intern/blf_util.c @@ -46,7 +46,7 @@ unsigned int blf_next_p2(unsigned int x) x |= (x >> 2); x |= (x >> 1); x += 1; - return(x); + return x; } unsigned int blf_hash(unsigned int val) @@ -60,7 +60,7 @@ unsigned int blf_hash(unsigned int val) key ^= (key >> 13); key += ~(key << 9); key ^= (key >> 17); - return(key % 257); + return key % 257; } /* @@ -85,7 +85,7 @@ int blf_utf8_next(unsigned char *buf, unsigned int *iindex) d= buf[index++]; if (!d) - return(0); + return 0; while (buf[index] && ((buf[index] & 0xc0) == 0x80)) index++; @@ -124,5 +124,5 @@ int blf_utf8_next(unsigned char *buf, unsigned int *iindex) r |= (d4 & 0x3f); } *iindex= index; - return(r); + return r; } diff --git a/source/blender/blenkernel/BKE_endian.h b/source/blender/blenkernel/BKE_endian.h deleted file mode 100644 index 5647645e990..00000000000 --- a/source/blender/blenkernel/BKE_endian.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * $Id$ - * - * ***** BEGIN GPL LICENSE BLOCK ***** - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. - * All rights reserved. - * - * The Original Code is: all of this file. - * - * Contributor(s): none yet. - * - * ***** END GPL LICENSE BLOCK ***** - * Are we little or big endian? From Harbison&Steele. - */ -#ifndef BKE_ENDIAN_H -#define BKE_ENDIAN_H - -/** \file BKE_endian.h - * \ingroup bke - */ - -/** - * BKE_ENDIANNESS(a) returns 1 if big endian and returns 0 if little endian - */ -#define BKE_ENDIANNESS(a) { \ - union { \ - intptr_t l; \ - char c[sizeof (intptr_t)]; \ - } u; \ - u.l = 1; \ - a = (u.c[sizeof (intptr_t) - 1] == 1) ? 1 : 0; \ -} - -#endif - diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 0e48673f1b1..a59d43d315d 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -151,9 +151,18 @@ typedef struct Global { /* ENDIAN_ORDER: indicates what endianness the platform where the file was * written had. */ +#if !defined( __BIG_ENDIAN__ ) && !defined( __LITTLE_ENDIAN__ ) +# error Either __BIG_ENDIAN__ or __LITTLE_ENDIAN__ must be defined. +#endif + #define L_ENDIAN 1 #define B_ENDIAN 0 -extern short ENDIAN_ORDER; + +#ifdef __BIG_ENDIAN__ +# define ENDIAN_ORDER B_ENDIAN +#else +# define ENDIAN_ORDER L_ENDIAN +#endif /* G.moving, signals drawing in (3d) window to denote transform */ #define G_TRANSFORM_OBJ 1 diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 14e622c972e..87684e4895d 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -47,18 +47,18 @@ /* this weirdo pops up in two places ... */ #if !defined(WIN32) -#ifndef O_BINARY -#define O_BINARY 0 -#endif +# ifndef O_BINARY +# define O_BINARY 0 +# endif #endif /* INTEGER CODES */ -#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__) - /* Big Endian */ -#define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) ) +#ifdef __BIG_ENDIAN__ + /* Big Endian */ +# define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) ) #else - /* Little Endian */ -#define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) ) + /* Little Endian */ +# define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) ) #endif #define ID_NEW(a) if( (a) && (a)->id.newid ) (a)= (void *)(a)->id.newid @@ -74,11 +74,11 @@ #define ENDB MAKE_ID('E','N','D','B') /* Bit operations */ -#define BTST(a,b) ( ( (a) & 1<<(b) )!=0 ) -#define BNTST(a,b) ( ( (a) & 1<<(b) )==0 ) -#define BTST2(a,b,c) ( BTST( (a), (b) ) || BTST( (a), (c) ) ) -#define BSET(a,b) ( (a) | 1<<(b) ) -#define BCLR(a,b) ( (a) & ~(1<<(b)) ) +#define BTST(a,b) ( ( (a) & 1<<(b) )!=0 ) +#define BNTST(a,b) ( ( (a) & 1<<(b) )==0 ) +#define BTST2(a,b,c) ( BTST( (a), (b) ) || BTST( (a), (c) ) ) +#define BSET(a,b) ( (a) | 1<<(b) ) +#define BCLR(a,b) ( (a) & ~(1<<(b)) ) /* bit-row */ #define BROW(min, max) (((max)>=31? 0xFFFFFFFF: (1<<(max+1))-1) - ((min)? ((1<<(min))-1):0) ) diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index b800c94a09c..5de78bd7a6b 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -179,7 +179,6 @@ set(SRC BKE_depsgraph.h BKE_displist.h BKE_effect.h - BKE_endian.h BKE_fcurve.h BKE_fluidsim.h BKE_font.h diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 9c2467505cd..73ddcbecf94 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -117,7 +117,7 @@ static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr) tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr; if (adt->action == mlac->act) { - if (id->lib==0) { + if (id->lib == NULL) { adt->action = mlac->actn; id_us_plus(&mlac->actn->id); @@ -524,7 +524,6 @@ void copy_pose (bPose **dst, bPose *src, int copycon) if (copycon) { copy_constraints(&listb, &pchan->constraints, TRUE); // copy_constraints NULLs listb pchan->constraints= listb; - pchan->path= NULL; // XXX remove this line when the new motionpaths are ready... (depreceated code) pchan->mpath= NULL; /* motion paths should not get copied yet... */ } @@ -595,17 +594,12 @@ void free_pose_channels_hash(bPose *pose) void free_pose_channel(bPoseChannel *pchan) { - // XXX this case here will need to be removed when the new motionpaths are ready - if (pchan->path) { - MEM_freeN(pchan->path); - pchan->path= NULL; - } - + if (pchan->mpath) { animviz_free_motionpath(pchan->mpath); pchan->mpath= NULL; } - + free_constraints(&pchan->constraints); if (pchan->prop) { diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 9ca11db7fce..824bbb8f70d 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1143,11 +1143,11 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa w= (mv4)? 0.25f: 1.0f/3.0f; if(orco) { - VECADDFAC(dob->orco, dob->orco, orco[mv1], w); - VECADDFAC(dob->orco, dob->orco, orco[mv2], w); - VECADDFAC(dob->orco, dob->orco, orco[mv3], w); + madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv1], w); + madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv2], w); + madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv3], w); if(mv4) - VECADDFAC(dob->orco, dob->orco, orco[mv4], w); + madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv4], w); } if(mtface) { diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 62ce184a2d7..08a95477c2e 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -1483,7 +1483,6 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected pchanw.next= pchan->next; pchanw.parent= pchan->parent; pchanw.child= pchan->child; - pchanw.path= NULL; /* this is freed so copy a copy, else undo crashes */ if(pchanw.prop) { diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 2d4354bdd9f..2b6261b1c81 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -98,7 +98,6 @@ Global G; UserDef U; /* ListBase = {NULL, NULL}; */ -short ENDIAN_ORDER; char versionstr[48]= ""; @@ -132,9 +131,6 @@ void initglobals(void) strcpy(G.ima, "//"); - ENDIAN_ORDER= 1; - ENDIAN_ORDER= (((char*)&ENDIAN_ORDER)[0])? L_ENDIAN: B_ENDIAN; - if(BLENDER_SUBVERSION) BLI_snprintf(versionstr, sizeof(versionstr), "blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION); else diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index e0b7ebe1f44..d8b51973948 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -2021,7 +2021,7 @@ static int cloth_collision_moving_edges ( ClothModifierData *clmd, CollisionModi { if(edgecollpair.p21==6 || edgecollpair.p22 == 6) { - printf("dist: %f, sol[k]: %lf, sol2[k]: %lf\n", distance, solution[k], solution2[k]); + printf("dist: %f, sol[k]: %f, sol2[k]: %f\n", distance, solution[k], solution2[k]); printf("a1: %f, a2: %f, b1: %f, b2: %f\n", x1[0], x2[0], x3[0], v1[0]); printf("b21: %d, b22: %d\n", edgecollpair.p21, edgecollpair.p22); } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 91091d3880f..a59092784dd 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -2167,7 +2167,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint if (data->type < 10) { /* extract rotation (is in whatever space target should be in) */ mat4_to_eul(vec, tempmat); - mul_v3_fl(vec, (float)(180.0/M_PI)); /* rad -> deg */ + mul_v3_fl(vec, RAD2DEGF(1.0f)); /* rad -> deg */ axis= data->type; } else if (data->type < 20) { @@ -3325,7 +3325,7 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * break; case 1: /* rotation (convert to degrees first) */ mat4_to_eulO(dvec, cob->rotOrder, ct->matrix); - mul_v3_fl(dvec, (float)(180.0/M_PI)); /* rad -> deg */ + mul_v3_fl(dvec, RAD2DEGF(1.0f)); /* rad -> deg */ break; default: /* location */ copy_v3_v3(dvec, ct->matrix[3]); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index bd70e365f51..794006e6f39 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1924,7 +1924,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) /* flip rotation if needs be */ cross_v3_v3v3(cross_tmp, vec_1, vec_2); normalize_v3(cross_tmp); - if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < 90.0f/(float)(180.0/M_PI)) + if(angle_normalized_v3v3(bevp_first->dir, cross_tmp) < DEG2RADF(90.0f)) angle = -angle; bevp2= (BevPoint *)(bl+1); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 468f39bf731..7fb9f96e0cf 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -571,7 +571,7 @@ float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *UNU if(falloff == 0.0f) break; - r_fac=saacos(fac/len_v3(efd->vec_to_point))*180.0f/(float)M_PI; + r_fac= RAD2DEGF(saacos(fac/len_v3(efd->vec_to_point))); falloff*= falloff_func_rad(eff->pd, r_fac); break; diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 4ce5de78895..002cfdbf41a 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -592,7 +592,7 @@ void BKE_image_print_memlist(void) for(ima= G.main->image.first; ima; ima= ima->id.next) totsize += image_mem_size(ima); - printf("\ntotal image memory len: %.3lf MB\n", (double)totsize/(double)(1024*1024)); + printf("\ntotal image memory len: %.3f MB\n", (double)totsize/(double)(1024*1024)); for(ima= G.main->image.first; ima; ima= ima->id.next) { size= image_mem_size(ima); diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 0d3f3cc5ae4..5acd6c169a0 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -942,7 +942,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", seq->name+2); } else - strcpy(buf, ""); /* empty string */ + buf[0]= '\0'; /* empty string */ BLI_dynstr_append(path, buf); /* need to add dot before property if there was anything precceding this */ diff --git a/source/blender/blenkernel/intern/navmesh_conversion.cpp b/source/blender/blenkernel/intern/navmesh_conversion.cpp index 9b373db59ff..fbc4775cf34 100644 --- a/source/blender/blenkernel/intern/navmesh_conversion.cpp +++ b/source/blender/blenkernel/intern/navmesh_conversion.cpp @@ -290,27 +290,15 @@ struct SortContext const int* trisToFacesMap; }; -#ifdef FREE_WINDOWS -static SortContext *_mingw_context; +/* XXX: not thread-safe, but it's called only from modifiers stack + which isn't threaded. Anyway, better to avoid this in the future */ +static SortContext *_qsort_context; + static int compareByData(const void * a, const void * b) { - return ( _mingw_context->recastData[_mingw_context->trisToFacesMap[*(int*)a]] - - _mingw_context->recastData[_mingw_context->trisToFacesMap[*(int*)b]] ); -} -#else -#if defined(_MSC_VER) -static int compareByData(void* data, const void * a, const void * b) -#elif defined(__APPLE__) || defined(__FreeBSD__) -static int compareByData(void* data, const void * a, const void * b) -#else -static int compareByData(const void * a, const void * b, void* data) -#endif -{ - const SortContext* context = (const SortContext*)data; - return ( context->recastData[context->trisToFacesMap[*(int*)a]] - - context->recastData[context->trisToFacesMap[*(int*)b]] ); + return ( _qsort_context->recastData[_qsort_context->trisToFacesMap[*(int*)a]] - + _qsort_context->recastData[_qsort_context->trisToFacesMap[*(int*)b]] ); } -#endif bool buildNavMeshData(const int nverts, const float* verts, const int ntris, const unsigned short *tris, @@ -333,16 +321,8 @@ bool buildNavMeshData(const int nverts, const float* verts, SortContext context; context.recastData = recastData; context.trisToFacesMap = trisToFacesMap; -#if defined(_MSC_VER) - qsort_s(trisMapping, ntris, sizeof(int), compareByData, &context); -#elif defined(__APPLE__) || defined(__FreeBSD__) - qsort_r(trisMapping, ntris, sizeof(int), &context, compareByData); -#elif defined(FREE_WINDOWS) - _mingw_context = &context; + _qsort_context = &context; qsort(trisMapping, ntris, sizeof(int), compareByData); -#else - qsort_r(trisMapping, ntris, sizeof(int), compareByData, &context); -#endif //search first valid triangle - triangle of convex polygon int validTriStart = -1; for (int i=0; i< ntris; i++) diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index d40b030c470..89fd3ff9c13 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -1051,9 +1051,9 @@ void ntreeMakeLocal(bNodeTree *ntree) if(ntree->id.lib==NULL) return; if(ntree->id.us==1) { - ntree->id.lib= 0; + ntree->id.lib= NULL; ntree->id.flag= LIB_LOCAL; - new_id(0, (ID *)ntree, 0); + new_id(NULL, (ID *)ntree, NULL); return; } @@ -1069,7 +1069,7 @@ void ntreeMakeLocal(bNodeTree *ntree) if(cd.local && cd.lib==0) { ntree->id.lib= NULL; ntree->id.flag= LIB_LOCAL; - new_id(0, (ID *)ntree, 0); + new_id(NULL, (ID *)ntree, NULL); } else if(cd.local && cd.lib) { /* this is the mixed case, we copy the tree and assign it to local users */ @@ -1438,7 +1438,7 @@ static void ntree_update_link_pointers(bNodeTree *ntree) } } -void ntree_validate_links(bNodeTree *ntree) +static void ntree_validate_links(bNodeTree *ntree) { bNodeTreeType *ntreetype = ntreeGetType(ntree->type); bNodeLink *link; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index c2b561b122a..3644b02e7b5 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -418,7 +418,7 @@ void unlink_object(Object *ob) for (ct= targets.first; ct; ct= ct->next) { if (ct->tar == ob) { ct->tar = NULL; - strcpy(ct->subtarget, ""); + ct->subtarget[0]= '\0'; obt->recalc |= OB_RECALC_DATA; } } @@ -448,7 +448,7 @@ void unlink_object(Object *ob) for (ct= targets.first; ct; ct= ct->next) { if (ct->tar == ob) { ct->tar = NULL; - strcpy(ct->subtarget, ""); + ct->subtarget[0]= '\0'; obt->recalc |= OB_RECALC_DATA; } } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 60432631492..82a2436a010 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -2542,7 +2542,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle normalize_v3(v1); normalize_v3(v2); - d = saacos(dot_v3v3(v1, v2)) * 180.0f/(float)M_PI; + d = RAD2DEGF(saacos(dot_v3v3(v1, v2))); } if(p_max > p_min) diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 50b3e32278a..ef1b75e5913 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -277,8 +277,7 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar) ar->v2d.tab_offset= NULL; } - if(ar) - BLI_freelistN(&ar->panels); + BLI_freelistN(&ar->panels); } /* not area itself */ diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 43747fde729..e5d74177c91 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -2132,7 +2132,7 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x } // Rotate - rotate_radians = ((float)M_PI*transform->rotIni)/180.0f; + rotate_radians = DEG2RADF(transform->rotIni); transform_image(x,y, ibuf1, out, scale_x, scale_y, translate_x, translate_y, rotate_radians, transform->interpolation); } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index ff518d69e21..d17b769888b 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -1,11 +1,35 @@ +/* + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + /** \file blender/blenkernel/intern/sound.c * \ingroup bke */ -/** - * sound.c (mar-2001 nzc) - * - * $Id$ - */ #include <string.h> #include <stdlib.h> diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index 72fe1c19884..8aeef0d84b1 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -345,7 +345,7 @@ static int unit_as_string(char *str, int len_max, double value, int prec, bUnitC /* Convert to a string */ { - len= BLI_snprintf(str, len_max, "%.*lf", prec, value_conv); + len= BLI_snprintf(str, len_max, "%.*f", prec, value_conv); if(len >= len_max) len= len_max; diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 9a3b81e5776..456ee72c4e0 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -35,11 +35,11 @@ */ #ifndef FALSE -#define FALSE 0 +# define FALSE 0 #endif #ifndef TRUE -#define TRUE 1 +# define TRUE 1 #endif @@ -94,7 +94,7 @@ /* some math and copy defines */ #ifndef SWAP -#define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } +# define SWAP(type, a, b) { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; } #endif #define ABS(a) ( (a)<0 ? (-(a)) : (a) ) diff --git a/source/blender/blenlib/BLI_voxel.h b/source/blender/blenlib/BLI_voxel.h index 41f8bfab729..8dd95a897ae 100644 --- a/source/blender/blenlib/BLI_voxel.h +++ b/source/blender/blenlib/BLI_voxel.h @@ -36,9 +36,9 @@ #define V_I(x, y, z, res) ( (z)*(res)[1]*(res)[0] + (y)*(res)[0] + (x) ) /* all input coordinates must be in bounding box 0.0 - 1.0 */ -float voxel_sample_nearest(float *data, int *res, float *co); -float voxel_sample_trilinear(float *data, int *res, float *co); -float voxel_sample_triquadratic(float *data, int *res, float *co); -float voxel_sample_tricubic(float *data, int *res, float *co, int bspline); +float voxel_sample_nearest(float *data, const int res[3], const float co[3]); +float voxel_sample_trilinear(float *data, const int res[3], const float co[3]); +float voxel_sample_triquadratic(float *data, const int res[3], const float co[3]); +float voxel_sample_tricubic(float *data, const int res[3], const float co[3], int bspline); #endif /* BLI_VOXEL_H */ diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 5c37d3003e4..961a41690f7 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -1,5 +1,5 @@ /* - * $Id: + * $Id$ * * ***** BEGIN GPL LICENSE BLOCK ***** * @@ -23,15 +23,17 @@ * Contributor(s): Campbell Barton. * * ***** END GPL LICENSE BLOCK ***** - * + * */ - + /** \file blender/blenlib/intern/string_utf8.c * \ingroup bli */ - + #include <string.h> +#include "BLI_string.h" + /* from libswish3, originally called u8_isvalid(), * modified to return the index of the bad character (byte index not utf). * http://svn.swish-e.org/libswish3/trunk/src/libswish3/utf8.c r3044 - campbell */ @@ -145,18 +147,18 @@ int BLI_utf8_invalid_strip(char *str, int length) /* compatible with BLI_strncpy, but esnure no partial utf8 chars */ -/* array copied from glib's glib's gutf8.c, +/* array copied from glib's gutf8.c, * note: this looks to be at odd's with 'trailingBytesForUTF8', * need to find out what gives here! - campbell */ static const size_t utf8_skip_data[256] = { - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1 + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, + 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1 }; char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy) diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index d11386ff606..6d912be71d3 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -36,7 +36,7 @@ -BM_INLINE float D(float *data, int *res, int x, int y, int z) +BM_INLINE float D(float *data, const int res[3], int x, int y, int z) { CLAMP(x, 0, res[0]-1); CLAMP(y, 0, res[1]-1); @@ -46,7 +46,7 @@ BM_INLINE float D(float *data, int *res, int x, int y, int z) /* *** nearest neighbour *** */ /* input coordinates must be in bounding box 0.0 - 1.0 */ -float voxel_sample_nearest(float *data, int *res, float *co) +float voxel_sample_nearest(float *data, const int res[3], const float co[3]) { int xi, yi, zi; @@ -71,7 +71,7 @@ BM_INLINE int _clamp(int a, int b, int c) return (a < b) ? b : ((a > c) ? c : a); } -float voxel_sample_trilinear(float *data, int *res, float *co) +float voxel_sample_trilinear(float *data, const int res[3], const float co[3]) { if (data) { @@ -103,7 +103,7 @@ float voxel_sample_trilinear(float *data, int *res, float *co) } -float voxel_sample_triquadratic(float *data, int *res, float *co) +float voxel_sample_triquadratic(float *data, const int res[3], const float co[3]) { if (data) { @@ -133,7 +133,7 @@ float voxel_sample_triquadratic(float *data, int *res, float *co) return 0.f; } -float voxel_sample_tricubic(float *data, int *res, float *co, int bspline) +float voxel_sample_tricubic(float *data, const int res[3], const float co[3], int bspline) { if (data) { diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 316999df6f6..38454547f48 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -2142,7 +2142,7 @@ static void lib_verify_nodetree(Main *main, int UNUSED(open)) ntreetype->foreach_nodetree(main, NULL, lib_nodetree_init_types_cb); } for(ntree= main->nodetree.first; ntree; ntree= ntree->id.next) - ntreeInitTypes(ntree); + lib_nodetree_init_types_cb(NULL, NULL, ntree); { int has_old_groups=0; @@ -3967,7 +3967,6 @@ static void direct_link_pose(FileData *fd, bPose *pose) direct_link_motionpath(fd, pchan->mpath); pchan->iktree.first= pchan->iktree.last= NULL; - pchan->path= NULL; /* incase this value changes in future, clamp else we get undefined behavior */ CLAMP(pchan->rotmode, ROT_MODE_MIN, ROT_MODE_MAX); @@ -4029,8 +4028,10 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb) FluidsimModifierData *fluidmd = (FluidsimModifierData*) md; fluidmd->fss= newdataadr(fd, fluidmd->fss); - fluidmd->fss->fmd= fluidmd; - fluidmd->fss->meshVelocities = NULL; + if(fluidmd->fss) { + fluidmd->fss->fmd= fluidmd; + fluidmd->fss->meshVelocities = NULL; + } } else if (md->type==eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData*) md; @@ -9232,7 +9233,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) simasel->prv_w = 96; simasel->flag = 7; /* ??? elubie */ strcpy (simasel->dir, U.textudir); /* TON */ - strcpy (simasel->file, ""); + simasel->file[0]= '\0'; simasel->returnfunc = NULL; simasel->title[0] = 0; @@ -9462,7 +9463,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* clear old targets to avoid problems */ data->tar = NULL; - strcpy(data->subtarget, ""); + data->subtarget[0]= '\0'; } } else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { @@ -9492,7 +9493,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) /* clear old targets to avoid problems */ data->tar = NULL; - strcpy(data->subtarget, ""); + data->subtarget[0]= '\0'; } } else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 2ea10111bb9..ae568e69936 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -577,7 +577,7 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman case COLLADASW::InputSemantic::OUTPUT: *length = 1; if (rotation) { - values[0] = (bezt->vec[1][1]) * 180.0f/M_PI; + values[0] = RAD2DEGF(bezt->vec[1][1]); } else { values[0] = bezt->vec[1][1]; @@ -593,7 +593,7 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman values[1] = 0; } else if (rotation) { - values[1] = (bezt->vec[0][1]) * 180.0f/M_PI; + values[1] = RAD2DEGF(bezt->vec[0][1]); } else { values[1] = bezt->vec[0][1]; } @@ -608,7 +608,7 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman values[1] = 0; } else if (rotation) { - values[1] = (bezt->vec[2][1]) * 180.0f/M_PI; + values[1] = RAD2DEGF(bezt->vec[2][1]); } else { values[1] = bezt->vec[2][1]; } @@ -688,7 +688,7 @@ std::string AnimationExporter::create_source_from_array(COLLADASW::InputSemantic // val = convert_time(val); //else if (is_rot) - val *= 180.0f / M_PI; + val = RAD2DEGF(val); source.appendValues(val); } diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index 43428f57d4f..a176b6eb4cd 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -170,9 +170,9 @@ void AnimationImporter::fcurve_deg_to_rad(FCurve *cu) { for (unsigned int i = 0; i < cu->totvert; i++) { // TODO convert handles too - cu->bezt[i].vec[1][1] *= M_PI / 180.0f; - cu->bezt[i].vec[0][1] *= M_PI / 180.0f; - cu->bezt[i].vec[2][1] *= M_PI / 180.0f; + cu->bezt[i].vec[1][1] *= DEG2RADF(1.0f); + cu->bezt[i].vec[0][1] *= DEG2RADF(1.0f); + cu->bezt[i].vec[2][1] *= DEG2RADF(1.0f); } } @@ -741,7 +741,7 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector<FCurve*>& mat4_to_quat(rot, mat); /*for ( int i = 0 ; i < 4 ; i ++ ) { - rot[i] = rot[i] * (180 / M_PI); + rot[i] = RAD2DEGF(rot[i]); }*/ copy_v3_v3(loc, mat[3]); mat4_to_size(scale, mat); diff --git a/source/blender/collada/CameraExporter.cpp b/source/blender/collada/CameraExporter.cpp index 542409072f1..006d4c0ed23 100644 --- a/source/blender/collada/CameraExporter.cpp +++ b/source/blender/collada/CameraExporter.cpp @@ -73,7 +73,7 @@ void CamerasExporter::operator()(Object *ob, Scene *sce) if (cam->type == CAM_PERSP) { COLLADASW::PerspectiveOptic persp(mSW); - persp.setXFov(lens_to_angle(cam->lens)*(180.0f/M_PI),"xfov"); + persp.setXFov(RAD2DEGF(lens_to_angle(cam->lens)), "xfov"); persp.setAspectRatio((float)(sce->r.xsch)/(float)(sce->r.ysch),false,"aspect_ratio"); persp.setZFar(cam->clipend, false , "zfar"); persp.setZNear(cam->clipsta,false , "znear"); diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 366837421e3..2387c9a1465 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -816,7 +816,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) double aspect = camera->getAspectRatio().getValue(); double xfov = aspect*yfov; // xfov is in degrees, cam->lens is in millimiters - cam->lens = angle_to_lens((float)xfov*(M_PI/180.0f)); + cam->lens = angle_to_lens(DEG2RADF(xfov));; } break; } @@ -837,7 +837,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) { double x = camera->getXFov().getValue(); // x is in degrees, cam->lens is in millimiters - cam->lens = angle_to_lens((float)x*(M_PI/180.0f)); + cam->lens = angle_to_lens(DEG2RADF(x)); } break; } @@ -854,7 +854,7 @@ bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) { double yfov = camera->getYFov().getValue(); // yfov is in degrees, cam->lens is in millimiters - cam->lens = angle_to_lens((float)yfov*(M_PI/180.0f)); + cam->lens = angle_to_lens(DEG2RADF(yfov)); } break; } diff --git a/source/blender/collada/TransformReader.cpp b/source/blender/collada/TransformReader.cpp index 625a0220830..fa14a548850 100644 --- a/source/blender/collada/TransformReader.cpp +++ b/source/blender/collada/TransformReader.cpp @@ -82,8 +82,8 @@ void TransformReader::dae_rotate_to_mat4(COLLADAFW::Transformation *tm, float m[ { COLLADAFW::Rotate *ro = (COLLADAFW::Rotate*)tm; COLLADABU::Math::Vector3& axis = ro->getRotationAxis(); - float angle = (float)(ro->getRotationAngle() * M_PI / 180.0f); - float ax[] = {axis[0], axis[1], axis[2]}; + const float angle = (float)DEG2RAD(ro->getRotationAngle()); + const float ax[] = {axis[0], axis[1], axis[2]}; // float quat[4]; // axis_angle_to_quat(quat, axis, angle); // quat_to_mat4(m, quat); diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index 88ed112c3fe..34d13a2184d 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -107,9 +107,9 @@ void TransformWriter::add_transform(COLLADASW::Node& node, float loc[3], float r /*node.addRotateZ("rotationZ", COLLADABU::Math::Utils::radToDegF(rot[2])); node.addRotateY("rotationY", COLLADABU::Math::Utils::radToDegF(rot[1])); node.addRotateX("rotationX", COLLADABU::Math::Utils::radToDegF(rot[0]));*/ - node.addRotateZ("rotationZ", rot[2] * 180.0f/M_PI); - node.addRotateY("rotationY", (rot[1]* 180.0f/M_PI)); - node.addRotateX("rotationX", (rot[0]* 180.0f/M_PI)); + node.addRotateZ("rotationZ", RAD2DEGF(rot[2])); + node.addRotateY("rotationY", RAD2DEGF(rot[1])); + node.addRotateX("rotationX", RAD2DEGF(rot[0])); node.addScale("scale", scale[0], scale[1], scale[2]); } diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 70974386917..d2b1fcc4abd 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -404,9 +404,9 @@ float ANIM_unit_mapping_get_factor (Scene *scene, ID *id, FCurve *fcu, short res /* if the radians flag is not set, default to using degrees which need conversions */ if ((scene) && (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS) == 0) { if (restore) - return M_PI / 180.0; /* degrees to radians */ + return DEG2RADF(1.0f); /* degrees to radians */ else - return 180.0 / M_PI; /* radians to degrees */ + return RAD2DEGF(1.0f); /* radians to degrees */ } } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index bb710a32794..bd5935c893c 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -893,7 +893,7 @@ static size_t skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner */ static short skip_fcurve_with_name (bDopeSheet *ads, FCurve *fcu, ID *owner_id) { - bAnimListElem ale_dummy = {0}; + bAnimListElem ale_dummy = {NULL}; bAnimChannelType *acf; /* create a dummy wrapper for the F-Curve */ diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 2305848e7b3..fa619e4cf44 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -204,8 +204,8 @@ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *o int filter; int ret=0; - bAnimListElem dummychan = {0}; - Base dummybase = {0}; + bAnimListElem dummychan = {NULL}; + Base dummybase = {NULL}; if (ob == NULL) return 0; @@ -249,7 +249,7 @@ static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene int filter; int ret=0; - bAnimListElem dummychan = {0}; + bAnimListElem dummychan = {NULL}; if (sce == NULL) return 0; diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index a4b1e9a6e2c..eafe65b4492 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -361,7 +361,7 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) print_m4("premat", premat); print_m4("postmat", postmat); print_m4("difmat", difmat); - printf ("Roll = %f\n", (-atan2(difmat[2][0], difmat[2][2]) * (180.0/M_PI))); + printf ("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2]))); #endif curBone->roll = (float)-atan2(difmat[2][0], difmat[2][2]); diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 81da047df36..00d94574146 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -1441,9 +1441,7 @@ static void poselib_preview_init_data (bContext *C, wmOperator *op) pld->pose->flag &= ~POSE_DO_UNLOCK; /* clear strings + search */ - strcpy(pld->headerstr, ""); - strcpy(pld->searchstr, ""); - strcpy(pld->searchold, ""); + pld->headerstr[0]= pld->searchstr[0]= pld->searchold[0]= '\0'; pld->search_cursor= 0; } diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index adf4f0fac2e..6b85523ac82 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -46,6 +46,7 @@ #include "WM_api.h" #include "WM_types.h" +#include "ED_curve.h" #include "ED_object.h" #include "ED_screen.h" #include "ED_transform.h" diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index a23f2064a9e..da3310ae883 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1878,7 +1878,7 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) static EnumPropertyItem prop_gpencil_drawmodes[] = { {GP_PAINTMODE_DRAW, "DRAW", 0, "Draw Freehand", ""}, {GP_PAINTMODE_DRAW_STRAIGHT, "DRAW_STRAIGHT", 0, "Draw Straight Lines", ""}, - {GP_PAINTMODE_DRAW_POLY, "DRAW_POLY", 0, "Dtaw Poly Line", ""}, + {GP_PAINTMODE_DRAW_POLY, "DRAW_POLY", 0, "Draw Poly Line", ""}, {GP_PAINTMODE_ERASER, "ERASER", 0, "Eraser", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 0664009319d..f076a63cb06 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -58,6 +58,7 @@ #include "UI_interface.h" +#include "IMB_imbuf.h" #include "WM_api.h" #include "WM_types.h" @@ -1874,6 +1875,8 @@ static void ui_free_but(const bContext *C, uiBut *but) 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); + MEM_freeN(but); } diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 33aeb2df926..a1275e237c1 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -461,19 +461,14 @@ void uiEmboss(float x1, float y1, float x2, float y2, int sel) /* ************** SPECIAL BUTTON DRAWING FUNCTIONS ************* */ -void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *UNUSED(but), uiWidgetColors *UNUSED(wcol), rcti *rect) +void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) { #ifdef WITH_HEADLESS (void)rect; #else - extern char datatoc_splash_png[]; - extern int datatoc_splash_png_size; - ImBuf *ibuf; + ImBuf *ibuf= (ImBuf *)but->poin; //GLint scissor[4]; //int w, h; - - /* hardcoded to splash, loading and freeing every draw, eek! */ - ibuf= IMB_ibImageFromMemory((unsigned char*)datatoc_splash_png, datatoc_splash_png_size, IB_rect); if (!ibuf) return; @@ -501,7 +496,6 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *UNUSED(but), uiWidgetColors * glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); */ - IMB_freeImBuf(ibuf); #endif } @@ -959,13 +953,13 @@ static float polar_to_y(float center, float diam, float ampli, float angle) return center + diam * ampli * sinf(angle); } -static void vectorscope_draw_target(float centerx, float centery, float diam, float r, float g, float b) +static void vectorscope_draw_target(float centerx, float centery, float diam, const float colf[3]) { float y,u,v; float tangle=0.f, tampli; float dangle, dampli, dangle2, dampli2; - rgb_to_yuv(r,g,b, &y, &u, &v); + rgb_to_yuv(colf[0], colf[1], colf[2], &y, &u, &v); if (u>0 && v>=0) tangle=atanf(v/u); else if (u>0 && v<0) tangle= atanf(v/u) + 2.0f * (float)M_PI; else if (u<0) tangle=atanf(v/u) + (float)M_PI; @@ -975,7 +969,7 @@ static void vectorscope_draw_target(float centerx, float centery, float diam, fl /* small target vary by 2.5 degree and 2.5 IRE unit */ glColor4f(1.0f, 1.0f, 1.0, 0.12f); - dangle= 2.5f*(float)M_PI/180.0f; + dangle= DEG2RADF(2.5f); dampli= 2.5f/200.0f; glBegin(GL_LINE_STRIP); glVertex2f(polar_to_x(centerx,diam,tampli+dampli,tangle+dangle), polar_to_y(centery,diam,tampli+dampli,tangle+dangle)); @@ -986,9 +980,9 @@ static void vectorscope_draw_target(float centerx, float centery, float diam, fl glEnd(); /* big target vary by 10 degree and 20% amplitude */ glColor4f(1.0f, 1.0f, 1.0, 0.12f); - dangle= 10.0f*(float)M_PI/180.0f; + dangle= DEG2RADF(10.0f); dampli= 0.2f*tampli; - dangle2= 5.0f*(float)M_PI/180.0f; + dangle2= DEG2RADF(5.0f); dampli2= 0.5f*dampli; glBegin(GL_LINE_STRIP); glVertex2f(polar_to_x(centerx,diam,tampli+dampli-dampli2,tangle+dangle), polar_to_y(centery,diam,tampli+dampli-dampli2,tangle+dangle)); @@ -1014,13 +1008,13 @@ static void vectorscope_draw_target(float centerx, float centery, float diam, fl void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti) { + const float skin_rad= DEG2RADF(123.0f); /* angle in radians of the skin tone line */ Scopes *scopes = (Scopes *)but->poin; rctf rect; int i, j; - int skina= 123; /* angle in degree of the skin tone line */ float w, h, centerx, centery, diam; float alpha; - float colors[6][3]={{.75,0,0},{.75,.75,0},{0,.75,0},{0,.75,.75},{0,0,.75},{.75,0,.75}}; + const float colors[6][3]={{.75,0,0},{.75,.75,0},{0,.75,0},{0,.75,.75},{0,0,.75},{.75,0,.75}}; GLint scissor[4]; rect.xmin = (float)recti->xmin+1; @@ -1056,19 +1050,19 @@ void ui_draw_but_VECTORSCOPE(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wco for(j=0; j<5; j++) { glBegin(GL_LINE_STRIP); for(i=0; i<=360; i=i+15) { - float a= i*M_PI/180.0; - float r= (j+1)/10.0f; - glVertex2f( polar_to_x(centerx,diam,r,a), polar_to_y(centery,diam,r,a)); + const float a= DEG2RADF((float)i); + const float r= (j+1)/10.0f; + glVertex2f(polar_to_x(centerx,diam,r,a), polar_to_y(centery,diam,r,a)); } glEnd(); } /* skin tone line */ glColor4f(1.f, 0.4f, 0.f, 0.2f); - fdrawline( polar_to_x(centerx, diam, 0.5f, skina*M_PI/180.0), polar_to_y(centery,diam,0.5,skina*M_PI/180.0), - polar_to_x(centerx, diam, 0.1f, skina*M_PI/180.0), polar_to_y(centery,diam,0.1,skina*M_PI/180.0)); + fdrawline(polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery,diam,0.5,skin_rad), + polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery,diam,0.1,skin_rad)); /* saturation points */ for(i=0; i<6; i++) - vectorscope_draw_target(centerx, centery, diam, colors[i][0], colors[i][1], colors[i][2]); + vectorscope_draw_target(centerx, centery, diam, colors[i]); if (scopes->ok && scopes->vecscope != NULL) { /* pixel point cloud */ diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 208babe2058..fec441f698a 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1237,7 +1237,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, ysize= block->maxy - block->miny+4; /*aspect/= (float)xsize;*/ /*UNUSED*/ - if(but) { + { int left=0, right=0, top=0, down=0; int winx, winy; // int offscreen; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index fd4581af194..09db4b805d7 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -292,7 +292,7 @@ static int return_editcurve_indexar(Object *obedit, int *tot, int **indexar, flo return totvert; } -static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char *name, float *cent_r) +static int object_hook_index_array(Scene *scene, Object *obedit, int *tot, int **indexar, char *name, float *cent_r) { *indexar= NULL; *tot= 0; @@ -302,7 +302,12 @@ static int object_hook_index_array(Object *obedit, int *tot, int **indexar, char case OB_MESH: { Mesh *me= obedit->data; - EditMesh *em = BKE_mesh_get_editmesh(me); + EditMesh *em; + + load_editMesh(scene, obedit); + make_editMesh(scene, obedit); + + em = BKE_mesh_get_editmesh(me); /* check selected vertices first */ if( return_editmesh_indexar(em, tot, indexar, cent_r)) { @@ -427,7 +432,7 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o int tot, ok, *indexar; char name[32]; - ok = object_hook_index_array(obedit, &tot, &indexar, name, cent); + ok = object_hook_index_array(scene, obedit, &tot, &indexar, name, cent); if (!ok) return; // XXX error("Requires selected vertices or active Vertex Group"); @@ -760,7 +765,7 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) /* assign functionality */ - if(!object_hook_index_array(ob, &tot, &indexar, name, cent)) { + if(!object_hook_index_array(CTX_data_scene(C), ob, &tot, &indexar, name, cent)) { BKE_report(op->reports, RPT_WARNING, "Requires selected vertices or active vertex group"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 8813b0027cd..17f174a5069 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -724,7 +724,7 @@ static int modifier_remove_exec(bContext *C, wmOperator *op) Scene *scene= CTX_data_scene(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); - int mode_orig = ob->mode; + int mode_orig = ob ? ob->mode : 0; if(!ob || !md || !ED_object_modifier_remove(op->reports, bmain, scene, ob, md)) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_navmesh.cpp b/source/blender/editors/object/object_navmesh.cpp index d0768d30236..ae97b40eb49 100644 --- a/source/blender/editors/object/object_navmesh.cpp +++ b/source/blender/editors/object/object_navmesh.cpp @@ -575,7 +575,7 @@ static int findFreeNavPolyIndex(EditMesh* em) else if (indices[i]>freeIdx) break; } - delete indices; + delete [] indices; return freeIdx; } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 4d7f6fa9e7a..97c9b2d06bb 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -95,6 +95,7 @@ #include "ED_object.h" #include "ED_screen.h" #include "ED_view3d.h" +#include "ED_mesh.h" #include "object_intern.h" @@ -122,7 +123,12 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) if(obedit->type==OB_MESH) { Mesh *me= obedit->data; - EditMesh *em = BKE_mesh_get_editmesh(me); + EditMesh *em; + + load_editMesh(scene, obedit); + make_editMesh(scene, obedit); + + em = BKE_mesh_get_editmesh(me); eve= em->verts.first; while(eve) { diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 79a3251cdf1..784c35ca523 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -717,7 +717,7 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float * 1 : occluded 2 : occluded with w[3] weights set (need to know in some cases) */ -static int project_paint_occlude_ptv(float pt[3], float v1[3], float v2[3], float v3[3], float w[3], int is_ortho) +static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], float v3[4], float w[3], int is_ortho) { /* if all are behind us, return false */ if(v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2]) @@ -749,7 +749,7 @@ static int project_paint_occlude_ptv(float pt[3], float v1[3], float v2[3], floa static int project_paint_occlude_ptv_clip( const ProjPaintState *ps, const MFace *mf, - float pt[3], float v1[3], float v2[3], float v3[3], + float pt[3], float v1[4], float v2[4], float v3[4], const int side ) { float w[3], wco[3]; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 9500c7f663c..767001ff163 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -447,9 +447,9 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, if(brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { /* brush rotation */ glTranslatef(0.5, 0.5, 0); - glRotatef((double)((brush->flag & BRUSH_RAKE) ? - sd->last_angle : sd->special_rotation) * (180.0/M_PI), - 0.0, 0.0, 1.0); + glRotatef((double)RAD2DEGF((brush->flag & BRUSH_RAKE) ? + sd->last_angle : sd->special_rotation), + 0.0, 0.0, 1.0); glTranslatef(-0.5f, -0.5f, 0); /* scale based on tablet pressure */ @@ -683,7 +683,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev /* TODO: as sculpt and other paint modes are unified, this separation will go away */ if(stroke->vc.obact->sculpt) { - float delta[3]; + float delta[2]; brush_jitter_pos(brush, mouse_in, mouse); @@ -691,13 +691,14 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev brush_jitter_pos isn't written in the best way to be reused here */ if(brush->flag & BRUSH_JITTER_PRESSURE) { - sub_v3_v3v3(delta, mouse, mouse_in); - mul_v3_fl(delta, pressure); - add_v3_v3v3(mouse, mouse_in, delta); + sub_v2_v2v2(delta, mouse, mouse_in); + mul_v2_fl(delta, pressure); + add_v2_v2v2(mouse, mouse_in, delta); } } - else - copy_v3_v3(mouse, mouse_in); + else { + copy_v2_v2(mouse, mouse_in); + } /* TODO: can remove the if statement once all modes have this */ if(stroke->get_location) diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 09f5c32bea0..e088f59a1d2 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -1,3 +1,32 @@ +/* + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + /** \file blender/editors/sculpt_paint/paint_utils.c * \ingroup edsculpt */ diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 92bc60e8b77..0bdb027a903 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2996,7 +2996,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) copy_v3_v3(cache->true_location, cache->orig_grab_location); sd->draw_anchored = 1; - copy_v3_v3(sd->anchored_initial_mouse, cache->initial_mouse); + copy_v2_v2(sd->anchored_initial_mouse, cache->initial_mouse); sd->anchored_size = cache->pixel_radius; } } diff --git a/source/blender/editors/sound/sound_intern.h b/source/blender/editors/sound/sound_intern.h index b17ef99132f..cde0b3c4479 100644 --- a/source/blender/editors/sound/sound_intern.h +++ b/source/blender/editors/sound/sound_intern.h @@ -36,7 +36,5 @@ struct wmOperatorType; -void SOUND_OT_open(wmOperatorType *ot); - #endif /* ED_SOUND_INTERN_H */ diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 19cae6aa67d..60d665de94c 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -175,7 +175,7 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *event) return WM_operator_filesel(C, op, event); } -void SOUND_OT_open(wmOperatorType *ot) +static void SOUND_OT_open(wmOperatorType *ot) { /* identifiers */ ot->name= "Open Sound"; @@ -196,7 +196,7 @@ void SOUND_OT_open(wmOperatorType *ot) RNA_def_boolean(ot->srna, "mono", FALSE, "Mono", "Mixdown the sound to mono."); } -void SOUND_OT_open_mono(wmOperatorType *ot) +static void SOUND_OT_open_mono(wmOperatorType *ot) { /* identifiers */ ot->name= "Open Sound Mono"; @@ -659,7 +659,7 @@ static int update_animation_flags_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void SOUND_OT_update_animation_flags(wmOperatorType *ot) +static void SOUND_OT_update_animation_flags(wmOperatorType *ot) { /* This operator is needed to set a correct state of the sound animation @@ -703,7 +703,7 @@ static int bake_animation_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -void SOUND_OT_bake_animation(wmOperatorType *ot) +static void SOUND_OT_bake_animation(wmOperatorType *ot) { /* identifiers */ ot->name= "Update animation cache"; diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index b5dfdcdc668..60662334e20 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -535,7 +535,7 @@ void ACTION_OT_paste (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; RNA_def_enum(ot->srna, "offset", keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys"); - RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merking pasted keys and existing"); + RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing"); } /* ******************** Insert Keyframes Operator ************************* */ diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index aa29e54f436..32594e710a4 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -580,7 +580,7 @@ void ACTION_OT_select_linked (wmOperatorType *ot) /* identifiers */ ot->name = "Select Linked"; ot->idname= "ACTION_OT_select_linked"; - ot->description = "Select keyframes occurring the same F-Curves as selected ones"; + ot->description = "Select keyframes occurring in the same F-Curves as selected ones"; /* api callbacks */ ot->exec= actkeys_select_linked_exec; diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index 4707baa279b..51e2679e8c2 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -54,6 +54,14 @@ #include "console_intern.h" +/* so when we type - the view scrolls to the bottom */ +static void console_scroll_bottom(ARegion *ar) +{ + View2D *v2d= &ar->v2d; + v2d->cur.ymin = 0.0; + v2d->cur.ymax =(float)v2d->winy; +} + static void console_textview_update_rect(SpaceConsole *sc, ARegion *ar) { View2D *v2d= &ar->v2d; @@ -339,9 +347,14 @@ static int move_exec(bContext *C, wmOperator *op) } if(done) { - ED_area_tag_redraw(CTX_wm_area(C)); + ScrArea *sa= CTX_wm_area(C); + ARegion *ar= CTX_wm_region(C); + + ED_area_tag_redraw(sa); + console_scroll_bottom(ar); } - + + return OPERATOR_FINISHED; } @@ -391,7 +404,9 @@ static int insert_exec(bContext *C, wmOperator *op) console_textview_update_rect(sc, ar); ED_area_tag_redraw(CTX_wm_area(C)); - + + console_scroll_bottom(ar); + return OPERATOR_FINISHED; } @@ -478,6 +493,8 @@ static int delete_exec(bContext *C, wmOperator *op) console_textview_update_rect(sc, ar); ED_area_tag_redraw(CTX_wm_area(C)); + + console_scroll_bottom(ar); return OPERATOR_FINISHED; } @@ -589,6 +606,8 @@ static int history_cycle_exec(bContext *C, wmOperator *op) console_textview_update_rect(sc, ar); ED_area_tag_redraw(CTX_wm_area(C)); + console_scroll_bottom(ar); + return OPERATOR_FINISHED; } @@ -604,7 +623,7 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot) ot->poll= ED_operator_console_active; /* properties */ - RNA_def_boolean(ot->srna, "reverse", 0, "Reverse", "reverse cycle history"); + RNA_def_boolean(ot->srna, "reverse", 0, "Reverse", "Reverse cycle history"); } @@ -612,6 +631,7 @@ void CONSOLE_OT_history_cycle(wmOperatorType *ot) static int history_append_exec(bContext *C, wmOperator *op) { SpaceConsole *sc= CTX_wm_space_console(C); + ARegion *ar= CTX_wm_region(C); ScrArea *sa= CTX_wm_area(C); ConsoleLine *ci= console_history_verify(C); char *str= RNA_string_get_alloc(op->ptr, "text", NULL, 0); /* own this text in the new line, dont free */ @@ -637,6 +657,8 @@ static int history_append_exec(bContext *C, wmOperator *op) ED_area_tag_redraw(sa); + console_scroll_bottom(ar); + return OPERATOR_FINISHED; } @@ -825,6 +847,8 @@ static int paste_exec(bContext *C, wmOperator *UNUSED(op)) console_textview_update_rect(sc, ar); ED_area_tag_redraw(CTX_wm_area(C)); + console_scroll_bottom(ar); + return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index c8fa049f5eb..5a965fc076b 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -138,8 +138,17 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; ListBase *lb; + const int prev_y_min= ar->v2d.cur.ymin; /* so resizing keeps the cursor visible */ + UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy); + /* always keep the bottom part of the view aligned, less annoying */ + if(prev_y_min != ar->v2d.cur.ymin) { + const float cur_y_range= ar->v2d.cur.ymax - ar->v2d.cur.ymin; + ar->v2d.cur.ymin= prev_y_min; + ar->v2d.cur.ymax= prev_y_min + cur_y_range; + } + /* own keymap */ keymap= WM_keymap_find(wm->defaultconf, "Console", SPACE_CONSOLE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 1b0893e50e0..43d5a5c9b4b 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -164,22 +164,26 @@ static FileSelect file_select_do(bContext* C, int selected_idx) SpaceFile *sfile= CTX_wm_space_file(C); FileSelectParams *params = ED_fileselect_get_params(sfile); int numfiles = filelist_numfiles(sfile->files); + struct direntry* file; /* make the selected file active */ - if ( (selected_idx >= 0) && (selected_idx < numfiles)) { - struct direntry* file = filelist_file(sfile->files, selected_idx); + if ( (selected_idx >= 0) && + (selected_idx < numfiles) && + (file= filelist_file(sfile->files, selected_idx))) + { params->active_file = selected_idx; - if(file && S_ISDIR(file->type)) { + if(S_ISDIR(file->type)) { /* the path is too long and we are not going up! */ - if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX ) - { + if (strcmp(file->relname, "..") && strlen(params->dir) + strlen(file->relname) >= FILE_MAX ) { // XXX error("Path too long, cannot enter this directory"); - } else { - if (strcmp(file->relname, "..")==0) { - /* avoids /../../ */ - BLI_parent_dir(params->dir); - } else { + } + else { + if (strcmp(file->relname, "..")==0) { + /* avoids /../../ */ + BLI_parent_dir(params->dir); + } + else { BLI_cleanup_dir(G.main->name, params->dir); strcat(params->dir, file->relname); BLI_add_slash(params->dir); @@ -189,8 +193,7 @@ static FileSelect file_select_do(bContext* C, int selected_idx) retval = FILE_SELECT_DIR; } } - else if (file) - { + else { if (file->relname) { BLI_strncpy(params->file, file->relname, FILE_MAXFILE); } diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 900aa6f6197..f115fd93c2e 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -763,7 +763,7 @@ void GRAPH_OT_paste (wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; RNA_def_enum(ot->srna, "offset", keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys"); - RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merking pasted keys and existing"); + RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing"); } /* ******************** Duplicate Keyframes Operator ************************* */ diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index b8c5d79df18..40380db03d4 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -585,7 +585,7 @@ void GRAPH_OT_select_linked (wmOperatorType *ot) /* identifiers */ ot->name = "Select Linked"; ot->idname= "GRAPH_OT_select_linked"; - ot->description = "Select keyframes occurring the same F-Curves as selected ones"; + ot->description = "Select keyframes occurring in the same F-Curves as selected ones"; /* api callbacks */ ot->exec= graphkeys_select_linked_exec; diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 08026e8a1d2..253e99b3036 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -1619,7 +1619,7 @@ void NLA_OT_action_sync_length (wmOperatorType *ot) /* identifiers */ ot->name= "Sync Action Length"; ot->idname= "NLA_OT_action_sync_length"; - ot->description= "Synchronise the length of the referenced Action with the lengths used in the strip"; + ot->description= "Synchronise the length of the referenced Action with the length used in the strip."; /* api callbacks */ ot->exec= nlaedit_sync_actlen_exec; @@ -2042,7 +2042,7 @@ void NLA_OT_fmodifier_add (wmOperatorType *ot) /* identifiers */ ot->name= "Add F-Modifier"; ot->idname= "NLA_OT_fmodifier_add"; - ot->description= "Add F-Modifier of the specified type to the selected NLA-Strips"; + ot->description= "Add a F-Modifier of the specified type to the selected NLA-Strips."; /* api callbacks */ ot->invoke= nla_fmodifier_add_invoke; @@ -2054,7 +2054,7 @@ void NLA_OT_fmodifier_add (wmOperatorType *ot) /* id-props */ ot->prop= RNA_def_enum(ot->srna, "type", fmodifier_type_items, 0, "Type", ""); - RNA_def_boolean(ot->srna, "only_active", 0, "Only Active", "Only add F-Modifier of the specified type to the active strip."); + RNA_def_boolean(ot->srna, "only_active", 0, "Only Active", "Only add a F-Modifier of the specified type to the active strip."); } /* ******************** Copy F-Modifiers Operator *********************** */ diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index e9b45da6bce..c8536185661 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -479,7 +479,7 @@ void NLA_OT_select_leftright (wmOperatorType *ot) /* identifiers */ ot->name= "Select Left/Right"; ot->idname= "NLA_OT_select_leftright"; - ot->description= "Select strips to the left or the right of the current frame "; + ot->description= "Select strips to the left or the right of the current frame."; /* api callbacks */ ot->invoke= nlaedit_select_leftright_invoke; diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 9ea1e8ee877..cd521f7e8c7 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -97,7 +97,7 @@ static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v) } } -void node_socket_button_default(const bContext *C, uiBlock *block, +static void node_socket_button_default(const bContext *C, uiBlock *block, bNodeTree *ntree, bNode *node, bNodeSocket *sock, const char *name, int x, int y, int width) { @@ -135,7 +135,7 @@ static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v) return block; } -void node_socket_button_components(const bContext *C, uiBlock *block, +static void node_socket_button_components(const bContext *C, uiBlock *block, bNodeTree *ntree, bNode *node, bNodeSocket *sock, const char *name, int x, int y, int width) { @@ -157,7 +157,7 @@ void node_socket_button_components(const bContext *C, uiBlock *block, uiDefBlockButN(block, socket_component_menu, args, name, x, y+1, width, NODE_DY-2, ""); } -void node_socket_button_color(const bContext *C, uiBlock *block, +static void node_socket_button_color(const bContext *C, uiBlock *block, bNodeTree *ntree, bNode *node, bNodeSocket *sock, const char *name, int x, int y, int width) { @@ -179,7 +179,7 @@ void node_socket_button_color(const bContext *C, uiBlock *block, /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */ -void node_draw_socket_new(bNodeSocket *sock, float size) +static void node_draw_socket_new(bNodeSocket *sock, float size) { float x=sock->locx, y=sock->locy; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 5f58f540aae..01519d55fa9 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -983,7 +983,7 @@ void NODE_OT_group_socket_remove(wmOperatorType *ot) { /* identifiers */ ot->name = "Remove Group Socket"; - ot->description = "Removed node group socket"; + ot->description = "Remove a node group socket."; ot->idname = "NODE_OT_group_socket_remove"; /* api callbacks */ diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c index 3d8b1676ea5..43d2696bdd4 100644 --- a/source/blender/editors/space_node/node_select.c +++ b/source/blender/editors/space_node/node_select.c @@ -141,7 +141,7 @@ void NODE_OT_select(wmOperatorType *ot) /* identifiers */ ot->name= "Select"; ot->idname= "NODE_OT_select"; - ot->description= "Select node under cursor"; + ot->description= "Select the node under the cursor."; /* api callbacks */ ot->invoke= node_select_invoke; @@ -379,7 +379,7 @@ void NODE_OT_select_same_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Select Same Type"; - ot->description = "Select all the same type"; + ot->description = "Select all the nodes of the same type."; ot->idname = "NODE_OT_select_same_type"; /* api callbacks */ diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 357730aff39..65ce2e71d8d 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -1008,6 +1008,10 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto UI_icon_draw(x, y, ICON_MOD_SOLIDIFY); break; case eModifierType_Screw: UI_icon_draw(x, y, ICON_MOD_SCREW); break; + case eModifierType_WeightVGEdit: + case eModifierType_WeightVGMix: + case eModifierType_WeightVGProximity: + UI_icon_draw(x, y, ICON_MOD_VERTEX_WEIGHT); break; default: UI_icon_draw(x, y, ICON_DOT); break; } diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 05eace0d4ef..6172273f7e1 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -218,7 +218,7 @@ void OUTLINER_OT_item_openclose(wmOperatorType *ot) /* Rename --------------------------------------------------- */ -void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports) +static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, ReportList *reports) { /* can't rename rna datablocks entries */ if(ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) @@ -765,7 +765,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so } else { /* pop up panel - no previous, or user didn't want search after previous */ - strcpy(name, ""); + name[0]= '\0'; // XXX if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) { // te= outliner_find_named(soops, &soops->tree, name, flags, NULL, &prevFound); // } diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index b2fdd34aab2..efbfbd51fb5 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -342,7 +342,7 @@ static void singleuser_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement if (id) { IdAdtTemplate *iat = (IdAdtTemplate *)tsep->id; - PointerRNA ptr = {{0}}; + PointerRNA ptr = {{NULL}}; PropertyRNA *prop; RNA_pointer_create(&iat->id, &RNA_AnimData, iat->adt, &ptr); diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 7e9eabc08db..0a1f7a3599d 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -473,7 +473,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); ten->name= pchan->name; ten->directdata= pchan; - pchan->prev= (bPoseChannel *)ten; + pchan->temp= (void *)ten; if(pchan->constraints.first) { //Object *target; @@ -506,19 +506,13 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree pchan= (bPoseChannel *)ten->directdata; if(pchan->parent) { BLI_remlink(&tenla->subtree, ten); - par= (TreeElement *)pchan->parent->prev; + par= (TreeElement *)pchan->parent->temp; BLI_addtail(&par->subtree, ten); ten->parent= par; } } ten= nten; } - /* restore prev pointers */ - pchan= ob->pose->chanbase.first; - if(pchan) pchan->prev= NULL; - for(; pchan; pchan= pchan->next) { - if(pchan->next) pchan->next->prev= pchan; - } } /* Pose Groups */ @@ -775,7 +769,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor ebone->temp= ten; } /* make hierarchy */ - ten= te->subtree.first; + ten= arm->edbo->first ? ((EditBone *)arm->edbo->first)->temp : NULL; while(ten) { TreeElement *nten= ten->next, *par; ebone= (EditBone *)ten->directdata; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index e7673651546..c3165adaf49 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -188,7 +188,7 @@ static void proxy_endjob(void *UNUSED(customdata)) } -void seq_proxy_build_job(const bContext *C, Sequence * seq) +static void seq_proxy_build_job(const bContext *C, Sequence * seq) { wmJob * steve; ProxyJob *pj; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 02f3bec3782..0e8e6cdfee1 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -257,7 +257,9 @@ static float cube[8][3] = { /* ----------------- OpenGL Circle Drawing - Tables for Optimised Drawing Speed ------------------ */ /* 32 values of sin function (still same result!) */ -static float sinval[32] = { +#define CIRCLE_RESOL 32 + +static const float sinval[CIRCLE_RESOL] = { 0.00000000, 0.20129852, 0.39435585, @@ -293,7 +295,7 @@ static float sinval[32] = { }; /* 32 values of cos function (still same result!) */ -static float cosval[32] ={ +static const float cosval[CIRCLE_RESOL] = { 1.00000000, 0.97952994, 0.91895781, @@ -611,28 +613,39 @@ static void draw_empty_image(Object *ob) glPopMatrix(); } -void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]) +static void circball_array_fill(float verts[CIRCLE_RESOL][3], const float cent[3], float rad, float tmat[][4]) { - float vec[3], vx[3], vy[3]; - int a, tot=32; + float vx[3], vy[3]; + float *viter= (float *)verts; + unsigned int a; mul_v3_v3fl(vx, tmat[0], rad); mul_v3_v3fl(vy, tmat[1], rad); - glBegin(mode); - for(a=0; a<tot; a++) { - vec[0]= cent[0] + *(sinval+a) * vx[0] + *(cosval+a) * vy[0]; - vec[1]= cent[1] + *(sinval+a) * vx[1] + *(cosval+a) * vy[1]; - vec[2]= cent[2] + *(sinval+a) * vx[2] + *(cosval+a) * vy[2]; - glVertex3fv(vec); + for (a=0; a < CIRCLE_RESOL; a++, viter += 3) { + viter[0]= cent[0] + sinval[a] * vx[0] + cosval[a] * vy[0]; + viter[1]= cent[1] + sinval[a] * vx[1] + cosval[a] * vy[1]; + viter[2]= cent[2] + sinval[a] * vx[2] + cosval[a] * vy[2]; } - glEnd(); +} + +void drawcircball(int mode, const float cent[3], float rad, float tmat[][4]) +{ + float verts[CIRCLE_RESOL][3]; + + circball_array_fill(verts, cent, rad, tmat); + + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, verts); + glDrawArrays(mode, 0, CIRCLE_RESOL); + glDisableClientState(GL_VERTEX_ARRAY); } /* circle for object centers, special_color is for library or ob users */ static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3], int selstate, int special_color) { const float size= ED_view3d_pixel_size(rv3d, co) * (float)U.obcenter_dia * 0.5f; + float verts[CIRCLE_RESOL][3]; /* using gldepthfunc guarantees that it does write z values, but not checks for it, so centers remain visible independt order of drawing */ if(v3d->zbuf) glDepthFunc(GL_ALWAYS); @@ -648,12 +661,25 @@ static void drawcentercircle(View3D *v3d, RegionView3D *rv3d, const float co[3], else if (selstate == SELECT) UI_ThemeColorShadeAlpha(TH_SELECT, 0, -80); else if (selstate == DESELECT) UI_ThemeColorShadeAlpha(TH_TRANSFORM, 0, -80); } - drawcircball(GL_POLYGON, co, size, rv3d->viewinv); - + + circball_array_fill(verts, co, size, rv3d->viewinv); + + /* enable vertex array */ + glEnableClientState(GL_VERTEX_ARRAY); + glVertexPointer(3, GL_FLOAT, 0, verts); + + /* 1. draw filled, blended polygon */ + glDrawArrays(GL_POLYGON, 0, CIRCLE_RESOL); + + /* 2. draw outline */ UI_ThemeColorShadeAlpha(TH_WIRE, 0, -30); - drawcircball(GL_LINE_LOOP, co, size, rv3d->viewinv); - + glDrawArrays(GL_LINE_LOOP, 0, CIRCLE_RESOL); + + /* finishe up */ + glDisableClientState(GL_VERTEX_ARRAY); + glDisable(GL_BLEND); + if(v3d->zbuf) glDepthFunc(GL_LEQUAL); } @@ -4512,16 +4538,22 @@ static void tekenhandlesN(Nurb *nu, short sel, short hide_handles) { BezTriple *bezt; float *fp; - int basecol; int a; - + if(nu->hide || hide_handles) return; glBegin(GL_LINES); - + if(nu->type == CU_BEZIER) { - if(sel) basecol= TH_HANDLE_SEL_FREE; - else basecol= TH_HANDLE_FREE; + +#define TH_HANDLE_COL_TOT ((TH_HANDLE_SEL_FREE - TH_HANDLE_FREE) + 1) + /* use MIN2 when indexing to ensure newer files dont read outside the array */ + unsigned char handle_cols[TH_HANDLE_COL_TOT][3]; + const int basecol= sel ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE; + + for (a=0; a < TH_HANDLE_COL_TOT; a++) { + UI_GetThemeColor3ubv(basecol + a, handle_cols[a]); + } bezt= nu->bezt; a= nu->pntsu; @@ -4530,31 +4562,34 @@ static void tekenhandlesN(Nurb *nu, short sel, short hide_handles) if( (bezt->f2 & SELECT)==sel) { fp= bezt->vec[0]; - UI_ThemeColor(basecol + bezt->h1); + glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT-1)]); glVertex3fv(fp); glVertex3fv(fp+3); - UI_ThemeColor(basecol + bezt->h2); + glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT-1)]); glVertex3fv(fp+3); glVertex3fv(fp+6); } else if( (bezt->f1 & SELECT)==sel) { fp= bezt->vec[0]; - UI_ThemeColor(basecol + bezt->h1); + glColor3ubv(handle_cols[MIN2(bezt->h1, TH_HANDLE_COL_TOT-1)]); glVertex3fv(fp); glVertex3fv(fp+3); } else if( (bezt->f3 & SELECT)==sel) { fp= bezt->vec[1]; - UI_ThemeColor(basecol + bezt->h2); + glColor3ubv(handle_cols[MIN2(bezt->h2, TH_HANDLE_COL_TOT-1)]); glVertex3fv(fp); glVertex3fv(fp+3); } } bezt++; } + +#undef TH_HANDLE_COL_TOT + } glEnd(); } @@ -5022,7 +5057,7 @@ static void curve_draw_speed(Scene *scene, Object *ob) #endif // XXX old animation system stuff -static void draw_textcurs(float textcurs[][2]) +static void draw_textcurs(float textcurs[4][2]) { cpack(0); @@ -5039,12 +5074,13 @@ static void draw_textcurs(float textcurs[][2]) static void drawspiral(const float cent[3], float rad, float tmat[][4], int start) { float vec[3], vx[3], vy[3]; - int a, tot=32; - char inverse=0; - + const float tot_inv= (1.0f / (float)CIRCLE_RESOL); + int a; + char inverse= FALSE; + if (start < 0) { - inverse = 1; - start *= -1; + inverse = TRUE; + start= -start; } mul_v3_v3fl(vx, tmat[0], rad); @@ -5053,31 +5089,31 @@ static void drawspiral(const float cent[3], float rad, float tmat[][4], int star copy_v3_v3(vec, cent); if (inverse==0) { - for(a=0; a<tot; a++) { + for(a=0; a<CIRCLE_RESOL; a++) { if (a+start>31) start=-a + 1; glBegin(GL_LINES); glVertex3fv(vec); - vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)a/(float)tot) + *(cosval+a+start) * (vy[0] * (float)a/(float)tot); - vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)a/(float)tot) + *(cosval+a+start) * (vy[1] * (float)a/(float)tot); - vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)a/(float)tot) + *(cosval+a+start) * (vy[2] * (float)a/(float)tot); + vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)a * tot_inv) + cosval[a+start] * (vy[0] * (float)a * tot_inv); + vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)a * tot_inv) + cosval[a+start] * (vy[1] * (float)a * tot_inv); + vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)a * tot_inv) + cosval[a+start] * (vy[2] * (float)a * tot_inv); glVertex3fv(vec); glEnd(); } } else { a=0; - vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[0] * (float)(-a+31)/(float)tot); - vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[1] * (float)(-a+31)/(float)tot); - vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[2] * (float)(-a+31)/(float)tot); - for(a=0; a<tot; a++) { + vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[0] * (float)(-a+31) * tot_inv); + vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[1] * (float)(-a+31) * tot_inv); + vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[2] * (float)(-a+31) * tot_inv); + for(a=0; a<CIRCLE_RESOL; a++) { if (a+start>31) start=-a + 1; glBegin(GL_LINES); glVertex3fv(vec); - vec[0]= cent[0] + *(sinval+a+start) * (vx[0] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[0] * (float)(-a+31)/(float)tot); - vec[1]= cent[1] + *(sinval+a+start) * (vx[1] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[1] * (float)(-a+31)/(float)tot); - vec[2]= cent[2] + *(sinval+a+start) * (vx[2] * (float)(-a+31)/(float)tot) + *(cosval+a+start) * (vy[2] * (float)(-a+31)/(float)tot); + vec[0]= cent[0] + sinval[a+start] * (vx[0] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[0] * (float)(-a+31) * tot_inv); + vec[1]= cent[1] + sinval[a+start] * (vx[1] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[1] * (float)(-a+31) * tot_inv); + vec[2]= cent[2] + sinval[a+start] * (vx[2] * (float)(-a+31) * tot_inv) + cosval[a+start] * (vy[2] * (float)(-a+31) * tot_inv); glVertex3fv(vec); glEnd(); } @@ -5095,9 +5131,9 @@ static void drawcircle_size(float size) glBegin(GL_LINE_LOOP); /* coordinates are: cos(degrees*11.25)=x, sin(degrees*11.25)=y, 0.0f=z */ - for (degrees=0; degrees<32; degrees++) { - x= *(cosval + degrees); - y= *(sinval + degrees); + for (degrees=0; degrees<CIRCLE_RESOL; degrees++) { + x= cosval[degrees]; + y= sinval[degrees]; glVertex3f(x*size, 0.0f, y*size); } @@ -5365,8 +5401,7 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) unit_m4(tmat); - radius=(pd->flag&PFIELD_USEMAXR)?pd->maxrad:1.0f; - radius*=(float)M_PI/180.0f; + radius= DEG2RADF((pd->flag&PFIELD_USEMAXR) ? pd->maxrad : 1.0f); distance=(pd->flag&PFIELD_USEMAX)?pd->maxdist:0.0f; if(pd->flag & (PFIELD_USEMAX|PFIELD_USEMAXR)){ @@ -5375,8 +5410,7 @@ static void draw_forcefield(Scene *scene, Object *ob, RegionView3D *rv3d) drawcone(vec, distance * sinf(radius),-distance * cosf(radius),tmat); } - radius=(pd->flag&PFIELD_USEMINR)?pd->minrad:1.0f; - radius*=(float)M_PI/180.0f; + radius= DEG2RADF((pd->flag&PFIELD_USEMINR) ? pd->minrad : 1.0f); distance=(pd->flag&PFIELD_USEMIN)?pd->mindist:0.0f; if(pd->flag & (PFIELD_USEMIN|PFIELD_USEMINR)){ diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 50c587194b7..6c69e816b30 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -887,9 +887,9 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob) quat_to_eul( tfp->ob_eul,pchan->quat); else copy_v3_v3(tfp->ob_eul, pchan->eul); - tfp->ob_eul[0]*= 180.0/M_PI; - tfp->ob_eul[1]*= 180.0/M_PI; - tfp->ob_eul[2]*= 180.0/M_PI; + tfp->ob_eul[0]*= RAD2DEGF(1.0f); + tfp->ob_eul[1]*= RAD2DEGF(1.0f); + tfp->ob_eul[2]*= RAD2DEGF(1.0f); uiDefBut(block, LABEL, 0, "Location:", 0, 240, 100, 20, 0, 0, 0, 0, 0, ""); uiBlockBeginAlign(block); @@ -1097,9 +1097,9 @@ static void do_view3d_region_buttons(bContext *C, void *UNUSED(index), int event if (!pchan) return; /* make a copy to eul[3], to allow TAB on buttons to work */ - eul[0]= (float)M_PI*tfp->ob_eul[0]/180.0f; - eul[1]= (float)M_PI*tfp->ob_eul[1]/180.0f; - eul[2]= (float)M_PI*tfp->ob_eul[2]/180.0f; + eul[0]= DEG2RADF(tfp->ob_eul[0]); + eul[1]= DEG2RADF(tfp->ob_eul[1]); + eul[2]= DEG2RADF(tfp->ob_eul[2]); if (pchan->rotmode == ROT_MODE_AXISANGLE) { float quat[4]; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 44ae6837aa2..c7feaebcddc 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -525,8 +525,8 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2] ED_view3d_win_to_vector(ar, mval, vec); copy_v3_v3(ray_start, rv3d->viewinv[3]); - VECADDFAC(ray_start, rv3d->viewinv[3], vec, v3d->near); - VECADDFAC(ray_end, rv3d->viewinv[3], vec, v3d->far); + madd_v3_v3v3fl(ray_start, rv3d->viewinv[3], vec, v3d->near); + madd_v3_v3v3fl(ray_end, rv3d->viewinv[3], vec, v3d->far); } else { float vec[4]; @@ -537,8 +537,8 @@ void ED_view3d_win_to_segment_clip(ARegion *ar, View3D *v3d, const float mval[2] mul_m4_v4(rv3d->persinv, vec); - VECADDFAC(ray_start, vec, rv3d->viewinv[2], 1000.0f); - VECADDFAC(ray_end, vec, rv3d->viewinv[2], -1000.0f); + madd_v3_v3v3fl(ray_start, vec, rv3d->viewinv[2], 1000.0f); + madd_v3_v3v3fl(ray_end, vec, rv3d->viewinv[2], -1000.0f); } /* clipping */ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 82598e0b5c6..c8b95727304 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -3371,10 +3371,10 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { if(chainlen) sprintf(autoik, "AutoIK-Len: %d", chainlen); else - strcpy(autoik, ""); + autoik[0]= '\0'; } else - strcpy(autoik, ""); + autoik[0]= '\0'; if (t->con.mode & CON_APPLY) { switch(t->num.idx_max) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index b187ca0650c..38776b51c62 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1666,13 +1666,13 @@ void calculatePropRatio(TransInfo *t) strcpy(t->proptext, "(Random)"); break; default: - strcpy(t->proptext, ""); + t->proptext[0]= '\0'; } } else { for(i = 0 ; i < t->total; i++, td++) { td->factor = 1.0; } - strcpy(t->proptext, ""); + t->proptext[0]= '\0'; } } diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 453bea0969b..d5a94c9b56a 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -275,7 +275,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac VECSUB2D(av4, tf_uv[2], tf_uv[3]); normalize_v2(av4); /* This is the correct angle however we are only comparing angles - * uvang1 = 90-((angle_normalized_v2v2(av1, av2) * 180.0/M_PI)-90);*/ + * uvang1 = 90-((angle_normalized_v2v2(av1, av2) * RAD2DEGF(1.0f))-90);*/ uvang1 = angle_normalized_v2v2(av1, av2); uvang2 = angle_normalized_v2v2(av2, av3); uvang3 = angle_normalized_v2v2(av3, av4); @@ -288,7 +288,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, EditMesh *em, MTFac VECSUB(av4, efa->v3->co, efa->v4->co); normalize_v3(av4); /* This is the correct angle however we are only comparing angles - * ang1 = 90-((angle_normalized_v3v3(av1, av2) * 180.0/M_PI)-90);*/ + * ang1 = 90-((angle_normalized_v3v3(av1, av2) * RAD2DEGF(1.0f))-90);*/ ang1 = angle_normalized_v3v3(av1, av2); ang2 = angle_normalized_v3v3(av2, av3); ang3 = angle_normalized_v3v3(av3, av4); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 4d4561e66db..ce3a378ea00 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -240,7 +240,7 @@ GPUBuffer *GPU_buffer_alloc(int size) size */ glGenBuffersARB(1, &buf->id); glBindBufferARB(GL_ARRAY_BUFFER_ARB, buf->id); - glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, 0, GL_STATIC_DRAW_ARB); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, size, NULL, GL_STATIC_DRAW_ARB); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); } else { @@ -493,7 +493,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, /* nothing to do for legacy mode */ if(dm->drawObject->legacy) - return 0; + return NULL; cur_index_per_mat = MEM_mallocN(sizeof(int)*object->totmaterial, "GPU_buffer_setup.cur_index_per_mat"); @@ -513,7 +513,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, /* bind the buffer and discard previous data, avoids stalling gpu */ glBindBufferARB(target, buffer->id); - glBufferDataARB(target, buffer->size, 0, GL_STATIC_DRAW_ARB); + glBufferDataARB(target, buffer->size, NULL, GL_STATIC_DRAW_ARB); /* attempt to map the buffer */ if(!(varray = glMapBufferARB(target, GL_WRITE_ONLY_ARB))) { diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index fb9f21cde8c..9cd6240d37d 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -514,8 +514,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, float *fpixels) if (pixels) MEM_freeN(pixels); - if (tex) - GPU_texture_unbind(tex); + GPU_texture_unbind(tex); return tex; } diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index 1547d2ee9ce..26be64bc268 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -58,13 +58,11 @@ set(SRC intern/indexer.c intern/indexer_dv.c intern/iris.c - intern/jp2.c intern/jpeg.c intern/md5.c intern/metadata.c intern/module.c intern/png.c - intern/radiance_hdr.c intern/readimage.c intern/rectop.c intern/rotate.c @@ -72,7 +70,6 @@ set(SRC intern/targa.c intern/thumbs.c intern/thumbs_blend.c - intern/tiff.c intern/util.c intern/writeimage.c @@ -119,6 +116,10 @@ if(WITH_IMAGE_TIFF) list(APPEND INC_SYS ${TIFF_INCLUDE_DIR} ) + list(APPEND SRC + intern/tiff.c + ) + add_definitions(-DWITH_TIFF) endif() @@ -126,6 +127,10 @@ if(WITH_IMAGE_OPENJPEG) list(APPEND INC_SYS ${OPENJPEG_INCLUDE_DIRS} ) + list(APPEND SRC + intern/jp2.c + ) + add_definitions(-DWITH_OPENJPEG) endif() @@ -165,6 +170,9 @@ if(WITH_IMAGE_CINEON) endif() if(WITH_IMAGE_HDR) + list(APPEND SRC + intern/radiance_hdr.c + ) add_definitions(-DWITH_HDR) endif() diff --git a/source/blender/imbuf/SConscript b/source/blender/imbuf/SConscript index a80f92b4421..7c5b94b9e12 100644 --- a/source/blender/imbuf/SConscript +++ b/source/blender/imbuf/SConscript @@ -22,6 +22,8 @@ if env['WITH_BF_OPENEXR']: if env['WITH_BF_TIFF']: defs.append('WITH_TIFF') +else: + sources.remove('intern/tiff.c') if env['WITH_BF_DDS']: defs.append('WITH_DDS') @@ -31,6 +33,8 @@ if env['WITH_BF_CINEON']: if env['WITH_BF_HDR']: defs.append('WITH_HDR') +else: + sources.remove('intern/radiance_hdr.c') if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') @@ -39,6 +43,8 @@ if env['WITH_BF_FFMPEG']: if env['WITH_BF_OPENJPEG']: defs.append('WITH_OPENJPEG') incs += ' ' + env['BF_OPENJPEG_INC'] +else: + sources.remove('intern/jp2.c') if env['WITH_BF_REDCODE']: defs.append('WITH_REDCODE') diff --git a/source/blender/imbuf/intern/IMB_anim.h b/source/blender/imbuf/intern/IMB_anim.h index 8436846bf2e..43168b97b88 100644 --- a/source/blender/imbuf/intern/IMB_anim.h +++ b/source/blender/imbuf/intern/IMB_anim.h @@ -38,21 +38,21 @@ #define IMB_ANIM_H #ifdef _WIN32 -#define INC_OLE2 -#include <windows.h> -#include <windowsx.h> -#include <mmsystem.h> -#include <memory.h> -#include <commdlg.h> - -#ifndef FREE_WINDOWS -#include <vfw.h> -#endif +# define INC_OLE2 +# include <windows.h> +# include <windowsx.h> +# include <mmsystem.h> +# include <memory.h> +# include <commdlg.h> + +# ifndef FREE_WINDOWS +# include <vfw.h> +# endif -#undef AVIIF_KEYFRAME // redefined in AVI_avi.h -#undef AVIIF_LIST // redefined in AVI_avi.h +# undef AVIIF_KEYFRAME // redefined in AVI_avi.h +# undef AVIIF_LIST // redefined in AVI_avi.h -#define FIXCC(fcc) if (fcc == 0) fcc = mmioFOURCC('N', 'o', 'n', 'e'); \ +# define FIXCC(fcc) if (fcc == 0) fcc = mmioFOURCC('N', 'o', 'n', 'e'); \ if (fcc == BI_RLE8) fcc = mmioFOURCC('R', 'l', 'e', '8'); #endif @@ -60,10 +60,11 @@ #include <ctype.h> #include <stdlib.h> #include <stdio.h> -#ifndef _WIN32 -#include <dirent.h> + +#ifdef _WIN32 +# include <io.h> #else -#include <io.h> +# include <dirent.h> #endif #include "BLI_blenlib.h" /* BLI_remlink BLI_filesize BLI_addtail @@ -74,23 +75,23 @@ #include "AVI_avi.h" #ifdef WITH_QUICKTIME -#if defined(_WIN32) || defined(__APPLE__) -#include "quicktime_import.h" -#endif /* _WIN32 || __APPLE__ */ +# if defined(_WIN32) || defined(__APPLE__) +# include "quicktime_import.h" +# endif /* _WIN32 || __APPLE__ */ #endif /* WITH_QUICKTIME */ #ifdef WITH_FFMPEG -#include <libavformat/avformat.h> -#include <libavcodec/avcodec.h> -#include <libswscale/swscale.h> +# include <libavformat/avformat.h> +# include <libavcodec/avcodec.h> +# include <libswscale/swscale.h> #endif #ifdef WITH_REDCODE -#ifdef _WIN32 /* on windows we use the one in extern instead */ -#include "libredcode/format.h" -#else -#include "libredcode/format.h" -#endif +# ifdef _WIN32 /* on windows we use the one in extern instead */ +# include "libredcode/format.h" +# else +# include "libredcode/format.h" +# endif #endif #include "IMB_imbuf_types.h" @@ -107,12 +108,12 @@ #define SWAP_S(x) (((x << 8) & 0xff00) | ((x >> 8) & 0xff)) /* more endianness... should move to a separate file... */ -#if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__) -#define GET_ID GET_BIG_LONG -#define LITTLE_LONG SWAP_LONG +#ifdef __BIG_ENDIAN__ +# define GET_ID GET_BIG_LONG +# define LITTLE_LONG SWAP_LONG #else -#define GET_ID GET_LITTLE_LONG -#define LITTLE_LONG ENDIAN_NOP +# define GET_ID GET_LITTLE_LONG +# define LITTLE_LONG ENDIAN_NOP #endif /* anim.curtype, runtime only */ diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h index 1a72af88de2..51ee7e28d0b 100644 --- a/source/blender/imbuf/intern/IMB_indexer.h +++ b/source/blender/imbuf/intern/IMB_indexer.h @@ -28,7 +28,7 @@ #define IMB_INDEXER_H #ifdef WIN32 -#include <io.h> +# include <io.h> #endif #include <stdlib.h> diff --git a/source/blender/imbuf/intern/filter.c b/source/blender/imbuf/intern/filter.c index 2677913caed..3719242aaba 100644 --- a/source/blender/imbuf/intern/filter.c +++ b/source/blender/imbuf/intern/filter.c @@ -518,7 +518,7 @@ void IMB_makemipmap(ImBuf *ibuf, int use_filter) hbuf= ibuf->mipmap[curmap]; hbuf->miplevel= curmap+1; - if(!hbuf || (hbuf->x <= 2 && hbuf->y <= 2)) + if(hbuf->x <= 2 && hbuf->y <= 2) break; curmap++; diff --git a/source/blender/imbuf/intern/imbuf.h b/source/blender/imbuf/intern/imbuf.h index cd7d385ed92..22481241812 100644 --- a/source/blender/imbuf/intern/imbuf.h +++ b/source/blender/imbuf/intern/imbuf.h @@ -44,7 +44,7 @@ #include <stdio.h> #ifndef WIN32 -#include <unistd.h> +# include <unistd.h> #endif #include <fcntl.h> @@ -53,11 +53,8 @@ #include <math.h> #ifndef WIN32 -#include <sys/mman.h> -#endif - -#if !defined(WIN32) -#define O_BINARY 0 +# include <sys/mman.h> +# define O_BINARY 0 #endif #define SWAP_SHORT(x) (((x & 0xff) << 8) | ((x >> 8) & 0xff)) @@ -65,16 +62,16 @@ #define ENDIAN_NOP(x) (x) -#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__hppa__) || (defined (__APPLE__) && !defined(__LITTLE_ENDIAN__)) -#define LITTLE_SHORT SWAP_SHORT -#define LITTLE_LONG SWAP_LONG -#define BIG_SHORT ENDIAN_NOP -#define BIG_LONG ENDIAN_NOP +#ifdef __BIG_ENDIAN__ +# define LITTLE_SHORT SWAP_SHORT +# define LITTLE_LONG SWAP_LONG +# define BIG_SHORT ENDIAN_NOP +# define BIG_LONG ENDIAN_NOP #else -#define LITTLE_SHORT ENDIAN_NOP -#define LITTLE_LONG ENDIAN_NOP -#define BIG_SHORT SWAP_SHORT -#define BIG_LONG SWAP_LONG +# define LITTLE_SHORT ENDIAN_NOP +# define LITTLE_LONG ENDIAN_NOP +# define BIG_SHORT SWAP_SHORT +# define BIG_LONG SWAP_LONG #endif typedef unsigned char uchar; diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 5fbe9fc2245..199ba0eff14 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -159,24 +159,24 @@ struct anim_index * IMB_indexer_open(const char * name) int i; if (!fp) { - return 0; + return NULL; } if (fread(header, 12, 1, fp) != 1) { fclose(fp); - return 0; + return NULL; } header[12] = 0; if (memcmp(header, magic, 8) != 0) { fclose(fp); - return 0; + return NULL; } if (atoi(header+9) != INDEX_FILE_VERSION) { fclose(fp); - return 0; + return NULL; } idx = MEM_callocN( sizeof(struct anim_index), "anim_index"); @@ -916,7 +916,7 @@ static AviMovie * alloc_proxy_output_avi( if (AVI_open_compress (filename, avi, 1, format) != AVI_ERROR_NONE) { MEM_freeN(avi); - return 0; + return NULL; } AVI_set_compress_option (avi, AVI_OPTION_TYPE_MAIN, 0, AVI_OPTION_WIDTH, &x); @@ -1000,7 +1000,7 @@ static void index_rebuild_fallback(struct anim * anim, s_ibuf->rect, x * y * 4); /* note that libavi free's the buffer... */ - s_ibuf->rect = 0; + s_ibuf->rect = NULL; IMB_freeImBuf(s_ibuf); } @@ -1056,14 +1056,14 @@ void IMB_free_indices(struct anim * anim) for (i = 0; i < IMB_PROXY_MAX_SLOT; i++) { if (anim->proxy_anim[i]) { IMB_close_anim(anim->proxy_anim[i]); - anim->proxy_anim[i] = 0; + anim->proxy_anim[i] = NULL; } } for (i = 0; i < IMB_TC_MAX_SLOT; i++) { if (anim->curr_idx[i]) { IMB_indexer_close(anim->curr_idx[i]); - anim->curr_idx[i] = 0; + anim->curr_idx[i] = NULL; } } @@ -1116,7 +1116,7 @@ struct anim_index * IMB_anim_open_index( } if (anim->indices_tried & tc) { - return 0; + return NULL; } get_tc_filename(anim, tc, fname); diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index adbf3659d3a..c6aaf336fb7 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -515,14 +515,15 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags) } - ibuf->ftype = IMAGIC; - ibuf->profile = IB_PROFILE_SRGB; - - test_endian_zbuf(ibuf); - if (ibuf) { - if (ibuf->rect) + ibuf->ftype = IMAGIC; + ibuf->profile = IB_PROFILE_SRGB; + + test_endian_zbuf(ibuf); + + if (ibuf->rect) { IMB_convert_rgba_to_abgr(ibuf); + } } return(ibuf); diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index a4eae492a58..4872896bf3a 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -25,9 +25,6 @@ * \ingroup imbuf */ - -#ifdef WITH_OPENJPEG - #include "MEM_guardedalloc.h" #include "BLI_blenlib.h" @@ -97,7 +94,7 @@ static void info_callback(const char *msg, void *client_data) { struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) { - struct ImBuf *ibuf = 0; + struct ImBuf *ibuf = NULL; int use_float = 0; /* for precision higher then 8 use float */ long signed_offsets[4]= {0, 0, 0, 0}; @@ -117,7 +114,7 @@ struct ImBuf *imb_jp2_decode(unsigned char *mem, size_t size, int flags) opj_dinfo_t* dinfo = NULL; /* handle to a decompressor */ opj_cio_t *cio = NULL; - if (check_jp2(mem) == 0) return(0); + if (check_jp2(mem) == 0) return(NULL); /* configure the event callbacks (not required) */ memset(&event_mgr, 0, sizeof(opj_event_mgr_t)); @@ -751,5 +748,3 @@ int imb_savejp2(struct ImBuf *ibuf, const char *name, int flags) { return 1; } - -#endif /* WITH_OPENJPEG */ diff --git a/source/blender/imbuf/intern/md5.c b/source/blender/imbuf/intern/md5.c index 18148143eb9..2192fa32f19 100644 --- a/source/blender/imbuf/intern/md5.c +++ b/source/blender/imbuf/intern/md5.c @@ -28,11 +28,11 @@ #include "md5.h" -#ifdef WORDS_BIGENDIAN -# define SWAP(n) \ +#ifdef __BIG_ENDIAN__ +# define SWAP(n) \ (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) #else -# define SWAP(n) (n) +# define SWAP(n) (n) #endif diff --git a/source/blender/imbuf/intern/radiance_hdr.c b/source/blender/imbuf/intern/radiance_hdr.c index ddddec1c09f..9dd330ca88b 100644 --- a/source/blender/imbuf/intern/radiance_hdr.c +++ b/source/blender/imbuf/intern/radiance_hdr.c @@ -33,9 +33,6 @@ * \ingroup imbuf */ - -#ifdef WITH_HDR - /* ---------------------------------------------------------------------- Radiance High Dynamic Range image file IO For description and code for reading/writing of radiance hdr files @@ -45,7 +42,7 @@ */ #ifdef WIN32 -#include <io.h> +# include <io.h> #endif #include "MEM_guardedalloc.h" @@ -369,5 +366,3 @@ int imb_savehdr(struct ImBuf *ibuf, const char *name, int flags) fclose(file); return 1; } - -#endif /* WITH_HDR */ diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 7beb853fe62..ccb271393a4 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -45,8 +45,6 @@ * used to compress images. */ -#ifdef WITH_TIFF - #include <string.h> #include "imbuf.h" @@ -836,5 +834,3 @@ int imb_savetiff(ImBuf *ibuf, const char *name, int flags) if(pixels16) _TIFFfree(pixels16); return (1); } - -#endif /* WITH_TIFF */ diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index 8fd9f49cd0a..80fc6f63363 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -146,16 +146,16 @@ typedef struct PreviewImage { * **/ -#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__) -/* big endian */ -#define MAKE_ID2(c, d) ( (c)<<8 | (d) ) -#define MOST_SIG_BYTE 0 -#define BBIG_ENDIAN +#ifdef __BIG_ENDIAN__ + /* big endian */ +# define MAKE_ID2(c, d) ( (c)<<8 | (d) ) +# define MOST_SIG_BYTE 0 +# define BBIG_ENDIAN #else -/* little endian */ -#define MAKE_ID2(c, d) ( (d)<<8 | (c) ) -#define MOST_SIG_BYTE 1 -#define BLITTLE_ENDIAN + /* little endian */ +# define MAKE_ID2(c, d) ( (d)<<8 | (c) ) +# define MOST_SIG_BYTE 1 +# define BLITTLE_ENDIAN #endif /* ID from database */ diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index a820e59779f..492dd34caa6 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -188,18 +188,13 @@ typedef struct bPoseChannel { char name[32]; /* Channels need longer names than normal blender objects */ short flag; /* dynamic, for detecting transform changes */ - short constflag; /* for quick detecting which constraints affect this channel */ short ikflag; /* settings for IK bones */ - short selectflag; /* copy of bone flag, so you can work with library armatures, not for runtime use */ short protectflag; /* protect channels from being transformed */ short agrp_index; /* index of action-group this bone belongs to (0 = default/no group) */ - -// XXX depreceated.... old animation system (armature only viz) ---- - int pathlen; /* for drawing paths, the amount of frames */ - int pathsf; /* for drawing paths, the start frame number */ - int pathef; /* for drawing paths, the end frame number */ -// XXX end of depreceated code ------------------------------------- - + char constflag; /* for quick detecting which constraints affect this channel */ + char selectflag; /* copy of bone flag, so you can work with library armatures, not for runtime use */ + char pad0[6]; + struct Bone *bone; /* set on read file or rebuild pose */ struct bPoseChannel *parent; /* set on read file or rebuild pose */ struct bPoseChannel *child; /* set on read file or rebuild pose, the 'ik' child, for b-bones */ @@ -233,7 +228,7 @@ typedef struct bPoseChannel { float ikrotweight; /* weight of joint rotation constraint */ float iklinweight; /* weight of joint stretch constraint */ - float *path; /* totpath x 3 x float */ // XXX depreceated... old animation system (armature only viz) + void *temp; /* use for outliner */ } bPoseChannel; diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index bac1e3cd8ca..4cfd0b56b70 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -103,10 +103,11 @@ typedef struct bNodeSocket { #define SOCK_FLOAT 0 #define SOCK_VECTOR 1 #define SOCK_RGBA 2 -#define SOCK_INT 3 +#define SOCK_SHADER 3 #define SOCK_BOOLEAN 4 #define SOCK_MESH 5 -#define NUM_SOCKET_TYPES 6 /* must be last! */ +#define SOCK_INT 6 +#define NUM_SOCKET_TYPES 7 /* must be last! */ /* socket side (input/output) */ #define SOCK_IN 1 @@ -123,6 +124,10 @@ typedef struct bNodeSocket { #define SOCK_DYNAMIC 16 /* group socket should not be exposed */ #define SOCK_INTERNAL 32 + /* socket collapsed in UI */ +#define SOCK_COLLAPSED 64 + /* hide socket value, if it gets auto default */ +#define SOCK_HIDE_VALUE 128 typedef struct bNodePreview { unsigned char *rect; diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 815a9c92968..53e1bf7e6f6 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -137,7 +137,7 @@ static TimeMarker *rna_Action_pose_markers_new(bAction *act, ReportList *reports TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); marker->flag= 1; marker->frame= 1; - BLI_strncpy(marker->name, name, sizeof(marker->name)); + BLI_strncpy_utf8(marker->name, name, sizeof(marker->name)); BLI_addtail(&act->markers, marker); return marker; } diff --git a/source/blender/makesrna/intern/rna_actuator.c b/source/blender/makesrna/intern/rna_actuator.c index 7356af05dcb..6aff68a9c09 100644 --- a/source/blender/makesrna/intern/rna_actuator.c +++ b/source/blender/makesrna/intern/rna_actuator.c @@ -1931,9 +1931,9 @@ static void rna_def_steering_actuator(BlenderRNA *brna) {1, "X", 0, "X", ""}, {2, "Y", 0, "Y", ""}, {3, "Z", 0, "Z", ""}, - {4, "-X", 0, "-X", ""}, - {5, "-Y", 0, "-Y", ""}, - {6, "-Z", 0, "-Z", ""}, + {4, "NEG_X", 0, "-X", ""}, + {5, "NEG_Y", 0, "-Y", ""}, + {6, "NEG_Z", 0, "-Z", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SteeringActuator", "Actuator"); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 0395a54be8e..2f5f22c52d5 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -252,7 +252,7 @@ static void rna_ksPath_RnaPath_get(PointerRNA *ptr, char *value) if (ksp->rna_path) strcpy(value, ksp->rna_path); else - strcpy(value, ""); + value[0]= '\0'; } static int rna_ksPath_RnaPath_length(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index e2399b5b57c..4ed5d2a125a 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -253,7 +253,7 @@ static void rna_EditBone_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(ebone->name)], newname[sizeof(ebone->name)]; /* need to be on the stack */ - BLI_strncpy(newname, value, sizeof(ebone->name)); + BLI_strncpy_utf8(newname, value, sizeof(ebone->name)); BLI_strncpy(oldname, ebone->name, sizeof(ebone->name)); ED_armature_bone_rename(arm, oldname, newname); @@ -266,7 +266,7 @@ static void rna_Bone_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(bone->name)], newname[sizeof(bone->name)]; /* need to be on the stack */ - BLI_strncpy(newname, value, sizeof(bone->name)); + BLI_strncpy_utf8(newname, value, sizeof(bone->name)); BLI_strncpy(oldname, bone->name, sizeof(bone->name)); ED_armature_bone_rename(arm, oldname, newname); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 22d9a19f933..fdbb4f09f93 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -170,7 +170,7 @@ static void rna_Constraint_name_set(PointerRNA *ptr, const char *value) BLI_strncpy(oldname, con->name, sizeof(con->name)); /* copy the new name into the name slot */ - BLI_strncpy(con->name, value, sizeof(con->name)); + BLI_strncpy_utf8(con->name, value, sizeof(con->name)); /* make sure name is unique */ if (ptr->id.data) { diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 3cf6feb005c..e3f86032213 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -74,6 +74,20 @@ EnumPropertyItem curve_type_items[] = { {CU_NURBS, "NURBS", 0, "Ease", ""}, {0, NULL, 0, NULL, NULL}}; +static const EnumPropertyItem curve3d_fill_mode_items[]= { + {0, "FULL", 0, "Full", ""}, + {CU_BACK, "BACK", 0, "Back", ""}, + {CU_FRONT, "FRONT", 0, "Front", ""}, + {CU_FRONT|CU_BACK, "HALF", 0, "Half", ""}, + {0, NULL, 0, NULL, NULL}}; + +static const EnumPropertyItem curve2d_fill_mode_items[]= { + {0, "NONE", 0, "None", ""}, + {CU_BACK, "BACK", 0, "Back", ""}, + {CU_FRONT, "FRONT", 0, "Front", ""}, + {CU_FRONT|CU_BACK, "BOTH", 0, "Both", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME #include "BLI_math.h" @@ -278,6 +292,12 @@ static void rna_Curve_dimension_set(PointerRNA *ptr, int value) } } +static EnumPropertyItem *rna_Curve_fill_mode_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) +{ + Curve *cu= (Curve*)ptr->id.data; + + return (cu->flag&CU_3D) ? curve3d_fill_mode_items : curve2d_fill_mode_items; +} static int rna_Nurb_length(PointerRNA *ptr) { @@ -1345,14 +1365,11 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Dimensions", "Select 2D or 3D curve type"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "use_fill_front", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FRONT); - RNA_def_property_ui_text(prop, "Front", "Draw filled front for extruded/beveled curves"); - RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - - prop= RNA_def_property(srna, "use_fill_back", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_BACK); - RNA_def_property_ui_text(prop, "Back", "Draw filled back for extruded/beveled curves"); + prop= RNA_def_property(srna, "fill_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); + RNA_def_property_enum_items(prop, curve3d_fill_mode_items); + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Curve_fill_mode_itemf"); + RNA_def_property_ui_text(prop, "Fill Mode", "Mode of filling curve"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "twist_mode", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index e922a007249..c0c8ac6b88a 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -215,7 +215,7 @@ static void rna_DriverTarget_RnaPath_get(PointerRNA *ptr, char *value) if (dtar->rna_path) strcpy(value, dtar->rna_path); else - strcpy(value, ""); + value[0]= '\0'; } static int rna_DriverTarget_RnaPath_length(PointerRNA *ptr) @@ -309,7 +309,7 @@ static void rna_FCurve_RnaPath_get(PointerRNA *ptr, char *value) if (fcu->rna_path) strcpy(value, fcu->rna_path); else - strcpy(value, ""); + value[0]= '\0'; } static int rna_FCurve_RnaPath_length(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index 7327c7203b9..083e87dfd4e 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -37,6 +37,9 @@ #include <time.h> #include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "DNA_packedFile_types.h" #include "BIF_gl.h" @@ -127,6 +130,38 @@ static void rna_Image_save(Image *image, ReportList *reports) } } +static void rna_Image_pack(Image *image, ReportList *reports, int as_png) +{ + ImBuf *ibuf = BKE_image_get_ibuf(image, NULL); + + if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { + BKE_reportf(reports, RPT_ERROR, "Can't pack edited image from disk, only as internal PNG."); + } + else { + if(as_png) { + BKE_image_memorypack(image); + } + else { + image->packedfile= newPackedFile(reports, image->name); + } + } +} + +static void rna_Image_unpack(Image *image, ReportList *reports, int method) +{ + if (!image->packedfile) { + BKE_report(reports, RPT_ERROR, "Image not packed"); + } + else if (image->source==IMA_SRC_SEQUENCE || image->source==IMA_SRC_MOVIE) { + BKE_report(reports, RPT_ERROR, "Unpacking movies or image sequences not supported."); + return; + } + else { + /* reports its own error on failier */ + unpackImage (reports, image, method); + } +} + static void rna_Image_reload(Image *image) { BKE_image_signal(image, NULL, IMA_SIGNAL_RELOAD); @@ -211,6 +246,16 @@ void RNA_api_image(StructRNA *srna) RNA_def_function_ui_description(func, "Save image to its source path"); RNA_def_function_flag(func, FUNC_USE_REPORTS); + func= RNA_def_function(srna, "pack", "rna_Image_pack"); + RNA_def_function_ui_description(func, "Pack an image as embedded data into the .blend file."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_boolean(func, "as_png", 0, "as_png", "Pack the image as PNG (needed for generated/dirty images)"); + + func= RNA_def_function(srna, "unpack", "rna_Image_unpack"); + RNA_def_function_ui_description(func, "Save an image packed in the .blend file to disk"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_enum(func, "method", unpack_method_items, PF_USE_LOCAL, "method", "How to unpack."); + func= RNA_def_function(srna, "reload", "rna_Image_reload"); RNA_def_function_ui_description(func, "Reload the image from its source path"); diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 3e65eb8665e..ad6f67cddaf 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -76,7 +76,7 @@ void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value) BLI_strncpy(oldname, kb->name, sizeof(kb->name)); /* copy the new name into the name slot */ - BLI_strncpy(kb->name, value, sizeof(kb->name)); + BLI_strncpy_utf8(kb->name, value, sizeof(kb->name)); /* make sure the name is truly unique */ if (ptr->id.data) { diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 80c98e8c428..b0554ea5b4f 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -690,7 +690,7 @@ static void rna_MeshTextureFaceLayer_name_set(PointerRNA *ptr, const char *value Mesh *me= (Mesh*)ptr->id.data; CustomData *fdata= rna_mesh_fdata(me); CustomDataLayer *cdl= (CustomDataLayer*)ptr->data; - BLI_strncpy(cdl->name, value, sizeof(cdl->name)); + BLI_strncpy_utf8(cdl->name, value, sizeof(cdl->name)); CustomData_set_layer_unique_name(fdata, cdl - fdata->layers); } @@ -802,7 +802,7 @@ static void rna_MeshColorLayer_name_set(PointerRNA *ptr, const char *value) Mesh *me= (Mesh*)ptr->id.data; CustomData *fdata= rna_mesh_fdata(me); CustomDataLayer *cdl= (CustomDataLayer*)ptr->data; - BLI_strncpy(cdl->name, value, sizeof(cdl->name)); + BLI_strncpy_utf8(cdl->name, value, sizeof(cdl->name)); CustomData_set_layer_unique_name(fdata, cdl - fdata->layers); } diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 464f676b7f6..b83f06c633c 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -211,7 +211,7 @@ void rna_Modifier_name_set(PointerRNA *ptr, const char *value) BLI_strncpy(oldname, md->name, sizeof(md->name)); /* copy the new name into the name slot */ - BLI_strncpy(md->name, value, sizeof(md->name)); + BLI_strncpy_utf8(md->name, value, sizeof(md->name)); /* make sure the name is truly unique */ if (ptr->id.data) { diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index ef4adde6fb4..2a234dfaa61 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -59,7 +59,7 @@ static void rna_NlaStrip_name_set(PointerRNA *ptr, const char *value) NlaStrip *data= (NlaStrip *)ptr->data; /* copy the name first */ - BLI_strncpy(data->name, value, sizeof(data->name)); + BLI_strncpy_utf8(data->name, value, sizeof(data->name)); /* validate if there's enough info to do so */ if (ptr->id.data) { diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 0554e4d00ad..61947977fee 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -361,7 +361,7 @@ static void rna_Node_name_set(PointerRNA *ptr, const char *value) /* make a copy of the old name first */ BLI_strncpy(oldname, node->name, sizeof(node->name)); /* set new name */ - BLI_strncpy(node->name, value, sizeof(node->name)); + BLI_strncpy_utf8(node->name, value, sizeof(node->name)); nodeUniqueName(ntree, node); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index bb223ac95b4..e7b5529af02 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -466,7 +466,7 @@ void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value) { Object *ob= (Object *)ptr->id.data; bDeformGroup *dg= (bDeformGroup *)ptr->data; - BLI_strncpy(dg->name, value, sizeof(dg->name)); + BLI_strncpy_utf8(dg->name, value, sizeof(dg->name)); defgroup_unique_name(dg, ob); } @@ -512,7 +512,7 @@ void rna_object_vgroup_name_index_get(PointerRNA *ptr, char *value, int index) dg= BLI_findlink(&ob->defbase, index-1); if(dg) BLI_strncpy(value, dg->name, sizeof(dg->name)); - else BLI_strncpy(value, "", sizeof(dg->name)); + else value[0]= '\0'; } int rna_object_vgroup_name_index_length(PointerRNA *ptr, int index) @@ -535,7 +535,7 @@ void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result Object *ob= (Object*)ptr->id.data; bDeformGroup *dg= defgroup_find_name(ob, value); if(dg) { - BLI_strncpy(result, value, maxlen); + BLI_strncpy(result, value, maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */ return; } @@ -562,7 +562,7 @@ void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *resul } } - BLI_strncpy(result, "", maxlen); + result[0]= '\0'; } void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen) @@ -585,7 +585,7 @@ void rna_object_vcollayer_name_set(PointerRNA *ptr, const char *value, char *res } } - BLI_strncpy(result, "", maxlen); + result[0]= '\0'; } static int rna_Object_active_material_index_get(PointerRNA *ptr) @@ -836,7 +836,7 @@ static void rna_MaterialSlot_name_get(PointerRNA *ptr, char *str) if(ma) strcpy(str, ma->id.name+2); else - strcpy(str, ""); + str[0]= '\0'; } static void rna_MaterialSlot_update(Main *bmain, Scene *scene, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 0dd8218d1b9..434634f6b10 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -222,7 +222,7 @@ static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(pchan->name)], newname[sizeof(pchan->name)]; /* need to be on the stack */ - BLI_strncpy(newname, value, sizeof(pchan->name)); + BLI_strncpy_utf8(newname, value, sizeof(pchan->name)); BLI_strncpy(oldname, pchan->name, sizeof(pchan->name)); ED_armature_bone_rename(ob->data, oldname, newname); @@ -411,7 +411,7 @@ static void rna_pose_bgroup_name_index_get(PointerRNA *ptr, char *value, int ind grp= BLI_findlink(&pose->agroups, index-1); if(grp) BLI_strncpy(value, grp->name, sizeof(grp->name)); - else BLI_strncpy(value, "", sizeof(grp->name)); // XXX if invalid pointer, won't this crash? + else value[0]= '\0'; } static int rna_pose_bgroup_name_index_length(PointerRNA *ptr, int index) @@ -451,7 +451,7 @@ static void rna_pose_pgroup_name_set(PointerRNA *ptr, const char *value, char *r } } - BLI_strncpy(result, "", maxlen); + result[0]= '\0'; } #endif diff --git a/source/blender/makesrna/intern/rna_property.c b/source/blender/makesrna/intern/rna_property.c index 9fd5610a577..e2b886b8d38 100644 --- a/source/blender/makesrna/intern/rna_property.c +++ b/source/blender/makesrna/intern/rna_property.c @@ -88,7 +88,7 @@ static void rna_GameProperty_type_set(PointerRNA *ptr, int value) static void rna_GameProperty_name_set(PointerRNA *ptr, const char *value) { bProperty *prop= (bProperty*)(ptr->data); - BLI_strncpy(prop->name, value, sizeof(prop->name)); + BLI_strncpy_utf8(prop->name, value, sizeof(prop->name)); unique_property(NULL, prop, 1); } diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 197ddd2ba06..76d7c3153d8 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -737,7 +737,7 @@ static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value) RenderEngineType *type= BLI_findlink(&R_engines, value); if(type) - BLI_strncpy(rd->engine, type->idname, sizeof(rd->engine)); + BLI_strncpy_utf8(rd->engine, type->idname, sizeof(rd->engine)); } static EnumPropertyItem *rna_RenderSettings_engine_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) @@ -810,7 +810,7 @@ static void rna_SceneRenderLayer_name_set(PointerRNA *ptr, const char *value) Scene *scene= (Scene*)ptr->id.data; SceneRenderLayer *rl= (SceneRenderLayer*)ptr->data; - BLI_strncpy(rl->name, value, sizeof(rl->name)); + BLI_strncpy_utf8(rl->name, value, sizeof(rl->name)); if(scene->nodetree) { bNode *node; @@ -1011,7 +1011,7 @@ static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[]) TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); marker->flag= SELECT; marker->frame= 1; - BLI_strncpy(marker->name, name, sizeof(marker->name)); + BLI_strncpy_utf8(marker->name, name, sizeof(marker->name)); BLI_addtail(&scene->markers, marker); return marker; } @@ -1811,8 +1811,8 @@ static void rna_def_scene_game_data(BlenderRNA *brna) static EnumPropertyItem obstacle_simulation_items[] = { {OBSTSIMULATION_NONE, "NONE", 0, "None", ""}, - {OBSTSIMULATION_TOI_rays, "RVO (rays)", 0, "RVO (rays)", ""}, - {OBSTSIMULATION_TOI_cells, "RVO (cells)", 0, "RVO (cells)", ""}, + {OBSTSIMULATION_TOI_rays, "RVO_RAYS", 0, "RVO (rays)", ""}, + {OBSTSIMULATION_TOI_cells, "RVO_CELLS", 0, "RVO (cells)", ""}, {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "SceneGameData", NULL); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 627c2274965..79724adf91c 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -359,7 +359,7 @@ static void rna_Sequence_name_set(PointerRNA *ptr, const char *value) BLI_strncpy(oldname, seq->name+2, sizeof(seq->name)-2); /* copy the new name into the name slot */ - BLI_strncpy(seq->name+2, value, sizeof(seq->name)-2); + BLI_strncpy_utf8(seq->name+2, value, sizeof(seq->name)-2); /* make sure the name is unique */ seqbase_unique_name_recursive(&scene->ed->seqbase, seq); diff --git a/source/blender/makesrna/intern/rna_text.c b/source/blender/makesrna/intern/rna_text.c index 959f9db851b..6a1e93fce41 100644 --- a/source/blender/makesrna/intern/rna_text.c +++ b/source/blender/makesrna/intern/rna_text.c @@ -53,7 +53,7 @@ static void rna_Text_filename_get(PointerRNA *ptr, char *value) if(text->name) strcpy(value, text->name); else - strcpy(value, ""); + value[0]= '\0'; } static int rna_Text_filename_length(PointerRNA *ptr) @@ -88,7 +88,7 @@ static void rna_TextLine_body_get(PointerRNA *ptr, char *value) if(line->line) strcpy(value, line->line); else - strcpy(value, ""); + value[0]= '\0'; } static int rna_TextLine_body_length(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 890be76c49a..608a7326d79 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -260,7 +260,7 @@ static void rna_TextureSlot_name_get(PointerRNA *ptr, char *str) if(mtex->tex) strcpy(str, mtex->tex->id.name+2); else - strcpy(str, ""); + str[0]= '\0'; } static int rna_TextureSlot_output_node_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_texture_api.c b/source/blender/makesrna/intern/rna_texture_api.c index bbadbd4f683..0ebb28dbf4a 100644 --- a/source/blender/makesrna/intern/rna_texture_api.c +++ b/source/blender/makesrna/intern/rna_texture_api.c @@ -68,7 +68,7 @@ void clear_envmap(struct EnvMap *env, bContext *C) } } -void texture_evaluate(struct Tex *tex, float value[3], float color_r[3]) +void texture_evaluate(struct Tex *tex, float value[3], float color_r[4]) { TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; multitex_ext(tex, value, NULL, NULL, 1, &texres); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 7ce1e1ab88f..a259f84ff1a 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -348,20 +348,20 @@ EnumPropertyItem keymap_modifiers_items[] = { {0, NULL, 0, NULL, NULL}}; EnumPropertyItem operator_flag_items[] = { - {OPTYPE_REGISTER, "REGISTER", 0, "Register", ""}, - {OPTYPE_UNDO, "UNDO", 0, "Undo", ""}, - {OPTYPE_BLOCKING, "BLOCKING", 0, "Blocking", ""}, - {OPTYPE_MACRO, "MACRO", 0, "Macro", ""}, - {OPTYPE_GRAB_POINTER, "GRAB_POINTER", 0, "Grab Pointer", ""}, - {OPTYPE_PRESET, "PRESET", 0, "Preset", ""}, - {OPTYPE_INTERNAL, "INTERNAL", 0, "Internal", ""}, + {OPTYPE_REGISTER, "REGISTER", 0, "Register", "Display in the info window and support the redo toolbar panel"}, + {OPTYPE_UNDO, "UNDO", 0, "Undo", "Push an undo event (needed for operator redo)"}, + {OPTYPE_BLOCKING, "BLOCKING", 0, "Blocking", "Block anything else from using the cursor"}, + {OPTYPE_MACRO, "MACRO", 0, "Macro", "Use to check if an operator is a macro"}, + {OPTYPE_GRAB_POINTER, "GRAB_POINTER", 0, "Grab Pointer", "Use so the operator grabs the mouse focus, enables wrapping when continuous grab is enabled"}, + {OPTYPE_PRESET, "PRESET", 0, "Preset", "Display a preset button with the operators settings"}, + {OPTYPE_INTERNAL, "INTERNAL", 0, "Internal", "Removes the operator from search results"}, {0, NULL, 0, NULL, NULL}}; EnumPropertyItem operator_return_items[] = { - {OPERATOR_RUNNING_MODAL, "RUNNING_MODAL", 0, "Running Modal", ""}, - {OPERATOR_CANCELLED, "CANCELLED", 0, "Cancelled", ""}, - {OPERATOR_FINISHED, "FINISHED", 0, "Finished", ""}, - {OPERATOR_PASS_THROUGH, "PASS_THROUGH", 0, "Pass Through", ""}, // used as a flag + {OPERATOR_RUNNING_MODAL, "RUNNING_MODAL", 0, "Running Modal", "Keep the operator running with blender"}, + {OPERATOR_CANCELLED, "CANCELLED", 0, "Cancelled", "When no action has been taken, operator exits"}, + {OPERATOR_FINISHED, "FINISHED", 0, "Finished", "When the operator is complete, operator exits"}, + {OPERATOR_PASS_THROUGH, "PASS_THROUGH", 0, "Pass Through", "Do nothing and pass the event on"}, // used as a flag {0, NULL, 0, NULL, NULL}}; /* flag/enum */ diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 98615c70553..128e888ca90 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -212,7 +212,7 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne /* For each weight (vertex), make the mix between org and new weights. */ for (i = 0; i < num; i++) { int idx = indices ? indices[i] : i; - const float f= defvert_find_weight(&dvert[idx], ref_didx) * fact; + const float f = defvert_find_weight(&dvert[idx], ref_didx) * fact; org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f-f)); /* If that vertex is not in ref vgroup, assume null factor, and hence do nothing! */ } @@ -220,87 +220,107 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne else { /* Default "influence" behavior. */ /* For each weight (vertex), make the mix between org and new weights. */ - const float ifact= 1.0f - fact; + const float ifact = 1.0f - fact; for (i = 0; i < num; i++) { org_w[i] = (new_w[i] * fact) + (org_w[i] * ifact); } } } +/* Adds the given vertex to the specified vertex group, with given weight. */ +static void defvert_add_to_group(MDeformVert *dv, int defgrp_idx, const float weight) { + /* TODO, move into deform.c as a generic function. This assumes the vertex + * groups have already been checked, so this has to remain low level. */ + MDeformWeight *newdw; + + newdw = MEM_callocN(sizeof(MDeformWeight)*(dv->totweight+1), "defvert_add_to group, new deformWeight"); + if(dv->dw) { + memcpy(newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight); + MEM_freeN(dv->dw); + } + dv->dw = newdw; + dv->dw[dv->totweight].weight = weight; + dv->dw[dv->totweight].def_nr = defgrp_idx; + dv->totweight++; +} + +/* Removes the given vertex from the vertex group, specified either by its defgrp_idx, + * or directly by its MDeformWeight pointer, if dw is not NULL. + * WARNING: This function frees the given MDeformWeight, do not use it afterward! */ +static void defvert_remove_from_group(MDeformVert *dv, int defgrp_idx, MDeformWeight *dw) { + /* TODO, move this into deform.c as a generic function. */ + MDeformWeight *newdw; + int i; + + /* Get index of removed MDeformWeight. */ + if(dw == NULL) { + dw = dv->dw; + for (i = dv->totweight; i > 0; i--, dw++) { + if (dw->def_nr == defgrp_idx) + break; + } + i--; + } + else { + i = dw - dv->dw; + /* Security check! */ + if(i < 0 || i >= dv->totweight) + return; + } + + dv->totweight--; + /* If there are still other deform weights attached to this vert then remove + * this deform weight, and reshuffle the others. + */ + if(dv->totweight) { + newdw = MEM_mallocN(sizeof(MDeformWeight)*(dv->totweight), "defvert_remove_from_group, new deformWeight"); + if(dv->dw){ + memcpy(newdw, dv->dw, sizeof(MDeformWeight)*i); + memcpy(newdw+i, dv->dw+i+1, sizeof(MDeformWeight)*(dv->totweight-i)); + MEM_freeN(dv->dw); + } + dv->dw = newdw; + } + /* If there are no other deform weights left then just remove this one. */ + else { + MEM_freeN(dv->dw); + dv->dw = NULL; + } +} + + /* Applies weights to given vgroup (defgroup), and optionnaly add/remove vertices from the group. - * If indices is not NULL, it must be a table of same length as weights, mapping to the real - * vertex index (in case the weight table does not cover the whole vertices...). + * If dws is not NULL, it must be an array of MDeformWeight pointers of same length as weights (and + * defgrp_idx can then have any value). + * If indices is not NULL, it must be an array of same length as weights, mapping to the real + * vertex index (in case the weight array does not cover the whole vertices...). */ -void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, int num, +void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, MDeformWeight **dws, int num, const int *indices, const float *weights, int do_add, float add_thresh, int do_rem, float rem_thresh) { int i; - for (i = 0; i < num; i++) { - int j; - int add2vg = do_add; + for(i = 0; i < num; i++) { float w = weights[i]; MDeformVert *dv = &dvert[indices ? indices[i] : i]; - MDeformWeight *newdw; + MDeformWeight *dw = dws ? dws[i] : defvert_find_index(dv, defgrp_idx); /* Never allow weights out of [0.0, 1.0] range. */ CLAMP(w, 0.0f, 1.0f); - /* Let's first check to see if this vert is already in the weight group – if so - * let's update it, or remove it if needed. - */ - for (j = 0; j < dv->totweight; j++) { - /* If this weight corresponds to the deform group, update the value or, - * if lower than rem_threshold, remove the vertex from the vgroup. - */ - if (dv->dw[j].def_nr == defgrp_idx) { - /* Remove the vertex from this vgroup if needed. */ - if (do_rem && w < rem_thresh) { - /* TODO, move this into deform.c to make into a generic function */ - - dv->totweight--; - /* If there are still other deform weights attached to this vert then remove - * this deform weight, and reshuffle the others. - */ - if(dv->totweight) { - newdw = MEM_mallocN(sizeof(MDeformWeight)*(dv->totweight), "deformWeight"); - if(dv->dw){ - memcpy(newdw, dv->dw, sizeof(MDeformWeight)*j); - memcpy(newdw+j, dv->dw+j+1, sizeof(MDeformWeight)*(dv->totweight-j)); - MEM_freeN(dv->dw); - } - dv->dw = newdw; - } - /* If there are no other deform weights left then just remove this one. */ - else { - MEM_freeN(dv->dw); - dv->dw = NULL; - } - } - /* Else, just set the new computed weight. */ - else { - dv->dw[j].weight = w; - } - add2vg = FALSE; - break; + /* If the vertex is in this vgroup, remove it if needed, or just update it. */ + if(dw != NULL) { + if(do_rem && w < rem_thresh) { + defvert_remove_from_group(dv, defgrp_idx, dw); } - } - - /* If the vert wasn't in the deform group, add it if needed! - */ - if ((add2vg == TRUE) && w > add_thresh) { - /* TODO, mvoe into deform.c and make into a generic function, this assumes the vertex - * groups have already been checked, so this has to remain low level */ - newdw = MEM_callocN(sizeof(MDeformWeight)*(dv->totweight+1), "WeightVGEdit Modifier, deformWeight"); - if(dv->dw) { - memcpy(newdw, dv->dw, sizeof(MDeformWeight)*dv->totweight); - MEM_freeN(dv->dw); + else { + dw->weight = w; } - dv->dw = newdw; - dv->dw[dv->totweight].weight = w; - dv->dw[dv->totweight].def_nr = defgrp_idx; - dv->totweight++; + } + /* Else, add it if needed! */ + else if(do_add && w > add_thresh) { + defvert_add_to_group(dv, defgrp_idx, w); } } } diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.h b/source/blender/modifiers/intern/MOD_weightvg_util.h index ce3520f1900..a327bdf969b 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.h +++ b/source/blender/modifiers/intern/MOD_weightvg_util.h @@ -83,7 +83,7 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne * If indices is not NULL, it must be a table of same length as weights, mapping to the real * vertex index (in case the weight table does not cover the whole vertices...). */ -void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, int num, +void weightvg_update_vg(MDeformVert *dvert, int defgrp_idx, MDeformWeight **dws, int num, const int *indices, const float *weights, int do_add, float add_thresh, int do_rem, float rem_thresh); diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index fb6d4dc10e6..233ad8baf0b 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -187,6 +187,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der Mesh *ob_m = NULL; #endif MDeformVert *dvert = NULL; + MDeformWeight **dw = NULL; float *org_w; /* Array original weights. */ float *new_w; /* Array new weights. */ int numVerts; @@ -257,13 +258,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Get org weights, assuming 0.0 for vertices not in given vgroup. */ org_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, org_w"); - new_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, org_w"); + new_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, new_w"); + dw = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGEdit Modifier, dw"); for (i = 0; i < numVerts; i++) { - MDeformWeight *dw= defvert_find_index(&dvert[i], defgrp_idx); - org_w[i] = new_w[i] = wmd->default_weight; - - if(dw) { - org_w[i] = new_w[i] = dw->weight; + dw[i] = defvert_find_index(&dvert[i], defgrp_idx); + if(dw[i]) { + org_w[i] = new_w[i] = dw[i]->weight; + } + else { + org_w[i] = new_w[i] = wmd->default_weight; } } @@ -278,12 +281,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der wmd->mask_tex_mapping, wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name); /* Update/add/remove from vgroup. */ - weightvg_update_vg(dvert, defgrp_idx, numVerts, NULL, org_w, do_add, wmd->add_threshold, + weightvg_update_vg(dvert, defgrp_idx, dw, numVerts, NULL, org_w, do_add, wmd->add_threshold, do_rem, wmd->rem_threshold); /* Freeing stuff. */ MEM_freeN(org_w); MEM_freeN(new_w); + MEM_freeN(dw); /* Return the vgroup-modified mesh. */ return ret; diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index f1422a342eb..283e812e11c 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -229,13 +229,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der Mesh *ob_m = NULL; #endif MDeformVert *dvert = NULL; + MDeformWeight **dw1, **tdw1, **dw2, **tdw2; int numVerts; int defgrp_idx, defgrp_idx2 = -1; float *org_w; float *new_w; int *tidx, *indices = NULL; int numIdx = 0; - int i, j; + int i; char rel_ret = 0; /* Boolean, whether we have to release ret dm or not, when not using it! */ /* Get number of verts. */ @@ -304,78 +305,91 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Find out which vertices to work on. */ tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGMix Modifier, tidx"); + tdw1 = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGMix Modifier, tdw1"); + tdw2 = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGMix Modifier, tdw2"); switch (wmd->mix_set) { case MOD_WVG_SET_A: /* All vertices in first vgroup. */ for (i = 0; i < numVerts; i++) { - for (j = 0; j < dvert[i].totweight; j++) { - if(dvert[i].dw[j].def_nr == defgrp_idx) { - tidx[numIdx++] = i; - break; - } + MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx); + if(dw) { + tdw1[numIdx] = dw; + tdw2[numIdx] = defvert_find_index(&dvert[i], defgrp_idx2); + tidx[numIdx++] = i; } } break; case MOD_WVG_SET_B: /* All vertices in second vgroup. */ for (i = 0; i < numVerts; i++) { - for (j = 0; j < dvert[i].totweight; j++) { - if(dvert[i].dw[j].def_nr == defgrp_idx2) { - tidx[numIdx++] = i; - break; - } + MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx2); + if(dw) { + tdw1[numIdx] = defvert_find_index(&dvert[i], defgrp_idx); + tdw2[numIdx] = dw; + tidx[numIdx++] = i; } } break; case MOD_WVG_SET_OR: /* All vertices in one vgroup or the other. */ for (i = 0; i < numVerts; i++) { - for (j = 0; j < dvert[i].totweight; j++) { - if(dvert[i].dw[j].def_nr == defgrp_idx || dvert[i].dw[j].def_nr == defgrp_idx2) { - tidx[numIdx++] = i; - break; - } + MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); + MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); + if(adw || bdw) { + tdw1[numIdx] = adw; + tdw2[numIdx] = bdw; + tidx[numIdx++] = i; } } break; case MOD_WVG_SET_AND: /* All vertices in both vgroups. */ for (i = 0; i < numVerts; i++) { - int idx1 = FALSE; - int idx2 = FALSE; - for (j = 0; j < dvert[i].totweight; j++) { - if(dvert[i].dw[j].def_nr == defgrp_idx) { - if (idx2 == TRUE) { - tidx[numIdx++] = i; - break; - } - else { - idx1 = TRUE; - } - } - else if(dvert[i].dw[j].def_nr == defgrp_idx2) { - if (idx1 == TRUE) { - tidx[numIdx++] = i; - break; - } - else { - idx2 = TRUE; - } - } + MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); + MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); + if(adw && bdw) { + tdw1[numIdx] = adw; + tdw2[numIdx] = bdw; + tidx[numIdx++] = i; } } break; case MOD_WVG_SET_ALL: default: - /* Use all vertices, no need to do anything here. */ + /* Use all vertices. */ + for (i = 0; i < numVerts; i++) { + tdw1[i] = defvert_find_index(&dvert[i], defgrp_idx); + tdw2[i] = defvert_find_index(&dvert[i], defgrp_idx2); + } + numIdx = -1; break; } - if (numIdx) { + if(numIdx == 0) { + /* Use no vertices! Hence, return org data. */ + MEM_freeN(tdw1); + MEM_freeN(tdw2); + MEM_freeN(tidx); + if (rel_ret) + ret->release(ret); + return dm; + } + if (numIdx != -1) { indices = MEM_mallocN(sizeof(int) * numIdx, "WeightVGMix Modifier, indices"); memcpy(indices, tidx, sizeof(int) * numIdx); + dw1 = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGMix Modifier, dw1"); + memcpy(dw1, tdw1, sizeof(MDeformWeight*) * numIdx); + MEM_freeN(tdw1); + dw2 = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGMix Modifier, dw2"); + memcpy(dw2, tdw2, sizeof(MDeformWeight*) * numIdx); + MEM_freeN(tdw2); } - else + else { + /* Use all vertices. */ numIdx = numVerts; + /* Just copy MDeformWeight pointers arrays, they will be freed at the end. */ + dw1 = tdw1; + dw2 = tdw2; + } MEM_freeN(tidx); org_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGMix Modifier, org_w"); @@ -384,27 +398,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Mix weights. */ for (i = 0; i < numIdx; i++) { float weight2 = 0.0; - int w1 = FALSE; - int w2 = FALSE; - int idx = indices ? indices[i] : i; - for (j = 0; j < dvert[idx].totweight; j++) { - if(dvert[idx].dw[j].def_nr == defgrp_idx) { - org_w[i] = dvert[idx].dw[j].weight; - w1 = TRUE; - if (w2 == TRUE) - break; - } - else if(dvert[idx].dw[j].def_nr == defgrp_idx2) { - weight2 = dvert[idx].dw[j].weight; - w2 = TRUE; - if (w1 == TRUE) - break; - } - } - if (w1 == FALSE) - org_w[i] = wmd->default_weight_a; - if (w2 == FALSE) - weight2 = wmd->default_weight_b; + org_w[i] = dw1[i] ? dw1[i]->weight : wmd->default_weight_a; + weight2 = dw2[i] ? dw2[i]->weight : wmd->default_weight_b; + new_w[i] = mix_weight(org_w[i], weight2, wmd->mix_mode); } @@ -416,11 +412,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Update (add to) vgroup. * XXX Depending on the MOD_WVG_SET_xxx option chosen, we might have to add vertices to vgroup. */ - weightvg_update_vg(dvert, defgrp_idx, numIdx, indices, org_w, TRUE, -FLT_MAX, 0, 0.0f); + weightvg_update_vg(dvert, defgrp_idx, dw1, numIdx, indices, org_w, TRUE, -FLT_MAX, FALSE, 0.0f); /* Freeing stuff. */ MEM_freeN(org_w); MEM_freeN(new_w); + MEM_freeN(dw1); + MEM_freeN(dw2); if (indices) MEM_freeN(indices); diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 2daa3f797c3..76be25a2b10 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -344,6 +344,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der Mesh *ob_m = NULL; #endif MDeformVert *dvert = NULL; + MDeformWeight **dw, **tdw; int numVerts; float (*v_cos)[3] = NULL; /* The vertices coordinates. */ Object *obr = NULL; /* Our target object. */ @@ -353,7 +354,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der float *new_w =NULL; int *tidx, *indices = NULL; int numIdx = 0; - int i, j; + int i; char rel_ret = 0; /* Boolean, whether we have to release ret dm or not, when not using it! */ /* Get number of verts. */ @@ -423,22 +424,34 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der */ tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGProximity Modifier, tidx"); tw = MEM_mallocN(sizeof(float) * numVerts, "WeightVGProximity Modifier, tw"); + tdw = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGProximity Modifier, tdw"); for (i = 0; i < numVerts; i++) { - for (j = 0; j < dvert[i].totweight; j++) { - if(dvert[i].dw[j].def_nr == defgrp_idx) { - tidx[numIdx] = i; - tw[numIdx++] = dvert[i].dw[j].weight; - break; - } + MDeformWeight *_dw = defvert_find_index(&dvert[i], defgrp_idx); + if(_dw) { + tidx[numIdx] = i; + tw[numIdx] = _dw->weight; + tdw[numIdx++] = _dw; } } + /* If no vertices found, return org data! */ + if(numIdx == 0) { + MEM_freeN(tidx); + MEM_freeN(tw); + MEM_freeN(tdw); + if (rel_ret) + ret->release(ret); + return dm; + } indices = MEM_mallocN(sizeof(int) * numIdx, "WeightVGProximity Modifier, indices"); memcpy(indices, tidx, sizeof(int) * numIdx); org_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, org_w"); new_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, new_w"); memcpy(org_w, tw, sizeof(float) * numIdx); + dw = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGProximity Modifier, dw"); + memcpy(dw, tdw, sizeof(MDeformWeight*) * numIdx); MEM_freeN(tidx); MEM_freeN(tw); + MEM_freeN(tdw); /* Get our vertex coordinates. */ v_cos = MEM_mallocN(sizeof(float[3]) * numIdx, "WeightVGProximity Modifier, v_cos"); @@ -447,7 +460,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Compute wanted distances. */ if (wmd->proximity_mode == MOD_WVG_PROXIMITY_OBJECT) { - float dist = get_ob2ob_distance(ob, obr); + const float dist = get_ob2ob_distance(ob, obr); for(i = 0; i < numIdx; i++) new_w[i] = dist; } @@ -482,8 +495,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der target_dm, &loc2trgt); for(i = 0; i < numIdx; i++) { new_w[i] = dists_v ? dists_v[i] : FLT_MAX; - new_w[i] = dists_e ? minf(dists_e[i], new_w[i]) : new_w[i]; - new_w[i] = dists_f ? minf(dists_f[i], new_w[i]) : new_w[i]; + if(dists_e) + new_w[i] = minf(dists_e[i], new_w[i]); + if(dists_f) + new_w[i] = minf(dists_f[i], new_w[i]); } if(dists_v) MEM_freeN(dists_v); if(dists_e) MEM_freeN(dists_e); @@ -508,11 +523,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der wmd->mask_tex_mapping, wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name); /* Update vgroup. Note we never add nor remove vertices from vgroup here. */ - weightvg_update_vg(dvert, defgrp_idx, numIdx, indices, org_w, 0, 0.0f, 0, 0.0f); + weightvg_update_vg(dvert, defgrp_idx, dw, numIdx, indices, org_w, FALSE, 0.0f, FALSE, 0.0f); /* Freeing stuff. */ MEM_freeN(org_w); MEM_freeN(new_w); + MEM_freeN(dw); MEM_freeN(indices); MEM_freeN(v_cos); diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 01e46ed3df9..5c58070be9d 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -337,7 +337,7 @@ static void *exec_composite_node(void *nodeexec_v) node->typeinfo->newexecfunc(thd->rd, 0, node, nodeexec->data, nsin, nsout); node->exec |= NODE_READY; - return 0; + return NULL; } /* return total of executable nodes, for timecursor */ diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c index 23bcf57e2bc..9f4af0e0d33 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c @@ -88,9 +88,9 @@ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float * static void node_composit_exec_diff_matte(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { - CompBuf *outbuf=0; - CompBuf *imbuf1=0; - CompBuf *imbuf2=0; + CompBuf *outbuf= NULL; + CompBuf *imbuf1= NULL; + CompBuf *imbuf2= NULL; NodeChroma *c; /*is anything connected?*/ diff --git a/source/blender/python/intern/bpy_app_handlers.c b/source/blender/python/intern/bpy_app_handlers.c index eeb2adb3cf2..5dcaf9e5423 100644 --- a/source/blender/python/intern/bpy_app_handlers.c +++ b/source/blender/python/intern/bpy_app_handlers.c @@ -63,7 +63,7 @@ static PyStructSequence_Desc app_cb_info_desc= { #endif */ -static PyObject *py_cb_array[BLI_CB_EVT_TOT]= {0}; +static PyObject *py_cb_array[BLI_CB_EVT_TOT]= {NULL}; static PyObject *make_app_cb_info(void) { @@ -102,7 +102,7 @@ PyObject *BPY_app_handlers_struct(void) /* assign the C callbacks */ if(ret) { - static bCallbackFuncStore funcstore_array[BLI_CB_EVT_TOT]= {{0}}; + static bCallbackFuncStore funcstore_array[BLI_CB_EVT_TOT]= {{NULL}}; bCallbackFuncStore *funcstore; int pos= 0; diff --git a/source/blender/python/intern/gpu.c b/source/blender/python/intern/gpu.c index 334bb1f725a..8fa6a7b0629 100644 --- a/source/blender/python/intern/gpu.c +++ b/source/blender/python/intern/gpu.c @@ -55,6 +55,8 @@ #include "bpy_rna.h" +#include "gpu.h" + #define PY_MODULE_ADD_CONSTANT(module, name) PyModule_AddIntConstant(module, #name, name) PyDoc_STRVAR(M_gpu_doc, diff --git a/source/blender/render/intern/include/voxeldata.h b/source/blender/render/intern/include/voxeldata.h index e9991a2a19c..aa3fd104ecf 100644 --- a/source/blender/render/intern/include/voxeldata.h +++ b/source/blender/render/intern/include/voxeldata.h @@ -45,6 +45,6 @@ typedef struct VoxelDataHeader void make_voxeldata(struct Render *re); void free_voxeldata(struct Render *re); -int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres); +int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texres); #endif /* VOXELDATA_H */ diff --git a/source/blender/render/intern/raytrace/rayobject_octree.cpp b/source/blender/render/intern/raytrace/rayobject_octree.cpp index e35fcbc2df7..5fa0b836f4f 100644 --- a/source/blender/render/intern/raytrace/rayobject_octree.cpp +++ b/source/blender/render/intern/raytrace/rayobject_octree.cpp @@ -264,7 +264,7 @@ static int face_in_node(RayFace *face, short x, short y, short z, float rtf[][3] return 0; } -static void ocwrite(Octree *oc, RayFace *face, int quad, short x, short y, short z, float rtf[][3]) +static void ocwrite(Octree *oc, RayFace *face, int quad, short x, short y, short z, float rtf[4][3]) { Branch *br; Node *no; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index c323760296b..ba7af235acc 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -822,7 +822,7 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[][4], int d if(obr->totvert==0) return; asverts= MEM_callocN(sizeof(ASvert)*obr->totvert, "all smooth verts"); - thresh= cosf((float)M_PI*(0.5f+(float)degr)/180.0f ); + thresh= cosf(DEG2RADF((0.5f + (float)degr))); /* step zero: give faces normals of original mesh, if this is provided */ @@ -1488,8 +1488,8 @@ static void particle_normal_ren(short ren_as, ParticleSettings *part, Render *re if(part->draw & PART_DRAW_VEL_LENGTH) mul_v3_fl(vel, len_v3(state->vel)); - VECADDFAC(loc0, loc, vel, -part->draw_line[0]); - VECADDFAC(loc1, loc, vel, part->draw_line[1]); + madd_v3_v3v3fl(loc0, loc, vel, -part->draw_line[0]); + madd_v3_v3v3fl(loc1, loc, vel, part->draw_line[1]); particle_curve(re, obr, dm, ma, sd, loc0, loc1, seed, pa_co); @@ -1717,7 +1717,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if(part->draw & PART_DRAW_REN_ADAPT) { sd.adapt = 1; sd.adapt_pix = (float)part->adapt_pix; - sd.adapt_angle = cos((float)part->adapt_angle * (float)(M_PI / 180.0)); + sd.adapt_angle = cosf(DEG2RADF((float)part->adapt_angle)); } if(re->r.renderer==R_INTERN && part->draw&PART_DRAW_REN_STRAND) { @@ -1728,7 +1728,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem strandbuf->winx= re->winx; strandbuf->winy= re->winy; strandbuf->maxdepth= 2; - strandbuf->adaptcos= cos((float)part->adapt_angle*(float)(M_PI/180.0)); + strandbuf->adaptcos= cosf(DEG2RADF((float)part->adapt_angle)); strandbuf->overrideuv= sd.override_uv; strandbuf->minwidth= ma->strand_min; diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 66a73b47790..e2b3b23b9c9 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -240,8 +240,8 @@ static void envmap_transmatrix(float mat[][4], int part) copy_m4_m4(tmat, mat); eul_to_mat4( rotmat,eul); mul_serie_m4(mat, tmat, rotmat, - 0, 0, 0, - 0, 0, 0); + NULL, NULL, NULL, + NULL, NULL, NULL); } /* ------------------------------------------------------------------------- */ diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 49e5e7b989d..05bcc32a90a 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1452,10 +1452,12 @@ void RE_test_break_cb(Render *re, void *handle, int (*f)(void *handle)) /* object is considered fully prepared on correct time etc */ /* includes lights */ +#if 0 void RE_AddObject(Render *UNUSED(re), Object *UNUSED(ob)) { } +#endif /* *************************************** */ diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 16bbe1ca5c2..59a505a3195 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2234,21 +2234,17 @@ static int bake_intersect_tree(RayObject* raytree, Isect* isect, float *start, f maxdist= R.r.bake_maxdist; else maxdist= RE_RAYTRACE_MAXDIST + R.r.bake_biasdist; - + /* 'dir' is always normalized */ - VECADDFAC(isect->start, start, dir, -R.r.bake_biasdist); + madd_v3_v3v3fl(isect->start, start, dir, -R.r.bake_biasdist); - isect->dir[0] = dir[0]*sign; - isect->dir[1] = dir[1]*sign; - isect->dir[2] = dir[2]*sign; + mul_v3_v3fl(isect->dir, dir, sign); isect->dist = maxdist; hit = RE_rayobject_raycast(raytree, isect); if(hit) { - hitco[0] = isect->start[0] + isect->dist*isect->dir[0]; - hitco[1] = isect->start[1] + isect->dist*isect->dir[1]; - hitco[2] = isect->start[2] + isect->dist*isect->dir[2]; + madd_v3_v3v3fl(hitco, isect->start, isect->dir, isect->dist); *dist= isect->dist; } diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index e4b2a0cf1d1..a4bf6c6b5e1 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -61,16 +61,16 @@ /* XXX, could be better implemented... this is for endian issues */ -#if defined(__sgi) || defined(__sparc) || defined(__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__) -#define RCOMP 3 -#define GCOMP 2 -#define BCOMP 1 -#define ACOMP 0 +#ifdef __BIG_ENDIAN__ +# define RCOMP 3 +# define GCOMP 2 +# define BCOMP 1 +# define ACOMP 0 #else -#define RCOMP 0 -#define GCOMP 1 -#define BCOMP 2 -#define ACOMP 3 +# define RCOMP 0 +# define GCOMP 1 +# define BCOMP 2 +# define ACOMP 3 #endif /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 128900d1fd2..d8231c7e7d4 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -1165,8 +1165,9 @@ void shade_input_set_shade_texco(ShadeInput *shi) shi->vcol[2]= 1.0f; shi->vcol[3]= 1.0f; } - if(tface && tface->tpage) + if(tface->tpage) { render_realtime_texture(shi, tface->tpage); + } } diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index ad6a951adff..608882e7eb7 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -186,7 +186,7 @@ static void shade_intersection(ShadeInput *shi, float col_r[4], Isect *is) col_r[3] = shr_new.alpha; } -static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, const float co[3], float col[3]) +static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, const float co[3], float col_r[4]) { Isect isect; @@ -204,10 +204,10 @@ static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, const float co[3], f /* check to see if there's anything behind the volume, otherwise shade the sky */ if(RE_rayobject_raycast(R.raytree, &isect)) { - shade_intersection(shi, col, &isect); + shade_intersection(shi, col_r, &isect); } else { - shadeSkyView(col, co, shi->view, NULL, shi->thread); - shadeSunView(col, shi->view); + shadeSkyView(col_r, co, shi->view, NULL, shi->thread); + shadeSunView(col_r, shi->view); } } @@ -699,7 +699,7 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in } else { /* we're tracing through the volume between the camera * and a solid surface, so use that pre-shaded radiance */ - QUATCOPY(col, shr->combined); + copy_v4_v4(col, shr->combined); } /* shade volume from 'camera' to 1st hit point */ diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 2ba346ae4c5..b63ece80119 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -383,7 +383,7 @@ void make_voxeldata(struct Render *re) } -int voxeldatatex(struct Tex *tex, float *texvec, struct TexResult *texres) +int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texres) { int retval = TEX_INT; VoxelData *vd = tex->vd; diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index ba922620ee1..ac56304bdcb 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -239,7 +239,7 @@ static short cliptestf(float p, float q, float *u1, float *u2) return 1; } -int testclip(const float v[3]) +int testclip(const float v[4]) { float abs4; /* WATCH IT: this function should do the same as cliptestf, otherwise troubles in zbufclip()*/ short c=0; @@ -843,7 +843,7 @@ static void zbufline_onlyZ(ZSpan *zspan, int UNUSED(obi), int UNUSED(zvlnr), flo } -static int clipline(float *v1, float *v2) /* return 0: do not draw */ +static int clipline(float v1[4], float v2[4]) /* return 0: do not draw */ { float dz,dw, u1=0.0, u2=1.0; float dx, dy, v13; @@ -893,7 +893,7 @@ static int clipline(float *v1, float *v2) /* return 0: do not draw */ return 0; } -void hoco_to_zco(ZSpan *zspan, float *zco, float *hoco) +void hoco_to_zco(ZSpan *zspan, float zco[3], const float hoco[4]) { float div; @@ -998,7 +998,7 @@ void zbufclipwire(ZSpan *zspan, int obi, int zvlnr, int ec, float *ho1, float *h } -void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, float *ho1, float *ho2) +void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, const float ho1[4], const float ho2[4]) { float f1[4], f2[4]; int c1, c2; @@ -1008,8 +1008,8 @@ void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, float *ho1, float *ho2) if(c1 | c2) { /* not in the middle */ if(!(c1 & c2)) { /* not out completely */ - QUATCOPY(f1, ho1); - QUATCOPY(f2, ho2); + copy_v4_v4(f1, ho1); + copy_v4_v4(f2, ho2); if(clipline(f1, f2)) { hoco_to_zco(zspan, f1, f1); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 510b3403c05..83086201730 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -300,6 +300,8 @@ int WM_init_game(bContext *C) WM_operator_name_call(C, "VIEW3D_OT_game_start", WM_OP_EXEC_DEFAULT, NULL); + sound_exit(); + return 1; } else diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index ab18792d75b..921ef006de2 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -81,6 +81,7 @@ #include "BLF_api.h" #include "IMB_imbuf_types.h" +#include "IMB_imbuf.h" #include "ED_screen.h" #include "ED_util.h" @@ -1206,6 +1207,9 @@ static int wm_resource_check_prev(void) static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(arg)) { + extern char datatoc_splash_png[]; + extern int datatoc_splash_png_size; + uiBlock *block; uiBut *but; uiLayout *layout, *split, *col; @@ -1214,6 +1218,8 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar int i; MenuType *mt= WM_menutype_find("USERPREF_MT_splash", TRUE); char url[96]; + /* hardcoded to splash, loading and freeing every draw, eek! */ + ImBuf *ibuf= IMB_ibImageFromMemory((unsigned char*)datatoc_splash_png, datatoc_splash_png_size, IB_rect); #ifdef WITH_BUILDINFO int ver_width, rev_width; @@ -1237,7 +1243,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); - but= uiDefBut(block, BUT_IMAGE, 0, "", 0, 10, 501, 282, NULL, 0.0, 0.0, 0, 0, ""); + but= uiDefBut(block, BUT_IMAGE, 0, "", 0, 10, 501, 282, ibuf, 0.0, 0.0, 0, 0, ""); /* button owns the imbuf now */ uiButSetFunc(but, wm_block_splash_close, block, NULL); uiBlockSetFunc(block, wm_block_splash_refreshmenu, block, NULL); diff --git a/source/creator/creator.c b/source/creator/creator.c index 264b4fc6208..91c2d74dc26 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -560,7 +560,7 @@ static int set_engine(int argc, const char **argv, void *data) RenderData *rd = &scene->r; if(BLI_findstring(&R_engines, argv[1], offsetof(RenderEngineType, idname))) { - BLI_strncpy(rd->engine, argv[1], sizeof(rd->engine)); + BLI_strncpy_utf8(rd->engine, argv[1], sizeof(rd->engine)); } } } diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index 684bd3f341e..c5bf28b9b8d 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -110,7 +110,6 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint) for (pchan=(bPoseChannel*)out->chanbase.first; pchan; pchan=(bPoseChannel*)pchan->next) { pchan->parent= (bPoseChannel*)BLI_ghash_lookup(ghash, pchan->parent); pchan->child= (bPoseChannel*)BLI_ghash_lookup(ghash, pchan->child); - pchan->path= NULL; if (copy_constraint) { ListBase listb; diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 00c5e5803a8..f0ea6f15ffe 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -561,7 +561,7 @@ void KX_Dome::CreateMeshDome180(void) int i,j; float uv_ratio = (float)(m_buffersize-1) / m_imagesize; - m_radangle = m_angle * M_PI/180.0;//calculates the radians angle, used for flattening + m_radangle = DEG2RADF(m_angle); //calculates the radians angle, used for flattening //creating faces for the env mapcube 180deg Dome // Top Face - just a triangle diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index ae8d7094015..853b36b54f7 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -364,7 +364,9 @@ BL_ActionManager* KX_GameObject::GetActionManager() { // We only want to create an action manager if we need it if (!m_actionManager) - { KX_GetActiveScene()->AddAnimatedObject(this); m_actionManager = new BL_ActionManager(this); + { + KX_GetActiveScene()->AddAnimatedObject(this); + m_actionManager = new BL_ActionManager(this); } return m_actionManager; } diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 65ff06456b4..acd25ace04a 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -327,6 +327,8 @@ void KX_KetsjiEngine::RenderDome() // do the rendering m_dome->RenderDomeFrame(scene,cam, i); + //render all the font objects for this scene + RenderFonts(scene); } list<class KX_Camera*>* cameras = scene->GetCameras(); @@ -344,6 +346,8 @@ void KX_KetsjiEngine::RenderDome() // do the rendering m_dome->RenderDomeFrame(scene, (*it),i); + //render all the font objects for this scene + RenderFonts(scene); } it++; diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index bdc30810b9e..7ff4a786387 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1034,6 +1034,8 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) ret = newobj->Release(); if (m_euthanasyobjects->RemoveValue(newobj)) ret = newobj->Release(); + if (m_animatedlist->RemoveValue(newobj)) + ret = newobj->Release(); if (newobj == m_active_camera) { @@ -1525,6 +1527,7 @@ void KX_Scene::LogicBeginFrame(double curtime) void KX_Scene::AddAnimatedObject(CValue* gameobj) { + gameobj->AddRef(); m_animatedlist->Add(gameobj); } @@ -1537,7 +1540,7 @@ void KX_Scene::UpdateAnimations(double curtime) { // Update any animations for (int i=0; i<m_animatedlist->GetCount(); ++i) - ((KX_GameObject*)GetObjectList()->GetValue(i))->UpdateActionManager(curtime); + ((KX_GameObject*)m_animatedlist->GetValue(i))->UpdateActionManager(curtime); } void KX_Scene::LogicUpdateFrame(double curtime, bool frame) |