diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-10-29 05:09:12 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-10-29 05:09:12 +0400 |
commit | 15ed8343437c6b304de72cd14591455da1d5b3ec (patch) | |
tree | cbe40f76668f5e8539744c4d2f8aeaa0ded72f52 /source | |
parent | 5acd5d14970c829c2873623716a67beeb6da5278 (diff) | |
parent | dd106b5c7a129e00bebe121c4da8cb90a16d48cb (diff) |
Merged changes in the trunk up to revision 51718.
Conflicts resolved:
source/blender/blenloader/intern/readfile.c
source/blender/makesrna/intern/rna_scene.c
release/datafiles/startup.blend
Diffstat (limited to 'source')
923 files changed, 16294 insertions, 12336 deletions
diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c index 15d8702a5ec..e1732b0caae 100644 --- a/source/blender/avi/intern/avi.c +++ b/source/blender/avi/intern/avi.c @@ -94,7 +94,7 @@ char *fcc_to_char(unsigned int fcc) DEBUG_FCC[2] = (fcc >> 16) & 127; DEBUG_FCC[3] = (fcc >> 24) & 127; - return DEBUG_FCC; + return DEBUG_FCC; } char *tcc_to_char(unsigned int tcc) @@ -104,7 +104,7 @@ char *tcc_to_char(unsigned int tcc) DEBUG_FCC[2] = 0; DEBUG_FCC[3] = 0; - return DEBUG_FCC; + return DEBUG_FCC; } int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num) @@ -302,7 +302,7 @@ int AVI_is_avi(const char *name) MEM_freeN(movie.streams); fclose(movie.fp); - return 0; + return 0; } movie.streams[temp].sh.Type = GET_FCC(movie.fp); @@ -401,12 +401,12 @@ int AVI_is_avi(const char *name) } } - } + } if (j > 0) fseek(movie.fp, j, SEEK_CUR); } else fseek(movie.fp, movie.streams[temp].sf_size, SEEK_CUR); - /* Walk to the next LIST */ + /* Walk to the next LIST */ while (GET_FCC(movie.fp) != FCC("LIST")) { temp = GET_FCC(movie.fp); if (temp < 0 || ftell(movie.fp) > movie.size) { @@ -414,9 +414,9 @@ int AVI_is_avi(const char *name) MEM_freeN(movie.streams); fclose(movie.fp); - return 0; + return 0; } - fseek(movie.fp, temp, SEEK_CUR); + fseek(movie.fp, temp, SEEK_CUR); } fseek(movie.fp, -4L, SEEK_CUR); @@ -592,12 +592,12 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) } } - } + } if (j > 0) fseek(movie->fp, j, SEEK_CUR); } else fseek(movie->fp, movie->streams[temp].sf_size, SEEK_CUR); - /* Walk to the next LIST */ + /* Walk to the next LIST */ while (GET_FCC(movie->fp) != FCC("LIST")) { temp = GET_FCC(movie->fp); if (temp < 0 || ftell(movie->fp) > movie->size) { @@ -827,7 +827,7 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) movie->streams[i].sh.right = 0; movie->streams[i].sh.bottom = 0; - if (movie->streams[i].sh.Type == FCC("vids")) { + if (movie->streams[i].sh.Type == FCC("vids")) { #if 0 if (movie->streams[i].format == AVI_FORMAT_MJPEG) { movie->streams[i].sf = MEM_mallocN(sizeof(AviBitmapInfoHeader) + diff --git a/source/blender/avi/intern/avi_mjpeg.c b/source/blender/avi/intern/avi_mjpeg.c index b98e03d6a19..396f1199cd9 100644 --- a/source/blender/avi/intern/avi_mjpeg.c +++ b/source/blender/avi/intern/avi_mjpeg.c @@ -73,7 +73,7 @@ static void std_huff_tables(j_decompress_ptr dinfo) 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; static const UINT8 val_dc_luminance[] = - { + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; @@ -82,7 +82,7 @@ static void std_huff_tables(j_decompress_ptr dinfo) 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; static const UINT8 val_dc_chrominance[] = - { + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; @@ -91,7 +91,7 @@ static void std_huff_tables(j_decompress_ptr dinfo) 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; static const UINT8 val_ac_luminance[] = - { + { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, @@ -119,7 +119,7 @@ static void std_huff_tables(j_decompress_ptr dinfo) 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; static const UINT8 val_ac_chrominance[] = - { + { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, @@ -393,7 +393,7 @@ void *avi_converter_to_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, numbytes = 0; check_and_compress_jpeg(movie->streams[stream].sh.Quality / 100, buf + *size, buffer + (movie->header->Height / 2) * movie->header->Width * 3, movie->header->Width, movie->header->Height / 2, bufsize / 2); } - *size += numbytes; + *size += numbytes; MEM_freeN(buffer); return buf; diff --git a/source/blender/avi/intern/avi_rgb.c b/source/blender/avi/intern/avi_rgb.c index 61587e15e61..11d9bdf8612 100644 --- a/source/blender/avi/intern/avi_rgb.c +++ b/source/blender/avi/intern/avi_rgb.c @@ -86,7 +86,7 @@ void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buf *(to++) = ((*pxl >> 10) & 0x1f) * 8; *(to++) = ((*pxl >> 5) & 0x1f) * 8; *(to++) = (*pxl & 0x1f) * 8; - pxl++; + pxl++; } } diff --git a/source/blender/blenfont/BLF_translation.h b/source/blender/blenfont/BLF_translation.h index 278c45dac52..b01ce93cb65 100644 --- a/source/blender/blenfont/BLF_translation.h +++ b/source/blender/blenfont/BLF_translation.h @@ -49,9 +49,13 @@ const char *BLF_pgettext(const char *context, const char *message); /* Search the path directory to the locale files, this try all * the case for Linux, Win and Mac. + * Also dynamically builds locales and locales' menu from "languages" text file. */ void BLF_lang_init(void); +/* Free languages and locales_menu arrays created by BLF_lang_init. */ +void BLF_lang_free(void); + /* Set the current locale. */ void BLF_lang_set(const char *); /* Get the current locale (short code, e.g. es_ES). */ @@ -60,6 +64,9 @@ const char *BLF_lang_get(void); /* Set the current encoding name. */ void BLF_lang_encoding(const char *str); +/* Get EnumPropertyItem's for translations menu. */ +struct EnumPropertyItem *BLF_RNA_lang_enum_properties(void); + /* translation */ int BLF_translate_iface(void); int BLF_translate_tooltips(void); diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt index da60710a137..022dfd282b0 100644 --- a/source/blender/blenfont/CMakeLists.txt +++ b/source/blender/blenfont/CMakeLists.txt @@ -25,8 +25,10 @@ set(INC . ../blenkernel ../blenlib + ../blenloader ../editors/include ../makesdna + ../makesrna ../imbuf ../../../intern/guardedalloc ) diff --git a/source/blender/blenfont/SConscript b/source/blender/blenfont/SConscript index d3c7b1c2fcc..075da58b116 100644 --- a/source/blender/blenfont/SConscript +++ b/source/blender/blenfont/SConscript @@ -4,7 +4,8 @@ Import ('env') sources = env.Glob('intern/*.c') -incs = '. intern #/intern/guardedalloc ../blenkernel ../blenlib ../makesdna ../imbuf ../editors/include' +incs = '. intern #/intern/guardedalloc ../blenkernel ../blenlib ../blenloader' +incs += ' ../makesdna ../makesrna ../imbuf ../editors/include' incs += ' #/extern/glew/include' incs += ' ' + env['BF_FREETYPE_INC'] incs += ' ' + env['BF_GETTEXT_INC'] diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index af2f9df3c00..9f4cf72d120 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -35,30 +35,26 @@ #include "BKE_global.h" #include "BLF_api.h" - #include "BLF_translation.h" /* own include */ #ifdef WITH_INTERNATIONAL #include <locale.h> -#if defined(_WIN32) -#include <windows.h> -#endif - #include "libintl.h" #include "DNA_userdef_types.h" -#include "DNA_listBase.h" -#include "DNA_vec_types.h" +#include "RNA_types.h" #include "MEM_guardedalloc.h" -#include "BLI_linklist.h" /* linknode */ #include "BLI_string.h" #include "BLI_utildefines.h" #include "BLI_path_util.h" +#include "BLI_fileops.h" +#include "BLI_linklist.h" +#include "BLI_string.h" #define SYSTEM_ENCODING_DEFAULT "UTF-8" #define FONT_SIZE_DEFAULT 12 @@ -68,50 +64,122 @@ static char global_messagepath[1024]; static char global_language[32]; static char global_encoding_name[32]; -/* Map from the rna_userdef.c:rna_def_userdef_system(BlenderRNA *brna):language_items */ -static const char *locales[] = { - "", "", - "english", "en_US", - "japanese", "ja_JP", - "dutch", "nl_NL", - "italian", "it_IT", - "german", "de_DE", - "finnish", "fi_FI", - "swedish", "sv_SE", - "french", "fr_FR", - "spanish", "es", - "catalan", "ca_AD", - "czech", "cs_CZ", - "portuguese", "pt_PT", -#if defined(_WIN32) && !defined(FREE_WINDOWS) - "Chinese (Simplified)_China.1252", "zh_CN", - "Chinese (Traditional)_China.1252", "zh_TW", -#else - "chs", "zh_CN", - "cht", "zh_TW", -#endif - "russian", "ru_RU", - "croatian", "hr_HR", - "serbian", "sr_RS", - "ukrainian", "uk_UA", - "polish", "pl_PL", - "romanian", "ro_RO", - "arabic", "ar_EG", - "bulgarian", "bg_BG", - "greek", "el_GR", - "korean", "ko_KR", - "nepali", "ne_NP", - "persian", "fa_IR", - "indonesian", "id_ID", - "serbian (latin)", "sr_RS@latin", - "kyrgyz", "ky_KG", - "turkish", "tr_TR", - "hungarian", "hu_HU", - "portuguese-brazilian", "pt_BR", - "hebrew", "he_IL", - "estonian", "et_EE", - "esperanto", "eo", /* No country code for esperanto! ;) */ -}; +static const char **locales = NULL; +static int num_locales = 0; +static EnumPropertyItem *locales_menu = NULL; +static int num_locales_menu = 0; + +#define ULANGUAGE ((U.language >= 0 && U.language < num_locales) ? U.language : 0) +#define LOCALE(_id) (locales ? locales[_id] : "") + +static void free_locales(void) +{ + if (locales) { + int idx = num_locales_menu - 1; /* Last item does not need to be freed! */ + while (idx--) { + MEM_freeN((void*)locales_menu[idx].identifier); + MEM_freeN((void*)locales_menu[idx].name); + MEM_freeN((void*)locales_menu[idx].description); /* Also frees locales's relevant value! */ + } + MEM_freeN(locales); + locales = NULL; + } + if (locales_menu) { + MEM_freeN(locales_menu); + locales_menu = NULL; + } + num_locales = num_locales_menu = 0; +} + +static void fill_locales(void) +{ + char *languages_path = BLI_get_folder(BLENDER_DATAFILES, "locale"); + LinkNode *lines = NULL, *line; + char *str; + int idx = 0; + + free_locales(); + + BLI_join_dirfile(languages_path, FILE_MAX, languages_path, "languages"); + line = lines = BLI_file_read_as_lines(languages_path); + + /* This whole "parsing" code is a bit weak, in that it expects strictly formated input file... + * Should not be a problem, though, as this file is script-generated! */ + + /* First loop to find highest locale ID */ + while (line) { + int t; + str = (char*) line->link; + if (str[0] == '#' || str[0] == '\0') { + line = line->next; + continue; /* Comment or void... */ + } + t = atoi(str); + if (t >= num_locales) + num_locales = t + 1; + num_locales_menu++; + line = line->next; + } + num_locales_menu++; /* The "closing" void item... */ + + /* And now, buil locales and locale_menu! */ + locales_menu = MEM_callocN(num_locales_menu * sizeof(EnumPropertyItem), __func__); + line = lines; + /* Do not allocate locales with zero-sized mem, as LOCALE macro uses NULL locales as invalid marker! */ + if (num_locales > 0) { + locales = MEM_callocN(num_locales * sizeof(char*), __func__); + while (line) { + int id; + char *loc, *sep1, *sep2; + + str = (char*) line->link; + if (str[0] == '#' || str[0] == '\0') { + line = line->next; + continue; + } + + id = atoi(str); + sep1 = strchr(str, ':'); + if (sep1) { + sep1++; + sep2 = strchr(sep1, ':'); + if (sep2) { + + locales_menu[idx].value = id; + locales_menu[idx].icon = 0; + locales_menu[idx].name = BLI_strdupn(sep1, sep2 - sep1); + locales_menu[idx].identifier = loc = BLI_strdup(sep2 + 1); + if (id == 0) { + /* The DEFAULT item... */ + if (BLI_strnlen(loc, 2)) + locales[id] = locales_menu[idx].description = BLI_strdup(""); + /* Menu "label", not to be stored in locales! */ + else + locales_menu[idx].description = BLI_strdup(""); + } + else + locales[id] = locales_menu[idx].description = BLI_strdup(loc); + idx++; + + } + } + + line = line->next; + } + } + + /* Add closing item to menu! */ + locales_menu[idx].identifier = NULL; + locales_menu[idx].value = locales_menu[idx].icon = 0; + locales_menu[idx].name = locales_menu[idx].description = ""; + + BLI_file_free_lines(lines); +} + +EnumPropertyItem *BLF_RNA_lang_enum_properties(void) +{ + return locales_menu; +} void BLF_lang_init(void) { @@ -121,6 +189,7 @@ void BLF_lang_init(void) if (messagepath) { BLI_strncpy(global_messagepath, messagepath, sizeof(global_messagepath)); + fill_locales(); } else { printf("%s: 'locale' data path for translations not found, continuing\n", __func__); @@ -128,6 +197,11 @@ void BLF_lang_init(void) } } +void BLF_lang_free(void) +{ + free_locales(); +} + /* Get LANG/LANGUAGE environment variable. */ static void get_language_variable(const char *varname, char *var, const size_t maxlen) { @@ -170,7 +244,8 @@ void BLF_lang_set(const char *str) { char *locreturn; const char *short_locale; - int ok = 1; + int ok = TRUE; + int ulang = ULANGUAGE; if ((U.transopts & USER_DOTRANSLATE) == 0) return; @@ -178,16 +253,14 @@ void BLF_lang_set(const char *str) if (str) short_locale = str; else - short_locale = locales[2 * U.language + 1]; + short_locale = LOCALE(ulang); #if defined(_WIN32) && !defined(FREE_WINDOWS) { - const char *long_locale = locales[2 * U.language]; - if (short_locale) { char *envStr; - if (U.language == 0) /* Use system setting. */ + if (ulang) /* Use system setting. */ envStr = BLI_sprintfN("LANG=%s", getenv("LANG")); else envStr = BLI_sprintfN("LANG=%s", short_locale); @@ -196,13 +269,13 @@ void BLF_lang_set(const char *str) MEM_freeN(envStr); } - locreturn = setlocale(LC_ALL, long_locale); + locreturn = setlocale(LC_ALL, short_locale); if (locreturn == NULL) { if (G.debug & G_DEBUG) - printf("Could not change locale to %s\n", long_locale); + printf("Could not change locale to %s\n", short_locale); - ok = 0; + ok = FALSE; } } #else @@ -271,7 +344,7 @@ void BLF_lang_set(const char *str) locreturn = setlocale(LC_ALL, ""); - ok = 0; + ok = FALSE; } } #endif @@ -290,7 +363,8 @@ void BLF_lang_set(const char *str) const char *BLF_lang_get(void) { - return locales[2 * U.language + 1]; + int uilang = ULANGUAGE; + return LOCALE(uilang); } void BLF_lang_encoding(const char *str) @@ -299,6 +373,9 @@ void BLF_lang_encoding(const char *str) /* bind_textdomain_codeset(TEXT_DOMAIN_NAME, encoding_name); */ } +#undef LOCALE +#undef ULANGUAGE + #else /* ! WITH_INTERNATIONAL */ void BLF_lang_init(void) @@ -306,6 +383,11 @@ void BLF_lang_init(void) return; } +void BLF_lang_free(void) +{ + return; +} + void BLF_lang_encoding(const char *str) { (void)str; diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index cf67899dfb0..fbdbf052878 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,11 +42,10 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 264 -#define BLENDER_SUBVERSION 4 +#define BLENDER_SUBVERSION 6 -/* 262 was the last editmesh release but its has compatibility code for bmesh data, - * so set the minversion to 2.61 */ -#define BLENDER_MINVERSION 261 +/* 262 was the last editmesh release but it has compatibility code for bmesh data */ +#define BLENDER_MINVERSION 262 #define BLENDER_MINSUBVERSION 0 /* used by packaging tools */ diff --git a/source/blender/blenkernel/BKE_bmesh.h b/source/blender/blenkernel/BKE_bmesh.h index 67b21eb764c..8bfee836c0d 100644 --- a/source/blender/blenkernel/BKE_bmesh.h +++ b/source/blender/blenkernel/BKE_bmesh.h @@ -99,7 +99,7 @@ typedef struct BME_Glob { /* stored in Global G for Transform() purposes */ struct BME_TransData *BME_get_transdata(struct BME_TransData_Head *td, struct BMVert *v); void BME_free_transdata(struct BME_TransData_Head *td); -struct BMesh *BME_bevel(struct BMEditMesh *em, float value, int res, int options, int defgrp_index, float angle, - BME_TransData_Head **rtd, int do_tessface); +struct BMesh *BME_bevel(struct BMesh *bm, float value, int res, int options, int defgrp_index, float angle, + BME_TransData_Head **rtd); #endif diff --git a/source/blender/blenkernel/BKE_cdderivedmesh.h b/source/blender/blenkernel/BKE_cdderivedmesh.h index d7882d8e7ec..2b2497f3f50 100644 --- a/source/blender/blenkernel/BKE_cdderivedmesh.h +++ b/source/blender/blenkernel/BKE_cdderivedmesh.h @@ -55,8 +55,10 @@ int CDDM_Check(struct DerivedMesh *dm); * data to not overwrite the original */ struct DerivedMesh *CDDM_from_mesh(struct Mesh *mesh, struct Object *ob); +struct DerivedMesh *CDDM_from_bmesh(struct BMesh *bm, int use_mdisps); + /* creates a CDDerivedMesh from the given BMEditMesh */ -DerivedMesh *CDDM_from_BMEditMesh(struct BMEditMesh *em, struct Mesh *me, int use_mdisps, int use_tessface); +DerivedMesh *CDDM_from_editbmesh(struct BMEditMesh *em, int use_mdisps, int use_tessface); /* merge verts */ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap); diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h index 33361b9921c..e387fc5f97c 100644 --- a/source/blender/blenkernel/BKE_customdata.h +++ b/source/blender/blenkernel/BKE_customdata.h @@ -80,6 +80,13 @@ void customData_mask_layers__print(CustomDataMask mask); * the below operations. */ int CustomData_layer_has_math(struct CustomData *data, int layer_n); +int CustomData_layer_has_interp(struct CustomData *data, int layer_n); + +/** + * Checks if any of the customdata layers has math. + */ +int CustomData_has_math(struct CustomData *data); +int CustomData_has_interp(struct CustomData *data); /* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to * another, while not overwriting anything else (e.g. flags). probably only @@ -205,8 +212,8 @@ void CustomData_free_elem(struct CustomData *data, int index, int count); void CustomData_interp(const struct CustomData *source, struct CustomData *dest, int *src_indices, float *weights, float *sub_weights, int count, int dest_index); -void CustomData_bmesh_interp(struct CustomData *data, void **src_blocks, - float *weights, float *sub_weights, int count, +void CustomData_bmesh_interp(struct CustomData *data, void **src_blocks, + const float *weights, const float *sub_weights, int count, void *dest_block); diff --git a/source/blender/blenkernel/BKE_global.h b/source/blender/blenkernel/BKE_global.h index 2656495a918..f7af534c2c2 100644 --- a/source/blender/blenkernel/BKE_global.h +++ b/source/blender/blenkernel/BKE_global.h @@ -130,8 +130,9 @@ enum { G_DEBUG_FFMPEG = (1 << 1), G_DEBUG_PYTHON = (1 << 2), /* extra python info */ G_DEBUG_EVENTS = (1 << 3), /* input/window/screen events */ - G_DEBUG_WM = (1 << 4), /* operator, undo */ - G_DEBUG_JOBS = (1 << 5) /* jobs time profiling */ + G_DEBUG_HANDLERS = (1 << 4), /* events handling */ + G_DEBUG_WM = (1 << 5), /* operator, undo */ + G_DEBUG_JOBS = (1 << 6) /* jobs time profiling */ }; #define G_DEBUG_ALL (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM | G_DEBUG_JOBS) @@ -145,17 +146,17 @@ enum { #define G_FILE_ENABLE_ALL_FRAMES (1 << 3) /* deprecated */ #define G_FILE_SHOW_DEBUG_PROPS (1 << 4) /* deprecated */ #define G_FILE_SHOW_FRAMERATE (1 << 5) /* deprecated */ -/* #define G_FILE_SHOW_PROFILE (1 << 6) */ /* deprecated */ +/* #define G_FILE_SHOW_PROFILE (1 << 6) */ /* deprecated */ #define G_FILE_LOCK (1 << 7) #define G_FILE_SIGN (1 << 8) -/* #define G_FILE_PUBLISH (1 << 9) */ /* deprecated */ +/* #define G_FILE_PUBLISH (1 << 9) */ /* deprecated */ #define G_FILE_NO_UI (1 << 10) -/* #define G_FILE_GAME_TO_IPO (1 << 11) */ /* deprecated */ +/* #define G_FILE_GAME_TO_IPO (1 << 11) */ /* deprecated */ #define G_FILE_GAME_MAT (1 << 12) /* deprecated */ -/* #define G_FILE_DISPLAY_LISTS (1 << 13) */ /* deprecated */ +/* #define G_FILE_DISPLAY_LISTS (1 << 13) */ /* deprecated */ #define G_FILE_SHOW_PHYSICS (1 << 14) /* deprecated */ #define G_FILE_GAME_MAT_GLSL (1 << 15) /* deprecated */ -/* #define G_FILE_GLSL_NO_LIGHTS (1 << 16) */ /* deprecated */ +/* #define G_FILE_GLSL_NO_LIGHTS (1 << 16) */ /* deprecated */ #define G_FILE_GLSL_NO_SHADERS (1 << 17) /* deprecated */ #define G_FILE_GLSL_NO_SHADOWS (1 << 18) /* deprecated */ #define G_FILE_GLSL_NO_RAMPS (1 << 19) /* deprecated */ diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index 5e5f58f73fe..1875fd66628 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -127,6 +127,7 @@ enum { #define IMA_SIGNAL_SRC_CHANGE 5 /* image-user gets a new image, check settings */ #define IMA_SIGNAL_USER_NEW_IMAGE 6 +#define IMA_SIGNAL_COLORMANAGE 7 #define IMA_CHAN_FLAG_BW 1 #define IMA_CHAN_FLAG_RGB 2 diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index 91756448297..bc081b7f308 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -81,6 +81,7 @@ int set_listbasepointers(struct Main *main, struct ListBase **lb); void BKE_libblock_free(struct ListBase *lb, void *idv); void BKE_libblock_free_us(struct ListBase *lb, void *idv); +void BKE_libblock_free_data(struct ID *id); void free_main(struct Main *mainvar); void tag_main_idcode(struct Main *mainvar, const short type, const short tag); diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 9fffb71785b..2f889084d0e 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -292,6 +292,7 @@ void create_vert_edge_map(MeshElemMap **map, int **mem, int BKE_mesh_minmax(struct Mesh *me, float r_min[3], float r_max[3]); int BKE_mesh_center_median(struct Mesh *me, float cent[3]); int BKE_mesh_center_bounds(struct Mesh *me, float cent[3]); +int BKE_mesh_center_centroid(struct Mesh *me, float cent[3]); void BKE_mesh_translate(struct Mesh *me, float offset[3], int do_keys); /* mesh_validate.c */ diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index 4ee5c894b5c..cd1875f848b 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -193,10 +193,8 @@ typedef struct bNodeType { struct bNodeTree *(*group_edit_set)(struct bNode *node, int edit); void (*group_edit_clear)(struct bNode *node); - /* Generate a temporary list of internal links (bNodeLink), for muting and disconnect operators. - * Result must be freed by caller! - */ - ListBase (*internal_connect)(struct bNodeTree *, struct bNode *node); + /* Update the internal links list, for muting and disconnect operators. */ + void (*update_internal_links)(struct bNodeTree *, struct bNode *node); /* **** execution callbacks **** */ void *(*initexecfunc)(struct bNode *node); @@ -293,7 +291,7 @@ typedef struct bNodeTreeType { int (*validate_link)(struct bNodeTree *ntree, struct bNodeLink *link); /* Default internal linking. */ - ListBase (*internal_connect)(struct bNodeTree *, struct bNode *node); + void (*update_internal_links)(struct bNodeTree *, struct bNode *node); } bNodeTreeType; /* ************** GENERIC API, TREES *************** */ @@ -389,6 +387,7 @@ struct bNode *nodeGetActiveTexture(struct bNodeTree *ntree); void nodeUpdate(struct bNodeTree *ntree, struct bNode *node); int nodeUpdateID(struct bNodeTree *ntree, struct ID *id); +void nodeUpdateInternalLinks(struct bNodeTree *ntree, struct bNode *node); void nodeFreePreview(struct bNode *node); @@ -445,7 +444,7 @@ void node_type_exec_new(struct bNodeType *ntype, void (*freeexecfunc)(struct bNode *node, void *nodedata), void (*newexecfunc)(void *data, int thread, struct bNode *, void *nodedata, struct bNodeStack **, struct bNodeStack **)); -void node_type_internal_connect(struct bNodeType *ntype, ListBase (*internal_connect)(struct bNodeTree *, struct bNode *)); +void node_type_internal_links(struct bNodeType *ntype, void (*update_internal_links)(struct bNodeTree *, struct bNode *)); void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out)); void node_type_gpu_ext(struct bNodeType *ntype, int (*gpuextfunc)(struct GPUMaterial *mat, struct bNode *node, @@ -456,8 +455,8 @@ void node_type_compatibility(struct bNodeType *ntype, short compatibi /* ************** COMMON NODES *************** */ #define NODE_GROUP 2 -#define NODE_FORLOOP 3 -#define NODE_WHILELOOP 4 +#define __NODE_FORLOOP 3 /* deprecated */ +#define __NODE_WHILELOOP 4 /* deprecated */ #define NODE_FRAME 5 #define NODE_REROUTE 6 @@ -699,6 +698,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *ntree, struct GPUMateria #define CMP_NODE_BOKEHIMAGE 315 #define CMP_NODE_BOKEHBLUR 316 #define CMP_NODE_SWITCH 317 +#define CMP_NODE_PIXELATE 318 /* channel toggles */ #define CMP_CHAN_RGB 1 diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index a93e542fe15..c452c177143 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -94,6 +94,7 @@ typedef struct SculptSession { /* PBVH acceleration structure */ struct PBVH *pbvh; + int show_diffuse_color; /* Paiting on deformed mesh */ int modifiers_active; /* object is deformed with some modifiers */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index f690c9dcda4..11ff3930ffb 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -358,12 +358,6 @@ if(WITH_MOD_OCEANSIM) add_definitions(-DWITH_OCEANSIM) endif() -if(WITH_MOD_DECIMATE) - list(APPEND INC - ../../../intern/decimation/extern - ) -endif() - if(WITH_MOD_BOOLEAN) list(APPEND INC ../../../intern/bsp/extern diff --git a/source/blender/blenkernel/SConscript b/source/blender/blenkernel/SConscript index 8a656c735f6..155d4068c9a 100644 --- a/source/blender/blenkernel/SConscript +++ b/source/blender/blenkernel/SConscript @@ -10,7 +10,7 @@ sources_mask = env.Glob('intern/mask*.c') incs = '. #/intern/guardedalloc #/intern/memutil' incs += ' ../blenlib ../blenfont ../makesdna ../windowmanager' -incs += ' ../render/extern/include #/intern/decimation/extern ../makesrna' +incs += ' ../render/extern/include ../makesrna' incs += ' ../imbuf ../ikplugin ../avi #/intern/elbeem/extern ../nodes ../modifiers' incs += ' #/intern/iksolver/extern ../blenloader ../freestyle' incs += ' #/extern/bullet2/src' diff --git a/source/blender/blenkernel/depsgraph_private.h b/source/blender/blenkernel/depsgraph_private.h index 512b799aeed..12c111f5f16 100644 --- a/source/blender/blenkernel/depsgraph_private.h +++ b/source/blender/blenkernel/depsgraph_private.h @@ -61,7 +61,7 @@ typedef struct DagAdjList { typedef struct DagNode { int color; short type; - float x, y, k; + float x, y, k; void *ob; void *first_ancestor; int ancestor_count; diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 82ac0736b07..cc20470b4d5 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -868,7 +868,7 @@ CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *a ss->oldVMap = ss->oldEMap = ss->oldFMap = NULL; ss->lenTempArrays = 0; ss->tempVerts = NULL; - ss->tempEdges = NULL; + ss->tempEdges = NULL; return ss; } diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 30804518e1d..ddbd4588778 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -51,8 +51,6 @@ #include "BLI_utildefines.h" #include "BLI_linklist.h" -#include "BLF_translation.h" - #include "BKE_cdderivedmesh.h" #include "BKE_displist.h" #include "BKE_key.h" @@ -903,7 +901,7 @@ static DerivedMesh *create_orco_dm(Object *ob, Mesh *me, BMEditMesh *em, int lay float (*orco)[3]; int free; - if (em) dm = CDDM_from_BMEditMesh(em, me, FALSE, FALSE); + if (em) dm = CDDM_from_editbmesh(em, FALSE, FALSE); else dm = CDDM_from_mesh(me, ob); orco = get_orco_coords_dm(ob, em, layer, &free); @@ -1270,7 +1268,7 @@ static void shapekey_layers_to_keyblocks(DerivedMesh *dm, Mesh *me, int actshape int i, j, tot; if (!me->key) - return; + return; tot = CustomData_number_of_layers(&dm->vertData, CD_SHAPEKEY); for (i = 0; i < tot; i++) { @@ -1507,7 +1505,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos if (!modifier_isEnabled(scene, md, required_mode)) continue; if (mti->type == eModifierTypeType_OnlyDeform && !useDeform) continue; if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) { - modifier_setError(md, "%s", TIP_("Modifier requires original data, bad stack position.")); + modifier_setError(md, "Modifier requires original data, bad stack position"); continue; } if (sculpt_mode && (!has_multires || multires_applied)) { @@ -1520,7 +1518,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos unsupported |= multires_applied; if (unsupported) { - modifier_setError(md, "%s", TIP_("Not supported in sculpt mode.")); + modifier_setError(md, "Not supported in sculpt mode"); continue; } } @@ -1881,7 +1879,7 @@ int editbmesh_modifier_is_enabled(Scene *scene, ModifierData *md, DerivedMesh *d if (!modifier_isEnabled(scene, md, required_mode)) return 0; if ((mti->flags & eModifierTypeFlag_RequiresOriginalData) && dm) { - modifier_setError(md, "%s", TIP_("Modifier requires original data, bad stack position.")); + modifier_setError(md, "Modifier requires original data, bad stack position"); return 0; } @@ -1976,7 +1974,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D } else { - dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE); + dm = CDDM_from_editbmesh(em, FALSE, FALSE); if (deformedVerts) { CDDM_apply_vert_coords(dm, deformedVerts); @@ -2067,12 +2065,18 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D } else if (dm) { *final_r = dm; - (*final_r)->calcNormals(*final_r); /* BMESH_ONLY - BMESH_TODO. check if this is needed */ + + /* once we support skipping normal calculation with modifiers we may want to add this back */ +#if 0 // was added for bmesh but is not needed + (*final_r)->calcNormals(*final_r); +#endif } else if (!deformedVerts && cage_r && *cage_r) { /* cage should already have up to date normals */ *final_r = *cage_r; - (*final_r)->calcNormals(*final_r); /* BMESH_ONLY - BMESH_TODO. check if this is needed */ +#if 0 // was added for bmesh but is not needed + (*final_r)->calcNormals(*final_r); +#endif } else { /* this is just a copy of the editmesh, no need to calc normals */ @@ -2428,7 +2432,7 @@ static int GetNumVertsOfFace(const SMikkTSpaceContext *pContext, const int face_ static void GetPosition(const SMikkTSpaceContext *pContext, float fPos[], const int face_num, const int vert_index) { - //assert(vert_index>=0 && vert_index<4); + //assert(vert_index >= 0 && vert_index < 4); SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData; const float *co = pMesh->mvert[(&pMesh->mface[face_num].v1)[vert_index]].co; copy_v3_v3(fPos, co); @@ -2436,7 +2440,7 @@ static void GetPosition(const SMikkTSpaceContext *pContext, float fPos[], const static void GetTextureCoordinate(const SMikkTSpaceContext *pContext, float fUV[], const int face_num, const int vert_index) { - //assert(vert_index>=0 && vert_index<4); + //assert(vert_index >= 0 && vert_index < 4); SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData; if (pMesh->mtface != NULL) { @@ -2451,7 +2455,7 @@ static void GetTextureCoordinate(const SMikkTSpaceContext *pContext, float fUV[] static void GetNormal(const SMikkTSpaceContext *pContext, float fNorm[], const int face_num, const int vert_index) { - //assert(vert_index>=0 && vert_index<4); + //assert(vert_index >= 0 && vert_index < 4); SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData; const int smoothnormal = (pMesh->mface[face_num].flag & ME_SMOOTH); @@ -2481,7 +2485,7 @@ static void GetNormal(const SMikkTSpaceContext *pContext, float fNorm[], const i } static void SetTSpace(const SMikkTSpaceContext *pContext, const float fvTangent[], const float fSign, const int face_num, const int iVert) { - //assert(vert_index>=0 && vert_index<4); + //assert(vert_index >= 0 && vert_index < 4); SGLSLMeshToTangent *pMesh = (SGLSLMeshToTangent *) pContext->m_pUserData; float *pRes = pMesh->tangent[4 * face_num + iVert]; copy_v3_v3(pRes, fvTangent); @@ -2492,15 +2496,11 @@ static void SetTSpace(const SMikkTSpaceContext *pContext, const float fvTangent[ void DM_add_tangent_layer(DerivedMesh *dm) { /* mesh vars */ - MTFace *mtface, *tf; - MFace *mface, *mf; - MVert *mvert, *v1, *v2, *v3, *v4; - MemArena *arena = NULL; - VertexTangent **vtangents = NULL; + MVert *mvert; + MTFace *mtface; + MFace *mface; float (*orco)[3] = NULL, (*tangent)[4]; - float *uv1, *uv2, *uv3, *uv4, *vtang; - float fno[3], tang[3], uv[4][2]; - int i, j, len, mf_vi[4], totvert, totface, iCalcNewMethod; + int /* totvert, */ totface; float *nors; if (CustomData_get_layer_index(&dm->faceData, CD_TANGENT) != -1) @@ -2509,7 +2509,7 @@ void DM_add_tangent_layer(DerivedMesh *dm) nors = dm->getTessFaceDataArray(dm, CD_NORMAL); /* check we have all the needed layers */ - totvert = dm->getNumVerts(dm); + /* totvert = dm->getNumVerts(dm); */ /* UNUSED */ totface = dm->getNumTessFaces(dm); mvert = dm->getVertArray(dm); @@ -2526,14 +2526,8 @@ void DM_add_tangent_layer(DerivedMesh *dm) DM_add_tessface_layer(dm, CD_TANGENT, CD_CALLOC, NULL); tangent = DM_get_tessface_data_layer(dm, CD_TANGENT); - /* allocate some space */ - arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "tangent layer arena"); - BLI_memarena_use_calloc(arena); - vtangents = MEM_callocN(sizeof(VertexTangent *) * totvert, "VertexTangent"); - /* new computation method */ - iCalcNewMethod = 1; - if (iCalcNewMethod != 0) { + { SGLSLMeshToTangent mesh2tangent = {0}; SMikkTSpaceContext sContext = {0}; SMikkTSpaceInterface sInterface = {0}; @@ -2556,87 +2550,13 @@ void DM_add_tangent_layer(DerivedMesh *dm) sInterface.m_setTSpaceBasic = SetTSpace; /* 0 if failed */ - iCalcNewMethod = genTangSpaceDefault(&sContext); + genTangSpaceDefault(&sContext); } - - if (!iCalcNewMethod) { - /* sum tangents at connected vertices */ - for (i = 0, tf = mtface, mf = mface; i < totface; mf++, tf++, i++) { - v1 = &mvert[mf->v1]; - v2 = &mvert[mf->v2]; - v3 = &mvert[mf->v3]; - - if (mf->v4) { - v4 = &mvert[mf->v4]; - normal_quad_v3(fno, v4->co, v3->co, v2->co, v1->co); - } - else { - v4 = NULL; - normal_tri_v3(fno, v3->co, v2->co, v1->co); - } - - if (mtface) { - uv1 = tf->uv[0]; - uv2 = tf->uv[1]; - uv3 = tf->uv[2]; - uv4 = tf->uv[3]; - } - else { - uv1 = uv[0]; uv2 = uv[1]; uv3 = uv[2]; uv4 = uv[3]; - map_to_sphere(&uv[0][0], &uv[0][1], orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); - map_to_sphere(&uv[1][0], &uv[1][1], orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); - map_to_sphere(&uv[2][0], &uv[2][1], orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); - if (v4) - map_to_sphere(&uv[3][0], &uv[3][1], orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); - } - - tangent_from_uv(uv1, uv2, uv3, v1->co, v2->co, v3->co, fno, tang); - sum_or_add_vertex_tangent(arena, &vtangents[mf->v1], tang, uv1); - sum_or_add_vertex_tangent(arena, &vtangents[mf->v2], tang, uv2); - sum_or_add_vertex_tangent(arena, &vtangents[mf->v3], tang, uv3); - - if (mf->v4) { - v4 = &mvert[mf->v4]; - - tangent_from_uv(uv1, uv3, uv4, v1->co, v3->co, v4->co, fno, tang); - sum_or_add_vertex_tangent(arena, &vtangents[mf->v1], tang, uv1); - sum_or_add_vertex_tangent(arena, &vtangents[mf->v3], tang, uv3); - sum_or_add_vertex_tangent(arena, &vtangents[mf->v4], tang, uv4); - } - } - - /* write tangent to layer */ - for (i = 0, tf = mtface, mf = mface; i < totface; mf++, tf++, i++, tangent += 4) { - len = (mf->v4) ? 4 : 3; - - if (mtface == NULL) { - map_to_sphere(&uv[0][0], &uv[0][1], orco[mf->v1][0], orco[mf->v1][1], orco[mf->v1][2]); - map_to_sphere(&uv[1][0], &uv[1][1], orco[mf->v2][0], orco[mf->v2][1], orco[mf->v2][2]); - map_to_sphere(&uv[2][0], &uv[2][1], orco[mf->v3][0], orco[mf->v3][1], orco[mf->v3][2]); - if (len == 4) - map_to_sphere(&uv[3][0], &uv[3][1], orco[mf->v4][0], orco[mf->v4][1], orco[mf->v4][2]); - } - - mf_vi[0] = mf->v1; - mf_vi[1] = mf->v2; - mf_vi[2] = mf->v3; - mf_vi[3] = mf->v4; - - for (j = 0; j < len; j++) { - vtang = find_vertex_tangent(vtangents[mf_vi[j]], mtface ? tf->uv[j] : uv[j]); - normalize_v3_v3(tangent[j], vtang); - ((float *) tangent[j])[3] = 1.0f; - } - } - } - - BLI_memarena_free(arena); - MEM_freeN(vtangents); } void DM_calc_auto_bump_scale(DerivedMesh *dm) { - /* int totvert= dm->getNumVerts(dm); */ /* UNUSED */ + /* int totvert = dm->getNumVerts(dm); */ /* UNUSED */ int totface = dm->getNumTessFaces(dm); MVert *mvert = dm->getVertArray(dm); diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 66df7eccbd0..e95451252d0 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -224,7 +224,7 @@ bActionGroup *get_active_actiongroup(bAction *act) { bActionGroup *agrp = NULL; - if (act && act->groups.first) { + if (act && act->groups.first) { for (agrp = act->groups.first; agrp; agrp = agrp->next) { if (agrp->flag & AGRP_ACTIVE) break; @@ -301,7 +301,7 @@ bActionGroup *action_groups_add_new(bAction *act, const char name[]) /* add to action, and validate */ BLI_addtail(&act->groups, agrp); - BLI_uniquename(&act->groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name)); + BLI_uniquename(&act->groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name)); /* return the new group */ return agrp; @@ -380,7 +380,7 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve) void action_groups_remove_channel(bAction *act, FCurve *fcu) { /* sanity checks */ - if (ELEM(NULL, act, fcu)) + if (ELEM(NULL, act, fcu)) return; /* check if any group used this directly */ @@ -906,8 +906,8 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ calc_fcurve_range(fcu, &nmin, &nmax, FALSE, TRUE); /* compare to the running tally */ - min = MIN2(min, nmin); - max = MAX2(max, nmax); + min = min_ff(min, nmin); + max = max_ff(max, nmax); foundvert = 1; } @@ -925,10 +925,10 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ FMod_Limits *fmd = (FMod_Limits *)fcm->data; if (fmd->flag & FCM_LIMIT_XMIN) { - min = MIN2(min, fmd->rect.xmin); + min = min_ff(min, fmd->rect.xmin); } if (fmd->flag & FCM_LIMIT_XMAX) { - max = MAX2(max, fmd->rect.xmax); + max = max_ff(max, fmd->rect.xmax); } } break; @@ -955,7 +955,7 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ foundmod = 1; } } - } + } if (foundvert || foundmod) { if (min == max) max += 1.0f; diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index 622658e0a49..dffe26bd782 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -176,7 +176,7 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec /* avoid 0 size allocs */ if (avs->path_sf >= avs->path_ef) { BKE_reportf(reports, RPT_ERROR, - "Motion Path frame extents invalid for %s (%d to %d)%s", + "Motion path frame extents invalid for %s (%d to %d)%s", (pchan) ? pchan->name : ob->id.name, avs->path_sf, avs->path_ef, (avs->path_sf == avs->path_ef) ? TIP_(", cannot have single-frame paths") : ""); @@ -824,7 +824,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int par_ind ok = (ok < ob->dupon); } - if (ok) { + if (ok) { DupliObject *dob; /* WARNING: doing animation updates in this way is not terribly accurate, as the dependencies @@ -970,7 +970,7 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl } /* Start looping on Scene OR Group objects */ - while (base || go) { + while (base || go) { if (sce) { ob_iter = base->object; oblay = base->lay; @@ -1104,7 +1104,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa } /* Start looping on Scene OR Group objects */ - while (base || go) { + while (base || go) { if (sce) { ob_iter = base->object; oblay = base->lay; diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index d685edfcda2..d3b7b3852fc 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -189,9 +189,9 @@ short BKE_animdata_set_action(ReportList *reports, ID *id, bAction *act) else { /* cannot set */ BKE_reportf(reports, RPT_ERROR, - "Couldn't set Action '%s' onto ID '%s', as it doesn't have suitably rooted paths for this purpose", - act->id.name + 2, id->name); - //ok = 0; + "Could not set action '%s' onto ID '%s', as it does not have suitably rooted paths " + "for this purpose", act->id.name + 2, id->name); + /* ok = 0; */ } } else { @@ -420,7 +420,7 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha /* should F-Curve be moved over? * - we only need the start of the path to match basepath */ - if (animpath_matches_basepath(fcu->rna_path, basepath)) { + if (animpath_matches_basepath(fcu->rna_path, basepath)) { bActionGroup *agrp = NULL; /* if grouped... */ @@ -575,7 +575,7 @@ static char *rna_path_rename_fix(ID *owner_id, const char *prefix, const char *o */ if ( (prefixPtr && oldNamePtr) && (prefixPtr + prefixLen == oldNamePtr) ) { /* if we haven't aren't able to resolve the path now, try again after fixing it */ - if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) == 0) { + if (!verify_paths || check_rna_path_is_valid(owner_id, oldpath) == 0) { DynStr *ds = BLI_dynstr_new(); char *postfixPtr = oldNamePtr + oldNameLen; char *newPath = NULL; @@ -725,7 +725,7 @@ void BKE_animdata_fix_paths_rename(ID *owner_id, AnimData *adt, ID *ref_id, cons /* pad the names with [" "] so that only exact matches are made */ oldN = BLI_sprintfN("[\"%s\"]", oldName); newN = BLI_sprintfN("[\"%s\"]", newName); - } + } else { oldN = BLI_sprintfN("[%d]", oldSubscript); newN = BLI_sprintfN("[%d]", newSubscript); @@ -1246,7 +1246,7 @@ static short animsys_write_rna_setting(PointerRNA *ptr, char *path, int array_in if (new_ptr.type == &RNA_PoseBone) { /* bone transforms - update pose (i.e. tag depsgraph) */ skip_updates_hack = 1; - } + } if (skip_updates_hack == 0) RNA_property_update_cache_add(&new_ptr, prop); diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index f5c7cab6019..b3cbc1f2b16 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -947,7 +947,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float } } - if (use_dverts || armature_def_nr >= 0) { + if (use_dverts || armature_def_nr != -1) { if (dm) dvert = dm->getVertData(dm, i, CD_MDEFORMVERT); else if (dverts && i < target_totvert) @@ -958,7 +958,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float else dvert = NULL; - if (armature_def_nr >= 0 && dvert) { + if (armature_def_nr != -1 && dvert) { armature_weight = defvert_find_weight(dvert, armature_def_nr); if (invert_vgroup) @@ -1462,7 +1462,7 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]) * so a value inbetween these is needed. * * was 0.000001, causes bug [#30438] (which is same as [#27675, imho). - * Reseting it to org value seems to cause no more [#23954]... + * Resetting it to org value seems to cause no more [#23954]... * * was 0.0000000000001, caused bug [#31333], smaller values give unstable * roll when toggling editmode again... @@ -1593,7 +1593,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected if (UNLIKELY(pchanp == NULL)) { /* happens for proxies that become invalid because of a missing link - * for regulat cases it shouldn't happen at all */ + * for regular cases it shouldn't happen at all */ } else if (pchan->bone->layer & layer_protected) { ListBase proxylocal_constraints = {NULL, NULL}; diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 197e38ac778..c6fa2de6545 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -119,7 +119,7 @@ void free_blender(void) BKE_sequencer_cache_destruct(); IMB_moviecache_destruct(); - free_nodesystem(); + free_nodesystem(); } void initglobals(void) @@ -237,7 +237,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath /* free G.main Main database */ // CTX_wm_manager_set(C, NULL); - clear_global(); + clear_global(); /* clear old property update cache, in case some old references are left dangling */ RNA_property_update_cache_free(); @@ -338,7 +338,7 @@ static int handle_subversion_warning(Main *main, ReportList *reports) (main->minversionfile == BLENDER_VERSION && main->minsubversionfile > BLENDER_SUBVERSION)) { - BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary: %d.%d, expect loss of data!", + BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary (%d.%d), expect loss of data!", main->minversionfile, main->minsubversionfile); } @@ -407,9 +407,9 @@ int BKE_read_file(bContext *C, const char *filepath, ReportList *reports) } else setup_app_data(C, bfd, filepath); // frees BFD - } + } else - BKE_reports_prependf(reports, "Loading %s failed: ", filepath); + BKE_reports_prependf(reports, "Loading '%s' failed: ", filepath); return (bfd ? retval : BKE_READ_FILE_FAIL); } @@ -612,7 +612,7 @@ void BKE_write_undo(bContext *C, const char *name) } } -/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */ +/* 1 = an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */ void BKE_undo_step(bContext *C, int step) { diff --git a/source/blender/blenkernel/intern/bmfont.c b/source/blender/blenkernel/intern/bmfont.c index a7d90f09160..df7fb2c1807 100644 --- a/source/blender/blenkernel/intern/bmfont.c +++ b/source/blender/blenkernel/intern/bmfont.c @@ -102,7 +102,7 @@ void readBitmapFontVersion0(ImBuf * ibuf, unsigned char * rect, int step) buffer = MEM_mallocN(bytes, "readBitmapFontVersion0:buffer"); - index = 0; + index = 0; for (i = 0; i < bytes; i++) { buffer[i] = rect[index]; index += step; diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index aafc7fe89b4..b6f1b88c912 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -956,7 +956,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) // } //} - bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f; + zero_v3(bbd->wanted_co); + bbd->wanted_speed = 0.0f; /* create random seed for every particle & frame */ rand = (int)(PSYS_FRAND(psys->seed + p) * 1000); @@ -990,7 +991,8 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) add_v3_v3(wanted_co, bbd->wanted_co); wanted_speed += bbd->wanted_speed; n++; - bbd->wanted_co[0]=bbd->wanted_co[1]=bbd->wanted_co[2]=bbd->wanted_speed=0.0f; + zero_v3(bbd->wanted_co); + bbd->wanted_speed = 0.0f; } } @@ -1170,7 +1172,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* constrain direction with maximum angular velocity */ angle = saacos(dot_v3v3(old_dir, wanted_dir)); - angle = minf(angle, val.max_ave); + angle = min_ff(angle, val.max_ave); cross_v3_v3v3(nor, old_dir, wanted_dir); axis_angle_to_quat(q, nor, angle); @@ -1266,9 +1268,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) { float grav[3]; - grav[0]= 0.0f; - grav[1]= 0.0f; - grav[2]= bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f; + grav[0] = 0.0f; + grav[1] = 0.0f; + grav[2] = bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f; /* don't take forward acceleration into account (better banking) */ if (dot_v3v3(bpa->data.acc, pa->state.vel) > 0.0f) { @@ -1309,9 +1311,9 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) { float grav[3]; - grav[0]= 0.0f; - grav[1]= 0.0f; - grav[2]= bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f; + grav[0] = 0.0f; + grav[1] = 0.0f; + grav[2] = bbd->sim->scene->physics_settings.gravity[2] < 0.0f ? -1.0f : 0.0f; /* gather apparent gravity */ diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index be79077bb58..461b945282f 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -142,7 +142,7 @@ CSG_AddMeshToBlender( /* Create a new blender mesh object - using 'base' as * a template for the new object. */ - ob_new= AddNewBlenderMesh(mesh->base); + ob_new = AddNewBlenderMesh(mesh->base); me_new = ob_new->data; @@ -180,7 +180,7 @@ CSG_PerformOp( if ((mesh1 == NULL) || (mesh2 == NULL) || (output == NULL)) { return 0; - } + } if ((int_op_type < 1) || (int_op_type > 3)) return 0; switch (int_op_type) { @@ -203,8 +203,8 @@ CSG_PerformOp( mesh1->m_face_iterator, mesh1->m_vertex_iterator, mesh2->m_face_iterator, - mesh2->m_vertex_iterator, - InterpFaceVertexData + mesh2->m_vertex_iterator, + InterpFaceVertexData ); } else { @@ -215,8 +215,8 @@ CSG_PerformOp( mesh1->m_face_iterator, mesh1->m_vertex_iterator, mesh2->m_face_iterator, - mesh2->m_vertex_iterator, - InterpNoUserData + mesh2->m_vertex_iterator, + InterpNoUserData ); } diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index f4efc30068c..98b206712d6 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -618,18 +618,18 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf /* Unified Size and Strength */ -// XXX: be careful about setting size and unprojected radius -// because they depend on one another -// these functions do not set the other corresponding value -// this can lead to odd behavior if size and unprojected -// radius become inconsistent. -// the biggest problem is that it isn't possible to change -// unprojected radius because a view context is not -// available. my ussual solution to this is to use the -// ratio of change of the size to change the unprojected -// radius. Not completely convinced that is correct. -// In anycase, a better solution is needed to prevent -// inconsistency. +/* XXX: be careful about setting size and unprojected radius + * because they depend on one another + * these functions do not set the other corresponding value + * this can lead to odd behavior if size and unprojected + * radius become inconsistent. + * the biggest problem is that it isn't possible to change + * unprojected radius because a view context is not + * available. my ussual solution to this is to use the + * ratio of change of the size to change the unprojected + * radius. Not completely convinced that is correct. + * In anycase, a better solution is needed to prevent + * inconsistency. */ void BKE_brush_size_set(Scene *scene, Brush *brush, int size) { @@ -876,8 +876,8 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, /* not sure if it's actually needed or it's a mistake in coords/sizes * calculation in brush_painter_fixed_tex_partial_update(), but without this * limitation memory gets corrupted at fast strokes with quite big spacing (sergey) */ - w = MIN2(w, ibuf->x); - h = MIN2(h, ibuf->y); + w = min_ii(w, ibuf->x); + h = min_ii(h, ibuf->y); if (painter->cache.flt) { for (; y < h; y++) { @@ -1052,13 +1052,13 @@ void BKE_brush_painter_break_stroke(BrushPainter *painter) static void brush_pressure_apply(BrushPainter *painter, Brush *brush, float pressure) { if (BKE_brush_use_alpha_pressure(painter->scene, brush)) - brush_alpha_set(painter->scene, brush, maxf(0.0f, painter->startalpha * pressure)); + brush_alpha_set(painter->scene, brush, max_ff(0.0f, painter->startalpha * pressure)); if (BKE_brush_use_size_pressure(painter->scene, brush)) - BKE_brush_size_set(painter->scene, brush, maxf(1.0f, painter->startsize * pressure)); + BKE_brush_size_set(painter->scene, brush, max_ff(1.0f, painter->startsize * pressure)); if (brush->flag & BRUSH_JITTER_PRESSURE) - brush->jitter = maxf(0.0f, painter->startjitter * pressure); + brush->jitter = max_ff(0.0f, painter->startjitter * pressure); if (brush->flag & BRUSH_SPACING_PRESSURE) - brush->spacing = maxf(1.0f, painter->startspacing * (1.5f - pressure)); + brush->spacing = max_ff(1.0f, painter->startspacing * (1.5f - pressure)); } void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2]) @@ -1158,7 +1158,7 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p /* compute brush spacing adapted to brush radius, spacing may depend * on pressure, so update it */ brush_pressure_apply(painter, brush, painter->lastpressure); - spacing = maxf(1.0f, radius) * brush->spacing * 0.01f; + spacing = max_ff(1.0f, radius) * brush->spacing * 0.01f; /* setup starting distance, direction vector and accumulated distance */ startdistance = painter->accumdistance; @@ -1176,7 +1176,7 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p t = step / len; press = (1.0f - t) * painter->lastpressure + t * pressure; brush_pressure_apply(painter, brush, press); - spacing = maxf(1.0f, radius) * brush->spacing * 0.01f; + spacing = max_ff(1.0f, radius) * brush->spacing * 0.01f; BKE_brush_jitter_pos(scene, brush, paintpos, finalpos); diff --git a/source/blender/blenkernel/intern/bullet.c b/source/blender/blenkernel/intern/bullet.c index 7defa7e1be3..088031e16a7 100644 --- a/source/blender/blenkernel/intern/bullet.c +++ b/source/blender/blenkernel/intern/bullet.c @@ -54,7 +54,7 @@ BulletSoftBody *bsbNew(void) bsb->viterations = 0; - bsb->piterations = 2; + bsb->piterations = 2; bsb->diterations = 0; bsb->citerations = 4; diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index 32ae6d04934..ad828a70dd8 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -358,8 +358,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f * BVH from meshs callbacks */ -// Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_faces. -// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. +/* Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_faces. + * userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. */ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest) { const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata; @@ -395,8 +395,8 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3 } while (t2); } -// Callback to bvh tree raycast. The tree must bust have been built using bvhtree_from_mesh_faces. -// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. +/* Callback to bvh tree raycast. The tree must bust have been built using bvhtree_from_mesh_faces. + * userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. */ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) { const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata; @@ -435,8 +435,8 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r } while (t2); } -// Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_edges. -// userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. +/* Callback to bvh tree nearest point. The tree must bust have been built using bvhtree_from_mesh_edges. + * userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. */ static void mesh_edges_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest) { const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata; @@ -463,12 +463,12 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float co[3 /* * BVH builders */ -// Builds a bvh tree.. where nodes are the vertexs of the given mesh +/* Builds a bvh tree.. where nodes are the vertexs of the given mesh */ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) { BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_VERTICES); - //Not in cache + /* Not in cache */ if (tree == NULL) { int i; int numVerts = mesh->getNumVerts(mesh); @@ -484,7 +484,7 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float BLI_bvhtree_balance(tree); - //Save on cache for later use + /* Save on cache for later use */ // printf("BVHTree built and saved on cache\n"); bvhcache_insert(&mesh->bvhCache, tree, BVHTREE_FROM_VERTICES); } @@ -495,15 +495,15 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float } - //Setup BVHTreeFromMesh + /* Setup BVHTreeFromMesh */ memset(data, 0, sizeof(*data)); data->tree = tree; if (data->tree) { data->cached = TRUE; - //a NULL nearest callback works fine - //remeber the min distance to point is the same as the min distance to BV of point + /* a NULL nearest callback works fine + * remeber the min distance to point is the same as the min distance to BV of point */ data->nearest_callback = NULL; data->raycast_callback = NULL; @@ -517,12 +517,12 @@ BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float return data->tree; } -// Builds a bvh tree.. where nodes are the faces of the given mesh. +/* Builds a bvh tree.. where nodes are the faces of the given mesh. */ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) { BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_FACES); - //Not in cache + /* Not in cache */ if (tree == NULL) { int i; int numFaces = mesh->getNumTessFaces(mesh); @@ -616,7 +616,7 @@ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float } BLI_bvhtree_balance(tree); - //Save on cache for later use + /* Save on cache for later use */ // printf("BVHTree built and saved on cache\n"); bvhcache_insert(&mesh->bvhCache, tree, BVHTREE_FROM_FACES); } @@ -627,7 +627,7 @@ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float } - //Setup BVHTreeFromMesh + /* Setup BVHTreeFromMesh */ memset(data, 0, sizeof(*data)); data->tree = tree; @@ -647,12 +647,12 @@ BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float } -// Builds a bvh tree.. where nodes are the faces of the given mesh. +/* Builds a bvh tree.. where nodes are the faces of the given mesh. */ BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) { BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES); - //Not in cache + /* Not in cache */ if (tree == NULL) { int i; int numEdges = mesh->getNumEdges(mesh); @@ -672,7 +672,7 @@ BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float } BLI_bvhtree_balance(tree); - //Save on cache for later use + /* Save on cache for later use */ // printf("BVHTree built and saved on cache\n"); bvhcache_insert(&mesh->bvhCache, tree, BVHTREE_FROM_EDGES); } @@ -683,7 +683,7 @@ BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float } - //Setup BVHTreeFromMesh + /* Setup BVHTreeFromMesh */ memset(data, 0, sizeof(*data)); data->tree = tree; @@ -703,7 +703,7 @@ BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float } -// Frees data allocated by a call to bvhtree_from_mesh_*. +/* Frees data allocated by a call to bvhtree_from_mesh_*. */ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data) { if (data->tree) { @@ -728,7 +728,7 @@ static void bvhcacheitem_set_if_match(void *_cached, void *_search) BVHCacheItem *search = (BVHCacheItem *)_search; if (search->type == cached->type) { - search->tree = cached->tree; + search->tree = cached->tree; } } diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index ed7ac0e1a32..9118baeae6f 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -151,7 +151,7 @@ float BKE_camera_object_dof_distance(Object *ob) Camera *cam = (Camera *)ob->data; if (ob->type != OB_CAMERA) return 0.0f; - if (cam->dof_ob) { + if (cam->dof_ob) { /* too simple, better to return the distance on the view axis only * return len_v3v3(ob->obmat[3], cam->dof_ob->obmat[3]); */ float mat[4][4], imat[4][4], obmat[4][4]; @@ -262,11 +262,12 @@ void BKE_camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView } else if (rv3d->persp == RV3D_ORTHO) { /* orthographic view */ + int sensor_size = BKE_camera_sensor_size(params->sensor_fit, params->sensor_x, params->sensor_y); params->clipend *= 0.5f; // otherwise too extreme low zbuffer quality params->clipsta = -params->clipend; params->is_ortho = TRUE; - params->ortho_scale = rv3d->dist; + params->ortho_scale = rv3d->dist * sensor_size / v3d->lens; params->zoom = 2.0f; } else { diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index b176ed429f8..1f02ad1ea5a 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -273,6 +273,8 @@ static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) cddm->pbvh = BLI_pbvh_new(); cddm->pbvh_draw = can_pbvh_draw(ob, dm); + pbvh_show_diffuse_color_set(cddm->pbvh, ob->sculpt->show_diffuse_color); + BKE_mesh_tessface_ensure(me); BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert, @@ -379,7 +381,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) for (i = 0; i < dm->numTessFaceData; i++, mf++) { if (!(mf->flag & ME_HIDE)) { draw = 1; - } + } else { draw = 0; } @@ -438,7 +440,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges (drawLooseEdges || !(medge->flag & ME_LOOSEEDGE))) { draw = TRUE; - } + } else { draw = FALSE; } @@ -486,7 +488,7 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm) for (i = 0; i < dm->numEdgeData; i++, medge++) { if (medge->flag & ME_LOOSEEDGE) { draw = 1; - } + } else { draw = 0; } @@ -552,7 +554,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, glShadeModel(shademodel = new_shademodel); glBegin(glmode = new_glmode); - } + } if (drawCurrentMat) { if (shademodel == GL_FLAT) { @@ -1176,13 +1178,13 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, datatypes[numdata].size = 2; datatypes[numdata].type = GL_FLOAT; numdata++; - } + } for (b = 0; b < attribs.totmcol; b++) { datatypes[numdata].index = attribs.mcol[b].gl_index; datatypes[numdata].size = 4; datatypes[numdata].type = GL_UNSIGNED_BYTE; numdata++; - } + } if (attribs.tottang) { datatypes[numdata].index = attribs.tang.gl_index; datatypes[numdata].size = 4; @@ -1242,7 +1244,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); offset += sizeof(unsigned char) * 4; - } + } if (attribs.tottang) { float *tang = attribs.tang.array[a * 4 + 0]; copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); @@ -1283,7 +1285,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); offset += sizeof(unsigned char) * 4; - } + } if (attribs.tottang) { float *tang = attribs.tang.array[a * 4 + 2]; copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); @@ -1789,10 +1791,10 @@ DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase, int **orco } static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata, - int cdindex, BMLoop *l3[3], + int cdindex, const BMLoop *l3[3], int numCol, int numTex) { - BMLoop *l; + const BMLoop *l; BMFace *f = l3[0]->f; MTFace *texface; MTexPoly *texpoly; @@ -1835,13 +1837,16 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata, } } -DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdisps, int use_tessface) +/* used for both editbmesh and bmesh */ +static DerivedMesh *cddm_from_bmesh_ex(struct BMesh *bm, int use_mdisps, + /* EditBMesh vars for use_tessface */ + int use_tessface, + const int em_tottri, const BMLoop *(*em_looptris)[3] + ) { - BMesh *bm = em->bm; - DerivedMesh *dm = CDDM_new(bm->totvert, bm->totedge, - use_tessface ? em->tottri : 0, + use_tessface ? em_tottri : 0, bm->totloop, bm->totface); @@ -1887,7 +1892,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis /* add tessellation mface layers */ if (use_tessface) { - CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em->tottri); + CustomData_from_bmeshpoly(&dm->faceData, &dm->polyData, &dm->loopData, em_tottri); } index = dm->getVertDataArray(dm, CD_ORIGINDEX); @@ -1953,7 +1958,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis index = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); for (i = 0; i < dm->numTessFaceData; i++, index++, polyindex++) { MFace *mf = &mface[i]; - BMLoop **l = em->looptris[i]; + const BMLoop **l = em_looptris[i]; efa = l[0]->f; mf->v1 = BM_elem_index_get(l[0]->v); @@ -2003,6 +2008,20 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis return dm; } +struct DerivedMesh *CDDM_from_bmesh(struct BMesh *bm, int use_mdisps) +{ + return cddm_from_bmesh_ex(bm, use_mdisps, FALSE, + /* these vars are for editmesh only */ + 0, NULL); +} + +DerivedMesh *CDDM_from_editbmesh(BMEditMesh *em, int use_mdisps, int use_tessface) +{ + return cddm_from_bmesh_ex(em->bm, use_mdisps, + /* editmesh */ + use_tessface, em->tottri, (const BMLoop *(*)[3])em->looptris); +} + static DerivedMesh *cddm_copy_ex(DerivedMesh *source, int faces_from_tessfaces) { CDDerivedMesh *cddm = cdDM_create("CDDM_copy cddm"); @@ -2339,7 +2358,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) BLI_array_append(oldp, i); } - /*create new cddm*/ + /*create new cddm*/ cddm2 = (CDDerivedMesh *) CDDM_from_template((DerivedMesh *)cddm, BLI_array_count(mvert), BLI_array_count(medge), 0, BLI_array_count(mloop), BLI_array_count(mpoly)); /*update edge indices and copy customdata*/ @@ -2364,7 +2383,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) CustomData_copy_data(&dm->loopData, &cddm2->dm.loopData, oldl[i], i, 1); } - /*copy vertex customdata*/ + /*copy vertex customdata*/ mv = mvert; for (i = 0; i < cddm2->dm.numVertData; i++, mv++) { CustomData_copy_data(&dm->vertData, &cddm2->dm.vertData, oldv[i], i, 1); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index da162ab37d0..f1d73c7777a 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -41,8 +41,6 @@ #include "BLI_utildefines.h" #include "BLI_linklist.h" -#include "BLF_translation.h" - #include "BKE_cdderivedmesh.h" #include "BKE_cloth.h" #include "BKE_effect.h" @@ -331,7 +329,7 @@ static int do_init_cloth(Object *ob, ClothModifierData *clmd, DerivedMesh *resul cache= clmd->point_cache; /* initialize simulation data if it didn't exist already */ - if (clmd->clothObject == NULL) { + if (clmd->clothObject == NULL) { if (!cloth_from_object(ob, clmd, result, framenr, 1)) { BKE_ptcache_invalidate(cache); return 0; @@ -824,7 +822,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d int i = 0; MVert *mvert = NULL; ClothVertex *verts = NULL; - float (*shapekey_rest)[3]= NULL; + float (*shapekey_rest)[3] = NULL; float tnull[3] = {0, 0, 0}; Cloth *cloth = NULL; float maxdist = 0; @@ -845,7 +843,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d clmd->clothObject->edgehash = NULL; } else if (!clmd->clothObject) { - modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject.")); + modifier_setError(&(clmd->modifier), "Out of memory on allocating clmd->clothObject"); return 0; } @@ -907,7 +905,7 @@ static int cloth_from_object(Object *ob, ClothModifierData *clmd, DerivedMesh *d if ( !cloth_build_springs ( clmd, dm ) ) { cloth_free_modifier ( clmd ); - modifier_setError(&(clmd->modifier), "%s", TIP_("Can't build springs.")); + modifier_setError(&(clmd->modifier), "Cannot build springs"); printf("cloth_free_modifier cloth_build_springs\n"); return 0; } @@ -949,7 +947,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) clmd->clothObject->verts = MEM_callocN ( sizeof ( ClothVertex ) * clmd->clothObject->numverts, "clothVertex" ); if ( clmd->clothObject->verts == NULL ) { cloth_free_modifier ( clmd ); - modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->verts.")); + modifier_setError(&(clmd->modifier), "Out of memory on allocating clmd->clothObject->verts"); printf("cloth_free_modifier clmd->clothObject->verts\n"); return; } @@ -959,7 +957,7 @@ static void cloth_from_mesh ( ClothModifierData *clmd, DerivedMesh *dm ) clmd->clothObject->mfaces = MEM_callocN ( sizeof ( MFace ) * clmd->clothObject->numfaces, "clothMFaces" ); if ( clmd->clothObject->mfaces == NULL ) { cloth_free_modifier ( clmd ); - modifier_setError(&(clmd->modifier), "%s", TIP_("Out of memory on allocating clmd->clothObject->mfaces.")); + modifier_setError(&(clmd->modifier), "Out of memory on allocating clmd->clothObject->mfaces"); printf("cloth_free_modifier clmd->clothObject->mfaces\n"); return; } @@ -1050,29 +1048,25 @@ static void cloth_update_springs( ClothModifierData *clmd ) spring->stiffness = 0.0f; - if(spring->type == CLOTH_SPRING_TYPE_STRUCTURAL) - { + if (spring->type == CLOTH_SPRING_TYPE_STRUCTURAL) { spring->stiffness = (cloth->verts[spring->kl].struct_stiff + cloth->verts[spring->ij].struct_stiff) / 2.0f; } - else if(spring->type == CLOTH_SPRING_TYPE_SHEAR) - { + else if (spring->type == CLOTH_SPRING_TYPE_SHEAR) { spring->stiffness = (cloth->verts[spring->kl].shear_stiff + cloth->verts[spring->ij].shear_stiff) / 2.0f; } - else if(spring->type == CLOTH_SPRING_TYPE_BENDING) - { + else if (spring->type == CLOTH_SPRING_TYPE_BENDING) { spring->stiffness = (cloth->verts[spring->kl].bend_stiff + cloth->verts[spring->ij].bend_stiff) / 2.0f; } - else if(spring->type == CLOTH_SPRING_TYPE_GOAL) - { + else if (spring->type == CLOTH_SPRING_TYPE_GOAL) { /* Warning: Appending NEW goal springs does not work because implicit solver would need reset! */ /* Activate / Deactivate existing springs */ - if ((!(cloth->verts[spring->ij].flags & CLOTH_VERT_FLAG_PINNED)) && (cloth->verts[spring->ij].goal > ALMOST_ZERO)) + if ((!(cloth->verts[spring->ij].flags & CLOTH_VERT_FLAG_PINNED)) && + (cloth->verts[spring->ij].goal > ALMOST_ZERO)) { spring->flags &= ~CLOTH_SPRING_FLAG_DEACTIVATE; } - else - { + else { spring->flags |= CLOTH_SPRING_FLAG_DEACTIVATE; } } diff --git a/source/blender/blenkernel/intern/collision.c b/source/blender/blenkernel/intern/collision.c index 05c916f9362..8da0538a08d 100644 --- a/source/blender/blenkernel/intern/collision.c +++ b/source/blender/blenkernel/intern/collision.c @@ -272,7 +272,7 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM /* Decrease in magnitude of relative tangential velocity due to coulomb friction * in original formula "magrelVel" should be the "change of relative velocity in normal direction" */ - magtangent = minf(clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf(dot_v3v3(vrel_t_pre, vrel_t_pre))); + magtangent = min_ff(clmd->coll_parms->friction * 0.01f * magrelVel, sqrtf(dot_v3v3(vrel_t_pre, vrel_t_pre))); /* Apply friction impulse. */ if ( magtangent > ALMOST_ZERO ) { @@ -312,8 +312,8 @@ static int cloth_collision_response_static ( ClothModifierData *clmd, CollisionM /* stay on the safe side and clamp repulse */ if ( impulse > ALMOST_ZERO ) - repulse = MIN2 ( repulse, 5.0*impulse ); - repulse = MAX2 ( impulse, repulse ); + repulse = min_ff( repulse, 5.0*impulse ); + repulse = max_ff(impulse, repulse); impulse = repulse / ( 1.0f + w1*w1 + w2*w2 + w3*w3 ); /* original 2.0 / 0.25 */ VECADDMUL ( i1, collpair->normal, impulse ); @@ -515,7 +515,7 @@ static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned if (((modifier_type == eModifierType_Collision) && ob->pd && ob->pd->deflect) || (modifier_type != eModifierType_Collision)) cmd= (CollisionModifierData *)modifiers_findByType(ob, modifier_type); - if (cmd) { + if (cmd) { /* extend array */ if (*numobj >= *maxobj) { *maxobj *= 2; @@ -534,7 +534,7 @@ static void add_collision_object(Object ***objs, unsigned int *numobj, unsigned /* add objects */ for (go= group->gobject.first; go; go= go->next) add_collision_object(objs, numobj, maxobj, go->ob, self, level+1, modifier_type); - } + } } // return all collision objects in scene @@ -580,7 +580,7 @@ static void add_collider_cache_object(ListBase **objs, Object *ob, Object *self, if (ob->pd && ob->pd->deflect) cmd =(CollisionModifierData *)modifiers_findByType(ob, eModifierType_Collision); - if (cmd && cmd->bvhtree) { + if (cmd && cmd->bvhtree) { if (*objs == NULL) *objs = MEM_callocN(sizeof(ListBase), "ColliderCache array"); @@ -738,8 +738,7 @@ int cloth_bvh_objcollision(Object *ob, ClothModifierData * clmd, float step, flo collision_move_object ( collmd, step + dt, step ); } - do - { + do { CollPair **collisions, **collisions_index; ret2 = 0; diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index d5d6d31b1e1..0c369a463d5 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -65,10 +65,10 @@ void curvemapping_set_defaults(CurveMapping *cumap, int tot, float minx, float m cumap->flag = CUMA_DO_CLIP; if (tot == 4) cumap->cur = 3; /* rhms, hack for 'col' curve? */ - clipminx = minf(minx, maxx); - clipminy = minf(miny, maxy); - clipmaxx = maxf(minx, maxx); - clipmaxy = maxf(miny, maxy); + clipminx = min_ff(minx, maxx); + clipminy = min_ff(miny, maxy); + clipmaxx = max_ff(minx, maxx); + clipmaxy = max_ff(miny, maxy); BLI_rctf_init(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy); cumap->clipr = cumap->curr; @@ -85,7 +85,7 @@ void curvemapping_set_defaults(CurveMapping *cumap, int tot, float minx, float m cumap->cm[a].curve[0].y = miny; cumap->cm[a].curve[1].x = maxx; cumap->cm[a].curve[1].y = maxy; - } + } cumap->changed_timestamp = 0; } @@ -160,7 +160,7 @@ void curvemapping_set_black_white_ex(const float black[3], const float white[3], int a; for (a = 0; a < 3; a++) { - const float delta = maxf(white[a] - black[a], 1e-5f); + const float delta = max_ff(white[a] - black[a], 1e-5f); r_bwmul[a] = 1.0f / delta; } } @@ -498,8 +498,8 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr) bezt = MEM_callocN(cuma->totpoint * sizeof(BezTriple), "beztarr"); for (a = 0; a < cuma->totpoint; a++) { - cuma->mintable = minf(cuma->mintable, cmp[a].x); - cuma->maxtable = maxf(cuma->maxtable, cmp[a].x); + cuma->mintable = min_ff(cuma->mintable, cmp[a].x); + cuma->maxtable = max_ff(cuma->maxtable, cmp[a].x); bezt[a].vec[1][0] = cmp[a].x; bezt[a].vec[1][1] = cmp[a].y; if (cmp[a].flag & CUMA_VECTOR) @@ -555,7 +555,7 @@ static void curvemap_make_table(CurveMap *cuma, const rctf *clipr) sub_v3_v3v3(bezt[a].vec[2], bezt[a].vec[1], vec); } } - } + } /* make the bezier curve */ if (cuma->table) MEM_freeN(cuma->table); @@ -690,13 +690,13 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) for (a = 0; a < cuma->totpoint; a++) { if (cmp[a].flag & CUMA_SELECT) { if (cmp[a].x < clipr->xmin) - dx = minf(dx, cmp[a].x - clipr->xmin); + dx = min_ff(dx, cmp[a].x - clipr->xmin); else if (cmp[a].x > clipr->xmax) - dx = maxf(dx, cmp[a].x - clipr->xmax); + dx = max_ff(dx, cmp[a].x - clipr->xmax); if (cmp[a].y < clipr->ymin) - dy = minf(dy, cmp[a].y - clipr->ymin); + dy = min_ff(dy, cmp[a].y - clipr->ymin); else if (cmp[a].y > clipr->ymax) - dy = maxf(dy, cmp[a].y - clipr->ymax); + dy = max_ff(dy, cmp[a].y - clipr->ymax); } } for (a = 0; a < cuma->totpoint; a++) { @@ -731,7 +731,7 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) } if (a != cuma->totpoint - 1) curvemap_remove(cuma, 2); - } + } curvemap_make_table(cuma, clipr); } diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index e3f7ae1b1c7..e300b5e0f19 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -221,51 +221,6 @@ void constraints_clear_evalob(bConstraintOb *cob) /* -------------- Space-Conversion API -------------- */ -#if 0 /* XXX Old code, does the same as one in armature.c, will remove it later. */ -static void constraint_pchan_diff_mat(bPoseChannel *pchan, float diff_mat[4][4]) -{ - if (pchan->parent) { - float offs_bone[4][4]; - - /* construct offs_bone the same way it is done in armature.c */ - copy_m4_m3(offs_bone, pchan->bone->bone_mat); - copy_v3_v3(offs_bone[3], pchan->bone->head); - offs_bone[3][1] += pchan->bone->parent->length; - - if (pchan->bone->flag & BONE_HINGE) { - /* pose_mat = par_pose-space_location * chan_mat */ - float tmat[4][4]; - - /* the rotation of the parent restposition */ - copy_m4_m4(tmat, pchan->bone->parent->arm_mat); - - /* the location of actual parent transform */ - copy_v3_v3(tmat[3], offs_bone[3]); - zero_v3(offs_bone[3]); - mul_m4_v3(pchan->parent->pose_mat, tmat[3]); - - mult_m4_m4m4(diff_mat, tmat, offs_bone); - } - else { - /* pose_mat = par_pose_mat * bone_mat * chan_mat */ - if (pchan->bone->flag & BONE_NO_SCALE) { - float tmat[4][4]; - copy_m4_m4(tmat, pchan->parent->pose_mat); - normalize_m4(tmat); - mult_m4_m4m4(diff_mat, tmat, offs_bone); - } - else { - mult_m4_m4m4(diff_mat, pchan->parent->pose_mat, offs_bone); - } - } - } - else { - /* pose_mat = chan_mat * arm_mat */ - copy_m4_m4(diff_mat, pchan->bone->arm_mat); - } -} -#endif - /* This function is responsible for the correct transformations/conversions * of a matrix from one space to another for constraint evaluation. * For now, this is only implemented for Objects and PoseChannels. @@ -307,18 +262,6 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] else if (to == CONSTRAINT_SPACE_LOCAL) { if (pchan->bone) { BKE_armature_mat_pose_to_bone(pchan, mat, mat); -#if 0 /* XXX Old code, will remove it later. */ - constraint_pchan_diff_mat(pchan, diff_mat); - - invert_m4_m4(imat, diff_mat); - mult_m4_m4m4(mat, imat, mat); - - /* override with local location */ - if ((pchan->parent) && (pchan->bone->flag & BONE_NO_LOCAL_LOCATION)) { - BKE_armature_mat_pose_to_bone_ex(ob, pchan, pchan->pose_mat, tempmat); - copy_v3_v3(mat[3], tempmat[3]); - } -#endif } } /* pose to local with parent */ @@ -336,24 +279,19 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] if (pchan->bone) { /* we need the posespace_matrix = local_matrix + (parent_posespace_matrix + restpos) */ BKE_armature_mat_bone_to_pose(pchan, mat, mat); -#if 0 - constraint_pchan_diff_mat(pchan, diff_mat); - - mult_m4_m4m4(mat, diff_mat, mat); -#endif } /* use pose-space as stepping stone for other spaces */ if (ELEM(to, CONSTRAINT_SPACE_WORLD, CONSTRAINT_SPACE_PARLOCAL)) { /* call self with slightly different values */ constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to); - } + } } break; case CONSTRAINT_SPACE_PARLOCAL: /* -------------- FROM LOCAL WITH PARENT ---------- */ { /* local + parent to pose */ - if (pchan->bone) { + if (pchan->bone) { copy_m4_m4(diff_mat, pchan->bone->arm_mat); mult_m4_m4m4(mat, mat, diff_mat); } @@ -432,7 +370,7 @@ static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[ /* get DerivedMesh */ if (em) { /* target is in editmode, so get a special derived mesh */ - dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE); + dm = CDDM_from_editbmesh(em, FALSE, FALSE); freeDM = 1; } else { @@ -604,15 +542,15 @@ static void constraint_target_to_mat4(Object *ob, const char *substring, float m float tempmat[4][4], loc[3]; /* interpolate along length of bone */ - interp_v3_v3v3(loc, pchan->pose_head, pchan->pose_tail, headtail); + interp_v3_v3v3(loc, pchan->pose_head, pchan->pose_tail, headtail); /* use interpolated distance for subtarget */ - copy_m4_m4(tempmat, pchan->pose_mat); + copy_m4_m4(tempmat, pchan->pose_mat); copy_v3_v3(tempmat[3], loc); mult_m4_m4m4(mat, ob->obmat, tempmat); } - } + } else copy_m4_m4(mat, ob->obmat); @@ -976,11 +914,11 @@ static void vectomat(const float vec[3], const float target_up[3], short axis, s else negate_v3(n); /* n specifies the transformation of the track axis */ - if (flags & TARGET_Z_UP) { + if (flags & TARGET_Z_UP) { /* target Z axis is the global up axis */ copy_v3_v3(u, target_up); } - else { + else { /* world Z axis is the global up axis */ u[0] = 0; u[1] = 0; @@ -1034,7 +972,7 @@ static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *tar /* Get size property, since ob->size is only the object's own relative size, not its global one */ mat4_to_size(size, cob->matrix); - /* Clear the object's rotation */ + /* Clear the object's rotation */ cob->matrix[0][0] = size[0]; cob->matrix[0][1] = 0; cob->matrix[0][2] = 0; @@ -1468,7 +1406,7 @@ static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *U if (data->flag & LIMIT_XMIN) { if (size[0] < data->xmin) - size[0] = data->xmin; + size[0] = data->xmin; } if (data->flag & LIMIT_XMAX) { if (size[0] > data->xmax) @@ -1476,7 +1414,7 @@ static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *U } if (data->flag & LIMIT_YMIN) { if (size[1] < data->ymin) - size[1] = data->ymin; + size[1] = data->ymin; } if (data->flag & LIMIT_YMAX) { if (size[1] > data->ymax) @@ -1484,7 +1422,7 @@ static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *U } if (data->flag & LIMIT_ZMIN) { if (size[2] < data->zmin) - size[2] = data->zmin; + size[2] = data->zmin; } if (data->flag & LIMIT_ZMAX) { if (size[2] > data->zmax) @@ -2002,7 +1940,7 @@ static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTa /* this check is to make sure curve objects get updated on file load correctly.*/ if (cu->path == NULL || cu->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */ - BKE_displist_make_curveTypes(cob->scene, ct->tar, 0); + BKE_displist_make_curveTypes(cob->scene, ct->tar, 0); } /* firstly calculate the matrix the normal way, then let the py-function override @@ -2764,7 +2702,7 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t default: /* should not happen, but in case*/ return; } /* switch (data->volmode) */ - + /* Clear the object's rotation and scale */ cob->matrix[0][0] = size[0] * scale[0]; cob->matrix[0][1] = 0; @@ -2787,10 +2725,10 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t /* othogonal to "new Y" "old X! plane */ cross_v3_v3v3(orth, vec, xx); normalize_v3(orth); - + /* new Z*/ copy_v3_v3(totmat[2], orth); - + /* we decided to keep X plane*/ cross_v3_v3v3(xx, orth, vec); normalize_v3_v3(totmat[0], xx); @@ -2800,16 +2738,16 @@ static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t /* othogonal to "new Y" "old Z! plane */ cross_v3_v3v3(orth, vec, zz); normalize_v3(orth); - + /* new X */ negate_v3_v3(totmat[0], orth); - + /* we decided to keep Z */ cross_v3_v3v3(zz, orth, vec); normalize_v3_v3(totmat[2], zz); break; } /* switch (data->plane) */ - + mul_m4_m3m4(cob->matrix, totmat, cob->matrix); } } @@ -2937,7 +2875,7 @@ static void minmax_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ if (data->flag & MINMAX_STICKY) { if (data->flag & MINMAX_STUCK) { copy_v3_v3(obmat[3], data->cache); - } + } else { copy_v3_v3(data->cache, obmat[3]); data->flag |= MINMAX_STUCK; @@ -2947,11 +2885,11 @@ static void minmax_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targ /* get out of localspace */ mult_m4_m4m4(tmat, ct->matrix, obmat); copy_m4_m4(cob->matrix, tmat); - } - else { + } + else { copy_v3_v3(cob->matrix[3], obmat[3]); } - } + } else { data->flag &= ~MINMAX_STUCK; } @@ -3291,7 +3229,7 @@ static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t /* extract components of owner's matrix */ copy_v3_v3(loc, cob->matrix[3]); mat4_to_eulO(eul, cob->rotOrder, cob->matrix); - mat4_to_size(size, cob->matrix); + mat4_to_size(size, cob->matrix); /* determine where in range current transforms lie */ if (data->expo) { @@ -3615,7 +3553,7 @@ static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *t cross_v3_v3v3(raxis, obvec, tarvec); rangle = dot_v3v3(obvec, tarvec); - rangle = acos(maxf(-1.0f, minf(1.0f, rangle))); + rangle = acos(max_ff(-1.0f, min_ff(1.0f, rangle))); /* construct rotation matrix from the axis-angle rotation found above * - this call takes care to make sure that the axis provided is a unit vector first @@ -4663,7 +4601,7 @@ short proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan) else { /* FIXME: constraints on object-level are not handled well yet */ return 1; - } + } } return 0; @@ -4703,7 +4641,7 @@ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n, unit_m4(cob->matrix); unit_m4(cob->startmat); } - } + } break; case CONSTRAINT_OBTYPE_BONE: /* this may occur in some cases */ { @@ -4839,7 +4777,7 @@ void solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime) * since some constraints may not convert the solution back to the input space before blending * but all are guaranteed to end up in good "worldspace" result */ - /* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka */ + /* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka (r.32105) */ if (enf < 1.0f) { float solution[4][4]; copy_m4_m4(solution, cob->matrix); diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index be81c70f261..719ae7357b4 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -234,9 +234,8 @@ struct bContextDataResult { static void *ctx_wm_python_context_get(const bContext *C, const char *member, void *fall_through) { #ifdef WITH_PYTHON - bContextDataResult result; - - if (C && CTX_py_dict_get(C)) { + if (UNLIKELY(C && CTX_py_dict_get(C))) { + bContextDataResult result; memset(&result, 0, sizeof(bContextDataResult)); BPY_context_member_get((bContext *)C, member, &result); if (result.ptr.data) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index e09e2eeb493..06dad495d81 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1050,10 +1050,13 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, MEM_freeN(jend); } +/** + * \param coord_array Has to be 3 * 4 * pntsu * resolu in size and zero-ed + * \param tilt_array set when non-NULL + * \param radius_array set when non-NULL + */ void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride) -/* coord_array has to be 3*4*pntsu*resolu in size and zero-ed - * tilt_array and radius_array will be written to if valid */ { BPoint *bp; float u, ustart, uend, ustep, sumdiv; @@ -1476,7 +1479,7 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende } } else if (cu->ext1 == 0.0f && cu->ext2 == 0.0f) { - ; + /* pass */ } else if (cu->ext2 == 0.0f) { dl = MEM_callocN(sizeof(DispList), "makebevelcurve2"); @@ -1945,7 +1948,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) if (bl->poly == -1) { /* check its not cyclic */ /* skip the first point */ - /* bevp0= bevp1; */ + /* bevp0 = bevp1; */ bevp1 = bevp2; bevp2++; nr--; @@ -1974,7 +1977,7 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) interp_qt_qtqt(bevp1->quat, bevp1->quat, q, 0.5); normalize_qt(bevp1->quat); - /* bevp0= bevp1; */ /* UNUSED */ + /* bevp0 = bevp1; */ /* UNUSED */ bevp1 = bevp2; bevp2++; } @@ -2151,7 +2154,7 @@ static void make_bevel_list_3D_tangent(BevList *bl) normalize_v3(cross_tmp); tri_to_quat(bevp1->quat, zero, cross_tmp, bevp1->tan); /* XXX - could be faster */ - /* bevp0= bevp1; */ /* UNUSED */ + /* bevp0 = bevp1; */ /* UNUSED */ bevp1 = bevp2; bevp2++; } diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 423bd93c70f..d8082902a44 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -65,6 +65,12 @@ /* number of layers to add when growing a CustomData object */ #define CUSTOMDATA_GROW 5 +/* ensure typemap size is ok */ +BLI_STATIC_ASSERT(sizeof(((CustomData *)NULL)->typemap) / + sizeof(((CustomData *)NULL)->typemap[0]) == CD_NUMTYPES, + "size mismatch"); + + /********************* Layer type information **********************/ typedef struct LayerTypeInfo { int size; /* the memory size of one element of this layer's data */ @@ -1076,7 +1082,7 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { layerEqual_mloopuv, layerMultiply_mloopuv, layerInitMinMax_mloopuv, layerAdd_mloopuv, layerDoMinMax_mloopuv, layerCopyValue_mloopuv}, /* 17: CD_MLOOPCOL */ - {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL, + {sizeof(MLoopCol), "MLoopCol", 1, "Col", NULL, NULL, layerInterp_mloopcol, NULL, layerDefault_mloopcol, layerEqual_mloopcol, layerMultiply_mloopcol, layerInitMinMax_mloopcol, layerAdd_mloopcol, layerDoMinMax_mloopcol, layerCopyValue_mloopcol}, /* 18: CD_TANGENT */ @@ -1221,9 +1227,6 @@ void CustomData_update_typemap(CustomData *data) { int i, lasttype = -1; - /* since we cant do in a pre-processor do here as an assert */ - BLI_assert(sizeof(data->typemap) / sizeof(int) >= CD_NUMTYPES); - for (i = 0; i < CD_NUMTYPES; i++) { data->typemap[i] = -1; } @@ -2477,10 +2480,49 @@ int CustomData_layer_has_math(struct CustomData *data, int layer_n) if (typeInfo->equal && typeInfo->add && typeInfo->multiply && typeInfo->initminmax && typeInfo->dominmax) { - return 1; + return TRUE; } - return 0; + return FALSE; +} + +int CustomData_layer_has_interp(struct CustomData *data, int layer_n) +{ + const LayerTypeInfo *typeInfo = layerType_getInfo(data->layers[layer_n].type); + + if (typeInfo->interp) { + return TRUE; + } + + return FALSE; +} + +int CustomData_has_math(struct CustomData *data) +{ + int i; + + /* interpolates a layer at a time */ + for (i = 0; i < data->totlayer; ++i) { + if (CustomData_layer_has_math(data, i)) { + return TRUE; + } + } + + return FALSE; +} + +int CustomData_has_interp(struct CustomData *data) +{ + int i; + + /* interpolates a layer at a time */ + for (i = 0; i < data->totlayer; ++i) { + if (CustomData_layer_has_interp(data, i)) { + return TRUE; + } + } + + return FALSE; } /* copies the "value" (e.g. mloopuv uv or mloopcol colors) from one block to @@ -2580,8 +2622,8 @@ void CustomData_bmesh_set_layer_n(CustomData *data, void *block, int n, void *so memcpy(dest, source, typeInfo->size); } -void CustomData_bmesh_interp(CustomData *data, void **src_blocks, float *weights, - float *sub_weights, int count, void *dest_block) +void CustomData_bmesh_interp(CustomData *data, void **src_blocks, const float *weights, + const float *sub_weights, int count, void *dest_block) { int i, j; void *source_buf[SOURCE_BUF_SIZE]; diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c index 4110d4565b2..82938ed1d39 100644 --- a/source/blender/blenkernel/intern/deform.c +++ b/source/blender/blenkernel/intern/deform.c @@ -278,7 +278,7 @@ void defvert_normalize_lock_map(MDeformVert *dvert, const char *lock_flags, cons } } - lock_iweight = maxf(0.0f, 1.0f - lock_iweight); + lock_iweight = max_ff(0.0f, 1.0f - lock_iweight); if (tot_weight > 0.0f) { /* paranoid, should be 1.0 but in case of float error clamp anyway */ @@ -431,7 +431,7 @@ int *defgroup_flip_map_single(Object *ob, int *flip_map_len, int use_default, in if (strcmp(name, dg->name)) { flip_num = defgroup_name_index(ob, name); - if (flip_num >= 0) { + if (flip_num != -1) { map[defgroup] = flip_num; map[flip_num] = defgroup; } diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 20b029371f1..950a0ca3d60 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -150,8 +150,8 @@ void queue_delete(DagNodeQueue *queue) MEM_freeN(temp); } - MEM_freeN(queue->freenodes); - MEM_freeN(queue); + MEM_freeN(queue->freenodes); + MEM_freeN(queue); } /* insert in queue, remove in front */ @@ -190,8 +190,8 @@ void push_queue(DagNodeQueue *queue, DagNode *node) } queue->freenodes->count = DAGQUEUEALLOC; - elem = queue->freenodes->first; - queue->freenodes->first = elem->next; + elem = queue->freenodes->first; + queue->freenodes->first = elem->next; } elem->next = NULL; elem->node = node; @@ -211,7 +211,7 @@ void push_stack(DagNodeQueue *queue, DagNode *node) DagNodeQueueElem *elem; int i; - elem = queue->freenodes->first; + elem = queue->freenodes->first; if (elem != NULL) { queue->freenodes->first = elem->next; if (queue->freenodes->last == elem) { @@ -235,8 +235,8 @@ void push_stack(DagNodeQueue *queue, DagNode *node) } queue->freenodes->count = DAGQUEUEALLOC; - elem = queue->freenodes->first; - queue->freenodes->first = elem->next; + elem = queue->freenodes->first; + queue->freenodes->first = elem->next; } elem->next = queue->first; elem->node = node; @@ -302,7 +302,7 @@ DagForest *dag_init(void) } /* isdata = object data... */ -// XXX this needs to be extended to be more flexible (so that not only objects are evaluated via depsgraph)... +/* XXX this needs to be extended to be more flexible (so that not only objects are evaluated via depsgraph)... */ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node, int isdata) { FCurve *fcu; @@ -412,7 +412,7 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec if ((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) { if (skip_forcefield && ob1->pd->forcefield == skip_forcefield) continue; - node2 = dag_get_node(dag, ob1); + node2 = dag_get_node(dag, ob1); dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Field Collision"); } } @@ -464,7 +464,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ct->tar->type == OB_MESH) node3->customdata_mask |= CD_MASK_MDEFORMVERT; } - else if (ELEM3(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK)) + else if (ELEM3(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK)) dag_add_relation(dag, node3, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, cti->name); else dag_add_relation(dag, node3, node, DAG_RL_OB_DATA, cti->name); @@ -606,7 +606,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (mom != ob) { node2 = dag_get_node(dag, mom); - dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Metaball"); // mom depends on children! + dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Metaball"); /* mom depends on children! */ } } break; @@ -818,7 +818,7 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask) tag_main_idcode(bmain, ID_MA, FALSE); /* add base node for scene. scene is always the first node in DAG */ - scenenode = dag_add_node(dag, sce); + scenenode = dag_add_node(dag, sce); /* add current scene objects */ for (base = sce->base.first; base; base = base->next) { @@ -872,7 +872,7 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask) } /* cycle detection and solving */ - // solve_cycles(dag); + // solve_cycles(dag); return dag; } @@ -881,23 +881,23 @@ DagForest *build_dag(Main *bmain, Scene *sce, short mask) void free_forest(DagForest *Dag) { /* remove all nodes and deps */ DagNode *tempN; - DagAdjList *tempA; + DagAdjList *tempA; DagAdjList *itA; DagNode *itN = Dag->DagNode.first; while (itN) { - itA = itN->child; + itA = itN->child; while (itA) { tempA = itA; itA = itA->next; - MEM_freeN(tempA); + MEM_freeN(tempA); } - itA = itN->parent; + itA = itN->parent; while (itA) { tempA = itA; itA = itA->next; - MEM_freeN(tempA); + MEM_freeN(tempA); } tempN = itN; @@ -921,8 +921,8 @@ DagNode *dag_find_node(DagForest *forest, void *fob) return NULL; } -static int ugly_hack_sorry = 1; // prevent type check -static int dag_print_dependencies = 0; // debugging +static int ugly_hack_sorry = 1; /* prevent type check */ +static int dag_print_dependencies = 0; /* debugging */ /* no checking of existence, use dag_find_node first or dag_get_node */ DagNode *dag_add_node(DagForest *forest, void *fob) @@ -934,7 +934,7 @@ DagNode *dag_add_node(DagForest *forest, void *fob) node->ob = fob; node->color = DAG_WHITE; - if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting + if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); /* sorry, done for pose sorting */ if (forest->numNodes) { ((DagNode *) forest->DagNode.last)->next = node; forest->DagNode.last = node; @@ -1153,7 +1153,7 @@ static void dag_check_cycle(DagForest *dag) for (node = dag->DagNode.first; node; node = node->next) { while (node->parent) { itA = node->parent->next; - MEM_freeN(node->parent); + MEM_freeN(node->parent); node->parent = itA; } } @@ -1242,7 +1242,7 @@ void graph_bfs(void) itA = itA->next; } if (pos[node->BFS_dist] > node->k) { - pos[node->BFS_dist] += 1; + pos[node->BFS_dist] += 1; node->k = (float) pos[node->BFS_dist]; } else { @@ -1303,7 +1303,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a pre_func(node->ob, data); } - else { // back or cross edge + else { /* back or cross edge */ retval = 1; } itA = itA->next; @@ -1334,7 +1334,7 @@ DagNodeQueue *graph_dfs(void) /* int is_cycle = 0; */ /* UNUSED */ /* *fprintf(stderr, "starting DFS\n ------------\n"); - */ + */ nqueue = queue_create(DAGQUEUEALLOC); retqueue = queue_create(MainDag->numNodes); for (i = 0; i < 50; i++) @@ -1386,7 +1386,7 @@ DagNodeQueue *graph_dfs(void) break; } else { - if (itA->node->color == DAG_GRAY) { // back edge + if (itA->node->color == DAG_GRAY) { /* back edge */ fprintf(stderr, "dfs back edge :%15s %15s\n", ((ID *) node->ob)->name, ((ID *) itA->node->ob)->name); /* is_cycle = 1; */ /* UNUSED */ } @@ -1464,7 +1464,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a int retval = 0; /* * fprintf(stderr, "starting DFS\n ------------\n"); - */ + */ nqueue = queue_create(DAGQUEUEALLOC); /* Init @@ -1518,7 +1518,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a // } } itA = itA->next; - } + } if (!skip) { node = pop_queue(nqueue); @@ -1537,7 +1537,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a } -// used to get the obs owning a datablock +/* used to get the obs owning a datablock */ DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) { DagNode *node, *node1; @@ -1548,7 +1548,7 @@ DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) if (node == NULL) { return NULL; } - else if (node->ancestor_count == 1) { // simple case + else if (node->ancestor_count == 1) { /* simple case */ nqueue = queue_create(1); push_queue(nqueue, node); } @@ -1557,7 +1557,7 @@ DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) node1 = dag->DagNode.first; do { - if (node1->DFS_fntm > node->DFS_fntm) { // a parent is finished after child. must check adj list + if (node1->DFS_fntm > node->DFS_fntm) { /* a parent is finished after child. must check adj list */ itA = node->child; while (itA != NULL) { if ((itA->node == node) && (itA->type == DAG_RL_DATA)) { @@ -1585,7 +1585,7 @@ DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) node1 = dag->DagNode.first; do { - if (node1->DFS_fntm > node->DFS_fntm) { + if (node1->DFS_fntm > node->DFS_fntm) { itA = node->child; while (itA != NULL) { if (itA->node == node) { @@ -1597,10 +1597,10 @@ DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) node1 = node1->next; } while (node1); - return nqueue; + return nqueue; } -// standard DFS list +/* standard DFS list */ DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) { DagNode *node; @@ -1611,7 +1611,7 @@ DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) int skip = 0; nqueue = queue_create(DAGQUEUEALLOC); - retqueue = queue_create(dag->numNodes); // was MainDag... why? (ton) + retqueue = queue_create(dag->numNodes); /* was MainDag... why? (ton) */ node = dag->DagNode.first; while (node) { @@ -1621,8 +1621,8 @@ DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) time = 1; - node = dag_find_node(dag, ob); // could be done in loop above (ton) - if (node) { // can be null for newly added objects + node = dag_find_node(dag, ob); /* could be done in loop above (ton) */ + if (node) { /* can be null for newly added objects */ node->color = DAG_GRAY; time++; @@ -1643,9 +1643,9 @@ DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) push_stack(nqueue, itA->node); skip = 1; break; - } + } itA = itA->next; - } + } if (!skip) { node = pop_queue(nqueue); @@ -1673,7 +1673,7 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) while (itA != NULL) { if (itA->node->ob == ob2) { return itA->node->type; - } + } itA = itA->next; } return DAG_NO_RELATION; @@ -1701,7 +1701,7 @@ void graph_print_queue(DagNodeQueue *nqueue) queueElem = nqueue->first; while (queueElem) { fprintf(stderr, "** %s %i %i-%i ", ((ID *) queueElem->node->ob)->name, queueElem->node->color, queueElem->node->DFS_dvtm, queueElem->node->DFS_fntm); - queueElem = queueElem->next; + queueElem = queueElem->next; } fprintf(stderr, "\n"); } @@ -1721,7 +1721,7 @@ void graph_print_queue_dist(DagNodeQueue *nqueue) fputc('|', stderr); fputc('\n', stderr); count = 0; - queueElem = queueElem->next; + queueElem = queueElem->next; } fprintf(stderr, "\n"); } @@ -1859,14 +1859,14 @@ void DAG_scene_sort(Main *bmain, Scene *sce) push_stack(nqueue, itA->node); skip = 1; break; - } + } itA = itA->next; - } + } if (!skip) { if (node) { node = pop_queue(nqueue); - if (node->ob == sce) // we are done + if (node->ob == sce) /* we are done */ break; node->color = DAG_BLACK; @@ -1878,7 +1878,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) BLI_remlink(&sce->base, base); BLI_addhead(&tempbase, base); } - } + } } } @@ -2023,7 +2023,7 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) for (itA = node->child; itA; itA = itA->next) { if (itA->node->type == ID_OB) { if (itA->node->lasttime != curtime) { - itA->lay = flush_layer_node(sce, itA->node, curtime); // lay is only set once for each relation + itA->lay = flush_layer_node(sce, itA->node, curtime); /* lay is only set once for each relation */ } else itA->lay = itA->node->lay; @@ -2071,12 +2071,12 @@ static void dag_scene_flush_layers(Scene *sce, int lay) Base *base; int lasttime; - firstnode = sce->theDag->DagNode.first; // always scene node + firstnode = sce->theDag->DagNode.first; /* always scene node */ for (itA = firstnode->child; itA; itA = itA->next) itA->lay = 0; - sce->theDag->time++; // so we know which nodes were accessed + sce->theDag->time++; /* so we know which nodes were accessed */ lasttime = sce->theDag->time; /* update layer flags in nodes */ @@ -2148,13 +2148,13 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho DAG_scene_sort(bmain, sce); } - firstnode = sce->theDag->DagNode.first; // always scene node + firstnode = sce->theDag->DagNode.first; /* always scene node */ /* first we flush the layer flags */ dag_scene_flush_layers(sce, lay); /* then we use the relationships + layer info to flush update events */ - sce->theDag->time++; // so we know which nodes were accessed + sce->theDag->time++; /* so we know which nodes were accessed */ lasttime = sce->theDag->time; for (itA = firstnode->child; itA; itA = itA->next) if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) @@ -2162,7 +2162,7 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho /* if update is not due to time change, do pointcache clears */ if (!time) { - sce->theDag->time++; // so we know which nodes were accessed + sce->theDag->time++; /* so we know which nodes were accessed */ lasttime = sce->theDag->time; for (itA = firstnode->child; itA; itA = itA->next) { if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) { @@ -2380,7 +2380,7 @@ static void dag_object_time_update_flags(Object *ob) } } } - } + } if (ob->recalc & OB_RECALC_OB) lib_id_recalc_tag(G.main, &ob->id); @@ -2930,9 +2930,9 @@ void DAG_pose_sort(Object *ob) int skip = 0; dag = dag_init(); - ugly_hack_sorry = 0; // no ID structs + ugly_hack_sorry = 0; /* no ID structs */ - rootnode = dag_add_node(dag, NULL); // node->ob becomes NULL + rootnode = dag_add_node(dag, NULL); /* node->ob becomes NULL */ /* we add the hierarchy and the constraints */ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { @@ -2977,7 +2977,7 @@ void DAG_pose_sort(Object *ob) dag_add_relation(dag, node2, node3, 0, "IK Constraint"); segcount++; - if (segcount == data->rootbone || segcount > 255) break; // 255 is weak + if (segcount == data->rootbone || segcount > 255) break; /* 255 is weak */ parchan = parchan->parent; } } @@ -3020,21 +3020,21 @@ void DAG_pose_sort(Object *ob) push_stack(nqueue, itA->node); skip = 1; break; - } + } itA = itA->next; - } + } if (!skip) { if (node) { node = pop_queue(nqueue); - if (node->ob == NULL) // we are done + if (node->ob == NULL) /* we are done */ break; node->color = DAG_BLACK; /* put node in new list */ BLI_remlink(&pose->chanbase, node->ob); BLI_addhead(&tempbase, node->ob); - } + } } } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 10c9f30f5ee..e13d05d0a2f 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -1386,8 +1386,8 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba ListBase top_capbase = {NULL, NULL}; for (dlb = dlbev.first; dlb; dlb = dlb->next) { - const float bevfac1 = minf(cu->bevfac1, cu->bevfac2); - const float bevfac2 = maxf(cu->bevfac1, cu->bevfac2); + const float bevfac1 = min_ff(cu->bevfac1, cu->bevfac2); + const float bevfac2 = max_ff(cu->bevfac1, cu->bevfac2); float firstblend = 0.0f, lastblend = 0.0f; int i, start, steps; diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index d55848514cc..f34a0150c79 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -32,6 +32,8 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "DNA_anim_types.h" #include "DNA_armature_types.h" #include "DNA_constraint_types.h" @@ -569,7 +571,7 @@ static void scene_setSubframe(Scene *scene, float subframe) static int surface_getBrushFlags(DynamicPaintSurface *surface, Scene *scene) { Base *base = NULL; - GroupObject *go = NULL; + GroupObject *go = NULL; Object *brushObj = NULL; ModifierData *md = NULL; @@ -848,7 +850,7 @@ static void surfaceGenerateGrid(struct DynamicPaintSurface *surface) grid->s_num = MEM_reallocN(grid->s_num, sizeof(int) * grid_cells); if (error || !grid->s_num) { - setError(surface->canvas, "Not enough free memory."); + setError(surface->canvas, N_("Not enough free memory")); freeGrid(sData); } } @@ -1235,7 +1237,7 @@ static void dynamicPaint_allocateSurfaceType(DynamicPaintSurface *surface) break; } - if (sData->type_data == NULL) setError(surface->canvas, "Not enough free memory!"); + if (sData->type_data == NULL) setError(surface->canvas, N_("Not enough free memory")); } static int surface_usesAdjDistance(DynamicPaintSurface *surface) @@ -1292,7 +1294,7 @@ static void dynamicPaint_initAdjacencyData(DynamicPaintSurface *surface, int for if (!ad->n_index || !ad->n_num || !ad->n_target || !temp_data) { dynamicPaint_freeAdjData(sData); if (temp_data) MEM_freeN(temp_data); - setError(surface->canvas, "Not enough free memory."); + setError(surface->canvas, N_("Not enough free memory")); return; } @@ -1762,10 +1764,10 @@ static DerivedMesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, } /* apply weights into a vertex group, if doesnt exists add a new layer */ - if (defgrp_index >= 0 && !dvert && (surface->output_name[0] != '\0')) + if (defgrp_index != -1 && !dvert && (surface->output_name[0] != '\0')) dvert = CustomData_add_layer_named(&result->vertData, CD_MDEFORMVERT, CD_CALLOC, NULL, sData->total_points, surface->output_name); - if (defgrp_index >= 0 && dvert) { + if (defgrp_index != -1 && dvert) { int i; for (i = 0; i < sData->total_points; i++) { MDeformVert *dv = &dvert[i]; @@ -2165,8 +2167,10 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) int *final_index; int aa_samples; - if (!dm) return setError(canvas, "Canvas mesh not updated."); - if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) return setError(canvas, "Can't bake non-\"image sequence\" formats."); + if (!dm) + return setError(canvas, N_("Canvas mesh not updated")); + if (surface->format != MOD_DPAINT_SURFACE_F_IMAGESEQ) + return setError(canvas, N_("Cannot bake non-'image sequence' formats")); numOfFaces = dm->getNumTessFaces(dm); mface = dm->getTessFaceArray(dm); @@ -2176,8 +2180,10 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) tface = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, uvname); /* Check for validity */ - if (!tface) return setError(canvas, "No UV data on canvas."); - if (surface->image_resolution < 16 || surface->image_resolution > 8192) return setError(canvas, "Invalid resolution."); + if (!tface) + return setError(canvas, N_("No UV data on canvas")); + if (surface->image_resolution < 16 || surface->image_resolution > 8192) + return setError(canvas, N_("Invalid resolution")); w = h = surface->image_resolution; @@ -2189,7 +2195,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) /* Init data struct */ if (surface->data) dynamicPaint_freeSurfaceData(surface); sData = surface->data = MEM_callocN(sizeof(PaintSurfaceData), "PaintSurfaceData"); - if (!surface->data) return setError(canvas, "Not enough free memory."); + if (!surface->data) + return setError(canvas, N_("Not enough free memory")); aa_samples = (surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1; tempPoints = (struct PaintUVPoint *) MEM_callocN(w * h * sizeof(struct PaintUVPoint), "Temp PaintUVPoint"); @@ -2547,7 +2554,8 @@ int dynamicPaint_createUVSurface(DynamicPaintSurface *surface) } } } - if (error == 1) setError(canvas, "Not enough free memory."); + if (error == 1) + setError(canvas, N_("Not enough free memory")); if (faceBB) MEM_freeN(faceBB); if (tempPoints) MEM_freeN(tempPoints); @@ -2598,7 +2606,10 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam int format = (surface->image_fileformat & MOD_DPAINT_IMGFORMAT_OPENEXR) ? R_IMF_IMTYPE_OPENEXR : R_IMF_IMTYPE_PNG; char output_file[FILE_MAX]; - if (!sData->type_data) { setError(surface->canvas, "Image save failed: Invalid surface."); return; } + if (!sData->type_data) { + setError(surface->canvas, N_("Image save failed: invalid surface")); + return; + } /* if selected format is openexr, but current build doesnt support one */ #ifndef WITH_OPENEXR if (format == R_IMF_IMTYPE_OPENEXR) format = R_IMF_IMTYPE_PNG; @@ -2612,7 +2623,10 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, char *filenam /* Init image buffer */ ibuf = IMB_allocImBuf(surface->image_resolution, surface->image_resolution, 32, IB_rectfloat); - if (ibuf == NULL) { setError(surface->canvas, "Image save failed: Not enough free memory."); return; } + if (ibuf == NULL) { + setError(surface->canvas, N_("Image save failed: not enough free memory")); + return; + } #pragma omp parallel for schedule(static) for (index = 0; index < sData->total_points; index++) { @@ -4649,7 +4663,7 @@ static int dynamicPaint_generateBakeData(DynamicPaintSurface *surface, Scene *sc if (bData->realCoord) MEM_freeN(bData->realCoord); if (canvas_verts) MEM_freeN(canvas_verts); - return setError(surface->canvas, "Not enough free memory."); + return setError(surface->canvas, N_("Not enough free memory")); } new_bdata = 1; @@ -4811,7 +4825,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su */ { Base *base = NULL; - GroupObject *go = NULL; + GroupObject *go = NULL; Object *brushObj = NULL; ModifierData *md = NULL; @@ -4878,7 +4892,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su /* Apply brush on the surface depending on it's collision type */ /* Particle brush: */ if (brush->collision == MOD_DPAINT_COL_PSYS) { - if (brush->psys && brush->psys->part && brush->psys->part->type == PART_EMITTER && + if (brush->psys && brush->psys->part && ELEM(brush->psys->part->type, PART_EMITTER, PART_FLUID) && psys_check_enabled(brushObj, brush->psys)) { @@ -4934,7 +4948,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su /* Allocate memory for surface previous points to read unchanged values from */ prevPoint = MEM_mallocN(sData->total_points * sizeof(struct PaintPoint), "PaintSurfaceDataCopy"); if (!prevPoint) - return setError(canvas, "Not enough free memory."); + return setError(canvas, N_("Not enough free memory")); /* Prepare effects and get number of required steps */ steps = dynamicPaint_prepareEffectStep(surface, scene, ob, &force, timescale); diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 7c0b43c24df..1f6db19ac27 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -166,7 +166,7 @@ void free_partdeflect(PartDeflect *pd) pd->tex->id.us--; if (pd->rng) - rng_free(pd->rng); + BLI_rng_free(pd->rng); MEM_freeN(pd); } @@ -175,9 +175,9 @@ static void precalculate_effector(EffectorCache *eff) { unsigned int cfra = (unsigned int)(eff->scene->r.cfra >= 0 ? eff->scene->r.cfra : -eff->scene->r.cfra); if (!eff->pd->rng) - eff->pd->rng = rng_new(eff->pd->seed + cfra); + eff->pd->rng = BLI_rng_new(eff->pd->seed + cfra); else - rng_srandom(eff->pd->rng, eff->pd->seed + cfra); + BLI_rng_srandom(eff->pd->rng, eff->pd->seed + cfra); if (eff->pd->forcefield == PFIELD_GUIDE && eff->ob->type==OB_CURVE) { Curve *cu= eff->ob->data; @@ -205,7 +205,7 @@ static void precalculate_effector(EffectorCache *eff) float old_vel[3]; BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra - 1.0f); - copy_v3_v3(old_vel, eff->ob->obmat[3]); + copy_v3_v3(old_vel, eff->ob->obmat[3]); BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra); sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel); } @@ -455,8 +455,8 @@ static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, Effect // noise function for wind e.g. static float wind_func(struct RNG *rng, float strength) { - int random = (rng_getInt(rng)+1) % 128; // max 2357 - float force = rng_getFloat(rng) + 1.0f; + int random = (BLI_rng_get_int(rng)+1) % 128; // max 2357 + float force = BLI_rng_get_float(rng) + 1.0f; float ret; float sign = 0; @@ -718,8 +718,8 @@ static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoin if (eff->pd->forcefield == PFIELD_CHARGE) { /* Only the charge of the effected particle is used for - * interaction, not fall-offs. If the fall-offs aren't the - * same this will be unphysical, but for animation this + * interaction, not fall-offs. If the fall-offs aren't the + * same this will be unphysical, but for animation this * could be the wanted behavior. If you want physical * correctness the fall-off should be spherical 2.0 anyways. */ @@ -828,7 +828,7 @@ static void do_physical_effector(EffectorCache *eff, EffectorData *efd, Effected { PartDeflect *pd = eff->pd; RNG *rng = pd->rng; - float force[3]={0, 0, 0}; + float force[3] = {0, 0, 0}; float temp[3]; float fac; float strength = pd->f_strength; @@ -1020,7 +1020,7 @@ void pdDoEffectors(ListBase *effectors, ListBase *colliders, EffectorWeights *we do_texture_effector(eff, &efd, point, force); } else { - float temp1[3]={0, 0, 0}, temp2[3]; + float temp1[3] = {0, 0, 0}, temp2[3]; copy_v3_v3(temp1, force); do_physical_effector(eff, &efd, point, force); diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 2dbc63e6944..ec61311d89e 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -504,14 +504,14 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo xmaxv = MAX3(xmaxv, bezt_last->vec[1][0], bezt_last->vec[2][0]); } else { - xminv = minf(xminv, bezt_first->vec[1][0]); - xmaxv = maxf(xmaxv, bezt_last->vec[1][0]); + xminv = min_ff(xminv, bezt_first->vec[1][0]); + xmaxv = max_ff(xmaxv, bezt_last->vec[1][0]); } } } /* only loop over keyframes to find extents for values if needed */ - if (ymin || ymax) { + if (ymin || ymax) { BezTriple *bezt; for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) { @@ -521,8 +521,8 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo ymaxv = MAX4(ymaxv, bezt->vec[1][1], bezt->vec[0][1], bezt->vec[2][1]); } else { - yminv = minf(yminv, bezt->vec[1][1]); - ymaxv = maxf(ymaxv, bezt->vec[1][1]); + yminv = min_ff(yminv, bezt->vec[1][1]); + ymaxv = max_ff(ymaxv, bezt->vec[1][1]); } foundvert = TRUE; @@ -533,8 +533,8 @@ short calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, flo else if (fcu->fpt) { /* frame range can be directly calculated from end verts */ if (xmin || xmax) { - xminv = minf(xminv, fcu->fpt[0].vec[0]); - xmaxv = maxf(xmaxv, fcu->fpt[fcu->totvert - 1].vec[0]); + xminv = min_ff(xminv, fcu->fpt[0].vec[0]); + xmaxv = max_ff(xmaxv, fcu->fpt[fcu->totvert - 1].vec[0]); } /* only loop over keyframes to find extents for values if needed */ @@ -591,15 +591,15 @@ void calc_fcurve_range(FCurve *fcu, float *start, float *end, if (bezt_first) { BLI_assert(bezt_last != NULL); - min = minf(min, bezt_first->vec[1][0]); - max = maxf(max, bezt_last->vec[1][0]); + min = min_ff(min, bezt_first->vec[1][0]); + max = max_ff(max, bezt_last->vec[1][0]); foundvert = TRUE; } } else if (fcu->fpt) { - min = minf(min, fcu->fpt[0].vec[0]); - max = maxf(max, fcu->fpt[fcu->totvert - 1].vec[0]); + min = min_ff(min, fcu->fpt[0].vec[0]); + max = max_ff(max, fcu->fpt[fcu->totvert - 1].vec[0]); foundvert = TRUE; } @@ -1039,7 +1039,7 @@ static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar) if (RNA_path_resolve_full(&id_ptr, dtar->rna_path, &ptr, &prop, &index)) { if (RNA_property_array_check(prop)) { /* array */ - if (index < RNA_property_array_length(&ptr, prop)) { + if (index < RNA_property_array_length(&ptr, prop)) { switch (RNA_property_type(prop)) { case PROP_BOOLEAN: value = (float)RNA_property_boolean_get_index(&ptr, prop, index); @@ -1143,7 +1143,7 @@ static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar) /* stop here... */ return 0.0f; - } + } /* use the final posed locations */ mat4_to_quat(q1, pchan->pose_mat); @@ -1549,7 +1549,7 @@ ChannelDriver *fcurve_copy_driver(ChannelDriver *driver) for (dvar = ndriver->variables.first; dvar; dvar = dvar->next) { /* need to go over all targets so that we don't leave any dangling paths */ DRIVER_TARGETS_LOOPER(dvar) - { + { /* make a copy of target's rna path if available */ if (dtar->rna_path) dtar->rna_path = MEM_dupallocN(dtar->rna_path); @@ -1832,7 +1832,7 @@ static int findzero(float x, float q0, float q1, float q2, float q3, float *o) return 1; } - return 0; + return 0; } } @@ -1916,7 +1916,7 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime cvalue = prevbezt->vec[1][1]; } } - } + } else { /* Use the first handle (earlier) of first BezTriple to calculate the * gradient and thus the value of the curve at evaltime @@ -1968,7 +1968,7 @@ static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime cvalue = lastbezt->vec[1][1]; } } - } + } else { /* Use the gradient of the second handle (later) of last BezTriple to calculate the * gradient and thus the value of the curve at evaltime diff --git a/source/blender/blenkernel/intern/fluidsim.c b/source/blender/blenkernel/intern/fluidsim.c index 9be599ac66c..efc9869c5ca 100644 --- a/source/blender/blenkernel/intern/fluidsim.c +++ b/source/blender/blenkernel/intern/fluidsim.c @@ -41,7 +41,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_fluidsim.h" -#include "DNA_object_force.h" // for pointcache +#include "DNA_object_force.h" // for pointcache #include "DNA_object_types.h" #include "DNA_particle_types.h" #include "DNA_scene_types.h" // N_T @@ -66,14 +66,14 @@ //------------------------------------------------------------------------------- void initElbeemMesh(struct Scene *scene, struct Object *ob, - int *numVertices, float **vertices, - int *numTriangles, int **triangles, - int useGlobalCoords, int modifierIndex) + int *numVertices, float **vertices, + int *numTriangles, int **triangles, + int useGlobalCoords, int modifierIndex) { DerivedMesh *dm = NULL; MVert *mvert; MFace *mface; - int countTris=0, i, totvert, totface; + int countTris = 0, i, totvert, totface; float *verts; int *tris; @@ -87,35 +87,35 @@ void initElbeemMesh(struct Scene *scene, struct Object *ob, totface = dm->getNumTessFaces(dm); *numVertices = totvert; - verts = MEM_callocN(totvert*3*sizeof(float), "elbeemmesh_vertices"); - for (i=0; i<totvert; i++) { - copy_v3_v3(&verts[i*3], mvert[i].co); - if (useGlobalCoords) { mul_m4_v3(ob->obmat, &verts[i*3]); } + verts = MEM_callocN(totvert * 3 * sizeof(float), "elbeemmesh_vertices"); + for (i = 0; i < totvert; i++) { + copy_v3_v3(&verts[i * 3], mvert[i].co); + if (useGlobalCoords) { mul_m4_v3(ob->obmat, &verts[i * 3]); } } *vertices = verts; - for (i=0; i<totface; i++) { + for (i = 0; i < totface; i++) { countTris++; if (mface[i].v4) { countTris++; } } *numTriangles = countTris; - tris = MEM_callocN(countTris*3*sizeof(int), "elbeemmesh_triangles"); + tris = MEM_callocN(countTris * 3 * sizeof(int), "elbeemmesh_triangles"); countTris = 0; - for (i=0; i<totface; i++) { + for (i = 0; i < totface; i++) { int face[4]; face[0] = mface[i].v1; face[1] = mface[i].v2; face[2] = mface[i].v3; face[3] = mface[i].v4; - tris[countTris*3+0] = face[0]; - tris[countTris*3+1] = face[1]; - tris[countTris*3+2] = face[2]; + tris[countTris * 3 + 0] = face[0]; + tris[countTris * 3 + 1] = face[1]; + tris[countTris * 3 + 2] = face[2]; countTris++; if (face[3]) { - tris[countTris*3+0] = face[0]; - tris[countTris*3+1] = face[2]; - tris[countTris*3+2] = face[3]; + tris[countTris * 3 + 0] = face[0]; + tris[countTris * 3 + 1] = face[2]; + tris[countTris * 3 + 2] = face[3]; countTris++; } } diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 1e6eb77f666..2b393b4d90b 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -156,7 +156,7 @@ static void fcm_generator_verify(FModifier *fcm) /* free the old data */ MEM_freeN(data->coefficients); - } + } /* set the new data */ data->coefficients = nc; @@ -182,7 +182,7 @@ static void fcm_generator_verify(FModifier *fcm) /* free the old data */ MEM_freeN(data->coefficients); - } + } /* set the new data */ data->coefficients = nc; @@ -276,7 +276,7 @@ static FModifierTypeInfo FMI_GENERATOR = { /* Built-In Function Generator F-Curve Modifier --------------------------- */ /* This uses the general equation for equations: - * y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset + * y = amplitude * fn(phase_multiplier * x + phase_offset) + y_offset * * where amplitude, phase_multiplier/offset, y_offset are user-defined coefficients, * x is the evaluation 'time', and 'y' is the resultant value @@ -316,7 +316,7 @@ static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float * WARNING: must perform special argument validation hereto guard against crashes */ switch (data->type) { - /* simple ones */ + /* simple ones */ case FCM_GENERATOR_FN_SIN: /* sine wave */ fn = sin; break; @@ -1022,7 +1022,7 @@ FModifier *add_fmodifier(ListBase *modifiers, int type) fcm->data = MEM_callocN(fmi->size, fmi->structName); /* init custom settings if necessary */ - if (fmi->new_data) + if (fmi->new_data) fmi->new_data(fcm->data); /* return modifier for further editing */ @@ -1099,7 +1099,7 @@ int remove_fmodifier(ListBase *modifiers, FModifier *fcm) if (modifiers) { BLI_freelinkN(modifiers, fcm); return 1; - } + } else { /* XXX this case can probably be removed some day, as it shouldn't happen... */ printf("remove_fmodifier() - no modifier stack given\n"); diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 06b21fbbd29..d4634748c71 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -177,7 +177,7 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) } } - return vfont->data; + return vfont->data; } VFont *BKE_vfont_load(Main *bmain, const char *name) @@ -306,23 +306,23 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i nu2->bp = bp; nu2->bp[0].vec[0] = x1; - nu2->bp[0].vec[1] = y1; + nu2->bp[0].vec[1] = y1; nu2->bp[0].vec[2] = 0; nu2->bp[0].vec[3] = 1.0f; nu2->bp[1].vec[0] = x2; nu2->bp[1].vec[1] = y1; - nu2->bp[1].vec[2] = 0; + nu2->bp[1].vec[2] = 0; nu2->bp[1].vec[3] = 1.0f; nu2->bp[2].vec[0] = x2; - nu2->bp[2].vec[1] = y2; + nu2->bp[2].vec[1] = y2; nu2->bp[2].vec[2] = 0; nu2->bp[2].vec[3] = 1.0f; nu2->bp[3].vec[0] = x1; nu2->bp[3].vec[1] = y2; - nu2->bp[3].vec[2] = 0; + nu2->bp[3].vec[2] = 0; nu2->bp[3].vec[3] = 1.0f; - BLI_addtail(&(cu->nurb), nu2); + BLI_addtail(&(cu->nurb), nu2); } @@ -545,7 +545,7 @@ struct CharTrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int /* The VFont Data can not be found */ if (!vfd) { if (mem) - MEM_freeN(mem); + MEM_freeN(mem); return NULL; } @@ -671,7 +671,7 @@ makebreak: yof -= linedist; - maxlen = maxf(maxlen, (xof - tb->x / cu->fsize)); + maxlen = max_ff(maxlen, (xof - tb->x / cu->fsize)); linedata[lnr] = xof - tb->x / cu->fsize; linedata2[lnr] = cnr; linedata3[lnr] = tb->w / cu->fsize; @@ -731,7 +731,7 @@ makebreak: if (ascii == 32) { wsfac = cu->wordspace; wsnr++; - } + } else { wsfac = 1.0f; } @@ -754,7 +754,7 @@ makebreak: for (i = 0; i <= slen; i++, tmp++, ct++) { ascii = *tmp; if (ascii == '\n' || ascii == '\r' || ct->dobreak) cu->lines++; - } + } /* linedata is now: width of line * linedata2 is now: number of characters @@ -792,7 +792,7 @@ makebreak: // } ct++; } - } + } else if ((cu->spacemode == CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) { float curofs = 0.0f; for (i = 0; i <= slen; i++) { diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 76b00ffdb1c..a7d0152a799 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -517,7 +517,7 @@ void gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl) if (ELEM(NULL, gpd, gpl)) return; - /* free layer */ + /* free layer */ free_gpencil_frames(gpl); BLI_freelinkN(&gpd->layers, gpl); } diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 3392f6f109b..d3545cd2720 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -99,7 +99,7 @@ void BKE_group_unlink(Group *group) base->object->flag &= ~OB_FROMGROUP; base->flag &= ~OB_FROMGROUP; } - } + } for (srl = sce->r.layers.first; srl; srl = srl->next) { if (srl->light_override == group) diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 9a1ea15da97..ef751ce3493 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -1063,6 +1063,7 @@ char BKE_imtype_valid_channels(const char imtype) case R_IMF_IMTYPE_DDS: case R_IMF_IMTYPE_JP2: case R_IMF_IMTYPE_QUICKTIME: + case R_IMF_IMTYPE_DPX: chan_flag |= IMA_CHAN_FLAG_ALPHA; } @@ -1091,10 +1092,11 @@ char BKE_imtype_valid_depths(const char imtype) return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32; case R_IMF_IMTYPE_MULTILAYER: return R_IMF_CHAN_DEPTH_32; - /* eeh, cineone does some strange 10bits per channel */ + /* eeh, cineon does some strange 10bits per channel */ case R_IMF_IMTYPE_DPX: + return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_10 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16; case R_IMF_IMTYPE_CINEON: - return R_IMF_CHAN_DEPTH_12; + return R_IMF_CHAN_DEPTH_10; case R_IMF_IMTYPE_JP2: return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16; /* most formats are 8bit only */ @@ -1825,9 +1827,33 @@ int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) #ifdef WITH_CINEON else if (imtype == R_IMF_IMTYPE_CINEON) { ibuf->ftype = CINEON; + if (imf->cineon_flag & R_IMF_CINEON_FLAG_LOG) { + ibuf->ftype |= CINEON_LOG; + } + if (imf->depth == R_IMF_CHAN_DEPTH_16) { + ibuf->ftype |= CINEON_16BIT; + } + else if (imf->depth == R_IMF_CHAN_DEPTH_12) { + ibuf->ftype |= CINEON_12BIT; + } + else if (imf->depth == R_IMF_CHAN_DEPTH_10) { + ibuf->ftype |= CINEON_10BIT; + } } else if (imtype == R_IMF_IMTYPE_DPX) { ibuf->ftype = DPX; + if (imf->cineon_flag & R_IMF_CINEON_FLAG_LOG) { + ibuf->ftype |= CINEON_LOG; + } + if (imf->depth == R_IMF_CHAN_DEPTH_16) { + ibuf->ftype |= CINEON_16BIT; + } + else if (imf->depth == R_IMF_CHAN_DEPTH_12) { + ibuf->ftype |= CINEON_12BIT; + } + else if (imf->depth == R_IMF_CHAN_DEPTH_10) { + ibuf->ftype |= CINEON_10BIT; + } } #endif else if (imtype == R_IMF_IMTYPE_TARGA) { @@ -2120,6 +2146,15 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) } } break; + case IMA_SIGNAL_COLORMANAGE: + image_free_buffers(ima); + + ima->ok = 1; + + if (iuser) + iuser->ok = 1; + + break; } /* don't use notifiers because they are not 100% sure to succeeded diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 37572eebed6..468a88775c6 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -244,7 +244,7 @@ static void checker_board_color_tint(unsigned char *rect, float *rect_float, int } } - } + } } static void checker_board_grid_fill(unsigned char *rect, float *rect_float, int width, int height, float blend) diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 235d7858e17..39dcd73e0e5 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -590,7 +590,7 @@ DO_INLINE void mul_bfmatrix_lfvector( float (*to)[3], fmatrix3x3 *from, lfVector for (i = from[0].vcount; i < from[0].vcount+from[0].scount; i++) { muladd_fmatrix_fvector(to[from[i].c], from[i].m, fLongVector[from[i].r]); } - } + } #pragma omp section { for (i = 0; i < from[0].vcount+from[0].scount; i++) { @@ -623,7 +623,7 @@ DO_INLINE void add_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix /* process diagonal elements */ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { - add_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); + add_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); } } @@ -634,7 +634,7 @@ DO_INLINE void addadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat /* process diagonal elements */ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { - addadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); + addadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); } } @@ -645,7 +645,7 @@ DO_INLINE void subadd_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat /* process diagonal elements */ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { - subadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); + subadd_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); } } @@ -656,7 +656,7 @@ DO_INLINE void sub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix /* process diagonal elements */ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { - sub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); + sub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); } } @@ -667,7 +667,7 @@ DO_INLINE void sub_bfmatrix_Smatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmatrix3 /* process diagonal elements */ for (i = 0; i < matrix[0].vcount; i++) { - sub_fmatrix_fmatrix(to[matrix[i].c].m, from[matrix[i].c].m, matrix[i].m); + sub_fmatrix_fmatrix(to[matrix[i].c].m, from[matrix[i].c].m, matrix[i].m); } } @@ -678,7 +678,7 @@ DO_INLINE void addsub_bfmatrix_bfmatrix( fmatrix3x3 *to, fmatrix3x3 *from, fmat /* process diagonal elements */ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { - addsub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); + addsub_fmatrix_fmatrix(to[i].m, from[i].m, matrix[i].m); } } @@ -691,7 +691,7 @@ DO_INLINE void subadd_bfmatrixS_bfmatrixS( fmatrix3x3 *to, fmatrix3x3 *from, flo /* process diagonal elements */ for (i = 0; i < matrix[0].vcount+matrix[0].scount; i++) { - subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS); + subadd_fmatrixS_fmatrixS(to[i].m, from[i].m, aS, matrix[i].m, bS); } } @@ -711,7 +711,7 @@ static void update_matrixS(ClothVertex *verts, int numverts, fmatrix3x3 *S) int i = 0; /* Clear matrix from old vertex constraints */ - for(i = 0; i < S[0].vcount; i++) + for (i = 0; i < S[0].vcount; i++) S[i].c = S[i].r = 0; /* Set new vertex constraints */ @@ -749,7 +749,7 @@ int implicit_init(Object *UNUSED(ob), ClothModifierData *clmd) id = (Implicit_Data *)MEM_callocN(sizeof(Implicit_Data), "implicit vecmat"); cloth->implicit = id; - /* process diagonal elements */ + /* process diagonal elements */ id->A = create_bfmatrix(cloth->numverts, cloth->numsprings); id->dFdV = create_bfmatrix(cloth->numverts, cloth->numsprings); id->dFdX = create_bfmatrix(cloth->numverts, cloth->numsprings); @@ -876,8 +876,8 @@ DO_INLINE float fbstar_jacobi(float length, float L, float kb, float cb) return cb; } else { - return kb * fbderiv(length, L); - } + return kb * fbderiv(length, L); + } } DO_INLINE void filter(lfVector *V, fmatrix3x3 *S) @@ -1148,7 +1148,7 @@ DO_INLINE void dfdx_spring_type1(float to[3][3], float extent[3], float length, // dir is unit length direction, rest is spring's restlength, k is spring constant. // return (outerprod(dir, dir)*k + (I - outerprod(dir, dir))*(k - ((k*L)/length))); float temp[3][3]; - float temp1 = k*(1.0 - (L/length)); + float temp1 = k*(1.0 - (L/length)); mul_fvectorT_fvectorS(temp, extent, extent, 1.0 / dot); sub_fmatrix_fmatrix(to, I, temp); @@ -1218,7 +1218,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, float stretch_force[3] = {0, 0, 0}; float bending_force[3] = {0, 0, 0}; float damping_force[3] = {0, 0, 0}; - float nulldfdx[3][3]={ {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + float nulldfdx[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; float scaling = 0.0; @@ -1246,7 +1246,7 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, s->flags |= CSPRING_FLAG_DEACTIVATE; return; } - } + } */ mul_fvector_S(dir, extent, 1.0f/length); } @@ -1318,9 +1318,9 @@ DO_INLINE void cloth_calc_spring_force(ClothModifierData *clmd, ClothSpring *s, if (length < L) { s->flags |= CLOTH_SPRING_FLAG_NEEDED; - k = clmd->sim_parms->bending; + k = clmd->sim_parms->bending; - scaling = k + s->stiffness * ABS(clmd->sim_parms->max_bend-k); + scaling = k + s->stiffness * ABS(clmd->sim_parms->max_bend-k); cb = k = scaling / (20.0*(clmd->sim_parms->avg_spring_len + FLT_EPSILON)); mul_fvector_S(bending_force, dir, fbstar(length, L, k, cb)); @@ -1337,7 +1337,7 @@ DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSp if (!(s->type & CLOTH_SPRING_TYPE_BENDING)) { sub_fmatrix_fmatrix(dFdV[s->ij].m, dFdV[s->ij].m, s->dfdv); sub_fmatrix_fmatrix(dFdV[s->kl].m, dFdV[s->kl].m, s->dfdv); - add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv); + add_fmatrix_fmatrix(dFdV[s->matrix_index].m, dFdV[s->matrix_index].m, s->dfdv); } VECADD(lF[s->ij], lF[s->ij], s->f); @@ -1348,7 +1348,7 @@ DO_INLINE void cloth_apply_spring_force(ClothModifierData *UNUSED(clmd), ClothSp sub_fmatrix_fmatrix(dFdX[s->kl].m, dFdX[s->kl].m, s->dfdx); sub_fmatrix_fmatrix(dFdX[s->ij].m, dFdX[s->ij].m, s->dfdx); add_fmatrix_fmatrix(dFdX[s->matrix_index].m, dFdX[s->matrix_index].m, s->dfdx); - } + } } @@ -1356,15 +1356,15 @@ static void CalcFloat( float *v1, float *v2, float *v3, float *n) { float n1[3], n2[3]; - n1[0]= v1[0]-v2[0]; - n2[0]= v2[0]-v3[0]; - n1[1]= v1[1]-v2[1]; - n2[1]= v2[1]-v3[1]; - n1[2]= v1[2]-v2[2]; - n2[2]= v2[2]-v3[2]; - n[0]= n1[1]*n2[2]-n1[2]*n2[1]; - n[1]= n1[2]*n2[0]-n1[0]*n2[2]; - n[2]= n1[0]*n2[1]-n1[1]*n2[0]; + n1[0] = v1[0]-v2[0]; + n2[0] = v2[0]-v3[0]; + n1[1] = v1[1]-v2[1]; + n2[1] = v2[1]-v3[1]; + n1[2] = v1[2]-v2[2]; + n2[2] = v2[2]-v3[2]; + n[0] = n1[1]*n2[2]-n1[2]*n2[1]; + n[1] = n1[2]*n2[0]-n1[0]*n2[2]; + n[2] = n1[0]*n2[1]-n1[1]*n2[0]; } static void CalcFloat4( float *v1, float *v2, float *v3, float *v4, float *n) @@ -1372,17 +1372,17 @@ static void CalcFloat4( float *v1, float *v2, float *v3, float *v4, float *n) /* real cross! */ float n1[3], n2[3]; - n1[0]= v1[0]-v3[0]; - n1[1]= v1[1]-v3[1]; - n1[2]= v1[2]-v3[2]; + n1[0] = v1[0]-v3[0]; + n1[1] = v1[1]-v3[1]; + n1[2] = v1[2]-v3[2]; - n2[0]= v2[0]-v4[0]; - n2[1]= v2[1]-v4[1]; - n2[2]= v2[2]-v4[2]; + n2[0] = v2[0]-v4[0]; + n2[1] = v2[1]-v4[1]; + n2[2] = v2[2]-v4[2]; - n[0]= n1[1]*n2[2]-n1[2]*n2[1]; - n[1]= n1[2]*n2[0]-n1[0]*n2[2]; - n[2]= n1[0]*n2[1]-n1[1]*n2[0]; + n[0] = n1[1]*n2[2]-n1[2]*n2[1]; + n[1] = n1[2]*n2[0]-n1[0]*n2[2]; + n[2] = n1[0]*n2[1]-n1[1]*n2[0]; } static float calculateVertexWindForce(float wind[3], float vertexnormal[3]) @@ -1544,7 +1544,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec lfVector *winvec; EffectedPoint epoint; - tm2[0][0]= tm2[1][1]= tm2[2][2]= -spring_air; + tm2[0][0] = tm2[1][1] = tm2[2][2] = -spring_air; /* global acceleration (gravitation) */ if (clmd->scene->physics_settings.flag & PHYS_GLOBAL_GRAVITY) { @@ -1588,9 +1588,9 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec } for (i = 0; i < cloth->numfaces; i++) { - float trinormal[3]={0, 0, 0}; // normalized triangle normal - float triunnormal[3]={0, 0, 0}; // not-normalized-triangle normal - float tmp[3]={0, 0, 0}; + float trinormal[3] = {0, 0, 0}; // normalized triangle normal + float triunnormal[3] = {0, 0, 0}; // not-normalized-triangle normal + float tmp[3] = {0, 0, 0}; float factor = (mfaces[i].v4) ? 0.25 : 1.0 / 3.0; factor *= 0.02; @@ -1628,9 +1628,9 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec /* Hair has only edges */ if (cloth->numfaces == 0) { ClothSpring *spring; - float edgevec[3]={0, 0, 0}; //edge vector - float edgeunnormal[3]={0, 0, 0}; // not-normalized-edge normal - float tmp[3]={0, 0, 0}; + float edgevec[3] = {0, 0, 0}; //edge vector + float edgeunnormal[3] = {0, 0, 0}; // not-normalized-edge normal + float tmp[3] = {0, 0, 0}; float factor = 0.01; search = cloth->springs; @@ -1662,7 +1662,7 @@ static void cloth_calc_force(ClothModifierData *clmd, float UNUSED(frame), lfVec while (search) { // only handle active springs ClothSpring *spring = search->link; - if( !(spring->flags & CLOTH_SPRING_FLAG_DEACTIVATE)) + if (!(spring->flags & CLOTH_SPRING_FLAG_DEACTIVATE)) cloth_calc_spring_force(clmd, search->link, lF, lX, lV, dFdV, dFdX, time); search = search->next; @@ -1730,8 +1730,8 @@ static int UNUSED_FUNCTION(cloth_calc_helper_forces)(Object *UNUSED(ob), ClothMo for (i=0; i<cloth->numverts; i++, cv++) { copy_v3_v3(cos[i], cv->tx); - if (cv->goal == 1.0f || len_v3v3(initial_cos[i], cv->tx) != 0.0) { - masses[i] = 1e+10; + if (cv->goal == 1.0f || len_squared_v3v3(initial_cos[i], cv->tx) != 0.0) { + masses[i] = 1e+10; } else { masses[i] = cv->mass; @@ -1814,7 +1814,7 @@ int implicit_solver(Object *ob, float frame, ClothModifierData *clmd, ListBase * sub_v3_v3v3(id->V[i], verts[i].xconst, verts[i].xold); // mul_v3_fl(id->V[i], clmd->sim_parms->stepsPerFrame); } - } + } } while (step < tf) { @@ -1839,7 +1839,7 @@ int implicit_solver(Object *ob, float frame, ClothModifierData *clmd, ListBase * mul_fvector_S(tvect, tvect, step+dt); VECADD(tvect, tvect, verts[i].xold); copy_v3_v3(id->Xnew[i], tvect); - } + } } copy_v3_v3(verts[i].txold, id->X[i]); @@ -1897,7 +1897,7 @@ int implicit_solver(Object *ob, float frame, ClothModifierData *clmd, ListBase * cp_lfvector(id->V, id->Vnew, numverts); // calculate - cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step+dt, id->M); + cloth_calc_force(clmd, frame, id->F, id->X, id->V, id->dFdV, id->dFdX, effectors, step+dt, id->M); simulate_implicit_euler(id->Vnew, id->X, id->V, id->F, id->dFdV, id->dFdX, dt / 2.0f, id->A, id->B, id->dV, id->S, id->z, id->olddV, id->P, id->Pinv, id->M, id->bigI); } @@ -1946,6 +1946,6 @@ void implicit_set_positions(ClothModifierData *clmd) copy_v3_v3(id->V[i], verts[i].v); } if (G.debug_value > 0) - printf("implicit_set_positions\n"); + printf("implicit_set_positions\n"); } diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index b7e33f1cf71..3b08e3d2fa1 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -569,7 +569,7 @@ static const char *material_adrcodes_to_paths(int adrcode, int *array_index) return mtex_adrcodes_to_paths(adrcode, array_index); } - return NULL; + return NULL; } /* Camera Types */ @@ -727,7 +727,7 @@ static const char *world_adrcodes_to_paths(int adrcode, int *array_index) return mtex_adrcodes_to_paths(adrcode, array_index); } - return NULL; + return NULL; } /* Particle Types */ @@ -873,7 +873,7 @@ static char *get_rna_access(int blocktype, int adrcode, char actname[], char con propname = "eval_time"; break; - /* XXX problematic blocktypes */ + /* XXX problematic blocktypes */ case ID_SEQ: /* sequencer strip */ //SEQ_FAC1: switch (adrcode) { @@ -981,21 +981,21 @@ static char *get_rna_access(int blocktype, int adrcode, char actname[], char con static short adrcode_to_dtar_transchan(short adrcode) { switch (adrcode) { - case OB_LOC_X: + case OB_LOC_X: return DTAR_TRANSCHAN_LOCX; case OB_LOC_Y: return DTAR_TRANSCHAN_LOCY; case OB_LOC_Z: return DTAR_TRANSCHAN_LOCZ; - case OB_ROT_X: + case OB_ROT_X: return DTAR_TRANSCHAN_ROTX; case OB_ROT_Y: return DTAR_TRANSCHAN_ROTY; case OB_ROT_Z: return DTAR_TRANSCHAN_ROTZ; - case OB_SIZE_X: + case OB_SIZE_X: return DTAR_TRANSCHAN_SCALEX; case OB_SIZE_Y: return DTAR_TRANSCHAN_SCALEX; @@ -1645,7 +1645,7 @@ static void nlastrips_to_animdata(ID *id, ListBase *strips) /* by default, we now always extrapolate, while in the past this was optional */ if ((as->flag & ACTSTRIP_HOLDLASTFRAME) == 0) strip->extendmode = NLASTRIP_EXTEND_NOTHING; - } + } /* try to add this strip to the current NLA-Track (i.e. the 'last' one on the stack atm) */ if (BKE_nlatrack_add_strip(nlt, strip) == 0) { diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index b9bf2fd01a3..782d796b8a7 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -389,7 +389,7 @@ static int setkeys(float fac, ListBase *lb, KeyBlock *k[], float t[4], int cycl) if (k1->next == NULL) k[0] = k1; k1 = k1->next; } - /* k1= k[1]; */ /* UNUSED */ + /* k1 = k[1]; */ /* UNUSED */ t[0] = k[0]->pos; t[1] += dpos; t[2] = k[2]->pos + dpos; @@ -609,7 +609,7 @@ static void cp_key(const int start, int end, const int tot, char *poin, Key *key } } else k1 += start * key->elemsize; - } + } if (mode == KEY_MODE_BEZTRIPLE) { elemstr[0] = 1; @@ -691,8 +691,8 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const if (nu->bp) { step = nu->pntsu * nu->pntsv; - a1 = maxi(a, start); - a2 = mini(a + step, end); + a1 = max_ii(a, start); + a2 = min_ii(a + step, end); if (a1 < a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BPOINT); } @@ -700,8 +700,8 @@ static void cp_cu_key(Curve *cu, Key *key, KeyBlock *actkb, KeyBlock *kb, const step = 3 * nu->pntsu; /* exception because keys prefer to work with complete blocks */ - a1 = maxi(a, start); - a2 = mini(a + step, end); + a1 = max_ii(a, start); + a2 = min_ii(a + step, end); if (a1 < a2) cp_key(a1, a2, tot, out, key, actkb, kb, NULL, KEY_MODE_BEZTRIPLE); } @@ -1043,7 +1043,7 @@ static float *get_weights_array(Object *ob, char *vgroup) /* find the group (weak loop-in-loop) */ defgrp_index = defgroup_name_index(ob, vgroup); - if (defgrp_index >= 0) { + if (defgrp_index != -1) { float *weights; int i; @@ -1217,7 +1217,7 @@ static void do_curve_key(Scene *scene, Object *ob, Key *key, char *out, const in remain = step; } - count = mini(remain, estep); + count = min_ii(remain, estep); if (mode == KEY_MODE_BEZTRIPLE) { count += 3 - count % 3; } @@ -1268,7 +1268,7 @@ static void do_latt_key(Scene *scene, Object *ob, Key *key, char *out, const int do_key(a, a + 1, tot, out, key, actkb, k, t, KEY_MODE_DUMMY); else cp_key(a, a + 1, tot, out, key, actkb, k[2], NULL, KEY_MODE_DUMMY); - } + } } else { if (key->type == KEY_RELATIVE) { @@ -1584,7 +1584,7 @@ void BKE_key_convert_to_lattice(KeyBlock *kb, Lattice *lt) fp = kb->data; tot = lt->pntsu * lt->pntsv * lt->pntsw; - tot = mini(kb->totelem, tot); + tot = min_ii(kb->totelem, tot); for (a = 0; a < tot; a++, fp += 3, bp++) { copy_v3_v3(bp->vec, fp); @@ -1656,7 +1656,7 @@ void BKE_key_convert_to_curve(KeyBlock *kb, Curve *UNUSED(cu), ListBase *nurb) tot = BKE_nurbList_verts_count(nurb); - tot = mini(kb->totelem, tot); + tot = min_ii(kb->totelem, tot); while (nu && tot > 0) { @@ -1724,7 +1724,7 @@ void BKE_key_convert_to_mesh(KeyBlock *kb, Mesh *me) mvert = me->mvert; fp = kb->data; - tot = mini(kb->totelem, me->totvert); + tot = min_ii(kb->totelem, me->totvert); for (a = 0; a < tot; a++, fp += 3, mvert++) { copy_v3_v3(mvert->co, fp); diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 5382ea453eb..a15ca7cb5ce 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -348,7 +348,7 @@ void calc_latt_deform(Object *ob, float co[3], float weight) int ui, vi, wi, uu, vv, ww; /* vgroup influence */ - int defgroup_nr = -1; + int defgrp_index = -1; float co_prev[3], weight_blend = 0.0f; MDeformVert *dvert = BKE_lattice_deform_verts_get(ob); @@ -357,7 +357,7 @@ void calc_latt_deform(Object *ob, float co[3], float weight) if (lt->latticedata == NULL) return; if (lt->vgroup[0] && dvert) { - defgroup_nr = defgroup_name_index(ob, lt->vgroup); + defgrp_index = defgroup_name_index(ob, lt->vgroup); copy_v3_v3(co_prev, co); } @@ -431,8 +431,8 @@ void calc_latt_deform(Object *ob, float co[3], float weight) madd_v3_v3fl(co, <->latticedata[idx_u * 3], u); - if (defgroup_nr != -1) - weight_blend += (u * defvert_find_weight(dvert + idx_u, defgroup_nr)); + if (defgrp_index != -1) + weight_blend += (u * defvert_find_weight(dvert + idx_u, defgrp_index)); } } } @@ -440,7 +440,7 @@ void calc_latt_deform(Object *ob, float co[3], float weight) } } - if (defgroup_nr != -1) + if (defgrp_index != -1) interp_v3_v3v3(co, co_prev, co, weight_blend); } @@ -669,9 +669,9 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, if (vgroup && vgroup[0] && use_vgroups) { Mesh *me = target->data; - int index = defgroup_name_index(target, vgroup); + const int defgrp_index = defgroup_name_index(target, vgroup); - if (index != -1 && (me->dvert || dm)) { + if (defgrp_index != -1 && (me->dvert || dm)) { MDeformVert *dvert = me->dvert; float vec[3]; float weight; @@ -681,7 +681,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, dvert = me->dvert; for (a = 0; a < numVerts; a++, dvert++) { if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - weight = defvert_find_weight(dvert, index); + weight = defvert_find_weight(dvert, defgrp_index); if (weight > 0.0f) { mul_m4_v3(cd.curvespace, vertexCos[a]); @@ -699,7 +699,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, for (a = 0; a < numVerts; a++, dvert++) { if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - if (defvert_find_weight(dvert, index) > 0.0f) { + if (defvert_find_weight(dvert, defgrp_index) > 0.0f) { mul_m4_v3(cd.curvespace, vertexCos[a]); minmax_v3v3_v3(cd.dmin, cd.dmax, vertexCos[a]); } @@ -709,7 +709,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, for (a = 0; a < numVerts; a++, dvert++) { if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - weight = defvert_find_weight(dvert, index); + weight = defvert_find_weight(dvert, defgrp_index); if (weight > 0.0f) { /* already in 'cd.curvespace', prev for loop */ @@ -815,16 +815,16 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, if (vgroup && vgroup[0] && use_vgroups) { Mesh *me = target->data; - int index = defgroup_name_index(target, vgroup); + const int defgrp_index = defgroup_name_index(target, vgroup); float weight; - if (index >= 0 && (me->dvert || dm)) { + if (defgrp_index >= 0 && (me->dvert || dm)) { MDeformVert *dvert = me->dvert; for (a = 0; a < numVerts; a++, dvert++) { if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - weight = defvert_find_weight(dvert, index); + weight = defvert_find_weight(dvert, defgrp_index); if (weight > 0.0f) calc_latt_deform(laOb, vertexCos[a], weight * fac); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index f6e86bdbb5a..7a33d94b3dc 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -808,6 +808,18 @@ static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata } } +void BKE_libblock_free_data(ID *id) +{ + Main *bmain = G.main; /* should eventually be an arg */ + + if (id->properties) { + IDP_FreeProperty(id->properties); + MEM_freeN(id->properties); + } + + /* this ID may be a driver target! */ + BKE_animdata_main_cb(bmain, animdata_dtar_clear_cb, (void *)id); +} /* used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c */ void BKE_libblock_free(ListBase *lb, void *idv) @@ -919,15 +931,9 @@ void BKE_libblock_free(ListBase *lb, void *idv) break; } - if (id->properties) { - IDP_FreeProperty(id->properties); - MEM_freeN(id->properties); - } - BLI_remlink(lb, id); - /* this ID may be a driver target! */ - BKE_animdata_main_cb(bmain, animdata_dtar_clear_cb, (void *)id); + BKE_libblock_free_data(id); MEM_freeN(id); } @@ -1215,7 +1221,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8]; /* make sure input name is terminated properly */ - /* if ( strlen(name) > MAX_ID_NAME-3 ) name[MAX_ID_NAME-3]= 0; */ + /* if ( strlen(name) > MAX_ID_NAME-3 ) name[MAX_ID_NAME-3] = 0; */ /* removed since this is only ever called from one place - campbell */ while (1) { @@ -1562,7 +1568,7 @@ void rename_id(ID *id, const char *name) BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2); lb = which_libbase(G.main, GS(id->name) ); - new_id(lb, id, name); + new_id(lb, id, name); } void name_uiprefix_id(char *name, ID *id) diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index aa19350c456..da0fb895ec2 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -1955,5 +1955,5 @@ void BKE_mask_layer_shape_changed_remove(MaskLayer *masklay, int index, int coun int BKE_mask_get_duration(Mask *mask) { - return maxi(1, mask->efra - mask->sfra); + return max_ii(1, mask->efra - mask->sfra); } diff --git a/source/blender/blenkernel/intern/mask_evaluate.c b/source/blender/blenkernel/intern/mask_evaluate.c index 4a8601df0b8..e67df9c6419 100644 --- a/source/blender/blenkernel/intern/mask_evaluate.c +++ b/source/blender/blenkernel/intern/mask_evaluate.c @@ -69,7 +69,7 @@ unsigned int BKE_mask_spline_resolution(MaskSpline *spline, int width, int heigh unsigned int i, resol = 1; if (width != 0 && height != 0) { - max_segment = 1.0f / (float)maxi(width, height); + max_segment = 1.0f / (float)max_ii(width, height); } for (i = 0; i < spline->tot_point; i++) { @@ -131,7 +131,7 @@ unsigned int BKE_mask_spline_feather_resolution(MaskSpline *spline, int width, i if (u_diff > FLT_EPSILON) { float jump = fabsf(w_diff / u_diff); - max_jump = MAX2(max_jump, jump); + max_jump = max_ff(max_jump, jump); } prev_u = point->uw[j].u; @@ -418,7 +418,7 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, float (*fe max_delta = MAX2(max_delta_x, max_delta_y); - buckets_per_side = MIN2(512, 0.9f / max_delta); + buckets_per_side = min_ii(512, 0.9f / max_delta); if (buckets_per_side == 0) { /* happens when some segment fills the whole bounding box across some of dimension */ diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index 13ad9962aff..3561d5db9c0 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -428,7 +428,7 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size) /* width and height of each bucket */ const float bucket_size_x = (bucket_dim_x + FLT_EPSILON) / layer->buckets_x; const float bucket_size_y = (bucket_dim_y + FLT_EPSILON) / layer->buckets_y; - const float bucket_max_rad = (maxf(bucket_size_x, bucket_size_y) * M_SQRT2) + FLT_EPSILON; + const float bucket_max_rad = (max_ff(bucket_size_x, bucket_size_y) * M_SQRT2) + FLT_EPSILON; const float bucket_max_rad_squared = bucket_max_rad * bucket_max_rad; unsigned int *face = &layer->face_array[0][0]; @@ -451,10 +451,10 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size) const float *v2 = cos[face[1]]; const float *v3 = cos[face[2]]; - xmin = minf(v1[0], minf(v2[0], v3[0])); - xmax = maxf(v1[0], maxf(v2[0], v3[0])); - ymin = minf(v1[1], minf(v2[1], v3[1])); - ymax = maxf(v1[1], maxf(v2[1], v3[1])); + xmin = min_ff(v1[0], min_ff(v2[0], v3[0])); + xmax = max_ff(v1[0], max_ff(v2[0], v3[0])); + ymin = min_ff(v1[1], min_ff(v2[1], v3[1])); + ymax = max_ff(v1[1], max_ff(v2[1], v3[1])); } else { const float *v1 = cos[face[0]]; @@ -462,10 +462,10 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size) const float *v3 = cos[face[2]]; const float *v4 = cos[face[3]]; - xmin = minf(v1[0], minf(v2[0], minf(v3[0], v4[0]))); - xmax = maxf(v1[0], maxf(v2[0], maxf(v3[0], v4[0]))); - ymin = minf(v1[1], minf(v2[1], minf(v3[1], v4[1]))); - ymax = maxf(v1[1], maxf(v2[1], maxf(v3[1], v4[1]))); + xmin = min_ff(v1[0], min_ff(v2[0], min_ff(v3[0], v4[0]))); + xmax = max_ff(v1[0], max_ff(v2[0], max_ff(v3[0], v4[0]))); + ymin = min_ff(v1[1], min_ff(v2[1], min_ff(v3[1], v4[1]))); + ymax = max_ff(v1[1], max_ff(v2[1], max_ff(v3[1], v4[1]))); } @@ -503,7 +503,7 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size) BLI_assert(bucket_index < bucket_tot); /* check if the bucket intersects with the face */ - /* note: there is a tradeoff here since checking box/tri intersections isn't + /* note: there is a trade off here since checking box/tri intersections isn't * as optimal as it could be, but checking pixels against faces they will never intersect * with is likely the greater slowdown here - so check if the cell intersects the face */ if (layer_bucket_isect_test(layer, face_index, @@ -560,7 +560,7 @@ void BKE_maskrasterize_handle_init(MaskRasterHandle *mr_handle, struct Mask *mas const short do_feather) { const rctf default_bounds = {0.0f, 1.0f, 0.0f, 1.0f}; - const float pixel_size = 1.0f / MIN2(width, height); + const float pixel_size = 1.0f / (float)min_ii(width, height); const float asp_xy[2] = {(do_aspect_correct && width > height) ? (float)height / (float)width : 1.0f, (do_aspect_correct && width < height) ? (float)width / (float)height : 1.0f}; @@ -1335,10 +1335,10 @@ float BKE_maskrasterize_handle_sample(MaskRasterHandle *mr_handle, const float x value -= value_layer; break; case MASK_BLEND_LIGHTEN: - value = maxf(value, value_layer); + value = max_ff(value, value_layer); break; case MASK_BLEND_DARKEN: - value = minf(value, value_layer); + value = min_ff(value, value_layer); break; case MASK_BLEND_MUL: value *= value_layer; diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index ad28e3a6d79..445ea2d4b3b 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -216,7 +216,7 @@ Material *BKE_material_add(const char *name) init_material(ma); - return ma; + return ma; } /* XXX keep synced with next function */ @@ -905,7 +905,7 @@ short find_material_index(Object *ob, Material *ma) break; if (a < *totcolp) return a + 1; - return 0; + return 0; } int object_add_material_slot(Object *ob) @@ -971,7 +971,7 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) ma->ambr = ma->amb * amb[0]; ma->ambg = ma->amb * amb[1]; ma->ambb = ma->amb * amb[2]; - } + } /* will become or-ed result of all node modes */ ma->mode_l = ma->mode; ma->mode_l &= ~MA_SHLESS; @@ -983,14 +983,16 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) if (ma->nodetree && ma->use_nodes) ntreeShaderGetTexcoMode(ma->nodetree, r_mode, &ma->texco, &ma->mode_l); - /* local group override */ - if((ma->shade_flag & MA_GROUP_LOCAL) && ma->id.lib && ma->group && ma->group->id.lib) { - Group *group; + /* local group override */ + if ((ma->shade_flag & MA_GROUP_LOCAL) && ma->id.lib && ma->group && ma->group->id.lib) { + Group *group; - for(group= G.main->group.first; group; group= group->id.next) - if(!group->id.lib && strcmp(group->id.name, ma->group->id.name) == 0) - ma->group = group; - } + for (group = G.main->group.first; group; group = group->id.next) { + if (!group->id.lib && strcmp(group->id.name, ma->group->id.name) == 0) { + ma->group = group; + } + } + } } static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode, float *amb) @@ -1158,7 +1160,7 @@ void material_drivers_update(Scene *scene, Material *ma, float ctime) /* ****************** */ #if 0 /* UNUSED */ -static char colname_array[125][20]= { +static char colname_array[125][20] = { "Black", "DarkRed", "HalfRed", "Red", "Red", "DarkGreen", "DarkOlive", "Brown", "Chocolate", "OrangeRed", "HalfGreen", "GreenOlive", "DryOlive", "Goldenrod", "DarkOrange", @@ -1614,7 +1616,7 @@ static int encode_tfaceflag(MTFace *tf, int convertall) /* calculate the flag */ int flag = tf->mode; - /* options that change the material offline render */ + /* options that change the material offline render */ if (!convertall) { flag &= ~TF_OBCOL; } @@ -1638,7 +1640,7 @@ static int encode_tfaceflag(MTFace *tf, int convertall) /* set the material options based in the tface flag */ static void decode_tfaceflag(Material *ma, int flag, int convertall) { - int alphablend; + int alphablend; GameSettings *game = &ma->game; /* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */ @@ -1797,13 +1799,13 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag) * for now store the flag into the material and change light/tex/collision * store the flag as a negative number */ ma->game.flag = -flag; - id_us_min((ID *)ma); + id_us_min((ID *)ma); } else printf("Error: Unable to create Material \"%s\" for Mesh \"%s\".", idname + 2, me->id.name + 2); } /* set as converted, no need to go bad to this face */ - tf->mode |= TF_CONVERTED; + tf->mode |= TF_CONVERTED; return mat_nr; } @@ -1856,7 +1858,7 @@ static void convert_tfacematerial(Main *main, Material *ma) if (mat_new) { /* rename the material*/ strcpy(mat_new->id.name, idname); - id_us_min((ID *)mat_new); + id_us_min((ID *)mat_new); mat_nr = mesh_addmaterial(me, mat_new); decode_tfaceflag(mat_new, flag, 1); @@ -2044,7 +2046,7 @@ int do_version_tface(Main *main, int fileload) nowarning = 0; } else - convert_tfacematerial(main, ma); continue; + convert_tfacematerial(main, ma); continue; } /* no conflicts in this material - 90% of cases diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index c244317ccb7..26120b771bf 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -735,7 +735,7 @@ float *BKE_mesh_orco_verts_get(Object *ob) /* Get appropriate vertex coordinates */ vcos = MEM_callocN(sizeof(*vcos) * me->totvert, "orco mesh"); mvert = tme->mvert; - totvert = MIN2(tme->totvert, me->totvert); + totvert = min_ii(tme->totvert, me->totvert); for (a = 0; a < totvert; a++, mvert++) { copy_v3_v3(vcos[a], mvert->co); @@ -3175,6 +3175,32 @@ int BKE_mesh_center_bounds(Mesh *me, float cent[3]) return 0; } +int BKE_mesh_center_centroid(Mesh *me, float cent[3]) +{ + int i = me->totpoly; + MPoly *mpoly; + float poly_area; + float total_area = 0.0f; + float poly_cent[3]; + + zero_v3(cent); + + /* calculate a weighted average of polygon centroids */ + for (mpoly = me->mpoly; i--; mpoly++) { + BKE_mesh_calc_poly_center(mpoly, me->mloop + mpoly->loopstart, me->mvert, poly_cent); + poly_area = BKE_mesh_calc_poly_area(mpoly, me->mloop + mpoly->loopstart, me->mvert, NULL); + + madd_v3_v3fl(cent, poly_cent, poly_area); + total_area += poly_area; + } + /* otherwise we get NAN for 0 polys */ + if (me->totpoly) { + mul_v3_fl(cent, 1.0f / total_area); + } + + return (me->totpoly != 0); +} + void BKE_mesh_translate(Mesh *me, float offset[3], int do_keys) { int i = me->totvert; diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 0afd048e7f2..9c7cbc42bdd 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -55,6 +55,8 @@ #include "BLI_linklist.h" #include "BLI_string.h" +#include "BLF_translation.h" + #include "BKE_cloth.h" #include "BKE_key.h" #include "BKE_multires.h" @@ -259,12 +261,13 @@ int modifier_nonGeometrical(ModifierData *md) return (mti->type == eModifierTypeType_NonGeometrical); } -void modifier_setError(ModifierData *md, const char *format, ...) +void modifier_setError(ModifierData *md, const char *_format, ...) { char buffer[512]; va_list ap; + const char *format = TIP_(_format); - va_start(ap, format); + va_start(ap, _format); vsnprintf(buffer, sizeof(buffer), format, ap); va_end(ap); buffer[sizeof(buffer) - 1] = '\0'; diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 58348483c61..d34bb99ab98 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -1045,7 +1045,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm k = 0; /*current loop/mdisp index within the mloop array*/ - #pragma omp parallel for private(i) if (totloop*gridSize*gridSize >= CCG_OMP_LIMIT) + #pragma omp parallel for private(i) if (totloop * gridSize * gridSize >= CCG_OMP_LIMIT) for (i = 0; i < totpoly; ++i) { const int numVerts = mpoly[i].totloop; @@ -1325,7 +1325,7 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to) k = 0; /*current loop/mdisp index within the mloop array*/ - //#pragma omp parallel for private(i) if (dm->numLoopData*gridSize*gridSize >= CCG_OMP_LIMIT) + //#pragma omp parallel for private(i) if (dm->numLoopData * gridSize * gridSize >= CCG_OMP_LIMIT) for (i = 0; i < dm->numPolyData; ++i) { const int numVerts = mpoly[i].totloop; @@ -1630,7 +1630,7 @@ void multires_free(Multires *mr) } while (lvl) { - multires_free_level(lvl); + multires_free_level(lvl); lvl = lvl->next; } @@ -2200,7 +2200,7 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) dGridSize = multires_side_tot[high_mmd.totlvl]; dSkip = (dGridSize - 1) / (gridSize - 1); - #pragma omp parallel for private(i) if (me->totface*gridSize*gridSize*4 >= CCG_OMP_LIMIT) + #pragma omp parallel for private(i) if (me->totface * gridSize * gridSize * 4 >= CCG_OMP_LIMIT) for (i = 0; i < me->totpoly; ++i) { const int numVerts = mpoly[i].totloop; MDisps *mdisp = &mdisps[mpoly[i].loopstart]; diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 9590160c8f3..6f585198524 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -423,7 +423,7 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short return strip->actstart; } else { - /* - the 'fmod(..., actlength*scale)' is needed to get the repeats working + /* - the 'fmod(..., actlength * scale)' is needed to get the repeats working * - the '/ scale' is needed to ensure that scaling influences the timing within the repeat */ return strip->actend - fmodf(cframe - strip->start, actlength * scale) / scale; @@ -446,7 +446,7 @@ static float nlastrip_get_frame_actionclip(NlaStrip *strip, float cframe, short return strip->actend; } else { - /* - the 'fmod(..., actlength*scale)' is needed to get the repeats working + /* - the 'fmod(..., actlength * scale)' is needed to get the repeats working * - the '/ scale' is needed to ensure that scaling influences the timing within the repeat */ return strip->actstart + fmodf(cframe - strip->start, actlength * scale) / scale; @@ -496,7 +496,7 @@ float nlastrip_get_frame(NlaStrip *strip, float cframe, short mode) case NLASTRIP_TYPE_CLIP: /* action-clip (default) */ default: return nlastrip_get_frame_actionclip(strip, cframe, mode); - } + } } @@ -1162,7 +1162,7 @@ static short nlastrip_is_first(AnimData *adt, NlaStrip *strip) if (ns->start < strip->start) return 0; } - } + } /* should be first now */ return 1; @@ -1491,7 +1491,7 @@ void BKE_nla_action_pushdown(AnimData *adt) /* add a new NLA strip to the track, which references the active action */ strip = add_nlastrip_to_stack(adt, adt->action); - /* do other necessary work on strip */ + /* do other necessary work on strip */ if (strip) { /* clear reference to action now that we've pushed it onto the stack */ id_us_min(&adt->action->id); @@ -1545,7 +1545,7 @@ short BKE_nla_tweakmode_enter(AnimData *adt) /* now try to find active strip */ activeStrip = BKE_nlastrip_find_active(nlt); break; - } + } } /* There are situations where we may have multiple strips selected and we want to enter tweakmode on all @@ -1563,7 +1563,7 @@ short BKE_nla_tweakmode_enter(AnimData *adt) activeStrip = BKE_nlastrip_find_active(nlt); break; } - } + } } if ((activeTrack) && (activeStrip == NULL)) { /* no active strip in active or last selected track; compromise for first selected (assuming only single)... */ diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index 0ff6b7abbca..3112e8dc13d 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -147,6 +147,7 @@ static bNodeSocket *make_socket(bNodeTree *UNUSED(ntree), int in_out, const char sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF); sock->type = type; sock->storage = NULL; + sock->flag |= SOCK_COLLAPSED; sock->default_value = node_socket_make_default_value(type); node_socket_init_default_value(type, sock->default_value); @@ -346,6 +347,7 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node) { bNode *nnode = MEM_callocN(sizeof(bNode), "dupli node"); bNodeSocket *sock, *oldsock; + bNodeLink *link, *oldlink; *nnode = *node; /* can be called for nodes outside a node tree (e.g. clipboard) */ @@ -385,6 +387,15 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node) sock->cache = NULL; } + BLI_duplicatelist(&nnode->internal_links, &node->internal_links); + oldlink = node->internal_links.first; + for (link = nnode->internal_links.first; link; link = link->next, oldlink = oldlink->next) { + link->fromnode = nnode; + link->tonode = nnode; + link->fromsock = link->fromsock->new_sock; + link->tosock = link->tosock->new_sock; + } + /* don't increase node->id users, freenode doesn't decrement either */ if (node->typeinfo->copystoragefunc) @@ -392,7 +403,13 @@ bNode *nodeCopyNode(struct bNodeTree *ntree, struct bNode *node) node->new_node = nnode; nnode->new_node = NULL; - nnode->preview = NULL; + + /* only shader nodes get pleasant preview updating this way, compo uses own system */ + if (node->preview && ntree->type == NTREE_SHADER) { + nnode->preview = MEM_dupallocN(node->preview); + if (node->preview->rect) + nnode->preview->rect = MEM_dupallocN(node->preview->rect); + } if (ntree) ntree->update |= NTREE_UPDATE_NODES; @@ -523,15 +540,12 @@ void nodeRemSocketLinks(bNodeTree *ntree, bNodeSocket *sock) void nodeInternalRelink(bNodeTree *ntree, bNode *node) { bNodeLink *link, *link_next; - ListBase intlinks; - if (!node->typeinfo->internal_connect) + if (node->internal_links.first == NULL) return; - intlinks = node->typeinfo->internal_connect(ntree, node); - /* store link pointers in output sockets, for efficient lookup */ - for (link = intlinks.first; link; link = link->next) + for (link = node->internal_links.first; link; link = link->next) link->tosock->link = link; /* redirect downstream links */ @@ -565,8 +579,6 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node) if (link->tonode == node) nodeRemLink(ntree, link); } - - BLI_freelistN(&intlinks); } void nodeToView(bNode *node, float x, float y, float *rx, float *ry) @@ -713,7 +725,7 @@ static bNodeTree *ntreeCopyTree_internal(bNodeTree *ntree, const short do_id_use } node->new_node = NULL; - /* nnode= */ nodeCopyNode(newtree, node); /* sets node->new */ + /* nnode = */ nodeCopyNode(newtree, node); /* sets node->new */ /* make sure we don't copy new nodes again! */ if (node == last) @@ -818,7 +830,7 @@ void nodeFreePreview(bNode *node) MEM_freeN(node->preview->rect); MEM_freeN(node->preview); node->preview = NULL; - } + } } static void node_init_preview(bNode *node, int xsize, int ysize) @@ -861,7 +873,7 @@ void ntreeInitPreview(bNodeTree *ntree, int xsize, int ysize) node_init_preview(node, xsize, ysize); if (node->type == NODE_GROUP && (node->flag & NODE_GROUP_EDIT)) ntreeInitPreview((bNodeTree *)node->id, xsize, ysize); - } + } } static void nodeClearPreview(bNode *node) @@ -883,7 +895,7 @@ void ntreeClearPreview(bNodeTree *ntree) nodeClearPreview(node); if (node->type == NODE_GROUP && (node->flag & NODE_GROUP_EDIT)) ntreeClearPreview((bNodeTree *)node->id); - } + } } /* hack warning! this function is only used for shader previews, and @@ -988,6 +1000,8 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node) MEM_freeN(sock); } + BLI_freelistN(&node->internal_links); + nodeFreePreview(node); MEM_freeN(node); @@ -999,6 +1013,7 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node) /* do not free ntree itself here, BKE_libblock_free calls this function too */ void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user) { + bNodeTree *tntree; bNode *node, *next; bNodeSocket *sock; @@ -1055,6 +1070,14 @@ void ntreeFreeTree_ex(bNodeTree *ntree, const short do_id_user) for (sock = ntree->outputs.first; sock; sock = sock->next) node_socket_free_default_value(sock->type, sock->default_value); BLI_freelistN(&ntree->outputs); + + /* if ntree is not part of library, free the libblock data explicitly */ + for (tntree = G.main->nodetree.first; tntree; tntree = tntree->id.next) + if (tntree == ntree) + break; + if (tntree == NULL) { + BKE_libblock_free_data(&ntree->id); + } } /* same as ntreeFreeTree_ex but always manage users */ void ntreeFreeTree(bNodeTree *ntree) @@ -1816,6 +1839,8 @@ void ntreeUpdateTree(bNodeTree *ntree) ntreetype->update_node(ntree, node); else if (node->typeinfo->updatefunc) node->typeinfo->updatefunc(ntree, node); + + nodeUpdateInternalLinks(ntree, node); } } @@ -1853,6 +1878,9 @@ void nodeUpdate(bNodeTree *ntree, bNode *node) ntreetype->update_node(ntree, node); else if (node->typeinfo->updatefunc) node->typeinfo->updatefunc(ntree, node); + + nodeUpdateInternalLinks(ntree, node); + /* clear update flag */ node->update = 0; } @@ -1892,9 +1920,21 @@ int nodeUpdateID(bNodeTree *ntree, ID *id) } } + for (node = ntree->nodes.first; node; node = node->next) { + nodeUpdateInternalLinks(ntree, node); + } + return change; } +void nodeUpdateInternalLinks(bNodeTree *ntree, bNode *node) +{ + BLI_freelistN(&node->internal_links); + + if (node->typeinfo && node->typeinfo->update_internal_links) + node->typeinfo->update_internal_links(ntree, node); +} + /* ************* node type access ********** */ @@ -1967,7 +2007,7 @@ void node_type_base(bNodeTreeType *ttype, bNodeType *ntype, int type, const char /* Default muting stuff. */ if (ttype) - ntype->internal_connect = ttype->internal_connect; + ntype->update_internal_links = ttype->update_internal_links; /* default size values */ ntype->width = 140; @@ -2063,9 +2103,9 @@ void node_type_exec_new(struct bNodeType *ntype, ntype->newexecfunc = newexecfunc; } -void node_type_internal_connect(bNodeType *ntype, ListBase (*internal_connect)(bNodeTree *, bNode *)) +void node_type_internal_links(bNodeType *ntype, void (*update_internal_links)(bNodeTree *, bNode *)) { - ntype->internal_connect = internal_connect; + ntype->update_internal_links = update_internal_links; } void node_type_gpu(struct bNodeType *ntype, int (*gpufunc)(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out)) @@ -2198,6 +2238,7 @@ static void registerCompositNodes(bNodeTreeType *ttype) register_node_type_cmp_bokehimage(ttype); register_node_type_cmp_bokehblur(ttype); register_node_type_cmp_switch(ttype); + register_node_type_cmp_pixelate(ttype); register_node_type_cmp_mask(ttype); register_node_type_cmp_trackpos(ttype); diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index ff778a4b71b..549d4e2d126 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -302,11 +302,11 @@ void BKE_object_free(Object *ob) BKE_object_free_display(ob); - /* disconnect specific data */ + /* disconnect specific data, but not for lib data (might be indirect data, can get relinked) */ if (ob->data) { ID *id = ob->data; id->us--; - if (id->us == 0) { + if (id->us == 0 && id->lib==NULL) { switch (ob->type) { case OB_MESH: BKE_mesh_unlink((Mesh *)id); @@ -456,7 +456,7 @@ void BKE_object_unlink(Object *ob) if (pchan->custom == ob) pchan->custom = NULL; } - } + } else if (ELEM(OB_MBALL, ob->type, obt->type)) { if (BKE_mball_is_basis_for(obt, ob)) obt->recalc |= OB_RECALC_DATA; @@ -2581,9 +2581,7 @@ void BKE_object_handle_update(Scene *scene, Object *ob) if (ob->recalc & OB_RECALC_DATA) { ID *data_id = (ID *)ob->data; AnimData *adt = BKE_animdata_from_id(data_id); - float ctime = (float)scene->r.cfra; // XXX this is bad... - ListBase pidlist; - PTCacheID *pid; + float ctime = (float)scene->r.cfra; /* XXX this is bad... */ if (G.debug & G_DEBUG) printf("recalcdata %s\n", ob->id.name + 2); @@ -2706,26 +2704,8 @@ void BKE_object_handle_update(Scene *scene, Object *ob) psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated; } } - - /* check if quick cache is needed */ - BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - - for (pid = pidlist.first; pid; pid = pid->next) { - if ((pid->cache->flag & PTCACHE_BAKED) || - (pid->cache->flag & PTCACHE_QUICK_CACHE) == 0) - { - continue; - } - - if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID) == 0) { - scene->physics_settings.quick_cache_step = - scene->physics_settings.quick_cache_step ? - mini(scene->physics_settings.quick_cache_step, pid->cache->step) : - pid->cache->step; - } - } - - BLI_freelistN(&pidlist); + + /* quick cache removed */ } /* the no-group proxy case, we call update */ diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 4f3921936e8..7bc736d394e 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -475,7 +475,7 @@ void BKE_ocean_eval_ij(struct Ocean *oc, struct OceanResult *ocr, int i, int j) if (oc->_do_normals) { ocr->normal[0] = oc->_N_x[i * oc->_N + j]; - ocr->normal[1] = oc->_N_y /*oc->_N_y[i*oc->_N+j] (MEM01)*/; + ocr->normal[1] = oc->_N_y /* oc->_N_y[i * oc->_N + j] (MEM01) */; ocr->normal[2] = oc->_N_z[i * oc->_N + j]; normalize_v3(ocr->normal); diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index f16748bf20a..dec49f417ae 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -201,7 +201,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char file = BLI_open(name, O_BINARY | O_RDONLY, 0); if (file <= 0) { - BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name); + BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path '%s' not found", name); } else { filelen = BLI_file_descriptor_size(file); @@ -311,20 +311,20 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i file = BLI_open(name, O_BINARY + O_WRONLY + O_CREAT + O_TRUNC, 0666); if (file >= 0) { if (write(file, pf->data, pf->size) != pf->size) { - BKE_reportf(reports, RPT_ERROR, "Error writing file: %s", name); + BKE_reportf(reports, RPT_ERROR, "Error writing file '%s'", name); ret_value = RET_ERROR; } close(file); } else { - BKE_reportf(reports, RPT_ERROR, "Error creating file: %s", name); + BKE_reportf(reports, RPT_ERROR, "Error creating file '%s'", name); ret_value = RET_ERROR; } if (remove_tmp) { if (ret_value == RET_ERROR) { if (BLI_rename(tempname, name) != 0) { - BKE_reportf(reports, RPT_ERROR, "Error restoring temp file. Check files: '%s' '%s'", tempname, name); + BKE_reportf(reports, RPT_ERROR, "Error restoring temp file (check files '%s' '%s')", tempname, name); } } else { diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 60d3b7a8846..9e37cc95b8c 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -336,7 +336,7 @@ void psys_check_group_weights(ParticleSettings *part) BLI_addtail(&part->dupliweights, dw); } - go = go->next; + go = go->next; } dw = part->dupliweights.first; @@ -561,7 +561,7 @@ void psys_free(Object *ob, ParticleSystem *psys) ob->transflag &= ~OB_DUPLIPARTS; if (psys->part) { - psys->part->id.us--; + psys->part->id.us--; psys->part = NULL; } @@ -899,7 +899,7 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) elem->scalemax = sqrt(elem->scalemax); /* clamp scaling */ - scaleclamp = MIN2(elem->totchild, 10.0f); + scaleclamp = (float)min_ii(elem->totchild, 10); elem->scalemin = MIN2(scaleclamp, elem->scalemin); elem->scalemax = MIN2(scaleclamp, elem->scalemax); @@ -2464,7 +2464,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c totthread = 1; for (i = 0; i < totthread; i++) { - threads[i].rng_path = rng_new(seed); + threads[i].rng_path = BLI_rng_new(seed); threads[i].tot = totthread; } diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 154c8cca75d..19ef83d53cf 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -369,10 +369,10 @@ void psys_calc_dmcache(Object *ob, DerivedMesh *dm, ParticleSystem *psys) if (nodearray[*origindex]) { /* prepend */ node->next = nodearray[*origindex]; - nodearray[*origindex]= node; + nodearray[*origindex] = node; } else - nodearray[*origindex]= node; + nodearray[*origindex] = node; } } @@ -556,8 +556,7 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) else /* store number of intersections */ (pa+(int)(lambda*size[a])*a0mul)->hair_index++; } - - if (mface->v4) { + else if (mface->v4) { copy_v3_v3(v4, mvert[mface->v4].co); if (isect_axial_line_tri_v3(a, co1, co2, v4, v1, v3, &lambda)) { @@ -632,10 +631,10 @@ static void hammersley_create(float *out, int n, int seed, float amount) double p, t, offs[2]; int k, kk; - rng = rng_new(31415926 + n + seed); - offs[0]= rng_getDouble(rng) + (double)amount; - offs[1]= rng_getDouble(rng) + (double)amount; - rng_free(rng); + rng = BLI_rng_new(31415926 + n + seed); + offs[0] = BLI_rng_get_double(rng) + (double)amount; + offs[1] = BLI_rng_get_double(rng) + (double)amount; + BLI_rng_free(rng); for (k = 0; k < n; k++) { t = 0; @@ -643,8 +642,8 @@ static void hammersley_create(float *out, int n, int seed, float amount) if (kk & 1) /* kk mod 2 = 1 */ t += p; - out[2*k + 0]= fmod((double)k/(double)n + offs[0], 1.0); - out[2*k + 1]= fmod(t + offs[1], 1.0); + out[2*k + 0] = fmod((double)k/(double)n + offs[0], 1.0); + out[2*k + 1] = fmod(t + offs[1], 1.0); } } @@ -661,13 +660,13 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount) rad2= (float)(1.0f/((float)num)); rad3= (float)sqrt((float)num)/((float)num); - rng = rng_new(31415926 + num + seed2); + rng = BLI_rng_new(31415926 + num + seed2); x= 0; num2 = 2 * num; for (i=0; i<num2; i+=2) { - jit[i]= x + amount*rad1*(0.5f - rng_getFloat(rng)); - jit[i+1]= i/(2.0f*num) + amount*rad1*(0.5f - rng_getFloat(rng)); + jit[i] = x + amount*rad1*(0.5f - BLI_rng_get_float(rng)); + jit[i+1] = i/(2.0f*num) + amount*rad1*(0.5f - BLI_rng_get_float(rng)); jit[i]-= (float)floor(jit[i]); jit[i+1]-= (float)floor(jit[i+1]); @@ -684,7 +683,7 @@ static void init_mv_jit(float *jit, int num, int seed2, float amount) BLI_jitterate2(jit, jit2, num, rad2); } MEM_freeN(jit2); - rng_free(rng); + BLI_rng_free(rng); } static void psys_uv_to_w(float u, float v, int quad, float *w) @@ -698,21 +697,21 @@ static void psys_uv_to_w(float u, float v, int quad, float *w) u= 1.0f-u; } - vert[0][0]= 0.0f; vert[0][1]= 0.0f; vert[0][2]= 0.0f; - vert[1][0]= 1.0f; vert[1][1]= 0.0f; vert[1][2]= 0.0f; - vert[2][0]= 1.0f; vert[2][1]= 1.0f; vert[2][2]= 0.0f; + vert[0][0] = 0.0f; vert[0][1] = 0.0f; vert[0][2] = 0.0f; + vert[1][0] = 1.0f; vert[1][1] = 0.0f; vert[1][2] = 0.0f; + vert[2][0] = 1.0f; vert[2][1] = 1.0f; vert[2][2] = 0.0f; - co[0]= u; - co[1]= v; - co[2]= 0.0f; + co[0] = u; + co[1] = v; + co[2] = 0.0f; if (quad) { - vert[3][0]= 0.0f; vert[3][1]= 1.0f; vert[3][2]= 0.0f; + vert[3][0] = 0.0f; vert[3][1] = 1.0f; vert[3][2] = 0.0f; interp_weights_poly_v3( w,vert, 4, co); } else { interp_weights_poly_v3( w,vert, 3, co); - w[3]= 0.0f; + w[3] = 0.0f; } } @@ -804,8 +803,8 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch } break; case PART_DISTR_RAND: - randu= rng_getFloat(thread->rng); - randv= rng_getFloat(thread->rng); + randu= BLI_rng_get_float(thread->rng); + randv= BLI_rng_get_float(thread->rng); rng_skip_tot -= 2; psys_uv_to_w(randu, randv, mface->v4, pa->fuv); @@ -881,8 +880,8 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch mf= dm->getTessFaceData(dm, ctx->index[p], CD_MFACE); - randu= rng_getFloat(thread->rng); - randv= rng_getFloat(thread->rng); + randu= BLI_rng_get_float(thread->rng); + randv= BLI_rng_get_float(thread->rng); rng_skip_tot -= 2; psys_uv_to_w(randu, randv, mf->v4, cpa->fuv); @@ -934,7 +933,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch } if (rng_skip_tot > 0) /* should never be below zero */ - rng_skip(thread->rng, rng_skip_tot); + BLI_rng_skip(thread->rng, rng_skip_tot); } static void *distribute_threads_exec_cb(void *data) @@ -951,12 +950,12 @@ static void *distribute_threads_exec_cb(void *data) for (p=0; p<totpart; p++, cpa++) { if (thread->ctx->skip) /* simplification skip */ - rng_skip(thread->rng, PSYS_RND_DIST_SKIP * thread->ctx->skip[p]); + BLI_rng_skip(thread->rng, PSYS_RND_DIST_SKIP * thread->ctx->skip[p]); if ((p+thread->num) % thread->tot == 0) distribute_threads_exec(thread, NULL, cpa, p); else /* thread skip */ - rng_skip(thread->rng, PSYS_RND_DIST_SKIP); + BLI_rng_skip(thread->rng, PSYS_RND_DIST_SKIP); } } else { @@ -973,8 +972,8 @@ static void *distribute_threads_exec_cb(void *data) static int *COMPARE_ORIG_INDEX = NULL; static int distribute_compare_orig_index(const void *p1, const void *p2) { - int index1 = COMPARE_ORIG_INDEX[*(const int*)p1]; - int index2 = COMPARE_ORIG_INDEX[*(const int*)p2]; + int index1 = COMPARE_ORIG_INDEX[*(const int *)p1]; + int index2 = COMPARE_ORIG_INDEX[*(const int *)p2]; if (index1 < index2) return -1; @@ -1000,7 +999,7 @@ static void distribute_invalid(Scene *scene, ParticleSystem *psys, int from) if (psys->child && totchild) { for (p=0,cpa=psys->child; p<totchild; p++,cpa++) { - cpa->fuv[0]=cpa->fuv[1]=cpa->fuv[2]=cpa->fuv[3]= 0.0; + cpa->fuv[0]=cpa->fuv[1]=cpa->fuv[2]=cpa->fuv[3] = 0.0; cpa->foffset= 0.0f; cpa->parent=0; cpa->pa[0]=cpa->pa[1]=cpa->pa[2]=cpa->pa[3]=0; @@ -1011,7 +1010,7 @@ static void distribute_invalid(Scene *scene, ParticleSystem *psys, int from) else { PARTICLE_P; LOOP_PARTICLES { - pa->fuv[0]=pa->fuv[1]=pa->fuv[2]= pa->fuv[3]= 0.0; + pa->fuv[0] = pa->fuv[1] = pa->fuv[2] = pa->fuv[3] = 0.0; pa->foffset= 0.0f; pa->num= -1; } @@ -1113,7 +1112,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D if (from == PART_FROM_VERT) { MVert *mv= dm->getVertDataArray(dm, CD_MVERT); - float (*orcodata)[3]= dm->getVertDataArray(dm, CD_ORCO); + float (*orcodata)[3] = dm->getVertDataArray(dm, CD_ORCO); int totvert = dm->getNumVerts(dm); tree=BLI_kdtree_new(totvert); @@ -1245,9 +1244,9 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D inv_totweight = (totweight > 0.f ? 1.f/totweight : 0.f); /* Calculate cumulative weights */ - element_sum[0]= 0.0f; + element_sum[0] = 0.0f; for (i=0; i<totelem; i++) - element_sum[i+1]= element_sum[i] + element_weight[i] * inv_totweight; + element_sum[i+1] = element_sum[i] + element_weight[i] * inv_totweight; /* Finally assign elements to particles */ if ((part->flag&PART_TRAND) || (part->simplify_flag&PART_SIMPLIFY_ENABLE)) { @@ -1256,9 +1255,9 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D for (p=0; p<totpart; p++) { /* In theory element_sum[totelem] should be 1.0, but due to float errors this is not necessarily always true, so scale pos accordingly. */ pos= BLI_frand() * element_sum[totelem]; - particle_element[p]= distribute_binary_search(element_sum, totelem, pos); - particle_element[p]= MIN2(totelem-1, particle_element[p]); - jitter_offset[particle_element[p]]= pos; + particle_element[p] = distribute_binary_search(element_sum, totelem, pos); + particle_element[p] = MIN2(totelem-1, particle_element[p]); + jitter_offset[particle_element[p]] = pos; } } else { @@ -1272,13 +1271,13 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D while ((i < totelem) && (pos > element_sum[i+1])) i++; - particle_element[p]= MIN2(totelem-1, i); + particle_element[p] = MIN2(totelem-1, i); /* avoid zero weight face */ if (p == totpart-1 && element_weight[particle_element[p]] == 0.0f) - particle_element[p]= particle_element[p-1]; + particle_element[p] = particle_element[p-1]; - jitter_offset[particle_element[p]]= pos; + jitter_offset[particle_element[p]] = pos; } } @@ -1353,7 +1352,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D seed= 31415926 + ctx->sim.psys->seed; for (i=0; i<totthread; i++) { - threads[i].rng= rng_new(seed); + threads[i].rng= BLI_rng_new(seed); threads[i].tot= totthread; } @@ -1492,9 +1491,9 @@ void psys_threads_free(ParticleThread *threads) /* threads */ for (i=0; i<totthread; i++) { if (threads[i].rng) - rng_free(threads[i].rng); + BLI_rng_free(threads[i].rng); if (threads[i].rng_path) - rng_free(threads[i].rng_path); + BLI_rng_free(threads[i].rng_path); } MEM_freeN(ctx); @@ -1583,7 +1582,7 @@ static void get_angular_velocity_vector(short avemode, ParticleKey *state, float switch (avemode) { case PART_AVE_VELOCITY: copy_v3_v3(vec, state->vel); - break; + break; case PART_AVE_HORIZONTAL: { float zvec[3]; @@ -1622,9 +1621,9 @@ void psys_get_birth_coordinates(ParticleSimulationData *sim, ParticleData *pa, P ParticleSystem *psys = sim->psys; ParticleSettings *part; ParticleTexture ptex; - float fac, phasefac, nor[3]={0,0,0},loc[3],vel[3]={0.0,0.0,0.0},rot[4],q2[4]; - float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3]={0.0,0.0,0.0}; - float x_vec[3]={1.0,0.0,0.0}, utan[3]={0.0,1.0,0.0}, vtan[3]={0.0,0.0,1.0}, rot_vec[3]={0.0,0.0,0.0}; + float fac, phasefac, nor[3] = {0,0,0},loc[3],vel[3] = {0.0,0.0,0.0},rot[4],q2[4]; + float r_vel[3],r_ave[3],r_rot[4],vec[3],p_vel[3] = {0.0,0.0,0.0}; + float x_vec[3] = {1.0,0.0,0.0}, utan[3] = {0.0,1.0,0.0}, vtan[3] = {0.0,0.0,1.0}, rot_vec[3] = {0.0,0.0,0.0}; float q_phase[4]; int p = pa - psys->particles; part=psys->part; @@ -2537,7 +2536,7 @@ static void sph_force_cb(void *sphdata_v, ParticleKey *state, float *force, floa madd_v3_v3fl(force, vec, -(pressure + near_pressure*q)*q); /* Viscosity */ - if (visc > 0.f || stiff_visc > 0.f) { + if (visc > 0.f || stiff_visc > 0.f) { sub_v3_v3v3(dv, vel, state->vel); u = dot_v3v3(vec, dv); @@ -2736,7 +2735,7 @@ static void basic_integrate(ParticleSimulationData *sim, int p, float dfra, floa } static void basic_rotate(ParticleSettings *part, ParticleData *pa, float dfra, float timestep) { - float rotfac, rot1[4], rot2[4]={1.0,0.0,0.0,0.0}, dtime=dfra*timestep, extrotfac; + float rotfac, rot1[4], rot2[4] = {1.0,0.0,0.0,0.0}, dtime=dfra*timestep, extrotfac; if ((part->flag & PART_ROTATIONS) == 0) { unit_qt(pa->state.rot); @@ -3166,8 +3165,7 @@ void BKE_psys_collision_neartest_cb(void *userdata, int index, const BVHTreeRay if (col->hit == col->current && col->pce.index == index && col->pce.tot == 3) return; - do - { + do { collision = collision_sphere_to_tri(col, ray->radius, &pce, &t); if (col->pce.inside == 0) { collision += collision_sphere_to_edges(col, ray->radius, &pce, &t); @@ -4076,7 +4074,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) { FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(sim->ob, eModifierType_Fluidsim); - if ( fluidmd && fluidmd->fss) { + if ( fluidmd && fluidmd->fss) { FluidsimSettings *fss= fluidmd->fss; ParticleSettings *part = psys->part; ParticleData *pa=NULL; @@ -4121,7 +4119,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra)) int ptype=0; gzread(gzf, &ptype, sizeof( ptype )); - if (ptype&readMask) { + if (ptype & readMask) { activeParts++; gzread(gzf, &(pa->size), sizeof(float)); diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 84301972ddf..cec676162f3 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -249,9 +249,9 @@ static int ptcache_particle_write(int index, void *psys_v, void **data, int cfr if (data[BPHYS_DATA_INDEX] && (cfra < pa->time - step || cfra > pa->dietime + step)) return 0; - times[0]= pa->time; - times[1]= pa->dietime; - times[2]= pa->lifetime; + times[0] = pa->time; + times[1] = pa->dietime; + times[2] = pa->lifetime; PTCACHE_DATA_FROM(data, BPHYS_DATA_INDEX, &index); PTCACHE_DATA_FROM(data, BPHYS_DATA_LOCATION, pa->state.co); @@ -691,7 +691,7 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) sds->dx = ch_dx; VECCOPY(sds->res, ch_res); sds->total_cells = ch_res[0]*ch_res[1]*ch_res[2]; - if(sds->flags & MOD_SMOKE_HIGHRES) { + if (sds->flags & MOD_SMOKE_HIGHRES) { smoke_reallocate_highres_fluid(sds, ch_dx, ch_res, 1); } } @@ -705,25 +705,25 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) smoke_export(sds->fluid, &dt, &dx, &dens, &react, &flame, &fuel, &heat, &heatold, &vx, &vy, &vz, &r, &g, &b, &obstacles); ptcache_file_compressed_read(pf, (unsigned char *)sds->shadow, out_len); - ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len); if (cache_fields & SM_ACTIVE_HEAT) { - ptcache_file_compressed_read(pf, (unsigned char*)heat, out_len); - ptcache_file_compressed_read(pf, (unsigned char*)heatold, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)heat, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)heatold, out_len); } if (cache_fields & SM_ACTIVE_FIRE) { - ptcache_file_compressed_read(pf, (unsigned char*)flame, out_len); - ptcache_file_compressed_read(pf, (unsigned char*)fuel, out_len); - ptcache_file_compressed_read(pf, (unsigned char*)react, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)react, out_len); } if (cache_fields & SM_ACTIVE_COLORS) { - ptcache_file_compressed_read(pf, (unsigned char*)r, out_len); - ptcache_file_compressed_read(pf, (unsigned char*)g, out_len); - ptcache_file_compressed_read(pf, (unsigned char*)b, out_len); - } - ptcache_file_compressed_read(pf, (unsigned char*)vx, out_len); - ptcache_file_compressed_read(pf, (unsigned char*)vy, out_len); - ptcache_file_compressed_read(pf, (unsigned char*)vz, out_len); - ptcache_file_compressed_read(pf, (unsigned char*)obstacles, (unsigned int)res); + ptcache_file_compressed_read(pf, (unsigned char *)r, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)g, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)b, out_len); + } + ptcache_file_compressed_read(pf, (unsigned char *)vx, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)vy, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)vz, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)obstacles, (unsigned int)res); ptcache_file_read(pf, &dt, 1, sizeof(float)); ptcache_file_read(pf, &dx, 1, sizeof(float)); ptcache_file_read(pf, &sds->p0, 3, sizeof(float)); @@ -751,20 +751,20 @@ static int ptcache_smoke_read(PTCacheFile *pf, void *smoke_v) smoke_turbulence_export(sds->wt, &dens, &react, &flame, &fuel, &r, &g, &b, &tcu, &tcv, &tcw); - ptcache_file_compressed_read(pf, (unsigned char*)dens, out_len_big); + ptcache_file_compressed_read(pf, (unsigned char *)dens, out_len_big); if (cache_fields & SM_ACTIVE_FIRE) { - ptcache_file_compressed_read(pf, (unsigned char*)flame, out_len_big); - ptcache_file_compressed_read(pf, (unsigned char*)fuel, out_len_big); + ptcache_file_compressed_read(pf, (unsigned char *)flame, out_len_big); + ptcache_file_compressed_read(pf, (unsigned char *)fuel, out_len_big); } if (cache_fields & SM_ACTIVE_COLORS) { - ptcache_file_compressed_read(pf, (unsigned char*)r, out_len_big); - ptcache_file_compressed_read(pf, (unsigned char*)g, out_len_big); - ptcache_file_compressed_read(pf, (unsigned char*)b, out_len_big); + ptcache_file_compressed_read(pf, (unsigned char *)r, out_len_big); + ptcache_file_compressed_read(pf, (unsigned char *)g, out_len_big); + ptcache_file_compressed_read(pf, (unsigned char *)b, out_len_big); } - ptcache_file_compressed_read(pf, (unsigned char*)tcu, out_len); - ptcache_file_compressed_read(pf, (unsigned char*)tcv, out_len); - ptcache_file_compressed_read(pf, (unsigned char*)tcw, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)tcu, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)tcv, out_len); + ptcache_file_compressed_read(pf, (unsigned char *)tcw, out_len); } return 1; @@ -859,7 +859,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v) return 0; } - ptcache_file_compressed_read(pf, (unsigned char*)surface->data->type_data, data_len*surface->data->total_points); + ptcache_file_compressed_read(pf, (unsigned char *)surface->data->type_data, data_len*surface->data->total_points); } return 1; @@ -1363,7 +1363,7 @@ static int ptcache_file_compressed_write(PTCacheFile *pf, unsigned char *in, uns if (mode == 1) { LZO_HEAP_ALLOC(wrkmem, LZO1X_MEM_COMPRESS); - r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem); + r = lzo1x_1_compress(in, (lzo_uint)in_len, out, (lzo_uint *)&out_len, wrkmem); if (!(r == LZO_E_OK) || (out_len >= in_len)) compressed = 0; else @@ -1699,7 +1699,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) for (i=0; i<BPHYS_TOT_DATA; i++) { unsigned int out_len = pm->totpoint*ptcache_data_size[i]; if (pf->data_types & (1<<i)) - ptcache_file_compressed_read(pf, (unsigned char*)(pm->data[i]), out_len); + ptcache_file_compressed_read(pf, (unsigned char *)(pm->data[i]), out_len); } } else { @@ -1730,7 +1730,7 @@ static PTCacheMem *ptcache_disk_frame_to_mem(PTCacheID *pid, int cfra) extra->data = MEM_callocN(extra->totdata * ptcache_extra_datasize[extra->type], "Pointcache extradata->data"); if (pf->flag & PTCACHE_TYPEFLAG_COMPRESS) - ptcache_file_compressed_read(pf, (unsigned char*)(extra->data), extra->totdata*ptcache_extra_datasize[extra->type]); + ptcache_file_compressed_read(pf, (unsigned char *)(extra->data), extra->totdata*ptcache_extra_datasize[extra->type]); else ptcache_file_read(pf, extra->data, extra->totdata, ptcache_extra_datasize[extra->type]); @@ -1787,7 +1787,7 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) if (pm->data[i]) { unsigned int in_len = pm->totpoint*ptcache_data_size[i]; unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer"); - ptcache_file_compressed_write(pf, (unsigned char*)(pm->data[i]), in_len, out, pid->cache->compression); + ptcache_file_compressed_write(pf, (unsigned char *)(pm->data[i]), in_len, out, pid->cache->compression); MEM_freeN(out); } } @@ -1820,7 +1820,7 @@ static int ptcache_mem_frame_to_disk(PTCacheID *pid, PTCacheMem *pm) if (pid->cache->compression) { unsigned int in_len = extra->totdata * ptcache_extra_datasize[extra->type]; unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer"); - ptcache_file_compressed_write(pf, (unsigned char*)(extra->data), in_len, out, pid->cache->compression); + ptcache_file_compressed_write(pf, (unsigned char *)(extra->data), in_len, out, pid->cache->compression); MEM_freeN(out); } else { @@ -2031,18 +2031,16 @@ int BKE_ptcache_read(PTCacheID *pid, float cfra) pid->cache->simframe = cfra2; } - if ((pid->cache->flag & PTCACHE_QUICK_CACHE)==0) { - cfrai = (int)cfra; - /* clear invalid cache frames so that better stuff can be simulated */ - if (pid->cache->flag & PTCACHE_OUTDATED) { - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai); - } - else if (pid->cache->flag & PTCACHE_FRAMES_SKIPPED) { - if (cfra <= pid->cache->last_exact) - pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED; + cfrai = (int)cfra; + /* clear invalid cache frames so that better stuff can be simulated */ + if (pid->cache->flag & PTCACHE_OUTDATED) { + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, cfrai); + } + else if (pid->cache->flag & PTCACHE_FRAMES_SKIPPED) { + if (cfra <= pid->cache->last_exact) + pid->cache->flag &= ~PTCACHE_FRAMES_SKIPPED; - BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai, pid->cache->last_exact)); - } + BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_AFTER, MAX2(cfrai, pid->cache->last_exact)); } return ret; @@ -2273,7 +2271,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) /* clear all files in the temp dir with the prefix of the ID and the ".bphys" suffix */ switch (mode) { case PTCACHE_CLEAR_ALL: - case PTCACHE_CLEAR_BEFORE: + case PTCACHE_CLEAR_BEFORE: case PTCACHE_CLEAR_AFTER: if (pid->cache->flag & PTCACHE_DISK_CACHE) { ptcache_path(pid, path); @@ -2377,7 +2375,7 @@ void BKE_ptcache_id_clear(PTCacheID *pid, int mode, unsigned int cfra) } } } - if (pid->cache->cached_frames && cfra>=sta && cfra<=end) + if (pid->cache->cached_frames && cfra >= sta && cfra <= end) pid->cache->cached_frames[cfra-sta] = 0; break; } @@ -2464,7 +2462,7 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra if (MEM_allocN_len(cache->cached_frames) != sizeof(char) * (cache->endframe-cache->startframe+1)) { MEM_freeN(cache->cached_frames); cache->cached_frames = NULL; - } + } } if (cache->cached_frames==NULL && cache->endframe > cache->startframe) { @@ -2537,8 +2535,6 @@ int BKE_ptcache_id_reset(Scene *scene, PTCacheID *pid, int mode) if (mode == PTCACHE_RESET_DEPSGRAPH) { if (!(cache->flag & PTCACHE_BAKED) && !BKE_ptcache_get_continue_physics()) { - if (cache->flag & PTCACHE_QUICK_CACHE) - clear= 1; after= 1; } @@ -2602,7 +2598,7 @@ int BKE_ptcache_object_reset(Scene *scene, Object *ob, int mode) } for (psys=ob->particlesystem.first; psys; psys=psys->next) { - /* children or just redo can be calculated without reseting anything */ + /* children or just redo can be calculated without resetting anything */ if (psys->recalc & PSYS_RECALC_REDO || psys->recalc & PSYS_RECALC_CHILD) skip = 1; /* Baked cloth hair has to be checked too, because we don't want to reset */ @@ -2826,6 +2822,8 @@ PointCache *BKE_ptcache_copy_list(ListBase *ptcaches_new, ListBase *ptcaches_old return ptcaches_new->first; } +/* Disabled this code; this is being called on scene_update_tagged, and that in turn gets called on + every user action changing stuff, and then it runs a complete bake??? (ton) */ /* Baking */ void BKE_ptcache_quick_cache_all(Main *bmain, Scene *scene) @@ -3009,7 +3007,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker) } if ((cache->flag & PTCACHE_REDO_NEEDED || (cache->flag & PTCACHE_SIMULATION_VALID)==0) && - ((cache->flag & PTCACHE_QUICK_CACHE)==0 || render || bake)) + (render || bake)) { BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); } @@ -3378,7 +3376,7 @@ void BKE_ptcache_update_info(PTCacheID *pid) if (cache->flag & PTCACHE_EXTERNAL) { int cfra = cache->startframe; - for (; cfra<=cache->endframe; cfra++) { + for (; cfra <= cache->endframe; cfra++) { if (BKE_ptcache_id_exist(pid, cfra)) totframes++; } @@ -3405,7 +3403,7 @@ void BKE_ptcache_update_info(PTCacheID *pid) else { int cfra = cache->startframe; - for (; cfra<=cache->endframe; cfra++) { + for (; cfra <= cache->endframe; cfra++) { if (BKE_ptcache_id_exist(pid, cfra)) totframes++; } @@ -3414,7 +3412,7 @@ void BKE_ptcache_update_info(PTCacheID *pid) } } else { - PTCacheMem *pm = cache->mem_cache.first; + PTCacheMem *pm = cache->mem_cache.first; float bytes = 0.0f; int i, mb; diff --git a/source/blender/blenkernel/intern/sca.c b/source/blender/blenkernel/intern/sca.c index 6c1fbbfa9a0..eb4e0d9c679 100644 --- a/source/blender/blenkernel/intern/sca.c +++ b/source/blender/blenkernel/intern/sca.c @@ -552,7 +552,7 @@ void set_sca_new_poins_ob(Object *ob) if (sens->flag & SENS_NEW) { for (a=0; a<sens->totlinks; a++) { if (sens->links[a] && sens->links[a]->mynew) - sens->links[a]= sens->links[a]->mynew; + sens->links[a] = sens->links[a]->mynew; } } sens= sens->next; @@ -563,7 +563,7 @@ void set_sca_new_poins_ob(Object *ob) if (cont->flag & CONT_NEW) { for (a=0; a<cont->totlinks; a++) { if ( cont->links[a] && cont->links[a]->mynew) - cont->links[a]= cont->links[a]->mynew; + cont->links[a] = cont->links[a]->mynew; } } cont= cont->next; diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 628a251ed26..721117d739f 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -332,7 +332,7 @@ void BKE_scene_free(Scene *sce) BKE_paint_free(&sce->toolsettings->imapaint.paint); MEM_freeN(sce->toolsettings); - sce->toolsettings = NULL; + sce->toolsettings = NULL; } if (sce->theDag) { @@ -443,7 +443,7 @@ Scene *BKE_scene_add(const char *name) sce->toolsettings->cornertype = 1; sce->toolsettings->degr = 90; sce->toolsettings->step = 9; - sce->toolsettings->turn = 1; + sce->toolsettings->turn = 1; sce->toolsettings->extr_offs = 1; sce->toolsettings->doublimit = 0.001; sce->toolsettings->segments = 32; @@ -965,7 +965,7 @@ float BKE_scene_frame_get_from_ctime(Scene *scene, const float frame) { float ctime = frame; ctime += scene->r.subframe; - ctime *= scene->r.framelen; + ctime *= scene->r.framelen; return ctime; } @@ -1049,7 +1049,7 @@ void BKE_scene_update_tagged(Main *bmain, Scene *scene) /* flush recalc flags to dependencies */ DAG_ids_flush_tagged(bmain); - scene->physics_settings.quick_cache_step = 0; + /* removed calls to quick_cache, see pointcache.c */ /* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later * when trying to find materials with drivers that need evaluating [#32017] @@ -1072,10 +1072,6 @@ void BKE_scene_update_tagged(Main *bmain, Scene *scene) BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, 0); } - /* quick point cache updates */ - if (scene->physics_settings.quick_cache_step) - BKE_ptcache_quick_cache_all(bmain, scene); - /* notify editors and python about recalc */ BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_POST); DAG_ids_check_recalc(bmain, scene, FALSE); @@ -1124,6 +1120,11 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) BKE_animsys_evaluate_all_animation(bmain, sce, ctime); /*...done with recusrive funcs */ + /* clear "LIB_DOIT" flag from all materials, to prevent infinite recursion problems later + * when trying to find materials with drivers that need evaluating [#32017] + */ + tag_main_idcode(bmain, ID_MA, FALSE); + /* BKE_object_handle_update() on all objects, groups and sets */ scene_update_tagged_recursive(bmain, sce, sce); @@ -1201,7 +1202,7 @@ int BKE_scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *s int get_render_subsurf_level(RenderData *r, int lvl) { if (r->mode & R_SIMPLIFY) - return MIN2(r->simplify_subsurf, lvl); + return min_ii(r->simplify_subsurf, lvl); else return lvl; } @@ -1217,7 +1218,7 @@ int get_render_child_particle_number(RenderData *r, int num) int get_render_shadow_samples(RenderData *r, int samples) { if ((r->mode & R_SIMPLIFY) && samples > 0) - return MIN2(r->simplify_shadowsamples, samples); + return min_ii(r->simplify_shadowsamples, samples); else return samples; } diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 33519483843..469881020c1 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -62,14 +62,14 @@ static void slice_get_byte_buffers(const SeqRenderData *context, const ImBuf *ib { int offset = 4 * start_line * context->rectx; - *rect1 = (unsigned char*) ibuf1->rect + offset; - *rect_out = (unsigned char*) out->rect + offset; + *rect1 = (unsigned char *)ibuf1->rect + offset; + *rect_out = (unsigned char *)out->rect + offset; if (ibuf2) - *rect2 = (unsigned char*) ibuf2->rect + offset; + *rect2 = (unsigned char *)ibuf2->rect + offset; if (ibuf3) - *rect3 = (unsigned char*) ibuf3->rect + offset; + *rect3 = (unsigned char *)ibuf3->rect + offset; } static void slice_get_float_buffers(const SeqRenderData *context, const ImBuf *ibuf1, const ImBuf *ibuf2, @@ -600,7 +600,7 @@ static void makeGammaTables(float gamma) color_step = 1.0f / RE_GAMMA_TABLE_SIZE; inv_color_step = (float) RE_GAMMA_TABLE_SIZE; - /* We could squeeze out the two range tables to gain some memory */ + /* We could squeeze out the two range tables to gain some memory */ for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) { color_domain_table[i] = i * color_step; gamma_range_table[i] = pow(color_domain_table[i], valid_gamma); @@ -1178,7 +1178,7 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, float *r fac3 = facf1; /* formula: - * fac*(a*b) + (1-fac)*a => fac*a*(b-1)+a + * fac * (a * b) + (1 - fac) * a => fac * a * (b - 1) + a */ while (y--) { @@ -1353,7 +1353,7 @@ static float check_zone(WipeZone *wipezone, int x, int y, Sequence *seq, float f hyp2 = fabsf(angle * x + y + (-(yo - posy * 0.5f) - angle * (xo - posx * 0.5f))) * wipezone->pythangle; } - hwidth = minf(hwidth, fabsf(b3 - b1) / 2.0f); + hwidth = min_ff(hwidth, fabsf(b3 - b1) / 2.0f); if (b2 < b1 && b2 < b3) { output = in_band(hwidth, hyp, 0, 1); @@ -2373,7 +2373,7 @@ static ImBuf *do_solid_color(SeqRenderData context, Sequence *seq, float UNUSED( rect[1] = col1[1]; rect[2] = col1[2]; rect[3] = 255; - } + } } } @@ -2609,7 +2609,7 @@ static void store_icu_yrange_speed(Sequence *seq, short UNUSED(adrcode), float * *ymin = 0.0; *ymax = seq->len; } - } + } } void BKE_sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, int force) diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 49ed7f80be3..b6ebc42fcf6 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -53,6 +53,8 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "BKE_animsys.h" #include "BKE_global.h" #include "BKE_image.h" @@ -507,8 +509,8 @@ static void seq_update_sound_bounds_recursive_rec(Scene *scene, Sequence *metase * since sound is played outside of evaluating the imbufs, */ for (seq = metaseq->seqbase.first; seq; seq = seq->next) { if (seq->type == SEQ_TYPE_META) { - seq_update_sound_bounds_recursive_rec(scene, seq, maxi(start, metaseq_start(seq)), - mini(end, metaseq_end(seq))); + seq_update_sound_bounds_recursive_rec(scene, seq, max_ii(start, metaseq_start(seq)), + min_ii(end, metaseq_end(seq))); } else if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM, SEQ_TYPE_SCENE)) { if (seq->scene_sound) { @@ -991,7 +993,7 @@ static float give_stripelem_index(Sequence *seq, float cfra) if (seq->type & SEQ_TYPE_EFFECT) { end = seq->enddisp; - } + } if (end < sta) { return -1; @@ -1882,7 +1884,7 @@ static ImBuf *input_preprocess(SeqRenderData context, Sequence *seq, float cfra, ibuf = i; } - } + } if (seq->flag & SEQ_FLIPX) { IMB_flipx(ibuf); @@ -1978,7 +1980,7 @@ static void copy_to_ibuf_still(SeqRenderData context, Sequence *seq, float nr, I if (nr == 0) { BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_STARTSTILL, ibuf); - } + } if (nr == seq->len - 1) { BKE_sequencer_cache_put(context, seq, seq->start, SEQ_STRIPELEM_IBUF_ENDSTILL, ibuf); @@ -2337,9 +2339,11 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float * -jahka */ - int rendering = G.is_rendering; - int doseq; - int doseq_gl = G.is_rendering ? /*(scene->r.seq_flag & R_SEQ_GL_REND)*/ 0 : /*(scene->r.seq_flag & R_SEQ_GL_PREV)*/ 1; + const short is_rendering = G.is_rendering; + const int do_seq_gl = G.is_rendering ? + 0 /* (context.scene->r.seq_flag & R_SEQ_GL_REND) */ : + (context.scene->r.seq_flag & R_SEQ_GL_PREV); + int do_seq; int have_seq = FALSE; Scene *scene; @@ -2356,9 +2360,10 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float oldcfra = scene->r.cfra; scene->r.cfra = frame; - if (seq->scene_camera) + if (seq->scene_camera) { camera = seq->scene_camera; - else { + } + else { BKE_scene_camera_switch_update(scene); camera = scene->camera; } @@ -2369,7 +2374,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float } /* prevent eternal loop */ - doseq = context.scene->r.scemode & R_DOSEQ; + do_seq = context.scene->r.scemode & R_DOSEQ; context.scene->r.scemode &= ~R_DOSEQ; #ifdef DURIAN_CAMERA_SWITCH @@ -2379,8 +2384,11 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float #else (void)oldmarkers; #endif - - if (sequencer_view3d_cb && BLI_thread_is_main() && doseq_gl && (scene == context.scene || have_seq == 0) && camera) { + + if ((sequencer_view3d_cb && do_seq_gl && camera) && + (BLI_thread_is_main() == TRUE) && + ((have_seq == FALSE) || (scene == context.scene))) + { char err_out[256] = "unknown"; /* for old scened this can be uninitialized, * should probably be added to do_versions at some point if the functionality stays */ @@ -2400,14 +2408,14 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float RenderResult rres; /* XXX: this if can be removed when sequence preview rendering uses the job system */ - if (rendering || context.scene != scene) { + if (is_rendering || context.scene != scene) { if (re == NULL) re = RE_NewRender(scene->id.name); RE_BlenderFrame(re, context.bmain, scene, NULL, camera, scene->lay, frame, FALSE); /* restore previous state after it was toggled on & off by RE_BlenderFrame */ - G.is_rendering = rendering; + G.is_rendering = is_rendering; } RE_AcquireResultImage(re, &rres); @@ -2434,7 +2442,7 @@ static ImBuf *seq_render_scene_strip(SeqRenderData context, Sequence *seq, float } /* restore */ - context.scene->r.scemode |= doseq; + context.scene->r.scemode |= do_seq; scene->r.cfra = oldcfra; @@ -2825,7 +2833,7 @@ ImBuf *BKE_sequencer_give_ibuf(SeqRenderData context, float cfra, int chanshown) count = BLI_countlist(&ed->metastack); if ((chanshown < 0) && (count > 0)) { - count = MAX2(count + chanshown, 0); + count = max_ii(count + chanshown, 0); seqbasep = ((MetaStack *)BLI_findlink(&ed->metastack, count))->oldbasep; } else { @@ -3194,7 +3202,7 @@ int BKE_sequence_tx_get_final_left(Sequence *seq, int metaclip) { if (metaclip && seq->tmp) { /* return the range clipped by the parents range */ - return maxi(BKE_sequence_tx_get_final_left(seq, 0), BKE_sequence_tx_get_final_left((Sequence *)seq->tmp, TRUE)); + return max_ii(BKE_sequence_tx_get_final_left(seq, 0), BKE_sequence_tx_get_final_left((Sequence *)seq->tmp, TRUE)); } else { return (seq->start - seq->startstill) + seq->startofs; @@ -3205,7 +3213,7 @@ int BKE_sequence_tx_get_final_right(Sequence *seq, int metaclip) { if (metaclip && seq->tmp) { /* return the range clipped by the parents range */ - return mini(BKE_sequence_tx_get_final_right(seq, 0), BKE_sequence_tx_get_final_right((Sequence *)seq->tmp, TRUE)); + return min_ii(BKE_sequence_tx_get_final_right(seq, 0), BKE_sequence_tx_get_final_right((Sequence *)seq->tmp, TRUE)); } else { return ((seq->start + seq->len) + seq->endstill) - seq->endofs; @@ -3457,7 +3465,7 @@ int BKE_sequence_base_shuffle(ListBase *seqbasep, Sequence *test, Scene *evil_sc for (seq = seqbasep->first; seq; seq = seq->next) { if (seq->machine == orig_machine) - new_frame = MAX2(new_frame, seq->enddisp); + new_frame = max_ii(new_frame, seq->enddisp); } test->machine = orig_machine; @@ -3482,10 +3490,10 @@ static int shuffle_seq_time_offset_test(ListBase *seqbasep, char dir) for (seq_other = seqbasep->first; seq_other; seq_other = seq_other->next) { if (!seq_other->tmp && seq_overlap(seq, seq_other)) { if (dir == 'L') { - offset = MIN2(offset, seq_other->startdisp - seq->enddisp); + offset = min_ii(offset, seq_other->startdisp - seq->enddisp); } else { - offset = MAX2(offset, seq_other->enddisp - seq->startdisp); + offset = max_ii(offset, seq_other->enddisp - seq->startdisp); } } } @@ -3670,26 +3678,26 @@ int BKE_sequence_swap(Sequence *seq_a, Sequence *seq_b, const char **error_str) char name[sizeof(seq_a->name)]; if (seq_a->len != seq_b->len) { - *error_str = "Strips must be the same length"; + *error_str = N_("Strips must be the same length"); return 0; } - /* type checking, could be more advanced but disalow sound vs non-sound copy */ + /* type checking, could be more advanced but disallow sound vs non-sound copy */ if (seq_a->type != seq_b->type) { if (seq_a->type == SEQ_TYPE_SOUND_RAM || seq_b->type == SEQ_TYPE_SOUND_RAM) { - *error_str = "Strips were not compatible"; + *error_str = N_("Strips were not compatible"); return 0; } /* disallow effects to swap with non-effects strips */ if ((seq_a->type & SEQ_TYPE_EFFECT) != (seq_b->type & SEQ_TYPE_EFFECT)) { - *error_str = "Strips were not compatible"; + *error_str = N_("Strips were not compatible"); return 0; } if ((seq_a->type & SEQ_TYPE_EFFECT) && (seq_b->type & SEQ_TYPE_EFFECT)) { if (BKE_sequence_effect_get_num_inputs(seq_a->type) != BKE_sequence_effect_get_num_inputs(seq_b->type)) { - *error_str = "Strips must have the same number of inputs"; + *error_str = N_("Strips must have the same number of inputs"); return 0; } } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 9a8bcaabe0c..5586d8e4c29 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -84,7 +84,7 @@ #endif /* get derived mesh */ -//TODO is anyfunction that does this? returning the derivedFinal without we caring if its in edit mode or not? +/* TODO is anyfunction that does this? returning the derivedFinal without we caring if its in edit mode or not? */ DerivedMesh *object_get_derived_final(Object *ob) { Mesh *me = ob->data; @@ -149,7 +149,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) return; } - //Setup nearest + /* Setup nearest */ nearest.index = -1; nearest.dist = FLT_MAX; #ifndef __APPLE__ @@ -162,7 +162,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) if (weight == 0.0f) continue; - //Convert the vertex to tree coordinates + /* Convert the vertex to tree coordinates */ if (calc->vert) { copy_v3_v3(tmp_co, calc->vert[i].co); } @@ -171,11 +171,11 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) } space_transform_apply(&calc->local2target, tmp_co); - //Use local proximity heuristics (to reduce the nearest search) - // - //If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex - //so we can initiate the "nearest.dist" with the expected value to that last hit. - //This will lead in prunning of the search tree. + /* Use local proximity heuristics (to reduce the nearest search) + * + * If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex + * so we can initiate the "nearest.dist" with the expected value to that last hit. + * This will lead in prunning of the search tree. */ if (nearest.index != -1) nearest.dist = len_squared_v3v3(tmp_co, nearest.co); else @@ -184,17 +184,18 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) BLI_bvhtree_find_nearest(treeData.tree, tmp_co, &nearest, treeData.nearest_callback, &treeData); - //Found the nearest vertex + /* Found the nearest vertex */ if (nearest.index != -1) { - //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position + /* Adjusting the vertex weight, + * so that after interpolating it keeps a certain distance from the nearest position */ float dist = sasqrt(nearest.dist); if (dist > FLT_EPSILON) weight *= (dist - calc->keepDist) / dist; - //Convert the coordinates back to mesh coordinates + /* Convert the coordinates back to mesh coordinates */ copy_v3_v3(tmp_co, nearest.co); space_transform_invert(&calc->local2target, tmp_co); - interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation + interp_v3_v3v3(co, co, tmp_co, weight); /* linear interpolation */ } } @@ -215,10 +216,10 @@ int normal_projection_project_vertex(char options, const float vert[3], const fl const float *co, *no; BVHTreeRayHit hit_tmp; - //Copy from hit (we need to convert hit rays from one space coordinates to the other + /* Copy from hit (we need to convert hit rays from one space coordinates to the other */ memcpy(&hit_tmp, hit, sizeof(hit_tmp)); - //Apply space transform (TODO readjust dist) + /* Apply space transform (TODO readjust dist) */ if (transf) { copy_v3_v3(tmp_co, vert); space_transform_apply(transf, tmp_co); @@ -272,39 +273,39 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) { int i; - //Options about projection direction + /* Options about projection direction */ const char use_normal = calc->smd->shrinkOpts; float proj_axis[3] = {0.0f, 0.0f, 0.0f}; - //Raycast and tree stuff + /* Raycast and tree stuff */ BVHTreeRayHit hit; BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; - //auxiliary target + /* auxiliary target */ DerivedMesh *auxMesh = NULL; BVHTreeFromMesh auxData = NULL_BVHTreeFromMesh; SpaceTransform local2aux; - //If the user doesn't allows to project in any direction of projection axis - //then theres nothing todo. + /* If the user doesn't allows to project in any direction of projection axis + * then theres nothing todo. */ if ((use_normal & (MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR | MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR)) == 0) return; - //Prepare data to retrieve the direction in which we should project each vertex + /* Prepare data to retrieve the direction in which we should project each vertex */ if (calc->smd->projAxis == MOD_SHRINKWRAP_PROJECT_OVER_NORMAL) { if (calc->vert == NULL) return; } else { - //The code supports any axis that is a combination of X,Y,Z - //although currently UI only allows to set the 3 different axis + /* The code supports any axis that is a combination of X,Y,Z + * although currently UI only allows to set the 3 different axis */ if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) proj_axis[0] = 1.0f; if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Y_AXIS) proj_axis[1] = 1.0f; if (calc->smd->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_Z_AXIS) proj_axis[2] = 1.0f; normalize_v3(proj_axis); - //Invalid projection direction + /* Invalid projection direction */ if (dot_v3v3(proj_axis, proj_axis) < FLT_EPSILON) return; } @@ -316,7 +317,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) SPACE_TRANSFORM_SETUP(&local2aux, calc->ob, calc->smd->auxTarget); } - //After sucessufuly build the trees, start projection vertexs + /* After sucessufuly build the trees, start projection vertexs */ if (bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 4, 6) && (auxMesh == NULL || bvhtree_from_mesh_faces(&auxData, auxMesh, 0.0, 4, 6))) { @@ -351,9 +352,9 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) hit.index = -1; - hit.dist = 10000.0f; //TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that + hit.dist = 10000.0f; /* TODO: we should use FLT_MAX here, but sweepsphere code isn't prepared for that */ - //Project over positive direction of axis + /* Project over positive direction of axis */ if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR) { if (auxData.tree) @@ -362,7 +363,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) normal_projection_project_vertex(calc->smd->shrinkOpts, tmp_co, tmp_no, &calc->local2target, treeData.tree, &hit, treeData.raycast_callback, &treeData); } - //Project over negative direction of axis + /* Project over negative direction of axis */ if (use_normal & MOD_SHRINKWRAP_PROJECT_ALLOW_NEG_DIR && hit.index == -1) { float inv_no[3]; negate_v3_v3(inv_no, tmp_no); @@ -381,7 +382,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) } } - //free data structures + /* free data structures */ free_bvhtree_from_mesh(&treeData); free_bvhtree_from_mesh(&auxData); } @@ -399,19 +400,19 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; BVHTreeNearest nearest = NULL_BVHTreeNearest; - //Create a bvh-tree of the given target + /* Create a bvh-tree of the given target */ BENCH(bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 2, 6)); if (treeData.tree == NULL) { OUT_OF_MEMORY(); return; } - //Setup nearest + /* Setup nearest */ nearest.index = -1; nearest.dist = FLT_MAX; - //Find the nearest vertex + /* Find the nearest vertex */ #ifndef __APPLE__ #pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static) #endif @@ -421,7 +422,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); if (weight == 0.0f) continue; - //Convert the vertex to tree coordinates + /* Convert the vertex to tree coordinates */ if (calc->vert) { copy_v3_v3(tmp_co, calc->vert[i].co); } @@ -430,11 +431,11 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) } space_transform_apply(&calc->local2target, tmp_co); - //Use local proximity heuristics (to reduce the nearest search) - // - //If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex - //so we can initiate the "nearest.dist" with the expected value to that last hit. - //This will lead in prunning of the search tree. + /* Use local proximity heuristics (to reduce the nearest search) + * + * If we already had an hit before.. we assume this vertex is going to have a close hit to that other vertex + * so we can initiate the "nearest.dist" with the expected value to that last hit. + * This will lead in prunning of the search tree. */ if (nearest.index != -1) nearest.dist = len_squared_v3v3(tmp_co, nearest.co); else @@ -442,24 +443,25 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) BLI_bvhtree_find_nearest(treeData.tree, tmp_co, &nearest, treeData.nearest_callback, &treeData); - //Found the nearest vertex + /* Found the nearest vertex */ if (nearest.index != -1) { if (calc->smd->shrinkOpts & MOD_SHRINKWRAP_KEEP_ABOVE_SURFACE) { - //Make the vertex stay on the front side of the face + /* Make the vertex stay on the front side of the face */ madd_v3_v3v3fl(tmp_co, nearest.co, nearest.no, calc->keepDist); } else { - //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position + /* Adjusting the vertex weight, + * so that after interpolating it keeps a certain distance from the nearest position */ float dist = sasqrt(nearest.dist); if (dist > FLT_EPSILON) - interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist) / dist); //linear interpolation + interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist) / dist); /* linear interpolation */ else copy_v3_v3(tmp_co, nearest.co); } - //Convert the coordinates back to mesh coordinates + /* Convert the coordinates back to mesh coordinates */ space_transform_invert(&calc->local2target, tmp_co); - interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation + interp_v3_v3v3(co, co, tmp_co, weight); /* linear interpolation */ } } @@ -473,18 +475,18 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM DerivedMesh *ss_mesh = NULL; ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData; - //remove loop dependencies on derived meshs (TODO should this be done elsewhere?) + /* remove loop dependencies on derived meshs (TODO should this be done elsewhere?) */ if (smd->target == ob) smd->target = NULL; if (smd->auxTarget == ob) smd->auxTarget = NULL; - //Configure Shrinkwrap calc data + /* Configure Shrinkwrap calc data */ calc.smd = smd; calc.ob = ob; calc.numVerts = numVerts; calc.vertexCos = vertexCos; - //DeformVertex + /* DeformVertex */ calc.vgroup = defgroup_name_index(calc.ob, calc.smd->vgroup_name); if (dm) { calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); @@ -497,12 +499,12 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM if (smd->target) { calc.target = object_get_derived_final(smd->target); - //TODO there might be several "bugs" on non-uniform scales matrixs - //because it will no longer be nearest surface, not sphere projection - //because space has been deformed + /* TODO there might be several "bugs" on non-uniform scales matrixs + * because it will no longer be nearest surface, not sphere projection + * because space has been deformed */ SPACE_TRANSFORM_SETUP(&calc.local2target, ob, smd->target); - //TODO: smd->keepDist is in global units.. must change to local + /* TODO: smd->keepDist is in global units.. must change to local */ calc.keepDist = smd->keepDist; } @@ -511,15 +513,15 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM calc.vgroup = defgroup_name_index(calc.ob, smd->vgroup_name); if (dm != NULL && smd->shrinkType == MOD_SHRINKWRAP_PROJECT) { - //Setup arrays to get vertexs positions, normals and deform weights + /* Setup arrays to get vertexs positions, normals and deform weights */ calc.vert = dm->getVertDataArray(dm, CD_MVERT); calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); - //Using vertexs positions/normals as if a subsurface was applied + /* Using vertexs positions/normals as if a subsurface was applied */ if (smd->subsurfLevels) { SubsurfModifierData ssmd = {{NULL}}; - ssmd.subdivType = ME_CC_SUBSURF; //catmull clark - ssmd.levels = smd->subsurfLevels; //levels + ssmd.subdivType = ME_CC_SUBSURF; /* catmull clark */ + ssmd.levels = smd->subsurfLevels; /* levels */ ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, NULL, (ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : 0); @@ -532,13 +534,13 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM } } - //Just to make sure we are not leaving any memory behind + /* Just to make sure we are not leaving any memory behind */ assert(ssmd.emCache == NULL); assert(ssmd.mCache == NULL); } } - //Projecting target defined - lets work! + /* Projecting target defined - lets work! */ if (calc.target) { switch (smd->shrinkType) { case MOD_SHRINKWRAP_NEAREST_SURFACE: @@ -555,7 +557,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM } } - //free memory + /* free memory */ if (ss_mesh) ss_mesh->release(ss_mesh); } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index c8d6ec73d28..443aed1fc41 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -640,7 +640,6 @@ void smokeModifier_copy(struct SmokeModifierData *smd, struct SmokeModifierData tsmd->flow->flags = smd->flow->flags; } else if (tsmd->coll) { - ; /* leave it as initialized, collision settings is mostly caches */ } } @@ -699,7 +698,7 @@ static void obstacles_from_derivedmesh(Object *coll_ob, SmokeDomainSettings *sds numverts = dm->getNumVerts(dm); // DG TODO - // if(scs->type > SM_COLL_STATIC) + // if (scs->type > SM_COLL_STATIC) // if line above is used, the code is in trouble if the object moves but is declared as "does not move" { @@ -952,7 +951,7 @@ static void em_freeData(EmissionMap *em) { static void emit_from_particles(Object *flow_ob, SmokeDomainSettings *sds, SmokeFlowSettings *sfs, EmissionMap *em, Scene *scene, float time, float dt) { - if (sfs && sfs->psys && sfs->psys->part && sfs->psys->part->type == PART_EMITTER) // is particle system selected + if (sfs && sfs->psys && sfs->psys->part && ELEM(sfs->psys->part->type, PART_EMITTER, PART_FLUID)) // is particle system selected { ParticleSimulationData sim; ParticleSystem *psys = sfs->psys; @@ -1239,7 +1238,7 @@ static void emit_from_derivedmesh(Object *flow_ob, SmokeDomainSettings *sds, Smo } /* apply vertex group influence if used */ - if (defgrp_index >= 0 && dvert) { + if (defgrp_index != -1 && dvert) { float weight_mask = defvert_find_weight(&dvert[v1], defgrp_index) * weights[0] + defvert_find_weight(&dvert[v2], defgrp_index) * weights[1] + defvert_find_weight(&dvert[v3], defgrp_index) * weights[2]; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index f47c931e309..3a16158c374 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -1598,7 +1598,7 @@ static void _scan_for_ext_spring_forces(Scene *scene, Object *ob, float timenow, /*see if we have wind*/ if (do_effector) { EffectedPoint epoint; - float speed[3]={0.0f, 0.0f, 0.0f}; + float speed[3] = {0.0f, 0.0f, 0.0f}; float pos[3]; mid_v3_v3v3(pos, sb->bpoint[bs->v1].pos, sb->bpoint[bs->v2].pos); mid_v3_v3v3(vel, sb->bpoint[bs->v1].vec, sb->bpoint[bs->v2].vec); @@ -1749,8 +1749,8 @@ static int sb_detect_vertex_collisionCached(float opco[3], float facenormal[3], Object *ob= NULL; GHash *hash; GHashIterator *ihash; - float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3], d_nvect[3], dv1[3], ve[3], avel[3]={0.0, 0.0, 0.0}, - vv1[3], vv2[3], vv3[3], vv4[3], coledge[3]={0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f, + float nv1[3], nv2[3], nv3[3], nv4[3], edge1[3], edge2[3], d_nvect[3], dv1[3], ve[3], avel[3] = {0.0, 0.0, 0.0}, + vv1[3], vv2[3], vv3[3], vv4[3], coledge[3] = {0.0f, 0.0f, 0.0f}, mindistedge = 1000.0f, outerforceaccu[3], innerforceaccu[3], facedist, /* n_mag, */ /* UNUSED */ force_mag_norm, minx, miny, minz, maxx, maxy, maxz, innerfacethickness = -0.5f, outerfacethickness = 0.2f, @@ -2209,7 +2209,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo bp = &sb->bpoint[ifirst]; for (bb=number_of_points_here; bb>0; bb--, bp++) { /* clear forces accumulator */ - bp->force[0]= bp->force[1]= bp->force[2]= 0.0; + bp->force[0] = bp->force[1] = bp->force[2] = 0.0; /* naive ball self collision */ /* needs to be done if goal snaps or not */ if (do_selfcollision) { @@ -2304,8 +2304,8 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, Object *ob, flo if (do_effector) { EffectedPoint epoint; float kd; - float force[3]= {0.0f, 0.0f, 0.0f}; - float speed[3]= {0.0f, 0.0f, 0.0f}; + float force[3] = {0.0f, 0.0f, 0.0f}; + float speed[3] = {0.0f, 0.0f, 0.0f}; float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */ pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint-bp, &epoint); pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); @@ -2557,7 +2557,7 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa for (a=sb->totpoint, bp= sb->bpoint; a>0; a--, bp++) { /* clear forces accumulator */ - bp->force[0]= bp->force[1]= bp->force[2]= 0.0; + bp->force[0] = bp->force[1] = bp->force[2] = 0.0; if (nl_flags & NLF_BUILD) { //int ia =3*(sb->totpoint-a); //int op =3*sb->totpoint; @@ -2712,8 +2712,8 @@ static void softbody_calc_forces(Scene *scene, Object *ob, float forcetime, floa /* particle field & vortex */ if (do_effector) { EffectedPoint epoint; - float force[3]= {0.0f, 0.0f, 0.0f}; - float speed[3]= {0.0f, 0.0f, 0.0f}; + float force[3] = {0.0f, 0.0f, 0.0f}; + float speed[3] = {0.0f, 0.0f, 0.0f}; float eval_sb_fric_force_scale = sb_fric_force_scale(ob); /* just for calling function once */ pd_point_from_soft(scene, bp->pos, bp->vec, sb->bpoint-bp, &epoint); pdDoEffectors(do_effector, NULL, sb->effector_weights, &epoint, force, speed); @@ -2905,7 +2905,7 @@ static void softbody_apply_forces(Object *ob, float forcetime, int mode, float * /* or heun ~ 2nd order runge-kutta steps, mode 1, 2 */ SoftBody *sb= ob->soft; /* is supposed to be there */ BodyPoint *bp; - float dx[3]={0}, dv[3], aabbmin[3], aabbmax[3], cm[3]={0.0f, 0.0f, 0.0f}; + float dx[3] = {0}, dv[3], aabbmin[3], aabbmax[3], cm[3] = {0.0f, 0.0f, 0.0f}; float timeovermass/*, freezeloc=0.00001f, freezeforce=0.00000000001f*/; float maxerrpos= 0.0f, maxerrvel = 0.0f; int a, fuzzy=0; @@ -3194,7 +3194,7 @@ static void interpolate_exciter(Object *ob, int timescale, int time) - xxxx_to_softbody(Object *ob) : a full (new) copy, creates SB geometry */ -static void get_scalar_from_vertexgroup(Object *ob, int vertID, short groupindex, float *target) +static void get_scalar_from_vertexgroup(Object *ob, int vertID, int groupindex, float *target) /* result 0 on success, else indicates error number -- kind of *inverse* result defintion, -- but this way we can signal error condition to caller @@ -3297,7 +3297,7 @@ static void mesh_to_softbody(Scene *scene, Object *ob) if ((ob->softflag & OB_SB_GOAL) && sb->vertgroup) { /* even this is a deprecated evil hack */ /* I'd like to have it .. if (sb->namedVG_Goal[0]) */ - get_scalar_from_vertexgroup(ob, a, (short) (sb->vertgroup-1), &bp->goal); + get_scalar_from_vertexgroup(ob, a, sb->vertgroup - 1, &bp->goal); /* do this always, regardless successful read from vertex group */ /* this is where '2.5 every thing is animatable' goes wrong in the first place jow_go_for2_5 */ /* 1st coding action to take : move this to frame level */ @@ -3316,10 +3316,10 @@ static void mesh_to_softbody(Scene *scene, Object *ob) */ if (sb->namedVG_Mass[0]) { - int grp= defgroup_name_index (ob, sb->namedVG_Mass); - /* printf("VGN %s %d\n", sb->namedVG_Mass, grp); */ - if (grp > -1) { - get_scalar_from_vertexgroup(ob, a, (short) (grp), &bp->mass); + int defgrp_index = defgroup_name_index (ob, sb->namedVG_Mass); + /* printf("VGN %s %d\n", sb->namedVG_Mass, defgrp_index); */ + if (defgrp_index != -1) { + get_scalar_from_vertexgroup(ob, a, defgrp_index, &bp->mass); /* 2.5 bp->mass = bp->mass * sb->nodemass; */ /* printf("bp->mass %f\n", bp->mass); */ @@ -3329,10 +3329,10 @@ static void mesh_to_softbody(Scene *scene, Object *ob) bp->springweight = 1.0f; if (sb->namedVG_Spring_K[0]) { - int grp= defgroup_name_index (ob, sb->namedVG_Spring_K); - //printf("VGN %s %d\n", sb->namedVG_Spring_K, grp); - if (grp > -1) { - get_scalar_from_vertexgroup(ob, a, (short) (grp), &bp->springweight); + int defgrp_index = defgroup_name_index (ob, sb->namedVG_Spring_K); + //printf("VGN %s %d\n", sb->namedVG_Spring_K, defgrp_index); + if (defgrp_index != -1) { + get_scalar_from_vertexgroup(ob, a, defgrp_index , &bp->springweight); //printf("bp->springweight %f\n", bp->springweight); } @@ -3865,7 +3865,7 @@ static void softbody_reset(Object *ob, SoftBody *sb, float (*vertexCos)[3], int copy_v3_v3(bp->origS, bp->pos); copy_v3_v3(bp->origE, bp->pos); copy_v3_v3(bp->origT, bp->pos); - bp->vec[0]= bp->vec[1]= bp->vec[2]= 0.0f; + bp->vec[0] = bp->vec[1] = bp->vec[2] = 0.0f; /* the bp->prev*'s are for rolling back from a canceled try to propagate in time * adaptive step size algo in a nutshell: diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index facf0793f87..33350a80928 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -3020,6 +3020,9 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) me->totface, me->totvert, &me->vdata); } + if (ccgdm->pbvh) + pbvh_show_diffuse_color_set(ccgdm->pbvh, ob->sculpt->show_diffuse_color); + return ccgdm->pbvh; } diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 05d0705107d..b9ca3c9cc63 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -314,7 +314,7 @@ int BKE_text_reload(Text *text) fseek(fp, 0L, SEEK_END); len = ftell(fp); - fseek(fp, 0L, SEEK_SET); + fseek(fp, 0L, SEEK_SET); text->undo_pos = -1; @@ -370,7 +370,7 @@ int BKE_text_reload(Text *text) text->curl = text->sell = text->lines.first; text->curc = text->selc = 0; - MEM_freeN(buffer); + MEM_freeN(buffer); return 1; } @@ -404,7 +404,7 @@ Text *BKE_text_load(const char *file, const char *relpath) fseek(fp, 0L, SEEK_END); len = ftell(fp); - fseek(fp, 0L, SEEK_SET); + fseek(fp, 0L, SEEK_SET); ta->name = MEM_mallocN(strlen(file) + 1, "text_name"); strcpy(ta->name, file); @@ -469,7 +469,7 @@ Text *BKE_text_load(const char *file, const char *relpath) ta->curl = ta->sell = ta->lines.first; ta->curc = ta->selc = 0; - MEM_freeN(buffer); + MEM_freeN(buffer); return ta; } @@ -683,7 +683,7 @@ void txt_clean_text(Text *text) if (!text->lines.first) { if (text->lines.last) text->lines.first = text->lines.last; else text->lines.first = text->lines.last = txt_new_line(NULL); - } + } if (!text->lines.last) text->lines.last = text->lines.first; @@ -732,7 +732,7 @@ int txt_get_span(TextLine *from, TextLine *to) if (!tmp) ret = 0; } - return ret; + return ret; } static void txt_make_dirty(Text *text) @@ -934,7 +934,7 @@ void txt_move_right(Text *text, short sel) txt_move_down(text, sel); *charp = 0; } - } + } else { // do nice right only if there are only spaces // spaces hardcoded in DNA_text_types.h @@ -1376,7 +1376,7 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case) int newc = (int)(s - tl->line); txt_move_to(text, newl, newc, 0); txt_move_to(text, newl, newc + strlen(findstr), 1); - return 1; + return 1; } else return 0; @@ -1458,7 +1458,7 @@ char *txt_sel_to_buf(Text *text) length += charl; buf[length] = 0; - } + } return buf; } @@ -2078,7 +2078,7 @@ void txt_do_undo(Text *text) charp = op - UNDO_BS_1 + 1; txt_add_char(text, txt_undo_read_unicode(text->undo_buf, &text->undo_pos, charp)); text->undo_pos--; - break; + break; case UNDO_DEL_1: case UNDO_DEL_2: case UNDO_DEL_3: case UNDO_DEL_4: charp = op - UNDO_DEL_1 + 1; @@ -2104,7 +2104,7 @@ void txt_do_undo(Text *text) txt_curs_first(text, &holdl, &holdc); holdln = txt_get_span(text->lines.first, holdl); - txt_insert_buf(text, buf); + txt_insert_buf(text, buf); MEM_freeN(buf); text->curl = text->lines.first; @@ -2235,7 +2235,7 @@ void txt_do_redo(Text *text) unsigned short charp; char *buf; - text->undo_pos++; + text->undo_pos++; op = text->undo_buf[text->undo_pos]; if (!op) { @@ -2351,7 +2351,7 @@ void txt_do_redo(Text *text) text->undo_pos += linep; buf[linep] = 0; - txt_insert_buf(text, buf); + txt_insert_buf(text, buf); MEM_freeN(buf); text->undo_pos++; @@ -2369,7 +2369,7 @@ void txt_do_redo(Text *text) //charp is the first char selected or 0 linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); - //linep is now the first line of the selection + //linep is now the first line of the selection //set the selcetion for this now text->curc = charp; text->curl = text->lines.first; @@ -2476,7 +2476,7 @@ void txt_split_curline(Text *text) text->curl->format = NULL; text->curl->len = text->curl->len - text->curc; - BLI_insertlinkbefore(&text->lines, text->curl, ins); + BLI_insertlinkbefore(&text->lines, text->curl, ins); text->curc = 0; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 300d272b86b..efc7a281636 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -646,7 +646,7 @@ MTex *add_mtex_id(ID *id, int slot) if (slot == -1) { /* find first free */ - int i; + int i; for (i = 0; i < MAX_MTEX; i++) { if (!mtex_ar[i]) { slot = i; diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index 0d304482060..e39ad4a08c0 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -51,6 +51,8 @@ #include "BLI_string.h" #include "BLI_threads.h" +#include "BLF_translation.h" + #include "BKE_global.h" #include "BKE_tracking.h" #include "BKE_movieclip.h" @@ -221,7 +223,7 @@ void BKE_tracking_get_projection_matrix(MovieTracking *tracking, MovieTrackingOb float viewfac, pixsize, left, right, bottom, top, clipsta, clipend; float winmat[4][4]; float ycor = 1.0f / tracking->camera.pixel_aspect; - float shiftx, shifty, winside = MAX2(winx, winy); + float shiftx, shifty, winside = (float)min_ii(winx, winy); BKE_tracking_camera_shift_get(tracking, winx, winy, &shiftx, &shifty); @@ -997,8 +999,8 @@ void BKE_tracking_marker_clamp(MovieTrackingMarker *marker, int event) if (event == CLAMP_PAT_DIM) { for (a = 0; a < 2; a++) { /* search shouldn't be resized smaller than pattern */ - marker->search_min[a] = minf(pat_min[a], marker->search_min[a]); - marker->search_max[a] = maxf(pat_max[a], marker->search_max[a]); + marker->search_min[a] = min_ff(pat_min[a], marker->search_min[a]); + marker->search_max[a] = max_ff(pat_max[a], marker->search_max[a]); } } else if (event == CLAMP_PAT_POS) { @@ -1022,8 +1024,8 @@ void BKE_tracking_marker_clamp(MovieTrackingMarker *marker, int event) else if (event == CLAMP_SEARCH_DIM) { for (a = 0; a < 2; a++) { /* search shouldn't be resized smaller than pattern */ - marker->search_min[a] = minf(pat_min[a], marker->search_min[a]); - marker->search_max[a] = maxf(pat_max[a], marker->search_max[a]); + marker->search_min[a] = min_ff(pat_min[a], marker->search_min[a]); + marker->search_max[a] = max_ff(pat_max[a], marker->search_max[a]); } } else if (event == CLAMP_SEARCH_POS) { @@ -2138,7 +2140,7 @@ void BKE_tracking_context_sync(MovieTrackingContext *context) context->sync_frame = newframe; - tracking->dopesheet.ok = FALSE; + BKE_tracking_dopesheet_tag_update(tracking); } void BKE_tracking_context_sync_user(const MovieTrackingContext *context, MovieClipUser *user) @@ -2345,10 +2347,10 @@ static int tracking_check_marker_margin(MovieTrackingTrack *track, MovieTracking /* margin from frame boundaries */ BKE_tracking_marker_pattern_minmax(marker, pat_min, pat_max); sub_v2_v2v2(dim, pat_max, pat_min); - margin[0] = margin[1] = maxf(dim[0], dim[1]) / 2.0f; + margin[0] = margin[1] = max_ff(dim[0], dim[1]) / 2.0f; - margin[0] = maxf(margin[0], (float)track->margin / frame_width); - margin[1] = maxf(margin[1], (float)track->margin / frame_height); + margin[0] = max_ff(margin[0], (float)track->margin / frame_width); + margin[1] = max_ff(margin[1], (float)track->margin / frame_height); /* do not track markers which are too close to boundary */ if (marker->pos[0] < margin[0] || marker->pos[0] > 1.0f - margin[0] || @@ -2787,7 +2789,7 @@ int BKE_tracking_reconstruction_check(MovieTracking *tracking, MovieTrackingObje return TRUE; } else if (reconstruct_count_tracks_on_both_keyframes(tracking, object) < 8) { - BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", + BLI_strncpy(error_msg, N_("At least 8 common tracks on both of keyframes are needed for reconstruction"), error_size); return FALSE; @@ -2795,7 +2797,7 @@ int BKE_tracking_reconstruction_check(MovieTracking *tracking, MovieTrackingObje return TRUE; #else - BLI_strncpy(error_msg, "Blender is compiled without motion tracking library", error_size); + BLI_strncpy(error_msg, N_("Blender is compiled without motion tracking library"), error_size); (void) tracking; (void) object; @@ -2848,10 +2850,10 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieTracking * } if (first < track->markersnr - 1) - sfra = MIN2(sfra, first_marker->framenr); + sfra = min_ii(sfra, first_marker->framenr); if (last >= 0) - efra = MAX2(efra, last_marker->framenr); + efra = max_ii(efra, last_marker->framenr); tracks_map_insert(context->tracks_map, track, NULL); @@ -2953,6 +2955,7 @@ int BKE_tracking_reconstruction_finish(MovieReconstructContext *context, MovieTr MovieTrackingReconstruction *reconstruction; tracks_map_merge(context->tracks_map, tracking); + BKE_tracking_dopesheet_tag_update(tracking); if (context->is_camera) { reconstruction = &tracking->reconstruction; @@ -3198,8 +3201,8 @@ static float stabilization_calculate_autoscale_factor(MovieTracking *tracking, i if (track->flag & TRACK_USE_2D_STAB || ((stab->flag & TRACKING_STABILIZE_ROTATION) && track == stab->rot_track)) { - sfra = MIN2(sfra, track->markers[0].framenr); - efra = MAX2(efra, track->markers[track->markersnr - 1].framenr); + sfra = min_ii(sfra, track->markers[0].framenr); + efra = max_ii(efra, track->markers[track->markersnr - 1].framenr); } track = track->next; @@ -3275,7 +3278,7 @@ static float stabilization_calculate_autoscale_factor(MovieTracking *tracking, i S = (-w * I - h * J) / (dx * I + dy * J + K); - scale = maxf(scale, S); + scale = max_ff(scale, S); } } } @@ -3284,7 +3287,7 @@ static float stabilization_calculate_autoscale_factor(MovieTracking *tracking, i stab->scale = scale; if (stab->maxscale > 0.0f) - stab->scale = minf(stab->scale, stab->maxscale); + stab->scale = min_ff(stab->scale, stab->maxscale); } else { stab->scale = 1.0f; @@ -3643,7 +3646,7 @@ static void channels_segments_calc(MovieTrackingDopesheetChannel *channel) channel->segments[2 * segment] = start_marker->framenr; channel->segments[2 * segment + 1] = start_marker->framenr + len; - channel->max_segment = MAX2(channel->max_segment, len); + channel->max_segment = max_ii(channel->max_segment, len); segment++; } @@ -3651,7 +3654,7 @@ static void channels_segments_calc(MovieTrackingDopesheetChannel *channel) } } -static void tracking_dopesheet_sort(MovieTracking *tracking, int sort_method, int inverse) +static void tracking_dopesheet_sort(MovieTracking *tracking, int sort_method, int inverse) { MovieTrackingDopesheet *dopesheet = &tracking->dopesheet; diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 434bfe19c1f..4bde895cf7d 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -107,7 +107,7 @@ World *add_world(const char *name) wrld->ao_indirect_energy = 1.0f; wrld->ao_indirect_bounces = 1; wrld->aobias = 0.05f; - wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY; + wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY; wrld->ao_approx_error = 0.25f; wrld->preview = NULL; diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index 9f29cb8b137..d4428be3faf 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -162,7 +162,7 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL else format = AVI_FORMAT_MJPEG; if (AVI_open_compress(name, avi, 1, format) != AVI_ERROR_NONE) { - BKE_report(reports, RPT_ERROR, "Cannot open or start AVI movie file."); + BKE_report(reports, RPT_ERROR, "Cannot open or start AVI movie file"); MEM_freeN(avi); avi = NULL; return 0; @@ -175,8 +175,8 @@ static int start_avi(Scene *scene, RenderData *rd, int rectx, int recty, ReportL avi->interlace = 0; avi->odd_fields = 0; -/* avi->interlace= rd->mode & R_FIELDS; */ -/* avi->odd_fields= (rd->mode & R_ODDFIELD)?1:0; */ +/* avi->interlace = rd->mode & R_FIELDS; */ +/* avi->odd_fields = (rd->mode & R_ODDFIELD) ? 1 : 0; */ printf("Created avi: %s\n", name); return 1; diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index ff1fdebb728..3a8a14290dc 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -289,7 +289,7 @@ static int write_video_frame(RenderData *rd, int cfra, AVFrame *frame, ReportLis } if (!success) - BKE_report(reports, RPT_ERROR, "Error writing frame."); + BKE_report(reports, RPT_ERROR, "Error writing frame"); return success; } @@ -307,7 +307,7 @@ static AVFrame *generate_video_frame(uint8_t *pixels, ReportList *reports) if (c->pix_fmt != PIX_FMT_BGR32) { rgb_frame = alloc_picture(PIX_FMT_BGR32, width, height); if (!rgb_frame) { - BKE_report(reports, RPT_ERROR, "Couldn't allocate temporary frame."); + BKE_report(reports, RPT_ERROR, "Could not allocate temporary frame"); return NULL; } } @@ -695,12 +695,12 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report exts = get_file_extensions(ffmpeg_type); if (!exts) { - BKE_report(reports, RPT_ERROR, "No valid formats found."); + BKE_report(reports, RPT_ERROR, "No valid formats found"); return 0; } fmt = av_guess_format(NULL, exts[0], NULL); if (!fmt) { - BKE_report(reports, RPT_ERROR, "No valid formats found."); + BKE_report(reports, RPT_ERROR, "No valid formats found"); return 0; } @@ -795,7 +795,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report if (error[0]) BKE_report(reports, RPT_ERROR, error); else - BKE_report(reports, RPT_ERROR, "Error initializing video stream."); + BKE_report(reports, RPT_ERROR, "Error initializing video stream"); av_dict_free(&opts); return 0; @@ -805,20 +805,20 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report if (ffmpeg_audio_codec != CODEC_ID_NONE) { audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of); if (!audio_stream) { - BKE_report(reports, RPT_ERROR, "Error initializing audio stream."); + BKE_report(reports, RPT_ERROR, "Error initializing audio stream"); av_dict_free(&opts); return 0; } } if (!(fmt->flags & AVFMT_NOFILE)) { if (avio_open(&of->pb, name, AVIO_FLAG_WRITE) < 0) { - BKE_report(reports, RPT_ERROR, "Could not open file for writing."); + BKE_report(reports, RPT_ERROR, "Could not open file for writing"); av_dict_free(&opts); return 0; } } if (avformat_write_header(of, NULL) < 0) { - BKE_report(reports, RPT_ERROR, "Could not initialize streams. Probably unsupported codec combination."); + BKE_report(reports, RPT_ERROR, "Could not initialize streams, probably unsupported codec combination"); av_dict_free(&opts); return 0; } @@ -982,7 +982,7 @@ int BKE_ffmpeg_append(RenderData *rd, int start_frame, int frame, int *pixels, i PRINT("Writing frame %i, render width=%d, render height=%d\n", frame, rectx, recty); -// why is this done before writing the video frame and again at end_ffmpeg? +/* why is this done before writing the video frame and again at end_ffmpeg? */ // write_audio_frames(frame / (((double)rd->frs_sec) / rd->frs_sec_base)); if (video_stream) { @@ -1225,7 +1225,7 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char while (*param == ' ') param++; } - o = my_av_find_opt(&c, name, NULL, 0, 0); + o = my_av_find_opt(&c, name, NULL, 0, 0); if (!o) { return 0; } @@ -1233,7 +1233,7 @@ int BKE_ffmpeg_property_add_string(RenderData *rd, const char *type, const char return 0; } if (param && o->type != FF_OPT_TYPE_CONST && o->unit) { - p = my_av_find_opt(&c, param, o->unit, 0, 0); + p = my_av_find_opt(&c, param, o->unit, 0, 0); if (p) { prop = BKE_ffmpeg_property_add(rd, (char *) type, p - c.av_class->option, o - c.av_class->option); } diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index d8fddb9851a..acbbcb0b043 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -118,13 +118,13 @@ int BKE_frameserver_start(struct Scene *scene, RenderData *UNUSED(rd), int rectx (void)scene; /* unused */ if (!startup_socket_system()) { - BKE_report(reports, RPT_ERROR, "Can't startup socket system"); + BKE_report(reports, RPT_ERROR, "Cannot startup socket system"); return 0; } if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { shutdown_socket_system(); - BKE_report(reports, RPT_ERROR, "Can't open socket"); + BKE_report(reports, RPT_ERROR, "Cannot open socket"); return 0; } @@ -136,13 +136,13 @@ int BKE_frameserver_start(struct Scene *scene, RenderData *UNUSED(rd), int rectx if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { shutdown_socket_system(); - BKE_report(reports, RPT_ERROR, "Can't bind to socket"); + BKE_report(reports, RPT_ERROR, "Cannot bind to socket"); return 0; } if (listen(sock, SOMAXCONN) < 0) { shutdown_socket_system(); - BKE_report(reports, RPT_ERROR, "Can't establish listen backlog"); + BKE_report(reports, RPT_ERROR, "Cannot establish listen backlog"); return 0; } connsock = -1; diff --git a/source/blender/blenlib/BLI_dlrbTree.h b/source/blender/blenlib/BLI_dlrbTree.h index d04e544376a..bdde8dbd597 100644 --- a/source/blender/blenlib/BLI_dlrbTree.h +++ b/source/blender/blenlib/BLI_dlrbTree.h @@ -46,7 +46,7 @@ /* Basic Layout for a Node */ typedef struct DLRBT_Node { /* ListBase capabilities */ - struct DLRBT_Node *next, *prev; + struct DLRBT_Node *next, *prev; /* Tree Associativity settings */ struct DLRBT_Node *left, *right; diff --git a/source/blender/blenlib/BLI_heap.h b/source/blender/blenlib/BLI_heap.h index 9d7e6107f19..c0941e00c9b 100644 --- a/source/blender/blenlib/BLI_heap.h +++ b/source/blender/blenlib/BLI_heap.h @@ -54,10 +54,10 @@ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr); void BLI_heap_remove(Heap *heap, HeapNode *node); /* Return 0 if the heap is empty, 1 otherwise. */ -int BLI_heap_empty(Heap *heap); +int BLI_heap_is_empty(Heap *heap); /* Return the size of the heap. */ -int BLI_heap_size(Heap *heap); +unsigned int BLI_heap_size(Heap *heap); /* Return the top node of the heap. This is the node with the lowest value. */ HeapNode *BLI_heap_top(Heap *heap); @@ -69,5 +69,4 @@ void *BLI_heap_popmin(Heap *heap); float BLI_heap_node_value(HeapNode *heap); void *BLI_heap_node_ptr(HeapNode *heap); -#endif - +#endif /* __BLI_HEAP_H__ */ diff --git a/source/blender/blenlib/BLI_kdopbvh.h b/source/blender/blenlib/BLI_kdopbvh.h index 8d0d4943ebe..8441413fba9 100644 --- a/source/blender/blenlib/BLI_kdopbvh.h +++ b/source/blender/blenlib/BLI_kdopbvh.h @@ -97,7 +97,7 @@ void BLI_bvhtree_update_tree(BVHTree *tree); /* collision/overlap: check two trees if they overlap, alloc's *overlap with length of the int return value */ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int *result); -float BLI_bvhtree_getepsilon(BVHTree *tree); +float BLI_bvhtree_getepsilon(const BVHTree *tree); /* find nearest node to the given coordinates * (if nearest is given it will only search nodes where square distance is smaller than nearest->dist) */ diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 6ee1498c855..2b513cbec41 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -188,8 +188,11 @@ MINLINE float sasqrt(float fac); MINLINE float interpf(float a, float b, float t); -MINLINE float minf(float a, float b); -MINLINE float maxf(float a, float b); +MINLINE float min_ff(float a, float b); +MINLINE float max_ff(float a, float b); + +MINLINE int min_ii(int a, int b); +MINLINE int max_ii(int a, int b); MINLINE float signf(float f); diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h index 107b688b36a..80169e952bf 100644 --- a/source/blender/blenlib/BLI_math_geom.h +++ b/source/blender/blenlib/BLI_math_geom.h @@ -95,12 +95,6 @@ int isect_line_sphere_v2(const float l1[2], const float l2[2], const float sp[2] int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[2], const float v4[2], float vi[2]); int isect_seg_seg_v2(const float v1[2], const float v2[2], const float v3[2], const float v4[2]); -/* Returns the number of point of interests - * 0 - lines are colinear - * 1 - lines are coplanar, i1 is set to intersection - * 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) respectively - * */ - int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float i1[3], float i2[3]); @@ -108,35 +102,13 @@ int isect_line_line_strict_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float vi[3], float *r_lambda); -/* if clip is nonzero, will only return true if lambda is >= 0.0 - * (i.e. intersection point is along positive d)*/ int isect_ray_plane_v3(const float p1[3], const float d[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, const int clip); -/** - * Intersect line/plane, optionally treat line as directional (like a ray) with the no_flip argument. - * \param out The intersection point. - * \param l1 The first point of the line. - * \param l2 The second point of the line. - * \param plane_co A point on the plane to intersect with. - * \param plane_no The direction of the plane (does not need to be normalized). - * \param no_flip When true, the intersection point will always be from l1 to l2, even if this is not on the plane. - */ int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3], const float plane_co[3], const float plane_no[3], const short no_flip); -/** - * Intersect two planes, return a point on the intersection and a vector - * that runs on the direction of the intersection. - * Return error code is the same as 'isect_line_line_v3'. - * \param r_isect_co The resulting intersection point. - * \param r_isect_no The resulting vector of the intersection. - * \param plane_a_co The point on the first plane. - * \param plane_a_no The normal of the first plane. - * \param plane_b_co The point on the second plane. - * \param plane_b_no The normal of the second plane. - */ void isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3], const float plane_a_co[3], const float plane_a_no[3], const float plane_b_co[3], const float plane_b_no[3]); @@ -250,14 +222,6 @@ void accumulate_vertex_normals_poly(float **vertnos, float polyno[3], /********************************* Tangents **********************************/ -typedef struct VertexTangent { - struct VertexTangent *next; - float tang[3], uv[2]; -} VertexTangent; - -float *find_vertex_tangent(VertexTangent *vtang, const float uv[2]); -void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, - const float tang[3], const float uv[2]); void tangent_from_uv(float uv1[2], float uv2[2], float uv3[2], float co1[3], float co2[3], float co3[3], float n[3], float tang[3]); @@ -291,6 +255,9 @@ float form_factor_hemi_poly(float p[3], float n[3], void axis_dominant_v3(int *axis_a, int *axis_b, const float axis[3]); +MINLINE int max_axis_v3(const float vec[3]); +MINLINE int min_axis_v3(const float vec[3]); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 83b07bae53f..77c0ec0a88f 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -226,6 +226,7 @@ MINLINE void normal_short_to_float_v3(float r[3], const short n[3]); MINLINE void normal_float_to_short_v3(short r[3], const float n[3]); void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]); +void minmax_v2v2_v2(float min[2], float max[2], const float vec[2]); void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist); void dist_ensure_v2_v2fl(float v1[2], const float v2[2], const float dist); diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h index 810b3b56386..9483d068bb9 100644 --- a/source/blender/blenlib/BLI_pbvh.h +++ b/source/blender/blenlib/BLI_pbvh.h @@ -263,5 +263,7 @@ void BLI_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***nodes, int *totnode); //void BLI_pbvh_node_BB_reset(PBVHNode *node); //void BLI_pbvh_node_BB_expand(PBVHNode *node, float co[3]); +void pbvh_show_diffuse_color_set(PBVH *bvh, int show_diffuse_color); + #endif /* __BLI_PBVH_H__ */ diff --git a/source/blender/blenlib/BLI_rand.h b/source/blender/blenlib/BLI_rand.h index 7dd6c8575c9..3bc9a3bdb32 100644 --- a/source/blender/blenlib/BLI_rand.h +++ b/source/blender/blenlib/BLI_rand.h @@ -40,18 +40,18 @@ struct RNG; typedef struct RNG RNG; -struct RNG *rng_new(unsigned int seed); -void rng_free(struct RNG *rng); +struct RNG *BLI_rng_new(unsigned int seed); +void BLI_rng_free(struct RNG *rng); -void rng_seed(struct RNG *rng, unsigned int seed); -void rng_srandom(struct RNG *rng, unsigned int seed); -int rng_getInt(struct RNG *rng); -double rng_getDouble(struct RNG *rng); -float rng_getFloat(struct RNG *rng); -void rng_shuffleArray(struct RNG *rng, void *data, int elemSize, int numElems); +void BLI_rng_seed(struct RNG *rng, unsigned int seed); +void BLI_rng_srandom(struct RNG *rng, unsigned int seed); +int BLI_rng_get_int(struct RNG *rng); +double BLI_rng_get_double(struct RNG *rng); +float BLI_rng_get_float(struct RNG *rng); +void BLI_rng_shuffle_array(struct RNG *rng, void *data, int elemSize, int numElems); /** Note that skipping is as slow as generating n numbers! */ -void rng_skip(struct RNG *rng, int n); +void BLI_rng_skip(struct RNG *rng, int n); /** Seed the random number generator */ void BLI_srand(unsigned int seed); @@ -94,7 +94,4 @@ int BLI_thread_rand(int thread); /** Allows up to BLENDER_MAX_THREADS threads to address */ float BLI_thread_frand(int thread); - - -#endif - +#endif /* __BLI_RAND_H__ */ diff --git a/source/blender/blenlib/BLI_scanfill.h b/source/blender/blenlib/BLI_scanfill.h index a6b1943cb4d..892afdd0b27 100644 --- a/source/blender/blenlib/BLI_scanfill.h +++ b/source/blender/blenlib/BLI_scanfill.h @@ -103,7 +103,7 @@ void BLI_scanfill_end(ScanFillContext *sf_ctx); /* These callbacks are needed to make the lib finction properly */ /** - * Set a function taking a char* as argument to flag errors. If the + * Set a function taking a (char *) as argument to flag errors. If the * callback is not set, the error is discarded. * \param f The function to use as callback * \attention used in creator.c diff --git a/source/blender/blenlib/BLI_string.h b/source/blender/blenlib/BLI_string.h index 943597b6688..ba906e1221c 100644 --- a/source/blender/blenlib/BLI_string.h +++ b/source/blender/blenlib/BLI_string.h @@ -204,7 +204,7 @@ __attribute__((warn_unused_result)) __attribute__((nonnull)) #endif ; -size_t BLI_strnlen(const char *str, size_t maxlen) +size_t BLI_strnlen(const char *str, const size_t maxlen) #ifdef __GNUC__ __attribute__((warn_unused_result)) __attribute__((nonnull)) diff --git a/source/blender/blenlib/BLI_string_utf8.h b/source/blender/blenlib/BLI_string_utf8.h index 47980d104fe..73f138a750d 100644 --- a/source/blender/blenlib/BLI_string_utf8.h +++ b/source/blender/blenlib/BLI_string_utf8.h @@ -50,6 +50,7 @@ char *BLI_str_prev_char_utf8(const char *p); /* wchar_t functions, copied from blenders own font.c originally */ size_t BLI_wstrlen_utf8(const wchar_t *src); size_t BLI_strlen_utf8(const char *strc); +size_t BLI_strnlen_utf8(const char *start, const size_t maxlen); size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict src, const size_t maxcpy); size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst, const char *__restrict src, const size_t maxcpy); diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 47c2256c1e1..056fa916da1 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -40,43 +40,22 @@ # define TRUE 1 #endif - -#define ELEM(a, b, c) ((a) == (b) || (a) == (c)) -#define ELEM3(a, b, c, d) (ELEM(a, b, c) || (a) == (d) ) -#define ELEM4(a, b, c, d, e) (ELEM(a, b, c) || ELEM(a, d, e) ) -#define ELEM5(a, b, c, d, e, f) (ELEM(a, b, c) || ELEM3(a, d, e, f) ) -#define ELEM6(a, b, c, d, e, f, g) (ELEM(a, b, c) || ELEM4(a, d, e, f, g) ) -#define ELEM7(a, b, c, d, e, f, g, h) (ELEM3(a, b, c, d) || ELEM4(a, e, f, g, h) ) -#define ELEM8(a, b, c, d, e, f, g, h, i) (ELEM4(a, b, c, d, e) || ELEM4(a, f, g, h, i) ) -#define ELEM9(a, b, c, d, e, f, g, h, i, j) (ELEM4(a, b, c, d, e) || ELEM5(a, f, g, h, i, j) ) -#define ELEM10(a, b, c, d, e, f, g, h, i, j, k) (ELEM4(a, b, c, d, e) || ELEM6(a, f, g, h, i, j, k) ) -#define ELEM11(a, b, c, d, e, f, g, h, i, j, k, l) (ELEM4(a, b, c, d, e) || ELEM7(a, f, g, h, i, j, k, l) ) - -/* shift around elements */ -#define SHIFT3(type, a, b, c) { \ - type tmp; \ - tmp = a; \ - a = c; \ - c = b; \ - b = tmp; \ -} (void)0 -#define SHIFT4(type, a, b, c, d) { \ - type tmp; \ - tmp = a; \ - a = d; \ - d = c; \ - c = b; \ - b = tmp; \ -} (void)0 +/* useful for finding bad use of min/max */ +#if 0 +/* gcc only */ +# define _TYPECHECK(a, b) ((void)(((typeof(a) *)0) == ((typeof(b) *)0))) +# define MIN2(x, y) (_TYPECHECK(x, y), (((x) < (y) ? (x) : (y)))) +# define MAX2(x, y) (_TYPECHECK(x, y), (((x) > (y) ? (x) : (y)))) +#endif /* min/max */ -#define MIN2(x, y) ( (x) < (y) ? (x) : (y) ) -#define MIN3(x, y, z) MIN2(MIN2((x), (y)), (z) ) -#define MIN4(x, y, z, a) MIN2(MIN2((x), (y)), MIN2((z), (a)) ) +#define MIN2(x, y) ((x) < (y) ? (x) : (y)) +#define MIN3(x, y, z) (MIN2(MIN2((x), (y)), (z))) +#define MIN4(x, y, z, a) (MIN2(MIN2((x), (y)), MIN2((z), (a)))) -#define MAX2(x, y) ( (x) > (y) ? (x) : (y) ) -#define MAX3(x, y, z) MAX2(MAX2((x), (y)), (z) ) -#define MAX4(x, y, z, a) MAX2(MAX2((x), (y)), MAX2((z), (a)) ) +#define MAX2(x, y) ((x) > (y) ? (x) : (y)) +#define MAX3(x, y, z) (MAX2(MAX2((x), (y)), (z))) +#define MAX4(x, y, z, a) (MAX2(MAX2((x), (y)), MAX2((z), (a)))) #define INIT_MINMAX(min, max) { \ (min)[0] = (min)[1] = (min)[2] = 1.0e30f; \ @@ -116,24 +95,28 @@ /* Causes warning: * incompatible types when assigning to type 'Foo' from type 'Bar' * ... the compiler optimizes away the temp var */ -#ifndef CHECK_TYPE #ifdef __GNUC__ #define CHECK_TYPE(var, type) { \ __typeof(var) *__tmp; \ __tmp = (type *)NULL; \ (void)__tmp; \ } (void)0 + +#define CHECK_TYPE_PAIR(var_a, var_b) { \ + __typeof(var_a) *__tmp; \ + __tmp = (__typeof(var_b) *)NULL; \ + (void)__tmp; \ +} (void)0 #else -#define CHECK_TYPE(var, type) -#endif +# define CHECK_TYPE(var, type) +# define CHECK_TYPE_PAIR(var_a, var_b) #endif /* can be used in simple macros */ #define CHECK_TYPE_INLINE(val, type) \ ((void)(((type *)0) != (val))) -#ifndef SWAP -# define SWAP(type, a, b) { \ +#define SWAP(type, a, b) { \ type sw_ap; \ CHECK_TYPE(a, type); \ CHECK_TYPE(b, type); \ @@ -141,7 +124,53 @@ (a) = (b); \ (b) = sw_ap; \ } (void)0 -#endif + +/* swap with a temp value */ +#define SWAP_TVAL(tval, a, b) { \ + CHECK_TYPE_PAIR(tval, a); \ + CHECK_TYPE_PAIR(tval, b); \ + (tval) = (a); \ + (a) = (b); \ + (b) = (tval); \ +} (void)0 + + +#define ELEM(a, b, c) ((a) == (b) || (a) == (c)) +#define ELEM3(a, b, c, d) (ELEM(a, b, c) || (a) == (d) ) +#define ELEM4(a, b, c, d, e) (ELEM(a, b, c) || ELEM(a, d, e) ) +#define ELEM5(a, b, c, d, e, f) (ELEM(a, b, c) || ELEM3(a, d, e, f) ) +#define ELEM6(a, b, c, d, e, f, g) (ELEM(a, b, c) || ELEM4(a, d, e, f, g) ) +#define ELEM7(a, b, c, d, e, f, g, h) (ELEM3(a, b, c, d) || ELEM4(a, e, f, g, h) ) +#define ELEM8(a, b, c, d, e, f, g, h, i) (ELEM4(a, b, c, d, e) || ELEM4(a, f, g, h, i) ) +#define ELEM9(a, b, c, d, e, f, g, h, i, j) (ELEM4(a, b, c, d, e) || ELEM5(a, f, g, h, i, j) ) +#define ELEM10(a, b, c, d, e, f, g, h, i, j, k) (ELEM4(a, b, c, d, e) || ELEM6(a, f, g, h, i, j, k) ) +#define ELEM11(a, b, c, d, e, f, g, h, i, j, k, l) (ELEM4(a, b, c, d, e) || ELEM7(a, f, g, h, i, j, k, l) ) + +/* shift around elements */ +#define SHIFT3(type, a, b, c) { \ + type tmp; \ + CHECK_TYPE(a, type); \ + CHECK_TYPE(b, type); \ + CHECK_TYPE(c, type); \ + tmp = a; \ + a = c; \ + c = b; \ + b = tmp; \ +} (void)0 + +#define SHIFT4(type, a, b, c, d) { \ + type tmp; \ + CHECK_TYPE(a, type); \ + CHECK_TYPE(b, type); \ + CHECK_TYPE(c, type); \ + CHECK_TYPE(d, type); \ + tmp = a; \ + a = d; \ + d = c; \ + c = b; \ + b = tmp; \ +} (void)0 + #define ABS(a) ( (a) < 0 ? (-(a)) : (a) ) @@ -326,6 +355,13 @@ # define BLI_assert(a) (void)0 #endif +#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 406)) /* gcc4.6+ only */ +# define BLI_STATIC_ASSERT(a, msg) _Static_assert(a, msg); +#else + /* TODO msvc, clang */ +# define BLI_STATIC_ASSERT(a, msg) +#endif + /* hints for branch pradiction, only use in code that runs a _lot_ where */ #ifdef __GNUC__ # define LIKELY(x) __builtin_expect(!!(x), 1) diff --git a/source/blender/blenlib/BLI_voronoi.h b/source/blender/blenlib/BLI_voronoi.h index a67b01c5175..68d7398d89b 100644 --- a/source/blender/blenlib/BLI_voronoi.h +++ b/source/blender/blenlib/BLI_voronoi.h @@ -49,7 +49,7 @@ typedef struct VoronoiEdge { float left[2]; /* point on Voronoi place on the left side of edge */ float right[2]; /* point on Voronoi place on the right side of edge */ - float f, g; /* directional coeffitients satisfying equation y = f*x + g (edge lies on this line) */ + float f, g; /* directional coeffitients satisfying equation y = f * x + g (edge lies on this line) */ /* some edges consist of two parts, so we add the pointer to another part to connect them at the end of an algorithm */ struct VoronoiEdge *neighbour; diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 844407f9e06..0cae9bab531 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -135,7 +135,7 @@ int BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFre BLI_mempool_free(gh->entrypool, e); /* correct but 'e' isn't used before return */ - /* e= n; *//*UNUSED*/ + /* e = n; *//*UNUSED*/ if (p) p->next = n; else gh->buckets[hash] = n; @@ -165,7 +165,7 @@ void *BLI_ghash_pop(GHash *gh, void *key, GHashKeyFreeFP keyfreefp) BLI_mempool_free(gh->entrypool, e); /* correct but 'e' isn't used before return */ - /* e= n; *//*UNUSED*/ + /* e = n; *//*UNUSED*/ if (p) p->next = n; else gh->buckets[hash] = n; diff --git a/source/blender/blenlib/intern/BLI_heap.c b/source/blender/blenlib/intern/BLI_heap.c index 5e0762a5d68..dcc028630e2 100644 --- a/source/blender/blenlib/intern/BLI_heap.c +++ b/source/blender/blenlib/intern/BLI_heap.c @@ -40,9 +40,9 @@ /***/ struct HeapNode { - void *ptr; - float value; - int index; + void *ptr; + float value; + unsigned int index; }; struct Heap { @@ -54,54 +54,43 @@ struct Heap { HeapNode **tree; }; +/* internal functions */ + #define HEAP_PARENT(i) ((i - 1) >> 1) #define HEAP_LEFT(i) ((i << 1) + 1) #define HEAP_RIGHT(i) ((i << 1) + 2) #define HEAP_COMPARE(a, b) (a->value < b->value) -// #define HEAP_EQUALS(a, b) (a->value == b->value) // UNUSED -#define HEAP_SWAP(heap, i, j) \ - { \ - SWAP(int, heap->tree[i]->index, heap->tree[j]->index); \ - SWAP(HeapNode *, heap->tree[i], heap->tree[j]); \ - } (void)0 -/***/ +#if 0 /* UNUSED */ +#define HEAP_EQUALS(a, b) (a->value == b->value) +#endif -/* use when the size of the heap is known in advance */ -Heap *BLI_heap_new_ex(unsigned int tot_reserve) +BLI_INLINE void heap_swap(Heap *heap, const unsigned int i, const unsigned int j) { - Heap *heap = (Heap *)MEM_callocN(sizeof(Heap), __func__); - heap->bufsize = tot_reserve; - heap->tree = (HeapNode **)MEM_mallocN(tot_reserve * sizeof(HeapNode *), "BLIHeapTree"); - heap->arena = BLI_memarena_new(1 << 16, "heap arena"); - - return heap; -} -Heap *BLI_heap_new(void) -{ - return BLI_heap_new_ex(1); +#if 0 + SWAP(unsigned int, heap->tree[i]->index, heap->tree[j]->index); + SWAP(HeapNode *, heap->tree[i], heap->tree[j]); +#else + HeapNode **tree = heap->tree; + union { + unsigned int index; + HeapNode *node; + } tmp; + SWAP_TVAL(tmp.index, tree[i]->index, tree[j]->index); + SWAP_TVAL(tmp.node, tree[i], tree[j]); +#endif } -void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp) +static void heap_down(Heap *heap, unsigned int i) { - int i; + /* size won't change in the loop */ + const unsigned int size = heap->size; - if (ptrfreefp) - for (i = 0; i < heap->size; i++) - ptrfreefp(heap->tree[i]->ptr); - - MEM_freeN(heap->tree); - BLI_memarena_free(heap->arena); - MEM_freeN(heap); -} - -static void BLI_heap_down(Heap *heap, int i) -{ while (1) { - int size = heap->size, smallest; - int l = HEAP_LEFT(i); - int r = HEAP_RIGHT(i); + const unsigned int l = HEAP_LEFT(i); + const unsigned int r = HEAP_RIGHT(i); + unsigned int smallest; smallest = ((l < size) && HEAP_COMPARE(heap->tree[l], heap->tree[i])) ? l : i; @@ -111,46 +100,75 @@ static void BLI_heap_down(Heap *heap, int i) if (smallest == i) break; - HEAP_SWAP(heap, i, smallest); + heap_swap(heap, i, smallest); i = smallest; } } -static void BLI_heap_up(Heap *heap, int i) +static void heap_up(Heap *heap, unsigned int i) { while (i > 0) { - int p = HEAP_PARENT(i); + const unsigned int p = HEAP_PARENT(i); if (HEAP_COMPARE(heap->tree[p], heap->tree[i])) break; - HEAP_SWAP(heap, p, i); + heap_swap(heap, p, i); i = p; } } -HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr) + +/***/ + +/* use when the size of the heap is known in advance */ +Heap *BLI_heap_new_ex(unsigned int tot_reserve) { - HeapNode *node; + Heap *heap = (Heap *)MEM_callocN(sizeof(Heap), __func__); + /* ensure we have at least one so we can keep doubling it */ + heap->bufsize = MAX2(1, tot_reserve); + heap->tree = (HeapNode **)MEM_mallocN(heap->bufsize * sizeof(HeapNode *), "BLIHeapTree"); + heap->arena = BLI_memarena_new(1 << 16, "heap arena"); - if ((heap->size + 1) > heap->bufsize) { - int newsize = heap->bufsize * 2; - HeapNode **newtree; + return heap; +} + +Heap *BLI_heap_new(void) +{ + return BLI_heap_new_ex(1); +} - newtree = (HeapNode **)MEM_mallocN(newsize * sizeof(*newtree), __func__); - memcpy(newtree, heap->tree, sizeof(HeapNode *) * heap->size); - MEM_freeN(heap->tree); +void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp) +{ + unsigned int i; - heap->tree = newtree; - heap->bufsize = newsize; + if (ptrfreefp) { + for (i = 0; i < heap->size; i++) { + ptrfreefp(heap->tree[i]->ptr); + } + } + + MEM_freeN(heap->tree); + BLI_memarena_free(heap->arena); + MEM_freeN(heap); +} + +HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr) +{ + HeapNode *node; + + if (UNLIKELY((heap->size + 1) > heap->bufsize)) { + heap->bufsize *= 2; + heap->tree = MEM_reallocN(heap->tree, heap->bufsize * sizeof(*heap->tree)); } if (heap->freenodes) { node = heap->freenodes; heap->freenodes = (HeapNode *)(((HeapNode *)heap->freenodes)->ptr); } - else + else { node = (HeapNode *)BLI_memarena_alloc(heap->arena, sizeof *node); + } node->value = value; node->ptr = ptr; @@ -160,17 +178,17 @@ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr) heap->size++; - BLI_heap_up(heap, heap->size - 1); + heap_up(heap, heap->size - 1); return node; } -int BLI_heap_empty(Heap *heap) +int BLI_heap_is_empty(Heap *heap) { return (heap->size == 0); } -int BLI_heap_size(Heap *heap) +unsigned int BLI_heap_size(Heap *heap) { return heap->size; } @@ -187,13 +205,14 @@ void *BLI_heap_popmin(Heap *heap) heap->tree[0]->ptr = heap->freenodes; heap->freenodes = heap->tree[0]; - if (heap->size == 1) + if (UNLIKELY(heap->size == 1)) { heap->size--; + } else { - HEAP_SWAP(heap, 0, heap->size - 1); + heap_swap(heap, 0, heap->size - 1); heap->size--; - BLI_heap_down(heap, 0); + heap_down(heap, 0); } return ptr; @@ -201,12 +220,12 @@ void *BLI_heap_popmin(Heap *heap) void BLI_heap_remove(Heap *heap, HeapNode *node) { - int i = node->index; + unsigned int i = node->index; while (i > 0) { - int p = HEAP_PARENT(i); + unsigned int p = HEAP_PARENT(i); - HEAP_SWAP(heap, p, i); + heap_swap(heap, p, i); i = p; } diff --git a/source/blender/blenlib/intern/BLI_kdopbvh.c b/source/blender/blenlib/intern/BLI_kdopbvh.c index 46b0cfeaaac..fe91f91320a 100644 --- a/source/blender/blenlib/intern/BLI_kdopbvh.c +++ b/source/blender/blenlib/intern/BLI_kdopbvh.c @@ -43,6 +43,8 @@ #define MAX_TREETYPE 32 +typedef unsigned char axis_t; + typedef struct BVHNode { struct BVHNode **children; struct BVHNode *parent; /* some user defined traversed need that */ @@ -53,6 +55,7 @@ typedef struct BVHNode { char main_axis; /* Axis used to split this node */ } BVHNode; +/* keep under 26 bytes for speed purposes */ struct BVHTree { BVHNode **nodes; BVHNode *nodearray; /* pre-alloc branch nodes */ @@ -61,16 +64,21 @@ struct BVHTree { float epsilon; /* epslion is used for inflation of the k-dop */ int totleaf; /* leafs */ int totbranch; + axis_t start_axis, stop_axis; /* KDOP_AXES array indices according to axis */ + axis_t axis; /* kdop type (6 => OBB, 7 => AABB, ...) */ char tree_type; /* type of tree (4 => quadtree) */ - char axis; /* kdop type (6 => OBB, 7 => AABB, ...) */ - char start_axis, stop_axis; /* KDOP_AXES array indices according to axis */ }; +/* optimization, ensure we stay small */ +BLI_STATIC_ASSERT((sizeof(void *) == 8 && sizeof(BVHTree) <= 48) || + (sizeof(void *) == 4 && sizeof(BVHTree) <= 32), + "over sized"); + typedef struct BVHOverlapData { BVHTree *tree1, *tree2; BVHTreeOverlap *overlap; int i, max_overlap; /* i is number of overlaps */ - int start_axis, stop_axis; + axis_t start_axis, stop_axis; } BVHOverlapData; typedef struct BVHNearestData { @@ -113,6 +121,15 @@ static float KDOP_AXES[13][3] = { {0, 1.0, -1.0} }; +MINLINE axis_t min_axis(axis_t a, axis_t b) +{ + return (a < b) ? a : b; +} +MINLINE axis_t max_axis(axis_t a, axis_t b) +{ + return (b < a) ? a : b; +} + #if 0 /* @@ -269,7 +286,7 @@ static void bvh_heapsort(BVHNode **a, int lo, int hi, int axis) } #endif -static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis) // returns Sortable +static BVHNode *bvh_medianof3(BVHNode **a, int lo, int mid, int hi, int axis) /* returns Sortable */ { if ((a[mid])->bv[axis] < (a[lo])->bv[axis]) { if ((a[hi])->bv[axis] < (a[mid])->bv[axis]) @@ -374,24 +391,25 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int { float newminmax; float *bv = node->bv; - int i, k; + int k; + axis_t axis_iter; /* don't init boudings for the moving case */ if (!moving) { - for (i = tree->start_axis; i < tree->stop_axis; i++) { - bv[2 * i] = FLT_MAX; - bv[2 * i + 1] = -FLT_MAX; + for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) { + bv[2 * axis_iter] = FLT_MAX; + bv[2 * axis_iter + 1] = -FLT_MAX; } } for (k = 0; k < numpoints; k++) { /* for all Axes. */ - for (i = tree->start_axis; i < tree->stop_axis; i++) { - newminmax = dot_v3v3(&co[k * 3], KDOP_AXES[i]); - if (newminmax < bv[2 * i]) - bv[2 * i] = newminmax; - if (newminmax > bv[(2 * i) + 1]) - bv[(2 * i) + 1] = newminmax; + for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) { + newminmax = dot_v3v3(&co[k * 3], KDOP_AXES[axis_iter]); + if (newminmax < bv[2 * axis_iter]) + bv[2 * axis_iter] = newminmax; + if (newminmax > bv[(2 * axis_iter) + 1]) + bv[(2 * axis_iter) + 1] = newminmax; } } } @@ -400,25 +418,25 @@ static void create_kdop_hull(BVHTree *tree, BVHNode *node, const float *co, int static void refit_kdop_hull(BVHTree *tree, BVHNode *node, int start, int end) { float newmin, newmax; - int i, j; float *bv = node->bv; + int j; + axis_t axis_iter; - - for (i = tree->start_axis; i < tree->stop_axis; i++) { - bv[2 * i] = FLT_MAX; - bv[2 * i + 1] = -FLT_MAX; + for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) { + bv[(2 * axis_iter)] = FLT_MAX; + bv[(2 * axis_iter) + 1] = -FLT_MAX; } for (j = start; j < end; j++) { /* for all Axes. */ - for (i = tree->start_axis; i < tree->stop_axis; i++) { - newmin = tree->nodes[j]->bv[(2 * i)]; - if ((newmin < bv[(2 * i)])) - bv[(2 * i)] = newmin; - - newmax = tree->nodes[j]->bv[(2 * i) + 1]; - if ((newmax > bv[(2 * i) + 1])) - bv[(2 * i) + 1] = newmax; + for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) { + newmin = tree->nodes[j]->bv[(2 * axis_iter)]; + if ((newmin < bv[(2 * axis_iter)])) + bv[(2 * axis_iter)] = newmin; + + newmax = tree->nodes[j]->bv[(2 * axis_iter) + 1]; + if ((newmax > bv[(2 * axis_iter) + 1])) + bv[(2 * axis_iter) + 1] = newmax; } } @@ -451,23 +469,24 @@ static char get_largest_axis(float *bv) * join the children on the parent BV */ static void node_join(BVHTree *tree, BVHNode *node) { - int i, j; - - for (i = tree->start_axis; i < tree->stop_axis; i++) { - node->bv[2 * i] = FLT_MAX; - node->bv[2 * i + 1] = -FLT_MAX; + int i; + axis_t axis_iter; + + for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) { + node->bv[(2 * axis_iter)] = FLT_MAX; + node->bv[(2 * axis_iter) + 1] = -FLT_MAX; } for (i = 0; i < tree->tree_type; i++) { if (node->children[i]) { - for (j = tree->start_axis; j < tree->stop_axis; j++) { + for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) { /* update minimum */ - if (node->children[i]->bv[(2 * j)] < node->bv[(2 * j)]) - node->bv[(2 * j)] = node->children[i]->bv[(2 * j)]; + if (node->children[i]->bv[(2 * axis_iter)] < node->bv[(2 * axis_iter)]) + node->bv[(2 * axis_iter)] = node->children[i]->bv[(2 * axis_iter)]; /* update maximum */ - if (node->children[i]->bv[(2 * j) + 1] > node->bv[(2 * j) + 1]) - node->bv[(2 * j) + 1] = node->children[i]->bv[(2 * j) + 1]; + if (node->children[i]->bv[(2 * axis_iter) + 1] > node->bv[(2 * axis_iter) + 1]) + node->bv[(2 * axis_iter) + 1] = node->children[i]->bv[(2 * axis_iter) + 1]; } } else @@ -482,10 +501,12 @@ static void node_join(BVHTree *tree, BVHNode *node) static void bvhtree_print_tree(BVHTree *tree, BVHNode *node, int depth) { int i; + axis_t axis_iter; + for (i = 0; i < depth; i++) printf(" "); printf(" - %d (%ld): ", node->index, node - tree->nodearray); - for (i = 2 * tree->start_axis; i < 2 * tree->stop_axis; i++) - printf("%.3f ", node->bv[i]); + for (axis_iter = 2 * tree->start_axis; axis_iter < 2 * tree->stop_axis; axis_iter++) + printf("%.3f ", node->bv[axis_iter]); printf("\n"); for (i = 0; i < tree->tree_type; i++) @@ -645,10 +666,10 @@ static int implicit_leafs_index(BVHBuildHelper *data, int depth, int child_index * (looping elements, knowing if its a leaf or not.. etc...) */ -// This functions returns the number of branches needed to have the requested number of leafs. +/* This functions returns the number of branches needed to have the requested number of leafs. */ static int implicit_needed_branches(int tree_type, int leafs) { - return maxi(1, (leafs + tree_type - 3) / (tree_type - 1) ); + return max_ii(1, (leafs + tree_type - 3) / (tree_type - 1) ); } /* @@ -724,7 +745,7 @@ static void non_recursive_bvh_div_nodes(BVHTree *tree, BVHNode *branches_array, /* Loop tree levels (log N) loops */ for (i = 1, depth = 1; i <= num_branches; i = i * tree_type + tree_offset, depth++) { const int first_of_next_level = i * tree_type + tree_offset; - const int end_j = MIN2(first_of_next_level, num_branches + 1); /* index of last branch on this level */ + const int end_j = min_ii(first_of_next_level, num_branches + 1); /* index of last branch on this level */ int j; /* Loop all branches on this level */ @@ -810,7 +831,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) /* tree epsilon must be >= FLT_EPSILON * so that tangent rays can still hit a bounding volume.. * this bug would show up when casting a ray aligned with a kdop-axis and with an edge of 2 faces */ - epsilon = MAX2(FLT_EPSILON, epsilon); + epsilon = max_ff(FLT_EPSILON, epsilon); if (tree) { tree->epsilon = epsilon; @@ -843,7 +864,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) } - //Allocate arrays + /* Allocate arrays */ numnodes = maxsize + implicit_needed_branches(tree_type, maxsize) + tree_type; tree->nodes = (BVHNode **)MEM_callocN(sizeof(BVHNode *) * numnodes, "BVHNodes"); @@ -876,7 +897,7 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis) return NULL; } - //link the dynamic bv and child links + /* link the dynamic bv and child links */ for (i = 0; i < numnodes; i++) { tree->nodearray[i].bv = tree->nodebv + i * axis; tree->nodearray[i].children = tree->nodechild + i * tree_type; @@ -923,7 +944,7 @@ void BLI_bvhtree_balance(BVHTree *tree) int BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints) { - int i; + axis_t axis_iter; BVHNode *node = NULL; /* insert should only possible as long as tree->totbranch is 0 */ @@ -942,9 +963,9 @@ int BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoint node->index = index; /* inflate the bv with some epsilon */ - for (i = tree->start_axis; i < tree->stop_axis; i++) { - node->bv[(2 * i)] -= tree->epsilon; /* minimum */ - node->bv[(2 * i) + 1] += tree->epsilon; /* maximum */ + for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) { + node->bv[(2 * axis_iter)] -= tree->epsilon; /* minimum */ + node->bv[(2 * axis_iter) + 1] += tree->epsilon; /* maximum */ } return 1; @@ -954,8 +975,8 @@ int BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoint /* call before BLI_bvhtree_update_tree() */ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float co[3], const float co_moving[3], int numpoints) { - int i; BVHNode *node = NULL; + axis_t axis_iter; /* check if index exists */ if (index > tree->totleaf) @@ -968,10 +989,10 @@ int BLI_bvhtree_update_node(BVHTree *tree, int index, const float co[3], const f if (co_moving) create_kdop_hull(tree, node, co_moving, numpoints, 1); - // inflate the bv with some epsilon - for (i = tree->start_axis; i < tree->stop_axis; i++) { - node->bv[(2 * i)] -= tree->epsilon; // minimum - node->bv[(2 * i) + 1] += tree->epsilon; // maximum + /* inflate the bv with some epsilon */ + for (axis_iter = tree->start_axis; axis_iter < tree->stop_axis; axis_iter++) { + node->bv[(2 * axis_iter)] -= tree->epsilon; /* minimum */ + node->bv[(2 * axis_iter) + 1] += tree->epsilon; /* maximum */ } return 1; @@ -991,7 +1012,7 @@ void BLI_bvhtree_update_tree(BVHTree *tree) node_join(tree, *index); } -float BLI_bvhtree_getepsilon(BVHTree *tree) +float BLI_bvhtree_getepsilon(const BVHTree *tree) { return tree->epsilon; } @@ -1001,7 +1022,7 @@ float BLI_bvhtree_getepsilon(BVHTree *tree) * BLI_bvhtree_overlap * * overlap - is it possible for 2 bv's to collide ? */ -static int tree_overlap(BVHNode *node1, BVHNode *node2, int start_axis, int stop_axis) +static int tree_overlap(BVHNode *node1, BVHNode *node2, axis_t start_axis, axis_t stop_axis) { float *bv1 = node1->bv; float *bv2 = node2->bv; @@ -1045,7 +1066,7 @@ static void traverse(BVHOverlapData *data, BVHNode *node1, BVHNode *node2) data->max_overlap *= 2; } - // both leafs, insert overlap! + /* both leafs, insert overlap! */ data->overlap[data->i].indexA = node1->index; data->overlap[data->i].indexB = node2->index; @@ -1075,12 +1096,14 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int BVHTreeOverlap *overlap = NULL, *to = NULL; BVHOverlapData **data; - // check for compatibility of both trees (can't compare 14-DOP with 18-DOP) + /* check for compatibility of both trees (can't compare 14-DOP with 18-DOP) */ if ((tree1->axis != tree2->axis) && (tree1->axis == 14 || tree2->axis == 14) && (tree1->axis == 18 || tree2->axis == 18)) return NULL; - // fast check root nodes for collision before doing big splitting + traversal - if (!tree_overlap(tree1->nodes[tree1->totleaf], tree2->nodes[tree2->totleaf], MIN2(tree1->start_axis, tree2->start_axis), MIN2(tree1->stop_axis, tree2->stop_axis))) + /* fast check root nodes for collision before doing big splitting + traversal */ + if (!tree_overlap(tree1->nodes[tree1->totleaf], tree2->nodes[tree2->totleaf], + min_axis(tree1->start_axis, tree2->start_axis), + min_axis(tree1->stop_axis, tree2->stop_axis))) return NULL; data = MEM_callocN(sizeof(BVHOverlapData *) * tree1->tree_type, "BVHOverlapData_star"); @@ -1088,14 +1111,14 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int for (j = 0; j < tree1->tree_type; j++) { data[j] = (BVHOverlapData *)MEM_callocN(sizeof(BVHOverlapData), "BVHOverlapData"); - // init BVHOverlapData - data[j]->overlap = (BVHTreeOverlap *)malloc(sizeof(BVHTreeOverlap) * MAX2(tree1->totleaf, tree2->totleaf)); + /* init BVHOverlapData */ + data[j]->overlap = (BVHTreeOverlap *)malloc(sizeof(BVHTreeOverlap) * max_ii(tree1->totleaf, tree2->totleaf)); data[j]->tree1 = tree1; data[j]->tree2 = tree2; data[j]->max_overlap = MAX2(tree1->totleaf, tree2->totleaf); data[j]->i = 0; - data[j]->start_axis = MIN2(tree1->start_axis, tree2->start_axis); - data[j]->stop_axis = MIN2(tree1->stop_axis, tree2->stop_axis); + data[j]->start_axis = min_axis(tree1->start_axis, tree2->start_axis); + data[j]->stop_axis = min_axis(tree1->stop_axis, tree2->stop_axis); } #pragma omp parallel for private(j) schedule(static) @@ -1123,13 +1146,13 @@ BVHTreeOverlap *BLI_bvhtree_overlap(BVHTree *tree1, BVHTree *tree2, unsigned int return overlap; } -//Determines the nearest point of the given node BV. Returns the squared distance to that point. +/* Determines the nearest point of the given node BV. Returns the squared distance to that point. */ static float calc_nearest_point(const float proj[3], BVHNode *node, float *nearest) { int i; const float *bv = node->bv; - //nearest on AABB hull + /* nearest on AABB hull */ for (i = 0; i != 3; i++, bv += 2) { if (bv[0] > proj[i]) nearest[i] = bv[0]; @@ -1140,7 +1163,7 @@ static float calc_nearest_point(const float proj[3], BVHNode *node, float *neare } #if 0 - //nearest on a general hull + /* nearest on a general hull */ copy_v3_v3(nearest, data->co); for (i = data->tree->start_axis; i != data->tree->stop_axis; i++, bv += 2) { @@ -1167,7 +1190,7 @@ typedef struct NodeDistance { } NodeDistance; -// TODO: use a priority queue to reduce the number of nodes looked on +/* TODO: use a priority queue to reduce the number of nodes looked on */ static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node) { if (node->totnode == 0) { @@ -1179,7 +1202,7 @@ static void dfs_find_nearest_dfs(BVHNearestData *data, BVHNode *node) } } else { - //Better heuristic to pick the closest node to dive on + /* Better heuristic to pick the closest node to dive on */ int i; float nearest[3]; @@ -1259,7 +1282,7 @@ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) dfs_find_nearest_dfs(data, child); } else { - //adjust heap size + /* adjust heap size */ if ((heap_size >= max_heap_size) && ADJUST_MEMORY(default_heap, (void **)&heap, heap_size + 1, &max_heap_size, sizeof(heap[0])) == FALSE) { @@ -1299,22 +1322,23 @@ static void bfs_find_nearest(BVHNearestData *data, BVHNode *node) #endif -int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata) +int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, + BVHTree_NearestPointCallback callback, void *userdata) { - int i; + axis_t axis_iter; BVHNearestData data; BVHNode *root = tree->nodes[tree->totleaf]; - //init data to search + /* init data to search */ data.tree = tree; data.co = co; data.callback = callback; data.userdata = userdata; - for (i = data.tree->start_axis; i != data.tree->stop_axis; i++) { - data.proj[i] = dot_v3v3(data.co, KDOP_AXES[i]); + for (axis_iter = data.tree->start_axis; axis_iter != data.tree->stop_axis; axis_iter++) { + data.proj[axis_iter] = dot_v3v3(data.co, KDOP_AXES[axis_iter]); } if (nearest) { @@ -1354,7 +1378,7 @@ static float ray_nearest_hit(BVHRayCastData *data, const float bv[6]) for (i = 0; i != 3; i++, bv += 2) { if (data->ray_dot_axis[i] == 0.0f) { - //axis aligned ray + /* axis aligned ray */ if (data->ray.origin[i] < bv[0] - data->ray.radius || data->ray.origin[i] > bv[1] + data->ray.radius) { @@ -1469,12 +1493,13 @@ static void iterative_raycast(BVHRayCastData *data, BVHNode *node) } else { node = node->children[0]; - } + } } } #endif -int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata) +int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, + BVHTree_RayCastCallback callback, void *userdata) { int i; BVHRayCastData data; @@ -1531,7 +1556,7 @@ float BLI_bvhtree_bb_raycast(const float bv[6], const float light_start[3], cons data.hit.dist = FLT_MAX; - // get light direction + /* get light direction */ data.ray.direction[0] = light_end[0] - light_start[0]; data.ray.direction[1] = light_end[1] - light_start[1]; data.ray.direction[2] = light_end[2] - light_start[2]; @@ -1563,7 +1588,7 @@ float BLI_bvhtree_bb_raycast(const float bv[6], const float light_start[3], cons typedef struct RangeQueryData { BVHTree *tree; const float *center; - float radius; //squared radius + float radius; /* squared radius */ int hits; @@ -1578,7 +1603,7 @@ static void dfs_range_query(RangeQueryData *data, BVHNode *node) { if (node->totnode == 0) { #if 0 /*UNUSED*/ - //Calculate the node min-coords (if the node was a point then this is the point coordinates) + /* Calculate the node min-coords (if the node was a point then this is the point coordinates) */ float co[3]; co[0] = node->bv[0]; co[1] = node->bv[2]; @@ -1591,7 +1616,7 @@ static void dfs_range_query(RangeQueryData *data, BVHNode *node) float nearest[3]; float dist = calc_nearest_point(data->center, node->children[i], nearest); if (dist < data->radius) { - //Its a leaf.. call the callback + /* Its a leaf.. call the callback */ if (node->children[i]->totnode == 0) { data->hits++; data->callback(data->userdata, node->children[i]->index, dist); diff --git a/source/blender/blenlib/intern/BLI_kdtree.c b/source/blender/blenlib/intern/BLI_kdtree.c index 900580317f2..dd6c25ab6ad 100644 --- a/source/blender/blenlib/intern/BLI_kdtree.c +++ b/source/blender/blenlib/intern/BLI_kdtree.c @@ -30,16 +30,12 @@ * \ingroup bli */ - - #include "MEM_guardedalloc.h" #include "BLI_math.h" #include "BLI_kdtree.h" +#include "BLI_utildefines.h" -#ifndef SWAP -# define SWAP(type, a, b) { type sw_ap; sw_ap = (a); (a) = (b); (b) = sw_ap; } (void)0 -#endif typedef struct KDTreeNode { struct KDTreeNode *left, *right; diff --git a/source/blender/blenlib/intern/DLRB_tree.c b/source/blender/blenlib/intern/DLRB_tree.c index 858eef0b2df..688372b3a28 100644 --- a/source/blender/blenlib/intern/DLRB_tree.c +++ b/source/blender/blenlib/intern/DLRB_tree.c @@ -502,7 +502,7 @@ void BLI_dlrbTree_insert(DLRBT_Tree *tree, DLRBT_Node *node) /* ----- */ /* Add the given data to the tree, and return the node added */ -// NOTE: for duplicates, the update_cb is called (if available), and the existing node is returned +/* NOTE: for duplicates, the update_cb is called (if available), and the existing node is returned */ DLRBT_Node *BLI_dlrbTree_add(DLRBT_Tree *tree, DLRBT_Comparator_FP cmp_cb, DLRBT_NAlloc_FP new_cb, DLRBT_NUpdate_FP update_cb, void *data) { diff --git a/source/blender/blenlib/intern/boxpack2d.c b/source/blender/blenlib/intern/boxpack2d.c index 1c70a612c4f..8a97fdcab67 100644 --- a/source/blender/blenlib/intern/boxpack2d.c +++ b/source/blender/blenlib/intern/boxpack2d.c @@ -73,7 +73,7 @@ typedef struct BoxVert { ((b)->v[BR]->x = (b)->v[TR]->x) #define UPDATE_V34Y(b) ((b)->v[TL]->y = (b)->v[TR]->y); \ ((b)->v[BR]->y = (b)->v[BL]->y) - + /* UNUSED */ // #define UPDATE_V34(b) UPDATE_V34X(b); UPDATE_V34Y(b) @@ -96,7 +96,7 @@ typedef struct BoxVert { BOXTOP(b1) - EPSILON <= BOXBOTTOM(b2)) /* compiler should inline */ -static float maxf(const float a, const float b) { return b > a ? b : a; } +static float max_ff(const float a, const float b) { return b > a ? b : a; } #if 0 #define BOXDEBUG(b) \ @@ -133,8 +133,8 @@ static int vertex_sort(const void *p1, const void *p2) v1 = vertarray + ((int *)p1)[0]; v2 = vertarray + ((int *)p2)[0]; - a1 = maxf(v1->x + box_width, v1->y + box_height); - a2 = maxf(v2->x + box_width, v2->y + box_height); + a1 = max_ff(v1->x + box_width, v1->y + box_height); + a2 = max_ff(v2->x + box_width, v2->y + box_height); /* sort largest to smallest */ if (a1 > a2) return 1; @@ -314,8 +314,8 @@ void BLI_box_pack_2D(BoxPack *boxarray, const int len, float *tot_width, float * if (!isect) { /* maintain the total width and height */ - (*tot_width) = maxf(BOXRIGHT(box), (*tot_width)); - (*tot_height) = maxf(BOXTOP(box), (*tot_height)); + (*tot_width) = max_ff(BOXRIGHT(box), (*tot_width)); + (*tot_height) = max_ff(BOXTOP(box), (*tot_height)); /* Place the box */ vert->free &= ~quad_flags[j]; diff --git a/source/blender/blenlib/intern/bpath.c b/source/blender/blenlib/intern/bpath.c index bdcb3cb9806..2f335b557fe 100644 --- a/source/blender/blenlib/intern/bpath.c +++ b/source/blender/blenlib/intern/bpath.c @@ -86,7 +86,7 @@ static int checkMissingFiles_visit_cb(void *userdata, char *UNUSED(path_dst), co ReportList *reports = (ReportList *)userdata; if (!BLI_exists(path_src)) { - BKE_reportf(reports, RPT_WARNING, "Path Not Found \"%s\"", path_src); + BKE_reportf(reports, RPT_WARNING, "Path '%s' not found", path_src); } return FALSE; @@ -123,7 +123,7 @@ static int makeFilesRelative_visit_cb(void *userdata, char *path_dst, const char data->count_changed++; } else { - BKE_reportf(data->reports, RPT_WARNING, "Path cant be made relative \"%s\"", path_src); + BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made relative", path_src); data->count_failed++; } return TRUE; @@ -145,7 +145,7 @@ void BLI_bpath_relative_convert(Main *bmain, const char *basedir, ReportList *re BLI_bpath_traverse_main(bmain, makeFilesRelative_visit_cb, 0, (void *)&data); BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO, - "Total files %d|Changed %d|Failed %d", + "Total files %d | Changed %d | Failed %d", data.count_tot, data.count_changed, data.count_failed); } @@ -165,7 +165,7 @@ static int makeFilesAbsolute_visit_cb(void *userdata, char *path_dst, const char data->count_changed++; } else { - BKE_reportf(data->reports, RPT_WARNING, "Path cant be made absolute \"%s\"", path_src); + BKE_reportf(data->reports, RPT_WARNING, "Path '%s' cannot be made absolute", path_src); data->count_failed++; } return TRUE; @@ -188,13 +188,13 @@ void BLI_bpath_absolute_convert(Main *bmain, const char *basedir, ReportList *re BLI_bpath_traverse_main(bmain, makeFilesAbsolute_visit_cb, 0, (void *)&data); BKE_reportf(reports, data.count_failed ? RPT_WARNING : RPT_INFO, - "Total files %d|Changed %d|Failed %d", + "Total files %d | Changed %d | Failed %d", data.count_tot, data.count_changed, data.count_failed); } /** * find this file recursively, use the biggest file so thumbnails don't get used by mistake - * \param filename_new: the path will be copied here, caller must initialize as empyu string. + * \param filename_new: the path will be copied here, caller must initialize as empty string. * \param dirname: subdir to search * \param filename: set this filename * \param filesize: filesize for the file @@ -280,13 +280,13 @@ static int findMissingFiles_visit_cb(void *userdata, char *path_dst, const char if (filesize == -1) { /* could not open dir */ BKE_reportf(data->reports, RPT_WARNING, - "Could open directory \"%s\"", + "Could not open directory '%s'", BLI_path_basename(data->searchdir)); return FALSE; } else if (found == FALSE) { BKE_reportf(data->reports, RPT_WARNING, - "Could not find \"%s\" in \"%s\"", + "Could not find '%s' in '%s'", BLI_path_basename((char *)path_src), data->searchdir); return FALSE; } diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index daedd39d693..0a87316aa81 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -271,7 +271,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf (len_squared_v2v2(bezt->vec[1], bezt->vec[2]) > 0.0001f * 0.0001f) && (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > 0.0002f * 0.0001f) && (len_squared_v2v2(bezt->vec[0], bezt->vec[2]) > - maxf(len_squared_v2v2(bezt->vec[0], bezt->vec[1]), + max_ff(len_squared_v2v2(bezt->vec[0], bezt->vec[1]), len_squared_v2v2(bezt->vec[1], bezt->vec[2])))) { bezt->h1 = bezt->h2 = HD_ALIGN; @@ -282,7 +282,7 @@ static void freetypechar_to_vchar(FT_Face face, FT_ULong charcode, VFontData *vf } } if (npoints) MEM_freeN(npoints); - if (onpoints) MEM_freeN(onpoints); + if (onpoints) MEM_freeN(onpoints); } } @@ -404,7 +404,7 @@ static VFontData *objfnt_to_ftvfontdata(PackedFile *pf) lcode = charcode; } - return vfd; + return vfd; } @@ -473,10 +473,10 @@ VFontData *BLI_vfontdata_from_freetypefont(PackedFile *pf) VFontData *vfd = NULL; int success = 0; - //init Freetype + /* init Freetype */ err = FT_Init_FreeType(&library); if (err) { - //XXX error("Failed to load the Freetype font library"); + /* XXX error("Failed to load the Freetype font library"); */ return NULL; } @@ -486,7 +486,7 @@ VFontData *BLI_vfontdata_from_freetypefont(PackedFile *pf) vfd = objfnt_to_ftvfontdata(pf); } - //free Freetype + /* free Freetype */ FT_Done_FreeType(library); return vfd; @@ -518,16 +518,16 @@ int BLI_vfontchar_from_freetypefont(VFont *vfont, unsigned long character) #if 0 -// Freetype2 Outline struct +/* Freetype2 Outline struct */ typedef struct FT_Outline_ - { +{ short n_contours; /* number of contours in glyph */ short n_points; /* number of points in the glyph */ - FT_Vector* points; /* the outline's points */ - char* tags; /* the points flags */ - short* contours; /* the contour end points */ + FT_Vector *points; /* the outline's points */ + char *tags; /* the points flags */ + short *contours; /* the contour end points */ int flags; /* outline masks */ } FT_Outline; diff --git a/source/blender/blenlib/intern/graph.c b/source/blender/blenlib/intern/graph.c index 51d7cb58b00..a93bbd97b51 100644 --- a/source/blender/blenlib/intern/graph.c +++ b/source/blender/blenlib/intern/graph.c @@ -353,12 +353,12 @@ int BLI_isGraphCyclic(BGraph *graph) /* Mark all nodes as not visited */ BLI_flagNodes(graph, 0); - /* detectCycles in subgraphs */ + /* detectCycles in subgraphs */ for (node = graph->nodes.first; node && value == 0; node = node->next) { /* only for nodes in subgraphs that haven't been visited yet */ if (node->flag == 0) { value = value || detectCycle(node, NULL); - } + } } return value; @@ -639,11 +639,11 @@ static void handleRadialSymmetry(BGraph *graph, BNode *root_node, int depth, flo /* if not dispatching already and on last arc * Dispatch using current arc as last - * */ + */ if (dispatch == 0 && i == total - 1) { last = i; dispatch = 1; - } + } if (dispatch) { int sub_total = last - first + 1; @@ -796,7 +796,7 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int /* count the number of branches in this symmetry group * and determinate the axis of symmetry - * */ + */ for (i = 0; i < node->degree; i++) { BArc *connectedArc = node->arcs[i]; @@ -821,7 +821,7 @@ static void markdownSecondarySymmetry(BGraph *graph, BNode *node, int depth, int handleRadialSymmetry(graph, node, depth, axis, limit); } - /* markdown secondary symetries */ + /* markdown secondary symetries */ for (i = 0; i < node->degree; i++) { BArc *connectedArc = node->arcs[i]; @@ -836,7 +836,7 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level { int i; - /* if arc is null, we start straight from a node */ + /* if arc is null, we start straight from a node */ if (arc) { arc->symmetry_level = level; @@ -875,7 +875,7 @@ static void markdownSymmetryArc(BGraph *graph, BArc *arc, BNode *node, int level /* not on the symmetry axis */ issymmetryAxis = 0; break; - } + } } } diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index ad718ed8e11..9f6f409c473 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -141,7 +141,7 @@ void BLI_insertlink(ListBase *listbase, void *vprevlink, void *vnewlink) if (listbase == NULL) return; /* empty list */ - if (listbase->first == NULL) { + if (listbase->first == NULL) { listbase->first = newlink; listbase->last = newlink; @@ -149,7 +149,7 @@ void BLI_insertlink(ListBase *listbase, void *vprevlink, void *vnewlink) } /* insert before first element */ - if (prevlink == NULL) { + if (prevlink == NULL) { newlink->next = listbase->first; newlink->prev = NULL; newlink->next->prev = newlink; @@ -203,14 +203,14 @@ void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) if (listbase == NULL) return; /* empty list */ - if (listbase->first == NULL) { + if (listbase->first == NULL) { listbase->first = newlink; listbase->last = newlink; return; } /* insert at head of list */ - if (prevlink == NULL) { + if (prevlink == NULL) { newlink->prev = NULL; newlink->next = listbase->first; ((Link *)listbase->first)->prev = newlink; @@ -238,14 +238,14 @@ void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) if (listbase == NULL) return; /* empty list */ - if (listbase->first == NULL) { + if (listbase->first == NULL) { listbase->first = newlink; listbase->last = newlink; return; } /* insert at end of list */ - if (nextlink == NULL) { + if (nextlink == NULL) { newlink->prev = listbase->last; newlink->next = NULL; ((Link *)listbase->last)->next = newlink; diff --git a/source/blender/blenlib/intern/math_base_inline.c b/source/blender/blenlib/intern/math_base_inline.c index 21ecfccf9d9..f27da759482 100644 --- a/source/blender/blenlib/intern/math_base_inline.c +++ b/source/blender/blenlib/intern/math_base_inline.c @@ -139,20 +139,20 @@ MINLINE int power_of_2_min_i(int n) return n; } -MINLINE float minf(float a, float b) +MINLINE float min_ff(float a, float b) { return (a < b) ? a : b; } -MINLINE float maxf(float a, float b) +MINLINE float max_ff(float a, float b) { return (a > b) ? a : b; } -MINLINE int mini(int a, int b) +MINLINE int min_ii(int a, int b) { return (a < b) ? a : b; } -MINLINE int maxi(int a, int b) +MINLINE int max_ii(int a, int b) { return (b < a) ? a : b; } diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index 50cef039acf..a01ba846cab 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -404,8 +404,8 @@ int isect_seg_seg_v2_point(const float v1[2], const float v2[2], const float v3[ if (u > u2) SWAP(float, u, u2); if (u > 1.0f + eps || u2 < -eps) return -1; /* non-ovlerlapping segments */ - else if (maxf(0.0f, u) == minf(1.0f, u2)) { /* one common point: can return result */ - interp_v2_v2v2(vi, v1, v2, maxf(0, u)); + else if (max_ff(0.0f, u) == min_ff(1.0f, u2)) { /* one common point: can return result */ + interp_v2_v2v2(vi, v1, v2, max_ff(0, u)); return 1; } } @@ -560,7 +560,8 @@ int isect_line_sphere_v2(const float l1[2], const float l2[2], } } -/* +/** + * \return * -1: collinear * 1: intersection */ @@ -758,6 +759,10 @@ int isect_ray_tri_v3(const float p1[3], const float d[3], return 1; } +/** + * if clip is nonzero, will only return true if lambda is >= 0.0 + * (i.e. intersection point is along positive d) + */ int isect_ray_plane_v3(const float p1[3], const float d[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, const int clip) @@ -876,6 +881,16 @@ int isect_ray_tri_threshold_v3(const float p1[3], const float d[3], return 1; } +/** + * Intersect line/plane, optionally treat line as directional (like a ray) with the no_flip argument. + * + * \param out The intersection point. + * \param l1 The first point of the line. + * \param l2 The second point of the line. + * \param plane_co A point on the plane to intersect with. + * \param plane_no The direction of the plane (does not need to be normalized). + * \param no_flip When true, the intersection point will always be from l1 to l2, even if this is not on the plane. + */ int isect_line_plane_v3(float out[3], const float l1[3], const float l2[3], const float plane_co[3], const float plane_no[3], const short no_flip) @@ -921,7 +936,20 @@ int isect_line_plane_v3(float out[3], } } -/* note: return normal isn't unit length */ +/** + * Intersect two planes, return a point on the intersection and a vector + * that runs on the direction of the intersection. + * Return error code is the same as 'isect_line_line_v3'. + * + * \param r_isect_co The resulting intersection point. + * \param r_isect_no The resulting vector of the intersection. + * \param plane_a_co The point on the first plane. + * \param plane_a_no The normal of the first plane. + * \param plane_b_co The point on the second plane. + * \param plane_b_no The normal of the second plane. + * + * \note return normal isn't unit length + */ void isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3], const float plane_a_co[3], const float plane_a_no[3], const float plane_b_co[3], const float plane_b_no[3]) @@ -939,10 +967,10 @@ void isect_plane_plane_v3(float r_isect_co[3], float r_isect_no[3], /* "Improved Collision detection and Response" */ static int getLowestRoot(const float a, const float b, const float c, const float maxR, float *root) { - // Check if a solution exists + /* Check if a solution exists */ float determinant = b * b - 4.0f * a * c; - // If determinant is negative it means no solutions. + /* If determinant is negative it means no solutions. */ if (determinant >= 0.0f) { /* calculate the two roots: (if determinant == 0 then * x1==x2 but lets disregard that slight optimization) */ @@ -950,24 +978,24 @@ static int getLowestRoot(const float a, const float b, const float c, const floa float r1 = (-b - sqrtD) / (2.0f * a); float r2 = (-b + sqrtD) / (2.0f * a); - // Sort so x1 <= x2 + /* Sort so x1 <= x2 */ if (r1 > r2) SWAP(float, r1, r2); - // Get lowest root: + /* Get lowest root: */ if (r1 > 0.0f && r1 < maxR) { *root = r1; return 1; } - // It is possible that we want x2 - this can happen - // if x1 < 0 + /* It is possible that we want x2 - this can happen */ + /* if x1 < 0 */ if (r2 > 0.0f && r2 < maxR) { *root = r2; return 1; } } - // No (valid) solutions + /* No (valid) solutions */ return 0; } @@ -1080,7 +1108,7 @@ int isect_sweeping_sphere_tri_v3(const float p1[3], const float p2[3], const flo } /*---test edges---*/ - sub_v3_v3v3(e3, v2, v1); //wasnt yet calculated + sub_v3_v3v3(e3, v2, v1); /* wasnt yet calculated */ /*e1*/ @@ -1206,11 +1234,12 @@ int isect_axial_line_tri_v3(const int axis, const float p1[3], const float p2[3] return 1; } -/* Returns the number of point of interests +/** + * \return The number of point of interests * 0 - lines are colinear * 1 - lines are coplanar, i1 is set to intersection * 2 - i1 and i2 are the nearest points on line 1 (v1, v2) and line 2 (v3, v4) respectively - * */ + */ int isect_line_line_v3(const float v1[3], const float v2[3], const float v3[3], const float v4[3], float i1[3], float i2[3]) { float a[3], b[3], c[3], ab[3], cb[3], dir1[3], dir2[3]; @@ -1344,7 +1373,7 @@ void isect_ray_aabb_initialize(IsectRayAABBData *data, const float ray_start[3], /* Adapted from http://www.gamedev.net/community/forums/topic.asp?topic_id=459973 */ int isect_ray_aabb(const IsectRayAABBData *data, const float bb_min[3], - const float bb_max[3], float *tmin_out) + const float bb_max[3], float *tmin_out) { float bbox[2][3]; float tmin, tmax, tymin, tymax, tzmin, tzmax; @@ -1587,7 +1616,7 @@ void isect_point_face_uv_v2(const int isquad, } } -#if 0 // XXX this version used to be used in isect_point_tri_v2_int() and was called IsPointInTri2D +#if 0 /* XXX this version used to be used in isect_point_tri_v2_int() and was called IsPointInTri2D */ int isect_point_tri_v2(float pt[2], float v1[2], float v2[2], float v3[2]) { @@ -1777,7 +1806,7 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, signed char ix; signed char iy; - // if x1 == x2 or y1 == y2, then it does not matter what we set here + /* if x1 == x2 or y1 == y2, then it does not matter what we set here */ int delta_x = (x2 > x1 ? (ix = 1, x2 - x1) : (ix = -1, x1 - x2)) << 1; int delta_y = (y2 > y1 ? (iy = 1, y2 - y1) : (iy = -1, y1 - y2)) << 1; @@ -1786,7 +1815,7 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, } if (delta_x >= delta_y) { - // error may go below zero + /* error may go below zero */ int error = delta_y - (delta_x >> 1); while (x1 != x2) { @@ -1795,9 +1824,9 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, y1 += iy; error -= delta_x; } - // else do nothing + /* else do nothing */ } - // else do nothing + /* else do nothing */ x1 += ix; error += delta_y; @@ -1808,7 +1837,7 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, } } else { - // error may go below zero + /* error may go below zero */ int error = delta_x - (delta_y >> 1); while (y1 != y2) { @@ -1817,9 +1846,9 @@ void plot_line_v2v2i(const int p1[2], const int p2[2], int (*callback)(int, int, x1 += ix; error -= delta_y; } - // else do nothing + /* else do nothing */ } - // else do nothing + /* else do nothing */ y1 += iy; error += delta_x; @@ -2323,10 +2352,10 @@ void resolve_quad_uv(float r_uv[2], const float st[2], const float st0[2], const (st2[0] * st3[1] - st2[1] * st3[0]) + (st3[0] * st0[1] - st3[1] * st0[0]); /* X is 2D cross product (determinant) - * A= (p0-p) X (p0-p3)*/ + * A = (p0 - p) X (p0 - p3)*/ const double a = (st0[0] - st[0]) * (st0[1] - st3[1]) - (st0[1] - st[1]) * (st0[0] - st3[0]); - /* B= ( (p0-p) X (p1-p2) + (p1-p) X (p0-p3) ) / 2 */ + /* B = ( (p0 - p) X (p1 - p2) + (p1 - p) X (p0 - p3) ) / 2 */ const double b = 0.5 * (((st0[0] - st[0]) * (st1[1] - st2[1]) - (st0[1] - st[1]) * (st1[0] - st2[0])) + ((st1[0] - st[0]) * (st0[1] - st3[1]) - (st1[1] - st[1]) * (st0[0] - st3[0]))); @@ -2334,7 +2363,7 @@ void resolve_quad_uv(float r_uv[2], const float st[2], const float st0[2], const const double fC = (st1[0] - st[0]) * (st1[1] - st2[1]) - (st1[1] - st[1]) * (st1[0] - st2[0]); const double denom = a - 2 * b + fC; - // clear outputs + /* clear outputs */ zero_v2(r_uv); if (IS_ZERO(denom) != 0) { @@ -2650,7 +2679,7 @@ void accumulate_vertex_normals(float n1[3], float n2[3], float n3[3], const float *cur_edge = vdiffs[i]; const float fac = saacos(-dot_v3v3(cur_edge, prev_edge)); - // accumulate + /* accumulate */ madd_v3_v3fl(vn[i], f_no, fac); prev_edge = cur_edge; } @@ -2691,50 +2720,6 @@ void accumulate_vertex_normals_poly(float **vertnos, float polyno[3], /********************************* Tangents **********************************/ -/* For normal map tangents we need to detect uv boundaries, and only average - * tangents in case the uvs are connected. Alternative would be to store 1 - * tangent per face rather than 4 per face vertex, but that's not compatible - * with games */ - - -/* from BKE_mesh.h */ -#define STD_UV_CONNECT_LIMIT 0.0001f - -void sum_or_add_vertex_tangent(void *arena, VertexTangent **vtang, const float tang[3], const float uv[2]) -{ - VertexTangent *vt; - - /* find a tangent with connected uvs */ - for (vt = *vtang; vt; vt = vt->next) { - if (fabsf(uv[0] - vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1] - vt->uv[1]) < STD_UV_CONNECT_LIMIT) { - add_v3_v3(vt->tang, tang); - return; - } - } - - /* if not found, append a new one */ - vt = BLI_memarena_alloc((MemArena *) arena, sizeof(VertexTangent)); - copy_v3_v3(vt->tang, tang); - vt->uv[0] = uv[0]; - vt->uv[1] = uv[1]; - - if (*vtang) - vt->next = *vtang; - *vtang = vt; -} - -float *find_vertex_tangent(VertexTangent *vtang, const float uv[2]) -{ - VertexTangent *vt; - static float nulltang[3] = {0.0f, 0.0f, 0.0f}; - - for (vt = vtang; vt; vt = vt->next) - if (fabsf(uv[0] - vt->uv[0]) < STD_UV_CONNECT_LIMIT && fabsf(uv[1] - vt->uv[1]) < STD_UV_CONNECT_LIMIT) - return vt->tang; - - return nulltang; /* shouldn't happen, except for nan or so */ -} - void tangent_from_uv(float uv1[2], float uv2[2], float uv3[3], float co1[3], float co2[3], float co3[3], float n[3], float tang[3]) { float s1 = uv2[0] - uv1[0]; diff --git a/source/blender/blenlib/intern/math_geom_inline.c b/source/blender/blenlib/intern/math_geom_inline.c index 0d4c797cefb..01585c93bc8 100644 --- a/source/blender/blenlib/intern/math_geom_inline.c +++ b/source/blender/blenlib/intern/math_geom_inline.c @@ -137,4 +137,24 @@ MINLINE void madd_sh_shfl(float r[9], const float sh[9], const float f) add_sh_shsh(r, r, tmp); } +MINLINE int max_axis_v3(const float vec[3]) +{ + const float x = vec[0]; + const float y = vec[1]; + const float z = vec[2]; + return ((x > y) ? + ((x > z) ? 0 : 2) : + ((y > z) ? 1 : 2)); +} + +MINLINE int min_axis_v3(const float vec[3]) +{ + const float x = vec[0]; + const float y = vec[1]; + const float z = vec[2]; + return ((x < y) ? + ((x < z) ? 0 : 2) : + ((y < z) ? 1 : 2)); +} + #endif /* __MATH_GEOM_INLINE_C__ */ diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 1f61b37a1af..f4a65564fd4 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1400,7 +1400,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) int m = 4; int n = 4; int maxiter = 200; - int nu = minf(m, n); + int nu = min_ff(m, n); float *work = work1; float *e = work2; @@ -1408,22 +1408,22 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) int i = 0, j = 0, k = 0, p, pp, iter; - // Reduce A to bidiagonal form, storing the diagonal elements - // in s and the super-diagonal elements in e. + /* Reduce A to bidiagonal form, storing the diagonal elements + * in s and the super-diagonal elements in e. */ - int nct = minf(m - 1, n); - int nrt = maxf(0, minf(n - 2, m)); + int nct = min_ff(m - 1, n); + int nrt = max_ff(0, min_ff(n - 2, m)); copy_m4_m4(A, A_); zero_m4(U); zero_v4(s); - for (k = 0; k < maxf(nct, nrt); k++) { + for (k = 0; k < max_ff(nct, nrt); k++) { if (k < nct) { - // Compute the transformation for the k-th column and - // place the k-th diagonal in s[k]. - // Compute 2-norm of k-th column without under/overflow. + /* Compute the transformation for the k-th column and + * place the k-th diagonal in s[k]. + * Compute 2-norm of k-th column without under/overflow. */ s[k] = 0; for (i = k; i < m; i++) { s[k] = hypotf(s[k], A[i][k]); @@ -1444,7 +1444,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) for (j = k + 1; j < n; j++) { if ((k < nct) && (s[k] != 0.0f)) { - // Apply the transformation. + /* Apply the transformation. */ float t = 0; for (i = k; i < m; i++) { @@ -1456,24 +1456,24 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) } } - // Place the k-th row of A into e for the - // subsequent calculation of the row transformation. + /* Place the k-th row of A into e for the */ + /* subsequent calculation of the row transformation. */ e[j] = A[k][j]; } if (k < nct) { - // Place the transformation in U for subsequent back - // multiplication. + /* Place the transformation in U for subsequent back + * multiplication. */ for (i = k; i < m; i++) U[i][k] = A[i][k]; } if (k < nrt) { - // Compute the k-th row transformation and place the - // k-th super-diagonal in e[k]. - // Compute 2-norm without under/overflow. + /* Compute the k-th row transformation and place the + * k-th super-diagonal in e[k]. + * Compute 2-norm without under/overflow. */ e[k] = 0; for (i = k + 1; i < n; i++) { e[k] = hypotf(e[k], e[i]); @@ -1493,7 +1493,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) if ((k + 1 < m) & (e[k] != 0.0f)) { float invek1; - // Apply the transformation. + /* Apply the transformation. */ for (i = k + 1; i < m; i++) { work[i] = 0.0f; @@ -1512,17 +1512,17 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) } } - // Place the transformation in V for subsequent - // back multiplication. + /* Place the transformation in V for subsequent + * back multiplication. */ for (i = k + 1; i < n; i++) V[i][k] = e[i]; } } - // Set up the final bidiagonal matrix or order p. + /* Set up the final bidiagonal matrix or order p. */ - p = minf(n, m + 1); + p = min_ff(n, m + 1); if (nct < n) { s[nct] = A[nct][nct]; } @@ -1534,7 +1534,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) } e[p - 1] = 0.0f; - // If required, generate U. + /* If required, generate U. */ for (j = nct; j < nu; j++) { for (i = 0; i < m; i++) { @@ -1570,7 +1570,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) } } - // If required, generate V. + /* If required, generate V. */ for (k = n - 1; k >= 0; k--) { if ((k < nrt) & (e[k] != 0.0f)) { @@ -1591,7 +1591,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) V[k][k] = 1.0f; } - // Main iteration loop for the singular values. + /* Main iteration loop for the singular values. */ pp = p - 1; iter = 0; @@ -1599,20 +1599,20 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) while (p > 0) { int kase = 0; - // Test for maximum iterations to avoid infinite loop + /* Test for maximum iterations to avoid infinite loop */ if (maxiter == 0) break; maxiter--; - // This section of the program inspects for - // negligible elements in the s and e arrays. On - // completion the variables kase and k are set as follows. - - // kase = 1 if s(p) and e[k - 1] are negligible and k<p - // kase = 2 if s(k) is negligible and k<p - // kase = 3 if e[k - 1] is negligible, k<p, and - // s(k), ..., s(p) are not negligible (qr step). - // kase = 4 if e(p - 1) is negligible (convergence). + /* This section of the program inspects for + * negligible elements in the s and e arrays. On + * completion the variables kase and k are set as follows. + * + * kase = 1 if s(p) and e[k - 1] are negligible and k<p + * kase = 2 if s(k) is negligible and k<p + * kase = 3 if e[k - 1] is negligible, k<p, and + * s(k), ..., s(p) are not negligible (qr step). + * kase = 4 if e(p - 1) is negligible (convergence). */ for (k = p - 2; k >= -1; k--) { if (k == -1) { @@ -1653,11 +1653,11 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) } k++; - // Perform the task indicated by kase. + /* Perform the task indicated by kase. */ switch (kase) { - // Deflate negligible s(p). + /* Deflate negligible s(p). */ case 1: { @@ -1683,7 +1683,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) break; } - // Split at negligible s(k). + /* Split at negligible s(k). */ case 2: { @@ -1707,14 +1707,14 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) break; } - // Perform one qr step. + /* Perform one qr step. */ case 3: { - // Calculate the shift. + /* Calculate the shift. */ - float scale = maxf(maxf(maxf(maxf( + float scale = max_ff(max_ff(max_ff(max_ff( fabsf(s[p - 1]), fabsf(s[p - 2])), fabsf(e[p - 2])), fabsf(s[k])), fabsf(e[k])); float invscale = 1.0f / scale; @@ -1737,7 +1737,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) f = (sk + sp) * (sk - sp) + shift; g = sk * ek; - // Chase zeros. + /* Chase zeros. */ for (j = k; j < p - 1; j++) { float t = hypotf(f, g); @@ -1779,12 +1779,12 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) iter = iter + 1; break; } - // Convergence. + /* Convergence. */ case 4: { - // Make the singular values positive. + /* Make the singular values positive. */ if (s[k] <= 0.0f) { s[k] = (s[k] < 0.0f ? -s[k] : 0.0f); @@ -1793,7 +1793,7 @@ void svd_m4(float U[4][4], float s[4], float V[4][4], float A_[4][4]) V[i][k] = -V[i][k]; } - // Order the singular values. + /* Order the singular values. */ while (k < pp) { float t; diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 53f2c1cd0d9..70d9ef27734 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -797,7 +797,7 @@ void mat3_to_axis_angle(float axis[3], float *angle, float mat[3][3]) float q[4]; /* use quaternions as intermediate representation */ - // TODO: it would be nicer to go straight there... + /* TODO: it would be nicer to go straight there... */ mat3_to_quat(q, mat); quat_to_axis_angle(axis, angle, q); } @@ -808,7 +808,7 @@ void mat4_to_axis_angle(float axis[3], float *angle, float mat[4][4]) float q[4]; /* use quaternions as intermediate representation */ - // TODO: it would be nicer to go straight there... + /* TODO: it would be nicer to go straight there... */ mat4_to_quat(q, mat); quat_to_axis_angle(axis, angle, q); } @@ -1363,7 +1363,7 @@ void mat4_to_compatible_eulO(float eul[3], float oldrot[3], const short order, f mat3_to_compatible_eulO(eul, oldrot, order, m); } /* rotate the given euler by the given angle on the specified axis */ -// NOTE: is this safe to do with different axis orders? +/* NOTE: is this safe to do with different axis orders? */ void rotate_eulO(float beul[3], const short order, char axis, float ang) { @@ -1679,34 +1679,34 @@ void vec_apply_track(float vec[3], short axis) switch (axis) { case 0: /* pos-x */ - /* vec[0]= 0.0; */ + /* vec[0] = 0.0; */ vec[1] = tvec[2]; vec[2] = -tvec[1]; break; case 1: /* pos-y */ - /* vec[0]= tvec[0]; */ - /* vec[1]= 0.0; */ - /* vec[2]= tvec[2]; */ + /* vec[0] = tvec[0]; */ + /* vec[1] = 0.0; */ + /* vec[2] = tvec[2]; */ break; case 2: /* pos-z */ - /* vec[0]= tvec[0]; */ - /* vec[1]= tvec[1]; */ - // vec[2]= 0.0; */ + /* vec[0] = tvec[0]; */ + /* vec[1] = tvec[1]; */ + /* vec[2] = 0.0; */ break; case 3: /* neg-x */ - /* vec[0]= 0.0; */ + /* vec[0] = 0.0; */ vec[1] = tvec[2]; vec[2] = -tvec[1]; break; case 4: /* neg-y */ vec[0] = -tvec[2]; - /* vec[1]= 0.0; */ + /* vec[1] = 0.0; */ vec[2] = tvec[0]; break; case 5: /* neg-z */ vec[0] = -tvec[0]; vec[1] = -tvec[1]; - /* vec[2]= 0.0; */ + /* vec[2] = 0.0; */ break; } } diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 4196bab0474..7c9c5f60126 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -451,6 +451,15 @@ void minmax_v3v3_v3(float min[3], float max[3], const float vec[3]) if (max[2] < vec[2]) max[2] = vec[2]; } +void minmax_v2v2_v2(float min[2], float max[2], const float vec[2]) +{ + if (min[0] > vec[0]) min[0] = vec[0]; + if (min[1] > vec[1]) min[1] = vec[1]; + + if (max[0] < vec[0]) max[0] = vec[0]; + if (max[1] < vec[1]) max[1] = vec[1]; +} + /** ensure \a v1 is \a dist from \a v2 */ void dist_ensure_v3_v3fl(float v1[3], const float v2[3], const float dist) { diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index cc482e2d3d8..444daf8817c 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -47,7 +47,7 @@ #include "BLI_string_utf8.h" #include "BLI_utildefines.h" -#include "BKE_blender.h" // BLENDER_VERSION +#include "BKE_blender.h" /* BLENDER_VERSION */ #include "GHOST_Path-api.h" @@ -330,7 +330,7 @@ void BLI_cleanup_path(const char *relabase, char *dir) if (strcmp(dir, ".") == 0) { /* happens for example in FILE_MAIN */ get_default_root(dir); return; - } + } while ( (start = strstr(dir, "\\..\\")) ) { eind = start + strlen("\\..\\") - 1; @@ -492,7 +492,7 @@ void BLI_path_rel(char *file, const char *relfile) */ if (*q != '/') { while ( (q >= file) && (*q != '/') ) { --q; --p; } - } + } else if (*p != '/') { while ( (p >= temp) && (*p != '/') ) { --p; --q; } } @@ -544,7 +544,7 @@ int BLI_parent_dir(char *path) BLI_cleanup_dir(NULL, tmp); if (!BLI_testextensie(tmp, parent_dir)) { - BLI_strncpy(path, tmp, sizeof(tmp)); + BLI_strncpy(path, tmp, sizeof(tmp)); return 1; } else { @@ -691,7 +691,7 @@ int BLI_path_abs(char *path, const char *basepath) * of paths and solving some problems (and prevent potential future * ones) -jesterKing. */ BLI_char_switch(tmp, '\\', '/'); - BLI_char_switch(base, '\\', '/'); + BLI_char_switch(base, '\\', '/'); /* Paths starting with // will get the blend file as their base, * this isn't standard in any os but is used in blender all over the place */ @@ -1300,7 +1300,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, BLI_char_switch(file, '\\', '/'); #endif - /* Resolve relative references */ + /* Resolve relative references */ if (relabase && dir[0] == '/' && dir[1] == '/') { char *lslash; @@ -1321,7 +1321,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, else { /* no drive specified */ /* first option: get the drive from the relabase if it has one */ if (relabase && strlen(relabase) >= 2 && relabase[1] == ':') { - BLI_strncpy(string, relabase, 3); + BLI_strncpy(string, relabase, 3); string[2] = '\\'; string[3] = '\0'; } @@ -1337,7 +1337,7 @@ void BLI_make_file_string(const char *relabase, char *string, const char *dir, strcat(string, dir); - /* Make sure string ends in one (and only one) slash */ + /* Make sure string ends in one (and only one) slash */ /* first trim all slashes from the end of the string */ sl = strlen(string); while (sl > 0 && (string[sl - 1] == '/' || string[sl - 1] == '\\') ) { diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index d3d8d371f60..7637c60ec16 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -157,6 +157,8 @@ struct PBVH { /* flag are verts/faces deformed */ int deformed; + + int show_diffuse_color; }; #define STACK_FIXED_DEPTH 100 @@ -189,8 +191,8 @@ static void BB_expand(BB *bb, float co[3]) { int i; for (i = 0; i < 3; ++i) { - bb->bmin[i] = minf(bb->bmin[i], co[i]); - bb->bmax[i] = maxf(bb->bmax[i], co[i]); + bb->bmin[i] = min_ff(bb->bmin[i], co[i]); + bb->bmax[i] = max_ff(bb->bmax[i], co[i]); } } @@ -199,8 +201,8 @@ static void BB_expand_with_bb(BB *bb, BB *bb2) { int i; for (i = 0; i < 3; ++i) { - bb->bmin[i] = minf(bb->bmin[i], bb2->bmin[i]); - bb->bmax[i] = maxf(bb->bmax[i], bb2->bmax[i]); + bb->bmin[i] = min_ff(bb->bmin[i], bb2->bmin[i]); + bb->bmax[i] = max_ff(bb->bmax[i], bb2->bmax[i]); } } @@ -663,7 +665,7 @@ void BLI_pbvh_build_grids(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, bvh->totgrid = totgrid; bvh->gridkey = *key; bvh->grid_hidden = grid_hidden; - bvh->leaf_limit = maxi(LEAF_LIMIT / ((gridsize - 1) * (gridsize - 1)), 1); + bvh->leaf_limit = max_ii(LEAF_LIMIT / ((gridsize - 1) * (gridsize - 1)), 1); BB_reset(&cb); @@ -1001,7 +1003,7 @@ static int update_search_cb(PBVHNode *node, void *data_v) if (node->flag & PBVH_Leaf) return (node->flag & flag); - + return 1; } @@ -1165,7 +1167,8 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) bvh->grid_flag_mats, node->prim_indices, node->totprim, - &bvh->gridkey); + &bvh->gridkey, + bvh->show_diffuse_color); break; case PBVH_FACES: GPU_update_mesh_buffers(node->draw_buffers, @@ -1174,7 +1177,9 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) node->uniq_verts + node->face_verts, CustomData_get_layer(bvh->vdata, - CD_PAINT_MASK)); + CD_PAINT_MASK), + node->face_vert_indices, + bvh->show_diffuse_color); break; } @@ -1630,9 +1635,9 @@ static PlaneAABBIsect test_planes_aabb(const float bb_min[3], PlaneAABBIsect ret = ISECT_INSIDE; int i, axis; - for (i = 0; i < 4; ++i) { + for (i = 0; i < 4; ++i) { for (axis = 0; axis < 3; ++axis) { - if (planes[i][axis] > 0) { + if (planes[i][axis] > 0) { vmin[axis] = bb_min[axis]; vmax[axis] = bb_max[axis]; } @@ -1646,7 +1651,7 @@ static PlaneAABBIsect test_planes_aabb(const float bb_min[3], return ISECT_OUTSIDE; else if (dot_v3v3(planes[i], vmax) + planes[i][3] >= 0) ret = ISECT_INTERSECT; - } + } return ret; } @@ -1667,11 +1672,23 @@ int BLI_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data) return test_planes_aabb(bb_min, bb_max, data) != ISECT_INSIDE; } +static void pbvh_node_check_diffuse_changed(PBVH *bvh, PBVHNode *node) +{ + if (!node->draw_buffers) + return; + + if (GPU_buffers_diffuse_changed(node->draw_buffers, bvh->show_diffuse_color)) + node->flag |= PBVH_UpdateDrawBuffers; +} + void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], DMSetMaterial setMaterial) { PBVHNode **nodes; - int totnode; + int a, totnode; + + for (a = 0; a < bvh->totnode; a++) + pbvh_node_check_diffuse_changed(bvh, &bvh->nodes[a]); BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals | PBVH_UpdateDrawBuffers), &nodes, &totnode); @@ -1876,3 +1893,8 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, if (!vi->grids) vi->vmask = CustomData_get_layer(bvh->vdata, CD_PAINT_MASK); } + +void pbvh_show_diffuse_color_set(PBVH *bvh, int show_diffuse_color) +{ + bvh->show_diffuse_color = show_diffuse_color; +} diff --git a/source/blender/blenlib/intern/quadric.c b/source/blender/blenlib/intern/quadric.c index 1c04beacbfb..bb39cb61e78 100644 --- a/source/blender/blenlib/intern/quadric.c +++ b/source/blender/blenlib/intern/quadric.c @@ -117,7 +117,7 @@ int BLI_quadric_optimize(const Quadric *q, float v[3]) m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]); - if (det != 0.0f) { + if (fabsf(det) > FLT_EPSILON) { invert_m3(m); BLI_quadric_to_vector_v3(q, v); mul_m3_v3(m, v); diff --git a/source/blender/blenlib/intern/rand.c b/source/blender/blenlib/intern/rand.c index 3c22d73d113..76d17f34b5e 100644 --- a/source/blender/blenlib/intern/rand.c +++ b/source/blender/blenlib/intern/rand.c @@ -64,51 +64,51 @@ struct RNG { r_uint64 X; }; -RNG *rng_new(unsigned int seed) +RNG *BLI_rng_new(unsigned int seed) { RNG *rng = MEM_mallocN(sizeof(*rng), "rng"); - rng_seed(rng, seed); + BLI_rng_seed(rng, seed); return rng; } -void rng_free(RNG *rng) +void BLI_rng_free(RNG *rng) { MEM_freeN(rng); } -void rng_seed(RNG *rng, unsigned int seed) +void BLI_rng_seed(RNG *rng, unsigned int seed) { rng->X = (((r_uint64) seed) << 16) | LOWSEED; } -void rng_srandom(RNG *rng, unsigned int seed) +void BLI_rng_srandom(RNG *rng, unsigned int seed) { - rng_seed(rng, seed + hash[seed & 255]); - seed = rng_getInt(rng); - rng_seed(rng, seed + hash[seed & 255]); - seed = rng_getInt(rng); - rng_seed(rng, seed + hash[seed & 255]); + BLI_rng_seed(rng, seed + hash[seed & 255]); + seed = BLI_rng_get_int(rng); + BLI_rng_seed(rng, seed + hash[seed & 255]); + seed = BLI_rng_get_int(rng); + BLI_rng_seed(rng, seed + hash[seed & 255]); } -int rng_getInt(RNG *rng) +int BLI_rng_get_int(RNG *rng) { rng->X = (MULTIPLIER * rng->X + ADDEND) & MASK; return (int) (rng->X >> 17); } -double rng_getDouble(RNG *rng) +double BLI_rng_get_double(RNG *rng) { - return (double) rng_getInt(rng) / 0x80000000; + return (double) BLI_rng_get_int(rng) / 0x80000000; } -float rng_getFloat(RNG *rng) +float BLI_rng_get_float(RNG *rng) { - return (float) rng_getInt(rng) / 0x80000000; + return (float) BLI_rng_get_int(rng) / 0x80000000; } -void rng_shuffleArray(RNG *rng, void *data, int elemSize, int numElems) +void BLI_rng_shuffle_array(RNG *rng, void *data, int elemSize, int numElems) { int i = numElems; void *temp; @@ -122,7 +122,7 @@ void rng_shuffleArray(RNG *rng, void *data, int elemSize, int numElems) /* XXX Shouldn't it rather be "while (i--) {" ? * Else we have no guaranty first (0) element has a chance to be shuffled... --mont29 */ while (--i) { - int j = rng_getInt(rng) % numElems; + int j = BLI_rng_get_int(rng) % numElems; if (i != j) { void *iElem = (unsigned char *)data + i * elemSize; void *jElem = (unsigned char *)data + j * elemSize; @@ -135,12 +135,12 @@ void rng_shuffleArray(RNG *rng, void *data, int elemSize, int numElems) free(temp); } -void rng_skip(RNG *rng, int n) +void BLI_rng_skip(RNG *rng, int n) { int i; for (i = 0; i < n; i++) - rng_getInt(rng); + BLI_rng_get_int(rng); } /***/ @@ -150,28 +150,28 @@ static RNG theBLI_rng = {0}; /* note, this one creates periodical patterns */ void BLI_srand(unsigned int seed) { - rng_seed(&theBLI_rng, seed); + BLI_rng_seed(&theBLI_rng, seed); } /* using hash table to create better seed */ void BLI_srandom(unsigned int seed) { - rng_srandom(&theBLI_rng, seed); + BLI_rng_srandom(&theBLI_rng, seed); } int BLI_rand(void) { - return rng_getInt(&theBLI_rng); + return BLI_rng_get_int(&theBLI_rng); } double BLI_drand(void) { - return rng_getDouble(&theBLI_rng); + return BLI_rng_get_double(&theBLI_rng); } float BLI_frand(void) { - return rng_getFloat(&theBLI_rng); + return BLI_rng_get_float(&theBLI_rng); } void BLI_fillrand(void *addr, int len) @@ -179,16 +179,16 @@ void BLI_fillrand(void *addr, int len) RNG rng; unsigned char *p = addr; - rng_seed(&rng, (unsigned int) (PIL_check_seconds_timer() * 0x7FFFFFFF)); - while (len--) *p++ = rng_getInt(&rng) & 0xFF; + BLI_rng_seed(&rng, (unsigned int) (PIL_check_seconds_timer() * 0x7FFFFFFF)); + while (len--) *p++ = BLI_rng_get_int(&rng) & 0xFF; } void BLI_array_randomize(void *data, int elemSize, int numElems, unsigned int seed) { RNG rng; - rng_seed(&rng, seed); - rng_shuffleArray(&rng, data, elemSize, numElems); + BLI_rng_seed(&rng, seed); + BLI_rng_shuffle_array(&rng, data, elemSize, numElems); } /* ********* for threaded random ************** */ @@ -200,20 +200,20 @@ void BLI_thread_srandom(int thread, unsigned int seed) if (thread >= BLENDER_MAX_THREADS) thread = 0; - rng_seed(&rng_tab[thread], seed + hash[seed & 255]); - seed = rng_getInt(&rng_tab[thread]); - rng_seed(&rng_tab[thread], seed + hash[seed & 255]); - seed = rng_getInt(&rng_tab[thread]); - rng_seed(&rng_tab[thread], seed + hash[seed & 255]); + BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]); + seed = BLI_rng_get_int(&rng_tab[thread]); + BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]); + seed = BLI_rng_get_int(&rng_tab[thread]); + BLI_rng_seed(&rng_tab[thread], seed + hash[seed & 255]); } int BLI_thread_rand(int thread) { - return rng_getInt(&rng_tab[thread]); + return BLI_rng_get_int(&rng_tab[thread]); } float BLI_thread_frand(int thread) { - return rng_getFloat(&rng_tab[thread]); + return BLI_rng_get_float(&rng_tab[thread]); } diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c index 7ae27b83e67..362a87782c6 100644 --- a/source/blender/blenlib/intern/scanfill.c +++ b/source/blender/blenlib/intern/scanfill.c @@ -661,8 +661,8 @@ static int scanfill(ScanFillContext *sf_ctx, PolyFill *pf) /* this happens with a serial of overlapping edges */ if (v1 == v2 || v2 == v3) break; /* printf("test verts %x %x %x\n",v1,v2,v3); */ - miny = minf(v1->xy[1], v3->xy[1]); - /* miny= minf(v1->xy[1],v3->xy[1]); */ + miny = min_ff(v1->xy[1], v3->xy[1]); + /* miny = min_ff(v1->xy[1],v3->xy[1]); */ sc1 = sc + 1; test = 0; @@ -985,12 +985,12 @@ int BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const short do_quad_tri_speedu /* CURRENT STATUS: - * - eve->f :1= availalble in edges + * - eve->f :1 = availalble in edges * - eve->xs :polynumber * - eve->h :amount of edges connected to vertex * - eve->tmp.v :store! original vertex number * - * - eed->f :1= boundary edge (optionally set by caller) + * - eed->f :1 = boundary edge (optionally set by caller) * - eed->poly_nr :poly number */ diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index 0d3f6aee30f..1358fdd2a62 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -187,7 +187,7 @@ double BLI_dir_free_space(const char *dir) #endif #if defined(__sun__) || defined(__sun) || defined(__NetBSD__) - if (statvfs(name, &disk)) return(-1); + if (statvfs(name, &disk)) return(-1); #elif !defined(__FreeBSD__) && !defined(linux) && (defined(__sparc) || defined(__sparc__)) /* WARNING - This may not be supported by geeneric unix os's - Campbell */ if (statfs(name, &disk, sizeof(struct statfs), 0)) return(-1); @@ -418,9 +418,9 @@ static void bli_adddirstrings(void) unsigned int BLI_dir_contents(const char *dirname, struct direntry **filelist) { - // reset global variables - // memory stored in files is free()'d in - // filesel.c:freefilelist() + /* reset global variables + * memory stored in files is free()'d in + * filesel.c:freefilelist() */ actnum = totnum = 0; files = NULL; diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 4b64a650b52..73d88ddd259 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -377,7 +377,7 @@ int BLI_natstrcmp(const char *s1, const char *s2) c2 = tolower(s2[d2]); } - /* first check for '.' so "foo.bar" comes before "foo 1.bar" */ + /* first check for '.' so "foo.bar" comes before "foo 1.bar" */ if (c1 == '.' && c2 != '.') return -1; if (c1 != '.' && c2 == '.') @@ -416,7 +416,7 @@ void BLI_timestr(double _time, char *str) } /* determine the length of a fixed-size string */ -size_t BLI_strnlen(const char *str, size_t maxlen) +size_t BLI_strnlen(const char *str, const size_t maxlen) { const char *end = memchr(str, '\0', maxlen); return end ? (size_t) (end - str) : maxlen; diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 17b9ed7ea8d..5684b12cc8b 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -124,15 +124,15 @@ utf8_error: int BLI_utf8_invalid_strip(char *str, int length) { - int bad_char, tot= 0; + int bad_char, tot = 0; - while ((bad_char= BLI_utf8_invalid_byte(str, length)) != -1) { + while ((bad_char = BLI_utf8_invalid_byte(str, length)) != -1) { str += bad_char; length -= bad_char; if (length == 0) { /* last character bad, strip it */ - *str= '\0'; + *str = '\0'; tot++; break; } @@ -166,9 +166,9 @@ static const size_t utf8_skip_data[256] = { #define BLI_STR_UTF8_CPY(dst, src, maxncpy) \ { \ size_t utf8_size; \ - while (*src != '\0' && (utf8_size= utf8_skip_data[*src]) < maxncpy) { \ + while (*src != '\0' && (utf8_size = utf8_skip_data[*src]) < maxncpy) {\ maxncpy -= utf8_size; \ - switch (utf8_size) { \ + switch (utf8_size) { \ case 6: *dst ++ = *src ++; \ case 5: *dst ++ = *src ++; \ case 4: *dst ++ = *src ++; \ @@ -177,12 +177,12 @@ static const size_t utf8_skip_data[256] = { case 1: *dst ++ = *src ++; \ } \ } \ - *dst= '\0'; \ + *dst = '\0'; \ } (void)0 char *BLI_strncpy_utf8(char *dst, const char *src, size_t maxncpy) { - char *dst_r= dst; + char *dst_r = dst; /* note: currently we don't attempt to deal with invalid utf8 chars */ BLI_STR_UTF8_CPY(dst, src, maxncpy); @@ -214,7 +214,7 @@ size_t BLI_strncpy_wchar_as_utf8(char *dst, const wchar_t *src, const size_t max len += BLI_str_utf8_from_unicode(*src++, dst + len); } - dst[len]= '\0'; + dst[len] = '\0'; return len; } @@ -231,27 +231,50 @@ size_t BLI_wstrlen_utf8(const wchar_t *src) return len; } -// utf8slen +/* this is very close to 'BLI_str_utf8_size' functionality, perhaps we should de-duplicate */ +/* size of UTF-8 character in bytes */ +static size_t strlen_utf8_char(const char *strc) +{ + if ((*strc & 0xe0) == 0xc0) { + if ((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00) + return 2; + } + else if ((*strc & 0xf0) == 0xe0) { + if ((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00) + return 3; + } + else if ((*strc & 0xf8) == 0xf0) { + if ((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00) + return 4; + } + + return 1; +} + size_t BLI_strlen_utf8(const char *strc) { - int len = 0; + int len; - while (*strc) { - if ((*strc & 0xe0) == 0xc0) { - if ((strc[1] & 0x80) && (strc[1] & 0x40) == 0x00) - strc++; - } - else if ((*strc & 0xf0) == 0xe0) { - if ((strc[1] & strc[2] & 0x80) && ((strc[1] | strc[2]) & 0x40) == 0x00) - strc += 2; - } - else if ((*strc & 0xf8) == 0xf0) { - if ((strc[1] & strc[2] & strc[3] & 0x80) && ((strc[1] | strc[2] | strc[3]) & 0x40) == 0x00) - strc += 3; - } + for (len = 0; *strc; len++) + strc += strlen_utf8_char(strc); - strc++; - len++; + return len; +} + +/** + * \param start the string to measure the length. + * \param maxlen the string length (in bytes) + * \return the unicode length (not in bytes!) + */ +size_t BLI_strnlen_utf8(const char *start, const size_t maxlen) +{ + const char *strc = start; + const char *strc_end = start + maxlen; + + size_t len; + + for (len = 0; *strc && strc < strc_end; len++) { + strc += strlen_utf8_char(strc); } return len; @@ -266,15 +289,15 @@ size_t BLI_strncpy_wchar_from_utf8(wchar_t *dst_w, const char *src_c, const size } while (*src_c && len < maxcpy) { - size_t step= 0; - unsigned int unicode= BLI_str_utf8_as_unicode_and_size(src_c, &step); + size_t step = 0; + unsigned int unicode = BLI_str_utf8_as_unicode_and_size(src_c, &step); if (unicode != BLI_UTF8_ERR) { - *dst_w= (wchar_t)unicode; + *dst_w = (wchar_t)unicode; src_c += step; } else { *dst_w = '?'; - src_c= BLI_str_find_next_char_utf8(src_c, NULL); + src_c = BLI_str_find_next_char_utf8(src_c, NULL); } dst_w++; len++; @@ -397,13 +420,13 @@ unsigned int BLI_str_utf8_as_unicode_step(const char *p, size_t *index) unsigned char c; p += *index; - c= (unsigned char) *p; + c = (unsigned char) *p; UTF8_COMPUTE (c, mask, len); if (len == -1) { /* when called with NULL end, result will never be NULL, * checks for a NULL character */ - char *p_next= BLI_str_find_next_char_utf8(p, NULL); + char *p_next = BLI_str_find_next_char_utf8(p, NULL); /* will never return the same pointer unless '\0', * eternal loop is prevented */ *index += (size_t)(p_next - p); @@ -420,8 +443,8 @@ unsigned int BLI_str_utf8_as_unicode_step(const char *p, size_t *index) * characters */ UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR); if (result == BLI_UTF8_ERR) { - len= 1; - result= *p; + len = 1; + result = *p; } /* end warning! */ #else diff --git a/source/blender/blenlib/intern/time.c b/source/blender/blenlib/intern/time.c index bf9720fee09..078fc2c295b 100644 --- a/source/blender/blenlib/intern/time.c +++ b/source/blender/blenlib/intern/time.c @@ -44,7 +44,7 @@ double PIL_check_seconds_timer(void) __int64 ifreq; hasperfcounter = QueryPerformanceFrequency((LARGE_INTEGER *) &ifreq); perffreq = (double) ifreq; - } + } if (hasperfcounter) { __int64 count; diff --git a/source/blender/blenlib/intern/voronoi.c b/source/blender/blenlib/intern/voronoi.c index 3030e54eb78..9674012a73d 100644 --- a/source/blender/blenlib/intern/voronoi.c +++ b/source/blender/blenlib/intern/voronoi.c @@ -259,9 +259,9 @@ static float voronoi_getXOfEdge(VoronoiProcess *process, VoronoiParabola *par, f x2 = (-b - sqrtf(disc)) / (2 * a); if (p[1] < r[1]) - ry = maxf(x1, x2); + ry = max_ff(x1, x2); else - ry = minf(x1, x2); + ry = min_ff(x1, x2); return ry; } @@ -490,9 +490,9 @@ static void voronoi_finishEdge(VoronoiProcess *process, VoronoiParabola *parabol } if (parabola->edge->direction[0] > 0.0f) - mx = MAX2(process->width, parabola->edge->start[0] + 10); + mx = max_ff(process->width, parabola->edge->start[0] + 10); else - mx = MIN2(0.0, parabola->edge->start[0] - 10); + mx = min_ff(0.0f, parabola->edge->start[0] - 10.0f); parabola->edge->end[0] = mx; parabola->edge->end[1] = mx * parabola->edge->f + parabola->edge->g; diff --git a/source/blender/blenlib/intern/voxel.c b/source/blender/blenlib/intern/voxel.c index bc775cb8f0c..5d58f9e9231 100644 --- a/source/blender/blenlib/intern/voxel.c +++ b/source/blender/blenlib/intern/voxel.c @@ -117,19 +117,19 @@ float BLI_voxel_sample_triquadratic(float *data, const int res[3], const float c const int zc[3] = {res[0] * res[1] * _clamp(z - 1, 0, res[2] - 1), res[0] * res[1] * _clamp(z, 0, res[2] - 1), res[0] * res[1] * _clamp(z + 1, 0, res[2] - 1)}; const float dx = xf - (float)x, dy = yf - (float)y, dz = zf - (float)z; - const float u[3] = {dx*(0.5f*dx - 1.f) + 0.5f, dx*(1.f - dx) + 0.5f, 0.5f*dx*dx}; - const float v[3] = {dy*(0.5f*dy - 1.f) + 0.5f, dy*(1.f - dy) + 0.5f, 0.5f*dy*dy}; - const float w[3] = {dz*(0.5f*dz - 1.f) + 0.5f, dz*(1.f - dz) + 0.5f, 0.5f*dz*dz}; + const float u[3] = {dx * (0.5f * dx - 1.f) + 0.5f, dx * (1.0f - dx) + 0.5f, 0.5f * dx * dx}; + const float v[3] = {dy * (0.5f * dy - 1.f) + 0.5f, dy * (1.0f - dy) + 0.5f, 0.5f * dy * dy}; + const float w[3] = {dz * (0.5f * dz - 1.f) + 0.5f, dz * (1.0f - dz) + 0.5f, 0.5f * dz * dz}; return w[0] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]] + u[2] * data[xc[2] + yc[0] + zc[0]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] + u[2] * data[xc[2] + yc[1] + zc[0]] ) - + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[0]] + u[1] * data[xc[1] + yc[2] + zc[0]] + u[2] * data[xc[2] + yc[2] + zc[0]] ) ) - + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] + u[2] * data[xc[2] + yc[0] + zc[1]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] + u[2] * data[xc[2] + yc[1] + zc[1]] ) - + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[1]] + u[1] * data[xc[1] + yc[2] + zc[1]] + u[2] * data[xc[2] + yc[2] + zc[1]] ) ) - + w[2] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[2]] + u[1] * data[xc[1] + yc[0] + zc[2]] + u[2] * data[xc[2] + yc[0] + zc[2]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[2]] + u[1] * data[xc[1] + yc[1] + zc[2]] + u[2] * data[xc[2] + yc[1] + zc[2]] ) - + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[2]] + u[1] * data[xc[1] + yc[2] + zc[2]] + u[2] * data[xc[2] + yc[2] + zc[2]] ) ); + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] + u[2] * data[xc[2] + yc[1] + zc[0]] ) + + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[0]] + u[1] * data[xc[1] + yc[2] + zc[0]] + u[2] * data[xc[2] + yc[2] + zc[0]] ) ) + + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] + u[2] * data[xc[2] + yc[0] + zc[1]] ) + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] + u[2] * data[xc[2] + yc[1] + zc[1]] ) + + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[1]] + u[1] * data[xc[1] + yc[2] + zc[1]] + u[2] * data[xc[2] + yc[2] + zc[1]] ) ) + + w[2] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[2]] + u[1] * data[xc[1] + yc[0] + zc[2]] + u[2] * data[xc[2] + yc[0] + zc[2]] ) + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[2]] + u[1] * data[xc[1] + yc[1] + zc[2]] + u[2] * data[xc[2] + yc[1] + zc[2]] ) + + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[2]] + u[1] * data[xc[1] + yc[2] + zc[2]] + u[2] * data[xc[2] + yc[2] + zc[2]] ) ); } return 0.f; @@ -179,21 +179,21 @@ float BLI_voxel_sample_tricubic(float *data, const int res[3], const float co[3] } return w[0] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[0]] + u[1] * data[xc[1] + yc[0] + zc[0]] + u[2] * data[xc[2] + yc[0] + zc[0]] + u[3] * data[xc[3] + yc[0] + zc[0]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] + u[2] * data[xc[2] + yc[1] + zc[0]] + u[3] * data[xc[3] + yc[1] + zc[0]] ) - + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[0]] + u[1] * data[xc[1] + yc[2] + zc[0]] + u[2] * data[xc[2] + yc[2] + zc[0]] + u[3] * data[xc[3] + yc[2] + zc[0]] ) - + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[0]] + u[1] * data[xc[1] + yc[3] + zc[0]] + u[2] * data[xc[2] + yc[3] + zc[0]] + u[3] * data[xc[3] + yc[3] + zc[0]] ) ) - + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] + u[2] * data[xc[2] + yc[0] + zc[1]] + u[3] * data[xc[3] + yc[0] + zc[1]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] + u[2] * data[xc[2] + yc[1] + zc[1]] + u[3] * data[xc[3] + yc[1] + zc[1]] ) - + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[1]] + u[1] * data[xc[1] + yc[2] + zc[1]] + u[2] * data[xc[2] + yc[2] + zc[1]] + u[3] * data[xc[3] + yc[2] + zc[1]] ) - + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[1]] + u[1] * data[xc[1] + yc[3] + zc[1]] + u[2] * data[xc[2] + yc[3] + zc[1]] + u[3] * data[xc[3] + yc[3] + zc[1]] ) ) - + w[2] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[2]] + u[1] * data[xc[1] + yc[0] + zc[2]] + u[2] * data[xc[2] + yc[0] + zc[2]] + u[3] * data[xc[3] + yc[0] + zc[2]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[2]] + u[1] * data[xc[1] + yc[1] + zc[2]] + u[2] * data[xc[2] + yc[1] + zc[2]] + u[3] * data[xc[3] + yc[1] + zc[2]] ) - + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[2]] + u[1] * data[xc[1] + yc[2] + zc[2]] + u[2] * data[xc[2] + yc[2] + zc[2]] + u[3] * data[xc[3] + yc[2] + zc[2]] ) - + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[2]] + u[1] * data[xc[1] + yc[3] + zc[2]] + u[2] * data[xc[2] + yc[3] + zc[2]] + u[3] * data[xc[3] + yc[3] + zc[2]] ) ) - + w[3] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[3]] + u[1] * data[xc[1] + yc[0] + zc[3]] + u[2] * data[xc[2] + yc[0] + zc[3]] + u[3] * data[xc[3] + yc[0] + zc[3]] ) - + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[3]] + u[1] * data[xc[1] + yc[1] + zc[3]] + u[2] * data[xc[2] + yc[1] + zc[3]] + u[3] * data[xc[3] + yc[1] + zc[3]] ) - + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[3]] + u[1] * data[xc[1] + yc[2] + zc[3]] + u[2] * data[xc[2] + yc[2] + zc[3]] + u[3] * data[xc[3] + yc[2] + zc[3]] ) - + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[3]] + u[1] * data[xc[1] + yc[3] + zc[3]] + u[2] * data[xc[2] + yc[3] + zc[3]] + u[3] * data[xc[3] + yc[3] + zc[3]] ) ); + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[0]] + u[1] * data[xc[1] + yc[1] + zc[0]] + u[2] * data[xc[2] + yc[1] + zc[0]] + u[3] * data[xc[3] + yc[1] + zc[0]] ) + + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[0]] + u[1] * data[xc[1] + yc[2] + zc[0]] + u[2] * data[xc[2] + yc[2] + zc[0]] + u[3] * data[xc[3] + yc[2] + zc[0]] ) + + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[0]] + u[1] * data[xc[1] + yc[3] + zc[0]] + u[2] * data[xc[2] + yc[3] + zc[0]] + u[3] * data[xc[3] + yc[3] + zc[0]] ) ) + + w[1] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[1]] + u[1] * data[xc[1] + yc[0] + zc[1]] + u[2] * data[xc[2] + yc[0] + zc[1]] + u[3] * data[xc[3] + yc[0] + zc[1]] ) + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[1]] + u[1] * data[xc[1] + yc[1] + zc[1]] + u[2] * data[xc[2] + yc[1] + zc[1]] + u[3] * data[xc[3] + yc[1] + zc[1]] ) + + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[1]] + u[1] * data[xc[1] + yc[2] + zc[1]] + u[2] * data[xc[2] + yc[2] + zc[1]] + u[3] * data[xc[3] + yc[2] + zc[1]] ) + + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[1]] + u[1] * data[xc[1] + yc[3] + zc[1]] + u[2] * data[xc[2] + yc[3] + zc[1]] + u[3] * data[xc[3] + yc[3] + zc[1]] ) ) + + w[2] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[2]] + u[1] * data[xc[1] + yc[0] + zc[2]] + u[2] * data[xc[2] + yc[0] + zc[2]] + u[3] * data[xc[3] + yc[0] + zc[2]] ) + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[2]] + u[1] * data[xc[1] + yc[1] + zc[2]] + u[2] * data[xc[2] + yc[1] + zc[2]] + u[3] * data[xc[3] + yc[1] + zc[2]] ) + + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[2]] + u[1] * data[xc[1] + yc[2] + zc[2]] + u[2] * data[xc[2] + yc[2] + zc[2]] + u[3] * data[xc[3] + yc[2] + zc[2]] ) + + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[2]] + u[1] * data[xc[1] + yc[3] + zc[2]] + u[2] * data[xc[2] + yc[3] + zc[2]] + u[3] * data[xc[3] + yc[3] + zc[2]] ) ) + + w[3] * ( v[0] * ( u[0] * data[xc[0] + yc[0] + zc[3]] + u[1] * data[xc[1] + yc[0] + zc[3]] + u[2] * data[xc[2] + yc[0] + zc[3]] + u[3] * data[xc[3] + yc[0] + zc[3]] ) + + v[1] * ( u[0] * data[xc[0] + yc[1] + zc[3]] + u[1] * data[xc[1] + yc[1] + zc[3]] + u[2] * data[xc[2] + yc[1] + zc[3]] + u[3] * data[xc[3] + yc[1] + zc[3]] ) + + v[2] * ( u[0] * data[xc[0] + yc[2] + zc[3]] + u[1] * data[xc[1] + yc[2] + zc[3]] + u[2] * data[xc[2] + yc[2] + zc[3]] + u[3] * data[xc[3] + yc[2] + zc[3]] ) + + v[3] * ( u[0] * data[xc[0] + yc[3] + zc[3]] + u[1] * data[xc[1] + yc[3] + zc[3]] + u[2] * data[xc[2] + yc[3] + zc[3]] + u[3] * data[xc[3] + yc[3] + zc[3]] ) ); } return 0.f; diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index a0b31f8d5b8..68d9d74cca4 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -293,7 +293,7 @@ void get_default_root(char *root) root[3] = '\0'; if (GetFileAttributes(root) != 0xFFFFFFFF) { rc = i; - break; + break; } } } @@ -304,7 +304,7 @@ void get_default_root(char *root) root[2] = '\\'; root[3] = '\0'; } - } + } } } diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c index e917ccdf342..e9caa337129 100644 --- a/source/blender/blenloader/intern/readblenentry.c +++ b/source/blender/blenloader/intern/readblenentry.c @@ -175,7 +175,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to else if (bhead->code == DATA) { if (looking) { if (bhead->SDNAnr == DNA_struct_find_nr(fd->filesdna, "PreviewImage") ) { - prv = BLO_library_read_struct(fd, bhead, "PreviewImage"); + prv = BLO_library_read_struct(fd, bhead, "PreviewImage"); if (prv) { memcpy(new_prv, prv, sizeof(PreviewImage)); if (prv->rect[0]) { @@ -183,7 +183,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to new_prv->rect[0] = MEM_callocN(new_prv->w[0] * new_prv->h[0] * sizeof(unsigned int), "prvrect"); bhead = blo_nextbhead(fd, bhead); rect = (unsigned int *)(bhead + 1); - memcpy(new_prv->rect[0], rect, bhead->len); + memcpy(new_prv->rect[0], rect, bhead->len); } else { new_prv->rect[0] = NULL; @@ -194,7 +194,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to new_prv->rect[1] = MEM_callocN(new_prv->w[1] * new_prv->h[1] * sizeof(unsigned int), "prvrect"); bhead = blo_nextbhead(fd, bhead); rect = (unsigned int *)(bhead + 1); - memcpy(new_prv->rect[1], rect, bhead->len); + memcpy(new_prv->rect[1], rect, bhead->len); } else { new_prv->rect[1] = NULL; @@ -265,10 +265,10 @@ BlendFileData *BLO_read_from_file(const char *filepath, ReportList *reports) if (fd) { fd->reports = reports; bfd = blo_read_file_internal(fd, filepath); - blo_freefiledata(fd); + blo_freefiledata(fd); } - return bfd; + return bfd; } BlendFileData *BLO_read_from_memory(void *mem, int memsize, ReportList *reports) @@ -280,10 +280,10 @@ BlendFileData *BLO_read_from_memory(void *mem, int memsize, ReportList *reports) if (fd) { fd->reports = reports; bfd = blo_read_file_internal(fd, ""); - blo_freefiledata(fd); + blo_freefiledata(fd); } - return bfd; + return bfd; } BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFile *memfile, ReportList *reports) @@ -332,10 +332,10 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, const char *filename, MemFil } blo_join_main(&mainlist); - blo_freefiledata(fd); + blo_freefiledata(fd); } - return bfd; + return bfd; } void BLO_blendfiledata_free(BlendFileData *bfd) diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index dc8cf3b9116..8929fa3ff7a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -1003,7 +1003,7 @@ FileData *blo_openblenderfile(const char *filepath, ReportList *reports) if (gzfile == (gzFile)Z_NULL) { BKE_reportf(reports, RPT_WARNING, "Unable to open '%s': %s", - filepath, errno ? strerror(errno) : TIP_("Unknown error reading file")); + filepath, errno ? strerror(errno) : TIP_("unknown error reading file")); return NULL; } else { @@ -1294,6 +1294,7 @@ void blo_end_image_pointer_map(FileData *fd, Main *oldmain) if (NULL == newimaadr(fd, ibuf)) { /* so was restored */ BLI_remlink(&ima->ibufs, ibuf); ima->bindcode = 0; + ima->tpageflag &= ~IMA_GLBIND_IS_DATA; ima->gputexture = NULL; } } @@ -1632,6 +1633,19 @@ static void IDP_LibLinkProperty(IDProperty *UNUSED(prop), int UNUSED(switch_endi { } +/* ************ READ ID *************** */ + +static void direct_link_id(FileData *fd, ID *id) +{ + /*link direct data of ID properties*/ + if (id->properties) { + id->properties = newdataadr(fd, id->properties); + if (id->properties) { /* this case means the data was written incorrectly, it should not happen */ + IDP_DirectLinkProperty(id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); + } + } +} + /* ************ READ CurveMapping *************** */ /* cuma itself has been read! */ @@ -2400,6 +2414,14 @@ static void direct_link_nodetree(FileData *fd, bNodeTree *ntree) link_list(fd, &node->inputs); link_list(fd, &node->outputs); + link_list(fd, &node->internal_links); + for (link = node->internal_links.first; link; link = link->next) { + link->fromnode = newdataadr(fd, link->fromnode); + link->fromsock = newdataadr(fd, link->fromsock); + link->tonode = newdataadr(fd, link->tonode); + link->tosock = newdataadr(fd, link->tosock); + } + if (node->type == CMP_NODE_MOVIEDISTORTION) { node->storage = newmclipadr(fd, node->storage); } @@ -2531,8 +2553,13 @@ static void direct_link_constraints(FileData *fd, ListBase *lb) break; case CONSTRAINT_TYPE_KINEMATIC: { + bKinematicConstraint *data = con->data; + con->lin_error = 0.f; con->rot_error = 0.f; + + /* version patch for runtime flag, was not cleared in some case */ + data->flag &= ~CONSTRAINT_IK_AUTO; } case CONSTRAINT_TYPE_CHILDOF: { @@ -2713,8 +2740,10 @@ static void direct_link_lamp(FileData *fd, Lamp *la) direct_link_curvemapping(fd, la->curfalloff); la->nodetree= newdataadr(fd, la->nodetree); - if (la->nodetree) + if (la->nodetree) { + direct_link_id(fd, &la->nodetree->id); direct_link_nodetree(fd, la->nodetree); + } la->preview = direct_link_preview_image(fd, la->preview); } @@ -2880,8 +2909,10 @@ static void direct_link_world(FileData *fd, World *wrld) } wrld->nodetree = newdataadr(fd, wrld->nodetree); - if (wrld->nodetree) + if (wrld->nodetree) { + direct_link_id(fd, &wrld->nodetree->id); direct_link_nodetree(fd, wrld->nodetree); + } wrld->preview = direct_link_preview_image(fd, wrld->preview); } @@ -3004,6 +3035,7 @@ static void direct_link_image(FileData *fd, Image *ima) /* if not restored, we keep the binded opengl index */ if (ima->ibufs.first == NULL) { ima->bindcode = 0; + ima->tpageflag &= ~IMA_GLBIND_IS_DATA; ima->gputexture = NULL; } @@ -3188,8 +3220,10 @@ static void direct_link_texture(FileData *fd, Tex *tex) tex->ot = newdataadr(fd, tex->ot); tex->nodetree = newdataadr(fd, tex->nodetree); - if (tex->nodetree) + if (tex->nodetree) { + direct_link_id(fd, &tex->nodetree->id); direct_link_nodetree(fd, tex->nodetree); + } tex->preview = direct_link_preview_image(fd, tex->preview); @@ -3248,8 +3282,10 @@ static void direct_link_material(FileData *fd, Material *ma) ma->ramp_spec = newdataadr(fd, ma->ramp_spec); ma->nodetree = newdataadr(fd, ma->nodetree); - if (ma->nodetree) + if (ma->nodetree) { + direct_link_id(fd, &ma->nodetree->id); direct_link_nodetree(fd, ma->nodetree); + } ma->preview = direct_link_preview_image(fd, ma->preview); ma->gpumaterial.first = ma->gpumaterial.last = NULL; @@ -3369,13 +3405,12 @@ static void lib_link_particlesettings(FileData *fd, Main *main) if (part->dupliweights.first && part->dup_group) { int index_ok = 0; /* check for old files without indices (all indexes 0) */ - dw = part->dupliweights.first; if (part->dupliweights.first == part->dupliweights.last) { /* special case for only one object in the group */ index_ok = 1; } else { - for (; dw; dw=dw->next) { + for (dw = part->dupliweights.first; dw; dw = dw->next) { if (dw->index > 0) { index_ok = 1; break; @@ -3385,18 +3420,18 @@ static void lib_link_particlesettings(FileData *fd, Main *main) if (index_ok) { /* if we have indexes, let's use them */ - dw = part->dupliweights.first; - for (; dw; dw=dw->next) { + for (dw = part->dupliweights.first; dw; dw = dw->next) { GroupObject *go = (GroupObject *)BLI_findlink(&part->dup_group->gobject, dw->index); - dw->ob = go ? go->ob : NULL; + dw->ob = go ? newlibadr(fd, part->id.lib, dw->ob) : NULL; } } else { /* otherwise try to get objects from own library (won't work on library linked groups) */ - for (; dw; dw=dw->next) + for (dw = part->dupliweights.first; dw; dw = dw->next) { dw->ob = newlibadr(fd, part->id.lib, dw->ob); } } + } else { part->dupliweights.first = part->dupliweights.last = NULL; } @@ -4770,7 +4805,7 @@ static void lib_link_scene(FileData *fd, Main *main) base->object = newlibadr_us(fd, sce->id.lib, base->object); if (base->object == NULL) { - BKE_reportf_wrap(fd->reports, RPT_WARNING, "LIB ERROR: object lost from scene: '%s'", + BKE_reportf_wrap(fd->reports, RPT_WARNING, TIP_("LIB ERROR: object lost from scene: '%s'"), sce->id.name + 2); BLI_remlink(&sce->base, base); if (base == sce->basact) sce->basact = NULL; @@ -5093,8 +5128,10 @@ static void direct_link_scene(FileData *fd, Scene *sce) } sce->nodetree = newdataadr(fd, sce->nodetree); - if (sce->nodetree) + if (sce->nodetree) { + direct_link_id(fd, &sce->nodetree->id); direct_link_nodetree(fd, sce->nodetree); + } direct_link_view_settings(fd, &sce->view_settings); } @@ -6008,11 +6045,11 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) if (newmain->curlib) { if (BLI_path_cmp(newmain->curlib->filepath, lib->filepath) == 0) { BKE_reportf_wrap(fd->reports, RPT_WARNING, - "Library '%s', '%s' had multiple instances, save and reload!", + TIP_("Library '%s', '%s' had multiple instances, save and reload!"), lib->name, lib->filepath); change_idid_adr(fd->mainlist, fd, lib, newmain->curlib); -// change_idid_adr_fd(fd, lib, newmain->curlib); +/* change_idid_adr_fd(fd, lib, newmain->curlib); */ BLI_remlink(&main->library, lib); MEM_freeN(lib); @@ -6026,8 +6063,10 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) BLI_strncpy(lib->filepath, lib->name, sizeof(lib->name)); cleanup_path(fd->relabase, lib->filepath); -// printf("direct_link_library: name %s\n", lib->name); -// printf("direct_link_library: filename %s\n", lib->filename); +#if 0 + printf("direct_link_library: name %s\n", lib->name); + printf("direct_link_library: filename %s\n", lib->filename); +#endif /* new main */ newmain= MEM_callocN(sizeof(Main), "directlink"); @@ -6636,6 +6675,8 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID bhead = read_data_into_oldnewmap(fd, bhead, allocname); /* init pointers direct data */ + direct_link_id(fd, id); + switch (GS(id->name)) { case ID_WM: direct_link_windowmanager(fd, (wmWindowManager *)id); @@ -6735,14 +6776,6 @@ static BHead *read_libblock(FileData *fd, Main *main, BHead *bhead, int flag, ID break; } - /*link direct data of ID properties*/ - if (id->properties) { - id->properties = newdataadr(fd, id->properties); - if (id->properties) { /* this case means the data was written incorrectly, it should not happen */ - IDP_DirectLinkProperty(id->properties, (fd->flags & FD_FLAGS_SWITCH_ENDIAN), fd); - } - } - oldnewmap_free_unused(fd->datamap); oldnewmap_clear(fd->datamap); @@ -7208,6 +7241,20 @@ static void do_version_ntree_dilateerode_264(void *UNUSED(data), ID *UNUSED(id), } } +static void do_version_ntree_defocus_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree) +{ + bNode *node; + + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_DEFOCUS) { + NodeDefocus *data = node->storage; + if (data->maxblur == 0.0f) { + data->maxblur = 16.0f; + } + } + } +} + static void do_version_ntree_mask_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree) { bNode *node; @@ -7265,6 +7312,21 @@ static void do_version_node_cleanup_dynamic_sockets_264(void *UNUSED(data), ID * } } +static void do_version_node_fix_internal_links_264(void *UNUSED(data), ID *UNUSED(id), bNodeTree *ntree) +{ + bNode *node; + bNodeLink *link, *nextlink; + + for (node = ntree->nodes.first; node; node = node->next) { + for (link = node->internal_links.first; link; link = nextlink) { + nextlink = link->next; + if (!link->fromnode || !link->fromsock || !link->tonode || !link->tosock) { + BLI_remlink(&node->internal_links, link); + } + } + } +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -7588,8 +7650,8 @@ static void do_versions(FileData *fd, Library *lib, Main *main) prop = BKE_bproperty_object_get(ob, "Text"); if (prop) { BKE_reportf_wrap(fd->reports, RPT_WARNING, - "Game property name conflict in object '%s':\ntext objects reserve the " - "['Text'] game property to change their content through logic bricks", + TIP_("Game property name conflict in object '%s':\ntext objects reserve the " + "['Text'] game property to change their content through logic bricks"), ob->id.name + 2); } } @@ -7978,6 +8040,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 10)) { { Scene *scene; + bNodeTreeType *ntreetype; // composite redesign for (scene=main->scene.first; scene; scene=scene->id.next) { if (scene->nodetree) { @@ -7986,6 +8049,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } } + ntreetype = ntreeGetType(NTREE_COMPOSIT); + + if (ntreetype && ntreetype->foreach_nodetree) + ntreetype->foreach_nodetree(main, NULL, do_version_ntree_defocus_264); + } { @@ -8334,6 +8402,40 @@ static void do_versions(FileData *fd, Library *lib, Main *main) do_version_node_cleanup_dynamic_sockets_264(NULL, NULL, ntree); } + if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 5)) { + /* set a unwrapping margin and ABF by default */ + Scene *scene; + + for (scene=main->scene.first; scene; scene=scene->id.next) { + if (scene->toolsettings->uvcalc_margin == 0.0f) { + scene->toolsettings->uvcalc_margin = 0.001f; + scene->toolsettings->unwrapper = 0; + } + } + } + + if (main->versionfile < 264 || (main->versionfile == 264 && main->subversionfile < 6)) { + /* Fix for bug #32982, internal_links list could get corrupted from r51630 onward. + * Simply remove bad internal_links lists to avoid NULL pointers. + */ + bNodeTreeType *ntreetype; + bNodeTree *ntree; + + ntreetype = ntreeGetType(NTREE_COMPOSIT); + if (ntreetype && ntreetype->foreach_nodetree) + ntreetype->foreach_nodetree(main, NULL, do_version_node_fix_internal_links_264); + ntreetype = ntreeGetType(NTREE_SHADER); + if (ntreetype && ntreetype->foreach_nodetree) + ntreetype->foreach_nodetree(main, NULL, do_version_node_fix_internal_links_264); + ntreetype = ntreeGetType(NTREE_TEXTURE); + if (ntreetype && ntreetype->foreach_nodetree) + ntreetype->foreach_nodetree(main, NULL, do_version_node_fix_internal_links_264); + + for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) + do_version_node_fix_internal_links_264(NULL, NULL, ntree); + + } + /* default values in Freestyle settings */ { Scene *sce; @@ -9931,8 +10033,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) if (fd == NULL) { /* printf and reports for now... its important users know this */ - BKE_reportf_wrap(basefd->reports, RPT_INFO, - "Read library: '%s', '%s'", + BKE_reportf_wrap(basefd->reports, RPT_INFO, TIP_("Read library: '%s', '%s'"), mainptr->curlib->filepath, mainptr->curlib->name); fd = blo_openblenderfile(mainptr->curlib->filepath, basefd->reports); @@ -9985,8 +10086,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) else mainptr->curlib->filedata = NULL; if (fd == NULL) { - BKE_reportf_wrap(basefd->reports, RPT_WARNING, - "Cannot find lib '%s'", + BKE_reportf_wrap(basefd->reports, RPT_WARNING, TIP_("Cannot find lib '%s'"), mainptr->curlib->filepath); } } @@ -10005,7 +10105,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) append_id_part(fd, mainptr, id, &realid); if (!realid) { BKE_reportf_wrap(fd->reports, RPT_WARNING, - "LIB ERROR: %s:'%s' missing from '%s'", + TIP_("LIB ERROR: %s: '%s' missing from '%s'"), BKE_idcode_to_name(GS(id->name)), id->name+2, mainptr->curlib->filepath); } @@ -10037,7 +10137,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist) if (id->flag & LIB_READ) { BLI_remlink(lbarray[a], id); BKE_reportf_wrap(basefd->reports, RPT_WARNING, - "LIB ERROR: %s:'%s' unread libblock missing from '%s'", + TIP_("LIB ERROR: %s: '%s' unread lib block missing from '%s'"), BKE_idcode_to_name(GS(id->name)), id->name + 2, mainptr->curlib->filepath); change_idid_adr(mainlist, basefd, id, NULL); diff --git a/source/blender/blenloader/intern/runtime.c b/source/blender/blenloader/intern/runtime.c index 4136f71f050..5d8a865eea8 100644 --- a/source/blender/blenloader/intern/runtime.c +++ b/source/blender/blenloader/intern/runtime.c @@ -91,7 +91,7 @@ cleanup: if (fd != -1) close(fd); - return res; + return res; } BlendFileData *BLO_read_runtime(const char *path, ReportList *reports) @@ -126,7 +126,7 @@ BlendFileData *BLO_read_runtime(const char *path, ReportList *reports) BKE_reportf(reports, RPT_ERROR, "Unable to read '%s' (not a blend file)", path); goto cleanup; } - else { + else { //printf("starting to read runtime from %s at datastart %d\n", path, datastart); lseek(fd, datastart, SEEK_SET); bfd = blo_read_blendafterruntime(fd, path, actualsize - datastart, reports); diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index a3cfa4413a8..d75339252d9 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -32,7 +32,7 @@ #include "zlib.h" #ifndef WIN32 -# include <unistd.h> // for read close +# include <unistd.h> /* for read close */ #else # include <io.h> // for open close read # include "winsock2.h" @@ -1134,7 +1134,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* Add default gravity to scenes */ for (sce = main->scene.first; sce; sce = sce->id.next) { if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 && - len_v3(sce->physics_settings.gravity) == 0.0f) + is_zero_v3(sce->physics_settings.gravity)) { sce->physics_settings.gravity[0] = sce->physics_settings.gravity[1] = 0.0f; sce->physics_settings.gravity[2] = -9.81f; @@ -2062,7 +2062,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { brush->add_col[0] = 1.00f; brush->add_col[1] = 0.39f; - brush->add_col[2] = 0.39f; + brush->add_col[2] = 0.39f; } if (brush->sub_col[0] == 0 && @@ -2333,7 +2333,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) for (sc = main->screen.first; sc; sc = sc->id.next) { if (sc->redraws_flag == 0) { /* just initialize to default? */ - // XXX: we could also have iterated through areas, and taken them from the first timeline available... + /* XXX: we could also have iterated through areas, and taken them from the first timeline available... */ sc->redraws_flag = TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN; } } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index d8333e7c8f4..8a56e3c2ab8 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -1237,7 +1237,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) TFace *tf = &((TFace*) me->tface)[i]; for (j = 0; j < 4; j++) { - char *col = (char*) &tf->col[j]; + char *col = (char *) &tf->col[j]; col[0] = 255; } diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index 99283cf9473..ea8b566340d 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -198,7 +198,7 @@ static WriteData *writedata_new(int file) if (wd == NULL) return NULL; - wd->sdna= DNA_sdna_from_data(DNAstr, DNAlen, 0); + wd->sdna = DNA_sdna_from_data(DNAstr, DNAlen, 0); wd->file= file; @@ -512,7 +512,7 @@ static void write_fcurves(WriteData *wd, ListBase *fcurves) writestruct(wd, DATA, "FCurve", 1, fcu); /* curve data */ - if (fcu->bezt) + if (fcu->bezt) writestruct(wd, DATA, "BezTriple", fcu->totvert, fcu->bezt); if (fcu->fpt) writestruct(wd, DATA, "FPoint", fcu->totvert, fcu->fpt); @@ -721,7 +721,9 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree) write_node_socket(wd, sock); for (sock= node->outputs.first; sock; sock= sock->next) write_node_socket(wd, sock); - + + for (link = node->internal_links.first; link; link = link->next) + writestruct(wd, DATA, "bNodeLink", 1, link); if (node->storage) { /* could be handlerized at some point, now only 1 exception still */ @@ -889,7 +891,7 @@ static const char *ptcache_data_struct[] = { "", // BPHYS_DATA_ROTATION "", // BPHYS_DATA_AVELOCITY / BPHYS_DATA_XCONST */ "", // BPHYS_DATA_SIZE: - "", // BPHYS_DATA_TIMES: + "", // BPHYS_DATA_TIMES: "BoidData" // case BPHYS_DATA_BOIDS: }; static const char *ptcache_extra_struct[] = { @@ -1242,7 +1244,7 @@ static void write_constraints(WriteData *wd, ListBase *conlist) break; case CONSTRAINT_TYPE_SPLINEIK: { - bSplineIKConstraint *data= (bSplineIKConstraint*)con->data; + bSplineIKConstraint *data = (bSplineIKConstraint *)con->data; /* write points array */ writedata(wd, DATA, sizeof(float)*(data->numpoints), data->points); @@ -1330,7 +1332,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) writestruct(wd, DATA, "ClothCollSettings", 1, clmd->coll_parms); writestruct(wd, DATA, "EffectorWeights", 1, clmd->sim_parms->effector_weights); write_pointcaches(wd, &clmd->ptcaches); - } + } else if (md->type==eModifierType_Smoke) { SmokeModifierData *smd = (SmokeModifierData*) md; @@ -1360,7 +1362,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) writestruct(wd, DATA, "SmokeFlowSettings", 1, smd->flow); else if (smd->type & MOD_SMOKE_TYPE_COLL) writestruct(wd, DATA, "SmokeCollSettings", 1, smd->coll); - } + } else if (md->type==eModifierType_Fluidsim) { FluidsimModifierData *fluidmd = (FluidsimModifierData*) md; @@ -1388,7 +1390,7 @@ static void write_modifiers(WriteData *wd, ListBase *modbase) writestruct(wd, DATA, "ColorBand", 1, pmd->brush->paint_ramp); writestruct(wd, DATA, "ColorBand", 1, pmd->brush->vel_ramp); } - } + } else if (md->type==eModifierType_Collision) { #if 0 @@ -1608,7 +1610,7 @@ static void write_curves(WriteData *wd, ListBase *idbase) if (cu->vfont) { writedata(wd, DATA, amount_of_chars(cu->str)+1, cu->str); writestruct(wd, DATA, "CharInfo", cu->len+1, cu->strinfo); - writestruct(wd, DATA, "TextBox", cu->totbox, cu->tb); + writestruct(wd, DATA, "TextBox", cu->totbox, cu->tb); } else { /* is also the order of reading */ @@ -2026,7 +2028,7 @@ static void write_materials(WriteData *wd, ListBase *idbase) write_nodetree(wd, ma->nodetree); } - write_previews(wd, ma->preview); + write_previews(wd, ma->preview); } ma= ma->id.next; } @@ -2082,7 +2084,7 @@ static void write_lamps(WriteData *wd, ListBase *idbase) } if (la->curfalloff) - write_curvemapping(wd, la->curfalloff); + write_curvemapping(wd, la->curfalloff); /* nodetree is integral part of lamps, no libdata */ if (la->nodetree) { @@ -2317,7 +2319,7 @@ static void write_gpencils(WriteData *wd, ListBase *lb) /* write strokes */ for (gps= gpf->strokes.first; gps; gps= gps->next) { writestruct(wd, DATA, "bGPDstroke", 1, gps); - writestruct(wd, DATA, "bGPDspoint", gps->totpoints, gps->points); + writestruct(wd, DATA, "bGPDspoint", gps->totpoints, gps->points); } } } @@ -2553,7 +2555,7 @@ static void write_bone(WriteData *wd, Bone *bone) Bone* cbone; // PATCH for upward compatibility after 2.37+ armature recode - bone->size[0]= bone->size[1]= bone->size[2]= 1.0f; + bone->size[0] = bone->size[1] = bone->size[2] = 1.0f; // Write this bone writestruct(wd, DATA, "Bone", 1, bone); @@ -3212,7 +3214,7 @@ static int do_history(const char *name, ReportList *reports) if (BLI_rename(tempname1, tempname2)) { BKE_report(reports, RPT_ERROR, "Unable to make version backup"); return 1; - } + } hisnr--; } @@ -3287,7 +3289,7 @@ int BLO_write_file(Main *mainvar, const char *filepath, int write_flags, ReportL /* file save to temporary file was successful */ /* now do reverse file history (move .blend1 -> .blend2, .blend -> .blend1) */ - if (write_flags & G_FILE_HISTORY) { + if (write_flags & G_FILE_HISTORY) { int err_hist = do_history(filepath, reports); if (err_hist) { BKE_report(reports, RPT_ERROR, "Version backup failed (file saved with @)"); diff --git a/source/blender/bmesh/CMakeLists.txt b/source/blender/bmesh/CMakeLists.txt index 1e56314ab6e..f811dcf956e 100644 --- a/source/blender/bmesh/CMakeLists.txt +++ b/source/blender/bmesh/CMakeLists.txt @@ -1,4 +1,3 @@ -# $Id: CMakeLists.txt 31746 2010-09-04 05:31:25Z joeedh $ # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or @@ -26,11 +25,12 @@ set(INC . + ../blenfont ../blenkernel ../blenlib ../makesdna ../../../intern/guardedalloc -) + ../../../extern/bullet2/src ../../../intern/opennl/extern) set(INC_SYS @@ -52,6 +52,7 @@ set(SRC operators/bmo_mirror.c operators/bmo_primitive.c operators/bmo_removedoubles.c + operators/bmo_smooth_laplacian.c operators/bmo_symmetrize.c operators/bmo_subdivide.c operators/bmo_subdivide.h @@ -64,7 +65,9 @@ set(SRC intern/bmesh_construct.h intern/bmesh_core.c intern/bmesh_core.h - intern/bmesh_decimate.c + intern/bmesh_decimate_collapse.c + intern/bmesh_decimate_dissolve.c + intern/bmesh_decimate_unsubdivide.c intern/bmesh_decimate.h intern/bmesh_inline.h intern/bmesh_interp.c @@ -112,4 +115,12 @@ if(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") endif() +if(WITH_BULLET) + add_definitions(-DWITH_BULLET) +endif() + +if(WITH_INTERNATIONAL) + add_definitions(-DWITH_INTERNATIONAL) +endif() + blender_add_lib(bf_bmesh "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/bmesh/SConscript b/source/blender/bmesh/SConscript index fb00aef4d78..6765d57cb3e 100644 --- a/source/blender/bmesh/SConscript +++ b/source/blender/bmesh/SConscript @@ -9,11 +9,20 @@ sources += env.Glob('tools/*.c') incs = [ './', + '../blenfont', '../blenlib', '../makesdna', '../blenkernel', '#/intern/guardedalloc', - ] + '#/extern/bullet2/src', + '#/intern/opennl/extern', ] defs = [] + +if env['WITH_BF_BULLET']: + defs.append('WITH_BULLET') + +if env['WITH_BF_INTERNATIONAL']: + defs.append('WITH_INTERNATIONAL') + env.BlenderLib ( libname = 'bf_bmesh', sources = sources, includes = Split(incs), libtype = ['core','player'], defines=defs, priority=[100, 100], compileflags=cflags ) diff --git a/source/blender/bmesh/bmesh_class.h b/source/blender/bmesh/bmesh_class.h index 998407c82ba..bdca3011714 100644 --- a/source/blender/bmesh/bmesh_class.h +++ b/source/blender/bmesh/bmesh_class.h @@ -225,9 +225,8 @@ enum { BM_ELEM_DRAW = (1 << 5), /* edge display */ - /* we have 1 spare flag which is awesome but since we're limited to 8 - * only add new flags with care! - campbell */ - /* BM_ELEM_SPARE = (1 << 6), */ + /* spare tag, assumed dirty, use define in each function to name based on use */ + // _BM_ELEM_TAG_ALT = (1 << 6), // UNUSED BM_ELEM_FREESTYLE = (1 << 6), /* used for Freestyle faces and edges */ BM_ELEM_INTERNAL_TAG = (1 << 7) /* for low level internal API tagging, diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 6ccd0cbc491..645e4e348e8 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -725,6 +725,7 @@ static void bm_vert_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const BMVert *source_vertex, BMVert *target_vertex) { if ((source_mesh == target_mesh) && (source_vertex == target_vertex)) { + BLI_assert(!"BMVert: source and targer match"); return; } copy_v3_v3(target_vertex->no, source_vertex->no); @@ -737,6 +738,7 @@ static void bm_edge_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const BMEdge *source_edge, BMEdge *target_edge) { if ((source_mesh == target_mesh) && (source_edge == target_edge)) { + BLI_assert(!"BMEdge: source and targer match"); return; } CustomData_bmesh_free_block(&target_mesh->edata, &target_edge->head.data); @@ -748,6 +750,7 @@ static void bm_loop_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const BMLoop *source_loop, BMLoop *target_loop) { if ((source_mesh == target_mesh) && (source_loop == target_loop)) { + BLI_assert(!"BMLoop: source and targer match"); return; } CustomData_bmesh_free_block(&target_mesh->ldata, &target_loop->head.data); @@ -759,6 +762,7 @@ static void bm_face_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const BMFace *source_face, BMFace *target_face) { if ((source_mesh == target_mesh) && (source_face == target_face)) { + BLI_assert(!"BMFace: source and targer match"); return; } copy_v3_v3(target_face->no, source_face->no); @@ -781,8 +785,10 @@ void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *sour BLI_assert(sheader->htype == theader->htype); - if (sheader->htype != theader->htype) + if (sheader->htype != theader->htype) { + BLI_assert(!"type mismatch"); return; + } /* First we copy select */ if (BM_elem_flag_test((BMElem *)sheader, BM_ELEM_SELECT)) { diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 4e6decfa913..0910dd82701 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -28,12 +28,13 @@ #include "MEM_guardedalloc.h" #include "BLI_math_vector.h" - -#include "BKE_DerivedMesh.h" - #include "BLI_listbase.h" #include "BLI_array.h" +#include "BLF_translation.h" + +#include "BKE_DerivedMesh.h" + #include "bmesh.h" #include "intern/bmesh_private.h" @@ -960,7 +961,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const short do_del int rlen = count_flagged_radial(bm, l_iter, _FLAG_JF); if (rlen > 2) { - err = "Input faces do not form a contiguous manifold region"; + err = N_("Input faces do not form a contiguous manifold region"); goto error; } else if (rlen == 1) { @@ -1023,7 +1024,7 @@ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface, const short do_del newf = BM_face_create_ngon(bm, v1, v2, edges, tote, FALSE); if (UNLIKELY(!newf || BMO_error_occurred(bm))) { if (!BMO_error_occurred(bm)) - err = "Invalid boundary region to join faces"; + err = N_("Invalid boundary region to join faces"); goto error; } diff --git a/source/blender/bmesh/intern/bmesh_decimate.c b/source/blender/bmesh/intern/bmesh_decimate.c deleted file mode 100644 index 519bdba02a9..00000000000 --- a/source/blender/bmesh/intern/bmesh_decimate.c +++ /dev/null @@ -1,599 +0,0 @@ -/* - * ***** 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. - * - * Contributor(s): Campbell Barton - * - * ***** END GPL LICENSE BLOCK ***** - */ - -/** \file blender/bmesh/intern/bmesh_decimate.c - * \ingroup bmesh - * - * BMesh decimator. - */ - -#include <stddef.h> - -#include "MEM_guardedalloc.h" - -#include "DNA_scene_types.h" - -#include "BLI_math.h" -#include "BLI_quadric.h" -#include "BLI_heap.h" - -#include "bmesh.h" -#include "bmesh_structure.h" -#include "bmesh_decimate.h" - -/* defines for testing */ -#define USE_CUSTOMDATA -#define USE_TRIANGULATE - -/* these checks are for rare cases that we can't avoid since they are valid meshes still */ -#define USE_SAFETY_CHECKS - -#define BOUNDARY_PRESERVE_WEIGHT 100.0f - - -/* BMesh Helper Functions - * ********************** */ - -/** - * \param vquadrics must be calloc'd - */ -static void bm_decim_build_quadrics(BMesh *bm, Quadric *vquadrics) -{ - BMIter iter; - BMFace *f; - BMEdge *e; - - BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - BMLoop *l_first; - BMLoop *l_iter; - - const float *co = BM_FACE_FIRST_LOOP(f)->v->co; - const float *no = f->no; - const float offset = -dot_v3v3(no, co); - Quadric q; - - BLI_quadric_from_v3_dist(&q, no, offset); - - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { - BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(l_iter->v)], &q); - } while ((l_iter = l_iter->next) != l_first); - } - - /* boundary edges */ - BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - if (UNLIKELY(BM_edge_is_boundary(e))) { - float edge_vector[3]; - float edge_cross[3]; - sub_v3_v3v3(edge_vector, e->v2->co, e->v1->co); - f = e->l->f; - cross_v3_v3v3(edge_cross, edge_vector, f->no); - - if (normalize_v3(edge_cross) != 0.0f) { - Quadric q; - BLI_quadric_from_v3_dist(&q, edge_vector, -dot_v3v3(edge_cross, e->v1->co)); - BLI_quadric_mul(&q, BOUNDARY_PRESERVE_WEIGHT); - - BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(e->v1)], &q); - BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(e->v2)], &q); - } - } - } -} - - -static void bm_decim_calc_target_co(BMEdge *e, float optimize_co[3], - const Quadric *vquadrics) -{ - /* compute an edge contration target for edge ei - * this is computed by summing it's vertices quadrics and - * optimizing the result. */ - Quadric q; - - BLI_quadric_add_qu_ququ(&q, - &vquadrics[BM_elem_index_get(e->v1)], - &vquadrics[BM_elem_index_get(e->v2)]); - - - if (BLI_quadric_optimize(&q, optimize_co)) { - return; /* all is good */ - } - else { - mid_v3_v3v3(optimize_co, e->v1->co, e->v2->co); - } -} - -static void bm_decim_build_edge_cost_single(BMEdge *e, - const Quadric *vquadrics, - Heap *eheap, HeapNode **eheap_table) -{ - const Quadric *q1, *q2; - float optimize_co[3]; - float cost; - - if (eheap_table[BM_elem_index_get(e)]) { - BLI_heap_remove(eheap, eheap_table[BM_elem_index_get(e)]); - } - - /* check we can collapse, some edges we better not touch */ - if (BM_edge_is_boundary(e)) { - if (e->l->f->len == 3) { - /* pass */ - } - else { - /* only collapse tri's */ - eheap_table[BM_elem_index_get(e)] = NULL; - return; - } - } - else if (BM_edge_is_manifold(e)) { - if ((e->l->f->len == 3) && (e->l->radial_next->f->len == 3)) { - /* pass */ - } - else { - /* only collapse tri's */ - eheap_table[BM_elem_index_get(e)] = NULL; - return; - } - } - else { - eheap_table[BM_elem_index_get(e)] = NULL; - return; - } - /* end sanity check */ - - - bm_decim_calc_target_co(e, optimize_co, vquadrics); - - q1 = &vquadrics[BM_elem_index_get(e->v1)]; - q2 = &vquadrics[BM_elem_index_get(e->v2)]; - - cost = (BLI_quadric_evaluate(q1, optimize_co) + BLI_quadric_evaluate(q2, optimize_co)); - - eheap_table[BM_elem_index_get(e)] = BLI_heap_insert(eheap, cost, e); -} - -static void bm_decim_build_edge_cost(BMesh *bm, - const Quadric *vquadrics, - Heap *eheap, HeapNode **eheap_table) -{ - BMIter iter; - BMEdge *e; - unsigned int i; - - BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) { - eheap_table[i] = NULL; /* keep sanity check happy */ - bm_decim_build_edge_cost_single(e, vquadrics, eheap, eheap_table); - } -} - -#ifdef USE_TRIANGULATE -/* Temp Triangulation - * ****************** */ - -/** - * To keep things simple we can only collapse edges on triangulated data - * (limitation with edge collapse and error calculation functions). - * - * But to avoid annoying users by only giving triangle results, we can - * triangulate, keeping a reference between the faces, then join after - * if the edges don't collapse, this will also allow more choices when - * collapsing edges so even has some advantage over decimating quads - * directly. - * - * \return TRUE if any faces were triangulated. - */ - -static int bm_decim_triangulate_begin(BMesh *bm) -{ -#ifdef USE_SAFETY_CHECKS - const int check_double_edges = TRUE; -#else - const int check_double_edges = FALSE; -#endif - - BMIter iter; - BMFace *f; - // int has_quad; // could optimize this a little - int has_cut = FALSE; - - BLI_assert((bm->elem_index_dirty & BM_VERT) == 0); - - /* first clear loop index values */ - BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - BMLoop *l_iter; - BMLoop *l_first; - - l_iter = l_first = BM_FACE_FIRST_LOOP(f); - do { - BM_elem_index_set(l_iter, -1); - } while ((l_iter = l_iter->next) != l_first); - - // has_quad |= (f->len == 4) - } - - /* adding new faces as we loop over faces - * is normally best avoided, however in this case its not so bad because any face touched twice - * will already be triangulated*/ - BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { - if (f->len == 4) { - BMLoop *f_l[4]; - BMLoop *l_iter; - BMLoop *l_a, *l_b; - - l_iter = BM_FACE_FIRST_LOOP(f); - - f_l[0] = l_iter; l_iter = l_iter->next; - f_l[1] = l_iter; l_iter = l_iter->next; - f_l[2] = l_iter; l_iter = l_iter->next; - f_l[3] = l_iter; l_iter = l_iter->next; - - if (len_squared_v3v3(f_l[0]->v->co, f_l[2]->v->co) < len_squared_v3v3(f_l[1]->v->co, f_l[3]->v->co)) { - l_a = f_l[0]; - l_b = f_l[2]; - } - else { - l_a = f_l[1]; - l_b = f_l[3]; - } - - { - BMFace *f_new; - BMLoop *l_new; - - /* warning, NO_DOUBLE option here isn't handled as nice as it could be - * - if there is a quad that has a free standing edge joining it along - * where we want to split the face, there isnt a good way we can handle this. - * currently that edge will get removed when joining the tris back into a quad. */ - f_new = BM_face_split(bm, f, l_a->v, l_b->v, &l_new, NULL, check_double_edges); - - if (f_new) { - /* the value of this doesn't matter, only that the 2 loops match and have unique values */ - const int f_index = BM_elem_index_get(f); - - /* since we just split theres only ever 2 loops */ - BLI_assert(BM_edge_is_manifold(l_new->e)); - - BM_elem_index_set(l_new, f_index); - BM_elem_index_set(l_new->radial_next, f_index); - - has_cut = TRUE; - } - } - } - } - - BLI_assert((bm->elem_index_dirty & BM_VERT) == 0); - - if (has_cut) { - /* now triangulation is done we need to correct index values */ - BM_mesh_elem_index_ensure(bm, BM_EDGE | BM_FACE); - } - - return has_cut; -} - -static void bm_decim_triangulate_end(BMesh *bm) -{ - /* decimation finished, now re-join */ - BMIter iter; - BMEdge *e; - - /* boundary edges */ - BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { - BMLoop *l_a, *l_b; - if (BM_edge_loop_pair(e, &l_a, &l_b)) { - const int l_a_index = BM_elem_index_get(l_a); - if (l_a_index != -1) { - const int l_b_index = BM_elem_index_get(l_b); - if (l_a_index == l_b_index) { - /* highly unlikely to fail, but prevents possible double-ups */ - if (l_a->f->len == 3 && l_b->f->len == 3) { - BMFace *f[2] = {l_a->f, l_b->f}; - BM_faces_join(bm, f, 2, TRUE); - } - } - } - } - } -} - -#endif /* USE_TRIANGULATE */ - -/* Edge Collapse Functions - * *********************** */ - -/** - * special, highly limited edge collapse function - * intended for speed over flexibiliy. - * can only collapse edges connected to (1, 2) tris. - * - * Important - dont add vert/edge/face data on collapsing! - * - * \param ke_other let caller know what edges we remove besides \a ke - */ -static int bm_edge_collapse(BMesh *bm, BMEdge *ke, BMVert *kv, int ke_other[2], -#ifdef USE_CUSTOMDATA - const float customdata_fac -#else - const float UNUSED(customdata_fac) -#endif - ) -{ - BMVert *v_other = BM_edge_other_vert(ke, kv); - - BLI_assert(v_other != NULL); - - if (BM_edge_is_manifold(ke)) { - BMLoop *l_a, *l_b; - BMEdge *e_a_other[2], *e_b_other[2]; - int ok; - - ok = BM_edge_loop_pair(ke, &l_a, &l_b); - - BLI_assert(ok == TRUE); - BLI_assert(l_a->f->len == 3); - BLI_assert(l_b->f->len == 3); - - /* keep 'kv' 0th */ - if (BM_vert_in_edge(l_a->prev->e, kv)) { - e_a_other[0] = l_a->prev->e; - e_a_other[1] = l_a->next->e; - } - else { - e_a_other[1] = l_a->prev->e; - e_a_other[0] = l_a->next->e; - } - - if (BM_vert_in_edge(l_b->prev->e, kv)) { - e_b_other[0] = l_b->prev->e; - e_b_other[1] = l_b->next->e; - } - else { - e_b_other[1] = l_b->prev->e; - e_b_other[0] = l_b->next->e; - } - - BLI_assert(BM_edge_share_vert(e_a_other[0], e_b_other[0])); - BLI_assert(BM_edge_share_vert(e_a_other[1], e_b_other[1])); - - /* we could assert this case, but better just bail out */ -#if 0 - BLI_assert(e_a_other[0] != e_b_other[0]); - BLI_assert(e_a_other[0] != e_b_other[1]); - BLI_assert(e_b_other[0] != e_a_other[0]); - BLI_assert(e_b_other[0] != e_a_other[1]); -#endif - /* not totally common but we want to avoid */ - if (ELEM(e_a_other[0], e_b_other[0], e_b_other[1]) || - ELEM(e_a_other[1], e_b_other[0], e_b_other[1])) - { - return FALSE; - } - - ke_other[0] = BM_elem_index_get(e_a_other[0]); - ke_other[1] = BM_elem_index_get(e_b_other[0]); - -#ifdef USE_CUSTOMDATA - /* TODO, loops */ - // const float w[2] = {customdata_fac, 1.0f - customdata_fac}; - - /* before killing, do customdata */ - BM_data_interp_from_verts(bm, v_other, kv, v_other, customdata_fac); -#endif - - BM_edge_kill(bm, ke); - - BM_vert_splice(bm, kv, v_other); - - BM_edge_splice(bm, e_a_other[0], e_a_other[1]); - BM_edge_splice(bm, e_b_other[0], e_b_other[1]); - - // BM_mesh_validate(bm); - - return TRUE; - } - else if (BM_edge_is_boundary(ke)) { - /* same as above but only one triangle */ - BMLoop *l_a; - BMEdge *e_a_other[2]; - - l_a = ke->l; - - BLI_assert(l_a->f->len == 3); - - /* keep 'kv' 0th */ - if (BM_vert_in_edge(l_a->prev->e, kv)) { - e_a_other[0] = l_a->prev->e; - e_a_other[1] = l_a->next->e; - } - else { - e_a_other[1] = l_a->prev->e; - e_a_other[0] = l_a->next->e; - } - - ke_other[0] = BM_elem_index_get(e_a_other[0]); - ke_other[1] = -1; - -#ifdef USE_CUSTOMDATA - /* TODO, loops */ - // const float w[2] = {customdata_fac, 1.0f - customdata_fac}; - - /* before killing, do customdata */ - BM_data_interp_from_verts(bm, v_other, kv, v_other, customdata_fac); -#endif - - BM_edge_kill(bm, ke); - - BM_vert_splice(bm, kv, v_other); - - BM_edge_splice(bm, e_a_other[0], e_a_other[1]); - - // BM_mesh_validate(bm); - - return TRUE; - } - else { - return FALSE; - } -} - - -/* collapse e the edge, removing e->v2 */ -static void bm_decim_edge_collapse(BMesh *bm, BMEdge *e, - Quadric *vquadrics, - Heap *eheap, HeapNode **eheap_table) -{ - int ke_other[2]; - BMVert *v = e->v1; - int kv_index = BM_elem_index_get(e->v2); /* the vert is removed so only store the index */ - float optimize_co[3]; - float customdata_fac; - - bm_decim_calc_target_co(e, optimize_co, vquadrics); - - /* use for customdata merging */ - customdata_fac = line_point_factor_v3(optimize_co, e->v1->co, e->v2->co); - - if (bm_edge_collapse(bm, e, e->v2, ke_other, customdata_fac)) { - /* update collapse info */ - int i; - - e = NULL; /* paranoid safety check */ - - copy_v3_v3(v->co, optimize_co); - - /* remove eheap */ - for (i = 0; i < 2; i++) { - /* highly unlikely 'eheap_table[ke_other[i]]' would be NULL, but do for sanity sake */ - if ((ke_other[i] != -1) && (eheap_table[ke_other[i]] != NULL)) { - BLI_heap_remove(eheap, eheap_table[ke_other[i]]); - eheap_table[ke_other[i]] = NULL; - } - } - - /* update vertex quadric, add kept vertex from killed vertex */ - BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(v)], &vquadrics[kv_index]); - - /* update connected normals */ - BM_vert_normal_update_all(v); - - /* update error costs and the eheap */ - if (LIKELY(v->e)) { - BMEdge *e_iter; - BMEdge *e_first; - e_iter = e_first = v->e; - do { - //BLI_assert(BM_edge_find_double(e_iter) == NULL); -#ifdef USE_SAFETY_CHECKS - /* note! - this check is slow, but we can't avoid it - Campbell */ - BMEdge *e_double; - - e_double = BM_edge_find_double(e_iter); - - if (UNLIKELY(e_double != NULL)) { - int e_index = BM_elem_index_get(e_double); - if (BM_edge_splice(bm, e_double, e_iter)) { - if (eheap_table[e_index]) { - BLI_heap_remove(eheap, eheap_table[e_index]); - eheap_table[e_index] = NULL; - } - } - } - - /* if this happens, the e_double check could be put in a while loop, - * so as to keep removing doubles while they are found. so far this isnt needed */ - BLI_assert(BM_edge_find_double(e_iter) == NULL); -#endif - - bm_decim_build_edge_cost_single(e_iter, vquadrics, eheap, eheap_table); - } while ((e_iter = bmesh_disk_edge_next(e_iter, v)) != e_first); - - } - } -} - - -/* Main Decimate Function - * ********************** */ - -void BM_mesh_decimate(BMesh *bm, const float factor) -{ - Heap *eheap; /* edge heap */ - HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */ - Quadric *vquadrics; /* vert index aligned quadrics */ - int tot_edge_orig; - int face_tot_target; - int use_triangulate; - - -#ifdef USE_TRIANGULATE - /* temp convert quads to triangles */ - use_triangulate = bm_decim_triangulate_begin(bm); -#endif - - - /* alloc vars */ - vquadrics = MEM_callocN(sizeof(Quadric) * bm->totvert, __func__); - eheap = BLI_heap_new_ex(bm->totedge); - eheap_table = MEM_callocN(sizeof(HeapNode *) * bm->totedge, __func__); - tot_edge_orig = bm->totedge; - - - /* build initial edge collapse cost data */ - bm_decim_build_quadrics(bm, vquadrics); - - bm_decim_build_edge_cost(bm, vquadrics, eheap, eheap_table); - - face_tot_target = bm->totface * factor; - bm->elem_index_dirty |= BM_FACE | BM_EDGE | BM_VERT; - - - /* iterative edge collapse and maintain the eheap */ - while ((bm->totface > face_tot_target) && (BLI_heap_empty(eheap) == FALSE)) { - BMEdge *e = BLI_heap_popmin(eheap); - BLI_assert(BM_elem_index_get(e) < tot_edge_orig); /* handy to detect corruptions elsewhere */ - - /* under normal conditions wont be accessed again, - * but NULL just incase so we don't use freed node */ - eheap_table[BM_elem_index_get(e)] = NULL; - - bm_decim_edge_collapse(bm, e, vquadrics, eheap, eheap_table); - } - - -#ifdef USE_TRIANGULATE - /* its possible we only had triangles, skip this step in that case */ - if (LIKELY(use_triangulate)) { - /* temp convert quads to triangles */ - bm_decim_triangulate_end(bm); - } -#endif - - /* free vars */ - MEM_freeN(vquadrics); - MEM_freeN(eheap_table); - BLI_heap_free(eheap, NULL); - - /* testing only */ - // BM_mesh_validate(bm); -} diff --git a/source/blender/bmesh/intern/bmesh_decimate.h b/source/blender/bmesh/intern/bmesh_decimate.h index e44aa576bda..04dc0cfd2ea 100644 --- a/source/blender/bmesh/intern/bmesh_decimate.h +++ b/source/blender/bmesh/intern/bmesh_decimate.h @@ -27,6 +27,15 @@ * \ingroup bmesh */ -void BM_mesh_decimate(BMesh *bm, const float factor); +void BM_mesh_decimate_collapse(BMesh *bm, const float factor, float *vweights, const int do_triangulate); + +void BM_mesh_decimate_unsubdivide_ex(BMesh *bm, const int iterations, const int tag_only); +void BM_mesh_decimate_unsubdivide(BMesh *bm, const int iterations); + +void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const int do_dissolve_boundaries, + BMVert **vinput_arr, const int vinput_len, + BMEdge **einput_arr, const int einput_len); +void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const int do_dissolve_boundaries); + #endif /* __BMESH_DECIMATE_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_decimate_collapse.c b/source/blender/bmesh/intern/bmesh_decimate_collapse.c new file mode 100644 index 00000000000..fbdbe2ffe94 --- /dev/null +++ b/source/blender/bmesh/intern/bmesh_decimate_collapse.c @@ -0,0 +1,949 @@ +/* + * ***** 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. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/bmesh/intern/bmesh_decimate_collapse.c + * \ingroup bmesh + * + * BMesh decimator that uses an edge collapse method. + */ + +#include <stddef.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_scene_types.h" + +#include "BLI_math.h" +#include "BLI_quadric.h" +#include "BLI_heap.h" + +#include "BKE_customdata.h" + +#include "bmesh.h" +#include "bmesh_structure.h" +#include "bmesh_decimate.h" /* own include */ + +/* defines for testing */ +#define USE_CUSTOMDATA +#define USE_TRIANGULATE + +/* these checks are for rare cases that we can't avoid since they are valid meshes still */ +#define USE_SAFETY_CHECKS + +#define BOUNDARY_PRESERVE_WEIGHT 100.0f + +typedef enum CD_UseFlag { + CD_DO_VERT, + CD_DO_EDGE, + CD_DO_LOOP +} CD_UseFlag; + + +/* BMesh Helper Functions + * ********************** */ + +/** + * \param vquadrics must be calloc'd + */ +static void bm_decim_build_quadrics(BMesh *bm, Quadric *vquadrics) +{ + BMIter iter; + BMFace *f; + BMEdge *e; + + BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { + BMLoop *l_first; + BMLoop *l_iter; + + const float *co = BM_FACE_FIRST_LOOP(f)->v->co; + const float *no = f->no; + const float offset = -dot_v3v3(no, co); + Quadric q; + + BLI_quadric_from_v3_dist(&q, no, offset); + + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(l_iter->v)], &q); + } while ((l_iter = l_iter->next) != l_first); + } + + /* boundary edges */ + BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { + if (UNLIKELY(BM_edge_is_boundary(e))) { + float edge_vector[3]; + float edge_cross[3]; + sub_v3_v3v3(edge_vector, e->v2->co, e->v1->co); + f = e->l->f; + cross_v3_v3v3(edge_cross, edge_vector, f->no); + + if (fabsf(normalize_v3(edge_cross)) > FLT_EPSILON) { + Quadric q; + BLI_quadric_from_v3_dist(&q, edge_cross, -dot_v3v3(edge_cross, e->v1->co)); + BLI_quadric_mul(&q, BOUNDARY_PRESERVE_WEIGHT); + + BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(e->v1)], &q); + BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(e->v2)], &q); + } + } + } +} + + +static void bm_decim_calc_target_co(BMEdge *e, float optimize_co[3], + const Quadric *vquadrics) +{ + /* compute an edge contration target for edge 'e' + * this is computed by summing it's vertices quadrics and + * optimizing the result. */ + Quadric q; + + BLI_quadric_add_qu_ququ(&q, + &vquadrics[BM_elem_index_get(e->v1)], + &vquadrics[BM_elem_index_get(e->v2)]); + + + if (BLI_quadric_optimize(&q, optimize_co)) { + return; /* all is good */ + } + else { + mid_v3_v3v3(optimize_co, e->v1->co, e->v2->co); + } +} + +static void bm_decim_build_edge_cost_single(BMEdge *e, + const Quadric *vquadrics, const float *vweights, + Heap *eheap, HeapNode **eheap_table) +{ + const Quadric *q1, *q2; + float optimize_co[3]; + float cost; + + if (eheap_table[BM_elem_index_get(e)]) { + BLI_heap_remove(eheap, eheap_table[BM_elem_index_get(e)]); + } + + /* check we can collapse, some edges we better not touch */ + if (BM_edge_is_boundary(e)) { + if (e->l->f->len == 3) { + /* pass */ + } + else { + /* only collapse tri's */ + eheap_table[BM_elem_index_get(e)] = NULL; + return; + } + } + else if (BM_edge_is_manifold(e)) { + if ((e->l->f->len == 3) && (e->l->radial_next->f->len == 3)) { + /* pass */ + } + else { + /* only collapse tri's */ + eheap_table[BM_elem_index_get(e)] = NULL; + return; + } + } + else { + eheap_table[BM_elem_index_get(e)] = NULL; + return; + } + + if (vweights) { + if ((vweights[BM_elem_index_get(e->v1)] < FLT_EPSILON) && + (vweights[BM_elem_index_get(e->v2)] < FLT_EPSILON)) + { + /* skip collapsing this edge */ + eheap_table[BM_elem_index_get(e)] = NULL; + return; + } + } + /* end sanity check */ + + + bm_decim_calc_target_co(e, optimize_co, vquadrics); + + q1 = &vquadrics[BM_elem_index_get(e->v1)]; + q2 = &vquadrics[BM_elem_index_get(e->v2)]; + + if (vweights == NULL) { + cost = (BLI_quadric_evaluate(q1, optimize_co) + + BLI_quadric_evaluate(q2, optimize_co)); + } + else { + cost = ((BLI_quadric_evaluate(q1, optimize_co) * vweights[BM_elem_index_get(e->v1)]) + + (BLI_quadric_evaluate(q2, optimize_co) * vweights[BM_elem_index_get(e->v2)])); + } + // print("COST %.12f\n"); + + eheap_table[BM_elem_index_get(e)] = BLI_heap_insert(eheap, cost, e); +} + +static void bm_decim_build_edge_cost(BMesh *bm, + const Quadric *vquadrics, const float *vweights, + Heap *eheap, HeapNode **eheap_table) +{ + BMIter iter; + BMEdge *e; + unsigned int i; + + BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) { + eheap_table[i] = NULL; /* keep sanity check happy */ + bm_decim_build_edge_cost_single(e, vquadrics, vweights, eheap, eheap_table); + } +} + +#ifdef USE_TRIANGULATE +/* Temp Triangulation + * ****************** */ + +/** + * To keep things simple we can only collapse edges on triangulated data + * (limitation with edge collapse and error calculation functions). + * + * But to avoid annoying users by only giving triangle results, we can + * triangulate, keeping a reference between the faces, then join after + * if the edges don't collapse, this will also allow more choices when + * collapsing edges so even has some advantage over decimating quads + * directly. + * + * \return TRUE if any faces were triangulated. + */ + +static int bm_decim_triangulate_begin(BMesh *bm) +{ + BMIter iter; + BMFace *f; + // int has_quad; // could optimize this a little + int has_cut = FALSE; + + BLI_assert((bm->elem_index_dirty & BM_VERT) == 0); + + /* first clear loop index values */ + BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { + BMLoop *l_iter; + BMLoop *l_first; + + l_iter = l_first = BM_FACE_FIRST_LOOP(f); + do { + BM_elem_index_set(l_iter, -1); + } while ((l_iter = l_iter->next) != l_first); + + // has_quad |= (f->len == 4) + } + + /* adding new faces as we loop over faces + * is normally best avoided, however in this case its not so bad because any face touched twice + * will already be triangulated*/ + BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { + if (f->len == 4) { + BMLoop *f_l[4]; + BMLoop *l_a, *l_b; + + { + BMLoop *l_iter = BM_FACE_FIRST_LOOP(f); + + f_l[0] = l_iter; l_iter = l_iter->next; + f_l[1] = l_iter; l_iter = l_iter->next; + f_l[2] = l_iter; l_iter = l_iter->next; + f_l[3] = l_iter; + } + + if (len_squared_v3v3(f_l[0]->v->co, f_l[2]->v->co) < + len_squared_v3v3(f_l[1]->v->co, f_l[3]->v->co)) + { + l_a = f_l[0]; + l_b = f_l[2]; + } + else { + l_a = f_l[1]; + l_b = f_l[3]; + } + +#ifdef USE_SAFETY_CHECKS + if (BM_edge_exists(l_a->v, l_b->v) == FALSE) +#endif + { + BMFace *f_new; + BMLoop *l_new; + + /* warning, NO_DOUBLE option here isn't handled as nice as it could be + * - if there is a quad that has a free standing edge joining it along + * where we want to split the face, there isnt a good way we can handle this. + * currently that edge will get removed when joining the tris back into a quad. */ + f_new = BM_face_split(bm, f, l_a->v, l_b->v, &l_new, NULL, FALSE); + + if (f_new) { + /* the value of this doesn't matter, only that the 2 loops match and have unique values */ + const int f_index = BM_elem_index_get(f); + + /* since we just split theres only ever 2 loops */ + BLI_assert(BM_edge_is_manifold(l_new->e)); + + BM_elem_index_set(l_new, f_index); + BM_elem_index_set(l_new->radial_next, f_index); + + BM_face_normal_update(f); + BM_face_normal_update(f_new); + + has_cut = TRUE; + } + } + } + } + + BLI_assert((bm->elem_index_dirty & BM_VERT) == 0); + + if (has_cut) { + /* now triangulation is done we need to correct index values */ + BM_mesh_elem_index_ensure(bm, BM_EDGE | BM_FACE); + } + + return has_cut; +} + +static void bm_decim_triangulate_end(BMesh *bm) +{ + /* decimation finished, now re-join */ + BMIter iter; + BMEdge *e; + + /* boundary edges */ + BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { + BMLoop *l_a, *l_b; + if (BM_edge_loop_pair(e, &l_a, &l_b)) { + const int l_a_index = BM_elem_index_get(l_a); + if (l_a_index != -1) { + const int l_b_index = BM_elem_index_get(l_b); + if (l_a_index == l_b_index) { + if (LIKELY(l_a->f->len == 3 && l_b->f->len == 3)) { + if (l_a->v != l_b->v) { /* if this is the case, faces have become flipped */ + /* check we are not making a degenerate quad */ + BMVert *vquad[4] = { + e->v1, + BM_vert_in_edge(e, l_a->next->v) ? l_a->prev->v : l_a->next->v, + e->v2, + BM_vert_in_edge(e, l_b->next->v) ? l_b->prev->v : l_b->next->v, + }; + + BLI_assert(ELEM3(vquad[0], vquad[1], vquad[2], vquad[3]) == FALSE); + BLI_assert(ELEM3(vquad[1], vquad[0], vquad[2], vquad[3]) == FALSE); + BLI_assert(ELEM3(vquad[2], vquad[1], vquad[0], vquad[3]) == FALSE); + BLI_assert(ELEM3(vquad[3], vquad[1], vquad[2], vquad[0]) == FALSE); + + if (is_quad_convex_v3(vquad[0]->co, vquad[1]->co, vquad[2]->co, vquad[3]->co)) { + /* highly unlikely to fail, but prevents possible double-ups */ + BMFace *f[2] = {l_a->f, l_b->f}; + BM_faces_join(bm, f, 2, TRUE); + } + } + } + } + } + } + } +} + +#endif /* USE_TRIANGULATE */ + +/* Edge Collapse Functions + * *********************** */ + +#ifdef USE_CUSTOMDATA + +/** + * \param v is the target to merge into. + */ +static void bm_edge_collapse_loop_customdata(BMesh *bm, BMLoop *l, BMVert *v_clear, BMVert *v_other, + const float customdata_fac) +{ + /* these don't need to be updated, since they will get removed when the edge collapses */ + BMLoop *l_clear, *l_other; + const int is_manifold = BM_edge_is_manifold(l->e); + int side; + + /* l defines the vert to collapse into */ + + /* first find the loop of 'v_other' thats attached to the face of 'l' */ + if (l->v == v_clear) { + l_clear = l; + l_other = l->next; + } + else { + l_clear = l->next; + l_other = l; + } + + BLI_assert(l_clear->v == v_clear); + BLI_assert(l_other->v == v_other); + (void)v_other; /* quiet warnings for release */ + + /* now we have both corners of the face 'l->f' */ + for (side = 0; side < 2; side++) { + int is_seam = FALSE; + void *src[2]; + BMFace *f_exit = is_manifold ? l->radial_next->f : NULL; + BMEdge *e_prev = l->e; + BMLoop *l_first; + BMLoop *l_iter; + float w[2]; + + if (side == 0) { + l_iter = l_first = l_clear; + src[0] = l_clear->head.data; + src[1] = l_other->head.data; + + w[0] = customdata_fac; + w[1] = 1.0f - customdata_fac; + } + else { + l_iter = l_first = l_other; + src[0] = l_other->head.data; + src[1] = l_clear->head.data; + + w[0] = 1.0f - customdata_fac; + w[1] = customdata_fac; + } + + // print_v2("weights", w); + + /* WATCH IT! - should NOT reference (_clear or _other) vars for this while loop */ + + /* walk around the fan using 'e_prev' */ + while (((l_iter = BM_vert_step_fan_loop(l_iter, &e_prev)) != l_first) && (l_iter != NULL)) { + int i; + /* quit once we hit the opposite face, if we have one */ + if (f_exit && UNLIKELY(f_exit == l_iter->f)) { + break; + } + + /* break out unless we find a match */ + is_seam = TRUE; + + /* ok. we have a loop. now be smart with it! */ + for (i = 0; i < bm->ldata.totlayer; i++) { + if (CustomData_layer_has_math(&bm->ldata, i)) { + const int offset = bm->ldata.layers[i].offset; + const int type = bm->ldata.layers[i].type; + void *cd_src, *cd_iter; + + /* todo, make nicer macros for this */ + cd_src = (char *)src[0] + offset; + // cd_dst = (char *)src[1] + offset; // UNUSED + cd_iter = (char *)l_iter->head.data + offset; + + /* detect seams */ + if (CustomData_data_equals(type, cd_src, cd_iter)) { + CustomData_bmesh_interp(&bm->ldata, src, w, NULL, 2, l_iter->head.data); + is_seam = FALSE; + } + } + } + + if (is_seam) { + break; + } + } + } +} +#endif /* USE_CUSTOMDATA */ + +/** + * Check if the collapse will result in a degenerate mesh, + * that is - duplicate edges or faces. + * + * This situation could be checked for when calculating collapse cost + * however its quite slow and a degenerate collapse could eventuate + * after the cost is calculated, so instead, check just before collapsing. + */ + +static void bm_edge_tag_enable(BMEdge *e) +{ + BM_elem_flag_enable(e->v1, BM_ELEM_TAG); + BM_elem_flag_enable(e->v2, BM_ELEM_TAG); + if (e->l) { + BM_elem_flag_enable(e->l->f, BM_ELEM_TAG); + if (e->l != e->l->radial_next) { + BM_elem_flag_enable(e->l->radial_next->f, BM_ELEM_TAG); + } + } +} + +static void bm_edge_tag_disable(BMEdge *e) +{ + BM_elem_flag_disable(e->v1, BM_ELEM_TAG); + BM_elem_flag_disable(e->v2, BM_ELEM_TAG); + if (e->l) { + BM_elem_flag_disable(e->l->f, BM_ELEM_TAG); + if (e->l != e->l->radial_next) { + BM_elem_flag_disable(e->l->radial_next->f, BM_ELEM_TAG); + } + } +} + +static int bm_edge_tag_test(BMEdge *e) +{ + /* is the edge or one of its faces tagged? */ + return (BM_elem_flag_test(e->v1, BM_ELEM_TAG) || + BM_elem_flag_test(e->v2, BM_ELEM_TAG) || + (e->l && (BM_elem_flag_test(e->l->f, BM_ELEM_TAG) || + (e->l != e->l->radial_next && + BM_elem_flag_test(e->l->radial_next->f, BM_ELEM_TAG)))) + ); +} + +/* takes the edges loop */ +BLI_INLINE int bm_edge_is_manifold_or_boundary(BMLoop *l) +{ +#if 0 + /* less optimized version of check below */ + return (BM_edge_is_manifold(l->e) || BM_edge_is_boundary(l->e); +#else + /* if the edge is a boundary it points to its self, else this must be a manifold */ + return LIKELY(l) && LIKELY(l->radial_next->radial_next == l); +#endif +} + +static int bm_edge_collapse_is_degenerate(BMEdge *e_first) +{ + /* simply check that there is no overlap between faces and edges of each vert, + * (excluding the 2 faces attached to 'e' and 'e' its self) */ + + BMEdge *e_iter; + + /* clear flags on both disks */ + e_iter = e_first; + do { + if (!bm_edge_is_manifold_or_boundary(e_iter->l)) { + return TRUE; + } + bm_edge_tag_disable(e_iter); + } while ((e_iter = bmesh_disk_edge_next(e_iter, e_first->v1)) != e_first); + + e_iter = e_first; + do { + if (!bm_edge_is_manifold_or_boundary(e_iter->l)) { + return TRUE; + } + bm_edge_tag_disable(e_iter); + } while ((e_iter = bmesh_disk_edge_next(e_iter, e_first->v2)) != e_first); + + /* now enable one side... */ + e_iter = e_first; + do { + bm_edge_tag_enable(e_iter); + } while ((e_iter = bmesh_disk_edge_next(e_iter, e_first->v1)) != e_first); + + /* ... except for the edge we will collapse, we know thats shared, + * disable this to avoid false positive. We could be smart and never enable these + * face/edge tags in the first place but easier to do this */ + // bm_edge_tag_disable(e_first); + /* do inline... */ + { +#if 0 + BMIter iter; + BMIter liter; + BMLoop *l; + BMVert *v; + BM_ITER_ELEM (l, &liter, e_first, BM_LOOPS_OF_EDGE) { + BM_elem_flag_disable(l->f, BM_ELEM_TAG); + BM_ITER_ELEM (v, &iter, l->f, BM_VERTS_OF_FACE) { + BM_elem_flag_disable(v, BM_ELEM_TAG); + } + } +#else + /* we know each face is a triangle, no looping/iterators needed here */ + + BMLoop *l_radial; + BMLoop *l_face; + + l_radial = e_first->l; + l_face = l_radial; + BLI_assert(l_face->f->len == 3); + BM_elem_flag_disable(l_face->f, BM_ELEM_TAG); + BM_elem_flag_disable((l_face = l_radial)->v, BM_ELEM_TAG); + BM_elem_flag_disable((l_face = l_face->next)->v, BM_ELEM_TAG); + BM_elem_flag_disable(( l_face->next)->v, BM_ELEM_TAG); + l_face = l_radial->radial_next; + if (l_radial != l_face) { + BLI_assert(l_face->f->len == 3); + BM_elem_flag_disable(l_face->f, BM_ELEM_TAG); + BM_elem_flag_disable((l_face = l_radial->radial_next)->v, BM_ELEM_TAG); + BM_elem_flag_disable((l_face = l_face->next)->v, BM_ELEM_TAG); + BM_elem_flag_disable(( l_face->next)->v, BM_ELEM_TAG); + } +#endif + } + + /* and check for overlap */ + e_iter = e_first; + do { + if (bm_edge_tag_test(e_iter)) { + return TRUE; + } + } while ((e_iter = bmesh_disk_edge_next(e_iter, e_first->v2)) != e_first); + + return FALSE; +} + +/** + * special, highly limited edge collapse function + * intended for speed over flexibiliy. + * can only collapse edges connected to (1, 2) tris. + * + * Important - dont add vert/edge/face data on collapsing! + * + * \param e_clear_other let caller know what edges we remove besides \a e_clear + * \param customdata_flag merge factor, scales from 0 - 1 ('v_clear' -> 'v_other') + */ +static int bm_edge_collapse(BMesh *bm, BMEdge *e_clear, BMVert *v_clear, int r_e_clear_other[2], +#ifdef USE_CUSTOMDATA + const CD_UseFlag customdata_flag, + const float customdata_fac +#else + const CD_UseFlag UNUSED(customdata_flag), + const float UNUSED(customdata_fac) +#endif + ) +{ + BMVert *v_other; + + /* disallow collapsing which results in degenerate cases */ + if (bm_edge_collapse_is_degenerate(e_clear)) { + return FALSE; + } + + v_other = BM_edge_other_vert(e_clear, v_clear); + BLI_assert(v_other != NULL); + + if (BM_edge_is_manifold(e_clear)) { + BMLoop *l_a, *l_b; + BMEdge *e_a_other[2], *e_b_other[2]; + int ok; + + ok = BM_edge_loop_pair(e_clear, &l_a, &l_b); + + BLI_assert(ok == TRUE); + BLI_assert(l_a->f->len == 3); + BLI_assert(l_b->f->len == 3); + + /* keep 'v_clear' 0th */ + if (BM_vert_in_edge(l_a->prev->e, v_clear)) { + e_a_other[0] = l_a->prev->e; + e_a_other[1] = l_a->next->e; + } + else { + e_a_other[1] = l_a->prev->e; + e_a_other[0] = l_a->next->e; + } + + if (BM_vert_in_edge(l_b->prev->e, v_clear)) { + e_b_other[0] = l_b->prev->e; + e_b_other[1] = l_b->next->e; + } + else { + e_b_other[1] = l_b->prev->e; + e_b_other[0] = l_b->next->e; + } + + BLI_assert(BM_edge_share_vert(e_a_other[0], e_b_other[0])); + BLI_assert(BM_edge_share_vert(e_a_other[1], e_b_other[1])); + + /* we could assert this case, but better just bail out */ +#if 0 + BLI_assert(e_a_other[0] != e_b_other[0]); + BLI_assert(e_a_other[0] != e_b_other[1]); + BLI_assert(e_b_other[0] != e_a_other[0]); + BLI_assert(e_b_other[0] != e_a_other[1]); +#endif + /* not totally common but we want to avoid */ + if (ELEM(e_a_other[0], e_b_other[0], e_b_other[1]) || + ELEM(e_a_other[1], e_b_other[0], e_b_other[1])) + { + return FALSE; + } + + r_e_clear_other[0] = BM_elem_index_get(e_a_other[0]); + r_e_clear_other[1] = BM_elem_index_get(e_b_other[0]); + +#ifdef USE_CUSTOMDATA + /* before killing, do customdata */ + if (customdata_flag & CD_DO_VERT) { + BM_data_interp_from_verts(bm, v_other, v_clear, v_other, customdata_fac); + } + if (customdata_flag & CD_DO_EDGE) { + BM_data_interp_from_edges(bm, e_a_other[1], e_a_other[0], e_a_other[1], customdata_fac); + BM_data_interp_from_edges(bm, e_b_other[1], e_b_other[0], e_b_other[1], customdata_fac); + } + if (customdata_flag & CD_DO_LOOP) { + bm_edge_collapse_loop_customdata(bm, e_clear->l, v_clear, v_other, customdata_fac); + bm_edge_collapse_loop_customdata(bm, e_clear->l->radial_next, v_clear, v_other, customdata_fac); + } +#endif + + BM_edge_kill(bm, e_clear); + + BM_vert_splice(bm, v_clear, v_other); + + BM_edge_splice(bm, e_a_other[0], e_a_other[1]); + BM_edge_splice(bm, e_b_other[0], e_b_other[1]); + + // BM_mesh_validate(bm); + + return TRUE; + } + else if (BM_edge_is_boundary(e_clear)) { + /* same as above but only one triangle */ + BMLoop *l_a; + BMEdge *e_a_other[2]; + + l_a = e_clear->l; + + BLI_assert(l_a->f->len == 3); + + /* keep 'v_clear' 0th */ + if (BM_vert_in_edge(l_a->prev->e, v_clear)) { + e_a_other[0] = l_a->prev->e; + e_a_other[1] = l_a->next->e; + } + else { + e_a_other[1] = l_a->prev->e; + e_a_other[0] = l_a->next->e; + } + + r_e_clear_other[0] = BM_elem_index_get(e_a_other[0]); + r_e_clear_other[1] = -1; + +#ifdef USE_CUSTOMDATA + /* before killing, do customdata */ + if (customdata_flag & CD_DO_VERT) { + BM_data_interp_from_verts(bm, v_other, v_clear, v_other, customdata_fac); + } + if (customdata_flag & CD_DO_EDGE) { + BM_data_interp_from_edges(bm, e_a_other[1], e_a_other[0], e_a_other[1], customdata_fac); + } + if (customdata_flag & CD_DO_LOOP) { + bm_edge_collapse_loop_customdata(bm, e_clear->l, v_clear, v_other, customdata_fac); + } +#endif + + BM_edge_kill(bm, e_clear); + + BM_vert_splice(bm, v_clear, v_other); + + BM_edge_splice(bm, e_a_other[0], e_a_other[1]); + + // BM_mesh_validate(bm); + + return TRUE; + } + else { + return FALSE; + } +} + + +/* collapse e the edge, removing e->v2 */ +static void bm_decim_edge_collapse(BMesh *bm, BMEdge *e, + Quadric *vquadrics, float *vweights, + Heap *eheap, HeapNode **eheap_table, + const CD_UseFlag customdata_flag) +{ + int e_clear_other[2]; + BMVert *v_other = e->v1; + int v_clear_index = BM_elem_index_get(e->v2); /* the vert is removed so only store the index */ + float optimize_co[3]; + float customdata_fac; + + bm_decim_calc_target_co(e, optimize_co, vquadrics); + + /* use for customdata merging */ + if (LIKELY(compare_v3v3(e->v1->co, e->v2->co, FLT_EPSILON) == FALSE)) { + customdata_fac = line_point_factor_v3(optimize_co, e->v1->co, e->v2->co); + +#if 0 + /* simple test for stupid collapse */ + if (customdata_fac < 0.0 - FLT_EPSILON || customdata_fac > 1.0f + FLT_EPSILON) { + return; + } +#endif + } + else { + /* avoid divide by zero */ + customdata_fac = 0.5f; + } + + if (bm_edge_collapse(bm, e, e->v2, e_clear_other, customdata_flag, customdata_fac)) { + /* update collapse info */ + int i; + + if (vweights) { + const int fac = CLAMPIS(customdata_fac, 0.0f, 1.0f); + vweights[BM_elem_index_get(v_other)] = (vweights[v_clear_index] * (1.0f - fac)) + + (vweights[BM_elem_index_get(v_other)] * fac); + } + + e = NULL; /* paranoid safety check */ + + copy_v3_v3(v_other->co, optimize_co); + + /* remove eheap */ + for (i = 0; i < 2; i++) { + /* highly unlikely 'eheap_table[ke_other[i]]' would be NULL, but do for sanity sake */ + if ((e_clear_other[i] != -1) && (eheap_table[e_clear_other[i]] != NULL)) { + BLI_heap_remove(eheap, eheap_table[e_clear_other[i]]); + eheap_table[e_clear_other[i]] = NULL; + } + } + + /* update vertex quadric, add kept vertex from killed vertex */ + BLI_quadric_add_qu_qu(&vquadrics[BM_elem_index_get(v_other)], &vquadrics[v_clear_index]); + + /* update connected normals */ + + /* in fact face normals are not used for progressive updates, no need to update them */ + // BM_vert_normal_update_all(v); + BM_vert_normal_update(v_other); + + /* update error costs and the eheap */ + if (LIKELY(v_other->e)) { + BMEdge *e_iter; + BMEdge *e_first; + e_iter = e_first = v_other->e; + do { + BLI_assert(BM_edge_find_double(e_iter) == NULL); + bm_decim_build_edge_cost_single(e_iter, vquadrics, vweights, eheap, eheap_table); + } while ((e_iter = bmesh_disk_edge_next(e_iter, v_other)) != e_first); + } + +#if 0 + /* optional, update edges around the vertex face fan */ + { + BMIter liter; + BMLoop *l; + BM_ITER_ELEM (l, &liter, v_other, BM_LOOPS_OF_VERT) { + if (l->f->len == 3) { + BMEdge *e_outer; + if (BM_vert_in_edge(l->prev->e, l->v)) + e_outer = l->next->e; + else + e_outer = l->prev->e; + + BLI_assert(BM_vert_in_edge(e_outer, l->v) == FALSE); + + bm_decim_build_edge_cost_single(e_outer, vquadrics, eheap, eheap_table); + } + } + } + /* end optional update */ +#endif + } +} + + +/* Main Decimate Function + * ********************** */ + +/** + * \brief BM_mesh_decimate + * \param bm The mesh + * \param factor face count multiplier [0 - 1] + * \param vertex_weights Optional array of vertex aligned weights [0 - 1], + * a vertex group is the usual source for this. + */ +void BM_mesh_decimate_collapse(BMesh *bm, const float factor, float *vweights, const int do_triangulate) +{ + Heap *eheap; /* edge heap */ + HeapNode **eheap_table; /* edge index aligned table pointing to the eheap */ + Quadric *vquadrics; /* vert index aligned quadrics */ + int tot_edge_orig; + int face_tot_target; + int use_triangulate; + + CD_UseFlag customdata_flag = 0; + +#ifdef USE_TRIANGULATE + /* temp convert quads to triangles */ + use_triangulate = bm_decim_triangulate_begin(bm); +#endif + + + /* alloc vars */ + vquadrics = MEM_callocN(sizeof(Quadric) * bm->totvert, __func__); + /* since some edges may be degenerate, we might be over allocing a little here */ + eheap = BLI_heap_new_ex(bm->totedge); + eheap_table = MEM_callocN(sizeof(HeapNode *) * bm->totedge, __func__); + tot_edge_orig = bm->totedge; + + + /* build initial edge collapse cost data */ + bm_decim_build_quadrics(bm, vquadrics); + + bm_decim_build_edge_cost(bm, vquadrics, vweights, eheap, eheap_table); + + face_tot_target = bm->totface * factor; + bm->elem_index_dirty |= BM_FACE | BM_EDGE | BM_VERT; + + +#ifdef USE_CUSTOMDATA + /* initialize customdata flag, we only need math for loops */ + if (CustomData_has_interp(&bm->vdata)) customdata_flag |= CD_DO_VERT; + if (CustomData_has_interp(&bm->edata)) customdata_flag |= CD_DO_EDGE; + if (CustomData_has_math(&bm->ldata)) customdata_flag |= CD_DO_LOOP; +#endif + + /* iterative edge collapse and maintain the eheap */ + while ((bm->totface > face_tot_target) && (BLI_heap_is_empty(eheap) == FALSE)) { + // const float value = BLI_heap_node_value(BLI_heap_top(eheap)); + BMEdge *e = BLI_heap_popmin(eheap); + BLI_assert(BM_elem_index_get(e) < tot_edge_orig); /* handy to detect corruptions elsewhere */ + + // printf("COST %.10f\n", value); + + /* under normal conditions wont be accessed again, + * but NULL just incase so we don't use freed node */ + eheap_table[BM_elem_index_get(e)] = NULL; + + bm_decim_edge_collapse(bm, e, vquadrics, vweights, eheap, eheap_table, customdata_flag); + } + + +#ifdef USE_TRIANGULATE + if (do_triangulate == FALSE) { + /* its possible we only had triangles, skip this step in that case */ + if (LIKELY(use_triangulate)) { + /* temp convert quads to triangles */ + bm_decim_triangulate_end(bm); + } + } +#endif + + /* free vars */ + MEM_freeN(vquadrics); + MEM_freeN(eheap_table); + BLI_heap_free(eheap, NULL); + + /* testing only */ + // BM_mesh_validate(bm); + + (void)tot_edge_orig; /* quiet release build warning */ +} diff --git a/source/blender/bmesh/intern/bmesh_decimate_dissolve.c b/source/blender/bmesh/intern/bmesh_decimate_dissolve.c new file mode 100644 index 00000000000..91eac527047 --- /dev/null +++ b/source/blender/bmesh/intern/bmesh_decimate_dissolve.c @@ -0,0 +1,242 @@ +/* + * ***** 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. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/bmesh/intern/bmesh_decimate_dissolve.c + * \ingroup bmesh + * + * BMesh decimator that dissolves flat areas into polygons (ngons). + */ + + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "bmesh.h" +#include "bmesh_decimate.h" /* own include */ + +#define UNIT_TO_ANGLE DEG2RADF(90.0f) +#define ANGLE_TO_UNIT (1.0f / UNIT_TO_ANGLE) + +/* multiply vertex edge angle by face angle + * this means we are not left with sharp corners between _almost_ planer faces + * convert angles [0-PI/2] -> [0-1], multiply together, then convert back to radians. */ +static float bm_vert_edge_face_angle(BMVert *v) +{ + const float angle = BM_vert_calc_edge_angle(v); + /* note: could be either edge, it doesn't matter */ + if (v->e && BM_edge_is_manifold(v->e)) { + return ((angle * ANGLE_TO_UNIT) * (BM_edge_calc_face_angle(v->e) * ANGLE_TO_UNIT)) * UNIT_TO_ANGLE; + } + else { + return angle; + } +} + +#undef UNIT_TO_ANGLE +#undef ANGLE_TO_UNIT + +typedef struct DissolveElemWeight { + BMHeader *ele; + float weight; +} DissolveElemWeight; + +static int dissolve_elem_cmp(const void *a1, const void *a2) +{ + const struct DissolveElemWeight *d1 = a1, *d2 = a2; + + if (d1->weight > d2->weight) return 1; + else if (d1->weight < d2->weight) return -1; + return 0; +} + +/** + * \param do_all_verts Collapse all verts between 2 faces - don't check their edge angle. + */ +void BM_mesh_decimate_dissolve_ex(BMesh *bm, const float angle_limit, const int do_dissolve_boundaries, + BMVert **vinput_arr, const int vinput_len, + BMEdge **einput_arr, const int einput_len) +{ + const float angle_max = (float)M_PI / 2.0f; + DissolveElemWeight *weight_elems = MEM_mallocN(max_ii(einput_len, vinput_len) * + sizeof(DissolveElemWeight), __func__); + int i, tot_found; + + BMIter iter; + BMEdge *e_iter; + BMEdge **earray; + + int *vert_reverse_lookup; + + /* --- first edges --- */ + + /* wire -> tag */ + BM_ITER_MESH (e_iter, &iter, bm, BM_EDGES_OF_MESH) { + BM_elem_flag_set(e_iter, BM_ELEM_TAG, BM_edge_is_wire(e_iter)); + } + + /* go through and split edge */ + for (i = 0, tot_found = 0; i < einput_len; i++) { + BMEdge *e = einput_arr[i]; + const float angle = BM_edge_calc_face_angle(e); + + if (angle < angle_limit) { + tot_found++; + } + weight_elems[i].ele = (BMHeader *)e; + weight_elems[i].weight = angle; + } + + if (tot_found != 0) { + qsort(weight_elems, einput_len, sizeof(DissolveElemWeight), dissolve_elem_cmp); + + for (i = 0; i < tot_found; i++) { + BMEdge *e = (BMEdge *)weight_elems[i].ele; + + if (/* may have become non-manifold */ + BM_edge_is_manifold(e) && + /* check twice because cumulative effect could dissolve over angle limit */ + (BM_edge_calc_face_angle(e) < angle_limit)) + { + BMFace *nf = BM_faces_join_pair(bm, e->l->f, + e->l->radial_next->f, + e, + FALSE); /* join faces */ + + /* there may be some errors, we don't mind, just move on */ + if (nf) { + BM_face_normal_update(nf); + } + else { + BMO_error_clear(bm); + } + } + } + } + + /* prepare for cleanup */ + BM_mesh_elem_index_ensure(bm, BM_VERT); + vert_reverse_lookup = MEM_mallocN(sizeof(int) * bm->totvert, __func__); + fill_vn_i(vert_reverse_lookup, bm->totvert, -1); + for (i = 0, tot_found = 0; i < vinput_len; i++) { + BMVert *v = vinput_arr[i]; + vert_reverse_lookup[BM_elem_index_get(v)] = i; + } + + /* --- cleanup --- */ + earray = MEM_mallocN(sizeof(BMEdge *) * bm->totedge, __func__); + BM_ITER_MESH_INDEX (e_iter, &iter, bm, BM_EDGES_OF_MESH, i) { + earray[i] = e_iter; + } + /* remove all edges/verts left behind from dissolving, NULL'ing the vertex array so we dont re-use */ + for (i = bm->totedge - 1; i != -1; i--) { + e_iter = earray[i]; + + if (BM_edge_is_wire(e_iter) && (BM_elem_flag_test(e_iter, BM_ELEM_TAG) == FALSE)) { + /* edge has become wire */ + int vidx_reverse; + BMVert *v1 = e_iter->v1; + BMVert *v2 = e_iter->v2; + BM_edge_kill(bm, e_iter); + if (v1->e == NULL) { + vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v1)]; + if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL; + BM_vert_kill(bm, v1); + } + if (v2->e == NULL) { + vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v2)]; + if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL; + BM_vert_kill(bm, v2); + } + } + } + MEM_freeN(vert_reverse_lookup); + + MEM_freeN(earray); + + + /* --- second verts --- */ + if (do_dissolve_boundaries) { + /* simple version of the branch below, sincve we will dissolve _all_ verts that use 2 edges */ + for (i = 0; i < vinput_len; i++) { + BMVert *v = vinput_arr[i]; + if (v) { + if (BM_vert_edge_count(v) == 2) { + BM_vert_collapse_edge(bm, v->e, v, TRUE); /* join edges */ + } + } + } + } + else { + for (i = 0, tot_found = 0; i < vinput_len; i++) { + BMVert *v = vinput_arr[i]; + const float angle = v ? bm_vert_edge_face_angle(v) : angle_limit; + + if (angle < angle_limit) { + weight_elems[i].ele = (BMHeader *)v; + weight_elems[i].weight = angle; + tot_found++; + } + else { + weight_elems[i].ele = NULL; + weight_elems[i].weight = angle_max; + } + } + + if (tot_found != 0) { + qsort(weight_elems, vinput_len, sizeof(DissolveElemWeight), dissolve_elem_cmp); + + for (i = 0; i < tot_found; i++) { + BMVert *v = (BMVert *)weight_elems[i].ele; + if (/* topology changes may cause this to be un-collapsable */ + (BM_vert_edge_count(v) == 2) && + /* check twice because cumulative effect could dissolve over angle limit */ + bm_vert_edge_face_angle(v) < angle_limit) + { + BMEdge *ne = BM_vert_collapse_edge(bm, v->e, v, TRUE); /* join edges */ + + if (ne && ne->l) { + BM_edge_normals_update(ne); + } + } + } + } + } + + MEM_freeN(weight_elems); +} + +void BM_mesh_decimate_dissolve(BMesh *bm, const float angle_limit, const int do_dissolve_boundaries) +{ + int vinput_len; + int einput_len; + + BMVert **vinput_arr = BM_iter_as_arrayN(bm, BM_VERTS_OF_MESH, NULL, &vinput_len); + BMEdge **einput_arr = BM_iter_as_arrayN(bm, BM_EDGES_OF_MESH, NULL, &einput_len); + + BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries, + vinput_arr, vinput_len, + einput_arr, einput_len); + + MEM_freeN(vinput_arr); + MEM_freeN(einput_arr); +} diff --git a/source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c b/source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c new file mode 100644 index 00000000000..68c0652d2c4 --- /dev/null +++ b/source/blender/bmesh/intern/bmesh_decimate_unsubdivide.c @@ -0,0 +1,344 @@ +/* + * ***** 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. + * + * Contributor(s): Campbell Barton + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/bmesh/intern/bmesh_decimate_unsubdivide.c + * \ingroup bmesh + * + * BMesh decimator that uses a grid un-subdivide method. + */ + + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" + +#include "bmesh.h" + +#include "intern/bmesh_operators_private.h" /* own include */ + + +static int bm_vert_dissolve_fan_test(BMVert *v) +{ + /* check if we should walk over these verts */ + BMIter iter; + BMEdge *e; + + unsigned int tot_edge = 0; + unsigned int tot_edge_boundary = 0; + unsigned int tot_edge_manifold = 0; + unsigned int tot_edge_wire = 0; + + BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { + if (BM_edge_is_boundary(e)) { + tot_edge_boundary++; + } + else if (BM_edge_is_manifold(e)) { + tot_edge_manifold++; + } + else if (BM_edge_is_wire(e)) { + tot_edge_wire++; + } + tot_edge++; + } + + if ((tot_edge == 4) && (tot_edge_boundary == 0) && (tot_edge_manifold == 4)) { + return TRUE; + } + else if ((tot_edge == 3) && (tot_edge_boundary == 0) && (tot_edge_manifold == 3)) { + return TRUE; + } + else if ((tot_edge == 3) && (tot_edge_boundary == 2) && (tot_edge_manifold == 1)) { + return TRUE; + } + else if ((tot_edge == 2) && (tot_edge_wire == 2)) { + return TRUE; + } + return FALSE; +} + +static int bm_vert_dissolve_fan(BMesh *bm, BMVert *v) +{ + /* collapse under 2 conditions. + * - vert connects to 4 manifold edges (and 4 faces). + * - vert connecrs to 1 manifold edge, 2 boundary edges (and 2 faces). + * + * This covers boundary verts of a quad grid and center verts. + * note that surrounding faces dont have to be quads. + */ + + BMIter iter; + BMEdge *e; + + unsigned int tot_loop = 0; + unsigned int tot_edge = 0; + unsigned int tot_edge_boundary = 0; + unsigned int tot_edge_manifold = 0; + unsigned int tot_edge_wire = 0; + + BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { + if (BM_edge_is_boundary(e)) { + tot_edge_boundary++; + } + else if (BM_edge_is_manifold(e)) { + tot_edge_manifold++; + } + else if (BM_edge_is_wire(e)) { + tot_edge_wire++; + } + tot_edge++; + } + + if (tot_edge == 2) { + /* check for 2 wire verts only */ + if (tot_edge_wire == 2) { + return (BM_vert_collapse_edge(bm, v->e, v, TRUE) != NULL); + } + } + else if (tot_edge == 4) { + /* check for 4 faces surrounding */ + if (tot_edge_boundary == 0 && tot_edge_manifold == 4) { + /* good to go! */ + tot_loop = 4; + } + } + else if (tot_edge == 3) { + /* check for 2 faces surrounding at a boundary */ + if (tot_edge_boundary == 2 && tot_edge_manifold == 1) { + /* good to go! */ + tot_loop = 2; + } + else if (tot_edge_boundary == 0 && tot_edge_manifold == 3) { + /* good to go! */ + tot_loop = 3; + } + } + + if (tot_loop) { + BMLoop *f_loop[4]; + unsigned int i; + + /* ensure there are exactly tot_loop loops */ + BLI_assert(BM_iter_at_index(bm, BM_LOOPS_OF_VERT, v, tot_loop) == NULL); + BM_iter_as_array(bm, BM_LOOPS_OF_VERT, v, (void **)f_loop, tot_loop); + + for (i = 0; i < tot_loop; i++) { + BMLoop *l = f_loop[i]; + if (l->f->len > 3) { + BMLoop *l_new; + BLI_assert(l->prev->v != l->next->v); + BM_face_split(bm, l->f, l->prev->v, l->next->v, &l_new, NULL, TRUE); + BM_elem_flag_merge_into(l_new->e, l->e, l->prev->e); + } + } + + return BM_vert_dissolve(bm, v); + } + + return FALSE; +} + +enum { + VERT_INDEX_DO_COLLAPSE = -1, + VERT_INDEX_INIT = 0, + VERT_INDEX_IGNORE = 1 +}; + +// #define USE_WALKER /* gives uneven results, disable for now */ + +/* - BMVert.flag & BM_ELEM_TAG: shows we touched this vert + * - BMVert.index == -1: shows we will remove this vert + */ + +/** + * \param tag_only so we can call this from an operator */ +void BM_mesh_decimate_unsubdivide_ex(BMesh *bm, const int iterations, const int tag_only) +{ +#ifdef USE_WALKER +# define ELE_VERT_TAG 1 +#else + BMVert **vert_seek_a = MEM_mallocN(sizeof(BMVert *) * bm->totvert, __func__); + BMVert **vert_seek_b = MEM_mallocN(sizeof(BMVert *) * bm->totvert, __func__); + unsigned vert_seek_a_tot = 0; + unsigned vert_seek_b_tot = 0; +#endif + + BMVert *v; + BMIter iter; + + const unsigned int offset = 0; + const unsigned int nth = 2; + + int iter_step; + + /* if tag_only is set, we assyme the caller knows what verts to tag + * needed for the operator */ + if (tag_only == FALSE) { + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + BM_elem_flag_enable(v, BM_ELEM_TAG); + } + } + + for (iter_step = 0; iter_step < iterations; iter_step++) { + int iter_done; + + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + if (BM_elem_flag_test(v, BM_ELEM_TAG) && bm_vert_dissolve_fan_test(v)) { +#ifdef USE_WALKER + BMO_elem_flag_enable(bm, v, ELE_VERT_TAG); +#endif + BM_elem_index_set(v, VERT_INDEX_INIT); /* set_dirty! */ + } + else { + BM_elem_index_set(v, VERT_INDEX_IGNORE); /* set_dirty! */ + } + } + /* done with selecting tagged verts */ + + + /* main loop, keep tagging until we can't tag any more islands */ + while (TRUE) { +#ifdef USE_WALKER + BMWalker walker; +#else + unsigned int depth = 1; + unsigned int i; +#endif + BMVert *v_first = NULL; + BMVert *v; + + /* we could avoid iterating from the start each time */ + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + if (v->e && (BM_elem_index_get(v) == VERT_INDEX_INIT)) { +#ifdef USE_WALKER + if (BMO_elem_flag_test(bm, v, ELE_VERT_TAG)) +#endif + { + /* check again incase the topology changed */ + if (bm_vert_dissolve_fan_test(v)) { + v_first = v; + } + break; + } + } + } + if (v_first == NULL) { + break; + } + +#ifdef USE_WALKER + /* Walk over selected elements starting at active */ + BMW_init(&walker, bm, BMW_CONNECTED_VERTEX, + ELE_VERT_TAG, BMW_MASK_NOP, BMW_MASK_NOP, + BMW_FLAG_NOP, /* don't use BMW_FLAG_TEST_HIDDEN here since we want to desel all */ + BMW_NIL_LAY); + + BLI_assert(walker.order == BMW_BREADTH_FIRST); + for (v = BMW_begin(&walker, v_first); v != NULL; v = BMW_step(&walker)) { + /* Deselect elements that aren't at "nth" depth from active */ + if (BM_elem_index_get(v) == VERT_INDEX_INIT) { + if ((offset + BMW_current_depth(&walker)) % nth) { + /* tag for removal */ + BM_elem_index_set(v, VERT_INDEX_DO_COLLAPSE); /* set_dirty! */ + } + else { + /* works better to allow these verts to be checked again */ + //BM_elem_index_set(v, VERT_INDEX_IGNORE); /* set_dirty! */ + } + } + } + BMW_end(&walker); +#else + + BM_elem_index_set(v_first, (offset + depth) % nth ? VERT_INDEX_IGNORE : VERT_INDEX_DO_COLLAPSE); /* set_dirty! */ + + vert_seek_b_tot = 0; + vert_seek_b[vert_seek_b_tot++] = v_first; + + while (TRUE) { + BMEdge *e; + + if ((offset + depth) % nth) { + vert_seek_a_tot = 0; + for (i = 0; i < vert_seek_b_tot; i++) { + v = vert_seek_b[i]; + BLI_assert(BM_elem_index_get(v) == VERT_INDEX_IGNORE); + BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { + BMVert *v_other = BM_edge_other_vert(e, v); + if (BM_elem_index_get(v_other) == VERT_INDEX_INIT) { + BM_elem_index_set(v_other, VERT_INDEX_DO_COLLAPSE); /* set_dirty! */ + vert_seek_a[vert_seek_a_tot++] = v_other; + } + } + } + if (vert_seek_a_tot == 0) { + break; + } + } + else { + vert_seek_b_tot = 0; + for (i = 0; i < vert_seek_a_tot; i++) { + v = vert_seek_a[i]; + BLI_assert(BM_elem_index_get(v) == VERT_INDEX_DO_COLLAPSE); + BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { + BMVert *v_other = BM_edge_other_vert(e, v); + if (BM_elem_index_get(v_other) == VERT_INDEX_INIT) { + BM_elem_index_set(v_other, VERT_INDEX_IGNORE); /* set_dirty! */ + vert_seek_b[vert_seek_b_tot++] = v_other; + } + } + } + if (vert_seek_b_tot == 0) { + break; + } + } + + depth++; + } +#endif /* USE_WALKER */ + + } + + /* now we tagged all verts -1 for removal, lets loop over and rebuild faces */ + iter_done = FALSE; + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { + if (BM_elem_index_get(v) == VERT_INDEX_DO_COLLAPSE) { + iter_done |= bm_vert_dissolve_fan(bm, v); + } + } + + if (iter_done == FALSE) { + break; + } + } + + bm->elem_index_dirty |= BM_VERT; + +#ifndef USE_WALKER + MEM_freeN(vert_seek_a); + MEM_freeN(vert_seek_b); +#endif +} + +void BM_mesh_decimate_unsubdivide(BMesh *bm, const int iterations) +{ + BM_mesh_decimate_unsubdivide_ex(bm, iterations, FALSE); +} diff --git a/source/blender/bmesh/intern/bmesh_inline.h b/source/blender/bmesh/intern/bmesh_inline.h index 400f4a55b0e..04b214f725a 100644 --- a/source/blender/bmesh/intern/bmesh_inline.h +++ b/source/blender/bmesh/intern/bmesh_inline.h @@ -37,6 +37,7 @@ #define BM_elem_flag_set( ele, hflag, val) _bm_elem_flag_set (&(ele)->head, hflag, val) #define BM_elem_flag_toggle( ele, hflag) _bm_elem_flag_toggle (&(ele)->head, hflag) #define BM_elem_flag_merge( ele_a, ele_b) _bm_elem_flag_merge (&(ele_a)->head, &(ele_b)->head) +#define BM_elem_flag_merge_into(ele, ele_a, ele_b)_bm_elem_flag_merge_into (&(ele)->head, &(ele_a)->head, &(ele_b)->head) BLI_INLINE char _bm_elem_flag_test(const BMHeader *head, const char hflag) { @@ -74,6 +75,11 @@ BLI_INLINE void _bm_elem_flag_merge(BMHeader *head_a, BMHeader *head_b) head_a->hflag = head_b->hflag = head_a->hflag | head_b->hflag; } +BLI_INLINE void _bm_elem_flag_merge_into(BMHeader *head, const BMHeader *head_a, const BMHeader *head_b) +{ + head->hflag = head_a->hflag | head_b->hflag; +} + /** * notes on #BM_elem_index_set(...) usage, * Set index is sometimes abused as temp storage, other times we cant be diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 12fcd51c069..ffe79923730 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -257,7 +257,7 @@ static float quad_coord(float aa[3], float bb[3], float cc[3], float dd[3], int f1 = fabsf(f1); f2 = fabsf(f2); - f1 = minf(f1, f2); + f1 = min_ff(f1, f2); CLAMP(f1, 0.0f, 1.0f + FLT_EPSILON); } else { @@ -345,9 +345,9 @@ static int mdisp_in_mdispquad(BMLoop *l, BMLoop *tl, float p[3], float *x, float float v1[3], v2[3], c[3], v3[3], v4[3], e1[3], e2[3]; float eps = FLT_EPSILON * 4000; - if (len_v3(l->v->no) == 0.0f) + if (is_zero_v3(l->v->no)) BM_vert_normal_update_all(l->v); - if (len_v3(tl->v->no) == 0.0f) + if (is_zero_v3(tl->v->no)) BM_vert_normal_update_all(tl->v); compute_mdisp_quad(tl, v1, v2, v3, v4, e1, e2); @@ -490,7 +490,7 @@ static void bm_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source) } /** - * smoothes boundaries between multires grids, + * smooths boundaries between multires grids, * including some borders in adjacent faces */ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f) diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index 360e2c93de3..32879caec71 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -295,7 +295,7 @@ static void UNUSED_FUNCTION(bm_mdisps_space_set)(Object *ob, BMesh *bm, int from /* switch multires data out of tangent space */ if (CustomData_has_layer(&bm->ldata, CD_MDISPS)) { BMEditMesh *em = BMEdit_Create(bm, FALSE); - DerivedMesh *dm = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE); + DerivedMesh *dm = CDDM_from_editbmesh(em, TRUE, FALSE); MDisps *mdisps; BMFace *f; BMIter iter; diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 91ca7124fc2..62374d8b7bb 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -437,7 +437,7 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, float cos[ /* bmesh_semv returns in newe the edge going from newv to tv */ copy_v3_v3(newv->co, cos[i]); - /* interpolate the loop data for the loops with v==newv, using orig face */ + /* interpolate the loop data for the loops with (v == newv), using orig face */ for (j = 0; j < 2; j++) { BMEdge *e_iter = (j == 0) ? e : newe; BMLoop *l_iter = e_iter->l; @@ -470,9 +470,6 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, float cos[ * both collapse a vertex and return a new edge. * Except this takes a factor and merges custom data. * - * BMESH_TODO: - * Insert error checking for KV valance. - * * \param bm The bmesh * \param ke The edge to collapse * \param kv The vertex to collapse into the edge diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 407e7caae0f..e12e28f8cff 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -114,6 +114,26 @@ static BMOpDefine bmo_smooth_vert_def = { }; /* + * Vertext Smooth Laplacian + * Smooths vertices by using Laplacian smoothing propose by. + * Desbrun, et al. Implicit Fairing of Irregular Meshes using Diffusion and Curvature Flow +*/ +static BMOpDefine bmo_smooth_laplacian_vert_def = { + "smooth_laplacian_vert", + {{BMO_OP_SLOT_ELEMENT_BUF, "verts"}, //input vertices + {BMO_OP_SLOT_FLT, "lambda"}, //lambda param + {BMO_OP_SLOT_FLT, "lambda_border"}, //lambda param in border + {BMO_OP_SLOT_BOOL, "use_x"}, //Smooth object along X axis + {BMO_OP_SLOT_BOOL, "use_y"}, //Smooth object along Y axis + {BMO_OP_SLOT_BOOL, "use_z"}, //Smooth object along Z axis + {BMO_OP_SLOT_BOOL, "volume_preservation"}, //Apply volume preservation after smooth + {0} /* null-terminating sentinel */, + }, + bmo_smooth_laplacian_vert_exec, + 0 +}; + +/* * Right-Hand Faces * * Computes an "outside" normal for the specified input faces. @@ -679,6 +699,7 @@ static BMOpDefine bmo_dissolve_faces_def = { static BMOpDefine bmo_dissolve_limit_def = { "dissolve_limit", {{BMO_OP_SLOT_FLT, "angle_limit"}, /* total rotation angle (degrees) */ + {BMO_OP_SLOT_BOOL, "use_dissolve_boundaries"}, {BMO_OP_SLOT_ELEMENT_BUF, "verts"}, {BMO_OP_SLOT_ELEMENT_BUF, "edges"}, {0} /* null-terminating sentinel */}, @@ -1161,6 +1182,7 @@ static BMOpDefine bmo_slide_vert_def = { BMO_OP_FLAG_UNTAN_MULTIRES }; +#ifdef WITH_BULLET /* * Convex Hull * @@ -1190,6 +1212,7 @@ static BMOpDefine bmo_convex_hull_def = { bmo_convex_hull_exec, 0 }; +#endif /* * Symmetrize @@ -1226,7 +1249,9 @@ BMOpDefine *opdefines[] = { &bmo_collapse_uvs_def, &bmo_connect_verts_def, &bmo_contextual_create_def, +#ifdef WITH_BULLET &bmo_convex_hull_def, +#endif &bmo_create_circle_def, &bmo_create_cone_def, &bmo_create_cube_def, @@ -1273,6 +1298,7 @@ BMOpDefine *opdefines[] = { &bmo_similar_verts_def, &bmo_slide_vert_def, &bmo_smooth_vert_def, + &bmo_smooth_laplacian_vert_def, &bmo_solidify_def, &bmo_spin_def, &bmo_split_def, diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 2100cd2bd0b..015052e685d 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -36,6 +36,8 @@ #include "BLI_listbase.h" #include "BLI_array.h" +#include "BLF_translation.h" + #include "bmesh.h" #include "intern/bmesh_private.h" @@ -49,16 +51,16 @@ static int bmo_opname_to_opcode(const char *opname); static const char *bmo_error_messages[] = { NULL, - "Self intersection error", - "Could not dissolve vert", - "Could not connect vertices", - "Could not traverse mesh", - "Could not dissolve faces", - "Could not dissolve vertices", - "Tessellation error", - "Can not deal with non-manifold geometry", - "Invalid selection", - "Internal mesh error", + N_("Self intersection error"), + N_("Could not dissolve vert"), + N_("Could not connect vertices"), + N_("Could not traverse mesh"), + N_("Could not dissolve faces"), + N_("Could not dissolve vertices"), + N_("Tessellation error"), + N_("Cannot deal with non-manifold geometry"), + N_("Invalid selection"), + N_("Internal mesh error"), }; @@ -1241,7 +1243,9 @@ void BMO_error_raise(BMesh *bm, BMOperator *owner, int errcode, const char *msg) BMOpError *err = MEM_callocN(sizeof(BMOpError), "bmop_error"); err->errorcode = errcode; - if (!msg) msg = bmo_error_messages[errcode]; + if (!msg) { + msg = bmo_error_messages[errcode]; + } err->msg = msg; err->op = owner; diff --git a/source/blender/bmesh/intern/bmesh_operators_private.h b/source/blender/bmesh/intern/bmesh_operators_private.h index d6135efe19a..65c9cf0c421 100644 --- a/source/blender/bmesh/intern/bmesh_operators_private.h +++ b/source/blender/bmesh/intern/bmesh_operators_private.h @@ -91,6 +91,7 @@ void bmo_similar_faces_exec(BMesh *bm, BMOperator *op); void bmo_similar_verts_exec(BMesh *bm, BMOperator *op); void bmo_slide_vert_exec(BMesh *bm, BMOperator *op); void bmo_smooth_vert_exec(BMesh *bm, BMOperator *op); +void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op); void bmo_solidify_face_region_exec(BMesh *bm, BMOperator *op); void bmo_spin_exec(BMesh *bm, BMOperator *op); void bmo_split_edges_exec(BMesh *bm, BMOperator *op); diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index eb2b7721bdc..bd0f93ee7aa 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -507,8 +507,8 @@ static int line_crosses_v2f(const float v1[2], const float v2[2], const float v3 #define GETMIN2_AXIS(a, b, ma, mb, axis) \ { \ - ma[axis] = minf(a[axis], b[axis]); \ - mb[axis] = maxf(a[axis], b[axis]); \ + ma[axis] = min_ff(a[axis], b[axis]); \ + mb[axis] = max_ff(a[axis], b[axis]); \ } (void)0 #define GETMIN2(a, b, ma, mb) \ @@ -994,8 +994,8 @@ void BM_face_legal_splits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len) for (i = 0, l = BM_FACE_FIRST_LOOP(f); i < f->len; i++, l = l->next) { p1 = projverts[i]; - out[0] = maxf(out[0], p1[0]); - out[1] = maxf(out[1], p1[1]); + out[0] = max_ff(out[0], p1[0]); + out[1] = max_ff(out[1], p1[1]); /* out[2] = 0.0f; */ /* keep at zero */ p1[2] = 0.0f; diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 9520b0298d8..fbbb9c2a825 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -343,10 +343,13 @@ BMLoop *BM_edge_other_loop(BMEdge *e, BMLoop *l) { BMLoop *l_other; - BLI_assert(BM_edge_is_manifold(e)); + // BLI_assert(BM_edge_is_manifold(e)); // TOO strict, just check if we have another radial face + BLI_assert(e->l && e->l->radial_next != l); BLI_assert(BM_vert_in_edge(e, l->v)); - l_other = (e->l == l) ? l->radial_next : l; + l_other = (l->e == e) ? l : l->prev; + l_other = l_other->radial_next; + BLI_assert(l_other->e == e); if (l_other->v == l->v) { /* pass */ @@ -362,6 +365,55 @@ BMLoop *BM_edge_other_loop(BMEdge *e, BMLoop *l) } /** + * Utility function to step around a fan of loops, + * using an edge to mark the previous side. + * + * \note all edges must be manifold, + * once a non manifold edge is hit, return NULL. + * + * <pre> + * ,.,-->| + * _,-' | + * ,' | (notice how 'e_step' + * / | and 'l' define the + * / | direction the arrow + * | return | points). + * | loop --> | + * ---------------------+--------------------- + * ^ l --> | + * | | + * assign e_step | + * | + * begin e_step ----> | + * | + * </pre> + */ + +BMLoop *BM_vert_step_fan_loop(BMLoop *l, BMEdge **e_step) +{ + BMEdge *e_prev = *e_step; + BMEdge *e_next; + if (l->e == e_prev) { + e_next = l->prev->e; + } + else if (l->prev->e == e_prev) { + e_next = l->e; + } + else { + BLI_assert(0); + } + + if (BM_edge_is_manifold(e_next)) { + return BM_edge_other_loop((*e_step = e_next), l); + } + else { + return NULL; + } +} + + + +/** * The function takes a vertex at the center of a fan and returns the opposite edge in the fan. * All edges in the fan must be manifold, otherwise return NULL. * diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index 166b8a54f8a..34d0747676c 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -44,6 +44,7 @@ BMLoop *BM_edge_other_loop(BMEdge *e, BMLoop *l); BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v); BMLoop *BM_face_other_vert_loop(BMFace *f, BMVert *v_prev, BMVert *v); BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v); +BMLoop *BM_vert_step_fan_loop(BMLoop *l, BMEdge **e_step); BMLoop *BM_vert_find_first_loop(BMVert *v); int BM_vert_edge_count_nonwire(BMVert *v); diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index 225ea6c2ef6..bb1e599f097 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -303,8 +303,7 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker) if (!BM_vert_is_manifold(v)) { BMW_reset(walker); BMO_error_raise(walker->bm, NULL, BMERR_WALKER_FAILED, - "Non-manifold vert " - "while searching region boundary"); + "Non-manifold vert while searching region boundary"); return NULL; } diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index e31df2e4444..c5120571755 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -126,7 +126,7 @@ static void calc_corner_co(BMLoop *l, const float fac, float r_co[3], * gives nicer, move even output. * * Use the minimum rather then the middle value so skinny faces don't flip along the short axis */ - float min_fac = minf(normalize_v3(l_vec_prev), normalize_v3(l_vec_next)); + float min_fac = min_ff(normalize_v3(l_vec_prev), normalize_v3(l_vec_next)); float angle; if (do_even) { diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c index fde475c2d6a..ebd848ff8b2 100644 --- a/source/blender/bmesh/operators/bmo_connect.c +++ b/source/blender/bmesh/operators/bmo_connect.c @@ -425,8 +425,8 @@ void bmo_bridge_loops_exec(BMesh *bm, BMOperator *op) /* merge loops of bridge faces */ if (use_merge) { - const int vert_len = mini(BLI_array_count(vv1), BLI_array_count(vv2)) - ((cl1 || cl2) ? 1 : 0); - const int edge_len = mini(BLI_array_count(ee1), BLI_array_count(ee2)); + const int vert_len = min_ii(BLI_array_count(vv1), BLI_array_count(vv2)) - ((cl1 || cl2) ? 1 : 0); + const int edge_len = min_ii(BLI_array_count(ee1), BLI_array_count(ee2)); if (merge_factor <= 0.0f) { /* 2 --> 1 */ diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c index 731170f963c..bd1c0f809bd 100644 --- a/source/blender/bmesh/operators/bmo_create.c +++ b/source/blender/bmesh/operators/bmo_create.c @@ -84,7 +84,7 @@ static int count_edge_faces(BMesh *bm, BMEdge *e); BLI_INLINE BMDiskLink *rs_edge_link_get(BMEdge *e, BMVert *v, EdgeData *e_data) { return v == ((BMEdge *)e)->v1 ? &(((EdgeData *)e_data)->v1_disk_link) : - &(((EdgeData *)e_data)->v2_disk_link) ; + &(((EdgeData *)e_data)->v2_disk_link); } static int rotsys_append_edge(BMEdge *e, BMVert *v, diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 84f6cb27b3b..9addb1b1657 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -477,182 +477,15 @@ void dummy_exec(BMesh *bm, BMOperator *op) #endif /* Limited Dissolve */ - -#define UNIT_TO_ANGLE DEG2RADF(90.0f) -#define ANGLE_TO_UNIT (1.0f / UNIT_TO_ANGLE) - -/* multiply vertex edge angle by face angle - * this means we are not left with sharp corners between _almost_ planer faces - * convert angles [0-PI/2] -> [0-1], multiply together, then convert back to radians. */ -static float bm_vert_edge_face_angle(BMVert *v) -{ - const float angle = BM_vert_calc_edge_angle(v); - /* note: could be either edge, it doesn't matter */ - if (v->e && BM_edge_is_manifold(v->e)) { - return ((angle * ANGLE_TO_UNIT) * (BM_edge_calc_face_angle(v->e) * ANGLE_TO_UNIT)) * UNIT_TO_ANGLE; - } - else { - return angle; - } -} - -#undef UNIT_TO_ANGLE -#undef ANGLE_TO_UNIT - -typedef struct DissolveElemWeight { - BMHeader *ele; - float weight; -} DissolveElemWeight; - -static int dissolve_elem_cmp(const void *a1, const void *a2) -{ - const struct DissolveElemWeight *d1 = a1, *d2 = a2; - - if (d1->weight > d2->weight) return 1; - else if (d1->weight < d2->weight) return -1; - return 0; -} - void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op) { BMOpSlot *einput = BMO_slot_get(op, "edges"); BMOpSlot *vinput = BMO_slot_get(op, "verts"); const float angle_max = (float)M_PI / 2.0f; - const float angle_limit = minf(angle_max, BMO_slot_float_get(op, "angle_limit")); - DissolveElemWeight *weight_elems = MEM_mallocN(MAX2(einput->len, vinput->len) * - sizeof(DissolveElemWeight), __func__); - int i, tot_found; - - BMIter iter; - BMEdge *e_iter; - BMEdge **earray; - - int *vert_reverse_lookup; - - BMEdge **einput_arr = (BMEdge **)einput->data.p; - BMVert **vinput_arr = (BMVert **)vinput->data.p; - - /* --- first edges --- */ - - /* wire -> tag */ - BM_ITER_MESH (e_iter, &iter, bm, BM_EDGES_OF_MESH) { - BM_elem_flag_set(e_iter, BM_ELEM_TAG, BM_edge_is_wire(e_iter)); - } - - /* go through and split edge */ - for (i = 0, tot_found = 0; i < einput->len; i++) { - BMEdge *e = einput_arr[i]; - const float angle = BM_edge_calc_face_angle(e); - - if (angle < angle_limit) { - tot_found++; - } - weight_elems[i].ele = (BMHeader *)e; - weight_elems[i].weight = angle; - } - - if (tot_found != 0) { - qsort(weight_elems, einput->len, sizeof(DissolveElemWeight), dissolve_elem_cmp); - - for (i = 0; i < tot_found; i++) { - BMEdge *e = (BMEdge *)weight_elems[i].ele; - - if (/* may have become non-manifold */ - BM_edge_is_manifold(e) && - /* check twice because cumulative effect could dissolve over angle limit */ - (BM_edge_calc_face_angle(e) < angle_limit)) - { - BMFace *nf = BM_faces_join_pair(bm, e->l->f, - e->l->radial_next->f, - e, - FALSE); /* join faces */ - - /* there may be some errors, we don't mind, just move on */ - if (nf) { - BM_face_normal_update(nf); - } - else { - BMO_error_clear(bm); - } - } - } - } - - /* prepare for cleanup */ - BM_mesh_elem_index_ensure(bm, BM_VERT); - vert_reverse_lookup = MEM_mallocN(sizeof(int) * bm->totvert, __func__); - fill_vn_i(vert_reverse_lookup, bm->totvert, -1); - for (i = 0, tot_found = 0; i < vinput->len; i++) { - BMVert *v = vinput_arr[i]; - vert_reverse_lookup[BM_elem_index_get(v)] = i; - } - - /* --- cleanup --- */ - earray = MEM_mallocN(sizeof(BMEdge *) * bm->totedge, __func__); - BM_ITER_MESH_INDEX (e_iter, &iter, bm, BM_EDGES_OF_MESH, i) { - earray[i] = e_iter; - } - /* remove all edges/verts left behind from dissolving, NULL'ing the vertex array so we dont re-use */ - for (i = bm->totedge - 1; i != -1; i--) { - e_iter = earray[i]; - - if (BM_edge_is_wire(e_iter) && (BM_elem_flag_test(e_iter, BM_ELEM_TAG) == FALSE)) { - /* edge has become wire */ - int vidx_reverse; - BMVert *v1 = e_iter->v1; - BMVert *v2 = e_iter->v2; - BM_edge_kill(bm, e_iter); - if (v1->e == NULL) { - vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v1)]; - if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL; - BM_vert_kill(bm, v1); - } - if (v2->e == NULL) { - vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v2)]; - if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL; - BM_vert_kill(bm, v2); - } - } - } - MEM_freeN(vert_reverse_lookup); - - MEM_freeN(earray); - - - /* --- second verts --- */ - for (i = 0, tot_found = 0; i < vinput->len; i++) { - BMVert *v = vinput_arr[i]; - const float angle = v ? bm_vert_edge_face_angle(v) : angle_limit; - - if (angle < angle_limit) { - weight_elems[i].ele = (BMHeader *)v; - weight_elems[i].weight = angle; - tot_found++; - } - else { - weight_elems[i].ele = NULL; - weight_elems[i].weight = angle_max; - } - } - - if (tot_found != 0) { - qsort(weight_elems, vinput->len, sizeof(DissolveElemWeight), dissolve_elem_cmp); - - for (i = 0; i < tot_found; i++) { - BMVert *v = (BMVert *)weight_elems[i].ele; - if (/* topology changes may cause this to be un-collapsable */ - (BM_vert_edge_count(v) == 2) && - /* check twice because cumulative effect could dissolve over angle limit */ - bm_vert_edge_face_angle(v) < angle_limit) - { - BMEdge *ne = BM_vert_collapse_edge(bm, v->e, v, TRUE); /* join edges */ - - if (ne && ne->l) { - BM_edge_normals_update(ne); - } - } - } - } + const float angle_limit = min_ff(angle_max, BMO_slot_float_get(op, "angle_limit")); + const int do_dissolve_boundaries = BMO_slot_bool_get(op, "use_dissolve_boundaries"); - MEM_freeN(weight_elems); + BM_mesh_decimate_dissolve_ex(bm, angle_limit, do_dissolve_boundaries, + vinput->data.p, vinput->len, + einput->data.p, einput->len); } diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 81cad277bee..627351ead11 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -88,7 +88,7 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) f2 = BM_face_create_ngon(bm, firstv, BM_edge_other_vert(edges[0], firstv), edges, f->len, FALSE); if (UNLIKELY(f2 == NULL)) { - BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Extrude failed; could not create face"); + BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Extrude failed: could not create face"); BLI_array_free(edges); return; } @@ -132,46 +132,36 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) * This function won't crash if its not but won't work right either. * \a e_b is the new edge. * - * \note this function could be exposed as an api call if other areas need it, - * so far only extrude does. + * \note The edge this face comes from needs to be from the first and second verts fo the face. + * The caller must ensure this else we will copy from the wrong source. */ -static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f, BMEdge *e_a, BMEdge *e_b) +static void bm_extrude_copy_face_loop_attributes(BMesh *bm, BMFace *f) { - /* 'a' is the starting edge #e, 'b' is the final edge #newedge */ - BMLoop *l_dst_a = BM_face_edge_share_loop(f, e_a); - BMLoop *l_dst_b = BM_face_edge_share_loop(f, e_b); - /* we could only have a face on one-or the other edges, - * check if either side of the face has an adjacent face */ - BMLoop *l_src_1; - BMLoop *l_src_2; - - /* there is no l_src_b */ - - /* sanity */ - BLI_assert(l_dst_a->f == l_dst_b->f); - - if (l_dst_a != l_dst_a->radial_next) { - l_src_1 = l_dst_a->radial_next; - l_src_2 = l_src_1->next; - } - else if (l_dst_b != l_dst_b->radial_next) { - l_src_2 = l_dst_b->radial_next; - l_src_1 = l_src_2->next; - } - else { - /* no new faces on either edge, nothing to copy from */ + /* edge we are extruded from */ + BMLoop *l_first_0 = BM_FACE_FIRST_LOOP(f); + BMLoop *l_first_1 = l_first_0->next; + BMLoop *l_first_2 = l_first_1->next; + BMLoop *l_first_3 = l_first_2->next; + + BMLoop *l_other_0; + BMLoop *l_other_1; + + if (UNLIKELY(l_first_0 == l_first_0->radial_next)) { return; } - BM_elem_attrs_copy(bm, bm, l_src_1->f, l_dst_a->f); - BM_elem_flag_disable(f, BM_ELEM_HIDDEN); /* possibly we copy from a hidden face */ + l_other_0 = BM_edge_other_loop(l_first_0->e, l_first_0); + l_other_1 = BM_edge_other_loop(l_first_0->e, l_first_1); /* copy data */ - BM_elem_attrs_copy(bm, bm, l_src_2, l_dst_a); - BM_elem_attrs_copy(bm, bm, l_src_2, l_dst_b->next); + BM_elem_attrs_copy(bm, bm, l_other_0->f, f); + BM_elem_flag_disable(f, BM_ELEM_HIDDEN); /* possibly we copy from a hidden face */ - BM_elem_attrs_copy(bm, bm, l_src_1, l_dst_a->next); - BM_elem_attrs_copy(bm, bm, l_src_1, l_dst_b); + BM_elem_attrs_copy(bm, bm, l_other_0, l_first_0); + BM_elem_attrs_copy(bm, bm, l_other_0, l_first_3); + + BM_elem_attrs_copy(bm, bm, l_other_1, l_first_1); + BM_elem_attrs_copy(bm, bm, l_other_1, l_first_2); } /* Disable the skin root flag on the input vert, assumes that the vert @@ -188,9 +178,8 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op) { BMOIter siter; BMOperator dupeop; - BMVert *v1, *v2, *v3, *v4; - BMEdge *e, *e2; BMFace *f; + BMEdge *e, *e_new; BMO_ITER (e, &siter, bm, op, "edges", BM_EDGE) { BMO_elem_flag_enable(bm, e, EXT_INPUT); @@ -203,33 +192,34 @@ void bmo_extrude_edge_only_exec(BMesh *bm, BMOperator *op) /* disable root flag on all new skin nodes */ if (CustomData_has_layer(&bm->vdata, CD_MVERT_SKIN)) { - BMO_ITER(v1, &siter, bm, &dupeop, "newout", BM_VERT) { - bm_extrude_disable_skin_root(bm, v1); + BMVert *v; + BMO_ITER(v, &siter, bm, &dupeop, "newout", BM_VERT) { + bm_extrude_disable_skin_root(bm, v); } } for (e = BMO_iter_new(&siter, bm, &dupeop, "boundarymap", 0); e; e = BMO_iter_step(&siter)) { - e2 = BMO_iter_map_value(&siter); - e2 = *(BMEdge **)e2; + BMVert *f_verts[4]; + e_new = *(BMEdge **)BMO_iter_map_value(&siter); if (e->l && e->v1 != e->l->v) { - v1 = e->v1; - v2 = e->v2; - v3 = e2->v2; - v4 = e2->v1; + f_verts[0] = e->v1; + f_verts[1] = e->v2; + f_verts[2] = e_new->v2; + f_verts[3] = e_new->v1; } else { - v1 = e2->v1; - v2 = e2->v2; - v3 = e->v2; - v4 = e->v1; + f_verts[0] = e->v2; + f_verts[1] = e->v1; + f_verts[2] = e_new->v1; + f_verts[3] = e_new->v2; } /* not sure what to do about example face, pass NULL for now */ - f = BM_face_create_quad_tri(bm, v1, v2, v3, v4, NULL, FALSE); - bm_extrude_copy_face_loop_attributes(bm, f, e, e2); + f = BM_face_create_quad_tri_v(bm, f_verts, 4, NULL, FALSE); + bm_extrude_copy_face_loop_attributes(bm, f); if (BMO_elem_flag_test(bm, e, EXT_INPUT)) - e = e2; + e = e_new; BMO_elem_flag_enable(bm, f, EXT_KEEP); BMO_elem_flag_enable(bm, e, EXT_KEEP); @@ -270,8 +260,8 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) BMOperator dupeop, delop; BMOIter siter; BMIter iter, fiter, viter; - BMEdge *e, *newedge; - BMVert *verts[4], *v, *v2; + BMEdge *e, *e_new; + BMVert *v, *v2; BMFace *f; int found, fwd, delorig = FALSE; @@ -378,6 +368,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) BMO_slot_copy(&dupeop, op, "newout", "geomout"); for (e = BMO_iter_new(&siter, bm, &dupeop, "boundarymap", 0); e; e = BMO_iter_step(&siter)) { + BMVert *f_verts[4]; /* this should always be wire, so this is mainly a speedup to avoid map lookup */ if (BM_edge_is_wire(e) && BMO_slot_map_contains(bm, op, "exclude", e)) { @@ -396,37 +387,37 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op) continue; } - newedge = *(BMEdge **)BMO_iter_map_value(&siter); + e_new = *(BMEdge **)BMO_iter_map_value(&siter); - if (!newedge) { + if (!e_new) { continue; } /* orient loop to give same normal as a loop of newedge * if it exists (will be an extruded face), * else same normal as a loop of e, if it exists */ - if (!newedge->l) + if (!e_new->l) fwd = !e->l || !(e->l->v == e->v1); else - fwd = (newedge->l->v == newedge->v1); + fwd = (e_new->l->v == e_new->v1); if (fwd) { - verts[0] = e->v1; - verts[1] = e->v2; - verts[2] = newedge->v2; - verts[3] = newedge->v1; + f_verts[0] = e->v1; + f_verts[1] = e->v2; + f_verts[2] = e_new->v2; + f_verts[3] = e_new->v1; } else { - verts[3] = e->v1; - verts[2] = e->v2; - verts[1] = newedge->v2; - verts[0] = newedge->v1; + f_verts[0] = e->v2; + f_verts[1] = e->v1; + f_verts[2] = e_new->v1; + f_verts[3] = e_new->v2; } /* not sure what to do about example face, pass NULL for now */ - f = BM_face_create_quad_tri_v(bm, verts, 4, NULL, FALSE); - bm_extrude_copy_face_loop_attributes(bm, f, e, newedge); + f = BM_face_create_quad_tri_v(bm, f_verts, 4, NULL, FALSE); + bm_extrude_copy_face_loop_attributes(bm, f); } /* link isolated vert */ diff --git a/source/blender/bmesh/operators/bmo_hull.c b/source/blender/bmesh/operators/bmo_hull.c index d97d901777c..013b6183f84 100644 --- a/source/blender/bmesh/operators/bmo_hull.c +++ b/source/blender/bmesh/operators/bmo_hull.c @@ -24,19 +24,17 @@ * \ingroup bmesh */ +#ifdef WITH_BULLET + #include "MEM_guardedalloc.h" +#include "BLI_array.h" #include "BLI_ghash.h" #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_utildefines.h" -/*XXX: This operator doesn't work well (at all?) for flat surfaces with - * >3 sides - creating overlapping faces at times. - * An easy workaround is to add in some noise but this is - * weak and unreliable, ideally this would detect flat surfaces - * (possibly making them into ngons) - see - */ +#include "Bullet-C-Api.h" /* XXX: using 128 for totelem and pchunk of mempool, no idea what good * values would be though */ @@ -46,21 +44,15 @@ #include "intern/bmesh_operators_private.h" /* own include */ -#define HULL_EPSILON_FLT 0.0001f -/* values above 0.0001 cause errors, see below for details, don't increase - * without checking against bug [#32027] */ -#define HULL_EPSILON_DOT_FLT 0.00000001f - /* Internal operator flags */ typedef enum { HULL_FLAG_INPUT = (1 << 0), - HULL_FLAG_TETRA_VERT = (1 << 1), - HULL_FLAG_INTERIOR_ELE = (1 << 2), - HULL_FLAG_OUTPUT_GEOM = (1 << 3), + HULL_FLAG_INTERIOR_ELE = (1 << 1), + HULL_FLAG_OUTPUT_GEOM = (1 << 2), - HULL_FLAG_DEL = (1 << 4), - HULL_FLAG_HOLE = (1 << 5) + HULL_FLAG_DEL = (1 << 3), + HULL_FLAG_HOLE = (1 << 4) } HullFlags; /* Store hull triangles separate from BMesh faces until the end; this @@ -72,63 +64,6 @@ typedef struct HullTriangle { int skip; } HullTriangle; -/* These edges define the hole created in the hull by deleting faces - * that can "see" a new vertex (the boundary edges then form the edge - * of a new triangle fan that has the new vertex as its center) */ -typedef struct HullBoundaryEdge { - struct HullBoundaryEdge *next, *prev; - BMVert *v[2]; -} HullBoundaryEdge; - - - -/*************************** Boundary Edges ***************************/ - -static int edge_match(BMVert *e1_v1, BMVert *e1_v2, BMVert *e2[2]) -{ - return (e1_v1 == e2[0] && e1_v2 == e2[1]) || - (e1_v1 == e2[1] && e1_v2 == e2[0]); -} - -/* Returns true if the edge (e1, e2) is already in edges; that edge is - * deleted here as well. if not found just returns 0 */ -static int check_for_dup(ListBase *edges, BLI_mempool *pool, - BMVert *v1, BMVert *v2) -{ - HullBoundaryEdge *e, *e_next; - - for (e = edges->first; e; e = e_next) { - e_next = e->next; - - if (edge_match(v1, v2, e->v)) { - /* remove the interior edge */ - BLI_remlink(edges, e); - BLI_mempool_free(pool, e); - return 1; - } - } - - return 0; -} - -static void expand_boundary_edges(ListBase *edges, BLI_mempool *edge_pool, - const HullTriangle *t) -{ - HullBoundaryEdge *e_new; - int i; - - /* Insert each triangle edge into the boundary list; if any of - * its edges are already in there, remove the edge entirely */ - for (i = 0; i < 3; i++) { - if (!check_for_dup(edges, edge_pool, t->v[i], t->v[(i + 1) % 3])) { - e_new = BLI_mempool_calloc(edge_pool); - e_new->v[0] = t->v[i]; - e_new->v[1] = t->v[(i + 1) % 3]; - BLI_addtail(edges, e_new); - } - } -} - /*************************** Hull Triangles ***************************/ @@ -152,75 +87,6 @@ static void hull_add_triangle(BMesh *bm, GHash *hull_triangles, BLI_mempool *poo normal_tri_v3(t->no, v1->co, v2->co, v3->co); } -static int hull_point_tri_side(const HullTriangle *t, const float co[3]) -{ - /* Added epsilon to fix bug [#31941], improves output when some - * vertices are nearly coplanar. Might need further tweaking for - * other cases though. - * ... - * Update: epsilon of 0.0001 causes [#32027], use HULL_EPSILON_DOT_FLT - * and give it a much smaller value - * */ - float p[3], d; - sub_v3_v3v3(p, co, t->v[0]->co); - d = dot_v3v3(t->no, p); - if (d < -HULL_EPSILON_DOT_FLT) return -1; - else if (d > HULL_EPSILON_DOT_FLT) return 1; - else return 0; -} - -/* Get all hull triangles that vertex 'v' is outside of */ -static GHash *hull_triangles_v_outside(GHash *hull_triangles, const BMVert *v) -{ - GHash *outside; - GHashIterator iter; - - outside = BLI_ghash_ptr_new("outside"); - - GHASH_ITER (iter, hull_triangles) { - HullTriangle *t = BLI_ghashIterator_getKey(&iter); - - if (hull_point_tri_side(t, v->co) > 0) - BLI_ghash_insert(outside, t, NULL); - } - - return outside; -} - -/* For vertex 'v', find which triangles must be deleted to extend the - * hull; find the boundary edges of that hole so that it can be filled - * with connections to the new vertex, and update the hull_triangles - * to delete the marked triangles */ -static void add_point(BMesh *bm, GHash *hull_triangles, BLI_mempool *hull_pool, - BLI_mempool *edge_pool, GHash *outside, BMVert *v) -{ - ListBase edges = {NULL, NULL}; - HullBoundaryEdge *e, *e_next; - GHashIterator iter; - - GHASH_ITER (iter, outside) { - HullTriangle *t = BLI_ghashIterator_getKey(&iter); - int i; - - expand_boundary_edges(&edges, edge_pool, t); - - /* Mark triangle's vertices as interior */ - for (i = 0; i < 3; i++) - BMO_elem_flag_enable(bm, t->v[i], HULL_FLAG_INTERIOR_ELE); - - /* Delete the triangle */ - BLI_ghash_remove(hull_triangles, t, NULL, NULL); - BLI_mempool_free(hull_pool, t); - } - - /* Fill hole boundary with triangles to new point */ - for (e = edges.first; e; e = e_next) { - e_next = e->next; - hull_add_triangle(bm, hull_triangles, hull_pool, e->v[0], e->v[1], v); - BLI_mempool_free(edge_pool, e); - } -} - static BMFace *hull_find_example_face(BMesh *bm, BMEdge *e) { BMIter iter; @@ -243,6 +109,7 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles) GHASH_ITER (iter, hull_triangles) { HullTriangle *t = BLI_ghashIterator_getKey(&iter); + int i; if (!t->skip) { BMEdge *edges[3] = { @@ -251,25 +118,53 @@ static void hull_output_triangles(BMesh *bm, GHash *hull_triangles) BM_edge_create(bm, t->v[2], t->v[0], NULL, TRUE) }; BMFace *f, *example = NULL; - int i; - /* Look for an adjacent face that existed before the hull */ - for (i = 0; i < 3; i++) { - if (!example) - example = hull_find_example_face(bm, edges[i]); + if (BM_face_exists(bm, t->v, 3, &f)) { + /* If the operator is run with "use_existing_faces" + * disabled, but an output face in the hull is the + * same as a face in the existing mesh, it should not + * be marked as unused or interior. */ + BMO_elem_flag_enable(bm, f, HULL_FLAG_OUTPUT_GEOM); + BMO_elem_flag_disable(bm, f, HULL_FLAG_HOLE); + BMO_elem_flag_disable(bm, f, HULL_FLAG_INTERIOR_ELE); } + else { + /* Look for an adjacent face that existed before the hull */ + for (i = 0; i < 3; i++) { + if (!example) + example = hull_find_example_face(bm, edges[i]); + } - f = BM_face_create_quad_tri_v(bm, t->v, 3, example, FALSE); - BM_face_copy_shared(bm, f); - - /* Mark face/verts/edges for 'geomout' slot and select */ + /* Create new hull face */ + f = BM_face_create_quad_tri_v(bm, t->v, 3, example, TRUE); + BM_face_copy_shared(bm, f); + } + /* Mark face for 'geomout' slot and select */ BMO_elem_flag_enable(bm, f, HULL_FLAG_OUTPUT_GEOM); BM_face_select_set(bm, f, TRUE); + + /* Mark edges for 'geomout' slot */ for (i = 0; i < 3; i++) { - BMO_elem_flag_enable(bm, t->v[i], HULL_FLAG_OUTPUT_GEOM); BMO_elem_flag_enable(bm, edges[i], HULL_FLAG_OUTPUT_GEOM); } } + else { + /* Mark input edges for 'geomout' slot */ + for (i = 0; i < 3; i++) { + const int next = (i == 2 ? 0 : i + 1); + BMEdge *e = BM_edge_exists(t->v[i], t->v[next]); + if (e && + BMO_elem_flag_test(bm, e, HULL_FLAG_INPUT) && + !BMO_elem_flag_test(bm, e, HULL_FLAG_HOLE)) { + BMO_elem_flag_enable(bm, e, HULL_FLAG_OUTPUT_GEOM); + } + } + } + + /* Mark verts for 'geomout' slot */ + for (i = 0; i < 3; i++) { + BMO_elem_flag_enable(bm, t->v[i], HULL_FLAG_OUTPUT_GEOM); + } } } @@ -362,158 +257,6 @@ static void hull_final_edges_free(HullFinalEdges *final_edges) -/************************* Initial Tetrahedron ************************/ - -static void hull_add_tetrahedron(BMesh *bm, GHash *hull_triangles, BLI_mempool *pool, - BMVert *tetra[4]) -{ - float center[3]; - int i, indices[4][3] = { - {0, 1, 2}, - {0, 2, 3}, - {1, 0, 3}, - {2, 1, 3} - }; - - /* Calculate center */ - zero_v3(center); - for (i = 0; i < 4; i++) - add_v3_v3(center, tetra[i]->co); - mul_v3_fl(center, 0.25f); - - for (i = 0; i < 4; i++) { - BMVert *v1 = tetra[indices[i][0]]; - BMVert *v2 = tetra[indices[i][1]]; - BMVert *v3 = tetra[indices[i][2]]; - float no[3], d[3]; - - normal_tri_v3(no, v1->co, v2->co, v3->co); - sub_v3_v3v3(d, center, v1->co); - if (dot_v3v3(no, d) > 0) - SWAP(BMVert *, v1, v3); - - hull_add_triangle(bm, hull_triangles, pool, v1, v2, v3); - } -} - -/* For each axis, get the minimum and maximum input vertices */ -static void hull_get_min_max(BMesh *bm, BMOperator *op, - BMVert *min[3], BMVert *max[3]) -{ - BMOIter oiter; - BMVert *v; - - min[0] = min[1] = min[2] = NULL; - max[0] = max[1] = max[2] = NULL; - - BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) { - int i; - - for (i = 0; i < 3; i++) { - if (!min[i] || v->co[i] < min[i]->co[i]) - min[i] = v; - if (!max[i] || v->co[i] > max[i]->co[i]) - max[i] = v; - } - } -} - -/* Returns true if input is coplanar */ -static int hull_find_large_tetrahedron(BMesh *bm, BMOperator *op, - BMVert *tetra[4]) -{ - BMVert *min[3], *max[3], *v; - BMOIter oiter; - float widest_axis_len, largest_dist, plane_normal[3]; - int i, j, widest_axis; - - tetra[0] = tetra[1] = tetra[2] = tetra[3] = NULL; - hull_get_min_max(bm, op, min, max); - - /* Check for flat axis */ - for (i = 0; i < 3; i++) { - if (min[i] == max[i]) { - return TRUE; - } - } - - /* Find widest axis */ - widest_axis_len = 0.0f; - widest_axis = 0; /* set here in the unlikey case this isn't set below */ - for (i = 0; i < 3; i++) { - float len = (max[i]->co[i] - min[i]->co[i]); - if (len >= widest_axis_len) { - widest_axis_len = len; - widest_axis = i; - } - } - - /* Use widest axis for first two points */ - tetra[0] = min[widest_axis]; - tetra[1] = max[widest_axis]; - BMO_elem_flag_enable(bm, tetra[0], HULL_FLAG_TETRA_VERT); - BMO_elem_flag_enable(bm, tetra[1], HULL_FLAG_TETRA_VERT); - - /* Choose third vertex farthest from existing line segment */ - largest_dist = 0; - for (i = 0; i < 3; i++) { - BMVert *v; - float dist; - - if (i == widest_axis) - continue; - - v = min[i]; - for (j = 0; j < 2; j++) { - dist = dist_to_line_segment_v3(v->co, tetra[0]->co, tetra[1]->co); - if (dist > largest_dist) { - largest_dist = dist; - tetra[2] = v; - } - - v = max[i]; - } - } - - if (tetra[2]) { - BMO_elem_flag_enable(bm, tetra[2], HULL_FLAG_TETRA_VERT); - } - else { - return TRUE; - } - - /* Check for colinear vertices */ - if (largest_dist < HULL_EPSILON_FLT) - return TRUE; - - /* Choose fourth point farthest from existing plane */ - largest_dist = 0; - normal_tri_v3(plane_normal, tetra[0]->co, tetra[1]->co, tetra[2]->co); - BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) { - if (!BMO_elem_flag_test(bm, v, HULL_FLAG_TETRA_VERT)) { - float dist = fabsf(dist_to_plane_v3(v->co, tetra[0]->co, plane_normal)); - if (dist > largest_dist) { - largest_dist = dist; - tetra[3] = v; - } - } - } - - if (tetra[3]) { - BMO_elem_flag_enable(bm, tetra[3], HULL_FLAG_TETRA_VERT); - } - else { - return TRUE; - } - - if (largest_dist < HULL_EPSILON_FLT) - return TRUE; - - return FALSE; -} - - - /**************************** Final Output ****************************/ static void hull_remove_overlapping(BMesh *bm, GHash *hull_triangles, @@ -650,44 +393,175 @@ static void hull_tag_holes(BMesh *bm, BMOperator *op) } } - /* Mark edges too if all adjacent faces are holes */ + /* Mark edges too if all adjacent faces are holes and the edge is + * not already isolated */ BMO_ITER (e, &oiter, bm, op, "input", BM_EDGE) { int hole = TRUE; + int any_faces = FALSE; BM_ITER_ELEM (f, &iter, e, BM_FACES_OF_EDGE) { + any_faces = TRUE; if (!BMO_elem_flag_test(bm, f, HULL_FLAG_HOLE)) { hole = FALSE; break; } } - if (hole) + if (hole && any_faces) BMO_elem_flag_enable(bm, e, HULL_FLAG_HOLE); } } +static int hull_input_vert_count(BMesh *bm, BMOperator *op) +{ + BMOIter oiter; + BMVert *v; + int count = 0; + + BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) { + count++; + } + + return count; +} + +static BMVert **hull_input_verts_copy(BMesh *bm, BMOperator *op, + const int num_input_verts) +{ + BMOIter oiter; + BMVert *v; + BMVert **input_verts = MEM_callocN(sizeof(*input_verts) * + num_input_verts, AT); + int i = 0; + + BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) { + input_verts[i++] = v; + } + + return input_verts; +} + +static float (*hull_verts_for_bullet(BMVert **input_verts, + const int num_input_verts))[3] +{ + float (*coords)[3] = MEM_callocN(sizeof(*coords) * num_input_verts, AT); + int i; + + for (i = 0; i < num_input_verts; i++) { + copy_v3_v3(coords[i], input_verts[i]->co); + } + + return coords; +} + +static BMVert **hull_verts_from_bullet(plConvexHull hull, + BMVert **input_verts, + const int num_input_verts) +{ + const int num_verts = plConvexHullNumVertices(hull); + BMVert **hull_verts = MEM_mallocN(sizeof(*hull_verts) * + num_verts, AT); + int i; + + for (i = 0; i < num_verts; i++) { + float co[3]; + int original_index; + plConvexHullGetVertex(hull, i, co, &original_index); + + if (original_index >= 0 && original_index < num_input_verts) { + hull_verts[i] = input_verts[original_index]; + } + else + BLI_assert(!"Unexpected new vertex in hull output"); + } + + return hull_verts; +} + +static void hull_from_bullet(BMesh *bm, BMOperator *op, + GHash *hull_triangles, + BLI_mempool *pool) +{ + int *fvi = NULL; + BLI_array_declare(fvi); + + BMVert **input_verts; + float (*coords)[3]; + BMVert **hull_verts; + + plConvexHull hull; + int i, count = 0; + + const int num_input_verts = hull_input_vert_count(bm, op); + + input_verts = hull_input_verts_copy(bm, op, num_input_verts); + coords = hull_verts_for_bullet(input_verts, num_input_verts); + + hull = plConvexHullCompute(coords, num_input_verts); + hull_verts = hull_verts_from_bullet(hull, input_verts, num_input_verts); + + count = plConvexHullNumFaces(hull); + for (i = 0; i < count; i++) { + const int len = plConvexHullGetFaceSize(hull, i); + + if (len > 2) { + BMVert *fv[3]; + int j; + + /* Get face vertex indices */ + BLI_array_empty(fvi); + BLI_array_grow_items(fvi, len); + plConvexHullGetFaceVertices(hull, i, fvi); + + /* Note: here we throw away any NGons from Bullet and turn + * them into triangle fans. Would be nice to use these + * directly, but will have to wait until HullTriangle goes + * away (TODO) */ + fv[0] = hull_verts[fvi[0]]; + for (j = 2; j < len; j++) { + fv[1] = hull_verts[fvi[j - 1]]; + fv[2] = hull_verts[fvi[j]]; + + hull_add_triangle(bm, hull_triangles, pool, + fv[0], fv[1], fv[2]); + } + } + } + + BLI_array_free(fvi); + MEM_freeN(hull_verts); + MEM_freeN(coords); + MEM_freeN(input_verts); +} + +/* Check that there are at least three vertices in the input */ +static int hull_num_input_verts_is_ok(BMesh *bm, BMOperator *op) +{ + BMOIter oiter; + BMVert *v; + int partial_num_verts = 0; + + BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) { + partial_num_verts++; + if (partial_num_verts >= 3) + break; + } + + return (partial_num_verts >= 3); +} + void bmo_convex_hull_exec(BMesh *bm, BMOperator *op) { HullFinalEdges *final_edges; - BLI_mempool *hull_pool, *edge_pool; - BMVert *v, *tetra[4]; + BLI_mempool *hull_pool; BMElemF *ele; BMOIter oiter; GHash *hull_triangles; - /* Verify that at least four verts in the input */ - if (BMO_slot_get(op, "input")->len < 4) { - BMO_error_raise(bm, op, BMERR_CONVEX_HULL_FAILED, - "Requires at least four vertices"); - return; - } - - /* Initialize the convex hull by building a tetrahedron. A - * degenerate tetrahedron can cause problems, so report error and - * fail if the result is coplanar */ - if (hull_find_large_tetrahedron(bm, op, tetra)) { + /* Verify that at least three verts in the input */ + if (!hull_num_input_verts_is_ok(bm, op)) { BMO_error_raise(bm, op, BMERR_CONVEX_HULL_FAILED, - "Input vertices are coplanar"); + "Requires at least three vertices"); return; } @@ -700,26 +574,11 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op) BMO_elem_flag_enable(bm, ele, HULL_FLAG_INTERIOR_ELE); } - edge_pool = BLI_mempool_create(sizeof(HullBoundaryEdge), 128, 128, 0); hull_pool = BLI_mempool_create(sizeof(HullTriangle), 128, 128, 0); hull_triangles = BLI_ghash_ptr_new("hull_triangles"); - /* Add tetrahedron triangles */ - hull_add_tetrahedron(bm, hull_triangles, hull_pool, tetra); + hull_from_bullet(bm, op, hull_triangles, hull_pool); - /* Expand hull to cover new vertices outside the existing hull */ - BMO_ITER (v, &oiter, bm, op, "input", BM_VERT) { - if (!BMO_elem_flag_test(bm, v, HULL_FLAG_TETRA_VERT)) { - GHash *outside = hull_triangles_v_outside(hull_triangles, v); - if (BLI_ghash_size(outside)) { - /* Expand hull and delete interior triangles */ - add_point(bm, hull_triangles, hull_pool, edge_pool, outside, v); - } - BLI_ghash_free(outside, NULL, NULL); - } - } - - BLI_mempool_destroy(edge_pool); final_edges = hull_final_edges(hull_triangles); hull_mark_interior_elements(bm, op, final_edges); @@ -762,3 +621,5 @@ void bmo_convex_hull_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_from_enabled_flag(bm, op, "geomout", BM_ALL, HULL_FLAG_OUTPUT_GEOM); } + +#endif /* WITH_BULLET */ diff --git a/source/blender/bmesh/operators/bmo_slide.c b/source/blender/bmesh/operators/bmo_slide.c index 0036f095d00..6db76119205 100644 --- a/source/blender/bmesh/operators/bmo_slide.c +++ b/source/blender/bmesh/operators/bmo_slide.c @@ -63,7 +63,7 @@ void bmo_slide_vert_exec(BMesh *bm, BMOperator *op) if (G.debug & G_DEBUG) { fprintf(stderr, "slide_vert: No vertex selected..."); } - BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide Error: Invalid selection."); + BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide error: invalid selection"); return; } @@ -83,7 +83,7 @@ void bmo_slide_vert_exec(BMesh *bm, BMOperator *op) if (G.debug & G_DEBUG) { fprintf(stderr, "slide_vert: select a single edge\n"); } - BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide Error: Invalid selection."); + BMO_error_raise(bm, op, BMERR_INVALID_SELECTION, "Vertex Slide error: invalid selection"); return; } diff --git a/source/blender/bmesh/operators/bmo_smooth_laplacian.c b/source/blender/bmesh/operators/bmo_smooth_laplacian.c new file mode 100644 index 00000000000..9a2a9c022e6 --- /dev/null +++ b/source/blender/bmesh/operators/bmo_smooth_laplacian.c @@ -0,0 +1,618 @@ +/* + * ***** 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. + * + * Contributor(s): Alexander Pinzon + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/bmesh/operators/bmo_smooth_laplacian.c + * \ingroup bmesh + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_meshdata_types.h" + +#include "BLI_array.h" +#include "BLI_heap.h" +#include "BLI_math.h" +#include "BLI_math_geom.h" +#include "BLI_smallhash.h" + +#include "BKE_customdata.h" +#include "BKE_mesh.h" + +#include "bmesh.h" + +#include "ONL_opennl.h" + +#include "intern/bmesh_operators_private.h" /* own include */ + +#define SMOOTH_LAPLACIAN_AREA_FACTOR 4.0f +#define SMOOTH_LAPLACIAN_EDGE_FACTOR 2.0f +#define SMOOTH_LAPLACIAN_MAX_EDGE_PERCENTAGE 1.8 +#define SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE 0.15 + +struct BLaplacianSystem { + float *eweights; /* Length weights per Edge */ + float (*fweights)[3]; /* Cotangent weights per face */ + float *ring_areas; /* Total area per ring*/ + float *vlengths; /* Total sum of lengths(edges) per vertice*/ + float *vweights; /* Total sum of weights per vertice*/ + int numEdges; /* Number of edges*/ + int numFaces; /* Number of faces*/ + int numVerts; /* Number of verts*/ + short *zerola; /* Is zero area or length*/ + + /* Pointers to data*/ + BMesh *bm; + BMOperator *op; + NLContext *context; + + /*Data*/ + float min_area; +}; +typedef struct BLaplacianSystem LaplacianSystem; + +static float compute_volume(BMesh *bm); +static float cotan_weight(float *v1, float *v2, float *v3); +static int vert_is_boundary(BMVert *v); +static LaplacianSystem * init_laplacian_system( int a_numEdges, int a_numFaces, int a_numVerts); +static void init_laplacian_matrix(LaplacianSystem * sys); +static void delete_laplacian_system(LaplacianSystem * sys); +static void delete_void_pointer(void *data); +static void fill_laplacian_matrix(LaplacianSystem * sys); +static void memset_laplacian_system(LaplacianSystem *sys, int val); +static void validate_solution(LaplacianSystem * sys, int usex, int usey, int usez, int volumepreservation); +static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend, int usex, int usey, int usez); + +static void delete_void_pointer(void *data) +{ + if (data) { + MEM_freeN(data); + data = NULL; + } +} + +static void delete_laplacian_system(LaplacianSystem * sys) +{ + delete_void_pointer(sys->eweights); + delete_void_pointer(sys->fweights); + delete_void_pointer(sys->ring_areas); + delete_void_pointer(sys->vlengths); + delete_void_pointer(sys->vweights); + delete_void_pointer(sys->zerola); + if (sys->context) { + nlDeleteContext(sys->context); + } + sys->bm = NULL; + sys->op = NULL; + MEM_freeN(sys); +} + +static void memset_laplacian_system(LaplacianSystem *sys, int val) +{ + memset(sys->eweights , val, sizeof(float) * sys->numEdges); + memset(sys->fweights , val, sizeof(float) * sys->numFaces * 3); + memset(sys->ring_areas , val, sizeof(float) * sys->numVerts); + memset(sys->vlengths , val, sizeof(float) * sys->numVerts); + memset(sys->vweights , val, sizeof(float) * sys->numVerts); + memset(sys->zerola , val, sizeof(short) * sys->numVerts); +} + +static LaplacianSystem * init_laplacian_system( int a_numEdges, int a_numFaces, int a_numVerts) +{ + LaplacianSystem * sys; + sys = MEM_callocN(sizeof(LaplacianSystem), "ModLaplSmoothSystem"); + sys->numEdges = a_numEdges; + sys->numFaces = a_numFaces; + sys->numVerts = a_numVerts; + + sys->eweights = MEM_callocN(sizeof(float) * sys->numEdges, "ModLaplSmoothEWeight"); + if (!sys->eweights) { + delete_laplacian_system(sys); + return NULL; + } + + sys->fweights = MEM_callocN(sizeof(float) * 3 * sys->numFaces, "ModLaplSmoothFWeight"); + if (!sys->fweights) { + delete_laplacian_system(sys); + return NULL; + } + + sys->ring_areas = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothRingAreas"); + if (!sys->ring_areas) { + delete_laplacian_system(sys); + return NULL; + } + + sys->vlengths = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothVlengths"); + if (!sys->vlengths) { + delete_laplacian_system(sys); + return NULL; + } + + sys->vweights = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothVweights"); + if (!sys->vweights) { + delete_laplacian_system(sys); + return NULL; + } + + sys->zerola = MEM_callocN(sizeof(short) * sys->numVerts, "ModLaplSmoothZeloa"); + if (!sys->zerola) { + delete_laplacian_system(sys); + return NULL; + } + + return sys; +} + +/* Compute weigth between vertice v_i and all your neighbors + * weight between v_i and v_neighbor + * Wij = cot(alpha) + cot(beta) / (4.0 * total area of all faces * sum all weight) + * v_i * + * / | \ + * / | \ + * v_beta* | * v_alpha + * \ | / + * \ | / + * * v_neighbor +*/ + +static void init_laplacian_matrix(LaplacianSystem * sys) +{ + float areaf; + float *v1, *v2, *v3, *v4; + float w1, w2, w3, w4; + int i, j; + int has_4_vert ; + unsigned int idv1, idv2, idv3, idv4, idv[4]; + BMEdge *e; + BMFace *f; + BMIter eiter; + BMIter fiter; + BMIter vi; + BMVert *vn; + BMVert *vf[4]; + + BM_ITER_MESH_INDEX (e, &eiter, sys->bm, BM_EDGES_OF_MESH, j) { + if (!BM_elem_flag_test(e, BM_ELEM_SELECT) && BM_edge_is_boundary(e)) { + v1 = e->v1->co; + v2 = e->v2->co; + idv1 = BM_elem_index_get(e->v1); + idv2 = BM_elem_index_get(e->v2); + + w1 = len_v3v3(v1, v2); + if (w1 > sys->min_area) { + w1 = 1.0f / w1; + i = BM_elem_index_get(e); + sys->eweights[i] = w1; + sys->vlengths[idv1] += w1; + sys->vlengths[idv2] += w1; + }else{ + sys->zerola[idv1] = 1; + sys->zerola[idv2] = 1; + } + } + } + + BM_ITER_MESH (f, &fiter, sys->bm, BM_FACES_OF_MESH) { + if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { + + BM_ITER_ELEM_INDEX (vn, &vi, f, BM_VERTS_OF_FACE, i) { + vf[i] = vn; + } + has_4_vert = (i == 4) ? 1 : 0; + idv1 = BM_elem_index_get(vf[0]); + idv2 = BM_elem_index_get(vf[1]); + idv3 = BM_elem_index_get(vf[2]); + idv4 = has_4_vert ? BM_elem_index_get(vf[3]) : 0; + + v1 = vf[0]->co; + v2 = vf[1]->co; + v3 = vf[2]->co; + v4 = has_4_vert ? vf[3]->co : 0; + + if (has_4_vert) { + areaf = area_quad_v3(v1, v2, v3, v4); + } + else { + areaf = area_tri_v3(v1, v2, v3); + } + + if (fabs(areaf) < sys->min_area) { + sys->zerola[idv1] = 1; + sys->zerola[idv2] = 1; + sys->zerola[idv3] = 1; + if (has_4_vert) sys->zerola[idv4] = 1; + } + + sys->ring_areas[idv1] += areaf; + sys->ring_areas[idv2] += areaf; + sys->ring_areas[idv3] += areaf; + if (has_4_vert) sys->ring_areas[idv4] += areaf; + + if (has_4_vert) { + + idv[0] = idv1; + idv[1] = idv2; + idv[2] = idv3; + idv[3] = idv4; + + for (j = 0; j < 4; j++) { + idv1 = idv[j]; + idv2 = idv[(j + 1) % 4]; + idv3 = idv[(j + 2) % 4]; + idv4 = idv[(j + 3) % 4]; + + v1 = vf[j]->co; + v2 = vf[(j + 1) % 4]->co; + v3 = vf[(j + 2) % 4]->co; + v4 = vf[(j + 3) % 4]->co; + + w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2); + w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3); + w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1); + + sys->vweights[idv1] += (w2 + w3 + w4) / 4.0f; + } + } + else { + i = BM_elem_index_get(f); + + w1 = cotan_weight(v1, v2, v3); + w2 = cotan_weight(v2, v3, v1); + w3 = cotan_weight(v3, v1, v2); + + sys->fweights[i][0] += w1; + sys->fweights[i][1] += w2; + sys->fweights[i][2] += w3; + + sys->vweights[idv1] += w2 + w3; + sys->vweights[idv2] += w1 + w3; + sys->vweights[idv3] += w1 + w2; + } + } + } +} + +static void fill_laplacian_matrix(LaplacianSystem * sys) +{ + float *v1, *v2, *v3, *v4; + float w2, w3, w4; + int i, j; + int has_4_vert ; + unsigned int idv1, idv2, idv3, idv4, idv[4]; + + BMEdge *e; + BMFace *f; + BMIter eiter; + BMIter fiter; + BMIter vi; + BMVert *vn; + BMVert *vf[4]; + + BM_ITER_MESH (f, &fiter, sys->bm, BM_FACES_OF_MESH) { + if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { + BM_ITER_ELEM_INDEX (vn, &vi, f, BM_VERTS_OF_FACE, i) { + vf[i] = vn; + } + has_4_vert = (i == 4) ? 1 : 0; + if (has_4_vert) { + idv[0] = BM_elem_index_get(vf[0]); + idv[1] = BM_elem_index_get(vf[1]); + idv[2] = BM_elem_index_get(vf[2]); + idv[3] = BM_elem_index_get(vf[3]); + for (j = 0; j < 4; j++) { + idv1 = idv[j]; + idv2 = idv[(j + 1) % 4]; + idv3 = idv[(j + 2) % 4]; + idv4 = idv[(j + 3) % 4]; + + v1 = vf[j]->co; + v2 = vf[(j + 1) % 4]->co; + v3 = vf[(j + 2) % 4]->co; + v4 = vf[(j + 3) % 4]->co; + + w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2); + w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3); + w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1); + + w2 = w2 / 4.0f; + w3 = w3 / 4.0f; + w4 = w4 / 4.0f; + + if (!vert_is_boundary(vf[j]) && sys->zerola[idv1] == 0) { + nlMatrixAdd(idv1, idv2, w2 * sys->vweights[idv1]); + nlMatrixAdd(idv1, idv3, w3 * sys->vweights[idv1]); + nlMatrixAdd(idv1, idv4, w4 * sys->vweights[idv1]); + } + } + } + else { + idv1 = BM_elem_index_get(vf[0]); + idv2 = BM_elem_index_get(vf[1]); + idv3 = BM_elem_index_get(vf[2]); + /* Is ring if number of faces == number of edges around vertice*/ + i = BM_elem_index_get(f); + if (!vert_is_boundary(vf[0]) && sys->zerola[idv1] == 0) { + nlMatrixAdd(idv1, idv2, sys->fweights[i][2] * sys->vweights[idv1]); + nlMatrixAdd(idv1, idv3, sys->fweights[i][1] * sys->vweights[idv1]); + } + if (!vert_is_boundary(vf[1]) && sys->zerola[idv2] == 0) { + nlMatrixAdd(idv2, idv1, sys->fweights[i][2] * sys->vweights[idv2]); + nlMatrixAdd(idv2, idv3, sys->fweights[i][0] * sys->vweights[idv2]); + } + if (!vert_is_boundary(vf[2]) && sys->zerola[idv3] == 0) { + nlMatrixAdd(idv3, idv1, sys->fweights[i][1] * sys->vweights[idv3]); + nlMatrixAdd(idv3, idv2, sys->fweights[i][0] * sys->vweights[idv3]); + } + } + } + } + BM_ITER_MESH (e, &eiter, sys->bm, BM_EDGES_OF_MESH) { + if (!BM_elem_flag_test(e, BM_ELEM_SELECT) && BM_edge_is_boundary(e) ) { + v1 = e->v1->co; + v2 = e->v2->co; + idv1 = BM_elem_index_get(e->v1); + idv2 = BM_elem_index_get(e->v2); + if (sys->zerola[idv1] == 0 && sys->zerola[idv2] == 0) { + i = BM_elem_index_get(e); + nlMatrixAdd(idv1, idv2, sys->eweights[i] * sys->vlengths[idv1]); + nlMatrixAdd(idv2, idv1, sys->eweights[i] * sys->vlengths[idv2]); + } + } + } +} + +static float cotan_weight(float *v1, float *v2, float *v3) +{ + float a[3], b[3], c[3], clen; + + sub_v3_v3v3(a, v2, v1); + sub_v3_v3v3(b, v3, v1); + cross_v3_v3v3(c, a, b); + + clen = len_v3(c); + + if (clen == 0.0f) + return 0.0f; + + return dot_v3v3(a, b) / clen; +} + +static int vert_is_boundary(BMVert *v) +{ + BMEdge *ed; + BMFace *f; + BMIter ei; + BMIter fi; + BM_ITER_ELEM(ed, &ei, v, BM_EDGES_OF_VERT) { + if (BM_edge_is_boundary(ed)) { + return 1; + } + } + BM_ITER_ELEM (f, &fi, v, BM_FACES_OF_VERT) { + if (!BM_elem_flag_test(f, BM_ELEM_SELECT)) { + return 1; + } + } + return 0; +} + +static float compute_volume(BMesh *bm) +{ + float vol = 0.0f; + float x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4; + int i; + BMFace *f; + BMIter fiter; + BMIter vi; + BMVert *vn; + BMVert *vf[4]; + + BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { + BM_ITER_ELEM_INDEX (vn, &vi, f, BM_VERTS_OF_FACE, i) { + vf[i] = vn; + } + x1 = vf[0]->co[0]; + y1 = vf[0]->co[1]; + z1 = vf[0]->co[2]; + + x2 = vf[1]->co[0]; + y2 = vf[1]->co[1]; + z2 = vf[1]->co[2]; + + x3 = vf[2]->co[0]; + y3 = vf[2]->co[1]; + z3 = vf[2]->co[2]; + + vol += (1.0 / 6.0) * (0.0 - x3*y2*z1 + x2*y3*z1 + x3*y1*z2 - x1*y3*z2 - x2*y1*z3 + x1*y2*z3); + + if (i == 4) { + x4 = vf[3]->co[0]; + y4 = vf[3]->co[1]; + z4 = vf[3]->co[2]; + vol += (1.0 / 6.0) * (x1*y3*z4 - x1*y4*z3 - x3*y1*z4 + x3*z1*y4 + y1*x4*z3 - x4*y3*z1); + } + } + return fabs(vol); +} + +static void volume_preservation(BMesh *bm, BMOperator *op, float vini, float vend, int usex, int usey, int usez) +{ + float beta; + BMOIter siter; + BMVert *v; + + if (vend != 0.0f) { + beta = pow (vini / vend, 1.0f / 3.0f); + BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + if (usex) { + v->co[0] *= beta; + } + if (usey) { + v->co[1] *= beta; + } + if (usez) { + v->co[2] *= beta; + } + + } + } +} + +static void validate_solution(LaplacianSystem * sys, int usex, int usey, int usez, int volumepreservation) +{ + int m_vertex_id; + float leni, lene; + float vini, vend; + float *vi1, *vi2, ve1[3], ve2[3]; + unsigned int idv1, idv2; + BMOIter siter; + BMVert *v; + BMEdge *e; + BMIter eiter; + + BM_ITER_MESH (e, &eiter, sys->bm, BM_EDGES_OF_MESH) { + idv1 = BM_elem_index_get(e->v1); + idv2 = BM_elem_index_get(e->v2); + vi1 = e->v1->co; + vi2 = e->v2->co; + ve1[0] = nlGetVariable(0, idv1); + ve1[1] = nlGetVariable(1, idv1); + ve1[2] = nlGetVariable(2, idv1); + ve2[0] = nlGetVariable(0, idv2); + ve2[1] = nlGetVariable(1, idv2); + ve2[2] = nlGetVariable(2, idv2); + leni = len_v3v3(vi1, vi2); + lene = len_v3v3(ve1, ve2); + if ( lene > leni* SMOOTH_LAPLACIAN_MAX_EDGE_PERCENTAGE || lene < leni*SMOOTH_LAPLACIAN_MIN_EDGE_PERCENTAGE) { + sys->zerola[idv1] = 1; + sys->zerola[idv2] = 1; + } + } + + if (volumepreservation) { + vini = compute_volume(sys->bm); + } + BMO_ITER (v, &siter, sys->bm, sys->op, "verts", BM_VERT) { + m_vertex_id = BM_elem_index_get(v); + if (sys->zerola[m_vertex_id] == 0) { + if (usex) { + v->co[0] = nlGetVariable(0, m_vertex_id); + } + if (usey) { + v->co[1] = nlGetVariable(1, m_vertex_id); + } + if (usez) { + v->co[2] = nlGetVariable(2, m_vertex_id); + } + } + } + if (volumepreservation) { + vend = compute_volume(sys->bm); + volume_preservation(sys->bm, sys->op, vini, vend, usex, usey, usez); + } + +} + +void bmo_smooth_laplacian_vert_exec(BMesh *bm, BMOperator *op) +{ + int i; + int m_vertex_id; + int usex, usey, usez, volumepreservation; + float lambda, lambda_border; + float w; + BMOIter siter; + BMVert *v; + LaplacianSystem * sys; + + sys = init_laplacian_system(bm->totedge, bm->totface, bm->totvert); + if (!sys) return; + sys->bm = bm; + sys->op = op; + + memset_laplacian_system(sys, 0); + + BM_mesh_elem_index_ensure(bm, BM_VERT); + lambda = BMO_slot_float_get(op, "lambda"); + lambda_border = BMO_slot_float_get(op, "lambda_border"); + sys->min_area = 0.00001f; + usex = BMO_slot_bool_get(op, "use_x"); + usey = BMO_slot_bool_get(op, "use_y"); + usez = BMO_slot_bool_get(op, "use_z"); + volumepreservation = BMO_slot_bool_get(op, "volume_preservation"); + + + nlNewContext(); + sys->context = nlGetCurrent(); + + nlSolverParameteri(NL_NB_VARIABLES, bm->totvert); + nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE); + nlSolverParameteri(NL_NB_ROWS, bm->totvert); + nlSolverParameteri(NL_NB_RIGHT_HAND_SIDES, 3); + + nlBegin(NL_SYSTEM); + for (i=0; i < bm->totvert; i++) { + nlLockVariable(i); + } + BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + m_vertex_id = BM_elem_index_get(v); + nlUnlockVariable(m_vertex_id); + nlSetVariable(0,m_vertex_id, v->co[0]); + nlSetVariable(1,m_vertex_id, v->co[1]); + nlSetVariable(2,m_vertex_id, v->co[2]); + } + + nlBegin(NL_MATRIX); + init_laplacian_matrix(sys); + BMO_ITER (v, &siter, bm, op, "verts", BM_VERT) { + m_vertex_id = BM_elem_index_get(v); + nlRightHandSideAdd(0, m_vertex_id, v->co[0]); + nlRightHandSideAdd(1, m_vertex_id, v->co[1]); + nlRightHandSideAdd(2, m_vertex_id, v->co[2]); + i = m_vertex_id; + if (sys->zerola[i] == 0) { + w = sys->vweights[i] * sys->ring_areas[i]; + sys->vweights[i] = (w == 0.0f) ? 0.0f : -lambda / (4.0f * w); + w = sys->vlengths[i]; + sys->vlengths[i] = (w == 0.0f) ? 0.0f : -lambda_border * 2.0f / w; + + if (!vert_is_boundary(v)) { + nlMatrixAdd(i, i, 1.0f + lambda / (4.0f * sys->ring_areas[i])); + } + else { + nlMatrixAdd(i, i, 1.0f + lambda_border * 2.0f); + } + } + else { + nlMatrixAdd(i, i, 1.0f); + } + } + fill_laplacian_matrix(sys); + + nlEnd(NL_MATRIX); + nlEnd(NL_SYSTEM); + + if (nlSolveAdvanced(NULL, NL_TRUE) ) { + validate_solution(sys, usex, usey, usez, volumepreservation); + } + + delete_laplacian_system(sys); +} diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index 4ec3d3471e6..c6726ec6f3e 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -982,7 +982,7 @@ void bmo_subdivide_edges_exec(BMesh *bm, BMOperator *op) * This edge pair could be used by more then one face, * in this case it used to (2.63), split both faces along the same verts * while it could be calculated which face should do the split, - * its ambigious, so in this case we're better off to skip them as exceptional cases + * it's ambiguous, so in this case we're better off to skip them as exceptional cases * and not try to be clever guessing which face to cut up. * * To avoid this case we need to check: diff --git a/source/blender/bmesh/operators/bmo_unsubdivide.c b/source/blender/bmesh/operators/bmo_unsubdivide.c index 64b7151aee5..3d44feac380 100644 --- a/source/blender/bmesh/operators/bmo_unsubdivide.c +++ b/source/blender/bmesh/operators/bmo_unsubdivide.c @@ -24,171 +24,23 @@ * \ingroup bmesh */ -#include "MEM_guardedalloc.h" - #include "BLI_math.h" +#include "BLI_utildefines.h" #include "bmesh.h" #include "intern/bmesh_operators_private.h" /* own include */ - -static int bm_vert_dissolve_fan_test(BMVert *v) -{ - /* check if we should walk over these verts */ - BMIter iter; - BMEdge *e; - - unsigned int tot_edge = 0; - unsigned int tot_edge_boundary = 0; - unsigned int tot_edge_manifold = 0; - unsigned int tot_edge_wire = 0; - - BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { - if (BM_edge_is_boundary(e)) { - tot_edge_boundary++; - } - else if (BM_edge_is_manifold(e)) { - tot_edge_manifold++; - } - else if (BM_edge_is_wire(e)) { - tot_edge_wire++; - } - tot_edge++; - } - - if ((tot_edge == 4) && (tot_edge_boundary == 0) && (tot_edge_manifold == 4)) { - return TRUE; - } - else if ((tot_edge == 3) && (tot_edge_boundary == 0) && (tot_edge_manifold == 3)) { - return TRUE; - } - else if ((tot_edge == 3) && (tot_edge_boundary == 2) && (tot_edge_manifold == 1)) { - return TRUE; - } - else if ((tot_edge == 2) && (tot_edge_wire == 2)) { - return TRUE; - } - return FALSE; -} - -static int bm_vert_dissolve_fan(BMesh *bm, BMVert *v) -{ - /* collapse under 2 conditions. - * - vert connects to 4 manifold edges (and 4 faces). - * - vert connecrs to 1 manifold edge, 2 boundary edges (and 2 faces). - * - * This covers boundary verts of a quad grid and center verts. - * note that surrounding faces dont have to be quads. - */ - - BMIter iter; - BMEdge *e; - - unsigned int tot_loop = 0; - unsigned int tot_edge = 0; - unsigned int tot_edge_boundary = 0; - unsigned int tot_edge_manifold = 0; - unsigned int tot_edge_wire = 0; - - BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { - if (BM_edge_is_boundary(e)) { - tot_edge_boundary++; - } - else if (BM_edge_is_manifold(e)) { - tot_edge_manifold++; - } - else if (BM_edge_is_wire(e)) { - tot_edge_wire++; - } - tot_edge++; - } - - if (tot_edge == 2) { - /* check for 2 wire verts only */ - if (tot_edge_wire == 2) { - return (BM_vert_collapse_edge(bm, v->e, v, TRUE) != NULL); - } - } - else if (tot_edge == 4) { - /* check for 4 faces surrounding */ - if (tot_edge_boundary == 0 && tot_edge_manifold == 4) { - /* good to go! */ - tot_loop = 4; - } - } - else if (tot_edge == 3) { - /* check for 2 faces surrounding at a boundary */ - if (tot_edge_boundary == 2 && tot_edge_manifold == 1) { - /* good to go! */ - tot_loop = 2; - } - else if (tot_edge_boundary == 0 && tot_edge_manifold == 3) { - /* good to go! */ - tot_loop = 3; - } - } - - if (tot_loop) { - BMLoop *f_loop[4]; - unsigned int i; - - /* ensure there are exactly tot_loop loops */ - BLI_assert(BM_iter_at_index(bm, BM_LOOPS_OF_VERT, v, tot_loop) == NULL); - BM_iter_as_array(bm, BM_LOOPS_OF_VERT, v, (void **)f_loop, tot_loop); - - for (i = 0; i < tot_loop; i++) { - BMLoop *l = f_loop[i]; - if (l->f->len > 3) { - BLI_assert(l->prev->v != l->next->v); - BM_face_split(bm, l->f, l->prev->v, l->next->v, NULL, NULL, TRUE); - } - } - - return BM_vert_dissolve(bm, v); - } - - return FALSE; -} - -enum { - VERT_INDEX_DO_COLLAPSE = -1, - VERT_INDEX_INIT = 0, - VERT_INDEX_IGNORE = 1 -}; - -// #define USE_WALKER /* gives uneven results, disable for now */ -// #define USE_ALL_VERTS - /* - BMVert.flag & BM_ELEM_TAG: shows we touched this vert * - BMVert.index == -1: shows we will remove this vert */ void bmo_unsubdivide_exec(BMesh *bm, BMOperator *op) { -#ifdef USE_WALKER -# define ELE_VERT_TAG 1 -#else - BMVert **vert_seek_a = MEM_mallocN(sizeof(BMVert *) * bm->totvert, __func__); - BMVert **vert_seek_b = MEM_mallocN(sizeof(BMVert *) * bm->totvert, __func__); - unsigned vert_seek_a_tot = 0; - unsigned vert_seek_b_tot = 0; -#endif - BMVert *v; BMIter iter; - const unsigned int offset = 0; - const unsigned int nth = 2; - - const int iterations = maxi(1, BMO_slot_int_get(op, "iterations")); - int iter_step; + const int iterations = max_ii(1, BMO_slot_int_get(op, "iterations")); -#ifdef USE_ALL_VERTS - (void)op; - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - BM_elem_flag_enable(v, BM_ELEM_TAG); - } -#else /* USE_ALL_VERTS */ BMOpSlot *vinput = BMO_slot_get(op, "verts"); BMVert **vinput_arr = (BMVert **)vinput->data.p; int v_index; @@ -201,148 +53,7 @@ void bmo_unsubdivide_exec(BMesh *bm, BMOperator *op) v = vinput_arr[v_index]; BM_elem_flag_enable(v, BM_ELEM_TAG); } -#endif /* USE_ALL_VERTS */ - - - for (iter_step = 0; iter_step < iterations; iter_step++) { - int iter_done; - - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_flag_test(v, BM_ELEM_TAG) && bm_vert_dissolve_fan_test(v)) { -#ifdef USE_WALKER - BMO_elem_flag_enable(bm, v, ELE_VERT_TAG); -#endif - BM_elem_index_set(v, VERT_INDEX_INIT); /* set_dirty! */ - } - else { - BM_elem_index_set(v, VERT_INDEX_IGNORE); /* set_dirty! */ - } - } - /* done with selecting tagged verts */ - - - /* main loop, keep tagging until we can't tag any more islands */ - while (TRUE) { -#ifdef USE_WALKER - BMWalker walker; -#else - unsigned int depth = 1; - unsigned int i; -#endif - BMVert *v_first = NULL; - BMVert *v; - - /* we could avoid iterating from the start each time */ - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - if (v->e && (BM_elem_index_get(v) == VERT_INDEX_INIT)) { -#ifdef USE_WALKER - if (BMO_elem_flag_test(bm, v, ELE_VERT_TAG)) -#endif - { - /* check again incase the topology changed */ - if (bm_vert_dissolve_fan_test(v)) { - v_first = v; - } - break; - } - } - } - if (v_first == NULL) { - break; - } - -#ifdef USE_WALKER - /* Walk over selected elements starting at active */ - BMW_init(&walker, bm, BMW_CONNECTED_VERTEX, - ELE_VERT_TAG, BMW_MASK_NOP, BMW_MASK_NOP, - BMW_FLAG_NOP, /* don't use BMW_FLAG_TEST_HIDDEN here since we want to desel all */ - BMW_NIL_LAY); - - BLI_assert(walker.order == BMW_BREADTH_FIRST); - for (v = BMW_begin(&walker, v_first); v != NULL; v = BMW_step(&walker)) { - /* Deselect elements that aren't at "nth" depth from active */ - if (BM_elem_index_get(v) == VERT_INDEX_INIT) { - if ((offset + BMW_current_depth(&walker)) % nth) { - /* tag for removal */ - BM_elem_index_set(v, VERT_INDEX_DO_COLLAPSE); /* set_dirty! */ - } - else { - /* works better to allow these verts to be checked again */ - //BM_elem_index_set(v, VERT_INDEX_IGNORE); /* set_dirty! */ - } - } - } - BMW_end(&walker); -#else - - BM_elem_index_set(v_first, (offset + depth) % nth ? VERT_INDEX_IGNORE : VERT_INDEX_DO_COLLAPSE); /* set_dirty! */ - - vert_seek_b_tot = 0; - vert_seek_b[vert_seek_b_tot++] = v_first; - - while (TRUE) { - BMEdge *e; - - if ((offset + depth) % nth) { - vert_seek_a_tot = 0; - for (i = 0; i < vert_seek_b_tot; i++) { - v = vert_seek_b[i]; - BLI_assert(BM_elem_index_get(v) == VERT_INDEX_IGNORE); - BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { - BMVert *v_other = BM_edge_other_vert(e, v); - if (BM_elem_index_get(v_other) == VERT_INDEX_INIT) { - BM_elem_index_set(v_other, VERT_INDEX_DO_COLLAPSE); /* set_dirty! */ - vert_seek_a[vert_seek_a_tot++] = v_other; - } - } - } - if (vert_seek_a_tot == 0) { - break; - } - } - else { - vert_seek_b_tot = 0; - for (i = 0; i < vert_seek_a_tot; i++) { - v = vert_seek_a[i]; - BLI_assert(BM_elem_index_get(v) == VERT_INDEX_DO_COLLAPSE); - BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) { - BMVert *v_other = BM_edge_other_vert(e, v); - if (BM_elem_index_get(v_other) == VERT_INDEX_INIT) { - BM_elem_index_set(v_other, VERT_INDEX_IGNORE); /* set_dirty! */ - vert_seek_b[vert_seek_b_tot++] = v_other; - } - } - } - if (vert_seek_b_tot == 0) { - break; - } - } - - depth++; - } -#endif /* USE_WALKER */ - - } - - /* now we tagged all verts -1 for removal, lets loop over and rebuild faces */ - iter_done = FALSE; - BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { - if (BM_elem_index_get(v) == VERT_INDEX_DO_COLLAPSE) { - iter_done |= bm_vert_dissolve_fan(bm, v); - } - } - - if (iter_done == FALSE) { - break; - } - } - - bm->elem_index_dirty |= BM_VERT; - -#ifndef USE_WALKER - MEM_freeN(vert_seek_a); - MEM_freeN(vert_seek_b); -#endif + /* do all the real work here */ + BM_mesh_decimate_unsubdivide_ex(bm, iterations, TRUE); } - diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index 3d792205d08..b396da3b8d1 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -1295,7 +1295,7 @@ void bmo_shortest_path_exec(BMesh *bm, BMOperator *op) vert_list[i].hn = BLI_heap_insert(h, vert_list[i].weight, vert_list[i].v); } - while (!BLI_heap_empty(h)) { + while (!BLI_heap_is_empty(h)) { BMEdge *e; BMIter e_i; float v_weight; diff --git a/source/blender/bmesh/tools/BME_bevel.c b/source/blender/bmesh/tools/BME_bevel.c index 98f270abd16..a632a4446ed 100644 --- a/source/blender/bmesh/tools/BME_bevel.c +++ b/source/blender/bmesh/tools/BME_bevel.c @@ -1096,10 +1096,9 @@ static BMesh *BME_bevel_mesh(BMesh *bm, float value, int UNUSED(res), int option return bm; } -BMesh *BME_bevel(BMEditMesh *em, float value, int res, int options, int defgrp_index, float angle, - BME_TransData_Head **rtd, int do_tessface) +BMesh *BME_bevel(BMesh *bm, float value, int res, int options, int defgrp_index, float angle, + BME_TransData_Head **rtd) { - BMesh *bm = em->bm; BMVert *v; BMIter iter; @@ -1126,12 +1125,6 @@ BMesh *BME_bevel(BMEditMesh *em, float value, int res, int options, int defgrp_i BMO_pop(bm); } - /* possibly needed when running as a tool (which is no longer functional) - * but keep as an option for now */ - if (do_tessface) { - BMEdit_RecalcTessellation(em); - } - /* interactive preview? */ if (rtd) { *rtd = td; diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 0e8ead61437..26b5edf7ea6 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -184,7 +184,7 @@ std::string AnimationExporter::getObjectBoneName(Object *ob, const FCurve *fcu) if (boneName != NULL) return /*id_name(ob) + "_" +*/ std::string(boneName); - else + else return id_name(ob); } @@ -265,7 +265,7 @@ void AnimationExporter::dae_animation(Object *ob, FCurve *fcu, char *transformNa MEM_freeN(eul); MEM_freeN(eul_axis); } - else if(!strcmp(transformName, "lens") && (ob->type == OB_CAMERA)) { + else if (!strcmp(transformName, "lens") && (ob->type == OB_CAMERA)) { output_id = create_lens_source_from_fcurve((Camera *) ob->data, COLLADASW::InputSemantic::OUTPUT, fcu, anim_id); } else { @@ -584,8 +584,8 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman values[0] = convert_time(bezt->vec[0][0]); if (bezt->ipo != BEZT_IPO_BEZ) { // We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data - values[0] = 0; - values[1] = 0; + values[0] = 0; + values[1] = 0; } else if (is_rotation) { values[1] = RAD2DEGF(bezt->vec[0][1]); @@ -600,8 +600,8 @@ void AnimationExporter::get_source_values(BezTriple *bezt, COLLADASW::InputSeman values[0] = convert_time(bezt->vec[2][0]); if (bezt->ipo != BEZT_IPO_BEZ) { // We're in a mixed interpolation scenario, set zero as it's irrelevant but value might contain unused data - values[0] = 0; - values[1] = 0; + values[0] = 0; + values[1] = 0; } else if (is_rotation) { values[1] = RAD2DEGF(bezt->vec[2][1]); @@ -634,11 +634,11 @@ std::string AnimationExporter::create_source_from_fcurve(COLLADASW::InputSemanti switch (semantic) { case COLLADASW::InputSemantic::INPUT: case COLLADASW::InputSemantic::OUTPUT: - source.setAccessorStride(1); + source.setAccessorStride(1); break; case COLLADASW::InputSemantic::IN_TANGENT: case COLLADASW::InputSemantic::OUT_TANGENT: - source.setAccessorStride(2); + source.setAccessorStride(2); break; default: break; @@ -1082,13 +1082,13 @@ std::string AnimationExporter::get_transform_sid(char *rna_path, int tm_type, co break; case 6: tm_name = "diffuse"; - break; + break; case 7: tm_name = "transparency"; - break; + break; case 8: tm_name = "index_of_refraction"; - break; + break; default: tm_name = ""; diff --git a/source/blender/collada/AnimationExporter.h b/source/blender/collada/AnimationExporter.h index 7fd39765cc9..665c6999093 100644 --- a/source/blender/collada/AnimationExporter.h +++ b/source/blender/collada/AnimationExporter.h @@ -122,7 +122,7 @@ protected: float convert_angle(float angle); - std::string get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic); + std::string get_semantic_suffix(COLLADASW::InputSemantic::Semantics semantic); void add_source_parameters(COLLADASW::SourceBase::ParameterNameList& param, COLLADASW::InputSemantic::Semantics semantic, bool is_rot, const char *axis, bool transform); diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index b2748a55b6a..374f6385ea7 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -136,7 +136,7 @@ void AnimationImporter::animation_to_fcurves(COLLADAFW::AnimationCurve *curve) bez.ipo = BEZT_IPO_BEZ; else bez.ipo = BEZT_IPO_CONST; - //bez.h1 = bez.h2 = HD_AUTO; + //bez.h1 = bez.h2 = HD_AUTO; } else { bez.h1 = bez.h2 = HD_AUTO; @@ -617,7 +617,7 @@ void AnimationImporter:: Assign_color_animations(const COLLADAFW::UniqueId& list //Add the curves of the current animation to the object for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { FCurve *fcu = *iter; - BLI_addtail(AnimCurves, fcu); + BLI_addtail(AnimCurves, fcu); } } @@ -854,14 +854,13 @@ static const double get_aspect_ratio(const COLLADAFW::Camera *camera) { double aspect = camera->getAspectRatio().getValue(); - if(aspect == 0) - { + if (aspect == 0) { const double yfov = camera->getYFov().getValue(); - if(yfov == 0) - aspect=1; // assume yfov and xfov are equal - else - { + if (yfov == 0) { + aspect = 1; // assume yfov and xfov are equal + } + else { const double xfov = camera->getXFov().getValue(); if (xfov==0) aspect = 1; @@ -885,7 +884,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node, COLLADAFW::Node *root = root_map.find(uid) == root_map.end() ? node : root_map[uid]; Object *ob; - if(is_joint) + if (is_joint) ob = armature_importer->get_armature_for_joint(root); else ob = object_map.find(uid) == object_map.end() ? NULL : object_map.find(uid)->second; @@ -938,7 +937,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node, if (is_matrix) { apply_matrix_curves(ob, animcurves, root, node, transform); } - else { + else { if (is_joint) { @@ -1094,7 +1093,7 @@ void AnimationImporter::translate_Animations(COLLADAFW::Node *node, } } } - } + } } } @@ -1114,8 +1113,8 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob, std::vector<FCurv for (iter = animcurves.begin(); iter != animcurves.end(); iter++) { FCurve *fcu = *iter; - fcurve_deg_to_rad(fcu); - } + fcurve_deg_to_rad(fcu); + } } diff --git a/source/blender/collada/AnimationImporter.h b/source/blender/collada/AnimationImporter.h index db61692484b..293b992f219 100644 --- a/source/blender/collada/AnimationImporter.h +++ b/source/blender/collada/AnimationImporter.h @@ -169,7 +169,7 @@ public: int setAnimType ( const COLLADAFW::Animatable * prop, int type, int addition); - void modify_fcurve(std::vector<FCurve*>* curves, const char* rna_path, int array_index ); + void modify_fcurve(std::vector<FCurve*>* curves, const char *rna_path, int array_index ); void unused_fcurve(std::vector<FCurve*>* curves ); // prerequisites: // animlist_map - map animlist id -> animlist diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index 30e9baccbf1..134fd639a73 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -346,7 +346,7 @@ void ArmatureExporter::export_controller(Object *ob, Object *ob_arm) if (this->export_settings->apply_modifiers) { me = bc_to_mesh_apply_modifiers(scene, ob, this->export_settings->export_mesh_type); - } + } else { me = (Mesh *)ob->data; } diff --git a/source/blender/collada/CMakeLists.txt b/source/blender/collada/CMakeLists.txt index 3b7a38eb950..0091df3c502 100644 --- a/source/blender/collada/CMakeLists.txt +++ b/source/blender/collada/CMakeLists.txt @@ -70,7 +70,7 @@ set(SRC collada_utils.cpp AnimationImporter.h - AnimationExporter.h + AnimationExporter.h ArmatureExporter.h ArmatureImporter.h CameraExporter.h diff --git a/source/blender/collada/DocumentExporter.h b/source/blender/collada/DocumentExporter.h index 05620087d76..84c0610282e 100644 --- a/source/blender/collada/DocumentExporter.h +++ b/source/blender/collada/DocumentExporter.h @@ -40,7 +40,7 @@ class DocumentExporter public: DocumentExporter(const ExportSettings *export_settings); void exportCurrentScene(Scene *sce); - void exportScenes(const char* filename); + void exportScenes(const char *filename); private: const ExportSettings *export_settings; }; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index f37f065b03b..1c4f0974c6d 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -311,7 +311,7 @@ bool DocumentImporter::writeScene(const COLLADAFW::Scene *scene) Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera, Scene *sce) { const COLLADAFW::UniqueId& cam_uid = camera->getInstanciatedObjectId(); - if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) { + if (uid_camera_map.find(cam_uid) == uid_camera_map.end()) { // fprintf(stderr, "Couldn't find camera by UID.\n"); return NULL; } @@ -329,7 +329,7 @@ Object *DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera Object *DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Scene *sce) { const COLLADAFW::UniqueId& lamp_uid = lamp->getInstanciatedObjectId(); - if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) { + if (uid_lamp_map.find(lamp_uid) == uid_lamp_map.end()) { fprintf(stderr, "Couldn't find lamp by UID.\n"); return NULL; } @@ -524,7 +524,7 @@ void DocumentImporter::write_node(COLLADAFW::Node *node, COLLADAFW::Node *parent } // if node has child nodes write them COLLADAFW::NodePointerArray &child_nodes = node->getChildNodes(); - for (unsigned int i = 0; i < child_nodes.getCount(); i++) { + for (unsigned int i = 0; i < child_nodes.getCount(); i++) { write_node(child_nodes[i], node, sce, ob, is_library_node); } } diff --git a/source/blender/collada/EffectExporter.cpp b/source/blender/collada/EffectExporter.cpp index dd59fb9fb91..e4a654dc99a 100644 --- a/source/blender/collada/EffectExporter.cpp +++ b/source/blender/collada/EffectExporter.cpp @@ -255,7 +255,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) if (ep.getShaderType() != COLLADASW::EffectProfile::LAMBERT) { cot = getcol(ma->specr * ma->spec, ma->specg * ma->spec, ma->specb * ma->spec, 1.0f); ep.setSpecular(cot, false, "specular"); - } + } // XXX make this more readable if possible @@ -381,7 +381,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) } std::set<Image *>::iterator uv_t_iter; - for(uv_t_iter = uv_textures.begin(); uv_t_iter != uv_textures.end(); uv_t_iter++ ) { + for (uv_t_iter = uv_textures.begin(); uv_t_iter != uv_textures.end(); uv_t_iter++ ) { Image *ima = *uv_t_iter; std::string key(id_name(ima)); key = translate_id(key); @@ -405,7 +405,7 @@ void EffectsExporter::operator()(Material *ma, Object *ob) ep.closeProfile(); if (twoSided) mSW->appendTextBlock("<extra><technique profile=\"MAX3D\"><double_sided>1</double_sided></technique></extra>"); - closeEffect(); + closeEffect(); } COLLADASW::ColorOrTexture EffectsExporter::createTexture(Image *ima, diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index e2332b7cd55..24ce1ee117d 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -78,7 +78,7 @@ void GeometryExporter::operator()(Object *ob) Mesh *me; if (this->export_settings->apply_modifiers) { me = bc_to_mesh_apply_modifiers(mScene, ob, this->export_settings->export_mesh_type); - } + } else { me = (Mesh *)ob->data; } @@ -364,7 +364,7 @@ void GeometryExporter::createVertsSource(std::string geom_id, Mesh *me) //appends data to <float_array> int i = 0; for (i = 0; i < totverts; i++) { - source.appendValues(verts[i].co[0], verts[i].co[1], verts[i].co[2]); + source.appendValues(verts[i].co[0], verts[i].co[1], verts[i].co[2]); } source.finish(); diff --git a/source/blender/collada/ImageExporter.cpp b/source/blender/collada/ImageExporter.cpp index a15dadda8cf..2e0c0f1ea57 100644 --- a/source/blender/collada/ImageExporter.cpp +++ b/source/blender/collada/ImageExporter.cpp @@ -62,7 +62,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) if (not_yet_exported) { ImBuf *imbuf = BKE_image_get_ibuf(image, NULL); - if(!imbuf) { + if (!imbuf) { fprintf(stderr, "Collada export: image does not exist:\n%s\n", image->name); return; } diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index 47ee35f0268..8337a977b3b 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -478,7 +478,7 @@ void MeshImporter::allocate_face_data(COLLADAFW::Mesh *mesh, Mesh *me, int new_t int total_facecount = 0; // collect edge_count and face_count from all parts - for (int i = 0; i < prim_arr.getCount(); i++) { + for (int i = 0; i < prim_arr.getCount(); i++) { COLLADAFW::MeshPrimitive *mp = prim_arr[i]; int type = mp->getPrimitiveType(); switch (type) { @@ -506,7 +506,7 @@ unsigned int MeshImporter::get_loose_edge_count(COLLADAFW::Mesh *mesh) { int loose_edge_count = 0; // collect edge_count and face_count from all parts - for (int i = 0; i < prim_arr.getCount(); i++) { + for (int i = 0; i < prim_arr.getCount(); i++) { COLLADAFW::MeshPrimitive *mp = prim_arr[i]; int type = mp->getPrimitiveType(); switch (type) { @@ -998,7 +998,7 @@ static bool bc_has_same_material_configuration(Object *ob1, Object *ob2) if (ob1->totcol != ob2->totcol) return false; // not same number of materials if (ob1->totcol == 0) return false; // no material at all - for(int index=0; index < ob1->totcol; index++) { + for (int index=0; index < ob1->totcol; index++) { if (ob1->matbits[index] != ob2->matbits[index]) return false; // shouldn't happen if (ob1->matbits[index] == 0) return false; // shouldn't happen if (ob1->mat[index] != ob2->mat[index]) return false; // different material assignment diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index 9932ed17378..b3e76a287ea 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -1,4 +1,3 @@ -# $Id: CMakeLists.txt 14444 2008-04-16 22:40:48Z hos $ # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or @@ -272,6 +271,11 @@ set(SRC operations/COM_NormalizeOperation.cpp operations/COM_NormalizeOperation.h + nodes/COM_PixelateNode.cpp + nodes/COM_PixelateNode.h + operations/COM_PixelateOperation.cpp + operations/COM_PixelateOperation.h + # Filter nodes nodes/COM_BilateralBlurNode.cpp nodes/COM_BilateralBlurNode.h @@ -650,6 +654,6 @@ list(APPEND INC ${CMAKE_CURRENT_BINARY_DIR}/operations ) data_to_c(${CMAKE_CURRENT_SOURCE_DIR}/operations/COM_OpenCLKernels.cl - ${CMAKE_CURRENT_BINARY_DIR}/operations/COM_OpenCLKernels.cl.h SRC) + ${CMAKE_CURRENT_BINARY_DIR}/operations/COM_OpenCLKernels.cl.h SRC) blender_add_lib(bf_compositor "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index 71067ac8f15..2b09c9d5b8c 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -119,6 +119,7 @@ #include "COM_ViewLevelsNode.h" #include "COM_ViewerNode.h" #include "COM_ZCombineNode.h" +#include "COM_PixelateNode.h" Node *Converter::convert(bNode *b_node, bool fast) { @@ -390,6 +391,9 @@ Node *Converter::convert(bNode *b_node, bool fast) node = new TrackPositionNode(b_node); break; /* not inplemented yet */ + case CMP_NODE_PIXELATE: + node = new PixelateNode(b_node); + break; default: node = new MuteNode(b_node); break; diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cpp b/source/blender/compositor/intern/COM_ExecutionGroup.cpp index 5c891705089..0553aebbba6 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cpp +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cpp @@ -204,7 +204,7 @@ void ExecutionGroup::determineNumberOfChunks() this->m_numberOfXChunks = 1; this->m_numberOfYChunks = 1; this->m_numberOfChunks = 1; - } + } else { const float chunkSizef = this->m_chunkSize; this->m_numberOfXChunks = ceil(this->m_width / chunkSizef); @@ -475,10 +475,10 @@ bool ExecutionGroup::scheduleAreaWhenPossible(ExecutionSystem *graph, rcti *area int maxxchunk = ceil((area->xmax - 1) / chunkSizef); int minychunk = floor(area->ymin / chunkSizef); int maxychunk = ceil((area->ymax - 1) / chunkSizef); - minxchunk = MAX2(minxchunk, 0); - minychunk = MAX2(minychunk, 0); - maxxchunk = MIN2(maxxchunk, this->m_numberOfXChunks); - maxychunk = MIN2(maxychunk, this->m_numberOfYChunks); + minxchunk = max(minxchunk, 0); + minychunk = max(minychunk, 0); + maxxchunk = min(maxxchunk, (int)this->m_numberOfXChunks); + maxychunk = min(maxychunk, (int)this->m_numberOfYChunks); bool result = true; for (indexx = minxchunk; indexx < maxxchunk; indexx++) { diff --git a/source/blender/compositor/intern/COM_InputSocket.h b/source/blender/compositor/intern/COM_InputSocket.h index 259479015aa..5970c9d5dd6 100644 --- a/source/blender/compositor/intern/COM_InputSocket.h +++ b/source/blender/compositor/intern/COM_InputSocket.h @@ -87,17 +87,11 @@ public: /** * @brief determine the resolution of this data going through this socket * @param resolution the result of this operation - * @param preferredResolution the preferrable resolution as no resolution could be determined + * @param preferredResolution the preferable resolution as no resolution could be determined */ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); /** - * @brief Notifies the Input of the data type (via a SocketConnection) - * @param datatype the datatype to evaluate - */ - void notifyActualInputType(DataType datatype); - - /** * @brief move all connections of this input socket to another socket * only use this method when already checked the availability of a SocketConnection * @param relinkToSocket the socket to move to connections to diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp index 4ae114bd031..a05c37e1b09 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cpp +++ b/source/blender/compositor/intern/COM_NodeOperation.cpp @@ -126,7 +126,7 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper else { rcti tempOutput; bool first = true; - for (int i = 0 ; i < getNumberOfInputSockets() ; i ++) { + for (int i = 0; i < getNumberOfInputSockets(); i ++) { NodeOperation * inputOperation = this->getInputOperation(i); if (inputOperation && inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) { if (first) { @@ -137,10 +137,10 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper first = false; } else { - output->xmin = MIN2(output->xmin, tempOutput.xmin); - output->ymin = MIN2(output->ymin, tempOutput.ymin); - output->xmax = MAX2(output->xmax, tempOutput.xmax); - output->ymax = MAX2(output->ymax, tempOutput.ymax); + output->xmin = min(output->xmin, tempOutput.xmin); + output->ymin = min(output->ymin, tempOutput.ymin); + output->xmax = max(output->xmax, tempOutput.xmax); + output->ymax = max(output->ymax, tempOutput.ymax); } } } diff --git a/source/blender/compositor/intern/COM_NodeOperation.h b/source/blender/compositor/intern/COM_NodeOperation.h index dfa22a29e41..9964c27bd46 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.h +++ b/source/blender/compositor/intern/COM_NodeOperation.h @@ -94,7 +94,7 @@ public: * @brief determine the resolution of this node * @note this method will not set the resolution, this is the responsibility of the caller * @param resolution the result of this operation - * @param preferredResolution the preferrable resolution as no resolution could be determined + * @param preferredResolution the preferable resolution as no resolution could be determined */ virtual void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); diff --git a/source/blender/compositor/intern/COM_OutputSocket.h b/source/blender/compositor/intern/COM_OutputSocket.h index c6b7993c561..63f24451b84 100644 --- a/source/blender/compositor/intern/COM_OutputSocket.h +++ b/source/blender/compositor/intern/COM_OutputSocket.h @@ -57,7 +57,7 @@ public: /** * @brief determine the resolution of this socket * @param resolution the result of this operation - * @param preferredResolution the preferrable resolution as no resolution could be determined + * @param preferredResolution the preferable resolution as no resolution could be determined */ void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); diff --git a/source/blender/compositor/intern/COM_WorkScheduler.cpp b/source/blender/compositor/intern/COM_WorkScheduler.cpp index eb9c26d4f43..e9767c41230 100644 --- a/source/blender/compositor/intern/COM_WorkScheduler.cpp +++ b/source/blender/compositor/intern/COM_WorkScheduler.cpp @@ -332,10 +332,10 @@ void WorkScheduler::initialize(bool use_opencl) const char *cl_str[2] = {datatoc_COM_OpenCLKernels_cl, NULL}; g_program = clCreateProgramWithSource(g_context, 1, cl_str, 0, &error); error = clBuildProgram(g_program, numberOfDevices, cldevices, 0, 0, 0); - if (error != CL_SUCCESS) { + if (error != CL_SUCCESS) { cl_int error2; size_t ret_val_size = 0; - printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); + printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); error2 = clGetProgramBuildInfo(g_program, cldevices[0], CL_PROGRAM_BUILD_LOG, 0, NULL, &ret_val_size); if (error2 != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } char *build_log = (char *)MEM_mallocN(sizeof(char) * ret_val_size + 1, __func__); diff --git a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp index 70aeee8fc27..254dfb7b9c7 100644 --- a/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp +++ b/source/blender/compositor/nodes/COM_ConvertAlphaNode.cpp @@ -35,7 +35,7 @@ void ConvertAlphaNode::convertToOperations(ExecutionSystem *graph, CompositorCon } else { operation = new ConvertKeyToPremulOperation(); - } + } this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph); this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket()); diff --git a/source/blender/compositor/nodes/COM_CropNode.cpp b/source/blender/compositor/nodes/COM_CropNode.cpp index b80a3e088f2..f09bb7e1c26 100644 --- a/source/blender/compositor/nodes/COM_CropNode.cpp +++ b/source/blender/compositor/nodes/COM_CropNode.cpp @@ -40,7 +40,7 @@ void CropNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co operation = new CropImageOperation(); } else { - operation = new CropOperation(); + operation = new CropOperation(); } operation->setCropSettings(cropSettings); operation->setRelative(relative); diff --git a/source/blender/compositor/nodes/COM_MuteNode.cpp b/source/blender/compositor/nodes/COM_MuteNode.cpp index 1821844c6f5..4502dcf469c 100644 --- a/source/blender/compositor/nodes/COM_MuteNode.cpp +++ b/source/blender/compositor/nodes/COM_MuteNode.cpp @@ -108,27 +108,16 @@ void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co /* mute node is also used for unknown nodes and couple of nodes in fast mode * can't use generic routines in that case */ - if ((editorNode->flag & NODE_MUTED) && editorNode->typeinfo->internal_connect) { + if (editorNode->flag & NODE_MUTED) { vector<InputSocket *> &inputsockets = this->getInputSockets(); vector<OutputSocket *> relinkedsockets; - bNodeTree *editorTree; SocketMap socketMap; - ListBase intlinks; bNodeLink *link; - if (this->getbNodeGroup()) { - editorTree = (bNodeTree *) getbNodeGroup()->id; - } - else { - editorTree = (bNodeTree *) context->getbNodeTree(); - } - - intlinks = editorNode->typeinfo->internal_connect(editorTree, editorNode); - this->fillSocketMap<OutputSocket>(outputsockets, socketMap); this->fillSocketMap<InputSocket>(inputsockets, socketMap); - for (link = (bNodeLink *) intlinks.first; link; link = link->next) { + for (link = (bNodeLink *) editorNode->internal_links.first; link; link = link->next) { if (link->fromnode == editorNode) { InputSocket *fromSocket = (InputSocket *) socketMap.find(link->fromsock)->second; OutputSocket *toSocket = (OutputSocket *) socketMap.find(link->tosock)->second; @@ -170,8 +159,6 @@ void MuteNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co createDefaultOutput(graph, output); } } - - BLI_freelistN(&intlinks); } else { for (unsigned int index = 0; index < outputsockets.size(); index++) { diff --git a/source/blender/compositor/nodes/COM_PixelateNode.cpp b/source/blender/compositor/nodes/COM_PixelateNode.cpp new file mode 100644 index 00000000000..f1c7c616a30 --- /dev/null +++ b/source/blender/compositor/nodes/COM_PixelateNode.cpp @@ -0,0 +1,48 @@ +/* + * Copyright 2011, Blender Foundation. + * + * 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. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_PixelateNode.h" + +#include "COM_PixelateOperation.h" +#include "COM_ExecutionSystem.h" + +PixelateNode::PixelateNode(bNode *editorNode) : Node(editorNode) +{ + /* pass */ +} + +void PixelateNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context) +{ + InputSocket *inputSocket = this->getInputSocket(0); + OutputSocket *outputSocket = this->getOutputSocket(0); + DataType datatype = inputSocket->getDataType(); + if (inputSocket->isConnected()) { + SocketConnection * connection = inputSocket->getConnection(); + OutputSocket* otherOutputSocket = connection->getFromSocket(); + datatype = otherOutputSocket->getDataType(); + } + + PixelateOperation *operation = new PixelateOperation(datatype); + inputSocket->relinkConnections(operation->getInputSocket(0), 0, graph); + outputSocket->relinkConnections(operation->getOutputSocket(0)); + graph->addOperation(operation); +} diff --git a/source/blender/compositor/nodes/COM_PixelateNode.h b/source/blender/compositor/nodes/COM_PixelateNode.h new file mode 100644 index 00000000000..c142d2d7a5b --- /dev/null +++ b/source/blender/compositor/nodes/COM_PixelateNode.h @@ -0,0 +1,38 @@ +/* + * Copyright 2011, Blender Foundation. + * + * 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. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_PixelateNode_h_ +#define _COM_PixelateNode_h_ + +#include "COM_Node.h" + +/** + * @brief PixelateNode + * @ingroup Node + */ +class PixelateNode : public Node { +public: + PixelateNode(bNode *editorNode); + void convertToOperations(ExecutionSystem *graph, CompositorContext *context); +}; + +#endif diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp index 152b10709fb..a8e8cb98564 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.cpp @@ -100,7 +100,7 @@ void ColorSpillOperation::executePixel(float output[4], float x, float y, PixelS } else { copy_v4_v4(output, input); - } + } } float ColorSpillOperation::calculateMapValue(float fac, float *input) { diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp index f6b23f6afd2..f39a28b87a8 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp @@ -65,7 +65,7 @@ void ConvertDepthToRadiusOperation::initExecution() this->m_aspect = (this->getWidth() > this->getHeight()) ? (this->getHeight() / (float)this->getWidth()) : (this->getWidth() / (float)this->getHeight()); this->m_aperture = 0.5f * (this->m_cam_lens / (this->m_aspect * cam_sensor)) / this->m_fStop; const float minsz = min(getWidth(), getHeight()); - this->m_dof_sp = minsz / ((cam_sensor / 2.0f) / this->m_cam_lens); // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov); + this->m_dof_sp = minsz / ((cam_sensor / 2.0f) / this->m_cam_lens); // <- == aspect * min(img->x, img->y) / tan(0.5f * fov); if (this->m_blurPostOperation) { m_blurPostOperation->setSigma(min(m_aperture * 128.0f, this->m_maxRadius)); diff --git a/source/blender/compositor/operations/COM_CropOperation.cpp b/source/blender/compositor/operations/COM_CropOperation.cpp index c33bd2544ac..16c19f3ebaa 100644 --- a/source/blender/compositor/operations/COM_CropOperation.cpp +++ b/source/blender/compositor/operations/COM_CropOperation.cpp @@ -36,25 +36,28 @@ void CropBaseOperation::updateArea() SocketReader *inputReference = this->getInputSocketReader(0); float width = inputReference->getWidth(); float height = inputReference->getHeight(); - if (this->m_relative) { - this->m_settings->x1 = width * this->m_settings->fac_x1; - this->m_settings->x2 = width * this->m_settings->fac_x2; - this->m_settings->y1 = height * this->m_settings->fac_y1; - this->m_settings->y2 = height * this->m_settings->fac_y2; - } - if (width <= this->m_settings->x1 + 1) - this->m_settings->x1 = width - 1; - if (height <= this->m_settings->y1 + 1) - this->m_settings->y1 = height - 1; - if (width <= this->m_settings->x2 + 1) - this->m_settings->x2 = width - 1; - if (height <= this->m_settings->y2 + 1) - this->m_settings->y2 = height - 1; - this->m_xmax = MAX2(this->m_settings->x1, this->m_settings->x2) + 1; - this->m_xmin = MIN2(this->m_settings->x1, this->m_settings->x2); - this->m_ymax = MAX2(this->m_settings->y1, this->m_settings->y2) + 1; - this->m_ymin = MIN2(this->m_settings->y1, this->m_settings->y2); + if (width > 0.0f && height > 0.0f) { + if (this->m_relative) { + this->m_settings->x1 = width * this->m_settings->fac_x1; + this->m_settings->x2 = width * this->m_settings->fac_x2; + this->m_settings->y1 = height * this->m_settings->fac_y1; + this->m_settings->y2 = height * this->m_settings->fac_y2; + } + if (width <= this->m_settings->x1 + 1) + this->m_settings->x1 = width - 1; + if (height <= this->m_settings->y1 + 1) + this->m_settings->y1 = height - 1; + if (width <= this->m_settings->x2 + 1) + this->m_settings->x2 = width - 1; + if (height <= this->m_settings->y2 + 1) + this->m_settings->y2 = height - 1; + + this->m_xmax = max(this->m_settings->x1, this->m_settings->x2) + 1; + this->m_xmin = min(this->m_settings->x1, this->m_settings->x2); + this->m_ymax = max(this->m_settings->y1, this->m_settings->y2) + 1; + this->m_ymin = min(this->m_settings->y1, this->m_settings->y2); + } } void CropBaseOperation::initExecution() @@ -110,5 +113,10 @@ void CropImageOperation::determineResolution(unsigned int resolution[2], unsigne void CropImageOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) { - this->m_inputOperation->read(output, (x + this->m_xmin), (y + this->m_ymin), sampler); + if (x >= 0 && x < getWidth() && y >= 0 && y < getHeight()) { + this->m_inputOperation->read(output, (x + this->m_xmin), (y + this->m_ymin), sampler); + } + else { + zero_v4(output); + } } diff --git a/source/blender/compositor/operations/COM_CropOperation.h b/source/blender/compositor/operations/COM_CropOperation.h index ddc7f855bf1..d2f2b15aa36 100644 --- a/source/blender/compositor/operations/COM_CropOperation.h +++ b/source/blender/compositor/operations/COM_CropOperation.h @@ -37,7 +37,7 @@ protected: void updateArea(); public: - CropBaseOperation(); + CropBaseOperation(); void initExecution(); void deinitExecution(); void setCropSettings(NodeTwoXYs *settings) { this->m_settings = settings; } diff --git a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp index 9c09c9bf034..f0fffa770f8 100644 --- a/source/blender/compositor/operations/COM_DilateErodeOperation.cpp +++ b/source/blender/compositor/operations/COM_DilateErodeOperation.cpp @@ -344,28 +344,28 @@ void *DilateStepOperation::initializeTileData(rcti *rect) for (y = 0; y < bheight; y++) { for (x = 0; x < bwidth - 1; x++) { p = rectf + (bwidth * y + x); - *p = MAX2(*p, *(p + 1)); + *p = max(*p, *(p + 1)); } } for (y = 0; y < bheight; y++) { for (x = bwidth - 1; x >= 1; x--) { p = rectf + (bwidth * y + x); - *p = MAX2(*p, *(p - 1)); + *p = max(*p, *(p - 1)); } } for (x = 0; x < bwidth; x++) { for (y = 0; y < bheight - 1; y++) { p = rectf + (bwidth * y + x); - *p = MAX2(*p, *(p + bwidth)); + *p = max(*p, *(p + bwidth)); } } for (x = 0; x < bwidth; x++) { for (y = bheight - 1; y >= 1; y--) { p = rectf + (bwidth * y + x); - *p = MAX2(*p, *(p - bwidth)); + *p = max(*p, *(p - bwidth)); } } } diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp index 31608c88274..1723da11f21 100644 --- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp @@ -92,8 +92,8 @@ void DisplaceOperation::executePixel(float output[4], int x, int y, void *data) dxt = p_dx - d_dx; dyt = p_dy - d_dy; - dxt = signf(dxt) * maxf(fabsf(dxt), DISPLACE_EPSILON) / this->getWidth(); - dyt = signf(dyt) * maxf(fabsf(dyt), DISPLACE_EPSILON) / this->getHeight(); + dxt = signf(dxt) * max_ff(fabsf(dxt), DISPLACE_EPSILON) / this->getWidth(); + dyt = signf(dyt) * max_ff(fabsf(dyt), DISPLACE_EPSILON) / this->getHeight(); /* EWA filtering (without nearest it gets blurry with NO distortion) */ this->m_inputColorProgram->read(output, u, v, dxt, dyt, COM_PS_NEAREST); diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index 262252f7d8c..4bdb2591cb7 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -190,7 +190,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src, float sigma, unsign } (void)0 // intermediate buffers - sz = MAX2(src_width, src_height); + sz = max(src_width, src_height); X = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss X buf"); Y = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss Y buf"); W = (double *)MEM_callocN(sz * sizeof(double), "IIR_gauss W buf"); diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp index a9bcb2dd752..44bce6308e8 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp @@ -257,7 +257,7 @@ void GaussianBlurReferenceOperation::initExecution() void GaussianBlurReferenceOperation::updateGauss() { int i; - int x = MAX2(m_radx, m_rady); + int x = max(m_radx, m_rady); this->m_maintabs = (float **)MEM_mallocN(x * sizeof(float *), "gauss array"); for (i = 0; i < x; i++) { m_maintabs[i] = make_gausstab(i + 1); @@ -327,11 +327,11 @@ void GaussianBlurReferenceOperation::executePixel(float output[4], int x, int y, void GaussianBlurReferenceOperation::deinitExecution() { int x, i; - x = MAX2(m_radx, m_rady); + x = max(this->m_radx, this->m_rady); for (i = 0; i < x; i++) { - MEM_freeN(m_maintabs[i]); + MEM_freeN(this->m_maintabs[i]); } - MEM_freeN(m_maintabs); + MEM_freeN(this->m_maintabs); BlurBaseOperation::deinitExecution(); } diff --git a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp index 7ab00b202e1..02627bae5ed 100644 --- a/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianYBlurOperation.cpp @@ -95,7 +95,7 @@ void GaussianYBlurOperation::executePixel(float output[4], int x, int y, void *d int index; int step = getStep(); - const int bufferIndexx = ((minx - bufferstartx) * 4) ; + const int bufferIndexx = ((minx - bufferstartx) * 4); for (int ny = miny; ny < maxy; ny += step) { index = (ny - y) + this->m_rad; int bufferindex = bufferIndexx + ((ny - bufferstarty) * 4 * bufferwidth); diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp index 70d4d987c81..81ca06cfff0 100644 --- a/source/blender/compositor/operations/COM_InpaintOperation.cpp +++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp @@ -133,9 +133,9 @@ void InpaintSimpleOperation::calc_manhatten_distance() if (this->get_pixel(i, j)[3] < 1.0f) { r = width + height; if (i > 0) - r = mini(r, m[j * width + i - 1] + 1); + r = min_ii(r, m[j * width + i - 1] + 1); if (j > 0) - r = mini(r, m[(j - 1) * width + i] + 1); + r = min_ii(r, m[(j - 1) * width + i] + 1); } m[j * width + i] = r; } @@ -146,9 +146,9 @@ void InpaintSimpleOperation::calc_manhatten_distance() int r = m[j * width + i]; if (i + 1 < width) - r = mini(r, m[j * width + i + 1] + 1); + r = min_ii(r, m[j * width + i + 1] + 1); if (j + 1 < height) - r = mini(r, m[(j + 1) * width + i] + 1); + r = min_ii(r, m[(j + 1) * width + i] + 1); m[j * width + i] = r; diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp index 4426666f100..01f5c032730 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp @@ -28,18 +28,6 @@ #include "BLI_listbase.h" #include "BLI_math.h" -static int get_pixel_primary_channel(float *pixel) -{ - float max_value = MAX3(pixel[0], pixel[1], pixel[2]); - - if (max_value == pixel[0]) - return 0; - else if (max_value == pixel[1]) - return 1; - - return 2; -} - KeyingDespillOperation::KeyingDespillOperation() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); @@ -73,12 +61,12 @@ void KeyingDespillOperation::executePixel(float output[4], float x, float y, Pix this->m_pixelReader->read(pixelColor, x, y, sampler); this->m_screenReader->read(screenColor, x, y, sampler); - int screen_primary_channel = get_pixel_primary_channel(screenColor); - int other_1 = (screen_primary_channel + 1) % 3; - int other_2 = (screen_primary_channel + 2) % 3; + const int screen_primary_channel = max_axis_v3(screenColor); + const int other_1 = (screen_primary_channel + 1) % 3; + const int other_2 = (screen_primary_channel + 2) % 3; - int min_channel = MIN2(other_1, other_2); - int max_channel = MAX2(other_1, other_2); + const int min_channel = min(other_1, other_2); + const int max_channel = max(other_1, other_2); float average_value, amount; @@ -87,7 +75,8 @@ void KeyingDespillOperation::executePixel(float output[4], float x, float y, Pix copy_v4_v4(output, pixelColor); - if (this->m_despillFactor * amount > 0) { - output[screen_primary_channel] = pixelColor[screen_primary_channel] - this->m_despillFactor * amount; + const float amount_despill = this->m_despillFactor * amount; + if (amount_despill > 0.0f) { + output[screen_primary_channel] = pixelColor[screen_primary_channel] - amount_despill; } } diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp index 35138cf0b92..baeacb56744 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.cpp +++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp @@ -28,27 +28,15 @@ #include "BLI_listbase.h" #include "BLI_math.h" -static int get_pixel_primary_channel(float pixelColor[4]) +static float get_pixel_saturation(const float pixelColor[4], float screen_balance, int primary_channel) { - float max_value = MAX3(pixelColor[0], pixelColor[1], pixelColor[2]); + const int other_1 = (primary_channel + 1) % 3; + const int other_2 = (primary_channel + 2) % 3; - if (max_value == pixelColor[0]) - return 0; - else if (max_value == pixelColor[1]) - return 1; + const int min_channel = min(other_1, other_2); + const int max_channel = max(other_1, other_2); - return 2; -} - -static float get_pixel_saturation(float pixelColor[4], float screen_balance, int primary_channel) -{ - int other_1 = (primary_channel + 1) % 3; - int other_2 = (primary_channel + 2) % 3; - - int min_channel = MIN2(other_1, other_2); - int max_channel = MAX2(other_1, other_2); - - float val = screen_balance * pixelColor[min_channel] + (1.0f - screen_balance) * pixelColor[max_channel]; + const float val = screen_balance * pixelColor[min_channel] + (1.0f - screen_balance) * pixelColor[max_channel]; return (pixelColor[primary_channel] - val) * fabsf(1.0f - val); } @@ -85,13 +73,13 @@ void KeyingOperation::executePixel(float output[4], float x, float y, PixelSampl this->m_pixelReader->read(pixelColor, x, y, sampler); this->m_screenReader->read(screenColor, x, y, sampler); - int primary_channel = get_pixel_primary_channel(screenColor); + const int primary_channel = max_axis_v3(screenColor); if (pixelColor[primary_channel] > 1.0f) { /* overexposure doesn't happen on screen itself and usually happens * on light sources in the shot, this need to be checked separately * because saturation and falloff calculation is based on the fact - * that pixels are not overexposured + * that pixels are not overexposed */ output[0] = 1.0f; } diff --git a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp index a3e00e9325b..0af5ec2d06c 100644 --- a/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieDistortionOperation.cpp @@ -111,7 +111,7 @@ void MovieDistortionOperation::executePixel(float output[4], float x, float y, P float u, v; this->m_cache->getUV(&this->m_movieClip->tracking, x, y, &u, &v); this->m_inputOperation->read(output, u, v, sampler); - } + } else { this->m_inputOperation->read(output, x, y, sampler); } diff --git a/source/blender/compositor/operations/COM_OpenCLKernels.cl b/source/blender/compositor/operations/COM_OpenCLKernels.cl index 4d366a864c4..36205bb94cc 100644 --- a/source/blender/compositor/operations/COM_OpenCLKernels.cl +++ b/source/blender/compositor/operations/COM_OpenCLKernels.cl @@ -33,7 +33,7 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima __read_only image2d_t bokehImage, __write_only image2d_t output, int2 offsetInput, int2 offsetOutput, int radius, int step, int2 dimension, int2 offset) { - int2 coords = {get_global_id(0), get_global_id(1)}; + int2 coords = {get_global_id(0), get_global_id(1)}; coords += offset; float tempBoundingBox; float4 color = {0.0f,0.0f,0.0f,0.0f}; @@ -54,10 +54,10 @@ __kernel void bokehBlurKernel(__read_only image2d_t boundingBox, __read_only ima float2 uv; int2 inputXy; - for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny +=step, inputXy.y+=step) { + for (ny = minXY.y, inputXy.y = ny - offsetInput.y ; ny < maxXY.y ; ny += step, inputXy.y += step) { uv.y = ((realCoordinate.y-ny)/radius2)*bokehImageDim.y+bokehImageCenter.y; - for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx +=step, inputXy.x+=step) { + for (nx = minXY.x, inputXy.x = nx - offsetInput.x; nx < maxXY.x ; nx += step, inputXy.x += step) { uv.x = ((realCoordinate.x-nx)/radius2)*bokehImageDim.x+bokehImageCenter.x; bokeh = read_imagef(bokehImage, SAMPLER_NEAREST, uv); color += bokeh * read_imagef(inputImage, SAMPLER_NEAREST, inputXy); @@ -124,7 +124,7 @@ __kernel void defocusKernel(__read_only image2d_t inputImage, __read_only image2 } } } - } + } } color = color_accum * (1.0f / multiplier_accum); @@ -148,7 +148,7 @@ __kernel void dilateKernel(__read_only image2d_t inputImage, __write_only image int2 offsetInput, int2 offsetOutput, int scope, int distanceSquared, int2 dimension, int2 offset) { - int2 coords = {get_global_id(0), get_global_id(1)}; + int2 coords = {get_global_id(0), get_global_id(1)}; coords += offset; const int2 realCoordinate = coords + offsetOutput; @@ -179,7 +179,7 @@ __kernel void erodeKernel(__read_only image2d_t inputImage, __write_only image2 int2 offsetInput, int2 offsetOutput, int scope, int distanceSquared, int2 dimension, int2 offset) { - int2 coords = {get_global_id(0), get_global_id(1)}; + int2 coords = {get_global_id(0), get_global_id(1)}; coords += offset; const int2 realCoordinate = coords + offsetOutput; @@ -210,7 +210,7 @@ __kernel void directionalBlurKernel(__read_only image2d_t inputImage, __write_o int2 offsetOutput, int iterations, float scale, float rotation, float2 translate, float2 center, int2 offset) { - int2 coords = {get_global_id(0), get_global_id(1)}; + int2 coords = {get_global_id(0), get_global_id(1)}; coords += offset; const int2 realCoordinate = coords + offsetOutput; diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp index b3c2df7230f..1bc262a4d27 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp @@ -149,7 +149,7 @@ void OutputSingleLayerOperation::deinitExecution() else printf("Saved: %s\n", filename); - IMB_freeImBuf(ibuf); + IMB_freeImBuf(ibuf); } this->m_outputBuffer = NULL; this->m_imageInput = NULL; diff --git a/source/blender/compositor/operations/COM_PixelateOperation.cpp b/source/blender/compositor/operations/COM_PixelateOperation.cpp new file mode 100644 index 00000000000..89e7f0093a1 --- /dev/null +++ b/source/blender/compositor/operations/COM_PixelateOperation.cpp @@ -0,0 +1,49 @@ +/* + * Copyright 2011, Blender Foundation. + * + * 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. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#include "COM_PixelateOperation.h" + +PixelateOperation::PixelateOperation(DataType datatype) : NodeOperation() +{ + this->addInputSocket(datatype); + this->addOutputSocket(datatype); + this->setResolutionInputSocketIndex(0); + this->m_inputOperation = NULL; +} + +void PixelateOperation::initExecution() +{ + this->m_inputOperation = this->getInputSocketReader(0); +} + +void PixelateOperation::deinitExecution() +{ + this->m_inputOperation = NULL; +} + +void PixelateOperation::executePixel(float output[4], float x, float y, PixelSampler sampler) +{ + float nx = round(x); + float ny = round(y); + this->m_inputOperation->read(output, nx, ny, sampler); +} + diff --git a/source/blender/compositor/operations/COM_PixelateOperation.h b/source/blender/compositor/operations/COM_PixelateOperation.h new file mode 100644 index 00000000000..b16b21b2ec1 --- /dev/null +++ b/source/blender/compositor/operations/COM_PixelateOperation.h @@ -0,0 +1,68 @@ +/* + * Copyright 2011, Blender Foundation. + * + * 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. + * + * Contributor: + * Jeroen Bakker + * Monique Dewanchand + */ + +#ifndef _COM_PixelateOperation_h_ +#define _COM_PixelateOperation_h_ + +#include "COM_NodeOperation.h" + +/** + * @brief Pixelate operation + * + * The Tile compositor is by default sub-pixel accurate. + * For some setups you don want this. + * This operation will remove the sub-pixel accuracy + */ +class PixelateOperation : public NodeOperation { +private: + /** + * @brief cached refeerence to the input operation + */ + SocketReader *m_inputOperation; +public: + /** + * @brief PixelateOperation + * @param dataType the datatype to create this operator for (saves datatype conversions) + */ + PixelateOperation(DataType dataType); + + /** + * @brief initialization of the execution + */ + void initExecution(); + + /** + * @brief de-initialization of the execution + */ + void deinitExecution(); + + /** + * @brief executePixel + * @param output result + * @param x x-coordinate + * @param y y-coordinate + * @param sampler sampler + */ + void executePixel(float output[4], float x, float y, PixelSampler sampler); +}; + +#endif diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp index d92fe04eb15..00e35f2c9d8 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp @@ -104,7 +104,7 @@ void ProjectorLensDistortionOperation::updateDispersion() float result[4]; this->getInputSocketReader(1)->read(result, 1, 1, COM_PS_NEAREST); this->m_dispersion = result[0]; - this->m_kr = 0.25f * maxf(minf(this->m_dispersion, 1.0f), 0.0f); + this->m_kr = 0.25f * max_ff(min_ff(this->m_dispersion, 1.0f), 0.0f); this->m_kr2 = this->m_kr * 20; this->m_dispersionAvailable = true; } diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index fd9cc1fddcb..d2c6c833e2e 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -226,7 +226,7 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input UPDATE_INPUT; determineUV(coords, input->xmax, input->ymin); UPDATE_INPUT; - } + } else { determineUV(coords, input->xmin, input->ymin, 1.0f, 1.0f); newInput.xmin = coords[0]; @@ -268,11 +268,11 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input void ScreenLensDistortionOperation::updateVariables(float distortion, float dispersion) { - this->m_kg = maxf(minf(distortion, 1.0f), -0.999f); + this->m_kg = max_ff(min_ff(distortion, 1.0f), -0.999f); // smaller dispersion range for somewhat more control - const float d = 0.25f * maxf(minf(dispersion, 1.0f), 0.0f); - this->m_kr = maxf(minf((this->m_kg + d), 1.0f), -0.999f); - this->m_kb = maxf(minf((this->m_kg - d), 1.0f), -0.999f); + const float d = 0.25f * max_ff(min_ff(dispersion, 1.0f), 0.0f); + this->m_kr = max_ff(min_ff((this->m_kg + d), 1.0f), -0.999f); + this->m_kb = max_ff(min_ff((this->m_kg - d), 1.0f), -0.999f); this->m_maxk = MAX3(this->m_kr, this->m_kg, this->m_kb); this->m_sc = (this->m_data->fit && (this->m_maxk > 0.0f)) ? (1.0f / (1.0f + 2.0f * this->m_maxk)) : (1.0f / (1.0f + this->m_maxk)); diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index b8e15934c30..52a9e2a4d8c 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -198,7 +198,7 @@ void VariableSizeBokehBlurOperation::executeOpenCL(OpenCLDevice *device, cl_float scalar = this->m_do_size_scale ? (max_dim / 100.0f) : 1.0f; maxBlur = (cl_int)sizeMemoryBuffer->getMaximumValue() * scalar; - maxBlur = MIN2(maxBlur, this->m_maxBlur); + maxBlur = min(maxBlur, this->m_maxBlur); device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 0, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputProgram); device->COM_clAttachMemoryBufferToKernelParameter(defocusKernel, 1, -1, clMemToCleanUp, inputMemoryBuffers, this->m_inputBokehProgram); diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index 576d5da4d74..d1ac7d74ead 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -96,7 +96,7 @@ void ViewerOperation::executeRegion(rcti *rect, unsigned int tileNumber) if (m_depthInput) { this->m_depthInput->read(depth, x, y, COM_PS_NEAREST); depthbuffer[offset] = depth[0]; - } + } offset ++; offset4 += 4; diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 12c0e851f88..81ebca7b2fb 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -1187,7 +1187,7 @@ static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type) if (ma->adt) return GET_ACF_FLAG_PTR(ma->adt->flag, type); else - return NULL; + return NULL; default: /* unsupported */ return NULL; @@ -1264,7 +1264,7 @@ static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type) if (la->adt) return GET_ACF_FLAG_PTR(la->adt->flag, type); else - return NULL; + return NULL; default: /* unsupported */ return NULL; @@ -1348,7 +1348,7 @@ static void *acf_dstex_setting_ptr(bAnimListElem *ale, int setting, short *type) if (tex->adt) return GET_ACF_FLAG_PTR(tex->adt->flag, type); else - return NULL; + return NULL; default: /* unsupported */ return NULL; @@ -3330,7 +3330,7 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann /* get the flag and the pointer to that flag */ flag = acf->setting_flag(ac, setting, &negflag); ptr = acf->setting_ptr(ale, setting, &ptrsize); - /* enabled= ANIM_channel_setting_get(ac, ale, setting); */ /* UNUSED */ + /* enabled = ANIM_channel_setting_get(ac, ale, setting); */ /* UNUSED */ /* get the base icon for the setting */ switch (setting) { @@ -3345,13 +3345,13 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann break; case ACHANNEL_SETTING_EXPAND: /* expanded triangle */ - //icon= ((enabled)? ICON_TRIA_DOWN : ICON_TRIA_RIGHT); + //icon = ((enabled)? ICON_TRIA_DOWN : ICON_TRIA_RIGHT); icon = ICON_TRIA_RIGHT; tooltip = "Make channels grouped under this channel visible"; break; case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */ - //icon= ((enabled)? ICON_LAYER_ACTIVE : ICON_LAYER_USED); + //icon = ((enabled)? ICON_LAYER_ACTIVE : ICON_LAYER_USED); icon = ICON_LAYER_USED; tooltip = "NLA Track is the only one evaluated for the AnimData block it belongs to"; break; @@ -3360,13 +3360,13 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann case ACHANNEL_SETTING_PROTECT: /* protected lock */ // TODO: what about when there's no protect needed? - //icon= ((enabled)? ICON_LOCKED : ICON_UNLOCKED); + //icon = ((enabled)? ICON_LOCKED : ICON_UNLOCKED); icon = ICON_UNLOCKED; tooltip = "Editability of keyframes for this channel"; break; case ACHANNEL_SETTING_MUTE: /* muted speaker */ - //icon= ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF); + //icon = ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF); icon = ICON_MUTE_IPO_OFF; if (ale->type == ALE_FCURVE) @@ -3449,7 +3449,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale y = (ymaxc - yminc) / 2 + yminc; ymid = y - 7; /* y-coordinates for text is only 4 down from middle */ - /* ytext= y - 4; */ + /* ytext = y - 4; */ /* no button backdrop behind icons */ uiBlockSetEmboss(block, UI_EMBOSSN); diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index ee31276a8c4..f6459bfc542 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -468,7 +468,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn /* store this level as the 'old' level now */ prevLevel = level; - } + } /* if the level is 'greater than' (i.e. less important) than the previous level... */ else if (level > prevLevel) { /* if previous level was a base-level (i.e. 0 offset / root of one hierarchy), @@ -604,7 +604,7 @@ static int animedit_poll_channels_nla_tweakmode_off(bContext *C) if (ELEM3(sa->spacetype, SPACE_ACTION, SPACE_IPO, SPACE_NLA) == 0) return 0; - /* NLA TweakMode test */ + /* NLA TweakMode test */ if (sa->spacetype == SPACE_NLA) { if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) return 0; @@ -798,7 +798,7 @@ static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *sr FCurve *fcu = (FCurve *)channel; is_sel = SEL_FCU(fcu); - } + } break; case ANIMTYPE_NLATRACK: { @@ -914,7 +914,7 @@ static void rearrange_nla_channels(bAnimContext *UNUSED(ac), AnimData *adt, shor if (rearrange_func == NULL) return; - /* only consider NLA data if it's accessible */ + /* only consider NLA data if it's accessible */ //if (EXPANDED_DRVD(adt) == 0) // return; @@ -935,7 +935,7 @@ static void rearrange_driver_channels(bAnimContext *UNUSED(ac), AnimData *adt, s if (rearrange_func == NULL) return; - /* only consider drivers if they're accessible */ + /* only consider drivers if they're accessible */ if (EXPANDED_DRVD(adt) == 0) return; @@ -2211,7 +2211,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in } notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); - } + } break; case ANIMTYPE_GROUP: @@ -2224,7 +2224,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in agrp->flag ^= AGRP_SELECTED; } else if (selectmode == -1) { - /* select all in group (and deselect everthing else) */ + /* select all in group (and deselect everthing else) */ FCurve *fcu; /* deselect all other channels */ @@ -2233,7 +2233,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in /* only select channels in group and group itself */ for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) fcu->flag |= FCURVE_SELECTED; - agrp->flag |= AGRP_SELECTED; + agrp->flag |= AGRP_SELECTED; } else { /* select group by itself */ @@ -2311,7 +2311,7 @@ static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_in /* invert selection status of this layer only */ gpl->flag ^= GP_LAYER_SELECT; } - else { + else { /* select layer by itself */ ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); gpl->flag |= GP_LAYER_SELECT; diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 620f5de9db7..01c0a95e200 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -261,8 +261,8 @@ void ANIM_draw_previewrange(const bContext *C, View2D *v2d) /* only draw two separate 'curtains' if there's no overlap between them */ if (PSFRA < PEFRA) { glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax); - glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); - } + glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + } else { glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 9b88c307cb6..f1fc93db60e 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -683,7 +683,7 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne ale->datatype = ALE_ACT; ale->adt = BKE_animdata_from_id(data); - } + } break; case ANIMTYPE_DSSPK: { @@ -825,7 +825,7 @@ static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owne } ale->datatype = (ale->key_data) ? ALE_FCURVE : ALE_NONE; } - } + } break; case ANIMTYPE_GPLAYER: @@ -1037,7 +1037,7 @@ static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, bActionGro if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode)) continue; } - } + } /* only include if visible (Graph Editor check, not channels check) */ if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || (fcu->flag & FCURVE_VISIBLE)) { @@ -1225,7 +1225,7 @@ static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDop */ if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) || (adt->action)) { /* there isn't really anything editable here, so skip if need editable */ - if ((filter_mode & ANIMFILTER_FOREDIT) == 0) { + if ((filter_mode & ANIMFILTER_FOREDIT) == 0) { /* just add the action track now (this MUST appear for drawing) * - as AnimData may not have an action, we pass a dummy pointer just to get the list elem created, then * overwrite this with the real value - REVIEW THIS... diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index 5295950546d..d8e3349e998 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -89,7 +89,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) * i.e. Bone1.Location.X, or Object.Location.X * 2) <array-index> <property-name> (<struct name>) * i.e. X Location (Bone1), or X Location (Object) - * + * * Currently, option 2 is in use, to try and make it easier to quickly identify F-Curves (it does have * problems with looking rather odd though). Option 1 is better in terms of revealing a consistent sense of * hierarchy though, which isn't so clear with option 2. diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 895aaec29da..852f3fa5469 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -150,7 +150,7 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f break; case TFM_TIME_SCALE: - { + { /* rescale the distance between the marker and the current frame */ marker->frame = cfra + (int)floorf(((float)(marker->frame - cfra) * value) + 0.5f); changed++; @@ -249,7 +249,7 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la min = (float)marker->frame; if (marker->frame > max) max = (float)marker->frame; - } + } } } @@ -278,7 +278,7 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only return; } else if (ce->cfra > marker->frame) break; - } + } cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem"); if (ce) BLI_insertlinkbefore(lb, ce, cen); @@ -360,7 +360,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) glScalef(1.0f / xscale, 1.0f, 1.0f); glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* vertical line - dotted */ #ifdef DURIAN_CAMERA_SWITCH @@ -522,7 +522,7 @@ static int ed_markers_opwrap_invoke_custom(bContext *C, wmOperator *op, wmEvent else if (op->type->exec) retval = op->type->exec(C, op); else - BKE_report(op->reports, RPT_ERROR, "Programming error: operator doesn't actually have code to do anything!"); + BKE_report(op->reports, RPT_ERROR, "Programming error: operator does not actually have code to do anything!"); /* return status modifications - for now, make this spacetype dependent as above */ if (sa->spacetype != SPACE_TIME) { @@ -726,7 +726,7 @@ static int ed_marker_move_cancel(bContext *C, wmOperator *op) { RNA_int_set(op->ptr, "frames", 0); ed_marker_move_apply(op); - ed_marker_move_exit(C, op); + ed_marker_move_exit(C, op); WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); @@ -821,7 +821,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) } else { /* we only print the offset */ - if (mm->slink->spacetype == SPACE_TIME) { + if (mm->slink->spacetype == SPACE_TIME) { SpaceTime *stime = (SpaceTime *)mm->slink; if (stime->flag & TIME_DRAWFRAMES) BLI_snprintf(str, sizeof(str), "Marker offset %d ", offs); @@ -1030,7 +1030,7 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) x = evt->x - ar->winrct.xmin; y = evt->y - ar->winrct.ymin; - UI_view2d_region_to_view(v2d, x, y, &viewx, NULL); + UI_view2d_region_to_view(v2d, x, y, &viewx, NULL); cfra = ED_markers_find_nearest_marker_time(markers, viewx); @@ -1377,7 +1377,7 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) } if (scene_to == CTX_data_scene(C)) { - BKE_report(op->reports, RPT_ERROR, "Can't re-link markers into the same scene"); + BKE_report(op->reports, RPT_ERROR, "Cannot re-link markers into the same scene"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 38f9119104b..25833c13925 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -91,7 +91,7 @@ FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_inde adt = BKE_animdata_from_id(id); if ((adt == NULL) && (add)) adt = BKE_id_add_animdata(id); - if (adt == NULL) { + if (adt == NULL) { /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */ return NULL; } @@ -478,7 +478,7 @@ static int add_driver_button_exec(bContext *C, wmOperator *op) char *path = get_driver_path_hack(C, &ptr, prop); short flags = CREATEDRIVER_WITH_DEFAULT_DVAR; - if (path) { + if (path) { success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON); MEM_freeN(path); diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index 6c9105dde69..e520a95aa95 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -322,7 +322,7 @@ static void nupdate_abk_bezt(void *node, void *data) /* just add the BezTriple to the buffer if there's space, or allocate a new one */ if (abk->numBezts >= MAX_ABK_BUFSIZE) { // TODO: need to allocate new array to cater... - //bezts_extra= MEM_callocN(...); + //bezts_extra = MEM_callocN(...); if (G.debug & G_DEBUG) printf("FIXME: nupdate_abk_bezt() missing case for too many overlapping BezTriples\n"); } @@ -345,7 +345,7 @@ static BezTriple *abk_get_bezt_with_value(ActBeztColumn *abk, float value) return NULL; /* look over each BezTriple in this container */ - for (i = 0; i < abk->numBezts; i++) { + for (i = 0; i < abk->numBezts; i++) { /* only do exact match for now... */ if (/*i >= MAX_ABK_BUFSIZE*/ 0) { // TODO: this case needs special handling @@ -582,7 +582,7 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, } /* tweak size of keyframe shape according to type of keyframe - * - 'proper' keyframes have key_type=0, so get drawn at full size + * - 'proper' keyframes have key_type = 0, so get drawn at full size */ hsize -= 0.5f * key_type; @@ -960,7 +960,7 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree if (fcu && fcu->totvert && fcu->bezt) { /* apply NLA-mapping (if applicable) */ - if (adt) + if (adt) ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 0); /* if getting long keyframes too, grab the BezTriples in a BST for diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index b277d0eccb5..015c2667a93 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -154,7 +154,7 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi if (fcu_cb) fcu_cb(fcu); - /* done */ + /* done */ return 0; } @@ -639,7 +639,7 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be if (ELEM3(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h1 = HD_ALIGN; if (ELEM3(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h2 = HD_ALIGN; } - return 0; + return 0; } /* value to snap to is stored in the custom data -> first float value slot */ @@ -880,7 +880,7 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code) switch (code) { case BEZT_IPO_CONST: /* constant */ return set_bezt_constant; - case BEZT_IPO_LIN: /* linear */ + case BEZT_IPO_LIN: /* linear */ return set_bezt_linear; default: /* bezier */ return set_bezt_bezier; @@ -930,7 +930,7 @@ KeyframeEditFunc ANIM_editkeyframes_keytype(short code) case BEZT_KEYTYPE_JITTER: /* jitter keyframe */ return set_keytype_jitter; - case BEZT_KEYTYPE_KEYFRAME: /* proper keyframe */ + case BEZT_KEYTYPE_KEYFRAME: /* proper keyframe */ default: return set_keytype_keyframe; } diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index b5c0555bf63..9249b912da6 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -188,7 +188,7 @@ void clean_fcurve(FCurve *fcu, float thresh) /* make a copy of the old BezTriples, and clear F-Curve */ old_bezts = fcu->bezt; - totCount = fcu->totvert; + totCount = fcu->totvert; fcu->bezt = NULL; fcu->totvert = 0; @@ -256,7 +256,7 @@ void clean_fcurve(FCurve *fcu, float thresh) insert_vert_fcurve(fcu, cur[0], cur[1], 0); } } - else { + else { /* add if value doesn't equal that of previous */ if (IS_EQT(cur[1], prev[1], thresh) == 0) { /* add new keyframe */ diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index f0c5f063e57..4f16c1a6622 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -108,7 +108,7 @@ short ANIM_get_keyframing_flags(Scene *scene, short incl_mode) } /* only if including settings from the autokeying mode... */ - if (incl_mode) { + if (incl_mode) { /* keyframing mode - only replace existing keyframes */ if (IS_AUTOKEY_MODE(scene, EDITKEYS)) flag |= INSERTKEY_REPLACE; @@ -131,7 +131,7 @@ bAction *verify_adt_action(ID *id, short add) adt = BKE_animdata_from_id(id); if ((adt == NULL) && (add)) adt = BKE_id_add_animdata(id); - if (adt == NULL) { + if (adt == NULL) { /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */ printf("ERROR: Couldn't add AnimData (ID = %s)\n", (id) ? (id->name) : "<None>"); return NULL; @@ -240,7 +240,7 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) i = binarysearch_bezt_index(fcu->bezt, bezt->vec[1][0], fcu->totvert, &replace); /* replace an existing keyframe? */ - if (replace) { + if (replace) { /* sanity check: 'i' may in rare cases exceed arraylen */ if ((i >= 0) && (i < fcu->totvert)) { /* just change the values when replacing, so as to not overwrite handles */ @@ -412,12 +412,12 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) float prevPosi = 0.0f, prevVal = 0.0f; float beztPosi = 0.0f, beztVal = 0.0f; - /* get current time+value */ + /* get current time+value */ beztPosi = bezt->vec[1][0]; beztVal = bezt->vec[1][1]; if (prev) { - /* there is a keyframe before the one currently being examined */ + /* there is a keyframe before the one currently being examined */ /* get previous time+value */ prevPosi = prev->vec[1][0]; @@ -789,7 +789,7 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p /* F-Curve not editable? */ if (fcurve_is_keyframable(fcu) == 0) { BKE_reportf(reports, RPT_ERROR, - "F-Curve with path = '%s' [%d] cannot be keyframed, ensure that it is not locked or sampled, " + "F-Curve with path '%s[%d]' cannot be keyframed, ensure that it is not locked or sampled, " "and try removing F-Modifiers", fcu->rna_path, fcu->array_index); return 0; @@ -940,7 +940,7 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou } /* key entire array convenience method */ - if (array_index == -1) { + if (array_index == -1) { array_index = 0; array_index_max = RNA_property_array_length(&ptr, prop); @@ -1028,13 +1028,13 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); } else { - BKE_reportf(reports, RPT_ERROR, "No action to delete keyframes from for ID = %s\n", id->name); + BKE_reportf(reports, RPT_ERROR, "No action to delete keyframes from for ID = %s", id->name); return 0; } } /* key entire array convenience method */ - if (array_index == -1) { + if (array_index == -1) { array_index = 0; array_index_max = RNA_property_array_length(&ptr, prop); @@ -1064,7 +1064,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou /* try to find index of beztriple to get rid of */ i = binarysearch_bezt_index(fcu->bezt, cfra, fcu->totvert, &found); - if (found) { + if (found) { /* delete the key at the index (will sanity check + do recalc afterwards) */ delete_fcurve_key(fcu, i, 1); @@ -1126,7 +1126,7 @@ static short clear_keyframe(ReportList *reports, ID *id, bAction *act, const cha act = adt->action; } else { - BKE_reportf(reports, RPT_ERROR, "No action to delete keyframes from for ID = %s\n", id->name); + BKE_reportf(reports, RPT_ERROR, "No action to delete keyframes from for ID = %s", id->name); return 0; } } @@ -1236,7 +1236,7 @@ static int insert_key_exec(bContext *C, wmOperator *op) /* try to insert keyframes for the channels specified by KeyingSet */ success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); if (G.debug & G_DEBUG) - BKE_reportf(op->reports, RPT_INFO, "Keying set '%s' - successfully added %d keyframes\n", ks->name, success); + BKE_reportf(op->reports, RPT_INFO, "Keying set '%s' - successfully added %d keyframes", ks->name, success); /* report failure or do updates? */ if (success == MODIFYKEY_INVALID_CONTEXT) { @@ -1863,7 +1863,7 @@ short fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter) /* binarysearch_bezt_index will set replace to be 0 or 1 * - obviously, 1 represents a match */ - if (replace) { + if (replace) { /* sanity check: 'i' may in rare cases exceed arraylen */ if ((i >= 0) && (i < fcu->totvert)) return 1; diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 5844bd6708f..ae7abd82600 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -377,7 +377,7 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot) /* callbacks */ ot->exec = add_keyingset_button_exec; - //op->poll= ??? + //op->poll = ??? /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -457,7 +457,7 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot) /* callbacks */ ot->exec = remove_keyingset_button_exec; - //op->poll= ??? + //op->poll = ??? /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -947,7 +947,7 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe /* skip path if no ID pointer is specified */ if (ksp->id == NULL) { BKE_reportf(reports, RPT_WARNING, - "Skipping path in keying set, as it has no ID (KS = '%s', path = '%s'[%d])", + "Skipping path in keying set, as it has no ID (KS = '%s', path = '%s[%d]')", ks->name, ksp->rna_path, ksp->array_index); continue; } diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index c19904d39ac..7c5b75e56ae 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -88,7 +88,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(ARMATURE_OT_armature_layers); WM_operatortype_append(ARMATURE_OT_bone_layers); - /* SKETCH */ + /* SKETCH */ WM_operatortype_append(SKETCH_OT_gesture); WM_operatortype_append(SKETCH_OT_delete); WM_operatortype_append(SKETCH_OT_draw_stroke); @@ -221,7 +221,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) /* Already part of view3d select */ //WM_keymap_add_item(keymap, "SKETCH_OT_select", SELECTMOUSE, KM_PRESS, 0, 0); - /* sketch poll checks mode */ + /* sketch poll checks mode */ WM_keymap_add_item(keymap, "SKETCH_OT_gesture", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", LEFTMOUSE, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "SKETCH_OT_draw_stroke", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 8a75d07a678..48da23d5e8d 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -117,14 +117,14 @@ void ED_armature_sync_selection(ListBase *edbo) else ebo->flag &= ~BONE_SELECTED; } - } + } } void ED_armature_validate_active(struct bArmature *arm) { EditBone *ebone = arm->act_edbone; - if (ebone) { + if (ebone) { if (ebone->flag & BONE_HIDDEN_A) arm->act_edbone = NULL; } @@ -304,7 +304,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone eBone->ease2 = curBone->ease2; eBone->rad_head = curBone->rad_head; eBone->rad_tail = curBone->rad_tail; - eBone->segments = curBone->segments; + eBone->segments = curBone->segments; eBone->layer = curBone->layer; if (curBone->prop) @@ -897,7 +897,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* make tar armature be new parent */ ob->parent = tarArm; } - } + } } /* join armature exec is exported for use in object->join objects operator... */ @@ -1113,7 +1113,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) } } } - } + } } /* Helper function for armature separating - remove certain bones from the given armature @@ -1440,7 +1440,7 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *ev /* Select parents */ for (curBone = bone; curBone; curBone = next) { /* ignore bone if cannot be selected */ - if ((curBone->flag & BONE_UNSELECTABLE) == 0) { + if ((curBone->flag & BONE_UNSELECTABLE) == 0) { // XXX old cruft! use notifiers instead //select_actionchannel_by_name (ob->action, curBone->name, !(shift)); @@ -1493,7 +1493,7 @@ void POSE_OT_select_linked(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - /* props */ + /* props */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); } @@ -1550,7 +1550,7 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, wmEvent *e bone = curBone; break; } - else { + else { bone = NULL; break; } @@ -2687,7 +2687,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) updateDuplicateSubtarget(eBone, arm->edbo, obedit); } } - } + } /* correct the active bone */ if (arm->act_edbone) { @@ -2802,7 +2802,7 @@ static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points) } for (ebp = points->first; ebp; ebp = ebp->next) { - if (equals_v3v3(ebp->vec, vec)) { + if (equals_v3v3(ebp->vec, vec)) { if (eb_tail) { if ((ebp->head_owner) && (ebp->head_owner->parent == ebo)) { /* so this bone's tail owner is this bone */ @@ -2886,7 +2886,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) mul_v3_m4v3(curs, obedit->imat, give_cursor(scene, v3d)); /* Create a bone */ - /* newbone= */ add_points_bone(obedit, ebp->vec, curs); + /* newbone = */ add_points_bone(obedit, ebp->vec, curs); } else if (count == 2) { EditBonePoint *ebp, *ebp2; @@ -2970,7 +2970,7 @@ static int armature_fill_bones_exec(bContext *C, wmOperator *op) } else { /* FIXME.. figure out a method for multiple bones */ - BKE_reportf(op->reports, RPT_ERROR, "Too many points selected: %d\n", count); + BKE_reportf(op->reports, RPT_ERROR, "Too many points selected: %d", count); BLI_freelistN(&points); return OPERATOR_CANCELLED; } @@ -3150,7 +3150,7 @@ static int armature_merge_exec(bContext *C, wmOperator *op) /* put back link */ BLI_insertlinkbefore(&chains, nchain, chain); - } + } armature_tag_unselect(arm); @@ -3301,7 +3301,9 @@ static void hide_unselected_armature_bones(Scene *scene) for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { bArmature *arm = obedit->data; if (EBONE_VISIBLE(arm, ebone)) { - if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL)) ; + if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL)) { + /* pass */ + } else { ebone->flag |= BONE_HIDDEN_A; } @@ -3457,7 +3459,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) /* Deselect the old bone */ ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); - } + } } /* if only one bone, make this one active */ if (totbone == 1 && first) arm->act_edbone = first; @@ -3681,7 +3683,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) parent = ebo->parent; /* only if selected and editable */ - if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) { + if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) { /* swap head and tail coordinates */ SWAP(float, ebo->head[0], ebo->tail[0]); SWAP(float, ebo->head[1], ebo->tail[1]); @@ -3721,7 +3723,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) } /* free chains */ - BLI_freelistN(&chains); + BLI_freelistN(&chains); armature_tag_unselect(arm); @@ -3778,7 +3780,7 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo } } - if (mode == ARM_PAR_CONNECT) { + if (mode == ARM_PAR_CONNECT) { /* Connected: Child bones will be moved to the parent tip */ selbone->flag |= BONE_CONNECTED; sub_v3_v3v3(offset, actbone->tail, selbone->head); @@ -3893,7 +3895,7 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEve { if (ebone != actbone) { if (ebone->parent != actbone) allchildbones = 1; - } + } } CTX_DATA_END; @@ -3901,7 +3903,7 @@ static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEve /* ob becomes parent, make the associated menus */ if (allchildbones) - uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET); + uiItemEnumO(layout, "ARMATURE_OT_parent_set", NULL, 0, "type", ARM_PAR_OFFSET); uiPupMenuEnd(C, pup); @@ -3994,7 +3996,7 @@ static int armature_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) ebone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } } - CTX_DATA_END; + CTX_DATA_END; WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); @@ -4055,7 +4057,7 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op) } } } - CTX_DATA_END; + CTX_DATA_END; WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); @@ -4295,7 +4297,7 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) break; } - } + } else { // BONE_SELECT_CHILD chbone = editbone_get_child(arm, curbone, 1); if (chbone == NULL) continue; @@ -4566,7 +4568,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); arm->act_bone = nearBone; } - } + } } if (ob_act) { @@ -5118,7 +5120,7 @@ static void pchan_clear_rot(bPoseChannel *pchan) } } } /* Duplicated in source/blender/editors/object/object_transform.c */ - else { + else { if (pchan->rotmode == ROT_MODE_QUAT) { unit_qt(pchan->quat); } @@ -5544,7 +5546,7 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam if (cti->flush_constraint_targets) cti->flush_constraint_targets(curcon, &targets, 0); - } + } } } @@ -5631,7 +5633,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } } - if (modifiers_usesArmature(ob, arm)) { + if (modifiers_usesArmature(ob, arm)) { bDeformGroup *dg = defgroup_find_name(ob, oldname); if (dg) { BLI_strncpy(dg->name, newname, MAXBONENAME); @@ -5959,7 +5961,7 @@ float arcLengthRatio(ReebArc *arc) embedLength = arcLength; } - return embedLength / arcLength; + return embedLength / arcLength; } EditBone *test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) @@ -6060,7 +6062,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) arc->flag = 1; /* mark arc direction */ } - /* Loop over subdivision methods */ + /* Loop over subdivision methods */ for (i = 0; lastBone == NULL && i < SKGEN_SUB_TOTAL; i++) { switch (scene->toolsettings->skgen_subdivisions[i]) { case SKGEN_SUB_LENGTH: diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c index 23dd3b15476..d9c7e78c01e 100644 --- a/source/blender/editors/armature/editarmature_generate.c +++ b/source/blender/editors/armature/editarmature_generate.c @@ -55,7 +55,7 @@ void setBoneRollFromNormal(EditBone *bone, const float no[3], float UNUSED(invma if (no != NULL && !is_zero_v3(no)) { float normal[3]; - copy_v3_v3(normal, no); + copy_v3_v3(normal, no); mul_m3_v3(tmat, normal); bone->roll = ED_rollBoneToVector(bone, normal, FALSE); diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index 196d03020e7..e5372c3ea09 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -191,7 +191,7 @@ static float rollBoneByQuatJoint(RigEdge *edge, RigEdge *previous, float qrot[4] if (previous->bone) { sub_v3_v3v3(vec_first, previous->bone->tail, previous->bone->head); - } + } else if (previous->prev->bone) { sub_v3_v3v3(vec_first, edge->bone->head, previous->prev->bone->tail); } @@ -653,7 +653,7 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link) sub_v3_v3v3(offset, ctrl->bone->head, link->head); - /* if root matches, check for direction too */ + /* if root matches, check for direction too */ if (dot_v3v3(offset, offset) < 0.0001f) { float vbone[3], vparent[3]; @@ -802,7 +802,7 @@ static void RIG_reconnectControlBones(RigGraph *rg) } } - /* if not found yet, check child */ + /* if not found yet, check child */ if (found == 0) { RigArc *arc; RigArc *best_arc = NULL; @@ -863,7 +863,7 @@ static void RIG_reconnectControlBones(RigGraph *rg) /* SET bone link to ctrl corresponding to pchan */ RigControl *link = BLI_ghash_lookup(rg->controls_map, pchan->name); - /* if owner is a control bone, link with it */ + /* if owner is a control bone, link with it */ if (link && link->link) { RIG_parentControl(ctrl, link->bone); found = 1; @@ -876,7 +876,7 @@ static void RIG_reconnectControlBones(RigGraph *rg) cti->flush_constraint_targets(con, &targets, 0); } } - } + } if (found == 0) { /* check if parent is already linked */ @@ -1324,7 +1324,7 @@ void RIG_printArc(RigGraph *rg, RigArc *arc) printf("\t\t%s\n", edge->bone->name); RIG_printLinkedCtrl(rg, edge->bone, 3); } - } + } printf("symmetry level: %i flag: %i group %i\n", arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group); RIG_printNode((RigNode *)arc->tail, "tail"); @@ -1336,7 +1336,7 @@ void RIG_printGraph(RigGraph *rg) printf("---- ARCS ----\n"); for (arc = rg->arcs.first; arc; arc = arc->next) { - RIG_printArc(rg, arc); + RIG_printArc(rg, arc); printf("\n"); } @@ -1345,7 +1345,7 @@ void RIG_printGraph(RigGraph *rg) } else { printf("HEAD NODE: NONE\n"); - } + } } /*******************************************************************************************************/ @@ -1584,7 +1584,7 @@ static void finalizeControl(RigGraph *rigg, RigControl *ctrl, float resize) repositionTailControl(rigg, ctrl_child); } } - } + } } static void repositionTailControl(RigGraph *rigg, RigControl *ctrl) @@ -1840,7 +1840,7 @@ static float calcCostAngleLengthDistance(BArcIterator *iter, float **UNUSED(vec_ length2 = normalize_v3(vec_second); - /* Angle cost */ + /* Angle cost */ if (edge->prev) { sub_v3_v3v3(vec_first, vec1, vec0); normalize_v3(vec_first); @@ -2135,7 +2135,7 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri no = node_end->no; } - /* no need to move virtual edges (space between unconnected bones) */ + /* no need to move virtual edges (space between unconnected bones) */ if (edge->bone) { repositionBone(C, rigg, edge, vec0, vec1, no); } @@ -2173,7 +2173,7 @@ void *exec_retargetArctoArc(void *param) RetargetParam *p = (RetargetParam *)param; RigGraph *rigg = p->rigg; RigArc *iarc = p->iarc; - bContext *C = p->context; + bContext *C = p->context; RigNode *inode_start = p->inode_start; ReebArc *earc = iarc->link_mesh; @@ -2222,7 +2222,7 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t enode = enode->link_down; reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); /* replace with call to link_down once that exists */ eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; - } + } } static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode) @@ -2273,7 +2273,7 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc reebg = reebg->link_up; enode = next_earc->head; eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS; - } + } next_earc->flag = ARC_USED; next_iarc->link_mesh = next_earc; @@ -2303,7 +2303,7 @@ static void matchMultiResolutionStartingNode(RigGraph *rigg, ReebGraph *reebg, R enode = reebg->nodes.first; eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; - } + } inode->link_mesh = enode; } @@ -2600,7 +2600,7 @@ void BIF_retargetArmature(bContext *C) ED_undo_push(C, "Retarget Skeleton"); - // XXX + // XXX // allqueue(REDRAWVIEW3D, 0); } diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 68d8a8d721e..da8fc328343 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -440,7 +440,7 @@ static void sk_cancelStroke(SK_Sketch *sketch) static float sk_clampPointSize(SK_Point *pt, float size) { - return MAX2(size * pt->size, size / 2); + return max_ff(size * pt->size, size / 2); } static void sk_drawPoint(GLUquadric *quad, SK_Point *pt, float size) diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 82fef00b1e6..e7586311312 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -53,7 +53,6 @@ #include "BKE_modifier.h" #include "BKE_mesh.h" - #ifdef RIGID_DEFORM #include "BLI_polardecomp.h" #endif @@ -563,7 +562,7 @@ static void heat_set_H(LaplacianSystem *sys, int vertex) /* compute H entry */ if (numclosest > 0) { - mindist = maxf(mindist, 1e-4f); + mindist = max_ff(mindist, 1e-4f); h = numclosest * C_WEIGHT / (mindist * mindist); } else @@ -794,7 +793,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, } } else if (*err_str == NULL) { - *err_str = "Bone Heat Weighting: failed to find solution for one or more bones"; + *err_str = N_("Bone Heat Weighting: failed to find solution for one or more bones"); break; } @@ -1195,7 +1194,7 @@ static int meshdeform_tri_intersect(const float orig[3], const float end[3], con } static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) - { +{ void **data = userdata; MeshDeformBind *mdb = data[1]; MFace *mface = data[0], *mf; @@ -1210,7 +1209,7 @@ static void harmonic_ray_callback(void *userdata, int index, const BVHTreeRay *r if (mf->v4) copy_v3_v3(face[3], mdb->cagecos[mf->v4]); - add_v3_v3v3(end, isec->start, isec->vec); + add_v3_v3v3(end, isec->start, isec->vec); if (!meshdeform_tri_intersect(ray->origin, end, face[0], face[1], face[2], co, uvw)) if (!mf->v4 || !meshdeform_tri_intersect(ray->origin, end, face[0], face[2], face[3], co, uvw)) @@ -1257,7 +1256,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float if (BLI_bvhtree_ray_cast(mdb->bvhtree, isect_mdef.start, isect_mdef.vec, 0.0, &hit, harmonic_ray_callback, data) != -1) { - len = isect_mdef.labda; + len = isect_mdef.labda; isect_mdef.face = mface = mface1 + hit.index; /* create MDefBoundIsect */ @@ -1722,7 +1721,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind } } else { - modifier_setError(&mmd->modifier, "%s", TIP_("Failed to find bind solution (increase precision?).")); + modifier_setError(&mmd->modifier, "Failed to find bind solution (increase precision?)"); error("Mesh Deform: failed to find bind solution."); break; } diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 31398948b82..3fd65de6c04 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -105,7 +105,7 @@ typedef struct tPoseSlideOp { int nextFrame; /* frame after current frame (blend-to) */ int mode; /* sliding mode (ePoseSlide_Modes) */ - int flag; // unused for now, but can later get used for storing runtime settings.... + int flag; /* unused for now, but can later get used for storing runtime settings.... */ float percentage; /* 0-1 value for determining the influence of whatever is relevant */ } tPoseSlideOp; @@ -486,7 +486,7 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso) pose_slide_apply_vec3(pso, pfl, pchan->eul, "rotation_euler"); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { - // TODO: need to figure out how to do this! + /* TODO: need to figure out how to do this! */ } else { /* quaternions - use quaternion blending */ @@ -538,7 +538,7 @@ static void pose_slide_draw_status(tPoseSlideOp *pso) break; default: - // unknown + /* unknown */ strcpy(mode_str, "Sliding-Tool"); break; } @@ -606,7 +606,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p } /* initial apply for operator... */ - // TODO: need to calculate percentage for initial round too... + /* TODO: need to calculate percentage for initial round too... */ pose_slide_apply(C, pso); /* depsgraph updates + redraws */ @@ -1152,7 +1152,7 @@ static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu, } /* just flatten handles, since values will now be the same either side... */ - // TODO: perhaps a fade-out modulation of the value is required here (optional once again)? + /* TODO: perhaps a fade-out modulation of the value is required here (optional once again)? */ bezt->vec[0][1] = bezt->vec[1][1] = bezt->vec[2][1] = refVal; /* select keyframe to indicate that it's been changed */ @@ -1247,13 +1247,13 @@ void POSE_OT_propagate(wmOperatorType *ot) /* callbacks */ ot->exec = pose_propagate_exec; - ot->poll = ED_operator_posemode; // XXX: needs selected bones! + ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */ /* flag */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - // TODO: add "fade out" control for tapering off amount of propagation as time goes by? + /* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */ ot->prop = RNA_def_enum(ot->srna, "mode", terminate_items, POSE_PROPAGATE_SMART_HOLDS, "Terminate Mode", "Method used to determine when to stop propagating pose to keyframes"); RNA_def_float(ot->srna, "end_frame", 250.0, FLT_MIN, FLT_MAX, "End Frame", "Frame to stop propagating frames to (for 'Before Frame' mode)", 1.0, 250.0); } diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index e2e3c49e7e0..f3c32399ad6 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -274,7 +274,7 @@ LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, con /* check if paths match */ if (strcmp(path, fcu->rna_path) == 0) return ld; - } + } /* none found */ return NULL; diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index a05a98c58ca..ae3d496b641 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -871,7 +871,7 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld) if (pld->marker) frame = pld->marker->frame; else - return; + return; /* init settings for testing groups for keyframes */ @@ -887,7 +887,7 @@ static void poselib_apply_pose(tPoseLib_PreviewData *pld) /* has keyframe on this frame, so try to get a PoseChannel with this name */ pchan = BKE_pose_channel_find_name(pose, agrp->name); - if (pchan) { + if (pchan) { short ok = 0; /* check if this bone should get any animation applied */ @@ -1079,7 +1079,7 @@ static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) } /* check if any matches */ - if (pld->searchp.first == NULL) { + if (pld->searchp.first == NULL) { pld->marker = NULL; return; } @@ -1152,7 +1152,7 @@ static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned sh poselib_preview_get_next(pld, 1); pld->redraw = PL_PREVIEW_REDRAWALL; return; - } + } break; case DELKEY: @@ -1639,7 +1639,7 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; - /* properties */ + /* properties */ // TODO: make the pose_index into a proper enum instead of a cryptic int... ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX); diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 99de90bc9fa..576e5983d16 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -134,7 +134,7 @@ void ED_armature_exit_posemode(bContext *C, Base *base) ob->mode &= ~OB_MODE_POSE; WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); - } + } } /* if a selected or active bone is protected, throw error (oonly if warn == 1) and return 1 */ @@ -500,7 +500,7 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) found = 1; break; } - } + } else { /* direction == BONE_SELECT_CHILD */ /* the child member is only assigned to connected bones, see [#30340] */ #if 0 @@ -992,7 +992,7 @@ static void pose_copy_menu(Scene *scene) } } } - } + } else { /* constraints, optional (note: max we can have is 24 constraints) */ bConstraint *con, *con_back; int const_toggle[24] = {0}; /* XXX, initialize as 0 to quiet errors */ @@ -1018,7 +1018,7 @@ static void pose_copy_menu(Scene *scene) con_back = con->next; BLI_freelinkN(&const_copy, con); con = con_back; - } + } else con = con->next; } @@ -1035,7 +1035,7 @@ static void pose_copy_menu(Scene *scene) * appending to list of constraints for this channel */ copy_constraints(&tmp_constraints, &const_copy, TRUE); - if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) { + if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) { /* add proxy-local tags */ for (con = tmp_constraints.first; con; con = con->next) con->flag |= CONSTRAINT_PROXY_LOCAL; @@ -1097,7 +1097,7 @@ static void set_pose_keys(Object *ob) for (chan = ob->pose->chanbase.first; chan; chan = chan->next) { Bone *bone = chan->bone; if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer)) - chan->flag |= POSE_KEY; + chan->flag |= POSE_KEY; else chan->flag &= ~POSE_KEY; } @@ -1916,7 +1916,7 @@ static int pose_bone_rotmode_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); int mode = RNA_enum_get(op->ptr, "type"); - /* set rotation mode of selected bones */ + /* set rotation mode of selected bones */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { pchan->rotmode = mode; @@ -2100,7 +2100,7 @@ static int pose_bone_layers_invoke(bContext *C, wmOperator *op, wmEvent *evt) { int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ - /* get layers that are active already */ + /* get layers that are active already */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { short bit; @@ -2299,10 +2299,10 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op) * just pose values should change, so this should be fine */ bPose *dummyPose = NULL; - Object workob = {{0}}; + Object workob = {{0}}; bPoseChannel *pchan; - /* execute animation step for current frame using a dummy copy of the pose */ + /* execute animation step for current frame using a dummy copy of the pose */ BKE_pose_copy_data(&dummyPose, ob->pose, 0); BLI_strncpy(workob.id.name, "OB<ClearTfmWorkOb>", sizeof(workob.id.name)); diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index 00f88a69fb6..b1bf13db69b 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -340,7 +340,7 @@ static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc) cp_arc->edges.first = NULL; cp_arc->edges.last = NULL; - /* copy buckets */ + /* copy buckets */ cp_arc->buckets = MEM_callocN(sizeof(EmbedBucket) * cp_arc->bcount, "embed bucket"); memcpy(cp_arc->buckets, arc->buckets, sizeof(EmbedBucket) * cp_arc->bcount); @@ -377,7 +377,7 @@ static ReebGraph *copyReebGraph(ReebGraph *rg, int level) cp_rg->link_up = rg; cp_rg->multi_level = level; - /* Copy nodes */ + /* Copy nodes */ for (node = rg->nodes.first; node; node = node->next) { ReebNode *cp_node = copyNode(cp_rg, node); @@ -889,7 +889,7 @@ static void calculateArcLength(ReebArc *arc) vec0 = vec1; } - arc->length += len_v3v3(arc->tail->p, vec1); + arc->length += len_v3v3(arc->tail->p, vec1); } static void calculateGraphLength(ReebGraph *rg) @@ -948,7 +948,7 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count) bucket1 = IT_next(iter1); bucket2 = IT_next(iter2); - /* Make sure they both start at the same value */ + /* Make sure they both start at the same value */ while (bucket1 && bucket2 && bucket1->val < bucket2->val) { bucket1 = IT_next(iter1); } @@ -1005,7 +1005,7 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count) bucket1 = IT_next(iter1); bucket2 = IT_next(iter2); - /* Make sure they both start at the same value */ + /* Make sure they both start at the same value */ while (bucket1 && bucket1->val < bucket2->val) { bucket1 = IT_next(iter1); } @@ -1016,7 +1016,7 @@ void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count) for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { - /* copy and mirror back to bucket2 */ + /* copy and mirror back to bucket2 */ bucket2->nv = bucket1->nv; copy_v3_v3(bucket2->p, bucket1->p); BLI_mirrorAlongAxis(bucket2->p, node->p, normal); @@ -1062,7 +1062,7 @@ void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BAr bucket1 = IT_next(iter1); bucket2 = IT_next(iter2); - /* Make sure they both start at the same value */ + /* Make sure they both start at the same value */ while (bucket1 && bucket1->val < bucket2->val) { bucket1 = IT_next(iter1); } @@ -1080,7 +1080,7 @@ void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BAr /* add bucket2 in bucket1 */ interp_v3_v3v3(bucket1->p, bucket1->p, bucket2->p, (float)bucket2->nv / (float)(bucket1->nv)); - /* copy and mirror back to bucket2 */ + /* copy and mirror back to bucket2 */ bucket2->nv = bucket1->nv; copy_v3_v3(bucket2->p, bucket1->p); BLI_mirrorAlongAxis(bucket2->p, root_node->p, nor); @@ -1212,7 +1212,7 @@ static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float reweightArc(rg, next_arc, node, end_weight); } - /* update only if needed */ + /* update only if needed */ if (arc->head->weight != start_weight || arc->tail->weight != end_weight) { old_weight = arc->head->weight; /* backup head weight, other arcs need it intact, it will be fixed by the source arc */ @@ -1318,7 +1318,7 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs) } joined = 1; - } + } } return joined; @@ -1450,7 +1450,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R arc->tail = newNode; } - // Remove looped arcs + // Remove looped arcs if (arc->head == arc->tail) { // v1 or v2 was already newNode, since we're removing an arc, decrement degree NodeDegreeDecrement(rg, newNode); @@ -1648,7 +1648,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) BLI_sortlist(&rg->arcs, compareArcs); #ifdef DEBUG_REEB - { + { EditFace *efa; for (efa = G.editMesh->faces.first; efa; efa = efa->next) { efa->tmp.fp = -1; @@ -1731,7 +1731,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) efa->tmp.fp = saacos(fabs(angle)); #endif #else - add_v3_v3(avg_vec, efa->n); + add_v3_v3(avg_vec, efa->n); #endif } @@ -1873,7 +1873,7 @@ static int compareVerts(const void *a, const void *b) value = 1; } - return value; + return value; } static void spreadWeight(EditMesh *em) @@ -1947,7 +1947,7 @@ void REEB_exportGraph(ReebGraph *rg, int count) fprintf(f, "angle %0.3f %0.3f %0.3f %0.3f %i\n", p[0], p[1], p[2], arc->angle, BLI_ghash_size(arc->faces)); exportNode(f, "v2", arc->tail); - } + } fclose(f); } @@ -1983,7 +1983,7 @@ void removeNormalNodes(ReebGraph *rg) /* If arcs are one after the other */ if (arc->head == connectedArc->tail) { - /* remove furthest arc */ + /* remove furthest arc */ if (arc->tail->weight < connectedArc->head->weight) { mergeConnectedArcs(rg, arc, connectedArc); nextArc = arc->next; @@ -2006,7 +2006,7 @@ void removeNormalNodes(ReebGraph *rg) /* If arcs are one after the other */ if (arc->tail == connectedArc->head) { - /* remove furthest arc */ + /* remove furthest arc */ if (arc->head->weight < connectedArc->tail->weight) { mergeConnectedArcs(rg, arc, connectedArc); nextArc = arc->next; @@ -2092,7 +2092,7 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d newEdge->nextEdge = e; - // if edge was the first in the list, point the edit edge to the new reeb edge instead. + // if edge was the first in the list, point the edit edge to the new reeb edge instead. if (*p == e) { *p = (void *)newEdge; } @@ -2289,12 +2289,12 @@ static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) arc->faces = BLI_ghash_ptr_new("createArc gh"); if (node1->weight <= node2->weight) { - v1 = node1; - v2 = node2; + v1 = node1; + v2 = node2; } else { - v1 = node2; - v2 = node1; + v1 = node2; + v2 = node1; } arc->head = v1; @@ -2857,7 +2857,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) /* Apply dijkstra spf for each selected vert */ for (eve = em->verts.first; eve; eve = eve->next) { if (eve->f & SELECT) { - shortestPathsFromVert(em, eve, indexed_edges); + shortestPathsFromVert(em, eve, indexed_edges); } } @@ -2927,7 +2927,7 @@ static void initIteratorFct(ReebArcIterator *iter) iter->next = nextBucket; iter->nextN = nextNBucket; iter->previous = previousBucket; - iter->stopped = iteratorStopped; + iter->stopped = iteratorStopped; } static void setIteratorValues(ReebArcIterator *iter, EmbedBucket *bucket) @@ -3419,7 +3419,7 @@ void REEB_draw() if (G.scene->toolsettings->skgen_options & SKGEN_DISP_EMBED) { - glColor3f(1, 1, 1); + glColor3f(1, 1, 1); glBegin(GL_POINTS); glVertex3fv(arc->head->p); glVertex3fv(arc->tail->p); diff --git a/source/blender/editors/armature/reeb.h b/source/blender/editors/armature/reeb.h index bb8b3003baf..b0e1fd3ae34 100644 --- a/source/blender/editors/armature/reeb.h +++ b/source/blender/editors/armature/reeb.h @@ -114,7 +114,7 @@ typedef struct ReebArc { int bcount; struct EmbedBucket *buckets; - struct GHash *faces; + struct GHash *faces; float angle; struct ReebArc *link_up; /* for multi resolution filtering, points to higher levels */ } ReebArc; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 874b31dd1ca..9ae5d3ca557 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -162,9 +162,9 @@ static short select_beztriple(BezTriple *bezt, short selstatus, short flag, shor bezt->f1 |= flag; bezt->f2 |= flag; bezt->f3 |= flag; - return 1; + return 1; } - else { /* deselects */ + else { /* deselects */ bezt->f1 &= ~flag; bezt->f2 &= ~flag; bezt->f3 &= ~flag; @@ -1361,7 +1361,7 @@ static int separate_exec(bContext *C, wmOperator *op) oldedit = oldcu->editnurb; if (oldcu->key) { - BKE_report(op->reports, RPT_ERROR, "Can't separate a curve with vertex keys"); + BKE_report(op->reports, RPT_ERROR, "Cannot separate a curve with vertex keys"); return OPERATOR_CANCELLED; } @@ -2063,7 +2063,7 @@ static int set_goal_weight_exec(bContext *C, wmOperator *op) bp->weight = weight; } } - } + } DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); @@ -2115,7 +2115,7 @@ static int set_radius_exec(bContext *C, wmOperator *op) bp->radius = radius; } } - } + } WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); @@ -2408,7 +2408,7 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short for (nu = editnurb->first; nu; nu = nu->next) { lastsel = 0; - if (nu->type == CU_BEZIER) { + if (nu->type == CU_BEZIER) { a = nu->pntsu; bezt = nu->bezt; if (next < 0) bezt = &nu->bezt[a - 1]; @@ -2425,7 +2425,7 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short bezt += next; lastsel = 0; } - /* move around in zigzag way so that we go through each */ + /* move around in zigzag way so that we go through each */ bezt -= (next - next / abs(next)); } } @@ -2440,7 +2440,7 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short if (!(bp->f1 & SELECT) || (selstatus == 0)) { short sel = select_bpoint(bp, selstatus, 1, VISIBLE); if ((sel == 1) && (cont == 0)) lastsel = 1; - } + } } else { bp += next; @@ -2706,7 +2706,7 @@ static int hide_exec(bContext *C, wmOperator *op) DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); - return OPERATOR_FINISHED; + return OPERATOR_FINISHED; } void CURVE_OT_hide(wmOperatorType *ot) @@ -2767,7 +2767,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); - return OPERATOR_FINISHED; + return OPERATOR_FINISHED; } void CURVE_OT_reveal(wmOperatorType *ot) @@ -3091,7 +3091,7 @@ static void subdividenurb(Object *obedit, int number_cuts) nu->pntsv = (number_cuts + 1) * nu->pntsv - number_cuts; BKE_nurb_knot_calc_u(nu); BKE_nurb_knot_calc_v(nu); - } /* End of 'if (sel == nu->pntsu*nu->pntsv)' (subdivide entire NURB) */ + } /* End of 'if (sel == nu->pntsu * nu->pntsv)' (subdivide entire NURB) */ else { /* subdivide in v direction? */ sel = 0; @@ -3200,7 +3200,7 @@ static int subdivide_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); - return OPERATOR_FINISHED; + return OPERATOR_FINISHED; } void CURVE_OT_subdivide(wmOperatorType *ot) @@ -3501,7 +3501,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) int changed = 0, type = RNA_enum_get(op->ptr, "type"); if (type == CU_CARDINAL || type == CU_BSPLINE) { - BKE_report(op->reports, RPT_ERROR, "Not implemented yet"); + BKE_report(op->reports, RPT_ERROR, "Not yet implemented"); return OPERATOR_CANCELLED; } @@ -3833,7 +3833,7 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu } if (nu1->pntsv != nu2->pntsv) { - BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match"); + BKE_report(op->reports, RPT_ERROR, "Resolution does not match"); return; } @@ -3943,7 +3943,7 @@ static int merge_nurb(bContext *C, wmOperator *op) } if (ok == 0) { - BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match"); + BKE_report(op->reports, RPT_ERROR, "Resolution does not match"); BLI_freelistN(&nsortbase); return OPERATOR_CANCELLED; } @@ -4123,7 +4123,7 @@ static int make_segment_exec(bContext *C, wmOperator *op) } if (!ok) { - BKE_report(op->reports, RPT_ERROR, "Can't make segment"); + BKE_report(op->reports, RPT_ERROR, "Cannot make segment"); return OPERATOR_CANCELLED; } @@ -4376,7 +4376,7 @@ static int spin_exec(bContext *C, wmOperator *op) unit_m4(viewmat); if (!spin_nurb(viewmat, obedit, axis, cent)) { - BKE_report(op->reports, RPT_ERROR, "Can't spin"); + BKE_report(op->reports, RPT_ERROR, "Cannot spin"); return OPERATOR_CANCELLED; } @@ -5252,10 +5252,10 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op)) tempbp = bp + 1; if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, 1, VISIBLE); if (sel) { - bp++; + bp++; a--; } - } + } } bp++; @@ -5313,8 +5313,8 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) if ((bp->hide == 0) && (bp->f1 & SELECT)) { sel = 0; - /* check if neighbors have been selected */ - /* edges of surface are an exception */ + /* check if neighbors have been selected */ + /* edges of surface are an exception */ if ((a + 1) % nu->pntsu == 0) sel++; else { bp--; @@ -5346,7 +5346,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) if (sel != 4) { select_bpoint(bp, DESELECT, 1, VISIBLE); selbpoints[a] = 1; - } + } } else lastsel = 0; @@ -5360,7 +5360,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) for (nu = editnurb->first; nu; nu = nu->next) { lastsel = 0; /* check what type of curve/nurb it is */ - if (nu->type == CU_BEZIER) { + if (nu->type == CU_BEZIER) { a = nu->pntsu; bezt = nu->bezt; while (a--) { @@ -5368,10 +5368,10 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) if (lastsel == 1) sel = 1; else sel = 0; - /* check if neighbors have been selected */ - /* first and last are exceptions */ + /* check if neighbors have been selected */ + /* first and last are exceptions */ if (a == nu->pntsu - 1) sel++; - else { + else { bezt--; if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++; bezt++; @@ -5385,14 +5385,14 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) } if (sel != 2) { - select_beztriple(bezt, DESELECT, 1, VISIBLE); + select_beztriple(bezt, DESELECT, 1, VISIBLE); lastsel = 1; } else lastsel = 0; } else lastsel = 0; - bezt++; + bezt++; } } else { @@ -5403,9 +5403,9 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) if (lastsel != 0) sel = 1; else sel = 0; - /* first and last are exceptions */ + /* first and last are exceptions */ if (a == nu->pntsu * nu->pntsv - 1) sel++; - else { + else { bp--; if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; bp++; @@ -5419,9 +5419,9 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) } if (sel != 2) { - select_bpoint(bp, DESELECT, 1, VISIBLE); + select_bpoint(bp, DESELECT, 1, VISIBLE); lastsel = 1; - } + } else lastsel = 0; } else lastsel = 0; @@ -5482,7 +5482,7 @@ static void selectrandom_curve(ListBase *editnurb, float randfac) select_bpoint(bp, SELECT, 1, VISIBLE); bp++; } - } + } } } @@ -5624,10 +5624,10 @@ static int select_nth_exec(bContext *C, wmOperator *op) if (!CU_select_nth(obedit, nth)) { if (obedit->type == OB_SURF) { - BKE_report(op->reports, RPT_ERROR, "Surface hasn't got active point"); + BKE_report(op->reports, RPT_ERROR, "Surface has not got active point"); } else { - BKE_report(op->reports, RPT_ERROR, "Curve hasn't got active point"); + BKE_report(op->reports, RPT_ERROR, "Curve has not got active point"); } return OPERATOR_CANCELLED; @@ -6627,7 +6627,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) if (obedit == NULL || obedit->type != OB_SURF) { obedit = ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); newob = 1; - } + } else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); } diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index b379ce6e5cf..2d039cfaf7f 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -310,7 +310,7 @@ static int insert_lorem_exec(bContext *C, wmOperator *UNUSED(op)) lastlorem = ED_lorem; insert_into_textbuf(obedit, '\n'); - insert_into_textbuf(obedit, '\n'); + insert_into_textbuf(obedit, '\n'); DAG_id_tag_update(obedit->data, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); @@ -458,7 +458,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float nchars += strlen(tmp->line) + 1; if (cu->str) MEM_freeN(cu->str); - if (cu->strinfo) MEM_freeN(cu->strinfo); + if (cu->strinfo) MEM_freeN(cu->strinfo); cu->str = MEM_callocN(nchars + 4, "str"); cu->strinfo = MEM_callocN((nchars + 4) * sizeof(CharInfo), "strinfo"); @@ -757,7 +757,7 @@ static int paste_selection(Object *obedit, ReportList *reports) /* Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT */ if (cu->len + len <= MAXTEXT) { - if (len) { + if (len) { int size = (cu->len * sizeof(wchar_t)) - (cu->pos * sizeof(wchar_t)) + sizeof(wchar_t); memmove(ef->textbuf + cu->pos + len, ef->textbuf + cu->pos, size); memcpy(ef->textbuf + cu->pos, ef->copybuf, len * sizeof(wchar_t)); @@ -835,7 +835,7 @@ static int move_cursor(bContext *C, int type, int select) if (ef->textbuf[cu->pos - 1] == '\n') break; if (ef->textbufinfo[cu->pos - 1].flag & CU_CHINFO_WRAP) break; cu->pos--; - } + } cursmove = FO_CURS; break; @@ -868,7 +868,7 @@ static int move_cursor(bContext *C, int type, int select) cursmove = FO_CURS; break; - case NEXT_CHAR: + case NEXT_CHAR: if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; cu->pos++; cursmove = FO_CURS; diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 3b26c46a410..11e07584405 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -98,8 +98,8 @@ static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickn if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) return; - /* if drawing a single point, draw it larger */ - if (totpoints == 1) { + /* if drawing a single point, draw it larger */ + if (totpoints == 1) { /* draw point */ glBegin(GL_POINTS); glVertex2iv(&points->x); @@ -315,7 +315,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, s0[1] = (pt1->y / 100 * winy) + offsy; s1[0] = (pt2->x / 100 * winx) + offsx; s1[1] = (pt2->y / 100 * winy) + offsy; - } + } /* calculate gradient and normal - 'angle'=(ny/nx) */ m1[1] = s1[1] - s0[1]; @@ -331,7 +331,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, if (i == 0) { /* draw start cap first * - make points slightly closer to center (about halfway across) - */ + */ mt[0] = m2[0] * pthick * 0.5f; mt[1] = m2[1] * pthick * 0.5f; sc[0] = s0[0] - (m1[0] * pthick * 0.75f); @@ -382,7 +382,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick) == 0)) { mt[0] += (mb[0] * dfac); mt[1] += (mb[1] * dfac); - } + } /* calculate points for start of segment */ t0[0] = s0[0] - mt[0]; @@ -420,7 +420,7 @@ static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, /* draw end cap as last step * - make points slightly closer to center (about halfway across) - */ + */ mt[0] = m2[0] * pthick * 0.5f; mt[1] = m2[1] * pthick * 0.5f; sc[0] = s1[0] + (m1[0] * pthick * 0.75f); @@ -531,7 +531,7 @@ static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int #endif } } - else if (gps->totpoints > 1) + else if (gps->totpoints > 1) gp_draw_stroke(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, offsx, offsy, winx, winy); } } @@ -611,7 +611,7 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, } else break; - } + } /* restore alpha */ glColor4fv(color); @@ -661,11 +661,11 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, /* ----- Grease Pencil Sketches Drawing API ------ */ -// ............................ -// XXX -// We need to review the calls below, since they may be/are not that suitable for -// the new ways that we intend to be drawing data... -// ............................ +/* ............................ + * XXX + * We need to review the calls below, since they may be/are not that suitable for + * the new ways that we intend to be drawing data... + * ............................ */ /* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */ void draw_gpencil_2dimage(const bContext *C) diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index b69db0040b5..a59a3f7a5ec 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -393,7 +393,7 @@ void paste_gpdata(Scene *scene) ScrArea *sa; /* get area that gp-data comes from */ - //sa= gpencil_data_findowner((bGPdata *)ale->owner); + //sa = gpencil_data_findowner((bGPdata *)ale->owner); sa = NULL; /* this should be the right frame... as it may be a pre-existing frame, diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 46df8ba5fac..ed8a1ea8280 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -212,7 +212,7 @@ static int gp_data_add_exec(bContext *C, wmOperator *op) bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); if (gpd_ptr == NULL) { - BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go"); + BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go"); return OPERATOR_CANCELLED; } else { @@ -260,7 +260,7 @@ static int gp_data_unlink_exec(bContext *C, wmOperator *op) bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); if (gpd_ptr == NULL) { - BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go"); + BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go"); return OPERATOR_CANCELLED; } else { @@ -299,7 +299,7 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op) /* if there's no existing Grease-Pencil data there, add some */ if (gpd_ptr == NULL) { - BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go"); + BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go"); return OPERATOR_CANCELLED; } if (*gpd_ptr == NULL) @@ -348,7 +348,7 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op) /* if there's no existing Grease-Pencil data there, add some */ if (gpd == NULL) { - BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data"); + BKE_report(op->reports, RPT_ERROR, "No grease pencil data"); return OPERATOR_CANCELLED; } if (ELEM(NULL, gpl, gpf)) { @@ -634,7 +634,7 @@ static int gp_convert_layer_exec(bContext *C, wmOperator *op) /* check if there's data to work with */ if (gpd == NULL) { - BKE_report(op->reports, RPT_ERROR, "No Grease Pencil data to work on"); + BKE_report(op->reports, RPT_ERROR, "No grease pencil data to work on"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index e5afbdba50b..42ea924522c 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -536,7 +536,7 @@ static void gp_stroke_simplify(tGPsdata *p) j += 2; } - } + } /* free old buffer */ MEM_freeN(old_points); @@ -860,7 +860,7 @@ static void gp_stroke_eraser_dostroke(tGPsdata *p, } } } - else { + else { /* loop over the points in the stroke, checking for intersections * - an intersection will require the stroke to be split */ @@ -959,8 +959,8 @@ static int gp_session_initdata(bContext *C, tGPsdata *p) /* supported views first */ case SPACE_VIEW3D: { - // View3D *v3d= curarea->spacedata.first; - // RegionView3D *rv3d= ar->regiondata; + // View3D *v3d = curarea->spacedata.first; + // RegionView3D *rv3d = ar->regiondata; /* set current area * - must verify that region data is 3D-view (and not something else) @@ -979,7 +979,7 @@ static int gp_session_initdata(bContext *C, tGPsdata *p) case SPACE_NODE: { - //SpaceNode *snode= curarea->spacedata.first; + //SpaceNode *snode = curarea->spacedata.first; /* set current area */ p->sa = curarea; @@ -1007,7 +1007,7 @@ static int gp_session_initdata(bContext *C, tGPsdata *p) break; case SPACE_IMAGE: { - //SpaceImage *sima= curarea->spacedata.first; + //SpaceImage *sima = curarea->spacedata.first; /* set the current area */ p->sa = curarea; @@ -1210,7 +1210,7 @@ static void gp_paint_initstroke(tGPsdata *p, short paintmode) /* make strokes be drawn in screen space */ p->gpd->sbuffer_sflag &= ~GP_STROKE_2DSPACE; p->gpd->flag &= ~GP_DATA_VIEWALIGN; - } + } else p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } @@ -1342,7 +1342,7 @@ static void gpencil_draw_exit(bContext *C, wmOperator *op) gp_session_cleanup(p); /* finally, free the temp data */ - MEM_freeN(p); + MEM_freeN(p); } op->customdata = NULL; @@ -1790,7 +1790,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) if (p->status == GP_STATUS_ERROR) { estate = OPERATOR_CANCELLED; } - } + } else { p->status = GP_STATUS_IDLING; } diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index f55f7755668..078762065b4 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -61,6 +61,7 @@ struct BMEditMesh; struct BMEditSelection; struct BMesh; struct BMVert; +struct BMLoop; struct MLoopCol; struct BMEdge; struct BMFace; @@ -118,6 +119,7 @@ void EDBM_update_generic(struct bContext *C, struct BMEditMesh *em, const short struct UvElementMap *EDBM_uv_element_map_create(struct BMEditMesh *em, int selected, int doIslands); void EDBM_uv_element_map_free(struct UvElementMap *vmap); +struct UvElement *ED_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l); int EDBM_mtexpoly_check(struct BMEditMesh *em); struct MTexPoly *EDBM_mtexpoly_active_get(struct BMEditMesh *em, struct BMFace **r_act_efa, int sloppy, int selected); diff --git a/source/blender/editors/include/ED_object.h b/source/blender/editors/include/ED_object.h index d6ac9eb750d..0d0b8d8e797 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -203,4 +203,3 @@ void ED_object_select_linked_by_id(struct bContext *C, struct ID *id); #endif #endif /* __ED_OBJECT_H__ */ - diff --git a/source/blender/editors/include/ED_screen_types.h b/source/blender/editors/include/ED_screen_types.h index 527ebb6c3ef..9f42fd042c3 100644 --- a/source/blender/editors/include/ED_screen_types.h +++ b/source/blender/editors/include/ED_screen_types.h @@ -94,7 +94,7 @@ typedef struct AZone { /* for draw */ short x1, y1, x2, y2; /* for clip */ - rcti rect; + rcti rect; } AZone; /* actionzone type */ diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index fc24f68f2d1..bd85e93f1af 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -263,6 +263,7 @@ void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d); int ED_view3d_scene_layer_set(int lay, const int *values, int *active); int ED_view3d_context_activate(struct bContext *C); +void ED_view3d_draw_offscreen_init(struct Scene *scene, struct View3D *v3d); void ED_view3d_draw_offscreen(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, int winx, int winy, float viewmat[][4], float winmat[][4], int do_bgpic, int colormanage_background); @@ -294,6 +295,7 @@ struct BGpic *ED_view3D_background_image_new(struct View3D *v3d); void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic); void ED_view3D_background_image_clear(struct View3D *v3d); +float ED_view3d_offset_distance(float mat[4][4], float ofs[3]); float ED_view3d_grid_scale(struct Scene *scene, struct View3D *v3d, const char **grid_unit); /* view matrix properties utilities */ diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 8f50edd1240..e400e44e944 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -94,7 +94,7 @@ DEF_ICON(LINK) DEF_ICON(INLINK) DEF_ICON(PLUGIN) - /* various ui */ + /* various ui */ DEF_ICON(HELP) DEF_ICON(GHOST_ENABLED) DEF_ICON(COLOR) @@ -799,13 +799,12 @@ DEF_ICON(NDOF_TRANS) DEF_ICON(LAYER_USED) DEF_ICON(LAYER_ACTIVE) #ifndef DEF_ICON_BLANK_SKIP + /* available */ DEF_ICON(BLANK254) DEF_ICON(BLANK255) DEF_ICON(BLANK256) DEF_ICON(BLANK257) DEF_ICON(BLANK257b) - - /* available */ DEF_ICON(BLANK258) DEF_ICON(BLANK259) DEF_ICON(BLANK260) @@ -890,8 +889,8 @@ DEF_ICON(FORWARD) DEF_ICON(BLANK313) DEF_ICON(BLANK314) DEF_ICON(BLANK315) - DEF_ICON(BLANK316) #endif +DEF_ICON(FILE_BACKUP) DEF_ICON(DISK_DRIVE) /* SHADING / TEXT */ diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 5d2709f0488..ed4b4ae027f 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -106,9 +106,9 @@ typedef struct uiLayout uiLayout; /* uiBlock->flag (controls) */ #define UI_BLOCK_LOOP 1 #define UI_BLOCK_REDRAW 2 -#define UI_BLOCK_RET_1 4 /* XXX 2.5 not implemented */ +#define UI_BLOCK_SEARCH_MENU 4 #define UI_BLOCK_NUMSELECT 8 -/*#define UI_BLOCK_ENTER_OK 16*/ /*UNUSED*/ +#define UI_BLOCK_NO_WIN_CLIP 16 /* don't apply window clipping */ /* was UI_BLOCK_ENTER_OK */ #define UI_BLOCK_CLIPBOTTOM 32 #define UI_BLOCK_CLIPTOP 64 #define UI_BLOCK_MOVEMOUSE_QUIT 128 diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index fcde4186778..b8e4fec1259 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -238,7 +238,7 @@ static void ui_text_bounds_block(uiBlock *block, float offset) bt->rect.xmax = bt->rect.xmin + i + block->bounds; if (col == lastcol) { - bt->rect.xmax = maxf(bt->rect.xmax, offset + block->minbounds); + bt->rect.xmax = max_ff(bt->rect.xmax, offset + block->minbounds); } ui_check_but(bt); /* clips text again */ @@ -275,7 +275,7 @@ void ui_bounds_block(uiBlock *block) block->rect.ymax += block->bounds; } - block->rect.xmax = block->rect.xmin + maxf(BLI_rctf_size_x(&block->rect), block->minbounds); + block->rect.xmax = block->rect.xmin + max_ff(BLI_rctf_size_x(&block->rect), block->minbounds); /* hardcoded exception... but that one is annoying with larger safety */ bt = block->buttons.first; @@ -527,7 +527,7 @@ static void ui_draw_links(uiBlock *block) foundselectline = TRUE; } } - } + } /* Draw any active lines (lines with either button being hovered over). * Do this last so they appear on top of inactive lines. */ @@ -539,7 +539,7 @@ static void ui_draw_links(uiBlock *block) ui_draw_linkline(line, !foundselectline); } } - } + } } } @@ -581,7 +581,7 @@ static void ui_but_update_linklines(uiBlock *block, uiBut *oldbut, uiBut *newbut if (line->from == newbut) line->from = oldbut; } - } + } /* check all other button links */ for (but = block->buttons.first; but; but = but->next) { @@ -610,28 +610,28 @@ static int ui_but_update_from_old_block(const bContext *C, uiBlock *block, uiBut if (ui_but_equals_old(oldbut, but)) { if (oldbut->active) { #if 0 -// but->flag= oldbut->flag; +// but->flag = oldbut->flag; #else /* exception! redalert flag can't be update from old button. * perhaps it should only copy specific flags rather than all. */ -// but->flag= (oldbut->flag & ~UI_BUT_REDALERT) | (but->flag & UI_BUT_REDALERT); +// but->flag = (oldbut->flag & ~UI_BUT_REDALERT) | (but->flag & UI_BUT_REDALERT); #endif -// but->active= oldbut->active; -// but->pos= oldbut->pos; -// but->ofs= oldbut->ofs; -// but->editstr= oldbut->editstr; -// but->editval= oldbut->editval; -// but->editvec= oldbut->editvec; -// but->editcoba= oldbut->editcoba; -// but->editcumap= oldbut->editcumap; -// but->selsta= oldbut->selsta; -// but->selend= oldbut->selend; -// but->softmin= oldbut->softmin; -// but->softmax= oldbut->softmax; -// but->linkto[0]= oldbut->linkto[0]; -// but->linkto[1]= oldbut->linkto[1]; +// but->active = oldbut->active; +// but->pos = oldbut->pos; +// but->ofs = oldbut->ofs; +// but->editstr = oldbut->editstr; +// but->editval = oldbut->editval; +// but->editvec = oldbut->editvec; +// but->editcoba = oldbut->editcoba; +// but->editcumap = oldbut->editcumap; +// but->selsta = oldbut->selsta; +// but->selend = oldbut->selend; +// but->softmin = oldbut->softmin; +// but->softmax = oldbut->softmax; +// but->linkto[0] = oldbut->linkto[0]; +// but->linkto[1] = oldbut->linkto[1]; found = 1; -// oldbut->active= NULL; +// oldbut->active = NULL; /* move button over from oldblock to new block */ BLI_remlink(&oldblock->buttons, oldbut); @@ -1270,7 +1270,7 @@ void ui_delete_linkline(uiLinkLine *line, uiBut *but) (*(link->ppoin))[b] = (*(link->ppoin))[a]; b++; } - } + } (*(link->totlink))--; } } @@ -1303,7 +1303,7 @@ void ui_get_but_vectorf(uiBut *but, float vec[3]) if (RNA_property_type(prop) == PROP_FLOAT) { tot = RNA_property_array_length(&but->rnapoin, prop); - tot = MIN2(tot, 3); + tot = min_ii(tot, 3); for (a = 0; a < tot; a++) vec[a] = RNA_property_float_get_index(&but->rnapoin, prop, a); @@ -1348,7 +1348,7 @@ void ui_set_but_vectorf(uiBut *but, const float vec[3]) int a; tot = RNA_property_array_length(&but->rnapoin, prop); - tot = MIN2(tot, 3); + tot = min_ii(tot, 3); for (a = 0; a < tot; a++) { RNA_property_float_set_index(&but->rnapoin, prop, a, vec[a]); @@ -1391,7 +1391,7 @@ int ui_is_but_unit(uiBut *but) return 0; #endif - /* for now disable time unit conversion */ + /* for now disable time unit conversion */ if (unit_type == PROP_UNIT_TIME) return 0; @@ -1464,16 +1464,16 @@ double ui_get_but_val(uiBut *but) case 'S': value = hsv[1]; break; case 'V': value = hsv[2]; break; } - } + } else if (but->pointype == UI_BUT_POIN_CHAR) { value = *(char *)but->poin; } else if (but->pointype == UI_BUT_POIN_SHORT) { value = *(short *)but->poin; - } + } else if (but->pointype == UI_BUT_POIN_INT) { value = *(int *)but->poin; - } + } else if (but->pointype == UI_BUT_POIN_FLOAT) { value = *(float *)but->poin; } @@ -1697,7 +1697,7 @@ void ui_get_but_string(uiBut *but, char *str, size_t maxlen) } else if (buf && buf != str) { /* string was too long, we have to truncate */ - memcpy(str, buf, MIN2(maxlen, buf_len + 1)); + memcpy(str, buf, MIN2(maxlen, (size_t)buf_len + 1)); MEM_freeN(buf); } } @@ -1947,8 +1947,8 @@ void ui_set_but_soft_range(uiBut *but, double value) RNA_property_int_ui_range(&but->rnapoin, but->rnaprop, &imin, &imax, &istep); softmin = (imin == INT_MIN) ? -1e4 : imin; softmax = (imin == INT_MAX) ? 1e4 : imax; - /*step= istep;*/ /*UNUSED*/ - /*precision= 1;*/ /*UNUSED*/ + /*step = istep;*/ /*UNUSED*/ + /*precision = 1;*/ /*UNUSED*/ if (array_len >= 2) { int value_range[2]; @@ -1964,8 +1964,8 @@ void ui_set_but_soft_range(uiBut *but, double value) RNA_property_float_ui_range(&but->rnapoin, but->rnaprop, &fmin, &fmax, &fstep, &fprecision); softmin = (fmin == -FLT_MAX) ? (float)-1e4 : fmin; softmax = (fmax == FLT_MAX) ? (float)1e4 : fmax; - /*step= fstep;*/ /*UNUSED*/ - /*precision= fprecision;*/ /*UNUSED*/ + /*step = fstep;*/ /*UNUSED*/ + /*precision = fprecision;*/ /*UNUSED*/ if (array_len >= 2) { float value_range[2]; @@ -2006,7 +2006,7 @@ void ui_set_but_soft_range(uiBut *but, double value) static void ui_free_link(uiLink *link) { - if (link) { + if (link) { BLI_freelistN(&link->lines); MEM_freeN(link); } @@ -2055,7 +2055,7 @@ void uiFreeBlock(const bContext *C, uiBlock *block) uiBut *but; while ( (but = block->buttons.first) ) { - BLI_remlink(&block->buttons, but); + BLI_remlink(&block->buttons, but); ui_free_but(C, but); } @@ -2256,7 +2256,7 @@ void ui_check_but(uiBut *but) /* safety is 4 to enable small number buttons (like 'users') */ - // okwidth= -4 + (BLI_rcti_size_x(&but->rect)); // UNUSED + // okwidth = -4 + (BLI_rcti_size_x(&but->rect)); // UNUSED /* name: */ switch (but->type) { @@ -2398,7 +2398,7 @@ void uiBlockBeginAlign(uiBlock *block) /* if other align was active, end it */ if (block->flag & UI_BUT_ALIGN) uiBlockEndAlign(block); - block->flag |= UI_BUT_ALIGN_DOWN; + block->flag |= UI_BUT_ALIGN_DOWN; block->alignnr++; /* buttons declared after this call will get this align nr */ // XXX flag? @@ -2439,7 +2439,7 @@ static void ui_block_do_align_but(uiBut *first, short nr) } } - /* rows==0: 1 row, cols==0: 1 column */ + /* rows == 0: 1 row, cols == 0: 1 column */ /* note; how it uses 'flag' in loop below (either set it, or OR it) is confusing */ for (but = first, prev = NULL; but && but->alignnr == nr; prev = but, but = but->next) { diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 010df0cbfbc..a73954e2075 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -160,13 +160,13 @@ void uiDrawBoxShade(int mode, float minx, float miny, float maxx, float maxy, fl /* get current color, needs to be outside of glBegin/End */ glGetFloatv(GL_CURRENT_COLOR, color); - /* 'shade' defines strength of shading */ - coltop[0] = minf(1.0f, color[0] + shadetop); - coltop[1] = minf(1.0f, color[1] + shadetop); - coltop[2] = minf(1.0f, color[2] + shadetop); - coldown[0] = maxf(0.0f, color[0] + shadedown); - coldown[1] = maxf(0.0f, color[1] + shadedown); - coldown[2] = maxf(0.0f, color[2] + shadedown); + /* 'shade' defines strength of shading */ + coltop[0] = min_ff(1.0f, color[0] + shadetop); + coltop[1] = min_ff(1.0f, color[1] + shadetop); + coltop[2] = min_ff(1.0f, color[2] + shadetop); + coldown[0] = max_ff(0.0f, color[0] + shadedown); + coldown[1] = max_ff(0.0f, color[1] + shadedown); + coldown[2] = max_ff(0.0f, color[2] + shadedown); glShadeModel(GL_SMOOTH); glBegin(mode); @@ -269,13 +269,13 @@ void uiDrawBoxVerticalShade(int mode, float minx, float miny, float maxx, float /* get current color, needs to be outside of glBegin/End */ glGetFloatv(GL_CURRENT_COLOR, color); - /* 'shade' defines strength of shading */ - colLeft[0] = minf(1.0f, color[0] + shadeLeft); - colLeft[1] = minf(1.0f, color[1] + shadeLeft); - colLeft[2] = minf(1.0f, color[2] + shadeLeft); - colRight[0] = maxf(0.0f, color[0] + shadeRight); - colRight[1] = maxf(0.0f, color[1] + shadeRight); - colRight[2] = maxf(0.0f, color[2] + shadeRight); + /* 'shade' defines strength of shading */ + colLeft[0] = min_ff(1.0f, color[0] + shadeLeft); + colLeft[1] = min_ff(1.0f, color[1] + shadeLeft); + colLeft[2] = min_ff(1.0f, color[2] + shadeLeft); + colRight[0] = max_ff(0.0f, color[0] + shadeRight); + colRight[1] = max_ff(0.0f, color[1] + shadeRight); + colRight[2] = max_ff(0.0f, color[2] + shadeRight); glShadeModel(GL_SMOOTH); glBegin(mode); @@ -510,7 +510,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) if (G.selfont && BKE_vfont_is_builtin(G.selfont) == FALSE) { /* Is the font file packed, if so then use the packed file */ if (G.selfont->packedfile) { - pf = G.selfont->packedfile; + pf = G.selfont->packedfile; FTF_SetFont(pf->data, pf->size, 14.0); } else { @@ -608,7 +608,7 @@ static void ui_draw_but_CHARTAB(uiBut *but) ey -= buth; sx = rect->xmin; ex = rect->xmin + butw; - } + } glShadeModel(GL_FLAT); /* Return Font Settings to original */ @@ -1221,7 +1221,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *rect) glColor3ub(255, 255, 255); glVertex2fv(v2); glVertex2fv(v3); - } + } } glEnd(); @@ -1707,7 +1707,7 @@ static void ui_shadowbox(float minx, float miny, float maxx, float maxy, float s glVertex2f(maxx, miny - shadsize); glEnd(); - /* bottom quad */ + /* bottom quad */ glBegin(GL_POLYGON); glColor4ub(0, 0, 0, alpha); glVertex2f(minx + 0.3f * shadsize, miny); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index c4440cf07ed..55b20bddd80 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -704,7 +704,7 @@ static int ui_but_mouse_inside_icon(uiBut *but, ARegion *ar, wmEvent *event) BLI_rcti_rctf_copy(&rect, &but->rect); - if (but->imb) { + if (but->imb) { /* use button size itself */ } else if (but->flag & UI_ICON_LEFT) { @@ -774,7 +774,7 @@ static void ui_delete_active_linkline(uiBlock *block) (*(link->ppoin))[b] = (*(link->ppoin))[a]; b++; } - } + } (*(link->totlink))--; } } @@ -1063,7 +1063,7 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut break; case HSVSLI: break; - case TOG3: + case TOG3: ui_apply_but_TOG3(C, but, data); break; case MENU: @@ -1109,10 +1109,10 @@ static void ui_apply_button(bContext *C, uiBlock *block, uiBut *but, uiHandleBut case INLINK: ui_apply_but_LINK(C, but, data); break; - case BUT_IMAGE: + case BUT_IMAGE: ui_apply_but_IMAGE(C, but, data); break; - case HISTOGRAM: + case HISTOGRAM: ui_apply_but_HISTOGRAM(C, but, data); break; case WAVEFORM: @@ -1299,6 +1299,71 @@ static void ui_but_copy_paste(bContext *C, uiBut *but, uiHandleButtonData *data, } } +/* ************************ password text ****************************** + * + * Functions to convert password strings that should not be displayed + * to asterisk representation (e.g. mysecretpasswd -> *************) + * + * It converts every UTF-8 character to an asterisk, and also remaps + * the cursor position and selection start/end. + * + * Note: remaping is used, because password could contain UTF-8 characters. + * + */ + +static int ui_text_position_from_hidden(uiBut *but, int pos) +{ + const char *strpos; + int i; + + for (i = 0, strpos = but->drawstr; i < pos; i++) + strpos = BLI_str_find_next_char_utf8(strpos, NULL); + + return (strpos - but->drawstr); +} + +static int ui_text_position_to_hidden(uiBut *but, int pos) +{ + return BLI_strnlen_utf8(but->drawstr, pos); +} + +void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, int restore) +{ + if (!(but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_PASSWORD)) + return; + + if (restore) { + /* restore original string */ + BLI_strncpy(but->drawstr, password_str, UI_MAX_DRAW_STR); + + /* remap cursor positions */ + if (but->pos >= 0) { + but->pos = ui_text_position_from_hidden(but, but->pos); + but->selsta = ui_text_position_from_hidden(but, but->selsta); + but->selend = ui_text_position_from_hidden(but, but->selend); + } + } + else { + /* convert text to hidden test using asterisks (e.g. pass -> ****) */ + int i, len = BLI_strlen_utf8(but->drawstr); + + /* remap cursor positions */ + if (but->pos >= 0) { + but->pos = ui_text_position_to_hidden(but, but->pos); + but->selsta = ui_text_position_to_hidden(but, but->selsta); + but->selend = ui_text_position_to_hidden(but, but->selend); + } + + /* save original string */ + BLI_strncpy(password_str, but->drawstr, UI_MAX_DRAW_STR); + + for (i = 0; i < len; i++) + but->drawstr[i] = '*'; + but->drawstr[i] = '\0'; + } +} + + /* ************* in-button text selection/editing ************* */ @@ -1322,13 +1387,15 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho uiStyle *style = UI_GetStyle(); // XXX pass on as arg uiFontStyle *fstyle = &style->widget; int startx = but->rect.xmin; - char *origstr; + char *origstr, password_str[UI_MAX_DRAW_STR]; uiStyleFontSet(fstyle); if (fstyle->kerning == 1) /* for BLF_width */ BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + ui_button_text_password_hide(password_str, but, FALSE); + origstr = MEM_callocN(sizeof(char) * data->maxlen, "ui_textedit origstr"); BLI_strncpy(origstr, but->drawstr, data->maxlen); @@ -1343,7 +1410,7 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho } /* mouse dragged outside the widget to the left */ - if (x < startx && but->ofs > 0) { + if (x < startx && but->ofs > 0) { int i = but->ofs; origstr[but->ofs] = 0; @@ -1407,6 +1474,8 @@ static void ui_textedit_set_cursor_pos(uiBut *but, uiHandleButtonData *data, sho if (fstyle->kerning == 1) BLF_disable(fstyle->uifont_id, BLF_KERNING_DEFAULT); + ui_button_text_password_hide(password_str, but, TRUE); + MEM_freeN(origstr); } @@ -1587,7 +1656,7 @@ static int ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directio but->pos -= step; changed = 1; } - } + } } return changed; @@ -1676,7 +1745,7 @@ static int ui_textedit_copypaste(uiBut *but, uiHandleButtonData *data, int paste if (cut) if ((but->selend - but->selsta) > 0) changed = ui_textedit_delete_selection(but, data); - } + } return changed; } @@ -1715,7 +1784,7 @@ static void ui_textedit_begin(bContext *C, uiBut *but, uiHandleButtonData *data) /* optional searchbox */ if (but->type == SEARCH_MENU) { data->searchbox = ui_searchbox_create(C, data->region, but); - ui_searchbox_update(C, data->searchbox, but, 1); /* 1= reset */ + ui_searchbox_update(C, data->searchbox, but, 1); /* 1 = reset */ } ui_check_but(but); @@ -2157,7 +2226,7 @@ static void ui_blockopen_begin(bContext *C, uiBut *but, uiHandleButtonData *data } /* this makes adjacent blocks auto open from now on */ - //if (but->block->auto_open ==0 ) but->block->auto_open = 1; + //if (but->block->auto_open == 0) but->block->auto_open = 1; } static void ui_blockopen_end(bContext *C, uiBut *but, uiHandleButtonData *data) @@ -2254,7 +2323,7 @@ static int ui_do_but_HOTKEYEVT(bContext *C, uiBut *but, uiHandleButtonData *data ED_region_tag_redraw(data->region); if (event->val == KM_PRESS) { - if (ISHOTKEY(event->type)) { + if (ISHOTKEY(event->type)) { if (WM_key_event_string(event->type)[0]) ui_set_but_val(but, event->type); @@ -2935,7 +3004,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton data->value = temp; else data->cancel = TRUE; - } + } else { if (f < tempf) tempf -= 0.01f; else tempf += 0.01f; @@ -2961,7 +3030,7 @@ static int ui_do_but_SLI(bContext *C, uiBlock *block, uiBut *but, uiHandleButton static int ui_do_but_SCROLL(bContext *C, uiBlock *block, uiBut *but, uiHandleButtonData *data, wmEvent *event) { - int mx, my /*, click= 0 */; + int mx, my /*, click = 0 */; int retval = WM_UI_HANDLER_CONTINUE; int horizontal = (BLI_rctf_size_x(&but->rect) > BLI_rctf_size_y(&but->rect)); @@ -3336,7 +3405,7 @@ static void ui_ndofedit_but_HSVCUBE(uiBut *but, uiHandleButtonData *data, wmNDOF case UI_GRAD_V: hsv[2] += ndof->ry * sensitivity; break; - case UI_GRAD_V_ALT: + case UI_GRAD_V_ALT: /* vertical 'value' strip */ /* exception only for value strip - use the range set in but->min/max */ @@ -3460,7 +3529,7 @@ static int ui_numedit_but_HSVCIRCLE(uiBut *but, uiHandleButtonData *data, float data->ungrab_mval[0] = mx_fl; data->ungrab_mval[1] = my_fl; { /* clamp */ - const float radius = minf(BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect)) / 2.0f; + const float radius = min_ff(BLI_rctf_size_x(&but->rect), BLI_rctf_size_y(&but->rect)) / 2.0f; const float cent[2] = {BLI_rctf_cent_x(&but->rect), BLI_rctf_cent_y(&but->rect)}; const float len = len_v2v2(cent, data->ungrab_mval); if (len > radius) { @@ -3747,8 +3816,8 @@ static int ui_numedit_but_CURVE(uiBut *but, uiHandleButtonData *data, int snap, zoomx = BLI_rctf_size_x(&but->rect) / BLI_rctf_size_x(&cumap->curr); zoomy = BLI_rctf_size_y(&but->rect) / BLI_rctf_size_y(&cumap->curr); - /* offsx= cumap->curr.xmin; */ - /* offsy= cumap->curr.ymin; */ + /* offsx = cumap->curr.xmin; */ + /* offsy = cumap->curr.ymin; */ if (snap) { float d[2]; @@ -3904,7 +3973,7 @@ static int ui_do_but_CURVE(bContext *C, uiBlock *block, uiBut *but, uiHandleButt changed = 1; - /* reset cmp back to the curve points again, rather than drawing segments */ + /* reset cmp back to the curve points again, rather than drawing segments */ cmp = cuma->curve; /* find newly added point and make it 'sel' */ @@ -4008,7 +4077,7 @@ static int ui_numedit_but_HISTOGRAM(uiBut *but, uiHandleButtonData *data, int mx } else { /* scale histogram values (dy / 10 for better control) */ - const float yfac = minf(powf(hist->ymax, 2.0f), 1.0f) * 0.5f; + const float yfac = min_ff(powf(hist->ymax, 2.0f), 1.0f) * 0.5f; hist->ymax += (dy * 0.1f) * yfac; /* 0.1 allows us to see HDR colors up to 10 */ @@ -4078,7 +4147,7 @@ static int ui_numedit_but_WAVEFORM(uiBut *but, uiHandleButtonData *data, int mx, Scopes *scopes = (Scopes *)but->poin; /* rcti rect; */ int changed = 1; - float /* dx, */ dy /* , yfac=1.f */; /* UNUSED */ + float /* dx, */ dy /* , yfac =1.0f */; /* UNUSED */ /* BLI_rcti_rctf_copy(&rect, &but->rect); */ @@ -4508,11 +4577,11 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) int kmi_id; /* XXX this guess_opname can potentially return a different keymap than being found on adding later... */ - km = WM_keymap_guess_opname(C, but->optype->idname); + km = WM_keymap_guess_opname(C, but->optype->idname); kmi = WM_keymap_add_item(km, but->optype->idname, AKEY, KM_PRESS, 0, 0); kmi_id = kmi->id; - /* copy properties, prop can be NULL for reset */ + /* copy properties, prop can be NULL for reset */ if (prop) prop = IDP_CopyProperty(prop); WM_keymap_properties_reset(kmi, prop); @@ -4520,14 +4589,13 @@ static uiBlock *menu_add_shortcut(bContext *C, ARegion *ar, void *arg) /* update and get pointers again */ WM_keyconfig_update(wm); - km = WM_keymap_guess_opname(C, but->optype->idname); + km = WM_keymap_guess_opname(C, but->optype->idname); kmi = WM_keymap_item_find_id(km, kmi_id); RNA_pointer_create(&wm->id, &RNA_KeyMapItem, kmi, &ptr); block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); uiBlockSetHandleFunc(block, but_shortcut_name_func, but); - uiBlockSetFlag(block, UI_BLOCK_RET_1); uiBlockSetDirection(block, UI_CENTER); layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, 200, 20, style); @@ -4865,14 +4933,11 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) if (but->flag & UI_BUT_DISABLED) return WM_UI_HANDLER_CONTINUE; - if ((data->state == BUTTON_STATE_HIGHLIGHT) && - /* check prevval because of modal operators [#24016], - * modifier check is to allow Ctrl+C for copy. - * if this causes other problems, remove this check and suffer the bug :) - campbell */ - ((event->prevval != KM_PRESS) || (ISKEYMODIFIER(event->prevtype)) || (event->type == EVT_DROP))) + if ((data->state == BUTTON_STATE_HIGHLIGHT) || (event->type == EVT_DROP)) { /* handle copy-paste */ if (ELEM(event->type, CKEY, VKEY) && event->val == KM_PRESS && (event->ctrl || event->oskey)) { + ui_but_copy_paste(C, but, data, (event->type == CKEY) ? 'c' : 'v'); return WM_UI_HANDLER_BREAK; } @@ -4954,7 +5019,7 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, wmEvent *event) button_activate_state(C, but, BUTTON_STATE_EXIT); return WM_UI_HANDLER_BREAK; } - } + } else if (but->pointype && but->poin == NULL) { /* there's a pointer needed */ BKE_reportf(NULL, RPT_WARNING, "DoButton pointer error: %s", but->str); @@ -6027,7 +6092,7 @@ static int ui_handle_button_event(bContext *C, wmEvent *event, uiBut *but) } else { retval = ui_do_button(C, block, but, event); - // retval= WM_UI_HANDLER_BREAK; XXX why ? + // retval = WM_UI_HANDLER_BREAK; XXX why ? } if (data->state == BUTTON_STATE_EXIT) { @@ -6380,7 +6445,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle break; /* opening sublevels of pulldowns */ - case RIGHTARROWKEY: + case RIGHTARROWKEY: if (event->val == KM_PRESS && (block->flag & UI_BLOCK_LOOP)) { PASS_EVENT_TO_PARENT_IF_NONACTIVE; @@ -6567,7 +6632,7 @@ static int ui_handle_menu_event(bContext *C, wmEvent *event, uiPopupBlockHandle case YKEY: case ZKEY: { - if ((event->val == KM_PRESS) && + if ((event->val == KM_PRESS || event->val == KM_DBL_CLICK) && (event->shift == FALSE) && (event->ctrl == FALSE) && (event->oskey == FALSE)) diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 0921107b8e6..bb0cc1176d8 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -142,7 +142,7 @@ static void def_internal_icon(ImBuf *bbuf, int icon_id, int xofs, int yofs, int new_icon = MEM_callocN(sizeof(Icon), "texicon"); new_icon->obj = NULL; /* icon is not for library object */ - new_icon->type = 0; + new_icon->type = 0; di = MEM_callocN(sizeof(DrawInfo), "drawinfo"); di->type = type; @@ -852,7 +852,7 @@ static void icon_set_image(bContext *C, ID *id, PreviewImage *prv_img, enum eIco if (G.debug & G_DEBUG) printf("%s: no preview image for this ID: %s\n", __func__, id->name); return; - } + } icon_create_rect(prv_img, size); @@ -982,8 +982,8 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al if (!di) { di = icon_create_drawinfo(); - icon->drawinfo = di; - icon->drawinfo_free = UI_icons_free_drawinfo; + icon->drawinfo = di; + icon->drawinfo_free = UI_icons_free_drawinfo; } /* scale width and height according to aspect */ @@ -994,13 +994,13 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al /* vector icons use the uiBlock transformation, they are not drawn * with untransformed coordinates like the other icons */ di->data.vector.func((int)x, (int)y, ICON_DEFAULT_HEIGHT, ICON_DEFAULT_HEIGHT, 1.0f); - } + } else if (di->type == ICON_TYPE_TEXTURE) { icon_draw_texture(x, y, (float)w, (float)h, di->data.texture.x, di->data.texture.y, di->data.texture.w, di->data.texture.h, alpha, rgb); } else if (di->type == ICON_TYPE_BUFFER) { - /* it is a builtin icon */ + /* it is a builtin icon */ iimg = di->data.buffer.image; if (!iimg->rect) return; /* something has gone wrong! */ @@ -1010,7 +1010,7 @@ static void icon_draw_size(float x, float y, int icon_id, float aspect, float al else if (di->type == ICON_TYPE_PREVIEW) { PreviewImage *pi = BKE_previewimg_get((ID *)icon->obj); - if (pi) { + if (pi) { /* no create icon on this level in code */ if (!pi->rect[size]) return; /* something has gone wrong! */ diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index b4b0686d6fc..98b75060aa8 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -160,7 +160,8 @@ struct uiBut { int flag, drawflag; eButType type; eButPointerType pointype; - short bit, bitnr, retval, strwidth, ofs, pos, selsta, selend, alignnr; + short bit, bitnr, retval, strwidth, alignnr; + short ofs, pos, selsta, selend; char *str; char strdata[UI_MAX_NAME_STR]; @@ -484,6 +485,7 @@ extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut extern void ui_button_active_free(const struct bContext *C, uiBut *but); extern int ui_button_is_active(struct ARegion *ar); extern int ui_button_open_menu_direction(uiBut *but); +extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, int restore); /* interface_widgets.c */ void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 8e30b31f3fe..5170fc7d51b 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -41,6 +41,7 @@ #include "BLI_string.h" #include "BLI_rect.h" #include "BLI_utildefines.h" +#include "BLI_math.h" #include "BLF_translation.h" @@ -1313,7 +1314,7 @@ static void rna_search_cb(const struct bContext *C, void *arg_but, const char *s BLI_addtail(items_list, cis); } MEM_freeN(name); - } + } i++; } @@ -1376,7 +1377,7 @@ void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRN /* turn button into search button */ if (searchprop) { but->type = SEARCH_MENU; - but->hardmax = MAX2(but->hardmax, 256); + but->hardmax = MAX2(but->hardmax, 256.0f); but->rnasearchpoin = *searchptr; but->rnasearchprop = searchprop; but->flag |= UI_ICON_LEFT | UI_TEXT_LEFT; @@ -1449,6 +1450,11 @@ static void ui_item_menutype_func(bContext *C, uiLayout *layout, void *arg_mt) menu.type = mt; menu.layout = layout; + + if (G.debug & G_DEBUG_WM) { + printf("%s: opening menu \"%s\"\n", __func__, mt->idname); + } + mt->draw(C, &menu); } @@ -1708,7 +1714,7 @@ static void ui_litem_layout_row(uiLayout *litem) int x, y, w, tot, totw, neww, itemw, minw, itemh, offset; int fixedw, freew, fixedx, freex, flag = 0, lastw = 0; - /* x= litem->x; */ /* UNUSED */ + /* x = litem->x; */ /* UNUSED */ y = litem->y; w = litem->w; totw = 0; @@ -1932,8 +1938,8 @@ static void ui_litem_estimate_column_flow(uiLayout *litem) return; } - flow->totcol = MAX2(litem->root->emw / maxw, 1); - flow->totcol = MIN2(flow->totcol, totitem); + flow->totcol = max_ii(litem->root->emw / maxw, 1); + flow->totcol = min_ii(flow->totcol, totitem); } else flow->totcol = flow->number; @@ -2007,7 +2013,7 @@ static void ui_litem_layout_column_flow(uiLayout *litem) emy -= itemh; ui_item_position(item, x + offset, y, itemw, itemh); y -= style->buttonspacey; - miny = MIN2(miny, y); + miny = min_ii(miny, y); /* decide to go to next one */ if (col < flow->totcol - 1 && emy <= -emh) { @@ -2038,8 +2044,8 @@ static void ui_litem_estimate_absolute(uiLayout *litem) ui_item_offset(item, &itemx, &itemy); ui_item_size(item, &itemw, &itemh); - minx = MIN2(minx, itemx); - miny = MIN2(miny, itemy); + minx = min_ii(minx, itemx); + miny = min_ii(miny, itemy); litem->w = MAX2(litem->w, itemx + itemw); litem->h = MAX2(litem->h, itemy + itemh); @@ -2064,11 +2070,11 @@ static void ui_litem_layout_absolute(uiLayout *litem) ui_item_offset(item, &itemx, &itemy); ui_item_size(item, &itemw, &itemh); - minx = MIN2(minx, itemx); - miny = MIN2(miny, itemy); + minx = min_ii(minx, itemx); + miny = min_ii(miny, itemy); - totw = MAX2(totw, itemx + itemw); - toth = MAX2(toth, itemy + itemh); + totw = max_ii(totw, itemx + itemw); + toth = max_ii(toth, itemy + itemh); } totw -= minx; diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 017ffdcfb14..e7a5f993d32 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -807,7 +807,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op, } if (text == NULL) { - BKE_reportf(op->reports, RPT_WARNING, "File: '%s' can't be opened", filepath); + BKE_reportf(op->reports, RPT_WARNING, "File '%s' cannot be opened", filepath); return OPERATOR_CANCELLED; } else { @@ -870,12 +870,12 @@ static int editsource_exec(bContext *C, wmOperator *op) but_store->py_dbg_ln); } else { - BKE_report(op->reports, RPT_ERROR, "Active button isn't from a script, cant edit source"); + BKE_report(op->reports, RPT_ERROR, "Active button is not from a script, cannot edit source"); ret = OPERATOR_CANCELLED; } } else { - BKE_report(op->reports, RPT_ERROR, "Active button match can't be found"); + BKE_report(op->reports, RPT_ERROR, "Active button match cannot be found"); ret = OPERATOR_CANCELLED; } @@ -973,12 +973,12 @@ static int edittranslation_exec(bContext *C, wmOperator *op) uiStringInfo rna_ctxt = {BUT_GET_RNA_LABEL_CONTEXT, NULL}; if (!BLI_is_dir(root)) { - BKE_report(op->reports, RPT_ERROR, "Please set your User Preferences' \"Translation Branches " - "Directory\" path to a valid directory"); + BKE_report(op->reports, RPT_ERROR, "Please set your User Preferences' 'Translation Branches " + "Directory' path to a valid directory"); return OPERATOR_CANCELLED; } if (!WM_operatortype_find(EDTSRC_I18N_OP_NAME, 0)) { - BKE_reportf(op->reports, RPT_ERROR, "Could not find operator \"%s\"! Please enable ui_translate addon " + BKE_reportf(op->reports, RPT_ERROR, "Could not find operator '%s'! Please enable ui_translate addon " "in the User Preferences", EDTSRC_I18N_OP_NAME); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 49e96bea6c6..2b170ea546b 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -240,7 +240,7 @@ Panel *uiBeginPanel(ScrArea *sa, ARegion *ar, uiBlock *block, PanelType *pt, int } } } - } + } } } @@ -545,7 +545,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) if (!(panel->flag & PNL_CLOSEDX)) { ui_draw_aligned_panel_header(style, block, &headrect, 'h'); - /* itemrect smaller */ + /* itemrect smaller */ itemrect.xmax = headrect.xmax - 5.0f / block->aspect; itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect); itemrect.ymin = headrect.ymin; @@ -594,7 +594,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, rcti *rect) /* draw collapse icon */ UI_ThemeColor(TH_TEXT); - /* itemrect smaller */ + /* itemrect smaller */ itemrect.xmin = headrect.xmin + 5.0f / block->aspect; itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&headrect); itemrect.ymin = headrect.ymin; @@ -814,8 +814,8 @@ static void ui_panels_size(ScrArea *sa, ARegion *ar, int *x, int *y) pa_sizey = pa->ofsy + get_panel_size_y(pa); } - sizex = MAX2(sizex, pa_sizex); - sizey = MIN2(sizey, pa_sizey); + sizex = max_ii(sizex, pa_sizex); + sizey = min_ii(sizey, pa_sizey); } } @@ -831,7 +831,7 @@ static void ui_do_animate(const bContext *C, Panel *panel) float fac; fac = (PIL_check_seconds_timer() - data->starttime) / ANIMATION_TIME; - fac = minf(sqrt(fac), 1.0f); + fac = min_ff(sqrt(fac), 1.0f); /* for max 1 second, interpolate positions */ if (uiAlignPanelStep(sa, ar, fac, 0)) { @@ -895,7 +895,7 @@ void uiEndPanels(const bContext *C, ARegion *ar, int *x, int *y) panew->paneltab = NULL; ED_region_tag_redraw(ar); /* the buttons panew were not made */ } - } + } } /* re-align, possibly with animation */ @@ -1200,7 +1200,7 @@ int ui_handler_panel_region(bContext *C, wmEvent *event) ED_region_tag_redraw(ar); retval = WM_UI_HANDLER_BREAK; - } + } } } #endif diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 14cb1cbe85a..f522af51c42 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -46,6 +46,7 @@ #include "BKE_context.h" #include "BKE_screen.h" +#include "BKE_global.h" #include "WM_api.h" #include "WM_types.h" @@ -213,7 +214,7 @@ static MenuData *decompose_menu_string(const char *str) else { menudata_add_item(md, nitem, nretval, nicon, 0); nretval = md->nitems + 1; - } + } nitem = NULL; nicon = 0; @@ -670,7 +671,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but) for (a = 0, fontw = 0, fonth = 0; a < data->totline; a++) { w = BLF_width(data->fstyle.uifont_id, data->lines[a]); - fontw = MAX2(fontw, w); + fontw = max_ff(fontw, (float)w); fonth += (a == 0) ? h : h + TIP_MARGIN_Y; } @@ -1159,7 +1160,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) /* special case, hardcoded feature, not draw backdrop when called from menus, * assume for design that popup already added it */ - if (but->block->flag & UI_BLOCK_LOOP) + if (but->block->flag & UI_BLOCK_SEARCH_MENU) data->noback = 1; if (but->a1 > 0 && but->a2 > 0) { @@ -1169,7 +1170,7 @@ ARegion *ui_searchbox_create(bContext *C, ARegion *butregion, uiBut *but) } /* compute position */ - if (but->block->flag & UI_BLOCK_LOOP) { + if (but->block->flag & UI_BLOCK_SEARCH_MENU) { /* this case is search menu inside other menu */ /* we copy region size */ @@ -1463,7 +1464,7 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, if (top == 0 && down == 0) { if (dir1 == UI_LEFT || dir1 == UI_RIGHT) { /* align with bottom of screen */ - // yof= ysize; (not with menu scrolls) + // yof = ysize; (not with menu scrolls) } } @@ -1548,7 +1549,11 @@ static void ui_block_region_draw(const bContext *C, ARegion *ar) static void ui_popup_block_clip(wmWindow *window, uiBlock *block) { int winx, winy; - + + if (block->flag & UI_BLOCK_NO_WIN_CLIP) { + return; + } + wm_window_get_size(window, &winx, &winy); if (block->rect.xmin < MENU_SHADOW_SIDE) @@ -1950,7 +1955,7 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3]) else if (bt->str[0] == 'V') { ui_set_but_val(bt, hsv[2]); } - } + } ui_check_but(bt); } @@ -2377,7 +2382,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi uiBlockSetFlag(block, UI_BLOCK_MOVEMOUSE_QUIT); if (pup->popup) { - uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_NUMSELECT | UI_BLOCK_RET_1); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_NUMSELECT); uiBlockSetDirection(block, direction); /* offset the mouse position, possibly based on earlier selection */ @@ -2396,7 +2401,7 @@ static uiBlock *ui_block_func_POPUP(bContext *C, uiPopupBlockHandle *handle, voi * on the first item */ offset[0] = 0; for (bt = block->buttons.first; bt; bt = bt->next) - offset[0] = mini(offset[0], -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect))); + offset[0] = min_ii(offset[0], -(bt->rect.xmin + 0.8f * BLI_rctf_size_x(&bt->rect))); offset[1] = 1.5 * UI_UNIT_Y; } @@ -2506,6 +2511,9 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) pup->block->flag |= UI_BLOCK_POPUP_MEMORY; pup->block->puphash = ui_popup_menu_hash(title); pup->layout = uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); + + /* note, this intentionally differs from the menu & submenu default because many operators + * use popups like this to select one of their options - where having invoke doesn't make sense */ uiLayoutSetOperatorContext(pup->layout, WM_OP_EXEC_REGION_WIN); /* create in advance so we can let buttons point to retval already */ @@ -2717,6 +2725,10 @@ void uiPupMenuInvoke(bContext *C, const char *idname) menu.layout = layout; menu.type = mt; + if (G.debug & G_DEBUG_WM) { + printf("%s: opening menu \"%s\"\n", __func__, idname); + } + mt->draw(C, &menu); uiPupMenuEnd(C, pup); diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index acf7712f97b..7e7db6aeaaa 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -348,7 +348,7 @@ void uiStyleInit(void) #else font->blf_id = BLF_load_mem("default", (unsigned char *)datatoc_bfont_ttf, datatoc_bfont_ttf_size); #endif - } + } else { font->blf_id = BLF_load(font->filename); if (font->blf_id == -1) diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 974d492a364..c7e6a5f2882 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -175,7 +175,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) idptr = RNA_property_pointer_get(&template.ptr, template.prop); block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU); /* preview thumbnails */ if (template.prv_rows > 0 && template.prv_cols > 0) { @@ -199,7 +199,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) uiBoundsBlock(block, 6); - uiBlockSetDirection(block, UI_DOWN); + uiBlockSetDirection(block, UI_DOWN); uiEndBlock(C, block); /* give search-field focus */ @@ -401,7 +401,7 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str //text_idbutton(id, name); name[0] = '\0'; - but = uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, NULL); + but = uiDefButR(block, TEX, 0, name, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, &idptr, "name", -1, 0, 0, -1, -1, RNA_struct_ui_description(type)); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_RENAME)); if (user_alert) uiButSetFlag(but, UI_BUT_REDALERT); @@ -581,7 +581,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co RNA_warning("pointer property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); return; } - if (!propType || RNA_property_type(propType) != PROP_ENUM) { + if (!propType || RNA_property_type(propType) != PROP_ENUM) { RNA_warning("pointer-type property not found: %s.%s", RNA_struct_identifier(ptr->type), proptypename); return; } @@ -1222,7 +1222,7 @@ void uiTemplatePreview(uiLayout *layout, ID *id, int show_buttons, ID *parent, M else ma = (Material *)pparent; /* Create RNA Pointer */ - RNA_pointer_create(id, &RNA_Material, ma, &material_ptr); + RNA_pointer_create(&ma->id, &RNA_Material, ma, &material_ptr); col = uiLayoutColumn(row, TRUE); uiLayoutSetScaleX(col, 1.5); @@ -1282,7 +1282,7 @@ static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v) if (colorband_element_add(coba, pos)) { rna_update_cb(C, cb_v, NULL); - ED_undo_push(C, "Add colorband"); + ED_undo_push(C, "Add colorband"); } } @@ -1406,7 +1406,7 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand uiItemR(layout, &ptr, "color", 0, "", ICON_NONE); } - bt = uiDefButS(block, MENU, 0, TIP_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"), + bt = uiDefButS(block, MENU, 0, IFACE_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"), xs + 10.0f * unit, butr->ymin + UI_UNIT_Y, unit * 4, UI_UNIT_Y, &coba->ipotype, 0.0, 0.0, 0, 0, TIP_("Set interpolation between color stops")); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); @@ -2745,7 +2745,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) uiDefIconTextBut(block, BUT, B_STOPCAST, ICON_CANCEL, IFACE_("Capture"), 0, 0, 85, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop screencast")); if (screen->animtimer) - uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, TIP_("Anim Player"), 0, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, + uiDefIconTextBut(block, BUT, B_STOPANIM, ICON_CANCEL, IFACE_("Anim Player"), 0, 0, 100, UI_UNIT_Y, NULL, 0.0f, 0.0f, 0, 0, TIP_("Stop animation playback")); } @@ -2775,8 +2775,8 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) block = uiLayoutGetBlock(ui_abs); width = BLF_width(style->widget.uifont_id, report->message); - width = MIN2(rti->widthfac * width, width); - width = MAX2(width, 10); + width = min_ii((int)(rti->widthfac * width), width); + width = max_ii(width, 10); /* make a box around the report to make it stand out */ uiBlockBeginAlign(block); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 3203237496f..238024a0856 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -345,7 +345,7 @@ static void round_box__edges(uiWidgetBase *wt, int roundboxalign, rcti *rect, fl const int vnum = ((roundboxalign & (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)) == (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) || (roundboxalign & (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) == (UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT)) ? 1 : 2; - minsize = mini(BLI_rcti_size_x(rect) * hnum, + minsize = min_ii(BLI_rcti_size_x(rect) * hnum, BLI_rcti_size_y(rect) * vnum); if (2.0f * rad > minsize) @@ -491,7 +491,7 @@ static void widget_num_tria(uiWidgetTrias *tria, rcti *rect, float triasize, cha float centx, centy, sizex, sizey, minsize; int a, i1 = 0, i2 = 1; - minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); + minsize = min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); /* center position and size */ centx = (float)rect->xmin + 0.5f * minsize; @@ -501,16 +501,16 @@ static void widget_num_tria(uiWidgetTrias *tria, rcti *rect, float triasize, cha if (where == 'r') { centx = (float)rect->xmax - 0.5f * minsize; sizex = -sizex; - } + } else if (where == 't') { centy = (float)rect->ymax - 0.5f * minsize; sizey = -sizey; i2 = 0; i1 = 1; - } + } else if (where == 'b') { sizex = -sizex; i2 = 0; i1 = 1; - } + } for (a = 0; a < 3; a++) { tria->vec[a][0] = sizex * num_tria_vert[a][i1] + centx; @@ -526,7 +526,7 @@ static void widget_scroll_circle(uiWidgetTrias *tria, rcti *rect, float triasize float centx, centy, sizex, sizey, minsize; int a, i1 = 0, i2 = 1; - minsize = mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); + minsize = min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); /* center position and size */ centx = (float)rect->xmin + 0.5f * minsize; @@ -536,16 +536,16 @@ static void widget_scroll_circle(uiWidgetTrias *tria, rcti *rect, float triasize if (where == 'r') { centx = (float)rect->xmax - 0.5f * minsize; sizex = -sizex; - } + } else if (where == 't') { centy = (float)rect->ymax - 0.5f * minsize; sizey = -sizey; i2 = 0; i1 = 1; - } + } else if (where == 'b') { sizex = -sizex; i2 = 0; i1 = 1; - } + } for (a = 0; a < 16; a++) { tria->vec[a][0] = sizex * scroll_circle_vert[a][i1] + centx; @@ -572,12 +572,12 @@ static void widget_menu_trias(uiWidgetTrias *tria, rcti *rect) /* center position and size */ centx = rect->xmax - 0.5f * BLI_rcti_size_y(rect); centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect); - size = 0.4f * BLI_rcti_size_y(rect); + size = 0.4f * (float)BLI_rcti_size_y(rect); /* XXX exception */ asp = ((float)BLI_rcti_size_x(rect)) / ((float)BLI_rcti_size_y(rect)); if (asp > 1.2f && asp < 2.6f) - centx = rect->xmax - 0.3f * BLI_rcti_size_y(rect); + centx = rect->xmax - 0.4f * (float)BLI_rcti_size_y(rect); for (a = 0; a < 6; a++) { tria->vec[a][0] = size * menu_tria_vert[a][0] + centx; @@ -878,7 +878,7 @@ static void widget_draw_icon(uiBut *but, BIFIconID icon, float alpha, rcti *rect aspect = but->block->aspect; if (aspect != but->aspect) { /* prevent scaling up icon in pupmenu */ - if (aspect < 1.0f) { + if (aspect < 1.0f) { height = UI_DPI_ICON_SIZE; aspect = 1.0f; @@ -1276,9 +1276,12 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b /* draws text and icons for buttons */ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) { - if (but == NULL) { + char password_str[UI_MAX_DRAW_STR]; + + if (but == NULL) return; - } + + ui_button_text_password_hide(password_str, but, FALSE); /* clip but->drawstr to fit in available space */ if (but->editstr && but->pos >= 0) { @@ -1337,6 +1340,8 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB widget_draw_text(fstyle, wcol, but, rect); } + + ui_button_text_password_hide(password_str, but, TRUE); } @@ -1852,7 +1857,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir else if (direction == UI_DOWN) { roundboxalign = (UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT); rect->ymin -= 4.0; - } + } else if (direction == UI_TOP) { roundboxalign = UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT; rect->ymax += 4.0; @@ -1895,7 +1900,7 @@ void ui_hsvcircle_vals_from_pos(float *val_rad, float *val_dist, const rcti *rec /* duplication of code... well, simple is better now */ const float centx = BLI_rcti_cent_x_fl(rect); const float centy = BLI_rcti_cent_y_fl(rect); - const float radius = (float)mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f; + const float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f; const float m_delta[2] = {mx - centx, my - centy}; const float dist_squared = len_squared_v2(m_delta); @@ -1910,7 +1915,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * const float centx = BLI_rcti_cent_x_fl(rect); const float centy = BLI_rcti_cent_y_fl(rect); - float radius = (float)mini(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f; + float radius = (float)min_ii(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)) / 2.0f; /* gouraud triangle fan */ const float *hsv_ptr = ui_block_hsv_get(but->block); @@ -2364,7 +2369,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat wtb.emboss = 0; /* only emboss once */ /* exception for progress bar */ - if (state & UI_SCROLL_NO_OUTLINE) + if (state & UI_SCROLL_NO_OUTLINE) SWAP(short, outline, wtb.outline); round_box_edges(&wtb, UI_CNR_ALL, slider, rad); @@ -2388,7 +2393,7 @@ void uiWidgetScrollDraw(uiWidgetColors *wcol, rcti *rect, rcti *slider, int stat if (state & UI_SCROLL_NO_OUTLINE) SWAP(short, outline, wtb.outline); - } + } } static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign)) @@ -2402,7 +2407,7 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat value = ui_get_but_val(but); size = (but->softmax + but->a1 - but->softmin); - size = MAX2(size, 2); + size = max_ff(size, 2.0f); /* position */ rect1 = *rect; @@ -2423,7 +2428,7 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat if (rect1.xmax > rect->xmax) { rect1.xmax = rect->xmax; - rect1.xmin = maxi(rect1.xmax - min, rect->xmin); + rect1.xmin = max_ii(rect1.xmax - min, rect->xmin); } } } @@ -2440,7 +2445,7 @@ static void widget_scroll(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat if (rect1.ymax > rect->ymax) { rect1.ymax = rect->ymax; - rect1.ymin = MAX2(rect1.ymax - min, rect->ymin); + rect1.ymin = max_ii(rect1.ymax - min, rect->ymin); } } } @@ -2627,7 +2632,7 @@ static void widget_icon_has_anim(uiBut *UNUSED(but), uiWidgetColors *wcol, rcti /* rounded */ round_box_edges(&wtb, UI_CNR_ALL, rect, 10.0f); widgetbase_draw(&wtb, wcol); - } + } } @@ -2662,8 +2667,8 @@ static void widget_menubut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), widgetbase_draw(&wtb, wcol); - /* text space */ - rect->xmax -= BLI_rcti_size_y(rect); + /* text space, arrows are about 0.6 height of button */ + rect->xmax -= (6*BLI_rcti_size_y(rect))/10; } static void widget_menuiconbut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign) @@ -3346,7 +3351,7 @@ void ui_draw_menu_back(uiStyle *UNUSED(style), uiBlock *block, rcti *rect) glColor3ubv((unsigned char *)wt->wcol.text); UI_DrawTriIcon(BLI_rcti_cent_x(rect), rect->ymin + 10, 'v'); } - } + } } uiWidgetColors *ui_tooltip_get_theme(void) diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index a964052cc23..de79a290cb3 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -655,7 +655,7 @@ void ui_theme_init_default(void) strcpy(btheme->name, "Default"); } - UI_SetTheme(0, 0); // make sure the global used in this file is set + UI_SetTheme(0, 0); /* make sure the global used in this file is set */ /* UI buttons */ ui_widget_color_init(&btheme->tui); @@ -814,9 +814,9 @@ void ui_theme_init_default(void) rgba_char_args_set_fl(btheme->tfile.list, 0.4, 0.4, 0.4, 1); rgba_char_args_set(btheme->tfile.text, 250, 250, 250, 255); rgba_char_args_set(btheme->tfile.text_hi, 15, 15, 15, 255); - rgba_char_args_set(btheme->tfile.panel, 145, 145, 145, 255); // bookmark/ui regions - rgba_char_args_set(btheme->tfile.active, 130, 130, 130, 255); // selected files - rgba_char_args_set(btheme->tfile.hilite, 255, 140, 25, 255); // selected files + rgba_char_args_set(btheme->tfile.panel, 145, 145, 145, 255); /* bookmark/ui regions */ + rgba_char_args_set(btheme->tfile.active, 130, 130, 130, 255); /* selected files */ + rgba_char_args_set(btheme->tfile.hilite, 255, 140, 25, 255); /* selected files */ rgba_char_args_set(btheme->tfile.grid, 250, 250, 250, 255); rgba_char_args_set(btheme->tfile.image, 250, 250, 250, 255); @@ -897,7 +897,7 @@ void ui_theme_init_default(void) btheme->ttime = btheme->tv3d; rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0); rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0); - rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); // sliders + rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); /* sliders */ /* space node, re-uses syntax color storage */ btheme->tnode = btheme->tv3d; @@ -938,7 +938,7 @@ void ui_theme_init_default(void) void UI_SetTheme(int spacetype, int regionid) { - if (spacetype == 0) { // called for safety, when delete themes + if (spacetype == 0) { /* called for safety, when delete themes */ theme_active = U.themes.first; theme_spacetype = SPACE_VIEW3D; theme_regionid = RGN_TYPE_WINDOW; @@ -956,7 +956,7 @@ bTheme *UI_GetTheme(void) return U.themes.first; } -// for space windows only +/* for space windows only */ void UI_ThemeColor(int colorid) { const unsigned char *cp; @@ -966,7 +966,7 @@ void UI_ThemeColor(int colorid) } -// plus alpha +/* plus alpha */ void UI_ThemeColor4(int colorid) { const unsigned char *cp; @@ -976,7 +976,7 @@ void UI_ThemeColor4(int colorid) } -// set the color with offset for shades +/* set the color with offset for shades */ void UI_ThemeColorShade(int colorid, int offset) { int r, g, b; @@ -1009,7 +1009,7 @@ void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset) glColor4ub(r, g, b, a); } -// blend between to theme colors, and set it +/* blend between to theme colors, and set it */ void UI_ThemeColorBlend(int colorid1, int colorid2, float fac) { int r, g, b; @@ -1026,7 +1026,7 @@ void UI_ThemeColorBlend(int colorid1, int colorid2, float fac) glColor3ub(r, g, b); } -// blend between to theme colors, shade it, and set it +/* blend between to theme colors, shade it, and set it */ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset) { int r, g, b; @@ -1047,7 +1047,7 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset) glColor3ub(r, g, b); } -// blend between to theme colors, shade it, and set it +/* blend between to theme colors, shade it, and set it */ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int offset, int alphaoffset) { int r, g, b, a; @@ -1071,7 +1071,7 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off } -// get individual values, not scaled +/* get individual values, not scaled */ float UI_GetThemeValuef(int colorid) { const unsigned char *cp; @@ -1081,7 +1081,7 @@ float UI_GetThemeValuef(int colorid) } -// get individual values, not scaled +/* get individual values, not scaled */ int UI_GetThemeValue(int colorid) { const unsigned char *cp; @@ -1092,7 +1092,7 @@ int UI_GetThemeValue(int colorid) } -// get the color, range 0.0-1.0 +/* get the color, range 0.0-1.0 */ void UI_GetThemeColor3fv(int colorid, float col[3]) { const unsigned char *cp; @@ -1114,7 +1114,7 @@ void UI_GetThemeColor4fv(int colorid, float col[4]) col[3] = ((float)cp[3]) / 255.0f; } -// get the color, range 0.0-1.0, complete with shading offset +/* get the color, range 0.0-1.0, complete with shading offset */ void UI_GetThemeColorShade3fv(int colorid, int offset, float col[3]) { int r, g, b; @@ -1153,7 +1153,7 @@ void UI_GetThemeColorShade3ubv(int colorid, int offset, unsigned char col[3]) col[2] = b; } -// get the color, in char pointer +/* get the color, in char pointer */ void UI_GetThemeColor3ubv(int colorid, unsigned char col[3]) { const unsigned char *cp; @@ -1164,7 +1164,7 @@ void UI_GetThemeColor3ubv(int colorid, unsigned char col[3]) col[2] = cp[2]; } -// get the color, in char pointer +/* get the color, in char pointer */ void UI_GetThemeColor4ubv(int colorid, unsigned char col[4]) { const unsigned char *cp; @@ -1187,7 +1187,7 @@ void UI_GetThemeColorType4ubv(int colorid, int spacetype, char col[4]) col[3] = cp[3]; } -// blends and shades between two char color pointers +/* blends and shades between two char color pointers */ void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], float fac, int offset) { int r, g, b; @@ -1220,7 +1220,7 @@ void UI_GetColorPtrShade3ubv(const unsigned char cp[3], unsigned char col[3], in col[2] = b; } -// get a 3 byte color, blended and shaded between two other char color pointers +/* get a 3 byte color, blended and shaded between two other char color pointers */ void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char cp2[3], unsigned char col[3], float fac, int offset) { @@ -1366,7 +1366,7 @@ void init_userdef_do_versions(void) btheme->ttime = btheme->tv3d; rgba_char_args_set_fl(btheme->ttime.back, 0.45, 0.45, 0.45, 1.0); rgba_char_args_set_fl(btheme->ttime.grid, 0.36, 0.36, 0.36, 1.0); - rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); // sliders + rgba_char_args_set(btheme->ttime.shade1, 173, 173, 173, 255); /* sliders */ } if (btheme->text.syntaxn[3] == 0) { rgba_char_args_set(btheme->text.syntaxn, 0, 0, 200, 255); /* Numbers Blue*/ diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 47bee92be62..fb7a2615583 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -299,7 +299,7 @@ void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy) /* other view types are completely defined using their own settings already */ default: /* we don't do anything here, as settings should be fine, but just make sure that rect */ - break; + break; } } @@ -476,8 +476,14 @@ void UI_view2d_curRect_validate_resize(View2D *v2d, int resize) if (winy < v2d->oldwiny) { float temp = v2d->oldwiny - winy; - cur->ymin += temp; - cur->ymax += temp; + if (v2d->align & V2D_ALIGN_NO_NEG_Y) { + cur->ymin -= temp; + cur->ymax -= temp; + } + else { /* Assume V2D_ALIGN_NO_POS_Y or combination */ + cur->ymin += temp; + cur->ymax += temp; + } } } @@ -1089,7 +1095,7 @@ static void step_to_grid(float *step, int *power, int unit) } /* prevents printing 1.0 2.0 3.0 etc */ - if (rem == 1.0f) (*power)++; + if (rem == 1.0f) (*power)++; } else { if (rem < 2.0f) rem = 2.0f; @@ -1100,7 +1106,7 @@ static void step_to_grid(float *step, int *power, int unit) (*power)++; /* prevents printing 1.0, 2.0, 3.0, etc. */ - if (rem == 10.0f) (*power)++; + if (rem == 10.0f) (*power)++; } } @@ -1256,7 +1262,7 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) vec2[1] = vec1[1] -= 0.5f * grid->dy; step++; - if (flag & V2D_HORIZONTAL_FINELINES) { + if (flag & V2D_HORIZONTAL_FINELINES) { UI_ThemeColorShade(TH_GRID, 16); for (a = 0; a < step; a++) { glBegin(GL_LINE_STRIP); @@ -1487,7 +1493,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, /* check whether sliders can disappear due to the full-range being used */ if (v2d->keeptot) { - if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) { + if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) { v2d->scroll |= V2D_SCROLL_HORIZONTAL_FULLR; scrollers->horfull = 1; } @@ -1529,7 +1535,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, /* check whether sliders can disappear due to the full-range being used */ if (v2d->keeptot) { - if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) { + if ((fac1 <= 0.0f) && (fac2 >= 1.0f)) { v2d->scroll |= V2D_SCROLL_VERTICAL_FULLR; scrollers->vertfull = 1; } @@ -1682,7 +1688,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v if (fac < hor.xmin + 10) continue; - switch (vs->xunits) { + switch (vs->xunits) { case V2D_UNIT_FRAMES: /* frames (as whole numbers)*/ scroll_printstr(scene, fac, h, val, grid->powerx, V2D_UNIT_FRAMES, 'h'); break; @@ -1797,7 +1803,7 @@ void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *v BLF_disable_default(BLF_ROTATION); } - } + } } } @@ -2066,7 +2072,7 @@ short UI_view2d_mouse_in_scrollers(const bContext *C, View2D *v2d, int x, int y) } if (scroll & V2D_SCROLL_VERTICAL) { if (IN_2D_VERT_SCROLL(v2d, co)) return 'v'; - } + } /* not found */ return 0; diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 12e04d392b4..48a1f8bf0f3 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -642,7 +642,7 @@ static void view_zoomstep_apply(bContext *C, wmOperator *op) v2d->cur.ymin += ofs + dy; v2d->cur.ymax += ofs - dy; - } + } else { v2d->cur.ymin += dy; v2d->cur.ymax -= dy; @@ -956,7 +956,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, wmEvent *event) view_zoomdrag_apply(C, op); view_zoomdrag_exit(C, op); return OPERATOR_FINISHED; - } + } /* set initial settings */ vzd->lastx = event->x; @@ -1065,7 +1065,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, wmEvent *event) /* apply zooming */ view_zoomdrag_apply(C, op); - } + } else if (event->type == vzd->invoke_event || event->type == ESCKEY) { if (event->val == KM_RELEASE) { @@ -1243,16 +1243,16 @@ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b) for (i = 0; i < 2; i++) { /* axis translation normalized to scale */ - tfac = fabsf(cent_a[i] - cent_b[i]) / minf(size_a[i], size_b[i]); - fac_max = maxf(fac_max, tfac); + tfac = fabsf(cent_a[i] - cent_b[i]) / min_ff(size_a[i], size_b[i]); + fac_max = max_ff(fac_max, tfac); if (fac_max >= 1.0f) break; /* axis scale difference, x2 so doubling or half gives 1.0f */ - tfac = (1.0f - (minf(size_a[i], size_b[i]) / maxf(size_a[i], size_b[i]))) * 2.0f; - fac_max = maxf(fac_max, tfac); + tfac = (1.0f - (min_ff(size_a[i], size_b[i]) / max_ff(size_a[i], size_b[i]))) * 2.0f; + fac_max = max_ff(fac_max, tfac); if (fac_max >= 1.0f) break; } - return minf(fac_max, 1.0f); + return min_ff(fac_max, 1.0f); } /* will start timer if appropriate */ @@ -1469,7 +1469,7 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_ else if (in_min) return SCROLLHANDLE_MIN; else if (out_min) - return SCROLLHANDLE_MIN_OUTSIDE; + return SCROLLHANDLE_MIN_OUTSIDE; else if (out_max) return SCROLLHANDLE_MAX_OUTSIDE; @@ -1751,7 +1751,7 @@ static int scroller_activate_invoke(bContext *C, wmOperator *op, wmEvent *event) /* can't catch this event for ourselves, so let it go to someone else? */ return OPERATOR_PASS_THROUGH; - } + } } /* zone is also inappropriate if scroller is not visible... */ diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 490389c6d0c..1c23df1c11e 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -408,7 +408,7 @@ static void draw_spline_curve(const bContext *C, MaskLayer *masklay, MaskSpline const short is_active, int width, int height) { - const unsigned int resol = maxi(BKE_mask_spline_feather_resolution(spline, width, height), + const unsigned int resol = max_ii(BKE_mask_spline_feather_resolution(spline, width, height), BKE_mask_spline_resolution(spline, width, height)); unsigned char rgb_tmp[4]; @@ -579,7 +579,7 @@ void ED_mask_draw_region(Mask *mask, ARegion *ar, y += v2d->tot.ymin * zoomy; /* frame the image */ - maxdim = maxf(width, height); + maxdim = max_ff(width, height); if (width == height) { xofs = yofs = 0; } diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index dc204909577..cd1a47754f8 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -34,6 +34,7 @@ #include "BLI_utildefines.h" #include "BLI_rect.h" #include "BLI_lasso.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_mask.h" @@ -622,7 +623,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) /* compute ellipse and position in unified coordinates */ ED_mask_get_size(sa, &width, &height); ED_mask_zoom(sa, ar, &zoomx, &zoomy); - width = height = MAX2(width, height); + width = height = max_ii(width, height); ellipse[0] = width * zoomx / radius; ellipse[1] = height * zoomy / radius; diff --git a/source/blender/editors/mesh/CMakeLists.txt b/source/blender/editors/mesh/CMakeLists.txt index 9aa3f3633f3..417cf92c29f 100644 --- a/source/blender/editors/mesh/CMakeLists.txt +++ b/source/blender/editors/mesh/CMakeLists.txt @@ -73,4 +73,8 @@ if(WITH_INTERNATIONAL) add_definitions(-DWITH_INTERNATIONAL) endif() +if(WITH_BULLET) + add_definitions(-DWITH_BULLET) +endif() + blender_add_lib(bf_editor_mesh "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/mesh/SConscript b/source/blender/editors/mesh/SConscript index 923bb3f9057..91ffdc91685 100644 --- a/source/blender/editors/mesh/SConscript +++ b/source/blender/editors/mesh/SConscript @@ -27,4 +27,7 @@ else: if env['WITH_BF_INTERNATIONAL']: defs.append('WITH_INTERNATIONAL') +if env['WITH_BF_BULLET']: + defs.append('WITH_BULLET') + env.BlenderLib ( 'bf_editors_mesh', sources, Split(incs), defs, libtype=['core'], priority=[45] ) diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 99ed86d7a06..70b359d3e28 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -476,7 +476,7 @@ static int add_primitive_uvsphere_exec(bContext *C, wmOperator *op) make_prim_finish(C, obedit, &state, enter_editmode); - return OPERATOR_FINISHED; + return OPERATOR_FINISHED; } void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot) diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 1d19d35ca34..82447cc0168 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -181,6 +181,7 @@ typedef struct KnifeTool_OpData { char select_result; /* set on initialization */ short is_ortho; + float ortho_extent; float clipsta, clipend; enum { @@ -1164,7 +1165,7 @@ static BMEdgeHit *knife_edge_tri_isect(KnifeTool_OpData *kcd, BMBVHTree *bmtree, /* for comparing distances, error of intersection depends on triangle scale. * need to scale down before squaring for accurate comparison */ - const float depsilon = (KNIFE_FLT_EPS / 2.0f) * len_v3_tri_side_max(v1, v2, v3); + const float depsilon = (FLT_EPSILON / 2.0f) * len_v3_tri_side_max(v1, v2, v3); const float depsilon_squared = depsilon * depsilon; copy_v3_v3(cos + 0, v1); @@ -1311,6 +1312,22 @@ static void knife_bgl_get_mats(KnifeTool_OpData *UNUSED(kcd), bglMats *mats) //copy_m4_m4(mats->projection, kcd->vc.rv3d->winmat); } +/* Calculate maximum excursion (doubled) from (0,0,0) of mesh */ +static void calc_ortho_extent(KnifeTool_OpData *kcd) +{ + BMIter iter; + BMVert *v; + BMesh* bm = kcd->em->bm; + float max_xyz = 0.0f; + int i; + + BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) { + for (i = 0; i < 3; i++) + max_xyz = max_ff(max_xyz, fabs(v->co[i])); + } + kcd->ortho_extent = 2 * max_xyz; +} + /* Finds visible (or all, if cutting through) edges that intersects the current screen drag line */ static void knife_find_line_hits(KnifeTool_OpData *kcd) { @@ -1353,8 +1370,10 @@ static void knife_find_line_hits(KnifeTool_OpData *kcd) * (which may involve using doubles everywhere!), * limit the distance between these points */ if (kcd->is_ortho) { - limit_dist_v3(v1, v3, 200.0f); - limit_dist_v3(v2, v4, 200.0f); + if (kcd->ortho_extent == 0.0f) + calc_ortho_extent(kcd); + limit_dist_v3(v1, v3, kcd->ortho_extent + 10.0f); + limit_dist_v3(v2, v4, kcd->ortho_extent + 10.0f); } BLI_smallhash_init(ehash); @@ -1506,7 +1525,7 @@ static float knife_snap_size(KnifeTool_OpData *kcd, float maxsize) if (density < 1.0f) density = 1.0f; - return minf(maxsize / (density * 0.5f), maxsize); + return min_ff(maxsize / (density * 0.5f), maxsize); } /* p is closest point on edge to the mouse cursor */ diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 98fae2cc701..8e5c89adfca 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -419,7 +419,7 @@ static int ringcut_invoke(bContext *C, wmOperator *op, wmEvent *evt) float dist = 75.0f; if (modifiers_isDeformedByLattice(obedit) || modifiers_isDeformedByArmature(obedit)) - BKE_report(op->reports, RPT_WARNING, "Loop cut doesn't work well on deformed edit mesh display"); + BKE_report(op->reports, RPT_WARNING, "Loop cut does not work well on deformed edit mesh display"); view3d_operator_needs_opengl(C); @@ -505,7 +505,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event) if (event->val == KM_RELEASE) break; - cuts = MAX2(cuts - 1, 0); + cuts = max_ii(cuts - 1, 0); RNA_int_set(op->ptr, "number_cuts", cuts); ringsel_find_edge(lcd, cuts); show_cuts = TRUE; @@ -527,7 +527,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event) ED_region_tag_redraw(lcd->ar); break; - } + } } /* using the keyboard to input the number of cuts */ diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index 8fe2aa4b1a7..6379bdbc0ca 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -496,21 +496,21 @@ static void edbm_tagged_loop_pairs_do_fill_faces(BMesh *bm, UnorderedLoopPair *u l_iter = BM_FACE_FIRST_LOOP(f); if (f_verts[3]) { - BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, ulp->l_pair[0]), l_iter); l_iter = l_iter->next; - BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, ulp->l_pair[1]->next), l_iter); l_iter = l_iter->next; - BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, ulp->l_pair[1]), l_iter); l_iter = l_iter->next; - BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, ulp->l_pair[0]->next), l_iter); + BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter); l_iter = l_iter->next; + BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, l_iter), l_iter); l_iter = l_iter->next; + BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, l_iter), l_iter); l_iter = l_iter->next; + BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter); } else { if (v_shared == f_verts[0]) { - BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, ulp->l_pair[0]->next), l_iter); l_iter = l_iter->next; - BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, ulp->l_pair[0]), l_iter); l_iter = l_iter->next; - BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, ulp->l_pair[1]->next), l_iter); + BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter); l_iter = l_iter->next; + BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter); l_iter = l_iter->next; + BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, l_iter), l_iter); } else { - BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, ulp->l_pair[0]->next), l_iter); l_iter = l_iter->next; - BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, ulp->l_pair[0]), l_iter); l_iter = l_iter->next; - BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, ulp->l_pair[1]), l_iter); + BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter); l_iter = l_iter->next; + BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[0]->e, l_iter), l_iter); l_iter = l_iter->next; + BM_elem_attrs_copy(bm, bm, BM_edge_other_loop(ulp->l_pair[1]->e, l_iter), l_iter); } } @@ -1007,7 +1007,7 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, wmEvent *event) * with modified selection */ // WM_operator_name_call(C, "MESH_OT_region_to_loop", WM_OP_INVOKE_DEFAULT, NULL); - BKE_report(op->reports, RPT_ERROR, "Can't rip selected faces"); + BKE_report(op->reports, RPT_ERROR, "Cannot rip selected faces"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index bc792037443..99eee19f66d 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -1333,7 +1333,7 @@ static int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, B EDBM_index_arrays_init(em, 1, 1, 0); targetnum = BM_elem_index_get(target); - while (!BLI_heap_empty(heap)) { + while (!BLI_heap_is_empty(heap)) { mednum = GET_INT_FROM_POINTER(BLI_heap_popmin(heap)); e = EDBM_edge_at_index(em, mednum); @@ -1444,7 +1444,7 @@ static int mouse_mesh_shortest_path(bContext *C, int mval[2]) case EDGE_MODE_TAG_SHARP: me->drawflag |= ME_DRAWSHARP; break; - case EDGE_MODE_TAG_CREASE: + case EDGE_MODE_TAG_CREASE: me->drawflag |= ME_DRAWCREASES; break; case EDGE_MODE_TAG_BEVEL: @@ -1717,7 +1717,7 @@ void EDBM_selectmode_convert(BMEditMesh *em, const short selectmode_old, const s BM_edge_select_set(em->bm, eed, TRUE); } } - } + } else if (selectmode_new == SCE_SELECT_FACE) { BMIter liter; BMLoop *l; @@ -2482,7 +2482,7 @@ static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op) */ if (em->selectmode == SCE_SELECT_FACE) { - BKE_report(op->reports, RPT_ERROR, "Doesn't work in face selection mode"); + BKE_report(op->reports, RPT_ERROR, "Does not work in face selection mode"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index ee615093c86..9d3cc7b7c76 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -255,7 +255,7 @@ static short edbm_extrude_discrete_faces(BMEditMesh *em, wmOperator *op, const c return 0; } - return 's'; // s is shrink/fatten + return 's'; /* s is shrink/fatten */ } /* extrudes individual edges */ @@ -275,7 +275,7 @@ static short edbm_extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char return 0; } - return 'n'; // n is normal grab + return 'n'; /* n is normal grab */ } /* extrudes individual vertices */ @@ -295,7 +295,7 @@ static short edbm_extrude_verts_indiv(BMEditMesh *em, wmOperator *op, const char return 0; } - return 'g'; // g is grab + return 'g'; /* g is grab */ } static short edbm_extrude_edge(Object *obedit, BMEditMesh *em, const char hflag, float nor[3]) @@ -1666,6 +1666,88 @@ void MESH_OT_vertices_smooth(wmOperatorType *ot) RNA_def_boolean(ot->srna, "zaxis", 1, "Z-Axis", "Smooth along the Z axis"); } +static int edbm_do_smooth_laplacian_vertex_exec(bContext *C, wmOperator *op) +{ + Object *obedit = CTX_data_edit_object(C); + BMEditMesh *em = BMEdit_FromObject(obedit); + int usex = TRUE, usey = TRUE, usez = TRUE, volume_preservation = TRUE; + int i, repeat; + float lambda; + float lambda_border; + BMIter fiter; + BMFace *f; + + /* Check if select faces are triangles */ + BM_ITER_MESH (f, &fiter, em->bm, BM_FACES_OF_MESH) { + if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { + if (f->len > 4) { + BKE_report(op->reports, RPT_WARNING, "Selected faces must be triangles or quads"); + return OPERATOR_CANCELLED; + } + } + } + + /* mirror before smooth */ + if (((Mesh *)obedit->data)->editflag & ME_EDIT_MIRROR_X) { + EDBM_verts_mirror_cache_begin(em, TRUE); + } + + repeat = RNA_int_get(op->ptr, "repeat"); + lambda = RNA_float_get(op->ptr, "lambda"); + lambda_border = RNA_float_get(op->ptr, "lambda_border"); + usex = RNA_boolean_get(op->ptr, "use_x"); + usey = RNA_boolean_get(op->ptr, "use_y"); + usez = RNA_boolean_get(op->ptr, "use_z"); + volume_preservation = RNA_boolean_get(op->ptr, "volume_preservation"); + if (!repeat) + repeat = 1; + + for (i = 0; i < repeat; i++) { + if (!EDBM_op_callf(em, op, + "smooth_laplacian_vert verts=%hv lambda=%f lambda_border=%f use_x=%b use_y=%b use_z=%b volume_preservation=%b", + BM_ELEM_SELECT, lambda, lambda_border, usex, usey, usez, volume_preservation)) + { + return OPERATOR_CANCELLED; + } + } + + /* apply mirror */ + if (((Mesh *)obedit->data)->editflag & ME_EDIT_MIRROR_X) { + EDBM_verts_mirror_apply(em, BM_ELEM_SELECT, 0); + EDBM_verts_mirror_cache_end(em); + } + + EDBM_update_generic(C, em, TRUE); + + return OPERATOR_FINISHED; +} + +void MESH_OT_vertices_smooth_laplacian(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Laplacian Smooth Vertex"; + ot->description = "Laplacian smooth of selected vertices"; + ot->idname = "MESH_OT_vertices_smooth_laplacian"; + + /* api callbacks */ + ot->exec = edbm_do_smooth_laplacian_vertex_exec; + ot->poll = ED_operator_editmesh; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + RNA_def_int(ot->srna, "repeat", 1, 1, 200, + "Number of iterations to smooth the mesh", "", 1, 200); + RNA_def_float(ot->srna, "lambda", 0.00005f, 0.0000001f, 1000.0f, + "Lambda factor", "", 0.0000001f, 1000.0f); + RNA_def_float(ot->srna, "lambda_border", 0.00005f, 0.0000001f, 1000.0f, + "Lambda factor in border", "", 0.0000001f, 1000.0f); + RNA_def_boolean(ot->srna, "use_x", 1, "Smooth X Axis", "Smooth object along X axis"); + RNA_def_boolean(ot->srna, "use_y", 1, "Smooth Y Axis", "Smooth object along Y axis"); + RNA_def_boolean(ot->srna, "use_z", 1, "Smooth Z Axis", "Smooth object along Z axis"); + RNA_def_boolean(ot->srna, "volume_preservation", 1, "Preserve Volume", "Apply volume preservation after smooth"); +} + /********************** Smooth/Solid Operators *************************/ static void mesh_set_smooth_faces(BMEditMesh *em, short smooth) @@ -2712,21 +2794,21 @@ static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2], m1 = MAXSLOPE; b1 = x12; } - x2max = maxf(x21, x22) + 0.001f; /* prevent missed edges */ - x2min = minf(x21, x22) - 0.001f; /* due to round off error */ - y2max = maxf(y21, y22) + 0.001f; - y2min = minf(y21, y22) - 0.001f; + x2max = max_ff(x21, x22) + 0.001f; /* prevent missed edges */ + x2min = min_ff(x21, x22) - 0.001f; /* due to round off error */ + y2max = max_ff(y21, y22) + 0.001f; + y2min = min_ff(y21, y22) - 0.001f; /* Found an intersect, calc intersect point */ if (m1 == m2) { /* co-incident lines */ /* cut at 50% of overlap area */ - x1max = maxf(x11, x12); - x1min = minf(x11, x12); - xi = (minf(x2max, x1max) + maxf(x2min, x1min)) / 2.0f; + x1max = max_ff(x11, x12); + x1min = min_ff(x11, x12); + xi = (min_ff(x2max, x1max) + max_ff(x2min, x1min)) / 2.0f; - y1max = maxf(y11, y12); - y1min = minf(y11, y12); - yi = (minf(y2max, y1max) + maxf(y2min, y1min)) / 2.0f; + y1max = max_ff(y11, y12); + y1min = min_ff(y11, y12); + yi = (min_ff(y2max, y1max) + max_ff(y2min, y1min)) / 2.0f; } else if (m2 == MAXSLOPE) { xi = x22; @@ -2766,7 +2848,7 @@ static float bm_edge_seg_isect(const float sco_a[2], const float sco_b[2], break; } - } + } lastdist = dist; } return perc; @@ -3412,7 +3494,8 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); BMesh *bm = em->bm; - float angle_limit = RNA_float_get(op->ptr, "angle_limit"); + const float angle_limit = RNA_float_get(op->ptr, "angle_limit"); + const int use_dissolve_boundaries = RNA_boolean_get(op->ptr, "use_dissolve_boundaries"); char dissolve_flag; @@ -3448,8 +3531,8 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op) } if (!EDBM_op_callf(em, op, - "dissolve_limit edges=%he verts=%hv angle_limit=%f", - dissolve_flag, dissolve_flag, angle_limit)) + "dissolve_limit edges=%he verts=%hv angle_limit=%f use_dissolve_boundaries=%b", + dissolve_flag, dissolve_flag, angle_limit, use_dissolve_boundaries)) { return OPERATOR_CANCELLED; } @@ -3476,8 +3559,10 @@ void MESH_OT_dissolve_limited(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; prop = RNA_def_float_rotation(ot->srna, "angle_limit", 0, NULL, 0.0f, DEG2RADF(180.0f), - "Max Angle", "Angle Limit in Degrees", 0.0f, DEG2RADF(180.0f)); + "Max Angle", "Angle limit", 0.0f, DEG2RADF(180.0f)); RNA_def_property_float_default(prop, DEG2RADF(15.0f)); + RNA_def_boolean(ot->srna, "use_dissolve_boundaries", 0, "All Boundaries", + "Dissolve all vertices inbetween face boundaries"); } static int edbm_split_exec(bContext *C, wmOperator *op) @@ -5147,7 +5232,7 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event) if (handleNumInput(&opdata->num_input, event)) { applyNumInput(&opdata->num_input, amounts); - amounts[0] = maxf(amounts[0], 0.0f); + amounts[0] = max_ff(amounts[0], 0.0f); RNA_float_set(op->ptr, "thickness", amounts[0]); RNA_float_set(op->ptr, "depth", amounts[1]); @@ -5188,7 +5273,7 @@ static int edbm_inset_modal(bContext *C, wmOperator *op, wmEvent *event) if (opdata->modify_depth) RNA_float_set(op->ptr, "depth", amount); else { - amount = maxf(amount, 0.0f); + amount = max_ff(amount, 0.0f); RNA_float_set(op->ptr, "thickness", amount); } @@ -5386,6 +5471,7 @@ void MESH_OT_wireframe(wmOperatorType *ot) RNA_def_boolean(ot->srna, "use_replace", TRUE, "Replace", "Remove original faces"); } +#ifdef WITH_BULLET static int edbm_convex_hull_exec(bContext *C, wmOperator *op) { Object *obedit = CTX_data_edit_object(C); @@ -5479,6 +5565,7 @@ void MESH_OT_convex_hull(wmOperatorType *ot) join_triangle_props(ot); } +#endif static int mesh_symmetrize_exec(bContext *C, wmOperator *op) { diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index 537d463dfbc..ef3d8db4156 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -1012,6 +1012,19 @@ void EDBM_uv_element_map_free(UvElementMap *element_map) } } +UvElement *ED_uv_element_get(UvElementMap *map, BMFace *efa, BMLoop *l) +{ + UvElement *element; + + element = map->vert[BM_elem_index_get(l->v)]; + + for (; element; element = element->next) + if (element->face == efa) + return element; + + return NULL; +} + /* last_sel, use em->act_face otherwise get the last selected face in the editselections * at the moment, last_sel is mainly useful for making sure the space image dosnt flicker */ MTexPoly *EDBM_mtexpoly_active_get(BMEditMesh *em, BMFace **r_act_efa, int sloppy, int selected) diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index 835b1ccd52d..65701663df4 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -135,6 +135,7 @@ void MESH_OT_mark_seam(struct wmOperatorType *ot); void MESH_OT_mark_sharp(struct wmOperatorType *ot); void MESH_OT_mark_freestyle_edge(struct wmOperatorType *ot); void MESH_OT_vertices_smooth(struct wmOperatorType *ot); +void MESH_OT_vertices_smooth_laplacian(struct wmOperatorType *ot); void MESH_OT_noise(struct wmOperatorType *ot); void MESH_OT_flip_normals(struct wmOperatorType *ot); void MESH_OT_solidify(struct wmOperatorType *ot); diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index d06142d2654..64e61d436ee 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -135,6 +135,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_mark_sharp); WM_operatortype_append(MESH_OT_mark_freestyle_edge); WM_operatortype_append(MESH_OT_vertices_smooth); + WM_operatortype_append(MESH_OT_vertices_smooth_laplacian); WM_operatortype_append(MESH_OT_noise); WM_operatortype_append(MESH_OT_flip_normals); WM_operatortype_append(MESH_OT_rip); @@ -167,7 +168,9 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_wireframe); WM_operatortype_append(MESH_OT_edge_split); +#ifdef WITH_BULLET WM_operatortype_append(MESH_OT_convex_hull); +#endif WM_operatortype_append(MESH_OT_symmetrize); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index d8793505608..765f9307247 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -113,7 +113,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) CustomData vdata, edata, fdata, ldata, pdata; if (scene->obedit) { - BKE_report(op->reports, RPT_WARNING, "Cannot join while in editmode"); + BKE_report(op->reports, RPT_WARNING, "Cannot join while in edit mode"); return OPERATOR_CANCELLED; } @@ -165,6 +165,9 @@ int join_mesh_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } + /* remove tessface to ensure we don't old references to invalid faces */ + BKE_mesh_tessface_clear(me); + /* new material indices and material array */ matar = MEM_callocN(sizeof(void *) * totmat, "join_mesh matar"); if (totmat) matmap = MEM_callocN(sizeof(int) * totmat, "join_mesh matmap"); @@ -264,7 +267,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) /* adjust settings to fit (allocate a new data-array) */ kbn->data = MEM_callocN(sizeof(float) * 3 * totvert, "joined_shapekey"); - kbn->totelem = totvert; + kbn->totelem = totvert; /* XXX 2.5 Animato */ #if 0 @@ -513,7 +516,8 @@ int join_mesh_exec(bContext *C, wmOperator *op) me->ldata = ldata; me->pdata = pdata; - mesh_update_customdata_pointers(me, TRUE); /* BMESH_TODO, check if this arg can be failse, non urgent - campbell */ + /* tessface data removed above, no need to update */ + mesh_update_customdata_pointers(me, FALSE); /* old material array */ for (a = 1; a <= ob->totcol; a++) { @@ -843,7 +847,7 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, const float co[3], char m minmax_v3v3_v3(min, max, eve->co); } } - else { + else { MVert *mvert; int a; @@ -878,7 +882,7 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, const float co[3], char m mesh_octree_add_nodes(MeshOctree.table, eve->co, MeshOctree.offs, MeshOctree.div, (intptr_t)(eve)); } } - else { + else { MVert *mvert; int a; diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index b9018914633..8633a7a9b38 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -124,7 +124,6 @@ MetaElem *add_metaball_primitive(bContext *UNUSED(C), Object *obedit, float mat[ /* Select or deselect all MetaElements */ static int mball_select_all_exec(bContext *C, wmOperator *op) { - //Scene *scene= CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 9a2915a5d55..9fc4e0a906d 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -833,8 +833,6 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) /* only used as menu */ void OBJECT_OT_group_instance_add(wmOperatorType *ot) { - PropertyRNA *prop; - /* identifiers */ ot->name = "Add Group Instance"; ot->description = "Add a dupligroup instance"; @@ -849,9 +847,8 @@ void OBJECT_OT_group_instance_add(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", ""); - RNA_def_enum_funcs(prop, RNA_group_itemf); - ot->prop = prop; + ot->prop = RNA_def_enum(ot->srna, "group", DummyRNA_NULL_items, 0, "Group", ""); + RNA_def_enum_funcs(ot->prop, RNA_group_itemf); ED_object_add_generic_props(ot, FALSE); } @@ -1124,13 +1121,13 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, basen->object = ob; /* make sure apply works */ - BKE_free_animdata(&ob->id); + BKE_free_animdata(&ob->id); ob->adt = NULL; ob->parent = NULL; ob->constraints.first = ob->constraints.last = NULL; ob->disp.first = ob->disp.last = NULL; - ob->transflag &= ~OB_DUPLI; + ob->transflag &= ~OB_DUPLI; ob->lay = base->lay; copy_m4_m4(ob->obmat, dob->mat); @@ -1410,7 +1407,7 @@ static int convert_exec(bContext *C, wmOperator *op) * cases this doesnt give correct results (when MDEF is used for eg) */ dm = mesh_get_derived_final(scene, newob, CD_MASK_MESH); - /* dm= mesh_create_derived_no_deform(ob1, NULL); this was called original (instead of get_derived). man o man why! (ton) */ + // dm = mesh_create_derived_no_deform(ob1, NULL); /* this was called original (instead of get_derived). man o man why! (ton) */ DM_to_mesh(dm, newob->data, newob); @@ -1576,7 +1573,7 @@ static int convert_exec(bContext *C, wmOperator *op) /* delete original if needed */ if (basedel) { if (!keep_original) - ED_base_object_free_and_unlink(bmain, scene, basedel); + ED_base_object_free_and_unlink(bmain, scene, basedel); basedel = NULL; } @@ -2060,11 +2057,11 @@ static int join_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); if (scene->obedit) { - BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); + BKE_report(op->reports, RPT_ERROR, "This data does not support joining in edit mode"); return OPERATOR_CANCELLED; } else if (BKE_object_obdata_is_libdata(ob)) { - BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); + BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata"); return OPERATOR_CANCELLED; } @@ -2114,11 +2111,11 @@ static int join_shapes_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); if (scene->obedit) { - BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); + BKE_report(op->reports, RPT_ERROR, "This data does not support joining in edit mode"); return OPERATOR_CANCELLED; } else if (BKE_object_obdata_is_libdata(ob)) { - BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); + BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index bc5d289d04c..2914a1ff673 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -966,6 +966,12 @@ static int multiresbake_check(bContext *C, wmOperator *op) break; } + if (mmd->lvl == 0) { + BKE_report(op->reports, RPT_ERROR, "Multires data baking is not supported for preview subdivision level 0"); + + break; + } + if (!me->mtpoly) { BKE_report(op->reports, RPT_ERROR, "Mesh should be unwrapped before multires data baking"); @@ -1030,8 +1036,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = *lvl; tmp_mmd.sculptlvl = *lvl; - dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, - 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0); cddm->release(cddm); } @@ -1051,8 +1056,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = mmd->totlvl; tmp_mmd.sculptlvl = mmd->totlvl; - dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, - 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0); cddm->release(cddm); return dm; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 80993d6cca7..f78e1203bc4 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -494,9 +494,9 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) /* auto-set 'Path' setting on curve so this works */ cu->flag |= CU_PATH; } - } + } } - } + } /* free any temporary targets */ if (cti->flush_constraint_targets) @@ -593,7 +593,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) { list = &ob->constraints; - } + } else if (owner == EDIT_CONSTRAINT_OWNER_BONE) { bPoseChannel *pchan = BKE_pose_channel_active(ob); if (pchan) @@ -807,7 +807,7 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op) /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) { printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : "<None>"); - BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse"); + BKE_report(op->reports, RPT_ERROR, "Could not find constraint data for Child-Of Set Inverse"); return OPERATOR_CANCELLED; } @@ -1028,7 +1028,7 @@ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) /* despite 3 layers of checks, we may still not be able to find a constraint */ if (data == NULL) { printf("DEBUG: Child-Of Set Inverse - object = '%s'\n", (ob) ? ob->id.name + 2 : "<None>"); - BKE_report(op->reports, RPT_ERROR, "Couldn't find constraint data for Child-Of Set Inverse"); + BKE_report(op->reports, RPT_ERROR, "Could not find constraint data for Child-Of Set Inverse"); return OPERATOR_CANCELLED; } @@ -1628,15 +1628,15 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase return OPERATOR_CANCELLED; } if ((type == CONSTRAINT_TYPE_RIGIDBODYJOINT) && (list != &ob->constraints)) { - BKE_report(op->reports, RPT_ERROR, "Rigid Body Joint Constraint can only be added to Objects"); + BKE_report(op->reports, RPT_ERROR, "Rigid Body Joint constraint can only be added to objects"); return OPERATOR_CANCELLED; } if ((type == CONSTRAINT_TYPE_KINEMATIC) && ((!pchan) || (list != &pchan->constraints))) { - BKE_report(op->reports, RPT_ERROR, "IK Constraint can only be added to Bones"); + BKE_report(op->reports, RPT_ERROR, "IK constraint can only be added to bones"); return OPERATOR_CANCELLED; } if ((type == CONSTRAINT_TYPE_SPLINEIK) && ((!pchan) || (list != &pchan->constraints))) { - BKE_report(op->reports, RPT_ERROR, "Spline IK Constraint can only be added to Bones"); + BKE_report(op->reports, RPT_ERROR, "Spline IK constraint can only be added to bones"); return OPERATOR_CANCELLED; } @@ -1856,7 +1856,7 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) /* must have active bone */ if (ELEM(NULL, ob, pchan)) { - BKE_report(op->reports, RPT_ERROR, "Must have active bone to add IK Constraint to"); + BKE_report(op->reports, RPT_ERROR, "Must have an active bone to add IK constraint to"); return OPERATOR_CANCELLED; } @@ -1865,7 +1865,7 @@ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) if (con->type == CONSTRAINT_TYPE_KINEMATIC) break; } if (con) { - BKE_report(op->reports, RPT_ERROR, "Bone already has IK Constraint"); + BKE_report(op->reports, RPT_ERROR, "Bone already has an IK constraint"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 43c6c332791..c0c2195592b 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -201,7 +201,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) ED_base_object_activate(C, NULL); } } - } + } } CTX_DATA_END; @@ -684,7 +684,7 @@ static void copymenu_logicbricks(Scene *scene, View3D *v3d, Object *ob) if (TESTBASELIB(v3d, base)) { /* first: free all logic */ - free_sensors(&base->object->sensors); + free_sensors(&base->object->sensors); unlink_controllers(&base->object->controllers); free_controllers(&base->object->controllers); unlink_actuators(&base->object->actuators); @@ -885,7 +885,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) id_us_plus((ID *)cu1->vfonti); if (cu1->vfontbi) cu1->vfontbi->id.us--; cu1->vfontbi = cu->vfontbi; - id_us_plus((ID *)cu1->vfontbi); + id_us_plus((ID *)cu1->vfontbi); BKE_vfont_to_curve(bmain, scene, base->object, 0); /* needed? */ @@ -988,7 +988,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) cu1->flag |= CU_UV_ORCO; else cu1->flag &= ~CU_UV_ORCO; - } + } } else if (event == 29) { /* protected bits */ base->object->protectflag = ob->protectflag; @@ -1401,7 +1401,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene * scene, View3D * v3d) else ob->size[1] = ob->size[0] * y / x; done = TRUE; - DAG_id_tag_update(&ob->id, OB_RECALC_OB); + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } if (done) break; @@ -1795,7 +1795,7 @@ static int logicbricks_copy_exec(bContext *C, wmOperator *UNUSED(op)) { if (ob != ob_iter) { /* first: free all logic */ - free_sensors(&ob_iter->sensors); + free_sensors(&ob_iter->sensors); unlink_controllers(&ob_iter->controllers); free_controllers(&ob_iter->controllers); unlink_actuators(&ob_iter->actuators); @@ -1864,7 +1864,7 @@ static int game_physics_copy_exec(bContext *C, wmOperator *UNUSED(op)) ob_iter->anisotropicFriction[0] = ob->anisotropicFriction[0]; ob_iter->anisotropicFriction[1] = ob->anisotropicFriction[1]; ob_iter->anisotropicFriction[2] = ob->anisotropicFriction[2]; - ob_iter->collision_boundtype = ob->collision_boundtype; + ob_iter->collision_boundtype = ob->collision_boundtype; ob_iter->margin = ob->margin; ob_iter->bsoft = copy_bulletsoftbody(ob->bsoft); if (ob->restrictflag & OB_RESTRICT_RENDER) diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index cca37cf3a44..a3bf27a19d6 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -195,7 +195,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) } } - if (!ok) BKE_report(op->reports, RPT_ERROR, "Active Object contains no groups"); + if (!ok) BKE_report(op->reports, RPT_ERROR, "Active object contains no groups"); DAG_scene_sort(bmain, scene); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); @@ -211,7 +211,7 @@ void GROUP_OT_objects_remove_active(wmOperatorType *ot) ot->idname = "GROUP_OT_objects_remove_active"; /* api callbacks */ - ot->exec = objects_remove_active_exec; + ot->exec = objects_remove_active_exec; ot->poll = ED_operator_objectmode; /* flags */ @@ -333,7 +333,7 @@ void GROUP_OT_create(wmOperatorType *ot) ot->idname = "GROUP_OT_create"; /* api callbacks */ - ot->exec = group_create_exec; + ot->exec = group_create_exec; ot->poll = ED_operator_objectmode; /* flags */ diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 8bc249974f2..caeff1e82a7 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -515,12 +515,12 @@ static int object_add_hook_selob_exec(bContext *C, wmOperator *op) CTX_DATA_END; if (!obsel) { - BKE_report(op->reports, RPT_ERROR, "Can't add hook with no other selected objects"); + BKE_report(op->reports, RPT_ERROR, "Cannot add hook with no other selected objects"); return OPERATOR_CANCELLED; } if (use_bone && obsel->type != OB_ARMATURE) { - BKE_report(op->reports, RPT_ERROR, "Can't add hook bone for a non armature object"); + BKE_report(op->reports, RPT_ERROR, "Cannot add hook bone for a non armature object"); return OPERATOR_CANCELLED; } @@ -590,7 +590,7 @@ static int object_hook_remove_exec(bContext *C, wmOperator *op) hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); if (!hmd) { - BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier"); + BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } @@ -667,13 +667,13 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) if (ptr.data) { /* if modifier context is available, use that */ ob = ptr.id.data; hmd = ptr.data; - } + } else { /* use the provided property */ ob = CTX_data_edit_object(C); hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); } if (!ob || !hmd) { - BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier"); + BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } @@ -735,13 +735,13 @@ static int object_hook_recenter_exec(bContext *C, wmOperator *op) if (ptr.data) { /* if modifier context is available, use that */ ob = ptr.id.data; hmd = ptr.data; - } + } else { /* use the provided property */ ob = CTX_data_edit_object(C); hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); } if (!ob || !hmd) { - BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier"); + BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } @@ -793,13 +793,13 @@ static int object_hook_assign_exec(bContext *C, wmOperator *op) if (ptr.data) { /* if modifier context is available, use that */ ob = ptr.id.data; hmd = ptr.data; - } + } else { /* use the provided property */ ob = CTX_data_edit_object(C); hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); } if (!ob || !hmd) { - BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier"); + BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } @@ -855,13 +855,13 @@ static int object_hook_select_exec(bContext *C, wmOperator *op) if (ptr.data) { /* if modifier context is available, use that */ ob = ptr.id.data; hmd = ptr.data; - } + } else { /* use the provided property */ ob = CTX_data_edit_object(C); hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num); } if (!ob || !hmd) { - BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier"); + BKE_report(op->reports, RPT_ERROR, "Could not find hook modifier"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index ac9c4f7adee..4aa2e825954 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -569,7 +569,7 @@ static void findnearestLattvert__doClosest(void *userData, BPoint *bp, const flo static BPoint *findnearestLattvert(ViewContext *vc, const int mval[2], int sel) { - /* sel==1: selected gets a disadvantage */ + /* (sel == 1): selected gets a disadvantage */ /* in nurb and bezt or bp the nearest is written */ /* return 0 1 2: handlepunt */ struct { BPoint *bp; float dist; int select; float mval_fl[2]; } data = {NULL}; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 02070506937..3d2c4f95624 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -99,13 +99,13 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc /* only geometry objects should be able to get modifiers [#25291] */ if (!ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { - BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to Object '%s'", ob->id.name + 2); + BKE_reportf(reports, RPT_WARNING, "Modifiers cannot be added to object '%s'", ob->id.name + 2); return NULL; } if (mti->flags & eModifierTypeFlag_Single) { if (modifiers_findByType(ob, type)) { - BKE_report(reports, RPT_WARNING, "Only one modifier of this type allowed"); + BKE_report(reports, RPT_WARNING, "Only one modifier of this type is allowed"); return NULL; } } @@ -556,7 +556,7 @@ static int modifier_apply_shape(ReportList *reports, Scene *scene, Object *ob, M KeyBlock *kb; if (!modifier_sameTopology(md) || mti->type == eModifierTypeType_NonGeometrical) { - BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to Shapes"); + BKE_report(reports, RPT_ERROR, "Only deforming modifiers can be applied to shapes"); return 0; } @@ -604,7 +604,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, MultiresModifierData *mmd = find_multires_modifier_before(scene, md); if (me->key && mti->type != eModifierTypeType_NonGeometrical) { - BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to Mesh with Shape Keys"); + BKE_report(reports, RPT_ERROR, "Modifier cannot be applied to a mesh with shape keys"); return 0; } @@ -681,7 +681,7 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi int prev_mode; if (scene->obedit) { - BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in editmode"); + BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in edit mode"); return 0; } else if (((ID *) ob->data)->us > 1) { diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index b6d3594c826..d19277d20a2 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -393,7 +393,7 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_proxy_make", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_make_local", LKEY, KM_PRESS, 0, 0); - // XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith + /* XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith */ WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 447ba29e203..58c6959d6f0 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -622,13 +622,13 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object /* fall back on regular parenting now (for follow only) */ if (partype == PAR_FOLLOW) partype = PAR_OBJECT; - } + } } else if (partype == PAR_BONE) { pchan = BKE_pose_channel_active(par); if (pchan == NULL) { - BKE_report(reports, RPT_ERROR, "No active Bone"); + BKE_report(reports, RPT_ERROR, "No active bone"); return 0; } } @@ -667,7 +667,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object * NOTE: the old (2.4x) method was to set ob->partype = PARSKEL, creating the virtual modifiers */ ob->partype = PAROBJECT; /* note, dna define, not operator property */ - //ob->partype= PARSKEL; /* note, dna define, not operator property */ + //ob->partype = PARSKEL; /* note, dna define, not operator property */ /* BUT, to keep the deforms, we need a modifier, and then we need to set the object that it uses * - We need to ensure that the modifier we're adding doesn't already exist, so we check this by @@ -1036,7 +1036,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) int type = RNA_enum_get(op->ptr, "type"); if (CTX_data_edit_object(C)) { - BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode"); + BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in edit mode"); return OPERATOR_CANCELLED; } CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) @@ -1260,7 +1260,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) base->object->lay = lay; base->object->flag &= ~SELECT; base->flag &= ~SELECT; - /* if (base->object->type==OB_LAMP) is_lamp = TRUE; */ + /* if (base->object->type == OB_LAMP) is_lamp = TRUE; */ } CTX_DATA_END; } @@ -1273,7 +1273,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) local = base->lay & 0xFF000000; base->lay = lay + local; base->object->lay = lay; - /* if (base->object->type==OB_LAMP) is_lamp = TRUE; */ + /* if (base->object->type == OB_LAMP) is_lamp = TRUE; */ } CTX_DATA_END; } @@ -1350,17 +1350,17 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) Scene *scene_to = BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene")); if (scene_to == NULL) { - BKE_report(op->reports, RPT_ERROR, "Couldn't find scene"); + BKE_report(op->reports, RPT_ERROR, "Could not find scene"); return OPERATOR_CANCELLED; } if (scene_to == CTX_data_scene(C)) { - BKE_report(op->reports, RPT_ERROR, "Can't link objects into the same scene"); + BKE_report(op->reports, RPT_ERROR, "Cannot link objects into the same scene"); return OPERATOR_CANCELLED; } if (scene_to->id.lib) { - BKE_report(op->reports, RPT_ERROR, "Can't link objects into a linked scene"); + BKE_report(op->reports, RPT_ERROR, "Cannot link objects into a linked scene"); return OPERATOR_CANCELLED; } @@ -1710,7 +1710,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) break; case OB_MESH: ob->data = BKE_mesh_copy(ob->data); - //me= ob->data; + //me = ob->data; //if (me && me->key) // ipo_idnew(me->key->ipo); /* drivers */ break; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index 4ed14c3cdce..2aa737d204d 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -425,7 +425,7 @@ static int object_select_linked_exec(bContext *C, wmOperator *op) ob = OBACT; if (ob == NULL) { - BKE_report(op->reports, RPT_ERROR, "No Active Object"); + BKE_report(op->reports, RPT_ERROR, "No active object"); return OPERATOR_CANCELLED; } @@ -608,11 +608,11 @@ static short select_grouped_group(bContext *C, Object *ob) /* Select objects in for (i = 0; i < group_count; i++) { group = ob_groups[i]; - uiItemStringO(layout, group->id.name + 2, 0, "OBJECT_OT_select_same_group", "group", group->id.name); + uiItemStringO(layout, group->id.name + 2, 0, "OBJECT_OT_select_same_group", "group", group->id.name + 2); } uiPupMenuEnd(C, pup); - return changed; // The operator already handle this! + return changed; /* The operator already handle this! */ } static short select_grouped_object_hooks(bContext *C, Object *ob) @@ -754,8 +754,8 @@ static short select_grouped_keyingset(bContext *C, Object *UNUSED(ob)) return 0; /* select each object that Keying Set refers to */ - // TODO: perhaps to be more in line with the rest of these, we should only take objects - // if the passed in object is included in this too + /* TODO: perhaps to be more in line with the rest of these, we should only take objects + * if the passed in object is included in this too */ CTX_DATA_BEGIN (C, Base *, base, selectable_bases) { /* only check for this object if it isn't selected already, to limit time wasted */ @@ -800,7 +800,7 @@ static int object_select_grouped_exec(bContext *C, wmOperator *op) ob = OBACT; if (ob == NULL) { - BKE_report(op->reports, RPT_ERROR, "No Active Object"); + BKE_report(op->reports, RPT_ERROR, "No active object"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 86a55a9b278..2b6d69ca694 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -211,7 +211,7 @@ static int object_shape_key_mirror(bContext *C, Object *ob) /* currently editmode isn't supported by mesh so * ignore here for now too */ - /* if (lt->editlatt) lt= lt->editlatt->latt; */ + /* if (lt->editlatt) lt = lt->editlatt->latt; */ for (w = 0; w < lt->pntsw; w++) { for (v = 0; v < lt->pntsv; v++) { diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 4c95884a51a..4476296866e 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -171,7 +171,7 @@ static void object_clear_rot(Object *ob) } } } // Duplicated in source/blender/editors/armature/editarmature.c - else { + else { if (ob->rotmode == ROT_MODE_QUAT) { unit_qt(ob->quat); unit_qt(ob->dquat); @@ -217,7 +217,7 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, /* sanity checks */ if (ELEM(NULL, clear_func, default_ksName)) { - BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or Keying Set Name"); + BKE_report(op->reports, RPT_ERROR, "Programming error: missing clear transform function or keying set name"); return OPERATOR_CANCELLED; } @@ -390,19 +390,19 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo if (ob->type == OB_MESH) { if (ID_REAL_USERS(ob->data) > 1) { - BKE_report(reports, RPT_ERROR, "Can't apply to a multi user mesh, doing nothing"); + BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user mesh, doing nothing"); change = 0; } } else if (ob->type == OB_ARMATURE) { if (ID_REAL_USERS(ob->data) > 1) { - BKE_report(reports, RPT_ERROR, "Can't apply to a multi user armature, doing nothing"); + BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user armature, doing nothing"); change = 0; } } else if (ob->type == OB_LATTICE) { if (ID_REAL_USERS(ob->data) > 1) { - BKE_report(reports, RPT_ERROR, "Can't apply to a multi user lattice, doing nothing"); + BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user lattice, doing nothing"); change = 0; } } @@ -410,7 +410,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo Curve *cu; if (ID_REAL_USERS(ob->data) > 1) { - BKE_report(reports, RPT_ERROR, "Can't apply to a multi user curve, doing nothing"); + BKE_report(reports, RPT_ERROR, "Cannot apply to a multi user curve, doing nothing"); change = 0; } @@ -422,7 +422,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo change = 0; } if (cu->key) { - BKE_report(reports, RPT_ERROR, "Can't apply to a curve with vertex keys, doing nothing"); + BKE_report(reports, RPT_ERROR, "Cannot apply to a curve with vertex keys, doing nothing"); change = 0; } } @@ -654,7 +654,8 @@ void OBJECT_OT_transform_apply(wmOperatorType *ot) enum { GEOMETRY_TO_ORIGIN = 0, ORIGIN_TO_GEOMETRY, - ORIGIN_TO_CURSOR + ORIGIN_TO_CURSOR, + ORIGIN_TO_CENTER_OF_MASS }; static int object_origin_set_exec(bContext *C, wmOperator *op) @@ -671,7 +672,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) int tot_change = 0, tot_lib_error = 0, tot_multiuser_arm_error = 0; if (obedit && centermode != GEOMETRY_TO_ORIGIN) { - BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in EditMode"); + BKE_report(op->reports, RPT_ERROR, "Operation cannot be performed in edit mode"); return OPERATOR_CANCELLED; } else { @@ -785,6 +786,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) Mesh *me = ob->data; if (centermode == ORIGIN_TO_CURSOR) { /* done */ } + else if (centermode == ORIGIN_TO_CENTER_OF_MASS) { BKE_mesh_center_centroid(me, cent); } else if (around == V3D_CENTROID) { BKE_mesh_center_median(me, cent); } else { BKE_mesh_center_bounds(me, cent); } @@ -852,7 +854,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (ID_REAL_USERS(arm) > 1) { #if 0 - BKE_report(op->reports, RPT_ERROR, "Can't apply to a multi user armature"); + BKE_report(op->reports, RPT_ERROR, "Cannot apply to a multi user armature"); return; #endif tot_multiuser_arm_error++; @@ -865,7 +867,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) tot_change++; arm->id.flag |= LIB_DOIT; - /* do_inverse_offset= TRUE; */ /* docenter_armature() handles this */ + /* do_inverse_offset = TRUE; */ /* docenter_armature() handles this */ BKE_object_where_is_calc(scene, ob); BKE_pose_where_is(scene, ob); /* needed for bone parents */ @@ -980,6 +982,8 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) "Move object origin to center of object geometry"}, {ORIGIN_TO_CURSOR, "ORIGIN_CURSOR", 0, "Origin to 3D Cursor", "Move object origin to position of the 3D cursor"}, + {ORIGIN_TO_CENTER_OF_MASS, "ORIGIN_CENTER_OF_MASS", 0, "Origin to Center of Mass", + "Move object origin to the object center of mass (assuming uniform density)"}, {0, NULL, 0, NULL, NULL} }; @@ -1006,4 +1010,3 @@ void OBJECT_OT_origin_set(wmOperatorType *ot) ot->prop = RNA_def_enum(ot->srna, "type", prop_set_center_types, 0, "Type", ""); RNA_def_enum(ot->srna, "center", prop_set_bounds_types, V3D_CENTROID, "Center", ""); } - diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 1be09847ef2..c0f9ecfa5a2 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -405,27 +405,27 @@ typedef enum WT_Method { typedef enum WT_ReplaceMode { WT_REPLACE_ALL_WEIGHTS = 1, - WT_REPLACE_EMPTY_WEIGHTS = 2, + WT_REPLACE_EMPTY_WEIGHTS = 2 } WT_ReplaceMode; static EnumPropertyItem WT_vertex_group_mode_item[] = { - {WT_REPLACE_ACTIVE_VERTEX_GROUP, "WT_REPLACE_ACTIVE_VERTEX_GROUP", 1, "Active", "Transfer active vertex group from selected to active mesh."}, - {WT_REPLACE_ALL_VERTEX_GROUPS, "WT_REPLACE_ALL_VERTEX_GROUPS", 1, "All", "Transfer all vertex groups from selected to active mesh."}, - {0, NULL, 0, NULL, NULL} + {WT_REPLACE_ACTIVE_VERTEX_GROUP, "WT_REPLACE_ACTIVE_VERTEX_GROUP", 1, "Active", "Transfer active vertex group from selected to active mesh"}, + {WT_REPLACE_ALL_VERTEX_GROUPS, "WT_REPLACE_ALL_VERTEX_GROUPS", 1, "All", "Transfer all vertex groups from selected to active mesh"}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem WT_method_item[] = { - {WT_BY_INDEX, "WT_BY_INDEX", 1, "Vertex index", "Copy for identical meshes."}, - {WT_BY_NEAREST_VERTEX, "WT_BY_NEAREST_VERTEX", 1, "Nearest vertex", "Copy weight from closest vertex."}, - {WT_BY_NEAREST_FACE, "WT_BY_NEAREST_FACE", 1, "Nearest face", "Barycentric interpolation from nearest face."}, - {WT_BY_NEAREST_VERTEX_IN_FACE, "WT_BY_NEAREST_VERTEX_IN_FACE", 1, "Nearest vertex in face", "Copy weight from closest vertex in nearest face."}, - {0, NULL, 0, NULL, NULL} + {WT_BY_INDEX, "WT_BY_INDEX", 1, "Vertex index", "Copy for identical meshes"}, + {WT_BY_NEAREST_VERTEX, "WT_BY_NEAREST_VERTEX", 1, "Nearest vertex", "Copy weight from closest vertex"}, + {WT_BY_NEAREST_FACE, "WT_BY_NEAREST_FACE", 1, "Nearest face", "Barycentric interpolation from nearest face"}, + {WT_BY_NEAREST_VERTEX_IN_FACE, "WT_BY_NEAREST_VERTEX_IN_FACE", 1, "Nearest vertex in face", "Copy weight from closest vertex in nearest face"}, + {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem WT_replace_mode_item[] = { - {WT_REPLACE_ALL_WEIGHTS, "WT_REPLACE_ALL_WEIGHTS", 1, "All", "Overwrites all weights."}, - {WT_REPLACE_EMPTY_WEIGHTS, "WT_REPLACE_EMPTY_WEIGHTS", 1, "Empty", "Adds weights to vertices with no weight."}, - {0, NULL, 0, NULL, NULL} + {WT_REPLACE_ALL_WEIGHTS, "WT_REPLACE_ALL_WEIGHTS", 1, "All", "Overwrite all weights"}, + {WT_REPLACE_EMPTY_WEIGHTS, "WT_REPLACE_EMPTY_WEIGHTS", 1, "Empty", "Add weights to vertices with no weight"}, + {0, NULL, 0, NULL, NULL} }; /*copy weight*/ @@ -941,7 +941,7 @@ static void vgroup_select_verts(Object *ob, int select) } /* this has to be called, because this function operates on vertices only */ - if (select) EDBM_select_flush(em); // vertices to edges/faces + if (select) EDBM_select_flush(em); /* vertices to edges/faces */ else EDBM_deselect_flush(em); } else { @@ -1062,7 +1062,7 @@ static void vgroup_normalize(Object *ob) dw = defvert_find_index(dv, def_nr); if (dw) { - weight_max = MAX2(dw->weight, weight_max); + weight_max = max_ff(dw->weight, weight_max); } } @@ -1174,23 +1174,24 @@ static void getVerticalAndHorizontalChange(const float norm[3], float d, const f const float start[3], float distToStart, float *end, float (*changes)[2], float *dists, int index) { - // A=Q-((Q-P).N)N - // D = (a*x0 + b*y0 +c*z0 +d) + /* A = Q - ((Q - P).N)N + * D = (a * x0 + b * y0 +c * z0 + d) */ float projA[3], projB[3]; closest_to_plane_v3(projA, coord, norm, start); closest_to_plane_v3(projB, coord, norm, end); - // (vertical and horizontal refer to the plane's y and xz respectively) - // vertical distance + /* (vertical and horizontal refer to the plane's y and xz respectively) + * vertical distance */ dists[index] = dot_v3v3(norm, end) + d; - // vertical change + /* vertical change */ changes[index][0] = dists[index] - distToStart; //printf("vc %f %f\n", distance(end, projB, 3)-distance(start, projA, 3), changes[index][0]); - // horizontal change + /* horizontal change */ changes[index][1] = len_v3v3(projA, projB); } -// I need the derived mesh to be forgotten so the positions are recalculated with weight changes (see dm_deform_recalc) +/* I need the derived mesh to be forgotten so the positions are recalculated + * with weight changes (see dm_deform_recalc) */ static void dm_deform_clear(DerivedMesh *dm, Object *ob) { if (ob->derivedDeform && (ob->derivedDeform) == dm) { @@ -1311,7 +1312,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in } } } - // sort the changes by the vertical change + /* sort the changes by the vertical change */ for (k = 0; k < totweight; k++) { float tf; int ti; @@ -1323,7 +1324,7 @@ static void moveCloserToDistanceFromPlane(Scene *scene, Object *ob, Mesh *me, in bestIndex = i; } } - // switch with k + /* switch with k */ if (bestIndex != k) { ti = upDown[k]; upDown[k] = upDown[bestIndex]; @@ -1650,11 +1651,11 @@ static void vgroup_blend(Object *ob, const float fac) /* i1 is always the selected one */ if (sel1) { i1 = BM_elem_index_get(eed->v1); - /* i2= BM_elem_index_get(eed->v2); */ /* UNUSED */ + /* i2 = BM_elem_index_get(eed->v2); */ /* UNUSED */ eve = eed->v2; } else { - /* i2= BM_elem_index_get(eed->v1); */ /* UNUSED */ + /* i2 = BM_elem_index_get(eed->v1); */ /* UNUSED */ i1 = BM_elem_index_get(eed->v2); eve = eed->v1; } @@ -3139,7 +3140,7 @@ void OBJECT_OT_vertex_group_limit_total(wmOperatorType *ot) /* identifiers */ ot->name = "Limit Number of Weights per Vertex"; ot->idname = "OBJECT_OT_vertex_group_limit_total"; - ot->description = "Limits deform weights associated with a vertex to a specified number by removing lowest weights"; + ot->description = "Limit deform weights associated with a vertex to a specified number by removing lowest weights"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -3469,7 +3470,7 @@ static int vgroup_do_remap(Object *ob, char *name_array, wmOperator *op) } } else { - BKE_report(op->reports, RPT_ERROR, "Editmode lattice isn't supported yet"); + BKE_report(op->reports, RPT_ERROR, "Editmode lattice is not supported yet"); MEM_freeN(sort_map_update); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/physics/CMakeLists.txt b/source/blender/editors/physics/CMakeLists.txt index 4d43c618568..da12a26e747 100644 --- a/source/blender/editors/physics/CMakeLists.txt +++ b/source/blender/editors/physics/CMakeLists.txt @@ -20,6 +20,7 @@ set(INC ../include + ../../blenfont ../../blenkernel ../../blenlib ../../blenloader @@ -54,4 +55,8 @@ if(WITH_OPENMP) add_definitions(-DPARALLEL=1) endif() +if(WITH_INTERNATIONAL) + add_definitions(-DWITH_INTERNATIONAL) +endif() + blender_add_lib(bf_editor_physics "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/physics/SConscript b/source/blender/editors/physics/SConscript index 9fe6cff4349..fffe05d6a0d 100644 --- a/source/blender/editors/physics/SConscript +++ b/source/blender/editors/physics/SConscript @@ -3,12 +3,12 @@ Import ('env') sources = env.Glob('*.c') -incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' +incs = '../include ../../blenfont ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../gpu ../../blenloader ../../bmesh' incs += ' ../../makesrna ../../render/extern/include #/intern/elbeem/extern' -defs = '' +defs = [] if env['OURPLATFORM'] == 'linux': cflags='-pthread' @@ -17,9 +17,11 @@ if env['OURPLATFORM'] == 'linux': if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs += ' ' + env['BF_PTHREADS_INC'] - if env['OURPLATFORM'] == 'darwin': if env['WITH_BF_OPENMP']: - defs += ' PARALLEL=1' + defs.append('PARALLEL=1') + +if env['WITH_BF_INTERNATIONAL']: + defs.append('WITH_INTERNATIONAL') -env.BlenderLib ( 'bf_editors_physics', sources, Split(incs), Split(defs), libtype=['core'], priority=[45] ) +env.BlenderLib ( 'bf_editors_physics', sources, Split(incs), defs, libtype=['core'], priority=[45] ) diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 467ad5c6ff9..c51b3ca4c43 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -26,6 +26,8 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "DNA_dynamicpaint_types.h" #include "DNA_modifier_types.h" #include "DNA_object_types.h" @@ -280,7 +282,10 @@ static int dynamicPaint_bakeImageSequence(bContext *C, DynamicPaintSurface *surf int frames; frames = surface->end_frame - surface->start_frame + 1; - if (frames <= 0) {BLI_strncpy(canvas->error, "No frames to bake.", sizeof(canvas->error)); return 0;} + if (frames <= 0) { + BLI_strncpy(canvas->error, N_("No frames to bake"), sizeof(canvas->error)); + return 0; + } /* Set frame to start point (also inits modifier data) */ frame = surface->start_frame; diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index aff66b272fe..dc309ec3c31 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -273,7 +273,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op)) /* there must be at least one state */ if (!part->boids->states.first) { state = boid_new_state(part->boids); - BLI_addtail(&part->boids->states, state); + BLI_addtail(&part->boids->states, state); } else state = part->boids->states.first; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 7343a44470a..f8ec51c7a7c 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -603,7 +603,7 @@ static void foreach_mouse_hit_key(PEData *data, ForKeyMatFunc func, int selected ParticleSystemModifierData *psmd = NULL; ParticleEditSettings *pset= PE_settings(data->scene); POINT_P; KEY_K; - float mat[4][4]= MAT4_UNITY, imat[4][4]= MAT4_UNITY; + float mat[4][4] = MAT4_UNITY, imat[4][4] = MAT4_UNITY; if (edit->psys) psmd= psys_get_modifier(data->ob, edit->psys); @@ -673,7 +673,7 @@ static void foreach_point(PEData *data, ForPointFunc func) PTCacheEdit *edit = data->edit; POINT_P; - LOOP_POINTS { + LOOP_POINTS { func(data, p); } } @@ -744,15 +744,15 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) psys_mat_hair_to_orco(ob, psmd->dm, psys->part->from, pa, mat); copy_v3_v3(co, key->co); mul_m4_v3(mat, co); - co[0]= -co[0]; + co[0] = -co[0]; index= BLI_kdtree_find_nearest(tree, co, NULL, &nearest); /* this needs a custom threshold still, duplicated for editmode mirror */ if (index != -1 && index != p && (nearest.dist <= 0.0002f)) - edit->mirror_cache[p]= index; + edit->mirror_cache[p] = index; else - edit->mirror_cache[p]= -1; + edit->mirror_cache[p] = -1; } /* make sure mirrors are in two directions */ @@ -760,7 +760,7 @@ static void PE_update_mirror_cache(Object *ob, ParticleSystem *psys) if (edit->mirror_cache[p]) { index= edit->mirror_cache[p]; if (edit->mirror_cache[index] != p) - edit->mirror_cache[p]= -1; + edit->mirror_cache[p] = -1; } } @@ -829,7 +829,7 @@ static void PE_mirror_particle(Object *ob, DerivedMesh *dm, ParticleSystem *psys for (k=0; k<pa->totkey; k++, hkey++, mhkey++, key++, mkey++) { copy_v3_v3(mhkey->co, hkey->co); mul_m4_v3(mat, mhkey->co); - mhkey->co[0]= -mhkey->co[0]; + mhkey->co[0] = -mhkey->co[0]; mul_m4_v3(immat, mhkey->co); if (key->flag & PEK_TAG) @@ -986,9 +986,9 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit) PTCacheEditKey *key; int j, k; float tlen; - float dv0[3]= {0.0f, 0.0f, 0.0f}; - float dv1[3]= {0.0f, 0.0f, 0.0f}; - float dv2[3]= {0.0f, 0.0f, 0.0f}; + float dv0[3] = {0.0f, 0.0f, 0.0f}; + float dv1[3] = {0.0f, 0.0f, 0.0f}; + float dv2[3] = {0.0f, 0.0f, 0.0f}; if (edit==0 || (pset->flag & PE_KEEP_LENGTHS)==0) return; @@ -1003,12 +1003,12 @@ static void pe_iterate_lengths(Scene *scene, PTCacheEdit *edit) if (pset->flag & PE_LOCK_FIRST) { key= point->keys + 1; k= 1; - dv1[0]= dv1[1]= dv1[2]= 0.0; + dv1[0] = dv1[1] = dv1[2] = 0.0; } else { key= point->keys; k= 0; - dv0[0]= dv0[1]= dv0[2]= 0.0; + dv0[0] = dv0[1] = dv0[2] = 0.0; } for (; k<point->totkey; k++, key++) { @@ -1527,8 +1527,8 @@ static int select_linked_exec(bContext *C, wmOperator *op) int location[2]; RNA_int_get_array(op->ptr, "location", location); - mval[0]= location[0]; - mval[1]= location[1]; + mval[0] = location[0]; + mval[1] = location[1]; PE_set_view3d_data(C, &data); data.mval= mval; @@ -1643,7 +1643,7 @@ int PE_lasso_select(bContext *C, const int mcords[][2], const short moves, short ParticleSystem *psys = edit->psys; ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); POINT_P; KEY_K; - float co[3], mat[4][4]= MAT4_UNITY; + float co[3], mat[4][4] = MAT4_UNITY; int screen_co[2]; PEData data; @@ -2535,7 +2535,7 @@ static void toggle_particle_cursor(bContext *C, int enable) enum { DEL_PARTICLE, DEL_KEY }; -static EnumPropertyItem delete_type_items[]= { +static EnumPropertyItem delete_type_items[] = { {DEL_PARTICLE, "PARTICLE", 0, "Particle", ""}, {DEL_KEY, "KEY", 0, "Key", ""}, {0, NULL, 0, NULL, NULL}}; @@ -2691,10 +2691,10 @@ static void PE_mirror_x(Scene *scene, Object *ob, int tagged) /* rotate weights according to vertex index rotation */ rotation= mirrorfaces[pa->num*2+1]; - newpa->fuv[0]= pa->fuv[2]; - newpa->fuv[1]= pa->fuv[1]; - newpa->fuv[2]= pa->fuv[0]; - newpa->fuv[3]= pa->fuv[3]; + newpa->fuv[0] = pa->fuv[2]; + newpa->fuv[1] = pa->fuv[1]; + newpa->fuv[2] = pa->fuv[0]; + newpa->fuv[3] = pa->fuv[3]; while (rotation-- > 0) if (me->mface[pa->num].v4) { SHIFT4(float, newpa->fuv[0], newpa->fuv[1], newpa->fuv[2], newpa->fuv[3]); @@ -3088,9 +3088,9 @@ static void intersect_dm_quad_weights(const float v1[3], const float v2[3], cons copy_v3_v3(vert[2], v3); copy_v3_v3(vert[3], v4); - co[0]= v1[0]*w[0] + v2[0]*w[1] + v3[0]*w[2] + v4[0]*w[3]; - co[1]= v1[1]*w[0] + v2[1]*w[1] + v3[1]*w[2] + v4[1]*w[3]; - co[2]= v1[2]*w[0] + v2[2]*w[1] + v3[2]*w[2] + v4[2]*w[3]; + co[0] = v1[0]*w[0] + v2[0]*w[1] + v3[0]*w[2] + v4[0]*w[3]; + co[1] = v1[1]*w[0] + v2[1]*w[1] + v3[1]*w[2] + v4[1]*w[3]; + co[2] = v1[2]*w[0] + v2[2]*w[1] + v3[2]*w[2] + v4[2]*w[3]; interp_weights_poly_v3(w, vert, 4, co); } @@ -3198,10 +3198,10 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, if (isect_line_tri_v3(co1, co2, v1, v2, v3, &cur_d, cur_uv)) { if (cur_d<*min_d) { *min_d=cur_d; - min_w[0]= 1.0f - cur_uv[0] - cur_uv[1]; - min_w[1]= cur_uv[0]; - min_w[2]= cur_uv[1]; - min_w[3]= 0.0f; + min_w[0] = 1.0f - cur_uv[0] - cur_uv[1]; + min_w[1] = cur_uv[0]; + min_w[2] = cur_uv[1]; + min_w[3] = 0.0f; if (mface->v4) intersect_dm_quad_weights(v1, v2, v3, v4, min_w); *min_face=i; @@ -3212,10 +3212,10 @@ static int particle_intersect_dm(Scene *scene, Object *ob, DerivedMesh *dm, if (isect_line_tri_v3(co1, co2, v1, v3, v4, &cur_d, cur_uv)) { if (cur_d<*min_d) { *min_d=cur_d; - min_w[0]= 1.0f - cur_uv[0] - cur_uv[1]; - min_w[1]= 0.0f; - min_w[2]= cur_uv[0]; - min_w[3]= cur_uv[1]; + min_w[0] = 1.0f - cur_uv[0] - cur_uv[1]; + min_w[1] = 0.0f; + min_w[2] = cur_uv[0]; + min_w[3] = cur_uv[1]; intersect_dm_quad_weights(v1, v2, v3, v4, min_w); *min_face=i; intersect=1; @@ -3274,8 +3274,8 @@ static int brush_add(PEData *data, short number) } } - mco[0]= data->mval[0] + dmx; - mco[1]= data->mval[1] + dmy; + mco[0] = data->mval[0] + dmx; + mco[1] = data->mval[1] + dmy; ED_view3d_win_to_segment_clip(data->vc.ar, data->vc.v3d, mco, co1, co2); mul_m4_v3(imat, co1); @@ -3368,11 +3368,11 @@ static int brush_add(PEData *data, short number) maxd= ptn[maxw-1].dist; for (w=0; w<maxw; w++) { - weight[w]= (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd)); + weight[w] = (float)pow(2.0, (double)(-6.0f * ptn[w].dist / maxd)); totw += weight[w]; } for (;w<3; w++) { - weight[w]= 0.0f; + weight[w] = 0.0f; } for (w=0; w<maxw; w++) @@ -3506,15 +3506,15 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) flip= RNA_boolean_get(itemptr, "pen_flip"); if (bedit->first) { - bedit->lastmouse[0]= mouse[0]; - bedit->lastmouse[1]= mouse[1]; + bedit->lastmouse[0] = mouse[0]; + bedit->lastmouse[1] = mouse[1]; } dx= mouse[0] - bedit->lastmouse[0]; dy= mouse[1] - bedit->lastmouse[1]; - mval[0]= mouse[0]; - mval[1]= mouse[1]; + mval[0] = mouse[0]; + mval[1] = mouse[1]; /* disable locking temporatily for disconnected hair */ @@ -3529,7 +3529,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) view3d_operator_needs_opengl(C); selected= (short)count_selected_keys(scene, edit); - dmax = maxf(fabsf(dx), fabsf(dy)); + dmax = max_ff(fabsf(dx), fabsf(dy)); tot_steps = dmax/(0.2f * brush->size) + 1; dx /= (float)tot_steps; @@ -3639,7 +3639,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) data.mval= mval; data.rad= (float)brush->size; - data.vec[0]= data.vec[1]= data.vec[2]= 0.0f; + data.vec[0] = data.vec[1] = data.vec[2] = 0.0f; data.tot= 0; data.smoothfac= brush->strength; @@ -3693,8 +3693,8 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); } - bedit->lastmouse[0]= mouse[0]; - bedit->lastmouse[1]= mouse[1]; + bedit->lastmouse[0] = mouse[0]; + bedit->lastmouse[1] = mouse[1]; bedit->first= 0; } @@ -4109,7 +4109,7 @@ int PE_minmax(Scene *scene, float min[3], float max[3]) LOOP_SELECTED_KEYS { copy_v3_v3(co, key->co); mul_m4_v3(mat, co); - DO_MINMAX(co, min, max); + DO_MINMAX(co, min, max); ok= 1; } } diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index a17d84af128..221aad2161c 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -110,11 +110,14 @@ static int particle_system_remove_exec(bContext *C, wmOperator *UNUSED(op)) /* possible this isn't the active object * object_remove_particle_system() clears the mode on the last psys - * */ - if (mode_orig & OB_MODE_PARTICLE_EDIT) - if ((ob->mode & OB_MODE_PARTICLE_EDIT)==0) - if (scene->basact && scene->basact->object==ob) + */ + if (mode_orig & OB_MODE_PARTICLE_EDIT) { + if ((ob->mode & OB_MODE_PARTICLE_EDIT) == 0) { + if (scene->basact && scene->basact->object == ob) { WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); + } + } + } WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); WM_event_add_notifier(C, NC_OBJECT|ND_POINTCACHE, ob); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 315386a947e..4a313079ad0 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -196,10 +196,10 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char int i, j; int channelSize = paramsize; - if (entries==3) { + if (entries == 3) { elbeemSimplifyChannelVec3(channel, &channelSize); } - else if (entries==1) { + else if (entries == 1) { elbeemSimplifyChannelFloat(channel, &channelSize); } else { @@ -211,10 +211,10 @@ static void fluidsimPrintChannel(FILE *file, float *channel, int paramsize, char fprintf(file, " "); for (j=0;j <= entries;j++) { // also print time value fprintf(file, " %f ", channel[i*(entries + 1) + j]); - if (j==entries-1) { fprintf(file, " "); } - } + if (j == entries-1) { fprintf(file, " "); } + } fprintf(file, "\n"); - } + } fprintf(file, " ;\n"); } @@ -402,7 +402,7 @@ static void fluid_init_all_channels(bContext *C, Object *UNUSED(fsDomain), Fluid } /* now we loop over the frames and fill the allocated channels with data */ - for (i=0; i<channels->length; i++) { + for (i=0; i < channels->length; i++) { FluidObject *fobj; float viscosity, gravity[3]; float timeAtFrame, time; @@ -527,7 +527,7 @@ static void export_fluid_objects(ListBase *fobjects, Scene *scene, int length) if ( ELEM(fsmesh.type, OB_FLUIDSIM_FLUID, OB_FLUIDSIM_INFLOW)) { fsmesh.channelInitialVel = fobj->InitialVelocity; fsmesh.localInivelCoords = ((fluidmd->fss->typeFlags & OB_FSINFLOW_LOCALCOORD)?1:0); - } + } if (fluidmd->fss->typeFlags & OB_FSBND_NOSLIP) fsmesh.obstacleType = FLUIDSIM_OBSTACLE_NOSLIP; @@ -593,7 +593,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom for (base=scene->base.first; base; base= base->next) { Object *ob = base->object; - FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); + FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); /* only find objects with fluid modifiers */ if (!fluidmdtmp || ob->type != OB_MESH) continue; @@ -627,7 +627,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom return 0; } - if (channelObjCount>=255) { + if (channelObjCount >= 255) { BKE_report(reports, RPT_ERROR, "Cannot bake with more then 256 objects"); return 0; } @@ -648,7 +648,7 @@ static int fluid_validate_scene(ReportList *reports, Scene *scene, Object *fsDom static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetFile, char *debugStrBuffer) { FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(fsDomain, eModifierType_Fluidsim); - FluidsimSettings *domainSettings= fluidmd->fss; + FluidsimSettings *domainSettings= fluidmd->fss; FILE *fileCfg; int dirExist = 0; char newSurfdataPath[FILE_MAX]; /* modified output settings */ @@ -673,7 +673,7 @@ static int fluid_init_filepaths(Object *fsDomain, char *targetDir, char *targetF // check selected directory // simply try to open cfg file for writing to test validity of settings fileCfg = BLI_fopen(targetFile, "w"); - if (fileCfg) { + if (fileCfg) { dirExist = 1; fclose(fileCfg); // remove cfg dummy from directory test BLI_delete(targetFile, 0, 0); @@ -902,7 +902,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor /* make sure it corresponds to startFrame setting (old: noFrames = scene->r.efra - scene->r.sfra +1) */; noFrames = scene->r.efra - 0; if (noFrames<=0) { - BKE_report(reports, RPT_ERROR, "No frames to export - check your animation range settings"); + BKE_report(reports, RPT_ERROR, "No frames to export (check your animation range settings)"); fluidbake_free_data(channels, fobjects, fsset, fb); return 0; } @@ -1050,7 +1050,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor fsset->generateVertexVectors = (domainSettings->domainNovecgen==0); // init blender domain transform matrix - { int j; + { int j; for (i=0; i<4; i++) { for (j=0; j<4; j++) { fsset->surfaceTrafo[i*4+j] = invDomMat[j][i]; diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c index 89ddfe02208..fb99d296a54 100644 --- a/source/blender/editors/physics/physics_ops.c +++ b/source/blender/editors/physics/physics_ops.c @@ -61,7 +61,7 @@ static void operatortypes_particle(void) WM_operatortype_append(PARTICLE_OT_rekey); WM_operatortype_append(PARTICLE_OT_subdivide); WM_operatortype_append(PARTICLE_OT_remove_doubles); - WM_operatortype_append(PARTICLE_OT_weight_set); + WM_operatortype_append(PARTICLE_OT_weight_set); WM_operatortype_append(PARTICLE_OT_delete); WM_operatortype_append(PARTICLE_OT_mirror); diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index b61280f14ce..ad9b082d044 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -83,7 +83,7 @@ void image_buffer_rect_update(Scene *scene, RenderResult *rr, ImBuf *ibuf, volat /* if renrect argument, we only refresh scanlines */ if (renrect) { - /* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */ + /* if (ymax == recty), rendering of layer is ready, we should not draw, other things happen... */ if (rr->renlay == NULL || renrect->ymax >= rr->recty) return; @@ -202,7 +202,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) screen_render_scene_layer_set(op, mainp, &scene, &srl); if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { - BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); + BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected"); return OPERATOR_CANCELLED; } @@ -493,9 +493,9 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event) } if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { - BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); + BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected"); return OPERATOR_CANCELLED; - } + } /* stop all running jobs, currently previews frustrate Render */ WM_jobs_stop_all(CTX_wm_manager(C)); diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 1d0e5bb6d44..0b6b5cb8e4a 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -171,11 +171,13 @@ static void screen_opengl_render_apply(OGLRender *oglrender) } } else if (view_context) { + ED_view3d_draw_offscreen_init(scene, v3d); + GPU_offscreen_bind(oglrender->ofs); /* bind */ /* render 3d view */ if (rv3d->persp == RV3D_CAMOB && v3d->camera) { - /*int is_ortho= scene->r.mode & R_ORTHO;*/ + /*int is_ortho = scene->r.mode & R_ORTHO;*/ camera = v3d->camera; RE_GetCameraWindow(oglrender->re, camera, scene->r.cfra, winmat); @@ -189,7 +191,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) else perspective_m4(winmat, viewplane.xmin, viewplane.xmax, viewplane.ymin, viewplane.ymax, clipsta, clipend); } - if ((scene->r.mode & R_OSA) == 0) { + if ((scene->r.mode & R_OSA) == 0) { ED_view3d_draw_offscreen(scene, v3d, ar, sizex, sizey, NULL, winmat, TRUE, FALSE); GPU_offscreen_read_pixels(oglrender->ofs, GL_FLOAT, rr->rectf); } @@ -306,7 +308,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) char err_out[256] = "unknown"; if (G.background) { - BKE_report(op->reports, RPT_ERROR, "Can't use OpenGL render in background mode (no opengl context)"); + BKE_report(op->reports, RPT_ERROR, "Cannot use OpenGL render in background mode (no opengl context)"); return 0; } @@ -327,7 +329,7 @@ static int screen_opengl_render_init(bContext *C, wmOperator *op) } if (!is_animation && is_write_still && BKE_imtype_is_movie(scene->r.im_format.imtype)) { - BKE_report(op->reports, RPT_ERROR, "Can't write a single file with an animation format selected"); + BKE_report(op->reports, RPT_ERROR, "Cannot write a single file with an animation format selected"); return 0; } @@ -716,7 +718,7 @@ static int screen_opengl_render_exec(bContext *C, wmOperator *op) } } - // no redraw needed, we leave state as we entered it + /* no redraw needed, we leave state as we entered it */ // ED_update_for_newframe(C, 1); WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, CTX_data_scene(C)); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 694d2302fbd..a2f31b35246 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -341,7 +341,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre if (sp->pr_method == PR_ICON_RENDER) { if (mat->material_type == MA_TYPE_HALO) { sce->lay = 1 << MA_FLAT; - } + } else { sce->lay = 1 << MA_SPHERE_A; } @@ -368,7 +368,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre if (OB_TYPE_SUPPORT_MATERIAL(base->object->type)) { /* don't use assign_material, it changed mat->id.us, which shows in the UI */ Material ***matar = give_matarar(base->object); - int actcol = MAX2(base->object->actcol - 1, 0); + int actcol = max_ii(base->object->actcol - 1, 0); if (matar && actcol < base->object->totcol) (*matar)[actcol] = mat; @@ -386,7 +386,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre tex = localize_texture(origtex); sp->texcopy = tex; BLI_addtail(&pr_main->tex, tex); - } + } sce->lay = 1 << MA_TEXTURE; for (base = sce->base.first; base; base = base->next) { @@ -518,8 +518,8 @@ static int ed_preview_draw_rect(ScrArea *sa, Scene *sce, ID *id, int split, int if (ABS(rres.rectx - newx) < 2 && ABS(rres.recty - newy) < 2) { - newrect->xmax = MAX2(newrect->xmax, rect->xmin + rres.rectx + offx); - newrect->ymax = MAX2(newrect->ymax, rect->ymin + rres.recty); + newrect->xmax = max_ii(newrect->xmax, rect->xmin + rres.rectx + offx); + newrect->ymax = max_ii(newrect->ymax, rect->ymin + rres.recty); if (rres.rectx && rres.recty) { /* temporary conversion to byte for drawing */ @@ -597,7 +597,7 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r if (ok == 0) { ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER); } - } + } } /* **************************** new shader preview system ****************** */ @@ -649,7 +649,7 @@ static void shader_preview_updatejob(void *spv) if (sp->lampcopy && la->nodetree && sp->lampcopy->nodetree) ntreeLocalSync(sp->lampcopy->nodetree, la->nodetree); } - } + } } } @@ -861,7 +861,7 @@ static void icon_copy_rect(ImBuf *ibuf, unsigned int w, unsigned int h, unsigned scaledx = (float)w; scaledy = ( (float)ima->y / (float)ima->x) * (float)w; } - else { + else { scaledx = ( (float)ima->x / (float)ima->y) * (float)h; scaledy = (float)h; } diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 5b1c03f65df..c5320fde0ff 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -82,7 +82,7 @@ void ED_render_scene_update(Main *bmain, Scene *scene, int updated) return; /* don't call this recursively for frame updates */ - if(recursive_check) + if (recursive_check) return; recursive_check = TRUE; diff --git a/source/blender/editors/render/render_view.c b/source/blender/editors/render/render_view.c index 01c0169eb50..5ec7f4d05b6 100644 --- a/source/blender/editors/render/render_view.c +++ b/source/blender/editors/render/render_view.c @@ -220,7 +220,6 @@ void render_view_open(bContext *C, int mx, int my) else { /* Leave it alone so the image editor will just go back from * full screen to the original tiled setup */ - ; } } } @@ -282,7 +281,7 @@ static int render_view_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent if (wincur->screen->temp) { wm_window_lower(wincur); } - else { + else { wmWindow *win, *winshow; ScrArea *sa = find_area_showing_r_result(C, &winshow); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index ad9b0f61eb1..f30e0abb4f3 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -390,7 +390,7 @@ void ED_area_overdraw(bContext *C) az->do_draw = FALSE; } } - } + } glDisable(GL_BLEND); } @@ -465,11 +465,11 @@ void ED_region_do_draw(bContext *C, ARegion *ar) if (ar->drawrct.xmin == ar->drawrct.xmax) ar->drawrct = winrct; else { - /* extra clip for safety */ - ar->drawrct.xmin = MAX2(winrct.xmin, ar->drawrct.xmin); - ar->drawrct.ymin = MAX2(winrct.ymin, ar->drawrct.ymin); - ar->drawrct.xmax = MIN2(winrct.xmax, ar->drawrct.xmax); - ar->drawrct.ymax = MIN2(winrct.ymax, ar->drawrct.ymax); + /* extra clip for safety (intersect the rects, could use API func) */ + ar->drawrct.xmin = max_ii(winrct.xmin, ar->drawrct.xmin); + ar->drawrct.ymin = max_ii(winrct.ymin, ar->drawrct.ymin); + ar->drawrct.xmax = min_ii(winrct.xmax, ar->drawrct.xmax); + ar->drawrct.ymax = min_ii(winrct.ymax, ar->drawrct.ymax); } /* note; this sets state, so we can use wmOrtho and friends */ @@ -533,10 +533,7 @@ void ED_region_tag_redraw_partial(ARegion *ar, rcti *rct) } else if (ar->drawrct.xmin != ar->drawrct.xmax) { /* partial redraw already set, expand region */ - ar->drawrct.xmin = MIN2(ar->drawrct.xmin, rct->xmin); - ar->drawrct.ymin = MIN2(ar->drawrct.ymin, rct->ymin); - ar->drawrct.xmax = MAX2(ar->drawrct.xmax, rct->xmax); - ar->drawrct.ymax = MAX2(ar->drawrct.ymax, rct->ymax); + BLI_rcti_union(&ar->drawrct, rct); } } } @@ -1260,19 +1257,15 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) } else { /* prevent uiblocks to run */ - uiFreeBlocks(NULL, &ar->uiblocks); + uiFreeBlocks(NULL, &ar->uiblocks); } - - /* rechecks 2d matrix for header on dpi changing, do not do for other regions, it resets view && blocks view2d operator polls (ton) */ - if (ar->regiontype == RGN_TYPE_HEADER) - ar->v2d.flag &= ~V2D_IS_INITIALISED; } } /* externally called for floating regions like menus */ void ED_region_init(bContext *C, ARegion *ar) { -// ARegionType *at= ar->type; +// ARegionType *at = ar->type; /* refresh can be called before window opened */ region_subwindow(CTX_wm_window(C), ar); @@ -1414,7 +1407,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) /* put in front of list */ BLI_remlink(&sa->spacedata, sl); BLI_addhead(&sa->spacedata, sl); - } + } else { /* new space */ if (st) { @@ -1457,7 +1450,8 @@ void ED_area_prevspace(bContext *C, ScrArea *sa) ED_area_newspace(C, sa, sl->next->spacetype); } else { - ED_area_newspace(C, sa, SPACE_INFO); + /* no change */ + return; } ED_area_tag_redraw(sa); @@ -1670,11 +1664,9 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE; v2d->scroll &= ~V2D_SCROLL_VERTICAL_HIDE; - /* don't jump back when panels close or hide */ - if (!newcontext) - y = MAX2(-y, -v2d->cur.ymin); - else - y = -y; + /* ensure tot is set correctly, to keep views on bottons, with sliders */ + y = min_ii(y, v2d->cur.ymin); + y = -y; } else { /* for now, allow scrolling in both directions (since layouts are optimized for vertical, @@ -1688,7 +1680,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * /* don't jump back when panels close or hide */ if (!newcontext) - x = MAX2(x, v2d->cur.xmax); + x = max_ii(x, v2d->cur.xmax); y = -y; } @@ -1741,7 +1733,7 @@ void ED_region_header(const bContext *C, ARegion *ar) int maxco, xco, yco; int headery = ED_area_headersize(); - /* clear */ + /* clear */ UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL); glClear(GL_COLOR_BUFFER_BIT); @@ -1778,7 +1770,7 @@ void ED_region_header(const bContext *C, ARegion *ar) } /* always as last */ - UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, BLI_rctf_size_y(&ar->v2d.tot)); + UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, headery); /* restore view matrix? */ UI_view2d_view_restore(C); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 24053d76672..ce2d045dc80 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -600,8 +600,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo /* The maximum pixel amounts the image can be cropped * at the lower left without exceeding the origin. */ - int off_x = floor(MAX2(ix, 0)); - int off_y = floor(MAX2(iy, 0)); + int off_x = floor(max_ff(ix, 0.0f)); + int off_y = floor(max_ff(iy, 0.0f)); /* The zoomed space coordinate of the raster position * (starting at the lower left most unclipped pixel). @@ -625,8 +625,8 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo * covers the entire screen). */ glGetFloatv(GL_SCISSOR_BOX, scissor); - draw_w = mini(img_w - off_x, ceil((scissor[2] - rast_x) / xzoom)); - draw_h = mini(img_h - off_y, ceil((scissor[3] - rast_y) / yzoom)); + draw_w = min_ii(img_w - off_x, ceil((scissor[2] - rast_x) / xzoom)); + draw_h = min_ii(img_h - off_y, ceil((scissor[3] - rast_y) / yzoom)); if (draw_w > 0 && draw_h > 0) { int old_row_length = glaGetOneInteger(GL_UNPACK_ROW_LENGTH); diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 352039c5a61..a516603cfd4 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -194,7 +194,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } } - } + } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } @@ -236,7 +236,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } } - } + } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); return 1; } diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 2e1723027b8..60aad14efcf 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -36,6 +36,7 @@ #include "DNA_scene_types.h" #include "DNA_userdef_types.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" @@ -271,7 +272,7 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my) if (abs(my - se->v1->vec.y) <= 2 && mx >= min && mx <= max) return se; - } + } else { short min, max; min = MIN2(se->v1->vec.y, se->v2->vec.y); @@ -631,10 +632,8 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) max[0] = max[1] = 0.0f; for (sv = sc->vertbase.first; sv; sv = sv->next) { - min[0] = MIN2(min[0], sv->vec.x); - min[1] = MIN2(min[1], sv->vec.y); - max[0] = MAX2(max[0], sv->vec.x); - max[1] = MAX2(max[1], sv->vec.y); + const float fv[2] = {(float)sv->vec.x, (float)sv->vec.y}; + minmax_v2v2_v2(min, max, fv); } /* always make 0.0 left under */ @@ -875,7 +874,7 @@ static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir)) glBlendFunc(GL_DST_COLOR, GL_SRC_ALPHA); glEnable(GL_BLEND); /* value 181 was hardly computed: 181~105 */ - glColor4ub(255, 255, 255, 50); + glColor4ub(255, 255, 255, 50); /* draw_join_shape(sa, dir); */ glRecti(sa->v1->vec.x, sa->v1->vec.y, sa->v3->vec.x, sa->v3->vec.y); glDisable(GL_BLEND); @@ -1066,7 +1065,7 @@ static void screen_refresh_headersizes(void) for (st = lb->first; st; st = st->next) { ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER); if (art) art->prefsizey = ED_area_headersize(); - } + } } /* make this screen usable */ @@ -1320,7 +1319,7 @@ int ED_screen_area_active(const bContext *C) for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->swinid == sc->subwinactive) return 1; - } + } return 0; } @@ -1453,10 +1452,10 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) if (scene != sc->scene) { /* all areas endlocalview */ - // XXX ScrArea *sa= sc->areabase.first; + // XXX ScrArea *sa = sc->areabase.first; // while (sa) { // endlocalview(sa); - // sa= sa->next; + // sa = sa->next; // } sc->scene = scene; } @@ -1733,7 +1732,7 @@ void ED_refresh_viewport_fps(bContext *C) fpsi->redrawtime = fpsi->lredrawtime; fpsi->lredrawtime = animtimer->ltime; } - else { + else { /* playback stopped or shouldn't be running */ if (scene->fps_info) MEM_freeN(scene->fps_info); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 5eac841dec6..bd171ef247a 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -192,7 +192,7 @@ int ED_operator_region_view3d_active(bContext *C) return TRUE; CTX_wm_operator_poll_msg_set(C, "expected a view3d region"); - return FALSE; + return FALSE; } /* generic for any view2d which uses anim_ops */ @@ -256,7 +256,7 @@ int ED_operator_node_active(bContext *C) return 0; } -// XXX rename +/* XXX rename */ int ED_operator_graphedit_active(bContext *C) { return ed_spacetype_test(C, SPACE_IPO); @@ -580,7 +580,7 @@ static int actionzone_area_poll(bContext *C) for (az = sa->actionzones.first; az; az = az->next) if (BLI_rcti_isect_pt(&az->rect, x, y)) return 1; - } + } return 0; } @@ -628,6 +628,7 @@ static void actionzone_apply(bContext *C, wmOperator *op, int type) event.type = EVT_ACTIONZONE_AREA; else event.type = EVT_ACTIONZONE_REGION; + event.val = 0; event.customdata = op->customdata; event.customdatafree = TRUE; op->customdata = NULL; @@ -701,7 +702,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event) case ESCKEY: actionzone_exit(op); return OPERATOR_CANCELLED; - case LEFTMOUSE: + case LEFTMOUSE: actionzone_exit(op); return OPERATOR_CANCELLED; @@ -969,18 +970,18 @@ static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller /* if top or down edge selected, test height */ if (sa->v1->flag && sa->v4->flag) - *bigger = MIN2(*bigger, y1); + *bigger = min_ii(*bigger, y1); else if (sa->v2->flag && sa->v3->flag) - *smaller = MIN2(*smaller, y1); + *smaller = min_ii(*smaller, y1); } else { int x1 = sa->v4->vec.x - sa->v1->vec.x - AREAMINX; /* if left or right edge selected, test width */ if (sa->v1->flag && sa->v2->flag) - *bigger = MIN2(*bigger, x1); + *bigger = min_ii(*bigger, x1); else if (sa->v3->flag && sa->v4->flag) - *smaller = MIN2(*smaller, x1); + *smaller = min_ii(*smaller, x1); } } } @@ -1341,7 +1342,7 @@ static int area_split_apply(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return 1; - } + } return 0; } @@ -1691,7 +1692,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) AZone *az; if (event->type != EVT_ACTIONZONE_REGION) { - BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone"); + BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone"); return OPERATOR_CANCELLED; } @@ -1855,7 +1856,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) break; case ESCKEY: - ; + break; } return OPERATOR_RUNNING_MODAL; @@ -2071,15 +2072,23 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot) /* ************** switch screen operator ***************************** */ +static int screen_set_is_ok(bScreen *screen, bScreen *screen_prev) +{ + return ((screen->winid == 0) && + (screen->full == 0) && + (screen != screen_prev) && + (screen->id.name[2] != '.' || !(U.uiflag & USER_HIDE_DOT))); +} /* function to be called outside UI context, or for redo */ static int screen_set_exec(bContext *C, wmOperator *op) { + Main *bmain = CTX_data_main(C); bScreen *screen = CTX_wm_screen(C); bScreen *screen_prev = screen; ScrArea *sa = CTX_wm_area(C); - int tot = BLI_countlist(&CTX_data_main(C)->screen); + int tot = BLI_countlist(&bmain->screen); int delta = RNA_int_get(op->ptr, "delta"); /* temp screens are for userpref or render display */ @@ -2089,17 +2098,19 @@ static int screen_set_exec(bContext *C, wmOperator *op) if (delta == 1) { while (tot--) { screen = screen->id.next; - if (screen == NULL) screen = CTX_data_main(C)->screen.first; - if (screen->winid == 0 && screen->full == 0 && screen != screen_prev) + if (screen == NULL) screen = bmain->screen.first; + if (screen_set_is_ok(screen, screen_prev)) { break; + } } } else if (delta == -1) { while (tot--) { screen = screen->id.prev; - if (screen == NULL) screen = CTX_data_main(C)->screen.last; - if (screen->winid == 0 && screen->full == 0 && screen != screen_prev) + if (screen == NULL) screen = bmain->screen.last; + if (screen_set_is_ok(screen, screen_prev)) { break; + } } } else { @@ -2359,14 +2370,14 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) ScrArea *sa = screen_areahascursor(sc, event->x, event->y); int dir; - if (sa) { + if (sa) { if (jd->sa1 != sa) { dir = area_getorientation(jd->sa1, sa); if (dir >= 0) { if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; jd->sa2 = sa; jd->sa2->flag |= AREA_FLAG_DRAWJOINTO; - } + } else { /* we are not bordering on the previously selected area * we check if area has common border with the one marked for removal @@ -2380,14 +2391,14 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) jd->sa2 = sa; if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM; if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO; - } + } else { if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; jd->sa2 = NULL; } } WM_event_add_notifier(C, NC_WINDOW, NULL); - } + } else { /* we are back in the area previously selected for keeping * we swap the areas if possible to allow user to choose */ @@ -2402,7 +2413,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) if (dir < 0) { printf("oops, didn't expect that!\n"); } - } + } else { dir = area_getorientation(jd->sa1, sa); if (dir >= 0) { @@ -2837,7 +2848,7 @@ static int header_flip_exec(bContext *C, wmOperator *UNUSED(op)) /* don't do anything if no region */ if (ar == NULL) return OPERATOR_CANCELLED; - } + } /* copied from SCREEN_OT_region_flip */ if (ar->alignment == RGN_ALIGN_TOP) @@ -2871,6 +2882,38 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot) ot->flag = 0; } + + +/* ************** show menus operator ***************************** */ + +/* show/hide header text menus */ +static int header_toggle_menus_exec(bContext *C, wmOperator *UNUSED(op)) +{ + ScrArea *sa = CTX_wm_area(C); + + sa->flag = sa->flag ^ HEADER_NO_PULLDOWN; + + ED_area_tag_redraw(CTX_wm_area(C)); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); + + return OPERATOR_FINISHED; +} + + +static void SCREEN_OT_header_toggle_menus(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Show/Hide Header Menus"; + ot->idname = "SCREEN_OT_header_toggle_menus"; + ot->description = "Show or hide the header pulldown menus"; + + /* api callbacks */ + ot->exec = header_toggle_menus_exec; + ot->poll = ED_operator_areaactive; + ot->flag = 0; +} + + /* ************** header tools operator ***************************** */ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UNUSED(arg)) { @@ -2883,6 +2926,11 @@ void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void *UN else uiItemO(layout, IFACE_("Flip to Top"), ICON_NONE, "SCREEN_OT_header_flip"); + if (sa->flag & HEADER_NO_PULLDOWN) + uiItemO(layout, IFACE_("Show Menus"), ICON_NONE, "SCREEN_OT_header_toggle_menus"); + else + uiItemO(layout, IFACE_("Hide Menus"), ICON_NONE, "SCREEN_OT_header_toggle_menus"); + uiItemS(layout); /* file browser should be fullscreen all the time, but other regions can be maximized/restored... */ @@ -3035,7 +3083,11 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e } else { if (sync) { - int step = floor((wt->duration - sad->last_duration) * FPS); + /* note: this is very simplistic, + * its has problem that it may skip too many frames. + * however at least this gives a less jittery playback */ + const int step = max_ii(1, floor((wt->duration - sad->last_duration) * FPS)); + /* skip frames */ if (sad->flag & ANIMPLAY_FLAG_REVERSE) scene->r.cfra -= step; @@ -3125,7 +3177,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e /* recalculate the timestep for the timer now that we've finished calculating this, * since the frames-per-second value may have been changed */ - // TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this? + /* TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this? */ wt->timestep = (1.0 / FPS); return OPERATOR_FINISHED; @@ -3175,7 +3227,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) else { int refresh = SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */ - if (mode == 1) // XXX only play audio forwards!? + if (mode == 1) /* XXX only play audio forwards!? */ sound_play_scene(scene); ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode); @@ -3427,7 +3479,7 @@ static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op)) static void SCREEN_OT_delete(wmOperatorType *ot) { /* identifiers */ - ot->name = "Delete Screen"; //was scene + ot->name = "Delete Screen"; /* was scene */ ot->description = "Delete active screen"; ot->idname = "SCREEN_OT_delete"; @@ -3547,6 +3599,7 @@ void ED_operatortypes_screen(void) WM_operatortype_append(SCREEN_OT_region_scale); WM_operatortype_append(SCREEN_OT_region_flip); WM_operatortype_append(SCREEN_OT_header_flip); + WM_operatortype_append(SCREEN_OT_header_toggle_menus); WM_operatortype_append(SCREEN_OT_header_toolbox); WM_operatortype_append(SCREEN_OT_screen_set); WM_operatortype_append(SCREEN_OT_screen_full_area); @@ -3574,7 +3627,7 @@ void ED_operatortypes_screen(void) /* tools shared by more space types */ WM_operatortype_append(ED_OT_undo); WM_operatortype_append(ED_OT_undo_push); - WM_operatortype_append(ED_OT_redo); + WM_operatortype_append(ED_OT_redo); WM_operatortype_append(ED_OT_undo_history); } @@ -3744,7 +3797,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", MEDIASTOP, KM_PRESS, 0, 0); /* Alternative keys for animation and sequencer playing */ -#if 0 // XXX: disabled for restoring later... bad implementation +#if 0 /* XXX: disabled for restoring later... bad implementation */ keymap = WM_keymap_find(keyconf, "Frames", 0, 0); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0); RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index aeae79aa9d0..0ecac5fc497 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -214,7 +214,7 @@ static int screenshot_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event) WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; - } + } return OPERATOR_CANCELLED; } @@ -365,7 +365,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float if (ok == 0) { printf("Write error: cannot save %s\n", name); - BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s\n", name); + BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s", name); break; } else { @@ -374,7 +374,7 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float } /* imbuf knows which rects are not part of ibuf */ - IMB_freeImBuf(ibuf); + IMB_freeImBuf(ibuf); } MEM_freeN(sj->dumprect); @@ -408,7 +408,7 @@ static int screencast_exec(bContext *C, wmOperator *op) sj->y = 0; sj->dumpsx = win->sizex; sj->dumpsy = win->sizey; - } + } else { ScrArea *curarea = CTX_wm_area(C); sj->x = curarea->totrct.xmin; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 34ff5efacc9..91a0a3821c9 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -113,26 +113,26 @@ #define IMAPAINT_CHAR_TO_FLOAT(c) ((c) / 255.0f) #define IMAPAINT_FLOAT_RGB_TO_CHAR(c, f) { \ - (c)[0]= FTOCHAR((f)[0]); \ - (c)[1]= FTOCHAR((f)[1]); \ - (c)[2]= FTOCHAR((f)[2]); \ + (c)[0] = FTOCHAR((f)[0]); \ + (c)[1] = FTOCHAR((f)[1]); \ + (c)[2] = FTOCHAR((f)[2]); \ } (void)0 #define IMAPAINT_FLOAT_RGBA_TO_CHAR(c, f) { \ - (c)[0]= FTOCHAR((f)[0]); \ - (c)[1]= FTOCHAR((f)[1]); \ - (c)[2]= FTOCHAR((f)[2]); \ - (c)[3]= FTOCHAR((f)[3]); \ + (c)[0] = FTOCHAR((f)[0]); \ + (c)[1] = FTOCHAR((f)[1]); \ + (c)[2] = FTOCHAR((f)[2]); \ + (c)[3] = FTOCHAR((f)[3]); \ } (void)0 #define IMAPAINT_CHAR_RGB_TO_FLOAT(f, c) { \ - (f)[0]= IMAPAINT_CHAR_TO_FLOAT((c)[0]); \ - (f)[1]= IMAPAINT_CHAR_TO_FLOAT((c)[1]); \ - (f)[2]= IMAPAINT_CHAR_TO_FLOAT((c)[2]); \ + (f)[0] = IMAPAINT_CHAR_TO_FLOAT((c)[0]); \ + (f)[1] = IMAPAINT_CHAR_TO_FLOAT((c)[1]); \ + (f)[2] = IMAPAINT_CHAR_TO_FLOAT((c)[2]); \ } (void)0 #define IMAPAINT_CHAR_RGBA_TO_FLOAT(f, c) { \ - (f)[0]= IMAPAINT_CHAR_TO_FLOAT((c)[0]); \ - (f)[1]= IMAPAINT_CHAR_TO_FLOAT((c)[1]); \ - (f)[2]= IMAPAINT_CHAR_TO_FLOAT((c)[2]); \ - (f)[3]= IMAPAINT_CHAR_TO_FLOAT((c)[3]); \ + (f)[0] = IMAPAINT_CHAR_TO_FLOAT((c)[0]); \ + (f)[1] = IMAPAINT_CHAR_TO_FLOAT((c)[1]); \ + (f)[2] = IMAPAINT_CHAR_TO_FLOAT((c)[2]); \ + (f)[3] = IMAPAINT_CHAR_TO_FLOAT((c)[3]); \ } (void)0 #define IMAPAINT_FLOAT_RGB_COPY(a, b) copy_v3_v3(a, b) @@ -173,7 +173,7 @@ typedef struct ImagePaintState { } ImagePaintState; typedef struct ImagePaintPartialRedraw { - int x1, y1, x2, y2; + int x1, y1, x2, y2; /* XXX, could use 'rcti' */ int enabled; } ImagePaintPartialRedraw; @@ -783,7 +783,7 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float else { //xi = (int)((uv[0]*ibuf->x) + 0.5f); //yi = (int)((uv[1]*ibuf->y) + 0.5f); - //if (xi<0 || xi>=ibuf->x || yi<0 || yi>=ibuf->y) return 0; + //if (xi < 0 || xi >= ibuf->x || yi < 0 || yi >= ibuf->y) return 0; /* wrap */ xi = ((int)(uv[0] * ibuf->x)) % ibuf->x; @@ -903,7 +903,7 @@ static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *buc else isect_ret = project_paint_occlude_ptv(pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v2], ps->screenCoords[mf->v3], w, ps->is_ortho); - /* Note, if isect_ret==-1 then we don't want to test the other side of the quad */ + /* Note, if (isect_ret == -1) then we don't want to test the other side of the quad */ if (isect_ret == 0 && mf->v4) { if (do_clip) isect_ret = project_paint_occlude_ptv_clip(ps, mf, pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v3], ps->screenCoords[mf->v4], 1); @@ -942,7 +942,7 @@ static int line_isect_y(const float p1[2], const float p2[2], const float y_leve if (y_diff < 0.000001f) { *x_isect = (p1[0] + p2[0]) * 0.5f; - return ISECT_TRUE; + return ISECT_TRUE; } if (p1[1] > y_level && p2[1] < y_level) { @@ -975,7 +975,7 @@ static int line_isect_x(const float p1[2], const float p2[2], const float x_leve if (x_diff < 0.000001f) { /* yuck, vertical line, we cant do much here */ *y_isect = (p1[0] + p2[0]) * 0.5f; - return ISECT_TRUE; + return ISECT_TRUE; } if (p1[0] > x_level && p2[0] < x_level) { @@ -1003,7 +1003,7 @@ static int cmp_uv(const float vec2a[2], const float vec2b[2]) float ya = (float)fmodf(vec2a[1], 1.0f); float xb = (float)fmodf(vec2b[0], 1.0f); - float yb = (float)fmodf(vec2b[1], 1.0f); + float yb = (float)fmodf(vec2b[1], 1.0f); if (xa < 0.0f) xa += 1.0f; if (ya < 0.0f) ya += 1.0f; @@ -1860,7 +1860,7 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s /* lower left out of radius test */ if (cent[1] < bucket_bounds->ymin) { return (len_squared_v2v2_alt(cent, bucket_bounds->xmin, bucket_bounds->ymin) < radius_squared) ? 1 : 0; - } + } /* top left test */ else if (cent[1] > bucket_bounds->ymax) { return (len_squared_v2v2_alt(cent, bucket_bounds->xmin, bucket_bounds->ymax) < radius_squared) ? 1 : 0; @@ -1870,7 +1870,7 @@ static int project_bucket_isect_circle(const float cent[2], const float radius_s /* lower right out of radius test */ if (cent[1] < bucket_bounds->ymin) { return (len_squared_v2v2_alt(cent, bucket_bounds->xmax, bucket_bounds->ymin) < radius_squared) ? 1 : 0; - } + } /* top right test */ else if (cent[1] > bucket_bounds->ymax) { return (len_squared_v2v2_alt(cent, bucket_bounds->xmax, bucket_bounds->ymax) < radius_squared) ? 1 : 0; @@ -2111,7 +2111,7 @@ static void project_bucket_clip_face( if ((inside_bucket_flag & ISECT_2) == 0) { copy_v2_v2(isectVCosSS[*tot], v1_clipSS); (*tot)++; } if ((inside_bucket_flag & ISECT_3) == 0) { copy_v2_v2(isectVCosSS[*tot], v2_clipSS); (*tot)++; } } - } + } if ((inside_bucket_flag & (ISECT_3 | ISECT_1)) != (ISECT_3 | ISECT_1)) { if (line_clip_rect2f(bucket_bounds, v3coSS, v1coSS, v1_clipSS, v2_clipSS)) { @@ -2394,7 +2394,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i tf_uv_pxoffset[1][1] = tf->uv[1][1] - yhalfpx; tf_uv_pxoffset[2][0] = tf->uv[2][0] - xhalfpx; - tf_uv_pxoffset[2][1] = tf->uv[2][1] - yhalfpx; + tf_uv_pxoffset[2][1] = tf->uv[2][1] - yhalfpx; if (mf->v4) { vCo[3] = ps->dm_mvert[mf->v4].co; @@ -3432,7 +3432,7 @@ static void project_paint_begin_clone(ProjPaintState *ps, int mouse[2]) mul_m4_v4(ps->projectMat, projCo); ps->cloneOffset[0] = mouse[0] - ((float)(ps->winx / 2.0f) + (ps->winx / 2.0f) * projCo[0] / projCo[3]); ps->cloneOffset[1] = mouse[1] - ((float)(ps->winy / 2.0f) + (ps->winy / 2.0f) * projCo[1] / projCo[3]); - } + } } static void project_paint_end(ProjPaintState *ps) @@ -3561,7 +3561,7 @@ static void project_paint_end(ProjPaintState *ps) ps->dm->release(ps->dm); } -/* 1= an undo, -1 is a redo. */ +/* 1 = an undo, -1 is a redo. */ static void partial_redraw_array_init(ImagePaintPartialRedraw *pr) { int tot = PROJ_BOUNDBOX_SQUARED; @@ -3583,11 +3583,11 @@ static int partial_redraw_array_merge(ImagePaintPartialRedraw *pr, ImagePaintPar { int touch = 0; while (tot--) { - pr->x1 = MIN2(pr->x1, pr_other->x1); - pr->y1 = MIN2(pr->y1, pr_other->y1); + pr->x1 = min_ii(pr->x1, pr_other->x1); + pr->y1 = min_ii(pr->y1, pr_other->y1); - pr->x2 = MAX2(pr->x2, pr_other->x2); - pr->y2 = MAX2(pr->y2, pr_other->y2); + pr->x2 = max_ii(pr->x2, pr_other->x2); + pr->y2 = max_ii(pr->y2, pr_other->y2); if (pr->x2 != -1) touch = 1; @@ -4032,11 +4032,11 @@ static void *do_projectpaint_thread(void *ph_v) /* end copy */ last_partial_redraw_cell = last_projIma->partRedrawRect + projPixel->bb_cell_index; - last_partial_redraw_cell->x1 = MIN2(last_partial_redraw_cell->x1, projPixel->x_px); - last_partial_redraw_cell->y1 = MIN2(last_partial_redraw_cell->y1, projPixel->y_px); + last_partial_redraw_cell->x1 = min_ii(last_partial_redraw_cell->x1, (int)projPixel->x_px); + last_partial_redraw_cell->y1 = min_ii(last_partial_redraw_cell->y1, (int)projPixel->y_px); - last_partial_redraw_cell->x2 = MAX2(last_partial_redraw_cell->x2, projPixel->x_px + 1); - last_partial_redraw_cell->y2 = MAX2(last_partial_redraw_cell->y2, projPixel->y_px + 1); + last_partial_redraw_cell->x2 = max_ii(last_partial_redraw_cell->x2, (int)projPixel->x_px + 1); + last_partial_redraw_cell->y2 = max_ii(last_partial_redraw_cell->y2, (int)projPixel->y_px + 1); switch (tool) { @@ -4100,7 +4100,7 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp { /* First unpack args from the struct */ ProjPaintState *ps = (ProjPaintState *)state; - int touch_any = 0; + int touch_any = 0; ProjectHandle handles[BLENDER_MAX_THREADS]; ListBase threads; @@ -4133,7 +4133,7 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp /* image bounds */ for (i = 0; i < ps->image_tot; i++) { handles[a].projImages[i].partRedrawRect = (ImagePaintPartialRedraw *)BLI_memarena_alloc(ps->arena_mt[a], sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED); - memcpy(handles[a].projImages[i].partRedrawRect, ps->projImages[i].partRedrawRect, sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED); + memcpy(handles[a].projImages[i].partRedrawRect, ps->projImages[i].partRedrawRect, sizeof(ImagePaintPartialRedraw) * PROJ_BOUNDBOX_SQUARED); } if (ps->thread_tot > 1) @@ -4222,10 +4222,10 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, imapaintpartial.enabled = 1; } else { - imapaintpartial.x1 = MIN2(imapaintpartial.x1, x); - imapaintpartial.y1 = MIN2(imapaintpartial.y1, y); - imapaintpartial.x2 = MAX2(imapaintpartial.x2, x + w); - imapaintpartial.y2 = MAX2(imapaintpartial.y2, y + h); + imapaintpartial.x1 = min_ii(imapaintpartial.x1, x); + imapaintpartial.y1 = min_ii(imapaintpartial.y1, y); + imapaintpartial.x2 = max_ii(imapaintpartial.x2, x + w); + imapaintpartial.y2 = max_ii(imapaintpartial.y2, y + h); } w = ((x + w - 1) >> IMAPAINT_TILE_BITS); @@ -4554,7 +4554,7 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) else if (ima->packedfile && ima->rr) { s->warnpackedfile = ima->id.name + 2; return 0; - } + } else if (ibuf && ibuf->channels != 4) { s->warnmultifile = ima->id.name + 2; return 0; @@ -5048,7 +5048,7 @@ static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) pop->prevmouse[1] = mouse[1]; } - else { + else { redraw = imapaint_paint_stroke(&pop->vc, &pop->s, pop->painter, pop->mode == PAINT_MODE_3D, pop->prevmouse, mouse, time, pressure); pop->prevmouse[0] = mouse[0]; pop->prevmouse[1] = mouse[1]; @@ -5066,7 +5066,7 @@ static void paint_brush_exit_tex(Brush *brush) MTex *mtex = &brush->mtex; if (mtex->tex && mtex->tex->nodetree) ntreeTexEndExecTree(mtex->tex->nodetree->execdata, 1); - } + } } static void paint_exit(bContext *C, wmOperator *op) @@ -5285,7 +5285,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) #define PX_SIZE_FADE_MIN 4.0f Scene *scene = CTX_data_scene(C); - //Brush *brush= image_paint_brush(C); + //Brush *brush = image_paint_brush(C); Paint *paint = paint_get_active_from_context(C); Brush *brush = paint_brush(paint); @@ -5302,7 +5302,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) !(ts->use_uv_sculpt && (scene->basact->object->mode == OB_MODE_EDIT)); if (use_zoom) { - pixel_size = size * maxf(zoomx, zoomy); + pixel_size = size * max_ff(zoomx, zoomy); } else { pixel_size = size; @@ -5654,7 +5654,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; if (BKE_object_obdata_is_libdata(ob)) { - BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); + BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 39a95300d5d..40dcb92f087 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -93,7 +93,7 @@ static int brush_scale_size_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Paint *paint = paint_get_active_from_context(C); struct Brush *brush = paint_brush(paint); - // Object *ob= CTX_data_active_object(C); + // Object *ob = CTX_data_active_object(C); float scalar = RNA_float_get(op->ptr, "scalar"); if (brush) { diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 2ae24db7c33..6396a0c2cbc 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -255,7 +255,7 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const if (pressure > FLT_EPSILON) { /* brushes can have a minimum size of 1.0 but with pressure it can be smaller then a pixel * causing very high step sizes, hanging blender [#32381] */ - const float size_clamp = maxf(1.0f, BKE_brush_size_get(scene, stroke->brush) * pressure); + const float size_clamp = max_ff(1.0f, BKE_brush_size_get(scene, stroke->brush) * pressure); scale = (size_clamp * stroke->brush->spacing / 50.0f) / length; if (scale > FLT_EPSILON) { mul_v2_fl(vec, scale); @@ -406,10 +406,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) paint_stroke_add_sample(p, stroke, event->x, event->y); paint_stroke_sample_average(stroke, &sample_average); - // let NDOF motion pass through to the 3D view so we can paint and rotate simultaneously! - // this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it - // since the 2D deltas are zero -- code in this file needs to be updated to use the - // post-NDOF_MOTION MOUSEMOVE + /* let NDOF motion pass through to the 3D view so we can paint and rotate simultaneously! + * this isn't perfect... even when an extra MOUSEMOVE is spoofed, the stroke discards it + * since the 2D deltas are zero -- code in this file needs to be updated to use the + * post-NDOF_MOTION MOUSEMOVE */ if (event->type == NDOF_MOTION) return OPERATOR_PASS_THROUGH; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index bb931dd1ff2..b8ac88f4d65 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -326,7 +326,7 @@ static void make_vertexcol(Object *ob) /* single ob */ CustomData_add_layer(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface); } if (!me->mloopcol) { - CustomData_add_layer(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop); + CustomData_add_layer(&me->ldata, CD_MLOOPCOL, CD_DEFAULT, NULL, me->totloop); } mesh_update_customdata_pointers(me, TRUE); } @@ -1526,7 +1526,7 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, if (total_changed > 1 && do_multipaint) { float undo_change = get_mp_change(ndv, defbase_tot, defbase_sel, left_over); multipaint_selection(ndv, defbase_tot, undo_change, defbase_sel); - } + } /* or designatedw is still -1 put weight back as evenly as possible */ else { redistribute_change(ndv, defbase_tot, change_status, 2, -2, left_over, total_changed, do_auto_normalize); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 092ec32e724..38dbdcd8337 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3076,6 +3076,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, MultiresModifierData *mmd = sculpt_multires_active(scene, ob); ss->modifiers_active = sculpt_modifiers_active(scene, sd, ob); + ss->show_diffuse_color = sd->flags & SCULPT_SHOW_DIFFUSE; if (need_mask) { if (mmd == NULL) { @@ -3130,6 +3131,8 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, ss->pbvh = dm->getPBVH(ob, dm); ss->pmap = (need_pmap && dm->getPolyMap) ? dm->getPolyMap(ob, dm) : NULL; + pbvh_show_diffuse_color_set(ss->pbvh, ss->show_diffuse_color); + if (ss->modifiers_active) { if (!ss->orig_cos) { int a; @@ -3513,7 +3516,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) if (tool == SCULPT_TOOL_GRAB) copy_v3_v3(sd->anchored_location, cache->true_location); else if (tool == SCULPT_TOOL_THUMB) - copy_v3_v3(sd->anchored_location, cache->orig_grab_location); + copy_v3_v3(sd->anchored_location, cache->orig_grab_location); if (ELEM(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB)) { /* location stays the same for finding vertices in brush radius */ @@ -4151,7 +4154,7 @@ int ED_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd) * isn't one already */ if (mmd && !CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) { GridPaintMask *gmask; - int level = MAX2(1, mmd->sculptlvl); + int level = max_ii(1, mmd->sculptlvl); int gridsize = ccg_gridsize(level); int gridarea = gridsize * gridsize; int i, j; diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index b204fc75255..1b3fd24ae22 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -99,7 +99,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; MVert *mvert; - int *index, i, j; + int *index, i, j; if (unode->maxvert) { /* regular mesh restore */ @@ -224,7 +224,7 @@ static int sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNode SculptSession *ss = ob->sculpt; MVert *mvert; float *vmask; - int *index, i, j; + int *index, i, j; if (unode->maxvert) { /* regular mesh restore */ diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 10adeb3e721..9bd7d2a44ca 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -98,7 +98,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) /* need to do a view-sync here, so that the keys area doesn't jump around (it must copy this) */ UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); - /* loop through channels, and set up drawing depending on their type */ + /* loop through channels, and set up drawing depending on their type */ { /* first pass: just the standard GL-drawing for backdrop + text */ y = (float)ACHANNEL_FIRST; @@ -189,7 +189,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) /* if in NLA there's a strip active, map the view */ if (ac->datatype == ANIMCONT_ACTION) { - /* adt= ANIM_nla_mapping_get(ac, NULL); */ /* UNUSED */ + /* adt = ANIM_nla_mapping_get(ac, NULL); */ /* UNUSED */ /* start and end of action itself */ calc_action_range(ac->data, &act_start, &act_end, 0); @@ -307,7 +307,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) /* Increment the step */ y -= ACHANNEL_STEP; - } + } glDisable(GL_BLEND); /* Draw keyframes diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index eeb297b7f57..ae78b71f2ad 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -132,7 +132,7 @@ void ACTION_OT_new(wmOperatorType *ot) /* api callbacks */ ot->exec = act_new_exec; - // NOTE: this is used in the NLA too... + /* NOTE: this is used in the NLA too... */ //ot->poll = ED_operator_action_active; /* flags */ @@ -234,8 +234,8 @@ static void get_keyframe_extents(bAnimContext *ac, float *min, float *max, const int filter; /* get data to filter, from Action or Dopesheet */ - // XXX: what is sel doing here?! - // Commented it, was breaking things (eg. the "auto preview range" tool). + /* XXX: what is sel doing here?! + * Commented it, was breaking things (eg. the "auto preview range" tool). */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL *//*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); @@ -254,8 +254,9 @@ static void get_keyframe_extents(bAnimContext *ac, float *min, float *max, const /* find gp-frame which is less than or equal to cframe */ for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { - *min = MIN2(*min, gpf->framenum); - *max = MAX2(*max, gpf->framenum); + const float framenum = (float)gpf->framenum; + *min = min_ff(*min, framenum); + *max = max_ff(*max, framenum); } } else if (ale->datatype == ALE_MASKLAY) { @@ -267,8 +268,9 @@ static void get_keyframe_extents(bAnimContext *ac, float *min, float *max, const masklay_shape; masklay_shape = masklay_shape->next) { - *min = MIN2(*min, masklay_shape->frame); - *max = MAX2(*max, masklay_shape->frame); + const float framenum = (float)masklay_shape->frame; + *min = min_ff(*min, framenum); + *max = max_ff(*max, framenum); } } else { @@ -284,8 +286,8 @@ static void get_keyframe_extents(bAnimContext *ac, float *min, float *max, const } /* try to set cur using these values, if they're more extreme than previously set values */ - *min = MIN2(*min, tmin); - *max = MAX2(*max, tmax); + *min = min_ff(*min, tmin); + *max = max_ff(*max, tmax); } } @@ -493,7 +495,7 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op) /* copy keyframes */ if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { /* FIXME... */ - BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for Grease Pencil mode"); + BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for grease pencil mode"); return OPERATOR_CANCELLED; } else if (ac.datatype == ANIMCONT_MASK) { @@ -502,7 +504,7 @@ static int actkeys_copy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else { - if (copy_action_keys(&ac)) { + if (copy_action_keys(&ac)) { BKE_report(op->reports, RPT_ERROR, "No keyframes copied to keyframes copy/paste buffer"); return OPERATOR_CANCELLED; } @@ -542,8 +544,8 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op) /* paste keyframes */ if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) { - // FIXME... - BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for Grease Pencil or Mask mode"); + /* FIXME... */ + BKE_report(op->reports, RPT_ERROR, "Keyframe pasting is not available for grease pencil or mask mode"); return OPERATOR_CANCELLED; } else { @@ -588,7 +590,7 @@ void ACTION_OT_paste(wmOperatorType *ot) static EnumPropertyItem prop_actkeys_insertkey_types[] = { {1, "ALL", 0, "All Channels", ""}, {2, "SEL", 0, "Only Selected Channels", ""}, - {3, "GROUP", 0, "In Active Group", ""}, // xxx not in all cases + {3, "GROUP", 0, "In Active Group", ""}, /* XXX not in all cases */ {0, NULL, 0, NULL, NULL} }; @@ -1010,7 +1012,7 @@ static void setexpo_action_keys(bAnimContext *ac, short mode) if (mode == MAKE_CYCLIC_EXPO) { /* only add if one doesn't exist */ if (list_has_suitable_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, -1) == 0) { - // TODO: add some more preset versions which set different extrapolation options? + /* TODO: add some more preset versions which set different extrapolation options? */ add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES); } } @@ -1319,7 +1321,7 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - /* init edit data */ + /* init edit data */ /* loop over action data, averaging values */ filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); @@ -1369,13 +1371,13 @@ void ACTION_OT_frame_jump(wmOperatorType *ot) /* defines for snap keyframes tool */ static EnumPropertyItem prop_actkeys_snap_types[] = { - {ACTKEYS_SNAP_CFRA, "CFRA", 0, "Current frame", + {ACTKEYS_SNAP_CFRA, "CFRA", 0, "Current frame", "Snap selected keyframes to the current frame"}, - {ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", + {ACTKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", "Snap selected keyframes to the nearest (whole) frame (use to fix accidental sub-frame offsets)"}, - {ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", + {ACTKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", "Snap selected keyframes to the nearest second"}, - {ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", + {ACTKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", "Snap selected keyframes to the nearest marker"}, {0, NULL, 0, NULL, NULL} }; @@ -1435,7 +1437,7 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op) if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - // XXX... + /* XXX... */ if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) return OPERATOR_PASS_THROUGH; @@ -1477,11 +1479,11 @@ void ACTION_OT_snap(wmOperatorType *ot) /* defines for mirror keyframes tool */ static EnumPropertyItem prop_actkeys_mirror_types[] = { - {ACTKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current frame", + {ACTKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current frame", "Flip times of selected keyframes using the current frame as the mirror line"}, - {ACTKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", + {ACTKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", "Flip values of selected keyframes (i.e. negative values become positive, and vice versa)"}, - {ACTKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", + {ACTKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", "Flip times of selected keyframes using the first selected marker as the reference point"}, {0, NULL, 0, NULL, NULL} }; @@ -1502,7 +1504,7 @@ static void mirror_action_keys(bAnimContext *ac, short mode) ked.scene = ac->scene; /* for 'first selected marker' mode, need to find first selected marker first! */ - // XXX should this be made into a helper func in the API? + /* XXX should this be made into a helper func in the API? */ if (mode == ACTKEYS_MIRROR_MARKER) { TimeMarker *marker = ED_markers_get_first_selected(ac->markers); @@ -1548,7 +1550,7 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op) if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - // XXX... + /* XXX... */ if (ELEM(ac.datatype, ANIMCONT_GPENCIL, ANIMCONT_MASK)) return OPERATOR_PASS_THROUGH; diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index c684ae1de51..10085d8a149 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -111,7 +111,7 @@ enum { ACTKEYS_SNAP_CFRA = 1, ACTKEYS_SNAP_NEAREST_FRAME, ACTKEYS_SNAP_NEAREST_SECOND, - ACTKEYS_SNAP_NEAREST_MARKER, + ACTKEYS_SNAP_NEAREST_MARKER, } eActKeys_Snap_Mode; /* defines for mirror keyframes @@ -121,7 +121,7 @@ enum { ACTKEYS_MIRROR_CFRA = 1, ACTKEYS_MIRROR_YAXIS, ACTKEYS_MIRROR_XAXIS, - ACTKEYS_MIRROR_MARKER, + ACTKEYS_MIRROR_MARKER, } eActKeys_Mirror_Mode; /* ***************************************** */ diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index 5da348b2a84..d0f76c21019 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -763,7 +763,7 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se if (leftright == ACTKEYS_LRSEL_LEFT) { ked.f1 = MINAFRAMEF; ked.f2 = (float)(CFRA + 0.1f); - } + } else { ked.f1 = (float)(CFRA - 0.1f); ked.f2 = MAXFRAMEF; @@ -785,7 +785,7 @@ static void actkeys_select_leftright(bAnimContext *ac, short leftright, short se ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1); } - else if (ale->type == ANIMTYPE_GPLAYER) + else if (ale->type == ANIMTYPE_GPLAYER) ED_gplayer_frames_select_border(ale->data, ked.f1, ked.f2, select_mode); else if (ale->type == ANIMTYPE_MASKLAYER) ED_masklayer_frames_select_border(ale->data, ked.f1, ked.f2, select_mode); @@ -869,7 +869,7 @@ static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL); if (x < CFRA) RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_LEFT); - else + else RNA_enum_set(op->ptr, "mode", ACTKEYS_LRSEL_RIGHT); } @@ -1081,7 +1081,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ /* dopesheet summary covers everything */ summary_to_keylist(ac, &anim_keys, NULL); } - else if (ale->type == ANIMTYPE_GROUP) { + else if (ale->type == ANIMTYPE_GROUP) { // TODO: why don't we just give groups key_data too? bActionGroup *agrp = (bActionGroup *)ale->data; agroup_to_keylist(adt, agrp, &anim_keys, NULL); @@ -1144,7 +1144,7 @@ static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_ agrp->flag |= AGRP_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); - } + } else if (ale->type == ANIMTYPE_FCURVE) { FCurve *fcu = ale->data; @@ -1210,7 +1210,7 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even return OPERATOR_CANCELLED; /* get useful pointers from animation context data */ - /* ar= ac.ar; */ /* UNUSED */ + /* ar = ac.ar; */ /* UNUSED */ /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 2e92b1eea6f..c5f3ccee101 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -129,7 +129,7 @@ static SpaceLink *action_new(const bContext *C) /* not spacelink itself */ static void action_free(SpaceLink *UNUSED(sl)) { -// SpaceAction *saction= (SpaceAction *) sl; +// SpaceAction *saction = (SpaceAction *) sl; } @@ -377,7 +377,7 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_refresh(sa); break; case NC_SCENE: - switch (wmn->data) { + switch (wmn->data) { case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ case ND_OB_SELECT: saction->flag |= SACTION_TEMP_NEEDCHANSYNC; @@ -433,7 +433,7 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn) saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); break; - } + } break; case NC_WINDOW: if (saction->flag & SACTION_TEMP_NEEDCHANSYNC) { diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c index 2cbcbcdbc9a..35344f2c5a4 100644 --- a/source/blender/editors/space_api/spacetypes.c +++ b/source/blender/editors/space_api/spacetypes.c @@ -193,7 +193,7 @@ void ED_spacetypes_keymap(wmKeyConfig *keyconf) typedef struct RegionDrawCB { struct RegionDrawCB *next, *prev; - void (*draw)(const struct bContext *, struct ARegion *, void *); + void (*draw)(const struct bContext *, struct ARegion *, void *); void *customdata; int type; @@ -239,7 +239,7 @@ void ED_region_draw_cb_draw(const bContext *C, ARegion *ar, int type) for (rdc = ar->type->drawcalls.first; rdc; rdc = rdc->next) { if (rdc->type == type) rdc->draw(C, ar, rdc->customdata); - } + } } diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index e5f5a4beac6..24e9effa9eb 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -236,7 +236,7 @@ static int buttons_context_path_material(ButsContextPath *path, int for_texture) if (ma) { RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; - } + } return 1; } } @@ -890,7 +890,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r else CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL); return 1; - } + } else if (CTX_data_equals(member, "particle_settings")) { /* only available when pinned */ PointerRNA *ptr = get_pointer_type(path, &RNA_ParticleSettings); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 9a7284de660..d40426a5bc9 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -162,7 +162,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) char *str; if (CTX_wm_space_file(C)) { - BKE_report(op->reports, RPT_ERROR, "Can't activate a file selector, one already open"); + BKE_report(op->reports, RPT_ERROR, "Cannot activate a file selector, one already open"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index a24a292be06..7d2374738ef 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -326,7 +326,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) /* currently works by redraws... if preview is set, it (re)starts job */ sbuts->preview = 1; break; - } + } break; case NC_WORLD: buttons_area_redraw(sa, BCONTEXT_WORLD); diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index d7936c1e2e8..fc9c040852f 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -716,7 +716,7 @@ static float get_shortest_pattern_side(MovieTrackingMarker *marker) cur_len = len_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]); - len = minf(cur_len, len); + len = min_ff(cur_len, len); } return len; @@ -788,11 +788,11 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo dy = 6.0f / height / sc->zoom; side = get_shortest_pattern_side(marker); - patdx = minf(dx * 2.0f / 3.0f, side / 6.0f); - patdy = minf(dy * 2.0f / 3.0f, side * width / height / 6.0f); + patdx = min_ff(dx * 2.0f / 3.0f, side / 6.0f); + patdy = min_ff(dy * 2.0f / 3.0f, side * width / height / 6.0f); - searchdx = minf(dx, (marker->search_max[0] - marker->search_min[0]) / 6.0f); - searchdy = minf(dy, (marker->search_max[1] - marker->search_min[1]) / 6.0f); + searchdx = min_ff(dx, (marker->search_max[0] - marker->search_min[0]) / 6.0f); + searchdy = min_ff(dy, (marker->search_max[1] - marker->search_min[1]) / 6.0f); px[0] = 1.0f / sc->zoom / width / sc->scale; px[1] = 1.0f / sc->zoom / height / sc->scale; diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index b495ca32813..71589517c83 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -395,7 +395,7 @@ int ED_clip_view_selection(const bContext *C, ARegion *ar, int fit) zoomx = (float)width / w / aspx; zoomy = (float)height / h / aspy; - newzoom = 1.0f / power_of_2(1.0f / minf(zoomx, zoomy)); + newzoom = 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)); if (fit || sc->zoom > newzoom) sc->zoom = newzoom; diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 37eb0bcb7c1..9ec2ad82bef 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -197,8 +197,8 @@ static int open_exec(bContext *C, wmOperator *op) if (op->customdata) MEM_freeN(op->customdata); - BKE_reportf(op->reports, RPT_ERROR, "Can't read \"%s\": %s", str, - errno ? strerror(errno) : TIP_("Unsupported movie clip format")); + BKE_reportf(op->reports, RPT_ERROR, "Cannot read '%s': %s", str, + errno ? strerror(errno) : TIP_("unsupported movie clip format")); return OPERATOR_CANCELLED; } @@ -747,7 +747,7 @@ static int view_all_exec(bContext *C, wmOperator *op) zoomx = (float) width / (w + 2 * margin); zoomy = (float) height / (h + 2 * margin); - sclip_zoom_set(C, minf(zoomx, zoomy), NULL); + sclip_zoom_set(C, min_ff(zoomx, zoomy), NULL); } else { if ((w >= width || h >= height) && (width > 0 && height > 0)) { @@ -755,7 +755,7 @@ static int view_all_exec(bContext *C, wmOperator *op) zoomy = (float) height / h; /* find the zoom value that will fit the image in the image space */ - sclip_zoom_set(C, 1.0f / power_of_2(1.0f / minf(zoomx, zoomy)), NULL); + sclip_zoom_set(C, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL); } else sclip_zoom_set(C, 1.0f, NULL); diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index c061125b4d5..f4ad5eee61e 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -372,8 +372,8 @@ static int mouse_on_slide_zone(SpaceClip *sc, MovieTrackingMarker *marker, dx = size / width / sc->zoom; dy = size / height / sc->zoom; - dx = minf(dx, (max[0] - min[0]) / 6.0f); - dy = minf(dy, (max[1] - min[1]) / 6.0f); + dx = min_ff(dx, (max[0] - min[0]) / 6.0f); + dy = min_ff(dy, (max[1] - min[1]) / 6.0f); return IN_RANGE_INCL(co[0], slide_zone[0] - dx, slide_zone[0] + dx) && IN_RANGE_INCL(co[1], slide_zone[1] - dy, slide_zone[1] + dy); @@ -424,14 +424,14 @@ static int get_mouse_pattern_corner(SpaceClip *sc, MovieTrackingMarker *marker, cur_len = len_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]); - len = minf(cur_len, len); + len = min_ff(cur_len, len); } dx = 12.0f / width / sc->zoom; dy = 12.0f / height / sc->zoom; - dx = minf(dx, len * 2.0f / 3.0f); - dy = minf(dy, len * width / height * 2.0f / 3.0f); + dx = min_ff(dx, len * 2.0f / 3.0f); + dy = min_ff(dy, len * width / height * 2.0f / 3.0f); for (i = 0; i < 4; i++) { float crn[2]; @@ -462,8 +462,8 @@ static int mouse_on_offset(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki dx = 12.0f / width / sc->zoom; dy = 12.0f / height / sc->zoom; - dx = minf(dx, (pat_max[0] - pat_min[0]) / 2.0f); - dy = minf(dy, (pat_max[1] - pat_min[1]) / 2.0f); + dx = min_ff(dx, (pat_max[0] - pat_min[0]) / 2.0f); + dy = min_ff(dy, (pat_max[1] - pat_min[1]) / 2.0f); return co[0] >= pos[0] - dx && co[0] <= pos[0] + dx && co[1] >= pos[1] - dy && co[1] <= pos[1] + dy; } @@ -1018,7 +1018,7 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit if (frames_limit == 0) frames_limit = track->frames_limit; else - frames_limit = MIN2(frames_limit, track->frames_limit); + frames_limit = min_ii(frames_limit, (int)track->frames_limit); } } } @@ -1396,9 +1396,8 @@ static void solve_camera_freejob(void *scv) } solved = BKE_tracking_reconstruction_finish(scj->context, tracking); - if (!solved) - BKE_report(scj->reports, RPT_WARNING, "Some data failed to reconstruct, see console for details"); + BKE_report(scj->reports, RPT_WARNING, "Some data failed to reconstruct (see console for details)"); else BKE_reportf(scj->reports, RPT_INFO, "Average re-projection error: %.3f", tracking->reconstruction.error); @@ -1410,7 +1409,7 @@ static void solve_camera_freejob(void *scv) id_us_plus(&clip->id); /* set blender camera focal length so result would look fine there */ - if (scene->camera) { + if (scene->camera && GS(scene->camera->id.name) == ID_CA) { Camera *camera = (Camera *)scene->camera->data; int width, height; @@ -3372,7 +3371,7 @@ static int tracking_object_remove_exec(bContext *C, wmOperator *op) object = BKE_tracking_object_get_active(tracking); if (object->flag & TRACKING_OBJECT_CAMERA) { - BKE_report(op->reports, RPT_WARNING, "Object used for camera tracking can't be deleted"); + BKE_report(op->reports, RPT_WARNING, "Object used for camera tracking cannot be deleted"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index feb523237ba..b8e162bfb17 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -107,7 +107,7 @@ static int mouse_on_crns(float co[2], float pos[2], float crns[4][2], float epsx { float dist = dist_to_crns(co, pos, crns); - return dist < maxf(epsx, epsy); + return dist < max_ff(epsx, epsy); } static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack *track) @@ -128,8 +128,8 @@ static int track_mouse_area(const bContext *C, float co[2], MovieTrackingTrack * epsy = MIN4(pat_min[1] - marker->search_min[1], marker->search_max[1] - pat_max[1], fabsf(pat_min[1]), fabsf(pat_max[1])) / 2; - epsx = maxf(epsx, 2.0f / width); - epsy = maxf(epsy, 2.0f / height); + epsx = max_ff(epsx, 2.0f / width); + epsy = max_ff(epsy, 2.0f / height); if (sc->flag & SC_SHOW_MARKER_SEARCH) { if (mouse_on_rect(co, marker->pos, marker->search_min, marker->search_max, epsx, epsy)) diff --git a/source/blender/editors/space_console/console_draw.c b/source/blender/editors/space_console/console_draw.c index c4a5c2a0154..f19835b7f85 100644 --- a/source/blender/editors/space_console/console_draw.c +++ b/source/blender/editors/space_console/console_draw.c @@ -84,7 +84,7 @@ typedef struct ConsoleDrawContext { #if 0 /* used by textview, may use later */ int *xy; // [2] int *sel; // [2] - int *pos_pick; // bottom of view == 0, top of file == combine chars, end of line is lower then start. + int *pos_pick; /* bottom of view == 0, top of file == combine chars, end of line is lower then start. */ int *mval; // [2] int draw; #endif diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index ecd9e316cef..c2344cca557 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -39,6 +39,7 @@ #include "BLI_string.h" #include "BLI_dynstr.h" #include "BLI_utildefines.h" +#include "BLI_math.h" #include "BKE_context.h" #include "BKE_text.h" /* only for character utility funcs */ @@ -650,7 +651,7 @@ static int console_clear_exec(bContext *C, wmOperator *op) short scrollback = RNA_boolean_get(op->ptr, "scrollback"); short history = RNA_boolean_get(op->ptr, "history"); - /*ConsoleLine *ci= */ console_history_verify(C); + /*ConsoleLine *ci = */ console_history_verify(C); if (scrollback) { /* last item in mistory */ while (sc->scrollback.first) @@ -803,7 +804,7 @@ void CONSOLE_OT_history_append(wmOperatorType *ot) ot->poll = ED_operator_console_active; /* properties */ - RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position"); + RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position"); RNA_def_int(ot->srna, "current_character", 0, 0, INT_MAX, "Cursor", "The index of the cursor", 0, 10000); RNA_def_boolean(ot->srna, "remove_duplicates", 0, "Remove Duplicates", "Remove duplicate items in the history"); } @@ -904,8 +905,8 @@ static int console_copy_exec(bContext *C, wmOperator *UNUSED(op)) for (cl = sc->scrollback.first; cl; cl = cl->next) { if (sel[0] <= cl->len && sel[1] >= 0) { - int sta = MAX2(sel[0], 0); - int end = MIN2(sel[1], cl->len); + int sta = max_ii(sel[0], 0); + int end = min_ii(sel[1], cl->len); if (BLI_dynstr_get_len(buf_dyn)) BLI_dynstr_append(buf_dyn, "\n"); @@ -1050,7 +1051,7 @@ static void console_modal_select_apply(bContext *C, wmOperator *op, wmEvent *eve static void console_cursor_set_exit(bContext *UNUSED(C), wmOperator *op) { -// SpaceConsole *sc= CTX_wm_space_console(C); +// SpaceConsole *sc = CTX_wm_space_console(C); SetConsoleCursor *scu = op->customdata; #if 0 @@ -1067,7 +1068,7 @@ static void console_cursor_set_exit(bContext *UNUSED(C), wmOperator *op) static int console_modal_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { SpaceConsole *sc = CTX_wm_space_console(C); -// ARegion *ar= CTX_wm_region(C); +// ARegion *ar = CTX_wm_region(C); SetConsoleCursor *scu; op->customdata = MEM_callocN(sizeof(SetConsoleCursor), "SetConsoleCursor"); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index b7ef278275e..75add570708 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -91,7 +91,7 @@ static SpaceLink *console_new(const bContext *UNUSED(C)) ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */ - //ar->v2d.keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM); + //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM); return (SpaceLink *)sconsole; } @@ -162,7 +162,7 @@ static void console_main_area_init(wmWindowManager *wm, ARegion *ar) static int id_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { -// SpaceConsole *sc= CTX_wm_space_console(C); +// SpaceConsole *sc = CTX_wm_space_console(C); if (drag->type == WM_DRAG_ID) return 1; return 0; @@ -184,7 +184,7 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop) static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { -// SpaceConsole *sc= CTX_wm_space_console(C); + // SpaceConsole *sc = CTX_wm_space_console(C); if (drag->type == WM_DRAG_PATH) return 1; return 0; @@ -359,7 +359,7 @@ static void console_header_area_draw(const bContext *C, ARegion *ar) static void console_main_area_listener(ARegion *ar, wmNotifier *wmn) { - // SpaceInfo *sinfo= sa->spacedata.first; + // SpaceInfo *sinfo = sa->spacedata.first; /* context changes */ switch (wmn->category) { diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 55e75992b89..fb438ae45fb 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -257,21 +257,23 @@ static int get_file_icon(struct direntry *file) else if (file->flags & BLENDERFILE) return ICON_FILE_BLEND; else if (file->flags & BLENDERFILE_BACKUP) - return ICON_FILE_BLEND; + return ICON_FILE_BACKUP; else if (file->flags & IMAGEFILE) return ICON_FILE_IMAGE; else if (file->flags & MOVIEFILE) return ICON_FILE_MOVIE; else if (file->flags & PYSCRIPTFILE) return ICON_FILE_SCRIPT; - else if (file->flags & SOUNDFILE) + else if (file->flags & SOUNDFILE) return ICON_FILE_SOUND; - else if (file->flags & FTFONTFILE) + else if (file->flags & FTFONTFILE) return ICON_FILE_FONT; - else if (file->flags & BTXFILE) + else if (file->flags & BTXFILE) return ICON_FILE_BLANK; - else if (file->flags & COLLADAFILE) + else if (file->flags & COLLADAFILE) return ICON_FILE_BLANK; + else if (file->flags & TEXTFILE) + return ICON_FILE_TEXT; else return ICON_FILE_BLANK; } @@ -280,7 +282,7 @@ static void file_draw_icon(uiBlock *block, char *path, int sx, int sy, int icon, { uiBut *but; int x, y; - /*float alpha=1.0f;*/ + // float alpha = 1.0f; x = sx; y = sy - height; @@ -494,7 +496,7 @@ void file_draw_list(const bContext *C, ARegion *ar) sx += (int)(v2d->tot.xmin + 2.0f); sy = (int)(v2d->tot.ymax - sy); - file = filelist_file(files, i); + file = filelist_file(files, i); UI_ThemeColor4(TH_TEXT); @@ -544,7 +546,7 @@ void file_draw_list(const bContext *C, ARegion *ar) if (params->display == FILE_SHORTDISPLAY) { sx += (int)layout->column_widths[COLUMN_NAME] + 12; if (!(file->type & S_IFDIR)) { - file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); + file_draw_string(sx, sy, file->size, layout->column_widths[COLUMN_SIZE], layout->tile_h, align); sx += (int)layout->column_widths[COLUMN_SIZE] + 12; } } diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 7a364eb8685..763b18788de 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -554,7 +554,7 @@ int file_highlight_set(SpaceFile *sfile, ARegion *ar, int mx, int my) { View2D *v2d = &ar->v2d; FileSelectParams *params; - int numfiles, origfile; + int numfiles, origfile; if (sfile == NULL || sfile->files == NULL) return 0; @@ -849,7 +849,7 @@ int file_parent_exec(bContext *C, wmOperator *UNUSED(unused)) file_change_dir(C, 0); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); } - } + } return OPERATOR_FINISHED; @@ -942,7 +942,7 @@ int file_next_exec(bContext *C, wmOperator *UNUSED(unused)) folderlist_pushdir(sfile->folders_prev, sfile->params->dir); file_change_dir(C, 1); - } + } WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); return OPERATOR_FINISHED; @@ -1105,7 +1105,7 @@ int file_directory_new_exec(bContext *C, wmOperator *op) if (generate_name) { /* create a new, non-existing folder name */ if (!new_folder_path(sfile->params->dir, path, name)) { - BKE_report(op->reports, RPT_ERROR, "Couldn't create new folder name"); + BKE_report(op->reports, RPT_ERROR, "Could not create new folder name"); return OPERATOR_CANCELLED; } } @@ -1114,9 +1114,9 @@ int file_directory_new_exec(bContext *C, wmOperator *op) BLI_dir_create_recursive(path); if (!BLI_exists(path)) { - BKE_report(op->reports, RPT_ERROR, "Couldn't create new folder"); + BKE_report(op->reports, RPT_ERROR, "Could not create new folder"); return OPERATOR_CANCELLED; - } + } /* now remember file to jump into editing */ BLI_strncpy(sfile->params->renamefile, name, FILE_MAXFILE); @@ -1427,11 +1427,11 @@ static int file_rename_poll(bContext *C) SpaceFile *sfile = CTX_wm_space_file(C); if (sfile && sfile->params) { - if (sfile->params->active_file < 0) { + if (sfile->params->active_file < 0) { poll = 0; } else { - char dir[FILE_MAX], group[FILE_MAX]; + char dir[FILE_MAX], group[FILE_MAX]; if (filelist_islibrary(sfile->files, dir, group)) poll = 0; } } @@ -1460,11 +1460,11 @@ static int file_delete_poll(bContext *C) struct direntry *file; if (sfile && sfile->params) { - if (sfile->params->active_file < 0) { + if (sfile->params->active_file < 0) { poll = 0; } else { - char dir[FILE_MAX], group[FILE_MAX]; + char dir[FILE_MAX], group[FILE_MAX]; if (filelist_islibrary(sfile->files, dir, group)) poll = 0; file = filelist_file(sfile->files, sfile->params->active_file); if (file && S_ISDIR(file->type)) poll = 0; @@ -1485,7 +1485,7 @@ int file_delete_exec(bContext *C, wmOperator *UNUSED(op)) file = filelist_file(sfile->files, sfile->params->active_file); BLI_make_file_string(G.main->name, str, sfile->params->dir, file->relname); - BLI_delete(str, 0, 0); + BLI_delete(str, 0, 0); ED_fileselect_clear(C, sfile); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL); diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index a7054909aaa..a159c88221e 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -135,6 +135,16 @@ static void file_panel_system(const bContext *C, Panel *pa) file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0); } +static void file_panel_system_bookmarks(const bContext *C, Panel *pa) +{ + SpaceFile *sfile = CTX_wm_space_file(C); + + if (sfile && !(U.uiflag & USER_HIDE_SYSTEM_BOOKMARKS) ) { + file_panel_category(C, pa, FS_CATEGORY_SYSTEM_BOOKMARKS, &sfile->systemnr, ICON_BOOKMARKS, 0); + } + +} + static void file_panel_bookmarks(const bContext *C, Panel *pa) { SpaceFile *sfile = CTX_wm_space_file(C); @@ -193,7 +203,7 @@ static void file_panel_operator(const bContext *C, Panel *pa) { SpaceFile *sfile = CTX_wm_space_file(C); wmOperator *op = sfile->op; - // int empty= 1, flag; + // int empty = 1, flag; uiBlockSetFunc(uiLayoutGetBlock(pa->layout), file_draw_check_cb, NULL, NULL); @@ -212,6 +222,12 @@ void file_panels_register(ARegionType *art) pt->draw = file_panel_system; BLI_addtail(&art->paneltypes, pt); + pt = MEM_callocN(sizeof(PanelType), "spacetype file system bookmarks"); + strcpy(pt->idname, "FILE_PT_system_bookmarks"); + strcpy(pt->label, N_("System Bookmarks")); + pt->draw = file_panel_system_bookmarks; + BLI_addtail(&art->paneltypes, pt); + pt = MEM_callocN(sizeof(PanelType), "spacetype file bookmarks"); strcpy(pt->idname, "FILE_PT_bookmarks"); strcpy(pt->label, N_("Bookmarks")); diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 1408e8b801b..b505fed7baa 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -143,7 +143,8 @@ typedef struct FolderList { #define SPECIAL_IMG_FONTFILE 8 #define SPECIAL_IMG_UNKNOWNFILE 9 #define SPECIAL_IMG_LOADING 10 -#define SPECIAL_IMG_MAX SPECIAL_IMG_LOADING + 1 +#define SPECIAL_IMG_BACKUP 11 +#define SPECIAL_IMG_MAX SPECIAL_IMG_BACKUP + 1 static ImBuf *gSpecialFileImages[SPECIAL_IMG_MAX]; @@ -300,7 +301,7 @@ static int is_hidden_file(const char *filename, short hide_dot) if ( (len > 0) && (filename[len - 1] == '~') ) { is_hidden = 1; /* ignore file~ */ } - } + } } else { if (((filename[0] == '.') && (filename[1] == 0) )) { @@ -360,7 +361,7 @@ void filelist_filter(FileList *filelist) struct direntry *file = &filelist->filelist[i]; if (filelist->filterf(file, filelist->dir, filelist->filter, filelist->hide_dot) ) { num_filtered++; - } + } } if (filelist->fidx) { @@ -420,7 +421,7 @@ void filelist_free_icons(void) } } -//-----------------FOLDERLIST (previous/next) --------------// +/* -----------------FOLDERLIST (previous/next) -------------- */ ListBase *folderlist_new(void) { ListBase *p = MEM_callocN(sizeof(ListBase), "folderlist"); @@ -520,7 +521,7 @@ static void filelist_read_main(struct FileList *filelist); static void filelist_read_library(struct FileList *filelist); static void filelist_read_dir(struct FileList *filelist); -//------------------FILELIST------------------------// +/* ------------------FILELIST------------------------ */ FileList *filelist_new(short type) { FileList *p = MEM_callocN(sizeof(FileList), "filelist"); @@ -557,7 +558,7 @@ void filelist_free(struct FileList *filelist) } for (i = 0; i < filelist->numfiles; ++i) { - if (filelist->filelist[i].image) { + if (filelist->filelist[i].image) { IMB_freeImBuf(filelist->filelist[i].image); } filelist->filelist[i].image = NULL; @@ -573,7 +574,7 @@ void filelist_free(struct FileList *filelist) filelist->numfiles = 0; free(filelist->filelist); - filelist->filelist = NULL; + filelist->filelist = NULL; filelist->filter = 0; filelist->filter_glob[0] = '\0'; filelist->numfiltered = 0; @@ -683,6 +684,9 @@ ImBuf *filelist_geticon(struct FileList *filelist, int index) else if (file->flags & IMAGEFILE) { ibuf = gSpecialFileImages[SPECIAL_IMG_LOADING]; } + else if (file->flags & BLENDERFILE_BACKUP) { + ibuf = gSpecialFileImages[SPECIAL_IMG_BACKUP]; + } return ibuf; } @@ -791,7 +795,7 @@ static int file_extension_type(const char *relname) BLI_testextensie(relname, ".otf") || BLI_testextensie(relname, ".otc")) { - return FTFONTFILE; + return FTFONTFILE; } else if (BLI_testextensie(relname, ".btx")) { return BTXFILE; @@ -802,14 +806,14 @@ static int file_extension_type(const char *relname) else if (BLI_testextensie_array(relname, imb_ext_image) || (G.have_quicktime && BLI_testextensie_array(relname, imb_ext_image_qt))) { - return IMAGEFILE; + return IMAGEFILE; } else if (BLI_testextensie_array(relname, imb_ext_movie)) { - return MOVIEFILE; + return MOVIEFILE; } else if (BLI_testextensie_array(relname, imb_ext_audio)) { return SOUNDFILE; - } + } return 0; } @@ -817,8 +821,10 @@ int ED_file_extension_icon(const char *relname) { int type = file_extension_type(relname); - if (type == BLENDERFILE || type == BLENDERFILE_BACKUP) + if (type == BLENDERFILE) return ICON_FILE_BLEND; + else if (type == BLENDERFILE_BACKUP) + return ICON_FILE_BACKUP; else if (type == IMAGEFILE) return ICON_FILE_IMAGE; else if (type == MOVIEFILE) @@ -833,6 +839,8 @@ int ED_file_extension_icon(const char *relname) return ICON_FILE_BLANK; else if (type == COLLADAFILE) return ICON_FILE_BLANK; + else if (type == TEXTFILE) + return ICON_FILE_TEXT; return ICON_FILE_BLANK; } @@ -934,7 +942,7 @@ void filelist_parent(struct FileList *filelist) void filelist_select_file(struct FileList *filelist, int index, FileSelType select, unsigned int flag, FileCheckType check) { struct direntry *file = filelist_file(filelist, index); - if (file != NULL) { + if (file != NULL) { int check_ok = 0; switch (check) { case CHECK_DIRS: @@ -969,7 +977,7 @@ void filelist_select(struct FileList *filelist, FileSelection *sel, FileSelType /* select all valid files between first and last indicated */ if ( (sel->first >= 0) && (sel->first < filelist->numfiltered) && (sel->last >= 0) && (sel->last < filelist->numfiltered) ) { int current_file; - for (current_file = sel->first; current_file <= sel->last; current_file++) { + for (current_file = sel->first; current_file <= sel->last; current_file++) { filelist_select_file(filelist, current_file, select, flag, check); } } @@ -1036,7 +1044,7 @@ void filelist_from_library(struct FileList *filelist) struct ImBuf *ima; int ok, i, nprevs, nnames, idcode; char filename[FILE_MAX]; - char dir[FILE_MAX], group[GROUP_MAX]; + char dir[FILE_MAX], group[GROUP_MAX]; /* name test */ ok = filelist_islibrary(filelist, dir, group); @@ -1234,7 +1242,7 @@ void filelist_from_main(struct FileList *filelist) BLI_snprintf(files->relname, FILE_MAX + (MAX_ID_NAME - 2) + 3, "%s | %s", id->lib->name, id->name + 2); } files->type |= S_IFREG; -#if 0 // XXXXX TODO show the selection status of the objects +#if 0 /* XXXXX TODO show the selection status of the objects */ if (!filelist->has_func) { /* F4 DATA BROWSE */ if (idcode == ID_OB) { if ( ((Object *)id)->flag & SELECT) files->selflag |= SELECTED_FILE; @@ -1302,7 +1310,7 @@ static void thumbnails_startjob(void *tjv, short *stop, short *do_update, float if (limg->flags & IMAGEFILE) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_IMAGE); } - else if (limg->flags & BLENDERFILE) { + else if (limg->flags & (BLENDERFILE | BLENDERFILE_BACKUP)) { limg->img = IMB_thumb_manage(limg->path, THB_NORMAL, THB_SOURCE_BLEND); } else if (limg->flags & MOVIEFILE) { @@ -1359,7 +1367,7 @@ void thumbnails_start(struct FileList *filelist, const struct bContext *C) tj->filelist = filelist; for (idx = 0; idx < filelist->numfiles; idx++) { if (!filelist->filelist[idx].image) { - if ( (filelist->filelist[idx].flags & (IMAGEFILE | MOVIEFILE | BLENDERFILE)) ) { + if ( (filelist->filelist[idx].flags & (IMAGEFILE | MOVIEFILE | BLENDERFILE | BLENDERFILE_BACKUP)) ) { FileImage *limg = MEM_callocN(sizeof(struct FileImage), "loadimage"); BLI_strncpy(limg->path, filelist->filelist[idx].path, FILE_MAX); limg->index = idx; diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 1fa89e5db9a..49562958f82 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -94,6 +94,9 @@ FileSelectParams *ED_fileselect_get_params(struct SpaceFile *sfile) return sfile->params; } +/** + * \note RNA_struct_property_is_set_ex is used here because we wan't + * the previously used settings to be used here rather then overriding them */ short ED_fileselect_set_params(SpaceFile *sfile) { FileSelectParams *params; @@ -124,7 +127,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) else params->type = FILE_SPECIAL; - if (is_filepath && RNA_struct_property_is_set(op->ptr, "filepath")) { + if (is_filepath && RNA_struct_property_is_set_ex(op->ptr, "filepath", FALSE)) { char name[FILE_MAX]; RNA_string_get(op->ptr, "filepath", name); if (params->type == FILE_LOADLIB) { @@ -136,12 +139,12 @@ short ED_fileselect_set_params(SpaceFile *sfile) } } else { - if (is_directory && RNA_struct_property_is_set(op->ptr, "directory")) { + if (is_directory && RNA_struct_property_is_set_ex(op->ptr, "directory", FALSE)) { RNA_string_get(op->ptr, "directory", params->dir); sfile->params->file[0] = '\0'; } - if (is_filename && RNA_struct_property_is_set(op->ptr, "filename")) { + if (is_filename && RNA_struct_property_is_set_ex(op->ptr, "filename", FALSE)) { RNA_string_get(op->ptr, "filename", params->file); } } @@ -165,8 +168,6 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0; if (RNA_struct_find_property(op->ptr, "filter_movie")) params->filter |= RNA_boolean_get(op->ptr, "filter_movie") ? MOVIEFILE : 0; - if (RNA_struct_find_property(op->ptr, "filter_text")) - params->filter |= RNA_boolean_get(op->ptr, "filter_text") ? TEXTFILE : 0; if (RNA_struct_find_property(op->ptr, "filter_python")) params->filter |= RNA_boolean_get(op->ptr, "filter_python") ? PYSCRIPTFILE : 0; if (RNA_struct_find_property(op->ptr, "filter_font")) @@ -228,7 +229,7 @@ short ED_fileselect_set_params(SpaceFile *sfile) } if (is_relative_path) { - if (!RNA_struct_property_is_set(op->ptr, "relative_path")) { + if (!RNA_struct_property_is_set_ex(op->ptr, "relative_path", FALSE)) { RNA_boolean_set(op->ptr, "relative_path", U.flag & USER_RELPATHS); } } @@ -307,7 +308,7 @@ FileSelection ED_fileselect_layout_offset_rect(FileLayout *layout, const rcti *r CLAMP(rowmin, 0, layout->rows - 1); CLAMP(colmax, 0, layout->columns - 1); CLAMP(rowmax, 0, layout->rows - 1); - } + } if ((colmin > layout->columns - 1) || (rowmin > layout->rows - 1)) { sel.first = -1; diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 66cda3082ea..c57bfaeeb2c 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -80,9 +80,9 @@ struct _FSMenuEntry { typedef struct FSMenu { FSMenuEntry *fsmenu_system; + FSMenuEntry *fsmenu_system_bookmarks; FSMenuEntry *fsmenu_bookmarks; FSMenuEntry *fsmenu_recent; - } FSMenu; static FSMenu *g_fsmenu = NULL; @@ -103,6 +103,9 @@ static FSMenuEntry *fsmenu_get_category(struct FSMenu *fsmenu, FSMenuCategory ca case FS_CATEGORY_SYSTEM: fsm_head = fsmenu->fsmenu_system; break; + case FS_CATEGORY_SYSTEM_BOOKMARKS: + fsm_head = fsmenu->fsmenu_system_bookmarks; + break; case FS_CATEGORY_BOOKMARKS: fsm_head = fsmenu->fsmenu_bookmarks; break; @@ -119,6 +122,9 @@ static void fsmenu_set_category(struct FSMenu *fsmenu, FSMenuCategory category, case FS_CATEGORY_SYSTEM: fsmenu->fsmenu_system = fsm_head; break; + case FS_CATEGORY_SYSTEM_BOOKMARKS: + fsmenu->fsmenu_system_bookmarks = fsm_head; + break; case FS_CATEGORY_BOOKMARKS: fsmenu->fsmenu_bookmarks = fsm_head; break; @@ -336,9 +342,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) /* Adding Desktop and My Documents */ if (read_bookmarks) { SHGetSpecialFolderPath(0, line, CSIDL_PERSONAL, 0); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); SHGetSpecialFolderPath(0, line, CSIDL_DESKTOPDIRECTORY, 0); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); } } #else @@ -361,7 +367,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) FSRefMakePath(&dir, path, FILE_MAX); if (strcmp((char *)path, "/home") && strcmp((char *)path, "/net")) { /* /net and /home are meaningless on OSX, home folders are stored in /Users */ - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, (char *)path, FS_INSERT_SORTED); } } @@ -371,26 +377,26 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) home = getenv("HOME"); if (read_bookmarks && home) { BLI_snprintf(line, 256, "%s/", home); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); BLI_snprintf(line, 256, "%s/Desktop/", home); if (BLI_exists(line)) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); } BLI_snprintf(line, 256, "%s/Documents/", home); if (BLI_exists(line)) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); } BLI_snprintf(line, 256, "%s/Pictures/", home); if (BLI_exists(line)) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); } BLI_snprintf(line, 256, "%s/Music/", home); if (BLI_exists(line)) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); } BLI_snprintf(line, 256, "%s/Movies/", home); if (BLI_exists(line)) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); } } #else @@ -423,7 +429,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) if (!CFStringGetCString(pathString, line, 256, kCFStringEncodingASCII)) continue; - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); CFRelease(pathString); CFRelease(cfURL); @@ -450,7 +456,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) FSRefMakePath(&dir, path, FILE_MAX); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, (char *)path, FS_INSERT_SORTED); } /* Finally get user favorite places */ @@ -473,7 +479,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) if (!CFStringGetCString(pathString, line, 256, kCFStringEncodingASCII)) continue; - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); CFRelease(pathString); CFRelease(cfURL); @@ -491,10 +497,10 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) if (read_bookmarks && home) { BLI_snprintf(line, FILE_MAXDIR, "%s/", home); - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); BLI_snprintf(line, FILE_MAXDIR, "%s/Desktop/", home); if (BLI_exists(line)) { - fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED); + fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED); } } @@ -564,13 +570,17 @@ void fsmenu_refresh_system_category(struct FSMenu *fsmenu) fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM); fsmenu_set_category(fsmenu, FS_CATEGORY_SYSTEM, NULL); + fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS); + fsmenu_set_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, NULL); + /* Add all entries to system category */ - fsmenu_read_system(fsmenu, FALSE); + fsmenu_read_system(fsmenu, TRUE); } void fsmenu_free(struct FSMenu *fsmenu) { fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM); + fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS); fsmenu_free_category(fsmenu, FS_CATEGORY_BOOKMARKS); fsmenu_free_category(fsmenu, FS_CATEGORY_RECENT); MEM_freeN(fsmenu); diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h index 30730578085..1b69eb09fce 100644 --- a/source/blender/editors/space_file/fsmenu.h +++ b/source/blender/editors/space_file/fsmenu.h @@ -39,6 +39,7 @@ typedef enum FSMenuCategory { FS_CATEGORY_SYSTEM, + FS_CATEGORY_SYSTEM_BOOKMARKS, FS_CATEGORY_BOOKMARKS, FS_CATEGORY_RECENT } FSMenuCategory; diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c index 4fe4ad133a9..be037a0d5ba 100644 --- a/source/blender/editors/space_file/space_file.c +++ b/source/blender/editors/space_file/space_file.c @@ -198,7 +198,7 @@ static void file_refresh(const bContext *C, ScrArea *UNUSED(sa)) params->active_file = -1; // added this so it opens nicer (ton) } filelist_hidedot(sfile->files, params->flag & FILE_HIDE_DOT); - filelist_setfilter(sfile->files, params->flag & FILE_FILTER ? params->filter : 0); + filelist_setfilter(sfile->files, params->flag & FILE_FILTER ? params->filter : 0); filelist_setfilter_types(sfile->files, params->filter_glob); if (filelist_empty(sfile->files)) { @@ -481,7 +481,7 @@ static void file_channel_area_init(wmWindowManager *wm, ARegion *ar) ED_region_panels_init(wm, ar); /* own keymaps */ - keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); + keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -505,7 +505,7 @@ static void file_header_area_init(wmWindowManager *wm, ARegion *ar) ED_region_header_init(ar); - keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); + keymap = WM_keymap_find(wm->defaultconf, "File Browser", SPACE_FILE, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); } @@ -598,7 +598,7 @@ void ED_spacetype_file(void) art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; art->init = file_header_area_init; art->draw = file_header_area_draw; - // art->listener= file_header_area_listener; + // art->listener = file_header_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: ui */ diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 3e8f6f1c7fc..8bb57a32090 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -77,7 +77,7 @@ static void do_graph_region_buttons(bContext *UNUSED(C), void *UNUSED(arg), int event) { - //Scene *scene= CTX_data_scene(C); + //Scene *scene = CTX_data_scene(C); switch (event) { @@ -299,7 +299,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) if (RNA_path_resolve(&id_ptr, fcu->rna_path, &fcu_prop_ptr, &fcu_prop) && fcu_prop) { /* determine the unit for this property */ unit = RNA_SUBTYPE_UNIT(RNA_property_subtype(fcu_prop)); - } + } /* interpolation */ col = uiLayoutColumn(layout, FALSE); @@ -407,7 +407,7 @@ static void driver_remove_cb(bContext *C, void *ale_v, void *UNUSED(arg)) if (ELEM(NULL, id, fcu)) return; - /* call API method to remove this driver */ + /* call API method to remove this driver */ ANIM_remove_driver(reports, id, fcu->rna_path, fcu->array_index, 0); } diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index ef2e56afca0..f665b979559 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -83,7 +83,7 @@ static float fcurve_display_alpha(FCurve *fcu) /* Envelope -------------- */ -// TODO: draw a shaded poly showing the region of influence too!!! +/* TODO: draw a shaded poly showing the region of influence too!!! */ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) { FMod_Envelope *env = (FMod_Envelope *)fcm->data; @@ -101,13 +101,13 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) glVertex2f(v2d->cur.xmin, env->midval + env->max); glVertex2f(v2d->cur.xmax, env->midval + env->max); - glEnd(); // GL_LINES + glEnd(); /* GL_LINES */ setlinestyle(0); /* set size of vertices (non-adjustable for now) */ glPointSize(2.0f); - // for now, point color is fixed, and is white + /* for now, point color is fixed, and is white */ glColor3f(1.0f, 1.0f, 1.0f); /* we use bgl points not standard gl points, to workaround vertex @@ -123,7 +123,7 @@ static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) glVertex2f(fed->time, fed->max); } } - bglEnd(); // GL_POINTS + bglEnd(); /* GL_POINTS */ glPointSize(1.0f); } @@ -160,13 +160,13 @@ static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo), } else { /* no check for selection here, as curve is not editable... */ - // XXX perhaps we don't want to even draw points? maybe add an option for that later + /* XXX perhaps we don't want to even draw points? maybe add an option for that later */ bglVertex3fv(bezt->vec[1]); } } } - bglEnd(); // GL_POINTS + bglEnd(); /* GL_POINTS */ } @@ -262,7 +262,7 @@ static void set_fcurve_vertex_color(FCurve *fcu, short sel) /* Curve's points ARE BEING edited */ if (sel) UI_ThemeColorShadeAlpha(TH_VERTEX_SELECT, 0, alphaOffset); else UI_ThemeColorShadeAlpha(TH_VERTEX, 0, alphaOffset); - } + } else { /* Curve's points CANNOT BE edited */ if (sel) UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, alphaOffset); @@ -318,7 +318,7 @@ static int draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu) ) { return 0; - } + } else { return 1; } @@ -404,7 +404,7 @@ static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu) } } - glEnd(); // GL_LINES + glEnd(); /* GL_LINES */ } /* Samples ---------------- */ @@ -428,7 +428,7 @@ static void draw_fcurve_sample_control(float x, float y, float xscale, float ysc glVertex2f(-0.7f, +0.7f); glVertex2f(+0.7f, -0.7f); - glEnd(); // GL_LINES + glEnd(); /* GL_LINES */ glEndList(); } @@ -515,7 +515,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d * chosen here is just the coarsest value which still looks reasonable... */ /* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */ - // TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? + /* TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? */ samplefreq = dx / U.v2d_min_gridsize; if (samplefreq < 0.00001f) samplefreq = 0.00001f; @@ -561,7 +561,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) { /* just extend across the first keyframe's value */ v[1] = prevfpt->vec[1]; - } + } else { /* extrapolate linear dosnt use the handle, use the next points center instead */ fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]); @@ -599,7 +599,7 @@ static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, Vie if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) { /* based on last keyframe's value */ v[1] = prevfpt->vec[1]; - } + } else { /* extrapolate linear dosnt use the handle, use the previous points center instead */ fpt = prevfpt - 1; @@ -642,13 +642,13 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) { /* just extend across the first keyframe's value */ v1[1] = prevbezt->vec[1][1]; - } + } else if (prevbezt->ipo == BEZT_IPO_LIN) { /* extrapolate linear dosnt use the handle, use the next points center instead */ fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); if (fac) fac = 1.0f / fac; v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]); - } + } else { /* based on angle of handle 1 (relative to keyframe) */ fac = (prevbezt->vec[0][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); @@ -667,7 +667,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 } /* draw curve between first and last keyframe (if there are enough to do so) */ - // TODO: optimize this to not have to calc stuff out of view too? + /* TODO: optimize this to not have to calc stuff out of view too? */ while (b--) { if (prevbezt->ipo == BEZT_IPO_CONST) { /* Constant-Interpolation: draw segment between previous keyframe and next, but holding same value */ @@ -691,7 +691,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 */ /* resol depends on distance between points (not just horizontal) OR is a fixed high res */ - // TODO: view scale should factor into this someday too... + /* TODO: view scale should factor into this someday too... */ if (fcu->driver) resol = 32; else @@ -705,7 +705,7 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 } else { /* clamp resolution to max of 32 */ - // NOTE: higher values will crash + /* NOTE: higher values will crash */ if (resol > 32) resol = 32; v1[0] = prevbezt->vec[1][0]; @@ -748,14 +748,14 @@ static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2 if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) { /* based on last keyframe's value */ v1[1] = prevbezt->vec[1][1]; - } + } else if (prevbezt->ipo == BEZT_IPO_LIN) { /* extrapolate linear dosnt use the handle, use the previous points center instead */ bezt = prevbezt - 1; fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); if (fac) fac = 1.0f / fac; v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]); - } + } else { /* based on angle of handle 1 (relative to keyframe) */ fac = (prevbezt->vec[2][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); @@ -852,7 +852,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid } if (((fcu->grp) && (fcu->grp->flag & AGRP_MUTED)) || (fcu->flag & FCURVE_MUTED)) { /* muted curves are drawn in a grayish hue */ - // XXX should we have some variations? + /* XXX should we have some variations? */ UI_ThemeColorShade(TH_HEADER, 50); } else { @@ -971,7 +971,7 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) height = (float)((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2)); UI_view2d_totRect_set(v2d, ar->winx, height); - /* loop through channels, and set up drawing depending on their type */ + /* loop through channels, and set up drawing depending on their type */ { /* first pass: just the standard GL-drawing for backdrop + text */ y = (float)ACHANNEL_FIRST; diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 30ec32ec0aa..453549ebf79 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -332,7 +332,7 @@ static void create_ghost_curves(bAnimContext *ac, int start, int end) ChannelDriver *driver = fcu->driver; FPoint *fpt; float unitFac; - int cfra; + int cfra; /* disable driver so that it don't muck up the sampling process */ fcu->driver = NULL; @@ -724,7 +724,7 @@ static int graphkeys_copy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* copy keyframes */ - if (copy_graph_keys(&ac)) { + if (copy_graph_keys(&ac)) { BKE_report(op->reports, RPT_ERROR, "No keyframes copied to keyframes copy/paste buffer"); return OPERATOR_CANCELLED; } @@ -1143,9 +1143,9 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) RNA_float_get(op->ptr, "attack"), RNA_float_get(op->ptr, "release"), RNA_float_get(op->ptr, "threshold"), - RNA_boolean_get(op->ptr, "accumulate"), + RNA_boolean_get(op->ptr, "use_accumulate"), RNA_boolean_get(op->ptr, "use_additive"), - RNA_boolean_get(op->ptr, "square"), + RNA_boolean_get(op->ptr, "use_square"), RNA_float_get(op->ptr, "sthreshold"), FPS, &sbi.length); @@ -1225,15 +1225,27 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot) /* properties */ WM_operator_properties_filesel(ot, FOLDERFILE | SOUNDFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - RNA_def_float(ot->srna, "low", 0.0f, 0.0, 100000.0, "Lowest frequency", "", 0.1, 1000.00); - RNA_def_float(ot->srna, "high", 100000.0, 0.0, 100000.0, "Highest frequency", "", 0.1, 1000.00); - RNA_def_float(ot->srna, "attack", 0.005, 0.0, 2.0, "Attack time", "", 0.01, 0.1); - RNA_def_float(ot->srna, "release", 0.2, 0.0, 5.0, "Release time", "", 0.01, 0.2); - RNA_def_float(ot->srna, "threshold", 0.0, 0.0, 1.0, "Threshold", "", 0.01, 0.1); - RNA_def_boolean(ot->srna, "accumulate", 0, "Accumulate", ""); - RNA_def_boolean(ot->srna, "use_additive", 0, "Additive", ""); - RNA_def_boolean(ot->srna, "square", 0, "Square", ""); - RNA_def_float(ot->srna, "sthreshold", 0.1, 0.0, 1.0, "Square Threshold", "", 0.01, 0.1); + RNA_def_float(ot->srna, "low", 0.0f, 0.0, 100000.0, "Lowest frequency", + "Cutoff frequency of a high-pass filter that is applied to the audio data", 0.1, 1000.00); + RNA_def_float(ot->srna, "high", 100000.0, 0.0, 100000.0, "Highest frequency", + "Cutoff frequency of a low-pass filter that is applied to the audio data", 0.1, 1000.00); + RNA_def_float(ot->srna, "attack", 0.005, 0.0, 2.0, "Attack time", + "Value for the hull curve calculation that tells how fast the hull curve can rise " + "(the lower the value the steeper it can rise)", 0.01, 0.1); + RNA_def_float(ot->srna, "release", 0.2, 0.0, 5.0, "Release time", + "Value for the hull curve calculation that tells how fast the hull curve can fall " + "(the lower the value the steeper it can fall)", 0.01, 0.2); + RNA_def_float(ot->srna, "threshold", 0.0, 0.0, 1.0, "Threshold", + "Minimum amplitude value needed to influence the hull curve", 0.01, 0.1); + RNA_def_boolean(ot->srna, "use_accumulate", 0, "Accumulate", + "Only the positive differences of the hull curve amplitudes are summarized to produce the output"); + RNA_def_boolean(ot->srna, "use_additive", 0, "Additive", + "The amplitudes of the hull curve are summarized (or, when Accumulate is enabled, " + "both positive and negative differences are accumulated)"); + RNA_def_boolean(ot->srna, "use_square", 0, "Square", + "The output is a square curve (negative values always result in -1, and positive ones in 1)"); + RNA_def_float(ot->srna, "sthreshold", 0.1, 0.0, 1.0, "Square Threshold", + "Square only: all values with an absolute amplitude lower than that result in 0", 0.01, 0.1); } /* ******************** Sample Keyframes Operator *********************** */ @@ -1614,7 +1626,7 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) else if (ELEM3(fcu->array_index, 0, 1, 2) == 0) { BKE_reportf(op->reports, RPT_WARNING, "Euler Rotation F-Curve has invalid index (ID='%s', Path='%s', Index=%d)", - (ale->id) ? ale->id->name : "<No ID>", fcu->rna_path, fcu->array_index); + (ale->id) ? ale->id->name : TIP_("<No ID>"), fcu->rna_path, fcu->array_index); continue; } @@ -1711,13 +1723,16 @@ static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) /* updates + finishing warnings */ if (failed == groups) { BKE_report(op->reports, RPT_ERROR, - "No Euler Rotations could be corrected, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected"); + "No Euler Rotations could be corrected, ensure each rotation has keys for all components, " + "and that F-Curves for these are in consecutive XYZ order and selected"); return OPERATOR_CANCELLED; } else { if (failed) { BKE_report(op->reports, RPT_ERROR, - "Some Euler Rotations couldn't be corrected due to missing/unselected/out-of-order F-Curves, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected"); + "Some Euler Rotations could not be corrected due to missing/unselected/out-of-order F-Curves, " + "ensure each rotation has keys for all components, and that F-Curves for these are in " + "consecutive XYZ order and selected"); } /* validate keyframes after editing */ @@ -1824,17 +1839,17 @@ void GRAPH_OT_frame_jump(wmOperatorType *ot) /* defines for snap keyframes tool */ static EnumPropertyItem prop_graphkeys_snap_types[] = { - {GRAPHKEYS_SNAP_CFRA, "CFRA", 0, "Current Frame", + {GRAPHKEYS_SNAP_CFRA, "CFRA", 0, "Current Frame", "Snap selected keyframes to the current frame"}, - {GRAPHKEYS_SNAP_VALUE, "VALUE", 0, "Cursor Value", + {GRAPHKEYS_SNAP_VALUE, "VALUE", 0, "Cursor Value", "Set values of selected keyframes to the cursor value (Y/Horizontal component)"}, - {GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", + {GRAPHKEYS_SNAP_NEAREST_FRAME, "NEAREST_FRAME", 0, "Nearest Frame", "Snap selected keyframes to the nearest (whole) frame (use to fix accidental sub-frame offsets)"}, - {GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", + {GRAPHKEYS_SNAP_NEAREST_SECOND, "NEAREST_SECOND", 0, "Nearest Second", "Snap selected keyframes to the nearest second"}, - {GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", + {GRAPHKEYS_SNAP_NEAREST_MARKER, "NEAREST_MARKER", 0, "Nearest Marker", "Snap selected keyframes to the nearest marker"}, - {GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", 0, "Flatten Handles", + {GRAPHKEYS_SNAP_HORIZONTAL, "HORIZONTAL", 0, "Flatten Handles", "Flatten handles for a smoother transition"}, {0, NULL, 0, NULL, NULL} }; @@ -1938,15 +1953,15 @@ void GRAPH_OT_snap(wmOperatorType *ot) /* defines for mirror keyframes tool */ static EnumPropertyItem prop_graphkeys_mirror_types[] = { - {GRAPHKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current Frame", + {GRAPHKEYS_MIRROR_CFRA, "CFRA", 0, "By Times over Current Frame", "Flip times of selected keyframes using the current frame as the mirror line"}, - {GRAPHKEYS_MIRROR_VALUE, "VALUE", 0, "By Values over Cursor Value", + {GRAPHKEYS_MIRROR_VALUE, "VALUE", 0, "By Values over Cursor Value", "Flip values of selected keyframes using the cursor value (Y/Horizontal component) as the mirror line"}, - {GRAPHKEYS_MIRROR_YAXIS, "YAXIS", 0, "By Times over Time=0", + {GRAPHKEYS_MIRROR_YAXIS, "YAXIS", 0, "By Times over Time=0", "Flip times of selected keyframes, effectively reversing the order they appear in"}, - {GRAPHKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", + {GRAPHKEYS_MIRROR_XAXIS, "XAXIS", 0, "By Values over Value=0", "Flip values of selected keyframes (i.e. negative values become positive, and vice versa)"}, - {GRAPHKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", + {GRAPHKEYS_MIRROR_MARKER, "MARKER", 0, "By Times over First Selected Marker", "Flip times of selected keyframes using the first selected marker as the reference point"}, {0, NULL, 0, NULL, NULL} }; @@ -2181,7 +2196,7 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op) if (fcm) set_active_fmodifier(&fcu->modifiers, fcm); else { - BKE_report(op->reports, RPT_ERROR, "Modifier couldn't be added, see console for details"); + BKE_report(op->reports, RPT_ERROR, "Modifier could not be added (see console for details)"); break; } } diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index eb657169970..b2dbf764c1d 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -123,7 +123,7 @@ enum { GRAPHKEYS_SNAP_CFRA = 1, GRAPHKEYS_SNAP_NEAREST_FRAME, GRAPHKEYS_SNAP_NEAREST_SECOND, - GRAPHKEYS_SNAP_NEAREST_MARKER, + GRAPHKEYS_SNAP_NEAREST_MARKER, GRAPHKEYS_SNAP_HORIZONTAL, GRAPHKEYS_SNAP_VALUE, } eGraphKeys_Snap_Mode; diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index e2fc1657379..978b3224850 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -757,7 +757,7 @@ static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short if (leftright == GRAPHKEYS_LRSEL_LEFT) { ked.f1 = MINAFRAMEF; ked.f2 = (float)(CFRA + 0.1f); - } + } else { ked.f1 = (float)(CFRA - 0.1f); ked.f2 = MAXFRAMEF; @@ -835,7 +835,7 @@ static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, wmEven UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL); if (x < CFRA) RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_LEFT); - else + else RNA_enum_set(op->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT); } @@ -1113,7 +1113,7 @@ static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_m nvi = find_nearest_fcurve_vert(ac, mval); /* check if anything to select */ - if (nvi == NULL) + if (nvi == NULL) return; /* deselect all other curves? */ @@ -1241,7 +1241,7 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short nvi = find_nearest_fcurve_vert(ac, mval); /* check if anything to select */ - if (nvi == NULL) + if (nvi == NULL) return; /* get frame number on which elements should be selected */ diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index a4611cf1453..f41169b6c39 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -441,7 +441,7 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_refresh(sa); break; case NC_SCENE: - switch (wmn->data) { + switch (wmn->data) { case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ case ND_OB_SELECT: sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; @@ -461,7 +461,7 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_refresh(sa); break; case ND_TRANSFORM: - break; /*do nothing*/ + break; /*do nothing*/ default: /* just redrawing the view will do */ ED_area_tag_redraw(sa); diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 59416dcf0c3..ae7a718ab5b 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -191,7 +191,7 @@ void image_preview_event(int event) waitcursor(0); WM_event_add_notifier(C, NC_IMAGE, ima_v); - } + } } @@ -722,8 +722,10 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char split = uiLayoutSplit(layout, 0.0f, FALSE); col = uiLayoutColumn(split, TRUE); + uiLayoutSetEnabled(col, 0); uiItemR(col, &imaptr, "generated_width", 0, "X", ICON_NONE); uiItemR(col, &imaptr, "generated_height", 0, "Y", ICON_NONE); + uiItemR(col, &imaptr, "use_generated_float", 0, NULL, ICON_NONE); uiItemR(split, &imaptr, "generated_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE); @@ -759,9 +761,10 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man uiItemR(sub, imfptr, "color_mode", UI_ITEM_R_EXPAND, IFACE_("Color"), ICON_NONE); /* only display depth setting if multiple depths can be used */ - if ((ELEM6(depth_ok, + if ((ELEM7(depth_ok, R_IMF_CHAN_DEPTH_1, R_IMF_CHAN_DEPTH_8, + R_IMF_CHAN_DEPTH_10, R_IMF_CHAN_DEPTH_12, R_IMF_CHAN_DEPTH_16, R_IMF_CHAN_DEPTH_24, @@ -801,9 +804,13 @@ void uiTemplateImageSettings(uiLayout *layout, PointerRNA *imfptr, int color_man uiItemR(col, imfptr, "use_jpeg2k_ycc", 0, NULL, ICON_NONE); } + if (imf->imtype == R_IMF_IMTYPE_DPX) { + uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE); + } + if (imf->imtype == R_IMF_IMTYPE_CINEON) { #if 1 - uiItemL(col, IFACE_("Hard coded Non-Linear, Gamma: 1.0"), ICON_NONE); + uiItemL(col, IFACE_("Hard coded Non-Linear, Gamma:1.7"), ICON_NONE); #else uiItemR(col, imfptr, "use_cineon_log", 0, NULL, ICON_NONE); uiItemR(col, imfptr, "cineon_black", 0, NULL, ICON_NONE); diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 04566af2b3b..9fc2b981547 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -578,7 +578,7 @@ void draw_image_grease_pencil(bContext *C, short onlyv2d) } else { /* assume that UI_view2d_restore(C) has been called... */ - //SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C); + //SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C); /* draw grease-pencil ('screen' strokes) */ draw_gpencil_view2d(C, 0); @@ -791,7 +791,7 @@ void draw_image_main(const bContext *C, ARegion *ar) xoffs = scene->r.disprect.xmin; yoffs = scene->r.disprect.ymin; glColor3ub(0, 0, 0); - calc_image_view(sima, 'f'); + calc_image_view(sima, 'f'); myortho2(G.v2d->cur.xmin, G.v2d->cur.xmax, G.v2d->cur.ymin, G.v2d->cur.ymax); glRectf(0.0f, 0.0f, 1.0f, 1.0f); glLoadIdentity(); diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 2f01483d23f..4ca2f8888f8 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -79,7 +79,7 @@ void ED_space_image_set(SpaceImage *sima, Scene *scene, Object *obedit, Image *i BKE_image_signal(sima->image, &sima->iuser, IMA_SIGNAL_USER_NEW_IMAGE); if (sima->image && ID_REAL_USERS(sima->image) <= 0) - sima->image->id.us = MAX2(sima->image->id.us, 0) + 1; + sima->image->id.us = max_ii(sima->image->id.us, 0) + 1; if (obedit) WM_main_add_notifier(NC_GEOM | ND_DATA, obedit->data); @@ -98,7 +98,7 @@ void ED_space_image_set_mask(bContext *C, SpaceImage *sima, Mask *mask) /* weak, but same as image/space */ if (sima->mask_info.mask && ID_REAL_USERS(sima->mask_info.mask) <= 0) - sima->mask_info.mask->id.us = MAX2(sima->mask_info.mask->id.us, 0) + 1; + sima->mask_info.mask->id.us = max_ii(sima->mask_info.mask->id.us, 0) + 1; if (C) { WM_event_add_notifier(C, NC_MASK | NA_SELECTED, mask); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 4793f995d98..c7f9bd87a1b 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -39,6 +39,8 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "DNA_object_types.h" #include "DNA_node_types.h" #include "DNA_packedFile_types.h" @@ -183,7 +185,7 @@ static int space_image_poll(bContext *C) int space_image_main_area_poll(bContext *C) { SpaceImage *sima = CTX_wm_space_image(C); - // XXX ARegion *ar= CTX_wm_region(C); + // XXX ARegion *ar = CTX_wm_region(C); if (sima) return 1; // XXX (ar && ar->type->regionid == RGN_TYPE_WINDOW); @@ -551,7 +553,7 @@ static int image_view_ndof_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent * sima->xof += pan_x; sima->yof += pan_y; - ED_region_tag_redraw(ar); + ED_region_tag_redraw(ar); return OPERATOR_FINISHED; } @@ -599,7 +601,7 @@ static int image_view_all_exec(bContext *C, wmOperator *UNUSED(op)) /* find the zoom value that will fit the image in the image space */ zoomx = width / w; zoomy = height / h; - sima_zoom_set(sima, ar, 1.0f / power_of_2(1.0f / minf(zoomx, zoomy)), NULL); + sima_zoom_set(sima, ar, 1.0f / power_of_2(1.0f / min_ff(zoomx, zoomy)), NULL); } else sima_zoom_set(sima, ar, 1.0f, NULL); @@ -858,7 +860,8 @@ static int image_open_exec(bContext *C, wmOperator *op) if (!ima) { if (op->customdata) MEM_freeN(op->customdata); - BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", str, errno ? strerror(errno) : "Unsupported image format"); + BKE_reportf(op->reports, RPT_ERROR, "Cannot read '%s': %s", + str, errno ? strerror(errno) : TIP_("unsupported image format")); return OPERATOR_CANCELLED; } @@ -1147,7 +1150,7 @@ static int save_image_options_init(SaveImageOptions *simopts, SpaceImage *sima, else { simopts->im_format.imtype = BKE_ftype_to_imtype(ibuf->ftype); } - //simopts->subimtype= scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */ + //simopts->subimtype = scene->r.subimtype; /* XXX - this is lame, we need to make these available too! */ simopts->im_format.quality = ibuf->ftype & 0xff; BLI_strncpy(simopts->filepath, ibuf->name, sizeof(simopts->filepath)); @@ -1313,7 +1316,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI } } else { - BKE_reportf(op->reports, RPT_ERROR, "Couldn't write image: %s", simopts->filepath); + BKE_reportf(op->reports, RPT_ERROR, "Could not write image %s", simopts->filepath); } @@ -1495,7 +1498,7 @@ static int image_save_exec(bContext *C, wmOperator *op) save_image_doit(C, sima, op, &simopts, FALSE); } else { - BKE_reportf(op->reports, RPT_ERROR, "Can not save image, path '%s' is not writable", simopts.filepath); + BKE_reportf(op->reports, RPT_ERROR, "Cannot save image, path '%s' is not writable", simopts.filepath); return OPERATOR_CANCELLED; } @@ -1536,7 +1539,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) } if (sima->image->type == IMA_TYPE_MULTILAYER) { - BKE_report(op->reports, RPT_ERROR, "Can't save multilayer sequences"); + BKE_report(op->reports, RPT_ERROR, "Cannot save multilayer sequences"); return OPERATOR_CANCELLED; } @@ -1572,7 +1575,7 @@ static int image_save_sequence_exec(bContext *C, wmOperator *op) break; } - BKE_reportf(op->reports, RPT_INFO, "Saved: %s\n", ibuf->name); + BKE_reportf(op->reports, RPT_INFO, "Saved %s", ibuf->name); ibuf->userflags &= ~IB_BITMAPDIRTY; } } @@ -1682,16 +1685,24 @@ static int image_new_exec(bContext *C, wmOperator *op) RNA_property_pointer_set(&ptr, prop, idptr); RNA_property_update(C, &ptr, prop); } - else if (sima) + else if (sima) { ED_space_image_set(sima, scene, obedit, ima); + } + else { + Tex *tex = CTX_data_pointer_get_type(C, "texture", &RNA_Texture).data; + if (tex && tex->type == TEX_IMAGE) { + tex->ima = ima; + ED_area_tag_redraw(CTX_wm_area(C)); + } + } - // XXX other users? BKE_image_signal(ima, (sima) ? &sima->iuser : NULL, IMA_SIGNAL_USER_NEW_IMAGE); return OPERATOR_FINISHED; } /* XXX, Ton is not a fan of OK buttons but using this function to avoid undo/redo bug while in mesh-editmode, - campbell */ +/* XXX Note: the WM_operator_props_dialog_popup() doesn't work for uiIDContextProperty(), image is not being that way */ static int image_new_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { return WM_operator_props_dialog_popup(C, op, 300, 100); @@ -1844,7 +1855,7 @@ static int image_pack_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; if (!as_png && (ibuf && (ibuf->userflags & IB_BITMAPDIRTY))) { - BKE_report(op->reports, RPT_ERROR, "Can't pack edited image from disk, only as internal PNG"); + BKE_report(op->reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG"); return OPERATOR_CANCELLED; } @@ -2362,8 +2373,8 @@ static int image_record_composite_apply(bContext *C, wmOperator *op) WM_cursor_time(CTX_wm_window(C), scene->r.cfra); - // XXX scene->nodetree->test_break= blender_test_break; - // XXX scene->nodetree->test_break= NULL; + // XXX scene->nodetree->test_break = blender_test_break; + // XXX scene->nodetree->test_break = NULL; BKE_image_all_free_anim_ibufs(scene->r.cfra); ntreeCompositTagAnimated(scene->nodetree); @@ -2429,8 +2440,7 @@ static int image_record_composite_exec(bContext *C, wmOperator *op) if (!image_record_composite_init(C, op)) return OPERATOR_CANCELLED; - while (image_record_composite_apply(C, op)) - ; + while (image_record_composite_apply(C, op)) {} image_record_composite_exit(C, op); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 7f53f378042..4131cbfdd0d 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -457,7 +457,7 @@ static void image_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); } break; - case NC_SPACE: + case NC_SPACE: if (wmn->data == ND_SPACE_IMAGE) { image_scopes_tag_refresh(sa); ED_area_tag_redraw(sa); @@ -550,7 +550,7 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar) int width, height, winx, winy; #if 0 - if (image_preview_active(curarea, &width, &height)) ; + if (image_preview_active(curarea, &width, &height)) {} else #endif ED_space_image_get_size(sima, &width, &height); diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index 35e19bcce38..5830c4574df 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -136,7 +136,7 @@ static int report_textview_skip__internal(TextViewContext *tvc) static int report_textview_begin(TextViewContext *tvc) { - // SpaceConsole *sc= (SpaceConsole *)tvc->arg1; + // SpaceConsole *sc = (SpaceConsole *)tvc->arg1; ReportList *reports = (ReportList *)tvc->arg2; tvc->lheight = 14; //sc->lheight; diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index bb2d55fa0f6..131908bc9db 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -196,7 +196,7 @@ static int make_paths_relative_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); if (!G.relbase_valid) { - BKE_report(op->reports, RPT_WARNING, "Can't set relative paths with an unsaved blend file"); + BKE_report(op->reports, RPT_WARNING, "Cannot set relative paths with an unsaved blend file"); return OPERATOR_CANCELLED; } @@ -229,7 +229,7 @@ static int make_paths_absolute_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); if (!G.relbase_valid) { - BKE_report(op->reports, RPT_WARNING, "Can't set absolute paths with an unsaved blend file"); + BKE_report(op->reports, RPT_WARNING, "Cannot set absolute paths with an unsaved blend file"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_info/info_report.c b/source/blender/editors/space_info/info_report.c index 2324f735a33..049a50f89fc 100644 --- a/source/blender/editors/space_info/info_report.c +++ b/source/blender/editors/space_info/info_report.c @@ -68,9 +68,9 @@ int info_report_mask(SpaceInfo *UNUSED(sinfo)) // TODO, get this working again! static int report_replay_exec(bContext *C, wmOperator *UNUSED(op)) { -// SpaceInfo *sc= CTX_wm_space_info(C); -// ReportList *reports= CTX_wm_reports(C); -// int report_mask= info_report_mask(sc); +// SpaceInfo *sc = CTX_wm_space_info(C); +// ReportList *reports = CTX_wm_reports(C); +// int report_mask = info_report_mask(sc); // Report *report; #if 0 @@ -223,7 +223,7 @@ static int borderselect_exec(bContext *C, wmOperator *op) int extend = RNA_boolean_get(op->ptr, "extend"); Report *report_min, *report_max, *report; - //View2D *v2d= UI_view2d_fromcontext(C); + //View2D *v2d = UI_view2d_fromcontext(C); rcti rect; diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c index 034c382cfd2..f108881091a 100644 --- a/source/blender/editors/space_info/space_info.c +++ b/source/blender/editors/space_info/space_info.c @@ -93,7 +93,7 @@ static SpaceLink *info_new(const bContext *UNUSED(C)) ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */ - //ar->v2d.keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM); + //ar->v2d.keepzoom = (V2D_KEEPASPECT|V2D_LIMITZOOM); return (SpaceLink *)sinfo; } @@ -228,7 +228,7 @@ static void info_header_area_draw(const bContext *C, ARegion *ar) static void info_main_area_listener(ARegion *ar, wmNotifier *wmn) { - // SpaceInfo *sinfo= sa->spacedata.first; + // SpaceInfo *sinfo = sa->spacedata.first; /* context changes */ switch (wmn->category) { @@ -249,7 +249,7 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn) if (ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY)) ED_region_tag_redraw(ar); break; - case NC_WM: + case NC_WM: if (wmn->data == ND_JOB) ED_region_tag_redraw(ar); break; @@ -257,7 +257,7 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn) if (wmn->data == ND_RENDER_RESULT) ED_region_tag_redraw(ar); break; - case NC_SPACE: + case NC_SPACE: if (wmn->data == ND_SPACE_INFO) ED_region_tag_redraw(ar); break; diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index cfab2542756..f454b1dbe7d 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -36,8 +36,6 @@ #include "BLI_math.h" #include "BLI_utildefines.h" - - #include "BIF_gl.h" #include "BIF_glutil.h" @@ -66,8 +64,8 @@ typedef struct ConsoleDrawContext { static void console_draw_sel(int sel[2], int xy[2], int str_len_draw, int cwidth, int lheight) { if (sel[0] <= str_len_draw && sel[1] >= 0) { - int sta = MAX2(sel[0], 0); - int end = MIN2(sel[1], str_len_draw); + int sta = max_ii(sel[0], 0); + int end = min_ii(sel[1], str_len_draw); glEnable(GL_POLYGON_STIPPLE); glPolygonStipple(stipple_halftone); diff --git a/source/blender/editors/space_logic/CMakeLists.txt b/source/blender/editors/space_logic/CMakeLists.txt index 8859d1d8bfd..13e6f9484e8 100644 --- a/source/blender/editors/space_logic/CMakeLists.txt +++ b/source/blender/editors/space_logic/CMakeLists.txt @@ -48,4 +48,8 @@ if(WITH_GAMEENGINE) add_definitions(-DWITH_GAMEENGINE) endif() +if(WITH_INTERNATIONAL) + add_definitions(-DWITH_INTERNATIONAL) +endif() + blender_add_lib(bf_editor_space_logic "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_logic/SConscript b/source/blender/editors/space_logic/SConscript index 6beb3ecb48f..e63d88ea5de 100644 --- a/source/blender/editors/space_logic/SConscript +++ b/source/blender/editors/space_logic/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.c') -incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' +incs = '../include ../../blenfont ../../blenlib ../../blenkernel ../../makesdna ../../imbuf' incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../makesrna ../interface ../../blenloader' @@ -12,4 +12,7 @@ defs = [] if env['WITH_BF_GAMEENGINE']: defs.append('WITH_GAMEENGINE') +if env['WITH_BF_INTERNATIONAL']: + defs.append('WITH_INTERNATIONAL') + env.BlenderLib ( 'bf_editors_space_game', sources, Split(incs), defs, libtype=['core'], priority=[120] ) diff --git a/source/blender/editors/space_logic/logic_buttons.c b/source/blender/editors/space_logic/logic_buttons.c index abdfa0ef4dd..e898a1baf74 100644 --- a/source/blender/editors/space_logic/logic_buttons.c +++ b/source/blender/editors/space_logic/logic_buttons.c @@ -52,8 +52,8 @@ static int logic_properties(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= logic_has_buttons_region(sa); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = logic_has_buttons_region(sa); if (ar) ED_region_toggle_hidden(C, ar); @@ -100,9 +100,9 @@ static int cut_links_intersect(uiLinkLine *line, float mcoords[][2], int tot) static int cut_links_exec(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); float mcoords[256][2]; - int i= 0; + int i = 0; RNA_BEGIN (op->ptr, itemptr, "path") { @@ -113,7 +113,7 @@ static int cut_links_exec(bContext *C, wmOperator *op) (int)loc[0], (int)loc[1], &mcoords[i][0], &mcoords[i][1]); i++; - if (i>= 256) break; + if (i >= 256) break; } RNA_END; @@ -121,23 +121,23 @@ static int cut_links_exec(bContext *C, wmOperator *op) uiBlock *block; uiLinkLine *line, *nline; uiBut *but; - for (block= ar->uiblocks.first; block; block= block->next) { - but= block->buttons.first; + for (block = ar->uiblocks.first; block; block = block->next) { + but = block->buttons.first; while (but) { if (but->type==LINK && but->link) { - for (line= but->link->lines.first; line; line= nline) { - nline= line->next; + for (line = but->link->lines.first; line; line = nline) { + nline = line->next; if (cut_links_intersect(line, mcoords, i)) { ui_delete_linkline(line, but); } } } - but= but->next; + but = but->next; } } return OPERATOR_FINISHED; - } + } return OPERATOR_CANCELLED|OPERATOR_PASS_THROUGH; } @@ -159,7 +159,7 @@ void LOGIC_OT_links_cut(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; - prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); + prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath); /* internal */ RNA_def_int(ot->srna, "cursor", BC_KNIFECURSOR, 0, INT_MAX, "Cursor", "", 0, INT_MAX); diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c index f2013e405e2..74be7c46d26 100644 --- a/source/blender/editors/space_logic/logic_ops.c +++ b/source/blender/editors/space_logic/logic_ops.c @@ -138,7 +138,7 @@ static bSensor *edit_sensor_property_get(bContext *C, wmOperator *op, Object **o *ob = edit_object_property_get(C, op); if (!*ob) return NULL; - sens = BLI_findstring(&((*ob)->sensors), sensor_name, offsetof(bSensor, name)); + sens = BLI_findstring(&((*ob)->sensors), sensor_name, offsetof(bSensor, name)); return sens; } @@ -177,7 +177,7 @@ static bController *edit_controller_property_get(bContext *C, wmOperator *op, Ob *ob = edit_object_property_get(C, op); if (!*ob) return NULL; - cont = BLI_findstring(&((*ob)->controllers), controller_name, offsetof(bController, name)); + cont = BLI_findstring(&((*ob)->controllers), controller_name, offsetof(bController, name)); return cont; } @@ -216,7 +216,7 @@ static bActuator *edit_actuator_property_get(bContext *C, wmOperator *op, Object *ob = edit_object_property_get(C, op); if (!*ob) return NULL; - act = BLI_findstring(&((*ob)->actuators), actuator_name, offsetof(bActuator, name)); + act = BLI_findstring(&((*ob)->actuators), actuator_name, offsetof(bActuator, name)); return act; } diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 5d7ff77e032..bffabe6d160 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -63,6 +63,8 @@ #include "BIF_gl.h" +#include "BLF_translation.h" + #include "UI_interface.h" #include "RNA_access.h" @@ -102,8 +104,8 @@ static int vergname(const void *v1, const void *v2) { char **x1, **x2; - x1= (char **)v1; - x2= (char **)v2; + x1 = (char **)v1; + x2 = (char **)v2; return BLI_natstrcmp(*x1, *x2); } @@ -134,7 +136,7 @@ void make_unique_prop_names(bContext *C, char *str) propcount+= BLI_countlist(&ob->sensors); propcount+= BLI_countlist(&ob->controllers); propcount+= BLI_countlist(&ob->actuators); - } + } if (propcount==0) { if (idar) MEM_freeN(idar); return; @@ -149,22 +151,22 @@ void make_unique_prop_names(bContext *C, char *str) ob= (Object *)idar[a]; prop= ob->prop.first; while (prop) { - names[nr++]= prop->name; + names[nr++] = prop->name; prop= prop->next; } sens= ob->sensors.first; while (sens) { - names[nr++]= sens->name; + names[nr++] = sens->name; sens= sens->next; } cont= ob->controllers.first; while (cont) { - names[nr++]= cont->name; + names[nr++] = cont->name; cont= cont->next; } act= ob->actuators.first; while (act) { - names[nr++]= act->name; + names[nr++] = act->name; act= act->next; } } @@ -524,7 +526,7 @@ static const char *actuator_name(int type) case ACT_ARMATURE: return "Armature"; case ACT_STEERING: - return "Steering"; + return "Steering"; } return "unknown"; } @@ -678,7 +680,7 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf ob= ob->id.next; } } - } + } /* now we count */ ob= bmain->object.first; @@ -687,8 +689,8 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf ob= ob->id.next; } - if (*count==0) return NULL; - if (*count>24) *count= 24; /* temporal */ + if (*count == 0) return NULL; + if (*count > 24) *count = 24; /* temporal */ idar= MEM_callocN((*count)*sizeof(void *), "idar"); @@ -697,16 +699,16 @@ static ID **get_selected_and_linked_obs(bContext *C, short *count, short scavisf /* make the active object always the first one of the list */ if (obact) { - idar[0]= (ID *)obact; + idar[0] = (ID *)obact; nr++; } while (ob) { if ((ob->scavisflag) && (ob != obact)) { - idar[nr]= (ID *)ob; + idar[nr] = (ID *)ob; nr++; } - if (nr>=24) break; + if (nr >= 24) break; ob= ob->id.next; } @@ -768,11 +770,11 @@ static uiBlock *sensor_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); uiBlockSetButmFunc(block, do_sensor_menu, NULL); - uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefBut(block, BUTM, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefBut(block, BUTM, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefBut(block, SEPR, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefBut(block, BUTM, 1, "Show Sensors", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefBut(block, BUTM, 1, "Hide Sensors", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); + uiDefBut(block, BUTM, 1, IFACE_("Show Sensors"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); + uiDefBut(block, BUTM, 1, IFACE_("Hide Sensors"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); uiBlockSetDirection(block, UI_TOP); uiEndBlock(C, block); @@ -817,11 +819,11 @@ static uiBlock *controller_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); uiBlockSetButmFunc(block, do_controller_menu, NULL); - uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefBut(block, BUTM, 1, IFACE_("Show Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefBut(block, BUTM, 1, IFACE_("Hide Objects"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefBut(block, SEPR, 0, "", 0, (short)(yco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefBut(block, BUTM, 1, "Show Controllers", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 2, 2, ""); - uiDefBut(block, BUTM, 1, "Hide Controllers", 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 3, 3, ""); + uiDefBut(block, BUTM, 1, IFACE_("Show Controllers"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 2, 2, ""); + uiDefBut(block, BUTM, 1, IFACE_("Hide Controllers"), 0, (short)(yco-=20), 160, 19, NULL, 0.0, 0.0, 3, 3, ""); uiBlockSetDirection(block, UI_TOP); uiEndBlock(C, block); @@ -866,11 +868,11 @@ static uiBlock *actuator_menu(bContext *C, ARegion *ar, void *UNUSED(arg)) block= uiBeginBlock(C, ar, __func__, UI_EMBOSSP); uiBlockSetButmFunc(block, do_actuator_menu, NULL); - uiDefBut(block, BUTM, 1, "Show Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); - uiDefBut(block, BUTM, 1, "Hide Objects", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); + uiDefBut(block, BUTM, 1, IFACE_("Show Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 0, ""); + uiDefBut(block, BUTM, 1, IFACE_("Hide Objects"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 1, ""); uiDefBut(block, SEPR, 0, "", 0, (short)(xco-=6), 160, 6, NULL, 0.0, 0.0, 0, 0, ""); - uiDefBut(block, BUTM, 1, "Show Actuators", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); - uiDefBut(block, BUTM, 1, "Hide Actuators", 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); + uiDefBut(block, BUTM, 1, IFACE_("Show Actuators"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 2, ""); + uiDefBut(block, BUTM, 1, IFACE_("Hide Actuators"), 0, (short)(xco-=20), 160, 19, NULL, 0.0, 0.0, 1, 3, ""); uiBlockSetDirection(block, UI_TOP); uiEndBlock(C, block); @@ -901,7 +903,7 @@ static uiBlock *controller_state_mask_menu(bContext *C, ARegion *ar, void *arg_c /* use this for a fake extra empy space around the buttons */ uiDefBut(block, LABEL, 0, "", -5, -5, 200, 34, NULL, 0, 0, 0, 0, ""); - for (offset=0; offset<15; offset+=5) { + for (offset=0; offset<15; offset += 5) { uiBlockBeginAlign(block); for (stbit=0; stbit<5; stbit++) { but = uiDefButBitI(block, TOG, (1<<(stbit+offset)), (stbit+offset), "", (short)(xco+12*stbit+13*offset), yco, 12, 12, (int *)&(cont->state_mask), 0, 0, 0, 0, ""); @@ -981,13 +983,13 @@ static void draw_sensor_internal_header(uiLayout *layout, PointerRNA *ptr) sub = uiLayoutRow(row, FALSE); uiLayoutSetActive(sub, (RNA_boolean_get(ptr, "use_pulse_true_level") || RNA_boolean_get(ptr, "use_pulse_false_level"))); - uiItemR(sub, ptr, "frequency", 0, "Freq", ICON_NONE); + uiItemR(sub, ptr, "frequency", 0, IFACE_("Freq"), ICON_NONE); row = uiLayoutRow(split, TRUE); uiItemR(row, ptr, "use_level", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); uiItemR(row, ptr, "use_tap", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - uiItemR(split, ptr, "invert", UI_ITEM_R_TOGGLE, "Invert", ICON_NONE); + uiItemR(split, ptr, "invert", UI_ITEM_R_TOGGLE, IFACE_("Invert"), ICON_NONE); } /* sensors in alphabetical order */ @@ -1010,7 +1012,7 @@ static void draw_sensor_armature(uiLayout *layout, PointerRNA *ptr) uiLayout *row; if (ob->type != OB_ARMATURE) { - uiItemL(layout, "Sensor only available for armatures", ICON_NONE); + uiItemL(layout, IFACE_("Sensor only available for armatures"), ICON_NONE); return; } @@ -1112,7 +1114,7 @@ static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr) uiLayout *row, *col; row = uiLayoutRow(layout, FALSE); - uiItemL(row, "Key:", ICON_NONE); + uiItemL(row, IFACE_("Key:"), ICON_NONE); col = uiLayoutColumn(row, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == FALSE); uiItemR(col, ptr, "key", UI_ITEM_R_EVENT, "", ICON_NONE); @@ -1122,11 +1124,11 @@ static void draw_sensor_keyboard(uiLayout *layout, PointerRNA *ptr) col = uiLayoutColumn(layout, FALSE); uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_all_keys") == FALSE); row = uiLayoutRow(col, FALSE); - uiItemL(row, "First Modifier:", ICON_NONE); + uiItemL(row, IFACE_("First Modifier:"), ICON_NONE); uiItemR(row, ptr, "modifier_key_1", UI_ITEM_R_EVENT, "", ICON_NONE); row = uiLayoutRow(col, FALSE); - uiItemL(row, "Second Modifier:", ICON_NONE); + uiItemL(row, IFACE_("Second Modifier:"), ICON_NONE); uiItemR(row, ptr, "modifier_key_2", UI_ITEM_R_EVENT, "", ICON_NONE); RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); @@ -1312,7 +1314,7 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i uiItemR(row, ptr, "type", 0, "", ICON_NONE); uiItemR(row, ptr, "name", 0, "", ICON_NONE); /* XXX provisory for Blender 2.50Beta */ - uiDefBlockBut(uiLayoutGetBlock(layout), controller_state_mask_menu, cont, state, (short)(xco+width-44), yco, 22+22, UI_UNIT_Y, "Set controller state index (from 1 to 30)"); + uiDefBlockBut(uiLayoutGetBlock(layout), controller_state_mask_menu, cont, state, (short)(xco+width-44), yco, 22+22, UI_UNIT_Y, IFACE_("Set controller state index (from 1 to 30)")); } else { uiItemL(row, controller_name(cont->type), ICON_NONE); @@ -1480,7 +1482,7 @@ static void draw_actuator_armature(uiLayout *layout, PointerRNA *ptr) PropertyRNA *bones_prop = NULL; if (ob->type != OB_ARMATURE) { - uiItemL(layout, "Actuator only available for armatures", ICON_NONE); + uiItemL(layout, IFACE_("Actuator only available for armatures"), ICON_NONE); return; } @@ -1586,7 +1588,7 @@ static void draw_actuator_constraint(uiLayout *layout, PointerRNA *ptr, bContext row = uiLayoutRow(layout, FALSE); col = uiLayoutColumn(row, TRUE); - uiItemL(col, "Range:", ICON_NONE); + uiItemL(col, IFACE_("Range:"), ICON_NONE); uiItemR(col, ptr, "range", 0, "", ICON_NONE); col = uiLayoutColumn(row, TRUE); @@ -1684,7 +1686,7 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) break; case ACT_EDOB_REPLACE_MESH: if (ob->type != OB_MESH) { - uiItemL(layout, "Mode only available for mesh objects", ICON_NONE); + uiItemL(layout, IFACE_("Mode only available for mesh objects"), ICON_NONE); break; } split = uiLayoutSplit(layout, 0.6, FALSE); @@ -1702,7 +1704,7 @@ static void draw_actuator_edit_object(uiLayout *layout, PointerRNA *ptr) break; case ACT_EDOB_DYNAMICS: if (ob->type != OB_MESH) { - uiItemL(layout, "Mode only available for mesh objects", ICON_NONE); + uiItemL(layout, IFACE_("Mode only available for mesh objects"), ICON_NONE); break; } uiItemR(layout, ptr, "dynamic_operation", 0, NULL, ICON_NONE); @@ -1772,7 +1774,7 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) uiLayout *split, *row, *col, *sub; int physics_type; - ob = (Object *)ptr->id.data; + ob = (Object *)ptr->id.data; RNA_pointer_create((ID *)ob, &RNA_GameObjectSettings, ob, &settings_ptr); physics_type = RNA_enum_get(&settings_ptr, "physics_type"); @@ -1790,8 +1792,8 @@ static void draw_actuator_motion(uiLayout *layout, PointerRNA *ptr) uiItemR(row, ptr, "offset_rotation", 0, NULL, ICON_NONE); uiItemR(split, ptr, "use_local_rotation", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - if (ELEM3(physics_type, OB_BODY_TYPE_DYNAMIC, OB_BODY_TYPE_RIGID, OB_BODY_TYPE_SOFT)) { - uiItemL(layout, "Dynamic Object Settings:", ICON_NONE); + if (ELEM3(physics_type, OB_BODY_TYPE_DYNAMIC, OB_BODY_TYPE_RIGID, OB_BODY_TYPE_SOFT)) { + uiItemL(layout, IFACE_("Dynamic Object Settings:"), ICON_NONE); split = uiLayoutSplit(layout, 0.9, FALSE); row = uiLayoutRow(split, FALSE); uiItemR(row, ptr, "force", 0, NULL, ICON_NONE); @@ -1941,7 +1943,7 @@ static void draw_actuator_random(uiLayout *layout, PointerRNA *ptr) break; case ACT_RANDOM_BOOL_UNIFORM: - uiItemL(row, "Choose between true and false, 50% chance each", ICON_NONE); + uiItemL(row, IFACE_("Choose between true and false, 50% chance each"), ICON_NONE); break; case ACT_RANDOM_BOOL_BERNOUILLI: @@ -2004,7 +2006,7 @@ static void draw_actuator_shape_action(uiLayout *layout, PointerRNA *ptr) uiLayout *row; if (ob->type != OB_MESH) { - uiItemL(layout, "Actuator only available for mesh objects", ICON_NONE); + uiItemL(layout, IFACE_("Actuator only available for mesh objects"), ICON_NONE); return; } @@ -2042,7 +2044,7 @@ static void draw_actuator_sound(uiLayout *layout, PointerRNA *ptr, bContext *C) uiTemplateID(layout, C, ptr, "sound", NULL, "SOUND_OT_open", NULL); if (!RNA_pointer_get(ptr, "sound").data) { - uiItemL(layout, "Select a sound from the list or load a new one", ICON_NONE); + uiItemL(layout, IFACE_("Select a sound from the list or load a new one"), ICON_NONE); return; } uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE); @@ -2272,11 +2274,11 @@ void logic_buttons(bContext *C, ARegion *ar) layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); row = uiLayoutRow(layout, TRUE); - uiDefBlockBut(block, controller_menu, NULL, "Controllers", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ + uiDefBlockBut(block, controller_menu, NULL, IFACE_("Controllers"), xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ - uiItemR(row, &logic_ptr, "show_controllers_selected_objects", 0, "Sel", ICON_NONE); - uiItemR(row, &logic_ptr, "show_controllers_active_object", 0, "Act", ICON_NONE); - uiItemR(row, &logic_ptr, "show_controllers_linked_controller", 0, "Link", ICON_NONE); + uiItemR(row, &logic_ptr, "show_controllers_selected_objects", 0, IFACE_("Sel"), ICON_NONE); + uiItemR(row, &logic_ptr, "show_controllers_active_object", 0, IFACE_("Act"), ICON_NONE); + uiItemR(row, &logic_ptr, "show_controllers_linked_controller", 0, IFACE_("Link"), ICON_NONE); for (a=0; a<count; a++) { bController *cont; @@ -2299,11 +2301,11 @@ void logic_buttons(bContext *C, ARegion *ar) uiItemR(split, &settings_ptr, "show_state_panel", UI_ITEM_R_NO_BG, "", ICON_DISCLOSURE_TRI_RIGHT); row = uiLayoutRow(split, TRUE); - uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide controllers"); + uiDefButBitS(block, TOG, OB_SHOWCONT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide controllers")); RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); uiLayoutSetContextPointer(row, "object", &object_ptr); - uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", ICON_NONE); + uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", IFACE_("Add Controller"), ICON_NONE); if (RNA_boolean_get(&settings_ptr, "show_state_panel")) { @@ -2311,8 +2313,8 @@ void logic_buttons(bContext *C, ARegion *ar) split = uiLayoutSplit(box, 0.2f, FALSE); col = uiLayoutColumn(split, FALSE); - uiItemL(col, "Visible", ICON_NONE); - uiItemL(col, "Initial", ICON_NONE); + uiItemL(col, IFACE_("Visible"), ICON_NONE); + uiItemL(col, IFACE_("Initial"), ICON_NONE); subsplit = uiLayoutSplit(split, 0.85f, FALSE); col = uiLayoutColumn(subsplit, FALSE); @@ -2379,12 +2381,12 @@ void logic_buttons(bContext *C, ARegion *ar) layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); row = uiLayoutRow(layout, TRUE); - uiDefBlockBut(block, sensor_menu, NULL, "Sensors", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ + uiDefBlockBut(block, sensor_menu, NULL, IFACE_("Sensors"), xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ - uiItemR(row, &logic_ptr, "show_sensors_selected_objects", 0, "Sel", ICON_NONE); - uiItemR(row, &logic_ptr, "show_sensors_active_object", 0, "Act", ICON_NONE); - uiItemR(row, &logic_ptr, "show_sensors_linked_controller", 0, "Link", ICON_NONE); - uiItemR(row, &logic_ptr, "show_sensors_active_states", 0, "State", ICON_NONE); + uiItemR(row, &logic_ptr, "show_sensors_selected_objects", 0, IFACE_("Sel"), ICON_NONE); + uiItemR(row, &logic_ptr, "show_sensors_active_object", 0, IFACE_("Act"), ICON_NONE); + uiItemR(row, &logic_ptr, "show_sensors_linked_controller", 0, IFACE_("Link"), ICON_NONE); + uiItemR(row, &logic_ptr, "show_sensors_active_states", 0, IFACE_("State"), ICON_NONE); for (a=0; a<count; a++) { bSensor *sens; @@ -2396,11 +2398,11 @@ void logic_buttons(bContext *C, ARegion *ar) if ((ob->scavisflag & OB_VIS_SENS) == 0) continue; row = uiLayoutRow(layout, TRUE); - uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide sensors"); + uiDefButBitS(block, TOG, OB_SHOWSENS, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide sensors")); RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); uiLayoutSetContextPointer(row, "object", &object_ptr); - uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", "Add Sensor", ICON_NONE); + uiItemMenuEnumO(row, "LOGIC_OT_sensor_add", "type", IFACE_("Add Sensor"), ICON_NONE); if ((ob->scaflag & OB_SHOWSENS) == 0) continue; @@ -2447,12 +2449,12 @@ void logic_buttons(bContext *C, ARegion *ar) layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, xco, yco, width, 20, UI_GetStyle()); row = uiLayoutRow(layout, TRUE); - uiDefBlockBut(block, actuator_menu, NULL, "Actuators", xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ + uiDefBlockBut(block, actuator_menu, NULL, IFACE_("Actuators"), xco-10, yco, 300, UI_UNIT_Y, ""); /* replace this with uiLayout stuff later */ - uiItemR(row, &logic_ptr, "show_actuators_selected_objects", 0, "Sel", ICON_NONE); - uiItemR(row, &logic_ptr, "show_actuators_active_object", 0, "Act", ICON_NONE); - uiItemR(row, &logic_ptr, "show_actuators_linked_controller", 0, "Link", ICON_NONE); - uiItemR(row, &logic_ptr, "show_actuators_active_states", 0, "State", ICON_NONE); + uiItemR(row, &logic_ptr, "show_actuators_selected_objects", 0, IFACE_("Sel"), ICON_NONE); + uiItemR(row, &logic_ptr, "show_actuators_active_object", 0, IFACE_("Act"), ICON_NONE); + uiItemR(row, &logic_ptr, "show_actuators_linked_controller", 0, IFACE_("Link"), ICON_NONE); + uiItemR(row, &logic_ptr, "show_actuators_active_states", 0, IFACE_("State"), ICON_NONE); for (a=0; a<count; a++) { bActuator *act; @@ -2466,11 +2468,11 @@ void logic_buttons(bContext *C, ARegion *ar) } row = uiLayoutRow(layout, TRUE); - uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, "Object name, click to show/hide actuators"); + uiDefButBitS(block, TOG, OB_SHOWACT, B_REDR, ob->id.name+2, (short)(xco-10), yco, (short)(width-30), UI_UNIT_Y, &ob->scaflag, 0, 31, 0, 0, TIP_("Object name, click to show/hide actuators")); RNA_pointer_create((ID *)ob, &RNA_Object, ob, &object_ptr); uiLayoutSetContextPointer(row, "object", &object_ptr); - uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", "Add Actuator", ICON_NONE); + uiItemMenuEnumO(row, "LOGIC_OT_actuator_add", "type", IFACE_("Add Actuator"), ICON_NONE); if ((ob->scaflag & OB_SHOWACT) == 0) continue; diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 1a50f72153a..c4ec801d6ed 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -62,20 +62,20 @@ ARegion *logic_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; /* add subdiv level; after header */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* is error! */ - if (ar==NULL) return NULL; + if (ar == NULL) return NULL; arnew= MEM_callocN(sizeof(ARegion), "buttons for image"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_UI; - arnew->alignment= RGN_ALIGN_LEFT; + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_LEFT; arnew->flag = RGN_FLAG_HIDDEN; @@ -129,18 +129,18 @@ static SpaceLink *logic_new(const bContext *UNUSED(C)) ar->v2d.cur.xmax = 1280.0f; ar->v2d.cur.ymax = 240.0f; - ar->v2d.min[0]= 1.0f; - ar->v2d.min[1]= 1.0f; + ar->v2d.min[0] = 1.0f; + ar->v2d.min[1] = 1.0f; - ar->v2d.max[0]= 32000.0f; - ar->v2d.max[1]= 32000.0f; + ar->v2d.max[0] = 32000.0f; + ar->v2d.max[1] = 32000.0f; - ar->v2d.minzoom= 0.5f; - ar->v2d.maxzoom= 1.21f; + ar->v2d.minzoom = 0.5f; + ar->v2d.maxzoom = 1.21f; - ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); - ar->v2d.keepzoom= V2D_LIMITZOOM|V2D_KEEPASPECT; - ar->v2d.keeptot= 0; + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); + ar->v2d.keepzoom = V2D_LIMITZOOM | V2D_KEEPASPECT; + ar->v2d.keeptot = 0; return (SpaceLink *)slogic; diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index badc4dbb533..ad6e66f7a7d 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -71,7 +71,7 @@ static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int event) { - //Scene *scene= CTX_data_scene(C); + //Scene *scene = CTX_data_scene(C); switch (event) { @@ -157,7 +157,7 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA found = -1; } } - } + } break; } @@ -243,7 +243,7 @@ static void nla_panel_animdata(const bContext *C, Panel *pa) if (!nla_panel_context(C, &adt_ptr, NULL, NULL)) return; - /* adt= adt_ptr.data; */ + /* adt = adt_ptr.data; */ block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); @@ -406,7 +406,7 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE); sub = uiLayoutColumn(col, TRUE); - uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence")); + uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence")); uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE); col = uiLayoutColumn(layout, TRUE); diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 89a5e9feeef..cf56f254c36 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -200,7 +200,7 @@ static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, shor } notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); - } + } break; case ANIMTYPE_NLATRACK: diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 5c8e7e99a8c..9091699bd4b 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -163,7 +163,7 @@ static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float col /* normal, unselected strip - use (hardly noticeable) blue tinge */ UI_GetThemeColor3fv(TH_NLA_TRANSITION, color); } - } + } else if (strip->type == NLASTRIP_TYPE_META) { /* Meta Clip */ // TODO: should temporary metas get different colors too? @@ -528,7 +528,7 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) */ v2d->tot.ymin = (float)(-height); - /* loop through channels, and set up drawing depending on their type */ + /* loop through channels, and set up drawing depending on their type */ y = (float)(-NLACHANNEL_HEIGHT(snla)); for (ale = anim_data.first; ale; ale = ale->next) { @@ -628,7 +628,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View bAnimListElem *ale; float x = 0.0f; - /* loop through channels, and set up drawing depending on their type */ + /* loop through channels, and set up drawing depending on their type */ for (ale = anim_data->first; ale; ale = ale->next) { const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); @@ -709,7 +709,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View // draw backdrops only... ANIM_channel_draw(ac, ale, yminc, ymaxc); break; - } + } /* if special types, draw manually for now... */ if (do_draw) { @@ -737,7 +737,7 @@ static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View /* even more */ offset = 21; indent = 1; - } + } break; default: @@ -936,7 +936,7 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - /* loop through channels, and set up drawing depending on their type */ + /* loop through channels, and set up drawing depending on their type */ for (ale = anim_data.first; ale; ale = ale->next) { const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index e0e5007aff0..3740c3fae5e 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -123,7 +123,7 @@ static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op) if (anim_data.first == NULL) { BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweak mode for"); return OPERATOR_CANCELLED; - } + } /* for each AnimData block with NLA-data, try setting it in tweak-mode */ for (ale = anim_data.first; ale; ale = ale->next) { @@ -192,7 +192,7 @@ static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op) if (anim_data.first == NULL) { BKE_report(op->reports, RPT_ERROR, "No AnimData blocks to enter tweak mode for"); return OPERATOR_CANCELLED; - } + } /* for each AnimData block with NLA-data, try exitting tweak-mode */ for (ale = anim_data.first; ale; ale = ale->next) { @@ -266,8 +266,8 @@ static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const /* only consider selected strips? */ if ((onlySel == 0) || (strip->flag & NLASTRIP_FLAG_SELECT)) { /* extend range if appropriate */ - *min = minf(*min, strip->start); - *max = maxf(*max, strip->end); + *min = min_ff(*min, strip->start); + *max = max_ff(*max, strip->end); } } } @@ -398,7 +398,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); if (act == NULL) { - BKE_report(op->reports, RPT_ERROR, "No valid Action to add"); + BKE_report(op->reports, RPT_ERROR, "No valid action to add"); //printf("Add strip - actname = '%s'\n", actname); return OPERATOR_CANCELLED; } @@ -407,7 +407,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_WARNING, "Action '%s' does not specify what datablocks it can be used on " "(try setting the 'ID Root Type' setting from the Datablocks Editor " - "for this Action to avoid future problems)", + "for this action to avoid future problems)", act->id.name + 2); } @@ -433,7 +433,7 @@ static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) */ if ((act->idroot) && (act->idroot != GS(ale->id->name))) { BKE_reportf(op->reports, RPT_ERROR, - "Couldn't add action '%s' as it cannot be used relative to ID-blocks of type '%s'", + "Could not add action '%s' as it cannot be used relative to ID-blocks of type '%s'", act->id.name + 2, ale->id->name); continue; } @@ -1364,7 +1364,7 @@ static int nlaedit_swap_exec(bContext *C, wmOperator *op) "Cannot swap selected strips as they will not be able to fit in their new places"); } else { - BKE_reportf(op->reports, RPT_WARNING, + BKE_reportf(op->reports, RPT_WARNING, "Cannot swap '%s' and '%s' as one or both will not be able to fit in their new places", sa->name, sb->name); } @@ -2023,7 +2023,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) set_active_fmodifier(&strip->modifiers, fcm); else { BKE_reportf(op->reports, RPT_ERROR, - "Modifier couldn't be added to (%s : %s) (see console for details)", + "Modifier could not be added to (%s : %s) (see console for details)", nlt->name, strip->name); } } diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index 3a74d0b4c9c..54ade829c0d 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -256,7 +256,7 @@ static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "NLA_OT_meta_remove", GKEY, KM_PRESS, KM_ALT, 0); /* duplicate */ - WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); + WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); /* delete */ WM_keymap_add_item(keymap, "NLA_OT_delete", XKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index 79be0d0a194..97553b7aa56 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -390,7 +390,7 @@ static void nlaedit_select_leftright(bContext *C, bAnimContext *ac, short leftri if (leftright == NLAEDIT_LRSEL_LEFT) { xmin = MINAFRAMEF; xmax = (float)(CFRA + 0.1f); - } + } else { xmin = (float)(CFRA - 0.1f); xmax = MAXFRAMEF; @@ -471,7 +471,7 @@ static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent UI_view2d_region_to_view(v2d, event->mval[0], event->mval[1], &x, NULL); if (x < CFRA) RNA_int_set(op->ptr, "mode", NLAEDIT_LRSEL_LEFT); - else + else RNA_int_set(op->ptr, "mode", NLAEDIT_LRSEL_RIGHT); } @@ -582,7 +582,7 @@ static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], s ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); /* Highlight NLA-Track */ - if (ale->type == ANIMTYPE_NLATRACK) { + if (ale->type == ANIMTYPE_NLATRACK) { NlaTrack *nlt = (NlaTrack *)ale->data; nlt->flag |= NLATRACK_SELECTED; diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 67508f2087a..711944809fd 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -834,7 +834,7 @@ static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bN layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (int)(rect.xmin + NODE_MARGIN_X), (int)(rect.ymax + (group_header - (2.5f * dpi_fac))), - mini((int)(BLI_rctf_size_x(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle()); + min_ii((int)(BLI_rctf_size_x(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle()); RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr); uiTemplateIDBrowse(layout, (bContext *)C, &ptr, "node_tree", NULL, NULL, NULL); uiBlockLayoutResolve(gnode->block, NULL, NULL); @@ -895,11 +895,6 @@ static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr) uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL); } -static void node_common_buts_whileloop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) -{ - uiItemR(layout, ptr, "max_iterations", 0, NULL, ICON_NONE); -} - /* XXX Does a bounding box update by iterating over all children. * Not ideal to do this in every draw call, but doing as transform callback doesn't work, * since the child node totr rects are not updated properly at that point. @@ -1179,16 +1174,6 @@ static void node_common_set_butfunc(bNodeType *ntype) ntype->drawfunc = node_draw_group; ntype->drawupdatefunc = node_update_group; break; - case NODE_FORLOOP: -// ntype->uifunc= node_common_buts_group; - ntype->drawfunc = node_draw_group; - ntype->drawupdatefunc = node_update_group; - break; - case NODE_WHILELOOP: - ntype->uifunc = node_common_buts_whileloop; - ntype->drawfunc = node_draw_group; - ntype->drawupdatefunc = node_update_group; - break; case NODE_FRAME: ntype->drawfunc = node_draw_frame; ntype->drawupdatefunc = node_update_frame; @@ -2595,7 +2580,7 @@ static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, Point static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - /* bNode *node= ptr->data; */ /* UNUSED */ + /* bNode *node = ptr->data; */ /* UNUSED */ uiItemR(layout, ptr, "blur_pre", 0, NULL, ICON_NONE); uiItemR(layout, ptr, "screen_balance", 0, NULL, ICON_NONE); @@ -3226,7 +3211,7 @@ static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode) float zoomx, zoomy; zoomx = (float)sa->winx / ibuf->x; zoomy = (float)sa->winy / ibuf->y; - zoom = minf(zoomx, zoomy); + zoom = min_ff(zoomx, zoomy); } x = (sa->winx - zoom * ibuf->x) / 2 + snode->xof; @@ -3557,7 +3542,7 @@ void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link) } do_shaded = TRUE; do_triple = TRUE; - } + } else { th_col1 = TH_REDALERT; } diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 99d49fa1e8f..df8a6f94d24 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -35,6 +35,8 @@ #include "BLI_math.h" +#include "BLF_translation.h" + #include "BKE_context.h" #include "BKE_image.h" #include "BKE_library.h" @@ -240,7 +242,8 @@ static int node_add_file_exec(bContext *C, wmOperator *op) ima = BKE_image_load_exists(path); if (!ima) { - BKE_reportf(op->reports, RPT_ERROR, "Can't read image: \"%s\", %s", path, errno ? strerror(errno) : "Unsupported format"); + BKE_reportf(op->reports, RPT_ERROR, "Cannot read image '%s': %s", + path, errno ? strerror(errno) : TIP_("unsupported format")); return OPERATOR_CANCELLED; } } @@ -250,7 +253,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) ima = (Image *)BKE_libblock_find_name(ID_IM, name); if (!ima) { - BKE_reportf(op->reports, RPT_ERROR, "Image named \"%s\", not found", name); + BKE_reportf(op->reports, RPT_ERROR, "Image '%s' not found", name); return OPERATOR_CANCELLED; } } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 379e9987c4c..1d3b21fe2d6 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -101,7 +101,7 @@ void ED_node_changed_update(ID *id, bNode *node) nodeUpdateID(nodetree, node->id); WM_main_add_notifier(NC_SCENE | ND_NODES, id); - } + } else if (treetype == NTREE_TEXTURE) { DAG_id_tag_update(id, 0); WM_main_add_notifier(NC_TEXTURE | ND_NODES, id); @@ -391,7 +391,7 @@ static void node_update_basis(const bContext *C, bNodeTree *ntree, bNode *node) node->totr.xmin = locx; node->totr.xmax = locx + node->width; node->totr.ymax = locy; - node->totr.ymin = minf(dy, locy - 2 * NODE_DY); + node->totr.ymin = min_ff(dy, locy - 2 * NODE_DY); /* Set the block bounds to clip mouse events from underlying nodes. * Add a margin for sockets on each side. @@ -506,25 +506,16 @@ int node_get_colorid(bNode *node) /* note: in node_edit.c is similar code, for untangle node */ static void node_draw_mute_line(View2D *v2d, SpaceNode *snode, bNode *node) { - ListBase links; bNodeLink *link; - if (node->typeinfo->internal_connect == NULL) - return; - - /* Get default muting links. */ - links = node->typeinfo->internal_connect(snode->edittree, node); - glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); - for (link = links.first; link; link = link->next) + for (link = node->internal_links.first; link; link = link->next) node_draw_link_bezier(v2d, snode, link, TH_REDALERT, 0, TH_WIRE, 0, TH_WIRE); glDisable(GL_BLEND); glDisable(GL_LINE_SMOOTH); - - BLI_freelistN(&links); } /* this might have some more generic use */ @@ -668,7 +659,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN bNodeSocket *sock; rctf *rct = &node->totr; float iconofs; - /* float socket_size= NODE_SOCKSIZE*U.dpi/72; */ /* UNUSED */ + /* float socket_size = NODE_SOCKSIZE*U.dpi/72; */ /* UNUSED */ float iconbutw = 0.8f * UI_UNIT_X; int color_id = node_get_colorid(node); char showname[128]; /* 128 used below */ @@ -915,7 +906,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b /* disable lines */ if (node->flag & NODE_MUTED) - node_draw_mute_line(&ar->v2d, snode, node); + node_draw_mute_line(&ar->v2d, snode, node); if (node->flag & SELECT) UI_ThemeColor(TH_SELECT); @@ -932,7 +923,7 @@ static void node_draw_hidden(const bContext *C, ARegion *ar, SpaceNode *snode, b (int)(rct->xmin + (NODE_MARGIN_X / snode->aspect_sqrt)), (int)(centy - 10), (short)(BLI_rctf_size_x(rct) - 18.0f - 12.0f), (short)NODE_DY, NULL, 0, 0, 0, 0, ""); - } + } /* scale widget thing */ UI_ThemeColorShade(color_id, -10); @@ -1108,7 +1099,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) /* aspect+font, set each time */ snode->aspect = BLI_rctf_size_x(&v2d->cur) / (float)ar->winx; snode->aspect_sqrt = sqrtf(snode->aspect); - // XXX snode->curfont= uiSetCurFont_ext(snode->aspect); + // XXX snode->curfont = uiSetCurFont_ext(snode->aspect); /* grid */ UI_view2d_multi_grid_draw(v2d, 25.0f, 5, 2); @@ -1138,7 +1129,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) #ifdef WITH_COMPOSITOR if (snode->nodetree->type == NTREE_COMPOSIT) { COM_startReadHighlights(); - } + } #endif node_draw_nodetree(C, ar, snode, snode->nodetree); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index f0afc647ed5..f21f343ea2b 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1622,7 +1622,7 @@ static int node_mute_exec(bContext *C, wmOperator *UNUSED(op)) for (node = snode->edittree->nodes.first; node; node = node->next) { /* Only allow muting of nodes having a mute func! */ - if ((node->flag & SELECT) && node->typeinfo->internal_connect) { + if ((node->flag & SELECT) && node->typeinfo->update_internal_links) { node->flag ^= NODE_MUTED; snode_update(snode, node); } @@ -1972,7 +1972,7 @@ static int node_clipboard_copy_exec(bContext *C, wmOperator *UNUSED(op)) } /* transform to basic view space. child node location is relative to parent */ - if (!new_node->parent) { + if (!new_node->parent) { new_node->locx += gnode_x; new_node->locy += gnode_y; } diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 5ab698cd415..e82917feb21 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -138,12 +138,6 @@ static void do_node_add_group(bContext *C, void *UNUSED(arg), int event) case NODE_GROUP: ntemp.ngroup = ntreeAddTree("Group", snode->treetype, ntemp.type); break; - case NODE_FORLOOP: - ntemp.ngroup = ntreeAddTree("For Loop", snode->treetype, ntemp.type); - break; - case NODE_WHILELOOP: - ntemp.ngroup = ntreeAddTree("While Loop", snode->treetype, ntemp.type); - break; default: ntemp.ngroup = NULL; } @@ -199,15 +193,11 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) /* XXX hack: negative numbers used for empty group types */ if (node_tree_has_type(ntree->type, NODE_GROUP)) uiItemV(layout, IFACE_("New Group"), 0, -NODE_GROUP); - if (node_tree_has_type(ntree->type, NODE_FORLOOP)) - uiItemV(layout, IFACE_("New For Loop"), 0, -NODE_FORLOOP); - if (node_tree_has_type(ntree->type, NODE_WHILELOOP)) - uiItemV(layout, IFACE_("New While Loop"), 0, -NODE_WHILELOOP); uiItemS(layout); for (ngroup = bmain->nodetree.first, event = 0; ngroup; ngroup = ngroup->id.next, ++event) { /* only use group trees */ - if (ngroup->type == ntree->type && ELEM3(ngroup->nodetype, NODE_GROUP, NODE_FORLOOP, NODE_WHILELOOP)) { + if (ngroup->type == ntree->type && ngroup->nodetype == NODE_GROUP) { uiItemV(layout, ngroup->id.name + 2, 0, event); } } diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index fec7366ee73..7fa48c48ad6 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -136,7 +136,7 @@ static bNodeSocket *best_socket_input(bNodeTree *ntree, bNode *node, int num, in int a = 0; for (sock = node->inputs.first; sock; sock = sock->next) { - maxtype = MAX2(sock->type, maxtype); + maxtype = max_ii(sock->type, maxtype); } /* find sockets of higher 'types' first (i.e. image) */ @@ -1368,7 +1368,7 @@ static bNodeSocket *socket_best_match(ListBase *sockets) /* find type range */ for (sock = sockets->first; sock; sock = sock->next) - maxtype = MAX2(sock->type, maxtype); + maxtype = max_ii(sock->type, maxtype); /* try all types, starting from 'highest' (i.e. colors, vectors, values) */ for (type = maxtype; type >= 0; --type) { diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 42480c0c2d9..d4df449a41b 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -122,6 +122,7 @@ static void node_socket_disconnect(Main *bmain, bNodeTree *ntree, bNode *node_to return; nodeRemLink(ntree, sock_to->link); + sock_to->flag |= SOCK_COLLAPSED; nodeUpdate(ntree, node_to); ntreeUpdateTree(ntree); @@ -136,6 +137,7 @@ static void node_socket_remove(Main *bmain, bNodeTree *ntree, bNode *node_to, bN return; node_remove_linked(ntree, sock_to->link->fromnode); + sock_to->flag |= SOCK_COLLAPSED; nodeUpdate(ntree, node_to); ntreeUpdateTree(ntree); @@ -185,6 +187,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t /* add link */ sock_from_tmp = BLI_findlink(&node_from->outputs, sock_num); nodeAddLink(ntree, node_from, sock_from_tmp, node_to, sock_to); + sock_to->flag &= ~SOCK_COLLAPSED; /* copy input sockets from previous node */ if (node_prev && node_from != node_prev) { @@ -613,7 +616,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree, /* input linked to a node */ uiTemplateNodeLink(split, ntree, node, input); - if (!(input->flag & SOCK_COLLAPSED)) { + if (depth == 0 || !(input->flag & SOCK_COLLAPSED)) { if (depth == 0) uiItemS(layout); diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 76d1357a83c..4d2512cdc93 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -111,7 +111,6 @@ static SpaceLink *node_new(const bContext *UNUSED(C)) BLI_addtail(&snode->regionbase, ar); ar->regiontype = RGN_TYPE_UI; ar->alignment = RGN_ALIGN_RIGHT; - ar->flag = RGN_FLAG_HIDDEN; /* main area */ ar = MEM_callocN(sizeof(ARegion), "main area for node"); diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index d2e47427b94..c4afe32e85f 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -36,6 +36,7 @@ #include "DNA_scene_types.h" #include "DNA_sequence_types.h" +#include "BLI_math.h" #include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLI_ghash.h" @@ -92,7 +93,7 @@ static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) { TreeElement *te = lb->first; while (te) { -// TreeStoreElem *tselem= TREESTORE(te); +// TreeStoreElem *tselem = TREESTORE(te); // XXX fixme... te->xend is not set yet if (!TSELEM_OPEN(tselem, soops)) { @@ -238,9 +239,9 @@ static int group_select_flag(Group *gr) void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) { - Scene *scene = (Scene *)poin; + Scene *scene = (Scene *)poin; GroupObject *gob; - Group *gr = (Group *)poin2; + Group *gr = (Group *)poin2; if (group_restrict_flag(gr, flag)) { for (gob = gr->gobject.first; gob; gob = gob->next) { @@ -309,7 +310,7 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) WM_event_add_notifier(C, NC_SCENE, NULL); break; default: WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break; - } + } /* Check the library target exists */ if (te->idcode == ID_LI) { Library *lib = (Library *)tselem->id; @@ -627,7 +628,7 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) search[0] = 0; block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU); /* fake button, it holds space for search items */ uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); @@ -636,7 +637,7 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) uiButSetSearchFunc(but, operator_search_cb, arg_kmi, operator_call_cb, ot); uiBoundsBlock(block, 6); - uiBlockSetDirection(block, UI_DOWN); + uiBlockSetDirection(block, UI_DOWN); uiEndBlock(C, block); event = *(win->eventstate); /* XXX huh huh? make api call */ @@ -1000,6 +1001,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto case eModifierType_Bevel: UI_icon_draw(x, y, ICON_MOD_BEVEL); break; case eModifierType_Smooth: + case eModifierType_LaplacianSmooth: UI_icon_draw(x, y, ICON_MOD_SMOOTH); break; case eModifierType_SimpleDeform: UI_icon_draw(x, y, ICON_MOD_SIMPLEDEFORM); break; @@ -1251,7 +1253,7 @@ static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, i for (ten = te->subtree.first; ten; ten = ten->next) { outliner_set_coord_tree_element(soops, ten, startx + UI_UNIT_X, starty); - } + } } @@ -1396,7 +1398,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_DIRECT); glPixelTransferf(GL_ALPHA_SCALE, 1.0f); offsx += UI_UNIT_X; - } + } glDisable(GL_BLEND); /* name */ @@ -1433,7 +1435,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene } } } - } + } /* store coord and continue, we need coordinates for elements outside view too */ te->xs = (float)startx; te->ys = (float)*starty; @@ -1444,7 +1446,7 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene for (ten = te->subtree.first; ten; ten = ten->next) outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx + UI_UNIT_X, starty); - } + } else { for (ten = te->subtree.first; ten; ten = ten->next) outliner_set_coord_tree_element(soops, te, startx, starty); @@ -1648,7 +1650,7 @@ void draw_outliner(const bContext *C) /* get actual width of column 1 */ outliner_rna_width(soops, &soops->tree, &sizex_rna, 0); - sizex_rna = MAX2(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX); + sizex_rna = max_ii(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX); /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ if (soops->outlinevis == SO_KEYMAP) @@ -1701,7 +1703,7 @@ void draw_outliner(const bContext *C) } /* draw edit buttons if nessecery */ - outliner_buttons(C, block, ar, soops, &soops->tree); + outliner_buttons(C, block, ar, soops, &soops->tree); uiEndBlock(C, block); uiDrawBlock(C, block); diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 8f059b0a735..23766d6a6fe 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -81,7 +81,7 @@ static int outliner_open_back(SpaceOops *soops, TreeElement *te) for (te = te->parent; te; te = te->parent) { tselem = TREESTORE(te); - if (tselem->flag & TSE_CLOSED) { + if (tselem->flag & TSE_CLOSED) { tselem->flag &= ~TSE_CLOSED; retval = 1; } @@ -197,10 +197,10 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, } else if (tselem->id->lib) { // XXX error_libdata(); - } + } else if (te->idcode == ID_LI && te->parent) { BKE_report(reports, RPT_WARNING, "Cannot edit the path of an indirectly linked library"); - } + } else { tselem->flag |= TSE_TEXTBUT; ED_region_tag_redraw(ar); @@ -730,7 +730,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so /* determine which type of search to do */ if (again && last_find) { - /* no popup panel - previous + user wanted to search for next after previous */ + /* no popup panel - previous + user wanted to search for next after previous */ BLI_strncpy(name, soops->search_string, sizeof(name)); flags = soops->search_flags; @@ -746,7 +746,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so /* pop up panel - no previous, or user didn't want search after previous */ name[0] = '\0'; // XXX if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) { -// te= outliner_find_name(soops, &soops->tree, name, flags, NULL, &prevFound); +// te = outliner_find_name(soops, &soops->tree, name, flags, NULL, &prevFound); // } // else return; /* XXX RETURN! XXX */ } @@ -786,7 +786,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so } else { /* no tree-element found */ - BKE_report(reports, RPT_WARNING, "Not found: %s", name); + BKE_reportf(reports, RPT_WARNING, "Not found: %s", name); } } #endif @@ -998,7 +998,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle char buf[128], *name; temnext = (TreeElement *)(ld->next->data); - /* tsenext= TREESTORE(temnext); */ /* UNUSED */ + /* tsenext = TREESTORE(temnext); */ /* UNUSED */ nextptr = &temnext->rnaptr; name = RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL); @@ -1858,7 +1858,7 @@ static int material_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) assign_material(ob, ma, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING, ma); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 823de61d044..4668dfa1386 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -236,7 +236,7 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo if (ob == NULL) return 0; // no active object - /*tselem= TREESTORE(te);*/ /*UNUSED*/ + /*tselem = TREESTORE(te);*/ /*UNUSED*/ /* find buttons area (note, this is undefined really still, needs recode in blender) */ /* XXX removed finding sbuts */ @@ -250,8 +250,8 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo if (set) { if (sbuts) { - // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c - // XXX sbuts->texfrom= 1; + // XXX sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c + // XXX sbuts->texfrom = 1; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture wrld->texact = te->index; @@ -264,8 +264,8 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo Lamp *la = (Lamp *)tselemp->id; if (set) { if (sbuts) { - // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c - // XXX sbuts->texfrom= 2; + // XXX sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c + // XXX sbuts->texfrom = 2; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture la->texact = te->index; @@ -280,8 +280,8 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo Material *ma = (Material *)tselemp->id; if (set) { if (sbuts) { - //sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c - // XXX sbuts->texfrom= 0; + //sbuts->tabo = TAB_SHADING_TEX; // hack from header_buttonswin.c + // XXX sbuts->texfrom = 0; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture ma->texact = (char)te->index; diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index e4cd971dbd5..5fb9780c700 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -811,7 +811,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) ED_undo_push(C, "Unlink world"); break; default: - BKE_report(op->reports, RPT_WARNING, "Not yet"); + BKE_report(op->reports, RPT_WARNING, "Not yet implemented"); break; } } @@ -844,7 +844,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) break; default: - BKE_report(op->reports, RPT_WARNING, "Not yet"); + BKE_report(op->reports, RPT_WARNING, "Not yet implemented"); break; } } @@ -974,7 +974,7 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); if (act == NULL) { - BKE_report(op->reports, RPT_ERROR, "No valid Action to add"); + BKE_report(op->reports, RPT_ERROR, "No valid action to add"); return OPERATOR_CANCELLED; } else if (act->idroot == 0) { @@ -982,7 +982,7 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_WARNING, "Action '%s' does not specify what datablocks it can be used on " "(try setting the 'ID Root Type' setting from the Datablocks Editor " - "for this Action to avoid future problems)", + "for this action to avoid future problems)", act->id.name + 2); } @@ -1202,6 +1202,7 @@ static int outliner_data_operation_exec(bContext *C, wmOperator *op) break; default: + BKE_report(op->reports, RPT_WARNING, "Not yet implemented"); break; } diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index ef0542130ea..af890a81ad6 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -553,16 +553,16 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree if (md->type == eModifierType_Lattice) { outliner_add_element(soops, &te->subtree, ((LatticeModifierData *) md)->object, te, TSE_LINKED_OB, 0); - } + } else if (md->type == eModifierType_Curve) { outliner_add_element(soops, &te->subtree, ((CurveModifierData *) md)->object, te, TSE_LINKED_OB, 0); - } + } else if (md->type == eModifierType_Armature) { outliner_add_element(soops, &te->subtree, ((ArmatureModifierData *) md)->object, te, TSE_LINKED_OB, 0); - } + } else if (md->type == eModifierType_Hook) { outliner_add_element(soops, &te->subtree, ((HookModifierData *) md)->object, te, TSE_LINKED_OB, 0); - } + } else if (md->type == eModifierType_ParticleSystem) { TreeElement *ten; ParticleSystem *psys = ((ParticleSystemModifierData *) md)->psys; @@ -590,7 +590,7 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree /* duplicated group */ if (ob->dup_group) - outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0); + outliner_add_element(soops, &te->subtree, ob->dup_group, te, 0, 0); } // can be inlined if necessary @@ -731,7 +731,7 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor case ID_AC: { // XXX do we want to be exposing the F-Curves here? - //bAction *act= (bAction *)id; + //bAction *act = (bAction *)id; } break; case ID_AR: @@ -1148,7 +1148,7 @@ static void outliner_add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *t } if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) - /* ch= */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); + /* ch = */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); p = p->next; } } @@ -1531,7 +1531,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) while (seq) { op = need_add_seq_dup(seq); if (op == 1) { - /* ten= */ outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE, 0); + /* ten = */ outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE, 0); } else if (op == 0) { ten = outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE_DUP, 0); @@ -1569,7 +1569,7 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) wmKeyMap *km; for (km = wm->defaultconf->keymaps.first; km; km = km->next) { - /* ten= */ outliner_add_element(soops, &soops->tree, (void *)km, NULL, TSE_KEYMAP, 0); + /* ten = */ outliner_add_element(soops, &soops->tree, (void *)km, NULL, TSE_KEYMAP, 0); } } else { diff --git a/source/blender/editors/space_sequencer/CMakeLists.txt b/source/blender/editors/space_sequencer/CMakeLists.txt index c1f7fc942e4..f108d9f1aaa 100644 --- a/source/blender/editors/space_sequencer/CMakeLists.txt +++ b/source/blender/editors/space_sequencer/CMakeLists.txt @@ -57,4 +57,8 @@ if(WITH_AUDASPACE) add_definitions(-DWITH_AUDASPACE) endif() +if(WITH_INTERNATIONAL) + add_definitions(-DWITH_INTERNATIONAL) +endif() + blender_add_lib(bf_editor_space_sequencer "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_sequencer/SConscript b/source/blender/editors/space_sequencer/SConscript index ec06eacae9c..0b429ae750b 100644 --- a/source/blender/editors/space_sequencer/SConscript +++ b/source/blender/editors/space_sequencer/SConscript @@ -8,7 +8,12 @@ incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include' incs += ' ../../makesrna ../../blenloader ../../blenfont' incs += ' #/intern/audaspace/intern' +defs = [] + if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): incs += ' ' + env['BF_PTHREADS_INC'] -env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), [], libtype=['core'], priority=[100] ) +if env['WITH_BF_INTERNATIONAL']: + defs.append('WITH_INTERNATIONAL') + +env.BlenderLib ( 'bf_editors_space_sequencer', sources, Split(incs), defs, libtype=['core'], priority=[100] ) diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index ff895c06d57..fd46f69da83 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -325,7 +325,7 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) clip = BLI_findlink(&CTX_data_main(C)->movieclip, RNA_enum_get(op->ptr, "clip")); if (clip == NULL) { - BKE_report(op->reports, RPT_ERROR, "MovieClip not found"); + BKE_report(op->reports, RPT_ERROR, "Movie clip not found"); return OPERATOR_CANCELLED; } @@ -553,7 +553,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad } if (seq_load.tot_success == 0) { - BKE_reportf(op->reports, RPT_ERROR, "File \"%s\" could not be loaded", seq_load.path); + BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", seq_load.path); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 7bec530fae9..29babd355ad 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -355,7 +355,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla y2 = seq->machine + SEQ_STRIP_OFSTOP; /* set up co-ordinates/dimensions for either left or right handle */ - if (direction == SEQ_LEFTHANDLE) { + if (direction == SEQ_LEFTHANDLE) { rx1 = x1; rx2 = x1 + handsize_clamped * 0.75f; @@ -415,7 +415,7 @@ static void draw_seq_handle(View2D *v2d, Sequence *seq, const float handsize_cla y1 = y2 + 0.05f; } UI_view2d_text_cache_add(v2d, x1, y1, numstr, col); - } + } } static void draw_seq_extensions(Scene *scene, ARegion *ar, Sequence *seq) @@ -810,7 +810,7 @@ static void UNUSED_FUNCTION(set_special_seq_update) (int val) /* if mouse over a sequence && LEFTMOUSE */ if (val) { -// XXX special_seq_update= find_nearest_seq(&x); +// XXX special_seq_update = find_nearest_seq(&x); } else special_seq_update = NULL; } @@ -1189,7 +1189,7 @@ static void draw_seq_backdrop(View2D *v2d) glRectf(v2d->cur.xmin, -1.0, v2d->cur.xmax, 1.0); /* Alternating horizontal stripes */ - i = maxi(1, ((int)v2d->cur.ymin) - 1); + i = max_ii(1, ((int)v2d->cur.ymin) - 1); glBegin(GL_QUADS); while (i < v2d->cur.ymax) { @@ -1208,7 +1208,7 @@ static void draw_seq_backdrop(View2D *v2d) glEnd(); /* Darker lines separating the horizontal bands */ - i = maxi(1, ((int)v2d->cur.ymin) - 1); + i = max_ii(1, ((int)v2d->cur.ymin) - 1); UI_ThemeColor(TH_GRID); glBegin(GL_LINES); @@ -1240,8 +1240,8 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) /* boundbox and selection tests for NOT drawing the strip... */ if ((seq->flag & SELECT) != sel) continue; else if (seq == last_seq) continue; - else if (MIN2(seq->startdisp, seq->start) > v2d->cur.xmax) continue; - else if (MAX2(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) continue; + else if (min_ii(seq->startdisp, seq->start) > v2d->cur.xmax) continue; + else if (max_ii(seq->enddisp, seq->start + seq->len) < v2d->cur.xmin) continue; else if (seq->machine + 1.0f < v2d->cur.ymin) continue; else if (seq->machine > v2d->cur.ymax) continue; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 82d08be4da2..7270516aa51 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -46,6 +46,8 @@ #include "BLI_utildefines.h" #include "BLI_threads.h" +#include "BLF_translation.h" + #include "DNA_scene_types.h" #include "DNA_userdef_types.h" @@ -507,7 +509,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT) { if (seq->type == SEQ_TYPE_SOUND_RAM && BKE_sequence_effect_get_num_inputs(type) != 0) { - *error_str = "Can't apply effects to audio sequence strips"; + *error_str = N_("Cannot apply effects to audio sequence strips"); return 0; } if ((seq != activeseq) && (seq != seq2)) { @@ -515,7 +517,7 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen else if (seq1 == NULL) seq1 = seq; else if (seq3 == NULL) seq3 = seq; else { - *error_str = "Can't apply effect to more than 3 sequence strips"; + *error_str = N_("Cannot apply effect to more than 3 sequence strips"); return 0; } } @@ -537,21 +539,21 @@ int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequen return 1; /* succsess */ case 1: if (seq2 == NULL) { - *error_str = "Need at least one selected sequence strip"; + *error_str = N_("At least one selected sequence strip is needed"); return 0; } if (seq1 == NULL) seq1 = seq2; if (seq3 == NULL) seq3 = seq2; case 2: if (seq1 == NULL || seq2 == NULL) { - *error_str = "Need 2 selected sequence strips"; + *error_str = N_("2 selected sequence strips are needed"); return 0; } if (seq3 == NULL) seq3 = seq2; } if (seq1 == NULL && seq2 == NULL && seq3 == NULL) { - *error_str = "TODO: in what cases does this happen?"; + *error_str = N_("TODO: in what cases does this happen?"); return 0; } @@ -680,7 +682,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe) seqn = BKE_sequence_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); } - if (seqn) { + if (seqn) { seqn->flag |= SELECT; /* Second Strip! */ @@ -701,7 +703,7 @@ static Sequence *cut_seq_hard(Scene *scene, Sequence *seq, int cutframe) seqn->anim_startofs += cutframe - ts.start; seqn->anim_endofs = ts.anim_endofs; seqn->endstill = ts.endstill; - } + } /* strips with extended stillframes after */ else if (((seqn->start + seqn->len) < cutframe) && (seqn->endstill)) { @@ -773,7 +775,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe) seqn = BKE_sequence_dupli_recursive(scene, NULL, seq, SEQ_DUPE_UNIQUE_NAME | SEQ_DUPE_ANIM); } - if (seqn) { + if (seqn) { seqn->flag |= SELECT; /* Second Strip! */ @@ -791,7 +793,7 @@ static Sequence *cut_seq_soft(Scene *scene, Sequence *seq, int cutframe) seqn->startofs = cutframe - ts.start; seqn->endofs = ts.endofs; seqn->endstill = ts.endstill; - } + } /* strips with extended stillframes after */ else if (((seqn->start + seqn->len) < cutframe) && (seqn->endstill)) { @@ -1056,7 +1058,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) { if ((seq->flag & (SEQ_LEFTSEL + SEQ_RIGHTSEL)) == 0) { /* simple but no anim update */ - /* seq->start= snap_frame-seq->startofs+seq->startstill; */ + /* seq->start = snap_frame-seq->startofs+seq->startstill; */ BKE_sequence_translate(scene, seq, (snap_frame - seq->startofs + seq->startstill) - seq->start); } @@ -1384,7 +1386,7 @@ static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op) seq_is_predecessor(seq2, last_seq) || seq_is_predecessor(seq3, last_seq)) { - BKE_report(op->reports, RPT_ERROR, "Can't reassign inputs: no cycles allowed"); + BKE_report(op->reports, RPT_ERROR, "Cannot reassign inputs: no cycles allowed"); return OPERATOR_CANCELLED; } @@ -1952,7 +1954,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) while (seq) { next = seq->next; if (seq != seqm && (seq->flag & SELECT)) { - channel_max = MAX2(seq->machine, channel_max); + channel_max = max_ii(seq->machine, channel_max); BLI_remlink(ed->seqbasep, seq); BLI_addtail(&seqm->seqbase, seq); } @@ -2129,7 +2131,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op)) zoomY = ((float)height) / ((float)imgheight); sseq->zoom = (zoomX < zoomY) ? zoomX : zoomY; - sseq->zoom = 1.0f / power_of_2(1 / minf(zoomX, zoomY)); + sseq->zoom = 1.0f / power_of_2(1 / min_ff(zoomX, zoomY)); } else { sseq->zoom = 1.0f; @@ -2255,11 +2257,11 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT) { - xmin = MIN2(xmin, seq->startdisp); - xmax = MAX2(xmax, seq->enddisp); + xmin = min_ii(xmin, seq->startdisp); + xmax = max_ii(xmax, seq->enddisp); - ymin = MIN2(ymin, seq->machine); - ymax = MAX2(ymax, seq->machine); + ymin = min_ii(ymin, seq->machine); + ymax = max_ii(ymax, seq->machine); } } @@ -2905,7 +2907,7 @@ static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) } if (*seq_1 == NULL || *seq_2 == NULL) { - BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, can't swap"); + BKE_report(op->reports, RPT_ERROR, "One of the effect inputs is unset, cannot swap"); return OPERATOR_CANCELLED; } else { @@ -3042,7 +3044,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) seq->anim_startofs = seq->anim_endofs = 0; /* correct start/end frames so we don't move - * important not to set seq->len= len; allow the function to handle it */ + * important not to set seq->len = len; allow the function to handle it */ BKE_sequence_reload_new_file(scene, seq, TRUE); BKE_sequence_calc(scene, seq); diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index be33b782fdf..c4df89547ef 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -353,7 +353,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) } else { /* deselect_markers(0, 0); */ /* XXX, in 2.4x, seq selection used to deselect all, need to re-thnik this for 2.5 */ - marker->flag |= SELECT; + marker->flag |= SELECT; } } @@ -399,7 +399,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) } } else { - // seq= find_nearest_seq(scene, v2d, &hand, mval); + // seq = find_nearest_seq(scene, v2d, &hand, mval); act_orig = ed->act_seq; @@ -1167,7 +1167,7 @@ static int sequencer_select_grouped_exec(bContext *C, wmOperator *op) extend = RNA_boolean_get(op->ptr, "extend"); if (actseq == NULL) { - BKE_report(op->reports, RPT_ERROR, "No Active Sequence!"); + BKE_report(op->reports, RPT_ERROR, "No active sequence!"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 7bfe58cb50a..e8d47016608 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -311,7 +311,7 @@ static SpaceLink *sequencer_duplicate(SpaceLink *sl) SpaceSeq *sseqn = MEM_dupallocN(sl); /* clear or remove stuff from old */ -// XXX sseq->gpd= gpencil_data_duplicate(sseq->gpd); +// XXX sseq->gpd = gpencil_data_duplicate(sseq->gpd); return (SpaceLink *)sseqn; } @@ -363,7 +363,7 @@ static void sequencer_main_area_init(wmWindowManager *wm, ARegion *ar) static void sequencer_main_area_draw(const bContext *C, ARegion *ar) { -// ScrArea *sa= CTX_wm_area(C); +// ScrArea *sa = CTX_wm_area(C); /* NLE - strip editing timeline interface */ draw_timeline_seq(C, ar); diff --git a/source/blender/editors/space_text/CMakeLists.txt b/source/blender/editors/space_text/CMakeLists.txt index ead7de92c5c..9cc407f0604 100644 --- a/source/blender/editors/space_text/CMakeLists.txt +++ b/source/blender/editors/space_text/CMakeLists.txt @@ -54,4 +54,8 @@ if(WITH_PYTHON) add_definitions(-DWITH_PYTHON) endif() +if(WITH_INTERNATIONAL) + add_definitions(-DWITH_INTERNATIONAL) +endif() + blender_add_lib(bf_editor_text "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/editors/space_text/SConscript b/source/blender/editors/space_text/SConscript index 6ad6427f1d3..373564520c8 100644 --- a/source/blender/editors/space_text/SConscript +++ b/source/blender/editors/space_text/SConscript @@ -10,4 +10,7 @@ incs += ' ../../python ../../makesrna ../../blenfont ../../blenloader' if env['WITH_BF_PYTHON']: defs.append('WITH_PYTHON') +if env['WITH_BF_INTERNATIONAL']: + defs.append('WITH_INTERNATIONAL') + env.BlenderLib ( 'bf_editors_space_text', sources, Split(incs), defs, libtype=['core'], priority=[95] ) diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index 501e1cad67e..3f70b2cb66e 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -431,7 +431,7 @@ static void text_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ SpaceText *st = CTX_wm_space_text(C); - //View2D *v2d= &ar->v2d; + //View2D *v2d = &ar->v2d; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index a68524fcdd6..94f64563fd8 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1139,7 +1139,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) barheight = (ltexth > 0) ? (st->viewlines * pix_available) / ltexth : 0; pix_bardiff = 0; if (barheight < 20) { - pix_bardiff = 20 - barheight; /* take into account the now non-linear sizing of the bar */ + pix_bardiff = 20 - barheight; /* take into account the now non-linear sizing of the bar */ barheight = 20; } barstart = (ltexth > 0) ? ((pix_available - pix_bardiff) * st->top) / ltexth : 0; @@ -1166,9 +1166,9 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) /* the scrollbar is non-linear sized */ if (pix_bardiff > 0) { /* the start of the highlight is in the current viewport */ - if (ltexth && st->viewlines && lhlstart >= st->top && lhlstart <= st->top + st->viewlines) { + if (ltexth && st->viewlines && lhlstart >= st->top && lhlstart <= st->top + st->viewlines) { /* speed the progresion of the start of the highlight through the scrollbar */ - hlstart = ( ( (pix_available - pix_bardiff) * lhlstart) / ltexth) + (pix_bardiff * (lhlstart - st->top) / st->viewlines); + hlstart = ( ( (pix_available - pix_bardiff) * lhlstart) / ltexth) + (pix_bardiff * (lhlstart - st->top) / st->viewlines); } else if (lhlstart > st->top + st->viewlines && hlstart < barstart + barheight && hlstart > barstart) { /* push hl start down */ @@ -1179,35 +1179,35 @@ static void calc_text_rcts(SpaceText *st, ARegion *ar, rcti *scroll, rcti *back) hlstart = barstart; } - if (hlend <= hlstart) { + if (hlend <= hlstart) { hlend = hlstart + 2; } /* the end of the highlight is in the current viewport */ - if (ltexth && st->viewlines && lhlend >= st->top && lhlend <= st->top + st->viewlines) { + if (ltexth && st->viewlines && lhlend >= st->top && lhlend <= st->top + st->viewlines) { /* speed the progresion of the end of the highlight through the scrollbar */ hlend = (((pix_available - pix_bardiff) * lhlend) / ltexth) + (pix_bardiff * (lhlend - st->top) / st->viewlines); } else if (lhlend < st->top && hlend >= barstart - 2 && hlend < barstart + barheight) { /* push hl end up */ hlend = barstart; - } + } else if (lhlend > st->top + st->viewlines && lhlstart < st->top + st->viewlines && hlend < barstart + barheight) { /* fill out end */ hlend = barstart + barheight; } - if (hlend <= hlstart) { + if (hlend <= hlstart) { hlstart = hlend - 2; - } - } + } + } } else { hlstart = 0; hlend = 0; } - if (hlend - hlstart < 2) { + if (hlend - hlstart < 2) { hlend = hlstart + 2; } @@ -1232,7 +1232,7 @@ static void draw_textscroll(SpaceText *st, rcti *scroll, rcti *back) uiWidgetScrollDraw(&wcol, scroll, &st->txtbar, (st->flags & ST_SCROLL_SELECT) ? UI_SCROLL_PRESSED : 0); uiSetRoundBox(UI_CNR_ALL); - rad = 0.4f * mini(BLI_rcti_size_x(&st->txtscroll), BLI_rcti_size_y(&st->txtscroll)); + rad = 0.4f * min_ii(BLI_rcti_size_x(&st->txtscroll), BLI_rcti_size_y(&st->txtscroll)); UI_GetThemeColor3ubv(TH_HILITE, col); col[3] = 48; glColor4ubv(col); @@ -1355,7 +1355,7 @@ static void draw_documentation(SpaceText *st, ARegion *ar) x += SUGG_LIST_WIDTH * st->cwidth + 50; } - /* top= */ /* UNUSED */ y = ar->winy - st->lheight * l - 2; + /* top = */ /* UNUSED */ y = ar->winy - st->lheight * l - 2; boxw = DOC_WIDTH * st->cwidth + 20; boxh = (DOC_HEIGHT + 1) * st->lheight; @@ -1702,7 +1702,7 @@ static void draw_brackets(SpaceText *st, ARegion *ar) if (!endl || endc == -1) return; - UI_ThemeColor(TH_HILITE); + UI_ThemeColor(TH_HILITE); x = st->showlinenrs ? TXT_OFFSET + TEXTXLOC : TXT_OFFSET; y = ar->winy - st->lheight; @@ -1789,7 +1789,7 @@ void draw_text_main(SpaceText *st, ARegion *ar) text_font_begin(st); st->cwidth = BLF_fixed_width(mono); - st->cwidth = MAX2(st->cwidth, 1); + st->cwidth = MAX2(st->cwidth, (char)1); /* draw line numbers background */ if (st->showlinenrs) { @@ -1873,7 +1873,7 @@ void text_update_character_width(SpaceText *st) { text_font_begin(st); st->cwidth = BLF_fixed_width(mono); - st->cwidth = MAX2(st->cwidth, 1); + st->cwidth = MAX2(st->cwidth, (char)1); text_font_end(st); } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index b2fb16ff7fe..2d902c4586a 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -44,6 +44,8 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "PIL_time.h" #include "BKE_context.h" @@ -93,7 +95,7 @@ static int text_edit_poll(bContext *C) return 0; if (text->id.lib) { - // BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); + // BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata"); return 0; } @@ -109,7 +111,7 @@ static int text_space_edit_poll(bContext *C) return 0; if (text->id.lib) { - // BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); + // BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata"); return 0; } @@ -129,7 +131,7 @@ static int text_region_edit_poll(bContext *C) return 0; if (text->id.lib) { - // BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); + // BKE_report(op->reports, RPT_ERROR, "Cannot edit external libdata"); return 0; } @@ -463,7 +465,8 @@ static void txt_write_file(Text *text, ReportList *reports) fp = BLI_fopen(filepath, "w"); if (fp == NULL) { - BKE_reportf(reports, RPT_ERROR, "Unable to save \"%s\": %s", filepath, errno ? strerror(errno) : "Unknown error writing file"); + BKE_reportf(reports, RPT_ERROR, "Unable to save '%s': %s", + filepath, errno ? strerror(errno) : TIP_("unknown error writing file")); return; } @@ -482,7 +485,8 @@ static void txt_write_file(Text *text, ReportList *reports) } else { text->mtime = 0; - BKE_reportf(reports, RPT_WARNING, "Unable to stat \"%s\": %s", filepath, errno ? strerror(errno) : "Unknown error starrng file"); + BKE_reportf(reports, RPT_WARNING, "Unable to stat '%s': %s", + filepath, errno ? strerror(errno) : TIP_("unknown error stating file")); } if (text->flags & TXT_ISDIRTY) @@ -970,21 +974,17 @@ static int text_unindent_exec(bContext *C, wmOperator *UNUSED(op)) { Text *text = CTX_data_edit_text(C); - if (txt_has_sel(text)) { - text_drawcache_tag_update(CTX_wm_space_text(C), 0); - - txt_order_cursors(text); - txt_unindent(text); + text_drawcache_tag_update(CTX_wm_space_text(C), 0); - text_update_edited(text); + txt_order_cursors(text); + txt_unindent(text); - text_update_cursor_moved(C); - WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); + text_update_edited(text); - return OPERATOR_FINISHED; - } + text_update_cursor_moved(C); + WM_event_add_notifier(C, NC_TEXT | NA_EDITED, text); - return OPERATOR_CANCELLED; + return OPERATOR_FINISHED; } void TEXT_OT_unindent(wmOperatorType *ot) @@ -1948,7 +1948,7 @@ static int text_move_cursor(bContext *C, int type, int select) txt_move_left(text, select); break; - case NEXT_CHAR: + case NEXT_CHAR: txt_move_right(text, select); break; @@ -2669,7 +2669,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, wmEvent *event) text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text); - } + } else if (!st->wordwrap && (event->mval[0] < 0 || event->mval[0] > ar->winx)) { if (event->mval[0] > ar->winx) st->left++; else if (event->mval[0] < 0 && st->left > 0) st->left--; @@ -2679,7 +2679,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, wmEvent *event) text_update_cursor_moved(C); WM_event_add_notifier(C, NC_TEXT | ND_CURSOR, st->text); // XXX PIL_sleep_ms(10); - } + } else { text_cursor_set_to_pos(st, ar, event->mval[0], event->mval[1], 1); @@ -2688,7 +2688,7 @@ static void text_cursor_set_apply(bContext *C, wmOperator *op, wmEvent *event) ssel->old[0] = event->mval[0]; ssel->old[1] = event->mval[1]; - } + } } static void text_cursor_set_exit(bContext *C, wmOperator *op) diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index 135e9b891bb..0649edc1ac4 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -84,7 +84,7 @@ void draw_motion_paths_init(View3D *v3d, ARegion *ar) void draw_motion_path_instance(Scene *scene, Object *ob, bPoseChannel *pchan, bAnimVizSettings *avs, bMotionPath *mpath) { - //RegionView3D *rv3d= ar->regiondata; + //RegionView3D *rv3d = ar->regiondata; bMotionPathVert *mpv, *mpv_start; int i, stepsize = avs->path_step; int sfra, efra, sind, len; @@ -148,11 +148,11 @@ void draw_motion_path_instance(Scene *scene, if ((sfra + i) < CFRA) { /* black - before cfra */ if (sel) { - // intensity= 0.5f; + // intensity = 0.5f; intensity = SET_INTENSITY(sfra, i, CFRA, 0.25f, 0.75f); } else { - //intensity= 0.8f; + //intensity = 0.8f; intensity = SET_INTENSITY(sfra, i, CFRA, 0.68f, 0.92f); } UI_ThemeColorBlend(TH_WIRE, TH_BACK, intensity); @@ -178,7 +178,7 @@ void draw_motion_path_instance(Scene *scene, intensity = 0.99f; } UI_ThemeColorBlendShade(TH_CFRAME, TH_BACK, intensity, 10); - } + } /* draw a vertex with this color */ glVertex3fv(mpv->co); diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 31df13343ce..beafee335d4 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -100,7 +100,7 @@ static void set_pchan_colorset(Object *ob, bPoseChannel *pchan) } /* only try to set custom color if enabled for armature */ - if (arm->flag & ARM_COL_CUSTOM) { + if (arm->flag & ARM_COL_CUSTOM) { /* currently, a bone can only use a custom color set if it's group (if it has one), * has been set to use one */ @@ -647,7 +647,7 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel /* this routine doesn't call get_matrix_editbone() that calculates it */ ebone->length = len_v3v3(ebone->head, ebone->tail); - /*length= ebone->length;*/ /*UNUSED*/ + /*length = ebone->length;*/ /*UNUSED*/ tail = ebone->rad_tail; dist = ebone->dist; if (ebone->parent && (ebone->flag & BONE_CONNECTED)) @@ -658,7 +658,7 @@ static void draw_sphere_bone_dist(float smat[][4], float imat[][4], bPoseChannel tailvec = ebone->tail; } else { - /*length= pchan->bone->length;*/ /*UNUSED*/ + /*length = pchan->bone->length;*/ /*UNUSED*/ tail = pchan->bone->rad_tail; dist = pchan->bone->dist; if (pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) @@ -767,7 +767,7 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4], /* this routine doesn't call get_matrix_editbone() that calculates it */ ebone->length = len_v3v3(ebone->head, ebone->tail); - /*length= ebone->length;*/ /*UNUSED*/ + /*length = ebone->length;*/ /*UNUSED*/ tail = ebone->rad_tail; if (ebone->parent && (boneflag & BONE_CONNECTED)) head = ebone->parent->rad_tail; @@ -777,7 +777,7 @@ static void draw_sphere_bone_wire(float smat[][4], float imat[][4], tailvec = ebone->tail; } else { - /*length= pchan->bone->length;*/ /*UNUSED*/ + /*length = pchan->bone->length;*/ /*UNUSED*/ tail = pchan->bone->rad_tail; if ((pchan->parent) && (boneflag & BONE_CONNECTED)) head = pchan->parent->bone->rad_tail; @@ -969,7 +969,7 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co glTranslatef(0.0f, 0.0f, head); gluSphere(qobj, fac1 * head + (1.0f - fac1) * tail, 16, 10); } - else { + else { /* 1 sphere in center */ glTranslatef(0.0f, 0.0f, (head + length - tail) / 2.0f); gluSphere(qobj, fac1 * head + (1.0f - fac1) * tail, 16, 10); @@ -1040,7 +1040,7 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned glEnd(); /* tip */ - if (G.f & G_PICKSEL) { + if (G.f & G_PICKSEL) { /* no bitmap in selection mode, crashes 3d cards... */ glLoadName(id | BONESEL_TIP); glBegin(GL_POINTS); @@ -1189,7 +1189,7 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl glDisable(GL_COLOR_MATERIAL); glDisable(GL_LIGHTING); } - else { + else { /* wire */ if (armflag & ARM_POSEMODE) { if (constflag) { @@ -1205,9 +1205,9 @@ static void draw_b_bone(const short dt, int armflag, int boneflag, short constfl /* restore colors */ set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); } - } + } - draw_b_bone_boxes(OB_WIRE, pchan, xwidth, length, zwidth); + draw_b_bone_boxes(OB_WIRE, pchan, xwidth, length, zwidth); } } @@ -1333,7 +1333,7 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag else if (armflag & ARM_POSEMODE) { if (constflag) { /* draw constraint colors */ - if (set_pchan_glColor(PCHAN_COLOR_CONSTS, boneflag, constflag)) { + if (set_pchan_glColor(PCHAN_COLOR_CONSTS, boneflag, constflag)) { glEnable(GL_BLEND); draw_bone_solid_octahedral(); @@ -1344,10 +1344,10 @@ static void draw_bone(const short dt, int armflag, int boneflag, short constflag /* restore colors */ set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag); } - } + } draw_bone_octahedral(); } - else { + else { /* solid */ if (armflag & ARM_POSEMODE) set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, constflag); @@ -1741,7 +1741,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (use_custom && pchan->custom_tx) { glMultMatrixf(pchan->custom_tx->pose_mat); - } + } else { glMultMatrixf(pchan->pose_mat); } @@ -1803,7 +1803,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, */ if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && (draw_wire == 0)) { /* object tag, for bordersel optim */ - glLoadName(index & 0xFFFF); + glLoadName(index & 0xFFFF); index = -1; } } @@ -1830,7 +1830,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (pchan->custom_tx) { glMultMatrixf(pchan->custom_tx->pose_mat); - } + } else { glMultMatrixf(pchan->pose_mat); } @@ -1869,7 +1869,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* stick or wire bones have not been drawn yet so don't clear object selection in this case */ if (ELEM(arm->drawtype, ARM_LINE, ARM_WIRE) == 0 && draw_wire) { /* object tag, for bordersel optim */ - glLoadName(index & 0xFFFF); + glLoadName(index & 0xFFFF); index = -1; } } @@ -1938,7 +1938,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, glLoadName(index & 0xFFFF); pchan_draw_IK_root_lines(pchan, !(do_dashed & 2)); } - } + } } } @@ -1992,7 +1992,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, /* restore things */ if (!ELEM(arm->drawtype, ARM_WIRE, ARM_LINE) && (dt > OB_WIRE) && (arm->flag & ARM_POSEMODE)) bglPolygonOffset(rv3d->dist, 0.0); - } + } /* restore */ glDisable(GL_CULL_FACE); @@ -2045,7 +2045,7 @@ static void draw_pose_bones(Scene *scene, View3D *v3d, ARegion *ar, Base *base, if (arm->flag & ARM_DRAWNAMES) { mid_v3_v3v3(vec, pchan->pose_head, pchan->pose_tail); view3d_cached_text_draw_add(vec, pchan->name, 10, 0, col); - } + } /* Draw additional axes on the bone tail */ if ((arm->flag & ARM_DRAWAXES) && (arm->flag & ARM_POSEMODE)) { @@ -2075,7 +2075,7 @@ static void get_matrix_editbone(EditBone *eBone, float bmat[][4]) float mat[3][3]; /* Compose the parent transforms (i.e. their translations) */ - sub_v3_v3v3(delta, eBone->tail, eBone->head); + sub_v3_v3v3(delta, eBone->tail, eBone->head); eBone->length = (float)sqrt(delta[0] * delta[0] + delta[1] * delta[1] + delta[2] * delta[2]); @@ -2258,7 +2258,7 @@ static void draw_ebones(View3D *v3d, ARegion *ar, Object *ob, const short dt) mid_v3_v3v3(vec, eBone->head, eBone->tail); glRasterPos3fv(vec); view3d_cached_text_draw_add(vec, eBone->name, 10, 0, col); - } + } /* Draw additional axes */ if (arm->flag & ARM_DRAWAXES) { glPushMatrix(); @@ -2643,7 +2643,7 @@ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, } draw_pose_paths(scene, v3d, ar, ob); } - } + } } draw_pose_bones(scene, v3d, ar, base, dt, ob_wire_col, (dflag & DRAW_CONSTCOLOR), is_outline); arm->flag &= ~ARM_POSEMODE; diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index cded7bbbdfc..cb5556396dd 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -382,7 +382,7 @@ static void draw_textured_begin(Scene *scene, View3D *v3d, RegionView3D *rv3d, O glEnable(GL_CULL_FACE); glCullFace(GL_BACK); } - else { + else { glDisable(GL_CULL_FACE); } glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, (me->flag & ME_TWOSIDED) ? GL_TRUE : GL_FALSE); @@ -406,7 +406,7 @@ static void draw_textured_end(void) * - zr */ glPushMatrix(); - glLoadIdentity(); + glLoadIdentity(); GPU_default_lights(); glPopMatrix(); } @@ -636,7 +636,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) int a, totpoly = me->totpoly; /* fake values to pass to GPU_render_text() */ - MCol tmp_mcol[4] = {{0}}; + MCol tmp_mcol[4] = {{0}}; MCol *tmp_mcol_pt = mloopcol ? tmp_mcol : NULL; MTFace tmp_tf = {{{0}}}; @@ -703,7 +703,7 @@ static void draw_mesh_text(Scene *scene, Object *ob, int glsl) /* COLOR */ if (mloopcol) { - unsigned int totloop_clamp = MIN2(4, mp->totloop); + unsigned int totloop_clamp = min_ii(4, mp->totloop); unsigned int j; lcol = &mloopcol[mp->loopstart]; diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index ec54ae09fd2..27a660eac2b 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -578,7 +578,7 @@ static void draw_empty_image(Object *ob, const short dflag, const unsigned char glTranslatef(0.0f, 0.0f, 0.0f); /* Calculate Image scale */ - scale = (ob->empty_drawsize / (float)MAX2(ima_x * sca_x, ima_y * sca_y)); + scale = (ob->empty_drawsize / max_ff((float)ima_x * sca_x, (float)ima_y * sca_y)); /* Set the object scale */ glScalef(scale * sca_x, scale * sca_y, 1.0f); @@ -4457,7 +4457,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv if (cdata2) MEM_freeN(cdata2); - /* cd2= */ /* UNUSED */ cdata2 = NULL; + /* cd2 = */ /* UNUSED */ cdata2 = NULL; glLineWidth(1.0f); @@ -5523,7 +5523,7 @@ 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 */ + /* coordinates are: cos(degrees * 11.25) = x, sin(degrees*11.25) = y, 0.0f = z */ for (degrees = 0; degrees < CIRCLE_RESOL; degrees++) { x = cosval[degrees]; y = sinval[degrees]; @@ -6570,7 +6570,6 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, const short /* code for new particle system */ if ((warning_recursive == 0) && (ob->particlesystem.first) && - (dflag & DRAW_PICKING) == 0 && (ob != scene->obedit) ) { diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 236cbb86724..6818c78bbd6 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -185,7 +185,7 @@ int ED_view3d_context_user_region(bContext *C, View3D **v3d_r, ARegion **ar_r) ar_unlock_user = ar; break; } - } + } } } @@ -719,7 +719,7 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) case NC_BRUSH: if (wmn->action == NA_EDITED) ED_region_tag_redraw_overlay(ar); - break; + break; case NC_MATERIAL: switch (wmn->data) { case ND_SHADING_DRAW: @@ -748,12 +748,12 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) break; } break; - case NC_IMAGE: + case NC_IMAGE: /* this could be more fine grained checks if we had * more context than just the region */ ED_region_tag_redraw(ar); break; - case NC_TEXTURE: + case NC_TEXTURE: /* same as above */ ED_region_tag_redraw(ar); break; @@ -882,7 +882,7 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn) case ND_KEYFRAME: if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); - break; + break; } break; case NC_SCENE: diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 9755c7d1b7c..f1be0978c06 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1223,7 +1223,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa) if (ob == NULL) return; - lim = 10000.0f * MAX2(1.0f, v3d->grid); + lim = 10000.0f * max_ff(1.0f, v3d->grid); block = uiLayoutGetBlock(pa->layout); uiBlockSetHandleFunc(block, do_view3d_region_buttons, NULL); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 8e1b0716136..d61ba5f1181 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -523,7 +523,7 @@ static void drawfloor(Scene *scene, View3D *v3d, const char **grid_unit) GPU_print_error("sdsd"); } - /* draw the Z axis line */ + /* draw the Z axis line */ /* check for the 'show Z axis' preference */ if (v3d->gridflag & (V3D_SHOW_X | V3D_SHOW_Y | V3D_SHOW_Z)) { int axis; @@ -1060,7 +1060,7 @@ static void drawviewborder_triangle(float x1, float x2, float y1, float y2, cons static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) { - float fac, a; + float hmargin, vmargin; float x1, x2, y1, y2; float x1i, x2i, y1i, y2i; float x3, y3, x4, y4; @@ -1115,7 +1115,7 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) } /* edge */ - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); setlinestyle(0); @@ -1214,20 +1214,15 @@ static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) } if (ca->flag & CAM_SHOWTITLESAFE) { - fac = 0.1; - - a = fac * (x2 - x1); - x1 += a; - x2 -= a; - - a = fac * (y2 - y1); - y1 += a; - y2 -= a; - UI_ThemeColorBlendShade(TH_WIRE, TH_BACK, 0.25, 0); - uiSetRoundBox(UI_CNR_ALL); - uiDrawBox(GL_LINE_LOOP, x1, y1, x2, y2, 12.0); + hmargin = 0.1 * (x2 - x1); + vmargin = 0.05 * (y2 - y1); + uiDrawBox(GL_LINE_LOOP, x1+hmargin, y1+vmargin, x2-hmargin, y2-vmargin, 2.0); + + hmargin = 0.035 * (x2 - x1); + vmargin = 0.035 * (y2 - y1); + uiDrawBox(GL_LINE_LOOP, x1+hmargin, y1+vmargin, x2-hmargin, y2-vmargin, 2.0); } if (ca && (ca->flag & CAM_SHOWSENSOR)) { /* determine sensor fit, and get sensor x/y, for auto fit we @@ -1429,7 +1424,7 @@ ImBuf *view3d_read_backbuf(ViewContext *vc, short xmin, short ymin, short xmax, (ymaxc - yminc + 1), GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); - glReadBuffer(GL_BACK); + glReadBuffer(GL_BACK); if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); @@ -1471,7 +1466,7 @@ unsigned int view3d_sample_backbuf_rect(ViewContext *vc, const int mval[2], int int a, b, rc, nr, amount, dirvec[4][2]; int distance = 0; unsigned int index = 0; - short indexok = 0; + short indexok = 0; amount = (size - 1) / 2; @@ -1640,7 +1635,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, /* apply offset last - camera offset is different to offset in blender units */ /* so this has some sane way of working - this matches camera's shift _exactly_ */ { - const float max_dim = maxf(x2 - x1, y2 - y1); + const float max_dim = max_ff(x2 - x1, y2 - y1); const float xof_scale = bgpic->xof * max_dim; const float yof_scale = bgpic->yof * max_dim; @@ -1689,7 +1684,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, /* calc window coord */ initgrabz(rv3d, 0.0, 0.0, 0.0); ED_view3d_win_to_delta(ar, mval_f, tvec); - fac = maxf(fabsf(tvec[0]), maxf(fabsf(tvec[1]), fabsf(tvec[2]))); /* largest abs axis */ + fac = max_ff(fabsf(tvec[0]), max_ff(fabsf(tvec[1]), fabsf(tvec[2]))); /* largest abs axis */ fac = 1.0f / fac; asp = (float)ibuf->y / (float)ibuf->x; @@ -1717,7 +1712,7 @@ static void view3d_draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, /* for some reason; zoomlevels down refuses to use GL_ALPHA_SCALE */ if (zoomx < 1.0f || zoomy < 1.0f) { - float tzoom = minf(zoomx, zoomy); + float tzoom = min_ff(zoomx, zoomy); int mip = 0; if ((ibuf->userflags & IB_MIPMAP_INVALID) != 0) { @@ -2024,7 +2019,7 @@ static void draw_dupli_objects(Scene *scene, ARegion *ar, View3D *v3d, Base *bas void view3d_update_depths_rect(ARegion *ar, ViewDepths *d, rcti *rect) { - int x, y, w, h; + int x, y, w, h; rcti r; /* clamp rect by area */ @@ -2122,7 +2117,7 @@ float view3d_depth_near(ViewDepths *d) int i = (int)d->w * (int)d->h; /* cast to avoid short overflow */ /* far is both the starting 'far' value - * and the closest value found. */ + * and the closest value found. */ while (i--) { depth = *depths++; if ((depth < far) && (depth > near)) { @@ -2138,7 +2133,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) short zbuf = v3d->zbuf; RegionView3D *rv3d = ar->regiondata; - setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ + setwinmatrixview3d(ar, v3d, NULL); setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); @@ -2173,7 +2168,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *)) U.glalphaclip = 0.5; /* not that nice but means we wont zoom into billboards */ U.obcenter_dia = 0; - setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ + setwinmatrixview3d(ar, v3d, NULL); setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); @@ -2371,6 +2366,7 @@ static void gpu_update_lamps_shadows(Scene *scene, View3D *v3d) mult_m4_m4m4(rv3d.persmat, rv3d.winmat, rv3d.viewmat); invert_m4_m4(rv3d.persinv, rv3d.viewinv); + /* no need to call ED_view3d_draw_offscreen_init since shadow buffers were already updated */ ED_view3d_draw_offscreen(scene, v3d, &ar, winsize, winsize, viewmat, winmat, FALSE, FALSE); GPU_lamp_shadow_buffer_unbind(shadow->lamp); @@ -2460,7 +2456,7 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view if (winmat) copy_m4_m4(rv3d->winmat, winmat); else - setwinmatrixview3d(ar, v3d, NULL); /* NULL= no pickrect */ + setwinmatrixview3d(ar, v3d, NULL); /* setup view matrix */ if (viewmat) @@ -2478,7 +2474,7 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view /* note: '1.0f / len_v3(v1)' replaced 'len_v3(rv3d->viewmat[0])' * because of float point precision problems at large values [#23908] */ float v1[3], v2[3]; - float len1, len2; + float len_px, len_sc; v1[0] = rv3d->persmat[0][0]; v1[1] = rv3d->persmat[1][0]; @@ -2488,10 +2484,10 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view v2[1] = rv3d->persmat[1][1]; v2[2] = rv3d->persmat[2][1]; - len1 = 1.0f / len_v3(v1); - len2 = 1.0f / len_v3(v2); + len_px = 2.0f / sqrtf(min_ff(len_squared_v3(v1), len_squared_v3(v2))); + len_sc = (float)MAX2(ar->winx, ar->winy); - rv3d->pixsize = (2.0f * MAX2(len1, len2)) / (float)MAX2(ar->winx, ar->winy); + rv3d->pixsize = len_px / len_sc; } } @@ -2508,6 +2504,16 @@ static void view3d_main_area_setup_view(Scene *scene, View3D *v3d, ARegion *ar, glLoadMatrixf(rv3d->viewmat); } +void ED_view3d_draw_offscreen_init(Scene *scene, View3D *v3d) +{ + /* shadow buffers, before we setup matrices */ + if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) + gpu_update_lamps_shadows(scene, v3d); +} + +/* ED_view3d_draw_offscreen_init should be called before this to initialize + * stuff like shadow buffers + */ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx, int winy, float viewmat[][4], float winmat[][4], int do_bgpic, int colormanage_background) @@ -2541,10 +2547,6 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, /* free images which can have changed on frame-change * warning! can be slow so only free animated images - campbell */ GPU_free_images_anim(); - - /* shadow buffers, before we setup matrices */ - if (draw_glsl_material(scene, NULL, v3d, v3d->drawtype)) - gpu_update_lamps_shadows(scene, v3d); /* set background color, fallback on the view background color * (if active clip is set but frame is failed to load fallback to horizon color as background) */ @@ -2687,6 +2689,8 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, if (ofs == NULL) return NULL; + ED_view3d_draw_offscreen_init(scene, v3d); + GPU_offscreen_bind(ofs); /* render 3d view */ @@ -2815,7 +2819,7 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar) if (fps + 0.5f < (float)(FPS)) { UI_ThemeColor(TH_REDALERT); BLI_snprintf(printable, sizeof(printable), "fps: %.2f", fps); - } + } else { UI_ThemeColor(TH_TEXT_HI); BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps + 0.5f)); @@ -2859,8 +2863,8 @@ static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar, int draw /* clamp small tile sizes to prevent inefficient threading utilization * the same happens for final renders as well */ - engine->tile_x = MAX2(engine->tile_x, 64); - engine->tile_y = MAX2(engine->tile_x, 64); + engine->tile_x = max_ii(engine->tile_x, 64); + engine->tile_y = max_ii(engine->tile_x, 64); type->view_update(engine, C); @@ -3135,8 +3139,6 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); - Object *ob; - if (rv3d->persp == RV3D_CAMOB) { drawviewborder(scene, ar, v3d); } @@ -3153,44 +3155,48 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha } if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + Object *ob; + /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */ // if (v3d->flag2 & V3D_DISPGP) draw_gpencil_view3d(scene, v3d, ar, 0); drawcursor(scene, ar, v3d); + + if (U.uiflag & USER_SHOW_ROTVIEWICON) + draw_view_axis(rv3d); + else + draw_view_icon(rv3d); + + ob = OBACT; + if (U.uiflag & USER_DRAWVIEWINFO) + draw_selected_name(scene, ob); } - - if (U.uiflag & USER_SHOW_ROTVIEWICON) - draw_view_axis(rv3d); - else - draw_view_icon(rv3d); - - ob = OBACT; - if (U.uiflag & USER_DRAWVIEWINFO) - draw_selected_name(scene, ob); if (rv3d->render_engine) { view3d_main_area_draw_engine_info(rv3d, ar); return; } - if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_playing(wm)) { - draw_viewport_fps(scene, ar); - } - else if (U.uiflag & USER_SHOW_VIEWPORTNAME) { - draw_viewport_name(ar, v3d); - } + if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { + if ((U.uiflag & USER_SHOW_FPS) && ED_screen_animation_playing(wm)) { + draw_viewport_fps(scene, ar); + } + else if (U.uiflag & USER_SHOW_VIEWPORTNAME) { + draw_viewport_name(ar, v3d); + } - if (grid_unit) { /* draw below the viewport name */ - char numstr[32] = ""; + if (grid_unit) { /* draw below the viewport name */ + char numstr[32] = ""; - UI_ThemeColor(TH_TEXT_HI); - if (v3d->grid != 1.0f) { - BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid); - } + UI_ThemeColor(TH_TEXT_HI); + if (v3d->grid != 1.0f) { + BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid); + } - BLF_draw_default_ascii(22, ar->winy - (USER_SHOW_VIEWPORTNAME ? 40 : 20), 0.0f, - numstr[0] ? numstr : grid_unit, sizeof(numstr)); + BLF_draw_default_ascii(22, ar->winy - (USER_SHOW_VIEWPORTNAME ? 40 : 20), 0.0f, + numstr[0] ? numstr : grid_unit, sizeof(numstr)); + } } } diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 96264081f10..242a3327b78 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -96,6 +96,7 @@ int ED_view3d_camera_lock_check(View3D *v3d, RegionView3D *rv3d) void ED_view3d_camera_lock_init(View3D *v3d, RegionView3D *rv3d) { if (ED_view3d_camera_lock_check(v3d, rv3d)) { + rv3d->dist = ED_view3d_offset_distance(v3d->camera->obmat, rv3d->ofs); ED_view3d_from_object(v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); } } @@ -894,6 +895,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) /* changed since 2.4x, use the camera view */ if (vod->v3d->camera) { + rv3d->dist = ED_view3d_offset_distance(vod->v3d->camera->obmat, rv3d->ofs); ED_view3d_from_object(vod->v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, NULL); } @@ -921,7 +923,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_FINISHED; } - else { + else { /* add temp handler */ WM_event_add_modal_handler(C, op); @@ -1354,7 +1356,7 @@ static int ndof_all_invoke(bContext *C, wmOperator *op, wmEvent *event) ED_view3d_camera_lock_sync(v3d, rv3d); ED_region_tag_redraw(CTX_wm_region(C)); - viewops_data_free(C, op); + viewops_data_free(C, op); return OPERATOR_FINISHED; } } @@ -1501,7 +1503,7 @@ static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event) viewmove_apply(vod, event->prevx, event->prevy); ED_view3d_depth_tag_update(vod->rv3d); - viewops_data_free(C, op); + viewops_data_free(C, op); return OPERATOR_FINISHED; } @@ -2039,7 +2041,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op) normalize_v3(mousevec); } - /* v3d= sa->spacedata.first; */ /* UNUSED */ + /* v3d = sa->spacedata.first; */ /* UNUSED */ rv3d = ar->regiondata; /* overwrite the mouse vector with the view direction (zoom into the center) */ @@ -2591,7 +2593,7 @@ static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) /* was xfac = (float)ar->winx / (float)(size[0] + 4); yfac = (float)ar->winy / (float)(size[1] + 4); - rv3d->camzoom = BKE_screen_view3d_zoom_from_fac(minf(xfac, yfac)); + rv3d->camzoom = BKE_screen_view3d_zoom_from_fac(min_ff(xfac, yfac)); CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); @@ -2695,7 +2697,7 @@ void VIEW3D_OT_render_border(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Render Border"; - ot->description = "Set the boundaries of the border render and enables border render"; + ot->description = "Set the boundaries of the border render and enable border render"; ot->idname = "VIEW3D_OT_render_border"; /* api callbacks */ @@ -2715,7 +2717,7 @@ void VIEW3D_OT_render_border(wmOperatorType *ot) RNA_def_boolean(ot->srna, "camera_only", 0, "Camera Only", "Set render border for camera view and final render only"); } -/* ********************* Set render border operator ****************** */ +/* ********************* Clear render border operator ****************** */ static int clear_render_border_exec(bContext *C, wmOperator *UNUSED(op)) { @@ -2751,7 +2753,7 @@ void VIEW3D_OT_clear_render_border(wmOperatorType *ot) { /* identifiers */ ot->name = "Clear Render Border"; - ot->description = "Clear the boundaries of the border render and enables border render"; + ot->description = "Clear the boundaries of the border render and disable border render"; ot->idname = "VIEW3D_OT_clear_render_border"; /* api callbacks */ @@ -2879,7 +2881,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) /* work out the ratios, so that everything selected fits when we zoom */ xscale = (BLI_rcti_size_x(&rect) / vb[0]); yscale = (BLI_rcti_size_y(&rect) / vb[1]); - new_dist *= maxf(xscale, yscale); + new_dist *= max_ff(xscale, yscale); /* zoom in as required, or as far as we can go */ dist_range_min = 0.001f * v3d->grid; @@ -3924,6 +3926,18 @@ int ED_view3d_autodist_depth_seg(ARegion *ar, const int mval_sta[2], const int m return (*depth == FLT_MAX) ? 0 : 1; } +float ED_view3d_offset_distance(float mat[4][4], float ofs[3]) { + float pos[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + float dir[4] = {0.0f, 0.0f, 1.0f, 0.0f}; + + mul_m4_v4(mat, pos); + add_v3_v3(pos, ofs); + mul_m4_v4(mat, dir); + normalize_v3(dir); + + return dot_v3v3(pos, dir); +} + /** * Set the view transformation from a 4x4 matrix. * diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index cd358dea869..5aee90f0860 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -27,7 +27,7 @@ /* defines VIEW3D_OT_fly modal operator */ //#define NDOF_FLY_DEBUG -//#define NDOF_FLY_DRAW_TOOMUCH // is this needed for ndof? - commented so redraw doesnt thrash - campbell +//#define NDOF_FLY_DRAW_TOOMUCH /* is this needed for ndof? - commented so redraw doesnt thrash - campbell */ #include "DNA_anim_types.h" #include "DNA_scene_types.h" #include "DNA_object_types.h" @@ -426,7 +426,6 @@ static int flyEnd(bContext *C, FlyInfo *fly) ED_region_draw_cb_exit(fly->ar->type, fly->draw_handle_pixel); rv3d->dist = fly->dist_backup; - if (fly->state == FLY_CANCEL) { /* Revert to original view? */ if (fly->persp_backup == RV3D_CAMOB) { /* a camera view */ @@ -441,12 +440,16 @@ static int flyEnd(bContext *C, FlyInfo *fly) else { /* Non Camera we need to reset the view back to the original location bacause the user canceled*/ copy_qt_qt(rv3d->viewquat, fly->rot_backup); - copy_v3_v3(rv3d->ofs, fly->ofs_backup); rv3d->persp = fly->persp_backup; } + /* always, is set to zero otherwise */ + copy_v3_v3(rv3d->ofs, fly->ofs_backup); } else if (fly->persp_backup == RV3D_CAMOB) { /* camera */ DAG_id_tag_update(fly->root_parent ? &fly->root_parent->id : &v3d->camera->id, OB_RECALC_OB); + + /* always, is set to zero otherwise */ + copy_v3_v3(rv3d->ofs, fly->ofs_backup); } else { /* not camera */ @@ -553,7 +556,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) time_wheel = (float)(time_currwheel - fly->time_lastwheel); fly->time_lastwheel = time_currwheel; /* Mouse wheel delays range from (0.5 == slow) to (0.01 == fast) */ - time_wheel = 1.0f + (10.0f - (20.0f * minf(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */ + time_wheel = 1.0f + (10.0f - (20.0f * min_ff(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */ if (fly->speed < 0.0f) { fly->speed = 0.0f; @@ -571,7 +574,7 @@ static void flyEvent(FlyInfo *fly, wmEvent *event) time_currwheel = PIL_check_seconds_timer(); time_wheel = (float)(time_currwheel - fly->time_lastwheel); fly->time_lastwheel = time_currwheel; - time_wheel = 1.0f + (10.0f - (20.0f * minf(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */ + time_wheel = 1.0f + (10.0f - (20.0f * min_ff(time_wheel, 0.5f))); /* 0-0.5 -> 0-5.0 */ if (fly->speed > 0.0f) { fly->speed = 0; @@ -795,8 +798,8 @@ static int flyApply(bContext *C, FlyInfo *fly) ymargin = ar->winy / 20.0f; // UNUSED - // cent_orig[0]= ar->winrct.xmin + ar->winx/2; - // cent_orig[1]= ar->winrct.ymin + ar->winy/2; + // cent_orig[0] = ar->winrct.xmin + ar->winx / 2; + // cent_orig[1] = ar->winrct.ymin + ar->winy / 2; { @@ -847,7 +850,7 @@ static int flyApply(bContext *C, FlyInfo *fly) #endif time_current = PIL_check_seconds_timer(); time_redraw = (float)(time_current - fly->time_lastdraw); - time_redraw_clamped = minf(0.05f, time_redraw); /* clamp redraw time to avoid jitter in roll correction */ + time_redraw_clamped = min_ff(0.05f, time_redraw); /* clamp redraw time to avoid jitter in roll correction */ fly->time_lastdraw = time_current; /* Scale the time to use shift to scale the speed down- just like diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index b2ae63df662..d8fcc7e12e7 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -167,7 +167,7 @@ static int view3d_layers_exec(bContext *C, wmOperator *op) } else { v3d->lay |= (1 << 20) - 1; - } + } } else { int bit; @@ -452,7 +452,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C) const float dpi_fac = UI_DPI_FAC; int is_paint = 0; - RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr); + RNA_pointer_create(&screen->id, &RNA_SpaceView3D, v3d, &v3dptr); RNA_pointer_create(&scene->id, &RNA_ToolSettings, ts, &toolsptr); RNA_pointer_create(&scene->id, &RNA_Scene, scene, &sceneptr); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 3017891183e..5beeda9f220 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -177,7 +177,7 @@ int ED_view3d_boundbox_clip(RegionView3D * rv3d, float obmat[][4], struct BoundB void view3d_smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *, float *ofs, float *quat, float *dist, float *lens); -void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */ +void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d); void fly_modal_keymap(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/space_view3d/view3d_iterators.c b/source/blender/editors/space_view3d/view3d_iterators.c index 0472f9f2c10..b928e060ca0 100644 --- a/source/blender/editors/space_view3d/view3d_iterators.c +++ b/source/blender/editors/space_view3d/view3d_iterators.c @@ -130,11 +130,12 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, const flo if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) { float screen_co_a[2]; float screen_co_b[2]; + eV3DProjTest clip_flag_nowin = data->clip_flag &= ~V3D_PROJ_TEST_CLIP_WIN; - if (ED_view3d_project_float_object(data->vc.ar, v0co, screen_co_a, data->clip_flag) != V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object(data->vc.ar, v0co, screen_co_a, clip_flag_nowin) != V3D_PROJ_RET_OK) { return; } - if (ED_view3d_project_float_object(data->vc.ar, v1co, screen_co_b, data->clip_flag) != V3D_PROJ_RET_OK) { + if (ED_view3d_project_float_object(data->vc.ar, v1co, screen_co_b, clip_flag_nowin) != V3D_PROJ_RET_OK) { return; } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index c30adf844a8..43626b058d6 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -165,7 +165,7 @@ void view3d_get_transformation(const ARegion *ar, RegionView3D *rv3d, Object *ob mats->viewport[0] = ar->winrct.xmin; mats->viewport[1] = ar->winrct.ymin; mats->viewport[2] = ar->winx; - mats->viewport[3] = ar->winy; + mats->viewport[3] = ar->winy; } /* ********************** view3d_select: selection manipulations ********************* */ @@ -2359,7 +2359,7 @@ static void paint_facesel_circle_select(ViewContext *vc, int select, const int m if (me) { bm_vertoffs = me->totpoly + 1; /* max index array */ - /* bbsel= */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); + /* bbsel = */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); edbm_backbuf_check_and_select_tfaces(me, select == LEFTMOUSE); EDBM_backbuf_free(); paintface_flush_flags(ob); @@ -2376,7 +2376,7 @@ static void paint_vertsel_circle_select(ViewContext *vc, int select, const int m if (me) { bm_vertoffs = me->totvert + 1; /* max index array */ - /* bbsel= */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); + /* bbsel = */ /* UNUSED */ EDBM_backbuf_circle_init(vc, mval[0], mval[1], (short)(rad + 1.0f)); edbm_backbuf_check_and_select_verts_obmode(me, select == LEFTMOUSE); EDBM_backbuf_free(); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index e55e97e501b..9517bc87721 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -233,7 +233,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod BMesh *bm = em->bm; BMIter iter; void *userdata[2] = {em, NULL}; - /*int proptrans= 0; */ /*UNUSED*/ + /*int proptrans = 0; */ /*UNUSED*/ /* abuses vertex index all over, set, just set dirty here, * perhaps this could use its own array instead? - campbell */ @@ -349,7 +349,7 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod tv->flag = 1; tv++; tottrans++; - } + } if ((mode & TM_ALL_JOINTS) && (tipsel)) { copy_v3_v3(tv->oldloc, ebo->tail); diff --git a/source/blender/editors/space_view3d/view3d_toolbar.c b/source/blender/editors/space_view3d/view3d_toolbar.c index b40e880591a..d36b0085acb 100644 --- a/source/blender/editors/space_view3d/view3d_toolbar.c +++ b/source/blender/editors/space_view3d/view3d_toolbar.c @@ -173,7 +173,7 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) search[0] = 0; block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_SEARCH_MENU); /* fake button, it holds space for search items */ uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); @@ -182,7 +182,7 @@ static uiBlock *tool_search_menu(bContext *C, ARegion *ar, void *arg_listbase) uiButSetSearchFunc(but, operator_search_cb, arg_listbase, operator_call_cb, NULL); uiBoundsBlock(block, 6); - uiBlockSetDirection(block, UI_DOWN); + uiBlockSetDirection(block, UI_DOWN); uiEndBlock(C, block); event = *(win->eventstate); /* XXX huh huh? make api call */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index de8cbd856e8..c16f04f01f3 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -161,6 +161,7 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera if (lens) sms.new_lens = *lens; if (camera) { + sms.new_dist = ED_view3d_offset_distance(camera->obmat, ofs); ED_view3d_from_object(camera, sms.new_ofs, sms.new_quat, &sms.new_dist, &sms.new_lens); sms.to_camera = TRUE; /* restore view3d values in end */ } @@ -185,7 +186,7 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera /* original values */ if (oldcamera) { - sms.orig_dist = rv3d->dist; /* below function does weird stuff with it... */ + sms.orig_dist = ED_view3d_offset_distance(oldcamera->obmat, rv3d->ofs); ED_view3d_from_object(oldcamera, sms.orig_ofs, sms.orig_quat, &sms.orig_dist, &sms.orig_lens); } else { @@ -657,7 +658,10 @@ int ED_view3d_viewplane_get(View3D *v3d, RegionView3D *rv3d, int winx, int winy, return params.is_ortho; } -void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for picking */ +/*! + * \param rect for picking, NULL not to use. + */ +void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) { RegionView3D *rv3d = ar->regiondata; rctf viewplane; @@ -690,7 +694,7 @@ void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect) /* rect: for if (orth) wmOrtho(rect->xmin, rect->xmax, rect->ymin, rect->ymax, -clipend, clipend); else wmFrustum(rect->xmin, rect->xmax, rect->ymin, rect->ymax, clipsta, clipend); - + } else { if (orth) wmOrtho(x1, x2, y1, y2, clipsta, clipend); @@ -786,7 +790,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) { if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */ if (v3d->camera) { - BKE_object_where_is_calc(scene, v3d->camera); + BKE_object_where_is_calc(scene, v3d->camera); obmat_to_viewmat(v3d, rv3d, v3d->camera, 0); } else { @@ -891,8 +895,8 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b glLoadName(code); draw_object(scene, ar, v3d, base, DRAW_PICKING | DRAW_CONSTCOLOR); - /* we draw group-duplicators for selection too */ - if ((base->object->transflag & OB_DUPLI) && base->object->dup_group) { + /* we draw duplicators for selection too */ + if ((base->object->transflag & OB_DUPLI)) { ListBase *lb; DupliObject *dob; Base tbase; @@ -919,7 +923,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b free_object_duplilist(lb); } code++; - } + } } } v3d->xray = FALSE; /* restore */ @@ -1037,7 +1041,7 @@ static int view3d_localview_init(Main *bmain, Scene *scene, ScrArea *sa, ReportL locallay = free_localbit(bmain); if (locallay == 0) { - BKE_reportf(reports, RPT_ERROR, "No more than 8 local views"); + BKE_report(reports, RPT_ERROR, "No more than 8 local views"); ok = FALSE; } else { @@ -1192,7 +1196,7 @@ static int view3d_localview_exit(Main *bmain, Scene *scene, ScrArea *sa) DAG_on_visible_update(bmain, FALSE); return TRUE; - } + } else { return FALSE; } @@ -1265,12 +1269,12 @@ static void RestoreState(bContext *C, wmWindow *win) GPU_paint_set_mipmap(0); //XXX curarea->win_swap = 0; - //XXX curarea->head_swap=0; + //XXX curarea->head_swap = 0; //XXX allqueue(REDRAWVIEW3D, 1); //XXX allqueue(REDRAWBUTSALL, 0); //XXX reset_slowparents(); //XXX waitcursor(0); - //XXX G.qual= 0; + //XXX G.qual = 0; if (win) /* check because closing win can set to NULL */ win->queue = queue_back; @@ -1395,7 +1399,7 @@ static int game_engine_exec(bContext *C, wmOperator *op) WM_redraw_windows(C); rv3d = CTX_wm_region_view3d(C); - /* sa= CTX_wm_area(C); */ /* UNUSED */ + /* sa = CTX_wm_area(C); */ /* UNUSED */ ar = CTX_wm_region(C); view3d_operator_needs_opengl(C); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 4a61978cc80..1537b4f61ce 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -277,7 +277,7 @@ void projectIntView(TransInfo *t, const float vec[3], int adr[2]) //vec[0] = vec[0]/((t->scene->r.frs_sec / t->scene->r.frs_sec_base)); /* same as below */ UI_view2d_to_region_no_clip((View2D *)t->view, vec[0], vec[1], out, out + 1); - } + } else #endif { @@ -469,11 +469,11 @@ static void viewRedrawForce(const bContext *C, TransInfo *t) } else if (t->spacetype == SPACE_ACTION) { - //SpaceAction *saction= (SpaceAction *)t->sa->spacedata.first; + //SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } else if (t->spacetype == SPACE_IPO) { - //SpaceIpo *sipo= (SpaceIpo *)t->sa->spacedata.first; + //SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } else if (t->spacetype == SPACE_NLA) { @@ -1020,7 +1020,7 @@ int transformEvent(TransInfo *t, wmEvent *event) if (t->flag & T_PROP_EDIT) { t->prop_size *= 1.1f; if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) - t->prop_size = minf(t->prop_size, ((View3D *)t->view)->far); + t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->far); calculatePropRatio(t); } t->redraw |= TREDRAW_HARD; @@ -1190,7 +1190,7 @@ int transformEvent(TransInfo *t, wmEvent *event) if (event->alt && t->flag & T_PROP_EDIT) { t->prop_size *= 1.1f; if (t->spacetype == SPACE_VIEW3D && t->persp != RV3D_ORTHO) - t->prop_size = minf(t->prop_size, ((View3D *)t->view)->far); + t->prop_size = min_ff(t->prop_size, ((View3D *)t->view)->far); calculatePropRatio(t); } t->redraw = 1; @@ -1264,6 +1264,8 @@ int transformEvent(TransInfo *t, wmEvent *event) } } } + else + handled = 0; // Per transform event, if present if (t->handleEvent) @@ -1484,8 +1486,8 @@ static void drawHelpline(bContext *UNUSED(C), int x, int y, void *customdata) float dx = t->mval[0] - cent[0], dy = t->mval[1] - cent[1]; float angle = atan2f(dy, dx); float dist = sqrtf(dx * dx + dy * dy); - float delta_angle = minf(15.0f / dist, (float)M_PI / 4.0f); - float spacing_angle = minf(5.0f / dist, (float)M_PI / 12.0f); + float delta_angle = min_ff(15.0f / dist, (float)M_PI / 4.0f); + float spacing_angle = min_ff(5.0f / dist, (float)M_PI / 12.0f); UI_ThemeColor(TH_WIRE); setlinestyle(3); @@ -1598,8 +1600,10 @@ static void drawTransformPixel(const struct bContext *UNUSED(C), ARegion *ar, vo */ if ((U.autokey_flag & AUTOKEY_FLAG_NOWARNING) == 0) { if (ar == t->ar) { - if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) { - drawAutoKeyWarning(t, ar); + if (t->flag & (T_OBJECT | T_POSE)) { + if (ob && autokeyframe_cfra_can_key(scene, &ob->id)) { + drawAutoKeyWarning(t, ar); + } } } } @@ -3383,7 +3387,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short /* this function works on end result */ protectedAxisAngleBits(td->protectflag, td->ext->rotAxis, td->ext->rotAngle, td->ext->irotAxis, td->ext->irotAngle); } - else { + else { float eulmat[3][3]; mul_m3_m3m3(totmat, mat, td->ext->r_mtx); @@ -4811,7 +4815,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l, } l = l->radial_next; - } while (l != firstl); + } while (l != firstl); if (i) mul_v3_fl(a, 1.0f / (float)i); @@ -5612,7 +5616,7 @@ static int doEdgeSlide(TransInfo *t, float perc) for (i = 0; i < sld->totsv; i++, sv++) { const float sv_length = len_v3v3(sv->up->co, sv->down->co); - const float fac = minf(sv_length, curr_length_perc) / sv_length; + const float fac = min_ff(sv_length, curr_length_perc) / sv_length; if (sld->flipped_vtx) { interp_v3_v3v3(sv->v->co, sv->down->co, sv->up->co, fac); @@ -6108,7 +6112,7 @@ static short getAnimEdit_DrawTime(TransInfo *t) SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; drawtime = (sipo->flag & SIPO_DRAWTIME) ? 1 : 0; - } + } else { drawtime = 0; } @@ -6589,5 +6593,5 @@ int TimeScale(TransInfo *t, const int UNUSED(mval[2])) void BIF_TransformSetUndo(const char *UNUSED(str)) { // TRANSFORM_FIX_ME - //Trans.undostr= str; + //Trans.undostr = str; } diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 0aa46a36afe..311cb5ee94d 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -782,7 +782,7 @@ void startConstraint(TransInfo *t) { t->con.mode |= CON_APPLY; *t->con.text = ' '; - t->num.idx_max = MIN2(getConstraintSpaceDimension(t) - 1, t->idx_max); + t->num.idx_max = min_ii(getConstraintSpaceDimension(t) - 1, t->idx_max); } void stopConstraint(TransInfo *t) diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 2e9d1ee670f..53cedc78d5c 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -76,6 +76,7 @@ #include "BKE_gpencil.h" #include "BKE_key.h" #include "BKE_main.h" +#include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_movieclip.h" #include "BKE_nla.h" @@ -124,62 +125,46 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list); /* ************************** Functions *************************** */ -static void qsort_trans_data(TransInfo *t, TransData *head, TransData *tail, TransData *temp) +static int trans_data_compare_dist(const void *A, const void *B) { - TransData *ihead = head; - TransData *itail = tail; - *temp = *head; + const TransData *td_A = (const TransData*)A; + const TransData *td_B = (const TransData*)B; - while (head < tail) { - if (t->flag & T_PROP_CONNECTED) { - while ((tail->dist >= temp->dist) && (head < tail)) - tail--; - } - else { - while ((tail->rdist >= temp->rdist) && (head < tail)) - tail--; - } - - if (head != tail) { - *head = *tail; - head++; - } - - if (t->flag & T_PROP_CONNECTED) { - while ((head->dist <= temp->dist) && (head < tail)) - head++; - } - else { - while ((head->rdist <= temp->rdist) && (head < tail)) - head++; - } + if(td_A->dist < td_B->dist) + return -1; + else if(td_A->dist > td_B->dist) + return 1; + + return 0; +} - if (head != tail) { - *tail = *head; - tail--; - } - } +static int trans_data_compare_rdist(const void *A, const void *B) +{ + const TransData *td_A = (const TransData*)A; + const TransData *td_B = (const TransData*)B; - *head = *temp; - if (ihead < head) { - qsort_trans_data(t, ihead, head - 1, temp); - } - if (itail > head) { - qsort_trans_data(t, head + 1, itail, temp); - } + if(td_A->rdist < td_B->rdist) + return -1; + else if(td_A->rdist > td_B->rdist) + return 1; + + return 0; } void sort_trans_data_dist(TransInfo *t) { - TransData temp; TransData *start = t->data; - int i = 1; + int i; - while (i < t->total && start->flag & TD_SELECTED) { + for (i = 0; i < t->total && start->flag & TD_SELECTED; i++) start++; - i++; + + if (i < t->total) { + if (t->flag & T_PROP_CONNECTED) + qsort(start, t->total - i, sizeof(TransData), trans_data_compare_dist); + else + qsort(start, t->total - i, sizeof(TransData), trans_data_compare_rdist); } - qsort_trans_data(t, start, t->data + t->total - 1, &temp); } static void sort_trans_data(TransInfo *t) @@ -332,7 +317,7 @@ static void createTransEdge(TransInfo *t) invert_m3_m3(smtx, mtx); BM_ITER_MESH (eed, &iter, em->bm, BM_EDGES_OF_MESH) { - if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && (BM_elem_flag_test(eed, BM_ELEM_SELECT) || propmode)) { + if (!BM_elem_flag_test(eed, BM_ELEM_HIDDEN) && (BM_elem_flag_test(eed, BM_ELEM_SELECT) || propmode)) { float *bweight = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_BWEIGHT); float *crease = CustomData_bmesh_get(&em->bm->edata, eed->head.data, CD_CREASE); @@ -419,7 +404,7 @@ static short apply_targetless_ik(Object *ob) float rmat[4][4] /*, tmat[4][4], imat[4][4]*/; /* pose_mat(b) = pose_mat(b-1) * offs_bone * channel * constraint * IK */ - /* we put in channel the entire result of rmat= (channel * constraint * IK) */ + /* we put in channel the entire result of rmat = (channel * constraint * IK) */ /* pose_mat(b) = pose_mat(b-1) * offs_bone * rmat */ /* rmat = pose_mat(b) * inv(pose_mat(b-1) * offs_bone ) */ @@ -850,7 +835,7 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) con = add_pose_constraint(NULL, pchan, "TempConstraint", CONSTRAINT_TYPE_KINEMATIC); pchan->constflag |= (PCHAN_HAS_IK | PCHAN_HAS_TARGET); /* for draw, but also for detecting while pose solving */ data = con->data; - if (targetless) { + if (targetless) { /* if exists, use values from last targetless (but disabled) IK-constraint as base */ *data = *targetless; } @@ -973,7 +958,7 @@ static void createTransPose(TransInfo *t, Object *ob) if (arm->flag & ARM_RESTPOS) { if (ELEM(t->mode, TFM_DUMMY, TFM_BONESIZE) == 0) { // XXX use transform operator reports - // BKE_report(op->reports, RPT_ERROR, "Can't select linked when sync selection is enabled"); + // BKE_report(op->reports, RPT_ERROR, "Cannot select linked when sync selection is enabled"); return; } } @@ -1830,7 +1815,7 @@ static void editmesh_set_connectivity_distance(BMEditMesh *em, float mtx[][3], f d2 = d + len_v3(vec); if (dists[BM_elem_index_get(v3)] != FLT_MAX) - dists[BM_elem_index_get(v3)] = minf(d2, dists[BM_elem_index_get(v3)]); + dists[BM_elem_index_get(v3)] = min_ff(d2, dists[BM_elem_index_get(v3)]); else dists[BM_elem_index_get(v3)] = d2; @@ -2359,6 +2344,7 @@ static void createTransUVs(bContext *C, TransInfo *t) SpaceImage *sima = CTX_wm_space_image(C); Image *ima = CTX_data_edit_image(C); Scene *scene = t->scene; + ToolSettings *ts = CTX_data_tool_settings(C); TransData *td = NULL; TransData2D *td2d = NULL; MTexPoly *tf; @@ -2367,12 +2353,26 @@ static void createTransUVs(bContext *C, TransInfo *t) BMFace *efa; BMLoop *l; BMIter iter, liter; - int count = 0, countsel = 0; + UvElementMap *elementmap; + char *island_enabled; + int count = 0, countsel = 0, count_rejected = 0; int propmode = t->flag & T_PROP_EDIT; + int propconnected = t->flag & T_PROP_CONNECTED; if (!ED_space_image_show_uvedit(sima, t->obedit)) return; /* count */ + if (propconnected) { + /* create element map with island information */ + if (ts->uv_flag & UV_SYNC_SELECTION) { + elementmap = EDBM_uv_element_map_create (em, FALSE, TRUE); + } + else { + elementmap = EDBM_uv_element_map_create (em, TRUE, TRUE); + } + island_enabled = MEM_callocN(sizeof(*island_enabled) * elementmap->totalIslands, "TransIslandData(UV Editing)"); + } + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); @@ -2380,14 +2380,22 @@ static void createTransUVs(bContext *C, TransInfo *t) BM_elem_flag_disable(efa, BM_ELEM_TAG); continue; } - + BM_elem_flag_enable(efa, BM_ELEM_TAG); BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { - if (uvedit_uv_select_test(em, scene, l)) + if (uvedit_uv_select_test(em, scene, l)) { countsel++; - if (propmode) + if (propconnected) { + UvElement *element = ED_uv_element_get(elementmap, efa, l); + island_enabled[element->island] = TRUE; + } + + } + + if (propmode) { count++; + } } } @@ -2413,12 +2421,26 @@ static void createTransUVs(bContext *C, TransInfo *t) BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { if (!propmode && !uvedit_uv_select_test(em, scene, l)) continue; + + if (propconnected) { + UvElement *element = ED_uv_element_get(elementmap, efa, l); + if (!island_enabled[element->island]) { + count_rejected++; + continue; + } + } luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV); UVsToTransData(sima, td++, td2d++, luv->uv, uvedit_uv_select_test(em, scene, l)); } } + if (propconnected) { + t->total -= count_rejected; + EDBM_uv_element_map_free(elementmap); + MEM_freeN(island_enabled); + } + if (sima->flag & SI_LIVE_UNWRAP) ED_uvedit_live_unwrap_begin(t->scene, t->obedit); } @@ -2510,8 +2532,8 @@ void clipUVData(TransInfo *t) if ((td->flag & TD_SKIP) || (!td->loc)) continue; - td->loc[0] = minf(maxf(0.0f, td->loc[0]), aspx); - td->loc[1] = minf(maxf(0.0f, td->loc[1]), aspy); + td->loc[0] = min_ff(max_ff(0.0f, td->loc[0]), aspx); + td->loc[1] = min_ff(max_ff(0.0f, td->loc[1]), aspy); } } @@ -3416,14 +3438,14 @@ static void bezt_to_transdata(TransData *td, TransData2D *td2d, AnimData *adt, B if (td->flag & TD_MOVEHANDLE1) { td2d->h1 = bezt->vec[0]; copy_v2_v2(td2d->ih1, td2d->h1); - } - else + } + else td2d->h1 = NULL; if (td->flag & TD_MOVEHANDLE2) { td2d->h2 = bezt->vec[2]; copy_v2_v2(td2d->ih2, td2d->h2); - } + } else td2d->h2 = NULL; @@ -3527,7 +3549,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) if (sel1) count++; if (sel3) count++; } - } + } else if (sipo->around == V3D_LOCAL) { /* for local-pivot we only need to count the number of selected handles only, so that centerpoints don't * don't get moved wrong @@ -3622,18 +3644,18 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) if (sel1) { hdata = initTransDataCurveHandles(td, bezt); bezt_to_transdata(td++, td2d++, adt, bezt, 0, 1, 1, intvals, mtx, smtx); - } + } else { - /* h1= 0; */ /* UNUSED */ + /* h1 = 0; */ /* UNUSED */ } if (sel3) { if (hdata == NULL) hdata = initTransDataCurveHandles(td, bezt); bezt_to_transdata(td++, td2d++, adt, bezt, 2, 1, 1, intvals, mtx, smtx); - } + } else { - /* h2= 0; */ /* UNUSED */ + /* h2 = 0; */ /* UNUSED */ } } @@ -4263,7 +4285,7 @@ static void freeSeqData(TransInfo *t) for (a = 0; a < t->total; a++, td++) { seq = ((TransDataSeq *)td->extra)->seq; if ((seq != seq_prev)) { - minframe = mini(minframe, seq->startdisp); + minframe = min_ii(minframe, seq->startdisp); } } @@ -4469,6 +4491,7 @@ static short constraints_list_needinv(TransInfo *t, ListBase *list) if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) return 1; if (con->type == CONSTRAINT_TYPE_CLAMPTO) return 1; if (con->type == CONSTRAINT_TYPE_OBJECTSOLVER) return 1; + if (con->type == CONSTRAINT_TYPE_FOLLOWTRACK) return 1; /* constraints that require this only under special conditions */ if (con->type == CONSTRAINT_TYPE_ROTLIKE) { @@ -4545,7 +4568,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) td->ext->irotAngle = ob->rotAngle; copy_v3_v3(td->ext->irotAxis, ob->rotAxis); - // td->ext->drotAngle= ob->drotAngle; // XXX, not implemented + // td->ext->drotAngle = ob->drotAngle; // XXX, not implemented // copy_v3_v3(td->ext->drotAxis, ob->drotAxis); // XXX, not implemented } else { @@ -4603,7 +4626,7 @@ static void set_trans_object_base_flags(TransInfo *t) /* * if Base selected and has parent selected: - * base->flag= BA_WAS_SEL + * base->flag = BA_WAS_SEL */ Base *base; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index a9d9ec7b010..f550cb05a8b 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -705,7 +705,7 @@ static void recalcData_view3d(TransInfo *t) BKE_nurb_handles_calc(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */ nu = nu->next; } - } + } else { /* Normal updating */ while (nu) { @@ -1002,9 +1002,9 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) /* moving: is shown in drawobject() (transform color) */ // TRANSFORM_FIX_ME -// if (obedit || (t->flag & T_POSE) ) G.moving= G_TRANSFORM_EDIT; -// else if (G.f & G_PARTICLEEDIT) G.moving= G_TRANSFORM_PARTICLE; -// else G.moving= G_TRANSFORM_OBJ; +// if (obedit || (t->flag & T_POSE) ) G.moving = G_TRANSFORM_EDIT; +// else if (G.f & G_PARTICLEEDIT) G.moving = G_TRANSFORM_PARTICLE; +// else G.moving = G_TRANSFORM_OBJ; t->scene = sce; t->sa = sa; @@ -1252,7 +1252,7 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) /* TRANSFORM_FIX_ME rna restrictions */ if (t->prop_size <= 0.00001f) { - printf("Proportional size (%f) under 0.00001, reseting to 1!\n", t->prop_size); + printf("Proportional size (%f) under 0.00001, resetting to 1!\n", t->prop_size); t->prop_size = 1.0f; } @@ -1712,8 +1712,9 @@ void calculatePropRatio(TransInfo *t) /* * The elements are sorted according to their dist member in the array, * that means we can stop when it finds one element outside of the propsize. + * do not set td->flag |= TD_NOACTION , the prop circle is being changed. */ - td->flag |= TD_NOACTION; + td->factor = 0.0f; restoreElement(td); } diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 74a2292d74c..0780b8f90b5 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -441,7 +441,7 @@ int calc_manipulator_stats(const bContext *C) } else if (obedit->type == OB_MBALL) { MetaBall *mb = (MetaBall *)obedit->data; - MetaElem *ml /* , *ml_sel=NULL */ /* UNUSED */; + MetaElem *ml /* , *ml_sel = NULL */ /* UNUSED */; ml = mb->editelems->first; while (ml) { @@ -498,7 +498,7 @@ int calc_manipulator_stats(const bContext *C) } } else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) { - ; + /* pass */ } else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) { PTCacheEdit *edit = PE_get_current(scene, ob); diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index fc0c174a525..916cf540589 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -284,7 +284,7 @@ static int create_orientation_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "name", name); if (use && !CTX_wm_view3d(C)) { - BKE_report(op->reports, RPT_ERROR, "Create Orientation \"use\" parameter only valid in a 3dView context"); + BKE_report(op->reports, RPT_ERROR, "Create Orientation's 'use' parameter only valid in a 3DView context"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 845d5b73f0c..70e4d4cd027 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -142,7 +142,7 @@ TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(reports) strncpy(name, ob->id.name + 2, MAX_ID_NAME - 2); } - return addMatrixSpace(C, mat, name, overwrite); + return addMatrixSpace(C, mat, name, overwrite); } TransformOrientation *createBoneSpace(bContext *C, ReportList *reports, char *name, int overwrite) diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 94b8abb8850..baca4629883 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -723,14 +723,14 @@ static float RotationBetween(TransInfo *t, float p1[3], float p2[3]) { float angle, start[3], end[3], center[3]; - copy_v3_v3(center, t->center); + copy_v3_v3(center, t->center); if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, center); } sub_v3_v3v3(start, p1, center); - sub_v3_v3v3(end, p2, center); + sub_v3_v3v3(end, p2, center); // Angle around a constraint axis (error prone, will need debug) if (t->con.applyRot != NULL && (t->con.mode & CON_APPLY)) { @@ -779,7 +779,7 @@ static float ResizeBetween(TransInfo *t, float p1[3], float p2[3]) { float d1[3], d2[3], center[3], len_d1; - copy_v3_v3(center, t->center); + copy_v3_v3(center, t->center); if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; mul_m4_v3(ob->obmat, center); @@ -846,7 +846,7 @@ static void CalcSnapGeometry(TransInfo *t, float *UNUSED(vec)) p2 = NULL; p1->flag = 1; - /* if peeling objects, take the first and last from each object */ + /* if peeling objects, take the first and last from each object */ if (t->settings->snap_flag & SCE_SNAP_PEEL_OBJECT) { DepthPeel *peel; for (peel = p1->next; peel; peel = peel->next) { @@ -982,7 +982,7 @@ static void TargetSnapCenter(TransInfo *t) { /* Only need to calculate once */ if ((t->tsnap.status & TARGET_INIT) == 0) { - copy_v3_v3(t->tsnap.snapTarget, t->center); + copy_v3_v3(t->tsnap.snapTarget, t->center); if (t->flag & (T_EDIT | T_POSE)) { Object *ob = t->obedit ? t->obedit : t->poseobj; @@ -991,7 +991,7 @@ static void TargetSnapCenter(TransInfo *t) TargetSnapOffset(t, NULL); - t->tsnap.status |= TARGET_INIT; + t->tsnap.status |= TARGET_INIT; } } @@ -1027,7 +1027,7 @@ static void TargetSnapActive(TransInfo *t) t->tsnap.target = SCE_SNAP_TARGET_MEDIAN; t->tsnap.targetSnap = TargetSnapMedian; TargetSnapMedian(t); - } + } } } @@ -1055,7 +1055,7 @@ static void TargetSnapMedian(TransInfo *t) TargetSnapOffset(t, NULL); - t->tsnap.status |= TARGET_INIT; + t->tsnap.status |= TARGET_INIT; } } @@ -1166,7 +1166,7 @@ static int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], fl mul_m4_v3(obmat, location); - new_depth = len_v3v3(location, ray_start); + new_depth = len_v3v3(location, ray_start); ED_view3d_project_int(ar, location, screen_loc); new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]); @@ -1182,7 +1182,7 @@ static int snapFace(ARegion *ar, float v1co[3], float v2co[3], float v3co[3], fl normalize_v3(no); *dist = new_dist; - } + } } return retval; @@ -1234,7 +1234,7 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh mul_m4_v3(obmat, location); - new_depth = len_v3v3(location, ray_start); + new_depth = len_v3v3(location, ray_start); if (ED_view3d_project_int_global(ar, location, screen_loc, V3D_PROJ_TEST_NOP) == V3D_PROJ_RET_OK) { new_dist = abs(screen_loc[0] - (int)mval[0]) + abs(screen_loc[1] - (int)mval[1]); @@ -1259,17 +1259,17 @@ static int snapEdge(ARegion *ar, float v1co[3], short v1no[3], float v2co[3], sh mul = dot_v3v3(vec, edge_loc) / dot_v3v3(edge_loc, edge_loc); if (r_no) { - normal_short_to_float_v3(n1, v1no); + normal_short_to_float_v3(n1, v1no); normal_short_to_float_v3(n2, v2no); interp_v3_v3v3(r_no, n2, n1, mul); mul_m3_v3(timat, r_no); normalize_v3(r_no); - } + } copy_v3_v3(r_loc, location); *r_dist = new_dist; - } + } } } @@ -1318,7 +1318,7 @@ static int snapVertex(ARegion *ar, float vco[3], short vno[3], float obmat[][4], } *r_dist = new_dist; - } + } } return retval; @@ -1425,7 +1425,7 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh switch (snap_mode) { case SCE_SNAP_MODE_FACE: - { + { #ifdef USE_BVH_FACE_SNAP // Added for durian BVHTreeRayHit hit; BVHTreeFromMesh treeData; @@ -1858,7 +1858,7 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], mul_m4_v3(obmat, location); - new_depth = len_v3v3(location, ray_start); + new_depth = len_v3v3(location, ray_start); mul_m3_v3(timat, normal); normalize_v3(normal); @@ -1893,7 +1893,7 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], normalize_v3(normal); addDepthPeel(depth_peels, new_depth, location, normal, ob); - } + } } } } diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c index 9a3b0476205..c8c26ed771d 100644 --- a/source/blender/editors/util/editmode_undo.c +++ b/source/blender/editors/util/editmode_undo.c @@ -104,7 +104,7 @@ static UndoElem *curundo = NULL; static void undo_restore(UndoElem *undo, void *editdata, void *obdata) { if (undo) { - undo->to_editmode(undo->undodata, editdata, obdata); + undo->to_editmode(undo->undodata, editdata, obdata); } } @@ -233,7 +233,7 @@ static void undo_clean_stack(bContext *C) if (curundo == NULL) curundo = undobase.last; } -/* 1= an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */ +/* 1 = an undo, -1 is a redo. we have to make sure 'curundo' remains at current situation */ void undo_editmode_step(bContext *C, int step) { Object *obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c index 5eafc3e65a9..1753a564a3c 100644 --- a/source/blender/editors/util/undo.c +++ b/source/blender/editors/util/undo.c @@ -505,7 +505,7 @@ static int undo_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even MEM_freeN(item); uiPupMenuEnd(C, pup); - } + } } return OPERATOR_CANCELLED; diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 7aaae404d15..9c2c300c530 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -534,7 +534,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) { tf = CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_MTEXPOLY); - if (uvedit_face_visible_test(scene, ima, efa, tf)) { + if (uvedit_face_visible_test(scene, ima, efa, tf)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); } else { @@ -818,7 +818,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) bglVertex2fv(luv->uv); } } - bglEnd(); + bglEnd(); } glPointSize(1.0); diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h index 3a89d6ce892..b42875f20c2 100644 --- a/source/blender/editors/uvedit/uvedit_intern.h +++ b/source/blender/editors/uvedit/uvedit_intern.h @@ -72,7 +72,6 @@ void uv_find_nearest_edge(struct Scene *scene, struct Image *ima, struct BMEditM /* utility tool functions */ -struct UvElement *ED_uv_element_get(struct UvElementMap *map, struct BMFace *efa, struct BMLoop *l); void uvedit_live_unwrap_update(struct SpaceImage *sima, struct Scene *scene, struct Object *obedit); /* operators */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index acc69309a8c..4b008d9a30f 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -895,19 +895,6 @@ int ED_uvedit_nearest_uv(Scene *scene, Object *obedit, Image *ima, const float c return found; } -UvElement *ED_uv_element_get(UvElementMap *map, BMFace *efa, BMLoop *l) -{ - UvElement *element; - - element = map->vert[BM_elem_index_get(l->v)]; - - for (; element; element = element->next) - if (element->face == efa) - return element; - - return NULL; -} - /*********************** loop select ***********************/ static void select_edgeloop_uv_vertex_loop_flag(UvMapVert *first) @@ -1953,7 +1940,7 @@ static int mouse_select(bContext *C, const float co[2], int extend, int loop) } flush = 1; - } + } } } else { diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index f017394356e..5b6125b558b 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -1566,7 +1566,7 @@ static void p_vert_harmonic_insert(PVert *v) e = v->edge; do { - npoints++; + npoints++; e = p_wheel_edge_next(e); } while (e && (e != v->edge)); @@ -3306,7 +3306,7 @@ static void p_chart_stretch_minimize(PChart *chart, RNG *rng) trusted_radius /= 2 * nedges; - random_angle = rng_getFloat(rng) * 2.0f * (float)M_PI; + random_angle = BLI_rng_get_float(rng) * 2.0f * (float)M_PI; dir[0] = trusted_radius * cosf(random_angle); dir[1] = trusted_radius * sinf(random_angle); @@ -3988,7 +3988,7 @@ static void p_smooth(PChart *chart) diff[1] = p[1] - oldp[1]; length = sqrt(diff[0] * diff[0] + diff[1] * diff[1]); - d = MAX2(d, length); + d = max_ff(d, length); moved += length; } } @@ -4285,7 +4285,7 @@ void param_stretch_begin(ParamHandle *handle) param_assert(phandle->state == PHANDLE_STATE_CONSTRUCTED); phandle->state = PHANDLE_STATE_STRETCH; - phandle->rng = rng_new(31415926); + phandle->rng = BLI_rng_new(31415926); phandle->blend = 0.0f; for (i = 0; i < phandle->ncharts; i++) { @@ -4332,7 +4332,7 @@ void param_stretch_end(ParamHandle *handle) param_assert(phandle->state == PHANDLE_STATE_STRETCH); phandle->state = PHANDLE_STATE_CONSTRUCTED; - rng_free(phandle->rng); + BLI_rng_free(phandle->rng); phandle->rng = NULL; } @@ -4400,7 +4400,7 @@ void param_pack(ParamHandle *handle, float margin) if (margin > 0.0f) area += sqrt(box->w * box->h); - } + } if (margin > 0.0f) { /* multiply the margin by the area to give predictable results not dependent on UV scale, diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 2b225118472..b1945c37048 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -432,8 +432,8 @@ static void stitch_island_calculate_edge_rotation(UvEdge *edge, StitchState *sta edgesin = uv1[0] * uv2[1] - uv2[0] * uv1[1]; rotation = (edgesin > 0.0f) ? - +acosf(maxf(-1.0f, minf(1.0f, edgecos))) : - -acosf(maxf(-1.0f, minf(1.0f, edgecos))); + +acosf(max_ff(-1.0f, min_ff(1.0f, edgecos))) : + -acosf(max_ff(-1.0f, min_ff(1.0f, edgecos))); island_stitch_data[element1->island].num_rot_elements++; island_stitch_data[element1->island].rotation += rotation; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 19a1c4339ad..74d007e92c0 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -408,7 +408,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e smd.levels = scene->toolsettings->uv_subsurf_level; smd.subdivType = ME_CC_SUBSURF; - initialDerived = CDDM_from_BMEditMesh(em, NULL, 0, 0); + initialDerived = CDDM_from_editbmesh(em, FALSE, FALSE); derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd, NULL, SUBSURF_IN_EDIT_MODE); @@ -1436,8 +1436,8 @@ static void uv_map_mirror(BMEditMesh *em, BMFace *efa, MTexPoly *UNUSED(tf)) if (i != mi) { dx = uvs[mi][0] - uvs[i][0]; if (dx > 0.5f) uvs[i][0] += 1.0f; - } - } + } + } BLI_array_fixedstack_free(uvs); } diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index 1729ac06f5a..de83a717bce 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -162,18 +162,22 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], struct MFace *mface, struct MVert *mvert, int *face_indices, int totface); -void GPU_update_mesh_buffers(GPU_Buffers *buffers, struct MVert *mvert, - int *vert_indices, int totvert, const float *vmask); +void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, + int *vert_indices, int totvert, const float *vmask, + int (*face_vert_indices)[4], int show_diffuse_color); GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid, unsigned int **grid_hidden, int gridsize); void GPU_update_grid_buffers(GPU_Buffers *buffers, struct CCGElem **grids, const struct DMFlagMat *grid_flag_mats, - int *grid_indices, int totgrid, const struct CCGKey *key); + int *grid_indices, int totgrid, const struct CCGKey *key, + int show_diffuse_color); void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial); +int GPU_buffers_diffuse_changed(GPU_Buffers *buffers, int show_diffuse_color); + void GPU_free_buffers(GPU_Buffers *buffers); #endif diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 285acb6bdde..b26c25558c3 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -75,6 +75,8 @@ void GPU_end_object_materials(void); int GPU_enable_material(int nr, void *attribs); void GPU_disable_material(void); +void GPU_material_diffuse_get(int nr, float diff[4]); + void GPU_set_material_alpha_blend(int alphablend); int GPU_get_material_alpha_blend(void); @@ -122,7 +124,7 @@ void GPU_set_gpu_mipmapping(int gpu_mipmap); void GPU_paint_update_image(struct Image *ima, int x, int y, int w, int h); void GPU_update_images_framechange(void); int GPU_update_image_time(struct Image *ima, double time); -int GPU_verify_image(struct Image *ima, struct ImageUser *iuser, int tftile, int compare, int mipmap, int ncd); +int GPU_verify_image(struct Image *ima, struct ImageUser *iuser, int tftile, int compare, int mipmap, int isdata); void GPU_create_gl_tex(unsigned int *bind, unsigned int *pix, float *frect, int rectw, int recth, int mipmap, int use_hight_bit_depth, struct Image *ima); void GPU_create_gl_tex_compressed(unsigned int *bind, unsigned int *pix, int x, int y, int mipmap, struct Image *ima, struct ImBuf *ibuf); int GPU_upload_dxt_texture(struct ImBuf *ibuf); diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index f4bb5da0495..7eaa4084e61 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -111,7 +111,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, float * GPUTexture *GPU_texture_create_depth(int w, int h, char err_out[256]); GPUTexture *GPU_texture_create_vsm_shadow_map(int size, char err_out[256]); GPUTexture *GPU_texture_from_blender(struct Image *ima, - struct ImageUser *iuser, int ncd, double time, int mipmap); + struct ImageUser *iuser, int isdata, double time, int mipmap); void GPU_texture_free(GPUTexture *tex); void GPU_texture_ref(GPUTexture *tex); diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index baa557c3484..97e8b756d08 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -107,7 +107,7 @@ typedef struct GPUNodeStack { GPUNodeLink *GPU_attribute(int type, const char *name); GPUNodeLink *GPU_uniform(float *num); GPUNodeLink *GPU_dynamic_uniform(float *num, int dynamictype, void *data); -GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, int ncd); +GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser, int isdata); GPUNodeLink *GPU_texture(int size, float *pixels); GPUNodeLink *GPU_dynamic_texture(struct GPUTexture *tex, int dynamictype, void *data); GPUNodeLink *GPU_socket(GPUNodeStack *sock); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 2986ce85c88..3f04de91900 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -54,6 +54,7 @@ #include "DNA_userdef_types.h" #include "GPU_buffers.h" +#include "GPU_draw.h" typedef enum { GPU_BUFFER_VERTEX_STATE = 1, @@ -1316,6 +1317,9 @@ struct GPU_Buffers { /* The PBVH ensures that either all faces in the node are smooth-shaded or all faces are flat-shaded */ int smooth; + + int show_diffuse_color; + float diffuse_color[4]; }; typedef enum { VBO_ENABLED, @@ -1339,24 +1343,24 @@ static void gpu_colors_disable(VBO_State vbo_state) static float gpu_color_from_mask(float mask) { - return (1.0f - mask) * 0.5f + 0.25f; + return 1.0f - mask * 0.75f; } -static void gpu_color_from_mask_copy(float mask, unsigned char out[3]) +static void gpu_color_from_mask_copy(float mask, const float diffuse_color[4], unsigned char out[3]) { - unsigned char color; - - color = gpu_color_from_mask(mask) * 255.0f; + float mask_color; + + mask_color = gpu_color_from_mask(mask) * 255.0f; - out[0] = color; - out[1] = color; - out[2] = color; + out[0] = diffuse_color[0] * mask_color; + out[1] = diffuse_color[1] * mask_color; + out[2] = diffuse_color[2] * mask_color; } -static void gpu_color_from_mask_set(float mask) +static void gpu_color_from_mask_set(float mask, float diffuse_color[4]) { float color = gpu_color_from_mask(mask); - glColor3f(color, color, color); + glColor3f(diffuse_color[0] * color, diffuse_color[1] * color, diffuse_color[2] * color); } static float gpu_color_from_mask_quad(const CCGKey *key, @@ -1372,37 +1376,50 @@ static float gpu_color_from_mask_quad(const CCGKey *key, static void gpu_color_from_mask_quad_copy(const CCGKey *key, CCGElem *a, CCGElem *b, CCGElem *c, CCGElem *d, + const float *diffuse_color, unsigned char out[3]) { - unsigned char color = + float mask_color = gpu_color_from_mask((*CCG_elem_mask(key, a) + *CCG_elem_mask(key, b) + *CCG_elem_mask(key, c) + *CCG_elem_mask(key, d)) * 0.25f) * 255.0f; - out[0] = color; - out[1] = color; - out[2] = color; + out[0] = diffuse_color[0] * mask_color; + out[1] = diffuse_color[1] * mask_color; + out[2] = diffuse_color[2] * mask_color; } static void gpu_color_from_mask_quad_set(const CCGKey *key, CCGElem *a, CCGElem *b, - CCGElem *c, CCGElem *d) + CCGElem *c, CCGElem *d, + float diffuse_color[4]) { float color = gpu_color_from_mask_quad(key, a, b, c, d); - glColor3f(color, color, color); + glColor3f(diffuse_color[0] * color, diffuse_color[1] * color, diffuse_color[2] * color); } void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, - int *vert_indices, int totvert, const float *vmask) + int *vert_indices, int totvert, const float *vmask, + int (*face_vert_indices)[4], int show_diffuse_color) { VertexBufferFormat *vert_data; int i, j, k; buffers->vmask = vmask; + buffers->show_diffuse_color = show_diffuse_color; if (buffers->vert_buf) { int totelem = (buffers->smooth ? totvert : (buffers->tot_tri * 3)); + float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f}; + + if (buffers->show_diffuse_color) { + MFace *f = buffers->mface + buffers->face_indices[0]; + + GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color); + } + + copy_v4_v4(buffers->diffuse_color, diffuse_color); /* Build VBO */ glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); @@ -1423,11 +1440,27 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, copy_v3_v3(out->co, v->co); memcpy(out->no, v->no, sizeof(short) * 3); - if (vmask) { - gpu_color_from_mask_copy(vmask[vert_indices[i]], - out->color); - } } + +#define UPDATE_VERTEX(face, vertex, index, diffuse_color) \ + { \ + VertexBufferFormat *out = vert_data + face_vert_indices[face][index]; \ + if (vmask) \ + gpu_color_from_mask_copy(vmask[vertex], diffuse_color, out->color); \ + else \ + rgb_float_to_uchar(out->color, diffuse_color); \ + } (void)0 + + for (i = 0; i < buffers->totface; i++) { + MFace *f = buffers->mface + buffers->face_indices[i]; + + UPDATE_VERTEX(i, f->v1, 0, diffuse_color); + UPDATE_VERTEX(i, f->v2, 1, diffuse_color); + UPDATE_VERTEX(i, f->v3, 2, diffuse_color); + if (f->v4) + UPDATE_VERTEX(i, f->v4, 3, diffuse_color); + } +#undef UPDATE_VERTEX } else { for (i = 0; i < buffers->totface; ++i) { @@ -1439,6 +1472,9 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, float fmask; + if (paint_is_face_hidden(f, mvert)) + continue; + /* Face normal and mask */ if (f->v4) { normal_quad_v3(fno, @@ -1473,8 +1509,11 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, copy_v3_v3(out->co, v->co); memcpy(out->no, no, sizeof(short) * 3); + if (vmask) - gpu_color_from_mask_copy(fmask, out->color); + gpu_color_from_mask_copy(fmask, diffuse_color, out->color); + else + rgb_float_to_uchar(out->color, diffuse_color); vert_data++; } @@ -1508,6 +1547,8 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], buffers->index_type = GL_UNSIGNED_SHORT; buffers->smooth = mface[face_indices[0]].flag & ME_SMOOTH; + buffers->show_diffuse_color = FALSE; + /* Count the number of visible triangles */ for (i = 0, tottri = 0; i < totface; ++i) { const MFace *f = &mface[face_indices[i]]; @@ -1576,16 +1617,27 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids, const DMFlagMat *grid_flag_mats, int *grid_indices, - int totgrid, const CCGKey *key) + int totgrid, const CCGKey *key, int show_diffuse_color) { VertexBufferFormat *vert_data; int i, j, k, x, y; + buffers->show_diffuse_color = show_diffuse_color; + /* Build VBO */ if (buffers->vert_buf) { int totvert = key->grid_area * totgrid; int smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH; const int has_mask = key->has_mask; + float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f}; + + if (buffers->show_diffuse_color) { + const DMFlagMat *flags = &grid_flag_mats[grid_indices[0]]; + + GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color); + } + + copy_v4_v4(buffers->diffuse_color, diffuse_color); glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); glBufferDataARB(GL_ARRAY_BUFFER_ARB, @@ -1603,12 +1655,11 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids, copy_v3_v3(vd->co, CCG_elem_co(key, elem)); if (smooth) { - normal_float_to_short_v3(vd->no, - CCG_elem_no(key, elem)); + normal_float_to_short_v3(vd->no, CCG_elem_no(key, elem)); if (has_mask) { gpu_color_from_mask_copy(*CCG_elem_mask(key, elem), - vd->color); + diffuse_color, vd->color); } } vd++; @@ -1644,6 +1695,7 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids, elems[1], elems[2], elems[3], + diffuse_color, vd->color); } } @@ -1812,6 +1864,8 @@ GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid, buffers->grid_hidden = grid_hidden; buffers->totgrid = totgrid; + buffers->show_diffuse_color = FALSE; + /* Count the number of quads */ totquad = gpu_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize); @@ -1856,6 +1910,11 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers) const MVert *mvert = buffers->mvert; int i, j; const int has_mask = (buffers->vmask != NULL); + const MFace *face = &buffers->mface[buffers->face_indices[0]]; + float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f}; + + if (buffers->show_diffuse_color) + GPU_material_diffuse_get(face->mat_nr + 1, diffuse_color); if (has_mask) { gpu_colors_enable(VBO_DISABLED); @@ -1874,7 +1933,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers) if (buffers->smooth) { for (j = 0; j < S; j++) { if (has_mask) { - gpu_color_from_mask_set(buffers->vmask[fv[j]]); + gpu_color_from_mask_set(buffers->vmask[fv[j]], diffuse_color); } glNormal3sv(mvert[fv[j]].no); glVertex3fv(mvert[fv[j]].co); @@ -1903,7 +1962,7 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers) fmask = (fmask + buffers->vmask[fv[3]]) * 0.25; else fmask /= 3.0f; - gpu_color_from_mask_set(fmask); + gpu_color_from_mask_set(fmask, diffuse_color); } for (j = 0; j < S; j++) @@ -1923,6 +1982,11 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers) const CCGKey *key = &buffers->gridkey; int i, j, x, y, gridsize = buffers->gridkey.grid_size; const int has_mask = key->has_mask; + const DMFlagMat *flags = &buffers->grid_flag_mats[buffers->grid_indices[0]]; + float diffuse_color[4] = {0.8f, 0.8f, 0.8f, 1.0f}; + + if (buffers->show_diffuse_color) + GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color); if (has_mask) { gpu_colors_enable(VBO_DISABLED); @@ -1954,7 +2018,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers) if (buffers->smooth) { for (j = 0; j < 4; j++) { if (has_mask) { - gpu_color_from_mask_set(*CCG_elem_mask(key, e[j])); + gpu_color_from_mask_set(*CCG_elem_mask(key, e[j]), diffuse_color); } glNormal3fv(CCG_elem_no(key, e[j])); glVertex3fv(CCG_elem_co(key, e[j])); @@ -1970,7 +2034,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers) glNormal3fv(fno); if (has_mask) { - gpu_color_from_mask_quad_set(key, e[0], e[1], e[2], e[3]); + gpu_color_from_mask_quad_set(key, e[0], e[1], e[2], e[3], diffuse_color); } for (j = 0; j < 4; j++) @@ -1989,12 +2053,12 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers) CCGElem *b = CCG_grid_elem(key, grid, x, y + 1); if (has_mask) { - gpu_color_from_mask_set(*CCG_elem_mask(key, a)); + gpu_color_from_mask_set(*CCG_elem_mask(key, a), diffuse_color); } glNormal3fv(CCG_elem_no(key, a)); glVertex3fv(CCG_elem_co(key, a)); if (has_mask) { - gpu_color_from_mask_set(*CCG_elem_mask(key, b)); + gpu_color_from_mask_set(*CCG_elem_mask(key, b), diffuse_color); } glNormal3fv(CCG_elem_no(key, b)); glVertex3fv(CCG_elem_co(key, b)); @@ -2022,7 +2086,7 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers) glNormal3fv(fno); if (has_mask) { - gpu_color_from_mask_quad_set(key, a, b, c, d); + gpu_color_from_mask_quad_set(key, a, b, c, d, diffuse_color); } } @@ -2041,8 +2105,6 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers) void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) { - const int has_mask = (buffers->vmask || buffers->gridkey.has_mask); - if (buffers->totface) { const MFace *f = &buffers->mface[buffers->face_indices[0]]; if (!setMaterial(f->mat_nr + 1, NULL)) @@ -2059,13 +2121,7 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) if (buffers->vert_buf) { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); - if (has_mask) { - gpu_colors_enable(VBO_ENABLED); - } - else { - gpu_colors_enable(VBO_DISABLED); - glColor4ub(0xff, 0xff, 0xff, 0xff); - } + gpu_colors_enable(VBO_ENABLED); glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); @@ -2080,10 +2136,8 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) offset + offsetof(VertexBufferFormat, co)); glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), offset + offsetof(VertexBufferFormat, no)); - if (has_mask) { - glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), - offset + offsetof(VertexBufferFormat, color)); - } + glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), + offset + offsetof(VertexBufferFormat, color)); glDrawElements(GL_QUADS, buffers->tot_quad * 4, buffers->index_type, 0); @@ -2097,10 +2151,8 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) (void *)offsetof(VertexBufferFormat, co)); glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), (void *)offsetof(VertexBufferFormat, no)); - if (has_mask) { - glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), - (void *)offsetof(VertexBufferFormat, color)); - } + glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), + (void *)offsetof(VertexBufferFormat, color)); if (buffers->index_buf) glDrawElements(GL_TRIANGLES, totelem, buffers->index_type, 0); @@ -2114,12 +2166,7 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); - if (has_mask) { - gpu_colors_disable(VBO_ENABLED); - } - else { - gpu_colors_disable(VBO_DISABLED); - } + gpu_colors_disable(VBO_ENABLED); } /* fallbacks if we are out of memory or VBO is disabled */ else if (buffers->totface) { @@ -2130,6 +2177,32 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) } } +int GPU_buffers_diffuse_changed(GPU_Buffers *buffers, int show_diffuse_color) +{ + float diffuse_color[4]; + + if (buffers->show_diffuse_color != show_diffuse_color) + return TRUE; + + if (buffers->show_diffuse_color == FALSE) + return FALSE; + + if (buffers->mface) { + MFace *f = buffers->mface + buffers->face_indices[0]; + + GPU_material_diffuse_get(f->mat_nr + 1, diffuse_color); + } + else { + const DMFlagMat *flags = &buffers->grid_flag_mats[buffers->grid_indices[0]]; + + GPU_material_diffuse_get(flags->mat_nr + 1, diffuse_color); + } + + return diffuse_color[0] != buffers->diffuse_color[0] || + diffuse_color[1] != buffers->diffuse_color[1] || + diffuse_color[2] != buffers->diffuse_color[2]; +} + void GPU_free_buffers(GPU_Buffers *buffers) { if (buffers) { diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 25990e8fc6e..b90e67ac838 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -761,7 +761,7 @@ void GPU_pass_bind(GPUPass *pass, double time, int mipmap) /* now bind the textures */ for (input=inputs->first; input; input=input->next) { if (input->ima) - input->tex = GPU_texture_from_blender(input->ima, input->iuser, input->imagencd, time, mipmap); + input->tex = GPU_texture_from_blender(input->ima, input->iuser, input->image_isdata, time, mipmap); if (input->tex && input->bindtex) { GPU_texture_bind(input->tex, input->texid); @@ -917,7 +917,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, int type) input->ima = link->ptr1; input->iuser = link->ptr2; - input->imagencd = link->imagencd; + input->image_isdata = link->image_isdata; input->textarget = GL_TEXTURE_2D; input->textype = GPU_TEX2D; MEM_freeN(link); @@ -1110,14 +1110,14 @@ GPUNodeLink *GPU_dynamic_uniform(float *num, int dynamictype, void *data) return link; } -GPUNodeLink *GPU_image(Image *ima, ImageUser *iuser, int ncd) +GPUNodeLink *GPU_image(Image *ima, ImageUser *iuser, int isdata) { GPUNodeLink *link = GPU_node_link_create(0); link->image= 1; link->ptr1= ima; link->ptr2= iuser; - link->imagencd= ncd; + link->image_isdata= isdata; return link; } diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h index 3010937a2f3..f61f34908c5 100644 --- a/source/blender/gpu/intern/gpu_codegen.h +++ b/source/blender/gpu/intern/gpu_codegen.h @@ -91,7 +91,7 @@ struct GPUNodeLink { const char *attribname; int image; - int imagencd; + int image_isdata; int texture; int texturesize; @@ -99,7 +99,7 @@ struct GPUNodeLink { void *ptr1, *ptr2; int dynamic; - int dynamictype; + int dynamictype; int type; int users; @@ -138,7 +138,7 @@ typedef struct GPUInput { struct Image *ima; /* image */ struct ImageUser *iuser;/* image user */ - int imagencd; /* image does not contain color data */ + int image_isdata; /* image does not contain color data */ float *dynamicvec; /* vector data in case it is dynamic */ int dynamictype; /* origin of the dynamic uniform (GPUDynamicType) */ void *dynamicdata; /* data source of the dynamic uniform */ diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index ac05f1e8309..b40e19e1c9e 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -422,7 +422,7 @@ static void gpu_verify_reflection(Image *ima) } } -int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int mipmap, int ncd) +int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int mipmap, int is_data) { ImBuf *ibuf = NULL; unsigned int *bind = NULL; @@ -492,7 +492,7 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int } /* TODO unneeded when float images are correctly treated as linear always */ - if (!ncd) + if (!is_data) do_color_management = TRUE; if (ibuf->rect==NULL) @@ -611,12 +611,21 @@ int GPU_verify_image(Image *ima, ImageUser *iuser, int tftile, int compare, int rect= tilerect; } } + #ifdef WITH_DDS if (ibuf->ftype & DDS) GPU_create_gl_tex_compressed(bind, rect, rectw, recth, mipmap, ima, ibuf); else #endif GPU_create_gl_tex(bind, rect, frect, rectw, recth, mipmap, use_high_bit_depth, ima); + + /* mark as non-color data texture */ + if(*bind) { + if (is_data) + ima->tpageflag |= IMA_GLBIND_IS_DATA; + else + ima->tpageflag &= ~IMA_GLBIND_IS_DATA; + } /* clean up */ if (tilerect) @@ -730,12 +739,17 @@ int GPU_upload_dxt_texture(ImBuf *ibuf) return FALSE; } + if(!is_power_of_2_i(width) || !is_power_of_2_i(height)) { + printf("Unable to load non-power-of-two DXT image resolution, falling back to uncompressed\n"); + return FALSE; + } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gpu_get_mipmap_filter(1)); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - blocksize = (format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) ? 8 : 16; + blocksize = (ibuf->dds_data.fourcc == FOURCC_DXT1) ? 8 : 16; for (i=0; i<ibuf->dds_data.nummipmaps && (width||height); ++i) { if (width == 0) width = 1; @@ -903,7 +917,8 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) /* if color correction is needed, we must update the part that needs updating. */ if (ibuf->rect_float) { float *buffer = MEM_mallocN(w*h*sizeof(float)*4, "temp_texpaint_float_buf"); - IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h); + int is_data = (ima->tpageflag & IMA_GLBIND_IS_DATA); + IMB_partial_rect_from_float(ibuf, buffer, x, y, w, h, is_data); glBindTexture(GL_TEXTURE_2D, ima->bindcode); glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, @@ -929,12 +944,8 @@ void GPU_paint_update_image(Image *ima, int x, int y, int w, int h) glPixelStorei(GL_UNPACK_SKIP_PIXELS, x); glPixelStorei(GL_UNPACK_SKIP_ROWS, y); - if (ibuf->rect_float) - glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, - GL_FLOAT, ibuf->rect_float); - else - glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, - GL_UNSIGNED_BYTE, ibuf->rect); + glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, GL_RGBA, + GL_UNSIGNED_BYTE, ibuf->rect); glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length); glPixelStorei(GL_UNPACK_SKIP_PIXELS, skip_pixels); @@ -1130,7 +1141,7 @@ void GPU_free_image(Image *ima) ima->repbind= NULL; } - ima->tpageflag &= ~IMA_MIPMAP_COMPLETE; + ima->tpageflag &= ~(IMA_MIPMAP_COMPLETE|IMA_GLBIND_IS_DATA); } void GPU_free_images(void) @@ -1216,7 +1227,7 @@ static void gpu_material_to_fixed(GPUMaterialFixed *smat, const Material *bmat, if (gamma) { linearrgb_to_srgb_v3_v3(smat->diff, smat->diff); linearrgb_to_srgb_v3_v3(smat->spec, smat->spec); - } + } } } @@ -1469,6 +1480,21 @@ void GPU_disable_material(void) GPU_set_material_alpha_blend(GPU_BLEND_SOLID); } +void GPU_material_diffuse_get(int nr, float diff[4]) +{ + /* prevent index to use un-initialized array items */ + if (nr >= GMS.totmat) + nr = 0; + + /* no GPU_begin_object_materials, use default material */ + if (!GMS.matbuf) { + mul_v3_v3fl(diff, &defmaterial.r, defmaterial.ref + defmaterial.emit); + } + else { + copy_v4_v4(diff, GMS.matbuf[nr].diff); + } +} + void GPU_end_object_materials(void) { GPU_disable_material(); @@ -1627,7 +1653,7 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4 glLightfv(GL_LIGHT0+count, GL_SPECULAR, energy); glEnable(GL_LIGHT0+count); - glPopMatrix(); + glPopMatrix(); count++; if (count==8) diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 798868a5efe..21d5482e9cc 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -528,7 +528,7 @@ GPUTexture *GPU_texture_create_3D(int w, int h, int depth, int channels, float * return tex; } -GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int ncd, double time, int mipmap) +GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int isdata, double time, int mipmap) { GPUTexture *tex; GLint w, h, border, lastbindcode, bindcode; @@ -536,7 +536,7 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int ncd, doub glGetIntegerv(GL_TEXTURE_BINDING_2D, &lastbindcode); GPU_update_image_time(ima, time); - bindcode = GPU_verify_image(ima, iuser, 0, 0, mipmap, ncd); + bindcode = GPU_verify_image(ima, iuser, 0, 0, mipmap, isdata); if (ima->gputexture) { ima->gputexture->bindcode = bindcode; diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index e5f08d38ce8..1fd215b1ec2 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1129,7 +1129,7 @@ static void do_material_tex(GPUShadeInput *shi) newnor = tnor; } - norfac = minf(fabsf(mtex->norfac), 1.0f); + norfac = min_ff(fabsf(mtex->norfac), 1.0f); if (norfac == 1.0f && !GPU_link_changed(stencil)) { shi->vn = newnor; @@ -1881,7 +1881,7 @@ GPUShaderExport *GPU_shader_export(struct Scene *scene, struct Material *ma) GPUBuiltin gputype; GPUDynamicType dynamictype; GPUDataType datatype; - } builtins[] = { + } builtins[] = { { GPU_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_VIEWMAT, GPU_DATA_16F }, { GPU_INVERSE_VIEW_MATRIX, GPU_DYNAMIC_OBJECT_VIEWIMAT, GPU_DATA_16F }, { GPU_OBJECT_MATRIX, GPU_DYNAMIC_OBJECT_MAT, GPU_DATA_16F }, diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 716ffc2b254..5713c5e88a2 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -1894,7 +1894,7 @@ void test_shadowbuf_vsm(vec3 rco, sampler2D shadowmap, mat4 shadowpersmat, float } else { result = 1.0; - } + } } } diff --git a/source/blender/ikplugin/BIK_api.h b/source/blender/ikplugin/BIK_api.h index 4fc273bd435..95b1dafd129 100644 --- a/source/blender/ikplugin/BIK_api.h +++ b/source/blender/ikplugin/BIK_api.h @@ -58,7 +58,7 @@ struct BIK_ParamValue { float f[8]; int i[8]; char s[32]; - } value; + } value; }; typedef struct BIK_ParamValue BIK_ParamValue; diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index c929c97a040..5cf762af3e8 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -1253,7 +1253,7 @@ static IK_Scene *convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) ret = arm->addSegment(joint, parent, KDL::Joint::TransY, rot[ikchan->ndof - 1]); const float ikstretch = pchan->ikstretch * pchan->ikstretch; /* why invert twice here? */ - weight[1] = (1.0 - minf(1.0 - ikstretch, 1.0f - 0.001f)); + weight[1] = (1.0 - min_ff(1.0 - ikstretch, 1.0f - 0.001f)); weights.push_back(weight[1]); } if (!ret) diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index 344ae604ed4..511b3c64cb5 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -81,13 +81,9 @@ set(SRC intern/IMB_indexer.h intern/IMB_metadata.h intern/imbuf.h - intern/cineon/cin_debug_stuff.h - intern/cineon/cineonfile.h intern/cineon/cineonlib.h - intern/cineon/dpxfile.h intern/cineon/dpxlib.h intern/cineon/logImageCore.h - intern/cineon/logImageLib.h intern/cineon/logmemfile.h intern/dds/BlockDXT.h intern/dds/Color.h diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 28dbe110528..e297ebe3980 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -371,7 +371,7 @@ void IMB_interlace(struct ImBuf *ibuf); void IMB_rect_from_float(struct ImBuf *ibuf); /* Create char buffer for part of the image, color corrected if necessary, * Changed part will be stored in buffer. This is expected to be used for texture painting updates */ -void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y, int w, int h); +void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y, int w, int h, int is_data); void IMB_float_from_rect(struct ImBuf *ibuf); void IMB_float_from_rect_simple(struct ImBuf *ibuf); /* no profile conversion */ /* note, check that the conversion exists, only some are supported */ diff --git a/source/blender/imbuf/IMB_imbuf_types.h b/source/blender/imbuf/IMB_imbuf_types.h index 76c247b2195..28e62d496b2 100644 --- a/source/blender/imbuf/IMB_imbuf_types.h +++ b/source/blender/imbuf/IMB_imbuf_types.h @@ -93,7 +93,7 @@ typedef struct ImBuf { /* tiled pixel storage */ int tilex, tiley; int xtiles, ytiles; - unsigned int **tiles; + unsigned int **tiles; /* zbuffer */ int *zbuf; /* z buffer data, original zbuffer */ @@ -200,6 +200,10 @@ typedef struct ImBuf { #ifdef WITH_CINEON #define CINEON (1 << 21) #define DPX (1 << 20) +#define CINEON_LOG (1 << 8) +#define CINEON_16BIT (1 << 7) +#define CINEON_12BIT (1 << 6) +#define CINEON_10BIT (1 << 5) #endif #ifdef WITH_DDS diff --git a/source/blender/imbuf/intern/IMB_filetype.h b/source/blender/imbuf/intern/IMB_filetype.h index 56a03121409..68ad4808c80 100644 --- a/source/blender/imbuf/intern/IMB_filetype.h +++ b/source/blender/imbuf/intern/IMB_filetype.h @@ -97,13 +97,13 @@ struct ImBuf *imb_cocoaLoadImage(unsigned char *mem, size_t size, int flags, cha short imb_cocoaSaveImage(struct ImBuf *ibuf, const char *name, int flags); /* cineon */ -int imb_savecineon(struct ImBuf *buf, const char *name, int flags); -struct ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); +int imb_save_cineon(struct ImBuf *buf, const char *name, int flags); +struct ImBuf *imb_load_cineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); int imb_is_cineon(unsigned char *buf); /* dpx */ int imb_save_dpx(struct ImBuf *buf, const char *name, int flags); -struct ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); +struct ImBuf *imb_load_dpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]); int imb_is_dpx(unsigned char *buf); /* hdr */ diff --git a/source/blender/imbuf/intern/IMB_indexer.h b/source/blender/imbuf/intern/IMB_indexer.h index 18816924a9b..9c95531e90d 100644 --- a/source/blender/imbuf/intern/IMB_indexer.h +++ b/source/blender/imbuf/intern/IMB_indexer.h @@ -72,7 +72,7 @@ typedef struct anim_index_builder { char name[FILE_MAX]; char temp_name[FILE_MAX]; - void * private_data; + void *private_data; void (*delete_priv_data)(struct anim_index_builder * idx); void (*proc_frame)(struct anim_index_builder * idx, diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 4aeba9af89d..5b64416c309 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -1233,7 +1233,7 @@ static ImBuf *anim_getnew(struct anim *anim) if (anim->curtype != 0) return (NULL); - anim->curtype = imb_get_anim_type(anim->name); + anim->curtype = imb_get_anim_type(anim->name); switch (anim->curtype) { case ANIM_SEQUENCE: diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index df12f0b703e..32733668052 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -184,7 +184,7 @@ struct ImBuf *imb_bmp_decode(unsigned char *mem, size_t size, int flags, char co rect += 4; bmp += 3; } /* for 24-bit images, rows are padded to multiples of 4 */ - bmp += x % 4; + bmp += x % 4; } } else if (depth == 32) { diff --git a/source/blender/imbuf/intern/cineon/CMakeLists.txt b/source/blender/imbuf/intern/cineon/CMakeLists.txt index fdf4f5409a5..8e76f5e729b 100644 --- a/source/blender/imbuf/intern/cineon/CMakeLists.txt +++ b/source/blender/imbuf/intern/cineon/CMakeLists.txt @@ -43,8 +43,11 @@ set(SRC cineonlib.c dpxlib.c logImageCore.c - logImageLib.c logmemfile.c ) +if(WITH_IMAGE_CINEON) + add_definitions(-DWITH_CINEON) +endif() + blender_add_lib(bf_imbuf_cineon "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/imbuf/intern/cineon/SConscript b/source/blender/imbuf/intern/cineon/SConscript index e1afb5ebd2d..a07334632d7 100644 --- a/source/blender/imbuf/intern/cineon/SConscript +++ b/source/blender/imbuf/intern/cineon/SConscript @@ -15,4 +15,7 @@ incs = ['.', defs = [] +if env['WITH_BF_CINEON']: + defs.append('WITH_CINEON') + env.BlenderLib ('bf_imbuf_cineon', source_files, incs, defs, libtype=['core','player'], priority = [220,175]) diff --git a/source/blender/imbuf/intern/cineon/cin_debug_stuff.h b/source/blender/imbuf/intern/cineon/cin_debug_stuff.h index a97499fb1ae..e69de29bb2d 100644 --- a/source/blender/imbuf/intern/cineon/cin_debug_stuff.h +++ b/source/blender/imbuf/intern/cineon/cin_debug_stuff.h @@ -1,4 +0,0 @@ -/** \file blender/imbuf/intern/cineon/cin_debug_stuff.h - * \ingroup imbcineon - */ -#define d_printf printf diff --git a/source/blender/imbuf/intern/cineon/cineon_dpx.c b/source/blender/imbuf/intern/cineon/cineon_dpx.c index 7705af13b1e..d20c6dec9d3 100644 --- a/source/blender/imbuf/intern/cineon/cineon_dpx.c +++ b/source/blender/imbuf/intern/cineon/cineon_dpx.c @@ -4,11 +4,11 @@ * 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 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * 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 @@ -20,25 +20,24 @@ * * The Original Code is: all of this file. * - * Contributor(s): none yet. + * Contributor(s): Julien Enche. * * ***** END GPL LICENSE BLOCK ***** * cineon.c - * contributors: joeedh + * contributors: joeedh, Julien Enche * I hearby donate this code and all rights to the Blender Foundation. + * $Id$ */ /** \file blender/imbuf/intern/cineon/cineon_dpx.c * \ingroup imbcineon */ - -#include <stdio.h> -#include <string.h> /*for memcpy*/ -#include "logImageLib.h" -#include "cineonlib.h" -#include "dpxlib.h" +#include <stdio.h> +#include <string.h> +#include <math.h> +#include "logImageCore.h" #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" @@ -51,167 +50,142 @@ #include "MEM_guardedalloc.h" -#if 0 -static void cineon_conversion_parameters(LogImageByteConversionParameters *params) -{ -// params->blackPoint = scene?scene->r.cineonblack:95; -// params->whitePoint = scene?scene->r.cineonwhite:685; -// params->gamma = scene?scene->r.cineongamma:1.7f; -// params->doLogarithm = scene?scene->r.subimtype & R_CINEON_LOG:0; - - params->blackPoint = 95; - params->whitePoint = 685; - params->gamma = 1.0f; - params->doLogarithm = 0; -} -#endif - -static ImBuf *imb_load_dpx_cineon(unsigned char *mem, int use_cineon, int size, int flags, char colorspace[IM_MAX_SPACE]) +static struct ImBuf *imb_load_dpx_cineon(unsigned char *mem, size_t size, int use_cineon, int flags, + char colorspace[IM_MAX_SPACE]) { ImBuf *ibuf; LogImageFile *image; - int x, y; - unsigned short *row, *upix; int width, height, depth; - float *frow; colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_FLOAT); - logImageSetVerbose((G.debug & G_DEBUG) ? 1:0); - - image = logImageOpenFromMem(mem, size, use_cineon); - - if (!image) { - printf("no image!\n"); - return NULL; + logImageSetVerbose((G.f & G_DEBUG) ? 1 : 0); + + image = logImageOpenFromMemory(mem, size); + + if (image == 0) { + printf("DPX/Cineon: error opening image.\n"); + return 0; } - + logImageGetSize(image, &width, &height, &depth); - - if (depth != 3) { /*need to do grayscale loading eventually.*/ + + if (width == 0 || height == 0) { logImageClose(image); - return NULL; + return 0; } - - if (width == 0 && height == 0) { + + ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags); + if (ibuf == 0) { logImageClose(image); - return NULL; + return 0; } - - ibuf = IMB_allocImBuf(width, height, 32, IB_rectfloat | flags); - row = MEM_mallocN(sizeof(unsigned short)*width*depth, "row in cineon_dpx.c"); - frow = ibuf->rect_float+width*height*4; - - for (y = 0; y < height; y++) { - logImageGetRowBytes(image, row, y); /* checks image->params.doLogarithm and convert */ - upix = row; - frow -= width*4; - - for (x=0; x<width; x++) { - *(frow++) = ((float)*(upix++)) / 65535.0f; - *(frow++) = ((float)*(upix++)) / 65535.0f; - *(frow++) = ((float)*(upix++)) / 65535.0f; - *(frow++) = 1.0f; - } - frow -= width*4; + if (logImageGetDataRGBA(image, ibuf->rect_float, 1) != 0) { + /* Conversion not possible (probably because the format is unsupported) */ + logImageClose(image); + MEM_freeN(ibuf); + return 0; } - MEM_freeN(row); logImageClose(image); - - if (flags & IB_rect) { + ibuf->ftype = use_cineon ? CINEON : DPX; + IMB_flipy(ibuf); + + if (flags & IB_rect) IMB_rect_from_float(ibuf); - } + return ibuf; } static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filename, int use_cineon, int flags) { - LogImageByteConversionParameters conversion; - const int width= ibuf->x; - const int height= ibuf->y; - const int depth= 3; - LogImageFile* logImage; - unsigned short* line, *pixel; - int i, j; - float *fline; + LogImageFile *logImage; float *fbuf; - int is_alloc= 0; + float *fbuf_ptr; + unsigned char *rect_ptr; + int x, y, depth, bitspersample, rvalue; + + if (flags & IB_mem) { + printf("DPX/Cineon: saving in memory is not supported.\n"); + return 0; + } - (void)flags; /* unused */ + logImageSetVerbose((G.f & G_DEBUG) ? 1 : 0); - // cineon_conversion_parameters(&conversion); - logImageGetByteConversionDefaults(&conversion); + depth = (ibuf->planes + 7) >> 3; + if (depth > 4 || depth < 3) { + printf("DPX/Cineon: unsupported depth: %d for file: '%s'\n", depth, filename); + return 0; + } - /* - * Get the drawable for the current image... - */ + if (ibuf->ftype & CINEON_10BIT) + bitspersample = 10; + else if (ibuf->ftype & CINEON_12BIT) + bitspersample = 12; + else if (ibuf->ftype & CINEON_16BIT) + bitspersample = 16; + else + bitspersample = 8; - fbuf= IMB_float_profile_ensure(ibuf, conversion.doLogarithm ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_NONE, &is_alloc); + logImage = logImageCreate(filename, use_cineon, ibuf->x, ibuf->y, bitspersample, (depth == 4), + (ibuf->ftype & CINEON_LOG), -1, -1, -1, "Blender"); - if (fbuf == NULL) { /* in the unlikely event that converting to a float buffer fails */ + if (logImage == 0) { + printf("DPX/Cineon: error creating file.\n"); return 0; } - - logImageSetVerbose((G.debug & G_DEBUG) ? 1:0); - logImage = logImageCreate(filename, use_cineon, width, height, depth); - if (!logImage) return 0; - - if (logImageSetByteConversion(logImage, &conversion)==0) { - printf("error setting args\n"); + if (ibuf->rect_float != 0 && bitspersample != 8) { + /* don't use the float buffer to save 8 bpp picture to prevent color banding + (there's no dithering algorithm behing the logImageSetDataRGBA function) */ + IMB_flipy(ibuf); + rvalue = (logImageSetDataRGBA(logImage, ibuf->rect_float, 1) == 0); + IMB_flipy(ibuf); } - - line = MEM_mallocN(sizeof(unsigned short)*depth*width, "line"); - - /*note that image is flipped when sent to logImageSetRowBytes (see last passed parameter).*/ - for (j = 0; j < height; ++j) { - fline = &fbuf[width*j*4]; - for (i=0; i<width; i++) { - float *fpix, fpix2[3]; - /*we have to convert to cinepaint's 16-bit-per-channel here*/ - pixel = &line[i*depth]; - fpix = &fline[i*4]; - memcpy(fpix2, fpix, sizeof(float)*3); - - if (fpix2[0]>=1.0f) fpix2[0] = 1.0f; else if (fpix2[0]<0.0f) fpix2[0]= 0.0f; - if (fpix2[1]>=1.0f) fpix2[1] = 1.0f; else if (fpix2[1]<0.0f) fpix2[1]= 0.0f; - if (fpix2[2]>=1.0f) fpix2[2] = 1.0f; else if (fpix2[2]<0.0f) fpix2[2]= 0.0f; - - pixel[0] = (unsigned short)(fpix2[0] * 65535.0f); /*float-float math is faster*/ - pixel[1] = (unsigned short)(fpix2[1] * 65535.0f); - pixel[2] = (unsigned short)(fpix2[2] * 65535.0f); + else { + if (ibuf->rect == 0) + IMB_rect_from_float(ibuf); + + fbuf = (float *)MEM_mallocN(ibuf->x * ibuf->y * 4 * sizeof(float), "fbuf in imb_save_dpx_cineon"); + if (fbuf == 0) { + printf("DPX/Cineon: error allocating memory.\n"); + logImageClose(logImage); + return 0; } - logImageSetRowBytes(logImage, (const unsigned short*)line, height-1-j); - } - logImageClose(logImage); - - MEM_freeN(line); - - if (is_alloc) { + for (y = 0; y < ibuf->y; y++) { + for (x = 0; x < ibuf->x; x++) { + fbuf_ptr = fbuf + 4 * ((ibuf->y - y - 1) * ibuf->x + x); + rect_ptr = (unsigned char *)ibuf->rect + 4 * (y * ibuf->x + x); + fbuf_ptr[0] = (float)rect_ptr[0] / 255.0f; + fbuf_ptr[1] = (float)rect_ptr[1] / 255.0f; + fbuf_ptr[2] = (float)rect_ptr[2] / 255.0f; + fbuf_ptr[3] = (depth == 4) ? ((float)rect_ptr[3] / 255.0f) : 1.0f; + } + } + rvalue = (logImageSetDataRGBA(logImage, fbuf, 0) == 0); MEM_freeN(fbuf); } - - return 1; + + logImageClose(logImage); + return rvalue; } -int imb_savecineon(struct ImBuf *buf, const char *myfile, int flags) +int imb_save_cineon(struct ImBuf *buf, const char *myfile, int flags) { return imb_save_dpx_cineon(buf, myfile, 1, flags); } - int imb_is_cineon(unsigned char *buf) { - return cineonIsMemFileCineon(buf); + return logImageIsCineon(buf); } -ImBuf *imb_loadcineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) +ImBuf *imb_load_cineon(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { if (imb_is_cineon(mem)) - return imb_load_dpx_cineon(mem, 1, size, flags, colorspace); - return NULL; + return imb_load_dpx_cineon(mem, size, 1, flags, colorspace); + return 0; } int imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags) @@ -221,12 +195,12 @@ int imb_save_dpx(struct ImBuf *buf, const char *myfile, int flags) int imb_is_dpx(unsigned char *buf) { - return dpxIsMemFileCineon(buf); + return logImageIsDpx(buf); } -ImBuf *imb_loaddpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) +ImBuf *imb_load_dpx(unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE]) { if (imb_is_dpx(mem)) - return imb_load_dpx_cineon(mem, 0, size, flags, colorspace); - return NULL; + return imb_load_dpx_cineon(mem, size, 0, flags, colorspace); + return 0; } diff --git a/source/blender/imbuf/intern/cineon/cineonfile.h b/source/blender/imbuf/intern/cineon/cineonfile.h index e681153aa6e..e69de29bb2d 100644 --- a/source/blender/imbuf/intern/cineon/cineonfile.h +++ b/source/blender/imbuf/intern/cineon/cineonfile.h @@ -1,134 +0,0 @@ -/* - * Cineon image file format library definitions. - * Cineon file format structures. - * - * This header file contains private details. - * User code should generally use cineonlib.h only. - * - * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> - * - * 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. - * - */ - -#ifndef __CINEONFILE_H__ -#define __CINEONFILE_H__ - -/** \file blender/imbuf/intern/cineon/cineonfile.h - * \ingroup imbcineon - */ - -#include "logImageCore.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - U32 magic_num; /* magic number */ - U32 image_offset; /* offset to image data in bytes */ - U32 gen_hdr_size; /* generic header length in bytes */ - U32 ind_hdr_size; /* industry header length in bytes */ - U32 user_data_size; /* user-defined data length in bytes */ - U32 file_size; /* file size in bytes */ - ASCII vers[8]; /* which header format version is being used (v4.5) */ - ASCII file_name[100]; /* image file name */ - ASCII create_date[12]; /* file creation date */ - ASCII create_time[12]; /* file creation time */ - ASCII Reserved[36]; /* reserved field TBD (need to pad) */ -} CineonFileInformation; - -typedef struct { - U8 designator1; - U8 designator2; - U8 bits_per_pixel; - U8 filler; - U32 pixels_per_line; - U32 lines_per_image; - U32 ref_low_data; /* reference low data code value */ - R32 ref_low_quantity; /* reference low quantity represented */ - U32 ref_high_data; /* reference high data code value */ - R32 ref_high_quantity;/* reference high quantity represented */ -} CineonChannelInformation; - -typedef struct { - U8 orientation; /* image orientation */ - U8 channels_per_image; - U16 filler; - CineonChannelInformation channel[8]; - R32 white_point_x; - R32 white_point_y; - R32 red_primary_x; - R32 red_primary_y; - R32 green_primary_x; - R32 green_primary_y; - R32 blue_primary_x; - R32 blue_primary_y; - ASCII label[200]; - ASCII reserved[28]; -} CineonImageInformation; - -typedef struct { - U8 interleave; - U8 packing; - U8 signage; - U8 sense; - U32 line_padding; - U32 channel_padding; - ASCII reserved[20]; -} CineonFormatInformation; - -typedef struct { - S32 x_offset; - S32 y_offset; - ASCII file_name[100]; - ASCII create_date[12]; /* file creation date */ - ASCII create_time[12]; /* file creation time */ - ASCII input_device[64]; - ASCII model_number[32]; - ASCII serial_number[32]; - R32 x_input_samples_per_mm; - R32 y_input_samples_per_mm; - R32 input_device_gamma; - ASCII reserved[40]; -} CineonOriginationInformation; - -typedef struct { - CineonFileInformation fileInfo; - CineonImageInformation imageInfo; - CineonFormatInformation formatInfo; - CineonOriginationInformation originInfo; -} CineonGenericHeader; - -typedef struct { - U8 filmCode; - U8 filmType; - U8 perfOffset; - U8 filler; - U32 keycodePrefix; - U32 keycodeCount; - ASCII format[32]; - U32 framePosition; /* in sequence */ - R32 frameRate; /* frames per second */ - ASCII attribute[32]; - ASCII slate[200]; - ASCII reserved[740]; -} CineonMPISpecificInformation; - -#ifdef __cplusplus -} -#endif - -#endif /* __CINEONFILE_H__ */ diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c index a9001303679..9926d8c8562 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.c +++ b/source/blender/imbuf/intern/cineon/cineonlib.c @@ -1,21 +1,23 @@ /* - * Cineon image file format library routines. + * Cineon image file format library routines. * - * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> + * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> * - * 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 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. + * 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. + * 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. + * + * Contributor(s): Julien Enche. * */ @@ -23,800 +25,355 @@ * \ingroup imbcineon */ + #include "cineonlib.h" -#include "cineonfile.h" +#include "logmemfile.h" #include <stdio.h> #include <math.h> #include <stdlib.h> -#include <time.h> /* strftime() */ +#include <time.h> #include <sys/types.h> -#ifdef WIN32 -#include <winsock.h> -#else -#include <netinet/in.h> /* htonl() */ -#endif -#include <string.h> /* memset */ +#include <string.h> -#include "BLI_utildefines.h" #include "BLI_fileops.h" +#include "BLI_math_base.h" +#include "BLI_utildefines.h" -#include "cin_debug_stuff.h" -#include "logmemfile.h" - -static void -fillCineonFileInfo(CineonFile* cineon, CineonFileInformation* fileInfo, const char* filename) { - - time_t fileClock; - struct tm* fileTime; - - fileInfo->magic_num = htonl(CINEON_FILE_MAGIC); - fileInfo->image_offset = htonl(cineon->imageOffset); - fileInfo->gen_hdr_size = htonl( - sizeof(CineonFileInformation) + - sizeof(CineonImageInformation) + - sizeof(CineonFormatInformation) + - sizeof(CineonOriginationInformation)); - fileInfo->ind_hdr_size = 0; - fileInfo->user_data_size = 0; - fileInfo->file_size = htonl(cineon->imageOffset + cineon->height * cineon->lineBufferLength); - strcpy(fileInfo->vers, "V4.5"); - strncpy(fileInfo->file_name, filename, 99); - fileInfo->file_name[99] = 0; - - fileClock = time(0); - fileTime = localtime(&fileClock); - strftime(fileInfo->create_date, 12, "%Y:%m:%d", fileTime); - /* Question: is %Z in strftime guaranteed to return 3 chars? */ - strftime(fileInfo->create_time, 12, "%H:%M:%S%Z", fileTime); - fileInfo->create_time[11] = 0; -} - -static void -dumpCineonFileInfo(CineonFileInformation* fileInfo) { - d_printf("\n--File Information--\n"); - d_printf("Magic: %8.8lX\n", (uintptr_t)ntohl(fileInfo->magic_num)); - d_printf("Image Offset %ld\n", (intptr_t)ntohl(fileInfo->image_offset)); - d_printf("Generic Header size %ld\n", (intptr_t)ntohl(fileInfo->gen_hdr_size)); - d_printf("Industry Header size %ld\n", (intptr_t)ntohl(fileInfo->ind_hdr_size)); - d_printf("User Data size %ld\n", (intptr_t)ntohl(fileInfo->user_data_size)); - d_printf("File size %ld\n", (intptr_t)ntohl(fileInfo->file_size)); - d_printf("Version \"%s\"\n", fileInfo->vers); - d_printf("File name \"%s\"\n", fileInfo->file_name); - d_printf("Creation date \"%s\"\n", fileInfo->create_date); - d_printf("Creation time \"%s\"\n", fileInfo->create_time); -} - -static void -fillCineonChannelInfo(CineonFile* cineon, CineonChannelInformation* chan, int des) { - - chan->designator1 = 0; - chan->designator2 = des; - chan->bits_per_pixel = 10; - chan->pixels_per_line = htonl(cineon->width); - chan->lines_per_image = htonl(cineon->height); - chan->ref_low_data = htonl(0); - chan->ref_low_quantity = htonf(0.0); - chan->ref_high_data = htonl(1023); - chan->ref_high_quantity = htonf(2.046); -} - -static void -dumpCineonChannelInfo(CineonChannelInformation* chan) { - d_printf(" Metric selector: %d", chan->designator1); - switch (chan->designator1) { - case 0: d_printf(" (Universal)\n"); break; - default: d_printf(" (Vendor specific)\n"); break; - } - d_printf(" Metric: %d,", chan->designator2); - switch (chan->designator2) { - case 0: d_printf(" B&W (printing density?)\n"); break; - case 1: d_printf(" Red printing density\n"); break; - case 2: d_printf(" Green printing density\n"); break; - case 3: d_printf(" Blue printing density\n"); break; - case 4: d_printf(" Red CCIR XA/11\n"); break; - case 5: d_printf(" Green CCIR XA/11\n"); break; - case 6: d_printf(" Blue CCIR XA/11\n"); break; - default: d_printf(" (unknown)\n"); break; - } - d_printf(" Bits per pixel %d\n", chan->bits_per_pixel); - d_printf(" Pixels per line %ld\n", (intptr_t)ntohl(chan->pixels_per_line)); - d_printf(" Lines per image %ld\n", (intptr_t)ntohl(chan->lines_per_image)); - d_printf(" Ref low data %ld\n", (intptr_t)ntohl(chan->ref_low_data)); - d_printf(" Ref low quantity %f\n", ntohf(chan->ref_low_quantity)); - d_printf(" Ref high data %ld\n", (intptr_t)ntohl(chan->ref_high_data)); - d_printf(" Ref high quantity %f\n", ntohf(chan->ref_high_quantity)); -} - -static void -fillCineonImageInfo(CineonFile* cineon, CineonImageInformation* imageInfo) { - - imageInfo->orientation = 0; - imageInfo->channels_per_image = cineon->depth; - - if (cineon->depth == 1) { - fillCineonChannelInfo(cineon, &imageInfo->channel[0], 0); - - } - else if (cineon->depth == 3) { - fillCineonChannelInfo(cineon, &imageInfo->channel[0], 1); - fillCineonChannelInfo(cineon, &imageInfo->channel[1], 2); - fillCineonChannelInfo(cineon, &imageInfo->channel[2], 3); - } - - imageInfo->white_point_x = htonf(undefined()); - imageInfo->white_point_y = htonf(undefined()); - imageInfo->red_primary_x = htonf(undefined()); - imageInfo->red_primary_y = htonf(undefined()); - imageInfo->green_primary_x = htonf(undefined()); - imageInfo->green_primary_y = htonf(undefined()); - imageInfo->blue_primary_x = htonf(undefined()); - imageInfo->blue_primary_y = htonf(undefined()); - - strcpy(imageInfo->label, "David's Cineon writer."); - -} - -static void -dumpCineonImageInfo(CineonImageInformation* imageInfo) { - - int i; - d_printf("\n--Image Information--\n"); - d_printf("Image orientation %d,", imageInfo->orientation); - switch (imageInfo->orientation) { - case 0: d_printf(" LRTB\n"); break; - case 1: d_printf(" LRBT\n"); break; - case 2: d_printf(" RLTB\n"); break; - case 3: d_printf(" RLBT\n"); break; - case 4: d_printf(" TBLR\n"); break; - case 5: d_printf(" TBRL\n"); break; - case 6: d_printf(" BTLR\n"); break; - case 7: d_printf(" BTRL\n"); break; - default: d_printf(" (unknown)\n"); break; - } - d_printf("Channels %d\n", imageInfo->channels_per_image); - for (i = 0; i < imageInfo->channels_per_image; ++i) { - d_printf(" --Channel %d--\n", i); - dumpCineonChannelInfo(&imageInfo->channel[i]); - } - - d_printf("White point x %f\n", ntohf(imageInfo->white_point_x)); - d_printf("White point y %f\n", ntohf(imageInfo->white_point_y)); - d_printf("Red primary x %f\n", ntohf(imageInfo->red_primary_x)); - d_printf("Red primary y %f\n", ntohf(imageInfo->red_primary_y)); - d_printf("Green primary x %f\n", ntohf(imageInfo->green_primary_x)); - d_printf("Green primary y %f\n", ntohf(imageInfo->green_primary_y)); - d_printf("Blue primary x %f\n", ntohf(imageInfo->blue_primary_x)); - d_printf("Blue primary y %f\n", ntohf(imageInfo->blue_primary_y)); - d_printf("Label \"%s\"\n", imageInfo->label); -} - -static void -fillCineonFormatInfo(CineonFile* cineon, CineonFormatInformation* formatInfo) { - - (void)cineon; /* unused */ - - formatInfo->interleave = 0; - formatInfo->packing = 5; - formatInfo->signage = 0; - formatInfo->sense = 0; - formatInfo->line_padding = htonl(0); - formatInfo->channel_padding = htonl(0); -} - -static void -dumpCineonFormatInfo(CineonFormatInformation* formatInfo) { - d_printf("\n--Format Information--\n"); - d_printf("Interleave %d,", formatInfo->interleave); - switch (formatInfo->interleave) { - case 0: d_printf(" pixel interleave\n"); break; - case 1: d_printf(" line interleave\n"); break; - case 2: d_printf(" channel interleave\n"); break; - default: d_printf(" (unknown)\n"); break; - } - d_printf("Packing %d,", formatInfo->packing); - if (formatInfo->packing & 0x80) { - d_printf(" multi pixel,"); - } - else { - d_printf(" single pixel,"); - } - switch (formatInfo->packing & 0x7F) { - case 0: d_printf(" tight\n"); break; - case 1: d_printf(" byte packed left\n"); break; - case 2: d_printf(" byte packed right\n"); break; - case 3: d_printf(" word packed left\n"); break; - case 4: d_printf(" word packed right\n"); break; - case 5: d_printf(" long packed left\n"); break; - case 6: d_printf(" long packed right\n"); break; - default: d_printf(" (unknown)\n"); break; - } - d_printf("Sign %d,", formatInfo->signage); - if (formatInfo->signage) { - d_printf(" signed\n"); - } - else { - d_printf(" unsigned\n"); - } - d_printf("Sense %d,", formatInfo->signage); - if (formatInfo->signage) { - d_printf(" negative\n"); - } - else { - d_printf(" positive\n"); - } - d_printf("End of line padding %ld\n", (intptr_t)ntohl(formatInfo->line_padding)); - d_printf("End of channel padding %ld\n", (intptr_t)ntohl(formatInfo->channel_padding)); -} - -static void -fillCineonOriginationInfo(CineonFile* cineon, - CineonOriginationInformation* originInfo, CineonFileInformation* fileInfo) { - - (void)cineon; /* unused */ - - originInfo->x_offset = htonl(0); - originInfo->y_offset = htonl(0); - strcpy(originInfo->file_name, fileInfo->file_name); - strcpy(originInfo->create_date, fileInfo->create_date); - strcpy(originInfo->create_time, fileInfo->create_time); - strncpy(originInfo->input_device, "David's Cineon writer", 64); - strncpy(originInfo->model_number, "Software", 32); - strncpy(originInfo->serial_number, "001", 32); - originInfo->x_input_samples_per_mm = htonf(undefined()); - originInfo->y_input_samples_per_mm = htonf(undefined()); - /* this should probably be undefined, too */ - originInfo->input_device_gamma = htonf(1.0); -} - -static void -dumpCineonOriginationInfo(CineonOriginationInformation* originInfo) { - d_printf("\n--Origination Information--\n"); - d_printf("X offset %ld\n", (intptr_t)ntohl(originInfo->x_offset)); - d_printf("Y offset %ld\n", (intptr_t)ntohl(originInfo->y_offset)); - d_printf("File name \"%s\"\n", originInfo->file_name); - d_printf("Creation date \"%s\"\n", originInfo->create_date); - d_printf("Creation time \"%s\"\n", originInfo->create_time); - d_printf("Input device \"%s\"\n", originInfo->input_device); - d_printf("Model number \"%s\"\n", originInfo->model_number); - d_printf("Serial number \"%s\"\n", originInfo->serial_number); - d_printf("Samples per mm in x %f\n", ntohf(originInfo->x_input_samples_per_mm)); - d_printf("Samples per mm in y %f\n", ntohf(originInfo->y_input_samples_per_mm)); - d_printf("Input device gamma %f\n", ntohf(originInfo->input_device_gamma)); -} - -static int -initCineonGenericHeader(CineonFile* cineon, CineonGenericHeader* header, const char* imagename) { - - fillCineonFileInfo(cineon, &header->fileInfo, imagename); - fillCineonImageInfo(cineon, &header->imageInfo); - fillCineonFormatInfo(cineon, &header->formatInfo); - fillCineonOriginationInfo(cineon, &header->originInfo, &header->fileInfo); +#include "logImageLib.h" - return 0; -} +#include "MEM_guardedalloc.h" -static void -UNUSED_FUNCTION(dumpCineonGenericHeader)(CineonGenericHeader* header) { - dumpCineonFileInfo(&header->fileInfo); - dumpCineonImageInfo(&header->imageInfo); - dumpCineonFormatInfo(&header->formatInfo); - dumpCineonOriginationInfo(&header->originInfo); -} +/* + * For debug purpose + */ static int verbose = 0; -void -cineonSetVerbose(int verbosity) { - verbose = verbosity; -} - -static void -verboseMe(CineonFile* cineon) { - - d_printf("size %d x %d x %d\n", cineon->width, cineon->height, cineon->depth); - d_printf("ImageStart %d, lineBufferLength %d, implied length %d\n", - cineon->imageOffset, cineon->lineBufferLength * 4, - cineon->imageOffset + cineon->lineBufferLength * 4 * cineon->height); -} - -int -cineonGetRowBytes(CineonFile* cineon, unsigned short* row, int y) { - - int longsRead; - int pixelIndex; - int longIndex; - int numPixels = cineon->width * cineon->depth; - - - /* only seek if not reading consecutive lines */ - if (y != cineon->fileYPos) { - int lineOffset = cineon->imageOffset + y * cineon->lineBufferLength * 4; - if (verbose) d_printf("Seek in getRowBytes\n"); - if (logimage_fseek(cineon, lineOffset, SEEK_SET) != 0) { - if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, lineOffset); - return 1; - } - cineon->fileYPos = y; - } - - longsRead = logimage_fread(cineon->lineBuffer, 4, cineon->lineBufferLength, cineon); - if (longsRead != cineon->lineBufferLength) { - if (verbose) { - d_printf("Couldn't read line %d length %d\n", y, cineon->lineBufferLength * 4); - perror("cineonGetRowBytes"); - } - - return 1; - } - /* remember where we left the car, honey */ - ++cineon->fileYPos; - - /* convert longwords to pixels */ - pixelIndex = 0; - for (longIndex = 0; longIndex < cineon->lineBufferLength; ++longIndex) { - unsigned int t = ntohl(cineon->lineBuffer[longIndex]); - t = t >> 2; - cineon->pixelBuffer[pixelIndex+2] = (unsigned short) t & 0x3ff; - t = t >> 10; - cineon->pixelBuffer[pixelIndex+1] = (unsigned short) t & 0x3ff; - t = t >> 10; - cineon->pixelBuffer[pixelIndex] = (unsigned short) t & 0x3ff; - pixelIndex += 3; - } - - /* extract required pixels */ - for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) { - if (cineon->params.doLogarithm) - row[pixelIndex] = cineon->lut10_16[cineon->pixelBuffer[pixelIndex]]; - else - row[pixelIndex] = cineon->pixelBuffer[pixelIndex] << 6; - } - - return 0; +void cineonSetVerbose(int verbosity) { + verbose = verbosity; } -int -cineonSetRowBytes(CineonFile* cineon, const unsigned short* row, int y) { - - int pixelIndex; - int numPixels = cineon->width * cineon->depth; - int longIndex; - int longsWritten; - - /* put new pixels into pixelBuffer */ - for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) { - if (cineon->params.doLogarithm) - cineon->pixelBuffer[pixelIndex] = cineon->lut16_16[row[pixelIndex]]; - else - cineon->pixelBuffer[pixelIndex] = row[pixelIndex] >> 6; - } - - /* pack into longwords */ - pixelIndex = 0; - for (longIndex = 0; longIndex < cineon->lineBufferLength; ++longIndex) { - unsigned int t = - (cineon->pixelBuffer[pixelIndex] << 22) | - (cineon->pixelBuffer[pixelIndex+1] << 12) | - (cineon->pixelBuffer[pixelIndex+2] << 2); - cineon->lineBuffer[longIndex] = htonl(t); - pixelIndex += 3; - } - - /* only seek if not reading consecutive lines */ - if (y != cineon->fileYPos) { - int lineOffset = cineon->imageOffset + y * cineon->lineBufferLength * 4; - if (verbose) d_printf("Seek in setRowBytes\n"); - if (logimage_fseek(cineon, lineOffset, SEEK_SET) != 0) { - if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, lineOffset); - return 1; - } - cineon->fileYPos = y; - } - - longsWritten = fwrite(cineon->lineBuffer, 4, cineon->lineBufferLength, cineon->file); - if (longsWritten != cineon->lineBufferLength) { - if (verbose) d_printf("Couldn't write line %d length %d\n", y, cineon->lineBufferLength * 4); - return 1; - } - - ++cineon->fileYPos; +static void fillCineonMainHeader(LogImageFile *cineon, CineonMainHeader *header, + const char *filename, const char *creator) +{ + time_t fileClock; + struct tm *fileTime; + int i; - return 0; + memset(header, 0, sizeof(CineonMainHeader)); + + /* --- File header --- */ + header->fileHeader.magic_num = swap_uint(CINEON_FILE_MAGIC, cineon->isMSB); + header->fileHeader.offset = swap_uint(cineon->element[0].dataOffset, cineon->isMSB); + header->fileHeader.gen_hdr_size = swap_uint(sizeof(CineonFileHeader) + sizeof(CineonImageHeader) + + sizeof(CineonOriginationHeader), cineon->isMSB); + header->fileHeader.ind_hdr_size = 0; + header->fileHeader.user_data_size = 0; + header->fileHeader.file_size = swap_uint(cineon->element[0].dataOffset + cineon->height * getRowLength(cineon->width, cineon->element[0]), cineon->isMSB); + strcpy(header->fileHeader.version, "v4.5"); + strncpy(header->fileHeader.file_name, filename, 99); + header->fileHeader.file_name[99] = 0; + fileClock = time(0); + fileTime = localtime(&fileClock); + strftime(header->fileHeader.creation_date, 12, "%Y:%m:%d", fileTime); + strftime(header->fileHeader.creation_time, 12, "%H:%M:%S%Z", fileTime); + header->fileHeader.creation_time[11] = 0; + + /* --- Image header --- */ + header->imageHeader.orientation = 0; + header->imageHeader.elements_per_image = cineon->depth; + + for (i = 0; i < 3; i++) { + header->imageHeader.element[i].descriptor1 = 0; + header->imageHeader.element[i].descriptor2 = i; + header->imageHeader.element[i].bits_per_sample = cineon->element[0].bitsPerSample; + header->imageHeader.element[i].pixels_per_line = swap_uint(cineon->width, cineon->isMSB); + header->imageHeader.element[i].lines_per_image = swap_uint(cineon->height, cineon->isMSB); + header->imageHeader.element[i].ref_low_data = swap_uint(cineon->element[0].refLowData, cineon->isMSB); + header->imageHeader.element[i].ref_low_quantity = swap_float(cineon->element[0].refLowQuantity, cineon->isMSB); + header->imageHeader.element[i].ref_high_data = swap_uint(cineon->element[0].refHighData, cineon->isMSB); + header->imageHeader.element[i].ref_high_quantity = swap_float(cineon->element[0].refHighQuantity, cineon->isMSB); + } + + header->imageHeader.white_point_x = swap_float(0.0f, cineon->isMSB); + header->imageHeader.white_point_y = swap_float(0.0f, cineon->isMSB); + header->imageHeader.red_primary_x = swap_float(0.0f, cineon->isMSB); + header->imageHeader.red_primary_y = swap_float(0.0f, cineon->isMSB); + header->imageHeader.green_primary_x = swap_float(0.0f, cineon->isMSB); + header->imageHeader.green_primary_y = swap_float(0.0f, cineon->isMSB); + header->imageHeader.blue_primary_x = swap_float(0.0f, cineon->isMSB); + header->imageHeader.blue_primary_y = swap_float(0.0f, cineon->isMSB); + strncpy(header->imageHeader.label, creator, 199); + header->imageHeader.label[199] = 0; + header->imageHeader.interleave = 0; + header->imageHeader.data_sign = 0; + header->imageHeader.sense = 0; + header->imageHeader.line_padding = swap_uint(0, cineon->isMSB); + header->imageHeader.element_padding = swap_uint(0, cineon->isMSB); + + switch (cineon->element[0].packing) { + case 0: + header->imageHeader.packing = 0; + break; + + case 1: + header->imageHeader.packing = 5; + break; + + case 2: + header->imageHeader.packing = 6; + break; + } + + /* --- Origination header --- */ + /* we leave it blank */ + + /* --- Film header --- */ + /* we leave it blank */ } -int -cineonGetRow(CineonFile* cineon, unsigned short* row, int y) { - - int longsRead; - int pixelIndex; - int longIndex; -/* int numPixels = cineon->width * cineon->depth; -*/ - /* only seek if not reading consecutive lines */ - if (y != cineon->fileYPos) { - int lineOffset = cineon->imageOffset + y * cineon->lineBufferLength * 4; - if (verbose) d_printf("Seek in getRow\n"); - if (logimage_fseek(cineon, lineOffset, SEEK_SET) != 0) { - if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, lineOffset); - return 1; - } - cineon->fileYPos = y; - } - - longsRead = logimage_fread(cineon->lineBuffer, 4, cineon->lineBufferLength, cineon); - if (longsRead != cineon->lineBufferLength) { - if (verbose) d_printf("Couldn't read line %d length %d\n", y, cineon->lineBufferLength * 4); - return 1; - } +LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize) +{ + CineonMainHeader header; + LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__); + char *filename = (char *)byteStuff; + int i; + unsigned int dataOffset; - /* remember where we left the car, honey */ - ++cineon->fileYPos; - - /* convert longwords to pixels */ - pixelIndex = 0; - for (longIndex = 0; longIndex < cineon->lineBufferLength; ++longIndex) { - unsigned int t = ntohl(cineon->lineBuffer[longIndex]); - t = t >> 2; - row[pixelIndex+2] = (unsigned short) t & 0x3ff; - t = t >> 10; - row[pixelIndex+1] = (unsigned short) t & 0x3ff; - t = t >> 10; - row[pixelIndex] = (unsigned short) t & 0x3ff; - pixelIndex += 3; + if (cineon == 0) { + if (verbose) printf("Cineon: Failed to malloc cineon file structure.\n"); + return 0; } - return 0; -} + /* zero the header */ + memset(&header, 0, sizeof(CineonMainHeader)); -int -cineonSetRow(CineonFile* cineon, const unsigned short* row, int y) { - - int pixelIndex; -/* int numPixels = cineon->width * cineon->depth; -*/ int longIndex; - int longsWritten; - - /* pack into longwords */ - pixelIndex = 0; - for (longIndex = 0; longIndex < cineon->lineBufferLength; ++longIndex) { - unsigned int t = - (row[pixelIndex] << 22) | - (row[pixelIndex+1] << 12) | - (row[pixelIndex+2] << 2); - cineon->lineBuffer[longIndex] = htonl(t); - pixelIndex += 3; - } + /* for close routine */ + cineon->file = 0; - /* only seek if not reading consecutive lines */ - if (y != cineon->fileYPos) { - int lineOffset = cineon->imageOffset + y * cineon->lineBufferLength * 4; - if (verbose) d_printf("Seek in setRowBytes\n"); - if (logimage_fseek(cineon, lineOffset, SEEK_SET) != 0) { - if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, lineOffset); - return 1; + if (fromMemory == 0) { + /* byteStuff is then the filename */ + cineon->file = BLI_fopen(filename, "rb"); + if (cineon->file == 0) { + if (verbose) printf("Cineon: Failed to open file \"%s\".\n", filename); + logImageClose(cineon); + return 0; } - cineon->fileYPos = y; + /* not used in this case */ + cineon->memBuffer = 0; + cineon->memCursor = 0; + cineon->memBufferSize = 0; } - - longsWritten = fwrite(cineon->lineBuffer, 4, cineon->lineBufferLength, cineon->file); - if (longsWritten != cineon->lineBufferLength) { - if (verbose) d_printf("Couldn't write line %d length %d\n", y, cineon->lineBufferLength * 4); - return 1; + else { + cineon->memBuffer = (unsigned char *)byteStuff; + cineon->memCursor = (unsigned char *)byteStuff; + cineon->memBufferSize = bufferSize; } - ++cineon->fileYPos; - - return 0; -} - -CineonFile* -cineonOpen(const char* filename) { - - CineonGenericHeader header; - - CineonFile* cineon = (CineonFile* )malloc(sizeof(CineonFile)); - if (cineon == 0) { - if (verbose) d_printf("Failed to malloc cineon file structure.\n"); + if (logimage_fread(&header, sizeof(header), 1, cineon) == 0) { + if (verbose) printf("Cineon: Not enough data for header in \"%s\".\n", byteStuff); + logImageClose(cineon); return 0; } - /* for close routine */ - cineon->file = 0; - cineon->lineBuffer = 0; - cineon->pixelBuffer = 0; - cineon->membuffer = 0; - cineon->memcursor = 0; - cineon->membuffersize = 0; - - cineon->file = BLI_fopen(filename, "rb"); - if (cineon->file == 0) { - if (verbose) d_printf("Failed to open file \"%s\".\n", filename); - cineonClose(cineon); - return 0; + /* endianness determination */ + if (header.fileHeader.magic_num == swap_uint(CINEON_FILE_MAGIC, 1)) { + cineon->isMSB = 1; + if (verbose) printf("Cineon: File is MSB.\n"); } - cineon->reading = 1; - - if (logimage_fread(&header, sizeof(CineonGenericHeader), 1, cineon) == 0) { - if (verbose) d_printf("Not enough data for header in \"%s\".\n", filename); - cineonClose(cineon); - return 0; + else if (header.fileHeader.magic_num == CINEON_FILE_MAGIC) { + cineon->isMSB = 0; + if (verbose) printf("Cineon: File is LSB.\n"); } - - /* let's assume cineon files are always network order */ - if (header.fileInfo.magic_num != ntohl(CINEON_FILE_MAGIC)) { - if (verbose) d_printf("Bad magic number %8.8lX in \"%s\".\n", - (uintptr_t)ntohl(header.fileInfo.magic_num), filename); - cineonClose(cineon); + else { + if (verbose) printf("Cineon: Bad magic number %lu in \"%s\".\n", + (uintptr_t)header.fileHeader.magic_num, byteStuff); + logImageClose(cineon); return 0; } - if (header.formatInfo.packing != 5) { - if (verbose) d_printf("Can't understand packing %d\n", header.formatInfo.packing); - cineonClose(cineon); - return 0; - } + cineon->width = swap_uint(header.imageHeader.element[0].pixels_per_line, cineon->isMSB); + cineon->height = swap_uint(header.imageHeader.element[0].lines_per_image, cineon->isMSB); + cineon->depth = header.imageHeader.elements_per_image; + cineon->srcFormat = format_Cineon; - cineon->width = ntohl(header.imageInfo.channel[0].pixels_per_line); - cineon->height = ntohl(header.imageInfo.channel[0].lines_per_image); - cineon->depth = header.imageInfo.channels_per_image; - /* cineon->bitsPerPixel = 10; */ - cineon->bitsPerPixel = header.imageInfo.channel[0].bits_per_pixel; - cineon->imageOffset = ntohl(header.fileInfo.image_offset); - - cineon->lineBufferLength = pixelsToLongs(cineon->width * cineon->depth); - cineon->lineBuffer = malloc(cineon->lineBufferLength * 4); - if (cineon->lineBuffer == 0) { - if (verbose) d_printf("Couldn't malloc line buffer of size %d\n", cineon->lineBufferLength * 4); - cineonClose(cineon); + if (header.imageHeader.interleave == 0) + cineon->numElements = 1; + else if (header.imageHeader.interleave == 2) + cineon->numElements = header.imageHeader.elements_per_image; + else { + if (verbose) printf("Cineon: Data interleave not supported: %d\n", header.imageHeader.interleave); return 0; } - cineon->pixelBuffer = malloc(cineon->lineBufferLength * 3 * sizeof(unsigned short)); - if (cineon->pixelBuffer == 0) { - if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n", - (cineon->width * cineon->depth) * (int)sizeof(unsigned short)); - cineonClose(cineon); - return 0; + if (cineon->depth == 1) { + /* Grayscale image */ + cineon->element[0].descriptor = descriptor_Luminance; + cineon->element[0].transfer = transfer_Linear; + cineon->element[0].depth = 1; } - cineon->pixelBufferUsed = 0; - - if (logimage_fseek(cineon, cineon->imageOffset, SEEK_SET) != 0) { - if (verbose) d_printf("Couldn't seek to image data at %d\n", cineon->imageOffset); - cineonClose(cineon); - return 0; + else if (cineon->depth == 3) { + /* RGB image */ + if (cineon->numElements == 1) { + cineon->element[0].descriptor = descriptor_RGB; + cineon->element[0].transfer = transfer_PrintingDensity; + cineon->element[0].depth = 3; + } + else if (cineon->numElements == 3) { + cineon->element[0].descriptor = descriptor_Red; + cineon->element[0].transfer = transfer_PrintingDensity; + cineon->element[0].depth = 1; + cineon->element[1].descriptor = descriptor_Green; + cineon->element[1].transfer = transfer_PrintingDensity; + cineon->element[1].depth = 1; + cineon->element[2].descriptor = descriptor_Blue; + cineon->element[2].transfer = transfer_PrintingDensity; + cineon->element[2].depth = 1; + } } - cineon->fileYPos = 0; - - logImageGetByteConversionDefaults(&cineon->params); - setupLut(cineon); - - cineon->getRow = &cineonGetRowBytes; - cineon->setRow = 0; - cineon->close = &cineonClose; - - if (verbose) { - verboseMe(cineon); + else { + if (verbose) printf("Cineon: Cineon image depth unsupported: %d\n", cineon->depth); + return 0; } - return cineon; -} + dataOffset = swap_uint(header.fileHeader.offset, cineon->isMSB); -int cineonIsMemFileCineon(unsigned char *mem) -{ - unsigned int num; - memcpy(&num, mem, sizeof(unsigned int)); - - if (num != ntohl(CINEON_FILE_MAGIC)) { - return 0; - } - else return 1; -} + for (i = 0; i < cineon->numElements; i++) { + cineon->element[i].bitsPerSample = header.imageHeader.element[i].bits_per_sample; + cineon->element[i].maxValue = powf(2, cineon->element[i].bitsPerSample) - 1.0f; + cineon->element[i].refLowData = swap_uint(header.imageHeader.element[i].ref_low_data, cineon->isMSB); + cineon->element[i].refLowQuantity = swap_float(header.imageHeader.element[i].ref_low_quantity, cineon->isMSB); + cineon->element[i].refHighData = swap_uint(header.imageHeader.element[i].ref_high_data, cineon->isMSB); + cineon->element[i].refHighQuantity = swap_float(header.imageHeader.element[i].ref_high_quantity, cineon->isMSB); -CineonFile* -cineonOpenFromMem(unsigned char *mem, unsigned int size) { + switch (header.imageHeader.packing) { + case 0: + cineon->element[i].packing = 0; + break; - CineonGenericHeader header; - - CineonFile* cineon = (CineonFile* )malloc(sizeof(CineonFile)); - if (cineon == 0) { - if (verbose) d_printf("Failed to malloc cineon file structure.\n"); - return 0; - } + case 5: + cineon->element[i].packing = 1; + break; - /* for close routine */ - cineon->file = 0; - cineon->lineBuffer = 0; - cineon->pixelBuffer = 0; - cineon->membuffer = mem; - cineon->membuffersize = size; - cineon->memcursor = mem; - - cineon->file = 0; - cineon->reading = 1; - verbose = 0; - if (size < sizeof(CineonGenericHeader)) { - if (verbose) d_printf("Not enough data for header!\n"); - cineonClose(cineon); - return 0; - } + case 6: + cineon->element[i].packing = 2; + break; - logimage_fread(&header, sizeof(CineonGenericHeader), 1, cineon); + default: + /* Not supported */ + if (verbose) printf("Cineon: packing unsupported: %d\n", header.imageHeader.packing); + return 0; + } - /* let's assume cineon files are always network order */ - if (header.fileInfo.magic_num != ntohl(CINEON_FILE_MAGIC)) { - if (verbose) d_printf("Bad magic number %8.8lX in\n", (uintptr_t)ntohl(header.fileInfo.magic_num)); + if (cineon->element[i].refLowData == CINEON_UNDEFINED_U32 || isnan(cineon->element[i].refLowData)) + cineon->element[i].refLowData = 0; - cineonClose(cineon); - return 0; - } + if (cineon->element[i].refHighData == CINEON_UNDEFINED_U32 || isnan(cineon->element[i].refHighData)) + cineon->element[i].refHighData = (unsigned int)cineon->element[i].maxValue; - if (header.formatInfo.packing != 5) { - if (verbose) d_printf("Can't understand packing %d\n", header.formatInfo.packing); - cineonClose(cineon); - return 0; - } + if (cineon->element[i].refLowQuantity == CINEON_UNDEFINED_R32 || isnan(cineon->element[i].refLowQuantity)) + cineon->element[i].refLowQuantity = 0.0f; - cineon->width = ntohl(header.imageInfo.channel[0].pixels_per_line); - cineon->height = ntohl(header.imageInfo.channel[0].lines_per_image); - cineon->depth = header.imageInfo.channels_per_image; - /* cineon->bitsPerPixel = 10; */ - cineon->bitsPerPixel = header.imageInfo.channel[0].bits_per_pixel; - cineon->imageOffset = ntohl(header.fileInfo.image_offset); - - cineon->lineBufferLength = pixelsToLongs(cineon->width * cineon->depth); - cineon->lineBuffer = malloc(cineon->lineBufferLength * 4); - if (cineon->lineBuffer == 0) { - if (verbose) d_printf("Couldn't malloc line buffer of size %d\n", cineon->lineBufferLength * 4); - cineonClose(cineon); - return 0; - } + if (cineon->element[i].refHighQuantity == CINEON_UNDEFINED_R32 || isnan(cineon->element[i].refHighQuantity)) { + if (cineon->element[i].transfer == transfer_PrintingDensity) + cineon->element[i].refHighQuantity = 2.048f; + else + cineon->element[i].refHighQuantity = cineon->element[i].maxValue; + } - cineon->pixelBuffer = malloc(cineon->lineBufferLength * 3 * sizeof(unsigned short)); - if (cineon->pixelBuffer == 0) { - if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n", - (cineon->width * cineon->depth) * (int)sizeof(unsigned short)); - cineonClose(cineon); - return 0; - } - cineon->pixelBufferUsed = 0; - - if (logimage_fseek(cineon, cineon->imageOffset, SEEK_SET) != 0) { - if (verbose) d_printf("Couldn't seek to image data at %d\n", cineon->imageOffset); - cineonClose(cineon); - return 0; + cineon->element[i].dataOffset = dataOffset; + dataOffset += cineon->height * getRowLength(cineon->width, cineon->element[i]); } - - cineon->fileYPos = 0; - - logImageGetByteConversionDefaults(&cineon->params); - setupLut(cineon); - cineon->getRow = &cineonGetRowBytes; - cineon->setRow = 0; - cineon->close = &cineonClose; + cineon->referenceBlack = 95.0f / 1023.0f * cineon->element[0].maxValue; + cineon->referenceWhite = 685.0f / 1023.0f * cineon->element[0].maxValue; + cineon->gamma = 1.7f; if (verbose) { - verboseMe(cineon); - } + printf("size %d x %d x %d elements\n", cineon->width, cineon->height, cineon->numElements); + for (i = 0; i < cineon->numElements; i++) { + printf(" Element %d:\n", i); + printf(" Bits per sample: %d\n", cineon->element[i].bitsPerSample); + printf(" Depth: %d\n", cineon->element[i].depth); + printf(" Transfer characteristics: %d\n", cineon->element[i].transfer); + printf(" Packing: %d\n", cineon->element[i].packing); + printf(" Descriptor: %d\n", cineon->element[i].descriptor); + printf(" Data offset: %u\n", cineon->element[i].dataOffset); + printf(" Reference low data: %u\n", cineon->element[i].refLowData); + printf(" Reference low quantity: %f\n", cineon->element[i].refLowQuantity); + printf(" Reference high data: %u\n", cineon->element[i].refHighData); + printf(" Reference high quantity: %f\n", cineon->element[i].refHighQuantity); + printf("\n"); + } + printf("Gamma: %f\n", cineon->gamma); + printf("Reference black: %f\n", cineon->referenceBlack); + printf("Reference white: %f\n", cineon->referenceWhite); + printf("----------------------------\n"); + } return cineon; } +LogImageFile *cineonCreate(const char *filename, int width, int height, int bitsPerSample, const char *creator) +{ + CineonMainHeader header; + const char *shortFilename = 0; + /* unsigned char pad[6044]; */ -int -cineonGetSize(const CineonFile* cineon, int* width, int* height, int* depth) { - *width = cineon->width; - *height = cineon->height; - *depth = cineon->depth; - return 0; -} - -CineonFile* -cineonCreate(const char* filename, int width, int height, int depth) { - - /* Note: always write files in network order */ - /* By the spec, it shouldn't matter, but ... */ - - CineonGenericHeader header; - const char* shortFilename = 0; - - CineonFile* cineon = (CineonFile*)malloc(sizeof(CineonFile)); + LogImageFile *cineon = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__); if (cineon == 0) { - if (verbose) d_printf("Failed to malloc cineon file structure.\n"); + if (verbose) printf("cineon: Failed to malloc cineon file structure.\n"); return 0; } - memset(&header, 0, sizeof(header)); - - /* for close routine */ - cineon->file = 0; - cineon->lineBuffer = 0; - cineon->pixelBuffer = 0; - - cineon->file = BLI_fopen(filename, "wb"); - if (cineon->file == 0) { - if (verbose) d_printf("Couldn't open file %s\n", filename); - cineonClose(cineon); + /* Only 10 bits Cineon are supported */ + if (bitsPerSample != 10) { + if (verbose) printf("cineon: Only 10 bits Cineon are supported.\n"); + logImageClose(cineon); return 0; } - cineon->reading = 0; cineon->width = width; cineon->height = height; - cineon->depth = depth; - cineon->bitsPerPixel = 10; - cineon->imageOffset = sizeof(CineonGenericHeader); - - cineon->lineBufferLength = pixelsToLongs(cineon->width * cineon->depth); - cineon->lineBuffer = malloc(cineon->lineBufferLength * 4); - if (cineon->lineBuffer == 0) { - if (verbose) d_printf("Couldn't malloc line buffer of size %d\n", cineon->lineBufferLength * 4); - cineonClose(cineon); - return 0; - } + cineon->element[0].bitsPerSample = 10; + cineon->element[0].dataOffset = sizeof(CineonMainHeader); + cineon->element[0].maxValue = 1023; + cineon->isMSB = 1; + cineon->numElements = 1; + cineon->element[0].packing = 1; + cineon->depth = 3; + cineon->element[0].depth = 3; + cineon->element[0].descriptor = descriptor_RGB; + cineon->element[0].transfer = transfer_PrintingDensity; + cineon->element[0].refHighQuantity = 2.048f; + cineon->element[0].refLowQuantity = 0; + cineon->element[0].refLowData = 0; + cineon->element[0].refHighData = cineon->element[0].maxValue; + cineon->referenceWhite = 685.0f; + cineon->referenceBlack = 95.0f; + cineon->gamma = 1.7f; - cineon->pixelBuffer = malloc(cineon->lineBufferLength * 3 * sizeof(unsigned short)); - if (cineon->pixelBuffer == 0) { - if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n", - (cineon->width * cineon->depth) * (int)sizeof(unsigned short)); - cineonClose(cineon); - return 0; - } - cineon->pixelBufferUsed = 0; - - /* find trailing part of filename */ shortFilename = strrchr(filename, '/'); - if (shortFilename == 0) { + if (shortFilename == 0) shortFilename = filename; - } - else { - ++shortFilename; - } + else + shortFilename++; - if (initCineonGenericHeader(cineon, &header, shortFilename) != 0) { - cineonClose(cineon); + cineon->file = BLI_fopen(filename, "wb"); + if (cineon->file == 0) { + if (verbose) printf("cineon: Couldn't open file %s\n", filename); + logImageClose(cineon); return 0; } + fillCineonMainHeader(cineon, &header, shortFilename, creator); + if (fwrite(&header, sizeof(header), 1, cineon->file) == 0) { - if (verbose) d_printf("Couldn't write image header\n"); - cineonClose(cineon); + if (verbose) printf("cineon: Couldn't write image header\n"); + logImageClose(cineon); return 0; } - cineon->fileYPos = 0; - - logImageGetByteConversionDefaults(&cineon->params); - setupLut(cineon); - - cineon->getRow = 0; - cineon->setRow = &cineonSetRowBytes; - cineon->close = &cineonClose; return cineon; } - -void -cineonClose(CineonFile* cineon) { - - if (cineon == 0) { - return; - } - - if (cineon->file) { - fclose(cineon->file); - cineon->file = 0; - } - - if (cineon->lineBuffer) { - free(cineon->lineBuffer); - cineon->lineBuffer = 0; - } - - if (cineon->pixelBuffer) { - free(cineon->pixelBuffer); - cineon->pixelBuffer = 0; - } - - free(cineon); -} diff --git a/source/blender/imbuf/intern/cineon/cineonlib.h b/source/blender/imbuf/intern/cineon/cineonlib.h index ef992c527b0..9333743a1bf 100644 --- a/source/blender/imbuf/intern/cineon/cineonlib.h +++ b/source/blender/imbuf/intern/cineon/cineonlib.h @@ -1,68 +1,142 @@ /* - * Cineon image file format library definitions. - * Also handles DPX files (almost) + * Cineon image file format library definitions. + * Also handles DPX files (almost) * - * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> + * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> * - * 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 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. + * 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. + * 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. + * + * Contributor(s): Julien Enche. * */ -#ifndef __CINEONLIB_H__ -#define __CINEONLIB_H__ - /** \file blender/imbuf/intern/cineon/cineonlib.h * \ingroup imbcineon */ -#include "logImageCore.h" + +#ifndef __CINEON_LIB_H__ +#define __CINEON_LIB_H__ #ifdef __cplusplus extern "C" { #endif -/* - * Cineon image structure. You don't care what this is. - */ +#include "logImageCore.h" -typedef struct _Log_Image_File_t_ CineonFile; +#define CINEON_FILE_MAGIC 0x802A5FD7 +#define CINEON_UNDEFINED_U8 0xFF +#define CINEON_UNDEFINED_U16 0xFFFF +#define CINEON_UNDEFINED_U32 0xFFFFFFFF +#define CINEON_UNDEFINED_R32 0x7F800000 +#define CINEON_UNDEFINED_CHAR 0 -/* int functions return 0 for OK */ +typedef struct { + unsigned int magic_num; + unsigned int offset; + unsigned int gen_hdr_size; + unsigned int ind_hdr_size; + unsigned int user_data_size; + unsigned int file_size; + char version[8]; + char file_name[100]; + char creation_date[12]; + char creation_time[12]; + char reserved[36]; +} CineonFileHeader; -void cineonSetVerbose(int); +typedef struct { + unsigned char descriptor1; + unsigned char descriptor2; + unsigned char bits_per_sample; + unsigned char filler; + unsigned int pixels_per_line; + unsigned int lines_per_image; + unsigned int ref_low_data; + float ref_low_quantity; + unsigned int ref_high_data; + float ref_high_quantity; +} CineonElementHeader; -CineonFile* cineonOpenFromMem(unsigned char *mem, unsigned int size); +typedef struct { + unsigned char orientation; + unsigned char elements_per_image; + unsigned short filler; + CineonElementHeader element[8]; + float white_point_x; + float white_point_y; + float red_primary_x; + float red_primary_y; + float green_primary_x; + float green_primary_y; + float blue_primary_x; + float blue_primary_y; + char label[200]; + char reserved[28]; + unsigned char interleave; + unsigned char packing; + unsigned char data_sign; + unsigned char sense; + unsigned int line_padding; + unsigned int element_padding; + char reserved2[20]; +} CineonImageHeader; -CineonFile* cineonOpen(const char* filename); -int cineonGetSize(const CineonFile* cineon, int* xsize, int* ysize, int* channels); -CineonFile* cineonCreate(const char* filename, int xsize, int ysize, int channels); -int cineonIsMemFileCineon(unsigned char *mem); +typedef struct { + int x_offset; + int y_offset; + char file_name[100]; + char creation_date[12]; + char creation_time[12]; + char input_device[64]; + char model_number[32]; + char input_serial_number[32]; + float x_input_samples_per_mm; + float y_input_samples_per_mm; + float input_device_gamma; + char reserved[40]; +} CineonOriginationHeader; -/* get/set scanline of converted bytes */ -int cineonGetRowBytes(CineonFile* cineon, unsigned short* row, int y); -int cineonSetRowBytes(CineonFile* cineon, const unsigned short* row, int y); +typedef struct { + unsigned char film_code; + unsigned char film_type; + unsigned char edge_code_perforation_offset; + unsigned char filler; + unsigned int prefix; + unsigned int count; + char format[32]; + unsigned int frame_position; + float frame_rate; + char attribute[32]; + char slate[200]; + char reserved[740]; +} CineonFilmHeader; -/* get/set scanline of unconverted shorts */ -int cineonGetRow(CineonFile* cineon, unsigned short* row, int y); -int cineonSetRow(CineonFile* cineon, const unsigned short* row, int y); +typedef struct { + CineonFileHeader fileHeader; + CineonImageHeader imageHeader; + CineonOriginationHeader originationHeader; + CineonFilmHeader filmHeader; +} CineonMainHeader; -/* closes file and deletes data */ -void cineonClose(CineonFile* cineon); +void cineonSetVerbose(int); +LogImageFile *cineonOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize); +LogImageFile *cineonCreate(const char *filename, int width, int height, int bitsPerSample, const char *creator); #ifdef __cplusplus } #endif -#endif /* __CINEONLIB_H__ */ +#endif /* __CINEON_LIB_H__ */ diff --git a/source/blender/imbuf/intern/cineon/dpxfile.h b/source/blender/imbuf/intern/cineon/dpxfile.h index e1d95268a80..e69de29bb2d 100644 --- a/source/blender/imbuf/intern/cineon/dpxfile.h +++ b/source/blender/imbuf/intern/cineon/dpxfile.h @@ -1,128 +0,0 @@ -/* - * Cineon image file format library definitions. - * Dpx file format structures. - * - * This header file contains private details. - * User code should generally use cineonlib.h only. - * - * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> - * - * 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. - * - */ - -#ifndef __DPXFILE_H__ -#define __DPXFILE_H__ - -/** \file blender/imbuf/intern/cineon/dpxfile.h - * \ingroup imbcineon - */ - -#include "logImageCore.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - U32 magic_num; /* magic number */ - U32 offset; /* offset to image data in bytes */ - ASCII vers[8]; /* which header format version is being used (v1.0) */ - U32 file_size; /* file size in bytes */ - U32 ditto_key; /* I bet some people use this */ - U32 gen_hdr_size; /* generic header length in bytes */ - U32 ind_hdr_size; /* industry header length in bytes */ - U32 user_data_size; /* user-defined data length in bytes */ - ASCII file_name[100]; /* image file name */ - ASCII create_date[24]; /* file creation date, yyyy:mm:dd:hh:mm:ss:LTZ */ - ASCII creator[100]; - ASCII project[200]; - ASCII copyright[200]; - U32 key; /* encryption key, FFFFFFF = unencrypted */ - ASCII Reserved[104]; /* reserved field TBD (need to pad) */ -} DpxFileInformation; - -typedef struct { - U32 signage; - U32 ref_low_data; /* reference low data code value */ - R32 ref_low_quantity; /* reference low quantity represented */ - U32 ref_high_data; /* reference high data code value */ - R32 ref_high_quantity;/* reference high quantity represented */ - U8 designator1; - U8 transfer_characteristics; - U8 colorimetry; - U8 bits_per_pixel; - U16 packing; - U16 encoding; - U32 data_offset; - U32 line_padding; - U32 channel_padding; - ASCII description[32]; -} DpxChannelInformation; - -typedef struct { - U16 orientation; - U16 channels_per_image; - U32 pixels_per_line; - U32 lines_per_image; - DpxChannelInformation channel[8]; - ASCII reserved[52]; -} DpxImageInformation; - -typedef struct { - U32 x_offset; - U32 y_offset; - R32 x_centre; - R32 y_centre; - U32 x_original_size; - U32 y_original_size; - ASCII file_name[100]; - ASCII creation_time[24]; - ASCII input_device[32]; - ASCII input_serial_number[32]; - U16 border_validity[4]; - U32 pixel_aspect_ratio[2]; /* h:v */ - ASCII reserved[28]; -} DpxOriginationInformation; - -typedef struct { - ASCII film_manufacturer_id[2]; - ASCII film_type[2]; - ASCII edge_code_perforation_offset[2]; - ASCII edge_code_prefix[6]; - ASCII edge_code_count[4]; - ASCII film_format[32]; - U32 frame_position; - U32 sequence_length; - U32 held_count; - R32 frame_rate; - R32 shutter_angle; - ASCII frame_identification[32]; - ASCII slate_info[100]; - ASCII reserved[56]; -} DpxMPIInformation; - -typedef struct { - DpxFileInformation fileInfo; - DpxImageInformation imageInfo; - DpxOriginationInformation originInfo; - DpxMPIInformation filmHeader; -} DpxMainHeader; - -#ifdef __cplusplus -} -#endif - -#endif /* __DPXFILE_H__ */ diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c index c1138225e93..aedce52a7bf 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.c +++ b/source/blender/imbuf/intern/cineon/dpxlib.c @@ -1,21 +1,23 @@ /* - * Dpx image file format library routines. + * Dpx image file format library routines. * - * Copyright 1999 - 2002 David Hodson <hodsond@acm.org> + * Copyright 1999 - 2002 David Hodson <hodsond@acm.org> * - * 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 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. + * 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. + * 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. + * + * Contributor(s): Julien Enche. * */ @@ -23,689 +25,445 @@ * \ingroup imbcineon */ -#include "dpxfile.h" + #include "dpxlib.h" +#include "logmemfile.h" #include <stdio.h> #include <math.h> #include <stdlib.h> -#include <time.h> /* strftime() */ +#include <time.h> #include <sys/types.h> -#ifdef WIN32 -#include <winsock.h> -#else -#include <netinet/in.h> /* htonl() */ -#endif -#include <string.h> /* memset */ -#include "cin_debug_stuff.h" -#include "logmemfile.h" -#include "BLI_fileops.h" - -static void -fillDpxChannelInfo(DpxFile* dpx, DpxChannelInformation* chan, int des) { - - (void)dpx; /* unused */ - - chan->signage = 0; - chan->ref_low_data = htonl(0); - chan->ref_low_quantity = htonf(0.0); - chan->ref_high_data = htonl(1023); - chan->ref_high_quantity = htonf(2.046); - chan->designator1 = des; - chan->transfer_characteristics = 0; - chan->colorimetry = 0; - chan->bits_per_pixel = 10; - chan->packing = htons(1); - chan->encoding = 0; - chan->data_offset = 0; - chan->line_padding = htonl(0); - chan->channel_padding = htonl(0); - chan->description[0] = 0; -} - -static void -dumpDpxChannelInfo(DpxChannelInformation* chan) { - d_printf(" Signage %ld", (intptr_t)ntohl(chan->signage)); - d_printf(" Ref low data %ld\n", (intptr_t)ntohl(chan->ref_low_data)); - d_printf(" Ref low quantity %f\n", ntohf(chan->ref_low_quantity)); - d_printf(" Ref high data %ld\n", (intptr_t)ntohl(chan->ref_high_data)); - d_printf(" Ref high quantity %f\n", ntohf(chan->ref_high_quantity)); - d_printf(" Designator1: %d,", chan->designator1); - d_printf(" Bits per pixel %d\n", chan->bits_per_pixel); - d_printf(" Packing: %d,", ntohs(chan->packing)); - d_printf(" Data Offset: %ld,", (intptr_t)ntohl(chan->data_offset)); -} - -static void -fillDpxFileInfo( - DpxFile* dpx, DpxFileInformation* fileInfo, const char* filename) { - - time_t fileClock; - struct tm* fileTime; - - /* Note: always write files in network order */ - /* By the spec, it shouldn't matter, but ... */ - - fileInfo->magic_num = htonl(DPX_FILE_MAGIC); - fileInfo->offset = htonl(dpx->imageOffset); - strcpy(fileInfo->vers, "v1.0"); - fileInfo->file_size = htonl(dpx->imageOffset + - pixelsToLongs(dpx->height * dpx->width * dpx->depth) * 4); - fileInfo->ditto_key = 0; - fileInfo->gen_hdr_size = htonl( - sizeof(DpxFileInformation) + - sizeof(DpxImageInformation) + - sizeof(DpxOriginationInformation)); - fileInfo->ind_hdr_size = htonl(sizeof(DpxMPIInformation)); - fileInfo->user_data_size = 0; - strncpy(fileInfo->file_name, filename, 99); - fileInfo->file_name[99] = 0; +#include <string.h> - fileClock = time(0); - fileTime = localtime(&fileClock); - strftime(fileInfo->create_date, 24, "%Y:%m:%d:%H:%M:%S%Z", fileTime); - /* Question: is %Z in strftime guaranteed to return 3 chars? */ - fileInfo->create_date[23] = 0; - - strcpy(fileInfo->creator, "David's DPX writer"); - fileInfo->project[0] = 0; - fileInfo->copyright[0] = 0; - fileInfo->key = 0xFFFFFFFF; /* same in any byte order */ -} +#include "BLI_fileops.h" +#include "BLI_math_base.h" +#include "BLI_utildefines.h" -static void -dumpDpxFileInfo(DpxFileInformation* fileInfo) { - d_printf("\n--File Information--\n"); - d_printf("Magic: %8.8lX\n", (unsigned long)ntohl(fileInfo->magic_num)); - d_printf("Image Offset %ld\n", (intptr_t)ntohl(fileInfo->offset)); - d_printf("Version \"%s\"\n", fileInfo->vers); - d_printf("File size %ld\n", (intptr_t)ntohl(fileInfo->file_size)); - d_printf("Ditto key %ld\n", (intptr_t)ntohl(fileInfo->ditto_key)); - d_printf("Generic Header size %ld\n", (intptr_t)ntohl(fileInfo->gen_hdr_size)); - d_printf("Industry Header size %ld\n", (intptr_t)ntohl(fileInfo->ind_hdr_size)); - d_printf("User Data size %ld\n", (intptr_t)ntohl(fileInfo->user_data_size)); - d_printf("File name \"%s\"\n", fileInfo->file_name); - d_printf("Creation date \"%s\"\n", fileInfo->create_date); - d_printf("Creator \"%s\"\n", fileInfo->creator); - d_printf("Project \"%s\"\n", fileInfo->project); - d_printf("Copyright \"%s\"\n", fileInfo->copyright); - d_printf("Key %ld\n", (intptr_t)ntohl(fileInfo->key)); -} +#include "MEM_guardedalloc.h" -static void -fillDpxImageInfo( - DpxFile* dpx, DpxImageInformation* imageInfo) { - imageInfo->orientation = 0; - imageInfo->channels_per_image = htons(1); - imageInfo->pixels_per_line = htonl(dpx->width); - imageInfo->lines_per_image = htonl(dpx->height); +/* + * For debug purpose + */ - if (dpx->depth == 1) { - fillDpxChannelInfo(dpx, &imageInfo->channel[0], 0); +static int verbose = 0; - } - else if (dpx->depth == 3) { - fillDpxChannelInfo(dpx, &imageInfo->channel[0], 50); - } +void dpxSetVerbose(int verbosity) { + verbose = verbosity; } -static void -dumpDpxImageInfo(DpxImageInformation* imageInfo) { - int n; - int i; - d_printf("\n--Image Information--\n"); - d_printf("Image orientation %d,", ntohs(imageInfo->orientation)); - n = ntohs(imageInfo->channels_per_image); - d_printf("Channels %d\n", n); - d_printf("Pixels per line %ld\n", (intptr_t)ntohl(imageInfo->pixels_per_line)); - d_printf("Lines per image %ld\n", (intptr_t)ntohl(imageInfo->lines_per_image)); - for (i = 0; i < n; ++i) { - d_printf(" --Channel %d--\n", i); - dumpDpxChannelInfo(&imageInfo->channel[i]); - } -} +/* + * Headers + */ -static void -fillDpxOriginationInfo( - DpxFile* dpx, DpxOriginationInformation* originInfo, DpxFileInformation* fileInfo) +static void fillDpxMainHeader(LogImageFile *dpx, DpxMainHeader *header, const char *filename, const char *creator) { - /* unused */ - (void)dpx; - (void)originInfo; - (void)fileInfo; -} - -static void -dumpDpxOriginationInfo(DpxOriginationInformation* originInfo) { - d_printf("\n--Origination Information--\n"); - d_printf("X offset %ld\n", (intptr_t)ntohl(originInfo->x_offset)); - d_printf("Y offset %ld\n", (intptr_t)ntohl(originInfo->y_offset)); - d_printf("X centre %f\n", ntohf(originInfo->x_centre)); - d_printf("Y centre %f\n", ntohf(originInfo->y_centre)); - d_printf("Original X %ld\n", (intptr_t)ntohl(originInfo->x_original_size)); - d_printf("Original Y %ld\n", (intptr_t)ntohl(originInfo->y_original_size)); - d_printf("File name \"%s\"\n", originInfo->file_name); - d_printf("Creation time \"%s\"\n", originInfo->creation_time); - d_printf("Input device \"%s\"\n", originInfo->input_device); - d_printf("Serial number \"%s\"\n", originInfo->input_serial_number); -} + time_t fileClock; + struct tm *fileTime; -static void -initDpxMainHeader(DpxFile* dpx, DpxMainHeader* header, const char* shortFilename) { memset(header, 0, sizeof(DpxMainHeader)); - fillDpxFileInfo(dpx, &header->fileInfo, shortFilename); - fillDpxImageInfo(dpx, &header->imageInfo); - fillDpxOriginationInfo(dpx, &header->originInfo, &header->fileInfo); -#if 0 - fillDpxMPIInfo(dpx, &header->filmHeader); -#endif -} - -static void -dumpDpxMainHeader(DpxMainHeader* header) { - dumpDpxFileInfo(&header->fileInfo); - dumpDpxImageInfo(&header->imageInfo); - dumpDpxOriginationInfo(&header->originInfo); -#if 0 - dumpDpxMPIInformation(&header->filmHeader); -#endif -} - -static int verbose = 0; -void -dpxSetVerbose(int verbosity) { - verbose = verbosity; -} - -static void -verboseMe(DpxFile* dpx) { - - d_printf("size %d x %d x %d\n", dpx->width, dpx->height, dpx->depth); - d_printf("ImageStart %d, lineBufferLength %d, implied length %d\n", - dpx->imageOffset, dpx->lineBufferLength * 4, - dpx->imageOffset + pixelsToLongs(dpx->width * dpx->depth * dpx->height) * 4); -} - -int -dpxGetRowBytes(DpxFile* dpx, unsigned short* row, int y) { - - /* Note: this code is bizarre because DPX files can wrap */ - /* packed longwords across line boundaries!!!! */ - - size_t readLongs; - unsigned int longIndex; - int numPixels = dpx->width * dpx->depth; - int pixelIndex; - - /* only seek if not reading consecutive lines */ - /* this is not quite right yet, need to account for leftovers */ - if (y != dpx->fileYPos) { - int lineOffset = pixelsToLongs(y * dpx->width * dpx->depth) * 4; - if (verbose) d_printf("Seek in getRowBytes\n"); - if (logimage_fseek(dpx, dpx->imageOffset + lineOffset, SEEK_SET) != 0) { - if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, dpx->imageOffset + lineOffset); - return 1; - } - dpx->fileYPos = y; - } - - /* read enough longwords */ - readLongs = pixelsToLongs(numPixels - dpx->pixelBufferUsed); - if (logimage_fread(dpx->lineBuffer, 4, readLongs, dpx) != readLongs) { - if (verbose) d_printf("Couldn't read line %d length %d\n", y, (int)readLongs * 4); - return 1; - } - ++dpx->fileYPos; - - /* convert longwords to pixels */ - pixelIndex = dpx->pixelBufferUsed; - - /* this is just strange */ - if (dpx->depth == 1) { - for (longIndex = 0; longIndex < readLongs; ++longIndex) { - unsigned int t = ntohl(dpx->lineBuffer[longIndex]); - dpx->pixelBuffer[pixelIndex] = t & 0x3ff; - t = t >> 10; - dpx->pixelBuffer[pixelIndex+1] = t & 0x3ff; - t = t >> 10; - dpx->pixelBuffer[pixelIndex+2] = t & 0x3ff; - pixelIndex += 3; - } - } - else /* if (dpx->depth == 3) */ { - for (longIndex = 0; longIndex < readLongs; ++longIndex) { - unsigned int t = ntohl(dpx->lineBuffer[longIndex]); - t = t >> 2; - dpx->pixelBuffer[pixelIndex+2] = t & 0x3ff; - t = t >> 10; - dpx->pixelBuffer[pixelIndex+1] = t & 0x3ff; - t = t >> 10; - dpx->pixelBuffer[pixelIndex] = t & 0x3ff; - pixelIndex += 3; - } - } - dpx->pixelBufferUsed = pixelIndex; - - /* extract required pixels */ - for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) { - if (dpx->params.doLogarithm) - row[pixelIndex] = dpx->lut10_16[dpx->pixelBuffer[pixelIndex]]; - else - row[pixelIndex] = dpx->pixelBuffer[pixelIndex] << 6; - } - - /* save remaining pixels */ - while (pixelIndex < dpx->pixelBufferUsed) { - dpx->pixelBuffer[pixelIndex - numPixels] = dpx->pixelBuffer[pixelIndex]; - ++pixelIndex; - } - dpx->pixelBufferUsed -= numPixels; - /* done! */ - return 0; -} - -int -dpxSetRowBytes(DpxFile* dpx, const unsigned short* row, int y) { - - /* Note: this code is bizarre because DPX files can wrap */ - /* packed longwords across line boundaries!!!! */ - - size_t writeLongs; - int longIndex; - int numPixels = dpx->width * dpx->depth; - int pixelIndex; - int pixelIndex2; - - /* only seek if not reading consecutive lines */ - /* this is not quite right yet */ - if (y != dpx->fileYPos) { - int lineOffset = pixelsToLongs(y * dpx->width * dpx->depth) * 4; - if (verbose) d_printf("Seek in getRowBytes\n"); - if (logimage_fseek(dpx, dpx->imageOffset + lineOffset, SEEK_SET) != 0) { - if (verbose) d_printf("Couldn't seek to line %d at %d\n", y, dpx->imageOffset + lineOffset); - return 1; - } - dpx->fileYPos = y; - } - - /* put new pixels into pixelBuffer */ - for (pixelIndex = 0; pixelIndex < numPixels; ++pixelIndex) { - if (dpx->params.doLogarithm) - dpx->pixelBuffer[dpx->pixelBufferUsed + pixelIndex] = dpx->lut16_16[row[pixelIndex]]; - else - dpx->pixelBuffer[dpx->pixelBufferUsed + pixelIndex] = row[pixelIndex] >> 6; - } - dpx->pixelBufferUsed += numPixels; - - /* pack into longwords */ - writeLongs = dpx->pixelBufferUsed / 3; - /* process whole line at image end */ - if (dpx->fileYPos == (dpx->height - 1)) { - writeLongs = pixelsToLongs(dpx->pixelBufferUsed); - } - pixelIndex = 0; - if (dpx->depth == 1) { - for (longIndex = 0; longIndex < writeLongs; ++longIndex) { - unsigned int t = dpx->pixelBuffer[pixelIndex] | - (dpx->pixelBuffer[pixelIndex+1] << 10) | - (dpx->pixelBuffer[pixelIndex+2] << 20); - dpx->lineBuffer[longIndex] = htonl(t); - pixelIndex += 3; - } - } - else { - for (longIndex = 0; longIndex < writeLongs; ++longIndex) { - unsigned int t = dpx->pixelBuffer[pixelIndex+2] << 2 | - (dpx->pixelBuffer[pixelIndex+1] << 12) | - (dpx->pixelBuffer[pixelIndex] << 22); - dpx->lineBuffer[longIndex] = htonl(t); - pixelIndex += 3; - } - } - - /* write them */ - if (fwrite(dpx->lineBuffer, 4, writeLongs, dpx->file) != writeLongs) { - if (verbose) d_printf("Couldn't write line %d length %d\n", y, (int)writeLongs * 4); - return 1; - } - ++dpx->fileYPos; - - /* save remaining pixels */ - pixelIndex2 = 0; - while (pixelIndex < dpx->pixelBufferUsed) { - dpx->pixelBuffer[pixelIndex2] = dpx->pixelBuffer[pixelIndex]; - ++pixelIndex; - ++pixelIndex2; - } - dpx->pixelBufferUsed = pixelIndex2; - - return 0; + /* --- File header --- */ + header->fileHeader.magic_num = swap_uint(DPX_FILE_MAGIC, dpx->isMSB); + header->fileHeader.offset = swap_uint(dpx->element[0].dataOffset, dpx->isMSB); + strcpy(header->fileHeader.version, "v2.0"); + header->fileHeader.file_size = swap_uint(dpx->element[0].dataOffset + dpx->height * getRowLength(dpx->width, dpx->element[0]), dpx->isMSB); + header->fileHeader.ditto_key = 0; + header->fileHeader.gen_hdr_size = swap_uint(sizeof(DpxFileHeader) + sizeof(DpxImageHeader) + sizeof(DpxOrientationHeader), dpx->isMSB); + header->fileHeader.ind_hdr_size = swap_uint(sizeof(DpxFilmHeader) + sizeof(DpxTelevisionHeader), dpx->isMSB); + header->fileHeader.user_data_size = DPX_UNDEFINED_U32; + strncpy(header->fileHeader.file_name, filename, 99); + header->fileHeader.file_name[99] = 0; + fileClock = time(0); + fileTime = localtime(&fileClock); + strftime(header->fileHeader.creation_date, 24, "%Y:%m:%d:%H:%M:%S%Z", fileTime); + header->fileHeader.creation_date[23] = 0; + strncpy(header->fileHeader.creator, creator, 99); + header->fileHeader.creator[99] = 0; + header->fileHeader.project[0] = 0; + header->fileHeader.copyright[0] = 0; + header->fileHeader.key = 0xFFFFFFFF; + + /* --- Image header --- */ + header->imageHeader.orientation = 0; + header->imageHeader.elements_per_image = swap_ushort(1, dpx->isMSB); + header->imageHeader.pixels_per_line = swap_uint(dpx->width, dpx->isMSB); + header->imageHeader.lines_per_element = swap_uint(dpx->height, dpx->isMSB); + + /* Fills element */ + header->imageHeader.element[0].data_sign = 0; + header->imageHeader.element[0].ref_low_data = swap_uint(dpx->element[0].refLowData, dpx->isMSB); + header->imageHeader.element[0].ref_low_quantity = swap_float(dpx->element[0].refLowQuantity, dpx->isMSB); + header->imageHeader.element[0].ref_high_data = swap_uint(dpx->element[0].refHighData, dpx->isMSB); + header->imageHeader.element[0].ref_high_quantity = swap_float(dpx->element[0].refHighQuantity, dpx->isMSB); + header->imageHeader.element[0].descriptor = dpx->element[0].descriptor; + header->imageHeader.element[0].transfer = dpx->element[0].transfer; + header->imageHeader.element[0].colorimetric = 0; + header->imageHeader.element[0].bits_per_sample = dpx->element[0].bitsPerSample; + header->imageHeader.element[0].packing = swap_ushort(dpx->element[0].packing, dpx->isMSB); + header->imageHeader.element[0].encoding = 0; + header->imageHeader.element[0].data_offset = swap_uint(dpx->element[0].dataOffset, dpx->isMSB); + header->imageHeader.element[0].line_padding = 0; + header->imageHeader.element[0].element_padding = 0; + header->imageHeader.element[0].description[0] = 0; + + /* --- Orientation header --- */ + /* we leave it blank */ + + /* --- Television header --- */ + header->televisionHeader.time_code = DPX_UNDEFINED_U32; + header->televisionHeader.user_bits = DPX_UNDEFINED_U32; + header->televisionHeader.interlace = DPX_UNDEFINED_U8; + header->televisionHeader.field_number = DPX_UNDEFINED_U8; + header->televisionHeader.video_signal = DPX_UNDEFINED_U8; + header->televisionHeader.padding = DPX_UNDEFINED_U8; + header->televisionHeader.horizontal_sample_rate = DPX_UNDEFINED_R32; + header->televisionHeader.vertical_sample_rate = DPX_UNDEFINED_R32; + header->televisionHeader.frame_rate = DPX_UNDEFINED_R32; + header->televisionHeader.time_offset = DPX_UNDEFINED_R32; + header->televisionHeader.gamma = swap_float(dpx->gamma, dpx->isMSB); + header->televisionHeader.black_level = swap_float(dpx->referenceBlack, dpx->isMSB); + header->televisionHeader.black_gain = DPX_UNDEFINED_R32; + header->televisionHeader.breakpoint = DPX_UNDEFINED_R32; + header->televisionHeader.white_level = swap_float(dpx->referenceWhite, dpx->isMSB); + header->televisionHeader.integration_times = DPX_UNDEFINED_R32; } -#define LFMEMFILE 0 -#define LFREALFILE 1 - -static DpxFile* -intern_dpxOpen(int mode, const char* bytestuff, int bufsize) { - +LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize) +{ DpxMainHeader header; - const char *filename = bytestuff; - DpxFile* dpx = (DpxFile*)malloc(sizeof(DpxFile)); - + LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__); + char *filename = (char *)byteStuff; + int i; + if (dpx == 0) { - if (verbose) d_printf("Failed to malloc dpx file structure.\n"); + if (verbose) printf("DPX: Failed to malloc dpx file structure.\n"); return 0; } + /* zero the header */ + memset(&header, 0, sizeof(DpxMainHeader)); + /* for close routine */ dpx->file = 0; - dpx->lineBuffer = 0; - dpx->pixelBuffer = 0; - if (mode == LFREALFILE) { - filename = bytestuff; + if (fromMemory == 0) { + /* byteStuff is then the filename */ dpx->file = BLI_fopen(filename, "rb"); - if (dpx->file == 0) { - if (verbose) d_printf("Failed to open file \"%s\".\n", filename); - dpxClose(dpx); + if (dpx->file == 0) { + if (verbose) printf("DPX: Failed to open file \"%s\".\n", filename); + logImageClose(dpx); return 0; } - dpx->membuffer = 0; - dpx->memcursor = 0; - dpx->membuffersize = 0; + /* not used in this case */ + dpx->memBuffer = 0; + dpx->memCursor = 0; + dpx->memBufferSize = 0; } - else if (mode == LFMEMFILE) { - dpx->membuffer = (unsigned char *)bytestuff; - dpx->memcursor = (unsigned char *)bytestuff; - dpx->membuffersize = bufsize; + else { + dpx->memBuffer = (unsigned char *)byteStuff; + dpx->memCursor = (unsigned char *)byteStuff; + dpx->memBufferSize = bufferSize; } - - dpx->reading = 1; if (logimage_fread(&header, sizeof(header), 1, dpx) == 0) { - if (verbose) d_printf("Not enough data for header in \"%s\".\n", filename); - dpxClose(dpx); + if (verbose) printf("DPX: Not enough data for header in \"%s\".\n", byteStuff); + logImageClose(dpx); return 0; } - /* let's assume dpx files are always network order */ - if (header.fileInfo.magic_num != ntohl(DPX_FILE_MAGIC)) { - if (verbose) d_printf("Bad magic number %8.8lX in \"%s\".\n", - (uintptr_t)ntohl(header.fileInfo.magic_num), filename); - dpxClose(dpx); - return 0; + /* endianness determination */ + if (header.fileHeader.magic_num == swap_uint(DPX_FILE_MAGIC, 1)) { + dpx->isMSB = 1; + if (verbose) printf("DPX: File is MSB.\n"); } - - if (ntohs(header.imageInfo.channel[0].packing) != 1) { - if (verbose) d_printf("Unknown packing %d\n", header.imageInfo.channel[0].packing); - dpxClose(dpx); + else if (header.fileHeader.magic_num == DPX_FILE_MAGIC) { + dpx->isMSB = 0; + if (verbose) printf("DPX: File is LSB.\n"); + } + else { + if (verbose) printf("DPX: Bad magic number %lu in \"%s\".\n", + (uintptr_t)header.fileHeader.magic_num, byteStuff); + logImageClose(dpx); return 0; } + dpx->srcFormat = format_DPX; + dpx->numElements = swap_ushort(header.imageHeader.elements_per_image, dpx->isMSB); + dpx->width = swap_uint(header.imageHeader.pixels_per_line, dpx->isMSB); + dpx->height = swap_uint(header.imageHeader.lines_per_element, dpx->isMSB); + dpx->depth = 0; + + for (i = 0; i < dpx->numElements; i++) { + dpx->element[i].descriptor = header.imageHeader.element[i].descriptor; + + switch (dpx->element[i].descriptor) { + case descriptor_Red: + case descriptor_Green: + case descriptor_Blue: + case descriptor_Alpha: + case descriptor_Luminance: + case descriptor_Chrominance: + dpx->depth++; + dpx->element[i].depth = 1; + break; + + case descriptor_CbYCrY: + dpx->depth += 2; + dpx->element[i].depth = 2; + break; + + case descriptor_RGB: + case descriptor_CbYCr: + case descriptor_CbYACrYA: + dpx->depth += 3; + dpx->element[i].depth = 3; + break; + + case descriptor_RGBA: + case descriptor_ABGR: + case descriptor_CbYCrA: + dpx->depth += 4; + dpx->element[i].depth = 4; + break; + + case descriptor_Depth: + case descriptor_Composite: + /* unsupported */ + break; + } - dpx->width = ntohl(header.imageInfo.pixels_per_line); - dpx->height = ntohl(header.imageInfo.lines_per_image); - dpx->depth = ntohs(header.imageInfo.channels_per_image); - /* Another DPX vs Cineon wierdness */ - if (dpx->depth == 1) { - switch (header.imageInfo.channel[0].designator1) { - case 50: dpx->depth = 3; break; - case 51: dpx->depth = 4; break; - case 52: dpx->depth = 4; break; - default: break; + if (dpx->depth == 0 || dpx->depth > 4) { + if (verbose) printf("DPX: Unsupported image depth: %d\n", dpx->depth); + logImageClose(dpx); + return 0; } - } - /* dpx->bitsPerPixel = 10; */ - dpx->bitsPerPixel = header.imageInfo.channel[0].bits_per_pixel; - if (dpx->bitsPerPixel != 10) { - if (verbose) d_printf("Don't support depth: %d\n", dpx->bitsPerPixel); - dpxClose(dpx); - return 0; - } - dpx->imageOffset = ntohl(header.fileInfo.offset); - dpx->lineBufferLength = pixelsToLongs(dpx->width * dpx->depth); - dpx->lineBuffer = malloc(dpx->lineBufferLength * 4); - if (dpx->lineBuffer == 0) { - if (verbose) d_printf("Couldn't malloc line buffer of size %d\n", dpx->lineBufferLength * 4); - dpxClose(dpx); - return 0; - } + dpx->element[i].bitsPerSample = header.imageHeader.element[i].bits_per_sample; + dpx->element[i].maxValue = powf(2, dpx->element[i].bitsPerSample) - 1.0f; + dpx->element[i].packing = swap_ushort(header.imageHeader.element[i].packing, dpx->isMSB); - /* could have 2 pixels left over */ - dpx->pixelBuffer = malloc((dpx->lineBufferLength * 3 + 2) * sizeof(unsigned short)); - if (dpx->pixelBuffer == 0) { - if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n", - (dpx->width * dpx->depth + 2 + 2) * (int)sizeof(unsigned short)); - dpxClose(dpx); - return 0; - } - dpx->pixelBufferUsed = 0; + /* Sometimes, the offset is not set correctly in the header */ + dpx->element[i].dataOffset = swap_uint(header.imageHeader.element[i].data_offset, dpx->isMSB); + if (dpx->element[i].dataOffset == 0 && dpx->numElements == 1) + dpx->element[i].dataOffset = swap_uint(header.fileHeader.offset, dpx->isMSB); - if (logimage_fseek(dpx, dpx->imageOffset, SEEK_SET) != 0) { - if (verbose) d_printf("Couldn't seek to image data start at %d\n", dpx->imageOffset); - dpxClose(dpx); - return 0; - } - dpx->fileYPos = 0; - - logImageGetByteConversionDefaults(&dpx->params); - /* The SMPTE define this code: - * 0 - User-defined - * 1 - Printing density - * 2 - Linear - * 3 - Logarithmic - * 4 - Unspecified video - * 5 - SMPTE 240M - * 6 - CCIR 709-1 - * 7 - CCIR 601-2 system B or G - * 8 - CCIR 601-2 system M - * 9 - NTSC composite video - * 10 - PAL composite video - * 11 - Z linear - * 12 - homogeneous - * - * Note that transfer_characteristics is U8, don't need - * check the byte order. - */ - - switch (header.imageInfo.channel[0].transfer_characteristics) { - case 1: - case 2: /* linear */ - dpx->params.doLogarithm= 0; - break; - - case 3: - dpx->params.doLogarithm= 1; - break; - - /* TODO - Unsupported, but for now just load them, - * colors may look wrong, but can solve color conversion later - */ - case 4: - case 5: - case 6: - case 7: - case 8: - case 9: - case 10: - case 11: - case 12: - if (verbose) d_printf("Un-supported Transfer Characteristics: %d using linear color conversion\n", header.imageInfo.channel[0].transfer_characteristics); - dpx->params.doLogarithm= 0; - break; - default: - if (verbose) d_printf("Un-supported Transfer Characteristics: %d\n", header.imageInfo.channel[0].transfer_characteristics); - dpxClose(dpx); + if (dpx->element[i].dataOffset == 0) { + if (verbose) printf("DPX: Image header is corrupted.\n"); + logImageClose(dpx); return 0; - break; - } - setupLut(dpx); - - dpx->getRow = &dpxGetRowBytes; - dpx->setRow = 0; - dpx->close = &dpxClose; + } - if (verbose) { - verboseMe(dpx); + dpx->element[i].transfer = header.imageHeader.element[i].transfer; + + /* if undefined, assign default */ + dpx->element[i].refLowData = swap_uint(header.imageHeader.element[i].ref_low_data, dpx->isMSB); + dpx->element[i].refLowQuantity = swap_float(header.imageHeader.element[i].ref_low_quantity, dpx->isMSB); + dpx->element[i].refHighData = swap_uint(header.imageHeader.element[i].ref_high_data, dpx->isMSB); + dpx->element[i].refHighQuantity = swap_float(header.imageHeader.element[i].ref_high_quantity, dpx->isMSB); + + switch (dpx->element[i].descriptor) { + case descriptor_Red: + case descriptor_Green: + case descriptor_Blue: + case descriptor_Alpha: + case descriptor_RGB: + case descriptor_RGBA: + case descriptor_ABGR: + if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refLowData)) + dpx->element[i].refLowData = 0; + + if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refHighData)) + dpx->element[i].refHighData = (unsigned int)dpx->element[i].maxValue; + + if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity)) + dpx->element[i].refLowQuantity = 0.0f; + + if (dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refHighQuantity)) { + if (dpx->element[i].transfer == transfer_PrintingDensity || dpx->element[i].transfer == transfer_Logarithmic) + dpx->element[i].refHighQuantity = 2.048f; + else + dpx->element[i].refHighQuantity = dpx->element[i].maxValue; + } + + break; + + case descriptor_Luminance: + case descriptor_Chrominance: + case descriptor_CbYCrY: + case descriptor_CbYCr: + case descriptor_CbYACrYA: + case descriptor_CbYCrA: + if (dpx->element[i].refLowData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refLowData)) + dpx->element[i].refLowData = 16.0f / 255.0f * dpx->element[i].maxValue; + + if (dpx->element[i].refHighData == DPX_UNDEFINED_U32 || isnan(dpx->element[i].refHighData)) + dpx->element[i].refHighData = 235.0f / 255.0f * dpx->element[i].maxValue; + + if (dpx->element[i].refLowQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refLowQuantity)) + dpx->element[i].refLowQuantity = 0.0f; + + if (dpx->element[i].refHighQuantity == DPX_UNDEFINED_R32 || isnan(dpx->element[i].refHighQuantity)) + dpx->element[i].refHighQuantity = 0.7f; + + break; + + default: + break; + } } - return dpx; -} - -DpxFile* -dpxOpen(const char *filename) { - return intern_dpxOpen(LFREALFILE, filename, 0); -} + dpx->referenceBlack = swap_float(header.televisionHeader.black_level, dpx->isMSB); + dpx->referenceWhite = swap_float(header.televisionHeader.white_level, dpx->isMSB); + dpx->gamma = swap_float(header.televisionHeader.gamma, dpx->isMSB); -DpxFile* -dpxOpenFromMem(unsigned char *buffer, unsigned int size) { - return intern_dpxOpen(LFMEMFILE, (const char *) buffer, size); -} + if ((dpx->referenceBlack == DPX_UNDEFINED_R32 || isnan(dpx->referenceBlack)) || + (dpx->referenceWhite == DPX_UNDEFINED_R32 || dpx->referenceWhite <= dpx->referenceBlack || isnan(dpx->referenceWhite)) || + (dpx->gamma == DPX_UNDEFINED_R32 || dpx->gamma <= 0 || isnan(dpx->gamma))) + { -int -dpxIsMemFileCineon(void *buffer) { - int magicnum = 0; - magicnum = *((int*)buffer); - if (magicnum == ntohl(DPX_FILE_MAGIC)) return 1; - else return 0; -} + dpx->referenceBlack = 95.0f / 1023.0f * dpx->element[0].maxValue; + dpx->referenceWhite = 685.0f / 1023.0f * dpx->element[0].maxValue; + dpx->gamma = 1.7f; + } -DpxFile* -dpxCreate(const char* filename, int width, int height, int depth) { + if (verbose) { + printf("size %d x %d x %d elements\n", dpx->width, dpx->height, dpx->numElements); + for (i = 0; i < dpx->numElements; i++) { + printf(" Element %d:\n", i); + printf(" Bits per sample: %d\n", dpx->element[i].bitsPerSample); + printf(" Depth: %d\n", dpx->element[i].depth); + printf(" Transfer characteristics: %d\n", dpx->element[i].transfer); + printf(" Packing: %d\n", dpx->element[i].packing); + printf(" Descriptor: %d\n", dpx->element[i].descriptor); + printf(" Data offset: %u\n", dpx->element[i].dataOffset); + printf(" Reference low data: %u\n", dpx->element[i].refLowData); + printf(" Reference low quantity: %f\n", dpx->element[i].refLowQuantity); + printf(" Reference high data: %u\n", dpx->element[i].refHighData); + printf(" Reference high quantity: %f\n", dpx->element[i].refHighQuantity); + printf("\n"); + } - /* Note: always write files in network order */ - /* By the spec, it shouldn't matter, but ... */ + printf("Gamma: %f\n", dpx->gamma); + printf("Reference black: %f\n", dpx->referenceBlack); + printf("Reference white: %f\n", dpx->referenceWhite); + printf("----------------------------\n"); + } + return dpx; +} +LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPerSample, int hasAlpha, + int isLogarithmic, int referenceWhite, int referenceBlack, float gamma, + const char *creator) +{ DpxMainHeader header; - const char* shortFilename = 0; + const char *shortFilename = 0; + unsigned char pad[6044]; - DpxFile* dpx = (DpxFile*)malloc(sizeof(DpxFile)); + LogImageFile *dpx = (LogImageFile *)MEM_mallocN(sizeof(LogImageFile), __func__); if (dpx == 0) { - if (verbose) d_printf("Failed to malloc dpx file structure.\n"); - return 0; - } - - memset(&header, 0, sizeof(header)); - - /* for close routine */ - dpx->file = 0; - dpx->lineBuffer = 0; - dpx->pixelBuffer = 0; - - dpx->file = BLI_fopen(filename, "wb"); - if (dpx->file == 0) { - if (verbose) d_printf("Couldn't open file %s\n", filename); - dpxClose(dpx); + if (verbose) printf("DPX: Failed to malloc dpx file structure.\n"); return 0; } - dpx->reading = 0; dpx->width = width; dpx->height = height; - dpx->depth = depth; - dpx->bitsPerPixel = 10; - dpx->imageOffset = sizeof(DpxMainHeader); - - dpx->lineBufferLength = pixelsToLongs(dpx->width * dpx->depth); - dpx->lineBuffer = malloc(dpx->lineBufferLength * 4); - if (dpx->lineBuffer == 0) { - if (verbose) d_printf("Couldn't malloc line buffer of size %d\n", dpx->lineBufferLength * 4); - dpxClose(dpx); - return 0; - } + dpx->element[0].bitsPerSample = bitsPerSample; + dpx->element[0].dataOffset = 8092; + dpx->element[0].maxValue = powf(2, dpx->element[0].bitsPerSample) - 1.0f; + dpx->isMSB = 1; + dpx->numElements = 1; - dpx->pixelBuffer = malloc((dpx->lineBufferLength * 3 + 2) * sizeof(unsigned short)); - if (dpx->pixelBuffer == 0) { - if (verbose) d_printf("Couldn't malloc pixel buffer of size %d\n", - (dpx->width * dpx->depth + 2 + 2) * (int)sizeof(unsigned short)); - dpxClose(dpx); - return 0; + switch (bitsPerSample) { + case 8: + case 16: + dpx->element[0].packing = 0; + break; + + case 10: + case 12: + /* Packed Type A padding is the most common 10/12 bits format */ + dpx->element[0].packing = 1; + break; + + default: + if (verbose) printf("DPX: bitsPerSample not supported: %d\n", bitsPerSample); + logImageClose(dpx); + return 0; } - dpx->pixelBufferUsed = 0; - /* find trailing part of filename */ - shortFilename = strrchr(filename, '/'); - if (shortFilename == 0) { - shortFilename = filename; + if (hasAlpha == 0) { + dpx->depth = 3; + dpx->element[0].depth = 3; + dpx->element[0].descriptor = descriptor_RGB; } else { - ++shortFilename; + dpx->depth = 4; + dpx->element[0].depth = 4; + dpx->element[0].descriptor = descriptor_RGBA; } - initDpxMainHeader(dpx, &header, shortFilename); - logImageGetByteConversionDefaults(&dpx->params); - /* Need set the file type before write the header! - * 2 - Linear - * 3 - Logarithmic - * - * Note that transfer characteristics is U8, don't need - * check the byte order. - */ - if (dpx->params.doLogarithm == 0) - header.imageInfo.channel[0].transfer_characteristics= 2; - else - header.imageInfo.channel[0].transfer_characteristics= 3; - if (fwrite(&header, sizeof(header), 1, dpx->file) == 0) { - if (verbose) d_printf("Couldn't write image header\n"); - dpxClose(dpx); - return 0; + if (isLogarithmic == 0) { + dpx->element[0].transfer = transfer_Linear; + dpx->element[0].refHighQuantity = dpx->element[0].maxValue; } - dpx->fileYPos = 0; - setupLut(dpx); + else { + dpx->element[0].transfer = transfer_PrintingDensity; + dpx->element[0].refHighQuantity = 2.048f; - dpx->getRow = 0; - dpx->setRow = &dpxSetRowBytes; - dpx->close = &dpxClose; + } - return dpx; -} + dpx->element[0].refLowQuantity = 0; + dpx->element[0].refLowData = 0; + dpx->element[0].refHighData = dpx->element[0].maxValue; -void -dpxClose(DpxFile* dpx) { + if (referenceWhite > 0) + dpx->referenceWhite = referenceWhite; + else + dpx->referenceWhite = 685.0f / 1023.0f * dpx->element[0].maxValue; - if (dpx == 0) { - return; - } + if (referenceBlack > 0) + dpx->referenceBlack = referenceBlack; + else + dpx->referenceBlack = 95.0f / 1023.0f * dpx->element[0].maxValue; - if (dpx->file) { - fclose(dpx->file); - dpx->file = 0; - } + if (gamma > 0.0f) + dpx->gamma = gamma; + else + dpx->gamma = 1.7f; - if (dpx->lineBuffer) { - free(dpx->lineBuffer); - dpx->lineBuffer = 0; - } - if (dpx->pixelBuffer) { - free(dpx->pixelBuffer); - dpx->pixelBuffer = 0; - } + shortFilename = strrchr(filename, '/'); + if (shortFilename == 0) + shortFilename = filename; + else + shortFilename++; - free(dpx); -} + dpx->file = BLI_fopen(filename, "wb"); -void -dpxDump(const char* filename) { + if (dpx->file == 0) { + if (verbose) printf("DPX: Couldn't open file %s\n", filename); + logImageClose(dpx); + return 0; + } - DpxMainHeader header; - FILE* file; + fillDpxMainHeader(dpx, &header, shortFilename, creator); - file = BLI_fopen(filename, "rb"); - if (file == 0) { - d_printf("Failed to open file \"%s\".\n", filename); - return; + if (fwrite(&header, sizeof(header), 1, dpx->file) == 0) { + if (verbose) printf("DPX: Couldn't write image header\n"); + logImageClose(dpx); + return 0; } - if (fread(&header, sizeof(header), 1, file) == 0) { - d_printf("Not enough data for header in \"%s\".\n", filename); - fclose(file); - return; + /* Header should be rounded to next 8k block + 6044 = 8092 - sizeof(DpxMainHeader) */ + memset(&pad, 0, 6044); + if (fwrite(&pad, 6044, 1, dpx->file) == 0) { + if (verbose) printf("DPX: Couldn't write image header\n"); + logImageClose(dpx); + return 0; } - fclose(file); - dumpDpxMainHeader(&header); + return dpx; } diff --git a/source/blender/imbuf/intern/cineon/dpxlib.h b/source/blender/imbuf/intern/cineon/dpxlib.h index eb3937f2bf7..e910aaa61e1 100644 --- a/source/blender/imbuf/intern/cineon/dpxlib.h +++ b/source/blender/imbuf/intern/cineon/dpxlib.h @@ -1,60 +1,160 @@ /* - * DPX image file format library definitions. + * DPX image file format library definitions. * - * Copyright 1999 - 2002 David Hodson <hodsond@acm.org> + * Copyright 1999 - 2002 David Hodson <hodsond@acm.org> * - * 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 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. + * 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. + * 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. + * + * Contributor(s): Julien Enche. * */ -#ifndef __DPXLIB_H__ -#define __DPXLIB_H__ - /** \file blender/imbuf/intern/cineon/dpxlib.h * \ingroup imbcineon */ + +#ifndef __DPX_LIB_H__ +#define __DPX_LIB_H__ + #ifdef __cplusplus extern "C" { #endif #include "logImageCore.h" -typedef struct _Log_Image_File_t_ DpxFile; +#define DPX_FILE_MAGIC 0x53445058 +#define DPX_UNDEFINED_U8 0xFF +#define DPX_UNDEFINED_U16 0xFFFF +#define DPX_UNDEFINED_U32 0xFFFFFFFF +#define DPX_UNDEFINED_R32 0xFFFFFFFF +#define DPX_UNDEFINED_CHAR 0 -/* int functions return 0 for OK */ +typedef struct { + unsigned int magic_num; + unsigned int offset; + char version[8]; + unsigned int file_size; + unsigned int ditto_key; + unsigned int gen_hdr_size; + unsigned int ind_hdr_size; + unsigned int user_data_size; + char file_name[100]; + char creation_date[24]; + char creator[100]; + char project[200]; + char copyright[200]; + unsigned int key; + char reserved[104]; +} DpxFileHeader; -void dpxSetVerbose(int); +typedef struct { + unsigned int data_sign; + unsigned int ref_low_data; + float ref_low_quantity; + unsigned int ref_high_data; + float ref_high_quantity; + unsigned char descriptor; + unsigned char transfer; + unsigned char colorimetric; + unsigned char bits_per_sample; + unsigned short packing; + unsigned short encoding; + unsigned int data_offset; + unsigned int line_padding; + unsigned int element_padding; + char description[32]; +} DpxElementHeader; -DpxFile* dpxOpen(const char* filename); -DpxFile* dpxCreate(const char* filename, int xsize, int ysize, int channels); -DpxFile* dpxOpenFromMem(unsigned char *buffer, unsigned int size); -int dpxIsMemFileCineon(void *buffer); +typedef struct { + unsigned short orientation; + unsigned short elements_per_image; + unsigned int pixels_per_line; + unsigned int lines_per_element; + DpxElementHeader element[8]; + char reserved[52]; +} DpxImageHeader; -/* get/set scanline of converted bytes */ -int dpxGetRowBytes(DpxFile* dpx, unsigned short* row, int y); -int dpxSetRowBytes(DpxFile* dpx, const unsigned short* row, int y); +typedef struct { + unsigned int x_offset; + unsigned int y_offset; + float x_center; + float y_center; + unsigned int x_original_size; + unsigned int y_original_size; + char file_name[100]; + char creation_time[24]; + char input_device[32]; + char input_serial_number[32]; + unsigned short border_validity[4]; + unsigned int pixel_aspect_ratio[2]; + char reserved[28]; +} DpxOrientationHeader; -/* closes file and deletes data */ -void dpxClose(DpxFile* dpx); +typedef struct { + char film_manufacturer_id[2]; + char film_type[2]; + char edge_code_perforation_offset[2]; + char edge_code_prefix[6]; + char edge_code_count[4]; + char film_format[32]; + unsigned int frame_position; + unsigned int sequence_length; + unsigned int held_count; + float frame_rate; + float shutter_angle; + char frame_identification[32]; + char slate_info[100]; + char reserved[56]; +} DpxFilmHeader; -/* dumps file to stdout */ -void dpxDump(const char* filename); +typedef struct { + unsigned int time_code; + unsigned int user_bits; + unsigned char interlace; + unsigned char field_number; + unsigned char video_signal; + unsigned char padding; + float horizontal_sample_rate; + float vertical_sample_rate; + float frame_rate; + float time_offset; + float gamma; + float black_level; + float black_gain; + float breakpoint; + float white_level; + float integration_times; + unsigned char reserved[76]; +} DpxTelevisionHeader; + + +typedef struct { + DpxFileHeader fileHeader; + DpxImageHeader imageHeader; + DpxOrientationHeader orientationHeader; + DpxFilmHeader filmHeader; + DpxTelevisionHeader televisionHeader; +} DpxMainHeader; + +void dpxSetVerbose(int verbosity); +LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t bufferSize); +LogImageFile *dpxCreate(const char *filename, int width, int height, int bitsPerSample, int hasAlpha, int isLogarithmic, int referenceWhite, int referenceBlack, float gamma, const char *creator); #ifdef __cplusplus } #endif -#endif /* __DPXLIB_H__ */ +#endif diff --git a/source/blender/imbuf/intern/cineon/logImageCore.c b/source/blender/imbuf/intern/cineon/logImageCore.c index f772cc7d477..5c734db323d 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.c +++ b/source/blender/imbuf/intern/cineon/logImageCore.c @@ -1,21 +1,23 @@ /* - * Cineon image file format library routines. + * Cineon image file format library routines. * - * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> + * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> * - * 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 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. + * 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. + * 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. + * + * Contributor(s): Julien Enche. * */ @@ -23,223 +25,1407 @@ * \ingroup imbcineon */ + +#include "logmemfile.h" #include "logImageCore.h" +#include "dpxlib.h" +#include "cineonlib.h" -#include <time.h> /* strftime() */ +#include <stdlib.h> +#include <string.h> #include <math.h> -/* Makes rint consistent in Windows and Linux: */ -#define rint(x) floor(x+0.5) -#ifdef WIN32 -#include <winsock.h> -#else -#include <sys/types.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <sys/param.h> -#endif +#include "BLI_fileops.h" +#include "BLI_utildefines.h" + +#include "MEM_guardedalloc.h" + +/* + * Declaration of static functions + */ + +static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement, float *data); +static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement, float *data); +static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement, float *data); +static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement, float *data); +static int logImageElementGetData(LogImageFile *dpx, LogImageElement logElement, float *data); +static int logImageElementGetData1(LogImageFile *dpx, LogImageElement logElement, float *data); +static int logImageElementGetData8(LogImageFile *dpx, LogImageElement logElement, float *data); +static int logImageElementGetData10(LogImageFile *dpx, LogImageElement logElement, float *data); +static int logImageElementGetData10Packed(LogImageFile *dpx, LogImageElement logElement, float *data); +static int logImageElementGetData12(LogImageFile *dpx, LogImageElement logElement, float *data); +static int logImageElementGetData12Packed(LogImageFile *dpx, LogImageElement logElement, float *data); +static int logImageElementGetData16(LogImageFile *dpx, LogImageElement logElement, float *data); +static int convertLogElementToRGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement, int dstIsLinearRGB); +static int convertRGBAToLogElement(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement, int srcIsLinearRGB); + + +/* + * For debug purpose + */ + +static int verbose = 0; + +void logImageSetVerbose(int verbosity) +{ + verbose = verbosity; + cineonSetVerbose(verbosity); + dpxSetVerbose(verbosity); +} + + +/* + * IO stuff + */ + +int logImageIsDpx(const void *buffer) +{ + unsigned int magicNum = *(unsigned int *)buffer; + return (magicNum == DPX_FILE_MAGIC || magicNum == swap_uint(DPX_FILE_MAGIC, 1)); +} -#if defined(__hpux) -/* These are macros in hpux */ -#ifdef htonl -#undef htonl -#undef htons -#undef ntohl -#undef ntohs -#endif -unsigned int htonl(h) unsigned int h; { return(h); } -unsigned short htons(h) unsigned short h; { return(h); } -unsigned int ntohl(n) unsigned int n; { return(n); } -unsigned short ntohs(n) unsigned short n; { return(n); } -#endif - - -/* obscure LogImage conversion */ -/* from 10 bit int to 0.0 - 1.0 */ -/* magic numbers left intact */ -static double -convertTo(int inp, int white, float gamma) { - /* return pow(pow(10.0, ((inp - white) * 0.002 / 0.6)), gamma); */ - return pow(10.0, (inp - white) * gamma * 0.002 / 0.6); +int logImageIsCineon(const void *buffer) +{ + unsigned int magicNum = *(unsigned int *)buffer; + return (magicNum == CINEON_FILE_MAGIC || magicNum == swap_uint(CINEON_FILE_MAGIC, 1)); } -static double -convertFrom(double inp, int white, float gamma) { - return white + log10(inp) / (gamma * 0.002 / 0.6); +LogImageFile *logImageOpenFromFile(const char *filename, int cineon) +{ + unsigned int magicNum; + FILE *f = BLI_fopen(filename, "rb"); + + (void)cineon; + + if (f == 0) + return 0; + + if (fread(&magicNum, sizeof(unsigned int), 1, f) != 1) { + fclose(f); + return 0; + } + + fclose(f); + + if (logImageIsDpx(&magicNum)) + return dpxOpen((const unsigned char *)filename, 0, 0); + else if (logImageIsCineon(&magicNum)) + return cineonOpen((const unsigned char *)filename, 0, 0); + + return 0; } -/* set up the 10 bit to 8 bit and 8 bit to 10 bit tables */ -void -setupLut(LogImageFile *logImage) { +LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size) +{ + if (logImageIsDpx(buffer)) + return dpxOpen(buffer, 1, size); + else if (logImageIsCineon(buffer)) + return cineonOpen(buffer, 1, size); - int i; - double f_black; - double scale; + return 0; +} + +LogImageFile *logImageCreate(const char *filename, int cineon, int width, int height, int bitsPerSample, + int isLogarithmic, int hasAlpha, int referenceWhite, int referenceBlack, + float gamma, const char *creator) +{ + /* referenceWhite, referenceBlack and gamma values are only supported for DPX file */ + if (cineon) + return cineonCreate(filename, width, height, bitsPerSample, creator); + else + return dpxCreate(filename, width, height, bitsPerSample, isLogarithmic, hasAlpha, + referenceWhite, referenceBlack, gamma, creator); - f_black = convertTo(logImage->params.blackPoint, logImage->params.whitePoint, logImage->params.gamma); - scale = 255.0 / (1.0 - f_black); + return 0; +} - for (i = 0; i <= logImage->params.blackPoint; ++i) { - logImage->lut10[i] = 0; +void logImageClose(LogImageFile *logImage) +{ + if (logImage != 0) { + if (logImage->file) { + fclose(logImage->file); + logImage->file = 0; + } + MEM_freeN(logImage); } - for (; i < logImage->params.whitePoint; ++i) { - double f_i; - f_i = convertTo(i, logImage->params.whitePoint, logImage->params.gamma); - logImage->lut10[i] = (int)rint(scale * (f_i - f_black)); +} + +void logImageGetSize(LogImageFile *logImage, int *width, int *height, int *depth) +{ + *width = logImage->width; + *height = logImage->height; + *depth = logImage->depth; +} + + +/* + * Helper + */ + +unsigned int getRowLength(int width, LogImageElement logElement) +{ + /* return the row length in bytes according to width and packing method */ + switch (logElement.bitsPerSample) { + case 1: + return ((width * logElement.depth - 1) / 32 + 1) * 4; + + case 8: + return ((width * logElement.depth - 1) / 4 + 1) * 4; + + case 10: + if (logElement.packing == 0) + return ((width * logElement.depth * 10 - 1) / 32 + 1) * 4; + else if (logElement.packing == 1 || logElement.packing == 2) + return ((width * logElement.depth - 1) / 3 + 1) * 4; + + case 12: + if (logElement.packing == 0) + return ((width * logElement.depth * 12 - 1) / 32 + 1) * 4; + else if (logElement.packing == 1 || logElement.packing == 2) + return width * logElement.depth * 2; + + case 16: + return width * logElement.depth * 2; + + default: + return 0; } - for (; i < 1024; ++i) { - logImage->lut10[i] = 255; +} + + +/* + * Data writing + */ + +int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB) +{ + float *elementData; + int returnValue; + + elementData = (float *)MEM_mallocN(logImage->width * logImage->height * logImage->depth * sizeof(float), __func__); + if (elementData == 0) + return 1; + + if (convertRGBAToLogElement(data, elementData, logImage, logImage->element[0], dataIsLinearRGB) != 0) { + MEM_freeN(elementData); + return 1; } - for (i = 0; i < 256; ++i) { - double f_i = f_black + (i / 255.0) * (1.0 - f_black); - logImage->lut8[i] = convertFrom(f_i, logImage->params.whitePoint, logImage->params.gamma); - } -} - -/* set up the 10 bit to 16 bit and 16 bit to 10 bit tables */ -void -setupLut16(LogImageFile *logImage) { + switch (logImage->element[0].bitsPerSample) { + case 8: + returnValue = logImageSetData8(logImage, logImage->element[0], elementData); + break; + + case 10: + returnValue = logImageSetData10(logImage, logImage->element[0], elementData); + break; - int i; - double f_black; - double scale; + case 12: + returnValue = logImageSetData12(logImage, logImage->element[0], elementData); + break; - f_black = convertTo(logImage->params.blackPoint, logImage->params.whitePoint, logImage->params.gamma); - scale = 65535.0 / (1.0 - f_black); - - for (i = 0; i <= logImage->params.blackPoint; ++i) { - logImage->lut10_16[i] = 0; - } - for (; i < logImage->params.whitePoint; ++i) { - double f_i; - f_i = convertTo(i, logImage->params.whitePoint, logImage->params.gamma); - logImage->lut10_16[i] = (int)rint(scale * (f_i - f_black)); - } - for (; i < 1024; ++i) { - logImage->lut10_16[i] = 65535; - } - - for (i = 0; i < 65536; ++i) { - double f_i = f_black + (i / 65535.0) * (1.0 - f_black); - logImage->lut16_16[i] = convertFrom(f_i, logImage->params.whitePoint, logImage->params.gamma); - } -} - -/* how many longwords to hold this many pixels? */ -int -pixelsToLongs(int numPixels) { - return (numPixels + 2) / 3; -} - -/* byte reversed float */ + case 16: + returnValue = logImageSetData16(logImage, logImage->element[0], elementData); + break; -typedef union { - U32 i; - R32 f; -} Hack; + default: + returnValue = 1; + break; + } -R32 -htonf(R32 f) { - Hack hack; - hack.f = f; - hack.i = htonl(hack.i); - return hack.f; + MEM_freeN(elementData); + return returnValue; } -R32 -ntohf(R32 f) { - Hack hack; - hack.f = f; - hack.i = ntohl(hack.i); - return hack.f; +static int logImageSetData8(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + unsigned int rowLength = getRowLength(logImage->width, logElement); + unsigned char *row; + int x, y; + + row = (unsigned char *)MEM_mallocN(rowLength, __func__); + if (row == 0) { + if (verbose) printf("DPX/Cineon: Cannot allocate row.\n"); + return 1; + } + memset(row, 0, rowLength); + + for (y = 0; y < logImage->height; y++) { + for (x = 0; x < logImage->width * logImage->depth; x++) + row[x] = (unsigned char)float_uint(data[y * logImage->width * logImage->depth + x], 255); + + if (logimage_fwrite(row, rowLength, 1, logImage) == 0) { + if (verbose) printf("DPX/Cineon: Error while writing file.\n"); + MEM_freeN(row); + return 1; + } + } + MEM_freeN(row); + return 0; } -#define UNDEF_FLOAT 0x7F800000 +static int logImageSetData10(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + unsigned int rowLength = getRowLength(logImage->width, logElement); + unsigned int pixel, index; + unsigned int *row; + int x, y, offset; -R32 -undefined(void) { - Hack hack; - hack.i = UNDEF_FLOAT; - return hack.f; + row = (unsigned int *)MEM_mallocN(rowLength, __func__); + if (row == 0) { + if (verbose) printf("DPX/Cineon: Cannot allocate row.\n"); + return 1; + } + + for (y = 0; y < logImage->height; y++) { + offset = 22; + index = 0; + pixel = 0; + + for (x = 0; x < logImage->width * logImage->depth; x++) { + pixel |= (unsigned int)float_uint(data[y * logImage->width * logImage->depth + x], 1023) << offset; + offset -= 10; + if (offset < 0) { + row[index] = swap_uint(pixel, logImage->isMSB); + index++; + pixel = 0; + offset = 22; + } + } + if (pixel != 0) + row[index] = swap_uint(pixel, logImage->isMSB); + + if (logimage_fwrite(row, rowLength, 1, logImage) == 0) { + if (verbose) printf("DPX/Cineon: Error while writing file.\n"); { + MEM_freeN(row); + return 1; + } + } + } + MEM_freeN(row); + return 0; } -/* reverse an endian-swapped U16 */ -U16 -reverseU16(U16 value) { +static int logImageSetData12(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + unsigned int rowLength = getRowLength(logImage->width, logElement); + unsigned short *row; + int x, y; - union { - U16 whole; - char part[2]; - } buff; - char temp; - buff.whole = value; - temp = buff.part[0]; - buff.part[0] = buff.part[1]; - buff.part[1] = temp; - return buff.whole; + row = (unsigned short *)MEM_mallocN(rowLength, __func__); + if (row == 0) { + if (verbose) printf("DPX/Cineon: Cannot allocate row.\n"); + return 1; + } + + for (y = 0; y < logImage->height; y++) { + for (x = 0; x < logImage->width * logImage->depth; x++) + row[x] = swap_ushort(((unsigned short)float_uint(data[y * logImage->width * logImage->depth + x], 4095)) << 4, logImage->isMSB); + + if (logimage_fwrite(row, rowLength, 1, logImage) == 0) { + if (verbose) printf("DPX/Cineon: Error while writing file.\n"); + MEM_freeN(row); + return 1; + } + } + MEM_freeN(row); + return 0; } -/* reverse an endian-swapped U32 */ -U32 -reverseU32(U32 value) { +static int logImageSetData16(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + unsigned int rowLength = getRowLength(logImage->width, logElement); + unsigned short *row; + int x, y; - union { - U32 whole; - char part[4]; - } buff; - char temp; - buff.whole = value; - temp = buff.part[0]; - buff.part[0] = buff.part[3]; - buff.part[3] = temp; - temp = buff.part[1]; - buff.part[1] = buff.part[2]; - buff.part[2] = temp; - return buff.whole; + row = (unsigned short *)MEM_mallocN(rowLength, __func__); + if (row == 0) { + if (verbose) printf("DPX/Cineon: Cannot allocate row.\n"); + return 1; + } + + for (y = 0; y < logImage->height; y++) { + for (x = 0; x < logImage->width * logImage->depth; x++) + row[x] = swap_ushort((unsigned short)float_uint(data[y * logImage->width * logImage->depth + x], 65535), logImage->isMSB); + + if (logimage_fwrite(row, rowLength, 1, logImage) == 0) { + if (verbose) printf("DPX/Cineon: Error while writing file.\n"); + MEM_freeN(row); + return 1; + } + } + MEM_freeN(row); + return 0; } -/* reverse an endian-swapped R32 */ -R32 -reverseR32(R32 value) { - union { - R32 whole; - char part[4]; - } buff; - char temp; - buff.whole = value; - temp = buff.part[0]; - buff.part[0] = buff.part[3]; - buff.part[3] = temp; - temp = buff.part[1]; - buff.part[1] = buff.part[2]; - buff.part[2] = temp; - return buff.whole; +/* + * Data reading + */ + +int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB) +{ + /* Fills data with 32 bits float RGBA values */ + int i, j, returnValue, sortedElementData[8], hasAlpha; + float *elementData[8]; + float *elementData_ptr[8]; + float *mergedData; + unsigned int sampleIndex; + LogImageElement mergedElement; + + /* Determine the depth of the picture and if there's a separate alpha element. + If the element is supported, load it into an unsigned ints array. */ + memset(&elementData, 0, 8 * sizeof(float *)); + hasAlpha = 0; + + for (i = 0; i < logImage->numElements; i++) { + /* descriptor_Depth and descriptor_Composite are not supported */ + if (logImage->element[i].descriptor != descriptor_Depth && logImage->element[i].descriptor != descriptor_Composite) { + /* Allocate memory */ + elementData[i] = (float *)MEM_mallocN(logImage->width * logImage->height * logImage->element[i].depth * sizeof(float), __func__); + if (elementData[i] == 0) { + if (verbose) printf("DPX/Cineon: Cannot allocate memory for elementData[%d]\n.", i); + for (j = 0; j < i; j++) + if (elementData[j] != 0) + MEM_freeN(elementData[j]); + return 1; + } + elementData_ptr[i] = elementData[i]; + + /* Load data */ + if (logImageElementGetData(logImage, logImage->element[i], elementData[i]) != 0) { + if (verbose) printf("DPX/Cineon: Cannot read elementData[%d]\n.", i); + for (j = 0; j < i; j++) + if (elementData[j] != 0) + MEM_freeN(elementData[j]); + return 1; + } + } + + if (logImage->element[i].descriptor == descriptor_Alpha) + hasAlpha = 1; + } + + /* only one element, easy case, no need to do anything */ + if (logImage->numElements == 1) { + returnValue = convertLogElementToRGBA(elementData[0], data, logImage, logImage->element[0], dataIsLinearRGB); + MEM_freeN(elementData[0]); + } + else { + /* The goal here is to merge every elements into only one + * to recreate a classic 16 bits RGB, RGBA or YCbCr element. + * Unsupported elements are skipped (depth, composite) */ + + memcpy(&mergedElement, &logImage->element[0], sizeof(LogImageElement)); + mergedElement.descriptor = -1; + mergedElement.depth = logImage->depth; + memset(&sortedElementData, -1, 8 * sizeof(int)); + + /* Try to know how to assemble the elements */ + for (i = 0; i < logImage->numElements; i++) { + switch (logImage->element[i].descriptor) { + case descriptor_Red: + case descriptor_RGB: + if (hasAlpha == 0) + mergedElement.descriptor = descriptor_RGB; + else + mergedElement.descriptor = descriptor_RGBA; + + sortedElementData[0] = i; + break; + + case descriptor_Green: + if (hasAlpha == 0) + mergedElement.descriptor = descriptor_RGB; + else + mergedElement.descriptor = descriptor_RGBA; + + sortedElementData[1] = i; + break; + + case descriptor_Blue: + if (hasAlpha == 0) + mergedElement.descriptor = descriptor_RGB; + else + mergedElement.descriptor = descriptor_RGBA; + + sortedElementData[2] = i; + break; + + case descriptor_Alpha: + /* Alpha component is always the last one */ + sortedElementData[mergedElement.depth - 1] = i; + break; + + case descriptor_Luminance: + if (mergedElement.descriptor == -1) + if (hasAlpha == 0) + mergedElement.descriptor = descriptor_Luminance; + else + mergedElement.descriptor = descriptor_YA; + else if (mergedElement.descriptor == descriptor_Chrominance) { + if (mergedElement.depth == 2) + mergedElement.descriptor = descriptor_CbYCrY; + else if (mergedElement.depth == 3) + if (hasAlpha == 0) + mergedElement.descriptor = descriptor_CbYCr; + else + mergedElement.descriptor = descriptor_CbYACrYA; + else if (mergedElement.depth == 4) + mergedElement.descriptor = descriptor_CbYCrA; + } + + /* Y component always in 1 except if it's alone or with alpha */ + if (mergedElement.depth == 1 || (mergedElement.depth == 2 && hasAlpha == 1)) + sortedElementData[0] = i; + else + sortedElementData[1] = i; + break; + + case descriptor_Chrominance: + if (mergedElement.descriptor == -1) + mergedElement.descriptor = descriptor_Chrominance; + else if (mergedElement.descriptor == descriptor_Luminance) { + if (mergedElement.depth == 2) + mergedElement.descriptor = descriptor_CbYCrY; + else if (mergedElement.depth == 3) + if (hasAlpha == 0) + mergedElement.descriptor = descriptor_CbYCr; + else + mergedElement.descriptor = descriptor_CbYACrYA; + else if (mergedElement.depth == 4) + mergedElement.descriptor = descriptor_CbYCrA; + } + + /* Cb and Cr always in 0 or 2 */ + if (sortedElementData[0] == -1) + sortedElementData[0] = i; + else + sortedElementData[2] = i; + break; + + case descriptor_CbYCr: + if (hasAlpha == 0) + mergedElement.descriptor = descriptor_CbYCr; + else + mergedElement.descriptor = descriptor_CbYCrA; + + sortedElementData[0] = i; + break; + + case descriptor_RGBA: + case descriptor_ABGR: + case descriptor_CbYACrYA: + case descriptor_CbYCrY: + case descriptor_CbYCrA: + /* I don't think these ones can be seen in a planar image */ + mergedElement.descriptor = logImage->element[i].descriptor; + sortedElementData[0] = i; + break; + + case descriptor_Depth: + case descriptor_Composite: + /* Not supported */ + break; + } + } + + mergedData = (float *)MEM_mallocN(logImage->width * logImage->height * mergedElement.depth * sizeof(float), __func__); + if (mergedData == 0) { + if (verbose) printf("DPX/Cineon: Cannot allocate mergedData.\n"); + for (i = 0; i < logImage->numElements; i++) + if (elementData[i] != 0) + MEM_freeN(elementData[i]); + return 1; + } + + sampleIndex = 0; + while (sampleIndex < logImage->width * logImage->height * mergedElement.depth) { + for (i = 0; i < logImage->numElements; i++) + for (j = 0; j < logImage->element[sortedElementData[i]].depth; j++) + mergedData[sampleIndex++] = *(elementData_ptr[sortedElementData[i]]++); + } + + /* Done with elements data, clean-up */ + for (i = 0; i < logImage->numElements; i++) + if (elementData[i] != 0) + MEM_freeN(elementData[i]); + + returnValue = convertLogElementToRGBA(mergedData, data, logImage, mergedElement, dataIsLinearRGB); + MEM_freeN(mergedData); + } + return returnValue; } -#if 0 -/* bytes per line for images packed 3 10 bit pixels to 32 bits, 32 bit aligned */ -int -bytesPerLine_10_4(int numPixels) { - return ((numPixels + 2) / 3) * 4; +static int logImageElementGetData(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + switch (logElement.bitsPerSample) { + case 1: + return logImageElementGetData1(logImage, logElement, data); + + case 8: + return logImageElementGetData8(logImage, logElement, data); + + case 10: + if (logElement.packing == 0) + return logImageElementGetData10Packed(logImage, logElement, data); + else if (logElement.packing == 1 || logElement.packing == 2) + return logImageElementGetData10(logImage, logElement, data); + + case 12: + if (logElement.packing == 0) + return logImageElementGetData12Packed(logImage, logElement, data); + else if (logElement.packing == 1 || logElement.packing == 2) + return logImageElementGetData12(logImage, logElement, data); + + case 16: + return logImageElementGetData16(logImage, logElement, data); + + default: + /* format not supported */ + return 1; + } } -void -seekLine_noPadding(LogImageFile* logImage, int lineNumber) { - int fileOffset = bytesPerLine_10_4(lineNumber * logImage->width * logImage->depth); - int filePos = logImage->imageOffset + fileOffset; - if (fseek(logImage->file, filePos, SEEK_SET) != 0) { - /* complain? */ - } -} - -void -seekLine_padding(LogImageFile* logImage, int lineNumber) { - int fileOffset = lineNumber * bytesPerLine_10_4(logImage->width * logImage->depth); - int filePos = logImage->imageOffset + fileOffset; - if (fseek(logImage->file, filePos, SEEK_SET) != 0) { - /* complain? */ - } -} -#endif +static int logImageElementGetData1(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + unsigned int pixel; + int x, y, offset; + + /* seek at the right place */ + if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) { + if (verbose) printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset); + return 1; + } + + /* read 1 bit data padded to 32 bits */ + for (y = 0; y < logImage->height; y++) { + for (x = 0; x < logImage->width * logElement.depth; x += 32) { + if (logimage_read_uint(&pixel, logImage) != 0) { + if (verbose) printf("DPX/Cineon: EOF reached\n"); + return 1; + } + pixel = swap_uint(pixel, logImage->isMSB); + for (offset = 0; offset < 32 && x + offset < logImage->width; offset++) + data[y * logImage->width * logElement.depth + x + offset] = (float)((pixel >> offset) & 0x01); + } + } + return 0; +} + +static int logImageElementGetData8(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + unsigned int rowLength = getRowLength(logImage->width, logElement); + unsigned char pixel; + int x, y; + + /* extract required pixels */ + for (y = 0; y < logImage->height; y++) { + /* 8 bits are 32-bits padded so we need to seek at each row */ + if (logimage_fseek(logImage, logElement.dataOffset + y * rowLength, SEEK_SET) != 0) { + if (verbose) printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset + y * rowLength); + return 1; + } + + for (x = 0; x < logImage->width * logElement.depth; x++) { + if (logimage_read_uchar(&pixel, logImage) != 0) { + if (verbose) printf("DPX/Cineon: EOF reached\n"); + return 1; + } + data[y * logImage->width * logElement.depth + x] = (float)pixel / 255.0f; + } + } + return 0; +} + +static int logImageElementGetData10(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + unsigned int pixel; + int x, y, offset; + + /* seek to data */ + if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) { + if (verbose) printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset); + return 1; + } + + if (logImage->depth == 1 && logImage->srcFormat == format_DPX) { + for (y = 0; y < logImage->height; y++) { + offset = 32; + for (x = 0; x < logImage->width * logElement.depth; x++) { + /* we need to read the next long */ + if (offset >= 30) { + if (logElement.packing == 1) + offset = 2; + else if (logElement.packing == 2) + offset = 0; + + if (logimage_read_uint(&pixel, logImage) != 0) { + if (verbose) printf("DPX/Cineon: EOF reached\n"); + return 1; + } + pixel = swap_uint(pixel, logImage->isMSB); + } + data[y * logImage->width * logElement.depth + x] = (float)((pixel >> offset) & 0x3ff) / 1023.0f; + offset += 10; + } + } + } + else { + for (y = 0; y < logImage->height; y++) { + offset = -1; + for (x = 0; x < logImage->width * logElement.depth; x++) { + /* we need to read the next long */ + if (offset < 0) { + if (logElement.packing == 1) + offset = 22; + else if (logElement.packing == 2) + offset = 20; + + if (logimage_read_uint(&pixel, logImage) != 0) { + if (verbose) printf("DPX/Cineon: EOF reached\n"); + return 1; + } + pixel = swap_uint(pixel, logImage->isMSB); + } + data[y * logImage->width * logElement.depth + x] = (float)((pixel >> offset) & 0x3ff) / 1023.0f; + offset -= 10; + } + } + } + + return 0; +} + +static int logImageElementGetData10Packed(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + unsigned int rowLength = getRowLength(logImage->width, logElement); + unsigned int pixel, oldPixel; + int offset, offset2, x, y; + + /* converting bytes to pixels */ + for (y = 0; y < logImage->height; y++) { + /* seek to data */ + if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) { + if (verbose) printf("DPX/Cineon: Couldn't seek at %u\n", y * rowLength + logElement.dataOffset); + return 1; + } + + oldPixel = 0; + offset = 0; + offset2 = 0; + + for (x = 0; x < logImage->width * logElement.depth; x++) { + if (offset2 != 0) { + offset = 10 - offset2; + offset2 = 0; + oldPixel = 0; + } + else if (offset == 32) { + offset = 0; + } + else if (offset + 10 > 32) { + /* next pixel is on two different longs */ + oldPixel = (pixel >> offset); + offset2 = 32 - offset; + offset = 0; + } + + if (offset == 0) { + /* we need to read the next long */ + if (logimage_read_uint(&pixel, logImage) != 0) { + if (verbose) printf("DPX/Cineon: EOF reached\n"); + return 1; + } + pixel = swap_uint(pixel, logImage->isMSB); + } + data[y * logImage->width * logElement.depth + x] = (float)((((pixel << offset2) >> offset) & 0x3ff) | oldPixel) / 1023.0f; + offset += 10; + } + } + return 0; +} + +static int logImageElementGetData12(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + unsigned int sampleIndex; + unsigned int numSamples = logImage->width * logImage->height * logElement.depth; + unsigned short pixel; + + /* seek to data */ + if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) { + if (verbose) printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset); + return 1; + } + + /* convert bytes to pixels */ + sampleIndex = 0; + + for (sampleIndex = 0; sampleIndex < numSamples; sampleIndex++) { + if (logimage_read_ushort(&pixel, logImage) != 0) { + if (verbose) printf("DPX/Cineon: EOF reached\n"); + return 1; + } + pixel = swap_ushort(pixel, logImage->isMSB); + + if (logElement.packing == 1) /* padded to the right */ + data[sampleIndex] = (float)(pixel >> 4) / 4095.0f; + else if (logElement.packing == 2) /* padded to the left */ + data[sampleIndex] = (float)pixel / 4095.0f; + } + return 0; +} + +static int logImageElementGetData12Packed(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + unsigned int rowLength = getRowLength(logImage->width, logElement); + unsigned int pixel, oldPixel; + int offset, offset2, x, y; + + /* converting bytes to pixels */ + for (y = 0; y < logImage->height; y++) { + /* seek to data */ + if (logimage_fseek(logImage, y * rowLength + logElement.dataOffset, SEEK_SET) != 0) { + if (verbose) printf("DPX/Cineon: Couldn't seek at %u\n", y * rowLength + logElement.dataOffset); + return 1; + } + + oldPixel = 0; + offset = 0; + offset2 = 0; + + for (x = 0; x < logImage->width * logElement.depth; x++) { + if (offset2 != 0) { + offset = 12 - offset2; + offset2 = 0; + oldPixel = 0; + } + else if (offset == 32) { + offset = 0; + } + else if (offset + 12 > 32) { + /* next pixel is on two different longs */ + oldPixel = (pixel >> offset); + offset2 = 32 - offset; + offset = 0; + } + + if (offset == 0) { + /* we need to read the next long */ + if (logimage_read_uint(&pixel, logImage) != 0) { + if (verbose) printf("DPX/Cineon: EOF reached\n"); + return 1; + } + pixel = swap_uint(pixel, logImage->isMSB); + } + data[y * logImage->width * logElement.depth + x] = (float)((((pixel << offset2) >> offset) & 0xfff) | oldPixel) / 4095.0f; + offset += 12; + } + } + return 0; +} + +static int logImageElementGetData16(LogImageFile *logImage, LogImageElement logElement, float *data) +{ + unsigned int numSamples = logImage->width * logImage->height * logElement.depth; + unsigned int sampleIndex; + unsigned short pixel; + + /* seek to data */ + if (logimage_fseek(logImage, logElement.dataOffset, SEEK_SET) != 0) { + if (verbose) printf("DPX/Cineon: Couldn't seek at %d\n", logElement.dataOffset); + return 1; + } + + for (sampleIndex = 0; sampleIndex < numSamples; sampleIndex++) { + if (logimage_read_ushort(&pixel, logImage) != 0) { + if (verbose) printf("DPX/Cineon: EOF reached\n"); + return 1; + } + pixel = swap_ushort(pixel, logImage->isMSB); + data[sampleIndex] = (float)pixel / 65535.0f; + } + + return 0; +} + + +/* + * Color conversion + */ + +static int getYUVtoRGBMatrix(float *matrix, LogImageElement logElement) +{ + float scaleY, scaleCbCr; + float refHighData = (float)logElement.refHighData / logElement.maxValue; + float refLowData = (float)logElement.refLowData / logElement.maxValue; + + scaleY = 1.0f / (refHighData - refLowData); + scaleCbCr = scaleY * ((940.0f - 64.0f) / (960.0f - 64.0f)); + + switch (logElement.transfer) { + case 2: /* linear */ + matrix[0] = 1.0f * scaleY; + matrix[1] = 1.0f * scaleCbCr; + matrix[2] = 1.0f * scaleCbCr; + matrix[3] = 1.0f * scaleY; + matrix[4] = 1.0f * scaleCbCr; + matrix[5] = 1.0f * scaleCbCr; + matrix[6] = 1.0f * scaleY; + matrix[7] = 1.0f * scaleCbCr; + matrix[8] = 1.0f * scaleCbCr; + return 0; + + case 5: /* SMPTE 240M */ + matrix[0] = 1.0000f * scaleY; + matrix[1] = 0.0000f * scaleCbCr; + matrix[2] = 1.5756f * scaleCbCr; + matrix[3] = 1.0000f * scaleY; + matrix[4] = -0.2253f * scaleCbCr; + matrix[5] = -0.5000f * scaleCbCr; + matrix[6] = 1.0000f * scaleY; + matrix[7] = 1.8270f * scaleCbCr; + matrix[8] = 0.0000f * scaleCbCr; + return 0; + + case 6: /* CCIR 709-1 */ + matrix[0] = 1.000000f * scaleY; + matrix[1] = 0.000000f * scaleCbCr; + matrix[2] = 1.574800f * scaleCbCr; + matrix[3] = 1.000000f * scaleY; + matrix[4] = -0.187324f * scaleCbCr; + matrix[5] = -0.468124f * scaleCbCr; + matrix[6] = 1.000000f * scaleY; + matrix[7] = 1.855600f * scaleCbCr; + matrix[8] = 0.000000f * scaleCbCr; + return 0; + + case 7: /* CCIR 601 */ + case 8: /* I'm not sure 7 and 8 should share the same matrix */ + matrix[0] = 1.000000f * scaleY; + matrix[1] = 0.000000f * scaleCbCr; + matrix[2] = 1.402000f * scaleCbCr; + matrix[3] = 1.000000f * scaleY; + matrix[4] = -0.344136f * scaleCbCr; + matrix[5] = -0.714136f * scaleCbCr; + matrix[6] = 1.000000f * scaleY; + matrix[7] = 1.772000f * scaleCbCr; + matrix[8] = 0.000000f * scaleCbCr; + return 0; + + default: + return 1; + } +} + +static void getLinToLogLut(float *lut, LogImageFile *logImage, LogImageElement logElement) +{ + float gain, negativeFilmGamma, offset, step; + unsigned int i; + + negativeFilmGamma = 0.6; + step = logElement.refHighQuantity / logElement.maxValue; + gain = logElement.maxValue / (1.0f - powf(10, (logImage->referenceBlack - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f)); + offset = gain - logElement.maxValue; + + for (i = 0; i < (int)(logElement.maxValue + 1); i++) + lut[i] = (logImage->referenceWhite + log10f(powf((i + offset) / gain, 1.7f / logImage->gamma)) / (step / negativeFilmGamma)) / logElement.maxValue; +} + +static void getLogToLinLut(float *lut, LogImageFile *logImage, LogImageElement logElement) +{ + float breakPoint, gain, kneeGain, kneeOffset, negativeFilmGamma, offset, step, softClip; + /* float filmGamma; unused */ + unsigned int i; + + /* Building the Log -> Lin LUT */ + step = logElement.refHighQuantity / logElement.maxValue; + negativeFilmGamma = 0.6; + + /* these are default values */ + /* filmGamma = 2.2f; unused */ + softClip = 0; + + breakPoint = logImage->referenceWhite - softClip; + gain = logElement.maxValue / (1.0 - powf(10, (logImage->referenceBlack - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f)); + offset = gain - logElement.maxValue; + kneeOffset = powf(10, (breakPoint - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f) * gain - offset; + kneeGain = (logElement.maxValue - kneeOffset) / powf(5 * softClip, softClip / 100); + + for (i = 0; i < (int)(logElement.maxValue + 1); i++) { + if (i < logImage->referenceBlack) + lut[i] = 0.0f; + else if (i > breakPoint) + lut[i] = (powf(i - breakPoint, softClip / 100) * kneeGain + kneeOffset) / logElement.maxValue; + else + lut[i] = (powf(10, ((float)i - logImage->referenceWhite) * step / negativeFilmGamma * logImage->gamma / 1.7f) * gain - offset) / logElement.maxValue; + } +} + +static void getLinToSrgbLut(float *lut, LogImageElement logElement) +{ + unsigned int i; + float col; + + for (i = 0; i < (int)(logElement.maxValue + 1); i++) { + col = (float)i / logElement.maxValue; + if (col < 0.0031308f) + lut[i] = (col < 0.0f) ? 0.0f : col * 12.92f; + else + lut[i] = 1.055f * powf(col, 1.0f / 2.4f) - 0.055f; + } +} + +static void getSrgbToLinLut(float *lut, LogImageElement logElement) +{ + unsigned int i; + float col; + + for (i = 0; i < (int)(logElement.maxValue + 1); i++) { + col = (float)i / logElement.maxValue; + if (col < 0.04045f) + lut[i] = (col < 0.0f) ? 0.0f : col * (1.0f / 12.92f); + else + lut[i] = powf((col + 0.055f) * (1.0f / 1.055f), 2.4f); + } +} + +static int convertRGBA_RGB(float *src, float *dst, LogImageFile *logImage, + LogImageElement logElement, int elementIsSource) +{ + unsigned int i; + float lut[65536]; + float *src_ptr = src; + float *dst_ptr = dst; + + switch (logElement.transfer) { + case transfer_UserDefined: + case transfer_Linear: + case transfer_Logarithmic: + for (i = 0; i < logImage->width * logImage->height; i++) { + *(dst_ptr++) = *(src_ptr++); + *(dst_ptr++) = *(src_ptr++); + *(dst_ptr++) = *(src_ptr++); + src_ptr++; + } + return 0; + + case transfer_PrintingDensity: + if (elementIsSource == 1) + getLogToLinLut((float *)&lut, logImage, logElement); + else + getLinToLogLut((float *)&lut, logImage, logElement); + + for (i = 0; i < logImage->width * logImage->height; i++) { + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + src_ptr++; + } + return 0; + + default: + return 1; + } +} + +static int convertRGB_RGBA(float *src, float *dst, LogImageFile *logImage, + LogImageElement logElement, int elementIsSource) +{ + unsigned int i; + float lut[65536]; + float *src_ptr = src; + float *dst_ptr = dst; + + switch (logElement.transfer) { + case transfer_UserDefined: + case transfer_Linear: + case transfer_Logarithmic: + for (i = 0; i < logImage->width * logImage->height; i++) { + *(dst_ptr++) = *(src_ptr++); + *(dst_ptr++) = *(src_ptr++); + *(dst_ptr++) = *(src_ptr++); + *(dst_ptr++) = 1.0f; + } + return 0; + + case transfer_PrintingDensity: + if (elementIsSource == 1) + getLogToLinLut((float *)&lut, logImage, logElement); + else + getLinToLogLut((float *)&lut, logImage, logElement); + + for (i = 0; i < logImage->width * logImage->height; i++) { + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(dst_ptr++) = 1.0f; + } + return 0; + + default: + return 1; + } +} + +static int convertRGBA_RGBA(float *src, float *dst, LogImageFile *logImage, + LogImageElement logElement, int elementIsSource) +{ + unsigned int i; + float lut[65536]; + float *src_ptr = src; + float *dst_ptr = dst; + + switch (logElement.transfer) { + case transfer_UserDefined: + case transfer_Linear: + case transfer_Logarithmic: + memcpy(dst, src, 4 * logImage->width * logImage->height * sizeof(float)); + return 0; + + case transfer_PrintingDensity: + if (elementIsSource == 1) + getLogToLinLut((float *)&lut, logImage, logElement); + else + getLinToLogLut((float *)&lut, logImage, logElement); + + for (i = 0; i < logImage->width * logImage->height; i++) { + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(dst_ptr++) = *(src_ptr++); + } + return 0; + + default: + return 1; + } +} + +static int convertABGR_RGBA(float *src, float *dst, LogImageFile *logImage, + LogImageElement logElement, int elementIsSource) +{ + unsigned int i; + float lut[65536]; + float *src_ptr = src; + float *dst_ptr = dst; + + switch (logElement.transfer) { + case transfer_UserDefined: + case transfer_Linear: + case transfer_Logarithmic: + for (i = 0; i < logImage->width * logImage->height; i++) { + src_ptr += 4; + *(dst_ptr++) = *(src_ptr--); + *(dst_ptr++) = *(src_ptr--); + *(dst_ptr++) = *(src_ptr--); + *(dst_ptr++) = *(src_ptr--); + src_ptr += 4; + } + return 0; + + case transfer_PrintingDensity: + if (elementIsSource == 1) + getLogToLinLut((float *)&lut, logImage, logElement); + else + getLinToLogLut((float *)&lut, logImage, logElement); + + for (i = 0; i < logImage->width * logImage->height; i++) { + src_ptr += 4; + *(dst_ptr++) = lut[float_uint(*(src_ptr--), logElement.maxValue)]; + *(dst_ptr++) = lut[float_uint(*(src_ptr--), logElement.maxValue)]; + *(dst_ptr++) = lut[float_uint(*(src_ptr--), logElement.maxValue)]; + *(dst_ptr++) = *(src_ptr--); + src_ptr += 4; + } + return 0; + + default: + return 1; + } +} + +static int convertCbYCr_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement) +{ + unsigned int i; + float conversionMatrix[9], refLowData, y, cb, cr; + float *src_ptr = src; + float *dst_ptr = dst; + + if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) + return 1; + + refLowData = (float)logElement.refLowData / logElement.maxValue; + + for (i = 0; i < logImage->width * logImage->height; i++) { + cb = *(src_ptr++) - 0.5f; + y = *(src_ptr++) - refLowData; + cr = *(src_ptr++) - 0.5f; + + *(dst_ptr++) = clamp_float(y * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f); + *(dst_ptr++) = 1.0f; + } + return 0; +} + +static int convertCbYCrA_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement) +{ + unsigned int i; + float conversionMatrix[9], refLowData, y, cb, cr, a; + float *src_ptr = src; + float *dst_ptr = dst; + + if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) + return 1; + + refLowData = (float)logElement.refLowData / logElement.maxValue; + + for (i = 0; i < logImage->width * logImage->height; i++) { + cb = *(src_ptr++) - 0.5f; + y = *(src_ptr++) - refLowData; + cr = *(src_ptr++) - 0.5f; + a = *(src_ptr++); + + *(dst_ptr++) = clamp_float(y * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f); + *(dst_ptr++) = a; + } + return 0; +} + +static int convertCbYCrY_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement) +{ + unsigned int i; + float conversionMatrix[9], refLowData, y1, y2, cb, cr; + float *src_ptr = src; + float *dst_ptr = dst; + + if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) + return 1; + + refLowData = (float)logElement.refLowData / logElement.maxValue; + + for (i = 0; i < logImage->width * logImage->height / 2; i++) { + cb = *(src_ptr++) - 0.5f; + y1 = *(src_ptr++) - refLowData; + cr = *(src_ptr++) - 0.5f; + y2 = *(src_ptr++) - refLowData; + + *(dst_ptr++) = clamp_float(y1 * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y1 * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y1 * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f); + *(dst_ptr++) = 1.0f; + *(dst_ptr++) = clamp_float(y2 * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y2 * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y2 * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f); + *(dst_ptr++) = 1.0f; + } + return 0; +} + +static int convertCbYACrYA_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement) +{ + unsigned int i; + float conversionMatrix[9], refLowData, y1, y2, cb, cr, a1, a2; + float *src_ptr = src; + float *dst_ptr = dst; + + if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) + return 1; + + refLowData = (float)logElement.refLowData / logElement.maxValue; + + for (i = 0; i < logImage->width * logImage->height / 2; i++) { + cb = *(src_ptr++) - 0.5f; + y1 = *(src_ptr++) - refLowData; + a1 = *(src_ptr++); + cr = *(src_ptr++) - 0.5f; + y2 = *(src_ptr++) - refLowData; + a2 = *(src_ptr++); + + *(dst_ptr++) = clamp_float(y1 * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y1 * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y1 * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f); + *(dst_ptr++) = a1; + *(dst_ptr++) = clamp_float(y2 * conversionMatrix[0] + cb * conversionMatrix[1] + cr * conversionMatrix[2], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y2 * conversionMatrix[3] + cb * conversionMatrix[4] + cr * conversionMatrix[5], 0.0f, 1.0f); + *(dst_ptr++) = clamp_float(y2 * conversionMatrix[6] + cb * conversionMatrix[7] + cr * conversionMatrix[8], 0.0f, 1.0f); + *(dst_ptr++) = a2; + } + return 0; +} + +static int convertLuminance_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement) +{ + unsigned int i; + float conversionMatrix[9], value, refLowData; + float *src_ptr = src; + float *dst_ptr = dst; + + if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) + return 1; + + refLowData = (float)logElement.refLowData / logElement.maxValue; + + for (i = 0; i < logImage->width * logImage->height; i++) { + value = clamp_float((*(src_ptr++) - refLowData) * conversionMatrix[0], 0.0f, 1.0f); + *(dst_ptr++) = value; + *(dst_ptr++) = value; + *(dst_ptr++) = value; + *(dst_ptr++) = 1.0f; + } + return 0; +} + +static int convertYA_RGBA(float *src, float *dst, LogImageFile *logImage, LogImageElement logElement) +{ + unsigned int i; + float conversionMatrix[9], value, refLowData; + float *src_ptr = src; + float *dst_ptr = dst; + + if (getYUVtoRGBMatrix((float *)&conversionMatrix, logElement) != 0) + return 1; + + refLowData = (float)logElement.refLowData / logElement.maxValue; + + for (i = 0; i < logImage->width * logImage->height; i++) { + value = clamp_float((*(src_ptr++) - refLowData) * conversionMatrix[0], 0.0f, 1.0f); + *(dst_ptr++) = value; + *(dst_ptr++) = value; + *(dst_ptr++) = value; + *(dst_ptr++) = *(src_ptr++); + } + return 0; +} + +static int convertLogElementToRGBA(float *src, float *dst, LogImageFile *logImage, + LogImageElement logElement, int dstIsLinearRGB) +{ + int rvalue; + unsigned int i; + float *src_ptr; + float *dst_ptr; + float lut[65536]; + + /* Convert data in src to linear RGBA in dst */ + switch (logElement.descriptor) { + case descriptor_RGB: + rvalue = convertRGB_RGBA(src, dst, logImage, logElement, 1); + break; + + case descriptor_RGBA: + rvalue = convertRGBA_RGBA(src, dst, logImage, logElement, 1); + break; + + case descriptor_ABGR: + rvalue = convertABGR_RGBA(src, dst, logImage, logElement, 1); + break; + + case descriptor_Luminance: + rvalue = convertLuminance_RGBA(src, dst, logImage, logElement); + break; + + case descriptor_CbYCr: + rvalue = convertCbYCr_RGBA(src, dst, logImage, logElement); + break; + + case descriptor_CbYCrY: + rvalue = convertCbYCrY_RGBA(src, dst, logImage, logElement); + break; + + case descriptor_CbYACrYA: + rvalue = convertCbYACrYA_RGBA(src, dst, logImage, logElement); + break; + + case descriptor_CbYCrA: + rvalue = convertCbYCrA_RGBA(src, dst, logImage, logElement); + break; + + case descriptor_YA: /* this descriptor is for internal use only */ + rvalue = convertYA_RGBA(src, dst, logImage, logElement); + break; + + default: + return 1; + } + + if (rvalue == 1) + return 1; + else if (dstIsLinearRGB) { + /* convert data from sRGB to Linear RGB via lut */ + getSrgbToLinLut((float *)&lut, logElement); + src_ptr = dst; // no error here + dst_ptr = dst; + for (i = 0; i < logImage->width * logImage->height; i++) { + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(dst_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + dst_ptr++; src_ptr++; + } + } + return 0; +} + +static int convertRGBAToLogElement(float *src, float *dst, LogImageFile *logImage, + LogImageElement logElement, int srcIsLinearRGB) +{ + unsigned int i; + int rvalue; + float *srgbSrc; + float *srgbSrc_ptr; + float *src_ptr = src; + float lut[65536]; + + if (srcIsLinearRGB != 0) { + /* we need to convert src to sRGB */ + srgbSrc = (float *)MEM_mallocN(4 * logImage->width * logImage->height * sizeof(float), __func__); + if (srgbSrc == 0) + return 1; + + memcpy(srgbSrc, src, 4 * logImage->width * logImage->height * sizeof(float)); + srgbSrc_ptr = srgbSrc; + + /* convert data from Linear RGB to sRGB via lut */ + getLinToSrgbLut((float *)&lut, logElement); + for (i = 0; i < logImage->width * logImage->height; i++) { + *(srgbSrc_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(srgbSrc_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + *(srgbSrc_ptr++) = lut[float_uint(*(src_ptr++), logElement.maxValue)]; + srgbSrc_ptr++; src_ptr++; + } + } + else + srgbSrc = src; + + /* Convert linear RGBA data in src to format described by logElement in dst */ + switch (logElement.descriptor) { + case descriptor_RGB: + rvalue = convertRGBA_RGB(srgbSrc, dst, logImage, logElement, 0); + break; + + case descriptor_RGBA: + rvalue = convertRGBA_RGBA(srgbSrc, dst, logImage, logElement, 0); + break; + + /* these ones are not supported for the moment */ + case descriptor_ABGR: + case descriptor_Luminance: + case descriptor_CbYCr: + case descriptor_CbYCrY: + case descriptor_CbYACrYA: + case descriptor_CbYCrA: + case descriptor_YA: /* this descriptor is for internal use only */ + default: + rvalue = 1; + } + + if (srcIsLinearRGB != 0) { + MEM_freeN(srgbSrc); + } + + return rvalue; +} diff --git a/source/blender/imbuf/intern/cineon/logImageCore.h b/source/blender/imbuf/intern/cineon/logImageCore.h index 7d88c10c2d6..7c75f8b730b 100644 --- a/source/blender/imbuf/intern/cineon/logImageCore.h +++ b/source/blender/imbuf/intern/cineon/logImageCore.h @@ -1,123 +1,283 @@ /* - * Cineon image file format library definitions. - * Cineon and DPX common structures. + * Cineon image file format library definitions. + * Cineon and DPX common structures. * - * This header file contains private details. - * User code should generally use cineonlib.h and dpxlib.h only. - * Hmm. I thought the two formats would have more in common! + * This header file contains private details. + * User code should generally use cineonlib.h and dpxlib.h only. + * Hmm. I thought the two formats would have more in common! * - * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> + * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> * - * 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 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. + * 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. + * 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. + * + * Contributor(s): Julien Enche. * */ -#ifndef __LOGIMAGECORE_H__ -#define __LOGIMAGECORE_H__ - /** \file blender/imbuf/intern/cineon/logImageCore.h * \ingroup imbcineon */ +#ifndef __LOG_IMAGE_CORE_H__ +#define __LOG_IMAGE_CORE_H__ + #include <stdio.h> -#include "logImageLib.h" + +#include "BLO_sys_types.h" +#include "BLI_utildefines.h" #ifdef __cplusplus extern "C" { #endif -#include "BLO_sys_types.h" // for intptr_t support +/* + * Image structure + */ -#ifdef _MSC_VER -#undef ntohl -#undef htonl -#endif +/* There are some differences between DPX and Cineon so we need to know from what type of file the datas come from */ +enum format { + format_DPX, + format_Cineon +}; -typedef int (GetRowFn)(LogImageFile* logImage, unsigned short* row, int lineNum); -typedef int (SetRowFn)(LogImageFile* logImage, const unsigned short* row, int lineNum); -typedef void (CloseFn)(LogImageFile* logImage); +typedef struct LogImageElement +{ + int depth; + int bitsPerSample; + int dataOffset; + int packing; + int transfer; + int descriptor; + unsigned int refLowData; + unsigned int refHighData; + float refLowQuantity; + float refHighQuantity; + float maxValue; /* = 2^bitsPerSample - 1 (used internally, doesn't come from the file header) */ +} LogImageElement; -struct _Log_Image_File_t_ +typedef struct LogImageFile { /* specified in header */ int width; int height; + int numElements; int depth; - int bitsPerPixel; - int imageOffset; + LogImageElement element[8]; - /* file buffer, measured in longwords (4 byte) */ - int lineBufferLength; - unsigned int* lineBuffer; - - /* pixel buffer, holds 10 bit pixel values */ - unsigned short* pixelBuffer; - int pixelBufferUsed; + /* used for log <-> lin conversion */ + float referenceBlack; + float referenceWhite; + float gamma; /* io stuff */ - FILE* file; - int reading; - int fileYPos; + FILE *file; + unsigned char *memBuffer; + uintptr_t memBufferSize; + unsigned char *memCursor; - /* byte conversion stuff */ - LogImageByteConversionParameters params; -#if 0 - float gamma; - int blackPoint; - int whitePoint; -#endif - unsigned char lut10[1024]; - unsigned short lut8[256]; - - unsigned short lut10_16[1024]; - unsigned short lut16_16[65536]; - - /* pixel access functions */ - GetRowFn* getRow; - SetRowFn* setRow; - CloseFn* close; - - unsigned char *membuffer; - uintptr_t membuffersize; - unsigned char *memcursor; + /* is the file LSB or MSB ? */ + int isMSB; + + /* DPX or Cineon ? */ + int srcFormat; +} LogImageFile; + + +/* The SMPTE defines this code: + * 0 - User-defined + * 1 - Printing density + * 2 - Linear + * 3 - Logarithmic + * 4 - Unspecified video + * 5 - SMPTE 240M + * 6 - CCIR 709-1 + * 7 - CCIR 601-2 system B or G + * 8 - CCIR 601-2 system M + * 9 - NTSC composite video + * 10 - PAL composite video + * 11 - Z linear + * 12 - homogeneous + * + * Note that transfer_characteristics is U8, don't need + * check the byte order. + */ + +enum transfer { + transfer_UserDefined, + transfer_PrintingDensity, + transfer_Linear, + transfer_Logarithmic, + transfer_Unspecified, + transfer_Smpte240M, + transfer_Ccir7091, + transfer_Ccir6012BG, + transfer_Ccir6012M, + transfer_NTSC, + transfer_PAL, + transfer_ZLinear, + transfer_Homogeneous +}; + +/* The SMPTE defines this code: + * 0 - User-defined + * 1 - Red + * 2 - Green + * 3 - Blue + * 4 - Alpha + * 6 - Luminance + * 7 - Chrominance + * 8 - Depth + * 9 - Composite video + * 50 - RGB + * 51 - RGBA + * 52 - ABGR + * 100 - CbYCrY + * 101 - CbYACrYA + * 102 - CbYCr + * 103 - CbYCrA + * 150 - User-defined 2-component element + * 151 - User-defined 3-component element + * 152 - User-defined 4-component element + * 153 - User-defined 5-component element + * 154 - User-defined 6-component element + * 155 - User-defined 7-component element + * 156 - User-defined 8-component element + */ + +enum descriptor { + descriptor_UserDefined, + descriptor_Red, + descriptor_Green, + descriptor_Blue, + descriptor_Alpha, + descriptor_Luminance = 6, /* don't ask me why there's no 5 */ + descriptor_Chrominance, + descriptor_Depth, + descriptor_Composite, + descriptor_RGB = 50, + descriptor_RGBA, + descriptor_ABGR, + descriptor_CbYCrY = 100, + descriptor_CbYACrYA, + descriptor_CbYCr, + descriptor_CbYCrA, + descriptor_UserDefined2Elt = 150, + descriptor_UserDefined3Elt, + descriptor_UserDefined4Elt, + descriptor_UserDefined5Elt, + descriptor_UserDefined6Elt, + descriptor_UserDefined7Elt, + descriptor_UserDefined8Elt, + /* following descriptors are for internal use only */ + descriptor_YA }; -void setupLut(LogImageFile*); -void setupLut16(LogImageFile*); +/* int functions return 0 for OK */ -int pixelsToLongs(int numPixels); +void logImageSetVerbose(int verbosity); +int logImageIsDpx(const void *buffer); +int logImageIsCineon(const void *buffer); +LogImageFile *logImageOpenFromMemory(const unsigned char *buffer, unsigned int size); +LogImageFile *logImageOpenFromFile(const char *filename, int cineon); +void logImageGetSize(LogImageFile *logImage, int *width, int *height, int *depth); +LogImageFile *logImageCreate(const char *filename, int cineon, int width, int height, int bitsPerSample, + int isLogarithmic, int hasAlpha, int referenceWhite, int referenceBlack, + float gamma, const char *creator); +void logImageClose(LogImageFile *logImage); -/* typedefs used in original docs */ -/* note size assumptions! */ +/* Data handling */ +unsigned int getRowLength(int width, LogImageElement logElement); +int logImageSetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB); +int logImageGetDataRGBA(LogImageFile *logImage, float *data, int dataIsLinearRGB); -typedef unsigned int U32; -typedef unsigned short U16; -typedef unsigned char U8; -typedef signed int S32; -typedef float R32; -typedef char ASCII; +/* + * Inline routines + */ + +/* Endianness swapping */ + +BLI_INLINE unsigned short swap_ushort(unsigned short x, int swap) +{ + if (swap != 0) + return (x >> 8) | (x << 8); + else + return x; +} + +BLI_INLINE unsigned int swap_uint(unsigned int x, int swap) +{ + if (swap != 0) + return (x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24); + else + return x; +} + +BLI_INLINE float swap_float(float x, int swap) +{ + if (swap != 0) { + union { + float f; + unsigned char b[4]; + } dat1, dat2; + + dat1.f = x; + dat2.b[0] = dat1.b[3]; + dat2.b[1] = dat1.b[2]; + dat2.b[2] = dat1.b[1]; + dat2.b[3] = dat1.b[0]; + return dat2.f; + } + else + return x; +} + +/* Other */ + +BLI_INLINE unsigned int clamp_uint(unsigned int x, unsigned int low, unsigned int high) +{ + if (x > high) + return high; + else if (x < low) + return low; + else + return x; +} + +BLI_INLINE float clamp_float(float x, float low, float high) +{ + if (x > high) + return high; + else if (x < low) + return low; + else + return x; +} + +BLI_INLINE unsigned int float_uint(float value, unsigned int max) +{ + if (value < 0.0f) + return 0; + else if (value > (1.0f - 0.5f / (float)max)) + return max; + else + return (unsigned int)(((float)max * value) + 0.5f); +} -R32 htonf(R32 f); -R32 ntohf(R32 f); -R32 undefined(void); -U16 reverseU16(U16 value); -U32 reverseU32(U32 value); -R32 reverseR32(R32 value); #ifdef __cplusplus } #endif -#endif /* __LOGIMAGECORE_H__ */ +#endif /* __LOG_IMAGE_CORE_H__ */ diff --git a/source/blender/imbuf/intern/cineon/logImageLib.c b/source/blender/imbuf/intern/cineon/logImageLib.c index ccc6045e6e5..e69de29bb2d 100644 --- a/source/blender/imbuf/intern/cineon/logImageLib.c +++ b/source/blender/imbuf/intern/cineon/logImageLib.c @@ -1,183 +0,0 @@ -/* - * Cineon and DPX image file format library routines. - * - * Copyright 1999 - 2002 David Hodson <hodsond@acm.org> - * - * 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. - * - */ - -/** \file blender/imbuf/intern/cineon/logImageLib.c - * \ingroup imbcineon - */ - -#include "cineonlib.h" -#include "dpxlib.h" - -#include <stdio.h> -#include <math.h> -#include <stdlib.h> -#include <time.h> /* strftime() */ -#include <sys/types.h> -#ifdef WIN32 -#include <winsock.h> -#else -#include <netinet/in.h> /* htonl() */ -#endif -#include <string.h> /* memset */ -#include "BLI_fileops.h" - -#define MIN_GAMMA 0.01 -#define MAX_GAMMA 99.9 -#define DEFAULT_GAMMA 1.0 -#define DEFAULT_BLACK_POINT 95 -#define DEFAULT_WHITE_POINT 685 - -void -logImageSetVerbose(int verbosity) -{ - cineonSetVerbose(verbosity); - dpxSetVerbose(verbosity); -} - -LogImageFile* -logImageOpen(const char* filename, int cineon) -{ - if (cineon) { - return cineonOpen(filename); - } - else { - return dpxOpen(filename); - } - return 0; -} - -LogImageFile* -logImageOpenFromMem(unsigned char *buffer, unsigned int size, int cineon) -{ - if (cineon) { - return cineonOpenFromMem(buffer, size); - } - else { - return dpxOpenFromMem(buffer, size); - } - return 0; -} - -LogImageFile* -logImageCreate(const char* filename, int cineon, int width, int height, int depth) -{ - if (cineon) { - return cineonCreate(filename, width, height, depth); - } - else { - return dpxCreate(filename, width, height, depth); - } - return 0; -} - -int -logImageGetSize(const LogImageFile* logImage, int* width, int* height, int* depth) -{ - *width = logImage->width; - *height = logImage->height; - *depth = logImage->depth; - return 0; -} - -int -logImageGetByteConversionDefaults(LogImageByteConversionParameters* params) -{ - params->gamma = DEFAULT_GAMMA; - params->blackPoint = DEFAULT_BLACK_POINT; - params->whitePoint = DEFAULT_WHITE_POINT; - params->doLogarithm = 0; - return 0; -} - -int -logImageGetByteConversion(const LogImageFile* logImage, LogImageByteConversionParameters* params) -{ - params->gamma = logImage->params.gamma; - params->blackPoint = logImage->params.blackPoint; - params->whitePoint = logImage->params.whitePoint; - params->doLogarithm = 0; - return 0; -} - -int -logImageSetByteConversion(LogImageFile* logImage, const LogImageByteConversionParameters* params) -{ - if ((params->gamma >= MIN_GAMMA) && - (params->gamma <= MAX_GAMMA) && - (params->blackPoint >= 0) && - (params->blackPoint < params->whitePoint) && - (params->whitePoint <= 1023)) - { - logImage->params.gamma = params->gamma; - logImage->params.blackPoint = params->blackPoint; - logImage->params.whitePoint = params->whitePoint; - logImage->params.doLogarithm = params->doLogarithm; - setupLut16(logImage); - return 0; - } - return 1; -} - -int -logImageGetRowBytes(LogImageFile* logImage, unsigned short* row, int y) -{ - return logImage->getRow(logImage, row, y); -} - -int -logImageSetRowBytes(LogImageFile* logImage, const unsigned short* row, int y) -{ - return logImage->setRow(logImage, row, y); -} - -void -logImageClose(LogImageFile* logImage) -{ - logImage->close(logImage); -} - -void -logImageDump(const char* filename) -{ - - U32 magic; - - FILE* foo = BLI_fopen(filename, "rb"); - if (foo == 0) { - return; - } - - if (fread(&magic, sizeof(magic), 1, foo) == 0) { - fclose(foo); - return; - } - - fclose(foo); - - if (magic == ntohl(CINEON_FILE_MAGIC)) { -#if 0 - cineonDump(filename); -#endif - } - else if (magic == ntohl(DPX_FILE_MAGIC)) { - dpxDump(filename); - } -} diff --git a/source/blender/imbuf/intern/cineon/logImageLib.h b/source/blender/imbuf/intern/cineon/logImageLib.h index 1c24358e4ef..e69de29bb2d 100644 --- a/source/blender/imbuf/intern/cineon/logImageLib.h +++ b/source/blender/imbuf/intern/cineon/logImageLib.h @@ -1,87 +0,0 @@ -/* - * Common library definitions for Cineon and DPX image files. - * - * Copyright 1999,2000,2001 David Hodson <hodsond@acm.org> - * - * 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. - * - */ - -#ifndef __LOGIMAGELIB_H__ -#define __LOGIMAGELIB_H__ - -/** \file blender/imbuf/intern/cineon/logImageLib.h - * \ingroup imbcineon - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Image structure. You don't care what this is. - */ - -typedef struct _Log_Image_File_t_ LogImageFile; - -/* - * Magic numbers for normal and byte-swapped Cineon and Dpx files - */ - -#define CINEON_FILE_MAGIC 0x802A5FD7 -#define DPX_FILE_MAGIC 0x53445058 - -/* - * Image 8 bit <-> 10 bit conversion parameters. - */ - -typedef struct { - float gamma; - int blackPoint; - int whitePoint; - int doLogarithm; -} LogImageByteConversionParameters; - -/* int functions return 0 for OK */ - -void logImageSetVerbose(int); - -LogImageFile* logImageOpenFromMem(unsigned char *buffer, unsigned int size, int cineon); -LogImageFile* logImageOpen(const char* filename, int cineon); -int logImageGetSize(const LogImageFile* logImage, int* xsize, int* ysize, int* channels); -LogImageFile* logImageCreate(const char* filename, int cineon, int xsize, int ysize, int channels); - -/* byte conversion routines for mapping logImage (usually) 10 bit values to 8 bit */ -/* see Kodak docs for details... */ - -int logImageGetByteConversionDefaults(LogImageByteConversionParameters* params); -int logImageGetByteConversion(const LogImageFile* logImage, LogImageByteConversionParameters* params); -int logImageSetByteConversion(LogImageFile* logImage, const LogImageByteConversionParameters* params); - -/* get/set scanline of converted bytes */ -int logImageGetRowBytes(LogImageFile* logImage, unsigned short* row, int y); -int logImageSetRowBytes(LogImageFile* logImage, const unsigned short* row, int y); - -/* closes file and deletes data */ -void logImageClose(LogImageFile* logImage); - -/* read file and dump header info */ -void logImageDump(const char* filename); - -#ifdef __cplusplus -} -#endif - -#endif /* __LOGIMAGELIB_H__ */ diff --git a/source/blender/imbuf/intern/cineon/logmemfile.c b/source/blender/imbuf/intern/cineon/logmemfile.c index a9938582f2a..3914f6dc633 100644 --- a/source/blender/imbuf/intern/cineon/logmemfile.c +++ b/source/blender/imbuf/intern/cineon/logmemfile.c @@ -1,21 +1,23 @@ /* - * Cineon image file format library routines. + * Cineon image file format library routines. * - * Copyright 2006 Joseph Eagar (joeedh@gmail.com) + * Copyright 2006 Joseph Eagar (joeedh@gmail.com) * - * 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 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. + * 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. + * 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. + * + * Contributor(s): Julien Enche. * */ @@ -23,64 +25,102 @@ * \ingroup imbcineon */ + #include <stdio.h> #include <stdlib.h> #include <string.h> #include "logImageCore.h" +#include "logmemfile.h" -#include "logmemfile.h" /* own include */ - -int logimage_fseek(void* logfile, intptr_t offsett, int origin) -{ - struct _Log_Image_File_t_ *file = (struct _Log_Image_File_t_*) logfile; - intptr_t offset = offsett; - - if (file->file) fseek(file->file, offset, origin); - else { /*we're seeking in memory*/ - if (origin==SEEK_SET) { - if (offset > file->membuffersize) return 1; - file->memcursor = file->membuffer + offset; +int logimage_fseek(LogImageFile *logFile, intptr_t offset, int origin) +{ + if (logFile->file) + fseek(logFile->file, offset, origin); + else { /* we're seeking in memory */ + if (origin == SEEK_SET) { + if (offset > logFile->memBufferSize) + return 1; + logFile->memCursor = logFile->memBuffer + offset; } - else if (origin==SEEK_END) { - if (offset > file->membuffersize) return 1; - file->memcursor = (file->membuffer + file->membuffersize) - offset; + else if (origin == SEEK_END) { + if (offset > logFile->memBufferSize) + return 1; + logFile->memCursor = (logFile->memBuffer + logFile->memBufferSize) - offset; } - else if (origin==SEEK_CUR) { - uintptr_t pos = (uintptr_t)file->membuffer - (uintptr_t)file->memcursor; - if (pos + offset > file->membuffersize) return 1; - if (pos < 0) return 1; - file->memcursor += offset; + else if (origin == SEEK_CUR) { + uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer; + if (pos + offset > logFile->memBufferSize || pos < 0) + return 1; + + logFile->memCursor += offset; } } return 0; } -int logimage_fwrite(void *buffer, unsigned int size, unsigned int count, void *logfile) +int logimage_fwrite(void *buffer, size_t size, unsigned int count, LogImageFile *logFile) { - struct _Log_Image_File_t_ *file = (struct _Log_Image_File_t_*) logfile; - if (file->file) return fwrite(buffer, size, count, file->file); - else { /*we're writing to memory*/ - /*do nothing as this isn't supported yet*/ + if (logFile->file) + return fwrite(buffer, size, count, logFile->file); + else { /* we're writing to memory */ + /* do nothing as this isn't supported yet */ return count; } } -int logimage_fread(void *buffer, unsigned int size, unsigned int count, void *logfile) +int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *logFile) { - struct _Log_Image_File_t_ *file = (struct _Log_Image_File_t_*) logfile; - if (file->file) return fread(buffer, size, count, file->file); - else { /*we're reading from memory*/ - int i; - /* we convert ot uchar just on the off chance some platform can't handle - * pointer arithmetic with type (void*). */ - unsigned char *buf = (unsigned char *) buffer; - - for (i=0; i<count; i++) { - memcpy(buf, file->memcursor, size); - file->memcursor += size; - buf += size; + if (logFile->file) { + return fread(buffer, size, count, logFile->file); + } + else { /* we're reading from memory */ + unsigned char *buf = (unsigned char *)buffer; + uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer; + size_t total_size = size * count; + if (pos + total_size > logFile->memBufferSize) { + /* how many elements can we read without overflow ? */ + count = (logFile->memBufferSize - pos) / size; + /* recompute the size */ + total_size = size * count; } + + if (total_size != 0) + memcpy(buf, logFile->memCursor, total_size); + return count; } } + +int logimage_read_uchar(unsigned char *x, LogImageFile *logFile) +{ + uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer; + if (pos + sizeof(unsigned char) > logFile->memBufferSize) + return 1; + + *x = *(unsigned char *)logFile->memCursor; + logFile->memCursor += sizeof(unsigned char); + return 0; +} + +int logimage_read_ushort(unsigned short *x, LogImageFile *logFile) +{ + uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer; + if (pos + sizeof(unsigned short) > logFile->memBufferSize) + return 1; + + *x = *(unsigned short *)logFile->memCursor; + logFile->memCursor += sizeof(unsigned short); + return 0; +} + +int logimage_read_uint(unsigned int *x, LogImageFile *logFile) +{ + uintptr_t pos = (uintptr_t)logFile->memCursor - (uintptr_t)logFile->memBuffer; + if (pos + sizeof(unsigned int) > logFile->memBufferSize) + return 1; + + *x = *(unsigned int *)logFile->memCursor; + logFile->memCursor += sizeof(unsigned int); + return 0; +} diff --git a/source/blender/imbuf/intern/cineon/logmemfile.h b/source/blender/imbuf/intern/cineon/logmemfile.h index df3589a70d3..068a53e641b 100644 --- a/source/blender/imbuf/intern/cineon/logmemfile.h +++ b/source/blender/imbuf/intern/cineon/logmemfile.h @@ -1,33 +1,43 @@ /* - * Cineon image file format library routines. + * Cineon image file format library routines. * - * Copyright 2006 Joseph Eagar (joeedh@gmail.com) + * Copyright 2006 Joseph Eagar (joeedh@gmail.com) * - * 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 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. + * 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. + * 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. + * + * Contributor(s): Julien Enche. * */ - -#ifndef __LOGMEMFILE_H__ -#define __LOGMEMFILE_H__ /** \file blender/imbuf/intern/cineon/logmemfile.h * \ingroup imbcineon */ -int logimage_fseek(void* logfile, intptr_t offsett, int origin); -int logimage_fwrite(void *buffer, unsigned int size, unsigned int count, void *logfile); -int logimage_fread(void *buffer, unsigned int size, unsigned int count, void *logfile); -#endif /* __LOGMEMFILE_H__ */ +#ifndef __LOGMEMFILE_H__ +#define __LOGMEMFILE_H__ + +#include "logImageCore.h" + +#include <stdlib.h> + +int logimage_fseek(LogImageFile *logFile, intptr_t offset, int origin); +int logimage_fwrite(void *buffer, size_t size, unsigned int count, LogImageFile *logFile); +int logimage_fread(void *buffer, size_t size, unsigned int count, LogImageFile *logFile); +int logimage_read_uchar(unsigned char *x, LogImageFile *logFile); +int logimage_read_ushort(unsigned short *x, LogImageFile *logFile); +int logimage_read_uint(unsigned int *x, LogImageFile *logFile); + +#endif /* __LOGMEMFILE_H__ */ diff --git a/source/blender/imbuf/intern/dds/BlockDXT.cpp b/source/blender/imbuf/intern/dds/BlockDXT.cpp index f5e9e536e41..db2ca5969ec 100644 --- a/source/blender/imbuf/intern/dds/BlockDXT.cpp +++ b/source/blender/imbuf/intern/dds/BlockDXT.cpp @@ -232,7 +232,7 @@ void BlockDXT1::decodeBlock(ColorBlock * block) const uint idx = (row[j] >> (2 * i)) & 3; block->color(i, j) = color_array[idx]; } - } + } } void BlockDXT1::decodeBlockNV5x(ColorBlock * block) const @@ -592,7 +592,7 @@ void BlockCTX1::decodeBlock(ColorBlock * block) const uint idx = (row[j] >> (2 * i)) & 3; block->color(i, j) = color_array[idx]; } - } + } } void BlockCTX1::setIndices(int * idx) diff --git a/source/blender/imbuf/intern/dds/CMakeLists.txt b/source/blender/imbuf/intern/dds/CMakeLists.txt index e514b7ab6f9..e0b5a6c10d6 100644 --- a/source/blender/imbuf/intern/dds/CMakeLists.txt +++ b/source/blender/imbuf/intern/dds/CMakeLists.txt @@ -40,6 +40,7 @@ set(INC_SYS set(SRC BlockDXT.cpp + FlipDXT.cpp ColorBlock.cpp DirectDrawSurface.cpp Image.cpp diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp index 0b9f5c163fb..dbd87bf1426 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.cpp +++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp @@ -393,7 +393,7 @@ void ColorBlock::computeRange(Vector3::Arg axis, Color32 * start, Color32 * end) int mini, maxi; mini = maxi = 0; - float min, max; + float min, max; min = max = dot(Vector3(m_color[0].r, m_color[0].g, m_color[0].b), axis); for (uint i = 1; i < 16; i++) diff --git a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp index d9d0cb86ee0..1fd41aa8c2d 100644 --- a/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp +++ b/source/blender/imbuf/intern/dds/DirectDrawSurface.cpp @@ -737,7 +737,7 @@ void DDSHeader::setPixelFormat(uint bitcount, uint rmask, uint gmask, uint bmask { // Compute bit count from the masks. uint total = rmask | gmask | bmask | amask; - while(total != 0) { + while (total != 0) { bitcount++; total >>= 1; } diff --git a/source/blender/imbuf/intern/dds/FlipDXT.cpp b/source/blender/imbuf/intern/dds/FlipDXT.cpp new file mode 100644 index 00000000000..1a577c4dafb --- /dev/null +++ b/source/blender/imbuf/intern/dds/FlipDXT.cpp @@ -0,0 +1,255 @@ +/* + * Copyright 2009, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// This file comes from the chromium project, adapted to Blender to add DDS +// flipping to OpenGL convention for Blender + +#include "IMB_imbuf_types.h" + +#include <string.h> + +#include <Common.h> +#include <Stream.h> +#include <ColorBlock.h> +#include <BlockDXT.h> +#include <FlipDXT.h> + +// A function that flips a DXTC block. +typedef void (*FlipBlockFunction)(uint8_t *block); + +// Flips a full DXT1 block in the y direction. +static void FlipDXT1BlockFull(uint8_t *block) +{ + // A DXT1 block layout is: + // [0-1] color0. + // [2-3] color1. + // [4-7] color bitmap, 2 bits per pixel. + // So each of the 4-7 bytes represents one line, flipping a block is just + // flipping those bytes. + uint8_t tmp = block[4]; + block[4] = block[7]; + block[7] = tmp; + tmp = block[5]; + block[5] = block[6]; + block[6] = tmp; +} + +// Flips the first 2 lines of a DXT1 block in the y direction. +static void FlipDXT1BlockHalf(uint8_t *block) +{ + // See layout above. + uint8_t tmp = block[4]; + block[4] = block[5]; + block[5] = tmp; +} + +// Flips a full DXT3 block in the y direction. +static void FlipDXT3BlockFull(uint8_t *block) +{ + // A DXT3 block layout is: + // [0-7] alpha bitmap, 4 bits per pixel. + // [8-15] a DXT1 block. + + // We can flip the alpha bits at the byte level (2 bytes per line). + uint8_t tmp = block[0]; + + block[0] = block[6]; + block[6] = tmp; + tmp = block[1]; + block[1] = block[7]; + block[7] = tmp; + tmp = block[2]; + block[2] = block[4]; + block[4] = tmp; + tmp = block[3]; + block[3] = block[5]; + block[5] = tmp; + + // And flip the DXT1 block using the above function. + FlipDXT1BlockFull(block + 8); +} + +// Flips the first 2 lines of a DXT3 block in the y direction. +static void FlipDXT3BlockHalf(uint8_t *block) +{ + // See layout above. + uint8_t tmp = block[0]; + + block[0] = block[2]; + block[2] = tmp; + tmp = block[1]; + block[1] = block[3]; + block[3] = tmp; + FlipDXT1BlockHalf(block + 8); +} + +// Flips a full DXT5 block in the y direction. +static void FlipDXT5BlockFull(uint8_t *block) +{ + // A DXT5 block layout is: + // [0] alpha0. + // [1] alpha1. + // [2-7] alpha bitmap, 3 bits per pixel. + // [8-15] a DXT1 block. + + // The alpha bitmap doesn't easily map lines to bytes, so we have to + // interpret it correctly. Extracted from + // http://www.opengl.org/registry/specs/EXT/texture_compression_s3tc.txt : + // + // The 6 "bits" bytes of the block are decoded into one 48-bit integer: + // + // bits = bits_0 + 256 * (bits_1 + 256 * (bits_2 + 256 * (bits_3 + + // 256 * (bits_4 + 256 * bits_5)))) + // + // bits is a 48-bit unsigned integer, from which a three-bit control code + // is extracted for a texel at location (x,y) in the block using: + // + // code(x,y) = bits[3*(4*y+x)+1..3*(4*y+x)+0] + // + // where bit 47 is the most significant and bit 0 is the least + // significant bit. + unsigned int line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]); + unsigned int line_2_3 = block[5] + 256 * (block[6] + 256 * block[7]); + // swap lines 0 and 1 in line_0_1. + unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) | + ((line_0_1 & 0xfff000) >> 12); + // swap lines 2 and 3 in line_2_3. + unsigned int line_3_2 = ((line_2_3 & 0x000fff) << 12) | + ((line_2_3 & 0xfff000) >> 12); + + block[2] = line_3_2 & 0xff; + block[3] = (line_3_2 & 0xff00) >> 8; + block[4] = (line_3_2 & 0xff0000) >> 8; + block[5] = line_1_0 & 0xff; + block[6] = (line_1_0 & 0xff00) >> 8; + block[7] = (line_1_0 & 0xff0000) >> 8; + + // And flip the DXT1 block using the above function. + FlipDXT1BlockFull(block + 8); +} + +// Flips the first 2 lines of a DXT5 block in the y direction. +static void FlipDXT5BlockHalf(uint8_t *block) +{ + // See layout above. + unsigned int line_0_1 = block[2] + 256 * (block[3] + 256 * block[4]); + unsigned int line_1_0 = ((line_0_1 & 0x000fff) << 12) | + ((line_0_1 & 0xfff000) >> 12); + block[2] = line_1_0 & 0xff; + block[3] = (line_1_0 & 0xff00) >> 8; + block[4] = (line_1_0 & 0xff0000) >> 8; + FlipDXT1BlockHalf(block + 8); +} + +// Flips a DXTC image, by flipping and swapping DXTC blocks as appropriate. +int FlipDXTCImage(unsigned int width, unsigned int height, unsigned int levels, int fourcc, uint8_t *data) +{ + // must have valid dimensions + if(width == 0 || height == 0) + return 0; + // height must be a power-of-two + if((height & (height - 1)) != 0) + return 0; + + FlipBlockFunction full_block_function; + FlipBlockFunction half_block_function; + unsigned int block_bytes = 0; + + switch (fourcc) { + case FOURCC_DXT1: + full_block_function = FlipDXT1BlockFull; + half_block_function = FlipDXT1BlockHalf; + block_bytes = 8; + break; + case FOURCC_DXT3: + full_block_function = FlipDXT3BlockFull; + half_block_function = FlipDXT3BlockHalf; + block_bytes = 16; + break; + case FOURCC_DXT5: + full_block_function = FlipDXT5BlockFull; + half_block_function = FlipDXT5BlockHalf; + block_bytes = 16; + break; + default: + return 0; + } + + unsigned int mip_width = width; + unsigned int mip_height = height; + + for (unsigned int i = 0; i < levels; ++i) { + unsigned int blocks_per_row = (mip_width + 3) / 4; + unsigned int blocks_per_col = (mip_height + 3) / 4; + unsigned int blocks = blocks_per_row * blocks_per_col; + + if (mip_height == 1) { + // no flip to do, and we're done. + break; + } + else if (mip_height == 2) { + // flip the first 2 lines in each block. + for (unsigned int i = 0; i < blocks_per_row; ++i) { + half_block_function(data + i * block_bytes); + } + } + else { + // flip each block. + for (unsigned int i = 0; i < blocks; ++i) + full_block_function(data + i * block_bytes); + + // swap each block line in the first half of the image with the + // corresponding one in the second half. + // note that this is a no-op if mip_height is 4. + unsigned int row_bytes = block_bytes * blocks_per_row; + uint8_t *temp_line = new uint8_t[row_bytes]; + + for (unsigned int y = 0; y < blocks_per_col / 2; ++y) { + uint8_t *line1 = data + y * row_bytes; + uint8_t *line2 = data + (blocks_per_col - y - 1) * row_bytes; + + memcpy(temp_line, line1, row_bytes); + memcpy(line1, line2, row_bytes); + memcpy(line2, temp_line, row_bytes); + } + + delete temp_line; + } + + // mip levels are contiguous. + data += block_bytes * blocks; + mip_width = max(1U, mip_width >> 1); + mip_height = max(1U, mip_height >> 1); + } + + return 1; +} + diff --git a/source/blender/imbuf/intern/dds/FlipDXT.h b/source/blender/imbuf/intern/dds/FlipDXT.h new file mode 100644 index 00000000000..8d0ae8139a1 --- /dev/null +++ b/source/blender/imbuf/intern/dds/FlipDXT.h @@ -0,0 +1,32 @@ +/* + * ***** 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. + * + * Contributors: Amorilia (amorilia@users.sourceforge.net) + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FLIPDXT_H__ +#define __FLIPDXT_H__ + +#include "MEM_sys_types.h" + +/* flip compressed DXT image vertically to fit OpenGL convention */ +int FlipDXTCImage(unsigned int width, unsigned int height, unsigned int levels, int fourcc, uint8_t *data); + +#endif + diff --git a/source/blender/imbuf/intern/dds/PixelFormat.h b/source/blender/imbuf/intern/dds/PixelFormat.h index ce36fb00b97..2bb1864e49d 100644 --- a/source/blender/imbuf/intern/dds/PixelFormat.h +++ b/source/blender/imbuf/intern/dds/PixelFormat.h @@ -101,37 +101,37 @@ } } - inline float quantizeCeil(float f, int inbits, int outbits) - { - //uint i = f * (float(1 << inbits) - 1); - //i = convert(i, inbits, outbits); - //float result = float(i) / (float(1 << outbits) - 1); - //nvCheck(result >= f); - float result; - int offset = 0; - do { - uint i = offset + uint(f * (float(1 << inbits) - 1)); - i = convert(i, inbits, outbits); - result = float(i) / (float(1 << outbits) - 1); - offset++; - } while (result < f); - - return result; - } - - /* - inline float quantizeRound(float f, int bits) - { - float scale = float(1 << bits); - return fround(f * scale) / scale; - } - - inline float quantizeFloor(float f, int bits) - { - float scale = float(1 << bits); - return floor(f * scale) / scale; - } - */ + inline float quantizeCeil(float f, int inbits, int outbits) + { + //uint i = f * (float(1 << inbits) - 1); + //i = convert(i, inbits, outbits); + //float result = float(i) / (float(1 << outbits) - 1); + //nvCheck(result >= f); + float result; + int offset = 0; + do { + uint i = offset + uint(f * (float(1 << inbits) - 1)); + i = convert(i, inbits, outbits); + result = float(i) / (float(1 << outbits) - 1); + offset++; + } while (result < f); + + return result; + } + +#if 0 + inline float quantizeRound(float f, int bits) + { + float scale = float(1 << bits); + return fround(f * scale) / scale; + } + + inline float quantizeFloor(float f, int bits) + { + float scale = float(1 << bits); + return floor(f * scale) / scale; + } +#endif } // PixelFormat namespace diff --git a/source/blender/imbuf/intern/dds/SConscript b/source/blender/imbuf/intern/dds/SConscript index 4245f5001b9..d5a613f5981 100644 --- a/source/blender/imbuf/intern/dds/SConscript +++ b/source/blender/imbuf/intern/dds/SConscript @@ -1,7 +1,7 @@ #!/usr/bin/python Import ('env') -source_files = ['dds_api.cpp', 'DirectDrawSurface.cpp', 'Stream.cpp', 'BlockDXT.cpp', 'ColorBlock.cpp', 'Image.cpp'] +source_files = ['dds_api.cpp', 'DirectDrawSurface.cpp', 'Stream.cpp', 'BlockDXT.cpp', 'ColorBlock.cpp', 'Image.cpp', 'FlipDXT.cpp'] incs = ['.', '../../', diff --git a/source/blender/imbuf/intern/dds/dds_api.cpp b/source/blender/imbuf/intern/dds/dds_api.cpp index 7aacbf20bae..5459cffe590 100644 --- a/source/blender/imbuf/intern/dds/dds_api.cpp +++ b/source/blender/imbuf/intern/dds/dds_api.cpp @@ -29,6 +29,7 @@ #include <dds_api.h> #include <Stream.h> #include <DirectDrawSurface.h> +#include <FlipDXT.h> #include <stdio.h> // printf #include <fstream> @@ -162,13 +163,18 @@ struct ImBuf *imb_load_dds(unsigned char *mem, size_t size, int flags, char colo rect[i] = col; } - if (ibuf->dds_data.fourcc != FOURCC_DDS) + if (ibuf->dds_data.fourcc != FOURCC_DDS) { ibuf->dds_data.data = (unsigned char*)dds.readData(ibuf->dds_data.size); + + /* flip compressed texture */ + FlipDXTCImage(dds.width(), dds.height(), dds.mipmapCount(), dds.fourCC(), ibuf->dds_data.data); + } else { ibuf->dds_data.data = NULL; ibuf->dds_data.size = 0; } + /* flip uncompressed texture */ IMB_flipy(ibuf); } diff --git a/source/blender/imbuf/intern/divers.c b/source/blender/imbuf/intern/divers.c index aa236af3507..55c1b02e90b 100644 --- a/source/blender/imbuf/intern/divers.c +++ b/source/blender/imbuf/intern/divers.c @@ -62,7 +62,7 @@ void IMB_de_interlace(ImBuf *ibuf) tbuf1 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect); tbuf2 = IMB_allocImBuf(ibuf->x, ibuf->y / 2, 32, IB_rect); - ibuf->x *= 2; + ibuf->x *= 2; IMB_rectcpy(tbuf1, ibuf, 0, 0, 0, 0, ibuf->x, ibuf->y); IMB_rectcpy(tbuf2, ibuf, 0, 0, tbuf2->x, 0, ibuf->x, ibuf->y); @@ -561,7 +561,7 @@ void IMB_rect_from_float(ImBuf *ibuf) } /* converts from linear float to sRGB byte for part of the texture, buffer will hold the changed part */ -void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w, int h) +void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w, int h, int is_data) { float *rect_float; uchar *rect_byte; @@ -580,14 +580,27 @@ void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w rect_float = ibuf->rect_float + (x + y * ibuf->x) * ibuf->channels; rect_byte = (uchar *)ibuf->rect + (x + y * ibuf->x) * 4; - IMB_buffer_float_from_float(buffer, rect_float, - ibuf->channels, IB_PROFILE_SRGB, profile_from, predivide, - w, h, w, ibuf->x); + if (is_data) { + /* exception for non-color data, just copy float */ + IMB_buffer_float_from_float(buffer, rect_float, + ibuf->channels, IB_PROFILE_LINEAR_RGB, IB_PROFILE_LINEAR_RGB, 0, + w, h, w, ibuf->x); - /* XXX: need to convert to image buffer's rect space */ - IMB_buffer_byte_from_float(rect_byte, buffer, - 4, ibuf->dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB, 0, - w, h, ibuf->x, w); + /* and do color space conversion to byte */ + IMB_buffer_byte_from_float(rect_byte, rect_float, + 4, ibuf->dither, IB_PROFILE_SRGB, profile_from, predivide, + w, h, ibuf->x, w); + } + else { + IMB_buffer_float_from_float(buffer, rect_float, + ibuf->channels, IB_PROFILE_SRGB, profile_from, predivide, + w, h, w, ibuf->x); + + /* XXX: need to convert to image buffer's rect space */ + IMB_buffer_byte_from_float(rect_byte, buffer, + 4, ibuf->dither, IB_PROFILE_SRGB, IB_PROFILE_SRGB, 0, + w, h, ibuf->x, w); + } /* ensure user flag is reset */ ibuf->userflags &= ~IB_RECT_INVALID; @@ -710,7 +723,7 @@ void IMB_buffer_float_clamp(float *buf, int width, int height) { int i, total = width * height * 4; for (i = 0; i < total; i++) { - buf[i] = minf(1.0, buf[i]); + buf[i] = min_ff(1.0, buf[i]); } } diff --git a/source/blender/imbuf/intern/filetype.c b/source/blender/imbuf/intern/filetype.c index ed4db50035d..5c2dc0c7df9 100644 --- a/source/blender/imbuf/intern/filetype.c +++ b/source/blender/imbuf/intern/filetype.c @@ -74,8 +74,8 @@ ImFileType IMB_FILE_TYPES[] = { {NULL, NULL, imb_is_a_targa, imb_ftype_default, imb_loadtarga, imb_savetarga, NULL, 0, TGA, COLOR_ROLE_DEFAULT_BYTE}, {NULL, NULL, imb_is_a_iris, imb_ftype_iris, imb_loadiris, imb_saveiris, NULL, 0, IMAGIC, COLOR_ROLE_DEFAULT_BYTE}, #ifdef WITH_CINEON - {NULL, NULL, imb_is_dpx, imb_ftype_default, imb_loaddpx, imb_save_dpx, NULL, IM_FTYPE_FLOAT, DPX, COLOR_ROLE_DEFAULT_FLOAT}, - {NULL, NULL, imb_is_cineon, imb_ftype_default, imb_loadcineon, imb_savecineon, NULL, IM_FTYPE_FLOAT, CINEON, COLOR_ROLE_DEFAULT_FLOAT}, + {NULL, NULL, imb_is_dpx, imb_ftype_default, imb_load_dpx, imb_save_dpx, NULL, IM_FTYPE_FLOAT, DPX, COLOR_ROLE_DEFAULT_FLOAT}, + {NULL, NULL, imb_is_cineon, imb_ftype_default, imb_load_cineon, imb_save_cineon, NULL, IM_FTYPE_FLOAT, CINEON, COLOR_ROLE_DEFAULT_FLOAT}, #endif #ifdef WITH_TIFF {imb_inittiff, NULL, imb_is_a_tiff, imb_ftype_default, imb_loadtiff, imb_savetiff, imb_loadtiletiff, 0, TIF, COLOR_ROLE_DEFAULT_BYTE}, diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index 863b8424cc2..57fbce710a1 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -444,7 +444,7 @@ void neareast_interpolation_color(struct ImBuf *in, unsigned char outI[4], float outF[2] = dataF[2]; outF[3] = dataF[3]; } - } + } } void neareast_interpolation(ImBuf *in, ImBuf *out, float x, float y, int xout, int yout) diff --git a/source/blender/imbuf/intern/iris.c b/source/blender/imbuf/intern/iris.c index 549a28a0453..dec5f6fb39e 100644 --- a/source/blender/imbuf/intern/iris.c +++ b/source/blender/imbuf/intern/iris.c @@ -408,7 +408,7 @@ struct ImBuf *imb_loadiris(unsigned char *mem, size_t size, int flags, char colo } MEM_freeN(starttab); - MEM_freeN(lengthtab); + MEM_freeN(lengthtab); } else { @@ -613,7 +613,7 @@ static void expandrow2(float *optr, unsigned char *iptr, int z) optr += 4; } } - } + } } static void expandrow(unsigned char *optr, unsigned char *iptr, int z) diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 01523463712..692ba3c49ea 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -436,7 +436,7 @@ static void cinema_parameters(opj_cparameters_t *parameters) parameters->image_offset_y0 = 0; /*Codeblock size = 32 * 32*/ - parameters->cblockw_init = 32; + parameters->cblockw_init = 32; parameters->cblockh_init = 32; parameters->csty |= 0x01; @@ -602,7 +602,7 @@ static opj_image_t *ibuftoimage(ImBuf *ibuf, opj_cparameters_t *parameters) prec = 12; numcomps = 3; } - else { + else { /* Get settings from the imbuf */ color_space = (ibuf->ftype & JP2_YCC) ? CLRSPC_SYCC : CLRSPC_SRGB; diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index a11f16d5669..8e072361583 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -447,7 +447,7 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, drectf += destskip * 4; srectf += srcskip * 4; - } + } } } } @@ -482,13 +482,13 @@ void IMB_rectfill(struct ImBuf *drect, const float col[4]) *rrectf++ = col[2]; *rrectf++ = col[3]; } - } + } } void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, - const float col[4], struct ColorManagedDisplay *display, - int x1, int y1, int x2, int y2) + const float col[4], struct ColorManagedDisplay *display, + int x1, int y1, int x2, int y2) { int i, j; float a; /* alpha */ diff --git a/source/blender/imbuf/intern/targa.c b/source/blender/imbuf/intern/targa.c index 253680e4bea..eaad77f1ff9 100644 --- a/source/blender/imbuf/intern/targa.c +++ b/source/blender/imbuf/intern/targa.c @@ -55,9 +55,9 @@ /***/ typedef struct TARGA { - unsigned char numid; + unsigned char numid; unsigned char maptyp; - unsigned char imgtyp; + unsigned char imgtyp; short maporig; short mapsize; unsigned char mapbits; diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index ff7218d649c..a3ce332b609 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -175,7 +175,7 @@ static void to_hex_char(char *hexbytes, const unsigned char *bytes, int len) static int uri_from_filename(const char *path, char *uri) { - char orig_uri[URI_MAX]; + char orig_uri[URI_MAX]; const char *dirstart = path; #ifdef WIN32 @@ -265,7 +265,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im char thumb[40]; short tsize = 128; short ex, ey; - float scaledx, scaledy; + float scaledx, scaledy; struct stat info; switch (size) { @@ -334,7 +334,7 @@ ImBuf *IMB_thumb_create(const char *path, ThumbSize size, ThumbSource source, Im } else { IMB_freeImBuf(img); - img = IMB_anim_previewframe(anim); + img = IMB_anim_previewframe(anim); } IMB_free_anim(anim); } @@ -401,7 +401,7 @@ ImBuf *IMB_thumb_read(const char *path, ThumbSize size) if (!uri_from_filename(path, uri)) { return NULL; } - if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) { + if (thumbpath_from_uri(uri, thumb, sizeof(thumb), size)) { img = IMB_loadiffname(thumb, IB_rect | IB_metadata, NULL); } @@ -438,7 +438,7 @@ ImBuf *IMB_thumb_manage(const char *path, ThumbSize size, ThumbSource source) if (stat(path, &st)) { return NULL; - } + } if (!uri_from_filename(path, uri)) { return NULL; } diff --git a/source/blender/imbuf/intern/thumbs_blend.c b/source/blender/imbuf/intern/thumbs_blend.c index cfc49d8cef5..73ced4095f9 100644 --- a/source/blender/imbuf/intern/thumbs_blend.c +++ b/source/blender/imbuf/intern/thumbs_blend.c @@ -166,7 +166,7 @@ void IMB_overlayblend_thumb(unsigned int *thumb, int width, int height, float as margin_t = height - margin_b; } - { + { int x, y; int stride_x = (margin_r - margin_l) - 2; diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c index 8dd791c8508..fe138a71a4a 100644 --- a/source/blender/imbuf/intern/util.c +++ b/source/blender/imbuf/intern/util.c @@ -416,7 +416,7 @@ int IMB_isanim(const char *filename) type = imb_get_anim_type(filename); } else { - return(FALSE); + return(FALSE); } } else { /* no quicktime */ diff --git a/source/blender/makesdna/DNA_actuator_types.h b/source/blender/makesdna/DNA_actuator_types.h index 4a5ad69cb91..b445d59db2c 100644 --- a/source/blender/makesdna/DNA_actuator_types.h +++ b/source/blender/makesdna/DNA_actuator_types.h @@ -46,21 +46,21 @@ typedef struct bAddObjectActuator { struct Object *ob; } bAddObjectActuator; -typedef struct bActionActuator { - struct bAction *act; /* Pointer to action */ - short type, flag; /* Playback type */ // not in use - float sta, end; /* Start & End frames */ - char name[64]; /* For property-driven playback, MAX_NAME */ - char frameProp[64]; /* Set this property to the actions current frame, MAX_NAME */ - short blendin; /* Number of frames of blending */ - short priority; /* Execution priority */ - short layer; /* Animation layer */ - short end_reset; /* Ending the actuator (negative pulse) wont reset the the action to its starting frame */ - short strideaxis; /* Displacement axis */ - short pad; - float stridelength; /* Displacement incurred by cycle */ // not in use - float layer_weight; /* How much of the previous layer to use for blending. (<0 = disable, 0 = add mode) */ -} bActionActuator; +typedef struct bActionActuator { + struct bAction *act; /* Pointer to action */ + short type, flag; /* Playback type */ // not in use + float sta, end; /* Start & End frames */ + char name[64]; /* For property-driven playback, MAX_NAME */ + char frameProp[64]; /* Set this property to the actions current frame, MAX_NAME */ + short blendin; /* Number of frames of blending */ + short priority; /* Execution priority */ + short layer; /* Animation layer */ + short end_reset; /* Ending the actuator (negative pulse) wont reset the the action to its starting frame */ + short strideaxis; /* Displacement axis */ + short pad; + float stridelength; /* Displacement incurred by cycle */ // not in use + float layer_weight; /* How much of the previous layer to use for blending. (<0 = disable, 0 = add mode) */ +} bActionActuator; typedef struct Sound3D { float min_gain; @@ -261,7 +261,7 @@ typedef struct bActuator { /** * For ipo's and props: to find out which object the actuator * belongs to */ - struct Object *ob; + struct Object *ob; } bActuator; diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index 7cf0d588710..1ac6e6db94b 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -246,13 +246,13 @@ typedef enum eFMod_Noise_Modifications { /* stepped modifier data */ typedef struct FMod_Stepped { - float step_size; /* Number of frames each interpolated value should be held */ - float offset; /* Reference frame number that stepping starts from */ - - float start_frame; /* start frame of the frame range that modifier works in */ - float end_frame; /* end frame of the frame range that modifier works in */ - - int flag; /* various settings */ + float step_size; /* Number of frames each interpolated value should be held */ + float offset; /* Reference frame number that stepping starts from */ + + float start_frame; /* start frame of the frame range that modifier works in */ + float end_frame; /* end frame of the frame range that modifier works in */ + + int flag; /* various settings */ } FMod_Stepped; /* stepped modifier range flags */ @@ -325,14 +325,14 @@ typedef enum eDriverTarget_TransformChannels { */ typedef struct DriverVar { struct DriverVar *next, *prev; - - char name[64]; /* name of the variable to use in py-expression (must be valid python identifier) */ - - DriverTarget targets[8]; /* MAX_DRIVER_TARGETS, target slots */ - short num_targets; /* number of targets actually used by this variable */ - - short type; /* type of driver target (eDriverTarget_Types) */ - float curval; /* result of previous evaluation */ + + char name[64]; /* name of the variable to use in py-expression (must be valid python identifier) */ + + DriverTarget targets[8]; /* MAX_DRIVER_TARGETS, target slots */ + short num_targets; /* number of targets actually used by this variable */ + + short type; /* type of driver target (eDriverTarget_Types) */ + float curval; /* result of previous evaluation */ } DriverVar; /* Driver Variable Types */ @@ -556,36 +556,36 @@ typedef struct AnimMapper { */ typedef struct NlaStrip { struct NlaStrip *next, *prev; - - ListBase strips; /* 'Child' strips (used for 'meta' strips) */ - bAction *act; /* Action that is referenced by this strip (strip is 'user' of the action) */ - AnimMapper *remap; /* Remapping info this strip (for tweaking correspondence of action with context) */ - - ListBase fcurves; /* F-Curves for controlling this strip's influence and timing */ // TODO: move out? - ListBase modifiers; /* F-Curve modifiers to be applied to the entire strip's referenced F-Curves */ - - char name[64]; /* User-Visible Identifier for Strip */ - - float influence; /* Influence of strip */ - float strip_time; /* Current 'time' within action being used (automatically evaluated, but can be overridden) */ - - float start, end; /* extents of the strip */ - float actstart, actend; /* range of the action to use */ - - float repeat; /* The number of times to repeat the action range (only when no F-Curves) */ - float scale; /* The amount the action range is scaled by (only when no F-Curves) */ - - float blendin, blendout; /* strip blending length (only used when there are no F-Curves) */ - short blendmode; /* strip blending mode (layer-based mixing) */ - - short extendmode; /* strip extrapolation mode (time-based mixing) */ + + ListBase strips; /* 'Child' strips (used for 'meta' strips) */ + bAction *act; /* Action that is referenced by this strip (strip is 'user' of the action) */ + AnimMapper *remap; /* Remapping info this strip (for tweaking correspondence of action with context) */ + + ListBase fcurves; /* F-Curves for controlling this strip's influence and timing */ // TODO: move out? + ListBase modifiers; /* F-Curve modifiers to be applied to the entire strip's referenced F-Curves */ + + char name[64]; /* User-Visible Identifier for Strip */ + + float influence; /* Influence of strip */ + float strip_time; /* Current 'time' within action being used (automatically evaluated, but can be overridden) */ + + float start, end; /* extents of the strip */ + float actstart, actend; /* range of the action to use */ + + float repeat; /* The number of times to repeat the action range (only when no F-Curves) */ + float scale; /* The amount the action range is scaled by (only when no F-Curves) */ + + float blendin, blendout; /* strip blending length (only used when there are no F-Curves) */ + short blendmode; /* strip blending mode (layer-based mixing) */ + + short extendmode; /* strip extrapolation mode (time-based mixing) */ short pad1; - - short type; /* type of NLA strip */ - - void *speaker_handle; /* handle for speaker objects */ - - int flag; /* settings */ + + short type; /* type of NLA strip */ + + void *speaker_handle; /* handle for speaker objects */ + + int flag; /* settings */ int pad2; } NlaStrip; @@ -600,48 +600,48 @@ typedef enum eNlaStrip_Blend_Mode { /* NLA Strip Extrpolation Mode */ typedef enum eNlaStrip_Extrapolate_Mode { /* extend before first frame if no previous strips in track, and always hold+extend last frame */ - NLASTRIP_EXTEND_HOLD = 0, + NLASTRIP_EXTEND_HOLD = 0, /* only hold+extend last frame */ - NLASTRIP_EXTEND_HOLD_FORWARD, + NLASTRIP_EXTEND_HOLD_FORWARD = 1, /* don't contribute at all */ - NLASTRIP_EXTEND_NOTHING + NLASTRIP_EXTEND_NOTHING = 2 } eNlaStrip_Extrapolate_Mode; /* NLA Strip Settings */ typedef enum eNlaStrip_Flag { /* UI selection flags */ /* NLA strip is the active one in the track (also indicates if strip is being tweaked) */ - NLASTRIP_FLAG_ACTIVE = (1<<0), + NLASTRIP_FLAG_ACTIVE = (1<<0), /* NLA strip is selected for editing */ - NLASTRIP_FLAG_SELECT = (1<<1), -// NLASTRIP_FLAG_SELECT_L = (1<<2), // left handle selected -// NLASTRIP_FLAG_SELECT_R = (1<<3), // right handle selected + NLASTRIP_FLAG_SELECT = (1<<1), +// NLASTRIP_FLAG_SELECT_L = (1<<2), // left handle selected +// NLASTRIP_FLAG_SELECT_R = (1<<3), // right handle selected /* NLA strip uses the same action that the action being tweaked uses (not set for the twaking one though) */ - NLASTRIP_FLAG_TWEAKUSER = (1<<4), - + NLASTRIP_FLAG_TWEAKUSER = (1<<4), + /* controls driven by local F-Curves */ /* strip influence is controlled by local F-Curve */ - NLASTRIP_FLAG_USR_INFLUENCE = (1<<5), - NLASTRIP_FLAG_USR_TIME = (1<<6), + NLASTRIP_FLAG_USR_INFLUENCE = (1<<5), + NLASTRIP_FLAG_USR_TIME = (1<<6), NLASTRIP_FLAG_USR_TIME_CYCLIC = (1<<7), - + /* NLA strip length is synced to the length of the referenced action */ - NLASTRIP_FLAG_SYNC_LENGTH = (1<<9), - + NLASTRIP_FLAG_SYNC_LENGTH = (1<<9), + /* playback flags (may be overridden by F-Curves) */ /* NLA strip blendin/out values are set automatically based on overlaps */ - NLASTRIP_FLAG_AUTO_BLENDS = (1<<10), + NLASTRIP_FLAG_AUTO_BLENDS = (1<<10), /* NLA strip is played back in reverse order */ - NLASTRIP_FLAG_REVERSE = (1<<11), + NLASTRIP_FLAG_REVERSE = (1<<11), /* NLA strip is muted (i.e. doesn't contribute in any way) */ - NLASTRIP_FLAG_MUTED = (1<<12), + NLASTRIP_FLAG_MUTED = (1<<12), /* NLA Strip is played back in 'ping-pong' style */ - NLASTRIP_FLAG_MIRROR = (1<<13), - + NLASTRIP_FLAG_MIRROR = (1<<13), + /* temporary editing flags */ /* NLA-Strip is really just a temporary meta used to facilitate easier transform code */ - NLASTRIP_FLAG_TEMP_META = (1<<30), - NLASTRIP_FLAG_EDIT_TOUCHED = (1<<31) + NLASTRIP_FLAG_TEMP_META = (1<<30), + NLASTRIP_FLAG_EDIT_TOUCHED = (1<<31) } eNlaStrip_Flag; /* NLA Strip Type */ @@ -651,7 +651,7 @@ typedef enum eNlaStrip_Type { /* 'transition' - blends between the adjacent strips */ NLASTRIP_TYPE_TRANSITION, /* 'meta' - a strip which acts as a container for a few others */ - NLASTRIP_TYPE_META, + NLASTRIP_TYPE_META, /* 'emit sound' - a strip which is used for timing when speaker emits sounds */ NLASTRIP_TYPE_SOUND @@ -827,71 +827,71 @@ typedef struct AnimOverride { * This datablock should be placed immediately after the ID block where it is used, so that * the code which retrieves this data can do so in an easier manner. See blenkernel/intern/anim_sys.c for details. */ -typedef struct AnimData { +typedef struct AnimData { /* active action - acts as the 'tweaking track' for the NLA */ - bAction *action; - /* temp-storage for the 'real' active action (i.e. the one used before the tweaking-action - * took over to be edited in the Animation Editors) + bAction *action; + /* temp-storage for the 'real' active action (i.e. the one used before the tweaking-action + * took over to be edited in the Animation Editors) */ - bAction *tmpact; - /* remapping-info for active action - should only be used if needed - * (for 'foreign' actions that aren't working correctly) + bAction *tmpact; + /* remapping-info for active action - should only be used if needed + * (for 'foreign' actions that aren't working correctly) */ - AnimMapper *remap; - + AnimMapper *remap; + /* nla-tracks */ - ListBase nla_tracks; + ListBase nla_tracks; /* active NLA-strip (only set/used during tweaking, so no need to worry about dangling pointers) */ - NlaStrip *actstrip; - - /* 'drivers' for this ID-block's settings - FCurves, but are completely - * separate from those for animation data + NlaStrip *actstrip; + + /* 'drivers' for this ID-block's settings - FCurves, but are completely + * separate from those for animation data */ - ListBase drivers; /* standard user-created Drivers/Expressions (used as part of a rig) */ - ListBase overrides; /* temp storage (AnimOverride) of values for settings that are animated (but the value hasn't been keyframed) */ - + ListBase drivers; /* standard user-created Drivers/Expressions (used as part of a rig) */ + ListBase overrides; /* temp storage (AnimOverride) of values for settings that are animated (but the value hasn't been keyframed) */ + /* settings for animation evaluation */ - int flag; /* user-defined settings */ - int recalc; /* depsgraph recalculation flags */ - + int flag; /* user-defined settings */ + int recalc; /* depsgraph recalculation flags */ + /* settings for active action evaluation (based on NLA strip settings) */ - short act_blendmode; /* accumulation mode for active action */ - short act_extendmode; /* extrapolation mode for active action */ - float act_influence; /* influence for active action */ + short act_blendmode; /* accumulation mode for active action */ + short act_extendmode; /* extrapolation mode for active action */ + float act_influence; /* influence for active action */ } AnimData; /* Animation Data settings (mostly for NLA) */ typedef enum eAnimData_Flag { /* only evaluate a single track in the NLA */ - ADT_NLA_SOLO_TRACK = (1<<0), + ADT_NLA_SOLO_TRACK = (1<<0), /* don't use NLA */ - ADT_NLA_EVAL_OFF = (1<<1), + ADT_NLA_EVAL_OFF = (1<<1), /* NLA is being 'tweaked' (i.e. in EditMode) */ - ADT_NLA_EDIT_ON = (1<<2), + ADT_NLA_EDIT_ON = (1<<2), /* active Action for 'tweaking' does not have mapping applied for editing */ - ADT_NLA_EDIT_NOMAP = (1<<3), + ADT_NLA_EDIT_NOMAP = (1<<3), /* NLA-Strip F-Curves are expanded in UI */ - ADT_NLA_SKEYS_COLLAPSED = (1<<4), - + ADT_NLA_SKEYS_COLLAPSED = (1<<4), + /* drivers expanded in UI */ - ADT_DRIVERS_COLLAPSED = (1<<10), + ADT_DRIVERS_COLLAPSED = (1<<10), /* don't execute drivers */ - ADT_DRIVERS_DISABLED = (1<<11), - + ADT_DRIVERS_DISABLED = (1<<11), + /* AnimData block is selected in UI */ - ADT_UI_SELECTED = (1<<14), + ADT_UI_SELECTED = (1<<14), /* AnimData block is active in UI */ - ADT_UI_ACTIVE = (1<<15), - + ADT_UI_ACTIVE = (1<<15), + /* F-Curves from this AnimData block are not visible in the Graph Editor */ - ADT_CURVES_NOT_VISIBLE = (1<<16) + ADT_CURVES_NOT_VISIBLE = (1<<16) } eAnimData_Flag; /* Animation Data recalculation settings (to be set by depsgraph) */ typedef enum eAnimData_Recalc { - ADT_RECALC_DRIVERS = (1<<0), - ADT_RECALC_ANIM = (1<<1), - ADT_RECALC_ALL = (ADT_RECALC_DRIVERS | ADT_RECALC_ANIM) + ADT_RECALC_DRIVERS = (1 << 0), + ADT_RECALC_ANIM = (1 << 1), + ADT_RECALC_ALL = (ADT_RECALC_DRIVERS | ADT_RECALC_ANIM) } eAnimData_Recalc; /* Base Struct for Anim ------------------------------------- */ diff --git a/source/blender/makesdna/DNA_armature_types.h b/source/blender/makesdna/DNA_armature_types.h index 0a20a60c893..fd68a6d9a27 100644 --- a/source/blender/makesdna/DNA_armature_types.h +++ b/source/blender/makesdna/DNA_armature_types.h @@ -45,91 +45,91 @@ struct AnimData; */ typedef struct Bone { - struct Bone *next, *prev; /* Next/prev elements within this list */ - IDProperty *prop; /* User-Defined Properties on this Bone */ - struct Bone *parent; /* Parent (ik parent if appropriate flag is set */ - ListBase childbase; /* Children */ - char name[64]; /* Name of the bone - must be unique within the armature, MAXBONENAME */ - - float roll; /* roll is input for editmode, length calculated */ - float head[3]; - float tail[3]; /* head/tail and roll in Bone Space */ - float bone_mat[3][3]; /* rotation derived from head/tail/roll */ - - int flag; - - float arm_head[3]; - float arm_tail[3]; /* head/tail in Armature Space (rest pos) */ - float arm_mat[4][4]; /* matrix: (bonemat(b)+head(b))*arm_mat(b-1), rest pos*/ - float arm_roll; /* roll in Armature Space (rest pos) */ - - float dist, weight; /* dist, weight: for non-deformgroup deforms */ - float xwidth, length, zwidth; /* width: for block bones. keep in this order, transform! */ - float ease1, ease2; /* length of bezier handles */ - float rad_head, rad_tail; /* radius for head/tail sphere, defining deform as well, parent->rad_tip overrides rad_head*/ - - float size[3]; /* patch for upward compat, UNUSED! */ - int layer; /* layers that bone appears on */ - short segments; /* for B-bones */ - short pad[1]; + struct Bone *next, *prev; /* Next/prev elements within this list */ + IDProperty *prop; /* User-Defined Properties on this Bone */ + struct Bone *parent; /* Parent (ik parent if appropriate flag is set */ + ListBase childbase; /* Children */ + char name[64]; /* Name of the bone - must be unique within the armature, MAXBONENAME */ + + float roll; /* roll is input for editmode, length calculated */ + float head[3]; + float tail[3]; /* head/tail and roll in Bone Space */ + float bone_mat[3][3]; /* rotation derived from head/tail/roll */ + + int flag; + + float arm_head[3]; + float arm_tail[3]; /* head/tail in Armature Space (rest pos) */ + float arm_mat[4][4]; /* matrix: (bonemat(b)+head(b))*arm_mat(b-1), rest pos*/ + float arm_roll; /* roll in Armature Space (rest pos) */ + + float dist, weight; /* dist, weight: for non-deformgroup deforms */ + float xwidth, length, zwidth; /* width: for block bones. keep in this order, transform! */ + float ease1, ease2; /* length of bezier handles */ + float rad_head, rad_tail; /* radius for head/tail sphere, defining deform as well, parent->rad_tip overrides rad_head */ + + float size[3]; /* patch for upward compat, UNUSED! */ + int layer; /* layers that bone appears on */ + short segments; /* for B-bones */ + short pad[1]; } Bone; typedef struct bArmature { - ID id; + ID id; struct AnimData *adt; - - ListBase bonebase; - ListBase chainbase; - ListBase *edbo; /* editbone listbase, we use pointer so we can check state */ - + + ListBase bonebase; + ListBase chainbase; + ListBase *edbo; /* editbone listbase, we use pointer so we can check state */ + /* active bones should work like active object where possible * - active and selection are unrelated - * - active & hidden is not allowed + * - active & hidden is not allowed * - from the user perspective active == last selected * - active should be ignored when not visible (hidden layer) */ - Bone *act_bone; /* active bone (when not in editmode) */ - void *act_edbone; /* active editbone (in editmode) */ - - void *sketch; /* sketch struct for etch-a-ton */ - - int flag; - int drawtype; - int gevertdeformer; /* how vertex deformation is handled in the ge */ - int pad; - short deformflag; - short pathflag; - - unsigned int layer_used; /* for UI, to show which layers are there */ - unsigned int layer, layer_protected; /* for buttons to work, both variables in this order together */ - + Bone *act_bone; /* active bone (when not in editmode) */ + void *act_edbone; /* active editbone (in editmode) */ + + void *sketch; /* sketch struct for etch-a-ton */ + + int flag; + int drawtype; + int gevertdeformer; /* how vertex deformation is handled in the ge */ + int pad; + short deformflag; + short pathflag; + + unsigned int layer_used; /* for UI, to show which layers are there */ + unsigned int layer, layer_protected; /* for buttons to work, both variables in this order together */ + // XXX deprecated... old animaton system (armature only viz) --- - short ghostep, ghostsize; /* number of frames to ghosts to show, and step between them */ - short ghosttype, pathsize; /* ghost drawing options and number of frames between points of path */ - int ghostsf, ghostef; /* start and end frames of ghost-drawing range */ - int pathsf, pathef; /* start and end frames of path-calculation range for all bones */ - int pathbc, pathac; /* number of frames before/after current frame of path-calculation for all bones */ + short ghostep, ghostsize; /* number of frames to ghosts to show, and step between them */ + short ghosttype, pathsize; /* ghost drawing options and number of frames between points of path */ + int ghostsf, ghostef; /* start and end frames of ghost-drawing range */ + int pathsf, pathef; /* start and end frames of path-calculation range for all bones */ + int pathbc, pathac; /* number of frames before/after current frame of path-calculation for all bones */ // XXX end of deprecated code ---------------------------------- } bArmature; /* armature->flag */ /* don't use bit 7, was saved in files to disable stuff */ typedef enum eArmature_Flag { - ARM_RESTPOS = (1<<0), - ARM_DRAWXRAY = (1<<1), /* XRAY is here only for backwards converting */ - ARM_DRAWAXES = (1<<2), - ARM_DRAWNAMES = (1<<3), - ARM_POSEMODE = (1<<4), - ARM_EDITMODE = (1<<5), - ARM_DELAYDEFORM = (1<<6), - ARM_DONT_USE = (1<<7), - ARM_MIRROR_EDIT = (1<<8), - ARM_AUTO_IK = (1<<9), - ARM_NO_CUSTOM = (1<<10), /* made option negative, for backwards compat */ - ARM_COL_CUSTOM = (1<<11), /* draw custom colors */ - ARM_GHOST_ONLYSEL = (1<<12), /* when ghosting, only show selected bones (this should belong to ghostflag instead) */ /* XXX deprecated */ - ARM_DS_EXPAND = (1<<13), /* dopesheet channel is expanded */ - ARM_HAS_VIZ_DEPS = (1<<14), /* other objects are used for visualizing various states (hack for efficient updates) */ + ARM_RESTPOS = (1<<0), + ARM_DRAWXRAY = (1<<1), /* XRAY is here only for backwards converting */ + ARM_DRAWAXES = (1<<2), + ARM_DRAWNAMES = (1<<3), + ARM_POSEMODE = (1<<4), + ARM_EDITMODE = (1<<5), + ARM_DELAYDEFORM = (1<<6), + ARM_DONT_USE = (1<<7), + ARM_MIRROR_EDIT = (1<<8), + ARM_AUTO_IK = (1<<9), + ARM_NO_CUSTOM = (1<<10), /* made option negative, for backwards compat */ + ARM_COL_CUSTOM = (1<<11), /* draw custom colors */ + ARM_GHOST_ONLYSEL = (1<<12), /* when ghosting, only show selected bones (this should belong to ghostflag instead) */ /* XXX deprecated */ + ARM_DS_EXPAND = (1<<13), /* dopesheet channel is expanded */ + ARM_HAS_VIZ_DEPS = (1<<14), /* other objects are used for visualizing various states (hack for efficient updates) */ } eArmature_Flag; /* armature->drawtype */ @@ -176,29 +176,29 @@ typedef enum eArmature_GhostType { /* bone->flag */ typedef enum eBone_Flag { - BONE_SELECTED = (1<<0), - BONE_ROOTSEL = (1<<1), - BONE_TIPSEL = (1<<2), - BONE_TRANSFORM = (1<<3), /* Used instead of BONE_SELECTED during transform */ - BONE_CONNECTED = (1<<4), /* when bone has a parent, connect head of bone to parent's tail*/ - /* 32 used to be quatrot, was always set in files, do not reuse unless you clear it always */ - BONE_HIDDEN_P = (1<<6), /* hidden Bones when drawing PoseChannels */ - BONE_DONE = (1<<7), /* For detecting cyclic dependencies */ - BONE_DRAW_ACTIVE = (1<<8), /* active is on mouse clicks only - deprecated, ONLY USE FOR DRAWING */ - BONE_HINGE = (1<<9), /* No parent rotation or scale */ - BONE_HIDDEN_A = (1<<10), /* hidden Bones when drawing Armature Editmode */ - BONE_MULT_VG_ENV = (1<<11), /* multiplies vgroup with envelope */ - BONE_NO_DEFORM = (1<<12), /* bone doesn't deform geometry */ - BONE_UNKEYED = (1<<13), /* set to prevent destruction of its unkeyframed pose (after transform) */ - BONE_HINGE_CHILD_TRANSFORM = (1<<14), /* set to prevent hinge child bones from influencing the transform center */ - BONE_NO_SCALE = (1<<15), /* No parent scale */ - BONE_HIDDEN_PG = (1<<16), /* hidden bone when drawing PoseChannels (for ghost drawing) */ - BONE_DRAWWIRE = (1<<17), /* bone should be drawn as OB_WIRE, regardless of draw-types of view+armature */ - BONE_NO_CYCLICOFFSET = (1<<18), /* when no parent, bone will not get cyclic offset */ - BONE_EDITMODE_LOCKED = (1<<19), /* bone transforms are locked in EditMode */ - BONE_TRANSFORM_CHILD = (1<<20), /* Indicates that a parent is also being transformed */ - BONE_UNSELECTABLE = (1<<21), /* bone cannot be selected */ - BONE_NO_LOCAL_LOCATION = (1<<22) /* bone location is in armature space */ + BONE_SELECTED = (1 << 0), + BONE_ROOTSEL = (1 << 1), + BONE_TIPSEL = (1 << 2), + BONE_TRANSFORM = (1 << 3), /* Used instead of BONE_SELECTED during transform */ + BONE_CONNECTED = (1 << 4), /* when bone has a parent, connect head of bone to parent's tail*/ + /* 32 used to be quatrot, was always set in files, do not reuse unless you clear it always */ + BONE_HIDDEN_P = (1 << 6), /* hidden Bones when drawing PoseChannels */ + BONE_DONE = (1 << 7), /* For detecting cyclic dependencies */ + BONE_DRAW_ACTIVE = (1 << 8), /* active is on mouse clicks only - deprecated, ONLY USE FOR DRAWING */ + BONE_HINGE = (1 << 9), /* No parent rotation or scale */ + BONE_HIDDEN_A = (1 << 10), /* hidden Bones when drawing Armature Editmode */ + BONE_MULT_VG_ENV = (1 << 11), /* multiplies vgroup with envelope */ + BONE_NO_DEFORM = (1 << 12), /* bone doesn't deform geometry */ + BONE_UNKEYED = (1 << 13), /* set to prevent destruction of its unkeyframed pose (after transform) */ + BONE_HINGE_CHILD_TRANSFORM = (1 << 14), /* set to prevent hinge child bones from influencing the transform center */ + BONE_NO_SCALE = (1 << 15), /* No parent scale */ + BONE_HIDDEN_PG = (1 << 16), /* hidden bone when drawing PoseChannels (for ghost drawing) */ + BONE_DRAWWIRE = (1 << 17), /* bone should be drawn as OB_WIRE, regardless of draw-types of view+armature */ + BONE_NO_CYCLICOFFSET = (1 << 18), /* when no parent, bone will not get cyclic offset */ + BONE_EDITMODE_LOCKED = (1 << 19), /* bone transforms are locked in EditMode */ + BONE_TRANSFORM_CHILD = (1 << 20), /* Indicates that a parent is also being transformed */ + BONE_UNSELECTABLE = (1 << 21), /* bone cannot be selected */ + BONE_NO_LOCAL_LOCATION = (1 << 22) /* bone location is in armature space */ } eBone_Flag; #define MAXBONENAME 64 diff --git a/source/blender/makesdna/DNA_boid_types.h b/source/blender/makesdna/DNA_boid_types.h index ce5fc4b0c3c..f1930ffd643 100644 --- a/source/blender/makesdna/DNA_boid_types.h +++ b/source/blender/makesdna/DNA_boid_types.h @@ -36,18 +36,18 @@ typedef enum BoidRuleType { eBoidRuleType_None = 0, - eBoidRuleType_Goal = 1, /* go to goal assigned object or loudest assigned signal source */ - eBoidRuleType_Avoid = 2, /* get away from assigned object or loudest assigned signal source */ - eBoidRuleType_AvoidCollision = 3, /* manoeuver to avoid collisions with other boids and deflector object in near future */ - eBoidRuleType_Separate = 4, /* keep from going through other boids */ - eBoidRuleType_Flock = 5, /* move to center of neighbors and match their velocity */ - eBoidRuleType_FollowLeader = 6, /* follow a boid or assigned object */ - eBoidRuleType_AverageSpeed = 7, /* maintain speed, flight level or wander*/ - eBoidRuleType_Fight = 8, /* go to closest enemy and attack when in range */ - //eBoidRuleType_Protect = 9, /* go to enemy closest to target and attack when in range */ - //eBoidRuleType_Hide = 10, /* find a deflector move to it's other side from closest enemy */ - //eBoidRuleType_FollowPath = 11, /* move along a assigned curve or closest curve in a group */ - //eBoidRuleType_FollowWall = 12, /* move next to a deflector object's in direction of it's tangent */ + eBoidRuleType_Goal = 1, /* go to goal assigned object or loudest assigned signal source */ + eBoidRuleType_Avoid = 2, /* get away from assigned object or loudest assigned signal source */ + eBoidRuleType_AvoidCollision = 3, /* manoeuver to avoid collisions with other boids and deflector object in near future */ + eBoidRuleType_Separate = 4, /* keep from going through other boids */ + eBoidRuleType_Flock = 5, /* move to center of neighbors and match their velocity */ + eBoidRuleType_FollowLeader = 6, /* follow a boid or assigned object */ + eBoidRuleType_AverageSpeed = 7, /* maintain speed, flight level or wander*/ + eBoidRuleType_Fight = 8, /* go to closest enemy and attack when in range */ + //eBoidRuleType_Protect = 9, /* go to enemy closest to target and attack when in range */ + //eBoidRuleType_Hide = 10, /* find a deflector move to it's other side from closest enemy */ + //eBoidRuleType_FollowPath = 11, /* move along a assigned curve or closest curve in a group */ + //eBoidRuleType_FollowWall = 12, /* move next to a deflector object's in direction of it's tangent */ NUM_BOID_RULE_TYPES } BoidRuleType; @@ -67,7 +67,7 @@ typedef struct BoidRuleGoalAvoid { BoidRule rule; struct Object *ob; int options; - float fear_factor; + float fear_factor; /* signals */ int signal_id, channels; diff --git a/source/blender/makesdna/DNA_cloth_types.h b/source/blender/makesdna/DNA_cloth_types.h index 4928a88b33e..df1cba6a44d 100644 --- a/source/blender/makesdna/DNA_cloth_types.h +++ b/source/blender/makesdna/DNA_cloth_types.h @@ -45,7 +45,7 @@ */ typedef struct ClothSimSettings { - struct LinkNode *cache; /* UNUSED atm */ + struct LinkNode *cache; /* UNUSED atm */ float mingoal; /* see SB */ float Cdis; /* Mechanical damping of springs. */ float Cvi; /* Viscous/fluid damping. */ diff --git a/source/blender/makesdna/DNA_constraint_types.h b/source/blender/makesdna/DNA_constraint_types.h index 8b1e7e12e17..f1b7a7c3cc3 100644 --- a/source/blender/makesdna/DNA_constraint_types.h +++ b/source/blender/makesdna/DNA_constraint_types.h @@ -170,7 +170,7 @@ typedef struct bSplineIKConstraint { short numpoints; /* number of points to bound in points array */ short chainlen; /* number of bones ('n') that are in the chain */ - /* settings */ + /* settings */ short flag; /* general settings for constraint */ short xzScaleMode; /* method used for determining the x & z scaling of the bones */ } bSplineIKConstraint; @@ -340,7 +340,7 @@ typedef struct bTransformConstraint { float from_max[3]; /* to map on to to_min/max range. */ float to_min[3]; /* range of motion on owner caused by target */ - float to_max[3]; + float to_max[3]; } bTransformConstraint; /* Pivot Constraint */ @@ -486,7 +486,7 @@ typedef enum eBConstraint_Flags { CONSTRAINT_EXPAND = (1<<0), /* pre-check for illegal object name or bone name */ CONSTRAINT_DISABLE = (1<<2), - /* to indicate which Ipo should be shown, maybe for 3d access later too */ + /* to indicate which Ipo should be shown, maybe for 3d access later too */ CONSTRAINT_ACTIVE = (1<<4), /* to indicate that the owner's space should only be changed into ownspace, but not out of it */ CONSTRAINT_SPACEONCE = (1<<6), @@ -664,7 +664,7 @@ typedef enum eSplineIK_Flags { /* bones in the chain should not scale to fit the curve */ CONSTRAINT_SPLINEIK_SCALE_LIMITED = (1<<2), /* evenly distribute the bones along the path regardless of length */ - CONSTRAINT_SPLINEIK_EVENSPLITS = (1<<3), + CONSTRAINT_SPLINEIK_EVENSPLITS = (1<<3), /* don't adjust the x and z scaling of the bones by the curve radius */ CONSTRAINT_SPLINEIK_NO_CURVERAD = (1<<4) } eSplineIK_Flags; @@ -751,7 +751,7 @@ typedef enum eChildOf_Flags { /* Restrictions for Pivot Constraint axis to consider for enabling constraint */ typedef enum ePivotConstraint_Axis { /* do not consider this activity-clamping */ - PIVOTCON_AXIS_NONE = -1, + PIVOTCON_AXIS_NONE = -1, /* consider -ve x-axis rotations */ PIVOTCON_AXIS_X_NEG = 0, diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index 9fbe045226e..3cf84648ea6 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -234,11 +234,11 @@ typedef struct Curve { float ctime; /* current evaltime - for use by Objects parented to curves */ int totbox, actbox; - struct TextBox *tb; + struct TextBox *tb; - int selstart, selend; + int selstart, selend; - struct CharInfo *strinfo; + struct CharInfo *strinfo; struct CharInfo curinfo; float bevfac1, bevfac2; diff --git a/source/blender/makesdna/DNA_genfile.h b/source/blender/makesdna/DNA_genfile.h index 20f7bb44e92..2d1549ff487 100644 --- a/source/blender/makesdna/DNA_genfile.h +++ b/source/blender/makesdna/DNA_genfile.h @@ -35,8 +35,8 @@ struct SDNA; -extern unsigned char DNAstr[]; /* DNA.c */ -extern int DNAlen; +extern const unsigned char DNAstr[]; /* DNA.c */ +extern const int DNAlen; typedef enum eSDNA_Type { SDNA_TYPE_CHAR = 0, @@ -56,7 +56,7 @@ typedef enum eSDNA_Type { /* define so switch statements don't complain */ #define SDNA_TYPE_VOID 9 -struct SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap); +struct SDNA *DNA_sdna_from_data(const void *data, const int datalen, int do_endian_swap); void DNA_sdna_free(struct SDNA *sdna); int DNA_struct_find_nr(struct SDNA *sdna, const char *str); diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h index 71b344d23d7..100968e7257 100644 --- a/source/blender/makesdna/DNA_gpencil_types.h +++ b/source/blender/makesdna/DNA_gpencil_types.h @@ -39,7 +39,7 @@ * This assumes that the bottom-left corner is (0,0) */ typedef struct bGPDspoint { - float x, y, z; /* co-ordinates of point (usually 2d, but can be 3d as well) */ + float x, y, z; /* co-ordinates of point (usually 2d, but can be 3d as well) */ float pressure; /* pressure of input device (from 0 to 1) at this point */ } bGPDspoint; @@ -53,7 +53,7 @@ typedef struct bGPDstroke { bGPDspoint *points; /* array of data-points for stroke */ int totpoints; /* number of data-points in array */ - short thickness; /* thickness of stroke (currently not used) */ + short thickness; /* thickness of stroke (currently not used) */ short flag; /* various settings about this stroke */ } bGPDstroke; @@ -94,7 +94,7 @@ typedef struct bGPDlayer { ListBase frames; /* list of annotations to display for frames (bGPDframe list) */ bGPDframe *actframe; /* active frame (should be the frame that is currently being displayed) */ - int flag; /* settings for layer */ + int flag; /* settings for layer */ short thickness; /* current thickness to apply to strokes */ short gstep; /* max number of frames between active and ghost to show (0=only those on either side) */ diff --git a/source/blender/makesdna/DNA_image_types.h b/source/blender/makesdna/DNA_image_types.h index 38058dbb699..fe3550327f7 100644 --- a/source/blender/makesdna/DNA_image_types.h +++ b/source/blender/makesdna/DNA_image_types.h @@ -137,6 +137,7 @@ typedef struct Image { #define IMA_CLAMP_U 16 #define IMA_CLAMP_V 32 #define IMA_TPAGE_REFRESH 64 +#define IMA_GLBIND_IS_DATA 128 /* opengl image texture bound as non-color data */ /* ima->type and ima->source moved to BKE_image.h, for API */ diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h index a73fc9073fa..3e641fba1ac 100644 --- a/source/blender/makesdna/DNA_ipo_types.h +++ b/source/blender/makesdna/DNA_ipo_types.h @@ -93,7 +93,7 @@ typedef struct Ipo { rctf cur; /* Rect defining extents of keyframes? */ short blocktype, showkey; /* blocktype: self-explanatory; showkey: either 0 or 1 (show vertical yellow lines for editing) */ - short muteipo, pad; /* muteipo: either 0 or 1 (whether ipo block is muted) */ + short muteipo, pad; /* muteipo: either 0 or 1 (whether ipo block is muted) */ } Ipo; /* ----------- adrcodes (for matching ipo-curves to data) ------------- */ diff --git a/source/blender/makesdna/DNA_lamp_types.h b/source/blender/makesdna/DNA_lamp_types.h index 4884db14c57..f36e65085c9 100644 --- a/source/blender/makesdna/DNA_lamp_types.h +++ b/source/blender/makesdna/DNA_lamp_types.h @@ -109,7 +109,7 @@ typedef struct Lamp { struct PreviewImage *preview; /* nodes */ - struct bNodeTree *nodetree; + struct bNodeTree *nodetree; } Lamp; /* **************** LAMP ********************* */ diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index 09451754dee..11b93b5fefe 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -86,7 +86,7 @@ typedef struct Material { ID id; struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */ - short material_type, flag; + short material_type, flag; /* note, keep this below synced with render_types.h */ float r, g, b; float specr, specg, specb; @@ -156,7 +156,7 @@ typedef struct Material { float rampfac_col, rampfac_spec; struct MTex *mtex[18]; /* MAX_MTEX */ - struct bNodeTree *nodetree; + struct bNodeTree *nodetree; struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */ struct Group *group; /* light group */ struct PreviewImage *preview; diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index f28c0328acc..bdb1568c73f 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -72,7 +72,7 @@ typedef struct MVert { * at the moment alpha is abused for vertex painting * and not used for transparency, note that red and blue are swapped */ typedef struct MCol { - char a, r, g, b; + char a, r, g, b; } MCol; /* new face structure, replaces MFace, which is now diff --git a/source/blender/makesdna/DNA_meta_types.h b/source/blender/makesdna/DNA_meta_types.h index 2912650c77c..5b37ff523cb 100644 --- a/source/blender/makesdna/DNA_meta_types.h +++ b/source/blender/makesdna/DNA_meta_types.h @@ -93,7 +93,7 @@ typedef struct MetaBall { /* used in editmode */ /*ListBase edit_elems;*/ - MetaElem *lastelem; + MetaElem *lastelem; } MetaBall; /* **************** METABALL ********************* */ diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 99df51e9ec4..c9e929ce41b 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -75,6 +75,7 @@ typedef enum ModifierType { eModifierType_DynamicPaint = 40, eModifierType_Remesh = 41, eModifierType_Skin = 42, + eModifierType_LaplacianSmooth = 43, NUM_MODIFIER_TYPES } ModifierType; @@ -348,7 +349,7 @@ typedef struct UVProjectModifierData { int flags; int num_projectors; float aspectx, aspecty; - float scalex, scaley; + float scalex, scaley; char uvlayer_name[64]; /* MAX_CUSTOMDATA_LAYER_NAME */ int uvlayer_tmp, pad; } UVProjectModifierData; @@ -361,10 +362,30 @@ typedef struct UVProjectModifierData { typedef struct DecimateModifierData { ModifierData modifier; - float percent; - int faceCount; + float percent; /* (mode == MOD_DECIM_MODE_COLLAPSE) */ + short iter; /* (mode == MOD_DECIM_MODE_UNSUBDIV) */ + short pad; + float angle; /* (mode == MOD_DECIM_MODE_DISSOLVE) */ + + char defgrp_name[64]; /* MAX_VGROUP_NAME */ + short flag, mode; + + /* runtime only */ + int face_count, pad2; } DecimateModifierData; +enum { + MOD_DECIM_FLAG_INVERT_VGROUP = (1 << 0), + MOD_DECIM_FLAG_TRIANGULATE = (1 << 1), /* for collapse only. dont convert tri pairs back to quads */ + MOD_DECIM_FLAG_ALL_BOUNDARY_VERTS = (1 << 2) /* for dissolve only. collapse all verts between 2 faces */ +}; + +enum { + MOD_DECIM_MODE_COLLAPSE, + MOD_DECIM_MODE_UNSUBDIV, + MOD_DECIM_MODE_DISSOLVE /* called planar in the UI */ +}; + /* Smooth modifier flags */ #define MOD_SMOOTH_X (1<<1) #define MOD_SMOOTH_Y (1<<2) @@ -683,7 +704,7 @@ typedef struct SimpleDeformModifierData { struct Object *origin; /* object to control the origin of modifier space coordinates */ char vgroup_name[64]; /* optional vertexgroup name, MAX_VGROUP_NAME */ float factor; /* factors to control simple deforms */ - float limit[2]; /* lower and upper limit */ + float limit[2]; /* lower and upper limit */ char mode; /* deform function */ char axis; /* lock axis (for taper and strech) */ @@ -1092,4 +1113,17 @@ enum { MOD_SKIN_SMOOTH_SHADING = 1 }; +/* Smooth modifier flags */ +#define MOD_LAPLACIANSMOOTH_X (1<<1) +#define MOD_LAPLACIANSMOOTH_Y (1<<2) +#define MOD_LAPLACIANSMOOTH_Z (1<<3) +#define MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION (1<<4) + +typedef struct LaplacianSmoothModifierData { + ModifierData modifier; + float lambda, lambda_border, pad1; + char defgrp_name[64]; /* MAX_VGROUP_NAME */ + short flag, repeat; +} LaplacianSmoothModifierData; + #endif diff --git a/source/blender/makesdna/DNA_nla_types.h b/source/blender/makesdna/DNA_nla_types.h index 43b52ed65eb..5837f891ae0 100644 --- a/source/blender/makesdna/DNA_nla_types.h +++ b/source/blender/makesdna/DNA_nla_types.h @@ -50,7 +50,7 @@ typedef struct bActionModifier { /* path deform modifier */ short no_rot_axis; - struct Object *ob; + struct Object *ob; } bActionModifier; /* NLA-Modifier Types */ diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 3f1f4933585..aa382632b7b 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -167,6 +167,7 @@ typedef struct bNode { struct ID *id; /* optional link to libdata */ void *storage; /* custom data, must be struct, for storage in file */ struct bNode *original; /* the original node in the tree (for localized tree) */ + ListBase internal_links; /* list of cached internal links (input to output), for muted nodes and operators */ float locx, locy; /* root offset for drawing (parent space) */ float width, height; /* node custom width and height */ diff --git a/source/blender/makesdna/DNA_object_force.h b/source/blender/makesdna/DNA_object_force.h index 67d540db177..5cc56d861a3 100644 --- a/source/blender/makesdna/DNA_object_force.h +++ b/source/blender/makesdna/DNA_object_force.h @@ -280,7 +280,7 @@ typedef struct SoftBody { float nodemass; /* softbody mass of *vertex* */ char namedVG_Mass[64]; /* MAX_VGROUP_NAME */ /* along with it introduce mass painting - * starting to fix old bug .. nastyness that VG are indexes + * starting to fix old bug .. nastiness that VG are indexes * rather find them by name tag to find it -> jow20090613 */ float grav; /* softbody amount of gravitaion to apply */ float mediafrict; /* friction to env */ @@ -295,7 +295,7 @@ typedef struct SoftBody { float defgoal; /* default goal for vertices without vgroup */ short vertgroup; /* index starting at 1 */ char namedVG_Softgoal[64]; /* MAX_VGROUP_NAME */ - /* starting to fix old bug .. nastyness that VG are indexes + /* starting to fix old bug .. nastiness that VG are indexes * rather find them by name tag to find it -> jow20090613 */ short fuzzyness; /* */ @@ -305,7 +305,7 @@ typedef struct SoftBody { float infrict; /* softbody inner springs friction */ char namedVG_Spring_K[64]; /* MAX_VGROUP_NAME */ /* along with it introduce Spring_K painting - * starting to fix old bug .. nastyness that VG are indexes + * starting to fix old bug .. nastiness that VG are indexes * rather find them by name tag to find it -> jow20090613 */ /* baking */ @@ -400,7 +400,7 @@ typedef struct SoftBody { //#define PTCACHE_BAKE_EDIT 16 //#define PTCACHE_BAKE_EDIT_ACTIVE 32 #define PTCACHE_DISK_CACHE 64 -#define PTCACHE_QUICK_CACHE 128 +//#define PTCACHE_QUICK_CACHE 128 /* removed since 2.64 - [#30974], could be added back in a more useful way */ #define PTCACHE_FRAMES_SKIPPED 256 #define PTCACHE_EXTERNAL 512 #define PTCACHE_READ_INFO 1024 diff --git a/source/blender/makesdna/DNA_packedFile_types.h b/source/blender/makesdna/DNA_packedFile_types.h index 4ec5866e8c3..ef0a0f642d6 100644 --- a/source/blender/makesdna/DNA_packedFile_types.h +++ b/source/blender/makesdna/DNA_packedFile_types.h @@ -35,9 +35,9 @@ #define __DNA_PACKEDFILE_TYPES_H__ typedef struct PackedFile { - int size; - int seek; - void * data; + int size; + int seek; + void *data; } PackedFile; enum PF_FileStatus diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 2aab702add0..9bfa0e7fdf7 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -323,10 +323,11 @@ typedef struct ImageFormatData { /* return values from BKE_imtype_valid_depths, note this is depts per channel */ #define R_IMF_CHAN_DEPTH_1 (1<<0) /* 1bits (unused) */ #define R_IMF_CHAN_DEPTH_8 (1<<1) /* 8bits (default) */ -#define R_IMF_CHAN_DEPTH_12 (1<<2) /* 12bits (uncommon, jp2 supports) */ -#define R_IMF_CHAN_DEPTH_16 (1<<3) /* 16bits (tiff, halff float exr) */ -#define R_IMF_CHAN_DEPTH_24 (1<<4) /* 24bits (unused) */ -#define R_IMF_CHAN_DEPTH_32 (1<<5) /* 32bits (full float exr) */ +#define R_IMF_CHAN_DEPTH_10 (1<<2) /* 10bits (uncommon, Cineon/DPX support) */ +#define R_IMF_CHAN_DEPTH_12 (1<<3) /* 12bits (uncommon, jp2/DPX support) */ +#define R_IMF_CHAN_DEPTH_16 (1<<4) /* 16bits (tiff, halff float exr) */ +#define R_IMF_CHAN_DEPTH_24 (1<<5) /* 24bits (unused) */ +#define R_IMF_CHAN_DEPTH_32 (1<<6) /* 32bits (full float exr) */ /* ImageFormatData.planes */ #define R_IMF_PLANES_RGB 24 @@ -480,7 +481,7 @@ typedef struct RenderData { int color_mgt_flag; /** post-production settings. deprecated, but here for upwards compat (initialized to 1) */ - float postgamma, posthue, postsat; + float postgamma, posthue, postsat; /* Dither noise intensity */ float dither_intensity; @@ -1095,7 +1096,7 @@ typedef struct Scene { short use_nodes; - struct bNodeTree *nodetree; + struct bNodeTree *nodetree; struct Editing *ed; /* sequence editor data is allocated here */ @@ -1197,7 +1198,7 @@ typedef struct Scene { /* seq_flag */ #define R_SEQ_GL_PREV 1 -#define R_SEQ_GL_REND 2 +// #define R_SEQ_GL_REND 2 // UNUSED, opengl render has its own operator now. /* displaymode */ @@ -1315,6 +1316,7 @@ typedef struct Scene { /* sequencer seq_prev_type seq_rend_type */ + /* **************** SCENE ********************* */ /* for general use */ @@ -1367,8 +1369,8 @@ typedef struct Scene { #define SFRA (scene->r.sfra) #define EFRA (scene->r.efra) #define PRVRANGEON (scene->r.flag & SCER_PRV_RANGE) -#define PSFRA ((PRVRANGEON)? (scene->r.psfra): (scene->r.sfra)) -#define PEFRA ((PRVRANGEON)? (scene->r.pefra): (scene->r.efra)) +#define PSFRA ((PRVRANGEON) ? (scene->r.psfra) : (scene->r.sfra)) +#define PEFRA ((PRVRANGEON) ? (scene->r.pefra) : (scene->r.efra)) #define FRA2TIME(a) ((((double) scene->r.frs_sec_base) * (double)(a)) / (double)scene->r.frs_sec) #define TIME2FRA(a) ((((double) scene->r.frs_sec) * (double)(a)) / (double)scene->r.frs_sec_base) #define FPS (((double) scene->r.frs_sec) / (double)scene->r.frs_sec_base) @@ -1466,6 +1468,7 @@ typedef enum SculptFlags { SCULPT_SYMMETRY_FEATHER = (1<<6), SCULPT_USE_OPENMP = (1<<7), SCULPT_ONLY_DEFORM = (1<<8), + SCULPT_SHOW_DIFFUSE = (1<<9), } SculptFlags; /* ImagePaintSettings.flag */ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 9289d140b85..408dc17c6a0 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -793,10 +793,10 @@ typedef struct SpaceText { float blockscale DNA_DEPRECATED; short blockhandler[8] DNA_DEPRECATED; - struct Text *text; + struct Text *text; int top, viewlines; - short flags, menunr; + short flags, menunr; short lheight; /* user preference */ char cwidth, linenrs_tot; /* runtime computed, character width and the number of chars to use when showing line numbers */ diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h index ce94a229750..dd63e6aad59 100644 --- a/source/blender/makesdna/DNA_texture_types.h +++ b/source/blender/makesdna/DNA_texture_types.h @@ -161,7 +161,7 @@ typedef struct PointDensity { float speed_scale, falloff_speed_scale, pdpad2; struct ColorBand *coba; /* for time -> color */ - struct CurveMapping *falloff_curve; /* falloff density curve */ + struct CurveMapping *falloff_curve; /* falloff density curve */ } PointDensity; typedef struct VoxelData { @@ -176,7 +176,7 @@ typedef struct VoxelData { int _pad; struct Object *object; /* for rendering smoke sims */ - float int_multiplier; + float int_multiplier; int still_frame; char source_path[1024]; /* 1024 = FILE_MAX */ diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 2c51a956e18..98c135fcf53 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -184,7 +184,7 @@ typedef struct ThemeSpace { /* button/tool regions */ char button[4]; char button_title[4]; - char button_text[4]; + char button_text[4]; char button_text_hi[4]; /* listview regions */ @@ -195,8 +195,8 @@ typedef struct ThemeSpace { /* float panel */ char panel[4]; - char panel_title[4]; - char panel_text[4]; + char panel_title[4]; + char panel_text[4]; char panel_text_hi[4]; char shade1[4]; @@ -303,7 +303,7 @@ typedef struct bTheme { ThemeUI tui; /* Individual Spacetypes */ - ThemeSpace tbuts; + ThemeSpace tbuts; ThemeSpace tv3d; ThemeSpace tfile; ThemeSpace tipo; @@ -317,7 +317,7 @@ typedef struct bTheme { ThemeSpace ttime; ThemeSpace tnode; ThemeSpace tlogic; - ThemeSpace tuserpref; + ThemeSpace tuserpref; ThemeSpace tconsole; ThemeSpace tclip; @@ -533,7 +533,8 @@ typedef enum eUserpref_UI_Flag { USER_SPLASH_DISABLE = (1 << 27), USER_HIDE_RECENT = (1 << 28), USER_SHOW_THUMBNAILS = (1 << 29), - USER_QUIT_PROMPT = (1 << 30) + USER_QUIT_PROMPT = (1 << 30), + USER_HIDE_SYSTEM_BOOKMARKS = (1 << 31) } eUserpref_UI_Flag; /* Auto-Keying mode */ diff --git a/source/blender/makesdna/DNA_view2d_types.h b/source/blender/makesdna/DNA_view2d_types.h index a3f4b362672..084496871bf 100644 --- a/source/blender/makesdna/DNA_view2d_types.h +++ b/source/blender/makesdna/DNA_view2d_types.h @@ -128,7 +128,7 @@ typedef struct View2D { #define V2D_SCROLL_HORIZONTAL (V2D_SCROLL_TOP|V2D_SCROLL_BOTTOM|V2D_SCROLL_BOTTOM_O) /* scale markings - vertical */ #define V2D_SCROLL_SCALE_VERTICAL (1<<5) - /* scale markings - horizontal */ + /* scale markings - horizontal */ #define V2D_SCROLL_SCALE_HORIZONTAL (1<<6) /* induce hiding of scrollbars - set by region drawing in response to size of region */ #define V2D_SCROLL_VERTICAL_HIDE (1<<7) diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h index b3c10406d4c..8a14564f8a4 100644 --- a/source/blender/makesdna/DNA_world_types.h +++ b/source/blender/makesdna/DNA_world_types.h @@ -61,14 +61,14 @@ typedef struct World { float ambr, ambg, ambb; float pad2; - unsigned int fastcol; + unsigned int fastcol; /** * Exposure= mult factor. unused now, but maybe back later. Kept in to be upward compat. * New is exp/range control. linfac & logfac are constants... don't belong in * file, but allocating 8 bytes for temp mem isn't useful either. */ - float exposure, exp, range; + float exposure, exp, range; float linfac, logfac; /** @@ -129,7 +129,7 @@ typedef struct World { struct PreviewImage *preview; /* nodes */ - struct bNodeTree *nodetree; + struct bNodeTree *nodetree; } World; diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index f5cf7e3ea3b..10c3b0bbee4 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -62,7 +62,7 @@ typedef long long __int64; * - if you want a struct not to be in DNA file: add two hash marks above it (#<enter>#<enter>) * * Structure DNA data is added to each blender file and to each executable, this to detect - * in .blend files new veriables in structs, changed array sizes, etc. It's also used for + * in .blend files new variables in structs, changed array sizes, etc. It's also used for * converting endian and pointer size (32-64 bits) * As an extra, Python uses a call to detect run-time the contents of a blender struct. * @@ -506,7 +506,7 @@ static void init_structDNA(SDNA *sdna, int do_endian_swap) } } -SDNA *DNA_sdna_from_data(void *data, int datalen, int do_endian_swap) +SDNA *DNA_sdna_from_data(const void *data, const int datalen, int do_endian_swap) { SDNA *sdna = MEM_mallocN(sizeof(*sdna), "sdna"); diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 24457f557b0..188c11911b1 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -87,14 +87,14 @@ static const char *includefiles[] = { "DNA_mesh_types.h", "DNA_meshdata_types.h", "DNA_modifier_types.h", - "DNA_lattice_types.h", + "DNA_lattice_types.h", "DNA_object_types.h", "DNA_object_force.h", "DNA_object_fluidsim.h", "DNA_world_types.h", "DNA_scene_types.h", "DNA_view3d_types.h", - "DNA_view2d_types.h", + "DNA_view2d_types.h", "DNA_space_types.h", "DNA_userdef_types.h", "DNA_screen_types.h", @@ -1176,7 +1176,7 @@ int main(int argc, char **argv) strcpy(baseDirectory, BASE_HEADER); } - fprintf(file, "unsigned char DNAstr[]= {\n"); + fprintf(file, "const unsigned char DNAstr[] = {\n"); if (make_structDNA(baseDirectory, file)) { /* error */ fclose(file); @@ -1185,7 +1185,7 @@ int main(int argc, char **argv) } else { fprintf(file, "};\n"); - fprintf(file, "int DNAlen = sizeof(DNAstr);\n"); + fprintf(file, "const int DNAlen = sizeof(DNAstr);\n"); fclose(file); } @@ -1197,7 +1197,7 @@ int main(int argc, char **argv) } /* handy but fails on struct bounds which makesdna doesnt care about - * unless structs are nested */ + * with quite the same strictness as GCC does */ #if 0 /* include files for automatic dependencies */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index fe3fd10b680..8c81a63ed4c 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -290,6 +290,7 @@ extern StructRNA RNA_KinematicConstraint; extern StructRNA RNA_Lamp; extern StructRNA RNA_LampSkySettings; extern StructRNA RNA_LampTextureSlot; +extern StructRNA RNA_LaplacianSmoothModifier; extern StructRNA RNA_Lattice; extern StructRNA RNA_LatticeModifier; extern StructRNA RNA_LatticePoint; @@ -995,7 +996,9 @@ void RNA_collection_clear(PointerRNA *ptr, const char *name); } /* check if the idproperty exists, for operators */ +int RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, int use_ghost); int RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop); +int RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, int use_ghost); int RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier); int RNA_property_is_idprop(PropertyRNA *prop); diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 511999dfa37..7d6e07baebd 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -113,6 +113,7 @@ typedef enum PropertySubType { PROP_BYTESTRING = 4, /* a string which should be represented as bytes * in python, still NULL terminated though. */ PROP_TRANSLATE = 5, /* a string which should be translated */ + PROP_PASSWORD = 6, /* a string which should not be displayed in UI */ /* numbers */ PROP_UNSIGNED = 13, diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 89be5761fac..d7a7452be05 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -61,7 +61,6 @@ /* Replace if different */ #define TMP_EXT ".tmp" - /* copied from BLI_file_older */ #include <sys/stat.h> static int file_older(const char *file1, const char *file2) @@ -76,6 +75,22 @@ static int file_older(const char *file1, const char *file2) } static const char *makesrna_path = NULL; +/* forward declarations */ +static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc, + const char *name_override, int close_prototype); + +/* helpers */ +#define WRITE_COMMA { \ + if (!first) \ + fprintf(f, ", "); \ + first = 0; \ + } (void)0 + +#define WRITE_PARAM(param) { \ + WRITE_COMMA; \ + fprintf(f, param); \ + } + static int replace_if_different(char *tmpfile, const char *dep_files[]) { /* return 0; *//* use for testing had edited rna */ @@ -212,6 +227,8 @@ static const char *rna_safe_id(const char *id) return "default_value"; else if (strcmp(id, "operator") == 0) return "operator_value"; + else if (strcmp(id, "new") == 0) + return "create"; return id; } @@ -322,13 +339,26 @@ static void rna_print_id_get(FILE *f, PropertyDefRNA *UNUSED(dp)) fprintf(f, " ID *id= ptr->id.data;\n"); } +static void rna_construct_function_name(char *buffer, int size, const char *structname, const char *propname, const char *type) +{ + snprintf(buffer, size, "%s_%s_%s", structname, propname, type); +} + +static void rna_construct_wrapper_function_name(char *buffer, int size, const char *structname, const char *propname, const char *type) +{ + if (type == NULL || type[0] == '\0') + snprintf(buffer, size, "%s_%s", structname, propname); + else + snprintf(buffer, size, "%s_%s_%s", structname, propname, type); +} + static char *rna_alloc_function_name(const char *structname, const char *propname, const char *type) { AllocDefRNA *alloc; char buffer[2048]; char *result; - snprintf(buffer, sizeof(buffer), "%s_%s_%s", structname, propname, type); + rna_construct_function_name(buffer, sizeof(buffer), structname, propname, type); result = MEM_callocN(sizeof(char) * strlen(buffer) + 1, "rna_alloc_function_name"); strcpy(result, buffer); @@ -627,17 +657,17 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr "get_length"); fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n"); fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc); - fprintf(f, " for (i=0; i<len; i++) {\n"); + fprintf(f, " for (i=0; i < len; i++) {\n"); MEM_freeN(lenfunc); } else { fprintf(f, " int i;\n\n"); - fprintf(f, " for (i=0; i<%u; i++) {\n", prop->totarraylength); + fprintf(f, " for (i=0; i < %u; i++) {\n", prop->totarraylength); } if (dp->dnaarraylength == 1) { if (prop->type == PROP_BOOLEAN && dp->booleanbit) { - fprintf(f, " values[i] = %s((data->%s & (%d<<i)) != 0);\n", + fprintf(f, " values[i] = %s((data->%s & (%d << i)) != 0);\n", (dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit); } else { @@ -653,7 +683,7 @@ static char *rna_def_property_get_func(FILE *f, StructRNA *srna, PropertyRNA *pr fprintf(f, ") != 0);\n"); } else if (rna_color_quantize(prop, dp)) { - fprintf(f, " values[i] = (%s)(data->%s[i]*(1.0f/255.0f));\n", + fprintf(f, " values[i] = (%s)(data->%s[i]*(1.0f / 255.0f));\n", rna_type_type(prop), dp->dnaname); } else if (dp->dnatype) { @@ -878,20 +908,20 @@ static char *rna_def_property_set_func(FILE *f, StructRNA *srna, PropertyRNA *pr fprintf(f, " int i, arraylen[RNA_MAX_ARRAY_DIMENSION];\n"); fprintf(f, " int len= %s(ptr, arraylen);\n\n", lenfunc); rna_clamp_value_range(f, prop); - fprintf(f, " for (i=0; i<len; i++) {\n"); + fprintf(f, " for (i=0; i < len; i++) {\n"); MEM_freeN(lenfunc); } else { fprintf(f, " int i;\n\n"); rna_clamp_value_range(f, prop); - fprintf(f, " for (i=0; i<%u; i++) {\n", prop->totarraylength); + fprintf(f, " for (i=0; i < %u; i++) {\n", prop->totarraylength); } if (dp->dnaarraylength == 1) { if (prop->type == PROP_BOOLEAN && dp->booleanbit) { fprintf(f, " if (%svalues[i]) data->%s |= (%d<<i);\n", (dp->booleannegative) ? "!" : "", dp->dnaname, dp->booleanbit); - fprintf(f, " else data->%s &= ~(%d<<i);\n", dp->dnaname, dp->booleanbit); + fprintf(f, " else data->%s &= ~(%d << i);\n", dp->dnaname, dp->booleanbit); } else { fprintf(f, " (&data->%s)[i] = %s", dp->dnaname, (dp->booleannegative) ? "!" : ""); @@ -1015,9 +1045,9 @@ static char *rna_def_property_length_func(FILE *f, StructRNA *srna, PropertyRNA else { rna_print_data_get(f, dp); if (dp->dnalengthname) - fprintf(f, " return (data->%s == NULL)? 0: data->%s;\n", dp->dnaname, dp->dnalengthname); + fprintf(f, " return (data->%s == NULL) ? 0 : data->%s;\n", dp->dnaname, dp->dnalengthname); else - fprintf(f, " return (data->%s == NULL)? 0: %d;\n", dp->dnaname, dp->dnalengthfixed); + fprintf(f, " return (data->%s == NULL) ? 0 : %d;\n", dp->dnaname, dp->dnalengthfixed); } fprintf(f, "}\n\n"); } @@ -1440,15 +1470,15 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR { if (!prop->arraydimension) { fprintf(f, "int %sget(PointerRNA *ptr);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func); } else if (prop->arraydimension && prop->totarraylength) { fprintf(f, "void %sget(PointerRNA *ptr, int values[%u]);\n", func, prop->totarraylength); - /*fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->arraylength); */ + fprintf(f, "void %sset(PointerRNA *ptr, const int values[%d]);\n", func, prop->totarraylength); } else { fprintf(f, "void %sget(PointerRNA *ptr, int values[]);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, const int values[]);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, const int values[]);\n", func); } break; } @@ -1456,15 +1486,15 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR { if (!prop->arraydimension) { fprintf(f, "float %sget(PointerRNA *ptr);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, float value);\n", func); } else if (prop->arraydimension && prop->totarraylength) { fprintf(f, "void %sget(PointerRNA *ptr, float values[%u]);\n", func, prop->totarraylength); - /*fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->arraylength); */ + fprintf(f, "void %sset(PointerRNA *ptr, const float values[%d]);\n", func, prop->totarraylength); } else { fprintf(f, "void %sget(PointerRNA *ptr, float values[]);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, const float values[]);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, const float values[]);", func); } break; } @@ -1485,7 +1515,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR } fprintf(f, "int %sget(PointerRNA *ptr);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, int value);\n", func); break; } @@ -1499,7 +1529,7 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR fprintf(f, "void %sget(PointerRNA *ptr, char *value);\n", func); fprintf(f, "int %slength(PointerRNA *ptr);\n", func); - /*fprintf(f, "void %sset(PointerRNA *ptr, const char *value);\n", func); */ + fprintf(f, "void %sset(PointerRNA *ptr, const char *value);\n", func); break; } @@ -1511,19 +1541,38 @@ static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefR } case PROP_COLLECTION: { + CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)prop; fprintf(f, "void %sbegin(CollectionPropertyIterator *iter, PointerRNA *ptr);\n", func); fprintf(f, "void %snext(CollectionPropertyIterator *iter);\n", func); fprintf(f, "void %send(CollectionPropertyIterator *iter);\n", func); - /*fprintf(f, "int %slength(PointerRNA *ptr);\n", func); */ - /*fprintf(f, "void %slookup_int(PointerRNA *ptr, int key, StructRNA **type);\n", func); */ - /*fprintf(f, "void %slookup_string(PointerRNA *ptr, const char *key, StructRNA **type);\n", func); */ + if (cprop->length) + fprintf(f, "int %slength(PointerRNA *ptr);\n", func); + if (cprop->lookupint) + fprintf(f, "int %slookup_int(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n", func); + if (cprop->lookupstring) + fprintf(f, "int %slookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n", func); break; } } + if (prop->getlength) { + char funcname[2048]; + rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, prop->identifier, "get_length"); + fprintf(f, "int %s(PointerRNA *ptr, int *arraylen);\n", funcname); + } + fprintf(f, "\n"); } +static void rna_def_function_funcs_header(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc) +{ + FunctionRNA *func = dfunc->func; + char funcname[2048]; + + rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL); + rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 1); +} + static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp) { PropertyRNA *prop; @@ -1543,26 +1592,50 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property switch (prop->type) { case PROP_BOOLEAN: { - if (!prop->arraydimension) - fprintf(f, "\tinline bool %s(void);", rna_safe_id(prop->identifier)); - else if (prop->totarraylength) - fprintf(f, "\tinline Array<int, %u> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier)); + if (!prop->arraydimension) { + fprintf(f, "\tinline bool %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int value);", rna_safe_id(prop->identifier)); + } + else if (prop->totarraylength) { + fprintf(f, "\tinline Array<int, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength); + } + else if (prop->getlength) { + fprintf(f, "\tinline DynamicArray<int> %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int values[]);", rna_safe_id(prop->identifier)); + } break; } case PROP_INT: { - if (!prop->arraydimension) - fprintf(f, "\tinline int %s(void);", rna_safe_id(prop->identifier)); - else if (prop->totarraylength) - fprintf(f, "\tinline Array<int, %u> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier)); + if (!prop->arraydimension) { + fprintf(f, "\tinline int %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int value);", rna_safe_id(prop->identifier)); + } + else if (prop->totarraylength) { + fprintf(f, "\tinline Array<int, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength); + } + else if (prop->getlength) { + fprintf(f, "\tinline DynamicArray<int> %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(int values[]);", rna_safe_id(prop->identifier)); + } break; } case PROP_FLOAT: { - if (!prop->arraydimension) - fprintf(f, "\tinline float %s(void);", rna_safe_id(prop->identifier)); - else if (prop->totarraylength) - fprintf(f, "\tinline Array<float, %u> %s(void);", prop->totarraylength, rna_safe_id(prop->identifier)); + if (!prop->arraydimension) { + fprintf(f, "\tinline float %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(float value);", rna_safe_id(prop->identifier)); + } + else if (prop->totarraylength) { + fprintf(f, "\tinline Array<float, %u> %s(void);\n", prop->totarraylength, rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(float values[%u]);", rna_safe_id(prop->identifier), prop->totarraylength); + } + else if (prop->getlength) { + fprintf(f, "\tinline DynamicArray<float> %s(void);\n", rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(float values[]);", rna_safe_id(prop->identifier)); + } break; } case PROP_ENUM: @@ -1581,7 +1654,8 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property fprintf(f, "\t};\n"); } - fprintf(f, "\tinline %s_enum %s(void);", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier)); + fprintf(f, "\tinline %s_enum %s(void);\n", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier)); + fprintf(f, "\tinline void %s(%s_enum value);", rna_safe_id(prop->identifier), rna_safe_id(prop->identifier)); break; } case PROP_STRING: @@ -1604,11 +1678,13 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop; if (cprop->item_type) - fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (const char *)cprop->item_type, srna->identifier, - rna_safe_id(prop->identifier)); + fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", (const char *)cprop->item_type, srna->identifier, + rna_safe_id(prop->identifier), (cprop->length ? "TRUE" : "FALSE"), + (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE")); else - fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, - rna_safe_id(prop->identifier)); + fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", "UnknownType", srna->identifier, + rna_safe_id(prop->identifier), (cprop->length ? "TRUE" : "FALSE"), + (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE")); break; } } @@ -1616,6 +1692,97 @@ static void rna_def_property_funcs_header_cpp(FILE *f, StructRNA *srna, Property fprintf(f, "\n"); } +static const char *rna_parameter_type_cpp_name(PropertyRNA *prop) +{ + if (prop->type == PROP_POINTER) { + /* for cpp api we need to use RNA structures names for pointers */ + PointerPropertyRNA *pprop = (PointerPropertyRNA *) prop; + + return (const char *) pprop->type; + } + else { + return rna_parameter_type_name(prop); + } +} + +static void rna_def_struct_function_prototype_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc, + const char *namespace, int close_prototype) +{ + PropertyDefRNA *dp; + FunctionRNA *func = dfunc->func; + + int first = 1; + const char *retval_type = "void"; + + if (func->c_ret) { + dp = rna_find_parameter_def(func->c_ret); + retval_type = rna_parameter_type_cpp_name(dp->prop); + } + + if (namespace && namespace[0]) + fprintf(f, "\tinline %s %s::%s(", retval_type, namespace, rna_safe_id(func->identifier)); + else + fprintf(f, "\tinline %s %s(", retval_type, rna_safe_id(func->identifier)); + + if (func->flag & FUNC_USE_MAIN) + WRITE_PARAM("void *main"); + + if (func->flag & FUNC_USE_CONTEXT) + WRITE_PARAM("Context C"); + + if (func->flag & FUNC_USE_REPORTS) + WRITE_PARAM("void *reports"); + + for (dp = dfunc->cont.properties.first; dp; dp = dp->next) { + int type, flag, pout; + const char *ptrstr; + + if (dp->prop == func->c_ret) + continue; + + type = dp->prop->type; + flag = dp->prop->flag; + pout = (flag & PROP_OUTPUT); + + if (type == PROP_POINTER) + ptrstr = ""; + else if (type == PROP_POINTER || dp->prop->arraydimension) + ptrstr = "*"; + else if (type == PROP_STRING && (flag & PROP_THICK_WRAP)) + ptrstr = ""; + else + ptrstr = pout ? "*" : ""; + + WRITE_COMMA; + + if (flag & PROP_DYNAMIC) + fprintf(f, "int %s%s_len, ", (flag & PROP_OUTPUT) ? "*" : "", dp->prop->identifier); + + if (!(flag & PROP_DYNAMIC) && dp->prop->arraydimension) + fprintf(f, "%s %s[%u]", rna_parameter_type_cpp_name(dp->prop), + rna_safe_id(dp->prop->identifier), dp->prop->totarraylength); + else + fprintf(f, "%s %s%s", rna_parameter_type_cpp_name(dp->prop), + ptrstr, rna_safe_id(dp->prop->identifier)); + } + + fprintf(f, ")"); + if (close_prototype) + fprintf(f, ";\n"); +} + +static void rna_def_struct_function_header_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc) +{ + FunctionRNA *func = dfunc->func; + + if (!dfunc->call) + return; + + fprintf(f, "\n\t/* %s */\n", func->description); + + rna_def_struct_function_prototype_cpp(f, srna, dfunc, NULL, 1); +} + static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDefRNA *dp) { PropertyRNA *prop; @@ -1633,6 +1800,9 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe else if (prop->totarraylength) fprintf(f, "\tBOOLEAN_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength, rna_safe_id(prop->identifier)); + else if (prop->getlength) + fprintf(f, "\tBOOLEAN_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier, + rna_safe_id(prop->identifier)); break; } case PROP_INT: @@ -1642,6 +1812,9 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe else if (prop->totarraylength) fprintf(f, "\tINT_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength, rna_safe_id(prop->identifier)); + else if (prop->getlength) + fprintf(f, "\tINT_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier, + rna_safe_id(prop->identifier)); break; } case PROP_FLOAT: @@ -1651,6 +1824,9 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe else if (prop->totarraylength) fprintf(f, "\tFLOAT_ARRAY_PROPERTY(%s, %u, %s)", srna->identifier, prop->totarraylength, rna_safe_id(prop->identifier)); + else if (prop->getlength) + fprintf(f, "\tFLOAT_DYNAMIC_ARRAY_PROPERTY(%s, %s)", srna->identifier, + rna_safe_id(prop->identifier)); break; } case PROP_ENUM: @@ -1683,10 +1859,13 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe CollectionPropertyRNA *cprop = (CollectionPropertyRNA *)dp->prop; if (cprop->type) - fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", (const char *)cprop->type, srna->identifier, - prop->identifier); + fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", (const char *)cprop->type, srna->identifier, + prop->identifier, (cprop->length ? "TRUE" : "FALSE"), + (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE")); else - fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s)", "UnknownType", srna->identifier, prop->identifier); + fprintf(f, "\tCOLLECTION_PROPERTY(%s, %s, %s, %s, %s, %s)", "UnknownType", srna->identifier, + prop->identifier, (cprop->length ? "TRUE" : "FALSE"), + (cprop->lookupint ? "TRUE" : "FALSE"), (cprop->lookupstring ? "TRUE" : "FALSE")); #endif break; } @@ -1695,6 +1874,178 @@ static void rna_def_property_funcs_impl_cpp(FILE *f, StructRNA *srna, PropertyDe fprintf(f, "\n"); } +static void rna_def_struct_function_call_impl_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc) +{ + PropertyDefRNA *dp; + StructDefRNA *dsrna; + FunctionRNA *func = dfunc->func; + char funcname[2048]; + + int first = 1; + + rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL); + + fprintf(f, "%s(", funcname); + + dsrna = rna_find_struct_def(srna); + + if (func->flag & FUNC_USE_SELF_ID) + WRITE_PARAM("(::ID *) ptr.id.data"); + + if ((func->flag & FUNC_NO_SELF) == 0) { + WRITE_COMMA; + if (dsrna->dnaname) fprintf(f, "(::%s *) this->ptr.data", dsrna->dnaname); + else fprintf(f, "(::%s *) this->ptr.data", srna->identifier); + } + + if (func->flag & FUNC_USE_MAIN) + WRITE_PARAM("(::Main *) main"); + + if (func->flag & FUNC_USE_CONTEXT) + WRITE_PARAM("(::bContext *) C.ptr.data"); + + if (func->flag & FUNC_USE_REPORTS) + WRITE_PARAM("(::ReportList *) reports"); + + dp = dfunc->cont.properties.first; + for (; dp; dp = dp->next) { + if (dp->prop == func->c_ret) + continue; + + WRITE_COMMA; + + if (dp->prop->flag & PROP_DYNAMIC) + fprintf(f, "%s_len, ", dp->prop->identifier); + + if (dp->prop->type == PROP_POINTER) + fprintf(f, "(::%s *) %s.ptr.data", rna_parameter_type_name(dp->prop), rna_safe_id(dp->prop->identifier)); + else + fprintf(f, "%s", rna_safe_id(dp->prop->identifier)); + } + + fprintf(f, ");\n"); +} + +static void rna_def_struct_function_impl_cpp(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc) +{ + PropertyDefRNA *dp; + PointerPropertyRNA *pprop; + + FunctionRNA *func = dfunc->func; + + if (!dfunc->call) + return; + + rna_def_struct_function_prototype_cpp(f, srna, dfunc, srna->identifier, 0); + + fprintf(f, " {\n"); + + if (func->c_ret) { + dp = rna_find_parameter_def(func->c_ret); + + if (dp->prop->type == PROP_POINTER) { + pprop = (PointerPropertyRNA *) dp->prop; + + fprintf(f, "\t\tPointerRNA ptr;\n"); + + if ((dp->prop->flag & PROP_RNAPTR) == 0) { + StructRNA *ret_srna = rna_find_struct((const char *) pprop->type); + fprintf(f, "\t\t::%s *retdata = ", rna_parameter_type_name(dp->prop)); + rna_def_struct_function_call_impl_cpp(f, srna, dfunc); + if (ret_srna->flag & STRUCT_ID) + fprintf(f, "\t\tRNA_id_pointer_create((::ID *) retdata, &ptr);\n"); + else + fprintf(f, "\t\tRNA_pointer_create(NULL, &RNA_%s, retdata, &ptr);\n", (const char *) pprop->type); + } + else { + fprintf(f, "\t\tptr = "); + rna_def_struct_function_call_impl_cpp(f, srna, dfunc); + } + + fprintf(f, "\t\treturn %s(ptr);\n", (const char *) pprop->type); + } + else { + fprintf(f, "\t\treturn "); + rna_def_struct_function_call_impl_cpp(f, srna, dfunc); + } + } + else { + fprintf(f, "\t\t"); + rna_def_struct_function_call_impl_cpp(f, srna, dfunc); + } + + fprintf(f, "\t}\n\n"); +} + +static void rna_def_property_wrapper_funcs(FILE *f, StructDefRNA *dsrna, PropertyDefRNA *dp) +{ + if (dp->prop->getlength) { + char funcname[2048]; + rna_construct_wrapper_function_name(funcname, sizeof(funcname), dsrna->srna->identifier, dp->prop->identifier, "get_length"); + fprintf(f, "int %s(PointerRNA *ptr, int *arraylen)\n", funcname); + fprintf(f, "{\n"); + fprintf(f, "\treturn %s(ptr, arraylen);\n", rna_function_string(dp->prop->getlength)); + fprintf(f, "}\n\n"); + } +} + +static void rna_def_function_wrapper_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc) +{ + StructRNA *srna = dsrna->srna; + FunctionRNA *func = dfunc->func; + PropertyDefRNA *dparm; + + int first; + char funcname[2048]; + + if (!dfunc->call) + return; + + rna_construct_wrapper_function_name(funcname, sizeof(funcname), srna->identifier, func->identifier, NULL); + + rna_generate_static_parameter_prototypes(f, srna, dfunc, funcname, 0); + + fprintf(f, "\n{\n"); + + if (func->c_ret) + fprintf(f, "\treturn %s(", dfunc->call); + else + fprintf(f, "\t%s(", dfunc->call); + + first = 1; + + if (func->flag & FUNC_USE_SELF_ID) + WRITE_PARAM("_selfid"); + + if ((func->flag & FUNC_NO_SELF) == 0) + WRITE_PARAM("_self"); + + if (func->flag & FUNC_USE_MAIN) + WRITE_PARAM("bmain"); + + if (func->flag & FUNC_USE_CONTEXT) + WRITE_PARAM("C"); + + if (func->flag & FUNC_USE_REPORTS) + WRITE_PARAM("reports"); + + dparm = dfunc->cont.properties.first; + for (; dparm; dparm = dparm->next) { + if (dparm->prop == func->c_ret) + continue; + + WRITE_COMMA; + + if (dparm->prop->flag & PROP_DYNAMIC) + fprintf(f, "%s_len, %s", dparm->prop->identifier, dparm->prop->identifier); + else + fprintf(f, "%s", rna_safe_id(dparm->prop->identifier)); + } + + fprintf(f, ");\n"); + fprintf(f, "}\n\n"); +} + static void rna_def_function_funcs(FILE *f, StructDefRNA *dsrna, FunctionDefRNA *dfunc) { StructRNA *srna; @@ -1994,6 +2345,7 @@ static const char *rna_property_subtypename(PropertySubType type) case PROP_COORDS: return "PROP_COORDS"; case PROP_LAYER: return "PROP_LAYER"; case PROP_LAYER_MEMBER: return "PROP_LAYER_MEMBER"; + case PROP_PASSWORD: return "PROP_PASSWORD"; default: { /* in case we don't have a type preset that includes the subtype */ if (RNA_SUBTYPE_UNIT(type)) { @@ -2110,7 +2462,7 @@ static void rna_generate_function_prototypes(BlenderRNA *brna, StructRNA *srna, fprintf(f, "\n"); } -static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FunctionDefRNA *dfunc, FILE *f) +static void rna_generate_static_parameter_prototypes(FILE *f, StructRNA *srna, FunctionDefRNA *dfunc, const char *name_override, int close_prototype) { FunctionRNA *func; PropertyDefRNA *dparm; @@ -2141,7 +2493,10 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), S fprintf(f, "void "); /* function name */ - fprintf(f, "%s(", dfunc->call); + if (name_override == NULL || name_override[0] == '\0') + fprintf(f, "%s(", dfunc->call); + else + fprintf(f, "%s(", name_override); first = 1; @@ -2150,7 +2505,7 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), S fprintf(f, "struct ID *_selfid"); first = 0; } - + if ((func->flag & FUNC_NO_SELF) == 0) { if (!first) fprintf(f, ", "); if (dsrna->dnaname) fprintf(f, "struct %s *_self", dsrna->dnaname); @@ -2203,17 +2558,19 @@ static void rna_generate_static_parameter_prototypes(BlenderRNA *UNUSED(brna), S if (!(flag & PROP_DYNAMIC) && dparm->prop->arraydimension) fprintf(f, "%s%s %s[%u]", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), - dparm->prop->identifier, dparm->prop->totarraylength); + rna_safe_id(dparm->prop->identifier), dparm->prop->totarraylength); else fprintf(f, "%s%s %s%s", rna_type_struct(dparm->prop), rna_parameter_type_name(dparm->prop), - ptrstr, dparm->prop->identifier); + ptrstr, rna_safe_id(dparm->prop->identifier)); } - fprintf(f, ");\n"); + fprintf(f, ")"); + if (close_prototype) + fprintf(f, ";\n"); } -static void rna_generate_static_function_prototypes(BlenderRNA *brna, StructRNA *srna, FILE *f) +static void rna_generate_static_function_prototypes(BlenderRNA *UNUSED(brna), StructRNA *srna, FILE *f) { FunctionRNA *func; FunctionDefRNA *dfunc; @@ -2228,7 +2585,50 @@ static void rna_generate_static_function_prototypes(BlenderRNA *brna, StructRNA first = 0; } - rna_generate_static_parameter_prototypes(brna, srna, dfunc, f); + rna_generate_static_parameter_prototypes(f, srna, dfunc, NULL, 1); + } + } + + fprintf(f, "\n"); +} + +static void rna_generate_struct_prototypes(FILE *f) +{ + StructDefRNA *ds; + PropertyDefRNA *dp; + FunctionDefRNA *dfunc; + const char *structures[2048]; + int all_structures = 0; + + /* structures definitions */ + for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { + for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) { + if (dfunc->call) { + for (dp = dfunc->cont.properties.first; dp; dp = dp->next) { + if (dp->prop->type == PROP_POINTER) { + int a, found = 0; + const char *struct_name = rna_parameter_type_name(dp->prop); + + for (a = 0; a < all_structures; a++) { + if (strcmp(struct_name, structures[a]) == 0) { + found = 1; + break; + } + } + + if (found == 0) { + fprintf(f, "struct %s;\n", struct_name); + + if (all_structures >= sizeof(structures) / sizeof(structures[0])) { + printf("Array size to store all structures names is too small\n"); + exit(1); + } + + structures[all_structures++] = struct_name; + } + } + } + } } } @@ -2795,8 +3195,13 @@ static void rna_generate(BlenderRNA *brna, FILE *f, const char *filename, const for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { if (!filename || ds->filename == filename) { - for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) + for (dp = ds->cont.properties.first; dp; dp = dp->next) + rna_def_property_wrapper_funcs(f, ds, dp); + + for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) { + rna_def_function_wrapper_funcs(f, ds, dfunc); rna_def_function_funcs(f, ds, dfunc); + } rna_generate_static_function_prototypes(brna, ds->srna, f); } @@ -2820,6 +3225,7 @@ static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f) StructDefRNA *ds; PropertyDefRNA *dp; StructRNA *srna; + FunctionDefRNA *dfunc; fprintf(f, "\n#ifndef __RNA_BLENDER_H__\n"); fprintf(f, "#define __RNA_BLENDER_H__\n\n"); @@ -2857,6 +3263,9 @@ static void rna_generate_header(BlenderRNA *UNUSED(brna), FILE *f) for (dp = ds->cont.properties.first; dp; dp = dp->next) rna_def_property_funcs_header(f, ds->srna, dp); + + for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) + rna_def_function_funcs_header(f, ds->srna, dfunc); } fprintf(f, "#ifdef __cplusplus\n}\n#endif\n\n"); @@ -2872,28 +3281,68 @@ static const char *cpp_classes = "" "namespace BL {\n" "\n" "#define BOOLEAN_PROPERTY(sname, identifier) \\\n" -" inline bool sname::identifier(void) { return sname##_##identifier##_get(&ptr)? true: false; }\n" +" inline bool sname::identifier(void) { return sname##_##identifier##_get(&ptr)? true: false; } \\\n" +" inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n" "\n" "#define BOOLEAN_ARRAY_PROPERTY(sname, size, identifier) \\\n" " inline Array<int,size> sname::identifier(void) \\\n" -" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n" +" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n" +" inline void sname::identifier(int values[size]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" +"\n" +"#define BOOLEAN_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n" +" inline DynamicArray<int> sname::identifier(void) { \\\n" +" int arraylen[3]; \\\n" +" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n" +" DynamicArray<int> ar(len); \\\n" +" sname##_##identifier##_get(&ptr, ar.data); \\\n" +" return ar; } \\\n" +" inline void sname::identifier(int values[]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" "\n" "#define INT_PROPERTY(sname, identifier) \\\n" -" inline int sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n" +" inline int sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n" +" inline void sname::identifier(int value) { sname##_##identifier##_set(&ptr, value); }\n" "\n" "#define INT_ARRAY_PROPERTY(sname, size, identifier) \\\n" " inline Array<int,size> sname::identifier(void) \\\n" -" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n" +" { Array<int, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n" +" inline void sname::identifier(int values[size]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" +"\n" +"#define INT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n" +" inline DynamicArray<int> sname::identifier(void) { \\\n" +" int arraylen[3]; \\\n" +" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n" +" DynamicArray<int> ar(len); \\\n" +" sname##_##identifier##_get(&ptr, ar.data); \\\n" +" return ar; } \\\n" +" inline void sname::identifier(int values[]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" "\n" "#define FLOAT_PROPERTY(sname, identifier) \\\n" -" inline float sname::identifier(void) { return sname##_##identifier##_get(&ptr); }\n" +" inline float sname::identifier(void) { return sname##_##identifier##_get(&ptr); } \\\n" +" inline void sname::identifier(float value) { sname##_##identifier##_set(&ptr, value); }\n" "\n" "#define FLOAT_ARRAY_PROPERTY(sname, size, identifier) \\\n" " inline Array<float,size> sname::identifier(void) \\\n" -" { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; }\n" +" { Array<float, size> ar; sname##_##identifier##_get(&ptr, ar.data); return ar; } \\\n" +" inline void sname::identifier(float values[size]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" +"\n" +"#define FLOAT_DYNAMIC_ARRAY_PROPERTY(sname, identifier) \\\n" +" inline DynamicArray<float> sname::identifier(void) { \\\n" +" int arraylen[3]; \\\n" +" int len = sname##_##identifier##_get_length(&ptr, arraylen); \\\n" +" DynamicArray<float> ar(len); \\\n" +" sname##_##identifier##_get(&ptr, ar.data); \\\n" +" return ar; } \\\n" +" inline void sname::identifier(float values[]) \\\n" +" { sname##_##identifier##_set(&ptr, values); } \\\n" "\n" "#define ENUM_PROPERTY(type, sname, identifier) \\\n" -" inline sname::type sname::identifier(void) { return (type)sname##_##identifier##_get(&ptr); }\n" +" inline sname::type sname::identifier(void) { return (type)sname##_##identifier##_get(&ptr); } \\\n" +" inline void sname::identifier(sname::type value) { sname##_##identifier##_set(&ptr, value); }\n" "\n" "#define STRING_PROPERTY(sname, identifier) \\\n" " inline std::string sname::identifier(void) { \\\n" @@ -2904,11 +3353,66 @@ static const char *cpp_classes = "" "#define POINTER_PROPERTY(type, sname, identifier) \\\n" " inline type sname::identifier(void) { return type(sname##_##identifier##_get(&ptr)); }\n" "\n" -"#define COLLECTION_PROPERTY(type, sname, identifier) \\\n" +"#define COLLECTION_PROPERTY_LENGTH_FALSE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n" +" { \\\n" +" CollectionPropertyIterator iter; \\\n" +" int length = 0; \\\n" +" sname##_##identifier##_begin(&iter, ptr); \\\n" +" while (iter.valid) { \\\n" +" sname##_##identifier##_next(&iter); \\\n" +" ++length; \\\n" +" } \\\n" +" sname##_##identifier##_end(&iter); \\\n" +" return length; \\\n" +" } \n" +"#define COLLECTION_PROPERTY_LENGTH_TRUE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_length_wrap(PointerRNA *ptr) \\\n" +" { return sname##_##identifier##_length(ptr); } \n" +"\n" +"#define COLLECTION_PROPERTY_LOOKUP_INT_FALSE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \\\n" +" { \\\n" +" CollectionPropertyIterator iter; \\\n" +" int i = 0; \\\n" +" sname##_##identifier##_begin(&iter, ptr); \\\n" +" while (iter.valid) { \\\n" +" if (i == key) { \\\n" +" *r_ptr = iter.ptr; \\\n" +" break; \\\n" +" } \\\n" +" sname##_##identifier##_next(&iter); \\\n" +" ++i; \\\n" +" } \\\n" +" sname##_##identifier##_end(&iter); \\\n" +" if (!iter.valid) \\\n" +" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n" +" return iter.valid; \\\n" +" } \n" +"#define COLLECTION_PROPERTY_LOOKUP_INT_TRUE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_lookup_int_wrap(PointerRNA *ptr, int key, PointerRNA *r_ptr) \\\n" +" { return sname##_##identifier##_lookup_int(ptr, key, r_ptr); } \n" +"\n" +"#define COLLECTION_PROPERTY_LOOKUP_STRING_FALSE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n" +" { \\\n" +" memset(r_ptr, 0, sizeof(*r_ptr)); \\\n" +" return 0; \\\n" +" } \n" +"#define COLLECTION_PROPERTY_LOOKUP_STRING_TRUE(sname, identifier) \\\n" +" inline static int sname##_##identifier##_lookup_string_wrap(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) \\\n" +" { return sname##_##identifier##_lookup_string(ptr, key, r_ptr); } \n" +"\n" +"#define COLLECTION_PROPERTY(type, sname, identifier, has_length, has_lookup_int, has_lookup_string) \\\n" " typedef CollectionIterator<type, sname##_##identifier##_begin, \\\n" " sname##_##identifier##_next, sname##_##identifier##_end> identifier##_iterator; \\\n" +" COLLECTION_PROPERTY_LENGTH_##has_length(sname, identifier) \\\n" +" COLLECTION_PROPERTY_LOOKUP_INT_##has_lookup_int(sname, identifier) \\\n" +" COLLECTION_PROPERTY_LOOKUP_STRING_##has_lookup_string(sname, identifier) \\\n" " Collection<sname, type, sname##_##identifier##_begin, \\\n" -" sname##_##identifier##_next, sname##_##identifier##_end> identifier;\n" +" sname##_##identifier##_next, sname##_##identifier##_end, \\\n" +" sname##_##identifier##_length_wrap, \\\n" +" sname##_##identifier##_lookup_int_wrap, sname##_##identifier##_lookup_string_wrap> identifier;\n" "\n" "class Pointer {\n" "public:\n" @@ -2927,7 +3431,7 @@ static const char *cpp_classes = "" "public:\n" " T data[Tsize];\n" "\n" -" Array() {}\n" +" Array() {}\n" " Array(const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); }\n" " const Array<T, Tsize>& operator=(const Array<T, Tsize>& other) { memcpy(data, other.data, sizeof(T) * Tsize); " "return *this; }\n" @@ -2935,9 +3439,36 @@ static const char *cpp_classes = "" " operator T*() { return data; }\n" "};\n" "\n" +"template<typename T>\n" +"class DynamicArray {\n" +"public:\n" +" T *data;\n" +" int length;\n" +"\n" +" DynamicArray() : data(NULL), length(0) {}\n" +" DynamicArray(int new_length) : data(NULL), length(new_length) { data = (float*)malloc(sizeof(T) * new_length); }\n" +" DynamicArray(const DynamicArray<T>& other) { copy_from(other); }\n" +" const DynamicArray<T>& operator=(const DynamicArray<T>& other) { copy_from(other); return *this; }\n" +"\n" +" ~DynamicArray() { if (data) free(data); }\n" +"\n" +" operator T*() { return data; }\n" +"\n" +"protected:\n" +" void copy_from(const DynamicArray<T>& other) {\n" +" if (data) free(data);\n" +" data = (float*)malloc(sizeof(T) * other.length);\n" +" memcpy(data, other.data, sizeof(T) * other.length);\n" +" length = other.length;\n" +" }\n" +"};\n" +"\n" "typedef void (*TBeginFunc)(CollectionPropertyIterator *iter, PointerRNA *ptr);\n" "typedef void (*TNextFunc)(CollectionPropertyIterator *iter);\n" "typedef void (*TEndFunc)(CollectionPropertyIterator *iter);\n" +"typedef int (*TLengthFunc)(PointerRNA *ptr);\n" +"typedef int (*TLookupIntFunc)(PointerRNA *ptr, int key, PointerRNA *r_ptr);\n" +"typedef int (*TLookupStringFunc)(PointerRNA *ptr, const char *key, PointerRNA *r_ptr);\n" "\n" "template<typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n" "class CollectionIterator {\n" @@ -2968,7 +3499,8 @@ static const char *cpp_classes = "" " bool init;\n" "};\n" "\n" -"template<typename Tp, typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend>\n" +"template<typename Tp, typename T, TBeginFunc Tbegin, TNextFunc Tnext, TEndFunc Tend,\n" +" TLengthFunc Tlength, TLookupIntFunc Tlookup_int, TLookupStringFunc Tlookup_string>\n" "class Collection {\n" "public:\n" " Collection(const PointerRNA &p) : ptr(p) {}\n" @@ -2977,6 +3509,13 @@ static const char *cpp_classes = "" " { iter.begin(ptr); }\n" " CollectionIterator<T, Tbegin, Tnext, Tend> end()\n" " { return CollectionIterator<T, Tbegin, Tnext, Tend>(); } /* test */ \n" +"" +" int length()\n" +" { return Tlength(&ptr); }\n" +" T& operator[](int key)\n" +" { PointerRNA r_ptr; Tlookup_int(&ptr, key, &r_ptr); return *(T*)r_ptr.data; }\n" +" T& operator[](const std::string &key)\n" +" { PointerRNA r_ptr; Tlookup_string(&ptr, key.c_str(), &r_ptr); return *(T*)r_ptr.data; }\n" "\n" "private:\n" " PointerRNA ptr;\n" @@ -2988,6 +3527,7 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f) StructDefRNA *ds; PropertyDefRNA *dp; StructRNA *srna; + FunctionDefRNA *dfunc; fprintf(f, "\n#ifndef __RNA_BLENDER_CPP_H__\n"); fprintf(f, "#define __RNA_BLENDER_CPP_H__\n\n"); @@ -3025,17 +3565,39 @@ static void rna_generate_header_cpp(BlenderRNA *UNUSED(brna), FILE *f) for (dp = ds->cont.properties.first; dp; dp = dp->next) rna_def_property_funcs_header_cpp(f, ds->srna, dp); + + fprintf(f, "\n"); + for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) + rna_def_struct_function_header_cpp(f, srna, dfunc); + fprintf(f, "};\n\n"); } + fprintf(f, "} /* namespace BL */\n"); + fprintf(f, "\n"); fprintf(f, "/**************** Implementation ****************/\n"); + fprintf(f, "\n"); + + fprintf(f, "/* Structure prototypes */\n\n"); + fprintf(f, "extern \"C\" {\n"); + rna_generate_struct_prototypes(f); + fprintf(f, "}\n\n"); + + fprintf(f, "namespace BL {\n"); for (ds = DefRNA.structs.first; ds; ds = ds->cont.next) { + srna = ds->srna; + for (dp = ds->cont.properties.first; dp; dp = dp->next) rna_def_property_funcs_impl_cpp(f, ds->srna, dp); fprintf(f, "\n"); + + for (dfunc = ds->functions.first; dfunc; dfunc = dfunc->cont.next) + rna_def_struct_function_impl_cpp(f, srna, dfunc); + + fprintf(f, "\n"); } fprintf(f, "}\n\n#endif /* __RNA_BLENDER_CPP_H__ */\n\n"); @@ -3072,34 +3634,8 @@ static int rna_preprocess(const char *outfile) rna_auto_types(); - - /* create RNA_blender_cpp.h */ - strcpy(deffile, outfile); - strcat(deffile, "RNA_blender_cpp.h" TMP_EXT); - status = (DefRNA.error != 0); - if (status) { - make_bad_file(deffile, __LINE__); - } - else { - file = fopen(deffile, "w"); - - if (!file) { - fprintf(stderr, "Unable to open file: %s\n", deffile); - status = 1; - } - else { - rna_generate_header_cpp(brna, file); - fclose(file); - status = (DefRNA.error != 0); - } - } - - replace_if_different(deffile, NULL); - - rna_sort(brna); - /* create rna_gen_*.c files */ for (i = 0; PROCESS_ITEMS[i].filename; i++) { strcpy(deffile, outfile); @@ -3132,6 +3668,31 @@ static int rna_preprocess(const char *outfile) replace_if_different(deffile, deps); } + /* create RNA_blender_cpp.h */ + strcpy(deffile, outfile); + strcat(deffile, "RNA_blender_cpp.h" TMP_EXT); + + if (status) { + make_bad_file(deffile, __LINE__); + } + else { + file = fopen(deffile, "w"); + + if (!file) { + fprintf(stderr, "Unable to open file: %s\n", deffile); + status = 1; + } + else { + rna_generate_header_cpp(brna, file); + fclose(file); + status = (DefRNA.error != 0); + } + } + + replace_if_different(deffile, NULL); + + rna_sort(brna); + /* create RNA_blender.h */ strcpy(deffile, outfile); strcat(deffile, "RNA_blender.h" TMP_EXT); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 2c3bc0360fc..5efd162fe02 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -246,8 +246,8 @@ StructRNA *rna_PropertyGroup_register(Main *UNUSED(bmain), ReportList *reports, * owns the string pointer which it could potentially free while blender * is running. */ if (BLI_strnlen(identifier, MAX_IDPROP_NAME) == MAX_IDPROP_NAME) { - BKE_reportf(reports, RPT_ERROR, "registering id property class: '%s' is too long, maximum length is " - STRINGIFY(MAX_IDPROP_NAME), identifier); + BKE_reportf(reports, RPT_ERROR, "Registering id property class: '%s' is too long, maximum length is %d", + identifier, MAX_IDPROP_NAME); return NULL; } @@ -290,7 +290,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) switch (GS(id->name)) { case ID_OB: if (flag & ~(OB_RECALC_ALL)) { - BKE_report(reports, RPT_ERROR, "'refresh' incompatible with Object ID type"); + BKE_report(reports, RPT_ERROR, "'Refresh' incompatible with Object ID type"); return; } break; @@ -298,7 +298,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) #if 0 case ID_PA: if (flag & ~(OB_RECALC_ALL | PSYS_RECALC)) { - BKE_report(reports, RPT_ERROR, "'refresh' incompatible with ParticleSettings ID type"); + BKE_report(reports, RPT_ERROR, "'Refresh' incompatible with ParticleSettings ID type"); return; } break; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 610895002aa..1fe46342819 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -3647,7 +3647,8 @@ int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prope int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop, int *index) { PropertyRNA *prop; - PointerRNA curptr, nextptr; + PointerRNA curptr; + PointerRNA nextptr; /* keep uninitialized, helps expose bugs in collection accessor functions */ char fixedbuf[256], *token; int type, intkey; @@ -3713,7 +3714,12 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, /* check for "" to see if it is a string */ if (rna_token_strip_quotes(token)) { - RNA_property_collection_lookup_string(&curptr, prop, token + 1, &nextptr); + if (RNA_property_collection_lookup_string(&curptr, prop, token + 1, &nextptr)) { + /* pass */ + } + else { + nextptr.data = NULL; + } } else { /* otherwise do int lookup */ @@ -3721,7 +3727,12 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, if (intkey == 0 && (token[0] != '0' || token[1] != '\0')) { return 0; /* we can be sure the fixedbuf was used in this case */ } - RNA_property_collection_lookup_int(&curptr, prop, intkey, &nextptr); + if (RNA_property_collection_lookup_int(&curptr, prop, intkey, &nextptr)) { + /* pass */ + } + else { + nextptr.data = NULL; + } } if (token != fixedbuf) { @@ -3730,13 +3741,14 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, } else { PointerRNA c_ptr; - - /* ensure we quit on invalid values */ - nextptr.data = NULL; if (RNA_property_collection_type_get(&curptr, prop, &c_ptr)) { nextptr = c_ptr; } + else { + /* ensure we quit on invalid values */ + nextptr.data = NULL; + } } if (nextptr.data) { @@ -4512,6 +4524,17 @@ int RNA_collection_length(PointerRNA *ptr, const char *name) } } +int RNA_property_is_set_ex(PointerRNA *ptr, PropertyRNA *prop, int use_ghost) +{ + if (prop->flag & PROP_IDPROPERTY) { + IDProperty *idprop = rna_idproperty_find(ptr, prop->identifier); + return ((idprop != NULL) && (use_ghost == FALSE || !(idprop->flag & IDP_FLAG_GHOST))); + } + else { + return 1; + } +} + int RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop) { if (prop->flag & PROP_IDPROPERTY) { @@ -4523,6 +4546,20 @@ int RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop) } } +int RNA_struct_property_is_set_ex(PointerRNA *ptr, const char *identifier, int use_ghost) +{ + PropertyRNA *prop = RNA_struct_find_property(ptr, identifier); + + if (prop) { + return RNA_property_is_set_ex(ptr, prop, use_ghost); + } + else { + /* python raises an error */ + /* printf("%s: %s.%s not found.\n", __func__, ptr->type->identifier, name); */ + return 0; + } +} + int RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier) { PropertyRNA *prop = RNA_struct_find_property(ptr, identifier); @@ -5219,7 +5256,7 @@ static int rna_function_format_array_length(const char *format, int ofs, int fle lenbuf[idx] = format[ofs]; if (ofs < flen && format[ofs + 1] == ']') { - /* XXX put better error reporting for ofs>=flen or idx over lenbuf capacity */ + /* XXX put better error reporting for (ofs >= flen) or idx over lenbuf capacity */ lenbuf[idx] = '\0'; return atoi(lenbuf); } diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 54e213c1ac6..739b02ef042 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -74,7 +74,7 @@ static void rna_Action_groups_remove(bAction *act, ReportList *reports, bActionG /* try to remove the F-Curve from the action */ if (!BLI_remlink_safe(&act->groups, agrp)) { - BKE_reportf(reports, RPT_ERROR, "ActionGroup '%s' not found in action '%s'", agrp->name, act->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Action group '%s' not found in action '%s'", agrp->name, act->id.name + 2); return; } @@ -116,7 +116,7 @@ static void rna_Action_fcurve_remove(bAction *act, ReportList *reports, FCurve * { if (fcu->grp) { if (BLI_findindex(&act->groups, fcu->grp) == -1) { - BKE_reportf(reports, RPT_ERROR, "F-Curve's ActionGroup '%s' not found in action '%s'", + BKE_reportf(reports, RPT_ERROR, "F-Curve's action group '%s' not found in action '%s'", fcu->grp->name, act->id.name + 2); return; } @@ -148,7 +148,7 @@ static TimeMarker *rna_Action_pose_markers_new(bAction *act, const char name[]) static void rna_Action_pose_markers_remove(bAction *act, ReportList *reports, TimeMarker *marker) { if (!BLI_remlink_safe(&act->markers, marker)) { - BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in Action '%s'", marker->name, act->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Timeline marker '%s' not found in action '%s'", marker->name, act->id.name + 2); return; } @@ -256,15 +256,14 @@ static void rna_def_dopesheet(BlenderRNA *brna) srna = RNA_def_struct(brna, "DopeSheet", NULL); RNA_def_struct_sdna(srna, "bDopeSheet"); - RNA_def_struct_ui_text(srna, "DopeSheet", "Settings for filtering the channels shown in Animation Editors"); + RNA_def_struct_ui_text(srna, "DopeSheet", "Settings for filtering the channels shown in animation editors"); /* Source of DopeSheet data */ /* XXX: make this obsolete? */ prop = RNA_def_property(srna, "source", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); RNA_def_property_ui_text(prop, "Source", - "ID-Block representing source data, currently ID_SCE (for Dopesheet), " - "and ID_SC (for Grease Pencil)"); + "ID-Block representing source data, usually ID_SCE (i.e. Scene)"); /* Show datablock filters */ prop = RNA_def_property(srna, "show_datablock_filters", PROP_BOOLEAN, PROP_NONE); @@ -283,29 +282,29 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_hidden", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_INCL_HIDDEN); - RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that aren't visible"); + RNA_def_property_ui_text(prop, "Display Hidden", "Include channels from objects/bone that are not visible"); RNA_def_property_ui_icon(prop, ICON_GHOST_ENABLED, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* Debug Filtering Settings */ prop = RNA_def_property(srna, "show_only_errors", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLY_ERRORS); - RNA_def_property_ui_text(prop, "Show Errors", "Only include F-Curves and Drivers that are disabled or have errors"); - RNA_def_property_ui_icon(prop, ICON_HELP, 0); // XXX: this doesn't quite fit? + RNA_def_property_ui_text(prop, "Show Errors", "Only include F-Curves and drivers that are disabled or have errors"); + RNA_def_property_ui_icon(prop, ICON_HELP, 0); /* XXX: this doesn't quite fit */ RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* Object Group Filtering Settings */ prop = RNA_def_property(srna, "show_only_group_objects", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_ONLYOBGROUP); RNA_def_property_ui_text(prop, "Only Objects in Group", - "Only include channels from Objects in the specified Group"); + "Only include channels from objects in the specified group"); RNA_def_property_ui_icon(prop, ICON_GROUP, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "filter_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "filter_grp"); RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Filtering Group", "Group that included Object should be a member of"); + RNA_def_property_ui_text(prop, "Filtering Group", "Group that included object should be a member of"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* FCurve Display Name Search Settings */ @@ -325,21 +324,21 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_missing_nla", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NLA_NOACT); RNA_def_property_ui_text(prop, "Include Missing NLA", - "Include Animation Data blocks with no NLA data (NLA Editor only)"); + "Include animation data blocks with no NLA data (NLA editor only)"); RNA_def_property_ui_icon(prop, ICON_ACTION, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* Summary Settings (DopeSheet editors only) */ prop = RNA_def_property(srna, "show_summary", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filterflag", ADS_FILTER_SUMMARY); - RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line (DopeSheet Editors only)"); + RNA_def_property_ui_text(prop, "Display Summary", "Display an additional 'summary' line (DopeSheet editors only)"); RNA_def_property_ui_icon(prop, ICON_BORDERMOVE, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_expanded_summary", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ADS_FLAG_SUMMARY_COLLAPSED); RNA_def_property_ui_text(prop, "Collapse Summary", - "Collapse summary when shown, so all other channels get hidden (DopeSheet Editors Only)"); + "Collapse summary when shown, so all other channels get hidden (DopeSheet editors only)"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -347,43 +346,43 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_transforms", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOOBJ); RNA_def_property_ui_text(prop, "Display Transforms", - "Include visualization of Object-level Animation data (mostly Transforms)"); + "Include visualization of object-level animation data (mostly transforms)"); RNA_def_property_ui_icon(prop, ICON_MANIPUL, 0); /* XXX? */ RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_shapekeys", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSHAPEKEYS); - RNA_def_property_ui_text(prop, "Display Shapekeys", "Include visualization of ShapeKey related Animation data"); + RNA_def_property_ui_text(prop, "Display Shapekeys", "Include visualization of shape key related animation data"); RNA_def_property_ui_icon(prop, ICON_SHAPEKEY_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_meshes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMESH); - RNA_def_property_ui_text(prop, "Display Meshes", "Include visualization of Mesh related Animation data"); + RNA_def_property_ui_text(prop, "Display Meshes", "Include visualization of mesh related animation data"); RNA_def_property_ui_icon(prop, ICON_MESH_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_lattices", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAT); - RNA_def_property_ui_text(prop, "Display Lattices", "Include visualization of Lattice related Animation data"); + RNA_def_property_ui_text(prop, "Display Lattices", "Include visualization of lattice related animation data"); RNA_def_property_ui_icon(prop, ICON_LATTICE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_cameras", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCAM); - RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of Camera related Animation data"); + RNA_def_property_ui_text(prop, "Display Camera", "Include visualization of camera related animation data"); RNA_def_property_ui_icon(prop, ICON_CAMERA_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_materials", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMAT); - RNA_def_property_ui_text(prop, "Display Material", "Include visualization of Material related Animation data"); + RNA_def_property_ui_text(prop, "Display Material", "Include visualization of material related animation data"); RNA_def_property_ui_icon(prop, ICON_MATERIAL_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_lamps", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOLAM); - RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of Lamp related Animation data"); + RNA_def_property_ui_text(prop, "Display Lamp", "Include visualization of lamp related animation data"); RNA_def_property_ui_icon(prop, ICON_LAMP_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -395,55 +394,55 @@ static void rna_def_dopesheet(BlenderRNA *brna) prop = RNA_def_property(srna, "show_textures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOTEX); - RNA_def_property_ui_text(prop, "Display Texture", "Include visualization of Texture related Animation data"); + RNA_def_property_ui_text(prop, "Display Texture", "Include visualization of texture related animation data"); RNA_def_property_ui_icon(prop, ICON_TEXTURE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_curves", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOCUR); - RNA_def_property_ui_text(prop, "Display Curve", "Include visualization of Curve related Animation data"); + RNA_def_property_ui_text(prop, "Display Curve", "Include visualization of curve related animation data"); RNA_def_property_ui_icon(prop, ICON_CURVE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_worlds", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOWOR); - RNA_def_property_ui_text(prop, "Display World", "Include visualization of World related Animation data"); + RNA_def_property_ui_text(prop, "Display World", "Include visualization of world related animation data"); RNA_def_property_ui_icon(prop, ICON_WORLD_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_scenes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSCE); - RNA_def_property_ui_text(prop, "Display Scene", "Include visualization of Scene related Animation data"); + RNA_def_property_ui_text(prop, "Display Scene", "Include visualization of scene related animation data"); RNA_def_property_ui_icon(prop, ICON_SCENE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_particles", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOPART); - RNA_def_property_ui_text(prop, "Display Particle", "Include visualization of Particle related Animation data"); + RNA_def_property_ui_text(prop, "Display Particle", "Include visualization of particle related animation data"); RNA_def_property_ui_icon(prop, ICON_PARTICLE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_metaballs", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOMBA); - RNA_def_property_ui_text(prop, "Display Metaball", "Include visualization of Metaball related Animation data"); + RNA_def_property_ui_text(prop, "Display Metaball", "Include visualization of metaball related animation data"); RNA_def_property_ui_icon(prop, ICON_META_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_armatures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOARM); - RNA_def_property_ui_text(prop, "Display Armature", "Include visualization of Armature related Animation data"); + RNA_def_property_ui_text(prop, "Display Armature", "Include visualization of armature related animation data"); RNA_def_property_ui_icon(prop, ICON_ARMATURE_DATA, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_nodes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NONTREE); - RNA_def_property_ui_text(prop, "Display Node", "Include visualization of Node related Animation data"); + RNA_def_property_ui_text(prop, "Display Node", "Include visualization of node related animation data"); RNA_def_property_ui_icon(prop, ICON_NODETREE, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_speakers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "filterflag", ADS_FILTER_NOSPK); - RNA_def_property_ui_text(prop, "Display Speaker", "Include visualization of Speaker related Animation data"); + RNA_def_property_ui_text(prop, "Display Speaker", "Include visualization of speaker related animation data"); RNA_def_property_ui_icon(prop, ICON_SPEAKER, 0); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } @@ -480,17 +479,17 @@ static void rna_def_action_group(BlenderRNA *brna) prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_SELECTED); - RNA_def_property_ui_text(prop, "Select", "Action Group is selected"); + RNA_def_property_ui_text(prop, "Select", "Action group is selected"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_PROTECTED); - RNA_def_property_ui_text(prop, "Lock", "Action Group is locked"); + RNA_def_property_ui_text(prop, "Lock", "Action group is locked"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", AGRP_EXPANDED); - RNA_def_property_ui_text(prop, "Expanded", "Action Group is expanded"); + RNA_def_property_ui_text(prop, "Expanded", "Action group is expanded"); RNA_def_property_update(prop, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* color set */ @@ -589,7 +588,7 @@ static void rna_def_action_pose_markers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_pointer_funcs(prop, "rna_Action_active_pose_marker_get", "rna_Action_active_pose_marker_set", NULL, NULL); - RNA_def_property_ui_text(prop, "Active Pose Marker", "Active pose marker for this Action"); + RNA_def_property_ui_text(prop, "Active Pose Marker", "Active pose marker for this action"); prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "active_marker"); @@ -612,7 +611,7 @@ static void rna_def_action(BlenderRNA *brna) prop = RNA_def_property(srna, "fcurves", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "curves", NULL); RNA_def_property_struct_type(prop, "FCurve"); - RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the Action"); + RNA_def_property_ui_text(prop, "F-Curves", "The individual F-Curves that make up the action"); rna_def_action_fcurves(brna, prop); prop = RNA_def_property(srna, "groups", PROP_COLLECTION, PROP_NONE); @@ -624,7 +623,7 @@ static void rna_def_action(BlenderRNA *brna) prop = RNA_def_property(srna, "pose_markers", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "markers", NULL); RNA_def_property_struct_type(prop, "TimelineMarker"); - RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this Action, for labeling poses"); + RNA_def_property_ui_text(prop, "Pose Markers", "Markers specific to this action, for labeling poses"); rna_def_action_pose_markers(brna, prop); /* properties */ @@ -639,8 +638,8 @@ static void rna_def_action(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "idroot"); RNA_def_property_enum_items(prop, id_type_items); RNA_def_property_ui_text(prop, "ID Root Type", - "Type of ID-block that action can be used on - " - "DO NOT CHANGE UNLESS YOU KNOW WHAT YOU'RE DOING"); + "Type of ID block that action can be used on - " + "DO NOT CHANGE UNLESS YOU KNOW WHAT YOU ARE DOING"); /* API calls */ RNA_api_action(srna); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index d50cb663b97..a68898112a0 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -369,7 +369,7 @@ static KS_Path *rna_KeyingSet_paths_add(KeyingSet *keyingset, ReportList *report keyingset->active_path = BLI_countlist(&keyingset->paths); } else { - BKE_report(reports, RPT_ERROR, "Keying Set Path could not be added"); + BKE_report(reports, RPT_ERROR, "Keying set path could not be added"); } /* return added path */ @@ -388,7 +388,7 @@ static void rna_KeyingSet_paths_remove(KeyingSet *keyingset, ReportList *reports keyingset->active_path = 0; } else { - BKE_report(reports, RPT_ERROR, "Keying Set Path could not be removed"); + BKE_report(reports, RPT_ERROR, "Keying set path could not be removed"); } } @@ -408,7 +408,7 @@ static void rna_KeyingSet_paths_clear(KeyingSet *keyingset, ReportList *reports) keyingset->active_path = 0; } else { - BKE_report(reports, RPT_ERROR, "Keying Set Paths could not be removed"); + BKE_report(reports, RPT_ERROR, "Keying set paths could not be removed"); } } @@ -448,7 +448,7 @@ static FCurve *rna_Driver_from_existing(AnimData *adt, bContext *C, FCurve *src_ { /* verify that we've got a driver to duplicate */ if (ELEM(NULL, src_driver, src_driver->driver)) { - BKE_reportf(CTX_wm_reports(C), RPT_ERROR, "No valid driver data to create copy of"); + BKE_report(CTX_wm_reports(C), RPT_ERROR, "No valid driver data to create copy of"); return NULL; } else { diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c index b93fd9daa36..492659fdc2e 100644 --- a/source/blender/makesrna/intern/rna_animation_api.c +++ b/source/blender/makesrna/intern/rna_animation_api.c @@ -56,11 +56,11 @@ static void rna_KeyingSet_context_refresh(KeyingSet *ks, bContext *C, ReportList if (success != 0) { switch (success) { case MODIFYKEY_INVALID_CONTEXT: - BKE_report(reports, RPT_ERROR, "Invalid context for Keying Set"); + BKE_report(reports, RPT_ERROR, "Invalid context for keying set"); break; case MODIFYKEY_MISSING_TYPEINFO: - BKE_report(reports, RPT_ERROR, "Incomplete built-in Keying Set, appears to be missing type info"); + BKE_report(reports, RPT_ERROR, "Incomplete built-in keying set, appears to be missing type info"); break; } } diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index fa43bf39319..4c188414cf8 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -564,7 +564,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) if (editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); else RNA_def_property_update(prop, 0, "rna_Armature_update_data"); RNA_def_property_float_sdna(prop, NULL, "rad_head"); - /* XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); */ + /* XXX range is 0 to lim, where lim = 10000.0f * MAX2(1.0, view3d->grid); */ /*RNA_def_property_range(prop, 0, 1000); */ RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Envelope Head Radius", "Radius of head of bone (for Envelope deform only)"); @@ -573,7 +573,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) if (editbone) RNA_def_property_update(prop, 0, "rna_Armature_editbone_transform_update"); else RNA_def_property_update(prop, 0, "rna_Armature_update_data"); RNA_def_property_float_sdna(prop, NULL, "rad_tail"); - /* XXX range is 0 to lim, where lim= 10000.0f*MAX2(1.0, view3d->grid); */ + /* XXX range is 0 to lim, where lim = 10000.0f * MAX2(1.0, view3d->grid); */ /*RNA_def_property_range(prop, 0, 1000); */ RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3); RNA_def_property_ui_text(prop, "Envelope Tail Radius", "Radius of tail of bone (for Envelope deform only)"); diff --git a/source/blender/makesrna/intern/rna_boid.c b/source/blender/makesrna/intern/rna_boid.c index 2a6ea2994fa..8e45da50e9b 100644 --- a/source/blender/makesrna/intern/rna_boid.c +++ b/source/blender/makesrna/intern/rna_boid.c @@ -436,7 +436,7 @@ static void rna_def_boidrule(BlenderRNA *brna) RNA_def_property_ui_text(prop, "On Land", "Use rule when boid is on land"); RNA_def_property_update(prop, 0, "rna_Boids_reset"); - /*prop= RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); */ + /*prop = RNA_def_property(srna, "show_expanded", PROP_BOOLEAN, PROP_NONE); */ /*RNA_def_property_boolean_sdna(prop, NULL, "mode", eModifierMode_Expanded); */ /*RNA_def_property_ui_text(prop, "Expanded", "Set modifier expanded in the user interface"); */ diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index ad926d6a08e..b72bba0422a 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -258,7 +258,7 @@ void RNA_def_camera(BlenderRNA *brna) prop = RNA_def_property(srna, "show_title_safe", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_SHOWTITLESAFE); - RNA_def_property_ui_text(prop, "Show Title Safe", "Show indicators for the title safe zone in Camera view"); + RNA_def_property_ui_text(prop, "Show Safe Areas", "Show TV title safe and action safe zones in Camera view"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "show_name", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_cloth.c b/source/blender/makesrna/intern/rna_cloth.c index 5f1ce4f2773..b9e86e116a2 100644 --- a/source/blender/makesrna/intern/rna_cloth.c +++ b/source/blender/makesrna/intern/rna_cloth.c @@ -419,41 +419,41 @@ static void rna_def_cloth_sim_settings(BlenderRNA *brna) /* unused still */ #if 0 - prop= RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "shear_stiffness", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "shear"); RNA_def_property_range(prop, 0.0f, 1000.0f); RNA_def_property_ui_text(prop, "Shear Stiffness", "Shear spring stiffness"); #endif /* unused still */ #if 0 - prop= RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "shear_stiffness_max", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "max_shear"); RNA_def_property_range(prop, 0.0f, upperLimitf); RNA_def_property_ui_text(prop, "Shear Stiffness Maximum", "Maximum shear scaling value"); #endif /* unused still */ #if 0 - prop= RNA_def_property(srna, "effector_force_scale", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "effector_force_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "eff_force_scale"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Effector Force Scale", ""); #endif /* unused still */ #if 0 - prop= RNA_def_property(srna, "effector_wind_scale", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "effector_wind_scale", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "eff_wind_scale"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Effector Wind Scale", ""); #endif /* unused still */ #if 0 - prop= RNA_def_property(srna, "tearing", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "tearing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", CLOTH_SIMSETTINGS_FLAG_TEARING); RNA_def_property_ui_text(prop, "Tearing", ""); #endif /* unused still */ #if 0 - prop= RNA_def_property(srna, "max_spring_extensions", PROP_INT, PROP_NONE); + prop = RNA_def_property(srna, "max_spring_extensions", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "maxspringlen"); RNA_def_property_range(prop, 1.0, 1000.0); RNA_def_property_ui_text(prop, "Maximum Spring Extension", "Maximum extension before spring gets cut"); diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 4de034b6407..f4afaf11d27 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -344,7 +344,7 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA * } } -void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4]) +static void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4]) { do_colorband(coba, position, color); } @@ -504,7 +504,9 @@ static void rna_ColorManagedColorspaceSettings_reload_update(Main *UNUSED(bmain) if (GS(id->name) == ID_IM) { Image *ima = (Image *) id; - BKE_image_signal(ima, NULL, IMA_SIGNAL_RELOAD); + DAG_id_tag_update(&ima->id, 0); + + BKE_image_signal(ima, NULL, IMA_SIGNAL_COLORMANAGE); WM_main_add_notifier(NC_IMAGE | ND_DISPLAY, &ima->id); WM_main_add_notifier(NC_IMAGE | NA_EDITED, &ima->id); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index f2454a2dcfb..7b6b629ca82 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -703,11 +703,6 @@ static void rna_def_constraint_kinematic(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Lock Z Rot", "Constraint rotation along Z axis"); RNA_def_property_update(prop, NC_OBJECT | ND_POSE, "rna_Constraint_dependency_update"); - prop = RNA_def_property(srna, "use_target", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CONSTRAINT_IK_AUTO); - RNA_def_property_ui_text(prop, "Target", "Disable for targetless IK"); - RNA_def_property_update(prop, NC_OBJECT | ND_CONSTRAINT, "rna_Constraint_dependency_update"); - prop = RNA_def_property(srna, "use_stretch", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CONSTRAINT_IK_STRETCH); RNA_def_property_ui_text(prop, "Stretch", "Enable IK Stretching"); @@ -2422,7 +2417,7 @@ void RNA_def_constraint(BlenderRNA *brna) RNA_def_property_float_sdna(prop, NULL, "rot_error"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Rot error", - "Amount of residual error in radiant for constraints that work on orientation"); + "Amount of residual error in radians for constraints that work on orientation"); /* pointers */ rna_def_constrainttarget(brna); diff --git a/source/blender/makesrna/intern/rna_controller.c b/source/blender/makesrna/intern/rna_controller.c index aef1f765fe2..c59e376da82 100644 --- a/source/blender/makesrna/intern/rna_controller.c +++ b/source/blender/makesrna/intern/rna_controller.c @@ -240,7 +240,7 @@ void RNA_def_controller(BlenderRNA *brna) /* State */ /* array of OB_MAX_STATES */ - /*prop= RNA_def_property(srna, "states", PROP_BOOLEAN, PROP_LAYER_MEMBER); */ + /*prop = RNA_def_property(srna, "states", PROP_BOOLEAN, PROP_LAYER_MEMBER); */ /*RNA_def_property_array(prop, OB_MAX_STATES); */ /*RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ /*RNA_def_property_ui_text(prop, "", "Set Controller state index (1 to 30)"); */ diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index ad05eff9568..354d7bae1ed 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -62,7 +62,7 @@ EnumPropertyItem keyframe_handle_type_items[] = { }; EnumPropertyItem beztriple_interpolation_mode_items[] = { - {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", "No interpolation. Value of A gets held until B is encountered"}, + {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", "No interpolation, value of A gets held until B is encountered"}, {BEZT_IPO_LIN, "LINEAR", 0, "Linear", "Straight-line interpolation between A and B (i.e. no ease in/out)"}, {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", "Smooth interpolation between A and B, with some control over curve shape"}, {0, NULL, 0, NULL, NULL} @@ -1109,7 +1109,7 @@ static void rna_def_charinfo(BlenderRNA *brna) /* probably there is no reason to expose this */ #if 0 - prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_WRAP); RNA_def_property_ui_text(prop, "Wrap", ""); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); */ @@ -1167,10 +1167,10 @@ static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); #if 0 - func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); + func = RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); RNA_def_function_ui_description(func, "Remove a spline from a curve"); RNA_def_function_flag(func, FUNC_USE_REPORTS); - parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); + parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove"); RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); #endif } diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index d4e0ba68d9d..ffeb221a847 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -42,6 +42,8 @@ #include "BLI_listbase.h" #include "BLI_ghash.h" +#include "BLF_translation.h" + #include "RNA_define.h" #include "rna_internal.h" @@ -898,7 +900,7 @@ void RNA_def_struct_translation_context(StructRNA *srna, const char *context) PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype) { - /*StructRNA *srna= DefRNA.laststruct;*/ /* invalid for python defined props */ + /*StructRNA *srna = DefRNA.laststruct;*/ /* invalid for python defined props */ ContainerRNA *cont = cont_; ContainerDefRNA *dcont; PropertyDefRNA *dprop = NULL; diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index daa661175a1..84ff53ee68f 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -699,7 +699,7 @@ void RNA_def_fluidsim(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Type", "Type of participation in the fluid simulation"); RNA_def_property_update(prop, 0, "rna_FluidSettings_update_type"); - /*prop= RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE); */ + /*prop = RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE); */ /*RNA_def_property_ui_text(prop, "IPO Curves", "IPO curves used by fluid simulation settings"); */ /* types */ diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c index b0fcfb9b540..55e7064390d 100644 --- a/source/blender/makesrna/intern/rna_gpencil.c +++ b/source/blender/makesrna/intern/rna_gpencil.c @@ -165,7 +165,7 @@ static bGPDstroke *rna_GPencil_stroke_new(bGPDframe *frame) static void rna_GPencil_stroke_remove(bGPDframe *frame, ReportList *reports, bGPDstroke *stroke) { if (BLI_findindex(&frame->strokes, stroke) == -1) { - BKE_reportf(reports, RPT_ERROR, "Stroke not found in grease pencil frame"); + BKE_report(reports, RPT_ERROR, "Stroke not found in grease pencil frame"); return; } @@ -179,7 +179,7 @@ static bGPDframe *rna_GPencil_frame_new(bGPDlayer *layer, ReportList *reports, i bGPDframe *frame; if (BKE_gpencil_layer_find_frame(layer, frame_number)) { - BKE_reportf(reports, RPT_ERROR, "Frame already exists on this frame number"); + BKE_reportf(reports, RPT_ERROR, "Frame already exists on this frame number %d", frame_number); return NULL; } @@ -193,7 +193,7 @@ static bGPDframe *rna_GPencil_frame_new(bGPDlayer *layer, ReportList *reports, i static void rna_GPencil_frame_remove(bGPDlayer *layer, ReportList *reports, bGPDframe *frame) { if (BLI_findindex(&layer->frames, frame) == -1) { - BKE_reportf(reports, RPT_ERROR, "Frame not found in grease pencil layer"); + BKE_report(reports, RPT_ERROR, "Frame not found in grease pencil layer"); return; } @@ -229,7 +229,7 @@ static bGPDlayer *rna_GPencil_layer_new(bGPdata *gpd, const char *name, int seta static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, bGPDlayer *layer) { if (BLI_findindex(&gpd->layers, layer) == -1) { - BKE_reportf(reports, RPT_ERROR, "Layer not found in grease pencil data"); + BKE_report(reports, RPT_ERROR, "Layer not found in grease pencil data"); return; } @@ -327,7 +327,7 @@ static void rna_def_gpencil_stroke(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "points", "totpoints"); RNA_def_property_struct_type(prop, "GPencilStrokePoint"); RNA_def_property_ui_text(prop, "Stroke Points", "Stroke data points"); - rna_def_gpencil_stroke_points_api(brna, prop); + rna_def_gpencil_stroke_points_api(brna, prop); prop = RNA_def_property(srna, "draw_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); @@ -376,7 +376,7 @@ static void rna_def_gpencil_frame(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "strokes", NULL); RNA_def_property_struct_type(prop, "GPencilStroke"); RNA_def_property_ui_text(prop, "Strokes", "Freehand curves defining the sketch on this frame"); - rna_def_gpencil_strokes_api(brna, prop); + rna_def_gpencil_strokes_api(brna, prop); /* Frame Number */ prop = RNA_def_property(srna, "frame_number", PROP_INT, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index a77e93f6a56..f8af2427827 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -150,7 +150,7 @@ static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA * static char *rna_ImageUser_path(PointerRNA *ptr) { if (ptr->id.data) { - /* ImageUser *iuser= ptr->data; */ + /* ImageUser *iuser = ptr->data; */ switch (GS(((ID *)ptr->id.data)->name)) { case ID_TE: @@ -366,7 +366,7 @@ static void rna_Image_pixels_set(PointerRNA *ptr, const float *values) ((unsigned char *)ibuf->rect)[i] = FTOCHAR(values[i]); } - ibuf->userflags |= IB_BITMAPDIRTY; + ibuf->userflags |= IB_BITMAPDIRTY | IB_DISPLAY_BUFFER_INVALID; } BKE_image_release_ibuf(ima, lock); @@ -388,23 +388,27 @@ static void rna_def_imageuser(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_ANIM_ALWAYS); RNA_def_property_ui_text(prop, "Auto Refresh", "Always refresh image on frame changes"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* animation */ prop = RNA_def_property(srna, "use_cyclic", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "cycl", 0); RNA_def_property_ui_text(prop, "Cyclic", "Cycle the images in the movie"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "frames"); RNA_def_property_range(prop, 0, MAXFRAMEF); RNA_def_property_ui_text(prop, "Frames", "Number of images of a movie to use"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "frame_offset", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "offset"); RNA_def_property_ui_text(prop, "Offset", "Offset the number of the frame to use in the animation"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "sfra"); @@ -412,12 +416,14 @@ static void rna_def_imageuser(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Start Frame", "Global starting frame of the movie/sequence, assuming first picture has a #1"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "fields_per_frame", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "fie_ima"); RNA_def_property_range(prop, 1, 200); RNA_def_property_ui_text(prop, "Fields per Frame", "Number of fields per rendered frame (2 fields is 1 image)"); RNA_def_property_update(prop, 0, "rna_ImageUser_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); prop = RNA_def_property(srna, "multilayer_layer", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "layer"); @@ -499,7 +505,8 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_FIELDS); RNA_def_property_ui_text(prop, "Fields", "Use fields of the image"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_fields_update"); - + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + prop = RNA_def_property(srna, "use_premultiply", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", IMA_DO_PREMUL); RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha"); @@ -528,23 +535,27 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_enum_items(prop, image_generated_type_items); RNA_def_property_ui_text(prop, "Generated Type", "Generated image type"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); - + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + prop = RNA_def_property(srna, "generated_width", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gen_x"); RNA_def_property_range(prop, 1, 16384); RNA_def_property_ui_text(prop, "Generated Width", "Generated image width"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); - + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + prop = RNA_def_property(srna, "generated_height", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gen_y"); RNA_def_property_range(prop, 1, 16384); RNA_def_property_ui_text(prop, "Generated Height", "Generated image height"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); - + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + prop = RNA_def_property(srna, "use_generated_float", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gen_flag", IMA_GEN_FLOAT); RNA_def_property_ui_text(prop, "Float Buffer", "Generate floating point buffer"); RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, "rna_Image_generated_update"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* realtime properties */ prop = RNA_def_property(srna, "mapping", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index d8ae579cd6b..cb5c515ce1f 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -80,7 +80,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock); if (ibuf == NULL) { - BKE_reportf(reports, RPT_ERROR, "Couldn't acquire buffer from image"); + BKE_report(reports, RPT_ERROR, "Could not acquire buffer from image"); } else { ImBuf *write_ibuf; @@ -92,7 +92,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports write_ibuf->dither = scene->r.dither_intensity; if (!BKE_imbuf_write(write_ibuf, path, &scene->r.im_format)) { - BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path); + BKE_reportf(reports, RPT_ERROR, "Could not write image '%s'", path); } if (write_ibuf != ibuf) @@ -102,7 +102,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports BKE_image_release_ibuf(image, lock); } else { - BKE_reportf(reports, RPT_ERROR, "Scene not in context, couldn't get save parameters"); + BKE_report(reports, RPT_ERROR, "Scene not in context, could not get save parameters"); } } @@ -116,7 +116,7 @@ static void rna_Image_save(Image *image, ReportList *reports) if (image->packedfile) { if (writePackedFile(reports, image->name, image->packedfile, 0) != RET_OK) { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" could saved packed file to \"%s\"", image->id.name + 2, image->name); + BKE_reportf(reports, RPT_ERROR, "Image '%s' could not save packed file to '%s'", image->id.name + 2, image->name); } } else if (IMB_saveiff(ibuf, filename, ibuf->flags)) { @@ -130,11 +130,11 @@ static void rna_Image_save(Image *image, ReportList *reports) ibuf->userflags &= ~IB_BITMAPDIRTY; } else { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" could not be saved to \"%s\"", image->id.name + 2, image->name); + BKE_reportf(reports, RPT_ERROR, "Image '%s' could not be saved to '%s'", image->id.name + 2, image->name); } } else { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); } } @@ -143,7 +143,7 @@ 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"); + BKE_report(reports, RPT_ERROR, "Cannot pack edited image from disk, only as internal PNG"); } else { if (as_png) { @@ -180,7 +180,7 @@ static void rna_Image_update(Image *image, ReportList *reports) ImBuf *ibuf = BKE_image_get_ibuf(image, NULL); if (ibuf == NULL) { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); return; } @@ -193,7 +193,7 @@ static void rna_Image_update(Image *image, ReportList *reports) static void rna_Image_scale(Image *image, ReportList *reports, int width, int height) { if (!BKE_image_scale(image, width, height)) { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); } } @@ -209,7 +209,7 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int ibuf = BKE_image_get_ibuf(image, NULL); if (ibuf == NULL || ibuf->rect == NULL) { - BKE_reportf(reports, RPT_ERROR, "Image \"%s\" does not have any image data", image->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Image '%s' does not have any image data", image->id.name + 2); return (int)GL_INVALID_OPERATION; } diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index e3ab7d25d79..fbb5dd569cc 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -409,19 +409,8 @@ int rna_IDMaterials_assign_int(struct PointerRNA *ptr, int key, const struct Poi /* Internal functions that cycles uses so we need to declare (tsk tsk) */ -struct Mesh *rna_Object_to_mesh(struct Object *ob, struct ReportList *reports, struct Scene *sce, int apply_modifiers, int settings); -void rna_Main_meshes_remove(struct Main *bmain, struct ReportList *reports, struct Mesh *mesh); -void rna_Object_create_duplilist(struct Object *ob, struct ReportList *reports, struct Scene *sce, int settings); -void rna_Object_free_duplilist(struct Object *ob); void rna_RenderLayer_rect_set(PointerRNA *ptr, const float *values); void rna_RenderPass_rect_set(PointerRNA *ptr, const float *values); -int rna_Object_is_modified(struct Object *ob, struct Scene *scene, int settings); -int rna_Object_is_deform_modified(struct Object *ob, struct Scene *scene, int settings); -void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4]); -void rna_Scene_frame_set(struct Scene *scene, int frame, float subframe); - -void engine_tag_redraw(struct RenderEngine *engine); -void engine_tag_update(struct RenderEngine *engine); #endif /* __RNA_INTERNAL_H__ */ diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index b77af6988ec..e38b64a09db 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -248,7 +248,7 @@ static Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name) id_us_min(&me->id); return me; } -void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) +static void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) { if (ID_REAL_USERS(mesh) <= 0) BKE_libblock_free(&bmain->mesh, mesh); @@ -573,7 +573,7 @@ static void rna_Main_grease_pencil_remove(Main *bmain, ReportList *reports, bGPd BKE_libblock_free(&bmain->gpencil, gpd); } else - BKE_reportf(reports, RPT_ERROR, "Grease Pencil '%s' must have zero users to be removed, found %d", + BKE_reportf(reports, RPT_ERROR, "Grease pencil '%s' must have zero users to be removed, found %d", gpd->id.name + 2, ID_REAL_USERS(gpd)); /* XXX python now has invalid pointer? */ diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index 97d9cc961ef..d7243dc519f 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -318,7 +318,7 @@ static MaskLayer *rna_Mask_layers_new(Mask *mask, const char *name) static void rna_Mask_layers_remove(Mask *mask, ReportList *reports, MaskLayer *masklay) { if (BLI_findindex(&mask->masklayers, masklay) == -1) { - BKE_reportf(reports, RPT_ERROR, "MaskLayer '%s' not found in mask '%s'", masklay->name, mask->id.name + 2); + BKE_reportf(reports, RPT_ERROR, "Mask layer '%s' not found in mask '%s'", masklay->name, mask->id.name + 2); return; } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index a2fbada3cc1..5e8dda7c065 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -81,12 +81,14 @@ EnumPropertyItem ramp_blend_items[] = { #include "MEM_guardedalloc.h" #include "DNA_node_types.h" +#include "DNA_object_types.h" #include "BKE_depsgraph.h" #include "BKE_main.h" #include "BKE_material.h" #include "BKE_texture.h" #include "BKE_node.h" +#include "BKE_paint.h" #include "ED_node.h" @@ -105,7 +107,18 @@ static void rna_Material_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *p } } -static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +static void rna_Material_update_previews(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Material *ma = ptr->id.data; + + if (ma->nodetree) + ntreeClearPreview(ma->nodetree); + + rna_Material_update(bmain, scene, ptr); +} + + +static void rna_Material_draw_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) { Material *ma = ptr->id.data; @@ -1755,7 +1768,7 @@ void RNA_def_material(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "pr_type"); RNA_def_property_enum_items(prop, preview_type_items); RNA_def_property_ui_text(prop, "Preview render type", "Type of preview render"); - RNA_def_property_update(prop, 0, "rna_Material_update"); + RNA_def_property_update(prop, 0, "rna_Material_update_previews"); prop = RNA_def_property(srna, "ambient", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "amb"); @@ -1824,9 +1837,9 @@ void RNA_def_material(BlenderRNA *brna) "from other scene lighting"); RNA_def_property_update(prop, 0, "rna_Material_update"); - prop= RNA_def_property(srna, "use_light_group_local", PROP_BOOLEAN, PROP_NONE); + prop = RNA_def_property(srna, "use_light_group_local", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_GROUP_LOCAL); - RNA_def_property_ui_text(prop, "Light Group Local", "When linked in, Material uses local light group with the same name"); + RNA_def_property_ui_text(prop, "Light Group Local", "When linked in, material uses local light group with the same name"); RNA_def_property_update(prop, 0, "rna_Material_update"); prop = RNA_def_property(srna, "use_raytrace", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 8a8bb2a2384..8eca7162d39 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -84,6 +84,7 @@ EnumPropertyItem modifier_type_items[] = { {eModifierType_Curve, "CURVE", ICON_MOD_CURVE, "Curve", ""}, {eModifierType_Displace, "DISPLACE", ICON_MOD_DISPLACE, "Displace", ""}, {eModifierType_Hook, "HOOK", ICON_HOOK, "Hook", ""}, + {eModifierType_LaplacianSmooth, "LAPLACIANSMOOTH", ICON_MOD_SMOOTH, "Laplacian Smooth", ""}, {eModifierType_Lattice, "LATTICE", ICON_MOD_LATTICE, "Lattice", ""}, {eModifierType_MeshDeform, "MESH_DEFORM", ICON_MOD_MESHDEFORM, "Mesh Deform", ""}, {eModifierType_Shrinkwrap, "SHRINKWRAP", ICON_MOD_SHRINKWRAP, "Shrinkwrap", ""}, @@ -210,6 +211,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr) return &RNA_RemeshModifier; case eModifierType_Skin: return &RNA_SkinModifier; + case eModifierType_LaplacianSmooth: + return &RNA_LaplacianSmoothModifier; default: return &RNA_Modifier; } @@ -359,6 +362,12 @@ static void rna_SmoothModifier_vgroup_set(PointerRNA *ptr, const char *value) rna_object_vgroup_name_set(ptr, value, lmd->defgrp_name, sizeof(lmd->defgrp_name)); } +static void rna_LaplacianSmoothModifier_vgroup_set(PointerRNA *ptr, const char *value) +{ + LaplacianSmoothModifierData *lmd = (LaplacianSmoothModifierData *)ptr->data; + rna_object_vgroup_name_set(ptr, value, lmd->defgrp_name, sizeof(lmd->defgrp_name)); +} + static void rna_WaveModifier_vgroup_set(PointerRNA *ptr, const char *value) { WaveModifierData *lmd = (WaveModifierData *)ptr->data; @@ -377,6 +386,12 @@ static void rna_SolidifyModifier_vgroup_set(PointerRNA *ptr, const char *value) rna_object_vgroup_name_set(ptr, value, smd->defgrp_name, sizeof(smd->defgrp_name)); } +static void rna_DecimateModifier_vgroup_set(PointerRNA *ptr, const char *value) +{ + DecimateModifierData *dmd = (DecimateModifierData *)ptr->data; + rna_object_vgroup_name_set(ptr, value, dmd->defgrp_name, sizeof(dmd->defgrp_name)); +} + static void rna_WeightVGModifier_vgroup_set(PointerRNA *ptr, const char *value) { ModifierData *md = (ModifierData *)ptr->data; @@ -1104,6 +1119,13 @@ static void rna_def_modifier_mirror(BlenderRNA *brna) static void rna_def_modifier_decimate(BlenderRNA *brna) { + static EnumPropertyItem modifier_decim_mode_items[] = { + {MOD_DECIM_MODE_COLLAPSE, "COLLAPSE", 0, "Collapse", "Use edge collapsing"}, + {MOD_DECIM_MODE_UNSUBDIV, "UNSUBDIV", 0, "Un-Subdivide", "Use un-subdivide face reduction"}, + {MOD_DECIM_MODE_DISSOLVE, "DISSOLVE", 0, "Planar", "Dissolve geometry to form planar polygons"}, + {0, NULL, 0, NULL, NULL} + }; + StructRNA *srna; PropertyRNA *prop; @@ -1112,15 +1134,65 @@ static void rna_def_modifier_decimate(BlenderRNA *brna) RNA_def_struct_sdna(srna, "DecimateModifierData"); RNA_def_struct_ui_icon(srna, ICON_MOD_DECIM); + prop = RNA_def_property(srna, "decimate_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "mode"); + RNA_def_property_enum_items(prop, modifier_decim_mode_items); + RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* (mode == MOD_DECIM_MODE_COLLAPSE) */ prop = RNA_def_property(srna, "ratio", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "percent"); RNA_def_property_range(prop, 0, 1); - RNA_def_property_ui_range(prop, 0, 1, 1, 2); - RNA_def_property_ui_text(prop, "Ratio", "Ratio of triangles to reduce to"); + RNA_def_property_ui_range(prop, 0, 1, 1, 4); + RNA_def_property_ui_text(prop, "Ratio", "Ratio of triangles to reduce to (collapse only)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* (mode == MOD_DECIM_MODE_UNSUBDIV) */ + prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "iter"); + RNA_def_property_range(prop, 0, SHRT_MAX); + RNA_def_property_ui_range(prop, 0, 100, 1, 0); + RNA_def_property_ui_text(prop, "Iterations", "Number of times reduce the geometry (unsubdivide only)"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + /* (mode == MOD_DECIM_MODE_DISSOLVE) */ + prop = RNA_def_property(srna, "angle_limit", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_float_sdna(prop, NULL, "angle"); + RNA_def_property_range(prop, 0, DEG2RAD(180)); + RNA_def_property_ui_range(prop, 0, DEG2RAD(180), 100, 2); + RNA_def_property_ui_text(prop, "Angle Limit", "Only dissolve angles below this (planar only)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + /* (mode == MOD_DECIM_MODE_COLLAPSE) */ + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); + RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name (collapse only)"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_DecimateModifier_vgroup_set"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "invert_vertex_group", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_INVERT_VGROUP); + RNA_def_property_ui_text(prop, "Invert", "Invert vertex group influence (collapse only)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "use_collapse_triangulate", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_TRIANGULATE); + RNA_def_property_ui_text(prop, "Triangulate", "Keep triangulated faces resulting from decimation (collapse only)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + /* end collapse-only option */ + + /* (mode == MOD_DECIM_MODE_DISSOLVE) */ + prop = RNA_def_property(srna, "use_dissolve_boundaries", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_DECIM_FLAG_ALL_BOUNDARY_VERTS); + RNA_def_property_ui_text(prop, "All Boundaries", "Dissolve all vertices inbetween face boundaries (planar only)"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + /* end dissolve-only option */ + + + + /* all modes use this */ prop = RNA_def_property(srna, "face_count", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "faceCount"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Face Count", "The current number of faces in the decimated mesh"); } @@ -1717,6 +1789,64 @@ static void rna_def_modifier_smooth(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); } +static void rna_def_modifier_laplaciansmooth(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "LaplacianSmoothModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "Laplacian Smooth Modifier", "Smoothing effect modifier"); + RNA_def_struct_sdna(srna, "LaplacianSmoothModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_SMOOTH); + + prop = RNA_def_property(srna, "use_x", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_X); + RNA_def_property_ui_text(prop, "X", "Smooth object along X axis"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "use_y", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_Y); + RNA_def_property_ui_text(prop, "Y", "Smooth object along Y axis"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "use_z", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_Z); + RNA_def_property_ui_text(prop, "Z", "Smooth object along Z axis"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "use_volume_preserve", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION); + RNA_def_property_ui_text(prop, "Preserve Volume", "Apply volume preservation after smooth"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "lambda_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "lambda"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0000001, 1000.0, 0.0000001, 8); + RNA_def_property_ui_text(prop, "Lambda Factor", "Smooth factor effect"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "lambda_border", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "lambda_border"); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0000001, 1000.0, 0.0000001, 8); + RNA_def_property_ui_text(prop, "Lambda Border", "Lambda factor in border"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "iterations", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "repeat"); + RNA_def_property_ui_range(prop, 0, 200, 1, 0); + RNA_def_property_ui_text(prop, "Repeat", ""); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); + RNA_def_property_ui_text(prop, "Vertex Group", + "Name of Vertex Group which determines influence of modifier per point"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_LaplacianSmoothModifier_vgroup_set"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); +} + static void rna_def_modifier_cast(BlenderRNA *brna) { StructRNA *srna; @@ -3331,6 +3461,7 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_ocean(brna); rna_def_modifier_remesh(brna); rna_def_modifier_skin(brna); + rna_def_modifier_laplaciansmooth(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 0d7d20d04ae..241ee8f9c9b 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -71,12 +71,12 @@ EnumPropertyItem node_quality_items[] = { }; EnumPropertyItem node_chunksize_items[] = { - {NTREE_CHUNCKSIZE_32, "32", 0, "32x32", "Chunksize of 32x32"}, - {NTREE_CHUNCKSIZE_64, "64", 0, "64x64", "Chunksize of 64x64"}, - {NTREE_CHUNCKSIZE_128, "128", 0, "128x128", "Chunksize of 128x128"}, - {NTREE_CHUNCKSIZE_256, "256", 0, "256x256", "Chunksize of 256x256"}, - {NTREE_CHUNCKSIZE_512, "512", 0, "512x512", "Chunksize of 512x512"}, - {NTREE_CHUNCKSIZE_1024, "1024", 0, "1024x1024", "Chunksize of 1024x1024"}, + {NTREE_CHUNCKSIZE_32, "32", 0, "32x32", "Chunksize of 32x32"}, + {NTREE_CHUNCKSIZE_64, "64", 0, "64x64", "Chunksize of 64x64"}, + {NTREE_CHUNCKSIZE_128, "128", 0, "128x128", "Chunksize of 128x128"}, + {NTREE_CHUNCKSIZE_256, "256", 0, "256x256", "Chunksize of 256x256"}, + {NTREE_CHUNCKSIZE_512, "512", 0, "512x512", "Chunksize of 512x512"}, + {NTREE_CHUNCKSIZE_1024, "1024", 0, "1024x1024", "Chunksize of 1024x1024"}, {0, NULL, 0, NULL, NULL} }; @@ -226,10 +226,6 @@ static StructRNA *rna_Node_refine(struct PointerRNA *ptr) case NODE_GROUP: return &RNA_NodeGroup; - case NODE_FORLOOP: - return &RNA_NodeForLoop; - case NODE_WHILELOOP: - return &RNA_NodeWhileLoop; case NODE_FRAME: return &RNA_NodeFrame; case NODE_REROUTE: @@ -1042,7 +1038,6 @@ static EnumPropertyItem node_glossy_items[] = { enum { Category_GroupNode, - Category_LoopNode, Category_LayoutNode, Category_ShaderNode, Category_CompositorNode, @@ -1086,8 +1081,6 @@ static void init(void) #include "rna_nodetree_types.h" reg_node(NODE_GROUP, Category_GroupNode, "GROUP", "NodeGroup", "SpecialNode", "Group", ""); - reg_node(NODE_FORLOOP, Category_LoopNode, "FORLOOP", "NodeForLoop", "SpecialNode", "ForLoop", ""); - reg_node(NODE_WHILELOOP, Category_LoopNode, "WHILELOOP", "NodeWhileLoop", "SpecialNode", "WhileLoop", ""); reg_node(NODE_FRAME, Category_LayoutNode, "FRAME", "NodeFrame", "SpecialNode", "Frame", ""); reg_node(NODE_REROUTE, Category_LayoutNode, "REROUTE", "NodeReroute", "SpecialNode", "Reroute", ""); } @@ -1166,36 +1159,6 @@ static void def_group(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update"); } -static void def_forloop(StructRNA *srna) -{ - PropertyRNA *prop; - - prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "id"); - RNA_def_property_struct_type(prop, "NodeTree"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Node Tree", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update"); -} - -static void def_whileloop(StructRNA *srna) -{ - PropertyRNA *prop; - - prop = RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "id"); - RNA_def_property_struct_type(prop, "NodeTree"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Node Tree", ""); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update"); - - prop = RNA_def_property(srna, "max_iterations", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "custom1"); - RNA_def_property_range(prop, 0.0f, SHRT_MAX); - RNA_def_property_ui_text(prop, "Max. Iterations", "Limit for number of iterations"); - RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_NodeGroup_update"); -} - static void def_frame(StructRNA *srna) { PropertyRNA *prop; @@ -3995,8 +3958,6 @@ static void rna_def_special_node(BlenderRNA *brna) static EnumPropertyItem specific_node_type_items[] = { {NODE_GROUP, "GROUP", ICON_NODE, "Group", ""}, - {NODE_FORLOOP, "FORLOOP", ICON_NODE, "For Loop", ""}, - {NODE_WHILELOOP, "WHILELOOP", ICON_NODE, "While Loop", ""}, {NODE_FRAME, "FRAME", ICON_NODE, "Frame", ""}, {NODE_REROUTE, "REROUTE", ICON_NODE, "Reroute", ""}, {0, NULL, 0, NULL, NULL} @@ -4619,8 +4580,6 @@ void RNA_def_nodetree(BlenderRNA *brna) #include "rna_nodetree_types.h" define_specific_node(brna, NODE_GROUP, def_group); - define_specific_node(brna, NODE_FORLOOP, def_forloop); - define_specific_node(brna, NODE_WHILELOOP, def_whileloop); define_specific_node(brna, NODE_FRAME, def_frame); define_specific_node(brna, NODE_REROUTE, 0); diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 0b8afef0364..0c1ec0b02f9 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -506,7 +506,7 @@ static void rna_Object_dup_group_set(PointerRNA *ptr, PointerRNA value) ob->dup_group = grp; else BKE_report(NULL, RPT_ERROR, - "Cannot set dupli-group as object belongs in group being instanced thus causing a cycle"); + "Cannot set dupli-group as object belongs in group being instanced, thus causing a cycle"); } static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value) @@ -1284,7 +1284,7 @@ static void rna_VertexGroup_vertex_add(ID *id, bDeformGroup *def, ReportList *re Object *ob = (Object *)id; if (ED_vgroup_object_is_edit_mode(ob)) { - BKE_reportf(reports, RPT_ERROR, "VertexGroup.add(): Can't be called while object is in edit mode"); + BKE_report(reports, RPT_ERROR, "VertexGroup.add(): cannot be called while object is in edit mode"); return; } @@ -1299,7 +1299,7 @@ static void rna_VertexGroup_vertex_remove(ID *id, bDeformGroup *dg, ReportList * Object *ob = (Object *)id; if (ED_vgroup_object_is_edit_mode(ob)) { - BKE_reportf(reports, RPT_ERROR, "VertexGroup.remove(): Can't be called while object is in edit mode"); + BKE_report(reports, RPT_ERROR, "VertexGroup.remove(): cannot be called while object is in edit mode"); return; } @@ -1314,7 +1314,7 @@ static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *report float weight = ED_vgroup_vert_weight((Object *)id, dg, index); if (weight < 0) { - BKE_reportf(reports, RPT_ERROR, "Vertex not in group"); + BKE_report(reports, RPT_ERROR, "Vertex not in group"); } return weight; } diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 3204dc8e6bc..d1640a51ded 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -74,7 +74,7 @@ /* copied from Mesh_getFromObject and adapted to RNA interface */ /* settings: 0 - preview, 1 - render */ -Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_modifiers, int settings) +static Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_modifiers, int settings) { Mesh *tmpmesh; Curve *tmpcu = NULL, *copycu; @@ -321,7 +321,7 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e } } - if (level == 0 && enable) { + if (enable) { /* this is to make sure we get render level duplis in groups: * the derivedmesh must be created before init_render_mesh, * since object_duplilist does dupliparticles before that */ @@ -340,7 +340,7 @@ static void dupli_render_particle_set(Scene *scene, Object *ob, int level, int e dupli_render_particle_set(scene, go->ob, level + 1, enable); } /* When no longer needed, duplilist should be freed with Object.free_duplilist */ -void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, int settings) +static void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, int settings) { int for_render = settings == eModifierMode_Render; @@ -364,7 +364,7 @@ void rna_Object_create_duplilist(Object *ob, ReportList *reports, Scene *sce, in /* ob->duplilist should now be freed with Object.free_duplilist */ } -void rna_Object_free_duplilist(Object *ob) +static void rna_Object_free_duplilist(Object *ob) { if (ob->duplilist) { free_object_duplilist(ob->duplilist); @@ -522,12 +522,12 @@ static void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d) base->lay = base->object->lay = v3d->lay; } -int rna_Object_is_modified(Object *ob, Scene *scene, int settings) +static int rna_Object_is_modified(Object *ob, Scene *scene, int settings) { return BKE_object_is_modified(scene, ob) & settings; } -int rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings) +static int rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings) { return BKE_object_is_deform_modified(scene, ob) & settings; } diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 940d59ec9b3..f47b864d25a 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -820,10 +820,13 @@ static void rna_def_pointcache(BlenderRNA *brna) RNA_def_property_ui_text(prop, "File Path", "Cache file path"); RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + /* removed, see PTCACHE_QUICK_CACHE */ +#if 0 prop = RNA_def_property(srna, "use_quick_cache", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_QUICK_CACHE); RNA_def_property_ui_text(prop, "Quick Cache", "Update simulation with cache steps"); RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change"); +#endif prop = RNA_def_property(srna, "info", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "info"); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 89638389fd2..9ba2a062791 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -823,12 +823,12 @@ static void psys_vg_name_set__internal(PointerRNA *ptr, const char *value, int i psys->vgroup[index] = 0; } else { - int vgroup_num = defgroup_name_index(ob, value); + int defgrp_index = defgroup_name_index(ob, value); - if (vgroup_num == -1) + if (defgrp_index == -1) return; - psys->vgroup[index] = vgroup_num + 1; + psys->vgroup[index] = defgrp_index + 1; } } diff --git a/source/blender/makesrna/intern/rna_render.c b/source/blender/makesrna/intern/rna_render.c index 736753894d1..4b4018433b3 100644 --- a/source/blender/makesrna/intern/rna_render.c +++ b/source/blender/makesrna/intern/rna_render.c @@ -50,12 +50,12 @@ /* RenderEngine Callbacks */ -void engine_tag_redraw(RenderEngine *engine) +static void engine_tag_redraw(RenderEngine *engine) { engine->flag |= RE_ENGINE_DO_DRAW; } -void engine_tag_update(RenderEngine *engine) +static void engine_tag_update(RenderEngine *engine) { engine->flag |= RE_ENGINE_DO_UPDATE; } diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index db309ed8f1f..7355e464fc3 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -829,7 +829,7 @@ static void rna_EnumProperty_items_begin(CollectionPropertyIterator *iter, Point int totitem, free = 0; rna_idproperty_check(&prop, ptr); - /* eprop= (EnumPropertyRNA *)prop; */ + /* eprop = (EnumPropertyRNA *)prop; */ RNA_property_enum_items(NULL, ptr, prop, &item, &totitem, &free); rna_iterator_array_begin(iter, (void *)item, sizeof(EnumPropertyItem), totitem, free, rna_enum_check_separator); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index e13a973334b..b71aa507591 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -277,6 +277,7 @@ EnumPropertyItem image_color_mode_items[] = { EnumPropertyItem image_color_depth_items[] = { /* 1 (monochrome) not used */ {R_IMF_CHAN_DEPTH_8, "8", 0, "8", "8 bit color channels"}, + {R_IMF_CHAN_DEPTH_10, "10", 0, "10", "10 bit color channels"}, {R_IMF_CHAN_DEPTH_12, "12", 0, "12", "12 bit color channels"}, {R_IMF_CHAN_DEPTH_16, "16", 0, "16", "16 bit color channels"}, /* 24 not used */ @@ -717,6 +718,7 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) R_IMF_CHAN_DEPTH_24, R_IMF_CHAN_DEPTH_16, R_IMF_CHAN_DEPTH_12, + R_IMF_CHAN_DEPTH_10, R_IMF_CHAN_DEPTH_8, R_IMF_CHAN_DEPTH_1, 0}; @@ -814,9 +816,10 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_depth_itemf(bContext *C, const int is_float = ELEM3(imf->imtype, R_IMF_IMTYPE_RADHDR, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER); EnumPropertyItem *item_8bit = &image_color_depth_items[0]; - EnumPropertyItem *item_12bit = &image_color_depth_items[1]; - EnumPropertyItem *item_16bit = &image_color_depth_items[2]; - EnumPropertyItem *item_32bit = &image_color_depth_items[3]; + EnumPropertyItem *item_10bit = &image_color_depth_items[1]; + EnumPropertyItem *item_12bit = &image_color_depth_items[2]; + EnumPropertyItem *item_16bit = &image_color_depth_items[3]; + EnumPropertyItem *item_32bit = &image_color_depth_items[4]; int totitem = 0; EnumPropertyItem *item = NULL; @@ -826,6 +829,10 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_depth_itemf(bContext *C, RNA_enum_item_add(&item, &totitem, item_8bit); } + if (depth_ok & R_IMF_CHAN_DEPTH_10) { + RNA_enum_item_add(&item, &totitem, item_10bit); + } + if (depth_ok & R_IMF_CHAN_DEPTH_12) { RNA_enum_item_add(&item, &totitem, item_12bit); } @@ -1034,7 +1041,7 @@ static void rna_RenderLayer_remove(ID *id, RenderData *UNUSED(rd), Main *bmain, Scene *scene = (Scene *)id; if (!BKE_scene_remove_render_layer(bmain, scene, srl)) { - BKE_reportf(reports, RPT_ERROR, "RenderLayer '%s' could not be removed from scene '%s'", + BKE_reportf(reports, RPT_ERROR, "Render layer '%s' could not be removed from scene '%s'", srl->name, scene->id.name + 2); } else { @@ -1212,9 +1219,12 @@ static void object_simplify_update(Object *ob) ModifierData *md; ParticleSystem *psys; - for (md = ob->modifiers.first; md; md = md->next) - if (ELEM3(md->type, eModifierType_Subsurf, eModifierType_Multires, eModifierType_ParticleSystem)) - ob->recalc |= OB_RECALC_DATA | PSYS_RECALC_CHILD; + for (md = ob->modifiers.first; md; md = md->next) { + if (ELEM3(md->type, eModifierType_Subsurf, eModifierType_Multires, eModifierType_ParticleSystem)) { + ob->recalc |= PSYS_RECALC_CHILD; + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + } + } for (psys = ob->particlesystem.first; psys; psys = psys->next) psys->recalc |= PSYS_RECALC_CHILD; @@ -1407,6 +1417,12 @@ static void rna_SceneCamera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Po DAG_id_tag_update(&camera->id, 0); } +static void rna_SceneSequencer_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ + BKE_sequencer_cache_cleanup(); + BKE_sequencer_preprocessed_cache_cleanup(); +} + static PointerRNA rna_FreestyleLineSet_linestyle_get(PointerRNA *ptr) { FreestyleLineSet *lineset= (FreestyleLineSet *)ptr->data; @@ -3325,7 +3341,6 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) #endif - #ifdef WITH_OPENJPEG /* Jpeg 2000 */ prop = RNA_def_property(srna, "use_jpeg2k_ycc", PROP_BOOLEAN, PROP_NONE); @@ -3347,7 +3362,7 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) /* Cineon and DPX */ prop = RNA_def_property(srna, "use_cineon_log", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "cineon_flag", R_CINEON_LOG); + RNA_def_property_boolean_sdna(prop, NULL, "cineon_flag", R_IMF_CINEON_FLAG_LOG); RNA_def_property_ui_text(prop, "Log", "Convert to logarithmic color space"); RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); @@ -4377,15 +4392,17 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_GL_PREV); RNA_def_property_ui_text(prop, "Sequencer OpenGL", ""); +#if 0 /* see R_SEQ_GL_REND comment */ prop = RNA_def_property(srna, "use_sequencer_gl_render", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "seq_flag", R_SEQ_GL_REND); RNA_def_property_ui_text(prop, "Sequencer OpenGL", ""); - +#endif prop = RNA_def_property(srna, "sequencer_gl_preview", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "seq_prev_type"); RNA_def_property_enum_items(prop, viewport_shade_items); RNA_def_property_ui_text(prop, "Sequencer Preview Shading", "Method to draw in the sequencer view"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_SceneSequencer_update"); prop = RNA_def_property(srna, "sequencer_gl_render", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "seq_rend_type"); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index cdf7ac5e68f..10efc7a94a7 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -53,7 +53,7 @@ -void rna_Scene_frame_set(Scene *scene, int frame, float subframe) +static void rna_Scene_frame_set(Scene *scene, int frame, float subframe) { scene->r.cfra = frame; scene->r.subframe = subframe; diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 58d676555c1..84e76fae896 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -60,6 +60,8 @@ static EnumPropertyItem particle_edit_hair_brush_items[] = { #include "BKE_particle.h" #include "BKE_depsgraph.h" +#include "BLI_pbvh.h" + #include "ED_particle.h" static EnumPropertyItem particle_edit_disconnected_hair_brush_items[] = { @@ -206,6 +208,21 @@ static void rna_Sculpt_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNU } } +static void rna_Sculpt_ShowDiffuseColor_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +{ + Object *ob = (scene->basact) ? scene->basact->object : NULL; + + if (ob) { + Sculpt *sd = scene->toolsettings->sculpt; + ob->sculpt->show_diffuse_color = sd->flags & SCULPT_SHOW_DIFFUSE; + + if (ob->sculpt->pbvh) + pbvh_show_diffuse_color_set(ob->sculpt->pbvh, ob->sculpt->show_diffuse_color); + + WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); + } +} + #else static void rna_def_paint(BlenderRNA *brna) @@ -297,6 +314,12 @@ static void rna_def_sculpt(BlenderRNA *brna) "Use only deformation modifiers (temporary disable all " "constructive modifiers except multi-resolution)"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update"); + + prop = RNA_def_property(srna, "show_diffuse_color", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", SCULPT_SHOW_DIFFUSE); + RNA_def_property_ui_text(prop, "Show Diffuse Color", + "Show diffuse color of object and overlay sculpt mask on top of it"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowDiffuseColor_update"); } diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 067589ca543..c5a0408c7a0 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -341,7 +341,7 @@ static void rna_SequenceElements_pop(ID *id, Sequence *seq, ReportList *reports, StripElem *new_seq, *se; if (seq->len == 1) { - BKE_report(reports, RPT_ERROR, "SequenceElements.pop: can not pop the last element"); + BKE_report(reports, RPT_ERROR, "SequenceElements.pop: cannot pop the last element"); return; } diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index faad2407516..bdcda79583e 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -368,7 +368,7 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "burning_rate", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01, 4.0); RNA_def_property_ui_range(prop, 0.01, 2.0, 1.0, 5); - RNA_def_property_ui_text(prop, "Speed", "Speed of the burning reaction. Use larger values for smaller flame"); + RNA_def_property_ui_text(prop, "Speed", "Speed of the burning reaction (use larger values for smaller flame)"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); prop = RNA_def_property(srna, "flame_smoke", PROP_FLOAT, PROP_NONE); @@ -423,7 +423,8 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) prop = RNA_def_property(srna, "adapt_threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.01, 0.5); RNA_def_property_ui_range(prop, 0.01, 0.5, 1.0, 5); - RNA_def_property_ui_text(prop, "Threshold", "Maximum amount of fluid cell can contain before it's considered empty"); + RNA_def_property_ui_text(prop, "Threshold", + "Maximum amount of fluid cell can contain before it is considered empty"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); } @@ -550,7 +551,7 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna) "rna_SmokeFlow_density_vgroup_length", "rna_SmokeFlow_density_vgroup_set"); RNA_def_property_ui_text(prop, "Vertex Group", - "Name of Vertex Group which determines surface emission rate"); + "Name of vertex group which determines surface emission rate"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); prop = RNA_def_property(srna, "use_texture", PROP_BOOLEAN, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index e670adb1e87..ecb2bf71cb2 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -961,7 +961,7 @@ static BGpic *rna_BackgroundImage_new(View3D *v3d) static void rna_BackgroundImage_remove(View3D *v3d, ReportList *reports, BGpic *bgpic) { if (BLI_findindex(&v3d->bgpicbase, bgpic) == -1) { - BKE_report(reports, RPT_ERROR, "BackgroundImage can't be removed"); + BKE_report(reports, RPT_ERROR, "Background image cannot be removed"); } else { ED_view3D_background_image_remove(v3d, bgpic); @@ -1509,7 +1509,7 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_RENDER_BORDER); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Render Border", - "use a user-defined border region within the frame size for rendered viewport"); + "Use a user-defined border region within the frame size for rendered viewport"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "render_border_min_x", PROP_FLOAT, PROP_NONE); @@ -1574,7 +1574,7 @@ static void rna_def_space_view3d(BlenderRNA *brna) prop = RNA_def_property(srna, "lens", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "lens"); - RNA_def_property_ui_text(prop, "Lens", "Lens angle (mm) in perspective view"); + RNA_def_property_ui_text(prop, "Lens", "Viewport lens angle (mm)"); RNA_def_property_range(prop, 1.0f, 250.0f); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); @@ -2827,6 +2827,12 @@ static void rna_def_fileselect_params(BlenderRNA *brna) RNA_def_property_ui_icon(prop, ICON_FILE_BLEND, 0); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); + prop = RNA_def_property(srna, "use_filter_backup", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "filter", BLENDERFILE_BACKUP); + RNA_def_property_ui_text(prop, "Filter BlenderBackup files", "Show .blend1, .blend2, etc. files"); + RNA_def_property_ui_icon(prop, ICON_FILE_BACKUP, 0); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); + prop = RNA_def_property(srna, "use_filter_movie", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "filter", MOVIEFILE); RNA_def_property_ui_text(prop, "Filter Movies", "Show movie files"); diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 7bfa7ccc3c2..a0a9f6183af 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -192,7 +192,7 @@ static StructRNA *rna_Panel_register(Main *bmain, ReportList *reports, void *dat return NULL; if (strlen(identifier) >= sizeof(dummypt.idname)) { - BKE_reportf(reports, RPT_ERROR, "registering panel class: '%s' is too long, maximum length is %d", + BKE_reportf(reports, RPT_ERROR, "Registering panel class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(dummypt.idname)); return NULL; } @@ -309,7 +309,7 @@ static StructRNA *rna_Header_register(Main *bmain, ReportList *reports, void *da return NULL; if (strlen(identifier) >= sizeof(dummyht.idname)) { - BKE_reportf(reports, RPT_ERROR, "registering header class: '%s' is too long, maximum length is %d", + BKE_reportf(reports, RPT_ERROR, "Registering header class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(dummyht.idname)); return NULL; } @@ -438,7 +438,7 @@ static StructRNA *rna_Menu_register(Main *bmain, ReportList *reports, void *data return NULL; if (strlen(identifier) >= sizeof(dummymt.idname)) { - BKE_reportf(reports, RPT_ERROR, "registering menu class: '%s' is too long, maximum length is %d", + BKE_reportf(reports, RPT_ERROR, "Registering menu class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(dummymt.idname)); return NULL; } diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 2e1c62cce53..2a8f1b90d4e 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -236,41 +236,41 @@ void RNA_api_ui_layout(StructRNA *srna) /* useful in C but not in python */ #if 0 - func= RNA_def_function(srna, "operator_enum_single", "uiItemEnumO_string"); + func = RNA_def_function(srna, "operator_enum_single", "uiItemEnumO_string"); api_ui_item_op_common(func); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); + parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_string(func, "value", "", 0, "", "Enum property value"); + parm = RNA_def_string(func, "value", "", 0, "", "Enum property value"); RNA_def_property_flag(parm, PROP_REQUIRED); - func= RNA_def_function(srna, "operator_boolean", "uiItemBooleanO"); + func = RNA_def_function(srna, "operator_boolean", "uiItemBooleanO"); api_ui_item_op_common(func); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); + parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_boolean(func, "value", 0, "", "Value of the property to call the operator with"); + parm = RNA_def_boolean(func, "value", 0, "", "Value of the property to call the operator with"); RNA_def_property_flag(parm, PROP_REQUIRED); */ - func= RNA_def_function(srna, "operator_int", "uiItemIntO"); + func = RNA_def_function(srna, "operator_int", "uiItemIntO"); api_ui_item_op_common(func); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); + parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "", + parm = RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "", "Value of the property to call the operator with", INT_MIN, INT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); */ - func= RNA_def_function(srna, "operator_float", "uiItemFloatO"); + func = RNA_def_function(srna, "operator_float", "uiItemFloatO"); api_ui_item_op_common(func); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); + parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "", + parm = RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "", "Value of the property to call the operator with", -FLT_MAX, FLT_MAX); RNA_def_property_flag(parm, PROP_REQUIRED); */ - func= RNA_def_function(srna, "operator_string", "uiItemStringO"); + func = RNA_def_function(srna, "operator_string", "uiItemStringO"); api_ui_item_op_common(func); - parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); + parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator"); RNA_def_property_flag(parm, PROP_REQUIRED); - parm= RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with"); + parm = RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with"); RNA_def_property_flag(parm, PROP_REQUIRED); #endif diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 307e2ff4f82..fc30c02341a 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -410,6 +410,15 @@ static EnumPropertyItem *rna_userdef_compute_device_itemf(bContext *UNUSED(C), P } #endif +#ifdef WITH_INTERNATIONAL +static EnumPropertyItem *rna_lang_enum_properties_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), + PropertyRNA *UNUSED(prop), int *free) +{ + *free = 0; /* These items are handled by BLF code! */ + return BLF_RNA_lang_enum_properties(); +} +#endif + #else static void rna_def_userdef_theme_ui_font_style(BlenderRNA *brna) @@ -481,7 +490,7 @@ static void rna_def_userdef_theme_ui_style(BlenderRNA *brna) /* (not used yet) */ #if 0 - prop= RNA_def_property(srna, "panelzoom", PROP_FLOAT, PROP_NONE); + prop = RNA_def_property(srna, "panelzoom", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.5, 2.0); RNA_def_property_ui_text(prop, "Panel Zoom", "Default zoom level for panel areas"); #endif @@ -2759,7 +2768,7 @@ static void rna_def_userdef_edit(BlenderRNA *brna) prop = RNA_def_property(srna, "use_auto_keying_warning", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "autokey_flag", AUTOKEY_FLAG_NOWARNING); RNA_def_property_ui_text(prop, "Show Auto Keying Warning", - "Show warning indicators when transforming Object and Bones if Auto Keying is enabled"); + "Show warning indicators when transforming objects and bones if auto keying is enabled"); /* keyframing settings */ prop = RNA_def_property(srna, "use_keyframe_insert_needed", PROP_BOOLEAN, PROP_NONE); @@ -2993,6 +3002,7 @@ static void rna_def_userdef_system(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; +#if 0 /* hardcoded here, could become dynamic somehow */ /* locale according to http://www.roseindia.net/tutorials/I18N/locales-list.shtml */ /* if you edit here, please also edit the source/blender/blenfont/intern/blf_lang.c 's locales */ @@ -3042,6 +3052,12 @@ static void rna_def_userdef_system(BlenderRNA *brna) {30, "TURKISH", 0, "Turkish (Türkçe)", "tr_TR"}, { 0, NULL, 0, NULL, NULL} }; +#else + static EnumPropertyItem language_items[] = { + { 0, "DEFAULT", 0, "Default (Default)", ""}, + { 0, NULL, 0, NULL, NULL} + }; +#endif #ifdef WITH_CYCLES static EnumPropertyItem compute_device_items[] = { @@ -3084,6 +3100,9 @@ static void rna_def_userdef_system(BlenderRNA *brna) prop = RNA_def_property(srna, "language", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, language_items); +#ifdef WITH_INTERNATIONAL + RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_lang_enum_properties_itemf"); +#endif RNA_def_property_ui_text(prop, "Language", "Language used for translation"); RNA_def_property_update(prop, NC_WINDOW, "rna_userdef_language_update"); @@ -3521,6 +3540,10 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_HIDE_RECENT); RNA_def_property_ui_text(prop, "Hide Recent Locations", "Hide recent locations in the file selector"); + prop = RNA_def_property(srna, "hide_system_bookmarks", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_HIDE_SYSTEM_BOOKMARKS); + RNA_def_property_ui_text(prop, "Hide System Bookmarks", "Hide system bookmarks in the file selector"); + prop = RNA_def_property(srna, "show_thumbnails", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_THUMBNAILS); RNA_def_property_ui_text(prop, "Show Thumbnails", "Open in thumbnail view for images and movies"); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 30bdc717f50..23587bf6cd6 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -629,6 +629,27 @@ static void rna_wmKeyMapItem_map_type_set(PointerRNA *ptr, int value) } } +/* assumes value to be an enum from event_type_items */ +/* function makes sure keymodifiers are only valid keys, ESC keeps it unaltered */ +static void rna_wmKeyMapItem_keymodifier_set(PointerRNA *ptr, int value) +{ + wmKeyMapItem *kmi = ptr->data; + + /* XXX, this should really be managed in an _itemf function, + * giving a list of valid enums, then silently changing them when they are set is not + * a good precedent, don't do this unless you have a good reason! */ + if (value == ESCKEY) { + /* pass */ + } + else if (value >= AKEY) { + kmi->keymodifier = value; + } + else { + kmi->keymodifier = 0; + } +} + + static EnumPropertyItem *rna_KeyMapItem_type_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *UNUSED(free)) { @@ -1180,7 +1201,7 @@ static StructRNA *rna_MacroOperator_register(Main *bmain, ReportList *reports, v } if (strlen(identifier) >= sizeof(dummyop.idname)) { - BKE_reportf(reports, RPT_ERROR, "registering operator class: '%s' is too long, maximum length is %d", + BKE_reportf(reports, RPT_ERROR, "Registering operator class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(dummyop.idname)); return NULL; } @@ -1230,24 +1251,30 @@ static void rna_Operator_bl_idname_set(PointerRNA *ptr, const char *value) { wmOperator *data = (wmOperator *)(ptr->data); char *str = (char *)data->type->idname; - if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */ - else assert(!"setting the bl_idname on a non-builtin operator"); + if (!str[0]) + BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */ + else + assert(!"setting the bl_idname on a non-builtin operator"); } static void rna_Operator_bl_label_set(PointerRNA *ptr, const char *value) { wmOperator *data = (wmOperator *)(ptr->data); char *str = (char *)data->type->name; - if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */ - else assert(!"setting the bl_label on a non-builtin operator"); + if (!str[0]) + BLI_strncpy(str, value, OP_MAX_TYPENAME); /* utf8 already ensured */ + else + assert(!"setting the bl_label on a non-builtin operator"); } static void rna_Operator_bl_description_set(PointerRNA *ptr, const char *value) { wmOperator *data = (wmOperator *)(ptr->data); char *str = (char *)data->type->description; - if (!str[0]) BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */ - else assert(!"setting the bl_description on a non-builtin operator"); + if (!str[0]) + BLI_strncpy(str, value, RNA_DYN_DESCR_MAX); /* utf8 already ensured */ + else + assert(!"setting the bl_description on a non-builtin operator"); } static void rna_KeyMapItem_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -1404,7 +1431,7 @@ static void rna_def_operator_type_macro(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Operator Macro", "Storage of a sub operator in a macro after it has been added"); RNA_def_struct_sdna(srna, "wmOperatorTypeMacro"); -/* prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); */ +/* prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); */ /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ /* RNA_def_property_string_sdna(prop, NULL, "idname"); */ /* RNA_def_property_ui_text(prop, "Name", "Name of the sub operator"); */ @@ -1865,6 +1892,7 @@ static void rna_def_keyconfig(BlenderRNA *brna) prop = RNA_def_property(srna, "key_modifier", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "keymodifier"); RNA_def_property_enum_items(prop, event_type_items); + RNA_def_property_enum_funcs(prop, NULL, "rna_wmKeyMapItem_keymodifier_set", NULL); RNA_def_property_ui_text(prop, "Key Modifier", "Regular key pressed as a modifier"); RNA_def_property_update(prop, 0, "rna_KeyMapItem_update"); diff --git a/source/blender/makesrna/rna_cleanup/rna_cleaner.py b/source/blender/makesrna/rna_cleanup/rna_cleaner.py index e3359fbae59..0231e57fcfd 100755 --- a/source/blender/makesrna/rna_cleanup/rna_cleaner.py +++ b/source/blender/makesrna/rna_cleanup/rna_cleaner.py @@ -130,11 +130,11 @@ def get_props_from_txt(input_filename): line = line[1:] # class - [bclass, tail] = [x.strip() for x in line.split('.', 1)] + bclass, tail = [x.strip() for x in line.split('.', 1)] # comment if '*' in bclass: - [comment, bclass] = [x.strip() for x in bclass.split('*', 1)] + comment, bclass = [x.strip() for x in bclass.split('*', 1)] else: comment= '' @@ -144,18 +144,18 @@ def get_props_from_txt(input_filename): continue # from - [bfrom, tail] = [x.strip() for x in tail.split('->', 1)] + bfrom, tail = [x.strip() for x in tail.split('->', 1)] # to - [bto, tail] = [x.strip() for x in tail.split(':', 1)] + bto, tail = [x.strip() for x in tail.split(':', 1)] # type, description try: - [btype, description] = tail.split(None, 1) + btype, description = tail.split(None, 1) # make life easy and strip quotes description = description.replace("'", "").replace('"', "").replace("\\", "").strip() except ValueError: - [btype, description] = [tail,'NO DESCRIPTION'] + btype, description = [tail,'NO DESCRIPTION'] # keyword-check kwcheck = check_prefix(bto, btype) diff --git a/source/blender/modifiers/CMakeLists.txt b/source/blender/modifiers/CMakeLists.txt index 83e7ea81ca5..3a7066ff41a 100644 --- a/source/blender/modifiers/CMakeLists.txt +++ b/source/blender/modifiers/CMakeLists.txt @@ -38,6 +38,7 @@ set(INC ../render/extern/include ../../../intern/elbeem/extern ../../../intern/guardedalloc + ../../../intern/opennl/extern ) set(INC_SYS @@ -64,6 +65,7 @@ set(SRC intern/MOD_fluidsim_util.c intern/MOD_hook.c intern/MOD_lattice.c + intern/MOD_laplaciansmooth.c intern/MOD_mask.c intern/MOD_meshdeform.c intern/MOD_mirror.c @@ -117,13 +119,6 @@ if(WITH_MOD_REMESH) ) endif() -if(WITH_MOD_DECIMATE) - add_definitions(-DWITH_MOD_DECIMATE) - list(APPEND INC - ../../../intern/decimation/extern - ) -endif() - if(WITH_MOD_FLUID) add_definitions(-DWITH_MOD_FLUID) endif() diff --git a/source/blender/modifiers/MOD_modifiertypes.h b/source/blender/modifiers/MOD_modifiertypes.h index 51e574e276d..a4817ff775d 100644 --- a/source/blender/modifiers/MOD_modifiertypes.h +++ b/source/blender/modifiers/MOD_modifiertypes.h @@ -75,6 +75,7 @@ extern ModifierTypeInfo modifierType_WeightVGProximity; extern ModifierTypeInfo modifierType_DynamicPaint; extern ModifierTypeInfo modifierType_Remesh; extern ModifierTypeInfo modifierType_Skin; +extern ModifierTypeInfo modifierType_LaplacianSmooth; /* MOD_util.c */ void modifier_type_init(ModifierTypeInfo *types[]); diff --git a/source/blender/modifiers/SConscript b/source/blender/modifiers/SConscript index 2b506cce2cf..62fd9ba2de1 100644 --- a/source/blender/modifiers/SConscript +++ b/source/blender/modifiers/SConscript @@ -4,7 +4,7 @@ Import ('env') sources = env.Glob('intern/*.c') incs = '. ./intern' -incs += ' #/intern/guardedalloc #/intern/decimation/extern #/intern/bsp/extern #/intern/elbeem/extern #/extern/glew/include' +incs += ' #/intern/guardedalloc #/intern/bsp/extern #/intern/elbeem/extern #/extern/glew/include #/intern/opennl/extern' incs += ' ../render/extern/include ../blenloader ../bmesh' incs += ' ../include ../blenlib ../blenfont ../makesdna ../makesrna ../blenkernel ../blenkernel/intern' incs += ' ../gpu' @@ -20,9 +20,6 @@ if env['WITH_BF_REMESH']: incs += ' #/intern/dualcon' defs.append('WITH_MOD_REMESH') -if env ['WITH_BF_DECIMATE']: - defs.append('WITH_MOD_DECIMATE') - if env['WITH_BF_FLUID']: defs.append('WITH_MOD_FLUID') diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index e6d86de45b4..7219038b087 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -135,13 +135,13 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, + ModifierData *md, Object *ob, struct BMEditMesh *em, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { ArmatureModifierData *amd = (ArmatureModifierData *) md; DerivedMesh *dm = derivedData; - if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); + if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE); modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ @@ -158,14 +158,14 @@ static void deformVertsEM( } static void deformMatricesEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, + ModifierData *md, Object *ob, struct BMEditMesh *em, DerivedMesh *derivedData, float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) { ArmatureModifierData *amd = (ArmatureModifierData *) md; DerivedMesh *dm = derivedData; - if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); + if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE); armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts, amd->deformflag, NULL, amd->defgrp_name); diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 26682e30841..7b699e5633c 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -53,7 +53,8 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_object.h" -#include "BKE_tessmesh.h" + +#include "bmesh.h" #include "depsgraph_private.h" @@ -310,7 +311,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, int UNUSED(initFlags)) { DerivedMesh *result; - BMEditMesh *em = DM_to_editbmesh(dm, NULL, FALSE); + BMesh *bm = DM_to_bmesh(dm); BMOperator first_dupe_op, dupe_op, old_dupe_op, weld_op; BMVert **first_geom = NULL; int i, j, indexLen; @@ -406,14 +407,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, * cleaner way to do this. One possibility: a "mirror" BMOp would * certainly help by compressing it all into one top-level BMOp that * executes a lot of second-level BMOps. */ - BMO_push(em->bm, NULL); - bmesh_edit_begin(em->bm, 0); + BMO_push(bm, NULL); + bmesh_edit_begin(bm, 0); if (amd->flags & MOD_ARR_MERGE) - BMO_op_init(em->bm, &weld_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), + BMO_op_init(bm, &weld_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "weld_verts"); - BMO_op_initf(em->bm, &dupe_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), + BMO_op_initf(bm, &dupe_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "duplicate geom=%avef"); first_dupe_op = dupe_op; @@ -424,11 +425,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, BMOIter oiter; if (j != 0) { - BMO_op_initf(em->bm, &dupe_op, + BMO_op_initf(bm, &dupe_op, (BMO_FLAG_DEFAULTS & ~BMO_FLAG_RESPECT_HIDE), "duplicate geom=%s", &old_dupe_op, "newout"); } - BMO_op_exec(em->bm, &dupe_op); + BMO_op_exec(bm, &dupe_op); geom_slot = BMO_slot_get(&dupe_op, "geom"); newout_slot = BMO_slot_get(&dupe_op, "newout"); @@ -443,14 +444,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, } /* apply transformation matrix */ - BMO_ITER (v, &oiter, em->bm, &dupe_op, "newout", BM_VERT) { + BMO_ITER (v, &oiter, bm, &dupe_op, "newout", BM_VERT) { mul_m4_v3(offset, v->co); } if (amd->flags & MOD_ARR_MERGE) { /*calculate merge mapping*/ if (j == 0) { - indexMap = find_doubles_index_map(em->bm, &dupe_op, + indexMap = find_doubles_index_map(bm, &dupe_op, amd, &indexLen); } @@ -465,11 +466,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, /* check in case the target vertex (v2) is already marked * for merging */ - while ((v3 = BMO_slot_map_ptr_get(em->bm, &weld_op, "targetmap", v2))) { + while ((v3 = BMO_slot_map_ptr_get(bm, &weld_op, "targetmap", v2))) { v2 = v3; } - BMO_slot_map_ptr_insert(em->bm, &weld_op, "targetmap", v, v2); + BMO_slot_map_ptr_insert(bm, &weld_op, "targetmap", v, v2); } #undef _E @@ -481,7 +482,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, first_dupe_op = dupe_op; if (j >= 2) - BMO_op_finish(em->bm, &old_dupe_op); + BMO_op_finish(bm, &old_dupe_op); old_dupe_op = dupe_op; } @@ -494,45 +495,44 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, * loop) the offset between first and last is different from * dupe X to dupe X+1. */ - merge_first_last(em->bm, amd, &first_dupe_op, &dupe_op, &weld_op); + merge_first_last(bm, amd, &first_dupe_op, &dupe_op, &weld_op); } /* start capping */ if (start_cap || end_cap) { - BM_mesh_elem_hflag_enable_all(em->bm, BM_VERT, BM_ELEM_TAG, FALSE); + BM_mesh_elem_hflag_enable_all(bm, BM_VERT, BM_ELEM_TAG, FALSE); if (start_cap) { float startoffset[4][4]; invert_m4_m4(startoffset, offset); - bm_merge_dm_transform(em->bm, start_cap, startoffset, amd, + bm_merge_dm_transform(bm, start_cap, startoffset, amd, &first_dupe_op, "geom", &weld_op); } if (end_cap) { float endoffset[4][4]; mult_m4_m4m4(endoffset, offset, final_offset); - bm_merge_dm_transform(em->bm, end_cap, endoffset, amd, + bm_merge_dm_transform(bm, end_cap, endoffset, amd, &dupe_op, count == 1 ? "geom" : "newout", &weld_op); } } /* done capping */ /* free remaining dupe operators */ - BMO_op_finish(em->bm, &first_dupe_op); + BMO_op_finish(bm, &first_dupe_op); if (count > 2) - BMO_op_finish(em->bm, &dupe_op); + BMO_op_finish(bm, &dupe_op); /* run merge operator */ if (amd->flags & MOD_ARR_MERGE) { - BMO_op_exec(em->bm, &weld_op); - BMO_op_finish(em->bm, &weld_op); + BMO_op_exec(bm, &weld_op); + BMO_op_finish(bm, &weld_op); } /* Bump the stack level back down to match the adjustment up above */ - BMO_pop(em->bm); + BMO_pop(bm); - BLI_assert(em->looptris == NULL); - result = CDDM_from_BMEditMesh(em, NULL, FALSE, FALSE); + result = CDDM_from_bmesh(bm, FALSE); if ((amd->offset_type & MOD_ARR_OFF_OBJ) && (amd->offset_ob)) { /* Update normals in case offset object has rotation. */ @@ -543,8 +543,8 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, CDDM_calc_normals(result); } - BMEdit_Free(em); - MEM_freeN(em); + BM_mesh_free(bm); + if (indexMap) MEM_freeN(indexMap); if (first_geom) diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 638e91e22f1..3e3bcb73491 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -38,11 +38,11 @@ #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" -#include "BKE_tessmesh.h" #include "BKE_mesh.h" - #include "BKE_bmesh.h" /* only for defines */ +#include "bmesh.h" + #include "DNA_object_types.h" #include "MEM_guardedalloc.h" @@ -88,6 +88,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } +// #define USE_BM_BEVEL_OP_AS_MOD + #ifdef USE_BM_BEVEL_OP_AS_MOD #define EDGE_MARK 1 @@ -111,14 +113,12 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), { DerivedMesh *result; BMesh *bm; - BMEditMesh *em; BMIter iter; BMEdge *e; BevelModifierData *bmd = (BevelModifierData *) md; - float threshold = cos((bmd->bevel_angle + 0.00001) * M_PI / 180.0); + float threshold = cos((bmd->bevel_angle + 0.00001f) * M_PI / 180.0f); - em = DM_to_editbmesh(dm, NULL, FALSE); - bm = em->bm; + bm = DM_to_bmesh(dm); BM_mesh_normals_update(bm, FALSE); BMO_push(bm, NULL); @@ -148,10 +148,8 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), EDGE_MARK, bmd->value, (bmd->flags & BME_BEVEL_EVEN) != 0, (bmd->flags & BME_BEVEL_DIST) != 0); BMO_pop(bm); - BLI_assert(em->looptris == NULL); - result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE); - BMEdit_Free(em); - MEM_freeN(em); + result = CDDM_from_bmesh(bm, TRUE); + BM_mesh_free(bm); return result; } @@ -164,7 +162,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), ModifierApplyFlag UNUSED(flag)) { DerivedMesh *result; - BMEditMesh *em; + BMesh *bm; /*bDeformGroup *def;*/ int /*i,*/ options, defgrp_index = -1; @@ -175,18 +173,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), #if 0 if ((options & BME_BEVEL_VWEIGHT) && bmd->defgrp_name[0]) { defgrp_index = defgroup_name_index(ob, bmd->defgrp_name); - if (defgrp_index < 0) { + if (defgrp_index == -1) { options &= ~BME_BEVEL_VWEIGHT; } } #endif - em = DM_to_editbmesh(derivedData, NULL, FALSE); - BME_bevel(em, bmd->value, bmd->res, options, defgrp_index, DEG2RADF(bmd->bevel_angle), NULL, FALSE); - BLI_assert(em->looptris == NULL); - result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE); - BMEdit_Free(em); - MEM_freeN(em); + bm = DM_to_bmesh(derivedData); + BME_bevel(bm, bmd->value, bmd->res, options, defgrp_index, DEG2RADF(bmd->bevel_angle), NULL); + result = CDDM_from_bmesh(bm, TRUE); + BM_mesh_free(bm); /* until we allow for dirty normal flag, always calc, * note: calculating on the CDDM is faster then the BMesh equivalent */ @@ -206,29 +202,29 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, ModifierTypeInfo modifierType_Bevel = { - /* name */ "Bevel", - /* structName */ "BevelModifierData", - /* structSize */ sizeof(BevelModifierData), - /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh | - eModifierTypeFlag_SupportsEditmode | - eModifierTypeFlag_EnableInEditmode, - - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ applyModifierEM, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, - /* isDisabled */ NULL, - /* updateDepgraph */ NULL, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* name */ "Bevel", + /* structName */ "BevelModifierData", + /* structSize */ sizeof(BevelModifierData), + /* type */ eModifierTypeType_Constructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, + + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ applyModifierEM, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ NULL, + /* isDisabled */ NULL, + /* updateDepgraph */ NULL, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index 5c78a8efe23..0a48003fc81 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -167,7 +167,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (result) return result; else - modifier_setError(md, "%s", TIP_("Can't execute boolean operation.")); + modifier_setError(md, "Cannot execute boolean operation"); } return derivedData; @@ -192,28 +192,28 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED( ModifierTypeInfo modifierType_Boolean = { - /* name */ "Boolean", - /* structName */ "BooleanModifierData", - /* structSize */ sizeof(BooleanModifierData), - /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh | - eModifierTypeFlag_UsesPointCache, - - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ NULL, - /* initData */ NULL, - /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* name */ "Boolean", + /* structName */ "BooleanModifierData", + /* structSize */ sizeof(BooleanModifierData), + /* type */ eModifierTypeType_Nonconstructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_UsesPointCache, + + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ NULL, + /* initData */ NULL, + /* requiredDataMask */ requiredDataMask, + /* freeData */ NULL, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index 121b0ee89e3..2105a6efd21 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -293,27 +293,27 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), ModifierTypeInfo modifierType_Build = { - /* name */ "Build", - /* structName */ "BuildModifierData", - /* structSize */ sizeof(BuildModifierData), - /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh | - eModifierTypeFlag_AcceptsCVs, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ NULL, - /* freeData */ NULL, - /* isDisabled */ NULL, - /* updateDepgraph */ NULL, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* name */ "Build", + /* structName */ "BuildModifierData", + /* structSize */ sizeof(BuildModifierData), + /* type */ eModifierTypeType_Nonconstructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ NULL, + /* freeData */ NULL, + /* isDisabled */ NULL, + /* updateDepgraph */ NULL, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 8eb47f4066c..54f3efcc84c 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -180,7 +180,7 @@ static void freeData(ModifierData *md) MEM_freeN(clmd->sim_parms); } if (clmd->coll_parms) - MEM_freeN(clmd->coll_parms); + MEM_freeN(clmd->coll_parms); BKE_ptcache_free_list(&clmd->ptcaches); clmd->point_cache = NULL; diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index 0ce4d74aebb..3ef6b9bfcb8 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -125,12 +125,12 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, + ModifierData *md, Object *ob, struct BMEditMesh *em, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; - if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); + if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE); deformVerts(md, ob, dm, vertexCos, numVerts, 0); diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index 171d601ea6d..dc29e59d549 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -32,10 +32,10 @@ * \ingroup modifiers */ - -#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" #include "BLI_math.h" +#include "BLI_string.h" #include "BLI_utildefines.h" #include "BLF_translation.h" @@ -44,16 +44,16 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" +#include "BKE_deform.h" #include "BKE_particle.h" #include "BKE_cdderivedmesh.h" -#include "BKE_tessmesh.h" +#include "bmesh.h" -/* testing only! - Campbell */ -// #define USE_DECIMATE_BMESH +// #define USE_TIMEIT -#ifdef WITH_MOD_DECIMATE -#include "LOD_decimation.h" +#ifdef USE_TIMEIT +# include "PIL_time.h" #endif #include "MOD_util.h" @@ -63,6 +63,7 @@ static void initData(ModifierData *md) DecimateModifierData *dmd = (DecimateModifierData *) md; dmd->percent = 1.0; + dmd->angle = DEG2RADF(15.0f); } static void copyData(ModifierData *md, ModifierData *target) @@ -71,174 +72,136 @@ static void copyData(ModifierData *md, ModifierData *target) DecimateModifierData *tdmd = (DecimateModifierData *) target; tdmd->percent = dmd->percent; + tdmd->iter = dmd->iter; + tdmd->angle = dmd->angle; + BLI_strncpy(tdmd->defgrp_name, dmd->defgrp_name, sizeof(tdmd->defgrp_name)); + tdmd->flag = dmd->flag; + tdmd->mode = dmd->mode; } -#ifdef WITH_MOD_DECIMATE -#ifdef USE_DECIMATE_BMESH - -#include "bmesh.h" - -static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), - DerivedMesh *derivedData, - ModifierApplyFlag UNUSED(flag)) +static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { DecimateModifierData *dmd = (DecimateModifierData *) md; - DerivedMesh *dm = derivedData, *result = NULL; - BMEditMesh *em; - BMesh *bm; - - em = DM_to_editbmesh(dm, NULL, FALSE); - bm = em->bm; - - BM_mesh_decimate(bm, dmd->percent); + CustomDataMask dataMask = 0; - BLI_assert(em->looptris == NULL); - result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE); - BMEdit_Free(em); - MEM_freeN(em); + /* ask for vertexgroups if we need them */ + if (dmd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT; - return result; + return dataMask; } -#else -static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), +static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData, ModifierApplyFlag UNUSED(flag)) { DecimateModifierData *dmd = (DecimateModifierData *) md; DerivedMesh *dm = derivedData, *result = NULL; - MVert *mvert; - MFace *mface; - LOD_Decimation_Info lod; - int totvert, totface; - int a, numTris; - - DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ - - mvert = dm->getVertArray(dm); - mface = dm->getTessFaceArray(dm); - totvert = dm->getNumVerts(dm); - totface = dm->getNumTessFaces(dm); - - numTris = 0; - for (a = 0; a < totface; a++) { - MFace *mf = &mface[a]; - numTris++; - if (mf->v4) numTris++; - } + BMesh *bm; - if (numTris < 3) { - modifier_setError(md, "%s", TIP_("Modifier requires more than 3 input faces (triangles).")); - dm = CDDM_copy(dm); - return dm; - } + float *vweights = NULL; - lod.vertex_buffer = MEM_mallocN(3 * sizeof(float) * totvert, "vertices"); - lod.vertex_normal_buffer = MEM_mallocN(3 * sizeof(float) * totvert, "normals"); - lod.triangle_index_buffer = MEM_mallocN(3 * sizeof(int) * numTris, "trias"); - lod.vertex_num = totvert; - lod.face_num = numTris; +#ifdef USE_TIMEIT + TIMEIT_START(decim); +#endif - for (a = 0; a < totvert; a++) { - MVert *mv = &mvert[a]; - float *vbCo = &lod.vertex_buffer[a * 3]; - float *vbNo = &lod.vertex_normal_buffer[a * 3]; + /* set up front so we dont show invalid info in the UI */ + dmd->face_count = dm->getNumPolys(dm); - copy_v3_v3(vbCo, mv->co); - normal_short_to_float_v3(vbNo, mv->no); + switch (dmd->mode) { + case MOD_DECIM_MODE_COLLAPSE: + if (dmd->percent == 1.0f) { + return dm; + } + break; + case MOD_DECIM_MODE_UNSUBDIV: + if (dmd->iter == 0) { + return dm; + } + break; + case MOD_DECIM_MODE_DISSOLVE: + if (dmd->angle == 0.0f) { + return dm; + } + break; } - numTris = 0; - for (a = 0; a < totface; a++) { - MFace *mf = &mface[a]; - int *tri = &lod.triangle_index_buffer[3 * numTris++]; - tri[0] = mf->v1; - tri[1] = mf->v2; - tri[2] = mf->v3; - - if (mf->v4) { - tri = &lod.triangle_index_buffer[3 * numTris++]; - tri[0] = mf->v1; - tri[1] = mf->v3; - tri[2] = mf->v4; - } + if (dmd->face_count <= 3) { + modifier_setError(md, "Modifier requires more than 3 input faces"); + return dm; } - dmd->faceCount = 0; - if (LOD_LoadMesh(&lod) ) { - if (LOD_PreprocessMesh(&lod) ) { - /* we assume the decim_faces tells how much to reduce */ + if (dmd->mode == MOD_DECIM_MODE_COLLAPSE) { + if (dmd->defgrp_name[0]) { + MDeformVert *dvert; + int defgrp_index; - while (lod.face_num > numTris * dmd->percent) { - if (LOD_CollapseEdge(&lod) == 0) break; - } + modifier_get_vgroup(ob, dm, dmd->defgrp_name, &dvert, &defgrp_index); - if (lod.vertex_num > 2) { - result = CDDM_new(lod.vertex_num, 0, lod.face_num, 0, 0); - dmd->faceCount = lod.face_num; - } - else - result = CDDM_new(lod.vertex_num, 0, 0, 0, 0); - - mvert = CDDM_get_verts(result); - for (a = 0; a < lod.vertex_num; a++) { - MVert *mv = &mvert[a]; - float *vbCo = &lod.vertex_buffer[a * 3]; - - copy_v3_v3(mv->co, vbCo); - } + if (dvert) { + const unsigned int vert_tot = dm->getNumVerts(dm); + unsigned int i; + + vweights = MEM_mallocN(vert_tot * sizeof(float), __func__); - if (lod.vertex_num > 2) { - mface = CDDM_get_tessfaces(result); - for (a = 0; a < lod.face_num; a++) { - MFace *mf = &mface[a]; - int *tri = &lod.triangle_index_buffer[a * 3]; - mf->v1 = tri[0]; - mf->v2 = tri[1]; - mf->v3 = tri[2]; - test_index_face(mf, NULL, 0, 3); + if (dmd->flag & MOD_DECIM_FLAG_INVERT_VGROUP) { + for (i = 0; i < vert_tot; i++) { + vweights[i] = 1.0f - defvert_find_weight(&dvert[i], defgrp_index); + } + } + else { + for (i = 0; i < vert_tot; i++) { + vweights[i] = defvert_find_weight(&dvert[i], defgrp_index); + } } } + } + } + + bm = DM_to_bmesh(dm); - CDDM_calc_edges_tessface(result); + switch (dmd->mode) { + case MOD_DECIM_MODE_COLLAPSE: + { + const int do_triangulate = (dmd->flag & MOD_DECIM_FLAG_TRIANGULATE) != 0; + BM_mesh_decimate_collapse(bm, dmd->percent, vweights, do_triangulate); + break; + } + case MOD_DECIM_MODE_UNSUBDIV: + { + BM_mesh_decimate_unsubdivide(bm, dmd->iter); + break; + } + case MOD_DECIM_MODE_DISSOLVE: + { + const int do_dissolve_boundaries = (dmd->flag & MOD_DECIM_FLAG_ALL_BOUNDARY_VERTS) != 0; + BM_mesh_decimate_dissolve(bm, dmd->angle, do_dissolve_boundaries); + break; } - else - modifier_setError(md, "%s", TIP_("Out of memory.")); + } - LOD_FreeDecimationData(&lod); + if (vweights) { + MEM_freeN(vweights); } - else - modifier_setError(md, "%s", TIP_("Non-manifold mesh as input.")); - MEM_freeN(lod.vertex_buffer); - MEM_freeN(lod.vertex_normal_buffer); - MEM_freeN(lod.triangle_index_buffer); + /* update for display only */ + dmd->face_count = bm->totface; + result = CDDM_from_bmesh(bm, FALSE); + BM_mesh_free(bm); - if (result) { - CDDM_tessfaces_to_faces(result); /*builds ngon faces from tess (mface) faces*/ +#ifdef USE_TIMEIT + TIMEIT_END(decim); +#endif - return result; - } - else { - return dm; - } -} -#endif // USE_DECIMATE_BMESH -#else // WITH_MOD_DECIMATE -static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob), - DerivedMesh *derivedData, - ModifierApplyFlag UNUSED(flag)) -{ - return derivedData; + return result; } -#endif // WITH_MOD_DECIMATE ModifierTypeInfo modifierType_Decimate = { /* name */ "Decimate", /* structName */ "DecimateModifierData", /* structSize */ sizeof(DecimateModifierData), /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs, /* copyData */ copyData, /* deformVerts */ NULL, /* deformMatrices */ NULL, @@ -247,7 +210,7 @@ ModifierTypeInfo modifierType_Decimate = { /* applyModifier */ applyModifier, /* applyModifierEM */ NULL, /* initData */ initData, - /* requiredDataMask */ NULL, + /* requiredDataMask */ requiredDataMask, /* freeData */ NULL, /* isDisabled */ NULL, /* updateDepgraph */ NULL, diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index 7d7bfade9b7..80866a7c435 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -170,10 +170,10 @@ ModifierTypeInfo modifierType_DynamicPaint = { /* structSize */ sizeof(DynamicPaintModifierData), /* type */ eModifierTypeType_Constructive, /* flags */ eModifierTypeFlag_AcceptsMesh | -/* eModifierTypeFlag_SupportsMapping |*/ - eModifierTypeFlag_UsesPointCache | - eModifierTypeFlag_Single | - eModifierTypeFlag_UsesPreview, +/* eModifierTypeFlag_SupportsMapping |*/ + eModifierTypeFlag_UsesPointCache | + eModifierTypeFlag_Single | + eModifierTypeFlag_UsesPreview, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index b1c3459bf51..21717d07fef 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -43,9 +43,10 @@ #include "BKE_cdderivedmesh.h" #include "BKE_modifier.h" -#include "BKE_tessmesh.h" #include "BKE_mesh.h" +#include "bmesh.h" + #include "DNA_object_types.h" /* EdgeSplit */ @@ -61,15 +62,12 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj { DerivedMesh *result; BMesh *bm; - BMEditMesh *em; BMIter iter; BMEdge *e; float threshold = cosf((emd->split_angle + 0.00001f) * (float)M_PI / 180.0f); - em = DM_to_editbmesh(dm, NULL, FALSE); - bm = em->bm; + bm = DM_to_bmesh(dm); - BM_mesh_normals_update(bm, FALSE); BMO_push(bm, NULL); if (emd->flags & MOD_EDGESPLIT_FROMANGLE) { @@ -110,10 +108,8 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj /* BM_mesh_validate(bm); */ /* for troubleshooting */ - BLI_assert(em->looptris == NULL); - result = CDDM_from_BMEditMesh(em, NULL, TRUE, FALSE); - BMEdit_Free(em); - MEM_freeN(em); + result = CDDM_from_bmesh(bm, TRUE); + BM_mesh_free(bm); return result; } diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index b9593353288..0e4aa54b4c1 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -206,11 +206,11 @@ static MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFa } #define SET_VERTS(a, b, c, d) { \ - v[0] = mf->v##a; uv[0] = a - 1; \ - v[1] = mf->v##b; uv[1] = b - 1; \ - v[2] = mf->v##c; uv[2] = c - 1; \ - v[3] = mf->v##d; uv[3] = d - 1; \ - } (void)0 + v[0] = mf->v##a; uv[0] = a - 1; \ + v[1] = mf->v##b; uv[1] = b - 1; \ + v[2] = mf->v##c; uv[2] = c - 1; \ + v[3] = mf->v##d; uv[3] = d - 1; \ + } (void)0 #define GET_ES(v1, v2) edgecut_get(eh, v1, v2) #define INT_UV(uvf, c0, c1) interp_v2_v2v2(uvf, mf->uv[c0], mf->uv[c1], 0.5f) @@ -813,7 +813,7 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd, sim.psys = psmd->psys; sim.psmd = psmd; - /* timestep= psys_get_timestep(&sim); */ + /* timestep = psys_get_timestep(&sim); */ cfra = BKE_scene_frame_get(scene); @@ -861,7 +861,7 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd, /* the final duplicated vertices */ explode = CDDM_from_template(dm, totdup, 0, totface - delface, 0, 0); mtface = CustomData_get_layer_named(&explode->faceData, CD_MTFACE, emd->uvname); - /*dupvert= CDDM_get_verts(explode);*/ + /*dupvert = CDDM_get_verts(explode);*/ /* getting back to object space */ invert_m4_m4(imat, ob->obmat); @@ -1039,26 +1039,26 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, ModifierTypeInfo modifierType_Explode = { - /* name */ "Explode", - /* structName */ "ExplodeModifierData", - /* structSize */ sizeof(ExplodeModifierData), - /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ freeData, - /* isDisabled */ NULL, - /* updateDepgraph */ NULL, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* name */ "Explode", + /* structName */ "ExplodeModifierData", + /* structSize */ sizeof(ExplodeModifierData), + /* type */ eModifierTypeType_Constructive, + /* flags */ eModifierTypeFlag_AcceptsMesh, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ freeData, + /* isDisabled */ NULL, + /* updateDepgraph */ NULL, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 9acac6d00cd..47523286229 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -529,7 +529,7 @@ DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, fss = fluidmd->fss; /* timescale not supported yet - * clmd->sim_parms->timescale= timescale; */ + * clmd->sim_parms->timescale = timescale; */ /* support reversing of baked fluid frames here */ if ((fss->flag & OB_FLUIDSIM_REVERSE) && (fss->lastgoodframe >= 0)) { diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c new file mode 100644 index 00000000000..eb05cecd932 --- /dev/null +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c @@ -0,0 +1,703 @@ +/* + * ***** 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) 2005 by the Blender Foundation. + * All rights reserved. + * + * Contributor(s): Alexander Pinzon + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/modifiers/intern/MOD_laplaciansmooth.c + * \ingroup modifiers + */ + + +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" + +#include "BLI_math.h" +#include "BLI_utildefines.h" +#include "BLI_string.h" + +#include "MEM_guardedalloc.h" + +#include "BKE_cdderivedmesh.h" +#include "BKE_deform.h" +#include "BKE_displist.h" +#include "BKE_mesh.h" +#include "BKE_modifier.h" +#include "BKE_object.h" +#include "BKE_particle.h" +#include "BKE_tessmesh.h" + +#include "MOD_modifiertypes.h" +#include "MOD_util.h" + +#include "ONL_opennl.h" + +#define MOD_LAPLACIANSMOOTH_MAX_EDGE_PERCENTAGE 1.8 +#define MOD_LAPLACIANSMOOTH_MIN_EDGE_PERCENTAGE 0.02 + +struct BLaplacianSystem { + float *eweights; /* Length weights per Edge */ + float (*fweights)[3]; /* Cotangent weights per face */ + float *ring_areas; /* Total area per ring*/ + float *vlengths; /* Total sum of lengths(edges) per vertice*/ + float *vweights; /* Total sum of weights per vertice*/ + int numEdges; /* Number of edges*/ + int numFaces; /* Number of faces*/ + int numVerts; /* Number of verts*/ + short *numNeFa; /* Number of neighboors faces around vertice*/ + short *numNeEd; /* Number of neighboors Edges around vertice*/ + short *zerola; /* Is zero area or length*/ + + /* Pointers to data*/ + float (*vertexCos)[3]; + MFace *mfaces; + MEdge *medges; + NLContext *context; + + /*Data*/ + float min_area; + float vert_centroid[3]; +}; +typedef struct BLaplacianSystem LaplacianSystem; + +static CustomDataMask required_data_mask(Object *UNUSED(ob), ModifierData *md); +static int is_disabled(ModifierData *md, int UNUSED(useRenderParams)); +static float compute_volume(float (*vertexCos)[3], MFace *mfaces, int numFaces); +static float cotan_weight(float *v1, float *v2, float *v3); +static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numFaces, int a_numVerts); +static void copy_data(ModifierData *md, ModifierData *target); +static void delete_laplacian_system(LaplacianSystem *sys); +static void delete_void_pointer(void *data); +static void fill_laplacian_matrix(LaplacianSystem *sys); +static void init_data(ModifierData *md); +static void init_laplacian_matrix(LaplacianSystem *sys); +static void memset_laplacian_system(LaplacianSystem *sys, int val); +static void volume_preservation(LaplacianSystem *sys, float vini, float vend, short flag); +static void validate_solution(LaplacianSystem *sys, short flag); + +static void delete_void_pointer(void *data) +{ + if (data) { + MEM_freeN(data); + data = NULL; + } +} + +static void delete_laplacian_system(LaplacianSystem *sys) +{ + delete_void_pointer(sys->eweights); + delete_void_pointer(sys->fweights); + delete_void_pointer(sys->numNeEd); + delete_void_pointer(sys->numNeFa); + delete_void_pointer(sys->ring_areas); + delete_void_pointer(sys->vlengths); + delete_void_pointer(sys->vweights); + delete_void_pointer(sys->zerola); + if (sys->context) { + nlDeleteContext(sys->context); + } + sys->vertexCos = NULL; + sys->mfaces = NULL; + sys->medges = NULL; + MEM_freeN(sys); +} + +static void memset_laplacian_system(LaplacianSystem *sys, int val) +{ + memset(sys->eweights, val, sizeof(float) * sys->numEdges); + memset(sys->fweights, val, sizeof(float) * sys->numFaces * 3); + memset(sys->numNeEd, val, sizeof(short) * sys->numVerts); + memset(sys->numNeFa, val, sizeof(short) * sys->numVerts); + memset(sys->ring_areas, val, sizeof(float) * sys->numVerts); + memset(sys->vlengths, val, sizeof(float) * sys->numVerts); + memset(sys->vweights, val, sizeof(float) * sys->numVerts); + memset(sys->zerola, val, sizeof(short) * sys->numVerts); +} + +static LaplacianSystem *init_laplacian_system(int a_numEdges, int a_numFaces, int a_numVerts) +{ + LaplacianSystem *sys; + sys = MEM_callocN(sizeof(LaplacianSystem), "ModLaplSmoothSystem"); + sys->numEdges = a_numEdges; + sys->numFaces = a_numFaces; + sys->numVerts = a_numVerts; + + sys->eweights = MEM_callocN(sizeof(float) * sys->numEdges, "ModLaplSmoothEWeight"); + if (!sys->eweights) { + delete_laplacian_system(sys); + return NULL; + } + + sys->fweights = MEM_callocN(sizeof(float) * 3 * sys->numFaces, "ModLaplSmoothFWeight"); + if (!sys->fweights) { + delete_laplacian_system(sys); + return NULL; + } + + sys->numNeEd = MEM_callocN(sizeof(short) * sys->numVerts, "ModLaplSmoothNumNeEd"); + if (!sys->numNeEd) { + delete_laplacian_system(sys); + return NULL; + } + + sys->numNeFa = MEM_callocN(sizeof(short) * sys->numVerts, "ModLaplSmoothNumNeFa"); + if (!sys->numNeFa) { + delete_laplacian_system(sys); + return NULL; + } + + sys->ring_areas = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothRingAreas"); + if (!sys->ring_areas) { + delete_laplacian_system(sys); + return NULL; + } + + sys->vlengths = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothVlengths"); + if (!sys->vlengths) { + delete_laplacian_system(sys); + return NULL; + } + + sys->vweights = MEM_callocN(sizeof(float) * sys->numVerts, "ModLaplSmoothVweights"); + if (!sys->vweights) { + delete_laplacian_system(sys); + return NULL; + } + + sys->zerola = MEM_callocN(sizeof(short) * sys->numVerts, "ModLaplSmoothZeloa"); + if (!sys->zerola) { + delete_laplacian_system(sys); + return NULL; + } + + return sys; +} + +static void init_data(ModifierData *md) +{ + LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *) md; + smd->lambda = 0.00001f; + smd->lambda_border = 0.00005f; + smd->repeat = 1; + smd->flag = MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z | MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION; + smd->defgrp_name[0] = '\0'; +} + +static void copy_data(ModifierData *md, ModifierData *target) +{ + LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *) md; + LaplacianSmoothModifierData *tsmd = (LaplacianSmoothModifierData *) target; + + tsmd->lambda = smd->lambda; + tsmd->lambda_border = smd->lambda_border; + tsmd->repeat = smd->repeat; + tsmd->flag = smd->flag; + BLI_strncpy(tsmd->defgrp_name, smd->defgrp_name, sizeof(tsmd->defgrp_name)); +} + +static int is_disabled(ModifierData *md, int UNUSED(useRenderParams)) +{ + LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *) md; + short flag; + + flag = smd->flag & (MOD_LAPLACIANSMOOTH_X | MOD_LAPLACIANSMOOTH_Y | MOD_LAPLACIANSMOOTH_Z); + + /* disable if modifier is off for X, Y and Z or if factor is 0 */ + if (flag == 0) return 1; + + return 0; +} + +static CustomDataMask required_data_mask(Object *UNUSED(ob), ModifierData *md) +{ + LaplacianSmoothModifierData *smd = (LaplacianSmoothModifierData *)md; + CustomDataMask dataMask = 0; + + /* ask for vertexgroups if we need them */ + if (smd->defgrp_name[0]) dataMask |= CD_MASK_MDEFORMVERT; + + return dataMask; +} + +static float cotan_weight(float *v1, float *v2, float *v3) +{ + float a[3], b[3], c[3], clen; + + sub_v3_v3v3(a, v2, v1); + sub_v3_v3v3(b, v3, v1); + cross_v3_v3v3(c, a, b); + + clen = len_v3(c); + + if (clen == 0.0f) + return 0.0f; + + return dot_v3v3(a, b) / clen; +} + +static float compute_volume(float (*vertexCos)[3], MFace *mfaces, int numFaces) +{ + float vol = 0.0f; + float x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4; + int i; + float *vf[4]; + for (i = 0; i < numFaces; i++) { + vf[0] = vertexCos[mfaces[i].v1]; + vf[1] = vertexCos[mfaces[i].v2]; + vf[2] = vertexCos[mfaces[i].v3]; + + x1 = vf[0][0]; + y1 = vf[0][1]; + z1 = vf[0][2]; + + x2 = vf[1][0]; + y2 = vf[1][1]; + z2 = vf[1][2]; + + x3 = vf[2][0]; + y3 = vf[2][1]; + z3 = vf[2][2]; + + + vol += (1.0 / 6.0) * (x2 * y3 * z1 + x3 * y1 * z2 - x1 * y3 * z2 - x2 * y1 * z3 + x1 * y2 * z3 - x3 * y2 * z1); + if ((&mfaces[i])->v4) { + vf[3] = vertexCos[mfaces[i].v4]; + x4 = vf[3][0]; + y4 = vf[3][1]; + z4 = vf[3][2]; + vol += (1.0 / 6.0) * (x1 * y3 * z4 - x1 * y4 * z3 - x3 * y1 * z4 + x3 * z1 * y4 + y1 * x4 * z3 - x4 * y3 * z1); + } + } + return fabsf(vol); +} + +static void volume_preservation(LaplacianSystem *sys, float vini, float vend, short flag) +{ + float beta; + int i; + + if (vend != 0.0f) { + beta = pow(vini / vend, 1.0f / 3.0f); + for (i = 0; i < sys->numVerts; i++) { + if (flag & MOD_LAPLACIANSMOOTH_X) { + sys->vertexCos[i][0] = (sys->vertexCos[i][0] - sys->vert_centroid[0]) * beta + sys->vert_centroid[0]; + } + if (flag & MOD_LAPLACIANSMOOTH_Y) { + sys->vertexCos[i][1] = (sys->vertexCos[i][1] - sys->vert_centroid[1]) * beta + sys->vert_centroid[1]; + } + if (flag & MOD_LAPLACIANSMOOTH_Z) { + sys->vertexCos[i][2] = (sys->vertexCos[i][2] - sys->vert_centroid[2]) * beta + sys->vert_centroid[2]; + } + + } + } +} + +static void init_laplacian_matrix(LaplacianSystem *sys) +{ + float *v1, *v2, *v3, *v4; + float w1, w2, w3, w4; + float areaf; + int i, j; + unsigned int idv1, idv2, idv3, idv4, idv[4]; + int has_4_vert; + for (i = 0; i < sys->numEdges; i++) { + idv1 = sys->medges[i].v1; + idv2 = sys->medges[i].v2; + + v1 = sys->vertexCos[idv1]; + v2 = sys->vertexCos[idv2]; + + sys->numNeEd[idv1] = sys->numNeEd[idv1] + 1; + sys->numNeEd[idv2] = sys->numNeEd[idv2] + 1; + w1 = len_v3v3(v1, v2); + if (w1 < sys->min_area) { + sys->zerola[idv1] = 1; + sys->zerola[idv2] = 1; + } + else { + w1 = 1.0f / w1; + } + + sys->eweights[i] = w1; + } + for (i = 0; i < sys->numFaces; i++) { + has_4_vert = ((&sys->mfaces[i])->v4) ? 1 : 0; + + idv1 = sys->mfaces[i].v1; + idv2 = sys->mfaces[i].v2; + idv3 = sys->mfaces[i].v3; + idv4 = has_4_vert ? sys->mfaces[i].v4 : 0; + + sys->numNeFa[idv1] += 1; + sys->numNeFa[idv2] += 1; + sys->numNeFa[idv3] += 1; + if (has_4_vert) sys->numNeFa[idv4] += 1; + + v1 = sys->vertexCos[idv1]; + v2 = sys->vertexCos[idv2]; + v3 = sys->vertexCos[idv3]; + v4 = has_4_vert ? sys->vertexCos[idv4] : 0; + + if (has_4_vert) { + areaf = area_quad_v3(v1, v2, v3, sys->vertexCos[sys->mfaces[i].v4]); + } + else { + areaf = area_tri_v3(v1, v2, v3); + } + if (fabs(areaf) < sys->min_area) { + sys->zerola[idv1] = 1; + sys->zerola[idv2] = 1; + sys->zerola[idv3] = 1; + if (has_4_vert) sys->zerola[idv4] = 1; + } + + sys->ring_areas[idv1] += areaf; + sys->ring_areas[idv2] += areaf; + sys->ring_areas[idv3] += areaf; + if (has_4_vert) sys->ring_areas[idv4] += areaf; + + if (has_4_vert) { + + idv[0] = idv1; + idv[1] = idv2; + idv[2] = idv3; + idv[3] = idv4; + + for (j = 0; j < 4; j++) { + idv1 = idv[j]; + idv2 = idv[(j + 1) % 4]; + idv3 = idv[(j + 2) % 4]; + idv4 = idv[(j + 3) % 4]; + + v1 = sys->vertexCos[idv1]; + v2 = sys->vertexCos[idv2]; + v3 = sys->vertexCos[idv3]; + v4 = sys->vertexCos[idv4]; + + w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2); + w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3); + w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1); + + sys->vweights[idv1] += (w2 + w3 + w4) / 4.0f; + } + } + else { + w1 = cotan_weight(v1, v2, v3); + w2 = cotan_weight(v2, v3, v1); + w3 = cotan_weight(v3, v1, v2); + + sys->fweights[i][0] = sys->fweights[i][0] + w1; + sys->fweights[i][1] = sys->fweights[i][1] + w2; + sys->fweights[i][2] = sys->fweights[i][2] + w3; + + sys->vweights[idv1] = sys->vweights[idv1] + w2 + w3; + sys->vweights[idv2] = sys->vweights[idv2] + w1 + w3; + sys->vweights[idv3] = sys->vweights[idv3] + w1 + w2; + } + } + for (i = 0; i < sys->numEdges; i++) { + idv1 = sys->medges[i].v1; + idv2 = sys->medges[i].v2; + /* if is boundary, apply scale-dependent umbrella operator only with neighboors in boundary */ + if (sys->numNeEd[idv1] != sys->numNeFa[idv1] && sys->numNeEd[idv2] != sys->numNeFa[idv2]) { + sys->vlengths[idv1] += sys->eweights[i]; + sys->vlengths[idv2] += sys->eweights[i]; + } + } + +} + +static void fill_laplacian_matrix(LaplacianSystem *sys) +{ + float *v1, *v2, *v3, *v4; + float w2, w3, w4; + int i, j; + int has_4_vert; + unsigned int idv1, idv2, idv3, idv4, idv[4]; + + for (i = 0; i < sys->numFaces; i++) { + idv1 = sys->mfaces[i].v1; + idv2 = sys->mfaces[i].v2; + idv3 = sys->mfaces[i].v3; + has_4_vert = ((&sys->mfaces[i])->v4) ? 1 : 0; + + if (has_4_vert) { + idv[0] = sys->mfaces[i].v1; + idv[1] = sys->mfaces[i].v2; + idv[2] = sys->mfaces[i].v3; + idv[3] = sys->mfaces[i].v4; + for (j = 0; j < 4; j++) { + idv1 = idv[j]; + idv2 = idv[(j + 1) % 4]; + idv3 = idv[(j + 2) % 4]; + idv4 = idv[(j + 3) % 4]; + + v1 = sys->vertexCos[idv1]; + v2 = sys->vertexCos[idv2]; + v3 = sys->vertexCos[idv3]; + v4 = sys->vertexCos[idv4]; + + w2 = cotan_weight(v4, v1, v2) + cotan_weight(v3, v1, v2); + w3 = cotan_weight(v2, v3, v1) + cotan_weight(v4, v1, v3); + w4 = cotan_weight(v2, v4, v1) + cotan_weight(v3, v4, v1); + + w2 = w2 / 4.0f; + w3 = w3 / 4.0f; + w4 = w4 / 4.0f; + + if (sys->numNeEd[idv1] == sys->numNeFa[idv1] && sys->zerola[idv1] == 0) { + nlMatrixAdd(idv1, idv2, w2 * sys->vweights[idv1]); + nlMatrixAdd(idv1, idv3, w3 * sys->vweights[idv1]); + nlMatrixAdd(idv1, idv4, w4 * sys->vweights[idv1]); + } + } + } + else { + /* Is ring if number of faces == number of edges around vertice*/ + if (sys->numNeEd[idv1] == sys->numNeFa[idv1] && sys->zerola[idv1] == 0) { + nlMatrixAdd(idv1, idv2, sys->fweights[i][2] * sys->vweights[idv1]); + nlMatrixAdd(idv1, idv3, sys->fweights[i][1] * sys->vweights[idv1]); + } + if (sys->numNeEd[idv2] == sys->numNeFa[idv2] && sys->zerola[idv2] == 0) { + nlMatrixAdd(idv2, idv1, sys->fweights[i][2] * sys->vweights[idv2]); + nlMatrixAdd(idv2, idv3, sys->fweights[i][0] * sys->vweights[idv2]); + } + if (sys->numNeEd[idv3] == sys->numNeFa[idv3] && sys->zerola[idv3] == 0) { + nlMatrixAdd(idv3, idv1, sys->fweights[i][1] * sys->vweights[idv3]); + nlMatrixAdd(idv3, idv2, sys->fweights[i][0] * sys->vweights[idv3]); + } + } + } + + for (i = 0; i < sys->numEdges; i++) { + idv1 = sys->medges[i].v1; + idv2 = sys->medges[i].v2; + /* Is boundary */ + if (sys->numNeEd[idv1] != sys->numNeFa[idv1] && + sys->numNeEd[idv2] != sys->numNeFa[idv2] && + sys->zerola[idv1] == 0 && + sys->zerola[idv2] == 0) + { + nlMatrixAdd(idv1, idv2, sys->eweights[i] * sys->vlengths[idv1]); + nlMatrixAdd(idv2, idv1, sys->eweights[i] * sys->vlengths[idv2]); + } + } +} + +static void validate_solution(LaplacianSystem *sys, short flag) +{ + int i, idv1, idv2; + float leni, lene; + float vini, vend; + float *vi1, *vi2, ve1[3], ve2[3]; + if (flag & MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION) { + vini = compute_volume(sys->vertexCos, sys->mfaces, sys->numFaces); + } + for (i = 0; i < sys->numEdges; i++) { + idv1 = sys->medges[i].v1; + idv2 = sys->medges[i].v2; + vi1 = sys->vertexCos[idv1]; + vi2 = sys->vertexCos[idv2]; + ve1[0] = nlGetVariable(0, idv1); + ve1[1] = nlGetVariable(1, idv1); + ve1[2] = nlGetVariable(2, idv1); + ve2[0] = nlGetVariable(0, idv2); + ve2[1] = nlGetVariable(1, idv2); + ve2[2] = nlGetVariable(2, idv2); + leni = len_v3v3(vi1, vi2); + lene = len_v3v3(ve1, ve2); + if (lene > leni * MOD_LAPLACIANSMOOTH_MAX_EDGE_PERCENTAGE || lene < leni * MOD_LAPLACIANSMOOTH_MIN_EDGE_PERCENTAGE) { + sys->zerola[idv1] = 1; + sys->zerola[idv2] = 1; + } + } + for (i = 0; i < sys->numVerts; i++) { + if (sys->zerola[i] == 0) { + if (flag & MOD_LAPLACIANSMOOTH_X) { + sys->vertexCos[i][0] = nlGetVariable(0, i); + } + if (flag & MOD_LAPLACIANSMOOTH_Y) { + sys->vertexCos[i][1] = nlGetVariable(1, i); + } + if (flag & MOD_LAPLACIANSMOOTH_Z) { + sys->vertexCos[i][2] = nlGetVariable(2, i); + } + } + } + if (flag & MOD_LAPLACIANSMOOTH_VOLUME_PRESERVATION) { + vend = compute_volume(sys->vertexCos, sys->mfaces, sys->numFaces); + volume_preservation(sys, vini, vend, flag); + } +} + +static void laplaciansmoothModifier_do( + LaplacianSmoothModifierData *smd, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) +{ + LaplacianSystem *sys; + MDeformVert *dvert = NULL; + MDeformVert *dv = NULL; + float w, wpaint; + int i, iter; + int defgrp_index; + + DM_ensure_tessface(dm); + + sys = init_laplacian_system(dm->getNumEdges(dm), dm->getNumTessFaces(dm), numVerts); + if (!sys) { + return; + } + + sys->mfaces = dm->getTessFaceArray(dm); + sys->medges = dm->getEdgeArray(dm); + sys->vertexCos = vertexCos; + sys->min_area = 0.00001f; + modifier_get_vgroup(ob, dm, smd->defgrp_name, &dvert, &defgrp_index); + + sys->vert_centroid[0] = 0.0f; + sys->vert_centroid[1] = 0.0f; + sys->vert_centroid[2] = 0.0f; + for (iter = 0; iter < smd->repeat; iter++) { + memset_laplacian_system(sys, 0); + nlNewContext(); + sys->context = nlGetCurrent(); + nlSolverParameteri(NL_NB_VARIABLES, numVerts); + nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE); + nlSolverParameteri(NL_NB_ROWS, numVerts); + nlSolverParameteri(NL_NB_RIGHT_HAND_SIDES, 3); + + init_laplacian_matrix(sys); + + nlBegin(NL_SYSTEM); + for (i = 0; i < numVerts; i++) { + nlSetVariable(0, i, vertexCos[i][0]); + nlSetVariable(1, i, vertexCos[i][1]); + nlSetVariable(2, i, vertexCos[i][2]); + if (iter == 0) { + add_v3_v3(sys->vert_centroid, vertexCos[i]); + } + } + if (iter == 0 && numVerts > 0) { + mul_v3_fl(sys->vert_centroid, 1.0f / (float)numVerts); + } + + nlBegin(NL_MATRIX); + dv = dvert; + for (i = 0; i < numVerts; i++) { + nlRightHandSideAdd(0, i, vertexCos[i][0]); + nlRightHandSideAdd(1, i, vertexCos[i][1]); + nlRightHandSideAdd(2, i, vertexCos[i][2]); + if (dv) { + wpaint = defvert_find_weight(dv, defgrp_index); + dv++; + } + else { + wpaint = 1.0f; + } + + if (sys->zerola[i] == 0) { + w = sys->vweights[i] * sys->ring_areas[i]; + sys->vweights[i] = (w == 0.0f) ? 0.0f : -smd->lambda * wpaint / (4.0f * w); + w = sys->vlengths[i]; + sys->vlengths[i] = (w == 0.0f) ? 0.0f : -smd->lambda_border * wpaint * 2.0f / w; + + if (sys->numNeEd[i] == sys->numNeFa[i]) { + nlMatrixAdd(i, i, 1.0f + smd->lambda * wpaint / (4.0f * sys->ring_areas[i])); + } + else { + nlMatrixAdd(i, i, 1.0f + smd->lambda_border * wpaint * 2.0f); + } + } + else { + nlMatrixAdd(i, i, 1.0f); + } + } + + fill_laplacian_matrix(sys); + + nlEnd(NL_MATRIX); + nlEnd(NL_SYSTEM); + + if (nlSolveAdvanced(NULL, NL_TRUE)) { + validate_solution(sys, smd->flag); + } + nlDeleteContext(sys->context); + sys->context = NULL; + } + delete_laplacian_system(sys); + +} + +static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, + float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag)) +{ + DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0); + + laplaciansmoothModifier_do((LaplacianSmoothModifierData *)md, ob, dm, + vertexCos, numVerts); + + if (dm != derivedData) + dm->release(dm); +} + +static void deformVertsEM( + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) +{ + DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, 0); + + laplaciansmoothModifier_do((LaplacianSmoothModifierData *)md, ob, dm, + vertexCos, numVerts); + + if (dm != derivedData) + dm->release(dm); +} + + +ModifierTypeInfo modifierType_LaplacianSmooth = { + /* name */ "Laplacian Smooth", + /* structName */ "LaplacianSmoothModifierData", + /* structSize */ sizeof(LaplacianSmoothModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode, + + /* copy_data */ copy_data, + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ NULL, + /* applyModifier */ NULL, + /* applyModifierEM */ NULL, + /* initData */ init_data, + /* requiredDataMask */ required_data_mask, + /* freeData */ NULL, + /* isDisabled */ is_disabled, + /* updateDepgraph */ NULL, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, + /* foreachObjectLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, +}; diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index d64ccf750b2..a5c52c6c76a 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -122,12 +122,12 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, + ModifierData *md, Object *ob, struct BMEditMesh *em, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; - if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); + if (!derivedData) dm = CDDM_from_editbmesh(em, FALSE, FALSE); deformVerts(md, ob, dm, vertexCos, numVerts, 0); diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index ab7263a1b53..f845f1d9dc7 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -226,11 +226,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, int defgrp_index = defgroup_name_index(ob, mmd->vgroup); /* get dverts */ - if (defgrp_index >= 0) + if (defgrp_index != -1) dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); /* if no vgroup (i.e. dverts) found, return the initial mesh */ - if ((defgrp_index < 0) || (dvert == NULL)) + if ((defgrp_index == -1) || (dvert == NULL)) return dm; /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index f0bdf1bb737..f4d9b7270e6 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -218,7 +218,7 @@ static void meshdeformModifier_do( } if (!cagedm) { - modifier_setError(md, "%s", TIP_("Can't get mesh from cage object.")); + modifier_setError(md, "Cannot get mesh from cage object"); return; } @@ -246,17 +246,17 @@ static void meshdeformModifier_do( totcagevert = cagedm->getNumVerts(cagedm); if (mmd->totvert != totvert) { - modifier_setError(md, TIP_("Verts changed from %d to %d."), mmd->totvert, totvert); + modifier_setError(md, "Verts changed from %d to %d", mmd->totvert, totvert); cagedm->release(cagedm); return; } else if (mmd->totcagevert != totcagevert) { - modifier_setError(md, TIP_("Cage verts changed from %d to %d."), mmd->totcagevert, totcagevert); + modifier_setError(md, "Cage verts changed from %d to %d", mmd->totcagevert, totcagevert); cagedm->release(cagedm); return; } else if (mmd->bindcagecos == NULL) { - modifier_setError(md, "%s", TIP_("Bind data missing.")); + modifier_setError(md, "Bind data missing"); cagedm->release(cagedm); return; } @@ -431,28 +431,28 @@ void modifier_mdef_compact_influences(ModifierData *md) } ModifierTypeInfo modifierType_MeshDeform = { - /* name */ "MeshDeform", - /* structName */ "MeshDeformModifierData", - /* structSize */ sizeof(MeshDeformModifierData), - /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs | - eModifierTypeFlag_SupportsEditmode, - - /* copyData */ copyData, - /* deformVerts */ deformVerts, - /* deformMatrices */ NULL, - /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, - /* applyModifier */ NULL, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ freeData, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* name */ "MeshDeform", + /* structName */ "MeshDeformModifierData", + /* structSize */ sizeof(MeshDeformModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, + + /* copyData */ copyData, + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ NULL, + /* applyModifier */ NULL, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ freeData, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c index febc4190fdf..83c678db7b3 100644 --- a/source/blender/modifiers/intern/MOD_mirror.c +++ b/source/blender/modifiers/intern/MOD_mirror.c @@ -43,7 +43,8 @@ #include "BKE_mesh.h" #include "BKE_modifier.h" #include "BKE_deform.h" -#include "BKE_tessmesh.h" + +#include "bmesh.h" #include "MEM_guardedalloc.h" #include "depsgraph_private.h" diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 3bf8b9ffacc..5cef59a462b 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -241,13 +241,13 @@ static void dm_get_bounds(DerivedMesh *dm, float *sx, float *sy, float *ox, floa copy_v3_v3(max, mvert->co); for (v = 1; v < totvert; v++, mvert++) { - min[0] = minf(min[0], mvert->co[0]); - min[1] = minf(min[1], mvert->co[1]); - min[2] = minf(min[2], mvert->co[2]); + min[0] = min_ff(min[0], mvert->co[0]); + min[1] = min_ff(min[1], mvert->co[1]); + min[2] = min_ff(min[2], mvert->co[2]); - max[0] = maxf(max[0], mvert->co[0]); - max[1] = maxf(max[1], mvert->co[1]); - max[2] = maxf(max[2], mvert->co[2]); + max[0] = max_ff(max[0], mvert->co[0]); + max[1] = max_ff(max[1], mvert->co[1]); + max[2] = max_ff(max[2], mvert->co[2]); } sub_v3_v3v3(delta, max, min); diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index 20b02c63605..4984682455a 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -401,32 +401,31 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } - ModifierTypeInfo modifierType_ParticleInstance = { - /* name */ "ParticleInstance", - /* structName */ "ParticleInstanceModifierData", - /* structSize */ sizeof(ParticleInstanceModifierData), - /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh | - eModifierTypeFlag_SupportsMapping | - eModifierTypeFlag_SupportsEditmode | - eModifierTypeFlag_EnableInEditmode, - - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ applyModifierEM, - /* initData */ initData, - /* requiredDataMask */ NULL, - /* freeData */ NULL, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* name */ "ParticleInstance", + /* structName */ "ParticleInstanceModifierData", + /* structSize */ sizeof(ParticleInstanceModifierData), + /* type */ eModifierTypeType_Constructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, + + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ applyModifierEM, + /* initData */ initData, + /* requiredDataMask */ NULL, + /* freeData */ NULL, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c index 2b55471be3d..746cad10a01 100644 --- a/source/blender/modifiers/intern/MOD_remesh.c +++ b/source/blender/modifiers/intern/MOD_remesh.c @@ -223,7 +223,7 @@ ModifierTypeInfo modifierType_Remesh = { /* structSize */ sizeof(RemeshModifierData), /* type */ eModifierTypeType_Nonconstructive, /* flags */ eModifierTypeFlag_AcceptsMesh | - eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index a94b4834d18..93b5e36e5a4 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -215,7 +215,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (totlen != 0.0f) { float zero[3] = {0.0f, 0.0f, 0.0f}; - float cp[3]; + float cp[3]; screw_ofs = closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec); } else { @@ -363,7 +363,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, */ vert_connect = MEM_mallocN(sizeof(ScrewVertConnect) * totvert, "ScrewVertConnect"); - //vert_connect= (ScrewVertConnect *) &medge_new[totvert]; /* skip the first slice of verts */ + //vert_connect = (ScrewVertConnect *) &medge_new[totvert]; /* skip the first slice of verts */ vc = vert_connect; /* Copy Vert Locations */ @@ -475,7 +475,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /*printf("\t\tVERT: %i\n", lt_iter.v);*/ if (lt_iter.v_poin->flag) { /*printf("\t\t\tBreaking Found end\n");*/ - //endpoints[0]= endpoints[1]= -1; + //endpoints[0] = endpoints[1] = -1; ed_loop_closed = 1; /* circle */ break; } @@ -490,7 +490,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, screwvert_iter_step(<_iter); if (!lt_iter.v_poin) { /*printf("\t\t\tFound End Also Num %i\n", j);*/ - /*endpoints[j]= lt_iter.v_other;*/ /* other is still valid */ + /*endpoints[j] = lt_iter.v_other;*/ /* other is still valid */ break; } } @@ -732,7 +732,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, copy_v3_v3(mv_new->co, mv_new_base->co); /* only need to set these if using non cleared memory */ - /*mv_new->mat_nr= mv_new->flag= 0;*/ + /*mv_new->mat_nr = mv_new->flag = 0;*/ if (ltmd->ob_axis) { sub_v3_v3(mv_new->co, mtx_tx[3]); @@ -831,7 +831,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* close the loop*/ - if (close) { + if (close) { if (do_flip) { ml_new[3].v = i1; ml_new[2].v = i2; diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c index 8ef86362edd..7fe8dc69790 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.c @@ -122,6 +122,7 @@ static void deformMatricesEM(ModifierData *UNUSED(md), Object *ob, } } + ModifierTypeInfo modifierType_ShapeKey = { /* name */ "ShapeKey", /* structName */ "ShapeKeyModifierData", diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c index 45cd33efea8..d3a03614d7c 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c @@ -163,30 +163,30 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, ModifierTypeInfo modifierType_Shrinkwrap = { - /* name */ "Shrinkwrap", - /* structName */ "ShrinkwrapModifierData", - /* structSize */ sizeof(ShrinkwrapModifierData), - /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh | - eModifierTypeFlag_AcceptsCVs | - eModifierTypeFlag_SupportsEditmode | - eModifierTypeFlag_EnableInEditmode, - - /* copyData */ copyData, - /* deformVerts */ deformVerts, - /* deformMatrices */ NULL, - /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, - /* applyModifier */ NULL, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* name */ "Shrinkwrap", + /* structName */ "ShrinkwrapModifierData", + /* structSize */ sizeof(ShrinkwrapModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, + + /* copyData */ copyData, + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ NULL, + /* applyModifier */ NULL, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ NULL, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index 44ebc76e4a1..5267c0d9ccb 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -161,7 +161,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object if (smd->limit[0] < 0.0f) smd->limit[0] = 0.0f; if (smd->limit[0] > 1.0f) smd->limit[0] = 1.0f; - smd->limit[0] = minf(smd->limit[0], smd->limit[1]); /* Upper limit >= than lower limit */ + smd->limit[0] = min_ff(smd->limit[0], smd->limit[1]); /* Upper limit >= than lower limit */ /* Calculate matrixs do convert between coordinate spaces */ if (smd->origin) { @@ -191,8 +191,8 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object if (transf) space_transform_apply(transf, tmp); - lower = minf(lower, tmp[limit_axis]); - upper = maxf(upper, tmp[limit_axis]); + lower = min_ff(lower, tmp[limit_axis]); + upper = max_ff(upper, tmp[limit_axis]); } @@ -200,7 +200,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object smd_limit[1] = lower + (upper - lower) * smd->limit[1]; smd_limit[0] = lower + (upper - lower) * smd->limit[0]; - smd_factor = smd->factor / maxf(FLT_EPSILON, smd_limit[1] - smd_limit[0]); + smd_factor = smd->factor / max_ff(FLT_EPSILON, smd_limit[1] - smd_limit[0]); } modifier_get_vgroup(ob, dm, smd->vgroup_name, &dvert, &vgroup); @@ -353,9 +353,9 @@ ModifierTypeInfo modifierType_SimpleDeform = { /* type */ eModifierTypeType_OnlyDeform, /* flags */ eModifierTypeFlag_AcceptsMesh | - eModifierTypeFlag_AcceptsCVs | - eModifierTypeFlag_SupportsEditmode | - eModifierTypeFlag_EnableInEditmode, + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 222f13185ea..5cc38ff0489 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -77,7 +77,8 @@ #include "BKE_DerivedMesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" -#include "BKE_tessmesh.h" + +#include "bmesh.h" #include "MOD_util.h" @@ -143,6 +144,7 @@ static int is_quad_symmetric(BMVert *quad[4], const SkinModifierData *smd) { const float threshold = 0.0001f; + const float threshold_squared = threshold * threshold; int axis; for (axis = 0; axis < 3; axis++) { @@ -152,16 +154,16 @@ static int is_quad_symmetric(BMVert *quad[4], copy_v3_v3(a, quad[0]->co); a[axis] = -a[axis]; - if (len_v3v3(a, quad[1]->co) < threshold) { + if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) { copy_v3_v3(a, quad[2]->co); a[axis] = -a[axis]; - if (len_v3v3(a, quad[3]->co) < threshold) + if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) return 1; } - else if (len_v3v3(a, quad[3]->co) < threshold) { + else if (len_squared_v3v3(a, quad[3]->co) < threshold_squared) { copy_v3_v3(a, quad[2]->co); a[axis] = -a[axis]; - if (len_v3v3(a, quad[1]->co) < threshold) + if (len_squared_v3v3(a, quad[1]->co) < threshold_squared) return 1; } } @@ -178,13 +180,13 @@ static int quad_crosses_symmetry_plane(BMVert *quad[4], for (axis = 0; axis < 3; axis++) { if (smd->symmetry_axes & (1 << axis)) { - int i, left = 0, right = 0; + int i, left = FALSE, right = FALSE; for (i = 0; i < 4; i++) { - if (quad[i]->co[axis] < 0) - left = 1; - else if (quad[i]->co[axis] > 0) - right = 1; + if (quad[i]->co[axis] < 0.0f) + left = TRUE; + else if (quad[i]->co[axis] > 0.0f) + right = TRUE; if (left && right) return TRUE; @@ -355,7 +357,7 @@ static void merge_frame_corners(Frame **frames, int totframe) BLI_assert(frames[i] != frames[k]); side_b = frame_len(frames[k]); - thresh = minf(side_a, side_b) / 2.0f; + thresh = min_ff(side_a, side_b) / 2.0f; /* Compare with each corner of all other frames... */ for (l = 0; l < 4; l++) { @@ -1422,7 +1424,7 @@ static void hull_merge_triangles(SkinOutput *so, const SkinModifierData *smd) } } - while (!BLI_heap_empty(heap)) { + while (!BLI_heap_is_empty(heap)) { BMFace *adj[2]; e = BLI_heap_popmin(heap); @@ -1544,23 +1546,23 @@ static void skin_output_end_nodes(SkinOutput *so, SkinNode *skin_nodes, if (sn->flag & CAP_START) { if (sn->flag & ROOT) { add_poly(so, - sn->frames[0].verts[0], - sn->frames[0].verts[1], - sn->frames[0].verts[2], - sn->frames[0].verts[3]); + sn->frames[0].verts[0], + sn->frames[0].verts[1], + sn->frames[0].verts[2], + sn->frames[0].verts[3]); } else { add_poly(so, - sn->frames[0].verts[3], - sn->frames[0].verts[2], - sn->frames[0].verts[1], - sn->frames[0].verts[0]); + sn->frames[0].verts[3], + sn->frames[0].verts[2], + sn->frames[0].verts[1], + sn->frames[0].verts[0]); } } if (sn->flag & CAP_END) { add_poly(so, sn->frames[1].verts[0], - sn->frames[1].verts[1], + sn->frames[1].verts[1], sn->frames[1].verts[2], sn->frames[1].verts[3]); } @@ -1770,7 +1772,6 @@ static void skin_set_orig_indices(DerivedMesh *dm) static DerivedMesh *base_skin(DerivedMesh *origdm, SkinModifierData *smd) { - BMEditMesh fake_em; DerivedMesh *result; MVertSkin *nodes; BMesh *bm; @@ -1807,8 +1808,7 @@ static DerivedMesh *base_skin(DerivedMesh *origdm, if (!bm) return NULL; - fake_em.bm = bm; - result = CDDM_from_BMEditMesh(&fake_em, NULL, FALSE, FALSE); + result = CDDM_from_bmesh(bm, FALSE); BM_mesh_free(bm); CDDM_calc_edges(result); @@ -1861,7 +1861,7 @@ static void copyData(ModifierData *md, ModifierData *target) static DerivedMesh *applyModifierEM(ModifierData *md, Object *UNUSED(ob), - BMEditMesh *UNUSED(em), + struct BMEditMesh *UNUSED(em), DerivedMesh *dm) { DerivedMesh *result; diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index 545e2135344..1d35d8f55bf 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -250,7 +250,7 @@ ModifierTypeInfo modifierType_Smooth = { /* structSize */ sizeof(SmoothModifierData), /* type */ eModifierTypeType_OnlyDeform, /* flags */ eModifierTypeFlag_AcceptsMesh | - eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 1dbbe14e643..3b769a30994 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -199,7 +199,7 @@ DerivedMesh *get_dm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float (* return dm; if (ob->type == OB_MESH) { - if (em) dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE); + if (em) dm = CDDM_from_editbmesh(em, FALSE, FALSE); else dm = CDDM_from_mesh((struct Mesh *)(ob->data), ob); if (vertexCos) { @@ -222,7 +222,7 @@ void modifier_get_vgroup(Object *ob, DerivedMesh *dm, const char *name, MDeformV *defgrp_index = defgroup_name_index(ob, name); *dvert = NULL; - if (*defgrp_index >= 0) { + if (*defgrp_index != -1) { if (ob->type == OB_LATTICE) *dvert = BKE_lattice_deform_verts_get(ob); else if (dm) @@ -277,5 +277,6 @@ void modifier_type_init(ModifierTypeInfo *types[]) INIT_TYPE(DynamicPaint); INIT_TYPE(Remesh); INIT_TYPE(Skin); + INIT_TYPE(LaplacianSmooth); #undef INIT_TYPE } diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h index eadf7af553b..6f05c9a957a 100644 --- a/source/blender/modifiers/intern/MOD_util.h +++ b/source/blender/modifiers/intern/MOD_util.h @@ -42,10 +42,14 @@ struct TexResult; void modifier_init_texture(struct Scene *scene, struct Tex *texture); void get_texture_value(struct Tex *texture, float *tex_co, struct TexResult *texres); -void get_texture_coords(struct MappingInfoModifierData *dmd, struct Object *ob, struct DerivedMesh *dm, float (*co)[3], float (*texco)[3], int numVerts); +void get_texture_coords(struct MappingInfoModifierData *dmd, struct Object *ob, struct DerivedMesh *dm, + float (*co)[3], float (*texco)[3], int numVerts); void modifier_vgroup_cache(struct ModifierData *md, float (*vertexCos)[3]); -struct DerivedMesh *get_cddm(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3]); -struct DerivedMesh *get_dm(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, float (*vertexCos)[3], int orco); -void modifier_get_vgroup(struct Object *ob, struct DerivedMesh *dm, const char *name, struct MDeformVert **dvert, int *defgrp_index); +struct DerivedMesh *get_cddm(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, + float (*vertexCos)[3]); +struct DerivedMesh *get_dm(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm, + float (*vertexCos)[3], int orco); +void modifier_get_vgroup(struct Object *ob, struct DerivedMesh *dm, + const char *name, struct MDeformVert **dvert, int *defgrp_index); #endif /* __MOD_UTIL_H__ */ diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 95f6ef60665..c2a62231529 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -238,7 +238,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, (fac = (wmd->falloff_radius - fac) / wmd->falloff_radius))) { /* skip if no vert group found */ - if (dvert && defgrp_index >= 0) { + if (dvert && defgrp_index != -1) { dv = &dvert[i]; if (dv) { @@ -337,7 +337,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, } } -static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData, +static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *em, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; @@ -345,7 +345,7 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD if (use_dm) { if (!derivedData) - dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); + dm = CDDM_from_editbmesh(em, FALSE, FALSE); } deformVerts(md, ob, dm, vertexCos, numVerts, 0); @@ -357,27 +357,27 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD ModifierTypeInfo modifierType_Warp = { - /* name */ "Warp", - /* structName */ "WarpModifierData", - /* structSize */ sizeof(WarpModifierData), - /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs | - eModifierTypeFlag_SupportsEditmode, - /* copyData */ copyData, - /* deformVerts */ deformVerts, - /* deformMatrices */ NULL, - /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, - /* applyModifier */ 0, - /* applyModifierEM */ 0, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ freeData, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* name */ "Warp", + /* structName */ "WarpModifierData", + /* structSize */ sizeof(WarpModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, + /* copyData */ copyData, + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ NULL, + /* applyModifier */ 0, + /* applyModifierEM */ 0, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ freeData, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ foreachIDLink, - /* foreachTexLink */ foreachTexLink, + /* foreachIDLink */ foreachIDLink, + /* foreachTexLink */ foreachTexLink, }; diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index ce6295e30cf..779ac6b5ecf 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -185,7 +185,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der float *org_w; /* Array original weights. */ float *new_w; /* Array new weights. */ int numVerts; - int defgrp_idx; + int defgrp_index; int i; /* Flags. */ int do_add = (wmd->edit_flags & MOD_WVG_EDIT_ADD2VG) != 0; @@ -205,8 +205,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der return dm; /* Get vgroup idx from its name. */ - defgrp_idx = defgroup_name_index(ob, wmd->defgrp_name); - if (defgrp_idx < 0) + defgrp_index = defgroup_name_index(ob, wmd->defgrp_name); + if (defgrp_index == -1) return dm; dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); @@ -228,7 +228,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der 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++) { - dw[i] = defvert_find_index(&dvert[i], defgrp_idx); + dw[i] = defvert_find_index(&dvert[i], defgrp_index); if (dw[i]) { org_w[i] = new_w[i] = dw[i]->weight; } @@ -249,7 +249,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der wmd->mask_tex_map_obj, wmd->mask_tex_uvlayer_name); /* Update/add/remove from vgroup. */ - weightvg_update_vg(dvert, defgrp_idx, dw, numVerts, NULL, org_w, do_add, wmd->add_threshold, + weightvg_update_vg(dvert, defgrp_index, dw, numVerts, NULL, org_w, do_add, wmd->add_threshold, do_rem, wmd->rem_threshold); /* If weight preview enabled... */ diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 2961082b448..5883b176317 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -225,7 +225,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der MDeformVert *dvert = NULL; MDeformWeight **dw1, **tdw1, **dw2, **tdw2; int numVerts; - int defgrp_idx, defgrp_idx2 = -1; + int defgrp_index, defgrp_index_other = -1; float *org_w; float *new_w; int *tidx, *indices = NULL; @@ -246,13 +246,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der return dm; /* Get vgroup idx from its name. */ - defgrp_idx = defgroup_name_index(ob, wmd->defgrp_name_a); - if (defgrp_idx < 0) + defgrp_index = defgroup_name_index(ob, wmd->defgrp_name_a); + if (defgrp_index == -1) return dm; /* Get seconf vgroup idx from its name, if given. */ if (wmd->defgrp_name_b[0] != (char)0) { - defgrp_idx2 = defgroup_name_index(ob, wmd->defgrp_name_b); - if (defgrp_idx2 < 0) + defgrp_index_other = defgroup_name_index(ob, wmd->defgrp_name_b); + if (defgrp_index_other == -1) return dm; } @@ -277,10 +277,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der case MOD_WVG_SET_A: /* All vertices in first vgroup. */ for (i = 0; i < numVerts; i++) { - MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx); + MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_index); if (dw) { tdw1[numIdx] = dw; - tdw2[numIdx] = defvert_find_index(&dvert[i], defgrp_idx2); + tdw2[numIdx] = defvert_find_index(&dvert[i], defgrp_index_other); tidx[numIdx++] = i; } } @@ -288,9 +288,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der case MOD_WVG_SET_B: /* All vertices in second vgroup. */ for (i = 0; i < numVerts; i++) { - MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx2); + MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_index_other); if (dw) { - tdw1[numIdx] = defvert_find_index(&dvert[i], defgrp_idx); + tdw1[numIdx] = defvert_find_index(&dvert[i], defgrp_index); tdw2[numIdx] = dw; tidx[numIdx++] = i; } @@ -299,8 +299,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der case MOD_WVG_SET_OR: /* All vertices in one vgroup or the other. */ for (i = 0; i < numVerts; i++) { - MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); - MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); + MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_index); + MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_index_other); if (adw || bdw) { tdw1[numIdx] = adw; tdw2[numIdx] = bdw; @@ -311,8 +311,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der case MOD_WVG_SET_AND: /* All vertices in both vgroups. */ for (i = 0; i < numVerts; i++) { - MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); - MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); + MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_index); + MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_index_other); if (adw && bdw) { tdw1[numIdx] = adw; tdw2[numIdx] = bdw; @@ -324,8 +324,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der default: /* 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); + tdw1[i] = defvert_find_index(&dvert[i], defgrp_index); + tdw2[i] = defvert_find_index(&dvert[i], defgrp_index_other); } numIdx = -1; break; @@ -377,7 +377,7 @@ 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, dw1, numIdx, indices, org_w, TRUE, -FLT_MAX, FALSE, 0.0f); + weightvg_update_vg(dvert, defgrp_index, dw1, numIdx, indices, org_w, TRUE, -FLT_MAX, FALSE, 0.0f); /* If weight preview enabled... */ #if 0 /* XXX Currently done in mod stack :/ */ diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 25a2a61d8e3..e936e571a5b 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -347,7 +347,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der int numVerts; float (*v_cos)[3] = NULL; /* The vertices coordinates. */ Object *obr = NULL; /* Our target object. */ - int defgrp_idx; + int defgrp_index; float *tw = NULL; float *org_w = NULL; float *new_w = NULL; @@ -378,8 +378,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der return dm; /* Get vgroup idx from its name. */ - defgrp_idx = defgroup_name_index(ob, wmd->defgrp_name); - if (defgrp_idx < 0) + defgrp_index = defgroup_name_index(ob, wmd->defgrp_name); + if (defgrp_index == -1) return dm; dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); @@ -394,7 +394,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der tw = MEM_mallocN(sizeof(float) * numVerts, "WeightVGProximity Modifier, tw"); tdw = MEM_mallocN(sizeof(MDeformWeight *) * numVerts, "WeightVGProximity Modifier, tdw"); for (i = 0; i < numVerts; i++) { - MDeformWeight *_dw = defvert_find_index(&dvert[i], defgrp_idx); + MDeformWeight *_dw = defvert_find_index(&dvert[i], defgrp_index); if (_dw) { tidx[numIdx] = i; tw[numIdx] = _dw->weight; @@ -460,7 +460,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der else if (obr->type == OB_MESH) { Mesh *me = (Mesh *)obr->data; if (me->edit_btmesh) - target_dm = CDDM_from_BMEditMesh(me->edit_btmesh, me, FALSE, FALSE); + target_dm = CDDM_from_editbmesh(me->edit_btmesh, FALSE, FALSE); else target_dm = CDDM_from_mesh(me, obr); } @@ -480,9 +480,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der for (i = 0; i < numIdx; i++) { new_w[i] = dists_v ? dists_v[i] : FLT_MAX; if (dists_e) - new_w[i] = minf(dists_e[i], new_w[i]); + new_w[i] = min_ff(dists_e[i], new_w[i]); if (dists_f) - new_w[i] = minf(dists_f[i], new_w[i]); + new_w[i] = min_ff(dists_f[i], new_w[i]); } if (free_target_dm) target_dm->release(target_dm); if (dists_v) MEM_freeN(dists_v); @@ -509,7 +509,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der 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, dw, numIdx, indices, org_w, FALSE, 0.0f, FALSE, 0.0f); + weightvg_update_vg(dvert, defgrp_index, dw, numIdx, indices, org_w, FALSE, 0.0f, FALSE, 0.0f); /* If weight preview enabled... */ #if 0 /* XXX Currently done in mod stack :/ */ diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 3fd9bfecedf..19b3df8affe 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -23,7 +23,7 @@ # # ***** END GPL LICENSE BLOCK ***** -set(INC +set(INC . composite intern @@ -119,7 +119,8 @@ set(SRC composite/nodes/node_composite_ellipsemask.c composite/nodes/node_composite_switch.c composite/nodes/node_composite_colorcorrection.c - + composite/nodes/node_composite_pixelate.c + composite/node_composite_tree.c composite/node_composite_util.c diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h index bcef230e1d0..ee67ac88085 100644 --- a/source/blender/nodes/NOD_composite.h +++ b/source/blender/nodes/NOD_composite.h @@ -96,7 +96,7 @@ void register_node_type_cmp_combhsva(struct bNodeTreeType *ttype); void register_node_type_cmp_sepyuva(struct bNodeTreeType *ttype); void register_node_type_cmp_combyuva(struct bNodeTreeType *ttype); void register_node_type_cmp_sepycca(struct bNodeTreeType *ttype); -void register_node_type_cmp_combycca(struct bNodeTreeType *ttype); +void register_node_type_cmp_combycca(struct bNodeTreeType *ttype); void register_node_type_cmp_premulkey(struct bNodeTreeType *ttype); void register_node_type_cmp_diff_matte(struct bNodeTreeType *ttype); @@ -105,7 +105,7 @@ void register_node_type_cmp_chroma_matte(struct bNodeTreeType *ttype); void register_node_type_cmp_color_matte(struct bNodeTreeType *ttype); void register_node_type_cmp_channel_matte(struct bNodeTreeType *ttype); void register_node_type_cmp_color_spill(struct bNodeTreeType *ttype); -void register_node_type_cmp_luma_matte(struct bNodeTreeType *ttype); +void register_node_type_cmp_luma_matte(struct bNodeTreeType *ttype); void register_node_type_cmp_doubleedgemask(struct bNodeTreeType *ttype); void register_node_type_cmp_keyingscreen(struct bNodeTreeType *ttype); void register_node_type_cmp_keying(struct bNodeTreeType *ttype); @@ -133,7 +133,7 @@ void register_node_type_cmp_ellipsemask(struct bNodeTreeType *ttype); void register_node_type_cmp_bokehimage(struct bNodeTreeType *ttype); void register_node_type_cmp_bokehblur(struct bNodeTreeType *ttype); void register_node_type_cmp_switch(struct bNodeTreeType *ttype); - +void register_node_type_cmp_pixelate(struct bNodeTreeType *ttype); void register_node_type_cmp_trackpos(struct bNodeTreeType *ttype); #endif diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 0d86ada8026..9a7e587ff56 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -273,7 +273,7 @@ bNodeTreeType ntreeType_Composite = { /* update */ update, /* update_node */ update_node, /* validate_link */ NULL, - /* internal_connect */ node_internal_connect_default + /* update_internal_links */ node_update_internal_links_default }; @@ -301,7 +301,7 @@ struct bNodeTreeExec *ntreeCompositBeginExecTree(bNodeTree *ntree, int use_tree_ for (node= exec->nodetree->nodes.first; node; node= node->next) { /* initialize needed for groups */ - node->exec= 0; + node->exec= 0; for (sock= node->outputs.first; sock; sock= sock->next) { bNodeStack *ns= node_get_socket_stack(exec->stack, sock); diff --git a/source/blender/nodes/composite/node_composite_util.c b/source/blender/nodes/composite/node_composite_util.c index ad2d26d7c27..57eb99021f6 100644 --- a/source/blender/nodes/composite/node_composite_util.c +++ b/source/blender/nodes/composite/node_composite_util.c @@ -72,7 +72,7 @@ CompBuf *dupalloc_compbuf(CompBuf *cbuf) dupbuf->xof= cbuf->xof; dupbuf->yof= cbuf->yof; - } + } return dupbuf; } @@ -94,7 +94,7 @@ CompBuf *pass_on_compbuf(CompBuf *cbuf) break; lastbuf->next= dupbuf; dupbuf->prev= lastbuf; - } + } return dupbuf; } @@ -213,53 +213,53 @@ void typecheck_compbuf_color(float *out, float *in, int outtype, int intype) } else if (outtype==CB_VEC2) { if (intype==CB_VAL) { - out[0]= in[0]; - out[1]= in[0]; + out[0] = in[0]; + out[1] = in[0]; } else if (intype==CB_VEC3) { - out[0]= in[0]; - out[1]= in[1]; + out[0] = in[0]; + out[1] = in[1]; } else if (intype==CB_RGBA) { - out[0]= in[0]; - out[1]= in[1]; + out[0] = in[0]; + out[1] = in[1]; } } else if (outtype==CB_VEC3) { if (intype==CB_VAL) { - out[0]= in[0]; - out[1]= in[0]; - out[2]= in[0]; + out[0] = in[0]; + out[1] = in[0]; + out[2] = in[0]; } else if (intype==CB_VEC2) { - out[0]= in[0]; - out[1]= in[1]; - out[2]= 0.0f; + out[0] = in[0]; + out[1] = in[1]; + out[2] = 0.0f; } else if (intype==CB_RGBA) { - out[0]= in[0]; - out[1]= in[1]; - out[2]= in[2]; + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; } } else if (outtype==CB_RGBA) { if (intype==CB_VAL) { - out[0]= in[0]; - out[1]= in[0]; - out[2]= in[0]; - out[3]= 1.0f; + out[0] = in[0]; + out[1] = in[0]; + out[2] = in[0]; + out[3] = 1.0f; } else if (intype==CB_VEC2) { - out[0]= in[0]; - out[1]= in[1]; - out[2]= 0.0f; - out[3]= 1.0f; + out[0] = in[0]; + out[1] = in[1]; + out[2] = 0.0f; + out[3] = 1.0f; } else if (intype==CB_VEC3) { - out[0]= in[0]; - out[1]= in[1]; - out[2]= in[2]; - out[3]= 1.0f; + out[0] = in[0]; + out[1] = in[1]; + out[2] = in[2]; + out[3] = 1.0f; } } } @@ -307,69 +307,69 @@ CompBuf *typecheck_compbuf(CompBuf *inbuf, int type) else if (type==CB_VEC2) { if (inbuf->type==CB_VAL) { for (; x>0; x--, outrf+= 2, inrf+= 1) { - outrf[0]= inrf[0]; - outrf[1]= inrf[0]; + outrf[0] = inrf[0]; + outrf[1] = inrf[0]; } } else if (inbuf->type==CB_VEC3) { for (; x>0; x--, outrf+= 2, inrf+= 3) { - outrf[0]= inrf[0]; - outrf[1]= inrf[1]; + outrf[0] = inrf[0]; + outrf[1] = inrf[1]; } } else if (inbuf->type==CB_RGBA) { for (; x>0; x--, outrf+= 2, inrf+= 4) { - outrf[0]= inrf[0]; - outrf[1]= inrf[1]; + outrf[0] = inrf[0]; + outrf[1] = inrf[1]; } } } else if (type==CB_VEC3) { if (inbuf->type==CB_VAL) { for (; x>0; x--, outrf+= 3, inrf+= 1) { - outrf[0]= inrf[0]; - outrf[1]= inrf[0]; - outrf[2]= inrf[0]; + outrf[0] = inrf[0]; + outrf[1] = inrf[0]; + outrf[2] = inrf[0]; } } else if (inbuf->type==CB_VEC2) { for (; x>0; x--, outrf+= 3, inrf+= 2) { - outrf[0]= inrf[0]; - outrf[1]= inrf[1]; - outrf[2]= 0.0f; + outrf[0] = inrf[0]; + outrf[1] = inrf[1]; + outrf[2] = 0.0f; } } else if (inbuf->type==CB_RGBA) { for (; x>0; x--, outrf+= 3, inrf+= 4) { - outrf[0]= inrf[0]; - outrf[1]= inrf[1]; - outrf[2]= inrf[2]; + outrf[0] = inrf[0]; + outrf[1] = inrf[1]; + outrf[2] = inrf[2]; } } } else if (type==CB_RGBA) { if (inbuf->type==CB_VAL) { for (; x>0; x--, outrf+= 4, inrf+= 1) { - outrf[0]= inrf[0]; - outrf[1]= inrf[0]; - outrf[2]= inrf[0]; - outrf[3]= 1.0f; + outrf[0] = inrf[0]; + outrf[1] = inrf[0]; + outrf[2] = inrf[0]; + outrf[3] = 1.0f; } } else if (inbuf->type==CB_VEC2) { for (; x>0; x--, outrf+= 4, inrf+= 2) { - outrf[0]= inrf[0]; - outrf[1]= inrf[1]; - outrf[2]= 0.0f; - outrf[3]= 1.0f; + outrf[0] = inrf[0]; + outrf[1] = inrf[1]; + outrf[2] = 0.0f; + outrf[3] = 1.0f; } } else if (inbuf->type==CB_VEC3) { for (; x>0; x--, outrf+= 4, inrf+= 3) { - outrf[0]= inrf[0]; - outrf[1]= inrf[1]; - outrf[2]= inrf[2]; - outrf[3]= 1.0f; + outrf[0] = inrf[0]; + outrf[1] = inrf[1]; + outrf[2] = inrf[2]; + outrf[3] = 1.0f; } } } @@ -387,7 +387,7 @@ float *compbuf_get_pixel(CompBuf *cbuf, float *defcol, float *use, int x, int y, return use; } else { - static float col[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + static float col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* map coords */ x-= cbuf->xof; @@ -707,18 +707,18 @@ void do_copy_rgba(bNode *UNUSED(node), float *out, float *in) void do_copy_rgb(bNode *UNUSED(node), float *out, float *in) { copy_v3_v3(out, in); - out[3]= 1.0f; + out[3] = 1.0f; } void do_copy_value(bNode *UNUSED(node), float *out, float *in) { - out[0]= in[0]; + out[0] = in[0]; } void do_copy_a_rgba(bNode *UNUSED(node), float *out, float *in, float *fac) { copy_v3_v3(out, in); - out[3]= *fac; + out[3] = *fac; } /* only accepts RGBA buffers */ @@ -732,16 +732,16 @@ void gamma_correct_compbuf(CompBuf *img, int inversed) drect= img->rect; if (inversed) { for (x=img->x*img->y; x>0; x--, drect+=4) { - if (drect[0]>0.0f) drect[0]= sqrt(drect[0]); else drect[0]= 0.0f; - if (drect[1]>0.0f) drect[1]= sqrt(drect[1]); else drect[1]= 0.0f; - if (drect[2]>0.0f) drect[2]= sqrt(drect[2]); else drect[2]= 0.0f; + if (drect[0]>0.0f) drect[0] = sqrt(drect[0]); else drect[0] = 0.0f; + if (drect[1]>0.0f) drect[1] = sqrt(drect[1]); else drect[1] = 0.0f; + if (drect[2]>0.0f) drect[2] = sqrt(drect[2]); else drect[2] = 0.0f; } } else { for (x=img->x*img->y; x>0; x--, drect+=4) { - if (drect[0]>0.0f) drect[0]*= drect[0]; else drect[0]= 0.0f; - if (drect[1]>0.0f) drect[1]*= drect[1]; else drect[1]= 0.0f; - if (drect[2]>0.0f) drect[2]*= drect[2]; else drect[2]= 0.0f; + if (drect[0]>0.0f) drect[0]*= drect[0]; else drect[0] = 0.0f; + if (drect[1]>0.0f) drect[1]*= drect[1]; else drect[1] = 0.0f; + if (drect[2]>0.0f) drect[2]*= drect[2]; else drect[2] = 0.0f; } } } @@ -757,9 +757,9 @@ void premul_compbuf(CompBuf *img, int inversed) if (inversed) { for (x=img->x*img->y; x>0; x--, drect+=4) { if (fabsf(drect[3]) < 1e-5f) { - drect[0]= 0.0f; - drect[1]= 0.0f; - drect[2]= 0.0f; + drect[0] = 0.0f; + drect[1] = 0.0f; + drect[2] = 0.0f; } else { drect[0] /= drect[3]; diff --git a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c index 86eb0aa2c83..72c2204d8c5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_alphaOver.c +++ b/source/blender/nodes/composite/nodes/node_composite_alphaOver.c @@ -32,13 +32,13 @@ #include "node_composite_util.h" /* **************** ALPHAOVER ******************** */ -static bNodeSocketTemplate cmp_node_alphaover_in[]= { +static bNodeSocketTemplate cmp_node_alphaover_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_alphaover_out[]= { +static bNodeSocketTemplate cmp_node_alphaover_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -48,7 +48,7 @@ static bNodeSocketTemplate cmp_node_alphaover_out[]= { static void do_alphaover_premul(bNode *UNUSED(node), float *out, float *src, float *over, float *fac) { - /* Zero alpha values should still permit an add of RGB data */ + /* Zero alpha values should still permit an add of RGB data */ if (over[3]<0.0f) { copy_v4_v4(out, src); } @@ -58,11 +58,11 @@ static void do_alphaover_premul(bNode *UNUSED(node), float *out, float *src, flo else { float mul= 1.0f - fac[0]*over[3]; - out[0]= (mul*src[0]) + fac[0]*over[0]; - out[1]= (mul*src[1]) + fac[0]*over[1]; - out[2]= (mul*src[2]) + fac[0]*over[2]; - out[3]= (mul*src[3]) + fac[0]*over[3]; - } + out[0] = (mul*src[0]) + fac[0]*over[0]; + out[1] = (mul*src[1]) + fac[0]*over[1]; + out[2] = (mul*src[2]) + fac[0]*over[2]; + out[3] = (mul*src[3]) + fac[0]*over[3]; + } } /* result will be still premul, but the over part is premulled */ @@ -79,10 +79,10 @@ static void do_alphaover_key(bNode *UNUSED(node), float *out, float *src, float float premul= fac[0]*over[3]; float mul= 1.0f - premul; - out[0]= (mul*src[0]) + premul*over[0]; - out[1]= (mul*src[1]) + premul*over[1]; - out[2]= (mul*src[2]) + premul*over[2]; - out[3]= (mul*src[3]) + fac[0]*over[3]; + out[0] = (mul*src[0]) + premul*over[0]; + out[1] = (mul*src[1]) + premul*over[1]; + out[2] = (mul*src[2]) + premul*over[2]; + out[3] = (mul*src[3]) + fac[0]*over[3]; } } @@ -102,10 +102,10 @@ static void do_alphaover_mixed(bNode *node, float *out, float *src, float *over, float premul= fac[0]*addfac; float mul= 1.0f - fac[0]*over[3]; - out[0]= (mul*src[0]) + premul*over[0]; - out[1]= (mul*src[1]) + premul*over[1]; - out[2]= (mul*src[2]) + premul*over[2]; - out[3]= (mul*src[3]) + fac[0]*over[3]; + out[0] = (mul*src[0]) + premul*over[0]; + out[1] = (mul*src[1]) + premul*over[1]; + out[2] = (mul*src[2]) + premul*over[2]; + out[3] = (mul*src[3]) + fac[0]*over[3]; } } diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c index e05ef1ea5a5..7674ace42a3 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c +++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.c @@ -33,14 +33,14 @@ /* **************** BILATERALBLUR ******************** */ static bNodeSocketTemplate cmp_node_bilateralblur_in[] = { - { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, - { SOCK_RGBA, 1, N_("Determinator"), 1.0f, 1.0f, 1.0f, 1.0f}, - { -1, 0, "" } + { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, + { SOCK_RGBA, 1, N_("Determinator"), 1.0f, 1.0f, 1.0f, 1.0f}, + { -1, 0, "" } }; static bNodeSocketTemplate cmp_node_bilateralblur_out[] = { - { SOCK_RGBA, 0, N_("Image")}, - { -1, 0, "" } + { SOCK_RGBA, 0, N_("Image")}, + { -1, 0, "" } }; #ifdef WITH_COMPOSITOR_LEGACY diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c index c5697679f90..8324b77b2d1 100644 --- a/source/blender/nodes/composite/nodes/node_composite_bokehimage.c +++ b/source/blender/nodes/composite/nodes/node_composite_bokehimage.c @@ -37,7 +37,7 @@ /* **************** Bokeh image Tools ******************** */ -static bNodeSocketTemplate cmp_node_bokehimage_out[]= { +static bNodeSocketTemplate cmp_node_bokehimage_out[] = { { SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_boxmask.c b/source/blender/nodes/composite/nodes/node_composite_boxmask.c index 1ba522c0e5f..d3c6b2ccef0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_boxmask.c +++ b/source/blender/nodes/composite/nodes/node_composite_boxmask.c @@ -1,6 +1,4 @@ /* - * $Id: CMP_math.c 36271 2011-04-21 13:11:51Z campbellbarton $ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -35,15 +33,15 @@ #include "../node_composite_util.h" /* **************** SCALAR MATH ******************** */ -static bNodeSocketTemplate cmp_node_boxmask_in[]= { +static bNodeSocketTemplate cmp_node_boxmask_in[] = { { SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - { -1, 0, "" } + { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_boxmask_out[]= { +static bNodeSocketTemplate cmp_node_boxmask_out[] = { { SOCK_FLOAT, 0, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - { -1, 0, "" } + { -1, 0, "" } }; static void node_composit_init_boxmask(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) diff --git a/source/blender/nodes/composite/nodes/node_composite_brightness.c b/source/blender/nodes/composite/nodes/node_composite_brightness.c index 2b8a394d6f2..ecf572f59c7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_brightness.c +++ b/source/blender/nodes/composite/nodes/node_composite_brightness.c @@ -36,13 +36,13 @@ /* **************** Brigh and contrsast ******************** */ -static bNodeSocketTemplate cmp_node_brightcontrast_in[]= { +static bNodeSocketTemplate cmp_node_brightcontrast_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Bright"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("Contrast"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_brightcontrast_out[]= { +static bNodeSocketTemplate cmp_node_brightcontrast_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -72,7 +72,7 @@ static void do_brightnesscontrast(bNode *UNUSED(node), float *out, float *in, fl b = a * (brightness + delta); } - for (c=0; c<3; c++) { + for (c=0; c<3; c++) { i = in[c]; v = a*i + b; out[c] = v; diff --git a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c index 06b77de463b..40dbbbb8dca 100644 --- a/source/blender/nodes/composite/nodes/node_composite_channelMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_channelMatte.c @@ -34,12 +34,12 @@ /* ******************* Channel Matte Node ********************************* */ -static bNodeSocketTemplate cmp_node_channel_matte_in[]={ +static bNodeSocketTemplate cmp_node_channel_matte_in[] ={ {SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, {-1, 0, ""} }; -static bNodeSocketTemplate cmp_node_channel_matte_out[]={ +static bNodeSocketTemplate cmp_node_channel_matte_out[] ={ {SOCK_RGBA, 0, N_("Image")}, {SOCK_FLOAT, 0, N_("Matte")}, {-1, 0, ""} @@ -71,7 +71,7 @@ static void do_normalized_ycca_to_rgba2(bNode *UNUSED(node), float *out, float * static void do_channel_matte(bNode *node, float *out, float *in) { NodeChroma *c=(NodeChroma *)node->storage; - float alpha=0.0; + float alpha=0.0; switch (c->algorithm) { case 0: { /* Alpha=key_channel-limit channel */ diff --git a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c index 55ee1b090bb..f343f806d57 100644 --- a/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_chromaMatte.c @@ -33,13 +33,13 @@ #include "node_composite_util.h" /* ******************* Chroma Key ********************************************************** */ -static bNodeSocketTemplate cmp_node_chroma_in[]={ +static bNodeSocketTemplate cmp_node_chroma_in[] = { {SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, {SOCK_RGBA, 1, N_("Key Color"), 1.0f, 1.0f, 1.0f, 1.0f}, {-1, 0, ""} }; -static bNodeSocketTemplate cmp_node_chroma_out[]={ +static bNodeSocketTemplate cmp_node_chroma_out[] = { {SOCK_RGBA, 0, N_("Image")}, {SOCK_FLOAT, 0, N_("Matte")}, {-1, 0, ""} diff --git a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c index 37fb29811ba..07a6647d976 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorMatte.c @@ -33,13 +33,13 @@ #include "node_composite_util.h" /* ******************* Color Key ********************************************************** */ -static bNodeSocketTemplate cmp_node_color_in[]={ +static bNodeSocketTemplate cmp_node_color_in[] = { {SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, {SOCK_RGBA, 1, N_("Key Color"), 1.0f, 1.0f, 1.0f, 1.0f}, {-1, 0, ""} }; -static bNodeSocketTemplate cmp_node_color_out[]={ +static bNodeSocketTemplate cmp_node_color_out[] = { {SOCK_RGBA, 0, N_("Image")}, {SOCK_FLOAT, 0, N_("Matte")}, {-1, 0, ""} diff --git a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c index c4120ab22c6..e8965d50b47 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorSpill.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorSpill.c @@ -36,13 +36,13 @@ #define AVG(a, b) ((a + b) / 2) /* ******************* Color Spill Supression ********************************* */ -static bNodeSocketTemplate cmp_node_color_spill_in[]={ +static bNodeSocketTemplate cmp_node_color_spill_in[] = { {SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, {SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, {-1, 0, ""} }; -static bNodeSocketTemplate cmp_node_color_spill_out[]={ +static bNodeSocketTemplate cmp_node_color_spill_out[] = { {SOCK_RGBA, 0, N_("Image")}, {-1, 0, ""} }; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c index a9f930f9cf2..e9d26ebebbc 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.c @@ -35,13 +35,13 @@ /* ******************* Color Balance ********************************* */ -static bNodeSocketTemplate cmp_node_colorbalance_in[]={ +static bNodeSocketTemplate cmp_node_colorbalance_in[] = { {SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, {SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, {-1, 0, ""} }; -static bNodeSocketTemplate cmp_node_colorbalance_out[]={ +static bNodeSocketTemplate cmp_node_colorbalance_out[] = { {SOCK_RGBA, 0, N_("Image")}, {-1, 0, ""} }; diff --git a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c index ce43b2f0f2b..526f8472992 100644 --- a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c +++ b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.c @@ -36,13 +36,13 @@ /* ******************* Color Balance ********************************* */ -static bNodeSocketTemplate cmp_node_colorcorrection_in[]={ +static bNodeSocketTemplate cmp_node_colorcorrection_in[] = { { SOCK_RGBA,1,N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Mask"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, { -1,0,""} }; -static bNodeSocketTemplate cmp_node_colorcorrection_out[]={ +static bNodeSocketTemplate cmp_node_colorcorrection_out[] = { { SOCK_RGBA,0,N_("Image")}, { -1,0,""} }; diff --git a/source/blender/nodes/composite/nodes/node_composite_common.c b/source/blender/nodes/composite/nodes/node_composite_common.c index 2596248d696..10b81cdaaa0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_common.c +++ b/source/blender/nodes/composite/nodes/node_composite_common.c @@ -231,153 +231,3 @@ void register_node_type_cmp_group(bNodeTreeType *ttype) nodeRegisterType(ttype, &ntype); } - -#ifdef WITH_COMPOSITOR_LEGACY - -/**** FOR LOOP ****/ - -#if 0 /* XXX loop nodes don't work nicely with current trees */ -/* Move the results from the previous iteration back to the input sockets. */ -static void loop_iteration_reset(bNodeTree *ngroup, bNodeStack *gstack) -{ - bNodeSocket *gin, *gout; - bNodeStack *nsin, *nsout; - - gin = ngroup->inputs.first; - gout = ngroup->outputs.first; - - while (gin && gout) { - /* skip static (non-looping) sockets */ - while (gin && !(gin->flag & SOCK_DYNAMIC)) - gin=gin->next; - while (gout && !(gout->flag & SOCK_DYNAMIC)) - gout=gout->next; - - if (gin && gout) { - nsin = node_get_socket_stack(gstack, gin); - nsout = node_get_socket_stack(gstack, gout); - - move_stack(nsin, nsout); - - gin=gin->next; - gout=gout->next; - } - } -} - -static void forloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out) -{ - bNodeTreeExec *exec= (bNodeTreeExec *)nodedata; - int totiterations= (int)in[0]->vec[0]; - bNodeSocket *sock; - bNodeStack *ns; - int iteration; - - /* XXX same behavior as trunk: all nodes inside group are executed. - * it's stupid, but just makes it work. compo redesign will do this better. - */ - { - bNode *inode; - for (inode=exec->nodetree->nodes.first; inode; inode=inode->next) - inode->need_exec = 1; - } - - /* "Iteration" socket */ - sock = exec->nodetree->inputs.first; - ns = node_get_socket_stack(exec->stack, sock); - - group_copy_inputs(node, in, exec->stack); - for (iteration=0; iteration < totiterations; ++iteration) { - /* first input contains current iteration counter */ - ns->vec[0] = (float)iteration; - - if (iteration > 0) - loop_iteration_reset(exec->nodetree, exec->stack); - ntreeExecNodes(exec, data, thread); - group_free_internal(exec); - } - group_move_outputs(node, out, exec->stack); -} - -void register_node_type_cmp_forloop(bNodeTreeType *ttype) -{ - static bNodeType ntype; - - node_type_base(ttype, &ntype, NODE_FORLOOP, "For", NODE_CLASS_GROUP, NODE_OPTIONS); - node_type_socket_templates(&ntype, NULL, NULL); - node_type_size(&ntype, 120, 60, 200); - node_type_label(&ntype, node_group_label); - node_type_init(&ntype, node_forloop_init); - node_type_valid(&ntype, node_group_valid); - node_type_template(&ntype, node_forloop_template); - node_type_update(&ntype, NULL, node_group_verify); - node_type_tree(&ntype, node_forloop_init_tree, node_loop_update_tree); - node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear); - node_type_exec_new(&ntype, group_initexec, group_freeexec, forloop_execute); - - nodeRegisterType(ttype, &ntype); -} -#endif - - -/**** WHILE LOOP ****/ - -#if 0 /* XXX loop nodes don't work nicely with current trees */ -static void whileloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out) -{ - bNodeTreeExec *exec= (bNodeTreeExec *)nodedata; - int condition= (in[0]->vec[0] > 0.0f); - bNodeSocket *sock; - bNodeStack *ns; - int iteration; - - /* XXX same behavior as trunk: all nodes inside group are executed. - * it's stupid, but just makes it work. compo redesign will do this better. - */ - { - bNode *inode; - for (inode=exec->nodetree->nodes.first; inode; inode=inode->next) - inode->need_exec = 1; - } - - /* "Condition" socket */ - sock = exec->nodetree->outputs.first; - ns = node_get_socket_stack(exec->stack, sock); - - iteration = 0; - group_copy_inputs(node, in, exec->stack); - while (condition && iteration < node->custom1) { - if (iteration > 0) - loop_iteration_reset(exec->nodetree, exec->stack); - ntreeExecNodes(exec, data, thread); - group_free_internal(exec); - -// PRINT_BUFFERS(exec); - - condition = (ns->vec[0] > 0.0f); - ++iteration; - } - group_move_outputs(node, out, exec->stack); -} - -void register_node_type_cmp_whileloop(bNodeTreeType *ttype) -{ - static bNodeType ntype; - - node_type_base(ttype, &ntype, NODE_WHILELOOP, "While", NODE_CLASS_GROUP, NODE_OPTIONS); - node_type_socket_templates(&ntype, NULL, NULL); - node_type_size(&ntype, 120, 60, 200); - node_type_label(&ntype, node_group_label); - node_type_init(&ntype, node_whileloop_init); - node_type_valid(&ntype, node_group_valid); - node_type_template(&ntype, node_whileloop_template); - node_type_update(&ntype, NULL, node_group_verify); - node_type_tree(&ntype, node_whileloop_init_tree, node_loop_update_tree); - node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear); - node_type_exec_new(&ntype, group_initexec, group_freeexec, whileloop_execute); - - nodeRegisterType(ttype, &ntype); -} -#endif - -#endif /* WITH_COMPOSITOR_LEGACY */ diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.c b/source/blender/nodes/composite/nodes/node_composite_composite.c index dadc863873d..cb932b6a8de 100644 --- a/source/blender/nodes/composite/nodes/node_composite_composite.c +++ b/source/blender/nodes/composite/nodes/node_composite_composite.c @@ -32,7 +32,7 @@ #include "node_composite_util.h" /* **************** COMPOSITE ******************** */ -static bNodeSocketTemplate cmp_node_composite_in[]= { +static bNodeSocketTemplate cmp_node_composite_in[] = { { SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_FLOAT, 1, N_("Z"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, @@ -110,7 +110,7 @@ void register_node_type_cmp_composite(bNodeTreeType *ttype) #endif /* Do not allow muting for this node. */ - node_type_internal_connect(&ntype, NULL); + node_type_internal_links(&ntype, NULL); nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_crop.c b/source/blender/nodes/composite/nodes/node_composite_crop.c index 9b1483d95cf..ad51fae1998 100644 --- a/source/blender/nodes/composite/nodes/node_composite_crop.c +++ b/source/blender/nodes/composite/nodes/node_composite_crop.c @@ -34,11 +34,11 @@ /* **************** Crop ******************** */ -static bNodeSocketTemplate cmp_node_crop_in[]= { +static bNodeSocketTemplate cmp_node_crop_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_crop_out[]= { +static bNodeSocketTemplate cmp_node_crop_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -82,7 +82,7 @@ static void node_composit_exec_crop(void *UNUSED(data), bNode *node, bNodeStack outputrect.ymin=MIN2(ntxy->y1, ntxy->y2); if (node->custom1) { - /* this option crops the image size too */ + /* this option crops the image size too */ stackbuf= get_cropped_compbuf(&outputrect, cbuf->rect, cbuf->x, cbuf->y, cbuf->type); } else { diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.c b/source/blender/nodes/composite/nodes/node_composite_curves.c index 1948709ec84..a1999ec8887 100644 --- a/source/blender/nodes/composite/nodes/node_composite_curves.c +++ b/source/blender/nodes/composite/nodes/node_composite_curves.c @@ -36,7 +36,7 @@ /* **************** CURVE Time ******************** */ /* custom1 = sfra, custom2 = efra */ -static bNodeSocketTemplate cmp_node_time_out[]= { +static bNodeSocketTemplate cmp_node_time_out[] = { { SOCK_FLOAT, 0, N_("Fac")}, { -1, 0, "" } }; @@ -55,7 +55,7 @@ static void node_composit_exec_curves_time(void *data, bNode *node, bNodeStack * curvemapping_initialize(node->storage); fac = curvemapping_evaluateF(node->storage, 0, fac); - out[0]->vec[0]= CLAMPIS(fac, 0.0f, 1.0f); + out[0]->vec[0] = CLAMPIS(fac, 0.0f, 1.0f); } #endif /* WITH_COMPOSITOR_LEGACY */ @@ -86,12 +86,12 @@ void register_node_type_cmp_curve_time(bNodeTreeType *ttype) /* **************** CURVE VEC ******************** */ -static bNodeSocketTemplate cmp_node_curve_vec_in[]= { +static bNodeSocketTemplate cmp_node_curve_vec_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_curve_vec_out[]= { +static bNodeSocketTemplate cmp_node_curve_vec_out[] = { { SOCK_VECTOR, 0, N_("Vector")}, { -1, 0, "" } }; @@ -132,7 +132,7 @@ void register_node_type_cmp_curve_vec(bNodeTreeType *ttype) /* **************** CURVE RGB ******************** */ -static bNodeSocketTemplate cmp_node_curve_rgb_in[]= { +static bNodeSocketTemplate cmp_node_curve_rgb_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_FACTOR}, { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_RGBA, 1, N_("Black Level"), 0.0f, 0.0f, 0.0f, 1.0f}, @@ -140,7 +140,7 @@ static bNodeSocketTemplate cmp_node_curve_rgb_in[]= { { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_curve_rgb_out[]= { +static bNodeSocketTemplate cmp_node_curve_rgb_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -151,7 +151,7 @@ static void do_curves(bNode *node, float *out, float *in) { curvemapping_initialize(node->storage); curvemapping_evaluate_premulRGBF(node->storage, out, in); - out[3]= in[3]; + out[3] = in[3]; } static void do_curves_fac(bNode *node, float *out, float *in, float *fac) @@ -166,11 +166,11 @@ static void do_curves_fac(bNode *node, float *out, float *in, float *fac) else { float col[4], mfac= 1.0f-*fac; curvemapping_evaluate_premulRGBF(node->storage, col, in); - out[0]= mfac*in[0] + *fac*col[0]; - out[1]= mfac*in[1] + *fac*col[1]; - out[2]= mfac*in[2] + *fac*col[2]; + out[0] = mfac*in[0] + *fac*col[0]; + out[1] = mfac*in[1] + *fac*col[1]; + out[2] = mfac*in[2] + *fac*col[2]; } - out[3]= in[3]; + out[3] = in[3]; } static void node_composit_exec_curve_rgb(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.c b/source/blender/nodes/composite/nodes/node_composite_defocus.c index 1a9852264bf..27ce0f7c4a7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_defocus.c +++ b/source/blender/nodes/composite/nodes/node_composite_defocus.c @@ -34,12 +34,12 @@ #include <limits.h> /* ************ qdn: Defocus node ****************** */ -static bNodeSocketTemplate cmp_node_defocus_in[]= { +static bNodeSocketTemplate cmp_node_defocus_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Z"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_defocus_out[]= { +static bNodeSocketTemplate cmp_node_defocus_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -338,7 +338,7 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, // fast blur... // bug #6656 part 1, probably when previous node_composite.c was split into separate files, it was not properly updated // to include recent cvs commits (well, at least not defocus node), so this part was missing... - wt = minf(nqd->maxblur, aperture * 128.0f); + wt = min_ff(nqd->maxblur, aperture * 128.0f); IIR_gauss_single(crad, wt); IIR_gauss_single(wts, wt); @@ -589,8 +589,8 @@ static void defocus_blur(bNode *node, CompBuf *new, CompBuf *img, CompBuf *zbuf, // n-agonal int ov, nv; float mind, maxd, lwt; - ys = maxi((int)floor(bkh_b[2] * ct_crad + y), 0); - ye = mini((int)ceil(bkh_b[3] * ct_crad + y), new->y - 1); + ys = max_ii((int)floor(bkh_b[2] * ct_crad + y), 0); + ye = min_ii((int)ceil(bkh_b[3] * ct_crad + y), new->y - 1); for (sy=ys; sy<=ye; sy++) { float fxs = 1e10f, fxe = -1e10f; float yf = (sy - y)/ct_crad; @@ -861,7 +861,7 @@ static void node_composit_exec_defocus(void *UNUSED(data), bNode *node, bNodeSta if (node->exec & NODE_BREAK) { free_compbuf(new); new= NULL; - } + } out[0]->data = new; if (zbuf_use && (zbuf_use != zbuf)) free_compbuf(zbuf_use); } diff --git a/source/blender/nodes/composite/nodes/node_composite_despeckle.c b/source/blender/nodes/composite/nodes/node_composite_despeckle.c index 21b703dc9a8..9d47e4bc276 100644 --- a/source/blender/nodes/composite/nodes/node_composite_despeckle.c +++ b/source/blender/nodes/composite/nodes/node_composite_despeckle.c @@ -32,12 +32,12 @@ #include "node_composite_util.h" /* **************** FILTER ******************** */ -static bNodeSocketTemplate cmp_node_despeckle_in[]= { +static bNodeSocketTemplate cmp_node_despeckle_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_despeckle_out[]= { +static bNodeSocketTemplate cmp_node_despeckle_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c index ed43baef420..014b72d3c60 100644 --- a/source/blender/nodes/composite/nodes/node_composite_diffMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_diffMatte.c @@ -33,13 +33,13 @@ #include "node_composite_util.h" /* ******************* channel Difference Matte ********************************* */ -static bNodeSocketTemplate cmp_node_diff_matte_in[]={ +static bNodeSocketTemplate cmp_node_diff_matte_in[] = { {SOCK_RGBA, 1, N_("Image 1"), 1.0f, 1.0f, 1.0f, 1.0f}, {SOCK_RGBA, 1, N_("Image 2"), 1.0f, 1.0f, 1.0f, 1.0f}, {-1, 0, ""} }; -static bNodeSocketTemplate cmp_node_diff_matte_out[]={ +static bNodeSocketTemplate cmp_node_diff_matte_out[] = { {SOCK_RGBA, 0, N_("Image")}, {SOCK_FLOAT, 0, N_("Matte")}, {-1, 0, ""} @@ -76,7 +76,7 @@ static void do_diff_matte(bNode *node, float *outColor, float *inColor1, float * } /*only change if more transparent than either image */ - maxInputAlpha=maxf(inColor1[3], inColor2[3]); + maxInputAlpha=max_ff(inColor1[3], inColor2[3]); if (alpha < maxInputAlpha) { /*clamp*/ if (alpha < 0.0f) alpha = 0.0f; diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.c b/source/blender/nodes/composite/nodes/node_composite_dilate.c index f53c64b990a..9787c9f7145 100644 --- a/source/blender/nodes/composite/nodes/node_composite_dilate.c +++ b/source/blender/nodes/composite/nodes/node_composite_dilate.c @@ -54,28 +54,28 @@ static void morpho_dilate(CompBuf *cbuf) for (y = 0; y < cbuf->y; y++) { for (x = 0; x < cbuf->x - 1; x++) { p = rectf + cbuf->x * y + x; - *p = maxf(*p, *(p + 1)); + *p = max_ff(*p, *(p + 1)); } } for (y = 0; y < cbuf->y; y++) { for (x = cbuf->x - 1; x >= 1; x--) { p = rectf + cbuf->x * y + x; - *p = maxf(*p, *(p - 1)); + *p = max_ff(*p, *(p - 1)); } } for (x = 0; x < cbuf->x; x++) { for (y = 0; y < cbuf->y - 1; y++) { p = rectf + cbuf->x * y + x; - *p = maxf(*p, *(p + cbuf->x)); + *p = max_ff(*p, *(p + cbuf->x)); } } for (x = 0; x < cbuf->x; x++) { for (y = cbuf->y - 1; y >= 1; y--) { p = rectf + cbuf->x * y + x; - *p = maxf(*p, *(p - cbuf->x)); + *p = max_ff(*p, *(p - cbuf->x)); } } } @@ -88,28 +88,28 @@ static void morpho_erode(CompBuf *cbuf) for (y = 0; y < cbuf->y; y++) { for (x = 0; x < cbuf->x - 1; x++) { p = rectf + cbuf->x * y + x; - *p = minf(*p, *(p + 1)); + *p = min_ff(*p, *(p + 1)); } } for (y = 0; y < cbuf->y; y++) { for (x = cbuf->x - 1; x >= 1; x--) { p = rectf + cbuf->x * y + x; - *p = minf(*p, *(p - 1)); + *p = min_ff(*p, *(p - 1)); } } for (x = 0; x < cbuf->x; x++) { for (y = 0; y < cbuf->y - 1; y++) { p = rectf + cbuf->x * y + x; - *p = minf(*p, *(p + cbuf->x)); + *p = min_ff(*p, *(p + cbuf->x)); } } for (x = 0; x < cbuf->x; x++) { for (y = cbuf->y - 1; y >= 1; y--) { p = rectf + cbuf->x * y + x; - *p = minf(*p, *(p - cbuf->x)); + *p = min_ff(*p, *(p - cbuf->x)); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_displace.c b/source/blender/nodes/composite/nodes/node_composite_displace.c index 51ccc2a4d39..c07ad0a0c97 100644 --- a/source/blender/nodes/composite/nodes/node_composite_displace.c +++ b/source/blender/nodes/composite/nodes/node_composite_displace.c @@ -35,14 +35,14 @@ /* **************** Displace ******************** */ -static bNodeSocketTemplate cmp_node_displace_in[]= { +static bNodeSocketTemplate cmp_node_displace_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_VECTOR, 1, N_("Vector"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_TRANSLATION}, { SOCK_FLOAT, 1, N_("X Scale"), 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f, PROP_FACTOR}, { SOCK_FLOAT, 1, N_("Y Scale"), 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f, PROP_FACTOR}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_displace_out[]= { +static bNodeSocketTemplate cmp_node_displace_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -113,8 +113,8 @@ static void do_displace(bNode *node, CompBuf *stackbuf, CompBuf *cbuf, CompBuf * dxt = p_dx - d_dx; dyt = p_dy - d_dy; - dxt = signf(dxt)*maxf(fabsf(dxt), DISPLACE_EPSILON)/(float)stackbuf->x; - dyt = signf(dyt)*maxf(fabsf(dyt), DISPLACE_EPSILON)/(float)stackbuf->y; + dxt = signf(dxt)*max_ff(fabsf(dxt), DISPLACE_EPSILON)/(float)stackbuf->x; + dyt = signf(dyt)*max_ff(fabsf(dyt), DISPLACE_EPSILON)/(float)stackbuf->y; ibuf_sample(ibuf, u, v, dxt, dyt, col); qd_setPixel(stackbuf, x, y, col); diff --git a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c index 7a101ff43b5..7e605865cd2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_distanceMatte.c @@ -33,13 +33,13 @@ #include "node_composite_util.h" /* ******************* channel Distance Matte ********************************* */ -static bNodeSocketTemplate cmp_node_distance_matte_in[]={ +static bNodeSocketTemplate cmp_node_distance_matte_in[] = { {SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, {SOCK_RGBA, 1, N_("Key Color"), 1.0f, 1.0f, 1.0f, 1.0f}, {-1, 0, ""} }; -static bNodeSocketTemplate cmp_node_distance_matte_out[]={ +static bNodeSocketTemplate cmp_node_distance_matte_out[] = { {SOCK_RGBA, 0, N_("Image")}, {SOCK_FLOAT, 0, N_("Matte")}, {-1, 0, ""} @@ -159,9 +159,9 @@ static void node_composit_exec_distance_matte(void *data, bNode *node, bNodeStac workbuf=dupalloc_compbuf(inbuf); /*use the input color*/ - c->key[0]= in[1]->vec[0]; - c->key[1]= in[1]->vec[1]; - c->key[2]= in[1]->vec[2]; + c->key[0] = in[1]->vec[0]; + c->key[1] = in[1]->vec[1]; + c->key[2] = in[1]->vec[2]; /* work in RGB color space */ if (c->channel == 1) { diff --git a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c index 63a54efea74..3c1e3ee443e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c +++ b/source/blender/nodes/composite/nodes/node_composite_doubleEdgeMask.c @@ -32,12 +32,12 @@ /* **************** Double Edge Mask ******************** */ -static bNodeSocketTemplate cmp_node_doubleedgemask_in[]= { +static bNodeSocketTemplate cmp_node_doubleedgemask_in[] = { { SOCK_FLOAT, 1, "Inner Mask", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f, PROP_NONE}, // inner mask socket definition { SOCK_FLOAT, 1, "Outer Mask", 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f, PROP_NONE}, // outer mask socket definition { -1, 0, "" } // input socket array terminator }; -static bNodeSocketTemplate cmp_node_doubleedgemask_out[]= { +static bNodeSocketTemplate cmp_node_doubleedgemask_out[] = { { SOCK_FLOAT, 0, "Mask"}, // output socket definition { -1, 0, "" } // output socket array terminator }; diff --git a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c index a97322a17c0..761b0b13f11 100644 --- a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c +++ b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.c @@ -1,6 +1,4 @@ /* - * $Id: CMP_math.c 36271 2011-04-21 13:11:51Z campbellbarton $ - * * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -35,15 +33,15 @@ #include "../node_composite_util.h" /* **************** SCALAR MATH ******************** */ -static bNodeSocketTemplate cmp_node_ellipsemask_in[]= { +static bNodeSocketTemplate cmp_node_ellipsemask_in[] = { { SOCK_FLOAT, 1, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - { -1, 0, "" } + { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_ellipsemask_out[]= { +static bNodeSocketTemplate cmp_node_ellipsemask_out[] = { { SOCK_FLOAT, 0, N_("Mask"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, - { -1, 0, "" } + { -1, 0, "" } }; static void node_composit_init_ellipsemask(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) diff --git a/source/blender/nodes/composite/nodes/node_composite_filter.c b/source/blender/nodes/composite/nodes/node_composite_filter.c index 0b12c03682b..a27116ab077 100644 --- a/source/blender/nodes/composite/nodes/node_composite_filter.c +++ b/source/blender/nodes/composite/nodes/node_composite_filter.c @@ -33,12 +33,12 @@ #include "node_composite_util.h" /* **************** FILTER ******************** */ -static bNodeSocketTemplate cmp_node_filter_in[]= { +static bNodeSocketTemplate cmp_node_filter_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_filter_out[]= { +static bNodeSocketTemplate cmp_node_filter_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -73,10 +73,10 @@ static void do_filter_edge(CompBuf *out, CompBuf *in, float *filter, float fac) for (c=0; c<3; c++) { f1= filter[0]*row1[0] + filter[1]*row1[4] + filter[2]*row1[8] + filter[3]*row2[0] + filter[4]*row2[4] + filter[5]*row2[8] + filter[6]*row3[0] + filter[7]*row3[4] + filter[8]*row3[8]; f2= filter[0]*row1[0] + filter[3]*row1[4] + filter[6]*row1[8] + filter[1]*row2[0] + filter[4]*row2[4] + filter[7]*row2[8] + filter[2]*row3[0] + filter[5]*row3[4] + filter[8]*row3[8]; - fp[0]= mfac*row2[4] + fac*sqrt(f1*f1 + f2*f2); + fp[0] = mfac*row2[4] + fac*sqrt(f1*f1 + f2*f2); fp++; row1++; row2++; row3++; } - fp[0]= row2[4]; + fp[0] = row2[4]; /* no alpha... will clear it completely */ fp++; row1++; row2++; row3++; } @@ -87,7 +87,7 @@ static void do_filter_edge(CompBuf *out, CompBuf *in, float *filter, float fac) for (x=2; x<rowlen; x++) { f1= filter[0]*row1[0] + filter[1]*row1[1] + filter[2]*row1[2] + filter[3]*row2[0] + filter[4]*row2[1] + filter[5]*row2[2] + filter[6]*row3[0] + filter[7]*row3[1] + filter[8]*row3[2]; f2= filter[0]*row1[0] + filter[3]*row1[1] + filter[6]*row1[2] + filter[1]*row2[0] + filter[4]*row2[1] + filter[7]*row2[2] + filter[2]*row3[0] + filter[5]*row3[1] + filter[8]*row3[2]; - fp[0]= mfac*row2[1] + fac*sqrt(f1*f1 + f2*f2); + fp[0] = mfac*row2[1] + fac*sqrt(f1*f1 + f2*f2); fp++; row1++; row2++; row3++; } } @@ -116,28 +116,28 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac) fp= out->rect + pixlen*(y)*rowlen; if (pixlen==1) { - fp[0]= row2[0]; + fp[0] = row2[0]; fp+= 1; for (x=2; x<rowlen; x++) { - fp[0]= mfac*row2[1] + fac*(filter[0]*row1[0] + filter[1]*row1[1] + filter[2]*row1[2] + filter[3]*row2[0] + filter[4]*row2[1] + filter[5]*row2[2] + filter[6]*row3[0] + filter[7]*row3[1] + filter[8]*row3[2]); + fp[0] = mfac*row2[1] + fac*(filter[0]*row1[0] + filter[1]*row1[1] + filter[2]*row1[2] + filter[3]*row2[0] + filter[4]*row2[1] + filter[5]*row2[2] + filter[6]*row3[0] + filter[7]*row3[1] + filter[8]*row3[2]); fp++; row1++; row2++; row3++; } - fp[0]= row2[1]; + fp[0] = row2[1]; } else if (pixlen==2) { - fp[0]= row2[0]; - fp[1]= row2[1]; + fp[0] = row2[0]; + fp[1] = row2[1]; fp+= 2; for (x=2; x<rowlen; x++) { for (c=0; c<2; c++) { - fp[0]= mfac*row2[2] + fac*(filter[0]*row1[0] + filter[1]*row1[2] + filter[2]*row1[4] + filter[3]*row2[0] + filter[4]*row2[2] + filter[5]*row2[4] + filter[6]*row3[0] + filter[7]*row3[2] + filter[8]*row3[4]); + fp[0] = mfac*row2[2] + fac*(filter[0]*row1[0] + filter[1]*row1[2] + filter[2]*row1[4] + filter[3]*row2[0] + filter[4]*row2[2] + filter[5]*row2[4] + filter[6]*row3[0] + filter[7]*row3[2] + filter[8]*row3[4]); fp++; row1++; row2++; row3++; } } - fp[0]= row2[2]; - fp[1]= row2[3]; + fp[0] = row2[2]; + fp[1] = row2[3]; } else if (pixlen==3) { copy_v3_v3(fp, row2); @@ -145,7 +145,7 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac) for (x=2; x<rowlen; x++) { for (c=0; c<3; c++) { - fp[0]= mfac*row2[3] + fac*(filter[0]*row1[0] + filter[1]*row1[3] + filter[2]*row1[6] + filter[3]*row2[0] + filter[4]*row2[3] + filter[5]*row2[6] + filter[6]*row3[0] + filter[7]*row3[3] + filter[8]*row3[6]); + fp[0] = mfac*row2[3] + fac*(filter[0]*row1[0] + filter[1]*row1[3] + filter[2]*row1[6] + filter[3]*row2[0] + filter[4]*row2[3] + filter[5]*row2[6] + filter[6]*row3[0] + filter[7]*row3[3] + filter[8]*row3[6]); fp++; row1++; row2++; row3++; } } @@ -157,7 +157,7 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac) for (x=2; x<rowlen; x++) { for (c=0; c<4; c++) { - fp[0]= mfac*row2[4] + fac*(filter[0]*row1[0] + filter[1]*row1[4] + filter[2]*row1[8] + filter[3]*row2[0] + filter[4]*row2[4] + filter[5]*row2[8] + filter[6]*row3[0] + filter[7]*row3[4] + filter[8]*row3[8]); + fp[0] = mfac*row2[4] + fac*(filter[0]*row1[0] + filter[1]*row1[4] + filter[2]*row1[8] + filter[3]*row2[0] + filter[4]*row2[4] + filter[5]*row2[8] + filter[6]*row3[0] + filter[7]*row3[4] + filter[8]*row3[8]); fp++; row1++; row2++; row3++; } } @@ -169,13 +169,13 @@ static void do_filter3(CompBuf *out, CompBuf *in, float *filter, float fac) static void node_composit_exec_filter(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { - static 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 sharp[9]= {-1, -1, -1, -1, 9, -1, -1, -1, -1}; - float laplace[9]= {-1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f, 1.0f, -1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f}; - float sobel[9]= {1, 2, 1, 0, 0, 0, -1, -2, -1}; - float prewitt[9]= {1, 1, 1, 0, 0, 0, -1, -1, -1}; - float kirsch[9]= {5, 5, 5, -3, -3, -3, -2, -2, -2}; - float shadow[9]= {1, 2, 1, 0, 1, 0, -1, -2, -1}; + static 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 sharp[9] = {-1, -1, -1, -1, 9, -1, -1, -1, -1}; + float laplace[9] = {-1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f, 1.0f, -1/8.0f, -1/8.0f, -1/8.0f, -1/8.0f}; + float sobel[9] = {1, 2, 1, 0, 0, 0, -1, -2, -1}; + float prewitt[9] = {1, 1, 1, 0, 0, 0, -1, -1, -1}; + float kirsch[9] = {5, 5, 5, -3, -3, -3, -2, -2, -2}; + float shadow[9] = {1, 2, 1, 0, 1, 0, -1, -2, -1}; if (out[0]->hasoutput==0) return; diff --git a/source/blender/nodes/composite/nodes/node_composite_flip.c b/source/blender/nodes/composite/nodes/node_composite_flip.c index 147e7591af7..4aa98d173e7 100644 --- a/source/blender/nodes/composite/nodes/node_composite_flip.c +++ b/source/blender/nodes/composite/nodes/node_composite_flip.c @@ -33,12 +33,12 @@ #include "node_composite_util.h" /* **************** Flip ******************** */ -static bNodeSocketTemplate cmp_node_flip_in[]= { +static bNodeSocketTemplate cmp_node_flip_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_flip_out[]= { +static bNodeSocketTemplate cmp_node_flip_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -75,7 +75,7 @@ static void node_composit_exec_flip(void *UNUSED(data), bNode *node, bNodeStack outfp += (src_width-1)*src_pix; for (x=0; x<src_width; x++) { for (i=0; i<src_pix; i++) { - outfp[i]= srcfp[i]; + outfp[i] = srcfp[i]; } outfp -= src_pix; srcfp += src_pix; diff --git a/source/blender/nodes/composite/nodes/node_composite_gamma.c b/source/blender/nodes/composite/nodes/node_composite_gamma.c index 87155478035..b8c99894301 100644 --- a/source/blender/nodes/composite/nodes/node_composite_gamma.c +++ b/source/blender/nodes/composite/nodes/node_composite_gamma.c @@ -35,12 +35,12 @@ /* **************** Gamma Tools ******************** */ -static bNodeSocketTemplate cmp_node_gamma_in[]= { +static bNodeSocketTemplate cmp_node_gamma_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Gamma"), 1.0f, 0.0f, 0.0f, 0.0f, 0.001f, 10.0f, PROP_UNSIGNED}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_gamma_out[]= { +static bNodeSocketTemplate cmp_node_gamma_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.c b/source/blender/nodes/composite/nodes/node_composite_glare.c index 7d6c0cb1a29..950d8a56f58 100644 --- a/source/blender/nodes/composite/nodes/node_composite_glare.c +++ b/source/blender/nodes/composite/nodes/node_composite_glare.c @@ -32,11 +32,11 @@ #include "node_composite_util.h" -static bNodeSocketTemplate cmp_node_glare_in[]= { +static bNodeSocketTemplate cmp_node_glare_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_glare_out[]= { +static bNodeSocketTemplate cmp_node_glare_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c index c8784ceedb7..d52e3d01a32 100644 --- a/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c +++ b/source/blender/nodes/composite/nodes/node_composite_hueSatVal.c @@ -34,12 +34,12 @@ /* **************** Hue Saturation ******************** */ -static bNodeSocketTemplate cmp_node_hue_sat_in[]= { +static bNodeSocketTemplate cmp_node_hue_sat_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_hue_sat_out[]= { +static bNodeSocketTemplate cmp_node_hue_sat_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -60,10 +60,10 @@ static void do_hue_sat_fac(bNode *node, float *out, float *in, float *fac) hsv[2]*= nhs->val; hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2); - out[0]= mfac*in[0] + *fac*col[0]; - out[1]= mfac*in[1] + *fac*col[1]; - out[2]= mfac*in[2] + *fac*col[2]; - out[3]= in[3]; + out[0] = mfac*in[0] + *fac*col[0]; + out[1] = mfac*in[1] + *fac*col[1]; + out[2] = mfac*in[2] + *fac*col[2]; + out[3] = in[3]; } else { copy_v4_v4(out, in); @@ -89,7 +89,7 @@ static void node_composit_exec_hue_sat(void *UNUSED(data), bNode *node, bNodeSta out[0]->data= stackbuf; - /* get rid of intermediary cbuf if it's extra */ + /* get rid of intermediary cbuf if it's extra */ if (stackbuf!=cbuf) free_compbuf(cbuf); } diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c index 42077cd5c06..f751dbea8d2 100644 --- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.c +++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.c @@ -32,13 +32,13 @@ #include "node_composite_util.h" -static bNodeSocketTemplate cmp_node_huecorrect_in[]= { +static bNodeSocketTemplate cmp_node_huecorrect_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_huecorrect_out[]= { +static bNodeSocketTemplate cmp_node_huecorrect_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -71,7 +71,7 @@ static void do_huecorrect(bNode *node, float *out, float *in) /* convert back to rgb */ hsv_to_rgb(hsv[0], hsv[1], hsv[2], out, out+1, out+2); - out[3]= in[3]; + out[3] = in[3]; } static void do_huecorrect_fac(bNode *node, float *out, float *in, float *fac) @@ -101,10 +101,10 @@ static void do_huecorrect_fac(bNode *node, float *out, float *in, float *fac) /* convert back to rgb */ hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb+1, rgb+2); - out[0]= mfac*in[0] + *fac*rgb[0]; - out[1]= mfac*in[1] + *fac*rgb[1]; - out[2]= mfac*in[2] + *fac*rgb[2]; - out[3]= in[3]; + out[0] = mfac*in[0] + *fac*rgb[0]; + out[1] = mfac*in[1] + *fac*rgb[1]; + out[2] = mfac*in[2] + *fac*rgb[2]; + out[3] = in[3]; } static void node_composit_exec_huecorrect(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/composite/nodes/node_composite_idMask.c b/source/blender/nodes/composite/nodes/node_composite_idMask.c index 31a3a765ebe..ef0c5021192 100644 --- a/source/blender/nodes/composite/nodes/node_composite_idMask.c +++ b/source/blender/nodes/composite/nodes/node_composite_idMask.c @@ -35,11 +35,11 @@ /* **************** ID Mask ******************** */ -static bNodeSocketTemplate cmp_node_idmask_in[]= { +static bNodeSocketTemplate cmp_node_idmask_in[] = { { SOCK_FLOAT, 1, N_("ID value"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_idmask_out[]= { +static bNodeSocketTemplate cmp_node_idmask_out[] = { { SOCK_FLOAT, 0, N_("Alpha")}, { -1, 0, "" } }; @@ -56,14 +56,14 @@ static void do_idmask(CompBuf *stackbuf, CompBuf *cbuf, float idnr) rect= cbuf->rect; for (x= cbuf->x*cbuf->y - 1; x>=0; x--) if (rect[x]==idnr) - abuf[x]= 255; + abuf[x] = 255; antialias_tagbuf(cbuf->x, cbuf->y, abuf); rect= stackbuf->rect; for (x= cbuf->x*cbuf->y - 1; x>=0; x--) if (abuf[x]>1) - rect[x]= (1.0f/255.0f)*(float)abuf[x]; + rect[x] = (1.0f/255.0f)*(float)abuf[x]; MEM_freeN(abuf); } @@ -78,7 +78,7 @@ static void do_idmask_fsa(CompBuf *stackbuf, CompBuf *cbuf, float idnr) rs= stackbuf->rect; for (x= cbuf->x*cbuf->y - 1; x>=0; x--) if (rect[x]==idnr) - rs[x]= 1.0f; + rs[x] = 1.0f; } diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 9f3874560ac..150382c1f8f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -34,7 +34,7 @@ /* **************** IMAGE (and RenderResult, multilayer image) ******************** */ -static bNodeSocketTemplate cmp_node_rlayers_out[]= { +static bNodeSocketTemplate cmp_node_rlayers_out[] = { { SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Z"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, @@ -505,7 +505,7 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE generate_preview(data, node, stackbuf); } } - } + } } #endif /* WITH_COMPOSITOR_LEGACY */ diff --git a/source/blender/nodes/composite/nodes/node_composite_invert.c b/source/blender/nodes/composite/nodes/node_composite_invert.c index b0e656b173b..2db6e42f603 100644 --- a/source/blender/nodes/composite/nodes/node_composite_invert.c +++ b/source/blender/nodes/composite/nodes/node_composite_invert.c @@ -32,15 +32,15 @@ #include "node_composite_util.h" /* **************** INVERT ******************** */ -static bNodeSocketTemplate cmp_node_invert_in[]= { - { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - { SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f}, - { -1, 0, "" } +static bNodeSocketTemplate cmp_node_invert_in[] = { + { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f}, + { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_invert_out[]= { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, "" } +static bNodeSocketTemplate cmp_node_invert_out[] = { + { SOCK_RGBA, 0, N_("Color")}, + { -1, 0, "" } }; #ifdef WITH_COMPOSITOR_LEGACY diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.c b/source/blender/nodes/composite/nodes/node_composite_lensdist.c index a4983cce8b8..c3f64f0eacb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lensdist.c +++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.c @@ -32,13 +32,13 @@ #include "node_composite_util.h" -static bNodeSocketTemplate cmp_node_lensdist_in[]= { +static bNodeSocketTemplate cmp_node_lensdist_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Distort"), 0.f, 0.f, 0.f, 0.f, -0.999f, 1.f, PROP_NONE}, { SOCK_FLOAT, 1, N_("Dispersion"), 0.f, 0.f, 0.f, 0.f, 0.f, 1.f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_lensdist_out[]= { +static bNodeSocketTemplate cmp_node_lensdist_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -74,7 +74,7 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb qd_getPixelLerpChan(tsrc, (u*dst->x - kr) - 0.5f, v*dst->y - 0.5f, 2, colp[x]+2); /* set alpha */ - colp[x][3]= 1.0f; + colp[x][3] = 1.0f; } } free_compbuf(tsrc); @@ -159,7 +159,7 @@ static void lensDistort(CompBuf *dst, CompBuf *src, float kr, float kg, float kb if (db) colp[x][2] = 2.f*tc[2] / (float)db; /* set alpha */ - colp[x][3]= 1.0f; + colp[x][3] = 1.0f; } } } diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.c b/source/blender/nodes/composite/nodes/node_composite_levels.c index 601516c5bb0..57d94d6cb4d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_levels.c +++ b/source/blender/nodes/composite/nodes/node_composite_levels.c @@ -34,12 +34,12 @@ /* **************** LEVELS ******************** */ -static bNodeSocketTemplate cmp_node_view_levels_in[]= { +static bNodeSocketTemplate cmp_node_view_levels_in[] = { { SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_view_levels_out[]={ +static bNodeSocketTemplate cmp_node_view_levels_out[] = { {SOCK_FLOAT, 0, N_("Mean")}, {SOCK_FLOAT, 0, N_("Std Dev")}, {-1, 0, ""} @@ -101,7 +101,7 @@ static void fill_bins(bNode *node, CompBuf* in, int* bins) bins[ivalue]+=1; } /*end if alpha */ } - } + } } static float brightness_mean(bNode *node, CompBuf* in) @@ -275,8 +275,8 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack * if (in[0]->hasinput==0) return; if (in[0]->data==NULL) return; - histogram=alloc_compbuf(256, 256, CB_RGBA, 1); - cbuf=typecheck_compbuf(in[0]->data, CB_RGBA); + histogram=alloc_compbuf(256, 256, CB_RGBA, 1); + cbuf=typecheck_compbuf(in[0]->data, CB_RGBA); /*initalize bins*/ for (x=0; x<256; x++) { @@ -300,9 +300,9 @@ static void node_composit_exec_view_levels(void *data, bNode *node, bNodeStack * #endif if (out[0]->hasoutput) - out[0]->vec[0]= mean; + out[0]->vec[0] = mean; if (out[1]->hasoutput) - out[1]->vec[0]= std_dev; + out[1]->vec[0] = std_dev; generate_preview(data, node, histogram); diff --git a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c index 61cd4493f39..ed232933139 100644 --- a/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c +++ b/source/blender/nodes/composite/nodes/node_composite_lummaMatte.c @@ -34,12 +34,12 @@ /* ******************* Luma Matte Node ********************************* */ -static bNodeSocketTemplate cmp_node_luma_matte_in[]={ +static bNodeSocketTemplate cmp_node_luma_matte_in[] = { {SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, {-1, 0, ""} }; -static bNodeSocketTemplate cmp_node_luma_matte_out[]={ +static bNodeSocketTemplate cmp_node_luma_matte_out[] = { {SOCK_RGBA, 0, N_("Image")}, {SOCK_FLOAT, 0, N_("Matte")}, {-1, 0, ""} diff --git a/source/blender/nodes/composite/nodes/node_composite_mapUV.c b/source/blender/nodes/composite/nodes/node_composite_mapUV.c index 04d2eaff4f4..40092a84367 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapUV.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapUV.c @@ -34,12 +34,12 @@ /* **************** Map UV ******************** */ -static bNodeSocketTemplate cmp_node_mapuv_in[]= { +static bNodeSocketTemplate cmp_node_mapuv_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_VECTOR, 1, N_("UV"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_mapuv_out[]= { +static bNodeSocketTemplate cmp_node_mapuv_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -135,7 +135,7 @@ static void do_mapuv(CompBuf *stackbuf, CompBuf *cbuf, CompBuf *uvbuf, float thr } } - IMB_freeImBuf(ibuf); + IMB_freeImBuf(ibuf); } diff --git a/source/blender/nodes/composite/nodes/node_composite_mapValue.c b/source/blender/nodes/composite/nodes/node_composite_mapValue.c index be69c11b35f..677d5bd5013 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mapValue.c +++ b/source/blender/nodes/composite/nodes/node_composite_mapValue.c @@ -33,11 +33,11 @@ #include "node_composite_util.h" /* **************** MAP VALUE ******************** */ -static bNodeSocketTemplate cmp_node_map_value_in[]= { +static bNodeSocketTemplate cmp_node_map_value_in[] = { { SOCK_FLOAT, 1, N_("Value"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_map_value_out[]= { +static bNodeSocketTemplate cmp_node_map_value_out[] = { { SOCK_FLOAT, 0, N_("Value")}, { -1, 0, "" } }; @@ -48,13 +48,13 @@ static void do_map_value(bNode *node, float *out, float *src) { TexMapping *texmap= node->storage; - out[0]= (src[0] + texmap->loc[0])*texmap->size[0]; + out[0] = (src[0] + texmap->loc[0])*texmap->size[0]; if (texmap->flag & TEXMAP_CLIP_MIN) if (out[0]<texmap->min[0]) - out[0]= texmap->min[0]; + out[0] = texmap->min[0]; if (texmap->flag & TEXMAP_CLIP_MAX) if (out[0]>texmap->max[0]) - out[0]= texmap->max[0]; + out[0] = texmap->max[0]; } static void node_composit_exec_map_value(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/composite/nodes/node_composite_math.c b/source/blender/nodes/composite/nodes/node_composite_math.c index 1bddfe0852a..c99e12a95b9 100644 --- a/source/blender/nodes/composite/nodes/node_composite_math.c +++ b/source/blender/nodes/composite/nodes/node_composite_math.c @@ -33,15 +33,15 @@ #include "node_composite_util.h" /* **************** SCALAR MATH ******************** */ -static bNodeSocketTemplate cmp_node_math_in[]= { - { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, - { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, - { -1, 0, "" } +static bNodeSocketTemplate cmp_node_math_in[] = { + { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_math_out[]= { - { SOCK_FLOAT, 0, N_("Value")}, - { -1, 0, "" } +static bNodeSocketTemplate cmp_node_math_out[] = { + { SOCK_FLOAT, 0, N_("Value")}, + { -1, 0, "" } }; #ifdef WITH_COMPOSITOR_LEGACY @@ -50,63 +50,63 @@ static void do_math(bNode *node, float *out, float *in, float *in2) { switch (node->custom1) { case 0: /* Add */ - out[0]= in[0] + in2[0]; + out[0] = in[0] + in2[0]; break; case 1: /* Subtract */ - out[0]= in[0] - in2[0]; + out[0] = in[0] - in2[0]; break; case 2: /* Multiply */ - out[0]= in[0] * in2[0]; + out[0] = in[0] * in2[0]; break; case 3: /* Divide */ { if (in2[0]==0) /* We don't want to divide by zero. */ - out[0]= 0.0; + out[0] = 0.0; else - out[0]= in[0] / in2[0]; + out[0] = in[0] / in2[0]; } break; case 4: /* Sine */ - out[0]= sin(in[0]); + out[0] = sin(in[0]); break; case 5: /* Cosine */ - out[0]= cos(in[0]); + out[0] = cos(in[0]); break; case 6: /* Tangent */ - out[0]= tan(in[0]); + out[0] = tan(in[0]); break; case 7: /* Arc-Sine */ { /* Can't do the impossible... */ if (in[0] <= 1 && in[0] >= -1 ) - out[0]= asin(in[0]); + out[0] = asin(in[0]); else - out[0]= 0.0; + out[0] = 0.0; } break; case 8: /* Arc-Cosine */ { /* Can't do the impossible... */ if ( in[0] <= 1 && in[0] >= -1 ) - out[0]= acos(in[0]); + out[0] = acos(in[0]); else - out[0]= 0.0; + out[0] = 0.0; } break; case 9: /* Arc-Tangent */ - out[0]= atan(in[0]); + out[0] = atan(in[0]); break; case 10: /* Power */ { /* Only raise negative numbers by full integers */ if ( in[0] >= 0 ) { - out[0]= pow(in[0], in2[0]); + out[0] = pow(in[0], in2[0]); } else { float y_mod_1 = fmod(in2[0], 1); /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */ if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { - out[0]= powf(in[0], floorf(in2[0] + 0.5f)); + out[0] = powf(in[0], floorf(in2[0] + 0.5f)); } else { out[0] = 0.0f; @@ -118,50 +118,50 @@ static void do_math(bNode *node, float *out, float *in, float *in2) { /* Don't want any imaginary numbers... */ if ( in[0] > 0 && in2[0] > 0 ) - out[0]= log(in[0]) / log(in2[0]); + out[0] = log(in[0]) / log(in2[0]); else - out[0]= 0.0; + out[0] = 0.0; } break; case 12: /* Minimum */ { if ( in[0] < in2[0] ) - out[0]= in[0]; + out[0] = in[0]; else - out[0]= in2[0]; + out[0] = in2[0]; } break; case 13: /* Maximum */ { if ( in[0] > in2[0] ) - out[0]= in[0]; + out[0] = in[0]; else - out[0]= in2[0]; + out[0] = in2[0]; } break; case 14: /* Round */ { /* round by the second value */ if ( in2[0] != 0.0f ) - out[0]= floorf(in[0] / in2[0] + 0.5f) * in2[0]; + out[0] = floorf(in[0] / in2[0] + 0.5f) * in2[0]; else - out[0]= floorf(in[0] + 0.5f); + out[0] = floorf(in[0] + 0.5f); } break; case 15: /* Less Than */ { if ( in[0] < in2[0] ) - out[0]= 1.0f; + out[0] = 1.0f; else - out[0]= 0.0f; + out[0] = 0.0f; } break; case 16: /* Greater Than */ { if ( in[0] > in2[0] ) - out[0]= 1.0f; + out[0] = 1.0f; else - out[0]= 0.0f; + out[0] = 0.0f; } break; } diff --git a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c index e2c9a5abcb1..5d3ee480612 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mixrgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_mixrgb.c @@ -32,13 +32,13 @@ #include "node_composite_util.h" /* **************** MIX RGB ******************** */ -static bNodeSocketTemplate cmp_node_mix_rgb_in[]= { +static bNodeSocketTemplate cmp_node_mix_rgb_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 5.0f, PROP_FACTOR}, { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_mix_rgb_out[]= { +static bNodeSocketTemplate cmp_node_mix_rgb_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -55,7 +55,7 @@ static void do_mix_rgb(bNode *node, float *out, float *in1, float *in2, float *f else ramp_blend(node->custom1, col, fac[0], in2); copy_v3_v3(out, col); - out[3]= in1[3]; + out[3] = in1[3]; } static void node_composit_exec_mix_rgb(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/composite/nodes/node_composite_normal.c b/source/blender/nodes/composite/nodes/node_composite_normal.c index 6f1e86e2760..93fd7ca1c1b 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normal.c +++ b/source/blender/nodes/composite/nodes/node_composite_normal.c @@ -34,12 +34,12 @@ /* **************** NORMAL ******************** */ -static bNodeSocketTemplate cmp_node_normal_in[]= { +static bNodeSocketTemplate cmp_node_normal_in[] = { { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_DIRECTION}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_normal_out[]= { +static bNodeSocketTemplate cmp_node_normal_out[] = { { SOCK_VECTOR, 0, N_("Normal")}, { SOCK_FLOAT, 0, N_("Dot")}, { -1, 0, "" } @@ -53,7 +53,7 @@ static void do_normal(bNode *node, float *out, float *in) float *nor= ((bNodeSocketValueVector*)sock->default_value)->value; /* render normals point inside... the widget points outside */ - out[0]= -dot_v3v3(nor, in); + out[0] = -dot_v3v3(nor, in); } /* generates normal, does dot product */ @@ -68,7 +68,7 @@ static void node_composit_exec_normal(void *UNUSED(data), bNode *node, bNodeStac if (in[0]->data==NULL) { copy_v3_v3(out[0]->vec, nor); /* render normals point inside... the widget points outside */ - out[1]->vec[0]= -dot_v3v3(out[0]->vec, in[0]->vec); + out[1]->vec[0] = -dot_v3v3(out[0]->vec, in[0]->vec); } else if (out[1]->hasoutput) { /* make output size of input image */ diff --git a/source/blender/nodes/composite/nodes/node_composite_normalize.c b/source/blender/nodes/composite/nodes/node_composite_normalize.c index 1d2312d8280..19b543dce5d 100644 --- a/source/blender/nodes/composite/nodes/node_composite_normalize.c +++ b/source/blender/nodes/composite/nodes/node_composite_normalize.c @@ -34,11 +34,11 @@ /* **************** NORMALIZE single channel, useful for Z buffer ******************** */ -static bNodeSocketTemplate cmp_node_normalize_in[]= { +static bNodeSocketTemplate cmp_node_normalize_in[] = { { SOCK_FLOAT, 1, N_("Value"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_normalize_out[]= { +static bNodeSocketTemplate cmp_node_normalize_out[] = { { SOCK_FLOAT, 0, N_("Value")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_pixelate.c b/source/blender/nodes/composite/nodes/node_composite_pixelate.c new file mode 100644 index 00000000000..5eac4867a23 --- /dev/null +++ b/source/blender/nodes/composite/nodes/node_composite_pixelate.c @@ -0,0 +1,57 @@ +/* + * ***** 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) 2006 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Jeroen Bakker + * Monique Dewanchand + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/nodes/composite/nodes/node_composite_pixelate.c + * \ingroup cmpnodes + */ + + +#include "node_composite_util.h" + + +/* **************** Pixelate ******************** */ + +static bNodeSocketTemplate cmp_node_pixelate_in[] = { + { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, + { -1, 0, "" } +}; +static bNodeSocketTemplate cmp_node_pixelate_out[] = { + { SOCK_RGBA, 0, N_("Color")}, + { -1, 0, "" } +}; + +void register_node_type_cmp_pixelate(bNodeTreeType *ttype) +{ + static bNodeType ntype; + + node_type_base(ttype, &ntype, CMP_NODE_PIXELATE, "Pixelate", NODE_CLASS_OP_FILTER, NODE_OPTIONS); + node_type_socket_templates(&ntype, cmp_node_pixelate_in, cmp_node_pixelate_out); + node_type_size(&ntype, 130, 100, 130); + + nodeRegisterType(ttype, &ntype); +} diff --git a/source/blender/nodes/composite/nodes/node_composite_premulkey.c b/source/blender/nodes/composite/nodes/node_composite_premulkey.c index d791983b069..7f7b7692b02 100644 --- a/source/blender/nodes/composite/nodes/node_composite_premulkey.c +++ b/source/blender/nodes/composite/nodes/node_composite_premulkey.c @@ -35,11 +35,11 @@ /* **************** Premul and Key Alpha Convert ******************** */ -static bNodeSocketTemplate cmp_node_premulkey_in[]= { +static bNodeSocketTemplate cmp_node_premulkey_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_premulkey_out[]= { +static bNodeSocketTemplate cmp_node_premulkey_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_rgb.c b/source/blender/nodes/composite/nodes/node_composite_rgb.c index 65c1dcdb7bb..54fba650783 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_rgb.c @@ -34,7 +34,7 @@ /* **************** RGB ******************** */ -static bNodeSocketTemplate cmp_node_rgb_out[]= { +static bNodeSocketTemplate cmp_node_rgb_out[] = { { SOCK_RGBA, 0, N_("RGBA"), 0.5f, 0.5f, 0.5f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.c b/source/blender/nodes/composite/nodes/node_composite_rotate.c index 8968fd5fb3a..9a76764b97e 100644 --- a/source/blender/nodes/composite/nodes/node_composite_rotate.c +++ b/source/blender/nodes/composite/nodes/node_composite_rotate.c @@ -34,12 +34,12 @@ /* **************** Rotate ******************** */ -static bNodeSocketTemplate cmp_node_rotate_in[]= { +static bNodeSocketTemplate cmp_node_rotate_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Degr"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_ANGLE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_rotate_out[]= { +static bNodeSocketTemplate cmp_node_rotate_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c index ebc18cd19eb..f1a75493718 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombHSVA.c @@ -34,11 +34,11 @@ /* **************** SEPARATE HSVA ******************** */ -static bNodeSocketTemplate cmp_node_sephsva_in[]= { +static bNodeSocketTemplate cmp_node_sephsva_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_sephsva_out[]= { +static bNodeSocketTemplate cmp_node_sephsva_out[] = { { SOCK_FLOAT, 0, N_("H")}, { SOCK_FLOAT, 0, N_("S")}, { SOCK_FLOAT, 0, N_("V")}, @@ -54,10 +54,10 @@ static void do_sephsva(bNode *UNUSED(node), float *out, float *in) rgb_to_hsv(in[0], in[1], in[2], &h, &s, &v); - out[0]= h; - out[1]= s; - out[2]= v; - out[3]= in[3]; + out[0] = h; + out[1] = s; + out[2] = v; + out[3] = in[3]; } static void node_composit_exec_sephsva(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) @@ -97,7 +97,7 @@ static void node_composit_exec_sephsva(void *UNUSED(data), bNode *node, bNodeSta /*not used anymore */ if (cbuf2!=cbuf) free_compbuf(cbuf2); - free_compbuf(cbuf); + free_compbuf(cbuf); } } @@ -126,7 +126,7 @@ static bNodeSocketTemplate cmp_node_combhsva_in[] = { { SOCK_FLOAT, 1, N_("A"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_combhsva_out[]= { +static bNodeSocketTemplate cmp_node_combhsva_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c index 0c989ed3fc6..83b2c731020 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombRGBA.c @@ -33,11 +33,11 @@ #include "node_composite_util.h" /* **************** SEPARATE RGBA ******************** */ -static bNodeSocketTemplate cmp_node_seprgba_in[]= { +static bNodeSocketTemplate cmp_node_seprgba_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_seprgba_out[]= { +static bNodeSocketTemplate cmp_node_seprgba_out[] = { { SOCK_FLOAT, 0, N_("R")}, { SOCK_FLOAT, 0, N_("G")}, { SOCK_FLOAT, 0, N_("B")}, @@ -98,14 +98,14 @@ void register_node_type_cmp_seprgba(bNodeTreeType *ttype) /* **************** COMBINE RGBA ******************** */ -static bNodeSocketTemplate cmp_node_combrgba_in[]= { +static bNodeSocketTemplate cmp_node_combrgba_in[] = { { SOCK_FLOAT, 1, N_("R"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("G"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("B"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("A"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_combrgba_out[]= { +static bNodeSocketTemplate cmp_node_combrgba_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -150,7 +150,7 @@ static void node_composit_exec_combrgba(void *UNUSED(data), bNode *node, bNodeSt do_combrgba, CB_VAL, CB_VAL, CB_VAL, CB_VAL); out[0]->data= stackbuf; - } + } } #endif /* WITH_COMPOSITOR_LEGACY */ diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c index ccae7cfe57f..982d674708c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYCCA.c @@ -34,11 +34,11 @@ /* **************** SEPARATE YCCA ******************** */ -static bNodeSocketTemplate cmp_node_sepycca_in[]= { +static bNodeSocketTemplate cmp_node_sepycca_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_sepycca_out[]= { +static bNodeSocketTemplate cmp_node_sepycca_out[] = { { SOCK_FLOAT, 0, N_("Y")}, { SOCK_FLOAT, 0, N_("Cb")}, { SOCK_FLOAT, 0, N_("Cr")}, @@ -55,10 +55,10 @@ static void do_sepycca_601(bNode *UNUSED(node), float *out, float *in) rgb_to_ycc(in[0], in[1], in[2], &y, &cb, &cr, BLI_YCC_ITU_BT601); /*divided by 255 to normalize for viewing in */ - out[0]= y/255.0f; - out[1]= cb/255.0f; - out[2]= cr/255.0f; - out[3]= in[3]; + out[0] = y/255.0f; + out[1] = cb/255.0f; + out[2] = cr/255.0f; + out[3] = in[3]; } static void do_sepycca_709(bNode *UNUSED(node), float *out, float *in) @@ -68,10 +68,10 @@ static void do_sepycca_709(bNode *UNUSED(node), float *out, float *in) rgb_to_ycc(in[0], in[1], in[2], &y, &cb, &cr, BLI_YCC_ITU_BT709); /*divided by 255 to normalize for viewing in */ - out[0]= y/255.0f; - out[1]= cb/255.0f; - out[2]= cr/255.0f; - out[3]= in[3]; + out[0] = y/255.0f; + out[1] = cb/255.0f; + out[2] = cr/255.0f; + out[3] = in[3]; } static void do_sepycca_jfif(bNode *UNUSED(node), float *out, float *in) @@ -81,10 +81,10 @@ static void do_sepycca_jfif(bNode *UNUSED(node), float *out, float *in) rgb_to_ycc(in[0], in[1], in[2], &y, &cb, &cr, BLI_YCC_JFIF_0_255); /*divided by 255 to normalize for viewing in */ - out[0]= y/255.0f; - out[1]= cb/255.0f; - out[2]= cr/255.0f; - out[3]= in[3]; + out[0] = y/255.0f; + out[1] = cb/255.0f; + out[2] = cr/255.0f; + out[3] = in[3]; } static void node_composit_exec_sepycca(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) @@ -167,14 +167,14 @@ void register_node_type_cmp_sepycca(bNodeTreeType *ttype) /* **************** COMBINE YCCA ******************** */ -static bNodeSocketTemplate cmp_node_combycca_in[]= { +static bNodeSocketTemplate cmp_node_combycca_in[] = { { SOCK_FLOAT, 1, N_("Y"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("Cb"), 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("Cr"), 0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("A"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_combycca_out[]= { +static bNodeSocketTemplate cmp_node_combycca_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; @@ -296,7 +296,7 @@ static void node_composit_exec_combycca(void *UNUSED(data), bNode *node, bNodeSt } out[0]->data= stackbuf; - } + } } #endif /* WITH_COMPOSITOR_LEGACY */ diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c index 9b8c805b0f0..0a9575971b4 100644 --- a/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c +++ b/source/blender/nodes/composite/nodes/node_composite_sepcombYUVA.c @@ -34,11 +34,11 @@ /* **************** SEPARATE YUVA ******************** */ -static bNodeSocketTemplate cmp_node_sepyuva_in[]= { +static bNodeSocketTemplate cmp_node_sepyuva_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_sepyuva_out[]= { +static bNodeSocketTemplate cmp_node_sepyuva_out[] = { { SOCK_FLOAT, 0, N_("Y")}, { SOCK_FLOAT, 0, N_("U")}, { SOCK_FLOAT, 0, N_("V")}, @@ -54,10 +54,10 @@ static void do_sepyuva(bNode *UNUSED(node), float *out, float *in) rgb_to_yuv(in[0], in[1], in[2], &y, &u, &v); - out[0]= y; - out[1]= u; - out[2]= v; - out[3]= in[3]; + out[0] = y; + out[1] = u; + out[2] = v; + out[3] = in[3]; } static void node_composit_exec_sepyuva(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) @@ -121,14 +121,14 @@ void register_node_type_cmp_sepyuva(bNodeTreeType *ttype) /* **************** COMBINE YUVA ******************** */ -static bNodeSocketTemplate cmp_node_combyuva_in[]= { +static bNodeSocketTemplate cmp_node_combyuva_in[] = { { SOCK_FLOAT, 1, N_("Y"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("U"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("V"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("A"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_combyuva_out[]= { +static bNodeSocketTemplate cmp_node_combyuva_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_setalpha.c b/source/blender/nodes/composite/nodes/node_composite_setalpha.c index 503815b74a0..59c104869fe 100644 --- a/source/blender/nodes/composite/nodes/node_composite_setalpha.c +++ b/source/blender/nodes/composite/nodes/node_composite_setalpha.c @@ -33,12 +33,12 @@ #include "node_composite_util.h" /* **************** SET ALPHA ******************** */ -static bNodeSocketTemplate cmp_node_setalpha_in[]= { +static bNodeSocketTemplate cmp_node_setalpha_in[] = { { SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_setalpha_out[]= { +static bNodeSocketTemplate cmp_node_setalpha_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index f6811f526f7..73cf039c6df 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -33,7 +33,7 @@ #include "node_composite_util.h" /* **************** SPLIT VIEWER ******************** */ -static bNodeSocketTemplate cmp_node_splitviewer_in[]= { +static bNodeSocketTemplate cmp_node_splitviewer_in[] = { { SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_RGBA, 1, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } @@ -167,7 +167,7 @@ void register_node_type_cmp_splitviewer(bNodeTreeType *ttype) #endif /* Do not allow muting for this node. */ - node_type_internal_connect(&ntype, NULL); + node_type_internal_links(&ntype, NULL); nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c index fdf0b38e844..1787e075a14 100644 --- a/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c +++ b/source/blender/nodes/composite/nodes/node_composite_stabilize2d.c @@ -35,12 +35,12 @@ /* **************** Translate ******************** */ -static bNodeSocketTemplate cmp_node_stabilize2d_in[]= { +static bNodeSocketTemplate cmp_node_stabilize2d_in[] = { { SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_stabilize2d_out[]= { +static bNodeSocketTemplate cmp_node_stabilize2d_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_switch.c b/source/blender/nodes/composite/nodes/node_composite_switch.c index 258fac18c11..7f9127c969f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_switch.c +++ b/source/blender/nodes/composite/nodes/node_composite_switch.c @@ -34,13 +34,13 @@ #include "../node_composite_util.h" /* **************** MIX RGB ******************** */ -static bNodeSocketTemplate cmp_node_switch_in[]= { +static bNodeSocketTemplate cmp_node_switch_in[] = { { SOCK_RGBA, 1, N_("Off"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_RGBA, 1, N_("On"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_switch_out[]= { +static bNodeSocketTemplate cmp_node_switch_out[] = { { SOCK_RGBA, 0, N_("Image"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_texture.c b/source/blender/nodes/composite/nodes/node_composite_texture.c index 3fedccd7d12..b6518c48638 100644 --- a/source/blender/nodes/composite/nodes/node_composite_texture.c +++ b/source/blender/nodes/composite/nodes/node_composite_texture.c @@ -33,12 +33,12 @@ #include "node_composite_util.h" /* **************** TEXTURE ******************** */ -static bNodeSocketTemplate cmp_node_texture_in[]= { +static bNodeSocketTemplate cmp_node_texture_in[] = { { SOCK_VECTOR, 1, N_("Offset"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_TRANSLATION}, { SOCK_VECTOR, 1, N_("Scale"), 1.0f, 1.0f, 1.0f, 1.0f, -10.0f, 10.0f, PROP_XYZ}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_texture_out[]= { +static bNodeSocketTemplate cmp_node_texture_out[] = { { SOCK_FLOAT, 0, N_("Value")}, { SOCK_RGBA, 0, N_("Color")}, { -1, 0, "" } @@ -51,28 +51,28 @@ static void texture_procedural(CompBuf *cbuf, float *out, float xco, float yco) { bNode *node= cbuf->node; TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; - float vec[3], *size, nor[3]={0.0f, 0.0f, 0.0f}, col[4]; + float vec[3], *size, nor[3] = {0.0f, 0.0f, 0.0f}, col[4]; int retval, type= cbuf->procedural_type; size= cbuf->procedural_size; - vec[0]= size[0]*(xco + cbuf->procedural_offset[0]); - vec[1]= size[1]*(yco + cbuf->procedural_offset[1]); - vec[2]= size[2]*cbuf->procedural_offset[2]; + vec[0] = size[0]*(xco + cbuf->procedural_offset[0]); + vec[1] = size[1]*(yco + cbuf->procedural_offset[1]); + vec[2] = size[2]*cbuf->procedural_offset[2]; retval= multitex_ext((Tex *)node->id, vec, NULL, NULL, 0, &texres); if (type==CB_VAL) { if (texres.talpha) - col[0]= texres.ta; + col[0] = texres.ta; else - col[0]= texres.tin; + col[0] = texres.tin; } else if (type==CB_RGBA) { if (texres.talpha) - col[3]= texres.ta; + col[3] = texres.ta; else - col[3]= texres.tin; + col[3] = texres.tin; if ((retval & TEX_RGB)) { copy_v3_v3(col, &texres.tr); @@ -81,7 +81,7 @@ static void texture_procedural(CompBuf *cbuf, float *out, float xco, float yco) copy_v3_fl(col, col[3]); } } - else { + else { copy_v3_v3(col, nor); } diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.c b/source/blender/nodes/composite/nodes/node_composite_tonemap.c index 5e4efe2f3b1..00b1a5514dc 100644 --- a/source/blender/nodes/composite/nodes/node_composite_tonemap.c +++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.c @@ -32,11 +32,11 @@ #include "node_composite_util.h" -static bNodeSocketTemplate cmp_node_tonemap_in[]= { +static bNodeSocketTemplate cmp_node_tonemap_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_tonemap_out[]= { +static bNodeSocketTemplate cmp_node_tonemap_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_translate.c b/source/blender/nodes/composite/nodes/node_composite_translate.c index 649902ff908..1c2963a2f08 100644 --- a/source/blender/nodes/composite/nodes/node_composite_translate.c +++ b/source/blender/nodes/composite/nodes/node_composite_translate.c @@ -35,13 +35,13 @@ /* **************** Translate ******************** */ -static bNodeSocketTemplate cmp_node_translate_in[]= { +static bNodeSocketTemplate cmp_node_translate_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, N_("X"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("Y"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_translate_out[]= { +static bNodeSocketTemplate cmp_node_translate_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c index 87a776c7bea..5c111998b18 100644 --- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c @@ -34,11 +34,11 @@ /* **************** VALTORGB ******************** */ -static bNodeSocketTemplate cmp_node_valtorgb_in[]= { +static bNodeSocketTemplate cmp_node_valtorgb_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_valtorgb_out[]= { +static bNodeSocketTemplate cmp_node_valtorgb_out[] = { { SOCK_RGBA, 0, N_("Image")}, { SOCK_FLOAT, 0, N_("Alpha")}, { -1, 0, "" } @@ -106,11 +106,11 @@ void register_node_type_cmp_valtorgb(bNodeTreeType *ttype) /* **************** RGBTOBW ******************** */ -static bNodeSocketTemplate cmp_node_rgbtobw_in[]= { +static bNodeSocketTemplate cmp_node_rgbtobw_in[] = { { SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_rgbtobw_out[]= { +static bNodeSocketTemplate cmp_node_rgbtobw_out[] = { { SOCK_FLOAT, 0, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/composite/nodes/node_composite_value.c b/source/blender/nodes/composite/nodes/node_composite_value.c index 63ab4fcb58f..2c65fe6be19 100644 --- a/source/blender/nodes/composite/nodes/node_composite_value.c +++ b/source/blender/nodes/composite/nodes/node_composite_value.c @@ -33,7 +33,7 @@ #include "node_composite_util.h" /* **************** VALUE ******************** */ -static bNodeSocketTemplate cmp_node_value_out[]= { +static bNodeSocketTemplate cmp_node_value_out[] = { /* XXX value nodes use the output sockets for buttons, so we need explicit limits here! */ { SOCK_FLOAT, 0, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, { -1, 0, "" } @@ -56,7 +56,7 @@ static void node_composit_exec_value(void *UNUSED(data), bNode *node, bNodeStack bNodeSocket *sock= node->outputs.first; float val= ((bNodeSocketValueFloat*)sock->default_value)->value; - out[0]->vec[0]= val; + out[0]->vec[0] = val; } #endif /* WITH_COMPOSITOR_LEGACY */ diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index 6321b1def4d..938f75cf3f5 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -149,7 +149,7 @@ void register_node_type_cmp_viewer(bNodeTreeType *ttype) node_type_exec(&ntype, node_composit_exec_viewer); #endif - node_type_internal_connect(&ntype, NULL); + node_type_internal_links(&ntype, NULL); nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/composite/nodes/node_composite_zcombine.c b/source/blender/nodes/composite/nodes/node_composite_zcombine.c index 3decbe8d230..8e639aaa357 100644 --- a/source/blender/nodes/composite/nodes/node_composite_zcombine.c +++ b/source/blender/nodes/composite/nodes/node_composite_zcombine.c @@ -35,14 +35,14 @@ /* **************** Z COMBINE ******************** */ /* lazy coder note: node->custom2 is abused to send signal */ -static bNodeSocketTemplate cmp_node_zcombine_in[]= { +static bNodeSocketTemplate cmp_node_zcombine_in[] = { { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Z"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 10000.0f, PROP_NONE}, { SOCK_RGBA, 1, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Z"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 10000.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate cmp_node_zcombine_out[]= { +static bNodeSocketTemplate cmp_node_zcombine_out[] = { { SOCK_RGBA, 0, N_("Image")}, { SOCK_FLOAT, 0, N_("Z")}, { -1, 0, "" } @@ -60,10 +60,10 @@ static void do_zcombine(bNode *node, float *out, float *src1, float *z1, float * // use alpha in combine operation alpha= src1[3]; malpha= 1.0f - alpha; - out[0]= malpha*src2[0] + alpha*src1[0]; - out[1]= malpha*src2[1] + alpha*src1[1]; - out[2]= malpha*src2[2] + alpha*src1[2]; - out[3]= malpha*src2[3] + alpha*src1[3]; + out[0] = malpha*src2[0] + alpha*src1[0]; + out[1] = malpha*src2[1] + alpha*src1[1]; + out[2] = malpha*src2[2] + alpha*src1[2]; + out[3] = malpha*src2[3] + alpha*src1[3]; } else { // do combination based solely on z value @@ -75,10 +75,10 @@ static void do_zcombine(bNode *node, float *out, float *src1, float *z1, float * // use alpha in combine operation alpha= src2[3]; malpha= 1.0f - alpha; - out[0]= malpha*src1[0] + alpha*src2[0]; - out[1]= malpha*src1[1] + alpha*src2[1]; - out[2]= malpha*src1[2] + alpha*src2[2]; - out[3]= malpha*src1[3] + alpha*src2[3]; + out[0] = malpha*src1[0] + alpha*src2[0]; + out[1] = malpha*src1[1] + alpha*src2[1]; + out[2] = malpha*src1[2] + alpha*src2[2]; + out[3] = malpha*src1[3] + alpha*src2[3]; } else { // do combination based solely on z value @@ -111,20 +111,20 @@ static void do_zcombine_add(bNode *node, float *out, float *col1, float *col2, f malpha= 1.0f - alpha; - out[0]= malpha*col1[0] + alpha*col2[0]; - out[1]= malpha*col1[1] + alpha*col2[1]; - out[2]= malpha*col1[2] + alpha*col2[2]; - out[3]= malpha*col1[3] + alpha*col2[3]; + out[0] = malpha*col1[0] + alpha*col2[0]; + out[1] = malpha*col1[1] + alpha*col2[1]; + out[2] = malpha*col1[2] + alpha*col2[2]; + out[3] = malpha*col1[3] + alpha*col2[3]; } else { alpha= col1[3]; malpha= 1.0f - alpha; - out[0]= malpha*col2[0] + alpha*col1[0]; - out[1]= malpha*col2[1] + alpha*col1[1]; - out[2]= malpha*col2[2] + alpha*col1[2]; - out[3]= malpha*col2[3] + alpha*col1[3]; + out[0] = malpha*col2[0] + alpha*col1[0]; + out[1] = malpha*col2[1] + alpha*col1[1]; + out[2] = malpha*col2[2] + alpha*col1[2]; + out[3] = malpha*col2[3] + alpha*col1[3]; } } else { @@ -132,10 +132,10 @@ static void do_zcombine_add(bNode *node, float *out, float *col1, float *col2, f alpha = *acol; malpha= 1.0f - alpha; - out[0]= malpha*col1[0] + alpha*col2[0]; - out[1]= malpha*col1[1] + alpha*col2[1]; - out[2]= malpha*col1[2] + alpha*col2[2]; - out[3]= malpha*col1[3] + alpha*col2[3]; + out[0] = malpha*col1[0] + alpha*col2[0]; + out[1] = malpha*col1[1] + alpha*col2[1]; + out[2] = malpha*col1[2] + alpha*col2[2]; + out[3] = malpha*col1[3] + alpha*col2[3]; } } @@ -202,8 +202,8 @@ static void node_composit_exec_zcombine(void *data, bNode *node, bNodeStack **in aabuf= MEM_mallocN(cbuf->x*cbuf->y, "aa buf"); fp= mbuf->rect; for (x= cbuf->x*cbuf->y-1; x>=0; x--) - if (fp[x]==0.0f) aabuf[x]= 0; - else aabuf[x]= 255; + if (fp[x]==0.0f) aabuf[x] = 0; + else aabuf[x] = 255; antialias_tagbuf(cbuf->x, cbuf->y, aabuf); @@ -211,7 +211,7 @@ static void node_composit_exec_zcombine(void *data, bNode *node, bNodeStack **in fp= mbuf->rect; for (x= cbuf->x*cbuf->y-1; x>=0; x--) if (aabuf[x]>1) - fp[x]= (1.0f/255.0f)*(float)aabuf[x]; + fp[x] = (1.0f/255.0f)*(float)aabuf[x]; composit3_pixel_processor(node, stackbuf, in[0]->data, in[0]->vec, in[2]->data, in[2]->vec, mbuf, NULL, do_zcombine_add, CB_RGBA, CB_RGBA, CB_VAL); diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index 301dea22c17..86ef8a14c12 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -92,7 +92,7 @@ bNodeSocket *node_group_add_extern_socket(bNodeTree *UNUSED(ntree), ListBase *lb sock->new_sock = NULL; /* group sockets are dynamically added */ - sock->flag |= SOCK_DYNAMIC; + sock->flag |= SOCK_DYNAMIC|SOCK_COLLAPSED; sock->own_index = gsock->own_index; sock->groupsock = gsock; @@ -115,7 +115,7 @@ bNodeSocket *node_group_add_socket(bNodeTree *ngroup, const char *name, int type BLI_strncpy(gsock->name, name, sizeof(gsock->name)); gsock->type = type; /* group sockets are dynamically added */ - gsock->flag |= SOCK_DYNAMIC; + gsock->flag |= SOCK_DYNAMIC|SOCK_COLLAPSED; gsock->next = gsock->prev = NULL; gsock->new_sock = NULL; @@ -354,168 +354,6 @@ static void UNUSED_FUNCTION(node_group_link)(bNodeTree *ntree, bNodeSocket *sock node_group_expose_socket(ntree, sock, in_out); } -/**** For Loop ****/ - -/* Essentially a group node with slightly different behavior. - * The internal tree is executed several times, with each output being re-used - * as an input in the next iteration. For this purpose, input and output socket - * lists are kept identical! - */ - -bNodeTemplate node_forloop_template(bNode *node) -{ - bNodeTemplate ntemp; - ntemp.type = NODE_FORLOOP; - ntemp.ngroup = (bNodeTree*)node->id; - return ntemp; -} - -void node_forloop_init(bNodeTree *ntree, bNode *node, bNodeTemplate *ntemp) -{ - bNodeSocket *sock; - - node->id = (ID*)ntemp->ngroup; - - sock = nodeAddSocket(ntree, node, SOCK_IN, "Iterations", SOCK_FLOAT); - node_socket_set_default_value_float(sock->default_value, PROP_UNSIGNED, 1, 0, 10000); - - /* NB: group socket input/output roles are inverted internally! - * Group "inputs" work as outputs in links and vice versa. - */ - if (ntemp->ngroup) { - bNodeSocket *gsock; - for (gsock=ntemp->ngroup->inputs.first; gsock; gsock=gsock->next) - node_group_add_extern_socket(ntree, &node->inputs, SOCK_IN, gsock); - for (gsock=ntemp->ngroup->outputs.first; gsock; gsock=gsock->next) - node_group_add_extern_socket(ntree, &node->outputs, SOCK_OUT, gsock); - } -} - -void node_forloop_init_tree(bNodeTree *ntree) -{ - bNodeSocket *sock; - sock = node_group_add_socket(ntree, "Iteration", SOCK_FLOAT, SOCK_IN); - sock->flag |= SOCK_INTERNAL; -} - -static void loop_sync(bNodeTree *ntree, int sync_in_out) -{ - bNodeSocket *sock, *sync, *nsync, *mirror; - ListBase *sync_lb; - - if (sync_in_out==SOCK_IN) { - sock = ntree->outputs.first; - - sync = ntree->inputs.first; - sync_lb = &ntree->inputs; - } - else { - sock = ntree->inputs.first; - - sync = ntree->outputs.first; - sync_lb = &ntree->outputs; - } - - /* NB: the sock->storage pointer is used here directly to store the own_index int - * out the mirrored socket counterpart! - */ - - while (sock) { - /* skip static and internal sockets on the sync side (preserves socket order!) */ - while (sync && ((sync->flag & SOCK_INTERNAL) || !(sync->flag & SOCK_DYNAMIC))) - sync = sync->next; - - if (sync && !(sync->flag & SOCK_INTERNAL) && (sync->flag & SOCK_DYNAMIC)) { - if (sock->storage==NULL) { - /* if mirror index is 0, the sockets is newly added and a new mirror must be created. */ - mirror = node_group_expose_socket(ntree, sock, sync_in_out); - /* store the mirror index */ - sock->storage = SET_INT_IN_POINTER(mirror->own_index); - mirror->storage = SET_INT_IN_POINTER(sock->own_index); - /* move mirror to the right place */ - BLI_remlink(sync_lb, mirror); - if (sync) - BLI_insertlinkbefore(sync_lb, sync, mirror); - else - BLI_addtail(sync_lb, mirror); - } - else { - /* look up the mirror socket */ - for (mirror=sync; mirror; mirror=mirror->next) - if (mirror->own_index == GET_INT_FROM_POINTER(sock->storage)) - break; - /* make sure the name is the same (only for identification by user, no deeper meaning) */ - BLI_strncpy(mirror->name, sock->name, sizeof(mirror->name)); - /* fix the socket order if necessary */ - if (mirror != sync) { - BLI_remlink(sync_lb, mirror); - BLI_insertlinkbefore(sync_lb, sync, mirror); - } - else - sync = sync->next; - } - } - - sock = sock->next; - } - - /* remaining sockets in sync_lb are leftovers from deleted sockets, remove them */ - while (sync) { - nsync = sync->next; - if (!(sync->flag & SOCK_INTERNAL) && (sync->flag & SOCK_DYNAMIC)) - node_group_remove_socket(ntree, sync, sync_in_out); - sync = nsync; - } -} - -void node_loop_update_tree(bNodeTree *ngroup) -{ - /* make sure inputs & outputs are identical */ - if (ngroup->update & NTREE_UPDATE_GROUP_IN) - loop_sync(ngroup, SOCK_OUT); - if (ngroup->update & NTREE_UPDATE_GROUP_OUT) - loop_sync(ngroup, SOCK_IN); -} - -void node_whileloop_init(bNodeTree *ntree, bNode *node, bNodeTemplate *ntemp) -{ - bNodeSocket *sock; - - node->id = (ID*)ntemp->ngroup; - - sock = nodeAddSocket(ntree, node, SOCK_IN, "Condition", SOCK_FLOAT); - node_socket_set_default_value_float(sock->default_value, PROP_NONE, 1, 0, 1); - - /* max iterations */ - node->custom1 = 10000; - - /* NB: group socket input/output roles are inverted internally! - * Group "inputs" work as outputs in links and vice versa. - */ - if (ntemp->ngroup) { - bNodeSocket *gsock; - for (gsock=ntemp->ngroup->inputs.first; gsock; gsock=gsock->next) - node_group_add_extern_socket(ntree, &node->inputs, SOCK_IN, gsock); - for (gsock=ntemp->ngroup->outputs.first; gsock; gsock=gsock->next) - node_group_add_extern_socket(ntree, &node->outputs, SOCK_OUT, gsock); - } -} - -void node_whileloop_init_tree(bNodeTree *ntree) -{ - bNodeSocket *sock; - sock = node_group_add_socket(ntree, "Condition", SOCK_FLOAT, SOCK_OUT); - sock->flag |= SOCK_INTERNAL; -} - -bNodeTemplate node_whileloop_template(bNode *node) -{ - bNodeTemplate ntemp; - ntemp.type = NODE_WHILELOOP; - ntemp.ngroup = (bNodeTree*)node->id; - return ntemp; -} - /**** FRAME ****/ static void node_frame_init(bNodeTree *UNUSED(ntree), bNode *node, bNodeTemplate *UNUSED(ntemp)) @@ -547,16 +385,13 @@ void register_node_type_frame(bNodeTreeType *ttype) /* **************** REROUTE ******************** */ /* simple, only a single input and output here */ -static ListBase node_reroute_internal_connect(bNodeTree *ntree, bNode *node) +static void node_reroute_update_internal_links(bNodeTree *ntree, bNode *node) { bNodeLink *link; - ListBase ret; - - ret.first = ret.last = NULL; /* Security check! */ if (!ntree) - return ret; + return; link = MEM_callocN(sizeof(bNodeLink), "internal node link"); link->fromnode = node; @@ -565,9 +400,7 @@ static ListBase node_reroute_internal_connect(bNodeTree *ntree, bNode *node) link->tosock = node->outputs.first; /* internal link is always valid */ link->flag |= NODE_LINK_VALID; - BLI_addtail(&ret, link); - - return ret; + BLI_addtail(&node->internal_links, link); } static void node_reroute_init(bNodeTree *ntree, bNode *node, bNodeTemplate *UNUSED(ntemp)) @@ -586,7 +419,7 @@ void register_node_type_reroute(bNodeTreeType *ttype) node_type_base(ttype, ntype, NODE_REROUTE, "Reroute", NODE_CLASS_LAYOUT, 0); node_type_init(ntype, node_reroute_init); - node_type_internal_connect(ntype, node_reroute_internal_connect); + node_type_internal_links(ntype, node_reroute_update_internal_links); ntype->needs_free = 1; nodeRegisterType(ttype, ntype); diff --git a/source/blender/nodes/intern/node_common.h b/source/blender/nodes/intern/node_common.h index 00f72469b0f..9e04a9e05f8 100644 --- a/source/blender/nodes/intern/node_common.h +++ b/source/blender/nodes/intern/node_common.h @@ -38,18 +38,8 @@ struct bNodeTree; void node_group_init(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp); -void node_forloop_init(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp); -void node_whileloop_init(struct bNodeTree *ntree, struct bNode *node, struct bNodeTemplate *ntemp); - -void node_forloop_init_tree(struct bNodeTree *ntree); -void node_whileloop_init_tree(struct bNodeTree *ntree); - const char *node_group_label(struct bNode *node); - struct bNodeTemplate node_group_template(struct bNode *node); -struct bNodeTemplate node_forloop_template(struct bNode *node); -struct bNodeTemplate node_whileloop_template(struct bNode *node); - int node_group_valid(struct bNodeTree *ntree, struct bNodeTemplate *ntemp); void node_group_verify(struct bNodeTree *ntree, struct bNode *node, struct ID *id); @@ -57,8 +47,6 @@ struct bNodeTree *node_group_edit_get(struct bNode *node); struct bNodeTree *node_group_edit_set(struct bNode *node, int edit); void node_group_edit_clear(bNode *node); -void node_loop_update_tree(struct bNodeTree *ngroup); - void ntree_update_reroute_nodes(struct bNodeTree *ntree); #endif diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c index d01ef2e2d52..3cc7ebf9337 100644 --- a/source/blender/nodes/intern/node_exec.c +++ b/source/blender/nodes/intern/node_exec.c @@ -69,7 +69,7 @@ void node_get_stack(bNode *node, bNodeStack *stack, bNodeStack **in, bNodeStack } } -void node_init_input_index(bNodeSocket *sock, int *index) +static void node_init_input_index(bNodeSocket *sock, int *index) { if (sock->link && sock->link->fromsock) { sock->stack_index = sock->link->fromsock->stack_index; @@ -79,16 +79,31 @@ void node_init_input_index(bNodeSocket *sock, int *index) } } -void node_init_output_index(bNodeSocket *sock, int *index) +static void node_init_output_index(bNodeSocket *sock, int *index, ListBase *internal_links) { - sock->stack_index = (*index)++; + if (internal_links) { + bNodeLink *link; + /* copy the stack index from internally connected input to skip the node */ + for (link = internal_links->first; link; link = link->next) { + if (link->tosock == sock) { + sock->stack_index = link->fromsock->stack_index; + break; + } + } + /* if not internally connected, assign a new stack index anyway to avoid bad stack access */ + if (!link) + sock->stack_index = (*index)++; + } + else { + sock->stack_index = (*index)++; + } } /* basic preparation of socket stacks */ static struct bNodeStack *setup_stack(bNodeStack *stack, bNodeSocket *sock) { bNodeStack *ns = node_get_socket_stack(stack, sock); - float null_value[4]= {0.0f, 0.0f, 0.0f, 0.0f}; + float null_value[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* don't mess with remote socket stacks, these are initialized by other nodes! */ if (sock->link) @@ -133,7 +148,7 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree) bNodeExec *nodeexec; bNodeSocket *sock, *gsock; bNodeStack *ns; - int index= 0; + int index; bNode **nodelist; int totnodes, n; @@ -148,10 +163,11 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree) /* backpointer to node tree */ exec->nodetree = ntree; + /* set stack indices */ + index = 0; /* group inputs essentially work as outputs */ for (gsock=ntree->inputs.first; gsock; gsock = gsock->next) - node_init_output_index(gsock, &index); - /* set stack indexes */ + node_init_output_index(gsock, &index, NULL); for (n=0; n < totnodes; ++n) { node = nodelist[n]; @@ -160,8 +176,15 @@ bNodeTreeExec *ntree_exec_begin(bNodeTree *ntree) /* init node socket stack indexes */ for (sock=node->inputs.first; sock; sock=sock->next) node_init_input_index(sock, &index); - for (sock=node->outputs.first; sock; sock=sock->next) - node_init_output_index(sock, &index); + + if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) { + for (sock=node->outputs.first; sock; sock=sock->next) + node_init_output_index(sock, &index, &node->internal_links); + } + else { + for (sock=node->outputs.first; sock; sock=sock->next) + node_init_output_index(sock, &index, NULL); + } } /* group outputs essentially work as inputs */ for (gsock=ntree->outputs.first; gsock; gsock = gsock->next) diff --git a/source/blender/nodes/intern/node_exec.h b/source/blender/nodes/intern/node_exec.h index 1003206e96a..e985795de71 100644 --- a/source/blender/nodes/intern/node_exec.h +++ b/source/blender/nodes/intern/node_exec.h @@ -73,8 +73,6 @@ typedef struct bNodeThreadStack { struct bNodeStack *node_get_socket_stack(struct bNodeStack *stack, struct bNodeSocket *sock); void node_get_stack(struct bNode *node, struct bNodeStack *stack, struct bNodeStack **in, struct bNodeStack **out); -void node_init_input_index(struct bNodeSocket *sock, int *index); -void node_init_output_index(struct bNodeSocket *sock, int *index); struct bNodeTreeExec *ntree_exec_begin(struct bNodeTree *ntree); void ntree_exec_end(struct bNodeTreeExec *exec); diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c index 8b393dd740a..8e49484d1eb 100644 --- a/source/blender/nodes/intern/node_socket.c +++ b/source/blender/nodes/intern/node_socket.c @@ -490,39 +490,39 @@ static bNodeSocket *verify_socket_template(bNodeTree *ntree, bNode *node, int in break; } if (sock) { - sock->type= stemp->type; /* in future, read this from tydefs! */ - if (stemp->limit==0) sock->limit= 0xFFF; - else sock->limit= stemp->limit; + sock->type = stemp->type; /* in future, read this from tydefs! */ + if (stemp->limit == 0) sock->limit= 0xFFF; + else sock->limit = stemp->limit; sock->flag |= stemp->flag; /* Copy the property range and subtype parameters in case the template changed. * NOT copying the actual value here, only button behavior changes! */ switch (sock->type) { - case SOCK_FLOAT: + case SOCK_FLOAT: { bNodeSocketValueFloat *dval= sock->default_value; dval->min = stemp->min; dval->max = stemp->max; dval->subtype = stemp->subtype; + break; } - break; - case SOCK_INT: + case SOCK_INT: { bNodeSocketValueInt *dval= sock->default_value; dval->min = stemp->min; dval->max = stemp->max; dval->subtype = stemp->subtype; + break; } - break; - case SOCK_VECTOR: + case SOCK_VECTOR: { bNodeSocketValueVector *dval= sock->default_value; dval->min = stemp->min; dval->max = stemp->max; dval->subtype = stemp->subtype; + break; } - break; } BLI_remlink(socklist, sock); @@ -600,7 +600,9 @@ void node_verify_socket_templates(bNodeTree *ntree, bNode *node) * This also prevents group node sockets from being removed, without the need to explicitly * check the node type here. */ - if (ntype && ((ntype->inputs && ntype->inputs[0].type>=0) || (ntype->outputs && ntype->outputs[0].type>=0))) { + if (ntype && ((ntype->inputs && ntype->inputs[0].type >= 0) || + (ntype->outputs && ntype->outputs[0].type >= 0))) + { verify_socket_template_list(ntree, node, SOCK_IN, &node->inputs, ntype->inputs); verify_socket_template_list(ntree, node, SOCK_OUT, &node->outputs, ntype->outputs); } diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index 27258c45fe5..09e6ddd18a5 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -65,12 +65,12 @@ void node_free_standard_storage(bNode *node) void node_copy_curves(bNode *orig_node, bNode *new_node) { - new_node->storage= curvemapping_copy(orig_node->storage); + new_node->storage = curvemapping_copy(orig_node->storage); } void node_copy_standard_storage(bNode *orig_node, bNode *new_node) { - new_node->storage= MEM_dupallocN(orig_node->storage); + new_node->storage = MEM_dupallocN(orig_node->storage); } void *node_initexec_curves(bNode *node) @@ -109,18 +109,15 @@ const char *node_filter_label(bNode *node) return IFACE_(name); } -ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node) +void node_update_internal_links_default(bNodeTree *ntree, bNode *node) { - ListBase ret; bNodeSocket *fromsock_first=NULL, *tosock_first=NULL; /* used for fallback link if no other reconnections are found */ int datatype; int num_links_in = 0, num_links_out = 0, num_reconnect = 0; - ret.first = ret.last = NULL; - /* Security check! */ if (!ntree) - return ret; + return; for (datatype=0; datatype < NUM_SOCKET_TYPES; ++datatype) { bNodeSocket *fromsock, *tosock; @@ -170,7 +167,7 @@ ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node) ilink->tosock = tosock; /* internal link is always valid */ ilink->flag |= NODE_LINK_VALID; - BLI_addtail(&ret, ilink); + BLI_addtail(&node->internal_links, ilink); ++num_reconnect; } @@ -188,8 +185,6 @@ ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node) ilink->tosock = tosock_first; /* internal link is always valid */ ilink->flag |= NODE_LINK_VALID; - BLI_addtail(&ret, ilink); + BLI_addtail(&node->internal_links, ilink); } - - return ret; } diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h index 95104df5fed..3134baa283c 100644 --- a/source/blender/nodes/intern/node_util.h +++ b/source/blender/nodes/intern/node_util.h @@ -62,7 +62,7 @@ const char *node_math_label(struct bNode *node); const char *node_vect_math_label(struct bNode *node); const char *node_filter_label(struct bNode *node); -ListBase node_internal_connect_default(struct bNodeTree *ntree, struct bNode *node); +void node_update_internal_links_default(struct bNodeTree *ntree, struct bNode *node); #endif diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index ad907c317f8..76bc3b12690 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -153,7 +153,7 @@ bNodeTreeType ntreeType_Shader = { /* update */ update, /* update_node */ NULL, /* validate_link */ NULL, - /* internal_connect */ node_internal_connect_default + /* update_internal_links */ node_update_internal_links_default }; /* GPU material from shader nodes */ diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index 56704b981be..6130fe72af3 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -50,9 +50,9 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns) } else if (type_in==SOCK_VECTOR) { if (ns->sockettype==SOCK_FLOAT) { - in[0]= from[0]; - in[1]= from[0]; - in[2]= from[0]; + in[0] = from[0]; + in[1] = from[0]; + in[2] = from[0]; } else { copy_v3_v3(in, from); @@ -63,14 +63,14 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns) copy_v4_v4(in, from); } else if (ns->sockettype==SOCK_FLOAT) { - in[0]= from[0]; - in[1]= from[0]; - in[2]= from[0]; - in[3]= 1.0f; + in[0] = from[0]; + in[1] = from[0]; + in[2] = from[0]; + in[3] = 1.0f; } else { copy_v3_v3(in, from); - in[3]= 1.0f; + in[3] = 1.0f; } } } diff --git a/source/blender/nodes/shader/nodes/node_shader_add_shader.c b/source/blender/nodes/shader/nodes/node_shader_add_shader.c index ee8513a4119..ec868b2cc38 100644 --- a/source/blender/nodes/shader/nodes/node_shader_add_shader.c +++ b/source/blender/nodes/shader/nodes/node_shader_add_shader.c @@ -29,13 +29,13 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_add_shader_in[]= { +static bNodeSocketTemplate sh_node_add_shader_in[] = { { SOCK_SHADER, 1, N_("Shader")}, { SOCK_SHADER, 1, N_("Shader")}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_add_shader_out[]= { +static bNodeSocketTemplate sh_node_add_shader_out[] = { { SOCK_SHADER, 0, N_("Shader")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_attribute.c b/source/blender/nodes/shader/nodes/node_shader_attribute.c index 9c65323337e..9b2ed2f14f0 100644 --- a/source/blender/nodes/shader/nodes/node_shader_attribute.c +++ b/source/blender/nodes/shader/nodes/node_shader_attribute.c @@ -29,7 +29,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_attribute_out[]= { +static bNodeSocketTemplate sh_node_attribute_out[] = { { SOCK_RGBA, 0, N_("Color")}, { SOCK_VECTOR, 0, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, diff --git a/source/blender/nodes/shader/nodes/node_shader_background.c b/source/blender/nodes/shader/nodes/node_shader_background.c index 7d13c359a2b..d82c513540c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_background.c +++ b/source/blender/nodes/shader/nodes/node_shader_background.c @@ -29,13 +29,13 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_background_in[]= { +static bNodeSocketTemplate sh_node_background_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_background_out[]= { +static bNodeSocketTemplate sh_node_background_out[] = { { SOCK_SHADER, 0, N_("Background")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_brightness.c b/source/blender/nodes/shader/nodes/node_shader_brightness.c index 2735553cdad..9c23a29cae9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_brightness.c +++ b/source/blender/nodes/shader/nodes/node_shader_brightness.c @@ -31,14 +31,14 @@ /* **************** Brigh and contrsast ******************** */ -static bNodeSocketTemplate sh_node_brightcontrast_in[]= { +static bNodeSocketTemplate sh_node_brightcontrast_in[] = { { SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Bright"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("Contrast"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_brightcontrast_out[]= { +static bNodeSocketTemplate sh_node_brightcontrast_out[] = { { SOCK_RGBA, 0, N_("Color")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c index 4a7643f5771..7e023ff8547 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c @@ -29,7 +29,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_bsdf_anisotropic_in[]= { +static bNodeSocketTemplate sh_node_bsdf_anisotropic_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Roughness U"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Roughness V"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, @@ -38,14 +38,14 @@ static bNodeSocketTemplate sh_node_bsdf_anisotropic_in[]= { { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_bsdf_anisotropic_out[]= { +static bNodeSocketTemplate sh_node_bsdf_anisotropic_out[] = { { SOCK_SHADER, 0, N_("BSDF")}, { -1, 0, "" } }; static int node_shader_gpu_bsdf_anisotropic(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) { - if(!in[3].link) + if (!in[3].link) in[3].link = GPU_builtin(GPU_VIEW_NORMAL); return GPU_stack_link(mat, "node_bsdf_anisotropic", in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c index 63ce637fd72..ad9f197afb8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c @@ -29,21 +29,21 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_bsdf_diffuse_in[]= { +static bNodeSocketTemplate sh_node_bsdf_diffuse_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_bsdf_diffuse_out[]= { +static bNodeSocketTemplate sh_node_bsdf_diffuse_out[] = { { SOCK_SHADER, 0, N_("BSDF")}, { -1, 0, "" } }; static int node_shader_gpu_bsdf_diffuse(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) { - if(!in[2].link) + if (!in[2].link) in[2].link = GPU_builtin(GPU_VIEW_NORMAL); return GPU_stack_link(mat, "node_bsdf_diffuse", in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c index 7b8b80ae8e2..9e188092570 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c @@ -29,7 +29,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_bsdf_glass_in[]= { +static bNodeSocketTemplate sh_node_bsdf_glass_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Roughness"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 1.0f, 1000.0f}, @@ -37,14 +37,14 @@ static bNodeSocketTemplate sh_node_bsdf_glass_in[]= { { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_bsdf_glass_out[]= { +static bNodeSocketTemplate sh_node_bsdf_glass_out[] = { { SOCK_SHADER, 0, N_("BSDF")}, { -1, 0, "" } }; static int node_shader_gpu_bsdf_glass(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) { - if(!in[3].link) + if (!in[3].link) in[3].link = GPU_builtin(GPU_VIEW_NORMAL); return GPU_stack_link(mat, "node_bsdf_glass", in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c index 9f42e23ebb6..5e32930b707 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c @@ -29,21 +29,21 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_bsdf_glossy_in[]= { +static bNodeSocketTemplate sh_node_bsdf_glossy_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Roughness"), 0.2f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_bsdf_glossy_out[]= { +static bNodeSocketTemplate sh_node_bsdf_glossy_out[] = { { SOCK_SHADER, 0, N_("BSDF")}, { -1, 0, "" } }; static int node_shader_gpu_bsdf_glossy(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) { - if(!in[2].link) + if (!in[2].link) in[2].link = GPU_builtin(GPU_VIEW_NORMAL); return GPU_stack_link(mat, "node_bsdf_glossy", in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c index b3290411aee..3c7084886b7 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c @@ -29,20 +29,20 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_bsdf_translucent_in[]= { +static bNodeSocketTemplate sh_node_bsdf_translucent_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_bsdf_translucent_out[]= { +static bNodeSocketTemplate sh_node_bsdf_translucent_out[] = { { SOCK_SHADER, 0, N_("BSDF")}, { -1, 0, "" } }; static int node_shader_gpu_bsdf_translucent(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) { - if(!in[1].link) + if (!in[1].link) in[1].link = GPU_builtin(GPU_VIEW_NORMAL); return GPU_stack_link(mat, "node_bsdf_translucent", in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c index 8c945abdd0d..7fb452ad78d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_transparent.c @@ -29,12 +29,12 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_bsdf_transparent_in[]= { +static bNodeSocketTemplate sh_node_bsdf_transparent_in[] = { { SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_bsdf_transparent_out[]= { +static bNodeSocketTemplate sh_node_bsdf_transparent_out[] = { { SOCK_SHADER, 0, N_("BSDF")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c index 97bc37a84c9..a4d25d42d4e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c @@ -29,21 +29,21 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_bsdf_velvet_in[]= { +static bNodeSocketTemplate sh_node_bsdf_velvet_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Sigma"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_bsdf_velvet_out[]= { +static bNodeSocketTemplate sh_node_bsdf_velvet_out[] = { { SOCK_SHADER, 0, N_("BSDF")}, { -1, 0, "" } }; static int node_shader_gpu_bsdf_velvet(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) { - if(!in[2].link) + if (!in[2].link) in[2].link = GPU_builtin(GPU_VIEW_NORMAL); return GPU_stack_link(mat, "node_bsdf_velvet", in, out); diff --git a/source/blender/nodes/shader/nodes/node_shader_bump.c b/source/blender/nodes/shader/nodes/node_shader_bump.c index 315565e619b..24ed825c36e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bump.c +++ b/source/blender/nodes/shader/nodes/node_shader_bump.c @@ -35,15 +35,15 @@ /* **************** BUMP ******************** */ -static bNodeSocketTemplate sh_node_bump_in[]= { - { SOCK_FLOAT, 1, "Strength", 0.1f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, - { SOCK_FLOAT, 1, "Height", 1.0f, 1.0f, 1.0f, 1.0f, -1000.0f, 1000.0f, PROP_NONE, SOCK_HIDE_VALUE}, - { -1, 0, "" } +static bNodeSocketTemplate sh_node_bump_in[] = { + { SOCK_FLOAT, 1, "Strength", 0.1f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, + { SOCK_FLOAT, 1, "Height", 1.0f, 1.0f, 1.0f, 1.0f, -1000.0f, 1000.0f, PROP_NONE, SOCK_HIDE_VALUE}, + { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_bump_out[]= { +static bNodeSocketTemplate sh_node_bump_out[] = { { SOCK_VECTOR, 0, "Normal"}, - { -1, 0, "" } + { -1, 0, "" } }; static int gpu_shader_bump(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/shader/nodes/node_shader_camera.c b/source/blender/nodes/shader/nodes/node_shader_camera.c index 17cec8196e8..fd36a94516e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_camera.c +++ b/source/blender/nodes/shader/nodes/node_shader_camera.c @@ -33,7 +33,7 @@ #include "node_shader_util.h" /* **************** CAMERA INFO ******************** */ -static bNodeSocketTemplate sh_node_camera_out[]= { +static bNodeSocketTemplate sh_node_camera_out[] = { { SOCK_VECTOR, 0, N_("View Vector")}, { SOCK_FLOAT, 0, N_("View Z Depth")}, { SOCK_FLOAT, 0, N_("View Distance")}, @@ -47,8 +47,8 @@ static void node_shader_exec_camera(void *data, bNode *UNUSED(node), bNodeStack ShadeInput *shi= ((ShaderCallData *)data)->shi; /* Data we need for shading. */ copy_v3_v3(out[0]->vec, shi->co); /* get view vector */ - out[1]->vec[0]= fabs(shi->co[2]); /* get view z-depth */ - out[2]->vec[0]= normalize_v3(out[0]->vec); /* get view distance */ + out[1]->vec[0] = fabs(shi->co[2]); /* get view z-depth */ + out[2]->vec[0] = normalize_v3(out[0]->vec); /* get view distance */ } } diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c index df369482a2e..688d77d8350 100644 --- a/source/blender/nodes/shader/nodes/node_shader_common.c +++ b/source/blender/nodes/shader/nodes/node_shader_common.c @@ -204,128 +204,3 @@ void register_node_type_sh_group(bNodeTreeType *ttype) nodeRegisterType(ttype, &ntype); } - - -/**** FOR LOOP ****/ - -#if 0 /* XXX loop nodes don't work nicely with current trees */ -static void forloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out) -{ - bNodeTreeExec *exec= (bNodeTreeExec*)nodedata; - bNodeThreadStack *nts; - int iterations= (int)in[0]->vec[0]; - bNodeSocket *sock; - bNodeStack *ns; - int iteration; - - /* XXX same behavior as trunk: all nodes inside group are executed. - * it's stupid, but just makes it work. compo redesign will do this better. - */ - { - bNode *inode; - for (inode=exec->nodetree->nodes.first; inode; inode=inode->next) - inode->need_exec = 1; - } - - nts = ntreeGetThreadStack(exec, thread); - - /* "Iteration" socket */ - sock = exec->nodetree->inputs.first; - ns = node_get_socket_stack(nts->stack, sock); - -// group_copy_inputs(node, in, nts->stack); - for (iteration=0; iteration < iterations; ++iteration) { - /* first input contains current iteration counter */ - ns->vec[0] = (float)iteration; - ns->vec[1]=ns->vec[2]=ns->vec[3] = 0.0f; - -// if (iteration > 0) -// loop_init_iteration(exec->nodetree, nts->stack); -// ntreeExecThreadNodes(exec, nts, data, thread); - } -// loop_copy_outputs(node, in, out, exec->stack); - - ntreeReleaseThreadStack(nts); -} - -void register_node_type_sh_forloop(bNodeTreeType *ttype) -{ - static bNodeType ntype; - - node_type_base(ttype, &ntype, NODE_FORLOOP, "For", NODE_CLASS_GROUP, NODE_OPTIONS); - node_type_socket_templates(&ntype, NULL, NULL); - node_type_size(&ntype, 120, 60, 200); - node_type_label(&ntype, node_group_label); - node_type_init(&ntype, node_forloop_init); - node_type_valid(&ntype, node_group_valid); - node_type_template(&ntype, node_forloop_template); - node_type_update(&ntype, NULL, node_group_verify); - node_type_tree(&ntype, node_forloop_init_tree, node_loop_update_tree); - node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear); - node_type_exec_new(&ntype, group_initexec, group_freeexec, forloop_execute); - - nodeRegisterType(ttype, &ntype); -} -#endif - -/**** WHILE LOOP ****/ - -#if 0 /* XXX loop nodes don't work nicely with current trees */ -static void whileloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out) -{ - bNodeTreeExec *exec= (bNodeTreeExec*)nodedata; - bNodeThreadStack *nts; - int condition= (in[0]->vec[0] > 0.0f); - bNodeSocket *sock; - bNodeStack *ns; - int iteration; - - /* XXX same behavior as trunk: all nodes inside group are executed. - * it's stupid, but just makes it work. compo redesign will do this better. - */ - { - bNode *inode; - for (inode=exec->nodetree->nodes.first; inode; inode=inode->next) - inode->need_exec = 1; - } - - nts = ntreeGetThreadStack(exec, thread); - - /* "Condition" socket */ - sock = exec->nodetree->outputs.first; - ns = node_get_socket_stack(nts->stack, sock); - - iteration = 0; -// group_copy_inputs(node, in, nts->stack); - while (condition && iteration < node->custom1) { -// if (iteration > 0) -// loop_init_iteration(exec->nodetree, nts->stack); -// ntreeExecThreadNodes(exec, nts, data, thread); - - condition = (ns->vec[0] > 0.0f); - ++iteration; - } -// loop_copy_outputs(node, in, out, exec->stack); - - ntreeReleaseThreadStack(nts); -} - -void register_node_type_sh_whileloop(bNodeTreeType *ttype) -{ - static bNodeType ntype; - - node_type_base(ttype, &ntype, NODE_WHILELOOP, "While", NODE_CLASS_GROUP, NODE_OPTIONS); - node_type_socket_templates(&ntype, NULL, NULL); - node_type_size(&ntype, 120, 60, 200); - node_type_label(&ntype, node_group_label); - node_type_init(&ntype, node_whileloop_init); - node_type_valid(&ntype, node_group_valid); - node_type_template(&ntype, node_whileloop_template); - node_type_update(&ntype, NULL, node_group_verify); - node_type_tree(&ntype, node_whileloop_init_tree, node_loop_update_tree); - node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear); - node_type_exec_new(&ntype, group_initexec, group_freeexec, whileloop_execute); - - nodeRegisterType(ttype, &ntype); -} -#endif diff --git a/source/blender/nodes/shader/nodes/node_shader_curves.c b/source/blender/nodes/shader/nodes/node_shader_curves.c index 83cb1d33628..9fa654c9740 100644 --- a/source/blender/nodes/shader/nodes/node_shader_curves.c +++ b/source/blender/nodes/shader/nodes/node_shader_curves.c @@ -34,13 +34,13 @@ /* **************** CURVE VEC ******************** */ -static bNodeSocketTemplate sh_node_curve_vec_in[]= { +static bNodeSocketTemplate sh_node_curve_vec_in[] = { { SOCK_FLOAT, 0, N_("Fac"), 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_curve_vec_out[]= { +static bNodeSocketTemplate sh_node_curve_vec_out[] = { { SOCK_VECTOR, 0, N_("Vector")}, { -1, 0, "" } }; @@ -88,13 +88,13 @@ void register_node_type_sh_curve_vec(bNodeTreeType *ttype) /* **************** CURVE RGB ******************** */ -static bNodeSocketTemplate sh_node_curve_rgb_in[]= { +static bNodeSocketTemplate sh_node_curve_rgb_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_FACTOR}, { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_curve_rgb_out[]= { +static bNodeSocketTemplate sh_node_curve_rgb_out[] = { { SOCK_RGBA, 0, N_("Color")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_emission.c b/source/blender/nodes/shader/nodes/node_shader_emission.c index 4854d887592..0c4cb7ed51c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_emission.c +++ b/source/blender/nodes/shader/nodes/node_shader_emission.c @@ -29,13 +29,13 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_emission_in[]= { +static bNodeSocketTemplate sh_node_emission_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Strength"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_emission_out[]= { +static bNodeSocketTemplate sh_node_emission_out[] = { { SOCK_SHADER, 0, N_("Emission")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_fresnel.c b/source/blender/nodes/shader/nodes/node_shader_fresnel.c index 610a2149011..80913e6b07a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_fresnel.c +++ b/source/blender/nodes/shader/nodes/node_shader_fresnel.c @@ -28,12 +28,12 @@ #include "../node_shader_util.h" /* **************** Fresnel ******************** */ -static bNodeSocketTemplate sh_node_fresnel_in[]= { +static bNodeSocketTemplate sh_node_fresnel_in[] = { { SOCK_FLOAT, 1, N_("IOR"), 1.45f, 0.0f, 0.0f, 0.0f, 1.0f, 1000.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_fresnel_out[]= { +static bNodeSocketTemplate sh_node_fresnel_out[] = { { SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_gamma.c b/source/blender/nodes/shader/nodes/node_shader_gamma.c index 526868f73d3..c49554c44be 100644 --- a/source/blender/nodes/shader/nodes/node_shader_gamma.c +++ b/source/blender/nodes/shader/nodes/node_shader_gamma.c @@ -30,13 +30,13 @@ /* **************** Gamma Tools ******************** */ -static bNodeSocketTemplate sh_node_gamma_in[]= { +static bNodeSocketTemplate sh_node_gamma_in[] = { { SOCK_RGBA, 1, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Gamma"), 1.0f, 0.0f, 0.0f, 0.0f, 0.001f, 10.0f, PROP_UNSIGNED}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_gamma_out[]= { +static bNodeSocketTemplate sh_node_gamma_out[] = { { SOCK_RGBA, 0, N_("Color")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_geom.c b/source/blender/nodes/shader/nodes/node_shader_geom.c index f23158ab5d4..eb3d462d616 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geom.c +++ b/source/blender/nodes/shader/nodes/node_shader_geom.c @@ -37,7 +37,7 @@ /* **************** GEOMETRY ******************** */ /* output socket type definition */ -static bNodeSocketTemplate sh_node_geom_out[]= { +static bNodeSocketTemplate sh_node_geom_out[] = { { SOCK_VECTOR, 0, N_("Global")}, { SOCK_VECTOR, 0, N_("Local")}, { SOCK_VECTOR, 0, N_("View")}, @@ -92,12 +92,12 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(i } copy_v3_v3(out[GEOM_OUT_VCOL]->vec, scol->col); - out[GEOM_OUT_VCOL]->vec[3]= scol->col[3]; - out[GEOM_OUT_VCOL_ALPHA]->vec[0]= scol->col[3]; + out[GEOM_OUT_VCOL]->vec[3] = scol->col[3]; + out[GEOM_OUT_VCOL_ALPHA]->vec[0] = scol->col[3]; } else { memcpy(out[GEOM_OUT_VCOL]->vec, defaultvcol, sizeof(defaultvcol)); - out[GEOM_OUT_VCOL_ALPHA]->vec[0]= 1.0f; + out[GEOM_OUT_VCOL_ALPHA]->vec[0] = 1.0f; } if (shi->osatex) { @@ -116,7 +116,7 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **UNUSED(i } /* front/back, normal flipping was stored */ - out[GEOM_OUT_FRONTBACK]->vec[0]= (shi->flippednor)? 0.0f: 1.0f; + out[GEOM_OUT_FRONTBACK]->vec[0] = (shi->flippednor)? 0.0f: 1.0f; } } diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c index 2ebd93218d6..acef885d2d4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geometry.c +++ b/source/blender/nodes/shader/nodes/node_shader_geometry.c @@ -29,7 +29,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_geometry_out[]= { +static bNodeSocketTemplate sh_node_geometry_out[] = { { SOCK_VECTOR, 0, N_("Position"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_VECTOR, 0, N_("Tangent"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, diff --git a/source/blender/nodes/shader/nodes/node_shader_holdout.c b/source/blender/nodes/shader/nodes/node_shader_holdout.c index dbd4ed8ab67..18ad4994c9b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_holdout.c +++ b/source/blender/nodes/shader/nodes/node_shader_holdout.c @@ -29,11 +29,11 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_holdout_in[]= { +static bNodeSocketTemplate sh_node_holdout_in[] = { { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_holdout_out[]= { +static bNodeSocketTemplate sh_node_holdout_out[] = { { SOCK_SHADER, 0, N_("Holdout")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c index b07650e33c0..b635ad1edd9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c +++ b/source/blender/nodes/shader/nodes/node_shader_hueSatVal.c @@ -34,7 +34,7 @@ /* **************** Hue Saturation ******************** */ -static bNodeSocketTemplate sh_node_hue_sat_in[]= { +static bNodeSocketTemplate sh_node_hue_sat_in[] = { { SOCK_FLOAT, 1, N_("Hue"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE}, { SOCK_FLOAT, 1, N_("Saturation"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_FACTOR}, { SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_FACTOR}, @@ -42,7 +42,7 @@ static bNodeSocketTemplate sh_node_hue_sat_in[]= { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_hue_sat_out[]= { +static bNodeSocketTemplate sh_node_hue_sat_out[] = { { SOCK_RGBA, 0, N_("Color")}, { -1, 0, "" } }; @@ -60,9 +60,9 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float *hue, float *s hsv[2]*= *val; hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2); - out[0]= mfac*in[0] + *fac*col[0]; - out[1]= mfac*in[1] + *fac*col[1]; - out[2]= mfac*in[2] + *fac*col[2]; + out[0] = mfac*in[0] + *fac*col[0]; + out[1] = mfac*in[1] + *fac*col[1]; + out[2] = mfac*in[2] + *fac*col[2]; } else { copy_v4_v4(out, in); diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.c index ef592a7e2ec..2ea858f4e34 100644 --- a/source/blender/nodes/shader/nodes/node_shader_invert.c +++ b/source/blender/nodes/shader/nodes/node_shader_invert.c @@ -35,15 +35,15 @@ /* **************** INVERT ******************** */ -static bNodeSocketTemplate sh_node_invert_in[]= { - { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, - { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, - { -1, 0, "" } +static bNodeSocketTemplate sh_node_invert_in[] = { + { SOCK_FLOAT, 1, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, + { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, + { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_invert_out[]= { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, "" } +static bNodeSocketTemplate sh_node_invert_out[] = { + { SOCK_RGBA, 0, N_("Color")}, + { -1, 0, "" } }; static void node_shader_exec_invert(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, diff --git a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c index 6eacea10b5b..3058483ebef 100644 --- a/source/blender/nodes/shader/nodes/node_shader_layer_weight.c +++ b/source/blender/nodes/shader/nodes/node_shader_layer_weight.c @@ -29,12 +29,12 @@ /* **************** Layer Weight ******************** */ -static bNodeSocketTemplate sh_node_layer_weight_in[]= { +static bNodeSocketTemplate sh_node_layer_weight_in[] = { { SOCK_FLOAT, 1, N_("Blend"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_layer_weight_out[]= { +static bNodeSocketTemplate sh_node_layer_weight_out[] = { { SOCK_FLOAT, 0, N_("Fresnel"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Facing"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c index aab5fa8060d..2dec244ae3a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c +++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c @@ -29,7 +29,7 @@ /* **************** INPUT ********************* */ -static bNodeSocketTemplate sh_node_light_falloff_in[]= { +static bNodeSocketTemplate sh_node_light_falloff_in[] = { { SOCK_FLOAT, 0, N_("Strength"), 100.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000000.0f}, { SOCK_FLOAT, 0, N_("Smooth"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, { -1, 0, "" } @@ -37,7 +37,7 @@ static bNodeSocketTemplate sh_node_light_falloff_in[]= { /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_light_falloff_out[]= { +static bNodeSocketTemplate sh_node_light_falloff_out[] = { { SOCK_FLOAT, 0, N_("Quadratic"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Linear"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Constant"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, diff --git a/source/blender/nodes/shader/nodes/node_shader_light_path.c b/source/blender/nodes/shader/nodes/node_shader_light_path.c index 264b1390688..b4a3d4e01e1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_light_path.c +++ b/source/blender/nodes/shader/nodes/node_shader_light_path.c @@ -29,7 +29,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_light_path_out[]= { +static bNodeSocketTemplate sh_node_light_path_out[] = { { SOCK_FLOAT, 0, N_("Is Camera Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Is Shadow Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Is Diffuse Ray"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c index 4508f66543e..cedd3a4910c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mapping.c +++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c @@ -33,12 +33,12 @@ #include "node_shader_util.h" /* **************** MAPPING ******************** */ -static bNodeSocketTemplate sh_node_mapping_in[]= { +static bNodeSocketTemplate sh_node_mapping_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_mapping_out[]= { +static bNodeSocketTemplate sh_node_mapping_out[] = { { SOCK_VECTOR, 0, N_("Vector")}, { -1, 0, "" } }; @@ -55,14 +55,14 @@ static void node_shader_exec_mapping(void *UNUSED(data), bNode *node, bNodeStack mul_m4_v3(texmap->mat, vec); if (texmap->flag & TEXMAP_CLIP_MIN) { - if (vec[0]<texmap->min[0]) vec[0]= texmap->min[0]; - if (vec[1]<texmap->min[1]) vec[1]= texmap->min[1]; - if (vec[2]<texmap->min[2]) vec[2]= texmap->min[2]; + if (vec[0]<texmap->min[0]) vec[0] = texmap->min[0]; + if (vec[1]<texmap->min[1]) vec[1] = texmap->min[1]; + if (vec[2]<texmap->min[2]) vec[2] = texmap->min[2]; } if (texmap->flag & TEXMAP_CLIP_MAX) { - if (vec[0]>texmap->max[0]) vec[0]= texmap->max[0]; - if (vec[1]>texmap->max[1]) vec[1]= texmap->max[1]; - if (vec[2]>texmap->max[2]) vec[2]= texmap->max[2]; + if (vec[0]>texmap->max[0]) vec[0] = texmap->max[0]; + if (vec[1]>texmap->max[1]) vec[1] = texmap->max[1]; + if (vec[2]>texmap->max[2]) vec[2] = texmap->max[2]; } } diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c b/source/blender/nodes/shader/nodes/node_shader_material.c index 57865e072e7..bccf6d349cf 100644 --- a/source/blender/nodes/shader/nodes/node_shader_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_material.c @@ -34,7 +34,7 @@ /* **************** MATERIAL ******************** */ -static bNodeSocketTemplate sh_node_material_in[]= { +static bNodeSocketTemplate sh_node_material_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_RGBA, 1, N_("Spec"), 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Refl"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, @@ -42,7 +42,7 @@ static bNodeSocketTemplate sh_node_material_in[]= { { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_material_out[]= { +static bNodeSocketTemplate sh_node_material_out[] = { { SOCK_RGBA, 0, N_("Color")}, { SOCK_FLOAT, 0, N_("Alpha")}, { SOCK_VECTOR, 0, N_("Normal")}, @@ -51,7 +51,7 @@ static bNodeSocketTemplate sh_node_material_out[]= { /* **************** EXTENDED MATERIAL ******************** */ -static bNodeSocketTemplate sh_node_material_ext_in[]= { +static bNodeSocketTemplate sh_node_material_ext_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_RGBA, 1, N_("Spec"), 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Refl"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR}, @@ -66,7 +66,7 @@ static bNodeSocketTemplate sh_node_material_ext_in[]= { { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_material_ext_out[]= { +static bNodeSocketTemplate sh_node_material_ext_out[] = { { SOCK_RGBA, 0, N_("Color")}, { SOCK_FLOAT, 0, N_("Alpha")}, { SOCK_VECTOR, 0, N_("Normal")}, @@ -84,7 +84,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, ShaderCallData *shcd= data; float col[4]; bNodeSocket *sock; - char hasinput[NUM_MAT_IN]= {'\0'}; + char hasinput[NUM_MAT_IN] = {'\0'}; int i; /* note: cannot use the in[]->hasinput flags directly, as these are not necessarily @@ -139,7 +139,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, if (hasinput[MAT_IN_ALPHA]) nodestack_get_vec(&shi->alpha, SOCK_FLOAT, in[MAT_IN_ALPHA]); if (hasinput[MAT_IN_TRANSLUCENCY]) - nodestack_get_vec(&shi->translucency, SOCK_FLOAT, in[MAT_IN_TRANSLUCENCY]); + nodestack_get_vec(&shi->translucency, SOCK_FLOAT, in[MAT_IN_TRANSLUCENCY]); } shi->nodes= 1; /* temp hack to prevent trashadow recursion */ @@ -157,20 +157,20 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, copy_v3_v3(col, shrnode.spec); } else - col[0]= col[1]= col[2]= 0.0f; + col[0] = col[1] = col[2] = 0.0f; - col[3]= shrnode.alpha; + col[3] = shrnode.alpha; if (shi->do_preview) nodeAddToPreview(node, col, shi->xs, shi->ys, shi->do_manage); copy_v3_v3(out[MAT_OUT_COLOR]->vec, col); - out[MAT_OUT_ALPHA]->vec[0]= shrnode.alpha; + out[MAT_OUT_ALPHA]->vec[0] = shrnode.alpha; if (node->custom1 & SH_NODE_MAT_NEG) { - shi->vn[0]= -shi->vn[0]; - shi->vn[1]= -shi->vn[1]; - shi->vn[2]= -shi->vn[2]; + shi->vn[0] = -shi->vn[0]; + shi->vn[1] = -shi->vn[1]; + shi->vn[2] = -shi->vn[2]; } copy_v3_v3(out[MAT_OUT_NORMAL]->vec, shi->vn); @@ -222,7 +222,7 @@ static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUShadeInput shi; GPUShadeResult shr; bNodeSocket *sock; - char hasinput[NUM_MAT_IN]= {'\0'}; + char hasinput[NUM_MAT_IN] = {'\0'}; int i; /* note: cannot use the in[]->hasinput flags directly, as these are not necessarily diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index c112ae1d448..a70134b2325 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -34,61 +34,61 @@ /* **************** SCALAR MATH ******************** */ -static bNodeSocketTemplate sh_node_math_in[]= { - { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, - { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, - { -1, 0, "" } +static bNodeSocketTemplate sh_node_math_in[] = { + { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_math_out[]= { - { SOCK_FLOAT, 0, N_("Value")}, - { -1, 0, "" } +static bNodeSocketTemplate sh_node_math_out[] = { + { SOCK_FLOAT, 0, N_("Value")}, + { -1, 0, "" } }; static void node_shader_exec_math(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) { - switch (node->custom1) { + switch (node->custom1) { case 0: /* Add */ - out[0]->vec[0]= in[0]->vec[0] + in[1]->vec[0]; + out[0]->vec[0] = in[0]->vec[0] + in[1]->vec[0]; break; case 1: /* Subtract */ - out[0]->vec[0]= in[0]->vec[0] - in[1]->vec[0]; + out[0]->vec[0] = in[0]->vec[0] - in[1]->vec[0]; break; case 2: /* Multiply */ - out[0]->vec[0]= in[0]->vec[0] * in[1]->vec[0]; + out[0]->vec[0] = in[0]->vec[0] * in[1]->vec[0]; break; case 3: /* Divide */ { if (in[1]->vec[0]==0) /* We don't want to divide by zero. */ - out[0]->vec[0]= 0.0; + out[0]->vec[0] = 0.0; else - out[0]->vec[0]= in[0]->vec[0] / in[1]->vec[0]; + out[0]->vec[0] = in[0]->vec[0] / in[1]->vec[0]; } break; case 4: /* Sine */ { if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ - out[0]->vec[0]= sin(in[0]->vec[0]); + out[0]->vec[0] = sin(in[0]->vec[0]); else - out[0]->vec[0]= sin(in[1]->vec[0]); + out[0]->vec[0] = sin(in[1]->vec[0]); } break; case 5: /* Cosine */ { - if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ - out[0]->vec[0]= cos(in[0]->vec[0]); + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + out[0]->vec[0] = cos(in[0]->vec[0]); else - out[0]->vec[0]= cos(in[1]->vec[0]); + out[0]->vec[0] = cos(in[1]->vec[0]); } break; case 6: /* Tangent */ { - if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ - out[0]->vec[0]= tan(in[0]->vec[0]); + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + out[0]->vec[0] = tan(in[0]->vec[0]); else - out[0]->vec[0]= tan(in[1]->vec[0]); + out[0]->vec[0] = tan(in[1]->vec[0]); } break; case 7: /* Arc-Sine */ @@ -96,16 +96,16 @@ bNodeStack **out) if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ /* Can't do the impossible... */ if ( in[0]->vec[0] <= 1 && in[0]->vec[0] >= -1 ) - out[0]->vec[0]= asin(in[0]->vec[0]); + out[0]->vec[0] = asin(in[0]->vec[0]); else - out[0]->vec[0]= 0.0; + out[0]->vec[0] = 0.0; } else { /* Can't do the impossible... */ if ( in[1]->vec[0] <= 1 && in[1]->vec[0] >= -1 ) - out[0]->vec[0]= asin(in[1]->vec[0]); + out[0]->vec[0] = asin(in[1]->vec[0]); else - out[0]->vec[0]= 0.0; + out[0]->vec[0] = 0.0; } } break; @@ -114,86 +114,86 @@ bNodeStack **out) if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ /* Can't do the impossible... */ if ( in[0]->vec[0] <= 1 && in[0]->vec[0] >= -1 ) - out[0]->vec[0]= acos(in[0]->vec[0]); + out[0]->vec[0] = acos(in[0]->vec[0]); else - out[0]->vec[0]= 0.0; + out[0]->vec[0] = 0.0; } else { /* Can't do the impossible... */ if ( in[1]->vec[0] <= 1 && in[1]->vec[0] >= -1 ) - out[0]->vec[0]= acos(in[1]->vec[0]); + out[0]->vec[0] = acos(in[1]->vec[0]); else - out[0]->vec[0]= 0.0; + out[0]->vec[0] = 0.0; } } break; case 9: /* Arc-Tangent */ { if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ - out[0]->vec[0]= atan(in[0]->vec[0]); + out[0]->vec[0] = atan(in[0]->vec[0]); else - out[0]->vec[0]= atan(in[1]->vec[0]); + out[0]->vec[0] = atan(in[1]->vec[0]); } break; case 10: /* Power */ { /* Don't want any imaginary numbers... */ if ( in[0]->vec[0] >= 0 ) - out[0]->vec[0]= pow(in[0]->vec[0], in[1]->vec[0]); + out[0]->vec[0] = pow(in[0]->vec[0], in[1]->vec[0]); else - out[0]->vec[0]= 0.0; + out[0]->vec[0] = 0.0; } break; case 11: /* Logarithm */ { /* Don't want any imaginary numbers... */ if ( in[0]->vec[0] > 0 && in[1]->vec[0] > 0 ) - out[0]->vec[0]= log(in[0]->vec[0]) / log(in[1]->vec[0]); + out[0]->vec[0] = log(in[0]->vec[0]) / log(in[1]->vec[0]); else - out[0]->vec[0]= 0.0; + out[0]->vec[0] = 0.0; } break; case 12: /* Minimum */ { if ( in[0]->vec[0] < in[1]->vec[0] ) - out[0]->vec[0]= in[0]->vec[0]; + out[0]->vec[0] = in[0]->vec[0]; else - out[0]->vec[0]= in[1]->vec[0]; + out[0]->vec[0] = in[1]->vec[0]; } break; case 13: /* Maximum */ { if ( in[0]->vec[0] > in[1]->vec[0] ) - out[0]->vec[0]= in[0]->vec[0]; + out[0]->vec[0] = in[0]->vec[0]; else - out[0]->vec[0]= in[1]->vec[0]; + out[0]->vec[0] = in[1]->vec[0]; } break; case 14: /* Round */ { if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ - out[0]->vec[0]= (in[0]->vec[0]<0)?(int)(in[0]->vec[0] - 0.5f):(int)(in[0]->vec[0] + 0.5f); + out[0]->vec[0] = (in[0]->vec[0]<0)?(int)(in[0]->vec[0] - 0.5f):(int)(in[0]->vec[0] + 0.5f); else - out[0]->vec[0]= (in[1]->vec[0]<0)?(int)(in[1]->vec[0] - 0.5f):(int)(in[1]->vec[0] + 0.5f); + out[0]->vec[0] = (in[1]->vec[0]<0)?(int)(in[1]->vec[0] - 0.5f):(int)(in[1]->vec[0] + 0.5f); } break; case 15: /* Less Than */ { if ( in[0]->vec[0] < in[1]->vec[0] ) - out[0]->vec[0]= 1.0f; + out[0]->vec[0] = 1.0f; else - out[0]->vec[0]= 0.0f; + out[0]->vec[0] = 0.0f; } break; case 16: /* Greater Than */ { if ( in[0]->vec[0] > in[1]->vec[0] ) - out[0]->vec[0]= 1.0f; + out[0]->vec[0] = 1.0f; else - out[0]->vec[0]= 0.0f; + out[0]->vec[0] = 0.0f; } break; - } + } } static int gpu_shader_math(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c index 53c1387ca1a..18dcc8f7fef 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c @@ -33,13 +33,13 @@ #include "node_shader_util.h" /* **************** MIX RGB ******************** */ -static bNodeSocketTemplate sh_node_mix_rgb_in[]= { +static bNodeSocketTemplate sh_node_mix_rgb_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { SOCK_RGBA, 1, N_("Color1"), 0.5f, 0.5f, 0.5f, 1.0f}, { SOCK_RGBA, 1, N_("Color2"), 0.5f, 0.5f, 0.5f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_mix_rgb_out[]= { +static bNodeSocketTemplate sh_node_mix_rgb_out[] = { { SOCK_RGBA, 0, N_("Color")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c index 80ee1a8499d..039e63a4dea 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mix_shader.c +++ b/source/blender/nodes/shader/nodes/node_shader_mix_shader.c @@ -29,14 +29,14 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_mix_shader_in[]= { +static bNodeSocketTemplate sh_node_mix_shader_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_SHADER, 1, N_("Shader")}, { SOCK_SHADER, 1, N_("Shader")}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_mix_shader_out[]= { +static bNodeSocketTemplate sh_node_mix_shader_out[] = { { SOCK_SHADER, 0, N_("Shader")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_normal.c b/source/blender/nodes/shader/nodes/node_shader_normal.c index bb0a85417d9..98a56c85279 100644 --- a/source/blender/nodes/shader/nodes/node_shader_normal.c +++ b/source/blender/nodes/shader/nodes/node_shader_normal.c @@ -33,12 +33,12 @@ #include "node_shader_util.h" /* **************** NORMAL ******************** */ -static bNodeSocketTemplate sh_node_normal_in[]= { +static bNodeSocketTemplate sh_node_normal_in[] = { { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_normal_out[]= { +static bNodeSocketTemplate sh_node_normal_out[] = { { SOCK_VECTOR, 0, N_("Normal")}, { SOCK_FLOAT, 0, N_("Dot")}, { -1, 0, "" } @@ -68,7 +68,7 @@ static void node_shader_exec_normal(void *UNUSED(data), bNode *node, bNodeStack copy_v3_v3(out[0]->vec, ((bNodeSocketValueVector*)sock->default_value)->value); /* render normals point inside... the widget points outside */ - out[1]->vec[0]= -dot_v3v3(out[0]->vec, vec); + out[1]->vec[0] = -dot_v3v3(out[0]->vec, vec); } static int gpu_shader_normal(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/shader/nodes/node_shader_object_info.c b/source/blender/nodes/shader/nodes/node_shader_object_info.c index 1cafa01ecec..ef283004d46 100644 --- a/source/blender/nodes/shader/nodes/node_shader_object_info.c +++ b/source/blender/nodes/shader/nodes/node_shader_object_info.c @@ -29,7 +29,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_object_info_out[]= { +static bNodeSocketTemplate sh_node_object_info_out[] = { { SOCK_VECTOR, 0, N_("Location"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Object Index"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Material Index"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, diff --git a/source/blender/nodes/shader/nodes/node_shader_output.c b/source/blender/nodes/shader/nodes/node_shader_output.c index 4434054abae..6f7f900aecd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output.c +++ b/source/blender/nodes/shader/nodes/node_shader_output.c @@ -33,7 +33,7 @@ #include "node_shader_util.h" /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_output_in[]= { +static bNodeSocketTemplate sh_node_output_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { -1, 0, "" } @@ -62,7 +62,7 @@ static void node_shader_exec_output(void *data, bNode *node, bNodeStack **in, bN // copy_v3_v3(shr->nor, in[3]->vec); } - } + } } static int gpu_shader_output(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) @@ -92,7 +92,7 @@ void register_node_type_sh_output(bNodeTreeType *ttype) node_type_gpu(&ntype, gpu_shader_output); /* Do not allow muting output node. */ - node_type_internal_connect(&ntype, NULL); + node_type_internal_links(&ntype, NULL); nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c index eb7208302fe..ce406a8f5a1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_lamp.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_lamp.c @@ -29,7 +29,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_output_lamp_in[]= { +static bNodeSocketTemplate sh_node_output_lamp_in[] = { { SOCK_SHADER, 1, N_("Surface"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; @@ -49,7 +49,7 @@ void register_node_type_sh_output_lamp(bNodeTreeType *ttype) node_type_gpu(&ntype, NULL); /* Do not allow muting output node. */ - node_type_internal_connect(&ntype, NULL); + node_type_internal_links(&ntype, NULL); nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_output_material.c b/source/blender/nodes/shader/nodes/node_shader_output_material.c index e81744c44bd..f185e13010b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_material.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_material.c @@ -29,7 +29,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_output_material_in[]= { +static bNodeSocketTemplate sh_node_output_material_in[] = { { SOCK_SHADER, 1, N_("Surface")}, { SOCK_SHADER, 1, N_("Volume")}, { SOCK_FLOAT, 1, N_("Displacement"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, @@ -62,7 +62,7 @@ void register_node_type_sh_output_material(bNodeTreeType *ttype) node_type_gpu(&ntype, node_shader_gpu_output_material); /* Do not allow muting output node. */ - node_type_internal_connect(&ntype, NULL); + node_type_internal_links(&ntype, NULL); nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_output_world.c b/source/blender/nodes/shader/nodes/node_shader_output_world.c index 3a931c2af53..953197ab2cd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_output_world.c +++ b/source/blender/nodes/shader/nodes/node_shader_output_world.c @@ -29,7 +29,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_output_world_in[]= { +static bNodeSocketTemplate sh_node_output_world_in[] = { { SOCK_SHADER, 1, N_("Surface"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_SHADER, 1, N_("Volume"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } @@ -50,7 +50,7 @@ void register_node_type_sh_output_world(bNodeTreeType *ttype) node_type_gpu(&ntype, NULL); /* Do not allow muting output node. */ - node_type_internal_connect(&ntype, NULL); + node_type_internal_links(&ntype, NULL); nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/shader/nodes/node_shader_particle_info.c b/source/blender/nodes/shader/nodes/node_shader_particle_info.c index ddfcb9476f4..c7e31d117cc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_particle_info.c +++ b/source/blender/nodes/shader/nodes/node_shader_particle_info.c @@ -28,18 +28,18 @@ #include "../node_shader_util.h" static bNodeSocketTemplate outputs[] = { - { SOCK_FLOAT, 0, "Index" }, - { SOCK_FLOAT, 0, "Age" }, - { SOCK_FLOAT, 0, "Lifetime" }, - { SOCK_VECTOR, 0, "Location" }, - #if 0 /* quaternion sockets not yet supported */ - { SOCK_QUATERNION, 0, "Rotation" }, - #endif - { SOCK_FLOAT, 0, "Size" }, - { SOCK_VECTOR, 0, "Velocity" }, - { SOCK_VECTOR, 0, "Angular Velocity" }, - { -1, 0, "" } -}; + { SOCK_FLOAT, 0, "Index" }, + { SOCK_FLOAT, 0, "Age" }, + { SOCK_FLOAT, 0, "Lifetime" }, + { SOCK_VECTOR, 0, "Location" }, +#if 0 /* quaternion sockets not yet supported */ + { SOCK_QUATERNION, 0, "Rotation" }, +#endif + { SOCK_FLOAT, 0, "Size" }, + { SOCK_VECTOR, 0, "Velocity" }, + { SOCK_VECTOR, 0, "Angular Velocity" }, + { -1, 0, "" } + }; /* node type definition */ void register_node_type_sh_particle_info(bNodeTreeType *ttype) diff --git a/source/blender/nodes/shader/nodes/node_shader_rgb.c b/source/blender/nodes/shader/nodes/node_shader_rgb.c index 5a19c61fe92..f37ff1d511b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_rgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_rgb.c @@ -33,7 +33,7 @@ #include "node_shader_util.h" /* **************** RGB ******************** */ -static bNodeSocketTemplate sh_node_rgb_out[]= { +static bNodeSocketTemplate sh_node_rgb_out[] = { { SOCK_RGBA, 0, N_("Color")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c index 55f37b666e7..70fba161de9 100644 --- a/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c +++ b/source/blender/nodes/shader/nodes/node_shader_sepcombRGB.c @@ -33,11 +33,11 @@ #include "node_shader_util.h" /* **************** SEPARATE RGBA ******************** */ -static bNodeSocketTemplate sh_node_seprgb_in[]= { +static bNodeSocketTemplate sh_node_seprgb_in[] = { { SOCK_RGBA, 1, N_("Image"), 0.8f, 0.8f, 0.8f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_seprgb_out[]= { +static bNodeSocketTemplate sh_node_seprgb_out[] = { { SOCK_FLOAT, 0, N_("R")}, { SOCK_FLOAT, 0, N_("G")}, { SOCK_FLOAT, 0, N_("B")}, @@ -73,13 +73,13 @@ void register_node_type_sh_seprgb(bNodeTreeType *ttype) /* **************** COMBINE RGB ******************** */ -static bNodeSocketTemplate sh_node_combrgb_in[]= { +static bNodeSocketTemplate sh_node_combrgb_in[] = { { SOCK_FLOAT, 1, N_("R"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, { SOCK_FLOAT, 1, N_("G"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, { SOCK_FLOAT, 1, N_("B"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_UNSIGNED}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_combrgb_out[]= { +static bNodeSocketTemplate sh_node_combrgb_out[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_squeeze.c b/source/blender/nodes/shader/nodes/node_shader_squeeze.c index adab396be02..d95191de987 100644 --- a/source/blender/nodes/shader/nodes/node_shader_squeeze.c +++ b/source/blender/nodes/shader/nodes/node_shader_squeeze.c @@ -33,16 +33,16 @@ #include "node_shader_util.h" /* **************** VALUE SQUEEZE ******************** */ -static bNodeSocketTemplate sh_node_squeeze_in[]= { - { SOCK_FLOAT, 1, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, - { SOCK_FLOAT, 1, N_("Width"), 1.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, - { SOCK_FLOAT, 1, N_("Center"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, - { -1, 0, "" } +static bNodeSocketTemplate sh_node_squeeze_in[] = { + { SOCK_FLOAT, 1, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, + { SOCK_FLOAT, 1, N_("Width"), 1.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, + { SOCK_FLOAT, 1, N_("Center"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE}, + { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_squeeze_out[]= { - { SOCK_FLOAT, 0, N_("Value")}, - { -1, 0, "" } +static bNodeSocketTemplate sh_node_squeeze_out[] = { + { SOCK_FLOAT, 0, N_("Value")}, + { -1, 0, "" } }; static void node_shader_exec_squeeze(void *UNUSED(data), bNode *UNUSED(node), bNodeStack **in, diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c index 11f7fb94ae0..66bf0267586 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_brick.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_brick.c @@ -29,7 +29,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_tex_brick_in[]= { +static bNodeSocketTemplate sh_node_tex_brick_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { SOCK_RGBA, 1, N_("Color1"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_RGBA, 1, N_("Color2"), 0.2f, 0.2f, 0.2f, 1.0f, 0.0f, 1.0f}, @@ -42,7 +42,7 @@ static bNodeSocketTemplate sh_node_tex_brick_in[]= { { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_brick_out[]= { +static bNodeSocketTemplate sh_node_tex_brick_out[] = { { SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c index 0c1e7dcb995..8a2ae2d40dc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_checker.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_checker.c @@ -29,7 +29,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_tex_checker_in[]= { +static bNodeSocketTemplate sh_node_tex_checker_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { SOCK_RGBA, 1, N_("Color1"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_RGBA, 1, N_("Color2"), 0.2f, 0.2f, 0.2f, 1.0f, 0.0f, 1.0f}, @@ -37,7 +37,7 @@ static bNodeSocketTemplate sh_node_tex_checker_in[]= { { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_checker_out[]= { +static bNodeSocketTemplate sh_node_tex_checker_out[] = { { SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c index 62b1cabd491..dd717874951 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_coord.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_coord.c @@ -31,7 +31,7 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_tex_coord_out[]= { +static bNodeSocketTemplate sh_node_tex_coord_out[] = { { SOCK_VECTOR, 0, N_("Generated"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_VECTOR, 0, N_("UV"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c index ace0f0c8774..30bfe1704ae 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c @@ -27,14 +27,16 @@ #include "../node_shader_util.h" +#include "IMB_colormanagement.h" + /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_tex_environment_in[]= { +static bNodeSocketTemplate sh_node_tex_environment_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_environment_out[]= { +static bNodeSocketTemplate sh_node_tex_environment_out[] = { { SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; @@ -59,7 +61,8 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, GPUNod Image *ima= (Image*)node->id; ImageUser *iuser= NULL; NodeTexImage *tex = node->storage; - int ncd = tex->color_space == SHD_COLORSPACE_NONE; + int isdata = tex->color_space == SHD_COLORSPACE_NONE; + int ret; if (!ima) return GPU_stack_link(mat, "node_tex_environment_empty", in, out); @@ -69,10 +72,18 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat, bNode *node, GPUNod node_shader_gpu_tex_mapping(mat, node, in, out); - if (out[0].link && GPU_material_do_color_management(mat)) - GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link); + ret = GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser, isdata)); + + if (ret) { + ImBuf *ibuf = BKE_image_get_ibuf(ima, iuser); + if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 && + GPU_material_do_color_management(mat)) + { + GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link); + } + } - return GPU_stack_link(mat, "node_tex_environment", in, out, GPU_image(ima, iuser, ncd)); + return ret; } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c index a7f869155fa..0802ecdea1d 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_gradient.c @@ -29,12 +29,12 @@ /* **************** BLEND ******************** */ -static bNodeSocketTemplate sh_node_tex_gradient_in[]= { +static bNodeSocketTemplate sh_node_tex_gradient_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_gradient_out[]= { +static bNodeSocketTemplate sh_node_tex_gradient_out[] = { { SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c index d6c757222b9..9b17f76bd47 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c @@ -27,14 +27,16 @@ #include "../node_shader_util.h" +#include "IMB_colormanagement.h" + /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_tex_image_in[]= { +static bNodeSocketTemplate sh_node_tex_image_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_image_out[]= { +static bNodeSocketTemplate sh_node_tex_image_out[] = { { SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Alpha"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } @@ -59,7 +61,8 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, GPUNodeStack Image *ima= (Image*)node->id; ImageUser *iuser= NULL; NodeTexImage *tex = node->storage; - int ncd = tex->color_space == SHD_COLORSPACE_NONE; + int isdata = tex->color_space == SHD_COLORSPACE_NONE; + int ret; if (!ima) return GPU_stack_link(mat, "node_tex_image_empty", in, out); @@ -69,10 +72,18 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat, bNode *node, GPUNodeStack node_shader_gpu_tex_mapping(mat, node, in, out); - if (out[0].link && GPU_material_do_color_management(mat)) - GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link); + ret = GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, isdata)); + + if (ret) { + ImBuf *ibuf = BKE_image_get_ibuf(ima, iuser); + if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) == 0 && + GPU_material_do_color_management(mat)) + { + GPU_link(mat, "srgb_to_linearrgb", out[0].link, &out[0].link); + } + } - return GPU_stack_link(mat, "node_tex_image", in, out, GPU_image(ima, iuser, ncd)); + return ret; } /* node type definition */ diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c index b9f1b5c1d21..86feabbcc2b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_magic.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_magic.c @@ -29,14 +29,14 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_tex_magic_in[]= { +static bNodeSocketTemplate sh_node_tex_magic_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, { SOCK_FLOAT, 1, N_("Distortion"), 1.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_magic_out[]= { +static bNodeSocketTemplate sh_node_tex_magic_out[] = { { SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c index 60b4f65f0b4..cd4b5743e14 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_musgrave.c @@ -29,7 +29,7 @@ /* **************** MUSGRAVE ******************** */ -static bNodeSocketTemplate sh_node_tex_musgrave_in[]= { +static bNodeSocketTemplate sh_node_tex_musgrave_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, { SOCK_FLOAT, 1, N_("Detail"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f}, @@ -40,7 +40,7 @@ static bNodeSocketTemplate sh_node_tex_musgrave_in[]= { { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_musgrave_out[]= { +static bNodeSocketTemplate sh_node_tex_musgrave_out[] = { { SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c index bd049300048..18788f9e72c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_noise.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_noise.c @@ -29,7 +29,7 @@ /* **************** NOISE ******************** */ -static bNodeSocketTemplate sh_node_tex_noise_in[]= { +static bNodeSocketTemplate sh_node_tex_noise_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, { SOCK_FLOAT, 1, N_("Detail"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 16.0f}, @@ -37,7 +37,7 @@ static bNodeSocketTemplate sh_node_tex_noise_in[]= { { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_noise_out[]= { +static bNodeSocketTemplate sh_node_tex_noise_out[] = { { SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c index 977d689ace6..7a1b853a7f4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c @@ -29,12 +29,12 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_tex_sky_in[]= { +static bNodeSocketTemplate sh_node_tex_sky_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_sky_out[]= { +static bNodeSocketTemplate sh_node_tex_sky_out[] = { { SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c index 22baa3853ac..d4cc24687b3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.c @@ -29,13 +29,13 @@ /* **************** VORONOI ******************** */ -static bNodeSocketTemplate sh_node_tex_voronoi_in[]= { +static bNodeSocketTemplate sh_node_tex_voronoi_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_voronoi_out[]= { +static bNodeSocketTemplate sh_node_tex_voronoi_out[] = { { SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c index 8a099521ee9..8b23de0310c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_wave.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_wave.c @@ -29,7 +29,7 @@ /* **************** WAVE ******************** */ -static bNodeSocketTemplate sh_node_tex_wave_in[]= { +static bNodeSocketTemplate sh_node_tex_wave_in[] = { { SOCK_VECTOR, 1, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, { SOCK_FLOAT, 1, N_("Scale"), 5.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, { SOCK_FLOAT, 1, N_("Distortion"), 0.0f, 0.0f, 0.0f, 0.0f, -1000.0f, 1000.0f}, @@ -38,7 +38,7 @@ static bNodeSocketTemplate sh_node_tex_wave_in[]= { { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_tex_wave_out[]= { +static bNodeSocketTemplate sh_node_tex_wave_out[] = { { SOCK_RGBA, 0, N_("Color"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 0, N_("Fac"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c index 73c3b846fe3..6d1b3ff6dba 100644 --- a/source/blender/nodes/shader/nodes/node_shader_texture.c +++ b/source/blender/nodes/shader/nodes/node_shader_texture.c @@ -32,14 +32,16 @@ #include "DNA_texture_types.h" +#include "IMB_colormanagement.h" + #include "node_shader_util.h" /* **************** TEXTURE ******************** */ -static bNodeSocketTemplate sh_node_texture_in[]= { +static bNodeSocketTemplate sh_node_texture_in[] = { { SOCK_VECTOR, 1, "Vector", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE}, /* no limit */ { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_texture_out[]= { +static bNodeSocketTemplate sh_node_texture_out[] = { { SOCK_FLOAT, 0, N_("Value")}, { SOCK_RGBA, 0, N_("Color")}, { SOCK_VECTOR, 0, N_("Normal")}, @@ -52,7 +54,7 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b ShadeInput *shi= ((ShaderCallData *)data)->shi; TexResult texres; bNodeSocket *sock_vector= node->inputs.first; - float vec[3], nor[3]={0.0f, 0.0f, 0.0f}; + float vec[3], nor[3] = {0.0f, 0.0f, 0.0f}; int retval; short which_output = node->custom1; @@ -76,8 +78,8 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b float *fp= in[0]->data; float dxt[3], dyt[3]; - dxt[0]= fp[0]; dxt[1]= dxt[2]= 0.0f; - dyt[0]= fp[1]; dyt[1]= dyt[2]= 0.0f; + dxt[0] = fp[0]; dxt[1] = dxt[2] = 0.0f; + dyt[0] = fp[1]; dyt[1] = dyt[2] = 0.0f; retval= multitex_nodes((Tex *)node->id, vec, dxt, dyt, shi->osatex, &texres, thread, which_output, NULL, NULL); } else @@ -96,9 +98,9 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b /* intensity and color need some handling */ if (texres.talpha) - out[0]->vec[0]= texres.ta; + out[0]->vec[0] = texres.ta; else - out[0]->vec[0]= texres.tin; + out[0]->vec[0] = texres.tin; if ((retval & TEX_RGB) == 0) { copy_v3_fl(out[1]->vec, out[0]->vec[0]); @@ -122,8 +124,19 @@ static int gpu_shader_texture(GPUMaterial *mat, bNode *node, GPUNodeStack *in, G Tex *tex = (Tex*)node->id; if (tex && tex->type == TEX_IMAGE && tex->ima) { - GPUNodeLink *texlink = GPU_image(tex->ima, NULL, FALSE); - return GPU_stack_link(mat, "texture_image", in, out, texlink); + GPUNodeLink *texlink = GPU_image(tex->ima, &tex->iuser, FALSE); + int ret = GPU_stack_link(mat, "texture_image", in, out, texlink); + + if (ret) { + ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); + if (ibuf && (ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA) ==0 && + GPU_material_do_color_management(mat)) + { + GPU_link(mat, "srgb_to_linearrgb", out[1].link, &out[1].link); + } + } + + return ret; } else return 0; diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c index d3094200f83..182487d343e 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c @@ -33,11 +33,11 @@ #include "node_shader_util.h" /* **************** VALTORGB ******************** */ -static bNodeSocketTemplate sh_node_valtorgb_in[]= { +static bNodeSocketTemplate sh_node_valtorgb_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_valtorgb_out[]= { +static bNodeSocketTemplate sh_node_valtorgb_out[] = { { SOCK_RGBA, 0, N_("Color")}, { SOCK_FLOAT, 0, N_("Alpha")}, { -1, 0, "" } @@ -53,7 +53,7 @@ static void node_shader_exec_valtorgb(void *UNUSED(data), bNode *node, bNodeStac nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); do_colorband(node->storage, fac, out[0]->vec); - out[1]->vec[0]= out[0]->vec[3]; + out[1]->vec[0] = out[0]->vec[3]; } } @@ -89,11 +89,11 @@ void register_node_type_sh_valtorgb(bNodeTreeType *ttype) /* **************** RGBTOBW ******************** */ -static bNodeSocketTemplate sh_node_rgbtobw_in[]= { +static bNodeSocketTemplate sh_node_rgbtobw_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_rgbtobw_out[]= { +static bNodeSocketTemplate sh_node_rgbtobw_out[] = { { SOCK_FLOAT, 0, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_value.c b/source/blender/nodes/shader/nodes/node_shader_value.c index 8a6c3c87e0d..a3d1e5afec2 100644 --- a/source/blender/nodes/shader/nodes/node_shader_value.c +++ b/source/blender/nodes/shader/nodes/node_shader_value.c @@ -33,7 +33,7 @@ #include "node_shader_util.h" /* **************** VALUE ******************** */ -static bNodeSocketTemplate sh_node_value_out[]= { +static bNodeSocketTemplate sh_node_value_out[] = { /* XXX value nodes use the output sockets for buttons, so we need explicit limits here! */ { SOCK_FLOAT, 0, N_("Value"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX}, { -1, 0, "" } @@ -54,7 +54,7 @@ static void node_shader_exec_value(void *UNUSED(data), bNode *node, bNodeStack * bNodeSocket *sock= node->outputs.first; float val= ((bNodeSocketValueFloat*)sock->default_value)->value; - out[0]->vec[0]= val; + out[0]->vec[0] = val; } static int gpu_shader_value(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out) diff --git a/source/blender/nodes/shader/nodes/node_shader_vectMath.c b/source/blender/nodes/shader/nodes/node_shader_vectMath.c index 007366c6082..2d9f1903c5b 100644 --- a/source/blender/nodes/shader/nodes/node_shader_vectMath.c +++ b/source/blender/nodes/shader/nodes/node_shader_vectMath.c @@ -35,16 +35,16 @@ /* **************** VECTOR MATH ******************** */ -static bNodeSocketTemplate sh_node_vect_math_in[]= { - { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, - { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, - { -1, 0, "" } +static bNodeSocketTemplate sh_node_vect_math_in[] = { + { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + { SOCK_VECTOR, 1, N_("Vector"), 0.5f, 0.5f, 0.5f, 1.0f, -10000.0f, 10000.0f, PROP_NONE}, + { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_vect_math_out[]= { - { SOCK_VECTOR, 0, N_("Vector")}, +static bNodeSocketTemplate sh_node_vect_math_out[] = { + { SOCK_VECTOR, 0, N_("Vector")}, { SOCK_FLOAT, 0, N_("Value")}, - { -1, 0, "" } + { -1, 0, "" } }; static void node_shader_exec_vect_math(void *UNUSED(data), bNode *node, bNodeStack **in, bNodeStack **out) @@ -55,46 +55,46 @@ static void node_shader_exec_vect_math(void *UNUSED(data), bNode *node, bNodeSta nodestack_get_vec(vec2, SOCK_VECTOR, in[1]); if (node->custom1 == 0) { /* Add */ - out[0]->vec[0]= vec1[0] + vec2[0]; - out[0]->vec[1]= vec1[1] + vec2[1]; - out[0]->vec[2]= vec1[2] + vec2[2]; + out[0]->vec[0] = vec1[0] + vec2[0]; + out[0]->vec[1] = vec1[1] + vec2[1]; + out[0]->vec[2] = vec1[2] + vec2[2]; - out[1]->vec[0]= (fabs(out[0]->vec[0]) + fabs(out[0]->vec[0]) + fabs(out[0]->vec[0])) / 3; + out[1]->vec[0] = (fabs(out[0]->vec[0]) + fabs(out[0]->vec[0]) + fabs(out[0]->vec[0])) / 3; } else if (node->custom1 == 1) { /* Subtract */ - out[0]->vec[0]= vec1[0] - vec2[0]; - out[0]->vec[1]= vec1[1] - vec2[1]; - out[0]->vec[2]= vec1[2] - vec2[2]; + out[0]->vec[0] = vec1[0] - vec2[0]; + out[0]->vec[1] = vec1[1] - vec2[1]; + out[0]->vec[2] = vec1[2] - vec2[2]; - out[1]->vec[0]= (fabs(out[0]->vec[0]) + fabs(out[0]->vec[0]) + fabs(out[0]->vec[0])) / 3; + out[1]->vec[0] = (fabs(out[0]->vec[0]) + fabs(out[0]->vec[0]) + fabs(out[0]->vec[0])) / 3; } else if (node->custom1 == 2) { /* Average */ - out[0]->vec[0]= vec1[0] + vec2[0]; - out[0]->vec[1]= vec1[1] + vec2[1]; - out[0]->vec[2]= vec1[2] + vec2[2]; + out[0]->vec[0] = vec1[0] + vec2[0]; + out[0]->vec[1] = vec1[1] + vec2[1]; + out[0]->vec[2] = vec1[2] + vec2[2]; out[1]->vec[0] = normalize_v3(out[0]->vec ); } else if (node->custom1 == 3) { /* Dot product */ - out[1]->vec[0]= (vec1[0] * vec2[0]) + (vec1[1] * vec2[1]) + (vec1[2] * vec2[2]); + out[1]->vec[0] = (vec1[0] * vec2[0]) + (vec1[1] * vec2[1]) + (vec1[2] * vec2[2]); } else if (node->custom1 == 4) { /* Cross product */ - out[0]->vec[0]= (vec1[1] * vec2[2]) - (vec1[2] * vec2[1]); - out[0]->vec[1]= (vec1[2] * vec2[0]) - (vec1[0] * vec2[2]); - out[0]->vec[2]= (vec1[0] * vec2[1]) - (vec1[1] * vec2[0]); + out[0]->vec[0] = (vec1[1] * vec2[2]) - (vec1[2] * vec2[1]); + out[0]->vec[1] = (vec1[2] * vec2[0]) - (vec1[0] * vec2[2]); + out[0]->vec[2] = (vec1[0] * vec2[1]) - (vec1[1] * vec2[0]); out[1]->vec[0] = normalize_v3(out[0]->vec ); } else if (node->custom1 == 5) { /* Normalize */ if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ - out[0]->vec[0]= vec1[0]; - out[0]->vec[1]= vec1[1]; - out[0]->vec[2]= vec1[2]; + out[0]->vec[0] = vec1[0]; + out[0]->vec[1] = vec1[1]; + out[0]->vec[2] = vec1[2]; } else { - out[0]->vec[0]= vec2[0]; - out[0]->vec[1]= vec2[1]; - out[0]->vec[2]= vec2[2]; + out[0]->vec[0] = vec2[0]; + out[0]->vec[1] = vec2[1]; + out[0]->vec[2] = vec2[2]; } out[1]->vec[0] = normalize_v3(out[0]->vec ); diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_isotropic.c b/source/blender/nodes/shader/nodes/node_shader_volume_isotropic.c index 366f50ab4fc..5451eb303cc 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_isotropic.c +++ b/source/blender/nodes/shader/nodes/node_shader_volume_isotropic.c @@ -29,13 +29,13 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_volume_isotropic_in[]= { +static bNodeSocketTemplate sh_node_volume_isotropic_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_volume_isotropic_out[]= { +static bNodeSocketTemplate sh_node_volume_isotropic_out[] = { { SOCK_SHADER, 0, N_("Volume")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/shader/nodes/node_shader_volume_transparent.c b/source/blender/nodes/shader/nodes/node_shader_volume_transparent.c index 9d48f613d34..ad7d7fceda3 100644 --- a/source/blender/nodes/shader/nodes/node_shader_volume_transparent.c +++ b/source/blender/nodes/shader/nodes/node_shader_volume_transparent.c @@ -29,13 +29,13 @@ /* **************** OUTPUT ******************** */ -static bNodeSocketTemplate sh_node_volume_transparent_in[]= { +static bNodeSocketTemplate sh_node_volume_transparent_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Density"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1000.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate sh_node_volume_transparent_out[]= { +static bNodeSocketTemplate sh_node_volume_transparent_out[] = { { SOCK_SHADER, 0, N_("Volume")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c index 1bfd88d3af7..ba94531c259 100644 --- a/source/blender/nodes/texture/node_texture_tree.c +++ b/source/blender/nodes/texture/node_texture_tree.c @@ -134,7 +134,7 @@ bNodeTreeType ntreeType_Texture = { /* update */ update, /* update_node */ NULL, /* validate_link */ NULL, - /* internal_connect */ node_internal_connect_default + /* update_internal_links */ node_update_internal_links_default }; int ntreeTexTagAnimated(bNodeTree *ntree) diff --git a/source/blender/nodes/texture/nodes/node_texture_at.c b/source/blender/nodes/texture/nodes/node_texture_at.c index 9e557705b3f..4c2d276b902 100644 --- a/source/blender/nodes/texture/nodes/node_texture_at.c +++ b/source/blender/nodes/texture/nodes/node_texture_at.c @@ -33,12 +33,12 @@ #include "node_texture_util.h" #include "NOD_texture.h" -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_RGBA, 1, N_("Texture"), 0.0f, 0.0f, 0.0f, 1.0f }, { SOCK_VECTOR, 1, N_("Coordinates"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE }, { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { +static bNodeSocketTemplate outputs[] = { { SOCK_RGBA, 0, N_("Texture") }, { -1, 0, "" } }; diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c index c575547b3ce..b4f81f08e43 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.c +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c @@ -35,7 +35,7 @@ #include <math.h> -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_RGBA, 1, N_("Bricks 1"), 0.596f, 0.282f, 0.0f, 1.0f }, { SOCK_RGBA, 1, N_("Bricks 2"), 0.632f, 0.504f, 0.05f, 1.0f }, { SOCK_RGBA, 1, N_("Mortar"), 0.0f, 0.0f, 0.0f, 1.0f }, @@ -45,7 +45,7 @@ static bNodeSocketTemplate inputs[]= { { SOCK_FLOAT, 1, N_("Row Height"), 0.25f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED }, { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { +static bNodeSocketTemplate outputs[] = { { SOCK_RGBA, 0, N_("Color")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/texture/nodes/node_texture_checker.c b/source/blender/nodes/texture/nodes/node_texture_checker.c index cd9c3170cf7..1f653d1f7b9 100644 --- a/source/blender/nodes/texture/nodes/node_texture_checker.c +++ b/source/blender/nodes/texture/nodes/node_texture_checker.c @@ -34,13 +34,13 @@ #include "NOD_texture.h" #include <math.h> -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_RGBA, 1, N_("Color1"), 1.0f, 0.0f, 0.0f, 1.0f }, { SOCK_RGBA, 1, N_("Color2"), 1.0f, 1.0f, 1.0f, 1.0f }, { SOCK_FLOAT, 1, N_("Size"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 100.0f, PROP_UNSIGNED }, { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { +static bNodeSocketTemplate outputs[] = { { SOCK_RGBA, 0, N_("Color") }, { -1, 0, "" } }; @@ -62,7 +62,7 @@ static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack ** } else { tex_input_rgba(out, in[1], p, thread); - } + } } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c index 1eaf9b2b0fe..41bfd0ae00a 100644 --- a/source/blender/nodes/texture/nodes/node_texture_common.c +++ b/source/blender/nodes/texture/nodes/node_texture_common.c @@ -148,128 +148,3 @@ void register_node_type_tex_group(bNodeTreeType *ttype) nodeRegisterType(ttype, &ntype); } - - -/**** FOR LOOP ****/ - -#if 0 /* XXX loop nodes don't work nicely with current trees */ -static void forloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out) -{ - bNodeTreeExec *exec= (bNodeTreeExec*)nodedata; - bNodeThreadStack *nts; - int iterations= (int)in[0]->vec[0]; - bNodeSocket *sock; - bNodeStack *ns; - int iteration; - - /* XXX same behavior as trunk: all nodes inside group are executed. - * it's stupid, but just makes it work. compo redesign will do this better. - */ - { - bNode *inode; - for (inode=exec->nodetree->nodes.first; inode; inode=inode->next) - inode->need_exec = 1; - } - - nts = ntreeGetThreadStack(exec, thread); - - /* "Iteration" socket */ - sock = exec->nodetree->inputs.first; - ns = node_get_socket_stack(nts->stack, sock); - -// group_copy_inputs(node, in, nts->stack); - for (iteration=0; iteration < iterations; ++iteration) { - /* first input contains current iteration counter */ - ns->vec[0] = (float)iteration; - ns->vec[1]=ns->vec[2]=ns->vec[3] = 0.0f; - -// if (iteration > 0) -// loop_init_iteration(exec->nodetree, nts->stack); -// ntreeExecThreadNodes(exec, nts, data, thread); - } -// loop_copy_outputs(node, in, out, exec->stack); - - ntreeReleaseThreadStack(nts); -} - -void register_node_type_tex_forloop(bNodeTreeType *ttype) -{ - static bNodeType ntype; - - node_type_base(ttype, &ntype, NODE_FORLOOP, "For", NODE_CLASS_GROUP, NODE_OPTIONS); - node_type_socket_templates(&ntype, NULL, NULL); - node_type_size(&ntype, 120, 60, 200); - node_type_label(&ntype, node_group_label); - node_type_init(&ntype, node_forloop_init); - node_type_valid(&ntype, node_group_valid); - node_type_template(&ntype, node_forloop_template); - node_type_update(&ntype, NULL, node_group_verify); - node_type_tree(&ntype, node_forloop_init_tree, node_loop_update_tree); - node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear); - node_type_exec_new(&ntype, group_initexec, group_freeexec, forloop_execute); - - nodeRegisterType(ttype, &ntype); -} -#endif - -/**** WHILE LOOP ****/ - -#if 0 /* XXX loop nodes don't work nicely with current trees */ -static void whileloop_execute(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out) -{ - bNodeTreeExec *exec= (bNodeTreeExec*)nodedata; - bNodeThreadStack *nts; - int condition= (in[0]->vec[0] > 0.0f); - bNodeSocket *sock; - bNodeStack *ns; - int iteration; - - /* XXX same behavior as trunk: all nodes inside group are executed. - * it's stupid, but just makes it work. compo redesign will do this better. - */ - { - bNode *inode; - for (inode=exec->nodetree->nodes.first; inode; inode=inode->next) - inode->need_exec = 1; - } - - nts = ntreeGetThreadStack(exec, thread); - - /* "Condition" socket */ - sock = exec->nodetree->outputs.first; - ns = node_get_socket_stack(nts->stack, sock); - - iteration = 0; -// group_copy_inputs(node, in, nts->stack); - while (condition && iteration < node->custom1) { -// if (iteration > 0) -// loop_init_iteration(exec->nodetree, nts->stack); -// ntreeExecThreadNodes(exec, nts, data, thread); - - condition = (ns->vec[0] > 0.0f); - ++iteration; - } -// loop_copy_outputs(node, in, out, exec->stack); - - ntreeReleaseThreadStack(nts); -} - -void register_node_type_tex_whileloop(bNodeTreeType *ttype) -{ - static bNodeType ntype; - - node_type_base(ttype, &ntype, NODE_WHILELOOP, "While", NODE_CLASS_GROUP, NODE_OPTIONS); - node_type_socket_templates(&ntype, NULL, NULL); - node_type_size(&ntype, 120, 60, 200); - node_type_label(&ntype, node_group_label); - node_type_init(&ntype, node_whileloop_init); - node_type_valid(&ntype, node_group_valid); - node_type_template(&ntype, node_whileloop_template); - node_type_update(&ntype, NULL, node_group_verify); - node_type_tree(&ntype, node_whileloop_init_tree, node_loop_update_tree); - node_type_group_edit(&ntype, node_group_edit_get, node_group_edit_set, node_group_edit_clear); - node_type_exec_new(&ntype, group_initexec, group_freeexec, whileloop_execute); - - nodeRegisterType(ttype, &ntype); -} -#endif diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c index 77521190590..25da4f19e52 100644 --- a/source/blender/nodes/texture/nodes/node_texture_compose.c +++ b/source/blender/nodes/texture/nodes/node_texture_compose.c @@ -33,14 +33,14 @@ #include "node_texture_util.h" #include "NOD_texture.h" -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_FLOAT, 1, N_("Red"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Green"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Blue"), 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Alpha"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED }, { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { +static bNodeSocketTemplate outputs[] = { { SOCK_RGBA, 0, N_("Color") }, { -1, 0, "" } }; diff --git a/source/blender/nodes/texture/nodes/node_texture_coord.c b/source/blender/nodes/texture/nodes/node_texture_coord.c index 2add5c820eb..971520ebc38 100644 --- a/source/blender/nodes/texture/nodes/node_texture_coord.c +++ b/source/blender/nodes/texture/nodes/node_texture_coord.c @@ -33,7 +33,7 @@ #include "node_texture_util.h" #include "NOD_texture.h" -static bNodeSocketTemplate outputs[]= { +static bNodeSocketTemplate outputs[] = { { SOCK_VECTOR, 0, N_("Coordinates") }, { -1, 0, "" } }; diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c index 6ccb5e1e83f..5980f938938 100644 --- a/source/blender/nodes/texture/nodes/node_texture_curves.c +++ b/source/blender/nodes/texture/nodes/node_texture_curves.c @@ -36,7 +36,7 @@ /* **************** CURVE Time ******************** */ /* custom1 = sfra, custom2 = efra */ -static bNodeSocketTemplate time_outputs[]= { +static bNodeSocketTemplate time_outputs[] = { { SOCK_FLOAT, 0, N_("Value") }, { -1, 0, "" } }; @@ -83,12 +83,12 @@ void register_node_type_tex_curve_time(bNodeTreeType *ttype) } /* **************** CURVE RGB ******************** */ -static bNodeSocketTemplate rgb_inputs[]= { +static bNodeSocketTemplate rgb_inputs[] = { { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate rgb_outputs[]= { +static bNodeSocketTemplate rgb_outputs[] = { { SOCK_RGBA, 0, N_("Color")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/texture/nodes/node_texture_decompose.c b/source/blender/nodes/texture/nodes/node_texture_decompose.c index eae34e2ce47..a2875c31d9e 100644 --- a/source/blender/nodes/texture/nodes/node_texture_decompose.c +++ b/source/blender/nodes/texture/nodes/node_texture_decompose.c @@ -34,11 +34,11 @@ #include "NOD_texture.h" #include <math.h> -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f }, { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { +static bNodeSocketTemplate outputs[] = { { SOCK_FLOAT, 0, N_("Red") }, { SOCK_FLOAT, 0, N_("Green") }, { SOCK_FLOAT, 0, N_("Blue") }, diff --git a/source/blender/nodes/texture/nodes/node_texture_distance.c b/source/blender/nodes/texture/nodes/node_texture_distance.c index 29f08a0ded0..8c3b1555d5d 100644 --- a/source/blender/nodes/texture/nodes/node_texture_distance.c +++ b/source/blender/nodes/texture/nodes/node_texture_distance.c @@ -35,13 +35,13 @@ #include "node_texture_util.h" #include "NOD_texture.h" -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_VECTOR, 1, N_("Coordinate 1"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE }, { SOCK_VECTOR, 1, N_("Coordinate 2"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE }, - { -1, 0, "" } + { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { +static bNodeSocketTemplate outputs[] = { { SOCK_FLOAT, 0, N_("Value") }, { -1, 0, "" } }; diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c index 6863eab9150..b5e9969a830 100644 --- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c +++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c @@ -34,7 +34,7 @@ #include "NOD_texture.h" -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_FLOAT, 1, N_("Hue"), 0.0f, 0.0f, 0.0f, 0.0f, -0.5f, 0.5f, PROP_NONE }, { SOCK_FLOAT, 1, N_("Saturation"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_FACTOR }, { SOCK_FLOAT, 1, N_("Value"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_FACTOR }, @@ -42,7 +42,7 @@ static bNodeSocketTemplate inputs[]= { { SOCK_RGBA, 1, N_("Color"), 0.8f, 0.8f, 0.8f, 1.0f }, { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { +static bNodeSocketTemplate outputs[] = { { SOCK_RGBA, 0, N_("Color") }, { -1, 0, "" } }; @@ -56,14 +56,14 @@ static void do_hue_sat_fac(bNode *UNUSED(node), float *out, float hue, float sat hsv[0]+= (hue - 0.5f); if (hsv[0]>1.0f) hsv[0]-=1.0f; else if (hsv[0]<0.0f) hsv[0]+= 1.0f; hsv[1]*= sat; - if (hsv[1]>1.0f) hsv[1]= 1.0f; else if (hsv[1]<0.0f) hsv[1]= 0.0f; + if (hsv[1]>1.0f) hsv[1] = 1.0f; else if (hsv[1]<0.0f) hsv[1] = 0.0f; hsv[2]*= val; - if (hsv[2]>1.0f) hsv[2]= 1.0f; else if (hsv[2]<0.0f) hsv[2]= 0.0f; + if (hsv[2]>1.0f) hsv[2] = 1.0f; else if (hsv[2]<0.0f) hsv[2] = 0.0f; hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col+1, col+2); - out[0]= mfac*in[0] + fac*col[0]; - out[1]= mfac*in[1] + fac*col[1]; - out[2]= mfac*in[2] + fac*col[2]; + out[0] = mfac*in[0] + fac*col[0]; + out[1] = mfac*in[1] + fac*col[1]; + out[2] = mfac*in[2] + fac*col[2]; } else { copy_v4_v4(out, in); diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c index 7ce91c37295..f3fdaf0bb64 100644 --- a/source/blender/nodes/texture/nodes/node_texture_image.c +++ b/source/blender/nodes/texture/nodes/node_texture_image.c @@ -33,7 +33,7 @@ #include "node_texture_util.h" #include "NOD_texture.h" -static bNodeSocketTemplate outputs[]= { +static bNodeSocketTemplate outputs[] = { { SOCK_RGBA, 0, N_("Image")}, { -1, 0, "" } }; diff --git a/source/blender/nodes/texture/nodes/node_texture_invert.c b/source/blender/nodes/texture/nodes/node_texture_invert.c index 0339c3f0cf2..9c2963d2dc2 100644 --- a/source/blender/nodes/texture/nodes/node_texture_invert.c +++ b/source/blender/nodes/texture/nodes/node_texture_invert.c @@ -34,14 +34,14 @@ #include "NOD_texture.h" /* **************** INVERT ******************** */ -static bNodeSocketTemplate inputs[]= { - { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, - { -1, 0, "" } +static bNodeSocketTemplate inputs[] = { + { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, + { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, "" } +static bNodeSocketTemplate outputs[] = { + { SOCK_RGBA, 0, N_("Color")}, + { -1, 0, "" } }; static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c index 36e9cac0827..95d70ccc7d6 100644 --- a/source/blender/nodes/texture/nodes/node_texture_math.c +++ b/source/blender/nodes/texture/nodes/node_texture_math.c @@ -35,15 +35,15 @@ /* **************** SCALAR MATH ******************** */ -static bNodeSocketTemplate inputs[]= { - { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE}, - { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE}, - { -1, 0, "" } +static bNodeSocketTemplate inputs[] = { + { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE}, + { SOCK_FLOAT, 1, N_("Value"), 0.5f, 0.5f, 0.5f, 1.0f, -100.0f, 100.0f, PROP_NONE}, + { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { - { SOCK_FLOAT, 0, N_("Value")}, - { -1, 0, "" } +static bNodeSocketTemplate outputs[] = { + { SOCK_FLOAT, 0, N_("Value")}, + { -1, 0, "" } }; static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) @@ -112,7 +112,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor { /* Only raise negative numbers by full integers */ if ( in0 >= 0 ) { - out[0]= pow(in0, in1); + out[0] = pow(in0, in1); } else { float y_mod_1 = fmod(in1, 1); @@ -178,7 +178,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor fprintf(stderr, "%s:%d: unhandeld value in switch statement: %d\n", __FILE__, __LINE__, node->custom1); - } + } } static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c index bf6cb7a3262..fe04854c734 100644 --- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c @@ -34,13 +34,13 @@ #include "NOD_texture.h" /* **************** MIX RGB ******************** */ -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_FLOAT, 1, N_("Factor"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR }, { SOCK_RGBA, 1, N_("Color1"), 0.5f, 0.5f, 0.5f, 1.0f }, { SOCK_RGBA, 1, N_("Color2"), 0.5f, 0.5f, 0.5f, 1.0f }, { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { +static bNodeSocketTemplate outputs[] = { { SOCK_RGBA, 0, N_("Color") }, { -1, 0, "" } }; diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c index fdd3b97ad59..2f5efe8c45e 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.c +++ b/source/blender/nodes/texture/nodes/node_texture_output.c @@ -34,7 +34,7 @@ #include "NOD_texture.h" /* **************** COMPOSITE ******************** */ -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_VECTOR, 1, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_DIRECTION}, { -1, 0, "" } @@ -170,7 +170,7 @@ void register_node_type_tex_output(bNodeTreeType *ttype) node_type_exec(&ntype, exec); /* Do not allow muting output. */ - node_type_internal_connect(&ntype, NULL); + node_type_internal_links(&ntype, NULL); nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c index 1f724292661..8876d98b9b2 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ b/source/blender/nodes/texture/nodes/node_texture_proc.c @@ -40,12 +40,12 @@ */ -static bNodeSocketTemplate outputs_both[]= { +static bNodeSocketTemplate outputs_both[] = { { SOCK_RGBA, 0, N_("Color"), 1.0f, 0.0f, 0.0f, 1.0f }, { SOCK_VECTOR, 0, N_("Normal"), 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, PROP_DIRECTION }, { -1, 0, "" } }; -static bNodeSocketTemplate outputs_color_only[]= { +static bNodeSocketTemplate outputs_color_only[] = { { SOCK_RGBA, 0, N_("Color") }, { -1, 0, "" } }; @@ -138,7 +138,7 @@ static int count_outputs(bNode *node) /* --- VORONOI -- */ -static bNodeSocketTemplate voronoi_inputs[]= { +static bNodeSocketTemplate voronoi_inputs[] = { COMMON_INPUTS, { SOCK_FLOAT, 1, N_("W1"), 1.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE }, { SOCK_FLOAT, 1, N_("W2"), 0.0f, 0.0f, 0.0f, 0.0f, -2.0f, 2.0f, PROP_NONE }, @@ -163,7 +163,7 @@ static void voronoi_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short th ProcDef(voronoi) /* --- BLEND -- */ -static bNodeSocketTemplate blend_inputs[]= { +static bNodeSocketTemplate blend_inputs[] = { COMMON_INPUTS, { -1, 0, "" } }; @@ -171,7 +171,7 @@ ProcNoInputs(blend) ProcDef(blend) /* -- MAGIC -- */ -static bNodeSocketTemplate magic_inputs[]= { +static bNodeSocketTemplate magic_inputs[] = { COMMON_INPUTS, { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED }, { -1, 0, "" } @@ -183,7 +183,7 @@ static void magic_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thre ProcDef(magic) /* --- MARBLE --- */ -static bNodeSocketTemplate marble_inputs[]= { +static bNodeSocketTemplate marble_inputs[] = { COMMON_INPUTS, { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED }, @@ -197,7 +197,7 @@ static void marble_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thr ProcDef(marble) /* --- CLOUDS --- */ -static bNodeSocketTemplate clouds_inputs[]= { +static bNodeSocketTemplate clouds_inputs[] = { COMMON_INPUTS, { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, { -1, 0, "" } @@ -209,7 +209,7 @@ static void clouds_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short thr ProcDef(clouds) /* --- DISTORTED NOISE --- */ -static bNodeSocketTemplate distnoise_inputs[]= { +static bNodeSocketTemplate distnoise_inputs[] = { COMMON_INPUTS, { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Distortion"), 1.00f, 0.0f, 0.0f, 0.0f, 0.0000f, 10.0f, PROP_UNSIGNED }, @@ -223,7 +223,7 @@ static void distnoise_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short ProcDef(distnoise) /* --- WOOD --- */ -static bNodeSocketTemplate wood_inputs[]= { +static bNodeSocketTemplate wood_inputs[] = { COMMON_INPUTS, { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED }, @@ -237,7 +237,7 @@ static void wood_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short threa ProcDef(wood) /* --- MUSGRAVE --- */ -static bNodeSocketTemplate musgrave_inputs[]= { +static bNodeSocketTemplate musgrave_inputs[] = { COMMON_INPUTS, { SOCK_FLOAT, 1, N_("H"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Lacunarity"), 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, 6.0f, PROP_UNSIGNED }, @@ -258,7 +258,7 @@ static void musgrave_map_inputs(Tex *tex, bNodeStack **in, TexParams *p, short t ProcDef(musgrave) /* --- NOISE --- */ -static bNodeSocketTemplate noise_inputs[]= { +static bNodeSocketTemplate noise_inputs[] = { COMMON_INPUTS, { -1, 0, "" } }; @@ -266,7 +266,7 @@ ProcNoInputs(noise) ProcDef(noise) /* --- STUCCI --- */ -static bNodeSocketTemplate stucci_inputs[]= { +static bNodeSocketTemplate stucci_inputs[] = { COMMON_INPUTS, { SOCK_FLOAT, 1, N_("Size"), 0.25f, 0.0f, 0.0f, 0.0f, 0.0001f, 2.0f, PROP_UNSIGNED }, { SOCK_FLOAT, 1, N_("Turbulence"), 5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 200.0f, PROP_UNSIGNED }, diff --git a/source/blender/nodes/texture/nodes/node_texture_rotate.c b/source/blender/nodes/texture/nodes/node_texture_rotate.c index 2f997d36e71..1b1d57044a3 100644 --- a/source/blender/nodes/texture/nodes/node_texture_rotate.c +++ b/source/blender/nodes/texture/nodes/node_texture_rotate.c @@ -35,16 +35,16 @@ #include "node_texture_util.h" #include "NOD_texture.h" -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_FLOAT, 1, N_("Turns"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE }, { SOCK_VECTOR, 1, N_("Axis"), 0.0f, 0.0f, 1.0f, 0.0f, -1.0f, 1.0f, PROP_DIRECTION }, - { -1, 0, "" } + { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, "" } +static bNodeSocketTemplate outputs[] = { + { SOCK_RGBA, 0, N_("Color")}, + { -1, 0, "" } }; static void rotate(float new_co[3], float a, float ax[3], const float co[3]) diff --git a/source/blender/nodes/texture/nodes/node_texture_scale.c b/source/blender/nodes/texture/nodes/node_texture_scale.c index 130a21ba84d..56562724fb9 100644 --- a/source/blender/nodes/texture/nodes/node_texture_scale.c +++ b/source/blender/nodes/texture/nodes/node_texture_scale.c @@ -33,15 +33,15 @@ #include <math.h> #include "node_texture_util.h" -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f }, { SOCK_VECTOR, 1, N_("Scale"), 1.0f, 1.0f, 1.0f, 0.0f, -10.0f, 10.0f, PROP_XYZ }, - { -1, 0, "" } + { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, "" } +static bNodeSocketTemplate outputs[] = { + { SOCK_RGBA, 0, N_("Color")}, + { -1, 0, "" } }; static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) diff --git a/source/blender/nodes/texture/nodes/node_texture_texture.c b/source/blender/nodes/texture/nodes/node_texture_texture.c index 4832f19f2c7..cc7367a7632 100644 --- a/source/blender/nodes/texture/nodes/node_texture_texture.c +++ b/source/blender/nodes/texture/nodes/node_texture_texture.c @@ -35,13 +35,13 @@ #include "RE_shader_ext.h" -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_RGBA, 1, N_("Color1"), 1.0f, 1.0f, 1.0f, 1.0f }, { SOCK_RGBA, 1, N_("Color2"), 0.0f, 0.0f, 0.0f, 1.0f }, { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { +static bNodeSocketTemplate outputs[] = { { SOCK_RGBA, 0, N_("Color") }, { -1, 0, "" } }; diff --git a/source/blender/nodes/texture/nodes/node_texture_translate.c b/source/blender/nodes/texture/nodes/node_texture_translate.c index 85f857ca2be..a95cb00a47d 100644 --- a/source/blender/nodes/texture/nodes/node_texture_translate.c +++ b/source/blender/nodes/texture/nodes/node_texture_translate.c @@ -34,15 +34,15 @@ #include "node_texture_util.h" #include "NOD_texture.h" -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_RGBA, 1, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f}, { SOCK_VECTOR, 1, N_("Offset"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_TRANSLATION }, - { -1, 0, "" } + { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, "" } +static bNodeSocketTemplate outputs[] = { + { SOCK_RGBA, 0, N_("Color")}, + { -1, 0, "" } }; static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) diff --git a/source/blender/nodes/texture/nodes/node_texture_valToNor.c b/source/blender/nodes/texture/nodes/node_texture_valToNor.c index 73dcc72eb40..bbfc1fa616b 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToNor.c +++ b/source/blender/nodes/texture/nodes/node_texture_valToNor.c @@ -33,15 +33,15 @@ #include "node_texture_util.h" #include "NOD_texture.h" -static bNodeSocketTemplate inputs[]= { +static bNodeSocketTemplate inputs[] = { { SOCK_FLOAT, 1, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE }, { SOCK_FLOAT, 1, N_("Nabla"), 0.025f, 0.0f, 0.0f, 0.0f, 0.001f, 0.1f, PROP_UNSIGNED }, - { -1, 0, "" } + { -1, 0, "" } }; -static bNodeSocketTemplate outputs[]= { - { SOCK_VECTOR, 0, N_("Normal") }, - { -1, 0, "" } +static bNodeSocketTemplate outputs[] = { + { SOCK_VECTOR, 0, N_("Normal") }, + { -1, 0, "" } }; static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) @@ -49,7 +49,7 @@ static void normalfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack * float new_co[3]; const float *co = p->co; - float nabla = tex_input_value(in[1], p, thread); + float nabla = tex_input_value(in[1], p, thread); float val; float nor[3]; diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c index 515613509f6..78635453fc1 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c @@ -34,11 +34,11 @@ #include "NOD_texture.h" /* **************** VALTORGB ******************** */ -static bNodeSocketTemplate valtorgb_in[]= { +static bNodeSocketTemplate valtorgb_in[] = { { SOCK_FLOAT, 1, N_("Fac"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR}, { -1, 0, "" } }; -static bNodeSocketTemplate valtorgb_out[]= { +static bNodeSocketTemplate valtorgb_out[] = { { SOCK_RGBA, 0, N_("Color")}, { -1, 0, "" } }; @@ -77,11 +77,11 @@ void register_node_type_tex_valtorgb(bNodeTreeType *ttype) } /* **************** RGBTOBW ******************** */ -static bNodeSocketTemplate rgbtobw_in[]= { +static bNodeSocketTemplate rgbtobw_in[] = { { SOCK_RGBA, 1, N_("Color"), 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; -static bNodeSocketTemplate rgbtobw_out[]= { +static bNodeSocketTemplate rgbtobw_out[] = { { SOCK_FLOAT, 0, N_("Val"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, { -1, 0, "" } }; diff --git a/source/blender/nodes/texture/nodes/node_texture_viewer.c b/source/blender/nodes/texture/nodes/node_texture_viewer.c index bc31bef59d8..5cb8d8c438c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_viewer.c +++ b/source/blender/nodes/texture/nodes/node_texture_viewer.c @@ -66,7 +66,7 @@ void register_node_type_tex_viewer(bNodeTreeType *ttype) node_type_exec(&ntype, exec); /* Do not allow muting viewer node. */ - node_type_internal_connect(&ntype, NULL); + node_type_internal_links(&ntype, NULL); nodeRegisterType(ttype, &ntype); } diff --git a/source/blender/opencl/CMakeLists.txt b/source/blender/opencl/CMakeLists.txt index 20dcf33d363..b3c76db1bca 100644 --- a/source/blender/opencl/CMakeLists.txt +++ b/source/blender/opencl/CMakeLists.txt @@ -1,4 +1,3 @@ -# $Id: CMakeLists.txt 14444 2008-04-16 22:40:48Z hos $ # ***** BEGIN GPL LICENSE BLOCK ***** # # This program is free software; you can redistribute it and/or diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index 83a40ecc068..9bd45d2b759 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -80,6 +80,7 @@ int BPY_button_exec(struct bContext *C, const char *expr, double *value, const int BPY_string_exec(struct bContext *C, const char *expr); void BPY_DECREF(void *pyob_ptr); /* Py_DECREF() */ +void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr); int BPY_context_member_get(struct bContext *C, const char *member, struct bContextDataResult *result); void BPY_context_set(struct bContext *C); void BPY_context_update(struct bContext *C); diff --git a/source/blender/python/bmesh/bmesh_py_types.h b/source/blender/python/bmesh/bmesh_py_types.h index 947e66bf24e..df5231a4b1b 100644 --- a/source/blender/python/bmesh/bmesh_py_types.h +++ b/source/blender/python/bmesh/bmesh_py_types.h @@ -116,7 +116,7 @@ typedef struct BPy_BMElemSeq { /* if this is a sequence on an existing element, * loops of faces for eg. - * If this veriable is set, it will be used */ + * If this variable is set, it will be used */ /* we hold a reference to this. * check in case the owner becomes invalid on access */ diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c index 0391839c763..1fea12d105c 100644 --- a/source/blender/python/bmesh/bmesh_py_types_customdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c @@ -1079,7 +1079,7 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj ret = -1; } else { - BLI_strncpy(mstring->s, tmp_val, MIN2(PyBytes_Size(py_value), sizeof(mstring->s))); + BLI_strncpy(mstring->s, tmp_val, min_ii(PyBytes_Size(py_value), sizeof(mstring->s))); } break; } diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index 9492c8384dc..3b8193c422d 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -542,7 +542,7 @@ void PyC_RunQuicky(const char *filepath, int n, ...) if (fp) { PyGILState_STATE gilstate = PyGILState_Ensure(); - va_list vargs; + va_list vargs; int *sizes = PyMem_MALLOC(sizeof(int) * (n / 2)); int i; diff --git a/source/blender/python/intern/bpy.c b/source/blender/python/intern/bpy.c index 529ad2782ab..333da6cb017 100644 --- a/source/blender/python/intern/bpy.c +++ b/source/blender/python/intern/bpy.c @@ -281,7 +281,7 @@ void BPy_init_modules(void) bpy_import_test("bpy_types"); PyModule_AddObject(mod, "data", BPY_rna_module()); /* imports bpy_types by running this */ bpy_import_test("bpy_types"); - PyModule_AddObject(mod, "props", BPY_rna_props()); + PyModule_AddObject(mod, "props", BPY_rna_props()); /* ops is now a python module that does the conversion from SOME_OT_foo -> some.foo */ PyModule_AddObject(mod, "ops", BPY_operator_module()); PyModule_AddObject(mod, "app", BPY_app_struct()); diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index ccce0d8c5ae..a8aa7269b72 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -242,6 +242,7 @@ static PyGetSetDef bpy_app_getsets[] = { {(char *)"debug_ffmpeg", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_FFMPEG}, {(char *)"debug_python", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_PYTHON}, {(char *)"debug_events", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_EVENTS}, + {(char *)"debug_handlers", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_HANDLERS}, {(char *)"debug_wm", bpy_app_debug_get, bpy_app_debug_set, (char *)bpy_app_debug_doc, (void *)G_DEBUG_WM}, {(char *)"debug_value", bpy_app_debug_value_get, bpy_app_debug_value_set, (char *)bpy_app_debug_value_doc, NULL}, diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index f6ab100ca1a..94cbee383ea 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -510,6 +510,18 @@ void BPY_DECREF(void *pyob_ptr) PyGILState_Release(gilstate); } +void BPY_DECREF_RNA_INVALIDATE(void *pyob_ptr) +{ + PyGILState_STATE gilstate = PyGILState_Ensure(); + const int do_invalidate = (Py_REFCNT((PyObject *)pyob_ptr) > 1); + Py_DECREF((PyObject *)pyob_ptr); + if (do_invalidate) { + pyrna_invalidate(pyob_ptr); + } + PyGILState_Release(gilstate); +} + + /* return -1 on error, else 0 */ int BPY_button_exec(bContext *C, const char *expr, double *value, const short verbose) { diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index bb116017f6b..164c9fec110 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -78,6 +78,7 @@ static EnumPropertyItem property_subtype_string_items[] = { {PROP_FILENAME, "FILENAME", 0, "Filename", ""}, {PROP_BYTESTRING, "BYTE_STRING", 0, "Byte String", ""}, {PROP_TRANSLATE, "TRANSLATE", 0, "Translate", ""}, + {PROP_PASSWORD, "PASSWORD", 0, "Password", 0}, {PROP_NONE, "NONE", 0, "None", ""}, {0, NULL, 0, NULL, NULL}}; @@ -260,7 +261,7 @@ static int bpy_prop_callback_check(PyObject *py_func, int argcount) static int bpy_prop_callback_assign(struct PropertyRNA *prop, PyObject *update_cb) { /* assume this is already checked for type and arg length */ - if (update_cb) { + if (update_cb && update_cb != Py_None) { PyObject **py_data = MEM_callocN(sizeof(PyObject *) * BPY_DATA_CB_SLOT_SIZE, __func__); RNA_def_property_update_runtime(prop, (void *)bpy_prop_update_cb); py_data[BPY_DATA_CB_SLOT_UPDATE] = update_cb; @@ -1511,7 +1512,7 @@ static PyObject *BPy_RemoveProperty(PyObject *self, PyObject *args, PyObject *kw args = PyTuple_New(0); ret = BPy_RemoveProperty(self, args, kw); Py_DECREF(args); - return ret; + return ret; } else if (PyTuple_GET_SIZE(args) > 1) { PyErr_SetString(PyExc_ValueError, "all args must be keywords"); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 00c1f5cfe6c..170eeb9e2af 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -119,13 +119,11 @@ int pyrna_prop_validity_check(BPy_PropertyRNA *self) return -1; } -#if defined(USE_PYRNA_INVALIDATE_GC) || defined(USE_PYRNA_INVALIDATE_WEAKREF) -static void pyrna_invalidate(BPy_DummyPointerRNA *self) +void pyrna_invalidate(BPy_DummyPointerRNA *self) { self->ptr.type = NULL; /* this is checked for validity */ self->ptr.id.data = NULL; /* should not be needed but prevent bad pointer access, just in case */ } -#endif #ifdef USE_PYRNA_INVALIDATE_GC #define FROM_GC(g) ((PyObject *)(((PyGC_Head *)g) + 1)) @@ -337,7 +335,7 @@ static int rna_id_write_error(PointerRNA *ptr, PyObject *key) } return FALSE; } -#endif // USE_PEDANTIC_WRITE +#endif /* USE_PEDANTIC_WRITE */ #ifdef USE_PEDANTIC_WRITE @@ -350,7 +348,7 @@ void pyrna_write_set(int val) { rna_disallow_writes = !val; } -#else // USE_PEDANTIC_WRITE +#else /* USE_PEDANTIC_WRITE */ int pyrna_write_check(void) { return TRUE; @@ -359,7 +357,7 @@ void pyrna_write_set(int UNUSED(val)) { /* nothing */ } -#endif // USE_PEDANTIC_WRITE +#endif /* USE_PEDANTIC_WRITE */ static Py_ssize_t pyrna_prop_collection_length(BPy_PropertyRNA *self); static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self); @@ -426,7 +424,7 @@ static int mathutils_rna_vector_set(BaseMathObject *bmo, int subtype) if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) { return -1; } -#endif // USE_PEDANTIC_WRITE +#endif /* USE_PEDANTIC_WRITE */ if (!RNA_property_editable_flag(&self->ptr, self->prop)) { PyErr_Format(PyExc_AttributeError, @@ -490,7 +488,7 @@ static int mathutils_rna_vector_set_index(BaseMathObject *bmo, int UNUSED(subtyp if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) { return -1; } -#endif // USE_PEDANTIC_WRITE +#endif /* USE_PEDANTIC_WRITE */ if (!RNA_property_editable_flag(&self->ptr, self->prop)) { PyErr_Format(PyExc_AttributeError, @@ -547,7 +545,7 @@ static int mathutils_rna_matrix_set(BaseMathObject *bmo, int UNUSED(subtype)) if (rna_disallow_writes && rna_id_write_error(&self->ptr, NULL)) { return -1; } -#endif // USE_PEDANTIC_WRITE +#endif /* USE_PEDANTIC_WRITE */ if (!RNA_property_editable_flag(&self->ptr, self->prop)) { PyErr_Format(PyExc_AttributeError, @@ -588,7 +586,7 @@ static short pyrna_rotation_euler_order_get(PointerRNA *ptr, PropertyRNA **prop_ return order_fallback; } -#endif // USE_MATHUTILS +#endif /* USE_MATHUTILS */ /* note that PROP_NONE is included as a vector subtype. this is because its handy to * have x/y access to fcurve keyframes and other fixed size float arrays of length 2-4. */ @@ -672,7 +670,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) PropertyRNA *prop_eul_order = NULL; short order = pyrna_rotation_euler_order_get(ptr, &prop_eul_order, EULER_ORDER_XYZ); - ret = Euler_CreatePyObject(NULL, order, Py_NEW, NULL); // TODO, get order from RNA + ret = Euler_CreatePyObject(NULL, order, Py_NEW, NULL); /* TODO, get order from RNA */ RNA_property_float_get_array(ptr, prop, ((EulerObject *)ret)->eul); } else { @@ -698,7 +696,7 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) case PROP_COLOR_GAMMA: if (len == 3) { /* color */ if (is_thick) { - ret = Color_CreatePyObject(NULL, Py_NEW, NULL); // TODO, get order from RNA + ret = Color_CreatePyObject(NULL, Py_NEW, NULL); RNA_property_float_get_array(ptr, prop, ((ColorObject *)ret)->col); } else { @@ -722,10 +720,10 @@ PyObject *pyrna_math_object_from_array(PointerRNA *ptr, PropertyRNA *prop) ret = pyrna_prop_CreatePyObject(ptr, prop); /* owned by the mathutils PyObject */ } } -#else // USE_MATHUTILS +#else /* USE_MATHUTILS */ (void)ptr; (void)prop; -#endif // USE_MATHUTILS +#endif /* USE_MATHUTILS */ return ret; } @@ -1302,7 +1300,7 @@ static PyObject *pyrna_enum_to_py(PointerRNA *ptr, PropertyRNA *prop, int val) val, RNA_struct_identifier(ptr->type), ptr_name, RNA_property_identifier(prop)); -#if 0 // gives python decoding errors while generating docs :( +#if 0 /* gives python decoding errors while generating docs :( */ char error_str[256]; BLI_snprintf(error_str, sizeof(error_str), "RNA Warning: Current value \"%d\" " @@ -1371,14 +1369,14 @@ PyObject *pyrna_prop_to_py(PointerRNA *ptr, PropertyRNA *prop) else { ret = PyUnicode_FromStringAndSize(buf, buf_len); } -#else // USE_STRING_COERCE +#else /* USE_STRING_COERCE */ if (subtype == PROP_BYTESTRING) { ret = PyBytes_FromStringAndSize(buf, buf_len); } else { ret = PyUnicode_FromStringAndSize(buf, buf_len); } -#endif // USE_STRING_COERCE +#endif /* USE_STRING_COERCE */ if (buf_fixed != buf) { MEM_freeN((void *)buf); } @@ -1635,12 +1633,12 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb if (subtype == PROP_TRANSLATE) { param = IFACE_(param); } -#endif // WITH_INTERNATIONAL +#endif /* WITH_INTERNATIONAL */ } -#else // USE_STRING_COERCE +#else /* USE_STRING_COERCE */ param = _PyUnicode_AsString(value); -#endif // USE_STRING_COERCE +#endif /* USE_STRING_COERCE */ if (param == NULL) { if (PyUnicode_Check(value)) { @@ -1668,7 +1666,7 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb } #ifdef USE_STRING_COERCE Py_XDECREF(value_coerce); -#endif // USE_STRING_COERCE +#endif /* USE_STRING_COERCE */ } break; } @@ -1995,7 +1993,7 @@ static int pyrna_py_to_prop_array_index(BPy_PropertyArrayRNA *self, int index, P return ret; } -//---------------sequence------------------------------------------- +/* ---------------sequence------------------------------------------- */ static Py_ssize_t pyrna_prop_array_length(BPy_PropertyArrayRNA *self) { PYRNA_PROP_CHECK_INT((BPy_PropertyRNA *)self); @@ -2982,7 +2980,7 @@ static int pyrna_struct_ass_subscript(BPy_StructRNA *self, PyObject *key, PyObje if (rna_disallow_writes && rna_id_write_error(&self->ptr, key)) { return -1; } -#endif // USE_PEDANTIC_WRITE +#endif /* USE_PEDANTIC_WRITE */ if (group == NULL) { PyErr_SetString(PyExc_TypeError, "bpy_struct[key] = val: id properties not supported for this type"); @@ -3441,7 +3439,7 @@ static PyObject *pyrna_struct_dir(BPy_StructRNA *self) return ret; } -//---------------getattr-------------------------------------------- +/* ---------------getattr-------------------------------------------- */ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) { const char *name = _PyUnicode_AsString(pyname); @@ -3455,7 +3453,7 @@ static PyObject *pyrna_struct_getattro(BPy_StructRNA *self, PyObject *pyname) PyErr_SetString(PyExc_AttributeError, "bpy_struct: __getattr__ must be a string"); ret = NULL; } - else if (name[0] == '_') { // rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups + else if (name[0] == '_') { /* rna can't start with a "_", so for __dict__ and similar we can skip using rna lookups */ /* annoying exception, maybe we need to have different types for this... */ if ((strcmp(name, "__getitem__") == 0 || strcmp(name, "__setitem__") == 0) && !RNA_struct_idprops_check(self->ptr.type)) { PyErr_SetString(PyExc_AttributeError, "bpy_struct: no __getitem__ support for this type"); @@ -3565,7 +3563,7 @@ static int pyrna_struct_pydict_contains(PyObject *self, PyObject *pyname) } #endif -//--------------- setattr------------------------------------------- +/* --------------- setattr------------------------------------------- */ static int pyrna_is_deferred_prop(const PyObject *value) { return PyTuple_CheckExact(value) && @@ -3678,7 +3676,7 @@ static int pyrna_struct_setattro(BPy_StructRNA *self, PyObject *pyname, PyObject if (rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) { return -1; } -#endif // USE_PEDANTIC_WRITE +#endif /* USE_PEDANTIC_WRITE */ if (name == NULL) { PyErr_SetString(PyExc_AttributeError, "bpy_struct: __setattr__ must be a string"); @@ -3829,7 +3827,7 @@ static PyObject *pyrna_prop_collection_getattro(BPy_PropertyRNA *self, PyObject #endif } -//--------------- setattr------------------------------------------- +/* --------------- setattr------------------------------------------- */ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pyname, PyObject *value) { const char *name = _PyUnicode_AsString(pyname); @@ -3840,7 +3838,7 @@ static int pyrna_prop_collection_setattro(BPy_PropertyRNA *self, PyObject *pynam if (rna_disallow_writes && rna_id_write_error(&self->ptr, pyname)) { return -1; } -#endif // USE_PEDANTIC_WRITE +#endif /* USE_PEDANTIC_WRITE */ if (name == NULL) { PyErr_SetString(PyExc_AttributeError, "bpy_prop: __setattr__ must be a string"); @@ -4275,7 +4273,7 @@ static int foreach_parse_args(BPy_PropertyRNA *self, PyObject *args, foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed); *size = RNA_raw_type_sizeof(*raw_type); -#if 0 // works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks +#if 0 /* works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks */ if ((*attr_tot) < 1) *attr_tot = 1; @@ -4617,7 +4615,7 @@ static struct PyMethodDef pyrna_prop_collection_methods[] = { static struct PyMethodDef pyrna_prop_collection_idprop_methods[] = { {"add", (PyCFunction)pyrna_prop_collection_idprop_add, METH_NOARGS, NULL}, {"remove", (PyCFunction)pyrna_prop_collection_idprop_remove, METH_O, NULL}, - {"clear", (PyCFunction)pyrna_prop_collection_idprop_clear, METH_NOARGS, NULL}, + {"clear", (PyCFunction)pyrna_prop_collection_idprop_clear, METH_NOARGS, NULL}, {"move", (PyCFunction)pyrna_prop_collection_idprop_move, METH_VARARGS, NULL}, {NULL, NULL, 0, NULL} }; @@ -5564,7 +5562,7 @@ PyTypeObject pyrna_prop_collection_Type = { NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ - NULL, /* subclassed */ /* tp_repr */ + NULL, /* subclassed */ /* tp_repr */ /* Method suites for standard classes */ @@ -5598,7 +5596,7 @@ PyTypeObject pyrna_prop_collection_Type = { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ + NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ #ifdef USE_WEAKREFS @@ -5683,7 +5681,7 @@ static PyTypeObject pyrna_prop_collection_idprop_Type = { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ + NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ #ifdef USE_WEAKREFS @@ -5830,7 +5828,7 @@ PyTypeObject pyrna_prop_collection_iter_Type = { NULL, /* getattrfunc tp_getattr; */ NULL, /* setattrfunc tp_setattr; */ NULL, /* tp_compare */ /* DEPRECATED in python 3.0! */ - NULL, /* subclassed */ /* tp_repr */ + NULL, /* subclassed */ /* tp_repr */ /* Method suites for standard classes */ @@ -5868,7 +5866,7 @@ PyTypeObject pyrna_prop_collection_iter_Type = { /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ - NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ + NULL, /* subclassed */ /* richcmpfunc tp_richcompare; */ /*** weak reference enabler ***/ #ifdef USE_WEAKREFS @@ -6044,8 +6042,8 @@ static PyObject *pyrna_srna_ExternalType(StructRNA *srna) fprintf(stderr, "%s: failed to find 'bpy_types' module\n", __func__); return NULL; } - bpy_types_dict = PyModule_GetDict(bpy_types); // borrow - Py_DECREF(bpy_types); // fairly safe to assume the dict is kept + bpy_types_dict = PyModule_GetDict(bpy_types); /* borrow */ + Py_DECREF(bpy_types); /* fairly safe to assume the dict is kept */ } newclass = PyDict_GetItemString(bpy_types_dict, idname); @@ -6134,7 +6132,7 @@ static PyObject *pyrna_srna_Subtype(StructRNA *srna) /* srna owns one, and the other is owned by the caller */ pyrna_subtype_set_rna(newclass, srna); - // XXX, adding this back segfaults blender on load. + /* XXX, adding this back segfaults blender on load. */ // Py_DECREF(newclass); /* let srna own */ } else { @@ -6291,7 +6289,7 @@ int pyrna_id_FromPyObject(PyObject *obj, ID **id) void BPY_rna_init(void) { -#ifdef USE_MATHUTILS // register mathutils callbacks, ok to run more then once. +#ifdef USE_MATHUTILS /* register mathutils callbacks, ok to run more then once. */ mathutils_rna_array_cb_index = Mathutils_RegisterCallback(&mathutils_rna_array_cb); mathutils_rna_matrix_cb_index = Mathutils_RegisterCallback(&mathutils_rna_matrix_cb); #endif @@ -6375,7 +6373,7 @@ PyObject *BPY_rna_doc(void) /* pyrna_basetype_* - BPy_BaseTypeRNA is just a BPy_PropertyRNA struct with a different type * the self->ptr and self->prop are always set to the "structs" collection */ -//---------------getattr-------------------------------------------- +/* ---------------getattr-------------------------------------------- */ static PyObject *pyrna_basetype_getattro(BPy_BaseTypeRNA *self, PyObject *pyname) { PointerRNA newptr; @@ -6750,7 +6748,7 @@ static int bpy_class_validate_recursive(PointerRNA *dummyptr, StructRNA *srna, v PyObject *base_class = RNA_struct_py_type_get(srna); PyObject *item; int i, flag, arg_count, func_arg_count; - const char *py_class_name = ((PyTypeObject *)py_class)->tp_name; // __name__ + const char *py_class_name = ((PyTypeObject *)py_class)->tp_name; /* __name__ */ if (srna_base) { if (bpy_class_validate_recursive(dummyptr, srna_base, py_data, have_function) != 0) @@ -7211,10 +7209,10 @@ static void bpy_class_free(void *pyob_ptr) gilstate = PyGILState_Ensure(); - // breaks re-registering classes + /* breaks re-registering classes */ // PyDict_Clear(((PyTypeObject *)self)->tp_dict); - // - // remove the rna attribute instead. + + /* remove the rna attribute instead. */ PyDict_DelItem(((PyTypeObject *)self)->tp_dict, bpy_intern_str_bl_rna); if (PyErr_Occurred()) PyErr_Clear(); @@ -7279,7 +7277,7 @@ void pyrna_free_types(void) void *py_ptr = RNA_struct_py_type_get(srna); if (py_ptr) { -#if 0 // XXX - should be able to do this but makes python crash on exit +#if 0 /* XXX - should be able to do this but makes python crash on exit */ bpy_class_free(py_ptr); #endif RNA_struct_py_type_set(srna, NULL); diff --git a/source/blender/python/intern/bpy_rna.h b/source/blender/python/intern/bpy_rna.h index 1fb4b116872..880ef4c2185 100644 --- a/source/blender/python/intern/bpy_rna.h +++ b/source/blender/python/intern/bpy_rna.h @@ -207,6 +207,7 @@ int pyrna_array_contains_py(PointerRNA *ptr, PropertyRNA *prop, PyObject *value) int pyrna_write_check(void); void pyrna_write_set(int val); +void pyrna_invalidate(BPy_DummyPointerRNA *self); int pyrna_struct_validity_check(BPy_StructRNA *pysrna); int pyrna_prop_validity_check(BPy_PropertyRNA *self); diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c index 70815d9f8bf..e66d8f05309 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.c @@ -30,6 +30,8 @@ #include "RNA_types.h" +#include "BLI_utildefines.h" + #include "bpy_rna.h" #include "BKE_global.h" #include "MEM_guardedalloc.h" @@ -664,7 +666,8 @@ PyObject *pyrna_py_from_array_index(BPy_PropertyArrayRNA *self, PointerRNA *ptr, len = RNA_property_multi_array_length(ptr, prop, arraydim); if (index >= len || index < 0) { /* this shouldn't happen because higher level funcs must check for invalid index */ - if (G.debug & G_DEBUG_PYTHON) printf("pyrna_py_from_array_index: invalid index %d for array with length=%d\n", index, len); + if (G.debug & G_DEBUG_PYTHON) + printf("%s: invalid index %d for array with length=%d\n", __func__, index, len); PyErr_SetString(PyExc_IndexError, "out of range"); return NULL; diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index 30b6806a796..b7994eeccdc 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -100,7 +100,7 @@ short BPy_errors_to_report(ReportList *reports) pystring = PyC_ExceptionBuffer(); if (pystring == NULL) { - BKE_report(reports, RPT_ERROR, "Unknown py-exception, couldn't convert"); + BKE_report(reports, RPT_ERROR, "Unknown py-exception, could not convert"); return 0; } @@ -111,15 +111,15 @@ short BPy_errors_to_report(ReportList *reports) cstring = _PyUnicode_AsString(pystring); #if 0 /* ARG!. workaround for a bug in blenders use of vsnprintf */ - BKE_reportf(reports, RPT_ERROR, "%s\nlocation:%s:%d\n", cstring, filename, lineno); + BKE_reportf(reports, RPT_ERROR, "%s\nlocation: %s:%d\n", cstring, filename, lineno); #else - pystring_format = PyUnicode_FromFormat(TIP_("%s\nlocation:%s:%d\n"), cstring, filename, lineno); + pystring_format = PyUnicode_FromFormat(TIP_("%s\nlocation: %s:%d\n"), cstring, filename, lineno); cstring = _PyUnicode_AsString(pystring_format); BKE_report(reports, RPT_ERROR, cstring); #endif /* not exactly needed. just for testing */ - fprintf(stderr, TIP_("%s\nlocation:%s:%d\n"), cstring, filename, lineno); + fprintf(stderr, TIP_("%s\nlocation: %s:%d\n"), cstring, filename, lineno); Py_DECREF(pystring); Py_DECREF(pystring_format); /* workaround */ diff --git a/source/blender/python/mathutils/mathutils.c b/source/blender/python/mathutils/mathutils.c index c08165f9850..a4a4010005a 100644 --- a/source/blender/python/mathutils/mathutils.c +++ b/source/blender/python/mathutils/mathutils.c @@ -276,12 +276,12 @@ int mathutils_any_to_rotmat(float rmat[3][3], PyObject *value, const char *error } -//----------------------------------MATRIX FUNCTIONS-------------------- +/* ----------------------------------MATRIX FUNCTIONS-------------------- */ /* Utility functions */ -// LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon +/* LomontRRDCompare4, Ever Faster Float Comparisons by Randy Dillon */ #define SIGNMASK(i) (-(int)(((unsigned int)(i)) >> 31)) int EXPP_FloatsAreEqual(float af, float bf, int maxDiff) diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index c14b4a0686b..747a23a719d 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -35,8 +35,8 @@ #define COLOR_SIZE 3 -//----------------------------------mathutils.Color() ------------------- -//makes a new color for you to play with +/* ----------------------------------mathutils.Color() ------------------- */ +/* makes a new color for you to play with */ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { float col[3] = {0.0f, 0.0f, 0.0f}; @@ -64,7 +64,7 @@ static PyObject *Color_new(PyTypeObject *type, PyObject *args, PyObject *kwds) return Color_CreatePyObject(col, Py_NEW, type); } -//-----------------------------METHODS---------------------------- +/* -----------------------------METHODS---------------------------- */ /* note: BaseMath_ReadCallback must be called beforehand */ static PyObject *Color_ToTupleExt(ColorObject *self, int ndigits) @@ -113,8 +113,8 @@ static PyObject *Color_deepcopy(ColorObject *self, PyObject *args) return Color_copy(self); } -//----------------------------print object (internal)-------------- -//print the object to screen +/* ----------------------------print object (internal)-------------- */ +/* print the object to screen */ static PyObject *Color_repr(ColorObject *self) { @@ -146,8 +146,8 @@ static PyObject *Color_str(ColorObject *self) return mathutils_dynstr_to_py(ds); /* frees ds */ } -//------------------------tp_richcmpr -//returns -1 exception, 0 false, 1 true +/* ------------------------tp_richcmpr */ +/* returns -1 exception, 0 false, 1 true */ static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op) { PyObject *res; @@ -184,15 +184,15 @@ static PyObject *Color_richcmpr(PyObject *a, PyObject *b, int op) return Py_INCREF(res), res; } -//---------------------SEQUENCE PROTOCOLS------------------------ -//----------------------------len(object)------------------------ -//sequence length +/* ---------------------SEQUENCE PROTOCOLS------------------------ */ +/* ----------------------------len(object)------------------------ */ +/* sequence length */ static int Color_len(ColorObject *UNUSED(self)) { return COLOR_SIZE; } -//----------------------------object[]--------------------------- -//sequence accessor (get) +/* ----------------------------object[]--------------------------- */ +/* sequence accessor (get) */ static PyObject *Color_item(ColorObject *self, int i) { if (i < 0) i = COLOR_SIZE - i; @@ -210,13 +210,13 @@ static PyObject *Color_item(ColorObject *self, int i) return PyFloat_FromDouble(self->col[i]); } -//----------------------------object[]------------------------- -//sequence accessor (set) +/* ----------------------------object[]------------------------- */ +/* sequence accessor (set) */ static int Color_ass_item(ColorObject *self, int i, PyObject *value) { float f = PyFloat_AsDouble(value); - if (f == -1 && PyErr_Occurred()) { // parsed item not a number + if (f == -1 && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "color[item] = x: " "argument not a number"); @@ -238,8 +238,8 @@ static int Color_ass_item(ColorObject *self, int i, PyObject *value) return 0; } -//----------------------------object[z:y]------------------------ -//sequence slice (get) +/* ----------------------------object[z:y]------------------------ */ +/* sequence slice (get) */ static PyObject *Color_slice(ColorObject *self, int begin, int end) { PyObject *tuple; @@ -260,8 +260,8 @@ static PyObject *Color_slice(ColorObject *self, int begin, int end) return tuple; } -//----------------------------object[z:y]------------------------ -//sequence slice (set) +/* ----------------------------object[z:y]------------------------ */ +/* sequence slice (set) */ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq) { int i, size; @@ -361,7 +361,7 @@ static int Color_ass_subscript(ColorObject *self, PyObject *item, PyObject *valu } } -//-----------------PROTCOL DECLARATIONS-------------------------- +/* -----------------PROTCOL DECLARATIONS-------------------------- */ static PySequenceMethods Color_SeqMethods = { (lenfunc) Color_len, /* sq_length */ (binaryfunc) NULL, /* sq_concat */ @@ -792,7 +792,7 @@ static PyGetSetDef Color_getseters[] = { }; -//-----------------------METHOD DEFINITIONS ---------------------- +/* -----------------------METHOD DEFINITIONS ---------------------- */ static struct PyMethodDef Color_methods[] = { {"copy", (PyCFunction) Color_copy, METH_NOARGS, Color_copy_doc}, {"__copy__", (PyCFunction) Color_copy, METH_NOARGS, Color_copy_doc}, @@ -800,60 +800,60 @@ static struct PyMethodDef Color_methods[] = { {NULL, NULL, 0, NULL} }; -//------------------PY_OBECT DEFINITION-------------------------- +/* ------------------PY_OBECT DEFINITION-------------------------- */ PyDoc_STRVAR(color_doc, "This object gives access to Colors in Blender." ); PyTypeObject color_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "Color", //tp_name - sizeof(ColorObject), //tp_basicsize - 0, //tp_itemsize - (destructor)BaseMathObject_dealloc, //tp_dealloc - NULL, //tp_print - NULL, //tp_getattr - NULL, //tp_setattr - NULL, //tp_compare - (reprfunc) Color_repr, //tp_repr - &Color_NumMethods, //tp_as_number - &Color_SeqMethods, //tp_as_sequence - &Color_AsMapping, //tp_as_mapping - NULL, //tp_hash - NULL, //tp_call - (reprfunc) Color_str, //tp_str - NULL, //tp_getattro - NULL, //tp_setattro - NULL, //tp_as_buffer - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags - color_doc, //tp_doc - (traverseproc)BaseMathObject_traverse, //tp_traverse - (inquiry)BaseMathObject_clear, //tp_clear - (richcmpfunc)Color_richcmpr, //tp_richcompare - 0, //tp_weaklistoffset - NULL, //tp_iter - NULL, //tp_iternext - Color_methods, //tp_methods - NULL, //tp_members - Color_getseters, //tp_getset - NULL, //tp_base - NULL, //tp_dict - NULL, //tp_descr_get - NULL, //tp_descr_set - 0, //tp_dictoffset - NULL, //tp_init - NULL, //tp_alloc - Color_new, //tp_new - NULL, //tp_free - NULL, //tp_is_gc - NULL, //tp_bases - NULL, //tp_mro - NULL, //tp_cache - NULL, //tp_subclasses - NULL, //tp_weaklist - NULL //tp_del + "Color", /* tp_name */ + sizeof(ColorObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)BaseMathObject_dealloc, /* tp_dealloc */ + NULL, /* tp_print */ + NULL, /* tp_getattr */ + NULL, /* tp_setattr */ + NULL, /* tp_compare */ + (reprfunc) Color_repr, /* tp_repr */ + &Color_NumMethods, /* tp_as_number */ + &Color_SeqMethods, /* tp_as_sequence */ + &Color_AsMapping, /* tp_as_mapping */ + NULL, /* tp_hash */ + NULL, /* tp_call */ + (reprfunc) Color_str, /* tp_str */ + NULL, /* tp_getattro */ + NULL, /* tp_setattro */ + NULL, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + color_doc, /* tp_doc */ + (traverseproc)BaseMathObject_traverse, /* tp_traverse */ + (inquiry)BaseMathObject_clear, /* tp_clear */ + (richcmpfunc)Color_richcmpr, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + NULL, /* tp_iter */ + NULL, /* tp_iternext */ + Color_methods, /* tp_methods */ + NULL, /* tp_members */ + Color_getseters, /* tp_getset */ + NULL, /* tp_base */ + NULL, /* tp_dict */ + NULL, /* tp_descr_get */ + NULL, /* tp_descr_set */ + 0, /* tp_dictoffset */ + NULL, /* tp_init */ + NULL, /* tp_alloc */ + Color_new, /* tp_new */ + NULL, /* tp_free */ + NULL, /* tp_is_gc */ + NULL, /* tp_bases */ + NULL, /* tp_mro */ + NULL, /* tp_cache */ + NULL, /* tp_subclasses */ + NULL, /* tp_weaklist */ + NULL /* tp_del */ }; -//------------------------Color_CreatePyObject (internal)------------- -//creates a new color object +/* ------------------------Color_CreatePyObject (internal)------------- */ +/* creates a new color object */ /* pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER * (i.e. it was allocated elsewhere by MEM_mallocN()) * pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON diff --git a/source/blender/python/mathutils/mathutils_Color.h b/source/blender/python/mathutils/mathutils_Color.h index d753b60d195..1c75766c2a9 100644 --- a/source/blender/python/mathutils/mathutils_Color.h +++ b/source/blender/python/mathutils/mathutils_Color.h @@ -46,7 +46,7 @@ typedef struct { * be stored in py_data) or be a wrapper for data allocated through * blender (stored in blend_data). This is an either/or struct not both*/ -//prototypes +/* prototypes */ PyObject *Color_CreatePyObject(float col[3], int type, PyTypeObject *base_type); PyObject *Color_CreatePyObject_cb(PyObject *cb_user, unsigned char cb_type, unsigned char cb_subtype); diff --git a/source/blender/python/mathutils/mathutils_Euler.c b/source/blender/python/mathutils/mathutils_Euler.c index 468ef3788c1..3592e1084fb 100644 --- a/source/blender/python/mathutils/mathutils_Euler.c +++ b/source/blender/python/mathutils/mathutils_Euler.c @@ -39,8 +39,8 @@ #define EULER_SIZE 3 -//----------------------------------mathutils.Euler() ------------------- -//makes a new euler for you to play with +/* ----------------------------------mathutils.Euler() ------------------- */ +/* makes a new euler for you to play with */ static PyObject *Euler_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *seq = NULL; @@ -122,8 +122,8 @@ static PyObject *Euler_ToTupleExt(EulerObject *self, int ndigits) return ret; } -//-----------------------------METHODS---------------------------- -//return a quaternion representation of the euler +/* -----------------------------METHODS---------------------------- + * return a quaternion representation of the euler */ PyDoc_STRVAR(Euler_to_quaternion_doc, ".. method:: to_quaternion()\n" @@ -145,7 +145,7 @@ static PyObject *Euler_to_quaternion(EulerObject *self) return Quaternion_CreatePyObject(quat, Py_NEW, NULL); } -//return a matrix representation of the euler +/* return a matrix representation of the euler */ PyDoc_STRVAR(Euler_to_matrix_doc, ".. method:: to_matrix()\n" "\n" @@ -277,8 +277,8 @@ static PyObject *Euler_make_compatible(EulerObject *self, PyObject *value) Py_RETURN_NONE; } -//----------------------------Euler.rotate()----------------------- -// return a copy of the euler +/* ----------------------------Euler.rotate()----------------------- + * return a copy of the euler */ PyDoc_STRVAR(Euler_copy_doc, ".. function:: copy()\n" @@ -305,8 +305,8 @@ static PyObject *Euler_deepcopy(EulerObject *self, PyObject *args) return Euler_copy(self); } -//----------------------------print object (internal)-------------- -//print the object to screen +/* ----------------------------print object (internal)-------------- + * print the object to screen */ static PyObject *Euler_repr(EulerObject *self) { @@ -374,15 +374,15 @@ static PyObject *Euler_richcmpr(PyObject *a, PyObject *b, int op) return Py_INCREF(res), res; } -//---------------------SEQUENCE PROTOCOLS------------------------ -//----------------------------len(object)------------------------ -//sequence length +/* ---------------------SEQUENCE PROTOCOLS------------------------ */ +/* ----------------------------len(object)------------------------ */ +/* sequence length */ static int Euler_len(EulerObject *UNUSED(self)) { return EULER_SIZE; } -//----------------------------object[]--------------------------- -//sequence accessor (get) +/* ----------------------------object[]--------------------------- */ +/* sequence accessor (get) */ static PyObject *Euler_item(EulerObject *self, int i) { if (i < 0) i = EULER_SIZE - i; @@ -400,13 +400,13 @@ static PyObject *Euler_item(EulerObject *self, int i) return PyFloat_FromDouble(self->eul[i]); } -//----------------------------object[]------------------------- -//sequence accessor (set) +/* ----------------------------object[]------------------------- */ +/* sequence accessor (set) */ static int Euler_ass_item(EulerObject *self, int i, PyObject *value) { float f = PyFloat_AsDouble(value); - if (f == -1 && PyErr_Occurred()) { // parsed item not a number + if (f == -1 && PyErr_Occurred()) { /* parsed item not a number */ PyErr_SetString(PyExc_TypeError, "euler[attribute] = x: " "argument not a number"); @@ -429,8 +429,8 @@ static int Euler_ass_item(EulerObject *self, int i, PyObject *value) return 0; } -//----------------------------object[z:y]------------------------ -//sequence slice (get) +/* ----------------------------object[z:y]------------------------ */ +/* sequence slice (get) */ static PyObject *Euler_slice(EulerObject *self, int begin, int end) { PyObject *tuple; @@ -451,8 +451,8 @@ static PyObject *Euler_slice(EulerObject *self, int begin, int end) return tuple; } -//----------------------------object[z:y]------------------------ -//sequence slice (set) +/* ----------------------------object[z:y]------------------------ */ +/* sequence slice (set) */ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq) { int i, size; @@ -553,7 +553,7 @@ static int Euler_ass_subscript(EulerObject *self, PyObject *item, PyObject *valu } } -//-----------------PROTCOL DECLARATIONS-------------------------- +/* -----------------PROTCOL DECLARATIONS-------------------------- */ static PySequenceMethods Euler_SeqMethods = { (lenfunc) Euler_len, /* sq_length */ (binaryfunc) NULL, /* sq_concat */ @@ -629,7 +629,7 @@ static PyGetSetDef Euler_getseters[] = { }; -//-----------------------METHOD DEFINITIONS ---------------------- +/* -----------------------METHOD DEFINITIONS ---------------------- */ static struct PyMethodDef Euler_methods[] = { {"zero", (PyCFunction) Euler_zero, METH_NOARGS, Euler_zero_doc}, {"to_matrix", (PyCFunction) Euler_to_matrix, METH_NOARGS, Euler_to_matrix_doc}, @@ -643,60 +643,60 @@ static struct PyMethodDef Euler_methods[] = { {NULL, NULL, 0, NULL} }; -//------------------PY_OBECT DEFINITION-------------------------- +/* ------------------PY_OBECT DEFINITION-------------------------- */ PyDoc_STRVAR(euler_doc, "This object gives access to Eulers in Blender." ); PyTypeObject euler_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "Euler", //tp_name - sizeof(EulerObject), //tp_basicsize - 0, //tp_itemsize - (destructor)BaseMathObject_dealloc, //tp_dealloc - NULL, //tp_print - NULL, //tp_getattr - NULL, //tp_setattr - NULL, //tp_compare - (reprfunc) Euler_repr, //tp_repr - NULL, //tp_as_number - &Euler_SeqMethods, //tp_as_sequence - &Euler_AsMapping, //tp_as_mapping - NULL, //tp_hash - NULL, //tp_call - (reprfunc) Euler_str, //tp_str - NULL, //tp_getattro - NULL, //tp_setattro - NULL, //tp_as_buffer - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags - euler_doc, //tp_doc - (traverseproc)BaseMathObject_traverse, //tp_traverse - (inquiry)BaseMathObject_clear, //tp_clear - (richcmpfunc)Euler_richcmpr, //tp_richcompare - 0, //tp_weaklistoffset - NULL, //tp_iter - NULL, //tp_iternext - Euler_methods, //tp_methods - NULL, //tp_members - Euler_getseters, //tp_getset - NULL, //tp_base - NULL, //tp_dict - NULL, //tp_descr_get - NULL, //tp_descr_set - 0, //tp_dictoffset - NULL, //tp_init - NULL, //tp_alloc - Euler_new, //tp_new - NULL, //tp_free - NULL, //tp_is_gc - NULL, //tp_bases - NULL, //tp_mro - NULL, //tp_cache - NULL, //tp_subclasses - NULL, //tp_weaklist - NULL //tp_del + "Euler", /* tp_name */ + sizeof(EulerObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)BaseMathObject_dealloc, /* tp_dealloc */ + NULL, /* tp_print */ + NULL, /* tp_getattr */ + NULL, /* tp_setattr */ + NULL, /* tp_compare */ + (reprfunc) Euler_repr, /* tp_repr */ + NULL, /* tp_as_number */ + &Euler_SeqMethods, /* tp_as_sequence */ + &Euler_AsMapping, /* tp_as_mapping */ + NULL, /* tp_hash */ + NULL, /* tp_call */ + (reprfunc) Euler_str, /* tp_str */ + NULL, /* tp_getattro */ + NULL, /* tp_setattro */ + NULL, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + euler_doc, /* tp_doc */ + (traverseproc)BaseMathObject_traverse, /* tp_traverse */ + (inquiry)BaseMathObject_clear, /* tp_clear */ + (richcmpfunc)Euler_richcmpr, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + NULL, /* tp_iter */ + NULL, /* tp_iternext */ + Euler_methods, /* tp_methods */ + NULL, /* tp_members */ + Euler_getseters, /* tp_getset */ + NULL, /* tp_base */ + NULL, /* tp_dict */ + NULL, /* tp_descr_get */ + NULL, /* tp_descr_set */ + 0, /* tp_dictoffset */ + NULL, /* tp_init */ + NULL, /* tp_alloc */ + Euler_new, /* tp_new */ + NULL, /* tp_free */ + NULL, /* tp_is_gc */ + NULL, /* tp_bases */ + NULL, /* tp_mro */ + NULL, /* tp_cache */ + NULL, /* tp_subclasses */ + NULL, /* tp_weaklist */ + NULL /* tp_del */ }; -//------------------------Euler_CreatePyObject (internal)------------- -//creates a new euler object +/* ------------------------Euler_CreatePyObject (internal)------------- */ +/* creates a new euler object */ /* pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER * (i.e. it was allocated elsewhere by MEM_mallocN()) * pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON diff --git a/source/blender/python/mathutils/mathutils_Euler.h b/source/blender/python/mathutils/mathutils_Euler.h index e04d45e4630..69e4c086d03 100644 --- a/source/blender/python/mathutils/mathutils_Euler.h +++ b/source/blender/python/mathutils/mathutils_Euler.h @@ -47,7 +47,7 @@ typedef struct { * be stored in py_data) or be a wrapper for data allocated through * blender (stored in blend_data). This is an either/or struct not both */ -//prototypes +/* prototypes */ PyObject *Euler_CreatePyObject(float *eul, const short order, int type, PyTypeObject *base_type); PyObject *Euler_CreatePyObject_cb(PyObject *cb_user, const short order, unsigned char cb_type, unsigned char cb_subtype); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 9a0a1b3ca95..bb6a75c3346 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -182,7 +182,7 @@ static int mathutils_matrix_col_get(BaseMathObject *bmo, int col) return -1; /* for 'translation' size will always be '3' even on 4x4 vec */ - num_row = MIN2(self->num_row, ((VectorObject *)bmo)->size); + num_row = min_ii(self->num_row, ((VectorObject *)bmo)->size); for (row = 0; row < num_row; row++) { bmo->data[row] = MATRIX_ITEM(self, row, col); @@ -203,7 +203,7 @@ static int mathutils_matrix_col_set(BaseMathObject *bmo, int col) return -1; /* for 'translation' size will always be '3' even on 4x4 vec */ - num_row = MIN2(self->num_row, ((VectorObject *)bmo)->size); + num_row = min_ii(self->num_row, ((VectorObject *)bmo)->size); for (row = 0; row < num_row; row++) { MATRIX_ITEM(self, row, col) = bmo->data[row]; @@ -329,9 +329,9 @@ Mathutils_Callback mathutils_matrix_translation_cb = { /* matrix column callbacks, this is so you can do matrix.translation = Vector() */ -//----------------------------------mathutils.Matrix() ----------------- -//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. -//create a new matrix type +/* ----------------------------------mathutils.Matrix() ----------------- */ +/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */ +/* create a new matrix type */ static PyObject *Matrix_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { if (kwds && PyDict_Size(kwds)) { @@ -410,7 +410,7 @@ static void matrix_3x3_as_4x4(float mat[16]) /*-----------------------CLASS-METHODS----------------------------*/ -//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. +/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */ PyDoc_STRVAR(C_Matrix_Identity_doc, ".. classmethod:: Identity(size)\n" "\n" @@ -518,7 +518,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) const float angle_cos = cosf(angle); const float angle_sin = sinf(angle); - //2D rotation matrix + /* 2D rotation matrix */ mat[0] = angle_cos; mat[1] = angle_sin; mat[2] = -angle_sin; @@ -532,7 +532,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) if (matSize == 4) { matrix_3x3_as_4x4(mat); } - //pass to matrix creation + /* pass to matrix creation */ return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } @@ -556,8 +556,8 @@ static PyObject *C_Matrix_Translation(PyObject *cls, PyObject *value) return Matrix_CreatePyObject(&mat[0][0], 4, 4, Py_NEW, (PyTypeObject *)cls); } -//----------------------------------mathutils.Matrix.Scale() ------------- -//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. +/* ----------------------------------mathutils.Matrix.Scale() ------------- */ +/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */ PyDoc_STRVAR(C_Matrix_Scale_doc, ".. classmethod:: Scale(factor, size, axis)\n" "\n" @@ -601,7 +601,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) return NULL; } } - if (vec == NULL) { //scaling along axis + if (vec == NULL) { /* scaling along axis */ if (matSize == 2) { mat[0] = factor; mat[3] = factor; @@ -645,11 +645,11 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args) if (matSize == 4) { matrix_3x3_as_4x4(mat); } - //pass to matrix creation + /* pass to matrix creation */ return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } -//----------------------------------mathutils.Matrix.OrthoProjection() --- -//mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. +/* ----------------------------------mathutils.Matrix.OrthoProjection() --- */ +/* mat is a 1D array of floats - row[0][0], row[0][1], row[1][0], etc. */ PyDoc_STRVAR(C_Matrix_OrthoProjection_doc, ".. classmethod:: OrthoProjection(axis, size)\n" "\n" @@ -685,7 +685,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) return NULL; } - if (PyUnicode_Check(axis)) { //ortho projection onto cardinal plane + if (PyUnicode_Check(axis)) { /* ortho projection onto cardinal plane */ Py_ssize_t plane_len; const char *plane = _PyUnicode_AsStringAndSize(axis, &plane_len); if (matSize == 2) { @@ -726,7 +726,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) } } else { - //arbitrary plane + /* arbitrary plane */ int vec_size = (matSize == 2 ? 2 : 3); float tvec[4]; @@ -737,7 +737,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) return NULL; } - //normalize arbitrary axis + /* normalize arbitrary axis */ for (x = 0; x < vec_size; x++) { norm += tvec[x] * tvec[x]; } @@ -766,7 +766,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args) if (matSize == 4) { matrix_3x3_as_4x4(mat); } - //pass to matrix creation + /* pass to matrix creation */ return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } @@ -869,7 +869,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args) if (matSize == 4) { matrix_3x3_as_4x4(mat); } - //pass to matrix creation + /* pass to matrix creation */ return Matrix_CreatePyObject(mat, matSize, matSize, Py_NEW, (PyTypeObject *)cls); } @@ -1579,7 +1579,7 @@ static PyObject *Matrix_str(MatrixObject *self) maxsize[col] = 0; for (row = 0; row < self->num_row; row++) { int size = BLI_snprintf(dummy_buf, sizeof(dummy_buf), "%.4f", MATRIX_ITEM(self, row, col)); - maxsize[col] = MAX2(maxsize[col], size); + maxsize[col] = max_ii(maxsize[col], size); } } @@ -2335,8 +2335,8 @@ PyTypeObject matrix_Type = { NULL, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ matrix_doc, /*tp_doc*/ - (traverseproc)BaseMathObject_traverse, //tp_traverse - (inquiry)BaseMathObject_clear, //tp_clear + (traverseproc)BaseMathObject_traverse, /* tp_traverse */ + (inquiry)BaseMathObject_clear, /*tp_clear*/ (richcmpfunc)Matrix_richcmpr, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ NULL, /*tp_iter*/ @@ -2635,8 +2635,8 @@ PyTypeObject matrix_access_Type = { NULL, /*tp_as_buffer*/ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /*tp_flags*/ NULL, /*tp_doc*/ - (traverseproc)MatrixAccess_traverse, //tp_traverse - (inquiry)MatrixAccess_clear, //tp_clear + (traverseproc)MatrixAccess_traverse,/*tp_traverse*/ + (inquiry)MatrixAccess_clear, /*tp_clear*/ NULL /* (richcmpfunc)MatrixAccess_richcmpr */ /* TODO*/, /*tp_richcompare*/ 0, /*tp_weaklistoffset*/ (getiterfunc)MatrixAccess_iter, /* getiterfunc tp_iter; */ diff --git a/source/blender/python/mathutils/mathutils_Quaternion.c b/source/blender/python/mathutils/mathutils_Quaternion.c index 2debff68af1..b9aba995973 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.c +++ b/source/blender/python/mathutils/mathutils_Quaternion.c @@ -44,7 +44,7 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle); static PyObject *Quaternion_copy(QuaternionObject *self); static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args); -//-----------------------------METHODS------------------------------ +/* -----------------------------METHODS------------------------------ */ /* note: BaseMath_ReadCallback must be called beforehand */ static PyObject *Quaternion_to_tuple_ext(QuaternionObject *self, int ndigits) @@ -124,7 +124,7 @@ static PyObject *Quaternion_to_euler(QuaternionObject *self, PyObject *args) return Euler_CreatePyObject(eul, order, Py_NEW, NULL); } -//----------------------------Quaternion.toMatrix()------------------ + PyDoc_STRVAR(Quaternion_to_matrix_doc, ".. method:: to_matrix()\n" "\n" @@ -144,7 +144,6 @@ static PyObject *Quaternion_to_matrix(QuaternionObject *self) return Matrix_CreatePyObject(mat, 3, 3, Py_NEW, NULL); } -//----------------------------Quaternion.toMatrix()------------------ PyDoc_STRVAR(Quaternion_to_axis_angle_doc, ".. method:: to_axis_angle()\n" "\n" @@ -176,8 +175,6 @@ static PyObject *Quaternion_to_axis_angle(QuaternionObject *self) return ret; } - -//----------------------------Quaternion.cross(other)------------------ PyDoc_STRVAR(Quaternion_cross_doc, ".. method:: cross(other)\n" "\n" @@ -205,7 +202,6 @@ static PyObject *Quaternion_cross(QuaternionObject *self, PyObject *value) return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(self)); } -//----------------------------Quaternion.dot(other)------------------ PyDoc_STRVAR(Quaternion_dot_doc, ".. method:: dot(other)\n" "\n" @@ -335,8 +331,8 @@ static PyObject *Quaternion_rotate(QuaternionObject *self, PyObject *value) Py_RETURN_NONE; } -//----------------------------Quaternion.normalize()---------------- -//normalize the axis of rotation of [theta, vector] +/* ----------------------------Quaternion.normalize()---------------- */ +/* normalize the axis of rotation of [theta, vector] */ PyDoc_STRVAR(Quaternion_normalize_doc, ".. function:: normalize()\n" "\n" @@ -365,7 +361,6 @@ static PyObject *Quaternion_normalized(QuaternionObject *self) return quat__apply_to_copy((PyNoArgsFunction)Quaternion_normalize, self); } -//----------------------------Quaternion.invert()------------------ PyDoc_STRVAR(Quaternion_invert_doc, ".. function:: invert()\n" "\n" @@ -394,7 +389,6 @@ static PyObject *Quaternion_inverted(QuaternionObject *self) return quat__apply_to_copy((PyNoArgsFunction)Quaternion_invert, self); } -//----------------------------Quaternion.identity()----------------- PyDoc_STRVAR(Quaternion_identity_doc, ".. function:: identity()\n" "\n" @@ -413,7 +407,7 @@ static PyObject *Quaternion_identity(QuaternionObject *self) (void)BaseMath_WriteCallback(self); Py_RETURN_NONE; } -//----------------------------Quaternion.negate()------------------- + PyDoc_STRVAR(Quaternion_negate_doc, ".. function:: negate()\n" "\n" @@ -432,7 +426,7 @@ static PyObject *Quaternion_negate(QuaternionObject *self) (void)BaseMath_WriteCallback(self); Py_RETURN_NONE; } -//----------------------------Quaternion.conjugate()---------------- + PyDoc_STRVAR(Quaternion_conjugate_doc, ".. function:: conjugate()\n" "\n" @@ -461,7 +455,6 @@ static PyObject *Quaternion_conjugated(QuaternionObject *self) return quat__apply_to_copy((PyNoArgsFunction)Quaternion_conjugate, self); } -//----------------------------Quaternion.copy()---------------- PyDoc_STRVAR(Quaternion_copy_doc, ".. function:: copy()\n" "\n" @@ -487,8 +480,7 @@ static PyObject *Quaternion_deepcopy(QuaternionObject *self, PyObject *args) return Quaternion_copy(self); } -//----------------------------print object (internal)-------------- -//print the object to screen +/* print the object to screen */ static PyObject *Quaternion_repr(QuaternionObject *self) { PyObject *ret, *tuple; @@ -555,15 +547,15 @@ static PyObject *Quaternion_richcmpr(PyObject *a, PyObject *b, int op) return Py_INCREF(res), res; } -//---------------------SEQUENCE PROTOCOLS------------------------ -//----------------------------len(object)------------------------ -//sequence length +/* ---------------------SEQUENCE PROTOCOLS------------------------ */ +/* ----------------------------len(object)------------------------ */ +/* sequence length */ static int Quaternion_len(QuaternionObject *UNUSED(self)) { return QUAT_SIZE; } -//----------------------------object[]--------------------------- -//sequence accessor (get) +/* ----------------------------object[]--------------------------- */ +/* sequence accessor (get) */ static PyObject *Quaternion_item(QuaternionObject *self, int i) { if (i < 0) i = QUAT_SIZE - i; @@ -581,8 +573,8 @@ static PyObject *Quaternion_item(QuaternionObject *self, int i) return PyFloat_FromDouble(self->quat[i]); } -//----------------------------object[]------------------------- -//sequence accessor (set) +/* ----------------------------object[]------------------------- */ +/* sequence accessor (set) */ static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob) { float scalar = (float)PyFloat_AsDouble(ob); @@ -608,8 +600,8 @@ static int Quaternion_ass_item(QuaternionObject *self, int i, PyObject *ob) return 0; } -//----------------------------object[z:y]------------------------ -//sequence slice (get) +/* ----------------------------object[z:y]------------------------ */ +/* sequence slice (get) */ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end) { PyObject *tuple; @@ -630,8 +622,8 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end) return tuple; } -//----------------------------object[z:y]------------------------ -//sequence slice (set) +/* ----------------------------object[z:y]------------------------ */ +/* sequence slice (set) */ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyObject *seq) { int i, size; @@ -734,9 +726,9 @@ static int Quaternion_ass_subscript(QuaternionObject *self, PyObject *item, PyOb } } -//------------------------NUMERIC PROTOCOLS---------------------- -//------------------------obj + obj------------------------------ -//addition +/* ------------------------NUMERIC PROTOCOLS---------------------- */ +/* ------------------------obj + obj------------------------------ */ +/* addition */ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2) { float quat[QUAT_SIZE]; @@ -758,8 +750,8 @@ static PyObject *Quaternion_add(PyObject *q1, PyObject *q2) add_qt_qtqt(quat, quat1->quat, quat2->quat, 1.0f); return Quaternion_CreatePyObject(quat, Py_NEW, Py_TYPE(q1)); } -//------------------------obj - obj------------------------------ -//subtraction +/* ------------------------obj - obj------------------------------ */ +/* subtraction */ static PyObject *Quaternion_sub(PyObject *q1, PyObject *q2) { int x; @@ -875,7 +867,7 @@ static PyObject *Quaternion_neg(QuaternionObject *self) } -//-----------------PROTOCOL DECLARATIONS-------------------------- +/* -----------------PROTOCOL DECLARATIONS-------------------------- */ static PySequenceMethods Quaternion_SeqMethods = { (lenfunc) Quaternion_len, /* sq_length */ (binaryfunc) NULL, /* sq_concat */ @@ -1060,7 +1052,7 @@ static int Quaternion_axis_vector_set(QuaternionObject *self, PyObject *value, v return 0; } -//----------------------------------mathutils.Quaternion() -------------- +/* ----------------------------------mathutils.Quaternion() -------------- */ static PyObject *Quaternion_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { PyObject *seq = NULL; @@ -1140,7 +1132,7 @@ static void quat__axis_angle_sanitize(float axis[3], float *angle) } } -//-----------------------METHOD DEFINITIONS ---------------------- +/* -----------------------METHOD DEFINITIONS ---------------------- */ static struct PyMethodDef Quaternion_methods[] = { /* in place only */ {"identity", (PyCFunction) Quaternion_identity, METH_NOARGS, Quaternion_identity_doc}, @@ -1190,60 +1182,60 @@ static PyGetSetDef Quaternion_getseters[] = { {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ }; -//------------------PY_OBECT DEFINITION-------------------------- +/* ------------------PY_OBECT DEFINITION-------------------------- */ PyDoc_STRVAR(quaternion_doc, "This object gives access to Quaternions in Blender." ); PyTypeObject quaternion_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "Quaternion", //tp_name - sizeof(QuaternionObject), //tp_basicsize - 0, //tp_itemsize - (destructor)BaseMathObject_dealloc, //tp_dealloc - NULL, //tp_print - NULL, //tp_getattr - NULL, //tp_setattr - NULL, //tp_compare - (reprfunc) Quaternion_repr, //tp_repr - &Quaternion_NumMethods, //tp_as_number - &Quaternion_SeqMethods, //tp_as_sequence - &Quaternion_AsMapping, //tp_as_mapping - NULL, //tp_hash - NULL, //tp_call - (reprfunc) Quaternion_str, //tp_str - NULL, //tp_getattro - NULL, //tp_setattro - NULL, //tp_as_buffer - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, //tp_flags - quaternion_doc, //tp_doc - (traverseproc)BaseMathObject_traverse, //tp_traverse - (inquiry)BaseMathObject_clear, //tp_clear - (richcmpfunc)Quaternion_richcmpr, //tp_richcompare - 0, //tp_weaklistoffset - NULL, //tp_iter - NULL, //tp_iternext - Quaternion_methods, //tp_methods - NULL, //tp_members - Quaternion_getseters, //tp_getset - NULL, //tp_base - NULL, //tp_dict - NULL, //tp_descr_get - NULL, //tp_descr_set - 0, //tp_dictoffset - NULL, //tp_init - NULL, //tp_alloc - Quaternion_new, //tp_new - NULL, //tp_free - NULL, //tp_is_gc - NULL, //tp_bases - NULL, //tp_mro - NULL, //tp_cache - NULL, //tp_subclasses - NULL, //tp_weaklist - NULL, //tp_del + "Quaternion", /* tp_name */ + sizeof(QuaternionObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + (destructor)BaseMathObject_dealloc, /* tp_dealloc */ + NULL, /* tp_print */ + NULL, /* tp_getattr */ + NULL, /* tp_setattr */ + NULL, /* tp_compare */ + (reprfunc) Quaternion_repr, /* tp_repr */ + &Quaternion_NumMethods, /* tp_as_number */ + &Quaternion_SeqMethods, /* tp_as_sequence */ + &Quaternion_AsMapping, /* tp_as_mapping */ + NULL, /* tp_hash */ + NULL, /* tp_call */ + (reprfunc) Quaternion_str, /* tp_str */ + NULL, /* tp_getattro */ + NULL, /* tp_setattro */ + NULL, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + quaternion_doc, /* tp_doc */ + (traverseproc)BaseMathObject_traverse, /* tp_traverse */ + (inquiry)BaseMathObject_clear, /* tp_clear */ + (richcmpfunc)Quaternion_richcmpr, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + NULL, /* tp_iter */ + NULL, /* tp_iternext */ + Quaternion_methods, /* tp_methods */ + NULL, /* tp_members */ + Quaternion_getseters, /* tp_getset */ + NULL, /* tp_base */ + NULL, /* tp_dict */ + NULL, /* tp_descr_get */ + NULL, /* tp_descr_set */ + 0, /* tp_dictoffset */ + NULL, /* tp_init */ + NULL, /* tp_alloc */ + Quaternion_new, /* tp_new */ + NULL, /* tp_free */ + NULL, /* tp_is_gc */ + NULL, /* tp_bases */ + NULL, /* tp_mro */ + NULL, /* tp_cache */ + NULL, /* tp_subclasses */ + NULL, /* tp_weaklist */ + NULL, /* tp_del */ }; -//------------------------Quaternion_CreatePyObject (internal)------------- -//creates a new quaternion object +/* ------------------------Quaternion_CreatePyObject (internal)------------- */ +/* creates a new quaternion object */ /*pass Py_WRAP - if vector is a WRAPPER for data allocated by BLENDER * (i.e. it was allocated elsewhere by MEM_mallocN()) * pass Py_NEW - if vector is not a WRAPPER and managed by PYTHON @@ -1266,7 +1258,7 @@ PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_ty } else if (type == Py_NEW) { self->quat = PyMem_Malloc(QUAT_SIZE * sizeof(float)); - if (!quat) { //new empty + if (!quat) { /* new empty */ unit_qt(self->quat); } else { diff --git a/source/blender/python/mathutils/mathutils_Quaternion.h b/source/blender/python/mathutils/mathutils_Quaternion.h index 4ffe8488843..b88715096bf 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.h +++ b/source/blender/python/mathutils/mathutils_Quaternion.h @@ -44,7 +44,7 @@ typedef struct { * be stored in py_data) or be a wrapper for data allocated through * blender (stored in blend_data). This is an either/or struct not both */ -//prototypes +/* prototypes */ PyObject *Quaternion_CreatePyObject(float *quat, int type, PyTypeObject *base_type); PyObject *Quaternion_CreatePyObject_cb(PyObject *cb_user, unsigned char cb_type, unsigned char cb_subtype); diff --git a/source/blender/python/mathutils/mathutils_Vector.c b/source/blender/python/mathutils/mathutils_Vector.c index d461486d485..4a6891c41b9 100644 --- a/source/blender/python/mathutils/mathutils_Vector.c +++ b/source/blender/python/mathutils/mathutils_Vector.c @@ -1100,12 +1100,12 @@ static PyObject *Vector_project(VectorObject *self, PyObject *value) if (BaseMath_ReadCallback(self) == -1) return NULL; - //get dot products + /* get dot products */ for (x = 0; x < size; x++) { dot += (double)(self->vec[x] * tvec[x]); dot2 += (double)(tvec[x] * tvec[x]); } - //projection + /* projection */ dot /= dot2; for (x = 0; x < size; x++) { vec[x] = (float)dot * tvec[x]; @@ -2709,7 +2709,7 @@ static int row_vector_multiplication(float r_vec[MAX_DIMENSIONS], VectorObject * memcpy(vec_cpy, vec->vec, vec_size * sizeof(float)); r_vec[3] = 1.0f; - //muliplication + /* muliplication */ for (col = 0; col < mat->num_col; col++) { double dot = 0.0; for (row = 0; row < mat->num_row; row++) { @@ -2733,7 +2733,7 @@ static PyObject *Vector_negate(VectorObject *self) negate_vn(self->vec, self->size); - (void)BaseMath_WriteCallback(self); // already checked for error + (void)BaseMath_WriteCallback(self); /* already checked for error */ Py_RETURN_NONE; } @@ -2829,10 +2829,10 @@ PyTypeObject vector_Type = { /*** Assigned meaning in release 2.0 ***/ /* call function for all accessible objects */ - (traverseproc)BaseMathObject_traverse, //tp_traverse + (traverseproc)BaseMathObject_traverse, /* tp_traverse */ /* delete references to contained objects */ - (inquiry)BaseMathObject_clear, //tp_clear + (inquiry)BaseMathObject_clear, /* tp_clear */ /*** Assigned meaning in release 2.1 ***/ /*** rich comparisons ***/ diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 818f30ec284..22317636faa 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -51,7 +51,7 @@ PyDoc_STRVAR(M_Geometry_doc, "The Blender geometry module" ); -//---------------------------------INTERSECTION FUNCTIONS-------------------- +/* ---------------------------------INTERSECTION FUNCTIONS-------------------- */ PyDoc_STRVAR(M_Geometry_intersect_ray_tri_doc, ".. function:: intersect_ray_tri(v1, v2, v3, ray, orig, clip=True)\n" @@ -251,10 +251,6 @@ static PyObject *M_Geometry_intersect_line_line(PyObject *UNUSED(self), PyObject } } - - - -//----------------------------geometry.normal() ------------------- PyDoc_STRVAR(M_Geometry_normal_doc, ".. function:: normal(v1, v2, v3, v4=None)\n" "\n" @@ -338,7 +334,7 @@ static PyObject *M_Geometry_normal(PyObject *UNUSED(self), PyObject *args) return Vector_CreatePyObject(n, 3, Py_NEW, NULL); } -//--------------------------------- AREA FUNCTIONS-------------------- +/* --------------------------------- AREA FUNCTIONS-------------------- */ PyDoc_STRVAR(M_Geometry_area_tri_doc, ".. function:: area_tri(v1, v2, v3)\n" diff --git a/source/blender/quicktime/apple/qtkit_export.m b/source/blender/quicktime/apple/qtkit_export.m index bb87fe21c49..bf37faa07ff 100644 --- a/source/blender/quicktime/apple/qtkit_export.m +++ b/source/blender/quicktime/apple/qtkit_export.m @@ -143,7 +143,7 @@ QuicktimeCodecTypeDesc* quicktime_get_videocodecType_desc(int indexValue) int quicktime_rnatmpvalue_from_videocodectype(int codecType) { int i; - for (i=0;i<qtVideoCodecCount;i++) { + for (i = 0; i < qtVideoCodecCount; i++) { if (qtVideoCodecList[i].codecType == codecType) return qtVideoCodecList[i].rnatmpvalue; } @@ -154,12 +154,12 @@ int quicktime_rnatmpvalue_from_videocodectype(int codecType) int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue) { int i; - for (i=0;i<qtVideoCodecCount;i++) { + for (i = 0; i < qtVideoCodecCount; i++) { if (qtVideoCodecList[i].rnatmpvalue == rnatmpvalue) return qtVideoCodecList[i].codecType; } - return 0; + return 0; } /* Audio codec */ @@ -188,7 +188,7 @@ QuicktimeCodecTypeDesc* quicktime_get_audiocodecType_desc(int indexValue) int quicktime_rnatmpvalue_from_audiocodectype(int codecType) { int i; - for (i=0;i<qtAudioCodecCount;i++) { + for (i = 0; i < qtAudioCodecCount; i++) { if (qtAudioCodecList[i].codecType == codecType) return qtAudioCodecList[i].rnatmpvalue; } @@ -199,12 +199,12 @@ int quicktime_rnatmpvalue_from_audiocodectype(int codecType) int quicktime_audiocodecType_from_rnatmpvalue(int rnatmpvalue) { int i; - for (i=0;i<qtAudioCodecCount;i++) { + for (i = 0; i < qtAudioCodecCount; i++) { if (qtAudioCodecList[i].rnatmpvalue == rnatmpvalue) return qtAudioCodecList[i].codecType; } - return 0; + return 0; } @@ -212,7 +212,7 @@ static NSString *stringWithCodecType(int codecType) { char str[5]; - *((int*)str) = EndianU32_NtoB(codecType); + *((int *)str) = EndianU32_NtoB(codecType); str[4] = 0; return [NSString stringWithCString:str encoding:NSASCIIStringEncoding]; @@ -235,7 +235,7 @@ void makeqtstring (RenderData *rd, char *string) void filepath_qt(char *string, RenderData *rd) { - if (string==NULL) return; + if (string == NULL) return; strcpy(string, rd->pic); BLI_path_abs(string, G.main->name); @@ -313,8 +313,8 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSError *error; char name[1024]; - int success= 1; - OSStatus err=noErr; + int success = 1; + OSStatus err = noErr; if(qtexport == NULL) qtexport = MEM_callocN(sizeof(QuicktimeExport), "QuicktimeExport"); @@ -323,7 +323,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R /* Check first if the QuickTime 7.2.1 initToWritableFile: method is available */ if ([[[[QTMovie alloc] init] autorelease] respondsToSelector:@selector(initToWritableFile:error:)] != YES) { BKE_report(reports, RPT_ERROR, "\nUnable to create quicktime movie, need Quicktime rev 7.2.1 or later"); - success= 0; + success = 0; } else { makeqtstring(rd, name); @@ -543,7 +543,7 @@ int start_qt(struct Scene *scene, struct RenderData *rd, int rectx, int recty, R if(qtexport->movie == nil) { BKE_report(reports, RPT_ERROR, "Unable to create quicktime movie."); - success= 0; + success = 0; if (qtexport->filename) [qtexport->filename release]; qtexport->filename = nil; if (qtexport->audioFileName) [qtexport->audioFileName release]; @@ -624,8 +624,8 @@ int append_qt(struct RenderData *rd, int start_frame, int frame, int *pixels, in return 0; } - from_Ptr = (unsigned char*)pixels; - to_Ptr = (unsigned char*)[blBitmapFormatImage bitmapData]; + from_Ptr = (unsigned char *)pixels; + to_Ptr = (unsigned char *)[blBitmapFormatImage bitmapData]; for (y = 0; y < recty; y++) { to_i = (recty-y-1)*rectx; from_i = y*rectx; @@ -647,7 +647,7 @@ int append_qt(struct RenderData *rd, int start_frame, int frame, int *pixels, in if (qtexport->audioFile) { UInt32 audioPacketsConverted; /* Append audio */ - while (qtexport->audioTotalExportedFrames < qtexport->audioLastFrame) { + while (qtexport->audioTotalExportedFrames < qtexport->audioLastFrame) { qtexport->audioBufferList.mNumberBuffers = 1; qtexport->audioBufferList.mBuffers[0].mNumberChannels = qtexport->audioOutputFormat.mChannelsPerFrame; @@ -683,7 +683,7 @@ int append_qt(struct RenderData *rd, int start_frame, int frame, int *pixels, in } } - [pool drain]; + [pool drain]; return 1; } diff --git a/source/blender/quicktime/apple/qtkit_import.m b/source/blender/quicktime/apple/qtkit_import.m index 75b9056de1b..d7c8889b44a 100644 --- a/source/blender/quicktime/apple/qtkit_import.m +++ b/source/blender/quicktime/apple/qtkit_import.m @@ -102,7 +102,7 @@ int anim_is_quicktime (const char *name) pool = [[NSAutoreleasePool alloc] init]; if([QTMovie canInitWithFile:[NSString stringWithCString:name - encoding:[NSString defaultCStringEncoding]]]) + encoding:[NSString defaultCStringEncoding]]]) { [pool drain]; return true; @@ -147,7 +147,7 @@ static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height) uchar *toIBuf = NULL; int x, y, to_i, from_i; NSSize bitmapSize; - NSBitmapImageRep *blBitmapFormatImageRGB,*blBitmapFormatImageRGBA,*bitmapImage=nil; + NSBitmapImageRep *blBitmapFormatImageRGB,*blBitmapFormatImageRGBA, *bitmapImage = nil; NSEnumerator *enumerator; NSImageRep *representation; @@ -162,18 +162,18 @@ static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height) /*Get the bitmap of the image*/ enumerator = [[sourceImage representations] objectEnumerator]; while ((representation = [enumerator nextObject])) { - if ([representation isKindOfClass:[NSBitmapImageRep class]]) { - bitmapImage = (NSBitmapImageRep *)representation; + if ([representation isKindOfClass:[NSBitmapImageRep class]]) { + bitmapImage = (NSBitmapImageRep *)representation; break; - } - } + } + } if (bitmapImage == nil) return NULL; if (([bitmapImage bitsPerPixel] == 32) && (([bitmapImage bitmapFormat] & 0x5) == 0) && ![bitmapImage isPlanar]) { /* Try a fast copy if the image is a meshed RGBA 32bit bitmap*/ - toIBuf = (uchar*)ibuf->rect; - rasterRGB = (uchar*)[bitmapImage bitmapData]; + toIBuf = (uchar *)ibuf->rect; + rasterRGB = (uchar *)[bitmapImage bitmapData]; for (y = 0; y < height; y++) { to_i = (height-y-1)*width; from_i = y*width; @@ -207,7 +207,7 @@ static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height) [bitmapImage draw]; [NSGraphicsContext restoreGraphicsState]; - rasterRGB = (uchar*)[blBitmapFormatImageRGB bitmapData]; + rasterRGB = (uchar *)[blBitmapFormatImageRGB bitmapData]; if (rasterRGB == NULL) { [blBitmapFormatImageRGB release]; return NULL; @@ -228,7 +228,7 @@ static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height) [bitmapImage draw]; [NSGraphicsContext restoreGraphicsState]; - rasterRGBA = (uchar*)[blBitmapFormatImageRGBA bitmapData]; + rasterRGBA = (uchar *)[blBitmapFormatImageRGBA bitmapData]; if (rasterRGBA == NULL) { [blBitmapFormatImageRGB release]; [blBitmapFormatImageRGBA release]; @@ -236,7 +236,7 @@ static ImBuf * nsImageToiBuf(NSImage *sourceImage, int width, int height) } /*Copy the image to ibuf, flipping it vertically*/ - toIBuf = (uchar*)ibuf->rect; + toIBuf = (uchar *)ibuf->rect; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { to_i = (height-y-1)*width + x; @@ -312,7 +312,7 @@ int startquicktime (struct anim *anim) pool = [[NSAutoreleasePool alloc] init]; - [QTMovie enterQTKitOnThread]; + [QTMovie enterQTKitOnThread]; attributes = [NSDictionary dictionaryWithObjectsAndKeys: [NSString stringWithCString:anim->name @@ -382,7 +382,7 @@ int startquicktime (struct anim *anim) anim->curposition = 0; [pool drain]; - + return 0; } @@ -486,7 +486,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags) [bitmapImage draw]; [NSGraphicsContext restoreGraphicsState]; - rasterRGB = (uchar*)[blBitmapFormatImageRGB bitmapData]; + rasterRGB = (uchar *)[blBitmapFormatImageRGB bitmapData]; if (rasterRGB == NULL) { [bitmapImage release]; [blBitmapFormatImageRGB release]; @@ -509,7 +509,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags) [bitmapImage draw]; [NSGraphicsContext restoreGraphicsState]; - rasterRGBA = (uchar*)[blBitmapFormatImageRGBA bitmapData]; + rasterRGBA = (uchar *)[blBitmapFormatImageRGBA bitmapData]; if (rasterRGBA == NULL) { [bitmapImage release]; [blBitmapFormatImageRGB release]; @@ -519,7 +519,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags) } /*Copy the image to ibuf, flipping it vertically*/ - toIBuf = (uchar*)ibuf->rect; + toIBuf = (uchar *)ibuf->rect; for (x = 0; x < bitmapSize.width; x++) { for (y = 0; y < bitmapSize.height; y++) { to_i = (bitmapSize.height-y-1)*bitmapSize.width + x; @@ -543,7 +543,7 @@ ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags) if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf); /* return successfully */ - return (ibuf); + return (ibuf); } diff --git a/source/blender/quicktime/apple/quicktime_export.c b/source/blender/quicktime/apple/quicktime_export.c index 1d5838e9905..1c4ab5a4b0e 100644 --- a/source/blender/quicktime/apple/quicktime_export.c +++ b/source/blender/quicktime/apple/quicktime_export.c @@ -105,8 +105,8 @@ typedef struct QuicktimeExport { PixMapHandle thePixMap; ImageDescription **anImageDescription; - ImBuf *ibuf; //imagedata for Quicktime's Gworld - ImBuf *ibuf2; //copy of renderdata, to be Y-flipped + ImBuf *ibuf; /* imagedata for Quicktime's Gworld */ + ImBuf *ibuf2; /* copy of renderdata, to be Y-flipped */ } QuicktimeExport; @@ -178,7 +178,7 @@ int quicktime_videocodecType_from_rnatmpvalue(int rnatmpvalue) return qtVideoCodecList[i].codecType; } - return 0; + return 0; } @@ -278,9 +278,9 @@ static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports) SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); - //Fill the render QuicktimeCodecSettigns struct + /* Fill the render QuicktimeCodecSettigns struct */ rd->qtcodecsettings.codecTemporalQuality = (qtdata->gTemporalSettings.temporalQuality * 100) / codecLosslessQuality; - //Do not override scene frame rate (qtdata->gTemporalSettings.framerate) + /* Do not override scene frame rate (qtdata->gTemporalSettings.framerate) */ rd->qtcodecsettings.keyFrameRate = qtdata->gTemporalSettings.keyFrameRate; rd->qtcodecsettings.codecType = qtdata->gSpatialSettings.codecType; @@ -291,7 +291,7 @@ static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports) rd->qtcodecsettings.bitRate = qtdata->aDataRateSetting.dataRate; rd->qtcodecsettings.minSpatialQuality = (qtdata->aDataRateSetting.minSpatialQuality * 100) / codecLosslessQuality; rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality; - //Frame duration is already known (qtdata->aDataRateSetting.frameDuration) + /* Frame duration is already known (qtdata->aDataRateSetting.frameDuration) */ } else { @@ -443,18 +443,18 @@ static void QT_DoAddVideoSamplesToMedia(int frame, int *pixels, int rectx, int r Ptr myPtr; - //copy and flip renderdata + /* copy and flip renderdata */ memcpy(qtexport->ibuf2->rect, pixels, 4 * rectx * recty); IMB_flipy(qtexport->ibuf2); - //get pointers to parse bitmapdata + /* get pointers to parse bitmapdata */ myPtr = GetPixBaseAddr(qtexport->thePixMap); imageRect = (**qtexport->thePixMap).bounds; from = (unsigned char *) qtexport->ibuf2->rect; to = (unsigned char *) myPtr; - //parse RGBA bitmap into Quicktime's ARGB GWorld + /* parse RGBA bitmap into Quicktime's ARGB GWorld */ boxsize = rectx * recty; for (index = 0; index < boxsize; index++) { to[0] = from[3]; @@ -684,15 +684,15 @@ static void check_renderbutton_framerate(RenderData *rd, ReportList *reports) err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); CheckError(err, "SCSetInfo error", reports); - if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps + if (qtdata->gTemporalSettings.frameRate == 1571553) { /* 23.98 fps */ qtdata->kVideoTimeScale = 24000; qtdata->duration = 1001; } - else if (qtdata->gTemporalSettings.frameRate == 1964113) { // 29.97 fps + else if (qtdata->gTemporalSettings.frameRate == 1964113) { /* 29.97 fps */ qtdata->kVideoTimeScale = 30000; qtdata->duration = 1001; } - else if (qtdata->gTemporalSettings.frameRate == 3928227) { // 59.94 fps + else if (qtdata->gTemporalSettings.frameRate == 3928227) { /* 59.94 fps */ qtdata->kVideoTimeScale = 60000; qtdata->duration = 1001; } @@ -714,7 +714,7 @@ void quicktime_verify_image_type(RenderData *rd, ImageFormatData *imf) rd->qtcodecsettings.codecSpatialQuality = (codecHighQuality * 100) / codecLosslessQuality; rd->qtcodecsettings.codecTemporalQuality = (codecHighQuality * 100) / codecLosslessQuality; rd->qtcodecsettings.keyFrameRate = 25; - rd->qtcodecsettings.bitRate = 5000000; //5 Mbps + rd->qtcodecsettings.bitRate = 5000000; /* 5 Mbps */ } } } @@ -804,7 +804,7 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) qtdata->aDataRateSetting.minSpatialQuality = (rd->qtcodecsettings.minSpatialQuality * codecLosslessQuality) / 100; qtdata->aDataRateSetting.minTemporalQuality = (rd->qtcodecsettings.minTemporalQuality * codecLosslessQuality) / 100; - qtdata->aDataRateSetting.frameDuration = rd->frs_sec; + qtdata->aDataRateSetting.frameDuration = rd->frs_sec; err = SCSetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); CheckError(err, "SCSetInfo1 error", op->reports); @@ -826,9 +826,9 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); - //Fill the render QuicktimeCodecSettings struct + /* Fill the render QuicktimeCodecSettings struct */ rd->qtcodecsettings.codecTemporalQuality = (qtdata->gTemporalSettings.temporalQuality * 100) / codecLosslessQuality; - //Do not override scene frame rate (qtdata->gTemporalSettings.framerate) + /* Do not override scene frame rate (qtdata->gTemporalSettings.framerate) */ rd->qtcodecsettings.keyFrameRate = qtdata->gTemporalSettings.keyFrameRate; rd->qtcodecsettings.codecType = qtdata->gSpatialSettings.codecType; @@ -839,26 +839,26 @@ static int request_qtcodec_settings(bContext *C, wmOperator *op) rd->qtcodecsettings.bitRate = qtdata->aDataRateSetting.dataRate; rd->qtcodecsettings.minSpatialQuality = (qtdata->aDataRateSetting.minSpatialQuality * 100) / codecLosslessQuality; rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality; - //Frame duration is already known (qtdata->aDataRateSetting.frameDuration) + /* Frame duration is already known (qtdata->aDataRateSetting.frameDuration) */ QT_SaveCodecSettingsToScene(rd, op->reports); /* framerate jugglin' */ - if (qtdata->gTemporalSettings.frameRate == 1571553) { // 23.98 fps + if (qtdata->gTemporalSettings.frameRate == 1571553) { /* 23.98 fps */ qtdata->kVideoTimeScale = 24000; qtdata->duration = 1001; rd->frs_sec = 24; rd->frs_sec_base = 1.001; } - else if (qtdata->gTemporalSettings.frameRate == 1964113) { // 29.97 fps + else if (qtdata->gTemporalSettings.frameRate == 1964113) { /* 29.97 fps */ qtdata->kVideoTimeScale = 30000; qtdata->duration = 1001; rd->frs_sec = 30; rd->frs_sec_base = 1.001; } - else if (qtdata->gTemporalSettings.frameRate == 3928227) { // 59.94 fps + else if (qtdata->gTemporalSettings.frameRate == 3928227) { /* 59.94 fps */ qtdata->kVideoTimeScale = 60000; qtdata->duration = 1001; @@ -891,8 +891,8 @@ static int ED_operator_setqtcodec(bContext *C) } #if defined(__APPLE__) && defined(GHOST_COCOA) -//Need to set up a Cocoa NSAutoReleasePool to avoid memory leak -//And it must be done in an objC file, so use a GHOST_SystemCocoa.mm function for that +/* Need to set up a Cocoa NSAutoReleasePool to avoid memory leak + * And it must be done in an objC file, so use a GHOST_SystemCocoa.mm function for that */ extern int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op); int fromcocoa_request_qtcodec_settings(bContext *C, wmOperator *op) diff --git a/source/blender/quicktime/quicktime_import.h b/source/blender/quicktime/quicktime_import.h index fb068fc2533..8fd016a3d74 100644 --- a/source/blender/quicktime/quicktime_import.h +++ b/source/blender/quicktime/quicktime_import.h @@ -43,35 +43,33 @@ #include "../imbuf/IMB_imbuf_types.h" #ifndef USE_QTKIT -#ifndef __MOVIES__ -#ifdef _WIN32 -#include <Movies.h> -#elif defined(__APPLE__) -#define __CARBONSOUND__ -#import <Carbon/Carbon.h> -#include <QuickTime/Movies.h> -#endif -#endif /* __MOVIES__ */ +# ifndef __MOVIES__ +# ifdef _WIN32 +# include <Movies.h> +# elif defined(__APPLE__) +# define __CARBONSOUND__ +# import <Carbon/Carbon.h> +# include <QuickTime/Movies.h> +# endif +# endif /* __MOVIES__ */ #endif /* USE_QTKIT */ #ifdef _WIN32 -#ifndef __FIXMATH__ -#include <FixMath.h> -#endif /* __FIXMATH__ */ +# ifndef __FIXMATH__ +# include <FixMath.h> +# endif /* __FIXMATH__ */ #endif /* _WIN32 _ */ - char *get_valid_qtname(const char *name); - -// quicktime movie import functions +/* quicktime movie import functions */ int anim_is_quicktime (const char *name); int startquicktime (struct anim *anim); void free_anim_quicktime (struct anim *anim); ImBuf *qtime_fetchibuf (struct anim *anim, int position); -// quicktime image import functions +/* quicktime image import functions */ int imb_is_a_quicktime (char *name); ImBuf *imb_quicktime_decode(unsigned char *mem, int size, int flags); diff --git a/source/blender/render/extern/include/RE_pipeline.h b/source/blender/render/extern/include/RE_pipeline.h index 395fbf8f01c..9525d1dd8f1 100644 --- a/source/blender/render/extern/include/RE_pipeline.h +++ b/source/blender/render/extern/include/RE_pipeline.h @@ -83,7 +83,7 @@ typedef struct RenderLayer { /* copy of RenderData */ char name[RE_MAXNAME]; unsigned int lay, lay_zmask, lay_exclude; - int layflag, passflag, pass_xor; + int layflag, passflag, pass_xor; struct Material *mat_override; struct Group *light_override; @@ -236,7 +236,7 @@ void RE_MergeFullSample(struct Render *re, struct Main *bmain, struct Scene *sce /* ancient stars function... go away! */ void RE_make_stars(struct Render *re, struct Scene *scenev3d, void (*initfunc)(void), - void (*vertexfunc)(float*), void (*termfunc)(void)); + void (*vertexfunc)(float *), void (*termfunc)(void)); /* display and event callbacks */ void RE_display_init_cb (struct Render *re, void *handle, void (*f)(void *handle, RenderResult *rr)); diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index dab89e1d1c0..5e4417a3bc6 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -128,7 +128,7 @@ struct Render /* if render with single-layer option, other rendered layers are stored here */ RenderResult *pushedresult; /* a list of RenderResults, for fullsample */ - ListBase fullresult; + ListBase fullresult; /* read/write mutex, all internal code that writes to re->result must use a * write lock, all external code must use a read lock. internal code is assumed * to not conflict with writes, so no lock used for that */ diff --git a/source/blender/render/intern/include/shadbuf.h b/source/blender/render/intern/include/shadbuf.h index 5cde8e5106a..7c168baada7 100644 --- a/source/blender/render/intern/include/shadbuf.h +++ b/source/blender/render/intern/include/shadbuf.h @@ -79,19 +79,19 @@ float ISB_getshadow(ShadeInput *shi, ShadBuf *shb); /* buffer samples, allocated in camera buffer and pointed to in lampbuffer nodes */ typedef struct ISBSample { - float zco[3]; /* coordinate in lampview projection */ - short *shadfac; /* initialized zero = full lighted */ - int obi; /* object for face lookup */ - int facenr; /* index in faces list */ + float zco[3]; /* coordinate in lampview projection */ + short *shadfac; /* initialized zero = full lighted */ + int obi; /* object for face lookup */ + int facenr; /* index in faces list */ } ISBSample; /* transparent version of buffer sample */ typedef struct ISBSampleA { - float zco[3]; /* coordinate in lampview projection */ - short *shadfac; /* NULL = full lighted */ - int obi; /* object for face lookup */ - int facenr; /* index in faces list */ - struct ISBSampleA *next; /* in end, we want the first items to align with ISBSample */ + float zco[3]; /* coordinate in lampview projection */ + short *shadfac; /* NULL = full lighted */ + int obi; /* object for face lookup */ + int facenr; /* index in faces list */ + struct ISBSampleA *next; /* in end, we want the first items to align with ISBSample */ } ISBSampleA; /* used for transparent storage only */ diff --git a/source/blender/render/intern/include/sunsky.h b/source/blender/render/intern/include/sunsky.h index 04aff810bbb..60fa8aa51ba 100644 --- a/source/blender/render/intern/include/sunsky.h +++ b/source/blender/render/intern/include/sunsky.h @@ -43,8 +43,7 @@ typedef struct SunSky { float perez_Y[5], perez_x[5], perez_y[5]; - /* suggested by glome in - * http://projects.blender.org/tracker/?func=detail&atid=127&aid=8063&group_id=9*/ + /* suggested by glome in patch [#8063] */ float horizon_brightness; float spread; float sun_brightness; diff --git a/source/blender/render/intern/raytrace/bvh.h b/source/blender/render/intern/raytrace/bvh.h index 103c04a590f..47d3a892e84 100644 --- a/source/blender/render/intern/raytrace/bvh.h +++ b/source/blender/render/intern/raytrace/bvh.h @@ -91,7 +91,7 @@ static inline int rayobject_bb_intersect_test(const Isect *isec, const float *_b if (t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return 0; if (t2x < 0.0f || t2y < 0.0f || t2z < 0.0f) return 0; if (t1x > isec->dist || t1y > isec->dist || t1z > isec->dist) return 0; - RE_RC_COUNT(isec->raycounter->bb.hit); + RE_RC_COUNT(isec->raycounter->bb.hit); return 1; } diff --git a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp b/source/blender/render/intern/raytrace/rayobject_blibvh.cpp index 2d642a0a0d8..198577f61c6 100644 --- a/source/blender/render/intern/raytrace/rayobject_blibvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_blibvh.cpp @@ -79,7 +79,7 @@ typedef struct BVHObject { RayObject *RE_rayobject_blibvh_create(int size) { BVHObject *obj = (BVHObject *)MEM_callocN(sizeof(BVHObject), "BVHObject"); - assert(RE_rayobject_isAligned(obj)); /* RayObject API assumes real data to be 4-byte aligned */ + assert(RE_rayobject_isAligned(obj)); /* RayObject API assumes real data to be 4-byte aligned */ obj->rayobj.api = &bvh_api; obj->bvh = BLI_bvhtree_new(size, 0.0, 4, 6); @@ -137,7 +137,7 @@ static void RE_rayobject_blibvh_add(RayObject *o, RayObject *ob) DO_MIN(min_max, obj->bb[0]); DO_MAX(min_max + 3, obj->bb[1]); - BLI_bvhtree_insert(obj->bvh, obj->next_leaf - obj->leafs, min_max, 2); + BLI_bvhtree_insert(obj->bvh, obj->next_leaf - obj->leafs, min_max, 2); *(obj->next_leaf++) = ob; } diff --git a/source/blender/render/intern/raytrace/rayobject_instance.cpp b/source/blender/render/intern/raytrace/rayobject_instance.cpp index c3e761ae069..f797f7a4311 100644 --- a/source/blender/render/intern/raytrace/rayobject_instance.cpp +++ b/source/blender/render/intern/raytrace/rayobject_instance.cpp @@ -59,7 +59,7 @@ static RayObjectAPI instance_api = RE_rayobject_instance_free, RE_rayobject_instance_bb, RE_rayobject_instance_cost, - RE_rayobject_instance_hint_bb + RE_rayobject_instance_hint_bb }; typedef struct InstanceRayObject { diff --git a/source/blender/render/intern/raytrace/rayobject_internal.h b/source/blender/render/intern/raytrace/rayobject_internal.h index 07672f7bfb2..92ac39909a8 100644 --- a/source/blender/render/intern/raytrace/rayobject_internal.h +++ b/source/blender/render/intern/raytrace/rayobject_internal.h @@ -50,7 +50,7 @@ typedef int (*RE_rayobjectcontrol_test_break_callback)(void *data); typedef struct RayObjectControl { void *data; - RE_rayobjectcontrol_test_break_callback test_break; + RE_rayobjectcontrol_test_break_callback test_break; } RayObjectControl; /* Returns true if for some reason a heavy processing function should stop diff --git a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp b/source/blender/render/intern/raytrace/rayobject_qbvh.cpp index 16d70297a34..33ce3bd33d5 100644 --- a/source/blender/render/intern/raytrace/rayobject_qbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_qbvh.cpp @@ -68,7 +68,7 @@ void bvh_done<QBVHTree>(QBVHTree *obj) //Build and optimize the tree //TODO do this in 1 pass (half memory usage during building) - VBVHNode *root = BuildBinaryVBVH<VBVHNode>(arena1, &obj->rayobj.control).transform(obj->builder); + VBVHNode *root = BuildBinaryVBVH<VBVHNode>(arena1, &obj->rayobj.control).transform(obj->builder); if (RE_rayobjectcontrol_test_break(&obj->rayobj.control)) { BLI_memarena_free(arena1); diff --git a/source/blender/render/intern/raytrace/rayobject_raycounter.cpp b/source/blender/render/intern/raytrace/rayobject_raycounter.cpp index 7d86b6cf8cb..5335bf50cbc 100644 --- a/source/blender/render/intern/raytrace/rayobject_raycounter.cpp +++ b/source/blender/render/intern/raytrace/rayobject_raycounter.cpp @@ -43,10 +43,10 @@ void RE_RC_INFO(RayCounter *info) printf("\n"); printf("BB tests: %llu\n", info->bb.test ); printf("BB hits: %llu\n", info->bb.hit ); - printf("\n"); + printf("\n"); printf("SIMD BB tests: %llu\n", info->simd_bb.test ); printf("SIMD BB hits: %llu\n", info->simd_bb.hit ); - printf("\n"); + printf("\n"); printf("Primitives tests: %llu\n", info->faces.test ); printf("Primitives hits: %llu\n", info->faces.hit ); printf("------------------------------------\n"); diff --git a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp index 678aa8e5634..bae65c492f4 100644 --- a/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp +++ b/source/blender/render/intern/raytrace/rayobject_rtbuild.cpp @@ -77,7 +77,7 @@ RTBuilder *rtbuild_create(int size) for (int i = 0; i < 3; i++) { builder->sorted_begin[i] = (RTBuilder::Object **)MEM_mallocN(sizeof(RTBuilder::Object *) * size, "RTBuilder.sorted_objects"); builder->sorted_end[i] = builder->sorted_begin[i]; - } + } return builder; @@ -224,7 +224,7 @@ int rtbuild_mean_split(RTBuilder *b, int nchilds, int axis) Mleafs_per_child = s / nchilds; mleafs_per_child = Mleafs_per_child / nchilds; - //split min leafs per child + //split min leafs per child b->child_offset[0] = 0; for (i = 1; i <= nchilds; i++) b->child_offset[i] = mleafs_per_child; @@ -295,7 +295,7 @@ int rtbuild_median_split(RTBuilder *b, float *separators, int nchilds, int axis) return rtbuild_mean_split(b, nchilds, axis); return nchilds; - } + } } int rtbuild_median_split_largest_axis(RTBuilder *b, int nchilds) @@ -324,7 +324,7 @@ struct SweepCost { /* Object Surface Area Heuristic splitter */ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds) { - int size = rtbuild_size(b); + int size = rtbuild_size(b); assert(nchilds == 2); assert(size > 1); int baxis = -1, boffset = 0; @@ -348,12 +348,12 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds) sweep[i].cost = obj[i]->cost; } else { - sweep[i].bb[0] = MIN2(obj[i]->bb[0], sweep[i + 1].bb[0]); - sweep[i].bb[1] = MIN2(obj[i]->bb[1], sweep[i + 1].bb[1]); - sweep[i].bb[2] = MIN2(obj[i]->bb[2], sweep[i + 1].bb[2]); - sweep[i].bb[3] = MAX2(obj[i]->bb[3], sweep[i + 1].bb[3]); - sweep[i].bb[4] = MAX2(obj[i]->bb[4], sweep[i + 1].bb[4]); - sweep[i].bb[5] = MAX2(obj[i]->bb[5], sweep[i + 1].bb[5]); + sweep[i].bb[0] = min_ff(obj[i]->bb[0], sweep[i + 1].bb[0]); + sweep[i].bb[1] = min_ff(obj[i]->bb[1], sweep[i + 1].bb[1]); + sweep[i].bb[2] = min_ff(obj[i]->bb[2], sweep[i + 1].bb[2]); + sweep[i].bb[3] = max_ff(obj[i]->bb[3], sweep[i + 1].bb[3]); + sweep[i].bb[4] = max_ff(obj[i]->bb[4], sweep[i + 1].bb[4]); + sweep[i].bb[5] = max_ff(obj[i]->bb[5], sweep[i + 1].bb[5]); sweep[i].cost = obj[i]->cost + sweep[i + 1].cost; } // right_cost += obj[i]->cost; @@ -375,8 +375,8 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds) // not using log seems to have no impact on raytracing perf, but // makes tree construction quicker, left out for now to test (brecht) - // left_side = bb_area(sweep_left.bb, sweep_left.bb+3)*(sweep_left.cost+logf((float)i)); - // right_side= bb_area(sweep[i].bb, sweep[i].bb+3)*(sweep[i].cost+logf((float)size-i)); + // left_side = bb_area(sweep_left.bb, sweep_left.bb + 3) * (sweep_left.cost + logf((float)i)); + // right_side = bb_area(sweep[i].bb, sweep[i].bb + 3) * (sweep[i].cost + logf((float)size - i)); left_side = bb_area(sweep_left.bb, sweep_left.bb + 3) * (sweep_left.cost); right_side = bb_area(sweep[i].bb, sweep[i].bb + 3) * (sweep[i].cost); hcost = left_side + right_side; @@ -429,7 +429,7 @@ int rtbuild_heuristic_object_split(RTBuilder *b, int nchilds) for (int i = 0; i < 3; i++) std::stable_partition(b->sorted_begin[i], b->sorted_end[i], selected_node); - return nchilds; + return nchilds; } /* @@ -494,7 +494,7 @@ int bb_largest_axis(const float min[3], const float max[3]) return 1; else return 2; - } + } } /* only returns 0 if merging inner and outerbox would create a box larger than outer box */ @@ -508,5 +508,5 @@ int bb_fits_inside(const float outer_min[3], const float outer_max[3], for (i = 0; i < 3; i++) if (outer_max[i] < inner_max[i]) return 0; - return 1; + return 1; } diff --git a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp index 85c9d0d402f..d03bdb74407 100644 --- a/source/blender/render/intern/raytrace/rayobject_vbvh.cpp +++ b/source/blender/render/intern/raytrace/rayobject_vbvh.cpp @@ -112,7 +112,7 @@ void bvh_done<VBVHTree>(VBVHTree *obj) //Finds the optimal packing of this tree using a given cost model //TODO this uses quite a lot of memory, find ways to reduce memory usage during building - OVBVHNode *root = BuildBinaryVBVH<OVBVHNode>(arena2).transform(obj->builder); + OVBVHNode *root = BuildBinaryVBVH<OVBVHNode>(arena2).transform(obj->builder); VBVH_optimalPackSIMD<OVBVHNode, PackCost>(PackCost()).transform(root); obj->root = Reorganize_VBVH<OVBVHNode>(arena1).transform(root); @@ -125,7 +125,7 @@ void bvh_done<VBVHTree>(VBVHTree *obj) obj->builder = NULL; obj->node_arena = arena1; - obj->cost = 1.0; + obj->cost = 1.0; } template<int StackSize> diff --git a/source/blender/render/intern/raytrace/reorganize.h b/source/blender/render/intern/raytrace/reorganize.h index a9ed71a76bc..9d9711eee56 100644 --- a/source/blender/render/intern/raytrace/reorganize.h +++ b/source/blender/render/intern/raytrace/reorganize.h @@ -75,7 +75,7 @@ void reorganize_find_fittest_parent(Node *tree, Node *node, std::pair<float, Nod float pcost = bb_area(parent->bb, parent->bb + 3); cost = std::min(cost, std::make_pair(pcost, parent) ); for (Node *child = parent->child; child; child = child->sibling) - q.push(child); + q.push(child); } } } @@ -140,7 +140,7 @@ void remove_useless(Node *node, Node **new_node) (*prev)->sibling = next; prev = &((*prev)->sibling); } - } + } } if (node->child) { if (RE_rayobject_isAligned(node->child) && node->child->sibling == 0) @@ -181,7 +181,7 @@ void pushup(Node *parent) *prev = child; prev = &(*prev)->sibling; child = *prev; - } + } } for (Node *child = parent->child; RE_rayobject_isAligned(child) && child; child = child->sibling) @@ -205,13 +205,13 @@ void pushup_simd(Node *parent) n += (cn - 1); append_sibling(child, child->child); child = child->sibling; - *prev = child; + *prev = child; } else { *prev = child; prev = &(*prev)->sibling; child = *prev; - } + } } for (Node *child = parent->child; RE_rayobject_isAligned(child) && child; child = child->sibling) @@ -320,7 +320,7 @@ struct OVBVHNode { /* * Reorganize the node based on calculated cut costs - */ + */ int best_cutsize; void set_cut(int cutsize, OVBVHNode ***cut) { @@ -357,7 +357,7 @@ struct OVBVHNode { //Optimize new childs for (OVBVHNode *child = this->child; child && RE_rayobject_isAligned(child); child = child->sibling) child->optimize(); - } + } } }; @@ -431,7 +431,7 @@ struct VBVH_optimalPackSIMD { current_size -= bt[j][current_size]; } } - } + } } }; @@ -493,6 +493,6 @@ struct VBVH_optimalPackSIMD { if ((G.debug & G_DEBUG) && first) printf("expected cost = %f (%d)\n", node->cut_cost[0], node->best_cutsize); node->optimize(); } - return node; - } + return node; + } }; diff --git a/source/blender/render/intern/raytrace/svbvh.h b/source/blender/render/intern/raytrace/svbvh.h index 4fdf3ac23e8..757ebc4c4d3 100644 --- a/source/blender/render/intern/raytrace/svbvh.h +++ b/source/blender/render/intern/raytrace/svbvh.h @@ -96,7 +96,7 @@ static int svbvh_bb_intersect_test(const Isect *isec, const float *_bb) if (t2x < 0.0 || t2y < 0.0 || t2z < 0.0) return 0; if (t1x > isec->dist || t1y > isec->dist || t1z > isec->dist) return 0; - RE_RC_COUNT(isec->raycounter->bb.hit); + RE_RC_COUNT(isec->raycounter->bb.hit); return 1; } @@ -165,16 +165,16 @@ inline void bvh_node_merge_bb<SVBVHNode>(SVBVHNode *node, float min[3], float ma for (i = 0; i + 4 <= node->nchilds; i += 4) { float *res = node->child_bb + 6 * i; for (int j = 0; j < 3; j++) { - min[j] = minf(res[4 * j + 0], - minf(res[4 * j + 1], - minf(res[4 * j + 2], - minf(res[4 * j + 3], min[j])))); + min[j] = min_ff(res[4 * j + 0], + min_ff(res[4 * j + 1], + min_ff(res[4 * j + 2], + min_ff(res[4 * j + 3], min[j])))); } for (int j = 0; j < 3; j++) { - max[j] = maxf(res[4 * (j + 3) + 0], - maxf(res[4 * (j + 3) + 1], - maxf(res[4 * (j + 3) + 2], - maxf(res[4 * (j + 3) + 3], max[j])))); + max[j] = max_ff(res[4 * (j + 3) + 0], + max_ff(res[4 * (j + 3) + 1], + max_ff(res[4 * (j + 3) + 2], + max_ff(res[4 * (j + 3) + 3], max[j])))); } } @@ -307,7 +307,7 @@ struct Reorganize_SVBVH { prepare_for_simd(node); return node; - } + } }; #endif /* __SSE__ */ diff --git a/source/blender/render/intern/raytrace/vbvh.h b/source/blender/render/intern/raytrace/vbvh.h index ec671f95c76..9755bf89668 100644 --- a/source/blender/render/intern/raytrace/vbvh.h +++ b/source/blender/render/intern/raytrace/vbvh.h @@ -233,6 +233,6 @@ struct Reorganize_VBVH { *child_ptr = 0; return node; - } + } }; #endif diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index e399951bd15..4aa30e6c4cf 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -157,7 +157,7 @@ static HaloRen *initstar(Render *re, ObjectRen *obr, const float vec[3], float h */ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), - void (*vertexfunc)(float*), void (*termfunc)(void)) + void (*vertexfunc)(float*), void (*termfunc)(void)) { extern unsigned char hash[512]; ObjectRen *obr= NULL; @@ -228,7 +228,7 @@ void RE_make_stars(Render *re, Scene *scenev3d, void (*initfunc)(void), hlfrand = 2.0 * dblrand; if (initfunc) { - initfunc(); + initfunc(); } if (re) /* add render object for stars */ @@ -365,7 +365,7 @@ static void split_v_renderfaces(ObjectRen *obr, int startvlak, int UNUSED(startv if (v==0) { vlr->v1 = RE_vertren_copy(obr, vlr->v1); - } + } } } } @@ -447,7 +447,7 @@ static void calc_edge_stress(Render *UNUSED(re), ObjectRen *obr, Mesh *me) } /* gets tangent from tface or orco */ -static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemArena *arena, VlakRen *vlr, int do_nmap_tangent, int do_tangent) +static void calc_tangent_vector(ObjectRen *obr, VlakRen *vlr, int do_tangent) { MTFace *tface= RE_vlakren_get_tface(obr, vlr, obr->actmtface, NULL, 0); VertRen *v1=vlr->v1, *v2=vlr->v2, *v3=vlr->v3, *v4=vlr->v4; @@ -482,12 +482,6 @@ static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemAr add_v3_v3(tav, tang); } - if (do_nmap_tangent) { - sum_or_add_vertex_tangent(arena, &vtangents[v1->index], tang, uv1); - sum_or_add_vertex_tangent(arena, &vtangents[v2->index], tang, uv2); - sum_or_add_vertex_tangent(arena, &vtangents[v3->index], tang, uv3); - } - if (v4) { tangent_from_uv(uv1, uv3, uv4, v1->co, v3->co, v4->co, vlr->n, tang); @@ -499,12 +493,6 @@ static void calc_tangent_vector(ObjectRen *obr, VertexTangent **vtangents, MemAr tav= RE_vertren_get_tangent(obr, v4, 1); add_v3_v3(tav, tang); } - - if (do_nmap_tangent) { - sum_or_add_vertex_tangent(arena, &vtangents[v1->index], tang, uv1); - sum_or_add_vertex_tangent(arena, &vtangents[v3->index], tang, uv3); - sum_or_add_vertex_tangent(arena, &vtangents[v4->index], tang, uv4); - } } } @@ -569,8 +557,14 @@ static void GetNormal(const SMikkTSpaceContext * pContext, float fNorm[], const //assert(vert_index>=0 && vert_index<4); SRenderMeshToTangent * pMesh = (SRenderMeshToTangent *) pContext->m_pUserData; VlakRen *vlr= RE_findOrAddVlak(pMesh->obr, face_num); - const float *n= (&vlr->v1)[vert_index]->n; - copy_v3_v3(fNorm, n); + + if (vlr->flag & ME_SMOOTH) { + const float *n = (&vlr->v1)[vert_index]->n; + copy_v3_v3(fNorm, n); + } + else { + negate_v3_v3(fNorm, vlr->n); + } } static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent[], const float fSign, const int face_num, const int iVert) { @@ -586,17 +580,8 @@ static void SetTSpace(const SMikkTSpaceContext * pContext, const float fvTangent static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangent, int do_nmap_tangent) { - MemArena *arena= NULL; - VertexTangent **vtangents= NULL; int a; - if (do_nmap_tangent) { - arena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "nmap tangent arena"); - BLI_memarena_use_calloc(arena); - - vtangents= MEM_callocN(sizeof(VertexTangent*)*obr->totvert, "VertexTangent"); - } - /* clear all vertex normals */ for (a=0; a<obr->totvert; a++) { VertRen *ver= RE_findOrAddVert(obr, a); @@ -614,10 +599,10 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen accumulate_vertex_normals(vlr->v1->n, vlr->v2->n, vlr->v3->n, n4, vlr->n, vlr->v1->co, vlr->v2->co, vlr->v3->co, c4); } - if (do_nmap_tangent || do_tangent) { + if (do_tangent) { /* tangents still need to be calculated for flat faces too */ /* weighting removed, they are not vertexnormals */ - calc_tangent_vector(obr, vtangents, arena, vlr, do_nmap_tangent, do_tangent); + calc_tangent_vector(obr, vlr, do_tangent); } } @@ -631,32 +616,6 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen if (is_zero_v3(vlr->v3->n)) copy_v3_v3(vlr->v3->n, vlr->n); if (vlr->v4 && is_zero_v3(vlr->v4->n)) copy_v3_v3(vlr->v4->n, vlr->n); } - - if (do_nmap_tangent) { - VertRen *v1=vlr->v1, *v2=vlr->v2, *v3=vlr->v3, *v4=vlr->v4; - MTFace *tface= RE_vlakren_get_tface(obr, vlr, obr->actmtface, NULL, 0); - - if (tface) { - int k=0; - float *vtang, *ftang= RE_vlakren_get_nmap_tangent(obr, vlr, 1); - - vtang= find_vertex_tangent(vtangents[v1->index], tface->uv[0]); - copy_v3_v3(ftang, vtang); - normalize_v3(ftang); - vtang= find_vertex_tangent(vtangents[v2->index], tface->uv[1]); - copy_v3_v3(ftang+4, vtang); - normalize_v3(ftang+4); - vtang= find_vertex_tangent(vtangents[v3->index], tface->uv[2]); - copy_v3_v3(ftang+8, vtang); - normalize_v3(ftang+8); - if (v4) { - vtang= find_vertex_tangent(vtangents[v4->index], tface->uv[3]); - copy_v3_v3(ftang+12, vtang); - normalize_v3(ftang+12); - } - for (k=0; k<4; k++) ftang[4*k+3]=1; - } - } } /* normalize vertex normals */ @@ -676,6 +635,7 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen } } + /* normal mapping tangent with mikktspace */ if (do_nmap_tangent != FALSE) { SRenderMeshToTangent mesh2tangent; SMikkTSpaceContext sContext; @@ -697,11 +657,6 @@ static void calc_vertexnormals(Render *UNUSED(re), ObjectRen *obr, int do_tangen genTangSpaceDefault(&sContext); } - - if (arena) - BLI_memarena_free(arena); - if (vtangents) - MEM_freeN(vtangents); } /* ------------------------------------------------------------------------- */ @@ -883,7 +838,7 @@ static void autosmooth(Render *UNUSED(re), ObjectRen *obr, float mat[][4], int d else normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co); } - } + } } /* ------------------------------------------------------------------------- */ @@ -1614,7 +1569,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem psys->flag |= PSYS_DRAWING; - rng= rng_new(psys->seed); + rng= BLI_rng_new(psys->seed); totpart=psys->totpart; @@ -1764,7 +1719,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem /* 3. start creating renderable things */ for (a=0, pa=pars; a<totpart+totchild; a++, pa++, seed++) { - random = rng_getFloat(rng); + random = BLI_rng_get_float(rng); /* setup per particle individual stuff */ if (a<totpart) { if (pa->flag & PARS_UNEXIST) continue; @@ -1940,7 +1895,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem copy_v3_v3(state.vel, (cache+k)->vel); } else - continue; + continue; if (k > 0) curlen += len_v3v3((cache+k-1)->co, (cache+k)->co); @@ -2100,7 +2055,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem if (states) MEM_freeN(states); - rng_free(rng); + BLI_rng_free(rng); psys->flag &= ~PSYS_DRAWING; @@ -2368,7 +2323,7 @@ static void displace_render_face(Render *re, ObjectRen *obr, VlakRen *vlr, float /* Recalculate the face normal - if flipped before, flip now */ if (vlr->v4) { normal_quad_v3(vlr->n, vlr->v4->co, vlr->v3->co, vlr->v2->co, vlr->v1->co); - } + } else { normal_tri_v3(vlr->n, vlr->v3->co, vlr->v2->co, vlr->v1->co); } @@ -2537,7 +2492,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, copy_v3_v3(v1->co, data); data += 3; if (orco) { v1->orco= orco; orco+= 3; orcoret++; - } + } mul_m4_v3(mat, v1->co); for (v = 1; v < sizev; v++) { @@ -2545,7 +2500,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, copy_v3_v3(ver->co, data); data += 3; if (orco) { ver->orco= orco; orco+= 3; orcoret++; - } + } mul_m4_v3(mat, ver->co); } /* if V-cyclic, add extra vertices at end of the row */ @@ -2555,8 +2510,8 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, if (orco) { ver->orco= orco; orco+=3; orcoret++; //orcobase + 3*(u*sizev + 0); } - } - } + } + } /* Done before next loop to get corner vert */ if (dl->flag & DL_CYCL_U) nsizev++; @@ -2609,7 +2564,7 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, p1++; p2++; p3++; p4++; } - } + } /* fix normals for U resp. V cyclic faces */ sizeu--; sizev--; /* dec size for face array */ if (dl->flag & DL_CYCL_V) { @@ -2930,8 +2885,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) vlr->v2= RE_findOrAddVert(obr, startvert+index[1]); vlr->v3= RE_findOrAddVert(obr, startvert+index[2]); vlr->v4= NULL; - - if (area_tri_v3(vlr->v3->co, vlr->v2->co, vlr->v1->co)>FLT_EPSILON) { + if (area_tri_v3(vlr->v3->co, vlr->v2->co, vlr->v1->co)>FLT_EPSILON10) { normal_tri_v3(tmp, vlr->v3->co, vlr->v2->co, vlr->v1->co); add_v3_v3(n, tmp); } @@ -3293,11 +3247,11 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) /* normalmaps, test if tangents needed, separated from shading */ if (ma->mode_l & MA_TANGENT_V) { need_tangent= 1; - if (me->mtface==NULL) + if (me->mtpoly==NULL) need_orco= 1; } if (ma->mode_l & MA_NORMAP_TANG) { - if (me->mtface==NULL) { + if (me->mtpoly==NULL) { need_orco= 1; need_tangent= 1; } @@ -3308,7 +3262,7 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) if (re->flag & R_NEED_TANGENT) { /* exception for tangent space baking */ - if (me->mtface==NULL) { + if (me->mtpoly==NULL) { need_orco= 1; need_tangent= 1; } @@ -3659,22 +3613,22 @@ static void area_lamp_vectors(LampRen *lar) /* corner vectors */ lar->area[0][0]= lar->co[0] - xsize*lar->mat[0][0] - ysize*lar->mat[1][0]; lar->area[0][1]= lar->co[1] - xsize*lar->mat[0][1] - ysize*lar->mat[1][1]; - lar->area[0][2]= lar->co[2] - xsize*lar->mat[0][2] - ysize*lar->mat[1][2]; + lar->area[0][2]= lar->co[2] - xsize*lar->mat[0][2] - ysize*lar->mat[1][2]; /* corner vectors */ lar->area[1][0]= lar->co[0] - xsize*lar->mat[0][0] + ysize*lar->mat[1][0]; lar->area[1][1]= lar->co[1] - xsize*lar->mat[0][1] + ysize*lar->mat[1][1]; - lar->area[1][2]= lar->co[2] - xsize*lar->mat[0][2] + ysize*lar->mat[1][2]; + lar->area[1][2]= lar->co[2] - xsize*lar->mat[0][2] + ysize*lar->mat[1][2]; /* corner vectors */ lar->area[2][0]= lar->co[0] + xsize*lar->mat[0][0] + ysize*lar->mat[1][0]; lar->area[2][1]= lar->co[1] + xsize*lar->mat[0][1] + ysize*lar->mat[1][1]; - lar->area[2][2]= lar->co[2] + xsize*lar->mat[0][2] + ysize*lar->mat[1][2]; + lar->area[2][2]= lar->co[2] + xsize*lar->mat[0][2] + ysize*lar->mat[1][2]; /* corner vectors */ lar->area[3][0]= lar->co[0] + xsize*lar->mat[0][0] - ysize*lar->mat[1][0]; lar->area[3][1]= lar->co[1] + xsize*lar->mat[0][1] - ysize*lar->mat[1][1]; - lar->area[3][2]= lar->co[2] + xsize*lar->mat[0][2] - ysize*lar->mat[1][2]; + lar->area[3][2]= lar->co[2] + xsize*lar->mat[0][2] - ysize*lar->mat[1][2]; /* only for correction button size, matrix size works on energy */ lar->areasize= lar->dist*lar->dist/(4.0f*xsize*ysize); } @@ -4995,7 +4949,8 @@ static void database_init_objects(Render *re, unsigned int renderlay, int nolamp * a dupligroup that has already been created before */ if (dob->type != OB_DUPLIGROUP || (obr=find_dupligroup_dupli(re, obd, 0))) { mult_m4_m4m4(mat, re->viewmat, dob->mat); - obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, 0, mat, obd->lay); + /* ob = particle system, use that layer */ + obi= RE_addRenderInstance(re, NULL, obd, ob, dob->index, 0, mat, ob->lay); /* fill in instance variables for texturing */ set_dupli_tex_mat(re, obi, dob); @@ -5396,7 +5351,7 @@ static float *calculate_strandsurface_speedvectors(Render *re, ObjectInstanceRen calculate_speedvector(vec, 1, winsq, winroot, mesh->co[a], ho, winspeed[a]); } - return (float*)winspeed; + return (float *)winspeed; } return NULL; @@ -5654,7 +5609,7 @@ void RE_Database_FromScene_Vectors(Render *re, Main *bmain, Scene *sce, unsigned re->i.infostr= "Calculating next frame vectors"; database_fromscene_vectors(re, sce, lay, +1); - } + } /* copy away vertex info */ copy_dbase_object_vectors(re, &newtable); diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index 910307f370b..558ba8fe062 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -76,7 +76,7 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf) BLI_lock_thread(LOCK_IMAGE); if (env->cube[1] == NULL) { - BKE_free_envmapdata(env); + BKE_free_envmapdata(env); dx = ibuf->y; dx /= 2; @@ -120,7 +120,7 @@ static void envmap_split_ima(EnvMap *env, ImBuf *ibuf) IMB_float_from_rect(env->cube[1]); } } - } + } BLI_unlock_thread(LOCK_IMAGE); } @@ -216,7 +216,7 @@ static void envmap_transmatrix(float mat[][4], int part) eul[0] = eul[1] = eul[2] = 0.0; if (part == 0) { /* neg z */ - ; + /* pass */ } else if (part == 1) { /* pos z */ eul[0] = M_PI; @@ -576,7 +576,7 @@ void make_envmaps(Render *re) re->display_init(re->dih, re->result); re->display_clear(re->dch, re->result); // re->flag |= R_REDRAW_PRV; - } + } /* restore */ re->r.mode |= trace; diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index 636b3205b23..94146467145 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -138,7 +138,7 @@ void RE_engine_free(RenderEngine *engine) { #ifdef WITH_PYTHON if (engine->py_instance) { - BPY_DECREF(engine->py_instance); + BPY_DECREF_RNA_INVALIDATE(engine->py_instance); } #endif diff --git a/source/blender/render/intern/source/gammaCorrectionTables.c b/source/blender/render/intern/source/gammaCorrectionTables.c index 1c2613e8d18..8efdf472232 100644 --- a/source/blender/render/intern/source/gammaCorrectionTables.c +++ b/source/blender/render/intern/source/gammaCorrectionTables.c @@ -107,13 +107,13 @@ void makeGammaTables(float gamma) color_step = 1.0 / RE_GAMMA_TABLE_SIZE; inv_color_step = (float) RE_GAMMA_TABLE_SIZE; - /* We could squeeze out the two range tables to gain some memory. */ + /* We could squeeze out the two range tables to gain some memory. */ for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) { - color_domain_table[i] = i * color_step; + color_domain_table[i] = i * color_step; gamma_range_table[i] = pow(color_domain_table[i], - valid_gamma); + valid_gamma); inv_gamma_range_table[i] = pow(color_domain_table[i], - valid_inv_gamma); + valid_inv_gamma); } /* The end of the table should match 1.0 carefully. In order to avoid */ diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index 154292a3065..44faee73d35 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -102,7 +102,7 @@ static void ibuf_get_color(float col[4], struct ImBuf *ibuf, int x, int y) col[1] = ((float)rect[1])*(1.0f/255.0f); col[2] = ((float)rect[2])*(1.0f/255.0f); col[3] = ((float)rect[3])*(1.0f/255.0f); - } + } } int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResult *texres) @@ -209,7 +209,7 @@ int imagewrap(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], TexResul if (tex->imaflag & TEX_USEALPHA) { if ((tex->imaflag & TEX_CALCALPHA) == 0) { texres->talpha = TRUE; - } + } } /* interpolate */ @@ -693,7 +693,7 @@ static int ibuf_get_color_clip(float col[4], ImBuf *ibuf, int x, int y, int extf } } else { - char* rect = (char*)(ibuf->rect + x + y*ibuf->x); + char *rect = (char *)(ibuf->rect + x + y*ibuf->x); col[0] = rect[0]*(1.f/255.f); col[1] = rect[1]*(1.f/255.f); col[2] = rect[2]*(1.f/255.f); @@ -989,7 +989,7 @@ static void alpha_clip_aniso(ImBuf *ibuf, float minx, float miny, float maxx, fl alphaclip = clipx_rctf(&rf, 0.0, (float)(ibuf->x)); alphaclip *= clipy_rctf(&rf, 0.0, (float)(ibuf->y)); - alphaclip = maxf(alphaclip, 0.0f); + alphaclip = max_ff(alphaclip, 0.0f); if (alphaclip!=1.0f) { /* premul it all */ @@ -1011,7 +1011,7 @@ static void image_mipmap_test(Tex *tex, ImBuf *ibuf) if (ibuf->userflags & IB_MIPMAP_INVALID) { IMB_remakemipmap(ibuf, tex->imaflag & TEX_GAUSS_MIP); ibuf->userflags &= ~IB_MIPMAP_INVALID; - } + } BLI_unlock_thread(LOCK_IMAGE); } if (ibuf->mipmap[0] == NULL) { @@ -1247,8 +1247,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex float fProbes; a *= ff; b *= ff; - a = maxf(a, 1.0f); - b = maxf(b, 1.0f); + a = max_ff(a, 1.0f); + b = max_ff(b, 1.0f); fProbes = 2.f*(a / b) - 1.f; AFD.iProbes = (int)floorf(fProbes + 0.5f); AFD.iProbes = MIN2(AFD.iProbes, tex->afmax); @@ -1264,7 +1264,7 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex if (ecc > (float)tex->afmax) b = a / (float)tex->afmax; b *= ff; } - maxd = maxf(b, 1e-8f); + maxd = max_ff(b, 1e-8f); levf = ((float)M_LOG2E) * logf(maxd); curmap = 0; @@ -1349,8 +1349,8 @@ static int imagewraposa_aniso(Tex *tex, Image *ima, ImBuf *ibuf, const float tex imp2radangle(A, B, C, F, &a, &b, &th, &ecc); a *= ff; b *= ff; - a = maxf(a, 1.0f); - b = maxf(b, 1.0f); + a = max_ff(a, 1.0f); + b = max_ff(b, 1.0f); fProbes = 2.f*(a / b) - 1.f; /* no limit to number of Probes here */ AFD.iProbes = (int)floorf(fProbes + 0.5f); @@ -1645,7 +1645,7 @@ int imagewraposa(Tex *tex, Image *ima, ImBuf *ibuf, const float texvec[3], const dx = minx; dy = miny; - maxd = maxf(dx, dy); + maxd = max_ff(dx, dy); if (maxd > 0.5f) maxd = 0.5f; pixsize = 1.0f / (float) MIN2(ibuf->x, ibuf->y); diff --git a/source/blender/render/intern/source/occlusion.c b/source/blender/render/intern/source/occlusion.c index 895c5d6c8fb..a7308821843 100644 --- a/source/blender/render/intern/source/occlusion.c +++ b/source/blender/render/intern/source/occlusion.c @@ -184,7 +184,7 @@ static void occ_shade(ShadeSample *ssamp, ObjectInstanceRen *obi, VlakRen *vlr, if (shi->flippednor) shade_input_flip_normals(shi); - madd_v3_v3fl(shi->co, shi->vn, 0.0001f); /* ugly.. */ + madd_v3_v3fl(shi->co, shi->facenor, -0.0001f); /* ugly.. */ /* not a pretty solution, but fixes common cases */ if (shi->obr->ob && shi->obr->ob->transflag & OB_NEG_SCALE) { @@ -1130,7 +1130,7 @@ static void normalizef(float *n) n[0] *= d; n[1] *= d; n[2] *= d; - } + } } /* TODO: exact duplicate of ff_quad_form_factor() in math_geom.c @@ -1547,7 +1547,7 @@ static int sample_occ_cache(OcclusionTree *tree, float *co, float *n, int x, int for (i = 0; i < 4; i++) { sub_v3_v3v3(d, samples[i]->co, co); - //dist2= dot_v3v3(d, d); + //dist2 = dot_v3v3(d, d); wz[i] = 1.0f; //(samples[i]->dist2/(1e-4f + dist2)); wn[i] = pow(dot_v3v3(samples[i]->n, n), 32.0f); diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 648c27e0d2f..8f1037ec051 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -502,7 +502,7 @@ void RE_InitState(Render *re, Render *source, RenderData *rd, SceneRenderLayer * } /* always call, checks for gamma, gamma tables and jitter too */ - make_sample_tables(re); + make_sample_tables(re); /* if preview render, we try to keep old result */ BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); @@ -994,7 +994,7 @@ static void addblur_rect_key(RenderResult *rr, float *rectf, float *rectf1, floa rf[1] = mfac * rf[1] + blurfac * rf1[1]; rf[2] = mfac * rf[2] + blurfac * rf1[2]; rf[3] = mfac * rf[3] + blurfac * rf1[3]; - } + } } } rectf += stride; @@ -1086,7 +1086,7 @@ static void do_render_blur_3d(Render *re) /* weak... the display callback wants an active renderlayer pointer... */ re->result->renlay = render_get_active_layer(re, re->result); - re->display_draw(re->ddh, re->result, NULL); + re->display_draw(re->ddh, re->result, NULL); } @@ -1646,7 +1646,7 @@ static void do_render_composite_fields_blur_3d(Render *re) ntreeFreeCache(ntree); do_render_fields_blur_3d(re); - } + } else { /* ensure new result gets added, like for regular renders */ BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE); @@ -1953,7 +1953,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r if (scene->r.border.xmax <= scene->r.border.xmin || scene->r.border.ymax <= scene->r.border.ymin) { - BKE_report(reports, RPT_ERROR, "No border area selected."); + BKE_report(reports, RPT_ERROR, "No border area selected"); return 0; } } @@ -1964,13 +1964,13 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r render_result_exr_file_path(scene, "", 0, str); if (BLI_file_is_writable(str) == 0) { - BKE_report(reports, RPT_ERROR, "Can not save render buffers, check the temp default path"); + BKE_report(reports, RPT_ERROR, "Cannot save render buffers, check the temp default path"); return 0; } /* no fullsample and edge */ if ((scene->r.scemode & R_FULL_SAMPLE) && (scene->r.mode & R_EDGE)) { - BKE_report(reports, RPT_ERROR, "Full Sample doesn't support Edge Enhance"); + BKE_report(reports, RPT_ERROR, "Full sample does not support edge enhance"); return 0; } @@ -1981,18 +1981,18 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r if (scene->r.scemode & R_DOCOMP) { if (scene->use_nodes) { if (!scene->nodetree) { - BKE_report(reports, RPT_ERROR, "No node tree in Scene"); + BKE_report(reports, RPT_ERROR, "No node tree in scene"); return 0; } if (!check_composite_output(scene)) { - BKE_report(reports, RPT_ERROR, "No Render Output Node in Scene"); + BKE_report(reports, RPT_ERROR, "No render output node in scene"); return 0; } if (scene->r.scemode & R_FULL_SAMPLE) { if (composite_needs_render(scene, 0) == 0) { - BKE_report(reports, RPT_ERROR, "Full Sample AA not supported without 3d rendering"); + BKE_report(reports, RPT_ERROR, "Full sample AA not supported without 3D rendering"); return 0; } } @@ -2011,7 +2011,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r /* forbidden combinations */ if (scene->r.mode & R_PANORAMA) { if (scene->r.mode & R_ORTHO) { - BKE_report(reports, RPT_ERROR, "No Ortho render possible for Panorama"); + BKE_report(reports, RPT_ERROR, "No ortho render possible for panorama"); return 0; } } @@ -2027,7 +2027,7 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r if (!(srl->layflag & SCE_LAY_DISABLE)) break; if (srl == NULL) { - BKE_report(reports, RPT_ERROR, "All RenderLayers are disabled"); + BKE_report(reports, RPT_ERROR, "All render layers are disabled"); return 0; } @@ -2230,7 +2230,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie IMB_freeImBuf(ibuf); printf("Append frame %d", scene->r.cfra); - } + } else { if (name_override) BLI_strncpy(name, name_override, sizeof(name)); @@ -2550,25 +2550,25 @@ void RE_layer_load_from_file(RenderLayer *layer, ReportList *reports, const char IMB_freeImBuf(ibuf_clip); } else { - BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to allocate clip buffer '%s'\n", filename); + BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to allocate clip buffer '%s'", filename); } } else { - BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: incorrect dimensions for partial copy '%s'\n", filename); + BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: incorrect dimensions for partial copy '%s'", filename); } } IMB_freeImBuf(ibuf); } else { - BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename); + BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'", filename); } } void RE_result_load_from_file(RenderResult *result, ReportList *reports, const char *filename) { if (!render_result_exr_file_read_path(result, NULL, filename)) { - BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'\n", filename); + BKE_reportf(reports, RPT_ERROR, "RE_result_rect_from_file: failed to load '%s'", filename); return; } } @@ -2629,7 +2629,7 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, return TRUE; } else { - BKE_report(reports, RPT_ERROR, "Error writing environment map."); + BKE_report(reports, RPT_ERROR, "Error writing environment map"); return FALSE; } } diff --git a/source/blender/render/intern/source/pixelshading.c b/source/blender/render/intern/source/pixelshading.c index 8e6078b18e0..3420648cb52 100644 --- a/source/blender/render/intern/source/pixelshading.c +++ b/source/blender/render/intern/source/pixelshading.c @@ -162,7 +162,7 @@ static void render_lighting_halo(HaloRen *har, float col_r[3]) copy_v3_v3(lvrot, lv); mul_m3_v3(lar->imat, lvrot); - x = maxf(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2])); + x = max_ff(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2])); /* 1.0/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */ inpr= 1.0/(sqrt(1.0f+x*x)); @@ -614,7 +614,7 @@ void shadeSkyPixel(float collector[4], float fx, float fy, short thread) copy_v3_v3(collector, &R.wrld.horr); collector[3] = 0.0f; - } + } else { /* 2. */ diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index f8462dcd888..a540cdb85d5 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -171,7 +171,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa pd->point_data[i*3 + 0] = state.vel[0]; pd->point_data[i*3 + 1] = state.vel[1]; pd->point_data[i*3 + 2] = state.vel[2]; - } + } if (data_used & POINT_DATA_LIFE) { float pa_time; @@ -419,7 +419,7 @@ int pointdensitytex(Tex *tex, const float texvec[3], TexResult *texres) texres->tin = 0.0f; - if ((!pd) || (!pd->point_tree)) + if ((!pd) || (!pd->point_tree)) return 0; init_pointdensityrangedata(pd, &pdr, &density, vec, &age, diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 260a80d70e9..127e0bc07b9 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -239,7 +239,7 @@ RayObject* makeraytree_object(Render *re, ObjectInstanceRen *obi) if (faces == 0) return NULL; - //Create Ray cast accelaration structure + //Create Ray cast accelaration structure raytree = RE_rayobject_create( re, re->r.raytrace_structure, faces ); if ( (re->r.raytrace_options & R_RAYTRACE_USE_LOCAL_COORDS) ) vlakprimitive = obr->rayprimitives = (VlakPrimitive*)MEM_callocN(faces*sizeof(VlakPrimitive), "ObjectRen primitives"); @@ -549,7 +549,7 @@ void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) /* raytrace likes to separate the spec color */ sub_v3_v3v3(shr->diff, shr->combined, shr->spec); - } + } } @@ -564,12 +564,12 @@ static int refraction(float refract[3], const float n[3], const float view[3], f if (dot>0.0f) { index = 1.0f/index; fac= 1.0f - (1.0f - dot*dot)*index*index; - if (fac<= 0.0f) return 0; + if (fac <= 0.0f) return 0; fac= -dot*index + sqrtf(fac); } else { fac= 1.0f - (1.0f - dot*dot)*index*index; - if (fac<= 0.0f) return 0; + if (fac <= 0.0f) return 0; fac= -dot*index - sqrtf(fac); } @@ -632,7 +632,7 @@ static float shade_by_transmission(Isect *is, ShadeInput *shi, ShadeResult *shr) if (shi->mat->tx_limit <= 0.0f) { d= 1.0f; - } + } else { float p; @@ -733,7 +733,7 @@ static void traceray(ShadeInput *origshi, ShadeResult *origshr, short depth, con if (depth>0) { float fr, fg, fb, f, f1; - if ((shi.mat->mode_l & MA_TRANSP) && shr.alpha < 1.0f && (shi.mat->mode_l & (MA_ZTRANSP | MA_RAYTRANSP))) { + if ((shi.mat->mode_l & MA_TRANSP) && shr.alpha < 1.0f && (shi.mat->mode_l & (MA_ZTRANSP | MA_RAYTRANSP))) { float nf, f, refract[3], tracol[4]; tracol[0]= shi.r; @@ -938,7 +938,7 @@ void init_jitter_plane(LampRen *lar) DP_energy(lar->jitter, fp, tot, lar->area_size, lar->area_sizey); } } - } + } /* create the dithered tables (could just check lamp type!) */ jitter_plane_offset(lar->jitter, lar->jitter+2*tot, tot, lar->area_size, lar->area_sizey, 0.5f, 0.0f); jitter_plane_offset(lar->jitter, lar->jitter+4*tot, tot, lar->area_size, lar->area_sizey, 0.5f, 0.5f); @@ -1151,7 +1151,7 @@ static void QMC_sampleHemiCosine(float vec[3], QMCSampler *qsa, int thread, int QMC_getSample(s, qsa, thread, num); - phi = s[0]*2.f*M_PI; + phi = s[0]*2.f*M_PI; sqr = s[1]*sqrt(2-s[1]*s[1]); vec[0] = cos(phi)*sqr; @@ -1295,7 +1295,7 @@ static void trace_refract(float col[4], ShadeInput *shi, ShadeResult *shr) max_samples = 1; - while (samples < max_samples) { + while (samples < max_samples) { if (refraction(v_refract, shi->vn, shi->view, shi->ang)) { traflag |= RAY_INSIDE; } @@ -1515,7 +1515,7 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr) if (!(shi->combinedflag & SCE_PASS_REFRACT)) sub_v3_v3v3(diff, diff, shr->refr); - shr->alpha = minf(1.0f, tracol[3]); + shr->alpha = min_ff(1.0f, tracol[3]); } if (do_mir) { @@ -1822,7 +1822,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in } return sphere; - } + } else { float *sphere; float *vec1; @@ -1847,7 +1847,7 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, in for (a=0; a<tot; a++, vec+=3, vec1+=3) { vec1[0]= cost*cosfi*vec[0] - sinfi*vec[1] + sint*cosfi*vec[2]; vec1[1]= cost*sinfi*vec[0] + cosfi*vec[1] + sint*sinfi*vec[2]; - vec1[2]= -sint*vec[0] + cost*vec[2]; + vec1[2]= -sint*vec[0] + cost*vec[2]; } } return sphere; @@ -1981,7 +1981,7 @@ static void ray_ao_qmc(ShadeInput *shi, float ao[3], float env[3]) samples++; if (qsa && qsa->type == SAMP_TYPE_HALTON) { - /* adaptive sampling - consider samples below threshold as in shadow (or vice versa) and exit early */ + /* adaptive sampling - consider samples below threshold as in shadow (or vice versa) and exit early */ if (adapt_thresh > 0.0f && (samples > max_samples/2) ) { if (adaptive_sample_contrast_val(samples, prev, fac, adapt_thresh)) { diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index a226556828e..eb330177bac 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -789,7 +789,7 @@ int RE_WriteRenderResult(ReportList *reports, RenderResult *rr, const char *file } else { /* TODO, get the error from openexr's exception */ - BKE_report(reports, RPT_ERROR, "Error Writing Render Result, see console"); + BKE_report(reports, RPT_ERROR, "Error writing render result (see console)"); success = FALSE; } IMB_exr_close(exrhandle); diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 167e91272e2..c507d6595e0 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -303,7 +303,7 @@ static float tex_tri(float a) /* computes basic wood intensity value at x,y,z */ static float wood_int(Tex *tex, float x, float y, float z) { - float wi=0; + float wi = 0; short wf = tex->noisebasis2; /* wave form: TEX_SIN=0, TEX_SAW=1, TEX_TRI=2 */ short wt = tex->stype; /* wood type: TEX_BAND=0, TEX_RING=1, TEX_BANDNOISE=2, TEX_RINGNOISE=3 */ @@ -374,7 +374,7 @@ static float marble_int(Tex *tex, float x, float y, float z) mi = waveform[wf](mi); if (mt==TEX_SHARP) { mi = sqrt(mi); - } + } else if (mt==TEX_SHARPER) { mi = sqrt(sqrt(mi)); } @@ -494,7 +494,7 @@ static int stucci(Tex *tex, const float texvec[3], TexResult *texres) if (tex->stype) ofs*=(b2*b2); nor[0] = BLI_gNoise(tex->noisesize, texvec[0]+ofs, texvec[1], texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); - nor[1] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1]+ofs, texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); + nor[1] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1]+ofs, texvec[2], (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); nor[2] = BLI_gNoise(tex->noisesize, texvec[0], texvec[1], texvec[2]+ofs, (tex->noisetype!=TEX_NOISESOFT), tex->noisebasis); texres->tin= nor[2]; @@ -769,7 +769,7 @@ static int cubemap_glob(const float n[3], float x, float y, float z, float *adr1 else { *adr1 = (y + 1.0f) / 2.0f; *adr2 = (z + 1.0f) / 2.0f; - ret= 2; + ret= 2; } return ret; } @@ -824,8 +824,8 @@ static int cubemap(MTex *mtex, VlakRen *vlr, const float n[3], float x, float y, *adr1 = (y + 1.0f) / 2.0f; *adr2 = (z + 1.0f) / 2.0f; ret= 2; - } - } + } + } else { return cubemap_glob(n, x, y, z, adr1, adr2); } @@ -862,7 +862,7 @@ static int cubemap_ob(Object *ob, const float n[3], float x, float y, float z, f else { *adr1 = (y + 1.0f) / 2.0f; *adr2 = (z + 1.0f) / 2.0f; - ret= 2; + ret= 2; } return ret; } @@ -971,7 +971,7 @@ static void do_2d_mapping(MTex *mtex, float texvec[3], VlakRen *vlr, const float map_to_tube(area + 2, area + 3, texvec[0] + dxt[0], texvec[1] + dxt[1], texvec[2] + dxt[2]); map_to_tube(area + 4, area + 5, texvec[0] + dyt[0], texvec[1] + dyt[1], texvec[2] + dyt[2]); } - else { + else { map_to_sphere(area, area+1, texvec[0], texvec[1], texvec[2]); map_to_sphere(area + 2, area + 3, texvec[0] + dxt[0], texvec[1] + dxt[1], texvec[2] + dxt[2]); map_to_sphere(area + 4, area + 5, texvec[0] + dyt[0], texvec[1] + dyt[1], texvec[2] + dyt[2]); @@ -1262,6 +1262,14 @@ int multitex_nodes(Tex *tex, float texvec[3], float dxt[3], float dyt[3], int os do_2d_mapping(&localmtex, texvec_l, NULL, NULL, dxt_l, dyt_l); rgbnor= multitex(tex, texvec_l, dxt_l, dyt_l, osatex, texres, thread, which_output); + + { + ImBuf *ibuf = BKE_image_get_ibuf(tex->ima, &tex->iuser); + + /* don't linearize float buffers, assumed to be linear */ + if (ibuf && !(ibuf->rect_float) && R.scene_color_manage) + IMB_colormanagement_colorspace_to_scene_linear_v3(&texres->tr, ibuf->rect_colorspace); + } } return rgbnor; @@ -1745,7 +1753,7 @@ static int compatible_bump_compute(CompatibleBump *compat_bump, ShadeInput *shi, if (mtex->texco == TEXCO_UV) { /* for the uv case, use the same value for both du/dv, * since individually scaling the normal derivatives makes them useless... */ - du = minf(du, dv); + du = min_ff(du, dv); idu = (du < 1e-5f) ? bf : (bf/du); /* +u val */ @@ -2664,8 +2672,8 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float col_ copy_v3_v3(co, xyz); if (mtex->texflag & MTEX_OB_DUPLI_ORIG) { if (shi->obi && shi->obi->duplitexmat) - mul_m4_v3(shi->obi->duplitexmat, co); - } + mul_m4_v3(shi->obi->duplitexmat, co); + } mul_m4_v3(ob->imat_ren, co); if (mtex->texflag & MTEX_MAPTO_BOUNDS && ob->bb) { @@ -3078,7 +3086,7 @@ void do_sky_tex(const float rco[3], float lo[3], const float dxyview[2], float h break; } - /* placement */ + /* placement */ if (mtex->projx) texvec[0]= mtex->size[0]*(co[mtex->projx-1]+mtex->ofs[0]); else texvec[0]= mtex->size[0]*(mtex->ofs[0]); @@ -3241,7 +3249,7 @@ void do_lamp_tex(LampRen *la, const float lavec[3], ShadeInput *shi, float col_r } co= tempvec; - dx= dxt; dy= dyt; + dx= dxt; dy= dyt; if (shi->osatex) { copy_v3_v3(dxt, shi->dxlv); copy_v3_v3(dyt, shi->dylv); diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 0bfbed8e58c..217fcc3c4ac 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -185,7 +185,8 @@ static void halo_pixelstruct(HaloRen *har, RenderLayer **rlpp, int totsample, in fullsample= (totsample > 1); amount= 0; - accol[0]=accol[1]=accol[2]=accol[3]= 0.0f; + accol[0] = accol[1] = accol[2] = accol[3]= 0.0f; + col[0] = col[1] = col[2] = col[3]= 0.0f; flarec= har->flarec; while (ps) { @@ -294,11 +295,11 @@ static void halo_tile(RenderPart *pa, RenderLayer *rl) } else { - minx= MAX2(minx, testrect.xmin); - maxx= MIN2(maxx, testrect.xmax); + minx = max_ii(minx, testrect.xmin); + maxx = min_ii(maxx, testrect.xmax); - miny= MAX2(har->miny, testrect.ymin); - maxy= MIN2(har->maxy, testrect.ymax); + miny = max_ii(har->miny, testrect.ymin); + maxy = min_ii(har->maxy, testrect.ymax); for (y=miny; y<maxy; y++) { int rectofs= (y-disprect.ymin)*pa->rectx + (minx - disprect.xmin); @@ -671,7 +672,7 @@ int get_sample_layers(RenderPart *pa, RenderLayer *rl, RenderLayer **rlpp) RenderResult *rr= BLI_findlink(&pa->fullresult, sample); rlpp[sample]= BLI_findlink(&rr->layers, nr); - } + } return R.osa; } else { @@ -714,7 +715,7 @@ static void sky_tile(RenderPart *pa, RenderLayer *rl) addAlphaUnderFloat(pass, col); } } - } + } } if (y&1) @@ -772,8 +773,8 @@ static void atm_tile(RenderPart *pa, RenderLayer *rl) if (*zrect >= 9.9e10f || rgbrect[3]==0.0f) { continue; } - - if ((lar->sunsky->effect_type & LA_SUN_EFFECT_AP)) { + + if ((lar->sunsky->effect_type & LA_SUN_EFFECT_AP)) { float tmp_rgb[3]; /* skip if worldspace lamp vector is below horizon */ @@ -928,7 +929,7 @@ static void addps(ListBase *lb, intptr_t *rd, int obi, int facenr, int z, int ma PixStrMain *psm; PixStr *ps, *last= NULL; - if (*rd) { + if (*rd) { ps= (PixStr *)(*rd); while (ps) { @@ -1582,7 +1583,7 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, ObjectInstanceRe copy_v3_v3(shi->facenor, nor); shade_input_set_viewco(shi, x, y, sx, sy, z); - *area = minf(len_v3(shi->dxco) * len_v3(shi->dyco), 2.0f * orthoarea); + *area = min_ff(len_v3(shi->dxco) * len_v3(shi->dyco), 2.0f * orthoarea); shade_input_set_uv(shi); shade_input_set_normals(shi); @@ -2012,7 +2013,7 @@ void add_halo_flare(Render *re) re->display_draw(re->ddh, rr, NULL); } - R.r.mode= mode; + R.r.mode= mode; } /* ************************* bake ************************ */ @@ -2474,7 +2475,7 @@ static int get_next_bake_face(BakeShade *bs) return 0; } - BLI_lock_thread(LOCK_CUSTOM1); + BLI_lock_thread(LOCK_CUSTOM1); for (; obi; obi=obi->next, v=0) { obr= obi->obr; @@ -2516,12 +2517,12 @@ static int get_next_bake_face(BakeShade *bs) if (R.r.bake_flag & R_BAKE_CLEAR) IMB_rectfill(ibuf, (ibuf->planes == R_IMF_PLANES_RGBA) ? vec_alpha : vec_solid); - ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; - /* might be read by UI to set active image for display */ R.bakebuf= ima; - } - + } + + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; + bs->obi= obi; bs->vlr= vlr; @@ -2557,7 +2558,7 @@ static void shade_tface(BakeShade *bs) /* note, these calls only free/fill contents of zspan struct, not zspan itself */ zbuf_free_span(bs->zspan); zbuf_alloc_span(bs->zspan, bs->ibuf->x, bs->ibuf->y, R.clipcrop); - } + } bs->rectx= bs->ibuf->x; bs->recty= bs->ibuf->y; diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 1721741d64d..886f266b22f 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -244,7 +244,7 @@ VertRen *RE_findOrAddVert(ObjectRen *obr, int nr) memset(obr->vertnodes+obr->vertnodeslen, 0, TABLEINITSIZE*sizeof(VertTableNode)); obr->vertnodeslen+=TABLEINITSIZE; - if (temp) MEM_freeN(temp); + if (temp) MEM_freeN(temp); } v= obr->vertnodes[a].vert; @@ -487,7 +487,7 @@ VlakRen *RE_findOrAddVlak(ObjectRen *obr, int nr) memset(obr->vlaknodes+obr->vlaknodeslen, 0, TABLEINITSIZE*sizeof(VlakTableNode)); obr->vlaknodeslen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/ - if (temp) MEM_freeN(temp); + if (temp) MEM_freeN(temp); } v= obr->vlaknodes[a].vlak; @@ -658,7 +658,7 @@ StrandRen *RE_findOrAddStrand(ObjectRen *obr, int nr) memset(obr->strandnodes+obr->strandnodeslen, 0, TABLEINITSIZE*sizeof(StrandTableNode)); obr->strandnodeslen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/ - if (temp) MEM_freeN(temp); + if (temp) MEM_freeN(temp); } v= obr->strandnodes[a].strand; @@ -892,7 +892,7 @@ HaloRen *RE_findOrAddHalo(ObjectRen *obr, int nr) if (temp) memcpy(obr->bloha, temp, obr->blohalen*sizeof(void*)); memset(&(obr->bloha[obr->blohalen]), 0, TABLEINITSIZE*sizeof(void*)); obr->blohalen+=TABLEINITSIZE; /*Does this really need to be power of 2?*/ - if (temp) MEM_freeN(temp); + if (temp) MEM_freeN(temp); } h= obr->bloha[a]; diff --git a/source/blender/render/intern/source/shadbuf.c b/source/blender/render/intern/source/shadbuf.c index bed3fb5f754..2253557955e 100644 --- a/source/blender/render/intern/source/shadbuf.c +++ b/source/blender/render/intern/source/shadbuf.c @@ -89,7 +89,7 @@ extern struct Render R; static void copy_to_ztile(int *rectz, int size, int x1, int y1, int tile, char *r1) { - int len4, *rz; + int len4, *rz; int x2, y2; x2= x1+tile; @@ -528,21 +528,21 @@ static void compress_shadowbuf(ShadBuf *shb, int *rectz, int square) for (y=0; y<size; y+=16) { if (y< size/2) miny= y+15-size/2; - else miny= y-size/2; + else miny= y-size/2; for (x=0; x<size; x+=16) { /* is tile within spotbundle? */ a= size/2; if (x< a) minx= x+15-a; - else minx= x-a; + else minx= x-a; dist= sqrt( (float)(minx*minx+miny*miny) ); if (square==0 && dist>(float)(a+12)) { /* 12, tested with a onlyshadow lamp */ a= 256; verg= 0; /* 0x80000000; */ /* 0x7FFFFFFF; */ rz1= (&verg)+1; - } + } else { copy_to_ztile(rectz, size, x, y, 16, rcline); rz1= (int *)rcline; @@ -669,8 +669,8 @@ static void shadowbuf_autoclip(Render *re, LampRen *lar) clipflag[vlr->v2->index]= 1; clipflag[vlr->v3->index]= 1; if (vlr->v4) clipflag[vlr->v4->index]= 1; - } - } + } + } /* calculate min and max */ for (a=0; a< obr->totvert;a++) { @@ -856,10 +856,10 @@ void threaded_makeshadowbufs(Render *re) if (lar->shb) totthread++; - totthread= MIN2(totthread, re->r.threads); + totthread = min_ii(totthread, re->r.threads); } else - totthread= 1; /* preview render */ + totthread = 1; /* preview render */ if (totthread <= 1) { for (lar=re->lampren.first; lar; lar= lar->next) { @@ -1394,7 +1394,7 @@ float shadow_halo(LampRen *lar, const float p1[3], const float p2[3]) } } - labda = minf(labdax, labday); + labda = min_ff(labdax, labday); if (labda==labdao || labda>=1.0f) break; zf= zf1 + labda*(zf2-zf1); @@ -1867,7 +1867,7 @@ static void isb_bsp_recalc_box(ISBBranch *root) init_box(&root->box); for (a=root->totsamp-1; a>=0; a--) bound_boxf(&root->box, root->samples[a]->zco); - } + } } /* callback function for zbuf clip */ @@ -2040,7 +2040,7 @@ static void isb_bsp_fillfaces(Render *re, LampRen *lar, ISBBranch *root) if (vlr->v4) c4= testclip(hoco[3]); - /* ***** NO WIRE YET */ + /* ***** NO WIRE YET */ if (ma->material_type == MA_TYPE_WIRE) { if (vlr->v4) zbufclipwire(&zspan, i, a+1, vlr->ec, hoco[0], hoco[1], hoco[2], hoco[3], c1, c2, c3, c4); @@ -2187,7 +2187,7 @@ static int isb_add_samples(RenderPart *pa, ISBBranch *root, MemArena *memarena, } if (bsp_err) break; } - } + } MEM_freeN(xcos); MEM_freeN(ycos); @@ -2394,7 +2394,7 @@ static int isb_add_samples_transp(RenderPart *pa, ISBBranch *root, MemArena *mem } if (bsp_err) break; } - } + } MEM_freeN(xcos); MEM_freeN(ycos); diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 36e9f4cb785..db93a21de2d 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -236,7 +236,7 @@ void vlr_set_uv_indices(VlakRen *vlr, int *i1, int *i2, int *i3) /* 1---2 1---2 0 = orig face, 1 = new face */ /* Update vert nums to point to correct verts of original face */ - if (vlr->flag & R_DIVIDE_24) { + if (vlr->flag & R_DIVIDE_24) { if (vlr->flag & R_FACE_SPLIT) { (*i1)++; (*i2)++; (*i3)++; } @@ -777,7 +777,7 @@ void shade_input_set_uv(ShadeInput *shi) CLAMP(shi->u, -2.0f, 1.0f); CLAMP(shi->v, -2.0f, 1.0f); } - } + } } void shade_input_set_normals(ShadeInput *shi) diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 100cbd416e0..ea155f944e4 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -114,7 +114,7 @@ static void fogcolor(const float colf[3], float *rco, float *view) addAlphaOverFloat(colf, hor); sub_v3_v3(vec, dview); - } + } } #endif @@ -168,7 +168,7 @@ float mistfactor(float zcor, float const co[3]) } } - return (1.0f-fac)* (1.0f-R.wrld.misi); + return (1.0f-fac)* (1.0f-R.wrld.misi); } static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) @@ -228,7 +228,7 @@ static void spothalo(struct LampRen *lar, ShadeInput *shi, float *intens) } } - /* scale z to make sure volume is normalized */ + /* scale z to make sure volume is normalized */ nray[2] *= (double)lar->sh_zfac; /* nray does not need normalization */ @@ -548,7 +548,7 @@ static float spec(float inp, int hard) b1= inp*inp; /* avoid FPE */ - if (b1<0.01f) b1= 0.01f; + if (b1<0.01f) b1= 0.01f; if ((hard & 1)==0) inp= 1.0f; if (hard & 2) inp*= b1; @@ -561,7 +561,7 @@ static float spec(float inp, int hard) b1*= b1; /* avoid FPE */ - if (b1<0.001f) b1= 0.0f; + if (b1<0.001f) b1= 0.0f; if (hard & 32) inp*= b1; b1*= b1; @@ -569,7 +569,7 @@ static float spec(float inp, int hard) b1*= b1; if (hard & 128) inp*=b1; - if (b1<0.001f) b1= 0.0f; + if (b1<0.001f) b1= 0.0f; if (hard & 256) { b1*= b1; @@ -827,7 +827,7 @@ static float Minnaert_Diff(float nl, const float n[3], const float v[3], float d nv = 0.0f; if (darkness <= 1.0f) - i = nl * pow(maxf(nv * nl, 0.1f), (darkness - 1.0f) ); /*The Real model*/ + i = nl * pow(max_ff(nv * nl, 0.1f), (darkness - 1.0f) ); /*The Real model*/ else i = nl * pow( (1.001f - nv), (darkness - 1.0f) ); /*Nvidia model*/ @@ -1233,7 +1233,7 @@ float lamp_get_visibility(LampRen *lar, const float co[3], float lv[3], float *d copy_v3_v3(lvrot, lv); mul_m3_v3(lar->imat, lvrot); - x = maxf(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2])); + x = max_ff(fabsf(lvrot[0]/lvrot[2]), fabsf(lvrot[1]/lvrot[2])); /* 1.0f/(sqrt(1+x*x)) is equivalent to cos(atan(x)) */ inpr= 1.0f/(sqrt(1.0f+x*x)); @@ -1317,7 +1317,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int if (lar->mode & LA_TEXTURE) do_lamp_tex(lar, lv, shi, lacol, LA_TEXTURE); if (lar->mode & LA_SHAD_TEX) do_lamp_tex(lar, lv, shi, lashdw, LA_SHAD_TEX); - /* tangent case; calculate fake face normal, aligned with lampvector */ + /* tangent case; calculate fake face normal, aligned with lampvector */ /* note, vnor==vn is used as tangent trigger for buffer shadow */ if (vlr->flag & R_TANGENT) { float cross[3], nstrand[3], blend; @@ -1363,7 +1363,7 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int /* inp = dotproduct, is = shader result, i = lamp energy (with shadow), i_noshad = i without shadow */ inp= dot_v3v3(vn, lv); - /* phong threshold to prevent backfacing faces having artefacts on ray shadow (terminator problem) */ + /* phong threshold to prevent backfacing faces having artifacts on ray shadow (terminator problem) */ /* this complex construction screams for a nicer implementation! (ton) */ if (R.r.mode & R_SHADOW) { if (ma->mode & MA_SHADOW) { @@ -1637,7 +1637,7 @@ static void shade_lamp_loop_only_shadow(ShadeInput *shi, ShadeResult *shr) } } - /* quite disputable this... also note it doesn't mirror-raytrace */ + /* quite disputable this... also note it doesn't mirror-raytrace */ if ((R.wrld.mode & (WO_AMB_OCC|WO_ENV_LIGHT)) && shi->amb!=0.0f) { float f; @@ -1851,7 +1851,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr) } } - if (shi->combinedflag & SCE_PASS_SHADOW) + if (shi->combinedflag & SCE_PASS_SHADOW) copy_v3_v3(shr->combined, shr->shad); /* note, no ';' ! */ else copy_v3_v3(shr->combined, shr->diff); diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index 77d68e6c85a..6d0e15ea46e 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -307,7 +307,7 @@ ScatterSettings *scatter_settings_new(float refl, float radius, float ior, float ss->Fdr= -1.440f/ior*ior + 0.710f/ior + 0.668f + 0.0636f*ior; ss->A= (1.0f + ss->Fdr)/(1.0f - ss->Fdr); ss->ld= radius; - ss->ro= minf(refl, 0.999f); + ss->ro= min_ff(refl, 0.999f); ss->color= ss->ro*reflfac + (1.0f-reflfac); ss->alpha_= compute_reduced_albedo(ss); diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index dc3225b7f09..6e2e97b95de 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -545,7 +545,7 @@ static void do_strand_fillac(void *handle, int x, int y, float u, float v, float bufferz= 0x7FFFFFFF; if (spart->rectmask) maskz= 0x7FFFFFFF; - if (*rd) { + if (*rd) { for (ps= (PixStr *)(*rd); ps; ps= ps->next) { if (mask & ps->mask) { bufferz= ps->z; diff --git a/source/blender/render/intern/source/sunsky.c b/source/blender/render/intern/source/sunsky.c index 1288b0305b1..e4a42fcd675 100644 --- a/source/blender/render/intern/source/sunsky.c +++ b/source/blender/render/intern/source/sunsky.c @@ -217,8 +217,7 @@ void InitSunSky(struct SunSky *sunsky, float turb, const float toSun[3], float h sunsky->perez_y[3] = -0.04405f * T - 1.65369f; sunsky->perez_y[4] = -0.01092f * T + 0.05291f; - /* suggested by glome in - * http://projects.blender.org/tracker/?func=detail&atid=127&aid=8063&group_id=9*/ + /* suggested by glome in patch [#8063] */ sunsky->perez_Y[0] *= sunsky->horizon_brightness; sunsky->perez_x[0] *= sunsky->horizon_brightness; sunsky->perez_y[0] *= sunsky->horizon_brightness; @@ -330,8 +329,8 @@ static void ComputeAttenuatedSunlight(float theta, int turbidity, float fTau[3]) int i; float fLambda[3]; - fLambda[0] = 0.65f; - fLambda[1] = 0.57f; + fLambda[0] = 0.65f; + fLambda[1] = 0.57f; fLambda[2] = 0.475f; fAlpha = 1.3f; diff --git a/source/blender/render/intern/source/volume_precache.c b/source/blender/render/intern/source/volume_precache.c index fb7ea38ef68..8757be740f3 100644 --- a/source/blender/render/intern/source/volume_precache.c +++ b/source/blender/render/intern/source/volume_precache.c @@ -270,7 +270,7 @@ BLI_INLINE int ms_I(int x, int y, int z, int *n) /* has a pad of 1 voxel surroun BLI_INLINE int v_I_pad(int x, int y, int z, int *n) /* has a pad of 1 voxel surrounding the core for boundary simulation */ { /* same ordering to light cache, with padding */ - return z*(n[1]+2)*(n[0]+2) + y*(n[0]+2) + x; + return z*(n[1]+2)*(n[0]+2) + y*(n[0]+2) + x; } BLI_INLINE int lc_to_ms_I(int x, int y, int z, int *n) @@ -389,7 +389,7 @@ static void multiple_scattering_diffusion(Render *re, VolumePrecache *vp, Materi const int j = ms_I(x, y, z, n); //ms index time= PIL_check_seconds_timer(); - c++; + c++; if (vp->data_r[i] > 0.0f) sr[j] += vp->data_r[i]; if (vp->data_g[i] > 0.0f) diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c index 220fcd3e986..fe4cff76093 100644 --- a/source/blender/render/intern/source/volumetric.c +++ b/source/blender/render/intern/source/volumetric.c @@ -76,7 +76,7 @@ static float vol_get_shadow(ShadeInput *shi, LampRen *lar, const float co[3]) if (lar->shb) { float dxco[3] = {0.f, 0.f, 0.f}, dyco[3] = {0.f, 0.f, 0.f}; - visibility = testshadowbuf(&R, lar->shb, co, dxco, dyco, 1.0, 0.0); + visibility = testshadowbuf(&R, lar->shb, co, dxco, dyco, 1.0, 0.0); } else if (lar->mode & LA_SHAD_RAY) { /* trace shadow manually, no good lamp api atm */ @@ -205,7 +205,7 @@ static void vol_trace_behind(ShadeInput *shi, VlakRen *vlr, const float co[3], f else { shadeSkyView(col_r, co, shi->view, NULL, shi->thread); shadeSunView(col_r, shi->view); - } + } } @@ -221,7 +221,7 @@ static void vol_get_precached_scattering(Render *re, ShadeInput *shi, float scat /* find sample point in global space bounding box 0.0-1.0 */ global_bounds_obi(re, shi->obi, bbmin, bbmax); sub_v3_v3v3(dim, bbmax, bbmin); - mul_v3_m4v3(world_co, re->viewinv, co); + mul_v3_m4v3(world_co, re->viewinv, co); /* sample_co in 0.0-1.0 */ sample_co[0] = (world_co[0] - bbmin[0]) / dim[0]; diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c index 7eccacb816d..b486407c61c 100644 --- a/source/blender/render/intern/source/voxeldata.c +++ b/source/blender/render/intern/source/voxeldata.c @@ -285,7 +285,7 @@ static void init_frame_smoke(VoxelData *vd, float cfra) } /* always store copy, as smoke internal data can change */ - totRes= vd_resol_size(vd); + totRes = vd_resol_size(vd); vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data"); memcpy(vd->dataset, flame, sizeof(float)*totRes); } @@ -414,7 +414,7 @@ void make_voxeldata(struct Render *re) int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texres) { - VoxelData *vd = tex->vd; + VoxelData *vd = tex->vd; float co[3], offset[3] = {0.5, 0.5, 0.5}, a; int retval = (vd->data_type == TEX_VD_RGBA_PREMUL) ? TEX_RGB : TEX_INT; int depth = (vd->data_type == TEX_VD_RGBA_PREMUL) ? 4 : 1; @@ -482,7 +482,7 @@ int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texre break; case TEX_VD_LINEAR: *result = BLI_voxel_sample_trilinear(dataset, vd->resol, co); - break; + break; case TEX_VD_QUADRATIC: *result = BLI_voxel_sample_triquadratic(dataset, vd->resol, co); break; @@ -515,5 +515,5 @@ int voxeldatatex(struct Tex *tex, const float texvec[3], struct TexResult *texre texres->ta = texres->tin; BRICONTRGB; - return retval; + return retval; } diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index ba62baae897..8e53ce11e4d 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -150,7 +150,7 @@ static void zbuf_add_to_span(ZSpan *zspan, const float *v1, const float *v2) } else { dx0 = 0.0f; - xs0 = minf(minv[0], maxv[0]); + xs0 = min_ff(minv[0], maxv[0]); } /* empty span */ @@ -409,7 +409,7 @@ static void zbuffillAc4(ZSpan *zspan, int obi, int zvlnr, if (apn->p[3]==zvlnr && apn->obi[3]==obi) {apn->mask[3]|= mask; break; } if (apn->next==NULL) apn->next= addpsA(zspan); apn= apn->next; - } + } } } zverg+= zxd; @@ -501,7 +501,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co if (apn->p[3]==zvlnr && apn->obi[3]==obi) {apn->mask[3]|= mask; break; } if (apn->next==0) apn->next= addpsA(zspan); apn= apn->next; - } + } } } } @@ -572,7 +572,7 @@ static void zbuflineAc(ZSpan *zspan, int obi, int zvlnr, const float vec1[3], co if (apn->p[3]==zvlnr) {apn->mask[3]|= mask; break; } if (apn->next==0) apn->next= addpsA(zspan); apn= apn->next; - } + } } } } @@ -1029,7 +1029,7 @@ void zbufsinglewire(ZSpan *zspan, int obi, int zvlnr, const float ho1[4], const /** * Fill the z buffer, but invert z order, and add the face index to - * the corresponing face buffer. + * the corresponding face buffer. * * This is one of the z buffer fill functions called in zbufclip() and * zbufwireclip(). @@ -1624,7 +1624,7 @@ static void clippyra(float *labda, float *v1, float *v2, int *b2, int *b3, int a else { dw= clipcrop*(v2[3]-v1[3]); v13= clipcrop*v1[3]; - } + } /* according the original article by Liang&Barsky, for clipping of * homogeneous coordinates with viewplane, the value of "0" is used instead of "-w" . * This differs from the other clipping cases (like left or top) and I considered @@ -1682,7 +1682,7 @@ static void makevertpyra(float *vez, float *labda, float **trias, float *v1, flo adr[1]= v1[1]+l1*(v2[1]-v1[1]); adr[2]= v1[2]+l1*(v2[2]-v1[2]); adr[3]= v1[3]+l1*(v2[3]-v1[3]); - } + } else trias[*b1]= v1; (*b1)++; @@ -2022,7 +2022,7 @@ static void zmask_rect(int *rectz, int *rectp, int xs, int ys, int neg) EXTEND_PIXEL(row1 + 2); EXTEND_PIXEL(row2 + 2); EXTEND_PIXEL(row3 + 2); - } + } if (tot) { len++; curz[0]= (int)(z/(float)tot); @@ -2047,7 +2047,7 @@ static void zmask_rect(int *rectz, int *rectp, int xs, int ys, int neg) if (rectp[len]==0) { rectz[len] = -0x7FFFFFFF; rectp[len]= -1; /* env code */ - } + } } } } @@ -3233,7 +3233,7 @@ static void copyto_abufz(RenderPart *pa, int *arectz, int *rectmask, int sample) *rza= 0x7FFFFFFF; if (rectmask) *rma= 0x7FFFFFFF; - if (*rd) { + if (*rd) { /* when there's a sky pixstruct, fill in sky-Z, otherwise solid Z */ for (ps= (PixStr *)(*rd); ps; ps= ps->next) { if (sample & ps->mask) { @@ -3517,7 +3517,7 @@ static void add_transp_obindex(RenderLayer *rl, int offset, Object *ob) RenderPass *rpass; for (rpass= rl->passes.first; rpass; rpass= rpass->next) { - if (rpass->passtype == SCE_PASS_INDEXOB||rpass->passtype == SCE_PASS_INDEXMA) { + if (rpass->passtype == SCE_PASS_INDEXOB) { float *fp= rpass->rect + offset; *fp= (float)ob->index; break; @@ -3525,6 +3525,19 @@ static void add_transp_obindex(RenderLayer *rl, int offset, Object *ob) } } +static void add_transp_material_index(RenderLayer *rl, int offset, Material *mat) +{ + RenderPass *rpass; + + for (rpass= rl->passes.first; rpass; rpass= rpass->next) { + if (rpass->passtype == SCE_PASS_INDEXMA) { + float *fp= rpass->rect + offset; + *fp= (float)mat->index; + break; + } + } +} + /* ONLY OSA! merge all shaderesult samples to one */ /* target should have been cleared */ static void merge_transp_passes(RenderLayer *rl, ShadeResult *shr) @@ -3876,7 +3889,7 @@ static int addtosamp_shr(ShadeResult *samp_shr, ShadeSample *ssamp, int addpassf addAlphaUnderFloat(samp_shr->combined, shr->combined); - samp_shr->z = minf(samp_shr->z, shr->z); + samp_shr->z = min_ff(samp_shr->z, shr->z); if (addpassflag & SCE_PASS_VECTOR) { copy_v4_v4(samp_shr->winspeed, shr->winspeed); @@ -4129,10 +4142,12 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas } } if (addpassflag & SCE_PASS_INDEXMA) { - ObjectRen *obr= R.objectinstance[zrow[totface-1].obi].obr; - if (obr->ob) { + ObjectRen *obr = R.objectinstance[zrow[totface-1].obi].obr; + VlakRen *vr = obr->vlaknodes->vlak; + Material *mat = vr->mat; + if (mat) { for (a= 0; a<totfullsample; a++) - add_transp_obindex(rlpp[a], od, obr->ob); + add_transp_material_index(rlpp[a], od, mat); } } @@ -4243,7 +4258,7 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas MEM_freeN(APixbufstrand); if (sscache) strand_shade_cache_free(sscache); - freepsA(&apsmbase); + freepsA(&apsmbase); if (R.r.mode & R_SHADOW) ISB_free(pa); diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 99d1c14059a..d1c08f43d07 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -425,7 +425,7 @@ typedef struct wmEvent { char ascii; /* from ghost, fallback if utf8 isn't set */ char pad; - /* previous state */ + /* previous state, used for double click and the 'click' */ short prevtype; short prevval; int prevx, prevy; @@ -436,7 +436,8 @@ typedef struct wmEvent { short shift, ctrl, alt, oskey; /* oskey is apple or windowskey, value denotes order of pressed */ short keymodifier; /* rawkey modifier */ - short pad1; + /* set in case a KM_PRESS went by unhandled */ + short check_click; /* keymap item, set by handler (weak?) */ const char *keymap_idname; diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index a34d294461c..8fe387765ce 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -78,7 +78,7 @@ void WM_operator_free(wmOperator *op) if (op->py_instance) { /* do this first in case there are any __del__ functions or * similar that use properties */ - BPY_DECREF(op->py_instance); + BPY_DECREF_RNA_INVALIDATE(op->py_instance); } #endif diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c index 7853b40c98a..ebde6407a48 100644 --- a/source/blender/windowmanager/intern/wm_cursors.c +++ b/source/blender/windowmanager/intern/wm_cursors.c @@ -61,7 +61,7 @@ static GHOST_TStandardCursor convert_cursor(int curs) case CURSOR_FACESEL: return GHOST_kStandardCursorRightArrow; case CURSOR_WAIT: return GHOST_kStandardCursorWait; case CURSOR_EDIT: return GHOST_kStandardCursorCrosshair; - case CURSOR_HELP: + case CURSOR_HELP: #ifdef __APPLE__ return GHOST_kStandardCursorLeftRight; #else @@ -317,7 +317,7 @@ void WM_cursor_time(wmWindow *win, int nr) /* Because defining a cursor mixes declarations and executable code * each cursor needs it's own scoping block or it would be split up * over several hundred lines of code. To enforce/document this better - * I define 2 pretty braindead macros so it's obvious what the extra "[]" + * I define 2 pretty brain-dead macros so it's obvious what the extra "[]" * are for */ #define BEGIN_CURSOR_BLOCK { @@ -560,7 +560,7 @@ BEGIN_CURSOR_BLOCK BlenderCursor[BC_CROSSCURSOR] = &CrossCursor; END_CURSOR_BLOCK - /********************** EditCross Cursor ***********************/ + /********************** EditCross Cursor ***********************/ BEGIN_CURSOR_BLOCK static char editcross_sbm[] = { 0x0e, 0x00, 0x11, 0x00, 0x1d, 0x00, 0x19, 0x03, @@ -775,7 +775,7 @@ BEGIN_CURSOR_BLOCK END_CURSOR_BLOCK - /********************** TextEdit Cursor ***********************/ + /********************** TextEdit Cursor ***********************/ BEGIN_CURSOR_BLOCK static char textedit_sbm[] = { 0xe0, 0x03, 0x10, 0x04, 0x60, 0x03, 0x40, 0x01, @@ -808,7 +808,7 @@ BEGIN_CURSOR_BLOCK END_CURSOR_BLOCK - /********************** Paintbrush Cursor ***********************/ + /********************** Paintbrush Cursor ***********************/ BEGIN_CURSOR_BLOCK static char paintbrush_sbm[] = { diff --git a/source/blender/windowmanager/intern/wm_dragdrop.c b/source/blender/windowmanager/intern/wm_dragdrop.c index bbb2a54887e..0581000e07c 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.c +++ b/source/blender/windowmanager/intern/wm_dragdrop.c @@ -141,7 +141,7 @@ void wm_dropbox_free(void) BLI_freelistN(&dm->dropboxes); } - BLI_freelistN(&dropboxes); + BLI_freelistN(&dropboxes); } /* *********************************** */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 73950bdfa19..9e072c4b03a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -339,6 +339,11 @@ static int wm_handler_ui_call(bContext *C, wmEventHandler *handler, wmEvent *eve int is_wheel = ELEM(event->type, WHEELUPMOUSE, WHEELDOWNMOUSE); int retval; + /* UI code doesn't handle return values - it just always returns break. + to make the DBL_CLICK conversion work, we just don't send this to UI */ + if (event->val == KM_DBL_CLICK) + return WM_HANDLER_CONTINUE; + /* UI is quite aggressive with swallowing events, like scrollwheel */ /* I realize this is not extremely nice code... when UI gets keymaps it can be maybe smarter */ if (do_wheel_ui == FALSE) { @@ -848,7 +853,7 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event, WM_operator_last_properties_init(op); } - if ((G.debug & G_DEBUG_EVENTS) && event && event->type != MOUSEMOVE) { + if ((G.debug & G_DEBUG_HANDLERS) && event && event->type != MOUSEMOVE) { printf("%s: handle evt %d win %d op %s\n", __func__, event ? event->type : 0, CTX_wm_screen(C)->subwinactive, ot->idname); } @@ -1370,13 +1375,30 @@ static void wm_event_modalkeymap(const bContext *C, wmOperator *op, wmEvent *eve for (kmi = keymap->items.first; kmi; kmi = kmi->next) { if (wm_eventmatch(event, kmi)) { + event->prevtype = event->type; + event->prevval = event->val; event->type = EVT_MODAL_MAP; event->val = kmi->propvalue; + + break; } } } } +/* bad hacking event system... better restore event type for checking of KM_CLICK for example */ +/* XXX modal maps could use different method (ton) */ +static void wm_event_modalmap_end(wmEvent *event) +{ + if (event->type == EVT_MODAL_MAP) { + event->type = event->prevtype; + event->prevtype = 0; + event->val = event->prevval; + event->prevval = 0; + } + +} + /* Warning: this function removes a modal handler, when finished */ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHandler *handler, wmEvent *event, PointerRNA *properties) @@ -1403,7 +1425,8 @@ static int wm_handler_operator_call(bContext *C, ListBase *handlers, wmEventHand retval = ot->modal(C, op, event); OPERATOR_RETVAL_CHECK(retval); - + wm_event_modalmap_end(event); + /* when this is _not_ the case the modal modifier may have loaded * a new blend file (demo mode does this), so we have to assume * the event, operator etc have all been freed. - campbell */ @@ -1672,10 +1695,13 @@ static int wm_action_not_handled(int action) return action == WM_HANDLER_CONTINUE || action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL); } -static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) +static int wm_handlers_do_intern(bContext *C, wmEvent *event, ListBase *handlers) { #ifndef NDEBUG - const int do_debug_handler = (G.debug & G_DEBUG_EVENTS); + const int do_debug_handler = (G.debug & G_DEBUG_HANDLERS) + /* comment this out to flood the console! (if you really want to test) */ + && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) + ; #endif wmWindowManager *wm = CTX_wm_manager(C); wmEventHandler *handler, *nexthandler; @@ -1844,49 +1870,58 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) } } - /* test for CLICK event */ - if (wm_action_not_handled(action) && event->val == KM_RELEASE) { - wmWindow *win = CTX_wm_window(C); + if (action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL)) + wm_cursor_arrow_move(CTX_wm_window(C), event); - if (win && win->eventstate->prevtype == event->type && win->eventstate->prevval == KM_PRESS) { - /* test for double click first, - * note1: this can be problematic because single click operators can get the - * double click event but then with old mouse coords which is highly confusing, - * so check for mouse moves too. - * note2: the first click event will be handled but still used to create a - * double click event if clicking again quickly. - * If no double click events are found it will fallback to a single click. - * So a double click event can result in 2 successive single click calls - * if its not handled by the keymap - campbell */ - if ((ABS(event->x - win->eventstate->prevclickx)) <= 2 && - (ABS(event->y - win->eventstate->prevclicky)) <= 2 && - ((PIL_check_seconds_timer() - win->eventstate->prevclicktime) * 1000 < U.dbl_click_time)) - { - event->val = KM_DBL_CLICK; - /* removed this because in cases where we're this is used as a single click - * event, this will give old coords, - * since the distance is checked above, using new coords should be ok. */ - // event->x = win->eventstate->prevclickx; - // event->y = win->eventstate->prevclicky; - action |= wm_handlers_do(C, event, handlers); - } + return action; +} - if (wm_action_not_handled(action)) { - event->val = KM_CLICK; - action |= wm_handlers_do(C, event, handlers); +/* this calls handlers twice - to solve (double-)click events */ +static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers) +{ + int action = wm_handlers_do_intern(C, event, handlers); + + if (!ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) && !ISTIMER(event->type)) { + + /* test for CLICK events */ + if (wm_action_not_handled(action)) { + wmWindow *win = CTX_wm_window(C); + + /* eventstate stores if previous event was a KM_PRESS, in case that + wasn't handled, the KM_RELEASE will become a KM_CLICK */ + + if (win && event->val == KM_PRESS) { + win->eventstate->check_click = TRUE; } + + if (win && win->eventstate->prevtype == event->type) { + + if (event->val == KM_RELEASE && win->eventstate->prevval == KM_PRESS && win->eventstate->check_click == TRUE) { + event->val = KM_CLICK; + // printf("add KM_CLICK\n"); + action |= wm_handlers_do_intern(C, event, handlers); - - /* revert value if not handled */ - if (wm_action_not_handled(action)) { - event->val = KM_RELEASE; + event->val = KM_RELEASE; + } + else if (event->val == KM_DBL_CLICK) { + event->val = KM_PRESS; + action |= wm_handlers_do_intern(C, event, handlers); + + /* revert value if not handled */ + if (wm_action_not_handled(action)) { + event->val = KM_DBL_CLICK; + } + } } } + else { + wmWindow *win = CTX_wm_window(C); + + if(win) + win->eventstate->check_click = 0; + } } - if (action == (WM_HANDLER_BREAK | WM_HANDLER_MODAL)) - wm_cursor_arrow_move(CTX_wm_window(C), event); - return action; } @@ -2064,7 +2099,7 @@ void wm_event_do_handlers(bContext *C) while ( (event = win->queue.first) ) { int action = WM_HANDLER_CONTINUE; - if ((G.debug & G_DEBUG_EVENTS) && event && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { + if ((G.debug & G_DEBUG_HANDLERS) && event && !ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { printf("%s: pass on evt %d val %d\n", __func__, event->type, event->val); } @@ -2180,40 +2215,6 @@ void wm_event_do_handlers(bContext *C) } } - /* store last event for this window */ - /* mousemove and timer events don't overwrite last type */ - if (!ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE) && !ISTIMER(event->type)) { - if (wm_action_not_handled(action)) { - if (win->eventstate->prevtype == event->type) { - /* set click time on first click (press -> release) */ - if (win->eventstate->prevval == KM_PRESS && event->val == KM_RELEASE) { - win->eventstate->prevclicktime = PIL_check_seconds_timer(); - win->eventstate->prevclickx = event->x; - win->eventstate->prevclicky = event->y; - } - } - else { - /* reset click time if event type not the same */ - win->eventstate->prevclicktime = 0; - } - - win->eventstate->prevval = event->val; - win->eventstate->prevtype = event->type; - } - else if (event->val == KM_CLICK) { /* keep click for double click later */ - win->eventstate->prevtype = event->type; - win->eventstate->prevval = event->val; - win->eventstate->prevclicktime = PIL_check_seconds_timer(); - win->eventstate->prevclickx = event->x; - win->eventstate->prevclicky = event->y; - } - else { /* reset if not */ - win->eventstate->prevtype = -1; - win->eventstate->prevval = 0; - win->eventstate->prevclicktime = 0; - } - } - /* unlink and free here, blender-quit then frees all */ BLI_remlink(&win->queue, event); wm_event_free(event); @@ -2622,7 +2623,7 @@ static void update_tablet_data(wmWindow *win, wmEvent *event) event->custom = EVT_DATA_TABLET; event->customdata = wmtab; event->customdatafree = 1; - } + } } /* adds customdata to event */ @@ -2801,7 +2802,12 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U case GHOST_kEventButtonUp: { GHOST_TEventButtonData *bd = customdata; + + /* copy prev state to event state */ + evt->prevval = evt->val; + evt->prevtype = evt->type; + /* get value and type from ghost */ event.val = (type == GHOST_kEventButtonDown) ? KM_PRESS : KM_RELEASE; if (bd->button == GHOST_kButtonMaskLeft) @@ -2815,6 +2821,10 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U else event.type = MIDDLEMOUSE; + /* copy to event state */ + evt->val = event.val; + evt->type = event.type; + if (win->active == 0) { int cx, cy; @@ -2825,6 +2835,21 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U event.y = evt->y = cy; } + /* double click test */ + if (event.type == evt->prevtype && event.val == KM_PRESS) { + if ((ABS(event.x - evt->prevclickx)) <= 2 && + (ABS(event.y - evt->prevclicky)) <= 2 && + ((PIL_check_seconds_timer() - evt->prevclicktime) * 1000 < U.dbl_click_time)) + { + event.val = KM_DBL_CLICK; + } + } + if (event.val == KM_RELEASE) { + evt->prevclicktime = PIL_check_seconds_timer(); + evt->prevclickx = event.x; + evt->prevclicky = event.y; + } + /* add to other window if event is there (not to both!) */ owin = wm_event_cursor_other_windows(wm, win, &event); if (owin) { @@ -2855,6 +2880,14 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U memcpy(event.utf8_buf, kd->utf8_buf, sizeof(event.utf8_buf)); /* might be not null terminated*/ event.val = (type == GHOST_kEventKeyDown) ? KM_PRESS : KM_RELEASE; + /* copy prev state to event state */ + evt->prevval = evt->val; + evt->prevtype = evt->type; + + /* copy to event state */ + evt->val = event.val; + evt->type = event.type; + /* exclude arrow keys, esc, etc from text input */ if (type == GHOST_kEventKeyUp) { event.ascii = '\0'; @@ -2880,28 +2913,28 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U } } - /* modifiers */ + /* modifiers assign to eventstate, so next event gets the modifer (makes modifier key events work) */ /* assigning both first and second is strange - campbell */ switch (event.type) { case LEFTSHIFTKEY: case RIGHTSHIFTKEY: - event.shift = evt->shift = (event.val == KM_PRESS) ? - ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : - FALSE; + evt->shift = (event.val == KM_PRESS) ? + ((evt->ctrl || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; break; case LEFTCTRLKEY: case RIGHTCTRLKEY: - event.ctrl = evt->ctrl = (event.val == KM_PRESS) ? - ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : - FALSE; + evt->ctrl = (event.val == KM_PRESS) ? + ((evt->shift || evt->alt || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; break; case LEFTALTKEY: case RIGHTALTKEY: - event.alt = evt->alt = (event.val == KM_PRESS) ? - ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : - FALSE; + evt->alt = (event.val == KM_PRESS) ? + ((evt->ctrl || evt->shift || evt->oskey) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; break; case OSKEY: - event.oskey = evt->oskey = (event.val == KM_PRESS) ? - ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : - FALSE; + evt->oskey = (event.val == KM_PRESS) ? + ((evt->ctrl || evt->alt || evt->shift) ? (KM_MOD_FIRST | KM_MOD_SECOND) : KM_MOD_FIRST) : + FALSE; break; default: if (event.val == KM_PRESS && event.keymodifier == 0) @@ -2911,12 +2944,24 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U break; } + /* double click test */ + if (event.type == evt->prevtype && event.val == KM_PRESS) { + if ((ABS(event.x - evt->prevclickx)) <= 2 && + (ABS(event.y - evt->prevclicky)) <= 2 && + ((PIL_check_seconds_timer() - evt->prevclicktime) * 1000 < U.dbl_click_time)) + { + // printf("double click\n"); + evt->val = event.val = KM_DBL_CLICK; + } + } + /* this case happens on some systems that on holding a key pressed, * generate press events without release, we still want to keep the * modifier in win->eventstate, but for the press event of the same * key we don't want the key modifier */ if (event.keymodifier == event.type) event.keymodifier = 0; + /* this case happened with an external numpad, it's not really clear * why, but it's also impossible to map a key modifier to an unknwon * key, so it shouldn't harm */ @@ -2927,6 +2972,12 @@ void wm_event_add_ghostevent(wmWindowManager *wm, wmWindow *win, int type, int U if (event.type == ESCKEY && event.val == KM_PRESS) G.is_break = TRUE; + if (event.val == KM_RELEASE) { + evt->prevclicktime = PIL_check_seconds_timer(); + evt->prevclickx = event.x; + evt->prevclicky = event.y; + } + wm_event_add(win, &event); break; diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 433c447bfd4..5baf223dc3e 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -718,7 +718,7 @@ static ImBuf *blend_file_thumb(Scene *scene, bScreen *screen, int **thumb_pt) IB_rect, FALSE, FALSE, err_out); } - if (ibuf) { + if (ibuf) { float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp); /* dirty oversampling */ diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 658a13a8918..89fa92b7373 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -423,6 +423,7 @@ void WM_exit_ext(bContext *C, const short do_python) #ifdef WITH_INTERNATIONAL BLF_free_unifont(); + BLF_lang_free(); #endif ANIM_keyingset_infos_exit(); diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 4a410363167..0917d766051 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -466,7 +466,7 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt) if (wm_job->flag & WM_JOB_PROGRESS) WM_event_add_notifier(C, NC_WM | ND_JOB, NULL); wm_job->do_update = FALSE; - } + } if (wm_job->ready) { if (wm_job->endjob) diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 8c9d4861a9e..af6ec370fea 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -674,6 +674,8 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) else { pup = uiPupMenuBegin(C, RNA_struct_ui_name(op->type->srna), ICON_NONE); layout = uiPupMenuLayout(pup); + /* set this so the default execution context is the same as submenus */ + uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN); uiItemsFullEnumO(layout, op->type->idname, RNA_property_identifier(prop), op->ptr->data, WM_OP_EXEC_REGION_WIN, 0); uiPupMenuEnd(C, pup); } @@ -745,7 +747,7 @@ static uiBlock *wm_enum_search_menu(bContext *C, ARegion *ar, void *arg_op) wmOperator *op = (wmOperator *)arg_op; block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); #if 0 /* ok, this isn't so easy... */ uiDefBut(block, LABEL, 0, RNA_struct_ui_name(op->type->srna), 10, 10, 180, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 0, ""); @@ -807,7 +809,7 @@ int WM_operator_filesel(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { if (RNA_struct_property_is_set(op->ptr, "filepath")) { return WM_operator_call_notest(C, op); /* call exec direct */ - } + } else { WM_event_add_fileselect(C, op); return OPERATOR_RUNNING_MODAL; @@ -993,7 +995,7 @@ static uiBlock *wm_block_create_redo(bContext *C, ARegion *ar, void *arg_op) block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); - uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT); /* if register is not enabled, the operator gets freed on OPERATOR_FINISHED * ui_apply_but_funcs_after calls ED_undo_operator_repeate_cb and crashes */ @@ -1071,7 +1073,7 @@ static uiBlock *wm_block_dialog_create(bContext *C, ARegion *ar, void *userData) /* intentionally don't use 'UI_BLOCK_MOVEMOUSE_QUIT', some dialogs have many items * where quitting by accident is very annoying */ - uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); @@ -1112,7 +1114,7 @@ static uiBlock *wm_operator_ui_create(bContext *C, ARegion *ar, void *userData) block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockClearFlag(block, UI_BLOCK_LOOP); - uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT); + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_MOVEMOUSE_QUIT); layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 0, 0, data->width, data->height, style); @@ -1215,7 +1217,7 @@ static int wm_debug_menu_exec(bContext *C, wmOperator *op) ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C)); WM_event_add_notifier(C, NC_WINDOW, NULL); - return OPERATOR_FINISHED; + return OPERATOR_FINISHED; } static int wm_debug_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) @@ -1317,10 +1319,14 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi); ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_buf) + 5; rev_width = (int)BLF_width(style->widgetlabel.uifont_id, revision_buf) + 5; -#endif //WITH_BUILDINFO +#endif /* WITH_BUILDINFO */ block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN); + + /* note on UI_BLOCK_NO_WIN_CLIP, the window size is not always synchronized + * with the OS when the splash shows, window clipping in this case gives + * ugly results and clipping the splash isn't useful anyway, just disable it [#32938] */ + uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP); 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); @@ -1329,7 +1335,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar #ifdef WITH_BUILDINFO uiDefBut(block, LABEL, 0, version_buf, 494 - ver_width, 282 - 24, ver_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); uiDefBut(block, LABEL, 0, revision_buf, 494 - rev_width, 282 - 36, rev_width, UI_UNIT_Y, NULL, 0, 0, 0, 0, NULL); -#endif //WITH_BUILDINFO +#endif /* WITH_BUILDINFO */ layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, 10, 2, 480, 110, style); @@ -1459,7 +1465,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_ uiBut *but; block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_RET_1 | UI_BLOCK_MOVEMOUSE_QUIT); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, ""); uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL); @@ -1501,12 +1507,12 @@ static int wm_search_menu_poll(bContext *C) else { ScrArea *sa = CTX_wm_area(C); if (sa) { - if (sa->spacetype == SPACE_CONSOLE) return 0; // XXX - so we can use the shortcut in the console - if (sa->spacetype == SPACE_TEXT) return 0; // XXX - so we can use the spacebar in the text editor + if (sa->spacetype == SPACE_CONSOLE) return 0; /* XXX - so we can use the shortcut in the console */ + if (sa->spacetype == SPACE_TEXT) return 0; /* XXX - so we can use the spacebar in the text editor */ } else { Object *editob = CTX_data_edit_object(C); - if (editob && editob->type == OB_FONT) return 0; // XXX - so we can use the spacebar for entering text + if (editob && editob->type == OB_FONT) return 0; /* XXX - so we can use the spacebar for entering text */ } } return 1; @@ -1715,7 +1721,7 @@ static int wm_link_append_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev { if (RNA_struct_property_is_set(op->ptr, "filepath")) { return WM_operator_call_notest(C, op); - } + } else { /* XXX TODO solve where to get last linked library from */ if (G.lib[0] != '\0') { @@ -2184,7 +2190,7 @@ static int wm_exit_blender_op(bContext *C, wmOperator *op) { WM_operator_free(op); - WM_exit(C); + WM_exit(C); return OPERATOR_FINISHED; } @@ -2282,10 +2288,10 @@ static int border_apply_rect(wmOperator *op) /* operator arguments and storage. */ - RNA_int_set(op->ptr, "xmin", MIN2(rect->xmin, rect->xmax)); - RNA_int_set(op->ptr, "ymin", MIN2(rect->ymin, rect->ymax)); - RNA_int_set(op->ptr, "xmax", MAX2(rect->xmin, rect->xmax)); - RNA_int_set(op->ptr, "ymax", MAX2(rect->ymin, rect->ymax)); + RNA_int_set(op->ptr, "xmin", min_ii(rect->xmin, rect->xmax)); + RNA_int_set(op->ptr, "ymin", min_ii(rect->ymin, rect->ymax)); + RNA_int_set(op->ptr, "xmax", max_ii(rect->xmin, rect->xmax)); + RNA_int_set(op->ptr, "ymax", max_ii(rect->ymin, rect->ymax)); return 1; } @@ -3483,7 +3489,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) if (type == 0) { if (ar) ED_region_do_draw(C, ar); - } + } else if (type == 1) { wmWindow *win = CTX_wm_window(C); @@ -3856,7 +3862,7 @@ static void gesture_border_modal_keymap(wmKeyConfig *keyconf) WM_modalkeymap_assign(keymap, "VIEW3D_OT_clip_border"); WM_modalkeymap_assign(keymap, "VIEW3D_OT_render_border"); WM_modalkeymap_assign(keymap, "VIEW3D_OT_select_border"); - WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom_border"); // XXX TODO: zoom border should perhaps map rightmouse to zoom out instead of in+cancel + WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom_border"); /* XXX TODO: zoom border should perhaps map rightmouse to zoom out instead of in+cancel */ } /* zoom to border modal operators */ diff --git a/source/blender/windowmanager/intern/wm_subwindow.c b/source/blender/windowmanager/intern/wm_subwindow.c index 4078a88b2fd..e33f936b4da 100644 --- a/source/blender/windowmanager/intern/wm_subwindow.c +++ b/source/blender/windowmanager/intern/wm_subwindow.c @@ -192,7 +192,7 @@ void wm_subwindow_close(wmWindow *win, int swinid) wm_subwindow_free(swin); BLI_remlink(&win->subwindows, swin); MEM_freeN(swin); - } + } else { printf("%s: Internal error, bad winid: %d\n", __func__, swinid); } @@ -398,7 +398,7 @@ int WM_framebuffer_to_index(unsigned int col) return col & 0xFFFFFF; default: // 18 bits... return ((col & 0xFC0000) >> 6) + ((col & 0xFC00) >> 4) + ((col & 0xFC) >> 2); - } + } } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 44827302d7d..7d5dc858b00 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -164,7 +164,7 @@ void wm_window_free(bContext *C, wmWindowManager *wm, wmWindow *win) if (CTX_wm_window(C) == win) CTX_wm_window_set(C, NULL); - } + } /* always set drawable and active to NULL, * prevents non-drawable state of main windows (bugs #22967 and #25071, possibly #22477 too) */ @@ -414,6 +414,10 @@ void wm_window_add_ghostwindows(wmWindowManager *wm) win->posy = wm_init_state.start_y; win->sizex = wm_init_state.size_x; win->sizey = wm_init_state.size_y; + + /* we can't properly resize a maximized window */ + win->windowstate = GHOST_kWindowStateNormal; + wm_init_state.override_flag &= ~WIN_OVERRIDE_GEOM; } @@ -648,7 +652,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr C_void_ptr else if (!GHOST_ValidWindow(g_system, ghostwin)) { /* XXX - should be checked, why are we getting an event here, and */ /* what is it? */ - puts("<!> event has invalid window"); + puts("<!> event has invalid window"); return 1; } else { @@ -1001,7 +1005,7 @@ void wm_ghost_init(bContext *C) g_system = GHOST_CreateSystem(); GHOST_AddEventConsumer(g_system, consumer); - } + } } void wm_ghost_exit(void) @@ -1076,7 +1080,7 @@ char *WM_clipboard_text_get(int selection) return NULL; /* always convert from \r\n to \n */ - newbuf = MEM_callocN(strlen(buf) + 1, "WM_clipboard_text_get"); + newbuf = MEM_callocN(strlen(buf) + 1, __func__); for (p = buf, p2 = newbuf; *p; p++) { if (*p != '\r') diff --git a/source/blender/windowmanager/wm_event_system.h b/source/blender/windowmanager/wm_event_system.h index a33d37ac50e..2d0dd2ef911 100644 --- a/source/blender/windowmanager/wm_event_system.h +++ b/source/blender/windowmanager/wm_event_system.h @@ -32,10 +32,10 @@ #define __WM_EVENT_SYSTEM_H__ /* return value of handler-operator call */ -#define WM_HANDLER_CONTINUE 0 -#define WM_HANDLER_BREAK 1 -#define WM_HANDLER_HANDLED 2 -#define WM_HANDLER_MODAL 4 /* MODAL|BREAK means unhandled */ +#define WM_HANDLER_CONTINUE 0 +#define WM_HANDLER_BREAK 1 +#define WM_HANDLER_HANDLED 2 +#define WM_HANDLER_MODAL 4 /* MODAL|BREAK means unhandled */ struct ScrArea; struct ARegion; @@ -44,40 +44,40 @@ struct ARegion; typedef struct wmEventHandler { struct wmEventHandler *next, *prev; - - int type, flag; /* type default=0, rest is custom */ - + + int type, flag; /* type default=0, rest is custom */ + /* keymap handler */ - wmKeyMap *keymap; /* pointer to builtin/custom keymaps */ - rcti *bblocal, *bbwin; /* optional local and windowspace bb */ - + wmKeyMap *keymap; /* pointer to builtin/custom keymaps */ + rcti *bblocal, *bbwin; /* optional local and windowspace bb */ + /* modal operator handler */ - wmOperator *op; /* for derived/modal handlers */ - struct ScrArea *op_area; /* for derived/modal handlers */ - struct ARegion *op_region; /* for derived/modal handlers */ + wmOperator *op; /* for derived/modal handlers */ + struct ScrArea *op_area; /* for derived/modal handlers */ + struct ARegion *op_region; /* for derived/modal handlers */ /* ui handler */ - wmUIHandlerFunc ui_handle; /* callback receiving events */ - wmUIHandlerRemoveFunc ui_remove; /* callback when handler is removed */ - void *ui_userdata; /* user data pointer */ - struct ScrArea *ui_area; /* for derived/modal handlers */ - struct ARegion *ui_region; /* for derived/modal handlers */ - struct ARegion *ui_menu; /* for derived/modal handlers */ - + wmUIHandlerFunc ui_handle; /* callback receiving events */ + wmUIHandlerRemoveFunc ui_remove; /* callback when handler is removed */ + void *ui_userdata; /* user data pointer */ + struct ScrArea *ui_area; /* for derived/modal handlers */ + struct ARegion *ui_region; /* for derived/modal handlers */ + struct ARegion *ui_menu; /* for derived/modal handlers */ + /* fileselect handler re-uses modal operator data */ - struct bScreen *filescreen; /* screen it started in, to validate exec */ - + struct bScreen *filescreen; /* screen it started in, to validate exec */ + /* drop box handler */ ListBase *dropboxes; - + } wmEventHandler; /* handler flag */ /* after this handler all others are ignored */ -#define WM_HANDLER_BLOCKING 1 +#define WM_HANDLER_BLOCKING 1 /* handler tagged to be freed in wm_handlers_do() */ -#define WM_HANDLER_DO_FREE 2 +#define WM_HANDLER_DO_FREE 2 @@ -89,23 +89,23 @@ enum { /* wm_event_system.c */ -void wm_event_free_all (wmWindow *win); -void wm_event_free (wmEvent *event); -void wm_event_free_handler (wmEventHandler *handler); +void wm_event_free_all (wmWindow *win); +void wm_event_free (wmEvent *event); +void wm_event_free_handler (wmEventHandler *handler); - /* goes over entire hierarchy: events -> window -> screen -> area -> region */ -void wm_event_do_handlers (bContext *C); + /* goes over entire hierarchy: events -> window -> screen -> area -> region */ +void wm_event_do_handlers (bContext *C); -void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata); +void wm_event_add_ghostevent (wmWindowManager *wm, wmWindow *win, int type, int time, void *customdata); -void wm_event_do_notifiers (bContext *C); +void wm_event_do_notifiers (bContext *C); /* wm_keymap.c */ /* wm_dropbox.c */ -void wm_dropbox_free(void); -void wm_drags_check_ops(bContext *C, wmEvent *event); -void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect); +void wm_dropbox_free(void); +void wm_drags_check_ops(bContext *C, wmEvent *event); +void wm_drags_draw(bContext *C, wmWindow *win, rcti *rect); #endif /* __WM_EVENT_SYSTEM_H__ */ diff --git a/source/blenderplayer/CMakeLists.txt b/source/blenderplayer/CMakeLists.txt index 04d4be05034..828b7f5066c 100644 --- a/source/blenderplayer/CMakeLists.txt +++ b/source/blenderplayer/CMakeLists.txt @@ -148,6 +148,7 @@ endif() extern_recastnavigation bf_intern_raskter bf_intern_opencolorio + bf_intern_opennl ) if(WITH_MOD_CLOTH_ELTOPO) @@ -169,10 +170,6 @@ endif() list(APPEND BLENDER_SORTED_LIBS extern_colamd) - if(WITH_MOD_DECIMATE) - list(APPEND BLENDER_SORTED_LIBS bf_intern_decimate) - endif() - if(WITH_MOD_BOOLEAN) list(APPEND BLENDER_SORTED_LIBS bf_intern_bsp) list(APPEND BLENDER_SORTED_LIBS bf_intern_moto) diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 39ed89638b2..f33fe8c6538 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -62,7 +62,6 @@ struct Image; struct ImageUser; struct KeyingSet; struct KeyingSetInfo; -struct LOD_Decimation_Info; struct MCol; struct MTex; struct Main; @@ -78,6 +77,7 @@ struct Nurb; struct Object; struct PBVHNode; struct PyObject; +struct Quadric; struct Render; struct RenderEngine; struct RenderEngineType; @@ -137,6 +137,13 @@ int BLI_smallhash_count(struct SmallHash *hash) { return 0; } void *BLI_smallhash_iternext(struct SmallHashIter *iter, uintptr_t *key) { return NULL; } void *BLI_smallhash_iternew(struct SmallHash *hash, struct SmallHashIter *iter, uintptr_t *key) { return NULL; } +void BLI_quadric_from_v3_dist(struct Quadric *q, const float v[3], const float offset) {} +void BLI_quadric_add_qu_qu(struct Quadric *a, const struct Quadric *b) {} +void BLI_quadric_add_qu_ququ(struct Quadric *r, const struct Quadric *a, const struct Quadric *b) {} +void BLI_quadric_mul(struct Quadric *a, const float scalar) {} +float BLI_quadric_evaluate(const struct Quadric *q, const float v[3]) {return 0.0f;} +int BLI_quadric_optimize(const struct Quadric *q, float v[3]) {return 0;} + float *RE_RenderLayerGetPass(struct RenderLayer *rl, int passtype) {return (float *) NULL;} float RE_filter_value(int type, float x) {return 0.0f;} struct RenderLayer *RE_GetRenderLayer(struct RenderResult *rr, const char *name) {return (struct RenderLayer *)NULL;} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index ce71757e7cb..682ab5013d6 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -900,7 +900,6 @@ endif() bf_imbuf_dds bf_collada bf_intern_bsp - bf_intern_decimate bf_intern_elbeem bf_intern_memutil bf_intern_guardedalloc diff --git a/source/creator/creator.c b/source/creator/creator.c index f25ff305c14..99f56d0c0ec 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -1130,6 +1130,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) #endif BLI_argsAdd(ba, 1, NULL, "--debug-python", "\n\tEnable debug messages for python", debug_mode_generic, (void *)G_DEBUG_PYTHON); BLI_argsAdd(ba, 1, NULL, "--debug-events", "\n\tEnable debug messages for the event system", debug_mode_generic, (void *)G_DEBUG_EVENTS); + BLI_argsAdd(ba, 1, NULL, "--debug-handlers", "\n\tEnable debug messages for event handling", debug_mode_generic, (void *)G_DEBUG_HANDLERS); BLI_argsAdd(ba, 1, NULL, "--debug-wm", "\n\tEnable debug messages for the window manager", debug_mode_generic, (void *)G_DEBUG_WM); BLI_argsAdd(ba, 1, NULL, "--debug-all", "\n\tEnable all debug messages (excludes libmv)", debug_mode_generic, (void *)G_DEBUG_ALL); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp index 1afa5d3d07b..346d2017ef0 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp @@ -46,7 +46,7 @@ m_frame_rect(rect) m_area_left = ar->winrct.xmin; m_area_top = ar->winrct.ymax; - glGetIntegerv(GL_VIEWPORT, (GLint*)m_viewport); + glGetIntegerv(GL_VIEWPORT, (GLint *)m_viewport); } KX_BlenderCanvas::~KX_BlenderCanvas() diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp index 85b76d7c676..e32239b148d 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp @@ -58,7 +58,7 @@ unsigned int KX_BlenderRenderTools::m_numgllights; KX_BlenderRenderTools::KX_BlenderRenderTools() { - glGetIntegerv(GL_MAX_LIGHTS, (GLint*) &m_numgllights); + glGetIntegerv(GL_MAX_LIGHTS, (GLint *) &m_numgllights); if (m_numgllights < 8) m_numgllights = 8; } @@ -164,11 +164,11 @@ bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo* client, KX_RayCast* resu left = (dir.cross(resultnormal)).safe_normalized(); // for the up vector, we take the 'resultnormal' returned by the physics - double maat[16]={ - left[0], left[1], left[2], 0, - dir[0], dir[1], dir[2], 0, - resultnormal[0],resultnormal[1],resultnormal[2], 0, - 0, 0, 0, 1}; + double maat[16] = {left[0], left[1], left[2], 0, + dir[0], dir[1], dir[2], 0, + resultnormal[0], resultnormal[1], resultnormal[2], 0, + 0, 0, 0, 1}; + glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]); //glMultMatrixd(oglmatrix); glMultMatrixd(maat); @@ -227,16 +227,17 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat left *= size[0]; dir *= size[1]; up *= size[2]; - double maat[16]={ - left[0], left[1],left[2], 0, - dir[0], dir[1],dir[2],0, - up[0],up[1],up[2],0, - 0,0,0,1}; - glTranslated(objpos[0],objpos[1],objpos[2]); - glMultMatrixd(maat); - - } else - { + + double maat[16] = {left[0], left[1], left[2], 0, + dir[0], dir[1], dir[2], 0, + up[0], up[1], up[2], 0, + 0, 0, 0, 1}; + + glTranslated(objpos[0],objpos[1],objpos[2]); + glMultMatrixd(maat); + + } + else { if (objectdrawmode & RAS_IPolyMaterial::SHADOW) { // shadow must be cast to the ground, physics system needed here! diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index fcf09588791..0bd09146f3a 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -140,8 +140,7 @@ void BL_ActionActuator::SetLocalTime(float curtime) // Handle wrap around if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) { - switch(m_playtype) - { + switch (m_playtype) { case ACT_ACTION_PLAY: // Clamp m_localtime = m_endframe; @@ -196,8 +195,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) return false; // Convert our playtype to one that BL_Action likes - switch(m_playtype) - { + switch (m_playtype) { case ACT_ACTION_LOOP_END: case ACT_ACTION_LOOP_STOP: playtype = BL_Action::ACT_MODE_LOOP; @@ -312,8 +310,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame) return false; } - switch(m_playtype) - { + switch (m_playtype) { case ACT_ACTION_LOOP_STOP: obj->StopAction(m_layer); // Stop the action after getting the frame @@ -492,9 +489,9 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, // for some reason loc.setValue(pchan->loc) fails if (pchan) { - pchan->loc[0]= loc[0]; pchan->loc[1]= loc[1]; pchan->loc[2]= loc[2]; - pchan->size[0]= size[0]; pchan->size[1]= size[1]; pchan->size[2]= size[2]; - pchan->quat[0]= quat[3]; pchan->quat[1]= quat[0]; pchan->quat[2]= quat[1]; pchan->quat[3]= quat[2]; /* notice xyzw -> wxyz is intentional */ + pchan->loc[0] = loc[0]; pchan->loc[1] = loc[1]; pchan->loc[2] = loc[2]; + pchan->size[0] = size[0]; pchan->size[1] = size[1]; pchan->size[2] = size[2]; + pchan->quat[0] = quat[3]; pchan->quat[1] = quat[0]; pchan->quat[2] = quat[1]; pchan->quat[3] = quat[2]; /* notice xyzw -> wxyz is intentional */ } } @@ -557,13 +554,13 @@ PyAttributeDef BL_ActionActuator::Attributes[] = { PyObject *BL_ActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); + BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v); return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : ""); } int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); + BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v); if (!PyUnicode_Check(value)) { @@ -595,7 +592,7 @@ PyObject *BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA return NULL; #if 0 // XXX To be removed in a later version (first removed in 2.64) - BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); + BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v); PyObject *ret= PyList_New(0); PyObject *item; @@ -622,13 +619,13 @@ PyObject *BL_ActionActuator::pyattr_get_channel_names(void *self_v, const KX_PYA PyObject *BL_ActionActuator::pyattr_get_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); + BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v); return PyBool_FromLong(self->m_flag & ACT_FLAG_CONTINUE); } int BL_ActionActuator::pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); + BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v); if (PyObject_IsTrue(value)) self->m_flag |= ACT_FLAG_CONTINUE; @@ -640,13 +637,13 @@ int BL_ActionActuator::pyattr_set_use_continue(void *self_v, const KX_PYATTRIBUT PyObject *BL_ActionActuator::pyattr_get_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); + BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v); return PyFloat_FromDouble(((KX_GameObject*)self->m_gameobj)->GetActionFrame(self->m_layer)); } int BL_ActionActuator::pyattr_set_frame(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - BL_ActionActuator* self= static_cast<BL_ActionActuator*>(self_v); + BL_ActionActuator* self = static_cast<BL_ActionActuator*>(self_v); ((KX_GameObject*)self->m_gameobj)->SetActionFrame(self->m_layer, PyFloat_AsDouble(value)); diff --git a/source/gameengine/Converter/BL_ArmatureChannel.cpp b/source/gameengine/Converter/BL_ArmatureChannel.cpp index 8f5547c337c..7cf895255ba 100644 --- a/source/gameengine/Converter/BL_ArmatureChannel.cpp +++ b/source/gameengine/Converter/BL_ArmatureChannel.cpp @@ -149,7 +149,7 @@ PyAttributeDef BL_ArmatureChannel::AttributesPtr[] = { PyObject *BL_ArmatureChannel::py_attr_getattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef) { - BL_ArmatureChannel* self= static_cast<BL_ArmatureChannel*>(self_v); + BL_ArmatureChannel* self = static_cast<BL_ArmatureChannel*>(self_v); bPoseChannel* channel = self->m_posechannel; int attr_order = attrdef-Attributes; @@ -177,7 +177,7 @@ PyObject *BL_ArmatureChannel::py_attr_getattr(void *self_v, const struct KX_PYAT int BL_ArmatureChannel::py_attr_setattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - BL_ArmatureChannel* self= static_cast<BL_ArmatureChannel*>(self_v); + BL_ArmatureChannel* self = static_cast<BL_ArmatureChannel*>(self_v); bPoseChannel* channel = self->m_posechannel; int attr_order = attrdef-Attributes; @@ -300,7 +300,7 @@ PyObject *BL_ArmatureChannel::py_attr_get_joint_rotation(void *self_v, const str int BL_ArmatureChannel::py_attr_set_joint_rotation(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - BL_ArmatureChannel* self= static_cast<BL_ArmatureChannel*>(self_v); + BL_ArmatureChannel* self = static_cast<BL_ArmatureChannel*>(self_v); bPoseChannel* pchan = self->m_posechannel; PyObject *item; float joints[3]; diff --git a/source/gameengine/Converter/BL_ArmatureConstraint.cpp b/source/gameengine/Converter/BL_ArmatureConstraint.cpp index 169205d79e7..b8ad117a220 100644 --- a/source/gameengine/Converter/BL_ArmatureConstraint.cpp +++ b/source/gameengine/Converter/BL_ArmatureConstraint.cpp @@ -288,7 +288,7 @@ PyAttributeDef BL_ArmatureConstraint::Attributes[] = { PyObject *BL_ArmatureConstraint::py_attr_getattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef) { - BL_ArmatureConstraint* self= static_cast<BL_ArmatureConstraint*>(self_v); + BL_ArmatureConstraint* self = static_cast<BL_ArmatureConstraint*>(self_v); bConstraint* constraint = self->m_constraint; bKinematicConstraint* ikconstraint = (constraint && constraint->type == CONSTRAINT_TYPE_KINEMATIC) ? (bKinematicConstraint*)constraint->data : NULL; int attr_order = attrdef-Attributes; @@ -353,7 +353,7 @@ PyObject *BL_ArmatureConstraint::py_attr_getattr(void *self_v, const struct KX_P int BL_ArmatureConstraint::py_attr_setattr(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - BL_ArmatureConstraint* self= static_cast<BL_ArmatureConstraint*>(self_v); + BL_ArmatureConstraint* self = static_cast<BL_ArmatureConstraint*>(self_v); bConstraint* constraint = self->m_constraint; bKinematicConstraint* ikconstraint = (constraint && constraint->type == CONSTRAINT_TYPE_KINEMATIC) ? (bKinematicConstraint*)constraint->data : NULL; int attr_order = attrdef-Attributes; diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 912e2126874..982988cc088 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -433,8 +433,7 @@ static void GetRGB(short type, unsigned int &c3) { unsigned int color = 0xFFFFFFFFL; - switch(type) - { + switch (type) { case 0: // vertex colors { if (mmcol) { @@ -627,7 +626,7 @@ static bool ConvertMaterial( if (!material->cubemap[i]->cube[0]) BL_Texture::SplitEnvMap(material->cubemap[i]); - material->texname[i]= material->cubemap[i]->ima->id.name; + material->texname[i] = material->cubemap[i]->ima->id.name; material->mapping[i].mapping |= USEENV; } } @@ -677,7 +676,7 @@ static bool ConvertMaterial( material->mapping[i].projplane[2] = mttmp->projz; /// -------------------------------- - switch( mttmp->blendtype ) { + switch (mttmp->blendtype) { case MTEX_BLEND: material->blend_mode[i] = BLEND_MIX; break; @@ -701,7 +700,7 @@ static bool ConvertMaterial( // above one tex the switches here // are not used - switch(valid_index) { + switch (valid_index) { case 0: material->IdMode = DEFAULT_BLENDER; break; @@ -778,7 +777,7 @@ static bool ConvertMaterial( const char *uvName = "", *uv2Name = ""; - uv2[0]= uv2[1]= uv2[2]= uv2[3]= MT_Point2(0.0f, 0.0f); + uv2[0] = uv2[1] = uv2[2] = uv2[3] = MT_Point2(0.0f, 0.0f); /* No material, what to do? let's see what is in the UV and set the material accordingly * light and visible is always on */ @@ -799,7 +798,7 @@ static bool ConvertMaterial( material->alphablend = GEMAT_SOLID; material->tile = 0; - uv[0]= uv[1]= uv[2]= uv[3]= MT_Point2(0.0f, 0.0f); + uv[0] = uv[1] = uv[2] = uv[3] = MT_Point2(0.0f, 0.0f); } if (validmat && validface) { @@ -1390,32 +1389,30 @@ static float my_boundbox_mesh(Mesh *me, float *loc, float *size) } if (me->totvert) { - loc[0]= (min[0]+max[0])/2.0f; - loc[1]= (min[1]+max[1])/2.0f; - loc[2]= (min[2]+max[2])/2.0f; + loc[0] = (min[0] + max[0]) / 2.0f; + loc[1] = (min[1] + max[1]) / 2.0f; + loc[2] = (min[2] + max[2]) / 2.0f; - size[0]= (max[0]-min[0])/2.0f; - size[1]= (max[1]-min[1])/2.0f; - size[2]= (max[2]-min[2])/2.0f; + size[0] = (max[0] - min[0]) / 2.0f; + size[1] = (max[1] - min[1]) / 2.0f; + size[2] = (max[2] - min[2]) / 2.0f; } else { - loc[0]= loc[1]= loc[2]= 0.0f; - size[0]= size[1]= size[2]= 0.0f; + loc[0] = loc[1] = loc[2] = 0.0f; + size[0] = size[1] = size[2] = 0.0f; } - bb->vec[0][0]=bb->vec[1][0]=bb->vec[2][0]=bb->vec[3][0]= loc[0]-size[0]; - bb->vec[4][0]=bb->vec[5][0]=bb->vec[6][0]=bb->vec[7][0]= loc[0]+size[0]; + bb->vec[0][0] = bb->vec[1][0] = bb->vec[2][0] = bb->vec[3][0] = loc[0]-size[0]; + bb->vec[4][0] = bb->vec[5][0] = bb->vec[6][0] = bb->vec[7][0] = loc[0]+size[0]; - bb->vec[0][1]=bb->vec[1][1]=bb->vec[4][1]=bb->vec[5][1]= loc[1]-size[1]; - bb->vec[2][1]=bb->vec[3][1]=bb->vec[6][1]=bb->vec[7][1]= loc[1]+size[1]; + bb->vec[0][1] = bb->vec[1][1] = bb->vec[4][1] = bb->vec[5][1] = loc[1]-size[1]; + bb->vec[2][1] = bb->vec[3][1] = bb->vec[6][1] = bb->vec[7][1] = loc[1]+size[1]; - bb->vec[0][2]=bb->vec[3][2]=bb->vec[4][2]=bb->vec[7][2]= loc[2]-size[2]; - bb->vec[1][2]=bb->vec[2][2]=bb->vec[5][2]=bb->vec[6][2]= loc[2]+size[2]; + bb->vec[0][2] = bb->vec[3][2] = bb->vec[4][2] = bb->vec[7][2] = loc[2]-size[2]; + bb->vec[1][2] = bb->vec[2][2] = bb->vec[5][2] = bb->vec[6][2] = loc[2]+size[2]; return sqrt(radius); } - - static void my_tex_space_mesh(Mesh *me) @@ -1438,12 +1435,12 @@ static void my_tex_space_mesh(Mesh *me) minmax_v3v3_v3(min, max, fp); } if (kb->totelem) { - loc[0]= (min[0]+max[0])/2.0f; loc[1]= (min[1]+max[1])/2.0f; loc[2]= (min[2]+max[2])/2.0f; - size[0]= (max[0]-min[0])/2.0f; size[1]= (max[1]-min[1])/2.0f; size[2]= (max[2]-min[2])/2.0f; + loc[0] = (min[0]+max[0])/2.0f; loc[1] = (min[1]+max[1])/2.0f; loc[2] = (min[2]+max[2])/2.0f; + size[0] = (max[0]-min[0])/2.0f; size[1] = (max[1]-min[1])/2.0f; size[2] = (max[2]-min[2])/2.0f; } else { - loc[0]= loc[1]= loc[2]= 0.0; - size[0]= size[1]= size[2]= 0.0; + loc[0] = loc[1] = loc[2] = 0.0; + size[0] = size[1] = size[2] = 0.0; } } @@ -1451,19 +1448,19 @@ static void my_tex_space_mesh(Mesh *me) copy_v3_v3(me->loc, loc); copy_v3_v3(me->size, size); - me->rot[0]= me->rot[1]= me->rot[2]= 0.0f; + me->rot[0] = me->rot[1] = me->rot[2] = 0.0f; if (me->size[0] == 0.0f) me->size[0] = 1.0f; - else if (me->size[0] > 0.0f && me->size[0]< 0.00001f) me->size[0]= 0.00001f; - else if (me->size[0] < 0.0f && me->size[0]> -0.00001f) me->size[0]= -0.00001f; + else if (me->size[0] > 0.0f && me->size[0]< 0.00001f) me->size[0] = 0.00001f; + else if (me->size[0] < 0.0f && me->size[0]> -0.00001f) me->size[0] = -0.00001f; - if (me->size[1] == 0.0f) me->size[1]= 1.0f; - else if (me->size[1] > 0.0f && me->size[1]< 0.00001f) me->size[1]= 0.00001f; - else if (me->size[1] < 0.0f && me->size[1]> -0.00001f) me->size[1]= -0.00001f; + if (me->size[1] == 0.0f) me->size[1] = 1.0f; + else if (me->size[1] > 0.0f && me->size[1]< 0.00001f) me->size[1] = 0.00001f; + else if (me->size[1] < 0.0f && me->size[1]> -0.00001f) me->size[1] = -0.00001f; - if (me->size[2] == 0.0f) me->size[2]= 1.0f; - else if (me->size[2] > 0.0f && me->size[2]< 0.00001f) me->size[2]= 0.00001f; - else if (me->size[2] < 0.0f && me->size[2]> -0.00001f) me->size[2]= -0.00001f; + if (me->size[2] == 0.0f) me->size[2] = 1.0f; + else if (me->size[2] > 0.0f && me->size[2]< 0.00001f) me->size[2] = 0.00001f; + else if (me->size[2] < 0.0f && me->size[2]> -0.00001f) me->size[2] = -0.00001f; } } @@ -1480,13 +1477,13 @@ static void my_get_local_bounds(Object *ob, DerivedMesh *dm, float *center, floa float min_r[3], max_r[3]; INIT_MINMAX(min_r, max_r); dm->getMinMax(dm, min_r, max_r); - size[0]= 0.5f*fabsf(max_r[0] - min_r[0]); - size[1]= 0.5f*fabsf(max_r[1] - min_r[1]); - size[2]= 0.5f*fabsf(max_r[2] - min_r[2]); + size[0] = 0.5f * fabsf(max_r[0] - min_r[0]); + size[1] = 0.5f * fabsf(max_r[1] - min_r[1]); + size[2] = 0.5f * fabsf(max_r[2] - min_r[2]); - center[0]= 0.5f*(max_r[0] + min_r[0]); - center[1]= 0.5f*(max_r[1] + min_r[1]); - center[2]= 0.5f*(max_r[2] + min_r[2]); + center[0] = 0.5f * (max_r[0] + min_r[0]); + center[1] = 0.5f * (max_r[1] + min_r[1]); + center[2] = 0.5f * (max_r[2] + min_r[2]); return; } else { @@ -1500,11 +1497,11 @@ static void my_get_local_bounds(Object *ob, DerivedMesh *dm, float *center, floa break; case OB_CURVE: case OB_SURF: - center[0]= center[1]= center[2]= 0.0; + center[0] = center[1] = center[2] = 0.0; size[0] = size[1]=size[2]=0.0; break; case OB_FONT: - center[0]= center[1]= center[2]= 0.0; + center[0] = center[1] = center[2] = 0.0; size[0] = size[1]=size[2]=1.0; break; case OB_MBALL: @@ -1514,15 +1511,15 @@ static void my_get_local_bounds(Object *ob, DerivedMesh *dm, float *center, floa if (bb==NULL) { - center[0]= center[1]= center[2]= 0.0; - size[0] = size[1]=size[2]=1.0; + center[0] = center[1] = center[2] = 0.0; + size[0] = size[1] = size[2] = 1.0; } else { size[0] = 0.5f * fabsf(bb->vec[0][0] - bb->vec[4][0]); size[1] = 0.5f * fabsf(bb->vec[0][1] - bb->vec[2][1]); size[2] = 0.5f * fabsf(bb->vec[0][2] - bb->vec[1][2]); - + center[0] = 0.5f * (bb->vec[0][0] + bb->vec[4][0]); center[1] = 0.5f * (bb->vec[0][1] + bb->vec[2][1]); center[2] = 0.5f * (bb->vec[0][2] + bb->vec[1][2]); @@ -1595,7 +1592,7 @@ static void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj, // get Root Parent of blenderobject struct Object* parent= blenderobject->parent; - while(parent && parent->parent) { + while (parent && parent->parent) { parent= parent->parent; } @@ -1929,8 +1926,7 @@ static KX_GameObject *gameobject_from_blenderobject( KX_GameObject *gameobj = NULL; Scene *blenderscene = kxscene->GetBlenderScene(); - switch(ob->type) - { + switch (ob->type) { case OB_LAMP: { KX_LightObject* gamelight = gamelight_from_blamp(ob, static_cast<Lamp*>(ob->data), ob->lay, kxscene, rendertools, converter); diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp index 0d3c0d269fc..911ff245ab4 100644 --- a/source/gameengine/Converter/BL_MeshDeformer.cpp +++ b/source/gameengine/Converter/BL_MeshDeformer.cpp @@ -154,27 +154,27 @@ void BL_MeshDeformer::RecalcNormals() v4 = &it.vertex[it.index[i+3]]; co4 = m_transverts[v4->getOrigIndex()]; - n1[0]= co1[0]-co3[0]; - n1[1]= co1[1]-co3[1]; - n1[2]= co1[2]-co3[2]; + n1[0] = co1[0] - co3[0]; + n1[1] = co1[1] - co3[1]; + n1[2] = co1[2] - co3[2]; - n2[0]= co2[0]-co4[0]; - n2[1]= co2[1]-co4[1]; - n2[2]= co2[2]-co4[2]; + n2[0] = co2[0] - co4[0]; + n2[1] = co2[1] - co4[1]; + n2[2] = co2[2] - co4[2]; } else { - n1[0]= co1[0]-co2[0]; - n2[0]= co2[0]-co3[0]; - n1[1]= co1[1]-co2[1]; + n1[0] = co1[0] - co2[0]; + n2[0] = co2[0] - co3[0]; + n1[1] = co1[1] - co2[1]; - n2[1]= co2[1]-co3[1]; - n1[2]= co1[2]-co2[2]; - n2[2]= co2[2]-co3[2]; + n2[1] = co2[1] - co3[1]; + n1[2] = co1[2] - co2[2]; + n2[2] = co2[2] - co3[2]; } - fnor[0]= n1[1]*n2[2] - n1[2]*n2[1]; - fnor[1]= n1[2]*n2[0] - n1[0]*n2[2]; - fnor[2]= n1[0]*n2[1] - n1[1]*n2[0]; + fnor[0] = n1[1] * n2[2] - n1[2] * n2[1]; + fnor[1] = n1[2] * n2[0] - n1[0] * n2[2]; + fnor[2] = n1[0] * n2[1] - n1[1] * n2[0]; normalize_v3(fnor); /* add to vertices for smooth normals */ diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp index 8325e80db78..d8b4f6aaf1c 100644 --- a/source/gameengine/Converter/BL_ShapeActionActuator.cpp +++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp @@ -528,13 +528,13 @@ PyAttributeDef BL_ShapeActionActuator::Attributes[] = { PyObject *BL_ShapeActionActuator::pyattr_get_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - BL_ShapeActionActuator* self= static_cast<BL_ShapeActionActuator*>(self_v); + BL_ShapeActionActuator* self = static_cast<BL_ShapeActionActuator*>(self_v); return PyUnicode_FromString(self->GetAction() ? self->GetAction()->id.name+2 : ""); } int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - BL_ShapeActionActuator* self= static_cast<BL_ShapeActionActuator*>(self_v); + BL_ShapeActionActuator* self = static_cast<BL_ShapeActionActuator*>(self_v); /* exact copy of BL_ActionActuator's function from here down */ if (!PyUnicode_Check(value)) { diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index 34af4038c4e..30a4209965e 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -818,13 +818,13 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber) if (icu_rz) icu_rz->ipo = IPO_LIN; } - if (icu_rx) eulerAnglesOld[0]= eval_icu( icu_rx, frameNumber - 1 ) / ((180 / 3.14159265f) / 10); - if (icu_ry) eulerAnglesOld[1]= eval_icu( icu_ry, frameNumber - 1 ) / ((180 / 3.14159265f) / 10); - if (icu_rz) eulerAnglesOld[2]= eval_icu( icu_rz, frameNumber - 1 ) / ((180 / 3.14159265f) / 10); + if (icu_rx) eulerAnglesOld[0] = eval_icu( icu_rx, frameNumber - 1 ) / ((180 / 3.14159265f) / 10); + if (icu_ry) eulerAnglesOld[1] = eval_icu( icu_ry, frameNumber - 1 ) / ((180 / 3.14159265f) / 10); + if (icu_rz) eulerAnglesOld[2] = eval_icu( icu_rz, frameNumber - 1 ) / ((180 / 3.14159265f) / 10); // orn.getValue((float *)tmat); // uses the wrong ordering, cant use this - for (int r=0;r<3;r++) - for (int c=0;c<3;c++) + for (int r = 0; r < 3; r++) + for (int c = 0; c < 3; c++) tmat[r][c] = orn[c][r]; // mat3_to_eul( eulerAngles,tmat); // better to use Mat3ToCompatibleEul @@ -944,7 +944,7 @@ static void load_datablocks(Main *main_newlib, BlendHandle *bpy_openlib, const c int i=0; LinkNode *n= names; - while(n) { + while (n) { BLO_library_append_named_part(main_tmp, &bpy_openlib, (char *)n->link, idcode); n= (LinkNode *)n->next; i++; @@ -1170,7 +1170,7 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie) else { /* free the mesh, we could be referecing a linked one! */ int mesh_index= gameobj->GetMeshCount(); - while(mesh_index--) { + while (mesh_index--) { mesh= gameobj->GetMesh(mesh_index); if (IS_TAGGED(mesh->GetMesh())) { gameobj->RemoveMeshes(); /* XXX - slack, should only remove meshes that are library items but mostly objects only have 1 mesh */ @@ -1450,14 +1450,12 @@ RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene* kx_scene, BLI_remlink(&m_maggie->mat, mat_new); BLI_addtail(&maggie->mat, mat_new); - mesh->mat[i]= mat_new; + mesh->mat[i] = mat_new; /* the same material may be used twice */ - for (int j=i+1; j<mesh->totcol; j++) - { - if (mesh->mat[j]==mat_old) - { - mesh->mat[j]= mat_new; + for (int j = i + 1; j < mesh->totcol; j++) { + if (mesh->mat[j] == mat_old) { + mesh->mat[j] = mat_new; mat_new->id.us++; mat_old->id.us--; } diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp index ea2b85f8c5e..24d321730eb 100644 --- a/source/gameengine/Converter/KX_ConvertActuators.cpp +++ b/source/gameengine/Converter/KX_ConvertActuators.cpp @@ -136,7 +136,7 @@ void BL_ConvertActuators(const char* maggiename, } gameobj->ReserveActuator(actcount); bact = (bActuator*) blenderobject->actuators.first; - while(bact) + while (bact) { STR_String uniquename = bact->name; STR_String& objectname = gameobj->GetName(); @@ -358,7 +358,7 @@ void BL_ConvertActuators(const char* maggiename, KX_SoundActuator::KX_SOUNDACT_TYPE soundActuatorType = KX_SoundActuator::KX_SOUNDACT_NODEF; - switch(soundact->type) { + switch (soundact->type) { case ACT_SND_PLAY_STOP_SOUND: soundActuatorType = KX_SoundActuator::KX_SOUNDACT_PLAYSTOP; break; @@ -946,8 +946,7 @@ void BL_ConvertActuators(const char* maggiename, SCA_2DFilterActuator *tmp = NULL; RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode; - switch(_2dfilter->type) - { + switch (_2dfilter->type) { case ACT_2DFILTER_MOTIONBLUR: filtermode = RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR; break; @@ -1026,8 +1025,7 @@ void BL_ConvertActuators(const char* maggiename, bool ghost = true; KX_GameObject *tmpgob = NULL; - switch(parAct->type) - { + switch (parAct->type) { case ACT_PARENT_SET: mode = KX_ParentActuator::KX_PARENT_SET; tmpgob = converter->FindGameObject(parAct->ob); @@ -1081,8 +1079,7 @@ void BL_ConvertActuators(const char* maggiename, KX_GameObject *targetob = converter->FindGameObject(stAct->target); int mode = KX_SteeringActuator::KX_STEERING_NODEF; - switch(stAct->type) - { + switch (stAct->type) { case ACT_STEERING_SEEK: mode = KX_SteeringActuator::KX_STEERING_SEEK; break; diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp index 3a6aa228957..769abd01ce0 100644 --- a/source/gameengine/Converter/KX_ConvertControllers.cpp +++ b/source/gameengine/Converter/KX_ConvertControllers.cpp @@ -110,8 +110,7 @@ void BL_ConvertControllers( while (bcontr) { SCA_IController* gamecontroller = NULL; - switch(bcontr->type) - { + switch (bcontr->type) { case CONT_LOGIC_AND: { gamecontroller = new SCA_ANDController(gameobj); diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp index a63f4c38fb6..7222c673322 100644 --- a/source/gameengine/Converter/KX_ConvertProperties.cpp +++ b/source/gameengine/Converter/KX_ConvertProperties.cpp @@ -69,13 +69,12 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan bProperty* prop = (bProperty*)object->prop.first; CValue* propval; bool show_debug_info; - while(prop) - { - + + while (prop) { propval = NULL; show_debug_info = bool (prop->flag & PROP_DEBUG); - switch(prop->type) { + switch (prop->type) { case GPROP_BOOL: { propval = new CBoolValue((bool)(prop->data != 0)); @@ -184,7 +183,7 @@ void BL_ConvertTextProperty(Object* object, KX_FontObject* fontobj,SCA_TimeEvent STR_String str = curve->str; CValue* propval = NULL; - switch(prop->type) { + switch (prop->type) { case GPROP_BOOL: { int value = atoi(str); diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index 859257e192d..d3d3256312e 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -118,8 +118,8 @@ void BL_ConvertSensors(struct Object* blenderobject, } gameobj->ReserveSensor(count); sens = (bSensor*)blenderobject->sensors.first; - while(sens) - { + + while (sens) { SCA_ISensor* gamesensor=NULL; /* All sensors have a pulse toggle, frequency, and invert field. */ /* These are extracted here, and set when the sensor is added to the */ @@ -398,7 +398,7 @@ void BL_ConvertSensors(struct Object* blenderobject, /* Better do an explicit conversion here! (was implicit */ /* before...) */ - switch(blenderpropsensor->type) { + switch (blenderpropsensor->type) { case SENS_PROP_EQUAL: propchecktype = SCA_PropertySensor::KX_PROPSENSOR_EQUAL; break; @@ -573,8 +573,7 @@ void BL_ConvertSensors(struct Object* blenderobject, int hatf =0; int prec =0; - switch(bjoy->type) - { + switch (bjoy->type) { case SENS_JOY_AXIS: axis = bjoy->axis; axisf = bjoy->axisf; diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp index 4fc0b0ad3ec..a81d52f6698 100644 --- a/source/gameengine/Converter/KX_IpoConvert.cpp +++ b/source/gameengine/Converter/KX_IpoConvert.cpp @@ -96,7 +96,7 @@ SG_Controller *BL_CreateIPO(struct bAction *action, KX_GameObject* gameobj, KX_B const char *rotmode, *drotmode; - switch(blenderobject->rotmode) { + switch (blenderobject->rotmode) { case ROT_MODE_AXISANGLE: rotmode = "rotation_axis_angle"; drotmode = "delta_rotation_axis_angle"; diff --git a/source/gameengine/Expressions/BoolValue.cpp b/source/gameengine/Expressions/BoolValue.cpp index e640923129a..ee913877c96 100644 --- a/source/gameengine/Expressions/BoolValue.cpp +++ b/source/gameengine/Expressions/BoolValue.cpp @@ -104,39 +104,37 @@ this object { CValue *ret; - switch(dtype) - { - case VALUE_EMPTY_TYPE: - case VALUE_BOOL_TYPE: + switch (dtype) { + case VALUE_EMPTY_TYPE: + case VALUE_BOOL_TYPE: { - switch(op) - { - case VALUE_AND_OPERATOR: + switch (op) { + case VALUE_AND_OPERATOR: { ret = new CBoolValue (((CBoolValue *) val)->GetBool() && m_bool); break; } - case VALUE_OR_OPERATOR: + case VALUE_OR_OPERATOR: { ret = new CBoolValue (((CBoolValue *) val)->GetBool() || m_bool); break; } - case VALUE_EQL_OPERATOR: + case VALUE_EQL_OPERATOR: { ret = new CBoolValue (((CBoolValue *) val)->GetBool() == m_bool); break; } - case VALUE_NEQ_OPERATOR: + case VALUE_NEQ_OPERATOR: { ret = new CBoolValue (((CBoolValue *) val)->GetBool() != m_bool); break; } - case VALUE_NOT_OPERATOR: + case VALUE_NOT_OPERATOR: { return new CBoolValue (!m_bool); break; } - default: + default: { ret = new CErrorValue(val->GetText() + op2str(op) + "[operator not allowed on booleans]"); @@ -145,16 +143,15 @@ this object } break; } - case VALUE_STRING_TYPE: + case VALUE_STRING_TYPE: { - switch(op) - { - case VALUE_ADD_OPERATOR: + switch (op) { + case VALUE_ADD_OPERATOR: { ret = new CStringValue(val->GetText() + GetText(),""); break; } - default: + default: { ret = new CErrorValue(val->GetText() + op2str(op) + "[Only + allowed on boolean and string]"); break; @@ -162,8 +159,8 @@ this object } break; } - default: - ret = new CErrorValue("[type mismatch]" + op2str(op) + GetText()); + default: + ret = new CErrorValue("[type mismatch]" + op2str(op) + GetText()); } return ret; diff --git a/source/gameengine/Expressions/FloatValue.cpp b/source/gameengine/Expressions/FloatValue.cpp index c9b59e52ee8..b7d7f528155 100644 --- a/source/gameengine/Expressions/FloatValue.cpp +++ b/source/gameengine/Expressions/FloatValue.cpp @@ -120,138 +120,134 @@ ret: a new object containing the result of applying operator op to val and { CValue *ret; - switch(dtype) - { - case VALUE_INT_TYPE: + switch (dtype) { + case VALUE_INT_TYPE: { - switch (op) - { - case VALUE_MOD_OPERATOR: - ret = new CFloatValue(fmod(((CIntValue *) val)->GetInt(), m_float)); - break; - case VALUE_ADD_OPERATOR: - ret = new CFloatValue(((CIntValue *) val)->GetInt() + m_float); - break; - case VALUE_SUB_OPERATOR: - ret = new CFloatValue(((CIntValue *) val)->GetInt() - m_float); - break; - case VALUE_MUL_OPERATOR: - ret = new CFloatValue(((CIntValue *) val)->GetInt() * m_float); - break; - case VALUE_DIV_OPERATOR: - if (m_float == 0) - ret = new CErrorValue("Division by zero"); - else - ret = new CFloatValue (((CIntValue *) val)->GetInt() / m_float); - break; - case VALUE_EQL_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() == m_float); - break; - case VALUE_NEQ_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() != m_float); - break; - case VALUE_GRE_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() > m_float); - break; - case VALUE_LES_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() < m_float); - break; - case VALUE_GEQ_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() >= m_float); - break; - case VALUE_LEQ_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() <= m_float); - break; - default: - ret = new CErrorValue("illegal operator. please send a bug report."); - break; + switch (op) { + case VALUE_MOD_OPERATOR: + ret = new CFloatValue(fmod(((CIntValue *) val)->GetInt(), m_float)); + break; + case VALUE_ADD_OPERATOR: + ret = new CFloatValue(((CIntValue *) val)->GetInt() + m_float); + break; + case VALUE_SUB_OPERATOR: + ret = new CFloatValue(((CIntValue *) val)->GetInt() - m_float); + break; + case VALUE_MUL_OPERATOR: + ret = new CFloatValue(((CIntValue *) val)->GetInt() * m_float); + break; + case VALUE_DIV_OPERATOR: + if (m_float == 0) + ret = new CErrorValue("Division by zero"); + else + ret = new CFloatValue (((CIntValue *) val)->GetInt() / m_float); + break; + case VALUE_EQL_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() == m_float); + break; + case VALUE_NEQ_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() != m_float); + break; + case VALUE_GRE_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() > m_float); + break; + case VALUE_LES_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() < m_float); + break; + case VALUE_GEQ_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() >= m_float); + break; + case VALUE_LEQ_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() <= m_float); + break; + default: + ret = new CErrorValue("illegal operator. please send a bug report."); + break; } break; } - case VALUE_EMPTY_TYPE: - case VALUE_FLOAT_TYPE: + case VALUE_EMPTY_TYPE: + case VALUE_FLOAT_TYPE: { - switch (op) - { - case VALUE_MOD_OPERATOR: - ret = new CFloatValue(fmod(((CFloatValue *) val)->GetFloat(), m_float)); - break; - case VALUE_ADD_OPERATOR: - ret = new CFloatValue(((CFloatValue *) val)->GetFloat() + m_float); - break; - case VALUE_SUB_OPERATOR: - ret = new CFloatValue(((CFloatValue *) val)->GetFloat() - m_float); - break; - case VALUE_MUL_OPERATOR: - ret = new CFloatValue(((CFloatValue *) val)->GetFloat() * m_float); - break; - case VALUE_DIV_OPERATOR: - if (m_float == 0) - ret = new CErrorValue("Division by zero"); - else - ret = new CFloatValue (((CFloatValue *) val)->GetFloat() / m_float); - break; - case VALUE_EQL_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() == m_float); - break; - case VALUE_NEQ_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() != m_float); - break; - case VALUE_GRE_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() > m_float); - break; - case VALUE_LES_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() < m_float); - break; - case VALUE_GEQ_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() >= m_float); - break; - case VALUE_LEQ_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() <= m_float); - break; - case VALUE_NEG_OPERATOR: - ret = new CFloatValue (-m_float); - break; - case VALUE_POS_OPERATOR: - ret = new CFloatValue (m_float); - break; - - default: - ret = new CErrorValue("illegal operator. please send a bug report."); - break; + switch (op) { + case VALUE_MOD_OPERATOR: + ret = new CFloatValue(fmod(((CFloatValue *) val)->GetFloat(), m_float)); + break; + case VALUE_ADD_OPERATOR: + ret = new CFloatValue(((CFloatValue *) val)->GetFloat() + m_float); + break; + case VALUE_SUB_OPERATOR: + ret = new CFloatValue(((CFloatValue *) val)->GetFloat() - m_float); + break; + case VALUE_MUL_OPERATOR: + ret = new CFloatValue(((CFloatValue *) val)->GetFloat() * m_float); + break; + case VALUE_DIV_OPERATOR: + if (m_float == 0) + ret = new CErrorValue("Division by zero"); + else + ret = new CFloatValue (((CFloatValue *) val)->GetFloat() / m_float); + break; + case VALUE_EQL_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() == m_float); + break; + case VALUE_NEQ_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() != m_float); + break; + case VALUE_GRE_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() > m_float); + break; + case VALUE_LES_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() < m_float); + break; + case VALUE_GEQ_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() >= m_float); + break; + case VALUE_LEQ_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() <= m_float); + break; + case VALUE_NEG_OPERATOR: + ret = new CFloatValue (-m_float); + break; + case VALUE_POS_OPERATOR: + ret = new CFloatValue (m_float); + break; + + default: + ret = new CErrorValue("illegal operator. please send a bug report."); + break; } break; } - case VALUE_STRING_TYPE: + case VALUE_STRING_TYPE: { - switch(op) - { - case VALUE_ADD_OPERATOR: - ret = new CStringValue(val->GetText() + GetText(),""); - break; - case VALUE_EQL_OPERATOR: - case VALUE_NEQ_OPERATOR: - case VALUE_GRE_OPERATOR: - case VALUE_LES_OPERATOR: - case VALUE_GEQ_OPERATOR: - case VALUE_LEQ_OPERATOR: - ret = new CErrorValue("[Cannot compare string with float]" + op2str(op) + GetText()); - break; - default: - ret = new CErrorValue("[operator not allowed on strings]" + op2str(op) + GetText()); - break; + switch (op) { + case VALUE_ADD_OPERATOR: + ret = new CStringValue(val->GetText() + GetText(),""); + break; + case VALUE_EQL_OPERATOR: + case VALUE_NEQ_OPERATOR: + case VALUE_GRE_OPERATOR: + case VALUE_LES_OPERATOR: + case VALUE_GEQ_OPERATOR: + case VALUE_LEQ_OPERATOR: + ret = new CErrorValue("[Cannot compare string with float]" + op2str(op) + GetText()); + break; + default: + ret = new CErrorValue("[operator not allowed on strings]" + op2str(op) + GetText()); + break; } break; } - case VALUE_BOOL_TYPE: - ret = new CErrorValue("[operator not valid on boolean and float]" + op2str(op) + GetText()); - break; - case VALUE_ERROR_TYPE: - ret = new CErrorValue(val->GetText() + op2str(op) + GetText()); - break; - default: - ret = new CErrorValue("illegal type. contact your dealer (if any)"); - break; + case VALUE_BOOL_TYPE: + ret = new CErrorValue("[operator not valid on boolean and float]" + op2str(op) + GetText()); + break; + case VALUE_ERROR_TYPE: + ret = new CErrorValue(val->GetText() + op2str(op) + GetText()); + break; + default: + ret = new CErrorValue("illegal type. contact your dealer (if any)"); + break; } return ret; } diff --git a/source/gameengine/Expressions/InputParser.cpp b/source/gameengine/Expressions/InputParser.cpp index bdf4ee4605b..0a5af4a18ea 100644 --- a/source/gameengine/Expressions/InputParser.cpp +++ b/source/gameengine/Expressions/InputParser.cpp @@ -187,11 +187,10 @@ void CParser::NextSym() // sets the global variable cellcoord to the kind of operator errmsg = NULL; - while(ch == ' ' || ch == 0x9) + while (ch == ' ' || ch == 0x9) NextCh(); - switch(ch) - { + switch (ch) { case '(': sym = lbracksym; NextCh(); break; @@ -359,7 +358,7 @@ STR_String CParser::Symbol2Str(int s) { // returns a string representation of of symbol s, // for use in Term when generating an error - switch(s) { + switch (s) { case errorsym: return "error"; case lbracksym: return "("; case rbracksym: return ")"; @@ -394,7 +393,7 @@ int CParser::Priority(int optorkind) { // returns the priority of an operator // higher number means higher priority - switch(optorkind) { + switch (optorkind) { case OPor: return 1; case OPand: return 2; case OPgreater: @@ -426,102 +425,103 @@ CExpression *CParser::Ex(int i) opkind2 = opkind; NextSym(); e2 = Ex(i + 1); - switch(opkind2) { - case OPmodulus: e1 = new COperator2Expr(VALUE_MOD_OPERATOR,e1, e2); break; - case OPplus: e1 = new COperator2Expr(VALUE_ADD_OPERATOR,e1, e2); break; - case OPminus: e1 = new COperator2Expr(VALUE_SUB_OPERATOR,e1, e2); break; - case OPtimes: e1 = new COperator2Expr(VALUE_MUL_OPERATOR,e1, e2); break; - case OPdivide: e1 = new COperator2Expr(VALUE_DIV_OPERATOR,e1, e2); break; - case OPand: e1 = new COperator2Expr(VALUE_AND_OPERATOR,e1, e2); break; - case OPor: e1 = new COperator2Expr(VALUE_OR_OPERATOR,e1, e2); break; - case OPequal: e1 = new COperator2Expr(VALUE_EQL_OPERATOR,e1, e2); break; - case OPunequal: e1 = new COperator2Expr(VALUE_NEQ_OPERATOR,e1, e2); break; - case OPgreater: e1 = new COperator2Expr(VALUE_GRE_OPERATOR,e1, e2); break; - case OPless: e1 = new COperator2Expr(VALUE_LES_OPERATOR,e1, e2); break; - case OPgreaterequal: e1 = new COperator2Expr(VALUE_GEQ_OPERATOR,e1, e2); break; - case OPlessequal: e1 = new COperator2Expr(VALUE_LEQ_OPERATOR,e1, e2); break; - default: MT_assert(false); break; // should not happen + switch (opkind2) { + case OPmodulus: e1 = new COperator2Expr(VALUE_MOD_OPERATOR,e1, e2); break; + case OPplus: e1 = new COperator2Expr(VALUE_ADD_OPERATOR,e1, e2); break; + case OPminus: e1 = new COperator2Expr(VALUE_SUB_OPERATOR,e1, e2); break; + case OPtimes: e1 = new COperator2Expr(VALUE_MUL_OPERATOR,e1, e2); break; + case OPdivide: e1 = new COperator2Expr(VALUE_DIV_OPERATOR,e1, e2); break; + case OPand: e1 = new COperator2Expr(VALUE_AND_OPERATOR,e1, e2); break; + case OPor: e1 = new COperator2Expr(VALUE_OR_OPERATOR,e1, e2); break; + case OPequal: e1 = new COperator2Expr(VALUE_EQL_OPERATOR,e1, e2); break; + case OPunequal: e1 = new COperator2Expr(VALUE_NEQ_OPERATOR,e1, e2); break; + case OPgreater: e1 = new COperator2Expr(VALUE_GRE_OPERATOR,e1, e2); break; + case OPless: e1 = new COperator2Expr(VALUE_LES_OPERATOR,e1, e2); break; + case OPgreaterequal: e1 = new COperator2Expr(VALUE_GEQ_OPERATOR,e1, e2); break; + case OPlessequal: e1 = new COperator2Expr(VALUE_LEQ_OPERATOR,e1, e2); break; + default: MT_assert(false); break; // should not happen } } } else if (i == NUM_PRIORITY) { - if ((sym == opsym) - && ( (opkind == OPminus) || (opkind == OPnot) || (opkind == OPplus) ) - ) + if ((sym == opsym) + && ( (opkind == OPminus) || (opkind == OPnot) || (opkind == OPplus) ) + ) { NextSym(); - switch(opkind) { - /* +1 is also a valid number! */ - case OPplus: e1 = new COperator1Expr(VALUE_POS_OPERATOR, Ex(NUM_PRIORITY)); break; - case OPminus: e1 = new COperator1Expr(VALUE_NEG_OPERATOR, Ex(NUM_PRIORITY)); break; - case OPnot: e1 = new COperator1Expr(VALUE_NOT_OPERATOR, Ex(NUM_PRIORITY)); break; - default: { - // should not happen - e1 = Error("operator +, - or ! expected"); - } + switch (opkind) { + /* +1 is also a valid number! */ + case OPplus: e1 = new COperator1Expr(VALUE_POS_OPERATOR, Ex(NUM_PRIORITY)); break; + case OPminus: e1 = new COperator1Expr(VALUE_NEG_OPERATOR, Ex(NUM_PRIORITY)); break; + case OPnot: e1 = new COperator1Expr(VALUE_NOT_OPERATOR, Ex(NUM_PRIORITY)); break; + default: + { + // should not happen + e1 = Error("operator +, - or ! expected"); + } } } else { - switch(sym) { - case constsym: { - switch(constkind) { - case booltype: - e1 = new CConstExpr(new CBoolValue(boolvalue)); - break; - case inttype: - { - cInt temp; - temp = strtoll(const_as_string, NULL, 10); /* atoi is for int only */ - e1 = new CConstExpr(new CIntValue(temp)); - break; - } - case floattype: - { - double temp; - temp = atof(const_as_string); - e1 = new CConstExpr(new CFloatValue(temp)); - break; + switch (sym) { + case constsym: { + switch (constkind) { + case booltype: + e1 = new CConstExpr(new CBoolValue(boolvalue)); + break; + case inttype: + { + cInt temp; + temp = strtoll(const_as_string, NULL, 10); /* atoi is for int only */ + e1 = new CConstExpr(new CIntValue(temp)); + break; + } + case floattype: + { + double temp; + temp = atof(const_as_string); + e1 = new CConstExpr(new CFloatValue(temp)); + break; + } + case stringtype: + e1 = new CConstExpr(new CStringValue(const_as_string,"")); + break; + default : + MT_assert(false); + break; } - case stringtype: - e1 = new CConstExpr(new CStringValue(const_as_string,"")); - break; - default : - MT_assert(false); + NextSym(); break; } - NextSym(); - break; - } - case lbracksym: - NextSym(); - e1 = Ex(1); - Term(rbracksym); - break; - case ifsym: - { - CExpression *e3; - NextSym(); - Term(lbracksym); - e1 = Ex(1); - Term(commasym); - e2 = Ex(1); - if (sym == commasym) { + case lbracksym: NextSym(); - e3 = Ex(1); - } else { - e3 = new CConstExpr(new CEmptyValue()); + e1 = Ex(1); + Term(rbracksym); + break; + case ifsym: + { + CExpression *e3; + NextSym(); + Term(lbracksym); + e1 = Ex(1); + Term(commasym); + e2 = Ex(1); + if (sym == commasym) { + NextSym(); + e3 = Ex(1); + } else { + e3 = new CConstExpr(new CEmptyValue()); + } + Term(rbracksym); + e1 = new CIfExpr(e1, e2, e3); + break; } - Term(rbracksym); - e1 = new CIfExpr(e1, e2, e3); - break; - } - case idsym: + case idsym: { e1 = new CIdentifierExpr(const_as_string,m_identifierContext); NextSym(); break; } - case errorsym: + case errorsym: { MT_assert(!e1); STR_String errtext="[no info]"; @@ -530,7 +530,7 @@ CExpression *CParser::Ex(int i) CValue* errmsgval = errmsg->Calculate(); errtext=errmsgval->GetText(); errmsgval->Release(); - + //e1 = Error(errmsg->Calculate()->GetText());//new CConstExpr(errmsg->Calculate()); if ( !(errmsg->Release()) ) @@ -545,11 +545,11 @@ CExpression *CParser::Ex(int i) break; } - default: - NextSym(); - //return Error("Expression expected"); - MT_assert(!e1); - e1 = Error("Expression expected"); + default: + NextSym(); + //return Error("Expression expected"); + MT_assert(!e1); + e1 = Error("Expression expected"); } } } diff --git a/source/gameengine/Expressions/IntValue.cpp b/source/gameengine/Expressions/IntValue.cpp index 12d6e258ddf..cb6bc556bab 100644 --- a/source/gameengine/Expressions/IntValue.cpp +++ b/source/gameengine/Expressions/IntValue.cpp @@ -108,165 +108,160 @@ object and val } } - - -CValue* CIntValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val) /* -pre: the type of val is dtype -ret: a new object containing the result of applying operator op to val and -this object -*/ + * pre: the type of val is dtype + * ret: a new object containing the result of applying operator op to val and + * this object + */ +CValue* CIntValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val) { CValue *ret; - switch(dtype) { - case VALUE_EMPTY_TYPE: - case VALUE_INT_TYPE: + switch (dtype) { + case VALUE_EMPTY_TYPE: + case VALUE_INT_TYPE: { switch (op) { - case VALUE_MOD_OPERATOR: - ret = new CIntValue (((CIntValue *) val)->GetInt() % m_int); - break; - case VALUE_ADD_OPERATOR: - ret = new CIntValue (((CIntValue *) val)->GetInt() + m_int); - break; - case VALUE_SUB_OPERATOR: - ret = new CIntValue (((CIntValue *) val)->GetInt() - m_int); - break; - case VALUE_MUL_OPERATOR: - ret = new CIntValue (((CIntValue *) val)->GetInt() * m_int); - break; - case VALUE_DIV_OPERATOR: - if (m_int == 0) - { - if (val->GetNumber() == 0) - { - ret = new CErrorValue("Not a Number"); - } else - { - ret = new CErrorValue("Division by zero"); + case VALUE_MOD_OPERATOR: + ret = new CIntValue (((CIntValue *) val)->GetInt() % m_int); + break; + case VALUE_ADD_OPERATOR: + ret = new CIntValue (((CIntValue *) val)->GetInt() + m_int); + break; + case VALUE_SUB_OPERATOR: + ret = new CIntValue (((CIntValue *) val)->GetInt() - m_int); + break; + case VALUE_MUL_OPERATOR: + ret = new CIntValue (((CIntValue *) val)->GetInt() * m_int); + break; + case VALUE_DIV_OPERATOR: + if (m_int == 0) { + if (val->GetNumber() == 0) { + ret = new CErrorValue("Not a Number"); + } + else { + ret = new CErrorValue("Division by zero"); + } } - } - else - ret = new CIntValue (((CIntValue *) val)->GetInt() / m_int); - break; - case VALUE_EQL_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() == m_int); - break; - case VALUE_NEQ_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() != m_int); - break; - case VALUE_GRE_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() > m_int); - break; - case VALUE_LES_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() < m_int); - break; - case VALUE_GEQ_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() >= m_int); - break; - case VALUE_LEQ_OPERATOR: - ret = new CBoolValue(((CIntValue *) val)->GetInt() <= m_int); - break; - case VALUE_NEG_OPERATOR: - ret = new CIntValue (-m_int); - break; - case VALUE_POS_OPERATOR: - ret = new CIntValue (m_int); - break; - default: - ret = new CErrorValue("illegal operator. please send a bug report."); - break; + else + ret = new CIntValue (((CIntValue *) val)->GetInt() / m_int); + break; + case VALUE_EQL_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() == m_int); + break; + case VALUE_NEQ_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() != m_int); + break; + case VALUE_GRE_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() > m_int); + break; + case VALUE_LES_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() < m_int); + break; + case VALUE_GEQ_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() >= m_int); + break; + case VALUE_LEQ_OPERATOR: + ret = new CBoolValue(((CIntValue *) val)->GetInt() <= m_int); + break; + case VALUE_NEG_OPERATOR: + ret = new CIntValue (-m_int); + break; + case VALUE_POS_OPERATOR: + ret = new CIntValue (m_int); + break; + default: + ret = new CErrorValue("illegal operator. please send a bug report."); + break; } break; } - case VALUE_FLOAT_TYPE: + case VALUE_FLOAT_TYPE: { switch (op) { - case VALUE_MOD_OPERATOR: - ret = new CFloatValue(fmod(((CFloatValue *) val)->GetFloat(), m_int)); - break; - case VALUE_ADD_OPERATOR: - ret = new CFloatValue (((CFloatValue *) val)->GetFloat() + m_int); - break; - case VALUE_SUB_OPERATOR: - ret = new CFloatValue (((CFloatValue *) val)->GetFloat() - m_int); - break; - case VALUE_MUL_OPERATOR: - ret = new CFloatValue (((CFloatValue *) val)->GetFloat() * m_int); - break; - case VALUE_DIV_OPERATOR: - if (m_int == 0) - ret = new CErrorValue("Division by zero"); - else - ret = new CFloatValue (((CFloatValue *) val)->GetFloat() / m_int); - break; - case VALUE_EQL_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() == m_int); - break; - case VALUE_NEQ_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() != m_int); - break; - case VALUE_GRE_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() > m_int); - break; - case VALUE_LES_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() < m_int); - break; - case VALUE_GEQ_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() >= m_int); - break; - case VALUE_LEQ_OPERATOR: - ret = new CBoolValue(((CFloatValue *) val)->GetFloat() <= m_int); - break; - default: - ret = new CErrorValue("illegal operator. please send a bug report."); - break; + case VALUE_MOD_OPERATOR: + ret = new CFloatValue(fmod(((CFloatValue *) val)->GetFloat(), m_int)); + break; + case VALUE_ADD_OPERATOR: + ret = new CFloatValue (((CFloatValue *) val)->GetFloat() + m_int); + break; + case VALUE_SUB_OPERATOR: + ret = new CFloatValue (((CFloatValue *) val)->GetFloat() - m_int); + break; + case VALUE_MUL_OPERATOR: + ret = new CFloatValue (((CFloatValue *) val)->GetFloat() * m_int); + break; + case VALUE_DIV_OPERATOR: + if (m_int == 0) + ret = new CErrorValue("Division by zero"); + else + ret = new CFloatValue (((CFloatValue *) val)->GetFloat() / m_int); + break; + case VALUE_EQL_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() == m_int); + break; + case VALUE_NEQ_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() != m_int); + break; + case VALUE_GRE_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() > m_int); + break; + case VALUE_LES_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() < m_int); + break; + case VALUE_GEQ_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() >= m_int); + break; + case VALUE_LEQ_OPERATOR: + ret = new CBoolValue(((CFloatValue *) val)->GetFloat() <= m_int); + break; + default: + ret = new CErrorValue("illegal operator. please send a bug report."); + break; } break; } - case VALUE_STRING_TYPE: + case VALUE_STRING_TYPE: { - switch(op) { - case VALUE_ADD_OPERATOR: - ret = new CStringValue(val->GetText() + GetText(),""); - break; - case VALUE_EQL_OPERATOR: - case VALUE_NEQ_OPERATOR: - case VALUE_GRE_OPERATOR: - case VALUE_LES_OPERATOR: - case VALUE_GEQ_OPERATOR: - case VALUE_LEQ_OPERATOR: - ret = new CErrorValue("[Cannot compare string with integer]" + op2str(op) + GetText()); - break; - default: - ret = new CErrorValue("[operator not allowed on strings]" + op2str(op) + GetText()); - break; + switch (op) { + case VALUE_ADD_OPERATOR: + ret = new CStringValue(val->GetText() + GetText(),""); + break; + case VALUE_EQL_OPERATOR: + case VALUE_NEQ_OPERATOR: + case VALUE_GRE_OPERATOR: + case VALUE_LES_OPERATOR: + case VALUE_GEQ_OPERATOR: + case VALUE_LEQ_OPERATOR: + ret = new CErrorValue("[Cannot compare string with integer]" + op2str(op) + GetText()); + break; + default: + ret = new CErrorValue("[operator not allowed on strings]" + op2str(op) + GetText()); + break; } break; } - case VALUE_BOOL_TYPE: - ret = new CErrorValue("[operator not valid on boolean and integer]" + op2str(op) + GetText()); - break; - /* + case VALUE_BOOL_TYPE: + ret = new CErrorValue("[operator not valid on boolean and integer]" + op2str(op) + GetText()); + break; +#if 0 case VALUE_EMPTY_TYPE: { - switch(op) { - - case VALUE_ADD_OPERATOR: - ret = new CIntValue (m_int); - break; - case VALUE_SUB_OPERATOR: - ret = new CIntValue (-m_int); - break; - default: - { - ret = new CErrorValue(op2str(op) + GetText()); - } - } - break; - } - */ + switch (op) { + case VALUE_ADD_OPERATOR: + ret = new CIntValue (m_int); + break; + case VALUE_SUB_OPERATOR: + ret = new CIntValue (-m_int); + break; + default: + { + ret = new CErrorValue(op2str(op) + GetText()); + } + } + break; + } +#endif case VALUE_ERROR_TYPE: ret = new CErrorValue(val->GetText() + op2str(op) + GetText()); break; diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp index 43f84d273fd..8cff5a01c0e 100644 --- a/source/gameengine/Expressions/ListValue.cpp +++ b/source/gameengine/Expressions/ListValue.cpp @@ -468,9 +468,9 @@ static PyObject *listvalue_buffer_concat(PyObject *self, PyObject *other) static int listvalue_buffer_contains(PyObject *self_v, PyObject *value) { - CListValue *self= static_cast<CListValue *>(BGE_PROXY_REF(self_v)); + CListValue *self = static_cast<CListValue *>(BGE_PROXY_REF(self_v)); - if (self==NULL) { + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "val in CList, "BGE_PROXY_ERROR_MSG); return -1; } diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp index 6bb2f039b5c..bb1d0a31c1f 100644 --- a/source/gameengine/Expressions/PyObjectPlus.cpp +++ b/source/gameengine/Expressions/PyObjectPlus.cpp @@ -170,7 +170,7 @@ PyObject *PyObjectPlus::py_base_new(PyTypeObject *type, PyObject *args, PyObject * * */ base_type= Py_TYPE(base); - while(base_type && !BGE_PROXY_CHECK_TYPE(base_type)) + while (base_type && !BGE_PROXY_CHECK_TYPE(base_type)) base_type= base_type->tp_base; if (base_type==NULL || !BGE_PROXY_CHECK_TYPE(base_type)) { @@ -1198,8 +1198,7 @@ void PyObjectPlus::ClearDeprecationWarning() WarnLink *wlink_next; WarnLink *wlink = GetDeprecationWarningLinkFirst(); - while(wlink) - { + while (wlink) { wlink->warn_done= false; /* no need to NULL the link, its cleared before adding to the list next time round */ wlink_next= reinterpret_cast<WarnLink *>(wlink->link); wlink->link= NULL; diff --git a/source/gameengine/Expressions/StringValue.cpp b/source/gameengine/Expressions/StringValue.cpp index 2e29a39222b..166125bc906 100644 --- a/source/gameengine/Expressions/StringValue.cpp +++ b/source/gameengine/Expressions/StringValue.cpp @@ -77,33 +77,34 @@ CValue* CStringValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue ret = new CErrorValue(val->GetText() + op2str(op) + GetText()); else ret = new CStringValue(val->GetText() + GetText(),""); - } else { - + } + else { if (dtype == VALUE_STRING_TYPE || dtype == VALUE_EMPTY_TYPE) { - switch(op) { - case VALUE_EQL_OPERATOR: - ret = new CBoolValue(val->GetText() == GetText()); - break; - case VALUE_NEQ_OPERATOR: - ret = new CBoolValue(val->GetText() != GetText()); - break; - case VALUE_GRE_OPERATOR: - ret = new CBoolValue(val->GetText() > GetText()); - break; - case VALUE_LES_OPERATOR: - ret = new CBoolValue(val->GetText() < GetText()); - break; - case VALUE_GEQ_OPERATOR: - ret = new CBoolValue(val->GetText() >= GetText()); - break; - case VALUE_LEQ_OPERATOR: - ret = new CBoolValue(val->GetText() <= GetText()); - break; - default: - ret = new CErrorValue(val->GetText() + op2str(op) + "[operator not allowed on strings]"); - break; + switch (op) { + case VALUE_EQL_OPERATOR: + ret = new CBoolValue(val->GetText() == GetText()); + break; + case VALUE_NEQ_OPERATOR: + ret = new CBoolValue(val->GetText() != GetText()); + break; + case VALUE_GRE_OPERATOR: + ret = new CBoolValue(val->GetText() > GetText()); + break; + case VALUE_LES_OPERATOR: + ret = new CBoolValue(val->GetText() < GetText()); + break; + case VALUE_GEQ_OPERATOR: + ret = new CBoolValue(val->GetText() >= GetText()); + break; + case VALUE_LEQ_OPERATOR: + ret = new CBoolValue(val->GetText() <= GetText()); + break; + default: + ret = new CErrorValue(val->GetText() + op2str(op) + "[operator not allowed on strings]"); + break; } - } else { + } + else { ret = new CErrorValue(val->GetText() + op2str(op) + "[operator not allowed on strings]"); } } diff --git a/source/gameengine/Expressions/VectorValue.cpp b/source/gameengine/Expressions/VectorValue.cpp index ed13b0c8639..612de658ce9 100644 --- a/source/gameengine/Expressions/VectorValue.cpp +++ b/source/gameengine/Expressions/VectorValue.cpp @@ -96,61 +96,60 @@ CValue* CVectorValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue { CValue *ret = NULL; - switch(op) - { - case VALUE_ADD_OPERATOR: + switch (op) { + case VALUE_ADD_OPERATOR: { switch (dtype) { - case VALUE_EMPTY_TYPE: - case VALUE_VECTOR_TYPE: + case VALUE_EMPTY_TYPE: + case VALUE_VECTOR_TYPE: { ret = new CVectorValue( - val->GetVector3()[KX_X] + GetVector3()[KX_X], - val->GetVector3()[KX_Y] + GetVector3()[KX_Y], - val->GetVector3()[KX_Z] + GetVector3()[KX_Z], - CValue::HEAPVALUE); + val->GetVector3()[KX_X] + GetVector3()[KX_X], + val->GetVector3()[KX_Y] + GetVector3()[KX_Y], + val->GetVector3()[KX_Z] + GetVector3()[KX_Z], + CValue::HEAPVALUE); ret->SetName(GetName()); break; } - - default: - ret = new CErrorValue(val->GetText() + op2str(op) + GetText()); + + default: + ret = new CErrorValue(val->GetText() + op2str(op) + GetText()); } break; } - case VALUE_MUL_OPERATOR: + case VALUE_MUL_OPERATOR: { switch (dtype) { - case VALUE_EMPTY_TYPE: - case VALUE_VECTOR_TYPE: + case VALUE_EMPTY_TYPE: + case VALUE_VECTOR_TYPE: { //MT_Vector3 supports 'scaling' by another vector, instead of using general transform, Gino? //ret = new CVectorValue(val->GetVector3().Scaled(GetVector3()),GetName()); break; } - case VALUE_FLOAT_TYPE: + case VALUE_FLOAT_TYPE: { ret = new CVectorValue( - val->GetVector3()[KX_X] * GetVector3()[KX_X], - val->GetVector3()[KX_Y] * GetVector3()[KX_Y], - val->GetVector3()[KX_Z] * GetVector3()[KX_Z], - CValue::HEAPVALUE); + val->GetVector3()[KX_X] * GetVector3()[KX_X], + val->GetVector3()[KX_Y] * GetVector3()[KX_Y], + val->GetVector3()[KX_Z] * GetVector3()[KX_Z], + CValue::HEAPVALUE); ret->SetName(GetName()); break; } - - default: - ret = new CErrorValue(val->GetText() + op2str(op) + GetText()); + + default: + ret = new CErrorValue(val->GetText() + op2str(op) + GetText()); } break; } - - default: - ret = new CErrorValue(val->GetText() + op2str(op) + GetText()); + + default: + ret = new CErrorValue(val->GetText() + op2str(op) + GetText()); } diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp index 48fa3257d20..8b343be8226 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp @@ -51,11 +51,11 @@ SCA_Joystick::SCA_Joystick(short int index) m_istrig_button(0), m_istrig_hat(0) { - for (int i=0; i<JOYAXIS_MAX; i++) - m_axis_array[i]= 0; + for (int i=0; i < JOYAXIS_MAX; i++) + m_axis_array[i] = 0; - for (int i=0; i<JOYHAT_MAX; i++) - m_hat_array[i]= 0; + for (int i=0; i < JOYHAT_MAX; i++) + m_hat_array[i] = 0; #ifdef WITH_SDL m_private = new PrivateData(); @@ -88,9 +88,9 @@ SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex ) if (m_refCount == 0) { int i; - // The video subsystem is required for joystick input to work. However, - // when GHOST is running under SDL, video is initialized elsewhere. - // Do this once only. + /* The video subsystem is required for joystick input to work. However, + * when GHOST is running under SDL, video is initialized elsewhere. + * Do this once only. */ # ifdef WITH_GHOST_SDL if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1 ) { # else @@ -127,12 +127,12 @@ void SCA_Joystick::ReleaseInstance() m_instance[i]->DestroyJoystickDevice(); delete m_instance[i]; } - m_instance[i]= NULL; + m_instance[i] = NULL; } - // The video subsystem is required for joystick input to work. However, - // when GHOST is running under SDL, video is freed elsewhere. - // Do this once only. + /* The video subsystem is required for joystick input to work. However, + * when GHOST is running under SDL, video is freed elsewhere. + * Do this once only. */ # ifdef WITH_GHOST_SDL SDL_QuitSubSystem(SDL_INIT_JOYSTICK); # else @@ -241,10 +241,10 @@ bool SCA_Joystick::CreateJoystickDevice(void) #else /* WITH_SDL */ if (m_isinit == false) { if (m_joyindex>=m_joynum) { - // don't print a message, because this is done anyway + /* don't print a message, because this is done anyway */ //ECHO("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)"); - // Need this so python args can return empty lists + /* Need this so python args can return empty lists */ m_axismax = m_buttonmax = m_hatmax = 0; return false; } @@ -256,17 +256,17 @@ bool SCA_Joystick::CreateJoystickDevice(void) ECHO("Joystick " << m_joyindex << " initialized"); /* must run after being initialized */ - m_axismax = SDL_JoystickNumAxes(m_private->m_joystick); - m_buttonmax = SDL_JoystickNumButtons(m_private->m_joystick); - m_hatmax = SDL_JoystickNumHats(m_private->m_joystick); - - if (m_axismax > JOYAXIS_MAX) m_axismax= JOYAXIS_MAX; /* very unlikely */ - else if (m_axismax < 0) m_axismax = 0; + m_axismax = SDL_JoystickNumAxes(m_private->m_joystick); + m_buttonmax = SDL_JoystickNumButtons(m_private->m_joystick); + m_hatmax = SDL_JoystickNumHats(m_private->m_joystick); + + if (m_axismax > JOYAXIS_MAX) m_axismax = JOYAXIS_MAX; /* very unlikely */ + else if (m_axismax < 0) m_axismax = 0; - if (m_hatmax > JOYHAT_MAX) m_hatmax= JOYHAT_MAX; /* very unlikely */ - else if (m_hatmax<0) m_hatmax= 0; + if (m_hatmax > JOYHAT_MAX) m_hatmax = JOYHAT_MAX; /* very unlikely */ + else if (m_hatmax < 0) m_hatmax = 0; - if (m_buttonmax<0) m_buttonmax= 0; + if (m_buttonmax < 0) m_buttonmax = 0; } return true; @@ -307,16 +307,16 @@ int SCA_Joystick::pGetAxis(int axisnum, int udlr) int SCA_Joystick::pAxisTest(int axisnum) { #ifdef WITH_SDL - short i1= m_axis_array[(axisnum*2)]; - short i2= m_axis_array[(axisnum*2)+1]; + short i1 = m_axis_array[(axisnum * 2)]; + short i2 = m_axis_array[(axisnum * 2) + 1]; - /* long winded way to do - * return maxf(absf(i1), absf(i2)) - * avoid abs from math.h */ + /* long winded way to do: + * return max_ff(absf(i1), absf(i2)) + * ...avoid abs from math.h */ if (i1 < 0) i1 = -i1; if (i2 < 0) i2 = -i2; if (i1 <i2) return i2; - else return i1; + else return i1; #else /* WITH_SDL */ return 0; #endif /* WITH_SDL */ diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp index efe76c3eb46..f50137cfcf6 100644 --- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp +++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp @@ -43,7 +43,7 @@ void SCA_Joystick::OnAxisMotion(SDL_Event* sdl_event) if (sdl_event->jaxis.axis >= JOYAXIS_MAX) return; - m_axis_array[sdl_event->jaxis.axis]= sdl_event->jaxis.value; + m_axis_array[sdl_event->jaxis.axis] = sdl_event->jaxis.value; m_istrig_axis = 1; } @@ -53,7 +53,7 @@ void SCA_Joystick::OnHatMotion(SDL_Event* sdl_event) if (sdl_event->jhat.hat >= JOYHAT_MAX) return; - m_hat_array[sdl_event->jhat.hat]= sdl_event->jhat.value; + m_hat_array[sdl_event->jhat.hat] = sdl_event->jhat.value; m_istrig_hat = 1; } @@ -89,8 +89,7 @@ void SCA_Joystick::HandleEvents(void) SCA_Joystick::m_instance[i]->OnNothing(&sdl_event); } - while(SDL_PollEvent(&sdl_event)) - { + while (SDL_PollEvent(&sdl_event)) { /* Note! m_instance[sdl_event.jaxis.which] * will segfault if over JOYINDEX_MAX, not too nice but what are the chances? */ @@ -100,28 +99,27 @@ void SCA_Joystick::HandleEvents(void) /* Note!, if you manage to press and release a button within 1 logic tick * it wont work as it should */ - switch(sdl_event.type) - { - case SDL_JOYAXISMOTION: - SCA_Joystick::m_instance[sdl_event.jaxis.which]->OnAxisMotion(&sdl_event); - break; - case SDL_JOYHATMOTION: - SCA_Joystick::m_instance[sdl_event.jhat.which]->OnHatMotion(&sdl_event); - break; - case SDL_JOYBUTTONUP: - SCA_Joystick::m_instance[sdl_event.jbutton.which]->OnButtonUp(&sdl_event); - break; - case SDL_JOYBUTTONDOWN: - SCA_Joystick::m_instance[sdl_event.jbutton.which]->OnButtonDown(&sdl_event); - break; + switch (sdl_event.type) { + case SDL_JOYAXISMOTION: + SCA_Joystick::m_instance[sdl_event.jaxis.which]->OnAxisMotion(&sdl_event); + break; + case SDL_JOYHATMOTION: + SCA_Joystick::m_instance[sdl_event.jhat.which]->OnHatMotion(&sdl_event); + break; + case SDL_JOYBUTTONUP: + SCA_Joystick::m_instance[sdl_event.jbutton.which]->OnButtonUp(&sdl_event); + break; + case SDL_JOYBUTTONDOWN: + SCA_Joystick::m_instance[sdl_event.jbutton.which]->OnButtonDown(&sdl_event); + break; #if 0 /* Not used yet */ - case SDL_JOYBALLMOTION: - SCA_Joystick::m_instance[sdl_event.jball.which]->OnBallMotion(&sdl_event); - break; + case SDL_JOYBALLMOTION: + SCA_Joystick::m_instance[sdl_event.jball.which]->OnBallMotion(&sdl_event); + break; #endif - default: - printf("SCA_Joystick::HandleEvents, Unknown SDL event, this should not happen\n"); - break; + default: + printf("SCA_Joystick::HandleEvents, Unknown SDL event, this should not happen\n"); + break; } } } diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp index 6d76f122163..57f7dd64287 100644 --- a/source/gameengine/GameLogic/SCA_IController.cpp +++ b/source/gameengine/GameLogic/SCA_IController.cpp @@ -240,7 +240,7 @@ PyAttributeDef SCA_IController::Attributes[] = { PyObject *SCA_IController::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_IController* self= static_cast<SCA_IController*>(self_v); + SCA_IController* self = static_cast<SCA_IController*>(self_v); return PyLong_FromSsize_t(self->m_statemask); } diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h index bc4d22eaaaf..1a403f40955 100644 --- a/source/gameengine/GameLogic/SCA_IInputDevice.h +++ b/source/gameengine/GameLogic/SCA_IInputDevice.h @@ -167,9 +167,9 @@ public: KX_CAPSLOCKKEY, // 123 KX_LEFTCTRLKEY, // 124 - KX_LEFTALTKEY, - KX_RIGHTALTKEY, - KX_RIGHTCTRLKEY, + KX_LEFTALTKEY, + KX_RIGHTALTKEY, + KX_RIGHTCTRLKEY, KX_RIGHTSHIFTKEY, KX_LEFTSHIFTKEY,// 129 diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp index cfbdc1e750f..ab0e6c5edcb 100644 --- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp +++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp @@ -233,7 +233,7 @@ int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef) /*Attribute functions */ PyObject *SCA_ILogicBrick::pyattr_get_owner(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_ILogicBrick* self= static_cast<SCA_ILogicBrick*>(self_v); + SCA_ILogicBrick* self = static_cast<SCA_ILogicBrick*>(self_v); CValue* parent = self->GetParent(); if (parent) diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp index 7cf0b18c3b5..bfb78abef04 100644 --- a/source/gameengine/GameLogic/SCA_ISensor.cpp +++ b/source/gameengine/GameLogic/SCA_ISensor.cpp @@ -382,7 +382,7 @@ PyAttributeDef SCA_ISensor::Attributes[] = { PyObject *SCA_ISensor::pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v); + SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v); int retval = 0; if (SCA_PythonController::m_sCurrentController) retval = SCA_PythonController::m_sCurrentController->IsTriggered(self); @@ -391,13 +391,13 @@ PyObject *SCA_ISensor::pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_D PyObject *SCA_ISensor::pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v); + SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v); return PyLong_FromSsize_t(self->GetState()); } PyObject *SCA_ISensor::pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v); + SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v); int status = 0; if (self->GetState()) { @@ -419,19 +419,19 @@ PyObject *SCA_ISensor::pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF PyObject *SCA_ISensor::pyattr_get_posTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v); + SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v); return PyLong_FromLong(self->GetPosTicks()); } PyObject *SCA_ISensor::pyattr_get_negTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v); + SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v); return PyLong_FromLong(self->GetNegTicks()); } int SCA_ISensor::pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v); + SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v); if (self->m_level) self->m_tap = false; return 0; @@ -439,7 +439,7 @@ int SCA_ISensor::pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attr int SCA_ISensor::pyattr_check_tap(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v); + SCA_ISensor* self = static_cast<SCA_ISensor*>(self_v); if (self->m_tap) self->m_level = false; return 0; diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp index 7e9a4bc903c..0c4dcae16f7 100644 --- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp +++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp @@ -113,21 +113,21 @@ bool SCA_JoystickSensor::Evaluate() return false; m_reset = false; - switch(m_joymode) - { - case KX_JOYSENSORMODE_AXIS: + + switch (m_joymode) { + case KX_JOYSENSORMODE_AXIS: { - /* what is what! - m_axisf == JOYAXIS_RIGHT, JOYAXIS_UP, JOYAXIS_DOWN, JOYAXIS_LEFT - m_axisf == 1 == up - m_axisf == 2 == left - m_axisf == 3 == down - - numberof== m_axis (1-4), range is half of JOYAXIS_MAX since - it assumes the axis joysticks are axis parirs (0,1), (2,3), etc - also note that this starts at 1 where functions its used - with expect a zero index. - */ + /* what is what! + * m_axisf == JOYAXIS_RIGHT, JOYAXIS_UP, JOYAXIS_DOWN, JOYAXIS_LEFT + * m_axisf == 1 == up + * m_axisf == 2 == left + * m_axisf == 3 == down + * + * numberof== m_axis (1-4), range is half of JOYAXIS_MAX since + * it assumes the axis joysticks are axis parirs (0,1), (2,3), etc + * also note that this starts at 1 where functions its used + * with expect a zero index. + */ if (!js->IsTrigAxis() && !reset) /* No events from SDL? - don't bother */ return false; @@ -159,7 +159,7 @@ bool SCA_JoystickSensor::Evaluate() } break; } - case KX_JOYSENSORMODE_AXIS_SINGLE: + case KX_JOYSENSORMODE_AXIS_SINGLE: { /* Like KX_JOYSENSORMODE_AXIS but don't pair up axis */ if (!js->IsTrigAxis() && !reset) /* No events from SDL? - don't bother */ @@ -179,12 +179,12 @@ bool SCA_JoystickSensor::Evaluate() } break; } - - case KX_JOYSENSORMODE_BUTTON: + + case KX_JOYSENSORMODE_BUTTON: { - /* what is what! - m_button = the actual button in question - */ + /* what is what! + * m_button = the actual button in question + */ if (!js->IsTrigButton() && !reset) /* No events from SDL? - don't bother */ return false; @@ -200,12 +200,12 @@ bool SCA_JoystickSensor::Evaluate() } break; } - case KX_JOYSENSORMODE_HAT: + case KX_JOYSENSORMODE_HAT: { - /* what is what! - numberof = m_hat -- max 4 - direction= m_hatf -- max 12 - */ + /* what is what! + * numberof = m_hat -- max 4 + * direction= m_hatf -- max 12 + */ if (!js->IsTrigHat() && !reset) /* No events from SDL? - don't bother */ return false; @@ -222,18 +222,19 @@ bool SCA_JoystickSensor::Evaluate() } break; } - /* test for ball anyone ?*/ - default: - printf("Error invalid switch statement\n"); - break; + /* test for ball anyone ?*/ + default: + printf("Error invalid switch statement\n"); + break; } - /* if not all events are enabled, only send a positive pulse when + /* if not all events are enabled, only send a positive pulse when * the button state changes */ if (!m_bAllEvents) { if (m_istrig_prev == m_istrig) { result = false; - } else { + } + else { m_istrig_prev = m_istrig; } } @@ -347,13 +348,13 @@ PyObject *SCA_JoystickSensor::PyGetButtonStatus( PyObject *args ) PyObject *SCA_JoystickSensor::pyattr_get_axis_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); + SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); int axis_index= joy->GetNumberOfAxes(); PyObject *list= PyList_New(axis_index); - while(axis_index--) { + while (axis_index--) { PyList_SET_ITEM(list, axis_index, PyLong_FromSsize_t(joy->GetAxisPosition(axis_index))); } @@ -362,7 +363,7 @@ PyObject *SCA_JoystickSensor::pyattr_get_axis_values(void *self_v, const KX_PYAT PyObject *SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); + SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); if (self->m_joymode != KX_JOYSENSORMODE_AXIS_SINGLE) { @@ -375,13 +376,13 @@ PyObject *SCA_JoystickSensor::pyattr_get_axis_single(void *self_v, const KX_PYAT PyObject *SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); + SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); int hat_index= joy->GetNumberOfHats(); PyObject *list= PyList_New(hat_index); - while(hat_index--) { + while (hat_index--) { PyList_SET_ITEM(list, hat_index, PyLong_FromSsize_t(joy->GetHat(hat_index))); } @@ -390,7 +391,7 @@ PyObject *SCA_JoystickSensor::pyattr_get_hat_values(void *self_v, const KX_PYATT PyObject *SCA_JoystickSensor::pyattr_get_hat_single(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); + SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); return PyLong_FromSsize_t(joy->GetHat(self->m_hat-1)); @@ -398,28 +399,28 @@ PyObject *SCA_JoystickSensor::pyattr_get_hat_single(void *self_v, const KX_PYATT PyObject *SCA_JoystickSensor::pyattr_get_num_axis(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); + SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); return PyLong_FromSsize_t( joy ? joy->GetNumberOfAxes() : 0 ); } PyObject *SCA_JoystickSensor::pyattr_get_num_buttons(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); + SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); return PyLong_FromSsize_t( joy ? joy->GetNumberOfButtons() : 0 ); } PyObject *SCA_JoystickSensor::pyattr_get_num_hats(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); + SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); return PyLong_FromSsize_t( joy ? joy->GetNumberOfHats() : 0 ); } PyObject *SCA_JoystickSensor::pyattr_get_connected(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_JoystickSensor* self= static_cast<SCA_JoystickSensor*>(self_v); + SCA_JoystickSensor* self = static_cast<SCA_JoystickSensor*>(self_v); SCA_Joystick *joy = ((SCA_JoystickManager *)self->m_eventmgr)->GetJoystickDevice(self->m_joyindex); return PyBool_FromLong( joy ? joy->Connected() : 0 ); } diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp index 9a2dd9bdd57..b3346270b61 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp +++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp @@ -225,37 +225,37 @@ bool SCA_KeyboardSensor::Evaluate() */ if (m_qual > 0) { const SCA_InputEvent & qualevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) m_qual); - switch(qualevent.m_status) { - case SCA_InputEvent::KX_NO_INPUTSTATUS: - qual = false; - break; - case SCA_InputEvent::KX_JUSTRELEASED: - qual_change = true; - qual = false; - break; - case SCA_InputEvent::KX_JUSTACTIVATED: - qual_change = true; - case SCA_InputEvent::KX_ACTIVE: - /* do nothing */ - break; + switch (qualevent.m_status) { + case SCA_InputEvent::KX_NO_INPUTSTATUS: + qual = false; + break; + case SCA_InputEvent::KX_JUSTRELEASED: + qual_change = true; + qual = false; + break; + case SCA_InputEvent::KX_JUSTACTIVATED: + qual_change = true; + case SCA_InputEvent::KX_ACTIVE: + /* do nothing */ + break; } } if (m_qual2 > 0 && qual==true) { const SCA_InputEvent & qualevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) m_qual2); /* copy of above */ - switch(qualevent.m_status) { - case SCA_InputEvent::KX_NO_INPUTSTATUS: - qual = false; - break; - case SCA_InputEvent::KX_JUSTRELEASED: - qual_change = true; - qual = false; - break; - case SCA_InputEvent::KX_JUSTACTIVATED: - qual_change = true; - case SCA_InputEvent::KX_ACTIVE: - /* do nothing */ - break; + switch (qualevent.m_status) { + case SCA_InputEvent::KX_NO_INPUTSTATUS: + qual = false; + break; + case SCA_InputEvent::KX_JUSTRELEASED: + qual_change = true; + qual = false; + break; + case SCA_InputEvent::KX_JUSTACTIVATED: + qual_change = true; + case SCA_InputEvent::KX_ACTIVE: + /* do nothing */ + break; } } /* done reading qualifiers */ @@ -497,7 +497,7 @@ PyAttributeDef SCA_KeyboardSensor::Attributes[] = { PyObject *SCA_KeyboardSensor::pyattr_get_events(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_KeyboardSensor* self= static_cast<SCA_KeyboardSensor*>(self_v); + SCA_KeyboardSensor* self = static_cast<SCA_KeyboardSensor*>(self_v); SCA_IInputDevice* inputdev = ((SCA_KeyboardManager *)self->m_eventmgr)->GetInputDevice(); diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 7dbbbb2a0d9..ece9d7b6c8f 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -376,64 +376,63 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr) PyObject *excdict= NULL; PyObject *resultobj= NULL; - switch(m_mode) { - case SCA_PYEXEC_SCRIPT: - { - if (m_bModified) - if (Compile()==false) // sets m_bModified to false + switch (m_mode) { + case SCA_PYEXEC_SCRIPT: + { + if (m_bModified) + if (Compile()==false) // sets m_bModified to false + return; + if (!m_bytecode) return; - if (!m_bytecode) - return; - - /* - * This part here with excdict is a temporary patch - * to avoid python/gameengine crashes when python - * inadvertently holds references to game objects - * in global variables. - * - * The idea is always make a fresh dictionary, and - * destroy it right after it is used to make sure - * python won't hold any gameobject references. - * - * Note that the PyDict_Clear _is_ necessary before - * the Py_DECREF() because it is possible for the - * variables inside the dictionary to hold references - * to the dictionary (ie. generate a cycle), so we - * break it by hand, then DECREF (which in this case - * should always ensure excdict is cleared). - */ - - excdict= PyDict_Copy(m_pythondictionary); - - resultobj = PyEval_EvalCode((PyObject *)m_bytecode, excdict, excdict); - - /* PyRun_SimpleString(m_scriptText.Ptr()); */ - break; - } - case SCA_PYEXEC_MODULE: - { - if (m_bModified || m_debug) - if (Import()==false) // sets m_bModified to false + + /* + * This part here with excdict is a temporary patch + * to avoid python/gameengine crashes when python + * inadvertently holds references to game objects + * in global variables. + * + * The idea is always make a fresh dictionary, and + * destroy it right after it is used to make sure + * python won't hold any gameobject references. + * + * Note that the PyDict_Clear _is_ necessary before + * the Py_DECREF() because it is possible for the + * variables inside the dictionary to hold references + * to the dictionary (ie. generate a cycle), so we + * break it by hand, then DECREF (which in this case + * should always ensure excdict is cleared). + */ + + excdict= PyDict_Copy(m_pythondictionary); + + resultobj = PyEval_EvalCode((PyObject *)m_bytecode, excdict, excdict); + + /* PyRun_SimpleString(m_scriptText.Ptr()); */ + break; + } + case SCA_PYEXEC_MODULE: + { + if (m_bModified || m_debug) + if (Import()==false) // sets m_bModified to false + return; + if (!m_function) return; - if (!m_function) - return; - - PyObject *args= NULL; - - if (m_function_argc==1) { - args = PyTuple_New(1); - PyTuple_SET_ITEM(args, 0, GetProxy()); + + PyObject *args= NULL; + + if (m_function_argc==1) { + args = PyTuple_New(1); + PyTuple_SET_ITEM(args, 0, GetProxy()); + } + + resultobj = PyObject_CallObject(m_function, args); + Py_XDECREF(args); + break; } - - resultobj = PyObject_CallObject(m_function, args); - Py_XDECREF(args); - break; - } - + } /* end switch */ - - - + + /* Free the return value and print the error */ if (resultobj) Py_DECREF(resultobj); @@ -485,10 +484,10 @@ PyObject *SCA_PythonController::PyDeActivate(PyObject *value) PyObject *SCA_PythonController::pyattr_get_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - //SCA_PythonController* self= static_cast<SCA_PythonController*>(static_cast<SCA_IController*>(static_cast<SCA_ILogicBrick*>(static_cast<CValue*>(static_cast<PyObjectPlus*>(self_v))))); + //SCA_PythonController* self = static_cast<SCA_PythonController*>(static_cast<SCA_IController*>(static_cast<SCA_ILogicBrick*>(static_cast<CValue*>(static_cast<PyObjectPlus*>(self_v))))); // static_cast<void *>(dynamic_cast<Derived *>(obj)) - static_cast<void *>(obj) - SCA_PythonController* self= static_cast<SCA_PythonController*>(self_v); + SCA_PythonController* self = static_cast<SCA_PythonController*>(self_v); return PyUnicode_From_STR_String(self->m_scriptText); } @@ -496,7 +495,7 @@ PyObject *SCA_PythonController::pyattr_get_script(void *self_v, const KX_PYATTRI int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - SCA_PythonController* self= static_cast<SCA_PythonController*>(self_v); + SCA_PythonController* self = static_cast<SCA_PythonController*>(self_v); const char *scriptArg = _PyUnicode_AsString(value); diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp index 17784755421..7199ee6cf22 100644 --- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp +++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp @@ -167,13 +167,13 @@ PyAttributeDef SCA_RandomSensor::Attributes[] = { PyObject *SCA_RandomSensor::pyattr_get_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v); + SCA_RandomSensor* self = static_cast<SCA_RandomSensor*>(self_v); return PyLong_FromSsize_t(self->m_basegenerator->GetSeed()); } int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v); + SCA_RandomSensor* self = static_cast<SCA_RandomSensor*>(self_v); if (!PyLong_Check(value)) { PyErr_SetString(PyExc_TypeError, "sensor.seed = int: Random Sensor, expected an integer"); return PY_SET_ATTR_FAIL; diff --git a/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.cpp b/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.cpp index adf0bcd8e57..c4022d69153 100644 --- a/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RawLoadDotBlendArray.cpp @@ -38,7 +38,8 @@ void GetRawLoadingAnimation(unsigned char **data, int *dataSize) { // create an array that will automatically be deleted when) // we're outta this scope - static unsigned char load_blend[]= { 66, 76, 69, 78, 68, 70, + static unsigned char load_blend[] = { + 66, 76, 69, 78, 68, 70, 73, 10, 0, 2, 21, 0, 0, 2, 22, 0, 0, 0, 0, 0, 0, 2, 30, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 25, 242, 2, 0, 2, 29, 253, 0, 0, 0, 4, 160, 249, 227, diff --git a/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.cpp b/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.cpp index 2471b528eac..2f58e9a692f 100644 --- a/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RawLogoArrays.cpp @@ -38,7 +38,8 @@ void GetRawBlenderLogo(unsigned char **data, int *width, int *height) { // create an array that will automatically be deleted when) // we're outta this scope - static unsigned char logo_blender_raw[]= { 0, 0, 0, 0, 0, + static unsigned char logo_blender_raw[] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1041,7 +1042,8 @@ void GetRawBlender3DLogo(unsigned char **data, int *width, int *height) { // create an array that will automatically be deleted when) // we're outta this scope - static unsigned char logo_blender3d_raw[]= {255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, + static unsigned char logo_blender3d_raw[] = { + 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp index 4bf81bf543e..dfc866526eb 100644 --- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp +++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp @@ -173,11 +173,11 @@ bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, vo left = (dir.cross(resultnormal)).safe_normalized(); // for the up vector, we take the 'resultnormal' returned by the physics - double maat[16]={ - left[0], left[1], left[2], 0, - dir[0], dir[1], dir[2], 0, - resultnormal[0],resultnormal[1],resultnormal[2], 0, - 0, 0, 0, 1}; + double maat[16] = {left[0], left[1], left[2], 0, + dir[0], dir[1], dir[2], 0, + resultnormal[0], resultnormal[1], resultnormal[2], 0, + 0, 0, 0, 1}; + glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]); //glMultMatrixd(oglmatrix); glMultMatrixd(maat); @@ -236,16 +236,16 @@ void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,in left *= size[0]; dir *= size[1]; up *= size[2]; - double maat[16]={ - left[0], left[1],left[2], 0, - dir[0], dir[1],dir[2],0, - up[0],up[1],up[2],0, - 0,0,0,1}; - glTranslated(objpos[0],objpos[1],objpos[2]); - glMultMatrixd(maat); - - } else - { + + double maat[16] = {left[0], left[1], left[2], 0, + dir[0], dir[1], dir[2], 0, + up[0], up[1], up[2], 0, + 0, 0, 0, 1}; + + glTranslated(objpos[0],objpos[1],objpos[2]); + glMultMatrixd(maat); + } + else { if (objectdrawmode & RAS_IPolyMaterial::SHADOW) { // shadow must be cast to the ground, physics system needed here! diff --git a/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp b/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp index b31803b761e..e8d3441e4ce 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_KeyboardDevice.cpp @@ -72,7 +72,7 @@ GPG_KeyboardDevice::GPG_KeyboardDevice(void) m_reverseKeyTranslateTable[GHOST_kKey7 ] = KX_SEVENKEY ; m_reverseKeyTranslateTable[GHOST_kKey8 ] = KX_EIGHTKEY ; m_reverseKeyTranslateTable[GHOST_kKey9 ] = KX_NINEKEY ; - + // Middle keyboard area keys m_reverseKeyTranslateTable[GHOST_kKeyPause ] = KX_PAUSEKEY ; m_reverseKeyTranslateTable[GHOST_kKeyInsert ] = KX_INSERTKEY ; @@ -81,7 +81,7 @@ GPG_KeyboardDevice::GPG_KeyboardDevice(void) m_reverseKeyTranslateTable[GHOST_kKeyEnd ] = KX_ENDKEY ; m_reverseKeyTranslateTable[GHOST_kKeyUpPage ] = KX_PAGEUPKEY ; m_reverseKeyTranslateTable[GHOST_kKeyDownPage ] = KX_PAGEDOWNKEY ; - + // Arrow keys m_reverseKeyTranslateTable[GHOST_kKeyUpArrow ] = KX_UPARROWKEY ; m_reverseKeyTranslateTable[GHOST_kKeyDownArrow ] = KX_DOWNARROWKEY ; @@ -108,19 +108,19 @@ GPG_KeyboardDevice::GPG_KeyboardDevice(void) m_reverseKeyTranslateTable[GHOST_kKeyF17 ] = KX_F17KEY ; m_reverseKeyTranslateTable[GHOST_kKeyF18 ] = KX_F18KEY ; m_reverseKeyTranslateTable[GHOST_kKeyF19 ] = KX_F19KEY ; - + // Numpad keys - m_reverseKeyTranslateTable[GHOST_kKeyNumpad0 ] = KX_PAD0 ; - m_reverseKeyTranslateTable[GHOST_kKeyNumpad1 ] = KX_PAD1 ; - m_reverseKeyTranslateTable[GHOST_kKeyNumpad2 ] = KX_PAD2 ; - m_reverseKeyTranslateTable[GHOST_kKeyNumpad3 ] = KX_PAD3 ; - m_reverseKeyTranslateTable[GHOST_kKeyNumpad4 ] = KX_PAD4 ; - m_reverseKeyTranslateTable[GHOST_kKeyNumpad5 ] = KX_PAD5 ; - m_reverseKeyTranslateTable[GHOST_kKeyNumpad6 ] = KX_PAD6 ; - m_reverseKeyTranslateTable[GHOST_kKeyNumpad7 ] = KX_PAD7 ; - m_reverseKeyTranslateTable[GHOST_kKeyNumpad8 ] = KX_PAD8 ; - m_reverseKeyTranslateTable[GHOST_kKeyNumpad9 ] = KX_PAD9 ; + m_reverseKeyTranslateTable[GHOST_kKeyNumpad0 ] = KX_PAD0 ; + m_reverseKeyTranslateTable[GHOST_kKeyNumpad1 ] = KX_PAD1 ; + m_reverseKeyTranslateTable[GHOST_kKeyNumpad2 ] = KX_PAD2 ; + m_reverseKeyTranslateTable[GHOST_kKeyNumpad3 ] = KX_PAD3 ; + m_reverseKeyTranslateTable[GHOST_kKeyNumpad4 ] = KX_PAD4 ; + m_reverseKeyTranslateTable[GHOST_kKeyNumpad5 ] = KX_PAD5 ; + m_reverseKeyTranslateTable[GHOST_kKeyNumpad6 ] = KX_PAD6 ; + m_reverseKeyTranslateTable[GHOST_kKeyNumpad7 ] = KX_PAD7 ; + m_reverseKeyTranslateTable[GHOST_kKeyNumpad8 ] = KX_PAD8 ; + m_reverseKeyTranslateTable[GHOST_kKeyNumpad9 ] = KX_PAD9 ; m_reverseKeyTranslateTable[GHOST_kKeyNumpadAsterisk ] = KX_PADASTERKEY ; m_reverseKeyTranslateTable[GHOST_kKeyNumpadPlus ] = KX_PADPLUSKEY ; m_reverseKeyTranslateTable[GHOST_kKeyNumpadPeriod ] = KX_PADPERIOD ; @@ -133,7 +133,7 @@ GPG_KeyboardDevice::GPG_KeyboardDevice(void) m_reverseKeyTranslateTable[GHOST_kKeyEsc ] = KX_ESCKEY ; m_reverseKeyTranslateTable[GHOST_kKeyTab ] = KX_TABKEY ; m_reverseKeyTranslateTable[GHOST_kKeySpace ] = KX_SPACEKEY ; - m_reverseKeyTranslateTable[GHOST_kKeyEnter ] = KX_RETKEY ; + m_reverseKeyTranslateTable[GHOST_kKeyEnter ] = KX_RETKEY ; m_reverseKeyTranslateTable[GHOST_kKeyBackSpace ] = KX_BACKSPACEKEY ; m_reverseKeyTranslateTable[GHOST_kKeySemicolon ] = KX_SEMICOLONKEY ; m_reverseKeyTranslateTable[GHOST_kKeyPeriod ] = KX_PERIODKEY ; @@ -141,19 +141,19 @@ GPG_KeyboardDevice::GPG_KeyboardDevice(void) m_reverseKeyTranslateTable[GHOST_kKeyQuote ] = KX_QUOTEKEY ; m_reverseKeyTranslateTable[GHOST_kKeyAccentGrave ] = KX_ACCENTGRAVEKEY ; m_reverseKeyTranslateTable[GHOST_kKeyMinus ] = KX_MINUSKEY ; - m_reverseKeyTranslateTable[GHOST_kKeySlash ] = KX_SLASHKEY ; + m_reverseKeyTranslateTable[GHOST_kKeySlash ] = KX_SLASHKEY ; m_reverseKeyTranslateTable[GHOST_kKeyBackslash ] = KX_BACKSLASHKEY ; m_reverseKeyTranslateTable[GHOST_kKeyEqual ] = KX_EQUALKEY ; - m_reverseKeyTranslateTable[GHOST_kKeyLeftBracket ] = KX_LEFTBRACKETKEY ; - m_reverseKeyTranslateTable[GHOST_kKeyRightBracket ] = KX_RIGHTBRACKETKEY ; + m_reverseKeyTranslateTable[GHOST_kKeyLeftBracket ] = KX_LEFTBRACKETKEY ; + m_reverseKeyTranslateTable[GHOST_kKeyRightBracket ] = KX_RIGHTBRACKETKEY ; // Modifier keys. - m_reverseKeyTranslateTable[GHOST_kKeyLeftControl ] = KX_LEFTCTRLKEY ; - m_reverseKeyTranslateTable[GHOST_kKeyRightControl ] = KX_RIGHTCTRLKEY ; + m_reverseKeyTranslateTable[GHOST_kKeyLeftControl ] = KX_LEFTCTRLKEY ; + m_reverseKeyTranslateTable[GHOST_kKeyRightControl ] = KX_RIGHTCTRLKEY ; m_reverseKeyTranslateTable[GHOST_kKeyLeftAlt ] = KX_LEFTALTKEY ; m_reverseKeyTranslateTable[GHOST_kKeyRightAlt ] = KX_RIGHTALTKEY ; m_reverseKeyTranslateTable[GHOST_kKeyLeftShift ] = KX_LEFTSHIFTKEY ; - m_reverseKeyTranslateTable[GHOST_kKeyRightShift ] = KX_RIGHTSHIFTKEY ; + m_reverseKeyTranslateTable[GHOST_kKeyRightShift ] = KX_RIGHTSHIFTKEY ; } diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index 7500a55a059..9006a629791 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -1064,6 +1064,7 @@ int main(int argc, char** argv) #ifdef WITH_INTERNATIONAL BLF_free_unifont(); + BLF_lang_free(); #endif IMB_exit(); diff --git a/source/gameengine/Ketsji/BL_Action.cpp b/source/gameengine/Ketsji/BL_Action.cpp index a21c3965be9..5b7a2313f43 100644 --- a/source/gameengine/Ketsji/BL_Action.cpp +++ b/source/gameengine/Ketsji/BL_Action.cpp @@ -352,29 +352,27 @@ void BL_Action::Update(float curtime) } // Handle wrap around - if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) - { - switch(m_playmode) - { - case ACT_MODE_PLAY: - // Clamp - m_localtime = m_endframe; - m_done = true; - break; - case ACT_MODE_LOOP: - // Put the time back to the beginning - m_localtime = m_startframe; - m_starttime = curtime; - break; - case ACT_MODE_PING_PONG: - // Swap the start and end frames - float temp = m_startframe; - m_startframe = m_endframe; - m_endframe = temp; - - m_starttime = curtime; - - break; + if (m_localtime < min(m_startframe, m_endframe) || m_localtime > max(m_startframe, m_endframe)) { + switch (m_playmode) { + case ACT_MODE_PLAY: + // Clamp + m_localtime = m_endframe; + m_done = true; + break; + case ACT_MODE_LOOP: + // Put the time back to the beginning + m_localtime = m_startframe; + m_starttime = curtime; + break; + case ACT_MODE_PING_PONG: + // Swap the start and end frames + float temp = m_startframe; + m_startframe = m_endframe; + m_endframe = temp; + + m_starttime = curtime; + + break; } } diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp index 122d692b599..b2dfefd9e0b 100644 --- a/source/gameengine/Ketsji/BL_BlenderShader.cpp +++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp @@ -143,9 +143,9 @@ void BL_BlenderShader::Update(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty ) viewinv.getValue((float*)viewinvmat); if (ms.m_bObjectColor) - ms.m_RGBAcolor.getValue((float*)obcol); + ms.m_RGBAcolor.getValue((float *)obcol); else - obcol[0]= obcol[1]= obcol[2]= obcol[3]= 1.0f; + obcol[0] = obcol[1] = obcol[2] = obcol[3] = 1.0f; float auto_bump_scale = ms.m_pDerivedMesh!=0 ? ms.m_pDerivedMesh->auto_bump_scale : 1.0f; GPU_material_bind_uniforms(gpumat, obmat, viewmat, viewinvmat, obcol, auto_bump_scale); diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp index e0ad1539b4a..fb8e7beb157 100644 --- a/source/gameengine/Ketsji/BL_Shader.cpp +++ b/source/gameengine/Ketsji/BL_Shader.cpp @@ -52,51 +52,70 @@ void BL_Uniform::Apply(class BL_Shader *shader) #ifdef SORT_UNIFORMS MT_assert(mType > UNI_NONE && mType < UNI_MAX && mData); - if (!mDirty) + if (!mDirty) return; - switch(mType) - { - case UNI_FLOAT: { + switch (mType) { + case UNI_FLOAT: + { float *f = (float*)mData; glUniform1fARB(mLoc,(GLfloat)*f); - }break; - case UNI_INT: { + break; + } + case UNI_INT: + { int *f = (int*)mData; glUniform1iARB(mLoc, (GLint)*f); - }break; - case UNI_FLOAT2: { + break; + } + case UNI_FLOAT2: + { float *f = (float*)mData; glUniform2fvARB(mLoc,1, (GLfloat*)f); - }break; - case UNI_FLOAT3: { + break; + } + case UNI_FLOAT3: + { float *f = (float*)mData; glUniform3fvARB(mLoc,1,(GLfloat*)f); - }break; - case UNI_FLOAT4: { + break; + } + case UNI_FLOAT4: + { float *f = (float*)mData; glUniform4fvARB(mLoc,1,(GLfloat*)f); - }break; - case UNI_INT2: { + break; + } + case UNI_INT2: + { int *f = (int*)mData; glUniform2ivARB(mLoc,1,(GLint*)f); - }break; - case UNI_INT3: { + break; + } + case UNI_INT3: + { int *f = (int*)mData; glUniform3ivARB(mLoc,1,(GLint*)f); - }break; - case UNI_INT4: { + break; + } + case UNI_INT4: + { int *f = (int*)mData; glUniform4ivARB(mLoc,1,(GLint*)f); - }break; - case UNI_MAT4: { + break; + } + case UNI_MAT4: + { float *f = (float*)mData; glUniformMatrix4fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); - }break; - case UNI_MAT3: { + break; + } + case UNI_MAT3: + { float *f = (float*)mData; glUniformMatrix3fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f); - }break; + break; + } } mDirty = false; #endif @@ -157,7 +176,7 @@ BL_Shader::~BL_Shader() void BL_Shader::ClearUniforms() { BL_UniformVec::iterator it = mUniforms.begin(); - while(it != mUniforms.end()) { + while (it != mUniforms.end()) { delete (*it); it++; } @@ -165,7 +184,7 @@ void BL_Shader::ClearUniforms() BL_UniformVecDef::iterator itp = mPreDef.begin(); - while(itp != mPreDef.end()) { + while (itp != mPreDef.end()) { delete (*itp); itp++; } @@ -178,7 +197,7 @@ BL_Uniform *BL_Shader::FindUniform(const int location) { #ifdef SORT_UNIFORMS BL_UniformVec::iterator it = mUniforms.begin(); - while(it != mUniforms.end()) { + while (it != mUniforms.end()) { if ((*it)->GetLocation() == location) return (*it); it++; @@ -947,7 +966,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f, "setUniform2f(name, fx, fy)") Py_RETURN_NONE; } const char *uniform=""; - float array[2]={ 0,0 }; + float array[2] = {0, 0}; if (PyArg_ParseTuple(args, "sff:setUniform2f", &uniform, &array[0],&array[1] )) { int loc = GetUniformLocation(uniform); @@ -971,7 +990,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ") Py_RETURN_NONE; } const char *uniform=""; - float array[3]={0,0,0}; + float array[3] = {0, 0, 0}; if (PyArg_ParseTuple(args, "sfff:setUniform3f", &uniform, &array[0],&array[1],&array[2])) { int loc = GetUniformLocation(uniform); @@ -996,7 +1015,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) " Py_RETURN_NONE; } const char *uniform=""; - float array[4]={0,0,0,0}; + float array[4] = {0, 0, 0, 0}; if (PyArg_ParseTuple(args, "sffff:setUniform4f", &uniform, &array[0],&array[1],&array[2], &array[3])) { int loc = GetUniformLocation(uniform); @@ -1044,7 +1063,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i, "setUniform2i(name, ix, iy)") Py_RETURN_NONE; } const char *uniform=""; - int array[2]={ 0,0 }; + int array[2] = {0, 0}; if (PyArg_ParseTuple(args, "sii:setUniform2i", &uniform, &array[0],&array[1] )) { int loc = GetUniformLocation(uniform); @@ -1069,7 +1088,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ") } const char *uniform=""; - int array[3]={0,0,0}; + int array[3] = {0, 0, 0}; if (PyArg_ParseTuple(args, "siii:setUniform3i", &uniform, &array[0],&array[1],&array[2])) { int loc = GetUniformLocation(uniform); @@ -1092,7 +1111,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) " Py_RETURN_NONE; } const char *uniform=""; - int array[4]={0,0,0, 0}; + int array[4] = {0, 0, 0, 0}; if (PyArg_ParseTuple(args, "siiii:setUniform4i", &uniform, &array[0],&array[1],&array[2], &array[3] )) { int loc = GetUniformLocation(uniform); @@ -1134,7 +1153,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv, "setUniformfv( float (list2 or list Py_DECREF(item); } - switch(list_size) + switch (list_size) { case 2: { @@ -1218,7 +1237,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( uniform_name, (list2 /* Sanity checks done! */ - switch(list_size) + switch (list_size) { case 2: { @@ -1394,15 +1413,14 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformDef, "setUniformDef(name, enum)" ) { bool defined = false; BL_UniformVecDef::iterator it = mPreDef.begin(); - while(it != mPreDef.end()) { + while (it != mPreDef.end()) { if ((*it)->mLoc == loc) { defined = true; break; } it++; } - if (defined) - { + if (defined) { Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp index 7196c1ec664..26523df8db3 100644 --- a/source/gameengine/Ketsji/BL_Texture.cpp +++ b/source/gameengine/Ketsji/BL_Texture.cpp @@ -562,7 +562,7 @@ void BL_Texture::setTexEnv(BL_Material *mat, bool modulate) using_alpha = true; } - switch( mat->blend_mode[mUnit] ) { + switch (mat->blend_mode[mUnit]) { case BLEND_MIX: { // ------------------------------ @@ -670,7 +670,7 @@ void my_envmap_split_ima(EnvMap *env, ImBuf *ibuf) } else { for (part=0; part<6; part++) { - env->cube[part]= IMB_allocImBuf(dx, dx, 24, IB_rect); + env->cube[part] = IMB_allocImBuf(dx, dx, 24, IB_rect); } IMB_rectcpy(env->cube[0], ibuf, 0, 0, 0, 0, dx, dx); @@ -698,7 +698,7 @@ void my_free_envmapdata(EnvMap *env) ImBuf *ibuf= env->cube[part]; if (ibuf) { IMB_freeImBuf(ibuf); - env->cube[part]= NULL; + env->cube[part] = NULL; } } env->ok= 0; diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp index 2337e9569f3..da6fd822a6b 100644 --- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp +++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp @@ -726,7 +726,7 @@ void KX_BlenderMaterial::setObjectMatrixData(int i, RAS_IRasterizer *ras) GLenum plane = GL_EYE_PLANE; // figure plane gen - float proj[4]= {0.f,0.f,0.f,0.f}; + float proj[4] = {0.f,0.f,0.f,0.f}; GetProjPlane(mMaterial, i, 0, proj); glTexGenfv(GL_S, plane, proj); @@ -837,26 +837,26 @@ PyTypeObject KX_BlenderMaterial::Type = { PyObject *KX_BlenderMaterial::pyattr_get_shader(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v); + KX_BlenderMaterial* self = static_cast<KX_BlenderMaterial*>(self_v); return self->PygetShader(NULL, NULL); } PyObject *KX_BlenderMaterial::pyattr_get_materialIndex(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v); + KX_BlenderMaterial* self = static_cast<KX_BlenderMaterial*>(self_v); return PyLong_FromSsize_t(self->GetMaterialIndex()); } PyObject *KX_BlenderMaterial::pyattr_get_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v); + KX_BlenderMaterial* self = static_cast<KX_BlenderMaterial*>(self_v); unsigned int* bfunc = self->getBlendFunc(); return Py_BuildValue("(ll)", (long int)bfunc[0], (long int)bfunc[1]); } int KX_BlenderMaterial::pyattr_set_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v); + KX_BlenderMaterial* self = static_cast<KX_BlenderMaterial*>(self_v); PyObject *obj = self->PysetBlending(value, NULL); if (obj) { diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp index 90912409af1..3cc51361788 100644 --- a/source/gameengine/Ketsji/KX_Camera.cpp +++ b/source/gameengine/Ketsji/KX_Camera.cpp @@ -714,13 +714,13 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_Camera, setOnTop, PyObject *KX_Camera::pyattr_get_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); return PyBool_FromLong(self->m_camdata.m_perspective); } int KX_Camera::pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); int param = PyObject_IsTrue( value ); if (param == -1) { PyErr_SetString(PyExc_AttributeError, "camera.perspective = bool: KX_Camera, expected True/False or 0/1"); @@ -734,13 +734,13 @@ int KX_Camera::pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *at PyObject *KX_Camera::pyattr_get_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); return PyFloat_FromDouble(self->m_camdata.m_lens); } int KX_Camera::pyattr_set_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); float param = PyFloat_AsDouble(value); if (param == -1) { PyErr_SetString(PyExc_AttributeError, "camera.lens = float: KX_Camera, expected a float greater then zero"); @@ -754,13 +754,13 @@ int KX_Camera::pyattr_set_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *KX_Camera::pyattr_get_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); return PyFloat_FromDouble(self->m_camdata.m_scale); } int KX_Camera::pyattr_set_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); float param = PyFloat_AsDouble(value); if (param == -1) { PyErr_SetString(PyExc_AttributeError, "camera.ortho_scale = float: KX_Camera, expected a float greater then zero"); @@ -774,13 +774,13 @@ int KX_Camera::pyattr_set_ortho_scale(void *self_v, const KX_PYATTRIBUTE_DEF *at PyObject *KX_Camera::pyattr_get_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); return PyFloat_FromDouble(self->m_camdata.m_clipstart); } int KX_Camera::pyattr_set_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); float param = PyFloat_AsDouble(value); if (param == -1) { PyErr_SetString(PyExc_AttributeError, "camera.near = float: KX_Camera, expected a float greater then zero"); @@ -794,13 +794,13 @@ int KX_Camera::pyattr_set_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *KX_Camera::pyattr_get_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); return PyFloat_FromDouble(self->m_camdata.m_clipend); } int KX_Camera::pyattr_set_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); float param = PyFloat_AsDouble(value); if (param == -1) { PyErr_SetString(PyExc_AttributeError, "camera.far = float: KX_Camera, expected a float greater then zero"); @@ -815,13 +815,13 @@ int KX_Camera::pyattr_set_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, P PyObject *KX_Camera::pyattr_get_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); return PyBool_FromLong(self->GetViewport()); } int KX_Camera::pyattr_set_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); int param = PyObject_IsTrue( value ); if (param == -1) { PyErr_SetString(PyExc_AttributeError, "camera.useViewport = bool: KX_Camera, expected True or False"); @@ -834,13 +834,13 @@ int KX_Camera::pyattr_set_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *a PyObject *KX_Camera::pyattr_get_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); return PyObjectFrom(self->GetProjectionMatrix()); } int KX_Camera::pyattr_set_projection_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); MT_Matrix4x4 mat; if (!PyMatTo(value, mat)) return PY_SET_ATTR_FAIL; @@ -851,19 +851,19 @@ int KX_Camera::pyattr_set_projection_matrix(void *self_v, const KX_PYATTRIBUTE_D PyObject *KX_Camera::pyattr_get_modelview_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); return PyObjectFrom(self->GetModelviewMatrix()); } PyObject *KX_Camera::pyattr_get_camera_to_world(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); return PyObjectFrom(self->GetCameraToWorld()); } PyObject *KX_Camera::pyattr_get_world_to_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Camera* self= static_cast<KX_Camera*>(self_v); + KX_Camera* self = static_cast<KX_Camera*>(self_v); return PyObjectFrom(self->GetWorldToCamera()); } diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index 9ca1ec59a0b..a37b1b0c396 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -143,9 +143,9 @@ static void Kx_VecUpMat3(float vec[3], float mat[][3], short axis) } if (axis==3) { cox= 0; coy= 1; coz= 2; /* Y op -Z tr */ - vec[0]= -vec[0]; - vec[1]= -vec[1]; - vec[2]= -vec[2]; + vec[0] = -vec[0]; + vec[1] = -vec[1]; + vec[2] = -vec[2]; } if (axis==4) { cox= 1; coy= 0; coz= 2; /* */ @@ -154,9 +154,9 @@ static void Kx_VecUpMat3(float vec[3], float mat[][3], short axis) cox= 2; coy= 1; coz= 0; /* Y up X tr */ } - mat[coz][0]= vec[0]; - mat[coz][1]= vec[1]; - mat[coz][2]= vec[2]; + mat[coz][0] = vec[0]; + mat[coz][1] = vec[1]; + mat[coz][2] = vec[2]; if (normalize_v3((float *)mat[coz]) == 0.f) { /* this is a very abnormal situation: the camera has reach the object center exactly * We will choose a completely arbitrary direction */ @@ -281,13 +281,13 @@ bool KX_CameraActuator::Update(double curtime, bool frame) assert(0); break; } - + inp = fp1[0]*fp2[0] + fp1[1]*fp2[1] + fp1[2]*fp2[2]; fac = (-1.0f + inp) * m_damping; - from[0]+= fac*fp1[0]; - from[1]+= fac*fp1[1]; - from[2]+= fac*fp1[2]; + from[0] += fac * fp1[0]; + from[1] += fac * fp1[1]; + from[2] += fac * fp1[2]; /* alleen alstie ervoor ligt: cross testen en loodrechte bijtellen */ if (inp < 0.0f) { @@ -303,9 +303,9 @@ bool KX_CameraActuator::Update(double curtime, bool frame) /* CONSTRAINT 5: minimum / maximum afstand */ - rc[0]= (lookat[0]-from[0]); - rc[1]= (lookat[1]-from[1]); - rc[2]= (lookat[2]-from[2]); + rc[0] = (lookat[0]-from[0]); + rc[1] = (lookat[1]-from[1]); + rc[2] = (lookat[2]-from[2]); distsq = rc[0]*rc[0] + rc[1]*rc[1] + rc[2]*rc[2]; if (distsq > maxdistsq) { @@ -325,9 +325,9 @@ bool KX_CameraActuator::Update(double curtime, bool frame) /* CONSTRAINT 7: track to schaduw */ - rc[0]= (lookat[0]-from[0]); - rc[1]= (lookat[1]-from[1]); - rc[2]= (lookat[2]-from[2]); + rc[0] = (lookat[0]-from[0]); + rc[1] = (lookat[1]-from[1]); + rc[2] = (lookat[2]-from[2]); Kx_VecUpMat3(rc, mat, 3); /* y up Track -z */ @@ -337,9 +337,9 @@ bool KX_CameraActuator::Update(double curtime, bool frame) obj->NodeSetLocalPosition(from); - actormat[0][0]= mat[0][0]; actormat[0][1]= mat[1][0]; actormat[0][2]= mat[2][0]; - actormat[1][0]= mat[0][1]; actormat[1][1]= mat[1][1]; actormat[1][2]= mat[2][1]; - actormat[2][0]= mat[0][2]; actormat[2][1]= mat[1][2]; actormat[2][2]= mat[2][2]; + actormat[0][0] = mat[0][0]; actormat[0][1] = mat[1][0]; actormat[0][2] = mat[2][0]; + actormat[1][0] = mat[0][1]; actormat[1][1] = mat[1][1]; actormat[1][2] = mat[2][1]; + actormat[2][0] = mat[0][2]; actormat[2][1] = mat[1][2]; actormat[2][2] = mat[2][2]; obj->NodeSetLocalOrientation(actormat); return true; @@ -396,7 +396,7 @@ PyAttributeDef KX_CameraActuator::Attributes[] = { PyObject *KX_CameraActuator::pyattr_get_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_CameraActuator* self= static_cast<KX_CameraActuator*>(self_v); + KX_CameraActuator* self = static_cast<KX_CameraActuator*>(self_v); if (self->m_ob==NULL) Py_RETURN_NONE; else @@ -405,7 +405,7 @@ PyObject *KX_CameraActuator::pyattr_get_object(void *self_v, const KX_PYATTRIBUT int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_CameraActuator* self= static_cast<KX_CameraActuator*>(self_v); + KX_CameraActuator* self = static_cast<KX_CameraActuator*>(self_v); KX_GameObject *gameobj; if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_CameraActuator")) diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp index 5727ed29e67..662db974ee8 100644 --- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp @@ -119,7 +119,7 @@ PyAttributeDef KX_ConstraintWrapper::Attributes[] = { PyObject *KX_ConstraintWrapper::pyattr_get_constraintId(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_ConstraintWrapper* self= static_cast<KX_ConstraintWrapper*>(self_v); + KX_ConstraintWrapper* self = static_cast<KX_ConstraintWrapper*>(self_v); return self->PyGetConstraintId(); } diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 87b0cfc1269..fca407f6398 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -94,7 +94,7 @@ KX_Dome::KX_Dome ( SetViewPort(viewport); - switch(m_mode) { + switch (m_mode) { case DOME_FISHEYE: if (m_angle <= 180) { cubetop.resize(1); @@ -1620,7 +1620,7 @@ void KX_Dome::Draw(void) glScissor(0,0,warp.imagesize, warp.imagesize); } - switch(m_mode) { + switch (m_mode) { case DOME_FISHEYE: DrawDomeFisheye(); break; diff --git a/source/gameengine/Ketsji/KX_FontObject.cpp b/source/gameengine/Ketsji/KX_FontObject.cpp index 9f6ef894f12..138124f9b1a 100644 --- a/source/gameengine/Ketsji/KX_FontObject.cpp +++ b/source/gameengine/Ketsji/KX_FontObject.cpp @@ -254,7 +254,7 @@ PyAttributeDef KX_FontObject::Attributes[] = { PyObject *KX_FontObject::pyattr_get_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_FontObject* self= static_cast<KX_FontObject*>(self_v); + KX_FontObject* self = static_cast<KX_FontObject*>(self_v); STR_String str = STR_String(); for (int i=0; i<self->m_text.size(); ++i) { @@ -267,7 +267,7 @@ PyObject *KX_FontObject::pyattr_get_text(void *self_v, const KX_PYATTRIBUTE_DEF int KX_FontObject::pyattr_set_text(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_FontObject* self= static_cast<KX_FontObject*>(self_v); + KX_FontObject* self = static_cast<KX_FontObject*>(self_v); if (!PyUnicode_Check(value)) return PY_SET_ATTR_FAIL; char* chars = _PyUnicode_AsString(value); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index dfc8073303e..48a45c2d1c2 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -228,11 +228,11 @@ STR_String& KX_GameObject::GetName() } - +/* Set the name of the value */ void KX_GameObject::SetName(const char *name) { m_name = name; -}; // Set the name of the value +} KX_IPhysicsController* KX_GameObject::GetPhysicsController() { @@ -241,7 +241,7 @@ KX_IPhysicsController* KX_GameObject::GetPhysicsController() KX_GameObject* KX_GameObject::GetDupliGroupObject() { - return m_pDupliGroupObject; + return m_pDupliGroupObject; } CListValue* KX_GameObject::GetInstanceObjects() @@ -251,11 +251,11 @@ CListValue* KX_GameObject::GetInstanceObjects() void KX_GameObject::AddInstanceObjects(KX_GameObject* obj) { - if(!m_pInstanceObjects) + if (!m_pInstanceObjects) m_pInstanceObjects = new CListValue(); obj->AddRef(); - m_pInstanceObjects->Add(obj); + m_pInstanceObjects->Add(obj); } void KX_GameObject::RemoveInstanceObject(KX_GameObject* obj) @@ -267,7 +267,7 @@ void KX_GameObject::RemoveInstanceObject(KX_GameObject* obj) void KX_GameObject::RemoveDupliGroupObject() { - if(m_pDupliGroupObject) { + if (m_pDupliGroupObject) { m_pDupliGroupObject->Release(); m_pDupliGroupObject = NULL; } @@ -1427,8 +1427,8 @@ static unsigned char mathutils_kxgameob_vector_cb_index= -1; /* index for our ca static int mathutils_kxgameob_generic_check(BaseMathObject *bmo) { - KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); - if (self==NULL) + KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); + if (self == NULL) return -1; return 0; @@ -1436,13 +1436,13 @@ static int mathutils_kxgameob_generic_check(BaseMathObject *bmo) static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype) { - KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); - if (self==NULL) + KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); + if (self == NULL) return -1; #define PHYS_ERR(attr) PyErr_SetString(PyExc_AttributeError, "KX_GameObject." attr ", is missing a physics controller") - switch(subtype) { + switch (subtype) { case MATHUTILS_VEC_CB_POS_LOCAL: self->NodeGetLocalPosition().getValue(bmo->data); break; @@ -1488,11 +1488,11 @@ static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype) static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype) { - KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); - if (self==NULL) + KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); + if (self == NULL) return -1; - switch(subtype) { + switch (subtype) { case MATHUTILS_VEC_CB_POS_LOCAL: self->NodeSetLocalPosition(MT_Point3(bmo->data)); self->NodeUpdateGS(0.f); @@ -1547,7 +1547,7 @@ static int mathutils_kxgameob_vector_set_index(BaseMathObject *bmo, int subtype, if (mathutils_kxgameob_vector_get(bmo, subtype) == -1) return -1; - bmo->data[index]= f; + bmo->data[index] = f; return mathutils_kxgameob_vector_set(bmo, subtype); } @@ -1567,11 +1567,11 @@ static unsigned char mathutils_kxgameob_matrix_cb_index= -1; /* index for our ca static int mathutils_kxgameob_matrix_get(BaseMathObject *bmo, int subtype) { - KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); - if (self==NULL) + KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); + if (self == NULL) return -1; - switch(subtype) { + switch (subtype) { case MATHUTILS_MAT_CB_ORI_LOCAL: self->NodeGetLocalOrientation().getValue3x3(bmo->data); break; @@ -1586,12 +1586,12 @@ static int mathutils_kxgameob_matrix_get(BaseMathObject *bmo, int subtype) static int mathutils_kxgameob_matrix_set(BaseMathObject *bmo, int subtype) { - KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); - if (self==NULL) + KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user); + if (self == NULL) return -1; MT_Matrix3x3 mat3x3; - switch(subtype) { + switch (subtype) { case MATHUTILS_MAT_CB_ORI_LOCAL: mat3x3.setValue3x3(bmo->data); self->NodeSetLocalOrientation(mat3x3); @@ -1774,12 +1774,12 @@ PyObject *KX_GameObject::PyReinstancePhysicsMesh(PyObject *args) static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) { - KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); const char *attr_str= _PyUnicode_AsString(item); CValue* resultattr; PyObject *pyconvert; - if (self==NULL) { + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "val = gameOb[key]: KX_GameObject, "BGE_PROXY_ERROR_MSG); return NULL; } @@ -1808,12 +1808,12 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) { - KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); const char *attr_str= _PyUnicode_AsString(key); if (attr_str==NULL) PyErr_Clear(); - if (self==NULL) { + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "gameOb[key] = value: KX_GameObject, "BGE_PROXY_ERROR_MSG); return -1; } @@ -1896,9 +1896,9 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) static int Seq_Contains(PyObject *self_v, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>BGE_PROXY_REF(self_v); - if (self==NULL) { + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "val in gameOb: KX_GameObject, "BGE_PROXY_ERROR_MSG); return -1; } @@ -1962,13 +1962,13 @@ PyTypeObject KX_GameObject::Type = { PyObject *KX_GameObject::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyUnicode_From_STR_String(self->GetName()); } PyObject *KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); KX_GameObject* parent = self->GetParent(); if (parent) { parent->Release(); /* self->GetParent() AddRef's */ @@ -1979,7 +1979,7 @@ PyObject *KX_GameObject::pyattr_get_parent(void *self_v, const KX_PYATTRIBUTE_DE PyObject *KX_GameObject::pyattr_get_group_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); CListValue* instances = self->GetInstanceObjects(); if (instances) { return instances->GetProxy(); @@ -2000,7 +2000,7 @@ PyObject* KX_GameObject::pyattr_get_scene(void *self_v, const KX_PYATTRIBUTE_DEF PyObject *KX_GameObject::pyattr_get_group_parent(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); KX_GameObject* pivot = self->GetDupliGroupObject(); if (pivot) { return pivot->GetProxy(); @@ -2010,7 +2010,7 @@ PyObject *KX_GameObject::pyattr_get_group_parent(void *self_v, const KX_PYATTRIB PyObject *KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); CValue *life = self->GetProperty("::timebomb"); if (life) @@ -2023,14 +2023,14 @@ PyObject *KX_GameObject::pyattr_get_life(void *self_v, const KX_PYATTRIBUTE_DEF PyObject *KX_GameObject::pyattr_get_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); KX_IPhysicsController *spc = self->GetPhysicsController(); return PyFloat_FromDouble(spc ? spc->GetMass() : 0.0); } int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); KX_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); if (val < 0.0) { /* also accounts for non float */ @@ -2046,14 +2046,14 @@ int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrd PyObject *KX_GameObject::pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); KX_IPhysicsController *spc = self->GetPhysicsController(); return PyFloat_FromDouble(spc ? spc->GetLinVelocityMin() : 0.0f); } int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); KX_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); if (val < 0.0) { /* also accounts for non float */ @@ -2069,14 +2069,14 @@ int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF PyObject *KX_GameObject::pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); KX_IPhysicsController *spc = self->GetPhysicsController(); return PyFloat_FromDouble(spc ? spc->GetLinVelocityMax() : 0.0f); } int KX_GameObject::pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); KX_IPhysicsController *spc = self->GetPhysicsController(); MT_Scalar val = PyFloat_AsDouble(value); if (val < 0.0) { /* also accounts for non float */ @@ -2093,13 +2093,13 @@ int KX_GameObject::pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF PyObject *KX_GameObject::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyBool_FromLong(self->GetVisible()); } int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); int param = PyObject_IsTrue( value ); if (param == -1) { PyErr_SetString(PyExc_AttributeError, "gameOb.visible = bool: KX_GameObject, expected True or False"); @@ -2116,14 +2116,14 @@ PyObject *KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRI #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_GLOBAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetWorldPosition()); #endif } int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); MT_Point3 pos; if (!PyVecTo(value, pos)) return PY_SET_ATTR_FAIL; @@ -2138,14 +2138,14 @@ PyObject *KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRI #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_POS_LOCAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetLocalPosition()); #endif } int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); MT_Point3 pos; if (!PyVecTo(value, pos)) return PY_SET_ATTR_FAIL; @@ -2160,7 +2160,7 @@ PyObject *KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIB #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_INERTIA_LOCAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); if (self->GetPhysicsController()) return PyObjectFrom(self->GetPhysicsController()->GetLocalInertia()); return Py_BuildValue("fff", 0.0f, 0.0f, 0.0f); @@ -2172,14 +2172,14 @@ PyObject *KX_GameObject::pyattr_get_worldOrientation(void *self_v, const KX_PYAT #ifdef USE_MATHUTILS return Matrix_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_GLOBAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetWorldOrientation()); #endif } int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); /* if value is not a sequence PyOrientationTo makes an error */ MT_Matrix3x3 rot; @@ -2197,14 +2197,14 @@ PyObject *KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYAT #ifdef USE_MATHUTILS return Matrix_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, 3, mathutils_kxgameob_matrix_cb_index, MATHUTILS_MAT_CB_ORI_LOCAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetLocalOrientation()); #endif } int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); /* if value is not a sequence PyOrientationTo makes an error */ MT_Matrix3x3 rot; @@ -2221,14 +2221,14 @@ PyObject *KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIB #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_GLOBAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetWorldScaling()); #endif } int KX_GameObject::pyattr_set_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); MT_Vector3 scale; if (!PyVecTo(value, scale)) return PY_SET_ATTR_FAIL; @@ -2243,14 +2243,14 @@ PyObject *KX_GameObject::pyattr_get_localScaling(void *self_v, const KX_PYATTRIB #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_SCALE_LOCAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->NodeGetLocalScaling()); #endif } int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); MT_Vector3 scale; if (!PyVecTo(value, scale)) return PY_SET_ATTR_FAIL; @@ -2345,14 +2345,14 @@ PyObject *KX_GameObject::pyattr_get_worldLinearVelocity(void *self_v, const KX_P #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_GLOBAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyObjectFrom(GetLinearVelocity(false)); #endif } int KX_GameObject::pyattr_set_worldLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); MT_Vector3 velocity; if (!PyVecTo(value, velocity)) return PY_SET_ATTR_FAIL; @@ -2367,14 +2367,14 @@ PyObject *KX_GameObject::pyattr_get_localLinearVelocity(void *self_v, const KX_P #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_LINVEL_LOCAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyObjectFrom(GetLinearVelocity(true)); #endif } int KX_GameObject::pyattr_set_localLinearVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); MT_Vector3 velocity; if (!PyVecTo(value, velocity)) return PY_SET_ATTR_FAIL; @@ -2389,14 +2389,14 @@ PyObject *KX_GameObject::pyattr_get_worldAngularVelocity(void *self_v, const KX_ #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_GLOBAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyObjectFrom(GetAngularVelocity(false)); #endif } int KX_GameObject::pyattr_set_worldAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); MT_Vector3 velocity; if (!PyVecTo(value, velocity)) return PY_SET_ATTR_FAIL; @@ -2411,14 +2411,14 @@ PyObject *KX_GameObject::pyattr_get_localAngularVelocity(void *self_v, const KX_ #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 3, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_ANGVEL_LOCAL); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyObjectFrom(GetAngularVelocity(true)); #endif } int KX_GameObject::pyattr_set_localAngularVelocity(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); MT_Vector3 velocity; if (!PyVecTo(value, velocity)) return PY_SET_ATTR_FAIL; @@ -2431,7 +2431,7 @@ int KX_GameObject::pyattr_set_localAngularVelocity(void *self_v, const KX_PYATTR PyObject *KX_GameObject::pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); SG_Node* sg_parent; if (self->GetSGNode() && (sg_parent = self->GetSGNode()->GetSGParent()) != NULL && sg_parent->IsSlowParent()) { return PyFloat_FromDouble(static_cast<KX_SlowParentRelation *>(sg_parent->GetParentRelation())->GetTimeOffset()); @@ -2442,7 +2442,7 @@ PyObject *KX_GameObject::pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUT int KX_GameObject::pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); if (self->GetSGNode()) { MT_Scalar val = PyFloat_AsDouble(value); SG_Node *sg_parent= self->GetSGNode()->GetSGParent(); @@ -2458,7 +2458,7 @@ int KX_GameObject::pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF PyObject *KX_GameObject::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); int state = 0; state |= self->GetState(); return PyLong_FromSsize_t(state); @@ -2466,7 +2466,7 @@ PyObject *KX_GameObject::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); int state_i = PyLong_AsSsize_t(value); unsigned int state = 0; @@ -2486,7 +2486,7 @@ int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attr PyObject *KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); PyObject *meshes= PyList_New(self->m_meshes.size()); int i; @@ -2504,14 +2504,14 @@ PyObject *KX_GameObject::pyattr_get_obcolor(void *self_v, const KX_PYATTRIBUTE_D #ifdef USE_MATHUTILS return Vector_CreatePyObject_cb(BGE_PROXY_FROM_REF(self_v), 4, mathutils_kxgameob_vector_cb_index, MATHUTILS_VEC_CB_OBJECT_COLOR); #else - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return PyObjectFrom(self->GetObjectColor()); #endif } int KX_GameObject::pyattr_set_obcolor(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); MT_Vector4 obcolor; if (!PyVecTo(value, obcolor)) return PY_SET_ATTR_FAIL; @@ -2539,19 +2539,19 @@ PyObject *KX_GameObject::pyattr_get_actuators(void *self_v, const KX_PYATTRIBUTE PyObject *KX_GameObject::pyattr_get_children(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return self->GetChildren()->NewProxy(true); } PyObject *KX_GameObject::pyattr_get_children_recursive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); return self->GetChildrenRecursive()->NewProxy(true); } PyObject *KX_GameObject::pyattr_get_attrDict(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_GameObject* self= static_cast<KX_GameObject*>(self_v); + KX_GameObject* self = static_cast<KX_GameObject*>(self_v); if (self->m_attr_dict==NULL) self->m_attr_dict= PyDict_New(); diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index 157e282b557..5ceef2c60c9 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -221,11 +221,11 @@ public: GetInstanceObjects( ); - void + void SetDupliGroupObject(KX_GameObject* ); - void + void AddInstanceObjects(KX_GameObject* ); diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp index 5ea7a2e7394..1597d7f8809 100644 --- a/source/gameengine/Ketsji/KX_IpoActuator.cpp +++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp @@ -455,13 +455,13 @@ PyAttributeDef KX_IpoActuator::Attributes[] = { PyObject *KX_IpoActuator::pyattr_get_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_IpoActuator* self= static_cast<KX_IpoActuator*>(self_v); + KX_IpoActuator* self = static_cast<KX_IpoActuator*>(self_v); return PyFloat_FromDouble(self->m_startframe); } int KX_IpoActuator::pyattr_set_frame_start(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_IpoActuator* self= static_cast<KX_IpoActuator*>(self_v); + KX_IpoActuator* self = static_cast<KX_IpoActuator*>(self_v); float param = PyFloat_AsDouble(value); if (PyErr_Occurred()) { @@ -476,13 +476,13 @@ int KX_IpoActuator::pyattr_set_frame_start(void *self_v, const KX_PYATTRIBUTE_DE PyObject *KX_IpoActuator::pyattr_get_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_IpoActuator* self= static_cast<KX_IpoActuator*>(self_v); + KX_IpoActuator* self = static_cast<KX_IpoActuator*>(self_v); return PyFloat_FromDouble(self->m_endframe); } int KX_IpoActuator::pyattr_set_frame_end(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_IpoActuator* self= static_cast<KX_IpoActuator*>(self_v); + KX_IpoActuator* self = static_cast<KX_IpoActuator*>(self_v); float param = PyFloat_AsDouble(value); if (PyErr_Occurred()) { diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 479e63a1f24..a85575d4f55 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -334,8 +334,7 @@ void KX_KetsjiEngine::RenderDome() // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); - while(it != cameras->end()) - { + while (it != cameras->end()) { if ((*it)->GetViewport()) { if (scene->IsClearingZBuffer()) @@ -889,8 +888,7 @@ void KX_KetsjiEngine::Render() // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); - while(it != cameras->end()) - { + while (it != cameras->end()) { if ((*it)->GetViewport()) { if (scene->IsClearingZBuffer()) @@ -939,8 +937,7 @@ void KX_KetsjiEngine::Render() // Draw the scene once for each camera with an enabled viewport list<KX_Camera*>::iterator it = cameras->begin(); - while(it != cameras->end()) - { + while (it != cameras->end()) { if ((*it)->GetViewport()) { if (scene->IsClearingZBuffer()) @@ -1327,8 +1324,7 @@ void KX_KetsjiEngine::RenderFonts(KX_Scene* scene) list<class KX_FontObject*>* fonts = scene->GetFonts(); list<KX_FontObject*>::iterator it = fonts->begin(); - while(it != fonts->end()) - { + while (it != fonts->end()) { (*it)->DrawText(); ++it; } diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp index 0e45684d2d0..a4e90cb1e83 100644 --- a/source/gameengine/Ketsji/KX_Light.cpp +++ b/source/gameengine/Ketsji/KX_Light.cpp @@ -126,14 +126,14 @@ bool KX_LightObject::ApplyLight(KX_Scene *kxscene, int oblayer, int slot) vec[0] = worldmatrix(0,2); vec[1] = worldmatrix(1,2); vec[2] = worldmatrix(2,2); - //vec[0]= base->object->obmat[2][0]; - //vec[1]= base->object->obmat[2][1]; - //vec[2]= base->object->obmat[2][2]; - vec[3]= 0.0; + //vec[0] = base->object->obmat[2][0]; + //vec[1] = base->object->obmat[2][1]; + //vec[2] = base->object->obmat[2][2]; + vec[3] = 0.0; glLightfv((GLenum)(GL_LIGHT0+slot), GL_POSITION, vec); } else { - //vec[3]= 1.0; + //vec[3] = 1.0; glLightfv((GLenum)(GL_LIGHT0+slot), GL_POSITION, vec); glLightf((GLenum)(GL_LIGHT0+slot), GL_CONSTANT_ATTENUATION, 1.0); glLightf((GLenum)(GL_LIGHT0+slot), GL_LINEAR_ATTENUATION, m_lightobj.m_att1/m_lightobj.m_distance); @@ -145,9 +145,9 @@ bool KX_LightObject::ApplyLight(KX_Scene *kxscene, int oblayer, int slot) vec[0] = -worldmatrix(0,2); vec[1] = -worldmatrix(1,2); vec[2] = -worldmatrix(2,2); - //vec[0]= -base->object->obmat[2][0]; - //vec[1]= -base->object->obmat[2][1]; - //vec[2]= -base->object->obmat[2][2]; + //vec[0] = -base->object->obmat[2][0]; + //vec[1] = -base->object->obmat[2][1]; + //vec[2] = -base->object->obmat[2][2]; glLightfv((GLenum)(GL_LIGHT0+slot), GL_SPOT_DIRECTION, vec); glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_CUTOFF, m_lightobj.m_spotsize / 2.0f); glLightf((GLenum)(GL_LIGHT0+slot), GL_SPOT_EXPONENT, 128.0f * m_lightobj.m_spotblend); @@ -161,10 +161,10 @@ bool KX_LightObject::ApplyLight(KX_Scene *kxscene, int oblayer, int slot) vec[0] = vec[1] = vec[2] = vec[3] = 0.0; } else { - vec[0]= m_lightobj.m_energy*m_lightobj.m_red; - vec[1]= m_lightobj.m_energy*m_lightobj.m_green; - vec[2]= m_lightobj.m_energy*m_lightobj.m_blue; - vec[3]= 1.0; + vec[0] = m_lightobj.m_energy*m_lightobj.m_red; + vec[1] = m_lightobj.m_energy*m_lightobj.m_green; + vec[2] = m_lightobj.m_energy*m_lightobj.m_blue; + vec[3] = 1.0; } glLightfv((GLenum)(GL_LIGHT0+slot), GL_DIFFUSE, vec); @@ -173,10 +173,10 @@ bool KX_LightObject::ApplyLight(KX_Scene *kxscene, int oblayer, int slot) vec[0] = vec[1] = vec[2] = vec[3] = 0.0; } else if (m_lightobj.m_nodiffuse) { - vec[0]= m_lightobj.m_energy*m_lightobj.m_red; - vec[1]= m_lightobj.m_energy*m_lightobj.m_green; - vec[2]= m_lightobj.m_energy*m_lightobj.m_blue; - vec[3]= 1.0; + vec[0] = m_lightobj.m_energy*m_lightobj.m_red; + vec[1] = m_lightobj.m_energy*m_lightobj.m_green; + vec[2] = m_lightobj.m_energy*m_lightobj.m_blue; + vec[3] = 1.0; } glLightfv((GLenum)(GL_LIGHT0+slot), GL_SPECULAR, vec); @@ -402,7 +402,7 @@ int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attr return PY_SET_ATTR_FAIL; } - switch(val) { + switch (val) { case 0: self->m_lightobj.m_type = self->m_lightobj.LIGHT_SPOT; break; diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp index 8451dc3497d..87c366046ad 100644 --- a/source/gameengine/Ketsji/KX_MeshProxy.cpp +++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp @@ -220,7 +220,7 @@ PyObject *KX_MeshProxy::PyGetPolygon(PyObject *args, PyObject *kwds) PyObject *KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_MeshProxy* self= static_cast<KX_MeshProxy*>(self_v); + KX_MeshProxy* self = static_cast<KX_MeshProxy*>(self_v); int tot= self->m_meshobj->NumMaterials(); int i; @@ -239,7 +239,7 @@ PyObject *KX_MeshProxy::pyattr_get_materials(void *self_v, const KX_PYATTRIBUTE_ KX_BlenderMaterial *mat = static_cast<KX_BlenderMaterial*>(polymat); PyList_SET_ITEM(materials, i, mat->GetProxy()); } - else { + else { KX_PolygonMaterial *mat = static_cast<KX_PolygonMaterial*>(polymat); PyList_SET_ITEM(materials, i, mat->GetProxy()); } diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp index f7dbbe5a86b..9368bc6458f 100644 --- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp +++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp @@ -141,7 +141,7 @@ bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo* client_info, KX_RayCast* r KX_GameObject* hitKXObj = client_info->m_gameobject; /* Is this me? In the ray test, there are a lot of extra checks - * for aliasing artefacts from self-hits. That doesn't happen + * for aliasing artifacts from self-hits. That doesn't happen * here, so a simple test suffices. Or does the camera also get * self-hits? (No, and the raysensor shouldn't do it either, since * self-hits are excluded by setting the correct ignore-object.) @@ -308,8 +308,7 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus() list<class KX_Camera*>* cameras = m_kxscene->GetCameras(); list<KX_Camera*>::iterator it = cameras->begin(); - while(it != cameras->end()) - { + while (it != cameras->end()) { if (((*it) != cam) && (*it)->GetViewport()) if (ParentObjectHasFocusCamera(*it)) return true; @@ -393,19 +392,19 @@ PyAttributeDef KX_MouseFocusSensor::Attributes[] = { /* Attributes */ PyObject *KX_MouseFocusSensor::pyattr_get_ray_source(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v); + KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v); return PyObjectFrom(self->RaySource()); } PyObject *KX_MouseFocusSensor::pyattr_get_ray_target(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v); + KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v); return PyObjectFrom(self->RayTarget()); } PyObject *KX_MouseFocusSensor::pyattr_get_ray_direction(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v); + KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v); MT_Vector3 dir = self->RayTarget() - self->RaySource(); if (MT_fuzzyZero(dir)) dir.setValue(0,0,0); else dir.normalize(); @@ -414,7 +413,7 @@ PyObject *KX_MouseFocusSensor::pyattr_get_ray_direction(void *self_v, const KX_P PyObject *KX_MouseFocusSensor::pyattr_get_hit_object(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v); + KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v); if (self->m_hitObject) return self->m_hitObject->GetProxy(); @@ -424,19 +423,19 @@ PyObject *KX_MouseFocusSensor::pyattr_get_hit_object(void *self_v, const KX_PYAT PyObject *KX_MouseFocusSensor::pyattr_get_hit_position(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v); + KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v); return PyObjectFrom(self->HitPosition()); } PyObject *KX_MouseFocusSensor::pyattr_get_hit_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v); + KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v); return PyObjectFrom(self->HitNormal()); } PyObject *KX_MouseFocusSensor::pyattr_get_hit_uv(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_MouseFocusSensor* self= static_cast<KX_MouseFocusSensor*>(self_v); + KX_MouseFocusSensor* self = static_cast<KX_MouseFocusSensor*>(self_v); return PyObjectFrom(self->HitUV()); } diff --git a/source/gameengine/Ketsji/KX_NavMeshObject.cpp b/source/gameengine/Ketsji/KX_NavMeshObject.cpp index a05292f268a..33656e9fd52 100644 --- a/source/gameengine/Ketsji/KX_NavMeshObject.cpp +++ b/source/gameengine/Ketsji/KX_NavMeshObject.cpp @@ -249,7 +249,7 @@ bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts, } //create tris - polys = (unsigned short*)MEM_callocN(sizeof(unsigned short)*3*2*npolys, "BuildVertIndArrays polys"); + polys = (unsigned short *)MEM_callocN(sizeof(unsigned short)*3*2*npolys, "BuildVertIndArrays polys"); memset(polys, 0xff, sizeof(unsigned short)*3*2*npolys); unsigned short *poly = polys; RAS_Polygon* raspoly; @@ -258,10 +258,10 @@ bool KX_NavMeshObject::BuildVertIndArrays(float *&vertices, int& nverts, raspoly = meshobj->GetPolygon(p); for (int v=0; v<raspoly->VertexCount()-2; v++) { - poly[0]= raspoly->GetVertex(0)->getOrigIndex(); + poly[0] = raspoly->GetVertex(0)->getOrigIndex(); for (size_t i=1; i<3; i++) { - poly[i]= raspoly->GetVertex(v+i)->getOrigIndex(); + poly[i] = raspoly->GetVertex(v+i)->getOrigIndex(); } poly += 6; } diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp index f35090f9e9b..9cebf9cfc82 100644 --- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp +++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp @@ -389,8 +389,8 @@ static unsigned char mathutils_kxobactu_vector_cb_index = -1; /* index for our c static int mathutils_obactu_generic_check(BaseMathObject *bmo) { - KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); - if (self==NULL) + KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); + if (self == NULL) return -1; return 0; @@ -398,11 +398,11 @@ static int mathutils_obactu_generic_check(BaseMathObject *bmo) static int mathutils_obactu_vector_get(BaseMathObject *bmo, int subtype) { - KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); - if (self==NULL) + KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); + if (self == NULL) return -1; - switch(subtype) { + switch (subtype) { case MATHUTILS_VEC_CB_LINV: self->m_linear_velocity.getValue(bmo->data); break; @@ -416,11 +416,11 @@ static int mathutils_obactu_vector_get(BaseMathObject *bmo, int subtype) static int mathutils_obactu_vector_set(BaseMathObject *bmo, int subtype) { - KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); - if (self==NULL) + KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>BGE_PROXY_REF(bmo->cb_user); + if (self == NULL) return -1; - switch(subtype) { + switch (subtype) { case MATHUTILS_VEC_CB_LINV: self->m_linear_velocity.setValue(bmo->data); break; @@ -442,13 +442,13 @@ static int mathutils_obactu_vector_get_index(BaseMathObject *bmo, int subtype, i static int mathutils_obactu_vector_set_index(BaseMathObject *bmo, int subtype, int index) { - float f= bmo->data[index]; + float f = bmo->data[index]; /* lazy, avoid repeteing the case statement */ if (mathutils_obactu_vector_get(bmo, subtype) == -1) return -1; - bmo->data[index]= f; + bmo->data[index] = f; return mathutils_obactu_vector_set(bmo, subtype); } @@ -467,7 +467,7 @@ PyObject *KX_ObjectActuator::pyattr_get_linV(void *self_v, const KX_PYATTRIBUTE_ int KX_ObjectActuator::pyattr_set_linV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>(self_v); + KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>(self_v); if (!PyVecTo(value, self->m_linear_velocity)) return PY_SET_ATTR_FAIL; @@ -483,7 +483,7 @@ PyObject *KX_ObjectActuator::pyattr_get_angV(void *self_v, const KX_PYATTRIBUTE_ int KX_ObjectActuator::pyattr_set_angV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_ObjectActuator* self= static_cast<KX_ObjectActuator*>(self_v); + KX_ObjectActuator* self = static_cast<KX_ObjectActuator*>(self_v); if (!PyVecTo(value, self->m_angular_velocity)) return PY_SET_ATTR_FAIL; diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp index 13b6bda4ebc..465e91ffb32 100644 --- a/source/gameengine/Ketsji/KX_PolyProxy.cpp +++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp @@ -114,52 +114,52 @@ CValue* KX_PolyProxy::GetReplica() { return NULL;} PyObject *KX_PolyProxy::pyattr_get_material_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); + KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v); return self->PygetMaterialName(); } PyObject *KX_PolyProxy::pyattr_get_texture_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); + KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v); return self->PygetTextureName(); } PyObject *KX_PolyProxy::pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); + KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v); return self->PygetMaterial(); } PyObject *KX_PolyProxy::pyattr_get_material_id(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); + KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v); return self->PygetMaterialIndex(); } PyObject *KX_PolyProxy::pyattr_get_v1(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); + KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v); return PyLong_FromSsize_t(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 0)); } PyObject *KX_PolyProxy::pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); + KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v); return PyLong_FromSsize_t(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 1)); } PyObject *KX_PolyProxy::pyattr_get_v3(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); + KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v); return PyLong_FromSsize_t(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 2)); } PyObject *KX_PolyProxy::pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); + KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v); if (3 < self->m_polygon->VertexCount()) { @@ -170,13 +170,13 @@ PyObject *KX_PolyProxy::pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *at PyObject *KX_PolyProxy::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); + KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v); return self->PyisVisible(); } PyObject *KX_PolyProxy::pyattr_get_collide(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v); + KX_PolyProxy* self = static_cast<KX_PolyProxy*>(self_v); return self->PyisCollider(); } diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp index 3b58a8abd83..36c94dc997b 100644 --- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp +++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp @@ -357,26 +357,26 @@ KX_PYMETHODDEF_DOC(KX_PolygonMaterial, activate, "activate(rasty, cachingInfo)") PyObject *KX_PolygonMaterial::pyattr_get_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); + KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v); return PyUnicode_From_STR_String(self->m_texturename); } PyObject *KX_PolygonMaterial::pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); + KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v); return PyUnicode_From_STR_String(self->m_materialname); } /* this does not seem useful */ PyObject *KX_PolygonMaterial::pyattr_get_tface(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); + KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v); return PyCapsule_New(&self->m_tface, KX_POLYGONMATERIAL_CAPSULE_ID, NULL); } PyObject *KX_PolygonMaterial::pyattr_get_gl_texture(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); + KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v); int bindcode= 0; if (self->m_tface.tpage) bindcode= self->m_tface.tpage->bindcode; @@ -387,13 +387,13 @@ PyObject *KX_PolygonMaterial::pyattr_get_gl_texture(void *self_v, const KX_PYATT PyObject *KX_PolygonMaterial::pyattr_get_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); + KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v); return PyObjectFrom(self->m_diffuse); } int KX_PolygonMaterial::pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); + KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v); MT_Vector3 vec; if (!PyVecTo(value, vec)) @@ -405,13 +405,13 @@ int KX_PolygonMaterial::pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DE PyObject *KX_PolygonMaterial::pyattr_get_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); + KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v); return PyObjectFrom(self->m_specular); } int KX_PolygonMaterial::pyattr_set_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_PolygonMaterial* self= static_cast<KX_PolygonMaterial*>(self_v); + KX_PolygonMaterial* self = static_cast<KX_PolygonMaterial*>(self_v); MT_Vector3 vec; if (!PyVecTo(value, vec)) diff --git a/source/gameengine/Ketsji/KX_PyMath.cpp b/source/gameengine/Ketsji/KX_PyMath.cpp index 85303b143bd..804e8de2ad1 100644 --- a/source/gameengine/Ketsji/KX_PyMath.cpp +++ b/source/gameengine/Ketsji/KX_PyMath.cpp @@ -86,11 +86,11 @@ bool PyQuatTo(PyObject *pyval, MT_Quaternion &qrot) return false; /* annoying!, Blender/Mathutils have the W axis first! */ - MT_Scalar w= qrot[0]; /* from python, this is actually the W */ - qrot[0]= qrot[1]; - qrot[1]= qrot[2]; - qrot[2]= qrot[3]; - qrot[3]= w; + MT_Scalar w = qrot[0]; /* from python, this is actually the W */ + qrot[0] = qrot[1]; + qrot[1] = qrot[2]; + qrot[2] = qrot[3]; + qrot[3] = w; return true; } diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 89799d065a4..2c147528bcb 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -1796,7 +1796,7 @@ static void initPySysObjects(Main *maggie) Library *lib= (Library *)maggie->library.first; - while(lib) { + while (lib) { /* lib->name wont work in some cases (on win32), * even when expanding with gp_GamePythonPath, using lib->filename is less trouble */ initPySysObjects__append(sys_path, lib->filepath); @@ -1844,7 +1844,7 @@ void removeImportMain(struct Main *maggie) } // Copied from bpy_interface.c -static struct _inittab bge_internal_modules[]= { +static struct _inittab bge_internal_modules[] = { {(char *)"mathutils", PyInit_mathutils}, {(char *)"bgl", BPyInit_bgl}, {(char *)"blf", BPyInit_blf}, @@ -2240,9 +2240,9 @@ PyObject *initGameKeys() KX_MACRO_addTypesToDict(d, CAPSLOCKKEY, SCA_IInputDevice::KX_CAPSLOCKKEY); KX_MACRO_addTypesToDict(d, LEFTCTRLKEY, SCA_IInputDevice::KX_LEFTCTRLKEY); - KX_MACRO_addTypesToDict(d, LEFTALTKEY, SCA_IInputDevice::KX_LEFTALTKEY); - KX_MACRO_addTypesToDict(d, RIGHTALTKEY, SCA_IInputDevice::KX_RIGHTALTKEY); - KX_MACRO_addTypesToDict(d, RIGHTCTRLKEY, SCA_IInputDevice::KX_RIGHTCTRLKEY); + KX_MACRO_addTypesToDict(d, LEFTALTKEY, SCA_IInputDevice::KX_LEFTALTKEY); + KX_MACRO_addTypesToDict(d, RIGHTALTKEY, SCA_IInputDevice::KX_RIGHTALTKEY); + KX_MACRO_addTypesToDict(d, RIGHTCTRLKEY, SCA_IInputDevice::KX_RIGHTCTRLKEY); KX_MACRO_addTypesToDict(d, RIGHTSHIFTKEY, SCA_IInputDevice::KX_RIGHTSHIFTKEY); KX_MACRO_addTypesToDict(d, LEFTSHIFTKEY, SCA_IInputDevice::KX_LEFTSHIFTKEY); diff --git a/source/gameengine/Ketsji/KX_PythonMain.cpp b/source/gameengine/Ketsji/KX_PythonMain.cpp index d926dff0bf5..740bb102fd9 100644 --- a/source/gameengine/Ketsji/KX_PythonMain.cpp +++ b/source/gameengine/Ketsji/KX_PythonMain.cpp @@ -1,6 +1,4 @@ -/* - * $Id: KX_PythonMain.cpp 37750 2011-06-27 09:27:56Z sjoerd $ - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -17,15 +15,11 @@ * 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. + * Contributor(s): Benoit Bolsee * * ***** END GPL LICENSE BLOCK ***** */ + /** \file gameengine/Ketsji/KX_PythonMain.cpp * \ingroup ketsji */ diff --git a/source/gameengine/Ketsji/KX_PythonMain.h b/source/gameengine/Ketsji/KX_PythonMain.h index 1460ea2ca96..e638fa9094e 100644 --- a/source/gameengine/Ketsji/KX_PythonMain.h +++ b/source/gameengine/Ketsji/KX_PythonMain.h @@ -1,6 +1,4 @@ -/* - * $Id: KX_PythonMain.h 37750 2011-06-27 09:27:56Z sjoerd $ - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -31,11 +29,12 @@ * \ingroup ketsji */ -#ifndef __KX_PYTHON_MAIN -#define __KX_PYTHON_MAIN +#ifndef __KX_PYTHON_MAIN__ +#define __KX_PYTHON_MAIN__ #include "BKE_main.h" #include "DNA_scene_types.h" extern "C" char *KX_GetPythonMain(struct Scene* scene); extern "C" char *KX_GetPythonCode(struct Main *main, char *python_main); -#endif + +#endif /* __KX_PYTHON_MAIN__ */ diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp index 5ab3de15fb3..6b4d88709e8 100644 --- a/source/gameengine/Ketsji/KX_PythonSeq.cpp +++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp @@ -72,31 +72,31 @@ static void KX_PythonSeq_dealloc(KX_PythonSeq * self) static Py_ssize_t KX_PythonSeq_len( PyObject *self ) { PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); - + if (self_plus==NULL) { PyErr_SetString(PyExc_SystemError, "len(seq): "BGE_PROXY_ERROR_MSG); return -1; } - switch(((KX_PythonSeq *)self)->type) { - case KX_PYGENSEQ_CONT_TYPE_SENSORS: - return ((SCA_IController *)self_plus)->GetLinkedSensors().size(); - case KX_PYGENSEQ_CONT_TYPE_ACTUATORS: - return ((SCA_IController *)self_plus)->GetLinkedActuators().size(); - case KX_PYGENSEQ_OB_TYPE_SENSORS: - return ((KX_GameObject *)self_plus)->GetSensors().size(); - case KX_PYGENSEQ_OB_TYPE_CONTROLLERS: - return ((KX_GameObject *)self_plus)->GetControllers().size(); - case KX_PYGENSEQ_OB_TYPE_ACTUATORS: - return ((KX_GameObject *)self_plus)->GetActuators().size(); - case KX_PYGENSEQ_OB_TYPE_CONSTRAINTS: - return ((BL_ArmatureObject *)self_plus)->GetConstraintNumber(); - case KX_PYGENSEQ_OB_TYPE_CHANNELS: - return ((BL_ArmatureObject *)self_plus)->GetChannelNumber(); - default: - /* Should never happen */ - PyErr_SetString(PyExc_SystemError, "invalid type, internal error"); - return -1; + switch (((KX_PythonSeq *)self)->type) { + case KX_PYGENSEQ_CONT_TYPE_SENSORS: + return ((SCA_IController *)self_plus)->GetLinkedSensors().size(); + case KX_PYGENSEQ_CONT_TYPE_ACTUATORS: + return ((SCA_IController *)self_plus)->GetLinkedActuators().size(); + case KX_PYGENSEQ_OB_TYPE_SENSORS: + return ((KX_GameObject *)self_plus)->GetSensors().size(); + case KX_PYGENSEQ_OB_TYPE_CONTROLLERS: + return ((KX_GameObject *)self_plus)->GetControllers().size(); + case KX_PYGENSEQ_OB_TYPE_ACTUATORS: + return ((KX_GameObject *)self_plus)->GetActuators().size(); + case KX_PYGENSEQ_OB_TYPE_CONSTRAINTS: + return ((BL_ArmatureObject *)self_plus)->GetConstraintNumber(); + case KX_PYGENSEQ_OB_TYPE_CHANNELS: + return ((BL_ArmatureObject *)self_plus)->GetChannelNumber(); + default: + /* Should never happen */ + PyErr_SetString(PyExc_SystemError, "invalid type, internal error"); + return -1; } } @@ -109,7 +109,7 @@ static PyObject *KX_PythonSeq_getIndex(PyObject *self, int index) return NULL; } - switch(((KX_PythonSeq *)self)->type) { + switch (((KX_PythonSeq *)self)->type) { case KX_PYGENSEQ_CONT_TYPE_SENSORS: { vector<SCA_ISensor*>& linkedsensors = ((SCA_IController *)self_plus)->GetLinkedSensors(); @@ -193,7 +193,7 @@ static PyObjectPlus * KX_PythonSeq_subscript__internal(PyObject *self, const cha { PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base); - switch(((KX_PythonSeq *)self)->type) { + switch (((KX_PythonSeq *)self)->type) { case KX_PYGENSEQ_CONT_TYPE_SENSORS: { vector<SCA_ISensor*>& linkedsensors = ((SCA_IController *)self_plus)->GetLinkedSensors(); diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp index fb949fffa8a..04d67fc73e1 100644 --- a/source/gameengine/Ketsji/KX_RadarSensor.cpp +++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp @@ -219,7 +219,7 @@ PyAttributeDef KX_RadarSensor::Attributes[] = { PyObject *KX_RadarSensor::pyattr_get_angle(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_RadarSensor* self= static_cast<KX_RadarSensor*>(self_v); + KX_RadarSensor* self = static_cast<KX_RadarSensor*>(self_v); // The original angle from the gui was converted, so we recalculate the value here to maintain // consistency between Python and the gui diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp index 459600f2e34..2a6b7d122b5 100644 --- a/source/gameengine/Ketsji/KX_RayCast.cpp +++ b/source/gameengine/Ketsji/KX_RayCast.cpp @@ -76,9 +76,9 @@ bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_ PHY_IPhysicsController* hit_controller; - while((hit_controller = physics_environment->rayTest(callback, - frompoint.x(),frompoint.y(),frompoint.z(), - topoint.x(),topoint.y(),topoint.z())) != NULL) + while ((hit_controller = physics_environment->rayTest(callback, + frompoint.x(),frompoint.y(),frompoint.z(), + topoint.x(),topoint.y(),topoint.z())) != NULL) { KX_ClientObjectInfo* info = static_cast<KX_ClientObjectInfo*>(hit_controller->getNewClientInfo()); diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h index 7dac93acd21..976f3c58d68 100644 --- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h +++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h @@ -50,7 +50,7 @@ class KX_SCA_AddObjectActuator : public SCA_IActuator /// Time field: lifetime of the new object int m_timeProp; - /// Original object reference (object to replicate) + /// Original object reference (object to replicate) SCA_IObject* m_OriginalObject; /// Object will be added to the following scene diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp index a6b7ed3f732..96b4a21a36c 100644 --- a/source/gameengine/Ketsji/KX_Scene.cpp +++ b/source/gameengine/Ketsji/KX_Scene.cpp @@ -1027,7 +1027,7 @@ int KX_Scene::NewRemoveObject(class CValue* gameobj) // if the object is the dupligroup proxy, you have to cleanup all m_pDupliGroupObject's in all // instances refering to this group - if(newobj->GetInstanceObjects()) { + if (newobj->GetInstanceObjects()) { for (int i = 0; i < newobj->GetInstanceObjects()->GetCount(); i++) { KX_GameObject* instance = (KX_GameObject*)newobj->GetInstanceObjects()->GetValue(i); instance->RemoveDupliGroupObject(); @@ -2043,11 +2043,11 @@ PyMethodDef KX_Scene::Methods[] = { }; static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) { - KX_Scene* self= static_cast<KX_Scene*>BGE_PROXY_REF(self_v); + KX_Scene* self = static_cast<KX_Scene*>BGE_PROXY_REF(self_v); const char *attr_str= _PyUnicode_AsString(item); PyObject *pyconvert; - if (self==NULL) { + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "val = scene[key]: KX_Scene, "BGE_PROXY_ERROR_MSG); return NULL; } @@ -2069,12 +2069,12 @@ static PyObject *Map_GetItem(PyObject *self_v, PyObject *item) static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) { - KX_Scene* self= static_cast<KX_Scene*>BGE_PROXY_REF(self_v); + KX_Scene* self = static_cast<KX_Scene*>BGE_PROXY_REF(self_v); const char *attr_str= _PyUnicode_AsString(key); if (attr_str==NULL) PyErr_Clear(); - if (self==NULL) { + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "scene[key] = value: KX_Scene, "BGE_PROXY_ERROR_MSG); return -1; } @@ -2116,9 +2116,9 @@ static int Map_SetItem(PyObject *self_v, PyObject *key, PyObject *val) static int Seq_Contains(PyObject *self_v, PyObject *value) { - KX_Scene* self= static_cast<KX_Scene*>BGE_PROXY_REF(self_v); + KX_Scene* self = static_cast<KX_Scene*>BGE_PROXY_REF(self_v); - if (self==NULL) { + if (self == NULL) { PyErr_SetString(PyExc_SystemError, "val in scene: KX_Scene, "BGE_PROXY_ERROR_MSG); return -1; } @@ -2130,45 +2130,45 @@ static int Seq_Contains(PyObject *self_v, PyObject *value) } PyMappingMethods KX_Scene::Mapping = { - (lenfunc)NULL , /*inquiry mp_length */ - (binaryfunc)Map_GetItem, /*binaryfunc mp_subscript */ - (objobjargproc)Map_SetItem, /*objobjargproc mp_ass_subscript */ + (lenfunc)NULL, /* inquiry mp_length */ + (binaryfunc)Map_GetItem, /* binaryfunc mp_subscript */ + (objobjargproc)Map_SetItem, /* objobjargproc mp_ass_subscript */ }; PySequenceMethods KX_Scene::Sequence = { - NULL, /* Cant set the len otherwise it can evaluate as false */ - NULL, /* sq_concat */ - NULL, /* sq_repeat */ - NULL, /* sq_item */ - NULL, /* sq_slice */ - NULL, /* sq_ass_item */ - NULL, /* sq_ass_slice */ - (objobjproc)Seq_Contains, /* sq_contains */ - (binaryfunc) NULL, /* sq_inplace_concat */ - (ssizeargfunc) NULL, /* sq_inplace_repeat */ + NULL, /* Cant set the len otherwise it can evaluate as false */ + NULL, /* sq_concat */ + NULL, /* sq_repeat */ + NULL, /* sq_item */ + NULL, /* sq_slice */ + NULL, /* sq_ass_item */ + NULL, /* sq_ass_slice */ + (objobjproc)Seq_Contains, /* sq_contains */ + (binaryfunc) NULL, /* sq_inplace_concat */ + (ssizeargfunc) NULL, /* sq_inplace_repeat */ }; PyObject *KX_Scene::pyattr_get_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Scene* self= static_cast<KX_Scene*>(self_v); + KX_Scene* self = static_cast<KX_Scene*>(self_v); return PyUnicode_From_STR_String(self->GetName()); } PyObject *KX_Scene::pyattr_get_objects(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Scene* self= static_cast<KX_Scene*>(self_v); + KX_Scene* self = static_cast<KX_Scene*>(self_v); return self->GetObjectList()->GetProxy(); } PyObject *KX_Scene::pyattr_get_objects_inactive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Scene* self= static_cast<KX_Scene*>(self_v); + KX_Scene* self = static_cast<KX_Scene*>(self_v); return self->GetInactiveList()->GetProxy(); } PyObject *KX_Scene::pyattr_get_lights(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Scene* self= static_cast<KX_Scene*>(self_v); + KX_Scene* self = static_cast<KX_Scene*>(self_v); return self->GetLightList()->GetProxy(); } @@ -2179,7 +2179,7 @@ PyObject *KX_Scene::pyattr_get_cameras(void *self_v, const KX_PYATTRIBUTE_DEF *a * however this is the same with "scene.objects + []", when you make a copy by adding lists. */ - KX_Scene* self= static_cast<KX_Scene*>(self_v); + KX_Scene* self = static_cast<KX_Scene*>(self_v); CListValue* clist = new CListValue(); /* return self->GetCameras()->GetProxy(); */ @@ -2195,7 +2195,7 @@ PyObject *KX_Scene::pyattr_get_cameras(void *self_v, const KX_PYATTRIBUTE_DEF *a PyObject *KX_Scene::pyattr_get_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_Scene* self= static_cast<KX_Scene*>(self_v); + KX_Scene* self = static_cast<KX_Scene*>(self_v); KX_Camera* cam= self->GetActiveCamera(); if (cam) return self->GetActiveCamera()->GetProxy(); @@ -2206,7 +2206,7 @@ PyObject *KX_Scene::pyattr_get_active_camera(void *self_v, const KX_PYATTRIBUTE_ int KX_Scene::pyattr_set_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_Scene* self= static_cast<KX_Scene*>(self_v); + KX_Scene* self = static_cast<KX_Scene*>(self_v); KX_Camera *camOb; if (!ConvertPythonToCamera(value, &camOb, false, "scene.active_camera = value: KX_Scene")) diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp index c0191db640a..f76f94aa81d 100644 --- a/source/gameengine/Ketsji/KX_SoundActuator.cpp +++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp @@ -325,15 +325,14 @@ KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound, "startSound()\n" "\tStarts the sound.\n") { - switch(m_handle.isNull() ? AUD_STATUS_INVALID : m_handle->getStatus()) - { - case AUD_STATUS_PLAYING: - break; - case AUD_STATUS_PAUSED: - m_handle->resume(); - break; - default: - play(); + switch (m_handle.isNull() ? AUD_STATUS_INVALID : m_handle->getStatus()) { + case AUD_STATUS_PLAYING: + break; + case AUD_STATUS_PAUSED: + m_handle->resume(); + break; + default: + play(); } Py_RETURN_NONE; } diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp index 885ac70061e..36e0bf692f1 100644 --- a/source/gameengine/Ketsji/KX_TouchSensor.cpp +++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp @@ -333,7 +333,7 @@ PyAttributeDef KX_TouchSensor::Attributes[] = { PyObject *KX_TouchSensor::pyattr_get_object_hit(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_TouchSensor* self= static_cast<KX_TouchSensor*>(self_v); + KX_TouchSensor* self = static_cast<KX_TouchSensor*>(self_v); if (self->m_hitObject) return self->m_hitObject->GetProxy(); @@ -343,7 +343,7 @@ PyObject *KX_TouchSensor::pyattr_get_object_hit(void *self_v, const KX_PYATTRIBU PyObject *KX_TouchSensor::pyattr_get_object_hit_list(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_TouchSensor* self= static_cast<KX_TouchSensor*>(self_v); + KX_TouchSensor* self = static_cast<KX_TouchSensor*>(self_v); return self->m_colliders->GetProxy(); } diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp index 461563d4512..dabb79b357d 100644 --- a/source/gameengine/Ketsji/KX_VertexProxy.cpp +++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp @@ -103,85 +103,85 @@ PyAttributeDef KX_VertexProxy::Attributes[] = { PyObject *KX_VertexProxy::pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyFloat_FromDouble(self->m_vertex->getXYZ()[0]); } PyObject *KX_VertexProxy::pyattr_get_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyFloat_FromDouble(self->m_vertex->getXYZ()[1]); } PyObject *KX_VertexProxy::pyattr_get_z(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyFloat_FromDouble(self->m_vertex->getXYZ()[2]); } PyObject *KX_VertexProxy::pyattr_get_r(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyFloat_FromDouble(self->m_vertex->getRGBA()[0]/255.0); } PyObject *KX_VertexProxy::pyattr_get_g(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyFloat_FromDouble(self->m_vertex->getRGBA()[1]/255.0); } PyObject *KX_VertexProxy::pyattr_get_b(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyFloat_FromDouble(self->m_vertex->getRGBA()[2]/255.0); } PyObject *KX_VertexProxy::pyattr_get_a(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyFloat_FromDouble(self->m_vertex->getRGBA()[3]/255.0); } PyObject *KX_VertexProxy::pyattr_get_u(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyFloat_FromDouble(self->m_vertex->getUV1()[0]); } PyObject *KX_VertexProxy::pyattr_get_v(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyFloat_FromDouble(self->m_vertex->getUV1()[1]); } PyObject *KX_VertexProxy::pyattr_get_u2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyFloat_FromDouble(self->m_vertex->getUV2()[0]); } PyObject *KX_VertexProxy::pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyFloat_FromDouble(self->m_vertex->getUV2()[1]); } PyObject *KX_VertexProxy::pyattr_get_XYZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyObjectFrom(MT_Vector3(self->m_vertex->getXYZ())); } PyObject *KX_VertexProxy::pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyObjectFrom(MT_Point2(self->m_vertex->getUV1())); } PyObject *KX_VertexProxy::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); const unsigned char *colp = self->m_vertex->getRGBA(); MT_Vector4 color(colp[0], colp[1], colp[2], colp[3]); color /= 255.0; @@ -190,13 +190,13 @@ PyObject *KX_VertexProxy::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DE PyObject *KX_VertexProxy::pyattr_get_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); return PyObjectFrom(MT_Vector3(self->m_vertex->getNormal())); } int KX_VertexProxy::pyattr_set_x(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); @@ -211,7 +211,7 @@ int KX_VertexProxy::pyattr_set_x(void *self_v, const struct KX_PYATTRIBUTE_DEF * int KX_VertexProxy::pyattr_set_y(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); @@ -226,7 +226,7 @@ int KX_VertexProxy::pyattr_set_y(void *self_v, const struct KX_PYATTRIBUTE_DEF * int KX_VertexProxy::pyattr_set_z(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); @@ -241,7 +241,7 @@ int KX_VertexProxy::pyattr_set_z(void *self_v, const struct KX_PYATTRIBUTE_DEF * int KX_VertexProxy::pyattr_set_u(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); @@ -256,7 +256,7 @@ int KX_VertexProxy::pyattr_set_u(void *self_v, const struct KX_PYATTRIBUTE_DEF * int KX_VertexProxy::pyattr_set_v(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); @@ -271,7 +271,7 @@ int KX_VertexProxy::pyattr_set_v(void *self_v, const struct KX_PYATTRIBUTE_DEF * int KX_VertexProxy::pyattr_set_u2(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); @@ -286,7 +286,7 @@ int KX_VertexProxy::pyattr_set_u2(void *self_v, const struct KX_PYATTRIBUTE_DEF int KX_VertexProxy::pyattr_set_v2(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); @@ -301,7 +301,7 @@ int KX_VertexProxy::pyattr_set_v2(void *self_v, const struct KX_PYATTRIBUTE_DEF int KX_VertexProxy::pyattr_set_r(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); @@ -318,7 +318,7 @@ int KX_VertexProxy::pyattr_set_r(void *self_v, const struct KX_PYATTRIBUTE_DEF * int KX_VertexProxy::pyattr_set_g(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); @@ -335,7 +335,7 @@ int KX_VertexProxy::pyattr_set_g(void *self_v, const struct KX_PYATTRIBUTE_DEF * int KX_VertexProxy::pyattr_set_b(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); @@ -352,7 +352,7 @@ int KX_VertexProxy::pyattr_set_b(void *self_v, const struct KX_PYATTRIBUTE_DEF * int KX_VertexProxy::pyattr_set_a(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PyFloat_Check(value)) { float val = PyFloat_AsDouble(value); @@ -369,7 +369,7 @@ int KX_VertexProxy::pyattr_set_a(void *self_v, const struct KX_PYATTRIBUTE_DEF * int KX_VertexProxy::pyattr_set_XYZ(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PySequence_Check(value)) { MT_Point3 vec; @@ -385,7 +385,7 @@ int KX_VertexProxy::pyattr_set_XYZ(void *self_v, const struct KX_PYATTRIBUTE_DEF int KX_VertexProxy::pyattr_set_UV(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PySequence_Check(value)) { MT_Point2 vec; @@ -401,7 +401,7 @@ int KX_VertexProxy::pyattr_set_UV(void *self_v, const struct KX_PYATTRIBUTE_DEF int KX_VertexProxy::pyattr_set_color(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PySequence_Check(value)) { MT_Vector4 vec; @@ -417,7 +417,7 @@ int KX_VertexProxy::pyattr_set_color(void *self_v, const struct KX_PYATTRIBUTE_D int KX_VertexProxy::pyattr_set_normal(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value) { - KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v); + KX_VertexProxy* self = static_cast<KX_VertexProxy*>(self_v); if (PySequence_Check(value)) { MT_Vector3 vec; diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp index 29a9b6481e9..568c11a0be4 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp @@ -1520,10 +1520,10 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, // only add polygons that have the collision flag set if (poly->IsCollider()) { - if (vert_tag_array[mf->v1]==false) {vert_tag_array[mf->v1]= true;tot_bt_verts++;} - if (vert_tag_array[mf->v2]==false) {vert_tag_array[mf->v2]= true;tot_bt_verts++;} - if (vert_tag_array[mf->v3]==false) {vert_tag_array[mf->v3]= true;tot_bt_verts++;} - if (mf->v4 && vert_tag_array[mf->v4]==false) {vert_tag_array[mf->v4]= true;tot_bt_verts++;} + if (vert_tag_array[mf->v1] == false) {vert_tag_array[mf->v1] = true; tot_bt_verts++;} + if (vert_tag_array[mf->v2] == false) {vert_tag_array[mf->v2] = true; tot_bt_verts++;} + if (vert_tag_array[mf->v3] == false) {vert_tag_array[mf->v3] = true; tot_bt_verts++;} + if (mf->v4 && vert_tag_array[mf->v4] == false) {vert_tag_array[mf->v4] = true; tot_bt_verts++;} } } @@ -1542,7 +1542,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, if (vert_tag_array[mf->v1]==true) { const float* vtx = mvert[mf->v1].co; - vert_tag_array[mf->v1]= false; + vert_tag_array[mf->v1] = false; *bt++ = vtx[0]; *bt++ = vtx[1]; *bt++ = vtx[2]; @@ -1550,7 +1550,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, if (vert_tag_array[mf->v2]==true) { const float* vtx = mvert[mf->v2].co; - vert_tag_array[mf->v2]= false; + vert_tag_array[mf->v2] = false; *bt++ = vtx[0]; *bt++ = vtx[1]; *bt++ = vtx[2]; @@ -1558,7 +1558,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, if (vert_tag_array[mf->v3]==true) { const float* vtx = mvert[mf->v3].co; - vert_tag_array[mf->v3]= false; + vert_tag_array[mf->v3] = false; *bt++ = vtx[0]; *bt++ = vtx[1]; *bt++ = vtx[2]; @@ -1566,7 +1566,7 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, if (mf->v4 && vert_tag_array[mf->v4]==true) { const float* vtx = mvert[mf->v4].co; - vert_tag_array[mf->v4]= false; + vert_tag_array[mf->v4] = false; *bt++ = vtx[0]; *bt++ = vtx[1]; *bt++ = vtx[2]; @@ -1588,13 +1588,13 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, if (poly->IsCollider()) { if (vert_tag_array[mf->v1]==false) - {vert_tag_array[mf->v1]= true;vert_remap_array[mf->v1]= tot_bt_verts;tot_bt_verts++;} + {vert_tag_array[mf->v1] = true;vert_remap_array[mf->v1] = tot_bt_verts;tot_bt_verts++;} if (vert_tag_array[mf->v2]==false) - {vert_tag_array[mf->v2]= true;vert_remap_array[mf->v2]= tot_bt_verts;tot_bt_verts++;} + {vert_tag_array[mf->v2] = true;vert_remap_array[mf->v2] = tot_bt_verts;tot_bt_verts++;} if (vert_tag_array[mf->v3]==false) - {vert_tag_array[mf->v3]= true;vert_remap_array[mf->v3]= tot_bt_verts;tot_bt_verts++;} + {vert_tag_array[mf->v3] = true;vert_remap_array[mf->v3] = tot_bt_verts;tot_bt_verts++;} if (mf->v4 && vert_tag_array[mf->v4]==false) - {vert_tag_array[mf->v4]= true;vert_remap_array[mf->v4]= tot_bt_verts;tot_bt_verts++;} + {vert_tag_array[mf->v4] = true;vert_remap_array[mf->v4] = tot_bt_verts;tot_bt_verts++;} tot_bt_tris += (mf->v4 ? 2:1); /* a quad or a tri */ } } @@ -1629,9 +1629,9 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, MVert *v3= &mvert[mf->v3]; // the face indices - tri_pt[0]= vert_remap_array[mf->v1]; - tri_pt[1]= vert_remap_array[mf->v2]; - tri_pt[2]= vert_remap_array[mf->v3]; + tri_pt[0] = vert_remap_array[mf->v1]; + tri_pt[1] = vert_remap_array[mf->v2]; + tri_pt[2] = vert_remap_array[mf->v3]; tri_pt= tri_pt+3; if (tf) { @@ -1650,19 +1650,19 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, // the vertex location if (vert_tag_array[mf->v1]==true) { /* *** v1 *** */ - vert_tag_array[mf->v1]= false; + vert_tag_array[mf->v1] = false; *bt++ = v1->co[0]; *bt++ = v1->co[1]; *bt++ = v1->co[2]; } if (vert_tag_array[mf->v2]==true) { /* *** v2 *** */ - vert_tag_array[mf->v2]= false; + vert_tag_array[mf->v2] = false; *bt++ = v2->co[0]; *bt++ = v2->co[1]; *bt++ = v2->co[2]; } if (vert_tag_array[mf->v3]==true) { /* *** v3 *** */ - vert_tag_array[mf->v3]= false; + vert_tag_array[mf->v3] = false; *bt++ = v3->co[0]; *bt++ = v3->co[1]; *bt++ = v3->co[2]; @@ -1672,9 +1672,9 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, { MVert *v4= &mvert[mf->v4]; - tri_pt[0]= vert_remap_array[mf->v1]; - tri_pt[1]= vert_remap_array[mf->v3]; - tri_pt[2]= vert_remap_array[mf->v4]; + tri_pt[0] = vert_remap_array[mf->v1]; + tri_pt[1] = vert_remap_array[mf->v3]; + tri_pt[2] = vert_remap_array[mf->v4]; tri_pt= tri_pt+3; if (tf) { @@ -1692,8 +1692,8 @@ bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, DerivedMesh* dm, poly_index_pt++; // the vertex location - if (vert_tag_array[mf->v4]==true) { /* *** v4 *** */ - vert_tag_array[mf->v4]= false; + if (vert_tag_array[mf->v4] == true) { /* *** v4 *** */ + vert_tag_array[mf->v4] = false; *bt++ = v4->co[0]; *bt++ = v4->co[1]; *bt++ = v4->co[2]; @@ -1832,8 +1832,8 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject* gameobj, class RA if (vert_tag_array[v_orig]==false) { - vert_tag_array[v_orig]= true; - vert_remap_array[v_orig]= tot_bt_verts; + vert_tag_array[v_orig] = true; + vert_remap_array[v_orig] = tot_bt_verts; tot_bt_verts++; } } @@ -1880,7 +1880,7 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject* gameobj, class RA *bt++ = mv->co[1]; *bt++ = mv->co[2]; - vert_tag_array[v_orig]= false; + vert_tag_array[v_orig] = false; } *tri_pt++ = vert_remap_array[v_orig]; uv_pt->uv[0] = tf->uv[*fv_pt][0]; @@ -1941,7 +1941,7 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject* gameobj, class RA /* transverts are only used for deformed RAS_Meshes, the RAS_TexVert data * is too hard to get at, see below for details */ - float (*transverts)[3]= NULL; + float (*transverts)[3] = NULL; int transverts_tot= 0; /* with deformed meshes - should always be greater then the max orginal index, or we get crashes */ if (deformer) { @@ -1971,8 +1971,8 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject* gameobj, class RA v_orig= poly->GetVertex(i)->getOrigIndex(); if (vert_tag_array[v_orig]==false) { - vert_tag_array[v_orig]= true; - vert_remap_array[v_orig]= tot_bt_verts; + vert_tag_array[v_orig] = true; + vert_remap_array[v_orig] = tot_bt_verts; tot_bt_verts++; } } @@ -2025,14 +2025,14 @@ bool CcdShapeConstructionInfo::UpdateMesh(class KX_GameObject* gameobj, class RA *bt++ = xyz[2]; } - vert_tag_array[v_orig]= false; + vert_tag_array[v_orig] = false; } *tri_pt++ = vert_remap_array[v_orig]; } } - m_polygonIndexArray[p]= p; /* dumb counting */ + m_polygonIndexArray[p] = p; /* dumb counting */ } } diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp index 82a60e756d7..e43ddb303e9 100644 --- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp +++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp @@ -1078,7 +1078,7 @@ static bool GetHitTriangle(btCollisionShape* shape, CcdShapeConstructionInfo* sh const btVector3& meshScaling = shape->getLocalScaling(); for (int j=2;j>=0;j--) { - int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j]; + int graphicsindex = (indicestype == PHY_SHORT) ? ((unsigned short *)gfxbase)[j] : gfxbase[j]; btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride); @@ -1517,8 +1517,8 @@ struct OcclusionBuffer return(true); } } - } else if (width == 1) - { + } + else if (width == 1) { // Degenerated in at least 2 vertical lines // The algorithm below doesn't work when face has a single pixel width // We cannot use general formulas because the plane is degenerated. @@ -1529,16 +1529,16 @@ struct OcclusionBuffer if (y[0] > y[1]) { ytmp=y[1];y[1]=y[0];y[0]=ytmp;ztmp=z[1];z[1]=z[0];z[0]=ztmp; } if (y[0] > y[2]) { ytmp=y[2];y[2]=y[0];y[0]=ytmp;ztmp=z[2];z[2]=z[0];z[0]=ztmp; } if (y[1] > y[2]) { ytmp=y[2];y[2]=y[1];y[1]=ytmp;ztmp=z[2];z[2]=z[1];z[1]=ztmp; } - int dy[]={ y[0]-y[1], - y[1]-y[2], - y[2]-y[0]}; + int dy[] = {y[0] - y[1], + y[1] - y[2], + y[2] - y[0]}; btScalar dzy[3]; - dzy[0] = (dy[0]) ? (z[0]-z[1])/dy[0] : btScalar(0.f); - dzy[1] = (dy[1]) ? (z[1]-z[2])/dy[1] : btScalar(0.f); - dzy[2] = (dy[2]) ? (z[2]-z[0])/dy[2] : btScalar(0.f); - btScalar v[3] = { dzy[0]*(miy-y[0])+z[0], - dzy[1]*(miy-y[1])+z[1], - dzy[2]*(miy-y[2])+z[2] }; + dzy[0] = (dy[0]) ? (z[0] - z[1]) / dy[0] : btScalar(0.f); + dzy[1] = (dy[1]) ? (z[1] - z[2]) / dy[1] : btScalar(0.f); + dzy[2] = (dy[2]) ? (z[2] - z[0]) / dy[2] : btScalar(0.f); + btScalar v[3] = {dzy[0] * (miy - y[0]) + z[0], + dzy[1] * (miy - y[1]) + z[1], + dzy[2] * (miy - y[2]) + z[2]}; dy[0] = y[1]-y[0]; dy[1] = y[0]-y[1]; dy[2] = y[2]-y[0]; @@ -1566,16 +1566,16 @@ struct OcclusionBuffer if (x[0] > x[1]) { xtmp=x[1];x[1]=x[0];x[0]=xtmp;ztmp=z[1];z[1]=z[0];z[0]=ztmp; } if (x[0] > x[2]) { xtmp=x[2];x[2]=x[0];x[0]=xtmp;ztmp=z[2];z[2]=z[0];z[0]=ztmp; } if (x[1] > x[2]) { xtmp=x[2];x[2]=x[1];x[1]=xtmp;ztmp=z[2];z[2]=z[1];z[1]=ztmp; } - int dx[]={ x[0]-x[1], - x[1]-x[2], - x[2]-x[0]}; + int dx[] = {x[0] - x[1], + x[1] - x[2], + x[2] - x[0]}; btScalar dzx[3]; dzx[0] = (dx[0]) ? (z[0]-z[1])/dx[0] : btScalar(0.f); dzx[1] = (dx[1]) ? (z[1]-z[2])/dx[1] : btScalar(0.f); dzx[2] = (dx[2]) ? (z[2]-z[0])/dx[2] : btScalar(0.f); - btScalar v[3] = { dzx[0]*(mix-x[0])+z[0], - dzx[1]*(mix-x[1])+z[1], - dzx[2]*(mix-x[2])+z[2] }; + btScalar v[3] = {dzx[0] * (mix - x[0]) + z[0], + dzx[1] * (mix - x[1]) + z[1], + dzx[2] * (mix - x[2]) + z[2]}; dx[0] = x[1]-x[0]; dx[1] = x[0]-x[1]; dx[2] = x[2]-x[0]; @@ -1592,24 +1592,24 @@ struct OcclusionBuffer v[0] += dzx[0]; v[1] += dzx[1]; v[2] += dzx[2]; dx[0]--; dx[1]++, dx[2]--; } - } else - { + } + else { // general case - const int dx[]={ y[0]-y[1], - y[1]-y[2], - y[2]-y[0]}; - const int dy[]={ x[1]-x[0]-dx[0]*width, - x[2]-x[1]-dx[1]*width, - x[0]-x[2]-dx[2]*width}; - const int a=x[2]*y[0]+x[0]*y[1]-x[2]*y[1]-x[0]*y[2]+x[1]*y[2]-x[1]*y[0]; - const btScalar ia=1/(btScalar)a; - const btScalar dzx=ia*(y[2]*(z[1]-z[0])+y[1]*(z[0]-z[2])+y[0]*(z[2]-z[1])); - const btScalar dzy=ia*(x[2]*(z[0]-z[1])+x[0]*(z[1]-z[2])+x[1]*(z[2]-z[0]))-(dzx*width); - int c[]={ miy*x[1]+mix*y[0]-x[1]*y[0]-mix*y[1]+x[0]*y[1]-miy*x[0], - miy*x[2]+mix*y[1]-x[2]*y[1]-mix*y[2]+x[1]*y[2]-miy*x[1], - miy*x[0]+mix*y[2]-x[0]*y[2]-mix*y[0]+x[2]*y[0]-miy*x[2]}; - btScalar v=ia*((z[2]*c[0])+(z[0]*c[1])+(z[1]*c[2])); - btScalar* scan=&m_buffer[miy*m_sizes[0]]; + const int dx[] = {y[0] - y[1], + y[1] - y[2], + y[2] - y[0]}; + const int dy[] = {x[1] - x[0] - dx[0] * width, + x[2] - x[1] - dx[1] * width, + x[0] - x[2] - dx[2] * width}; + const int a = x[2] * y[0] + x[0] * y[1] - x[2] * y[1] - x[0] * y[2] + x[1] * y[2] - x[1] * y[0]; + const btScalar ia = 1 / (btScalar)a; + const btScalar dzx = ia*(y[2]*(z[1]-z[0])+y[1]*(z[0]-z[2])+y[0]*(z[2]-z[1])); + const btScalar dzy = ia*(x[2]*(z[0]-z[1])+x[0]*(z[1]-z[2])+x[1]*(z[2]-z[0]))-(dzx*width); + int c[] = {miy*x[1]+mix*y[0]-x[1]*y[0]-mix*y[1]+x[0]*y[1]-miy*x[0], + miy*x[2]+mix*y[1]-x[2]*y[1]-mix*y[2]+x[1]*y[2]-miy*x[1], + miy*x[0]+mix*y[2]-x[0]*y[2]-mix*y[0]+x[2]*y[0]-miy*x[2]}; + btScalar v = ia*((z[2]*c[0])+(z[0]*c[1])+(z[1]*c[2])); + btScalar *scan = &m_buffer[miy*m_sizes[0]]; for (int iy=miy;iy<mxy;++iy) { for (int ix=mix;ix<mxx;++ix) @@ -1696,18 +1696,18 @@ struct OcclusionBuffer // the box is clipped, it's probably a large box, don't waste our time to check if ((x[i][2]+x[i][3])<=0) return(true); } - static const int d[]={ 1,0,3,2, - 4,5,6,7, - 4,7,3,0, - 6,5,1,2, - 7,6,2,3, - 5,4,0,1}; + static const int d[] = {1,0,3,2, + 4,5,6,7, + 4,7,3,0, + 6,5,1,2, + 7,6,2,3, + 5,4,0,1}; for (unsigned int i=0;i<(sizeof(d)/sizeof(d[0]));) { - const btVector4 p[]={ x[d[i++]], - x[d[i++]], - x[d[i++]], - x[d[i++]]}; + const btVector4 p[] = {x[d[i++]], + x[d[i++]], + x[d[i++]], + x[d[i++]]}; if (clipDraw<4,QueryOCL>(p,1.f,0.f)) return(true); } @@ -1966,8 +1966,8 @@ void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint; int transMotorIndex = param-6; btTranslationalLimitMotor* transMotor = genCons->getTranslationalLimitMotor(); - transMotor->m_targetVelocity[transMotorIndex]= value0; - transMotor->m_maxMotorForce[transMotorIndex]=value1; + transMotor->m_targetVelocity[transMotorIndex] = value0; + transMotor->m_maxMotorForce[transMotorIndex] = value1; transMotor->m_enableMotor[transMotorIndex] = (value1>0.f); break; } diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp index 0ae8908e946..cf869e71945 100644 --- a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp +++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp @@ -153,8 +153,7 @@ unsigned int RAS_2DFilterManager::CreateShaderProgram(const char* shadersource) unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode) { - switch(filtermode) - { + switch (filtermode) { case RAS_2DFILTER_BLUR: return CreateShaderProgram(BlurFragmentShader); case RAS_2DFILTER_SHARPEN: diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp index 3c49d6e5289..f24e3397801 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp +++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp @@ -34,7 +34,6 @@ # pragma warning (disable:4786) #endif -#include "CTR_Map.h" #include "RAS_MaterialBucket.h" #include "STR_HashedString.h" #include "RAS_MeshObject.h" @@ -129,7 +128,7 @@ void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList RAS_MaterialBucket* bucket = *bit; RAS_MeshSlot* ms; // remove the mesh slot form the list, it culls them automatically for next frame - while((ms = bucket->GetNextActiveMeshSlot())) { + while ((ms = bucket->GetNextActiveMeshSlot())) { slots[i++].set(ms, bucket, pnorm); } } @@ -156,7 +155,7 @@ void RAS_BucketManager::RenderAlphaBuckets( for (sit=slots.begin(); sit!=slots.end(); ++sit) { rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj); - while(sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools)) + while (sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools)) sit->m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(sit->m_ms)); // make this mesh slot culled automatically for next frame @@ -179,8 +178,7 @@ void RAS_BucketManager::RenderSolidBuckets( RAS_MaterialBucket* bucket = *bit; RAS_MeshSlot* ms; // remove the mesh slot form the list, it culls them automatically for next frame - while((ms = bucket->GetNextActiveMeshSlot())) - { + while ((ms = bucket->GetNextActiveMeshSlot())) { rendertools->SetClientObject(rasty, ms->m_clientObj); while (bucket->ActivateMaterial(cameratrans, rasty, rendertools)) bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *ms); @@ -219,7 +217,7 @@ void RAS_BucketManager::RenderSolidBuckets( for (sit=slots.begin(); sit!=slots.end(); ++sit) { rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj); - while(sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools)) + while (sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools)) sit->m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(sit->m_ms)); } #endif diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h index c85a9f65d27..78125a7bbb3 100644 --- a/source/gameengine/Rasterizer/RAS_BucketManager.h +++ b/source/gameengine/Rasterizer/RAS_BucketManager.h @@ -34,7 +34,6 @@ #include "MT_Transform.h" #include "RAS_MaterialBucket.h" -#include "CTR_Map.h" #include <vector> diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp index 0cb6bc7439a..9fb47117f1d 100644 --- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp +++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp @@ -73,7 +73,7 @@ RAS_MeshSlot::~RAS_MeshSlot() #ifdef USE_SPLIT Split(true); - while(m_joinedSlots.size()) + while (m_joinedSlots.size()) m_joinedSlots.front()->Split(true); #endif @@ -393,7 +393,7 @@ bool RAS_MeshSlot::Join(RAS_MeshSlot *target, MT_Scalar distance) target->m_joinedSlots.push_back(this); MT_Matrix4x4 ntransform = m_joinInvTransform.transposed(); - ntransform[0][3]= ntransform[1][3]= ntransform[2][3]= 0.0f; + ntransform[0][3] = ntransform[1][3] = ntransform[2][3] = 0.0f; for (begin(mit); !end(mit); next(mit)) for (i=mit.startvertex; i<mit.endvertex; i++) @@ -471,7 +471,7 @@ bool RAS_MeshSlot::Split(bool force) } MT_Matrix4x4 ntransform = m_joinInvTransform.inverse().transposed(); - ntransform[0][3]= ntransform[1][3]= ntransform[2][3]= 0.0f; + ntransform[0][3] = ntransform[1][3] = ntransform[2][3] = 0.0f; for (begin(mit); !end(mit); next(mit)) for (i=mit.startvertex; i<mit.endvertex; i++) diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp index 21d2e6d5a7b..2ccb9453b3d 100644 --- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp +++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp @@ -608,7 +608,7 @@ void RAS_MeshObject::CheckWeightCache(Object* obj) weights= (float*)MEM_mallocN(totvert*sizeof(float), "weights"); for (i=0; i < totvert; i++, dv++) { - weights[i]= defvert_find_weight(dv, defindex); + weights[i] = defvert_find_weight(dv, defindex); } kb->weights = weights; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp index 1f411a09586..d74aa134779 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp @@ -124,7 +124,7 @@ void RAS_ListRasterizer::RemoveListSlot(RAS_ListSlot* list) { if (list->m_flag & LIST_DERIVEDMESH) { RAS_DerivedMeshLists::iterator it = mDerivedMeshLists.begin(); - while(it != mDerivedMeshLists.end()) { + while (it != mDerivedMeshLists.end()) { RAS_ListSlots *slots = it->second; if (slots->size() > list->m_matnr && slots->at(list->m_matnr) == list) { (*slots)[list->m_matnr] = NULL; @@ -145,7 +145,7 @@ void RAS_ListRasterizer::RemoveListSlot(RAS_ListSlot* list) } } else { RAS_ArrayLists::iterator it = mArrayLists.begin(); - while(it != mArrayLists.end()) { + while (it != mArrayLists.end()) { if (it->second == list) { mArrayLists.erase(it); break; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index a0da1c79baa..dc96e972217 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -239,10 +239,10 @@ void RAS_OpenGLRasterizer::DisplayFog() glFogf(GL_FOG_DENSITY, 0.1f); glFogf(GL_FOG_START, m_fogstart); glFogf(GL_FOG_END, m_fogstart + m_fogdist); - params[0]= m_fogr; - params[1]= m_fogg; - params[2]= m_fogb; - params[3]= 0.0; + params[0] = m_fogr; + params[1] = m_fogg; + params[2] = m_fogb; + params[3] = 0.0; glFogfv(GL_FOG_COLOR, params); glEnable(GL_FOG); } @@ -447,8 +447,7 @@ void RAS_OpenGLRasterizer::SetRenderArea() switch (m_stereomode) { case RAS_STEREO_ABOVEBELOW: - switch(m_curreye) - { + switch (m_curreye) { case RAS_STEREO_LEFTEYE: // upper half of window area.SetLeft(0); @@ -716,53 +715,53 @@ void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv) glMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV2()); continue; } - switch(m_texco[unit]) { - case RAS_TEXCO_ORCO: - case RAS_TEXCO_GLOB: - glMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getXYZ()); - break; - case RAS_TEXCO_UV1: - glMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV1()); - break; - case RAS_TEXCO_NORM: - glMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getNormal()); - break; - case RAS_TEXTANGENT: - glMultiTexCoord4fvARB(GL_TEXTURE0_ARB+unit, tv.getTangent()); - break; - case RAS_TEXCO_UV2: - glMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV2()); - break; - default: - break; + switch (m_texco[unit]) { + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + glMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getXYZ()); + break; + case RAS_TEXCO_UV1: + glMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV1()); + break; + case RAS_TEXCO_NORM: + glMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getNormal()); + break; + case RAS_TEXTANGENT: + glMultiTexCoord4fvARB(GL_TEXTURE0_ARB+unit, tv.getTangent()); + break; + case RAS_TEXCO_UV2: + glMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV2()); + break; + default: + break; } } } if (GLEW_ARB_vertex_program) { for (unit=0; unit<m_attrib_num; unit++) { - switch(m_attrib[unit]) { - case RAS_TEXCO_ORCO: - case RAS_TEXCO_GLOB: - glVertexAttrib3fvARB(unit, tv.getXYZ()); - break; - case RAS_TEXCO_UV1: - glVertexAttrib2fvARB(unit, tv.getUV1()); - break; - case RAS_TEXCO_NORM: - glVertexAttrib3fvARB(unit, tv.getNormal()); - break; - case RAS_TEXTANGENT: - glVertexAttrib4fvARB(unit, tv.getTangent()); - break; - case RAS_TEXCO_UV2: - glVertexAttrib2fvARB(unit, tv.getUV2()); - break; - case RAS_TEXCO_VCOL: - glVertexAttrib4ubvARB(unit, tv.getRGBA()); - break; - default: - break; + switch (m_attrib[unit]) { + case RAS_TEXCO_ORCO: + case RAS_TEXCO_GLOB: + glVertexAttrib3fvARB(unit, tv.getXYZ()); + break; + case RAS_TEXCO_UV1: + glVertexAttrib2fvARB(unit, tv.getUV1()); + break; + case RAS_TEXCO_NORM: + glVertexAttrib3fvARB(unit, tv.getNormal()); + break; + case RAS_TEXTANGENT: + glVertexAttrib4fvARB(unit, tv.getTangent()); + break; + case RAS_TEXCO_UV2: + glVertexAttrib2fvARB(unit, tv.getUV2()); + break; + case RAS_TEXCO_VCOL: + glVertexAttrib4ubvARB(unit, tv.getRGBA()); + break; + default: + break; } } } @@ -1007,8 +1006,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix( near_div_focallength = frustnear / m_focallength; offset = 0.5f * m_eyeseparation * near_div_focallength; - switch(m_curreye) - { + switch (m_curreye) { case RAS_STEREO_LEFTEYE: left += offset; right += offset; @@ -1078,8 +1076,7 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, // vector between eyes eyeline = viewDir.cross(viewupVec); - switch(m_curreye) - { + switch (m_curreye) { case RAS_STEREO_LEFTEYE: { // translate to left by half the eye distance diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp index a36229c35d1..076acb0d153 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp @@ -246,8 +246,7 @@ void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv) glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert), tv->getUV2()); continue; } - switch(m_texco[unit]) - { + switch (m_texco[unit]) { case RAS_TEXCO_ORCO: case RAS_TEXCO_GLOB: glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getXYZ()); @@ -274,7 +273,7 @@ void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv) if (GLEW_ARB_vertex_program) { for (unit=0; unit<m_attrib_num; unit++) { - switch(m_attrib[unit]) { + switch (m_attrib[unit]) { case RAS_TEXCO_ORCO: case RAS_TEXCO_GLOB: glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getXYZ()); @@ -330,8 +329,7 @@ void RAS_VAOpenGLRasterizer::EnableTextures(bool enable) for (unit=0; unit<texco_num; unit++) { glClientActiveTextureARB(GL_TEXTURE0_ARB+unit); - switch(texco[unit]) - { + switch (texco[unit]) { case RAS_TEXCO_ORCO: case RAS_TEXCO_GLOB: case RAS_TEXCO_UV1: @@ -358,7 +356,7 @@ void RAS_VAOpenGLRasterizer::EnableTextures(bool enable) if (GLEW_ARB_vertex_program) { for (unit=0; unit<attrib_num; unit++) { - switch(attrib[unit]) { + switch (attrib[unit]) { case RAS_TEXCO_ORCO: case RAS_TEXCO_GLOB: case RAS_TEXCO_UV1: diff --git a/source/gameengine/Rasterizer/RAS_Polygon.cpp b/source/gameengine/Rasterizer/RAS_Polygon.cpp index f454d1c0204..74544a80efa 100644 --- a/source/gameengine/Rasterizer/RAS_Polygon.cpp +++ b/source/gameengine/Rasterizer/RAS_Polygon.cpp @@ -40,7 +40,7 @@ RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, i { m_bucket = bucket; m_darray = darray; - m_offset[0]= m_offset[1]= m_offset[2]= m_offset[3]= 0; + m_offset[0] = m_offset[1] = m_offset[2] = m_offset[3] = 0; m_numvert = numvert; // m_edgecode = 255; diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp index f74aa24232b..b60fae73e2a 100644 --- a/source/gameengine/Rasterizer/RAS_TexVert.cpp +++ b/source/gameengine/Rasterizer/RAS_TexVert.cpp @@ -77,7 +77,7 @@ void RAS_TexVert::SetXYZ(const MT_Point3& xyz) void RAS_TexVert::SetXYZ(const float *xyz) { - m_localxyz[0]= xyz[0]; m_localxyz[1]= xyz[1]; m_localxyz[2]= xyz[2]; + m_localxyz[0] = xyz[0]; m_localxyz[1] = xyz[1]; m_localxyz[2] = xyz[2]; } void RAS_TexVert::SetUV(const MT_Point2& uv) diff --git a/source/gameengine/Rasterizer/RAS_texmatrix.cpp b/source/gameengine/Rasterizer/RAS_texmatrix.cpp index 4399265c380..d335a38171f 100644 --- a/source/gameengine/Rasterizer/RAS_texmatrix.cpp +++ b/source/gameengine/Rasterizer/RAS_texmatrix.cpp @@ -93,10 +93,10 @@ int main() MT_Point2 puv0={0,0}; MT_Point3 pxyz0 (0,0,128); - MT_Scalar puv1[2]={1,0}; + MT_Scalar puv1[2] = {1,0}; MT_Point3 pxyz1(128,0,128); - MT_Scalar puv2[2]={1,1}; + MT_Scalar puv2[2] = {1,1}; MT_Point3 pxyz2(128,0,0); RAS_TexVert p0(pxyz0,puv0); diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp index 8c0d2b88c63..f30c80da434 100644 --- a/source/gameengine/SceneGraph/SG_Spatial.cpp +++ b/source/gameengine/SceneGraph/SG_Spatial.cpp @@ -103,7 +103,7 @@ SetParentRelation( /** * Update Spatial Data. - * Calculates WorldTransform., (either doing itsself or using the linked SGControllers) + * Calculates WorldTransform., (either doing its self or using the linked SGControllers) */ diff --git a/source/gameengine/VideoTexture/FilterBase.h b/source/gameengine/VideoTexture/FilterBase.h index 422cf86f23e..98bc495375a 100644 --- a/source/gameengine/VideoTexture/FilterBase.h +++ b/source/gameengine/VideoTexture/FilterBase.h @@ -95,6 +95,10 @@ protected: virtual unsigned int filter (unsigned int * src, short x, short y, short * size, unsigned int pixSize, unsigned int val = 0) { return val; } + /// filter pixel, source float buffer + virtual unsigned int filter (float * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val = 0) + { return val; } /// get source pixel size virtual unsigned int getPixelSize (void) { return 1; } diff --git a/source/gameengine/VideoTexture/FilterSource.h b/source/gameengine/VideoTexture/FilterSource.h index a4900e8c148..0e0a3e8d1b9 100644 --- a/source/gameengine/VideoTexture/FilterSource.h +++ b/source/gameengine/VideoTexture/FilterSource.h @@ -31,7 +31,6 @@ http://www.gnu.org/copyleft/lesser.txt. #include "FilterBase.h" - /// class for RGB24 conversion class FilterRGB24 : public FilterBase { @@ -97,6 +96,65 @@ protected: { VT_RGBA(val,src[2],src[1],src[0],0xFF); return val; } }; +/// class for Z_buffer conversion +class FilterZZZA : public FilterBase +{ +public: + /// constructor + FilterZZZA (void) {} + /// destructor + virtual ~FilterZZZA (void) {} + + /// get source pixel size + virtual unsigned int getPixelSize (void) { return 1; } + +protected: + /// filter pixel, source float buffer + virtual unsigned int filter (float * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val) + { + // calculate gray value + // convert float to unsigned char + unsigned int depth = int(src[0] * 255); + // return depth scale value + VT_R(val) = depth; + VT_G(val) = depth; + VT_B(val) = depth; + VT_A(val) = 0xFF; + + return val; + } +}; + + +/// class for Z_buffer conversion +class FilterDEPTH : public FilterBase +{ +public: + /// constructor + FilterDEPTH (void) {} + /// destructor + virtual ~FilterDEPTH (void) {} + + /// get source pixel size + virtual unsigned int getPixelSize (void) { return 1; } + +protected: + /// filter pixel, source float buffer + virtual unsigned int filter (float * src, short x, short y, + short * size, unsigned int pixSize, unsigned int val) + { + // Copy the float value straight away + // The user can retrieve the original float value by using + // 'F' mode in BGL buffer + memcpy(&val, src, sizeof (unsigned int)); + return val; + } +}; + + + + /// class for YV12 conversion class FilterYV12 : public FilterBase { diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp index 2de49795681..de54d8e8940 100644 --- a/source/gameengine/VideoTexture/ImageBase.cpp +++ b/source/gameengine/VideoTexture/ImageBase.cpp @@ -49,6 +49,8 @@ extern "C" { // constructor ImageBase::ImageBase (bool staticSrc) : m_image(NULL), m_imgSize(0), m_avail(false), m_scale(false), m_scaleChange(false), m_flip(false), +m_zbuff(false), +m_depth(false), m_staticSources(staticSrc), m_pyfilter(NULL) { m_size[0] = m_size[1] = 0; @@ -402,6 +404,18 @@ PyObject *Image_getImage (PyImage *self, char * mode) { buffer = BGL_MakeBuffer( GL_BYTE, 1, &dimensions, image); } + else if (!strcasecmp(mode, "F")) + { + // this mode returns the image as an array of float. + // This makes sense ONLY for the depth buffer: + // source = VideoTexture.ImageViewport() + // source.depth = True + // depth = VideoTexture.imageToArray(source, 'F') + + // adapt dimension from byte to float + dimensions /= sizeof(float); + buffer = BGL_MakeBuffer( GL_FLOAT, 1, &dimensions, image); + } else { int i, c, ncolor, pixels; @@ -532,6 +546,52 @@ int Image_setFlip (PyImage *self, PyObject *value, void *closure) return 0; } +// get zbuff +PyObject * Image_getZbuff (PyImage * self, void * closure) +{ + if (self->m_image != NULL && self->m_image->getZbuff()) Py_RETURN_TRUE; + else Py_RETURN_FALSE; +} + +// set zbuff +int Image_setZbuff (PyImage * self, PyObject * value, void * closure) +{ + // check parameter, report failure + if (value == NULL || !PyBool_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be a bool"); + return -1; + } + // set scale + if (self->m_image != NULL) self->m_image->setZbuff(value == Py_True); + // success + return 0; +} + +// get depth +PyObject * Image_getDepth (PyImage * self, void * closure) +{ + if (self->m_image != NULL && self->m_image->getDepth()) Py_RETURN_TRUE; + else Py_RETURN_FALSE; +} + +// set depth +int Image_setDepth (PyImage * self, PyObject * value, void * closure) +{ + // check parameter, report failure + if (value == NULL || !PyBool_Check(value)) + { + PyErr_SetString(PyExc_TypeError, "The value must be a bool"); + return -1; + } + // set scale + if (self->m_image != NULL) self->m_image->setDepth(value == Py_True); + // success + return 0; +} + + + // get filter source object PyObject *Image_getSource (PyImage *self, PyObject *args) diff --git a/source/gameengine/VideoTexture/ImageBase.h b/source/gameengine/VideoTexture/ImageBase.h index bb3f0c19e4b..a9f25f61406 100644 --- a/source/gameengine/VideoTexture/ImageBase.h +++ b/source/gameengine/VideoTexture/ImageBase.h @@ -78,6 +78,14 @@ public: bool getFlip (void) { return m_flip; } /// set vertical flip void setFlip (bool flip) { m_flip = flip; } + /// get Z buffer + bool getZbuff (void) { return m_zbuff; } + /// set Z buffer + void setZbuff (bool zbuff) { m_zbuff = zbuff; } + /// get depth + bool getDepth (void) { return m_depth; } + /// set depth + void setDepth (bool depth) { m_depth = depth; } /// get source object PyImage * getSource (const char * id); @@ -111,6 +119,10 @@ protected: bool m_scaleChange; /// flip image vertically bool m_flip; + /// use the Z buffer as a texture + bool m_zbuff; + /// extract the Z buffer with unisgned int precision + bool m_depth; /// source image list ImageSourceList m_sources; @@ -347,7 +359,15 @@ int Image_setFlip (PyImage *self, PyObject *value, void *closure); PyObject *Image_getSource (PyImage *self, PyObject *args); // set filter source object PyObject *Image_setSource (PyImage *self, PyObject *args); - +// get Z buffer +PyObject * Image_getZbuff (PyImage * self, void * closure); +// set Z buffer +int Image_setZbuff (PyImage * self, PyObject * value, void * closure); +// get depth +PyObject * Image_getDepth (PyImage * self, void * closure); +// set depth +int Image_setDepth (PyImage * self, PyObject * value, void * closure); + // get pixel filter object PyObject *Image_getFilter (PyImage *self, void *closure); // set pixel filter object diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp index 2135d0a07eb..85857165403 100644 --- a/source/gameengine/VideoTexture/ImageRender.cpp +++ b/source/gameengine/VideoTexture/ImageRender.cpp @@ -385,6 +385,8 @@ static PyGetSetDef imageRenderGetSets[] = {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL}, {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbor)", NULL}, {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL}, + {(char*)"zbuff", (getter)Image_getZbuff, (setter)Image_setZbuff, (char*)"use depth buffer as texture", NULL}, + {(char*)"depth", (getter)Image_getDepth, (setter)Image_setDepth, (char*)"get depth information from z-buffer using unsigned int precision", NULL}, {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL}, {NULL} }; @@ -547,6 +549,8 @@ static PyGetSetDef imageMirrorGetSets[] = {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL}, {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbor)", NULL}, {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL}, + {(char*)"zbuff", (getter)Image_getZbuff, (setter)Image_setZbuff, (char*)"use depth buffer as texture", NULL}, + {(char*)"depth", (getter)Image_getDepth, (setter)Image_setDepth, (char*)"get depth information from z-buffer using unsigned int precision", NULL}, {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL}, {NULL} }; diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp index 9b503efcf39..0836422576f 100644 --- a/source/gameengine/VideoTexture/ImageViewport.cpp +++ b/source/gameengine/VideoTexture/ImageViewport.cpp @@ -50,6 +50,8 @@ ImageViewport::ImageViewport (void) : m_alpha(false), m_texInit(false) //glGetIntegerv(GL_VIEWPORT, m_viewport); // create buffer for viewport image + // Warning: this buffer is also used to get the depth buffer as an array of + // float (1 float = 4 bytes per pixel) m_viewportImage = new BYTE [4 * getViewportSize()[0] * getViewportSize()[1]]; // set attributes setWhole(false); @@ -57,7 +59,9 @@ ImageViewport::ImageViewport (void) : m_alpha(false), m_texInit(false) // destructor ImageViewport::~ImageViewport (void) -{ delete [] m_viewportImage; } +{ + delete [] m_viewportImage; +} // use whole viewport to capture image @@ -131,7 +135,7 @@ void ImageViewport::calcImage (unsigned int texId, double ts) } // if texture can be directly created if (texId != 0 && m_pyfilter == NULL && m_capSize[0] == calcSize(m_capSize[0]) - && m_capSize[1] == calcSize(m_capSize[1]) && !m_flip) + && m_capSize[1] == calcSize(m_capSize[1]) && !m_flip && !m_zbuff && !m_depth) { // just copy current viewport to texture glBindTexture(GL_TEXTURE_2D, texId); @@ -142,6 +146,32 @@ void ImageViewport::calcImage (unsigned int texId, double ts) // otherwise copy viewport to buffer, if image is not available else if (!m_avail) { + if (m_zbuff) + { + // Use read pixels with the depth buffer + // *** misusing m_viewportImage here, but since it has the correct size + // (4 bytes per pixel = size of float) and we just need it to apply + // the filter, it's ok + glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], + GL_DEPTH_COMPONENT, GL_FLOAT, m_viewportImage); + // filter loaded data + FilterZZZA filt; + filterImage(filt, (float *)m_viewportImage, m_capSize); + } + else + + if (m_depth) + { + // Use read pixels with the depth buffer + // See warning above about m_viewportImage. + glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], + GL_DEPTH_COMPONENT, GL_FLOAT, m_viewportImage); + // filter loaded data + FilterDEPTH filt; + filterImage(filt, (float *)m_viewportImage, m_capSize); + } + else + // get frame buffer data if (m_alpha) { @@ -310,6 +340,8 @@ static PyGetSetDef imageViewportGetSets[] = {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL}, {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbor)", NULL}, {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL}, + {(char*)"zbuff", (getter)Image_getZbuff, (setter)Image_setZbuff, (char*)"use depth buffer as texture", NULL}, + {(char*)"depth", (getter)Image_getDepth, (setter)Image_setDepth, (char*)"get depth information from z-buffer as array of float", NULL}, {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL}, {NULL} }; diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index cf65362c31d..3f42d5c4fed 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -485,13 +485,13 @@ void VideoFFmpeg::stopCache() av_free(frame->frame); delete frame; } - while((packet = (CachePacket *)m_packetCacheBase.first) != NULL) + while ((packet = (CachePacket *)m_packetCacheBase.first) != NULL) { BLI_remlink(&m_packetCacheBase, packet); av_free_packet(&packet->packet); delete packet; } - while((packet = (CachePacket *)m_packetCacheFree.first) != NULL) + while ((packet = (CachePacket *)m_packetCacheFree.first) != NULL) { BLI_remlink(&m_packetCacheFree, packet); delete packet; @@ -921,7 +921,7 @@ AVFrame *VideoFFmpeg::grabFrame(long position) && m_preseek && position - (m_curPosition + 1) < m_preseek) { - while(av_read_frame(m_formatCtx, &packet)>=0) + while (av_read_frame(m_formatCtx, &packet)>=0) { if (packet.stream_index == m_videoStream) { @@ -996,7 +996,7 @@ AVFrame *VideoFFmpeg::grabFrame(long position) // find the correct frame, in case of streaming and no cache, it means just // return the next frame. This is not quite correct, may need more work - while(av_read_frame(m_formatCtx, &packet)>=0) + while (av_read_frame(m_formatCtx, &packet) >= 0) { if (packet.stream_index == m_videoStream) { diff --git a/source/tests/rna_array.py b/source/tests/rna_array.py index 06b4735cc0d..a2241dff108 100644 --- a/source/tests/rna_array.py +++ b/source/tests/rna_array.py @@ -98,14 +98,14 @@ class TestArray(unittest.TestCase): for arr, rand_func in zip((test.farr, test.iarr, test.barr), (rand_float, rand_int, rand_bool)): for i in range(len(arr)): val= rand_func() - arr[i]= val + arr[i] = val self.assertEqual(arr[i], val) # float prop should accept also int for i in range(len(test.farr)): val= rand_int() - test.farr[i]= val + test.farr[i] = val self.assertEqual(test.farr[i], float(val)) # @@ -115,7 +115,7 @@ class TestArray(unittest.TestCase): arr[4] = 1.0 def assign_bad_type(arr): - arr[1]= "123" + arr[1] = "123" for arr in [test.farr, test.iarr, test.barr]: self.assertRaises(IndexError, assign_bad_index, arr) @@ -183,7 +183,7 @@ class TestMArray(unittest.TestCase): rval= make_random_2d_array((4, 5), func) for i in range(3): - getattr(test, arr)[i]= rval + getattr(test, arr)[i] = rval self.assertEqual(prop_to_list(getattr(test, arr)[i]), rval) # arr[i][j] = x @@ -194,13 +194,13 @@ class TestMArray(unittest.TestCase): for i in range(3): for j in range(4): - arr[i][j]= rval + arr[i][j] = rval self.assertEqual(prop_to_list(arr[i][j]), rval) def test_assign_item_fail(self): def assign_wrong_size(arr, i, rval): - getattr(test, arr)[i]= rval + getattr(test, arr)[i] = rval # assign wrong size at level 2 for arr, func in zip(("fmarr", "imarr", "bmarr"), (rand_float, rand_int, rand_bool)): |